stitchkit 0.54.0 → 0.55.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/README.md +4 -1
- package/dist/browser/socket-io.d.ts +11 -1
- package/dist/browser/socket-io.d.ts.map +1 -1
- package/dist/cli.js +14 -9
- package/dist/contract/file-ref.d.ts +13 -0
- package/dist/contract/file-ref.d.ts.map +1 -0
- package/dist/contract/index.d.ts +1 -0
- package/dist/contract/index.d.ts.map +1 -1
- package/dist/contract/index.js +21 -17
- package/dist/files/boundary.d.ts +52 -0
- package/dist/files/boundary.d.ts.map +1 -0
- package/dist/files.d.ts +3 -0
- package/dist/files.d.ts.map +1 -0
- package/dist/files.js +16 -0
- package/dist/{index-7vb44hy8.js → index-0gv7k0ra.js} +127 -92
- package/dist/index-1bx83sw4.js +4 -0
- package/dist/index-1k16zv57.js +269 -0
- package/dist/index-6k1937bx.js +20 -0
- package/dist/{index-bmnhqtya.js → index-7eq9va6e.js} +1 -4
- package/dist/{index-yxpe3phd.js → index-cby4ar3v.js} +1 -18
- package/dist/index-h60df7rj.js +110 -0
- package/dist/{index-yez419px.js → index-js7yexng.js} +19 -6
- package/dist/index-k4dftwf7.js +66 -0
- package/dist/{index-z7761jk2.js → index-npye5kt7.js} +16 -22
- package/dist/{index-b15rtha1.js → index-pzc32v75.js} +61 -3
- package/dist/{index-e1es808r.js → index-qh4xevf5.js} +1 -1
- package/dist/{index-gvha32jh.js → index-qx84bqzk.js} +2 -2
- package/dist/{index-pfqjb5xy.js → index-rgd18hx3.js} +23 -5
- package/dist/index-sbdmyz75.js +18 -0
- package/dist/{index-173tvqcp.js → index-v4bbq3p4.js} +9 -114
- package/dist/index.js +162 -35
- package/dist/node.js +30 -27
- package/dist/observability/index.js +28 -25
- package/dist/react.js +2 -2
- package/dist/realtime/contract.d.ts +9 -0
- package/dist/realtime/contract.d.ts.map +1 -1
- package/dist/realtime/index.d.ts +2 -1
- package/dist/realtime/index.d.ts.map +1 -1
- package/dist/realtime/request.d.ts +21 -0
- package/dist/realtime/request.d.ts.map +1 -0
- package/dist/realtime/socket.d.ts +3 -0
- package/dist/realtime/socket.d.ts.map +1 -1
- package/dist/remote.d.ts +9 -0
- package/dist/remote.d.ts.map +1 -0
- package/dist/remote.js +79 -0
- package/dist/server/context-contribution.d.ts +10 -0
- package/dist/server/context-contribution.d.ts.map +1 -0
- package/dist/server/context.d.ts.map +1 -1
- package/dist/server/index.d.ts +2 -1
- package/dist/server/index.d.ts.map +1 -1
- package/dist/server/index.js +133 -88
- package/dist/server/lifecycle.d.ts +4 -0
- package/dist/server/lifecycle.d.ts.map +1 -0
- package/dist/server/middleware/auth.d.ts +35 -7
- package/dist/server/middleware/auth.d.ts.map +1 -1
- package/dist/server/types.d.ts +1 -1
- package/dist/server/types.d.ts.map +1 -1
- package/dist/testing/surface-conformance.d.ts +47 -0
- package/dist/testing/surface-conformance.d.ts.map +1 -0
- package/dist/testing/surface-manifest.d.ts +156 -0
- package/dist/testing/surface-manifest.d.ts.map +1 -0
- package/dist/testing.d.ts +2 -0
- package/dist/testing.d.ts.map +1 -1
- package/dist/testing.js +366 -3
- package/dist/tools/agent.d.ts.map +1 -1
- package/dist/tools/async-operation.d.ts +168 -0
- package/dist/tools/async-operation.d.ts.map +1 -0
- package/dist/tools/cli-args.d.ts +1 -1
- package/dist/tools/cli-args.d.ts.map +1 -1
- package/dist/tools/cli-format.d.ts +2 -2
- package/dist/tools/cli-format.d.ts.map +1 -1
- package/dist/tools/cli-wait.d.ts +11 -2
- package/dist/tools/cli-wait.d.ts.map +1 -1
- package/dist/tools/cli.d.ts +2 -0
- package/dist/tools/cli.d.ts.map +1 -1
- package/dist/tools/define-download-tool.d.ts +6 -5
- package/dist/tools/define-download-tool.d.ts.map +1 -1
- package/dist/tools/define-upload-tool.d.ts +3 -1
- package/dist/tools/define-upload-tool.d.ts.map +1 -1
- package/dist/tools/define-wait-tool.d.ts +1 -1
- package/dist/tools/define-wait-tool.d.ts.map +1 -1
- package/dist/tools/download-core.d.ts +5 -10
- package/dist/tools/download-core.d.ts.map +1 -1
- package/dist/tools/lifecycle.d.ts +4 -0
- package/dist/tools/lifecycle.d.ts.map +1 -0
- package/dist/tools/mount-download.d.ts +5 -4
- package/dist/tools/mount-download.d.ts.map +1 -1
- package/dist/tools/mount-upload.d.ts +4 -2
- package/dist/tools/mount-upload.d.ts.map +1 -1
- package/dist/tools/upload-core.d.ts +3 -2
- package/dist/tools/upload-core.d.ts.map +1 -1
- package/dist/tools/view-file.d.ts +4 -3
- package/dist/tools/view-file.d.ts.map +1 -1
- package/dist/tools/wait-core.d.ts +6 -1
- package/dist/tools/wait-core.d.ts.map +1 -1
- package/dist/tools.d.ts +3 -2
- package/dist/tools.d.ts.map +1 -1
- package/dist/tools.js +385 -244
- package/llms-full.txt +417 -27
- package/package.json +10 -2
package/dist/testing.js
CHANGED
|
@@ -1,9 +1,362 @@
|
|
|
1
|
+
import {
|
|
2
|
+
assertToolName,
|
|
3
|
+
assertUniqueToolName,
|
|
4
|
+
toToolName
|
|
5
|
+
} from "./index-k4dftwf7.js";
|
|
6
|
+
import {
|
|
7
|
+
toJsonSchema
|
|
8
|
+
} from "./index-cby4ar3v.js";
|
|
1
9
|
import {
|
|
2
10
|
createClient,
|
|
3
11
|
createClients
|
|
4
|
-
} from "./index-
|
|
12
|
+
} from "./index-qh4xevf5.js";
|
|
5
13
|
import"./index-48ffdxgk.js";
|
|
6
|
-
import
|
|
14
|
+
import {
|
|
15
|
+
isRecord
|
|
16
|
+
} from "./index-7eq9va6e.js";
|
|
17
|
+
import"./index-1bx83sw4.js";
|
|
18
|
+
|
|
19
|
+
// src/testing/surface-conformance.ts
|
|
20
|
+
import { z as z2 } from "zod";
|
|
21
|
+
|
|
22
|
+
// src/testing/surface-manifest.ts
|
|
23
|
+
import { createHash } from "node:crypto";
|
|
24
|
+
import { z } from "zod";
|
|
25
|
+
var HttpMethodSchema = z.enum(["GET", "POST", "PUT", "PATCH", "DELETE", "HEAD"]);
|
|
26
|
+
var ToolTransportSchema = z.enum(["MCP", "AGENT", "CLI"]);
|
|
27
|
+
var SurfaceSchemaDigestsSchema = z.object({
|
|
28
|
+
params: z.string().nullable(),
|
|
29
|
+
input: z.string().nullable(),
|
|
30
|
+
output: z.string().nullable(),
|
|
31
|
+
multipart: z.string().nullable()
|
|
32
|
+
});
|
|
33
|
+
var SurfaceManifestOperationSchema = z.object({
|
|
34
|
+
kind: z.enum(["contract", "runtime"]),
|
|
35
|
+
service: z.string(),
|
|
36
|
+
action: z.string(),
|
|
37
|
+
method: HttpMethodSchema,
|
|
38
|
+
scope: z.string().nullable(),
|
|
39
|
+
description: z.string(),
|
|
40
|
+
schemas: SurfaceSchemaDigestsSchema,
|
|
41
|
+
http: z.array(z.object({ method: HttpMethodSchema, path: z.string() })),
|
|
42
|
+
tools: z.partialRecord(ToolTransportSchema, z.string())
|
|
43
|
+
});
|
|
44
|
+
var SurfaceManifestCliCommandSchema = z.object({
|
|
45
|
+
name: z.string(),
|
|
46
|
+
description: z.string(),
|
|
47
|
+
input: z.string(),
|
|
48
|
+
output: z.string().nullable()
|
|
49
|
+
});
|
|
50
|
+
var SurfaceManifestExtensionSchema = z.object({
|
|
51
|
+
name: z.string(),
|
|
52
|
+
transport: z.enum(["HTTP", "MCP", "AGENT", "CLI"])
|
|
53
|
+
});
|
|
54
|
+
var SurfaceManifestSchema = z.object({
|
|
55
|
+
manifestVersion: z.literal(1),
|
|
56
|
+
digestVersion: z.literal(1),
|
|
57
|
+
operations: z.array(SurfaceManifestOperationSchema),
|
|
58
|
+
cliOnly: z.array(SurfaceManifestCliCommandSchema),
|
|
59
|
+
extensions: z.array(SurfaceManifestExtensionSchema)
|
|
60
|
+
});
|
|
61
|
+
function compareCodepoints(left, right) {
|
|
62
|
+
if (left < right)
|
|
63
|
+
return -1;
|
|
64
|
+
if (left > right)
|
|
65
|
+
return 1;
|
|
66
|
+
return 0;
|
|
67
|
+
}
|
|
68
|
+
function canonicalValue(value) {
|
|
69
|
+
if (Array.isArray(value))
|
|
70
|
+
return value.map(canonicalValue);
|
|
71
|
+
if (!isRecord(value))
|
|
72
|
+
return value;
|
|
73
|
+
const result = {};
|
|
74
|
+
for (const key of Object.keys(value).sort(compareCodepoints)) {
|
|
75
|
+
result[key] = canonicalValue(value[key]);
|
|
76
|
+
}
|
|
77
|
+
return result;
|
|
78
|
+
}
|
|
79
|
+
function serializeSurfaceValue(value) {
|
|
80
|
+
return JSON.stringify(canonicalValue(value));
|
|
81
|
+
}
|
|
82
|
+
function digestValue(value) {
|
|
83
|
+
return createHash("sha256").update(serializeSurfaceValue(value)).digest("hex").slice(0, 16);
|
|
84
|
+
}
|
|
85
|
+
function canonicalSchemaValue(value, parentKey) {
|
|
86
|
+
if (Array.isArray(value)) {
|
|
87
|
+
const entries = value.map((entry) => canonicalSchemaValue(entry));
|
|
88
|
+
return parentKey === "required" && entries.every((entry) => typeof entry === "string") ? entries.sort((left, right) => compareCodepoints(String(left), String(right))) : entries;
|
|
89
|
+
}
|
|
90
|
+
if (!isRecord(value))
|
|
91
|
+
return value;
|
|
92
|
+
const result = {};
|
|
93
|
+
for (const key of Object.keys(value).sort(compareCodepoints)) {
|
|
94
|
+
result[key] = canonicalSchemaValue(value[key], key);
|
|
95
|
+
}
|
|
96
|
+
return result;
|
|
97
|
+
}
|
|
98
|
+
function schemaDigest(schema, io) {
|
|
99
|
+
if (!schema)
|
|
100
|
+
return null;
|
|
101
|
+
return digestValue(canonicalSchemaValue(toJsonSchema(schema, io, "any")));
|
|
102
|
+
}
|
|
103
|
+
function multipartDigest(value) {
|
|
104
|
+
return value === undefined ? null : digestValue(value);
|
|
105
|
+
}
|
|
106
|
+
function joinPath(...parts) {
|
|
107
|
+
const joined = parts.filter((part) => Boolean(part)).map((part) => part.replace(/^\/+|\/+$/g, "")).filter(Boolean).join("/");
|
|
108
|
+
return `/${joined}`;
|
|
109
|
+
}
|
|
110
|
+
function operationKey(kind, service, action) {
|
|
111
|
+
return `${kind}\x00${service}\x00${action}`;
|
|
112
|
+
}
|
|
113
|
+
function uniqueToolServices(config) {
|
|
114
|
+
const services = new Set;
|
|
115
|
+
for (const service of config.services ?? [])
|
|
116
|
+
services.add(service);
|
|
117
|
+
for (const group of config.groups ?? []) {
|
|
118
|
+
for (const service of group.services)
|
|
119
|
+
services.add(service);
|
|
120
|
+
}
|
|
121
|
+
return [...services];
|
|
122
|
+
}
|
|
123
|
+
function buildSurfaceManifest(config) {
|
|
124
|
+
const operations = new Map;
|
|
125
|
+
const addContract = (service, prefix) => {
|
|
126
|
+
for (const method of Object.values(service.methods)) {
|
|
127
|
+
const key = operationKey("contract", service.name, method.key);
|
|
128
|
+
const existing = operations.get(key);
|
|
129
|
+
const http = !method.expose || method.expose.includes("HTTP") ? [{ method: method.method, path: joinPath(prefix, service.prefix, method.path) }] : [];
|
|
130
|
+
if (existing) {
|
|
131
|
+
existing.http.push(...http);
|
|
132
|
+
continue;
|
|
133
|
+
}
|
|
134
|
+
operations.set(key, {
|
|
135
|
+
kind: "contract",
|
|
136
|
+
service: service.name,
|
|
137
|
+
action: method.key,
|
|
138
|
+
method: method.method,
|
|
139
|
+
scope: method.scope ?? service.scope ?? null,
|
|
140
|
+
description: method.desc,
|
|
141
|
+
schemas: {
|
|
142
|
+
params: schemaDigest(method.paramsSchema, "input"),
|
|
143
|
+
input: schemaDigest(method.inputSchema, "input"),
|
|
144
|
+
output: schemaDigest(method.outputSchema, "output"),
|
|
145
|
+
multipart: multipartDigest(method.multipart)
|
|
146
|
+
},
|
|
147
|
+
http,
|
|
148
|
+
tools: {}
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
};
|
|
152
|
+
for (const service of config.services ?? []) {
|
|
153
|
+
addContract(service, config.scopePrefixes?.[service.scope] ?? "");
|
|
154
|
+
}
|
|
155
|
+
for (const group of config.groups ?? []) {
|
|
156
|
+
for (const service of group.services)
|
|
157
|
+
addContract(service, group.pathPrefix ?? "");
|
|
158
|
+
}
|
|
159
|
+
for (const definition of config.runtimeTools ?? []) {
|
|
160
|
+
const identity = definition.identity;
|
|
161
|
+
const key = operationKey("runtime", identity.serviceName, identity.action);
|
|
162
|
+
if (operations.has(key)) {
|
|
163
|
+
throw new Error(`Duplicate runtime operation identity ${identity.serviceName}.${identity.action}`);
|
|
164
|
+
}
|
|
165
|
+
operations.set(key, {
|
|
166
|
+
kind: "runtime",
|
|
167
|
+
service: identity.serviceName,
|
|
168
|
+
action: identity.action,
|
|
169
|
+
method: identity.method,
|
|
170
|
+
scope: identity.scope ?? null,
|
|
171
|
+
description: definition.description,
|
|
172
|
+
schemas: {
|
|
173
|
+
params: null,
|
|
174
|
+
input: schemaDigest(definition.input, "input"),
|
|
175
|
+
output: schemaDigest(definition.output, "output"),
|
|
176
|
+
multipart: null
|
|
177
|
+
},
|
|
178
|
+
http: [],
|
|
179
|
+
tools: {}
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
const usedNames = {
|
|
183
|
+
MCP: new Set,
|
|
184
|
+
AGENT: new Set,
|
|
185
|
+
CLI: new Set
|
|
186
|
+
};
|
|
187
|
+
const addTool = (operation, name, transport) => {
|
|
188
|
+
if (transport !== "CLI")
|
|
189
|
+
assertToolName(name, operation.service, operation.action);
|
|
190
|
+
const surface = transport === "CLI" ? "CLI command" : transport === "MCP" ? "MCP tool name" : "agent tool name";
|
|
191
|
+
assertUniqueToolName(name, usedNames[transport].has(name), surface);
|
|
192
|
+
usedNames[transport].add(name);
|
|
193
|
+
operation.tools[transport] = name;
|
|
194
|
+
};
|
|
195
|
+
for (const service of uniqueToolServices(config)) {
|
|
196
|
+
for (const method of Object.values(service.methods)) {
|
|
197
|
+
if (method.multipart || method.rawBody || method.rawResponse || method.responseMeta)
|
|
198
|
+
continue;
|
|
199
|
+
const operation = operations.get(operationKey("contract", service.name, method.key));
|
|
200
|
+
if (!operation)
|
|
201
|
+
continue;
|
|
202
|
+
const name = method.toolName ?? toToolName(service.name, method.key);
|
|
203
|
+
if (!method.expose || method.expose.includes("MCP"))
|
|
204
|
+
addTool(operation, name, "MCP");
|
|
205
|
+
if (!method.expose || method.expose.includes("AGENT"))
|
|
206
|
+
addTool(operation, name, "AGENT");
|
|
207
|
+
if (method.expose?.includes("CLI"))
|
|
208
|
+
addTool(operation, name, "CLI");
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
for (const definition of config.runtimeTools ?? []) {
|
|
212
|
+
const operation = operations.get(operationKey("runtime", definition.identity.serviceName, definition.identity.action));
|
|
213
|
+
if (!operation)
|
|
214
|
+
continue;
|
|
215
|
+
const transports = definition.transports ?? [
|
|
216
|
+
"MCP",
|
|
217
|
+
"AGENT"
|
|
218
|
+
];
|
|
219
|
+
for (const transport of transports)
|
|
220
|
+
addTool(operation, definition.name, transport);
|
|
221
|
+
}
|
|
222
|
+
const cliOnly = (config.cliCommands ?? []).map((command) => ({
|
|
223
|
+
name: command.name,
|
|
224
|
+
description: command.description,
|
|
225
|
+
input: schemaDigest(command.input, "input") ?? digestValue({}),
|
|
226
|
+
output: schemaDigest(command.output, "output")
|
|
227
|
+
})).sort((left, right) => compareCodepoints(left.name, right.name));
|
|
228
|
+
return SurfaceManifestSchema.parse({
|
|
229
|
+
manifestVersion: 1,
|
|
230
|
+
digestVersion: 1,
|
|
231
|
+
operations: [...operations.values()].sort((left, right) => compareCodepoints(left.service, right.service) || compareCodepoints(left.action, right.action) || compareCodepoints(left.kind, right.kind)),
|
|
232
|
+
cliOnly,
|
|
233
|
+
extensions: [...config.extensions ?? []].sort((left, right) => compareCodepoints(left.transport, right.transport) || compareCodepoints(left.name, right.name))
|
|
234
|
+
});
|
|
235
|
+
}
|
|
236
|
+
function assertSurfaceManifestSnapshot(manifest, snapshot) {
|
|
237
|
+
const actual = serializeSurfaceValue(SurfaceManifestSchema.parse(manifest));
|
|
238
|
+
const expected = serializeSurfaceValue(SurfaceManifestSchema.parse(snapshot));
|
|
239
|
+
if (actual !== expected) {
|
|
240
|
+
throw new Error(`Surface manifest diverged from its committed snapshot
|
|
241
|
+
expected: ${expected}
|
|
242
|
+
actual: ${actual}`);
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
// src/testing/surface-conformance.ts
|
|
247
|
+
var ProbeOutcomeSchema = z2.enum(["success", "validation_error", "domain_error", "aborted"]);
|
|
248
|
+
var TransportObservationSchema = z2.object({
|
|
249
|
+
outcome: ProbeOutcomeSchema,
|
|
250
|
+
code: z2.string().optional(),
|
|
251
|
+
data: z2.unknown().optional(),
|
|
252
|
+
diagnostic: z2.string().optional()
|
|
253
|
+
});
|
|
254
|
+
function sorted(values) {
|
|
255
|
+
return [...values].sort((left, right) => left < right ? -1 : left > right ? 1 : 0);
|
|
256
|
+
}
|
|
257
|
+
function assertSameSet(label, expectedValues, actualValues) {
|
|
258
|
+
const expected = sorted(expectedValues);
|
|
259
|
+
const actual = sorted(actualValues);
|
|
260
|
+
if (serializeSurfaceValue(expected) === serializeSurfaceValue(actual))
|
|
261
|
+
return;
|
|
262
|
+
throw new Error(`${label} mismatch
|
|
263
|
+
expected: ${expected.join(", ") || "(empty)"}
|
|
264
|
+
actual: ${actual.join(", ") || "(empty)"}`);
|
|
265
|
+
}
|
|
266
|
+
function openApiOperations(document) {
|
|
267
|
+
return Object.entries(document.paths).flatMap(([path, item]) => Object.keys(item).filter((method) => ["get", "post", "put", "patch", "delete", "head"].includes(method)).map((method) => `${method.toUpperCase()}:${path}`));
|
|
268
|
+
}
|
|
269
|
+
function expectedToolNames(operations, transport) {
|
|
270
|
+
return operations.flatMap((operation) => {
|
|
271
|
+
const name = operation.tools[transport];
|
|
272
|
+
return name ? [name] : [];
|
|
273
|
+
});
|
|
274
|
+
}
|
|
275
|
+
function assertSurfaceDiscovery(manifest, observed) {
|
|
276
|
+
if (observed.openApi) {
|
|
277
|
+
assertSameSet("HTTP/OpenAPI", manifest.operations.flatMap((operation) => operation.http.map((entry) => `${entry.method}:${entry.path.replace(/:([^/]+)/g, "{$1}")}`)), openApiOperations(observed.openApi));
|
|
278
|
+
}
|
|
279
|
+
for (const transport of ["MCP", "AGENT", "CLI"]) {
|
|
280
|
+
const names = observed[transport];
|
|
281
|
+
if (names)
|
|
282
|
+
assertSameSet(`${transport} discovery`, expectedToolNames(manifest.operations, transport), names);
|
|
283
|
+
}
|
|
284
|
+
if (observed.cliOnly) {
|
|
285
|
+
assertSameSet("CLI-only discovery", manifest.cliOnly.map((command) => command.name), observed.cliOnly);
|
|
286
|
+
}
|
|
287
|
+
for (const transport of ["HTTP", "MCP", "AGENT", "CLI"]) {
|
|
288
|
+
const names = observed.extensions?.[transport];
|
|
289
|
+
if (!names)
|
|
290
|
+
continue;
|
|
291
|
+
assertSameSet(`${transport} extension discovery`, manifest.extensions.filter((extension) => extension.transport === transport).map((extension) => extension.name), names);
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
function boundedObservation(observation, maxDiagnosticBytes) {
|
|
295
|
+
const parsed = TransportObservationSchema.parse(observation);
|
|
296
|
+
if (!parsed.diagnostic)
|
|
297
|
+
return parsed;
|
|
298
|
+
const bytes = new TextEncoder().encode(parsed.diagnostic);
|
|
299
|
+
if (bytes.byteLength <= maxDiagnosticBytes)
|
|
300
|
+
return parsed;
|
|
301
|
+
return {
|
|
302
|
+
...parsed,
|
|
303
|
+
diagnostic: new TextDecoder().decode(bytes.slice(0, maxDiagnosticBytes))
|
|
304
|
+
};
|
|
305
|
+
}
|
|
306
|
+
async function invokeBounded(driver, fixture, signal) {
|
|
307
|
+
signal.throwIfAborted();
|
|
308
|
+
let removeAbortListener = () => {
|
|
309
|
+
return;
|
|
310
|
+
};
|
|
311
|
+
const aborted = new Promise((_resolve, reject) => {
|
|
312
|
+
const onAbort = () => reject(signal.reason);
|
|
313
|
+
signal.addEventListener("abort", onAbort, { once: true });
|
|
314
|
+
removeAbortListener = () => signal.removeEventListener("abort", onAbort);
|
|
315
|
+
});
|
|
316
|
+
try {
|
|
317
|
+
return await Promise.race([driver.invoke(fixture, signal), aborted]);
|
|
318
|
+
} finally {
|
|
319
|
+
removeAbortListener();
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
async function runSurfaceProbes({
|
|
323
|
+
probes,
|
|
324
|
+
drivers,
|
|
325
|
+
signal,
|
|
326
|
+
timeoutMs = 1e4,
|
|
327
|
+
maxDiagnosticBytes = 4096
|
|
328
|
+
}) {
|
|
329
|
+
if (!Number.isFinite(timeoutMs) || timeoutMs <= 0) {
|
|
330
|
+
throw new TypeError("Surface probe timeoutMs must be a finite positive number");
|
|
331
|
+
}
|
|
332
|
+
if (!Number.isInteger(maxDiagnosticBytes) || maxDiagnosticBytes <= 0) {
|
|
333
|
+
throw new TypeError("Surface probe maxDiagnosticBytes must be a positive integer");
|
|
334
|
+
}
|
|
335
|
+
for (const probe of probes) {
|
|
336
|
+
await probe.setup?.();
|
|
337
|
+
try {
|
|
338
|
+
for (const transport of probe.transports) {
|
|
339
|
+
const driver = drivers[transport];
|
|
340
|
+
if (!driver)
|
|
341
|
+
throw new Error(`Surface probe "${probe.name}" has no ${transport} driver`);
|
|
342
|
+
const timeoutSignal = AbortSignal.timeout(timeoutMs);
|
|
343
|
+
const invokeSignal = signal ? AbortSignal.any([signal, timeoutSignal]) : timeoutSignal;
|
|
344
|
+
const actual = boundedObservation(await invokeBounded(driver, probe.fixture, invokeSignal), maxDiagnosticBytes);
|
|
345
|
+
const expected = probe.expected[transport];
|
|
346
|
+
if (!expected) {
|
|
347
|
+
throw new Error(`Surface probe "${probe.name}" has no ${transport} expectation`);
|
|
348
|
+
}
|
|
349
|
+
if (serializeSurfaceValue(actual) !== serializeSurfaceValue(expected)) {
|
|
350
|
+
throw new Error(`Surface probe "${probe.name}" ${transport} mismatch
|
|
351
|
+
expected: ${serializeSurfaceValue(expected)}
|
|
352
|
+
actual: ${serializeSurfaceValue(actual)}`);
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
} finally {
|
|
356
|
+
await probe.teardown?.();
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
}
|
|
7
360
|
|
|
8
361
|
// src/testing.ts
|
|
9
362
|
function resolveTestBaseUrl(origin, pathPrefix) {
|
|
@@ -31,6 +384,16 @@ function createHandlerTestClients(config) {
|
|
|
31
384
|
return createClients(config.contracts, createTestClientConfig(config), config.contractConfig);
|
|
32
385
|
}
|
|
33
386
|
export {
|
|
387
|
+
SurfaceManifestExtensionSchema,
|
|
388
|
+
SurfaceManifestOperationSchema,
|
|
389
|
+
SurfaceManifestSchema,
|
|
390
|
+
SurfaceSchemaDigestsSchema,
|
|
391
|
+
TransportObservationSchema,
|
|
392
|
+
assertSurfaceDiscovery,
|
|
393
|
+
assertSurfaceManifestSnapshot,
|
|
394
|
+
buildSurfaceManifest,
|
|
395
|
+
createHandlerTestClient,
|
|
34
396
|
createHandlerTestClients,
|
|
35
|
-
|
|
397
|
+
runSurfaceProbes,
|
|
398
|
+
serializeSurfaceValue
|
|
36
399
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent.d.ts","sourceRoot":"","sources":["../../src/tools/agent.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"agent.d.ts","sourceRoot":"","sources":["../../src/tools/agent.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAwB,OAAO,EAAE,MAAM,IAAI,CAAC;AAGxD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EACL,KAAK,WAAW,EAChB,KAAK,aAAa,EAClB,KAAK,aAAa,EAEnB,MAAM,WAAW,CAAC;AACnB,OAAO,EAAqC,KAAK,UAAU,EAAE,MAAM,SAAS,CAAC;AAC7E,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AAG5D,MAAM,WAAW,YAAY;IAC3B,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED,MAAM,WAAW,gBAAgB;IAC/B,OAAO,CAAC,EAAE,YAAY,CAAC;IACvB,qCAAqC;IACrC,KAAK,CAAC,EAAE,aAAa,CAAC;IACtB;;;;OAIG;IACH,SAAS,CAAC,EAAE,aAAa,CAAC;IAC1B,MAAM,CAAC,EAAE,UAAU,CAAC;IACpB,+EAA+E;IAC/E,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,mEAAmE;IACnE,aAAa,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,IAAI,CAAC;IAC5D,+EAA+E;IAC/E,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,gEAAgE;IAChE,SAAS,CAAC,EAAE,WAAW,CAAC;IACxB,2EAA2E;IAC3E,YAAY,CAAC,EAAE,SAAS,qBAAqB,EAAE,CAAC;CACjD;AAED,wBAAgB,UAAU,CACxB,QAAQ,EAAE,UAAU,GAAG,UAAU,EAAE,EACnC,MAAM,GAAE,gBAAqB,GAC5B,OAAO,CAwET"}
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
import { type ZodObject, type ZodType, z } from 'zod';
|
|
2
|
+
import type { ContractDef, EndpointDef, EndpointToolAnnotations } from '../contract';
|
|
3
|
+
import type { Handlers } from '../server/types';
|
|
4
|
+
import { type RuntimeToolDefinition, type RuntimeToolDefinitionWithOutput, type RuntimeToolHandlerContext, type RuntimeToolTransport } from './runtime-tool';
|
|
5
|
+
export declare const AsyncOperationCancelResultSchema: z.ZodDiscriminatedUnion<[ZodObject<{
|
|
6
|
+
outcome: z.ZodLiteral<"accepted">;
|
|
7
|
+
}, z.core.$strip>, ZodObject<{
|
|
8
|
+
outcome: z.ZodLiteral<"already_terminal">;
|
|
9
|
+
}, z.core.$strip>, ZodObject<{
|
|
10
|
+
outcome: z.ZodLiteral<"rejected">;
|
|
11
|
+
reason: z.ZodString;
|
|
12
|
+
}, z.core.$strip>], "outcome">;
|
|
13
|
+
export type AsyncOperationCancelResult = z.infer<typeof AsyncOperationCancelResultSchema>;
|
|
14
|
+
export type AsyncOperationCapability = 'start' | 'status' | 'wait' | 'cancel' | 'result' | 'artifacts';
|
|
15
|
+
export declare function createAsyncOperationSnapshotSchema<TProgress extends ZodType | undefined = undefined, TFailure extends ZodType = ZodType>(config: {
|
|
16
|
+
progress?: TProgress;
|
|
17
|
+
failure: TFailure;
|
|
18
|
+
}): z.ZodDiscriminatedUnion<[ZodObject<{
|
|
19
|
+
progress: z.ZodOptional<ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>>;
|
|
20
|
+
phase: z.ZodLiteral<"pending">;
|
|
21
|
+
} | {
|
|
22
|
+
progress?: undefined;
|
|
23
|
+
phase: z.ZodLiteral<"pending">;
|
|
24
|
+
}, z.core.$strip>, ZodObject<{
|
|
25
|
+
progress: z.ZodOptional<ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>>;
|
|
26
|
+
phase: z.ZodLiteral<"running">;
|
|
27
|
+
} | {
|
|
28
|
+
progress?: undefined;
|
|
29
|
+
phase: z.ZodLiteral<"running">;
|
|
30
|
+
}, z.core.$strip>, ZodObject<{
|
|
31
|
+
progress: z.ZodOptional<ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>>;
|
|
32
|
+
phase: z.ZodLiteral<"succeeded">;
|
|
33
|
+
} | {
|
|
34
|
+
progress?: undefined;
|
|
35
|
+
phase: z.ZodLiteral<"succeeded">;
|
|
36
|
+
}, z.core.$strip>, ZodObject<{
|
|
37
|
+
progress: z.ZodOptional<ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>>;
|
|
38
|
+
phase: z.ZodLiteral<"failed">;
|
|
39
|
+
failure: TFailure;
|
|
40
|
+
} | {
|
|
41
|
+
progress?: undefined;
|
|
42
|
+
phase: z.ZodLiteral<"failed">;
|
|
43
|
+
failure: TFailure;
|
|
44
|
+
}, z.core.$strip>, ZodObject<{
|
|
45
|
+
progress: z.ZodOptional<ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>>;
|
|
46
|
+
phase: z.ZodLiteral<"cancelled">;
|
|
47
|
+
} | {
|
|
48
|
+
progress?: undefined;
|
|
49
|
+
phase: z.ZodLiteral<"cancelled">;
|
|
50
|
+
}, z.core.$strip>], "phase">;
|
|
51
|
+
export interface AsyncOperationIdentity {
|
|
52
|
+
serviceName: string;
|
|
53
|
+
action: string;
|
|
54
|
+
scope?: string;
|
|
55
|
+
meta?: Record<string, unknown>;
|
|
56
|
+
}
|
|
57
|
+
export interface AsyncOperationCancelCapability<TId extends ZodObject, TState extends ZodType> {
|
|
58
|
+
handler: (state: z.output<TState>, context: RuntimeToolHandlerContext<TId>) => z.output<typeof AsyncOperationCancelResultSchema> | Promise<z.output<typeof AsyncOperationCancelResultSchema>>;
|
|
59
|
+
}
|
|
60
|
+
export interface AsyncOperationOutputCapability<TId extends ZodObject, TState extends ZodType, TOutput extends ZodType> {
|
|
61
|
+
output: TOutput;
|
|
62
|
+
handler: (state: z.output<TState>, context: RuntimeToolHandlerContext<TId>) => z.output<TOutput> | Promise<z.output<TOutput>>;
|
|
63
|
+
}
|
|
64
|
+
export interface RuntimeAsyncOperationConfig<TStartInput extends ZodObject, TId extends ZodObject, TState extends ZodType, TSnapshot extends ZodType, TCancel extends AsyncOperationCancelCapability<TId, TState> = never, TResult extends AsyncOperationOutputCapability<TId, TState, ZodType> = never, TArtifacts extends AsyncOperationOutputCapability<TId, TState, ZodType> = never> {
|
|
65
|
+
mode: 'runtime-only';
|
|
66
|
+
/** Provider-safe prefix used for the generated capability names. */
|
|
67
|
+
name: string;
|
|
68
|
+
description: string;
|
|
69
|
+
identity: AsyncOperationIdentity;
|
|
70
|
+
startInput: TStartInput;
|
|
71
|
+
id: TId;
|
|
72
|
+
state: TState;
|
|
73
|
+
snapshot: TSnapshot;
|
|
74
|
+
start: (input: z.output<TStartInput>, context: RuntimeToolHandlerContext<TStartInput>) => z.output<TId> | Promise<z.output<TId>>;
|
|
75
|
+
/** Mandatory resource authorization, repeated before every follow-up callback. */
|
|
76
|
+
authorize: (id: z.output<TId>, capability: Exclude<AsyncOperationCapability, 'start'>, context: RuntimeToolHandlerContext<TId>) => void | Promise<void>;
|
|
77
|
+
inspect: (id: z.output<TId>, context: RuntimeToolHandlerContext<TId>) => z.output<TState> | Promise<z.output<TState>>;
|
|
78
|
+
classify: (state: z.output<TState>, context: RuntimeToolHandlerContext<TId>) => z.output<TSnapshot> | Promise<z.output<TSnapshot>>;
|
|
79
|
+
cancel?: TCancel;
|
|
80
|
+
result?: TResult;
|
|
81
|
+
artifacts?: TArtifacts;
|
|
82
|
+
names?: Partial<Record<AsyncOperationCapability, string>>;
|
|
83
|
+
descriptions?: Partial<Record<AsyncOperationCapability, string>>;
|
|
84
|
+
scopes?: Partial<Record<AsyncOperationCapability, string>>;
|
|
85
|
+
annotations?: Partial<Record<AsyncOperationCapability, EndpointToolAnnotations>>;
|
|
86
|
+
transports?: Partial<Record<AsyncOperationCapability, readonly RuntimeToolTransport[]>>;
|
|
87
|
+
backoff?: number[];
|
|
88
|
+
defaultTimeout?: number;
|
|
89
|
+
timeoutFromId?: (id: z.output<TId>) => number | undefined;
|
|
90
|
+
}
|
|
91
|
+
export type AsyncOperationStartDefinition<TInput extends ZodObject, TId extends ZodObject> = RuntimeToolDefinitionWithOutput<TInput, TId>;
|
|
92
|
+
export type AsyncOperationFollowDefinition<TId extends ZodObject, TOutput extends ZodType> = RuntimeToolDefinitionWithOutput<TId, TOutput>;
|
|
93
|
+
export type RuntimeAsyncOperation<TStartInput extends ZodObject, TId extends ZodObject, TSnapshot extends ZodType, TCancel, TResult, TArtifacts> = {
|
|
94
|
+
start: AsyncOperationStartDefinition<TStartInput, TId>;
|
|
95
|
+
status: AsyncOperationFollowDefinition<TId, TSnapshot>;
|
|
96
|
+
wait: AsyncOperationFollowDefinition<TId, TSnapshot>;
|
|
97
|
+
runtimeTools: readonly RuntimeToolDefinition[];
|
|
98
|
+
schemas: {
|
|
99
|
+
id: TId;
|
|
100
|
+
snapshot: TSnapshot;
|
|
101
|
+
cancelResult: typeof AsyncOperationCancelResultSchema;
|
|
102
|
+
};
|
|
103
|
+
} & ([TCancel] extends [never] ? object : {
|
|
104
|
+
cancel: AsyncOperationFollowDefinition<TId, typeof AsyncOperationCancelResultSchema>;
|
|
105
|
+
}) & ([TResult] extends [never] ? object : TResult extends {
|
|
106
|
+
output: infer TOutput extends ZodType;
|
|
107
|
+
} ? {
|
|
108
|
+
result: AsyncOperationFollowDefinition<TId, TOutput>;
|
|
109
|
+
} : object) & ([TArtifacts] extends [never] ? object : TArtifacts extends {
|
|
110
|
+
output: infer TOutput extends ZodType;
|
|
111
|
+
} ? {
|
|
112
|
+
artifacts: AsyncOperationFollowDefinition<TId, TOutput>;
|
|
113
|
+
} : object);
|
|
114
|
+
/** Define a pathless async-operation surface. It never creates an HTTP route. */
|
|
115
|
+
export declare function defineAsyncOperation<TStartInput extends ZodObject, TId extends ZodObject, TState extends ZodType, TSnapshot extends ZodType, TCancel extends AsyncOperationCancelCapability<TId, TState> = never, TResult extends AsyncOperationOutputCapability<TId, TState, ZodType> = never, TArtifacts extends AsyncOperationOutputCapability<TId, TState, ZodType> = never>(config: RuntimeAsyncOperationConfig<TStartInput, TId, TState, TSnapshot, TCancel, TResult, TArtifacts>): RuntimeAsyncOperation<TStartInput, TId, TSnapshot, TCancel, TResult, TArtifacts>;
|
|
116
|
+
export type ContractAsyncOperationKeys<TEndpoints extends Record<string, EndpointDef>> = keyof TEndpoints & string;
|
|
117
|
+
type EndpointInputSchema<TEndpoint> = TEndpoint extends {
|
|
118
|
+
input: infer TSchema extends ZodType;
|
|
119
|
+
} ? TSchema : never;
|
|
120
|
+
type EndpointOutputSchema<TEndpoint> = TEndpoint extends {
|
|
121
|
+
output: infer TSchema extends ZodType;
|
|
122
|
+
} ? TSchema : never;
|
|
123
|
+
type TypesEqual<TLeft, TRight> = [TLeft] extends [TRight] ? [TRight] extends [TLeft] ? true : false : false;
|
|
124
|
+
type SchemasEquivalent<TLeft extends ZodType, TRight extends ZodType> = TypesEqual<z.input<TLeft>, z.input<TRight>> extends true ? TypesEqual<z.output<TLeft>, z.output<TRight>> : false;
|
|
125
|
+
export type ContractAsyncOperationStartKey<TEndpoints extends Record<string, EndpointDef>> = {
|
|
126
|
+
[TKey in keyof TEndpoints]: EndpointOutputSchema<TEndpoints[TKey]> extends never ? never : TKey;
|
|
127
|
+
}[keyof TEndpoints] & string;
|
|
128
|
+
export type ContractAsyncOperationFollowKey<TEndpoints extends Record<string, EndpointDef>, TStart extends ContractAsyncOperationStartKey<TEndpoints>> = {
|
|
129
|
+
[TKey in keyof TEndpoints]: EndpointInputSchema<TEndpoints[TKey]> extends infer TInput extends ZodType ? EndpointOutputSchema<TEndpoints[TStart]> extends infer TId extends ZodType ? SchemasEquivalent<TInput, TId> extends true ? TKey : never : never : never;
|
|
130
|
+
}[keyof TEndpoints] & string;
|
|
131
|
+
export type ContractAsyncOperationWaitKey<TEndpoints extends Record<string, EndpointDef>, TStart extends ContractAsyncOperationStartKey<TEndpoints>, TStatus extends ContractAsyncOperationFollowKey<TEndpoints, TStart>> = {
|
|
132
|
+
[TKey in keyof TEndpoints]: TKey extends ContractAsyncOperationFollowKey<TEndpoints, TStart> ? EndpointOutputSchema<TEndpoints[TKey]> extends infer TOutput extends ZodType ? EndpointOutputSchema<TEndpoints[TStatus]> extends infer TSnapshot extends ZodType ? SchemasEquivalent<TOutput, TSnapshot> extends true ? TKey : never : never : never : never;
|
|
133
|
+
}[keyof TEndpoints] & string;
|
|
134
|
+
export interface ContractAsyncOperationConfig<TEndpoints extends Record<string, EndpointDef>, TScope extends string, TStart extends ContractAsyncOperationStartKey<TEndpoints> = ContractAsyncOperationStartKey<TEndpoints>, TStatus extends ContractAsyncOperationFollowKey<TEndpoints, TStart> = ContractAsyncOperationFollowKey<TEndpoints, TStart>> {
|
|
135
|
+
mode: 'contract-backed';
|
|
136
|
+
contract: ContractDef<TEndpoints, TScope>;
|
|
137
|
+
capabilities: {
|
|
138
|
+
start: TStart;
|
|
139
|
+
status: TStatus;
|
|
140
|
+
wait: ContractAsyncOperationWaitKey<TEndpoints, TStart, TStatus>;
|
|
141
|
+
cancel?: ContractAsyncOperationFollowKey<TEndpoints, TStart>;
|
|
142
|
+
result?: ContractAsyncOperationFollowKey<TEndpoints, TStart>;
|
|
143
|
+
artifacts?: ContractAsyncOperationFollowKey<TEndpoints, TStart>;
|
|
144
|
+
};
|
|
145
|
+
handlers: Handlers<TEndpoints>;
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Bind a dedicated contract's already-declared methods as one async operation.
|
|
149
|
+
* The returned handlers go straight to `implement`; no schema or HTTP route is copied.
|
|
150
|
+
*/
|
|
151
|
+
export declare function bindContractAsyncOperation<TEndpoints extends Record<string, EndpointDef>, TScope extends string, const TStart extends ContractAsyncOperationStartKey<TEndpoints>, const TStatus extends ContractAsyncOperationFollowKey<TEndpoints, TStart>>(config: ContractAsyncOperationConfig<TEndpoints, TScope, TStart, TStatus>): {
|
|
152
|
+
contract: ContractDef<TEndpoints, TScope>;
|
|
153
|
+
handlers: Handlers<TEndpoints, import("..").HandlerContext<undefined, undefined>>;
|
|
154
|
+
capabilities: {
|
|
155
|
+
start: TStart;
|
|
156
|
+
status: TStatus;
|
|
157
|
+
wait: { [TKey in keyof TEndpoints]: TKey extends ContractAsyncOperationFollowKey<TEndpoints, TStart> ? EndpointOutputSchema<TEndpoints[TKey]> extends infer TOutput extends ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>> ? EndpointOutputSchema<TEndpoints[TStatus]> extends infer TSnapshot extends ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>> ? SchemasEquivalent<TOutput, TSnapshot> extends true ? TKey : never : never : never : never; }[keyof TEndpoints];
|
|
158
|
+
cancel?: ContractAsyncOperationFollowKey<TEndpoints, TStart> | undefined;
|
|
159
|
+
result?: ContractAsyncOperationFollowKey<TEndpoints, TStart> | undefined;
|
|
160
|
+
artifacts?: ContractAsyncOperationFollowKey<TEndpoints, TStart> | undefined;
|
|
161
|
+
};
|
|
162
|
+
schemas: {
|
|
163
|
+
id: ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>;
|
|
164
|
+
snapshot: ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>;
|
|
165
|
+
};
|
|
166
|
+
};
|
|
167
|
+
export {};
|
|
168
|
+
//# sourceMappingURL=async-operation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"async-operation.d.ts","sourceRoot":"","sources":["../../src/tools/async-operation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,SAAS,EAAE,KAAK,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACtD,OAAO,KAAK,EACV,WAAW,EACX,WAAW,EACX,uBAAuB,EAExB,MAAM,aAAa,CAAC;AAErB,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAGhD,OAAO,EAEL,KAAK,qBAAqB,EAC1B,KAAK,+BAA+B,EACpC,KAAK,yBAAyB,EAE9B,KAAK,oBAAoB,EAC1B,MAAM,gBAAgB,CAAC;AAExB,eAAO,MAAM,gCAAgC;;;;;;;8BAI3C,CAAC;AAEH,MAAM,MAAM,0BAA0B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gCAAgC,CAAC,CAAC;AAC1F,MAAM,MAAM,wBAAwB,GAChC,OAAO,GACP,QAAQ,GACR,MAAM,GACN,QAAQ,GACR,QAAQ,GACR,WAAW,CAAC;AAEhB,wBAAgB,kCAAkC,CAChD,SAAS,SAAS,OAAO,GAAG,SAAS,GAAG,SAAS,EACjD,QAAQ,SAAS,OAAO,GAAG,OAAO,EAClC,MAAM,EAAE;IAAE,QAAQ,CAAC,EAAE,SAAS,CAAC;IAAC,OAAO,EAAE,QAAQ,CAAA;CAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;6BASpD;AAED,MAAM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od';
|
|
21
21
|
/** CLI-behaviour flags, parsed out of argv before the tool arguments. */
|
|
22
22
|
export interface CliRunOptions {
|
|
23
|
-
/** `--json` — emit
|
|
23
|
+
/** `--json` — emit compact success/error JSON records for scripts. */
|
|
24
24
|
json: boolean;
|
|
25
25
|
/** `--wait` — block-poll an async result to a terminal state. */
|
|
26
26
|
wait: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli-args.d.ts","sourceRoot":"","sources":["../../src/tools/cli-args.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AACH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,yEAAyE;AACzE,MAAM,WAAW,aAAa;IAC5B,
|
|
1
|
+
{"version":3,"file":"cli-args.d.ts","sourceRoot":"","sources":["../../src/tools/cli-args.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AACH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,yEAAyE;AACzE,MAAM,WAAW,aAAa;IAC5B,sEAAsE;IACtE,IAAI,EAAE,OAAO,CAAC;IACd,iEAAiE;IACjE,IAAI,EAAE,OAAO,CAAC;IACd,8DAA8D;IAC9D,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,wEAAwE;IACxE,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,yDAAyD;IACzD,KAAK,EAAE,OAAO,CAAC;IACf,qEAAqE;IACrE,MAAM,EAAE,OAAO,CAAC;IAChB,qDAAqD;IACrD,IAAI,EAAE,OAAO,CAAC;CACf;AAED,MAAM,WAAW,aAAa;IAC5B,mEAAmE;IACnE,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAClC,+BAA+B;IAC/B,OAAO,EAAE,aAAa,CAAC;CACxB;AAED,KAAK,SAAS,GACV,SAAS,GACT,QAAQ,GACR,QAAQ,GACR,MAAM,GACN,QAAQ,GACR,MAAM,GACN,OAAO,GACP,QAAQ,GACR,OAAO,CAAC;AAEZ,UAAU,SAAS;IACjB,IAAI,EAAE,SAAS,CAAC;IAChB,uEAAuE;IACvE,WAAW,CAAC,EAAE,SAAS,CAAC;CACzB;AAOD,eAAO,MAAM,oBAAoB,aAA+C,CAAC;AAEjF,qBAAa,gBAAiB,SAAQ,KAAK;IAChC,IAAI,SAAsB;CACpC;AAuED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,CAAC,CAAC,OAAO,GAAG,SAAS,GAAG,GAAG,CAAC,MAAM,EAAE,SAAS,CAAC,CAI1F;AA8FD;;;;;;;;;GASG;AACH,wBAAgB,YAAY,CAC1B,IAAI,EAAE,MAAM,EAAE,EACd,MAAM,EAAE,CAAC,CAAC,OAAO,GAAG,SAAS,EAC7B,MAAM,GAAE;IAAE,YAAY,CAAC,EAAE,OAAO,CAAC;IAAC,WAAW,CAAC,EAAE,SAAS,MAAM,EAAE,CAAA;CAAO,GACvE,aAAa,CA+Kf"}
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Output is JSON — the CLI's audience is agents (Skills via Bash), scripts and
|
|
5
5
|
* `| jq`, for which structured JSON is the right shape, not a hand-formatted
|
|
6
6
|
* table. The default is pretty-printed (indented, the same shape an MCP tool
|
|
7
|
-
* returns); `--json` switches to
|
|
7
|
+
* returns); `--json` switches success and error records to one compact line.
|
|
8
8
|
*
|
|
9
9
|
* stdout is reserved for that result; an error goes to stderr as the same
|
|
10
10
|
* model-facing `{ error, details, _hint }` object the MCP / agent transports
|
|
@@ -24,7 +24,7 @@ export interface CliWriters {
|
|
|
24
24
|
stderr: (text: string) => void;
|
|
25
25
|
}
|
|
26
26
|
export interface EmitOptions {
|
|
27
|
-
/** Compact single-line
|
|
27
|
+
/** Compact single-line success/error JSON; otherwise pretty-printed. */
|
|
28
28
|
json: boolean;
|
|
29
29
|
toolName: string;
|
|
30
30
|
errorHint?: ErrorHintFn;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli-format.d.ts","sourceRoot":"","sources":["../../src/tools/cli-format.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,KAAK,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAGzD,sDAAsD;AACtD,MAAM,MAAM,WAAW,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAEjD;;;GAGG;AACH,eAAO,MAAM,kBAAkB,EAAE,
|
|
1
|
+
{"version":3,"file":"cli-format.d.ts","sourceRoot":"","sources":["../../src/tools/cli-format.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,KAAK,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAGzD,sDAAsD;AACtD,MAAM,MAAM,WAAW,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAEjD;;;GAGG;AACH,eAAO,MAAM,kBAAkB,EAAE,WAWhC,CAAC;AAEF,MAAM,WAAW,UAAU;IACzB,MAAM,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IAC/B,MAAM,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;CAChC;AAED,MAAM,WAAW,WAAW;IAC1B,wEAAwE;IACxE,IAAI,EAAE,OAAO,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,WAAW,CAAC;IACxB,SAAS,CAAC,EAAE,WAAW,CAAC;CACzB;AAED;;;;GAIG;AACH,wBAAgB,UAAU,CACxB,MAAM,EAAE,UAAU,EAClB,OAAO,EAAE,UAAU,EACnB,IAAI,EAAE,WAAW,GAChB,MAAM,CAgBR"}
|
package/dist/tools/cli-wait.d.ts
CHANGED
|
@@ -17,6 +17,13 @@ export interface CliWaitConfig {
|
|
|
17
17
|
tool: string;
|
|
18
18
|
/** Done when this returns `true` for a poll result. */
|
|
19
19
|
done: (result: unknown) => boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Terminal domain failure. A `true` result stops polling and turns the
|
|
22
|
+
* otherwise-successful tool payload into a `WAIT_FAILED` CLI failure. Checked
|
|
23
|
+
* before `done`, including for the initial result, so contradictory
|
|
24
|
+
* predicates fail closed.
|
|
25
|
+
*/
|
|
26
|
+
failed?: (result: unknown) => boolean;
|
|
20
27
|
/** Backoff schedule in seconds; the last entry repeats. Default `[2,3,5,5,8,10]`. */
|
|
21
28
|
backoff?: number[];
|
|
22
29
|
/** Max seconds before giving up. Default `600`. */
|
|
@@ -34,12 +41,14 @@ export interface PollParams {
|
|
|
34
41
|
onTick?: (attempt: number, elapsedSec: number) => void;
|
|
35
42
|
/** Injectable sleep for tests. */
|
|
36
43
|
sleepFn?: (ms: number) => Promise<void>;
|
|
44
|
+
/** Explicit caller cancellation. Process SIGINT wiring remains application-owned. */
|
|
45
|
+
signal?: AbortSignal;
|
|
37
46
|
}
|
|
38
47
|
/**
|
|
39
48
|
* Poll `wait.tool` until `wait.done` or the timeout. Returns the last poll
|
|
40
49
|
* result; returns the initial result untouched when the initial call failed,
|
|
41
|
-
* already satisfies `done`, or yields no poll target. A
|
|
42
|
-
* `
|
|
50
|
+
* already satisfies `done`, or yields no poll target. A terminal result matched
|
|
51
|
+
* by `failed` produces `WAIT_FAILED`; a timeout produces `TIMEOUT`.
|
|
43
52
|
*/
|
|
44
53
|
export declare function pollUntilDone(params: PollParams): Promise<ToolResult>;
|
|
45
54
|
//# sourceMappingURL=cli-wait.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli-wait.d.ts","sourceRoot":"","sources":["../../src/tools/cli-wait.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAG5C,MAAM,WAAW,aAAa;IAC5B;;;OAGG;IACH,IAAI,EAAE,CAAC,MAAM,EAAE,OAAO,KAAK,MAAM,CA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