@hop-top/kit 0.5.0-alpha.0 → 0.5.0-alpha.2
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 +98 -0
- package/README.md +237 -9
- package/dist/aim-CTp-kJW2.d.ts +139 -0
- package/dist/aim.d.ts +1 -116
- package/dist/alias-dhhr08Ei.d.ts +88 -0
- package/dist/alias.d.ts +2 -73
- package/dist/api-miiso81x.d.ts +77 -0
- package/dist/api.d.ts +1 -62
- package/dist/auth-2-jfgiHn.d.ts +34 -0
- package/dist/auth.d.ts +1 -26
- package/dist/cli-DgOEOsPB.d.ts +450 -0
- package/dist/cli.d.ts +5 -309
- package/dist/cli.js +250 -62
- package/dist/config-BUY7_W2n.d.ts +103 -0
- package/dist/config.d.ts +1 -97
- package/dist/errcorrect-BcX1Ft0K.d.ts +44 -0
- package/dist/errcorrect.d.ts +1 -37
- package/dist/id/index.d.ts +2 -83
- package/dist/index--C7Mtsmm.d.ts +328 -0
- package/dist/index-C3Zw4wDJ.d.ts +359 -0
- package/dist/index-MLrRDvEG.d.ts +1073 -0
- package/dist/index-QSffbLnj.d.ts +94 -0
- package/dist/index.d.ts +26 -0
- package/dist/index.js +5863 -0
- package/dist/llm-B5XUWH8T.d.ts +231 -0
- package/dist/llm.d.ts +1 -188
- package/dist/mcp/index.d.ts +2 -0
- package/dist/mcp/index.js +1453 -0
- package/dist/netpolicy-asvCfwi8.d.ts +138 -0
- package/dist/netpolicy.d.ts +1 -0
- package/dist/netpolicy.js +118 -0
- package/dist/output-VFFLqor9.d.ts +521 -0
- package/dist/output.d.ts +2 -213
- package/dist/output.js +554 -43
- package/dist/progress-CAzyxeWl.d.ts +38 -0
- package/dist/progress.d.ts +1 -30
- package/dist/provenance-SMFHm5gx.d.ts +30 -0
- package/dist/provenance.d.ts +1 -24
- package/dist/routellm-PGSt2D1y.d.ts +75 -0
- package/dist/routellm.d.ts +2 -64
- package/dist/rpc-D5xLEf8V.d.ts +32 -0
- package/dist/rpc.d.ts +2 -25
- package/dist/safety-CUaYEjZc.d.ts +30 -0
- package/dist/safety.d.ts +1 -24
- package/dist/scope-BrhYB4ij.d.ts +141 -0
- package/dist/scope.d.ts +1 -121
- package/dist/stream-CrjeCp0M.d.ts +44 -0
- package/dist/stream.d.ts +1 -35
- package/dist/telemetry/index.d.ts +1 -315
- package/dist/telemetry/index.js +12 -1
- package/dist/tui/index.d.ts +4 -298
- package/dist/tui/index.js +61 -9
- package/dist/upgrade-p_zh3pvV.d.ts +102 -0
- package/dist/upgrade.d.ts +1 -95
- package/dist/xdg-DB7Shoib.d.ts +179 -0
- package/dist/xdg.d.ts +1 -169
- package/package.json +65 -25
- package/src/cli.offline.test.ts +93 -0
- package/src/cli.parity.test.ts +192 -0
- package/src/cli.ts +112 -12
- package/src/index.test.ts +58 -0
- package/src/index.ts +36 -0
- package/src/log.parity.test.ts +105 -0
- package/src/log.ts +64 -13
- package/src/mcp/bridge.test.ts +150 -0
- package/src/mcp/bridge.ts +246 -0
- package/src/mcp/conformance.test.ts +336 -0
- package/src/mcp/dispatch.ts +313 -0
- package/src/mcp/index.ts +138 -0
- package/src/mcp/legacy.ts +314 -0
- package/src/mcp/mcp.test.ts +697 -0
- package/src/mcp/modern-confirm.test.ts +520 -0
- package/src/mcp/modern-confirm.ts +452 -0
- package/src/mcp/modern.ts +723 -0
- package/src/mcp/tasks.ts +82 -0
- package/src/mcp/testtree.ts +250 -0
- package/src/mcp/types.ts +504 -0
- package/src/netpolicy.test.ts +202 -0
- package/src/netpolicy.ts +231 -0
- package/src/output/dispatch.ts +10 -2
- package/src/output/error.ts +293 -0
- package/src/output/formatter.ts +29 -5
- 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 +39 -3
- package/src/telemetry/client.test.ts +31 -0
- package/src/telemetry/client.ts +7 -1
- package/src/telemetry/offline.test.ts +64 -0
- package/src/tui/parity.test.ts +142 -0
- package/src/tui/parity.ts +59 -13
- package/test/output/csv.test.ts +164 -0
- package/test/output/error.test.ts +241 -0
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,104 @@ 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.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
|
+
|
|
9
|
+
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.
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
### ⚠ BREAKING CHANGES
|
|
13
|
+
|
|
14
|
+
* **ai/llm:** `Request.Temperature` type changes from `float64` to `*float64`. Callers setting a literal must pass a pointer; zero-value construction (unset) keeps behaving as before via nil.
|
|
15
|
+
|
|
16
|
+
### Features
|
|
17
|
+
|
|
18
|
+
* merge offline-transport
|
|
19
|
+
* merge offline-transport
|
|
20
|
+
* **sdk/ts:** add structured error envelope with transience class
|
|
21
|
+
* **ts/mcp:** implement MRTR confirmation loop on the modern surface
|
|
22
|
+
* **ts:** enforce --offline at the fetch layer
|
|
23
|
+
* **ts:** serve dual-spec MCP surface
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
### Bug Fixes
|
|
27
|
+
|
|
28
|
+
* **ai/llm:** send explicit zero temperature on the wire
|
|
29
|
+
* **output:** collapse header/key split, let --cols reorder
|
|
30
|
+
* **output:** emit valid csv from ts in crlf mode
|
|
31
|
+
* **output:** reach projection helpers from every render
|
|
32
|
+
* **parity:** load verbosity/streams blocks, drop decorative table block
|
|
33
|
+
* **ts:** exempt telemetry from `--offline`
|
|
34
|
+
* **ts:** re-export registerOutputFlags + dispatch from output subpath
|
|
35
|
+
* **ts:** ship root index entry so bare package import resolves
|
|
36
|
+
|
|
37
|
+
Full diff: [kit-ts/v0.5.0-alpha.1...kit-ts/v0.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)
|
|
38
|
+
|
|
39
|
+
## [Unreleased]
|
|
40
|
+
|
|
41
|
+
### Changed
|
|
42
|
+
|
|
43
|
+
- **Output column ordering is now driven by the `ColumnSpec[]` list.** The
|
|
44
|
+
projection helpers already implemented the rule but were unreachable from a
|
|
45
|
+
render: `options.columns` was consumed by `--cols` validation and then
|
|
46
|
+
dropped, while the built-in formatters derived headers from
|
|
47
|
+
`Object.keys(rows[0])`. The list now supplies the default column order, the
|
|
48
|
+
header labels, and the column selection. **User-visible:** callers passing a
|
|
49
|
+
`columns` list whose order differs from their payload's key order will see
|
|
50
|
+
columns reorder, and payload keys absent from the schema stop being emitted.
|
|
51
|
+
Anyone parsing column positions or diffing `--format json` output sees
|
|
52
|
+
different bytes. Precedence is `--cols` (user order always wins; it reorders
|
|
53
|
+
as well as selects), else `ColumnSpec` order, else payload key order.
|
|
54
|
+
- `Formatter.render` is **unchanged**. `resolveEffectiveCols` collapses
|
|
55
|
+
`--cols` and the `ColumnSpec` list into one ordered list once, at the
|
|
56
|
+
dispatch layer, and passes it through the existing `cols` argument — so
|
|
57
|
+
third-party formatters keep working and pick up correct ordering with no
|
|
58
|
+
code change. The collapse is sound only because `header === key`.
|
|
59
|
+
- **`header` must equal `key`.** The two name the same column: the label, the
|
|
60
|
+
value matched against `--cols`, and the property read off the row. Go cannot
|
|
61
|
+
express a header/key split through its `table:""` struct tags, so no SDK
|
|
62
|
+
may. `key` is retained for source compatibility and must equal `header`.
|
|
63
|
+
`priority` is still accepted and stored but remains ignored outside Go.
|
|
64
|
+
|
|
65
|
+
### Removed
|
|
66
|
+
|
|
67
|
+
- `filterColumns` and `buildHeaderToKey`. Under `header === key` the latter
|
|
68
|
+
was an identity map and `projectRows`' `out[c.header] = r[c.key]` an
|
|
69
|
+
identity mapping; `filterColumns` became unreachable once dispatch passes
|
|
70
|
+
the resolved column list verbatim. Unknown-`--cols` rejection was never
|
|
71
|
+
lost — it lives in `validateCols`.
|
|
72
|
+
|
|
73
|
+
### Known limitations
|
|
74
|
+
|
|
75
|
+
- `csv` and `text` formatters are not implemented in the Rust and PHP SDKs.
|
|
76
|
+
Only `table`, `json` and `yaml` are portable across all five kit runtimes.
|
|
77
|
+
|
|
78
|
+
### Fixed
|
|
79
|
+
|
|
80
|
+
- **CSV no longer emits structurally invalid output in `crlf` mode.** A field
|
|
81
|
+
containing an embedded LF was written UNQUOTED, so a single record decoded
|
|
82
|
+
as two records (three under some readers). This was data corruption, not a
|
|
83
|
+
quoting preference. Encoding is now hand-rolled instead of delegated to
|
|
84
|
+
csv-stringify, which produced that output in its `windows`
|
|
85
|
+
record-delimiter mode.
|
|
86
|
+
- **A field beginning with whitespace is now quoted**, matching the other
|
|
87
|
+
SDKs; it was previously emitted bare. A field equal to `\.` is quoted too,
|
|
88
|
+
since that sequence alone on a line terminates a PostgreSQL `COPY` stream.
|
|
89
|
+
- A quoted field's bytes are preserved verbatim in both line-ending modes and
|
|
90
|
+
both quoting paths; `crlf` changes the record terminator and nothing else.
|
|
91
|
+
RFC 4180 lists `CR` and `LF` as separate alternatives inside the `escaped`
|
|
92
|
+
production, so a bare CR between quotes is legal.
|
|
93
|
+
|
|
94
|
+
## [0.5.0-alpha.1](https://github.com/hop-top/poly-kit/compare/kit-ts/v0.5.0-alpha.0...kit-ts/v0.5.0-alpha.1) (2026-07-14)
|
|
95
|
+
|
|
96
|
+
The hop-top team is happy to announce Kit's TS SDK 0.5.0-alpha.1. This release includes maintenance release with bug fixes.
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
### Bug Fixes
|
|
100
|
+
|
|
101
|
+
* **ts:** ESM export conditions + self-contained parity data
|
|
102
|
+
|
|
103
|
+
Full diff: [kit-ts/v0.5.0-alpha.0...kit-ts/v0.5.0-alpha.1](https://github.com/hop-top/poly-kit/compare/kit-ts/v0.5.0-alpha.0...kit-ts/v0.5.0-alpha.1)
|
|
104
|
+
|
|
7
105
|
## [0.5.0-alpha.0](https://github.com/hop-top/poly-kit/compare/kit-ts/v0.4.0-alpha.2...kit-ts/v0.5.0-alpha.0) (2026-06-07)
|
|
8
106
|
|
|
9
107
|
The hop-top team is happy to announce Kit's TS SDK 0.5.0-alpha.0. This release includes miscellaneous improvements.
|
package/README.md
CHANGED
|
@@ -89,6 +89,8 @@ const htmlFormatter: Formatter = {
|
|
|
89
89
|
extensions: ['.html'],
|
|
90
90
|
options: [],
|
|
91
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".
|
|
92
94
|
// ... render HTML to `out`
|
|
93
95
|
},
|
|
94
96
|
};
|
|
@@ -103,17 +105,18 @@ r.register(htmlFormatter);
|
|
|
103
105
|
|
|
104
106
|
### Column metadata
|
|
105
107
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
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:
|
|
109
112
|
|
|
110
113
|
```ts
|
|
111
114
|
import type { ColumnSpec } from '@hop-top/kit/output';
|
|
112
115
|
|
|
113
116
|
const userCols: ColumnSpec[] = [
|
|
114
|
-
{ header: '
|
|
115
|
-
{ header: '
|
|
116
|
-
{ header: '
|
|
117
|
+
{ header: 'id', key: 'id', priority: 9 },
|
|
118
|
+
{ header: 'name', key: 'name', priority: 8 },
|
|
119
|
+
{ header: 'notes', key: 'notes', priority: 2 },
|
|
117
120
|
];
|
|
118
121
|
|
|
119
122
|
await dispatch(cmd, users, { columns: userCols });
|
|
@@ -122,6 +125,119 @@ await dispatch(cmd, users, { columns: userCols });
|
|
|
122
125
|
When no `columns` is passed, headers are derived from the first row's
|
|
123
126
|
own enumerable keys.
|
|
124
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
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
Capability differences against the Go reference:
|
|
206
|
+
|
|
207
|
+
| Capability | Go (reference) | ts / py | rs / php |
|
|
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
|
+
|
|
125
241
|
### Backward compatibility
|
|
126
242
|
|
|
127
243
|
The legacy `render(w, format, v)` signature stays. It is now a thin
|
|
@@ -137,7 +253,14 @@ render(process.stdout, JSON_FORMAT, { ok: true });
|
|
|
137
253
|
|
|
138
254
|
- `@hop-top/kit/cli` — `createCLI(cfg)` builds a Commander root program
|
|
139
255
|
with the hop-top contract: `--format`, `--quiet`, `--no-color`,
|
|
140
|
-
`--no-hints`, themed help, version, hidden completion
|
|
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)`.
|
|
141
264
|
- `@hop-top/kit/id` — TypeID primitive (cross-language; see
|
|
142
265
|
[ADR 0001](../../docs/adr/0001-typeid-primitive.md)). Source:
|
|
143
266
|
[`src/id/`](src/id/).
|
|
@@ -150,13 +273,118 @@ render(process.stdout, JSON_FORMAT, { ok: true });
|
|
|
150
273
|
- `@hop-top/kit/uri` — thin facade over `@hop-top/cite` for URI parsing,
|
|
151
274
|
action resolution, completions, registries, and OS handler metadata.
|
|
152
275
|
- `@hop-top/kit/tui` — TUI toolkit (parity, anim, prompts).
|
|
276
|
+
- `@hop-top/kit/mcp` — dual-spec MCP surface (see [MCP surface](#mcp-surface)).
|
|
153
277
|
|
|
154
278
|
See package.json `exports` for the full list.
|
|
155
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.
|
|
290
|
+
|
|
291
|
+
### Use the v2 scoped packages
|
|
292
|
+
|
|
293
|
+
The protocol layer comes from `@modelcontextprotocol/core` and
|
|
294
|
+
`@modelcontextprotocol/server`, both pinned at `2.0.0`. They are already
|
|
295
|
+
dependencies of this package.
|
|
296
|
+
|
|
297
|
+
**`@modelcontextprotocol/sdk` — the v1 package — is deliberately not a
|
|
298
|
+
dependency.** It is legacy-era only: its `LATEST_PROTOCOL_VERSION` is
|
|
299
|
+
`2025-11-25`, and `2026-07-28` appears nowhere in it. It cannot serve
|
|
300
|
+
the modern era. It is also the name every search result reaches for, so
|
|
301
|
+
it is the most likely mistake here — code that imports it passes the
|
|
302
|
+
legacy fixtures and fails every modern one.
|
|
303
|
+
|
|
304
|
+
### Hosting: a framework-free handler
|
|
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
|
+
|
|
156
383
|
## URI facade
|
|
157
384
|
|
|
158
|
-
The URI module delegates to `@hop-top/cite
|
|
159
|
-
contract. It mirrors the kit Go URI command intent
|
|
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:
|
|
160
388
|
|
|
161
389
|
```ts
|
|
162
390
|
import { parse, resolve, complete, handler, newRegistry } from '@hop-top/kit/uri';
|
|
@@ -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, type CacheOptions as a, type Cost as b, type Model as c, ModelsDevSource as d, type ModelsDevSourceOptions as e, type RegistryOptions as f, aim 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, a as CacheOptions, b as Cost, E as ETagSource, F as Filter, L as Limit, M as Modalities, c as Model, d as ModelsDevSource, e as ModelsDevSourceOptions, P as Provider, R as Registry, f as RegistryOptions, S as Source, n as normalize, p as parseQuery } from './aim-CTp-kJW2.js';
|