@sema-agent/server 7.149.0 → 7.151.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/MIGRATION.md +307 -9
- package/README.md +1 -1
- package/README.zh-CN.md +1 -1
- package/USAGE.md +92 -40
- package/deploy/sema-up/README.md +7 -1
- package/deploy/sema-up/chart/Chart.yaml +1 -1
- package/deploy/sema-up/chart/templates/NOTES.txt +5 -0
- package/deploy/sema-up/chart/templates/_helpers.tpl +15 -16
- package/deploy/sema-up/chart/templates/server-v4pro.yaml +5 -3
- package/deploy/sema-up/chart/templates/server.yaml +5 -3
- package/deploy/sema-up/chart/values-full-single.yaml +3 -1
- package/deploy/sema-up/chart/values.yaml +8 -1
- package/deploy/sema-up/cluster-up.sh +1 -0
- package/deploy/sema-up/kube-up.sh +1 -1
- package/deploy/sema-up/lib/flagshape.sh +1 -1
- package/deploy/sema-up/lib/helm-values-cluster.py +2 -0
- package/deploy/sema-up/lib/helm-values-kube.py +2 -0
- package/dist/adoption/import.js +3 -3
- package/dist/approval-ask-machine.d.ts +1 -1
- package/dist/approval-card.d.ts +3 -3
- package/dist/approval-gate-currency.d.ts +2 -2
- package/dist/audit.d.ts +1 -1
- package/dist/audit.js +2 -2
- package/dist/auth-bridge.d.ts +20 -0
- package/dist/auth-bridge.js +9 -0
- package/dist/background-session-reap.d.ts +2 -2
- package/dist/bake-runner/main.d.ts +4 -2
- package/dist/bind-host.d.ts +2 -3
- package/dist/bind-host.js +2 -4
- package/dist/boot/budget-tracing.js +1 -1
- package/dist/boot/deferred-sandbox-path-env.d.ts +5 -3
- package/dist/boot/deferred-sandbox-path-env.js +1 -2
- package/dist/boot/engine-lease.d.ts +5 -0
- package/dist/boot/engine-lease.js +1 -0
- package/dist/boot/execution-env.d.ts +8 -14
- package/dist/boot/execution-env.js +54 -17
- package/dist/boot/execution-lane.js +32 -5
- package/dist/boot/late-binds.d.ts +8 -4
- package/dist/boot/late-binds.js +7 -1
- package/dist/boot/memory-consolidation.d.ts +3 -2
- package/dist/boot/memory-consolidation.js +6 -6
- package/dist/boot/parked-revive-gate.d.ts +5 -5
- package/dist/boot/parked-revive-gate.js +2 -3
- package/dist/boot/reapers.d.ts +5 -0
- package/dist/boot/reapers.js +12 -1
- package/dist/boot/resolve-spec.d.ts +7 -8
- package/dist/boot/resolve-spec.js +80 -35
- package/dist/boot/retention-lane.d.ts +1 -1
- package/dist/boot/runner-deps.d.ts +9 -2
- package/dist/boot/runner-deps.js +3 -3
- package/dist/boot/session-age-out.d.ts +36 -0
- package/dist/boot/session-age-out.js +101 -0
- package/dist/boot/session-faces.d.ts +5 -14
- package/dist/boot/session-faces.js +28 -24
- package/dist/boot/stage-01-config.js +2 -0
- package/dist/boot/stage-03-store-backend.js +2 -2
- package/dist/boot/stage-05-execution-env.d.ts +5 -3
- package/dist/boot/stage-05-execution-env.js +2 -2
- package/dist/boot/stage-06-runners.d.ts +7 -4
- package/dist/boot/stage-06-runners.js +16 -8
- package/dist/boot/stage-07-capability-layer.d.ts +7 -4
- package/dist/boot/stage-07-capability-layer.js +3 -2
- package/dist/boot/stage-08-reapers.d.ts +7 -4
- package/dist/boot/stage-08-reapers.js +4 -2
- package/dist/boot/stage-09-leader.d.ts +11 -5
- package/dist/boot/stage-09-leader.js +12 -3
- package/dist/boot/stage-10-http-server.d.ts +44 -6
- package/dist/boot/stage-10-http-server.js +12 -10
- package/dist/boot/web-admin.d.ts +1 -1
- package/dist/boot/web-admin.js +3 -1
- package/dist/boot/workflow-orchestration.d.ts +7 -2
- package/dist/boot/workflow-orchestration.js +24 -7
- package/dist/bounded-rotation.d.ts +29 -0
- package/dist/bounded-rotation.js +24 -0
- package/dist/capability-facts.d.ts +84 -66
- package/dist/capability-facts.js +58 -41
- package/dist/center-credential.d.ts +25 -6
- package/dist/center-credential.js +25 -5
- package/dist/config-catalog.d.ts +26 -7
- package/dist/config-catalog.js +15 -12
- package/dist/config-invariants.d.ts +2 -1
- package/dist/config-invariants.js +4 -4
- package/dist/config-types.d.ts +22 -15
- package/dist/config.d.ts +51 -2
- package/dist/config.js +35 -24
- package/dist/deployment-governance.d.ts +7 -28
- package/dist/deployment-governance.js +1 -14
- package/dist/deployment-shape.d.ts +9 -1
- package/dist/deployment-shape.js +2 -1
- package/dist/device-protocol.d.ts +5 -4
- package/dist/device-protocol.js +1 -1
- package/dist/device-ws-hub.d.ts +1 -0
- package/dist/device-ws-hub.js +66 -29
- package/dist/device-ws-protocol.d.ts +79 -12
- package/dist/device-ws-protocol.js +64 -26
- package/dist/engine-identity.d.ts +23 -5
- package/dist/engine-identity.js +13 -0
- package/dist/entry-mode-clamp-notice.d.ts +2 -1
- package/dist/execution-env-refusal.d.ts +23 -0
- package/dist/execution-env-refusal.js +5 -0
- package/dist/execution-lane-caps.d.ts +3 -1
- package/dist/field-conflict.d.ts +3 -3
- package/dist/file-history-capture.d.ts +11 -4
- package/dist/file-history-capture.js +9 -6
- package/dist/file-history-disclosure.d.ts +7 -5
- package/dist/file-history-disclosure.js +7 -5
- package/dist/fleet/drain-entry.d.ts +4 -0
- package/dist/fleet/engine-signal.d.ts +14 -1
- package/dist/fleet/engine-signal.js +5 -1
- package/dist/fleet/fleet-reconciler.d.ts +1 -1
- package/dist/fleet/serving-lease.d.ts +18 -3
- package/dist/fleet/serving-lease.js +81 -35
- package/dist/fleet-client.d.ts +13 -11
- package/dist/fleet-client.js +53 -33
- package/dist/history-anchor.js +1 -1
- package/dist/hitl-delivery.d.ts +1 -3
- package/dist/hitl-delivery.js +1 -1
- package/dist/hooks/hook-runner.js +2 -2
- package/dist/host-lsp-manager.d.ts +2 -2
- package/dist/http/active-run-conflict.d.ts +3 -7
- package/dist/http/active-run-conflict.js +2 -2
- package/dist/http/admission.js +19 -4
- package/dist/http/approval-sweeps.js +7 -6
- package/dist/http/caller-trust.d.ts +2 -2
- package/dist/http/caller-trust.js +3 -3
- package/dist/http/checkpoint-ctx.d.ts +20 -63
- package/dist/http/checkpoint-ctx.js +2 -24
- package/dist/http/claim-heartbeat.d.ts +4 -4
- package/dist/http/claim-heartbeat.js +3 -3
- package/dist/http/dispatch.d.ts +2 -1
- package/dist/http/dispatch.js +36 -29
- package/dist/http/durable-run-leg.js +17 -17
- package/dist/http/health-self-report.d.ts +9 -1
- package/dist/http/health-self-report.js +2 -0
- package/dist/http/owner-access.d.ts +264 -20
- package/dist/http/owner-access.js +215 -5
- package/dist/http/readiness.d.ts +4 -2
- package/dist/http/resume-ctx-read.js +38 -1
- package/dist/http/resume-legs.d.ts +2 -1
- package/dist/http/resume-legs.js +273 -89
- package/dist/http/route-ctx.d.ts +41 -19
- package/dist/http/route-table.d.ts +1 -1
- package/dist/http/routes/a2a-serve.js +15 -14
- package/dist/http/routes/admin-memory-optout.d.ts +1 -1
- package/dist/http/routes/agents-roster.js +2 -3
- package/dist/http/routes/approvals-assistant.d.ts +3 -2
- package/dist/http/routes/approvals-assistant.js +12 -12
- package/dist/http/routes/background.d.ts +3 -3
- package/dist/http/routes/capabilities.js +10 -6
- package/dist/http/routes/config-catalog.d.ts +1 -1
- package/dist/http/routes/fleet.js +10 -8
- package/dist/http/routes/mcp-reconnect.js +2 -2
- package/dist/http/routes/memory-origin.d.ts +1 -1
- package/dist/http/routes/notify-wake.js +2 -3
- package/dist/http/routes/projects.d.ts +4 -2
- package/dist/http/routes/projects.js +7 -6
- package/dist/http/routes/retention-ops.d.ts +1 -1
- package/dist/http/routes/run-permission-mode.d.ts +1 -1
- package/dist/http/routes/run-permission-mode.js +2 -2
- package/dist/http/routes/runs.d.ts +1 -1
- package/dist/http/routes/runs.js +125 -66
- package/dist/http/routes/session-memory-sync.js +4 -5
- package/dist/http/routes/session-sync.d.ts +4 -3
- package/dist/http/routes/session-sync.js +174 -83
- package/dist/http/routes/sessions-list.js +13 -7
- package/dist/http/routes/sessions.d.ts +1 -1
- package/dist/http/routes/sessions.js +26 -48
- package/dist/http/routes/tasks.js +38 -23
- package/dist/http/routes/trace-usage.js +14 -14
- package/dist/http/routes/workflows.d.ts +1 -0
- package/dist/http/routes/workflows.js +20 -38
- package/dist/http/server.d.ts +28 -30
- package/dist/http/server.js +7 -3
- package/dist/http/stored-body-replay.d.ts +3 -24
- package/dist/http/stored-body-replay.js +2 -12
- package/dist/http/submit-ctx.d.ts +1 -2
- package/dist/http/submit-ctx.js +8 -6
- package/dist/http/submit-replay.d.ts +15 -2
- package/dist/http/submit-replay.js +10 -4
- package/dist/http/wire-types.d.ts +19 -6
- package/dist/identity-source.d.ts +20 -3
- package/dist/identity-source.js +14 -0
- package/dist/index.d.ts +4 -0
- package/dist/lane-home-probe.d.ts +3 -7
- package/dist/lane-home-probe.js +0 -1
- package/dist/leader/endpoint.js +9 -8
- package/dist/leader/leader.d.ts +2 -1
- package/dist/leg-facts.d.ts +19 -5
- package/dist/leg-facts.js +3 -1
- package/dist/mcp-authorization-face.d.ts +18 -14
- package/dist/mcp-authorization-face.js +3 -2
- package/dist/memory-scope.d.ts +5 -4
- package/dist/memory-scope.js +4 -4
- package/dist/memory-store-refusal.d.ts +1 -1
- package/dist/memory-sync-client.d.ts +30 -2
- package/dist/memory-sync-client.js +16 -9
- package/dist/observability/corrupt-read-seat.d.ts +1 -1
- package/dist/observability/err-text.d.ts +7 -0
- package/dist/observability/err-text.js +5 -0
- package/dist/observability/fail-open.d.ts +12 -8
- package/dist/observability/fail-open.js +12 -8
- package/dist/observability/logger.d.ts +7 -0
- package/dist/observability/logger.js +3 -1
- package/dist/observability/metrics.js +1 -0
- package/dist/observability/run-terminal.d.ts +1 -1
- package/dist/orchestration/workflow-notify-journal.d.ts +18 -1
- package/dist/orchestration/workflow-notify-journal.js +12 -1
- package/dist/orchestration/workflow-park-decision.d.ts +70 -18
- package/dist/orchestration/workflow-park-decision.js +49 -10
- package/dist/orchestration/workflow-park-holder.d.ts +65 -0
- package/dist/orchestration/workflow-park-holder.js +98 -0
- package/dist/orchestration/workflow-record-fence.d.ts +36 -0
- package/dist/orchestration/workflow-record-fence.js +42 -0
- package/dist/owner-faces.d.ts +28 -4
- package/dist/owner-faces.js +2 -0
- package/dist/parked-decide.d.ts +104 -53
- package/dist/parked-decide.js +153 -117
- package/dist/peer-directory.d.ts +2 -2
- package/dist/peer-inbound-face.d.ts +2 -6
- package/dist/peer-inbound-face.js +0 -3
- package/dist/peer-seat.d.ts +1 -1
- package/dist/peer-seat.js +52 -59
- package/dist/permission-mode-admission.d.ts +41 -5
- package/dist/permission-mode-admission.js +29 -3
- package/dist/plugins/adoption-log-sql.d.ts +3 -1
- package/dist/plugins/adoption-log-sql.js +7 -1
- package/dist/plugins/approval-ask-store-file.d.ts +10 -2
- package/dist/plugins/approval-ask-store-file.js +8 -0
- package/dist/plugins/approval-ask-store-memory.d.ts +6 -1
- package/dist/plugins/approval-ask-store-memory.js +28 -9
- package/dist/plugins/approval-ask-store-sql.d.ts +43 -2
- package/dist/plugins/approval-ask-store-sql.js +34 -5
- package/dist/plugins/approval-exemption-store.js +3 -0
- package/dist/plugins/approval-nonce-store.js +2 -0
- package/dist/plugins/breaker-state-sql.js +2 -0
- package/dist/plugins/caching-session-store.d.ts +9 -15
- package/dist/plugins/caching-session-store.js +6 -0
- package/dist/plugins/device-store-sql.js +6 -0
- package/dist/plugins/error-origin.d.ts +18 -0
- package/dist/plugins/error-origin.js +10 -0
- package/dist/plugins/exec-path-law.d.ts +34 -0
- package/dist/plugins/exec-path-law.js +13 -0
- package/dist/plugins/execution-placement-sql.js +6 -6
- package/dist/plugins/file-run-store.js +1 -1
- package/dist/plugins/image-bake-store-sql.js +6 -0
- package/dist/plugins/image-index-sql.js +4 -0
- package/dist/plugins/landed-attendants.d.ts +212 -0
- package/dist/plugins/landed-attendants.js +161 -0
- package/dist/plugins/leader-run-store-sql.js +4 -0
- package/dist/plugins/local-checkpoint-store.d.ts +4 -1
- package/dist/plugins/local-checkpoint-store.js +3 -0
- package/dist/plugins/local-session-live-reference.d.ts +40 -0
- package/dist/plugins/local-session-live-reference.js +39 -0
- package/dist/plugins/local-session-store.d.ts +71 -33
- package/dist/plugins/local-session-store.js +129 -27
- package/dist/plugins/memory-engine-pg.js +4 -0
- package/dist/plugins/memory-engine-sql-apply.js +5 -2
- package/dist/plugins/memory-engine-tidb.js +4 -0
- package/dist/plugins/memory-optout-grant-store-sql.js +4 -0
- package/dist/plugins/memory-run-store.js +1 -1
- package/dist/plugins/memory-sync-store-pg.js +5 -0
- package/dist/plugins/memory-sync-store-tidb.js +5 -0
- package/dist/plugins/one-time-migrations.d.ts +80 -61
- package/dist/plugins/one-time-migrations.js +241 -104
- package/dist/plugins/org-delivery-quota-store.js +4 -1
- package/dist/plugins/outcome-ledger-sql.js +2 -0
- package/dist/plugins/permission-rule-store-sql.js +11 -4
- package/dist/plugins/pg-cost-quota.js +4 -0
- package/dist/plugins/pg-pool.js +28 -1
- package/dist/plugins/pg-rate-limiter.js +2 -0
- package/dist/plugins/posix-shell-fs.d.ts +6 -1
- package/dist/plugins/posix-shell-fs.js +8 -3
- package/dist/plugins/remote-env-adb.d.ts +19 -15
- package/dist/plugins/remote-env-adb.js +44 -17
- package/dist/plugins/remote-env-connect-seat.d.ts +105 -0
- package/dist/plugins/remote-env-connect-seat.js +72 -0
- package/dist/plugins/remote-env-device.d.ts +22 -5
- package/dist/plugins/remote-env-device.js +114 -14
- package/dist/plugins/remote-env-e2b.d.ts +18 -7
- package/dist/plugins/remote-env-e2b.js +53 -40
- package/dist/plugins/remote-env-file-error.js +6 -2
- package/dist/plugins/remote-env-host.d.ts +18 -1
- package/dist/plugins/remote-env-host.js +48 -47
- package/dist/plugins/remote-env-k8s.d.ts +41 -39
- package/dist/plugins/remote-env-k8s.js +56 -32
- package/dist/plugins/remote-env-local-docker.d.ts +13 -8
- package/dist/plugins/remote-env-local-docker.js +37 -43
- package/dist/plugins/remote-env-ssh.d.ts +18 -12
- package/dist/plugins/remote-env-ssh.js +64 -62
- package/dist/plugins/remote-shell.d.ts +101 -2
- package/dist/plugins/remote-shell.js +221 -3
- package/dist/plugins/replica-registration.d.ts +35 -0
- package/dist/plugins/replica-registration.js +48 -0
- package/dist/plugins/resume-anchor-store-sql.d.ts +11 -2
- package/dist/plugins/resume-anchor-store-sql.js +12 -5
- package/dist/plugins/retention-lane-store-sql.d.ts +1 -1
- package/dist/plugins/retention-lane-store-sql.js +4 -0
- package/dist/plugins/retention-sql.d.ts +20 -2
- package/dist/plugins/retention-sql.js +11 -0
- package/dist/plugins/run-store-sql.d.ts +22 -3
- package/dist/plugins/run-store-sql.js +33 -9
- package/dist/plugins/scenario-prefix-switch-m42.d.ts +6 -12
- package/dist/plugins/scenario-prefix-switch-m42.js +7 -5
- package/dist/plugins/schema-consistency.d.ts +9 -5
- package/dist/plugins/schema-consistency.js +48 -18
- package/dist/plugins/schema-drift-sentence.js +1 -1
- package/dist/plugins/send-file-ledger.js +3 -0
- package/dist/plugins/serving-requirement.d.ts +68 -0
- package/dist/plugins/serving-requirement.js +60 -0
- package/dist/plugins/session-birth.d.ts +6 -2
- package/dist/plugins/session-capture-record-store-sql.js +2 -0
- package/dist/plugins/session-ext-table.d.ts +14 -1
- package/dist/plugins/session-ext-table.js +5 -1
- package/dist/plugins/session-row-sql.d.ts +49 -2
- package/dist/plugins/session-row-sql.js +56 -13
- package/dist/plugins/session-store-sql.d.ts +34 -18
- package/dist/plugins/session-store-sql.js +98 -17
- package/dist/plugins/shared-memory-store-sql.d.ts +1 -0
- package/dist/plugins/shared-memory-store-sql.js +6 -2
- package/dist/plugins/sql-driver.d.ts +2 -1
- package/dist/plugins/sql-driver.js +18 -3
- package/dist/plugins/sql-errors.d.ts +11 -6
- package/dist/plugins/sql-errors.js +5 -6
- package/dist/plugins/stop-then-start-sentence.d.ts +48 -3
- package/dist/plugins/stop-then-start-sentence.js +48 -0
- package/dist/plugins/stop-then-start.d.ts +109 -0
- package/dist/plugins/stop-then-start.js +104 -0
- package/dist/plugins/store-backend.d.ts +40 -13
- package/dist/plugins/store-backend.js +169 -27
- package/dist/plugins/store-boundary.d.ts +57 -0
- package/dist/plugins/store-boundary.js +139 -0
- package/dist/plugins/store-contracts.d.ts +29 -2
- package/dist/plugins/store-contracts.js +3 -0
- package/dist/plugins/store-fault-sentence-m53.d.ts +7 -0
- package/dist/plugins/store-fault-sentence-m53.js +25 -0
- package/dist/plugins/store-fault.d.ts +26 -7
- package/dist/plugins/store-fault.js +18 -2
- package/dist/plugins/task-attachment-store.js +9 -0
- package/dist/plugins/task-list-store-sql.d.ts +2 -2
- package/dist/plugins/task-list-store-sql.js +10 -8
- package/dist/plugins/tidb-cost-quota.js +4 -0
- package/dist/plugins/tidb-pool.js +6 -1
- package/dist/plugins/tidb-rate-limiter.js +4 -0
- package/dist/plugins/user-input-ledger-sql.js +4 -0
- package/dist/plugins/workflow-run-store-sql.d.ts +28 -10
- package/dist/plugins/workflow-run-store-sql.js +64 -4
- package/dist/plugins/workspace-fill.d.ts +4 -7
- package/dist/plugins/workspace-fill.js +2 -1
- package/dist/plugins/write-behind-counter.js +5 -0
- package/dist/process-instance.d.ts +3 -0
- package/dist/process-instance.js +7 -0
- package/dist/project-context.d.ts +64 -0
- package/dist/project-context.js +66 -0
- package/dist/project-registry.d.ts +46 -0
- package/dist/project-registry.js +44 -0
- package/dist/question.d.ts +9 -21
- package/dist/question.js +28 -19
- package/dist/request-key-closure.js +1 -1
- package/dist/request-value-closure.d.ts +4 -0
- package/dist/request-value-closure.js +10 -0
- package/dist/run-acceptance.d.ts +3 -2
- package/dist/run-acceptance.js +4 -6
- package/dist/run-cancel-card.d.ts +1 -1
- package/dist/run-cancel-card.js +2 -1
- package/dist/run-local.js +1 -0
- package/dist/runs.d.ts +37 -8
- package/dist/runs.js +53 -12
- package/dist/runtime-governance.d.ts +5 -4
- package/dist/security.d.ts +31 -33
- package/dist/security.js +41 -7
- package/dist/server-secret-env.d.ts +12 -10
- package/dist/server-secret-env.js +24 -15
- package/dist/session-agent.d.ts +1 -10
- package/dist/session-agent.js +0 -6
- package/dist/session-bindings.d.ts +82 -0
- package/dist/session-bindings.js +18 -0
- package/dist/session-children-retire.d.ts +2 -2
- package/dist/session-children-retire.js +2 -6
- package/dist/session-deletion.d.ts +16 -1
- package/dist/session-error-wire.d.ts +3 -3
- package/dist/session-error-wire.js +3 -3
- package/dist/session-incarnation.d.ts +28 -4
- package/dist/session-incarnation.js +14 -2
- package/dist/session-kind.d.ts +57 -0
- package/dist/session-kind.js +22 -0
- package/dist/session-notify-door.d.ts +4 -4
- package/dist/session-notify-door.js +5 -6
- package/dist/session-row.d.ts +21 -1
- package/dist/session-row.js +7 -1
- package/dist/session-rules-seat.d.ts +4 -3
- package/dist/session-rules-seat.js +3 -11
- package/dist/session-sync-kernel.d.ts +24 -14
- package/dist/session-sync-kernel.js +3 -6
- package/dist/session-sync.d.ts +4 -98
- package/dist/session-sync.js +4 -74
- package/dist/session-titler.d.ts +10 -3
- package/dist/session-titler.js +19 -6
- package/dist/ssh-host-key.d.ts +5 -0
- package/dist/ssh-host-key.js +3 -0
- package/dist/stores-sql/checkpoint-store-sql.d.ts +21 -2
- package/dist/stores-sql/checkpoint-store-sql.js +106 -18
- package/dist/stores-sql/file-history-store-sql.d.ts +52 -2
- package/dist/stores-sql/file-history-store-sql.js +108 -70
- package/dist/stores-sql/pg-session-storage.d.ts +34 -7
- package/dist/stores-sql/pg-session-storage.js +37 -13
- package/dist/stores-sql/retention-store-sql.d.ts +2 -10
- package/dist/stores-sql/retention-store-sql.js +2 -10
- package/dist/stores-sql/session-policy-store-sql.d.ts +30 -7
- package/dist/stores-sql/session-policy-store-sql.js +61 -44
- package/dist/stores-sql/session-write-hooks.d.ts +11 -0
- package/dist/stores-sql/tidb-session-store.d.ts +58 -7
- package/dist/stores-sql/tidb-session-store.js +37 -13
- package/dist/submission-exit.d.ts +3 -2
- package/dist/submission-exit.js +9 -1
- package/dist/task-cwd.d.ts +6 -5
- package/dist/task-settings.d.ts +19 -5
- package/dist/task-settings.js +13 -7
- package/dist/terminal.d.ts +33 -2
- package/dist/terminal.js +139 -9
- package/dist/tool-approval.d.ts +147 -12
- package/dist/tool-approval.js +206 -109
- package/dist/trace/engine-notice-wire.d.ts +14 -0
- package/dist/trace/engine-notice-wire.js +18 -1
- package/dist/trace/project.d.ts +4 -3
- package/dist/trace/project.js +3 -2
- package/dist/trace/projection-table.d.ts +33 -2
- package/dist/trace/self-minted-wire.d.ts +422 -26
- package/dist/trace/self-minted-wire.js +149 -23
- package/dist/trace/tool-card.d.ts +3 -0
- package/dist/trace/tool-card.js +24 -0
- package/dist/trace/tool-output-media.d.ts +2 -1
- package/dist/unattended-permission-mode.d.ts +1 -1
- package/dist/web-admin-client/apply-effective.d.ts +1 -1
- package/dist/web-admin-client/effective-keys.d.ts +1 -1
- package/dist/web-admin-client/skills-mcp.d.ts +1 -1
- package/docs/DEVICE-EXECUTOR-PROTOCOL.md +120 -41
- package/package.json +3 -3
- package/wire-changes/server@7.150.0.json +335 -0
- package/wire-changes/server@7.151.0.json +762 -0
- package/dist/http/session-inherit-env.d.ts +0 -36
- package/dist/http/session-inherit-env.js +0 -6
|
@@ -6,7 +6,7 @@ import { MANAGED_RETENTION, UNMANAGED_RETENTION } from "../plugins/retention-dec
|
|
|
6
6
|
import { headFromRow, mintSessionIncarnation, sessionFaceFromRow } from "../session-incarnation.js";
|
|
7
7
|
import { contentForkRelation, fastForwardSharedContentDiverged } from "../session-sync-content.js";
|
|
8
8
|
import { placementCapabilityOf, LIST_PLACED_BATCH, PLACEMENT_SELECT_COLUMNS, placedRowFromRow, placementFromRow, placementInsertCells, SESSION_DURABILITY, SESSION_PLACEMENTS, } from "../plugins/session-placement.js";
|
|
9
|
-
import { classifySyncRelationshipByIds, SyncConflictError,
|
|
9
|
+
import { classifySyncRelationshipByIds, SyncConflictError, StagedCommitOccupantChangedError, stagingIdFor, STAGING_ID_MARKER, STAGING_GC_GRACE_MS, } from "../session-sync-kernel.js";
|
|
10
10
|
import { assertFirstOwnerWritable, forkOwnerOf, isSessionOwnerValue, placedSessionOwnerOf } from "../plugins/session-ownership.js";
|
|
11
11
|
import { forkRowCells, selectForkRows } from "@sema-agent/core";
|
|
12
12
|
import { FORK_LOG_ROW_SHAPE, ForkTargetUnsettledError, classifyForkTarget, forkByFreshId, forkPointOf, sameSourceGeneration } from "../plugins/session-fork.js";
|
|
@@ -104,14 +104,33 @@ export class TiDBSessionStore {
|
|
|
104
104
|
async register(sessionId, owner) {
|
|
105
105
|
await this.registerWithReceipt(sessionId, owner);
|
|
106
106
|
}
|
|
107
|
-
async registerWithReceipt(sessionId, owner) {
|
|
107
|
+
async registerWithReceipt(sessionId, owner, kind) {
|
|
108
108
|
if (!isSessionOwnerValue(owner)) {
|
|
109
109
|
if ((await this.headOf(sessionId)) !== undefined)
|
|
110
110
|
return {};
|
|
111
111
|
assertFirstOwnerWritable(sessionId, owner);
|
|
112
112
|
}
|
|
113
113
|
const incarnation = mintSessionIncarnation();
|
|
114
|
-
|
|
114
|
+
if (kind === undefined) {
|
|
115
|
+
await this.insertMeta(sessionId, owner, undefined, incarnation);
|
|
116
|
+
return { minted: { sessionId, owner, incarnation } };
|
|
117
|
+
}
|
|
118
|
+
const conn = await this.pool.getConnection();
|
|
119
|
+
try {
|
|
120
|
+
await conn.beginTransaction();
|
|
121
|
+
await this.insertMetaOn(conn, sessionId, owner, undefined, incarnation);
|
|
122
|
+
const [rows] = await conn.query("SELECT incarnation FROM session_meta WHERE session_id = ? FOR UPDATE", [sessionId]);
|
|
123
|
+
if (rows[0]?.incarnation === incarnation)
|
|
124
|
+
await this.hooks.birth.record(statementsOn(conn), { rootSessionId: sessionId, kind });
|
|
125
|
+
await conn.commit();
|
|
126
|
+
}
|
|
127
|
+
catch (err) {
|
|
128
|
+
await conn.rollback().catch(() => undefined);
|
|
129
|
+
throw err;
|
|
130
|
+
}
|
|
131
|
+
finally {
|
|
132
|
+
conn.release();
|
|
133
|
+
}
|
|
115
134
|
return { minted: { sessionId, owner, incarnation } };
|
|
116
135
|
}
|
|
117
136
|
async deleteSessionIf(sessionId, cond) {
|
|
@@ -137,9 +156,12 @@ export class TiDBSessionStore {
|
|
|
137
156
|
await this.insertMeta(sessionId, placement === undefined ? null : placedSessionOwnerOf(sessionId, placement), placement);
|
|
138
157
|
}
|
|
139
158
|
async insertMeta(sessionId, owner, placement, incarnation = mintSessionIncarnation()) {
|
|
159
|
+
await this.insertMetaOn(this.pool, sessionId, owner, placement, incarnation);
|
|
160
|
+
}
|
|
161
|
+
async insertMetaOn(on, sessionId, owner, placement, incarnation) {
|
|
140
162
|
const now = new Date();
|
|
141
163
|
const placed = placementInsertCells(placement, now);
|
|
142
|
-
await
|
|
164
|
+
await on.query(`INSERT INTO session_meta (session_id, owner, created_at, updated_at, leaf_id, leaf_seq, incarnation, ${placed.columns}) ` +
|
|
143
165
|
"VALUES (?,?,?,?,NULL,0,?,?,?,?,?,?,?) ON DUPLICATE KEY UPDATE leaf_seq = leaf_seq", [sessionId, owner, now, now, incarnation, ...placed.values]);
|
|
144
166
|
}
|
|
145
167
|
async placementOf(sessionId) {
|
|
@@ -202,7 +224,7 @@ export class TiDBSessionStore {
|
|
|
202
224
|
}
|
|
203
225
|
throw err instanceof SessionError
|
|
204
226
|
? err
|
|
205
|
-
: new SessionError("storage", `placed session ${sessionId} could not be deleted
|
|
227
|
+
: new SessionError("storage", `placed session ${sessionId} could not be deleted`, err instanceof Error ? err : undefined);
|
|
206
228
|
}
|
|
207
229
|
finally {
|
|
208
230
|
conn.release();
|
|
@@ -298,11 +320,13 @@ export class TiDBSessionStore {
|
|
|
298
320
|
if (!metaRows[0])
|
|
299
321
|
return null;
|
|
300
322
|
const pool = this.pool;
|
|
301
|
-
const batchSize = opts
|
|
323
|
+
const batchSize = opts.batchSize ?? 500;
|
|
302
324
|
async function* gen() {
|
|
303
|
-
let cursor = opts
|
|
325
|
+
let cursor = opts.afterSeq ?? -1;
|
|
304
326
|
for (;;) {
|
|
305
327
|
const [rows] = await pool.query(`SELECT seq, ${jsonColumnText("mysql", "payload")} FROM session_event WHERE session_id = ? AND seq > ? ORDER BY seq ASC LIMIT ?`, [sessionId, cursor, batchSize]);
|
|
328
|
+
if (rows.length > 0)
|
|
329
|
+
await opts.recheck();
|
|
306
330
|
for (const r of rows)
|
|
307
331
|
yield decodeSessionEventPayload(r.payload, sessionId, r.seq);
|
|
308
332
|
if (rows.length < batchSize)
|
|
@@ -426,7 +450,7 @@ export class TiDBSessionStore {
|
|
|
426
450
|
this.pending.clear();
|
|
427
451
|
}
|
|
428
452
|
}
|
|
429
|
-
class TiDBStagingHandle {
|
|
453
|
+
export class TiDBStagingHandle {
|
|
430
454
|
pool;
|
|
431
455
|
hooks;
|
|
432
456
|
realSessionId;
|
|
@@ -466,11 +490,11 @@ class TiDBStagingHandle {
|
|
|
466
490
|
await conn.beginTransaction();
|
|
467
491
|
const now = new Date();
|
|
468
492
|
const minted = mintSessionIncarnation();
|
|
469
|
-
if (opts.
|
|
470
|
-
const [cas] = await conn.query("UPDATE session_meta SET leaf_seq = leaf_seq + 1 WHERE session_id = ? AND owner <=> ?", [this.realSessionId, opts.
|
|
493
|
+
if (opts.expectedOccupant !== undefined) {
|
|
494
|
+
const [cas] = await conn.query("UPDATE session_meta SET leaf_seq = leaf_seq + 1 WHERE session_id = ? AND owner <=> ? AND incarnation = ?", [this.realSessionId, opts.expectedOccupant.owner, opts.expectedOccupant.incarnation]);
|
|
471
495
|
if (cas.affectedRows !== 1) {
|
|
472
496
|
await conn.rollback();
|
|
473
|
-
throw new
|
|
497
|
+
throw new StagedCommitOccupantChangedError(this.realSessionId);
|
|
474
498
|
}
|
|
475
499
|
}
|
|
476
500
|
else {
|
|
@@ -478,7 +502,7 @@ class TiDBStagingHandle {
|
|
|
478
502
|
const [claimed] = await conn.query("SELECT incarnation FROM session_meta WHERE session_id = ? FOR UPDATE", [this.realSessionId]);
|
|
479
503
|
if (String(claimed[0]?.incarnation) !== minted) {
|
|
480
504
|
await conn.rollback();
|
|
481
|
-
throw new
|
|
505
|
+
throw new StagedCommitOccupantChangedError(this.realSessionId);
|
|
482
506
|
}
|
|
483
507
|
}
|
|
484
508
|
settleHookVerdict(await this.hooks.beforeCommit(statementsOn(conn), { op: "import", rootSessionId: this.realSessionId }));
|
|
@@ -490,7 +514,7 @@ class TiDBStagingHandle {
|
|
|
490
514
|
throw new SessionError("placement_refused", `session ${this.realSessionId} belongs to the ${String(dstMeta[0].placement_kind)} placement partition — a session-sync staged commit cannot overwrite a delegation transcript`);
|
|
491
515
|
}
|
|
492
516
|
const srcIds = stagedRows.map((r) => String(r.entry_id));
|
|
493
|
-
const dstIds = opts.
|
|
517
|
+
const dstIds = opts.expectedOccupant !== undefined ? dstRows.map((r) => String(r.entry_id)) : null;
|
|
494
518
|
const rel = classifySyncRelationshipByIds(srcIds, dstIds);
|
|
495
519
|
if ((rel.relation === "fork" || rel.relation === "stale") && opts.resolution !== "overwrite-dst") {
|
|
496
520
|
await conn.rollback();
|
|
@@ -2,6 +2,7 @@ import type { DeploymentShapeInput } from "./deployment-shape.js";
|
|
|
2
2
|
import type { RunAcceptance } from "./run-acceptance.js";
|
|
3
3
|
import type { SessionWithdrawFace } from "./plugins/session-birth.js";
|
|
4
4
|
import type { SessionBirth, StoreKeptWord } from "./session-incarnation.js";
|
|
5
|
+
import type { BindingReceiptSink } from "./session-bindings.js";
|
|
5
6
|
/** 收场词(闭集;加词 ⇒ {@link SubmissionSeat.close} 的穷尽 switch 编译红)。 */
|
|
6
7
|
export type SubmissionEnd = "accepted" | "record" | "refused";
|
|
7
8
|
/** 「留」的词:店内七词 + 座内四词(`withdraw_failed` = 撤回事务抛了,按留答)。 */
|
|
@@ -25,7 +26,7 @@ export interface SubmissionSeatDeps {
|
|
|
25
26
|
};
|
|
26
27
|
}
|
|
27
28
|
/** 一次提交的出口座(提交门在授权之前铸;三条提交腿只喂它、收它)。 */
|
|
28
|
-
export interface SubmissionSeat {
|
|
29
|
+
export interface SubmissionSeat extends BindingReceiptSink {
|
|
29
30
|
/** 授权器登记新行时交来的候选与店的撤回面(只有新行臂调;调多次以第一次为准)。 */
|
|
30
31
|
noteBirth(birth: SessionBirth, face: SessionWithdrawFace): void;
|
|
31
32
|
/** 提交门铸好 spec 之后挂上受理座(闩的唯一读者在 {@link close})。 */
|
|
@@ -36,7 +37,7 @@ export interface SubmissionSeat {
|
|
|
36
37
|
markRecord(): void;
|
|
37
38
|
/** 执行环境为这次提交留下了按会话键的持久物。 */
|
|
38
39
|
noteEnvWitness(): void;
|
|
39
|
-
/**
|
|
40
|
+
/** 此刻判不判得出「什么都不撤」而不必收场(闩上 / record / 没有候选也没有回执 / 有见证也没有回执)。 */
|
|
40
41
|
readonly keepsWithoutWithdraw: boolean;
|
|
41
42
|
/** 收场(幂等、先到者定;不抛)。 */
|
|
42
43
|
close(): Promise<SubmissionVerdict>;
|
package/dist/submission-exit.js
CHANGED
|
@@ -4,6 +4,7 @@ import { retireSessionId } from "./deleted-session-ids.js";
|
|
|
4
4
|
import { seatText } from "./trace/exit-seat.js";
|
|
5
5
|
export function createSubmissionSeat(deps) {
|
|
6
6
|
let birth;
|
|
7
|
+
let bindings;
|
|
7
8
|
let acceptance;
|
|
8
9
|
let ownTaskId;
|
|
9
10
|
let recorded = false;
|
|
@@ -16,12 +17,15 @@ export function createSubmissionSeat(deps) {
|
|
|
16
17
|
let verdict;
|
|
17
18
|
switch (end) {
|
|
18
19
|
case "accepted":
|
|
20
|
+
bindings?.face.settleSessionBindings(bindings.receipt);
|
|
19
21
|
verdict = "kept_accepted";
|
|
20
22
|
break;
|
|
21
23
|
case "record":
|
|
24
|
+
bindings?.face.settleSessionBindings(bindings.receipt);
|
|
22
25
|
verdict = "kept_record";
|
|
23
26
|
break;
|
|
24
27
|
case "refused":
|
|
28
|
+
bindings?.face.withdrawSessionBindings(bindings.receipt);
|
|
25
29
|
verdict = await withdrawOrKeep();
|
|
26
30
|
break;
|
|
27
31
|
default: {
|
|
@@ -60,6 +64,10 @@ export function createSubmissionSeat(deps) {
|
|
|
60
64
|
if (birth === undefined)
|
|
61
65
|
birth = { birth: b, face };
|
|
62
66
|
},
|
|
67
|
+
noteBindings(receipt, face) {
|
|
68
|
+
if (bindings === undefined)
|
|
69
|
+
bindings = { receipt, face };
|
|
70
|
+
},
|
|
63
71
|
attachAcceptance(a) {
|
|
64
72
|
acceptance = a;
|
|
65
73
|
},
|
|
@@ -77,7 +85,7 @@ export function createSubmissionSeat(deps) {
|
|
|
77
85
|
witnessed = true;
|
|
78
86
|
},
|
|
79
87
|
get keepsWithoutWithdraw() {
|
|
80
|
-
return birth === undefined || witnessed
|
|
88
|
+
return endNow() !== "refused" || (bindings === undefined && (birth === undefined || witnessed));
|
|
81
89
|
},
|
|
82
90
|
close() {
|
|
83
91
|
if (closing === undefined) {
|
package/dist/task-cwd.d.ts
CHANGED
|
@@ -6,9 +6,10 @@ import type { RunInternals } from "@sema-agent/core";
|
|
|
6
6
|
* 统一剥掉(根 `/` 除外),让同一目标只有一个 key —— 前缀判域(见 {@link dirCoversPath})靠的就是
|
|
7
7
|
* key 的唯一性。
|
|
8
8
|
*
|
|
9
|
-
* 🔴 **单点**([ref] 起)
|
|
10
|
-
*
|
|
11
|
-
*
|
|
9
|
+
* 🔴 **单点**([ref] 起):写门豁免域与任务根的判域读的是同一条律 —— 两份各自归一就是两个 key
|
|
10
|
+
* 空间,而「豁免域盖没盖住任务根」这种判断在两个 key 空间里可以同时答是和否。它只答**配置座**上的判域
|
|
11
|
+
* (env-facts 的 cwd / scratchpad 事实、{@link dirCoversPath});执行环境方法读路径不经它 —— 那一面是执行缝路径律
|
|
12
|
+
* (`plugins/exec-path-law.ts`,只锚不折,沙箱写门代理的 `absolutePath` 也读那一只)。
|
|
12
13
|
* (core 内部有同形的 `normalizeAbsPathLexically`,但未从包根导出;此处是 Node 标准库的等价运算,
|
|
13
14
|
* 不是它的抄本——若日后 core 导出,这里应改为直接复用。)
|
|
14
15
|
*/
|
|
@@ -114,8 +115,8 @@ export declare function effectiveHostWorkspace(sessionCwd: string | undefined, c
|
|
|
114
115
|
* 为什么组合腿要它:梯子的每一级是在引擎**现铸的会话**里冷跑(core `runCascade` 剥掉 spec 的 `sessionId`),验证门的验证器腿的 spec 不带会话 ——
|
|
115
116
|
* 工厂按腿的会话查登记表(第 1 臂)查不到提交登记在根会话上的那一枚,不交就落第 3 臂(临时目录):用户让梯子在项目里改文件,改到了别处;验证器验的是一只空目录。
|
|
116
117
|
* 跑在根会话上的腿(验证门的实现腿 / 修复腿)第 1 臂先命中,同一个值。
|
|
117
|
-
* 没登记(
|
|
118
|
-
* 登记粘在会话上(`
|
|
118
|
+
* 没登记(这条腿的会话绑定没有工作目录:非 host / device 车道、多租户、根会话的提交从没带过 `cwd`、嵌入方装配器没铸事实)⇒ 空对象 —— 每一条腿照旧落临时目录、收场由托管表删。
|
|
119
|
+
* 登记粘在会话上(会话绑定的 `cwd` 一格 = 这条腿跑在的那一枚 —— 请求带的 ?? 项目继承来的 ?? 会话上已登记的 —— 受理之后写回会话,`session-bindings.ts`):同一会话之前带过、这次不带 ⇒ 交的仍是那一枚 —— 与第 1 臂对同一会话上普通 run 的读法一致。
|
|
119
120
|
*/
|
|
120
121
|
export declare function compositionLegRoot(registeredCwd: string | undefined): Pick<RunInternals, "parentCwd">;
|
|
121
122
|
/** {@link launchWorkspaceOf} 读到的那一格出自哪里(闭集;起服那一行日志与随包文档的 `workspaceFrom` 词)。 */
|
package/dist/task-settings.d.ts
CHANGED
|
@@ -122,11 +122,12 @@ export declare function planReviewDecisionExitsPlan(decision: "approve" | "edit"
|
|
|
122
122
|
* 新体 `{ ...body, permissionMode: entry.effective }`,调用方的对象不改;bundle 的 `settings.permissions.defaultMode` 不动 —— 顶层赢过它
|
|
123
123
|
* ({@link effectivePermissionMode} 的优先序),再改它就是同一语义的第二个写者。披露这一折的通告(`entry-mode-clamp-notice.ts`)读的也是同一份 `entry`。
|
|
124
124
|
*
|
|
125
|
-
*
|
|
126
|
-
* `buildCheckpointCtx` 持久化的体
|
|
127
|
-
*
|
|
128
|
-
* (`http/
|
|
129
|
-
*
|
|
125
|
+
* 调用点两个,都是受理判官的入口一步(`permission-mode-admission.ts`,同一只 `bodyEntry`):提交口 `stampSubmissionEntryMode`(`http/admission.ts` 的 `prepareSpec` 调它:
|
|
126
|
+
* 值形门全部判完之后、`resolveSpec` 之前 —— 那一份体就是首跑装配读的体,也是 `buildCheckpointCtx` 持久化的体)与续跑口 `stampReplayEntryMode`(`http/resume-legs.ts`
|
|
127
|
+
* 的 `replayCtxOf`:停驻 run 的存储体被重放之前过一次**现**地板,地板的出口词原样;钳过的体随 CAS 赢点写回)。装配腿不读地板;每一腿读一次地板、写进体,
|
|
128
|
+
* run 的模式词仍只有存储体一个源。另外两个写者是 `plan_review` 写回(`http/resume-legs.ts` `drivePlanReview`,判据 {@link planReviewDecisionExitsPlan};
|
|
129
|
+
* 写下的是 plan 地板的出口词)与在飞 run 的切档口写回(`http/routes/run-permission-mode.ts`,写的是同一只判官准入的词)。
|
|
130
|
+
* 热改 `AUTONOMY` 对之后的提交、切档与停驻 run 的下一次续跑都生效。地板的属主是 `runtime-governance.ts` 的 `autonomyModeFloor`。
|
|
130
131
|
*/
|
|
131
132
|
export declare function stampEntryPermissionMode<B extends {
|
|
132
133
|
permissionMode?: unknown;
|
|
@@ -463,6 +464,19 @@ export declare function taskHooksHonored(config: {
|
|
|
463
464
|
* 在 `server.ts` prepareSpec 里 400 响亮拒 + 逐字列名。双层姿势与 outputStyle / permissionMode 两处逐字相同。
|
|
464
465
|
*/
|
|
465
466
|
export declare function parseTaskSettings(raw: unknown, seats?: ParseTaskSettingsSeats): ParseTaskSettingsResult;
|
|
467
|
+
/** The one reading of `settings.outputStyle`: a non-empty string within {@link MAX_SETTINGS_OUTPUT_STYLE_CHARS} ⇒ it; anything else ⇒ absent.
|
|
468
|
+
* Readers: the settings parser above and the system-prompt fold judgment at the head of `resolveSpec` (which runs before the parser's stage). */
|
|
469
|
+
export declare function acceptOutputStyle(v: unknown): string | undefined;
|
|
470
|
+
/**
|
|
471
|
+
* **系统提示追加折叠的唯一读法**(一个 spec 字段 `TaskSpec.appendSystemPrompt` 里折进几段):段按序、缺席 / 空段不出、`\n\n` 连接;`chars` = 折出来的字符数(含连接符)。
|
|
472
|
+
* 段序恒为 请求 `appendSystemPrompt` → 项目简报(`project-context.ts`)→ `settings.outputStyle`(字节稳定,前缀缓存靠它);三段共一只上限 16384。
|
|
473
|
+
* 读者四位,同读这一只:受理口的两段合计判(`http/admission.ts`)、装配器头部的三段判(`boot/resolve-spec.ts`,只在简报在场时)、装配合成(本文件 `applyTaskSettings` 接 style)、
|
|
474
|
+
* 续跑镜像(`resolve-spec.ts` 阶段⑤:存量体合计超帽 ⇒ 丢 style + warn)。
|
|
475
|
+
*/
|
|
476
|
+
export declare function appendFold(segments: readonly (string | undefined)[]): {
|
|
477
|
+
readonly text: string | undefined;
|
|
478
|
+
readonly chars: number;
|
|
479
|
+
};
|
|
466
480
|
/** Defensive acceptance of the `appendSystemPrompt` rider ([ref] R2 + codex F2): the HTTP 400 gate (prepareSpec,
|
|
467
481
|
* MAX_SYSTEM_PROMPT_CHARS) only covers FRESH submits — every resume family re-enters resolveSpec on a STORED body,
|
|
468
482
|
* and a pre-1.243 store preserved unknown request keys verbatim (the field was INERT then), so an over-cap legacy
|
package/dist/task-settings.js
CHANGED
|
@@ -360,9 +360,9 @@ export function parseTaskSettings(raw, seats = {}) {
|
|
|
360
360
|
}
|
|
361
361
|
if (typeof s.model === "string" && s.model.length > 0)
|
|
362
362
|
out.model = s.model;
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
363
|
+
const outputStyle = acceptOutputStyle(s.outputStyle);
|
|
364
|
+
if (outputStyle !== undefined)
|
|
365
|
+
out.outputStyle = outputStyle;
|
|
366
366
|
if (shellEnv)
|
|
367
367
|
out.shellEnv = shellEnv;
|
|
368
368
|
if (s.ultracode === true)
|
|
@@ -388,6 +388,14 @@ export function parseTaskSettings(raw, seats = {}) {
|
|
|
388
388
|
out.httpHookAllowlist = httpHookAllowlist;
|
|
389
389
|
return { settings: Object.keys(out).length > 0 ? out : undefined, deferred, ...(hooksReread !== undefined ? { hooksReread } : {}) };
|
|
390
390
|
}
|
|
391
|
+
export function acceptOutputStyle(v) {
|
|
392
|
+
return typeof v === "string" && v.length > 0 && v.length <= MAX_SETTINGS_OUTPUT_STYLE_CHARS ? v : undefined;
|
|
393
|
+
}
|
|
394
|
+
export function appendFold(segments) {
|
|
395
|
+
const present = segments.filter((segment) => segment !== undefined && segment.length > 0);
|
|
396
|
+
const text = present.length > 0 ? present.join("\n\n") : undefined;
|
|
397
|
+
return { text, chars: text?.length ?? 0 };
|
|
398
|
+
}
|
|
391
399
|
export function acceptAppendSystemPrompt(v, warn) {
|
|
392
400
|
if (v === undefined)
|
|
393
401
|
return undefined;
|
|
@@ -593,10 +601,8 @@ export function applyTaskSettings(base, settings, bases) {
|
|
|
593
601
|
const allow = settings.permissions?.allow;
|
|
594
602
|
if (allow !== undefined)
|
|
595
603
|
next = { ...next, allowedTools: allow.map((entry) => allowMemberOf(entry, bases?.configRoot)) };
|
|
596
|
-
if (settings.outputStyle)
|
|
597
|
-
|
|
598
|
-
next = { ...next, appendSystemPrompt: appended };
|
|
599
|
-
}
|
|
604
|
+
if (settings.outputStyle)
|
|
605
|
+
next = { ...next, appendSystemPrompt: appendFold([next.appendSystemPrompt, settings.outputStyle]).text };
|
|
600
606
|
return next;
|
|
601
607
|
}
|
|
602
608
|
//# sourceMappingURL=task-settings.js.map
|
package/dist/terminal.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { terminalProjection, type PausedCause, type TaskStatus, type TerminalCause } from "@sema-agent/core";
|
|
2
|
+
import { StoreBoundaryFault, type StoreFaultClass } from "./plugins/store-fault.js";
|
|
2
3
|
/**
|
|
3
4
|
* 这次失败带的**机器码**(`terminal.failed.code`);非失败终局 ⇒ `undefined`。
|
|
4
5
|
*
|
|
@@ -129,9 +130,12 @@ export declare function mapPauseSeats<T>(result: T, f: (seat: SeatObject, keys:
|
|
|
129
130
|
*
|
|
130
131
|
* ── 折码的运维线索:一句定形字段,两只入口各说一只词 ──
|
|
131
132
|
* 字段 `original=<码 | <not-a-code>> outward=<对外词> messageBytes=<n> at=<观看点>`,只有闭集词、数字与码({@link isCodeToken});码形座里装着文字的、长得像码的秘密同理只报 `<not-a-code>`。
|
|
132
|
-
*
|
|
133
|
-
*
|
|
133
|
+
* 失败句**不上 wire**({@link outwardStoreFailure});店起源的失败到这里时句子已是店边界换过的对外句({@link storeBoundaryFault}:库驱动原句 —— 自由文本,可以有连接串 / 口令 / 库账号 / 表名 ——
|
|
134
|
+
* 只进店边界那一行 `at=store`),写入口那一行的末尾格 `message=<JSON 串>` 对它们带的就是对外句;不经店边界的抛出物(fs / 网络 / 第三方码)带的仍是它自己的句子 ——
|
|
135
|
+
* 都经出口座的一句话行(`operator-log-text`:凭据形换记号、剥控制字符、有界),读座的再观看不带(同一行存量行每读一次就重放一次)。`at` 说这是哪一次观看,**一个入口一只词**(类型给定,不靠记得传):
|
|
134
136
|
* · 本函数 = 结果**第一次**离开引擎(店的写口 / 出口铸体)⇒ `at=exit`,每折一次一行 `[terminal] outward_failure_code_folded <字段>[ message=<句>]` —— 每次都是一件新的失败;
|
|
137
|
+
* · {@link storeBoundaryFault} = 失败**离开本服务的店**(SQL 店的出口)⇒ `at=store`,每次一行,多两格 `site=<店>.<方法> class=<判官词>`,`message=` 是原错与其 `cause` 链各层的句子(逐层过座);
|
|
138
|
+
* 查库的原话读这一行,按 `original=` 与时间对 `at=exit` / `request_error` 行;
|
|
135
139
|
* · {@link sealStoredResult} = 存量行的**再观看**(读座必填)⇒ 走 fail-open 纪律(登记 tag `server.terminal.stored-result-code-folded`):
|
|
136
140
|
* 逐读计数 + 逐读探针行 + 每进程一次 warn,detail 即上面那句字段。读面每次轮询 / 每个观看者 / 每次重连都重放同一批行 ——
|
|
137
141
|
* 计数让「旧失败被读了多少次」看得见,一次 warn 让日志不随读次放大;去重归记录器一只,不另造表。
|
|
@@ -148,12 +152,39 @@ export declare function sealResultForExit<T extends {
|
|
|
148
152
|
export declare function sealStoredResult<T extends {
|
|
149
153
|
readonly terminal?: unknown;
|
|
150
154
|
}>(result: T, seat: StoredResultReadSeat): T;
|
|
155
|
+
/**
|
|
156
|
+
* 一个折掉的码在出口上的对外句(纯函数、无副作用)—— 出口四入口的**唯一**读法:{@link outwardStoreFailure}(封口 / 抛出臂,带运维线索)、{@link outwardPlane}
|
|
157
|
+
* (投影出口,纯读、不出线索)与 {@link persistedPlaneOf} 的旧形臂。句子已是「某个类别句 + 本码尾注」⇒ 原样(店边界换过的句子,词在原错上判,见 {@link storeBoundaryFault});
|
|
158
|
+
* 否则 = 判官读 `{ code }` 的类别句 + 尾注(拼法 `outwardStoreSentence`,一只拼法两种输入)。任何一张脸上折过码的 `errorMessage` 都不可能是驱动的原句,不论这条因由封过口没有、存的是哪一代形。
|
|
159
|
+
* 店边界之前落盘的存量子代句的一次性改写(M53,`store-fault-sentence-m53.ts`)读同一只。
|
|
160
|
+
*/
|
|
161
|
+
export declare function outwardStoreMessageOf(code: string, message: unknown): string;
|
|
151
162
|
/**
|
|
152
163
|
* 腿**抛出**的错落进 run 行 `error` 列时的对外句(没有终局结果、没有因由的那一臂:`runs.ts` 后台腿的兜底腿与它的孪生 `resume-legs.ts` 兜底腿)—— 与终局因由是**同一只**
|
|
153
164
|
* 铸点({@link outwardStoreFailure}):抛出物自带的 `code`({@link errorCodeOf},字符串)出了本仓词法 ⇒ 同码同句;没有码 / 码在词法内(本仓与引擎自己的错、普通 `Error`)⇒ 文本逐字,非库错误照旧。
|
|
154
165
|
* `message` 是调用方已取出的抛出文本({@link errorText} 的产物,不抛);本函数不抛(读码口不抛)。
|
|
155
166
|
*/
|
|
156
167
|
export declare function outwardThrownMessage(err: unknown, message: string): string;
|
|
168
|
+
/**
|
|
169
|
+
* 🔴 **店边界 —— 驱动原句越出 SQL 店的唯一读者**。律:一只 SQL 店的任何出口(抛出值、包装错误的 `cause`、抛出或返回值里的失败文本、交给调用方的可调用对象)
|
|
170
|
+
* 只带「原码 + 稳定句」({@link StoreBoundaryFault});驱动的原句在这里记一次运维日志,不随错误走。店的出口在 `plugins/store-boundary.ts` 封口(逐生产者、编译期穷尽的出口表),
|
|
171
|
+
* 店里自己拼句 / 拼值 / 包 `cause` 的地方先读本函数、再用它交回的形。交回:
|
|
172
|
+
* · 已是边界形 ⇒ 同一引用(嵌套店:最里层出口换过、记过,外层同一引用放行、不再记);
|
|
173
|
+
* · typed 失败(顶层自带词法内的码:`SessionError("storage")`、`store.row_too_large` …)⇒ 同一引用,它的类、码与句子原样;它 `cause` 链上的驱动错**就地**换成边界形
|
|
174
|
+
* (typed 层往下走,第一只不是 typed 而带驱动证据的那一段整只换;那一段的原句照样记一行 `at=store`);
|
|
175
|
+
* · 调用方出身(`error-origin.ts` 的 `caller`:店把调用方钩子的抛出物原样还给调用方)⇒ 同一引用、不记 —— 它不是店的失败;
|
|
176
|
+
* · 不触发扳机 ⇒ 同一引用(不带码 / 码在词法内、不带驱动出身记号的错照旧);
|
|
177
|
+
* · 触发 ⇒ 一行运维日志(`at=store site=<店>.<方法> class=<判官词>`,`message=` 是原错与其 `cause` 链各层的句子,逐层过出口座)+ 计数,交回新铸的边界形。
|
|
178
|
+
* 扳机两条(任一):① **码出词法**:码在场且 {@link outwardFailureCode} 折它 —— fail-closed,词法外的码一律换句(驱动、套接字、对象存储、fs 都算);
|
|
179
|
+
* ② **驱动出身**:原错或其 `cause` 链上任一层带池座打的记号(`plugins/error-origin.ts` 的 `driver`)—— 补词法看不见的无码驱动错。
|
|
180
|
+
* 链读法一律深 ≤ {@link CAUSE_CHAIN_DEPTH};链比这更深 ⇒ 当作带驱动证据(fail-closed:看不到底的链不放行)。
|
|
181
|
+
* 码的读法({@link driverCodeOf}):沿 `cause` 链(深 ≤ 8)取第一个非空串 `code`,`"unknown"` 只作兜底(与 core 的码链读法同读);一条串码都没有、而某一层带整数 `errno`
|
|
182
|
+
* ⇒ 码 = 那个 `errno` 的十进制串 —— 这是本仓的规则(引擎不读 errno):只带 errno 的驱动错(TiDB 自有号,mysql2 的码表里没有符号)于是进同一只扳机、说同一句,出口照折。
|
|
183
|
+
* 判官(`storeFaultClassOf`)在**原错**上判一次(连接类整句、errno 臂、1005 内层号都只在原错上读得到),词随形带走。不抛。
|
|
184
|
+
* `site` = 封口调用点的字面店词 + 方法名(源码里的标识符,不是外部输入)。
|
|
185
|
+
*/
|
|
186
|
+
export declare function storeBoundaryFault<E>(err: E, site: string): E | StoreBoundaryFault;
|
|
187
|
+
export declare function setStoreBoundaryObserver(fn: ((site: string, faultClass: StoreFaultClass) => void) | undefined): void;
|
|
157
188
|
/**
|
|
158
189
|
* **投影出口的唯一属主**([ref])—— core 的 `terminalProjection` + 对外码归一,一次。
|
|
159
190
|
*
|
package/dist/terminal.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { writeLogText } from "./observability/logger.js";
|
|
2
2
|
import { terminalProjection } from "@sema-agent/core";
|
|
3
|
-
import { errorCodeOf } from "./observability/err-text.js";
|
|
3
|
+
import { errorCodeOf, errorMemberOf } from "./observability/err-text.js";
|
|
4
4
|
import { recordFailOpen } from "./observability/fail-open.js";
|
|
5
5
|
import { redactSecrets } from "./trace/redact.js";
|
|
6
6
|
import { seatText } from "./trace/exit-seat.js";
|
|
7
|
-
import {
|
|
7
|
+
import { STORE_FAULT_CLASSES, StoreBoundaryFault, outwardStoreSentence, storeFaultClassOf } from "./plugins/store-fault.js";
|
|
8
|
+
import { errorOriginOf } from "./plugins/error-origin.js";
|
|
8
9
|
import { readDenyFloorRefusalMessage, readDenyFloorSummaryOf } from "./read-deny-floor-notice.js";
|
|
9
10
|
export function failureCodeOf(terminal) {
|
|
10
11
|
return terminal.kind === "failed" ? terminal.code : undefined;
|
|
@@ -93,10 +94,13 @@ function foldCauseCode(terminal, at) {
|
|
|
93
94
|
function outwardStoreFailure(code, message, at) {
|
|
94
95
|
const outward = outwardFailureCode(code);
|
|
95
96
|
reportFold(code, outward, message, at);
|
|
96
|
-
return { code: outward, message:
|
|
97
|
+
return { code: outward, message: outwardStoreMessageOf(code, message) };
|
|
97
98
|
}
|
|
98
|
-
function
|
|
99
|
-
return
|
|
99
|
+
export function outwardStoreMessageOf(code, message) {
|
|
100
|
+
return isOutwardStoreSentence(message, code) ? message : outwardStoreSentence(storeFaultClassOf({ code }), code);
|
|
101
|
+
}
|
|
102
|
+
function isOutwardStoreSentence(message, code) {
|
|
103
|
+
return typeof message === "string" && STORE_FAULT_CLASSES.some((cls) => message === outwardStoreSentence(cls, code));
|
|
100
104
|
}
|
|
101
105
|
export function outwardThrownMessage(err, message) {
|
|
102
106
|
const code = errorCodeOf(err);
|
|
@@ -104,6 +108,123 @@ export function outwardThrownMessage(err, message) {
|
|
|
104
108
|
return message;
|
|
105
109
|
return outwardStoreFailure(code, message, "exit").message;
|
|
106
110
|
}
|
|
111
|
+
export function storeBoundaryFault(err, site) {
|
|
112
|
+
if (err instanceof StoreBoundaryFault)
|
|
113
|
+
return err;
|
|
114
|
+
const origin = errorOriginOf(err);
|
|
115
|
+
switch (origin) {
|
|
116
|
+
case "caller":
|
|
117
|
+
return err;
|
|
118
|
+
case "driver":
|
|
119
|
+
case undefined:
|
|
120
|
+
break;
|
|
121
|
+
default: {
|
|
122
|
+
const unhandled = origin;
|
|
123
|
+
throw new Error(`store boundary: unknown error origin ${String(unhandled)}`);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
if (isTypedFailure(err))
|
|
127
|
+
return rewriteDriverCause(err, site) ? err : reportedBoundaryForm(err, site);
|
|
128
|
+
if (!carriesDriverFault(err))
|
|
129
|
+
return err;
|
|
130
|
+
return reportedBoundaryForm(err, site);
|
|
131
|
+
}
|
|
132
|
+
const CAUSE_CHAIN_DEPTH = 8;
|
|
133
|
+
function boundaryFormOf(err) {
|
|
134
|
+
const coded = driverCodeOf(err);
|
|
135
|
+
return new StoreBoundaryFault(storeFaultClassOf(err), coded.code, coded.errno);
|
|
136
|
+
}
|
|
137
|
+
function reportBoundary(err, fault, site) {
|
|
138
|
+
reportFold(fault.code, fault.code === undefined ? "-" : outwardFailureCode(fault.code), errorMemberOf(err, "message"), { at: "store", site, faultClass: fault.faultClass, layers: chainSentences(err) });
|
|
139
|
+
}
|
|
140
|
+
function reportedBoundaryForm(err, site) {
|
|
141
|
+
const fault = boundaryFormOf(err);
|
|
142
|
+
reportBoundary(err, fault, site);
|
|
143
|
+
return fault;
|
|
144
|
+
}
|
|
145
|
+
function isTypedFailure(err) {
|
|
146
|
+
const code = errorMemberOf(err, "code");
|
|
147
|
+
return typeof code === "string" && code !== "" && outwardFailureCode(code) === code && errorOriginOf(err) !== "driver";
|
|
148
|
+
}
|
|
149
|
+
function carriesDriverFault(err) {
|
|
150
|
+
const coded = driverCodeOf(err);
|
|
151
|
+
return (coded.code !== undefined && outwardFailureCode(coded.code) !== coded.code) || driverOriginOnChain(err) || causeChainBeyondDepth(err);
|
|
152
|
+
}
|
|
153
|
+
function causeChainBeyondDepth(err) {
|
|
154
|
+
let cur = err;
|
|
155
|
+
for (let depth = 0; depth < CAUSE_CHAIN_DEPTH; depth++) {
|
|
156
|
+
if (cur === null || typeof cur !== "object")
|
|
157
|
+
return false;
|
|
158
|
+
cur = errorMemberOf(cur, "cause");
|
|
159
|
+
}
|
|
160
|
+
return cur !== null && typeof cur === "object";
|
|
161
|
+
}
|
|
162
|
+
function rewriteDriverCause(top, site) {
|
|
163
|
+
let parent = top;
|
|
164
|
+
for (let depth = 0; depth < CAUSE_CHAIN_DEPTH; depth++) {
|
|
165
|
+
const cur = errorMemberOf(parent, "cause");
|
|
166
|
+
if (cur === null || typeof cur !== "object" || cur instanceof StoreBoundaryFault || errorOriginOf(cur) === "caller")
|
|
167
|
+
return true;
|
|
168
|
+
if (isTypedFailure(cur)) {
|
|
169
|
+
parent = cur;
|
|
170
|
+
continue;
|
|
171
|
+
}
|
|
172
|
+
if (!carriesDriverFault(cur))
|
|
173
|
+
return true;
|
|
174
|
+
const fault = boundaryFormOf(cur);
|
|
175
|
+
if (!Reflect.defineProperty(parent, "cause", { value: fault, writable: true, configurable: true, enumerable: false }))
|
|
176
|
+
return false;
|
|
177
|
+
reportBoundary(cur, fault, site);
|
|
178
|
+
return true;
|
|
179
|
+
}
|
|
180
|
+
return false;
|
|
181
|
+
}
|
|
182
|
+
let storeBoundaryObserver;
|
|
183
|
+
export function setStoreBoundaryObserver(fn) {
|
|
184
|
+
storeBoundaryObserver = fn;
|
|
185
|
+
}
|
|
186
|
+
function driverCodeOf(err) {
|
|
187
|
+
let cur = err;
|
|
188
|
+
let fallback;
|
|
189
|
+
let errnoLink;
|
|
190
|
+
for (let depth = 0; cur !== null && typeof cur === "object" && depth < CAUSE_CHAIN_DEPTH; depth++) {
|
|
191
|
+
const code = errorMemberOf(cur, "code");
|
|
192
|
+
const errno = errorMemberOf(cur, "errno");
|
|
193
|
+
const integerErrno = typeof errno === "number" && Number.isInteger(errno) ? errno : undefined;
|
|
194
|
+
if (typeof code === "string" && code !== "") {
|
|
195
|
+
const link = { code, ...(integerErrno !== undefined ? { errno: integerErrno } : {}) };
|
|
196
|
+
if (code !== "unknown")
|
|
197
|
+
return link;
|
|
198
|
+
fallback ??= link;
|
|
199
|
+
}
|
|
200
|
+
if (integerErrno !== undefined)
|
|
201
|
+
errnoLink ??= { code: String(integerErrno), errno: integerErrno };
|
|
202
|
+
cur = errorMemberOf(cur, "cause");
|
|
203
|
+
}
|
|
204
|
+
return fallback ?? errnoLink ?? {};
|
|
205
|
+
}
|
|
206
|
+
function driverOriginOnChain(err) {
|
|
207
|
+
let cur = err;
|
|
208
|
+
for (let depth = 0; cur !== null && typeof cur === "object" && depth < CAUSE_CHAIN_DEPTH; depth++) {
|
|
209
|
+
if (errorOriginOf(cur) === "driver")
|
|
210
|
+
return true;
|
|
211
|
+
cur = errorMemberOf(cur, "cause");
|
|
212
|
+
}
|
|
213
|
+
return false;
|
|
214
|
+
}
|
|
215
|
+
function chainSentences(err) {
|
|
216
|
+
const layers = [];
|
|
217
|
+
let cur = err;
|
|
218
|
+
for (let depth = 0; cur !== null && typeof cur === "object" && depth < CAUSE_CHAIN_DEPTH; depth++) {
|
|
219
|
+
const message = errorMemberOf(cur, "message");
|
|
220
|
+
if (typeof message === "string" && message !== "")
|
|
221
|
+
layers.push(seatText("operator-log-text", message));
|
|
222
|
+
cur = errorMemberOf(cur, "cause");
|
|
223
|
+
}
|
|
224
|
+
if (layers.length === 0 && typeof err === "string" && err !== "")
|
|
225
|
+
layers.push(seatText("operator-log-text", err));
|
|
226
|
+
return layers.join(" | cause: ");
|
|
227
|
+
}
|
|
107
228
|
function foldAttemptCodes(attempts, at) {
|
|
108
229
|
if (!Array.isArray(attempts))
|
|
109
230
|
return attempts;
|
|
@@ -123,15 +244,24 @@ function foldAttemptCodes(attempts, at) {
|
|
|
123
244
|
return folded ?? attempts;
|
|
124
245
|
}
|
|
125
246
|
const STORED_RESULT_FOLD_TAG = "server.terminal.stored-result-code-folded";
|
|
126
|
-
function reportFold(code, outward, message,
|
|
247
|
+
function reportFold(code, outward, message, sighting) {
|
|
127
248
|
const messageBytes = typeof message === "string" ? Buffer.byteLength(message, "utf8") : 0;
|
|
128
|
-
const
|
|
249
|
+
const at = typeof sighting === "string" ? sighting : sighting.at;
|
|
250
|
+
const original = code === undefined ? "<uncoded>" : isCodeToken(code) ? code : "<not-a-code>";
|
|
251
|
+
const fields = `original=${original} outward=${outward} messageBytes=${messageBytes} at=${at}`;
|
|
129
252
|
switch (at) {
|
|
130
253
|
case "exit": {
|
|
131
254
|
const sentence = typeof message === "string" && message !== "" ? ` message=${JSON.stringify(seatText("operator-log-text", message))}` : "";
|
|
132
255
|
writeLogText("stderr", `[terminal] outward_failure_code_folded ${fields}${sentence}`);
|
|
133
256
|
return;
|
|
134
257
|
}
|
|
258
|
+
case "store": {
|
|
259
|
+
const where = sighting;
|
|
260
|
+
const layers = where.layers !== "" ? ` message=${JSON.stringify(where.layers)}` : "";
|
|
261
|
+
writeLogText("stderr", `[terminal] outward_failure_code_folded ${fields} site=${where.site} class=${where.faultClass}${layers}`);
|
|
262
|
+
storeBoundaryObserver?.(where.site, where.faultClass);
|
|
263
|
+
return;
|
|
264
|
+
}
|
|
135
265
|
case "run.result":
|
|
136
266
|
case "ev.done.result":
|
|
137
267
|
recordFailOpen(STORED_RESULT_FOLD_TAG, fields);
|
|
@@ -160,7 +290,7 @@ function outwardProjection(terminal, at) {
|
|
|
160
290
|
const presented = at === "exit" && plane.status === "failed" ? readDenyFloorRefusalMessage(plane.errorCode) : undefined;
|
|
161
291
|
return presented === undefined ? plane : { ...plane, errorMessage: presented };
|
|
162
292
|
}
|
|
163
|
-
return plane.status === "failed" ? { ...plane, errorCode: outward, errorMessage:
|
|
293
|
+
return plane.status === "failed" ? { ...plane, errorCode: outward, errorMessage: outwardStoreMessageOf(plane.errorCode, plane.errorMessage) } : { ...plane, errorCode: outward };
|
|
164
294
|
}
|
|
165
295
|
export function nestedPauseOf(terminal) {
|
|
166
296
|
return terminal.kind === "failed" ? terminal.nestedPause : undefined;
|
|
@@ -200,7 +330,7 @@ export function persistedPlaneOf(result) {
|
|
|
200
330
|
return {
|
|
201
331
|
...(typeof r.status === "string" ? { status: r.status } : {}),
|
|
202
332
|
...(typeof r.errorCode === "string" ? { errorCode: outwardFailureCode(r.errorCode) } : {}),
|
|
203
|
-
...(typeof r.errorMessage === "string" ? { errorMessage: flatFolded && typeof r.errorCode === "string" ?
|
|
333
|
+
...(typeof r.errorMessage === "string" ? { errorMessage: flatFolded && typeof r.errorCode === "string" ? outwardStoreMessageOf(r.errorCode, r.errorMessage) : r.errorMessage } : {}),
|
|
204
334
|
...(typeof r.blockedReason === "string" ? { blockedReason: r.blockedReason } : {}),
|
|
205
335
|
};
|
|
206
336
|
}
|