agentcash 0.15.1 → 0.16.1

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 (63) hide show
  1. package/dist/cjs/run-server.cjs +115249 -106900
  2. package/dist/esm/{add-skill-5HFBHQTQ.js → add-skill-DPQR466Y.js} +4 -4
  3. package/dist/esm/{bridge-BOLVXKCD.js → bridge-JNIOVDD3.js} +3 -3
  4. package/dist/esm/{check-FEWY37RD.js → check-LR3CSSJF.js} +4 -4
  5. package/dist/esm/{chunk-MKA2PTOE.js → chunk-7VILIGSP.js} +2 -2
  6. package/dist/esm/{chunk-O57QVTLM.js → chunk-7WQMJKJR.js} +2 -2
  7. package/dist/esm/{chunk-TX7S7QGG.js → chunk-BLL6K4VP.js} +27 -43
  8. package/dist/esm/chunk-BLL6K4VP.js.map +1 -0
  9. package/dist/esm/{chunk-7CV5CENJ.js → chunk-CVVQQEP2.js} +2 -2
  10. package/dist/esm/{chunk-FBGNOXFP.js → chunk-DFKWVWIB.js} +72 -5
  11. package/dist/esm/chunk-DFKWVWIB.js.map +1 -0
  12. package/dist/esm/{chunk-PQXKQJIU.js → chunk-DZPXJSQF.js} +2 -2
  13. package/dist/esm/{chunk-BM5W5OV2.js → chunk-F2CAC7EO.js} +2 -2
  14. package/dist/esm/{chunk-W37JKCLN.js → chunk-H5V6L7NG.js} +2 -3
  15. package/dist/esm/{chunk-W37JKCLN.js.map → chunk-H5V6L7NG.js.map} +1 -1
  16. package/dist/esm/{chunk-2C7X7XIG.js → chunk-M3YTSL6T.js} +3 -3
  17. package/dist/esm/{chunk-66AVEFTO.js → chunk-MODREQSS.js} +3 -3
  18. package/dist/esm/{chunk-SLTRGQ7W.js → chunk-Q5YKPVXL.js} +3 -7
  19. package/dist/esm/{chunk-SLTRGQ7W.js.map → chunk-Q5YKPVXL.js.map} +1 -1
  20. package/dist/esm/{chunk-EDI77S36.js → chunk-R2DMZHHI.js} +18 -23
  21. package/dist/esm/chunk-R2DMZHHI.js.map +1 -0
  22. package/dist/esm/{chunk-K3WB4R2P.js → chunk-WPCEYCCK.js} +2 -2
  23. package/dist/esm/{discover-TXEJNB5A.js → discover-EIFUI6QT.js} +3 -3
  24. package/dist/esm/{fetch-AFKCCCHZ.js → fetch-DNP3HFLX.js} +6 -6
  25. package/dist/esm/index.js +20 -23
  26. package/dist/esm/index.js.map +1 -1
  27. package/dist/esm/{install-LAWJMMPO.js → install-5ZGCZP2G.js} +3 -3
  28. package/dist/esm/{onboard-W7CUGJJM.js → onboard-UI7N3VSS.js} +3 -3
  29. package/dist/esm/{origins-EVVF3N4G.js → origins-ZXQOPPWV.js} +4 -4
  30. package/dist/esm/{register-5KLJDRG4.js → register-CJS3SLVN.js} +3 -3
  31. package/dist/esm/{report-error-HN4YXEOC.js → report-error-YSAKMBMB.js} +3 -3
  32. package/dist/esm/{search-MEGI3KJW.js → search-AOPUK7XJ.js} +5 -5
  33. package/dist/esm/{server-7QJB55AW.js → server-M7PKUMAZ.js} +2 -2
  34. package/dist/esm/{server-M7SLAGFR.js → server-NFKD3OWT.js} +12 -12
  35. package/dist/esm/{sessions-NUOSJC6M.js → sessions-BMTVAZ3P.js} +3 -3
  36. package/dist/esm/{try-4RHB5KHZ.js → try-3CZ3JFD2.js} +3 -3
  37. package/package.json +2 -2
  38. package/dist/esm/chunk-EDI77S36.js.map +0 -1
  39. package/dist/esm/chunk-FBGNOXFP.js.map +0 -1
  40. package/dist/esm/chunk-TX7S7QGG.js.map +0 -1
  41. /package/dist/esm/{add-skill-5HFBHQTQ.js.map → add-skill-DPQR466Y.js.map} +0 -0
  42. /package/dist/esm/{bridge-BOLVXKCD.js.map → bridge-JNIOVDD3.js.map} +0 -0
  43. /package/dist/esm/{check-FEWY37RD.js.map → check-LR3CSSJF.js.map} +0 -0
  44. /package/dist/esm/{chunk-MKA2PTOE.js.map → chunk-7VILIGSP.js.map} +0 -0
  45. /package/dist/esm/{chunk-O57QVTLM.js.map → chunk-7WQMJKJR.js.map} +0 -0
  46. /package/dist/esm/{chunk-7CV5CENJ.js.map → chunk-CVVQQEP2.js.map} +0 -0
  47. /package/dist/esm/{chunk-PQXKQJIU.js.map → chunk-DZPXJSQF.js.map} +0 -0
  48. /package/dist/esm/{chunk-BM5W5OV2.js.map → chunk-F2CAC7EO.js.map} +0 -0
  49. /package/dist/esm/{chunk-2C7X7XIG.js.map → chunk-M3YTSL6T.js.map} +0 -0
  50. /package/dist/esm/{chunk-66AVEFTO.js.map → chunk-MODREQSS.js.map} +0 -0
  51. /package/dist/esm/{chunk-K3WB4R2P.js.map → chunk-WPCEYCCK.js.map} +0 -0
  52. /package/dist/esm/{discover-TXEJNB5A.js.map → discover-EIFUI6QT.js.map} +0 -0
  53. /package/dist/esm/{fetch-AFKCCCHZ.js.map → fetch-DNP3HFLX.js.map} +0 -0
  54. /package/dist/esm/{install-LAWJMMPO.js.map → install-5ZGCZP2G.js.map} +0 -0
  55. /package/dist/esm/{onboard-W7CUGJJM.js.map → onboard-UI7N3VSS.js.map} +0 -0
  56. /package/dist/esm/{origins-EVVF3N4G.js.map → origins-ZXQOPPWV.js.map} +0 -0
  57. /package/dist/esm/{register-5KLJDRG4.js.map → register-CJS3SLVN.js.map} +0 -0
  58. /package/dist/esm/{report-error-HN4YXEOC.js.map → report-error-YSAKMBMB.js.map} +0 -0
  59. /package/dist/esm/{search-MEGI3KJW.js.map → search-AOPUK7XJ.js.map} +0 -0
  60. /package/dist/esm/{server-7QJB55AW.js.map → server-M7PKUMAZ.js.map} +0 -0
  61. /package/dist/esm/{server-M7SLAGFR.js.map → server-NFKD3OWT.js.map} +0 -0
  62. /package/dist/esm/{sessions-NUOSJC6M.js.map → sessions-BMTVAZ3P.js.map} +0 -0
  63. /package/dist/esm/{try-4RHB5KHZ.js.map → try-3CZ3JFD2.js.map} +0 -0
@@ -1,14 +1,14 @@
1
1
  import {
2
2
  resolveOrigin
3
- } from "./chunk-O57QVTLM.js";
3
+ } from "./chunk-7WQMJKJR.js";
4
4
  import {
5
5
  installSkills
6
6
  } from "./chunk-FVVSNDQR.js";
7
7
  import {
8
8
  addUserOrigin
9
9
  } from "./chunk-YIU364NZ.js";
10
- import "./chunk-K3WB4R2P.js";
11
- import "./chunk-W37JKCLN.js";
10
+ import "./chunk-WPCEYCCK.js";
11
+ import "./chunk-H5V6L7NG.js";
12
12
  import "./chunk-KVSTJRSJ.js";
13
13
  import "./chunk-FB5CMO3J.js";
14
14
  import "./chunk-U6FRXL3X.js";
@@ -97,4 +97,4 @@ var addSkillCommand = async (input) => {
97
97
  export {
98
98
  addSkillCommand
99
99
  };
100
- //# sourceMappingURL=add-skill-5HFBHQTQ.js.map
100
+ //# sourceMappingURL=add-skill-DPQR466Y.js.map
@@ -1,10 +1,10 @@
1
1
  import {
2
2
  bridge,
3
3
  bridgeSchema
4
- } from "./chunk-MKA2PTOE.js";
4
+ } from "./chunk-7VILIGSP.js";
5
5
  import {
6
6
  DESCRIPTIONS
7
- } from "./chunk-W37JKCLN.js";
7
+ } from "./chunk-H5V6L7NG.js";
8
8
  import "./chunk-RAS5DZPQ.js";
9
9
  import {
10
10
  getWalletOrExit
@@ -54,4 +54,4 @@ var bridgeCommand = async (args) => {
54
54
  export {
55
55
  bridgeCommand
56
56
  };
57
- //# sourceMappingURL=bridge-BOLVXKCD.js.map
57
+ //# sourceMappingURL=bridge-JNIOVDD3.js.map
@@ -3,9 +3,9 @@ import {
3
3
  } from "./chunk-5CMVFNXO.js";
4
4
  import {
5
5
  cliRequestSchema
6
- } from "./chunk-2C7X7XIG.js";
7
- import "./chunk-SLTRGQ7W.js";
8
- import "./chunk-W37JKCLN.js";
6
+ } from "./chunk-M3YTSL6T.js";
7
+ import "./chunk-Q5YKPVXL.js";
8
+ import "./chunk-H5V6L7NG.js";
9
9
  import "./chunk-IKPLMFAK.js";
10
10
  import {
11
11
  RequestMethod
@@ -69,4 +69,4 @@ var checkCommand = async (args) => {
69
69
  export {
70
70
  checkCommand
71
71
  };
72
- //# sourceMappingURL=check-FEWY37RD.js.map
72
+ //# sourceMappingURL=check-LR3CSSJF.js.map
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  TOOL_PARAMS
3
- } from "./chunk-W37JKCLN.js";
3
+ } from "./chunk-H5V6L7NG.js";
4
4
  import {
5
5
  safeFetchJson
6
6
  } from "./chunk-RAS5DZPQ.js";
@@ -539,4 +539,4 @@ export {
539
539
  bridgeSchema,
540
540
  bridge
541
541
  };
542
- //# sourceMappingURL=chunk-MKA2PTOE.js.map
542
+ //# sourceMappingURL=chunk-7VILIGSP.js.map
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  discoverResources
3
- } from "./chunk-K3WB4R2P.js";
3
+ } from "./chunk-WPCEYCCK.js";
4
4
  import {
5
5
  errorResponse
6
6
  } from "./chunk-7EBJ4BCH.js";
@@ -52,4 +52,4 @@ function resolveDescription(result) {
52
52
  export {
53
53
  resolveOrigin
54
54
  };
55
- //# sourceMappingURL=chunk-O57QVTLM.js.map
55
+ //# sourceMappingURL=chunk-7WQMJKJR.js.map
@@ -1,12 +1,14 @@
1
1
  import {
2
+ createSessionStore,
2
3
  createTempoClient,
3
4
  mppErr,
4
5
  mppOk,
5
6
  mppResultFromPromise,
6
- mppResultFromThrowable,
7
+ readStoredChannel,
7
8
  safeGetMppChallenge,
8
- sessionCloseFailedErr
9
- } from "./chunk-FBGNOXFP.js";
9
+ sessionCloseFailedErr,
10
+ sessionScopeForUrl
11
+ } from "./chunk-DFKWVWIB.js";
10
12
  import {
11
13
  safeFetch,
12
14
  safeReadResponseText
@@ -15,10 +17,23 @@ import {
15
17
  // src/operations/sessions/close.ts
16
18
  import { Mppx, tempo as tempoMethod } from "mppx/client";
17
19
  import { Session } from "mppx/tempo";
18
- var DEFAULT_ESCROW_CONTRACT = "0x33b901018174DDabE4841042ab76ba85D4e24f25";
19
20
  async function closeMppSession(input, options) {
20
21
  const { surface, wallets } = options;
21
22
  const { channelId, url, cumulativeAmountRaw } = input;
23
+ const scope = sessionScopeForUrl(url, wallets.evm.address);
24
+ const stored = readStoredChannel(scope);
25
+ if (!stored) {
26
+ return mppErr(surface, {
27
+ cause: "mpp_session_close_no_channel",
28
+ message: `No tracked MPP session for ${scope}. agentcash records open channels per origin; there is nothing to close (it may already be closed, or was opened by a different client).`
29
+ });
30
+ }
31
+ if (channelId.toLowerCase() !== stored.channelId.toLowerCase()) {
32
+ return mppErr(surface, {
33
+ cause: "mpp_session_close_channel_mismatch",
34
+ message: `Requested channel ${channelId} does not match the tracked channel ${stored.channelId} for ${scope}.`
35
+ });
36
+ }
22
37
  const probeResult = await safeFetch(
23
38
  surface,
24
39
  new Request(url, { method: "POST" })
@@ -50,18 +65,7 @@ async function closeMppSession(input, options) {
50
65
  message: `${url} returned a ${challenge.method}:${challenge.intent} challenge, not a session challenge.`
51
66
  });
52
67
  }
53
- const methodDetails = challenge.request.methodDetails;
54
- const escrowContract = methodDetails?.escrowContract ?? DEFAULT_ESCROW_CONTRACT;
55
- const cumulativeResult = await resolveCloseCumulative({
56
- surface,
57
- channelId,
58
- escrowContract,
59
- cumulativeAmountRaw
60
- });
61
- if (cumulativeResult.isErr()) {
62
- return cumulativeResult;
63
- }
64
- const cumulativeRaw = cumulativeResult.value;
68
+ const cumulativeRaw = cumulativeAmountRaw ?? stored.cumulativeAmount;
65
69
  const mppx = Mppx.create({
66
70
  polyfill: false,
67
71
  methods: [
@@ -72,8 +76,9 @@ async function closeMppSession(input, options) {
72
76
  surface,
73
77
  mppx.createCredential(probeResponse, {
74
78
  action: "close",
75
- channelId,
76
- cumulativeAmountRaw: cumulativeRaw
79
+ channelId: stored.channelId,
80
+ cumulativeAmountRaw: cumulativeRaw,
81
+ descriptor: stored.descriptor
77
82
  }),
78
83
  (e) => sessionCloseFailedErr(e, "Failed to sign close credential")
79
84
  );
@@ -110,37 +115,16 @@ async function closeMppSession(input, options) {
110
115
  );
111
116
  }
112
117
  const receiptHeader = closeResponse.headers.get("Payment-Receipt");
113
- const receipt = receiptHeader ? Session.Receipt.deserializeSessionReceipt(receiptHeader) : null;
118
+ const receipt = receiptHeader ? Session.Precompile.Receipt.deserializeSessionReceipt(receiptHeader) : null;
119
+ void createSessionStore(scope).delete?.();
114
120
  return mppOk({
115
- channelId,
121
+ channelId: stored.channelId,
116
122
  cumulativeAmount: receipt?.spent ?? cumulativeRaw,
117
123
  ...receipt?.txHash ? { transactionHash: receipt.txHash } : {}
118
124
  });
119
125
  }
120
- async function resolveCloseCumulative(args) {
121
- const { surface, channelId, escrowContract, cumulativeAmountRaw } = args;
122
- if (cumulativeAmountRaw !== void 0) {
123
- return mppResultFromThrowable(
124
- surface,
125
- () => BigInt(cumulativeAmountRaw).toString(),
126
- (e) => sessionCloseFailedErr(e, "Invalid cumulativeAmountRaw")
127
- );
128
- }
129
- return mppResultFromPromise(
130
- surface,
131
- Session.Chain.getOnChainChannel(
132
- createTempoClient(),
133
- escrowContract,
134
- channelId
135
- ).then((onChain) => onChain.settled.toString()),
136
- (e) => sessionCloseFailedErr(
137
- e,
138
- `Failed to read on-chain channel state for ${channelId}`
139
- )
140
- );
141
- }
142
126
 
143
127
  export {
144
128
  closeMppSession
145
129
  };
146
- //# sourceMappingURL=chunk-TX7S7QGG.js.map
130
+ //# sourceMappingURL=chunk-BLL6K4VP.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/operations/sessions/close.ts"],"sourcesContent":["import type { Hex } from 'viem';\n\nimport { Mppx, tempo as tempoMethod } from 'mppx/client';\nimport { Session } from 'mppx/tempo';\n\nimport { safeFetch, safeReadResponseText } from '@/shared/neverthrow/fetch';\nimport {\n createTempoClient,\n mppErr,\n mppOk,\n mppResultFromPromise,\n safeGetMppChallenge,\n sessionCloseFailedErr,\n} from '@/shared/protocols/mpp';\nimport {\n createSessionStore,\n readStoredChannel,\n sessionScopeForUrl,\n} from '@/shared/protocols/mpp/session/session-store';\n\nimport type { GlobalFlags } from '@/types';\nimport type { Wallets } from '@/wallet';\n\nexport interface CloseSessionInput {\n channelId: Hex;\n url: string;\n cumulativeAmountRaw?: string;\n}\n\nexport interface CloseSessionOptions {\n surface: string;\n wallets: Wallets;\n flags: GlobalFlags;\n}\n\nexport interface CloseSessionResult {\n channelId: Hex;\n cumulativeAmount: string;\n transactionHash?: string;\n}\n\n/**\n * Closes a TIP-1034 (v2) Tempo session out of band.\n *\n * v2 channels can only be closed with their on-chain descriptor, which the\n * fetch flow persists per origin via {@link createSessionStore}. We load that\n * stored channel, sign a `close` credential against a fresh server challenge,\n * POST it for the server to settle on-chain, and drop the stored hint.\n */\nexport async function closeMppSession(\n input: CloseSessionInput,\n options: CloseSessionOptions\n) {\n const { surface, wallets } = options;\n const { channelId, url, cumulativeAmountRaw } = input;\n\n const scope = sessionScopeForUrl(url, wallets.evm.address);\n const stored = readStoredChannel(scope);\n if (!stored) {\n return mppErr(surface, {\n cause: 'mpp_session_close_no_channel',\n message: `No tracked MPP session for ${scope}. agentcash records open channels per origin; there is nothing to close (it may already be closed, or was opened by a different client).`,\n });\n }\n\n if (channelId.toLowerCase() !== stored.channelId.toLowerCase()) {\n return mppErr(surface, {\n cause: 'mpp_session_close_channel_mismatch',\n message: `Requested channel ${channelId} does not match the tracked channel ${stored.channelId} for ${scope}.`,\n });\n }\n\n const probeResult = await safeFetch(\n surface,\n new Request(url, { method: 'POST' })\n );\n if (probeResult.isErr()) {\n return mppErr(\n surface,\n sessionCloseFailedErr(\n probeResult.error.message,\n `Failed to probe ${url} for a session challenge`\n )\n );\n }\n const probeResponse = probeResult.value;\n\n if (probeResponse.status !== 402) {\n return mppErr(surface, {\n cause: 'mpp_session_close_no_challenge',\n message: `Expected a 402 session challenge from ${url}, received ${probeResponse.status} ${probeResponse.statusText}. The endpoint may not be MPP-protected or the channel has already been closed.`,\n });\n }\n\n const challengeResult = safeGetMppChallenge(surface, probeResponse);\n if (challengeResult.isErr()) {\n return challengeResult;\n }\n const challenge = challengeResult.value;\n\n if (challenge.intent !== 'session') {\n return mppErr(surface, {\n cause: 'mpp_session_close_no_challenge',\n message: `${url} returned a ${challenge.method}:${challenge.intent} challenge, not a session challenge.`,\n });\n }\n\n const cumulativeRaw = cumulativeAmountRaw ?? stored.cumulativeAmount;\n\n const mppx = Mppx.create({\n polyfill: false,\n methods: [\n tempoMethod({ account: wallets.evm, getClient: createTempoClient }),\n ],\n });\n\n const credentialResult = await mppResultFromPromise(\n surface,\n mppx.createCredential(probeResponse, {\n action: 'close',\n channelId: stored.channelId,\n cumulativeAmountRaw: cumulativeRaw,\n descriptor: stored.descriptor,\n }),\n e => sessionCloseFailedErr(e, 'Failed to sign close credential')\n );\n if (credentialResult.isErr()) {\n return credentialResult;\n }\n\n const closeResult = await safeFetch(\n surface,\n new Request(url, {\n method: 'POST',\n headers: { Authorization: credentialResult.value },\n })\n );\n if (closeResult.isErr()) {\n return mppErr(\n surface,\n sessionCloseFailedErr(\n closeResult.error.message,\n `Close POST to ${url} failed`\n )\n );\n }\n const closeResponse = closeResult.value;\n\n if (!closeResponse.ok) {\n const body = await safeReadResponseText(surface, closeResponse).unwrapOr(\n ''\n );\n const detail = body ? `: ${body}` : '';\n return mppErr(\n surface,\n sessionCloseFailedErr(\n `Server rejected close credential with ${closeResponse.status} ${closeResponse.statusText}${detail}. The cumulative-amount may be below the server's voucher state — retry with --cumulative-amount-raw set to the server's expected value.`\n )\n );\n }\n\n const receiptHeader = closeResponse.headers.get('Payment-Receipt');\n const receipt = receiptHeader\n ? Session.Precompile.Receipt.deserializeSessionReceipt(receiptHeader)\n : null;\n\n // Channel is settled on-chain — drop the stored hint so the next request to\n // this origin opens a fresh channel instead of reusing a closed one.\n void createSessionStore(scope).delete?.();\n\n return mppOk<CloseSessionResult>({\n channelId: stored.channelId,\n cumulativeAmount: receipt?.spent ?? cumulativeRaw,\n ...(receipt?.txHash ? { transactionHash: receipt.txHash } : {}),\n });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAEA,SAAS,MAAM,SAAS,mBAAmB;AAC3C,SAAS,eAAe;AA8CxB,eAAsB,gBACpB,O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SAAO,MAA0B;AAAA,IAC/B,WAAW,OAAO;AAAA,IAClB,kBAAkB,SAAS,SAAS;AAAA,IACpC,GAAI,SAAS,SAAS,EAAE,iBAAiB,QAAQ,OAAO,IAAI,CAAC;AAAA,EAC/D,CAAC;AACH;","names":[]}
@@ -6,7 +6,7 @@ import {
6
6
  } from "./chunk-27DZCYDB.js";
7
7
  import {
8
8
  INSTALL_PACKAGE_SPECIFIER
9
- } from "./chunk-PQXKQJIU.js";
9
+ } from "./chunk-DZPXJSQF.js";
10
10
  import {
11
11
  log,
12
12
  safeReadFile,
@@ -628,4 +628,4 @@ export {
628
628
  tryAddServer,
629
629
  addServer
630
630
  };
631
- //# sourceMappingURL=chunk-7CV5CENJ.js.map
631
+ //# sourceMappingURL=chunk-CVVQQEP2.js.map
@@ -2,6 +2,7 @@ import {
2
2
  EVM_CONFIGS
3
3
  } from "./chunk-HTGTKVXB.js";
4
4
  import {
5
+ configFile,
5
6
  err,
6
7
  ok,
7
8
  resultFromPromise,
@@ -11,7 +12,7 @@ import {
11
12
  // src/shared/protocols/mpp/index.ts
12
13
  import { Challenge, Receipt } from "mppx";
13
14
  import { Methods } from "mppx/tempo";
14
- import { Mppx, tempo as tempoMethod } from "mppx/client";
15
+ import { Mppx, tempo as tempoMethod, Transport } from "mppx/client";
15
16
  import { createClient, http } from "viem";
16
17
  var errorType = "mpp";
17
18
  var mppOk = (value) => ok(value);
@@ -56,6 +57,18 @@ var safeGetMppChallenge = (surface, response) => {
56
57
  })
57
58
  );
58
59
  };
60
+ var mppMethods = [Methods.charge, Methods.session];
61
+ var mppOnlyTransport = Transport.from({
62
+ name: "mpp-www-authenticate-only",
63
+ isPaymentRequired: (response) => response.status === 402,
64
+ getChallenges: (response) => response.headers.has("WWW-Authenticate") ? Challenge.fromResponseList(response, { methods: mppMethods }) : [],
65
+ getChallenge: (response) => Challenge.fromResponse(response, { methods: mppMethods }),
66
+ setCredential: (request, credential) => {
67
+ const headers = new Headers(request.headers);
68
+ headers.set("Authorization", credential);
69
+ return { ...request, headers };
70
+ }
71
+ });
59
72
  var safeCreateMppCredential = (surface, wallets, response) => {
60
73
  const client = Mppx.create({
61
74
  polyfill: false,
@@ -64,7 +77,8 @@ var safeCreateMppCredential = (surface, wallets, response) => {
64
77
  account: wallets.evm,
65
78
  getClient: createTempoClient
66
79
  })
67
- ]
80
+ ],
81
+ transport: mppOnlyTransport
68
82
  });
69
83
  return mppResultFromPromise(
70
84
  surface,
@@ -86,17 +100,70 @@ var safeGetMppReceipt = (surface, response) => {
86
100
  );
87
101
  };
88
102
 
103
+ // src/shared/protocols/mpp/session/session-store.ts
104
+ import fs from "fs";
105
+ var SESSIONS_FILE = configFile("sessions.json");
106
+ function readAll() {
107
+ if (!fs.existsSync(SESSIONS_FILE)) return {};
108
+ const parsed = resultFromThrowable(
109
+ "sessions_read_failed",
110
+ "mpp:session-store",
111
+ () => JSON.parse(fs.readFileSync(SESSIONS_FILE, "utf-8")),
112
+ (e) => ({
113
+ cause: "sessions_read_failed",
114
+ message: e instanceof Error ? e.message : String(e)
115
+ })
116
+ );
117
+ if (parsed.isErr()) return {};
118
+ return parsed.value && typeof parsed.value === "object" ? parsed.value : {};
119
+ }
120
+ function writeAll(all) {
121
+ fs.writeFileSync(SESSIONS_FILE, JSON.stringify(all, null, 2));
122
+ }
123
+ function isUsableEntry(entry) {
124
+ return !!entry && typeof entry === "object" && "descriptor" in entry && "channelId" in entry && "escrow" in entry;
125
+ }
126
+ function createSessionStore(scope) {
127
+ return {
128
+ get() {
129
+ const entry = readAll()[scope];
130
+ return isUsableEntry(entry) ? entry : null;
131
+ },
132
+ set(channel) {
133
+ const all = readAll();
134
+ all[scope] = channel;
135
+ writeAll(all);
136
+ },
137
+ delete() {
138
+ const all = readAll();
139
+ if (scope in all) {
140
+ delete all[scope];
141
+ writeAll(all);
142
+ }
143
+ }
144
+ };
145
+ }
146
+ function readStoredChannel(scope) {
147
+ const entry = readAll()[scope];
148
+ return isUsableEntry(entry) ? entry : null;
149
+ }
150
+ function sessionScopeForUrl(url, walletAddress) {
151
+ return `${walletAddress.toLowerCase()}:${new URL(url).origin}`;
152
+ }
153
+
89
154
  export {
90
155
  mppOk,
91
156
  mppErr,
92
157
  sessionRequestFailedErr,
93
158
  sessionCloseFailedErr,
94
159
  mppResultFromPromise,
95
- mppResultFromThrowable,
96
160
  createTempoClient,
97
161
  assertTempoUsdc,
98
162
  safeGetMppChallenge,
99
163
  safeCreateMppCredential,
100
- safeGetMppReceipt
164
+ safeGetMppReceipt,
165
+ createSessionStore,
166
+ readStoredChannel,
167
+ sessionScopeForUrl
101
168
  };
102
- //# sourceMappingURL=chunk-FBGNOXFP.js.map
169
+ //# sourceMappingURL=chunk-DFKWVWIB.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/shared/protocols/mpp/index.ts","../../src/shared/protocols/mpp/session/session-store.ts"],"sourcesContent":["import { Challenge, Receipt } from 'mppx';\nimport { Methods } from 'mppx/tempo';\nimport {\n err,\n ok,\n resultFromPromise,\n resultFromThrowable,\n} from '@agentcash/neverthrow';\n\nimport { Mppx, tempo as tempoMethod, Transport } from 'mppx/client';\n\nimport { type Address, createClient, http } from 'viem';\n\nimport { EVM_CONFIGS, Network } from '@agentcash/networks';\n\nimport type { BaseMppError } from './types';\nimport type { Wallets } from '@/wallet';\n\nconst errorType = 'mpp';\n\nexport const mppOk = <T>(value: T) => ok(value);\nexport const mppErr = (surface: string, error: BaseMppError) =>\n err(errorType, surface, error);\n\nconst formatErrMsg = (e: unknown, prefix?: string) => {\n const msg =\n e instanceof Error ? e.message : typeof e === 'string' ? e : String(e);\n return prefix ? `${prefix}: ${msg}` : msg;\n};\n\nexport const sessionRequestFailedErr = (e: unknown, prefix?: string) => ({\n cause: 'mpp_session_request_failed' as const,\n message: formatErrMsg(e, prefix),\n});\n\nexport const sessionCloseFailedErr = (e: unknown, prefix?: string) => ({\n cause: 'mpp_session_close_failed' as const,\n message: formatErrMsg(e, prefix),\n});\n\nexport const mppResultFromPromise = <T>(\n surface: string,\n promise: Promise<T>,\n error: (e: unknown) => BaseMppError\n) => resultFromPromise(errorType, surface, promise, error);\n\nexport const mppResultFromThrowable = <T>(\n surface: string,\n fn: () => T,\n error: (e: unknown) => BaseMppError\n) => resultFromThrowable(errorType, surface, fn, error);\n\nexport const createTempoClient = () =>\n createClient({\n chain: EVM_CONFIGS[Network.TEMPO].chain,\n transport: http(EVM_CONFIGS[Network.TEMPO].rpcUrl),\n });\n\nexport const assertTempoUsdc = (surface: string, tokenAddress: Address) => {\n const expected = EVM_CONFIGS[Network.TEMPO].usdcAddress;\n if (tokenAddress.toLowerCase() === expected.toLowerCase()) {\n return mppOk(true);\n }\n return mppErr(surface, {\n cause: 'unsupported_token',\n message: `Endpoint requires payment in token ${tokenAddress} on Tempo, but agentcash only supports ${expected}. The endpoint may be configured for a different token (e.g. PathUSD vs USDC).`,\n });\n};\n\nexport const safeGetMppChallenge = (surface: string, response: Response) => {\n return mppResultFromThrowable(\n surface,\n () =>\n Challenge.fromResponse(response, {\n methods: [Methods.charge, Methods.session],\n }),\n error => ({\n cause: 'parse_mpp_challenge',\n message:\n error instanceof Error\n ? error.message\n : 'Failed to parse MPP challenge from response',\n })\n );\n};\n\n// MPP-only transport: reads challenges from `WWW-Authenticate` and skips x402\n// `PAYMENT-REQUIRED` parsing entirely. The default `Transport.http()` parses both\n// protocols, and its EVM-only x402 schema throws on non-EVM `accepts` entries\n// (e.g. `solana:…`) before MPP signing runs. See issue #605.\nconst mppMethods = [Methods.charge, Methods.session];\n\nexport const mppOnlyTransport = Transport.from<RequestInit, Response>({\n name: 'mpp-www-authenticate-only',\n isPaymentRequired: response => response.status === 402,\n getChallenges: response =>\n response.headers.has('WWW-Authenticate')\n ? Challenge.fromResponseList(response, { methods: mppMethods })\n : [],\n getChallenge: response =>\n Challenge.fromResponse(response, { methods: mppMethods }),\n setCredential: (request, credential) => {\n const headers = new Headers(request.headers);\n headers.set('Authorization', credential);\n return { ...request, headers };\n },\n});\n\nexport const safeCreateMppCredential = (\n surface: string,\n wallets: Wallets,\n response: Response\n) => {\n const client = Mppx.create({\n polyfill: false,\n methods: [\n tempoMethod({\n account: wallets.evm,\n getClient: createTempoClient,\n }),\n ],\n transport: mppOnlyTransport,\n });\n\n return mppResultFromPromise(\n surface,\n client.createCredential(response),\n error => ({\n cause: 'create_mpp_credential',\n message:\n error instanceof Error\n ? error.message\n : 'Failed to create MPP credential',\n })\n );\n};\n\nexport const safeGetMppReceipt = (surface: string, response: Response) => {\n return mppResultFromThrowable(\n surface,\n () => Receipt.fromResponse(response),\n error => ({\n cause: 'parse_mpp_receipt',\n message:\n error instanceof Error\n ? error.message\n : 'Failed to parse MPP receipt from response',\n })\n );\n};\n","import fs from 'fs';\n\nimport { resultFromThrowable } from '@agentcash/neverthrow';\nimport type { Session } from 'mppx/tempo';\n\nimport { configFile } from '@/shared/fs';\n\ntype StoredSessionChannel = Session.Client.StoredSessionChannel;\ntype SessionStore = Session.Client.SessionStore;\n\nconst SESSIONS_FILE = configFile('sessions.json');\n\ntype SessionsFile = Record<string, StoredSessionChannel>;\n\nfunction readAll(): SessionsFile {\n if (!fs.existsSync(SESSIONS_FILE)) return {};\n const parsed = resultFromThrowable(\n 'sessions_read_failed',\n 'mpp:session-store',\n () => JSON.parse(fs.readFileSync(SESSIONS_FILE, 'utf-8')) as unknown,\n e => ({\n cause: 'sessions_read_failed' as const,\n message: e instanceof Error ? e.message : String(e),\n })\n );\n // A corrupt or unreadable file should never block a payment — start fresh.\n if (parsed.isErr()) return {};\n return parsed.value && typeof parsed.value === 'object'\n ? (parsed.value as SessionsFile)\n : {};\n}\n\nfunction writeAll(all: SessionsFile): void {\n fs.writeFileSync(SESSIONS_FILE, JSON.stringify(all, null, 2));\n}\n\n/**\n * A stored entry is only usable by the v2 session manager if it carries the\n * TIP-1034 `descriptor` needed to resume or close the channel. Legacy v1\n * entries (channelId-keyed, no descriptor) are ignored rather than handed to\n * the manager, where they would fail.\n */\nfunction isUsableEntry(entry: unknown): entry is StoredSessionChannel {\n return (\n !!entry &&\n typeof entry === 'object' &&\n 'descriptor' in entry &&\n 'channelId' in entry &&\n 'escrow' in entry\n );\n}\n\n/**\n * File-backed {@link SessionStore} scoped to a single origin.\n *\n * Persisting the channel hint (including its TIP-1034 descriptor) to\n * `~/.agentcash/sessions.json` lets the v2 session manager reuse an open\n * channel across separate `fetch` invocations and process restarts, and gives\n * `sessions_close` the descriptor it needs to settle a channel out of band.\n *\n * Scope is `walletAddress:origin` (see {@link sessionScopeForUrl}) so a channel\n * is only ever reused by the wallet that opened it.\n */\nexport function createSessionStore(scope: string): SessionStore {\n return {\n get() {\n const entry = readAll()[scope];\n return isUsableEntry(entry) ? entry : null;\n },\n set(channel) {\n const all = readAll();\n all[scope] = channel;\n writeAll(all);\n },\n delete() {\n const all = readAll();\n if (scope in all) {\n delete all[scope];\n writeAll(all);\n }\n },\n };\n}\n\n/** Reads the stored channel for an origin without constructing a store. */\nexport function readStoredChannel(scope: string): StoredSessionChannel | null {\n const entry = readAll()[scope];\n return isUsableEntry(entry) ? entry : null;\n}\n\n/**\n * Scope key for a stored channel: wallet address + request origin.\n *\n * A v2 channel is bound to its payer (the `descriptor.payer`), so the scope\n * must include the wallet — keying by origin alone would let a channel opened\n * by one wallet be handed to a different wallet (e.g. after `X402_PRIVATE_KEY`\n * changes against the same `~/.agentcash`), whose `payer` would not match and\n * whose reuse/close would fail. mppx frames the store as \"per-manager scope\",\n * and a manager is bound to one account — so this mirrors that.\n *\n * Example: `0xabc…:https://openai.mpp.tempo.xyz`.\n */\nexport function sessionScopeForUrl(url: string, walletAddress: string): string {\n return `${walletAddress.toLowerCase()}:${new URL(url).origin}`;\n}\n"],"mappings":";;;;;;;;;;;;AAAA,SAAS,WAAW,eAAe;AACnC,SAAS,eAAe;AAQxB,SAAS,MAAM,SAAS,aAAa,iBAAiB;AAEtD,SAAuB,cAAc,YAAY;AAOjD,IAAM,YAAY;AAEX,IAAM,QAAQ,CAAI,UAAa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{
6
6
  if (true) {
7
- return "0.15.1";
7
+ return "0.16.1";
8
8
  }
9
9
  const __dirname2 = dirname(fileURLToPath(import.meta.url));
10
10
  const pkg = JSON.parse(
@@ -23,4 +23,4 @@ export {
23
23
  MCP_VERSION,
24
24
  INSTALL_PACKAGE_SPECIFIER
25
25
  };
26
- //# sourceMappingURL=chunk-PQXKQJIU.js.map
26
+ //# sourceMappingURL=chunk-DZPXJSQF.js.map
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  MCP_VERSION
3
- } from "./chunk-PQXKQJIU.js";
3
+ } from "./chunk-DZPXJSQF.js";
4
4
  import {
5
5
  safeFetchJson
6
6
  } from "./chunk-RAS5DZPQ.js";
@@ -51,4 +51,4 @@ async function submitErrorReport(surface, input, address, dev) {
51
51
  export {
52
52
  submitErrorReport
53
53
  };
54
- //# sourceMappingURL=chunk-BM5W5OV2.js.map
54
+ //# sourceMappingURL=chunk-F2CAC7EO.js.map
@@ -200,8 +200,7 @@ var REQUEST_FETCH_PARAMS = {
200
200
  paymentProtocol: "Payment protocol to use when payment is required. If not specified, the payment protocol will be auto-detected.",
201
201
  paymentNetwork: "Chain to use for SIWX and payment when applicable. If not specified, the network will be auto-detected.",
202
202
  maxAmount: "Maximum amount (in USD) to pay per request. Aborts if the endpoint requests more. Defaults to $5. Pass a higher value for known-expensive endpoints.",
203
- stream: "Escape hatch for streaming MPP session endpoints. Typically unnecessary \u2014 a correctly configured server advertises `streaming: true` in its 402 challenge and the signer handles it automatically. Only pass this when the response is actually a stream AND the server fails to advertise it; otherwise long streams may stall once the initial deposit is exhausted.",
204
- channelId: "Reuse an existing MPP `tempo:session` payment channel instead of opening a new one. Pass the `channelId` surfaced in a prior fetch's paymentInfo. The channel must still have positive on-chain deposit and not be finalized; if it cannot be recovered, the request fails fast rather than silently opening a new channel. 0x-prefixed 32-byte hex string. Ignored by x402 (non-session) endpoints."
203
+ stream: "Escape hatch for streaming MPP session endpoints. Typically unnecessary \u2014 a correctly configured server advertises `streaming: true` in its 402 challenge and the signer handles it automatically. Only pass this when the response is actually a stream AND the server fails to advertise it; otherwise long streams may stall once the initial deposit is exhausted."
205
204
  };
206
205
  var TOOL_PARAMS = {
207
206
  bridge: {
@@ -286,4 +285,4 @@ export {
286
285
  REQUEST_FETCH_PARAMS,
287
286
  TOOL_PARAMS
288
287
  };
289
- //# sourceMappingURL=chunk-W37JKCLN.js.map
288
+ //# sourceMappingURL=chunk-H5V6L7NG.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/shared/descriptions.ts"],"sourcesContent":["/**\n * Single source of truth for all LLM-facing text in the MCP package.\n *\n * `DESCRIPTIONS` covers every tool with both an `mcp` variant (detailed,\n * AI-audience) and a `cli` variant (concise, human-readable for --help).\n * `serverInstructions` is shared across both surfaces.\n *\n * Additional exports cover parameter/output schema descriptions, origin\n * metadata, and prompt content — all LLM-facing text in one place.\n */\n\nimport type { UserOrigin } from './user-origins';\nimport { Origin } from './origins';\n\n// ─────────────────────────────────────────────────────────────────────────────\n// Origin metadata (used for MCP resource registration descriptions)\n// ─────────────────────────────────────────────────────────────────────────────\n\nexport const ORIGIN_METADATA: Record<\n string,\n { title: string; description: string }\n> = {\n [Origin.StableEnrich]: {\n title: 'StableEnrich',\n description:\n 'People/org search, Google Maps, Exa web search, LinkedIn data, Firecrawl scrape, WhitePages, email enrichment',\n },\n [Origin.StableSocial]: {\n title: 'StableSocial',\n description: 'Social media data for TikTok, Instagram, Facebook, Reddit',\n },\n [Origin.StableStudio]: {\n title: 'StableStudio',\n description: 'Generate and edit images and videos',\n },\n [Origin.StableUpload]: {\n title: 'StableUpload',\n description: 'Pay to upload files, get a permanent download URL.',\n },\n [Origin.StableEmail]: {\n title: 'StableEmail',\n description: 'Send emails',\n },\n [Origin.X402Scan]: {\n title: 'X402 Scan',\n description: 'x402 protocol explorer',\n },\n [Origin.Shirt]: {\n title: 'Shirt',\n description: 'Shirt.sh',\n },\n [Origin.X402Puppet]: {\n title: 'X402 Puppet',\n description: 'Browser automation',\n },\n [Origin.X402Facilitator]: {\n title: 'X402 Facilitator',\n description: 'Payment facilitation',\n },\n [Origin.StableMerch]: {\n title: 'StableMerch',\n description:\n 'Create shirts and mugs with custom images and have them shipped to your address.',\n },\n [Origin.StableVoice]: {\n title: 'StableVoice',\n description:\n 'Text-to-speech with 20+ bundled voices, custom voice cloning, multi-language support (23 languages), mp3/wav output',\n },\n [Origin.StableTube]: {\n title: 'StableTube',\n description:\n 'YouTube video downloads — POST a URL, get a direct CDN download link (expires ~6h)',\n },\n [Origin.StableKey]: {\n title: 'StableKey',\n description:\n 'VFX-grade neural green-screen unmixing (CorridorKey) — submit a green-screen plate, get alpha + foreground + RGBA outputs',\n },\n [Origin.StableMemes]: {\n title: 'StableMemes',\n description:\n 'Generate memes — caption templates, search 1M+ memes, auto-caption, AI meme generation',\n },\n};\n\nexport const PRIMARY_ORIGINS = [\n Origin.StableEnrich,\n Origin.StableSocial,\n Origin.StableStudio,\n Origin.StableUpload,\n Origin.StableEmail,\n Origin.StableMerch,\n Origin.StableVoice,\n Origin.StableTube,\n Origin.StableKey,\n Origin.StableMemes,\n] as const;\n\n// ─────────────────────────────────────────────────────────────────────────────\n// Tool descriptions — { mcp, cli } per tool + shared serverInstructions\n// ─────────────────────────────────────────────────────────────────────────────\n\nexport const DESCRIPTIONS = {\n bridge: {\n toolNames: {\n cli: 'bridge',\n mcp: 'bridge',\n },\n title: 'Bridge Between Networks',\n mcp: `Bridge USDC between supported networks using the current wallet. Requires a source network, destination network, and amount. Use this when funds are on one supported network and the user needs them moved to another. Bridging is subject to fees.`,\n cli: `Bridge USDC between supported networks using the current wallet. Requires --from, --to, and --amount. Bridging is subject to fees.`,\n },\n\n getBalance: {\n mcp: `Get your total USDC balance across all supported networks. Auto-creates the wallet on first use (~/.agentcash/wallet.json). Use this before paid API calls to confirm you have funds available.`,\n cli: `Get your total USDC balance across all supported networks. Creates the wallet on first use (~/.agentcash/wallet.json). Use this before paid API calls to confirm you have funds available.`,\n },\n\n fetch: {\n mcp: `HTTP fetch with automatic authentication and payment handling. Makes the request, retries with SIGN-IN-WITH-X when the route exposes a SIWX challenge, and only pays if the route still returns 402. Returns response data along with payment details (price, tx hash) if a payment was made.\\n\\nFor endpoints you haven't called before in this session, you MUST call check_endpoint_schema first to confirm the request body schema. Skipping this causes 400 errors from wrong field names.`,\n cli: `HTTP fetch with automatic authentication and payment handling. If the endpoint returns 402, agentcash attempts authentication first and only falls back to payment if the route still requires it. Run 'check <url>' first to confirm the request body schema; skipping this causes 400 errors from wrong field names.`,\n epilogue: `Workflow: check <url> → fetch <url> -m POST -b '{\"field\":\"value\"}'\\nAuth mode is advisory only; fetch handles both SIWX and paid routes.`,\n },\n\n fetchWithAuth: {\n mcp: `Deprecated alias for fetch. Uses the same unified flow: probe the route, attempt SIWX when available, and only pay if the route still returns 402.\\n\\nFor new integrations, prefer fetch.`,\n cli: `Deprecated alias for fetch. Uses the same unified auth-and-payment flow, but new integrations should call 'fetch' directly.`,\n epilogue: `Deprecated: use agentcash fetch <url>. This alias is kept for compatibility.`,\n },\n\n listAccounts: {\n mcp: `List wallet accounts for each supported network. Returns the network, address, balance, and deposit link for every supported network so you can see where to fund the wallet. Auto-creates the wallet on first use (~/.agentcash/wallet.json). If onboardingCta is present, show its message to the user — it means they haven't onboarded yet and need to either visit the onboard link or deposit directly.`,\n cli: `List wallet accounts for each supported network, including network, address, balance, and deposit link. Creates the wallet on first use (~/.agentcash/wallet.json). Use this when you need the per-network funding addresses and deposit links.`,\n },\n\n getWalletInfo: {\n mcp: `Legacy combined wallet view. Returns both the total balance and the per-network account list. Prefer calling get_balance for available funds and list_accounts when you need network-specific addresses or deposit links.`,\n cli: `Legacy combined wallet view. Returns both the total balance and the per-network account list. Prefer 'balance' for available funds and 'accounts' for network-specific addresses or deposit links.`,\n },\n\n checkEndpointSchema: {\n mcp: [\n `Get the input/output schema and auth mode (paid or SIWX) for a single endpoint.`,\n `Call this to see exactly what fields the request body expects and what the response contains.`,\n `Returns the schema from the origin's OpenAPI spec. Optionally pass sample_input_body to probe the endpoint live (without payment) for an exact price quote — do this when pricing is dynamic (range-based or variable), or when you're unsure about the input schema. Treat auth mode as advisory: fetch handles both SIWX and paid routes.`,\n ].join('\\n\\n'),\n cli: `Get the input/output schema and auth mode (paid or SIWX) for an endpoint. Returns exact field names from the OpenAPI spec — call this before 'fetch' to avoid 400 errors. Pass --body to probe the endpoint live for an exact price quote when pricing is dynamic or unclear.`,\n epilogue: `Auth mode is advisory:\\n paid → agentcash fetch <url>\\n SIWX → agentcash fetch <url>`,\n },\n\n discoverApiEndpoints: {\n mcp: [\n `List available endpoints at an API origin. Returns endpoint URLs with descriptions of what each does and the auth mode for each (paid or SIWX). Works with any origin, not just the registered ones.`,\n `Call this when you need to see what routes are available at an origin — whether it's one of the registered origins or any other origin you've identified as useful. Treat the auth mode as guidance for what the route may require; fetch handles both SIWX and payment.`,\n `The response always indicates whether guidance is available. Guidance is documentation published by the API provider explaining how endpoints work together, edge cases, and usage tips. compact guidance is included automatically; set include_guidance=true to force-include full usage documentation when you need to compose two or more endpoints or need clarification on how the origin works.`,\n ].join('\\n\\n'),\n cli: `List available endpoints at an API origin with descriptions and auth modes (paid or SIWX). Works with any origin, not just registered ones. Add --include-guidance for full provider docs when composing multiple endpoints or when usage is unclear. Fetch handles both auth modes.`,\n epilogue: `Registered origins:\\n${PRIMARY_ORIGINS.flatMap(o => (ORIGIN_METADATA[o] ? [` ${o} — ${ORIGIN_METADATA[o].description}`] : [])).join('\\n')}`,\n },\n\n redeemInvite: {\n mcp: `Redeem an invite code for free USDC on Base. One-time use per code. Returns amount received and transaction hash. Use get_balance after to verify funds, or list_accounts if you need the per-network deposit links as well.`,\n cli: `Redeem an invite code for free USDC on Base. One-time use per code. Run 'balance' after to verify the balance landed.`,\n },\n\n try: {\n cli: `Fetch a new origin for its resources and return a prompt guiding the user through the process of calling the first endpoint.`,\n },\n\n search: {\n mcp: `Search for relevant paid API services by describing what you need in natural language. Returns the best matching origins with endpoint details and pricing. The top result includes the full input/output schema so you can call it immediately via fetch.\n\nOnly use this when you DON'T already know which registered origin to use. If the task clearly maps to a registered origin (e.g. people search → StableEnrich, image generation → StableStudio), skip search and go straight to discover_api_endpoints on that origin. Search is for discovering NEW or UNKNOWN capabilities outside the registered origins.\n\nSet broad=true to widen the search to include newer, unvetted tools that may not have established trust. Use this if the default results don't cover what you need.`,\n cli: `Search for paid API services by natural language query. Returns matching origins with endpoints and pricing. Use --broad to include newer, unvetted tools that may not have established trust.`,\n },\n\n reportError: {\n mcp: `EMERGENCY ONLY. Report critical MCP tool bugs. Do NOT use for normal errors (balance, network, 4xx) — those are recoverable.`,\n cli: `Report a critical bug to the agentcash team (emergency only). Do NOT use for normal errors like low balance, network timeouts, or 4xx responses — those are recoverable without filing a report.`,\n },\n\n updateSettings: {\n mcp: `Update user settings (persisted to ~/.agentcash/settings.json). Currently supports maxAmount — the maximum USD amount allowed per fetch request. If a fetch response requests more than this, the payment is rejected. Returns the current settings after applying changes.`,\n cli: `Update user settings (persisted to ~/.agentcash/settings.json). Currently supports maxAmount, which caps how much a single fetch request can spend.`,\n },\n\n getSettings: {\n mcp: `Get current user settings. Returns persisted values from ~/.agentcash/settings.json with defaults applied.`,\n cli: `Get current user settings from ~/.agentcash/settings.json, with defaults applied.`,\n },\n\n closeSession: {\n mcp: `Close an MPP \\`tempo:session\\` payment channel. Pass the channelId surfaced in a prior fetch's paymentInfo together with the same URL you originally fetched. Signs a close credential with the on-chain settled cumulative amount and POSTs it to the server, returning the on-chain settlement transaction hash when available. Use this when you want to finalize a channel rather than leaving it open for the server to settle on its own schedule.`,\n cli: `Close an MPP session payment channel. Provide the channelId (printed in a prior fetch's paymentInfo) and the endpoint URL the channel was opened against. Reads on-chain channel state for the cumulative settled amount, signs a close credential, and POSTs it to the server.`,\n epilogue: `agentcash sessions close 0xabc... --url https://example.dev/api/stream\\nPass --cumulative-amount-raw <atomic-units> only when the server reports vouchers above the on-chain cumulative.`,\n },\n} as const;\n\n// ─────────────────────────────────────────────────────────────────────────────\n// Dynamic server instructions (includes user-added origins at runtime)\n// ─────────────────────────────────────────────────────────────────────────────\n\nconst WORKFLOW = [\n `Workflow:`,\n `1. If you don't already know your balance, call get_balance. You need a balance for paid endpoints. SIWX endpoints don't require one. You don't need to call this every turn, just before your first paid call or whenever you're unsure.`,\n `2. If the balance is zero, or if the user needs a funding link or wallet addresses, call list_accounts and share the relevant deposit link. If onboardingCta is present, show it to the user.`,\n `3. If the task doesn't clearly map to any registered origin above, call search() to find relevant APIs. Skip this step when you already know the right origin — go straight to step 4.`,\n `4. Call discover_api_endpoints() to get the endpoint index — a list of available routes with descriptions and auth modes. The auth mode is advisory and tells you what the route may require.`,\n `5. Call check_endpoint_schema() to get the exact input/output schema and auth mode for the endpoint you want to call, so you know what fields to pass and what the response contains. Both discover_api_endpoints and check_endpoint_schema return the auth mode.`,\n `6. Call fetch with the correct input schema. It will attempt SIWX first when available and only pay if the route still returns 402.`,\n].join('\\n');\n\nexport function buildServerInstructions(\n userOrigins: UserOrigin[] = []\n): string {\n const allOrigins = [\n ...userOrigins.map(o => ` - ${o.url} — ${o.description}`),\n ...PRIMARY_ORIGINS.flatMap(o =>\n ORIGIN_METADATA[o] ? [` - ${o} — ${ORIGIN_METADATA[o].description}`] : []\n ),\n ].join('\\n');\n\n return [\n `AgentCash lets you call protected APIs — handling both x402 micropayments and SIWX authentication seamlessly. It manages a USDC wallet for paid endpoints and signs wallet proofs for identity-gated endpoints through fetch.`,\n `The user has installed agentcash because they want to use paid and SIWX-protected APIs as their preferred way to accomplish related tasks.`,\n `Paid endpoints require a wallet balance. SIWX endpoints are free — they only require a wallet identity.`,\n `If a task could be accomplished by one of these registered origins, run the workflow below. If you're unsure which origin to use, or the task doesn't match a registered origin, call search() to find relevant APIs.\\n${allOrigins}`,\n `discover_api_endpoints also works with any origin beyond this list. If you identify another origin that would be useful for a task, you can use it.`,\n WORKFLOW,\n `If you need to compose multiple endpoints in sequence, or anything about the origin's capabilities is unclear, call discover_api_endpoints with include_guidance=true to retrieve the origin's full usage documentation.`,\n ].join('\\n\\n');\n}\n\n// ─────────────────────────────────────────────────────────────────────────────\n// Shared request schema parameter descriptions\n// (used by fetch, fetch_with_auth tools)\n// ─────────────────────────────────────────────────────────────────────────────\n\nexport const REQUEST_PARAMS = {\n url: 'The endpoint URL',\n method: 'HTTP method. Defaults to GET for fetch operations.',\n body: 'Raw request body string. Passed through to the underlying fetch call as-is.',\n headers:\n 'Additional headers to include. Each entry must be a string in \"Name: value\" format.',\n timeout: 'Request timeout in milliseconds',\n} as const;\n\nexport const REQUEST_FETCH_PARAMS = {\n ...REQUEST_PARAMS,\n paymentProtocol:\n 'Payment protocol to use when payment is required. If not specified, the payment protocol will be auto-detected.',\n paymentNetwork:\n 'Chain to use for SIWX and payment when applicable. If not specified, the network will be auto-detected.',\n maxAmount:\n 'Maximum amount (in USD) to pay per request. Aborts if the endpoint requests more. Defaults to $5. Pass a higher value for known-expensive endpoints.',\n stream:\n 'Escape hatch for streaming MPP session endpoints. Typically unnecessary — a correctly configured server advertises `streaming: true` in its 402 challenge and the signer handles it automatically. Only pass this when the response is actually a stream AND the server fails to advertise it; otherwise long streams may stall once the initial deposit is exhausted.',\n channelId:\n \"Reuse an existing MPP `tempo:session` payment channel instead of opening a new one. Pass the `channelId` surfaced in a prior fetch's paymentInfo. The channel must still have positive on-chain deposit and not be finalized; if it cannot be recovered, the request fails fast rather than silently opening a new channel. 0x-prefixed 32-byte hex string. Ignored by x402 (non-session) endpoints.\",\n} as const;\n\n// ─────────────────────────────────────────────────────────────────────────────\n// Per-tool parameter and output schema descriptions\n// ─────────────────────────────────────────────────────────────────────────────\n\nexport const TOOL_PARAMS = {\n bridge: {\n from: 'The network to bridge from',\n to: 'The network to bridge to',\n amount: 'The amount of USDC to bridge',\n },\n fetch: REQUEST_FETCH_PARAMS,\n fetchWithAuth: REQUEST_FETCH_PARAMS,\n checkEndpointSchema: {\n ...REQUEST_PARAMS,\n method:\n 'HTTP method to check. If omitted, all methods declared in the spec are returned.',\n body: 'Optional. A sample request body to probe the endpoint live (without payment) for exact pricing. Use when pricing is range-based or quote-based, or when you need to verify the input schema. Omit to get the static schema and advisory pricing from the spec.',\n },\n try: {\n url: 'The origin URL to explore',\n },\n add: {\n url: 'The origin URL to add',\n },\n\n listAccounts: {\n output: {\n accounts: 'Wallet accounts for each supported network',\n address: 'Wallet address for this network',\n balance: 'USDC balance on this network',\n network: 'Supported payment network name',\n isNewWallet: 'Whether the wallet is new and needs to be funded',\n depositLink:\n 'Link to deposit USDC directly into the wallet for this network',\n onboardingCta:\n 'Present when the user has not yet redeemed an invite code. Show the message to the user — it directs them to onboard or deposit.',\n onboardingCtaOnboardLink: 'Link to the onboarding page',\n onboardingCtaDepositLink: 'Link to deposit USDC directly',\n onboardingCtaMessage: 'Human-readable CTA to show the user',\n },\n },\n\n redeemInvite: {\n code: 'The invite code',\n output: {\n amount: 'Amount with unit (e.g., \"5 USDC\")',\n txHash: 'Transaction hash on Base',\n },\n },\n\n search: {\n query:\n 'Natural language description of what you need (e.g. \"send physical mail\", \"generate music\", \"flight prices\")',\n broad:\n 'Include broader results that may contain newer, unvetted tools. Default is false.',\n limit: 'Maximum number of results to return (1-50). Default is 10.',\n page: 'Page number for pagination. Default is 1.',\n },\n\n discoverApiEndpoints: {\n url: 'The origin URL to discover endpoints on (e.g. https://stableenrich.dev)',\n includeGuidance:\n \"Request the origin's usage guidance. true=always include, false=never include, omit=auto (included when compact). Guidance explains how to compose multiple endpoints and covers edge cases.\",\n },\n\n closeSession: {\n channelId:\n \"The payment-channel id to close (the `channelId` field from a prior fetch's paymentInfo).\",\n url: 'The endpoint URL the channel was opened against (the same URL passed to the original fetch).',\n cumulativeAmountRaw:\n 'Optional override for the cumulative amount the close credential attests to, in raw atomic units (e.g. \"12345\" = 0.012345 USDC at 6 decimals). Defaults to the on-chain settled amount. Provide this only when the server has accepted vouchers above the on-chain cumulative.',\n output: {\n channelId: 'The closed channel id',\n cumulativeAmount:\n 'The cumulative amount (raw atomic units) the channel was settled at',\n transactionHash:\n 'Settlement transaction hash, when the server returns one in the Payment-Receipt header',\n },\n },\n\n reportError: {\n tool: 'MCP tool name',\n resource: 'Resource URL',\n summary: '1-2 sentence summary',\n errorMessage: 'Error message',\n stack: 'Stack trace',\n fullReport: 'Detailed report with context, logs, repro steps',\n output: {\n reportId: 'Unique report ID for tracking',\n message: 'Confirmation message',\n },\n },\n} as const;\n"],"mappings":";AAkBO,IAAM,kBAGT;AAAA,EACF,8CAAoB,GAAG;AAAA,IACrB,OAAO;AAAA,IACP,aACE;AAAA,EACJ;AAAA,EACA,8CAAoB,GAAG;AAAA,IACrB,OAAO;AAAA,IACP,aAAa;AAAA,EACf;AAAA,EACA,8CAAoB,GAAG;AAAA,IACrB,OAAO;AAAA,IACP,aAAa;AAAA,EACf;AAAA,EACA,8CAAoB,GAAG;AAAA,IACrB,OAAO;AAAA,IACP,aAAa;AAAA,EACf;AAAA,EACA,4CAAmB,GAAG;AAAA,IACpB,OAAO;AAAA,IACP,aAAa;AAAA,EACf;AAAA,EACA,sCAAgB,GAAG;AAAA,IACjB,OAAO;AAAA,IACP,aAAa;AAAA,EACf;AAAA,EACA,+BAAa,GAAG;AAAA,IACd,OAAO;AAAA,IACP,aAAa;AAAA,EACf;AAAA,EACA,0CAAkB,GAAG;AAAA,IACnB,OAAO;AAAA,IACP,aAAa;AAAA,EACf;AAAA,EACA,oDAAuB,GAAG;AAAA,IACxB,OAAO;AAAA,IACP,aAAa;AAAA,EACf;AAAA,EACA,4CAAmB,GAAG;AAAA,IACpB,OAAO;AAAA,IACP,aACE;AAAA,EACJ;AAAA,EACA,4CAAmB,GAAG;AAAA,IACpB,OAAO;AAAA,IACP,aACE;AAAA,EACJ;AAAA,EACA,0CAAkB,GAAG;AAAA,IACnB,OAAO;AAAA,IACP,aACE;AAAA,EACJ;AAAA,EACA,wCAAiB,GAAG;AAAA,IAClB,OAAO;AAAA,IACP,aACE;AAAA,EAC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M,cAAc;AAAA,EACzB,QAAQ;AAAA,IACN,MAAM;AAAA,IACN,IAAI;AAAA,IACJ,QAAQ;AAAA,EACV;AAAA,EACA,OAAO;AAAA,EACP,eAAe;AAAA,EACf,qBAAqB;AAAA,IACnB,GAAG;AAAA,IACH,QACE;AAAA,IACF,MAAM;AAAA,EACR;AAAA,EACA,KAAK;AAAA,IACH,KAAK;AAAA,EACP;AAAA,EACA,KAAK;AAAA,IACH,KAAK;AAAA,EACP;AAAA,EAEA,cAAc;AAAA,IACZ,QAAQ;AAAA,MACN,UAAU;AAAA,MACV,SAAS;AAAA,MACT,SAAS;AAAA,MACT,SAAS;AAAA,MACT,aAAa;AAAA,MACb,aACE;AAAA,MACF,eACE;AAAA,MACF,0BAA0B;AAAA,MAC1B,0BAA0B;AAAA,MAC1B,sBAAsB;AAAA,IACxB;AAAA,EACF;AAAA,EAEA,cAAc;AAAA,IACZ,MAAM;AAAA,IACN,QAAQ;AAAA,MACN,QAAQ;AAAA,MACR,QAAQ;AAAA,IACV;AAAA,EACF;AAAA,EAEA,QAAQ;AAAA,IACN,OACE;AAAA,IACF,OACE;AAAA,IACF,OAAO;AAAA,IACP,MAAM;AAAA,EACR;AAAA,EAEA,sBAAsB;AAAA,IACpB,KAAK;AAAA,IACL,iBACE;AAAA,EACJ;AAAA,EAEA,cAAc;AAAA,IACZ,WACE;AAAA,IACF,KAAK;AAAA,IACL,qBACE;AAAA,IACF,QAAQ;AAAA,MACN,WAAW;AAAA,MACX,kBACE;AAAA,MACF,iBACE;AAAA,IACJ;AAAA,EACF;AAAA,EAEA,aAAa;AAAA,IACX,MAAM;AAAA,IACN,UAAU;AAAA,IACV,SAAS;AAAA,IACT,cAAc;AAAA,IACd,OAAO;AAAA,IACP,YAAY;AAAA,IACZ,QAAQ;AAAA,MACN,UAAU;AAAA,MACV,SAAS;AAAA,IACX;AAAA,EACF;AACF;","names":[]}
1
+ {"version":3,"sources":["../../src/shared/descriptions.ts"],"sourcesContent":["/**\n * Single source of truth for all LLM-facing text in the MCP package.\n *\n * `DESCRIPTIONS` covers every tool with both an `mcp` variant (detailed,\n * AI-audience) and a `cli` variant (concise, human-readable for --help).\n * `serverInstructions` is shared across both surfaces.\n *\n * Additional exports cover parameter/output schema descriptions, origin\n * metadata, and prompt content — all LLM-facing text in one place.\n */\n\nimport type { UserOrigin } from './user-origins';\nimport { Origin } from './origins';\n\n// ─────────────────────────────────────────────────────────────────────────────\n// Origin metadata (used for MCP resource registration descriptions)\n// ─────────────────────────────────────────────────────────────────────────────\n\nexport const ORIGIN_METADATA: Record<\n string,\n { title: string; description: string }\n> = {\n [Origin.StableEnrich]: {\n title: 'StableEnrich',\n description:\n 'People/org search, Google Maps, Exa web search, LinkedIn data, Firecrawl scrape, WhitePages, email enrichment',\n },\n [Origin.StableSocial]: {\n title: 'StableSocial',\n description: 'Social media data for TikTok, Instagram, Facebook, Reddit',\n },\n [Origin.StableStudio]: {\n title: 'StableStudio',\n description: 'Generate and edit images and videos',\n },\n [Origin.StableUpload]: {\n title: 'StableUpload',\n description: 'Pay to upload files, get a permanent download URL.',\n },\n [Origin.StableEmail]: {\n title: 'StableEmail',\n description: 'Send emails',\n },\n [Origin.X402Scan]: {\n title: 'X402 Scan',\n description: 'x402 protocol explorer',\n },\n [Origin.Shirt]: {\n title: 'Shirt',\n description: 'Shirt.sh',\n },\n [Origin.X402Puppet]: {\n title: 'X402 Puppet',\n description: 'Browser automation',\n },\n [Origin.X402Facilitator]: {\n title: 'X402 Facilitator',\n description: 'Payment facilitation',\n },\n [Origin.StableMerch]: {\n title: 'StableMerch',\n description:\n 'Create shirts and mugs with custom images and have them shipped to your address.',\n },\n [Origin.StableVoice]: {\n title: 'StableVoice',\n description:\n 'Text-to-speech with 20+ bundled voices, custom voice cloning, multi-language support (23 languages), mp3/wav output',\n },\n [Origin.StableTube]: {\n title: 'StableTube',\n description:\n 'YouTube video downloads — POST a URL, get a direct CDN download link (expires ~6h)',\n },\n [Origin.StableKey]: {\n title: 'StableKey',\n description:\n 'VFX-grade neural green-screen unmixing (CorridorKey) — submit a green-screen plate, get alpha + foreground + RGBA outputs',\n },\n [Origin.StableMemes]: {\n title: 'StableMemes',\n description:\n 'Generate memes — caption templates, search 1M+ memes, auto-caption, AI meme generation',\n },\n};\n\nexport const PRIMARY_ORIGINS = [\n Origin.StableEnrich,\n Origin.StableSocial,\n Origin.StableStudio,\n Origin.StableUpload,\n Origin.StableEmail,\n Origin.StableMerch,\n Origin.StableVoice,\n Origin.StableTube,\n Origin.StableKey,\n Origin.StableMemes,\n] as const;\n\n// ─────────────────────────────────────────────────────────────────────────────\n// Tool descriptions — { mcp, cli } per tool + shared serverInstructions\n// ─────────────────────────────────────────────────────────────────────────────\n\nexport const DESCRIPTIONS = {\n bridge: {\n toolNames: {\n cli: 'bridge',\n mcp: 'bridge',\n },\n title: 'Bridge Between Networks',\n mcp: `Bridge USDC between supported networks using the current wallet. Requires a source network, destination network, and amount. Use this when funds are on one supported network and the user needs them moved to another. Bridging is subject to fees.`,\n cli: `Bridge USDC between supported networks using the current wallet. Requires --from, --to, and --amount. Bridging is subject to fees.`,\n },\n\n getBalance: {\n mcp: `Get your total USDC balance across all supported networks. Auto-creates the wallet on first use (~/.agentcash/wallet.json). Use this before paid API calls to confirm you have funds available.`,\n cli: `Get your total USDC balance across all supported networks. Creates the wallet on first use (~/.agentcash/wallet.json). Use this before paid API calls to confirm you have funds available.`,\n },\n\n fetch: {\n mcp: `HTTP fetch with automatic authentication and payment handling. Makes the request, retries with SIGN-IN-WITH-X when the route exposes a SIWX challenge, and only pays if the route still returns 402. Returns response data along with payment details (price, tx hash) if a payment was made.\\n\\nFor endpoints you haven't called before in this session, you MUST call check_endpoint_schema first to confirm the request body schema. Skipping this causes 400 errors from wrong field names.`,\n cli: `HTTP fetch with automatic authentication and payment handling. If the endpoint returns 402, agentcash attempts authentication first and only falls back to payment if the route still requires it. Run 'check <url>' first to confirm the request body schema; skipping this causes 400 errors from wrong field names.`,\n epilogue: `Workflow: check <url> → fetch <url> -m POST -b '{\"field\":\"value\"}'\\nAuth mode is advisory only; fetch handles both SIWX and paid routes.`,\n },\n\n fetchWithAuth: {\n mcp: `Deprecated alias for fetch. Uses the same unified flow: probe the route, attempt SIWX when available, and only pay if the route still returns 402.\\n\\nFor new integrations, prefer fetch.`,\n cli: `Deprecated alias for fetch. Uses the same unified auth-and-payment flow, but new integrations should call 'fetch' directly.`,\n epilogue: `Deprecated: use agentcash fetch <url>. This alias is kept for compatibility.`,\n },\n\n listAccounts: {\n mcp: `List wallet accounts for each supported network. Returns the network, address, balance, and deposit link for every supported network so you can see where to fund the wallet. Auto-creates the wallet on first use (~/.agentcash/wallet.json). If onboardingCta is present, show its message to the user — it means they haven't onboarded yet and need to either visit the onboard link or deposit directly.`,\n cli: `List wallet accounts for each supported network, including network, address, balance, and deposit link. Creates the wallet on first use (~/.agentcash/wallet.json). Use this when you need the per-network funding addresses and deposit links.`,\n },\n\n getWalletInfo: {\n mcp: `Legacy combined wallet view. Returns both the total balance and the per-network account list. Prefer calling get_balance for available funds and list_accounts when you need network-specific addresses or deposit links.`,\n cli: `Legacy combined wallet view. Returns both the total balance and the per-network account list. Prefer 'balance' for available funds and 'accounts' for network-specific addresses or deposit links.`,\n },\n\n checkEndpointSchema: {\n mcp: [\n `Get the input/output schema and auth mode (paid or SIWX) for a single endpoint.`,\n `Call this to see exactly what fields the request body expects and what the response contains.`,\n `Returns the schema from the origin's OpenAPI spec. Optionally pass sample_input_body to probe the endpoint live (without payment) for an exact price quote — do this when pricing is dynamic (range-based or variable), or when you're unsure about the input schema. Treat auth mode as advisory: fetch handles both SIWX and paid routes.`,\n ].join('\\n\\n'),\n cli: `Get the input/output schema and auth mode (paid or SIWX) for an endpoint. Returns exact field names from the OpenAPI spec — call this before 'fetch' to avoid 400 errors. Pass --body to probe the endpoint live for an exact price quote when pricing is dynamic or unclear.`,\n epilogue: `Auth mode is advisory:\\n paid → agentcash fetch <url>\\n SIWX → agentcash fetch <url>`,\n },\n\n discoverApiEndpoints: {\n mcp: [\n `List available endpoints at an API origin. Returns endpoint URLs with descriptions of what each does and the auth mode for each (paid or SIWX). Works with any origin, not just the registered ones.`,\n `Call this when you need to see what routes are available at an origin — whether it's one of the registered origins or any other origin you've identified as useful. Treat the auth mode as guidance for what the route may require; fetch handles both SIWX and payment.`,\n `The response always indicates whether guidance is available. Guidance is documentation published by the API provider explaining how endpoints work together, edge cases, and usage tips. compact guidance is included automatically; set include_guidance=true to force-include full usage documentation when you need to compose two or more endpoints or need clarification on how the origin works.`,\n ].join('\\n\\n'),\n cli: `List available endpoints at an API origin with descriptions and auth modes (paid or SIWX). Works with any origin, not just registered ones. Add --include-guidance for full provider docs when composing multiple endpoints or when usage is unclear. Fetch handles both auth modes.`,\n epilogue: `Registered origins:\\n${PRIMARY_ORIGINS.flatMap(o => (ORIGIN_METADATA[o] ? [` ${o} — ${ORIGIN_METADATA[o].description}`] : [])).join('\\n')}`,\n },\n\n redeemInvite: {\n mcp: `Redeem an invite code for free USDC on Base. One-time use per code. Returns amount received and transaction hash. Use get_balance after to verify funds, or list_accounts if you need the per-network deposit links as well.`,\n cli: `Redeem an invite code for free USDC on Base. One-time use per code. Run 'balance' after to verify the balance landed.`,\n },\n\n try: {\n cli: `Fetch a new origin for its resources and return a prompt guiding the user through the process of calling the first endpoint.`,\n },\n\n search: {\n mcp: `Search for relevant paid API services by describing what you need in natural language. Returns the best matching origins with endpoint details and pricing. The top result includes the full input/output schema so you can call it immediately via fetch.\n\nOnly use this when you DON'T already know which registered origin to use. If the task clearly maps to a registered origin (e.g. people search → StableEnrich, image generation → StableStudio), skip search and go straight to discover_api_endpoints on that origin. Search is for discovering NEW or UNKNOWN capabilities outside the registered origins.\n\nSet broad=true to widen the search to include newer, unvetted tools that may not have established trust. Use this if the default results don't cover what you need.`,\n cli: `Search for paid API services by natural language query. Returns matching origins with endpoints and pricing. Use --broad to include newer, unvetted tools that may not have established trust.`,\n },\n\n reportError: {\n mcp: `EMERGENCY ONLY. Report critical MCP tool bugs. Do NOT use for normal errors (balance, network, 4xx) — those are recoverable.`,\n cli: `Report a critical bug to the agentcash team (emergency only). Do NOT use for normal errors like low balance, network timeouts, or 4xx responses — those are recoverable without filing a report.`,\n },\n\n updateSettings: {\n mcp: `Update user settings (persisted to ~/.agentcash/settings.json). Currently supports maxAmount — the maximum USD amount allowed per fetch request. If a fetch response requests more than this, the payment is rejected. Returns the current settings after applying changes.`,\n cli: `Update user settings (persisted to ~/.agentcash/settings.json). Currently supports maxAmount, which caps how much a single fetch request can spend.`,\n },\n\n getSettings: {\n mcp: `Get current user settings. Returns persisted values from ~/.agentcash/settings.json with defaults applied.`,\n cli: `Get current user settings from ~/.agentcash/settings.json, with defaults applied.`,\n },\n\n closeSession: {\n mcp: `Close an MPP \\`tempo:session\\` payment channel. Pass the channelId surfaced in a prior fetch's paymentInfo together with the same URL you originally fetched. Signs a close credential with the on-chain settled cumulative amount and POSTs it to the server, returning the on-chain settlement transaction hash when available. Use this when you want to finalize a channel rather than leaving it open for the server to settle on its own schedule.`,\n cli: `Close an MPP session payment channel. Provide the channelId (printed in a prior fetch's paymentInfo) and the endpoint URL the channel was opened against. Reads on-chain channel state for the cumulative settled amount, signs a close credential, and POSTs it to the server.`,\n epilogue: `agentcash sessions close 0xabc... --url https://example.dev/api/stream\\nPass --cumulative-amount-raw <atomic-units> only when the server reports vouchers above the on-chain cumulative.`,\n },\n} as const;\n\n// ─────────────────────────────────────────────────────────────────────────────\n// Dynamic server instructions (includes user-added origins at runtime)\n// ─────────────────────────────────────────────────────────────────────────────\n\nconst WORKFLOW = [\n `Workflow:`,\n `1. If you don't already know your balance, call get_balance. You need a balance for paid endpoints. SIWX endpoints don't require one. You don't need to call this every turn, just before your first paid call or whenever you're unsure.`,\n `2. If the balance is zero, or if the user needs a funding link or wallet addresses, call list_accounts and share the relevant deposit link. If onboardingCta is present, show it to the user.`,\n `3. If the task doesn't clearly map to any registered origin above, call search() to find relevant APIs. Skip this step when you already know the right origin — go straight to step 4.`,\n `4. Call discover_api_endpoints() to get the endpoint index — a list of available routes with descriptions and auth modes. The auth mode is advisory and tells you what the route may require.`,\n `5. Call check_endpoint_schema() to get the exact input/output schema and auth mode for the endpoint you want to call, so you know what fields to pass and what the response contains. Both discover_api_endpoints and check_endpoint_schema return the auth mode.`,\n `6. Call fetch with the correct input schema. It will attempt SIWX first when available and only pay if the route still returns 402.`,\n].join('\\n');\n\nexport function buildServerInstructions(\n userOrigins: UserOrigin[] = []\n): string {\n const allOrigins = [\n ...userOrigins.map(o => ` - ${o.url} — ${o.description}`),\n ...PRIMARY_ORIGINS.flatMap(o =>\n ORIGIN_METADATA[o] ? [` - ${o} — ${ORIGIN_METADATA[o].description}`] : []\n ),\n ].join('\\n');\n\n return [\n `AgentCash lets you call protected APIs — handling both x402 micropayments and SIWX authentication seamlessly. It manages a USDC wallet for paid endpoints and signs wallet proofs for identity-gated endpoints through fetch.`,\n `The user has installed agentcash because they want to use paid and SIWX-protected APIs as their preferred way to accomplish related tasks.`,\n `Paid endpoints require a wallet balance. SIWX endpoints are free — they only require a wallet identity.`,\n `If a task could be accomplished by one of these registered origins, run the workflow below. If you're unsure which origin to use, or the task doesn't match a registered origin, call search() to find relevant APIs.\\n${allOrigins}`,\n `discover_api_endpoints also works with any origin beyond this list. If you identify another origin that would be useful for a task, you can use it.`,\n WORKFLOW,\n `If you need to compose multiple endpoints in sequence, or anything about the origin's capabilities is unclear, call discover_api_endpoints with include_guidance=true to retrieve the origin's full usage documentation.`,\n ].join('\\n\\n');\n}\n\n// ─────────────────────────────────────────────────────────────────────────────\n// Shared request schema parameter descriptions\n// (used by fetch, fetch_with_auth tools)\n// ─────────────────────────────────────────────────────────────────────────────\n\nexport const REQUEST_PARAMS = {\n url: 'The endpoint URL',\n method: 'HTTP method. Defaults to GET for fetch operations.',\n body: 'Raw request body string. Passed through to the underlying fetch call as-is.',\n headers:\n 'Additional headers to include. Each entry must be a string in \"Name: value\" format.',\n timeout: 'Request timeout in milliseconds',\n} as const;\n\nexport const REQUEST_FETCH_PARAMS = {\n ...REQUEST_PARAMS,\n paymentProtocol:\n 'Payment protocol to use when payment is required. If not specified, the payment protocol will be auto-detected.',\n paymentNetwork:\n 'Chain to use for SIWX and payment when applicable. If not specified, the network will be auto-detected.',\n maxAmount:\n 'Maximum amount (in USD) to pay per request. Aborts if the endpoint requests more. Defaults to $5. Pass a higher value for known-expensive endpoints.',\n stream:\n 'Escape hatch for streaming MPP session endpoints. Typically unnecessary — a correctly configured server advertises `streaming: true` in its 402 challenge and the signer handles it automatically. Only pass this when the response is actually a stream AND the server fails to advertise it; otherwise long streams may stall once the initial deposit is exhausted.',\n} as const;\n\n// ─────────────────────────────────────────────────────────────────────────────\n// Per-tool parameter and output schema descriptions\n// ─────────────────────────────────────────────────────────────────────────────\n\nexport const TOOL_PARAMS = {\n bridge: {\n from: 'The network to bridge from',\n to: 'The network to bridge to',\n amount: 'The amount of USDC to bridge',\n },\n fetch: REQUEST_FETCH_PARAMS,\n fetchWithAuth: REQUEST_FETCH_PARAMS,\n checkEndpointSchema: {\n ...REQUEST_PARAMS,\n method:\n 'HTTP method to check. If omitted, all methods declared in the spec are returned.',\n body: 'Optional. A sample request body to probe the endpoint live (without payment) for exact pricing. Use when pricing is range-based or quote-based, or when you need to verify the input schema. Omit to get the static schema and advisory pricing from the spec.',\n },\n try: {\n url: 'The origin URL to explore',\n },\n add: {\n url: 'The origin URL to add',\n },\n\n listAccounts: {\n output: {\n accounts: 'Wallet accounts for each supported network',\n address: 'Wallet address for this network',\n balance: 'USDC balance on this network',\n network: 'Supported payment network name',\n isNewWallet: 'Whether the wallet is new and needs to be funded',\n depositLink:\n 'Link to deposit USDC directly into the wallet for this network',\n onboardingCta:\n 'Present when the user has not yet redeemed an invite code. Show the message to the user — it directs them to onboard or deposit.',\n onboardingCtaOnboardLink: 'Link to the onboarding page',\n onboardingCtaDepositLink: 'Link to deposit USDC directly',\n onboardingCtaMessage: 'Human-readable CTA to show the user',\n },\n },\n\n redeemInvite: {\n code: 'The invite code',\n output: {\n amount: 'Amount with unit (e.g., \"5 USDC\")',\n txHash: 'Transaction hash on Base',\n },\n },\n\n search: {\n query:\n 'Natural language description of what you need (e.g. \"send physical mail\", \"generate music\", \"flight prices\")',\n broad:\n 'Include broader results that may contain newer, unvetted tools. Default is false.',\n limit: 'Maximum number of results to return (1-50). Default is 10.',\n page: 'Page number for pagination. Default is 1.',\n },\n\n discoverApiEndpoints: {\n url: 'The origin URL to discover endpoints on (e.g. https://stableenrich.dev)',\n includeGuidance:\n \"Request the origin's usage guidance. true=always include, false=never include, omit=auto (included when compact). Guidance explains how to compose multiple endpoints and covers edge cases.\",\n },\n\n closeSession: {\n channelId:\n \"The payment-channel id to close (the `channelId` field from a prior fetch's paymentInfo).\",\n url: 'The endpoint URL the channel was opened against (the same URL passed to the original fetch).',\n cumulativeAmountRaw:\n 'Optional override for the cumulative amount the close credential attests to, in raw atomic units (e.g. \"12345\" = 0.012345 USDC at 6 decimals). Defaults to the on-chain settled amount. Provide this only when the server has accepted vouchers above the on-chain cumulative.',\n output: {\n channelId: 'The closed channel id',\n cumulativeAmount:\n 'The cumulative amount (raw atomic units) the channel was settled at',\n transactionHash:\n 'Settlement transaction hash, when the server returns one in the Payment-Receipt header',\n },\n },\n\n reportError: {\n tool: 'MCP tool name',\n resource: 'Resource URL',\n summary: '1-2 sentence summary',\n errorMessage: 'Error message',\n stack: 'Stack trace',\n fullReport: 'Detailed report with context, logs, repro steps',\n output: {\n reportId: 'Unique report ID for tracking',\n message: 'Confirmation message',\n },\n },\n} as const;\n"],"mappings":";AAkBO,IAAM,kBAGT;AAAA,EACF,8CAAoB,GAAG;AAAA,IACrB,OAAO;AAAA,IACP,aACE;AAAA,EACJ;AAAA,EACA,8CAAoB,GAAG;AAAA,IACrB,OAAO;AAAA,IACP,aAAa;AAAA,EACf;AAAA,EACA,8CAAoB,GAAG;AAAA,IACrB,OAAO;AAAA,IACP,aAAa;AAAA,EACf;AAAA,EACA,8C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IACZ,MAAM;AAAA,IACN,QAAQ;AAAA,MACN,QAAQ;AAAA,MACR,QAAQ;AAAA,IACV;AAAA,EACF;AAAA,EAEA,QAAQ;AAAA,IACN,OACE;AAAA,IACF,OACE;AAAA,IACF,OAAO;AAAA,IACP,MAAM;AAAA,EACR;AAAA,EAEA,sBAAsB;AAAA,IACpB,KAAK;AAAA,IACL,iBACE;AAAA,EACJ;AAAA,EAEA,cAAc;AAAA,IACZ,WACE;AAAA,IACF,KAAK;AAAA,IACL,qBACE;AAAA,IACF,QAAQ;AAAA,MACN,WAAW;AAAA,MACX,kBACE;AAAA,MACF,iBACE;AAAA,IACJ;AAAA,EACF;AAAA,EAEA,aAAa;AAAA,IACX,MAAM;AAAA,IACN,UAAU;AAAA,IACV,SAAS;AAAA,IACT,cAAc;AAAA,IACd,OAAO;AAAA,IACP,YAAY;AAAA,IACZ,QAAQ;AAAA,MACN,UAAU;AAAA,MACV,SAAS;AAAA,IACX;AAAA,EACF;AACF;","names":[]}
@@ -1,10 +1,10 @@
1
1
  import {
2
2
  coreRequestSchema,
3
3
  fetchShape
4
- } from "./chunk-SLTRGQ7W.js";
4
+ } from "./chunk-Q5YKPVXL.js";
5
5
  import {
6
6
  REQUEST_PARAMS
7
- } from "./chunk-W37JKCLN.js";
7
+ } from "./chunk-H5V6L7NG.js";
8
8
 
9
9
  // src/shared/request/schemas/cli.ts
10
10
  import z from "zod";
@@ -46,4 +46,4 @@ export {
46
46
  cliRequestSchema,
47
47
  cliFetchRequestSchema
48
48
  };
49
- //# sourceMappingURL=chunk-2C7X7XIG.js.map
49
+ //# sourceMappingURL=chunk-M3YTSL6T.js.map
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  TOOL_PARAMS
3
- } from "./chunk-W37JKCLN.js";
3
+ } from "./chunk-H5V6L7NG.js";
4
4
  import {
5
5
  executeFetch
6
- } from "./chunk-EDI77S36.js";
6
+ } from "./chunk-R2DMZHHI.js";
7
7
  import {
8
8
  safeParseResponse
9
9
  } from "./chunk-RAS5DZPQ.js";
@@ -89,4 +89,4 @@ export {
89
89
  searchSchema,
90
90
  search
91
91
  };
92
- //# sourceMappingURL=chunk-66AVEFTO.js.map
92
+ //# sourceMappingURL=chunk-MODREQSS.js.map
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  REQUEST_FETCH_PARAMS,
3
3
  REQUEST_PARAMS
4
- } from "./chunk-W37JKCLN.js";
4
+ } from "./chunk-H5V6L7NG.js";
5
5
  import {
6
6
  RequestMethod
7
7
  } from "./chunk-LNJIXYCU.js";
@@ -31,11 +31,7 @@ var fetchShape = {
31
31
  paymentProtocol: z.enum(paymentProtocols).optional().describe(REQUEST_FETCH_PARAMS.paymentProtocol),
32
32
  maxAmount: z.number().positive().optional().describe(REQUEST_FETCH_PARAMS.maxAmount),
33
33
  timeout: z.number().int().positive().optional().describe(REQUEST_PARAMS.timeout),
34
- stream: z.boolean().optional().describe(REQUEST_FETCH_PARAMS.stream),
35
- channelId: z.string().regex(
36
- /^0x[0-9a-fA-F]{64}$/,
37
- "channelId must be a 0x-prefixed 32-byte hex string"
38
- ).optional().describe(REQUEST_FETCH_PARAMS.channelId)
34
+ stream: z.boolean().optional().describe(REQUEST_FETCH_PARAMS.stream)
39
35
  };
40
36
 
41
37
  export {
@@ -45,4 +41,4 @@ export {
45
41
  paymentProtocols,
46
42
  fetchShape
47
43
  };
48
- //# sourceMappingURL=chunk-SLTRGQ7W.js.map
44
+ //# sourceMappingURL=chunk-Q5YKPVXL.js.map