@codespar/types 0.10.5 → 0.10.7
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/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/meta-tool-contract.d.ts +162 -0
- package/dist/meta-tool-contract.d.ts.map +1 -0
- package/dist/meta-tool-contract.js +196 -0
- package/dist/meta-tool-contract.js.map +1 -0
- package/dist/testing/conformance-kit.d.ts +101 -0
- package/dist/testing/conformance-kit.d.ts.map +1 -0
- package/dist/testing/conformance-kit.js +323 -0
- package/dist/testing/conformance-kit.js.map +1 -0
- package/dist/testing/conformance-kit.test.d.ts +18 -0
- package/dist/testing/conformance-kit.test.d.ts.map +1 -0
- package/dist/testing/conformance-kit.test.js +434 -0
- package/dist/testing/conformance-kit.test.js.map +1 -0
- package/dist/testing/contract-suite.d.ts +7 -0
- package/dist/testing/contract-suite.d.ts.map +1 -1
- package/dist/testing/contract-suite.js +7 -1
- package/dist/testing/contract-suite.js.map +1 -1
- package/dist/testing/index.d.ts +5 -0
- package/dist/testing/index.d.ts.map +1 -0
- package/dist/testing/index.js +8 -0
- package/dist/testing/index.js.map +1 -0
- package/dist/types.d.ts +91 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +13 -1
|
@@ -0,0 +1,323 @@
|
|
|
1
|
+
import { describe, it, expect, afterEach } from "vitest";
|
|
2
|
+
import { validateBaseUrl } from "./contract-suite.js";
|
|
3
|
+
import { META_TOOL_CONTRACTS, } from "../meta-tool-contract.js";
|
|
4
|
+
/** True when `value` matches the JSON-value kind `rule.kind` demands. */
|
|
5
|
+
export function fieldMatches(rule, value) {
|
|
6
|
+
switch (rule.kind) {
|
|
7
|
+
case "string":
|
|
8
|
+
return typeof value === "string";
|
|
9
|
+
case "string-enum":
|
|
10
|
+
return (typeof value === "string" &&
|
|
11
|
+
(rule.values?.includes(value) ?? false));
|
|
12
|
+
case "number":
|
|
13
|
+
return typeof value === "number";
|
|
14
|
+
case "boolean":
|
|
15
|
+
return typeof value === "boolean";
|
|
16
|
+
case "array":
|
|
17
|
+
return Array.isArray(value);
|
|
18
|
+
case "object":
|
|
19
|
+
return (typeof value === "object" && value !== null && !Array.isArray(value));
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Check a wire object against a {@link WireShape}. Returns the violations
|
|
24
|
+
* found (empty array = conforms). A field is checked when it is `required`
|
|
25
|
+
* (the default) or present; absent optional fields are skipped.
|
|
26
|
+
*/
|
|
27
|
+
export function checkWireShape(shape, obj) {
|
|
28
|
+
if (typeof obj !== "object" || obj === null || Array.isArray(obj)) {
|
|
29
|
+
return [
|
|
30
|
+
{
|
|
31
|
+
code: "wire-shape",
|
|
32
|
+
detail: `${shape.name}: expected an object, got ${describeType(obj)}`,
|
|
33
|
+
},
|
|
34
|
+
];
|
|
35
|
+
}
|
|
36
|
+
const record = obj;
|
|
37
|
+
const violations = [];
|
|
38
|
+
for (const rule of shape.fields) {
|
|
39
|
+
const required = rule.required ?? true;
|
|
40
|
+
const present = rule.name in record && record[rule.name] != null;
|
|
41
|
+
if (!present) {
|
|
42
|
+
if (required) {
|
|
43
|
+
violations.push({
|
|
44
|
+
code: "wire-shape",
|
|
45
|
+
detail: `${shape.name}.${rule.name}: required field is missing`,
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
continue;
|
|
49
|
+
}
|
|
50
|
+
if (!fieldMatches(rule, record[rule.name])) {
|
|
51
|
+
violations.push({
|
|
52
|
+
code: "wire-shape",
|
|
53
|
+
detail: `${shape.name}.${rule.name}: expected ${describeRule(rule)}, got ${describeType(record[rule.name])}`,
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
return violations;
|
|
58
|
+
}
|
|
59
|
+
function describeType(value) {
|
|
60
|
+
if (value === null)
|
|
61
|
+
return "null";
|
|
62
|
+
if (Array.isArray(value))
|
|
63
|
+
return "array";
|
|
64
|
+
return typeof value;
|
|
65
|
+
}
|
|
66
|
+
function describeRule(rule) {
|
|
67
|
+
if (rule.kind === "string-enum") {
|
|
68
|
+
return `one of [${(rule.values ?? []).join(", ")}]`;
|
|
69
|
+
}
|
|
70
|
+
return rule.kind;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Verify a successful action result: the `ToolResult` reports success and
|
|
74
|
+
* its `data` conforms to the action's result wire shape. Also enforces that
|
|
75
|
+
* a `statusField`, when declared, holds a value the state machine knows —
|
|
76
|
+
* a terminal status or `in_progress`/non-terminal status drawn from the
|
|
77
|
+
* declared enum (the enum check is part of the wire shape).
|
|
78
|
+
*/
|
|
79
|
+
export function checkActionResult(descriptor, action, result) {
|
|
80
|
+
const rule = descriptor.stateMachine?.actions.find((a) => a.action === action);
|
|
81
|
+
if (!rule) {
|
|
82
|
+
return [
|
|
83
|
+
{
|
|
84
|
+
code: "action-state",
|
|
85
|
+
detail: `${descriptor.toolName}: action "${action}" is not in the state machine`,
|
|
86
|
+
},
|
|
87
|
+
];
|
|
88
|
+
}
|
|
89
|
+
if (!result.success) {
|
|
90
|
+
return [
|
|
91
|
+
{
|
|
92
|
+
code: "action-state",
|
|
93
|
+
detail: `${descriptor.toolName}.${action}: expected a success result, got error "${result.error ?? ""}"`,
|
|
94
|
+
},
|
|
95
|
+
];
|
|
96
|
+
}
|
|
97
|
+
return checkWireShape(rule.result, result.data);
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Verify a single-shot tool's happy-path result: the `ToolResult` reports
|
|
101
|
+
* success and its `data` conforms to the descriptor's `singleShot` result
|
|
102
|
+
* wire shape. This gives a no-state-machine tool (e.g. `codespar_discover`)
|
|
103
|
+
* the same wire-shape teeth the action path has — a wrong-shaped result
|
|
104
|
+
* fails with a precise `[wire-shape]` violation rather than passing on
|
|
105
|
+
* `success: true` alone.
|
|
106
|
+
*/
|
|
107
|
+
export function checkSingleShotResult(descriptor, result) {
|
|
108
|
+
const rule = descriptor.singleShot;
|
|
109
|
+
if (!rule) {
|
|
110
|
+
return [
|
|
111
|
+
{
|
|
112
|
+
code: "wire-shape",
|
|
113
|
+
detail: `${descriptor.toolName}: no single-shot rule on the descriptor`,
|
|
114
|
+
},
|
|
115
|
+
];
|
|
116
|
+
}
|
|
117
|
+
if (!result.success) {
|
|
118
|
+
return [
|
|
119
|
+
{
|
|
120
|
+
code: "wire-shape",
|
|
121
|
+
detail: `${descriptor.toolName}: expected a success result, got error "${result.error ?? ""}"`,
|
|
122
|
+
},
|
|
123
|
+
];
|
|
124
|
+
}
|
|
125
|
+
return checkWireShape(rule.result, result.data);
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Verify the unregistered-tool error rule: a runtime with no registered
|
|
129
|
+
* implementation returns `success: false` with an `error` that starts with
|
|
130
|
+
* the descriptor's `unregisteredErrorPrefix` (never an HTTP-level error and
|
|
131
|
+
* never a success result).
|
|
132
|
+
*/
|
|
133
|
+
export function checkUnregisteredError(descriptor, result) {
|
|
134
|
+
const prefix = descriptor.errors.unregisteredErrorPrefix;
|
|
135
|
+
if (result.success) {
|
|
136
|
+
return [
|
|
137
|
+
{
|
|
138
|
+
code: "error-unregistered",
|
|
139
|
+
detail: `${descriptor.toolName}: expected an unregistered error, got a success result`,
|
|
140
|
+
},
|
|
141
|
+
];
|
|
142
|
+
}
|
|
143
|
+
if (!result.error || !result.error.startsWith(prefix)) {
|
|
144
|
+
return [
|
|
145
|
+
{
|
|
146
|
+
code: "error-unregistered",
|
|
147
|
+
detail: `${descriptor.toolName}: expected error starting with "${prefix}", got "${result.error ?? ""}"`,
|
|
148
|
+
},
|
|
149
|
+
];
|
|
150
|
+
}
|
|
151
|
+
return [];
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Verify the malformed-input error rule: a malformed input yields a typed
|
|
155
|
+
* error envelope (`success: false` with a non-empty `error`) rather than a
|
|
156
|
+
* success result. The error message itself is implementation-defined; only
|
|
157
|
+
* the shape of the failure is contracted.
|
|
158
|
+
*/
|
|
159
|
+
export function checkMalformedError(descriptor, result) {
|
|
160
|
+
if (result.success) {
|
|
161
|
+
return [
|
|
162
|
+
{
|
|
163
|
+
code: "error-malformed",
|
|
164
|
+
detail: `${descriptor.toolName}: expected a typed error for malformed input, got a success result`,
|
|
165
|
+
},
|
|
166
|
+
];
|
|
167
|
+
}
|
|
168
|
+
if (!result.error) {
|
|
169
|
+
return [
|
|
170
|
+
{
|
|
171
|
+
code: "error-malformed",
|
|
172
|
+
detail: `${descriptor.toolName}: expected a non-empty error for malformed input`,
|
|
173
|
+
},
|
|
174
|
+
];
|
|
175
|
+
}
|
|
176
|
+
return [];
|
|
177
|
+
}
|
|
178
|
+
async function openSession(baseUrl, apiKey, servers) {
|
|
179
|
+
const headers = {
|
|
180
|
+
"Content-Type": "application/json",
|
|
181
|
+
Authorization: `Bearer ${apiKey}`,
|
|
182
|
+
};
|
|
183
|
+
const res = await fetch(`${baseUrl}/v1/sessions`, {
|
|
184
|
+
method: "POST",
|
|
185
|
+
headers,
|
|
186
|
+
body: JSON.stringify({ servers, user_id: "conformance-suite" }),
|
|
187
|
+
});
|
|
188
|
+
if (!res.ok) {
|
|
189
|
+
const text = await res.text();
|
|
190
|
+
throw new Error(`session create failed: ${res.status} ${text}`);
|
|
191
|
+
}
|
|
192
|
+
const raw = (await res.json());
|
|
193
|
+
return {
|
|
194
|
+
get id() {
|
|
195
|
+
return raw.id;
|
|
196
|
+
},
|
|
197
|
+
async execute(toolName, params) {
|
|
198
|
+
const r = await fetch(`${baseUrl}/v1/sessions/${raw.id}/execute`, {
|
|
199
|
+
method: "POST",
|
|
200
|
+
headers,
|
|
201
|
+
body: JSON.stringify({ tool: toolName, input: params }),
|
|
202
|
+
});
|
|
203
|
+
if (!r.ok) {
|
|
204
|
+
const body = await r.text();
|
|
205
|
+
return {
|
|
206
|
+
success: false,
|
|
207
|
+
data: null,
|
|
208
|
+
error: `${r.status}: ${body}`,
|
|
209
|
+
duration: 0,
|
|
210
|
+
server: "",
|
|
211
|
+
tool: toolName,
|
|
212
|
+
};
|
|
213
|
+
}
|
|
214
|
+
return (await r.json());
|
|
215
|
+
},
|
|
216
|
+
async close() {
|
|
217
|
+
await fetch(`${baseUrl}/v1/sessions/${raw.id}`, {
|
|
218
|
+
method: "DELETE",
|
|
219
|
+
headers,
|
|
220
|
+
});
|
|
221
|
+
},
|
|
222
|
+
};
|
|
223
|
+
}
|
|
224
|
+
/** Build the action input the kit posts: the action rule's sample input
|
|
225
|
+
* plus the `action` discriminator. */
|
|
226
|
+
function actionInput(action, sample) {
|
|
227
|
+
return { action, ...sample };
|
|
228
|
+
}
|
|
229
|
+
/**
|
|
230
|
+
* Register the meta-tool conformance test suite against a live backend.
|
|
231
|
+
*
|
|
232
|
+
* Given a base URL and an `apiKey` for a backend that has an implementation
|
|
233
|
+
* of `opts.tool` registered, drives `execute(toolName, ...)` and asserts the
|
|
234
|
+
* tool's contract descriptor: every action's result wire shape, the action
|
|
235
|
+
* state machine (the declared status enum, terminal vs non-terminal), and
|
|
236
|
+
* the two error rules (unregistered → "Tool not registered"; malformed
|
|
237
|
+
* input → typed error envelope).
|
|
238
|
+
*
|
|
239
|
+
* The suite is implementation-agnostic — it tests whatever is registered at
|
|
240
|
+
* `baseUrl`. It validates the baseUrl before issuing any request: only
|
|
241
|
+
* https:// URLs and localhost are accepted, so a misconfigured CI
|
|
242
|
+
* environment fails early rather than leaking the apiKey to an arbitrary
|
|
243
|
+
* host.
|
|
244
|
+
*
|
|
245
|
+
* The unregistered-error leg uses a deliberately unregistered tool name
|
|
246
|
+
* (the contract'd tool name with a `__unregistered_probe` suffix) so it
|
|
247
|
+
* asserts the runtime's fall-through behavior without depending on any
|
|
248
|
+
* tool being absent.
|
|
249
|
+
*
|
|
250
|
+
* Backend prerequisites:
|
|
251
|
+
* - **Route prefix.** The kit drives `POST /v1/sessions`,
|
|
252
|
+
* `POST /v1/sessions/:id/execute`, and `DELETE /v1/sessions/:id` — the
|
|
253
|
+
* backend (or test harness) must mount the session routes under the `/v1`
|
|
254
|
+
* prefix.
|
|
255
|
+
* - **`servers` option.** `opts.servers` defaults to `[]`. A self-hosted
|
|
256
|
+
* OSS runtime accepts an empty server list on session create, but a
|
|
257
|
+
* managed backend requires at least one server — so a managed-side
|
|
258
|
+
* consumer MUST pass `opts.servers: [<seeded-server-id>]` (a server whose
|
|
259
|
+
* meta-tool implementation is registered), or session create will be
|
|
260
|
+
* rejected before any conformance case runs.
|
|
261
|
+
*
|
|
262
|
+
* @param baseUrl - API base URL (e.g. "https://your-runtime.example" or "http://localhost:3000")
|
|
263
|
+
* @param apiKey - Bearer token for session creation
|
|
264
|
+
* @param opts - The tool to assert and optional servers list (see {@link ConformanceSuiteOptions})
|
|
265
|
+
*/
|
|
266
|
+
export function runMetaToolConformanceSuite(baseUrl, apiKey, opts) {
|
|
267
|
+
validateBaseUrl(baseUrl);
|
|
268
|
+
const descriptor = META_TOOL_CONTRACTS[opts.tool];
|
|
269
|
+
const servers = opts.servers ?? [];
|
|
270
|
+
describe(`meta-tool conformance suite: ${descriptor.toolName}`, () => {
|
|
271
|
+
let session = null;
|
|
272
|
+
afterEach(async () => {
|
|
273
|
+
try {
|
|
274
|
+
if (session)
|
|
275
|
+
await session.close();
|
|
276
|
+
}
|
|
277
|
+
finally {
|
|
278
|
+
session = null;
|
|
279
|
+
}
|
|
280
|
+
});
|
|
281
|
+
if (descriptor.stateMachine) {
|
|
282
|
+
for (const action of descriptor.stateMachine.actions) {
|
|
283
|
+
it(`${descriptor.toolName} action "${action.action}" returns a conforming ${action.result.name}`, async () => {
|
|
284
|
+
session = await openSession(baseUrl, apiKey, servers);
|
|
285
|
+
const result = await session.execute(descriptor.toolName, actionInput(action.action, action.sampleInput));
|
|
286
|
+
const violations = checkActionResult(descriptor, action.action, result);
|
|
287
|
+
expect(violations, formatViolations(violations)).toEqual([]);
|
|
288
|
+
});
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
else if (descriptor.singleShot) {
|
|
292
|
+
const singleShot = descriptor.singleShot;
|
|
293
|
+
it(`${descriptor.toolName} returns a conforming ${singleShot.result.name}`, async () => {
|
|
294
|
+
session = await openSession(baseUrl, apiKey, servers);
|
|
295
|
+
const result = await session.execute(descriptor.toolName, singleShot.sampleInput);
|
|
296
|
+
const violations = checkSingleShotResult(descriptor, result);
|
|
297
|
+
expect(violations, formatViolations(violations)).toEqual([]);
|
|
298
|
+
});
|
|
299
|
+
}
|
|
300
|
+
it(`${descriptor.toolName} returns "${descriptor.errors.unregisteredErrorPrefix}" for an unregistered name`, async () => {
|
|
301
|
+
session = await openSession(baseUrl, apiKey, servers);
|
|
302
|
+
const result = await session.execute(`${descriptor.toolName}__unregistered_probe`, {});
|
|
303
|
+
const violations = checkUnregisteredError(descriptor, result);
|
|
304
|
+
expect(violations, formatViolations(violations)).toEqual([]);
|
|
305
|
+
});
|
|
306
|
+
it(`${descriptor.toolName} returns a typed error for malformed input`, async () => {
|
|
307
|
+
session = await openSession(baseUrl, apiKey, servers);
|
|
308
|
+
const malformed = descriptor.errors.malformedAction
|
|
309
|
+
? actionInput(descriptor.errors.malformedAction, descriptor.errors.malformedInput)
|
|
310
|
+
: descriptor.errors.malformedInput;
|
|
311
|
+
const result = await session.execute(descriptor.toolName, malformed);
|
|
312
|
+
const violations = checkMalformedError(descriptor, result);
|
|
313
|
+
expect(violations, formatViolations(violations)).toEqual([]);
|
|
314
|
+
});
|
|
315
|
+
});
|
|
316
|
+
}
|
|
317
|
+
/** Join violations into a single message for an assertion failure. */
|
|
318
|
+
export function formatViolations(violations) {
|
|
319
|
+
if (violations.length === 0)
|
|
320
|
+
return "no violations";
|
|
321
|
+
return violations.map((v) => `[${v.code}] ${v.detail}`).join("; ");
|
|
322
|
+
}
|
|
323
|
+
//# sourceMappingURL=conformance-kit.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"conformance-kit.js","sourceRoot":"","sources":["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uB;IACtD,IAAI,UAAU,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,eAAe,CAAC;IACpD,OAAO,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACrE,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Unit tests for the meta-tool conformance kit.
|
|
3
|
+
*
|
|
4
|
+
* The kit's value is its pass/fail logic: a conforming implementation
|
|
5
|
+
* passes, and an implementation that violates a wire shape, an action-state
|
|
6
|
+
* rule, or an error rule fails — with a violation naming the specific
|
|
7
|
+
* breach. We prove that two ways without a real backend:
|
|
8
|
+
*
|
|
9
|
+
* 1. The pure verification core (`checkWireShape`, `checkActionResult`,
|
|
10
|
+
* `checkUnregisteredError`, `checkMalformedError`) is exercised
|
|
11
|
+
* directly against hand-built conforming and violating envelopes.
|
|
12
|
+
* 2. The live suite (`runMetaToolConformanceSuite`) is run end-to-end
|
|
13
|
+
* against a FAKE backend (a stubbed `fetch`), asserting that a
|
|
14
|
+
* conforming fake registers passing cases and a fake that breaks each
|
|
15
|
+
* rule registers a failing case carrying the right violation.
|
|
16
|
+
*/
|
|
17
|
+
export {};
|
|
18
|
+
//# sourceMappingURL=conformance-kit.test.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"conformance-kit.test.d.ts","sourceRoot":"","sources":["../../src/testing/conformance-kit.test.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG"}
|