@toon-protocol/client-mcp 0.1.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. package/README.md +19 -38
  2. package/dist/app/index.html +166 -0
  3. package/dist/{chunk-5KFXUT5Q.js → chunk-CQ2QIZ6Z.js} +864 -604
  4. package/dist/chunk-CQ2QIZ6Z.js.map +1 -0
  5. package/dist/{chunk-FSS45ZX3.js → chunk-DLYE6U2Z.js} +1516 -316
  6. package/dist/chunk-DLYE6U2Z.js.map +1 -0
  7. package/dist/{chunk-3NAWISI5.js → chunk-QFHCXJ2V.js} +348 -101
  8. package/dist/chunk-QFHCXJ2V.js.map +1 -0
  9. package/dist/chunk-XV52IHVR.js +977 -0
  10. package/dist/chunk-XV52IHVR.js.map +1 -0
  11. package/dist/daemon.js +3 -4
  12. package/dist/daemon.js.map +1 -1
  13. package/dist/e2e/run-journey.d.ts +1 -0
  14. package/dist/e2e/run-journey.js +19953 -0
  15. package/dist/e2e/run-journey.js.map +1 -0
  16. package/dist/{ed25519-2QVPINLS.js → ed25519-2LFQXLYS.js} +6 -2
  17. package/dist/index.d.ts +282 -68
  18. package/dist/index.js +380 -5
  19. package/dist/index.js.map +1 -1
  20. package/dist/mcp.js +39 -6
  21. package/dist/mcp.js.map +1 -1
  22. package/package.json +11 -7
  23. package/dist/anon-proxy-W3KMM7GU-FN7ZJY7P.js +0 -25
  24. package/dist/chunk-3NAWISI5.js.map +0 -1
  25. package/dist/chunk-5KFXUT5Q.js.map +0 -1
  26. package/dist/chunk-FSS45ZX3.js.map +0 -1
  27. package/dist/chunk-SKQTKZIH.js +0 -278
  28. package/dist/chunk-SKQTKZIH.js.map +0 -1
  29. package/dist/chunk-ZQKYZJWT.js +0 -359
  30. package/dist/chunk-ZQKYZJWT.js.map +0 -1
  31. package/dist/ed25519-2QVPINLS.js.map +0 -1
  32. package/dist/gateway-QOK47RKS-SEGTXBR3.js +0 -16
  33. package/dist/gateway-QOK47RKS-SEGTXBR3.js.map +0 -1
  34. package/dist/socks5-WTJBYGME-6COK4LXW.js +0 -139
  35. package/dist/socks5-WTJBYGME-6COK4LXW.js.map +0 -1
  36. /package/dist/{anon-proxy-W3KMM7GU-FN7ZJY7P.js.map → ed25519-2LFQXLYS.js.map} +0 -0
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/mcp-tools.ts"],"sourcesContent":["/**\n * MCP tool definitions + dispatch. The MCP server is a thin proxy: each tool\n * maps to a `toon-clientd` control-plane call. This module is the testable core\n * (no stdio / SDK transport) so the tool→HTTP mapping and the\n * \"bootstrapping — retry\" handling can be unit-tested directly.\n */\n\nimport { ControlApiError, DaemonUnreachableError } from './control-client.js';\nimport type { ControlClient } from './control-client.js';\nimport type {\n AddApexRequest,\n NostrFilter,\n PublishRequest,\n SettlementChain,\n SwapRequest,\n} from './control-api.js';\n\n/** A JSON-Schema-described MCP tool. */\nexport interface ToolDefinition {\n name: string;\n description: string;\n inputSchema: Record<string, unknown>;\n}\n\n/** MCP tool-call result shape (subset of the SDK's CallToolResult). */\nexport interface ToolResult {\n content: { type: 'text'; text: string }[];\n isError?: boolean;\n}\n\nexport const TOOL_DEFINITIONS: ToolDefinition[] = [\n {\n name: 'toon_status',\n description:\n 'Report TOON client daemon health: bootstrapping/ready state, transport, ' +\n 'relay connection, buffered-event count, and per-chain settlement status.',\n inputSchema: {\n type: 'object',\n properties: {},\n additionalProperties: false,\n },\n },\n {\n name: 'toon_identity',\n description:\n \"Return this client's public identity (Nostr pubkey + EVM/Solana/Mina \" +\n 'addresses). Never returns private keys.',\n inputSchema: {\n type: 'object',\n properties: {},\n additionalProperties: false,\n },\n },\n {\n name: 'toon_publish',\n description:\n 'Pay-to-write: publish a fully-signed Nostr event to the TOON network. ' +\n 'Signs an off-chain payment-channel claim and forwards it over BTP. ' +\n 'Returns the event id, channel id, and the advanced channel nonce.',\n inputSchema: {\n type: 'object',\n properties: {\n event: {\n type: 'object',\n description:\n 'A fully-signed Nostr event (must include id, pubkey, sig, kind, ' +\n 'created_at, tags, content).',\n },\n destination: {\n type: 'string',\n description:\n 'Optional ILP destination override (default: the apex/town).',\n },\n fee: {\n type: 'string',\n description:\n 'Optional fee override in base units (default: daemon config).',\n },\n btpUrl: {\n type: 'string',\n description:\n 'Which apex (BTP write target) to publish through (default: the ' +\n 'config-seeded apex). Use toon_targets to list registered apexes. ' +\n 'Writes always go through BTP — never a relay directly.',\n },\n },\n required: ['event'],\n additionalProperties: false,\n },\n },\n {\n name: 'toon_subscribe',\n description:\n 'Free read: register a persistent town-relay subscription with NIP-01 ' +\n 'filter(s). Returns a subscription id to drain with toon_read.',\n inputSchema: {\n type: 'object',\n properties: {\n filters: {\n description: 'A NIP-01 filter object or an array of OR-ed filters.',\n },\n subId: { type: 'string', description: 'Optional caller-supplied id.' },\n relayUrl: {\n type: 'string',\n description:\n 'Restrict to one relay. Omit to FAN OUT across every registered ' +\n 'relay (reads merge into one ordered stream).',\n },\n },\n required: ['filters'],\n additionalProperties: false,\n },\n },\n {\n name: 'toon_read',\n description:\n 'Free read: drain buffered events newer than a cursor. Pass back the ' +\n 'returned cursor to fetch only events received since the last read.',\n inputSchema: {\n type: 'object',\n properties: {\n subId: { type: 'string', description: 'Restrict to one subscription.' },\n cursor: {\n type: 'number',\n description: 'Cursor from a prior toon_read.',\n },\n limit: {\n type: 'number',\n description: 'Max events to return (default 200).',\n },\n relayUrl: {\n type: 'string',\n description: 'Restrict the drain to events from a single relay.',\n },\n },\n additionalProperties: false,\n },\n },\n {\n name: 'toon_open_channel',\n description:\n 'Open (or return the existing) payment channel for a destination. ' +\n 'Channels open lazily on first publish; use this to pre-open.',\n inputSchema: {\n type: 'object',\n properties: {\n destination: {\n type: 'string',\n description: 'ILP destination (default: apex).',\n },\n },\n additionalProperties: false,\n },\n },\n {\n name: 'toon_channels',\n description:\n 'List tracked payment channels with their nonce watermark and cumulative ' +\n 'transferred amount.',\n inputSchema: {\n type: 'object',\n properties: {},\n additionalProperties: false,\n },\n },\n {\n name: 'toon_swap',\n description:\n 'Pay a mill peer (asset A) to receive asset B plus a signed target-chain ' +\n 'claim. Builds the NIP-59 gift-wrapped kind:20032 swap rumor and streams ' +\n 'it; the source-asset claim is signed against the open apex channel (the ' +\n 'mill must be routed via apexChildPeers). Returns the accumulated, ' +\n 'decrypted target-chain claim(s) and settlement metadata.',\n inputSchema: {\n type: 'object',\n properties: {\n destination: {\n type: 'string',\n description: 'Mill peer ILP destination (e.g. g.townhouse.mill).',\n },\n amount: {\n type: 'string',\n description: 'Total source-asset amount to swap, source micro-units.',\n },\n millPubkey: {\n type: 'string',\n description:\n \"Mill's 64-char lowercase hex Nostr pubkey (gift-wrap recipient).\",\n },\n pair: {\n type: 'object',\n description:\n 'The swap pair (from kind:10032 discovery or operator-supplied): ' +\n '{ from:{assetCode,assetScale,chain}, to:{...}, rate, minAmount?, maxAmount? }.',\n },\n chainRecipient: {\n type: 'string',\n description:\n \"Sender's payout address on pair.to.chain (EVM 0x-hex / Solana / Mina base58).\",\n },\n packetCount: {\n type: 'number',\n description: 'Split the swap into N equal packets (default 1).',\n },\n },\n required: [\n 'destination',\n 'amount',\n 'millPubkey',\n 'pair',\n 'chainRecipient',\n ],\n additionalProperties: false,\n },\n },\n {\n name: 'toon_targets',\n description:\n 'List every registered target: relays (read sources, with connection + ' +\n 'buffered-event status) and apexes (BTP write targets, with ready/' +\n 'channel status). The TOON client is 1-to-many — many apexes to write ' +\n 'through, many relays to read from.',\n inputSchema: {\n type: 'object',\n properties: {},\n additionalProperties: false,\n },\n },\n {\n name: 'toon_add_relay',\n description:\n 'Add a relay READ target at runtime (persisted across restarts). It joins ' +\n 'all fan-out reads immediately; `.anyone` hidden-service relays reuse the ' +\n 'managed anon read proxy automatically.',\n inputSchema: {\n type: 'object',\n properties: {\n relayUrl: {\n type: 'string',\n description: 'Relay WS URL (ws://host:7100 or a .anyone service).',\n },\n },\n required: ['relayUrl'],\n additionalProperties: false,\n },\n },\n {\n name: 'toon_remove_relay',\n description:\n 'Remove a relay read target (persisted). The config-seeded default relay ' +\n 'cannot be removed.',\n inputSchema: {\n type: 'object',\n properties: {\n relayUrl: { type: 'string', description: 'Relay WS URL to remove.' },\n },\n required: ['relayUrl'],\n additionalProperties: false,\n },\n },\n {\n name: 'toon_add_apex',\n description:\n 'Add an apex WRITE target at runtime (persisted across restarts). ' +\n 'Settlement params are DISCOVERED by reading the apex’s kind:10032 ' +\n 'announcement off the given relay — you do not supply chain/settlement ' +\n 'details. The relay is added as a read target first if unknown.',\n inputSchema: {\n type: 'object',\n properties: {\n ilpAddress: {\n type: 'string',\n description: 'ILP address of the apex (e.g. g.townhouse.town).',\n },\n relayUrl: {\n type: 'string',\n description: 'Relay to discover the apex’s kind:10032 on.',\n },\n pubkey: {\n type: 'string',\n description:\n 'Optional apex Nostr pubkey (64-char hex) to narrow discovery.',\n },\n chain: {\n type: 'string',\n enum: ['evm', 'solana', 'mina'],\n description: 'Preferred settlement chain (default: apex’s first).',\n },\n childPeers: {\n type: 'array',\n items: { type: 'string' },\n description:\n 'Child peers via this apex’s channel (e.g. [\"dvm\",\"mill\"]).',\n },\n feePerEvent: {\n type: 'string',\n description: 'Per-write fee override for this apex (base units).',\n },\n },\n required: ['ilpAddress', 'relayUrl'],\n additionalProperties: false,\n },\n },\n {\n name: 'toon_remove_apex',\n description:\n 'Remove an apex write target by its BTP URL (persisted). The ' +\n 'config-seeded default apex cannot be removed.',\n inputSchema: {\n type: 'object',\n properties: {\n btpUrl: {\n type: 'string',\n description: 'BTP URL of the apex to remove (from toon_targets).',\n },\n },\n required: ['btpUrl'],\n additionalProperties: false,\n },\n },\n];\n\n/**\n * Dispatch an MCP tool call to the daemon control plane. Always resolves with a\n * `ToolResult` (errors are encoded as `isError: true` text, not thrown, so the\n * agent sees a readable message). A retryable error (daemon still\n * bootstrapping) yields a clear \"retry shortly\" message.\n */\nexport async function dispatchTool(\n client: ControlClient,\n name: string,\n args: Record<string, unknown>\n): Promise<ToolResult> {\n try {\n switch (name) {\n case 'toon_status':\n return ok(await client.status());\n case 'toon_identity': {\n const s = await client.status();\n return ok({\n identity: s.identity,\n ready: s.ready,\n bootstrapping: s.bootstrapping,\n });\n }\n case 'toon_publish':\n return ok(await client.publish(args as unknown as PublishRequest));\n case 'toon_subscribe':\n return ok(\n await client.subscribe({\n filters: args['filters'] as NostrFilter | NostrFilter[],\n ...(typeof args['subId'] === 'string'\n ? { subId: args['subId'] }\n : {}),\n ...(typeof args['relayUrl'] === 'string'\n ? { relayUrl: args['relayUrl'] }\n : {}),\n })\n );\n case 'toon_read':\n return ok(\n await client.events({\n ...(typeof args['subId'] === 'string'\n ? { subId: args['subId'] }\n : {}),\n ...(typeof args['cursor'] === 'number'\n ? { cursor: args['cursor'] }\n : {}),\n ...(typeof args['limit'] === 'number'\n ? { limit: args['limit'] }\n : {}),\n ...(typeof args['relayUrl'] === 'string'\n ? { relayUrl: args['relayUrl'] }\n : {}),\n })\n );\n case 'toon_open_channel':\n return ok(\n await client.openChannel(\n typeof args['destination'] === 'string'\n ? { destination: args['destination'] }\n : {}\n )\n );\n case 'toon_channels':\n return ok(await client.channels());\n case 'toon_swap':\n return ok(\n await client.swap({\n destination: String(args['destination']),\n amount: String(args['amount']),\n millPubkey: String(args['millPubkey']),\n pair: args['pair'] as SwapRequest['pair'],\n chainRecipient: String(args['chainRecipient']),\n ...(typeof args['packetCount'] === 'number'\n ? { packetCount: args['packetCount'] }\n : {}),\n })\n );\n case 'toon_targets':\n return ok(await client.targets());\n case 'toon_add_relay':\n return ok(\n await client.addRelay({ relayUrl: String(args['relayUrl']) })\n );\n case 'toon_remove_relay':\n return ok(\n await client.removeRelay({ relayUrl: String(args['relayUrl']) })\n );\n case 'toon_add_apex': {\n const req: AddApexRequest = {\n ilpAddress: String(args['ilpAddress']),\n relayUrl: String(args['relayUrl']),\n ...(typeof args['pubkey'] === 'string'\n ? { pubkey: args['pubkey'] }\n : {}),\n ...(typeof args['chain'] === 'string'\n ? { chain: args['chain'] as SettlementChain }\n : {}),\n ...(Array.isArray(args['childPeers'])\n ? { childPeers: (args['childPeers'] as unknown[]).map(String) }\n : {}),\n ...(typeof args['feePerEvent'] === 'string'\n ? { feePerEvent: args['feePerEvent'] }\n : {}),\n };\n return ok(await client.addApex(req));\n }\n case 'toon_remove_apex':\n return ok(await client.removeApex({ btpUrl: String(args['btpUrl']) }));\n default:\n return err(`Unknown tool: ${name}`);\n }\n } catch (e) {\n // A 504 is a retryable apex-discovery timeout — give a discovery-specific\n // hint rather than the daemon-bootstrapping one.\n if (e instanceof ControlApiError && e.status === 504) {\n return err(\n `${e.detail ?? e.message} — retry once the relay is reachable and the apex is online.`\n );\n }\n if (e instanceof ControlApiError && e.retryable) {\n return err(\n `TOON client is still bootstrapping (the anon proxy / BTP session can take ` +\n `30–90s) — retry shortly. (${e.message})`\n );\n }\n if (e instanceof DaemonUnreachableError) {\n return err(\n `TOON client daemon is not reachable at ${e.baseUrl}. It may have failed ` +\n `to start — check ~/.toon-client/daemon.log.`\n );\n }\n if (e instanceof ControlApiError) {\n return err(`${e.message}${e.detail ? `: ${e.detail}` : ''}`);\n }\n return err(e instanceof Error ? e.message : String(e));\n }\n}\n\nfunction ok(data: unknown): ToolResult {\n return { content: [{ type: 'text', text: JSON.stringify(data, null, 2) }] };\n}\n\nfunction err(message: string): ToolResult {\n return { content: [{ type: 'text', text: message }], isError: true };\n}\n"],"mappings":";;;;;;;AA8BO,IAAM,mBAAqC;AAAA,EAChD;AAAA,IACE,MAAM;AAAA,IACN,aACE;AAAA,IAEF,aAAa;AAAA,MACX,MAAM;AAAA,MACN,YAAY,CAAC;AAAA,MACb,sBAAsB;AAAA,IACxB;AAAA,EACF;AAAA,EACA;AAAA,IACE,MAAM;AAAA,IACN,aACE;AAAA,IAEF,aAAa;AAAA,MACX,MAAM;AAAA,MACN,YAAY,CAAC;AAAA,MACb,sBAAsB;AAAA,IACxB;AAAA,EACF;AAAA,EACA;AAAA,IACE,MAAM;AA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A,MACrC;AAAA,MACA,KAAK;AACH,eAAO,GAAG,MAAM,OAAO,WAAW,EAAE,QAAQ,OAAO,KAAK,QAAQ,CAAC,EAAE,CAAC,CAAC;AAAA,MACvE;AACE,eAAO,IAAI,iBAAiB,IAAI,EAAE;AAAA,IACtC;AAAA,EACF,SAAS,GAAG;AAGV,QAAI,aAAa,mBAAmB,EAAE,WAAW,KAAK;AACpD,aAAO;AAAA,QACL,GAAG,EAAE,UAAU,EAAE,OAAO;AAAA,MAC1B;AAAA,IACF;AACA,QAAI,aAAa,mBAAmB,EAAE,WAAW;AAC/C,aAAO;AAAA,QACL,iHAC+B,EAAE,OAAO;AAAA,MAC1C;AAAA,IACF;AACA,QAAI,aAAa,wBAAwB;AACvC,aAAO;AAAA,QACL,0CAA0C,EAAE,OAAO;AAAA,MAErD;AAAA,IACF;AACA,QAAI,aAAa,iBAAiB;AAChC,aAAO,IAAI,GAAG,EAAE,OAAO,GAAG,EAAE,SAAS,KAAK,EAAE,MAAM,KAAK,EAAE,EAAE;AAAA,IAC7D;AACA,WAAO,IAAI,aAAa,QAAQ,EAAE,UAAU,OAAO,CAAC,CAAC;AAAA,EACvD;AACF;AAEA,SAAS,GAAG,MAA2B;AACrC,SAAO,EAAE,SAAS,CAAC,EAAE,MAAM,QAAQ,MAAM,KAAK,UAAU,MAAM,MAAM,CAAC,EAAE,CAAC,EAAE;AAC5E;AAEA,SAAS,IAAI,SAA6B;AACxC,SAAO,EAAE,SAAS,CAAC,EAAE,MAAM,QAAQ,MAAM,QAAQ,CAAC,GAAG,SAAS,KAAK;AACrE;","names":[]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -1,16 +0,0 @@
1
- import { createRequire as __cr } from 'module'; const require = __cr(import.meta.url);
2
- import "./chunk-F22GNSF6.js";
3
-
4
- // ../client/dist/gateway-QOK47RKS.js
5
- function rewriteUrlsForGateway(gatewayUrl, btpUrl, connectorUrl) {
6
- const base = gatewayUrl.replace(/\/$/, "");
7
- const wsBase = base.replace(/^https:/, "wss:").replace(/^http:/, "ws:");
8
- return {
9
- btpUrl: btpUrl ? `${wsBase}/btp` : void 0,
10
- connectorUrl: connectorUrl ? `${base}/api` : void 0
11
- };
12
- }
13
- export {
14
- rewriteUrlsForGateway
15
- };
16
- //# sourceMappingURL=gateway-QOK47RKS-SEGTXBR3.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../client/src/transport/gateway.ts"],"sourcesContent":["/**\n * Gateway transport for browser environments.\n *\n * Rewrites BTP and HTTP URLs to route through an ator gateway that handles\n * SOCKS5 proxying server-side. Browser clients connect to the gateway via\n * standard WebSocket/HTTP — no special transport code needed.\n */\n\n/**\n * Rewrites btpUrl and connectorUrl to route through a gateway.\n *\n * Gateway endpoint conventions:\n * - WebSocket: `ws(s)://<gateway>/btp` — proxies BTP connections\n * - HTTP: `http(s)://<gateway>/api` — proxies connector admin API\n *\n * @param gatewayUrl - Base URL of the ator gateway (http:// or https://)\n * @param btpUrl - Original BTP WebSocket URL (optional)\n * @param connectorUrl - Original connector HTTP URL (optional)\n */\nexport function rewriteUrlsForGateway(\n gatewayUrl: string,\n btpUrl?: string,\n connectorUrl?: string\n): { btpUrl?: string; connectorUrl?: string } {\n const base = gatewayUrl.replace(/\\/$/, '');\n\n // Derive WebSocket scheme from HTTP scheme\n const wsBase = base.replace(/^https:/, 'wss:').replace(/^http:/, 'ws:');\n\n return {\n btpUrl: btpUrl ? `${wsBase}/btp` : undefined,\n connectorUrl: connectorUrl ? `${base}/api` : undefined,\n };\n}\n"],"mappings":";;;;AAmBO,SAAS,sBACd,YACA,QACA,cAC4C;AAC5C,QAAM,OAAO,WAAW,QAAQ,OAAO,EAAE;AAGzC,QAAM,SAAS,KAAK,QAAQ,WAAW,MAAM,EAAE,QAAQ,UAAU,KAAK;AAEtE,SAAO;IACL,QAAQ,SAAS,GAAG,MAAM,SAAS;IACnC,cAAc,eAAe,GAAG,IAAI,SAAS;EAC/C;AACF;","names":[]}
@@ -1,139 +0,0 @@
1
- import { createRequire as __cr } from 'module'; const require = __cr(import.meta.url);
2
- import "./chunk-F22GNSF6.js";
3
-
4
- // ../client/dist/socks5-WTJBYGME.js
5
- import { createConnection } from "net";
6
- import { createRequire } from "module";
7
- var require2 = createRequire(import.meta.url);
8
- function validateSocks5hUrl(socksProxy) {
9
- if (!socksProxy.startsWith("socks5h://")) {
10
- throw new Error(
11
- `SOCKS5 proxy URL must use socks5h:// scheme (got "${socksProxy.split("://")[0]}://"). The "h" suffix ensures DNS resolution happens at the proxy, preventing leaks of .anyone hostnames.`
12
- );
13
- }
14
- const httpUrl = socksProxy.replace(/^socks5h:\/\//, "http://");
15
- let parsed;
16
- try {
17
- parsed = new URL(httpUrl);
18
- } catch {
19
- throw new Error(`Malformed SOCKS5 proxy URL: "${socksProxy}"`);
20
- }
21
- const host = parsed.hostname;
22
- const port = parsed.port ? parseInt(parsed.port, 10) : 1080;
23
- if (!host) {
24
- throw new Error(`SOCKS5 proxy URL missing host: "${socksProxy}"`);
25
- }
26
- if (port < 0 || port > 65535 || !Number.isFinite(port)) {
27
- throw new Error(`SOCKS5 proxy port out of range (0\u201365535): ${parsed.port}`);
28
- }
29
- return { host, port };
30
- }
31
- function createSocks5WebSocketFactory(socksProxy) {
32
- validateSocks5hUrl(socksProxy);
33
- const { SocksProxyAgent } = require2("socks-proxy-agent");
34
- const WS = require2("ws");
35
- const agent = new SocksProxyAgent(socksProxy, { timeout: 12e4 });
36
- const ws = WS;
37
- const WSClass = typeof ws === "function" ? ws : typeof ws.default === "function" ? ws.default : typeof ws.WebSocket === "function" ? ws.WebSocket : null;
38
- if (WSClass === null) {
39
- throw new Error(
40
- "createSocks5WebSocketFactory: require('ws') did not yield a constructor on .default, .WebSocket, or the module root."
41
- );
42
- }
43
- return (url) => (
44
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
45
- new WSClass(url, { agent })
46
- );
47
- }
48
- function createSocks5Fetch(socksProxy) {
49
- validateSocks5hUrl(socksProxy);
50
- const { SocksProxyAgent } = require2("socks-proxy-agent");
51
- const http = require2("node:http");
52
- const https = require2("node:https");
53
- const agent = new SocksProxyAgent(socksProxy);
54
- return (input, init) => {
55
- const url = typeof input === "string" ? input : input instanceof URL ? input.href : input.url;
56
- const parsedUrl = new URL(url);
57
- const isHttps = parsedUrl.protocol === "https:";
58
- const transport = isHttps ? https : http;
59
- return new Promise((resolve, reject) => {
60
- const method = init?.method ?? "GET";
61
- const headers = init?.headers ? Object.fromEntries(
62
- init.headers instanceof Headers ? init.headers.entries() : Array.isArray(init.headers) ? init.headers : Object.entries(init.headers)
63
- ) : {};
64
- const req = transport.request(
65
- url,
66
- { method, headers, agent, timeout: 3e4 },
67
- (res) => {
68
- const chunks = [];
69
- res.on("data", (chunk) => chunks.push(chunk));
70
- res.on("end", () => {
71
- const body = Buffer.concat(chunks);
72
- const responseHeaders = new Headers();
73
- for (const [key, val] of Object.entries(res.headers)) {
74
- if (val)
75
- responseHeaders.set(
76
- key,
77
- Array.isArray(val) ? val.join(", ") : val
78
- );
79
- }
80
- resolve(
81
- new Response(body, {
82
- status: res.statusCode ?? 200,
83
- statusText: res.statusMessage ?? "",
84
- headers: responseHeaders
85
- })
86
- );
87
- });
88
- }
89
- );
90
- req.on("error", reject);
91
- req.on("timeout", () => {
92
- req.destroy();
93
- reject(new Error("SOCKS5 proxied request timeout"));
94
- });
95
- if (init?.signal) {
96
- init.signal.addEventListener("abort", () => {
97
- req.destroy();
98
- reject(new Error("Aborted"));
99
- });
100
- }
101
- if (init?.body) {
102
- req.write(typeof init.body === "string" ? init.body : init.body);
103
- }
104
- req.end();
105
- });
106
- };
107
- }
108
- async function probeSocks5Proxy(socksProxy, timeoutMs = 2e3) {
109
- const { host, port } = validateSocks5hUrl(socksProxy);
110
- return new Promise((resolve, reject) => {
111
- const socket = createConnection({ host, port }, () => {
112
- socket.destroy();
113
- resolve();
114
- });
115
- socket.setTimeout(timeoutMs, () => {
116
- socket.destroy();
117
- reject(
118
- new Error(
119
- `SOCKS5 proxy at ${host}:${port} unreachable (timeout ${timeoutMs}ms). Refusing to start without privacy transport (fail-closed).`
120
- )
121
- );
122
- });
123
- socket.on("error", (err) => {
124
- socket.destroy();
125
- reject(
126
- new Error(
127
- `SOCKS5 proxy at ${host}:${port} unreachable: ${err.message}. Refusing to start without privacy transport (fail-closed).`
128
- )
129
- );
130
- });
131
- });
132
- }
133
- export {
134
- createSocks5Fetch,
135
- createSocks5WebSocketFactory,
136
- probeSocks5Proxy,
137
- validateSocks5hUrl
138
- };
139
- //# sourceMappingURL=socks5-WTJBYGME-6COK4LXW.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../client/src/transport/socks5.ts"],"sourcesContent":["/**\n * SOCKS5 transport helpers for Node.js environments.\n *\n * This module is dynamically imported only when `transport.type === 'socks5'`\n * is configured, keeping `ws` and `socks-proxy-agent` out of browser bundles.\n */\n\nimport { createConnection } from 'node:net';\nimport { createRequire } from 'node:module';\nimport type SocksProxyAgentModule from 'socks-proxy-agent';\nimport type WSModule from 'ws';\nimport type httpModule from 'node:http';\nimport type httpsModule from 'node:https';\n\n// ESM-safe require. This module builds as ESM (tsup `format: ['esm']`) with\n// `socks-proxy-agent`/`ws` external, so a bare `require(...)` would be rewritten\n// by esbuild into a `__require` shim that throws\n// `Dynamic require of \"socks-proxy-agent\" is not supported` for any pure-ESM\n// consumer — breaking the SOCKS5/ATOR transport entirely (the npm-consumer\n// toon-client image surfaced this). Building a real require off `import.meta.url`\n// (the same pattern as docker/esbuild.config.mjs's banner) keeps the\n// synchronous, browser-guarded `require(...)` calls below working in the\n// published ESM bundle while leaving the deps external. Browser bundlers never\n// reach this code: the module is dynamically imported only when\n// `transport.type === 'socks5'`, which is Node-only.\nconst require = createRequire(import.meta.url);\n\n/**\n * Parses and validates a `socks5h://` URL.\n * Enforces `socks5h://` scheme (not `socks5://`) to prevent DNS leaks —\n * `.anyone` hostnames must be resolved by the proxy, not locally.\n *\n * Mirrors the connector's `transport/socks-url.ts` validation logic.\n */\nexport function validateSocks5hUrl(socksProxy: string): {\n host: string;\n port: number;\n} {\n if (!socksProxy.startsWith('socks5h://')) {\n throw new Error(\n `SOCKS5 proxy URL must use socks5h:// scheme (got \"${socksProxy.split('://')[0]}://\"). ` +\n 'The \"h\" suffix ensures DNS resolution happens at the proxy, preventing leaks of .anyone hostnames.'\n );\n }\n\n // Parse by converting to http:// for URL constructor compatibility\n const httpUrl = socksProxy.replace(/^socks5h:\\/\\//, 'http://');\n let parsed: URL;\n try {\n parsed = new URL(httpUrl);\n } catch {\n throw new Error(`Malformed SOCKS5 proxy URL: \"${socksProxy}\"`);\n }\n\n const host = parsed.hostname;\n const port = parsed.port ? parseInt(parsed.port, 10) : 1080;\n\n if (!host) {\n throw new Error(`SOCKS5 proxy URL missing host: \"${socksProxy}\"`);\n }\n if (port < 0 || port > 65535 || !Number.isFinite(port)) {\n throw new Error(`SOCKS5 proxy port out of range (0–65535): ${parsed.port}`);\n }\n\n return { host, port };\n}\n\n/**\n * Creates a WebSocket factory that routes connections through a SOCKS5 proxy.\n * Uses the `ws` npm package (Node.js only) which accepts an `agent` option.\n */\nexport function createSocks5WebSocketFactory(\n socksProxy: string\n): (url: string) => WebSocket {\n validateSocks5hUrl(socksProxy);\n\n // Resolved via the module-scoped ESM-safe `require` (createRequire) above.\n const { SocksProxyAgent } =\n require('socks-proxy-agent') as typeof SocksProxyAgentModule;\n const WS = require('ws') as typeof WSModule;\n\n // 120s timeout: the socks library's default is 30s, which is too short for\n // the ATOR network to build circuits to fresh hidden services from certain\n // network paths (e.g., Akash datacenter → public ATOR proxy → local HS).\n // 120s gives the proxy time to find a working introduction-point circuit.\n const agent = new SocksProxyAgent(socksProxy, { timeout: 120_000 });\n\n // CJS/ESM interop: `require('ws')` can return any of three shapes depending on\n // the bundler/loader: the class directly (pure CJS); `{ default: WSClass, ... }`\n // (esModuleInterop=true / synthetic default); or `{ WebSocket: WSClass, ... }`\n // (named export, no default). Walk the ladder so this factory works in all\n // three environments. Pass 2 code review 2026-05-18: previous `(WS as any).default ?? WS`\n // would accept a namespace object as a \"constructor\" and throw cryptically.\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const ws = WS as any;\n const WSClass = (typeof ws === 'function'\n ? ws\n : typeof ws.default === 'function'\n ? ws.default\n : typeof ws.WebSocket === 'function'\n ? ws.WebSocket\n : null) as unknown as typeof WSModule.prototype.constructor;\n if (WSClass === null) {\n throw new Error(\n \"createSocks5WebSocketFactory: require('ws') did not yield a constructor on .default, .WebSocket, or the module root.\"\n );\n }\n\n return (url: string) =>\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n new (WSClass as any)(url, { agent }) as unknown as WebSocket;\n}\n\n/**\n * Creates a fetch wrapper that routes HTTP requests through a SOCKS5 proxy.\n * Uses `socks-proxy-agent` with Node.js `http`/`https` modules (not native\n * fetch, which uses undici and doesn't support SocksProxyAgent's dispatcher).\n */\nexport function createSocks5Fetch(socksProxy: string): typeof fetch {\n validateSocks5hUrl(socksProxy);\n\n // Resolved via the module-scoped ESM-safe `require` (createRequire) above.\n const { SocksProxyAgent } =\n require('socks-proxy-agent') as typeof SocksProxyAgentModule;\n const http = require('node:http') as typeof httpModule;\n const https = require('node:https') as typeof httpsModule;\n\n const agent = new SocksProxyAgent(socksProxy);\n\n return (input: string | URL | Request, init?: RequestInit) => {\n const url =\n typeof input === 'string'\n ? input\n : input instanceof URL\n ? input.href\n : input.url;\n const parsedUrl = new URL(url);\n const isHttps = parsedUrl.protocol === 'https:';\n const transport = isHttps ? https : http;\n\n return new Promise<Response>((resolve, reject) => {\n const method = init?.method ?? 'GET';\n const headers = init?.headers\n ? Object.fromEntries(\n init.headers instanceof Headers\n ? init.headers.entries()\n : Array.isArray(init.headers)\n ? init.headers\n : Object.entries(init.headers)\n )\n : {};\n\n const req = transport.request(\n url,\n { method, headers, agent, timeout: 30_000 },\n (res) => {\n const chunks: Buffer[] = [];\n res.on('data', (chunk: Buffer) => chunks.push(chunk));\n res.on('end', () => {\n const body = Buffer.concat(chunks);\n const responseHeaders = new Headers();\n for (const [key, val] of Object.entries(res.headers)) {\n if (val)\n responseHeaders.set(\n key,\n Array.isArray(val) ? val.join(', ') : val\n );\n }\n resolve(\n new Response(body, {\n status: res.statusCode ?? 200,\n statusText: res.statusMessage ?? '',\n headers: responseHeaders,\n })\n );\n });\n }\n );\n\n req.on('error', reject);\n req.on('timeout', () => {\n req.destroy();\n reject(new Error('SOCKS5 proxied request timeout'));\n });\n\n if (init?.signal) {\n init.signal.addEventListener('abort', () => {\n req.destroy();\n reject(new Error('Aborted'));\n });\n }\n\n if (init?.body) {\n req.write(typeof init.body === 'string' ? init.body : init.body);\n }\n req.end();\n });\n };\n}\n\n/**\n * Probes SOCKS5 proxy reachability with a TCP connection test.\n * Fail-closed: throws if the proxy is unreachable within the timeout.\n *\n * @param socksProxy - `socks5h://host:port` URL\n * @param timeoutMs - Connection timeout in milliseconds (default: 2000)\n */\nexport async function probeSocks5Proxy(\n socksProxy: string,\n timeoutMs = 2000\n): Promise<void> {\n const { host, port } = validateSocks5hUrl(socksProxy);\n\n return new Promise<void>((resolve, reject) => {\n const socket = createConnection({ host, port }, () => {\n socket.destroy();\n resolve();\n });\n\n socket.setTimeout(timeoutMs, () => {\n socket.destroy();\n reject(\n new Error(\n `SOCKS5 proxy at ${host}:${port} unreachable (timeout ${timeoutMs}ms). ` +\n 'Refusing to start without privacy transport (fail-closed).'\n )\n );\n });\n\n socket.on('error', (err) => {\n socket.destroy();\n reject(\n new Error(\n `SOCKS5 proxy at ${host}:${port} unreachable: ${err.message}. ` +\n 'Refusing to start without privacy transport (fail-closed).'\n )\n );\n });\n });\n}\n"],"mappings":";;;;AAOA,SAAS,wBAAwB;AACjC,SAAS,qBAAqB;AAiB9B,IAAMA,WAAU,cAAc,YAAY,GAAG;AAStC,SAAS,mBAAmB,YAGjC;AACA,MAAI,CAAC,WAAW,WAAW,YAAY,GAAG;AACxC,UAAM,IAAI;MACR,q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