tenjin-cli 0.1.0-alpha.21 → 0.1.0-alpha.22
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.
- package/README.md +1 -1
- package/dist/{chunk-PJEG2JIJ.js → chunk-2RMXTNLT.js} +4 -4
- package/dist/{chunk-IOIHYOU4.js → chunk-3Q3UBMVB.js} +2 -2
- package/dist/{chunk-2AQO4YDI.js → chunk-AG4DWNHO.js} +3 -3
- package/dist/{chunk-RCJQARZF.js → chunk-B4GA3HAK.js} +2 -2
- package/dist/{chunk-RCJQARZF.js.map → chunk-B4GA3HAK.js.map} +1 -1
- package/dist/{chunk-OSUD6YZZ.js → chunk-CYEUVU3F.js} +8 -8
- package/dist/{chunk-GHTPYKDT.js → chunk-DA53QKTD.js} +4 -4
- package/dist/{chunk-YVODPFTL.js → chunk-DHCOGDJB.js} +4 -4
- package/dist/{chunk-AQRUD5GQ.js → chunk-F4IJQBGP.js} +4 -4
- package/dist/{chunk-SRVDXR6B.js → chunk-GONDQ27X.js} +5 -5
- package/dist/{chunk-N4DJEQAF.js → chunk-NYJCBQL5.js} +2 -2
- package/dist/{chunk-3EUTWC2B.js → chunk-NZYVSZNF.js} +4 -4
- package/dist/{chunk-W3LVZ2EN.js → chunk-SAN5PFTL.js} +102 -5
- package/dist/chunk-SAN5PFTL.js.map +1 -0
- package/dist/{chunk-JN7TMXVF.js → chunk-TU3IK7KK.js} +2 -2
- package/dist/{chunk-UY2TOI3B.js → chunk-U5FFVIIF.js} +74 -7
- package/dist/chunk-U5FFVIIF.js.map +1 -0
- package/dist/{chunk-ETW2ASBP.js → chunk-UAT3Q7VF.js} +68 -16
- package/dist/chunk-UAT3Q7VF.js.map +1 -0
- package/dist/chunk-UFCN7NCE.js +130 -0
- package/dist/chunk-UFCN7NCE.js.map +1 -0
- package/dist/{chunk-QRFONFRW.js → chunk-UGLTSPXQ.js} +2 -2
- package/dist/{chunk-IOB7URFH.js → chunk-UHEMZEGW.js} +2 -2
- package/dist/{chunk-OTPEH3AH.js → chunk-UIOZRILX.js} +5 -5
- package/dist/{chunk-U2ATFMKZ.js → chunk-WXFVJPZD.js} +2 -2
- package/dist/{chunk-C363JZN2.js → chunk-XBYTP4SP.js} +3 -3
- package/dist/{cli-7KJ4QLUU.js → cli-5WM56Y7K.js} +28 -28
- package/dist/{cli-7KJ4QLUU.js.map → cli-5WM56Y7K.js.map} +1 -1
- package/dist/{config-MSN6H4MD.js → config-JBF5BZNO.js} +7 -7
- package/dist/{doctor-ITUCKN6C.js → doctor-6KHBE77P.js} +15 -15
- package/dist/{fund-XPB4IIG5.js → fund-GSFCXEF7.js} +9 -10
- package/dist/{fund-XPB4IIG5.js.map → fund-GSFCXEF7.js.map} +1 -1
- package/dist/{hook-command-VVV2Q23L.js → hook-command-UQZ4DVDL.js} +90 -12
- package/dist/hook-command-UQZ4DVDL.js.map +1 -0
- package/dist/index.js +3 -3
- package/dist/{install-OSJRM2ME.js → install-TDYC22KI.js} +10 -10
- package/dist/{install-identity-YIWKQOUD.js → install-identity-QS4UFF27.js} +6 -6
- package/dist/{install-wallet-BWJO2SUC.js → install-wallet-T737X74E.js} +8 -9
- package/dist/{install-wallet-BWJO2SUC.js.map → install-wallet-T737X74E.js.map} +1 -1
- package/dist/{mcp-KE5YKPS2.js → mcp-JWOOSKLX.js} +449 -68
- package/dist/mcp-JWOOSKLX.js.map +1 -0
- package/dist/{pay-MUV2U232.js → pay-TDYQFSKY.js} +11 -12
- package/dist/{payments-4D27K4L2.js → payments-26NVMFR2.js} +6 -7
- package/dist/{payments-4D27K4L2.js.map → payments-26NVMFR2.js.map} +1 -1
- package/dist/{send-BXHFKDBF.js → send-4RUBQQKP.js} +8 -9
- package/dist/{send-BXHFKDBF.js.map → send-4RUBQQKP.js.map} +1 -1
- package/dist/{status-3Z3YPRSE.js → status-CEHZKHBU.js} +5 -5
- package/dist/{status-line-CKRMGZ3Q.js → status-line-QRAO3Y2E.js} +4 -4
- package/dist/{status-line-wiring-GECLIIBT.js → status-line-wiring-XKUVI5UW.js} +4 -4
- package/dist/tenjin-daemon.mjs +5 -2
- package/dist/{uninstall-BZTVWJ7W.js → uninstall-SJ6R2W2M.js} +10 -10
- package/dist/{update-IQQTEOI5.js → update-N2NZS3AA.js} +5 -5
- package/dist/{wallet-UFXQ57TZ.js → wallet-IB2EFAUP.js} +8 -9
- package/docs/agent-permissions.md +8 -8
- package/docs/safety-model.md +2 -2
- package/package.json +1 -1
- package/dist/chunk-ETW2ASBP.js.map +0 -1
- package/dist/chunk-QHILSA6G.js +0 -82
- package/dist/chunk-QHILSA6G.js.map +0 -1
- package/dist/chunk-UY2TOI3B.js.map +0 -1
- package/dist/chunk-W3LVZ2EN.js.map +0 -1
- package/dist/hook-command-VVV2Q23L.js.map +0 -1
- package/dist/mcp-KE5YKPS2.js.map +0 -1
- /package/dist/{chunk-PJEG2JIJ.js.map → chunk-2RMXTNLT.js.map} +0 -0
- /package/dist/{chunk-IOIHYOU4.js.map → chunk-3Q3UBMVB.js.map} +0 -0
- /package/dist/{chunk-2AQO4YDI.js.map → chunk-AG4DWNHO.js.map} +0 -0
- /package/dist/{chunk-OSUD6YZZ.js.map → chunk-CYEUVU3F.js.map} +0 -0
- /package/dist/{chunk-GHTPYKDT.js.map → chunk-DA53QKTD.js.map} +0 -0
- /package/dist/{chunk-YVODPFTL.js.map → chunk-DHCOGDJB.js.map} +0 -0
- /package/dist/{chunk-AQRUD5GQ.js.map → chunk-F4IJQBGP.js.map} +0 -0
- /package/dist/{chunk-SRVDXR6B.js.map → chunk-GONDQ27X.js.map} +0 -0
- /package/dist/{chunk-N4DJEQAF.js.map → chunk-NYJCBQL5.js.map} +0 -0
- /package/dist/{chunk-3EUTWC2B.js.map → chunk-NZYVSZNF.js.map} +0 -0
- /package/dist/{chunk-JN7TMXVF.js.map → chunk-TU3IK7KK.js.map} +0 -0
- /package/dist/{chunk-QRFONFRW.js.map → chunk-UGLTSPXQ.js.map} +0 -0
- /package/dist/{chunk-IOB7URFH.js.map → chunk-UHEMZEGW.js.map} +0 -0
- /package/dist/{chunk-OTPEH3AH.js.map → chunk-UIOZRILX.js.map} +0 -0
- /package/dist/{chunk-U2ATFMKZ.js.map → chunk-WXFVJPZD.js.map} +0 -0
- /package/dist/{chunk-C363JZN2.js.map → chunk-XBYTP4SP.js.map} +0 -0
- /package/dist/{config-MSN6H4MD.js.map → config-JBF5BZNO.js.map} +0 -0
- /package/dist/{doctor-ITUCKN6C.js.map → doctor-6KHBE77P.js.map} +0 -0
- /package/dist/{install-OSJRM2ME.js.map → install-TDYC22KI.js.map} +0 -0
- /package/dist/{install-identity-YIWKQOUD.js.map → install-identity-QS4UFF27.js.map} +0 -0
- /package/dist/{pay-MUV2U232.js.map → pay-TDYQFSKY.js.map} +0 -0
- /package/dist/{status-3Z3YPRSE.js.map → status-CEHZKHBU.js.map} +0 -0
- /package/dist/{status-line-CKRMGZ3Q.js.map → status-line-QRAO3Y2E.js.map} +0 -0
- /package/dist/{status-line-wiring-GECLIIBT.js.map → status-line-wiring-XKUVI5UW.js.map} +0 -0
- /package/dist/{uninstall-BZTVWJ7W.js.map → uninstall-SJ6R2W2M.js.map} +0 -0
- /package/dist/{update-IQQTEOI5.js.map → update-N2NZS3AA.js.map} +0 -0
- /package/dist/{wallet-UFXQ57TZ.js.map → wallet-IB2EFAUP.js.map} +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createRequire as __tenjinCreateRequire } from 'node:module'; const require = __tenjinCreateRequire(import.meta.url);
|
|
2
2
|
import {
|
|
3
3
|
inspectHooksFile
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-3Q3UBMVB.js";
|
|
5
5
|
import {
|
|
6
6
|
CliError,
|
|
7
7
|
writeFileAtomic
|
|
@@ -169,4 +169,4 @@ export {
|
|
|
169
169
|
removeStatusLine,
|
|
170
170
|
inspectStatusLine
|
|
171
171
|
};
|
|
172
|
-
//# sourceMappingURL=chunk-
|
|
172
|
+
//# sourceMappingURL=chunk-TU3IK7KK.js.map
|
|
@@ -2,10 +2,10 @@ import { createRequire as __tenjinCreateRequire } from 'node:module'; const requ
|
|
|
2
2
|
import {
|
|
3
3
|
fetchFailureToCliError,
|
|
4
4
|
httpRequest
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-AG4DWNHO.js";
|
|
6
6
|
import {
|
|
7
7
|
external_exports
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-SAN5PFTL.js";
|
|
9
9
|
|
|
10
10
|
// src/router/decision.ts
|
|
11
11
|
var ROUTER_PATH = "/api/x402-router";
|
|
@@ -74,13 +74,39 @@ var DiscoveredCandidateSchema = external_exports.strictObject({
|
|
|
74
74
|
schema: external_exports.record(external_exports.string(), external_exports.unknown())
|
|
75
75
|
})
|
|
76
76
|
});
|
|
77
|
+
var ToolSpecSchema = external_exports.strictObject({
|
|
78
|
+
capabilityId: external_exports.string().min(1).max(200),
|
|
79
|
+
provider: external_exports.string().min(1).max(120),
|
|
80
|
+
description: external_exports.string().min(1).max(500),
|
|
81
|
+
priceAtomic: external_exports.string().regex(/^\d+$/),
|
|
82
|
+
priceVaries: external_exports.boolean(),
|
|
83
|
+
maxAmountAtomic: external_exports.string().regex(/^\d+$/),
|
|
84
|
+
payTo: external_exports.string().min(1).max(200),
|
|
85
|
+
network: external_exports.string().min(1).max(64),
|
|
86
|
+
asset: external_exports.string().min(1).max(200),
|
|
87
|
+
request: external_exports.strictObject({
|
|
88
|
+
method: external_exports.enum(["GET", "POST"]),
|
|
89
|
+
url: external_exports.string().min(1).max(2048),
|
|
90
|
+
fields: external_exports.record(external_exports.string(), external_exports.enum(["path", "query", "body"])),
|
|
91
|
+
location: external_exports.enum(["query", "body"])
|
|
92
|
+
}),
|
|
93
|
+
input: external_exports.record(external_exports.string(), external_exports.unknown()),
|
|
94
|
+
pinned: external_exports.record(external_exports.string(), external_exports.unknown()),
|
|
95
|
+
example: external_exports.record(external_exports.string(), external_exports.unknown()).optional(),
|
|
96
|
+
returns: external_exports.string().min(1).max(200).optional(),
|
|
97
|
+
returnsExample: external_exports.unknown().optional(),
|
|
98
|
+
resultSchema: external_exports.record(external_exports.string(), external_exports.unknown()).optional()
|
|
99
|
+
});
|
|
100
|
+
var OfferSpecSchema = ToolSpecSchema.extend({ id: IdSchema });
|
|
101
|
+
var SpecsSchema = external_exports.array(OfferSpecSchema).min(1).max(4).optional();
|
|
77
102
|
var DiscoveredSchema = external_exports.strictObject({
|
|
78
103
|
action: external_exports.literal("discovered"),
|
|
79
104
|
id: IdSchema,
|
|
80
105
|
candidate: DiscoveredCandidateSchema,
|
|
81
106
|
/** THE LINE, FINISHED, as on `execute`: it carries the seller's
|
|
82
107
|
* description and the input it takes. */
|
|
83
|
-
hint: external_exports.string().min(1).max(2e3)
|
|
108
|
+
hint: external_exports.string().min(1).max(2e3),
|
|
109
|
+
specs: SpecsSchema
|
|
84
110
|
}).superRefine(checkHint);
|
|
85
111
|
var HookDecisionSchema = external_exports.discriminatedUnion("action", [
|
|
86
112
|
external_exports.strictObject({
|
|
@@ -98,7 +124,8 @@ var HookDecisionSchema = external_exports.discriminatedUnion("action", [
|
|
|
98
124
|
* more: two sides writing the same sentence is how they drift. The same
|
|
99
125
|
* bound as a discovered line's.
|
|
100
126
|
*/
|
|
101
|
-
hint: external_exports.string().min(1).max(2e3)
|
|
127
|
+
hint: external_exports.string().min(1).max(2e3),
|
|
128
|
+
specs: SpecsSchema
|
|
102
129
|
}).superRefine(checkHint),
|
|
103
130
|
DiscoveredSchema,
|
|
104
131
|
RefusedSchema.extend({ action: external_exports.literal("native") }),
|
|
@@ -110,6 +137,22 @@ var ToolDecisionSchema = external_exports.discriminatedUnion("action", [
|
|
|
110
137
|
...CapabilityFields,
|
|
111
138
|
contract: ContractSchema
|
|
112
139
|
}),
|
|
140
|
+
/**
|
|
141
|
+
* A query with no id, answered with the spec of the service the server
|
|
142
|
+
* picked under a fresh `id`: kept like a hook's. `input` is there only when
|
|
143
|
+
* the query, as written, was a valid value for the spec's query field (a
|
|
144
|
+
* free-text field, or one whose format or pattern it satisfies), and the
|
|
145
|
+
* tool then runs it in the same call, checked again like any input.
|
|
146
|
+
* Otherwise the agent fills the skeleton. `hint` is the line, with the skeleton of the call:
|
|
147
|
+
* `request({id, input: {...}})` with the required fields, or the bound one.
|
|
148
|
+
*/
|
|
149
|
+
external_exports.strictObject({
|
|
150
|
+
action: external_exports.literal("spec"),
|
|
151
|
+
id: IdSchema,
|
|
152
|
+
spec: ToolSpecSchema,
|
|
153
|
+
hint: external_exports.string().min(1).max(2e3),
|
|
154
|
+
input: external_exports.record(external_exports.string(), external_exports.unknown()).optional()
|
|
155
|
+
}).superRefine(checkHint),
|
|
113
156
|
DiscoveredSchema,
|
|
114
157
|
RefusedSchema.extend({ action: external_exports.literal("native") }),
|
|
115
158
|
RefusedSchema.extend({ action: external_exports.literal("needs_input") })
|
|
@@ -127,7 +170,7 @@ function envelope(decision) {
|
|
|
127
170
|
}
|
|
128
171
|
var HookResponseSchema = envelope(HookDecisionSchema);
|
|
129
172
|
var ToolResponseSchema = envelope(ToolDecisionSchema);
|
|
130
|
-
var CLIENT_ACCEPTS = ["discovered"];
|
|
173
|
+
var CLIENT_ACCEPTS = ["discovered", "spec"];
|
|
131
174
|
var BAZAAR_ACCEPT = "bazaar";
|
|
132
175
|
function acceptsFor(bazaar) {
|
|
133
176
|
return bazaar ? [...CLIENT_ACCEPTS, BAZAAR_ACCEPT] : [...CLIENT_ACCEPTS];
|
|
@@ -173,6 +216,28 @@ async function requestDecision(kind, request, deps) {
|
|
|
173
216
|
kind === "hook" ? HookResponseSchema : ToolResponseSchema
|
|
174
217
|
);
|
|
175
218
|
}
|
|
219
|
+
var OUTCOME_TIMEOUT_MS = 3e3;
|
|
220
|
+
async function reportSpecOutcome(outcome, deps) {
|
|
221
|
+
try {
|
|
222
|
+
await httpRequest(new URL(ROUTER_PATH, deps.baseUrl).toString(), {
|
|
223
|
+
method: "POST",
|
|
224
|
+
timeoutMs: OUTCOME_TIMEOUT_MS,
|
|
225
|
+
blockRedirects: true,
|
|
226
|
+
jsonBody: buildOutcomeBody(outcome),
|
|
227
|
+
...deps.fetchImpl !== void 0 ? { fetchImpl: deps.fetchImpl } : {}
|
|
228
|
+
});
|
|
229
|
+
} catch {
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
function buildOutcomeBody(outcome) {
|
|
233
|
+
return {
|
|
234
|
+
schemaVersion: 1,
|
|
235
|
+
id: outcome.id,
|
|
236
|
+
status: outcome.status,
|
|
237
|
+
...outcome.httpStatus !== void 0 ? { httpStatus: outcome.httpStatus } : {},
|
|
238
|
+
...outcome.ms !== void 0 ? { ms: Math.max(0, Math.round(outcome.ms)) } : {}
|
|
239
|
+
};
|
|
240
|
+
}
|
|
176
241
|
function readDecision(response, schema) {
|
|
177
242
|
if (!response.ok) return { status: "failed", reason: fetchFailureToCliError(response).message };
|
|
178
243
|
if (response.status < 200 || response.status >= 300) {
|
|
@@ -203,6 +268,8 @@ function errorOf(body) {
|
|
|
203
268
|
|
|
204
269
|
export {
|
|
205
270
|
ROUTER_PATH,
|
|
206
|
-
|
|
271
|
+
OfferSpecSchema,
|
|
272
|
+
requestDecision,
|
|
273
|
+
reportSpecOutcome
|
|
207
274
|
};
|
|
208
|
-
//# sourceMappingURL=chunk-
|
|
275
|
+
//# sourceMappingURL=chunk-U5FFVIIF.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/router/decision.ts"],"sourcesContent":["import { z } from 'zod';\nimport { fetchFailureToCliError, httpRequest } from '../lib/http';\nimport type { HttpRequestOptions, HttpResult } from '../lib/http';\nimport type { CommandContext } from '../context';\nimport type { Packet } from './context';\n\n/**\n * `POST /api/x402-router`: ONE FREE DECISION PER LOOKUP.\n *\n * The routing decision costs nothing and nobody signs for it. The hook asks for\n * it from the user's own words, the backend answers with what it would do and\n * what the provider charges, and the only payment on the wire is the one\n * `runPay` makes to that provider. That deletes the router fee and everything\n * built to carry it: the 402 probe, the requirements cache, the stale-quote\n * retry, the settlement accounting and one Base settlement of about 1.5 s from\n * every paid lookup.\n *\n * NOTHING IS STORED LOCALLY. The bounded packet travels with the request and\n * the backend keeps it against the decision id until that id expires, which is\n * how `request({query})` reaches the same calibrated input with no session\n * file, no timestamp latch and no guess about which window this process serves.\n */\n\nexport const ROUTER_PATH = '/api/x402-router';\n\n/**\n * The request the server builds and this client sends verbatim. Query assembly,\n * body encoding and header choice are the server's; what stays here is every\n * check that decides whether to send it at all.\n */\nconst RequestSchema = z.object({\n url: z.string().min(1).max(16_384),\n method: z.enum(['GET', 'POST', 'PUT', 'PATCH', 'DELETE', 'HEAD', 'OPTIONS']),\n headers: z.record(z.string(), z.string()),\n body: z\n .string()\n .max(256 * 1024)\n .optional(),\n});\n\nconst ContractSchema = z.object({\n /** Flat, for display and for the result check; never re-encoded into a call:\n * the server built `request` from them and this client sends that verbatim. */\n arguments: z.record(z.string(), z.unknown()).optional(),\n resultSchema: z.record(z.string(), z.unknown()).optional(),\n request: RequestSchema,\n});\nexport type DecisionContract = z.infer<typeof ContractSchema>;\n\n/**\n * What stopped an outcome this client cannot execute, in terms the host can act\n * on: a stable reason code, the stage that stopped, the fields or scope choices\n * the user can supply, and one concrete next action.\n */\nconst DiagnosticsSchema = z.object({\n reasonCode: z.string().min(1).max(64),\n stage: z.string().min(1).max(32),\n missing: z.array(z.string().max(200)).max(60),\n nextAction: z.string().max(500),\n});\nexport type DecisionDiagnostics = z.infer<typeof DiagnosticsSchema>;\n\n/**\n * ONE VARIANT PER ANSWER, DISCRIMINATED ON THE ACTION. Optional fields made\n * every shape legal: an `execute` with no contract parsed and came back to the\n * host as a routine `needs_input`, a non-execute with no diagnostics parsed\n * with nothing to act on, and a hook answer carrying a contract parsed as\n * though the hook had quoted a price. Each of those is drift the shared\n * fixtures exist to catch, so each is now a parse failure that names itself.\n *\n * The two calls ask different questions and get different answers, so they get\n * different parsers. The HOOK asks whether a paid lookup is worth offering: an\n * id, or a reason it is not. The TOOL asks for the decision: the capability,\n * its price and the contract together, so a caller cannot approve one offer and\n * receive another.\n */\nconst IdSchema = z\n .string()\n .regex(/^[A-Za-z0-9_-]{8,64}$/)\n .describe(\n 'The turn id, an OPAQUE HANDLE: it is the one piece of server text this ' +\n 'client puts in a model-facing line, so the alphabet is pinned here ' +\n 'rather than escaped later.',\n );\n\n/** Every non-execute answer carries these, beside the action they explain. */\nconst RefusedSchema = z.strictObject({\n reason: z.string().max(2_000).optional(),\n diagnostics: DiagnosticsSchema,\n});\n\n/**\n * WHAT THE SERVICE IS, AND WHAT IT DOES. The hook answer used to be an id and\n * nothing else, so the line the host injected could only say \"a paid lookup is\n * available\", which a model follows 8 to 20 times in 40 where a line naming the\n * task and the service is followed 40 in 40. The gate knows which capability\n * serves the category it chose, so it now says so; the CONTRACT is still not\n * here, because the task the host will run does not exist yet.\n */\nconst CapabilityFields = {\n capabilityId: z.string().min(1).max(200),\n category: z.string().min(1).max(64),\n /** The service's own name, not the x402 reseller in front of it. */\n provider: z.string().min(1).max(120),\n capabilityDescription: z.string().min(1).max(500),\n /** What the provider charges, atomic USDC. The `request` tool refuses a live\n * 402 above it; `gateSpend` still caps the amount actually signed. */\n providerPriceAtomic: z.string().regex(/^\\d+$/),\n};\n\n/**\n * STRUCTURE, NEVER WORDING. A hint lands in the model's context verbatim, so\n * its shape is checked the way the id's alphabet is: one line, no control\n * characters, and it has to be the call it claims to be, naming the id this\n * same answer carries. A hint that fails any of these is a protocol error and\n * the turn falls back to the generic line; nothing here rewrites a word of a\n * hint that passes. Both offering arms, `execute` and `discovered`, hold it.\n */\nfunction checkHint(decision: { id: string; hint: string }, ctx: z.RefinementCtx): void {\n if (/[\\p{Cc}\\p{Cf}]/u.test(decision.hint)) {\n ctx.addIssue({ code: 'custom', path: ['hint'], message: 'a hint is one plain line' });\n }\n if (!decision.hint.includes('request({')) {\n ctx.addIssue({ code: 'custom', path: ['hint'], message: 'a hint names the call to make' });\n }\n if (!decision.hint.includes(decision.id)) {\n ctx.addIssue({\n code: 'custom',\n path: ['hint'],\n message: \"a hint carries this answer's own id\",\n });\n }\n}\n\n/**\n * A PAY-PER-CALL SERVICE NOBODY CURATED. When no capability in the catalog fits\n * but a listed x402 service could do the step, the server names that one\n * service: who sells it, where, for how much, and the input it takes. The\n * candidate is the seller's own listing, so every field is data for the host\n * to judge, never an instruction; the host builds the `input` and the tool\n * call pays through the same `runPay` path and caps as a curated lookup.\n */\nconst DiscoveredCandidateSchema = z.strictObject({\n source: z.string().min(1).max(64),\n provider: z.string().min(1).max(120),\n url: z.string().min(1).max(2_048),\n method: z.enum(['GET', 'POST']),\n description: z.string().max(500),\n providerPriceAtomic: z.string().regex(/^\\d+$/),\n network: z.string().min(1).max(64),\n payTo: z.string().min(1).max(200),\n input: z.strictObject({\n location: z.enum(['body', 'query']),\n schema: z.record(z.string(), z.unknown()),\n }),\n});\n\n/**\n * A REQUEST SPEC: the offered service's real contract, sent beside the line only\n * because this build asks for it (`accepts: [\"spec\"]`). The hook stores it by\n * the offer's id; `request({id})` shows it and `request({id, input})` fills its\n * request and pays the provider directly, with no second decision. Every field\n * is the server's, and so is checked like the rest of the answer: the payee and\n * price still meet the live 402 and the spend policy in `runPay`.\n */\nexport const ToolSpecSchema = z.strictObject({\n capabilityId: z.string().min(1).max(200),\n provider: z.string().min(1).max(120),\n description: z.string().min(1).max(500),\n priceAtomic: z.string().regex(/^\\d+$/),\n priceVaries: z.boolean(),\n maxAmountAtomic: z.string().regex(/^\\d+$/),\n payTo: z.string().min(1).max(200),\n network: z.string().min(1).max(64),\n asset: z.string().min(1).max(200),\n request: z.strictObject({\n method: z.enum(['GET', 'POST']),\n url: z.string().min(1).max(2_048),\n fields: z.record(z.string(), z.enum(['path', 'query', 'body'])),\n location: z.enum(['query', 'body']),\n }),\n input: z.record(z.string(), z.unknown()),\n pinned: z.record(z.string(), z.unknown()),\n example: z.record(z.string(), z.unknown()).optional(),\n returns: z.string().min(1).max(200).optional(),\n returnsExample: z.unknown().optional(),\n resultSchema: z.record(z.string(), z.unknown()).optional(),\n});\nexport type ToolSpec = z.infer<typeof ToolSpecSchema>;\n\nexport const OfferSpecSchema = ToolSpecSchema.extend({ id: IdSchema });\nexport type OfferSpec = z.infer<typeof OfferSpecSchema>;\n\n/** One spec per service the line names: the offer and any alternative. */\nconst SpecsSchema = z.array(OfferSpecSchema).min(1).max(4).optional();\n\n/** The same answer on both calls: the hook's offer, and the tool's fallback\n * when a query with no id found no curated capability. */\nconst DiscoveredSchema = z\n .strictObject({\n action: z.literal('discovered'),\n id: IdSchema,\n candidate: DiscoveredCandidateSchema,\n /** THE LINE, FINISHED, as on `execute`: it carries the seller's\n * description and the input it takes. */\n hint: z.string().min(1).max(2_000),\n specs: SpecsSchema,\n })\n .superRefine(checkHint);\n\nconst HookDecisionSchema = z.discriminatedUnion('action', [\n z\n .strictObject({\n action: z.literal('execute'),\n id: IdSchema,\n ...CapabilityFields,\n /** The x402 URL a lookup would pay, for the line the server writes. */\n endpoint: z.string().min(1).max(2_048),\n /** What to pass in `query`, in the service's own terms. */\n usage: z.string().min(1).max(300),\n /**\n * THE LINE, FINISHED. The server writes it with the real id in it and, on a\n * native call, the exact search or URL that was denied. The client injects\n * it and composes nothing, which is why there is no hint builder here any\n * more: two sides writing the same sentence is how they drift. The same\n * bound as a discovered line's.\n */\n hint: z.string().min(1).max(2_000),\n specs: SpecsSchema,\n })\n .superRefine(checkHint),\n DiscoveredSchema,\n RefusedSchema.extend({ action: z.literal('native') }),\n RefusedSchema.extend({ action: z.literal('needs_input') }),\n]);\n\nconst ToolDecisionSchema = z.discriminatedUnion('action', [\n z.strictObject({\n action: z.literal('execute'),\n ...CapabilityFields,\n contract: ContractSchema,\n }),\n /**\n * A query with no id, answered with the spec of the service the server\n * picked under a fresh `id`: kept like a hook's. `input` is there only when\n * the query, as written, was a valid value for the spec's query field (a\n * free-text field, or one whose format or pattern it satisfies), and the\n * tool then runs it in the same call, checked again like any input.\n * Otherwise the agent fills the skeleton. `hint` is the line, with the skeleton of the call:\n * `request({id, input: {...}})` with the required fields, or the bound one.\n */\n z\n .strictObject({\n action: z.literal('spec'),\n id: IdSchema,\n spec: ToolSpecSchema,\n hint: z.string().min(1).max(2_000),\n input: z.record(z.string(), z.unknown()).optional(),\n })\n .superRefine(checkHint),\n DiscoveredSchema,\n RefusedSchema.extend({ action: z.literal('native') }),\n RefusedSchema.extend({ action: z.literal('needs_input') }),\n]);\n\nfunction envelope<T extends z.ZodTypeAny>(decision: T) {\n return z.strictObject({\n schemaVersion: z.literal(1),\n routerVersion: z.string().min(1).max(64),\n decision,\n /** A plain sentence about the CALL, such as an id that had expired. Never a\n * failure: the decision beside it ran anyway. */\n note: z.string().max(500).optional(),\n jev: z.object({ calls: z.number(), latencyMs: z.number() }).optional(),\n });\n}\n\nconst HookResponseSchema = envelope(HookDecisionSchema);\nconst ToolResponseSchema = envelope(ToolDecisionSchema);\n\nexport type HookResponse = z.infer<typeof HookResponseSchema>;\nexport type ToolResponse = z.infer<typeof ToolResponseSchema>;\nexport type HookDecision = HookResponse['decision'];\nexport type ToolDecision = ToolResponse['decision'];\n\n/** Which call this is, and therefore which answer is legal for it. */\nexport type CallKind = 'hook' | 'tool';\n\n/**\n * What this client can act on beyond the curated answers, sent on both calls.\n * `discovered` is Tenjin's reviewed list of third-party services, on for every\n * build that parses it; the server answers that arm only to a request that\n * lists it, so an older build never sees one. `spec` asks for each offered\n * service's request spec beside its line, and for the picked service's spec in\n * place of a decision on a query with no id, which only a build that parses\n * them can take: the decision schemas are strict. `bazaar` widens discovery\n * to the open Bazaar and is sent only while `experimental.bazaar` is on.\n */\nexport const CLIENT_ACCEPTS: readonly string[] = ['discovered', 'spec'];\nexport const BAZAAR_ACCEPT = 'bazaar';\n\n/** The `accepts` this build sends, with the open Bazaar or without it. */\nexport function acceptsFor(bazaar: boolean): string[] {\n return bazaar ? [...CLIENT_ACCEPTS, BAZAAR_ACCEPT] : [...CLIENT_ACCEPTS];\n}\n\n/**\n * The exact body the hook call sends, spelled once and pinned to the shared\n * fixtures. The route reads it with a strict object, so an extra field is a\n * 400, and a 400 is a turn with no hint.\n *\n * ONE BODY FOR BOTH HOOKS. Which hook is asking is not a field: the route reads\n * it from `packet.pendingCall`, which the native hook sets and the prompt hook\n * does not. A `source` beside the packet was the `/prepare` route's shape, and\n * that route is gone. `sessionId` is the harness's own session id, which the\n * server uses only so one session is not offered the same discovered service\n * twice.\n */\nexport function buildHookBody(\n packet: Packet,\n extras: { sessionId?: string; accepts?: readonly string[] } = {},\n): Record<string, unknown> {\n return {\n schemaVersion: 1,\n ...(extras.sessionId !== undefined ? { sessionId: extras.sessionId } : {}),\n ...(extras.accepts !== undefined ? { accepts: [...extras.accepts] } : {}),\n packet,\n };\n}\n\n/** The exact body the tool call sends. `id` is the turn whose packet decides\n * with this query; `gateHint` is evidence, never authority. `input` is the\n * host's own input for a discovered service, and stands in for `query`. */\nexport function buildToolBody(request: {\n query?: string;\n id?: string;\n input?: Record<string, unknown>;\n gateHint?: GateHint;\n accepts?: readonly string[];\n}): Record<string, unknown> {\n return {\n schemaVersion: 1,\n ...(request.query !== undefined ? { query: request.query } : {}),\n ...(request.id !== undefined ? { id: request.id } : {}),\n ...(request.input !== undefined ? { input: request.input } : {}),\n ...(request.gateHint !== undefined ? { gateHint: request.gateHint } : {}),\n ...(request.accepts !== undefined ? { accepts: [...request.accepts] } : {}),\n };\n}\n\n/** The parsers, exposed so the shared wire fixtures are checked against the\n * same schemas production parses with rather than against a copy of them. */\nexport function parseForTests(kind: CallKind, value: unknown): { success: boolean } {\n const schema = kind === 'hook' ? HookResponseSchema : ToolResponseSchema;\n return { success: schema.safeParse(value).success };\n}\n\n/**\n * The gate's own reading of this turn, travelling as EVIDENCE for the lookup it\n * was produced for. The backend may refine or reject it, and it authorizes no\n * money: the local spend policy does that. Optional on both call forms.\n */\nexport interface GateHint {\n category: string;\n turnId: string;\n lookupId: string;\n}\n\nexport interface DecisionDeps {\n ctx: CommandContext;\n baseUrl: string;\n /** `experimental.bazaar`: add {@link BAZAAR_ACCEPT}, so a service from the\n * open Bazaar may come back. Off by default: curated and the Tenjin list. */\n acceptsBazaar?: boolean;\n fetchImpl?: typeof fetch;\n /** Overrides the per-call deadline; the hook passes its own, smaller one. */\n timeoutMs?: number;\n}\n\nexport type DecisionOutcome<T> =\n | { status: 'decided'; decision: T }\n /** Nothing was paid and nothing could be: the endpoint is free, so a failure\n * here costs the turn a routing answer and nothing else. */\n | { status: 'failed'; reason: string; errorCode?: string };\n\n/**\n * ONE FREE CALL, IN TWO FORMS. The hook sends `{ packet }`: the backend runs\n * the gate, and on `execute` stores that packet under an id. The tool sends\n * `{ query, id? }`: the backend makes THE decision from that query plus the\n * packet it stored, and answers with the contract to run. A discovered\n * service's id is sent with the host's own `{ input }` instead of a query.\n *\n * The tool never sends a packet of its own. The turn's context lives on the\n * backend against the id, and the query the model wrote is what the routing\n * corpus is calibrated against: 55 of 56 for query plus packet, 53 of 56 for\n * the raw prompt, measured on jev-1.13.0.\n */\nexport async function requestDecision(\n kind: 'hook',\n request: { packet: Packet; sessionId?: string },\n deps: DecisionDeps,\n): Promise<DecisionOutcome<HookResponse>>;\nexport async function requestDecision(\n kind: 'tool',\n request: { query?: string; id?: string; input?: Record<string, unknown>; gateHint?: GateHint },\n deps: DecisionDeps,\n): Promise<DecisionOutcome<ToolResponse>>;\nexport async function requestDecision(\n kind: CallKind,\n request: {\n query?: string;\n packet?: Packet;\n sessionId?: string;\n id?: string;\n input?: Record<string, unknown>;\n gateHint?: GateHint;\n },\n deps: DecisionDeps,\n): Promise<DecisionOutcome<HookResponse | ToolResponse>> {\n const url = new URL(ROUTER_PATH, deps.baseUrl).toString();\n const options: HttpRequestOptions = {\n method: 'POST',\n timeoutMs: deps.timeoutMs ?? deps.ctx.flags.timeout,\n blockRedirects: true,\n jsonBody:\n kind === 'hook'\n ? buildHookBody(request.packet as Packet, {\n ...(request.sessionId !== undefined ? { sessionId: request.sessionId } : {}),\n accepts: acceptsFor(deps.acceptsBazaar === true),\n })\n : buildToolBody({\n ...(request.query !== undefined ? { query: request.query } : {}),\n ...(request.id !== undefined ? { id: request.id } : {}),\n ...(request.input !== undefined ? { input: request.input } : {}),\n ...(request.gateHint !== undefined ? { gateHint: request.gateHint } : {}),\n accepts: acceptsFor(deps.acceptsBazaar === true),\n }),\n ...(deps.fetchImpl !== undefined ? { fetchImpl: deps.fetchImpl } : {}),\n };\n return readDecision(\n await httpRequest(url, options),\n kind === 'hook' ? HookResponseSchema : ToolResponseSchema,\n );\n}\n\n/** How a call run from a request spec ended, for the server's offer-to-call\n * count. No text: the id, the outcome, the provider's status and the time. */\nexport interface SpecOutcome {\n id: string;\n status: 'fulfilled' | 'unverified' | 'failed' | 'needs_approval';\n httpStatus?: number;\n ms?: number;\n}\n\n/** The outcome report's own deadline: it is telemetry and never holds a result. */\nexport const OUTCOME_TIMEOUT_MS = 3_000;\n\n/**\n * TELL THE SERVER A SPEC WAS USED. The client called and paid the provider\n * itself, so this is the only word the server gets that its offer was taken.\n * Never throws and never waits on anything the caller needs: a lost report\n * costs one count.\n */\nexport async function reportSpecOutcome(\n outcome: SpecOutcome,\n deps: Pick<DecisionDeps, 'ctx' | 'baseUrl' | 'fetchImpl'>,\n): Promise<void> {\n try {\n await httpRequest(new URL(ROUTER_PATH, deps.baseUrl).toString(), {\n method: 'POST',\n timeoutMs: OUTCOME_TIMEOUT_MS,\n blockRedirects: true,\n jsonBody: buildOutcomeBody(outcome),\n ...(deps.fetchImpl !== undefined ? { fetchImpl: deps.fetchImpl } : {}),\n });\n } catch {\n // Telemetry only.\n }\n}\n\n/** The exact body of an outcome report, pinned to the shared fixtures. */\nexport function buildOutcomeBody(outcome: SpecOutcome): Record<string, unknown> {\n return {\n schemaVersion: 1,\n id: outcome.id,\n status: outcome.status,\n ...(outcome.httpStatus !== undefined ? { httpStatus: outcome.httpStatus } : {}),\n ...(outcome.ms !== undefined ? { ms: Math.max(0, Math.round(outcome.ms)) } : {}),\n };\n}\n\nfunction readDecision<T extends z.ZodTypeAny>(\n response: HttpResult,\n schema: T,\n): DecisionOutcome<z.infer<T>> {\n // A transport failure says its own reason; nothing was paid either way,\n // because there is nothing to pay for on this route.\n if (!response.ok) return { status: 'failed', reason: fetchFailureToCliError(response).message };\n if (response.status < 200 || response.status >= 300) {\n const named = errorOf(response.json);\n return {\n status: 'failed',\n // The backend's own code and message, never a bare status line: a typed\n // refusal the host could act on was arriving as \"answered 400\".\n reason:\n named === null\n ? `The router endpoint answered ${response.status}.`\n : `The router endpoint answered ${response.status} (${named.code}): ${named.message}`,\n ...(named !== null ? { errorCode: named.code } : {}),\n };\n }\n const parsed = schema.safeParse(response.json);\n if (!parsed.success) {\n return { status: 'failed', reason: 'The router returned a decision this build cannot read.' };\n }\n return { status: 'decided', decision: parsed.data as z.infer<T> };\n}\n\n/** `{ error: { code, message } }`, the envelope every Tenjin route answers a\n * refusal with. Anything else reads as no code rather than as a guess. */\nfunction errorOf(body: unknown): { code: string; message: string } | null {\n if (body === null || typeof body !== 'object') return null;\n const error = (body as { error?: unknown }).error;\n if (error === null || typeof error !== 'object') return null;\n const { code, message } = error as { code?: unknown; message?: unknown };\n if (typeof code !== 'string' || code.length === 0 || code.length > 64) return null;\n const text = typeof message === 'string' ? message.slice(0, 500) : '';\n return { code, message: text };\n}\n"],"mappings":";;;;;;;;;;AAuBO,IAAM,cAAc;AAO3B,IAAM,gBAAgB,iBAAE,OAAO;AAAA,EAC7B,KAAK,iBAAE,OAAO,EAAE,IAAI,CAAC,EAAE,IAAI,KAAM;AAAA,EACjC,QAAQ,iBAAE,KAAK,CAAC,OAAO,QAAQ,OAAO,SAAS,UAAU,QAAQ,SAAS,CAAC;AAAA,EAC3E,SAAS,iBAAE,OAAO,iBAAE,OAAO,GAAG,iBAAE,OAAO,CAAC;AAAA,EACxC,MAAM,iBACH,OAAO,EACP,IAAI,MAAM,IAAI,EACd,SAAS;AACd,CAAC;AAED,IAAM,iBAAiB,i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MACvF,GAAI,UAAU,OAAO,EAAE,WAAW,MAAM,KAAK,IAAI,CAAC;AAAA,IACpD;AAAA,EACF;AACA,QAAM,SAAS,OAAO,UAAU,SAAS,IAAI;AAC7C,MAAI,CAAC,OAAO,SAAS;AACnB,WAAO,EAAE,QAAQ,UAAU,QAAQ,yDAAyD;AAAA,EAC9F;AACA,SAAO,EAAE,QAAQ,WAAW,UAAU,OAAO,KAAmB;AAClE;AAIA,SAAS,QAAQ,MAAyD;AACxE,MAAI,SAAS,QAAQ,OAAO,SAAS,SAAU,QAAO;AACtD,QAAM,QAAS,KAA6B;AAC5C,MAAI,UAAU,QAAQ,OAAO,UAAU,SAAU,QAAO;AACxD,QAAM,EAAE,MAAM,QAAQ,IAAI;AAC1B,MAAI,OAAO,SAAS,YAAY,KAAK,WAAW,KAAK,KAAK,SAAS,GAAI,QAAO;AAC9E,QAAM,OAAO,OAAO,YAAY,WAAW,QAAQ,MAAM,GAAG,GAAG,IAAI;AACnE,SAAO,EAAE,MAAM,SAAS,KAAK;AAC/B;","names":[]}
|
|
@@ -30,39 +30,37 @@ import {
|
|
|
30
30
|
} from "./chunk-LHHMV4GU.js";
|
|
31
31
|
import {
|
|
32
32
|
USDC_ADDRESS
|
|
33
|
-
} from "./chunk-
|
|
34
|
-
import {
|
|
35
|
-
readUsdcBalance
|
|
36
|
-
} from "./chunk-QHILSA6G.js";
|
|
33
|
+
} from "./chunk-F4IJQBGP.js";
|
|
37
34
|
import {
|
|
38
35
|
describeWallet,
|
|
39
36
|
resolveSpendAuthorizer,
|
|
40
37
|
resolveWalletProvider
|
|
41
|
-
} from "./chunk-
|
|
38
|
+
} from "./chunk-DHCOGDJB.js";
|
|
42
39
|
import {
|
|
43
40
|
getAddress
|
|
44
41
|
} from "./chunk-EGELTSPU.js";
|
|
45
42
|
import {
|
|
46
43
|
sanitizeForTerminal
|
|
47
|
-
} from "./chunk-
|
|
44
|
+
} from "./chunk-UGLTSPXQ.js";
|
|
48
45
|
import {
|
|
49
46
|
mask
|
|
50
47
|
} from "./chunk-7QKHZQKW.js";
|
|
51
48
|
import {
|
|
52
49
|
fetchFailureToCliError,
|
|
53
50
|
httpRequest
|
|
54
|
-
} from "./chunk-
|
|
51
|
+
} from "./chunk-AG4DWNHO.js";
|
|
55
52
|
import {
|
|
56
53
|
resolveContextSettings
|
|
57
|
-
} from "./chunk-
|
|
54
|
+
} from "./chunk-UHEMZEGW.js";
|
|
58
55
|
import {
|
|
59
56
|
parseUsdToAtomic,
|
|
60
57
|
toMoney
|
|
61
58
|
} from "./chunk-O2JYBOUO.js";
|
|
62
59
|
import {
|
|
63
60
|
external_exports,
|
|
64
|
-
isSameDeployment
|
|
65
|
-
|
|
61
|
+
isSameDeployment,
|
|
62
|
+
readUsdcBalanceWithFallback
|
|
63
|
+
} from "./chunk-SAN5PFTL.js";
|
|
66
64
|
import {
|
|
67
65
|
CliError
|
|
68
66
|
} from "./chunk-JLEF5WHM.js";
|
|
@@ -8617,18 +8615,18 @@ function walk(value, schemaMode, depth = 0) {
|
|
|
8617
8615
|
if (schemaMode && key === "$ref" && typeof entry === "string" && !entry.startsWith("#/")) {
|
|
8618
8616
|
throw new Error("Remote or recursive schema references are unsupported.");
|
|
8619
8617
|
}
|
|
8620
|
-
if (schemaMode && (key === "pattern" || key === "patternProperties")) {
|
|
8618
|
+
if (schemaMode && (key === "pattern" && typeof entry === "string" || key === "patternProperties")) {
|
|
8621
8619
|
throw new Error("Regular-expression schema constraints are unsupported.");
|
|
8622
8620
|
}
|
|
8623
8621
|
walk(entry, schemaMode, depth + 1);
|
|
8624
8622
|
}
|
|
8625
8623
|
}
|
|
8626
8624
|
var validators = /* @__PURE__ */ new Map();
|
|
8627
|
-
function compile(schema) {
|
|
8625
|
+
function compile(schema, { allErrors = false, ignoreUnknown = false } = {}) {
|
|
8628
8626
|
if (Buffer.byteLength(stable(schema)) > MAX_SCHEMA_BYTES) {
|
|
8629
8627
|
throw new Error("Schema exceeds its size limit.");
|
|
8630
8628
|
}
|
|
8631
|
-
const key = canonicalHash(schema)
|
|
8629
|
+
const key = `${canonicalHash(schema)}${allErrors ? ":all" : ""}${ignoreUnknown ? ":lenient" : ""}`;
|
|
8632
8630
|
const cached = validators.get(key);
|
|
8633
8631
|
if (cached !== void 0) return cached;
|
|
8634
8632
|
walk(schema, true);
|
|
@@ -8637,7 +8635,8 @@ function compile(schema) {
|
|
|
8637
8635
|
strictTypes: false,
|
|
8638
8636
|
strictTuples: false,
|
|
8639
8637
|
strictRequired: false,
|
|
8640
|
-
|
|
8638
|
+
...ignoreUnknown ? { strictSchema: false, logger: false } : {},
|
|
8639
|
+
allErrors,
|
|
8641
8640
|
validateFormats: true,
|
|
8642
8641
|
coerceTypes: false,
|
|
8643
8642
|
useDefaults: false,
|
|
@@ -8676,6 +8675,58 @@ function validateAgainstSchema(schema, value) {
|
|
|
8676
8675
|
return { valid: false, errors: [err instanceof Error ? err.message : String(err)] };
|
|
8677
8676
|
}
|
|
8678
8677
|
}
|
|
8678
|
+
function withoutPatterns(value) {
|
|
8679
|
+
if (Array.isArray(value)) return value.map(withoutPatterns);
|
|
8680
|
+
if (value === null || typeof value !== "object") return value;
|
|
8681
|
+
return Object.fromEntries(
|
|
8682
|
+
Object.entries(value).filter(
|
|
8683
|
+
([key, entry]) => !(key === "pattern" && typeof entry === "string") && key !== "patternProperties"
|
|
8684
|
+
).map(([key, entry]) => [key, withoutPatterns(entry)])
|
|
8685
|
+
);
|
|
8686
|
+
}
|
|
8687
|
+
function describeProblem(error) {
|
|
8688
|
+
const at = error.instancePath.replace(/^\//, "").replaceAll("/", ".");
|
|
8689
|
+
const field = (name) => at ? `${at}.${name}` : name;
|
|
8690
|
+
const subject = at || "the input";
|
|
8691
|
+
const { params } = error;
|
|
8692
|
+
switch (error.keyword) {
|
|
8693
|
+
case "required":
|
|
8694
|
+
return `${field(String(params.missingProperty))} is required`;
|
|
8695
|
+
case "additionalProperties":
|
|
8696
|
+
return `${subject} has no field ${JSON.stringify(params.additionalProperty)}`;
|
|
8697
|
+
case "enum":
|
|
8698
|
+
return `${subject} must be one of ${params.allowedValues.map((v) => JSON.stringify(v)).join(", ")}`;
|
|
8699
|
+
case "const":
|
|
8700
|
+
return `${subject} must be ${JSON.stringify(params.allowedValue)}`;
|
|
8701
|
+
case "type":
|
|
8702
|
+
return `${subject} must be ${String(params.type)}`;
|
|
8703
|
+
default:
|
|
8704
|
+
return `${subject} ${error.message ?? "is invalid"}`;
|
|
8705
|
+
}
|
|
8706
|
+
}
|
|
8707
|
+
function inputProblems(schema, value) {
|
|
8708
|
+
if (schema === null || typeof schema !== "object" || Array.isArray(schema)) return void 0;
|
|
8709
|
+
let validate;
|
|
8710
|
+
try {
|
|
8711
|
+
validate = compile(withoutPatterns(schema), {
|
|
8712
|
+
allErrors: true,
|
|
8713
|
+
ignoreUnknown: true
|
|
8714
|
+
});
|
|
8715
|
+
} catch {
|
|
8716
|
+
return void 0;
|
|
8717
|
+
}
|
|
8718
|
+
try {
|
|
8719
|
+
const json = JSON.stringify(value);
|
|
8720
|
+
if (json === void 0 || Buffer.byteLength(json) > MAX_VALUE_BYTES) {
|
|
8721
|
+
return ["the input is not JSON, or exceeds its size limit"];
|
|
8722
|
+
}
|
|
8723
|
+
walk(value, false);
|
|
8724
|
+
} catch (err) {
|
|
8725
|
+
return [err instanceof Error ? err.message : String(err)];
|
|
8726
|
+
}
|
|
8727
|
+
if (validate(value)) return [];
|
|
8728
|
+
return [...new Set((validate.errors ?? []).map(describeProblem))];
|
|
8729
|
+
}
|
|
8679
8730
|
function assertResultSchema(schema) {
|
|
8680
8731
|
if (schema === null || typeof schema !== "object" || Array.isArray(schema)) {
|
|
8681
8732
|
throw new Error("A result success schema must be a JSON Schema object.");
|
|
@@ -10182,7 +10233,7 @@ async function executePay(args, ctx, deps, warnings) {
|
|
|
10182
10233
|
try {
|
|
10183
10234
|
if (amountAtomic > 0n) {
|
|
10184
10235
|
const deadline = Date.now() + ctx.flags.timeout;
|
|
10185
|
-
const readBalance = deps.readBalance ??
|
|
10236
|
+
const readBalance = deps.readBalance ?? readUsdcBalanceWithFallback;
|
|
10186
10237
|
let balance = await readBalance(signer.address, settings.rpcUrl, {
|
|
10187
10238
|
timeoutMs: Math.max(1, Math.floor(ctx.flags.timeout / 2))
|
|
10188
10239
|
});
|
|
@@ -10553,10 +10604,11 @@ export {
|
|
|
10553
10604
|
require_ajv,
|
|
10554
10605
|
require_dist,
|
|
10555
10606
|
canonicalHash,
|
|
10607
|
+
inputProblems,
|
|
10556
10608
|
assertResultSchema,
|
|
10557
10609
|
runPay,
|
|
10558
10610
|
MAX_PAID_LEG_TIMEOUT_MS,
|
|
10559
10611
|
paidLegTimeoutMs,
|
|
10560
10612
|
settlementTx
|
|
10561
10613
|
};
|
|
10562
|
-
//# sourceMappingURL=chunk-
|
|
10614
|
+
//# sourceMappingURL=chunk-UAT3Q7VF.js.map
|