stitchkit 0.56.1 → 0.56.3
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 +12 -3
- package/dist/agent-runtime/compaction.d.ts +33 -0
- package/dist/agent-runtime/compaction.d.ts.map +1 -0
- package/dist/agent-runtime/coordinator.d.ts +24 -0
- package/dist/agent-runtime/coordinator.d.ts.map +1 -0
- package/dist/agent-runtime/events.d.ts +454 -0
- package/dist/agent-runtime/events.d.ts.map +1 -0
- package/dist/agent-runtime/history.d.ts +11 -0
- package/dist/agent-runtime/history.d.ts.map +1 -0
- package/dist/agent-runtime/managed-tools.d.ts +18 -0
- package/dist/agent-runtime/managed-tools.d.ts.map +1 -0
- package/dist/agent-runtime/models.d.ts +51 -0
- package/dist/agent-runtime/models.d.ts.map +1 -0
- package/dist/agent-runtime/observability.d.ts +134 -0
- package/dist/agent-runtime/observability.d.ts.map +1 -0
- package/dist/agent-runtime/prompt.d.ts +50 -0
- package/dist/agent-runtime/prompt.d.ts.map +1 -0
- package/dist/agent-runtime/protocol.d.ts +16 -0
- package/dist/agent-runtime/protocol.d.ts.map +1 -0
- package/dist/agent-runtime/runtime.d.ts +132 -0
- package/dist/agent-runtime/runtime.d.ts.map +1 -0
- package/dist/agent-runtime/schemas.d.ts +470 -0
- package/dist/agent-runtime/schemas.d.ts.map +1 -0
- package/dist/agent-runtime/store.d.ts +905 -0
- package/dist/agent-runtime/store.d.ts.map +1 -0
- package/dist/agent-runtime/testing.d.ts +17 -0
- package/dist/agent-runtime/testing.d.ts.map +1 -0
- package/dist/agent-runtime-openrouter.d.ts +6 -0
- package/dist/agent-runtime-openrouter.d.ts.map +1 -0
- package/dist/agent-runtime-openrouter.js +46 -0
- package/dist/agent-runtime.d.ts +13 -0
- package/dist/agent-runtime.d.ts.map +1 -0
- package/dist/agent-runtime.js +1955 -0
- package/dist/cli.js +8 -5
- package/dist/index-0nc0cddp.js +178 -0
- package/dist/{index-6y759j86.js → index-1tkyng3g.js} +9 -57
- package/dist/{index-sm2tjx06.js → index-41wm56v0.js} +2 -2
- package/dist/index-6djpbnda.js +56 -0
- package/dist/{index-j3dem06f.js → index-7c0gkyvj.js} +5 -3
- package/dist/{index-75njxz7p.js → index-9zn9fb4e.js} +8 -6
- package/dist/{index-xy8fmh6w.js → index-f6pymtqe.js} +3 -3
- package/dist/{index-jcc611vh.js → index-gnvzyw0k.js} +2 -2
- package/dist/{index-qh4xevf5.js → index-mr617n62.js} +4 -2
- package/dist/{index-5r13htq1.js → index-ps5pxp3h.js} +1 -1
- package/dist/index-sa2mbwa7.js +336 -0
- package/dist/index-smpbdg6k.js +27 -0
- package/dist/{index-7eq9va6e.js → index-y2rb7dwx.js} +1 -27
- package/dist/{index-escqg10p.js → index-zk5zn2nh.js} +32 -334
- package/dist/internal/observability-sink.d.ts +26 -0
- package/dist/internal/observability-sink.d.ts.map +1 -0
- package/dist/node.js +6 -5
- package/dist/observability/audit.d.ts.map +1 -1
- package/dist/observability/index.js +15 -178
- package/dist/remote.js +4 -3
- package/dist/server/error-hook.d.ts +9 -7
- package/dist/server/error-hook.d.ts.map +1 -1
- package/dist/server/index.js +9 -7
- package/dist/testing.js +5 -3
- package/dist/tools/agent.d.ts.map +1 -1
- package/dist/tools/execute.d.ts +7 -0
- package/dist/tools/execute.d.ts.map +1 -1
- package/dist/tools.d.ts +2 -1
- package/dist/tools.d.ts.map +1 -1
- package/dist/tools.js +23 -12
- package/llms-full.txt +382 -10
- package/llms.txt +1 -0
- package/package.json +16 -3
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
import {
|
|
2
|
+
coerceJsonArgs,
|
|
3
|
+
executeToolMethod,
|
|
4
|
+
toolResultFromError
|
|
5
|
+
} from "./index-sa2mbwa7.js";
|
|
1
6
|
import {
|
|
2
7
|
isWithinDir
|
|
3
8
|
} from "./index-sbdmyz75.js";
|
|
@@ -5,344 +10,37 @@ import {
|
|
|
5
10
|
assertToolExtensionCompatible,
|
|
6
11
|
assertUniqueToolName,
|
|
7
12
|
buildToolPresentationSchema,
|
|
13
|
+
projectRuntimeTool,
|
|
14
|
+
projectToolSurface
|
|
15
|
+
} from "./index-1tkyng3g.js";
|
|
16
|
+
import {
|
|
8
17
|
mergeSchemas,
|
|
9
18
|
objectShapeKeys,
|
|
10
|
-
projectRuntimeTool,
|
|
11
|
-
projectToolSurface,
|
|
12
19
|
rebuildObject
|
|
13
|
-
} from "./index-
|
|
20
|
+
} from "./index-6djpbnda.js";
|
|
14
21
|
import {
|
|
15
22
|
jsonSchemaFields
|
|
16
23
|
} from "./index-cby4ar3v.js";
|
|
17
24
|
import {
|
|
18
25
|
formatZodError,
|
|
19
|
-
getRequestContext,
|
|
20
|
-
normalizeError,
|
|
21
|
-
runWithRequestContext,
|
|
22
26
|
validateDeclaredOutput
|
|
23
|
-
} from "./index-
|
|
27
|
+
} from "./index-7c0gkyvj.js";
|
|
24
28
|
import {
|
|
25
|
-
AppError,
|
|
26
|
-
STITCH_ERROR_STATUS,
|
|
27
|
-
isStitchErrorCode,
|
|
28
29
|
isUnsafeKey,
|
|
29
30
|
safeJsonParse
|
|
30
|
-
} from "./index-
|
|
31
|
+
} from "./index-ps5pxp3h.js";
|
|
31
32
|
import {
|
|
32
33
|
isRecord
|
|
33
|
-
} from "./index-
|
|
34
|
-
|
|
35
|
-
// src/tools/coerce.ts
|
|
36
|
-
import { z } from "zod";
|
|
37
|
-
function needsJsonCoercion(schema) {
|
|
38
|
-
if (schema instanceof z.ZodArray || schema instanceof z.ZodObject || schema instanceof z.ZodRecord || schema instanceof z.ZodTuple || schema instanceof z.ZodUnion) {
|
|
39
|
-
return true;
|
|
40
|
-
}
|
|
41
|
-
if (schema instanceof z.ZodOptional || schema instanceof z.ZodNullable || schema instanceof z.ZodDefault) {
|
|
42
|
-
return needsJsonCoercion(schema.unwrap());
|
|
43
|
-
}
|
|
44
|
-
return false;
|
|
45
|
-
}
|
|
46
|
-
function acceptsRawString(schema) {
|
|
47
|
-
const type = schema._zod.def.type;
|
|
48
|
-
if (type === "string" || type === "template_literal")
|
|
49
|
-
return true;
|
|
50
|
-
if (schema instanceof z.ZodLiteral) {
|
|
51
|
-
return schema.def.values.some((value) => typeof value === "string");
|
|
52
|
-
}
|
|
53
|
-
if (schema instanceof z.ZodEnum) {
|
|
54
|
-
return schema.options.some((value) => typeof value === "string");
|
|
55
|
-
}
|
|
56
|
-
if (schema instanceof z.ZodOptional || schema instanceof z.ZodNullable || schema instanceof z.ZodDefault) {
|
|
57
|
-
return acceptsRawString(schema.unwrap());
|
|
58
|
-
}
|
|
59
|
-
if (schema instanceof z.ZodUnion) {
|
|
60
|
-
return schema.def.options.some((option) => acceptsRawString(option));
|
|
61
|
-
}
|
|
62
|
-
return false;
|
|
63
|
-
}
|
|
64
|
-
function matchingVariant(union, value) {
|
|
65
|
-
const disc = union.def.discriminator;
|
|
66
|
-
const tag = value[disc];
|
|
67
|
-
for (const option of union.def.options) {
|
|
68
|
-
if (!(option instanceof z.ZodObject))
|
|
69
|
-
continue;
|
|
70
|
-
const field = option.shape[disc];
|
|
71
|
-
if (field instanceof z.ZodLiteral && field.def.values.some((v) => v === tag))
|
|
72
|
-
return option;
|
|
73
|
-
if (field instanceof z.ZodEnum && field.options.some((v) => v === tag))
|
|
74
|
-
return option;
|
|
75
|
-
}
|
|
76
|
-
return;
|
|
77
|
-
}
|
|
78
|
-
function coerceValue(value, schema) {
|
|
79
|
-
if (!schema)
|
|
80
|
-
return value;
|
|
81
|
-
if (schema instanceof z.ZodOptional || schema instanceof z.ZodNullable || schema instanceof z.ZodDefault) {
|
|
82
|
-
return coerceValue(value, schema.unwrap());
|
|
83
|
-
}
|
|
84
|
-
let current = value;
|
|
85
|
-
if (typeof current === "string" && needsJsonCoercion(schema)) {
|
|
86
|
-
if (acceptsRawString(schema))
|
|
87
|
-
return current;
|
|
88
|
-
try {
|
|
89
|
-
current = safeJsonParse(current);
|
|
90
|
-
} catch {
|
|
91
|
-
return value;
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
if (schema instanceof z.ZodObject && isRecord(current)) {
|
|
95
|
-
const shape = schema.shape;
|
|
96
|
-
const out = {};
|
|
97
|
-
for (const [key, item] of Object.entries(current)) {
|
|
98
|
-
out[key] = coerceValue(item, shape[key]);
|
|
99
|
-
}
|
|
100
|
-
return out;
|
|
101
|
-
}
|
|
102
|
-
if (schema instanceof z.ZodArray && Array.isArray(current)) {
|
|
103
|
-
return current.map((item) => coerceValue(item, schema.element));
|
|
104
|
-
}
|
|
105
|
-
if (schema instanceof z.ZodDiscriminatedUnion && isRecord(current)) {
|
|
106
|
-
const variant = matchingVariant(schema, current);
|
|
107
|
-
return variant ? coerceValue(current, variant) : current;
|
|
108
|
-
}
|
|
109
|
-
return current;
|
|
110
|
-
}
|
|
111
|
-
function coerceJsonArgs(args, schema) {
|
|
112
|
-
const coerced = coerceValue(args, schema);
|
|
113
|
-
return isRecord(coerced) ? coerced : args;
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
// src/tools/mount.ts
|
|
117
|
-
import { z as z2 } from "zod";
|
|
118
|
-
|
|
119
|
-
// src/tools/execute.ts
|
|
120
|
-
var normalizedToolErrors = new WeakMap;
|
|
121
|
-
function toolResultFromError(err) {
|
|
122
|
-
const appErr = normalizeError(err);
|
|
123
|
-
const result = {
|
|
124
|
-
ok: false,
|
|
125
|
-
code: appErr.code,
|
|
126
|
-
details: appErr.details ?? { message: appErr.message },
|
|
127
|
-
...appErr.hint && { hint: appErr.hint }
|
|
128
|
-
};
|
|
129
|
-
normalizedToolErrors.set(result, appErr);
|
|
130
|
-
return result;
|
|
131
|
-
}
|
|
132
|
-
function toolErrorFromResult(result) {
|
|
133
|
-
const retained = normalizedToolErrors.get(result);
|
|
134
|
-
if (retained)
|
|
135
|
-
return retained;
|
|
136
|
-
const details = isRecord(result.details) ? result.details : undefined;
|
|
137
|
-
const message = typeof details?.message === "string" ? details.message : result.code;
|
|
138
|
-
const status = isStitchErrorCode(result.code) ? STITCH_ERROR_STATUS[result.code] : 500;
|
|
139
|
-
return new AppError(result.code, message, status, details, result.hint);
|
|
140
|
-
}
|
|
141
|
-
async function executeToolMethod(method, toolName, rawArgs, context, hooks, lifecycle, coerceJson = false, onOutputStrip, extension, finalizeOutput) {
|
|
142
|
-
return inToolCallContext({ source: context.source, toolName, method }, () => runToolMethod(method, toolName, rawArgs, context, hooks, lifecycle, coerceJson, onOutputStrip, extension, finalizeOutput));
|
|
143
|
-
}
|
|
144
|
-
function inToolCallContext(call, body) {
|
|
145
|
-
const parent = getRequestContext();
|
|
146
|
-
if (!parent)
|
|
147
|
-
return body();
|
|
148
|
-
return runWithRequestContext({
|
|
149
|
-
...parent,
|
|
150
|
-
trace: parent.trace,
|
|
151
|
-
dimensions: parent.dimensions ? { ...parent.dimensions } : undefined,
|
|
152
|
-
error: undefined,
|
|
153
|
-
source: call.source,
|
|
154
|
-
method: "TOOL",
|
|
155
|
-
path: `/${call.source}/${call.toolName}`,
|
|
156
|
-
serviceName: call.method.serviceName,
|
|
157
|
-
action: call.method.key
|
|
158
|
-
}, body);
|
|
159
|
-
}
|
|
160
|
-
async function runToolMethod(method, toolName, rawArgs, context, hooks, lifecycle, coerceJson, onOutputStrip, extension, finalizeOutput) {
|
|
161
|
-
const startedAt = Date.now();
|
|
162
|
-
let hookContext = context;
|
|
163
|
-
const finish = async (result, thrown) => {
|
|
164
|
-
try {
|
|
165
|
-
await hooks?.afterToolCall?.({
|
|
166
|
-
toolName,
|
|
167
|
-
args: rawArgs,
|
|
168
|
-
result,
|
|
169
|
-
durationMs: Date.now() - startedAt,
|
|
170
|
-
context: hookContext,
|
|
171
|
-
endpoint: method,
|
|
172
|
-
...thrown !== undefined && { error: thrown }
|
|
173
|
-
});
|
|
174
|
-
} catch (hookError) {
|
|
175
|
-
try {
|
|
176
|
-
console.error("[stitchkit] afterToolCall hook failed:", hookError);
|
|
177
|
-
} catch {}
|
|
178
|
-
}
|
|
179
|
-
return result;
|
|
180
|
-
};
|
|
181
|
-
let beforeRan = false;
|
|
182
|
-
const runBefore = async () => {
|
|
183
|
-
if (beforeRan || !hooks?.beforeToolCall)
|
|
184
|
-
return null;
|
|
185
|
-
beforeRan = true;
|
|
186
|
-
try {
|
|
187
|
-
await hooks.beforeToolCall({
|
|
188
|
-
toolName,
|
|
189
|
-
args: rawArgs,
|
|
190
|
-
context: hookContext,
|
|
191
|
-
endpoint: method
|
|
192
|
-
});
|
|
193
|
-
return null;
|
|
194
|
-
} catch (err) {
|
|
195
|
-
return finish(toolResultFromError(err));
|
|
196
|
-
}
|
|
197
|
-
};
|
|
198
|
-
const finishThrown = async (err) => {
|
|
199
|
-
const beforeFailure2 = await runBefore();
|
|
200
|
-
if (beforeFailure2)
|
|
201
|
-
return beforeFailure2;
|
|
202
|
-
if (hooks?.onToolError) {
|
|
203
|
-
try {
|
|
204
|
-
await hooks.onToolError({
|
|
205
|
-
toolName,
|
|
206
|
-
error: err,
|
|
207
|
-
context: hookContext,
|
|
208
|
-
endpoint: method
|
|
209
|
-
});
|
|
210
|
-
} catch (hookErr) {
|
|
211
|
-
try {
|
|
212
|
-
console.error("[stitchkit] onToolError hook failed:", hookErr);
|
|
213
|
-
} catch {}
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
|
-
return finish(toolResultFromError(err), err);
|
|
217
|
-
};
|
|
218
|
-
let callArgs = rawArgs;
|
|
219
|
-
let callContext = context;
|
|
220
|
-
if (extension) {
|
|
221
|
-
const extensionKeys = new Set(Object.keys(extension.schema.shape));
|
|
222
|
-
const extensionArgs = Object.fromEntries(Object.entries(rawArgs).filter(([key]) => extensionKeys.has(key)));
|
|
223
|
-
let parsed;
|
|
224
|
-
try {
|
|
225
|
-
parsed = extension.schema.safeParse(extensionArgs);
|
|
226
|
-
} catch (err) {
|
|
227
|
-
return finishThrown(err);
|
|
228
|
-
}
|
|
229
|
-
if (!parsed.success) {
|
|
230
|
-
const beforeFailure2 = await runBefore();
|
|
231
|
-
if (beforeFailure2)
|
|
232
|
-
return beforeFailure2;
|
|
233
|
-
return finish({
|
|
234
|
-
ok: false,
|
|
235
|
-
code: "VALIDATION_ERROR",
|
|
236
|
-
details: { message: `Invalid tool extension: ${formatZodError(parsed.error)}` }
|
|
237
|
-
});
|
|
238
|
-
}
|
|
239
|
-
try {
|
|
240
|
-
const resolved = await extension.resolve({ ...rawArgs, ...parsed.data });
|
|
241
|
-
callContext = {
|
|
242
|
-
...context,
|
|
243
|
-
...resolved,
|
|
244
|
-
source: context.source,
|
|
245
|
-
...context.mcp !== undefined && { mcp: context.mcp }
|
|
246
|
-
};
|
|
247
|
-
hookContext = callContext;
|
|
248
|
-
callArgs = Object.fromEntries(Object.entries(rawArgs).filter(([key]) => !extensionKeys.has(key)));
|
|
249
|
-
} catch (err) {
|
|
250
|
-
return finishThrown(err);
|
|
251
|
-
}
|
|
252
|
-
}
|
|
253
|
-
const beforeFailure = await runBefore();
|
|
254
|
-
if (beforeFailure)
|
|
255
|
-
return beforeFailure;
|
|
256
|
-
const paramKeys = new Set(objectShapeKeys(method.paramsSchema));
|
|
257
|
-
let paramArgs = {};
|
|
258
|
-
let inputArgs = {};
|
|
259
|
-
for (const [key, value] of Object.entries(callArgs)) {
|
|
260
|
-
if (isUnsafeKey(key))
|
|
261
|
-
continue;
|
|
262
|
-
if (paramKeys.has(key))
|
|
263
|
-
paramArgs[key] = value;
|
|
264
|
-
else
|
|
265
|
-
inputArgs[key] = value;
|
|
266
|
-
}
|
|
267
|
-
if (coerceJson) {
|
|
268
|
-
paramArgs = coerceJsonArgs(paramArgs, method.paramsSchema);
|
|
269
|
-
inputArgs = coerceJsonArgs(inputArgs, method.inputSchema);
|
|
270
|
-
}
|
|
271
|
-
let params;
|
|
272
|
-
if (method.paramsSchema) {
|
|
273
|
-
let result;
|
|
274
|
-
try {
|
|
275
|
-
result = method.paramsSchema.safeParse(paramArgs);
|
|
276
|
-
} catch (err) {
|
|
277
|
-
return finishThrown(err);
|
|
278
|
-
}
|
|
279
|
-
if (!result.success) {
|
|
280
|
-
return finish({
|
|
281
|
-
ok: false,
|
|
282
|
-
code: "VALIDATION_ERROR",
|
|
283
|
-
details: { message: `Invalid params: ${formatZodError(result.error)}` }
|
|
284
|
-
});
|
|
285
|
-
}
|
|
286
|
-
params = result.data;
|
|
287
|
-
}
|
|
288
|
-
let input;
|
|
289
|
-
if (method.inputSchema) {
|
|
290
|
-
let result;
|
|
291
|
-
try {
|
|
292
|
-
result = method.inputSchema.safeParse(inputArgs);
|
|
293
|
-
} catch (err) {
|
|
294
|
-
return finishThrown(err);
|
|
295
|
-
}
|
|
296
|
-
if (!result.success) {
|
|
297
|
-
return finish({
|
|
298
|
-
ok: false,
|
|
299
|
-
code: "VALIDATION_ERROR",
|
|
300
|
-
details: { message: `Invalid input: ${formatZodError(result.error)}` }
|
|
301
|
-
});
|
|
302
|
-
}
|
|
303
|
-
input = result.data;
|
|
304
|
-
}
|
|
305
|
-
try {
|
|
306
|
-
const ctx = {
|
|
307
|
-
...callContext,
|
|
308
|
-
params,
|
|
309
|
-
input,
|
|
310
|
-
source: context.source
|
|
311
|
-
};
|
|
312
|
-
if (lifecycle?.beforeHandle) {
|
|
313
|
-
await lifecycle.beforeHandle(ctx, method);
|
|
314
|
-
}
|
|
315
|
-
let data = await method.handler(ctx);
|
|
316
|
-
if (lifecycle?.afterHandle) {
|
|
317
|
-
const transformed = await lifecycle.afterHandle(ctx, data, method);
|
|
318
|
-
if (transformed !== undefined)
|
|
319
|
-
data = transformed;
|
|
320
|
-
}
|
|
321
|
-
const checked = validateDeclaredOutput(method.outputSchema, data, onOutputStrip);
|
|
322
|
-
if (!checked.ok) {
|
|
323
|
-
return finish({
|
|
324
|
-
ok: false,
|
|
325
|
-
code: "INTERNAL_SERVER_ERROR",
|
|
326
|
-
details: { message: checked.message }
|
|
327
|
-
});
|
|
328
|
-
}
|
|
329
|
-
data = checked.data;
|
|
330
|
-
if (finalizeOutput)
|
|
331
|
-
data = await finalizeOutput(data);
|
|
332
|
-
const output = (data === undefined || data === null) && !method.outputSchema ? { status: "ok" } : data;
|
|
333
|
-
return finish({ ok: true, data: output });
|
|
334
|
-
} catch (err) {
|
|
335
|
-
return finishThrown(err);
|
|
336
|
-
}
|
|
337
|
-
}
|
|
34
|
+
} from "./index-smpbdg6k.js";
|
|
338
35
|
|
|
339
36
|
// src/tools/mount.ts
|
|
37
|
+
import { z } from "zod";
|
|
340
38
|
function applyExtend(base, extra) {
|
|
341
|
-
if (base instanceof
|
|
39
|
+
if (base instanceof z.ZodObject) {
|
|
342
40
|
assertToolExtensionCompatible(base, extra);
|
|
343
41
|
return rebuildObject(base, { ...extra, ...base.shape });
|
|
344
42
|
}
|
|
345
|
-
return
|
|
43
|
+
return z.intersection(z.object(extra), base);
|
|
346
44
|
}
|
|
347
45
|
function contractToolMountable(projected, extend) {
|
|
348
46
|
const method = projected.source;
|
|
@@ -373,7 +71,7 @@ function collectTools(service, transport, config = {}) {
|
|
|
373
71
|
}
|
|
374
72
|
function createToolRunner(config) {
|
|
375
73
|
const extension = config.extend ? {
|
|
376
|
-
schema:
|
|
74
|
+
schema: z.object(config.extend.schema),
|
|
377
75
|
resolve: config.extend.resolve
|
|
378
76
|
} : undefined;
|
|
379
77
|
return async function runOneToolCall(tool, rawArgs, context) {
|
|
@@ -479,7 +177,7 @@ function runtimeToolMountable(definition, assertName = true) {
|
|
|
479
177
|
}
|
|
480
178
|
|
|
481
179
|
// src/tools/cli-args.ts
|
|
482
|
-
import { z as
|
|
180
|
+
import { z as z2 } from "zod";
|
|
483
181
|
var NUMERIC_VALUE = /^-(\d+\.?\d*|\.\d+)$/;
|
|
484
182
|
var BOOL_OPTIONS = new Set(["json", "wait", "quiet", "dry-run", "help"]);
|
|
485
183
|
var VALUE_OPTIONS = new Set(["wait-timeout", "output-dir"]);
|
|
@@ -489,27 +187,27 @@ class CliArgumentError extends Error {
|
|
|
489
187
|
name = "CliArgumentError";
|
|
490
188
|
}
|
|
491
189
|
function unwrap(field) {
|
|
492
|
-
if (field instanceof
|
|
190
|
+
if (field instanceof z2.ZodOptional || field instanceof z2.ZodNullable || field instanceof z2.ZodDefault) {
|
|
493
191
|
return unwrap(field.unwrap());
|
|
494
192
|
}
|
|
495
193
|
return field;
|
|
496
194
|
}
|
|
497
195
|
function classify(field) {
|
|
498
|
-
if (field instanceof
|
|
196
|
+
if (field instanceof z2.ZodBoolean)
|
|
499
197
|
return "boolean";
|
|
500
|
-
if (field instanceof
|
|
198
|
+
if (field instanceof z2.ZodNumber)
|
|
501
199
|
return "number";
|
|
502
|
-
if (field instanceof
|
|
200
|
+
if (field instanceof z2.ZodBigInt)
|
|
503
201
|
return "bigint";
|
|
504
|
-
if (field instanceof
|
|
202
|
+
if (field instanceof z2.ZodDate)
|
|
505
203
|
return "date";
|
|
506
|
-
if (field instanceof
|
|
204
|
+
if (field instanceof z2.ZodEnum)
|
|
507
205
|
return "enum";
|
|
508
|
-
if (field instanceof
|
|
206
|
+
if (field instanceof z2.ZodArray)
|
|
509
207
|
return "array";
|
|
510
|
-
if (field instanceof
|
|
208
|
+
if (field instanceof z2.ZodObject)
|
|
511
209
|
return "object";
|
|
512
|
-
if (field instanceof
|
|
210
|
+
if (field instanceof z2.ZodString || field instanceof z2.ZodLiteral)
|
|
513
211
|
return "string";
|
|
514
212
|
return "other";
|
|
515
213
|
}
|
|
@@ -529,11 +227,11 @@ function mergeField(fields, name, info) {
|
|
|
529
227
|
}
|
|
530
228
|
function collectSchemaFields(schema, fields) {
|
|
531
229
|
const base = unwrap(schema);
|
|
532
|
-
if (base instanceof
|
|
230
|
+
if (base instanceof z2.ZodObject) {
|
|
533
231
|
for (const [name, raw] of Object.entries(base.shape)) {
|
|
534
232
|
const fieldBase = unwrap(raw);
|
|
535
233
|
const kind = classify(fieldBase);
|
|
536
|
-
if (kind === "array" && fieldBase instanceof
|
|
234
|
+
if (kind === "array" && fieldBase instanceof z2.ZodArray) {
|
|
537
235
|
mergeField(fields, name, { kind, elementKind: classify(unwrap(fieldBase.element)) });
|
|
538
236
|
} else {
|
|
539
237
|
mergeField(fields, name, { kind });
|
|
@@ -541,12 +239,12 @@ function collectSchemaFields(schema, fields) {
|
|
|
541
239
|
}
|
|
542
240
|
return;
|
|
543
241
|
}
|
|
544
|
-
if (base instanceof
|
|
242
|
+
if (base instanceof z2.ZodUnion) {
|
|
545
243
|
for (const option of base.def.options)
|
|
546
244
|
collectSchemaFields(option, fields);
|
|
547
245
|
return;
|
|
548
246
|
}
|
|
549
|
-
if (base instanceof
|
|
247
|
+
if (base instanceof z2.ZodIntersection) {
|
|
550
248
|
collectSchemaFields(base.def.left, fields);
|
|
551
249
|
collectSchemaFields(base.def.right, fields);
|
|
552
250
|
return;
|
|
@@ -1790,4 +1488,4 @@ async function createCli(config) {
|
|
|
1790
1488
|
return exit(downloadsOk ? exitCode : 1);
|
|
1791
1489
|
}
|
|
1792
1490
|
|
|
1793
|
-
export {
|
|
1491
|
+
export { collectTools, createToolRunner, formatToolError, defineRuntimeTool, createRuntimeToolFactory, collectToolSurface, WaitTimeoutError, runWaitOperation, fetchGuarded, fetchPinnedDocument, readCapped, parseCliArgs, defineCliCommand, DEFAULT_EXIT_CODES, emitResult, pollUntilDone, createCli };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { type ObservabilitySinkStatus } from '../observability/status';
|
|
2
|
+
export type BoundedSinkDropReason = 'capacity' | 'closed';
|
|
3
|
+
export interface BoundedSinkError<EVENT> {
|
|
4
|
+
error: unknown;
|
|
5
|
+
event?: EVENT;
|
|
6
|
+
}
|
|
7
|
+
export interface BoundedSinkDrop<EVENT> {
|
|
8
|
+
reason: BoundedSinkDropReason;
|
|
9
|
+
event: EVENT;
|
|
10
|
+
pending: number;
|
|
11
|
+
}
|
|
12
|
+
export interface BoundedSinkConfig<EVENT> {
|
|
13
|
+
write(event: EVENT): void | Promise<void>;
|
|
14
|
+
filter?(event: EVENT): boolean;
|
|
15
|
+
maxPending?: number;
|
|
16
|
+
onSinkError?(failure: BoundedSinkError<EVENT>): void | Promise<void>;
|
|
17
|
+
onDrop?(drop: BoundedSinkDrop<EVENT>): void | Promise<void>;
|
|
18
|
+
}
|
|
19
|
+
export interface BoundedSinkManager<EVENT> {
|
|
20
|
+
submit(produce: () => EVENT | Promise<EVENT>): void;
|
|
21
|
+
flush(): Promise<void>;
|
|
22
|
+
getStatus(): ObservabilitySinkStatus;
|
|
23
|
+
close(): Promise<ObservabilitySinkStatus>;
|
|
24
|
+
}
|
|
25
|
+
export declare function createBoundedSinkManager<EVENT>(config: BoundedSinkConfig<EVENT>): BoundedSinkManager<EVENT>;
|
|
26
|
+
//# sourceMappingURL=observability-sink.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"observability-sink.d.ts","sourceRoot":"","sources":["../../src/internal/observability-sink.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,uBAAuB,EAE7B,MAAM,yBAAyB,CAAC;AAEjC,MAAM,MAAM,qBAAqB,GAAG,UAAU,GAAG,QAAQ,CAAC;AAE1D,MAAM,WAAW,gBAAgB,CAAC,KAAK;IACrC,KAAK,EAAE,OAAO,CAAC;IACf,KAAK,CAAC,EAAE,KAAK,CAAC;CACf;AAED,MAAM,WAAW,eAAe,CAAC,KAAK;IACpC,MAAM,EAAE,qBAAqB,CAAC;IAC9B,KAAK,EAAE,KAAK,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,iBAAiB,CAAC,KAAK;IACtC,KAAK,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC1C,MAAM,CAAC,CAAC,KAAK,EAAE,KAAK,GAAG,OAAO,CAAC;IAC/B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,CAAC,OAAO,EAAE,gBAAgB,CAAC,KAAK,CAAC,GAAG,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACrE,MAAM,CAAC,CAAC,IAAI,EAAE,eAAe,CAAC,KAAK,CAAC,GAAG,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAC7D;AAED,MAAM,WAAW,kBAAkB,CAAC,KAAK;IACvC,MAAM,CAAC,OAAO,EAAE,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC;IACpD,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACvB,SAAS,IAAI,uBAAuB,CAAC;IACrC,KAAK,IAAI,OAAO,CAAC,uBAAuB,CAAC,CAAC;CAC3C;AAaD,wBAAgB,wBAAwB,CAAC,KAAK,EAC5C,MAAM,EAAE,iBAAiB,CAAC,KAAK,CAAC,GAC/B,kBAAkB,CAAC,KAAK,CAAC,CAuI3B"}
|
package/dist/node.js
CHANGED
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
createHandler,
|
|
9
9
|
createServerLifecycle,
|
|
10
10
|
createSocketIOServer
|
|
11
|
-
} from "./index-
|
|
11
|
+
} from "./index-9zn9fb4e.js";
|
|
12
12
|
import {
|
|
13
13
|
createImplement,
|
|
14
14
|
createImplementRegistry,
|
|
@@ -17,9 +17,9 @@ import {
|
|
|
17
17
|
createScopedImplementRegistry,
|
|
18
18
|
implement,
|
|
19
19
|
implementRegistry
|
|
20
|
-
} from "./index-
|
|
20
|
+
} from "./index-41wm56v0.js";
|
|
21
21
|
import"./index-557by2db.js";
|
|
22
|
-
import"./index-
|
|
22
|
+
import"./index-7c0gkyvj.js";
|
|
23
23
|
import {
|
|
24
24
|
AppError,
|
|
25
25
|
appError,
|
|
@@ -29,9 +29,10 @@ import {
|
|
|
29
29
|
notFound,
|
|
30
30
|
rateLimited,
|
|
31
31
|
unauthorized
|
|
32
|
-
} from "./index-
|
|
32
|
+
} from "./index-ps5pxp3h.js";
|
|
33
33
|
import"./index-6k1937bx.js";
|
|
34
|
-
import"./index-
|
|
34
|
+
import"./index-y2rb7dwx.js";
|
|
35
|
+
import"./index-smpbdg6k.js";
|
|
35
36
|
import"./index-1bx83sw4.js";
|
|
36
37
|
// src/server/node.ts
|
|
37
38
|
import { serve } from "srvx/node";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"audit.d.ts","sourceRoot":"","sources":["../../src/observability/audit.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"audit.d.ts","sourceRoot":"","sources":["../../src/observability/audit.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,aAAa,EAAc,MAAM,kBAAkB,CAAC;AAClE,OAAO,EAAqB,KAAK,cAAc,EAAE,MAAM,WAAW,CAAC;AACnE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAC5C,OAAO,EAAe,KAAK,eAAe,EAAmB,MAAM,YAAY,CAAC;AAChF,OAAO,EAEL,KAAK,wBAAwB,EAG7B,KAAK,mBAAmB,EAEzB,MAAM,UAAU,CAAC;AAGlB,kEAAkE;AAClE,MAAM,WAAW,sBAAsB;IACrC;;;OAGG;IACH,KAAK,EAAE,CAAC,KAAK,EAAE,YAAY,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACrD,iFAAiF;IACjF,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,YAAY,KAAK,OAAO,CAAC;IAC1C,yEAAyE;IACzE,QAAQ,CAAC,EAAE,eAAe,CAAC;IAC3B,sEAAsE;IACtE,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,2DAA2D;IAC3D,WAAW,CAAC,EAAE,CAAC,OAAO,EAAE,SAAS,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC3D,8DAA8D;IAC9D,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,QAAQ,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACnD;AAED,MAAM,MAAM,cAAc,GAAG,UAAU,GAAG,QAAQ,CAAC;AAEnD,MAAM,WAAW,SAAS;IACxB,KAAK,EAAE,OAAO,CAAC;IACf,KAAK,CAAC,EAAE,YAAY,CAAC;CACtB;AAED,MAAM,WAAW,QAAQ;IACvB,MAAM,EAAE,cAAc,CAAC;IACvB,KAAK,EAAE,YAAY,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,0BAA2B,SAAQ,sBAAsB;IACxE,2DAA2D;IAC3D,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,iFAAiF;IACjF,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC5B;AAED,MAAM,WAAW,mBAAmB;IAClC,OAAO,CAAC,EAAE,0BAA0B,CAAC;IACrC,KAAK,CAAC,EAAE,sBAAsB,CAAC;CAChC;AAED,gEAAgE;AAChE,MAAM,WAAW,qBAAqB;IACpC,OAAO,EAAE,cAAc,CAAC;IACxB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC;IAC3B,4EAA4E;IAC5E,OAAO,CAAC,EAAE,WAAW,CAAC;CACvB;AAED,0EAA0E;AAC1E,MAAM,WAAW,mBAAmB;IAClC,cAAc,EAAE,OAAO,CAAC;IACxB,QAAQ,CAAC,UAAU,EAAE,qBAAqB,GAAG,IAAI,CAAC;CACnD;AAED,iFAAiF;AACjF,MAAM,WAAW,aAAa;IAC5B,OAAO,CAAC,EAAE,mBAAmB,CAAC;IAC9B,QAAQ,EAAE,aAAa,CAAC;IACxB,iDAAiD;IACjD,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACvB,2EAA2E;IAC3E,SAAS,IAAI,mBAAmB,CAAC;IACjC,4EAA4E;IAC5E,KAAK,IAAI,OAAO,CAAC,wBAAwB,CAAC,CAAC;CAC5C;AA2ED,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,mBAAmB,GAAG,aAAa,CA8J9E"}
|