@sema-agent/server 1.322.0 → 2.0.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/dist/approval-hmac.d.ts +40 -0
- package/dist/approval-hmac.js +67 -0
- package/dist/approval.d.ts +31 -0
- package/dist/approval.js +72 -4
- package/dist/audit.d.ts +26 -0
- package/dist/audit.js +40 -1
- package/dist/auth-bridge.d.ts +10 -0
- package/dist/auth-bridge.js +47 -4
- package/dist/auth-keys.d.ts +19 -0
- package/dist/auth-keys.js +13 -0
- package/dist/bake-runner/main.d.ts +5 -0
- package/dist/bake-runner/main.js +43 -4
- package/dist/bake-runner/protocol.d.ts +57 -0
- package/dist/bake-runner/protocol.js +58 -3
- package/dist/bake-runner/runner.d.ts +54 -0
- package/dist/bake-runner/runner.js +87 -5
- package/dist/bench/l8/artifact.d.ts +63 -0
- package/dist/bench/l8/artifact.js +61 -2
- package/dist/bench/l8/escape.d.ts +36 -0
- package/dist/bench/l8/escape.js +25 -0
- package/dist/bench/l8/index.d.ts +14 -0
- package/dist/bench/l8/index.js +14 -0
- package/dist/bench/l8/probes.d.ts +74 -0
- package/dist/bench/l8/probes.js +60 -0
- package/dist/bench/l8/run-probes.d.ts +43 -0
- package/dist/bench/l8/run-probes.js +45 -2
- package/dist/bench/s1/arms.d.ts +126 -0
- package/dist/bench/s1/arms.js +188 -13
- package/dist/bench/s1/live-deps.d.ts +66 -0
- package/dist/bench/s1/live-deps.js +249 -11
- package/dist/bench/s1/oracle.d.ts +49 -0
- package/dist/bench/s1/oracle.js +36 -1
- package/dist/bench/s1/repair-oracle-adapter.d.ts +33 -0
- package/dist/bench/s1/repair-oracle-adapter.js +30 -0
- package/dist/bench/s1/reviewer.d.ts +38 -0
- package/dist/bench/s1/reviewer.js +34 -0
- package/dist/bench/s1/row.d.ts +77 -0
- package/dist/bench/s1/row.js +62 -0
- package/dist/bench/s1/run-firm.d.ts +47 -0
- package/dist/bench/s1/run-firm.js +70 -4
- package/dist/bench/s1/runner-ctx.d.ts +71 -0
- package/dist/bench/s1/runner-ctx.js +36 -0
- package/dist/bench/s1/tasks.d.ts +108 -0
- package/dist/bench/s1/tasks.js +115 -0
- package/dist/boot-reclaim.d.ts +19 -0
- package/dist/boot-reclaim.js +20 -0
- package/dist/brain.d.ts +25 -0
- package/dist/brain.js +61 -1
- package/dist/budget.d.ts +66 -0
- package/dist/budget.js +128 -4
- package/dist/capabilities/builtin-tools.d.ts +3 -0
- package/dist/capabilities/builtin-tools.js +3 -0
- package/dist/capabilities/center-plugins.d.ts +17 -1
- package/dist/capabilities/center-plugins.js +45 -4
- package/dist/capabilities/center-prompts.d.ts +46 -0
- package/dist/capabilities/center-prompts.js +57 -3
- package/dist/capabilities/code-review-council.d.ts +28 -0
- package/dist/capabilities/code-review-council.js +40 -7
- package/dist/capabilities/collab-wire.d.ts +2 -0
- package/dist/capabilities/collab-workflows.d.ts +7 -0
- package/dist/capabilities/collab-workflows.js +44 -1
- package/dist/capabilities/oa-tools.d.ts +6 -0
- package/dist/capabilities/oa-tools.js +10 -0
- package/dist/capabilities/prompt.d.ts +14 -0
- package/dist/capabilities/prompt.js +14 -0
- package/dist/capabilities/prompts/code-review.d.ts +14 -0
- package/dist/capabilities/prompts/code-review.js +14 -0
- package/dist/capabilities/prompts/identity.d.ts +6 -0
- package/dist/capabilities/prompts/identity.js +6 -0
- package/dist/capabilities/prompts/team.d.ts +4 -0
- package/dist/capabilities/prompts/team.js +4 -0
- package/dist/capabilities/repo-tools.d.ts +11 -0
- package/dist/capabilities/repo-tools.js +8 -0
- package/dist/capabilities/sandbox-file-send.d.ts +95 -0
- package/dist/capabilities/sandbox-file-send.js +91 -3
- package/dist/capabilities/scenarios.d.ts +130 -0
- package/dist/capabilities/scenarios.js +180 -7
- package/dist/capabilities/select-environment-tool.d.ts +7 -0
- package/dist/capabilities/select-environment-tool.js +30 -0
- package/dist/capabilities/send-user-file-tool.d.ts +33 -0
- package/dist/capabilities/send-user-file-tool.js +65 -1
- package/dist/capabilities/skills.d.ts +29 -0
- package/dist/capabilities/skills.js +13 -2
- package/dist/capabilities/team.d.ts +22 -0
- package/dist/capabilities/team.js +22 -2
- package/dist/capabilities/tool-defer.d.ts +26 -0
- package/dist/capabilities/tool-defer.js +3 -0
- package/dist/config-center/apply-effective.d.ts +65 -0
- package/dist/config-center/apply-effective.js +204 -12
- package/dist/config-center/http-client.d.ts +34 -0
- package/dist/config-center/http-client.js +68 -0
- package/dist/config-center/restart-signal.d.ts +22 -0
- package/dist/config-center/restart-signal.js +39 -0
- package/dist/config-center/skills-mcp.d.ts +20 -1
- package/dist/config-center/skills-mcp.js +42 -7
- package/dist/config-center/types.d.ts +92 -1
- package/dist/config-lkg.d.ts +12 -0
- package/dist/config-lkg.js +41 -0
- package/dist/config-provider.d.ts +78 -0
- package/dist/config-provider.js +165 -2
- package/dist/config-types.d.ts +546 -0
- package/dist/config.d.ts +64 -0
- package/dist/config.js +455 -60
- package/dist/degenerate-instrument.d.ts +38 -0
- package/dist/degenerate-instrument.js +55 -3
- package/dist/elicitation.d.ts +39 -0
- package/dist/elicitation.js +87 -3
- package/dist/env-facts.d.ts +61 -0
- package/dist/env-facts.js +73 -7
- package/dist/fleet/fleet-bus.d.ts +185 -0
- package/dist/fleet/fleet-bus.js +333 -27
- package/dist/fleet/subagent-tail-bus.d.ts +11 -0
- package/dist/fleet/subagent-tail-bus.js +33 -2
- package/dist/fleet-client.d.ts +38 -0
- package/dist/fleet-client.js +44 -9
- package/dist/fleet-lease.d.ts +46 -0
- package/dist/fleet-lease.js +73 -5
- package/dist/hooks/branch-transcript.d.ts +8 -0
- package/dist/hooks/branch-transcript.js +33 -0
- package/dist/hooks/cc-stop-prompt.d.ts +42 -0
- package/dist/hooks/cc-stop-prompt.js +43 -1
- package/dist/hooks/hook-llm.d.ts +15 -0
- package/dist/hooks/hook-llm.js +47 -0
- package/dist/hooks/hook-runner.d.ts +89 -0
- package/dist/hooks/hook-runner.js +327 -18
- package/dist/http/idempotency.d.ts +31 -0
- package/dist/http/idempotency.js +34 -0
- package/dist/http/principal-gate.d.ts +17 -0
- package/dist/http/principal-gate.js +35 -3
- package/dist/http/route-ctx.d.ts +36 -0
- package/dist/http/routes/approvals-assistant.d.ts +25 -0
- package/dist/http/routes/approvals-assistant.js +253 -23
- package/dist/http/routes/attachments.js +22 -4
- package/dist/http/routes/capabilities.d.ts +7 -0
- package/dist/http/routes/capabilities.js +202 -1
- package/dist/http/routes/fleet.d.ts +6 -0
- package/dist/http/routes/fleet.js +94 -5
- package/dist/http/routes/images.d.ts +17 -0
- package/dist/http/routes/images.js +222 -14
- package/dist/http/routes/leader.d.ts +7 -0
- package/dist/http/routes/leader.js +10 -0
- package/dist/http/routes/memory-policy.d.ts +6 -0
- package/dist/http/routes/memory-policy.js +38 -6
- package/dist/http/routes/notify-wake.d.ts +10 -0
- package/dist/http/routes/notify-wake.js +19 -3
- package/dist/http/routes/observability.d.ts +6 -0
- package/dist/http/routes/observability.js +19 -2
- package/dist/http/routes/runs.d.ts +15 -0
- package/dist/http/routes/runs.js +464 -41
- package/dist/http/routes/session-sync.d.ts +15 -0
- package/dist/http/routes/session-sync.js +229 -19
- package/dist/http/routes/sessions-list.d.ts +6 -0
- package/dist/http/routes/sessions-list.js +35 -4
- package/dist/http/routes/sessions.d.ts +14 -0
- package/dist/http/routes/sessions.js +176 -31
- package/dist/http/routes/side-query.d.ts +8 -0
- package/dist/http/routes/side-query.js +26 -1
- package/dist/http/routes/tasks.d.ts +18 -0
- package/dist/http/routes/tasks.js +501 -38
- package/dist/http/routes/trace-usage.d.ts +10 -0
- package/dist/http/routes/trace-usage.js +66 -14
- package/dist/http/routes/workflows.d.ts +12 -0
- package/dist/http/routes/workflows.js +180 -19
- package/dist/http/run-meta.d.ts +11 -0
- package/dist/http/run-meta.js +6 -0
- package/dist/http/send.d.ts +19 -0
- package/dist/http/send.js +11 -0
- package/dist/http/server.d.ts +255 -0
- package/dist/http/server.js +921 -75
- package/dist/http/sse-log.d.ts +15 -0
- package/dist/http/sse-log.js +16 -0
- package/dist/http/tar.d.ts +9 -0
- package/dist/http/tar.js +21 -5
- package/dist/http/wire-gate.d.ts +9 -0
- package/dist/http/wire-gate.js +9 -0
- package/dist/http/wire-types.d.ts +187 -0
- package/dist/http/workspace-content.d.ts +8 -0
- package/dist/http/workspace-content.js +10 -0
- package/dist/images/bake-validate.d.ts +63 -0
- package/dist/images/bake-validate.js +71 -1
- package/dist/images/manifest.d.ts +19 -0
- package/dist/images/manifest.js +6 -1
- package/dist/index.d.ts +1 -5
- package/dist/index.js +10 -5
- package/dist/key-resolver.d.ts +23 -0
- package/dist/key-resolver.js +27 -2
- package/dist/leader/diffout.d.ts +23 -0
- package/dist/leader/diffout.js +8 -1
- package/dist/leader/diffup.d.ts +32 -0
- package/dist/leader/diffup.js +43 -0
- package/dist/leader/endpoint.d.ts +20 -0
- package/dist/leader/endpoint.js +25 -2
- package/dist/leader/fanout.d.ts +60 -0
- package/dist/leader/fanout.js +29 -3
- package/dist/leader/grader-env-factory.d.ts +74 -0
- package/dist/leader/grader-env-factory.js +62 -3
- package/dist/leader/leader.d.ts +97 -0
- package/dist/leader/leader.js +151 -4
- package/dist/leader/merge.d.ts +94 -0
- package/dist/leader/merge.js +112 -9
- package/dist/leader/planner.d.ts +52 -0
- package/dist/leader/planner.js +47 -3
- package/dist/leader/repair-oracle.d.ts +61 -0
- package/dist/leader/repair-oracle.js +59 -1
- package/dist/leader/repair-wire.d.ts +78 -0
- package/dist/leader/repair-wire.js +79 -2
- package/dist/leader/wire.d.ts +79 -0
- package/dist/leader/wire.js +255 -8
- package/dist/lsp/e2b-bridge.d.ts +16 -0
- package/dist/lsp/e2b-bridge.js +32 -4
- package/dist/lsp/e2b-manager.d.ts +10 -0
- package/dist/lsp/e2b-manager.js +18 -2
- package/dist/lsp/lsp-frames.d.ts +12 -0
- package/dist/lsp/lsp-frames.js +12 -0
- package/dist/lsp/manager.d.ts +12 -0
- package/dist/lsp/manager.js +35 -2
- package/dist/lsp/types.d.ts +10 -0
- package/dist/lsp/ws-transport.d.ts +12 -0
- package/dist/lsp/ws-transport.js +53 -5
- package/dist/lsp-evict.d.ts +14 -0
- package/dist/lsp-evict.js +15 -1
- package/dist/main.js +2132 -96
- package/dist/memory-export.d.ts +1 -0
- package/dist/memory-export.js +4 -0
- package/dist/memory-scope.d.ts +49 -0
- package/dist/memory-scope.js +87 -4
- package/dist/memory-sync-client.d.ts +24 -0
- package/dist/memory-sync-client.js +41 -2
- package/dist/memory-sync.d.ts +23 -0
- package/dist/memory-sync.js +70 -1
- package/dist/model-select.d.ts +39 -0
- package/dist/model-select.js +42 -1
- package/dist/observability/cost-quota.d.ts +20 -0
- package/dist/observability/cost-quota.js +4 -0
- package/dist/observability/cost-taxonomy.d.ts +45 -0
- package/dist/observability/cost-taxonomy.js +34 -0
- package/dist/observability/logger.d.ts +1 -0
- package/dist/observability/logger.js +6 -0
- package/dist/observability/metrics.d.ts +13 -0
- package/dist/observability/metrics.js +63 -0
- package/dist/observability/otel-exporter.d.ts +9 -0
- package/dist/observability/otel-exporter.js +11 -3
- package/dist/observability/principal-context.d.ts +9 -0
- package/dist/observability/principal-context.js +9 -0
- package/dist/observability/prompt-manifest.d.ts +37 -0
- package/dist/observability/prompt-manifest.js +35 -1
- package/dist/observability/rate-limit.d.ts +10 -0
- package/dist/observability/rate-limit.js +1 -0
- package/dist/observability/tool-trace.d.ts +24 -0
- package/dist/observability/tool-trace.js +41 -1
- package/dist/orchestration/hardened-vm-runner.d.ts +107 -0
- package/dist/orchestration/hardened-vm-runner.js +119 -4
- package/dist/orchestration/hardened-vm-worker-runner.d.ts +14 -0
- package/dist/orchestration/hardened-vm-worker-runner.js +26 -1
- package/dist/orchestration/hardened-vm-worker.js +27 -0
- package/dist/orchestration/subagent-steer.d.ts +44 -0
- package/dist/orchestration/subagent-steer.js +45 -1
- package/dist/orchestration/workflow-agent-steer.d.ts +54 -0
- package/dist/orchestration/workflow-agent-steer.js +80 -1
- package/dist/orchestration/workflow-completion-inbox.d.ts +189 -2
- package/dist/orchestration/workflow-completion-inbox.js +283 -32
- package/dist/orchestration/workflow-notify-journal.d.ts +132 -1
- package/dist/orchestration/workflow-notify-journal.js +187 -13
- package/dist/parked-decide.d.ts +61 -0
- package/dist/parked-decide.js +58 -1
- package/dist/per-task-image.d.ts +54 -0
- package/dist/per-task-image.js +41 -0
- package/dist/plan-cache-probe.d.ts +35 -0
- package/dist/plan-cache-probe.js +18 -3
- package/dist/plugins/approval-exemption-store.d.ts +7 -0
- package/dist/plugins/approval-exemption-store.js +28 -2
- package/dist/plugins/approval-store-sql.d.ts +64 -0
- package/dist/plugins/approval-store-sql.js +32 -0
- package/dist/plugins/background-agent-store-sql.d.ts +55 -0
- package/dist/plugins/background-agent-store-sql.js +91 -4
- package/dist/plugins/background-shell-support.d.ts +98 -0
- package/dist/plugins/background-shell-support.js +117 -13
- package/dist/plugins/blob-backend.d.ts +104 -0
- package/dist/plugins/blob-backend.js +163 -6
- package/dist/plugins/breaker-state-sql.d.ts +65 -1
- package/dist/plugins/breaker-state-sql.js +46 -8
- package/dist/plugins/caching-session-store.d.ts +42 -0
- package/dist/plugins/caching-session-store.js +63 -3
- package/dist/plugins/checkpoint-store-sql.d.ts +179 -0
- package/dist/plugins/checkpoint-store-sql.js +239 -11
- package/dist/plugins/file-outcome-sink.d.ts +4 -0
- package/dist/plugins/file-outcome-sink.js +9 -0
- package/dist/plugins/file-resume-anchor-store.d.ts +20 -0
- package/dist/plugins/file-resume-anchor-store.js +43 -4
- package/dist/plugins/file-run-store.d.ts +90 -0
- package/dist/plugins/file-run-store.js +145 -13
- package/dist/plugins/file-snapshot-store-sql.d.ts +133 -1
- package/dist/plugins/file-snapshot-store-sql.js +178 -10
- package/dist/plugins/file-workflow-journal-store.d.ts +10 -0
- package/dist/plugins/file-workflow-journal-store.js +10 -0
- package/dist/plugins/fork-routing-session-store.d.ts +47 -0
- package/dist/plugins/fork-routing-session-store.js +51 -3
- package/dist/plugins/host-platform.d.ts +69 -0
- package/dist/plugins/host-platform.js +81 -2
- package/dist/plugins/image-bake-store-sql.d.ts +136 -1
- package/dist/plugins/image-bake-store-sql.js +241 -7
- package/dist/plugins/image-index-sql.d.ts +46 -0
- package/dist/plugins/image-index-sql.js +113 -4
- package/dist/plugins/k8s-bg-scripts.d.ts +34 -0
- package/dist/plugins/k8s-bg-scripts.js +88 -4
- package/dist/plugins/k8s-exec-protocol.d.ts +33 -0
- package/dist/plugins/k8s-exec-protocol.js +41 -0
- package/dist/plugins/local-checkpoint-store.d.ts +40 -0
- package/dist/plugins/local-checkpoint-store.js +86 -7
- package/dist/plugins/local-session-store.d.ts +157 -0
- package/dist/plugins/local-session-store.js +289 -34
- package/dist/plugins/local-task-attachment-store.js +14 -2
- package/dist/plugins/mailbox-store-sql.d.ts +38 -0
- package/dist/plugins/mailbox-store-sql.js +39 -6
- package/dist/plugins/memory-engine-pg.d.ts +30 -0
- package/dist/plugins/memory-engine-pg.js +122 -4
- package/dist/plugins/memory-engine-tidb.d.ts +26 -0
- package/dist/plugins/memory-engine-tidb.js +115 -5
- package/dist/plugins/memory-engine-vector-util.d.ts +5 -0
- package/dist/plugins/memory-engine-vector-util.js +5 -0
- package/dist/plugins/memory-resume-anchor-store.d.ts +8 -0
- package/dist/plugins/memory-resume-anchor-store.js +17 -0
- package/dist/plugins/memory-run-store.d.ts +63 -0
- package/dist/plugins/memory-run-store.js +73 -8
- package/dist/plugins/memory-session-policy-store.d.ts +17 -0
- package/dist/plugins/memory-session-policy-store.js +17 -0
- package/dist/plugins/memory-sync-store-pg.d.ts +42 -0
- package/dist/plugins/memory-sync-store-pg.js +45 -2
- package/dist/plugins/memory-sync-store-tidb.d.ts +9 -0
- package/dist/plugins/memory-sync-store-tidb.js +31 -1
- package/dist/plugins/outcome-ledger-sql.d.ts +63 -0
- package/dist/plugins/outcome-ledger-sql.js +97 -3
- package/dist/plugins/pg-approval-store.d.ts +7 -0
- package/dist/plugins/pg-approval-store.js +7 -0
- package/dist/plugins/pg-breaker-state.d.ts +6 -0
- package/dist/plugins/pg-breaker-state.js +6 -0
- package/dist/plugins/pg-checkpoint-store.d.ts +8 -0
- package/dist/plugins/pg-checkpoint-store.js +8 -0
- package/dist/plugins/pg-cost-quota.d.ts +17 -0
- package/dist/plugins/pg-cost-quota.js +6 -0
- package/dist/plugins/pg-file-snapshot-store.d.ts +6 -0
- package/dist/plugins/pg-file-snapshot-store.js +6 -0
- package/dist/plugins/pg-image-bake.d.ts +9 -0
- package/dist/plugins/pg-image-bake.js +9 -0
- package/dist/plugins/pg-image-index.d.ts +9 -0
- package/dist/plugins/pg-image-index.js +9 -0
- package/dist/plugins/pg-outcome-ledger.d.ts +9 -0
- package/dist/plugins/pg-outcome-ledger.js +9 -0
- package/dist/plugins/pg-pool.d.ts +50 -0
- package/dist/plugins/pg-pool.js +78 -0
- package/dist/plugins/pg-query.d.ts +11 -0
- package/dist/plugins/pg-rate-limiter.d.ts +23 -0
- package/dist/plugins/pg-rate-limiter.js +12 -2
- package/dist/plugins/pg-resume-anchor-store.d.ts +5 -0
- package/dist/plugins/pg-resume-anchor-store.js +5 -0
- package/dist/plugins/pg-run-store.d.ts +7 -0
- package/dist/plugins/pg-run-store.js +7 -0
- package/dist/plugins/pg-safe-json.d.ts +13 -0
- package/dist/plugins/pg-safe-json.js +40 -4
- package/dist/plugins/pg-session-policy-store.d.ts +5 -0
- package/dist/plugins/pg-session-policy-store.js +5 -0
- package/dist/plugins/pg-session-storage.d.ts +72 -0
- package/dist/plugins/pg-session-storage.js +152 -20
- package/dist/plugins/pg-session-store.d.ts +10 -0
- package/dist/plugins/pg-session-store.js +10 -0
- package/dist/plugins/pg-tool-result-store.d.ts +7 -0
- package/dist/plugins/pg-tool-result-store.js +7 -0
- package/dist/plugins/pg-workflow-journal-store.d.ts +7 -0
- package/dist/plugins/pg-workflow-journal-store.js +7 -0
- package/dist/plugins/pg-workflow-run-store.d.ts +7 -0
- package/dist/plugins/pg-workflow-run-store.js +7 -0
- package/dist/plugins/posix-shell-fs.d.ts +3 -0
- package/dist/plugins/posix-shell-fs.js +31 -1
- package/dist/plugins/remote-env-adb.d.ts +25 -0
- package/dist/plugins/remote-env-adb.js +95 -12
- package/dist/plugins/remote-env-e2b.d.ts +146 -0
- package/dist/plugins/remote-env-e2b.js +371 -40
- package/dist/plugins/remote-env-file-error.d.ts +34 -0
- package/dist/plugins/remote-env-file-error.js +37 -0
- package/dist/plugins/remote-env-host.d.ts +151 -0
- package/dist/plugins/remote-env-host.js +468 -70
- package/dist/plugins/remote-env-k8s.d.ts +135 -0
- package/dist/plugins/remote-env-k8s.js +318 -32
- package/dist/plugins/remote-env-local-docker.d.ts +65 -0
- package/dist/plugins/remote-env-local-docker.js +149 -24
- package/dist/plugins/remote-env-ssh.d.ts +35 -0
- package/dist/plugins/remote-env-ssh.js +117 -20
- package/dist/plugins/remote-scratchpad.d.ts +38 -0
- package/dist/plugins/remote-scratchpad.js +32 -2
- package/dist/plugins/remote-shell.d.ts +22 -0
- package/dist/plugins/remote-shell.js +27 -1
- package/dist/plugins/resume-anchor-store-sql.d.ts +28 -0
- package/dist/plugins/resume-anchor-store-sql.js +11 -0
- package/dist/plugins/roster-store-sql.d.ts +27 -0
- package/dist/plugins/roster-store-sql.js +54 -0
- package/dist/plugins/run-store-sql.d.ts +194 -0
- package/dist/plugins/run-store-sql.js +210 -9
- package/dist/plugins/s3-presign.d.ts +20 -0
- package/dist/plugins/s3-presign.js +49 -2
- package/dist/plugins/scheduler-support.d.ts +12 -0
- package/dist/plugins/scheduler-support.js +75 -3
- package/dist/plugins/send-file-ledger.d.ts +15 -0
- package/dist/plugins/send-file-ledger.js +53 -4
- package/dist/plugins/send-user-file.d.ts +77 -0
- package/dist/plugins/send-user-file.js +92 -4
- package/dist/plugins/session-policy-store-sql.d.ts +15 -0
- package/dist/plugins/session-policy-store-sql.js +75 -3
- package/dist/plugins/session-store.d.ts +45 -0
- package/dist/plugins/session-store.js +51 -0
- package/dist/plugins/sql-driver.d.ts +77 -0
- package/dist/plugins/sql-driver.js +4 -0
- package/dist/plugins/sql-escape.d.ts +8 -0
- package/dist/plugins/sql-escape.js +8 -0
- package/dist/plugins/sql-row-helpers.d.ts +25 -0
- package/dist/plugins/sql-row-helpers.js +25 -0
- package/dist/plugins/store-backend.d.ts +103 -0
- package/dist/plugins/store-backend.js +120 -27
- package/dist/plugins/store-contracts.d.ts +62 -0
- package/dist/plugins/store-contracts.js +3 -0
- package/dist/plugins/task-attachment-store.d.ts +60 -0
- package/dist/plugins/task-attachment-store.js +49 -3
- package/dist/plugins/task-list-store-sql.d.ts +25 -0
- package/dist/plugins/task-list-store-sql.js +21 -0
- package/dist/plugins/tidb-approval-store.d.ts +6 -0
- package/dist/plugins/tidb-approval-store.js +6 -0
- package/dist/plugins/tidb-breaker-state.d.ts +5 -0
- package/dist/plugins/tidb-breaker-state.js +5 -0
- package/dist/plugins/tidb-checkpoint-store.d.ts +7 -0
- package/dist/plugins/tidb-checkpoint-store.js +7 -0
- package/dist/plugins/tidb-cost-quota.d.ts +6 -0
- package/dist/plugins/tidb-cost-quota.js +1 -0
- package/dist/plugins/tidb-file-snapshot-store.d.ts +6 -0
- package/dist/plugins/tidb-file-snapshot-store.js +6 -0
- package/dist/plugins/tidb-image-bake.d.ts +8 -0
- package/dist/plugins/tidb-image-bake.js +8 -0
- package/dist/plugins/tidb-image-index.d.ts +8 -0
- package/dist/plugins/tidb-image-index.js +8 -0
- package/dist/plugins/tidb-outcome-ledger.d.ts +10 -0
- package/dist/plugins/tidb-outcome-ledger.js +10 -0
- package/dist/plugins/tidb-pool.d.ts +56 -0
- package/dist/plugins/tidb-pool.js +181 -1
- package/dist/plugins/tidb-rate-limiter.d.ts +11 -0
- package/dist/plugins/tidb-rate-limiter.js +5 -2
- package/dist/plugins/tidb-resume-anchor-store.d.ts +5 -0
- package/dist/plugins/tidb-resume-anchor-store.js +5 -0
- package/dist/plugins/tidb-run-store.d.ts +7 -0
- package/dist/plugins/tidb-run-store.js +7 -0
- package/dist/plugins/tidb-session-policy-store.d.ts +5 -0
- package/dist/plugins/tidb-session-policy-store.js +5 -0
- package/dist/plugins/tidb-session-storage.d.ts +43 -0
- package/dist/plugins/tidb-session-storage.js +62 -3
- package/dist/plugins/tidb-session-store.d.ts +142 -0
- package/dist/plugins/tidb-session-store.js +264 -16
- package/dist/plugins/tidb-tool-result-store.d.ts +5 -0
- package/dist/plugins/tidb-tool-result-store.js +7 -0
- package/dist/plugins/tidb-workflow-journal-store.d.ts +7 -0
- package/dist/plugins/tidb-workflow-journal-store.js +7 -0
- package/dist/plugins/tidb-workflow-run-store.d.ts +8 -0
- package/dist/plugins/tidb-workflow-run-store.js +8 -0
- package/dist/plugins/tool-result-store-sql.d.ts +58 -0
- package/dist/plugins/tool-result-store-sql.js +38 -2
- package/dist/plugins/web-search.d.ts +35 -0
- package/dist/plugins/web-search.js +45 -9
- package/dist/plugins/workflow-journal-limits.d.ts +10 -0
- package/dist/plugins/workflow-journal-limits.js +10 -0
- package/dist/plugins/workflow-journal-store-sql.d.ts +78 -0
- package/dist/plugins/workflow-journal-store-sql.js +59 -3
- package/dist/plugins/workflow-run-store-sql.d.ts +84 -0
- package/dist/plugins/workflow-run-store-sql.js +84 -6
- package/dist/plugins/worktree-isolation.d.ts +45 -0
- package/dist/plugins/worktree-isolation.js +105 -6
- package/dist/plugins/write-behind-counter.d.ts +56 -1
- package/dist/plugins/write-behind-counter.js +53 -14
- package/dist/principal-jwt.d.ts +24 -0
- package/dist/principal-jwt.js +60 -5
- package/dist/project-memory.d.ts +22 -0
- package/dist/project-memory.js +144 -15
- package/dist/prompts-domain-validate.d.ts +28 -0
- package/dist/prompts-domain-validate.js +42 -1
- package/dist/question.d.ts +33 -0
- package/dist/question.js +69 -2
- package/dist/resource-suspend.d.ts +21 -0
- package/dist/resource-suspend.js +16 -0
- package/dist/router/route-orchestration.d.ts +78 -0
- package/dist/router/route-orchestration.js +77 -0
- package/dist/run-local.d.ts +32 -0
- package/dist/run-local.js +172 -8
- package/dist/runs.d.ts +189 -4
- package/dist/runs.js +465 -24
- package/dist/runtime-caps-resolver.d.ts +106 -0
- package/dist/runtime-caps-resolver.js +89 -4
- package/dist/runtime-governance.d.ts +84 -0
- package/dist/runtime-governance.js +127 -1
- package/dist/sandbox-pkg-source.d.ts +23 -0
- package/dist/sandbox-pkg-source.js +37 -0
- package/dist/sealed-key.d.ts +54 -0
- package/dist/sealed-key.js +68 -3
- package/dist/security.d.ts +108 -0
- package/dist/security.js +145 -6
- package/dist/sema-registry.d.ts +21 -0
- package/dist/sema-registry.js +21 -0
- package/dist/session-leaf-bus.d.ts +31 -0
- package/dist/session-leaf-bus.js +32 -0
- package/dist/session-sync-content.d.ts +46 -0
- package/dist/session-sync-content.js +47 -1
- package/dist/session-sync-kernel.d.ts +89 -0
- package/dist/session-sync-kernel.js +48 -3
- package/dist/session-sync.d.ts +125 -0
- package/dist/session-sync.js +181 -8
- package/dist/session-titler.d.ts +26 -0
- package/dist/session-titler.js +41 -7
- package/dist/session-watch.d.ts +53 -1
- package/dist/session-watch.js +73 -9
- package/dist/sighup-idle.d.ts +30 -0
- package/dist/sighup-idle.js +12 -1
- package/dist/spec-fields.d.ts +91 -3
- package/dist/spec-fields.js +116 -4
- package/dist/task-cwd.d.ts +50 -0
- package/dist/task-cwd.js +68 -1
- package/dist/task-mcp.d.ts +47 -0
- package/dist/task-mcp.js +29 -0
- package/dist/task-settings.d.ts +175 -0
- package/dist/task-settings.js +226 -11
- package/dist/task-workflow.d.ts +67 -0
- package/dist/task-workflow.js +75 -8
- package/dist/tool-approval.d.ts +91 -0
- package/dist/tool-approval.js +215 -0
- package/dist/trace/artifacts.d.ts +9 -0
- package/dist/trace/artifacts.js +30 -5
- package/dist/trace/core-keyset-guard.d.ts +18 -0
- package/dist/trace/ledger-sink.d.ts +43 -0
- package/dist/trace/ledger-sink.js +64 -5
- package/dist/trace/project.d.ts +133 -0
- package/dist/trace/project.js +189 -2
- package/dist/trace/redact.d.ts +19 -0
- package/dist/trace/redact.js +66 -9
- package/dist/usage-analytics.d.ts +26 -0
- package/dist/usage-analytics.js +26 -3
- package/package.json +1 -1
|
@@ -4,9 +4,19 @@ import { NotifiedKeys, taskNotificationStreamKey } from "../orchestration/workfl
|
|
|
4
4
|
export function createLedgerSink(opts) {
|
|
5
5
|
const keys = opts.notifiedKeys ?? new NotifiedKeys();
|
|
6
6
|
let seq = 0;
|
|
7
|
+
// [1.211 codex H2] 单写串行链:seq 的「分配」在链步内发生 ⇒ 分配序 == durable 提交序。没有它,
|
|
8
|
+
// onForwardEvent 的 fire-and-forget 写与主循环的 awaited 写交错时,高 seq 可先落盘对 events tail 可见,
|
|
9
|
+
// 迟到的低 seq 在读方游标(afterSeq)前进后被永久遗漏。链上一步失败不断链(catch → undefined),
|
|
10
|
+
// 调用方拿到的是自己那步的真实结果(await 者照常收到 reject)。
|
|
7
11
|
let chain = Promise.resolve();
|
|
8
12
|
let text = "";
|
|
9
13
|
let reasoning = "";
|
|
14
|
+
// E18 resume-at: the turn's FIRST text_delta eventId = the message's stable per-message resume handle,
|
|
15
|
+
// stamped on the durable `text` event (ONE handle per message even when a mid-turn tool_start flushes the
|
|
16
|
+
// text early). Latched on the first DEFINED eventId of the turn (`??=` — a later part after a tool must not
|
|
17
|
+
// re-latch), cleared at turn_end — the exact `TurnAnchorCapture.firstTextEventId` semantics. (The bg leg's
|
|
18
|
+
// anchor tracks the same value for its own anchor-put; both latches see the same events in the same order,
|
|
19
|
+
// so the stamps agree byte-for-byte — the anchor's extra `turnHadTool` state never feeds the stamp.)
|
|
10
20
|
let textEventId;
|
|
11
21
|
const append = (type, data) => {
|
|
12
22
|
const step = chain.then(() => opts.appendEvent(++seq, type, data));
|
|
@@ -14,12 +24,14 @@ export function createLedgerSink(opts) {
|
|
|
14
24
|
return step;
|
|
15
25
|
};
|
|
16
26
|
const flush = async () => {
|
|
27
|
+
// Thinking precedes content within a turn → flush a buffered reasoning block FIRST (redacted).
|
|
17
28
|
if (reasoning) {
|
|
18
29
|
await append("reasoning", { text: redactSecrets(reasoning) });
|
|
19
30
|
reasoning = "";
|
|
20
31
|
}
|
|
21
32
|
if (text) {
|
|
22
|
-
|
|
33
|
+
// E18: stamp the turn's first-text eventId as the per-message resume handle (additive; tolerate-absent).
|
|
34
|
+
await append("text", { text, ...(textEventId ? { eventId: textEventId } : {}) }); // persist first; clear only on success so a failed write doesn't drop it
|
|
23
35
|
text = "";
|
|
24
36
|
}
|
|
25
37
|
};
|
|
@@ -32,45 +44,85 @@ export function createLedgerSink(opts) {
|
|
|
32
44
|
break;
|
|
33
45
|
}
|
|
34
46
|
case "reasoning_delta":
|
|
47
|
+
// Persist the agent's thinking for the trace UI (core [R57]: reasoning IS on the live stream but NOT in
|
|
48
|
+
// the metadata Tracer — capturing it is the service's call). Gated by TRACE_THINKING; redacted on flush.
|
|
35
49
|
if (opts.persistThinking)
|
|
36
50
|
reasoning += ev.delta;
|
|
37
51
|
break;
|
|
38
52
|
case "tool_start":
|
|
39
53
|
await flush();
|
|
54
|
+
// E1+E2 (shell-host contract): redacted args + identity via the shared whitelist builder — identical
|
|
55
|
+
// persisted shape across every leg.
|
|
40
56
|
await append("tool_start", toolStartEventData(ev));
|
|
41
57
|
break;
|
|
42
58
|
case "tool_end":
|
|
43
59
|
await flush();
|
|
60
|
+
// E1: redacted model-facing output (+truncated, core size-bound) + E2 identity, via the shared builder.
|
|
44
61
|
await append("tool_end", toolEndEventData(ev));
|
|
45
62
|
break;
|
|
46
63
|
case "status":
|
|
64
|
+
// S4 (SILENT-FALLBACK P0-a): persist the brain-layer liveness observation. core marks the live frame
|
|
65
|
+
// EPHEMERAL (it never replays it) — this durable row is OUR observation record so async/replay readers
|
|
66
|
+
// can attribute a stalled turn. flush() first (review MED-2): a reconnect can fire MID-TEXT — without
|
|
67
|
+
// the flush the already-streamed text lands AFTER this row and the durable timeline inverts.
|
|
68
|
+
// design/158 B2: durable row type aligned to the live frame name ("status", not "brain_status") — the
|
|
69
|
+
// two legs were emitting the SAME logical event under two different `type` strings, and the SDK's
|
|
70
|
+
// public `AgentEvent` union only declared "status" (a durable-leg reader saw a frame outside its own
|
|
71
|
+
// public type). 写新读旧:这里只管写新;**存量行救不了**(任何旧部署的账本里都躺着 `brain_status`
|
|
72
|
+
// 行),所以重放边界配了一次性归一 —— `normalizeRunEventType`(trace/project.ts),唯一调用点是
|
|
73
|
+
// task_run SSE 的 `formatEvent`(routes/runs.ts)。两半缺一不可:只改写入侧的话,存量行重放时
|
|
74
|
+
// 仍会漏出公开联合之外的名字。无 migration、无回填(读边界归一比改历史行便宜且不可逆风险为零)。
|
|
47
75
|
await flush();
|
|
48
76
|
await append("status", brainStatusEventData(ev));
|
|
49
77
|
break;
|
|
50
78
|
case "context_usage":
|
|
79
|
+
// core 1.414 一等分支(server [1669]⑥ 要的上下文用量面)。每个压缩边界上报一次 ⇒ 一次任务多条,
|
|
80
|
+
// 消费方取最后一条为当前值。两条口径见 `contextUsageEventData` 旁注(别把 windowTokens 当模型上下文)。
|
|
51
81
|
await flush();
|
|
52
82
|
await append("context_usage", contextUsageEventData(ev));
|
|
53
83
|
break;
|
|
54
84
|
case "compacted":
|
|
55
85
|
await flush();
|
|
86
|
+
// MF-18 (1.149) trigger/tokensBefore + core 1.219 attachedFiles/preserved_segment via the SHARED
|
|
87
|
+
// whitelist builder — the shell renders CC's post-compact `Read {path}` cards + the divider from these.
|
|
56
88
|
await append("compacted", compactedEventData(ev));
|
|
57
89
|
break;
|
|
58
90
|
case "diagnostics":
|
|
91
|
+
// core 1.220 (design/121): NEW LSP diagnostics at a turn boundary — the shell's render source for CC's
|
|
92
|
+
// "Found N new diagnostic issues" row. §E1: language-server output is UNTRUSTED RAW → builder redacts.
|
|
59
93
|
await flush();
|
|
60
94
|
await append("diagnostics", diagnosticsEventData(ev));
|
|
61
95
|
break;
|
|
62
96
|
case "steering_injected":
|
|
97
|
+
// [1550]/[1552]: core's mid-run system-reminder injection (todo/file-change/date-roll/skills-delta/…) —
|
|
98
|
+
// the shell's render source for CC's steering-attachment row. §E1: preview is UNTRUSTED free text →
|
|
99
|
+
// builder redacts. Host/self-session only — NOT mirrored into onForwardEvent (a delegated child's own
|
|
100
|
+
// reminders are its internal bookkeeping, not host-relevant progress like tool_start/task_progress).
|
|
63
101
|
await flush();
|
|
64
102
|
await append("steering_injected", steeringInjectedEventData(ev));
|
|
65
103
|
break;
|
|
66
104
|
case "workspace_changed":
|
|
105
|
+
// [1559]二 core 裁定:design/99 §E13 旧臂,L1 门扩臂时首次撞见。durable 记账与其余内容型臂
|
|
106
|
+
// 同处置(轨迹回放时「何时 cd 到了哪」是合法历史事实,「不当持久态渲染」是 LIVE 消费端纪律,
|
|
107
|
+
// 不是不许落账)——共享白名单构造器 + §E1 redact。
|
|
67
108
|
await flush();
|
|
68
109
|
await append("workspace_changed", workspaceChangedEventData(ev));
|
|
69
110
|
break;
|
|
70
111
|
case "task_progress":
|
|
112
|
+
// core breakpoint⑤: a subagent's live progress tick → an INLINE "subagent working" card for the tailing
|
|
113
|
+
// client (S2-a). Shared whitelist+redact builder (+ E2 identity for the exact concurrent-tick binding).
|
|
71
114
|
await append("task_progress", taskProgressEventData(ev));
|
|
72
115
|
break;
|
|
73
116
|
case "task_notification": {
|
|
117
|
+
// core 1.202 (design/115 P2): a background task finished while this harness was live — persist the
|
|
118
|
+
// display projection so a tailing client renders it (summary/result are UNTRUSTED free text → shared
|
|
119
|
+
// builder redacts). core [784]④a+④b: seq-folded shared key + skip keys this leg already delivered
|
|
120
|
+
// (start-of-leg inbox drain or observer arm) — core's pend-drain replays a double-parked idle arrival
|
|
121
|
+
// as a stream event; appending it again doubles the frame in the durable tail. codex F1: a key claimed
|
|
122
|
+
// by a fire-and-forget arm may have FAILED to land — await the claim's outcome; false ⇒ write anyway
|
|
123
|
+
// (this stream replay is the notification's last copy on this leg) and promote the key with THIS
|
|
124
|
+
// write's outcome. The claim promise is registered before the awaited append so a concurrent observer
|
|
125
|
+
// callback can't double-claim mid-write.
|
|
74
126
|
await flush();
|
|
75
127
|
const tn = ev.notification;
|
|
76
128
|
const tnKey = tn?.task_id ? taskNotificationStreamKey({ task_type: tn.task_type, task_id: tn.task_id, status: String(tn.status), seq: tn.seq }) : undefined;
|
|
@@ -78,21 +130,26 @@ export function createLedgerSink(opts) {
|
|
|
78
130
|
if (tnPrior === undefined || !(await tnPrior)) {
|
|
79
131
|
const write = append("task_notification", taskNotificationEventData(ev));
|
|
80
132
|
if (tnKey !== undefined)
|
|
81
|
-
keys.set(tnKey, write.then(() => true, () => false));
|
|
133
|
+
keys.set(tnKey, write.then(() => true, () => false)); // the stream delivered this key
|
|
82
134
|
await write;
|
|
83
135
|
}
|
|
84
136
|
break;
|
|
85
137
|
}
|
|
86
138
|
case "turn_end": {
|
|
87
139
|
await flush();
|
|
140
|
+
// core 1.76 (service [41]/core [R59]): per-turn usage rides turn_end.usage — persist it for TraceTurn.tokens.
|
|
88
141
|
const usage = ev.usage;
|
|
89
|
-
await append("turn_end", turnEndEventData(ev));
|
|
90
|
-
textEventId = undefined;
|
|
142
|
+
await append("turn_end", turnEndEventData(ev)); // 白名单 builder(此前手写 {usage},剥掉了 stopReason/usageMissing)
|
|
143
|
+
textEventId = undefined; // next turn latches its own first-text handle (TurnAnchorCapture parity)
|
|
91
144
|
break;
|
|
92
145
|
}
|
|
146
|
+
// `done` / `message_committed` / unknown: deliberate no-ops — see the interface doc.
|
|
93
147
|
}
|
|
94
148
|
};
|
|
95
149
|
const onForwardEvent = (e) => {
|
|
150
|
+
// 1.78 (review HIGH) + C1 (core 1.219, spec.forwardSubagentEvents): a delegated child's lifecycle rides the
|
|
151
|
+
// forward sink (each stamped parentToolCallId — the shell nests them under the delegation card). Same
|
|
152
|
+
// shared builders as the top stream; fire-and-forget (`++seq` is sync → unique seqs vs the awaited loop).
|
|
96
153
|
const t = e.type;
|
|
97
154
|
if (t === "task_progress") {
|
|
98
155
|
void append("task_progress", taskProgressEventData(e)).catch(() => undefined);
|
|
@@ -104,7 +161,9 @@ export function createLedgerSink(opts) {
|
|
|
104
161
|
void append("tool_end", toolEndEventData(e)).catch(() => undefined);
|
|
105
162
|
}
|
|
106
163
|
};
|
|
107
|
-
const appendParked = (kind, result) =>
|
|
164
|
+
const appendParked = (kind, result) =>
|
|
165
|
+
// Never the capability checkpointToken — only the non-secret gate (search [18] Q1b).
|
|
166
|
+
append(kind, { gate: result?.checkpointGate ?? null });
|
|
108
167
|
const appendDone = (result) => append("done", { result });
|
|
109
168
|
const onDone = async (result) => {
|
|
110
169
|
await flush();
|
package/dist/trace/project.d.ts
CHANGED
|
@@ -1,19 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Task Trace projection (S1): the durable run event log → sema-registry's `TraceTurn[]` contract.
|
|
3
|
+
*
|
|
4
|
+
* The event log (src/runs.ts) is a flat per-task seq stream: reasoning / text / tool_start / tool_end /
|
|
5
|
+
* turn_end / compacted / done / suspended / failed. sema-registry renders an ORDERED `blocks[]` transcript
|
|
6
|
+
* (CC-style thinking↔tool interleave), grouped into turns. This is pure presentation/projection = the
|
|
7
|
+
* SERVICE layer (core [R57] adversarial: do NOT push this shape into core — different consumer, different shape).
|
|
8
|
+
*
|
|
9
|
+
* Per core [R57] corrections: there is no `suspended` event (suspend = the run row's status); per-turn tokens ride
|
|
10
|
+
* on `turn_end.usage` (core additive). As of core 1.121.0 (design/99 §E1) `tool_end` ALSO carries the model-facing
|
|
11
|
+
* `output` (+ `truncated`) — redacted + size-bounded at append (runs.ts) and read straight off the event here (the
|
|
12
|
+
* old session-join `toolOutput` hook is gone, there's a real source now); `eventId`/`parentToolCallId` (§E2) ride
|
|
13
|
+
* each content event, additive / tolerate-absent.
|
|
14
|
+
*/
|
|
1
15
|
import type { TaskResult } from "@sema-agent/core";
|
|
2
16
|
import type { RunEvent, RunRecord } from "../plugins/store-contracts.js";
|
|
3
17
|
import type { ModelUsageDelta, ModelUsageTracker, PromptManifestRecord } from "../budget.js";
|
|
4
18
|
type AppendFn = (type: string, data: unknown) => Promise<void>;
|
|
5
19
|
type GetEventsFn = (taskId: string, afterSeq: number) => Promise<RunEvent[]>;
|
|
20
|
+
/** E8 (shell-host): drain the per-task model-usage accumulator into an append-only `model_usage` DELTA event.
|
|
21
|
+
* Shared by BOTH durable-write legs (runInBackground + the resume leg) so the persisted shape never drifts; the
|
|
22
|
+
* append-only deltas make a suspended/resumed run's total resume-safe (each leg appends its own, the echo sums). */
|
|
6
23
|
export declare function appendModelUsageDelta(append: AppendFn, modelUsage: ModelUsageTracker | undefined, taskId: string): Promise<void>;
|
|
24
|
+
/** [998]② drain the pending prompt-manifest records (whitelisted at RECORD time, budget.ts — ids/digests/
|
|
25
|
+
* counts only, no prompt bodies by core's manifest contract) into durable `prompt_assembled` events, one per
|
|
26
|
+
* prepare IN EMISSION ORDER (a cascade/verify leg re-prepares under one taskId — every rung's manifest
|
|
27
|
+
* persists; release-review finding). Shared by both durable-write legs; a no-op when nothing is pending
|
|
28
|
+
* (one Map.get), so callers fire it liberally. */
|
|
7
29
|
export declare function appendPromptManifest(append: AppendFn, tracker: {
|
|
8
30
|
drain(taskId: string): PromptManifestRecord[] | undefined;
|
|
9
31
|
drainConfig?(taskId: string): Array<Record<string, unknown>> | undefined;
|
|
10
32
|
} | undefined, taskId: string): Promise<void>;
|
|
33
|
+
/** E8: at a TERMINAL done — flush the final delta, then SUM all `model_usage` events (every process leg) into the
|
|
34
|
+
* result's `stats.modelUsage` echo. Returns the result unchanged when no usage was tracked (shell soft-degrades). */
|
|
11
35
|
export declare function attachModelUsage<T extends TaskResult>(result: T, ctx: {
|
|
12
36
|
append: AppendFn;
|
|
13
37
|
getEvents: GetEventsFn;
|
|
14
38
|
modelUsage: ModelUsageTracker | undefined;
|
|
15
39
|
taskId: string;
|
|
16
40
|
}): Promise<T>;
|
|
41
|
+
/** E8 (shell-host contract): SUM the per-turn `model_usage` delta events in a run's durable event log into the
|
|
42
|
+
* cumulative per-model total for `TaskStats.modelUsage`. The tracer drains deltas at each turn boundary
|
|
43
|
+
* (append-only) → this is resume-safe: it sums across ALL process legs of a suspended/resumed run. Returns
|
|
44
|
+
* undefined when the run logged no model usage (→ the shell soft-degrades to aggregate cost only). */
|
|
17
45
|
export declare function aggregateModelUsage(events: RunEvent[]): Record<string, ModelUsageDelta> | undefined;
|
|
18
46
|
export type TraceBlock = {
|
|
19
47
|
type: "thinking";
|
|
@@ -48,6 +76,10 @@ export type TraceBlock = {
|
|
|
48
76
|
sections?: unknown;
|
|
49
77
|
tools?: unknown;
|
|
50
78
|
};
|
|
79
|
+
/** The durable `tool_start` event payload, shared by BOTH append sites (runInBackground + the resume leg) so the
|
|
80
|
+
* persisted shape never drifts: redacted args (UNTRUSTED) + E2 identity. `label`([1543]§三族B:durable 腿
|
|
81
|
+
* 此前剥掉——同一 run live 观看有展示名、replay/resume 退化成 wire 名):core 展示名 verbatim(tail 面
|
|
82
|
+
* 1.251 复审同裁,两腿同处理)。 */
|
|
51
83
|
export declare function toolStartEventData(ev: {
|
|
52
84
|
toolCallId: string;
|
|
53
85
|
toolName: string;
|
|
@@ -56,6 +88,15 @@ export declare function toolStartEventData(ev: {
|
|
|
56
88
|
eventId?: string;
|
|
57
89
|
parentToolCallId?: string;
|
|
58
90
|
}): Record<string, unknown>;
|
|
91
|
+
/** The durable `tool_end` payload (shared by both append sites). E1: the model-facing `output` is UNTRUSTED RAW
|
|
92
|
+
* from core (file/shell/API bodies) — core only SIZE-bounds it (`truncated`), REDACTION is ours (same contract as
|
|
93
|
+
* `tool_start.args`); never re-fed to a model. E2: identity. Absent `output` ⇒ the tool produced no content body.
|
|
94
|
+
* core 1.203: `structured` = the tool's CC-shaped `details` card (edit/create/bash/… — core
|
|
95
|
+
* allowlists the card `type` and size-caps the whole card, omit-whole on overflow, so a subagent's child-TaskResult
|
|
96
|
+
* can never appear here) — SAME UNTRUSTED RAW contract as `output` (a card carries `originalFile`/stdout bodies),
|
|
97
|
+
* so it gets the same deep redaction before it is persisted or echoed. `label`(core 展示名,同 tool_start 的
|
|
98
|
+
* label 待遇 verbatim)白名单排查(2026-07-24)补齐进函数本体——此前外包给调用点各自手动拼接,7 处只有
|
|
99
|
+
* 3 处记得拼,resume leg + ledger-sink 落盘两处漏了,持久化记录本身缺 label 一写盘就永久追不回来。 */
|
|
59
100
|
export declare function toolEndEventData(ev: {
|
|
60
101
|
toolCallId: string;
|
|
61
102
|
toolName: string;
|
|
@@ -68,6 +109,12 @@ export declare function toolEndEventData(ev: {
|
|
|
68
109
|
eventId?: string;
|
|
69
110
|
parentToolCallId?: string;
|
|
70
111
|
}): Record<string, unknown>;
|
|
112
|
+
/** The `task_progress` payload (a subagent's live progress tick) — EXPLICIT WHITELIST shared by all
|
|
113
|
+
* three legs (bg runs.ts + resume append + the sync live SSE frame): taskId/parent linkage/token rollup verbatim,
|
|
114
|
+
* `name` UNTRUSTED (core sanitizes for rendering, does NOT secret-redact — a taskName can be secret-shaped) →
|
|
115
|
+
* `redactSecrets`. Never the delegated objective/args. E2 identity rides (eventId/
|
|
116
|
+
* parentToolCallId are core-mint uuidv7 identifiers, not content — consumers bind concurrent subagent ticks
|
|
117
|
+
* exactly by them; the 1.72 whitelist dropped them, leaving a FIFO heuristic). */
|
|
71
118
|
export declare function taskProgressEventData(ev: {
|
|
72
119
|
taskId: string;
|
|
73
120
|
parentTaskId?: string;
|
|
@@ -80,6 +127,18 @@ export declare function taskProgressEventData(ev: {
|
|
|
80
127
|
workflowRunId?: string;
|
|
81
128
|
workflowAgentLabel?: string;
|
|
82
129
|
}): Record<string, unknown>;
|
|
130
|
+
/** The `task_notification` payload (core 1.202 design/115 P2: a background task finished — this event is the
|
|
131
|
+
* LEDGER/display projection of the OBSERVED terminal state, emitted the moment core observes it. It does NOT
|
|
132
|
+
* attest that the `<task-notification>` XML has entered the model context: core's steer targets the NEXT TURN
|
|
133
|
+
* BOUNDARY (design/116 §7 — turn 在飞时不注入), so the frame can precede actual injection by minutes ([1818]
|
|
134
|
+
* clay live: 3m54s; the previous wording here — "core already injected in-process" — was the same wrong
|
|
135
|
+
* assumption that broke the shell's dedup). `injected: false` says exactly that on the wire: a consumer must
|
|
136
|
+
* NOT treat this frame as an echo of model-context injection. EXPLICIT WHITELIST (never `{...ev}` — the 1.72 task_progress lesson: a
|
|
137
|
+
* future core field must not ride raw): ids/status/usage verbatim; `summary`/`result`/`output_file` are UNTRUSTED
|
|
138
|
+
* free text (core bounds+sanitizes for XML, does NOT secret-redact) → `redactSecrets` at OUR wire boundary. Shared
|
|
139
|
+
* by all three legs (bg runs.ts + resume append + the sync live SSE frame) so the shape never drifts. Takes the
|
|
140
|
+
* EVENT (not just the payload) so the E2 identity fields core stamps on it (eventId/parentToolCallId) ride the
|
|
141
|
+
* frame like every other content event (review round 2: the payload-only version silently dropped them). */
|
|
83
142
|
export declare function taskNotificationEventData(ev: {
|
|
84
143
|
notification: {
|
|
85
144
|
task_id: string;
|
|
@@ -113,6 +172,18 @@ export declare function taskNotificationEventData(ev: {
|
|
|
113
172
|
eventId?: string;
|
|
114
173
|
parentToolCallId?: string;
|
|
115
174
|
}): Record<string, unknown>;
|
|
175
|
+
/** The `compacted` payload — EXPLICIT WHITELIST shared by all three legs (bg runs.ts + resume append + the sync
|
|
176
|
+
* live SSE frame; the 1.72 task_progress lesson: never `{...ev}`). trigger/tokensBefore (MF-18) verbatim;
|
|
177
|
+
* `preserved_segment.firstKeptEntryId` verbatim (a core-mint entryId, the shell's compaction-divider anchor);
|
|
178
|
+
* core 1.219 `attachedFiles` (attachWorkingFiles default-ON — the shell renders CC's post-compact `Read {path}`
|
|
179
|
+
* cards from it): `path` is the engine's own working-file path (env-derived, not free text) but still crosses our
|
|
180
|
+
* wire → `redactSecrets` (a project path can embed a secret-shaped dir name); chars/truncated are numeric/bool
|
|
181
|
+
* verbatim. Absent fields stay absent (feature off / nothing attached / no kept-tail floor). */
|
|
182
|
+
/** The `diagnostics` payload (core 1.220 design/121 — NEW LSP diagnostics drained at a turn boundary; the model
|
|
183
|
+
* already got the `<new-diagnostics>` context message in-process, this frame is the shell's render source).
|
|
184
|
+
* EXPLICIT WHITELIST shared by all three legs. UNTRUSTED RAW (§E1: language-server output over workspace files —
|
|
185
|
+
* a diagnostic message can quote file content, a secret-shaped uri/source is possible) → `redactSecrets` on the
|
|
186
|
+
* string fields; severity/range/code numbers verbatim. E2 identity rides. */
|
|
116
187
|
export declare function diagnosticsEventData(ev: {
|
|
117
188
|
files: Array<{
|
|
118
189
|
uri: string;
|
|
@@ -128,17 +199,32 @@ export declare function diagnosticsEventData(ev: {
|
|
|
128
199
|
eventId?: string;
|
|
129
200
|
parentToolCallId?: string;
|
|
130
201
|
}): Record<string, unknown>;
|
|
202
|
+
/** The `steering_injected` payload([1550]/[1552] 裁定透传;core `TaskEvent` 联合臂 `type: "steering_injected"`,
|
|
203
|
+
* shell 渲染源 = CC 的系统提醒条:core 在 turn 之间给模型注入一条系统提示[todo 提醒/文件变化/日期跨天/
|
|
204
|
+
* 技能列表变化…]时随手抛的展示投影,一附件一帧)。EXPLICIT WHITELIST(source=封闭枚举 verbatim;
|
|
205
|
+
* preview=注入文本的展示摘录,UNTRUSTED[core 未做秘密脱敏]→ `redactSecrets`)。共享三腿(sync 实时 SSE +
|
|
206
|
+
* bg/resume 落账,ledger-sink 同门)。 */
|
|
131
207
|
export declare function steeringInjectedEventData(ev: {
|
|
132
208
|
source: string;
|
|
133
209
|
preview: string;
|
|
134
210
|
eventId?: string;
|
|
135
211
|
parentToolCallId?: string;
|
|
136
212
|
}): Record<string, unknown>;
|
|
213
|
+
/** The `workspace_changed` payload([1559]二 core 裁定:design/99 §E13 旧臂,L1 门本车首次撞见——非新增,
|
|
214
|
+
* 是本门扩 TaskEvent 臂集时第一次显式处置。语义 = bash `cd`/EnterWorktree 移动任务逻辑 cwd 后,在移动
|
|
215
|
+
* 它的工具结算后发一帧,给 shell/宿主 UI 一个路径提示行。cwd 与已展示的工具 args 同信任级[UNTRUSTED,
|
|
216
|
+
* RAW 逻辑路径,symlink 不解析]→ `redactSecrets` + 长度 bound[300,与 brainStatusEventData.detail 同
|
|
217
|
+
* 惯例]。core 只在真变化时才发(不播初始 cwd);渲染面(cli)不得当持久态——跨 suspend/resume 重置为
|
|
218
|
+
* 根,这是消费端纪律,服务端只如实转发单帧不做状态缓存。 */
|
|
137
219
|
export declare function workspaceChangedEventData(ev: {
|
|
138
220
|
cwd: string;
|
|
139
221
|
eventId?: string;
|
|
140
222
|
parentToolCallId?: string;
|
|
141
223
|
}): Record<string, unknown>;
|
|
224
|
+
/** S4 (SILENT-FALLBACK P0-a): the durable `brain_status` observation row, shared by the bg + resume append
|
|
225
|
+
* sites. core marks the live `status` frame EPHEMERAL (never replayed by core on resume) — this row is the
|
|
226
|
+
* SERVICE's own observation record (why a turn stalled: rate_limited/retrying/reconnecting/circuit_open),
|
|
227
|
+
* not a core event replay. Whitelist: the closed phase union + neutral bounded detail (redacted) + retryInSec. */
|
|
142
228
|
export declare function brainStatusEventData(ev: {
|
|
143
229
|
phase: string;
|
|
144
230
|
detail?: string;
|
|
@@ -172,6 +258,7 @@ export declare function compactedEventData(ev: {
|
|
|
172
258
|
};
|
|
173
259
|
}): Record<string, unknown>;
|
|
174
260
|
export interface TraceTurn {
|
|
261
|
+
/** per-task seq = the turn's terminating event seq (so history-up-to-H splices with stream seq>H). */
|
|
175
262
|
seq: number;
|
|
176
263
|
ts: string;
|
|
177
264
|
role: "system" | "user" | "assistant" | "tool";
|
|
@@ -183,21 +270,47 @@ export interface TraceTurn {
|
|
|
183
270
|
cacheWrite?: number;
|
|
184
271
|
};
|
|
185
272
|
}
|
|
273
|
+
/**
|
|
274
|
+
* `context_usage` 的白名单投影(core 1.414 新增一等 `TaskEvent` 分支;server [1669]⑥ 点名要的上下文用量面)。
|
|
275
|
+
*
|
|
276
|
+
* 🔴 两条 core 明确交代的口径,必须原样传下去、不要在服务端"聪明地"重算:
|
|
277
|
+
* · `usedTokens > compactAtTokens` **就是引擎自己喂 `shouldCompact` 的谓词** —— 消费方直接用,别重新推导阈值。
|
|
278
|
+
* · `windowTokens` 是 **autocompact 窗**,**不是**「模型上下文大小」(模型声明 `autoCompactTokens` 时物理请求
|
|
279
|
+
* 窗更大)。渲染成"模型上下文"会给用户一个错的分母。
|
|
280
|
+
* ⚠️ 它在**每个压缩边界**上报(不只压缩真发生时),所以一次任务里会有多条 —— 消费方按最后一条取当前值。
|
|
281
|
+
* ⚠️ 它**没有**挂在 `turn_end.usage` 上(core 解释:边界检查跑在 turn_end 之后、对 flush 后的消息集,
|
|
282
|
+
* 挂那儿会是"另一次更早的测量顶着同一个名字")。去 turn_end 找是找不到的。
|
|
283
|
+
* 三个字段都是引擎派生的有限数标量 ⇒ 走 finite 门(与 compacted 的 1.289 标量同姿势),非有限即缺席。
|
|
284
|
+
*/
|
|
186
285
|
export declare function contextUsageEventData(ev: {
|
|
187
286
|
usedTokens?: unknown;
|
|
188
287
|
windowTokens?: unknown;
|
|
189
288
|
compactAtTokens?: unknown;
|
|
190
289
|
}): Record<string, unknown>;
|
|
290
|
+
/**
|
|
291
|
+
* `turn_end` 的白名单投影 —— 🔴 2026-07-25 补:`turn_end` 此前是**唯一没有 builder 的内容臂**,两条持久化点
|
|
292
|
+
* (ledger-sink 与 resume 腿)各自手写 `{ usage }`,于是 core 的另两个字段被静默剥掉:
|
|
293
|
+
* · `stopReason` —— **这一轮为什么停**(max_tokens / stop_sequence / …);
|
|
294
|
+
* · `usageMissing: true` —— **用量不可信**的诚实标记。缺了它,"没有 usage"会被读成"用量是 0",
|
|
295
|
+
* 而不是"未知";这正是那种"回放后看起来一切正常"的丢失。
|
|
296
|
+
* 两者**在 live 腿看得见、durable 腿回放后永久消失** —— 与 [1622] 的 `label`、[1611] 的 workflowRunId 同一族
|
|
297
|
+
* (白名单没跟上 core 新增字段)。补 builder 的同时也就把它纳入了 `wire-whitelist-exhaustiveness` 的编译期差集门。
|
|
298
|
+
*/
|
|
191
299
|
export declare function turnEndEventData(ev: {
|
|
192
300
|
usage?: unknown;
|
|
193
301
|
usageMissing?: true;
|
|
194
302
|
stopReason?: string;
|
|
195
303
|
}): Record<string, unknown>;
|
|
304
|
+
/** Map core's `turn_end.usage` (1.76 / core [R59]: inputTokens/outputTokens/cacheReadTokens/cacheWriteTokens/
|
|
305
|
+
* costMicroUsd) → the contract's `TraceTurn.tokens {in,out,cacheRead?,cacheWrite?}`. Absent/empty → undefined. */
|
|
196
306
|
export declare function toContractTokens(usage: unknown): TraceTurn["tokens"] | undefined;
|
|
197
307
|
export interface ProjectOpts {
|
|
308
|
+
/** Prepend the user turn (the objective is not in the event log; the endpoint supplies it). */
|
|
198
309
|
objective?: string;
|
|
199
310
|
}
|
|
311
|
+
/** Project a per-task event slice (seq-ascending) into ordered `TraceTurn[]`. Pure + total (never throws). */
|
|
200
312
|
export declare function projectEvents(events: RunEvent[], opts?: ProjectOpts): TraceTurn[];
|
|
313
|
+
/** Structured `lastStep` (contract 2.1) from the latest event — UI maps an icon, never free text. */
|
|
201
314
|
export declare function lastStep(latestEventType: string | undefined, status: string): {
|
|
202
315
|
type: "thinking" | "tool-call" | "responding" | "idle";
|
|
203
316
|
label?: string;
|
|
@@ -206,9 +319,13 @@ export interface TaskSummary {
|
|
|
206
319
|
id: string;
|
|
207
320
|
status: string;
|
|
208
321
|
scenario?: string;
|
|
322
|
+
/** Work-view correlation id (optional) — lets the client group a list into logical tasks. */
|
|
209
323
|
jobId?: string;
|
|
324
|
+
/** Credential-derived submitting system (oa/cc-mcp/portal…) — per-door attribution. */
|
|
210
325
|
source?: string;
|
|
326
|
+
/** Redacted first ~120 chars of the objective — the "what is this task" glance. */
|
|
211
327
|
objectivePreview?: string;
|
|
328
|
+
/** The run's owner principal — the operator/boss view needs "whose task". */
|
|
212
329
|
owner?: string;
|
|
213
330
|
startedAt: string;
|
|
214
331
|
endedAt?: string;
|
|
@@ -220,8 +337,24 @@ export interface TaskSummary {
|
|
|
220
337
|
label?: string;
|
|
221
338
|
};
|
|
222
339
|
}
|
|
340
|
+
/** A run record → the cheap list summary (contract 2.1). Token/cost/turns come from the terminal result.stats;
|
|
341
|
+
* scenario isn't denormalized on the run row (omitted — a later push-index/column refinement). */
|
|
223
342
|
export declare function taskSummary(run: RunRecord, latestEventType?: string): TaskSummary;
|
|
343
|
+
/** design/158 B2(lens4 N8)—— 重放边界的**读旧**归一:把历史账本里的 `brain_status` 行改叫 `status`。
|
|
344
|
+
*
|
|
345
|
+
* 同一条「大脑存活性」观测曾在两条腿上叫两个名字:live 腿(`POST /v1/tasks/stream`)发 `type:"status"`,
|
|
346
|
+
* durable 腿的账本行落 `brain_status`,而 SDK 的公开 `AgentEvent` 联合**只有** `status` —— 于是走
|
|
347
|
+
* `GET /v1/runs/:id/events` 的消费端会收到一个公开联合之外的帧(穷举式 closed-oneOf 消费者当场抛)。
|
|
348
|
+
*
|
|
349
|
+
* 写入侧已经改叫 `status`(ledger-sink.ts 与 resume 腿的 append 两处),但**存量行救不了**:任何
|
|
350
|
+
* <1.317 的部署账本里都躺着 `brain_status` 行,重放它们仍会漏出旧名。所以「写新」必须配一个「读旧」——
|
|
351
|
+
* 这个函数就是那个读边界,唯一调用点是 task_run SSE 的 `formatEvent`(routes/runs.ts)。
|
|
352
|
+
*
|
|
353
|
+
* 🔴 刻意**只**认这一个键,不做成映射表:帧名归一是历史包袱的一次性偿还,不是一条可以长胖的兼容层。
|
|
354
|
+
* 再有第二个名字对不齐,应当在源头修,而不是往这里加一行。 */
|
|
224
355
|
export declare function normalizeRunEventType(type: string): string;
|
|
356
|
+
/** Map one durable event → a sema-registry SSE trace event (contract 2.3). null = not a client event. The
|
|
357
|
+
* durable log is block-grained, so each block ships as one "delta" the client appends (stream mode = "delta"). */
|
|
225
358
|
export declare function mapTraceEvent(type: string, seq: number, data: Record<string, unknown>): {
|
|
226
359
|
event: string;
|
|
227
360
|
data: Record<string, unknown>;
|