stitchkit 0.127.0 → 0.129.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 +194 -6
- package/dist/agent-executor/acp/v1-connect.d.ts +9 -1
- package/dist/agent-executor/acp/v1-connect.d.ts.map +1 -1
- package/dist/agent-executor/acp/v1-driver.d.ts +8 -2
- package/dist/agent-executor/acp/v1-driver.d.ts.map +1 -1
- package/dist/agent-executor/acp/v1-map.d.ts.map +1 -1
- package/dist/agent-executor/acp/v1-session.d.ts +8 -0
- package/dist/agent-executor/acp/v1-session.d.ts.map +1 -1
- package/dist/agent-executor/claude/cli-driver.d.ts +4 -0
- package/dist/agent-executor/claude/cli-driver.d.ts.map +1 -1
- package/dist/agent-executor/claude/protocol.d.ts +20 -2
- package/dist/agent-executor/claude/protocol.d.ts.map +1 -1
- package/dist/agent-executor/claude/session.d.ts +2 -1
- package/dist/agent-executor/claude/session.d.ts.map +1 -1
- package/dist/agent-executor/claude/transcript.d.ts +9 -6
- package/dist/agent-executor/claude/transcript.d.ts.map +1 -1
- package/dist/agent-executor/claude-sdk/controls.d.ts +19 -0
- package/dist/agent-executor/claude-sdk/controls.d.ts.map +1 -0
- package/dist/agent-executor/claude-sdk/driver.d.ts +118 -4
- package/dist/agent-executor/claude-sdk/driver.d.ts.map +1 -1
- package/dist/agent-executor/claude-sdk/query-loop.d.ts +46 -0
- package/dist/agent-executor/claude-sdk/query-loop.d.ts.map +1 -0
- package/dist/agent-executor/claude-sdk/query-options.d.ts +27 -0
- package/dist/agent-executor/claude-sdk/query-options.d.ts.map +1 -0
- package/dist/agent-executor/claude-sdk/session.d.ts +6 -5
- package/dist/agent-executor/claude-sdk/session.d.ts.map +1 -1
- package/dist/agent-executor/codex/classify.d.ts.map +1 -1
- package/dist/agent-executor/codex/connect.d.ts +45 -0
- package/dist/agent-executor/codex/connect.d.ts.map +1 -0
- package/dist/agent-executor/codex/driver.d.ts +55 -10
- package/dist/agent-executor/codex/driver.d.ts.map +1 -1
- package/dist/agent-executor/codex/limits.d.ts +11 -2
- package/dist/agent-executor/codex/limits.d.ts.map +1 -1
- package/dist/agent-executor/codex/protocol.d.ts +75 -6
- package/dist/agent-executor/codex/protocol.d.ts.map +1 -1
- package/dist/agent-executor/codex/session-controls.d.ts +155 -0
- package/dist/agent-executor/codex/session-controls.d.ts.map +1 -0
- package/dist/agent-executor/codex/session.d.ts +28 -30
- package/dist/agent-executor/codex/session.d.ts.map +1 -1
- package/dist/agent-executor/codex/unix-socket-target.d.ts +26 -0
- package/dist/agent-executor/codex/unix-socket-target.d.ts.map +1 -0
- package/dist/agent-executor/codex/unix-socket.d.ts +26 -0
- package/dist/agent-executor/codex/unix-socket.d.ts.map +1 -0
- package/dist/agent-executor/codex/ws-frame.d.ts +15 -0
- package/dist/agent-executor/codex/ws-frame.d.ts.map +1 -0
- package/dist/agent-executor/contract.d.ts +2 -0
- package/dist/agent-executor/contract.d.ts.map +1 -1
- package/dist/agent-executor/engine-process.d.ts +9 -0
- package/dist/agent-executor/engine-process.d.ts.map +1 -1
- package/dist/agent-executor/hello.d.ts +8 -0
- package/dist/agent-executor/hello.d.ts.map +1 -1
- package/dist/agent-executor/image-input.d.ts +71 -0
- package/dist/agent-executor/image-input.d.ts.map +1 -0
- package/dist/agent-executor/session-primitives.d.ts +0 -3
- package/dist/agent-executor/session-primitives.d.ts.map +1 -1
- package/dist/agent-runtime/agent-tool.d.ts +21 -7
- package/dist/agent-runtime/agent-tool.d.ts.map +1 -1
- package/dist/agent-runtime/branch-contract.d.ts +1 -0
- package/dist/agent-runtime/branch-contract.d.ts.map +1 -1
- package/dist/agent-runtime/branch-identities.d.ts +5 -2
- package/dist/agent-runtime/branch-identities.d.ts.map +1 -1
- package/dist/agent-runtime/branch-messages.d.ts +9 -9
- package/dist/agent-runtime/branch-messages.d.ts.map +1 -1
- package/dist/agent-runtime/branch-observations.d.ts +49 -36
- package/dist/agent-runtime/branch-observations.d.ts.map +1 -1
- package/dist/agent-runtime/branch-provider.d.ts +14 -8
- package/dist/agent-runtime/branch-provider.d.ts.map +1 -1
- package/dist/agent-runtime/branch-source.d.ts +13 -1
- package/dist/agent-runtime/branch-source.d.ts.map +1 -1
- package/dist/agent-runtime/child-tools.d.ts +64 -0
- package/dist/agent-runtime/child-tools.d.ts.map +1 -1
- package/dist/agent-runtime/event-search-tools.d.ts +82 -5
- package/dist/agent-runtime/event-search-tools.d.ts.map +1 -1
- package/dist/agent-runtime/invocation-attempt.d.ts +1 -1
- package/dist/agent-runtime/invocation-attempt.d.ts.map +1 -1
- package/dist/agent-runtime/invocation-payload.d.ts +12 -0
- package/dist/agent-runtime/invocation-payload.d.ts.map +1 -1
- package/dist/agent-runtime/invocation-read.d.ts +6 -3
- package/dist/agent-runtime/invocation-read.d.ts.map +1 -1
- package/dist/agent-runtime/invocation-schema.d.ts +50 -8
- package/dist/agent-runtime/invocation-schema.d.ts.map +1 -1
- package/dist/agent-runtime/invocations.d.ts +20 -9
- package/dist/agent-runtime/invocations.d.ts.map +1 -1
- package/dist/agent-runtime/postgres.d.ts.map +1 -1
- package/dist/agent-runtime/schedule-tools.d.ts +30 -0
- package/dist/agent-runtime/schedule-tools.d.ts.map +1 -1
- package/dist/agent-runtime/schemas-invocation-payload.d.ts +48 -0
- package/dist/agent-runtime/schemas-invocation-payload.d.ts.map +1 -0
- package/dist/agent-runtime/sql-events.d.ts.map +1 -1
- package/dist/agent-runtime/sql-rows.d.ts +10 -10
- package/dist/agent-runtime/sql-session.d.ts +11 -0
- package/dist/agent-runtime/sql-session.d.ts.map +1 -1
- package/dist/agent-runtime/sqlite-transactions.d.ts.map +1 -1
- package/dist/agent-runtime/state-tools.d.ts +55 -0
- package/dist/agent-runtime/state-tools.d.ts.map +1 -1
- package/dist/agent-runtime/store-branch.d.ts.map +1 -1
- package/dist/agent-runtime/store-conformance-lifecycle.d.ts +20 -20
- package/dist/agent-runtime/store-conformance-support.d.ts +10 -10
- package/dist/agent-runtime/store-create.d.ts.map +1 -1
- package/dist/agent-runtime/store-driver-contract.d.ts +12 -0
- package/dist/agent-runtime/store-driver-contract.d.ts.map +1 -1
- package/dist/agent-runtime/store-memory-events.d.ts.map +1 -1
- package/dist/agent-runtime/store.d.ts +7 -0
- package/dist/agent-runtime/store.d.ts.map +1 -1
- package/dist/agent-runtime/terminal-commit.d.ts +10 -10
- package/dist/declaration/declaration.d.ts +6 -3
- package/dist/declaration/declaration.d.ts.map +1 -1
- package/dist/entrypoints/agent-executor/acp.d.ts +1 -1
- package/dist/entrypoints/agent-executor/acp.d.ts.map +1 -1
- package/dist/entrypoints/agent-executor/acp.js +28 -17
- package/dist/entrypoints/agent-executor/claude-sdk.d.ts +1 -1
- package/dist/entrypoints/agent-executor/claude-sdk.d.ts.map +1 -1
- package/dist/entrypoints/agent-executor/claude-sdk.js +543 -96
- package/dist/entrypoints/agent-executor/claude.js +40 -21
- package/dist/entrypoints/agent-executor/codex.d.ts +4 -0
- package/dist/entrypoints/agent-executor/codex.d.ts.map +1 -1
- package/dist/entrypoints/agent-executor/codex.js +1530 -207
- package/dist/entrypoints/agent-executor.js +7 -7
- package/dist/entrypoints/agent-runtime/browser.js +1 -1
- package/dist/entrypoints/agent-runtime/coding-tools.js +3 -3
- package/dist/entrypoints/agent-runtime/harness.js +10 -11
- package/dist/entrypoints/agent-runtime/openrouter.js +4 -4
- package/dist/entrypoints/agent-runtime/postgres.js +12 -7
- package/dist/entrypoints/agent-runtime/realtime.js +4 -4
- package/dist/entrypoints/agent-runtime/sandbox.js +7 -7
- package/dist/entrypoints/agent-runtime/sqlite/bun.js +7 -7
- package/dist/entrypoints/agent-runtime/sqlite/node.js +7 -7
- package/dist/entrypoints/agent-runtime/testing.js +9 -9
- package/dist/entrypoints/agent-runtime.d.ts +9 -7
- package/dist/entrypoints/agent-runtime.d.ts.map +1 -1
- package/dist/entrypoints/agent-runtime.js +254 -207
- package/dist/entrypoints/application/diagnostic-journal.js +4 -4
- package/dist/entrypoints/application/directory-inbox.js +8 -8
- package/dist/entrypoints/application/opentelemetry.js +2 -2
- package/dist/entrypoints/application.js +2 -2
- package/dist/entrypoints/cli/publish.js +8 -8
- package/dist/entrypoints/cli.js +12 -11
- package/dist/entrypoints/contract.js +2 -2
- package/dist/entrypoints/declaration.js +0 -1
- package/dist/entrypoints/files/packaging.js +2 -2
- package/dist/entrypoints/files.js +42 -19
- package/dist/entrypoints/handler.js +4 -4
- package/dist/entrypoints/http.js +5 -5
- package/dist/entrypoints/index.js +7 -7
- package/dist/entrypoints/node.js +7 -7
- package/dist/entrypoints/observability.js +4 -4
- package/dist/entrypoints/primitives.js +2 -2
- package/dist/entrypoints/process.js +6 -6
- package/dist/entrypoints/react.js +1 -1
- package/dist/entrypoints/remote.js +2 -2
- package/dist/entrypoints/server.js +10 -10
- package/dist/entrypoints/service-host/macos.js +6 -6
- package/dist/entrypoints/service-host.d.ts +4 -1
- package/dist/entrypoints/service-host.d.ts.map +1 -1
- package/dist/entrypoints/service-host.js +835 -224
- package/dist/entrypoints/spend.js +1 -1
- package/dist/entrypoints/sync/postgres.js +1 -1
- package/dist/entrypoints/sync.js +2 -2
- package/dist/entrypoints/telegram.js +5 -5
- package/dist/entrypoints/testing.js +5 -5
- package/dist/entrypoints/tools/agent.js +5 -4
- package/dist/entrypoints/tools/connections.js +2 -2
- package/dist/entrypoints/tools/invoker.js +4 -3
- package/dist/entrypoints/tools/mcp.js +5 -4
- package/dist/entrypoints/tools/toolkit.js +8 -7
- package/dist/entrypoints/tools.d.ts +1 -1
- package/dist/entrypoints/tools.d.ts.map +1 -1
- package/dist/entrypoints/tools.js +15 -13
- package/dist/entrypoints/tracking/contract.js +1 -1
- package/dist/entrypoints/xlsx.js +1 -1
- package/dist/files/directory-appearance.d.ts +20 -9
- package/dist/files/directory-appearance.d.ts.map +1 -1
- package/dist/files/polled-json.d.ts.map +1 -1
- package/dist/files/regular-file.d.ts +15 -5
- package/dist/files/regular-file.d.ts.map +1 -1
- package/dist/{index-prf6ayhf.js → index-13wmzpa6.js} +1 -1
- package/dist/{index-qnzhmk2s.js → index-17qgm6xe.js} +91 -48
- package/dist/{index-wv8dqy7q.js → index-205456mf.js} +1 -1
- package/dist/{index-3gwp8ez6.js → index-21cfxc4z.js} +13 -18
- package/dist/{index-xtkw9866.js → index-2c5w2d1d.js} +1 -1
- package/dist/{index-g1q7fwn9.js → index-2nwvn7m2.js} +1 -1
- package/dist/{index-d4svrknj.js → index-39c2hj6h.js} +2 -2
- package/dist/{index-sfzfd2m2.js → index-39rmc00v.js} +1 -1
- package/dist/{index-ky3ardqn.js → index-3fym4j8n.js} +1 -1
- package/dist/{index-d96c1n1q.js → index-5tdc0q43.js} +20 -19
- package/dist/{index-3ypvpkwr.js → index-669374qc.js} +1 -1
- package/dist/{index-x90w78yz.js → index-673drwkn.js} +23 -8
- package/dist/{index-83n766x4.js → index-7jqn3b3g.js} +16 -10
- package/dist/{index-5jyjb4s0.js → index-80acsm27.js} +1 -1
- package/dist/{index-xmr47znh.js → index-827bgv33.js} +1 -1
- package/dist/{index-xypxnzhp.js → index-93n6jwy0.js} +4 -4
- package/dist/{index-wbnpa8z6.js → index-9kpxz49v.js} +5 -5
- package/dist/{index-fcw255hd.js → index-9sfhje6y.js} +3 -3
- package/dist/{index-bh4pmtr9.js → index-afb6z77w.js} +3 -1
- package/dist/{index-9y0afd5f.js → index-apf5g7y9.js} +1 -1
- package/dist/{index-4qvyhn23.js → index-bjmj2q1z.js} +1 -1
- package/dist/{index-bbzvrq66.js → index-dcsxj68j.js} +457 -204
- package/dist/{index-j516jaaz.js → index-dnzxxf8a.js} +49 -2
- package/dist/{index-kmbpej2y.js → index-emgrmavr.js} +102 -61
- package/dist/index-fgahdc7s.js +100 -0
- package/dist/{index-kzavdze2.js → index-gr0kxymw.js} +5 -1
- package/dist/{index-e06z0tkb.js → index-gya4hwh3.js} +2 -2
- package/dist/{index-3djgv3ch.js → index-hab790s6.js} +26 -11
- package/dist/{index-j13gzgdv.js → index-j0ef04jw.js} +9 -5
- package/dist/{index-rhb33thr.js → index-jcge9tx3.js} +1 -1
- package/dist/{index-dvd1qdwa.js → index-ke02kxsr.js} +3 -3
- package/dist/{index-3agqmmrg.js → index-mkfhpk11.js} +7 -9
- package/dist/{index-a725ayvz.js → index-mttkdm5a.js} +1 -1
- package/dist/{index-9wh98cpa.js → index-n3bm7zqq.js} +131 -91
- package/dist/{index-7xp05h20.js → index-p06z7g7w.js} +7 -7
- package/dist/{index-kt6dh1n6.js → index-p16q492v.js} +1 -1
- package/dist/{index-5zwac8ft.js → index-pp97q86a.js} +3 -3
- package/dist/{index-39n02e0q.js → index-psye60qn.js} +1 -1
- package/dist/{index-5ptwb6ka.js → index-pzhqydxb.js} +1 -1
- package/dist/{index-7kfcb576.js → index-qa2jjb65.js} +1 -1
- package/dist/{index-0djnptn8.js → index-qhjmmsm2.js} +10 -3
- package/dist/{index-7grgs8cx.js → index-qpzyahe3.js} +2 -2
- package/dist/{index-8xr2eq99.js → index-r97ppg0g.js} +4 -4
- package/dist/{index-bmaz3jzy.js → index-rjs94dny.js} +1 -1
- package/dist/{index-p1m9djt6.js → index-rxh3qy4x.js} +33 -6
- package/dist/{index-en8e5zsj.js → index-ryxb427v.js} +1 -1
- package/dist/{index-nbv44x0x.js → index-s2e3h616.js} +137 -36
- package/dist/{index-dwa6pskj.js → index-sd4e5x5j.js} +86 -47
- package/dist/{index-g56ht6qf.js → index-t3qcac2a.js} +1 -1
- package/dist/index-vgzhw2zk.js +304 -0
- package/dist/{index-jrka9029.js → index-vmbxj75t.js} +2 -2
- package/dist/{index-caywx1c0.js → index-wv2amqm4.js} +109 -12
- package/dist/{index-5e0zsbf7.js → index-x2fb37t0.js} +2 -2
- package/dist/{index-z4k0hqp9.js → index-y71zn1gw.js} +137 -27
- package/dist/{index-wavv538x.js → index-ybdq8kk2.js} +3 -3
- package/dist/{index-4gk6k3zc.js → index-ycr4pk0z.js} +1 -1
- package/dist/{index-0tyt97nk.js → index-yrr3n391.js} +1 -1
- package/dist/{index-v37b2cd6.js → index-z20pdxeb.js} +2 -2
- package/dist/{index-0hdm5sx6.js → index-z9d74jmb.js} +8 -4
- package/dist/{index-4s2w4g37.js → index-zhshhxew.js} +80 -2
- package/dist/{index-3b31z0pc.js → index-znd1b57f.js} +12 -6
- package/dist/internal/bounded-file-confirm.d.ts +32 -0
- package/dist/internal/bounded-file-confirm.d.ts.map +1 -0
- package/dist/internal/bounded-file-read.d.ts +10 -7
- package/dist/internal/bounded-file-read.d.ts.map +1 -1
- package/dist/internal/file-observation.d.ts +5 -1
- package/dist/internal/file-observation.d.ts.map +1 -1
- package/dist/internal/positive-integer.d.ts +2 -0
- package/dist/internal/positive-integer.d.ts.map +1 -1
- package/dist/internal/process-instance.d.ts +8 -0
- package/dist/internal/process-instance.d.ts.map +1 -1
- package/dist/internal/unix-socket.d.ts +10 -1
- package/dist/internal/unix-socket.d.ts.map +1 -1
- package/dist/server/unix-client.d.ts +7 -0
- package/dist/server/unix-client.d.ts.map +1 -1
- package/dist/service-host/systemd-inspect.d.ts +3 -1
- package/dist/service-host/systemd-inspect.d.ts.map +1 -1
- package/dist/service-host/systemd-render-shared.d.ts +64 -0
- package/dist/service-host/systemd-render-shared.d.ts.map +1 -0
- package/dist/service-host/systemd-render.d.ts +31 -26
- package/dist/service-host/systemd-render.d.ts.map +1 -1
- package/dist/service-host/systemd-timer-render.d.ts +31 -0
- package/dist/service-host/systemd-timer-render.d.ts.map +1 -0
- package/dist/service-host/systemd-timer-rollback.d.ts +26 -0
- package/dist/service-host/systemd-timer-rollback.d.ts.map +1 -0
- package/dist/service-host/systemd-timer.d.ts +82 -0
- package/dist/service-host/systemd-timer.d.ts.map +1 -0
- package/dist/service-host/systemd-unit-ops.d.ts +26 -0
- package/dist/service-host/systemd-unit-ops.d.ts.map +1 -0
- package/dist/service-host/systemd.d.ts +1 -1
- package/dist/service-host/systemd.d.ts.map +1 -1
- package/dist/tools/access.d.ts +30 -1
- package/dist/tools/access.d.ts.map +1 -1
- package/dist/tools/agent.d.ts +2 -2
- package/dist/tools/agent.d.ts.map +1 -1
- package/dist/tools/cli/args-scan.d.ts +5 -0
- package/dist/tools/cli/args-scan.d.ts.map +1 -1
- package/dist/tools/cli/args.d.ts +11 -5
- package/dist/tools/cli/args.d.ts.map +1 -1
- package/dist/tools/cli/invoke.d.ts +2 -1
- package/dist/tools/cli/invoke.d.ts.map +1 -1
- package/dist/tools/cli/notices.d.ts.map +1 -1
- package/dist/tools/cli/run-managed.d.ts.map +1 -1
- package/dist/tools/cli/session.d.ts.map +1 -1
- package/dist/tools/execute.d.ts.map +1 -1
- package/dist/tools/invoker.d.ts +2 -1
- package/dist/tools/invoker.d.ts.map +1 -1
- package/dist/tools/list-names.d.ts +2 -3
- package/dist/tools/list-names.d.ts.map +1 -1
- package/dist/tools/manifest.d.ts +2 -3
- package/dist/tools/manifest.d.ts.map +1 -1
- package/dist/tools/mcp/mount.d.ts +5 -5
- package/dist/tools/mcp/mount.d.ts.map +1 -1
- package/dist/tools/mcp/register.d.ts +2 -1
- package/dist/tools/mcp/register.d.ts.map +1 -1
- package/dist/tools/mcp/runtime-tools.d.ts.map +1 -1
- package/llms/agent-executor-acp.txt +10 -6
- package/llms/agent-executor-claude-sdk.txt +13 -10
- package/llms/agent-executor-claude.txt +2 -2
- package/llms/agent-executor-codex.txt +9 -3
- package/llms/agent-executor.txt +2 -2
- package/llms/agent-runtime.4.txt +21 -9
- package/llms/cli.3.txt +4 -4
- package/llms/cli.txt +1 -0
- package/llms/declaration.txt +2 -2
- package/llms/files.txt +1 -1
- package/llms/node.txt +2 -2
- package/llms/server.5.txt +2 -2
- package/llms/service-host.txt +5 -5
- package/llms/stitchkit.txt +81 -77
- package/llms/tools.3.txt +3 -2
- package/llms/upgrading-0.128.0-0.129.0.txt +175 -0
- package/llms/upgrading.txt +1 -0
- package/llms-full.txt +323 -127
- package/llms.txt +15 -14
- package/package.json +1 -1
- package/dist/index-ajmtxsky.js +0 -193
- package/dist/index-ax3wns1a.js +0 -93
|
@@ -11,15 +11,21 @@ import {
|
|
|
11
11
|
AgentSeedReceiptSchema2,
|
|
12
12
|
AgentHistoryMutationSchema2,
|
|
13
13
|
isActiveRunState,
|
|
14
|
-
AgentRecoverablePageSchema2
|
|
14
|
+
AgentRecoverablePageSchema2,
|
|
15
|
+
canonicalAgentJson2
|
|
15
16
|
} from "./index-9xr44d2g.js";
|
|
17
|
+
import {
|
|
18
|
+
InvocationExpiredPayloadSchema,
|
|
19
|
+
parsePayloadPurgeCutoff,
|
|
20
|
+
redactLiveInvocationPayload
|
|
21
|
+
} from "./index-vgzhw2zk.js";
|
|
16
22
|
import {
|
|
17
23
|
ArchiveProjectionSchema,
|
|
18
24
|
isRuntimeSnapshotEntry,
|
|
19
25
|
replaceMessage,
|
|
20
26
|
ArchiveSpillSchema,
|
|
21
27
|
createAgentRuntimeStore2
|
|
22
|
-
} from "./index-
|
|
28
|
+
} from "./index-dcsxj68j.js";
|
|
23
29
|
|
|
24
30
|
// src/agent-runtime/store-memory.ts
|
|
25
31
|
import { z as z2 } from "zod";
|
|
@@ -75,6 +81,47 @@ var memoryEvents = {
|
|
|
75
81
|
},
|
|
76
82
|
async find(transaction, input) {
|
|
77
83
|
return (transaction.events.get(input.conversationId) ?? []).find((event) => event.eventId === input.eventId);
|
|
84
|
+
},
|
|
85
|
+
async redactExpiredPayloads(transaction, input) {
|
|
86
|
+
const cutoffEpoch = parsePayloadPurgeCutoff(input.before);
|
|
87
|
+
const conversationIds = input.conversationId !== undefined ? [input.conversationId] : [...transaction.events.keys()].sort();
|
|
88
|
+
const eligible = [];
|
|
89
|
+
for (const conversationId of conversationIds) {
|
|
90
|
+
const list = transaction.events.get(conversationId);
|
|
91
|
+
if (!list)
|
|
92
|
+
continue;
|
|
93
|
+
for (const [index, event] of list.entries()) {
|
|
94
|
+
if (event.kind !== "provider/payload")
|
|
95
|
+
continue;
|
|
96
|
+
if (InvocationExpiredPayloadSchema.safeParse(event.payload).success)
|
|
97
|
+
continue;
|
|
98
|
+
if (Date.parse(event.occurredAt) < cutoffEpoch) {
|
|
99
|
+
eligible.push({ conversationId, index, event });
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
eligible.sort((a, b) => a.event.occurredAt.localeCompare(b.event.occurredAt) || a.conversationId.localeCompare(b.conversationId) || a.event.seq - b.event.seq);
|
|
104
|
+
const hasMore = eligible.length > input.limit;
|
|
105
|
+
const toPurge = eligible.slice(0, input.limit);
|
|
106
|
+
let freedBytes = 0;
|
|
107
|
+
const updatedLists = new Map;
|
|
108
|
+
for (const entry of toPurge) {
|
|
109
|
+
const expired = redactLiveInvocationPayload(entry.event.payload, input.expiredAt);
|
|
110
|
+
if (expired === undefined)
|
|
111
|
+
continue;
|
|
112
|
+
const beforeBytes = Buffer.byteLength(canonicalAgentJson2(entry.event.payload));
|
|
113
|
+
const afterBytes = Buffer.byteLength(canonicalAgentJson2(expired));
|
|
114
|
+
freedBytes += Math.max(0, beforeBytes - afterBytes);
|
|
115
|
+
const list = updatedLists.get(entry.conversationId) ?? [
|
|
116
|
+
...transaction.events.get(entry.conversationId) ?? []
|
|
117
|
+
];
|
|
118
|
+
list[entry.index] = { ...entry.event, payload: expired };
|
|
119
|
+
updatedLists.set(entry.conversationId, list);
|
|
120
|
+
}
|
|
121
|
+
for (const [conversationId, list] of updatedLists) {
|
|
122
|
+
transaction.events.set(conversationId, list);
|
|
123
|
+
}
|
|
124
|
+
return { purged: toPurge.length, freedBytes, hasMore };
|
|
78
125
|
}
|
|
79
126
|
};
|
|
80
127
|
|
|
@@ -11,10 +11,10 @@ import {
|
|
|
11
11
|
AgentProviderResponseSchema2
|
|
12
12
|
} from "./index-97rp94ff.js";
|
|
13
13
|
import {
|
|
14
|
-
ModelInvocationTraceSchema2,
|
|
15
14
|
InvocationPayloadSchema,
|
|
15
|
+
ModelInvocationTraceSchema2,
|
|
16
16
|
assistantStatus
|
|
17
|
-
} from "./index-
|
|
17
|
+
} from "./index-vgzhw2zk.js";
|
|
18
18
|
import {
|
|
19
19
|
agentDurableEventId2
|
|
20
20
|
} from "./index-paff5y0r.js";
|
|
@@ -688,6 +688,19 @@ function invocationJson(value) {
|
|
|
688
688
|
function invocationHash(value) {
|
|
689
689
|
return createHash("sha256").update(serializeCanonicalJson(invocationJson(value))).digest("hex");
|
|
690
690
|
}
|
|
691
|
+
|
|
692
|
+
class InvocationPayloadTooLargeError2 extends RangeError {
|
|
693
|
+
bytes;
|
|
694
|
+
maxBytes;
|
|
695
|
+
sha256;
|
|
696
|
+
constructor(bytes, maxBytes, sha256) {
|
|
697
|
+
super(`Invocation payload (${bytes} bytes) exceeds maxPayloadBytes (${maxBytes})`);
|
|
698
|
+
this.name = "InvocationPayloadTooLargeError";
|
|
699
|
+
this.bytes = bytes;
|
|
700
|
+
this.maxBytes = maxBytes;
|
|
701
|
+
this.sha256 = sha256;
|
|
702
|
+
}
|
|
703
|
+
}
|
|
691
704
|
function createInvocationPayloads(store, key, maxBytes) {
|
|
692
705
|
if (key.byteLength !== 32)
|
|
693
706
|
throw new TypeError("Invocation payload key must contain 32 bytes");
|
|
@@ -696,10 +709,11 @@ function createInvocationPayloads(store, key, maxBytes) {
|
|
|
696
709
|
maxBytes,
|
|
697
710
|
async write(identity, value) {
|
|
698
711
|
const data = Buffer.from(serializeCanonicalJson(invocationJson(value)));
|
|
699
|
-
if (data.byteLength > maxBytes)
|
|
700
|
-
throw new RangeError("Invocation payload exceeds maxPayloadBytes");
|
|
701
|
-
const artifactId = randomUUID();
|
|
702
712
|
const sha256 = createHash("sha256").update(data).digest("hex");
|
|
713
|
+
if (data.byteLength > maxBytes) {
|
|
714
|
+
throw new InvocationPayloadTooLargeError2(data.byteLength, maxBytes, sha256);
|
|
715
|
+
}
|
|
716
|
+
const artifactId = randomUUID();
|
|
703
717
|
const iv = randomBytes(12);
|
|
704
718
|
const cipher = createCipheriv("aes-256-gcm", encryptionKey, iv);
|
|
705
719
|
cipher.setAAD(Buffer.from(JSON.stringify([identity.conversationId, identity.invocationId, artifactId])));
|
|
@@ -794,7 +808,16 @@ function wrapInvocationModel(writer, selected, step, model = selected.model) {
|
|
|
794
808
|
const begin = async (params) => invocationAudit(async () => {
|
|
795
809
|
const context = { ...writer.identity, step, attemptId: randomUUID2() };
|
|
796
810
|
const { headers: _headers, abortSignal: _signal, ...payload } = params;
|
|
797
|
-
|
|
811
|
+
let artifact;
|
|
812
|
+
let omittedSha256;
|
|
813
|
+
try {
|
|
814
|
+
artifact = await writer.payloads.write(writer.identity, payload);
|
|
815
|
+
} catch (error) {
|
|
816
|
+
if (!(error instanceof InvocationPayloadTooLargeError2))
|
|
817
|
+
throw error;
|
|
818
|
+
writer.receiptErrors.push(error);
|
|
819
|
+
omittedSha256 = error.sha256;
|
|
820
|
+
}
|
|
798
821
|
await writer.append({
|
|
799
822
|
...writer.identity,
|
|
800
823
|
type: "provider/request",
|
|
@@ -808,8 +831,8 @@ function wrapInvocationModel(writer, selected, step, model = selected.model) {
|
|
|
808
831
|
sent: {
|
|
809
832
|
modelId: model.modelId,
|
|
810
833
|
provider: model.provider,
|
|
811
|
-
payloadSha256: artifact.sha256,
|
|
812
|
-
artifactId: artifact.artifactId,
|
|
834
|
+
payloadSha256: artifact ? artifact.sha256 : omittedSha256 ?? "",
|
|
835
|
+
...artifact ? { artifactId: artifact.artifactId } : { payloadOmitted: "max-payload-bytes" },
|
|
813
836
|
tools: params.tools?.length ?? 0
|
|
814
837
|
}
|
|
815
838
|
});
|
|
@@ -825,7 +848,16 @@ function wrapInvocationModel(writer, selected, step, model = selected.model) {
|
|
|
825
848
|
writer.receiptErrors.push(error);
|
|
826
849
|
});
|
|
827
850
|
const recordResponse = async (context, status, payload, usage, response, providerMetadata) => invocationAudit(async () => {
|
|
828
|
-
|
|
851
|
+
let artifact;
|
|
852
|
+
let omittedSha256;
|
|
853
|
+
try {
|
|
854
|
+
artifact = await writer.payloads.write(writer.identity, boundedEvidence(payload, Math.floor(writer.payloads.maxBytes / 2)));
|
|
855
|
+
} catch (error) {
|
|
856
|
+
if (!(error instanceof InvocationPayloadTooLargeError2))
|
|
857
|
+
throw error;
|
|
858
|
+
writer.receiptErrors.push(error);
|
|
859
|
+
omittedSha256 = error.sha256;
|
|
860
|
+
}
|
|
829
861
|
await writer.append({
|
|
830
862
|
...writer.identity,
|
|
831
863
|
type: "provider/response",
|
|
@@ -838,8 +870,8 @@ function wrapInvocationModel(writer, selected, step, model = selected.model) {
|
|
|
838
870
|
responseId: response?.id ?? null
|
|
839
871
|
},
|
|
840
872
|
usage: reportedUsage(selected, usage, providerMetadata),
|
|
841
|
-
artifactId: artifact.artifactId,
|
|
842
|
-
payloadSha256: artifact.sha256
|
|
873
|
+
...artifact ? { artifactId: artifact.artifactId } : { payloadOmitted: "max-payload-bytes" },
|
|
874
|
+
payloadSha256: artifact ? artifact.sha256 : omittedSha256 ?? ""
|
|
843
875
|
});
|
|
844
876
|
});
|
|
845
877
|
return wrapLanguageModel({
|
|
@@ -879,59 +911,68 @@ function wrapInvocationModel(writer, selected, step, model = selected.model) {
|
|
|
879
911
|
});
|
|
880
912
|
throw markProviderOrigin(error);
|
|
881
913
|
}
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
if (ended)
|
|
889
|
-
return;
|
|
890
|
-
ended = true;
|
|
891
|
-
await finish(context, status, evidence.payload(value), usage, response, metadata);
|
|
892
|
-
};
|
|
893
|
-
return {
|
|
894
|
-
...result,
|
|
895
|
-
stream: new ReadableStream({
|
|
896
|
-
async pull(controller) {
|
|
897
|
-
let next;
|
|
898
|
-
try {
|
|
899
|
-
next = await currentAttempt.run(context, () => reader.read());
|
|
900
|
-
} catch (error) {
|
|
901
|
-
await end(params.abortSignal?.aborted ? "cancelled" : "failed", { error });
|
|
902
|
-
controller.error(markProviderOrigin(error));
|
|
903
|
-
return;
|
|
904
|
-
}
|
|
905
|
-
if (next.done) {
|
|
906
|
-
await end("failed", { reason: "stream-ended-without-finish" });
|
|
907
|
-
controller.close();
|
|
908
|
-
return;
|
|
909
|
-
}
|
|
910
|
-
const part = next.value;
|
|
911
|
-
if (part.type === "response-metadata")
|
|
912
|
-
response = part;
|
|
913
|
-
if (part.type === "finish") {
|
|
914
|
-
await end(failed || part.finishReason.unified === "error" ? "failed" : "succeeded", part, part.usage, part.providerMetadata);
|
|
915
|
-
} else {
|
|
916
|
-
if (part.type === "error")
|
|
917
|
-
failed = true;
|
|
918
|
-
evidence.record(part);
|
|
919
|
-
}
|
|
920
|
-
controller.enqueue(part);
|
|
921
|
-
},
|
|
922
|
-
async cancel(reason) {
|
|
923
|
-
try {
|
|
924
|
-
await currentAttempt.run(context, () => reader.cancel(reason));
|
|
925
|
-
} finally {
|
|
926
|
-
await end("cancelled", { reason: "consumer-cancelled" });
|
|
927
|
-
}
|
|
928
|
-
}
|
|
929
|
-
})
|
|
930
|
-
};
|
|
914
|
+
return wrapInvocationStreamResult(result, {
|
|
915
|
+
context,
|
|
916
|
+
abortSignal: params.abortSignal,
|
|
917
|
+
maxEvidenceBytes: Math.floor(writer.payloads.maxBytes / 2),
|
|
918
|
+
finish
|
|
919
|
+
});
|
|
931
920
|
}
|
|
932
921
|
}
|
|
933
922
|
});
|
|
934
923
|
}
|
|
924
|
+
function wrapInvocationStreamResult(result, options) {
|
|
925
|
+
const { context, abortSignal, maxEvidenceBytes, finish } = options;
|
|
926
|
+
const reader = result.stream.getReader();
|
|
927
|
+
let ended = false;
|
|
928
|
+
let failed = false;
|
|
929
|
+
let response;
|
|
930
|
+
const evidence = streamEvidence(maxEvidenceBytes);
|
|
931
|
+
const end = async (status, value, usage, metadata) => {
|
|
932
|
+
if (ended)
|
|
933
|
+
return;
|
|
934
|
+
ended = true;
|
|
935
|
+
await finish(context, status, evidence.payload(value), usage, response, metadata);
|
|
936
|
+
};
|
|
937
|
+
return {
|
|
938
|
+
...result,
|
|
939
|
+
stream: new ReadableStream({
|
|
940
|
+
async pull(controller) {
|
|
941
|
+
let next;
|
|
942
|
+
try {
|
|
943
|
+
next = await currentAttempt.run(context, () => reader.read());
|
|
944
|
+
} catch (error) {
|
|
945
|
+
await end(abortSignal?.aborted ? "cancelled" : "failed", { error });
|
|
946
|
+
controller.error(markProviderOrigin(error));
|
|
947
|
+
return;
|
|
948
|
+
}
|
|
949
|
+
if (next.done) {
|
|
950
|
+
await end("failed", { reason: "stream-ended-without-finish" });
|
|
951
|
+
controller.close();
|
|
952
|
+
return;
|
|
953
|
+
}
|
|
954
|
+
const part = next.value;
|
|
955
|
+
if (part.type === "response-metadata")
|
|
956
|
+
response = part;
|
|
957
|
+
if (part.type === "finish") {
|
|
958
|
+
await end(failed || part.finishReason.unified === "error" ? "failed" : "succeeded", part, part.usage, part.providerMetadata);
|
|
959
|
+
} else {
|
|
960
|
+
if (part.type === "error")
|
|
961
|
+
failed = true;
|
|
962
|
+
evidence.record(part);
|
|
963
|
+
}
|
|
964
|
+
controller.enqueue(part);
|
|
965
|
+
},
|
|
966
|
+
async cancel(reason) {
|
|
967
|
+
try {
|
|
968
|
+
await currentAttempt.run(context, () => reader.cancel(reason));
|
|
969
|
+
} finally {
|
|
970
|
+
await end("cancelled", { reason: "consumer-cancelled" });
|
|
971
|
+
}
|
|
972
|
+
}
|
|
973
|
+
})
|
|
974
|
+
};
|
|
975
|
+
}
|
|
935
976
|
function boundedEvidence(payload, limit) {
|
|
936
977
|
const serialized = JSON.stringify(invocationJson(payload));
|
|
937
978
|
const bytes = Buffer.byteLength(serialized);
|
|
@@ -1149,4 +1190,4 @@ function validateAgentModelSnapshot2(input, policy) {
|
|
|
1149
1190
|
return snapshot;
|
|
1150
1191
|
}
|
|
1151
1192
|
|
|
1152
|
-
export { withStoreRetries, AgentRuntimeConflictError2, AgentRunUnsettledError2, appliedSnapshot, terminalOfSnapshot, terminalOfRunView, commitAgentRunTerminal, findRun, jsonValue, providerEnvelope, providerResponseIdentity, appendText, abortTerminalReason, addUsage, mergeModelTotals, statedUsage, unknownUsage, normalizeSdkUsage, createIdleDeadline, adoptSnapshot, transientSequence, runUsage, updateReasoning, checkpoint, DEFAULT_STEP_SPEND_TIMEOUT_MS, AgentStepSpendPhaseSchema2, AgentStepSpendProviderSchema, AgentStepSpendSchema2, normalizeStepUsage, recordStepSpend, InvocationReceiptError, invocationHash, createInvocationPayloads, isOwnInputRefusal, markProviderOrigin, hasProviderOrigin, markProviderStream, currentModelInvocationAttempt2, wrapInvocationModel, AgentModelCapabilitySchema2, AgentModelDescriptorSchema2, AgentModelRegistrySnapshotSchema2, AgentModelPriceSchema2, AgentModelMetricSchema2, AgentModelPopularitySchema2, AgentModelCatalogEntrySchema2, AgentModelCatalogSchema2, AgentModelSelectionSchema2, AgentModelSearchInputSchema2, AgentModelSearchResultSchema2, searchAgentModelCatalog2, createMemoryAgentModelSelectionStore2, defineModelRegistry2, validateAgentModelSnapshot2 };
|
|
1193
|
+
export { withStoreRetries, AgentRuntimeConflictError2, AgentRunUnsettledError2, appliedSnapshot, terminalOfSnapshot, terminalOfRunView, commitAgentRunTerminal, findRun, jsonValue, providerEnvelope, providerResponseIdentity, appendText, abortTerminalReason, addUsage, mergeModelTotals, statedUsage, unknownUsage, normalizeSdkUsage, createIdleDeadline, adoptSnapshot, transientSequence, runUsage, updateReasoning, checkpoint, DEFAULT_STEP_SPEND_TIMEOUT_MS, AgentStepSpendPhaseSchema2, AgentStepSpendProviderSchema, AgentStepSpendSchema2, normalizeStepUsage, recordStepSpend, InvocationReceiptError, invocationHash, InvocationPayloadTooLargeError2, createInvocationPayloads, isOwnInputRefusal, markProviderOrigin, hasProviderOrigin, markProviderStream, currentModelInvocationAttempt2, wrapInvocationModel, AgentModelCapabilitySchema2, AgentModelDescriptorSchema2, AgentModelRegistrySnapshotSchema2, AgentModelPriceSchema2, AgentModelMetricSchema2, AgentModelPopularitySchema2, AgentModelCatalogEntrySchema2, AgentModelCatalogSchema2, AgentModelSelectionSchema2, AgentModelSearchInputSchema2, AgentModelSearchResultSchema2, searchAgentModelCatalog2, createMemoryAgentModelSelectionStore2, defineModelRegistry2, validateAgentModelSnapshot2 };
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import {
|
|
2
|
+
rebuildObject,
|
|
3
|
+
mergeSchemas
|
|
4
|
+
} from "./index-360j58vb.js";
|
|
5
|
+
import {
|
|
6
|
+
toolErrorFromResult,
|
|
7
|
+
executeToolMethod
|
|
8
|
+
} from "./index-n3bm7zqq.js";
|
|
9
|
+
import {
|
|
10
|
+
assertToolExtensionCompatible,
|
|
11
|
+
projectToolSurface
|
|
12
|
+
} from "./index-669374qc.js";
|
|
13
|
+
import {
|
|
14
|
+
isRetryableStatus2
|
|
15
|
+
} from "./index-9pv126eh.js";
|
|
16
|
+
|
|
17
|
+
// src/tools/mount.ts
|
|
18
|
+
import { z } from "zod";
|
|
19
|
+
function applyExtend(base, extra) {
|
|
20
|
+
if (base instanceof z.ZodObject) {
|
|
21
|
+
assertToolExtensionCompatible(base, extra);
|
|
22
|
+
return rebuildObject(base, { ...extra, ...base.shape });
|
|
23
|
+
}
|
|
24
|
+
return z.intersection(z.object(extra), base);
|
|
25
|
+
}
|
|
26
|
+
function contractToolMountable(projected, extend) {
|
|
27
|
+
const method = projected.source;
|
|
28
|
+
const baseArgumentSchema = mergeSchemas(method.paramsSchema, method.inputSchema);
|
|
29
|
+
const argumentSchema = projected.shouldExtend && extend ? applyExtend(baseArgumentSchema, extend.schema) : baseArgumentSchema;
|
|
30
|
+
return {
|
|
31
|
+
method,
|
|
32
|
+
name: projected.name,
|
|
33
|
+
argumentSchema,
|
|
34
|
+
presentationSchema: projected.presentationSchema,
|
|
35
|
+
shouldExtend: projected.shouldExtend
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
function collectTools2(service, transport, config = {}) {
|
|
39
|
+
const {
|
|
40
|
+
extend,
|
|
41
|
+
flattenUnionInput = false,
|
|
42
|
+
inputRecursionDepth,
|
|
43
|
+
assertNames = true
|
|
44
|
+
} = config;
|
|
45
|
+
const tools = [];
|
|
46
|
+
for (const projected of projectToolSurface({ services: [service] }, transport === "HTTP" ? "AGENT" : transport, {
|
|
47
|
+
extend,
|
|
48
|
+
flattenUnionInput,
|
|
49
|
+
inputRecursionDepth,
|
|
50
|
+
assertNames,
|
|
51
|
+
assertUniqueNames: false
|
|
52
|
+
})) {
|
|
53
|
+
if (projected.kind !== "contract")
|
|
54
|
+
continue;
|
|
55
|
+
tools.push(contractToolMountable(projected, extend));
|
|
56
|
+
}
|
|
57
|
+
return tools;
|
|
58
|
+
}
|
|
59
|
+
function createToolRunner(config) {
|
|
60
|
+
const extension = config.extend ? {
|
|
61
|
+
schema: z.object(config.extend.schema),
|
|
62
|
+
resolve: config.extend.resolve
|
|
63
|
+
} : undefined;
|
|
64
|
+
return async function runOneToolCall(tool, rawArgs, context, call) {
|
|
65
|
+
return executeToolMethod(tool.method, {
|
|
66
|
+
toolName: tool.name,
|
|
67
|
+
rawArgs,
|
|
68
|
+
context: { ...config.context, ...context, source: config.source }
|
|
69
|
+
}, {
|
|
70
|
+
hooks: config.hooks,
|
|
71
|
+
lifecycle: config.lifecycle,
|
|
72
|
+
coerceJson: config.coerceJsonArgs ?? true,
|
|
73
|
+
onOutputStrip: config.onOutputStrip ? (paths) => config.onOutputStrip?.(tool.name, paths) : undefined,
|
|
74
|
+
extension: tool.shouldExtend ? extension : undefined,
|
|
75
|
+
toolSurface: config.toolSurface ?? false,
|
|
76
|
+
finalizeOutput: call?.finalizeOutput
|
|
77
|
+
});
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
function formatToolError(result, toolName, errorHint) {
|
|
81
|
+
const err = {
|
|
82
|
+
error: result.code,
|
|
83
|
+
retryable: result.retryable ?? isRetryableStatus2(toolErrorFromResult(result).status)
|
|
84
|
+
};
|
|
85
|
+
if (result.details)
|
|
86
|
+
err.details = result.details;
|
|
87
|
+
const hints = [];
|
|
88
|
+
if (result.hint)
|
|
89
|
+
hints.push(result.hint);
|
|
90
|
+
if (errorHint && toolName) {
|
|
91
|
+
const global = errorHint(toolName, result.code);
|
|
92
|
+
if (global)
|
|
93
|
+
hints.push(global);
|
|
94
|
+
}
|
|
95
|
+
if (hints.length > 0)
|
|
96
|
+
err._hint = hints.join(" ");
|
|
97
|
+
return err;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
export { contractToolMountable, collectTools2, createToolRunner, formatToolError };
|
|
@@ -5,6 +5,10 @@ function assertSafeIntegerFrom(least, rule, name, value, errorType, options) {
|
|
|
5
5
|
if (typeof value !== "number" || !Number.isSafeInteger(value) || value < least)
|
|
6
6
|
throw new errorType(`${name} ${rule}, received ${value}`);
|
|
7
7
|
}
|
|
8
|
+
function isPositiveSafeInteger(value) {
|
|
9
|
+
const least = 1;
|
|
10
|
+
return typeof value === "number" && Number.isSafeInteger(value) && value >= least;
|
|
11
|
+
}
|
|
8
12
|
function assertPositiveSafeInteger(name, value, errorType = TypeError, options = {}) {
|
|
9
13
|
assertSafeIntegerFrom(1, "must be a positive safe integer", name, value, errorType, options);
|
|
10
14
|
}
|
|
@@ -12,4 +16,4 @@ function assertNonNegativeSafeInteger(name, value, errorType = TypeError, option
|
|
|
12
16
|
assertSafeIntegerFrom(0, "must be a non-negative safe integer", name, value, errorType, options);
|
|
13
17
|
}
|
|
14
18
|
|
|
15
|
-
export { assertPositiveSafeInteger, assertNonNegativeSafeInteger };
|
|
19
|
+
export { isPositiveSafeInteger, assertPositiveSafeInteger, assertNonNegativeSafeInteger };
|
|
@@ -19,12 +19,12 @@ import {
|
|
|
19
19
|
isAbortLikeError,
|
|
20
20
|
classifyUnixTransportRetry,
|
|
21
21
|
parseApiErrorBody
|
|
22
|
-
} from "./index-
|
|
22
|
+
} from "./index-jcge9tx3.js";
|
|
23
23
|
import {
|
|
24
24
|
DEFAULT_STREAM_LINE_BYTES,
|
|
25
25
|
createBoundedLineDecoder,
|
|
26
26
|
readBoundedUtf8Lines
|
|
27
|
-
} from "./index-
|
|
27
|
+
} from "./index-39rmc00v.js";
|
|
28
28
|
import {
|
|
29
29
|
inputIsQuery
|
|
30
30
|
} from "./index-xhzq2qvj.js";
|
|
@@ -1,20 +1,23 @@
|
|
|
1
1
|
import {
|
|
2
2
|
machineIdentitySync,
|
|
3
3
|
readProcessInstanceSync
|
|
4
|
-
} from "./index-
|
|
4
|
+
} from "./index-673drwkn.js";
|
|
5
5
|
import {
|
|
6
6
|
recordOwner,
|
|
7
7
|
readOwner,
|
|
8
8
|
diagnoseSync,
|
|
9
9
|
reclaimable,
|
|
10
10
|
OWNER_RECORD_BYTES
|
|
11
|
-
} from "./index-
|
|
11
|
+
} from "./index-vmbxj75t.js";
|
|
12
12
|
import {
|
|
13
13
|
UnixClientTransportError2
|
|
14
14
|
} from "./index-cv9b7fz2.js";
|
|
15
15
|
import {
|
|
16
16
|
errnoOf
|
|
17
17
|
} from "./index-jj9228tt.js";
|
|
18
|
+
import {
|
|
19
|
+
assertNonNegativeSafeInteger
|
|
20
|
+
} from "./index-gr0kxymw.js";
|
|
18
21
|
import {
|
|
19
22
|
randomHex
|
|
20
23
|
} from "./index-c9d05kvt.js";
|
|
@@ -322,15 +325,25 @@ function assertUnixSocketPathLength(socketPath, caller) {
|
|
|
322
325
|
throw new Error(`[stitchkit] ${caller}: unix socket path "${socketPath}" is ${bytes} bytes, exceeding the ${MAX_UNIX_SOCKET_PATH_BYTES}-byte portable sun_path limit (ENAMETOOLONG) — choose a shorter path`);
|
|
323
326
|
}
|
|
324
327
|
}
|
|
325
|
-
|
|
328
|
+
var MAX_POSIX_UID = 4294967295;
|
|
329
|
+
function assertExpectedOwnerUid(uid, caller) {
|
|
330
|
+
if (uid === undefined)
|
|
331
|
+
return;
|
|
332
|
+
assertNonNegativeSafeInteger(`[stitchkit] ${caller}: expectedOwnerUid`, uid);
|
|
333
|
+
if (uid > MAX_POSIX_UID) {
|
|
334
|
+
throw new TypeError(`[stitchkit] ${caller}: expectedOwnerUid must be a 32-bit unsigned integer (0..${MAX_POSIX_UID}), got ${String(uid)}`);
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
function unixSocketDirectoryViolation(dir, stats, caller, expectedUid) {
|
|
326
338
|
if (stats.isSymbolicLink()) {
|
|
327
339
|
return `[stitchkit] ${caller}: unix socket directory "${dir}" must not be a symlink`;
|
|
328
340
|
}
|
|
329
341
|
if (!stats.isDirectory()) {
|
|
330
342
|
return `[stitchkit] ${caller}: unix socket parent "${dir}" is not a directory`;
|
|
331
343
|
}
|
|
332
|
-
|
|
333
|
-
|
|
344
|
+
const requiredUid = expectedUid !== undefined ? expectedUid : typeof process.getuid === "function" ? process.getuid() : undefined;
|
|
345
|
+
if (requiredUid !== undefined && stats.uid !== requiredUid) {
|
|
346
|
+
return `[stitchkit] ${caller}: unix socket directory "${dir}" is owned by uid ${stats.uid}, expected ${requiredUid}`;
|
|
334
347
|
}
|
|
335
348
|
const mode = stats.mode & PERMISSION_BITS;
|
|
336
349
|
if ((mode & GROUP_OR_OTHER_WRITE_BITS) !== 0) {
|
|
@@ -344,7 +357,7 @@ function assertPrivateUnixSocketDirectory(socketPath, caller) {
|
|
|
344
357
|
if (stats === undefined) {
|
|
345
358
|
throw new Error(`[stitchkit] ${caller}: unix socket directory "${dir}" does not exist`);
|
|
346
359
|
}
|
|
347
|
-
const violation =
|
|
360
|
+
const violation = unixSocketDirectoryViolation(dir, stats, caller);
|
|
348
361
|
if (violation !== undefined)
|
|
349
362
|
throw new Error(violation);
|
|
350
363
|
}
|
|
@@ -358,7 +371,9 @@ function statForClientTarget(targetPath, label, caller, socketPath) {
|
|
|
358
371
|
throw new UnixClientTransportError2("UNIX_TARGET_REFUSED", `[stitchkit] ${caller}: failed to inspect unix socket ${label} "${targetPath}" (${code})`, "not-dispatched", { cause: error, socketPath });
|
|
359
372
|
}
|
|
360
373
|
}
|
|
361
|
-
function assertUnixSocketClientTarget(socketPath, caller = "createUnixClientTransport") {
|
|
374
|
+
function assertUnixSocketClientTarget(socketPath, caller = "createUnixClientTransport", expectedOwnerUid) {
|
|
375
|
+
assertExpectedOwnerUid(expectedOwnerUid, caller);
|
|
376
|
+
const requiredUid = expectedOwnerUid !== undefined ? expectedOwnerUid : typeof process.getuid === "function" ? process.getuid() : undefined;
|
|
362
377
|
const dir = dirname2(socketPath);
|
|
363
378
|
const refuse = (message) => {
|
|
364
379
|
throw new UnixClientTransportError2("UNIX_TARGET_REFUSED", message, "not-dispatched", {
|
|
@@ -368,7 +383,7 @@ function assertUnixSocketClientTarget(socketPath, caller = "createUnixClientTran
|
|
|
368
383
|
const dirStats = statForClientTarget(dir, "directory", caller, socketPath);
|
|
369
384
|
if (dirStats === undefined)
|
|
370
385
|
return;
|
|
371
|
-
const dirViolation =
|
|
386
|
+
const dirViolation = unixSocketDirectoryViolation(dir, dirStats, caller, requiredUid);
|
|
372
387
|
if (dirViolation !== undefined)
|
|
373
388
|
refuse(dirViolation);
|
|
374
389
|
const socketStats = statForClientTarget(socketPath, "path", caller, socketPath);
|
|
@@ -380,8 +395,8 @@ function assertUnixSocketClientTarget(socketPath, caller = "createUnixClientTran
|
|
|
380
395
|
if (!socketStats.isSocket()) {
|
|
381
396
|
refuse(`[stitchkit] ${caller}: "${socketPath}" is not a unix socket`);
|
|
382
397
|
}
|
|
383
|
-
if (
|
|
384
|
-
refuse(`[stitchkit] ${caller}: unix socket "${socketPath}" is owned by uid ${socketStats.uid}, expected ${
|
|
398
|
+
if (requiredUid !== undefined && socketStats.uid !== requiredUid) {
|
|
399
|
+
refuse(`[stitchkit] ${caller}: unix socket "${socketPath}" is owned by uid ${socketStats.uid}, expected ${requiredUid}`);
|
|
385
400
|
}
|
|
386
401
|
}
|
|
387
402
|
function chooseStagingSocketName(dir, targetPath, platform = process.platform) {
|
|
@@ -469,4 +484,4 @@ function bindUnixSocket2(socket, bind) {
|
|
|
469
484
|
return bound;
|
|
470
485
|
}
|
|
471
486
|
|
|
472
|
-
export { withUnixSocketLockSync, assertUnixSocketMode, unlinkUnixSocketIfMatching, unlinkUnixSocketIfOwned, assertUnixSocketPathLength, assertPrivateUnixSocketDirectory, assertUnixSocketClientTarget, publishStagedUnixSocket, bindUnixSocket2 };
|
|
487
|
+
export { withUnixSocketLockSync, assertUnixSocketMode, unlinkUnixSocketIfMatching, unlinkUnixSocketIfOwned, assertUnixSocketPathLength, assertExpectedOwnerUid, unixSocketDirectoryViolation, assertPrivateUnixSocketDirectory, assertUnixSocketClientTarget, publishStagedUnixSocket, bindUnixSocket2 };
|
|
@@ -3,11 +3,11 @@ import {
|
|
|
3
3
|
RegularFileError2,
|
|
4
4
|
fileCacheIdentity,
|
|
5
5
|
readRegularFileWithMetaSync,
|
|
6
|
-
|
|
6
|
+
readRegularFileWithMeta,
|
|
7
7
|
decodeJsonText,
|
|
8
8
|
parseJsonText,
|
|
9
9
|
validateJsonValue
|
|
10
|
-
} from "./index-
|
|
10
|
+
} from "./index-21cfxc4z.js";
|
|
11
11
|
import {
|
|
12
12
|
messageOf
|
|
13
13
|
} from "./index-r9kq5ark.js";
|
|
@@ -19,7 +19,7 @@ import {
|
|
|
19
19
|
} from "./index-jj9228tt.js";
|
|
20
20
|
import {
|
|
21
21
|
assertPositiveSafeInteger
|
|
22
|
-
} from "./index-
|
|
22
|
+
} from "./index-gr0kxymw.js";
|
|
23
23
|
|
|
24
24
|
// src/files/json-file-reading.ts
|
|
25
25
|
var VALUE_REFUSALS = new Set([
|
|
@@ -271,13 +271,17 @@ class PolledJsonFiles2 {
|
|
|
271
271
|
const existing = this.entries.get(path);
|
|
272
272
|
const readStartedNs = clockNs();
|
|
273
273
|
const found = await pathStatOfAsync(path, options.noFollow, readStartedNs);
|
|
274
|
+
signal?.throwIfAborted();
|
|
274
275
|
const shortcut = this.fromStat(existing, options, found, true);
|
|
275
276
|
if (shortcut !== undefined)
|
|
276
277
|
return shortcut;
|
|
277
278
|
let outcome;
|
|
278
279
|
try {
|
|
279
|
-
const bytes = await
|
|
280
|
-
outcome = {
|
|
280
|
+
const { bytes, after } = await readRegularFileWithMeta(path, { ...options, signal });
|
|
281
|
+
outcome = {
|
|
282
|
+
bytes,
|
|
283
|
+
...after !== undefined ? { stamp: stampOf(after, readStartedNs) } : found.kind === "file" ? { stamp: found.stamp } : {}
|
|
284
|
+
};
|
|
281
285
|
} catch (error) {
|
|
282
286
|
if (signal?.aborted)
|
|
283
287
|
throw error;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
machineIdentity,
|
|
3
3
|
readProcessInstance
|
|
4
|
-
} from "./index-
|
|
4
|
+
} from "./index-673drwkn.js";
|
|
5
5
|
import {
|
|
6
6
|
recordOwner,
|
|
7
7
|
readOwner,
|
|
@@ -9,11 +9,11 @@ import {
|
|
|
9
9
|
reclaimable,
|
|
10
10
|
LockRecordError,
|
|
11
11
|
readLockRecord
|
|
12
|
-
} from "./index-
|
|
12
|
+
} from "./index-vmbxj75t.js";
|
|
13
13
|
import {
|
|
14
14
|
AtomicFilePublicationError2,
|
|
15
15
|
publishAtomicFile
|
|
16
|
-
} from "./index-
|
|
16
|
+
} from "./index-2c5w2d1d.js";
|
|
17
17
|
import {
|
|
18
18
|
errnoOf
|
|
19
19
|
} from "./index-jj9228tt.js";
|
|
@@ -1,32 +1,30 @@
|
|
|
1
1
|
import {
|
|
2
2
|
TOOL_TRANSPORTS2
|
|
3
3
|
} from "./index-yt1gg11x.js";
|
|
4
|
+
import {
|
|
5
|
+
projectToolSurface
|
|
6
|
+
} from "./index-669374qc.js";
|
|
4
7
|
import {
|
|
5
8
|
contractOnlyService
|
|
6
9
|
} from "./index-wa6h4tz6.js";
|
|
7
|
-
import {
|
|
8
|
-
collectToolSurface
|
|
9
|
-
} from "./index-5e0zsbf7.js";
|
|
10
10
|
|
|
11
11
|
// src/tools/list-names.ts
|
|
12
12
|
function listToolNames2(surface) {
|
|
13
13
|
const entries = new Map;
|
|
14
14
|
for (const transport of TOOL_TRANSPORTS2) {
|
|
15
|
-
for (const entry of
|
|
16
|
-
surface,
|
|
17
|
-
transport,
|
|
15
|
+
for (const entry of projectToolSurface(surface, transport, {
|
|
18
16
|
assertNames: false,
|
|
19
17
|
assertUniqueNames: false
|
|
20
18
|
})) {
|
|
21
|
-
const id = `${entry.kind}\x00${entry.
|
|
19
|
+
const id = `${entry.kind}\x00${entry.serviceName}\x00${entry.action}`;
|
|
22
20
|
const existing = entries.get(id);
|
|
23
21
|
if (existing) {
|
|
24
22
|
existing.expose.push(transport);
|
|
25
23
|
} else {
|
|
26
24
|
entries.set(id, {
|
|
27
25
|
kind: entry.kind,
|
|
28
|
-
name: entry.
|
|
29
|
-
service: entry.
|
|
26
|
+
name: entry.name,
|
|
27
|
+
service: entry.serviceName,
|
|
30
28
|
method: entry.action,
|
|
31
29
|
expose: [transport]
|
|
32
30
|
});
|