stitchkit 0.136.7 → 0.137.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +68 -0
- package/dist/agent-runtime/stores/branch-observations.d.ts +19 -19
- package/dist/agent-runtime/stores/schedule-contract.d.ts.map +1 -1
- package/dist/agent-runtime/stores/schedule-records.d.ts.map +1 -1
- package/dist/agent-runtime/stores/schedule-tools.d.ts.map +1 -1
- package/dist/agent-runtime/stores/sql-rows.d.ts +36 -36
- package/dist/agent-runtime/terminal-commit.d.ts +5 -5
- package/dist/agent-runtime/testing/store-conformance-lifecycle.d.ts +52 -52
- package/dist/agent-runtime/testing/store-conformance-support.d.ts +26 -26
- package/dist/browser/client-executors.d.ts +2 -3
- package/dist/browser/client-executors.d.ts.map +1 -1
- package/dist/browser/realtime-client.d.ts +6 -1
- package/dist/browser/realtime-client.d.ts.map +1 -1
- package/dist/browser/socket-io-client.d.ts.map +1 -1
- package/dist/browser/socket-io-contract.d.ts +2 -0
- package/dist/browser/socket-io-contract.d.ts.map +1 -1
- package/dist/contract/define-validation.d.ts +6 -0
- package/dist/contract/define-validation.d.ts.map +1 -1
- package/dist/contract/define.d.ts +1 -1
- package/dist/contract/define.d.ts.map +1 -1
- package/dist/contract/error-mapping.d.ts +71 -0
- package/dist/contract/error-mapping.d.ts.map +1 -0
- package/dist/contract/errors.d.ts +8 -0
- package/dist/contract/errors.d.ts.map +1 -1
- package/dist/contract/factory.d.ts +8 -0
- package/dist/contract/factory.d.ts.map +1 -1
- package/dist/contract/fragments.d.ts +45 -0
- package/dist/contract/fragments.d.ts.map +1 -0
- package/dist/contract/normalize.d.ts +6 -3
- package/dist/contract/normalize.d.ts.map +1 -1
- package/dist/contract/operation-read.d.ts +38 -0
- package/dist/contract/operation-read.d.ts.map +1 -0
- package/dist/contract/stream.d.ts.map +1 -1
- package/dist/contract/time-zone.d.ts +31 -0
- package/dist/contract/time-zone.d.ts.map +1 -0
- package/dist/contract/tool-options.d.ts +1 -1
- package/dist/contract/tool-options.d.ts.map +1 -1
- package/dist/device-relay/hub.d.ts +1 -1
- package/dist/device-relay/hub.d.ts.map +1 -1
- package/dist/entrypoints/agent-executor/acp.js +9 -9
- package/dist/entrypoints/agent-executor/claude-sdk.js +11 -11
- package/dist/entrypoints/agent-executor/claude.js +8 -8
- package/dist/entrypoints/agent-executor/codex.js +15 -15
- package/dist/entrypoints/agent-executor/testing.js +11 -11
- package/dist/entrypoints/agent-executor.js +14 -13
- package/dist/entrypoints/agent-runtime/ai-sdk.js +5 -5
- package/dist/entrypoints/agent-runtime/anthropic.js +1 -1
- package/dist/entrypoints/agent-runtime/browser.js +5 -5
- package/dist/entrypoints/agent-runtime/coding-tools.js +3 -3
- package/dist/entrypoints/agent-runtime/harness.js +14 -15
- package/dist/entrypoints/agent-runtime/openai.js +1 -1
- package/dist/entrypoints/agent-runtime/openrouter.js +7 -7
- package/dist/entrypoints/agent-runtime/postgres.js +5 -5
- package/dist/entrypoints/agent-runtime/realtime.js +8 -8
- package/dist/entrypoints/agent-runtime/sandbox.js +7 -7
- package/dist/entrypoints/agent-runtime/sqlite/bun.js +6 -6
- package/dist/entrypoints/agent-runtime/sqlite/node.js +6 -6
- package/dist/entrypoints/agent-runtime/testing.js +5 -5
- package/dist/entrypoints/agent-runtime.js +33 -29
- package/dist/entrypoints/application/diagnostic-journal.js +3 -3
- package/dist/entrypoints/application/directory-inbox.js +1 -1
- package/dist/entrypoints/application/grammy.js +1 -1
- package/dist/entrypoints/application/opentelemetry.js +2 -2
- package/dist/entrypoints/application.js +10 -10
- package/dist/entrypoints/cli/publish.d.ts +4 -4
- package/dist/entrypoints/cli/publish.d.ts.map +1 -1
- package/dist/entrypoints/cli/publish.js +160 -52
- package/dist/entrypoints/cli.d.ts +3 -1
- package/dist/entrypoints/cli.d.ts.map +1 -1
- package/dist/entrypoints/cli.js +520 -59
- package/dist/entrypoints/contract.d.ts +5 -1
- package/dist/entrypoints/contract.d.ts.map +1 -1
- package/dist/entrypoints/contract.js +25 -7
- package/dist/entrypoints/device-relay.js +20 -10
- package/dist/entrypoints/files/packaging.js +2 -2
- package/dist/entrypoints/files.js +10 -10
- package/dist/entrypoints/handler.d.ts +1 -1
- package/dist/entrypoints/handler.d.ts.map +1 -1
- package/dist/entrypoints/handler.js +12 -12
- package/dist/entrypoints/http.js +13 -12
- package/dist/entrypoints/index.js +36 -18
- package/dist/entrypoints/live.d.ts +2 -1
- package/dist/entrypoints/live.d.ts.map +1 -1
- package/dist/entrypoints/live.js +630 -1
- package/dist/entrypoints/node.d.ts +5 -0
- package/dist/entrypoints/node.d.ts.map +1 -1
- package/dist/entrypoints/node.js +36 -16
- package/dist/entrypoints/observability.js +25 -10
- package/dist/entrypoints/postgres.d.ts +4 -1
- package/dist/entrypoints/postgres.d.ts.map +1 -1
- package/dist/entrypoints/postgres.js +312 -0
- package/dist/entrypoints/primitives.js +11 -4
- package/dist/entrypoints/process.js +7 -7
- package/dist/entrypoints/react.js +1 -1
- package/dist/entrypoints/realtime.js +3 -3
- package/dist/entrypoints/remote.js +6 -29
- package/dist/entrypoints/server.d.ts +6 -1
- package/dist/entrypoints/server.d.ts.map +1 -1
- package/dist/entrypoints/server.js +93 -32
- package/dist/entrypoints/service-host/macos.js +6 -6
- package/dist/entrypoints/service-host/work.js +6 -6
- package/dist/entrypoints/service-host.js +10 -10
- package/dist/entrypoints/spend.js +2 -1
- package/dist/entrypoints/sync.js +5 -5
- package/dist/entrypoints/telegram.js +8 -8
- package/dist/entrypoints/testing.d.ts +1 -0
- package/dist/entrypoints/testing.d.ts.map +1 -1
- package/dist/entrypoints/testing.js +1501 -13
- package/dist/entrypoints/tools/agent.js +6 -7
- package/dist/entrypoints/tools/connections.js +9 -11
- package/dist/entrypoints/tools/contract.js +1 -2
- package/dist/entrypoints/tools/invoker.js +4 -5
- package/dist/entrypoints/tools/mcp.js +10 -11
- package/dist/entrypoints/tools/toolkit.d.ts +1 -1
- package/dist/entrypoints/tools/toolkit.d.ts.map +1 -1
- package/dist/entrypoints/tools/toolkit.js +29 -24
- package/dist/entrypoints/tools.js +28 -30
- package/dist/entrypoints/tracking/contract.js +2 -1
- package/dist/entrypoints/xlsx.js +5 -8
- package/dist/{index-033tyx59.js → index-0zw0hcyg.js} +4 -1
- package/dist/{index-zcq3dby3.js → index-1bjwfnnj.js} +1 -1
- package/dist/{index-f103md2v.js → index-1cfacbe2.js} +88 -23
- package/dist/{index-gj4wdts6.js → index-1ckh9qx1.js} +1 -1
- package/dist/index-1pvwmbxp.js +1435 -0
- package/dist/{index-0s75mjh7.js → index-2e4hdh32.js} +1 -1
- package/dist/{index-3shdhzt6.js → index-2j0pqxkn.js} +12 -6
- package/dist/index-3k8w02se.js +28 -0
- package/dist/{index-7fjbdga8.js → index-3pb4ccj2.js} +8 -0
- package/dist/{index-w7e402wx.js → index-48kb4gqq.js} +46 -7
- package/dist/{index-cv9b7fz2.js → index-6rws2xf5.js} +8 -0
- package/dist/{index-bbpygynk.js → index-77w5vx0g.js} +1 -1
- package/dist/index-7dz1ngaf.js +35 -0
- package/dist/{index-y68gavb5.js → index-7n4atsm4.js} +1 -1
- package/dist/index-8ef1bfea.js +71 -0
- package/dist/{index-0x4mnwg5.js → index-8k3y9nd4.js} +6 -9
- package/dist/{index-ezwsqyad.js → index-8rkdkefj.js} +40 -23
- package/dist/{index-3cwq5byx.js → index-9nax7tkn.js} +2 -2
- package/dist/{index-dz6tstcp.js → index-9r6emjwz.js} +1 -1
- package/dist/{index-32ew02z1.js → index-c4b7d6ej.js} +5 -5
- package/dist/index-ceshyndf.js +284 -0
- package/dist/{index-w161azza.js → index-d13rw31w.js} +6 -6
- package/dist/{index-1h0dtfz3.js → index-dmm7vs3f.js} +1 -1
- package/dist/{index-ypm85xwe.js → index-dp8j2e77.js} +1 -1
- package/dist/{index-qqd979f7.js → index-edycjvrv.js} +9 -9
- package/dist/{index-18qdpbcq.js → index-egpf9dv0.js} +200 -1479
- package/dist/{index-fatke81t.js → index-ezgvsj9w.js} +2 -2
- package/dist/{index-chapre0y.js → index-f3e7tj1g.js} +1 -1
- package/dist/{index-df5xr2f9.js → index-frsd2a94.js} +16 -1
- package/dist/index-fy9mmek1.js +95 -0
- package/dist/{index-2331y2tf.js → index-g0gvfzrx.js} +12 -12
- package/dist/index-gpe8d1ka.js +19 -0
- package/dist/{index-4p2zx593.js → index-gyw4qd0m.js} +1 -1
- package/dist/index-gzqy81tw.js +172 -0
- package/dist/{index-yrhw10ef.js → index-h34c510q.js} +8 -4
- package/dist/{index-rr94xcj6.js → index-h527p1yj.js} +10 -4
- package/dist/{index-qj0sq69b.js → index-hgf1tbgz.js} +76 -16
- package/dist/{index-smvmnz5y.js → index-hvpan32x.js} +1 -1
- package/dist/{index-4gbybjg6.js → index-hxawqrb6.js} +2 -2
- package/dist/{index-0k1ba0ss.js → index-j91jffhv.js} +1 -1
- package/dist/{index-d01akj5n.js → index-jr4kwetx.js} +8 -8
- package/dist/{index-xqppqn97.js → index-ka6z48zc.js} +315 -69
- package/dist/{index-by8w2461.js → index-kw0segzt.js} +104 -3
- package/dist/{index-6f4fjygr.js → index-m5t4dr7h.js} +29 -7
- package/dist/{index-afaq0nc4.js → index-n0egp1ke.js} +1 -1
- package/dist/{index-9fzjgg86.js → index-n74rb1dq.js} +2 -2
- package/dist/{index-dwq6a6sq.js → index-pt25vmhc.js} +33 -16
- package/dist/{index-vwg0n3e6.js → index-pyazb8q4.js} +23 -14
- package/dist/{index-5md04mwc.js → index-qpjjbkc5.js} +4 -4
- package/dist/{index-08a3qfr8.js → index-r1qt6zgj.js} +1 -1
- package/dist/{index-ctaxjpa4.js → index-r709pqed.js} +1 -1
- package/dist/{index-2zrx0nzv.js → index-rzc40z6e.js} +3 -5
- package/dist/{index-gq35s3bm.js → index-s5axtd56.js} +2 -2
- package/dist/{index-edpkm3k7.js → index-scpcps66.js} +669 -16
- package/dist/{index-ry8m2mhg.js → index-sf2mt6wj.js} +1 -1
- package/dist/{index-tjhhsnjv.js → index-t1213r0t.js} +1 -1
- package/dist/{index-gvgtmt7a.js → index-t7efje30.js} +2 -2
- package/dist/{index-w3s79kcb.js → index-tzyk36dy.js} +1 -1
- package/dist/{index-8tn10tp6.js → index-v64bvwjr.js} +1 -1
- package/dist/{index-1fhbe4e4.js → index-vksbsqpb.js} +1 -1
- package/dist/{index-dxft2mnm.js → index-wdg7bswj.js} +1 -1
- package/dist/{index-ppy23bd2.js → index-wjx1zs2r.js} +7 -578
- package/dist/{index-efbzm2se.js → index-x2r0ma9t.js} +1 -1
- package/dist/{index-kd48gk7d.js → index-x8py72a3.js} +1 -1
- package/dist/index-xvydbxmk.js +1404 -0
- package/dist/index-xwaphv0d.js +31 -0
- package/dist/{index-a09r9ff0.js → index-y44j39yk.js} +1 -1
- package/dist/{index-7mjsb7zv.js → index-ybrrxjhb.js} +1 -1
- package/dist/{index-xsrma0jd.js → index-ysthxsa8.js} +6 -6
- package/dist/{index-6p5pshcd.js → index-yyh3ey4b.js} +1 -1
- package/dist/{index-mr3njw67.js → index-z6hq9j8j.js} +1 -1
- package/dist/{index-67mzzkdv.js → index-z72agxdn.js} +2 -2
- package/dist/{index-e4w0sfm1.js → index-z78mtc16.js} +1 -1
- package/dist/{index-7csn6pva.js → index-ze94h4ph.js} +5 -0
- package/dist/internal/json-stringify.d.ts +12 -0
- package/dist/internal/json-stringify.d.ts.map +1 -1
- package/dist/internal/unix-client-error.d.ts +4 -0
- package/dist/internal/unix-client-error.d.ts.map +1 -1
- package/dist/live/watch-contract.d.ts +4 -0
- package/dist/live/watch-contract.d.ts.map +1 -1
- package/dist/live/watch-fanout-frame.d.ts +81 -0
- package/dist/live/watch-fanout-frame.d.ts.map +1 -0
- package/dist/live/watch-fanout.d.ts +57 -0
- package/dist/live/watch-fanout.d.ts.map +1 -0
- package/dist/observability/audit.d.ts.map +1 -1
- package/dist/observability/spool-core.d.ts +1 -0
- package/dist/observability/spool-core.d.ts.map +1 -1
- package/dist/observability/spool-drain.d.ts +48 -0
- package/dist/observability/spool-drain.d.ts.map +1 -0
- package/dist/observability/spool.d.ts +12 -6
- package/dist/observability/spool.d.ts.map +1 -1
- package/dist/postgres/connection-config.d.ts +54 -0
- package/dist/postgres/connection-config.d.ts.map +1 -0
- package/dist/postgres/rollback-transaction.d.ts +61 -0
- package/dist/postgres/rollback-transaction.d.ts.map +1 -0
- package/dist/primitives/deadline.d.ts +4 -4
- package/dist/primitives/deadline.d.ts.map +1 -1
- package/dist/server/error-hook.d.ts +3 -32
- package/dist/server/error-hook.d.ts.map +1 -1
- package/dist/server/local-consent-key.d.ts +104 -0
- package/dist/server/local-consent-key.d.ts.map +1 -0
- package/dist/server/local-control-journal.d.ts +51 -0
- package/dist/server/local-control-journal.d.ts.map +1 -0
- package/dist/server/local-control-reporter.d.ts +32 -0
- package/dist/server/local-control-reporter.d.ts.map +1 -0
- package/dist/server/local-control.d.ts +48 -0
- package/dist/server/local-control.d.ts.map +1 -0
- package/dist/server/local-host-clients.d.ts +105 -0
- package/dist/server/local-host-clients.d.ts.map +1 -0
- package/dist/server/middleware/trust-fence.d.ts +20 -0
- package/dist/server/middleware/trust-fence.d.ts.map +1 -1
- package/dist/spend/receipt-spool.d.ts +9 -4
- package/dist/spend/receipt-spool.d.ts.map +1 -1
- package/dist/testing/tool-surface-checks.d.ts +89 -0
- package/dist/testing/tool-surface-checks.d.ts.map +1 -0
- package/dist/testing/tool-surface-cli-callable.d.ts +63 -0
- package/dist/testing/tool-surface-cli-callable.d.ts.map +1 -0
- package/dist/testing/tool-surface-dead-refs.d.ts +32 -0
- package/dist/testing/tool-surface-dead-refs.d.ts.map +1 -0
- package/dist/testing/tool-surface-gates.d.ts +72 -0
- package/dist/testing/tool-surface-gates.d.ts.map +1 -0
- package/dist/testing/tool-surface-parity-drivers.d.ts +56 -0
- package/dist/testing/tool-surface-parity-drivers.d.ts.map +1 -0
- package/dist/testing/tool-surface-parity.d.ts +28 -0
- package/dist/testing/tool-surface-parity.d.ts.map +1 -0
- package/dist/testing/tool-surface-ratchet.d.ts +71 -0
- package/dist/testing/tool-surface-ratchet.d.ts.map +1 -0
- package/dist/tools/agent-tools.d.ts +3 -0
- package/dist/tools/agent-tools.d.ts.map +1 -1
- package/dist/tools/cli/command.d.ts +3 -0
- package/dist/tools/cli/command.d.ts.map +1 -1
- package/dist/tools/cli/create-cli.d.ts.map +1 -1
- package/dist/tools/cli/distribution-config.d.ts +39 -1
- package/dist/tools/cli/distribution-config.d.ts.map +1 -1
- package/dist/tools/cli/distribution-routes.d.ts +4 -2
- package/dist/tools/cli/distribution-routes.d.ts.map +1 -1
- package/dist/tools/cli/format.d.ts +3 -6
- package/dist/tools/cli/format.d.ts.map +1 -1
- package/dist/tools/cli/invoke.d.ts +4 -0
- package/dist/tools/cli/invoke.d.ts.map +1 -1
- package/dist/tools/cli/local-key-command.d.ts +53 -0
- package/dist/tools/cli/local-key-command.d.ts.map +1 -0
- package/dist/tools/cli/managed-surface.d.ts.map +1 -1
- package/dist/tools/cli/publication-contract.d.ts +9 -2
- package/dist/tools/cli/publication-contract.d.ts.map +1 -1
- package/dist/tools/cli/publication.d.ts.map +1 -1
- package/dist/tools/cli/run-managed.d.ts.map +1 -1
- package/dist/tools/cli/run-stream.d.ts.map +1 -1
- package/dist/tools/cli/runner.d.ts +8 -3
- package/dist/tools/cli/runner.d.ts.map +1 -1
- package/dist/tools/cli/secret.d.ts +55 -0
- package/dist/tools/cli/secret.d.ts.map +1 -0
- package/dist/tools/cli/session.d.ts +2 -2
- package/dist/tools/cli/session.d.ts.map +1 -1
- package/dist/tools/cli/signature.d.ts +23 -9
- package/dist/tools/cli/signature.d.ts.map +1 -1
- package/dist/tools/cli/stream.d.ts.map +1 -1
- package/dist/tools/cli/unix-outcome.d.ts +6 -0
- package/dist/tools/cli/unix-outcome.d.ts.map +1 -1
- package/dist/tools/cli/update.d.ts +6 -1
- package/dist/tools/cli/update.d.ts.map +1 -1
- package/dist/tools/execute-result.d.ts +20 -0
- package/dist/tools/execute-result.d.ts.map +1 -1
- package/dist/tools/execute.d.ts +3 -0
- package/dist/tools/execute.d.ts.map +1 -1
- package/dist/tools/internal/json-projection.d.ts +13 -9
- package/dist/tools/internal/json-projection.d.ts.map +1 -1
- package/dist/tools/internal/remote-error.d.ts +15 -0
- package/dist/tools/internal/remote-error.d.ts.map +1 -0
- package/dist/tools/internal/surface-projector.d.ts +2 -0
- package/dist/tools/internal/surface-projector.d.ts.map +1 -1
- package/dist/tools/invoker.d.ts +3 -0
- package/dist/tools/invoker.d.ts.map +1 -1
- package/dist/tools/mcp/handler.d.ts.map +1 -1
- package/dist/tools/mcp/lazy-discovery.d.ts +2 -0
- package/dist/tools/mcp/lazy-discovery.d.ts.map +1 -1
- package/dist/tools/mcp/mount.d.ts +5 -0
- package/dist/tools/mcp/mount.d.ts.map +1 -1
- package/dist/tools/mcp/register.d.ts +2 -0
- package/dist/tools/mcp/register.d.ts.map +1 -1
- package/dist/tools/mcp/runtime-tools.d.ts +2 -0
- package/dist/tools/mcp/runtime-tools.d.ts.map +1 -1
- package/dist/tools/mcp/stdio.d.ts.map +1 -1
- package/dist/tools/mount.d.ts +3 -0
- package/dist/tools/mount.d.ts.map +1 -1
- package/dist/tools/read-operation.d.ts +2 -6
- package/dist/tools/read-operation.d.ts.map +1 -1
- package/dist/tools/remote.d.ts.map +1 -1
- package/dist/tools/runtime-tool.d.ts.map +1 -1
- package/dist/tools/toolkit.d.ts +10 -3
- package/dist/tools/toolkit.d.ts.map +1 -1
- package/dist/xlsx/schema.d.ts.map +1 -1
- package/llms/cli-publish.txt +4 -1
- package/llms/cli.2.txt +42 -51
- package/llms/cli.3.txt +34 -1
- package/llms/cli.txt +18 -3
- package/llms/contract.txt +47 -5
- package/llms/handler.txt +1 -1
- package/llms/live.txt +82 -0
- package/llms/node.txt +5 -0
- package/llms/observability.2.txt +1 -1
- package/llms/observability.txt +6 -0
- package/llms/postgres.txt +14 -3
- package/llms/server.2.txt +206 -240
- package/llms/server.3.txt +242 -202
- package/llms/server.4.txt +202 -1025
- package/llms/server.5.txt +1053 -255
- package/llms/server.6.txt +274 -0
- package/llms/server.txt +32 -116
- package/llms/spend.txt +8 -7
- package/llms/stitchkit.2.txt +13 -35
- package/llms/stitchkit.3.txt +27 -0
- package/llms/stitchkit.txt +82 -82
- package/llms/testing.txt +40 -0
- package/llms/tools-toolkit.txt +2 -2
- package/llms/tools.2.txt +29 -20
- package/llms/{upgrading-0.128.0-0.129.0.txt → upgrading-0.128.0-0.131.0.txt} +101 -3
- package/llms/{upgrading-0.130.0-0.136.0.txt → upgrading-0.132.0-0.137.0.txt} +62 -101
- package/llms/upgrading.txt +2 -2
- package/llms-full.txt +641 -189
- package/llms.txt +14 -14
- package/package.json +3 -3
- package/dist/index-9118dw8d.js +0 -603
- package/dist/index-9vj869rx.js +0 -19
- package/dist/index-a1rjr381.js +0 -114
- package/dist/index-dacxr7nf.js +0 -17
- package/dist/index-dm50x3by.js +0 -63
- package/dist/index-dmrx8xma.js +0 -163
- package/dist/index-ednf2cxs.js +0 -37
- package/dist/{index-e4zt2x70.js → index-3czppvrr.js} +3 -3
- package/dist/{index-42n9jycn.js → index-3f79t32b.js} +3 -3
- package/dist/{index-mfe9a266.js → index-84n49vam.js} +0 -0
- package/dist/{index-f16b7rze.js → index-er1tp8de.js} +3 -3
- package/dist/{index-k137ezb6.js → index-f5d0fdcf.js} +3 -3
- package/dist/{index-65p8v81y.js → index-psz8qrz0.js} +3 -3
- package/dist/{index-kadgaw1s.js → index-r8cq86h1.js} +0 -0
- package/dist/{index-1yky29qg.js → index-tyyvbarf.js} +0 -0
- package/dist/{index-tjakdpf2.js → index-wq71v08n.js} +3 -3
- package/dist/{index-7an2fs5h.js → index-wswcpbm4.js} +3 -3
package/dist/index-9118dw8d.js
DELETED
|
@@ -1,603 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
localVerdict
|
|
3
|
-
} from "./index-dsa676h8.js";
|
|
4
|
-
import {
|
|
5
|
-
objectShapeKeys,
|
|
6
|
-
rebuildObject,
|
|
7
|
-
mergeSchemas
|
|
8
|
-
} from "./index-dm50x3by.js";
|
|
9
|
-
import {
|
|
10
|
-
coerceJsonArgs2
|
|
11
|
-
} from "./index-qj0sq69b.js";
|
|
12
|
-
import {
|
|
13
|
-
applyToolViewDefaults,
|
|
14
|
-
projectToolView,
|
|
15
|
-
assertToolExtensionCompatible,
|
|
16
|
-
projectToolSurface
|
|
17
|
-
} from "./index-edpkm3k7.js";
|
|
18
|
-
import {
|
|
19
|
-
runWithRequestContext2,
|
|
20
|
-
getRequestContext2
|
|
21
|
-
} from "./index-q4tr9vnf.js";
|
|
22
|
-
import {
|
|
23
|
-
normalizeError2,
|
|
24
|
-
validateDeclaredOutput
|
|
25
|
-
} from "./index-dwq6a6sq.js";
|
|
26
|
-
import {
|
|
27
|
-
projectedToolError
|
|
28
|
-
} from "./index-dacxr7nf.js";
|
|
29
|
-
import {
|
|
30
|
-
isUnsafeKey
|
|
31
|
-
} from "./index-zsarb5xp.js";
|
|
32
|
-
import {
|
|
33
|
-
formatZodError2
|
|
34
|
-
} from "./index-1eeqpadm.js";
|
|
35
|
-
import {
|
|
36
|
-
AppError2,
|
|
37
|
-
STITCH_ERROR_STATUS2,
|
|
38
|
-
isRetryableStatus2,
|
|
39
|
-
isStitchErrorCode2
|
|
40
|
-
} from "./index-7fjbdga8.js";
|
|
41
|
-
import {
|
|
42
|
-
isRecord
|
|
43
|
-
} from "./index-ps3djm8d.js";
|
|
44
|
-
|
|
45
|
-
// src/tools/access.ts
|
|
46
|
-
var TOOL_OPEN_REASONS = ["public", "local-operator", "remote"];
|
|
47
|
-
var TOOL_OPEN_REASON_SET = new Set(TOOL_OPEN_REASONS);
|
|
48
|
-
var inspectOnlyLifecycles = new WeakMap;
|
|
49
|
-
function accessRequiredMessage(entryName) {
|
|
50
|
-
return `${entryName}: access is required — pass { gate } with the auth hook, { open }, or { inspect: true }`;
|
|
51
|
-
}
|
|
52
|
-
function legacyLifecycleMessage(entryName) {
|
|
53
|
-
return `${entryName}: access is required — pass { gate } with the auth hook, { open }, or { inspect: true } ("lifecycle" was replaced by "access")`;
|
|
54
|
-
}
|
|
55
|
-
function inspectForbiddenError(entryName) {
|
|
56
|
-
return new AppError2("FORBIDDEN", {
|
|
57
|
-
message: `${entryName}: mounted with access: { inspect: true } (read-only surface inspection); tool execution is forbidden`,
|
|
58
|
-
status: 403
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
|
-
function isInspectOnlyLifecycle(lifecycle) {
|
|
62
|
-
return lifecycle !== undefined && inspectOnlyLifecycles.has(lifecycle);
|
|
63
|
-
}
|
|
64
|
-
function inspectOnlyError(lifecycle) {
|
|
65
|
-
if (lifecycle === undefined)
|
|
66
|
-
return;
|
|
67
|
-
const entryName = inspectOnlyLifecycles.get(lifecycle);
|
|
68
|
-
return entryName !== undefined ? inspectForbiddenError(entryName) : undefined;
|
|
69
|
-
}
|
|
70
|
-
function isBeforeHandleHook(value) {
|
|
71
|
-
return typeof value === "function";
|
|
72
|
-
}
|
|
73
|
-
function isAfterHandleHook(value) {
|
|
74
|
-
return typeof value === "function";
|
|
75
|
-
}
|
|
76
|
-
function isToolOpenReason(value) {
|
|
77
|
-
return typeof value === "string" && TOOL_OPEN_REASON_SET.has(value);
|
|
78
|
-
}
|
|
79
|
-
function resolveToolAccess(entryName, config) {
|
|
80
|
-
if (!isRecord(config)) {
|
|
81
|
-
throw new TypeError(accessRequiredMessage(entryName));
|
|
82
|
-
}
|
|
83
|
-
if (Object.hasOwn(config, "lifecycle")) {
|
|
84
|
-
throw new TypeError(legacyLifecycleMessage(entryName));
|
|
85
|
-
}
|
|
86
|
-
if (!Object.hasOwn(config, "access")) {
|
|
87
|
-
throw new TypeError(accessRequiredMessage(entryName));
|
|
88
|
-
}
|
|
89
|
-
const { access } = config;
|
|
90
|
-
if (!isRecord(access)) {
|
|
91
|
-
throw new TypeError(accessRequiredMessage(entryName));
|
|
92
|
-
}
|
|
93
|
-
const hasGate = Object.hasOwn(access, "gate") && access.gate !== undefined;
|
|
94
|
-
const hasOpen = Object.hasOwn(access, "open") && access.open !== undefined;
|
|
95
|
-
const hasInspect = Object.hasOwn(access, "inspect") && access.inspect !== undefined;
|
|
96
|
-
if (Number(hasGate) + Number(hasOpen) + Number(hasInspect) !== 1) {
|
|
97
|
-
throw new TypeError(accessRequiredMessage(entryName));
|
|
98
|
-
}
|
|
99
|
-
if (hasGate) {
|
|
100
|
-
for (const key of Object.keys(access)) {
|
|
101
|
-
if (key === "gate")
|
|
102
|
-
continue;
|
|
103
|
-
if ((key === "open" || key === "inspect" || key === "afterHandle") && access[key] === undefined)
|
|
104
|
-
continue;
|
|
105
|
-
throw new TypeError(accessRequiredMessage(entryName));
|
|
106
|
-
}
|
|
107
|
-
const { gate } = access;
|
|
108
|
-
if (!isRecord(gate)) {
|
|
109
|
-
throw new TypeError(accessRequiredMessage(entryName));
|
|
110
|
-
}
|
|
111
|
-
const { beforeHandle, afterHandle } = gate;
|
|
112
|
-
if (!isBeforeHandleHook(beforeHandle)) {
|
|
113
|
-
throw new TypeError(accessRequiredMessage(entryName));
|
|
114
|
-
}
|
|
115
|
-
if (afterHandle !== undefined && !isAfterHandleHook(afterHandle)) {
|
|
116
|
-
throw new TypeError(accessRequiredMessage(entryName));
|
|
117
|
-
}
|
|
118
|
-
return afterHandle !== undefined ? { beforeHandle, afterHandle } : { beforeHandle };
|
|
119
|
-
}
|
|
120
|
-
if (hasInspect) {
|
|
121
|
-
for (const key of Object.keys(access)) {
|
|
122
|
-
if (key === "inspect")
|
|
123
|
-
continue;
|
|
124
|
-
if ((key === "gate" || key === "open" || key === "afterHandle") && access[key] === undefined)
|
|
125
|
-
continue;
|
|
126
|
-
throw new TypeError(accessRequiredMessage(entryName));
|
|
127
|
-
}
|
|
128
|
-
if (access.inspect !== true) {
|
|
129
|
-
throw new TypeError(accessRequiredMessage(entryName));
|
|
130
|
-
}
|
|
131
|
-
const lifecycle = {
|
|
132
|
-
beforeHandle() {
|
|
133
|
-
throw inspectForbiddenError(entryName);
|
|
134
|
-
}
|
|
135
|
-
};
|
|
136
|
-
inspectOnlyLifecycles.set(lifecycle, entryName);
|
|
137
|
-
return lifecycle;
|
|
138
|
-
}
|
|
139
|
-
for (const key of Object.keys(access)) {
|
|
140
|
-
if (key === "open" || key === "afterHandle")
|
|
141
|
-
continue;
|
|
142
|
-
if ((key === "gate" || key === "inspect") && access[key] === undefined)
|
|
143
|
-
continue;
|
|
144
|
-
throw new TypeError(accessRequiredMessage(entryName));
|
|
145
|
-
}
|
|
146
|
-
const { open, afterHandle } = access;
|
|
147
|
-
if (!isToolOpenReason(open)) {
|
|
148
|
-
throw new TypeError(accessRequiredMessage(entryName));
|
|
149
|
-
}
|
|
150
|
-
if (afterHandle !== undefined && !isAfterHandleHook(afterHandle)) {
|
|
151
|
-
throw new TypeError(accessRequiredMessage(entryName));
|
|
152
|
-
}
|
|
153
|
-
return afterHandle !== undefined ? { afterHandle } : {};
|
|
154
|
-
}
|
|
155
|
-
function resolveOptionalCliToolAccess(entryName, config) {
|
|
156
|
-
if (!isRecord(config)) {
|
|
157
|
-
throw new TypeError(accessRequiredMessage(entryName));
|
|
158
|
-
}
|
|
159
|
-
if (Object.hasOwn(config, "lifecycle")) {
|
|
160
|
-
throw new TypeError(legacyLifecycleMessage(entryName));
|
|
161
|
-
}
|
|
162
|
-
const hasManagedSurface = config.services !== undefined || config.runtimeTools !== undefined;
|
|
163
|
-
if (hasManagedSurface || Object.hasOwn(config, "access") && config.access !== undefined) {
|
|
164
|
-
return resolveToolAccess(entryName, config);
|
|
165
|
-
}
|
|
166
|
-
return {};
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
// src/tools/execute-args.ts
|
|
170
|
-
import { z } from "zod";
|
|
171
|
-
function parseToolCallArguments(method, callArgs, {
|
|
172
|
-
coerceJson = false,
|
|
173
|
-
toolSurface = false
|
|
174
|
-
} = {}) {
|
|
175
|
-
const paramKeys = new Set(objectShapeKeys(method.paramsSchema));
|
|
176
|
-
let paramArgs = {};
|
|
177
|
-
let inputArgs = {};
|
|
178
|
-
for (const [key, value] of Object.entries(callArgs)) {
|
|
179
|
-
if (isUnsafeKey(key))
|
|
180
|
-
continue;
|
|
181
|
-
if (paramKeys.has(key))
|
|
182
|
-
paramArgs[key] = value;
|
|
183
|
-
else
|
|
184
|
-
inputArgs[key] = value;
|
|
185
|
-
}
|
|
186
|
-
if (coerceJson) {
|
|
187
|
-
try {
|
|
188
|
-
paramArgs = coerceJsonArgs2(paramArgs, method.paramsSchema);
|
|
189
|
-
} catch (err) {
|
|
190
|
-
if (err instanceof z.ZodError) {
|
|
191
|
-
return { ok: false, message: `Invalid params: ${formatZodError2(err)}` };
|
|
192
|
-
}
|
|
193
|
-
throw err;
|
|
194
|
-
}
|
|
195
|
-
try {
|
|
196
|
-
inputArgs = coerceJsonArgs2(inputArgs, method.inputSchema);
|
|
197
|
-
} catch (err) {
|
|
198
|
-
if (err instanceof z.ZodError) {
|
|
199
|
-
return { ok: false, message: `Invalid input: ${formatZodError2(err)}` };
|
|
200
|
-
}
|
|
201
|
-
throw err;
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
if (toolSurface)
|
|
205
|
-
inputArgs = applyToolViewDefaults(inputArgs, method.toolView?.defaults);
|
|
206
|
-
let params;
|
|
207
|
-
if (method.paramsSchema) {
|
|
208
|
-
let result;
|
|
209
|
-
try {
|
|
210
|
-
result = method.paramsSchema.safeParse(paramArgs);
|
|
211
|
-
} catch (err) {
|
|
212
|
-
return { ok: false, message: "Invalid params", thrown: err };
|
|
213
|
-
}
|
|
214
|
-
if (!result.success) {
|
|
215
|
-
return { ok: false, message: `Invalid params: ${formatZodError2(result.error)}` };
|
|
216
|
-
}
|
|
217
|
-
params = result.data;
|
|
218
|
-
}
|
|
219
|
-
let input;
|
|
220
|
-
if (method.inputSchema) {
|
|
221
|
-
let result;
|
|
222
|
-
try {
|
|
223
|
-
result = method.inputSchema.safeParse(inputArgs);
|
|
224
|
-
} catch (err) {
|
|
225
|
-
return { ok: false, message: "Invalid input", thrown: err };
|
|
226
|
-
}
|
|
227
|
-
if (result.success)
|
|
228
|
-
input = result.data;
|
|
229
|
-
else {
|
|
230
|
-
const refused = localVerdict(method.inputSchema, result.error);
|
|
231
|
-
if (refused)
|
|
232
|
-
return { ok: false, message: `Invalid input: ${formatZodError2(refused)}` };
|
|
233
|
-
input = inputArgs;
|
|
234
|
-
}
|
|
235
|
-
}
|
|
236
|
-
return { ok: true, params, input };
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
// src/tools/execute-handler.ts
|
|
240
|
-
async function invokeToolHandler(method, ctx, input, source, {
|
|
241
|
-
lifecycle,
|
|
242
|
-
onOutputStrip,
|
|
243
|
-
finalizeOutput,
|
|
244
|
-
toolSurface
|
|
245
|
-
}) {
|
|
246
|
-
if (lifecycle?.beforeHandle) {
|
|
247
|
-
await lifecycle.beforeHandle(ctx, method);
|
|
248
|
-
}
|
|
249
|
-
let data = await method.handler(ctx);
|
|
250
|
-
if (method.stream !== undefined)
|
|
251
|
-
return { ok: true, data };
|
|
252
|
-
if (lifecycle?.afterHandle) {
|
|
253
|
-
const transformed = await lifecycle.afterHandle(ctx, data, method);
|
|
254
|
-
if (transformed !== undefined)
|
|
255
|
-
data = transformed;
|
|
256
|
-
}
|
|
257
|
-
const checked = validateDeclaredOutput(method.outputSchema, data, onOutputStrip);
|
|
258
|
-
if (checked.ok) {
|
|
259
|
-
data = checked.data;
|
|
260
|
-
} else {
|
|
261
|
-
const verdict = checked.error && method.outputSchema ? localVerdict(method.outputSchema, checked.error) : undefined;
|
|
262
|
-
if (verdict !== null) {
|
|
263
|
-
const message = verdict && verdict !== checked.error ? `Handler output does not match the contract: ${formatZodError2(verdict)}` : checked.message;
|
|
264
|
-
return {
|
|
265
|
-
ok: false,
|
|
266
|
-
code: "INTERNAL_SERVER_ERROR",
|
|
267
|
-
details: { message }
|
|
268
|
-
};
|
|
269
|
-
}
|
|
270
|
-
}
|
|
271
|
-
if (toolSurface && method.toolView && method.outputSchema) {
|
|
272
|
-
const viewed = projectToolView({
|
|
273
|
-
view: method.toolView,
|
|
274
|
-
fullSchema: method.outputSchema,
|
|
275
|
-
full: data,
|
|
276
|
-
call: { input, source },
|
|
277
|
-
operation: `${method.serviceName}.${method.key}`,
|
|
278
|
-
onStripped: onOutputStrip
|
|
279
|
-
});
|
|
280
|
-
if (!viewed.ok) {
|
|
281
|
-
return {
|
|
282
|
-
ok: false,
|
|
283
|
-
code: "INTERNAL_SERVER_ERROR",
|
|
284
|
-
details: { message: viewed.message }
|
|
285
|
-
};
|
|
286
|
-
}
|
|
287
|
-
data = viewed.data;
|
|
288
|
-
}
|
|
289
|
-
if (finalizeOutput)
|
|
290
|
-
data = await finalizeOutput(data);
|
|
291
|
-
const output = (data === undefined || data === null) && !method.outputSchema ? { status: "ok" } : data;
|
|
292
|
-
return { ok: true, data: output };
|
|
293
|
-
}
|
|
294
|
-
async function resolveToolExtension(extension, keys, rawArgs, context) {
|
|
295
|
-
const extensionArgs = Object.fromEntries(Object.entries(rawArgs).filter(([key]) => keys.has(key)));
|
|
296
|
-
let parsed;
|
|
297
|
-
try {
|
|
298
|
-
parsed = extension.schema.safeParse(extensionArgs);
|
|
299
|
-
} catch (err) {
|
|
300
|
-
return { thrown: err };
|
|
301
|
-
}
|
|
302
|
-
if (!parsed.success)
|
|
303
|
-
return { invalid: formatZodError2(parsed.error) };
|
|
304
|
-
try {
|
|
305
|
-
const resolved = await extension.resolve({ ...rawArgs, ...parsed.data });
|
|
306
|
-
return {
|
|
307
|
-
context: {
|
|
308
|
-
...context,
|
|
309
|
-
...resolved,
|
|
310
|
-
source: context.source,
|
|
311
|
-
...context.mcp !== undefined && { mcp: context.mcp },
|
|
312
|
-
...context.toolCallId !== undefined && { toolCallId: context.toolCallId }
|
|
313
|
-
},
|
|
314
|
-
args: Object.fromEntries(Object.entries(rawArgs).filter(([key]) => !keys.has(key)))
|
|
315
|
-
};
|
|
316
|
-
} catch (err) {
|
|
317
|
-
return { thrown: err };
|
|
318
|
-
}
|
|
319
|
-
}
|
|
320
|
-
|
|
321
|
-
// src/tools/execute-result.ts
|
|
322
|
-
var normalizedToolErrors = new WeakMap;
|
|
323
|
-
function toolResultFromError(err) {
|
|
324
|
-
const appErr = normalizeError2(projectedToolError(err) ?? err, { logUnexpected: false });
|
|
325
|
-
const result = {
|
|
326
|
-
ok: false,
|
|
327
|
-
code: appErr.code,
|
|
328
|
-
details: appErr.details ?? { message: appErr.message },
|
|
329
|
-
...appErr.hint && { hint: appErr.hint },
|
|
330
|
-
retryable: appErr.retryable ?? isRetryableStatus2(appErr.status)
|
|
331
|
-
};
|
|
332
|
-
normalizedToolErrors.set(result, { normalized: appErr, cause: err });
|
|
333
|
-
return result;
|
|
334
|
-
}
|
|
335
|
-
function toolErrorFromResult(result) {
|
|
336
|
-
const retained = normalizedToolErrors.get(result);
|
|
337
|
-
if (retained)
|
|
338
|
-
return retained.normalized;
|
|
339
|
-
const details = isRecord(result.details) ? result.details : undefined;
|
|
340
|
-
const message = typeof details?.message === "string" ? details.message : result.code;
|
|
341
|
-
const status = isStitchErrorCode2(result.code) ? STITCH_ERROR_STATUS2[result.code] : 500;
|
|
342
|
-
return new AppError2(result.code, {
|
|
343
|
-
message,
|
|
344
|
-
status,
|
|
345
|
-
details,
|
|
346
|
-
hint: result.hint,
|
|
347
|
-
retryable: result.retryable
|
|
348
|
-
});
|
|
349
|
-
}
|
|
350
|
-
function toolCauseFromResult(result) {
|
|
351
|
-
return normalizedToolErrors.get(result)?.cause;
|
|
352
|
-
}
|
|
353
|
-
|
|
354
|
-
// src/tools/internal/observe-hook.ts
|
|
355
|
-
async function observed(hook, call) {
|
|
356
|
-
try {
|
|
357
|
-
await call();
|
|
358
|
-
} catch (hookError) {
|
|
359
|
-
try {
|
|
360
|
-
console.error(`[stitchkit] ${hook} hook failed:`, hookError);
|
|
361
|
-
} catch {}
|
|
362
|
-
}
|
|
363
|
-
}
|
|
364
|
-
|
|
365
|
-
// src/tools/execute.ts
|
|
366
|
-
class ToolExecutionControlError2 extends Error {
|
|
367
|
-
reason;
|
|
368
|
-
constructor(reason) {
|
|
369
|
-
super(`Agent tool execution stopped: ${reason}`);
|
|
370
|
-
this.name = "ToolExecutionControlError";
|
|
371
|
-
this.reason = reason;
|
|
372
|
-
}
|
|
373
|
-
}
|
|
374
|
-
function isPlainObject(value) {
|
|
375
|
-
if (!isRecord(value))
|
|
376
|
-
return false;
|
|
377
|
-
const proto = Object.getPrototypeOf(value);
|
|
378
|
-
return proto === Object.prototype || proto === null;
|
|
379
|
-
}
|
|
380
|
-
function isToolExecutionControlError2(value) {
|
|
381
|
-
return value instanceof ToolExecutionControlError2;
|
|
382
|
-
}
|
|
383
|
-
var noProgress = async () => {
|
|
384
|
-
return;
|
|
385
|
-
};
|
|
386
|
-
async function executeToolMethod(method, call, options = {}) {
|
|
387
|
-
const inspectErr = inspectOnlyError(options.lifecycle);
|
|
388
|
-
if (inspectErr)
|
|
389
|
-
return toolResultFromError(inspectErr);
|
|
390
|
-
const { toolName, context } = call;
|
|
391
|
-
return inToolCallContext({ source: context.source, toolName, method }, () => runToolMethod(method, call, options));
|
|
392
|
-
}
|
|
393
|
-
function inToolCallContext(call, body) {
|
|
394
|
-
const parent = getRequestContext2();
|
|
395
|
-
if (!parent)
|
|
396
|
-
return body();
|
|
397
|
-
return runWithRequestContext2({
|
|
398
|
-
...parent,
|
|
399
|
-
trace: parent.trace,
|
|
400
|
-
dimensions: parent.dimensions ? { ...parent.dimensions } : undefined,
|
|
401
|
-
error: undefined,
|
|
402
|
-
source: call.source,
|
|
403
|
-
method: "TOOL",
|
|
404
|
-
path: `/${call.source}/${call.toolName}`,
|
|
405
|
-
serviceName: call.method.serviceName,
|
|
406
|
-
action: call.method.key
|
|
407
|
-
}, body);
|
|
408
|
-
}
|
|
409
|
-
async function runToolMethod(method, { toolName, rawArgs, context }, {
|
|
410
|
-
hooks,
|
|
411
|
-
lifecycle,
|
|
412
|
-
coerceJson = false,
|
|
413
|
-
onOutputStrip,
|
|
414
|
-
extension,
|
|
415
|
-
finalizeOutput,
|
|
416
|
-
toolSurface = false
|
|
417
|
-
}) {
|
|
418
|
-
const startedAt = Date.now();
|
|
419
|
-
let hookContext = context;
|
|
420
|
-
const finish = async (result, thrown) => {
|
|
421
|
-
await observed("afterToolCall", () => hooks?.afterToolCall?.({
|
|
422
|
-
toolName,
|
|
423
|
-
args: rawArgs,
|
|
424
|
-
result,
|
|
425
|
-
durationMs: Date.now() - startedAt,
|
|
426
|
-
context: hookContext,
|
|
427
|
-
endpoint: method,
|
|
428
|
-
...thrown !== undefined && { error: thrown },
|
|
429
|
-
...rewrittenArgsApplied && rewrittenArgs !== undefined && { effectiveArgs: rewrittenArgs }
|
|
430
|
-
}));
|
|
431
|
-
return result;
|
|
432
|
-
};
|
|
433
|
-
let beforeRan = false;
|
|
434
|
-
let rewrittenArgs;
|
|
435
|
-
let rewrittenArgsApplied = false;
|
|
436
|
-
const runBefore = async () => {
|
|
437
|
-
if (beforeRan || !hooks?.beforeToolCall)
|
|
438
|
-
return null;
|
|
439
|
-
beforeRan = true;
|
|
440
|
-
let returned;
|
|
441
|
-
try {
|
|
442
|
-
returned = await hooks.beforeToolCall({
|
|
443
|
-
toolName,
|
|
444
|
-
args: rawArgs,
|
|
445
|
-
context: hookContext,
|
|
446
|
-
endpoint: method
|
|
447
|
-
});
|
|
448
|
-
} catch (err) {
|
|
449
|
-
return { kind: "failure", result: await finish(toolResultFromError(err)) };
|
|
450
|
-
}
|
|
451
|
-
if (!isPlainObject(returned))
|
|
452
|
-
return null;
|
|
453
|
-
rewrittenArgs = returned;
|
|
454
|
-
return { kind: "args" };
|
|
455
|
-
};
|
|
456
|
-
const finishThrown = async (err) => {
|
|
457
|
-
const before = await runBefore();
|
|
458
|
-
if (before?.kind === "failure")
|
|
459
|
-
return before.result;
|
|
460
|
-
await observed("onToolError", () => hooks?.onToolError?.({ toolName, error: err, context: hookContext, endpoint: method }));
|
|
461
|
-
return finish(toolResultFromError(err), err);
|
|
462
|
-
};
|
|
463
|
-
let callArgs = rawArgs;
|
|
464
|
-
let callContext = context;
|
|
465
|
-
let extensionKeys;
|
|
466
|
-
if (extension) {
|
|
467
|
-
extensionKeys = new Set(Object.keys(extension.schema.shape));
|
|
468
|
-
const resolved = await resolveToolExtension(extension, extensionKeys, rawArgs, context);
|
|
469
|
-
if ("thrown" in resolved)
|
|
470
|
-
return finishThrown(resolved.thrown);
|
|
471
|
-
if ("invalid" in resolved) {
|
|
472
|
-
const before = await runBefore();
|
|
473
|
-
if (before?.kind === "failure")
|
|
474
|
-
return before.result;
|
|
475
|
-
return finish({
|
|
476
|
-
ok: false,
|
|
477
|
-
code: "VALIDATION_ERROR",
|
|
478
|
-
details: { message: `Invalid tool extension: ${resolved.invalid}` }
|
|
479
|
-
});
|
|
480
|
-
}
|
|
481
|
-
callContext = resolved.context;
|
|
482
|
-
hookContext = callContext;
|
|
483
|
-
callArgs = resolved.args;
|
|
484
|
-
}
|
|
485
|
-
const before = await runBefore();
|
|
486
|
-
if (before?.kind === "failure")
|
|
487
|
-
return before.result;
|
|
488
|
-
if (before?.kind === "args" && rewrittenArgs) {
|
|
489
|
-
callArgs = extensionKeys ? Object.fromEntries(Object.entries(rewrittenArgs).filter(([key]) => !extensionKeys.has(key))) : rewrittenArgs;
|
|
490
|
-
rewrittenArgsApplied = true;
|
|
491
|
-
}
|
|
492
|
-
const parsed = parseToolCallArguments(method, callArgs, { coerceJson, toolSurface });
|
|
493
|
-
if (!parsed.ok) {
|
|
494
|
-
return parsed.thrown !== undefined ? finishThrown(parsed.thrown) : finish({ ok: false, code: "VALIDATION_ERROR", details: { message: parsed.message } });
|
|
495
|
-
}
|
|
496
|
-
const { params, input } = parsed;
|
|
497
|
-
try {
|
|
498
|
-
const ctx = {
|
|
499
|
-
reportProgress: noProgress,
|
|
500
|
-
...callContext,
|
|
501
|
-
params,
|
|
502
|
-
input,
|
|
503
|
-
source: context.source
|
|
504
|
-
};
|
|
505
|
-
return finish(await invokeToolHandler(method, ctx, input, context.source, {
|
|
506
|
-
lifecycle,
|
|
507
|
-
onOutputStrip,
|
|
508
|
-
finalizeOutput,
|
|
509
|
-
toolSurface
|
|
510
|
-
}));
|
|
511
|
-
} catch (err) {
|
|
512
|
-
if (isToolExecutionControlError2(err))
|
|
513
|
-
throw err;
|
|
514
|
-
return finishThrown(err);
|
|
515
|
-
}
|
|
516
|
-
}
|
|
517
|
-
|
|
518
|
-
// src/tools/mount.ts
|
|
519
|
-
import { z as z2 } from "zod";
|
|
520
|
-
function applyExtend(base, extra) {
|
|
521
|
-
if (base instanceof z2.ZodObject) {
|
|
522
|
-
assertToolExtensionCompatible(base, extra);
|
|
523
|
-
return rebuildObject(base, { ...extra, ...base.shape });
|
|
524
|
-
}
|
|
525
|
-
return z2.intersection(z2.object(extra), base);
|
|
526
|
-
}
|
|
527
|
-
function contractToolMountable(projected, extend) {
|
|
528
|
-
const method = projected.source;
|
|
529
|
-
const baseArgumentSchema = mergeSchemas(method.paramsSchema, method.inputSchema);
|
|
530
|
-
const argumentSchema = projected.shouldExtend && extend ? applyExtend(baseArgumentSchema, extend.schema) : baseArgumentSchema;
|
|
531
|
-
return {
|
|
532
|
-
method,
|
|
533
|
-
name: projected.name,
|
|
534
|
-
argumentSchema,
|
|
535
|
-
presentationSchema: projected.presentationSchema,
|
|
536
|
-
shouldExtend: projected.shouldExtend
|
|
537
|
-
};
|
|
538
|
-
}
|
|
539
|
-
function collectTools2(service, transport, config = {}) {
|
|
540
|
-
const {
|
|
541
|
-
extend,
|
|
542
|
-
flattenUnionInput = false,
|
|
543
|
-
inputRecursionDepth,
|
|
544
|
-
inputNestingDepth,
|
|
545
|
-
assertNames = true
|
|
546
|
-
} = config;
|
|
547
|
-
const tools = [];
|
|
548
|
-
for (const projected of projectToolSurface({ services: [service] }, transport === "HTTP" ? "AGENT" : transport, {
|
|
549
|
-
extend,
|
|
550
|
-
flattenUnionInput,
|
|
551
|
-
inputRecursionDepth,
|
|
552
|
-
inputNestingDepth,
|
|
553
|
-
assertNames,
|
|
554
|
-
assertUniqueNames: false
|
|
555
|
-
})) {
|
|
556
|
-
if (projected.kind !== "contract")
|
|
557
|
-
continue;
|
|
558
|
-
tools.push(contractToolMountable(projected, extend));
|
|
559
|
-
}
|
|
560
|
-
return tools;
|
|
561
|
-
}
|
|
562
|
-
function createToolRunner(config) {
|
|
563
|
-
const extension = config.extend ? {
|
|
564
|
-
schema: z2.object(config.extend.schema),
|
|
565
|
-
resolve: config.extend.resolve
|
|
566
|
-
} : undefined;
|
|
567
|
-
return async function runOneToolCall(tool, rawArgs, context, call) {
|
|
568
|
-
return executeToolMethod(tool.method, {
|
|
569
|
-
toolName: tool.name,
|
|
570
|
-
rawArgs,
|
|
571
|
-
context: { ...config.context, ...context, source: config.source }
|
|
572
|
-
}, {
|
|
573
|
-
hooks: config.hooks,
|
|
574
|
-
lifecycle: config.lifecycle,
|
|
575
|
-
coerceJson: config.coerceJsonArgs ?? true,
|
|
576
|
-
onOutputStrip: config.onOutputStrip ? (paths) => config.onOutputStrip?.(tool.name, paths) : undefined,
|
|
577
|
-
extension: tool.shouldExtend ? extension : undefined,
|
|
578
|
-
toolSurface: config.toolSurface ?? false,
|
|
579
|
-
finalizeOutput: call?.finalizeOutput
|
|
580
|
-
});
|
|
581
|
-
};
|
|
582
|
-
}
|
|
583
|
-
function formatToolError(result, toolName, errorHint) {
|
|
584
|
-
const err = {
|
|
585
|
-
error: result.code,
|
|
586
|
-
retryable: result.retryable ?? isRetryableStatus2(toolErrorFromResult(result).status)
|
|
587
|
-
};
|
|
588
|
-
if (result.details)
|
|
589
|
-
err.details = result.details;
|
|
590
|
-
const hints = [];
|
|
591
|
-
if (result.hint)
|
|
592
|
-
hints.push(result.hint);
|
|
593
|
-
if (errorHint && toolName) {
|
|
594
|
-
const global = errorHint(toolName, result.code);
|
|
595
|
-
if (global)
|
|
596
|
-
hints.push(global);
|
|
597
|
-
}
|
|
598
|
-
if (hints.length > 0)
|
|
599
|
-
err._hint = hints.join(" ");
|
|
600
|
-
return err;
|
|
601
|
-
}
|
|
602
|
-
|
|
603
|
-
export { isInspectOnlyLifecycle, inspectOnlyError, resolveToolAccess, resolveOptionalCliToolAccess, parseToolCallArguments, toolResultFromError, toolErrorFromResult, toolCauseFromResult, observed, ToolExecutionControlError2, isToolExecutionControlError2, contractToolMountable, collectTools2, createToolRunner, formatToolError };
|
package/dist/index-9vj869rx.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
redact2
|
|
3
|
-
} from "./index-28kbdn63.js";
|
|
4
|
-
|
|
5
|
-
// src/tools/internal/json-projection.ts
|
|
6
|
-
function projectJsonSafe(value, space) {
|
|
7
|
-
try {
|
|
8
|
-
const serialized = JSON.stringify(value, null, space);
|
|
9
|
-
if (serialized !== undefined)
|
|
10
|
-
return { value, text: serialized };
|
|
11
|
-
} catch {}
|
|
12
|
-
const safe = redact2(value, { sensitiveKeys: /(?!)/ });
|
|
13
|
-
return { value: safe, text: JSON.stringify(safe, null, space) ?? "null" };
|
|
14
|
-
}
|
|
15
|
-
function stringifyJsonSafe(value, space) {
|
|
16
|
-
return projectJsonSafe(value, space).text;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export { projectJsonSafe, stringifyJsonSafe };
|