@hop-top/kit 0.5.0-alpha.2 → 0.5.0-alpha.4
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 +60 -0
- package/LICENSE +1 -1
- package/README.md +48 -480
- package/dist/{aim-CTp-kJW2.d.ts → aim-DZHwwiIc.d.ts} +1 -1
- package/dist/aim.d.ts +1 -1
- package/dist/aim.js +13 -414
- package/dist/{alias-dhhr08Ei.d.ts → alias-BOj0-VAr.d.ts} +1 -1
- package/dist/alias.d.ts +1 -1
- package/dist/alias.js +18 -206
- package/dist/{api-miiso81x.d.ts → api-DAexsu2H.d.ts} +1 -1
- package/dist/api.d.ts +1 -1
- package/dist/api.js +10 -164
- package/dist/auth.js +6 -40
- package/dist/chunk-3FIKGFKI.js +54 -0
- package/dist/chunk-4UE5TCMQ.js +104 -0
- package/dist/chunk-6HFAEZ52.js +29 -0
- package/dist/chunk-6SVOHNIC.js +17 -0
- package/dist/chunk-72XZWQX7.js +504 -0
- package/dist/chunk-ABQSE7AI.js +513 -0
- package/dist/chunk-BDNNPRX6.js +41 -0
- package/dist/chunk-BRNEKPWX.js +37 -0
- package/dist/chunk-CSJWB6D3.js +151 -0
- package/dist/chunk-GGWJRWWA.js +309 -0
- package/dist/chunk-IQXEISMC.js +142 -0
- package/dist/chunk-JTMPNXVQ.js +1491 -0
- package/dist/chunk-KVG7YCTS.js +115 -0
- package/dist/chunk-L23O2FFE.js +51 -0
- package/dist/chunk-MQXYDYRD.js +968 -0
- package/dist/chunk-MUIQVU6E.js +251 -0
- package/dist/chunk-POR5L2DG.js +247 -0
- package/dist/chunk-PSFYJGDG.js +1445 -0
- package/dist/chunk-QJVSKKRQ.js +369 -0
- package/dist/chunk-QPUCXQXT.js +67 -0
- package/dist/chunk-R5U7XKVJ.js +16 -0
- package/dist/chunk-S45UHXQF.js +182 -0
- package/dist/chunk-T46YPHKN.js +669 -0
- package/dist/chunk-UIOOOK6M.js +334 -0
- package/dist/chunk-UKZIAQA7.js +26 -0
- package/dist/chunk-WBVO43HU.js +355 -0
- package/dist/chunk-WTYDHXPW.js +574 -0
- package/dist/chunk-WUOAQVOA.js +86 -0
- package/dist/chunk-WWUKGJB5.js +90 -0
- package/dist/chunk-YGYQUFGY.js +219 -0
- package/dist/chunk-YOBAUCVN.js +583 -0
- package/dist/{cli-DgOEOsPB.d.ts → cli-8rfITnv4.d.ts} +13 -4
- package/dist/cli.d.ts +4 -3
- package/dist/cli.js +50 -1056
- package/dist/{config-BUY7_W2n.d.ts → config-Bm9fBXch.d.ts} +35 -4
- package/dist/config.d.ts +1 -1
- package/dist/config.js +6 -78
- package/dist/errcorrect.js +8 -68
- package/dist/error-Do8Qji43.d.ts +231 -0
- package/dist/id/index.d.ts +1 -1
- package/dist/id/index.js +14 -65
- package/dist/{index-MLrRDvEG.d.ts → index-B-pqGHhU.d.ts} +113 -19
- package/dist/{index--C7Mtsmm.d.ts → index-DEyjGoo2.d.ts} +1 -1
- package/dist/{index-QSffbLnj.d.ts → index-VLDcI5NF.d.ts} +3 -2
- package/dist/index.d.ts +18 -13
- package/dist/index.js +40 -5792
- package/dist/llm-DYuR7_uX.d.ts +1069 -0
- package/dist/llm-anthropic-Cd_I2xXB.d.ts +67 -0
- package/dist/llm-anthropic.d.ts +2 -0
- package/dist/llm-anthropic.js +13 -0
- package/dist/llm-openai-DyFrucmV.d.ts +87 -0
- package/dist/llm-openai.d.ts +2 -0
- package/dist/llm-openai.js +19 -0
- package/dist/llm.d.ts +1 -1
- package/dist/llm.js +101 -356
- package/dist/mcp/index.d.ts +2 -1
- package/dist/mcp/index.js +155 -1453
- package/dist/{netpolicy-asvCfwi8.d.ts → netpolicy-Brx5XZUB.d.ts} +16 -3
- package/dist/netpolicy.d.ts +1 -1
- package/dist/netpolicy.js +25 -118
- package/dist/{output-VFFLqor9.d.ts → output-CjZWmL8s.d.ts} +29 -130
- package/dist/output.d.ts +2 -1
- package/dist/output.js +137 -958
- package/dist/progress.js +6 -55
- package/dist/provenance.js +6 -31
- package/dist/routellm-B0nv59mH.d.ts +111 -0
- package/dist/routellm.d.ts +2 -2
- package/dist/routellm.js +13 -255
- package/dist/{rpc-D5xLEf8V.d.ts → rpc-D31Lg0Kc.d.ts} +1 -1
- package/dist/rpc.d.ts +2 -2
- package/dist/rpc.js +4 -98
- package/dist/safety.js +6 -43
- package/dist/scope.js +20 -377
- package/dist/serve-D8yWMrTc.d.ts +646 -0
- package/dist/serve.d.ts +3 -0
- package/dist/serve.js +75 -0
- package/dist/sqlstore.js +6 -39
- package/dist/stream.js +8 -51
- package/dist/telemetry/index.js +24 -608
- package/dist/tui/index.d.ts +5 -4
- package/dist/tui/index.js +17 -373
- package/dist/upgrade.js +6 -114
- package/dist/xdg.js +14 -128
- package/package.json +135 -25
- package/src/README.md +15 -0
- package/src/cli.test.ts +56 -1
- package/src/cli.ts +24 -4
- package/src/completion-values.test.ts +10 -10
- package/src/compliance.test.ts +196 -2
- package/src/compliance.ts +440 -20
- package/src/config.test.ts +187 -1
- package/src/config.ts +173 -7
- package/src/gen/crud_pb.ts +7 -7
- package/src/id/README.md +38 -0
- package/src/id/contract.test.ts +1 -1
- package/src/id/index.test.ts +1 -1
- package/src/id/index.ts +3 -2
- package/src/index.test.ts +12 -0
- package/src/index.ts +3 -0
- package/src/llm-anthropic.conformance.test.ts +1135 -0
- package/src/llm-anthropic.test.ts +152 -0
- package/src/llm-anthropic.ts +940 -0
- package/src/llm-choice-hermetic.test.ts +335 -0
- package/src/llm-config.test.ts +232 -0
- package/src/llm-config.ts +106 -0
- package/src/llm-endpoint.ts +254 -0
- package/src/llm-error.ts +17 -0
- package/src/llm-errors.ts +152 -0
- package/src/llm-file.ts +126 -0
- package/src/llm-http.ts +317 -0
- package/src/llm-keys.ts +167 -0
- package/src/llm-media.conformance.test.ts +87 -0
- package/src/llm-media.test.ts +279 -0
- package/src/llm-media.ts +322 -0
- package/src/llm-openai.conformance.test.ts +407 -0
- package/src/llm-openai.test.ts +510 -0
- package/src/llm-openai.ts +708 -0
- package/src/llm-payload.ts +155 -0
- package/src/llm-quote.ts +46 -0
- package/src/llm-routellm.conformance.test.ts +44 -0
- package/src/llm-toolnames.conformance.test.ts +112 -0
- package/src/llm-toolnames.test.ts +132 -0
- package/src/llm-toolnames.ts +298 -0
- package/src/llm-uri.ts +99 -0
- package/src/llm.test.ts +43 -15
- package/src/llm.toolcall.test.ts +175 -0
- package/src/llm.ts +602 -190
- package/src/mcp/README.md +57 -0
- package/src/mcp/conformance.test.ts +24 -3
- package/src/mcp/dispatch.ts +4 -4
- package/src/mcp/identity.test.ts +166 -0
- package/src/mcp/identity.ts +72 -0
- package/src/mcp/index.ts +6 -0
- package/src/mcp/legacy.ts +21 -8
- package/src/mcp/mcp.test.ts +14 -4
- package/src/mcp/modern-confirm.ts +1 -1
- package/src/mcp/modern.ts +12 -11
- package/src/mcp/tasks.ts +1 -1
- package/src/mcp/types.ts +80 -8
- package/src/netpolicy.test.ts +78 -0
- package/src/netpolicy.ts +28 -3
- package/src/output/README.md +46 -0
- package/src/output/builtins.ts +5 -5
- package/src/output/error.ts +167 -1
- package/src/output/formatters/README.md +50 -0
- package/src/output.ts +26 -1
- package/src/published-types.test.ts +115 -0
- package/src/routellm.test.ts +209 -28
- package/src/routellm.toolcall.test.ts +521 -0
- package/src/routellm.ts +213 -177
- package/src/router/README.md +44 -0
- package/src/router/server.test.ts +41 -0
- package/src/router/server.ts +11 -0
- package/src/safety.test.ts +19 -9
- package/src/scope-defaults.json +29 -29
- package/src/serve.test.ts +1257 -0
- package/src/serve.ts +1665 -0
- package/src/telemetry/README.md +48 -0
- package/src/telemetry/client.ts +5 -5
- package/src/toolspec.test.ts +2 -2
- package/src/triton/README.md +34 -0
- package/src/tui/README.md +42 -0
- package/src/wizard.test.ts +7 -7
- package/test/llm/conformance-helpers.ts +100 -0
- package/test/output/dispatch.test.ts +1 -2
- package/test/output/error.test.ts +38 -2
- package/test/output/smoke-capture.ts +2 -2
- package/test/output/smoke.test.ts +2 -2
- package/test/output/taxonomy-contract.test.ts +148 -0
- package/test/setup-env.ts +16 -0
- package/tsconfig.json +3 -1
- package/tsconfig.test.json +10 -0
- package/vitest.config.ts +9 -0
- package/dist/llm-B5XUWH8T.d.ts +0 -231
- package/dist/routellm-PGSt2D1y.d.ts +0 -75
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,66 @@ 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.4](https://github.com/hop-top/poly-kit/compare/kit-ts/v0.5.0-alpha.3...kit-ts/v0.5.0-alpha.4) (2026-10-29)
|
|
8
|
+
|
|
9
|
+
The hop-top team is happy to announce Kit's TS SDK 0.5.0-alpha.4. This release includes new features and bug fixes.
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
### ⚠ BREAKING CHANGES
|
|
13
|
+
|
|
14
|
+
* **ts:** TS routellm URI base_url / provider base URL now beats ROUTELLM_BASE_URL and extras routellm.base_url.
|
|
15
|
+
* **llm:** openai stream caps, truncation error, StreamWithTools
|
|
16
|
+
* **ts:** URI api_key outranks LLM_API_KEY; URI base_url/host outrank LLM_BASE_URL; params no longer percent-decoded; empty model parses; parse error texts changed; LLM_API_KEY not lent to routellm, lmstudio or unregistered schemes; llm.yaml now read; an env key no longer reaches a URI-named endpoint trusted only via ANTHROPIC_BASE_URL.
|
|
17
|
+
* **ts:** a 403 is now PermissionDeniedError (still instanceof AuthError, message "permission denied ..."); anthropic sends every system message joined instead of only the last
|
|
18
|
+
* **ts:** RouteLLMAdapter.stream returns a ToolStream (async iterable) instead of an AsyncGenerator; tokens carry text only, one final done token; errors are typed (AuthError, RateLimitError, ModelError, HTTPStatusError, APIError) instead of LLMError text; 429/5xx are retried; a key over plain http to a remote host is refused.
|
|
19
|
+
|
|
20
|
+
### Features
|
|
21
|
+
|
|
22
|
+
* **llm:** gemini StreamWithTools with tool-call and usage stream events ([d9dacad](https://github.com/hop-top/poly-kit/commit/d9dacad263b20945a27fedbf66605b6b6d10e319))
|
|
23
|
+
* **llm:** openai stream caps, truncation error, StreamWithTools ([a72eaf2](https://github.com/hop-top/poly-kit/commit/a72eaf2493d4404b45e623401385894d4896f367))
|
|
24
|
+
* **ts/llm:** openai stream events and stream_options ([68266c3](https://github.com/hop-top/poly-kit/commit/68266c3ad01aef1e2c28288f6f4beba2a895613f))
|
|
25
|
+
* **ts:** accept routellm tier names in model field ([aecd6bb](https://github.com/hop-top/poly-kit/commit/aecd6bb5bffbc49566d46b3f4d0ad87b0f518cf6))
|
|
26
|
+
* **ts:** anthropic adapter with tool calling ([ed450ef](https://github.com/hop-top/poly-kit/commit/ed450efef40ec8397090b4dd17587f5e3001c1d4))
|
|
27
|
+
* **ts:** llm core for provider adapters ([17c6b96](https://github.com/hop-top/poly-kit/commit/17c6b96c474dae655cd76f23920bc71c7f6a2e87))
|
|
28
|
+
* **ts:** llm parseURI, llm.yaml and key resolution as in Go ([50d2f39](https://github.com/hop-top/poly-kit/commit/50d2f3934db7ad18086d4bc19dffe688d1e63b53))
|
|
29
|
+
* **ts:** llm stream events, tool_choice, hermetic mode, 403 split, system joining ([41b7051](https://github.com/hop-top/poly-kit/commit/41b705112fe88a0e13b8c0202007563a1716cc2d))
|
|
30
|
+
* **ts:** openai adapter; routellm tool calling through it ([13042f0](https://github.com/hop-top/poly-kit/commit/13042f01debc39393a30dbf5a3b134ac360c01d8))
|
|
31
|
+
* **ts:** tool-name validation and reversible sanitizing ([e484b1c](https://github.com/hop-top/poly-kit/commit/e484b1cd23b80dff7fe9898b59765161995fd16f))
|
|
32
|
+
* **ts:** tool-name validation and reversible sanitizing ([#579](https://github.com/hop-top/poly-kit/issues/579)) ([e484b1c](https://github.com/hop-top/poly-kit/commit/e484b1cd23b80dff7fe9898b59765161995fd16f))
|
|
33
|
+
* **ts:** validate and reversibly sanitize llm tool names ([bc18b50](https://github.com/hop-top/poly-kit/commit/bc18b5057f68b2250e1758951adb83011aae9b2d))
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
### Bug Fixes
|
|
37
|
+
|
|
38
|
+
* **deps:** npm lockfile advisories ([2950eb5](https://github.com/hop-top/poly-kit/commit/2950eb594c6c0a27846828c82d63b442cad12181))
|
|
39
|
+
* **llm:** send anthropic media urls as url sources; media_fetch vectors ([c1600dd](https://github.com/hop-top/poly-kit/commit/c1600dd6ad41a40e10fac7d08b644abbbc8af727))
|
|
40
|
+
* **ts/config:** bound alias expansion and nesting in load ([f6dd39a](https://github.com/hop-top/poly-kit/commit/f6dd39a168706e9cd7f4f42fb8a5b4a3b08948f1))
|
|
41
|
+
* **ts/config:** merge nested objects across layers ([0e9a7f4](https://github.com/hop-top/poly-kit/commit/0e9a7f41a4304a7507b140e13492e06ee9a0698f))
|
|
42
|
+
* **ts:** guard URL media fetches against SSRF ([dd73a22](https://github.com/hop-top/poly-kit/commit/dd73a2282504b7d04ddc3b5b228196750d88bcc6))
|
|
43
|
+
* **ts:** routellm base URL precedence matches Go ([16e9cb6](https://github.com/hop-top/poly-kit/commit/16e9cb68283d98090722d3c9109d7f43c64fc7c6))
|
|
44
|
+
|
|
45
|
+
Full diff: [kit-ts/v0.5.0-alpha.3...kit-ts/v0.5.0-alpha.4](https://github.com/hop-top/poly-kit/compare/kit-ts/v0.5.0-alpha.3...kit-ts/v0.5.0-alpha.4)
|
|
46
|
+
|
|
47
|
+
## [0.5.0-alpha.3](https://github.com/hop-top/poly-kit/compare/kit-ts/v0.5.0-alpha.2...kit-ts/v0.5.0-alpha.3) (2026-09-05)
|
|
48
|
+
|
|
49
|
+
The hop-top team is happy to announce Kit's TS SDK 0.5.0-alpha.3. This release includes new features and bug fixes.
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
### Features
|
|
53
|
+
|
|
54
|
+
* **sdk:** EXIT_GENERIC and generic error constructor in all SDKs
|
|
55
|
+
* **ts:** EXIT_GENERIC and genericError for the exit-1 class
|
|
56
|
+
* **ts:** serve --enable/--disable and timeout flags
|
|
57
|
+
* **ts:** serve cross-language contract and TypeScript implementation
|
|
58
|
+
* **ts:** serve hierarchy and service lifecycle
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
### Bug Fixes
|
|
62
|
+
|
|
63
|
+
* **parity:** record and implement serve --enable/--disable and timeout flags
|
|
64
|
+
|
|
65
|
+
Full diff: [kit-ts/v0.5.0-alpha.2...kit-ts/v0.5.0-alpha.3](https://github.com/hop-top/poly-kit/compare/kit-ts/v0.5.0-alpha.2...kit-ts/v0.5.0-alpha.3)
|
|
66
|
+
|
|
7
67
|
## [0.5.0-alpha.2](https://github.com/hop-top/poly-kit/compare/kit-ts/v0.5.0-alpha.1...kit-ts/v0.5.0-alpha.2) (2026-09-04)
|
|
8
68
|
|
|
9
69
|
The hop-top team is happy to announce Kit's TS SDK 0.5.0-alpha.2. This release includes new features and bug fixes.
|
package/LICENSE
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
MIT License
|
|
2
2
|
|
|
3
3
|
Copyright (c) 2026 Idea Crafters LLC <open@ideacrafters.com>
|
|
4
|
-
Copyright (c) 2026
|
|
4
|
+
Copyright (c) 2026 Jad Bitar <https://github.com/jadb>
|
|
5
5
|
|
|
6
6
|
Permission is hereby granted, free of charge, to any person
|
|
7
7
|
obtaining a copy of this software and associated documentation
|
package/README.md
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
# @hop-top/kit (TypeScript)
|
|
2
2
|
|
|
3
|
-
Shared CLI utilities for hop-top tools
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
checks, LLM helpers, alias resolution, and a TUI toolkit.
|
|
3
|
+
Shared CLI utilities for hop-top tools, CommonJS edition. Mirrors the Go
|
|
4
|
+
`kit` package surface: a Commander-based CLI factory, output formatting
|
|
5
|
+
with a registry/Formatter contract, theming, hint plumbing, XDG paths,
|
|
6
|
+
config files, an embedded SQLite store, upgrade checks, LLM helpers,
|
|
7
|
+
alias resolution, and a TUI toolkit.
|
|
9
8
|
|
|
10
9
|
## Install
|
|
11
10
|
|
|
@@ -13,500 +12,69 @@ checks, LLM helpers, alias resolution, and a TUI toolkit.
|
|
|
13
12
|
pnpm add @hop-top/kit
|
|
14
13
|
```
|
|
15
14
|
|
|
16
|
-
Subpath imports follow the package's `exports` map (see
|
|
17
|
-
`
|
|
18
|
-
`@hop-top/kit/xdg`, `@hop-top/kit/uri`,
|
|
19
|
-
|
|
20
|
-
## Output formatting
|
|
21
|
-
|
|
22
|
-
The `output` module ships a Formatter + Registry contract identical to
|
|
23
|
-
the Go `go/console/output` package, plus a Commander integration layer
|
|
24
|
-
that wires the standard flag suite onto your program.
|
|
25
|
-
|
|
26
|
-
### Built-in formatters
|
|
15
|
+
Subpath imports follow the package's `exports` map (see `package.json`),
|
|
16
|
+
mirrored in `typesVersions` for `moduleResolution: node10`: `@hop-top/kit/cli`,
|
|
17
|
+
`@hop-top/kit/output`, `@hop-top/kit/xdg`, `@hop-top/kit/uri`, and so on.
|
|
27
18
|
|
|
28
|
-
|
|
29
|
-
| ------- | -------------- | --------------------------------------------------------------------------------- |
|
|
30
|
-
| `json` | `.json` | `indent` (int, default 2) |
|
|
31
|
-
| `yaml` | `.yaml`, `.yml`| `flow-level` (int, default -1) |
|
|
32
|
-
| `table` | (none) | (none) |
|
|
33
|
-
| `csv` | `.csv` | `delimiter` (string), `no-header` (bool), `quote-all` (bool), `crlf` (bool) |
|
|
34
|
-
| `text` | `.txt` | `style` (enum kv\|lines\|paragraph), `separator` (string, kv only) |
|
|
35
|
-
|
|
36
|
-
### Wiring into a Commander CLI
|
|
19
|
+
## Quick start
|
|
37
20
|
|
|
38
21
|
```ts
|
|
39
|
-
import {
|
|
22
|
+
import { createCLI } from '@hop-top/kit/cli';
|
|
40
23
|
import { registerOutputFlags, dispatch } from '@hop-top/kit/output';
|
|
41
24
|
|
|
42
|
-
const program =
|
|
25
|
+
const { program } = createCLI({
|
|
26
|
+
name: 'mytool', version: '1.0.0', description: 'does things',
|
|
27
|
+
});
|
|
43
28
|
registerOutputFlags(program);
|
|
44
29
|
|
|
45
30
|
program.command('list').action(async () => {
|
|
46
31
|
await dispatch(program, [{ id: '1', name: 'Alice' }]);
|
|
47
32
|
});
|
|
48
33
|
|
|
49
|
-
program.
|
|
50
|
-
```
|
|
51
|
-
|
|
52
|
-
`registerOutputFlags` adds the full suite — opt-out per flag via
|
|
53
|
-
`{ disable: { format?, formatOpt?, formatHelp?, cols?, template?, output? } }`.
|
|
54
|
-
|
|
55
|
-
### Flag surface
|
|
56
|
-
|
|
57
|
-
- `--format <fmt>` — pick a registered formatter (default `table`).
|
|
58
|
-
- `--format-opt <kv...>` — repeatable key=value pairs validated against
|
|
59
|
-
the active formatter's option specs (e.g. `--format-opt delimiter=';'`).
|
|
60
|
-
Bool keys may omit `=value`.
|
|
61
|
-
- `--format-help [fmt]` — without an argument, list every registered
|
|
62
|
-
formatter; with an argument, print that formatter's options table.
|
|
63
|
-
Short-circuits before render.
|
|
64
|
-
- `--cols`, `--columns <cols...>` — restrict output to the named
|
|
65
|
-
columns. Accepts comma-separated or repeated flags. Honored by all
|
|
66
|
-
five built-ins.
|
|
67
|
-
- `--template <tpl>` — eta template applied to results. Mutually
|
|
68
|
-
exclusive with `--cols`. Template input shape: `{ items, cols, data }`.
|
|
69
|
-
See [eta syntax](https://eta.js.org/docs/intro/syntax) — note the
|
|
70
|
-
EJS-style `<%= %>` tags differ from Go's `{{ }}` text/template syntax.
|
|
71
|
-
- `-o`, `--output <path>` — write to a file instead of stdout. Empty
|
|
72
|
-
string or `-` means stdout. Extension inference: when `--format` is
|
|
73
|
-
default and the path's extension matches a registered formatter, that
|
|
74
|
-
formatter is selected (e.g. `-o report.csv` → csv). Mismatch is a
|
|
75
|
-
hard error (e.g. `--format json -o report.csv`).
|
|
76
|
-
|
|
77
|
-
### Programmatic Formatter API
|
|
78
|
-
|
|
79
|
-
```ts
|
|
80
|
-
import {
|
|
81
|
-
defaultRegistry,
|
|
82
|
-
Registry,
|
|
83
|
-
type Formatter,
|
|
84
|
-
} from '@hop-top/kit/output';
|
|
85
|
-
|
|
86
|
-
// Custom formatter:
|
|
87
|
-
const htmlFormatter: Formatter = {
|
|
88
|
-
key: 'html',
|
|
89
|
-
extensions: ['.html'],
|
|
90
|
-
options: [],
|
|
91
|
-
render(out, data, _opts, cols) {
|
|
92
|
-
// `cols` is the resolved column list, already ordered — render it in
|
|
93
|
-
// the order given. Empty means "fall back to payload key order".
|
|
94
|
-
// ... render HTML to `out`
|
|
95
|
-
},
|
|
96
|
-
};
|
|
97
|
-
|
|
98
|
-
// Replace a built-in or add a new one:
|
|
99
|
-
defaultRegistry.override(htmlFormatter); // or .register() to fail-loud on dup
|
|
100
|
-
|
|
101
|
-
// Isolated registry for tests/multi-CLI binaries:
|
|
102
|
-
const r = new Registry();
|
|
103
|
-
r.register(htmlFormatter);
|
|
104
|
-
```
|
|
105
|
-
|
|
106
|
-
### Column metadata
|
|
107
|
-
|
|
108
|
-
Go reads column order off struct field declaration order via `table:""`
|
|
109
|
-
tags. TS has no struct tags, so pass an explicit `ColumnSpec[]` list to
|
|
110
|
-
`dispatch` to pin **which columns appear and in what order** — the list
|
|
111
|
-
is what payload-shaped SDKs use in place of Go's field order:
|
|
112
|
-
|
|
113
|
-
```ts
|
|
114
|
-
import type { ColumnSpec } from '@hop-top/kit/output';
|
|
115
|
-
|
|
116
|
-
const userCols: ColumnSpec[] = [
|
|
117
|
-
{ header: 'id', key: 'id', priority: 9 },
|
|
118
|
-
{ header: 'name', key: 'name', priority: 8 },
|
|
119
|
-
{ header: 'notes', key: 'notes', priority: 2 },
|
|
120
|
-
];
|
|
121
|
-
|
|
122
|
-
await dispatch(cmd, users, { columns: userCols });
|
|
123
|
-
```
|
|
124
|
-
|
|
125
|
-
When no `columns` is passed, headers are derived from the first row's
|
|
126
|
-
own enumerable keys.
|
|
127
|
-
|
|
128
|
-
### Column ordering
|
|
129
|
-
|
|
130
|
-
1. **Default order.** With a `ColumnSpec[]` and no `--cols`, column order
|
|
131
|
-
and headers come from the list, in list order. Payload key order is the
|
|
132
|
-
fallback only when no list was supplied.
|
|
133
|
-
2. **`--cols` precedence.** `--cols` reorders as well as selects:
|
|
134
|
-
`--cols status,name` renders `status` then `name`, whatever the list
|
|
135
|
-
says. Same rule on the no-schema fallback path.
|
|
136
|
-
3. **`header` == `key`.** The two are the same name: it is the label, the
|
|
137
|
-
value matched against `--cols`, and the property read off the row. Go
|
|
138
|
-
cannot express a split through `table:""` tags, so no SDK offers one.
|
|
139
|
-
`key` is retained for source compatibility and must equal `header`.
|
|
140
|
-
4. **Empty payload.** Zero rows emits nothing — not even a bare header
|
|
141
|
-
row. Emptiness is decided by row count, never by header count.
|
|
142
|
-
5. **`priority`.** Accepted and stored, currently ignored. Hide-on-overflow
|
|
143
|
-
is implemented in Go only; the payload SDKs will port it separately.
|
|
144
|
-
|
|
145
|
-
`dispatch` applies rules 1 and 2 before calling `render`, so the `cols`
|
|
146
|
-
argument a formatter receives is already the final, ordered column list —
|
|
147
|
-
empty only when it should fall back to payload key order. Custom
|
|
148
|
-
formatters get correct ordering by rendering `cols` in the order given;
|
|
149
|
-
they never see `ColumnSpec` and need no changes.
|
|
150
|
-
|
|
151
|
-
Worked example — the same rows under each rule:
|
|
152
|
-
|
|
153
|
-
```ts
|
|
154
|
-
const rows = [
|
|
155
|
-
{ count: 3, status: 'ready', name: 'alpha' },
|
|
156
|
-
{ count: 8, status: 'held', name: 'beta' },
|
|
157
|
-
];
|
|
158
|
-
const cols: ColumnSpec[] = [
|
|
159
|
-
{ header: 'name', key: 'name', priority: 9 },
|
|
160
|
-
{ header: 'count', key: 'count', priority: 7 },
|
|
161
|
-
{ header: 'status', key: 'status', priority: 5 },
|
|
162
|
-
];
|
|
163
|
-
```
|
|
164
|
-
|
|
165
|
-
With `columns: cols` and no `--cols`, the list drives order — note the
|
|
166
|
-
payload's own key order is `count, status, name` and is not what appears
|
|
167
|
-
(rule 1):
|
|
168
|
-
|
|
169
|
-
```
|
|
170
|
-
name count status
|
|
171
|
-
alpha 3 ready
|
|
172
|
-
beta 8 held
|
|
173
|
-
```
|
|
174
|
-
|
|
175
|
-
`--cols status,name` reorders as well as selects (rule 2), in `table`
|
|
176
|
-
and `json` alike:
|
|
177
|
-
|
|
178
|
-
```
|
|
179
|
-
status name
|
|
180
|
-
ready alpha
|
|
181
|
-
held beta
|
|
182
|
-
```
|
|
183
|
-
|
|
184
|
-
```json
|
|
185
|
-
[
|
|
186
|
-
{
|
|
187
|
-
"status": "ready",
|
|
188
|
-
"name": "alpha"
|
|
189
|
-
},
|
|
190
|
-
{
|
|
191
|
-
"status": "held",
|
|
192
|
-
"name": "beta"
|
|
193
|
-
}
|
|
194
|
-
]
|
|
195
|
-
```
|
|
196
|
-
|
|
197
|
-
With no `columns` at all, payload key order is the fallback:
|
|
198
|
-
|
|
199
|
-
```
|
|
200
|
-
count status name
|
|
201
|
-
3 ready alpha
|
|
202
|
-
8 held beta
|
|
34
|
+
program.parse();
|
|
203
35
|
```
|
|
204
36
|
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|---|---|---|---|
|
|
209
|
-
| Column order source | `table:""` tags, declaration order | `ColumnSpec[]` order | `ColumnSpec` list order |
|
|
210
|
-
| `priority` hide-on-overflow | implemented | accepted, stored, ignored | accepted, stored, ignored |
|
|
211
|
-
| `header != key` | inexpressible via `table:""` | rejected at construction | rejected at construction |
|
|
212
|
-
| json/yaml key order | follows the resolved order | follows the resolved order | follows the resolved order |
|
|
213
|
-
| `--cols` reorders | yes | yes | yes |
|
|
214
|
-
| Built-in formats | `table`, `json`, `yaml`, `csv`, `text` (+ `human`) | same five | `table`, `json`, `yaml` only |
|
|
215
|
-
| Ordered columns on the template path | `.Cols` | `cols` | `{*}` (php); none (rs) |
|
|
216
|
-
|
|
217
|
-
Go's inability to express `header != key` is the *reason* rule 3 binds
|
|
218
|
-
every runtime: no SDK may carry a capability the reference cannot mirror.
|
|
219
|
-
|
|
220
|
-
### Conformance status
|
|
221
|
-
|
|
222
|
-
TS satisfies all five rules, as does Go across all five formats. The
|
|
223
|
-
fixtures under `sdk/tests/cross-lang/` execute the contract against every
|
|
224
|
-
runtime. Two gaps remain open and matter when writing portable code:
|
|
225
|
-
|
|
226
|
-
- **`csv` and `text` do not exist in rs or php.** Only `table`, `json`
|
|
227
|
-
and `yaml` are available in all five runtimes today. The fixtures
|
|
228
|
-
record this as `rs-php-no-csv-text`.
|
|
229
|
-
- **rs has no ordered-column affordance on the `--template` path.** Go
|
|
230
|
-
exposes `.Cols` and py and ts expose `cols`; php has a `{*}`
|
|
231
|
-
placeholder yielding pre-joined values. The spelling for rs is an open
|
|
232
|
-
decision.
|
|
233
|
-
|
|
234
|
-
The fixtures compare the **column order re-parsed from each runtime's own
|
|
235
|
-
output**, never raw bytes — table padding and YAML block style differ
|
|
236
|
-
legitimately between runtimes. Byte-level formatting parity is pinned by
|
|
237
|
-
each SDK's own unit tests instead. `csv` output agrees byte-for-byte
|
|
238
|
-
across go/py/ts in the default LF mode; the `crlf` option exposes known
|
|
239
|
-
quoting divergences.
|
|
240
|
-
|
|
241
|
-
### Backward compatibility
|
|
242
|
-
|
|
243
|
-
The legacy `render(w, format, v)` signature stays. It is now a thin
|
|
244
|
-
shim over `defaultRegistry.lookup(format).render(...)`. Existing
|
|
245
|
-
callers do not need to migrate.
|
|
246
|
-
|
|
247
|
-
```ts
|
|
248
|
-
import { render, JSON_FORMAT } from '@hop-top/kit/output';
|
|
249
|
-
render(process.stdout, JSON_FORMAT, { ok: true });
|
|
250
|
-
```
|
|
251
|
-
|
|
252
|
-
## Other modules
|
|
253
|
-
|
|
254
|
-
- `@hop-top/kit/cli` — `createCLI(cfg)` builds a Commander root program
|
|
255
|
-
with the hop-top contract: `--format`, `--quiet`, `--no-color`,
|
|
256
|
-
`--no-hints`, `--offline`, themed help, version, hidden completion
|
|
257
|
-
command.
|
|
258
|
-
- `@hop-top/kit/netpolicy` — enforcement behind the `--offline` global.
|
|
259
|
-
`createCLI` guards `globalThis.fetch`, so a leaf that never consults
|
|
260
|
-
the marker is still refused; loopback stays reachable. Callers that
|
|
261
|
-
inject their own transport wrap it with `guardFetch`, and socket-level
|
|
262
|
-
clients (`node:net`, SQL drivers, gRPC) consult `isOffline()`
|
|
263
|
-
themselves. Match the refusal with `isOfflineError(err)`.
|
|
264
|
-
- `@hop-top/kit/id` — TypeID primitive (cross-language; see
|
|
265
|
-
[ADR 0001](../../docs/adr/0001-typeid-primitive.md)). Source:
|
|
266
|
-
[`src/id/`](src/id/).
|
|
267
|
-
- `@hop-top/kit/xdg` — XDG Base Directory paths.
|
|
268
|
-
- `@hop-top/kit/config` — config-file loading.
|
|
269
|
-
- `@hop-top/kit/sqlstore` — embedded SQLite key/value store.
|
|
270
|
-
- `@hop-top/kit/upgrade` — semver upgrade detection.
|
|
271
|
-
- `@hop-top/kit/llm` / `routellm` — LLM client + routing helpers.
|
|
272
|
-
- `@hop-top/kit/alias` — alias resolution + completion.
|
|
273
|
-
- `@hop-top/kit/uri` — thin facade over `@hop-top/cite` for URI parsing,
|
|
274
|
-
action resolution, completions, registries, and OS handler metadata.
|
|
275
|
-
- `@hop-top/kit/tui` — TUI toolkit (parity, anim, prompts).
|
|
276
|
-
- `@hop-top/kit/mcp` — dual-spec MCP surface (see [MCP surface](#mcp-surface)).
|
|
277
|
-
|
|
278
|
-
See package.json `exports` for the full list.
|
|
279
|
-
|
|
280
|
-
## MCP surface
|
|
281
|
-
|
|
282
|
-
Serves the Model Context Protocol over a bridged command tree, one MCP
|
|
283
|
-
tool per runnable leaf. A single mount answers **both** revisions —
|
|
284
|
-
`2024-11-05` (handshake) and `2026-07-28` (stateless per-request
|
|
285
|
-
envelope) — choosing per request, because the newer revision has no
|
|
286
|
-
handshake to negotiate with.
|
|
287
|
-
|
|
288
|
-
Wire behaviour is pinned by the shared cross-language fixtures in
|
|
289
|
-
`sdk/tests/cross-lang/fixtures/mcp-wire.json`, compared as raw bytes.
|
|
37
|
+
`createCLI` gives the root the hop-top contract: `--format`, `--quiet`,
|
|
38
|
+
`--no-color`, `--no-hints`, `--offline`, themed help, version, and a
|
|
39
|
+
hidden completion command.
|
|
290
40
|
|
|
291
|
-
|
|
41
|
+
## Modules
|
|
292
42
|
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
43
|
+
| Path | What it is | Start here when |
|
|
44
|
+
|------|------------|-----------------|
|
|
45
|
+
| [`src/output/`](src/output/README.md) | formatter registry and the Commander flag suite | a command renders one payload as table, json, yaml, csv or text |
|
|
46
|
+
| [`src/mcp/`](src/mcp/README.md) | dual-spec MCP surface over a bridged command tree | MCP clients must call your commands as tools |
|
|
47
|
+
| [`src/telemetry/`](src/telemetry/README.md) | consent-gated usage events, redaction, sinks | you record usage under user consent |
|
|
48
|
+
| [`src/id/`](src/id/README.md) | TypeID primitive | you mint or parse prefixed identifiers |
|
|
49
|
+
| [`src/tui/`](src/tui/README.md) | TUI toolkit (parity, anim, prompts) | you build an interactive terminal surface |
|
|
50
|
+
| [`src/router/`](src/router/README.md) | RouteLLM strong/weak model routing and its Hono handler | a prompt must pick a model in-process |
|
|
51
|
+
| [`src/triton/`](src/triton/README.md) | Triton Inference Server client, KServe v2 over HTTP | you call a model hosted on Triton |
|
|
296
52
|
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
`
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
`createMcpHandler` returns a plain async function, not a server. kit
|
|
307
|
-
does not own your HTTP stack, and a pure request-to-response function is
|
|
308
|
-
testable against the fixtures with no socket open.
|
|
309
|
-
|
|
310
|
-
```ts
|
|
311
|
-
import { createMcpHandler, commanderBridge } from '@hop-top/kit/mcp';
|
|
312
|
-
|
|
313
|
-
const bridge = commanderBridge(rootCommand, {
|
|
314
|
-
run: async (inv, cmd) => ({ stdout: await execute(cmd, inv.flags), exitCode: 0 }),
|
|
315
|
-
});
|
|
316
|
-
|
|
317
|
-
const handler = createMcpHandler(bridge, {
|
|
318
|
-
serverInfo: { name: 'my-cli', version: '1.4.0' },
|
|
319
|
-
});
|
|
320
|
-
|
|
321
|
-
const res = await handler({ method: 'POST', headers, body });
|
|
322
|
-
// res: { status, headers, body }
|
|
323
|
-
```
|
|
324
|
-
|
|
325
|
-
`commanderBridge` requires a `run` callback — kit does not dictate how a
|
|
326
|
-
command's output is captured. Bind the handler to node:http, hono,
|
|
327
|
-
express, fastify, or a Worker.
|
|
328
|
-
|
|
329
|
-
### Options
|
|
330
|
-
|
|
331
|
-
`path` (`/mcp`), `serverInfo` (`cmdsurface` / `0.0.0`), `specVersions`
|
|
332
|
-
(both eras), `cacheHints` (`ttlMs` 0, `cacheScope` `private`),
|
|
333
|
-
`originAllowlist` (empty, no check), `confirmationKey`, and `policy`
|
|
334
|
-
(`defaultPolicy()`). The option *set* is normative across every kit SDK;
|
|
335
|
-
only the spelling is idiomatic.
|
|
336
|
-
|
|
337
|
-
An explicitly empty `specVersions`, a negative ttl, an unrecognized
|
|
338
|
-
cache scope, or an empty confirmation key all throw at mount time rather
|
|
339
|
-
than starting a server that quietly serves nothing.
|
|
340
|
-
|
|
341
|
-
### Safety
|
|
342
|
-
|
|
343
|
-
Exposure is gated by `policyAllowed(policy, cls, surface)`. The default
|
|
344
|
-
is deliberately closed: **no remote surface may invoke a destructive
|
|
345
|
-
leaf** — `defaultPolicy()` leaves `allowDestructiveOn` empty, and empty
|
|
346
|
-
means block-all. A blocked call returns an `isError` result at HTTP 200,
|
|
347
|
-
not a transport error: the call was understood and declined, not
|
|
348
|
-
malformed.
|
|
349
|
-
|
|
350
|
-
```ts
|
|
351
|
-
const policy = { allowDestructiveOn: ['mcp'], defaultEnabled: ['cli', 'lib', 'mcp'] };
|
|
352
|
-
```
|
|
353
|
-
|
|
354
|
-
Leaves are classified from `kit/*` annotations: `kit/side-effect`
|
|
355
|
-
(`destructive`, `destructive-local`, `destructive-shared`),
|
|
356
|
-
`kit/auth-required`, `kit/requires-confirmation`.
|
|
357
|
-
|
|
358
|
-
This gate is unrelated to the Factor 10 `safetyGuard` `--force` helper,
|
|
359
|
-
which is a CLI-time TTY check for delegation safety.
|
|
360
|
-
|
|
361
|
-
### Confirmation is header-only in this port
|
|
362
|
-
|
|
363
|
-
A `kit/requires-confirmation` leaf requires an `X-Confirm-Token` header.
|
|
364
|
-
`confirmationKey` is accepted and validated at mount time but **the
|
|
365
|
-
modern handler does not read it** — the MRTR elicitation round-trip that
|
|
366
|
-
Go, Python, Rust and PHP offer is not implemented here yet. Do not plan
|
|
367
|
-
an elicitation flow against this port today.
|
|
368
|
-
|
|
369
|
-
### Scope
|
|
370
|
-
|
|
371
|
-
Deprecated upstream features (Roots, Sampling, Logging, HTTP+SSE) are
|
|
372
|
-
unimplemented, matching the Go reference. `tasks/*` answers `-32601` and
|
|
373
|
-
no `extensions` map is advertised in `server/discover`, which is the
|
|
374
|
-
conformant way to not support it.
|
|
375
|
-
|
|
376
|
-
### Cross-references
|
|
377
|
-
|
|
378
|
-
- [Serve MCP from any SDK](../../docs/adopters/guides/serve-mcp-from-any-sdk.md)
|
|
379
|
-
— the polyglot adopter guide
|
|
380
|
-
- [Expose your CLI over MCP](../../docs/adopters/guides/expose-cli-over-mcp.md)
|
|
381
|
-
— the Go reference surface, in depth
|
|
382
|
-
|
|
383
|
-
## URI facade
|
|
384
|
-
|
|
385
|
-
The URI module delegates to `@hop-top/cite` (`^0.1.0`); it does not
|
|
386
|
-
reimplement the URI contract. It mirrors the kit Go URI command intent
|
|
387
|
-
for SDK consumers:
|
|
388
|
-
|
|
389
|
-
```ts
|
|
390
|
-
import { parse, resolve, complete, handler, newRegistry } from '@hop-top/kit/uri';
|
|
391
|
-
|
|
392
|
-
const policy = {
|
|
393
|
-
schemeNamespaceSegments: { tlc: 2 },
|
|
394
|
-
actionRoutes: {
|
|
395
|
-
'task.claim': {
|
|
396
|
-
command: 'tlc',
|
|
397
|
-
args: ['-C', '{namespace}', 'task', 'claim', '{id}'],
|
|
398
|
-
},
|
|
399
|
-
},
|
|
400
|
-
};
|
|
401
|
-
|
|
402
|
-
const parsed = parse('tlc://hop-top/kit/T-0001?cmd=task&verb=claim', policy);
|
|
403
|
-
const plan = resolve(parsed, policy); // command plan only; never executes
|
|
404
|
-
|
|
405
|
-
const registry = newRegistry(policy);
|
|
406
|
-
registry.register({ name: 'tlc', completer: async () => ['hop-top/kit/T-0001'] });
|
|
407
|
-
const suggestions = await complete(registry, 'tlc', 'tlc://T-');
|
|
408
|
-
|
|
409
|
-
const id = handler.id({
|
|
410
|
-
vendor: 'hop-top',
|
|
411
|
-
app: 'tlc',
|
|
412
|
-
language: 'ts',
|
|
413
|
-
scheme: 'tlc',
|
|
414
|
-
appPath: '/usr/local/bin/tlc',
|
|
415
|
-
});
|
|
416
|
-
```
|
|
417
|
-
|
|
418
|
-
## Telemetry
|
|
419
|
-
|
|
420
|
-
`@hop-top/kit/telemetry` ships the SDK-side primitives for the kit
|
|
421
|
-
telemetry contract: a non-blocking `Client`, a best-effort PII /
|
|
422
|
-
secret redactor, and the consent + install-id readers needed to gate
|
|
423
|
-
emission.
|
|
424
|
-
|
|
425
|
-
**Default-denied**: a fresh install never emits. The `Client.record()`
|
|
426
|
-
call is a no-op unless the operator has run `kit consent grant` AND a
|
|
427
|
-
mode is selected via `KIT_TELEMETRY_MODE=anon|full` (or the prefixed
|
|
428
|
-
`<APP>_TELEMETRY_MODE` equivalent). Inspect what would ship with `kit
|
|
429
|
-
telemetry inspect`.
|
|
430
|
-
|
|
431
|
-
```ts
|
|
432
|
-
import { Client } from '@hop-top/kit/telemetry';
|
|
433
|
-
|
|
434
|
-
const client = new Client({
|
|
435
|
-
sink: 'jsonl', // or 'https'
|
|
436
|
-
sinkFile: '/tmp/kit-events.jsonl', // jsonl sink only
|
|
437
|
-
endpoint: 'https://telemetry.example', // https sink only
|
|
438
|
-
sdkVersion: '1.2.3',
|
|
439
|
-
});
|
|
440
|
-
|
|
441
|
-
// Fire-and-forget. Returns synchronously; never throws.
|
|
442
|
-
client.record('cmd.invoked', { command: 'launch', exit_code: 0 });
|
|
443
|
-
|
|
444
|
-
// Best-effort drain on process exit.
|
|
445
|
-
await client.shutdown(5_000);
|
|
446
|
-
```
|
|
447
|
-
|
|
448
|
-
### Configuration
|
|
449
|
-
|
|
450
|
-
All `ClientOptions` fields are mirrored by env vars (env wins when the
|
|
451
|
-
option is omitted):
|
|
452
|
-
|
|
453
|
-
| Field | Env var | Default |
|
|
454
|
-
| ----------- | ----------------------------- | ---------------------------------------------------- |
|
|
455
|
-
| `endpoint` | `KIT_TELEMETRY_ENDPOINT` | — |
|
|
456
|
-
| `sink` | `KIT_TELEMETRY_SINK` | `jsonl` |
|
|
457
|
-
| `sinkFile` | `KIT_TELEMETRY_SINK_FILE` | `$XDG_STATE_HOME/kit/telemetry/events.jsonl` |
|
|
458
|
-
| `queueSize` | `KIT_TELEMETRY_QUEUE_SIZE` | `1024` |
|
|
459
|
-
|
|
460
|
-
### Redactor
|
|
461
|
-
|
|
462
|
-
The default `redact()` pass scrubs emails, IPv4 / IPv6 addresses, `sk-`
|
|
463
|
-
/ `gh[pousr]_` / `xoxb-` token prefixes, and `$HOME` path prefixes
|
|
464
|
-
before the envelope hits a sink. Placeholders (`<redacted:email>`,
|
|
465
|
-
`<redacted:ipv4>`, `<redacted:ipv6>`, `<redacted:token>`) are
|
|
466
|
-
byte-parity with the py / rs / php SDKs so the cross-language contract
|
|
467
|
-
harness can diff outputs.
|
|
468
|
-
|
|
469
|
-
```ts
|
|
470
|
-
import { redact, redactString } from '@hop-top/kit/telemetry';
|
|
471
|
-
|
|
472
|
-
redactString('user@example.com from 10.0.0.1'); // → '<redacted:email> from <redacted:ipv4>'
|
|
473
|
-
redact({ ip: '8.8.8.8', count: 3 }); // → { ip: '<redacted:ipv4>', count: 3 }
|
|
474
|
-
```
|
|
475
|
-
|
|
476
|
-
A per-`Client` `redactor` callback runs BEFORE the default pass — use
|
|
477
|
-
it for adopter-specific allowlists or stricter rules. Throwing
|
|
478
|
-
callbacks are isolated (the event still goes through the default
|
|
479
|
-
pass).
|
|
480
|
-
|
|
481
|
-
### Envelope
|
|
482
|
-
|
|
483
|
-
Each emitted event is one NDJSON line with the shape:
|
|
484
|
-
|
|
485
|
-
```json
|
|
486
|
-
{
|
|
487
|
-
"schema_version": "1",
|
|
488
|
-
"sdk_lang": "ts",
|
|
489
|
-
"sdk_version": "0.4.0",
|
|
490
|
-
"installation_id": "<64-char hex sha256>",
|
|
491
|
-
"mode": "anon",
|
|
492
|
-
"occurred_at": "2026-05-19T12:00:00.000Z",
|
|
493
|
-
"event": "cmd.invoked",
|
|
494
|
-
"attrs": { "command": "launch", "exit_code": 0 }
|
|
495
|
-
}
|
|
496
|
-
```
|
|
53
|
+
Non-directory subpaths: `cli` (CLI factory), `serve` (serve hierarchy
|
|
54
|
+
and service lifecycle), `netpolicy` (`--offline` enforcement, guards
|
|
55
|
+
`globalThis.fetch`), `xdg` (base directory paths), `config`
|
|
56
|
+
(config-file loading), `sqlstore` (embedded SQLite key/value store),
|
|
57
|
+
`upgrade` (semver upgrade detection), `llm`, `anthropic`, `openai`,
|
|
58
|
+
`routellm`, `alias`, `uri` (facade over `@hop-top/cite`), `api`,
|
|
59
|
+
`rpc`, `aim`, `scope`, `safety`, `provenance`, `stream`, `progress`,
|
|
60
|
+
`auth`, `errcorrect`. See `package.json` `exports` for the full list.
|
|
497
61
|
|
|
498
|
-
|
|
499
|
-
canonical envelope (Go pins a typed `Event` struct). See
|
|
500
|
-
`sdk/docs/telemetry-event-schema.md` for the cross-language contract.
|
|
62
|
+
## Contract
|
|
501
63
|
|
|
502
|
-
|
|
64
|
+
- Five built-in formatters (`json`, `yaml`, `table`, `csv`, `text`), the same set every kit SDK ships.
|
|
65
|
+
- Column order comes from an explicit `ColumnSpec[]`; `--cols` reorders as well as selects; `header` must equal `key`.
|
|
66
|
+
- `serve <service>` starts a named service even when `services.<name>.enabled` is false; a supervisor run resolving to zero services exits 2.
|
|
67
|
+
- MCP exposure is default-closed: `defaultPolicy()` blocks every destructive leaf on every remote surface.
|
|
68
|
+
- Telemetry is default-denied: `Client.record()` is a no-op without both a granted consent decision and a non-`off` mode.
|
|
503
69
|
|
|
504
|
-
|
|
505
|
-
diffs envelopes across SDKs. As of this revision the harness is not
|
|
506
|
-
landed; TS-side wiring is deferred until the directory exists.
|
|
70
|
+
## See also
|
|
507
71
|
|
|
508
|
-
|
|
72
|
+
- [TypeScript API reference](https://github.com/hop-top/poly-kit/blob/main/docs/adopters/reference/ts-api-reference.md):
|
|
73
|
+
every module in depth, output formatting rules and worked examples,
|
|
74
|
+
serve lifecycle, the MCP surface, the URI facade, telemetry envelope
|
|
75
|
+
and redactor, LLM adapters and tool calling (`toolCalls` / `toolCallId`)
|
|
76
|
+
- [Serve MCP from any SDK](https://github.com/hop-top/poly-kit/blob/main/docs/adopters/guides/serve-mcp-from-any-sdk.md), [serve lifecycle contract](https://github.com/hop-top/poly-kit/blob/main/docs/contracts/serve-lifecycle.md), [CLI parity guide](https://github.com/hop-top/poly-kit/blob/main/docs/adopters/guides/cli-parity-guide.md)
|
|
509
77
|
|
|
510
78
|
MIT.
|
|
511
79
|
|
|
512
|
-
<!-- release: track @hop-top/cite ^0.1.
|
|
80
|
+
<!-- release: track @hop-top/cite ^0.1.2 -->
|
|
@@ -136,4 +136,4 @@ declare namespace aim {
|
|
|
136
136
|
export { aim_Cache as Cache, type aim_CacheOptions as CacheOptions, type aim_Cost as Cost, type aim_ETagSource as ETagSource, type aim_Filter as Filter, type aim_Limit as Limit, type aim_Modalities as Modalities, type aim_Model as Model, aim_ModelsDevSource as ModelsDevSource, type aim_ModelsDevSourceOptions as ModelsDevSourceOptions, type aim_Provider as Provider, aim_Registry as Registry, type aim_RegistryOptions as RegistryOptions, type aim_Source as Source, aim_normalize as normalize, aim_parseQuery as parseQuery };
|
|
137
137
|
}
|
|
138
138
|
|
|
139
|
-
export { Cache as C, type ETagSource as E, type Filter as F, type Limit as L, type Modalities as M, type Provider as P, Registry as R, type Source as S,
|
|
139
|
+
export { Cache as C, type ETagSource as E, type Filter as F, type Limit as L, type Modalities as M, type Provider as P, Registry as R, type Source as S, aim as a, type CacheOptions as b, type Cost as c, type Model as d, ModelsDevSource as e, type ModelsDevSourceOptions as f, type RegistryOptions as g, normalize as n, parseQuery as p };
|
package/dist/aim.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { C as Cache,
|
|
1
|
+
export { C as Cache, b as CacheOptions, c as Cost, E as ETagSource, F as Filter, L as Limit, M as Modalities, d as Model, e as ModelsDevSource, f as ModelsDevSourceOptions, P as Provider, R as Registry, g as RegistryOptions, S as Source, n as normalize, p as parseQuery } from './aim-DZHwwiIc.js';
|