stitchkit 0.100.1 → 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 +99 -0
- package/README.md +2 -1
- package/dist/application/process-lifecycle-transitions.d.ts +13 -2
- package/dist/application/process-lifecycle-transitions.d.ts.map +1 -1
- package/dist/application/process-lifecycle.d.ts +2 -1
- package/dist/application/process-lifecycle.d.ts.map +1 -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.d.ts +1 -1
- package/dist/entrypoints/application.d.ts.map +1 -1
- package/dist/entrypoints/application.js +218 -214
- 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/application.2.txt +26 -1
- package/llms/application.txt +18 -27
- 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 +755 -11
- package/llms.txt +11 -6
- 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,133 +1,127 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
EffectUnresolvedError2,
|
|
3
|
+
createLocalStepDurability2,
|
|
4
|
+
AgentToolError2,
|
|
5
|
+
isAgentToolError2
|
|
6
|
+
} from "../index-a9pd417t.js";
|
|
4
7
|
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
} from "../index-
|
|
8
|
-
import"../index-hr4tzbwq.js";
|
|
8
|
+
AppError2,
|
|
9
|
+
STITCH_ERROR_STATUS2
|
|
10
|
+
} from "../index-n53mswt3.js";
|
|
9
11
|
import {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
contractOnlyService,
|
|
13
|
-
defaultSignalSource,
|
|
14
|
-
guardSignalCallback,
|
|
15
|
-
mediaTypeEssence,
|
|
16
|
-
reportSignalError
|
|
17
|
-
} from "../index-2gxzjvyr.js";
|
|
18
|
-
import"../index-2bxbyab0.js";
|
|
12
|
+
normalizeError2
|
|
13
|
+
} from "../index-b2bz0kdm.js";
|
|
19
14
|
import {
|
|
20
|
-
|
|
21
|
-
} from "../index-
|
|
15
|
+
resolvePropagationContext2
|
|
16
|
+
} from "../index-hby4qhax.js";
|
|
22
17
|
import {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
mountAgent
|
|
26
|
-
} from "../index-sh3s86na.js";
|
|
18
|
+
coerceJsonArgs2
|
|
19
|
+
} from "../index-9pw0a51a.js";
|
|
27
20
|
import {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
createLocalStepDurability,
|
|
31
|
-
isAgentToolError
|
|
32
|
-
} from "../index-79z7m7dt.js";
|
|
33
|
-
import"../index-rxfy4cq7.js";
|
|
21
|
+
toJsonSchema
|
|
22
|
+
} from "../index-ct75c3at.js";
|
|
34
23
|
import {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
24
|
+
toolSurfaceOutputSchema,
|
|
25
|
+
staticInputRounds,
|
|
26
|
+
validateMcpRoundPolicy,
|
|
27
|
+
validateResolvedInputRounds,
|
|
28
|
+
assertToolName,
|
|
29
|
+
assertUniqueToolName,
|
|
30
|
+
PORTABLE_JSON_SCHEMA_FORMATS2,
|
|
31
|
+
findNonPortableFormats2,
|
|
32
|
+
flattenToolJsonSchema2,
|
|
33
|
+
presentationMetadata,
|
|
34
|
+
findUntypedProperties2,
|
|
35
|
+
prepareProjectedMcpTools
|
|
36
|
+
} from "../index-7z9ym7t8.js";
|
|
40
37
|
import {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
38
|
+
parseToolCallArguments,
|
|
39
|
+
toolResultFromError,
|
|
40
|
+
ToolExecutionControlError2,
|
|
41
|
+
isToolExecutionControlError2
|
|
42
|
+
} from "../index-dvwj1f43.js";
|
|
44
43
|
import {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
ViewFileInputSchema,
|
|
50
|
-
ViewFileOutputSchema,
|
|
51
|
-
createAsyncOperationSnapshotSchema
|
|
52
|
-
} from "../index-m9zn6cpq.js";
|
|
44
|
+
collectTools2,
|
|
45
|
+
createToolRunner,
|
|
46
|
+
formatToolError
|
|
47
|
+
} from "../index-n9tyz8z3.js";
|
|
53
48
|
import {
|
|
54
|
-
|
|
55
|
-
|
|
49
|
+
mountAgent2,
|
|
50
|
+
describeToolCatalog2,
|
|
51
|
+
buildToolManifest2
|
|
52
|
+
} from "../index-xkhk5d6g.js";
|
|
53
|
+
import"../index-m38ej7e5.js";
|
|
56
54
|
import {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
runWaitOperation
|
|
63
|
-
} from "../index-r066jx76.js";
|
|
64
|
-
import"../index-sbdmyz75.js";
|
|
55
|
+
ALL_TRANSPORTS2,
|
|
56
|
+
TOOL_TRANSPORTS2,
|
|
57
|
+
defineContract2
|
|
58
|
+
} from "../index-ck71tbcf.js";
|
|
59
|
+
import"../index-1bx1xv1k.js";
|
|
65
60
|
import {
|
|
66
|
-
|
|
67
|
-
} from "../index-
|
|
61
|
+
redact2
|
|
62
|
+
} from "../index-kzz6rq0w.js";
|
|
68
63
|
import {
|
|
69
|
-
|
|
70
|
-
|
|
64
|
+
AsyncOperationCancelResultSchema2,
|
|
65
|
+
createAsyncOperationSnapshotSchema2,
|
|
66
|
+
McpAnnotationsSchema2,
|
|
67
|
+
McpMediaContentSchema2,
|
|
68
|
+
ViewFileErrorSchema2,
|
|
69
|
+
ViewFileOutputSchema2,
|
|
70
|
+
ViewFileInputSchema2
|
|
71
|
+
} from "../index-5107q189.js";
|
|
71
72
|
import {
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
73
|
+
fetchGuarded,
|
|
74
|
+
fetchPinnedDocument,
|
|
75
|
+
readCapped,
|
|
76
|
+
WaitTimeoutError,
|
|
77
|
+
runWaitOperation,
|
|
78
|
+
createCli2
|
|
79
|
+
} from "../index-c6aagrbd.js";
|
|
76
80
|
import {
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
toolResultFromError
|
|
81
|
-
} from "../index-8qt2m66q.js";
|
|
81
|
+
ManagedFilePathSchema2,
|
|
82
|
+
ManagedFileRefSchema2
|
|
83
|
+
} from "../index-xqhede6x.js";
|
|
82
84
|
import {
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
runWithRequestContext
|
|
86
|
-
} from "../index-zfrhfn82.js";
|
|
87
|
-
import"../index-35mh5bhj.js";
|
|
85
|
+
ManagedFileError2
|
|
86
|
+
} from "../index-v4a2fjtk.js";
|
|
88
87
|
import {
|
|
89
|
-
|
|
90
|
-
|
|
88
|
+
signJwt2,
|
|
89
|
+
verifyPkce2
|
|
90
|
+
} from "../index-45tdvqa3.js";
|
|
91
91
|
import {
|
|
92
|
-
|
|
93
|
-
|
|
92
|
+
DEFAULT_CORS_ALLOW_HEADERS2,
|
|
93
|
+
contractOnlyService,
|
|
94
|
+
DEFAULT_PROCESS_SIGNALS,
|
|
95
|
+
defaultSignalSource,
|
|
96
|
+
reportSignalError,
|
|
97
|
+
guardSignalCallback,
|
|
98
|
+
mediaTypeEssence
|
|
99
|
+
} from "../index-afjvjyck.js";
|
|
94
100
|
import {
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
} from "../index-d8m8zpd8.js";
|
|
101
|
+
collectToolSurface
|
|
102
|
+
} from "../index-ewbaywk5.js";
|
|
98
103
|
import {
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
assertUniqueToolName,
|
|
102
|
-
findNonPortableFormats,
|
|
103
|
-
findUntypedProperties,
|
|
104
|
-
flattenToolJsonSchema,
|
|
105
|
-
prepareProjectedMcpTools,
|
|
106
|
-
presentationMetadata,
|
|
107
|
-
staticInputRounds,
|
|
108
|
-
toolSurfaceOutputSchema,
|
|
109
|
-
validateMcpRoundPolicy,
|
|
110
|
-
validateResolvedInputRounds
|
|
111
|
-
} from "../index-0r0fbk7z.js";
|
|
104
|
+
argumentsDigest
|
|
105
|
+
} from "../index-r7a7r7ha.js";
|
|
112
106
|
import {
|
|
113
|
-
|
|
114
|
-
} from "../index-
|
|
107
|
+
createToolInvoker2
|
|
108
|
+
} from "../index-m9fndta6.js";
|
|
115
109
|
import {
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
110
|
+
runWithRequestContext2,
|
|
111
|
+
getRequestContext2,
|
|
112
|
+
getTraceId2
|
|
113
|
+
} from "../index-r1z0rd9c.js";
|
|
119
114
|
import {
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
} from "../index-
|
|
115
|
+
defineRuntimeTool2,
|
|
116
|
+
createRuntimeToolFactory2
|
|
117
|
+
} from "../index-jzczzcsb.js";
|
|
123
118
|
import {
|
|
124
119
|
compareCodeUnits,
|
|
125
120
|
serializeCanonicalJson
|
|
126
|
-
} from "../index-
|
|
127
|
-
import"../index-kzfs85xp.js";
|
|
121
|
+
} from "../index-zsvzhjtk.js";
|
|
128
122
|
import {
|
|
129
123
|
isRecord
|
|
130
|
-
} from "../index-
|
|
124
|
+
} from "../index-9jfdm5tg.js";
|
|
131
125
|
// src/server/oauth/cimd.ts
|
|
132
126
|
import { z } from "zod";
|
|
133
127
|
function isPlainDisplayCharacter(character) {
|
|
@@ -454,7 +448,7 @@ function wwwAuthenticateHeader(resource) {
|
|
|
454
448
|
var PUBLIC_CORS = {
|
|
455
449
|
"Access-Control-Allow-Origin": "*",
|
|
456
450
|
"Access-Control-Allow-Methods": "GET, OPTIONS",
|
|
457
|
-
"Access-Control-Allow-Headers":
|
|
451
|
+
"Access-Control-Allow-Headers": DEFAULT_CORS_ALLOW_HEADERS2
|
|
458
452
|
};
|
|
459
453
|
function oauthProtectedResourceRoute(config) {
|
|
460
454
|
const body = JSON.stringify({
|
|
@@ -483,7 +477,7 @@ import { randomUUID } from "node:crypto";
|
|
|
483
477
|
var PUBLIC_CORS2 = {
|
|
484
478
|
"Access-Control-Allow-Origin": "*",
|
|
485
479
|
"Access-Control-Allow-Methods": "GET, POST, OPTIONS",
|
|
486
|
-
"Access-Control-Allow-Headers":
|
|
480
|
+
"Access-Control-Allow-Headers": DEFAULT_CORS_ALLOW_HEADERS2
|
|
487
481
|
};
|
|
488
482
|
var AS_METADATA_PATH = "/.well-known/oauth-authorization-server";
|
|
489
483
|
var AUTH_CODE_TTL_MS = 60000;
|
|
@@ -657,7 +651,7 @@ function authorizeRoute(ctx) {
|
|
|
657
651
|
}
|
|
658
652
|
const requestedScopes = parseScopes(scope);
|
|
659
653
|
const supportedScopes = new Set(config.scopesSupported ?? []);
|
|
660
|
-
if (config.scopesSupported && requestedScopes.some((
|
|
654
|
+
if (config.scopesSupported && requestedScopes.some((requestedScope) => !supportedScopes.has(requestedScope))) {
|
|
661
655
|
return ctx.redirectToClient(redirectUri, {
|
|
662
656
|
error: "invalid_scope",
|
|
663
657
|
error_description: "One or more requested scopes are not supported",
|
|
@@ -685,11 +679,11 @@ function authorizeRoute(ctx) {
|
|
|
685
679
|
const result = await config.authorizeUser(req, authRequest);
|
|
686
680
|
if (result instanceof Response)
|
|
687
681
|
return result;
|
|
688
|
-
if (!Array.isArray(result.approvedScopes) || !result.approvedScopes.every((
|
|
682
|
+
if (!Array.isArray(result.approvedScopes) || !result.approvedScopes.every((scope) => typeof scope === "string")) {
|
|
689
683
|
throw new Error("authorizeUser must return approvedScopes as an array of strings");
|
|
690
684
|
}
|
|
691
685
|
const approvedScopes = [...new Set(result.approvedScopes)];
|
|
692
|
-
if (approvedScopes.some((
|
|
686
|
+
if (approvedScopes.some((approvedScope) => !requestedScopes.includes(approvedScope) || config.scopesSupported !== undefined && !supportedScopes.has(approvedScope))) {
|
|
693
687
|
throw new Error("authorizeUser approvedScopes must be a subset of requested scopes");
|
|
694
688
|
}
|
|
695
689
|
const approvedScope = approvedScopes.length > 0 ? approvedScopes.join(" ") : undefined;
|
|
@@ -737,7 +731,7 @@ function tokenRoute(ctx) {
|
|
|
737
731
|
return oauthError("invalid_grant", "client_id mismatch");
|
|
738
732
|
if (data.redirectUri !== redirectUri)
|
|
739
733
|
return oauthError("invalid_grant", "redirect_uri mismatch");
|
|
740
|
-
if (!await
|
|
734
|
+
if (!await verifyPkce2(verifier, data.codeChallenge)) {
|
|
741
735
|
return oauthError("invalid_grant", "PKCE verification failed");
|
|
742
736
|
}
|
|
743
737
|
const accessToken = await ctx.issueAccessToken(data.userId, data.resource, data.clientId, data.scope);
|
|
@@ -823,7 +817,7 @@ function mountOAuthProvider(config) {
|
|
|
823
817
|
return dcrClient?.clientId === clientId ? dcrClient : null;
|
|
824
818
|
};
|
|
825
819
|
const redirectToClient = (uri, params) => redirectWith(uri, { ...params, iss: config.issuer });
|
|
826
|
-
const issueAccessToken = (userId, audience, clientId, scope) =>
|
|
820
|
+
const issueAccessToken = (userId, audience, clientId, scope) => signJwt2({ scope, client_id: clientId }, config.signingSecret, {
|
|
827
821
|
issuer: config.issuer,
|
|
828
822
|
audience,
|
|
829
823
|
subject: userId,
|
|
@@ -862,7 +856,7 @@ function composeToolLifecycle(...hooks) {
|
|
|
862
856
|
// src/tools/list-names.ts
|
|
863
857
|
function listToolNames(surface) {
|
|
864
858
|
const entries = new Map;
|
|
865
|
-
for (const transport of
|
|
859
|
+
for (const transport of TOOL_TRANSPORTS2) {
|
|
866
860
|
for (const entry of collectToolSurface({
|
|
867
861
|
surface,
|
|
868
862
|
transport,
|
|
@@ -995,7 +989,7 @@ function formatMcpResult(result, mode, toolName, errorHint) {
|
|
|
995
989
|
serialized = undefined;
|
|
996
990
|
}
|
|
997
991
|
if (serialized === undefined) {
|
|
998
|
-
const safe =
|
|
992
|
+
const safe = redact2(result.data, { sensitiveKeys: /(?!)/ });
|
|
999
993
|
return { content: textBlock(JSON.stringify(safe, null, 2)), structuredContent: safe };
|
|
1000
994
|
}
|
|
1001
995
|
return { content: textBlock(serialized), structuredContent: result.data };
|
|
@@ -1007,7 +1001,7 @@ function formatMcpResult(result, mode, toolName, errorHint) {
|
|
|
1007
1001
|
}
|
|
1008
1002
|
function prepareMcpSurface(services, config = {}) {
|
|
1009
1003
|
const serviceList = Array.isArray(services) ? services : [services];
|
|
1010
|
-
const tools = serviceList.flatMap((service) =>
|
|
1004
|
+
const tools = serviceList.flatMap((service) => collectTools2(service, "MCP", config));
|
|
1011
1005
|
return prepareMcpTools(tools, config);
|
|
1012
1006
|
}
|
|
1013
1007
|
function prepareMcpTools(tools, config = {}) {
|
|
@@ -1177,7 +1171,7 @@ async function runRoundFailure(tool, rawArgs, runTool, context, code, message) {
|
|
|
1177
1171
|
...tool.method,
|
|
1178
1172
|
outputSchema: undefined,
|
|
1179
1173
|
handler: () => {
|
|
1180
|
-
throw new
|
|
1174
|
+
throw new AppError2(code, message, 400);
|
|
1181
1175
|
}
|
|
1182
1176
|
}
|
|
1183
1177
|
}, rawArgs, context);
|
|
@@ -1322,10 +1316,10 @@ async function resolveMcpRound(options) {
|
|
|
1322
1316
|
return { kind: "response", response: options.formatFailure(guarded) };
|
|
1323
1317
|
}
|
|
1324
1318
|
}
|
|
1325
|
-
const
|
|
1326
|
-
if (!
|
|
1319
|
+
const request = requests[0];
|
|
1320
|
+
if (!request)
|
|
1327
1321
|
throw new Error("[stitchkit] validated MRTR policy has no first round");
|
|
1328
|
-
return askRound(options.runtime, options.context,
|
|
1322
|
+
return askRound(options.runtime, options.context, request, {
|
|
1329
1323
|
identity: operationIdentity(options.tool),
|
|
1330
1324
|
argumentsDigest: digest,
|
|
1331
1325
|
round: 0,
|
|
@@ -1388,7 +1382,7 @@ import {
|
|
|
1388
1382
|
TRACESTATE_META_KEY
|
|
1389
1383
|
} from "@modelcontextprotocol/server";
|
|
1390
1384
|
function runInMcpRequestContext(context, toolName, body) {
|
|
1391
|
-
const ambient =
|
|
1385
|
+
const ambient = getRequestContext2();
|
|
1392
1386
|
const metadata = context.mcpReq._meta;
|
|
1393
1387
|
const propagation = metadata ? {
|
|
1394
1388
|
traceparent: metadata[TRACEPARENT_META_KEY],
|
|
@@ -1402,7 +1396,7 @@ function runInMcpRequestContext(context, toolName, body) {
|
|
|
1402
1396
|
path: `/mcp/${toolName}`,
|
|
1403
1397
|
startedAt: process.hrtime.bigint()
|
|
1404
1398
|
},
|
|
1405
|
-
trace:
|
|
1399
|
+
trace: resolvePropagationContext2(propagation, ambient?.trace),
|
|
1406
1400
|
source: "mcp",
|
|
1407
1401
|
method: "MCP",
|
|
1408
1402
|
path: `/mcp/${toolName}`,
|
|
@@ -1410,7 +1404,7 @@ function runInMcpRequestContext(context, toolName, body) {
|
|
|
1410
1404
|
dimensions: ambient?.dimensions ? { ...ambient.dimensions } : undefined,
|
|
1411
1405
|
error: undefined
|
|
1412
1406
|
};
|
|
1413
|
-
return
|
|
1407
|
+
return runWithRequestContext2(request, body);
|
|
1414
1408
|
}
|
|
1415
1409
|
|
|
1416
1410
|
// src/tools/mcp/register.ts
|
|
@@ -1442,28 +1436,28 @@ function registerMcpTool(server, presentation, descriptor, config) {
|
|
|
1442
1436
|
policy: mountable.method.mcp,
|
|
1443
1437
|
runtime: config.multiRoundRuntime,
|
|
1444
1438
|
runTool: config.runTool,
|
|
1445
|
-
formatFailure: (
|
|
1439
|
+
formatFailure: (result) => format(result, "none", name)
|
|
1446
1440
|
});
|
|
1447
1441
|
if (round.kind === "response")
|
|
1448
1442
|
return round.response;
|
|
1449
1443
|
const { present } = presentation;
|
|
1450
1444
|
if (!present) {
|
|
1451
|
-
const
|
|
1452
|
-
return format(
|
|
1445
|
+
const result = await config.runTool(mountable, args, round.context);
|
|
1446
|
+
return format(result, descriptor.outputMode, name);
|
|
1453
1447
|
}
|
|
1454
1448
|
const result = await config.runTool(mountable, args, round.context, {
|
|
1455
1449
|
finalizeOutput: async (data) => {
|
|
1456
1450
|
const presented = await present(data);
|
|
1457
1451
|
if (!isRecord(presented)) {
|
|
1458
|
-
throw new
|
|
1452
|
+
throw new AppError2("INTERNAL_SERVER_ERROR", "Runtime MCP presenter did not return a result", 500);
|
|
1459
1453
|
}
|
|
1460
1454
|
if ("structuredContent" in presented || "isError" in presented) {
|
|
1461
|
-
throw new
|
|
1455
|
+
throw new AppError2("INTERNAL_SERVER_ERROR", "Runtime MCP presenter cannot set framework-owned structuredContent or isError", 500);
|
|
1462
1456
|
}
|
|
1463
1457
|
const structured = format({ ok: true, data }, descriptor.outputMode, name).structuredContent;
|
|
1464
1458
|
const response = structured === undefined ? presented : { ...presented, structuredContent: structured };
|
|
1465
1459
|
if (!isCallToolResult(response)) {
|
|
1466
|
-
throw new
|
|
1460
|
+
throw new AppError2("INTERNAL_SERVER_ERROR", "Runtime MCP presenter returned an invalid CallToolResult", 500);
|
|
1467
1461
|
}
|
|
1468
1462
|
return response;
|
|
1469
1463
|
}
|
|
@@ -2091,16 +2085,16 @@ function buildCanonicalEndpointTable(config, startOutput) {
|
|
|
2091
2085
|
startOutput,
|
|
2092
2086
|
id: config.id,
|
|
2093
2087
|
snapshot: config.snapshot,
|
|
2094
|
-
cancelResult:
|
|
2088
|
+
cancelResult: AsyncOperationCancelResultSchema2
|
|
2095
2089
|
};
|
|
2096
2090
|
const inputFor = {
|
|
2097
2091
|
status: (id) => adapterResult("status", "input", config.id, id),
|
|
2098
2092
|
wait: (id) => adapterResult("wait", "input", config.id, id)
|
|
2099
2093
|
};
|
|
2100
2094
|
if (config.cancel) {
|
|
2101
|
-
endpoints.cancel = endpoint("cancel", "POST", "/cancel", config.id,
|
|
2095
|
+
endpoints.cancel = endpoint("cancel", "POST", "/cancel", config.id, AsyncOperationCancelResultSchema2);
|
|
2102
2096
|
capabilities.cancel = "cancel";
|
|
2103
|
-
schemas.cancel =
|
|
2097
|
+
schemas.cancel = AsyncOperationCancelResultSchema2;
|
|
2104
2098
|
inputFor.cancel = (id) => adapterResult("cancel", "input", config.id, id);
|
|
2105
2099
|
}
|
|
2106
2100
|
if (config.result) {
|
|
@@ -2126,7 +2120,7 @@ function defineAsyncOperationContract(config) {
|
|
|
2126
2120
|
}
|
|
2127
2121
|
const startOutput = config.startOutput ?? config.id;
|
|
2128
2122
|
const { endpoints, capabilities, schemas, inputFor } = buildCanonicalEndpointTable(config, startOutput);
|
|
2129
|
-
const contract = config.scope ?
|
|
2123
|
+
const contract = config.scope ? defineContract2({ prefix: config.prefix, scope: config.scope }, endpoints) : defineContract2({ prefix: config.prefix }, endpoints);
|
|
2130
2124
|
const applicationStartOutput = config.startOutput;
|
|
2131
2125
|
const applicationIdFromStart = config.idFromStart;
|
|
2132
2126
|
const idFromStart = applicationStartOutput && applicationIdFromStart ? (output) => adapterResult("start", "id", config.id, applicationIdFromStart(output)) : (output) => adapterResult("start", "id", config.id, output);
|
|
@@ -2158,7 +2152,7 @@ function defineWaitTool(config) {
|
|
|
2158
2152
|
}
|
|
2159
2153
|
} : undefined;
|
|
2160
2154
|
const present = renderedMcp || config.present ? { ...renderedMcp, ...config.present } : undefined;
|
|
2161
|
-
return
|
|
2155
|
+
return defineRuntimeTool2({
|
|
2162
2156
|
name: config.name ?? "wait",
|
|
2163
2157
|
description: config.description,
|
|
2164
2158
|
identity: managedNativeIdentity(config.identity, "GET"),
|
|
@@ -2180,16 +2174,16 @@ function defineWaitTool(config) {
|
|
|
2180
2174
|
});
|
|
2181
2175
|
} catch (error) {
|
|
2182
2176
|
if (error instanceof WaitTimeoutError) {
|
|
2183
|
-
throw new
|
|
2177
|
+
throw new AppError2("WAIT_TIMEOUT", "Wait timed out before the first snapshot", 408);
|
|
2184
2178
|
}
|
|
2185
2179
|
throw error;
|
|
2186
2180
|
}
|
|
2187
2181
|
const rendered = config.render?.(result.state, result.timedOut);
|
|
2188
2182
|
if (result.timedOut) {
|
|
2189
|
-
throw new
|
|
2183
|
+
throw new AppError2("WAIT_TIMEOUT", rendered?.text ?? "Wait timed out before the operation completed", 408);
|
|
2190
2184
|
}
|
|
2191
2185
|
if (rendered?.isError) {
|
|
2192
|
-
throw new
|
|
2186
|
+
throw new AppError2("WAIT_FAILED", rendered.text, 409);
|
|
2193
2187
|
}
|
|
2194
2188
|
return result.state;
|
|
2195
2189
|
}
|
|
@@ -2234,7 +2228,7 @@ function createRuntimeOperationSurface(config) {
|
|
|
2234
2228
|
}
|
|
2235
2229
|
function defineObservationTools(surface) {
|
|
2236
2230
|
const { config } = surface;
|
|
2237
|
-
const status =
|
|
2231
|
+
const status = defineRuntimeTool2({
|
|
2238
2232
|
...surface.common("status"),
|
|
2239
2233
|
identity: surface.identity("status", "GET"),
|
|
2240
2234
|
input: config.id,
|
|
@@ -2255,11 +2249,11 @@ function defineObservationTools(surface) {
|
|
|
2255
2249
|
return { status, wait };
|
|
2256
2250
|
}
|
|
2257
2251
|
function defineCancelTool(surface, capability) {
|
|
2258
|
-
return
|
|
2252
|
+
return defineRuntimeTool2({
|
|
2259
2253
|
...surface.common("cancel"),
|
|
2260
2254
|
identity: surface.identity("cancel", "DELETE"),
|
|
2261
2255
|
input: surface.config.id,
|
|
2262
|
-
output:
|
|
2256
|
+
output: AsyncOperationCancelResultSchema2,
|
|
2263
2257
|
handler: async (context) => {
|
|
2264
2258
|
const inspected = await surface.inspect("cancel", context);
|
|
2265
2259
|
return capability.handler(inspected.state, context);
|
|
@@ -2267,7 +2261,7 @@ function defineCancelTool(surface, capability) {
|
|
|
2267
2261
|
});
|
|
2268
2262
|
}
|
|
2269
2263
|
function defineSucceededOutputTool(surface, kind, capability, unavailableMessage) {
|
|
2270
|
-
return
|
|
2264
|
+
return defineRuntimeTool2({
|
|
2271
2265
|
...surface.common(kind),
|
|
2272
2266
|
identity: surface.identity(kind, "GET"),
|
|
2273
2267
|
input: surface.config.id,
|
|
@@ -2275,7 +2269,7 @@ function defineSucceededOutputTool(surface, kind, capability, unavailableMessage
|
|
|
2275
2269
|
handler: async (context) => {
|
|
2276
2270
|
const inspected = await surface.inspect(kind, context);
|
|
2277
2271
|
if (!succeeded(inspected.snapshot)) {
|
|
2278
|
-
throw new
|
|
2272
|
+
throw new AppError2("OPERATION_NOT_SUCCEEDED", unavailableMessage, 409);
|
|
2279
2273
|
}
|
|
2280
2274
|
return capability.handler(inspected.state, context);
|
|
2281
2275
|
}
|
|
@@ -2285,7 +2279,7 @@ function defineSucceededOutputTool(surface, kind, capability, unavailableMessage
|
|
|
2285
2279
|
// src/tools/operations/async-operation-runtime.ts
|
|
2286
2280
|
function defineAsyncOperation(config) {
|
|
2287
2281
|
const surface = createRuntimeOperationSurface(config);
|
|
2288
|
-
const start =
|
|
2282
|
+
const start = defineRuntimeTool2({
|
|
2289
2283
|
...surface.common("start"),
|
|
2290
2284
|
identity: surface.identity("start", "POST"),
|
|
2291
2285
|
input: config.startInput,
|
|
@@ -2314,7 +2308,7 @@ function defineAsyncOperation(config) {
|
|
|
2314
2308
|
schemas: {
|
|
2315
2309
|
id: config.id,
|
|
2316
2310
|
snapshot: config.snapshot,
|
|
2317
|
-
cancelResult:
|
|
2311
|
+
cancelResult: AsyncOperationCancelResultSchema2
|
|
2318
2312
|
}
|
|
2319
2313
|
};
|
|
2320
2314
|
}
|
|
@@ -2431,7 +2425,7 @@ function createToolLogger(config = {}) {
|
|
|
2431
2425
|
code: result.ok ? undefined : result.code,
|
|
2432
2426
|
durationMs: Math.round(durationMs),
|
|
2433
2427
|
source: String(context.source),
|
|
2434
|
-
traceId:
|
|
2428
|
+
traceId: getTraceId2()
|
|
2435
2429
|
};
|
|
2436
2430
|
const codePart = result.ok ? "" : ` ${result.code}`;
|
|
2437
2431
|
log(`[tool] ${result.ok ? "ok" : "warn"} ${toolName} (${endpoint.serviceName}.${endpoint.key})${codePart} ${record.durationMs}ms`);
|
|
@@ -2443,11 +2437,11 @@ function createToolLogger(config = {}) {
|
|
|
2443
2437
|
function createToolkit() {
|
|
2444
2438
|
return {
|
|
2445
2439
|
mountMcp: (server, services, config) => mountMcp(server, services, config),
|
|
2446
|
-
mountAgent: (services, config) =>
|
|
2440
|
+
mountAgent: (services, config) => mountAgent2(services, config),
|
|
2447
2441
|
buildMcpServer: (config, auth) => buildMcpServer(config, auth),
|
|
2448
2442
|
createMcpHandler: (config) => createMcpHandler(config),
|
|
2449
2443
|
createStdioMcpServer: (config) => createStdioMcpServer(config),
|
|
2450
|
-
createCli: (config) =>
|
|
2444
|
+
createCli: (config) => createCli2(config)
|
|
2451
2445
|
};
|
|
2452
2446
|
}
|
|
2453
2447
|
// src/tools/transfer/download-core.ts
|
|
@@ -2527,7 +2521,7 @@ var SAFE_MANAGED_FILE_MESSAGES = {
|
|
|
2527
2521
|
FILE_EXISTS: "Managed file already exists"
|
|
2528
2522
|
};
|
|
2529
2523
|
function managedFileAppError(error) {
|
|
2530
|
-
if (!(error instanceof
|
|
2524
|
+
if (!(error instanceof ManagedFileError2))
|
|
2531
2525
|
return null;
|
|
2532
2526
|
switch (error.code) {
|
|
2533
2527
|
case "FILE_INVALID_PATH":
|
|
@@ -2537,30 +2531,30 @@ function managedFileAppError(error) {
|
|
|
2537
2531
|
case "FILE_INSPECTION_REJECTED":
|
|
2538
2532
|
case "FILE_TOO_LARGE":
|
|
2539
2533
|
case "FILE_EXISTS":
|
|
2540
|
-
return new
|
|
2534
|
+
return new AppError2(error.code, SAFE_MANAGED_FILE_MESSAGES[error.code], STITCH_ERROR_STATUS2[error.code]);
|
|
2541
2535
|
case "FILE_IO_ERROR":
|
|
2542
2536
|
return null;
|
|
2543
2537
|
}
|
|
2544
2538
|
}
|
|
2545
2539
|
function normalizeFileToolError(error) {
|
|
2546
|
-
return managedFileAppError(error) ??
|
|
2540
|
+
return managedFileAppError(error) ?? normalizeError2(error);
|
|
2547
2541
|
}
|
|
2548
2542
|
|
|
2549
2543
|
// src/tools/transfer/define-download-tool.ts
|
|
2550
2544
|
function defineDownloadTool(config) {
|
|
2551
|
-
return
|
|
2545
|
+
return defineRuntimeTool2({
|
|
2552
2546
|
name: config.name ?? "download",
|
|
2553
2547
|
description: config.description,
|
|
2554
2548
|
identity: managedNativeIdentity(config.identity, "POST"),
|
|
2555
2549
|
input: config.input,
|
|
2556
|
-
output:
|
|
2550
|
+
output: ManagedFileRefSchema2,
|
|
2557
2551
|
transports: config.transports,
|
|
2558
2552
|
annotations: config.annotations,
|
|
2559
2553
|
present: config.present,
|
|
2560
2554
|
handler: async (context) => {
|
|
2561
2555
|
const url = await config.resolveUrl(context.input, context);
|
|
2562
2556
|
if (!url) {
|
|
2563
|
-
throw new
|
|
2557
|
+
throw new AppError2("DOWNLOAD_NOT_FOUND", "Nothing to download", 404);
|
|
2564
2558
|
}
|
|
2565
2559
|
try {
|
|
2566
2560
|
return await runDownloadOperation({
|
|
@@ -2574,7 +2568,7 @@ function defineDownloadTool(config) {
|
|
|
2574
2568
|
});
|
|
2575
2569
|
} catch (error) {
|
|
2576
2570
|
if (error instanceof DownloadOperationError) {
|
|
2577
|
-
throw new
|
|
2571
|
+
throw new AppError2(error.code, `Download failed: ${error.message}`, error.status);
|
|
2578
2572
|
}
|
|
2579
2573
|
const managedError = managedFileAppError(error);
|
|
2580
2574
|
if (managedError)
|
|
@@ -2595,10 +2589,10 @@ function runUploadOperation(files, path, upload, signal) {
|
|
|
2595
2589
|
|
|
2596
2590
|
// src/tools/transfer/define-upload-tool.ts
|
|
2597
2591
|
var UploadToolInputSchema = z6.object({
|
|
2598
|
-
path:
|
|
2592
|
+
path: ManagedFilePathSchema2.describe("Path relative to the configured file boundary")
|
|
2599
2593
|
});
|
|
2600
2594
|
function defineUploadTool(config) {
|
|
2601
|
-
return
|
|
2595
|
+
return defineRuntimeTool2({
|
|
2602
2596
|
name: config.name ?? "upload",
|
|
2603
2597
|
description: config.description,
|
|
2604
2598
|
identity: managedNativeIdentity(config.identity, "POST"),
|
|
@@ -2645,7 +2639,7 @@ async function fetchSource(pathOrUrl, options, maxBytes) {
|
|
|
2645
2639
|
signal: options.signal
|
|
2646
2640
|
});
|
|
2647
2641
|
if (!res.ok)
|
|
2648
|
-
throw new
|
|
2642
|
+
throw new AppError2("VIEW_HTTP_ERROR", `HTTP ${res.status}`, 502);
|
|
2649
2643
|
const headerMime = mediaTypeEssence(res.headers.get("content-type"));
|
|
2650
2644
|
const mimeType = headerMime || extMime || "application/octet-stream";
|
|
2651
2645
|
if (mimeType.startsWith("video/")) {
|
|
@@ -2661,11 +2655,11 @@ async function fetchSource(pathOrUrl, options, maxBytes) {
|
|
|
2661
2655
|
return buffer ? { buffer, mimeType, bytesRead: buffer.length } : { tooLarge: true, mimeType, bytesRead: maxBytes };
|
|
2662
2656
|
}
|
|
2663
2657
|
if (!options.files) {
|
|
2664
|
-
throw new
|
|
2658
|
+
throw new AppError2("FILE_INVALID_PATH", "local file paths are disabled — set files to allow them", 400);
|
|
2665
2659
|
}
|
|
2666
2660
|
options.signal?.throwIfAborted();
|
|
2667
2661
|
if (!extMime) {
|
|
2668
|
-
throw new
|
|
2662
|
+
throw new AppError2("FILE_INSPECTION_REJECTED", "refusing to read a non-media file", 422);
|
|
2669
2663
|
}
|
|
2670
2664
|
try {
|
|
2671
2665
|
const source = await options.files.read(pathOrUrl, {
|
|
@@ -2679,7 +2673,7 @@ async function fetchSource(pathOrUrl, options, maxBytes) {
|
|
|
2679
2673
|
bytesRead: buffer.length
|
|
2680
2674
|
};
|
|
2681
2675
|
} catch (error) {
|
|
2682
|
-
if (error instanceof
|
|
2676
|
+
if (error instanceof ManagedFileError2 && error.code === "FILE_TOO_LARGE") {
|
|
2683
2677
|
return { tooLarge: true, mimeType: extMime, bytesRead: maxBytes };
|
|
2684
2678
|
}
|
|
2685
2679
|
throw error;
|
|
@@ -2773,12 +2767,12 @@ async function runViewFileOperation(paths, options = {}, signal) {
|
|
|
2773
2767
|
content.push({ type: "text", text: `[${pathOrUrl}] Error: ${message}` });
|
|
2774
2768
|
}
|
|
2775
2769
|
}
|
|
2776
|
-
return
|
|
2770
|
+
return ViewFileOutputSchema2.parse({ content, errors });
|
|
2777
2771
|
}
|
|
2778
2772
|
function mountViewFile(server, options = {}) {
|
|
2779
2773
|
server.registerTool("view_file", {
|
|
2780
2774
|
description: "View media (image, audio, video) by URL or local path — returns it as content you can SEE / HEAR. Pass several paths to view multiple files at once. Use it on a generation `output` url to inspect the result.",
|
|
2781
|
-
inputSchema:
|
|
2775
|
+
inputSchema: ViewFileInputSchema2.shape,
|
|
2782
2776
|
annotations: { title: "View Media", readOnlyHint: true, idempotentHint: true }
|
|
2783
2777
|
}, async (args) => {
|
|
2784
2778
|
const result = await runViewFileOperation(args.paths, options);
|
|
@@ -2803,12 +2797,12 @@ function defineViewFileTool(config) {
|
|
|
2803
2797
|
})
|
|
2804
2798
|
})
|
|
2805
2799
|
};
|
|
2806
|
-
return
|
|
2800
|
+
return defineRuntimeTool2({
|
|
2807
2801
|
name: config.name ?? "view_file",
|
|
2808
2802
|
description: config.description,
|
|
2809
2803
|
identity: managedNativeIdentity(config.identity, "GET"),
|
|
2810
|
-
input:
|
|
2811
|
-
output:
|
|
2804
|
+
input: ViewFileInputSchema2,
|
|
2805
|
+
output: ViewFileOutputSchema2,
|
|
2812
2806
|
transports: config.transports,
|
|
2813
2807
|
annotations: config.annotations ?? {
|
|
2814
2808
|
title: "View Media",
|
|
@@ -2859,7 +2853,7 @@ function mountUpload(server, config) {
|
|
|
2859
2853
|
server.registerTool(name, {
|
|
2860
2854
|
description: config.description,
|
|
2861
2855
|
inputSchema: {
|
|
2862
|
-
path:
|
|
2856
|
+
path: ManagedFilePathSchema2.describe("Path relative to the configured file boundary")
|
|
2863
2857
|
}
|
|
2864
2858
|
}, async (rawArgs) => {
|
|
2865
2859
|
const args = isRecord(rawArgs) ? rawArgs : {};
|
|
@@ -2885,7 +2879,7 @@ function contractCounts(service) {
|
|
|
2885
2879
|
if (!method.expose || method.expose.includes("HTTP"))
|
|
2886
2880
|
counts.HTTP += 1;
|
|
2887
2881
|
}
|
|
2888
|
-
for (const transport of
|
|
2882
|
+
for (const transport of TOOL_TRANSPORTS2) {
|
|
2889
2883
|
counts[transport] = collectToolSurface({
|
|
2890
2884
|
surface: { services: [service] },
|
|
2891
2885
|
transport,
|
|
@@ -2897,7 +2891,7 @@ function contractCounts(service) {
|
|
|
2897
2891
|
}
|
|
2898
2892
|
function runtimeCounts(runtimeTools) {
|
|
2899
2893
|
const counts = emptyCounts();
|
|
2900
|
-
for (const transport of
|
|
2894
|
+
for (const transport of TOOL_TRANSPORTS2) {
|
|
2901
2895
|
counts[transport] = collectToolSurface({
|
|
2902
2896
|
surface: { runtimeTools },
|
|
2903
2897
|
transport,
|
|
@@ -2908,7 +2902,7 @@ function runtimeCounts(runtimeTools) {
|
|
|
2908
2902
|
return counts;
|
|
2909
2903
|
}
|
|
2910
2904
|
function addCounts(target, source) {
|
|
2911
|
-
for (const transport of
|
|
2905
|
+
for (const transport of ALL_TRANSPORTS2)
|
|
2912
2906
|
target[transport] += source[transport];
|
|
2913
2907
|
}
|
|
2914
2908
|
function summarizeTransports(surface) {
|
|
@@ -2941,69 +2935,69 @@ function summarizeTransports(surface) {
|
|
|
2941
2935
|
};
|
|
2942
2936
|
}
|
|
2943
2937
|
export {
|
|
2944
|
-
|
|
2945
|
-
|
|
2946
|
-
summarizeTransports,
|
|
2947
|
-
resolveMedia,
|
|
2948
|
-
readMcpCatalogStamp,
|
|
2949
|
-
protectedResourceMetadataUrl,
|
|
2950
|
-
oauthProtectedResourceRoute,
|
|
2951
|
-
mountWait,
|
|
2952
|
-
mountViewFile,
|
|
2953
|
-
mountUpload,
|
|
2954
|
-
mountOAuthProvider,
|
|
2955
|
-
mountMcpResource,
|
|
2956
|
-
mountMcp,
|
|
2957
|
-
mountDownload,
|
|
2958
|
-
mountAgent,
|
|
2959
|
-
mcpCatalogMeta,
|
|
2960
|
-
listToolNames,
|
|
2961
|
-
listContractToolNames,
|
|
2962
|
-
isToolExecutionControlError,
|
|
2963
|
-
isAgentToolError,
|
|
2964
|
-
inlineMcpAppBundle,
|
|
2965
|
-
flattenToolJsonSchema,
|
|
2966
|
-
findUntypedProperties,
|
|
2967
|
-
findNonPortableFormats,
|
|
2968
|
-
describeToolCatalog,
|
|
2969
|
-
defineWaitTool,
|
|
2970
|
-
defineViewFileTool,
|
|
2971
|
-
defineUploadTool,
|
|
2972
|
-
defineToolRegistry,
|
|
2973
|
-
defineRuntimeTool,
|
|
2974
|
-
defineDownloadTool,
|
|
2975
|
-
defineAsyncOperationContract,
|
|
2976
|
-
defineAsyncOperation,
|
|
2977
|
-
createToolkit,
|
|
2978
|
-
createToolLogger,
|
|
2979
|
-
createToolInvoker,
|
|
2980
|
-
createStdioMcpServer,
|
|
2981
|
-
createSecureClientMetadataFetcher,
|
|
2982
|
-
createRuntimeToolFactory,
|
|
2983
|
-
createMcpHttpRoute,
|
|
2984
|
-
createMcpHandler,
|
|
2985
|
-
createLocalStepDurability,
|
|
2986
|
-
createAsyncOperationSnapshotSchema,
|
|
2987
|
-
composeToolLifecycle,
|
|
2988
|
-
collectTools,
|
|
2989
|
-
coerceJsonArgs,
|
|
2990
|
-
buildToolManifest,
|
|
2991
|
-
buildMcpServer,
|
|
2992
|
-
bindStdioProcessSignals,
|
|
2993
|
-
bindContractAsyncOperation,
|
|
2994
|
-
ViewFileOutputSchema,
|
|
2995
|
-
ViewFileInputSchema,
|
|
2996
|
-
ViewFileErrorSchema,
|
|
2997
|
-
UploadToolInputSchema,
|
|
2998
|
-
ToolExecutionControlError,
|
|
2999
|
-
RESOURCE_MIME_TYPE,
|
|
3000
|
-
PROTECTED_RESOURCE_PATH,
|
|
3001
|
-
PORTABLE_JSON_SCHEMA_FORMATS,
|
|
3002
|
-
McpMediaContentSchema,
|
|
3003
|
-
McpAnnotationsSchema,
|
|
3004
|
-
MCP_CATALOG_META_KEY,
|
|
3005
|
-
EffectUnresolvedError,
|
|
2938
|
+
AgentToolError2 as AgentToolError,
|
|
2939
|
+
AsyncOperationCancelResultSchema2 as AsyncOperationCancelResultSchema,
|
|
3006
2940
|
EXT_APPS_BUNDLE_PLACEHOLDER,
|
|
3007
|
-
|
|
3008
|
-
|
|
2941
|
+
EffectUnresolvedError2 as EffectUnresolvedError,
|
|
2942
|
+
MCP_CATALOG_META_KEY,
|
|
2943
|
+
McpAnnotationsSchema2 as McpAnnotationsSchema,
|
|
2944
|
+
McpMediaContentSchema2 as McpMediaContentSchema,
|
|
2945
|
+
PORTABLE_JSON_SCHEMA_FORMATS2 as PORTABLE_JSON_SCHEMA_FORMATS,
|
|
2946
|
+
PROTECTED_RESOURCE_PATH,
|
|
2947
|
+
RESOURCE_MIME_TYPE,
|
|
2948
|
+
ToolExecutionControlError2 as ToolExecutionControlError,
|
|
2949
|
+
UploadToolInputSchema,
|
|
2950
|
+
ViewFileErrorSchema2 as ViewFileErrorSchema,
|
|
2951
|
+
ViewFileInputSchema2 as ViewFileInputSchema,
|
|
2952
|
+
ViewFileOutputSchema2 as ViewFileOutputSchema,
|
|
2953
|
+
bindContractAsyncOperation,
|
|
2954
|
+
bindStdioProcessSignals,
|
|
2955
|
+
buildMcpServer,
|
|
2956
|
+
buildToolManifest2 as buildToolManifest,
|
|
2957
|
+
coerceJsonArgs2 as coerceJsonArgs,
|
|
2958
|
+
collectTools2 as collectTools,
|
|
2959
|
+
composeToolLifecycle,
|
|
2960
|
+
createAsyncOperationSnapshotSchema2 as createAsyncOperationSnapshotSchema,
|
|
2961
|
+
createLocalStepDurability2 as createLocalStepDurability,
|
|
2962
|
+
createMcpHandler,
|
|
2963
|
+
createMcpHttpRoute,
|
|
2964
|
+
createRuntimeToolFactory2 as createRuntimeToolFactory,
|
|
2965
|
+
createSecureClientMetadataFetcher,
|
|
2966
|
+
createStdioMcpServer,
|
|
2967
|
+
createToolInvoker2 as createToolInvoker,
|
|
2968
|
+
createToolLogger,
|
|
2969
|
+
createToolkit,
|
|
2970
|
+
defineAsyncOperation,
|
|
2971
|
+
defineAsyncOperationContract,
|
|
2972
|
+
defineDownloadTool,
|
|
2973
|
+
defineRuntimeTool2 as defineRuntimeTool,
|
|
2974
|
+
defineToolRegistry,
|
|
2975
|
+
defineUploadTool,
|
|
2976
|
+
defineViewFileTool,
|
|
2977
|
+
defineWaitTool,
|
|
2978
|
+
describeToolCatalog2 as describeToolCatalog,
|
|
2979
|
+
findNonPortableFormats2 as findNonPortableFormats,
|
|
2980
|
+
findUntypedProperties2 as findUntypedProperties,
|
|
2981
|
+
flattenToolJsonSchema2 as flattenToolJsonSchema,
|
|
2982
|
+
inlineMcpAppBundle,
|
|
2983
|
+
isAgentToolError2 as isAgentToolError,
|
|
2984
|
+
isToolExecutionControlError2 as isToolExecutionControlError,
|
|
2985
|
+
listContractToolNames,
|
|
2986
|
+
listToolNames,
|
|
2987
|
+
mcpCatalogMeta,
|
|
2988
|
+
mountAgent2 as mountAgent,
|
|
2989
|
+
mountDownload,
|
|
2990
|
+
mountMcp,
|
|
2991
|
+
mountMcpResource,
|
|
2992
|
+
mountOAuthProvider,
|
|
2993
|
+
mountUpload,
|
|
2994
|
+
mountViewFile,
|
|
2995
|
+
mountWait,
|
|
2996
|
+
oauthProtectedResourceRoute,
|
|
2997
|
+
protectedResourceMetadataUrl,
|
|
2998
|
+
readMcpCatalogStamp,
|
|
2999
|
+
resolveMedia,
|
|
3000
|
+
summarizeTransports,
|
|
3001
|
+
validateMcpSchemas,
|
|
3002
|
+
wwwAuthenticateHeader
|
|
3009
3003
|
};
|