@kindgi/tools 0.0.0-bootstrap.0 → 0.1.0
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/LICENSE +201 -0
- package/README.md +86 -1
- package/dist/define.d.ts +138 -0
- package/dist/define.d.ts.map +1 -0
- package/dist/define.js +318 -0
- package/dist/define.js.map +1 -0
- package/dist/errors.d.ts +113 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +4 -0
- package/dist/errors.js.map +1 -0
- package/dist/http.d.ts +2 -0
- package/dist/http.d.ts.map +1 -0
- package/dist/http.js +213 -0
- package/dist/http.js.map +1 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +14 -0
- package/dist/index.js.map +1 -0
- package/dist/invoke.d.ts +27 -0
- package/dist/invoke.d.ts.map +1 -0
- package/dist/invoke.js +127 -0
- package/dist/invoke.js.map +1 -0
- package/dist/manifest.d.ts +23 -0
- package/dist/manifest.d.ts.map +1 -0
- package/dist/manifest.js +37 -0
- package/dist/manifest.js.map +1 -0
- package/dist/precondition.d.ts +25 -0
- package/dist/precondition.d.ts.map +1 -0
- package/dist/precondition.js +34 -0
- package/dist/precondition.js.map +1 -0
- package/dist/registry.d.ts +87 -0
- package/dist/registry.d.ts.map +1 -0
- package/dist/registry.js +171 -0
- package/dist/registry.js.map +1 -0
- package/dist/spec-registry.d.ts +48 -0
- package/dist/spec-registry.d.ts.map +1 -0
- package/dist/spec-registry.js +37 -0
- package/dist/spec-registry.js.map +1 -0
- package/dist/tool.schema.json +297 -0
- package/dist/types.d.ts +508 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +14 -0
- package/dist/types.js.map +1 -0
- package/package.json +64 -4
- package/src/define.ts +537 -0
- package/src/errors.ts +139 -0
- package/src/http.ts +268 -0
- package/src/index.ts +68 -0
- package/src/invoke.ts +165 -0
- package/src/manifest.ts +40 -0
- package/src/precondition.ts +40 -0
- package/src/registry.ts +262 -0
- package/src/spec-registry.ts +78 -0
- package/src/tool.schema.json +297 -0
- package/src/types.ts +538 -0
package/dist/define.js
ADDED
|
@@ -0,0 +1,318 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
// Copyright (C) 2026 Kindgi Inc.
|
|
3
|
+
import * as addFormatsModule from 'ajv-formats';
|
|
4
|
+
import { Ajv2020 } from 'ajv/dist/2020.js';
|
|
5
|
+
import { createSpecRegistry, isZodSchema, loadZodConverter, loadZodConverterSync, toJSONSchemaSync, } from '@kindgi/schema';
|
|
6
|
+
import { getToolSpecSynthesizer } from './spec-registry.js';
|
|
7
|
+
import toolSchema from './tool.schema.json' with { type: 'json' };
|
|
8
|
+
import { EFFECT_KINDS, } from './types.js';
|
|
9
|
+
const TOOL_SCHEMA_URI = 'https://kindgi.com/schemas/v1/tool.schema.json';
|
|
10
|
+
/**
|
|
11
|
+
* Exact semver regex — accepts `MAJOR.MINOR.PATCH[-PRERELEASE]`. Tool
|
|
12
|
+
* VERSIONS are always exact (a tool row ships a specific semver);
|
|
13
|
+
* agent bindings reference tools via `{ id, version: <range> }`
|
|
14
|
+
* where the range grammar is npm-style (parsed by `semver` at
|
|
15
|
+
* dispatch time).
|
|
16
|
+
*/
|
|
17
|
+
const SEMVER_EXACT_RE = /^\d+\.\d+\.\d+(?:-[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?$/;
|
|
18
|
+
const addFormatsRaw = addFormatsModule;
|
|
19
|
+
const addFormats = typeof addFormatsRaw === 'function'
|
|
20
|
+
? addFormatsRaw
|
|
21
|
+
: addFormatsRaw.default;
|
|
22
|
+
let cachedRegistry;
|
|
23
|
+
function registry() {
|
|
24
|
+
if (cachedRegistry !== undefined)
|
|
25
|
+
return cachedRegistry;
|
|
26
|
+
const built = createSpecRegistry([toolSchema]);
|
|
27
|
+
if (built.kind === 'err') {
|
|
28
|
+
throw new Error(`@kindgi/tools: bundled schema failed to compile: ${built.error.message}`);
|
|
29
|
+
}
|
|
30
|
+
cachedRegistry = built.value;
|
|
31
|
+
return cachedRegistry;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Sync converter resolver. `@kindgi/schema` handles caching + peer-dep
|
|
35
|
+
* absence; when zod is installed, this returns the converter on every
|
|
36
|
+
* call after the first at O(1); when zod is missing, this returns
|
|
37
|
+
* `undefined` and callers surface a typed `invalid-schema` error.
|
|
38
|
+
*/
|
|
39
|
+
function resolveZodConverterSync() {
|
|
40
|
+
return loadZodConverterSync();
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Sanity-check that a candidate JSON Schema compiles under Draft 2020-12.
|
|
44
|
+
* We build a throwaway Ajv per call — cheap for authoring-time, safe under
|
|
45
|
+
* concurrent defineTool() calls.
|
|
46
|
+
*/
|
|
47
|
+
function compilesAsSchema(schema, where) {
|
|
48
|
+
const ajv = new Ajv2020({ strict: true, allErrors: true, allowUnionTypes: false });
|
|
49
|
+
addFormats(ajv);
|
|
50
|
+
try {
|
|
51
|
+
ajv.compile(schema);
|
|
52
|
+
return undefined;
|
|
53
|
+
}
|
|
54
|
+
catch (cause) {
|
|
55
|
+
return {
|
|
56
|
+
code: 'invalid-schema',
|
|
57
|
+
message: `Tool ${where} schema does not compile: ${cause instanceof Error ? cause.message : String(cause)}`,
|
|
58
|
+
where,
|
|
59
|
+
cause,
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Given an `AnySchema` (JSON Schema object OR Zod v4 schema), return the
|
|
65
|
+
* JSON Schema wire form. Converts synchronously using the pre-loaded Zod
|
|
66
|
+
* converter — callers must have called `ensureZodConverter()` first if
|
|
67
|
+
* they might be handed a Zod schema.
|
|
68
|
+
*/
|
|
69
|
+
function resolveWireSchema(schema, where, converter) {
|
|
70
|
+
if (!isZodSchema(schema)) {
|
|
71
|
+
return { kind: 'ok', value: { wire: schema } };
|
|
72
|
+
}
|
|
73
|
+
// The input side for `input` (a `.default()` field is optional to the
|
|
74
|
+
// caller), the output side for `output` (the field is always there).
|
|
75
|
+
const converted = toJSONSchemaSync(schema, converter, where);
|
|
76
|
+
if (converted.kind === 'err') {
|
|
77
|
+
return { kind: 'err', error: toSchemaError(converted.error, where) };
|
|
78
|
+
}
|
|
79
|
+
return { kind: 'ok', value: { wire: converted.value, zod: schema } };
|
|
80
|
+
}
|
|
81
|
+
function toSchemaError(err, where) {
|
|
82
|
+
return {
|
|
83
|
+
code: 'invalid-schema',
|
|
84
|
+
message: `Tool ${where} Zod schema conversion failed: ${err.message}`,
|
|
85
|
+
where,
|
|
86
|
+
cause: err.cause,
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
export function defineTool(spec, options = {}) {
|
|
90
|
+
// Fast path: JSON-Schema-only authoring never needs the peer dep.
|
|
91
|
+
const authoredWithZod = isZodSchema(spec.input) || isZodSchema(spec.output);
|
|
92
|
+
const converter = authoredWithZod ? resolveZodConverterSync() : undefined;
|
|
93
|
+
return finalizeDefinition(spec, converter, options);
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Async companion to `defineTool` — resolves the Zod peer dependency
|
|
97
|
+
* via dynamic `import()` instead of Node's `createRequire`. Prefer this
|
|
98
|
+
* in environments that prohibit `createRequire` (edge runtimes, some
|
|
99
|
+
* bundler configurations) OR for pack-init code that already lives on
|
|
100
|
+
* the async path.
|
|
101
|
+
*/
|
|
102
|
+
export async function defineToolAsync(spec, options = {}) {
|
|
103
|
+
const authoredWithZod = isZodSchema(spec.input) || isZodSchema(spec.output);
|
|
104
|
+
const converter = authoredWithZod ? await loadZodConverter() : undefined;
|
|
105
|
+
return finalizeDefinition(spec, converter, options);
|
|
106
|
+
}
|
|
107
|
+
function finalizeDefinition(spec, converter, options) {
|
|
108
|
+
// `version` is required on every tool manifest.
|
|
109
|
+
// Deep semver grammar checked here via a lightweight regex; range
|
|
110
|
+
// parsing (for agent-side `tools[].version` refs) happens elsewhere
|
|
111
|
+
// via the `semver` library at dispatch time. This regex accepts
|
|
112
|
+
// exact semvers only — tool VERSIONS are exact (a tool ships a
|
|
113
|
+
// specific `1.2.3`); ranges live on the agent binding.
|
|
114
|
+
const specVersion = spec.version;
|
|
115
|
+
if (typeof specVersion !== 'string' || !SEMVER_EXACT_RE.test(specVersion)) {
|
|
116
|
+
return {
|
|
117
|
+
kind: 'err',
|
|
118
|
+
error: {
|
|
119
|
+
code: 'invalid-tool-definition',
|
|
120
|
+
message: '`version` is required on every tool manifest and must be an exact semver (e.g., `1.2.3`, `1.2.3-beta.1`). Agent bindings then reference tools via `{ id, version: <range> }`.',
|
|
121
|
+
issues: [
|
|
122
|
+
{
|
|
123
|
+
path: '/version',
|
|
124
|
+
message: 'version must be a non-empty exact semver string',
|
|
125
|
+
},
|
|
126
|
+
],
|
|
127
|
+
},
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
// handler / spec mutual-exclusion + spec synthesis.
|
|
131
|
+
const authorHandler = spec.handler;
|
|
132
|
+
const declarativeSpec = spec.spec;
|
|
133
|
+
if (authorHandler !== undefined && declarativeSpec !== undefined) {
|
|
134
|
+
return {
|
|
135
|
+
kind: 'err',
|
|
136
|
+
error: {
|
|
137
|
+
code: 'invalid-tool-definition',
|
|
138
|
+
message: '`handler` and `spec` are mutually exclusive. Provide an imperative handler OR a declarative spec, not both.',
|
|
139
|
+
issues: [{ path: '/handler', message: 'handler + spec both set' }],
|
|
140
|
+
},
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
if (authorHandler === undefined && declarativeSpec === undefined) {
|
|
144
|
+
return {
|
|
145
|
+
kind: 'err',
|
|
146
|
+
error: {
|
|
147
|
+
code: 'invalid-tool-definition',
|
|
148
|
+
message: 'A tool must declare exactly one of `handler` (imperative) or `spec` (declarative).',
|
|
149
|
+
issues: [{ path: '/handler', message: 'handler + spec both absent' }],
|
|
150
|
+
},
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
let effectiveHandler = authorHandler;
|
|
154
|
+
if (declarativeSpec !== undefined) {
|
|
155
|
+
const synth = getToolSpecSynthesizer(declarativeSpec.kind);
|
|
156
|
+
if (synth === undefined) {
|
|
157
|
+
return {
|
|
158
|
+
kind: 'err',
|
|
159
|
+
error: {
|
|
160
|
+
code: 'invalid-tool-definition',
|
|
161
|
+
message: `No synthesizer registered for tool spec kind "${declarativeSpec.kind}". Import the package that owns this kind (e.g. \`@kindgi/tools\` for 'http') before calling \`defineTool\`.`,
|
|
162
|
+
issues: [{ path: '/spec/kind', message: `unknown kind "${declarativeSpec.kind}"` }],
|
|
163
|
+
},
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
effectiveHandler = synth(declarativeSpec, spec.id, options.synthesizer);
|
|
167
|
+
}
|
|
168
|
+
const inputResolved = resolveWireSchema(spec.input, 'input', converter);
|
|
169
|
+
if (inputResolved.kind === 'err')
|
|
170
|
+
return { kind: 'err', error: inputResolved.error };
|
|
171
|
+
const outputResolved = resolveWireSchema(spec.output, 'output', converter);
|
|
172
|
+
if (outputResolved.kind === 'err')
|
|
173
|
+
return { kind: 'err', error: outputResolved.error };
|
|
174
|
+
// Rebuild the spec against the JSON Schema wire form. Downstream code
|
|
175
|
+
// (invokeTool, manifest projection, MCP publish) reads `.input` /
|
|
176
|
+
// `.output`; the original Zod objects are stored separately on
|
|
177
|
+
// `inputZod` / `outputZod`.
|
|
178
|
+
const wireSpec = {
|
|
179
|
+
...spec,
|
|
180
|
+
input: inputResolved.value.wire,
|
|
181
|
+
output: outputResolved.value.wire,
|
|
182
|
+
handler: effectiveHandler,
|
|
183
|
+
};
|
|
184
|
+
const manifest = stripHandler(wireSpec);
|
|
185
|
+
const schemaResult = registry().validate(TOOL_SCHEMA_URI, manifest);
|
|
186
|
+
if (schemaResult.kind === 'err') {
|
|
187
|
+
const err = schemaResult.error;
|
|
188
|
+
if (err.code !== 'validation-error') {
|
|
189
|
+
throw new Error(`@kindgi/tools: unexpected schema error ${err.code}: ${err.message}`);
|
|
190
|
+
}
|
|
191
|
+
return { kind: 'err', error: toDefinitionError(err) };
|
|
192
|
+
}
|
|
193
|
+
const badEffect = checkEffectKinds(manifest);
|
|
194
|
+
if (badEffect)
|
|
195
|
+
return { kind: 'err', error: badEffect };
|
|
196
|
+
const badInput = compilesAsSchema(manifest.input, 'input');
|
|
197
|
+
if (badInput)
|
|
198
|
+
return { kind: 'err', error: badInput };
|
|
199
|
+
const badOutput = compilesAsSchema(manifest.output, 'output');
|
|
200
|
+
if (badOutput)
|
|
201
|
+
return { kind: 'err', error: badOutput };
|
|
202
|
+
const tool = {
|
|
203
|
+
...wireSpec,
|
|
204
|
+
...(inputResolved.value.zod !== undefined && { inputZod: inputResolved.value.zod }),
|
|
205
|
+
...(outputResolved.value.zod !== undefined && { outputZod: outputResolved.value.zod }),
|
|
206
|
+
};
|
|
207
|
+
return { kind: 'ok', value: tool };
|
|
208
|
+
}
|
|
209
|
+
function stripHandler(spec) {
|
|
210
|
+
// Structural copy dropping `handler`. `handler` is a function and Ajv rejects
|
|
211
|
+
// functions during validation, so it MUST be stripped before schema check.
|
|
212
|
+
const { handler: _handler, inputZod: _iz, outputZod: _oz, ...manifest } = spec;
|
|
213
|
+
return manifest;
|
|
214
|
+
}
|
|
215
|
+
function toDefinitionError(err) {
|
|
216
|
+
const issues = err.errors.map((e) => {
|
|
217
|
+
const ajvErr = e;
|
|
218
|
+
return {
|
|
219
|
+
path: typeof ajvErr.instancePath === 'string' ? ajvErr.instancePath : '',
|
|
220
|
+
message: typeof ajvErr.message === 'string' ? ajvErr.message : 'validation failed',
|
|
221
|
+
};
|
|
222
|
+
});
|
|
223
|
+
return { code: 'invalid-tool-definition', message: err.message, issues };
|
|
224
|
+
}
|
|
225
|
+
function checkEffectKinds(manifest) {
|
|
226
|
+
const kinds = new Set(EFFECT_KINDS);
|
|
227
|
+
for (const eff of manifest.effects ?? []) {
|
|
228
|
+
if (!kinds.has(eff.kind)) {
|
|
229
|
+
return {
|
|
230
|
+
code: 'unknown-effect',
|
|
231
|
+
message: `Tool "${manifest.id}" declares unknown effect kind "${eff.kind}"`,
|
|
232
|
+
kind: eff.kind,
|
|
233
|
+
};
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
return undefined;
|
|
237
|
+
}
|
|
238
|
+
/**
|
|
239
|
+
* Validate an arbitrary wire manifest against `@kindgi/specs/tool.schema.json`
|
|
240
|
+
* + the same effect / input-schema / output-schema checks `defineTool`
|
|
241
|
+
* runs, but without requiring a runtime `handler`. Used by transport
|
|
242
|
+
* layers (HTTP API, MCP publish) that accept metadata-only tool
|
|
243
|
+
* registrations — the actual handler is bound server-side via the
|
|
244
|
+
* runtime registry.
|
|
245
|
+
*
|
|
246
|
+
* The returned value has the manifest fields only; there is no
|
|
247
|
+
* `handler` (metadata-only shape).
|
|
248
|
+
*/
|
|
249
|
+
export function validateToolManifest(manifest) {
|
|
250
|
+
if (manifest === null || typeof manifest !== 'object') {
|
|
251
|
+
return {
|
|
252
|
+
kind: 'err',
|
|
253
|
+
error: {
|
|
254
|
+
code: 'invalid-tool-definition',
|
|
255
|
+
message: 'Tool manifest must be an object',
|
|
256
|
+
issues: [{ path: '', message: 'must be an object' }],
|
|
257
|
+
},
|
|
258
|
+
};
|
|
259
|
+
}
|
|
260
|
+
// `defineTool` strips `handler` before schema validation; forward the
|
|
261
|
+
// wire object unchanged. `handler` isn't in the ToolManifest shape,
|
|
262
|
+
// so any incidental value on the wire is ignored by validation.
|
|
263
|
+
const { handler: _ignored, ...candidate } = manifest;
|
|
264
|
+
const schemaResult = registry().validate(TOOL_SCHEMA_URI, candidate);
|
|
265
|
+
if (schemaResult.kind === 'err') {
|
|
266
|
+
const err = schemaResult.error;
|
|
267
|
+
if (err.code !== 'validation-error') {
|
|
268
|
+
throw new Error(`@kindgi/tools: unexpected schema error ${err.code}: ${err.message}`);
|
|
269
|
+
}
|
|
270
|
+
return { kind: 'err', error: toDefinitionError(err) };
|
|
271
|
+
}
|
|
272
|
+
const parsed = candidate;
|
|
273
|
+
const badEffect = checkEffectKinds(parsed);
|
|
274
|
+
if (badEffect)
|
|
275
|
+
return { kind: 'err', error: badEffect };
|
|
276
|
+
const badInput = compilesAsSchema(parsed.input, 'input');
|
|
277
|
+
if (badInput)
|
|
278
|
+
return { kind: 'err', error: badInput };
|
|
279
|
+
const badOutput = compilesAsSchema(parsed.output, 'output');
|
|
280
|
+
if (badOutput)
|
|
281
|
+
return { kind: 'err', error: badOutput };
|
|
282
|
+
const badUrl = checkHttpUrlTemplate(parsed);
|
|
283
|
+
if (badUrl)
|
|
284
|
+
return { kind: 'err', error: badUrl };
|
|
285
|
+
return { kind: 'ok', value: parsed };
|
|
286
|
+
}
|
|
287
|
+
/**
|
|
288
|
+
* An HTTP tool's `urlTemplate` fills `{placeholders}` in its path and
|
|
289
|
+
* query only. In the scheme, host or port, a run's input (or a model's
|
|
290
|
+
* arguments) would choose where the server sends the request.
|
|
291
|
+
*/
|
|
292
|
+
function checkHttpUrlTemplate(manifest) {
|
|
293
|
+
const spec = manifest.spec;
|
|
294
|
+
if (spec?.kind !== 'http')
|
|
295
|
+
return undefined;
|
|
296
|
+
const origin = /^(https?):\/\/([^/?#]*)/i.exec(spec.urlTemplate);
|
|
297
|
+
const message = origin === null
|
|
298
|
+
? 'must start with http:// or https:// and a host'
|
|
299
|
+
: /[{}]/.test(origin[2] ?? '')
|
|
300
|
+
? 'fills {placeholders} in its path and query only, never in its host or port'
|
|
301
|
+
: (origin[2] ?? '') === ''
|
|
302
|
+
? 'must name a host'
|
|
303
|
+
: undefined;
|
|
304
|
+
if (message === undefined)
|
|
305
|
+
return undefined;
|
|
306
|
+
return {
|
|
307
|
+
code: 'invalid-tool-definition',
|
|
308
|
+
message: `Tool "${manifest.id}" spec.urlTemplate ${message}`,
|
|
309
|
+
issues: [{ path: '/spec/urlTemplate', message }],
|
|
310
|
+
};
|
|
311
|
+
}
|
|
312
|
+
/** Exported for tests and downstream registry building. */
|
|
313
|
+
export function toolIdOf(spec) {
|
|
314
|
+
return spec.id;
|
|
315
|
+
}
|
|
316
|
+
/** The `$id` of the JSON Schema this loader validates against. */
|
|
317
|
+
export const TOOL_SCHEMA_URI_EXPORTED = TOOL_SCHEMA_URI;
|
|
318
|
+
//# sourceMappingURL=define.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"define.js","sourceRoot":"","sources":["../src/define.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,iCAAiC;AAEjC,OAAO,KAAK,gBAAgB,MAAM,aAAa,CAAC;AAChD,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAE3C,OAAO,EACL,kBAAkB,EAClB,WAAW,EACX,gBAAgB,EAChB,oBAAoB,EACpB,gBAAgB,GACjB,MAAM,gBAAgB,CAAC;AAgBxB,OAAO,EAAmC,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAC7F,OAAO,UAAU,MAAM,oBAAoB,CAAC,OAAO,IAAI,EAAE,MAAM,EAAE,CAAC;AAClE,OAAO,EACL,YAAY,GAKb,MAAM,YAAY,CAAC;AAEpB,MAAM,eAAe,GAAG,gDAAgD,CAAC;AAEzE;;;;;;GAMG;AACH,MAAM,eAAe,GAAG,wDAAwD,CAAC;AAIjF,MAAM,aAAa,GAAG,gBAA2B,CAAC;AAClD,MAAM,UAAU,GACd,OAAO,aAAa,KAAK,UAAU;IACjC,CAAC,CAAE,aAA8B;IACjC,CAAC,CAAE,aAA2C,CAAC,OAAO,CAAC;AAE3D,IAAI,cAAwC,CAAC;AAC7C,SAAS,QAAQ;IACf,IAAI,cAAc,KAAK,SAAS;QAAE,OAAO,cAAc,CAAC;IACxD,MAAM,KAAK,GAAG,kBAAkB,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC;IAC/C,IAAI,KAAK,CAAC,IAAI,KAAK,KAAK,EAAE,CAAC;QACzB,MAAM,IAAI,KAAK,CAAC,oDAAoD,KAAK,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC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OAAO;QACL,IAAI,EAAE,yBAAyB;QAC/B,OAAO,EAAE,SAAS,QAAQ,CAAC,EAAE,sBAAsB,OAAO,EAAE;QAC5D,MAAM,EAAE,CAAC,EAAE,IAAI,EAAE,mBAAmB,EAAE,OAAO,EAAE,CAAC;KACjD,CAAC;AACJ,CAAC;AAED,2DAA2D;AAC3D,MAAM,UAAU,QAAQ,CAAC,IAA8B;IACrD,OAAO,IAAI,CAAC,EAAE,CAAC;AACjB,CAAC;AAED,kEAAkE;AAClE,MAAM,CAAC,MAAM,wBAAwB,GAAG,eAAe,CAAC"}
|
package/dist/errors.d.ts
ADDED
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import type { ToolId } from '@kindgi/types';
|
|
2
|
+
/**
|
|
3
|
+
* Errors emitted by @kindgi/tools. Every variant carries a `code` for
|
|
4
|
+
* pattern matching; messages are human-readable, not API contract.
|
|
5
|
+
*/
|
|
6
|
+
export type ToolError = InvalidToolDefinitionError | InvalidSchemaError | UnknownEffectError | DuplicateToolError | DuplicateToolVersionError | ToolNotFoundError | ToolVersionNotFoundError | InvalidVersionRangeError | ToolVersionUnresolvableError | InputValidationError | OutputValidationError | HandlerError | PreconditionFailedError;
|
|
7
|
+
/** `defineTool` was called with something the schema loader rejects. */
|
|
8
|
+
export interface InvalidToolDefinitionError {
|
|
9
|
+
readonly code: 'invalid-tool-definition';
|
|
10
|
+
readonly message: string;
|
|
11
|
+
readonly issues: readonly {
|
|
12
|
+
readonly path: string;
|
|
13
|
+
readonly message: string;
|
|
14
|
+
}[];
|
|
15
|
+
}
|
|
16
|
+
/** The provided `input` or `output` is not a valid JSON Schema Draft 2020-12. */
|
|
17
|
+
export interface InvalidSchemaError {
|
|
18
|
+
readonly code: 'invalid-schema';
|
|
19
|
+
readonly message: string;
|
|
20
|
+
readonly where: 'input' | 'output';
|
|
21
|
+
readonly cause: unknown;
|
|
22
|
+
}
|
|
23
|
+
/** An effect kind not in `EFFECT_KINDS` was declared. */
|
|
24
|
+
export interface UnknownEffectError {
|
|
25
|
+
readonly code: 'unknown-effect';
|
|
26
|
+
readonly message: string;
|
|
27
|
+
readonly kind: string;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* ToolRegistry.register was called with an id that already exists AND the
|
|
31
|
+
* registry doesn't support multiple versions per id. `createToolRegistry`
|
|
32
|
+
* holds several versions per id and returns `duplicate-tool-version`
|
|
33
|
+
* instead when the same (id, version) is registered twice.
|
|
34
|
+
*/
|
|
35
|
+
export interface DuplicateToolError {
|
|
36
|
+
readonly code: 'duplicate-tool';
|
|
37
|
+
readonly message: string;
|
|
38
|
+
readonly id: ToolId;
|
|
39
|
+
}
|
|
40
|
+
/** Same `(id, version)` pair was registered twice — versions must be unique. */
|
|
41
|
+
export interface DuplicateToolVersionError {
|
|
42
|
+
readonly code: 'duplicate-tool-version';
|
|
43
|
+
readonly message: string;
|
|
44
|
+
readonly id: ToolId;
|
|
45
|
+
readonly version: string;
|
|
46
|
+
}
|
|
47
|
+
/** ToolRegistry.get was called with an id that isn't registered. */
|
|
48
|
+
export interface ToolNotFoundError {
|
|
49
|
+
readonly code: 'tool-not-found';
|
|
50
|
+
readonly message: string;
|
|
51
|
+
readonly id: ToolId;
|
|
52
|
+
}
|
|
53
|
+
/** The id exists but the requested exact version doesn't. */
|
|
54
|
+
export interface ToolVersionNotFoundError {
|
|
55
|
+
readonly code: 'tool-version-not-found';
|
|
56
|
+
readonly message: string;
|
|
57
|
+
readonly id: ToolId;
|
|
58
|
+
readonly version: string;
|
|
59
|
+
}
|
|
60
|
+
/** The provided version range isn't a valid semver range (per npm grammar). */
|
|
61
|
+
export interface InvalidVersionRangeError {
|
|
62
|
+
readonly code: 'invalid-version-range';
|
|
63
|
+
readonly message: string;
|
|
64
|
+
readonly id: ToolId;
|
|
65
|
+
readonly range: string;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* `resolve(id, range)` found the id but no registered version satisfies
|
|
69
|
+
* the range. Distinct from `tool-not-found` (no id at all) and from
|
|
70
|
+
* `invalid-version-range` (grammar error on the range string).
|
|
71
|
+
*/
|
|
72
|
+
export interface ToolVersionUnresolvableError {
|
|
73
|
+
readonly code: 'tool-version-unresolvable';
|
|
74
|
+
readonly message: string;
|
|
75
|
+
readonly id: ToolId;
|
|
76
|
+
readonly range: string;
|
|
77
|
+
readonly availableVersions: readonly string[];
|
|
78
|
+
}
|
|
79
|
+
/** invokeTool: the caller's input didn't validate against tool.input. */
|
|
80
|
+
export interface InputValidationError {
|
|
81
|
+
readonly code: 'input-validation-failed';
|
|
82
|
+
readonly message: string;
|
|
83
|
+
readonly toolId: ToolId;
|
|
84
|
+
readonly errors: readonly unknown[];
|
|
85
|
+
}
|
|
86
|
+
/** invokeTool: the handler returned something that didn't validate against tool.output. */
|
|
87
|
+
export interface OutputValidationError {
|
|
88
|
+
readonly code: 'output-validation-failed';
|
|
89
|
+
readonly message: string;
|
|
90
|
+
readonly toolId: ToolId;
|
|
91
|
+
readonly errors: readonly unknown[];
|
|
92
|
+
}
|
|
93
|
+
/** invokeTool: the handler threw. */
|
|
94
|
+
export interface HandlerError {
|
|
95
|
+
readonly code: 'handler-error';
|
|
96
|
+
readonly message: string;
|
|
97
|
+
readonly toolId: ToolId;
|
|
98
|
+
readonly cause: unknown;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* invokeTool: the runtime refused to run the tool — something it declares
|
|
102
|
+
* wasn't there (a `ToolPreconditionError` from the runtime's handler
|
|
103
|
+
* wrapper). The tool's own code never ran.
|
|
104
|
+
*/
|
|
105
|
+
export interface PreconditionFailedError {
|
|
106
|
+
readonly code: 'precondition-failed';
|
|
107
|
+
readonly message: string;
|
|
108
|
+
readonly toolId: ToolId;
|
|
109
|
+
/** The runtime's code for what was missing (`secret-unavailable`, …). */
|
|
110
|
+
readonly reason: string;
|
|
111
|
+
readonly cause: unknown;
|
|
112
|
+
}
|
|
113
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@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CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,MAAM,EAAE,SAAS,OAAO,EAAE,CAAC;CACrC;AAED,2FAA2F;AAC3F,MAAM,WAAW,qBAAqB;IACpC,QAAQ,CAAC,IAAI,EAAE,0BAA0B,CAAC;IAC1C,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,MAAM,EAAE,SAAS,OAAO,EAAE,CAAC;CACrC;AAED,qCAAqC;AACrC,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,IAAI,EAAE,eAAe,CAAC;IAC/B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;CACzB;AAED;;;;GAIG;AACH,MAAM,WAAW,uBAAuB;IACtC,QAAQ,CAAC,IAAI,EAAE,qBAAqB,CAAC;IACrC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,yEAAyE;IACzE,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;CACzB"}
|
package/dist/errors.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,iCAAiC"}
|
package/dist/http.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../src/http.ts"],"names":[],"mappings":""}
|