@hop-top/kit 0.4.0-alpha.1

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.
Files changed (174) hide show
  1. package/CHANGELOG.md +86 -0
  2. package/LICENSE +25 -0
  3. package/README.md +189 -0
  4. package/dist/aim.d.ts +116 -0
  5. package/dist/aim.js +417 -0
  6. package/dist/alias.d.ts +73 -0
  7. package/dist/alias.js +207 -0
  8. package/dist/api.d.ts +62 -0
  9. package/dist/api.js +165 -0
  10. package/dist/auth.d.ts +26 -0
  11. package/dist/auth.js +41 -0
  12. package/dist/cli.d.ts +309 -0
  13. package/dist/cli.js +885 -0
  14. package/dist/config.d.ts +97 -0
  15. package/dist/config.js +79 -0
  16. package/dist/errcorrect.d.ts +37 -0
  17. package/dist/errcorrect.js +69 -0
  18. package/dist/llm.d.ts +188 -0
  19. package/dist/llm.js +356 -0
  20. package/dist/output.d.ts +213 -0
  21. package/dist/output.js +447 -0
  22. package/dist/progress.d.ts +30 -0
  23. package/dist/progress.js +56 -0
  24. package/dist/provenance.d.ts +24 -0
  25. package/dist/provenance.js +32 -0
  26. package/dist/routellm.d.ts +64 -0
  27. package/dist/routellm.js +258 -0
  28. package/dist/rpc.d.ts +25 -0
  29. package/dist/rpc.js +101 -0
  30. package/dist/safety.d.ts +24 -0
  31. package/dist/safety.js +44 -0
  32. package/dist/scope.d.ts +121 -0
  33. package/dist/scope.js +380 -0
  34. package/dist/sqlstore.d.ts +84 -0
  35. package/dist/sqlstore.js +85 -0
  36. package/dist/stream.d.ts +35 -0
  37. package/dist/stream.js +52 -0
  38. package/dist/tui/index.d.ts +300 -0
  39. package/dist/tui/index.js +332 -0
  40. package/dist/upgrade.d.ts +95 -0
  41. package/dist/upgrade.js +115 -0
  42. package/dist/xdg.d.ts +169 -0
  43. package/dist/xdg.js +129 -0
  44. package/eslint.config.mjs +17 -0
  45. package/package.json +133 -0
  46. package/src/README.md +3 -0
  47. package/src/aim.test.ts +331 -0
  48. package/src/aim.ts +388 -0
  49. package/src/alias.test.ts +423 -0
  50. package/src/alias.ts +256 -0
  51. package/src/api.test.ts +190 -0
  52. package/src/api.ts +214 -0
  53. package/src/auth.test.ts +24 -0
  54. package/src/auth.ts +37 -0
  55. package/src/bus.test.ts +178 -0
  56. package/src/bus.ts +114 -0
  57. package/src/cli.test.ts +690 -0
  58. package/src/cli.ts +741 -0
  59. package/src/completion-values.test.ts +202 -0
  60. package/src/completion-values.ts +173 -0
  61. package/src/completion.test.ts +212 -0
  62. package/src/completion.ts +158 -0
  63. package/src/compliance.test.ts +134 -0
  64. package/src/compliance.ts +669 -0
  65. package/src/config.test.ts +110 -0
  66. package/src/config.ts +164 -0
  67. package/src/errcorrect.test.ts +134 -0
  68. package/src/errcorrect.ts +84 -0
  69. package/src/flagregister.test.ts +103 -0
  70. package/src/flagregister.ts +78 -0
  71. package/src/gen/crud_connect.ts +76 -0
  72. package/src/gen/crud_pb.ts +269 -0
  73. package/src/hint.test.ts +315 -0
  74. package/src/hint.ts +178 -0
  75. package/src/llm.test.ts +612 -0
  76. package/src/llm.ts +577 -0
  77. package/src/log.test.ts +145 -0
  78. package/src/log.ts +155 -0
  79. package/src/output/builtins.ts +34 -0
  80. package/src/output/dispatch.ts +195 -0
  81. package/src/output/flags.ts +151 -0
  82. package/src/output/format_help.ts +80 -0
  83. package/src/output/formatter.ts +167 -0
  84. package/src/output/formatters/csv.ts +72 -0
  85. package/src/output/formatters/json.ts +44 -0
  86. package/src/output/formatters/table.ts +44 -0
  87. package/src/output/formatters/text.ts +109 -0
  88. package/src/output/formatters/yaml.ts +47 -0
  89. package/src/output/projection.ts +126 -0
  90. package/src/output/registry.ts +88 -0
  91. package/src/output/template.ts +63 -0
  92. package/src/output.test.ts +117 -0
  93. package/src/output.ts +90 -0
  94. package/src/progress.test.ts +93 -0
  95. package/src/progress.ts +58 -0
  96. package/src/provenance.test.ts +59 -0
  97. package/src/provenance.ts +26 -0
  98. package/src/routellm.test.ts +179 -0
  99. package/src/routellm.ts +365 -0
  100. package/src/router/bert.test.ts +180 -0
  101. package/src/router/bert.ts +145 -0
  102. package/src/router/controller.test.ts +183 -0
  103. package/src/router/controller.ts +165 -0
  104. package/src/router/integration.test.ts +309 -0
  105. package/src/router/intent.test.ts +187 -0
  106. package/src/router/intent.ts +208 -0
  107. package/src/router/mf.test.ts +66 -0
  108. package/src/router/mf.ts +52 -0
  109. package/src/router/random.test.ts +23 -0
  110. package/src/router/random.ts +13 -0
  111. package/src/router/router.test.ts +31 -0
  112. package/src/router/router.ts +62 -0
  113. package/src/router/server.test.ts +193 -0
  114. package/src/router/server.ts +134 -0
  115. package/src/router/sw.test.ts +199 -0
  116. package/src/router/sw.ts +232 -0
  117. package/src/rpc.test.ts +47 -0
  118. package/src/rpc.ts +91 -0
  119. package/src/safety.test.ts +53 -0
  120. package/src/safety.ts +42 -0
  121. package/src/scope-defaults.json +72 -0
  122. package/src/scope.test.ts +177 -0
  123. package/src/scope.ts +382 -0
  124. package/src/setflag.test.ts +110 -0
  125. package/src/setflag.ts +102 -0
  126. package/src/sqlstore.test.ts +110 -0
  127. package/src/sqlstore.ts +144 -0
  128. package/src/stream.test.ts +69 -0
  129. package/src/stream.ts +47 -0
  130. package/src/textflag.test.ts +105 -0
  131. package/src/textflag.ts +68 -0
  132. package/src/toolspec.test.ts +187 -0
  133. package/src/toolspec.ts +279 -0
  134. package/src/triton/client.test.ts +205 -0
  135. package/src/triton/client.ts +261 -0
  136. package/src/tui/anim.test.ts +146 -0
  137. package/src/tui/anim.ts +134 -0
  138. package/src/tui/badge.test.ts +41 -0
  139. package/src/tui/badge.ts +55 -0
  140. package/src/tui/confirm.test.ts +68 -0
  141. package/src/tui/confirm.ts +49 -0
  142. package/src/tui/index.ts +29 -0
  143. package/src/tui/list.test.ts +84 -0
  144. package/src/tui/list.ts +72 -0
  145. package/src/tui/parity.ts +41 -0
  146. package/src/tui/pills.test.ts +40 -0
  147. package/src/tui/pills.ts +43 -0
  148. package/src/tui/progress.test.ts +164 -0
  149. package/src/tui/progress.ts +120 -0
  150. package/src/tui/spinner.test.ts +111 -0
  151. package/src/tui/spinner.ts +96 -0
  152. package/src/tui/status.test.ts +68 -0
  153. package/src/tui/status.ts +66 -0
  154. package/src/upgrade.test.ts +298 -0
  155. package/src/upgrade.ts +205 -0
  156. package/src/uri.ts +199 -0
  157. package/src/wizard.test.ts +441 -0
  158. package/src/wizard.ts +662 -0
  159. package/src/xdg.test.ts +202 -0
  160. package/src/xdg.ts +280 -0
  161. package/test/output/cols.test.ts +148 -0
  162. package/test/output/csv.test.ts +129 -0
  163. package/test/output/dispatch.test.ts +194 -0
  164. package/test/output/format_help.test.ts +131 -0
  165. package/test/output/formatter.test.ts +137 -0
  166. package/test/output/output_flag.test.ts +124 -0
  167. package/test/output/registry.test.ts +127 -0
  168. package/test/output/smoke-capture.ts +83 -0
  169. package/test/output/smoke.test.ts +142 -0
  170. package/test/output/template.test.ts +95 -0
  171. package/test/output/text.test.ts +75 -0
  172. package/test/testdata/api-fixture.json +115 -0
  173. package/test/testdata/query-vectors.json +187 -0
  174. package/tsconfig.json +12 -0
package/CHANGELOG.md ADDED
@@ -0,0 +1,86 @@
1
+ # Changelog
2
+
3
+ All notable changes to `@hop-top/kit` are documented in this file.
4
+ Format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/);
5
+ versions follow [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
+
7
+ ## [0.4.0-alpha.1](https://github.com/hop-top/poly-kit/compare/kit-ts/v0.4.0-alpha.0...kit-ts/v0.4.0-alpha.1) (2026-05-17)
8
+
9
+ The hop-top team is happy to announce Kit's TS SDK 0.4.0-alpha.1. This release includes new features.
10
+
11
+
12
+ ### Features
13
+
14
+ * initial public release
15
+
16
+ Full diff: [kit-ts/v0.4.0-alpha.0...kit-ts/v0.4.0-alpha.1](https://github.com/hop-top/poly-kit/compare/kit-ts/v0.4.0-alpha.0...kit-ts/v0.4.0-alpha.1)
17
+
18
+ ## [0.2.0-alpha.0](https://github.com/hop-top/poly-kit/compare/sdk/ts/v0.1.0-alpha.0...sdk/ts/v0.2.0-alpha.0) (2026-05-16)
19
+
20
+ The hop-top team is happy to announce kit 0.2.0-alpha.0. This release includes new features.
21
+
22
+
23
+ ### Features
24
+
25
+ * initial public release
26
+
27
+ Full diff: [sdk/ts/v0.1.0-alpha.0...sdk/ts/v0.2.0-alpha.0](https://github.com/hop-top/poly-kit/compare/sdk/ts/v0.1.0-alpha.0...sdk/ts/v0.2.0-alpha.0)
28
+
29
+ ## [0.3.0] — 2026-05-01
30
+
31
+ ### Added
32
+
33
+ - **Formatter / Registry public API** under `@hop-top/kit/output`:
34
+ - `Formatter<T = unknown>` interface with `key`, `extensions`, `options`,
35
+ and `render(out, data, opts, cols)`.
36
+ - `OptionSpec` (string | int | bool | enum) + `parseOptions` helper
37
+ with type coercion, default fill-in, and enum validation.
38
+ - `ColumnSpec` for header/key/priority metadata passed via `dispatch`.
39
+ - `Registry` class — `register` (throws on dup), `override` (replaces),
40
+ `lookup`, `keys`, `formatters`, `extensionMap`.
41
+ - `defaultRegistry` singleton + `newRegistry()` factory.
42
+ - **New built-in formatters**:
43
+ - `csv` — RFC 4180 quoting via `csv-stringify`. Options: `delimiter`,
44
+ `no-header`, `quote-all`, `crlf`. Extension `.csv`.
45
+ - `text` — three styles (`kv`, `lines`, `paragraph`) + custom
46
+ `separator`. Extension `.txt`.
47
+ - **New flags via Commander**:
48
+ - `--format-opt <kv...>` — repeatable, validated against the active
49
+ formatter's option specs. Bool keys may omit `=value`.
50
+ - `--format-help [fmt]` — list registry or per-formatter options.
51
+ - `--cols`, `--columns <cols...>` — variadic + comma-split + dedupe;
52
+ honored by all five built-ins.
53
+ - `--template <tpl>` — eta engine (EJS-style `<%= %>`); mutually
54
+ exclusive with `--cols`.
55
+ - `-o`, `--output <path>` — write to file. Empty string or `-` =
56
+ stdout. Extension inference selects the format when `--format` is
57
+ default; explicit `--format` paired with a different extension is a
58
+ hard mismatch error.
59
+ - **Helper exports** under `@hop-top/kit/output`:
60
+ - `registerOutputFlags(program, opts?)` — wires the full flag suite.
61
+ - `dispatch(cmd, data, opts?)` — resolves writer/format/options/cols
62
+ and invokes the active formatter.
63
+ - **CLI factory** (`createCLI`) now wires the full flag suite via
64
+ `registerOutputFlags`. `disable.format` toggles all six output flags.
65
+ - **Template scaffold** `templates/cli-ts/src/cli.ts.tmpl` ships the
66
+ parity flag suite by default.
67
+
68
+ ### Changed
69
+
70
+ - `render(w, format, v)` is now a thin shim over `defaultRegistry`.
71
+ Behavior is unchanged for `json` / `yaml` / `table`.
72
+ - New `dependencies`: `csv-stringify` (CSV quoting) and `eta`
73
+ (template engine).
74
+
75
+ ### Backward compatibility
76
+
77
+ - The existing `render(w, format, v)` signature is preserved.
78
+ - The five existing format constants stay (`JSON_FORMAT`, `YAML_FORMAT`,
79
+ `TABLE_FORMAT`); `CSV_FORMAT` and `TEXT_FORMAT` added.
80
+ - All existing tests pass byte-for-byte; the only change is
81
+ `output.test.ts`'s "unknown format" fixture, which now uses `'bogus'`
82
+ in place of `'csv'` — `csv` is now a registered built-in.
83
+
84
+ ## [0.2.1] and earlier
85
+
86
+ See git history.
package/LICENSE ADDED
@@ -0,0 +1,25 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Idea Crafters LLC <open@ideacrafters.com>
4
+ Copyright (c) 2026 jadb <https://x.com/jadb>
5
+
6
+ Permission is hereby granted, free of charge, to any person
7
+ obtaining a copy of this software and associated documentation
8
+ files (the "Software"), to deal in the Software without
9
+ restriction, including without limitation the rights to use,
10
+ copy, modify, merge, publish, distribute, sublicense, and/or
11
+ sell copies of the Software, and to permit persons to whom the
12
+ Software is furnished to do so, subject to the following
13
+ conditions:
14
+
15
+ The above copyright notice and this permission notice shall be
16
+ included in all copies or substantial portions of the Software.
17
+
18
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
20
+ OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
22
+ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
23
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
24
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
25
+ OTHER DEALINGS IN THE SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,189 @@
1
+ # @hop-top/kit (TypeScript)
2
+
3
+ Shared CLI utilities for hop-top tools — CommonJS edition.
4
+
5
+ Mirrors the Go `kit` package surface: a Commander-based CLI factory,
6
+ output formatting with a registry/Formatter contract, theming, hint
7
+ plumbing, XDG paths, config files, an embedded SQLite store, upgrade
8
+ checks, LLM helpers, alias resolution, and a TUI toolkit.
9
+
10
+ ## Install
11
+
12
+ ```sh
13
+ pnpm add @hop-top/kit
14
+ ```
15
+
16
+ Subpath imports follow the package's `exports` map (see
17
+ `package.json`): `@hop-top/kit/cli`, `@hop-top/kit/output`,
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) |
35
+
36
+ ### Wiring into a Commander CLI
37
+
38
+ ```ts
39
+ import { Command } from 'commander';
40
+ import { registerOutputFlags, dispatch } from '@hop-top/kit/output';
41
+
42
+ const program = new Command('mytool');
43
+ registerOutputFlags(program);
44
+
45
+ program.command('list').action(async () => {
46
+ await dispatch(program, [{ id: '1', name: 'Alice' }]);
47
+ });
48
+
49
+ program.parseAsync();
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);
102
+ ```
103
+
104
+ ### Column metadata
105
+
106
+ TS lacks struct tags; pass an explicit `ColumnSpec[]` list to `dispatch`
107
+ when you want headers/keys to differ or want priority ordering for
108
+ table layout:
109
+
110
+ ```ts
111
+ import type { ColumnSpec } from '@hop-top/kit/output';
112
+
113
+ const userCols: ColumnSpec[] = [
114
+ { header: 'ID', key: 'id', priority: 9 },
115
+ { header: 'Name', key: 'name', priority: 8 },
116
+ { header: 'Notes', key: 'notes', priority: 2 },
117
+ ];
118
+
119
+ await dispatch(cmd, users, { columns: userCols });
120
+ ```
121
+
122
+ When no `columns` is passed, headers are derived from the first row's
123
+ own enumerable keys.
124
+
125
+ ### Backward compatibility
126
+
127
+ The legacy `render(w, format, v)` signature stays. It is now a thin
128
+ shim over `defaultRegistry.lookup(format).render(...)`. Existing
129
+ callers do not need to migrate.
130
+
131
+ ```ts
132
+ import { render, JSON_FORMAT } from '@hop-top/kit/output';
133
+ render(process.stdout, JSON_FORMAT, { ok: true });
134
+ ```
135
+
136
+ ## Other modules
137
+
138
+ - `@hop-top/kit/cli` — `createCLI(cfg)` builds a Commander root program
139
+ with the hop-top contract: `--format`, `--quiet`, `--no-color`,
140
+ `--no-hints`, themed help, version, hidden completion command.
141
+ - `@hop-top/kit/xdg` — XDG Base Directory paths.
142
+ - `@hop-top/kit/config` — config-file loading.
143
+ - `@hop-top/kit/sqlstore` — embedded SQLite key/value store.
144
+ - `@hop-top/kit/upgrade` — semver upgrade detection.
145
+ - `@hop-top/kit/llm` / `routellm` — LLM client + routing helpers.
146
+ - `@hop-top/kit/alias` — alias resolution + completion.
147
+ - `@hop-top/kit/uri` — thin facade over `@hop-top/uri` for URI parsing,
148
+ action resolution, completions, registries, and OS handler metadata.
149
+ - `@hop-top/kit/tui` — TUI toolkit (parity, anim, prompts).
150
+
151
+ See package.json `exports` for the full list.
152
+
153
+ ## URI facade
154
+
155
+ The URI module delegates to `@hop-top/uri`; it does not reimplement the URI
156
+ contract. It mirrors the kit Go URI command intent for SDK consumers:
157
+
158
+ ```ts
159
+ import { parse, resolve, complete, handler, newRegistry } from '@hop-top/kit/uri';
160
+
161
+ const policy = {
162
+ schemeNamespaceSegments: { tlc: 2 },
163
+ actionRoutes: {
164
+ 'task.claim': {
165
+ command: 'tlc',
166
+ args: ['-C', '{namespace}', 'task', 'claim', '{id}'],
167
+ },
168
+ },
169
+ };
170
+
171
+ const parsed = parse('tlc://hop-top/kit/T-0001?cmd=task&verb=claim', policy);
172
+ const plan = resolve(parsed, policy); // command plan only; never executes
173
+
174
+ const registry = newRegistry(policy);
175
+ registry.register({ name: 'tlc', completer: async () => ['hop-top/kit/T-0001'] });
176
+ const suggestions = await complete(registry, 'tlc', 'tlc://T-');
177
+
178
+ const id = handler.id({
179
+ vendor: 'hop-top',
180
+ app: 'tlc',
181
+ language: 'ts',
182
+ scheme: 'tlc',
183
+ appPath: '/usr/local/bin/tlc',
184
+ });
185
+ ```
186
+
187
+ ## License
188
+
189
+ MIT.
package/dist/aim.d.ts ADDED
@@ -0,0 +1,116 @@
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
+ 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 };