@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
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
2
|
import { randomUUID } from "node:crypto";
|
|
3
3
|
import { RemoteExecutionError } from "@sema-agent/core";
|
|
4
|
+
import { connectRefusal } from "./remote-env-connect-seat.js";
|
|
4
5
|
import { readProjectBundle } from "../project-bundle.js";
|
|
5
6
|
import { attachmentBytesOf, attachmentPlacementsOf, seedOfSession } from "./task-attachment-store.js";
|
|
6
7
|
import { shellQuote } from "./remote-shell.js";
|
|
7
8
|
const FILLED = { ok: true };
|
|
8
9
|
function refused(message, standing = false) {
|
|
9
|
-
return { ok: false, error: new RemoteExecutionError("connect_failed", message), standing };
|
|
10
|
+
return standing ? connectRefusal("workspace_fill_refused", message) : { ok: false, error: new RemoteExecutionError("connect_failed", message), standing: false };
|
|
10
11
|
}
|
|
11
12
|
function errText(e) {
|
|
12
13
|
return e instanceof Error ? e.message : String(e);
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { alignedWindow, retryAfterSecUntil } from "../observability/cost-quota.js";
|
|
2
|
+
import { sealStoreClass } from "./store-boundary.js";
|
|
2
3
|
const SEP = "\u0000";
|
|
3
4
|
export const DEFAULT_COUNTER_QUERY_TIMEOUT_MS = 30_000;
|
|
4
5
|
export class SqlWriteBehindCounter {
|
|
@@ -173,6 +174,10 @@ export class SqlWriteBehindCounter {
|
|
|
173
174
|
this.windowMs = windowMs;
|
|
174
175
|
}
|
|
175
176
|
}
|
|
177
|
+
sealStoreClass(SqlWriteBehindCounter, "sql-write-behind-counter", {
|
|
178
|
+
window: "exit", bucket: "exit", usedIn: "exit", used: "exit", addLocal: "exit", retryAfterSec: "exit", flush: "exit", refresh: "exit", reap: "exit",
|
|
179
|
+
startRefresh: "exit", stop: "exit", refreshRunning: "exit", setWindowMs: "exit",
|
|
180
|
+
});
|
|
176
181
|
export class WriteBehindCounter extends SqlWriteBehindCounter {
|
|
177
182
|
constructor(pool, t, windowMs, now, onDegraded, queryTimeoutMs) {
|
|
178
183
|
super("mysql", pool, t, windowMs, now, onDegraded, queryTimeoutMs);
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { type ProjectRegistration } from "@sema-agent/settings-schema";
|
|
2
|
+
import type { ListFilter } from "./owner-faces.js";
|
|
3
|
+
/** 进简报 / 进 `cwd` 的登记字段(闭集)。每一格的写角色不低于 `prompts` 域(`test/project-context-inheritance.test.ts` 按 settings-schema 的 `writeRoleFor` 钉);身份字段永不在表里。 */
|
|
4
|
+
export declare const PROJECT_BRIEF_FIELDS: readonly ["goal", "notes", "contextItems"];
|
|
5
|
+
/** 进简报 / 进 `cwd` 的登记字段。 */
|
|
6
|
+
export type ProjectBriefField = (typeof PROJECT_BRIEF_FIELDS)[number];
|
|
7
|
+
/** 内容证明:配置中心写口在一次按写权表判过内容字段的写之后盖的时刻(写角色同为 publisher)。本服务只读在不在。 */
|
|
8
|
+
export declare const PROJECT_CONTENT_ATTESTATION_FIELD: "contentAttestedAt";
|
|
9
|
+
/** 继承判读得到的登记成员(类型上只够得着表内字段 + 可见性的属主键 + 内容证明)。 */
|
|
10
|
+
export type ProjectContextSource = Pick<ProjectRegistration, ProjectBriefField | "registeredBy" | typeof PROJECT_CONTENT_ATTESTATION_FIELD>;
|
|
11
|
+
/** 一条 run 继承到的项目上下文(冻结记录;随 run 落进续跑重建输入,续跑腿原样重放)。 */
|
|
12
|
+
export interface ProjectContext {
|
|
13
|
+
/** 判出它的项目(登记簿键,小写)。 */
|
|
14
|
+
readonly projectId: string;
|
|
15
|
+
/** 继承的工作目录:第一条 `folder` 条目 —— 只在射程内(`callerOwnsWorkerDisk`)且请求没带 `cwd` 时在场。 */
|
|
16
|
+
readonly cwd?: string;
|
|
17
|
+
/** 项目简报(系统提示追加折叠的第二段);`projectMemory: "disabled"` 或无可列内容 ⇒ 缺席。 */
|
|
18
|
+
readonly brief?: string;
|
|
19
|
+
}
|
|
20
|
+
/** 继承判的输入(全部是新提交腿此刻读得到的事实)。 */
|
|
21
|
+
export interface ProjectContextInput {
|
|
22
|
+
/** 这条腿的项目(`legProjectIdOf`);缺席 ⇒ 不继承。 */
|
|
23
|
+
readonly projectId: string | undefined;
|
|
24
|
+
/** 本部署的登记簿(`capability-facts.ts` `projectRegistry` 的见证);缺席 = 本部署没有登记簿 ⇒ 不继承。 */
|
|
25
|
+
readonly registry: Readonly<Record<string, ProjectContextSource>> | undefined;
|
|
26
|
+
/** 提交者在读面上的视域(读面同一只推导);缺席 = 没有请求 ⇒ 不继承。 */
|
|
27
|
+
readonly viewer: ListFilter | undefined;
|
|
28
|
+
/** 部署形表行 `callerOwnsWorkerDisk`:路径条目(继承 `cwd`、简报的路径两段)只在它成立时兑现。 */
|
|
29
|
+
readonly pathsHonored: boolean;
|
|
30
|
+
/** 请求体带了 `cwd`(非空串)⇒ 显式值赢,不填。 */
|
|
31
|
+
readonly requestCwd: boolean;
|
|
32
|
+
/** 请求 `projectMemory: "disabled"` ⇒ 不出简报。 */
|
|
33
|
+
readonly projectMemoryOff: boolean;
|
|
34
|
+
}
|
|
35
|
+
/** 继承判的答案:继承到的上下文,外加射程外未列的路径条目数(server 侧 warn 只计数,不记路径)。 */
|
|
36
|
+
export interface ProjectContextDecision {
|
|
37
|
+
readonly context: ProjectContext | undefined;
|
|
38
|
+
readonly withheldPathItems: number;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* 项目简报的唯一铸点(纯串;各段缺席不出,全缺席 ⇒ 无简报)。只读 {@link PROJECT_BRIEF_FIELDS};路径两段只在 `pathsHonored` 时出,且只列名字 ——
|
|
42
|
+
* `file` 条目未附上,段名写明「相关时去读」。首行点名来源与项目 id(不带 `displayName`:身份字段不进提示)。
|
|
43
|
+
*/
|
|
44
|
+
export declare function buildProjectBrief(projectId: string, registration: Pick<ProjectRegistration, ProjectBriefField>, pathsHonored: boolean): string | undefined;
|
|
45
|
+
/**
|
|
46
|
+
* 继承判(唯一;调用点只有装配器头部的新提交腿)。项目缺席 / 本部署无登记簿 / 没有观者 / 未登记 / 看不见 / 无内容证明 ⇒ 不继承(不拒,与随机 id 同答)。
|
|
47
|
+
*/
|
|
48
|
+
export declare function projectContextOf(input: ProjectContextInput): ProjectContextDecision;
|
|
49
|
+
/** 续跑重建输入里冻结的那一份的读数:缺席(没继承 / 7.150.0 之前写下的行)· 读得出 · 形不对。 */
|
|
50
|
+
export type FrozenProjectContextReading = {
|
|
51
|
+
readonly kind: "absent";
|
|
52
|
+
} | {
|
|
53
|
+
readonly kind: "ok";
|
|
54
|
+
readonly context: ProjectContext;
|
|
55
|
+
} | {
|
|
56
|
+
readonly kind: "malformed";
|
|
57
|
+
};
|
|
58
|
+
/**
|
|
59
|
+
* 冻结的那一份的**唯一读法**(读者 = `http/resume-ctx-read.ts` 的续跑上下文读口)。服务端写下的形是闭集(本文件 {@link projectContextOf} 铸、`buildCheckpointCtx` 原样落盘):
|
|
60
|
+
* 自有键只在 `projectId` / `cwd` / `brief` 里;`projectId` = 规范小写 UUID;`cwd` 在场 = 宿主绝对路径;`brief` 在场 = 非空串、不超过系统提示追加折叠的帽;
|
|
61
|
+
* `cwd` 与 `brief` 至少其一(都缺的不会被冻结)。别的形 ⇒ `malformed`(读口答坏体:续跑不重放它、不登记它的 `cwd`)。
|
|
62
|
+
*/
|
|
63
|
+
export declare function frozenProjectContextOf(stored: unknown): FrozenProjectContextReading;
|
|
64
|
+
//# sourceMappingURL=project-context.d.ts.map
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { PROJECT_ID_REGEX } from "@sema-agent/core";
|
|
2
|
+
import { isAbsoluteHostPath } from "@sema-agent/settings-schema";
|
|
3
|
+
import { visibleProjectOf } from "./project-registry.js";
|
|
4
|
+
import { MAX_SETTINGS_OUTPUT_STYLE_CHARS } from "./task-settings.js";
|
|
5
|
+
export const PROJECT_BRIEF_FIELDS = ["goal", "notes", "contextItems"];
|
|
6
|
+
export const PROJECT_CONTENT_ATTESTATION_FIELD = "contentAttestedAt";
|
|
7
|
+
export function buildProjectBrief(projectId, registration, pathsHonored) {
|
|
8
|
+
const sections = [];
|
|
9
|
+
if (registration.goal !== undefined && registration.goal.length > 0)
|
|
10
|
+
sections.push(`## Goal\n${registration.goal}`);
|
|
11
|
+
if (registration.notes !== undefined && registration.notes.length > 0)
|
|
12
|
+
sections.push(`## Notes\n${registration.notes}`);
|
|
13
|
+
const items = registration.contextItems ?? [];
|
|
14
|
+
const notes = items.flatMap((item) => (item.kind === "note" && item.value.length > 0 ? [item.value] : []));
|
|
15
|
+
if (notes.length > 0)
|
|
16
|
+
sections.push(`## Project notes\n${notes.join("\n\n")}`);
|
|
17
|
+
if (pathsHonored) {
|
|
18
|
+
const folders = items.flatMap((item) => (item.kind === "folder" ? [`- ${item.value}`] : []));
|
|
19
|
+
if (folders.length > 0)
|
|
20
|
+
sections.push(`## Project folders\n${folders.join("\n")}`);
|
|
21
|
+
const files = items.flatMap((item) => (item.kind === "file" ? [`- ${item.value}`] : []));
|
|
22
|
+
if (files.length > 0)
|
|
23
|
+
sections.push(`## Project files (not attached — read them when relevant)\n${files.join("\n")}`);
|
|
24
|
+
}
|
|
25
|
+
if (sections.length === 0)
|
|
26
|
+
return undefined;
|
|
27
|
+
return [`# Project context (from this deployment's project registry; project ${projectId})`, ...sections].join("\n\n");
|
|
28
|
+
}
|
|
29
|
+
export function projectContextOf(input) {
|
|
30
|
+
const { projectId } = input;
|
|
31
|
+
const registration = visibleProjectOf(input.registry, projectId, input.viewer);
|
|
32
|
+
if (projectId === undefined || registration === undefined)
|
|
33
|
+
return { context: undefined, withheldPathItems: 0 };
|
|
34
|
+
if (registration[PROJECT_CONTENT_ATTESTATION_FIELD] === undefined)
|
|
35
|
+
return { context: undefined, withheldPathItems: 0 };
|
|
36
|
+
const items = registration.contextItems ?? [];
|
|
37
|
+
const withheldPathItems = input.pathsHonored ? 0 : items.filter((item) => item.kind !== "note").length;
|
|
38
|
+
const firstFolder = input.pathsHonored ? items.find((item) => item.kind === "folder")?.value : undefined;
|
|
39
|
+
const cwd = input.requestCwd ? undefined : firstFolder;
|
|
40
|
+
const brief = input.projectMemoryOff ? undefined : buildProjectBrief(projectId, registration, input.pathsHonored);
|
|
41
|
+
if (cwd === undefined && brief === undefined)
|
|
42
|
+
return { context: undefined, withheldPathItems };
|
|
43
|
+
return { context: { projectId, ...(cwd !== undefined ? { cwd } : {}), ...(brief !== undefined ? { brief } : {}) }, withheldPathItems };
|
|
44
|
+
}
|
|
45
|
+
export function frozenProjectContextOf(stored) {
|
|
46
|
+
if (stored === undefined)
|
|
47
|
+
return { kind: "absent" };
|
|
48
|
+
if (typeof stored !== "object" || stored === null || Array.isArray(stored))
|
|
49
|
+
return { kind: "malformed" };
|
|
50
|
+
if (!Object.keys(stored).every((k) => k === "projectId" || k === "cwd" || k === "brief"))
|
|
51
|
+
return { kind: "malformed" };
|
|
52
|
+
const own = (k) => (Object.hasOwn(stored, k) ? stored[k] : undefined);
|
|
53
|
+
const projectId = own("projectId");
|
|
54
|
+
const cwd = own("cwd");
|
|
55
|
+
const brief = own("brief");
|
|
56
|
+
if (typeof projectId !== "string" || !PROJECT_ID_REGEX.test(projectId) || projectId !== projectId.toLowerCase())
|
|
57
|
+
return { kind: "malformed" };
|
|
58
|
+
if (cwd !== undefined && (typeof cwd !== "string" || !isAbsoluteHostPath(cwd)))
|
|
59
|
+
return { kind: "malformed" };
|
|
60
|
+
if (brief !== undefined && (typeof brief !== "string" || brief.length === 0 || brief.length > MAX_SETTINGS_OUTPUT_STYLE_CHARS))
|
|
61
|
+
return { kind: "malformed" };
|
|
62
|
+
if (cwd === undefined && brief === undefined)
|
|
63
|
+
return { kind: "malformed" };
|
|
64
|
+
return { kind: "ok", context: { projectId, ...(cwd !== undefined ? { cwd } : {}), ...(brief !== undefined ? { brief } : {}) } };
|
|
65
|
+
}
|
|
66
|
+
//# sourceMappingURL=project-context.js.map
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type { ProjectRegistration } from "@sema-agent/settings-schema";
|
|
2
|
+
import type { ListFilter } from "./owner-faces.js";
|
|
3
|
+
/** 一张登记簿(键 = 小写规范 UUID;值至少带可见性的属主键)。缺席 = 本部署没有登记簿(`capability-facts.ts` `projectRegistry` 答 no)。 */
|
|
4
|
+
export type ProjectRegistryTable<R> = Readonly<Record<string, R>> | undefined;
|
|
5
|
+
/**
|
|
6
|
+
* 谓词读的观者事实(列表面视域 {@link ListFilter} 里与登记可见性有关的两格)。`gateOwner` 只拿来与登记的 `registeredBy`(settings-schema 的纯串)逐字节比,
|
|
7
|
+
* 所以这里收纯串:新提交腿交来的是读面推导出的主体(品牌串,天然是串),续跑腿交来的是冻结时落成字节的那一串(不重铸品牌 —— 它不进任何属主门,只比这一格)。
|
|
8
|
+
*/
|
|
9
|
+
export interface ProjectViewer {
|
|
10
|
+
readonly fleetWide: ListFilter["fleetWide"];
|
|
11
|
+
readonly gateOwner: string | null;
|
|
12
|
+
}
|
|
13
|
+
/** 一只登记对这位观者可见吗(唯一判):全舰队视域看全部;否则只看 `registeredBy` 恰是自己的(无身份的观者 `gateOwner = null` 恒看不见)。 */
|
|
14
|
+
export declare function projectVisibleTo(viewer: ProjectViewer, registration: Pick<ProjectRegistration, "registeredBy">): boolean;
|
|
15
|
+
/** 这位观者看得见的那只登记(唯一取法):未登记 / 看不见 / 没有观者 / 本部署没有登记簿 ⇒ 同答 `undefined`。按 id 只认自有键。 */
|
|
16
|
+
export declare function visibleProjectOf<R extends Pick<ProjectRegistration, "registeredBy">>(registry: ProjectRegistryTable<R>, projectId: string | undefined, viewer: ProjectViewer | undefined): R | undefined;
|
|
17
|
+
/** 一条 run 的登记簿默认读层种子:种子项目(这次提交带的、提交者看得见的那只)+ 判出它的那一位观者。随 run 冻结(续跑重建输入 `CheckpointCtx.memorySeed`)。 */
|
|
18
|
+
export interface MemorySeed {
|
|
19
|
+
readonly projectId: string;
|
|
20
|
+
readonly viewer: ProjectViewer;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* 新提交腿的种子判(一条 run 一次):这次**提交**没带项目 ⇒ `undefined`(没什么可判);带了而对提交者可见 ⇒ 种子;带了而判不出(未登记 / 看不见 / 没有观者 / 没有登记簿)
|
|
24
|
+
* ⇒ `null`(判过,无 —— 冻结下来,续跑腿据它与「停驻在种子判出现之前」分开)。
|
|
25
|
+
*/
|
|
26
|
+
export declare function memorySeedOf(registry: ProjectRegistryTable<Pick<ProjectRegistration, "registeredBy">>, submittedProjectId: string | undefined, viewer: ProjectViewer | undefined): MemorySeed | null | undefined;
|
|
27
|
+
/** 种子的词(两腿同调):种子的那一位观者此刻仍看得见的那只登记声明的 `defaultScopes`;没有种子 / 判过无 / 登记已不在 / 不再对他可见 ⇒ 缺席。 */
|
|
28
|
+
export declare function memorySeedScopesOf(registry: ProjectRegistryTable<Pick<ProjectRegistration, "registeredBy" | "defaultScopes">>, seed: MemorySeed | null | undefined): string[] | undefined;
|
|
29
|
+
/** 续跑重建输入里冻结的种子的读数:缺席(提交没带项目 / 本格出现之前写下的行)· 判过无(`null`)· 读得出 · 形不对。 */
|
|
30
|
+
export type FrozenMemorySeedReading = {
|
|
31
|
+
readonly kind: "absent";
|
|
32
|
+
} | {
|
|
33
|
+
readonly kind: "none";
|
|
34
|
+
} | {
|
|
35
|
+
readonly kind: "ok";
|
|
36
|
+
readonly seed: MemorySeed;
|
|
37
|
+
} | {
|
|
38
|
+
readonly kind: "malformed";
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* 冻结的种子的**唯一读法**(读者 = `http/resume-ctx-read.ts` 的续跑上下文读口,开封之后、任何续跑消费者之前)。服务端写下的形是闭集({@link memorySeedOf} 铸、经部署事实落盘):
|
|
42
|
+
* `null`(判过,无)或 `{ projectId, viewer: { fleetWide, gateOwner } }` —— `projectId` = 规范小写 UUID;`fleetWide` 布尔;`gateOwner` = 非空串(冻结时落成字节的主体,原样)或 `null`;
|
|
43
|
+
* 观者至少看得见点什么(`fleetWide` 或 `gateOwner` 在场 —— 看不见的提交不冻结种子)。别的形 ⇒ `malformed`(读口答坏体:续跑不按它挑种子)。
|
|
44
|
+
*/
|
|
45
|
+
export declare function frozenMemorySeedOf(stored: unknown): FrozenMemorySeedReading;
|
|
46
|
+
//# sourceMappingURL=project-registry.d.ts.map
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { PROJECT_ID_REGEX } from "@sema-agent/core";
|
|
2
|
+
export function projectVisibleTo(viewer, registration) {
|
|
3
|
+
return viewer.fleetWide || registration.registeredBy === viewer.gateOwner;
|
|
4
|
+
}
|
|
5
|
+
export function visibleProjectOf(registry, projectId, viewer) {
|
|
6
|
+
if (registry === undefined || projectId === undefined || viewer === undefined || !Object.hasOwn(registry, projectId))
|
|
7
|
+
return undefined;
|
|
8
|
+
const registration = registry[projectId];
|
|
9
|
+
return registration !== undefined && projectVisibleTo(viewer, registration) ? registration : undefined;
|
|
10
|
+
}
|
|
11
|
+
export function memorySeedOf(registry, submittedProjectId, viewer) {
|
|
12
|
+
if (submittedProjectId === undefined)
|
|
13
|
+
return undefined;
|
|
14
|
+
if (viewer === undefined || visibleProjectOf(registry, submittedProjectId, viewer) === undefined)
|
|
15
|
+
return null;
|
|
16
|
+
return { projectId: submittedProjectId, viewer: { fleetWide: viewer.fleetWide, gateOwner: viewer.gateOwner } };
|
|
17
|
+
}
|
|
18
|
+
export function memorySeedScopesOf(registry, seed) {
|
|
19
|
+
return visibleProjectOf(registry, seed?.projectId, seed?.viewer)?.defaultScopes;
|
|
20
|
+
}
|
|
21
|
+
export function frozenMemorySeedOf(stored) {
|
|
22
|
+
if (stored === undefined)
|
|
23
|
+
return { kind: "absent" };
|
|
24
|
+
if (stored === null)
|
|
25
|
+
return { kind: "none" };
|
|
26
|
+
const own = (o, k) => (Object.hasOwn(o, k) ? o[k] : undefined);
|
|
27
|
+
const closedObject = (v, keys) => typeof v === "object" && v !== null && !Array.isArray(v) && Object.keys(v).every((k) => keys.includes(k));
|
|
28
|
+
if (!closedObject(stored, ["projectId", "viewer"]))
|
|
29
|
+
return { kind: "malformed" };
|
|
30
|
+
const projectId = own(stored, "projectId");
|
|
31
|
+
const viewer = own(stored, "viewer");
|
|
32
|
+
if (typeof projectId !== "string" || !PROJECT_ID_REGEX.test(projectId) || projectId !== projectId.toLowerCase())
|
|
33
|
+
return { kind: "malformed" };
|
|
34
|
+
if (!closedObject(viewer, ["fleetWide", "gateOwner"]))
|
|
35
|
+
return { kind: "malformed" };
|
|
36
|
+
const fleetWide = own(viewer, "fleetWide");
|
|
37
|
+
const gateOwner = own(viewer, "gateOwner");
|
|
38
|
+
if (typeof fleetWide !== "boolean" || (gateOwner !== null && (typeof gateOwner !== "string" || gateOwner.length === 0)))
|
|
39
|
+
return { kind: "malformed" };
|
|
40
|
+
if (!fleetWide && gateOwner === null)
|
|
41
|
+
return { kind: "malformed" };
|
|
42
|
+
return { kind: "ok", seed: { projectId, viewer: { fleetWide, gateOwner } } };
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=project-registry.js.map
|
package/dist/question.d.ts
CHANGED
|
@@ -9,15 +9,15 @@ export interface QuestionFrame {
|
|
|
9
9
|
/** "question" only: the model's structured questions, secret-redacted. UNTRUSTED-for-display (shell renders; never
|
|
10
10
|
* re-feeds a model). Absent on an over-cap payload (the ask then reports unavailable — no frame is emitted at all). */
|
|
11
11
|
questions?: AskQuestion[];
|
|
12
|
-
/** "question_complete" only: whether the human answered (`answered`) or the ask
|
|
13
|
-
* (`unanswered` —
|
|
12
|
+
/** "question_complete" only: whether the human answered (`answered`) or the ask closed without an answer
|
|
13
|
+
* (`unanswered` — window elapsed / abort / leg-exit sweep). Cosmetic dialog-dismiss. */
|
|
14
14
|
outcome?: "answered" | "unanswered";
|
|
15
15
|
/** Server-signed emit timestamp (additive, [ref]§五→[ref]). Server-minted side-frame ⇒ no core-stream
|
|
16
16
|
* `eventId` to carry (absence is honest); this is the frame's own time coordinate. */
|
|
17
17
|
serverNowMs?: number;
|
|
18
18
|
/** "question" only ([ref]③, additive, the `tool_approval` window-trio precedent from [ref]): the
|
|
19
|
-
* coordinator's OWN answer window (`QUESTION_TTL_MS`, default 5min) — at expiry the ask
|
|
20
|
-
*
|
|
19
|
+
* coordinator's OWN answer window (`QUESTION_TTL_MS`, default 5min) — at expiry the ask closes ("unanswered"); core hears
|
|
20
|
+
* a delivery failure when a live face presented the card, `unavailable` otherwise ({@link seamOutcomeOf}). Minted from the SAME `ttlMs` the
|
|
21
21
|
* `setTimeout` below actually arms (single source; a shell countdown rendered from these can never
|
|
22
22
|
* disagree with the release). Relative + absolute + `serverNowMs` above = clock-skew-proof trio. */
|
|
23
23
|
expiresInMs?: number;
|
|
@@ -30,9 +30,7 @@ export interface QuestionFrame {
|
|
|
30
30
|
* awaiting a human when the run aborts.
|
|
31
31
|
*
|
|
32
32
|
* The ledger carries the CARD, not the answer door: `POST /v1/questions/:id/respond` stays live-only (this replica's
|
|
33
|
-
* memory, `ttlMs`), so a replayed card is answerable only until its own `expiresAtMs` and only on this replica.
|
|
34
|
-
* The adjudication probe ({@link QuestionCoordinator.hasLiveContext}) reads the same transport's `reachable()` — one
|
|
35
|
-
* reading of "can this leg's face show a card right now?". */
|
|
33
|
+
* memory, `ttlMs`), so a replayed card is answerable only until its own `expiresAtMs` and only on this replica. */
|
|
36
34
|
export interface QuestionRunContext {
|
|
37
35
|
taskId: string;
|
|
38
36
|
owner: string | null;
|
|
@@ -73,12 +71,11 @@ export declare class QuestionCoordinator {
|
|
|
73
71
|
private readonly throttle;
|
|
74
72
|
constructor(throttle?: QuestionThrottle);
|
|
75
73
|
/** Run `fn` with the per-run question context ambient. On exit, release any still-pending question for this run (a
|
|
76
|
-
* live-only question cannot outlive its leg →
|
|
74
|
+
* live-only question cannot outlive its leg → released) and drop the run's counters (no leak). */
|
|
77
75
|
runWithContext<T>(ctx: QuestionRunContext, fn: () => Promise<T>): Promise<T>;
|
|
78
|
-
/** `RunnerDeps.onQuestion`. core calls this when the agent's AskUserQuestion tool fires;
|
|
79
|
-
*
|
|
80
|
-
*
|
|
81
|
-
* run never hangs). Arrow property so it can be passed as `onQuestion: coordinator.question` with `this` bound. */
|
|
76
|
+
/** `RunnerDeps.onQuestion`. core calls this when the agent's AskUserQuestion tool fires; what it settles to is what core
|
|
77
|
+
* acts on — a {@link QuestionAnswer} ONLY when a human really answered; a THROW when a live face presented the card and its
|
|
78
|
+
* window elapsed unanswered; `{kind:"unavailable"}` otherwise ({@link seamOutcomeOf}). Either way the run never hangs. Arrow property so it can be passed as `onQuestion: coordinator.question` with `this` bound. */
|
|
82
79
|
question: (req: AskQuestionRequest, signal?: AbortSignal) => Promise<OnQuestionOutcome>;
|
|
83
80
|
/** `POST /v1/questions/:id/respond` — resolve a parked question with the shell's answer. Owner-gated with a 404 (no
|
|
84
81
|
* existence oracle): a non-owner AND an unknown id (answered / expired / wrong replica) both get 404. Returns the
|
|
@@ -89,15 +86,6 @@ export declare class QuestionCoordinator {
|
|
|
89
86
|
};
|
|
90
87
|
/** Test/observability hook: number of currently-parked questions. */
|
|
91
88
|
pendingCount(): number;
|
|
92
|
-
/** [ref] ([ref] 案二):durable 部署上的 AskUserQuestion 判决探针——本调用点是否处在某条**投递得到人的**
|
|
93
|
-
* 活流腿上(runWithContext 包裹的 bg/SSE 腿=true;sync /v1/tasks、verify/cascade、durable resume 驱动=false)。
|
|
94
|
-
* resolve-spec 的 durable question policy 用它在**判决时**分腿:有活流 ⇒ allow(问活人),无 ⇒
|
|
95
|
-
* ask(durable park)。ALS 让这个判断天然 per-leg,policy 组装期不必预知腿别。
|
|
96
|
-
* 🔴 判据是「投递面此刻可达」而不只是「ALS 在场」(复审 A1):detach 腿断连后 run 仍在本作用域里跑,
|
|
97
|
-
* 只判 ALS 会把一条谁也收不到的问题判成 allow;park 才是它该走的腿。读的是本腿传输的 `reachable()`
|
|
98
|
-
* (有直写面 ⇒ 直写此刻活着;只有账本 ⇒ 恒真,后台腿的 durable events tail 语义;谓词读不出 ⇒ 假,判决面 fail-closed 到 park)。
|
|
99
|
-
* 只服务判决面:判决放行之后的开帧投递只读传输律(有账本的腿上死直写 = 卡在账本里,送到)。 */
|
|
100
|
-
hasLiveContext(): boolean;
|
|
101
89
|
private countersFor;
|
|
102
90
|
}
|
|
103
91
|
//# sourceMappingURL=question.d.ts.map
|
package/dist/question.js
CHANGED
|
@@ -12,6 +12,20 @@ export const DEFAULT_QUESTION_THROTTLE = {
|
|
|
12
12
|
ttlMs: 5 * 60_000,
|
|
13
13
|
};
|
|
14
14
|
const UNAVAILABLE = Object.freeze({ kind: "unavailable" });
|
|
15
|
+
const RELEASED = Object.freeze({ kind: "released" });
|
|
16
|
+
const WINDOW_ELAPSED = Object.freeze({ kind: "window_elapsed" });
|
|
17
|
+
function seamOutcomeOf(settlement, presentedLive, ttlMs) {
|
|
18
|
+
switch (settlement.kind) {
|
|
19
|
+
case "answered":
|
|
20
|
+
return settlement.answer;
|
|
21
|
+
case "released":
|
|
22
|
+
return UNAVAILABLE;
|
|
23
|
+
case "window_elapsed":
|
|
24
|
+
if (!presentedLive)
|
|
25
|
+
return UNAVAILABLE;
|
|
26
|
+
throw new Error(`the question was shown on this run's live stream and nobody answered it within its ${ttlMs / 1000}s answer window`);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
15
29
|
export function parseQuestionResponse(body) {
|
|
16
30
|
if (body === null || typeof body !== "object" || Array.isArray(body))
|
|
17
31
|
return { ok: false, error: "body must be an object" };
|
|
@@ -61,7 +75,7 @@ export class QuestionCoordinator {
|
|
|
61
75
|
finally {
|
|
62
76
|
for (const [, p] of [...this.pending]) {
|
|
63
77
|
if (p.taskId === ctx.taskId)
|
|
64
|
-
p.settle(
|
|
78
|
+
p.settle(RELEASED);
|
|
65
79
|
}
|
|
66
80
|
this.counters.delete(ctx.taskId);
|
|
67
81
|
}
|
|
@@ -83,9 +97,9 @@ export class QuestionCoordinator {
|
|
|
83
97
|
rc.inflight += 1;
|
|
84
98
|
let done = false;
|
|
85
99
|
let timer;
|
|
86
|
-
let
|
|
87
|
-
const
|
|
88
|
-
const settle = (
|
|
100
|
+
let resolveSettled;
|
|
101
|
+
const settledP = new Promise((resolve) => { resolveSettled = resolve; });
|
|
102
|
+
const settle = (s) => {
|
|
89
103
|
if (done)
|
|
90
104
|
return;
|
|
91
105
|
done = true;
|
|
@@ -95,12 +109,10 @@ export class QuestionCoordinator {
|
|
|
95
109
|
ctx.abortSignal?.removeEventListener("abort", onAbort);
|
|
96
110
|
this.pending.delete(id);
|
|
97
111
|
rc.inflight = Math.max(0, rc.inflight - 1);
|
|
98
|
-
|
|
99
|
-
resolveAnswer(a);
|
|
112
|
+
resolveSettled(s);
|
|
100
113
|
};
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
timer = setTimeout(() => settle(UNAVAILABLE, "unanswered"), this.throttle.ttlMs);
|
|
114
|
+
const onAbort = () => settle(RELEASED);
|
|
115
|
+
timer = setTimeout(() => settle(WINDOW_ELAPSED), this.throttle.ttlMs);
|
|
104
116
|
timer.unref?.();
|
|
105
117
|
signal?.addEventListener("abort", onAbort, { once: true });
|
|
106
118
|
ctx.abortSignal?.addEventListener("abort", onAbort, { once: true });
|
|
@@ -108,7 +120,7 @@ export class QuestionCoordinator {
|
|
|
108
120
|
const now = Date.now();
|
|
109
121
|
const race = createHitlOpenRace({
|
|
110
122
|
targets: [{ transport: ctx.transport, frame: { type: "question", questionId: id, questions, serverNowMs: now, expiresInMs: this.throttle.ttlMs, expiresAtMs: now + this.throttle.ttlMs } }],
|
|
111
|
-
settled:
|
|
123
|
+
settled: settledP,
|
|
112
124
|
});
|
|
113
125
|
const phase = await race.phase;
|
|
114
126
|
if (phase === "delivered") {
|
|
@@ -116,7 +128,7 @@ export class QuestionCoordinator {
|
|
|
116
128
|
}
|
|
117
129
|
else if (phase === "undelivered") {
|
|
118
130
|
recordFailOpen("server.question.open-frame-undelivered", `question=${id}`);
|
|
119
|
-
settle(
|
|
131
|
+
settle(RELEASED);
|
|
120
132
|
}
|
|
121
133
|
else {
|
|
122
134
|
void race.landing.then((late) => {
|
|
@@ -126,9 +138,10 @@ export class QuestionCoordinator {
|
|
|
126
138
|
recordFailOpen("server.question.open-frame-undelivered", `question=${id}`);
|
|
127
139
|
});
|
|
128
140
|
}
|
|
129
|
-
const
|
|
130
|
-
race.close({ type: "question_complete", questionId: id, outcome:
|
|
131
|
-
|
|
141
|
+
const settlement = await settledP;
|
|
142
|
+
race.close({ type: "question_complete", questionId: id, outcome: settlement.kind === "answered" ? "answered" : "unanswered", serverNowMs: Date.now() });
|
|
143
|
+
const presentedLive = settlement.kind === "window_elapsed" && phase === "delivered" && (await race.acceptedLive(0));
|
|
144
|
+
return seamOutcomeOf(settlement, presentedLive, this.throttle.ttlMs);
|
|
132
145
|
};
|
|
133
146
|
respond(id, principal, body) {
|
|
134
147
|
const parsed = parseQuestionResponse(body);
|
|
@@ -138,16 +151,12 @@ export class QuestionCoordinator {
|
|
|
138
151
|
if (!entry || !keyAdmits("ask.answer", { subject: recoveredSubject(principal), operator: false }, ownerCellOf(entry.owner))) {
|
|
139
152
|
return { status: 404, body: refusalBody({ errorCode: "question.not_pending", message: "no pending question for this id (answered, expired, or not on this replica)" }) };
|
|
140
153
|
}
|
|
141
|
-
entry.settle(parsed.value
|
|
154
|
+
entry.settle({ kind: "answered", answer: parsed.value });
|
|
142
155
|
return { status: 200, body: { questionId: id, delivery: "applied" } };
|
|
143
156
|
}
|
|
144
157
|
pendingCount() {
|
|
145
158
|
return this.pending.size;
|
|
146
159
|
}
|
|
147
|
-
hasLiveContext() {
|
|
148
|
-
const ctx = this.als.getStore();
|
|
149
|
-
return ctx !== undefined && ctx.transport.reachable();
|
|
150
|
-
}
|
|
151
160
|
countersFor(taskId) {
|
|
152
161
|
let rc = this.counters.get(taskId);
|
|
153
162
|
if (!rc) {
|
|
@@ -29,7 +29,7 @@ const TASK_BODY_DECLARED_KEYS = [
|
|
|
29
29
|
"outputSchema", "permissionMode", "projectId", "projectMemory", "promptLean", "reasoningEffort", "requireExistingSession",
|
|
30
30
|
"resilience", "restoreFiles", "resumeAt", "resumeAtMode", "retainBackgroundProcesses", "retainSubagentSessions",
|
|
31
31
|
"rewindFilesTo", "sandboxImageProfile", "scenario", "scratchpadDir", "selfOrchestration",
|
|
32
|
-
"sessionId", "settings", "skills", "suggestNextPrompts", "systemPrompt", "taskId", "toolMaterializeStrategy",
|
|
32
|
+
"sessionId", "sessionKind", "settings", "skills", "suggestNextPrompts", "systemPrompt", "taskId", "toolMaterializeStrategy",
|
|
33
33
|
"userAttachments", "userInvokedSkills", "verify", "verifyRounds",
|
|
34
34
|
];
|
|
35
35
|
const TASK_BODY_SCENARIO_KEYS = ["repo"];
|
|
@@ -148,5 +148,9 @@ export interface InheritEnvFieldIssue {
|
|
|
148
148
|
* 句子对两种坏值形是同一句(点名两词与「名单不是请求值」);`reason` 区分它们。
|
|
149
149
|
*/
|
|
150
150
|
export declare function inheritEnvFieldIssue(raw: unknown): InheritEnvFieldIssue | null;
|
|
151
|
+
/** 词表外的拒句(wire 可见、字节冻结在 `test/api-error-text-freeze.test.ts` 的常量锚格)。 */
|
|
152
|
+
export declare const SESSION_KIND_VALUE_MESSAGE: string;
|
|
153
|
+
/** `sessionKind` 在场且不在闭集里 ⇒ 拒句;缺席或合法 ⇒ `null`(只在 fresh 受理门调)。 */
|
|
154
|
+
export declare function sessionKindFieldIssue(raw: unknown): string | null;
|
|
151
155
|
export {};
|
|
152
156
|
//# sourceMappingURL=request-value-closure.d.ts.map
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { SESSION_KINDS, isSessionKind } from "./session-kind.js";
|
|
1
2
|
export const MEMORY_CAPTURE_SPELLING_MESSAGE = "memoryCapture must be the string 'off' when present (the session-level memory-capture opt-out declaration; absent = capture as usual — there is no 'on' spelling)";
|
|
2
3
|
export const MEMORY_OFF_SPELLING_MESSAGE = "memory must be the string 'off' when present (the request-level declaration that this run mounts no memory face at all; absent = memory as usual — there is no 'on' spelling; to keep memory mounted but stop this session's content from entering long-term memory, send memoryCapture: 'off' instead)";
|
|
3
4
|
export const FILE_HISTORY_OFF_SPELLING_MESSAGE = "fileHistory must be the string 'disabled' when present (the request-level declaration that this run records no file history — no backup of an edited file, and no file restore in the same request; absent = the deployment's setting — there is no 'enabled' spelling)";
|
|
@@ -49,4 +50,13 @@ export function inheritEnvFieldIssue(raw) {
|
|
|
49
50
|
return null;
|
|
50
51
|
return { message: INHERIT_ENV_VALUE_MESSAGE, facts: inheritEnvFacts(typeof value === "string" ? "unknown_word" : "not_a_string") };
|
|
51
52
|
}
|
|
53
|
+
export const SESSION_KIND_VALUE_MESSAGE = `sessionKind must be one of ${SESSION_KINDS.map((w) => JSON.stringify(w)).join(" | ")} when present ` +
|
|
54
|
+
`("sidechain" = the session this submission creates is a client-placed sub-conversation: it is not listed by GET /v1/sessions unless asked for with ?sessionKind=sidechain, ` +
|
|
55
|
+
`and it is deleted after BG_AGENT_RETENTION_MS of inactivity; absent = a top-level conversation) — the kind is written once, when the session is created`;
|
|
56
|
+
export function sessionKindFieldIssue(raw) {
|
|
57
|
+
if (raw === null || raw === undefined || typeof raw !== "object" || Array.isArray(raw))
|
|
58
|
+
return null;
|
|
59
|
+
const value = raw.sessionKind;
|
|
60
|
+
return value === undefined || isSessionKind(value) ? null : SESSION_KIND_VALUE_MESSAGE;
|
|
61
|
+
}
|
|
52
62
|
//# sourceMappingURL=request-value-closure.js.map
|
package/dist/run-acceptance.d.ts
CHANGED
|
@@ -76,12 +76,13 @@ export interface RunAcceptance {
|
|
|
76
76
|
observe(ev: {
|
|
77
77
|
type: string;
|
|
78
78
|
}): Promise<void>;
|
|
79
|
-
/**
|
|
79
|
+
/** 结果到手、**放掉这条 run 的认领之前**(收场写 / 停驻提交之前):还没在流上见过受理帧、而结果里跑过 turn(只回结果的腿)⇒ 受理。只读 `stats.turns`。不抛;
|
|
80
|
+
* 交回的那一拍等标题器钉住要起名的住客(有界一读;认领在手 ⇒ 会话删不掉 ⇒ 住客就是这条 run 的)与补写落定 —— 腿 await 它再放认领。 */
|
|
80
81
|
settle(result: {
|
|
81
82
|
readonly stats: {
|
|
82
83
|
readonly turns: number;
|
|
83
84
|
};
|
|
84
|
-
}): void
|
|
85
|
+
}): Promise<void>;
|
|
85
86
|
/** 提交那一刻就知道的交付文本(腿上没有屏 ⇒ 请求原文);腿上有屏 ⇒ 缺席:各面提交时不写,交付时经 {@link onDelivered} 补。 */
|
|
86
87
|
readonly objectiveAtSubmit: string | undefined;
|
|
87
88
|
/**
|
package/dist/run-acceptance.js
CHANGED
|
@@ -35,11 +35,10 @@ export function createRunAcceptance(deps, input) {
|
|
|
35
35
|
delivered = objective;
|
|
36
36
|
if (objective === undefined)
|
|
37
37
|
return Promise.resolve();
|
|
38
|
-
|
|
39
|
-
deps.sessionTitler?.maybeTitle(input.sessionId, objective, input.model, deliver);
|
|
38
|
+
const titled = input.sessionId ? (deps.sessionTitler?.maybeTitle(input.sessionId, objective, input.model, deliver) ?? Promise.resolve()) : Promise.resolve();
|
|
40
39
|
if (!input.screened)
|
|
41
|
-
return
|
|
42
|
-
return Promise.all(fills.map(({ face, fill }) => runFill(face, fill, objective))).then(() => undefined);
|
|
40
|
+
return titled;
|
|
41
|
+
return Promise.all([titled, ...fills.map(({ face, fill }) => runFill(face, fill, objective))]).then(() => undefined);
|
|
43
42
|
};
|
|
44
43
|
return {
|
|
45
44
|
objectiveAtSubmit: input.screened ? undefined : input.objective,
|
|
@@ -51,8 +50,7 @@ export function createRunAcceptance(deps, input) {
|
|
|
51
50
|
return Promise.resolve();
|
|
52
51
|
},
|
|
53
52
|
settle(result) {
|
|
54
|
-
|
|
55
|
-
void accept(input.screened ? undefined : input.objective);
|
|
53
|
+
return result.stats.turns > 0 ? accept(input.screened ? undefined : input.objective) : Promise.resolve();
|
|
56
54
|
},
|
|
57
55
|
onDelivered(face, fill) {
|
|
58
56
|
if (!input.screened)
|
|
@@ -15,7 +15,7 @@ import type { CheckpointToken } from "@sema-agent/core";
|
|
|
15
15
|
import type { CheckpointStoreFull, RunStore } from "./plugins/store-backend.js";
|
|
16
16
|
/** 取消动词在 `runSessionId` 这条 run 的会话上会结算的那一张卡;没有 ⇒ `null`。 */
|
|
17
17
|
export declare function runCancelCardOf(cs: Pick<CheckpointStoreFull, "findPendingTokenBySession">, runSessionId: string): Promise<CheckpointToken | null>;
|
|
18
|
-
/** 取消动词要问的 run 行的两口:这条会话上持着认领的 run
|
|
18
|
+
/** 取消动词要问的 run 行的两口:这条会话上持着认领的 run、它的状态(不带属主的一格事实,只经属主存取器读)。 */
|
|
19
19
|
export type CancelRunReader = Pick<RunStore, "getActiveTaskId" | "getRun">;
|
|
20
20
|
/**
|
|
21
21
|
* 取消动词会不会结算 `token` 这一张 —— 出路投影问的就是这一问,三个条件都是取消口自己的:
|
package/dist/run-cancel-card.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { LIVE_RUN_GATE_KINDS } from "./plugins/checkpoint-store-face.js";
|
|
2
2
|
import { isParkedRunStatus } from "./plugins/store-contracts.js";
|
|
3
|
+
import { runFactsOf } from "./http/owner-access.js";
|
|
3
4
|
const RUN_CANCEL_CARD = { gateKinds: LIVE_RUN_GATE_KINDS, axis: "run" };
|
|
4
5
|
export function runCancelCardOf(cs, runSessionId) {
|
|
5
6
|
return cs.findPendingTokenBySession(runSessionId, undefined, RUN_CANCEL_CARD);
|
|
@@ -13,7 +14,7 @@ export async function cancelSettlesCard(cs, runs, token) {
|
|
|
13
14
|
const holder = await runs.getActiveTaskId(host);
|
|
14
15
|
if (holder === undefined)
|
|
15
16
|
return false;
|
|
16
|
-
const run = await runs
|
|
17
|
+
const run = await runFactsOf(runs, holder);
|
|
17
18
|
return run !== undefined && isParkedRunStatus(run.status) && (await runCancelCardOf(cs, host)) === token;
|
|
18
19
|
}
|
|
19
20
|
//# sourceMappingURL=run-cancel-card.js.map
|
package/dist/run-local.js
CHANGED