stitchkit 0.91.2 → 0.92.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/CHANGELOG.md +80 -0
- package/dist/agent-runtime-coding-tools.js +3 -3
- package/dist/agent-runtime-harness.js +5 -5
- package/dist/agent-runtime-sandbox.js +3 -3
- package/dist/agent-runtime.js +8 -8
- package/dist/cli.d.ts +6 -3
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +370 -49
- package/dist/contract/define.d.ts +84 -2
- package/dist/contract/define.d.ts.map +1 -1
- package/dist/contract/index.d.ts +1 -1
- package/dist/contract/index.d.ts.map +1 -1
- package/dist/{index-a2nzz56k.js → index-2c2bjw3s.js} +3 -3
- package/dist/{index-seyy8dvn.js → index-7n145nbe.js} +182 -108
- package/dist/{index-axvavfr4.js → index-bx75zwt7.js} +3 -3
- package/dist/{index-709nh7z7.js → index-cxqhvq21.js} +2 -1
- package/dist/{index-pena034b.js → index-e42wzzz5.js} +3 -3
- package/dist/{index-qjeyx5t2.js → index-fq77yfzc.js} +1 -1
- package/dist/{index-fenaekmk.js → index-h9etkkyk.js} +37 -27
- package/dist/{index-4x809vqd.js → index-mzvgxp0n.js} +2 -2
- package/dist/{index-jpfqfg5c.js → index-n0f51dfn.js} +2 -2
- package/dist/{index-bv7mytab.js → index-sr93cwf9.js} +1 -1
- package/dist/{index-vsbzgd7b.js → index-tmwcrptx.js} +1 -0
- package/dist/{index-8z9we758.js → index-vjpvjqpn.js} +1 -1
- package/dist/{index-7hz88dy8.js → index-vk3kq9sb.js} +1 -1
- package/dist/{index-s3dssqxp.js → index-yn8remb1.js} +60 -56
- package/dist/internal/atomic-file.d.ts +21 -0
- package/dist/internal/atomic-file.d.ts.map +1 -0
- package/dist/node.js +3 -3
- package/dist/observability/audit.d.ts +5 -1
- package/dist/observability/audit.d.ts.map +1 -1
- package/dist/observability/changes.d.ts.map +1 -1
- package/dist/observability/context.d.ts +27 -6
- package/dist/observability/context.d.ts.map +1 -1
- package/dist/observability/event.d.ts +34 -6
- package/dist/observability/event.d.ts.map +1 -1
- package/dist/observability/index.d.ts +2 -1
- package/dist/observability/index.d.ts.map +1 -1
- package/dist/observability/index.js +50 -6
- package/dist/observability/work.d.ts +55 -0
- package/dist/observability/work.d.ts.map +1 -0
- package/dist/server/context-contribution.d.ts.map +1 -1
- package/dist/server/index.js +4 -4
- package/dist/server/types.d.ts +20 -6
- package/dist/server/types.d.ts.map +1 -1
- package/dist/testing/surface-manifest.d.ts.map +1 -1
- package/dist/testing.js +6 -4
- package/dist/tool-invoker.js +5 -5
- package/dist/tools/cli-checkpoint.d.ts +24 -0
- package/dist/tools/cli-checkpoint.d.ts.map +1 -0
- package/dist/tools/cli-format.d.ts +10 -0
- package/dist/tools/cli-format.d.ts.map +1 -1
- package/dist/tools/cli-invoke.d.ts +118 -0
- package/dist/tools/cli-invoke.d.ts.map +1 -0
- package/dist/tools/cli-manifest.d.ts +6 -9
- package/dist/tools/cli-manifest.d.ts.map +1 -1
- package/dist/tools/cli-signature.d.ts +81 -0
- package/dist/tools/cli-signature.d.ts.map +1 -0
- package/dist/tools/cli-stream.d.ts +93 -0
- package/dist/tools/cli-stream.d.ts.map +1 -0
- package/dist/tools/cli-update.d.ts +62 -0
- package/dist/tools/cli-update.d.ts.map +1 -1
- package/dist/tools/cli.d.ts +4 -13
- package/dist/tools/cli.d.ts.map +1 -1
- package/dist/tools/connections/index.js +2 -2
- package/dist/tools/execute.d.ts +21 -0
- package/dist/tools/execute.d.ts.map +1 -1
- package/dist/tools/mcp-progress.d.ts +46 -0
- package/dist/tools/mcp-progress.d.ts.map +1 -0
- package/dist/tools/mcp-round-policy.d.ts +25 -1
- package/dist/tools/mcp-round-policy.d.ts.map +1 -1
- package/dist/tools/mcp-round.d.ts +20 -1
- package/dist/tools/mcp-round.d.ts.map +1 -1
- package/dist/tools/mcp-trace.d.ts +9 -1
- package/dist/tools/mcp-trace.d.ts.map +1 -1
- package/dist/tools/mount-wait.d.ts.map +1 -1
- package/dist/tools.js +159 -50
- package/llms-full.txt +358 -8
- package/package.json +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
getRequestContext,
|
|
3
3
|
runWithRequestContext
|
|
4
|
-
} from "./index-
|
|
4
|
+
} from "./index-tmwcrptx.js";
|
|
5
5
|
import {
|
|
6
6
|
formatZodError,
|
|
7
7
|
normalizeError,
|
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
} from "./index-7zbps32p.js";
|
|
13
13
|
import {
|
|
14
14
|
objectShapeKeys
|
|
15
|
-
} from "./index-
|
|
15
|
+
} from "./index-h9etkkyk.js";
|
|
16
16
|
import {
|
|
17
17
|
AppError,
|
|
18
18
|
STITCH_ERROR_STATUS,
|
|
@@ -45,6 +45,53 @@ function isToolExecutionControlError(value) {
|
|
|
45
45
|
return value instanceof ToolExecutionControlError;
|
|
46
46
|
}
|
|
47
47
|
var normalizedToolErrors = new WeakMap;
|
|
48
|
+
function parseToolCallArguments(method, callArgs, coerceJson) {
|
|
49
|
+
const paramKeys = new Set(objectShapeKeys(method.paramsSchema));
|
|
50
|
+
let paramArgs = {};
|
|
51
|
+
let inputArgs = {};
|
|
52
|
+
for (const [key, value] of Object.entries(callArgs)) {
|
|
53
|
+
if (isUnsafeKey(key))
|
|
54
|
+
continue;
|
|
55
|
+
if (paramKeys.has(key))
|
|
56
|
+
paramArgs[key] = value;
|
|
57
|
+
else
|
|
58
|
+
inputArgs[key] = value;
|
|
59
|
+
}
|
|
60
|
+
if (coerceJson) {
|
|
61
|
+
paramArgs = coerceJsonArgs(paramArgs, method.paramsSchema);
|
|
62
|
+
inputArgs = coerceJsonArgs(inputArgs, method.inputSchema);
|
|
63
|
+
}
|
|
64
|
+
let params;
|
|
65
|
+
if (method.paramsSchema) {
|
|
66
|
+
let result;
|
|
67
|
+
try {
|
|
68
|
+
result = method.paramsSchema.safeParse(paramArgs);
|
|
69
|
+
} catch (err) {
|
|
70
|
+
return { ok: false, message: "Invalid params", thrown: err };
|
|
71
|
+
}
|
|
72
|
+
if (!result.success) {
|
|
73
|
+
return { ok: false, message: `Invalid params: ${formatZodError(result.error)}` };
|
|
74
|
+
}
|
|
75
|
+
params = result.data;
|
|
76
|
+
}
|
|
77
|
+
let input;
|
|
78
|
+
if (method.inputSchema) {
|
|
79
|
+
let result;
|
|
80
|
+
try {
|
|
81
|
+
result = method.inputSchema.safeParse(inputArgs);
|
|
82
|
+
} catch (err) {
|
|
83
|
+
return { ok: false, message: "Invalid input", thrown: err };
|
|
84
|
+
}
|
|
85
|
+
if (!result.success) {
|
|
86
|
+
return { ok: false, message: `Invalid input: ${formatZodError(result.error)}` };
|
|
87
|
+
}
|
|
88
|
+
input = result.data;
|
|
89
|
+
}
|
|
90
|
+
return { ok: true, params, input };
|
|
91
|
+
}
|
|
92
|
+
var noProgress = async () => {
|
|
93
|
+
return;
|
|
94
|
+
};
|
|
48
95
|
function toolResultFromError(err) {
|
|
49
96
|
const appErr = normalizeError(err);
|
|
50
97
|
const result = {
|
|
@@ -160,24 +207,24 @@ async function runToolMethod(method, toolName, rawArgs, context, hooks, lifecycl
|
|
|
160
207
|
const keys = new Set(Object.keys(extension.schema.shape));
|
|
161
208
|
extensionKeys = keys;
|
|
162
209
|
const extensionArgs = Object.fromEntries(Object.entries(rawArgs).filter(([key]) => keys.has(key)));
|
|
163
|
-
let
|
|
210
|
+
let parsed2;
|
|
164
211
|
try {
|
|
165
|
-
|
|
212
|
+
parsed2 = extension.schema.safeParse(extensionArgs);
|
|
166
213
|
} catch (err) {
|
|
167
214
|
return finishThrown(err);
|
|
168
215
|
}
|
|
169
|
-
if (!
|
|
216
|
+
if (!parsed2.success) {
|
|
170
217
|
const before2 = await runBefore();
|
|
171
218
|
if (before2?.kind === "failure")
|
|
172
219
|
return before2.result;
|
|
173
220
|
return finish({
|
|
174
221
|
ok: false,
|
|
175
222
|
code: "VALIDATION_ERROR",
|
|
176
|
-
details: { message: `Invalid tool extension: ${formatZodError(
|
|
223
|
+
details: { message: `Invalid tool extension: ${formatZodError(parsed2.error)}` }
|
|
177
224
|
});
|
|
178
225
|
}
|
|
179
226
|
try {
|
|
180
|
-
const resolved = await extension.resolve({ ...rawArgs, ...
|
|
227
|
+
const resolved = await extension.resolve({ ...rawArgs, ...parsed2.data });
|
|
181
228
|
callContext = {
|
|
182
229
|
...context,
|
|
183
230
|
...resolved,
|
|
@@ -198,57 +245,14 @@ async function runToolMethod(method, toolName, rawArgs, context, hooks, lifecycl
|
|
|
198
245
|
callArgs = extensionKeys ? Object.fromEntries(Object.entries(rewrittenArgs).filter(([key]) => !extensionKeys.has(key))) : rewrittenArgs;
|
|
199
246
|
rewrittenArgsApplied = true;
|
|
200
247
|
}
|
|
201
|
-
const
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
for (const [key, value] of Object.entries(callArgs)) {
|
|
205
|
-
if (isUnsafeKey(key))
|
|
206
|
-
continue;
|
|
207
|
-
if (paramKeys.has(key))
|
|
208
|
-
paramArgs[key] = value;
|
|
209
|
-
else
|
|
210
|
-
inputArgs[key] = value;
|
|
211
|
-
}
|
|
212
|
-
if (coerceJson) {
|
|
213
|
-
paramArgs = coerceJsonArgs(paramArgs, method.paramsSchema);
|
|
214
|
-
inputArgs = coerceJsonArgs(inputArgs, method.inputSchema);
|
|
215
|
-
}
|
|
216
|
-
let params;
|
|
217
|
-
if (method.paramsSchema) {
|
|
218
|
-
let result;
|
|
219
|
-
try {
|
|
220
|
-
result = method.paramsSchema.safeParse(paramArgs);
|
|
221
|
-
} catch (err) {
|
|
222
|
-
return finishThrown(err);
|
|
223
|
-
}
|
|
224
|
-
if (!result.success) {
|
|
225
|
-
return finish({
|
|
226
|
-
ok: false,
|
|
227
|
-
code: "VALIDATION_ERROR",
|
|
228
|
-
details: { message: `Invalid params: ${formatZodError(result.error)}` }
|
|
229
|
-
});
|
|
230
|
-
}
|
|
231
|
-
params = result.data;
|
|
232
|
-
}
|
|
233
|
-
let input;
|
|
234
|
-
if (method.inputSchema) {
|
|
235
|
-
let result;
|
|
236
|
-
try {
|
|
237
|
-
result = method.inputSchema.safeParse(inputArgs);
|
|
238
|
-
} catch (err) {
|
|
239
|
-
return finishThrown(err);
|
|
240
|
-
}
|
|
241
|
-
if (!result.success) {
|
|
242
|
-
return finish({
|
|
243
|
-
ok: false,
|
|
244
|
-
code: "VALIDATION_ERROR",
|
|
245
|
-
details: { message: `Invalid input: ${formatZodError(result.error)}` }
|
|
246
|
-
});
|
|
247
|
-
}
|
|
248
|
-
input = result.data;
|
|
248
|
+
const parsed = parseToolCallArguments(method, callArgs, coerceJson);
|
|
249
|
+
if (!parsed.ok) {
|
|
250
|
+
return parsed.thrown !== undefined ? finishThrown(parsed.thrown) : finish({ ok: false, code: "VALIDATION_ERROR", details: { message: parsed.message } });
|
|
249
251
|
}
|
|
252
|
+
const { params, input } = parsed;
|
|
250
253
|
try {
|
|
251
254
|
const ctx = {
|
|
255
|
+
reportProgress: noProgress,
|
|
252
256
|
...callContext,
|
|
253
257
|
params,
|
|
254
258
|
input,
|
|
@@ -283,4 +287,4 @@ async function runToolMethod(method, toolName, rawArgs, context, hooks, lifecycl
|
|
|
283
287
|
}
|
|
284
288
|
}
|
|
285
289
|
|
|
286
|
-
export { ToolExecutionControlError, isToolExecutionControlError, toolResultFromError, toolErrorFromResult, toolCauseFromResult, executeToolMethod };
|
|
290
|
+
export { ToolExecutionControlError, isToolExecutionControlError, parseToolCallArguments, toolResultFromError, toolErrorFromResult, toolCauseFromResult, executeToolMethod };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Replace a file without ever leaving half of one behind, and without handing
|
|
3
|
+
* a writable directory to whoever guessed the staging name.
|
|
4
|
+
*
|
|
5
|
+
* Write beside the target, then rename onto it: the rename is atomic within a
|
|
6
|
+
* filesystem, so a reader sees the old bytes or the new ones and never a
|
|
7
|
+
* partial write. The staging path has to be in the target's own directory for
|
|
8
|
+
* that to hold — a rename across filesystems is a copy, and a copy is exactly
|
|
9
|
+
* the window this avoids.
|
|
10
|
+
*
|
|
11
|
+
* The staging name is random and the file is created exclusively. A name built
|
|
12
|
+
* from pid and clock is guessable, and `writeFileSync` follows a symlink: an
|
|
13
|
+
* attacker who can write to the directory plants `.app.1234.1700000000000` →
|
|
14
|
+
* `/etc/something`, and the update writes its bytes through the link, chmods
|
|
15
|
+
* the target 0o755 and then renames the link itself into place, so every later
|
|
16
|
+
* write goes there too. `wx` refuses to open anything that already exists,
|
|
17
|
+
* link or file, which closes it.
|
|
18
|
+
*/
|
|
19
|
+
/** Write `bytes` to `target` atomically, with an explicit mode. */
|
|
20
|
+
export declare function writeFileAtomic(target: string, bytes: Uint8Array, mode: number): void;
|
|
21
|
+
//# sourceMappingURL=atomic-file.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"atomic-file.d.ts","sourceRoot":"","sources":["../../src/internal/atomic-file.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAMH,mEAAmE;AACnE,wBAAgB,eAAe,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI,CAmBrF"}
|
package/dist/node.js
CHANGED
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
createHandler,
|
|
6
6
|
createSocketIOServer,
|
|
7
7
|
createUnixClientTransport
|
|
8
|
-
} from "./index-
|
|
8
|
+
} from "./index-n0f51dfn.js";
|
|
9
9
|
import"./index-y91ry9h2.js";
|
|
10
10
|
import {
|
|
11
11
|
ShutdownOptionsSchema,
|
|
@@ -24,8 +24,8 @@ import {
|
|
|
24
24
|
createScopedImplementRegistry,
|
|
25
25
|
implement,
|
|
26
26
|
implementRegistry
|
|
27
|
-
} from "./index-
|
|
28
|
-
import"./index-
|
|
27
|
+
} from "./index-cxqhvq21.js";
|
|
28
|
+
import"./index-tmwcrptx.js";
|
|
29
29
|
import"./index-f9mb610r.js";
|
|
30
30
|
import"./index-e0znv5gn.js";
|
|
31
31
|
import"./index-0a349c33.js";
|
|
@@ -52,7 +52,11 @@ export interface ObservabilityConfig {
|
|
|
52
52
|
/** The one HTTP completion snapshot produced by the handler. */
|
|
53
53
|
export interface HttpRequestCompletion {
|
|
54
54
|
context: RequestContext;
|
|
55
|
-
|
|
55
|
+
/**
|
|
56
|
+
* The transport's status, when there is a transport. Absent for a unit of
|
|
57
|
+
* work that never had one — `ok` and `errorCode` carry its outcome instead.
|
|
58
|
+
*/
|
|
59
|
+
statusCode?: number;
|
|
56
60
|
durationMs: number;
|
|
57
61
|
payload?: Promise<unknown>;
|
|
58
62
|
/** Framework-owned neutral cancellation; currently paired with HTTP 499. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"audit.d.ts","sourceRoot":"","sources":["../../src/observability/audit.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAElD,OAAO,EAIL,KAAK,uBAAuB,EAE7B,MAAM,gCAAgC,CAAC;AAExC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,KAAK,EAAE,aAAa,EAAc,MAAM,kBAAkB,CAAC;AAClE,OAAO,EACL,KAAK,kBAAkB,EAEvB,KAAK,cAAc,EAEpB,MAAM,WAAW,CAAC;AACnB,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,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AAM,SAAS,CAAC;AAuB5C;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,YAAY,GAAG,OAAO,
|
|
1
|
+
{"version":3,"file":"changes.d.ts","sourceRoot":"","sources":["../../src/observability/changes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAuB5C;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,YAAY,GAAG,OAAO,CASzD"}
|
|
@@ -1,15 +1,36 @@
|
|
|
1
1
|
import type { TransportSource } from '../contract/index.js';
|
|
2
2
|
import { type TraceContext } from './trace.js';
|
|
3
|
-
/**
|
|
3
|
+
/** What a unit of work is: a call that arrived, or work that runs on its own. */
|
|
4
|
+
export type RequestContextKind = 'request' | 'job';
|
|
5
|
+
/** Everything known about the unit of work in flight. */
|
|
4
6
|
export interface RequestContext {
|
|
5
|
-
/** W3C trace ids for this
|
|
7
|
+
/** W3C trace ids for this unit of work. */
|
|
6
8
|
trace: TraceContext;
|
|
7
9
|
/** Which surface the request arrived on. */
|
|
8
10
|
source: TransportSource;
|
|
9
|
-
/**
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
/**
|
|
12
|
+
* What this is. Absent means `request`, so every context written before this
|
|
13
|
+
* existed still reads correctly and no caller has to start declaring it.
|
|
14
|
+
*/
|
|
15
|
+
kind?: RequestContextKind;
|
|
16
|
+
/**
|
|
17
|
+
* What the work is, for work that has no route to name it — `agent-loop`,
|
|
18
|
+
* `broadcast-send`. A request is named by its method and path; a job is named
|
|
19
|
+
* by what it does.
|
|
20
|
+
*/
|
|
21
|
+
name?: string;
|
|
22
|
+
/**
|
|
23
|
+
* HTTP verb — absent for work that did not arrive over a transport.
|
|
24
|
+
*
|
|
25
|
+
* It was required, and work without a transport therefore had to invent one:
|
|
26
|
+
* a background loop wrote `method: 'AGENT'`, which is not a verb, it is the
|
|
27
|
+
* absence of one recorded in the field for verbs. An absent field says the
|
|
28
|
+
* same thing and says it truthfully, which is the difference between a filter
|
|
29
|
+
* that can exclude jobs and a filter that silently counts them as writes.
|
|
30
|
+
*/
|
|
31
|
+
method?: string;
|
|
32
|
+
/** Request path — absent for work that did not arrive over a transport. */
|
|
33
|
+
path?: string;
|
|
13
34
|
/** Monotonic start, for duration — `process.hrtime.bigint()`. */
|
|
14
35
|
startedAt: bigint;
|
|
15
36
|
/** Client IP, when resolvable. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../src/observability/context.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAGnD,OAAO,EAAuB,KAAK,YAAY,EAAE,MAAM,SAAS,CAAC;AAEjE,
|
|
1
|
+
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../src/observability/context.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAGnD,OAAO,EAAuB,KAAK,YAAY,EAAE,MAAM,SAAS,CAAC;AAEjE,iFAAiF;AACjF,MAAM,MAAM,kBAAkB,GAAG,SAAS,GAAG,KAAK,CAAC;AAEnD,yDAAyD;AACzD,MAAM,WAAW,cAAc;IAC7B,2CAA2C;IAC3C,KAAK,EAAE,YAAY,CAAC;IACpB,4CAA4C;IAC5C,MAAM,EAAE,eAAe,CAAC;IACxB;;;OAGG;IACH,IAAI,CAAC,EAAE,kBAAkB,CAAC;IAC1B;;;;OAIG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;;;;;;;OAQG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,2EAA2E;IAC3E,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,iEAAiE;IACjE,SAAS,EAAE,MAAM,CAAC;IACl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AC,MAAM,EAAE,MAAM,CAAC,EAClC,OAAO,GAAE,2BAAgC,GACxC,IAAI,CAeN;AAED;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE;IACrC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB,GAAG,IAAI,CAGP;AAED,0CAA0C;AAC1C,MAAM,WAAW,yBAAyB;IACxC;;;OAGG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,oBAAoB,CAAC,CAAC,EACpC,OAAO,EAAE,CAAC,GAAG,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC,KAAK,OAAO,CAAC,QAAQ,CAAC,EACvD,OAAO,GAAE,yBAA8B,GACtC,CAAC,GAAG,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC,KAAK,OAAO,CAAC,QAAQ,CAAC,CAkBhD"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { HttpMethod, McpCallContext, TransportSource } from '../contract/index.js';
|
|
2
|
+
import type { RequestContextKind } from './context.js';
|
|
2
3
|
import type { JsonValue } from './sanitize.js';
|
|
3
4
|
/**
|
|
4
5
|
* A normalised audit event — one shape for a completed call on any surface
|
|
@@ -9,8 +10,24 @@ import type { JsonValue } from './sanitize.js';
|
|
|
9
10
|
export interface RequestEvent {
|
|
10
11
|
/** Surface the call arrived on. */
|
|
11
12
|
source: TransportSource;
|
|
12
|
-
/**
|
|
13
|
-
|
|
13
|
+
/**
|
|
14
|
+
* A call that arrived, or work that ran on its own. Always written, including
|
|
15
|
+
* on requests: a filter that has to read "the absence of `method` means a
|
|
16
|
+
* job" is carrying the same implicit knowledge this field exists to remove.
|
|
17
|
+
*/
|
|
18
|
+
kind: RequestContextKind;
|
|
19
|
+
/**
|
|
20
|
+
* What the work is, for work no route names — `agent-loop`, `broadcast-send`.
|
|
21
|
+
* Absent on requests, which are named by method and path.
|
|
22
|
+
*/
|
|
23
|
+
name?: string;
|
|
24
|
+
/**
|
|
25
|
+
* HTTP verb, `TOOL` for a tool call, and **absent** for work that did not
|
|
26
|
+
* arrive over a transport. It was required, so a background loop had to write
|
|
27
|
+
* something, and what it wrote was `AGENT` — not a verb, but the absence of
|
|
28
|
+
* one recorded in the field for verbs.
|
|
29
|
+
*/
|
|
30
|
+
method?: string;
|
|
14
31
|
/**
|
|
15
32
|
* The operation's contract verb (`GET` / `POST` / …). Set on **tool** events
|
|
16
33
|
* (whose `method` is `TOOL`) so a single filter can tell a read from a write
|
|
@@ -18,8 +35,11 @@ export interface RequestEvent {
|
|
|
18
35
|
* Omitted on HTTP events, where `method` already is the verb. → ADR 0030.
|
|
19
36
|
*/
|
|
20
37
|
httpMethod?: HttpMethod;
|
|
21
|
-
/**
|
|
22
|
-
|
|
38
|
+
/**
|
|
39
|
+
* Request path — `/api/...` for HTTP, `/{source}/{tool}` for a tool call, and
|
|
40
|
+
* absent for work with no transport to have a path on.
|
|
41
|
+
*/
|
|
42
|
+
path?: string;
|
|
23
43
|
/**
|
|
24
44
|
* Stable owning-contract identity of the matched operation — the "service"
|
|
25
45
|
* (contract prefix) and "action" (endpoint key) halves. Set on every surface
|
|
@@ -53,8 +73,16 @@ export interface RequestEvent {
|
|
|
53
73
|
* into; ordinary success/failure rows retain their released shape.
|
|
54
74
|
*/
|
|
55
75
|
outcome?: 'cancelled';
|
|
56
|
-
/**
|
|
57
|
-
|
|
76
|
+
/**
|
|
77
|
+
* HTTP status — the real status for HTTP, `200` / `400` for a tool call, and
|
|
78
|
+
* absent for work that has no transport to have a status on.
|
|
79
|
+
*
|
|
80
|
+
* This one is the trap the rest of this change would otherwise have walked
|
|
81
|
+
* into. Dropping `method: 'AGENT'` while still demanding a status would have
|
|
82
|
+
* replaced one fabricated transport field with another, in the same row, for
|
|
83
|
+
* the same reason. A job's outcome is `ok`, and `errorCode` when it failed.
|
|
84
|
+
*/
|
|
85
|
+
statusCode?: number;
|
|
58
86
|
/** Wall-clock duration. */
|
|
59
87
|
durationMs: number;
|
|
60
88
|
/** Error code — failures only. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"event.d.ts","sourceRoot":"","sources":["../../src/observability/event.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC/E,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAE5C;;;;;GAKG;AACH,MAAM,WAAW,YAAY;IAC3B,mCAAmC;IACnC,MAAM,EAAE,eAAe,CAAC;IACxB,
|
|
1
|
+
{"version":3,"file":"event.d.ts","sourceRoot":"","sources":["../../src/observability/event.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC/E,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AACpD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAE5C;;;;;GAKG;AACH,MAAM,WAAW,YAAY;IAC3B,mCAAmC;IACnC,MAAM,EAAE,eAAe,CAAC;IACxB;;;;OAIG;IACH,IAAI,EAAE,kBAAkB,CAAC;IACzB;;;OAGG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;;;;OAKG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;;;OAKG;IACH,UAAU,CAAC,EAAE,UAAU,CAAC;IACxB;;;OAGG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;;;OAIG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;;;OAKG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACpC,mCAAmC;IACnC,QAAQ,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jectorConfig, type HttpRequestCompletion, type HttpRequestObserver, type Observability, type ObservabilityConfig, type ObservabilityDrainBound, type ProjectedDimensions, type RequestEventSinkConfig, type RequestObservabilityConfig, type SinkDrop, type SinkDropReason, type SinkError, } from './audit.js';
|
|
10
10
|
export { type BoundedLoggerBounds, type BoundedLoggerOptions, createBoundedLogger, DEFAULT_REDACT_PATHS, } from './bounded-logger.js';
|
|
11
11
|
export { auditChanges } from './changes.js';
|
|
12
|
-
export { type DimensionCollision, getRequestContext, getTraceId, getUserId, type RequestContext, runWithRequestContext, type SetRequestDimensionsOptions, setRequestDimensions, setRequestEndpoint, setRequestError, setRequestUser, type WrapRequestContextOptions, wrapInRequestContext, } from './context.js';
|
|
12
|
+
export { type DimensionCollision, getRequestContext, getTraceId, getUserId, type RequestContext, type RequestContextKind, runWithRequestContext, type SetRequestDimensionsOptions, setRequestDimensions, setRequestEndpoint, setRequestError, setRequestUser, type WrapRequestContextOptions, wrapInRequestContext, } from './context.js';
|
|
13
13
|
export type { RequestEvent } from './event.js';
|
|
14
14
|
export { type JsonValue, measureSize, redact, type SanitizeOptions, type SizeMeasure, sanitizePayload, truncatePreview, } from './sanitize.js';
|
|
15
15
|
export { createSpooledSink, type SpooledSink, type SpooledSinkConfig, type SpoolRecovery, } from './spool.js';
|
|
16
16
|
export { type ObservabilityDrainReport, ObservabilityDrainReportSchema, type ObservabilitySinkStatus, ObservabilitySinkStatusSchema, type ObservabilityStatus, ObservabilityStatusSchema, } from './status.js';
|
|
17
17
|
export { childSpan, createTraceContext, formatTraceparent, parseTraceparent, resolvePropagationContext, resolveTraceContext, type TraceContext, } from './trace.js';
|
|
18
|
+
export { type RunUnitOfWorkOptions, runUnitOfWork } from './work.js';
|
|
18
19
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/observability/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EACL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AK,YAAY,GAClB,MAAM,SAAS,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/observability/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EACL,yBAAyB,EACzB,mBAAmB,EACnB,KAAK,mBAAmB,EACxB,KAAK,yBAAyB,EAC9B,KAAK,qBAAqB,EAC1B,KAAK,mBAAmB,EACxB,KAAK,aAAa,EAClB,KAAK,mBAAmB,EACxB,KAAK,uBAAuB,EAC5B,KAAK,mBAAmB,EACxB,KAAK,sBAAsB,EAC3B,KAAK,0BAA0B,EAC/B,KAAK,QAAQ,EACb,KAAK,cAAc,EACnB,KAAK,SAAS,GACf,MAAM,SAAS,CAAC;AACjB,OAAO,EACL,KAAK,mBAAmB,EACxB,KAAK,oBAAoB,EACzB,mBAAmB,EACnB,oBAAoB,GACrB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EACL,KAAK,kBAAkB,EACvB,iBAAiB,EACjB,UAAU,EACV,SAAS,EACT,KAAK,cAAc,EACnB,KAAK,kBAAkB,EACvB,qBAAqB,EACrB,KAAK,2BAA2B,EAChC,oBAAoB,EACpB,kBAAkB,EAClB,eAAe,EACf,cAAc,EACd,KAAK,yBAAyB,EAC9B,oBAAoB,GACrB,MAAM,WAAW,CAAC;AACnB,YAAY,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAC5C,OAAO,EACL,KAAK,SAAS,EACd,WAAW,EACX,MAAM,EACN,KAAK,eAAe,EACpB,KAAK,WAAW,EAChB,eAAe,EACf,eAAe,GAChB,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,iBAAiB,EACjB,KAAK,WAAW,EAChB,KAAK,iBAAiB,EACtB,KAAK,aAAa,GACnB,MAAM,SAAS,CAAC;AACjB,OAAO,EACL,KAAK,wBAAwB,EAC7B,8BAA8B,EAC9B,KAAK,uBAAuB,EAC5B,6BAA6B,EAC7B,KAAK,mBAAmB,EACxB,yBAAyB,GAC1B,MAAM,UAAU,CAAC;AAClB,OAAO,EACL,SAAS,EACT,kBAAkB,EAClB,iBAAiB,EACjB,gBAAgB,EAChB,yBAAyB,EACzB,mBAAmB,EACnB,KAAK,YAAY,GAClB,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,KAAK,oBAAoB,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC"}
|
|
@@ -23,7 +23,7 @@ import {
|
|
|
23
23
|
setRequestError,
|
|
24
24
|
setRequestUser,
|
|
25
25
|
wrapInRequestContext
|
|
26
|
-
} from "../index-
|
|
26
|
+
} from "../index-tmwcrptx.js";
|
|
27
27
|
import"../index-f9mb610r.js";
|
|
28
28
|
import {
|
|
29
29
|
recordedErrorMessage
|
|
@@ -141,8 +141,10 @@ function createObservability(config) {
|
|
|
141
141
|
}
|
|
142
142
|
return {
|
|
143
143
|
source: context.source,
|
|
144
|
-
|
|
145
|
-
|
|
144
|
+
kind: context.kind ?? "request",
|
|
145
|
+
...context.name !== undefined && { name: context.name },
|
|
146
|
+
...context.method !== undefined && { method: context.method },
|
|
147
|
+
...context.path !== undefined && { path: context.path },
|
|
146
148
|
...context.serviceName !== undefined && {
|
|
147
149
|
serviceName: context.serviceName
|
|
148
150
|
},
|
|
@@ -153,9 +155,9 @@ function createObservability(config) {
|
|
|
153
155
|
traceId: context.trace.traceId,
|
|
154
156
|
spanId: context.trace.spanId,
|
|
155
157
|
parentSpanId: context.trace.parentSpanId,
|
|
156
|
-
ok: !cancelled && statusCode < 400,
|
|
158
|
+
ok: !cancelled && (statusCode !== undefined ? statusCode < 400 : context.error === undefined),
|
|
157
159
|
...cancelled && { outcome: "cancelled" },
|
|
158
|
-
statusCode,
|
|
160
|
+
...statusCode !== undefined && { statusCode },
|
|
159
161
|
durationMs,
|
|
160
162
|
...!cancelled && {
|
|
161
163
|
errorCode: context.error?.code,
|
|
@@ -188,6 +190,7 @@ function createObservability(config) {
|
|
|
188
190
|
const toolPhase = mcp?.outcome === "input_required" ? "input-round" : "operation";
|
|
189
191
|
toolManager?.submit(() => ({
|
|
190
192
|
source: context.source,
|
|
193
|
+
kind: "request",
|
|
191
194
|
method: "TOOL",
|
|
192
195
|
httpMethod: endpoint.method,
|
|
193
196
|
path: `/${context.source}/${toolName}`,
|
|
@@ -372,9 +375,11 @@ function createBoundedLogger(options) {
|
|
|
372
375
|
var READ_METHODS = new Set(["GET", "HEAD", "OPTIONS"]);
|
|
373
376
|
var SECURITY_STATUSES = new Set([401, 403]);
|
|
374
377
|
function auditChanges(event) {
|
|
375
|
-
if (SECURITY_STATUSES.has(event.statusCode))
|
|
378
|
+
if (event.statusCode !== undefined && SECURITY_STATUSES.has(event.statusCode))
|
|
376
379
|
return true;
|
|
377
380
|
const verb = event.httpMethod ?? event.method;
|
|
381
|
+
if (verb === undefined)
|
|
382
|
+
return true;
|
|
378
383
|
return !READ_METHODS.has(verb.toUpperCase());
|
|
379
384
|
}
|
|
380
385
|
// src/observability/spool.ts
|
|
@@ -493,6 +498,44 @@ function code(error) {
|
|
|
493
498
|
return typeof value === "string" ? value : undefined;
|
|
494
499
|
}
|
|
495
500
|
var isMissing = (error) => code(error) === "ENOENT";
|
|
501
|
+
// src/observability/work.ts
|
|
502
|
+
async function runUnitOfWork(options, body) {
|
|
503
|
+
const context = {
|
|
504
|
+
trace: resolvePropagationContext(options.traceparent === undefined ? undefined : { traceparent: options.traceparent }, undefined),
|
|
505
|
+
source: options.source ?? "job",
|
|
506
|
+
kind: "job",
|
|
507
|
+
name: options.name,
|
|
508
|
+
startedAt: process.hrtime.bigint(),
|
|
509
|
+
...options.dimensions !== undefined && { dimensions: { ...options.dimensions } }
|
|
510
|
+
};
|
|
511
|
+
const startedAtMs = Date.now();
|
|
512
|
+
return runWithRequestContext(context, async () => {
|
|
513
|
+
try {
|
|
514
|
+
const value = await body();
|
|
515
|
+
complete(options.observability, context, startedAtMs);
|
|
516
|
+
return value;
|
|
517
|
+
} catch (error) {
|
|
518
|
+
context.error ??= {
|
|
519
|
+
...errorCodeOf(error) !== undefined && { code: errorCodeOf(error) },
|
|
520
|
+
message: error instanceof Error ? error.message : String(error)
|
|
521
|
+
};
|
|
522
|
+
complete(options.observability, context, startedAtMs);
|
|
523
|
+
throw error;
|
|
524
|
+
}
|
|
525
|
+
});
|
|
526
|
+
}
|
|
527
|
+
function errorCodeOf(error) {
|
|
528
|
+
if (typeof error !== "object" || error === null)
|
|
529
|
+
return;
|
|
530
|
+
const code2 = Reflect.get(error, "code");
|
|
531
|
+
return typeof code2 === "string" ? code2 : undefined;
|
|
532
|
+
}
|
|
533
|
+
function complete(observability, context, startedAtMs) {
|
|
534
|
+
observability?.request?.complete({
|
|
535
|
+
context,
|
|
536
|
+
durationMs: Date.now() - startedAtMs
|
|
537
|
+
});
|
|
538
|
+
}
|
|
496
539
|
export {
|
|
497
540
|
wrapInRequestContext,
|
|
498
541
|
truncatePreview,
|
|
@@ -502,6 +545,7 @@ export {
|
|
|
502
545
|
setRequestDimensions,
|
|
503
546
|
sanitizePayload,
|
|
504
547
|
runWithRequestContext,
|
|
548
|
+
runUnitOfWork,
|
|
505
549
|
resolveTraceContext,
|
|
506
550
|
resolvePropagationContext,
|
|
507
551
|
redact,
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A unit of work that is not a request.
|
|
3
|
+
*
|
|
4
|
+
* An agent loop started fire-and-forget, a scheduled broadcast, a scenario
|
|
5
|
+
* engine tick: each has a beginning, a duration and an outcome, and none of
|
|
6
|
+
* them arrived over a transport. The context they run in was shaped for
|
|
7
|
+
* requests and required `method` and `path`, so work without a transport either
|
|
8
|
+
* invented them — `method: 'AGENT'`, which is not a verb but the absence of one
|
|
9
|
+
* written into the field for verbs — or ran with no context at all, in which
|
|
10
|
+
* case `setRequestDimensions` was a silent no-op and nothing it did was
|
|
11
|
+
* audited.
|
|
12
|
+
*
|
|
13
|
+
* `runUnitOfWork` gives that work the same treatment a request gets: one
|
|
14
|
+
* context, one completion record, written by the same hand into the same sink.
|
|
15
|
+
* What it deliberately does NOT do is fill the transport fields. A job has no
|
|
16
|
+
* verb, no path and no HTTP status, and the honest record of that is their
|
|
17
|
+
* absence — moving the invention from the consumer into the framework would
|
|
18
|
+
* have been the same lie with a better address.
|
|
19
|
+
*/
|
|
20
|
+
import type { TransportSource } from '../contract/index.js';
|
|
21
|
+
import type { Observability } from './audit.js';
|
|
22
|
+
export interface RunUnitOfWorkOptions {
|
|
23
|
+
/**
|
|
24
|
+
* What the work is — `agent-loop`, `broadcast-send`, `scenario-tick`. A
|
|
25
|
+
* request is named by its method and path; this is how a job is named, and
|
|
26
|
+
* it is the field a dashboard groups by.
|
|
27
|
+
*/
|
|
28
|
+
name: string;
|
|
29
|
+
/**
|
|
30
|
+
* Where the completion record goes — the value `createObservability`
|
|
31
|
+
* returned. Without it the work still gets a context (so trace ids, dimensions
|
|
32
|
+
* and the bounded logger behave), and nothing is recorded.
|
|
33
|
+
*/
|
|
34
|
+
observability?: Observability;
|
|
35
|
+
/**
|
|
36
|
+
* Surface attribution. Defaults to `job`, which is not a transport and does
|
|
37
|
+
* not claim to be one; pass `agent` or a name of your own where the work
|
|
38
|
+
* belongs to a surface you already report under.
|
|
39
|
+
*/
|
|
40
|
+
source?: TransportSource;
|
|
41
|
+
/** Continue an existing trace — the `traceparent` of whatever scheduled this. */
|
|
42
|
+
traceparent?: string;
|
|
43
|
+
/** Domain dimensions known before the work starts; `setRequestDimensions` adds more. */
|
|
44
|
+
dimensions?: Record<string, string>;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Run `body` as one audited unit of work.
|
|
48
|
+
*
|
|
49
|
+
* The record is written whether the body returns or throws, and the throw is
|
|
50
|
+
* re-thrown: observing work must not change what the work does. A failure is
|
|
51
|
+
* recorded as `ok: false` with the error's own code when it has one, which is
|
|
52
|
+
* the same thing a failed request's row says, minus the status a job never had.
|
|
53
|
+
*/
|
|
54
|
+
export declare function runUnitOfWork<T>(options: RunUnitOfWorkOptions, body: () => Promise<T>): Promise<T>;
|
|
55
|
+
//# sourceMappingURL=work.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"work.d.ts","sourceRoot":"","sources":["../../src/observability/work.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AACH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAI7C,MAAM,WAAW,oBAAoB;IACnC;;;;OAIG;IACH,IAAI,EAAE,MAAM,CAAC;IACb;;;;OAIG;IACH,aAAa,CAAC,EAAE,aAAa,CAAC;IAC9B;;;;OAIG;IACH,MAAM,CAAC,EAAE,eAAe,CAAC;IACzB,iFAAiF;IACjF,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,wFAAwF;IACxF,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACrC;AAED;;;;;;;GAOG;AACH,wBAAsB,aAAa,CAAC,CAAC,EACnC,OAAO,EAAE,oBAAoB,EAC7B,IAAI,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GACrB,OAAO,CAAC,CAAC,CAAC,CA8BZ"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context-contribution.d.ts","sourceRoot":"","sources":["../../src/server/context-contribution.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAGlD,kGAAkG;AAClG,eAAO,MAAM,6BAA6B,
|
|
1
|
+
{"version":3,"file":"context-contribution.d.ts","sourceRoot":"","sources":["../../src/server/context-contribution.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAGlD,kGAAkG;AAClG,eAAO,MAAM,6BAA6B,aAgBxC,CAAC;AA0BH;;;;GAIG;AACH,wBAAgB,wBAAwB,CACtC,QAAQ,EAAE,cAAc,EACxB,MAAM,EAAE,cAAc,EACtB,KAAK,EAAE,MAAM,GACZ,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAuBzB;AAED,2EAA2E;AAC3E,wBAAgB,0BAA0B,CACxC,KAAK,EAAE,OAAO,EACd,KAAK,EAAE,MAAM,GACZ,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAuCzB;AAED;;;;GAIG;AACH,wBAAgB,wBAAwB,CACtC,GAAG,EAAE,cAAc,EACnB,KAAK,EAAE,OAAO,EACd,KAAK,EAAE,MAAM,GACZ,IAAI,CAEN"}
|
package/dist/server/index.js
CHANGED
|
@@ -13,7 +13,7 @@ import {
|
|
|
13
13
|
sseRoute,
|
|
14
14
|
streamingRoute,
|
|
15
15
|
webSocketLane
|
|
16
|
-
} from "../index-
|
|
16
|
+
} from "../index-n0f51dfn.js";
|
|
17
17
|
import"../index-y91ry9h2.js";
|
|
18
18
|
import {
|
|
19
19
|
withDeadline
|
|
@@ -44,7 +44,7 @@ import {
|
|
|
44
44
|
signJwt,
|
|
45
45
|
verifyJwt,
|
|
46
46
|
verifyPkce
|
|
47
|
-
} from "../index-
|
|
47
|
+
} from "../index-sr93cwf9.js";
|
|
48
48
|
import {
|
|
49
49
|
deriveCodeChallenge
|
|
50
50
|
} from "../index-hr4tzbwq.js";
|
|
@@ -61,14 +61,14 @@ import {
|
|
|
61
61
|
defineMultipartStream,
|
|
62
62
|
implement,
|
|
63
63
|
implementRegistry
|
|
64
|
-
} from "../index-
|
|
64
|
+
} from "../index-cxqhvq21.js";
|
|
65
65
|
import {
|
|
66
66
|
isWithinDir,
|
|
67
67
|
realPathWithinDir
|
|
68
68
|
} from "../index-sbdmyz75.js";
|
|
69
69
|
import {
|
|
70
70
|
getTraceId
|
|
71
|
-
} from "../index-
|
|
71
|
+
} from "../index-tmwcrptx.js";
|
|
72
72
|
import {
|
|
73
73
|
extractIp,
|
|
74
74
|
generateTraceId,
|