@hop-top/kit 0.5.0-alpha.1 → 0.5.0-alpha.10
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 +251 -0
- package/LICENSE +1 -1
- package/LICENSE-cobra.txt +174 -0
- package/NOTICE +15 -0
- package/README.md +55 -259
- package/dist/aim-DZHwwiIc.d.ts +139 -0
- package/dist/aim.d.ts +1 -116
- package/dist/aim.js +13 -414
- package/dist/alias-D9_qFlyP.d.ts +174 -0
- package/dist/alias.d.ts +2 -73
- package/dist/alias.js +27 -207
- package/dist/api-DAexsu2H.d.ts +77 -0
- package/dist/api.d.ts +1 -62
- package/dist/api.js +10 -164
- package/dist/auth-2-jfgiHn.d.ts +34 -0
- package/dist/auth.d.ts +1 -26
- package/dist/auth.js +6 -40
- package/dist/chunk-2JV3A7OP.js +1894 -0
- 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-BLS2OBIQ.js +263 -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-GHPJJV5L.js +613 -0
- package/dist/chunk-IXVQ62NZ.js +334 -0
- package/dist/chunk-JKMQSAJP.js +174 -0
- package/dist/chunk-JZ22ZUFA.js +1131 -0
- package/dist/chunk-K7VCKJ27.js +814 -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-NLMS7HGP.js +178 -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-QQQYCWSC.js +240 -0
- package/dist/chunk-R5U7XKVJ.js +16 -0
- package/dist/chunk-SNVGDYX7.js +187 -0
- package/dist/chunk-T46YPHKN.js +669 -0
- package/dist/chunk-UKZIAQA7.js +26 -0
- package/dist/chunk-WBVO43HU.js +355 -0
- package/dist/chunk-WUOAQVOA.js +86 -0
- package/dist/chunk-WWUKGJB5.js +90 -0
- package/dist/chunk-XJTRY453.js +868 -0
- package/dist/chunk-YGYQUFGY.js +219 -0
- package/dist/chunk-YOBAUCVN.js +583 -0
- package/dist/cli-C5B5tnpA.d.ts +400 -0
- package/dist/cli.d.ts +7 -309
- package/dist/cli.js +70 -945
- package/dist/completion-csVun6SP.d.ts +112 -0
- package/dist/completion-values-By-mnjNt.d.ts +142 -0
- package/dist/completion-values.d.ts +1 -0
- package/dist/completion-values.js +29 -0
- package/dist/completion.d.ts +3 -0
- package/dist/completion.js +34 -0
- package/dist/compliance-AxFf-uMy.d.ts +60 -0
- package/dist/compliance.d.ts +1 -0
- package/dist/compliance.js +17 -0
- package/dist/config-CaK60ByQ.d.ts +241 -0
- package/dist/config.d.ts +1 -97
- package/dist/config.js +8 -78
- package/dist/errcorrect-BcX1Ft0K.d.ts +44 -0
- package/dist/errcorrect.d.ts +1 -37
- package/dist/errcorrect.js +8 -68
- package/dist/error-Do8Qji43.d.ts +231 -0
- package/dist/id/index.d.ts +2 -83
- package/dist/id/index.js +14 -65
- package/dist/index-BKJZClJx.d.ts +1486 -0
- package/dist/index-C3Zw4wDJ.d.ts +359 -0
- package/dist/index-DCe1boBz.d.ts +328 -0
- package/dist/index-VLDcI5NF.d.ts +95 -0
- package/dist/index.d.ts +37 -0
- package/dist/index.js +132 -0
- 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 -188
- package/dist/llm.js +101 -356
- package/dist/log-CkaxMX3U.d.ts +115 -0
- package/dist/log.d.ts +2 -0
- package/dist/log.js +14 -0
- package/dist/mcp/index.d.ts +4 -0
- package/dist/mcp/index.js +184 -0
- package/dist/netpolicy-Brx5XZUB.d.ts +151 -0
- package/dist/netpolicy.d.ts +1 -0
- package/dist/netpolicy.js +25 -0
- package/dist/output-CjZWmL8s.d.ts +420 -0
- package/dist/output.d.ts +3 -213
- package/dist/output.js +137 -447
- package/dist/parity-CvMuYcVI.d.ts +61 -0
- package/dist/progress-CAzyxeWl.d.ts +38 -0
- package/dist/progress.d.ts +1 -30
- package/dist/progress.js +6 -55
- package/dist/provenance-SMFHm5gx.d.ts +30 -0
- package/dist/provenance.d.ts +1 -24
- package/dist/provenance.js +6 -31
- package/dist/routellm-B0nv59mH.d.ts +111 -0
- package/dist/routellm.d.ts +2 -64
- package/dist/routellm.js +13 -255
- package/dist/rpc-D31Lg0Kc.d.ts +32 -0
- package/dist/rpc.d.ts +2 -25
- package/dist/rpc.js +4 -98
- package/dist/safety-CUaYEjZc.d.ts +30 -0
- package/dist/safety.d.ts +1 -24
- package/dist/safety.js +6 -43
- package/dist/scope-BrhYB4ij.d.ts +141 -0
- package/dist/scope.d.ts +1 -121
- 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-CrjeCp0M.d.ts +44 -0
- package/dist/stream.d.ts +1 -35
- package/dist/stream.js +8 -51
- package/dist/telemetry/index.d.ts +1 -315
- package/dist/telemetry/index.js +26 -599
- package/dist/toolspec-DcPwwoAZ.d.ts +368 -0
- package/dist/toolspec.d.ts +2 -0
- package/dist/toolspec.js +37 -0
- package/dist/tui/index.d.ts +6 -298
- package/dist/tui/index.js +17 -381
- package/dist/upgrade-p_zh3pvV.d.ts +102 -0
- package/dist/upgrade.d.ts +1 -95
- package/dist/upgrade.js +6 -114
- package/dist/xdg-DB7Shoib.d.ts +179 -0
- package/dist/xdg.d.ts +1 -169
- package/dist/xdg.js +14 -128
- package/package.json +192 -24
- package/src/README.md +15 -0
- package/src/alias.conformance.test.ts +250 -0
- package/src/alias.test.ts +206 -2
- package/src/alias.ts +196 -21
- package/src/cli.help-command.test.ts +105 -0
- package/src/cli.offline.test.ts +93 -0
- package/src/cli.parity.test.ts +192 -0
- package/src/cli.test.ts +95 -1
- package/src/cli.ts +195 -25
- package/src/completion-scripts.ts +16 -0
- package/src/completion-values.test.ts +76 -16
- package/src/completion-values.ts +170 -66
- package/src/completion.conformance.test.ts +297 -0
- package/src/completion.test.ts +256 -145
- package/src/completion.ts +767 -121
- package/src/compliance.test.ts +196 -2
- package/src/compliance.ts +440 -20
- package/src/config-merge.test.ts +425 -0
- package/src/config.test.ts +228 -1
- package/src/config.ts +429 -16
- 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 +71 -0
- package/src/index.ts +46 -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/log.parity.test.ts +105 -0
- package/src/log.test.ts +270 -1
- package/src/log.ts +228 -49
- package/src/mcp/README.md +63 -0
- package/src/mcp/args-separator.test.ts +164 -0
- package/src/mcp/args.test.ts +223 -0
- package/src/mcp/args.ts +160 -0
- package/src/mcp/audit.test.ts +520 -0
- package/src/mcp/audit.ts +70 -0
- package/src/mcp/bridge.test.ts +222 -0
- package/src/mcp/bridge.ts +291 -0
- package/src/mcp/conformance.test.ts +357 -0
- package/src/mcp/dispatch.ts +359 -0
- package/src/mcp/identity.test.ts +166 -0
- package/src/mcp/identity.ts +72 -0
- package/src/mcp/index.ts +176 -0
- package/src/mcp/legacy-notify.test.ts +59 -0
- package/src/mcp/legacy.ts +367 -0
- package/src/mcp/mcp.test.ts +707 -0
- package/src/mcp/modern-confirm.test.ts +520 -0
- package/src/mcp/modern-confirm.ts +484 -0
- package/src/mcp/modern.ts +788 -0
- package/src/mcp/stdio.test.ts +313 -0
- package/src/mcp/stdio.ts +254 -0
- package/src/mcp/tasks.ts +82 -0
- package/src/mcp/testtree.ts +250 -0
- package/src/mcp/toolname.test.ts +147 -0
- package/src/mcp/types.ts +689 -0
- package/src/netpolicy.test.ts +280 -0
- package/src/netpolicy.ts +256 -0
- package/src/output/README.md +46 -0
- package/src/output/builtins.ts +5 -5
- package/src/output/dispatch.ts +10 -2
- package/src/output/error.ts +459 -0
- package/src/output/formatter.ts +29 -5
- package/src/output/formatters/README.md +50 -0
- package/src/output/formatters/csv.ts +48 -12
- package/src/output/formatters/json.ts +4 -25
- package/src/output/formatters/project.ts +34 -0
- package/src/output/formatters/table.ts +8 -6
- package/src/output/formatters/text.ts +7 -3
- package/src/output/formatters/yaml.ts +5 -22
- package/src/output/projection.test.ts +298 -0
- package/src/output/projection.ts +33 -59
- package/src/output/template.ts +11 -21
- package/src/output.surface.test.ts +41 -0
- package/src/output.ts +64 -3
- package/src/published-types.test.ts +133 -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.test.ts +31 -0
- package/src/telemetry/client.ts +12 -6
- package/src/telemetry/offline.test.ts +64 -0
- package/src/toolspec-internal.ts +279 -0
- package/src/toolspec-manifest.test.ts +167 -0
- package/src/toolspec-manifest.ts +410 -0
- package/src/toolspec-spec-schemas.ts +12 -0
- package/src/toolspec-spec.test.ts +273 -0
- package/src/toolspec-spec.ts +458 -0
- package/src/toolspec.from-command.test.ts +350 -0
- package/src/toolspec.test.ts +2 -2
- package/src/toolspec.ts +222 -0
- package/src/triton/README.md +34 -0
- package/src/tui/README.md +42 -0
- package/src/tui/parity.test.ts +120 -31
- package/src/tui/parity.ts +58 -7
- package/src/wizard.test.ts +7 -7
- package/test/llm/conformance-helpers.ts +100 -0
- package/test/output/csv.test.ts +164 -0
- package/test/output/dispatch.test.ts +1 -2
- package/test/output/error.test.ts +277 -0
- 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/test/toolspec/fixture.ts +79 -0
- package/tsconfig.json +3 -1
- package/tsconfig.test.json +10 -0
- package/vitest.config.ts +9 -0
- package/src/tui/parity.json +0 -74
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,272 +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
|
|
27
|
-
|
|
28
|
-
| Key | Extensions | Options |
|
|
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) |
|
|
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.
|
|
35
18
|
|
|
36
|
-
|
|
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
|
-
// ... render HTML to `out`
|
|
93
|
-
},
|
|
94
|
-
};
|
|
95
|
-
|
|
96
|
-
// Replace a built-in or add a new one:
|
|
97
|
-
defaultRegistry.override(htmlFormatter); // or .register() to fail-loud on dup
|
|
98
|
-
|
|
99
|
-
// Isolated registry for tests/multi-CLI binaries:
|
|
100
|
-
const r = new Registry();
|
|
101
|
-
r.register(htmlFormatter);
|
|
34
|
+
program.parse();
|
|
102
35
|
```
|
|
103
36
|
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
]
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
- `@hop-top/kit/xdg` — XDG Base Directory paths.
|
|
145
|
-
- `@hop-top/kit/config` — config-file loading.
|
|
146
|
-
- `@hop-top/kit/sqlstore` — embedded SQLite key/value store.
|
|
147
|
-
- `@hop-top/kit/upgrade` — semver upgrade detection.
|
|
148
|
-
- `@hop-top/kit/llm` / `routellm` — LLM client + routing helpers.
|
|
149
|
-
- `@hop-top/kit/alias` — alias resolution + completion.
|
|
150
|
-
- `@hop-top/kit/uri` — thin facade over `@hop-top/cite` for URI parsing,
|
|
151
|
-
action resolution, completions, registries, and OS handler metadata.
|
|
152
|
-
- `@hop-top/kit/tui` — TUI toolkit (parity, anim, prompts).
|
|
153
|
-
|
|
154
|
-
See package.json `exports` for the full list.
|
|
155
|
-
|
|
156
|
-
## URI facade
|
|
157
|
-
|
|
158
|
-
The URI module delegates to `@hop-top/cite`; it does not reimplement the URI
|
|
159
|
-
contract. It mirrors the kit Go URI command intent for SDK consumers:
|
|
160
|
-
|
|
161
|
-
```ts
|
|
162
|
-
import { parse, resolve, complete, handler, newRegistry } from '@hop-top/kit/uri';
|
|
163
|
-
|
|
164
|
-
const policy = {
|
|
165
|
-
schemeNamespaceSegments: { tlc: 2 },
|
|
166
|
-
actionRoutes: {
|
|
167
|
-
'task.claim': {
|
|
168
|
-
command: 'tlc',
|
|
169
|
-
args: ['-C', '{namespace}', 'task', 'claim', '{id}'],
|
|
170
|
-
},
|
|
171
|
-
},
|
|
172
|
-
};
|
|
173
|
-
|
|
174
|
-
const parsed = parse('tlc://hop-top/kit/T-0001?cmd=task&verb=claim', policy);
|
|
175
|
-
const plan = resolve(parsed, policy); // command plan only; never executes
|
|
176
|
-
|
|
177
|
-
const registry = newRegistry(policy);
|
|
178
|
-
registry.register({ name: 'tlc', completer: async () => ['hop-top/kit/T-0001'] });
|
|
179
|
-
const suggestions = await complete(registry, 'tlc', 'tlc://T-');
|
|
180
|
-
|
|
181
|
-
const id = handler.id({
|
|
182
|
-
vendor: 'hop-top',
|
|
183
|
-
app: 'tlc',
|
|
184
|
-
language: 'ts',
|
|
185
|
-
scheme: 'tlc',
|
|
186
|
-
appPath: '/usr/local/bin/tlc',
|
|
187
|
-
});
|
|
188
|
-
```
|
|
189
|
-
|
|
190
|
-
## Telemetry
|
|
191
|
-
|
|
192
|
-
`@hop-top/kit/telemetry` ships the SDK-side primitives for the kit
|
|
193
|
-
telemetry contract: a non-blocking `Client`, a best-effort PII /
|
|
194
|
-
secret redactor, and the consent + install-id readers needed to gate
|
|
195
|
-
emission.
|
|
196
|
-
|
|
197
|
-
**Default-denied**: a fresh install never emits. The `Client.record()`
|
|
198
|
-
call is a no-op unless the operator has run `kit consent grant` AND a
|
|
199
|
-
mode is selected via `KIT_TELEMETRY_MODE=anon|full` (or the prefixed
|
|
200
|
-
`<APP>_TELEMETRY_MODE` equivalent). Inspect what would ship with `kit
|
|
201
|
-
telemetry inspect`.
|
|
202
|
-
|
|
203
|
-
```ts
|
|
204
|
-
import { Client } from '@hop-top/kit/telemetry';
|
|
205
|
-
|
|
206
|
-
const client = new Client({
|
|
207
|
-
sink: 'jsonl', // or 'https'
|
|
208
|
-
sinkFile: '/tmp/kit-events.jsonl', // jsonl sink only
|
|
209
|
-
endpoint: 'https://telemetry.example', // https sink only
|
|
210
|
-
sdkVersion: '1.2.3',
|
|
211
|
-
});
|
|
212
|
-
|
|
213
|
-
// Fire-and-forget. Returns synchronously; never throws.
|
|
214
|
-
client.record('cmd.invoked', { command: 'launch', exit_code: 0 });
|
|
215
|
-
|
|
216
|
-
// Best-effort drain on process exit.
|
|
217
|
-
await client.shutdown(5_000);
|
|
218
|
-
```
|
|
219
|
-
|
|
220
|
-
### Configuration
|
|
221
|
-
|
|
222
|
-
All `ClientOptions` fields are mirrored by env vars (env wins when the
|
|
223
|
-
option is omitted):
|
|
224
|
-
|
|
225
|
-
| Field | Env var | Default |
|
|
226
|
-
| ----------- | ----------------------------- | ---------------------------------------------------- |
|
|
227
|
-
| `endpoint` | `KIT_TELEMETRY_ENDPOINT` | — |
|
|
228
|
-
| `sink` | `KIT_TELEMETRY_SINK` | `jsonl` |
|
|
229
|
-
| `sinkFile` | `KIT_TELEMETRY_SINK_FILE` | `$XDG_STATE_HOME/kit/telemetry/events.jsonl` |
|
|
230
|
-
| `queueSize` | `KIT_TELEMETRY_QUEUE_SIZE` | `1024` |
|
|
231
|
-
|
|
232
|
-
### Redactor
|
|
233
|
-
|
|
234
|
-
The default `redact()` pass scrubs emails, IPv4 / IPv6 addresses, `sk-`
|
|
235
|
-
/ `gh[pousr]_` / `xoxb-` token prefixes, and `$HOME` path prefixes
|
|
236
|
-
before the envelope hits a sink. Placeholders (`<redacted:email>`,
|
|
237
|
-
`<redacted:ipv4>`, `<redacted:ipv6>`, `<redacted:token>`) are
|
|
238
|
-
byte-parity with the py / rs / php SDKs so the cross-language contract
|
|
239
|
-
harness can diff outputs.
|
|
240
|
-
|
|
241
|
-
```ts
|
|
242
|
-
import { redact, redactString } from '@hop-top/kit/telemetry';
|
|
243
|
-
|
|
244
|
-
redactString('user@example.com from 10.0.0.1'); // → '<redacted:email> from <redacted:ipv4>'
|
|
245
|
-
redact({ ip: '8.8.8.8', count: 3 }); // → { ip: '<redacted:ipv4>', count: 3 }
|
|
246
|
-
```
|
|
247
|
-
|
|
248
|
-
A per-`Client` `redactor` callback runs BEFORE the default pass — use
|
|
249
|
-
it for adopter-specific allowlists or stricter rules. Throwing
|
|
250
|
-
callbacks are isolated (the event still goes through the default
|
|
251
|
-
pass).
|
|
252
|
-
|
|
253
|
-
### Envelope
|
|
254
|
-
|
|
255
|
-
Each emitted event is one NDJSON line with the shape:
|
|
256
|
-
|
|
257
|
-
```json
|
|
258
|
-
{
|
|
259
|
-
"schema_version": "1",
|
|
260
|
-
"sdk_lang": "ts",
|
|
261
|
-
"sdk_version": "0.4.0",
|
|
262
|
-
"installation_id": "<64-char hex sha256>",
|
|
263
|
-
"mode": "anon",
|
|
264
|
-
"occurred_at": "2026-05-19T12:00:00.000Z",
|
|
265
|
-
"event": "cmd.invoked",
|
|
266
|
-
"attrs": { "command": "launch", "exit_code": 0 }
|
|
267
|
-
}
|
|
268
|
-
```
|
|
269
|
-
|
|
270
|
-
The `event` + `attrs` extension is the TS / Py divergence from Go's
|
|
271
|
-
canonical envelope (Go pins a typed `Event` struct). See
|
|
272
|
-
`sdk/docs/telemetry-event-schema.md` for the cross-language contract.
|
|
273
|
-
|
|
274
|
-
### Cross-SDK contract harness
|
|
275
|
-
|
|
276
|
-
The harness at `hops/main/sdk/tests/cross-lang/` (planned in T-0709)
|
|
277
|
-
diffs envelopes across SDKs. As of this revision the harness is not
|
|
278
|
-
landed; TS-side wiring is deferred until the directory exists.
|
|
279
|
-
|
|
280
|
-
## License
|
|
37
|
+
`createCLI` gives the root the hop-top contract: `--format`, `--quiet`,
|
|
38
|
+
`--no-color`, `--no-hints`, `--offline`, themed help, version, and shell
|
|
39
|
+
completion's hidden `__complete` (scripts: `completionCommand(program)`).
|
|
40
|
+
|
|
41
|
+
## Modules
|
|
42
|
+
|
|
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 |
|
|
52
|
+
|
|
53
|
+
Non-directory subpaths: `cli` (CLI factory), `serve` (serve hierarchy and
|
|
54
|
+
service lifecycle), `netpolicy` (`--offline` enforcement, guards
|
|
55
|
+
`globalThis.fetch`), `xdg` (base directory paths), `config` (config-file
|
|
56
|
+
loading), `sqlstore` (embedded SQLite key/value store), `upgrade` (semver
|
|
57
|
+
upgrade detection), `llm`, `anthropic`, `openai`, `routellm`, `alias`, `uri`
|
|
58
|
+
(facade over `@hop-top/cite`), `api`, `rpc`, `aim`, `scope`, `safety`,
|
|
59
|
+
`provenance`, `stream`, `progress`, `auth`, `errcorrect`, `log`,
|
|
60
|
+
`completion`, `completion-values`, `toolspec`, `compliance`.
|
|
61
|
+
|
|
62
|
+
## Contract
|
|
63
|
+
|
|
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.
|
|
69
|
+
|
|
70
|
+
## See also
|
|
71
|
+
|
|
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)
|
|
281
77
|
|
|
282
78
|
MIT.
|
|
283
79
|
|
|
284
|
-
<!-- release: track @hop-top/cite ^0.1.
|
|
80
|
+
<!-- release: track @hop-top/cite ^0.1.2 -->
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
interface Modalities {
|
|
2
|
+
input?: string[];
|
|
3
|
+
output?: string[];
|
|
4
|
+
}
|
|
5
|
+
interface Limit {
|
|
6
|
+
context?: number;
|
|
7
|
+
output?: number;
|
|
8
|
+
}
|
|
9
|
+
interface Cost {
|
|
10
|
+
input?: number;
|
|
11
|
+
output?: number;
|
|
12
|
+
}
|
|
13
|
+
interface Model {
|
|
14
|
+
id: string;
|
|
15
|
+
name: string;
|
|
16
|
+
provider?: string;
|
|
17
|
+
family?: string;
|
|
18
|
+
input: string[];
|
|
19
|
+
output: string[];
|
|
20
|
+
tool_call: boolean;
|
|
21
|
+
reasoning: boolean;
|
|
22
|
+
open_weights: boolean;
|
|
23
|
+
context: number;
|
|
24
|
+
maxOutput: number;
|
|
25
|
+
costInput: number;
|
|
26
|
+
costOutput: number;
|
|
27
|
+
modalities?: Modalities;
|
|
28
|
+
limit?: Limit;
|
|
29
|
+
cost?: Cost;
|
|
30
|
+
}
|
|
31
|
+
interface Provider {
|
|
32
|
+
id: string;
|
|
33
|
+
name: string;
|
|
34
|
+
models: Record<string, Model>;
|
|
35
|
+
}
|
|
36
|
+
interface Filter {
|
|
37
|
+
input?: string;
|
|
38
|
+
output?: string;
|
|
39
|
+
provider?: string;
|
|
40
|
+
family?: string;
|
|
41
|
+
toolCall?: boolean;
|
|
42
|
+
reasoning?: boolean;
|
|
43
|
+
openWeights?: boolean;
|
|
44
|
+
query?: string;
|
|
45
|
+
}
|
|
46
|
+
/** Flatten nested wire fields into top-level Model fields. */
|
|
47
|
+
declare function normalize(m: Model): Model;
|
|
48
|
+
interface Source {
|
|
49
|
+
fetch(signal?: AbortSignal): Promise<Record<string, Provider>>;
|
|
50
|
+
}
|
|
51
|
+
interface ETagSource extends Source {
|
|
52
|
+
fetchWithETag(etag: string, signal?: AbortSignal): Promise<{
|
|
53
|
+
providers: Record<string, Provider> | null;
|
|
54
|
+
etag: string;
|
|
55
|
+
notModified: boolean;
|
|
56
|
+
}>;
|
|
57
|
+
}
|
|
58
|
+
interface ModelsDevSourceOptions {
|
|
59
|
+
url?: string;
|
|
60
|
+
timeout?: number;
|
|
61
|
+
maxSize?: number;
|
|
62
|
+
}
|
|
63
|
+
declare class ModelsDevSource implements ETagSource {
|
|
64
|
+
private url;
|
|
65
|
+
private timeout;
|
|
66
|
+
private maxSize;
|
|
67
|
+
constructor(opts?: ModelsDevSourceOptions);
|
|
68
|
+
private doFetch;
|
|
69
|
+
private readBody;
|
|
70
|
+
fetch(signal?: AbortSignal): Promise<Record<string, Provider>>;
|
|
71
|
+
fetchWithETag(etag: string, signal?: AbortSignal): Promise<{
|
|
72
|
+
providers: null;
|
|
73
|
+
etag: string;
|
|
74
|
+
notModified: true;
|
|
75
|
+
} | {
|
|
76
|
+
providers: Record<string, Provider>;
|
|
77
|
+
notModified: false;
|
|
78
|
+
etag: string;
|
|
79
|
+
}>;
|
|
80
|
+
}
|
|
81
|
+
interface CacheOptions {
|
|
82
|
+
ttl?: number;
|
|
83
|
+
dir?: string;
|
|
84
|
+
}
|
|
85
|
+
declare class Cache implements Source {
|
|
86
|
+
private src;
|
|
87
|
+
private ttl;
|
|
88
|
+
private dir;
|
|
89
|
+
constructor(src: Source, opts?: CacheOptions);
|
|
90
|
+
fetch(signal?: AbortSignal): Promise<Record<string, Provider>>;
|
|
91
|
+
forceRefresh(signal?: AbortSignal): Promise<Record<string, Provider>>;
|
|
92
|
+
private refresh;
|
|
93
|
+
private load;
|
|
94
|
+
private store;
|
|
95
|
+
private readFile;
|
|
96
|
+
private writeFile;
|
|
97
|
+
}
|
|
98
|
+
declare function parseQuery(q: string): Filter;
|
|
99
|
+
interface RegistryOptions {
|
|
100
|
+
sources?: Source[];
|
|
101
|
+
cacheDir?: string;
|
|
102
|
+
cacheTTL?: number;
|
|
103
|
+
}
|
|
104
|
+
declare class Registry {
|
|
105
|
+
private cache;
|
|
106
|
+
private providers;
|
|
107
|
+
constructor(opts?: RegistryOptions);
|
|
108
|
+
ensure(): Promise<void>;
|
|
109
|
+
refresh(): Promise<void>;
|
|
110
|
+
getProviders(): Promise<Provider[]>;
|
|
111
|
+
models(f: Filter): Promise<Model[]>;
|
|
112
|
+
get(provider: string, model: string): Promise<Model | undefined>;
|
|
113
|
+
query(q: string): Promise<Model[]>;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
type aim_Cache = Cache;
|
|
117
|
+
declare const aim_Cache: typeof Cache;
|
|
118
|
+
type aim_CacheOptions = CacheOptions;
|
|
119
|
+
type aim_Cost = Cost;
|
|
120
|
+
type aim_ETagSource = ETagSource;
|
|
121
|
+
type aim_Filter = Filter;
|
|
122
|
+
type aim_Limit = Limit;
|
|
123
|
+
type aim_Modalities = Modalities;
|
|
124
|
+
type aim_Model = Model;
|
|
125
|
+
type aim_ModelsDevSource = ModelsDevSource;
|
|
126
|
+
declare const aim_ModelsDevSource: typeof ModelsDevSource;
|
|
127
|
+
type aim_ModelsDevSourceOptions = ModelsDevSourceOptions;
|
|
128
|
+
type aim_Provider = Provider;
|
|
129
|
+
type aim_Registry = Registry;
|
|
130
|
+
declare const aim_Registry: typeof Registry;
|
|
131
|
+
type aim_RegistryOptions = RegistryOptions;
|
|
132
|
+
type aim_Source = Source;
|
|
133
|
+
declare const aim_normalize: typeof normalize;
|
|
134
|
+
declare const aim_parseQuery: typeof parseQuery;
|
|
135
|
+
declare namespace aim {
|
|
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
|
+
}
|
|
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, 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,116 +1 @@
|
|
|
1
|
-
|
|
2
|
-
input?: string[];
|
|
3
|
-
output?: string[];
|
|
4
|
-
}
|
|
5
|
-
interface Limit {
|
|
6
|
-
context?: number;
|
|
7
|
-
output?: number;
|
|
8
|
-
}
|
|
9
|
-
interface Cost {
|
|
10
|
-
input?: number;
|
|
11
|
-
output?: number;
|
|
12
|
-
}
|
|
13
|
-
interface Model {
|
|
14
|
-
id: string;
|
|
15
|
-
name: string;
|
|
16
|
-
provider?: string;
|
|
17
|
-
family?: string;
|
|
18
|
-
input: string[];
|
|
19
|
-
output: string[];
|
|
20
|
-
tool_call: boolean;
|
|
21
|
-
reasoning: boolean;
|
|
22
|
-
open_weights: boolean;
|
|
23
|
-
context: number;
|
|
24
|
-
maxOutput: number;
|
|
25
|
-
costInput: number;
|
|
26
|
-
costOutput: number;
|
|
27
|
-
modalities?: Modalities;
|
|
28
|
-
limit?: Limit;
|
|
29
|
-
cost?: Cost;
|
|
30
|
-
}
|
|
31
|
-
interface Provider {
|
|
32
|
-
id: string;
|
|
33
|
-
name: string;
|
|
34
|
-
models: Record<string, Model>;
|
|
35
|
-
}
|
|
36
|
-
interface Filter {
|
|
37
|
-
input?: string;
|
|
38
|
-
output?: string;
|
|
39
|
-
provider?: string;
|
|
40
|
-
family?: string;
|
|
41
|
-
toolCall?: boolean;
|
|
42
|
-
reasoning?: boolean;
|
|
43
|
-
openWeights?: boolean;
|
|
44
|
-
query?: string;
|
|
45
|
-
}
|
|
46
|
-
/** Flatten nested wire fields into top-level Model fields. */
|
|
47
|
-
declare function normalize(m: Model): Model;
|
|
48
|
-
interface Source {
|
|
49
|
-
fetch(signal?: AbortSignal): Promise<Record<string, Provider>>;
|
|
50
|
-
}
|
|
51
|
-
interface ETagSource extends Source {
|
|
52
|
-
fetchWithETag(etag: string, signal?: AbortSignal): Promise<{
|
|
53
|
-
providers: Record<string, Provider> | null;
|
|
54
|
-
etag: string;
|
|
55
|
-
notModified: boolean;
|
|
56
|
-
}>;
|
|
57
|
-
}
|
|
58
|
-
interface ModelsDevSourceOptions {
|
|
59
|
-
url?: string;
|
|
60
|
-
timeout?: number;
|
|
61
|
-
maxSize?: number;
|
|
62
|
-
}
|
|
63
|
-
declare class ModelsDevSource implements ETagSource {
|
|
64
|
-
private url;
|
|
65
|
-
private timeout;
|
|
66
|
-
private maxSize;
|
|
67
|
-
constructor(opts?: ModelsDevSourceOptions);
|
|
68
|
-
private doFetch;
|
|
69
|
-
private readBody;
|
|
70
|
-
fetch(signal?: AbortSignal): Promise<Record<string, Provider>>;
|
|
71
|
-
fetchWithETag(etag: string, signal?: AbortSignal): Promise<{
|
|
72
|
-
providers: null;
|
|
73
|
-
etag: string;
|
|
74
|
-
notModified: true;
|
|
75
|
-
} | {
|
|
76
|
-
providers: Record<string, Provider>;
|
|
77
|
-
notModified: false;
|
|
78
|
-
etag: string;
|
|
79
|
-
}>;
|
|
80
|
-
}
|
|
81
|
-
interface CacheOptions {
|
|
82
|
-
ttl?: number;
|
|
83
|
-
dir?: string;
|
|
84
|
-
}
|
|
85
|
-
declare class Cache implements Source {
|
|
86
|
-
private src;
|
|
87
|
-
private ttl;
|
|
88
|
-
private dir;
|
|
89
|
-
constructor(src: Source, opts?: CacheOptions);
|
|
90
|
-
fetch(signal?: AbortSignal): Promise<Record<string, Provider>>;
|
|
91
|
-
forceRefresh(signal?: AbortSignal): Promise<Record<string, Provider>>;
|
|
92
|
-
private refresh;
|
|
93
|
-
private load;
|
|
94
|
-
private store;
|
|
95
|
-
private readFile;
|
|
96
|
-
private writeFile;
|
|
97
|
-
}
|
|
98
|
-
declare function parseQuery(q: string): Filter;
|
|
99
|
-
interface RegistryOptions {
|
|
100
|
-
sources?: Source[];
|
|
101
|
-
cacheDir?: string;
|
|
102
|
-
cacheTTL?: number;
|
|
103
|
-
}
|
|
104
|
-
declare class Registry {
|
|
105
|
-
private cache;
|
|
106
|
-
private providers;
|
|
107
|
-
constructor(opts?: RegistryOptions);
|
|
108
|
-
ensure(): Promise<void>;
|
|
109
|
-
refresh(): Promise<void>;
|
|
110
|
-
getProviders(): Promise<Provider[]>;
|
|
111
|
-
models(f: Filter): Promise<Model[]>;
|
|
112
|
-
get(provider: string, model: string): Promise<Model | undefined>;
|
|
113
|
-
query(q: string): Promise<Model[]>;
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
export { Cache, type CacheOptions, type Cost, type ETagSource, type Filter, type Limit, type Modalities, type Model, ModelsDevSource, type ModelsDevSourceOptions, type Provider, Registry, type RegistryOptions, type Source, normalize, parseQuery };
|
|
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';
|