[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M77W6X1VMDFMZYNH849BR9G5":3,"skill-same:01M77W6X1VMDFMZYNH849BR9G5":59},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":36,"commitSha":37,"skillDirectory":38,"forksCount":39,"repositoryHtmlUrl":40,"repositoryHomepageUrl":41,"ownerHtmlUrl":42,"ownerBlogUrl":6,"ownerDescription":43,"updatedAt":44,"install":45,"resources":58},"01M77W6X1VMDFMZYNH849BR9G5","teneo-protocol-cli",null,"Teneo Protocol CLI — discover and query 400+ AI agents on the Teneo Protocol network. Manage rooms, handle x402 USDC micropayments, and auto-generate encrypted wallets. Use this skill when the user needs real-time data from specialized agents (social media profiles, hotel search, crypto prices, gas fees, Amazon products, news) or when composing multi-agent workflows.","Lord1Egypt\u002Fawesome-skill-forge","Lord1Egypt","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F99746359?v=4","01M7592YDNT0XK9WJ0T2MQVPDN","Mohamed Mounir Ali AL Keshita","01M75GRFNHC8VZNWEB8DKDE433",3,"MIT","https:\u002F\u002Fgithub.com\u002FLord1Egypt\u002Fawesome-skill-forge\u002Fblob\u002Fmaster\u002Fcommunity\u002Fclawhub\u002Ft\u002Fteneo-agent-sdk\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: teneo-protocol-cli\nversion: 2.0.0\ndescription: \"Teneo Protocol CLI — discover and query 400+ AI agents on the Teneo Protocol network. Manage rooms, handle x402 USDC micropayments, and auto-generate encrypted wallets. Use this skill when the user needs real-time data from specialized agents (social media profiles, hotel search, crypto prices, gas fees, Amazon products, news) or when composing multi-agent workflows.\"\nhomepage: https:\u002F\u002Fteneo-protocol.ai\nmetadata: {\"teneo\":{\"backend\":\"wss:\u002F\u002Fbackend.developer.chatroom.teneo-protocol.ai\u002Fws\",\"sdk\":\"https:\u002F\u002Fwww.npmjs.com\u002Fpackage\u002F@teneo-protocol\u002Fsdk\",\"chains\":[\"base:8453\",\"peaq:3338\",\"avalanche:43114\",\"xlayer:196\"],\"payment\":\"x402-usdc\"}}\n---\n\n# teneo-protocol-cli — CLI Gateway for the Teneo Agent Network\n\n## What This Skill Teaches You\n\nThis skill enables you to **consume** AI agents on the Teneo Protocol network. You will learn to:\n\n1. **Discover** every available agent, their commands, pricing, and capabilities\n2. **Inspect** any agent's full command interface, parameters, and billing model\n3. **Query** agents directly — free agents auto-confirm, paid agents auto-pay via x402 USDC micropayments\n4. **Manage rooms** — create private rooms, add\u002Fremove agents, control which agents you can query\n5. **Handle payments** — automatic USDC payments on Base, Peaq, Avalanche, or X Layer\n6. **Sign transactions** — handle on-chain transaction requests from agents (swaps, transfers) automatically\n7. **Manage wallets** — auto-generated encrypted wallets, balance checks, withdrawals to funder\n\n**When to use this skill:** Whenever you need real-time data that a Teneo agent provides — social media profiles (X\u002FTwitter, Instagram, TikTok, LinkedIn), hotel availability, crypto prices, gas fees, Amazon products, news, and more. Run `node ~\u002Fteneo-skill\u002Fteneo.ts list-agents` first to see everything available.\n\n---\n\n## Prerequisites\n\n- **Node.js 18+** (required — the CLI is a Node.js tool)\n- **USDC on a supported chain** (Base, Peaq, Avalanche, or X Layer) if querying paid agents\n- No wallet setup needed — a new wallet is auto-generated on first use\n\n---\n\n## Installation — Auto-Install If Missing\n\n**Before running any command, check if the CLI is set up. If not, install it automatically.**\n\n### Step 1: Check if the CLI exists\n\n```bash\ntest -f ~\u002Fteneo-skill\u002Fteneo.ts && echo \"INSTALLED\" || echo \"NOT_INSTALLED\"\n```\n\n### Step 2: If NOT_INSTALLED, set up the CLI\n\n```bash\nmkdir -p ~\u002Fteneo-skill && cd ~\u002Fteneo-skill && npm init -y && NODE_OPTIONS=\"--max-old-space-size=512\" npm install --prefer-offline @teneo-protocol\u002Fsdk@^3.0.0 commander@^12.1.0 dotenv@^16.0.0 viem@^2.21.0 tsx@^4.0.0\n```\n\nThen create the CLI script by writing the following content to `~\u002Fteneo-skill\u002Fteneo.ts`:\n\n\u003C!-- CLI_CODE -->\n```typescript\n#!\u002Fusr\u002Fbin\u002Fenv npx tsx\n\n\u002F**\n * Teneo Protocol CLI\n * SECURITY: Auto-generates a new wallet on first use. Never asks for existing keys.\n * The generated key is encrypted at rest (AES-256-GCM) and used for local signing only.\n * Only cryptographic signatures are transmitted — never the key itself.\n *\u002F\n\nimport \"dotenv\u002Fconfig\";\nimport { TeneoSDK, SDKConfigBuilder } from \"@teneo-protocol\u002Fsdk\";\nimport { Command } from \"commander\";\nimport {\n  createWalletClient,\n  createPublicClient,\n  http,\n  defineChain,\n  type Chain,\n} from \"viem\";\nimport { privateKeyToAccount, generatePrivateKey } from \"viem\u002Faccounts\";\nimport * as allChains from \"viem\u002Fchains\";\nimport * as nodeCrypto from \"node:crypto\";\nimport * as nodeFs from \"node:fs\";\nimport * as nodePath from \"node:path\";\nimport * as nodeOs from \"node:os\";\n\n\u002F\u002F ─── Config ──────────────────────────────────────────────────────────────────\n\nconst WS_URL =\n  process.env.TENEO_WS_URL ||\n  \"wss:\u002F\u002Fbackend.developer.chatroom.teneo-protocol.ai\u002Fws\";\nconst PRIVATE_KEY = process.env.TENEO_PRIVATE_KEY;\nconst DEFAULT_ROOM = process.env.TENEO_DEFAULT_ROOM || \"\";\nconst DEFAULT_CHAIN = process.env.TENEO_DEFAULT_CHAIN || \"base\";\n\n\u002F\u002F Build chain ID lookup from all viem-supported chains\nconst CHAIN_BY_ID: Record\u003Cnumber, Chain> = {};\nfor (const key of Object.keys(allChains)) {\n  const c = (allChains as Record\u003Cstring, unknown>)[key];\n  if (c && typeof c === \"object\" && \"id\" in c)\n    CHAIN_BY_ID[(c as Chain).id] = c as Chain;\n}\n\nfunction getChain(chainId: number): Chain {\n  if (CHAIN_BY_ID[chainId]) return CHAIN_BY_ID[chainId];\n  return defineChain({\n    id: chainId,\n    name: `Chain ${chainId}`,\n    nativeCurrency: { name: \"ETH\", symbol: \"ETH\", decimals: 18 },\n    rpcUrls: {\n      default: { http: [`https:\u002F\u002Frpc.chain${chainId}.org`] },\n    },\n  });\n}\n\n\u002F\u002F ─── Wallet Storage ──────────────────────────────────────────────────────────\n\nconst WALLET_DIR = nodePath.join(nodeOs.homedir(), \".teneo-wallet\");\nconst WALLET_FILE = nodePath.join(WALLET_DIR, \"wallet.json\");\nconst SECRET_FILE = nodePath.join(WALLET_DIR, \".secret\");\n\ninterface WalletData {\n  version: number;\n  address: string;\n  encryptedKey: string;\n  iv: string;\n  authTag: string;\n  createdAt: string;\n  funder: string | null;\n}\n\nfunction ensureWalletDir() {\n  if (!nodeFs.existsSync(WALLET_DIR)) {\n    nodeFs.mkdirSync(WALLET_DIR, { recursive: true, mode: 0o700 });\n  }\n}\n\nfunction getOrCreateMasterSecret(): Buffer {\n  ensureWalletDir();\n  if (nodeFs.existsSync(SECRET_FILE)) {\n    const hex = nodeFs.readFileSync(SECRET_FILE, \"utf8\").trim();\n    return Buffer.from(hex, \"hex\");\n  }\n  const secret = nodeCrypto.randomBytes(32);\n  nodeFs.writeFileSync(SECRET_FILE, secret.toString(\"hex\"), { mode: 0o600 });\n  nodeFs.chmodSync(SECRET_FILE, 0o600);\n  return secret;\n}\n\nfunction encryptPK(\n  pk: string,\n  masterSecret: Buffer\n): { encryptedKey: string; iv: string; authTag: string } {\n  const iv = nodeCrypto.randomBytes(12);\n  const cipher = nodeCrypto.createCipheriv(\"aes-256-gcm\", masterSecret, iv);\n  const encrypted = Buffer.concat([\n    cipher.update(pk, \"utf8\"),\n    cipher.final(),\n  ]);\n  return {\n    encryptedKey: encrypted.toString(\"base64\"),\n    iv: iv.toString(\"base64\"),\n    authTag: cipher.getAuthTag().toString(\"base64\"),\n  };\n}\n\nfunction decryptPK(\n  encryptedKey: string,\n  iv: string,\n  authTag: string,\n  masterSecret: Buffer\n): string {\n  const decipher = nodeCrypto.createDecipheriv(\n    \"aes-256-gcm\",\n    masterSecret,\n    Buffer.from(iv, \"base64\")\n  );\n  decipher.setAuthTag(Buffer.from(authTag, \"base64\"));\n  const decrypted = Buffer.concat([\n    decipher.update(Buffer.from(encryptedKey, \"base64\")),\n    decipher.final(),\n  ]);\n  return decrypted.toString(\"utf8\");\n}\n\nfunction loadWallet(): WalletData | null {\n  if (!nodeFs.existsSync(WALLET_FILE)) return null;\n  try {\n    return JSON.parse(nodeFs.readFileSync(WALLET_FILE, \"utf8\"));\n  } catch {\n    return null;\n  }\n}\n\nfunction saveWallet(data: WalletData) {\n  ensureWalletDir();\n  nodeFs.writeFileSync(WALLET_FILE, JSON.stringify(data, null, 2), {\n    mode: 0o600,\n  });\n  nodeFs.chmodSync(WALLET_FILE, 0o600);\n}\n\nfunction getWalletAddress(): string {\n  const wallet = loadWallet();\n  if (wallet) return wallet.address;\n  if (PRIVATE_KEY) {\n    const key = PRIVATE_KEY.startsWith(\"0x\")\n      ? PRIVATE_KEY\n      : `0x${PRIVATE_KEY}`;\n    return privateKeyToAccount(key as `0x${string}`).address;\n  }\n  return fail(\"No wallet found. Run any command to auto-generate one.\");\n}\n\n\u002F\u002F ─── USDC Chain Config ───────────────────────────────────────────────────────\n\nconst USDC_ADDRESSES: Record\u003Cstring, `0x${string}`> = {\n  base: \"0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913\",\n  avax: \"0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E\",\n  peaq: \"0xbbA60da06c2c5424f03f7434542280FCAd453d10\",\n  xlayer: \"0x74b7F16337b8972027F6196A17a631aC6dE26d22\",\n};\n\nconst WALLET_CHAIN_MAP: Record\u003Cstring, Chain> = {\n  base: allChains.base,\n  avax: allChains.avalanche,\n  peaq: defineChain({\n    id: 3338,\n    name: \"PEAQ\",\n    nativeCurrency: { name: \"PEAQ\", symbol: \"PEAQ\", decimals: 18 },\n    rpcUrls: {\n      default: { http: [\"https:\u002F\u002Fpeaq.api.onfinality.io\u002Fpublic\"] },\n    },\n  }),\n  xlayer: defineChain({\n    id: 196,\n    name: \"XLayer\",\n    nativeCurrency: { name: \"OKB\", symbol: \"OKB\", decimals: 18 },\n    rpcUrls: { default: { http: [\"https:\u002F\u002Frpc.xlayer.tech\"] } },\n  }),\n};\n\nconst ERC20_BALANCE_ABI = [\n  {\n    inputs: [{ name: \"account\", type: \"address\" }],\n    name: \"balanceOf\",\n    outputs: [{ name: \"\", type: \"uint256\" }],\n    stateMutability: \"view\",\n    type: \"function\",\n  },\n] as const;\n\nconst ERC20_TRANSFER_ABI = [\n  {\n    inputs: [\n      { name: \"to\", type: \"address\" },\n      { name: \"amount\", type: \"uint256\" },\n    ],\n    name: \"transfer\",\n    outputs: [{ name: \"\", type: \"bool\" }],\n    stateMutability: \"nonpayable\",\n    type: \"function\",\n  },\n] as const;\n\nconst ERC20_TRANSFER_EVENT = {\n  type: \"event\",\n  name: \"Transfer\",\n  inputs: [\n    { name: \"from\", type: \"address\", indexed: true },\n    { name: \"to\", type: \"address\", indexed: true },\n    { name: \"value\", type: \"uint256\", indexed: false },\n  ],\n} as const;\n\nasync function detectFunder(\n  walletAddress: string\n): Promise\u003C{ funder: string; chain: string } | null> {\n  for (const chainName of [\"base\", \"avax\", \"peaq\", \"xlayer\"]) {\n    const chain = WALLET_CHAIN_MAP[chainName];\n    const usdcAddr = USDC_ADDRESSES[chainName];\n    if (!chain || !usdcAddr) continue;\n    try {\n      const client = createPublicClient({ chain, transport: http() });\n      const logs = await client.getLogs({\n        address: usdcAddr,\n        event: ERC20_TRANSFER_EVENT,\n        args: { to: walletAddress as `0x${string}` },\n        fromBlock: 0n,\n        toBlock: \"latest\",\n      });\n      if (logs.length > 0) {\n        logs.sort(\n          (a, b) =>\n            Number((a.blockNumber ?? 0n) - (b.blockNumber ?? 0n))\n        );\n        const from = logs[0].args.from;\n        if (from) return { funder: from, chain: chainName };\n      }\n    } catch {\n      \u002F\u002F Skip chain on error\n    }\n  }\n  return null;\n}\n\n\u002F\u002F ─── Output Helpers ──────────────────────────────────────────────────────────\n\nconst JSON_FLAG = process.argv.includes(\"--json\");\n\nfunction out(data: unknown) {\n  console.log(JSON.stringify(data, null, 2));\n}\n\nfunction fail(msg: string): never {\n  if (JSON_FLAG) console.error(JSON.stringify({ error: msg }));\n  else console.error(`Error: ${msg}`);\n  process.exit(1);\n}\n\nfunction pad(str: string, len: number): string {\n  return str.length >= len\n    ? str.substring(0, len - 1) + \" \"\n    : str + \" \".repeat(len - str.length);\n}\n\nfunction padCenter(str: string, len: number): string {\n  if (str.length >= len) return str.substring(0, len);\n  const left = Math.floor((len - str.length) \u002F 2);\n  const right = len - str.length - left;\n  return \" \".repeat(left) + str + \" \".repeat(right);\n}\n\nfunction parseCommands(agent: any): any[] {\n  if (!agent.commands) return [];\n  if (Array.isArray(agent.commands)) return agent.commands;\n  try {\n    return JSON.parse(agent.commands);\n  } catch {\n    return [];\n  }\n}\n\nfunction formatPrice(cmd: any): string {\n  if (!cmd.pricePerUnit || cmd.pricePerUnit === 0) return \"FREE\";\n  const unit = cmd.taskUnit === \"per-item\" ? \"\u002Fitem\" : \"\u002Fquery\";\n  return `${cmd.pricePerUnit} USDC${unit}`;\n}\n\nfunction requireKey(): string {\n  \u002F\u002F Tier 1: Environment variable\n  if (PRIVATE_KEY) return PRIVATE_KEY;\n\n  \u002F\u002F Tier 2: Encrypted wallet file\n  const wallet = loadWallet();\n  if (wallet) {\n    const secret = getOrCreateMasterSecret();\n    return decryptPK(wallet.encryptedKey, wallet.iv, wallet.authTag, secret);\n  }\n\n  \u002F\u002F Tier 3: Auto-generate new wallet\n  const masterSecret = getOrCreateMasterSecret();\n  const newKey = generatePrivateKey();\n  const account = privateKeyToAccount(newKey);\n  const encrypted = encryptPK(newKey, masterSecret);\n\n  saveWallet({\n    version: 1,\n    address: account.address,\n    encryptedKey: encrypted.encryptedKey,\n    iv: encrypted.iv,\n    authTag: encrypted.authTag,\n    createdAt: new Date().toISOString(),\n    funder: null,\n  });\n\n  console.error(\n    JSON.stringify({\n      info: \"Wallet auto-generated\",\n      address: account.address,\n      note: \"Send USDC to this address on base, avax, peaq, or xlayer to start using paid agents.\",\n    })\n  );\n\n  return newKey;\n}\n\nfunction resolveRoom(opt?: string): string {\n  const room = opt || DEFAULT_ROOM;\n  if (!room)\n    fail(\"Room ID required. Pass --room \u003Cid> or set TENEO_DEFAULT_ROOM.\");\n  return room;\n}\n\n\u002F\u002F ─── SDK Lifecycle ───────────────────────────────────────────────────────────\n\nconst MAX_RETRIES = 3;\nconst RETRY_DELAY = 5000;\nconst SHORT_TIMEOUT = 20000;\n\nasync function sleep(ms: number) {\n  return new Promise((r) => setTimeout(r, ms));\n}\n\ninterface SDKOpts {\n  autoJoinRoom?: string;\n  payments?: boolean;\n  kickAgent?: string;\n}\n\nfunction buildSDK(key: string, opts?: SDKOpts): TeneoSDK {\n  const builder = new SDKConfigBuilder()\n    .withWebSocketUrl(WS_URL)\n    .withAuthentication(key)\n    .withReconnection({ enabled: true, delay: 3000, maxAttempts: 5 })\n    .withCache(true, 600000, 500);\n  if (opts?.autoJoinRoom && !opts.autoJoinRoom.startsWith(\"private_\"))\n    builder.withAutoJoinPublicRooms([opts.autoJoinRoom]);\n  if (opts?.payments)\n    builder.withPayments({ autoApprove: true, quoteTimeout: 120000 });\n  return new TeneoSDK(builder.build());\n}\n\nfunction registerTxSigner(sdk: TeneoSDK) {\n  const key = requireKey();\n  const account = privateKeyToAccount(\n    (key.startsWith(\"0x\") ? key : `0x${key}`) as `0x${string}`\n  );\n\n  sdk.on(\"wallet:tx_requested\", async (data: any) => {\n    const { taskId, tx, agentName, description } = data;\n    console.error(\n      JSON.stringify({\n        info: `Transaction requested by ${agentName || \"agent\"}`,\n        description: description || \"on-chain transaction\",\n        to: tx.to,\n        value: tx.value,\n        chainId: tx.chainId,\n      })\n    );\n\n    try {\n      const chain = getChain(tx.chainId);\n      const walletClient = createWalletClient({\n        account,\n        chain,\n        transport: http(),\n      });\n      const txHash = await walletClient.sendTransaction({\n        to: tx.to,\n        value: tx.value ? BigInt(tx.value) : 0n,\n        data: tx.data || undefined,\n        chain,\n      });\n      console.error(\n        JSON.stringify({ info: \"Transaction sent\", txHash, chainId: tx.chainId })\n      );\n      await (sdk as any).sendTxResult(taskId, \"confirmed\", txHash);\n    } catch (err: any) {\n      console.error(\n        JSON.stringify({ error: `Transaction failed: ${err.message}` })\n      );\n      await (sdk as any).sendTxResult(taskId, \"failed\", undefined, err.message);\n    }\n  });\n}\n\nasync function kickAgent(sdk: TeneoSDK, roomId: string, agentId: string) {\n  try {\n    console.error(\n      JSON.stringify({\n        warn: `Kicking agent ${agentId} from room to reset dangling WebSocket...`,\n      })\n    );\n    await sdk.removeAgentFromRoom(roomId, agentId);\n    await sleep(2000);\n    await sdk.addAgentToRoom(roomId, agentId);\n    await sleep(3000);\n    console.error(\n      JSON.stringify({ info: `Agent ${agentId} re-added to room ${roomId}.` })\n    );\n  } catch (e: any) {\n    console.error(\n      JSON.stringify({ warn: `Kick failed (non-fatal): ${e.message}` })\n    );\n  }\n}\n\nasync function withSDK\u003CT>(\n  fn: (sdk: TeneoSDK, attempt: number) => Promise\u003CT>,\n  opts?: SDKOpts\n): Promise\u003CT> {\n  let lastErr: Error | undefined;\n  for (let attempt = 1; attempt \u003C= MAX_RETRIES; attempt++) {\n    let sdk: TeneoSDK | null = null;\n    try {\n      const key = requireKey();\n      sdk = buildSDK(key, opts);\n      await sdk.connect();\n      registerTxSigner(sdk);\n      return await fn(sdk, attempt);\n    } catch (err: any) {\n      lastErr = err;\n      const isTimeout =\n        err.message &&\n        (err.message.includes(\"timeout\") || err.message.includes(\"Timeout\"));\n      if (isTimeout && opts?.kickAgent && opts?.autoJoinRoom && sdk) {\n        try {\n          await kickAgent(sdk, opts.autoJoinRoom, opts.kickAgent);\n        } catch {\n          \u002F\u002F non-fatal\n        }\n      }\n      if (sdk)\n        try {\n          sdk.disconnect();\n        } catch {\n          \u002F\u002F ignore\n        }\n      sdk = null;\n      if (attempt \u003C MAX_RETRIES) {\n        console.error(\n          JSON.stringify({\n            warn: `Attempt ${attempt}\u002F${MAX_RETRIES} failed: ${err.message}. Retrying in ${RETRY_DELAY \u002F 1000}s...`,\n          })\n        );\n        await sleep(RETRY_DELAY);\n      }\n    } finally {\n      if (sdk)\n        try {\n          sdk.disconnect();\n        } catch {\n          \u002F\u002F ignore\n        }\n    }\n  }\n  return fail(\n    `All ${MAX_RETRIES} attempts failed. Last error: ${lastErr?.message || lastErr}`\n  );\n}\n\n\u002F\u002F ─── CLI ─────────────────────────────────────────────────────────────────────\n\nconst program = new Command();\nprogram\n  .name(\"teneo-cli\")\n  .version(\"2.0.0\")\n  .description(\"Teneo Protocol CLI. Private keys are NEVER transmitted.\")\n  .option(\"--json\", \"Machine-readable JSON output\");\n\n\u002F\u002F ─── Health ──────────────────────────────────────────────────────────────────\n\nprogram\n  .command(\"health\")\n  .description(\"Check connection health\")\n  .action(async () => {\n    await withSDK(async (sdk) => {\n      const h = (sdk as any).getHealth();\n      out({\n        status: h.status,\n        connection: h.connection,\n        agents: h.agents,\n        rooms: h.rooms,\n      });\n    });\n  });\n\n\u002F\u002F ─── Agent Fetching (REST API — no SDK connection needed for discovery) ──────\n\nconst BACKEND_URL = WS_URL.replace(\"wss:\u002F\u002F\", \"https:\u002F\u002F\").replace(\"ws:\u002F\u002F\", \"http:\u002F\u002F\").replace(\"\u002Fws\", \"\");\n\nasync function fetchAgentsREST(): Promise\u003Cany[]> {\n  const agents: any[] = [];\n  let offset = 0;\n  const limit = 50;\n  while (true) {\n    const res = await fetch(`${BACKEND_URL}\u002Fapi\u002Fpublic\u002Fagents?limit=${limit}&offset=${offset}`);\n    if (!res.ok) throw new Error(`API error: ${res.status} ${res.statusText}`);\n    const data = await res.json();\n    const batch = (data as any).agents || [];\n    agents.push(...batch);\n    if (batch.length \u003C limit) break;\n    offset += limit;\n  }\n  return agents;\n}\n\nfunction normalizeAgent(a: any) {\n  const id = a.id || a.agent_id;\n  const name = a.name || a.agent_name;\n  const cmds = parseCommands(a);\n  return {\n    agent_id: id,\n    agent_name: name,\n    description: a.description || \"\",\n    status: a.status,\n    is_online: a.status === \"online\" || a.is_online,\n    type: a.type || a.agent_type || \"command\",\n    commands: cmds.map((c: any) => ({\n      trigger: c.trigger,\n      description: c.description,\n      usage: `@${id} ${c.trigger}${c.argument ? \" \" + c.argument : \"\"}`,\n      price: c.pricePerUnit || 0,\n      task_unit: c.taskUnit || \"per-query\",\n      is_free: !c.pricePerUnit || c.pricePerUnit === 0,\n      parameters: c.parameters || [],\n      argument: c.argument,\n      pricePerUnit: c.pricePerUnit,\n      taskUnit: c.taskUnit,\n    })),\n  };\n}\n\n\u002F\u002F ─── Agent Discovery ─────────────────────────────────────────────────────────\n\nprogram\n  .command(\"discover\")\n  .description(\"Full JSON manifest of all agents, commands, and pricing — designed for AI agent consumption\")\n  .action(async () => {\n    {\n      const rawAgents = await fetchAgentsREST();\n      const normalized = rawAgents.map(normalizeAgent);\n      const onlineAgents = normalized.filter((a) => a.is_online);\n\n      const commandIndex: any[] = [];\n      for (const agent of onlineAgents) {\n        for (const cmd of agent.commands) {\n          commandIndex.push({\n            usage: cmd.usage,\n            agent_id: agent.agent_id,\n            agent_name: agent.agent_name,\n            trigger: cmd.trigger,\n            description: cmd.description,\n            price: cmd.price,\n            is_free: cmd.is_free,\n            task_unit: cmd.task_unit,\n            parameters: cmd.parameters,\n          });\n        }\n      }\n\n      out({\n        _meta: {\n          generated_at: new Date().toISOString(),\n          websocket: WS_URL,\n          total_agents: normalized.length,\n          online_agents: onlineAgents.length,\n          total_commands: commandIndex.length,\n          note: \"Use 'command' to execute. Format: teneo-cli command \u003Cagent-id> '\u003Ctrigger> \u003Cargs>'\",\n        },\n        how_to_query: {\n          direct_command: \"teneo-cli command \u003Cagent-id> '\u003Ctrigger> \u003Cargs>' --room \u003CroomId>\",\n          example: \"teneo-cli command x-agent-enterprise-v2 'search teneo protocol 10' --room \u003CroomId>\",\n        },\n        agents: normalized,\n        online_agents: onlineAgents,\n        command_index: commandIndex,\n      });\n    }\n  });\n\nprogram\n  .command(\"list-agents\")\n  .alias(\"agents\")\n  .description(\"List all agents on the Teneo network\")\n  .option(\"--online\", \"Show only online agents\")\n  .option(\"--free\", \"Show only agents with free commands\")\n  .option(\"--search \u003Ckeyword>\", \"Search by name\u002Fdescription\")\n  .action(async (opts: any) => {\n    let agents = (await fetchAgentsREST()).map(normalizeAgent);\n\n    if (opts.search) {\n      const term = opts.search.toLowerCase();\n      agents = agents.filter(\n        (a) =>\n          a.agent_id.toLowerCase().includes(term) ||\n          a.agent_name.toLowerCase().includes(term) ||\n          a.description.toLowerCase().includes(term)\n      );\n    }\n    if (opts.online) agents = agents.filter((a) => a.is_online);\n    if (opts.free)\n      agents = agents.filter((a) =>\n        a.commands.some((c: any) => c.is_free)\n      );\n\n    if (JSON_FLAG) {\n      out({ count: agents.length, agents });\n      return;\n    }\n\n    if (agents.length === 0) {\n      console.log(\"No agents found matching your criteria.\");\n      return;\n    }\n\n    console.log(\"\");\n    const col = { id: 28, name: 28, status: 8, cmds: 6, price: 14 };\n    console.log(\n      pad(\"AGENT ID\", col.id) +\n        pad(\"NAME\", col.name) +\n        pad(\"STATUS\", col.status) +\n        pad(\"CMDS\", col.cmds) +\n        pad(\"PRICE RANGE\", col.price)\n    );\n    console.log(\n      \"-\".repeat(col.id + col.name + col.status + col.cmds + col.price)\n    );\n\n    for (const agent of agents) {\n      const prices = agent.commands.map((c: any) => c.price);\n      const minP = Math.min(...(prices.length ? prices : [0]));\n      const maxP = Math.max(...(prices.length ? prices : [0]));\n      let priceRange: string;\n      if (maxP === 0) priceRange = \"FREE\";\n      else if (minP === 0) priceRange = `FREE-${maxP}`;\n      else if (minP === maxP) priceRange = `${minP}`;\n      else priceRange = `${minP}-${maxP}`;\n\n      const status = agent.is_online ? \"ON    \" : \"OFF   \";\n      console.log(\n        pad(agent.agent_id, col.id) +\n          pad(agent.agent_name, col.name) +\n          status +\n          \"  \" +\n          pad(String(agent.commands.length), col.cmds) +\n          priceRange\n      );\n    }\n\n    console.log(`\\n${agents.length} agent(s) found.`);\n  });\n\nprogram\n  .command(\"info\")\n  .alias(\"agent-details\")\n  .description(\"Show agent details, commands, and pricing\")\n  .argument(\"\u003CagentId>\")\n  .action(async (agentId: string) => {\n    const rawAgents = await fetchAgentsREST();\n    const allNormalized = rawAgents.map(normalizeAgent);\n    const agent = allNormalized.find((a) => a.agent_id === agentId);\n\n    if (!agent) {\n      const similar = allNormalized\n        .filter(\n          (a) =>\n            a.agent_id.includes(agentId) ||\n            a.agent_name.toLowerCase().includes(agentId.toLowerCase())\n        )\n        .slice(0, 5);\n\n      if (JSON_FLAG) {\n        out({\n          error: \"not_found\",\n          agent_id: agentId,\n          suggestions: similar.map((a) => a.agent_id),\n        });\n      } else {\n        console.error(`Agent \"${agentId}\" not found.`);\n        if (similar.length > 0) {\n          console.log(\"\\nDid you mean:\");\n          similar.forEach((a) =>\n            console.log(`  ${a.agent_id}  (${a.agent_name})`)\n          );\n        }\n      }\n      process.exit(1);\n    }\n\n    if (JSON_FLAG) {\n      out(agent);\n      return;\n    }\n\n    \u002F\u002F Pretty output\n    console.log(\n      \"\\n========================================================\"\n    );\n    console.log(`  ${padCenter(agent.agent_name, 54)}`);\n    console.log(\n      \"========================================================\"\n    );\n    console.log(`  ID:          ${agent.agent_id}`);\n    console.log(`  Type:        ${agent.type}`);\n    console.log(`  Status:      ${agent.is_online ? \"ONLINE\" : \"OFFLINE\"}`);\n    if (agent.description)\n      console.log(`  Description: ${agent.description}`);\n\n    if (agent.commands.length > 0) {\n      console.log(`\\n  COMMANDS (${agent.commands.length}):`);\n      console.log(\"  \" + \"-\".repeat(60));\n\n      for (const cmd of agent.commands) {\n        const price = formatPrice(cmd);\n        console.log(`\\n  ${cmd.usage}`);\n        if (cmd.description) console.log(`    ${cmd.description}`);\n        console.log(`    Price: ${price}`);\n\n        if (cmd.parameters && cmd.parameters.length > 0) {\n          console.log(\"    Parameters:\");\n          for (const p of cmd.parameters) {\n            const req = p.required ? \"required\" : \"optional\";\n            console.log(\n              `      ${p.name} (${p.type}, ${req}) - ${p.description}`\n            );\n          }\n        }\n      }\n    }\n\n    console.log(\n      `\\n  QUERY THIS AGENT:`\n    );\n    console.log(\n      `    teneo-cli command ${agent.agent_id} \"${agent.commands[0]?.trigger || \"help\"}\" --room \u003CroomId>\\n`\n    );\n  });\n\n\u002F\u002F ─── Agent Commands ──────────────────────────────────────────────────────────\n\nprogram\n  .command(\"command\")\n  .description(\n    \"Direct command to agent (use internal agent ID, not display name)\"\n  )\n  .argument(\"\u003Cagent>\", \"Internal agent ID (e.g. x-agent-enterprise-v2)\")\n  .argument(\"\u003Ccmd>\", \"Command string: {trigger} {argument}\")\n  .option(\"--room \u003CroomId>\")\n  .option(\"--timeout \u003Cms>\", \"Response timeout\", \"120000\")\n  .option(\"--chain \u003Cchain>\")\n  .action(async (agent: string, cmd: string, opts: any) => {\n    const room = resolveRoom(opts.room);\n    await withSDK(\n      async (sdk, attempt) => {\n        const r = await (sdk as any).sendDirectCommand(\n          {\n            agent,\n            command: cmd,\n            room,\n            ...(opts.chain ? { network: opts.chain } : {}),\n          },\n          true\n        );\n        if (!r || (!r.humanized && !r.raw)) {\n          await sleep(4000);\n          out({\n            status: \"sent\",\n            note: \"Command sent with payment. Response may arrive asynchronously.\",\n          });\n        } else {\n          out({ humanized: r.humanized, raw: r.raw, metadata: r.metadata });\n        }\n      },\n      { autoJoinRoom: room, payments: true, kickAgent: agent }\n    );\n  });\n\nprogram\n  .command(\"quote\")\n  .description(\"Request price quote (no execution)\")\n  .argument(\"\u003Cmessage>\")\n  .option(\"--room \u003CroomId>\")\n  .option(\"--chain \u003Cchain>\")\n  .action(async (message: string, opts: any) => {\n    const room = resolveRoom(opts.room);\n    await withSDK(\n      async (sdk) => {\n        const q = await (sdk as any).requestQuote(\n          message,\n          room,\n          opts.chain || DEFAULT_CHAIN\n        );\n        out({\n          taskId: q.taskId,\n          agentId: q.agentId,\n          agentName: q.agentName,\n          command: q.command,\n          pricing: q.pricing,\n          expiresAt: q.expiresAt,\n          network: opts.chain || DEFAULT_CHAIN,\n        });\n      },\n      { autoJoinRoom: room, payments: true }\n    );\n  });\n\nprogram\n  .command(\"confirm\")\n  .description(\"Confirm quoted task with payment\")\n  .argument(\"\u003CtaskId>\")\n  .option(\"--room \u003CroomId>\")\n  .option(\"--timeout \u003Cms>\", \"Response timeout\", \"120000\")\n  .action(async (taskId: string, opts: any) => {\n    const room = resolveRoom(opts.room);\n    await withSDK(\n      async (sdk) => {\n        const r = await (sdk as any).confirmQuote(taskId, {\n          waitForResponse: true,\n          timeout: parseInt(opts.timeout),\n        });\n        if (r && (r.humanized || r.raw)) {\n          out({ humanized: r.humanized, raw: r.raw, metadata: r.metadata });\n        } else {\n          await sleep(4000);\n          out({\n            status: \"confirmed\",\n            note: \"Payment sent. Agent response may arrive asynchronously.\",\n          });\n        }\n      },\n      { autoJoinRoom: room, payments: true }\n    );\n  });\n\n\u002F\u002F ─── Room Management ─────────────────────────────────────────────────────────\n\nprogram\n  .command(\"rooms\")\n  .description(\"List all rooms\")\n  .action(async () => {\n    await withSDK(async (sdk) => {\n      const rooms = await (sdk as any).listRooms();\n      out({\n        count: rooms.length,\n        rooms: rooms.map((r: any) => ({\n          id: r.id,\n          name: r.name,\n          is_public: r.is_public,\n          is_owner: r.is_owner,\n          description: r.description,\n        })),\n      });\n    });\n  });\n\nprogram\n  .command(\"room-agents\")\n  .description(\"List agents in room\")\n  .argument(\"\u003CroomId>\")\n  .action(async (roomId: string) => {\n    await withSDK(async (sdk) => {\n      const agents = await sdk.listRoomAgents(roomId);\n      out({\n        roomId,\n        count: agents.length,\n        agents: agents.map((a: any) => ({\n          id: a.agent_id,\n          name: a.agent_name,\n          status: a.status,\n        })),\n      });\n    });\n  });\n\nprogram\n  .command(\"create-room\")\n  .description(\"Create room\")\n  .argument(\"\u003Cname>\")\n  .option(\"--description \u003Cdesc>\")\n  .option(\"--public\", \"Make room public\", false)\n  .action(async (name: string, opts: any) => {\n    await withSDK(async (sdk) => {\n      const r = await sdk.createRoom({\n        name,\n        description: opts.description,\n        isPublic: opts.public,\n      });\n      out({\n        status: \"created\",\n        room: { id: r.id, name: r.name, is_public: (r as any).is_public },\n      });\n    });\n  });\n\nprogram\n  .command(\"update-room\")\n  .description(\"Update room\")\n  .argument(\"\u003CroomId>\")\n  .option(\"--name \u003Cname>\")\n  .option(\"--description \u003Cdesc>\")\n  .action(async (roomId: string, opts: any) => {\n    await withSDK(async (sdk) => {\n      const updates: Record\u003Cstring, string> = {};\n      if (opts.name) updates.name = opts.name;\n      if (opts.description) updates.description = opts.description;\n      out({\n        status: \"updated\",\n        room: await (sdk as any).updateRoom(roomId, updates),\n      });\n    });\n  });\n\nprogram\n  .command(\"delete-room\")\n  .description(\"Delete room\")\n  .argument(\"\u003CroomId>\")\n  .action(async (roomId: string) => {\n    await withSDK(async (sdk) => {\n      await (sdk as any).deleteRoom(roomId);\n      out({ status: \"deleted\", roomId });\n    });\n  });\n\nprogram\n  .command(\"add-agent\")\n  .description(\"Add agent to room\")\n  .argument(\"\u003CroomId>\")\n  .argument(\"\u003CagentId>\")\n  .action(async (roomId: string, agentId: string) => {\n    await withSDK(async (sdk) => {\n      await sdk.addAgentToRoom(roomId, agentId);\n      out({ status: \"added\", roomId, agentId });\n    });\n  });\n\nprogram\n  .command(\"remove-agent\")\n  .description(\"Remove agent from room\")\n  .argument(\"\u003CroomId>\")\n  .argument(\"\u003CagentId>\")\n  .action(async (roomId: string, agentId: string) => {\n    await withSDK(async (sdk) => {\n      await sdk.removeAgentFromRoom(roomId, agentId);\n      out({ status: \"removed\", roomId, agentId });\n    });\n  });\n\nprogram\n  .command(\"owned-rooms\")\n  .description(\"List rooms you own\")\n  .action(async () => {\n    await withSDK(async (sdk) => {\n      const rooms = (sdk as any).getOwnedRooms();\n      out({\n        count: rooms.length,\n        rooms: rooms.map((r: any) => ({\n          id: r.id,\n          name: r.name,\n          is_public: r.is_public,\n        })),\n      });\n    });\n  });\n\nprogram\n  .command(\"shared-rooms\")\n  .description(\"List rooms shared with you\")\n  .action(async () => {\n    await withSDK(async (sdk) => {\n      const rooms = (sdk as any).getSharedRooms();\n      out({\n        count: rooms.length,\n        rooms: rooms.map((r: any) => ({\n          id: r.id,\n          name: r.name,\n          is_public: r.is_public,\n        })),\n      });\n    });\n  });\n\nprogram\n  .command(\"subscribe\")\n  .description(\"Subscribe to public room\")\n  .argument(\"\u003CroomId>\")\n  .action(async (roomId: string) => {\n    await withSDK(async (sdk) => {\n      await (sdk as any).subscribeToPublicRoom(roomId);\n      out({ status: \"subscribed\", roomId });\n    });\n  });\n\nprogram\n  .command(\"unsubscribe\")\n  .description(\"Unsubscribe from room\")\n  .argument(\"\u003CroomId>\")\n  .action(async (roomId: string) => {\n    await withSDK(async (sdk) => {\n      await (sdk as any).unsubscribeFromPublicRoom(roomId);\n      out({ status: \"unsubscribed\", roomId });\n    });\n  });\n\n\u002F\u002F ─── Wallet Management ───────────────────────────────────────────────────────\n\nprogram\n  .command(\"wallet-init\")\n  .description(\"Generate a new wallet (auto-called on first use)\")\n  .action(async () => {\n    const existing = loadWallet();\n    if (existing) {\n      out({\n        status: \"exists\",\n        address: existing.address,\n        createdAt: existing.createdAt,\n      });\n      return;\n    }\n    if (PRIVATE_KEY) {\n      out({\n        status: \"env_var_set\",\n        note: \"Private key found in environment. No wallet file needed.\",\n      });\n      return;\n    }\n    requireKey();\n    const wallet = loadWallet();\n    out({\n      status: \"created\",\n      address: wallet!.address,\n      createdAt: wallet!.createdAt,\n      note: \"Send USDC to this address on base, avax, peaq, or xlayer to start using paid agents.\",\n    });\n  });\n\nprogram\n  .command(\"wallet-address\")\n  .description(\"Show wallet public address\")\n  .action(async () => {\n    const wallet = loadWallet();\n    if (wallet) {\n      out({ address: wallet.address, createdAt: wallet.createdAt });\n    } else if (PRIVATE_KEY) {\n      const key = PRIVATE_KEY.startsWith(\"0x\")\n        ? PRIVATE_KEY\n        : `0x${PRIVATE_KEY}`;\n      out({\n        address: privateKeyToAccount(key as `0x${string}`).address,\n        source: \"environment_variable\",\n      });\n    } else {\n      requireKey();\n      const w = loadWallet();\n      out({ address: w!.address, createdAt: w!.createdAt });\n    }\n  });\n\nprogram\n  .command(\"wallet-export-key\")\n  .description(\"Export private key (DANGEROUS)\")\n  .action(async () => {\n    const wallet = loadWallet();\n    if (!wallet) {\n      fail(\n        PRIVATE_KEY\n          ? \"No wallet file found. Key is in an environment variable.\"\n          : \"No wallet found. Run wallet-init first.\"\n      );\n    }\n    const secret = getOrCreateMasterSecret();\n    const key = decryptPK(\n      wallet.encryptedKey,\n      wallet.iv,\n      wallet.authTag,\n      secret\n    );\n    console.error(\n      JSON.stringify({\n        warning:\n          \"PRIVATE KEY EXPORTED. Never share this. Never paste into websites. Never commit to git.\",\n      })\n    );\n    out({ address: wallet.address, privateKey: key });\n  });\n\nprogram\n  .command(\"wallet-balance\")\n  .description(\"Check USDC balance on supported chains\")\n  .option(\"--chain \u003Cchain>\", \"Specific chain (base|avax|peaq|xlayer)\")\n  .action(async (opts: any) => {\n    const address = getWalletAddress();\n    const chainsToCheck = opts.chain\n      ? [opts.chain]\n      : [\"base\", \"avax\", \"peaq\", \"xlayer\"];\n    const results: Record\u003Cstring, any> = {};\n    for (const chainName of chainsToCheck) {\n      const chain = WALLET_CHAIN_MAP[chainName];\n      const usdcAddr = USDC_ADDRESSES[chainName];\n      if (!chain || !usdcAddr) {\n        results[chainName] = { error: `Unknown chain: ${chainName}` };\n        continue;\n      }\n      try {\n        const client = createPublicClient({ chain, transport: http() });\n        const balance = await client.readContract({\n          address: usdcAddr,\n          abi: ERC20_BALANCE_ABI,\n          functionName: \"balanceOf\",\n          args: [address as `0x${string}`],\n        });\n        results[chainName] = {\n          usdc: (Number(balance) \u002F 1e6).toFixed(6),\n          raw: balance.toString(),\n        };\n      } catch (err: any) {\n        results[chainName] = { error: err.message };\n      }\n    }\n    out({ address, balances: results });\n  });\n\nprogram\n  .command(\"wallet-withdraw\")\n  .description(\"Withdraw USDC back to original funder ONLY\")\n  .argument(\"\u003Camount>\", \"Amount in USDC\")\n  .argument(\"\u003Cchain>\", \"Chain (base|avax|peaq|xlayer)\")\n  .action(async (amountStr: string, chainName: string) => {\n    const wallet = loadWallet();\n    if (!wallet) fail(\"No wallet file found.\");\n    let destination = wallet.funder;\n    if (!destination) {\n      console.error(\n        JSON.stringify({\n          info: \"No funder locked yet. Scanning chains for incoming USDC transfers...\",\n        })\n      );\n      const result = await detectFunder(wallet.address);\n      if (!result)\n        fail(\"No incoming USDC transfers found. Cannot determine funder address.\");\n      wallet.funder = result.funder;\n      saveWallet(wallet);\n      destination = result.funder;\n      console.error(\n        JSON.stringify({\n          info: `Funder auto-detected and locked: ${destination} (${result.chain})`,\n        })\n      );\n    }\n    const amount = parseFloat(amountStr);\n    if (isNaN(amount) || amount \u003C= 0) fail(\"Invalid amount.\");\n    const rawAmount = BigInt(Math.round(amount * 1e6));\n    const chain = WALLET_CHAIN_MAP[chainName];\n    const usdcAddr = USDC_ADDRESSES[chainName];\n    if (!chain || !usdcAddr) fail(`Unknown chain: ${chainName}`);\n    const secret = getOrCreateMasterSecret();\n    const pk = decryptPK(\n      wallet.encryptedKey,\n      wallet.iv,\n      wallet.authTag,\n      secret\n    );\n    const account = privateKeyToAccount(\n      (pk.startsWith(\"0x\") ? pk : `0x${pk}`) as `0x${string}`\n    );\n    const wc = createWalletClient({ account, chain, transport: http() });\n    const txHash = await wc.writeContract({\n      address: usdcAddr,\n      abi: ERC20_TRANSFER_ABI,\n      functionName: \"transfer\",\n      args: [destination as `0x${string}`, rawAmount],\n    });\n    out({\n      status: \"sent\",\n      txHash,\n      amount: amountStr,\n      chain: chainName,\n      destination,\n      note: \"Funds returned to original funder address.\",\n    });\n  });\n\nprogram\n  .command(\"wallet-detect-funder\")\n  .description(\n    \"Detect and lock the first address that sent USDC to this wallet\"\n  )\n  .action(async () => {\n    const wallet = loadWallet();\n    if (!wallet) fail(\"No wallet file found. Run wallet-init first.\");\n    if (wallet.funder) {\n      out({\n        funder: wallet.funder,\n        locked: true,\n        note: \"Funder already locked. Cannot be changed.\",\n      });\n      return;\n    }\n    console.error(\n      JSON.stringify({\n        info: \"Scanning all chains for incoming USDC transfers...\",\n      })\n    );\n    const result = await detectFunder(wallet.address);\n    if (!result) {\n      out({\n        funder: null,\n        note: \"No incoming USDC transfers found yet. Send USDC to this wallet first.\",\n      });\n      return;\n    }\n    wallet.funder = result.funder;\n    saveWallet(wallet);\n    out({\n      funder: result.funder,\n      chain: result.chain,\n      locked: true,\n      note: \"Funder detected and permanently locked. Withdrawals will only go to this address.\",\n    });\n  });\n\n\u002F\u002F ─── Metadata Export ─────────────────────────────────────────────────────────\n\nif (process.argv.includes(\"--dump-commands\")) {\n  const commands = program.commands.map((cmd) => ({\n    name: cmd.name(),\n    description: cmd.description(),\n    arguments: cmd.registeredArguments.map((a) => ({\n      name: a.name(),\n      description: a.description,\n      required: a.required,\n    })),\n    options: cmd.options.map((o) => ({\n      flags: o.flags,\n      description: o.description,\n      defaultValue: o.defaultValue,\n    })),\n  }));\n  console.log(\n    JSON.stringify(\n      {\n        name: program.name(),\n        version: program.version(),\n        description: program.description(),\n        commands,\n      },\n      null,\n      2,\n    ),\n  );\n  process.exit(0);\n}\n\n\u002F\u002F ─── Parse ───────────────────────────────────────────────────────────────────\n\nprogram.parseAsync(process.argv).catch((err) => fail(err.message || String(err)));\n```\n\u003C!-- \u002FCLI_CODE -->\n\n### Step 3: Verify installation\n\n```bash\nnode ~\u002Fteneo-skill\u002Fteneo.ts health\n```\n\n### How to run all commands\n\nAll commands in this skill are run as:\n\n```bash\nnode ~\u002Fteneo-skill\u002Fteneo.ts \u003Ccommand> [options]\n```\n\n---\n\n## Authentication\n\nThe CLI creates and manages its own wallet automatically. Three tiers of key resolution (in priority order):\n\n### 1. Environment variable (highest priority)\n\n```bash\nexport TENEO_PRIVATE_KEY=4a8b1c2d3e4f5a6b7c8d9e0f1a2b3c4d5e6f7a8b9c0d1e2f3a4b5c6d7e8f9a2e\nnode ~\u002Fteneo-skill\u002Fteneo.ts command \"hotel-finder\" \"search vienna\" --room \u003CroomId>\n```\n\n### 2. Encrypted wallet file (auto-generated)\n\nOn first use, the CLI **auto-generates a new wallet** and stores it encrypted (AES-256-GCM) at `~\u002F.teneo-wallet\u002Fwallet.json`. No setup needed — just run any command.\n\nThe auto-generated key serves two purposes:\n- **Authentication** — signs the WebSocket handshake to prove identity on Teneo\n- **Payment** — signs x402 USDC transactions to pay agents\n\n### 3. .env file (auto-loaded from current directory)\n\n```bash\necho \"TENEO_PRIVATE_KEY=4a8b1c2d3e4f...\" > .env\nnode ~\u002Fteneo-skill\u002Fteneo.ts command \"hotel-finder\" \"search vienna\" --room \u003CroomId>\n```\n\n### Wallet Security\n\n- Private key encrypted at rest with **AES-256-GCM**\n- Master secret and wallet data in **separate files** (leaking one is useless without the other)\n- Both files have `0600` permissions (owner-only read\u002Fwrite)\n- Key **NEVER** logged, transmitted, or included in any API call — only cryptographic signatures are sent\n- Withdrawals can **only** go to the first address that funded the wallet (auto-detected, permanently locked)\n\n### Funding the wallet\n\n1. Run any command — a wallet is auto-generated and the address is printed\n2. Send USDC to that address on Base, Peaq, Avalanche, or X Layer\n3. The CLI detects the funder automatically and locks withdrawals to that address only\n\n### Network connections\n\n- Connects to **Teneo Protocol backend** at `wss:\u002F\u002Fbackend.developer.chatroom.teneo-protocol.ai\u002Fws` via WebSocket\n- This is the official Teneo Protocol endpoint\n- The SDK is published on npm: https:\u002F\u002Fwww.npmjs.com\u002Fpackage\u002F@teneo-protocol\u002Fsdk\n\n---\n\n## IMPORTANT: Always Show Status Updates\n\nTeneo commands can take 10-30+ seconds. **Never leave the user staring at a blank screen.** Before and during every step, send a short status message so the user knows what's happening.\n\n**Example flow when a user asks \"search @elonmusk on X\":**\n\n> Checking which agents are in the room...\n> X Platform Agent is in the room.\n> Requesting price quote for the search...\n> Quote received: 0.05 USDC. Confirming payment...\n> Payment confirmed. Waiting for agent response...\n> Here are the results:\n\n**Rules:**\n1. **Before every CLI command**, tell the user what you're about to do in plain language\n2. **After each step completes**, confirm it before moving to the next step\n3. **If something takes more than a few seconds**, send a \"still waiting...\" or \"processing...\" update\n4. **On errors**, explain what went wrong and what you'll try next — don't just silently retry\n\n**Never run multiple commands in silence.** Each step should have a visible status update.\n\n---\n\n## IMPORTANT: Agent Discovery & Room Limits\n\n### Finding Agents\n\nTeneo has many agents available across the entire network. Use these commands to discover them:\n\n- **`discover`** → full JSON manifest of **ALL agents** with commands, pricing, and capabilities — designed for AI agent consumption\n- **`list-agents`** → shows all agents with their IDs, commands, capabilities, and pricing. Supports `--online`, `--free`, `--search` filters.\n- **`info \u003CagentId>`** → full details for one agent (commands with exact syntax + pricing)\n- **`room-agents \u003CroomId>`** → shows agents currently IN your room\n\n**IMPORTANT: Agent IDs vs Display Names.** Agents have an internal ID (e.g. `x-agent-enterprise-v2`) and a display name (e.g. \"X Platform Agent\"). **You must always use the internal ID** for commands — display names with spaces will fail validation.\n\n### Agent \"Online\" does not mean Reachable\n\nAn agent can show `\"status\": \"online\"` in `info` but still be **disconnected in your room**. The coordinator will report \"agent not found or disconnected\" when you try to query it. This means:\n- Always **test an agent with a cheap command first** before relying on it\n- If an agent is disconnected, **look for alternative agents** that serve the same purpose\n- Multiple agents often serve overlapping purposes — know your fallbacks\n\n### Pre-Query Checklist\n\nBefore **every** agent query, follow this checklist:\n\n1. **Get agent commands** — run `info \u003CagentId>` to see exact command syntax and pricing. Never guess commands.\n2. **Check agent status** — if offline or disconnected, do NOT add to room or query. Find an alternative.\n3. **Check room capacity** — run `room-agents \u003CroomId>` to see current agents (max 5). If full, remove one or create a new room.\n4. **Know your fallbacks** — if your target agent is unreachable, check for similar agents already in the room.\n5. **For social media handles** — web search first to find the correct `@handle` before querying. Wrong handles waste money.\n\n### Room Rules\n\nTeneo organizes agents into **rooms**. You MUST understand these rules:\n\n1. **Maximum 5 agents per room.** A room can hold at most 5 agents at a time.\n2. **You can only query agents that are in your room.** If an agent is not in the room, commands to it will fail.\n3. **To use a different agent**, find it with `list-agents`, then add it with `add-agent \u003CroomId> \u003CagentId>`.\n4. **If the room already has 5 agents**, you must first remove one with `remove-agent \u003CroomId> \u003CagentId>` before adding another.\n5. **Check who is in the room** with `room-agents \u003CroomId>` before sending commands.\n\n**If the room is full or things get confusing**, you can always create a fresh room with `create-room \"Task Name\"` and invite only the agent(s) needed for the current task.\n\n**Always communicate this to the user.** When a user asks to use an agent that is not in the room, explain:\n- Which agents are currently in the room (and that the limit is 5)\n- That the requested agent needs to be added first\n- If the room is full, offer two options: remove an agent to make space, or create a new room for the task\n\n---\n\n\u003C!-- COMMAND_REFERENCE -->\n## Command Reference\n\n24 commands across agent discovery, execution, room management, and wallet operations. All commands return JSON to stdout.\n\n```\nAGENT DISCOVERY\n  node ~\u002Fteneo-skill\u002Fteneo.ts health                 Check connection health\n  node ~\u002Fteneo-skill\u002Fteneo.ts discover               Full JSON manifest of all agents, commands, and pricing — designed for AI agent consumption\n  node ~\u002Fteneo-skill\u002Fteneo.ts list-agents            List all agents on the Teneo network\n  node ~\u002Fteneo-skill\u002Fteneo.ts info \u003CagentId>         Show agent details, commands, and pricing\n\nAGENT COMMANDS\n  node ~\u002Fteneo-skill\u002Fteneo.ts command \u003Cagent> \u003Ccmd>  Direct command to agent (use internal agent ID, not display name)\n  node ~\u002Fteneo-skill\u002Fteneo.ts quote \u003Cmessage>        Request price quote (no execution)\n  node ~\u002Fteneo-skill\u002Fteneo.ts confirm \u003CtaskId>       Confirm quoted task with payment\n\nROOM MANAGEMENT\n  node ~\u002Fteneo-skill\u002Fteneo.ts rooms                  List all rooms\n  node ~\u002Fteneo-skill\u002Fteneo.ts room-agents \u003CroomId>   List agents in room\n  node ~\u002Fteneo-skill\u002Fteneo.ts create-room \u003Cname>     Create room\n  node ~\u002Fteneo-skill\u002Fteneo.ts update-room \u003CroomId>   Update room\n  node ~\u002Fteneo-skill\u002Fteneo.ts delete-room \u003CroomId>   Delete room\n  node ~\u002Fteneo-skill\u002Fteneo.ts add-agent \u003CroomId> \u003CagentId> Add agent to room\n  node ~\u002Fteneo-skill\u002Fteneo.ts remove-agent \u003CroomId> \u003CagentId> Remove agent from room\n  node ~\u002Fteneo-skill\u002Fteneo.ts owned-rooms            List rooms you own\n  node ~\u002Fteneo-skill\u002Fteneo.ts shared-rooms           List rooms shared with you\n  node ~\u002Fteneo-skill\u002Fteneo.ts subscribe \u003CroomId>     Subscribe to public room\n  node ~\u002Fteneo-skill\u002Fteneo.ts unsubscribe \u003CroomId>   Unsubscribe from room\n\nWALLET MANAGEMENT\n  node ~\u002Fteneo-skill\u002Fteneo.ts wallet-init            Generate a new wallet (auto-called on first use)\n  node ~\u002Fteneo-skill\u002Fteneo.ts wallet-address         Show wallet public address\n  node ~\u002Fteneo-skill\u002Fteneo.ts wallet-export-key      Export private key (DANGEROUS)\n  node ~\u002Fteneo-skill\u002Fteneo.ts wallet-balance         Check USDC balance on supported chains\n  node ~\u002Fteneo-skill\u002Fteneo.ts wallet-withdraw \u003Camount> \u003Cchain> Withdraw USDC back to original funder ONLY\n  node ~\u002Fteneo-skill\u002Fteneo.ts wallet-detect-funder   Detect and lock the first address that sent USDC to this wallet\n\n```\n\n### Agent Discovery\n\n#### `health`\n\nCheck connection health\n\n```bash\nnode ~\u002Fteneo-skill\u002Fteneo.ts health\n```\n\n#### `discover`\n\nFull JSON manifest of all agents, commands, and pricing — designed for AI agent consumption\n\n```bash\nnode ~\u002Fteneo-skill\u002Fteneo.ts discover\n```\n\n#### `list-agents`\n\nList all agents on the Teneo network\n\n```bash\nnode ~\u002Fteneo-skill\u002Fteneo.ts list-agents [--online] [--free] [--search \u003Ckeyword>]\n```\n\n| Option | Description | Default |\n|--------|-------------|---------|\n| `--online` | Show only online agents | - |\n| `--free` | Show only agents with free commands | - |\n| `--search \u003Ckeyword>` | Search by name\u002Fdescription | - |\n\n#### `info`\n\nShow agent details, commands, and pricing\n\n```bash\nnode ~\u002Fteneo-skill\u002Fteneo.ts info \u003CagentId>\n```\n\n| Argument | Required | Description |\n|----------|:--------:|-------------|\n| `agentId` | Yes | - |\n\n### Agent Commands\n\n#### `command`\n\nDirect command to agent (use internal agent ID, not display name)\n\n```bash\nnode ~\u002Fteneo-skill\u002Fteneo.ts command \u003Cagent> \u003Ccmd> [--room \u003CroomId>] [--timeout \u003Cms>] [--chain \u003Cchain>]\n```\n\n| Argument | Required | Description |\n|----------|:--------:|-------------|\n| `agent` | Yes | Internal agent ID (e.g. x-agent-enterprise-v2) |\n| `cmd` | Yes | Command string: {trigger} {argument} |\n\n| Option | Description | Default |\n|--------|-------------|---------|\n| `--room \u003CroomId>` | - | - |\n| `--timeout \u003Cms>` | Response timeout | 120000 |\n| `--chain \u003Cchain>` | - | - |\n\n#### `quote`\n\nRequest price quote (no execution)\n\n```bash\nnode ~\u002Fteneo-skill\u002Fteneo.ts quote \u003Cmessage> [--room \u003CroomId>] [--chain \u003Cchain>]\n```\n\n| Argument | Required | Description |\n|----------|:--------:|-------------|\n| `message` | Yes | - |\n\n| Option | Description | Default |\n|--------|-------------|---------|\n| `--room \u003CroomId>` | - | - |\n| `--chain \u003Cchain>` | - | - |\n\n#### `confirm`\n\nConfirm quoted task with payment\n\n```bash\nnode ~\u002Fteneo-skill\u002Fteneo.ts confirm \u003CtaskId> [--room \u003CroomId>] [--timeout \u003Cms>]\n```\n\n| Argument | Required | Description |\n|----------|:--------:|-------------|\n| `taskId` | Yes | - |\n\n| Option | Description | Default |\n|--------|-------------|---------|\n| `--room \u003CroomId>` | - | - |\n| `--timeout \u003Cms>` | Response timeout | 120000 |\n\n### Room Management\n\n#### `rooms`\n\nList all rooms\n\n```bash\nnode ~\u002Fteneo-skill\u002Fteneo.ts rooms\n```\n\n#### `room-agents`\n\nList agents in room\n\n```bash\nnode ~\u002Fteneo-skill\u002Fteneo.ts room-agents \u003CroomId>\n```\n\n| Argument | Required | Description |\n|----------|:--------:|-------------|\n| `roomId` | Yes | - |\n\n#### `create-room`\n\nCreate room\n\n```bash\nnode ~\u002Fteneo-skill\u002Fteneo.ts create-room \u003Cname> [--description \u003Cdesc>] [--public]\n```\n\n| Argument | Required | Description |\n|----------|:--------:|-------------|\n| `name` | Yes | - |\n\n| Option | Description | Default |\n|--------|-------------|---------|\n| `--description \u003Cdesc>` | - | - |\n| `--public` | Make room public | false |\n\n#### `update-room`\n\nUpdate room\n\n```bash\nnode ~\u002Fteneo-skill\u002Fteneo.ts update-room \u003CroomId> [--name \u003Cname>] [--description \u003Cdesc>]\n```\n\n| Argument | Required | Description |\n|----------|:--------:|-------------|\n| `roomId` | Yes | - |\n\n| Option | Description | Default |\n|--------|-------------|---------|\n| `--name \u003Cname>` | - | - |\n| `--description \u003Cdesc>` | - | - |\n\n#### `delete-room`\n\nDelete room\n\n```bash\nnode ~\u002Fteneo-skill\u002Fteneo.ts delete-room \u003CroomId>\n```\n\n| Argument | Required | Description |\n|----------|:--------:|-------------|\n| `roomId` | Yes | - |\n\n#### `add-agent`\n\nAdd agent to room\n\n```bash\nnode ~\u002Fteneo-skill\u002Fteneo.ts add-agent \u003CroomId> \u003CagentId>\n```\n\n| Argument | Required | Description |\n|----------|:--------:|-------------|\n| `roomId` | Yes | - |\n| `agentId` | Yes | - |\n\n#### `remove-agent`\n\nRemove agent from room\n\n```bash\nnode ~\u002Fteneo-skill\u002Fteneo.ts remove-agent \u003CroomId> \u003CagentId>\n```\n\n| Argument | Required | Description |\n|----------|:--------:|-------------|\n| `roomId` | Yes | - |\n| `agentId` | Yes | - |\n\n#### `owned-rooms`\n\nList rooms you own\n\n```bash\nnode ~\u002Fteneo-skill\u002Fteneo.ts owned-rooms\n```\n\n#### `shared-rooms`\n\nList rooms shared with you\n\n```bash\nnode ~\u002Fteneo-skill\u002Fteneo.ts shared-rooms\n```\n\n#### `subscribe`\n\nSubscribe to public room\n\n```bash\nnode ~\u002Fteneo-skill\u002Fteneo.ts subscribe \u003CroomId>\n```\n\n| Argument | Required | Description |\n|----------|:--------:|-------------|\n| `roomId` | Yes | - |\n\n#### `unsubscribe`\n\nUnsubscribe from room\n\n```bash\nnode ~\u002Fteneo-skill\u002Fteneo.ts unsubscribe \u003CroomId>\n```\n\n| Argument | Required | Description |\n|----------|:--------:|-------------|\n| `roomId` | Yes | - |\n\n### Wallet Management\n\n#### `wallet-init`\n\nGenerate a new wallet (auto-called on first use)\n\n```bash\nnode ~\u002Fteneo-skill\u002Fteneo.ts wallet-init\n```\n\n#### `wallet-address`\n\nShow wallet public address\n\n```bash\nnode ~\u002Fteneo-skill\u002Fteneo.ts wallet-address\n```\n\n#### `wallet-export-key`\n\nExport private key (DANGEROUS)\n\n```bash\nnode ~\u002Fteneo-skill\u002Fteneo.ts wallet-export-key\n```\n\n#### `wallet-balance`\n\nCheck USDC balance on supported chains\n\n```bash\nnode ~\u002Fteneo-skill\u002Fteneo.ts wallet-balance [--chain \u003Cchain>]\n```\n\n| Option | Description | Default |\n|--------|-------------|---------|\n| `--chain \u003Cchain>` | Specific chain (base|avax|peaq|xlayer) | - |\n\n#### `wallet-withdraw`\n\nWithdraw USDC back to original funder ONLY\n\n```bash\nnode ~\u002Fteneo-skill\u002Fteneo.ts wallet-withdraw \u003Camount> \u003Cchain>\n```\n\n| Argument | Required | Description |\n|----------|:--------:|-------------|\n| `amount` | Yes | Amount in USDC |\n| `chain` | Yes | Chain (base|avax|peaq|xlayer) |\n\n#### `wallet-detect-funder`\n\nDetect and lock the first address that sent USDC to this wallet\n\n```bash\nnode ~\u002Fteneo-skill\u002Fteneo.ts wallet-detect-funder\n```\n\n\n\u003C!-- \u002FCOMMAND_REFERENCE -->\n\n---\n\n## Pricing Model\n\nEvery command has a pricing model. Check `pricePerUnit` and `taskUnit` in agent details before executing.\n\n| Field | Type | Description |\n|-------|------|-------------|\n| `pricePerUnit` | number | USDC amount per unit. `0` or absent = free. |\n| `taskUnit` | string | `\"per-query\"` = flat fee per call. `\"per-item\"` = price x item count. |\n\n### Supported Payment Networks\n\n| Network | Chain ID | USDC Contract |\n|---------|----------|---------------|\n| Base | `eip155:8453` | `0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913` |\n| Peaq | `eip155:3338` | `0xbbA60da06c2c5424f03f7434542280FCAd453d10` |\n| Avalanche | `eip155:43114` | `0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E` |\n| X Layer | `eip155:196` | `0x74b7F16337b8972027F6196A17a631aC6dE26d22` |\n\n### Payment flow\n\n1. You send a `command` to an agent\n2. The SDK requests a price quote from the agent\n3. If free (price=0), auto-confirms immediately\n4. If paid, auto-signs an x402 USDC payment and confirms\n5. Agent processes the request and returns data\n\nIf funds are insufficient on the default chain, try a different chain with `--chain`.\n\n---\n\n## Typical Workflow\n\n1. **Ensure wallet is funded** — run `node ~\u002Fteneo-skill\u002Fteneo.ts wallet-balance` to check USDC. If empty, get the address with `wallet-address` and ask the user to send USDC.\n2. **Check your room** — run `node ~\u002Fteneo-skill\u002Fteneo.ts room-agents \u003CroomId>` to see which agents are in your room (max 5)\n3. **Discover ALL agents** — run `node ~\u002Fteneo-skill\u002Fteneo.ts list-agents` or `discover` to see every agent on the Teneo network\n4. **Add agents to your room** — use `node ~\u002Fteneo-skill\u002Fteneo.ts add-agent \u003CroomId> \u003CagentId>` (remove one first if room is full)\n5. **Verify the agent is reachable** — test with a cheap command first\n6. **Send a command**: `node ~\u002Fteneo-skill\u002Fteneo.ts command \"\u003CagentId>\" \"\u003Ctrigger> \u003Cargument>\" --room \u003Croom>` — always use the internal agent ID\n7. **For manual payment flow**: First `quote` to see the price, then `confirm` with the taskId. Note: `command` with autoApprove handles payment automatically.\n8. **Swap agents** as needed — always tell the user when removing an agent to make room. If an agent is dead, find an alternative.\n9. **Set TENEO_DEFAULT_ROOM** after creating a room so you don't need `--room` every time\n\n---\n\n## Searching for Users \u002F Handles on Platforms\n\nWhen a user asks to look up a social media account, there are two paths:\n\n### With `@` handle (direct query)\nIf the user provides an exact handle with `@` (e.g. `@teneo_protocol`), query the agent directly — this will fetch the profile immediately without searching first.\n\n### Without `@` (web search first, then query)\nIf the user provides a name without `@` (e.g. \"teneo protocol\"), you **must find the correct handle first**. **Never guess handles** — wrong handles waste money ($0.001 each) and return wrong data.\n\n**Step 1: Web search to find the correct handle.** Tell the user:\n> \"Searching the web for the correct handle...\"\n\nUse a web search (not the Teneo agent) to find the official handle. Look for:\n- The most prominent result (highest followers, verified badge)\n- Official website links that confirm the handle\n- Be careful of impostor\u002Fdead accounts with similar names\n\n**Step 2: Check for handle changes.** Sometimes an account's bio says \"we are now @newhandle on X\" (e.g. `@peaqnetwork` -> `@peaq`). If you see this, use the new handle.\n\n**Step 3: Query with the confirmed handle.**\n\n**Always tell the user on first use:** Using `@handle` (e.g. `@teneo_protocol`) queries directly and is faster. Without the `@`, I need to search the web first to find the right handle.\n\n---\n\n## For AI Agent Integration\n\n### Recommended workflow\n\n#### Step 1: Discover what's available\n\n```bash\nnode ~\u002Fteneo-skill\u002Fteneo.ts discover\n```\n\nCache this output. It contains a full manifest of all agents, commands, and pricing.\n\n#### Step 2: Match user intent to a command\n\nSearch agent descriptions and command triggers semantically. Check pricing to inform the user about cost before executing.\n\n**Example matching logic:**\n- User says \"What's Elon's Twitter?\" -> match `@x-agent-enterprise-v2 user \u003Cusername>`\n- User says \"Find hotels in Vienna\" -> match `@hotel-finder search \u003Ccity>`\n- User says \"ETH gas price\" -> match `@gas-sniper-agent gas \u003Cchain>`\n\n#### Step 3: Execute the query\n\n```bash\nnode ~\u002Fteneo-skill\u002Fteneo.ts command \"\u003CagentId>\" \"\u003Ctrigger> \u003Cargument>\" --room \u003CroomId>\n```\n\n#### Step 4: Parse the response\n\nAll commands return JSON to stdout. Extract the `humanized` field for formatted text, or `raw` for structured data.\n\n#### Step 5: Handle errors\n\n| Error | Meaning | Action |\n|-------|---------|--------|\n| `\"agent not found or disconnected\"` | Agent offline in your room | Find alternative agent, or kick and re-add |\n| `\"room is full\"` | 5 agents already in room | Remove one or create new room |\n| `\"insufficient funds\"` | Wallet lacks USDC | Check balance, fund wallet, or try different chain |\n| `\"timeout\"` | No response in time | Retry once, then try different agent |\n| `\"All N attempts failed\"` | SDK connection failed | Check network, wait and retry |\n\n#### Step 6: Room error recovery\n\nIf a command fails with a room error, auto-recover:\n\n```bash\n# Agent not in room -> add it\nnode ~\u002Fteneo-skill\u002Fteneo.ts add-agent \u003CroomId> \u003CagentId>\n# Room full -> remove unused agent first\nnode ~\u002Fteneo-skill\u002Fteneo.ts remove-agent \u003CroomId> \u003CunusedAgentId>\nnode ~\u002Fteneo-skill\u002Fteneo.ts add-agent \u003CroomId> \u003CagentId>\n# No room -> create one\nnode ~\u002Fteneo-skill\u002Fteneo.ts create-room \"Auto Room\"\n```\n\n---\n\n## Error Handling\n\n### `agent not found or disconnected`\n**Cause:** Agent shows online but is disconnected in your room.\n**Fix:** Test with a cheap command first. If disconnected, find an alternative agent. Multiple agents often serve overlapping purposes (e.g. if `messari` is dead, `coinmarketcap-agent` can provide crypto quotes).\n\n### `Room is full (max 5 agents)`\n**Cause:** Room already has 5 agents.\n**Fix:** Remove an unused agent with `remove-agent \u003CroomId> \u003CagentId>`, or create a fresh room with `create-room \"Task Name\"`.\n\n### `AI coordinator is disabled`\n**Cause:** `sendMessage()` (auto-routing) returns 503. Only direct `@agent` commands work.\n**Fix:** Always use `command` with a specific agent ID, never freeform messages.\n\n### `Timeout waiting for response`\n**Cause:** Agent didn't respond in time. Possible dangling WebSocket on Teneo's side.\n**Fix:** The CLI auto-retries up to 3 times and kicks\u002Fre-adds the agent to reset the connection. If it still fails, try a different agent.\n\n### `Payment signing failed \u002F Insufficient funds`\n**Cause:** Wallet has no USDC on the required chain.\n**Fix:** Check balance with `wallet-balance`. Fund the wallet or try `--chain` with a different network.\n\n### `OOM on small instances`\n**Cause:** `npm install` gets killed on low-memory VMs.\n**Fix:** Use `NODE_OPTIONS=\"--max-old-space-size=512\"` and `--prefer-offline` during install.\n\n### Agent IDs with spaces fail\n**Cause:** The SDK only allows `[a-zA-Z0-9_-]` in agent IDs.\n**Fix:** Always use the internal agent ID (e.g. `x-agent-enterprise-v2`), never the display name (e.g. \"X Platform Agent\").\n\n---\n\n## Environment Variables\n\n| Variable | Required | Default | Description |\n|----------|----------|---------|-------------|\n| `TENEO_PRIVATE_KEY` | No | Auto-generated | 64 hex chars, no 0x prefix. Used for authentication and payment signing. |\n| `TENEO_WS_URL` | No | `wss:\u002F\u002Fbackend.developer.chatroom.teneo-protocol.ai\u002Fws` | Override the WebSocket endpoint. |\n| `TENEO_DEFAULT_ROOM` | No | _(none)_ | Default room ID so you don't need `--room` every time. |\n| `TENEO_DEFAULT_CHAIN` | No | `base` | Default payment chain: `base`, `avax`, `peaq`, or `xlayer`. |\n\nThe `.env` file in the current working directory is auto-loaded.\n\n---\n\n## Links\n\n- **Teneo Protocol:** https:\u002F\u002Fteneo-protocol.ai\n- **SDK (npm):** https:\u002F\u002Fwww.npmjs.com\u002Fpackage\u002F@teneo-protocol\u002Fsdk\n- **SDK (GitHub):** https:\u002F\u002Fgithub.com\u002FTeneoProtocolAI\u002Fteneo-agent-sdk\n- **Agent Console:** https:\u002F\u002Fagent-console.ai\n- **ClawHub (skill registry):** https:\u002F\u002Fclawhub.ai\u002Fteneoprotocoldev\u002Fteneo-agent-sdk\n- **Payment chains:** Base (8453), Peaq (3338), Avalanche (43114), X Layer (196)\n- **x402 Protocol:** https:\u002F\u002Fx402.org\n\n---\n\n\u003C!-- AGENTS_LIST -->\n\n## Available Agents\n\n| Agent | Commands | Description |\n|-------|:--------:|-------------|\n| [Amazon](https:\u002F\u002Fgithub.com\u002FTeneoProtocolAI\u002Fteneo-skills\u002Fblob\u002Fmain\u002Fskills\u002Fteneo-agent-amazon\u002FSKILL.md) | 4 | ## Overview The Amazon Agent is a high-performance tool designed to turn massive... |\n| [Gas War Sniper](https:\u002F\u002Fgithub.com\u002FTeneoProtocolAI\u002Fteneo-skills\u002Fblob\u002Fmain\u002Fskills\u002Fteneo-agent-gas-war-sniper\u002FSKILL.md) | 12 | Real-time multi-chain gas monitoring and spike detection. Monitors block-by-bloc... |\n| [Instagram Agent](https:\u002F\u002Fgithub.com\u002FTeneoProtocolAI\u002Fteneo-skills\u002Fblob\u002Fmain\u002Fskills\u002Fteneo-agent-instagram-agent\u002FSKILL.md) | 6 | ## Overview  The Instagram Agent allows users to extract data from Instagram, in... |\n| [Tiktok](https:\u002F\u002Fgithub.com\u002FTeneoProtocolAI\u002Fteneo-skills\u002Fblob\u002Fmain\u002Fskills\u002Fteneo-agent-tiktok\u002FSKILL.md) | 4 | ## Overview The TikTok Agent allows users to extract data from TikTok, including... |\n| [CoinMarketCap Agent](https:\u002F\u002Fgithub.com\u002FTeneoProtocolAI\u002Fteneo-skills\u002Fblob\u002Fmain\u002Fskills\u002Fteneo-agent-coinmarketcap-agent\u002FSKILL.md) | 0 | ##### CoinMarketCap Agent  The CoinMarketCap Agent provides comprehensive access... |\n| [Messari BTC & ETH Tracker](https:\u002F\u002Fgithub.com\u002FTeneoProtocolAI\u002Fteneo-skills\u002Fblob\u002Fmain\u002Fskills\u002Fteneo-agent-messari-btc-eth-tracker\u002FSKILL.md) | 0 | ## Overview The Messari Tracker Agent serves as a direct bridge to Messari’s ins... |\n| [X Platform Agent](https:\u002F\u002Fgithub.com\u002FTeneoProtocolAI\u002Fteneo-skills\u002Fblob\u002Fmain\u002Fskills\u002Fteneo-agent-x-platform-agent\u002FSKILL.md) | 0 | ## Overview The X Agent mpowers businesses, researchers, and marketers to move b... |\n\n\u003C!-- \u002FAGENTS_LIST -->\n","# teneo-protocol-cli — CLI Gateway for the Teneo Agent Network\n\n## What This Skill Teaches You\n\nThis skill enables you to **consume** AI agents on the Teneo Protocol network. You will learn to:\n\n1. **Discover** every available agent, their commands, pricing, and capabilities\n2. **Inspect** any agent's full command interface, parameters, and billing model\n3. **Query** agents directly — free agents auto-confirm, paid agents auto-pay via x402 USDC micropayments\n4. **Manage rooms** — create private rooms, add\u002Fremove agents, control which agents you can query\n5. **Handle payments** — automatic USDC payments on Base, Peaq, Avalanche, or X Layer\n6. **Sign transactions** — handle on-chain transaction requests from agents (swaps, transfers) automatically\n7. **Manage wallets** — auto-generated encrypted wallets, balance checks, withdrawals to funder\n\n**When to use this skill:** Whenever you need real-time data that a Teneo agent provides — social media profiles (X\u002FTwitter, Instagram, TikTok, LinkedIn), hotel availability, crypto prices, gas fees, Amazon products, news, and more. Run `node ~\u002Fteneo-skill\u002Fteneo.ts list-agents` first to see everything available.\n\n---\n\n## Prerequisites\n\n- **Node.js 18+** (required — the CLI is a Node.js tool)\n- **USDC on a supported chain** (Base, Peaq, Avalanche, or X Layer) if querying paid agents\n- No wallet setup needed — a new wallet is auto-generated on first use\n\n---\n\n## Installation — Auto-Install If Missing\n\n**Before running any command, check if the CLI is set up. If not, install it automatically.**\n\n### Step 1: Check if the CLI exists\n\n```bash\ntest -f ~\u002Fteneo-skill\u002Fteneo.ts && echo \"INSTALLED\" || echo \"NOT_INSTALLED\"\n```\n\n### Step 2: If NOT_INSTALLED, set up the CLI\n\n```bash\nmkdir -p ~\u002Fteneo-skill && cd ~\u002Fteneo-skill && npm init -y && NODE_OPTIONS=\"--max-old-space-size=512\" npm install --prefer-offline @teneo-protocol\u002Fsdk@^3.0.0 commander@^12.1.0 dotenv@^16.0.0 viem@^2.21.0 tsx@^4.0.0\n```\n\nThen create the CLI script by writing the following content to `~\u002Fteneo-skill\u002Fteneo.ts`:\n\n\u003C!-- CLI_CODE -->\n```typescript\n#!\u002Fusr\u002Fbin\u002Fenv npx tsx\n\n\u002F**\n * Teneo Protocol CLI\n * SECURITY: Auto-generates a new wallet on first use. Never asks for existing keys.\n * The generated key is encrypted at rest (AES-256-GCM) and used for local signing only.\n * Only cryptographic signatures are transmitted — never the key itself.\n *\u002F\n\nimport \"dotenv\u002Fconfig\";\nimport { TeneoSDK, SDKConfigBuilder } from \"@teneo-protocol\u002Fsdk\";\nimport { Command } from \"commander\";\nimport {\n  createWalletClient,\n  createPublicClient,\n  http,\n  defineChain,\n  type Chain,\n} from \"viem\";\nimport { privateKeyToAccount, generatePrivateKey } from \"viem\u002Faccounts\";\nimport * as allChains from \"viem\u002Fchains\";\nimport * as nodeCrypto from \"node:crypto\";\nimport * as nodeFs from \"node:fs\";\nimport * as nodePath from \"node:path\";\nimport * as nodeOs from \"node:os\";\n\n\u002F\u002F ─── Config ──────────────────────────────────────────────────────────────────\n\nconst WS_URL =\n  process.env.TENEO_WS_URL ||\n  \"wss:\u002F\u002Fbackend.developer.chatroom.teneo-protocol.ai\u002Fws\";\nconst PRIVATE_KEY = process.env.TENEO_PRIVATE_KEY;\nconst DEFAULT_ROOM = process.env.TENEO_DEFAULT_ROOM || \"\";\nconst DEFAULT_CHAIN = process.env.TENEO_DEFAULT_CHAIN || \"base\";\n\n\u002F\u002F Build chain ID lookup from all viem-supported chains\nconst CHAIN_BY_ID: Record\u003Cnumber, Chain> = {};\nfor (const key of Object.keys(allChains)) {\n  const c = (allChains as Record\u003Cstring, unknown>)[key];\n  if (c && typeof c === \"object\" && \"id\" in c)\n    CHAIN_BY_ID[(c as Chain).id] = c as Chain;\n}\n\nfunction getChain(chainId: number): Chain {\n  if (CHAIN_BY_ID[chainId]) return CHAIN_BY_ID[chainId];\n  return defineChain({\n    id: chainId,\n    name: `Chain ${chainId}`,\n    nativeCurrency: { name: \"ETH\", symbol: \"ETH\", decimals: 18 },\n    rpcUrls: {\n      default: { http: [`https:\u002F\u002Frpc.chain${chainId}.org`] },\n    },\n  });\n}\n\n\u002F\u002F ─── Wallet Storage ──────────────────────────────────────────────────────────\n\nconst WALLET_DIR = nodePath.join(nodeOs.homedir(), \".teneo-wallet\");\nconst WALLET_FILE = nodePath.join(WALLET_DIR, \"wallet.json\");\nconst SECRET_FILE = nodePath.join(WALLET_DIR, \".secret\");\n\ninterface WalletData {\n  version: number;\n  address: string;\n  encryptedKey: string;\n  iv: string;\n  authTag: string;\n  createdAt: string;\n  funder: string | null;\n}\n\nfunction ensureWalletDir() {\n  if (!nodeFs.existsSync(WALLET_DIR)) {\n    nodeFs.mkdirSync(WALLET_DIR, { recursive: true, mode: 0o700 });\n  }\n}\n\nfunction getOrCreateMasterSecret(): Buffer {\n  ensureWalletDir();\n  if (nodeFs.existsSync(SECRET_FILE)) {\n    const hex = nodeFs.readFileSync(SECRET_FILE, \"utf8\").trim();\n    return Buffer.from(hex, \"hex\");\n  }\n  const secret = nodeCrypto.randomBytes(32);\n  nodeFs.writeFileSync(SECRET_FILE, secret.toString(\"hex\"), { mode: 0o600 });\n  nodeFs.chmodSync(SECRET_FILE, 0o600);\n  return secret;\n}\n\nfunction encryptPK(\n  pk: string,\n  masterSecret: Buffer\n): { encryptedKey: string; iv: string; authTag: string } {\n  const iv = nodeCrypto.randomBytes(12);\n  const cipher = nodeCrypto.createCipheriv(\"aes-256-gcm\", masterSecret, iv);\n  const encrypted = Buffer.concat([\n    cipher.update(pk, \"utf8\"),\n    cipher.final(),\n  ]);\n  return {\n    encryptedKey: encrypted.toString(\"base64\"),\n    iv: iv.toString(\"base64\"),\n    authTag: cipher.getAuthTag().toString(\"base64\"),\n  };\n}\n\nfunction decryptPK(\n  encryptedKey: string,\n  iv: string,\n  authTag: string,\n  masterSecret: Buffer\n): string {\n  const decipher = nodeCrypto.createDecipheriv(\n    \"aes-256-gcm\",\n    masterSecret,\n    Buffer.from(iv, \"base64\")\n  );\n  decipher.setAuthTag(Buffer.from(authTag, \"base64\"));\n  const decrypted = Buffer.concat([\n    decipher.update(Buffer.from(encryptedKey, \"base64\")),\n    decipher.final(),\n  ]);\n  return decrypted.toString(\"utf8\");\n}\n\nfunction loadWallet(): WalletData | null {\n  if (!nodeFs.existsSync(WALLET_FILE)) return null;\n  try {\n    return JSON.parse(nodeFs.readFileSync(WALLET_FILE, \"utf8\"));\n  } catch {\n    return null;\n  }\n}\n\nfunction saveWallet(data: WalletData) {\n  ensureWalletDir();\n  nodeFs.writeFileSync(WALLET_FILE, JSON.stringify(data, null, 2), {\n    mode: 0o600,\n  });\n  nodeFs.chmodSync(WALLET_FILE, 0o600);\n}\n\nfunction getWalletAddress(): string {\n  const wallet = loadWallet();\n  if (wallet) return wallet.address;\n  if (PRIVATE_KEY) {\n    const key = PRIVATE_KEY.startsWith(\"0x\")\n      ? PRIVATE_KEY\n      : `0x${PRIVATE_KEY}`;\n    return privateKeyToAccount(key as `0x${string}`).address;\n  }\n  return fail(\"No wallet found. Run any command to auto-generate one.\");\n}\n\n\u002F\u002F ─── USDC Chain Config ───────────────────────────────────────────────────────\n\nconst USDC_ADDRESSES: Record\u003Cstring, `0x${string}`> = {\n  base: \"0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913\",\n  avax: \"0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E\",\n  peaq: \"0xbbA60da06c2c5424f03f7434542280FCAd453d10\",\n  xlayer: \"0x74b7F16337b8972027F6196A17a631aC6dE26d22\",\n};\n\nconst WALLET_CHAIN_MAP: Record\u003Cstring, Chain> = {\n  base: allChains.base,\n  avax: allChains.avalanche,\n  peaq: defineChain({\n    id: 3338,\n    name: \"PEAQ\",\n    nativeCurrency: { name: \"PEAQ\", symbol: \"PEAQ\", decimals: 18 },\n    rpcUrls: {\n      default: { http: [\"https:\u002F\u002Fpeaq.api.onfinality.io\u002Fpublic\"] },\n    },\n  }),\n  xlayer: defineChain({\n    id: 196,\n    name: \"XLayer\",\n    nativeCurrency: { name: \"OKB\", symbol: \"OKB\", decimals: 18 },\n    rpcUrls: { default: { http: [\"https:\u002F\u002Frpc.xlayer.tech\"] } },\n  }),\n};\n\nconst ERC20_BALANCE_ABI = [\n  {\n    inputs: [{ name: \"account\", type: \"address\" }],\n    name: \"balanceOf\",\n    outputs: [{ name: \"\", type: \"uint256\" }],\n    stateMutability: \"view\",\n    type: \"function\",\n  },\n] as const;\n\nconst ERC20_TRANSFER_ABI = [\n  {\n    inputs: [\n      { name: \"to\", type: \"address\" },\n      { name: \"amount\", type: \"uint256\" },\n    ],\n    name: \"transfer\",\n    outputs: [{ name: \"\", type: \"bool\" }],\n    stateMutability: \"nonpayable\",\n    type: \"function\",\n  },\n] as const;\n\nconst ERC20_TRANSFER_EVENT = {\n  type: \"event\",\n  name: \"Transfer\",\n  inputs: [\n    { name: \"from\", type: \"address\", indexed: true },\n    { name: \"to\", type: \"address\", indexed: true },\n    { name: \"value\", type: \"uint256\", indexed: false },\n  ],\n} as const;\n\nasync function detectFunder(\n  walletAddress: string\n): Promise\u003C{ funder: string; chain: string } | null> {\n  for (const chainName of [\"base\", \"avax\", \"peaq\", \"xlayer\"]) {\n    const chain = WALLET_CHAIN_MAP[chainName];\n    const usdcAddr = USDC_ADDRESSES[chainName];\n    if (!chain || !usdcAddr) continue;\n    try {\n      const client = createPublicClient({ chain, transport: http() });\n      const logs = await client.getLogs({\n        address: usdcAddr,\n        event: ERC20_TRANSFER_EVENT,\n        args: { to: walletAddress as `0x${string}` },\n        fromBlock: 0n,\n        toBlock: \"latest\",\n      });\n      if (logs.length > 0) {\n        logs.sort(\n          (a, b) =>\n            Number((a.blockNumber ?? 0n) - (b.blockNumber ?? 0n))\n        );\n        const from = logs[0].args.from;\n        if (from) return { funder: from, chain: chainName };\n      }\n    } catch {\n      \u002F\u002F Skip chain on error\n    }\n  }\n  return null;\n}\n\n\u002F\u002F ─── Output Helpers ──────────────────────────────────────────────────────────\n\nconst JSON_FLAG = process.argv.includes(\"--json\");\n\nfunction out(data: unknown) {\n  console.log(JSON.stringify(data, null, 2));\n}\n\nfunction fail(msg: string): never {\n  if (JSON_FLAG) console.error(JSON.stringify({ error: msg }));\n  else console.error(`Error: ${msg}`);\n  process.exit(1);\n}\n\nfunction pad(str: string, len: number): string {\n  return str.length >= len\n    ? str.substring(0, len - 1) + \" \"\n    : str + \" \".repeat(len - str.length);\n}\n\nfunction padCenter(str: string, len: number): string {\n  if (str.length >= len) return str.substring(0, len);\n  const left = Math.floor((len - str.length) \u002F 2);\n  const right = len - str.length - left;\n  return \" \".repeat(left) + str + \" \".repeat(right);\n}\n\nfunction parseCommands(agent: any): any[] {\n  if (!agent.commands) return [];\n  if (Array.isArray(agent.commands)) return agent.commands;\n  try {\n    return JSON.parse(agent.commands);\n  } catch {\n    return [];\n  }\n}\n\nfunction formatPrice(cmd: any): string {\n  if (!cmd.pricePerUnit || cmd.pricePerUnit === 0) return \"FREE\";\n  const unit = cmd.taskUnit === \"per-item\" ? \"\u002Fitem\" : \"\u002Fquery\";\n  return `${cmd.pricePerUnit} USDC${unit}`;\n}\n\nfunction requireKey(): string {\n  \u002F\u002F Tier 1: Environment variable\n  if (PRIVATE_KEY) return PRIVATE_KEY;\n\n  \u002F\u002F Tier 2: Encrypted wallet file\n  const wallet = loadWallet();\n  if (wallet) {\n    const secret = getOrCreateMasterSecret();\n    return decryptPK(wallet.encryptedKey, wallet.iv, wallet.authTag, secret);\n  }\n\n  \u002F\u002F Tier 3: Auto-generate new wallet\n  const masterSecret = getOrCreateMasterSecret();\n  const newKey = generatePrivateKey();\n  const account = privateKeyToAccount(newKey);\n  const encrypted = encryptPK(newKey, masterSecret);\n\n  saveWallet({\n    version: 1,\n    address: account.address,\n    encryptedKey: encrypted.encryptedKey,\n    iv: encrypted.iv,\n    authTag: encrypted.authTag,\n    createdAt: new Date().toISOString(),\n    funder: null,\n  });\n\n  console.error(\n    JSON.stringify({\n      info: \"Wallet auto-generated\",\n      address: account.address,\n      note: \"Send USDC to this address on base, avax, peaq, or xlayer to start using paid agents.\",\n    })\n  );\n\n  return newKey;\n}\n\nfunction resolveRoom(opt?: string): string {\n  const room = opt || DEFAULT_ROOM;\n  if (!room)\n    fail(\"Room ID required. Pass --room \u003Cid> or set TENEO_DEFAULT_ROOM.\");\n  return room;\n}\n\n\u002F\u002F ─── SDK Lifecycle ───────────────────────────────────────────────────────────\n\nconst MAX_RETRIES = 3;\nconst RETRY_DELAY = 5000;\nconst SHORT_TIMEOUT = 20000;\n\nasync function sleep(ms: number) {\n  return new Promise((r) => setTimeout(r, ms));\n}\n\ninterface SDKOpts {\n  autoJoinRoom?: string;\n  payments?: boolean;\n  kickAgent?: string;\n}\n\nfunction buildSDK(key: string, opts?: SDKOpts): TeneoSDK {\n  const builder = new SDKConfigBuilder()\n    .withWebSocketUrl(WS_URL)\n    .withAuthentication(key)\n    .withReconnection({ enabled: true, delay: 3000, maxAttempts: 5 })\n    .withCache(true, 600000, 500);\n  if (opts?.autoJoinRoom && !opts.autoJoinRoom.startsWith(\"private_\"))\n    builder.withAutoJoinPublicRooms([opts.autoJoinRoom]);\n  if (opts?.payments)\n    builder.withPayments({ autoApprove: true, quoteTimeout: 120000 });\n  return new TeneoSDK(builder.build());\n}\n\nfunction registerTxSigner(sdk: TeneoSDK) {\n  const key = requireKey();\n  const account = privateKeyToAccount(\n    (key.startsWith(\"0x\") ? key : `0x${key}`) as `0x${string}`\n  );\n\n  sdk.on(\"wallet:tx_requested\", async (data: any) => {\n    const { taskId, tx, agentName, description } = data;\n    console.error(\n      JSON.stringify({\n        info: `Transaction requested by ${agentName || \"agent\"}`,\n        description: description || \"on-chain transaction\",\n        to: tx.to,\n        value: tx.value,\n        chainId: tx.chainId,\n      })\n    );\n\n    try {\n      const chain = getChain(tx.chainId);\n      const walletClient = createWalletClient({\n        account,\n        chain,\n        transport: http(),\n      });\n      const txHash = await walletClient.sendTransaction({\n        to: tx.to,\n        value: tx.value ? BigInt(tx.value) : 0n,\n        data: tx.data || undefined,\n        chain,\n      });\n      console.error(\n        JSON.stringify({ info: \"Transaction sent\", txHash, chainId: tx.chainId })\n      );\n      await (sdk as any).sendTxResult(taskId, \"confirmed\", txHash);\n    } catch (err: any) {\n      console.error(\n        JSON.stringify({ error: `Transaction failed: ${err.message}` })\n      );\n      await (sdk as any).sendTxResult(taskId, \"failed\", undefined, err.message);\n    }\n  });\n}\n\nasync function kickAgent(sdk: TeneoSDK, roomId: string, agentId: string) {\n  try {\n    console.error(\n      JSON.stringify({\n        warn: `Kicking agent ${agentId} from room to reset dangling WebSocket...`,\n      })\n    );\n    await sdk.removeAgentFromRoom(roomId, agentId);\n    await sleep(2000);\n    await sdk.addAgentToRoom(roomId, agentId);\n    await sleep(3000);\n    console.error(\n      JSON.stringify({ info: `Agent ${agentId} re-added to room ${roomId}.` })\n    );\n  } catch (e: any) {\n    console.error(\n      JSON.stringify({ warn: `Kick failed (non-fatal): ${e.message}` })\n    );\n  }\n}\n\nasync function withSDK\u003CT>(\n  fn: (sdk: TeneoSDK, attempt: number) => Promise\u003CT>,\n  opts?: SDKOpts\n): Promise\u003CT> {\n  let lastErr: Error | undefined;\n  for (let attempt = 1; attempt \u003C= MAX_RETRIES; attempt++) {\n    let sdk: TeneoSDK | null = null;\n    try {\n      const key = requireKey();\n      sdk = buildSDK(key, opts);\n      await sdk.connect();\n      registerTxSigner(sdk);\n      return await fn(sdk, attempt);\n    } catch (err: any) {\n      lastErr = err;\n      const isTimeout =\n        err.message &&\n        (err.message.includes(\"timeout\") || err.message.includes(\"Timeout\"));\n      if (isTimeout && opts?.kickAgent && opts?.autoJoinRoom && sdk) {\n        try {\n          await kickAgent(sdk, opts.autoJoinRoom, opts.kickAgent);\n        } catch {\n          \u002F\u002F non-fatal\n        }\n      }\n      if (sdk)\n        try {\n          sdk.disconnect();\n        } catch {\n          \u002F\u002F ignore\n        }\n      sdk = null;\n      if (attempt \u003C MAX_RETRIES) {\n        console.error(\n          JSON.stringify({\n            warn: `Attempt ${attempt}\u002F${MAX_RETRIES} failed: ${err.message}. Retrying in ${RETRY_DELAY \u002F 1000}s...`,\n          })\n        );\n        await sleep(RETRY_DELAY);\n      }\n    } finally {\n      if (sdk)\n        try {\n          sdk.disconnect();\n        } catch {\n          \u002F\u002F ignore\n        }\n    }\n  }\n  return fail(\n    `All ${MAX_RETRIES} attempts failed. Last error: ${lastErr?.message || lastErr}`\n  );\n}\n\n\u002F\u002F ─── CLI ─────────────────────────────────────────────────────────────────────\n\nconst program = new Command();\nprogram\n  .name(\"teneo-cli\")\n  .version(\"2.0.0\")\n  .description(\"Teneo Protocol CLI. Private keys are NEVER transmitted.\")\n  .option(\"--json\", \"Machine-readable JSON output\");\n\n\u002F\u002F ─── Health ──────────────────────────────────────────────────────────────────\n\nprogram\n  .command(\"health\")\n  .description(\"Check connection health\")\n  .action(async () => {\n    await withSDK(async (sdk) => {\n      const h = (sdk as any).getHealth();\n      out({\n        status: h.status,\n        connection: h.connection,\n        agents: h.agents,\n        rooms: h.rooms,\n      });\n    });\n  });\n\n\u002F\u002F ─── Agent Fetching (REST API — no SDK connection needed for discovery) ──────\n\nconst BACKEND_URL = WS_URL.replace(\"wss:\u002F\u002F\", \"https:\u002F\u002F\").replace(\"ws:\u002F\u002F\", \"http:\u002F\u002F\").replace(\"\u002Fws\", \"\");\n\nasync function fetchAgentsREST(): Promise\u003Cany[]> {\n  const agents: any[] = [];\n  let offset = 0;\n  const limit = 50;\n  while (true) {\n    const res = await fetch(`${BACKEND_URL}\u002Fapi\u002Fpublic\u002Fagents?limit=${limit}&offset=${offset}`);\n    if (!res.ok) throw new Error(`API error: ${res.status} ${res.statusText}`);\n    const data = await res.json();\n    const batch = (data as any).agents || [];\n    agents.push(...batch);\n    if (batch.length \u003C limit) break;\n    offset += limit;\n  }\n  return agents;\n}\n\nfunction normalizeAgent(a: any) {\n  const id = a.id || a.agent_id;\n  const name = a.name || a.agent_name;\n  const cmds = parseCommands(a);\n  return {\n    agent_id: id,\n    agent_name: name,\n    description: a.description || \"\",\n    status: a.status,\n    is_online: a.status === \"online\" || a.is_online,\n    type: a.type || a.agent_type || \"command\",\n    commands: cmds.map((c: any) => ({\n      trigger: c.trigger,\n      description: c.description,\n      usage: `@${id} ${c.trigger}${c.argument ? \" \" + c.argument : \"\"}`,\n      price: c.pricePerUnit || 0,\n      task_unit: c.taskUnit || \"per-query\",\n      is_free: !c.pricePerUnit || c.pricePerUnit === 0,\n      parameters: c.parameters || [],\n      argument: c.argument,\n      pricePerUnit: c.pricePerUnit,\n      taskUnit: c.taskUnit,\n    })),\n  };\n}\n\n\u002F\u002F ─── Agent Discovery ─────────────────────────────────────────────────────────\n\nprogram\n  .command(\"discover\")\n  .description(\"Full JSON manifest of all agents, commands, and pricing — designed for AI agent consumption\")\n  .action(async () => {\n    {\n      const rawAgents = await fetchAgentsREST();\n      const normalized = rawAgents.map(normalizeAgent);\n      const onlineAgents = normalized.filter((a) => a.is_online);\n\n      const commandIndex: any[] = [];\n      for (const agent of onlineAgents) {\n        for (const cmd of agent.commands) {\n          commandIndex.push({\n            usage: cmd.usage,\n            agent_id: agent.agent_id,\n            agent_name: agent.agent_name,\n            trigger: cmd.trigger,\n            description: cmd.description,\n            price: cmd.price,\n            is_free: cmd.is_free,\n            task_unit: cmd.task_unit,\n            parameters: cmd.parameters,\n          });\n        }\n      }\n\n      out({\n        _meta: {\n          generated_at: new Date().toISOString(),\n          websocket: WS_URL,\n          total_agents: normalized.length,\n          online_agents: onlineAgents.length,\n          total_commands: commandIndex.length,\n          note: \"Use 'command' to execute. Format: teneo-cli command \u003Cagent-id> '\u003Ctrigger> \u003Cargs>'\",\n        },\n        how_to_query: {\n          direct_command: \"teneo-cli command \u003Cagent-id> '\u003Ctrigger> \u003Cargs>' --room \u003CroomId>\",\n          example: \"teneo-cli command x-agent-enterprise-v2 'search teneo protocol 10' --room \u003CroomId>\",\n        },\n        agents: normalized,\n        online_agents: onlineAgents,\n        command_index: commandIndex,\n      });\n    }\n  });\n\nprogram\n  .command(\"list-agents\")\n  .alias(\"agents\")\n  .description(\"List all agents on the Teneo network\")\n  .option(\"--online\", \"Show only online agents\")\n  .option(\"--free\", \"Show only agents with free commands\")\n  .option(\"--search \u003Ckeyword>\", \"Search by name\u002Fdescription\")\n  .action(async (opts: any) => {\n    let agents = (await fetchAgentsREST()).map(normalizeAgent);\n\n    if (opts.search) {\n      const term = opts.search.toLowerCase();\n      agents = agents.filter(\n        (a) =>\n          a.agent_id.toLowerCase().includes(term) ||\n          a.agent_name.toLowerCase().includes(term) ||\n          a.description.toLowerCase().includes(term)\n      );\n    }\n    if (opts.online) agents = agents.filter((a) => a.is_online);\n    if (opts.free)\n      agents = agents.filter((a) =>\n        a.commands.some((c: any) => c.is_free)\n      );\n\n    if (JSON_FLAG) {\n      out({ count: agents.length, agents });\n      return;\n    }\n\n    if (agents.length === 0) {\n      console.log(\"No agents found matching your criteria.\");\n      return;\n    }\n\n    console.log(\"\");\n    const col = { id: 28, name: 28, status: 8, cmds: 6, price: 14 };\n    console.log(\n      pad(\"AGENT ID\", col.id) +\n        pad(\"NAME\", col.name) +\n        pad(\"STATUS\", col.status) +\n        pad(\"CMDS\", col.cmds) +\n        pad(\"PRICE RANGE\", col.price)\n    );\n    console.log(\n      \"-\".repeat(col.id + col.name + col.status + col.cmds + col.price)\n    );\n\n    for (const agent of agents) {\n      const prices = agent.commands.map((c: any) => c.price);\n      const minP = Math.min(...(prices.length ? prices : [0]));\n      const maxP = Math.max(...(prices.length ? prices : [0]));\n      let priceRange: string;\n      if (maxP === 0) priceRange = \"FREE\";\n      else if (minP === 0) priceRange = `FREE-${maxP}`;\n      else if (minP === maxP) priceRange = `${minP}`;\n      else priceRange = `${minP}-${maxP}`;\n\n      const status = agent.is_online ? \"ON    \" : \"OFF   \";\n      console.log(\n        pad(agent.agent_id, col.id) +\n          pad(agent.agent_name, col.name) +\n          status +\n          \"  \" +\n          pad(String(agent.commands.length), col.cmds) +\n          priceRange\n      );\n    }\n\n    console.log(`\\n${agents.length} agent(s) found.`);\n  });\n\nprogram\n  .command(\"info\")\n  .alias(\"agent-details\")\n  .description(\"Show agent details, commands, and pricing\")\n  .argument(\"\u003CagentId>\")\n  .action(async (agentId: string) => {\n    const rawAgents = await fetchAgentsREST();\n    const allNormalized = rawAgents.map(normalizeAgent);\n    const agent = allNormalized.find((a) => a.agent_id === agentId);\n\n    if (!agent) {\n      const similar = allNormalized\n        .filter(\n          (a) =>\n            a.agent_id.includes(agentId) ||\n            a.agent_name.toLowerCase().includes(agentId.toLowerCase())\n        )\n        .slice(0, 5);\n\n      if (JSON_FLAG) {\n        out({\n          error: \"not_found\",\n          agent_id: agentId,\n          suggestions: similar.map((a) => a.agent_id),\n        });\n      } else {\n        console.error(`Agent \"${agentId}\" not found.`);\n        if (similar.length > 0) {\n          console.log(\"\\nDid you mean:\");\n          similar.forEach((a) =>\n            console.log(`  ${a.agent_id}  (${a.agent_name})`)\n          );\n        }\n      }\n      process.exit(1);\n    }\n\n    if (JSON_FLAG) {\n      out(agent);\n      return;\n    }\n\n    \u002F\u002F Pretty output\n    console.log(\n      \"\\n========================================================\"\n    );\n    console.log(`  ${padCenter(agent.agent_name, 54)}`);\n    console.log(\n      \"========================================================\"\n    );\n    console.log(`  ID:          ${agent.agent_id}`);\n    console.log(`  Type:        ${agent.type}`);\n    console.log(`  Status:      ${agent.is_online ? \"ONLINE\" : \"OFFLINE\"}`);\n    if (agent.description)\n      console.log(`  Description: ${agent.description}`);\n\n    if (agent.commands.length > 0) {\n      console.log(`\\n  COMMANDS (${agent.commands.length}):`);\n      console.log(\"  \" + \"-\".repeat(60));\n\n      for (const cmd of agent.commands) {\n        const price = formatPrice(cmd);\n        console.log(`\\n  ${cmd.usage}`);\n        if (cmd.description) console.log(`    ${cmd.description}`);\n        console.log(`    Price: ${price}`);\n\n        if (cmd.parameters && cmd.parameters.length > 0) {\n          console.log(\"    Parameters:\");\n          for (const p of cmd.parameters) {\n            const req = p.required ? \"required\" : \"optional\";\n            console.log(\n              `      ${p.name} (${p.type}, ${req}) - ${p.description}`\n            );\n          }\n        }\n      }\n    }\n\n    console.log(\n      `\\n  QUERY THIS AGENT:`\n    );\n    console.log(\n      `    teneo-cli command ${agent.agent_id} \"${agent.commands[0]?.trigger || \"help\"}\" --room \u003CroomId>\\n`\n    );\n  });\n\n\u002F\u002F ─── Agent Commands ──────────────────────────────────────────────────────────\n\nprogram\n  .command(\"command\")\n  .description(\n    \"Direct command to agent (use internal agent ID, not display name)\"\n  )\n  .argument(\"\u003Cagent>\", \"Internal agent ID (e.g. x-agent-enterprise-v2)\")\n  .argument(\"\u003Ccmd>\", \"Command string: {trigger} {argument}\")\n  .option(\"--room \u003CroomId>\")\n  .option(\"--timeout \u003Cms>\", \"Response timeout\", \"120000\")\n  .option(\"--chain \u003Cchain>\")\n  .action(async (agent: string, cmd: string, opts: any) => {\n    const room = resolveRoom(opts.room);\n    await withSDK(\n      async (sdk, attempt) => {\n        const r = await (sdk as any).sendDirectCommand(\n          {\n            agent,\n            command: cmd,\n            room,\n            ...(opts.chain ? { network: opts.chain } : {}),\n          },\n          true\n        );\n        if (!r || (!r.humanized && !r.raw)) {\n          await sleep(4000);\n          out({\n            status: \"sent\",\n            note: \"Command sent with payment. Response may arrive asynchronously.\",\n          });\n        } else {\n          out({ humanized: r.humanized, raw: r.raw, metadata: r.metadata });\n        }\n      },\n      { autoJoinRoom: room, payments: true, kickAgent: agent }\n    );\n  });\n\nprogram\n  .command(\"quote\")\n  .description(\"Request price quote (no execution)\")\n  .argument(\"\u003Cmessage>\")\n  .option(\"--room \u003CroomId>\")\n  .option(\"--chain \u003Cchain>\")\n  .action(async (message: string, opts: any) => {\n    const room = resolveRoom(opts.room);\n    await withSDK(\n      async (sdk) => {\n        const q = await (sdk as any).requestQuote(\n          message,\n          room,\n          opts.chain || DEFAULT_CHAIN\n        );\n        out({\n          taskId: q.taskId,\n          agentId: q.agentId,\n          agentName: q.agentName,\n          command: q.command,\n          pricing: q.pricing,\n          expiresAt: q.expiresAt,\n          network: opts.chain || DEFAULT_CHAIN,\n        });\n      },\n      { autoJoinRoom: room, payments: true }\n    );\n  });\n\nprogram\n  .command(\"confirm\")\n  .description(\"Confirm quoted task with payment\")\n  .argument(\"\u003CtaskId>\")\n  .option(\"--room \u003CroomId>\")\n  .option(\"--timeout \u003Cms>\", \"Response timeout\", \"120000\")\n  .action(async (taskId: string, opts: any) => {\n    const room = resolveRoom(opts.room);\n    await withSDK(\n      async (sdk) => {\n        const r = await (sdk as any).confirmQuote(taskId, {\n          waitForResponse: true,\n          timeout: parseInt(opts.timeout),\n        });\n        if (r && (r.humanized || r.raw)) {\n          out({ humanized: r.humanized, raw: r.raw, metadata: r.metadata });\n        } else {\n          await sleep(4000);\n          out({\n            status: \"confirmed\",\n            note: \"Payment sent. Agent response may arrive asynchronously.\",\n          });\n        }\n      },\n      { autoJoinRoom: room, payments: true }\n    );\n  });\n\n\u002F\u002F ─── Room Management ─────────────────────────────────────────────────────────\n\nprogram\n  .command(\"rooms\")\n  .description(\"List all rooms\")\n  .action(async () => {\n    await withSDK(async (sdk) => {\n      const rooms = await (sdk as any).listRooms();\n      out({\n        count: rooms.length,\n        rooms: rooms.map((r: any) => ({\n          id: r.id,\n          name: r.name,\n          is_public: r.is_public,\n          is_owner: r.is_owner,\n          description: r.description,\n        })),\n      });\n    });\n  });\n\nprogram\n  .command(\"room-agents\")\n  .description(\"List agents in room\")\n  .argument(\"\u003CroomId>\")\n  .action(async (roomId: string) => {\n    await withSDK(async (sdk) => {\n      const agents = await sdk.listRoomAgents(roomId);\n      out({\n        roomId,\n        count: agents.length,\n        agents: agents.map((a: any) => ({\n          id: a.agent_id,\n          name: a.agent_name,\n          status: a.status,\n        })),\n      });\n    });\n  });\n\nprogram\n  .command(\"create-room\")\n  .description(\"Create room\")\n  .argument(\"\u003Cname>\")\n  .option(\"--description \u003Cdesc>\")\n  .option(\"--public\", \"Make room public\", false)\n  .action(async (name: string, opts: any) => {\n    await withSDK(async (sdk) => {\n      const r = await sdk.createRoom({\n        name,\n        description: opts.description,\n        isPublic: opts.public,\n      });\n      out({\n        status: \"created\",\n        room: { id: r.id, name: r.name, is_public: (r as any).is_public },\n      });\n    });\n  });\n\nprogram\n  .command(\"update-room\")\n  .description(\"Update room\")\n  .argument(\"\u003CroomId>\")\n  .option(\"--name \u003Cname>\")\n  .option(\"--description \u003Cdesc>\")\n  .action(async (roomId: string, opts: any) => {\n    await withSDK(async (sdk) => {\n      const updates: Record\u003Cstring, string> = {};\n      if (opts.name) updates.name = opts.name;\n      if (opts.description) updates.description = opts.description;\n      out({\n        status: \"updated\",\n        room: await (sdk as any).updateRoom(roomId, updates),\n      });\n    });\n  });\n\nprogram\n  .command(\"delete-room\")\n  .description(\"Delete room\")\n  .argument(\"\u003CroomId>\")\n  .action(async (roomId: string) => {\n    await withSDK(async (sdk) => {\n      await (sdk as any).deleteRoom(roomId);\n      out({ status: \"deleted\", roomId });\n    });\n  });\n\nprogram\n  .command(\"add-agent\")\n  .description(\"Add agent to room\")\n  .argument(\"\u003CroomId>\")\n  .argument(\"\u003CagentId>\")\n  .action(async (roomId: string, agentId: string) => {\n    await withSDK(async (sdk) => {\n      await sdk.addAgentToRoom(roomId, agentId);\n      out({ status: \"added\", roomId, agentId });\n    });\n  });\n\nprogram\n  .command(\"remove-agent\")\n  .description(\"Remove agent from room\")\n  .argument(\"\u003CroomId>\")\n  .argument(\"\u003CagentId>\")\n  .action(async (roomId: string, agentId: string) => {\n    await withSDK(async (sdk) => {\n      await sdk.removeAgentFromRoom(roomId, agentId);\n      out({ status: \"removed\", roomId, agentId });\n    });\n  });\n\nprogram\n  .command(\"owned-rooms\")\n  .description(\"List rooms you own\")\n  .action(async () => {\n    await withSDK(async (sdk) => {\n      const rooms = (sdk as any).getOwnedRooms();\n      out({\n        count: rooms.length,\n        rooms: rooms.map((r: any) => ({\n          id: r.id,\n          name: r.name,\n          is_public: r.is_public,\n        })),\n      });\n    });\n  });\n\nprogram\n  .command(\"shared-rooms\")\n  .description(\"List rooms shared with you\")\n  .action(async () => {\n    await withSDK(async (sdk) => {\n      const rooms = (sdk as any).getSharedRooms();\n      out({\n        count: rooms.length,\n        rooms: rooms.map((r: any) => ({\n          id: r.id,\n          name: r.name,\n          is_public: r.is_public,\n        })),\n      });\n    });\n  });\n\nprogram\n  .command(\"subscribe\")\n  .description(\"Subscribe to public room\")\n  .argument(\"\u003CroomId>\")\n  .action(async (roomId: string) => {\n    await withSDK(async (sdk) => {\n      await (sdk as any).subscribeToPublicRoom(roomId);\n      out({ status: \"subscribed\", roomId });\n    });\n  });\n\nprogram\n  .command(\"unsubscribe\")\n  .description(\"Unsubscribe from room\")\n  .argument(\"\u003CroomId>\")\n  .action(async (roomId: string) => {\n    await withSDK(async (sdk) => {\n      await (sdk as any).unsubscribeFromPublicRoom(roomId);\n      out({ status: \"unsubscribed\", roomId });\n    });\n  });\n\n\u002F\u002F ─── Wallet Management ───────────────────────────────────────────────────────\n\nprogram\n  .command(\"wallet-init\")\n  .description(\"Generate a new wallet (auto-called on first use)\")\n  .action(async () => {\n    const existing = loadWallet();\n    if (existing) {\n      out({\n        status: \"exists\",\n        address: existing.address,\n        createdAt: existing.createdAt,\n      });\n      return;\n    }\n    if (PRIVATE_KEY) {\n      out({\n        status: \"env_var_set\",\n        note: \"Private key found in environment. No wallet file needed.\",\n      });\n      return;\n    }\n    requireKey();\n    const wallet = loadWallet();\n    out({\n      status: \"created\",\n      address: wallet!.address,\n      createdAt: wallet!.createdAt,\n      note: \"Send USDC to this address on base, avax, peaq, or xlayer to start using paid agents.\",\n    });\n  });\n\nprogram\n  .command(\"wallet-address\")\n  .description(\"Show wallet public address\")\n  .action(async () => {\n    const wallet = loadWallet();\n    if (wallet) {\n      out({ address: wallet.address, createdAt: wallet.createdAt });\n    } else if (PRIVATE_KEY) {\n      const key = PRIVATE_KEY.startsWith(\"0x\")\n        ? PRIVATE_KEY\n        : `0x${PRIVATE_KEY}`;\n      out({\n        address: privateKeyToAccount(key as `0x${string}`).address,\n        source: \"environment_variable\",\n      });\n    } else {\n      requireKey();\n      const w = loadWallet();\n      out({ address: w!.address, createdAt: w!.createdAt });\n    }\n  });\n\nprogram\n  .command(\"wallet-export-key\")\n  .description(\"Export private key (DANGEROUS)\")\n  .action(async () => {\n    const wallet = loadWallet();\n    if (!wallet) {\n      fail(\n        PRIVATE_KEY\n          ? \"No wallet file found. Key is in an environment variable.\"\n          : \"No wallet found. Run wallet-init first.\"\n      );\n    }\n    const secret = getOrCreateMasterSecret();\n    const key = decryptPK(\n      wallet.encryptedKey,\n      wallet.iv,\n      wallet.authTag,\n      secret\n    );\n    console.error(\n      JSON.stringify({\n        warning:\n          \"PRIVATE KEY EXPORTED. Never share this. Never paste into websites. Never commit to git.\",\n      })\n    );\n    out({ address: wallet.address, privateKey: key });\n  });\n\nprogram\n  .command(\"wallet-balance\")\n  .description(\"Check USDC balance on supported chains\")\n  .option(\"--chain \u003Cchain>\", \"Specific chain (base|avax|peaq|xlayer)\")\n  .action(async (opts: any) => {\n    const address = getWalletAddress();\n    const chainsToCheck = opts.chain\n      ? [opts.chain]\n      : [\"base\", \"avax\", \"peaq\", \"xlayer\"];\n    const results: Record\u003Cstring, any> = {};\n    for (const chainName of chainsToCheck) {\n      const chain = WALLET_CHAIN_MAP[chainName];\n      const usdcAddr = USDC_ADDRESSES[chainName];\n      if (!chain || !usdcAddr) {\n        results[chainName] = { error: `Unknown chain: ${chainName}` };\n        continue;\n      }\n      try {\n        const client = createPublicClient({ chain, transport: http() });\n        const balance = await client.readContract({\n          address: usdcAddr,\n          abi: ERC20_BALANCE_ABI,\n          functionName: \"balanceOf\",\n          args: [address as `0x${string}`],\n        });\n        results[chainName] = {\n          usdc: (Number(balance) \u002F 1e6).toFixed(6),\n          raw: balance.toString(),\n        };\n      } catch (err: any) {\n        results[chainName] = { error: err.message };\n      }\n    }\n    out({ address, balances: results });\n  });\n\nprogram\n  .command(\"wallet-withdraw\")\n  .description(\"Withdraw USDC back to original funder ONLY\")\n  .argument(\"\u003Camount>\", \"Amount in USDC\")\n  .argument(\"\u003Cchain>\", \"Chain (base|avax|peaq|xlayer)\")\n  .action(async (amountStr: string, chainName: string) => {\n    const wallet = loadWallet();\n    if (!wallet) fail(\"No wallet file found.\");\n    let destination = wallet.funder;\n    if (!destination) {\n      console.error(\n        JSON.stringify({\n          info: \"No funder locked yet. Scanning chains for incoming USDC transfers...\",\n        })\n      );\n      const result = await detectFunder(wallet.address);\n      if (!result)\n        fail(\"No incoming USDC transfers found. Cannot determine funder address.\");\n      wallet.funder = result.funder;\n      saveWallet(wallet);\n      destination = result.funder;\n      console.error(\n        JSON.stringify({\n          info: `Funder auto-detected and locked: ${destination} (${result.chain})`,\n        })\n      );\n    }\n    const amount = parseFloat(amountStr);\n    if (isNaN(amount) || amount \u003C= 0) fail(\"Invalid amount.\");\n    const rawAmount = BigInt(Math.round(amount * 1e6));\n    const chain = WALLET_CHAIN_MAP[chainName];\n    const usdcAddr = USDC_ADDRESSES[chainName];\n    if (!chain || !usdcAddr) fail(`Unknown chain: ${chainName}`);\n    const secret = getOrCreateMasterSecret();\n    const pk = decryptPK(\n      wallet.encryptedKey,\n      wallet.iv,\n      wallet.authTag,\n      secret\n    );\n    const account = privateKeyToAccount(\n      (pk.startsWith(\"0x\") ? pk : `0x${pk}`) as `0x${string}`\n    );\n    const wc = createWalletClient({ account, chain, transport: http() });\n    const txHash = await wc.writeContract({\n      address: usdcAddr,\n      abi: ERC20_TRANSFER_ABI,\n      functionName: \"transfer\",\n      args: [destination as `0x${string}`, rawAmount],\n    });\n    out({\n      status: \"sent\",\n      txHash,\n      amount: amountStr,\n      chain: chainName,\n      destination,\n      note: \"Funds returned to original funder address.\",\n    });\n  });\n\nprogram\n  .command(\"wallet-detect-funder\")\n  .description(\n    \"Detect and lock the first address that sent USDC to this wallet\"\n  )\n  .action(async () => {\n    const wallet = loadWallet();\n    if (!wallet) fail(\"No wallet file found. Run wallet-init first.\");\n    if (wallet.funder) {\n      out({\n        funder: wallet.funder,\n        locked: true,\n        note: \"Funder already locked. Cannot be changed.\",\n      });\n      return;\n    }\n    console.error(\n      JSON.stringify({\n        info: \"Scanning all chains for incoming USDC transfers...\",\n      })\n    );\n    const result = await detectFunder(wallet.address);\n    if (!result) {\n      out({\n        funder: null,\n        note: \"No incoming USDC transfers found yet. Send USDC to this wallet first.\",\n      });\n      return;\n    }\n    wallet.funder = result.funder;\n    saveWallet(wallet);\n    out({\n      funder: result.funder,\n      chain: result.chain,\n      locked: true,\n      note: \"Funder detected and permanently locked. Withdrawals will only go to this address.\",\n    });\n  });\n\n\u002F\u002F ─── Metadata Export ─────────────────────────────────────────────────────────\n\nif (process.argv.includes(\"--dump-commands\")) {\n  const commands = program.commands.map((cmd) => ({\n    name: cmd.name(),\n    description: cmd.description(),\n    arguments: cmd.registeredArguments.map((a) => ({\n      name: a.name(),\n      description: a.description,\n      required: a.required,\n    })),\n    options: cmd.options.map((o) => ({\n      flags: o.flags,\n      description: o.description,\n      defaultValue: o.defaultValue,\n    })),\n  }));\n  console.log(\n    JSON.stringify(\n      {\n        name: program.name(),\n        version: program.version(),\n        description: program.description(),\n        commands,\n      },\n      null,\n      2,\n    ),\n  );\n  process.exit(0);\n}\n\n\u002F\u002F ─── Parse ───────────────────────────────────────────────────────────────────\n\nprogram.parseAsync(process.argv).catch((err) => fail(err.message || String(err)));\n```\n\u003C!-- \u002FCLI_CODE -->\n\n### Step 3: Verify installation\n\n```bash\nnode ~\u002Fteneo-skill\u002Fteneo.ts health\n```\n\n### How to run all commands\n\nAll commands in this skill are run as:\n\n```bash\nnode ~\u002Fteneo-skill\u002Fteneo.ts \u003Ccommand> [options]\n```\n\n---\n\n## Authentication\n\nThe CLI creates and manages its own wallet automatically. Three tiers of key resolution (in priority order):\n\n### 1. Environment variable (highest priority)\n\n```bash\nexport TENEO_PRIVATE_KEY=4a8b1c2d3e4f5a6b7c8d9e0f1a2b3c4d5e6f7a8b9c0d1e2f3a4b5c6d7e8f9a2e\nnode ~\u002Fteneo-skill\u002Fteneo.ts command \"hotel-finder\" \"search vienna\" --room \u003CroomId>\n```\n\n### 2. Encrypted wallet file (auto-generated)\n\nOn first use, the CLI **auto-generates a new wallet** and stores it encrypted (AES-256-GCM) at `~\u002F.teneo-wallet\u002Fwallet.json`. No setup needed — just run any command.\n\nThe auto-generated key serves two purposes:\n- **Authentication** — signs the WebSocket handshake to prove identity on Teneo\n- **Payment** — signs x402 USDC transactions to pay agents\n\n### 3. .env file (auto-loaded from current directory)\n\n```bash\necho \"TENEO_PRIVATE_KEY=4a8b1c2d3e4f...\" > .env\nnode ~\u002Fteneo-skill\u002Fteneo.ts command \"hotel-finder\" \"search vienna\" --room \u003CroomId>\n```\n\n### Wallet Security\n\n- Private key encrypted at rest with **AES-256-GCM**\n- Master secret and wallet data in **separate files** (leaking one is useless without the other)\n- Both files have `0600` permissions (owner-only read\u002Fwrite)\n- Key **NEVER** logged, transmitted, or included in any API call — only cryptographic signatures are sent\n- Withdrawals can **only** go to the first address that funded the wallet (auto-detected, permanently locked)\n\n### Funding the wallet\n\n1. Run any command — a wallet is auto-generated and the address is printed\n2. Send USDC to that address on Base, Peaq, Avalanche, or X Layer\n3. The CLI detects the funder automatically and locks withdrawals to that address only\n\n### Network connections\n\n- Connects to **Teneo Protocol backend** at `wss:\u002F\u002Fbackend.developer.chatroom.teneo-protocol.ai\u002Fws` via WebSocket\n- This is the official Teneo Protocol endpoint\n- The SDK is published on npm: https:\u002F\u002Fwww.npmjs.com\u002Fpackage\u002F@teneo-protocol\u002Fsdk\n\n---\n\n## IMPORTANT: Always Show Status Updates\n\nTeneo commands can take 10-30+ seconds. **Never leave the user staring at a blank screen.** Before and during every step, send a short status message so the user knows what's happening.\n\n**Example flow when a user asks \"search @elonmusk on X\":**\n\n> Checking which agents are in the room...\n> X Platform Agent is in the room.\n> Requesting price quote for the search...\n> Quote received: 0.05 USDC. Confirming payment...\n> Payment confirmed. Waiting for agent response...\n> Here are the results:\n\n**Rules:**\n1. **Before every CLI command**, tell the user what you're about to do in plain language\n2. **After each step completes**, confirm it before moving to the next step\n3. **If something takes more than a few seconds**, send a \"still waiting...\" or \"processing...\" update\n4. **On errors**, explain what went wrong and what you'll try next — don't just silently retry\n\n**Never run multiple commands in silence.** Each step should have a visible status update.\n\n---\n\n## IMPORTANT: Agent Discovery & Room Limits\n\n### Finding Agents\n\nTeneo has many agents available across the entire network. Use these commands to discover them:\n\n- **`discover`** → full JSON manifest of **ALL agents** with commands, pricing, and capabilities — designed for AI agent consumption\n- **`list-agents`** → shows all agents with their IDs, commands, capabilities, and pricing. Supports `--online`, `--free`, `--search` filters.\n- **`info \u003CagentId>`** → full details for one agent (commands with exact syntax + pricing)\n- **`room-agents \u003CroomId>`** → shows agents currently IN your room\n\n**IMPORTANT: Agent IDs vs Display Names.** Agents have an internal ID (e.g. `x-agent-enterprise-v2`) and a display name (e.g. \"X Platform Agent\"). **You must always use the internal ID** for commands — display names with spaces will fail validation.\n\n### Agent \"Online\" does not mean Reachable\n\nAn agent can show `\"status\": \"online\"` in `info` but still be **disconnected in your room**. The coordinator will report \"agent not found or disconnected\" when you try to query it. This means:\n- Always **test an agent with a cheap command first** before relying on it\n- If an agent is disconnected, **look for alternative agents** that serve the same purpose\n- Multiple agents often serve overlapping purposes — know your fallbacks\n\n### Pre-Query Checklist\n\nBefore **every** agent query, follow this checklist:\n\n1. **Get agent commands** — run `info \u003CagentId>` to see exact command syntax and pricing. Never guess commands.\n2. **Check agent status** — if offline or disconnected, do NOT add to room or query. Find an alternative.\n3. **Check room capacity** — run `room-agents \u003CroomId>` to see current agents (max 5). If full, remove one or create a new room.\n4. **Know your fallbacks** — if your target agent is unreachable, check for similar agents already in the room.\n5. **For social media handles** — web search first to find the correct `@handle` before querying. Wrong handles waste money.\n\n### Room Rules\n\nTeneo organizes agents into **rooms**. You MUST understand these rules:\n\n1. **Maximum 5 agents per room.** A room can hold at most 5 agents at a time.\n2. **You can only query agents that are in your room.** If an agent is not in the room, commands to it will fail.\n3. **To use a different agent**, find it with `list-agents`, then add it with `add-agent \u003CroomId> \u003CagentId>`.\n4. **If the room already has 5 agents**, you must first remove one with `remove-agent \u003CroomId> \u003CagentId>` before adding another.\n5. **Check who is in the room** with `room-agents \u003CroomId>` before sending commands.\n\n**If the room is full or things get confusing**, you can always create a fresh room with `create-room \"Task Name\"` and invite only the agent(s) needed for the current task.\n\n**Always communicate this to the user.** When a user asks to use an agent that is not in the room, explain:\n- Which agents are currently in the room (and that the limit is 5)\n- That the requested agent needs to be added first\n- If the room is full, offer two options: remove an agent to make space, or create a new room for the task\n\n---\n\n\u003C!-- COMMAND_REFERENCE -->\n## Command Reference\n\n24 commands across agent discovery, execution, room management, and wallet operations. All commands return JSON to stdout.\n\n```\nAGENT DISCOVERY\n  node ~\u002Fteneo-skill\u002Fteneo.ts health                 Check connection health\n  node ~\u002Fteneo-skill\u002Fteneo.ts discover               Full JSON manifest of all agents, commands, and pricing — designed for AI agent consumption\n  node ~\u002Fteneo-skill\u002Fteneo.ts list-agents            List all agents on the Teneo network\n  node ~\u002Fteneo-skill\u002Fteneo.ts info \u003CagentId>         Show agent details, commands, and pricing\n\nAGENT COMMANDS\n  node ~\u002Fteneo-skill\u002Fteneo.ts command \u003Cagent> \u003Ccmd>  Direct command to agent (use internal agent ID, not display name)\n  node ~\u002Fteneo-skill\u002Fteneo.ts quote \u003Cmessage>        Request price quote (no execution)\n  node ~\u002Fteneo-skill\u002Fteneo.ts confirm \u003CtaskId>       Confirm quoted task with payment\n\nROOM MANAGEMENT\n  node ~\u002Fteneo-skill\u002Fteneo.ts rooms                  List all rooms\n  node ~\u002Fteneo-skill\u002Fteneo.ts room-agents \u003CroomId>   List agents in room\n  node ~\u002Fteneo-skill\u002Fteneo.ts create-room \u003Cname>     Create room\n  node ~\u002Fteneo-skill\u002Fteneo.ts update-room \u003CroomId>   Update room\n  node ~\u002Fteneo-skill\u002Fteneo.ts delete-room \u003CroomId>   Delete room\n  node ~\u002Fteneo-skill\u002Fteneo.ts add-agent \u003CroomId> \u003CagentId> Add agent to room\n  node ~\u002Fteneo-skill\u002Fteneo.ts remove-agent \u003CroomId> \u003CagentId> Remove agent from room\n  node ~\u002Fteneo-skill\u002Fteneo.ts owned-rooms            List rooms you own\n  node ~\u002Fteneo-skill\u002Fteneo.ts shared-rooms           List rooms shared with you\n  node ~\u002Fteneo-skill\u002Fteneo.ts subscribe \u003CroomId>     Subscribe to public room\n  node ~\u002Fteneo-skill\u002Fteneo.ts unsubscribe \u003CroomId>   Unsubscribe from room\n\nWALLET MANAGEMENT\n  node ~\u002Fteneo-skill\u002Fteneo.ts wallet-init            Generate a new wallet (auto-called on first use)\n  node ~\u002Fteneo-skill\u002Fteneo.ts wallet-address         Show wallet public address\n  node ~\u002Fteneo-skill\u002Fteneo.ts wallet-export-key      Export private key (DANGEROUS)\n  node ~\u002Fteneo-skill\u002Fteneo.ts wallet-balance         Check USDC balance on supported chains\n  node ~\u002Fteneo-skill\u002Fteneo.ts wallet-withdraw \u003Camount> \u003Cchain> Withdraw USDC back to original funder ONLY\n  node ~\u002Fteneo-skill\u002Fteneo.ts wallet-detect-funder   Detect and lock the first address that sent USDC to this wallet\n\n```\n\n### Agent Discovery\n\n#### `health`\n\nCheck connection health\n\n```bash\nnode ~\u002Fteneo-skill\u002Fteneo.ts health\n```\n\n#### `discover`\n\nFull JSON manifest of all agents, commands, and pricing — designed for AI agent consumption\n\n```bash\nnode ~\u002Fteneo-skill\u002Fteneo.ts discover\n```\n\n#### `list-agents`\n\nList all agents on the Teneo network\n\n```bash\nnode ~\u002Fteneo-skill\u002Fteneo.ts list-agents [--online] [--free] [--search \u003Ckeyword>]\n```\n\n| Option | Description | Default |\n|--------|-------------|---------|\n| `--online` | Show only online agents | - |\n| `--free` | Show only agents with free commands | - |\n| `--search \u003Ckeyword>` | Search by name\u002Fdescription | - |\n\n#### `info`\n\nShow agent details, commands, and pricing\n\n```bash\nnode ~\u002Fteneo-skill\u002Fteneo.ts info \u003CagentId>\n```\n\n| Argument | Required | Description |\n|----------|:--------:|-------------|\n| `agentId` | Yes | - |\n\n### Agent Commands\n\n#### `command`\n\nDirect command to agent (use internal agent ID, not display name)\n\n```bash\nnode ~\u002Fteneo-skill\u002Fteneo.ts command \u003Cagent> \u003Ccmd> [--room \u003CroomId>] [--timeout \u003Cms>] [--chain \u003Cchain>]\n```\n\n| Argument | Required | Description |\n|----------|:--------:|-------------|\n| `agent` | Yes | Internal agent ID (e.g. x-agent-enterprise-v2) |\n| `cmd` | Yes | Command string: {trigger} {argument} |\n\n| Option | Description | Default |\n|--------|-------------|---------|\n| `--room \u003CroomId>` | - | - |\n| `--timeout \u003Cms>` | Response timeout | 120000 |\n| `--chain \u003Cchain>` | - | - |\n\n#### `quote`\n\nRequest price quote (no execution)\n\n```bash\nnode ~\u002Fteneo-skill\u002Fteneo.ts quote \u003Cmessage> [--room \u003CroomId>] [--chain \u003Cchain>]\n```\n\n| Argument | Required | Description |\n|----------|:--------:|-------------|\n| `message` | Yes | - |\n\n| Option | Description | Default |\n|--------|-------------|---------|\n| `--room \u003CroomId>` | - | - |\n| `--chain \u003Cchain>` | - | - |\n\n#### `confirm`\n\nConfirm quoted task with payment\n\n```bash\nnode ~\u002Fteneo-skill\u002Fteneo.ts confirm \u003CtaskId> [--room \u003CroomId>] [--timeout \u003Cms>]\n```\n\n| Argument | Required | Description |\n|----------|:--------:|-------------|\n| `taskId` | Yes | - |\n\n| Option | Description | Default |\n|--------|-------------|---------|\n| `--room \u003CroomId>` | - | - |\n| `--timeout \u003Cms>` | Response timeout | 120000 |\n\n### Room Management\n\n#### `rooms`\n\nList all rooms\n\n```bash\nnode ~\u002Fteneo-skill\u002Fteneo.ts rooms\n```\n\n#### `room-agents`\n\nList agents in room\n\n```bash\nnode ~\u002Fteneo-skill\u002Fteneo.ts room-agents \u003CroomId>\n```\n\n| Argument | Required | Description |\n|----------|:--------:|-------------|\n| `roomId` | Yes | - |\n\n#### `create-room`\n\nCreate room\n\n```bash\nnode ~\u002Fteneo-skill\u002Fteneo.ts create-room \u003Cname> [--description \u003Cdesc>] [--public]\n```\n\n| Argument | Required | Description |\n|----------|:--------:|-------------|\n| `name` | Yes | - |\n\n| Option | Description | Default |\n|--------|-------------|---------|\n| `--description \u003Cdesc>` | - | - |\n| `--public` | Make room public | false |\n\n#### `update-room`\n\nUpdate room\n\n```bash\nnode ~\u002Fteneo-skill\u002Fteneo.ts update-room \u003CroomId> [--name \u003Cname>] [--description \u003Cdesc>]\n```\n\n| Argument | Required | Description |\n|----------|:--------:|-------------|\n| `roomId` | Yes | - |\n\n| Option | Description | Default |\n|--------|-------------|---------|\n| `--name \u003Cname>` | - | - |\n| `--description \u003Cdesc>` | - | - |\n\n#### `delete-room`\n\nDelete room\n\n```bash\nnode ~\u002Fteneo-skill\u002Fteneo.ts delete-room \u003CroomId>\n```\n\n| Argument | Required | Description |\n|----------|:--------:|-------------|\n| `roomId` | Yes | - |\n\n#### `add-agent`\n\nAdd agent to room\n\n```bash\nnode ~\u002Fteneo-skill\u002Fteneo.ts add-agent \u003CroomId> \u003CagentId>\n```\n\n| Argument | Required | Description |\n|----------|:--------:|-------------|\n| `roomId` | Yes | - |\n| `agentId` | Yes | - |\n\n#### `remove-agent`\n\nRemove agent from room\n\n```bash\nnode ~\u002Fteneo-skill\u002Fteneo.ts remove-agent \u003CroomId> \u003CagentId>\n```\n\n| Argument | Required | Description |\n|----------|:--------:|-------------|\n| `roomId` | Yes | - |\n| `agentId` | Yes | - |\n\n#### `owned-rooms`\n\nList rooms you own\n\n```bash\nnode ~\u002Fteneo-skill\u002Fteneo.ts owned-rooms\n```\n\n#### `shared-rooms`\n\nList rooms shared with you\n\n```bash\nnode ~\u002Fteneo-skill\u002Fteneo.ts shared-rooms\n```\n\n#### `subscribe`\n\nSubscribe to public room\n\n```bash\nnode ~\u002Fteneo-skill\u002Fteneo.ts subscribe \u003CroomId>\n```\n\n| Argument | Required | Description |\n|----------|:--------:|-------------|\n| `roomId` | Yes | - |\n\n#### `unsubscribe`\n\nUnsubscribe from room\n\n```bash\nnode ~\u002Fteneo-skill\u002Fteneo.ts unsubscribe \u003CroomId>\n```\n\n| Argument | Required | Description |\n|----------|:--------:|-------------|\n| `roomId` | Yes | - |\n\n### Wallet Management\n\n#### `wallet-init`\n\nGenerate a new wallet (auto-called on first use)\n\n```bash\nnode ~\u002Fteneo-skill\u002Fteneo.ts wallet-init\n```\n\n#### `wallet-address`\n\nShow wallet public address\n\n```bash\nnode ~\u002Fteneo-skill\u002Fteneo.ts wallet-address\n```\n\n#### `wallet-export-key`\n\nExport private key (DANGEROUS)\n\n```bash\nnode ~\u002Fteneo-skill\u002Fteneo.ts wallet-export-key\n```\n\n#### `wallet-balance`\n\nCheck USDC balance on supported chains\n\n```bash\nnode ~\u002Fteneo-skill\u002Fteneo.ts wallet-balance [--chain \u003Cchain>]\n```\n\n| Option | Description | Default |\n|--------|-------------|---------|\n| `--chain \u003Cchain>` | Specific chain (base|avax|peaq|xlayer) | - |\n\n#### `wallet-withdraw`\n\nWithdraw USDC back to original funder ONLY\n\n```bash\nnode ~\u002Fteneo-skill\u002Fteneo.ts wallet-withdraw \u003Camount> \u003Cchain>\n```\n\n| Argument | Required | Description |\n|----------|:--------:|-------------|\n| `amount` | Yes | Amount in USDC |\n| `chain` | Yes | Chain (base|avax|peaq|xlayer) |\n\n#### `wallet-detect-funder`\n\nDetect and lock the first address that sent USDC to this wallet\n\n```bash\nnode ~\u002Fteneo-skill\u002Fteneo.ts wallet-detect-funder\n```\n\n\n\u003C!-- \u002FCOMMAND_REFERENCE -->\n\n---\n\n## Pricing Model\n\nEvery command has a pricing model. Check `pricePerUnit` and `taskUnit` in agent details before executing.\n\n| Field | Type | Description |\n|-------|------|-------------|\n| `pricePerUnit` | number | USDC amount per unit. `0` or absent = free. |\n| `taskUnit` | string | `\"per-query\"` = flat fee per call. `\"per-item\"` = price x item count. |\n\n### Supported Payment Networks\n\n| Network | Chain ID | USDC Contract |\n|---------|----------|---------------|\n| Base | `eip155:8453` | `0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913` |\n| Peaq | `eip155:3338` | `0xbbA60da06c2c5424f03f7434542280FCAd453d10` |\n| Avalanche | `eip155:43114` | `0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E` |\n| X Layer | `eip155:196` | `0x74b7F16337b8972027F6196A17a631aC6dE26d22` |\n\n### Payment flow\n\n1. You send a `command` to an agent\n2. The SDK requests a price quote from the agent\n3. If free (price=0), auto-confirms immediately\n4. If paid, auto-signs an x402 USDC payment and confirms\n5. Agent processes the request and returns data\n\nIf funds are insufficient on the default chain, try a different chain with `--chain`.\n\n---\n\n## Typical Workflow\n\n1. **Ensure wallet is funded** — run `node ~\u002Fteneo-skill\u002Fteneo.ts wallet-balance` to check USDC. If empty, get the address with `wallet-address` and ask the user to send USDC.\n2. **Check your room** — run `node ~\u002Fteneo-skill\u002Fteneo.ts room-agents \u003CroomId>` to see which agents are in your room (max 5)\n3. **Discover ALL agents** — run `node ~\u002Fteneo-skill\u002Fteneo.ts list-agents` or `discover` to see every agent on the Teneo network\n4. **Add agents to your room** — use `node ~\u002Fteneo-skill\u002Fteneo.ts add-agent \u003CroomId> \u003CagentId>` (remove one first if room is full)\n5. **Verify the agent is reachable** — test with a cheap command first\n6. **Send a command**: `node ~\u002Fteneo-skill\u002Fteneo.ts command \"\u003CagentId>\" \"\u003Ctrigger> \u003Cargument>\" --room \u003Croom>` — always use the internal agent ID\n7. **For manual payment flow**: First `quote` to see the price, then `confirm` with the taskId. Note: `command` with autoApprove handles payment automatically.\n8. **Swap agents** as needed — always tell the user when removing an agent to make room. If an agent is dead, find an alternative.\n9. **Set TENEO_DEFAULT_ROOM** after creating a room so you don't need `--room` every time\n\n---\n\n## Searching for Users \u002F Handles on Platforms\n\nWhen a user asks to look up a social media account, there are two paths:\n\n### With `@` handle (direct query)\nIf the user provides an exact handle with `@` (e.g. `@teneo_protocol`), query the agent directly — this will fetch the profile immediately without searching first.\n\n### Without `@` (web search first, then query)\nIf the user provides a name without `@` (e.g. \"teneo protocol\"), you **must find the correct handle first**. **Never guess handles** — wrong handles waste money ($0.001 each) and return wrong data.\n\n**Step 1: Web search to find the correct handle.** Tell the user:\n> \"Searching the web for the correct handle...\"\n\nUse a web search (not the Teneo agent) to find the official handle. Look for:\n- The most prominent result (highest followers, verified badge)\n- Official website links that confirm the handle\n- Be careful of impostor\u002Fdead accounts with similar names\n\n**Step 2: Check for handle changes.** Sometimes an account's bio says \"we are now @newhandle on X\" (e.g. `@peaqnetwork` -> `@peaq`). If you see this, use the new handle.\n\n**Step 3: Query with the confirmed handle.**\n\n**Always tell the user on first use:** Using `@handle` (e.g. `@teneo_protocol`) queries directly and is faster. Without the `@`, I need to search the web first to find the right handle.\n\n---\n\n## For AI Agent Integration\n\n### Recommended workflow\n\n#### Step 1: Discover what's available\n\n```bash\nnode ~\u002Fteneo-skill\u002Fteneo.ts discover\n```\n\nCache this output. It contains a full manifest of all agents, commands, and pricing.\n\n#### Step 2: Match user intent to a command\n\nSearch agent descriptions and command triggers semantically. Check pricing to inform the user about cost before executing.\n\n**Example matching logic:**\n- User says \"What's Elon's Twitter?\" -> match `@x-agent-enterprise-v2 user \u003Cusername>`\n- User says \"Find hotels in Vienna\" -> match `@hotel-finder search \u003Ccity>`\n- User says \"ETH gas price\" -> match `@gas-sniper-agent gas \u003Cchain>`\n\n#### Step 3: Execute the query\n\n```bash\nnode ~\u002Fteneo-skill\u002Fteneo.ts command \"\u003CagentId>\" \"\u003Ctrigger> \u003Cargument>\" --room \u003CroomId>\n```\n\n#### Step 4: Parse the response\n\nAll commands return JSON to stdout. Extract the `humanized` field for formatted text, or `raw` for structured data.\n\n#### Step 5: Handle errors\n\n| Error | Meaning | Action |\n|-------|---------|--------|\n| `\"agent not found or disconnected\"` | Agent offline in your room | Find alternative agent, or kick and re-add |\n| `\"room is full\"` | 5 agents already in room | Remove one or create new room |\n| `\"insufficient funds\"` | Wallet lacks USDC | Check balance, fund wallet, or try different chain |\n| `\"timeout\"` | No response in time | Retry once, then try different agent |\n| `\"All N attempts failed\"` | SDK connection failed | Check network, wait and retry |\n\n#### Step 6: Room error recovery\n\nIf a command fails with a room error, auto-recover:\n\n```bash\n# Agent not in room -> add it\nnode ~\u002Fteneo-skill\u002Fteneo.ts add-agent \u003CroomId> \u003CagentId>\n# Room full -> remove unused agent first\nnode ~\u002Fteneo-skill\u002Fteneo.ts remove-agent \u003CroomId> \u003CunusedAgentId>\nnode ~\u002Fteneo-skill\u002Fteneo.ts add-agent \u003CroomId> \u003CagentId>\n# No room -> create one\nnode ~\u002Fteneo-skill\u002Fteneo.ts create-room \"Auto Room\"\n```\n\n---\n\n## Error Handling\n\n### `agent not found or disconnected`\n**Cause:** Agent shows online but is disconnected in your room.\n**Fix:** Test with a cheap command first. If disconnected, find an alternative agent. Multiple agents often serve overlapping purposes (e.g. if `messari` is dead, `coinmarketcap-agent` can provide crypto quotes).\n\n### `Room is full (max 5 agents)`\n**Cause:** Room already has 5 agents.\n**Fix:** Remove an unused agent with `remove-agent \u003CroomId> \u003CagentId>`, or create a fresh room with `create-room \"Task Name\"`.\n\n### `AI coordinator is disabled`\n**Cause:** `sendMessage()` (auto-routing) returns 503. Only direct `@agent` commands work.\n**Fix:** Always use `command` with a specific agent ID, never freeform messages.\n\n### `Timeout waiting for response`\n**Cause:** Agent didn't respond in time. Possible dangling WebSocket on Teneo's side.\n**Fix:** The CLI auto-retries up to 3 times and kicks\u002Fre-adds the agent to reset the connection. If it still fails, try a different agent.\n\n### `Payment signing failed \u002F Insufficient funds`\n**Cause:** Wallet has no USDC on the required chain.\n**Fix:** Check balance with `wallet-balance`. Fund the wallet or try `--chain` with a different network.\n\n### `OOM on small instances`\n**Cause:** `npm install` gets killed on low-memory VMs.\n**Fix:** Use `NODE_OPTIONS=\"--max-old-space-size=512\"` and `--prefer-offline` during install.\n\n### Agent IDs with spaces fail\n**Cause:** The SDK only allows `[a-zA-Z0-9_-]` in agent IDs.\n**Fix:** Always use the internal agent ID (e.g. `x-agent-enterprise-v2`), never the display name (e.g. \"X Platform Agent\").\n\n---\n\n## Environment Variables\n\n| Variable | Required | Default | Description |\n|----------|----------|---------|-------------|\n| `TENEO_PRIVATE_KEY` | No | Auto-generated | 64 hex chars, no 0x prefix. Used for authentication and payment signing. |\n| `TENEO_WS_URL` | No | `wss:\u002F\u002Fbackend.developer.chatroom.teneo-protocol.ai\u002Fws` | Override the WebSocket endpoint. |\n| `TENEO_DEFAULT_ROOM` | No | _(none)_ | Default room ID so you don't need `--room` every time. |\n| `TENEO_DEFAULT_CHAIN` | No | `base` | Default payment chain: `base`, `avax`, `peaq`, or `xlayer`. |\n\nThe `.env` file in the current working directory is auto-loaded.\n\n---\n\n## Links\n\n- **Teneo Protocol:** https:\u002F\u002Fteneo-protocol.ai\n- **SDK (npm):** https:\u002F\u002Fwww.npmjs.com\u002Fpackage\u002F@teneo-protocol\u002Fsdk\n- **SDK (GitHub):** https:\u002F\u002Fgithub.com\u002FTeneoProtocolAI\u002Fteneo-agent-sdk\n- **Agent Console:** https:\u002F\u002Fagent-console.ai\n- **ClawHub (skill registry):** https:\u002F\u002Fclawhub.ai\u002Fteneoprotocoldev\u002Fteneo-agent-sdk\n- **Payment chains:** Base (8453), Peaq (3338), Avalanche (43114), X Layer (196)\n- **x402 Protocol:** https:\u002F\u002Fx402.org\n\n---\n\n\u003C!-- AGENTS_LIST -->\n\n## Available Agents\n\n| Agent | Commands | Description |\n|-------|:--------:|-------------|\n| [Amazon](https:\u002F\u002Fgithub.com\u002FTeneoProtocolAI\u002Fteneo-skills\u002Fblob\u002Fmain\u002Fskills\u002Fteneo-agent-amazon\u002FSKILL.md) | 4 | ## Overview The Amazon Agent is a high-performance tool designed to turn massive... |\n| [Gas War Sniper](https:\u002F\u002Fgithub.com\u002FTeneoProtocolAI\u002Fteneo-skills\u002Fblob\u002Fmain\u002Fskills\u002Fteneo-agent-gas-war-sniper\u002FSKILL.md) | 12 | Real-time multi-chain gas monitoring and spike detection. Monitors block-by-bloc... |\n| [Instagram Agent](https:\u002F\u002Fgithub.com\u002FTeneoProtocolAI\u002Fteneo-skills\u002Fblob\u002Fmain\u002Fskills\u002Fteneo-agent-instagram-agent\u002FSKILL.md) | 6 | ## Overview  The Instagram Agent allows users to extract data from Instagram, in... |\n| [Tiktok](https:\u002F\u002Fgithub.com\u002FTeneoProtocolAI\u002Fteneo-skills\u002Fblob\u002Fmain\u002Fskills\u002Fteneo-agent-tiktok\u002FSKILL.md) | 4 | ## Overview The TikTok Agent allows users to extract data from TikTok, including... |\n| [CoinMarketCap Agent](https:\u002F\u002Fgithub.com\u002FTeneoProtocolAI\u002Fteneo-skills\u002Fblob\u002Fmain\u002Fskills\u002Fteneo-agent-coinmarketcap-agent\u002FSKILL.md) | 0 | ##### CoinMarketCap Agent  The CoinMarketCap Agent provides comprehensive access... |\n| [Messari BTC & ETH Tracker](https:\u002F\u002Fgithub.com\u002FTeneoProtocolAI\u002Fteneo-skills\u002Fblob\u002Fmain\u002Fskills\u002Fteneo-agent-messari-btc-eth-tracker\u002FSKILL.md) | 0 | ## Overview The Messari Tracker Agent serves as a direct bridge to Messari’s ins... |\n| [X Platform Agent](https:\u002F\u002Fgithub.com\u002FTeneoProtocolAI\u002Fteneo-skills\u002Fblob\u002Fmain\u002Fskills\u002Fteneo-agent-x-platform-agent\u002FSKILL.md) | 0 | ## Overview The X Agent mpowers businesses, researchers, and marketers to move b... |\n\n\u003C!-- \u002FAGENTS_LIST -->\n",{"name":5,"version":24,"homepage":25,"metadata":26,"description":7},"2.0.0","https:\u002F\u002Fteneo-protocol.ai",{"teneo":27},{"sdk":28,"chains":29,"backend":34,"payment":35},"https:\u002F\u002Fwww.npmjs.com\u002Fpackage\u002F@teneo-protocol\u002Fsdk",[30,31,32,33],"base:8453","peaq:3338","avalanche:43114","xlayer:196","wss:\u002F\u002Fbackend.developer.chatroom.teneo-protocol.ai\u002Fws","x402-usdc","master","4aa004da461d820f4ea5499e58eb8d196cf99016","community\u002Fclawhub\u002Ft\u002Fteneo-agent-sdk",0,"https:\u002F\u002Fgithub.com\u002FLord1Egypt\u002Fawesome-skill-forge","https:\u002F\u002Fskill-explorer-rho.vercel.app","https:\u002F\u002Fgithub.com\u002FLord1Egypt","Unbreakable. Unstoppable. Unmatched⚡.\r\n Speaker of machine tongues 🤖  | World-builder of decentralized dreams 🌐 | Defender of the digital realm🛡️.","2026-06-10 08:21:01",{"source":8,"skillName":5,"commands":46,"prompt":56,"zipAvailable":57},[47,50,53],{"tool":48,"command":49},"npx","npx skills add Lord1Egypt\u002Fawesome-skill-forge --skill teneo-protocol-cli",{"tool":51,"command":52},"bunx","bunx skills add Lord1Egypt\u002Fawesome-skill-forge --skill teneo-protocol-cli",{"tool":54,"command":55},"pnpm","pnpm dlx skills add Lord1Egypt\u002Fawesome-skill-forge --skill teneo-protocol-cli","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FLord1Egypt\u002Fawesome-skill-forge\u002Fblob\u002Fmaster\u002Fcommunity\u002Fclawhub\u002Ft\u002Fteneo-agent-sdk\u002FSKILL.md",true,[],[60,67,74,81,88,95],{"skillNo":61,"name":62,"nameZh":6,"description":63,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":64,"categories":65,"keywords":66,"publishedAt":19},"01M785WKJB99G3STR1NF9NRTJW","youtube-content","YouTube transcripts to summaries, threads, blogs.","https:\u002F\u002Fgithub.com\u002FLord1Egypt\u002Fawesome-skill-forge\u002Fblob\u002Fmaster\u002Fskills\u002Fyoutube-content\u002FSKILL.md",[],[],{"skillNo":68,"name":69,"nameZh":6,"description":70,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":71,"categories":72,"keywords":73,"publishedAt":19},"01M785WEFHB0G2S9YA6EPR3H0E","xurl","X\u002FTwitter via xurl CLI: post, search, DM, media, v2 API.","https:\u002F\u002Fgithub.com\u002FLord1Egypt\u002Fawesome-skill-forge\u002Fblob\u002Fmaster\u002Fskills\u002Fxurl\u002FSKILL.md",[],[],{"skillNo":75,"name":76,"nameZh":6,"description":77,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":78,"categories":79,"keywords":80,"publishedAt":19},"01M785W98EDN4EFJXJPMQEHCRC","touchdesigner-mcp","Control a running TouchDesigner instance via twozero MCP — create operators, set parameters, wire connections, execute Python, build real-time visuals. 36 native tools.","https:\u002F\u002Fgithub.com\u002FLord1Egypt\u002Fawesome-skill-forge\u002Fblob\u002Fmaster\u002Fskills\u002Ftouchdesigner-mcp\u002FSKILL.md",[],[],{"skillNo":82,"name":83,"nameZh":6,"description":84,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":85,"categories":86,"keywords":87,"publishedAt":19},"01M785W5S9FP3QBH2V191E025P","test-driven-development","TDD: enforce RED-GREEN-REFACTOR, tests before code.","https:\u002F\u002Fgithub.com\u002FLord1Egypt\u002Fawesome-skill-forge\u002Fblob\u002Fmaster\u002Fskills\u002Ftest-driven-development\u002FSKILL.md",[],[],{"skillNo":89,"name":90,"nameZh":6,"description":91,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":92,"categories":93,"keywords":94,"publishedAt":19},"01M785W2AS08NSSH9YATCV6FJB","teams-meeting-pipeline","Operate the Teams meeting summary pipeline via Hermes CLI — summarize meetings, inspect pipeline status, replay jobs, manage Microsoft Graph subscriptions.","https:\u002F\u002Fgithub.com\u002FLord1Egypt\u002Fawesome-skill-forge\u002Fblob\u002Fmaster\u002Fskills\u002Fteams-meeting-pipeline\u002FSKILL.md",[],[],{"skillNo":96,"name":97,"nameZh":6,"description":98,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":99,"categories":100,"keywords":101,"publishedAt":19},"01M785VXKW4T34BTP1SCHW1R7F","systematic-debugging","4-phase root cause debugging: understand bugs before fixing.","https:\u002F\u002Fgithub.com\u002FLord1Egypt\u002Fawesome-skill-forge\u002Fblob\u002Fmaster\u002Fskills\u002Fsystematic-debugging\u002FSKILL.md",[],[]]