@hop-top/kit 0.5.0-alpha.10 → 0.5.0-alpha.12
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/CHANGELOG.md +42 -0
- package/README.md +4 -4
- package/dist/alias.js +3 -3
- package/dist/{chunk-T46YPHKN.js → chunk-4FMALWYB.js} +45 -45
- package/dist/{chunk-JZ22ZUFA.js → chunk-65VPWMPV.js} +4 -1
- package/dist/{chunk-YGYQUFGY.js → chunk-BXJ2J27B.js} +10 -10
- package/dist/chunk-CXBZTONY.js +65 -0
- package/dist/{chunk-K7VCKJ27.js → chunk-EE4M2UOF.js} +8 -4
- package/dist/{chunk-72XZWQX7.js → chunk-GFRAYYRD.js} +475 -162
- package/dist/{chunk-2JV3A7OP.js → chunk-IVQHLI56.js} +6 -10
- package/dist/{chunk-NLMS7HGP.js → chunk-IZ6Q4SE3.js} +3 -3
- package/dist/chunk-MFVUENZR.js +1549 -0
- package/dist/{chunk-BLS2OBIQ.js → chunk-ML7D5DWY.js} +2 -2
- package/dist/chunk-P3Y46PYF.js +138 -0
- package/dist/{chunk-GGWJRWWA.js → chunk-RYKLVOVK.js} +7 -7
- package/dist/{chunk-QPUCXQXT.js → chunk-T6OZMPPV.js} +2 -1
- package/dist/{chunk-MUIQVU6E.js → chunk-VGOA5Y7S.js} +11 -11
- package/dist/{chunk-ABQSE7AI.js → chunk-VWGP4NVJ.js} +38 -38
- package/dist/chunk-X4E5QGEB.js +171 -0
- package/dist/cli-RSRk1M36.d.ts +707 -0
- package/dist/cli.d.ts +1 -1
- package/dist/cli.js +60 -5
- package/dist/completion.js +2 -2
- package/dist/id/index.d.ts +1 -1
- package/dist/id/index.js +4 -2
- package/dist/{index-DCe1boBz.d.ts → index-CGE5yLBj.d.ts} +1 -1
- package/dist/{index-VLDcI5NF.d.ts → index-D9zpUrpE.d.ts} +18 -6
- package/dist/index.d.ts +4 -4
- package/dist/index.js +23 -23
- package/dist/llm-anthropic.js +5 -5
- package/dist/llm-openai.js +5 -5
- package/dist/llm.js +3 -3
- package/dist/log.js +3 -3
- package/dist/mcp/index.js +3 -2
- package/dist/output.js +2 -4
- package/dist/routellm.js +6 -6
- package/dist/toolspec.js +4 -4
- package/dist/tui/index.d.ts +2 -2
- package/dist/tui/index.js +3 -3
- package/dist/{upgrade-p_zh3pvV.d.ts → upgrade-BJ2z6Oqf.d.ts} +58 -4
- package/dist/upgrade.d.ts +1 -1
- package/dist/upgrade.js +4 -2
- package/package.json +9 -9
- package/src/cli.root.conformance.test.ts +166 -0
- package/src/cli.ts +39 -0
- package/src/completion.conformance.test.ts +3 -2
- package/src/completion.test.ts +12 -0
- package/src/completion.ts +8 -3
- package/src/delegation.test.ts +299 -0
- package/src/delegation.ts +807 -0
- package/src/id/README.md +2 -2
- package/src/id/contract.test.ts +11 -8
- package/src/id/differential.test.ts +54 -0
- package/src/id/index.ts +123 -17
- package/src/mcp/bridge.test.ts +28 -0
- package/src/mcp/bridge.ts +5 -10
- package/src/plan.ts +89 -0
- package/src/policy.ts +472 -0
- package/src/sideeffect.ts +105 -0
- package/src/toolspec-manifest.ts +7 -2
- package/src/upgrade.test.ts +393 -1
- package/src/upgrade.ts +183 -25
- package/dist/chunk-GHPJJV5L.js +0 -613
- package/dist/chunk-IXVQ62NZ.js +0 -334
- package/dist/chunk-L23O2FFE.js +0 -51
- package/dist/chunk-WWUKGJB5.js +0 -90
- package/dist/cli-C5B5tnpA.d.ts +0 -400
- package/dist/{chunk-PSFYJGDG.js → chunk-K7E34Q3A.js} +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,48 @@ All notable changes to `@hop-top/kit` are documented in this file.
|
|
|
4
4
|
Format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/);
|
|
5
5
|
versions follow [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
6
6
|
|
|
7
|
+
## [0.5.0-alpha.12](https://github.com/hop-top/poly-kit/compare/kit-ts/v0.5.0-alpha.11...kit-ts/v0.5.0-alpha.12) (2026-11-15)
|
|
8
|
+
|
|
9
|
+
The hop-top team is happy to announce Kit's TS SDK 0.5.0-alpha.12. This release includes new features and bug fixes.
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
### Features
|
|
13
|
+
|
|
14
|
+
* **py/upgrade:** result-returning check() ([b212133](https://github.com/hop-top/poly-kit/commit/b212133e1e072b95efe93404e979052abdef2bb8))
|
|
15
|
+
* **ts/upgrade:** result-returning check() ([855da06](https://github.com/hop-top/poly-kit/commit/855da064273c089f49207156f42fdc58a272bd71))
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
### Bug Fixes
|
|
19
|
+
|
|
20
|
+
* **deps:** hono 4.13.16 in sdk/ts ([7c20fb7](https://github.com/hop-top/poly-kit/commit/7c20fb7b5d9dda0ff949b05bac2460cf33991fe9))
|
|
21
|
+
* **ts:** ship a self-contained TypeID, drop the typeid-js runtime dep ([c5aa133](https://github.com/hop-top/poly-kit/commit/c5aa133e826330d47b29e2b46e51c9e07ad4fa7a))
|
|
22
|
+
|
|
23
|
+
Full diff: [kit-ts/v0.5.0-alpha.11...kit-ts/v0.5.0-alpha.12](https://github.com/hop-top/poly-kit/compare/kit-ts/v0.5.0-alpha.11...kit-ts/v0.5.0-alpha.12)
|
|
24
|
+
|
|
25
|
+
## [0.5.0-alpha.11](https://github.com/hop-top/poly-kit/compare/kit-ts/v0.5.0-alpha.10...kit-ts/v0.5.0-alpha.11) (2026-11-04)
|
|
26
|
+
|
|
27
|
+
The hop-top team is happy to announce Kit's TS SDK 0.5.0-alpha.11. This release includes new features and bug fixes.
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
### ⚠ BREAKING CHANGES
|
|
31
|
+
|
|
32
|
+
* **ts/cli:** unannotated leaf named delete|remove|rm|destroy|purge|drop now needs confirmation on CLI and is blocked on MCP default policy; --dry-run/--confirm/--max-ops/--policy reserved on root
|
|
33
|
+
|
|
34
|
+
### Features
|
|
35
|
+
|
|
36
|
+
* **ts/cli:** delegation gate, side-effect inference ([692582a](https://github.com/hop-top/poly-kit/commit/692582ad6bd12757b5fa9199266a5e0584c108eb))
|
|
37
|
+
* **ts/upgrade:** tagPrefix and includePrereleases options ([bfec2d7](https://github.com/hop-top/poly-kit/commit/bfec2d7512410205cb9bb9aeb2e5faa52256dff9))
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
### Bug Fixes
|
|
41
|
+
|
|
42
|
+
* **toolspec:** dry_run_supported counts inferred destructive leaves ([8cb1f6c](https://github.com/hop-top/poly-kit/commit/8cb1f6c60bca7033fd9a137113eb3851bc94b2bb))
|
|
43
|
+
* **ts,py/cli:** inferred dry-run plan matches Go, drop stale skip ([b96cba3](https://github.com/hop-top/poly-kit/commit/b96cba3816a8f21fb2f7b1c900a8240439a8b7c0))
|
|
44
|
+
* **ts/cli:** refuse malformed side-effect tiers before running ([582dc3a](https://github.com/hop-top/poly-kit/commit/582dc3a86e292a1d9ff6ce1bc2576a4559545c80))
|
|
45
|
+
* **ts/completion:** deep alias shim offers inherited root flags ([f79acac](https://github.com/hop-top/poly-kit/commit/f79acac4b1a5fe9004292e3e81a25cc139da1d94))
|
|
46
|
+
|
|
47
|
+
Full diff: [kit-ts/v0.5.0-alpha.10...kit-ts/v0.5.0-alpha.11](https://github.com/hop-top/poly-kit/compare/kit-ts/v0.5.0-alpha.10...kit-ts/v0.5.0-alpha.11)
|
|
48
|
+
|
|
7
49
|
## [0.5.0-alpha.10](https://github.com/hop-top/poly-kit/compare/kit-ts/v0.5.0-alpha.9...kit-ts/v0.5.0-alpha.10) (2026-10-30)
|
|
8
50
|
|
|
9
51
|
The hop-top team is happy to announce Kit's TS SDK 0.5.0-alpha.10. This release includes new features.
|
package/README.md
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
# @hop-top/kit (TypeScript)
|
|
2
2
|
|
|
3
|
-
Shared CLI utilities for hop-top tools, CommonJS edition. Mirrors the Go
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
config files, an embedded SQLite store, upgrade checks, LLM helpers,
|
|
3
|
+
Shared CLI utilities for hop-top tools, CommonJS edition. Mirrors the Go `kit` package surface:
|
|
4
|
+
a Commander-based CLI factory, output formatting with a registry/Formatter contract, theming,
|
|
5
|
+
hint plumbing, XDG paths, config files, an embedded SQLite store, upgrade checks, LLM helpers,
|
|
7
6
|
alias resolution, and a TUI toolkit.
|
|
8
7
|
|
|
9
8
|
## Install
|
|
@@ -64,6 +63,7 @@ upgrade detection), `llm`, `anthropic`, `openai`, `routellm`, `alias`, `uri`
|
|
|
64
63
|
- Five built-in formatters (`json`, `yaml`, `table`, `csv`, `text`), the same set every kit SDK ships.
|
|
65
64
|
- Column order comes from an explicit `ColumnSpec[]`; `--cols` reorders as well as selects; `header` must equal `key`.
|
|
66
65
|
- `serve <service>` starts a named service even when `services.<name>.enabled` is false; a supervisor run resolving to zero services exits 2.
|
|
66
|
+
- Delegation gates: root `--confirm`, `--confirm-token`, `--max-ops`, `--policy`, `--dry-run` enforce a leaf's `kit/side-effect`; an unannotated leaf named `delete`/`remove`/`rm`/`destroy`/`purge`/`drop` is gated as destructive (and blocked on MCP by default). See the API reference.
|
|
67
67
|
- MCP exposure is default-closed: `defaultPolicy()` blocks every destructive leaf on every remote surface.
|
|
68
68
|
- Telemetry is default-denied: `Client.record()` is a no-op without both a granted consent decision and a non-`off` mode.
|
|
69
69
|
|
package/dist/alias.js
CHANGED
|
@@ -9,8 +9,8 @@
|
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
|
|
12
|
-
var
|
|
13
|
-
require('./chunk-
|
|
12
|
+
var _chunkML7D5DWYjs = require('./chunk-ML7D5DWY.js');
|
|
13
|
+
require('./chunk-65VPWMPV.js');
|
|
14
14
|
require('./chunk-JKMQSAJP.js');
|
|
15
15
|
require('./chunk-R5U7XKVJ.js');
|
|
16
16
|
|
|
@@ -24,4 +24,4 @@ require('./chunk-R5U7XKVJ.js');
|
|
|
24
24
|
|
|
25
25
|
|
|
26
26
|
|
|
27
|
-
exports.AliasNameError =
|
|
27
|
+
exports.AliasNameError = _chunkML7D5DWYjs.AliasNameError; exports.AliasStore = _chunkML7D5DWYjs.AliasStore; exports.Expander = _chunkML7D5DWYjs.Expander; exports.bridgeAliases = _chunkML7D5DWYjs.bridgeAliases; exports.detectCycles = _chunkML7D5DWYjs.detectCycles; exports.findCommand = _chunkML7D5DWYjs.findCommand; exports.findFirstNonFlag = _chunkML7D5DWYjs.findFirstNonFlag; exports.loadFrom = _chunkML7D5DWYjs.loadFrom; exports.saveTo = _chunkML7D5DWYjs.saveTo; exports.validateAliasName = _chunkML7D5DWYjs.validateAliasName;
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
|
|
8
|
-
var
|
|
8
|
+
var _chunkBXJ2J27Bjs = require('./chunk-BXJ2J27B.js');
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
|
|
@@ -23,7 +23,7 @@ var _chunkYGYQUFGYjs = require('./chunk-YGYQUFGY.js');
|
|
|
23
23
|
|
|
24
24
|
|
|
25
25
|
|
|
26
|
-
var
|
|
26
|
+
var _chunkK7E34Q3Ajs = require('./chunk-K7E34Q3A.js');
|
|
27
27
|
|
|
28
28
|
|
|
29
29
|
var _chunkR5U7XKVJjs = require('./chunk-R5U7XKVJ.js');
|
|
@@ -55,12 +55,12 @@ var EVENT_STATUS = {
|
|
|
55
55
|
var AnthropicAdapter = class {
|
|
56
56
|
constructor(cfg) {
|
|
57
57
|
const key = _nullishCoalesce(cfg.provider.apiKey, () => ( ""));
|
|
58
|
-
if (key.trim() === "") throw new (0,
|
|
59
|
-
this.limits =
|
|
58
|
+
if (key.trim() === "") throw new (0, _chunkK7E34Q3Ajs.LLMError)("anthropic: API key required");
|
|
59
|
+
this.limits = _chunkBXJ2J27Bjs.limitsFrom.call(void 0, SCHEME, cfg.provider.params);
|
|
60
60
|
try {
|
|
61
|
-
this.toolNames =
|
|
61
|
+
this.toolNames = _chunkK7E34Q3Ajs.toolNameModeOf.call(void 0, cfg.provider.params);
|
|
62
62
|
} catch (err) {
|
|
63
|
-
throw new (0,
|
|
63
|
+
throw new (0, _chunkK7E34Q3Ajs.LLMError)(`anthropic: ${err.message}`);
|
|
64
64
|
}
|
|
65
65
|
const env = envReader(cfg);
|
|
66
66
|
const envBase = env("ANTHROPIC_BASE_URL");
|
|
@@ -69,7 +69,7 @@ var AnthropicAdapter = class {
|
|
|
69
69
|
const base = cfg.provider.baseURL || envBase || ANTHROPIC_DEFAULT_BASE_URL;
|
|
70
70
|
this.baseURL = base;
|
|
71
71
|
this.model = cfg.provider.model || _optionalChain([cfg, 'access', _ => _.uri, 'optionalAccess', _2 => _2.model]) || "";
|
|
72
|
-
|
|
72
|
+
_chunkK7E34Q3Ajs.checkKeyEndpoint.call(void 0, SCHEME, key, base);
|
|
73
73
|
this.headers = {
|
|
74
74
|
"content-type": "application/json",
|
|
75
75
|
accept: "application/json",
|
|
@@ -79,14 +79,14 @@ var AnthropicAdapter = class {
|
|
|
79
79
|
const token = _nullishCoalesce(env("ANTHROPIC_AUTH_TOKEN"), () => ( ""));
|
|
80
80
|
const extra = {};
|
|
81
81
|
if (token.trim() !== "") {
|
|
82
|
-
|
|
82
|
+
_chunkK7E34Q3Ajs.checkKeyEndpoint.call(void 0, SCHEME, token, base);
|
|
83
83
|
extra["authorization"] = `Bearer ${token}`;
|
|
84
84
|
}
|
|
85
85
|
const ws = _nullishCoalesce(env("ANTHROPIC_WORKSPACE_ID"), () => ( ""));
|
|
86
86
|
if (ws !== "") extra["anthropic-workspace-id"] = ws;
|
|
87
87
|
const trusted = [ANTHROPIC_DEFAULT_BASE_URL];
|
|
88
88
|
if (envBase) trusted.push(envBase);
|
|
89
|
-
if (Object.keys(extra).length > 0 &&
|
|
89
|
+
if (Object.keys(extra).length > 0 && _chunkK7E34Q3Ajs.credentialsTrusted.call(void 0, SCHEME, base, ...trusted)) {
|
|
90
90
|
Object.assign(this.headers, extra);
|
|
91
91
|
}
|
|
92
92
|
this.secrets = [key, token].filter((s) => s.trim() !== "");
|
|
@@ -122,7 +122,7 @@ var AnthropicAdapter = class {
|
|
|
122
122
|
}
|
|
123
123
|
// ── private ────────────────────────────────────────────────────
|
|
124
124
|
toolNameMap(tools) {
|
|
125
|
-
return
|
|
125
|
+
return _chunkK7E34Q3Ajs.ToolNames.build(_chunkK7E34Q3Ajs.ANTHROPIC_TOOL_NAMES, this.toolNames, tools);
|
|
126
126
|
}
|
|
127
127
|
transport(req) {
|
|
128
128
|
const model = req.model || this.model;
|
|
@@ -135,18 +135,18 @@ var AnthropicAdapter = class {
|
|
|
135
135
|
}
|
|
136
136
|
async send(body, req) {
|
|
137
137
|
const opts = this.transport(req);
|
|
138
|
-
const resp = await
|
|
139
|
-
const text = await
|
|
140
|
-
throw
|
|
138
|
+
const resp = await _chunkBXJ2J27Bjs.post.call(void 0, opts, this.url(), this.headers, body);
|
|
139
|
+
const text = await _chunkBXJ2J27Bjs.readBody.call(void 0, resp, this.limits.body, SCHEME).catch((e) => {
|
|
140
|
+
throw _chunkBXJ2J27Bjs.scrubError.call(void 0, e, this.secrets);
|
|
141
141
|
});
|
|
142
142
|
try {
|
|
143
143
|
return JSON.parse(text);
|
|
144
144
|
} catch (e2) {
|
|
145
|
-
throw new (0,
|
|
145
|
+
throw new (0, _chunkK7E34Q3Ajs.LLMError)("anthropic: response is not valid JSON");
|
|
146
146
|
}
|
|
147
147
|
}
|
|
148
148
|
url() {
|
|
149
|
-
return
|
|
149
|
+
return _chunkBXJ2J27Bjs.joinURL.call(void 0, this.baseURL, "v1/messages");
|
|
150
150
|
}
|
|
151
151
|
openStream(req, tools) {
|
|
152
152
|
let outcome;
|
|
@@ -165,19 +165,19 @@ var AnthropicAdapter = class {
|
|
|
165
165
|
setToolChoice(body, req.toolChoice, _nullishCoalesce(tools, () => ( [])), names);
|
|
166
166
|
body["stream"] = true;
|
|
167
167
|
const opts = this.transport(req);
|
|
168
|
-
const resp = await
|
|
168
|
+
const resp = await _chunkBXJ2J27Bjs.post.call(void 0, opts, this.url(), {
|
|
169
169
|
...this.headers,
|
|
170
170
|
accept: "text/event-stream"
|
|
171
171
|
}, body);
|
|
172
172
|
const acc = new Accumulator();
|
|
173
173
|
const events = req.streamEvents ? new EventMapper(acc, names) : void 0;
|
|
174
174
|
try {
|
|
175
|
-
for await (const ev of
|
|
175
|
+
for await (const ev of _chunkBXJ2J27Bjs.sseEvents.call(void 0, resp, this.limits.event, SCHEME)) {
|
|
176
176
|
let evt;
|
|
177
177
|
try {
|
|
178
178
|
evt = JSON.parse(ev.data);
|
|
179
179
|
} catch (e3) {
|
|
180
|
-
throw new (0,
|
|
180
|
+
throw new (0, _chunkK7E34Q3Ajs.LLMError)("anthropic: stream event is not valid JSON");
|
|
181
181
|
}
|
|
182
182
|
if (evt.type === "error") {
|
|
183
183
|
throw streamError(evt.error, req.model || this.model);
|
|
@@ -198,9 +198,9 @@ var AnthropicAdapter = class {
|
|
|
198
198
|
}
|
|
199
199
|
}
|
|
200
200
|
} catch (err) {
|
|
201
|
-
throw
|
|
201
|
+
throw _chunkBXJ2J27Bjs.scrubError.call(void 0, err, this.secrets);
|
|
202
202
|
}
|
|
203
|
-
throw new (0,
|
|
203
|
+
throw new (0, _chunkK7E34Q3Ajs.StreamTruncatedError)(SCHEME);
|
|
204
204
|
}
|
|
205
205
|
async buildBody(req, names) {
|
|
206
206
|
const maxTokens = req.maxTokens !== void 0 && req.maxTokens > 0 ? req.maxTokens : DEFAULT_MAX_TOKENS;
|
|
@@ -214,12 +214,12 @@ var AnthropicAdapter = class {
|
|
|
214
214
|
if (req.thinking) {
|
|
215
215
|
const b = req.thinking.budgetTokens;
|
|
216
216
|
if (b < MIN_THINKING_BUDGET) {
|
|
217
|
-
throw new (0,
|
|
217
|
+
throw new (0, _chunkK7E34Q3Ajs.LLMError)(
|
|
218
218
|
`anthropic: thinking budget_tokens must be at least ${MIN_THINKING_BUDGET}, got ${b}`
|
|
219
219
|
);
|
|
220
220
|
}
|
|
221
221
|
if (b >= maxTokens) {
|
|
222
|
-
throw new (0,
|
|
222
|
+
throw new (0, _chunkK7E34Q3Ajs.LLMError)(
|
|
223
223
|
`anthropic: thinking budget_tokens (${b}) must be less than max_tokens (${maxTokens})`
|
|
224
224
|
);
|
|
225
225
|
}
|
|
@@ -237,7 +237,7 @@ function checkBaseURL(what, base) {
|
|
|
237
237
|
try {
|
|
238
238
|
new URL(base);
|
|
239
239
|
} catch (e4) {
|
|
240
|
-
throw new (0,
|
|
240
|
+
throw new (0, _chunkK7E34Q3Ajs.LLMError)(`anthropic: invalid ${what}: ${JSON.stringify(_chunkK7E34Q3Ajs.redactURI.call(void 0, base))}`);
|
|
241
241
|
}
|
|
242
242
|
}
|
|
243
243
|
async function extractSystem(msgs, names) {
|
|
@@ -288,27 +288,27 @@ function systemBlocks(msgs) {
|
|
|
288
288
|
}
|
|
289
289
|
function checkLinkageRole(m) {
|
|
290
290
|
if ((_nullishCoalesce(_optionalChain([m, 'access', _9 => _9.toolCalls, 'optionalAccess', _10 => _10.length]), () => ( 0))) > 0 && m.role !== "assistant") {
|
|
291
|
-
throw new (0,
|
|
291
|
+
throw new (0, _chunkK7E34Q3Ajs.LLMError)(
|
|
292
292
|
`anthropic: ToolCalls are valid only on role assistant, got ${JSON.stringify(m.role)}`
|
|
293
293
|
);
|
|
294
294
|
}
|
|
295
295
|
if ((_nullishCoalesce(_optionalChain([m, 'access', _11 => _11.thinking, 'optionalAccess', _12 => _12.length]), () => ( 0))) > 0 && m.role !== "assistant") {
|
|
296
|
-
throw new (0,
|
|
296
|
+
throw new (0, _chunkK7E34Q3Ajs.LLMError)(
|
|
297
297
|
`anthropic: Thinking is valid only on role assistant, got ${JSON.stringify(m.role)}`
|
|
298
298
|
);
|
|
299
299
|
}
|
|
300
300
|
if (m.toolCallId && m.role !== "tool") {
|
|
301
|
-
throw new (0,
|
|
301
|
+
throw new (0, _chunkK7E34Q3Ajs.LLMError)(
|
|
302
302
|
`anthropic: ToolCallID is valid only on role tool, got ${JSON.stringify(m.role)}`
|
|
303
303
|
);
|
|
304
304
|
}
|
|
305
305
|
}
|
|
306
306
|
function toolResultBlock(m) {
|
|
307
307
|
if (!m.toolCallId) {
|
|
308
|
-
throw new (0,
|
|
308
|
+
throw new (0, _chunkK7E34Q3Ajs.LLMError)("anthropic: tool result needs ToolCallID");
|
|
309
309
|
}
|
|
310
310
|
if (_optionalChain([m, 'access', _13 => _13.parts, 'optionalAccess', _14 => _14.length])) {
|
|
311
|
-
throw new (0,
|
|
311
|
+
throw new (0, _chunkK7E34Q3Ajs.LLMError)(
|
|
312
312
|
`anthropic: tool result ${JSON.stringify(m.toolCallId)} carries only Content`
|
|
313
313
|
);
|
|
314
314
|
}
|
|
@@ -319,7 +319,7 @@ function toolResultBlock(m) {
|
|
|
319
319
|
function toolUseBlocks(calls, names) {
|
|
320
320
|
return calls.map((tc) => {
|
|
321
321
|
if (!tc.id) {
|
|
322
|
-
throw new (0,
|
|
322
|
+
throw new (0, _chunkK7E34Q3Ajs.LLMError)(`anthropic: tool call ${JSON.stringify(tc.name)} needs an ID`);
|
|
323
323
|
}
|
|
324
324
|
return {
|
|
325
325
|
type: "tool_use",
|
|
@@ -336,7 +336,7 @@ function inputOf(tc) {
|
|
|
336
336
|
try {
|
|
337
337
|
return JSON.parse(args);
|
|
338
338
|
} catch (e5) {
|
|
339
|
-
throw new (0,
|
|
339
|
+
throw new (0, _chunkK7E34Q3Ajs.LLMError)(
|
|
340
340
|
`anthropic: tool call ${JSON.stringify(tc.id)} arguments are not valid JSON`
|
|
341
341
|
);
|
|
342
342
|
}
|
|
@@ -351,7 +351,7 @@ function cacheParam(cc) {
|
|
|
351
351
|
const ttl = _nullishCoalesce(cc.ttl, () => ( ""));
|
|
352
352
|
if (ttl === "") return { type: "ephemeral" };
|
|
353
353
|
if (ttl === "5m" || ttl === "1h") return { type: "ephemeral", ttl };
|
|
354
|
-
throw new (0,
|
|
354
|
+
throw new (0, _chunkK7E34Q3Ajs.LLMError)(
|
|
355
355
|
`anthropic: cache_control ttl must be "5m" or "1h", got ${JSON.stringify(ttl)}`
|
|
356
356
|
);
|
|
357
357
|
}
|
|
@@ -368,8 +368,8 @@ async function mapParts(parts) {
|
|
|
368
368
|
break;
|
|
369
369
|
case "image": {
|
|
370
370
|
const mime = p.mimeType || _optionalChain([p, 'access', _15 => _15.source, 'optionalAccess', _16 => _16.mimeType, 'call', _17 => _17()]) || "";
|
|
371
|
-
if (!mime) throw new (0,
|
|
372
|
-
if (!p.source) throw new (0,
|
|
371
|
+
if (!mime) throw new (0, _chunkK7E34Q3Ajs.LLMError)("anthropic: image part needs a MIME type");
|
|
372
|
+
if (!p.source) throw new (0, _chunkK7E34Q3Ajs.LLMError)("anthropic: nil media source");
|
|
373
373
|
const url = p.source.url();
|
|
374
374
|
if (url) {
|
|
375
375
|
out.push({ type: mime === "application/pdf" ? "document" : "image", source: { type: "url", url } });
|
|
@@ -382,16 +382,16 @@ async function mapParts(parts) {
|
|
|
382
382
|
break;
|
|
383
383
|
}
|
|
384
384
|
default:
|
|
385
|
-
throw new (0,
|
|
385
|
+
throw new (0, _chunkK7E34Q3Ajs.LLMError)(`anthropic: unsupported modality ${JSON.stringify(p.type)}`);
|
|
386
386
|
}
|
|
387
387
|
}
|
|
388
388
|
return out;
|
|
389
389
|
}
|
|
390
390
|
function setToolChoice(body, c, tools, names) {
|
|
391
391
|
try {
|
|
392
|
-
|
|
392
|
+
_chunkK7E34Q3Ajs.checkToolChoice.call(void 0, c, tools);
|
|
393
393
|
} catch (err) {
|
|
394
|
-
throw new (0,
|
|
394
|
+
throw new (0, _chunkK7E34Q3Ajs.LLMError)(`anthropic: ${err.message}`);
|
|
395
395
|
}
|
|
396
396
|
if (!c) return;
|
|
397
397
|
body["tool_choice"] = c.mode === "tool" ? { type: "tool", name: names.wire(_nullishCoalesce(c.name, () => ( ""))) } : { type: c.mode };
|
|
@@ -493,7 +493,7 @@ var Accumulator = class {
|
|
|
493
493
|
}
|
|
494
494
|
case "content_block_start": {
|
|
495
495
|
if (evt.index !== this.content.length) {
|
|
496
|
-
throw new (0,
|
|
496
|
+
throw new (0, _chunkK7E34Q3Ajs.LLMError)(
|
|
497
497
|
`anthropic: received event of type content_block_start for content block at index ${evt.index}, expected index ${this.content.length}`
|
|
498
498
|
);
|
|
499
499
|
}
|
|
@@ -505,7 +505,7 @@ var Accumulator = class {
|
|
|
505
505
|
case "content_block_delta": {
|
|
506
506
|
const i = _nullishCoalesce(evt.index, () => ( -1));
|
|
507
507
|
if (i < 0 || i >= this.content.length) {
|
|
508
|
-
throw new (0,
|
|
508
|
+
throw new (0, _chunkK7E34Q3Ajs.LLMError)(
|
|
509
509
|
`anthropic: received event of type content_block_delta for content block at index ${i}, only ${this.content.length} blocks exist`
|
|
510
510
|
);
|
|
511
511
|
}
|
|
@@ -636,18 +636,18 @@ function streamError(e, model) {
|
|
|
636
636
|
return classify(status, type, `anthropic: stream error: ${type}: ${_nullishCoalesce(_optionalChain([e, 'optionalAccess', _26 => _26.message]), () => ( ""))}`, model);
|
|
637
637
|
}
|
|
638
638
|
function classify(status, type, message, model) {
|
|
639
|
-
const api = new (0,
|
|
639
|
+
const api = new (0, _chunkK7E34Q3Ajs.APIError)(SCHEME, status, type, message);
|
|
640
640
|
switch (status) {
|
|
641
641
|
case 401:
|
|
642
|
-
return new (0,
|
|
642
|
+
return new (0, _chunkK7E34Q3Ajs.AuthError)(SCHEME, api);
|
|
643
643
|
case 403:
|
|
644
|
-
return new (0,
|
|
644
|
+
return new (0, _chunkK7E34Q3Ajs.PermissionDeniedError)(SCHEME, api);
|
|
645
645
|
case 429:
|
|
646
|
-
return new (0,
|
|
646
|
+
return new (0, _chunkK7E34Q3Ajs.RateLimitError)(SCHEME);
|
|
647
647
|
case 404:
|
|
648
|
-
return new (0,
|
|
648
|
+
return new (0, _chunkK7E34Q3Ajs.ModelError)(model, SCHEME);
|
|
649
649
|
}
|
|
650
|
-
if (status >= 500) return new (0,
|
|
650
|
+
if (status >= 500) return new (0, _chunkK7E34Q3Ajs.HTTPStatusError)(status, message);
|
|
651
651
|
return api;
|
|
652
652
|
}
|
|
653
653
|
function anthropicFactory(cfg) {
|
|
@@ -660,7 +660,7 @@ function anthropicFactory(cfg) {
|
|
|
660
660
|
close: () => a.close()
|
|
661
661
|
};
|
|
662
662
|
}
|
|
663
|
-
|
|
663
|
+
_chunkK7E34Q3Ajs.register.call(void 0, SCHEME, anthropicFactory, { endpoints: [ANTHROPIC_DEFAULT_BASE_URL] });
|
|
664
664
|
|
|
665
665
|
|
|
666
666
|
|
|
@@ -832,7 +832,10 @@ function flagsOf(root, chain) {
|
|
|
832
832
|
for (let i = chain.length - 2; i >= 0; i--) {
|
|
833
833
|
const anc = chain[i];
|
|
834
834
|
if (internals(anc)._enablePositionalOptions) break;
|
|
835
|
-
for (const o of anc.options)
|
|
835
|
+
for (const o of anc.options) {
|
|
836
|
+
if (internals(anc)._versionOptionName === o.attributeName()) continue;
|
|
837
|
+
out.push(toFlag(o, anc, root, true));
|
|
838
|
+
}
|
|
836
839
|
}
|
|
837
840
|
if (isShim(root, cmd)) {
|
|
838
841
|
out.push({
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
var
|
|
6
|
+
var _chunkK7E34Q3Ajs = require('./chunk-K7E34Q3A.js');
|
|
7
7
|
|
|
8
8
|
// src/llm-http.ts
|
|
9
9
|
var DEFAULT_MAX_BODY_BYTES = 32 << 20;
|
|
@@ -21,7 +21,7 @@ function limitsFrom(provider, params) {
|
|
|
21
21
|
const t = v.trim();
|
|
22
22
|
const n = Number(t);
|
|
23
23
|
if (!/^\d+$/.test(t) || !Number.isSafeInteger(n) || n <= 0) {
|
|
24
|
-
throw new (0,
|
|
24
|
+
throw new (0, _chunkK7E34Q3Ajs.LLMError)(`${provider}: ${name} must be a positive byte count`);
|
|
25
25
|
}
|
|
26
26
|
l[key] = n;
|
|
27
27
|
}
|
|
@@ -48,7 +48,7 @@ async function post(opts, url, headers, body) {
|
|
|
48
48
|
}
|
|
49
49
|
if (resp.status >= 300 && resp.status < 400) {
|
|
50
50
|
await _optionalChain([resp, 'access', _2 => _2.body, 'optionalAccess', _3 => _3.cancel, 'call', _4 => _4(), 'access', _5 => _5.catch, 'call', _6 => _6(() => void 0)]);
|
|
51
|
-
throw new (0,
|
|
51
|
+
throw new (0, _chunkK7E34Q3Ajs.HTTPStatusError)(resp.status, `${opts.provider}: redirect not followed`);
|
|
52
52
|
}
|
|
53
53
|
if (resp.ok) return resp;
|
|
54
54
|
const text = await readBody(resp, opts.limits.body, opts.provider).catch(
|
|
@@ -65,7 +65,7 @@ async function post(opts, url, headers, body) {
|
|
|
65
65
|
status: resp.status,
|
|
66
66
|
statusText: resp.statusText,
|
|
67
67
|
headers: resp.headers,
|
|
68
|
-
body:
|
|
68
|
+
body: _chunkK7E34Q3Ajs.scrubSecrets.call(void 0, text, opts.secrets)
|
|
69
69
|
}),
|
|
70
70
|
opts.secrets
|
|
71
71
|
);
|
|
@@ -114,14 +114,14 @@ function sleep(ms) {
|
|
|
114
114
|
function networkError(provider, err) {
|
|
115
115
|
const cause = err.cause;
|
|
116
116
|
const detail = _nullishCoalesce(_nullishCoalesce(_optionalChain([cause, 'optionalAccess', _7 => _7.message]), () => ( _optionalChain([err, 'optionalAccess', _8 => _8.message]))), () => ( String(err)));
|
|
117
|
-
const e = new (0,
|
|
117
|
+
const e = new (0, _chunkK7E34Q3Ajs.LLMError)(`${provider}: request failed: ${detail}`);
|
|
118
118
|
if (_optionalChain([cause, 'optionalAccess', _9 => _9.code])) e.code = cause.code;
|
|
119
119
|
return e;
|
|
120
120
|
}
|
|
121
121
|
function scrubError(err, secrets) {
|
|
122
122
|
if (!(err instanceof Error) || secrets.length === 0) return err;
|
|
123
|
-
err.message =
|
|
124
|
-
if (err.stack) err.stack =
|
|
123
|
+
err.message = _chunkK7E34Q3Ajs.scrubSecrets.call(void 0, err.message, secrets);
|
|
124
|
+
if (err.stack) err.stack = _chunkK7E34Q3Ajs.scrubSecrets.call(void 0, err.stack, secrets);
|
|
125
125
|
const cause = err.cause;
|
|
126
126
|
if (cause instanceof Error && cause !== err) scrubError(cause, secrets);
|
|
127
127
|
return err;
|
|
@@ -138,7 +138,7 @@ async function readBody(resp, max, provider) {
|
|
|
138
138
|
read += value.byteLength;
|
|
139
139
|
if (read > max) {
|
|
140
140
|
await reader.cancel().catch(() => void 0);
|
|
141
|
-
throw new (0,
|
|
141
|
+
throw new (0, _chunkK7E34Q3Ajs.ResponseTooLargeError)(provider, "body", max);
|
|
142
142
|
}
|
|
143
143
|
chunks.push(value);
|
|
144
144
|
}
|
|
@@ -177,7 +177,7 @@ async function* sseEvents(resp, max, provider) {
|
|
|
177
177
|
continue;
|
|
178
178
|
}
|
|
179
179
|
eventBytes += nonCR(line) + 1;
|
|
180
|
-
if (eventBytes > max) throw new (0,
|
|
180
|
+
if (eventBytes > max) throw new (0, _chunkK7E34Q3Ajs.ResponseTooLargeError)(provider, "event", max);
|
|
181
181
|
const text = decoder.decode(line);
|
|
182
182
|
if (text.startsWith(":")) continue;
|
|
183
183
|
const colon = text.indexOf(":");
|
|
@@ -188,7 +188,7 @@ async function* sseEvents(resp, max, provider) {
|
|
|
188
188
|
else if (field === "data") data.push(v);
|
|
189
189
|
}
|
|
190
190
|
if (eventBytes + nonCR(buf) > max) {
|
|
191
|
-
throw new (0,
|
|
191
|
+
throw new (0, _chunkK7E34Q3Ajs.ResponseTooLargeError)(provider, "event", max);
|
|
192
192
|
}
|
|
193
193
|
if (done) {
|
|
194
194
|
finished = true;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }// src/sideeffect.ts
|
|
2
|
+
var SIDE_EFFECT_ANNOTATION = "kit/side-effect";
|
|
3
|
+
var SIDE_EFFECT_TIERS = [
|
|
4
|
+
"read",
|
|
5
|
+
"write",
|
|
6
|
+
"write-local",
|
|
7
|
+
"write-shared",
|
|
8
|
+
"destructive",
|
|
9
|
+
"destructive-local",
|
|
10
|
+
"destructive-shared",
|
|
11
|
+
"interactive"
|
|
12
|
+
];
|
|
13
|
+
var INFERRED_TIER = "destructive-shared";
|
|
14
|
+
var WRITE_LIKE = /* @__PURE__ */ new Set(["write", "write-local", "write-shared"]);
|
|
15
|
+
var DESTRUCTIVE_LIKE = /* @__PURE__ */ new Set([
|
|
16
|
+
"destructive",
|
|
17
|
+
"destructive-local",
|
|
18
|
+
"destructive-shared"
|
|
19
|
+
]);
|
|
20
|
+
function isWriteLike(tier) {
|
|
21
|
+
return WRITE_LIKE.has(tier);
|
|
22
|
+
}
|
|
23
|
+
function isDestructiveLike(tier) {
|
|
24
|
+
return DESTRUCTIVE_LIKE.has(tier);
|
|
25
|
+
}
|
|
26
|
+
function isValidSideEffect(tier) {
|
|
27
|
+
return SIDE_EFFECT_TIERS.includes(tier);
|
|
28
|
+
}
|
|
29
|
+
var DESTRUCTIVE_NAMES = /* @__PURE__ */ new Set([
|
|
30
|
+
"delete",
|
|
31
|
+
"remove",
|
|
32
|
+
"rm",
|
|
33
|
+
"destroy",
|
|
34
|
+
"purge",
|
|
35
|
+
"drop"
|
|
36
|
+
]);
|
|
37
|
+
function isDestructiveName(name) {
|
|
38
|
+
return DESTRUCTIVE_NAMES.has(name);
|
|
39
|
+
}
|
|
40
|
+
function destructiveNames() {
|
|
41
|
+
return [...DESTRUCTIVE_NAMES].sort();
|
|
42
|
+
}
|
|
43
|
+
function inferredDestructive(name, annotations) {
|
|
44
|
+
const declared = _optionalChain([annotations, 'optionalAccess', _ => _[SIDE_EFFECT_ANNOTATION]]);
|
|
45
|
+
if (declared !== void 0 && declared !== "") return false;
|
|
46
|
+
return isDestructiveName(name);
|
|
47
|
+
}
|
|
48
|
+
function gateSideEffect(name, annotations) {
|
|
49
|
+
if (inferredDestructive(name, annotations)) return INFERRED_TIER;
|
|
50
|
+
const declared = _optionalChain([annotations, 'optionalAccess', _2 => _2[SIDE_EFFECT_ANNOTATION]]);
|
|
51
|
+
return declared === void 0 ? void 0 : declared;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
exports.SIDE_EFFECT_ANNOTATION = SIDE_EFFECT_ANNOTATION; exports.SIDE_EFFECT_TIERS = SIDE_EFFECT_TIERS; exports.INFERRED_TIER = INFERRED_TIER; exports.isWriteLike = isWriteLike; exports.isDestructiveLike = isDestructiveLike; exports.isValidSideEffect = isValidSideEffect; exports.isDestructiveName = isDestructiveName; exports.destructiveNames = destructiveNames; exports.inferredDestructive = inferredDestructive; exports.gateSideEffect = gateSideEffect;
|
|
@@ -15,7 +15,10 @@
|
|
|
15
15
|
var _chunkSNVGDYX7js = require('./chunk-SNVGDYX7.js');
|
|
16
16
|
|
|
17
17
|
|
|
18
|
-
var
|
|
18
|
+
var _chunkCXBZTONYjs = require('./chunk-CXBZTONY.js');
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
var _chunkGFRAYYRDjs = require('./chunk-GFRAYYRD.js');
|
|
19
22
|
|
|
20
23
|
|
|
21
24
|
|
|
@@ -138,13 +141,14 @@ var DRY_RUN_SIDE_EFFECTS = /* @__PURE__ */ new Set([
|
|
|
138
141
|
"destructive-local",
|
|
139
142
|
"destructive-shared"
|
|
140
143
|
]);
|
|
141
|
-
function dryRunSupported(ann) {
|
|
144
|
+
function dryRunSupported(name, ann) {
|
|
142
145
|
switch (ann["kit/dry-run"]) {
|
|
143
146
|
case "opted-out":
|
|
144
147
|
return false;
|
|
145
148
|
case "supported":
|
|
146
149
|
return true;
|
|
147
150
|
}
|
|
151
|
+
if (_chunkCXBZTONYjs.inferredDestructive.call(void 0, name, ann)) return true;
|
|
148
152
|
return DRY_RUN_SIDE_EFFECTS.has(_nullishCoalesce(ann["kit/side-effect"], () => ( "")));
|
|
149
153
|
}
|
|
150
154
|
function manifestFlags(cmd, ann, withHelp) {
|
|
@@ -237,7 +241,7 @@ function manifestCommand(cmd, path, hidden, reserved, invoked) {
|
|
|
237
241
|
if (ann["kit/passthrough"] === "true") out.passthrough = true;
|
|
238
242
|
const token = ann["kit/destructive-token"];
|
|
239
243
|
if (token === "required" || token === "true") out.destructive_token_required = true;
|
|
240
|
-
out.dry_run_supported = dryRunSupported(ann);
|
|
244
|
+
out.dry_run_supported = dryRunSupported(cmd.name(), ann);
|
|
241
245
|
if (ann["kit/dry-run-rationale"]) out.dry_run_rationale = ann["kit/dry-run-rationale"];
|
|
242
246
|
if (reserved) out.reserved = true;
|
|
243
247
|
if (hidden) out.hidden = true;
|
|
@@ -502,7 +506,7 @@ function captureRender(format, v) {
|
|
|
502
506
|
return true;
|
|
503
507
|
}
|
|
504
508
|
};
|
|
505
|
-
|
|
509
|
+
_chunkGFRAYYRDjs.render.call(void 0, sink, format, v);
|
|
506
510
|
return buf;
|
|
507
511
|
}
|
|
508
512
|
function registerCoverageCommand(spec, program, reserved) {
|