stitchkit 0.100.2 → 0.100.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/CHANGELOG.md +86 -0
- package/README.md +2 -1
- package/dist/entrypoints/agent-runtime/browser.js +119 -119
- package/dist/entrypoints/agent-runtime/coding-tools.js +15 -20
- package/dist/entrypoints/agent-runtime/harness.js +55 -63
- package/dist/entrypoints/agent-runtime/openrouter.js +6 -6
- package/dist/entrypoints/agent-runtime/sandbox.js +20 -25
- package/dist/entrypoints/agent-runtime/sqlite/bun.js +11 -13
- package/dist/entrypoints/agent-runtime/sqlite/node.js +11 -13
- package/dist/entrypoints/agent-runtime/testing.js +32 -34
- package/dist/entrypoints/agent-runtime.js +395 -402
- package/dist/entrypoints/application/diagnostic-journal.js +26 -27
- package/dist/entrypoints/application/directory-inbox.js +16 -17
- package/dist/entrypoints/application/grammy.js +13 -13
- package/dist/entrypoints/application/opentelemetry.js +13 -13
- package/dist/entrypoints/application/schemas.js +24 -24
- package/dist/entrypoints/application.js +208 -210
- package/dist/entrypoints/bin/upgrade-cli.js +2 -2
- package/dist/entrypoints/cli.js +81 -84
- package/dist/entrypoints/contract.js +54 -57
- package/dist/entrypoints/declaration.js +22 -22
- package/dist/entrypoints/files.js +18 -21
- package/dist/entrypoints/geo.js +7 -8
- package/dist/entrypoints/google.js +2 -2
- package/dist/entrypoints/index.js +150 -154
- package/dist/entrypoints/live.js +45 -47
- package/dist/entrypoints/node.js +68 -74
- package/dist/entrypoints/oauth.js +6 -6
- package/dist/entrypoints/observability.d.ts +1 -0
- package/dist/entrypoints/observability.d.ts.map +1 -1
- package/dist/entrypoints/observability.js +115 -87
- package/dist/entrypoints/primitives.js +35 -35
- package/dist/entrypoints/react/keyboard.d.ts +4 -0
- package/dist/entrypoints/react/keyboard.d.ts.map +1 -0
- package/dist/entrypoints/react/keyboard.js +397 -0
- package/dist/entrypoints/react.js +10 -10
- package/dist/entrypoints/release.js +7 -7
- package/dist/entrypoints/remote.js +15 -17
- package/dist/entrypoints/server.js +198 -200
- package/dist/entrypoints/telegram/html.d.ts +5 -0
- package/dist/entrypoints/telegram/html.d.ts.map +1 -0
- package/dist/entrypoints/telegram/html.js +26 -0
- package/dist/entrypoints/telegram/screens.d.ts +14 -0
- package/dist/entrypoints/telegram/screens.d.ts.map +1 -0
- package/dist/entrypoints/telegram/screens.js +2028 -0
- package/dist/entrypoints/telegram.d.ts +5 -1
- package/dist/entrypoints/telegram.d.ts.map +1 -1
- package/dist/entrypoints/telegram.js +548 -156
- package/dist/entrypoints/testing.js +75 -79
- package/dist/entrypoints/tools/connections.js +30 -32
- package/dist/entrypoints/tools/contract.js +18 -20
- package/dist/entrypoints/tools/invoker.js +12 -17
- package/dist/entrypoints/tools.js +223 -229
- package/dist/entrypoints/tracking/server.js +6 -6
- package/dist/entrypoints/tracking.js +40 -42
- package/dist/entrypoints/voice.js +3 -3
- package/dist/{index-eaysmdtq.js → index-0ndk4555.js} +56 -56
- package/dist/{index-2bxbyab0.js → index-1bx1xv1k.js} +1 -1
- package/dist/{index-p5r7qpdd.js → index-1eeqpadm.js} +4 -4
- package/dist/{index-hadmp193.js → index-3ct7hhq6.js} +210 -210
- package/dist/{index-e01r054k.js → index-45tdvqa3.js} +26 -26
- package/dist/{index-dce5wxcq.js → index-4s0fep5q.js} +8 -8
- package/dist/index-50ejfz75.js +9 -0
- package/dist/{index-m9zn6cpq.js → index-5107q189.js} +12 -12
- package/dist/{index-sbdmyz75.js → index-5cc6r990.js} +3 -3
- package/dist/index-6k1svmjh.js +141 -0
- package/dist/{index-c6bxbsnc.js → index-7kxw1awn.js} +2 -2
- package/dist/{index-0r0fbk7z.js → index-7z9ym7t8.js} +28 -28
- package/dist/{index-p7hgdyhb.js → index-814xpr6d.js} +2 -2
- package/dist/{index-gtj3zc53.js → index-8kzct1d6.js} +99 -99
- package/dist/{index-1zbbzgfh.js → index-9pw0a51a.js} +4 -4
- package/dist/{index-79z7m7dt.js → index-a9pd417t.js} +35 -35
- package/dist/{index-ham5sz8m.js → index-aaj97r4y.js} +45 -45
- package/dist/{index-s812ycat.js → index-aan6hqb9.js} +3 -3
- package/dist/{index-10x2hbx0.js → index-adhgd4pe.js} +44 -44
- package/dist/{index-2gxzjvyr.js → index-afjvjyck.js} +23 -23
- package/dist/{index-qmy6zq75.js → index-ahvsksw5.js} +16 -16
- package/dist/{index-hr4tzbwq.js → index-ap3gqe56.js} +3 -3
- package/dist/{index-znfs20ss.js → index-b2bz0kdm.js} +16 -16
- package/dist/{index-r066jx76.js → index-c6aagrbd.js} +148 -120
- package/dist/{index-k30h66yd.js → index-ck71tbcf.js} +9 -9
- package/dist/{index-eqqvgdb3.js → index-ct75c3at.js} +2 -2
- package/dist/{index-gw8bmyaj.js → index-djjhhgjk.js} +41 -41
- package/dist/{index-8qt2m66q.js → index-dvwj1f43.js} +43 -43
- package/dist/{index-fhwqwxe0.js → index-ej331hah.js} +1 -1
- package/dist/{index-9t3dffv2.js → index-ewbaywk5.js} +5 -5
- package/dist/{index-7p1f0vp2.js → index-fyphpknh.js} +25 -25
- package/dist/{index-83bdg97s.js → index-g149e9pk.js} +1 -1
- package/dist/{index-ngfhvfpd.js → index-g6a3na27.js} +4 -4
- package/dist/{index-qwhynv6x.js → index-h124epcf.js} +20 -20
- package/dist/{index-h6eeys1v.js → index-h97tqqp1.js} +9 -9
- package/dist/{index-zcgf3gqf.js → index-hby4qhax.js} +10 -10
- package/dist/{index-5jrd0yng.js → index-j8aw2c0e.js} +4 -4
- package/dist/{index-d8m8zpd8.js → index-jzczzcsb.js} +14 -14
- package/dist/index-kqnd6a85.js +26 -0
- package/dist/{index-35mh5bhj.js → index-kw1ws0cs.js} +12 -12
- package/dist/{index-yw4fzmdz.js → index-kzz6rq0w.js} +28 -17
- package/dist/{index-4gcnakhx.js → index-m38ej7e5.js} +2 -2
- package/dist/{index-ndddxtyx.js → index-m79yr938.js} +19 -19
- package/dist/{index-5p2m7we1.js → index-m9fndta6.js} +11 -11
- package/dist/index-mnkk1ffz.js +150 -0
- package/dist/index-n15jny5b.js +4 -0
- package/dist/{index-2vtcmrj9.js → index-n53mswt3.js} +20 -20
- package/dist/{index-bt14acb5.js → index-n5yqxd3d.js} +21 -21
- package/dist/{index-bm5rx7n6.js → index-n9tyz8z3.js} +12 -12
- package/dist/index-nmaqxdx7.js +463 -0
- package/dist/{index-mqv3b5rh.js → index-nx6eazt0.js} +30 -30
- package/dist/{index-3z73fh2c.js → index-q0th8q0z.js} +9 -9
- package/dist/{index-v260df89.js → index-qjeggp8w.js} +20 -20
- package/dist/{index-zfrhfn82.js → index-r1z0rd9c.js} +20 -20
- package/dist/{index-wqgjfstn.js → index-r5c4fedv.js} +3 -3
- package/dist/{index-cyktc4bp.js → index-r5hsgkz5.js} +118 -118
- package/dist/{index-0b1ess5e.js → index-r7a7r7ha.js} +1 -1
- package/dist/{index-1j8pm5t0.js → index-rfkh44ss.js} +15 -15
- package/dist/index-rz3z13e9.js +47 -0
- package/dist/{index-k6gpggb9.js → index-s80awwsw.js} +35 -35
- package/dist/{index-vqr7f7v8.js → index-ssmd41kh.js} +124 -124
- package/dist/{index-ensd0r74.js → index-v14qqmys.js} +41 -41
- package/dist/{index-paz6sgdp.js → index-v4a2fjtk.js} +36 -36
- package/dist/{index-d9pk3td4.js → index-w0eqdhyd.js} +14 -14
- package/dist/{index-5qn1kx34.js → index-w575evhq.js} +29 -29
- package/dist/{index-3gye9wzb.js → index-w5s3xftz.js} +26 -26
- package/dist/{index-tm88avnj.js → index-wykebpn9.js} +3 -3
- package/dist/{index-sh3s86na.js → index-xkhk5d6g.js} +17 -17
- package/dist/{index-6k1937bx.js → index-xqhede6x.js} +4 -4
- package/dist/{index-f4fx2tza.js → index-zs4ms3th.js} +181 -181
- package/dist/{index-k5hsfc3j.js → index-zsvzhjtk.js} +1 -1
- package/dist/observability/bounded-logger.d.ts +2 -0
- package/dist/observability/bounded-logger.d.ts.map +1 -1
- package/dist/observability/sanitize.d.ts +6 -0
- package/dist/observability/sanitize.d.ts.map +1 -1
- package/dist/observability/secret-values.d.ts +25 -0
- package/dist/observability/secret-values.d.ts.map +1 -0
- package/dist/react/keyboard/hooks.d.ts +71 -0
- package/dist/react/keyboard/hooks.d.ts.map +1 -0
- package/dist/react/keyboard/layers.d.ts +98 -0
- package/dist/react/keyboard/layers.d.ts.map +1 -0
- package/dist/react/keyboard/zone.d.ts +139 -0
- package/dist/react/keyboard/zone.d.ts.map +1 -0
- package/dist/telegram/crypto.d.ts +16 -0
- package/dist/telegram/crypto.d.ts.map +1 -0
- package/dist/telegram/html/check.d.ts +26 -0
- package/dist/telegram/html/check.d.ts.map +1 -0
- package/dist/telegram/html/nodes.d.ts +70 -0
- package/dist/telegram/html/nodes.d.ts.map +1 -0
- package/dist/telegram/html/parse.d.ts +35 -0
- package/dist/telegram/html/parse.d.ts.map +1 -0
- package/dist/telegram/html/render.d.ts +39 -0
- package/dist/telegram/html/render.d.ts.map +1 -0
- package/dist/telegram/init-data.d.ts.map +1 -1
- package/dist/telegram/operator-channel.d.ts +36 -3
- package/dist/telegram/operator-channel.d.ts.map +1 -1
- package/dist/telegram/screens/callback-codec.d.ts +34 -0
- package/dist/telegram/screens/callback-codec.d.ts.map +1 -0
- package/dist/telegram/screens/dispatch.d.ts +22 -0
- package/dist/telegram/screens/dispatch.d.ts.map +1 -0
- package/dist/telegram/screens/display.d.ts +70 -0
- package/dist/telegram/screens/display.d.ts.map +1 -0
- package/dist/telegram/screens/execute.d.ts +57 -0
- package/dist/telegram/screens/execute.d.ts.map +1 -0
- package/dist/telegram/screens/html.d.ts +36 -0
- package/dist/telegram/screens/html.d.ts.map +1 -0
- package/dist/telegram/screens/outcome.d.ts +74 -0
- package/dist/telegram/screens/outcome.d.ts.map +1 -0
- package/dist/telegram/screens/path.d.ts +29 -0
- package/dist/telegram/screens/path.d.ts.map +1 -0
- package/dist/telegram/screens/reconcile.d.ts +67 -0
- package/dist/telegram/screens/reconcile.d.ts.map +1 -0
- package/dist/telegram/screens/registry.d.ts +23 -0
- package/dist/telegram/screens/registry.d.ts.map +1 -0
- package/dist/telegram/screens/render.d.ts +70 -0
- package/dist/telegram/screens/render.d.ts.map +1 -0
- package/dist/telegram/screens/runtime.d.ts +133 -0
- package/dist/telegram/screens/runtime.d.ts.map +1 -0
- package/dist/telegram/screens/screen-types.d.ts +130 -0
- package/dist/telegram/screens/screen-types.d.ts.map +1 -0
- package/dist/telegram/screens/screen.d.ts +138 -0
- package/dist/telegram/screens/screen.d.ts.map +1 -0
- package/dist/telegram/screens/state.d.ts +115 -0
- package/dist/telegram/screens/state.d.ts.map +1 -0
- package/dist/telegram/screens/telegram-screens.d.ts +18 -0
- package/dist/telegram/screens/telegram-screens.d.ts.map +1 -0
- package/dist/telegram/screens/test-chat-telegram.d.ts +47 -0
- package/dist/telegram/screens/test-chat-telegram.d.ts.map +1 -0
- package/dist/telegram/screens/test-chat.d.ts +66 -0
- package/dist/telegram/screens/test-chat.d.ts.map +1 -0
- package/dist/telegram/screens/view.d.ts +89 -0
- package/dist/telegram/screens/view.d.ts.map +1 -0
- package/dist/telegram/send-failure.d.ts +19 -0
- package/dist/telegram/send-failure.d.ts.map +1 -1
- package/dist/telegram/update-intake.d.ts +78 -0
- package/dist/telegram/update-intake.d.ts.map +1 -0
- package/dist/telegram/update-store-sqlite.d.ts +26 -0
- package/dist/telegram/update-store-sqlite.d.ts.map +1 -0
- package/dist/telegram/update-store.d.ts +67 -0
- package/dist/telegram/update-store.d.ts.map +1 -0
- package/dist/telegram/webhook.d.ts +105 -0
- package/dist/telegram/webhook.d.ts.map +1 -0
- package/dist/tools/cli/args-fields.d.ts +8 -0
- package/dist/tools/cli/args-fields.d.ts.map +1 -1
- package/dist/tools/cli/args-route.d.ts.map +1 -1
- package/dist/tools/cli/args.d.ts.map +1 -1
- package/dist/tools/cli/help.d.ts.map +1 -1
- package/llms/cli.txt +8 -2
- package/llms/observability.txt +2 -1
- package/llms/react-keyboard.txt +193 -0
- package/llms/stitchkit.txt +7 -1
- package/llms/telegram-html.txt +35 -0
- package/llms/telegram-screens.txt +365 -0
- package/llms/telegram.txt +160 -4
- package/llms-full.txt +736 -8
- package/llms.txt +10 -5
- package/package.json +17 -2
- package/dist/index-2k4yrqkc.js +0 -9
- package/dist/index-crykmqkr.js +0 -26
- package/dist/index-y64k3s0h.js +0 -150
- package/dist/index-y91ry9h2.js +0 -4
- /package/dist/{index-hffjpmq9.js → index-9jfdm5tg.js} +0 -0
- /package/dist/{index-zjjyynm3.js → index-d4pa2bgs.js} +0 -0
- /package/dist/{index-rxfy4cq7.js → index-dwfv9a85.js} +0 -0
- /package/dist/{index-5jm36zv1.js → index-gfk7nrht.js} +0 -0
- /package/dist/{index-b9aefrqd.js → index-n1dqr7gf.js} +0 -0
- /package/dist/{index-q3pyb9n0.js → index-sykb5ag7.js} +0 -0
- /package/dist/{index-48ffdxgk.js → index-xhzq2qvj.js} +0 -0
- /package/dist/{index-kzfs85xp.js → index-zsarb5xp.js} +0 -0
|
@@ -1,26 +1,26 @@
|
|
|
1
1
|
import {
|
|
2
|
-
inputIsQuery
|
|
3
|
-
} from "./index-48ffdxgk.js";
|
|
4
|
-
import {
|
|
5
|
-
ContractStreamFrameSchema,
|
|
6
|
-
DEFAULT_CONTRACT_STREAM_FRAME_BYTES
|
|
7
|
-
} from "./index-wqgjfstn.js";
|
|
8
|
-
import {
|
|
9
|
-
ApiError,
|
|
10
2
|
RequestCancellationError,
|
|
11
3
|
createRequestCancellation,
|
|
12
|
-
|
|
4
|
+
responseTraceId,
|
|
5
|
+
ApiError2,
|
|
13
6
|
refuseLocally,
|
|
14
|
-
|
|
15
|
-
} from "./index-
|
|
7
|
+
parseApiErrorBody
|
|
8
|
+
} from "./index-qjeggp8w.js";
|
|
16
9
|
import {
|
|
17
10
|
parseTrailingWildcard
|
|
18
|
-
} from "./index-
|
|
11
|
+
} from "./index-m38ej7e5.js";
|
|
12
|
+
import {
|
|
13
|
+
DEFAULT_CONTRACT_STREAM_FRAME_BYTES2,
|
|
14
|
+
ContractStreamFrameSchema2
|
|
15
|
+
} from "./index-r5c4fedv.js";
|
|
16
|
+
import {
|
|
17
|
+
inputIsQuery
|
|
18
|
+
} from "./index-xhzq2qvj.js";
|
|
19
19
|
import {
|
|
20
|
+
typedEntries,
|
|
20
21
|
isRecord,
|
|
21
|
-
mapObject
|
|
22
|
-
|
|
23
|
-
} from "./index-hffjpmq9.js";
|
|
22
|
+
mapObject
|
|
23
|
+
} from "./index-9jfdm5tg.js";
|
|
24
24
|
|
|
25
25
|
// src/internal/bounded-lines.ts
|
|
26
26
|
var DEFAULT_STREAM_LINE_BYTES = 1024 * 1024;
|
|
@@ -89,7 +89,7 @@ function parseFailure(raw, error, onParseError) {
|
|
|
89
89
|
throw failure;
|
|
90
90
|
onParseError(raw, failure);
|
|
91
91
|
}
|
|
92
|
-
async function*
|
|
92
|
+
async function* parseNDJSON2(response, options) {
|
|
93
93
|
try {
|
|
94
94
|
for await (const rawLine of readBoundedUtf8Lines(response, options?.maxLineBytes ?? DEFAULT_STREAM_LINE_BYTES, options?.finalLine === "require-newline")) {
|
|
95
95
|
const line = (rawLine.endsWith("\r") ? rawLine.slice(0, -1) : rawLine).trim();
|
|
@@ -105,7 +105,7 @@ async function* parseNDJSON(response, options) {
|
|
|
105
105
|
parseFailure("", error, options?.onParseError);
|
|
106
106
|
}
|
|
107
107
|
}
|
|
108
|
-
async function*
|
|
108
|
+
async function* parseSSE2(response, options) {
|
|
109
109
|
try {
|
|
110
110
|
for await (const rawLine of readBoundedUtf8Lines(response, options?.maxLineBytes ?? DEFAULT_STREAM_LINE_BYTES)) {
|
|
111
111
|
const line = rawLine.endsWith("\r") ? rawLine.slice(0, -1) : rawLine;
|
|
@@ -343,10 +343,10 @@ function joinClientBaseUrl(baseUrl, relativeUrl) {
|
|
|
343
343
|
// src/browser/contract-stream.ts
|
|
344
344
|
function sourceFor(response, descriptor) {
|
|
345
345
|
const options = {
|
|
346
|
-
maxLineBytes: descriptor.maxFrameBytes ??
|
|
346
|
+
maxLineBytes: descriptor.maxFrameBytes ?? DEFAULT_CONTRACT_STREAM_FRAME_BYTES2,
|
|
347
347
|
finalLine: descriptor.finalLine
|
|
348
348
|
};
|
|
349
|
-
return descriptor.format === "sse" ?
|
|
349
|
+
return descriptor.format === "sse" ? parseSSE2(response, options) : parseNDJSON2(response, options);
|
|
350
350
|
}
|
|
351
351
|
async function* readContractStream(response, descriptor, abort) {
|
|
352
352
|
let ended = false;
|
|
@@ -359,17 +359,17 @@ async function* readContractStream(response, descriptor, abort) {
|
|
|
359
359
|
break;
|
|
360
360
|
let candidate = next.value;
|
|
361
361
|
if (descriptor.framing !== "item") {
|
|
362
|
-
const parsedFrame =
|
|
362
|
+
const parsedFrame = ContractStreamFrameSchema2.safeParse(candidate);
|
|
363
363
|
if (!parsedFrame.success) {
|
|
364
|
-
throw new
|
|
364
|
+
throw new ApiError2("STREAM_PROTOCOL_ERROR", 0, undefined, "Stream frame did not match the protocol envelope");
|
|
365
365
|
}
|
|
366
366
|
const frame = parsedFrame.data;
|
|
367
367
|
if (frame.type === "error") {
|
|
368
|
-
throw new
|
|
368
|
+
throw new ApiError2(frame.error.code, 0, frame.error.details, frame.error.message, frame.error.hint);
|
|
369
369
|
}
|
|
370
370
|
if (frame.type === "end") {
|
|
371
371
|
if (!terminalSeen) {
|
|
372
|
-
throw new
|
|
372
|
+
throw new ApiError2("STREAM_TERMINAL_MISSING", 0, undefined, "Stream completed before its declared terminal item");
|
|
373
373
|
}
|
|
374
374
|
ended = true;
|
|
375
375
|
return;
|
|
@@ -378,7 +378,7 @@ async function* readContractStream(response, descriptor, abort) {
|
|
|
378
378
|
}
|
|
379
379
|
const parsedItem = descriptor.item.safeParse(candidate);
|
|
380
380
|
if (!parsedItem.success) {
|
|
381
|
-
throw new
|
|
381
|
+
throw new ApiError2("STREAM_ITEM_INVALID", 0, undefined, "Stream item did not match its contract");
|
|
382
382
|
}
|
|
383
383
|
const item = parsedItem.data;
|
|
384
384
|
const terminal = descriptor.terminal?.safeParse(item).success ?? false;
|
|
@@ -396,10 +396,10 @@ async function* readContractStream(response, descriptor, abort) {
|
|
|
396
396
|
if (descriptor.framing === "item") {
|
|
397
397
|
if (terminalSeen)
|
|
398
398
|
return;
|
|
399
|
-
throw new
|
|
399
|
+
throw new ApiError2("STREAM_TERMINAL_MISSING", 0, undefined, "Stream completed before its declared terminal item");
|
|
400
400
|
}
|
|
401
401
|
if (!ended) {
|
|
402
|
-
throw new
|
|
402
|
+
throw new ApiError2("STREAM_TRUNCATED", 0, undefined, "Stream ended without its protocol terminal frame");
|
|
403
403
|
}
|
|
404
404
|
} finally {
|
|
405
405
|
abort();
|
|
@@ -567,12 +567,12 @@ function createFetchExecutor(endpoint, prefix, config, contractConfig) {
|
|
|
567
567
|
});
|
|
568
568
|
} catch (error) {
|
|
569
569
|
if (error instanceof RequestCancellationError) {
|
|
570
|
-
throw new
|
|
570
|
+
throw new ApiError2(error.cause === "caller" ? "REQUEST_ABORTED" : "REQUEST_TIMEOUT", 0, undefined, error.message);
|
|
571
571
|
}
|
|
572
|
-
if (
|
|
572
|
+
if (ApiError2.is(error))
|
|
573
573
|
throw error;
|
|
574
574
|
const message = error instanceof Error ? error.message : undefined;
|
|
575
|
-
throw new
|
|
575
|
+
throw new ApiError2("UNKNOWN_ERROR", 0, message ? { message } : undefined, message, undefined, undefined, { cause: error });
|
|
576
576
|
}
|
|
577
577
|
};
|
|
578
578
|
}
|
|
@@ -581,13 +581,13 @@ async function throwForErrorResponse(res, config, fallbackBody) {
|
|
|
581
581
|
config.onError?.(res.status, body);
|
|
582
582
|
const parsed = parseApiErrorBody(body);
|
|
583
583
|
if (parsed) {
|
|
584
|
-
throw new
|
|
584
|
+
throw new ApiError2(parsed.code, res.status, parsed.details, parsed.message, parsed.hint, responseTraceId(res));
|
|
585
585
|
}
|
|
586
|
-
throw new
|
|
586
|
+
throw new ApiError2("HTTP_ERROR", res.status, { body }, undefined, undefined, responseTraceId(res));
|
|
587
587
|
}
|
|
588
588
|
|
|
589
589
|
// src/browser/client.ts
|
|
590
|
-
function
|
|
590
|
+
function contractEndpointMatchers2(contract, endpointNames, contractConfig) {
|
|
591
591
|
const selected = endpointNames ? new Set(endpointNames) : null;
|
|
592
592
|
const matchers = [];
|
|
593
593
|
for (const [key, endpoint] of typedEntries(contract.endpoints)) {
|
|
@@ -606,7 +606,7 @@ function contractEndpointMatchers(contract, endpointNames, contractConfig) {
|
|
|
606
606
|
}
|
|
607
607
|
return matchers;
|
|
608
608
|
}
|
|
609
|
-
function
|
|
609
|
+
function createClient2(contract, configOrClient, contractConfig) {
|
|
610
610
|
const client = {};
|
|
611
611
|
const makeExecutor = isHttpAdapter(configOrClient) ? (endpoint) => createHttpExecutor(endpoint, contract.meta.prefix, configOrClient, contractConfig) : (endpoint) => createFetchExecutor(endpoint, contract.meta.prefix, configOrClient, contractConfig);
|
|
612
612
|
for (const [key, endpoint] of typedEntries(contract.endpoints)) {
|
|
@@ -616,8 +616,8 @@ function createClient(contract, configOrClient, contractConfig) {
|
|
|
616
616
|
}
|
|
617
617
|
return client;
|
|
618
618
|
}
|
|
619
|
-
function
|
|
620
|
-
return mapObject(contracts, (_key, contract) =>
|
|
619
|
+
function createClients2(contracts, configOrClient, contractConfig) {
|
|
620
|
+
return mapObject(contracts, (_key, contract) => createClient2(contract, configOrClient, contractConfig));
|
|
621
621
|
}
|
|
622
622
|
function buildScopedRegistry(contracts, scopeConfigs, surfaceName, build) {
|
|
623
623
|
const registry = {};
|
|
@@ -644,8 +644,8 @@ function buildScopedRegistry(contracts, scopeConfigs, surfaceName, build) {
|
|
|
644
644
|
}
|
|
645
645
|
return registry;
|
|
646
646
|
}
|
|
647
|
-
function
|
|
648
|
-
return buildScopedRegistry(contracts, scopeConfigs, "client", (contract, config) =>
|
|
647
|
+
function createScopedClients2(contracts, configOrClient, scopeConfigs) {
|
|
648
|
+
return buildScopedRegistry(contracts, scopeConfigs, "client", (contract, config) => createClient2(contract, configOrClient, config));
|
|
649
649
|
}
|
|
650
650
|
function isHttpAdapter(value) {
|
|
651
651
|
return typeof value === "object" && "get" in value && typeof value.get === "function";
|
|
@@ -656,8 +656,8 @@ function setClientMethod(target, key, method) {
|
|
|
656
656
|
function createEndpointMethod(endpoint, execute, contractConfig) {
|
|
657
657
|
const hasScopedArguments = (contractConfig?.stripPrefixKeys?.length ?? 0) > 0;
|
|
658
658
|
if (endpointHasArguments(endpoint) || hasScopedArguments) {
|
|
659
|
-
const
|
|
660
|
-
return Object.assign(
|
|
659
|
+
const method = (requestArgs) => settle(execute, readClientRequestArgs(requestArgs), undefined);
|
|
660
|
+
return Object.assign(method, {
|
|
661
661
|
withOptions: (...args) => {
|
|
662
662
|
refuseExtraWithOptionsArguments(endpoint, args.length, 2);
|
|
663
663
|
return settle(execute, readClientRequestArgs(args[0]), readClientRequestOptions(args[1]));
|
|
@@ -708,7 +708,7 @@ function readClientRequestOptions(value) {
|
|
|
708
708
|
function isAbortSignal(value) {
|
|
709
709
|
return typeof value === "object" && value !== null && "aborted" in value && typeof value.aborted === "boolean" && "addEventListener" in value && typeof value.addEventListener === "function" && "removeEventListener" in value && typeof value.removeEventListener === "function";
|
|
710
710
|
}
|
|
711
|
-
function
|
|
711
|
+
function createUrlBuilder2(contract, source, contractConfig) {
|
|
712
712
|
const builder = {};
|
|
713
713
|
for (const [key, endpoint] of typedEntries(contract.endpoints)) {
|
|
714
714
|
if (endpoint.expose && !endpoint.expose.includes("HTTP"))
|
|
@@ -724,11 +724,11 @@ function createUrlBuilder(contract, source, contractConfig) {
|
|
|
724
724
|
}
|
|
725
725
|
return builder;
|
|
726
726
|
}
|
|
727
|
-
function
|
|
728
|
-
return mapObject(contracts, (_key, contract) =>
|
|
727
|
+
function createUrlBuilders2(contracts, source, contractConfig) {
|
|
728
|
+
return mapObject(contracts, (_key, contract) => createUrlBuilder2(contract, source, contractConfig));
|
|
729
729
|
}
|
|
730
|
-
function
|
|
731
|
-
return buildScopedRegistry(contracts, scopeConfigs, "URL builder", (contract, config) =>
|
|
730
|
+
function createScopedUrlBuilders2(contracts, source, scopeConfigs) {
|
|
731
|
+
return buildScopedRegistry(contracts, scopeConfigs, "URL builder", (contract, config) => createUrlBuilder2(contract, source, config));
|
|
732
732
|
}
|
|
733
733
|
|
|
734
|
-
export {
|
|
734
|
+
export { parseNDJSON2, parseSSE2, contractEndpointMatchers2, createClient2, createClients2, createScopedClients2, createUrlBuilder2, createUrlBuilders2, createScopedUrlBuilders2 };
|
|
@@ -18,7 +18,7 @@ function stagingPath(target) {
|
|
|
18
18
|
function bytesOf(data) {
|
|
19
19
|
return typeof data === "string" ? new TextEncoder().encode(data) : data;
|
|
20
20
|
}
|
|
21
|
-
async function
|
|
21
|
+
async function writeFileAtomic2(target, data, options = {}) {
|
|
22
22
|
const mode = options.mode ?? DEFAULT_MODE;
|
|
23
23
|
const staged = stagingPath(target);
|
|
24
24
|
const handle = await open(staged, "wx", mode);
|
|
@@ -38,7 +38,7 @@ async function writeFileAtomic(target, data, options = {}) {
|
|
|
38
38
|
throw error;
|
|
39
39
|
}
|
|
40
40
|
}
|
|
41
|
-
function
|
|
41
|
+
function writeFileAtomicSync2(target, data, options = {}) {
|
|
42
42
|
const mode = options.mode ?? DEFAULT_MODE;
|
|
43
43
|
const bytes = bytesOf(data);
|
|
44
44
|
const staged = stagingPath(target);
|
|
@@ -62,4 +62,4 @@ function writeFileAtomicSync(target, data, options = {}) {
|
|
|
62
62
|
}
|
|
63
63
|
}
|
|
64
64
|
|
|
65
|
-
export {
|
|
65
|
+
export { writeFileAtomic2, writeFileAtomicSync2 };
|
|
@@ -1,26 +1,26 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
AgentStoredRunSchema,
|
|
7
|
-
createAgentRuntimeStore,
|
|
8
|
-
isActiveRunState,
|
|
9
|
-
replaceMessage
|
|
10
|
-
} from "./index-vqr7f7v8.js";
|
|
2
|
+
AgentStoreEventEnvelopeSchema2,
|
|
3
|
+
AgentStoreEventPageSchema2,
|
|
4
|
+
AgentRecoverablePageSchema2
|
|
5
|
+
} from "./index-r5hsgkz5.js";
|
|
11
6
|
import {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
} from "./index-cyktc4bp.js";
|
|
7
|
+
AgentRecordIdSchema2,
|
|
8
|
+
AgentMessageSchema2
|
|
9
|
+
} from "./index-8kzct1d6.js";
|
|
16
10
|
import {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
11
|
+
AgentRuntimeHeadSchema2,
|
|
12
|
+
AgentStoredRunSchema2,
|
|
13
|
+
AgentAdmissionReceiptSchema2,
|
|
14
|
+
AgentSeedReceiptSchema2,
|
|
15
|
+
AgentHistoryMutationSchema2,
|
|
16
|
+
isActiveRunState,
|
|
17
|
+
replaceMessage,
|
|
18
|
+
createAgentRuntimeStore2
|
|
19
|
+
} from "./index-ssmd41kh.js";
|
|
20
20
|
|
|
21
21
|
// src/agent-runtime/store-memory.ts
|
|
22
22
|
import { z } from "zod";
|
|
23
|
-
var RecoverableCursorSchema = z.tuple([
|
|
23
|
+
var RecoverableCursorSchema = z.tuple([AgentRecordIdSchema2, AgentRecordIdSchema2]);
|
|
24
24
|
function recoverableCursor(input) {
|
|
25
25
|
return JSON.stringify([input.conversationId, input.run.id]);
|
|
26
26
|
}
|
|
@@ -30,7 +30,7 @@ function parseRecoverableCursor(cursor) {
|
|
|
30
30
|
function cloneHeadMap(source) {
|
|
31
31
|
return new Map([...source].map(([key, value]) => [
|
|
32
32
|
key,
|
|
33
|
-
|
|
33
|
+
AgentRuntimeHeadSchema2.parse(structuredClone(value))
|
|
34
34
|
]));
|
|
35
35
|
}
|
|
36
36
|
function cloneNestedMap(source, clone) {
|
|
@@ -42,7 +42,7 @@ function cloneNestedMap(source, clone) {
|
|
|
42
42
|
function cloneHistoryMap(source) {
|
|
43
43
|
return new Map([...source].map(([key, value]) => [
|
|
44
44
|
key,
|
|
45
|
-
value.map((message) =>
|
|
45
|
+
value.map((message) => AgentMessageSchema2.parse(structuredClone(message)))
|
|
46
46
|
]));
|
|
47
47
|
}
|
|
48
48
|
var memoryConversations = {
|
|
@@ -62,7 +62,7 @@ var memoryConversations = {
|
|
|
62
62
|
var memoryHead = {
|
|
63
63
|
async load(transaction, conversationId) {
|
|
64
64
|
const head = transaction.heads.get(conversationId);
|
|
65
|
-
return head ?
|
|
65
|
+
return head ? AgentRuntimeHeadSchema2.parse(structuredClone(head)) : undefined;
|
|
66
66
|
},
|
|
67
67
|
async compareAndSwap(transaction, input) {
|
|
68
68
|
const current = transaction.heads.get(input.conversationId);
|
|
@@ -70,31 +70,31 @@ var memoryHead = {
|
|
|
70
70
|
if (actualVersion !== input.expectedVersion) {
|
|
71
71
|
return { outcome: "conflict", actualVersion };
|
|
72
72
|
}
|
|
73
|
-
transaction.heads.set(input.conversationId,
|
|
73
|
+
transaction.heads.set(input.conversationId, AgentRuntimeHeadSchema2.parse(structuredClone(input.next)));
|
|
74
74
|
return { outcome: "applied" };
|
|
75
75
|
}
|
|
76
76
|
};
|
|
77
77
|
var memoryRuns = {
|
|
78
78
|
async load(transaction, input) {
|
|
79
79
|
const record = transaction.runs.get(input.conversationId)?.get(input.runId);
|
|
80
|
-
return record ?
|
|
80
|
+
return record ? AgentStoredRunSchema2.parse(structuredClone(record)) : undefined;
|
|
81
81
|
},
|
|
82
82
|
async loadByAssistantMessageId(transaction, input) {
|
|
83
83
|
const record = [...transaction.runs.get(input.conversationId)?.values() ?? []].find((candidate) => candidate.run.assistantMessageId === input.assistantMessageId);
|
|
84
|
-
return record ?
|
|
84
|
+
return record ? AgentStoredRunSchema2.parse(structuredClone(record)) : undefined;
|
|
85
85
|
},
|
|
86
86
|
async loadMany(transaction, input) {
|
|
87
87
|
const records = transaction.runs.get(input.conversationId);
|
|
88
88
|
return input.runIds.flatMap((runId) => {
|
|
89
89
|
const record = records?.get(runId);
|
|
90
|
-
return record ? [
|
|
90
|
+
return record ? [AgentStoredRunSchema2.parse(structuredClone(record))] : [];
|
|
91
91
|
});
|
|
92
92
|
},
|
|
93
93
|
async listActive(transaction, conversationId) {
|
|
94
|
-
return [...transaction.runs.get(conversationId)?.values() ?? []].filter((record) => isActiveRunState(record.run.state)).map((record) =>
|
|
94
|
+
return [...transaction.runs.get(conversationId)?.values() ?? []].filter((record) => isActiveRunState(record.run.state)).map((record) => AgentStoredRunSchema2.parse(structuredClone(record)));
|
|
95
95
|
},
|
|
96
96
|
async save(transaction, rawRecord) {
|
|
97
|
-
const record =
|
|
97
|
+
const record = AgentStoredRunSchema2.parse(structuredClone(rawRecord));
|
|
98
98
|
const conversationRuns = transaction.runs.get(record.run.conversationId) ?? new Map;
|
|
99
99
|
const collision = [...conversationRuns.values()].find((candidate) => candidate.run.id !== record.run.id && candidate.run.assistantMessageId === record.run.assistantMessageId);
|
|
100
100
|
if (collision)
|
|
@@ -106,16 +106,16 @@ var memoryRuns = {
|
|
|
106
106
|
var memoryAdmissions = {
|
|
107
107
|
async load(transaction, input) {
|
|
108
108
|
const receipt = transaction.admissions.get(input.conversationId)?.get(input.idempotencyKey);
|
|
109
|
-
return receipt ?
|
|
109
|
+
return receipt ? AgentAdmissionReceiptSchema2.parse(structuredClone(receipt)) : undefined;
|
|
110
110
|
},
|
|
111
111
|
async loadByInputMessageId(transaction, input) {
|
|
112
112
|
const receipt = [
|
|
113
113
|
...transaction.admissions.get(input.conversationId)?.values() ?? []
|
|
114
114
|
].find((candidate) => candidate.input.id === input.inputMessageId);
|
|
115
|
-
return receipt ?
|
|
115
|
+
return receipt ? AgentAdmissionReceiptSchema2.parse(structuredClone(receipt)) : undefined;
|
|
116
116
|
},
|
|
117
117
|
async create(transaction, rawReceipt) {
|
|
118
|
-
const receipt =
|
|
118
|
+
const receipt = AgentAdmissionReceiptSchema2.parse(structuredClone(rawReceipt));
|
|
119
119
|
const conversationAdmissions = transaction.admissions.get(receipt.conversationId) ?? new Map;
|
|
120
120
|
if (conversationAdmissions.has(receipt.idempotencyKey) || [...conversationAdmissions.values()].some((candidate) => candidate.input.id === receipt.input.id)) {
|
|
121
121
|
throw new TypeError("Admission identity is already reserved");
|
|
@@ -127,10 +127,10 @@ var memoryAdmissions = {
|
|
|
127
127
|
var memorySeeds = {
|
|
128
128
|
async load(transaction, input) {
|
|
129
129
|
const receipt = transaction.seeds.get(input.conversationId)?.get(input.seedKey);
|
|
130
|
-
return receipt ?
|
|
130
|
+
return receipt ? AgentSeedReceiptSchema2.parse(structuredClone(receipt)) : undefined;
|
|
131
131
|
},
|
|
132
132
|
async create(transaction, rawReceipt) {
|
|
133
|
-
const receipt =
|
|
133
|
+
const receipt = AgentSeedReceiptSchema2.parse(structuredClone(rawReceipt));
|
|
134
134
|
const conversationSeeds = transaction.seeds.get(receipt.conversationId) ?? new Map;
|
|
135
135
|
if (conversationSeeds.has(receipt.seedKey)) {
|
|
136
136
|
throw new TypeError("Conversation seed identity is already reserved");
|
|
@@ -141,13 +141,13 @@ var memorySeeds = {
|
|
|
141
141
|
};
|
|
142
142
|
var memoryHistory = {
|
|
143
143
|
async load(transaction, conversationId) {
|
|
144
|
-
return (transaction.histories.get(conversationId) ?? []).map((message) =>
|
|
144
|
+
return (transaction.histories.get(conversationId) ?? []).map((message) => AgentMessageSchema2.parse(structuredClone(message)));
|
|
145
145
|
},
|
|
146
146
|
async hasMessage(transaction, input) {
|
|
147
147
|
return (transaction.histories.get(input.conversationId) ?? []).some((message) => message.id === input.messageId);
|
|
148
148
|
},
|
|
149
149
|
async apply(transaction, rawMutation) {
|
|
150
|
-
const mutation =
|
|
150
|
+
const mutation = AgentHistoryMutationSchema2.parse(rawMutation);
|
|
151
151
|
const conversationId = mutation.type === "admit" ? mutation.input.conversationId : mutation.type === "upsert-assistant" ? mutation.message.conversationId : mutation.type === "seed" ? mutation.message.conversationId : mutation.summary.conversationId;
|
|
152
152
|
const current = transaction.histories.get(conversationId) ?? [];
|
|
153
153
|
if (mutation.type === "admit") {
|
|
@@ -184,7 +184,7 @@ var memoryHistory = {
|
|
|
184
184
|
var memoryEvents = {
|
|
185
185
|
async append(transaction, draft) {
|
|
186
186
|
const current = transaction.events.get(draft.conversationId) ?? [];
|
|
187
|
-
const event =
|
|
187
|
+
const event = AgentStoreEventEnvelopeSchema2.parse({
|
|
188
188
|
...draft,
|
|
189
189
|
seq: (current.at(-1)?.seq ?? 0) + 1
|
|
190
190
|
});
|
|
@@ -198,7 +198,7 @@ var memoryEvents = {
|
|
|
198
198
|
const selected = (transaction.events.get(input.conversationId) ?? []).filter((event) => (input.fromSeq === undefined || event.seq >= input.fromSeq) && (input.toSeq === undefined || event.seq <= input.toSeq));
|
|
199
199
|
const items = selected.slice(0, input.limit);
|
|
200
200
|
const last = items.at(-1);
|
|
201
|
-
return
|
|
201
|
+
return AgentStoreEventPageSchema2.parse({
|
|
202
202
|
items,
|
|
203
203
|
...selected.length > items.length && last ? { nextSeq: last.seq + 1 } : {}
|
|
204
204
|
});
|
|
@@ -212,17 +212,17 @@ function scanMemoryRecoverable(runs, input) {
|
|
|
212
212
|
const cursorTuple = input.cursor ? parseRecoverableCursor(input.cursor) : undefined;
|
|
213
213
|
const start = cursorTuple ? descriptors.findIndex((item) => item.conversationId.localeCompare(cursorTuple[0]) > 0 || item.conversationId === cursorTuple[0] && item.run.id.localeCompare(cursorTuple[1]) > 0) : 0;
|
|
214
214
|
if (start === -1) {
|
|
215
|
-
return
|
|
215
|
+
return AgentRecoverablePageSchema2.parse({ items: [] });
|
|
216
216
|
}
|
|
217
217
|
const items = descriptors.slice(start, start + input.limit);
|
|
218
218
|
const last = items.at(-1);
|
|
219
219
|
const hasMore = start + items.length < descriptors.length;
|
|
220
|
-
return
|
|
220
|
+
return AgentRecoverablePageSchema2.parse({
|
|
221
221
|
items,
|
|
222
222
|
...hasMore && last && { nextCursor: recoverableCursor(last) }
|
|
223
223
|
});
|
|
224
224
|
}
|
|
225
|
-
function
|
|
225
|
+
function createMemoryAgentRuntimeStore2() {
|
|
226
226
|
let purged = new Set;
|
|
227
227
|
let heads = new Map;
|
|
228
228
|
let runs = new Map;
|
|
@@ -244,13 +244,13 @@ function createMemoryAgentRuntimeStore() {
|
|
|
244
244
|
const transaction = {
|
|
245
245
|
purged: new Set(purged),
|
|
246
246
|
heads: cloneHeadMap(heads),
|
|
247
|
-
runs: cloneNestedMap(runs, (record) =>
|
|
248
|
-
admissions: cloneNestedMap(admissions, (receipt) =>
|
|
249
|
-
seeds: cloneNestedMap(seeds, (receipt) =>
|
|
247
|
+
runs: cloneNestedMap(runs, (record) => AgentStoredRunSchema2.parse(structuredClone(record))),
|
|
248
|
+
admissions: cloneNestedMap(admissions, (receipt) => AgentAdmissionReceiptSchema2.parse(structuredClone(receipt))),
|
|
249
|
+
seeds: cloneNestedMap(seeds, (receipt) => AgentSeedReceiptSchema2.parse(structuredClone(receipt))),
|
|
250
250
|
histories: cloneHistoryMap(histories),
|
|
251
251
|
events: new Map([...events].map(([conversationId, stored]) => [
|
|
252
252
|
conversationId,
|
|
253
|
-
stored.map((event) =>
|
|
253
|
+
stored.map((event) => AgentStoreEventEnvelopeSchema2.parse(structuredClone(event)))
|
|
254
254
|
]))
|
|
255
255
|
};
|
|
256
256
|
try {
|
|
@@ -278,7 +278,7 @@ function createMemoryAgentRuntimeStore() {
|
|
|
278
278
|
return scanMemoryRecoverable(runs, input);
|
|
279
279
|
}
|
|
280
280
|
};
|
|
281
|
-
return
|
|
281
|
+
return createAgentRuntimeStore2(driver);
|
|
282
282
|
}
|
|
283
283
|
|
|
284
|
-
export {
|
|
284
|
+
export { createMemoryAgentRuntimeStore2 };
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
} from "./index-
|
|
2
|
+
AppError2
|
|
3
|
+
} from "./index-n53mswt3.js";
|
|
4
4
|
import {
|
|
5
|
-
|
|
6
|
-
} from "./index-
|
|
5
|
+
contractMethodFields
|
|
6
|
+
} from "./index-1bx1xv1k.js";
|
|
7
7
|
import {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
} from "./index-
|
|
8
|
+
typedEntries,
|
|
9
|
+
callRuntimeHandler
|
|
10
|
+
} from "./index-9jfdm5tg.js";
|
|
11
11
|
|
|
12
12
|
// src/server/middleware/cors.ts
|
|
13
|
-
var
|
|
14
|
-
var
|
|
13
|
+
var DEFAULT_CORS_ALLOW_HEADERS2 = "Content-Type, Authorization, X-Trace-Id, traceparent, tracestate";
|
|
14
|
+
var DEFAULT_CORS_EXPOSE_HEADERS2 = "Content-Disposition, Content-Length, Content-Range, Accept-Ranges, ETag, Last-Modified, X-Request-Id, X-Build-Id";
|
|
15
15
|
function assertCorsConfig(config) {
|
|
16
16
|
if (config.credentials && (config.origin === undefined || config.origin === "*")) {
|
|
17
17
|
throw new Error("[stitchkit] cors: `credentials: true` cannot be combined with a wildcard origin. " + "Set `origin` to an explicit string or list.");
|
|
@@ -46,13 +46,13 @@ function isOriginAllowed(config, requestOrigin) {
|
|
|
46
46
|
const allowed = Array.isArray(config.origin) ? config.origin : [config.origin];
|
|
47
47
|
return allowed.some((origin) => origin.toLowerCase() === lower);
|
|
48
48
|
}
|
|
49
|
-
function
|
|
49
|
+
function corsHeaders2(config, requestOrigin) {
|
|
50
50
|
const allowOrigin = resolveOrigin(config, requestOrigin);
|
|
51
51
|
const headers = {
|
|
52
52
|
"Access-Control-Allow-Methods": config.methods ?? "GET, HEAD, POST, PUT, PATCH, DELETE, OPTIONS",
|
|
53
|
-
"Access-Control-Allow-Headers": config.headers ??
|
|
53
|
+
"Access-Control-Allow-Headers": config.headers ?? DEFAULT_CORS_ALLOW_HEADERS2
|
|
54
54
|
};
|
|
55
|
-
const expose = Array.isArray(config.exposeHeaders) ? config.exposeHeaders.join(", ") : config.exposeHeaders ??
|
|
55
|
+
const expose = Array.isArray(config.exposeHeaders) ? config.exposeHeaders.join(", ") : config.exposeHeaders ?? DEFAULT_CORS_EXPOSE_HEADERS2;
|
|
56
56
|
if (expose !== "") {
|
|
57
57
|
headers["Access-Control-Expose-Headers"] = expose;
|
|
58
58
|
}
|
|
@@ -67,16 +67,16 @@ function corsHeaders(config, requestOrigin) {
|
|
|
67
67
|
}
|
|
68
68
|
return headers;
|
|
69
69
|
}
|
|
70
|
-
function
|
|
70
|
+
function corsPreflightResponse2(config, req) {
|
|
71
71
|
return new Response(null, {
|
|
72
72
|
status: 204,
|
|
73
|
-
headers:
|
|
73
|
+
headers: corsHeaders2(config, req.headers.get("origin"))
|
|
74
74
|
});
|
|
75
75
|
}
|
|
76
76
|
function requestCorsHeaders(cors, req) {
|
|
77
77
|
if (!cors)
|
|
78
78
|
return {};
|
|
79
|
-
return
|
|
79
|
+
return corsHeaders2(cors, req.headers.get("origin"));
|
|
80
80
|
}
|
|
81
81
|
function applyCors(res, cors, req) {
|
|
82
82
|
const extra = requestCorsHeaders(cors, req);
|
|
@@ -116,7 +116,7 @@ function setCorsHeader(headers, key, value) {
|
|
|
116
116
|
function isStreamingImplementation(value) {
|
|
117
117
|
return typeof value === "object" && value !== null && "kind" in value && value.kind === "stitchkit.multipart.stream";
|
|
118
118
|
}
|
|
119
|
-
function
|
|
119
|
+
function defineMultipartStream2(endpoint, config) {
|
|
120
120
|
return buildMultipartStream(endpoint, config.files, config.handler);
|
|
121
121
|
}
|
|
122
122
|
function buildMultipartStream(endpoint, files, handler) {
|
|
@@ -137,7 +137,7 @@ function buildMultipartStream(endpoint, files, handler) {
|
|
|
137
137
|
}
|
|
138
138
|
};
|
|
139
139
|
}
|
|
140
|
-
function
|
|
140
|
+
function createMultipartStream2() {
|
|
141
141
|
return (endpoint, config) => buildMultipartStream(endpoint, config.files, config.handler);
|
|
142
142
|
}
|
|
143
143
|
function isStreamingEndpoint(endpoint) {
|
|
@@ -171,7 +171,7 @@ function contractOnlyService(contract) {
|
|
|
171
171
|
}
|
|
172
172
|
function stubHandler(label) {
|
|
173
173
|
return () => {
|
|
174
|
-
throw new
|
|
174
|
+
throw new AppError2("NOT_IMPLEMENTED", `[stitchkit] ${label} is declared by its contract and has no handler`, 501);
|
|
175
175
|
};
|
|
176
176
|
}
|
|
177
177
|
function bindContract(contract, handlers, options) {
|
|
@@ -211,13 +211,13 @@ function bindContract(contract, handlers, options) {
|
|
|
211
211
|
methods
|
|
212
212
|
};
|
|
213
213
|
}
|
|
214
|
-
function
|
|
214
|
+
function implement2(contract, handlers, options) {
|
|
215
215
|
return bindContract(contract, handlers, options);
|
|
216
216
|
}
|
|
217
|
-
function
|
|
218
|
-
return (contract, handlers, options) =>
|
|
217
|
+
function createImplement2() {
|
|
218
|
+
return (contract, handlers, options) => implement2(contract, handlers, options);
|
|
219
219
|
}
|
|
220
|
-
function
|
|
220
|
+
function createScopedImplement2() {
|
|
221
221
|
const implementScoped = (contract, handlers, options) => bindContract(contract, handlers, options);
|
|
222
222
|
const stream = (scope, endpoint, config) => {
|
|
223
223
|
if (endpoint.scope !== undefined && endpoint.scope !== scope) {
|
|
@@ -263,4 +263,4 @@ function mediaTypeEssence(contentType) {
|
|
|
263
263
|
return (contentType ?? "").split(";", 1)[0]?.trim().toLowerCase() ?? "";
|
|
264
264
|
}
|
|
265
265
|
|
|
266
|
-
export {
|
|
266
|
+
export { DEFAULT_CORS_ALLOW_HEADERS2, DEFAULT_CORS_EXPOSE_HEADERS2, assertCorsConfig, isOriginAllowed, corsHeaders2, corsPreflightResponse2, requestCorsHeaders, applyCors, defineMultipartStream2, createMultipartStream2, contractOnlyService, bindContract, implement2, createImplement2, createScopedImplement2, DEFAULT_PROCESS_SIGNALS, defaultSignalSource, reportSignalError, guardSignalCallback, mediaTypeEssence };
|
|
@@ -1,45 +1,45 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
} from "./index-
|
|
2
|
+
AppError2,
|
|
3
|
+
STITCH_ERROR_STATUS2
|
|
4
|
+
} from "./index-n53mswt3.js";
|
|
5
5
|
|
|
6
6
|
// src/agent-runtime/sandbox.ts
|
|
7
7
|
import { z } from "zod";
|
|
8
|
-
var
|
|
8
|
+
var AgentSandboxRestrictionSchema2 = z.enum([
|
|
9
9
|
"network-denied",
|
|
10
10
|
"write-contained",
|
|
11
11
|
"secrets-hidden",
|
|
12
12
|
"process-contained"
|
|
13
13
|
]);
|
|
14
|
-
var
|
|
15
|
-
z.object({ grade: z.literal("full"), restrictions: z.array(
|
|
14
|
+
var AgentSandboxGradeSchema2 = z.discriminatedUnion("grade", [
|
|
15
|
+
z.object({ grade: z.literal("full"), restrictions: z.array(AgentSandboxRestrictionSchema2) }).strict(),
|
|
16
16
|
z.object({
|
|
17
17
|
grade: z.literal("partial"),
|
|
18
|
-
restrictions: z.array(
|
|
19
|
-
gaps: z.array(
|
|
18
|
+
restrictions: z.array(AgentSandboxRestrictionSchema2),
|
|
19
|
+
gaps: z.array(AgentSandboxRestrictionSchema2)
|
|
20
20
|
}).strict(),
|
|
21
21
|
z.object({ grade: z.literal("unavailable"), reason: z.string().min(1) }).strict()
|
|
22
22
|
]);
|
|
23
23
|
var probes = new WeakMap;
|
|
24
|
-
function
|
|
24
|
+
function probeAgentProcessSandbox2(sandbox, options = {}) {
|
|
25
25
|
if (options.refresh)
|
|
26
26
|
probes.delete(sandbox);
|
|
27
27
|
const present = probes.get(sandbox);
|
|
28
28
|
if (present)
|
|
29
29
|
return present;
|
|
30
|
-
const pending = Promise.resolve(sandbox.probe()).then((grade) =>
|
|
30
|
+
const pending = Promise.resolve(sandbox.probe()).then((grade) => AgentSandboxGradeSchema2.parse(grade));
|
|
31
31
|
probes.set(sandbox, pending);
|
|
32
32
|
return pending;
|
|
33
33
|
}
|
|
34
|
-
function
|
|
34
|
+
function missingSandboxRestrictions2(grade, required) {
|
|
35
35
|
if (grade.grade === "unavailable")
|
|
36
36
|
return required;
|
|
37
37
|
const present = new Set(grade.restrictions);
|
|
38
38
|
return required.filter((restriction) => !present.has(restriction));
|
|
39
39
|
}
|
|
40
|
-
async function
|
|
41
|
-
const grade = await
|
|
42
|
-
const missing =
|
|
40
|
+
async function recordAgentSandboxProbe2(input) {
|
|
41
|
+
const grade = await probeAgentProcessSandbox2(input.sandbox);
|
|
42
|
+
const missing = missingSandboxRestrictions2(grade, input.required);
|
|
43
43
|
await input.store.appendEvent({
|
|
44
44
|
conversationId: input.conversationId,
|
|
45
45
|
kind: "sandbox/probed",
|
|
@@ -54,7 +54,7 @@ async function recordAgentSandboxProbe(input) {
|
|
|
54
54
|
|
|
55
55
|
// src/agent-runtime/coding-tool-refusals.ts
|
|
56
56
|
function codingRefusal(code, message, options = {}) {
|
|
57
|
-
throw new
|
|
57
|
+
throw new AppError2(code, message, STITCH_ERROR_STATUS2[code], { message, ...options.details }, options.hint);
|
|
58
58
|
}
|
|
59
59
|
function codingPathRefusal(code, message, path, options = {}) {
|
|
60
60
|
codingRefusal(code, message, {
|
|
@@ -98,4 +98,4 @@ function refuseUnknownSpillReference(reference) {
|
|
|
98
98
|
});
|
|
99
99
|
}
|
|
100
100
|
|
|
101
|
-
export {
|
|
101
|
+
export { AgentSandboxRestrictionSchema2, AgentSandboxGradeSchema2, probeAgentProcessSandbox2, missingSandboxRestrictions2, recordAgentSandboxProbe2, codingRefusal, codingPathRefusal, refuseMissingCodingPath, refuseUnknownSpillReference };
|