@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
package/dist/task-settings.js
CHANGED
|
@@ -1,12 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TaskRequest.settings wire — project a client's per-request `SemaSettings` stamp onto the per-task `TaskSpec`,
|
|
3
|
+
* TIGHTEN-ONLY (deny-wins), at the SAME seam as runtime-governance (after the approval baseline + operator
|
|
4
|
+
* governance). Backs the remote-mode settings path: sema runs over HTTP→engine with no local Runner, so the
|
|
5
|
+
* resolved settings can't be applied by a local `tightenTaskSpec` — they ride on `TaskRequest.settings` and the
|
|
6
|
+
* SERVICE projects them into the engine here.
|
|
7
|
+
*
|
|
8
|
+
* Design: `TaskRequest.settings` is a
|
|
9
|
+
* PER-REQUEST ephemeral stamp = the v2-design TASK layer (a single-run override, NOT durable). It folds into THIS
|
|
10
|
+
* spec via {@link tightenTaskSpec} and that is all — it is NEVER written to the durable `SessionPolicyStore` (the
|
|
11
|
+
* operator/principal axis, design/99 §E6, a different trust axis + lifecycle). Re-applying on a resume leg is
|
|
12
|
+
* idempotent (the same tighten), so no special resume handling is needed (mirrors runtime-governance).
|
|
13
|
+
*
|
|
14
|
+
* 🔒 SECURITY INVARIANTS (SDK settings.ts §3.3):
|
|
15
|
+
* - permissions are TIGHTEN-ONLY — folded via `tightenTaskSpec` (deny-wins `combinePolicies`); it THROWS on any
|
|
16
|
+
* override that would LOOSEN a stricter base safety field. The client can only ADD denies/asks/handsReadOnly on
|
|
17
|
+
* top of the deployment + operator baseline, never widen it.
|
|
18
|
+
* - permissionMode(轴B #2 注释保鲜,1.254——[816]/[820] 后的真实现):`defaultMode` 收**五**模式
|
|
19
|
+
* (default | acceptEdits | plan | bypassPermissions | auto),bypass/auto 被 HONOR 为 gate-shape 选择
|
|
20
|
+
* ——但深层不变量未变:bypass=「不加 ask 门」,恒不越部署基线(tightenTaskSpec deny-wins,基线 deny/
|
|
21
|
+
* ask 照压);精化语义见 :2xx 行内注释。旧头注的「NEVER honored/三模式白名单」是 pre-[816] 拍照。
|
|
22
|
+
*
|
|
23
|
+
* 🔴 SYNC WITH shell `src/sema/settings/seam.ts`: the permissions→toolPolicy + §6.4 permissionMode derive MIRRORS
|
|
24
|
+
* the shell's LOCAL-Runner resolver — both compose the SAME core primitives (`createAllowDenyPolicy` /
|
|
25
|
+
* `combinePolicies` / `tightenTaskSpec`), so the deny-wins ENFORCEMENT is core-single-source. Only the COMPOSITION
|
|
26
|
+
* is duplicated for the remote path; a proposed follow-up extracts it to `@sema-agent/sdk` for true
|
|
27
|
+
* single-source. Because the core backstops (deny-wins + tighten-throws-on-loosen + this bypass-reject) hold either
|
|
28
|
+
* way, a composition drift would be a local/remote CONSISTENCY gap, never a privilege escalation.
|
|
29
|
+
*
|
|
30
|
+
* v1 scope: `permissions` + `permissions.defaultMode` + `model` + `outputStyle` + `env` (shipped 1.26.0). DEFERRED
|
|
31
|
+
* (need a seam, flagged to the team + advertised in capabilities so a caller never silently loses a setting):
|
|
32
|
+
* - (`env` is NO LONGER deferred — systematic-audit doc fix: core kept no untrusted `TaskSpec.env` seam (types §7
|
|
33
|
+
* Q4), so the SERVICE applies it on the TRUSTED host lane: `settings.env` → `cleanEnvMap` → `shellEnv` on the
|
|
34
|
+
* executionEnvFactory, single-user-gated. See `deriveSettings` below + main.ts.)
|
|
35
|
+
* - (`hooks` NO LONGER deferred either — 轴B #2 注释保鲜:applied 形已接线(本文件 hooks 分片 +
|
|
36
|
+
* main.ts 单用户闸),仅 malformed 才报 deferred;旧「需要 remote hook-runner」是接线前拍照。)
|
|
37
|
+
*/
|
|
1
38
|
import { combinePolicies, createAllowDenyPolicy, createFsWriteGatePolicy, createSensitivePathPolicy, canonicalToolName, tightenTaskSpec, resolveReasoningProfile, rankOf, isThinkingLevel, CYBER_RISK, URL_SAFETY, HARNESS_SECTION_ANCHOR, } from "@sema-agent/core";
|
|
2
39
|
import { parseHooksConfig } from "./hooks/hook-runner.js";
|
|
40
|
+
/**
|
|
41
|
+
* R4: coerce a raw top-level `body.permissionMode` (the LIGHT per-turn wire — the shell sends the
|
|
42
|
+
* CC permission mode RAW, axis-agnostic; the service interprets) to a service-honored mode, or undefined.
|
|
43
|
+
* 🔴 TIGHTEN-ONLY vs the DEPLOYMENT baseline still holds for every value: the mode only selects the CLIENT-derived
|
|
44
|
+
* gate ({@link deriveSettingsPolicy}); it can never subtract from the deployment/operator policy (applyTaskSettings
|
|
45
|
+
* folds via tightenTaskSpec, deny-wins). Post-[816] the value set is CC's five modes verbatim — `acceptEdits`,
|
|
46
|
+
* `bypassPermissions` and `auto` are now HONORED as gate-shape choices (they no longer coerce to `default`, which
|
|
47
|
+
* would FORCE the manual ask gate onto a caller that explicitly asked for less asking — with the gate live, the old
|
|
48
|
+
* coercion would have been a behavior change for them, incl. a headless-deny regression for bypass callers). An
|
|
49
|
+
* UNKNOWN string still coerces to `default` (fail-safe: the most-asking mode).
|
|
50
|
+
*/
|
|
3
51
|
export function coercePermissionMode(raw) {
|
|
4
52
|
if (raw === "plan" || raw === "acceptEdits" || raw === "default" || raw === "bypassPermissions" || raw === "auto")
|
|
5
53
|
return raw;
|
|
6
54
|
if (typeof raw === "string" && raw.length > 0)
|
|
7
|
-
return "default";
|
|
8
|
-
return undefined;
|
|
55
|
+
return "default"; // unknown → default (the most-asking mode, never a widening)
|
|
56
|
+
return undefined; // absent → no opinion (don't touch the spec)
|
|
9
57
|
}
|
|
58
|
+
/** L2 ultracode (design/111): the effective `thinking` level given the explicit `reasoningEffort` and the ultracode
|
|
59
|
+
* preset. ultracode FLOORS at the "ultra" tier — core's single source `resolveReasoningProfile("ultra").thinking`
|
|
60
|
+
* (= "max"), never a hardcoded literal — so an explicit higher tier still wins (none exists above max today;
|
|
61
|
+
* future-proof). Awareness rides for free: core composes ORCHESTRATION_AWARENESS from thinking∈{xhigh,max}, no field. */
|
|
10
62
|
export function effectiveThinking(reasoningEffort, ultracode) {
|
|
11
63
|
const explicit = isThinkingLevel(reasoningEffort) ? reasoningEffort : undefined;
|
|
12
64
|
if (!ultracode)
|
|
@@ -14,15 +66,25 @@ export function effectiveThinking(reasoningEffort, ultracode) {
|
|
|
14
66
|
const ultra = resolveReasoningProfile("ultra").thinking;
|
|
15
67
|
return explicit && rankOf(explicit) > rankOf(ultra) ? explicit : ultra;
|
|
16
68
|
}
|
|
69
|
+
/** R4: fold a top-level `body.permissionMode` onto the parsed settings as `permissions.defaultMode` (the top-level
|
|
70
|
+
* field is the explicit per-turn intent → it WINS over a bundle defaultMode). Creates a minimal settings object when
|
|
71
|
+
* no `body.settings` bundle was sent. The result flows through {@link applyTaskSettings} (tighten-only). */
|
|
17
72
|
export function withPermissionMode(settings, mode) {
|
|
18
73
|
const base = settings ?? {};
|
|
19
74
|
return { ...base, permissions: { ...base.permissions, defaultMode: mode } };
|
|
20
75
|
}
|
|
76
|
+
/** Cap on `outputStyle` length — it lands in the system prompt, so it shares the `MAX_SYSTEM_PROMPT_CHARS` (16384)
|
|
77
|
+
* posture (an uncapped prompt body is a per-turn token-cost hole; adversarial review). Exported so the HTTP layer
|
|
78
|
+
* (prepareSpec) can 400 fail-loud on submit with the SAME bound this defensive parse enforces on every path. */
|
|
21
79
|
export const MAX_SETTINGS_OUTPUT_STYLE_CHARS = 16_384;
|
|
80
|
+
/** Cap on the element count of each permission list (allow/deny/ask) — bounds a pathological rule blast. */
|
|
22
81
|
export const MAX_SETTINGS_PERMISSION_RULES = 1_000;
|
|
82
|
+
/** Caps on `settings.env` — bound a pathological env blast (count + per-value length; values land in the shell env). */
|
|
23
83
|
export const MAX_SETTINGS_ENV_VARS = 256;
|
|
24
84
|
export const MAX_SETTINGS_ENV_VALUE_CHARS = 32_768;
|
|
25
85
|
export const MAX_SETTINGS_ENV_KEY_CHARS = 256;
|
|
86
|
+
/** A `Record<string,string>` of non-empty string keys → string values (capped), or undefined. Untrusted input →
|
|
87
|
+
* defensive (drop non-string entries, over-long values, and bound the count). */
|
|
26
88
|
function cleanEnvMap(v) {
|
|
27
89
|
if (v === null || typeof v !== "object" || Array.isArray(v))
|
|
28
90
|
return undefined;
|
|
@@ -31,7 +93,7 @@ function cleanEnvMap(v) {
|
|
|
31
93
|
let seen = 0;
|
|
32
94
|
for (const [k, val] of Object.entries(v)) {
|
|
33
95
|
if (n >= MAX_SETTINGS_ENV_VARS || seen >= MAX_SETTINGS_ENV_VARS * 8)
|
|
34
|
-
break;
|
|
96
|
+
break; // bound BOTH accepted + total iterated (adversarial-review LOW)
|
|
35
97
|
seen++;
|
|
36
98
|
if (typeof k === "string" && k.length > 0 && k.length <= MAX_SETTINGS_ENV_KEY_CHARS && typeof val === "string" && val.length <= MAX_SETTINGS_ENV_VALUE_CHARS) {
|
|
37
99
|
out[k] = val;
|
|
@@ -40,17 +102,29 @@ function cleanEnvMap(v) {
|
|
|
40
102
|
}
|
|
41
103
|
return n > 0 ? out : undefined;
|
|
42
104
|
}
|
|
105
|
+
/** A string[] of non-empty strings (capped at {@link MAX_SETTINGS_PERMISSION_RULES}), or undefined. Untrusted input
|
|
106
|
+
* → defensive (drop non-strings/empties; cap the count). */
|
|
43
107
|
function cleanStringArray(v) {
|
|
44
108
|
if (!Array.isArray(v))
|
|
45
109
|
return undefined;
|
|
46
110
|
const out = v.filter((x) => typeof x === "string" && x.length > 0).slice(0, MAX_SETTINGS_PERMISSION_RULES);
|
|
47
111
|
return out.length > 0 ? out : undefined;
|
|
48
112
|
}
|
|
113
|
+
/**
|
|
114
|
+
* Validate an untrusted `body.settings` (raw `unknown` off the wire) into the service-trusted {@link
|
|
115
|
+
* ParsedTaskSettings}. NEVER trusts the wire type — every field is shape-checked; unknown keys are ignored
|
|
116
|
+
* (forward-compatible, matching the SDK's open `[k: string]: unknown`). `defaultMode` accepts the FIVE modes
|
|
117
|
+
* (post-[816]; unknown values coerce to `default` — see the header note). Returns the
|
|
118
|
+
* present-but-deferred field names so the caller can warn/advertise rather than silently dropping `env`/`hooks`.
|
|
119
|
+
*/
|
|
49
120
|
export function parseTaskSettings(raw) {
|
|
50
121
|
if (raw === null || raw === undefined || typeof raw !== "object")
|
|
51
122
|
return { deferred: [] };
|
|
52
123
|
const s = raw;
|
|
53
124
|
const deferred = [];
|
|
125
|
+
// `hooks` is NO LONGER deferred(hook-runner 阶段一):契约校验(registry-core HooksConfig +
|
|
126
|
+
// 服务侧上限)通过 → 进 applied 形状,由 apply 侧单用户闸决定翻不翻;malformed → 报 deferred(镜像 env 的
|
|
127
|
+
// present-but-malformed 姿势——本函数是 resume 等路径的防御层,submit 路径另有 fail-loud 400)。
|
|
54
128
|
let hooksConfig;
|
|
55
129
|
if (s.hooks !== undefined && s.hooks !== null) {
|
|
56
130
|
const parsedHooks = parseHooksConfig(s.hooks);
|
|
@@ -61,7 +135,7 @@ export function parseTaskSettings(raw) {
|
|
|
61
135
|
}
|
|
62
136
|
const shellEnv = cleanEnvMap(s.env);
|
|
63
137
|
if (s.env !== undefined && s.env !== null && shellEnv === undefined)
|
|
64
|
-
deferred.push("env");
|
|
138
|
+
deferred.push("env"); // present but malformed/empty → report
|
|
65
139
|
const out = {};
|
|
66
140
|
const perms = s.permissions;
|
|
67
141
|
if (perms !== null && typeof perms === "object") {
|
|
@@ -69,6 +143,10 @@ export function parseTaskSettings(raw) {
|
|
|
69
143
|
const allow = cleanStringArray(p.allow);
|
|
70
144
|
const deny = cleanStringArray(p.deny);
|
|
71
145
|
const ask = cleanStringArray(p.ask);
|
|
146
|
+
// 🔒 whitelist the five CC modes; any other value is dropped (absent = no opinion). `bypassPermissions` is
|
|
147
|
+
// accepted post-[816] because it now means "do not ADD the mode-derived fs-write ask gate" — exactly every
|
|
148
|
+
// mode's pre-[816] behavior — and can never subtract from the deployment baseline (tightenTaskSpec deny-wins;
|
|
149
|
+
// the module-header §3.3 invariant is thereby REFINED, not weakened: bypass still cannot LOOSEN anything).
|
|
72
150
|
const mode = p.defaultMode;
|
|
73
151
|
const defaultMode = mode === "default" || mode === "acceptEdits" || mode === "plan" || mode === "bypassPermissions" || mode === "auto" ? mode : undefined;
|
|
74
152
|
if (allow || deny || ask || defaultMode) {
|
|
@@ -77,11 +155,15 @@ export function parseTaskSettings(raw) {
|
|
|
77
155
|
}
|
|
78
156
|
if (typeof s.model === "string" && s.model.length > 0)
|
|
79
157
|
out.model = s.model;
|
|
158
|
+
// outputStyle is appended to the system prompt → cap it (defense in depth; prepareSpec 400s an over-cap value on
|
|
159
|
+
// submit, this drops it on any path the HTTP gate didn't cover, e.g. a resume of a pre-cap stored body).
|
|
80
160
|
if (typeof s.outputStyle === "string" && s.outputStyle.length > 0 && s.outputStyle.length <= MAX_SETTINGS_OUTPUT_STYLE_CHARS) {
|
|
81
161
|
out.outputStyle = s.outputStyle;
|
|
82
162
|
}
|
|
83
163
|
if (shellEnv)
|
|
84
164
|
out.shellEnv = shellEnv;
|
|
165
|
+
// L2 ultracode preset (design/111): a CC-parity boolean. Only `true` opts in; any other value is ignored (a settings
|
|
166
|
+
// bundle that ONLY sets ultracode still returns `settings` via the hasApplied OR below).
|
|
85
167
|
if (s.ultracode === true)
|
|
86
168
|
out.ultracode = true;
|
|
87
169
|
if (hooksConfig)
|
|
@@ -89,12 +171,33 @@ export function parseTaskSettings(raw) {
|
|
|
89
171
|
const hasApplied = out.permissions !== undefined || out.model !== undefined || out.outputStyle !== undefined || out.shellEnv !== undefined || out.ultracode !== undefined || out.hooks !== undefined;
|
|
90
172
|
return { settings: hasApplied ? out : undefined, deferred };
|
|
91
173
|
}
|
|
174
|
+
/** Defensive acceptance of the `appendSystemPrompt` rider ([1478] R2 + codex F2): the HTTP 400 gate (prepareSpec,
|
|
175
|
+
* MAX_SYSTEM_PROMPT_CHARS) only covers FRESH submits — every resume family re-enters resolveSpec on a STORED body,
|
|
176
|
+
* and a pre-1.243 store preserved unknown request keys verbatim (the field was INERT then), so an over-cap legacy
|
|
177
|
+
* value must not become active prompt content after rollout (context exhaustion / spend hole). Over-cap ⇒ dropped +
|
|
178
|
+
* warned — the rider was inert pre-upgrade, so dropping preserves the stored task's prior behavior; a 4xx here would
|
|
179
|
+
* permanently brick that task's resume instead (same defensive posture as parseTaskSettings' outputStyle drop).
|
|
180
|
+
* Cap value = the submit gate's (16384; MAX_SETTINGS_OUTPUT_STYLE_CHARS — both land in the same spec field). */
|
|
181
|
+
/** TRUE when `text` is an ALREADY-ASSEMBLED system prompt — core's migration guard detects the same three
|
|
182
|
+
* constitution anchors and takes the pass-through assembler arm, whose section subset (OPAQUE_KEPT, dist-read)
|
|
183
|
+
* has NO `core/role.append`: any append rider (top-level or settings.outputStyle) would be SILENTLY discarded
|
|
184
|
+
* there. Shared predicate for the submit 400 gate, the resolveSpec resume mirror, and the center-declaration
|
|
185
|
+
* probe — one definition so the three gates can't drift. */
|
|
92
186
|
export function hasConstitutionAnchors(text) {
|
|
93
187
|
return typeof text === "string" && text.includes(CYBER_RISK) && text.includes(URL_SAFETY) && text.includes(HARNESS_SECTION_ANCHOR);
|
|
94
188
|
}
|
|
189
|
+
/** codex R9 (provider-aware append-less detection): mirrors core's ACTUAL pass-through triggers instead of a raw
|
|
190
|
+
* body-text heuristic — the assembler's migration guard probes (a) `stableBlocks` identity declarations and
|
|
191
|
+
* (b) `stableSystem` OUTPUT for the three anchors; a plain `userSystemPrompt` under the DEFAULT provider (no
|
|
192
|
+
* scenario provider) never triggers it and `core/role.append` is retained, so an anchored systemPrompt there
|
|
193
|
+
* must NOT block/strip a rider (R9 false-positive: unbranded default / scan rejected valid combos). Probing
|
|
194
|
+
* calls the provider hooks with a minimal ctx — server providers (and centerPromptProvider) are pure functions
|
|
195
|
+
* of ctx, and the same hooks run again inside core's assembly; a hook throw = conservative false (core will
|
|
196
|
+
* fail the task loudly on its own). `replaceAll` owns the whole prompt(legacy free-form `system()` 腿已随 core 2.0.0 删除)
|
|
197
|
+
* (REPLACE_ALL_EXCLUDED strips role.append) → append-less true. */
|
|
95
198
|
export function providerDropsAppend(provider, userSystemPrompt) {
|
|
96
199
|
if (!provider)
|
|
97
|
-
return false;
|
|
200
|
+
return false; // core defaultPromptProvider — role.append always retained
|
|
98
201
|
if (provider.replaceAll === true)
|
|
99
202
|
return true;
|
|
100
203
|
const ctx = { userSystemPrompt, tools: [], memoryEnabled: false, consolidationEnabled: false };
|
|
@@ -114,11 +217,11 @@ export function providerDropsAppend(provider, userSystemPrompt) {
|
|
|
114
217
|
return false;
|
|
115
218
|
}
|
|
116
219
|
}
|
|
117
|
-
return false;
|
|
220
|
+
return false; // core 2.0.0 删除了 legacy free-form `system()` 腿(不存在的腿不需要探测)——结构化 provider 到此都保 append
|
|
118
221
|
}
|
|
119
222
|
export function acceptAppendSystemPrompt(v, warn, packDropsAppend) {
|
|
120
223
|
if (v === undefined)
|
|
121
|
-
return undefined;
|
|
224
|
+
return undefined; // absent = the only QUIET arm (codex R8: defined-but-malformed must warn)
|
|
122
225
|
if (typeof v !== "string" || v.length === 0) {
|
|
123
226
|
warn?.(`appendSystemPrompt dropped: defined but malformed (${typeof v === "string" ? "empty string" : `non-string: ${typeof v}`}) — fresh submits 400 this shape; a stored resume body carrying it is normalized to absent`);
|
|
124
227
|
return undefined;
|
|
@@ -127,13 +230,26 @@ export function acceptAppendSystemPrompt(v, warn, packDropsAppend) {
|
|
|
127
230
|
warn?.(`appendSystemPrompt dropped: ${v.length} chars exceeds the ${MAX_SETTINGS_OUTPUT_STYLE_CHARS} cap (pre-cap stored body on a resume leg?)`);
|
|
128
231
|
return undefined;
|
|
129
232
|
}
|
|
233
|
+
// codex R2/R3/R9: `packDropsAppend` = the caller's PROVIDER-AWARE append-less verdict ({@link
|
|
234
|
+
// providerDropsAppend} over the effective provider / center snapshot — NOT a raw body-text heuristic, which
|
|
235
|
+
// false-positived on default-provider scenarios where core retains role.append). Fresh submits 400 the combo
|
|
236
|
+
// in resolveSpec; this is the resume-family mirror — the rider was INERT pre-1.243, so dropping WITH a warn
|
|
237
|
+
// preserves the stored task's prior behavior and leaves an audit trail. (core typed error at the assembly
|
|
238
|
+
// boundary = the structural endgame, requested on the board.)
|
|
130
239
|
if (packDropsAppend === true) {
|
|
131
240
|
warn?.("appendSystemPrompt dropped: the effective prompt pack cannot mount the append rider (assembled-identity/stableSystem pass-through, replaceAll, or legacy provider — no core/role.append section)");
|
|
132
241
|
return undefined;
|
|
133
242
|
}
|
|
134
243
|
return v;
|
|
135
244
|
}
|
|
245
|
+
/** A name-keyed ASK-list ToolPolicy: a tool whose NAME is in `askNames` tightens to `ask` (HITL gate); every other
|
|
246
|
+
* tool is out of scope (`allow`). core's `createAllowDenyPolicy` has only allow/deny slots (no `ask`), so the
|
|
247
|
+
* CC-parity `permissions.ask` list — "prompt the human before THIS tool" — needs this thin policy. Composed
|
|
248
|
+
* deny-wins with the allow/deny base, so `ask` only ever tightens (a baseline `deny` still wins; `allow`→`ask`). */
|
|
136
249
|
function createAskListPolicy(askNames) {
|
|
250
|
+
// Canonical-space matching, mirroring core's `createAllowDenyPolicy` (1.202): a rule written against a legacy
|
|
251
|
+
// alias ("MultiEdit"/"Task") keeps asking after a CC-parity rename, and a durable-resume replay carrying a
|
|
252
|
+
// pre-rename `req.toolName` can't slip a rule written in the new names (ask only ever tightens — widening-safe).
|
|
137
253
|
const askSet = new Set(askNames.map(canonicalToolName));
|
|
138
254
|
return {
|
|
139
255
|
check(req) {
|
|
@@ -141,28 +257,53 @@ function createAskListPolicy(askNames) {
|
|
|
141
257
|
? { action: "ask", message: `tool "${req.toolName}" requires approval by your settings`, decisionReason: "rule" }
|
|
142
258
|
: { action: "allow" };
|
|
143
259
|
},
|
|
260
|
+
// [931]③ core 1.300 名单池审计面:自定义 closure 无元数据曾是审计盲区(`ask:["*"]`/typo 名静默
|
|
261
|
+
// no-op)——附 nameSets 后 core prepare 对实挂宇宙交叉核,无匹配名 → onError config.toolpolicy.
|
|
262
|
+
// unmatched_names(enforcement 字节不变,纯观测)。core combinePolicies 全链透传。
|
|
144
263
|
nameSets: [{ ask: askNames }],
|
|
145
264
|
};
|
|
146
265
|
}
|
|
266
|
+
/** [1245]/[1247]③ — the mode-derived dynamic-workflow ask gate (CC "Run a dynamic workflow?" dialog, engine half).
|
|
267
|
+
* core mounts `run_workflow` with effect="write" and NO exemption in the gate stack, but the mode-derived leg here
|
|
268
|
+
* only ever gated fs writes — so manual/default mode ran workflows un-asked ([1245] clay dogfood). This leg keys
|
|
269
|
+
* the canonical name (`Workflow`; run_workflow/RunWorkflow aliases fold in via canonicalToolName on BOTH sides)
|
|
270
|
+
* and attaches on default/auto/acceptEdits, independent of the fs-gate wiring (workflow gating is not
|
|
271
|
+
* fs-dependent — sandbox lanes get it too). acceptEdits asks ON PURPOSE: CC's acceptEdits auto-allows file edits
|
|
272
|
+
* only, a workflow confirmation is not an edit ([1248]② — cli to verify against the 212 live shell; flip there
|
|
273
|
+
* if the real shell differs). bypassPermissions/undefined-mode attach nothing (pre-existing behavior); plan is
|
|
274
|
+
* blocked upstream by handsReadOnly (effect="write"). Deployment disable stays `RuntimeCaps.allowWorkflows` —
|
|
275
|
+
* this leg is the per-request HITL gate, not the capability switch. */
|
|
147
276
|
const WORKFLOW_ASK_NAMES = ["Workflow"];
|
|
148
277
|
function createWorkflowAskPolicy(isExempt) {
|
|
149
278
|
return {
|
|
150
279
|
async check(req) {
|
|
151
280
|
if (canonicalToolName(req.toolName) !== "Workflow")
|
|
152
281
|
return { action: "allow" };
|
|
282
|
+
// codex F2 (durable lane): the "don't ask again this session" grant (decide remember="session" →
|
|
283
|
+
// approvalExemptionStore) is probed at the POLICY layer here — the durable lane parks every policy `ask`
|
|
284
|
+
// and its own exempt probe only covers the deployment policy's asks, so without this probe a remembered
|
|
285
|
+
// Workflow approval would re-park on every later call. Same posture as the fs-write gate's isExempt
|
|
286
|
+
// (canonical toolName key space, one grant serves all layers); a THROWN probe ⇒ not exempt (fail-closed).
|
|
153
287
|
if (isExempt) {
|
|
154
288
|
try {
|
|
155
289
|
if (await isExempt(canonicalToolName(req.toolName)))
|
|
156
290
|
return { action: "allow", decisionReason: "rule" };
|
|
157
291
|
}
|
|
158
292
|
catch {
|
|
293
|
+
/* fail-closed: keep asking */
|
|
159
294
|
}
|
|
160
295
|
}
|
|
161
296
|
return { action: "ask", message: `dynamic workflow "${req.toolName}" requires approval in this permission mode`, decisionReason: "rule" };
|
|
162
297
|
},
|
|
163
|
-
nameSets: [{ ask: WORKFLOW_ASK_NAMES }],
|
|
298
|
+
nameSets: [{ ask: WORKFLOW_ASK_NAMES }], // [931]③ audit face, same as createAskListPolicy
|
|
164
299
|
};
|
|
165
300
|
}
|
|
301
|
+
/** codex F1 (plan-mode escape): `run_workflow` mounts off self-orchestration INDEPENDENT of the hands band
|
|
302
|
+
* (core prepare-task dist 亲读:handsReadOnly only strips/reads the hand tools; the runtime plan blocker
|
|
303
|
+
* `planModeRef` starts INACTIVE and only the model-driven EnterPlanMode tool arms it), so USER-driven plan
|
|
304
|
+
* (permissionMode=plan) would run workflows — whose child agents write by default — during "read-only"
|
|
305
|
+
* research. Plan therefore composes an explicit canonical-space DENY (not ask: plan is research, CC blocks
|
|
306
|
+
* write-effect tools outright), deny-wins under the fold so nothing can un-tighten it. */
|
|
166
307
|
function createWorkflowPlanDenyPolicy() {
|
|
167
308
|
return {
|
|
168
309
|
check(req) {
|
|
@@ -173,16 +314,53 @@ function createWorkflowPlanDenyPolicy() {
|
|
|
173
314
|
nameSets: [{ deny: WORKFLOW_ASK_NAMES }],
|
|
174
315
|
};
|
|
175
316
|
}
|
|
317
|
+
/**
|
|
318
|
+
* Build the per-request permission ToolPolicy from the parsed settings (mirrors shell `seam.ts` — see header).
|
|
319
|
+
* - base = name-keyed allow/deny (`createAllowDenyPolicy`): an `allow` list narrows to those tools; a `deny` list
|
|
320
|
+
* hard-blocks — composed deny-wins with an ASK-list ({@link createAskListPolicy}) so `permissions.ask` actually
|
|
321
|
+
* forces an approval gate (NOT silently dropped — review finding). `deny` > `ask` > `allow` on overlap.
|
|
322
|
+
* - `defaultMode` derive onto that base ([820]/[822] five-mode table; the fs-write gate needs `gate` wiring —
|
|
323
|
+
* without it every mode degrades to the base rules only, the pre-[816] behavior):
|
|
324
|
+
* `default` → base + `createFsWriteGatePolicy({rootPath: cwd, exemptDirs:[scratchpad], ask})` — CC
|
|
325
|
+
* manual: every fs write asks (the [816] P0 fix), scratchpad writes ride free.
|
|
326
|
+
* `acceptEdits` → base + the same factory with `acceptDirs:[cwd]` — writes INSIDE the cwd subtree
|
|
327
|
+
* auto-allow, OUTSIDE still ask (CC 207 dirname-variant card). NOT a loosen vs the
|
|
328
|
+
* deployment: the factory only ever emits allow/ask and is folded deny-wins, so a
|
|
329
|
+
* baseline deny/ask still wins; vs `default` it is simply a narrower CLIENT gate, and
|
|
330
|
+
* both are client-side ADDITIONS the client may size itself.
|
|
331
|
+
* `plan` → handsReadOnly + present_plan (unchanged; the write tools never reach an ask).
|
|
332
|
+
* `bypassPermissions` → base only, NO factory ([820] table: bypass = "不加门" not "开门" — deployment
|
|
333
|
+
* approval/governance baselines still apply; this is exactly every mode's pre-[816]
|
|
334
|
+
* derive, so bypass grants nothing that wasn't already granted).
|
|
335
|
+
* `auto` → base + the `default` factory (ask 兜底) — core's auto-mode classifier (entitlement-
|
|
336
|
+
* gated: RunnerDeps.autoMode ∧ runtimeCaps.autoMode, 1.276/1.277) screens asks UPSTREAM
|
|
337
|
+
* of resolveAsk, allowing safe calls and leaving suspicious ones on the ask path ([822]②).
|
|
338
|
+
* absent (undefined) → base only, NO factory: an expressed-no-mode request keeps its pre-[816] behavior
|
|
339
|
+
* (attaching the ask gate on a mere allow/deny-list stamp would regress headless callers
|
|
340
|
+
* that never asked for a mode; the shell always sends its mode explicitly).
|
|
341
|
+
* Returns the composed ToolPolicy + whether `handsReadOnly` should tighten. Returns `undefined` policy when there
|
|
342
|
+
* is no permission rule and no mode-derived gate (nothing to project).
|
|
343
|
+
*/
|
|
176
344
|
export function deriveSettingsPolicy(settings, gate, workflowGate) {
|
|
177
345
|
const perms = settings.permissions;
|
|
178
346
|
if (!perms)
|
|
179
347
|
return {};
|
|
180
348
|
const { allow, deny, ask, defaultMode } = perms;
|
|
349
|
+
// The base name-keyed gate: allow/deny via core's helper + an ask-list (FINDING-1: `ask` must enforce, not drop).
|
|
350
|
+
// Each is composed deny-wins (`deny` > `ask` > `allow`), so the fold can only ever tighten.
|
|
181
351
|
const policies = [];
|
|
182
352
|
if (allow || deny)
|
|
183
353
|
policies.push(createAllowDenyPolicy({ ...(allow ? { allow } : {}), ...(deny ? { deny } : {}) }));
|
|
184
354
|
if (ask)
|
|
185
355
|
policies.push(createAskListPolicy(ask));
|
|
356
|
+
// The mode-derived fs-write ask gate (core 1.290 factory — real shape read in dist: {env, rootPath?, acceptDirs?,
|
|
357
|
+
// exemptDirs?, defaultWrite}, gates Write/Edit/NotebookEdit, exempt→accept→default layering, canonicalize inside
|
|
358
|
+
// the given env, only ever allow/ask). undefined off the host lane / without wiring (see FsWriteGateWiring).
|
|
359
|
+
// ③ (core 1.295): the sensitive-path DENY policy (patterns from the wiring — config SENSITIVE_WRITE_PATTERNS,
|
|
360
|
+
// default = core's RECOMMENDED set) composes into the SAME fold, deny-wins — core semantics deny/"safety", so
|
|
361
|
+
// neither the gate's own allow legs (exemptDirs/acceptDirs/isExempt session exemption) nor a settings allow can
|
|
362
|
+
// cross it (the 1.199-batch gap: an exempted tool could write .git/hooks — closed here). Same env/rootPath as
|
|
363
|
+
// the gate (the fs the hands really write; symlink canonicalization inside the policy, dist-read).
|
|
186
364
|
const fsWriteGate = (acceptCwd) => {
|
|
187
365
|
if (!gate)
|
|
188
366
|
return undefined;
|
|
@@ -191,9 +369,14 @@ export function deriveSettingsPolicy(settings, gate, workflowGate) {
|
|
|
191
369
|
rootPath: gate.cwd,
|
|
192
370
|
...(acceptCwd ? { acceptDirs: [gate.cwd] } : {}),
|
|
193
371
|
...(gate.scratchpadDir ? { exemptDirs: [gate.scratchpadDir] } : {}),
|
|
194
|
-
...(gate.isExempt ? { isExempt: gate.isExempt } : {}),
|
|
372
|
+
...(gate.isExempt ? { isExempt: gate.isExempt } : {}), // 1.294 session-exemption probe (see FsWriteGateWiring)
|
|
195
373
|
defaultWrite: "ask",
|
|
196
374
|
});
|
|
375
|
+
// NotebookEdit coverage is core-native since 1.296.1(我方 [886]① 请修 core 已兑现,1.207 的临时参数桥
|
|
376
|
+
// 就此撤除):DEFAULT_GUARDED_TOOLS 含 NotebookEdit,且两 policy 共用 `writeTargetPath` 提取器——canonical
|
|
377
|
+
// NotebookEdit 时 notebook_path 恒先(诱饵 file_path 失效),其余工具 file_path 先(反向诱饵也封);均 dist
|
|
378
|
+
// 亲读。回归锚保留在 test/task-settings.test.ts(NotebookEdit deny + 双向诱饵),现在锁的是 core 行为经
|
|
379
|
+
// 我方折叠——core 若回退,锚变红。
|
|
197
380
|
return gate.sensitivePatterns && gate.sensitivePatterns.length > 0
|
|
198
381
|
? combinePolicies(createSensitivePathPolicy({ env: gate.env, patterns: gate.sensitivePatterns, rootPath: gate.cwd }), gatePolicy)
|
|
199
382
|
: gatePolicy;
|
|
@@ -205,6 +388,10 @@ export function deriveSettingsPolicy(settings, gate, workflowGate) {
|
|
|
205
388
|
const basePolicy = compose();
|
|
206
389
|
switch (defaultMode) {
|
|
207
390
|
case "plan":
|
|
391
|
+
// plan = read-only hands + the plan workflow: a TIGHTEN (handsReadOnly false→true), honored remotely.
|
|
392
|
+
// ALSO mount core's `present_plan` (enablePlanMode) so the model explores read-only then
|
|
393
|
+
// proposes a plan (CC EnterPlanMode→ExitPlanMode parity). Both are tighten/additive — no loosening.
|
|
394
|
+
// codex F1: run_workflow mounts OUTSIDE the hands band — deny it explicitly (see createWorkflowPlanDenyPolicy).
|
|
208
395
|
return { toolPolicy: compose(createWorkflowPlanDenyPolicy()), handsReadOnly: true, enablePlanMode: true };
|
|
209
396
|
case "acceptEdits": {
|
|
210
397
|
const p = compose(fsWriteGate(true), createWorkflowAskPolicy(workflowGate?.isExempt));
|
|
@@ -212,6 +399,12 @@ export function deriveSettingsPolicy(settings, gate, workflowGate) {
|
|
|
212
399
|
}
|
|
213
400
|
case "default":
|
|
214
401
|
case "auto": {
|
|
402
|
+
// (historical note kept: the pre-[816] impl fell through to base-only here — with no gate to attach,
|
|
403
|
+
// acceptEdits-as-loosen could not be honored. The [820] factory inverts the frame: default now ADDS an ask
|
|
404
|
+
// gate and acceptEdits ADDS a narrower one, both tighten-safe under the deny-wins fold.)
|
|
405
|
+
// [1557]§四: gate.shellGate opt-in(absent = pre-此批行为 byte-for-byte)rides alongside the fs-write ask
|
|
406
|
+
// gate on the SAME "CC manual" modes — closes the "echo > file bypasses the write gate" hole (cli[1555]②)
|
|
407
|
+
// when the deployment explicitly opts in (config MANUAL_MODE_SHELL_GATE).
|
|
215
408
|
const p = compose(fsWriteGate(false), createWorkflowAskPolicy(workflowGate?.isExempt));
|
|
216
409
|
return { ...(p ? { toolPolicy: p } : {}), ...(gate?.shellGate ? { shellGate: gate.shellGate } : {}) };
|
|
217
410
|
}
|
|
@@ -220,6 +413,24 @@ export function deriveSettingsPolicy(settings, gate, workflowGate) {
|
|
|
220
413
|
return basePolicy ? { toolPolicy: basePolicy } : {};
|
|
221
414
|
}
|
|
222
415
|
}
|
|
416
|
+
/**
|
|
417
|
+
* Apply a client's parsed per-request settings onto a base `TaskSpec`, TIGHTEN-ONLY, in a SINGLE {@link
|
|
418
|
+
* tightenTaskSpec} pass (so the permission override composes deny-wins onto the baseline — TRAP #1 — and
|
|
419
|
+
* `handsReadOnly`/`onAsk` can only narrow). `tightenTaskSpec` THROWS `TaskSpecTightenError` if any override would
|
|
420
|
+
* LOOSEN a stricter base — surfaced by the caller as a 4xx (a client settings stamp that tries to widen is a
|
|
421
|
+
* client error, never a silent weakening). `model`/`outputStyle` are applied directly (model is the caller's
|
|
422
|
+
* choice WITHIN the catalog — the caller gates it before calling; outputStyle appends to the system prompt).
|
|
423
|
+
*
|
|
424
|
+
* Returns `base` untouched when the parsed settings project nothing onto the spec.
|
|
425
|
+
*/
|
|
426
|
+
// [1557]§四: core's tightenTaskSpec THROWS TaskSpecTightenError when an override's shellGate ranks LOWER than
|
|
427
|
+
// base's (its contract is "the override must itself tighten", not "take the stricter of the two" — unlike
|
|
428
|
+
// handsReadOnly, which ORs). Red-first repro: tightenTaskSpec({shellGate:"always"}, {shellGate:"classify"})
|
|
429
|
+
// throws — so a deployment that layers autonomy=ask (→"always") UNDER this opt-in (→"classify") would 422
|
|
430
|
+
// EVERY request on that mode. Mirrors core's own SHELL_GATE_RANK (tighten-task-spec.js) — only pass the
|
|
431
|
+
// override through when it would not be a downgrade; otherwise the baseline already covers it (tightenTaskSpec's
|
|
432
|
+
// base-only branch keeps `base.shellGate` unchanged either way — omitting is behaviorally identical, never a
|
|
433
|
+
// silent weakening, just avoids the throw).
|
|
223
434
|
const SHELL_GATE_RANK = { off: 0, classify: 1, always: 2 };
|
|
224
435
|
export function applyTaskSettings(base, settings, gate, workflowGate) {
|
|
225
436
|
const { toolPolicy, handsReadOnly, enablePlanMode, shellGate } = deriveSettingsPolicy(settings, gate, workflowGate);
|
|
@@ -232,11 +443,15 @@ export function applyTaskSettings(base, settings, gate, workflowGate) {
|
|
|
232
443
|
if (handsReadOnly !== undefined)
|
|
233
444
|
overrides.handsReadOnly = handsReadOnly;
|
|
234
445
|
if (shellGateSafe !== undefined)
|
|
235
|
-
overrides.shellGate = shellGateSafe;
|
|
236
|
-
next = tightenTaskSpec(next, overrides);
|
|
446
|
+
overrides.shellGate = shellGateSafe; // [1557]§四 opt-in; rank-guarded above
|
|
447
|
+
next = tightenTaskSpec(next, overrides); // deny-wins compose + THROWS on loosen (fail-loud)
|
|
237
448
|
}
|
|
449
|
+
// R4: enablePlanMode (mount present_plan) is ADDITIVE — it widens NOTHING (a read-only plan workflow), so it rides
|
|
450
|
+
// directly (not through tightenTaskSpec, which guards safety fields). Only ever set true (plan), never cleared.
|
|
238
451
|
if (enablePlanMode)
|
|
239
452
|
next = { ...next, enablePlanMode: true };
|
|
453
|
+
// outputStyle → appended system prompt (additive UX directive; never a safety field). The caller already set any
|
|
454
|
+
// business systemPrompt; core's appendSystemPrompt rides after the scenario base.
|
|
240
455
|
if (settings.outputStyle) {
|
|
241
456
|
const appended = next.appendSystemPrompt ? `${next.appendSystemPrompt}\n\n${settings.outputStyle}` : settings.outputStyle;
|
|
242
457
|
next = { ...next, appendSystemPrompt: appended };
|
package/dist/task-workflow.d.ts
CHANGED
|
@@ -1,25 +1,92 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Workflow super-set unlock — map the per-task `body.selfOrchestration` intent onto
|
|
3
|
+
* `TaskSpec.selfOrchestration`, the gate that mounts core's LLM-authored `run_workflow` engine (the workflow.ts
|
|
4
|
+
* agent/parallel/pipeline orchestrator). Same shape as the rank-1 roster gap: the engine (core run_workflow +
|
|
5
|
+
* workflow.ts) is BUILT, but nothing mapped a body field to the per-task spec flag, so it was unreachable over HTTP
|
|
6
|
+
* (capabilities advertised `workflows:true` but the LLM could never call run_workflow).
|
|
7
|
+
*
|
|
8
|
+
* Gating:
|
|
9
|
+
* - DEPLOYMENT: `selfOrchestrationEnabled` must be on (the workflowScriptRunner + stores are wired). Otherwise a set
|
|
10
|
+
* flag is a harmless no-op (core fail-closes run_workflow without the sandbox runner), so it's dropped for clarity.
|
|
11
|
+
* - MULTI-TENANT: honored ONLY when a per-principal entitlement RESOLVER is wired (`hasEntitlementResolver`). 🔴 core's
|
|
12
|
+
* `allowWorkflows` (RuntimeCaps) is TIGHTEN-ONLY — a resolver can only DENY; `undefined` = NO restriction, so the
|
|
13
|
+
* deployment capability governs. Therefore WITHOUT a resolver the engine would mount run_workflow UNGATED for every
|
|
14
|
+
* tenant. So we fail-closed here (defense-in-depth: a misconfigured multi-tenant deployment with no entitlement
|
|
15
|
+
* source must NOT leak the LLM-authored workflow engine). WITH a resolver, core enforces `allowWorkflows`
|
|
16
|
+
* per-principal (deny → fail-closed). Single-user (owns its own worker) honors directly. Three-gate: engine-can ∧
|
|
17
|
+
* center-may(allowWorkflows) ∧ shell-show.
|
|
18
|
+
*/
|
|
1
19
|
export declare function selfOrchestrationFromBody(body: {
|
|
2
20
|
selfOrchestration?: unknown;
|
|
3
21
|
}, config: {
|
|
4
22
|
selfOrchestrationEnabled: boolean;
|
|
5
23
|
requirePrincipal?: boolean;
|
|
6
24
|
}, hasEntitlementResolver: boolean): true | undefined;
|
|
25
|
+
/**
|
|
26
|
+
* §4 (Fork) — map the per-task `body.enableFork` intent onto `TaskSpec.enableFork`. core 1.257 (design/136 BREAKING)
|
|
27
|
+
* RETIRED the standalone `Fork` tool; a fork is now `Agent(subagent_type:"fork")`, and `enableFork` is one of the two
|
|
28
|
+
* governance axes (`forkGovernanceDenial(spec.enableFork, runtimeCaps.allowFork)`) that gate it.
|
|
29
|
+
*
|
|
30
|
+
* 🔴 CONSUME-CRITICAL — the default FLIPPED to opt-OUT: core now treats `enableFork === undefined` as **available**
|
|
31
|
+
* (only an EXPLICIT `enableFork:false` / `allowFork:false` denies — CC's default posture). So where the SERVICE intends
|
|
32
|
+
* to DENY, it must return `false` EXPLICITLY — the old "return undefined = not granted" is now fail-OPEN.
|
|
33
|
+
* - DEPLOYMENT posture OFF (`!forkEnabled`, e.g. multi-tenant default): `false` (explicit deny — preserve opt-in posture).
|
|
34
|
+
* - PER-TASK OPT-OUT (`body.enableFork === false`): `false` (any tenancy).
|
|
35
|
+
* - SINGLE-USER TURNKEY: `true` — DEFAULT ON for the LLM (clay 2026-07-01). (core still only lets it fork where the
|
|
36
|
+
* session store is fork-capable and never inside a fork / read-only band — graceful degrade, no capability lie.)
|
|
37
|
+
* - MULTI-TENANT: `true` ONLY with a per-principal entitlement RESOLVER wired (core then enforces `allowFork`
|
|
38
|
+
* tighten-only per-principal); WITHOUT a resolver `false` (fail-closed — `allowFork` is tighten-only so an absent
|
|
39
|
+
* resolver = `undefined` = ungated, and now `enableFork:undefined` also auto-grants, so the service must hard-deny).
|
|
40
|
+
*/
|
|
7
41
|
export declare function enableForkFromBody(body: {
|
|
8
42
|
enableFork?: unknown;
|
|
9
43
|
}, config: {
|
|
10
44
|
forkEnabled: boolean;
|
|
11
45
|
requirePrincipal?: boolean;
|
|
12
46
|
}, hasEntitlementResolver: boolean): boolean;
|
|
47
|
+
/**
|
|
48
|
+
* The workflow-script MODEL allowlist (`agent({model})` picks). core is
|
|
49
|
+
* fail-closed: NO allowlist configured ⇒ `WorkflowModelNotAllowedError` on ANY model pick, which on a TOC
|
|
50
|
+
* single-user deployment broke clay's own dual-model scripts (决策 v4-pro + 执行 v4-flash) out of the box —
|
|
51
|
+
* the operator configured every catalog entry themselves, so there is nothing to protect them from.
|
|
52
|
+
* - Explicit `SELF_ORCHESTRATION_MODELS` always wins (any tenancy — the operator's deliberate narrowing).
|
|
53
|
+
* - SINGLE-USER: default to the deployment's OWN model catalog (`Object.keys(models)`).
|
|
54
|
+
* - MULTI-TENANT: keep core's fail-closed empty default (a model pick is a cost/capability grant the
|
|
55
|
+
* operator must make explicitly; a tenant script must not self-select the expensive rung).
|
|
56
|
+
* Returns undefined when no allowlist should be set (core then fail-closes picks; the script's `agent()`
|
|
57
|
+
* without a model still runs on the workflow's default role — only PICKING is gated).
|
|
58
|
+
*/
|
|
13
59
|
export declare function workflowModelAllowlistFor(config: {
|
|
14
60
|
selfOrchestrationModels: string[];
|
|
15
61
|
requirePrincipal?: boolean;
|
|
16
62
|
models: Record<string, unknown>;
|
|
17
63
|
}): string[] | undefined;
|
|
64
|
+
/** design/122 caps for a caller-supplied `retainSubagentSessions` object (core defaults 30min/16; the ledger
|
|
65
|
+
* is run-scoped and fully released at parent end, so these only bound the WITHIN-RUN memory pin). */
|
|
18
66
|
export declare const RETAIN_SUBAGENT_TTL_MS_CAP: number;
|
|
19
67
|
export declare const RETAIN_SUBAGENT_MAX_CAP = 64;
|
|
68
|
+
/**
|
|
69
|
+
* design/122 (core 1.225): normalize an untrusted `body.retainSubagentSessions` onto the TaskSpec field.
|
|
70
|
+
* `true`/`false` pass through (core's own defaults apply); an object keeps only NUMERIC ttlMs/max, each
|
|
71
|
+
* clamped to a positive integer under the cap (retention pins settled child sessions in memory for the
|
|
72
|
+
* parent run's lifetime — the knob must not become a caller-controlled resource hold). Anything malformed →
|
|
73
|
+
* undefined = OFF (core default). Defensive, never throws: RESUME re-runs resolveSpec WITHOUT the HTTP-layer
|
|
74
|
+
* validation, so this normalizer is the single guard on every path.
|
|
75
|
+
*/
|
|
20
76
|
export declare function normalizeRetainSubagentSessions(raw: unknown): boolean | {
|
|
21
77
|
ttlMs?: number;
|
|
22
78
|
max?: number;
|
|
23
79
|
} | undefined;
|
|
80
|
+
/**
|
|
81
|
+
* Per-task wall clock by TENANCY POSTURE (clay 2026-07-04, make-real 教训①:600s 默认墙钟砍掉了健康推进的
|
|
82
|
+
* 长任务/chaos 恢复 run):
|
|
83
|
+
* - SINGLE-USER turnkey(`requirePrincipal !== true`)= the user IS the superadmin → **NO wall clock**
|
|
84
|
+
* (undefined; core arms none — its separate wedge safety-net still catches a stuck tool call, so "no wall"
|
|
85
|
+
* never means "hangs forever"). CC has no whole-task decapitation either.
|
|
86
|
+
* - MULTI-TENANT: base 2400s (big tasks — council/debate/team — 3600s). (PAIR-REVIEW F-4 附带修:此行
|
|
87
|
+
* 曾写 600s/1500s 与代码漂移——真值以下方 base 为准。)
|
|
88
|
+
* - Explicit `TASK_TIMEOUT_SEC` wins in ANY tenancy (the operator's deliberate wall) and keeps its documented
|
|
89
|
+
* raise-only floor (`Math.max` with the base, so a misconfigured low value cannot shrink a council budget).
|
|
90
|
+
*/
|
|
24
91
|
export declare function taskWallClockSec(envTimeoutSec: number, requirePrincipal: boolean | undefined, big: boolean): number | undefined;
|
|
25
92
|
//# sourceMappingURL=task-workflow.d.ts.map
|