tenjin-cli 0.1.0-alpha.23 → 0.1.0-alpha.24
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/NOTICE.md +1 -1
- package/README.md +2 -7
- package/dist/{chunk-HTC4VJFT.js → chunk-EP5P2STS.js} +8 -11
- package/dist/chunk-EP5P2STS.js.map +1 -0
- package/dist/{chunk-F4IJQBGP.js → chunk-FFL5M5BC.js} +2 -2
- package/dist/{chunk-DHCOGDJB.js → chunk-GPLSNGKX.js} +4 -4
- package/dist/{chunk-Y3LKUXZA.js → chunk-H5UR3GFJ.js} +98 -14
- package/dist/chunk-H5UR3GFJ.js.map +1 -0
- package/dist/{chunk-K63HPLYT.js → chunk-IIE65SJC.js} +4 -4
- package/dist/{chunk-2RMXTNLT.js → chunk-KC24CYGV.js} +4 -4
- package/dist/{chunk-XBYTP4SP.js → chunk-NSDZESRS.js} +3 -3
- package/dist/{chunk-UGLTSPXQ.js → chunk-O2WN732M.js} +2 -2
- package/dist/{chunk-SAN5PFTL.js → chunk-P22ZWXFX.js} +1 -1
- package/dist/{chunk-SAN5PFTL.js.map → chunk-P22ZWXFX.js.map} +1 -1
- package/dist/{chunk-2QYORQBF.js → chunk-P7LABKCW.js} +36 -1
- package/dist/{chunk-2QYORQBF.js.map → chunk-P7LABKCW.js.map} +1 -1
- package/dist/{chunk-3IOS6YG6.js → chunk-RCJ64OXH.js} +3 -3
- package/dist/{chunk-6O6DFYF3.js → chunk-SQSKVKX6.js} +2 -2
- package/dist/{chunk-UHEMZEGW.js → chunk-TMLCEPCD.js} +2 -2
- package/dist/{chunk-YT7A7DLY.js → chunk-UBOFYC6J.js} +7 -7
- package/dist/{chunk-GONDQ27X.js → chunk-UXSF7IFD.js} +3 -3
- package/dist/{chunk-I2GBBIDI.js → chunk-W2ARIOAZ.js} +43 -27
- package/dist/chunk-W2ARIOAZ.js.map +1 -0
- package/dist/{chunk-N7A5EXJZ.js → chunk-XRW4N23F.js} +4 -4
- package/dist/{chunk-NYJCBQL5.js → chunk-XZUGRTSV.js} +2 -2
- package/dist/{chunk-A2XMQSWI.js → chunk-YXLG7Q6Q.js} +3 -3
- package/dist/{chunk-HJYI52HM.js → chunk-YZTIYDWU.js} +2 -2
- package/dist/{chunk-WXFVJPZD.js → chunk-ZMFDMALH.js} +2 -2
- package/dist/{chunk-RA2J3TWG.js → chunk-ZNZGBUV6.js} +11 -9
- package/dist/chunk-ZNZGBUV6.js.map +1 -0
- package/dist/{cli-MUYFTWWB.js → cli-GGNOQQEB.js} +28 -28
- package/dist/{cli-MUYFTWWB.js.map → cli-GGNOQQEB.js.map} +1 -1
- package/dist/{config-IIRRO3XC.js → config-XUUFICXK.js} +8 -8
- package/dist/{doctor-KGHM2CAC.js → doctor-3LGF6CWI.js} +16 -16
- package/dist/{fund-DOWIT3JT.js → fund-3URFMBMN.js} +9 -9
- package/dist/{hook-command-RDT754KQ.js → hook-command-GMIDXVFK.js} +28 -10
- package/dist/{hook-command-RDT754KQ.js.map → hook-command-GMIDXVFK.js.map} +1 -1
- package/dist/index.js +3 -3
- package/dist/{install-BYQUMYBN.js → install-FRTG4KHF.js} +11 -11
- package/dist/{install-identity-KTQPYVAO.js → install-identity-WNXSYP6N.js} +6 -6
- package/dist/{install-wallet-T737X74E.js → install-wallet-MXLJJP3N.js} +9 -9
- package/dist/{mcp-ZKOTURQN.js → mcp-O2WJ3QBW.js} +23 -33
- package/dist/{mcp-ZKOTURQN.js.map → mcp-O2WJ3QBW.js.map} +1 -1
- package/dist/{pay-LZPU2HUT.js → pay-43WUYTW5.js} +11 -11
- package/dist/{payments-26NVMFR2.js → payments-7UTMMTIO.js} +6 -6
- package/dist/{send-4RUBQQKP.js → send-ALHG2RXT.js} +8 -8
- package/dist/{status-CEHZKHBU.js → status-CFPNHB6R.js} +5 -5
- package/dist/{status-line-QRAO3Y2E.js → status-line-FJ6N7MKJ.js} +4 -4
- package/dist/{status-line-wiring-7D2CSV3K.js → status-line-wiring-GXFNXHPE.js} +4 -4
- package/dist/{uninstall-VR44B4KD.js → uninstall-5P2GFYBY.js} +11 -11
- package/dist/{update-SOYQLDBF.js → update-QJ5YHJ7I.js} +5 -5
- package/dist/{wallet-IB2EFAUP.js → wallet-6OJPGNEV.js} +8 -8
- package/docs/agent-permissions.md +5 -5
- package/docs/safety-model.md +10 -23
- package/package.json +10 -8
- package/dist/chunk-HTC4VJFT.js.map +0 -1
- package/dist/chunk-I2GBBIDI.js.map +0 -1
- package/dist/chunk-RA2J3TWG.js.map +0 -1
- package/dist/chunk-Y3LKUXZA.js.map +0 -1
- package/dist/tenjin-daemon.mjs +0 -20601
- package/dist/tenjin-shim.mjs +0 -251
- package/dist/tenjin-vitest-reporter.mjs +0 -49
- /package/dist/{chunk-F4IJQBGP.js.map → chunk-FFL5M5BC.js.map} +0 -0
- /package/dist/{chunk-DHCOGDJB.js.map → chunk-GPLSNGKX.js.map} +0 -0
- /package/dist/{chunk-K63HPLYT.js.map → chunk-IIE65SJC.js.map} +0 -0
- /package/dist/{chunk-2RMXTNLT.js.map → chunk-KC24CYGV.js.map} +0 -0
- /package/dist/{chunk-XBYTP4SP.js.map → chunk-NSDZESRS.js.map} +0 -0
- /package/dist/{chunk-UGLTSPXQ.js.map → chunk-O2WN732M.js.map} +0 -0
- /package/dist/{chunk-3IOS6YG6.js.map → chunk-RCJ64OXH.js.map} +0 -0
- /package/dist/{chunk-6O6DFYF3.js.map → chunk-SQSKVKX6.js.map} +0 -0
- /package/dist/{chunk-UHEMZEGW.js.map → chunk-TMLCEPCD.js.map} +0 -0
- /package/dist/{chunk-YT7A7DLY.js.map → chunk-UBOFYC6J.js.map} +0 -0
- /package/dist/{chunk-GONDQ27X.js.map → chunk-UXSF7IFD.js.map} +0 -0
- /package/dist/{chunk-N7A5EXJZ.js.map → chunk-XRW4N23F.js.map} +0 -0
- /package/dist/{chunk-NYJCBQL5.js.map → chunk-XZUGRTSV.js.map} +0 -0
- /package/dist/{chunk-A2XMQSWI.js.map → chunk-YXLG7Q6Q.js.map} +0 -0
- /package/dist/{chunk-HJYI52HM.js.map → chunk-YZTIYDWU.js.map} +0 -0
- /package/dist/{chunk-WXFVJPZD.js.map → chunk-ZMFDMALH.js.map} +0 -0
- /package/dist/{config-IIRRO3XC.js.map → config-XUUFICXK.js.map} +0 -0
- /package/dist/{doctor-KGHM2CAC.js.map → doctor-3LGF6CWI.js.map} +0 -0
- /package/dist/{fund-DOWIT3JT.js.map → fund-3URFMBMN.js.map} +0 -0
- /package/dist/{install-BYQUMYBN.js.map → install-FRTG4KHF.js.map} +0 -0
- /package/dist/{install-identity-KTQPYVAO.js.map → install-identity-WNXSYP6N.js.map} +0 -0
- /package/dist/{install-wallet-T737X74E.js.map → install-wallet-MXLJJP3N.js.map} +0 -0
- /package/dist/{pay-LZPU2HUT.js.map → pay-43WUYTW5.js.map} +0 -0
- /package/dist/{payments-26NVMFR2.js.map → payments-7UTMMTIO.js.map} +0 -0
- /package/dist/{send-4RUBQQKP.js.map → send-ALHG2RXT.js.map} +0 -0
- /package/dist/{status-CEHZKHBU.js.map → status-CFPNHB6R.js.map} +0 -0
- /package/dist/{status-line-QRAO3Y2E.js.map → status-line-FJ6N7MKJ.js.map} +0 -0
- /package/dist/{status-line-wiring-7D2CSV3K.js.map → status-line-wiring-GXFNXHPE.js.map} +0 -0
- /package/dist/{uninstall-VR44B4KD.js.map → uninstall-5P2GFYBY.js.map} +0 -0
- /package/dist/{update-SOYQLDBF.js.map → update-QJ5YHJ7I.js.map} +0 -0
- /package/dist/{wallet-IB2EFAUP.js.map → wallet-6OJPGNEV.js.map} +0 -0
package/NOTICE.md
CHANGED
|
@@ -43,7 +43,7 @@ BlockRun MCP is licensed under the MIT License:
|
|
|
43
43
|
|
|
44
44
|
## gitleaks
|
|
45
45
|
|
|
46
|
-
The provider secret-token shape patterns in the
|
|
46
|
+
The provider secret-token shape patterns in the CLI's secret redaction rules are
|
|
47
47
|
adapted from the [gitleaks](https://github.com/gitleaks/gitleaks) ruleset (MIT),
|
|
48
48
|
by Zachary Rice: AWS access keys, GitHub classic and fine-grained tokens,
|
|
49
49
|
Slack/Stripe/npm/Anthropic/OpenAI/Google/Supabase/Twilio/SendGrid/Hugging Face
|
package/README.md
CHANGED
|
@@ -5,12 +5,7 @@
|
|
|
5
5
|
</picture>
|
|
6
6
|
</p>
|
|
7
7
|
|
|
8
|
-
<h3 align="center">The tool router for coding agents.</h3>
|
|
9
|
-
|
|
10
|
-
<p align="center">
|
|
11
|
-
Give your agent superpowers once. Tenjin hands it the right tool when it helps, and you keep working like before.<br>
|
|
12
|
-
No API keys. No pile of MCP servers. No rules to write.
|
|
13
|
-
</p>
|
|
8
|
+
<h3 align="center">The tool router for coding agents. Tenjin picks the right tool when your agent needs one, and one wallet pays for every call.</h3>
|
|
14
9
|
|
|
15
10
|
<p align="center">
|
|
16
11
|
<a href="https://www.npmjs.com/package/tenjin-cli"><img src="https://img.shields.io/npm/v/tenjin-cli?color=C85A3B&label=npm" alt="npm version"></a>
|
|
@@ -91,7 +86,7 @@ The router picks from a catalog we curate and maintain. When nothing in it fits,
|
|
|
91
86
|
| **X posts** · [glim](https://glim.sh) | Posts matching a search, or one post with its thread | $0.005 |
|
|
92
87
|
| **Reddit** · [glim](https://glim.sh) | Posts matching a search, or one thread with its comments | $0.01 / $0.005 |
|
|
93
88
|
|
|
94
|
-
|
|
89
|
+
Every tool, including the Tenjin list, with current prices: [tenjin.sh/tools](https://tenjin.sh/tools). More are added by demand: [tell us what you want](#request-a-tool).
|
|
95
90
|
|
|
96
91
|
### Tenjin list and experimental Bazaar
|
|
97
92
|
|
|
@@ -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-RCJ64OXH.js";
|
|
6
6
|
import {
|
|
7
7
|
external_exports
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-P22ZWXFX.js";
|
|
9
9
|
|
|
10
10
|
// src/router/decision.ts
|
|
11
11
|
var ROUTER_PATH = "/api/x402-router";
|
|
@@ -142,12 +142,11 @@ var ToolDecisionSchema = external_exports.discriminatedUnion("action", [
|
|
|
142
142
|
}),
|
|
143
143
|
/**
|
|
144
144
|
* A query with no id, answered with the spec of the service the server
|
|
145
|
-
* picked under a fresh `id`: kept like a hook's
|
|
146
|
-
*
|
|
147
|
-
*
|
|
148
|
-
*
|
|
149
|
-
*
|
|
150
|
-
* `request({id, input: {...}})` with the required fields, or the bound one.
|
|
145
|
+
* picked under a fresh `id`: kept like a hook's, and never run in the same
|
|
146
|
+
* call. `hint` is the line, with the skeleton of the next call:
|
|
147
|
+
* `request({id, input: {...}})` with the required fields. `input` is what a
|
|
148
|
+
* router from before the binder's removal still sends on a bound pick: it
|
|
149
|
+
* is accepted so that answer parses, and never read, so it never runs.
|
|
151
150
|
*/
|
|
152
151
|
external_exports.strictObject({
|
|
153
152
|
action: external_exports.literal("spec"),
|
|
@@ -191,7 +190,6 @@ function buildToolBody(request) {
|
|
|
191
190
|
schemaVersion: 1,
|
|
192
191
|
...request.query !== void 0 ? { query: request.query } : {},
|
|
193
192
|
...request.id !== void 0 ? { id: request.id } : {},
|
|
194
|
-
...request.input !== void 0 ? { input: request.input } : {},
|
|
195
193
|
...request.gateHint !== void 0 ? { gateHint: request.gateHint } : {},
|
|
196
194
|
...request.accepts !== void 0 ? { accepts: [...request.accepts] } : {}
|
|
197
195
|
};
|
|
@@ -208,7 +206,6 @@ async function requestDecision(kind, request, deps) {
|
|
|
208
206
|
}) : buildToolBody({
|
|
209
207
|
...request.query !== void 0 ? { query: request.query } : {},
|
|
210
208
|
...request.id !== void 0 ? { id: request.id } : {},
|
|
211
|
-
...request.input !== void 0 ? { input: request.input } : {},
|
|
212
209
|
...request.gateHint !== void 0 ? { gateHint: request.gateHint } : {},
|
|
213
210
|
accepts: acceptsFor(deps.acceptsBazaar === true)
|
|
214
211
|
}),
|
|
@@ -275,4 +272,4 @@ export {
|
|
|
275
272
|
requestDecision,
|
|
276
273
|
reportSpecOutcome
|
|
277
274
|
};
|
|
278
|
-
//# sourceMappingURL=chunk-
|
|
275
|
+
//# sourceMappingURL=chunk-EP5P2STS.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 * The bounded packet travels with the hook request and the backend keeps it\n * against the decision id until that id expires. What this client keeps is\n * each offer's spec, by its id (`specs.ts`).\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 /** The fields the result promises (type, properties, items, required). The\n * agent is handed only these; the whole body is saved to a file. */\n outputSchema: 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, and never run in the same\n * call. `hint` is the line, with the skeleton of the next call:\n * `request({id, input: {...}})` with the required fields. `input` is what a\n * router from before the binder's removal still sends on a bound pick: it\n * is accepted so that answer parses, and never read, so it never runs.\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 offer the query is for,\n * sent only for an offer with no spec kept; `gateHint` is evidence, never\n * authority. */\nexport function buildToolBody(request: {\n query?: string;\n id?: string;\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.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 and answers with\n * each offered service's spec. The tool sends `{ query }`, which the backend\n * answers with the spec of the service its gate picks, or `{ query, id }` for\n * the free docs offer, which has no spec and is bound from the query. Every\n * provider call is built here, from a spec, or for the docs lookup by the\n * backend from the query.\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; 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 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.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":";;;;;;;;;;AAsBO,IAAM,cAAc;AAO3B,IAAM,gBAAgB,iBA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B,QAAQ,EAAE,QAAQ;AAC9F,MAAI,SAAS,SAAS,OAAO,SAAS,UAAU,KAAK;AACnD,UAAM,QAAQ,QAAQ,SAAS,IAAI;AACnC,WAAO;AAAA,MACL,QAAQ;AAAA;AAAA;AAAA,MAGR,QACE,UAAU,OACN,gCAAgC,SAAS,MAAM,MAC/C,gCAAgC,SAAS,MAAM,KAAK,MAAM,IAAI,MAAM,MAAM,OAAO;AAAA,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":[]}
|
|
@@ -27,7 +27,7 @@ import {
|
|
|
27
27
|
} from "./chunk-EGELTSPU.js";
|
|
28
28
|
import {
|
|
29
29
|
USDC_ADDRESS
|
|
30
|
-
} from "./chunk-
|
|
30
|
+
} from "./chunk-P22ZWXFX.js";
|
|
31
31
|
|
|
32
32
|
// node_modules/.pnpm/viem@2.55.2_typescript@6.0.3_zod@4.4.3/node_modules/viem/_esm/op-stack/contracts.js
|
|
33
33
|
var contracts = {
|
|
@@ -318,4 +318,4 @@ export {
|
|
|
318
318
|
prepareUsdcSend,
|
|
319
319
|
broadcastUsdcSend
|
|
320
320
|
};
|
|
321
|
-
//# sourceMappingURL=chunk-
|
|
321
|
+
//# sourceMappingURL=chunk-FFL5M5BC.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createRequire as __tenjinCreateRequire } from 'node:module'; const require = __tenjinCreateRequire(import.meta.url);
|
|
2
2
|
import {
|
|
3
3
|
createLocalSpendAuthorizer
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-XZUGRTSV.js";
|
|
5
5
|
import {
|
|
6
6
|
hashAuthorization,
|
|
7
7
|
hashMessage,
|
|
@@ -45,13 +45,13 @@ import {
|
|
|
45
45
|
} from "./chunk-BPMWXTFX.js";
|
|
46
46
|
import {
|
|
47
47
|
emitNotice
|
|
48
|
-
} from "./chunk-
|
|
48
|
+
} from "./chunk-O2WN732M.js";
|
|
49
49
|
import {
|
|
50
50
|
hasCode
|
|
51
51
|
} from "./chunk-2I4QTOLB.js";
|
|
52
52
|
import {
|
|
53
53
|
external_exports
|
|
54
|
-
} from "./chunk-
|
|
54
|
+
} from "./chunk-P22ZWXFX.js";
|
|
55
55
|
import {
|
|
56
56
|
CliError,
|
|
57
57
|
fsyncDir,
|
|
@@ -1678,4 +1678,4 @@ export {
|
|
|
1678
1678
|
@noble/ciphers/esm/utils.js:
|
|
1679
1679
|
(*! noble-ciphers - MIT License (c) 2023 Paul Miller (paulmillr.com) *)
|
|
1680
1680
|
*/
|
|
1681
|
-
//# sourceMappingURL=chunk-
|
|
1681
|
+
//# sourceMappingURL=chunk-GPLSNGKX.js.map
|
|
@@ -5,30 +5,38 @@ import {
|
|
|
5
5
|
} from "./chunk-TGLKKLQG.js";
|
|
6
6
|
import {
|
|
7
7
|
paint
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-O2WN732M.js";
|
|
9
9
|
import {
|
|
10
|
+
CLI_SKILL_NAMES,
|
|
10
11
|
RETIRED_SKILL_NAMES,
|
|
12
|
+
ROUTER_DEFAULTS,
|
|
13
|
+
SHIPPED_SKILL_FILES,
|
|
11
14
|
onPath,
|
|
12
15
|
persistRouterDefaults,
|
|
13
16
|
readSkillFile,
|
|
14
17
|
skillFrontmatterName,
|
|
15
18
|
skillsDirsFor
|
|
16
|
-
} from "./chunk-
|
|
19
|
+
} from "./chunk-W2ARIOAZ.js";
|
|
20
|
+
import {
|
|
21
|
+
askText,
|
|
22
|
+
selectOne
|
|
23
|
+
} from "./chunk-P7LABKCW.js";
|
|
17
24
|
import {
|
|
18
25
|
hasCode
|
|
19
26
|
} from "./chunk-2I4QTOLB.js";
|
|
20
27
|
import {
|
|
21
28
|
resolveContextSettings
|
|
22
|
-
} from "./chunk-
|
|
29
|
+
} from "./chunk-TMLCEPCD.js";
|
|
23
30
|
import {
|
|
31
|
+
parseUsdToAtomic,
|
|
24
32
|
toMoney
|
|
25
33
|
} from "./chunk-O2JYBOUO.js";
|
|
26
34
|
import {
|
|
27
35
|
loadRawConfig
|
|
28
|
-
} from "./chunk-
|
|
36
|
+
} from "./chunk-P22ZWXFX.js";
|
|
29
37
|
import {
|
|
30
38
|
ensureStatusLine
|
|
31
|
-
} from "./chunk-
|
|
39
|
+
} from "./chunk-YZTIYDWU.js";
|
|
32
40
|
import {
|
|
33
41
|
appendAllowlistRules,
|
|
34
42
|
claudeAdapter,
|
|
@@ -36,7 +44,7 @@ import {
|
|
|
36
44
|
inspectHooksFile,
|
|
37
45
|
ownsHookEntry,
|
|
38
46
|
writeHooks
|
|
39
|
-
} from "./chunk-
|
|
47
|
+
} from "./chunk-SQSKVKX6.js";
|
|
40
48
|
import {
|
|
41
49
|
CliError
|
|
42
50
|
} from "./chunk-JLEF5WHM.js";
|
|
@@ -51,7 +59,7 @@ import { promisify } from "node:util";
|
|
|
51
59
|
// src/lib/skill-placement.ts
|
|
52
60
|
import { lstatSync } from "node:fs";
|
|
53
61
|
import { readdir, rm, rmdir } from "node:fs/promises";
|
|
54
|
-
import { join } from "node:path";
|
|
62
|
+
import { dirname, join } from "node:path";
|
|
55
63
|
function isRealDirectory(path) {
|
|
56
64
|
try {
|
|
57
65
|
return lstatSync(path, { throwIfNoEntry: false })?.isDirectory() === true;
|
|
@@ -74,16 +82,27 @@ async function removeOwnedSkill(name, skillsDir) {
|
|
|
74
82
|
if (read.kind !== "ok" || skillFrontmatterName(read.bytes.toString("utf8")) !== name) {
|
|
75
83
|
return { changed: false };
|
|
76
84
|
}
|
|
85
|
+
const shipped = SHIPPED_SKILL_FILES[name] ?? [];
|
|
86
|
+
const subdirs = /* @__PURE__ */ new Set();
|
|
87
|
+
for (const rel of shipped) {
|
|
88
|
+
if (rel === "SKILL.md") continue;
|
|
89
|
+
const file = join(skillDir, rel);
|
|
90
|
+
if (!isRealDirectory(dirname(file))) continue;
|
|
91
|
+
subdirs.add(dirname(file));
|
|
92
|
+
if (lstatSync(file, { throwIfNoEntry: false })?.isFile() === true) await rm(file);
|
|
93
|
+
}
|
|
77
94
|
await rm(path, { force: true });
|
|
78
|
-
const
|
|
79
|
-
|
|
95
|
+
for (const dir of [...subdirs, skillDir].sort((a, b) => b.length - a.length)) {
|
|
96
|
+
const rest = await readdir(dir).catch(() => null);
|
|
97
|
+
if (rest !== null && rest.length === 0) await rmdir(dir).catch(() => void 0);
|
|
98
|
+
}
|
|
80
99
|
return { changed: true };
|
|
81
100
|
}
|
|
82
101
|
async function removeRetiredSkills(home, project) {
|
|
83
102
|
const removed = [];
|
|
84
103
|
const dirs = [...skillsDirsFor(home), ...project ? skillsDirsFor(project) : []];
|
|
85
104
|
for (const dir of new Set(dirs)) {
|
|
86
|
-
for (const name of RETIRED_SKILL_NAMES) {
|
|
105
|
+
for (const name of [...RETIRED_SKILL_NAMES, ...CLI_SKILL_NAMES]) {
|
|
87
106
|
if ((await removeOwnedSkill(name, dir)).changed) removed.push(join(dir, name));
|
|
88
107
|
}
|
|
89
108
|
}
|
|
@@ -156,7 +175,7 @@ async function runRouterInstall(args, ctx, deps = {}) {
|
|
|
156
175
|
fix: "Set HOME to your home directory (`export HOME=...`), then re-run `tenjin install`."
|
|
157
176
|
});
|
|
158
177
|
}
|
|
159
|
-
await loadRawConfig(ctx.dataDir);
|
|
178
|
+
const config = await loadRawConfig(ctx.dataDir);
|
|
160
179
|
const cwd = deps.cwd ?? process.cwd();
|
|
161
180
|
const project = args.project ?? (args.refresh === true && await inferRefreshProject(cwd, home, ctx.dataDir, deps.readMcpEntry ?? readMcpEntry));
|
|
162
181
|
const settingsPath = routerSettingsPath({
|
|
@@ -179,7 +198,10 @@ async function runRouterInstall(args, ctx, deps = {}) {
|
|
|
179
198
|
);
|
|
180
199
|
}
|
|
181
200
|
}
|
|
182
|
-
const
|
|
201
|
+
const humanOutput = ctx.flags.json === true ? false : deps.isInteractive ?? ctx.io.isTTY;
|
|
202
|
+
const canPrompt = humanOutput && (deps.isInteractive ?? Boolean(process.stdin.isTTY));
|
|
203
|
+
const limits = args.refresh !== true && canPrompt ? await approveLimits(config, deps) : void 0;
|
|
204
|
+
const spend = await persistRouterDefaults(ctx.dataDir, args.refresh === true, limits);
|
|
183
205
|
const removedKeysLines = spend.removed.length > 0 ? [
|
|
184
206
|
`Removed retired settings: ${spend.removed.join(", ")}. Automatic router limits remain in effect; manual pay always requires consent.`
|
|
185
207
|
] : [];
|
|
@@ -224,7 +246,7 @@ async function runRouterInstall(args, ctx, deps = {}) {
|
|
|
224
246
|
]
|
|
225
247
|
};
|
|
226
248
|
}
|
|
227
|
-
const { resolveWallet } = await import("./install-wallet-
|
|
249
|
+
const { resolveWallet } = await import("./install-wallet-MXLJJP3N.js");
|
|
228
250
|
const wallet = await resolveWallet(ctx, deps, args.noWallet === true ? "flag" : void 0, false);
|
|
229
251
|
const effective = await resolveContextSettings(ctx);
|
|
230
252
|
const data = {
|
|
@@ -254,6 +276,68 @@ async function runRouterInstall(args, ctx, deps = {}) {
|
|
|
254
276
|
]
|
|
255
277
|
};
|
|
256
278
|
}
|
|
279
|
+
async function approveLimits(config, deps) {
|
|
280
|
+
const shown = {
|
|
281
|
+
maxAutoSpend: config.maxAutoSpend ?? ROUTER_DEFAULTS.maxAutoSpend,
|
|
282
|
+
sessionBudget: config.sessionBudget ?? ROUTER_DEFAULTS.sessionBudget
|
|
283
|
+
};
|
|
284
|
+
const askCall = config.maxAutoSpend === void 0;
|
|
285
|
+
const askDay = config.sessionBudget === void 0;
|
|
286
|
+
if (!askCall && !askDay) return void 0;
|
|
287
|
+
const daily = shown.sessionBudget === "none" ? "no daily limit" : `$${toMoney(shown.sessionBudget).usd} a day`;
|
|
288
|
+
const choice = await (deps.promptLimits ?? promptLimits)(
|
|
289
|
+
`The router pays for tool calls without asking, up to:
|
|
290
|
+
$${toMoney(shown.maxAutoSpend).usd} a call, ${daily}`
|
|
291
|
+
);
|
|
292
|
+
if (choice === null) throw installCancelled();
|
|
293
|
+
if (choice === "approve") return shown;
|
|
294
|
+
const ask = deps.promptAmount ?? promptAmount;
|
|
295
|
+
return {
|
|
296
|
+
maxAutoSpend: askCall ? await askLimit(ask, "Most the router may pay for one call, in USD", "0.25", false) : shown.maxAutoSpend,
|
|
297
|
+
sessionBudget: askDay ? await askLimit(ask, "Most it may pay in a day, in USD, or none", "5", true) : shown.sessionBudget
|
|
298
|
+
};
|
|
299
|
+
}
|
|
300
|
+
async function askLimit(ask, question, placeholder, allowNone) {
|
|
301
|
+
let message = question;
|
|
302
|
+
for (; ; ) {
|
|
303
|
+
const answer = await ask(message, placeholder);
|
|
304
|
+
if (answer === null) throw installCancelled();
|
|
305
|
+
const parsed = parseLimit(answer, allowNone);
|
|
306
|
+
if (!("refusal" in parsed)) return parsed.value;
|
|
307
|
+
message = `${parsed.refusal} ${question}`;
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
function parseLimit(answer, allowNone) {
|
|
311
|
+
const trimmed = answer.trim();
|
|
312
|
+
if (allowNone && trimmed === "none") return { value: "none" };
|
|
313
|
+
let atomic;
|
|
314
|
+
try {
|
|
315
|
+
atomic = parseUsdToAtomic(trimmed);
|
|
316
|
+
} catch (err) {
|
|
317
|
+
if (err instanceof CliError) return { refusal: `${err.message}.` };
|
|
318
|
+
throw err;
|
|
319
|
+
}
|
|
320
|
+
if (atomic === "0") return { refusal: "The limit must be more than zero." };
|
|
321
|
+
return { value: atomic };
|
|
322
|
+
}
|
|
323
|
+
function installCancelled() {
|
|
324
|
+
return new CliError("REFUSED", "Install cancelled before anything was written.", {
|
|
325
|
+
fix: "Re-run `tenjin install` and choose the spend limits."
|
|
326
|
+
});
|
|
327
|
+
}
|
|
328
|
+
function promptLimits(message) {
|
|
329
|
+
return selectOne({
|
|
330
|
+
message,
|
|
331
|
+
choices: [
|
|
332
|
+
{ value: "approve", label: "Use these limits" },
|
|
333
|
+
{ value: "own", label: "Choose my own" }
|
|
334
|
+
],
|
|
335
|
+
initialValue: "approve"
|
|
336
|
+
});
|
|
337
|
+
}
|
|
338
|
+
function promptAmount(message, placeholder) {
|
|
339
|
+
return askText({ message, placeholder });
|
|
340
|
+
}
|
|
257
341
|
async function ensureAllowRule(path) {
|
|
258
342
|
const result = await appendAllowlistRules(path, [ALLOW_RULE]);
|
|
259
343
|
return {
|
|
@@ -448,4 +532,4 @@ export {
|
|
|
448
532
|
readMcpEntry,
|
|
449
533
|
statusLineProblems
|
|
450
534
|
};
|
|
451
|
-
//# sourceMappingURL=chunk-
|
|
535
|
+
//# sourceMappingURL=chunk-H5UR3GFJ.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/router/install.ts","../src/lib/skill-placement.ts"],"sourcesContent":["import { execFile } from 'node:child_process';\nimport { readFile, realpath } from 'node:fs/promises';\nimport { homedir } from 'node:os';\nimport { isAbsolute, join } from 'node:path';\nimport { promisify } from 'node:util';\nimport { claudeAdapter } from '../adapters/claude';\nimport { persistRouterDefaults, ROUTER_DEFAULTS, type RouterLimits } from '../commands/config';\nimport { askText, selectOne } from '../lib/clack';\nimport { CliError } from '../lib/errors';\nimport { appendAllowlistRules, claudeSettingsPath } from '../lib/harness-permissions';\nimport {\n inspectHooksFile,\n ownsHookEntry,\n pruneHooks,\n writeHooks,\n type HooksResult,\n} from '../lib/harness-hooks';\nimport { parseUsdToAtomic, toMoney } from '../lib/money';\nimport { paint } from '../lib/output';\nimport { resolveContextSettings } from '../lib/settings';\nimport type { SpendPolicy } from '../lib/policy';\nimport { removeRetiredSkills } from '../lib/skill-placement';\nimport { loadRawConfig, type PartialConfig } from '../lib/config';\nimport { onPath } from '../lib/skill-wiring';\nimport type { WalletDeps, WalletOutcome } from '../commands/install-wallet';\nimport type { CommandContext, CommandResult } from '../context';\nimport { MCP_SERVER_NAME, REQUEST_TOOL } from './names';\nimport { ensureStatusLine, type StatusLineMode, type StatusLineResult } from './status-line-wiring';\n\n/**\n * `tenjin install` for the router product: seven hook entries, one MCP server,\n * one permission rule, the spend defaults, and a wallet when there is none.\n *\n * WHAT IT WRITES IS WHAT IT SAYS. There is no skill to materialize and no\n * daemon to start: the hooks are plain command lines, the tool lives in an MCP\n * server the harness starts per session, and every other key in the settings\n * file is preserved byte for byte. The one process a hook starts is the free\n * docs fetch beside a search, which exits within `PREFETCH_TIMEOUT_MS`.\n */\n\nconst exec = promisify(execFile);\n\n/**\n * The harness's kill budget for each hook entry, and the number every other\n * wait inside the hook is cut from: 1 s of stdin plus 3.5 s of gate, with\n * 500 ms left for node's boot and the transcript read (`wire.test.ts` pins it).\n * Raised from 3 s because a gate abort costs the turn its hint silently.\n *\n * A machine carrying the old number is converged by the writer, not by the\n * user: the entries are ours by marker, so `install`, `install --refresh` and\n * the refresh `tenjin update` spawns all rewrite them in place.\n */\nexport const HOOK_TIMEOUT_SECONDS = 5;\n/**\n * The after-call entries' kill budget, longer than the rest for the one wait\n * any hook makes: a search the pre-call arm is fetching free docs for waits up\n * to `AUGMENT_WAIT_MS` for them, and when none came back and the search was\n * short, the gate is asked after that (`wire.test.ts` pins the sum). Every\n * other after-call event returns as fast as before, so the number is a\n * ceiling, not a cost. The pre-call entry stays at\n * {@link HOOK_TIMEOUT_SECONDS}: it starts that fetch and never waits for it.\n */\nexport const AFTER_CALL_TIMEOUT_SECONDS = 15;\nexport { MCP_SERVER_NAME };\nexport const ALLOW_RULE = REQUEST_TOOL;\n/**\n * The MCP registration follows the SAME SCOPE the hook entries do. A\n * `--project` install that wrote its hooks into the project and then registered\n * the server at user scope would reach into `~/.claude.json` on a run whose\n * whole point is to touch this project and nothing else, and `tenjin uninstall\n * --project` would leave that behind.\n *\n * Project scope writes `<project>/.mcp.json`, so the registration lives beside\n * the settings file that names the hooks and travels with the repository.\n */\nexport function mcpScope(project: boolean | undefined): 'user' | 'project' {\n return project === true ? 'project' : 'user';\n}\n\nexport function mcpAddCommand(project?: boolean): string {\n return `claude mcp add ${MCP_SERVER_NAME} -s ${mcpScope(project)} -- tenjin mcp`;\n}\n\nexport function mcpRemoveCommand(project?: boolean): string {\n return `claude mcp remove ${MCP_SERVER_NAME} -s ${mcpScope(project)}`;\n}\n\n/** The user-scope form, kept as the name the docs and the tests already use. */\nexport const MCP_ADD_COMMAND = mcpAddCommand();\n\n/**\n * Which settings file this machine's router wiring lives in, spelled once so\n * `install`, `uninstall` and `doctor` can never disagree about where to look.\n * A doctor reading the home file on a `--project` install reported a correctly\n * wired machine as unwired and exited 3.\n */\nexport function routerSettingsPath(\n opts: { project?: boolean; homeDir?: string; cwd?: string } = {},\n): string {\n if (opts.project === true) return join(opts.cwd ?? process.cwd(), '.claude', 'settings.json');\n return claudeSettingsPath(opts.homeDir ?? homedir());\n}\n\n/** The subagent tool, under its current name and its older one. */\nexport const DELEGATION_MATCHER = 'Agent|Task';\n\n/** The native tools both native arms watch. */\nexport const NATIVE_MATCHER = 'WebSearch|WebFetch';\n\n/** The host's question to the user, watched before it is asked and after. */\nexport const ASK_MATCHER = 'AskUserQuestion';\n\n/**\n * The seven entries, spelled once so `uninstall`, `doctor` and the tests read\n * the same list. The native tools are routed twice over one lookup: BEFORE the\n * call, as every release has, with a line pointing to a paid lookup when one\n * fits; and AFTER it, only when it came back short and nothing was said before,\n * or to add the free docs the pre-call arm fetched to a search's results. A\n * failed call fires PostToolUseFailure rather than PostToolUse, so the second\n * takes both. The host's question to the user is routed the same two ways:\n * before it is asked, when a service could stand in for what it asks for, and\n * after, with the user's answers read as their own words.\n */\nexport function routerHookPlan(): unknown[] {\n const handler = (command: string, timeout = HOOK_TIMEOUT_SECONDS) => [\n { type: 'command', command, timeout },\n ];\n const afterCall = () => handler('tenjin hook shortfall', AFTER_CALL_TIMEOUT_SECONDS);\n return [\n { event: 'UserPromptSubmit', hooks: handler('tenjin hook prompt') },\n { event: 'PreToolUse', matcher: NATIVE_MATCHER, hooks: handler('tenjin hook native') },\n { event: 'PreToolUse', matcher: DELEGATION_MATCHER, hooks: handler('tenjin hook agent') },\n { event: 'PostToolUse', matcher: NATIVE_MATCHER, hooks: afterCall() },\n { event: 'PostToolUseFailure', matcher: NATIVE_MATCHER, hooks: afterCall() },\n { event: 'PreToolUse', matcher: ASK_MATCHER, hooks: handler('tenjin hook ask') },\n { event: 'PostToolUse', matcher: ASK_MATCHER, hooks: handler('tenjin hook answer') },\n ];\n}\n\nexport const DISCLOSURE: readonly string[] = [\n \"What leaves this machine: the bounded text of each prompt, each native search query or URL (and, when one came back short, its status, size or error), each task handed to a subagent, and each question your assistant asks you with your answers, sent to Tenjin for the free routing gate, beside this session's id. When the gate offers free library docs for a search, that search query also goes to Tenjin's docs lookup, which asks Context7.\",\n 'What is kept when a lookup is paid: the capability chosen, a hash of the contract, a hash of the arguments, and your wallet address. No prompt text, no arguments, no hint text.',\n 'What never leaves: your private key. It is decrypted in this CLI to sign, and never sent anywhere.',\n];\n\nexport interface RouterInstallArgs {\n /** Write into this project's `.claude/settings.json` instead of your home one. */\n project?: boolean;\n /**\n * Bring the entries this machine ALREADY has up to the running build, and\n * add nothing: no config write, no MCP registration, and a refusal when\n * nothing of ours is here. `tenjin update` spawns exactly this after it swaps\n * the binary, so the flag's name and meaning are a compatibility contract.\n */\n refresh?: boolean;\n /**\n * What to do about Claude Code's `statusLine`. Absent is the default path:\n * write ours when the key is free, and print the composition line when it is\n * not. `compose` wraps the status line already there and appends ours;\n * `skip` leaves the key alone entirely.\n */\n statusLine?: StatusLineMode;\n /** Create no wallet, for CI and scripted machines. */\n noWallet?: boolean;\n}\n\nexport interface RouterInstallDeps extends WalletDeps {\n homeDir?: string;\n cwd?: string;\n env?: NodeJS.ProcessEnv;\n /** PATH probe for the `claude` binary. */\n which?: (bin: string) => boolean;\n /** Runs `claude mcp add`; tests inject it so no binary is spawned. The scope\n * and the working directory are passed, because project scope is decided by\n * where the command runs as much as by the flag. */\n registerMcp?: (\n command: string,\n opts: { scope: 'user' | 'project'; cwd: string },\n ) => Promise<void>;\n /** Reads the registration the scope's own file holds; tests inject it. */\n readMcpEntry?: (\n scope: 'user' | 'project',\n cwd: string,\n home: string,\n ) => Promise<{ found: boolean; state: McpEntryState }>;\n /** Whether a person can answer the spend-limit question (a TTY on stdout and\n * stdin, no `--json`); injected in tests. */\n isInteractive?: boolean;\n /** The spend-limit selector; defaults to the clack list. */\n promptLimits?: (message: string) => Promise<LimitsChoice | null>;\n /** One amount question; defaults to the clack text input. */\n promptAmount?: (message: string, placeholder: string) => Promise<string | null>;\n}\n\nexport type LimitsChoice = 'approve' | 'own';\n\nexport interface McpRegistration {\n name: string;\n registered: boolean;\n /** Which scope it went to, following the hook entries rather than the flag\n * being read twice. `project` writes `<project>/.mcp.json`. */\n scope: 'user' | 'project';\n /** The command to run by hand, when this run could not. */\n command: string;\n /**\n * WHAT THIS RUN ACTUALLY DID, which `registered` alone cannot say:\n * `already-registered` (the scope's file already launches `tenjin mcp`, and\n * nothing was spawned), `added`, `repaired` (a same-name entry launching\n * something else was removed and re-added, which only `uninstall` does now),\n * `unrepaired` (a registration this run KNOWS is wrong or unreadable and will\n * not touch) or `unavailable` (it is simply not there and this machine could\n * not add it, e.g. no `claude` on PATH). A refresh fails on `unrepaired`,\n * because reporting convergence over a registration that launches something\n * else is the thing to avoid; it still only prints the manual command for\n * `unavailable`.\n */\n reconciled: 'already-registered' | 'added' | 'repaired' | 'unrepaired' | 'unavailable';\n reason?: string;\n}\n\nasync function inferRefreshProject(\n cwd: string,\n home: string,\n dataDir: string,\n readRegistration: typeof readMcpEntry,\n): Promise<boolean> {\n const hooks = await probeOurEntries(routerSettingsPath({ project: true, cwd }), dataDir);\n if (hooks.state !== 'present') return false;\n const [cwdPath, homePath] = await Promise.all([\n realpath(cwd),\n realpath(home).catch((err: NodeJS.ErrnoException) => {\n // A missing home cannot alias this existing project. Do not require it\n // to exist (or create it) just to refresh the project's own settings.\n if (err.code === 'ENOENT' || err.code === 'ENOTDIR') return null;\n throw err;\n }),\n ]);\n if (cwdPath !== homePath) return true;\n\n // Home shares one hooks file between scopes. Preserve a project-only install,\n // but prefer user scope when both registrations exist (including alpha.18's\n // accidental duplicate). With neither registration, the default is user.\n // Unreadable/conflicting entries stay in their scope so reconciliation refuses\n // them instead of silently creating a registration in the other scope.\n const user = await readRegistration('user', cwd, home);\n if (user.state !== 'absent') return false;\n const project = await readRegistration('project', cwd, home);\n return project.state !== 'absent';\n}\n\nexport async function runRouterInstall(\n args: RouterInstallArgs,\n ctx: CommandContext,\n deps: RouterInstallDeps = {},\n): Promise<CommandResult> {\n const env = deps.env ?? process.env;\n const home = deps.homeDir ?? homedir();\n if (!isAbsolute(home)) {\n throw new CliError('INTERNAL', 'The home directory is not an absolute path.', {\n fix: 'Set HOME to your home directory (`export HOME=...`), then re-run `tenjin install`.',\n });\n }\n const config = await loadRawConfig(ctx.dataDir); // Validate before any install writes; retired keys remain readable.\n const cwd = deps.cwd ?? process.cwd();\n // `tenjin update` runs from home, where the hooks file cannot prove scope.\n // An explicit --project still wins, including for a project rooted at home.\n const project =\n args.project ??\n (args.refresh === true &&\n (await inferRefreshProject(cwd, home, ctx.dataDir, deps.readMcpEntry ?? readMcpEntry)));\n const settingsPath = routerSettingsPath({\n ...(project ? { project: true } : {}),\n homeDir: home,\n cwd,\n });\n\n if (args.refresh === true) {\n const probe = await probeOurEntries(settingsPath, ctx.dataDir);\n // An unreadable file is not an absence, and telling someone to install over\n // it is the wrong instruction: the writer would refuse it too.\n if (probe.state === 'unreadable') {\n throw new CliError('CONFIG_INVALID', `Could not inspect ${settingsPath}: ${probe.reason}`, {\n fix: `Fix ${settingsPath}, then re-run: tenjin update`,\n });\n }\n if (probe.state === 'absent') {\n throw new CliError(\n 'REFUSED',\n `Nothing to refresh in ${settingsPath}: no Tenjin hook entries are registered here.`,\n { fix: 'Run `tenjin install` to set this machine up.' },\n );\n }\n }\n // The shelf install's gate: a refresh, `--json`, or a run with no terminal on\n // either side asks nothing and writes the defaults only where the file is silent.\n const humanOutput = ctx.flags.json === true ? false : (deps.isInteractive ?? ctx.io.isTTY);\n const canPrompt = humanOutput && (deps.isInteractive ?? Boolean(process.stdin.isTTY));\n const limits = args.refresh !== true && canPrompt ? await approveLimits(config, deps) : undefined;\n const spend = await persistRouterDefaults(ctx.dataDir, args.refresh === true, limits);\n const removedKeysLines =\n spend.removed.length > 0\n ? [\n `Removed retired settings: ${spend.removed.join(', ')}. Automatic router limits remain in effect; manual pay always requires consent.`,\n ]\n : [];\n const removedSkills = await removeRetiredSkills(home, project ? cwd : undefined);\n const hooks = await writeHooks({\n adapter: claudeAdapter,\n homeDir: home,\n dataDir: ctx.dataDir,\n env,\n plan: routerHookPlan(),\n settingsPath,\n });\n const permissions = await ensureAllowRule(settingsPath);\n const statusLine = await ensureStatusLine(settingsPath, {\n ...(args.statusLine !== undefined ? { mode: args.statusLine } : {}),\n ...(args.refresh === true ? { refreshOnly: true } : {}),\n });\n const mcp = await registerMcpServer(deps, env, project, cwd, home);\n if (args.refresh === true) {\n // The SAME writers, minus the one that decides anything: the entries are\n // rewritten in place by their ownership marker so an upgrade never\n // duplicates them, the rule and the registration are re-checked because a\n // new version can change either. Config cleanup only removes retired keys;\n // the wallet, current limits and `spend.json` are unchanged. Widening an agent's spend policy\n // during an unattended upgrade is not a convergence.\n // RECONCILED, not re-added: `claude mcp add` exits 1 on an existing entry,\n // so the registration is read first and only written when it is missing or\n // wrong (see {@link registerMcpServer}).\n // A registration this run KNOWS is wrong and could not repair is not a\n // converged install, and `tenjin update` reporting success over it is how\n // a machine keeps a stale `x402` server across upgrade after upgrade.\n if (mcp.reconciled === 'unrepaired') {\n throw new CliError(\n 'REFUSED',\n `The ${MCP_SERVER_NAME} MCP registration (${mcpScope(project)} scope) is not the router's and this run could not repair it: ${mcp.reason ?? 'unknown reason'}.`,\n { fix: `Run: ${mcp.command}`, details: { settingsPath, hooks, permissions, mcp } },\n );\n }\n return {\n data: {\n settingsPath,\n hooks,\n permissions,\n statusLine,\n mcp,\n refresh: true,\n spend,\n removedSkills,\n scope: mcpScope(project),\n },\n humanLines: [\n ...refreshLines(ctx, problems(ctx, hooks, permissions, statusLine, mcp)),\n ...removedKeysLines,\n ],\n };\n }\n // The shelf install's wallet step, unchanged except that it never asks: a\n // lookup cannot be paid without a wallet, so install makes one. A failure is\n // reported, never fatal; everything above is useful without it.\n const { resolveWallet } = await import('../commands/install-wallet');\n const wallet = await resolveWallet(ctx, deps, args.noWallet === true ? 'flag' : undefined, false);\n // Read back AFTER the write: a machine that already carried its own caps\n // keeps them, and a readout quoting the defaults would describe limits this\n // run did not set.\n const effective = await resolveContextSettings(ctx);\n\n const data = {\n settingsPath,\n hooks,\n permissions,\n statusLine,\n spend: { ...spend, effective: effectiveLimits(effective.policy) },\n mcp,\n wallet,\n disclosure: DISCLOSURE,\n removedSkills,\n };\n return {\n data,\n humanLines: [\n ...lines(ctx, {\n project,\n hooks,\n permissions,\n statusLine,\n mcp,\n wallet,\n policy: effective.policy,\n }),\n ...removedKeysLines,\n ],\n };\n}\n\n/**\n * The one question install asks, before anything is written: approve the\n * automatic spend limits or set your own. Only a key the file does not already\n * name is asked for, because the write fills absent keys and keeps the rest.\n * Cancelling at any step writes nothing.\n */\nasync function approveLimits(\n config: PartialConfig,\n deps: RouterInstallDeps,\n): Promise<RouterLimits | undefined> {\n const shown: RouterLimits = {\n maxAutoSpend: config.maxAutoSpend ?? ROUTER_DEFAULTS.maxAutoSpend,\n sessionBudget: config.sessionBudget ?? ROUTER_DEFAULTS.sessionBudget,\n };\n const askCall = config.maxAutoSpend === undefined;\n const askDay = config.sessionBudget === undefined;\n if (!askCall && !askDay) return undefined;\n const daily =\n shown.sessionBudget === 'none'\n ? 'no daily limit'\n : `$${toMoney(shown.sessionBudget).usd} a day`;\n const choice = await (deps.promptLimits ?? promptLimits)(\n `The router pays for tool calls without asking, up to:\\n $${toMoney(shown.maxAutoSpend).usd} a call, ${daily}`,\n );\n if (choice === null) throw installCancelled();\n if (choice === 'approve') return shown;\n const ask = deps.promptAmount ?? promptAmount;\n return {\n maxAutoSpend: askCall\n ? await askLimit(ask, 'Most the router may pay for one call, in USD', '0.25', false)\n : shown.maxAutoSpend,\n sessionBudget: askDay\n ? await askLimit(ask, 'Most it may pay in a day, in USD, or none', '5', true)\n : shown.sessionBudget,\n };\n}\n\n/** Asks until the answer is a positive amount (or `none` for the daily limit). */\nasync function askLimit(\n ask: NonNullable<RouterInstallDeps['promptAmount']>,\n question: string,\n placeholder: string,\n allowNone: boolean,\n): Promise<string> {\n let message = question;\n for (;;) {\n const answer = await ask(message, placeholder);\n if (answer === null) throw installCancelled();\n const parsed = parseLimit(answer, allowNone);\n if (!('refusal' in parsed)) return parsed.value;\n message = `${parsed.refusal} ${question}`;\n }\n}\n\n/** Zero is refused: a zero per-call limit means the router can never pay, and\n * `router.enabled false` is how to turn it off. */\nfunction parseLimit(answer: string, allowNone: boolean): { value: string } | { refusal: string } {\n const trimmed = answer.trim();\n if (allowNone && trimmed === 'none') return { value: 'none' };\n let atomic: string;\n try {\n atomic = parseUsdToAtomic(trimmed);\n } catch (err) {\n if (err instanceof CliError) return { refusal: `${err.message}.` };\n throw err;\n }\n if (atomic === '0') return { refusal: 'The limit must be more than zero.' };\n return { value: atomic };\n}\n\nfunction installCancelled(): CliError {\n return new CliError('REFUSED', 'Install cancelled before anything was written.', {\n fix: 'Re-run `tenjin install` and choose the spend limits.',\n });\n}\n\nfunction promptLimits(message: string): Promise<LimitsChoice | null> {\n return selectOne<LimitsChoice>({\n message,\n choices: [\n { value: 'approve', label: 'Use these limits' },\n { value: 'own', label: 'Choose my own' },\n ],\n initialValue: 'approve',\n });\n}\n\nfunction promptAmount(message: string, placeholder: string): Promise<string | null> {\n return askText({ message, placeholder });\n}\n\nexport interface AllowRuleResult {\n path: string;\n rule: string;\n added: boolean;\n /** Set when the file could not be written; the rule is then not in force. */\n warning?: string;\n}\n\n/**\n * The one permission rule, through the shared allowlist writer rather than a\n * third hand-rolled one: it resolves a symlinked settings.json before the\n * rename, refuses a file it cannot parse, and compares the bytes it read before\n * committing, none of which a local copy of the merge would have.\n */\nasync function ensureAllowRule(path: string): Promise<AllowRuleResult> {\n const result = await appendAllowlistRules(path, [ALLOW_RULE]);\n return {\n path: result.path,\n rule: ALLOW_RULE,\n added: result.added.length > 0,\n ...(result.warning !== undefined\n ? { warning: result.warning }\n : result.skipped !== undefined\n ? { warning: `${result.path} was left untouched (${result.skipped}).` }\n : {}),\n };\n}\n\n/**\n * RECONCILE, do not re-add blindly. `claude mcp add` is not idempotent: Claude\n * Code 2.1.280 exits 1 on a second identical add with \"MCP server x402 already\n * exists in .mcp.json\". Running it unconditionally therefore reported a\n * perfectly healthy machine as an unregistered one and printed a repair command\n * that would fail the same way, while a same-name entry launching something\n * else never converged, because `add` refuses to overwrite it.\n *\n * So the scope's own file is read first: an entry that already launches\n * `tenjin mcp` is the goal state and nothing is spawned, and a file that cannot\n * be read is refused out loud rather than written over.\n *\n * AN `x402` ENTRY THAT LAUNCHES SOMETHING ELSE IS SOMEBODY ELSE'S. This command\n * will not delete it. It may be another tool of the user's that happens to\n * share the name, and an installer that removes a registration nobody asked it\n * to touch has destroyed configuration to make its own output look tidy. The\n * conflict is reported with the exact two commands to run, and the user decides.\n */\nasync function registerMcpServer(\n deps: RouterInstallDeps,\n env: NodeJS.ProcessEnv,\n project: boolean,\n cwd: string,\n home: string,\n): Promise<McpRegistration> {\n const scope = mcpScope(project);\n const command = mcpAddCommand(project);\n const base = { name: MCP_SERVER_NAME, scope, command };\n const existing = await (deps.readMcpEntry ?? readMcpEntry)(scope, cwd, home);\n if (existing.state === 'ok') {\n return { ...base, registered: true, reconciled: 'already-registered' };\n }\n if (existing.state === 'unreadable') {\n return {\n ...base,\n registered: false,\n reconciled: 'unrepaired',\n reason: `the ${scope}-scope registration file could not be read, so nothing was written over it`,\n };\n }\n // REFUSED, NOT REPLACED. Nothing of the user's is removed to make room.\n if (existing.state === 'wrong-command') {\n return {\n ...base,\n registered: false,\n reconciled: 'unrepaired',\n command: `${mcpRemoveCommand(project)} && ${command}`,\n reason: `an MCP server named ${MCP_SERVER_NAME} is already registered at ${scope} scope and launches something else. This command will not remove a registration it did not write; run the two commands above if that entry is stale`,\n };\n }\n const which = deps.which ?? ((bin: string) => onPath(bin, env));\n if (!which('claude')) {\n return {\n ...base,\n registered: false,\n reconciled: 'unavailable',\n reason: 'the `claude` binary is not on PATH',\n };\n }\n try {\n await (deps.registerMcp ?? runClaudeMcpAdd)(command, { scope, cwd });\n return { ...base, registered: true, reconciled: 'added' };\n } catch (err) {\n return {\n ...base,\n registered: false,\n reconciled: 'unavailable',\n reason: err instanceof Error ? err.message : String(err),\n };\n }\n}\n\nexport type McpEntryState = 'ok' | 'absent' | 'wrong-command' | 'unreadable';\n\n/**\n * What an entry named `x402` actually launches. The name proves nothing: a\n * stale entry pointing at another binary would read as a working request tool.\n */\nexport function classifyMcpEntry(entry: unknown): McpEntryState {\n if (entry === null || typeof entry !== 'object' || Array.isArray(entry)) return 'absent';\n const { command, args } = entry as { command?: unknown; args?: unknown };\n if (typeof command !== 'string' || command.length === 0) return 'wrong-command';\n // The basename, so `/opt/homebrew/bin/tenjin` and a bare `tenjin` both pass.\n const binary = command.split(/[\\\\/]/).pop();\n const runsRouter =\n binary === 'tenjin' && Array.isArray(args) && args.length === 1 && args[0] === 'mcp';\n return runsRouter ? 'ok' : 'wrong-command';\n}\n\n/**\n * The file each scope writes: the project's own `.mcp.json`, or the user's\n * `~/.claude.json`. Neither can inherit from the other. Shared by `install`,\n * which reconciles against it, and `doctor`, which reports it.\n */\nexport async function readMcpEntry(\n scope: 'user' | 'project',\n cwd: string,\n home: string,\n): Promise<{ found: boolean; state: McpEntryState }> {\n const path = scope === 'project' ? join(cwd, '.mcp.json') : join(home, '.claude.json');\n // ONLY \"it is not there\" is an absence. A permission or filesystem error on a\n // file that DOES exist says nothing about what is registered in it, and\n // treating it as missing sent the refresh on to `claude mcp add` over a\n // registration it had never read: a failed add then looked like a machine\n // that simply lacks the tooling, and `tenjin update` exited 0 over whatever\n // was actually in there.\n let raw: string;\n try {\n raw = await readFile(path, 'utf8');\n } catch (err) {\n const code = (err as NodeJS.ErrnoException).code;\n if (code === 'ENOENT' || code === 'ENOTDIR') return { found: false, state: 'absent' };\n return { found: true, state: 'unreadable' };\n }\n let parsed: unknown;\n try {\n parsed = JSON.parse(raw);\n } catch {\n // NOT an absence: the harness's own file is there and unreadable to this\n // build, so neither \"register it\" nor \"it is missing\" is a true statement.\n return { found: true, state: 'unreadable' };\n }\n const servers = (parsed as { mcpServers?: unknown } | null)?.mcpServers;\n if (servers === undefined) return { found: true, state: 'absent' };\n if (servers === null || typeof servers !== 'object' || Array.isArray(servers)) {\n return { found: true, state: 'unreadable' };\n }\n const entry = (servers as Record<string, unknown>)[MCP_SERVER_NAME];\n if (entry === undefined) return { found: true, state: 'absent' };\n return { found: true, state: classifyMcpEntry(entry) };\n}\n\n/** Project scope is decided by the working directory as well as the flag:\n * `claude` writes `.mcp.json` beside the project it was run in. */\nasync function runClaudeMcpAdd(\n _command: string,\n opts: { scope: 'user' | 'project'; cwd: string },\n): Promise<void> {\n await exec('claude', ['mcp', 'add', MCP_SERVER_NAME, '-s', opts.scope, '--', 'tenjin', 'mcp'], {\n timeout: 20_000,\n cwd: opts.cwd,\n });\n}\n\ninterface EffectiveLimits {\n maxAutoSpend: string;\n sessionBudget: string;\n}\n\nfunction effectiveLimits(policy: SpendPolicy): EffectiveLimits {\n return {\n maxAutoSpend: toMoney(policy.maxAutoSpendAtomic.toString()).usd,\n sessionBudget:\n policy.sessionBudgetAtomic === null\n ? 'no daily ceiling'\n : toMoney(policy.sessionBudgetAtomic.toString()).usd,\n };\n}\n\n/** Only the status-line state that needs the user: one this install would not\n * touch, with the command that adds the footer beside it. */\nexport function statusLineProblems(ctx: CommandContext, result: StatusLineResult): string[] {\n const warn = (text: string) => paint(ctx.io, 'yellow', `! ${text}`);\n if (result.warning !== undefined) {\n return [warn(`The live status line was not registered (${result.warning})`)];\n }\n if (result.state !== 'foreign') return [];\n return [\n warn('You already have a status line, so it was left exactly as it is.'),\n ' To show the live x402 footer beside it, run:',\n ' tenjin install --status-line compose',\n ...(result.compose === undefined\n ? []\n : [' or set this command yourself:', ` ${result.compose}`]),\n ];\n}\n\n/**\n * A few lines a first-time user can read at a glance: it worked, here is your\n * wallet, here is the one thing to do next. The file paths, entry counts and\n * data-handling detail stay in `--json` and the docs; the terminal only grows\n * a line when something needs the user.\n */\nfunction lines(\n ctx: CommandContext,\n s: {\n project: boolean;\n hooks: HooksResult;\n permissions: AllowRuleResult;\n statusLine: StatusLineResult;\n mcp: McpRegistration;\n wallet: WalletOutcome;\n policy: SpendPolicy;\n },\n): string[] {\n const ok = paint(ctx.io, 'green', '✓');\n const limits = effectiveLimits(s.policy);\n const daily =\n s.policy.sessionBudgetAtomic === null ? 'no daily limit' : `$${limits.sessionBudget} a day`;\n // The first line only says \"set up\" when it is: a settings file this run\n // would not write to means nothing was set up, and hooks without the MCP\n // server point at a `request` tool that is not there.\n const blocked = s.hooks.skipped !== undefined;\n const needsMcp = !blocked && !s.mcp.registered;\n const where = s.project ? ' in this project' : '';\n const fund = paint(ctx.io, 'bold', 'tenjin wallet fund');\n return [\n blocked\n ? paint(ctx.io, 'yellow', `! Tenjin could not finish setting up Claude Code${where}`)\n : needsMcp\n ? paint(ctx.io, 'yellow', '! Almost done: Claude Code needs one command')\n : `${ok} Tenjin is set up for Claude Code${where}`,\n ...walletLines(ctx, ok, s.wallet),\n ` Automatic router: up to $${limits.maxAutoSpend} per call; daily limit ${daily}`,\n ...(s.statusLine.state === 'ours' || s.statusLine.state === 'composed'\n ? [' Live status line on: each lookup names its provider while it runs']\n : []),\n ...problems(ctx, s.hooks, s.permissions, s.statusLine, s.mcp),\n '',\n blocked\n ? 'Next: fix the file above, then run tenjin install again'\n : needsMcp\n ? s.wallet.status === 'created'\n ? `Next: run the command above and ${fund}, then restart Claude Code`\n : 'Next: run the command above, then restart Claude Code'\n : s.wallet.status === 'created'\n ? `Next: ${fund}, then restart Claude Code`\n : 'Next: restart Claude Code',\n ];\n}\n\n/** \"Up to date\" only when nothing below it needs the user. */\nfunction refreshLines(ctx: CommandContext, issues: string[]): string[] {\n if (issues.length === 0) return [`${paint(ctx.io, 'green', '✓')} Tenjin is up to date`];\n return [paint(ctx.io, 'yellow', '! Tenjin is updated, but needs one fix'), ...issues];\n}\n\nfunction walletLines(ctx: CommandContext, ok: string, w: WalletOutcome): string[] {\n if (w.status === 'created') return [`${ok} Wallet created: ${w.address}`];\n if (w.status === 'existing') return [`${ok} Wallet: ${w.address}`];\n if (w.reason === 'flag') return [' No wallet yet. Create one with: tenjin wallet create'];\n return [\n paint(ctx.io, 'yellow', `! No wallet was created. ${w.warning ?? ''}`.trimEnd()),\n ` ${w.fix ?? 'Create one with: tenjin wallet create'}`,\n ];\n}\n\n/** Only what needs the user, each with the command that fixes it. */\nfunction problems(\n ctx: CommandContext,\n hooks: HooksResult,\n permissions: AllowRuleResult,\n statusLine: StatusLineResult,\n mcp: McpRegistration,\n): string[] {\n const warn = (text: string) => paint(ctx.io, 'yellow', `! ${text}`);\n const out: string[] = [];\n // The hooks and the permission rule share one settings file, so a file this\n // run would not touch is reported once, not once per writer.\n if (hooks.skipped !== undefined) {\n out.push(\n warn(\n hooks.warning ??\n `${hooks.path ?? 'Your Claude Code settings file'} was left untouched (${hooks.skipped}).`,\n ),\n );\n } else {\n if (hooks.warning !== undefined) out.push(warn(hooks.warning));\n if (permissions.warning !== undefined) out.push(warn(permissions.warning));\n }\n if (!mcp.registered) {\n // The reason stays in --json: raw exec output is noise here, the fix is not.\n out.push(warn('Could not add the request tool to Claude Code. Run:'));\n out.push(` ${mcp.command}`);\n }\n out.push(...statusLineProblems(ctx, statusLine));\n return out;\n}\n\n/**\n * THREE ANSWERS, NOT TWO. A settings file that cannot be read or parsed is not\n * a file without our entries, and collapsing the two let `refreshEveryInstall`\n * read a momentarily broken project settings file as confirmed absence and\n * strike the project off `install.routerProjects` for good: repairing the file\n * afterwards did not bring it back, so every later `tenjin update` from HOME\n * silently skipped it.\n */\ntype EntriesProbe =\n { state: 'present' } | { state: 'absent' } | { state: 'unreadable'; reason: string };\n\nasync function probeOurEntries(path: string, dataDir: string): Promise<EntriesProbe> {\n const found = await inspectHooksFile(path);\n if ('refusal' in found) {\n // `unreadable` here is the inspection's own vocabulary for \"the file exists\n // and this build could not use it\"; a file that is simply not there comes\n // back as an empty, readable inspection rather than a refusal.\n return { state: 'unreadable', reason: found.refusal.reason };\n }\n const present = Object.values(found.hooks).some((list) =>\n list.some((entry) => ownsHookEntry(entry, dataDir)),\n );\n return present ? { state: 'present' } : { state: 'absent' };\n}\n\n/** Shared with `uninstall`: the prune this module's writer already performs. */\nexport { pruneHooks };\n","import { lstatSync } from 'node:fs';\nimport { readdir, rm, rmdir } from 'node:fs/promises';\nimport { dirname, join } from 'node:path';\nimport {\n CLI_SKILL_NAMES,\n readSkillFile,\n skillFrontmatterName,\n skillsDirsFor,\n} from './skill-wiring';\nimport { RETIRED_SKILL_NAMES, SHIPPED_SKILL_FILES } from './skills-source';\nimport { hasCode } from './errno';\n\nfunction isRealDirectory(path: string): boolean {\n try {\n return lstatSync(path, { throwIfNoEntry: false })?.isDirectory() === true;\n } catch (err) {\n // Linux reports ENOTDIR when an ancestor is a regular file. Nothing can\n // be installed below it, just as with an absent path. Do not follow symlinks.\n if (hasCode(err, 'ENOENT') || hasCode(err, 'ENOTDIR')) return false;\n throw err;\n }\n}\n\n/**\n * Remove only the files our named skill shipped (SKILL.md last, as the ownership\n * proof), then any directory they leave empty; preserve foreign skills and\n * adjacent user files.\n */\nexport async function removeOwnedSkill(\n name: string,\n skillsDir: string,\n): Promise<{ changed: boolean }> {\n if (!isRealDirectory(skillsDir)) {\n return { changed: false };\n }\n const skillDir = join(skillsDir, name);\n if (!isRealDirectory(skillDir)) {\n return { changed: false };\n }\n const path = join(skillDir, 'SKILL.md');\n const read = await readSkillFile(path);\n if (read.kind === 'absent') return { changed: false };\n if (read.kind !== 'ok' || skillFrontmatterName(read.bytes.toString('utf8')) !== name) {\n return { changed: false }; // not ours to delete for sitting at our path\n }\n const shipped = (SHIPPED_SKILL_FILES as Record<string, readonly string[]>)[name] ?? [];\n const subdirs = new Set<string>();\n for (const rel of shipped) {\n if (rel === 'SKILL.md') continue;\n const file = join(skillDir, rel);\n // A symlinked `references/` would route the delete outside the skill.\n if (!isRealDirectory(dirname(file))) continue;\n subdirs.add(dirname(file));\n if (lstatSync(file, { throwIfNoEntry: false })?.isFile() === true) await rm(file);\n }\n await rm(path, { force: true });\n for (const dir of [...subdirs, skillDir].sort((a, b) => b.length - a.length)) {\n const rest = await readdir(dir).catch(() => null);\n if (rest !== null && rest.length === 0) await rmdir(dir).catch(() => undefined);\n }\n return { changed: true };\n}\n\n/**\n * Refresh retires obsolete skills without needing their old packaged source:\n * the retired names, and the shelf's CLI skills, whose `tenjin search` and\n * `tenjin publish` commands the router CLI does not ship.\n */\nexport async function removeRetiredSkills(home: string, project?: string): Promise<string[]> {\n const removed: string[] = [];\n const dirs = [...skillsDirsFor(home), ...(project ? skillsDirsFor(project) : [])];\n for (const dir of new Set(dirs)) {\n for (const name of [...RETIRED_SKILL_NAMES, ...CLI_SKILL_NAMES])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,MAAM,KAAK,EAAE;AAAA,IAAK,CAAC,SAC/C,KAAK,KAAK,CAAC,UAAU,cAAc,OAAO,OAAO,CAAC;AAAA,EACpD;AACA,SAAO,UAAU,EAAE,OAAO,UAAU,IAAI,EAAE,OAAO,SAAS;AAC5D;","names":["join","join"]}
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import { createRequire as __tenjinCreateRequire } from 'node:module'; const require = __tenjinCreateRequire(import.meta.url);
|
|
2
2
|
import {
|
|
3
3
|
setTenjinIdentity
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-RCJ64OXH.js";
|
|
5
5
|
import {
|
|
6
6
|
hasCode
|
|
7
7
|
} from "./chunk-2I4QTOLB.js";
|
|
8
8
|
import {
|
|
9
9
|
isTeamModeConfig
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-TMLCEPCD.js";
|
|
11
11
|
import {
|
|
12
12
|
knownDeploymentOrigins,
|
|
13
13
|
loadRawConfig,
|
|
14
14
|
resolveSettings
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-P22ZWXFX.js";
|
|
16
16
|
import {
|
|
17
17
|
writeFileAtomicExclusive
|
|
18
18
|
} from "./chunk-JLEF5WHM.js";
|
|
@@ -109,4 +109,4 @@ export {
|
|
|
109
109
|
enableCliIdentity,
|
|
110
110
|
enableDaemonIdentity
|
|
111
111
|
};
|
|
112
|
-
//# sourceMappingURL=chunk-
|
|
112
|
+
//# sourceMappingURL=chunk-IIE65SJC.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createRequire as __tenjinCreateRequire } from 'node:module'; const require = __tenjinCreateRequire(import.meta.url);
|
|
2
2
|
import {
|
|
3
3
|
getUsdcBalance
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-FFL5M5BC.js";
|
|
5
5
|
import {
|
|
6
6
|
commitLocalWallet,
|
|
7
7
|
createLocalWallet,
|
|
@@ -14,7 +14,7 @@ import {
|
|
|
14
14
|
verifyAndPreserveOutgoingWallet,
|
|
15
15
|
walletExistsError,
|
|
16
16
|
walletFileExists
|
|
17
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-GPLSNGKX.js";
|
|
18
18
|
import {
|
|
19
19
|
LockTimeoutError,
|
|
20
20
|
withFileLock
|
|
@@ -25,7 +25,7 @@ import {
|
|
|
25
25
|
import {
|
|
26
26
|
loadRawConfig,
|
|
27
27
|
resolveSettings
|
|
28
|
-
} from "./chunk-
|
|
28
|
+
} from "./chunk-P22ZWXFX.js";
|
|
29
29
|
import {
|
|
30
30
|
CliError
|
|
31
31
|
} from "./chunk-JLEF5WHM.js";
|
|
@@ -239,4 +239,4 @@ export {
|
|
|
239
239
|
runWalletShow,
|
|
240
240
|
runWalletBalance
|
|
241
241
|
};
|
|
242
|
-
//# sourceMappingURL=chunk-
|
|
242
|
+
//# sourceMappingURL=chunk-KC24CYGV.js.map
|
|
@@ -5,12 +5,12 @@ import {
|
|
|
5
5
|
mainWorktreeOf,
|
|
6
6
|
ownedCandidates,
|
|
7
7
|
projectRoot
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-TMLCEPCD.js";
|
|
9
9
|
import {
|
|
10
10
|
CONFIG_DEFAULTS,
|
|
11
11
|
loadRawConfig,
|
|
12
12
|
parseRouterLayer
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-P22ZWXFX.js";
|
|
14
14
|
import {
|
|
15
15
|
CliError
|
|
16
16
|
} from "./chunk-JLEF5WHM.js";
|
|
@@ -124,4 +124,4 @@ export {
|
|
|
124
124
|
readProjectRouterFile,
|
|
125
125
|
projectRouterPath
|
|
126
126
|
};
|
|
127
|
-
//# sourceMappingURL=chunk-
|
|
127
|
+
//# sourceMappingURL=chunk-NSDZESRS.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createRequire as __tenjinCreateRequire } from 'node:module'; const require = __tenjinCreateRequire(import.meta.url);
|
|
2
2
|
import {
|
|
3
3
|
external_exports
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-P22ZWXFX.js";
|
|
5
5
|
import {
|
|
6
6
|
CliError
|
|
7
7
|
} from "./chunk-JLEF5WHM.js";
|
|
@@ -228,4 +228,4 @@ export {
|
|
|
228
228
|
sanitizeForTerminal,
|
|
229
229
|
paint
|
|
230
230
|
};
|
|
231
|
-
//# sourceMappingURL=chunk-
|
|
231
|
+
//# sourceMappingURL=chunk-O2WN732M.js.map
|
|
@@ -15198,4 +15198,4 @@ export {
|
|
|
15198
15198
|
resolveSettings,
|
|
15199
15199
|
resolveExperimentalBazaar
|
|
15200
15200
|
};
|
|
15201
|
-
//# sourceMappingURL=chunk-
|
|
15201
|
+
//# sourceMappingURL=chunk-P22ZWXFX.js.map
|