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
|
@@ -0,0 +1,304 @@
|
|
|
1
|
+
import {
|
|
2
|
+
AgentTimestampSchema2,
|
|
3
|
+
AgentUsageSchema2
|
|
4
|
+
} from "./index-bn2baakz.js";
|
|
5
|
+
|
|
6
|
+
// src/agent-runtime/invocation-schema.ts
|
|
7
|
+
import { z as z2 } from "zod";
|
|
8
|
+
|
|
9
|
+
// src/agent-runtime/schemas-invocation-payload.ts
|
|
10
|
+
import { z } from "zod";
|
|
11
|
+
var Id = z.string().min(1).max(512);
|
|
12
|
+
var Hash = z.string().regex(/^[a-f0-9]{64}$/);
|
|
13
|
+
var PayloadBase = z.object({
|
|
14
|
+
conversationId: Id,
|
|
15
|
+
invocationId: Id,
|
|
16
|
+
operationId: Id,
|
|
17
|
+
runId: Id.optional()
|
|
18
|
+
});
|
|
19
|
+
var InvocationPayloadSchema = PayloadBase.extend({
|
|
20
|
+
artifactId: Id,
|
|
21
|
+
sha256: Hash,
|
|
22
|
+
bytes: z.int().nonnegative(),
|
|
23
|
+
iv: z.string(),
|
|
24
|
+
tag: z.string(),
|
|
25
|
+
ciphertext: z.string()
|
|
26
|
+
}).strict();
|
|
27
|
+
var InvocationExpiredPayloadSchema = PayloadBase.extend({
|
|
28
|
+
artifactId: Id,
|
|
29
|
+
sha256: Hash,
|
|
30
|
+
bytes: z.int().nonnegative(),
|
|
31
|
+
expiredAt: AgentTimestampSchema2
|
|
32
|
+
}).strict();
|
|
33
|
+
var PurgeInvocationPayloadsInputSchema2 = z.object({
|
|
34
|
+
before: AgentTimestampSchema2,
|
|
35
|
+
conversationId: Id.optional(),
|
|
36
|
+
limit: z.int().positive().max(1e4).optional()
|
|
37
|
+
}).strict();
|
|
38
|
+
var PurgeInvocationPayloadsResultSchema2 = z.object({
|
|
39
|
+
purged: z.int().nonnegative(),
|
|
40
|
+
freedBytes: z.int().nonnegative(),
|
|
41
|
+
hasMore: z.boolean()
|
|
42
|
+
}).strict();
|
|
43
|
+
function parsePayloadPurgeCutoff(before) {
|
|
44
|
+
const cutoffEpoch = Date.parse(before);
|
|
45
|
+
if (Number.isNaN(cutoffEpoch)) {
|
|
46
|
+
throw new TypeError(`Invalid payload expiry cutoff timestamp: ${JSON.stringify(before)}`);
|
|
47
|
+
}
|
|
48
|
+
return cutoffEpoch;
|
|
49
|
+
}
|
|
50
|
+
function redactLiveInvocationPayload(rawPayload, expiredAt) {
|
|
51
|
+
if (InvocationExpiredPayloadSchema.safeParse(rawPayload).success)
|
|
52
|
+
return;
|
|
53
|
+
const live = InvocationPayloadSchema.parse(rawPayload);
|
|
54
|
+
return InvocationExpiredPayloadSchema.parse({
|
|
55
|
+
conversationId: live.conversationId,
|
|
56
|
+
invocationId: live.invocationId,
|
|
57
|
+
operationId: live.operationId,
|
|
58
|
+
...live.runId !== undefined && { runId: live.runId },
|
|
59
|
+
artifactId: live.artifactId,
|
|
60
|
+
sha256: live.sha256,
|
|
61
|
+
bytes: live.bytes,
|
|
62
|
+
expiredAt
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// src/agent-runtime/invocation-schema.ts
|
|
67
|
+
var Id2 = z2.string().min(1).max(512);
|
|
68
|
+
var Hash2 = z2.string().regex(/^[a-f0-9]{64}$/);
|
|
69
|
+
var ModelInvocationTraceSchema2 = z2.object({
|
|
70
|
+
operationId: Id2,
|
|
71
|
+
purpose: Id2,
|
|
72
|
+
project: Id2,
|
|
73
|
+
parent: z2.object({ traceId: Id2, invocationId: Id2.optional() }).strict().optional(),
|
|
74
|
+
experiment: Id2.optional(),
|
|
75
|
+
case: Id2.optional(),
|
|
76
|
+
profile: Id2.optional()
|
|
77
|
+
}).strict();
|
|
78
|
+
var CompletionInvocationInputSchema2 = z2.object({
|
|
79
|
+
conversationId: Id2,
|
|
80
|
+
idempotencyKey: Id2,
|
|
81
|
+
trace: ModelInvocationTraceSchema2,
|
|
82
|
+
prompt: z2.string().min(1),
|
|
83
|
+
models: z2.array(Id2).min(1).max(8),
|
|
84
|
+
settings: z2.object({
|
|
85
|
+
maxOutputTokens: z2.int().positive().optional(),
|
|
86
|
+
temperature: z2.number().finite().optional(),
|
|
87
|
+
topP: z2.number().min(0).max(1).optional(),
|
|
88
|
+
seed: z2.int().optional()
|
|
89
|
+
}).strict().optional(),
|
|
90
|
+
timeoutMs: z2.int().positive().max(3600000)
|
|
91
|
+
}).strict();
|
|
92
|
+
var Identity = z2.object({
|
|
93
|
+
provider: Id2.nullable(),
|
|
94
|
+
modelId: Id2.nullable(),
|
|
95
|
+
responseId: Id2.nullable()
|
|
96
|
+
}).strict();
|
|
97
|
+
var InvocationCallerSchema = z2.object({ subject: Id2 }).strict();
|
|
98
|
+
var InvocationProcessSchema = z2.object({
|
|
99
|
+
instanceId: Id2,
|
|
100
|
+
pid: z2.int().positive(),
|
|
101
|
+
hostname: Id2
|
|
102
|
+
}).strict();
|
|
103
|
+
var Base = z2.object({
|
|
104
|
+
conversationId: Id2,
|
|
105
|
+
invocationId: Id2,
|
|
106
|
+
operationId: Id2,
|
|
107
|
+
runId: Id2.optional()
|
|
108
|
+
});
|
|
109
|
+
var InvocationStartedSchema = Base.extend({
|
|
110
|
+
type: z2.literal("invocation/started"),
|
|
111
|
+
mode: z2.enum(["completion", "agent"]),
|
|
112
|
+
trace: ModelInvocationTraceSchema2,
|
|
113
|
+
caller: InvocationCallerSchema,
|
|
114
|
+
executingProcess: InvocationProcessSchema,
|
|
115
|
+
fingerprint: Hash2,
|
|
116
|
+
requested: z2.object({ models: z2.array(Id2), payloadSha256: Hash2 }).strict()
|
|
117
|
+
}).strict();
|
|
118
|
+
var InvocationAttemptContextSchema = Base.extend({
|
|
119
|
+
attemptId: Id2,
|
|
120
|
+
step: z2.int().nonnegative()
|
|
121
|
+
}).strict();
|
|
122
|
+
var InvocationPayloadOmissionReasonSchema2 = z2.enum(["max-payload-bytes"]);
|
|
123
|
+
var Attempt = Base.extend({ attemptId: Id2, step: z2.int().nonnegative() });
|
|
124
|
+
var InvocationRequestSchema = Attempt.extend({
|
|
125
|
+
type: z2.literal("provider/request"),
|
|
126
|
+
requested: z2.object({ modelId: Id2, provider: Id2 }).strict(),
|
|
127
|
+
executingProcess: InvocationProcessSchema,
|
|
128
|
+
sent: z2.object({
|
|
129
|
+
modelId: Id2,
|
|
130
|
+
provider: Id2,
|
|
131
|
+
payloadSha256: Hash2,
|
|
132
|
+
artifactId: Id2.optional(),
|
|
133
|
+
payloadOmitted: InvocationPayloadOmissionReasonSchema2.optional(),
|
|
134
|
+
tools: z2.int().nonnegative()
|
|
135
|
+
}).strict().superRefine((sent, ctx) => {
|
|
136
|
+
const hasArtifact = sent.artifactId !== undefined;
|
|
137
|
+
const hasOmitted = sent.payloadOmitted !== undefined;
|
|
138
|
+
if (hasArtifact === hasOmitted) {
|
|
139
|
+
ctx.addIssue({
|
|
140
|
+
code: "custom",
|
|
141
|
+
message: "provider/request sent requires exactly one of artifactId or payloadOmitted"
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
})
|
|
145
|
+
}).strict();
|
|
146
|
+
var InvocationResponseSchema = Attempt.extend({
|
|
147
|
+
type: z2.literal("provider/response"),
|
|
148
|
+
status: z2.enum(["succeeded", "failed", "cancelled"]),
|
|
149
|
+
effective: Identity,
|
|
150
|
+
usage: AgentUsageSchema2,
|
|
151
|
+
artifactId: Id2.optional(),
|
|
152
|
+
payloadOmitted: InvocationPayloadOmissionReasonSchema2.optional(),
|
|
153
|
+
payloadSha256: Hash2
|
|
154
|
+
}).strict().superRefine((response, ctx) => {
|
|
155
|
+
const hasArtifact = response.artifactId !== undefined;
|
|
156
|
+
const hasOmitted = response.payloadOmitted !== undefined;
|
|
157
|
+
if (hasArtifact === hasOmitted) {
|
|
158
|
+
ctx.addIssue({
|
|
159
|
+
code: "custom",
|
|
160
|
+
message: "provider/response requires exactly one of artifactId or payloadOmitted"
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
});
|
|
164
|
+
var InvocationFinishedSchema = Base.extend({
|
|
165
|
+
type: z2.literal("invocation/finished"),
|
|
166
|
+
failure: z2.object({ artifactId: Id2, payloadSha256: Hash2 }).strict().optional(),
|
|
167
|
+
status: z2.enum(["succeeded", "failed", "cancelled"])
|
|
168
|
+
}).strict();
|
|
169
|
+
var ModelInvocationRecordSchema2 = z2.discriminatedUnion("type", [
|
|
170
|
+
InvocationStartedSchema,
|
|
171
|
+
InvocationRequestSchema,
|
|
172
|
+
InvocationResponseSchema,
|
|
173
|
+
InvocationFinishedSchema
|
|
174
|
+
]);
|
|
175
|
+
var InvocationStoredPayloadSchema = z2.union([
|
|
176
|
+
InvocationPayloadSchema,
|
|
177
|
+
InvocationExpiredPayloadSchema
|
|
178
|
+
]);
|
|
179
|
+
var InvocationPayloadReceiptSchema = Base.extend({
|
|
180
|
+
artifactId: Id2,
|
|
181
|
+
sha256: Hash2,
|
|
182
|
+
bytes: z2.int().nonnegative(),
|
|
183
|
+
iv: z2.string().optional(),
|
|
184
|
+
tag: z2.string().optional(),
|
|
185
|
+
ciphertext: z2.string().optional(),
|
|
186
|
+
expiredAt: AgentTimestampSchema2.optional()
|
|
187
|
+
}).strict().superRefine((value, ctx) => {
|
|
188
|
+
const cipherParts = [value.iv, value.tag, value.ciphertext].filter((p) => p !== undefined).length;
|
|
189
|
+
if (cipherParts > 0 && cipherParts < 3) {
|
|
190
|
+
ctx.addIssue({
|
|
191
|
+
code: "custom",
|
|
192
|
+
message: "Invocation payload receipt has incomplete encryption fields"
|
|
193
|
+
});
|
|
194
|
+
}
|
|
195
|
+
if (cipherParts > 0 && value.expiredAt !== undefined) {
|
|
196
|
+
ctx.addIssue({
|
|
197
|
+
code: "custom",
|
|
198
|
+
message: "Invocation payload receipt cannot carry both ciphertext and expiredAt"
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
});
|
|
202
|
+
var ModelInvocationPayloadReadSchema2 = z2.discriminatedUnion("status", [
|
|
203
|
+
z2.object({
|
|
204
|
+
status: z2.literal("available"),
|
|
205
|
+
artifactId: Id2,
|
|
206
|
+
sha256: Hash2,
|
|
207
|
+
bytes: z2.int().nonnegative(),
|
|
208
|
+
payload: z2.json()
|
|
209
|
+
}).strict(),
|
|
210
|
+
z2.object({
|
|
211
|
+
status: z2.literal("expired"),
|
|
212
|
+
artifactId: Id2,
|
|
213
|
+
sha256: Hash2,
|
|
214
|
+
bytes: z2.int().nonnegative(),
|
|
215
|
+
expiredAt: AgentTimestampSchema2
|
|
216
|
+
}).strict()
|
|
217
|
+
]);
|
|
218
|
+
function isModelInvocationRecord(payload) {
|
|
219
|
+
return payload !== null && typeof payload === "object" && "invocationId" in payload;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
// src/agent-runtime/history-chronology.ts
|
|
223
|
+
function createToolChronology() {
|
|
224
|
+
return { calls: new Map, approvals: new Map, pending: 0, resultsStarted: false };
|
|
225
|
+
}
|
|
226
|
+
function advanceToolChronology(previous, parts) {
|
|
227
|
+
const calls = new Map(previous.calls);
|
|
228
|
+
const approvals = new Map(previous.approvals);
|
|
229
|
+
let { pending, resultsStarted } = previous;
|
|
230
|
+
for (const part of parts) {
|
|
231
|
+
if (part.type === "tool-call") {
|
|
232
|
+
if (calls.has(part.callId) || resultsStarted && pending > 0)
|
|
233
|
+
return;
|
|
234
|
+
if (pending === 0)
|
|
235
|
+
resultsStarted = false;
|
|
236
|
+
calls.set(part.callId, { toolName: part.toolName, phase: "called" });
|
|
237
|
+
pending += 1;
|
|
238
|
+
} else if (part.type === "tool-approval-request") {
|
|
239
|
+
const call = calls.get(part.callId);
|
|
240
|
+
if (call?.phase !== "called" || approvals.has(part.approvalId))
|
|
241
|
+
return;
|
|
242
|
+
approvals.set(part.approvalId, part.callId);
|
|
243
|
+
calls.set(part.callId, { ...call, phase: "requested" });
|
|
244
|
+
} else if (part.type === "tool-approval-response") {
|
|
245
|
+
const callId = approvals.get(part.approvalId);
|
|
246
|
+
const call = callId === undefined ? undefined : calls.get(callId);
|
|
247
|
+
if (callId === undefined || !call || call.phase !== "requested")
|
|
248
|
+
return;
|
|
249
|
+
calls.set(callId, { ...call, phase: part.approved ? "approved" : "denied" });
|
|
250
|
+
} else if (part.type === "tool-result") {
|
|
251
|
+
const call = calls.get(part.callId);
|
|
252
|
+
if (!call || call.toolName !== part.toolName || call.phase === "result" || call.phase === "requested" || call.phase === "denied" && part.outcome === "success")
|
|
253
|
+
return;
|
|
254
|
+
calls.set(part.callId, { ...call, phase: "result" });
|
|
255
|
+
pending -= 1;
|
|
256
|
+
resultsStarted = true;
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
return { calls, approvals, pending, resultsStarted };
|
|
260
|
+
}
|
|
261
|
+
function canProjectToolChronology(state) {
|
|
262
|
+
return [...state.calls.values()].every(({ phase }) => phase !== "called");
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
// src/agent-runtime/terminal-status.ts
|
|
266
|
+
function isSpeakableAssistantStatus(status) {
|
|
267
|
+
return status === "completed" || status === "interrupted" || status === "committed";
|
|
268
|
+
}
|
|
269
|
+
function isAssistantHistoryEvidence2(status, policy) {
|
|
270
|
+
return isSpeakableAssistantStatus(status) || status === "failed" && policy?.failedAssistant === "assistant-marked";
|
|
271
|
+
}
|
|
272
|
+
function isCompleteAgentHistoryTurn(messages, policy) {
|
|
273
|
+
if (messages[0]?.role !== "user")
|
|
274
|
+
return false;
|
|
275
|
+
let chronology = createToolChronology();
|
|
276
|
+
let assistantCount = 0;
|
|
277
|
+
for (const message of messages) {
|
|
278
|
+
if (message.role === "assistant") {
|
|
279
|
+
if (!isAssistantHistoryEvidence2(message.status, policy))
|
|
280
|
+
return false;
|
|
281
|
+
assistantCount += 1;
|
|
282
|
+
}
|
|
283
|
+
const next = advanceToolChronology(chronology, message.parts);
|
|
284
|
+
if (!next)
|
|
285
|
+
return false;
|
|
286
|
+
chronology = next;
|
|
287
|
+
}
|
|
288
|
+
return assistantCount > 0 && chronology.pending === 0;
|
|
289
|
+
}
|
|
290
|
+
function assistantStatus(reason) {
|
|
291
|
+
if (reason === "success" || reason === "policy_stop" || reason === "provider_stop") {
|
|
292
|
+
return "completed";
|
|
293
|
+
}
|
|
294
|
+
if (reason === "superseded")
|
|
295
|
+
return "superseded";
|
|
296
|
+
if (reason === "absorbed")
|
|
297
|
+
return "superseded";
|
|
298
|
+
if (reason === "interrupted" || reason === "cancelled" || reason === "shutdown") {
|
|
299
|
+
return "interrupted";
|
|
300
|
+
}
|
|
301
|
+
return "failed";
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
export { InvocationPayloadSchema, InvocationExpiredPayloadSchema, PurgeInvocationPayloadsInputSchema2, PurgeInvocationPayloadsResultSchema2, parsePayloadPurgeCutoff, redactLiveInvocationPayload, ModelInvocationTraceSchema2, CompletionInvocationInputSchema2, InvocationCallerSchema, InvocationStartedSchema, InvocationPayloadOmissionReasonSchema2, InvocationRequestSchema, InvocationResponseSchema, InvocationFinishedSchema, ModelInvocationRecordSchema2, InvocationStoredPayloadSchema, InvocationPayloadReceiptSchema, ModelInvocationPayloadReadSchema2, isModelInvocationRecord, createToolChronology, advanceToolChronology, canProjectToolChronology, isAssistantHistoryEvidence2, isCompleteAgentHistoryTurn, assistantStatus };
|
|
@@ -4,11 +4,11 @@ import {
|
|
|
4
4
|
ProcessInstanceSchema2,
|
|
5
5
|
probeProcessOwner2,
|
|
6
6
|
probeProcessOwnerSync
|
|
7
|
-
} from "./index-
|
|
7
|
+
} from "./index-673drwkn.js";
|
|
8
8
|
import {
|
|
9
9
|
BoundedFileReadError,
|
|
10
10
|
readBoundedFile
|
|
11
|
-
} from "./index-
|
|
11
|
+
} from "./index-s2e3h616.js";
|
|
12
12
|
import {
|
|
13
13
|
isRecord
|
|
14
14
|
} from "./index-ps3djm8d.js";
|
|
@@ -3,15 +3,19 @@ import {
|
|
|
3
3
|
} from "./index-09f7w2qq.js";
|
|
4
4
|
import {
|
|
5
5
|
engineEnvironment2
|
|
6
|
-
} from "./index-
|
|
6
|
+
} from "./index-afb6z77w.js";
|
|
7
7
|
import {
|
|
8
8
|
runNativeCommand2
|
|
9
|
-
} from "./index-
|
|
9
|
+
} from "./index-pzhqydxb.js";
|
|
10
10
|
import {
|
|
11
11
|
jsonDataRefusal
|
|
12
12
|
} from "./index-m6w6jtda.js";
|
|
13
|
+
import {
|
|
14
|
+
assertPositiveSafeInteger
|
|
15
|
+
} from "./index-gr0kxymw.js";
|
|
13
16
|
import {
|
|
14
17
|
abortReason,
|
|
18
|
+
raceAbort,
|
|
15
19
|
linkAbortSignals
|
|
16
20
|
} from "./index-rptj3qnc.js";
|
|
17
21
|
|
|
@@ -73,15 +77,6 @@ function offerTurnDelta(channel, delta) {
|
|
|
73
77
|
channel.fail(new Error(`The turn's delta queue refused a delta (${result.reason})`));
|
|
74
78
|
}
|
|
75
79
|
}
|
|
76
|
-
function extractTextOnlyInput(parts, driverLabel) {
|
|
77
|
-
return parts.map((part) => {
|
|
78
|
-
if (part.type !== "text") {
|
|
79
|
-
throw new TypeError(`${driverLabel} sends text input only, received ${part.type}`);
|
|
80
|
-
}
|
|
81
|
-
return part.text;
|
|
82
|
-
}).join(`
|
|
83
|
-
`);
|
|
84
|
-
}
|
|
85
80
|
function sessionAbort(caller) {
|
|
86
81
|
if (caller?.aborted)
|
|
87
82
|
throw abortReason(caller);
|
|
@@ -145,6 +140,108 @@ function safeJsonValue(value) {
|
|
|
145
140
|
return z.json().parse(snapshot.value);
|
|
146
141
|
}
|
|
147
142
|
|
|
143
|
+
// src/agent-executor/image-input.ts
|
|
144
|
+
var DEFAULT_MAX_IMAGE_BYTES = 5 * 1024 * 1024;
|
|
145
|
+
var CLAUDE_CLI_MAX_LINE_BYTES = 16 * 1024 * 1024;
|
|
146
|
+
var SUPPORTED_IMAGE_MEDIA_TYPES = new Set([
|
|
147
|
+
"image/png",
|
|
148
|
+
"image/jpeg",
|
|
149
|
+
"image/gif",
|
|
150
|
+
"image/webp"
|
|
151
|
+
]);
|
|
152
|
+
function isSupportedImageMediaType(value) {
|
|
153
|
+
return value === "image/png" || value === "image/jpeg" || value === "image/gif" || value === "image/webp";
|
|
154
|
+
}
|
|
155
|
+
function validateImageOptions(options) {
|
|
156
|
+
assertPositiveSafeInteger("maxImageBytes", options.maxImageBytes);
|
|
157
|
+
}
|
|
158
|
+
function bytesToBase64(bytes) {
|
|
159
|
+
return Buffer.from(bytes.buffer, bytes.byteOffset, bytes.byteLength).toString("base64");
|
|
160
|
+
}
|
|
161
|
+
async function resolveImageBytes(reference, options) {
|
|
162
|
+
assertPositiveSafeInteger("maxImageBytes", options.maxImageBytes);
|
|
163
|
+
let bytes;
|
|
164
|
+
try {
|
|
165
|
+
bytes = await options.resolveFile(reference);
|
|
166
|
+
} catch {
|
|
167
|
+
throw new Error("Failed to resolve image input");
|
|
168
|
+
}
|
|
169
|
+
if (!(bytes instanceof Uint8Array)) {
|
|
170
|
+
throw new TypeError("resolveFile must return a Uint8Array");
|
|
171
|
+
}
|
|
172
|
+
if (bytes.byteLength === 0) {
|
|
173
|
+
throw new RangeError("The image is empty (0 bytes)");
|
|
174
|
+
}
|
|
175
|
+
if (bytes.byteLength > options.maxImageBytes) {
|
|
176
|
+
throw new RangeError(`The image is ${bytes.byteLength} bytes, over maxImageBytes ${options.maxImageBytes}`);
|
|
177
|
+
}
|
|
178
|
+
return bytes;
|
|
179
|
+
}
|
|
180
|
+
async function inlineParts(parts, options) {
|
|
181
|
+
const maxImageBytes = options.maxImageBytes ?? DEFAULT_MAX_IMAGE_BYTES;
|
|
182
|
+
assertPositiveSafeInteger("maxImageBytes", maxImageBytes);
|
|
183
|
+
for (const part of parts) {
|
|
184
|
+
if (part.type === "text")
|
|
185
|
+
continue;
|
|
186
|
+
if (part.type !== "file") {
|
|
187
|
+
throw new TypeError(`${options.driverLabel} sends text and images, received ${part.type}`);
|
|
188
|
+
}
|
|
189
|
+
if (!isSupportedImageMediaType(part.mediaType)) {
|
|
190
|
+
throw new TypeError(`${options.driverLabel} sends PNG, JPEG, GIF or WebP images only, received a file of ${part.mediaType}`);
|
|
191
|
+
}
|
|
192
|
+
if (options.resolveFile === undefined) {
|
|
193
|
+
throw new TypeError("An image needs resolveFile to read its bytes");
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
const resolved = [];
|
|
197
|
+
for (const part of parts) {
|
|
198
|
+
if (part.type === "text") {
|
|
199
|
+
resolved.push({ type: "text", text: part.text });
|
|
200
|
+
continue;
|
|
201
|
+
}
|
|
202
|
+
if (part.type !== "file" || options.resolveFile === undefined)
|
|
203
|
+
continue;
|
|
204
|
+
const read = resolveImageBytes(part.reference, {
|
|
205
|
+
resolveFile: options.resolveFile,
|
|
206
|
+
maxImageBytes
|
|
207
|
+
});
|
|
208
|
+
const bytes = options.signal ? await raceAbort(read, options.signal) : await read;
|
|
209
|
+
resolved.push({
|
|
210
|
+
type: "image",
|
|
211
|
+
mediaType: part.mediaType,
|
|
212
|
+
base64: bytesToBase64(bytes)
|
|
213
|
+
});
|
|
214
|
+
}
|
|
215
|
+
return resolved;
|
|
216
|
+
}
|
|
217
|
+
function assertImageFrameBytes(serialized, maxBytes) {
|
|
218
|
+
const byteLength = Buffer.byteLength(serialized);
|
|
219
|
+
if (byteLength > maxBytes) {
|
|
220
|
+
throw new RangeError(`Turn input frame is ${byteLength} bytes, over the ${maxBytes}-byte frame limit`);
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
function imageTurnStarter(options) {
|
|
224
|
+
let preparing = false;
|
|
225
|
+
return async (input) => {
|
|
226
|
+
if (preparing)
|
|
227
|
+
throw new Error(options.busyMessage);
|
|
228
|
+
options.check(input);
|
|
229
|
+
preparing = true;
|
|
230
|
+
let parts;
|
|
231
|
+
try {
|
|
232
|
+
parts = await inlineParts(input.input, {
|
|
233
|
+
...options.imageOptions,
|
|
234
|
+
driverLabel: options.driverLabel,
|
|
235
|
+
signal: options.signal
|
|
236
|
+
});
|
|
237
|
+
} finally {
|
|
238
|
+
preparing = false;
|
|
239
|
+
}
|
|
240
|
+
options.check(input);
|
|
241
|
+
return await options.dispatch(input, parts);
|
|
242
|
+
};
|
|
243
|
+
}
|
|
244
|
+
|
|
148
245
|
// src/agent-executor/engine-requests.ts
|
|
149
246
|
function holdEngineRequest(turn, request) {
|
|
150
247
|
if (turn.state.interruptRequested) {
|
|
@@ -196,4 +293,4 @@ function loseEngineTurn(turn, answer, error) {
|
|
|
196
293
|
turn.channel.fail(error);
|
|
197
294
|
}
|
|
198
295
|
|
|
199
|
-
export { nonEmptyString, epochSecondsToIso, createTurnDeltaChannel, offerTurnDelta,
|
|
296
|
+
export { nonEmptyString, epochSecondsToIso, createTurnDeltaChannel, offerTurnDelta, sessionAbort, runEngineCli, stopConnection, withEphemeralConnection, safeJsonValue, DEFAULT_MAX_IMAGE_BYTES, CLAUDE_CLI_MAX_LINE_BYTES, isSupportedImageMediaType, validateImageOptions, bytesToBase64, resolveImageBytes, inlineParts, assertImageFrameBytes, imageTurnStarter, holdEngineRequest, answerEngineRequest, drainEngineRequests, endEngineTurn, loseEngineTurn };
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
2
|
PlanWindowSchema2,
|
|
3
3
|
engineProfile
|
|
4
|
-
} from "./index-
|
|
4
|
+
} from "./index-afb6z77w.js";
|
|
5
5
|
import {
|
|
6
6
|
nonEmptyString,
|
|
7
7
|
epochSecondsToIso,
|
|
8
|
-
safeJsonValue
|
|
9
|
-
|
|
8
|
+
safeJsonValue,
|
|
9
|
+
isSupportedImageMediaType
|
|
10
|
+
} from "./index-wv2amqm4.js";
|
|
10
11
|
import {
|
|
11
12
|
errnoOf
|
|
12
13
|
} from "./index-jj9228tt.js";
|
|
@@ -112,10 +113,27 @@ var ClaudeRecordSchema = z.discriminatedUnion("type", [
|
|
|
112
113
|
})
|
|
113
114
|
]);
|
|
114
115
|
var ClaudeUnknownRecordSchema = z.looseObject({ type: z.string() });
|
|
116
|
+
function claudeUserContent(parts) {
|
|
117
|
+
if (parts.every((part) => part.type === "text")) {
|
|
118
|
+
return parts.map((part) => part.text).join(`
|
|
119
|
+
`);
|
|
120
|
+
}
|
|
121
|
+
return parts.map((part) => {
|
|
122
|
+
if (part.type === "text")
|
|
123
|
+
return { type: "text", text: part.text };
|
|
124
|
+
if (!isSupportedImageMediaType(part.mediaType)) {
|
|
125
|
+
throw new TypeError(`Unsupported Claude image media type: ${part.mediaType}`);
|
|
126
|
+
}
|
|
127
|
+
return {
|
|
128
|
+
type: "image",
|
|
129
|
+
source: { type: "base64", media_type: part.mediaType, data: part.base64 }
|
|
130
|
+
};
|
|
131
|
+
});
|
|
132
|
+
}
|
|
115
133
|
function claudeUserMessage(input) {
|
|
116
134
|
return {
|
|
117
135
|
type: "user",
|
|
118
|
-
message: { role: "user", content: input.
|
|
136
|
+
message: { role: "user", content: input.content },
|
|
119
137
|
uuid: input.clientId,
|
|
120
138
|
parent_tool_use_id: null,
|
|
121
139
|
session_id: input.sessionId
|
|
@@ -404,16 +422,66 @@ function claudePlanWindows2(info) {
|
|
|
404
422
|
}
|
|
405
423
|
|
|
406
424
|
// src/agent-executor/claude/transcript.ts
|
|
425
|
+
import { realpathSync } from "node:fs";
|
|
407
426
|
import { open } from "node:fs/promises";
|
|
408
|
-
import { join } from "node:path";
|
|
427
|
+
import { basename, dirname, join } from "node:path";
|
|
409
428
|
var SAFE_SESSION_ID = /^[A-Za-z0-9_-]+$/;
|
|
429
|
+
function stripTrailingSlashes(path) {
|
|
430
|
+
const stripped = path.replace(/\/+$/, "");
|
|
431
|
+
return stripped.length === 0 && path.startsWith("/") ? "/" : stripped;
|
|
432
|
+
}
|
|
433
|
+
function canonicalClaudeCwd(cwd) {
|
|
434
|
+
if (cwd.length === 0)
|
|
435
|
+
return cwd;
|
|
436
|
+
const normalized = stripTrailingSlashes(cwd);
|
|
437
|
+
const missingTail = [];
|
|
438
|
+
let probe = normalized;
|
|
439
|
+
for (;; ) {
|
|
440
|
+
try {
|
|
441
|
+
const resolved = realpathSync(probe);
|
|
442
|
+
return missingTail.length === 0 ? resolved : join(resolved, ...missingTail.reverse());
|
|
443
|
+
} catch (error) {
|
|
444
|
+
const code = errnoOf(error);
|
|
445
|
+
if (code !== "ENOENT" && code !== "ENOTDIR")
|
|
446
|
+
throw error;
|
|
447
|
+
const parent = dirname(probe);
|
|
448
|
+
if (parent === probe)
|
|
449
|
+
return normalized;
|
|
450
|
+
missingTail.push(basename(probe));
|
|
451
|
+
probe = parent;
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
}
|
|
410
455
|
function claudeTranscriptPath2(input) {
|
|
411
456
|
if (!SAFE_SESSION_ID.test(input.sessionId)) {
|
|
412
457
|
throw new TypeError(`Invalid Claude sessionId: ${input.sessionId}`);
|
|
413
458
|
}
|
|
414
|
-
|
|
459
|
+
const canonicalCwd = canonicalClaudeCwd(input.cwd);
|
|
460
|
+
return join(input.home, "projects", canonicalCwd.replace(/[^A-Za-z0-9-]/g, "-"), `${input.sessionId}.jsonl`);
|
|
461
|
+
}
|
|
462
|
+
var MAX_RECORD_BYTES = 16 * 1024 * 1024;
|
|
463
|
+
var INITIAL_RECORD_BYTES = 64 * 1024;
|
|
464
|
+
var READ_CHUNK_BYTES = 64 * 1024;
|
|
465
|
+
var UTF8_STRICT = new TextDecoder("utf-8", { fatal: true });
|
|
466
|
+
function classifyTranscriptLine(bytes, uuid) {
|
|
467
|
+
const end = bytes.length > 0 && bytes[bytes.length - 1] === 13 ? bytes.length - 1 : bytes.length;
|
|
468
|
+
if (end === 0)
|
|
469
|
+
return "other";
|
|
470
|
+
let record;
|
|
471
|
+
try {
|
|
472
|
+
record = JSON.parse(UTF8_STRICT.decode(bytes.subarray(0, end)));
|
|
473
|
+
} catch {
|
|
474
|
+
return "invalid";
|
|
475
|
+
}
|
|
476
|
+
if (typeof record !== "object" || record === null || Array.isArray(record))
|
|
477
|
+
return "invalid";
|
|
478
|
+
if (Reflect.get(record, "type") !== "user")
|
|
479
|
+
return "other";
|
|
480
|
+
const recordUuid = Reflect.get(record, "uuid");
|
|
481
|
+
if (typeof recordUuid !== "string")
|
|
482
|
+
return "invalid";
|
|
483
|
+
return recordUuid === uuid ? "match" : "other";
|
|
415
484
|
}
|
|
416
|
-
var MAX_SCAN_BYTES = 64 * 1024 * 1024;
|
|
417
485
|
async function claudeTranscriptHasUuid(path, uuid) {
|
|
418
486
|
let handle;
|
|
419
487
|
try {
|
|
@@ -424,28 +492,70 @@ async function claudeTranscriptHasUuid(path, uuid) {
|
|
|
424
492
|
throw error;
|
|
425
493
|
}
|
|
426
494
|
try {
|
|
427
|
-
const
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
let
|
|
432
|
-
|
|
433
|
-
|
|
495
|
+
const chunk = new Uint8Array(READ_CHUNK_BYTES);
|
|
496
|
+
let lineBuf = new Uint8Array(INITIAL_RECORD_BYTES);
|
|
497
|
+
let lineLen = 0;
|
|
498
|
+
let lineOverflow = false;
|
|
499
|
+
let lineNumber = 1;
|
|
500
|
+
let problem;
|
|
501
|
+
const appendSlice = (src, start, end) => {
|
|
502
|
+
if (lineOverflow || end <= start)
|
|
503
|
+
return;
|
|
504
|
+
const add = end - start;
|
|
505
|
+
const needed = lineLen + add;
|
|
506
|
+
if (needed > MAX_RECORD_BYTES) {
|
|
507
|
+
lineOverflow = true;
|
|
508
|
+
lineLen = 0;
|
|
509
|
+
return;
|
|
510
|
+
}
|
|
511
|
+
if (needed > lineBuf.length) {
|
|
512
|
+
let nextCap = lineBuf.length;
|
|
513
|
+
while (nextCap < needed)
|
|
514
|
+
nextCap = Math.min(MAX_RECORD_BYTES, nextCap * 2);
|
|
515
|
+
const grown = new Uint8Array(nextCap);
|
|
516
|
+
grown.set(lineBuf.subarray(0, lineLen));
|
|
517
|
+
lineBuf = grown;
|
|
518
|
+
}
|
|
519
|
+
lineBuf.set(src.subarray(start, end), lineLen);
|
|
520
|
+
lineLen = needed;
|
|
521
|
+
};
|
|
522
|
+
const finishLine = () => {
|
|
523
|
+
const currentLine = lineNumber;
|
|
524
|
+
lineNumber += 1;
|
|
525
|
+
if (lineOverflow) {
|
|
526
|
+
problem ??= `line ${currentLine} exceeds the ${MAX_RECORD_BYTES}-byte record limit`;
|
|
527
|
+
lineOverflow = false;
|
|
528
|
+
lineLen = 0;
|
|
529
|
+
return false;
|
|
530
|
+
}
|
|
531
|
+
const verdict = classifyTranscriptLine(lineBuf.subarray(0, lineLen), uuid);
|
|
532
|
+
lineLen = 0;
|
|
533
|
+
if (verdict === "match")
|
|
534
|
+
return true;
|
|
535
|
+
if (verdict === "invalid") {
|
|
536
|
+
problem ??= `line ${currentLine} could not be parsed as a valid transcript record`;
|
|
537
|
+
}
|
|
538
|
+
return false;
|
|
539
|
+
};
|
|
540
|
+
for (;; ) {
|
|
541
|
+
const { bytesRead } = await handle.read(chunk, 0, chunk.length, null);
|
|
434
542
|
if (bytesRead === 0)
|
|
435
543
|
break;
|
|
436
|
-
|
|
544
|
+
let start = 0;
|
|
545
|
+
for (let i = 0;i < bytesRead; i += 1) {
|
|
546
|
+
if (chunk[i] === 10) {
|
|
547
|
+
appendSlice(chunk, start, i);
|
|
548
|
+
if (finishLine())
|
|
549
|
+
return true;
|
|
550
|
+
start = i + 1;
|
|
551
|
+
}
|
|
552
|
+
}
|
|
553
|
+
appendSlice(chunk, start, bytesRead);
|
|
437
554
|
}
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
if (trimmed.length === 0)
|
|
443
|
-
continue;
|
|
444
|
-
try {
|
|
445
|
-
const record = JSON.parse(trimmed);
|
|
446
|
-
if (typeof record === "object" && record !== null && Reflect.get(record, "uuid") === uuid)
|
|
447
|
-
return true;
|
|
448
|
-
} catch {}
|
|
555
|
+
if ((lineLen > 0 || lineOverflow) && finishLine())
|
|
556
|
+
return true;
|
|
557
|
+
if (problem !== undefined) {
|
|
558
|
+
throw new Error(`Claude transcript ${path} could not prove absence of input: ${problem}`);
|
|
449
559
|
}
|
|
450
560
|
return false;
|
|
451
561
|
} finally {
|
|
@@ -473,4 +583,4 @@ async function findTranscriptInput(engine, input) {
|
|
|
473
583
|
}), input.clientId);
|
|
474
584
|
}
|
|
475
585
|
|
|
476
|
-
export { claudeUserMessage, claudePermissionResponse, claudeControlError, claudeInterrupt, newClaudeTurnState, classifyClaudeRecord, claudePlanWindows2, claudeTranscriptPath2, claudeTranscriptExists, findTranscriptInput };
|
|
586
|
+
export { claudeUserContent, claudeUserMessage, claudePermissionResponse, claudeControlError, claudeInterrupt, newClaudeTurnState, classifyClaudeRecord, claudePlanWindows2, claudeTranscriptPath2, claudeTranscriptExists, findTranscriptInput };
|