stitchkit 0.122.1 → 0.123.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 +93 -0
- package/dist/agent-runtime/deferred-tool-search.d.ts.map +1 -1
- package/dist/agent-runtime/deferred-tool-types.d.ts.map +1 -1
- package/dist/browser/client.d.ts.map +1 -1
- package/dist/browser/contract-identity.d.ts +21 -0
- package/dist/browser/contract-identity.d.ts.map +1 -0
- package/dist/browser/unknown-operation.d.ts +3 -0
- package/dist/browser/unknown-operation.d.ts.map +1 -0
- package/dist/contract/define.d.ts +6 -2
- package/dist/contract/define.d.ts.map +1 -1
- package/dist/contract/endpoint-capabilities.d.ts.map +1 -1
- package/dist/contract/errors.d.ts +4 -0
- package/dist/contract/errors.d.ts.map +1 -1
- package/dist/contract/fingerprint.d.ts +51 -0
- package/dist/contract/fingerprint.d.ts.map +1 -0
- package/dist/contract/identity.d.ts +21 -0
- package/dist/contract/identity.d.ts.map +1 -0
- package/dist/contract/stream.d.ts +32 -0
- package/dist/contract/stream.d.ts.map +1 -1
- package/dist/entrypoints/agent-runtime/browser.js +2 -2
- package/dist/entrypoints/agent-runtime/coding-tools.js +11 -11
- package/dist/entrypoints/agent-runtime/harness.js +12 -12
- package/dist/entrypoints/agent-runtime/openrouter.js +1 -1
- package/dist/entrypoints/agent-runtime/realtime.js +2 -2
- package/dist/entrypoints/agent-runtime/sandbox.js +11 -11
- package/dist/entrypoints/agent-runtime/sqlite/bun.js +15 -15
- package/dist/entrypoints/agent-runtime/sqlite/node.js +15 -15
- package/dist/entrypoints/agent-runtime/testing.js +15 -15
- package/dist/entrypoints/agent-runtime.js +26 -25
- package/dist/entrypoints/application/diagnostic-journal.js +5 -5
- package/dist/entrypoints/application/directory-inbox.js +5 -5
- package/dist/entrypoints/application/grammy.js +1 -1
- package/dist/entrypoints/application.js +7 -7
- package/dist/entrypoints/cli/publish.js +5 -5
- package/dist/entrypoints/cli.d.ts +1 -1
- package/dist/entrypoints/cli.d.ts.map +1 -1
- package/dist/entrypoints/cli.js +20 -17
- package/dist/entrypoints/contract.d.ts +2 -0
- package/dist/entrypoints/contract.d.ts.map +1 -1
- package/dist/entrypoints/contract.js +11 -5
- package/dist/entrypoints/files/packaging.d.ts +1 -0
- package/dist/entrypoints/files/packaging.d.ts.map +1 -1
- package/dist/entrypoints/files/packaging.js +230 -61
- package/dist/entrypoints/files.js +5 -5
- package/dist/entrypoints/geo.js +3 -3
- package/dist/entrypoints/http.js +3 -3
- package/dist/entrypoints/index.d.ts +1 -0
- package/dist/entrypoints/index.d.ts.map +1 -1
- package/dist/entrypoints/index.js +45 -24
- package/dist/entrypoints/live.js +2 -2
- package/dist/entrypoints/node.js +11 -11
- package/dist/entrypoints/observability.js +4 -4
- package/dist/entrypoints/primitives.js +1 -1
- package/dist/entrypoints/process/owner-loss.js +2 -2
- package/dist/entrypoints/process.d.ts +6 -1
- package/dist/entrypoints/process.d.ts.map +1 -1
- package/dist/entrypoints/process.js +370 -9
- package/dist/entrypoints/react.js +2 -2
- package/dist/entrypoints/realtime.js +3 -3
- package/dist/entrypoints/remote.js +20 -10
- package/dist/entrypoints/server.d.ts +1 -0
- package/dist/entrypoints/server.d.ts.map +1 -1
- package/dist/entrypoints/server.js +56 -20
- package/dist/entrypoints/telegram/screens.js +4 -4
- package/dist/entrypoints/telegram.js +6 -6
- package/dist/entrypoints/testing.js +10 -10
- package/dist/entrypoints/tools/agent.js +9 -9
- package/dist/entrypoints/tools/connections.js +7 -7
- package/dist/entrypoints/tools/contract.js +1 -1
- package/dist/entrypoints/tools/invoker.js +7 -7
- package/dist/entrypoints/tools/mcp.js +9 -9
- package/dist/entrypoints/tools/toolkit.js +15 -14
- package/dist/entrypoints/tools.js +17 -17
- package/dist/entrypoints/tracking/contract.js +2 -2
- package/dist/entrypoints/tracking.js +1 -1
- package/dist/files/client-artifact.d.ts +75 -0
- package/dist/files/client-artifact.d.ts.map +1 -0
- package/dist/{index-am1h8c9v.js → index-0d3sm0m9.js} +5 -5
- package/dist/{index-72xtvcvr.js → index-0ndz5r8z.js} +1 -1
- package/dist/index-0v9xb8pz.js +66 -0
- package/dist/{index-qcn84byh.js → index-0w0hxp7n.js} +4 -0
- package/dist/{index-3za04re9.js → index-1c945ten.js} +1 -1
- package/dist/{index-r6v4mc67.js → index-1d7s7da0.js} +1 -1
- package/dist/{index-zsvzhjtk.js → index-20hn8pbh.js} +1 -1
- package/dist/{index-f6pw75e1.js → index-2x2ch0bt.js} +2 -2
- package/dist/{index-61hve0ez.js → index-303qne11.js} +1 -1
- package/dist/{index-g149e9pk.js → index-3bzk2645.js} +1 -1
- package/dist/index-45dyex0j.js +119 -0
- package/dist/{index-nwm3ww60.js → index-64b2dxqz.js} +1 -1
- package/dist/{index-aqwg2dm5.js → index-6k47xdtt.js} +2 -2
- package/dist/index-7q05ag0z.js +10 -0
- package/dist/{index-kz9734jc.js → index-96yjwwgf.js} +6 -5
- package/dist/{index-ff39f9dr.js → index-993vtv1w.js} +3 -3
- package/dist/{index-4jpykzvw.js → index-99nnsz39.js} +2 -2
- package/dist/{index-pfvde2fz.js → index-9ypczvpj.js} +1 -1
- package/dist/{index-qch1vcaa.js → index-a7ebd769.js} +2 -2
- package/dist/{index-98hv3sba.js → index-aw6kx2e6.js} +1 -1
- package/dist/{index-yj6saztf.js → index-bz9cmnqq.js} +96 -14
- package/dist/{index-mtwh9hyp.js → index-cjzaj7ev.js} +1 -1
- package/dist/{index-gtx3eknx.js → index-dv7pa9w6.js} +2 -2
- package/dist/{index-sa99p98w.js → index-eabx6qjh.js} +3 -3
- package/dist/{index-8yxgcyt6.js → index-egg0yp2j.js} +1 -1
- package/dist/{index-h1j71dr1.js → index-enkc9pem.js} +1 -1
- package/dist/{index-aqmadanx.js → index-fa53vygr.js} +2 -2
- package/dist/{index-e6c2spsd.js → index-fpwbskp2.js} +1 -1
- package/dist/{index-m8a44e64.js → index-ftk3838x.js} +1 -1
- package/dist/{index-j95jp7ee.js → index-gdqawggb.js} +1 -1
- package/dist/{index-9dyd8xzf.js → index-hkw233vx.js} +2 -2
- package/dist/{index-9jfdm5tg.js → index-hkxgennw.js} +7 -1
- package/dist/{index-qaqxdbxf.js → index-j8rda9n6.js} +7 -7
- package/dist/{index-4tyt1qya.js → index-jc5xgkpk.js} +2 -2
- package/dist/{index-s9a0fjh3.js → index-kffm4r8w.js} +1 -1
- package/dist/{index-5w6t91ze.js → index-m8ddk770.js} +1 -1
- package/dist/{index-2fc1k9k2.js → index-mdyhr36s.js} +32 -122
- package/dist/{index-r7a7r7ha.js → index-mfntvj58.js} +6 -3
- package/dist/{index-gq3fnq3f.js → index-n90tkkcv.js} +2 -2
- package/dist/{index-k42ckyzx.js → index-ndjzbt2v.js} +2 -2
- package/dist/{index-ycqhyars.js → index-qc7tq0za.js} +3 -3
- package/dist/{index-9frf01t9.js → index-r0xr7y4m.js} +1 -1
- package/dist/{index-s3yxw6kt.js → index-s512scra.js} +9 -7
- package/dist/{index-1h2zv8rx.js → index-sqc6ezrb.js} +41 -1
- package/dist/{index-2bqf0a74.js → index-sqkttz7z.js} +1 -1
- package/dist/{index-rbzq0q16.js → index-t8jz0e20.js} +1 -1
- package/dist/{index-8ryydawp.js → index-tt3ej8r3.js} +1 -1
- package/dist/{index-x4p3kw1p.js → index-tynna0n4.js} +6 -6
- package/dist/{index-72r9k0av.js → index-v62cpkx3.js} +1 -1
- package/dist/{index-10rg78vf.js → index-v8xm2s9v.js} +2 -2
- package/dist/{index-y6ye582c.js → index-w0wy05gr.js} +10 -10
- package/dist/{index-kw1ws0cs.js → index-w3nv6kr8.js} +1 -1
- package/dist/{index-eeahxwvg.js → index-ww3gss55.js} +1 -1
- package/dist/{index-6j15ktag.js → index-wzqd6pen.js} +1 -1
- package/dist/{index-aswegq1r.js → index-xjb131sc.js} +367 -131
- package/dist/{index-1fyea34p.js → index-yebkpytc.js} +5 -5
- package/dist/{index-bgcwxhxh.js → index-yfpt7sxr.js} +24 -46
- package/dist/{index-69t14s4a.js → index-yt1gg11x.js} +3 -2
- package/dist/{index-jk29rwkr.js → index-zfncctjp.js} +1 -1
- package/dist/internal/stable-digest.d.ts +5 -0
- package/dist/internal/stable-digest.d.ts.map +1 -1
- package/dist/internal/typed.d.ts +2 -0
- package/dist/internal/typed.d.ts.map +1 -1
- package/dist/process/operation-child.d.ts +38 -0
- package/dist/process/operation-child.d.ts.map +1 -0
- package/dist/process/operation-wire.d.ts +68 -0
- package/dist/process/operation-wire.d.ts.map +1 -0
- package/dist/process/operation.d.ts +74 -0
- package/dist/process/operation.d.ts.map +1 -0
- package/dist/server/contract-identity.d.ts +10 -0
- package/dist/server/contract-identity.d.ts.map +1 -0
- package/dist/server/contract-stream.d.ts.map +1 -1
- package/dist/server/endpoint-response.d.ts.map +1 -1
- package/dist/server/error-hook.d.ts +1 -0
- package/dist/server/error-hook.d.ts.map +1 -1
- package/dist/tools/cli/args-route.d.ts.map +1 -1
- package/dist/tools/cli/args-tokens.d.ts.map +1 -1
- package/dist/tools/cli/command.d.ts +39 -18
- package/dist/tools/cli/command.d.ts.map +1 -1
- package/dist/tools/cli/format.d.ts.map +1 -1
- package/dist/tools/cli/help.d.ts.map +1 -1
- package/dist/tools/cli/invoke.d.ts +3 -1
- package/dist/tools/cli/invoke.d.ts.map +1 -1
- package/dist/tools/cli/io.d.ts +6 -0
- package/dist/tools/cli/io.d.ts.map +1 -1
- package/dist/tools/cli/managed-surface.d.ts +2 -0
- package/dist/tools/cli/managed-surface.d.ts.map +1 -1
- package/dist/tools/cli/policy.d.ts +14 -0
- package/dist/tools/cli/policy.d.ts.map +1 -1
- package/dist/tools/cli/run-managed.d.ts.map +1 -1
- package/dist/tools/cli/run-native.d.ts.map +1 -1
- package/dist/tools/cli/run-stream.d.ts +23 -0
- package/dist/tools/cli/run-stream.d.ts.map +1 -0
- package/dist/tools/cli/session.d.ts +8 -0
- package/dist/tools/cli/session.d.ts.map +1 -1
- package/dist/tools/cli/stream-surface.d.ts +17 -0
- package/dist/tools/cli/stream-surface.d.ts.map +1 -0
- package/dist/tools/execute.d.ts +7 -1
- package/dist/tools/execute.d.ts.map +1 -1
- package/dist/tools/invoker.d.ts.map +1 -1
- package/dist/tools/remote.d.ts.map +1 -1
- package/llms/agent-runtime.2.txt +632 -745
- package/llms/agent-runtime.3.txt +733 -492
- package/llms/agent-runtime.4.txt +521 -88
- package/llms/agent-runtime.5.txt +114 -0
- package/llms/agent-runtime.txt +4 -655
- package/llms/cli.2.txt +56 -1
- package/llms/cli.txt +68 -1
- package/llms/contract.txt +4 -1
- package/llms/files-packaging.txt +10 -0
- package/llms/process.2.txt +75 -1
- package/llms/process.txt +59 -25
- package/llms/server.4.txt +8 -4
- package/llms/server.5.txt +1 -0
- package/llms/stitchkit.2.txt +74 -0
- package/llms/stitchkit.txt +5 -5
- package/llms/tools.txt +1 -1
- package/llms/{upgrading-0.106.0-0.122.0.txt → upgrading-0.106.0-0.123.0.txt} +50 -3
- package/llms/upgrading.txt +1 -1
- package/llms-full.txt +384 -14
- package/llms.txt +8 -8
- package/package.json +1 -1
- package/dist/index-h2fhjqy7.js +0 -19
- package/dist/index-m5m9rmvt.js +0 -44
|
@@ -14,7 +14,7 @@ import {
|
|
|
14
14
|
import {
|
|
15
15
|
ToolExecutionControlError2,
|
|
16
16
|
isToolExecutionControlError2
|
|
17
|
-
} from "./index-
|
|
17
|
+
} from "./index-s512scra.js";
|
|
18
18
|
import {
|
|
19
19
|
AGENT_TOOL_PROGRESS_MESSAGE_MAX2,
|
|
20
20
|
agentDurableEventId2
|
|
@@ -34,10 +34,10 @@ import {
|
|
|
34
34
|
ProviderJournalRequestSchema,
|
|
35
35
|
ProviderJournalResponseSchema,
|
|
36
36
|
isActiveRunState
|
|
37
|
-
} from "./index-
|
|
37
|
+
} from "./index-egg0yp2j.js";
|
|
38
38
|
import {
|
|
39
39
|
messageOf
|
|
40
|
-
} from "./index-
|
|
40
|
+
} from "./index-3bzk2645.js";
|
|
41
41
|
import {
|
|
42
42
|
createRuntimeToolContext
|
|
43
43
|
} from "./index-eh71zr32.js";
|
|
@@ -52,11 +52,11 @@ import {
|
|
|
52
52
|
} from "./index-0s4xebbg.js";
|
|
53
53
|
import {
|
|
54
54
|
serializeCanonicalJson
|
|
55
|
-
} from "./index-
|
|
55
|
+
} from "./index-20hn8pbh.js";
|
|
56
56
|
import {
|
|
57
57
|
isRecord,
|
|
58
58
|
transportResult
|
|
59
|
-
} from "./index-
|
|
59
|
+
} from "./index-hkxgennw.js";
|
|
60
60
|
|
|
61
61
|
// src/agent-runtime/runtime-internals.ts
|
|
62
62
|
import { z } from "zod";
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import {
|
|
2
|
+
untilAborted
|
|
3
|
+
} from "./index-a5qr2rj6.js";
|
|
4
|
+
import {
|
|
5
|
+
AppError2
|
|
6
|
+
} from "./index-0w0hxp7n.js";
|
|
7
|
+
|
|
8
|
+
// src/contract/stream.ts
|
|
9
|
+
import { z } from "zod";
|
|
10
|
+
var DEFAULT_CONTRACT_STREAM_FRAME_BYTES2 = 256 * 1024;
|
|
11
|
+
var ContractStreamErrorSchema = z.object({
|
|
12
|
+
code: z.string(),
|
|
13
|
+
message: z.string().optional(),
|
|
14
|
+
details: z.unknown().optional(),
|
|
15
|
+
hint: z.string().optional(),
|
|
16
|
+
retryable: z.boolean().optional()
|
|
17
|
+
}).strict();
|
|
18
|
+
var ContractStreamFrameSchema2 = z.discriminatedUnion("type", [
|
|
19
|
+
z.object({ type: z.literal("data"), data: z.unknown() }).strict(),
|
|
20
|
+
z.object({ type: z.literal("error"), error: ContractStreamErrorSchema }).strict(),
|
|
21
|
+
z.object({ type: z.literal("end") }).strict()
|
|
22
|
+
]);
|
|
23
|
+
function checkContractStreamItem(descriptor, value) {
|
|
24
|
+
const parsed = descriptor.item.safeParse(value);
|
|
25
|
+
if (!parsed.success) {
|
|
26
|
+
console.error("[stitchkit] contract stream item failed validation:", parsed.error);
|
|
27
|
+
throw new AppError2("STREAM_ITEM_INVALID", {
|
|
28
|
+
message: "Stream item did not match its contract",
|
|
29
|
+
status: 500
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
return {
|
|
33
|
+
item: parsed.data,
|
|
34
|
+
terminal: descriptor.terminal?.safeParse(parsed.data).success ?? false
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
async function* readContractStreamItems(iterator, descriptor, signal, observe) {
|
|
38
|
+
let terminalSeen = descriptor.terminal === undefined;
|
|
39
|
+
for (;; ) {
|
|
40
|
+
const pending = Promise.resolve(iterator.next());
|
|
41
|
+
observe?.(pending);
|
|
42
|
+
const next = await untilAborted(pending, signal);
|
|
43
|
+
if (next.done)
|
|
44
|
+
break;
|
|
45
|
+
const checked = checkContractStreamItem(descriptor, next.value);
|
|
46
|
+
if (checked.terminal)
|
|
47
|
+
terminalSeen = true;
|
|
48
|
+
yield checked;
|
|
49
|
+
if (checked.terminal && descriptor.completion === "terminal")
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
if (!terminalSeen) {
|
|
53
|
+
throw new AppError2("STREAM_TERMINAL_MISSING", {
|
|
54
|
+
message: "Stream completed before its declared terminal item",
|
|
55
|
+
status: 500
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
function contractStreamLifetimeExceeded() {
|
|
60
|
+
return new AppError2("STREAM_LIFETIME_EXCEEDED", {
|
|
61
|
+
message: "Stream exceeded its declared lifetime",
|
|
62
|
+
status: 408
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export { DEFAULT_CONTRACT_STREAM_FRAME_BYTES2, ContractStreamErrorSchema, ContractStreamFrameSchema2, readContractStreamItems, contractStreamLifetimeExceeded };
|
|
@@ -57,6 +57,7 @@ var STITCH_ERROR_STATUS2 = {
|
|
|
57
57
|
UNAUTHORIZED: 401,
|
|
58
58
|
FORBIDDEN: 403,
|
|
59
59
|
NOT_FOUND: 404,
|
|
60
|
+
UNKNOWN_OPERATION: 404,
|
|
60
61
|
METHOD_NOT_ALLOWED: 405,
|
|
61
62
|
CONFLICT: 409,
|
|
62
63
|
RATE_LIMITED: 429,
|
|
@@ -85,6 +86,9 @@ var STITCH_ERROR_STATUS2 = {
|
|
|
85
86
|
CONNECTION_REQUEST_FAILED: 502,
|
|
86
87
|
UPSTREAM_TOOL_ERROR: 502,
|
|
87
88
|
OPERATION_NOT_SUCCEEDED: 409,
|
|
89
|
+
OPERATION_BUSY: 503,
|
|
90
|
+
OPERATION_RESPONSE_TOO_LARGE: 500,
|
|
91
|
+
OPERATION_PROCESS_FAILED: 500,
|
|
88
92
|
STREAM_ITEM_INVALID: 500,
|
|
89
93
|
STREAM_FRAME_TOO_LARGE: 500,
|
|
90
94
|
STREAM_TERMINAL_MISSING: 500,
|
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
AgentSeedReceiptSchema2,
|
|
9
9
|
AgentHistoryMutationSchema2,
|
|
10
10
|
isActiveRunState
|
|
11
|
-
} from "./index-
|
|
11
|
+
} from "./index-egg0yp2j.js";
|
|
12
12
|
import {
|
|
13
13
|
AgentRecordIdSchema2,
|
|
14
14
|
AgentMessageSchema2
|
|
@@ -17,7 +17,7 @@ import {
|
|
|
17
17
|
replaceMessage,
|
|
18
18
|
ArchiveSpillSchema,
|
|
19
19
|
createAgentRuntimeStore2
|
|
20
|
-
} from "./index-
|
|
20
|
+
} from "./index-v8xm2s9v.js";
|
|
21
21
|
|
|
22
22
|
// src/agent-runtime/store-memory.ts
|
|
23
23
|
import { z as z2 } from "zod";
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import {
|
|
2
|
+
chunksOf
|
|
3
|
+
} from "./index-cjbn98zt.js";
|
|
4
|
+
import {
|
|
5
|
+
assertPositiveSafeInteger
|
|
6
|
+
} from "./index-0s4xebbg.js";
|
|
7
|
+
|
|
8
|
+
// src/internal/bounded-lines.ts
|
|
9
|
+
var DEFAULT_STREAM_LINE_BYTES = 1024 * 1024;
|
|
10
|
+
|
|
11
|
+
class StreamLineLimitError2 extends RangeError {
|
|
12
|
+
limitBytes;
|
|
13
|
+
lineBytes;
|
|
14
|
+
name = "StreamLineLimitError";
|
|
15
|
+
constructor(limitBytes, lineBytes) {
|
|
16
|
+
super(`Stream line exceeds the ${limitBytes} byte limit (${lineBytes} bytes so far)`);
|
|
17
|
+
this.limitBytes = limitBytes;
|
|
18
|
+
this.lineBytes = lineBytes;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
class StreamTruncatedLineError2 extends SyntaxError {
|
|
23
|
+
lineBytes;
|
|
24
|
+
name = "StreamTruncatedLineError";
|
|
25
|
+
constructor(lineBytes) {
|
|
26
|
+
super(`Stream ended with an unterminated final line (${lineBytes} bytes)`);
|
|
27
|
+
this.lineBytes = lineBytes;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
function lineLimit(value) {
|
|
31
|
+
const resolved = value ?? DEFAULT_STREAM_LINE_BYTES;
|
|
32
|
+
assertPositiveSafeInteger("maxLineBytes", resolved);
|
|
33
|
+
return resolved;
|
|
34
|
+
}
|
|
35
|
+
function createLineSplitter(maxLineBytes, requireFinalNewline = false) {
|
|
36
|
+
const limit = lineLimit(maxLineBytes);
|
|
37
|
+
const decoder = new TextDecoder("utf-8", { fatal: true });
|
|
38
|
+
let parts = [];
|
|
39
|
+
let pendingBytes = 0;
|
|
40
|
+
let ended = false;
|
|
41
|
+
let failed = false;
|
|
42
|
+
const drop = () => {
|
|
43
|
+
parts = [];
|
|
44
|
+
pendingBytes = 0;
|
|
45
|
+
};
|
|
46
|
+
const retain = (bytes) => {
|
|
47
|
+
if (bytes.byteLength === 0)
|
|
48
|
+
return;
|
|
49
|
+
pendingBytes += bytes.byteLength;
|
|
50
|
+
if (pendingBytes > limit) {
|
|
51
|
+
const seen = pendingBytes;
|
|
52
|
+
drop();
|
|
53
|
+
throw new StreamLineLimitError2(limit, seen);
|
|
54
|
+
}
|
|
55
|
+
parts.push(new Uint8Array(bytes));
|
|
56
|
+
};
|
|
57
|
+
const take = () => {
|
|
58
|
+
const line = new Uint8Array(pendingBytes);
|
|
59
|
+
let at = 0;
|
|
60
|
+
for (const part of parts) {
|
|
61
|
+
line.set(part, at);
|
|
62
|
+
at += part.byteLength;
|
|
63
|
+
}
|
|
64
|
+
drop();
|
|
65
|
+
return decoder.decode(line);
|
|
66
|
+
};
|
|
67
|
+
function* lines(chunk) {
|
|
68
|
+
if (ended)
|
|
69
|
+
throw new Error("Line decoder received bytes after end()");
|
|
70
|
+
if (failed)
|
|
71
|
+
throw new Error("Line decoder stopped at an earlier error; read the source again");
|
|
72
|
+
try {
|
|
73
|
+
let start = 0;
|
|
74
|
+
for (let index = chunk.indexOf(10);index !== -1; index = chunk.indexOf(10, start)) {
|
|
75
|
+
retain(chunk.subarray(start, index));
|
|
76
|
+
yield take();
|
|
77
|
+
start = index + 1;
|
|
78
|
+
}
|
|
79
|
+
retain(chunk.subarray(start));
|
|
80
|
+
} catch (error) {
|
|
81
|
+
failed = true;
|
|
82
|
+
throw error;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
return {
|
|
86
|
+
lines,
|
|
87
|
+
push: (chunk) => [...lines(chunk)],
|
|
88
|
+
end() {
|
|
89
|
+
ended = true;
|
|
90
|
+
if (pendingBytes === 0)
|
|
91
|
+
return [];
|
|
92
|
+
if (requireFinalNewline) {
|
|
93
|
+
const seen = pendingBytes;
|
|
94
|
+
drop();
|
|
95
|
+
throw new StreamTruncatedLineError2(seen);
|
|
96
|
+
}
|
|
97
|
+
return [take()];
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
function createBoundedLineDecoder(maxLineBytes, requireFinalNewline = false) {
|
|
102
|
+
const { push, end } = createLineSplitter(maxLineBytes, requireFinalNewline);
|
|
103
|
+
return { push, end };
|
|
104
|
+
}
|
|
105
|
+
async function* readBoundedUtf8Lines(source, maxLineBytes, requireFinalNewline = false, signal) {
|
|
106
|
+
const splitter = createLineSplitter(maxLineBytes, requireFinalNewline);
|
|
107
|
+
for await (const chunk of chunksOf(source, signal)) {
|
|
108
|
+
for (const line of splitter.lines(chunk)) {
|
|
109
|
+
signal?.throwIfAborted();
|
|
110
|
+
yield line;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
for (const line of splitter.end()) {
|
|
114
|
+
signal?.throwIfAborted();
|
|
115
|
+
yield line;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
export { DEFAULT_STREAM_LINE_BYTES, StreamLineLimitError2, StreamTruncatedLineError2, createBoundedLineDecoder, readBoundedUtf8Lines };
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import {
|
|
2
2
|
assertUniqueToolName
|
|
3
|
-
} from "./index-
|
|
3
|
+
} from "./index-tynna0n4.js";
|
|
4
4
|
import {
|
|
5
5
|
toolErrorFromResult
|
|
6
|
-
} from "./index-
|
|
6
|
+
} from "./index-s512scra.js";
|
|
7
7
|
import {
|
|
8
8
|
collectTools2,
|
|
9
9
|
createToolRunner
|
|
10
|
-
} from "./index-
|
|
10
|
+
} from "./index-qc7tq0za.js";
|
|
11
11
|
import {
|
|
12
12
|
AppError2
|
|
13
|
-
} from "./index-
|
|
13
|
+
} from "./index-0w0hxp7n.js";
|
|
14
14
|
|
|
15
15
|
// src/tools/invoker.ts
|
|
16
16
|
function createToolInvoker2(services, config) {
|
|
@@ -30,10 +30,11 @@ function createToolInvoker2(services, config) {
|
|
|
30
30
|
const tool = tools.get(name);
|
|
31
31
|
if (tool)
|
|
32
32
|
return tool;
|
|
33
|
-
throw new AppError2("
|
|
33
|
+
throw new AppError2("UNKNOWN_OPERATION", {
|
|
34
34
|
message: `Unknown tool: ${name}`,
|
|
35
35
|
status: 404,
|
|
36
36
|
details: {
|
|
37
|
+
operation: name,
|
|
37
38
|
available: names
|
|
38
39
|
}
|
|
39
40
|
});
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
projectToolSurface
|
|
3
|
-
} from "./index-
|
|
3
|
+
} from "./index-tynna0n4.js";
|
|
4
4
|
import {
|
|
5
5
|
contractToolMountable
|
|
6
|
-
} from "./index-
|
|
6
|
+
} from "./index-qc7tq0za.js";
|
|
7
7
|
import {
|
|
8
8
|
runtimeToolMountable
|
|
9
|
-
} from "./index-
|
|
9
|
+
} from "./index-6k47xdtt.js";
|
|
10
10
|
|
|
11
11
|
// src/tools/surface.ts
|
|
12
12
|
function collectToolSurface({
|
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
TOOL_TRANSPORTS2,
|
|
6
6
|
isHttpOnlyEndpoint,
|
|
7
7
|
assertEndpointExposure
|
|
8
|
-
} from "./index-
|
|
8
|
+
} from "./index-yt1gg11x.js";
|
|
9
9
|
import {
|
|
10
10
|
isUnsafeKey
|
|
11
11
|
} from "./index-zsarb5xp.js";
|
|
@@ -14,7 +14,7 @@ import {
|
|
|
14
14
|
} from "./index-0s4xebbg.js";
|
|
15
15
|
import {
|
|
16
16
|
isRecord
|
|
17
|
-
} from "./index-
|
|
17
|
+
} from "./index-hkxgennw.js";
|
|
18
18
|
|
|
19
19
|
// src/contract/define-validation.ts
|
|
20
20
|
function assertMultipartEndpoint(prefix, key, ep) {
|
|
@@ -4,10 +4,10 @@ import {
|
|
|
4
4
|
} from "./index-rfkh44ss.js";
|
|
5
5
|
import {
|
|
6
6
|
serializeCanonicalJson
|
|
7
|
-
} from "./index-
|
|
7
|
+
} from "./index-20hn8pbh.js";
|
|
8
8
|
import {
|
|
9
9
|
isRecord
|
|
10
|
-
} from "./index-
|
|
10
|
+
} from "./index-hkxgennw.js";
|
|
11
11
|
|
|
12
12
|
// src/live/watch-contract.ts
|
|
13
13
|
import { z as z2 } from "zod";
|
|
@@ -1,10 +1,16 @@
|
|
|
1
|
+
import {
|
|
2
|
+
resolveRouteParamsSchema
|
|
3
|
+
} from "./index-m38ej7e5.js";
|
|
1
4
|
import {
|
|
2
5
|
ExposureSchema,
|
|
3
6
|
isHttpOnlyEndpoint
|
|
4
|
-
} from "./index-
|
|
7
|
+
} from "./index-yt1gg11x.js";
|
|
5
8
|
import {
|
|
6
9
|
defineContract2
|
|
7
|
-
} from "./index-
|
|
10
|
+
} from "./index-99nnsz39.js";
|
|
11
|
+
import {
|
|
12
|
+
canonicalDigest
|
|
13
|
+
} from "./index-mfntvj58.js";
|
|
8
14
|
import {
|
|
9
15
|
bytesToBase64Url,
|
|
10
16
|
base64UrlToBytes
|
|
@@ -13,16 +19,92 @@ import {
|
|
|
13
19
|
AppError2,
|
|
14
20
|
STITCH_ERROR_STATUS2,
|
|
15
21
|
isStitchErrorCode2
|
|
16
|
-
} from "./index-
|
|
22
|
+
} from "./index-0w0hxp7n.js";
|
|
17
23
|
import {
|
|
18
24
|
typedEntries,
|
|
25
|
+
isRecord,
|
|
19
26
|
transportResult,
|
|
20
27
|
mapObjectTypeBoundary
|
|
21
|
-
} from "./index-
|
|
22
|
-
|
|
28
|
+
} from "./index-hkxgennw.js";
|
|
29
|
+
|
|
30
|
+
// src/contract/fingerprint.ts
|
|
23
31
|
import { z } from "zod";
|
|
32
|
+
var ContractFingerprintSchema2 = z.strictObject({
|
|
33
|
+
fingerprint: z.string(),
|
|
34
|
+
operations: z.record(z.string(), z.string())
|
|
35
|
+
});
|
|
36
|
+
var ANNOTATIONS = new Set(["description", "title", "examples", "deprecated", "$comment"]);
|
|
37
|
+
function constraintsOf(schema) {
|
|
38
|
+
if (Array.isArray(schema))
|
|
39
|
+
return schema.map(constraintsOf);
|
|
40
|
+
if (!isRecord(schema))
|
|
41
|
+
return schema;
|
|
42
|
+
const constraints = {};
|
|
43
|
+
for (const [key, value] of Object.entries(schema)) {
|
|
44
|
+
if (ANNOTATIONS.has(key))
|
|
45
|
+
continue;
|
|
46
|
+
constraints[key] = key === "required" && Array.isArray(value) ? [...value].sort() : key === "properties" && isRecord(value) ? Object.fromEntries(Object.entries(value).map(([name, property]) => [name, constraintsOf(property)])) : constraintsOf(value);
|
|
47
|
+
}
|
|
48
|
+
return constraints;
|
|
49
|
+
}
|
|
50
|
+
function schemaIdentity(schema, io) {
|
|
51
|
+
if (schema === undefined)
|
|
52
|
+
return null;
|
|
53
|
+
return constraintsOf(z.toJSONSchema(schema, { io, unrepresentable: "any", cycles: "ref" }));
|
|
54
|
+
}
|
|
55
|
+
function fingerprintOperations(operations) {
|
|
56
|
+
const digests = {};
|
|
57
|
+
for (const operation of operations) {
|
|
58
|
+
if (Object.hasOwn(digests, operation.name)) {
|
|
59
|
+
throw new Error(`[stitchkit] contract fingerprint: duplicate operation "${operation.name}"`);
|
|
60
|
+
}
|
|
61
|
+
digests[operation.name] = canonicalDigest({
|
|
62
|
+
method: operation.method,
|
|
63
|
+
path: operation.path,
|
|
64
|
+
params: schemaIdentity(operation.params, "input"),
|
|
65
|
+
input: schemaIdentity(operation.input, "input"),
|
|
66
|
+
output: schemaIdentity(operation.output, "output"),
|
|
67
|
+
item: schemaIdentity(operation.item, "output")
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
return { fingerprint: canonicalDigest(digests), operations: digests };
|
|
71
|
+
}
|
|
72
|
+
function contractFingerprint2(contracts) {
|
|
73
|
+
const list = Array.isArray(contracts) ? contracts : [contracts];
|
|
74
|
+
return fingerprintOperations(list.flatMap(contractOperations));
|
|
75
|
+
}
|
|
76
|
+
function contractOperations(contract) {
|
|
77
|
+
const operations = [];
|
|
78
|
+
for (const [key, endpoint] of typedEntries(contract.endpoints)) {
|
|
79
|
+
if (endpoint.expose && !endpoint.expose.includes("HTTP"))
|
|
80
|
+
continue;
|
|
81
|
+
operations.push({
|
|
82
|
+
name: `${contract.meta.prefix}.${key}`,
|
|
83
|
+
method: endpoint.method,
|
|
84
|
+
path: endpoint.path,
|
|
85
|
+
params: resolveRouteParamsSchema(endpoint.path, endpoint.params),
|
|
86
|
+
input: endpoint.input,
|
|
87
|
+
output: endpoint.output,
|
|
88
|
+
item: "stream" in endpoint ? endpoint.stream?.item : undefined
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
return operations;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
// src/contract/identity.ts
|
|
95
|
+
var contractIdentityContract2 = defineContract2({ prefix: "contract-identity", scope: "public" }, {
|
|
96
|
+
read: {
|
|
97
|
+
method: "GET",
|
|
98
|
+
path: "/",
|
|
99
|
+
desc: "The fingerprint of the contract operations this server answers",
|
|
100
|
+
expose: ["HTTP"],
|
|
101
|
+
output: ContractFingerprintSchema2
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
// src/contract/errors-factory.ts
|
|
105
|
+
import { z as z2 } from "zod";
|
|
24
106
|
function isErrorDetailsSchema(value) {
|
|
25
|
-
return value instanceof
|
|
107
|
+
return value instanceof z2.ZodObject || value instanceof z2.ZodOptional && value.unwrap() instanceof z2.ZodObject;
|
|
26
108
|
}
|
|
27
109
|
function validateDefinition(code, definition) {
|
|
28
110
|
if (!Number.isInteger(definition.status) || definition.status < 400 || definition.status > 599) {
|
|
@@ -123,9 +205,9 @@ function defineErrors2(source, mapping) {
|
|
|
123
205
|
});
|
|
124
206
|
}
|
|
125
207
|
// src/contract/factory.ts
|
|
126
|
-
import { z as
|
|
127
|
-
var ContractFactoryToolExposureSchema =
|
|
128
|
-
var ContractFactoryConfigSchema =
|
|
208
|
+
import { z as z3 } from "zod";
|
|
209
|
+
var ContractFactoryToolExposureSchema = z3.strictObject({ default: ExposureSchema });
|
|
210
|
+
var ContractFactoryConfigSchema = z3.strictObject({
|
|
129
211
|
toolExposure: ContractFactoryToolExposureSchema
|
|
130
212
|
});
|
|
131
213
|
function createContractFactory2(...args) {
|
|
@@ -154,11 +236,11 @@ function createContractFactory2(...args) {
|
|
|
154
236
|
return { defineContract: scoped, configure };
|
|
155
237
|
}
|
|
156
238
|
// src/contract/pagination.ts
|
|
157
|
-
import { z as
|
|
239
|
+
import { z as z4 } from "zod";
|
|
158
240
|
function paginatedSchema2(itemSchema) {
|
|
159
|
-
return
|
|
160
|
-
items:
|
|
161
|
-
nextCursor:
|
|
241
|
+
return z4.object({
|
|
242
|
+
items: z4.array(itemSchema),
|
|
243
|
+
nextCursor: z4.string().nullable()
|
|
162
244
|
});
|
|
163
245
|
}
|
|
164
246
|
function toBase64Url(str) {
|
|
@@ -180,4 +262,4 @@ function decodeCursor2(cursor, schema) {
|
|
|
180
262
|
return null;
|
|
181
263
|
}
|
|
182
264
|
}
|
|
183
|
-
export { defineErrors2, createContractFactory2, paginatedSchema2, encodeCursor2, decodeCursor2 };
|
|
265
|
+
export { ContractFingerprintSchema2, fingerprintOperations, contractFingerprint2, contractIdentityContract2, defineErrors2, createContractFactory2, paginatedSchema2, encodeCursor2, decodeCursor2 };
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
ProcessInstanceSchema2,
|
|
4
4
|
readProcessInstance,
|
|
5
5
|
probeProcessOwner2
|
|
6
|
-
} from "./index-
|
|
6
|
+
} from "./index-n90tkkcv.js";
|
|
7
7
|
import {
|
|
8
8
|
BoundedFileReadError,
|
|
9
9
|
readBoundedFile
|
|
@@ -14,7 +14,7 @@ import {
|
|
|
14
14
|
} from "./index-b56nnscm.js";
|
|
15
15
|
import {
|
|
16
16
|
isRecord
|
|
17
|
-
} from "./index-
|
|
17
|
+
} from "./index-hkxgennw.js";
|
|
18
18
|
|
|
19
19
|
// src/internal/exclusive-lock.ts
|
|
20
20
|
import { randomUUID } from "node:crypto";
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
2
|
contractMethodFields
|
|
3
|
-
} from "./index-
|
|
3
|
+
} from "./index-9ypczvpj.js";
|
|
4
4
|
import {
|
|
5
5
|
AppError2
|
|
6
|
-
} from "./index-
|
|
6
|
+
} from "./index-0w0hxp7n.js";
|
|
7
7
|
import {
|
|
8
8
|
typedEntries,
|
|
9
9
|
callRuntimeHandler
|
|
10
|
-
} from "./index-
|
|
10
|
+
} from "./index-hkxgennw.js";
|
|
11
11
|
|
|
12
12
|
// src/server/implement.ts
|
|
13
13
|
function isStreamingImplementation(value) {
|