stitchkit 0.67.0 → 0.68.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.
- package/dist/agent-runtime/admission-lanes.d.ts +1 -1
- package/dist/agent-runtime/compaction.d.ts +2 -2
- package/dist/agent-runtime/events.d.ts +1 -1
- package/dist/agent-runtime/history.d.ts +1 -1
- package/dist/agent-runtime/history.d.ts.map +1 -1
- package/dist/agent-runtime/injection.d.ts +1 -1
- package/dist/agent-runtime/managed-tools.d.ts +3 -3
- package/dist/agent-runtime/models.d.ts +1 -1
- package/dist/agent-runtime/observability.d.ts +1 -1
- package/dist/agent-runtime/prompt.d.ts +1 -1
- package/dist/agent-runtime/prompt.d.ts.map +1 -1
- package/dist/agent-runtime/protocol.d.ts +19 -1
- package/dist/agent-runtime/protocol.d.ts.map +1 -1
- package/dist/agent-runtime/run-execution.d.ts +5 -5
- package/dist/agent-runtime/run-execution.d.ts.map +1 -1
- package/dist/agent-runtime/runtime-internals.d.ts +1 -1
- package/dist/agent-runtime/runtime-result.d.ts +1 -1
- package/dist/agent-runtime/runtime.d.ts +14 -12
- package/dist/agent-runtime/runtime.d.ts.map +1 -1
- package/dist/agent-runtime/store-driver.d.ts +2 -2
- package/dist/agent-runtime/store.d.ts +2 -2
- package/dist/agent-runtime/terminal-commit.d.ts +2 -2
- package/dist/agent-runtime/terminal-status.d.ts +1 -1
- package/dist/agent-runtime-openrouter.d.ts +1 -1
- package/dist/agent-runtime.d.ts +15 -15
- package/dist/agent-runtime.d.ts.map +1 -1
- package/dist/agent-runtime.js +90 -30
- package/dist/application/admission.d.ts +131 -0
- package/dist/application/admission.d.ts.map +1 -0
- package/dist/application/channel.d.ts +106 -0
- package/dist/application/channel.d.ts.map +1 -0
- package/dist/application/events.d.ts +2 -2
- package/dist/application/grammy.d.ts +2 -2
- package/dist/application/graph.d.ts +1 -1
- package/dist/application/health.d.ts +1 -1
- package/dist/application/kernel.d.ts +3 -3
- package/dist/application/latest-sink.d.ts.map +1 -1
- package/dist/application/opentelemetry.d.ts +3 -3
- package/dist/application/resource.d.ts +1 -1
- package/dist/application/schedule.d.ts +1 -1
- package/dist/application/server-resource.d.ts +7 -9
- package/dist/application/server-resource.d.ts.map +1 -1
- package/dist/application-grammy.d.ts +1 -1
- package/dist/application-grammy.js +1 -1
- package/dist/application-opentelemetry.d.ts +1 -1
- package/dist/application-opentelemetry.js +1 -1
- package/dist/application.d.ts +11 -9
- package/dist/application.d.ts.map +1 -1
- package/dist/application.js +393 -24
- package/dist/browser/client-multipart.d.ts +1 -1
- package/dist/browser/client-url.d.ts +2 -2
- package/dist/browser/client.d.ts +4 -5
- package/dist/browser/client.d.ts.map +1 -1
- package/dist/browser/contract-stream.d.ts +5 -0
- package/dist/browser/contract-stream.d.ts.map +1 -0
- package/dist/browser/http.d.ts +9 -6
- package/dist/browser/http.d.ts.map +1 -1
- package/dist/browser/socket-io.d.ts +12 -31
- package/dist/browser/socket-io.d.ts.map +1 -1
- package/dist/browser/stream.d.ts +5 -2
- package/dist/browser/stream.d.ts.map +1 -1
- package/dist/browser/transport.d.ts +3 -0
- package/dist/browser/transport.d.ts.map +1 -0
- package/dist/cli.d.ts +6 -6
- package/dist/cli.js +7 -7
- package/dist/contract/define.d.ts +34 -2
- package/dist/contract/define.d.ts.map +1 -1
- package/dist/contract/errors-factory.d.ts +1 -1
- package/dist/contract/errors.d.ts +4 -0
- package/dist/contract/errors.d.ts.map +1 -1
- package/dist/contract/factory.d.ts +1 -1
- package/dist/contract/index.d.ts +7 -6
- package/dist/contract/index.d.ts.map +1 -1
- package/dist/contract/index.js +5 -1
- package/dist/contract/stream.d.ts +19 -0
- package/dist/contract/stream.d.ts.map +1 -0
- package/dist/files/boundary.d.ts +1 -1
- package/dist/files.d.ts +2 -2
- package/dist/{index-xxye8j3k.js → index-0w9abg87.js} +4 -0
- package/dist/{index-svqhcrrj.js → index-2ve29dzn.js} +159 -13
- package/dist/index-69m2278y.js +115 -0
- package/dist/{index-physbf4z.js → index-6wzr93cg.js} +1 -1
- package/dist/index-7etq650s.js +75 -0
- package/dist/index-9ky9hhg3.js +484 -0
- package/dist/{index-413xk7ga.js → index-cq9q73nf.js} +50 -1
- package/dist/{index-1pgeyyee.js → index-cszjsxy5.js} +25 -88
- package/dist/{index-wrhf06ak.js → index-cz32amcb.js} +8 -8
- package/dist/{index-6taryy00.js → index-dafax5md.js} +1 -1
- package/dist/index-g2j2m6vv.js +63 -0
- package/dist/{index-8mxadm34.js → index-nck3yx3y.js} +1102 -22
- package/dist/{index-y91zd0ch.js → index-pr0qsmjy.js} +3 -2
- package/dist/index-v5bayx1z.js +138 -0
- package/dist/{index-mfw1pec7.js → index-wqyrvhzz.js} +3 -3
- package/dist/{index-x8v8b7rc.js → index-zpyj7hsv.js} +330 -58
- package/dist/index.d.ts +10 -10
- package/dist/index.js +274 -109
- package/dist/internal/bounded-lines.d.ts +4 -0
- package/dist/internal/bounded-lines.d.ts.map +1 -0
- package/dist/internal/errors.d.ts +1 -1
- package/dist/internal/observability-sink.d.ts +1 -1
- package/dist/node.d.ts +11 -10
- package/dist/node.d.ts.map +1 -1
- package/dist/node.js +11 -8
- package/dist/observability/audit.d.ts +5 -5
- package/dist/observability/context.d.ts +2 -2
- package/dist/observability/event.d.ts +2 -2
- package/dist/observability/index.d.ts +6 -6
- package/dist/observability/index.js +6 -7
- package/dist/react/entity-cache.d.ts +26 -1
- package/dist/react/entity-cache.d.ts.map +1 -1
- package/dist/react.d.ts +3 -3
- package/dist/react.d.ts.map +1 -1
- package/dist/react.js +136 -38
- package/dist/realtime/contract.d.ts +1 -1
- package/dist/realtime/index.d.ts +4 -4
- package/dist/realtime/rejection.d.ts +1 -1
- package/dist/realtime/request.d.ts +1 -1
- package/dist/realtime/socket.d.ts +2 -2
- package/dist/remote.d.ts +1 -1
- package/dist/remote.js +5 -6
- package/dist/server/bun.d.ts +3 -3
- package/dist/server/context-contribution.d.ts +1 -1
- package/dist/server/context.d.ts +4 -4
- package/dist/server/contract-stream.d.ts +5 -0
- package/dist/server/contract-stream.d.ts.map +1 -0
- package/dist/server/create.d.ts +1 -1
- package/dist/server/create.d.ts.map +1 -1
- package/dist/server/error-hook.d.ts +3 -3
- package/dist/server/file.d.ts +1 -1
- package/dist/server/implement.d.ts +2 -2
- package/dist/server/implement.d.ts.map +1 -1
- package/dist/server/index.d.ts +31 -30
- package/dist/server/index.d.ts.map +1 -1
- package/dist/server/index.js +44 -286
- package/dist/server/lifecycle.d.ts +1 -1
- package/dist/server/logging.d.ts +1 -1
- package/dist/server/middleware/auth.d.ts +2 -2
- package/dist/server/multipart.d.ts +2 -2
- package/dist/server/node.d.ts +2 -2
- package/dist/server/openapi.d.ts +1 -1
- package/dist/server/openapi.d.ts.map +1 -1
- package/dist/server/process-signal-common.d.ts +1 -1
- package/dist/server/process-signals.d.ts +1 -1
- package/dist/server/realtime.d.ts +4 -4
- package/dist/server/response-metadata.d.ts +1 -1
- package/dist/server/router.d.ts +1 -1
- package/dist/server/shutdown.d.ts +1 -1
- package/dist/server/socket-io-node.d.ts +3 -3
- package/dist/server/socket-io.d.ts +6 -6
- package/dist/server/stream.d.ts +3 -1
- package/dist/server/stream.d.ts.map +1 -1
- package/dist/server/streaming-route.d.ts +4 -2
- package/dist/server/streaming-route.d.ts.map +1 -1
- package/dist/server/types.d.ts +18 -8
- package/dist/server/types.d.ts.map +1 -1
- package/dist/server/unix-client-body.d.ts +4 -0
- package/dist/server/unix-client-body.d.ts.map +1 -0
- package/dist/server/unix-client-bun.d.ts +13 -0
- package/dist/server/unix-client-bun.d.ts.map +1 -0
- package/dist/server/unix-client-error.d.ts +9 -0
- package/dist/server/unix-client-error.d.ts.map +1 -0
- package/dist/server/unix-client.d.ts +25 -0
- package/dist/server/unix-client.d.ts.map +1 -0
- package/dist/testing/agent-store-conformance.d.ts +1 -1
- package/dist/testing/managed-resource-conformance-contract.d.ts +1 -1
- package/dist/testing/managed-resource-conformance-driver.d.ts +2 -2
- package/dist/testing/managed-resource-conformance-scenarios.d.ts +2 -2
- package/dist/testing/managed-resource-conformance.d.ts +2 -2
- package/dist/testing/surface-conformance.d.ts +3 -3
- package/dist/testing/surface-manifest.d.ts +5 -5
- package/dist/testing.d.ts +8 -8
- package/dist/testing.js +6 -5
- package/dist/tool-invoker.d.ts +9 -0
- package/dist/tool-invoker.d.ts.map +1 -0
- package/dist/tool-invoker.js +16 -0
- package/dist/tools/agent.d.ts +4 -4
- package/dist/tools/async-operation.d.ts +3 -3
- package/dist/tools/cli-command.d.ts +3 -3
- package/dist/tools/cli-format.d.ts +1 -1
- package/dist/tools/cli-policy.d.ts +1 -1
- package/dist/tools/cli-wait.d.ts +1 -1
- package/dist/tools/cli.d.ts +7 -7
- package/dist/tools/define-download-tool.d.ts +4 -4
- package/dist/tools/define-upload-tool.d.ts +3 -3
- package/dist/tools/define-view-file-tool.d.ts +3 -3
- package/dist/tools/define-wait-tool.d.ts +2 -2
- package/dist/tools/download-core.d.ts +2 -2
- package/dist/tools/execute.d.ts +2 -2
- package/dist/tools/flatten-join.d.ts +1 -1
- package/dist/tools/internal/surface-projector.d.ts +3 -3
- package/dist/tools/invoker.d.ts +4 -4
- package/dist/tools/lifecycle.d.ts +1 -1
- package/dist/tools/list-names.d.ts +2 -2
- package/dist/tools/managed-file-error.d.ts +1 -1
- package/dist/tools/manifest.d.ts +3 -3
- package/dist/tools/mcp-handler.d.ts +4 -4
- package/dist/tools/mcp-prepare.d.ts +8 -8
- package/dist/tools/mcp-round-policy.d.ts +1 -1
- package/dist/tools/mcp-round.d.ts +3 -3
- package/dist/tools/mcp-stdio-signals.d.ts +2 -2
- package/dist/tools/mcp-stdio.d.ts +3 -3
- package/dist/tools/mcp.d.ts +7 -7
- package/dist/tools/mount-download.d.ts +1 -1
- package/dist/tools/mount-upload.d.ts +1 -1
- package/dist/tools/mount.d.ts +5 -5
- package/dist/tools/native-definition.d.ts +2 -2
- package/dist/tools/native-mcp.d.ts +3 -3
- package/dist/tools/oauth-metadata.d.ts +1 -1
- package/dist/tools/oauth-provider.d.ts +1 -1
- package/dist/tools/presentation.d.ts +1 -1
- package/dist/tools/remote.d.ts +3 -3
- package/dist/tools/runtime-tool.d.ts +2 -2
- package/dist/tools/surface.d.ts +5 -5
- package/dist/tools/tool-logger.d.ts +1 -1
- package/dist/tools/toolkit.d.ts +7 -7
- package/dist/tools/transports.d.ts +2 -2
- package/dist/tools/upload-core.d.ts +1 -1
- package/dist/tools/view-file.d.ts +1 -1
- package/dist/tools.d.ts +42 -42
- package/dist/tools.js +27 -72
- package/llms-full.txt +506 -35
- package/package.json +8 -4
- package/dist/index-48ffdxgk.js +0 -6
- package/dist/index-pzyt11ch.js +0 -127
- package/dist/index-tvwcrx2d.js +0 -224
- package/dist/index-wd8g8z6e.js +0 -206
|
@@ -1,100 +1,37 @@
|
|
|
1
|
+
import {
|
|
2
|
+
contractToolMountable,
|
|
3
|
+
createToolRunner,
|
|
4
|
+
formatToolError
|
|
5
|
+
} from "./index-7etq650s.js";
|
|
1
6
|
import {
|
|
2
7
|
coerceJsonArgs,
|
|
3
|
-
executeToolMethod,
|
|
4
8
|
toolResultFromError
|
|
5
|
-
} from "./index-
|
|
9
|
+
} from "./index-cz32amcb.js";
|
|
6
10
|
import {
|
|
7
11
|
isWithinDir
|
|
8
12
|
} from "./index-sbdmyz75.js";
|
|
9
13
|
import {
|
|
10
|
-
assertToolExtensionCompatible,
|
|
11
14
|
assertUniqueToolName,
|
|
12
15
|
buildToolPresentationSchema,
|
|
13
16
|
projectRuntimeTool,
|
|
14
17
|
projectToolSurface
|
|
15
18
|
} from "./index-vkk06pv1.js";
|
|
16
19
|
import {
|
|
17
|
-
|
|
18
|
-
objectShapeKeys,
|
|
19
|
-
rebuildObject
|
|
20
|
+
objectShapeKeys
|
|
20
21
|
} from "./index-6djpbnda.js";
|
|
21
22
|
import {
|
|
22
23
|
jsonSchemaFields
|
|
23
24
|
} from "./index-cby4ar3v.js";
|
|
24
25
|
import {
|
|
25
26
|
formatZodError,
|
|
26
|
-
validateDeclaredOutput
|
|
27
|
-
} from "./index-tvwcrx2d.js";
|
|
28
|
-
import {
|
|
29
27
|
isUnsafeKey,
|
|
30
|
-
safeJsonParse
|
|
31
|
-
|
|
28
|
+
safeJsonParse,
|
|
29
|
+
validateDeclaredOutput
|
|
30
|
+
} from "./index-9ky9hhg3.js";
|
|
32
31
|
import {
|
|
33
32
|
isRecord
|
|
34
33
|
} from "./index-smpbdg6k.js";
|
|
35
34
|
|
|
36
|
-
// src/tools/mount.ts
|
|
37
|
-
import { z } from "zod";
|
|
38
|
-
function applyExtend(base, extra) {
|
|
39
|
-
if (base instanceof z.ZodObject) {
|
|
40
|
-
assertToolExtensionCompatible(base, extra);
|
|
41
|
-
return rebuildObject(base, { ...extra, ...base.shape });
|
|
42
|
-
}
|
|
43
|
-
return z.intersection(z.object(extra), base);
|
|
44
|
-
}
|
|
45
|
-
function contractToolMountable(projected, extend) {
|
|
46
|
-
const method = projected.source;
|
|
47
|
-
const baseArgumentSchema = mergeSchemas(method.paramsSchema, method.inputSchema);
|
|
48
|
-
const argumentSchema = projected.shouldExtend && extend ? applyExtend(baseArgumentSchema, extend.schema) : baseArgumentSchema;
|
|
49
|
-
return {
|
|
50
|
-
method,
|
|
51
|
-
name: projected.name,
|
|
52
|
-
argumentSchema,
|
|
53
|
-
presentationSchema: projected.presentationSchema,
|
|
54
|
-
shouldExtend: projected.shouldExtend
|
|
55
|
-
};
|
|
56
|
-
}
|
|
57
|
-
function collectTools(service, transport, config = {}) {
|
|
58
|
-
const { extend, flattenUnionInput = false, assertNames = true } = config;
|
|
59
|
-
const tools = [];
|
|
60
|
-
for (const projected of projectToolSurface({ services: [service] }, transport === "HTTP" ? "AGENT" : transport, {
|
|
61
|
-
extend,
|
|
62
|
-
flattenUnionInput,
|
|
63
|
-
assertNames,
|
|
64
|
-
assertUniqueNames: false
|
|
65
|
-
})) {
|
|
66
|
-
if (projected.kind !== "contract")
|
|
67
|
-
continue;
|
|
68
|
-
tools.push(contractToolMountable(projected, extend));
|
|
69
|
-
}
|
|
70
|
-
return tools;
|
|
71
|
-
}
|
|
72
|
-
function createToolRunner(config) {
|
|
73
|
-
const extension = config.extend ? {
|
|
74
|
-
schema: z.object(config.extend.schema),
|
|
75
|
-
resolve: config.extend.resolve
|
|
76
|
-
} : undefined;
|
|
77
|
-
return async function runOneToolCall(tool, rawArgs, context) {
|
|
78
|
-
return executeToolMethod(tool.method, tool.name, rawArgs, { ...config.context, ...context, source: config.source }, config.hooks, config.lifecycle, config.coerceJsonArgs ?? true, config.onOutputStrip ? (paths) => config.onOutputStrip?.(tool.name, paths) : undefined, tool.shouldExtend ? extension : undefined);
|
|
79
|
-
};
|
|
80
|
-
}
|
|
81
|
-
function formatToolError(result, toolName, errorHint) {
|
|
82
|
-
const err = { error: result.code };
|
|
83
|
-
if (result.details)
|
|
84
|
-
err.details = result.details;
|
|
85
|
-
const hints = [];
|
|
86
|
-
if (result.hint)
|
|
87
|
-
hints.push(result.hint);
|
|
88
|
-
if (errorHint && toolName) {
|
|
89
|
-
const global = errorHint(toolName, result.code);
|
|
90
|
-
if (global)
|
|
91
|
-
hints.push(global);
|
|
92
|
-
}
|
|
93
|
-
if (hints.length > 0)
|
|
94
|
-
err._hint = hints.join(" ");
|
|
95
|
-
return err;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
35
|
// src/tools/runtime-tool.ts
|
|
99
36
|
function defineRuntimeTool(definition) {
|
|
100
37
|
if (definition.transports?.length === 0) {
|
|
@@ -177,7 +114,7 @@ function runtimeToolMountable(definition, assertName = true) {
|
|
|
177
114
|
}
|
|
178
115
|
|
|
179
116
|
// src/tools/cli-args.ts
|
|
180
|
-
import { z
|
|
117
|
+
import { z } from "zod";
|
|
181
118
|
var NUMERIC_VALUE = /^-(\d+\.?\d*|\.\d+)$/;
|
|
182
119
|
var BOOL_OPTIONS = new Set(["json", "wait", "quiet", "dry-run", "help"]);
|
|
183
120
|
var VALUE_OPTIONS = new Set(["wait-timeout", "output-dir"]);
|
|
@@ -286,27 +223,27 @@ class CliArgumentError extends Error {
|
|
|
286
223
|
name = "CliArgumentError";
|
|
287
224
|
}
|
|
288
225
|
function unwrap(field) {
|
|
289
|
-
if (field instanceof
|
|
226
|
+
if (field instanceof z.ZodOptional || field instanceof z.ZodNullable || field instanceof z.ZodDefault) {
|
|
290
227
|
return unwrap(field.unwrap());
|
|
291
228
|
}
|
|
292
229
|
return field;
|
|
293
230
|
}
|
|
294
231
|
function classify(field) {
|
|
295
|
-
if (field instanceof
|
|
232
|
+
if (field instanceof z.ZodBoolean)
|
|
296
233
|
return "boolean";
|
|
297
|
-
if (field instanceof
|
|
234
|
+
if (field instanceof z.ZodNumber)
|
|
298
235
|
return "number";
|
|
299
|
-
if (field instanceof
|
|
236
|
+
if (field instanceof z.ZodBigInt)
|
|
300
237
|
return "bigint";
|
|
301
|
-
if (field instanceof
|
|
238
|
+
if (field instanceof z.ZodDate)
|
|
302
239
|
return "date";
|
|
303
|
-
if (field instanceof
|
|
240
|
+
if (field instanceof z.ZodEnum)
|
|
304
241
|
return "enum";
|
|
305
|
-
if (field instanceof
|
|
242
|
+
if (field instanceof z.ZodArray)
|
|
306
243
|
return "array";
|
|
307
|
-
if (field instanceof
|
|
244
|
+
if (field instanceof z.ZodObject)
|
|
308
245
|
return "object";
|
|
309
|
-
if (field instanceof
|
|
246
|
+
if (field instanceof z.ZodString || field instanceof z.ZodLiteral)
|
|
310
247
|
return "string";
|
|
311
248
|
return "other";
|
|
312
249
|
}
|
|
@@ -326,11 +263,11 @@ function mergeField(fields, name, info) {
|
|
|
326
263
|
}
|
|
327
264
|
function collectSchemaFields(schema, fields) {
|
|
328
265
|
const base = unwrap(schema);
|
|
329
|
-
if (base instanceof
|
|
266
|
+
if (base instanceof z.ZodObject) {
|
|
330
267
|
for (const [name, raw] of Object.entries(base.shape)) {
|
|
331
268
|
const fieldBase = unwrap(raw);
|
|
332
269
|
const kind = classify(fieldBase);
|
|
333
|
-
if (kind === "array" && fieldBase instanceof
|
|
270
|
+
if (kind === "array" && fieldBase instanceof z.ZodArray) {
|
|
334
271
|
mergeField(fields, name, { kind, elementKind: classify(unwrap(fieldBase.element)) });
|
|
335
272
|
} else {
|
|
336
273
|
mergeField(fields, name, { kind });
|
|
@@ -338,12 +275,12 @@ function collectSchemaFields(schema, fields) {
|
|
|
338
275
|
}
|
|
339
276
|
return;
|
|
340
277
|
}
|
|
341
|
-
if (base instanceof
|
|
278
|
+
if (base instanceof z.ZodUnion) {
|
|
342
279
|
for (const option of base.def.options)
|
|
343
280
|
collectSchemaFields(option, fields);
|
|
344
281
|
return;
|
|
345
282
|
}
|
|
346
|
-
if (base instanceof
|
|
283
|
+
if (base instanceof z.ZodIntersection) {
|
|
347
284
|
collectSchemaFields(base.def.left, fields);
|
|
348
285
|
collectSchemaFields(base.def.right, fields);
|
|
349
286
|
return;
|
|
@@ -1737,4 +1674,4 @@ async function createCli(config) {
|
|
|
1737
1674
|
return exit(downloadsOk ? exitCode : 1);
|
|
1738
1675
|
}
|
|
1739
1676
|
|
|
1740
|
-
export {
|
|
1677
|
+
export { defineRuntimeTool, createRuntimeToolFactory, collectToolSurface, WaitTimeoutError, runWaitOperation, fetchGuarded, fetchPinnedDocument, readCapped, parseCliArgs, defineCliCommand, DEFAULT_EXIT_CODES, emitResult, pollUntilDone, createCli };
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
+
import {
|
|
2
|
+
getRequestContext,
|
|
3
|
+
runWithRequestContext
|
|
4
|
+
} from "./index-69m2278y.js";
|
|
1
5
|
import {
|
|
2
6
|
objectShapeKeys
|
|
3
7
|
} from "./index-6djpbnda.js";
|
|
4
8
|
import {
|
|
5
9
|
formatZodError,
|
|
6
|
-
|
|
10
|
+
isUnsafeKey,
|
|
7
11
|
normalizeError,
|
|
8
|
-
|
|
12
|
+
safeJsonParse,
|
|
9
13
|
validateDeclaredOutput
|
|
10
|
-
} from "./index-
|
|
11
|
-
import {
|
|
12
|
-
isUnsafeKey,
|
|
13
|
-
safeJsonParse
|
|
14
|
-
} from "./index-wd8g8z6e.js";
|
|
14
|
+
} from "./index-9ky9hhg3.js";
|
|
15
15
|
import {
|
|
16
16
|
isRecord
|
|
17
17
|
} from "./index-smpbdg6k.js";
|
|
@@ -19,7 +19,7 @@ import {
|
|
|
19
19
|
AppError,
|
|
20
20
|
STITCH_ERROR_STATUS,
|
|
21
21
|
isStitchErrorCode
|
|
22
|
-
} from "./index-
|
|
22
|
+
} from "./index-0w9abg87.js";
|
|
23
23
|
|
|
24
24
|
// src/tools/coerce.ts
|
|
25
25
|
import { z } from "zod";
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import {
|
|
2
|
+
collectTools,
|
|
3
|
+
createToolRunner
|
|
4
|
+
} from "./index-7etq650s.js";
|
|
5
|
+
import {
|
|
6
|
+
toolErrorFromResult
|
|
7
|
+
} from "./index-cz32amcb.js";
|
|
8
|
+
import {
|
|
9
|
+
assertUniqueToolName
|
|
10
|
+
} from "./index-vkk06pv1.js";
|
|
11
|
+
import {
|
|
12
|
+
AppError
|
|
13
|
+
} from "./index-0w9abg87.js";
|
|
14
|
+
|
|
15
|
+
// src/tools/invoker.ts
|
|
16
|
+
function createToolInvoker(services, config) {
|
|
17
|
+
const serviceList = Array.isArray(services) ? services : [services];
|
|
18
|
+
const tools = new Map;
|
|
19
|
+
for (const service of serviceList) {
|
|
20
|
+
for (const tool of collectTools(service, config.transport, {
|
|
21
|
+
extend: config.extend,
|
|
22
|
+
flattenUnionInput: config.flattenUnionInput
|
|
23
|
+
})) {
|
|
24
|
+
assertUniqueToolName(tool.name, tools.has(tool.name), "in-process tool name");
|
|
25
|
+
tools.set(tool.name, tool);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
const names = Object.freeze([...tools.keys()].sort());
|
|
29
|
+
const operation = (name) => {
|
|
30
|
+
const tool = tools.get(name);
|
|
31
|
+
if (tool)
|
|
32
|
+
return tool;
|
|
33
|
+
throw new AppError("NOT_FOUND", `Unknown tool: ${name}`, 404, {
|
|
34
|
+
available: names
|
|
35
|
+
});
|
|
36
|
+
};
|
|
37
|
+
const run = (name, args, options = {}) => {
|
|
38
|
+
const runTool = createToolRunner({
|
|
39
|
+
source: options.source ?? "internal",
|
|
40
|
+
context: options.context,
|
|
41
|
+
hooks: options.hooks,
|
|
42
|
+
lifecycle: options.lifecycle,
|
|
43
|
+
extend: config.extend,
|
|
44
|
+
coerceJsonArgs: config.coerceJsonArgs,
|
|
45
|
+
onOutputStrip: options.onOutputStrip
|
|
46
|
+
});
|
|
47
|
+
return runTool(operation(name), args);
|
|
48
|
+
};
|
|
49
|
+
return Object.freeze({
|
|
50
|
+
names,
|
|
51
|
+
invoke(name, args, options) {
|
|
52
|
+
return run(name, args, options);
|
|
53
|
+
},
|
|
54
|
+
async invokeOrThrow(name, args, options) {
|
|
55
|
+
const result = await run(name, args, options);
|
|
56
|
+
if (!result.ok)
|
|
57
|
+
throw toolErrorFromResult(result);
|
|
58
|
+
return result.data;
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export { createToolInvoker };
|