@sema-agent/server 7.147.0 → 7.149.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 +1468 -24
- package/README.md +35 -7
- package/README.zh-CN.md +18 -8
- package/USAGE.md +444 -193
- package/deploy/sema-up/README.md +16 -5
- package/deploy/sema-up/chart/templates/NOTES.txt +1 -1
- package/deploy/sema-up/chart/templates/_helpers.tpl +20 -4
- package/deploy/sema-up/chart/values.yaml +3 -2
- package/deploy/sema-up/cluster-up.sh +74 -176
- package/deploy/sema-up/kube-up.sh +29 -49
- package/deploy/sema-up/lib/chart-run.sh +23 -0
- package/deploy/sema-up/lib/dataroot.sh +3 -3
- package/deploy/sema-up/lib/health.sh +62 -13
- package/deploy/sema-up/lib/helm-values-cluster.py +18 -0
- package/deploy/sema-up/lib/helm-values-kube.py +35 -0
- package/deploy/sema-up/lib/regcred.py +8 -0
- package/deploy/sema-up/lib/remote/helm-install.sh +3 -0
- package/deploy/sema-up/lib/remote/image-import.sh +6 -0
- package/deploy/sema-up/lib/remote/machine-precheck.sh +11 -0
- package/deploy/sema-up/lib/remote/region-probe.sh +3 -0
- package/deploy/sema-up/lib/remote/stack-ready.sh +26 -0
- package/deploy/sema-up/lib/remote/vxlan-guard.sh +8 -0
- package/deploy/sema-up/lib/render-stack.py +17 -0
- package/deploy/sema-up/lib/shell-text.sh +87 -0
- package/deploy/sema-up/lib/usage-flags.txt +10 -0
- package/deploy/sema-up/lib/usage-head.txt +1 -0
- package/deploy/sema-up/lib/usage-tail.txt +13 -0
- package/deploy/sema-up/preflight.sh +10 -8
- package/deploy/sema-up/sema-up.sh +14 -39
- package/deploy/sema-up/smoke.sh +7 -6
- package/deploy/sema-up/stack/compose.dataroot.yaml +3 -0
- package/deploy/sema-up/stack/compose.yaml +13 -1
- package/deploy/sema-up/stack/sema-stack-cluster.yaml +21 -0
- package/dist/adoption/plan.d.ts +24 -0
- package/dist/adoption/plan.js +53 -1
- package/dist/adoption/runner.d.ts +10 -1
- package/dist/adoption/runner.js +36 -16
- package/dist/approval-card.d.ts +36 -38
- package/dist/approval-gate-currency.js +3 -2
- package/dist/approval-leg-origin.d.ts +33 -0
- package/dist/approval-leg-origin.js +4 -0
- package/dist/approval-reconciler.d.ts +4 -13
- package/dist/approval-reconciler.js +2 -2
- package/dist/approval.d.ts +13 -11
- package/dist/approval.js +3 -3
- package/dist/audit.d.ts +10 -3
- package/dist/audit.js +15 -7
- package/dist/auth-bridge.d.ts +9 -15
- package/dist/auth-bridge.js +4 -11
- package/dist/auth-keys.d.ts +10 -1
- package/dist/auth-keys.js +8 -0
- package/dist/auto-mode-face.d.ts +10 -7
- package/dist/auto-mode-face.js +7 -4
- package/dist/background-agent-name.d.ts +19 -1
- package/dist/background-agent-name.js +12 -2
- package/dist/background-session-reap.d.ts +1 -1
- package/dist/bake-runner/main.js +9 -6
- package/dist/bench/s1/arms.js +6 -5
- package/dist/bench/s1/live-deps.js +5 -2
- package/dist/bench/s1/run-firm.js +6 -5
- package/dist/bind-host.d.ts +25 -0
- package/dist/bind-host.js +25 -0
- package/dist/boot/adoption.d.ts +3 -0
- package/dist/boot/adoption.js +1 -0
- package/dist/boot/deployment-mods.d.ts +1 -1
- package/dist/boot/execution-env.d.ts +17 -7
- package/dist/boot/execution-env.js +47 -42
- package/dist/boot/execution-lane.d.ts +6 -4
- package/dist/boot/execution-lane.js +3 -1
- package/dist/boot/exit-boundary.d.ts +2 -2
- package/dist/boot/exit-boundary.js +6 -5
- package/dist/boot/fatal-exit.d.ts +3 -5
- package/dist/boot/fatal-exit.js +2 -2
- package/dist/boot/leader.d.ts +15 -0
- package/dist/boot/leader.js +17 -15
- package/dist/boot/memory-consolidation.d.ts +37 -29
- package/dist/boot/memory-consolidation.js +11 -5
- package/dist/boot/org-delivery.d.ts +3 -2
- package/dist/boot/org-memory.js +1 -1
- package/dist/boot/parked-revive-gate.js +2 -2
- package/dist/boot/reapers.d.ts +4 -3
- package/dist/boot/reapers.js +19 -16
- package/dist/boot/resolve-spec.d.ts +5 -3
- package/dist/boot/resolve-spec.js +60 -70
- package/dist/boot/retention-lane.d.ts +4 -4
- package/dist/boot/retention-lane.js +2 -2
- package/dist/boot/runner-deps.d.ts +28 -7
- package/dist/boot/runner-deps.js +14 -5
- package/dist/boot/runtime-caps.d.ts +2 -2
- package/dist/boot/runtime-caps.js +16 -2
- package/dist/boot/session-faces.d.ts +16 -7
- package/dist/boot/session-faces.js +114 -94
- package/dist/boot/shutdown.d.ts +5 -4
- package/dist/boot/shutdown.js +6 -4
- package/dist/boot/stage-01-config.d.ts +1 -0
- package/dist/boot/stage-01-config.js +13 -4
- package/dist/boot/stage-02-web-admin-pull.d.ts +2 -0
- package/dist/boot/stage-02-web-admin-pull.js +16 -3
- package/dist/boot/stage-03-store-backend.d.ts +4 -0
- package/dist/boot/stage-03-store-backend.js +4 -3
- package/dist/boot/stage-04-stores.d.ts +3 -0
- package/dist/boot/stage-04-stores.js +2 -2
- package/dist/boot/stage-05-execution-env.d.ts +8 -3
- package/dist/boot/stage-05-execution-env.js +2 -2
- package/dist/boot/stage-06-runners.d.ts +12 -13
- package/dist/boot/stage-06-runners.js +23 -15
- package/dist/boot/stage-07-capability-layer.d.ts +13 -9
- package/dist/boot/stage-07-capability-layer.js +5 -3
- package/dist/boot/stage-08-reapers.d.ts +13 -9
- package/dist/boot/stage-08-reapers.js +3 -3
- package/dist/boot/stage-09-leader.d.ts +14 -16
- package/dist/boot/stage-09-leader.js +12 -4
- package/dist/boot/stage-10-http-server.d.ts +14 -16
- package/dist/boot/stage-10-http-server.js +7 -4
- package/dist/boot/store-evidence.d.ts +20 -0
- package/dist/boot/store-evidence.js +13 -0
- package/dist/boot/stores.d.ts +6 -0
- package/dist/boot/stores.js +41 -27
- package/dist/boot/task-list-lane.d.ts +4 -4
- package/dist/boot/web-admin.d.ts +4 -2
- package/dist/boot/web-admin.js +55 -35
- package/dist/boot/webfetch-summarize-lane.d.ts +1 -1
- package/dist/boot-reclaim.d.ts +3 -1
- package/dist/boot-reclaim.js +1 -1
- package/dist/brain.d.ts +7 -18
- package/dist/brain.js +5 -17
- package/dist/budget.js +6 -6
- package/dist/capabilities/center-plugins.d.ts +7 -1
- package/dist/capabilities/center-plugins.js +32 -10
- package/dist/capabilities/center-wiring.js +1 -1
- package/dist/capabilities/composite-members.d.ts +2 -2
- package/dist/capabilities/composite-members.js +2 -2
- package/dist/capabilities/repo-tools.d.ts +2 -0
- package/dist/capabilities/repo-tools.js +14 -12
- package/dist/capabilities/scenarios.d.ts +6 -15
- package/dist/capabilities/scenarios.js +11 -16
- package/dist/capabilities/skills.d.ts +1 -1
- package/dist/capabilities/tool-defer.d.ts +1 -1
- package/dist/capability-facts.d.ts +39 -11
- package/dist/capability-facts.js +35 -7
- package/dist/card-settle-stored-scope.d.ts +56 -0
- package/dist/card-settle-stored-scope.js +27 -0
- package/dist/card-void.d.ts +8 -13
- package/dist/card-void.js +2 -7
- package/dist/center-credential-renewer.d.ts +6 -2
- package/dist/center-credential-renewer.js +7 -3
- package/dist/config-catalog.d.ts +28 -1
- package/dist/config-catalog.js +95 -85
- package/dist/config-dir-trust.d.ts +37 -4
- package/dist/config-dir-trust.js +88 -44
- package/dist/config-invariants.d.ts +43 -3
- package/dist/config-invariants.js +69 -5
- package/dist/config-lkg.d.ts +23 -1
- package/dist/config-lkg.js +17 -3
- package/dist/config-provider.d.ts +9 -9
- package/dist/config-provider.js +25 -110
- package/dist/config-pull-failure.d.ts +50 -0
- package/dist/config-pull-failure.js +48 -0
- package/dist/config-types.d.ts +62 -21
- package/dist/config.d.ts +14 -21
- package/dist/config.js +141 -64
- package/dist/context-window-notice.d.ts +31 -0
- package/dist/context-window-notice.js +28 -0
- package/dist/delegated-session-owner.d.ts +1 -1
- package/dist/deleted-session-ids.d.ts +3 -2
- package/dist/deployment-governance.d.ts +3 -3
- package/dist/deployment-shape.d.ts +46 -11
- package/dist/deployment-shape.js +8 -0
- package/dist/egress-redirect.d.ts +25 -7
- package/dist/egress-redirect.js +20 -2
- package/dist/elicitation.d.ts +6 -5
- package/dist/elicitation.js +23 -22
- package/dist/engine-identity.d.ts +28 -0
- package/dist/engine-identity.js +10 -0
- package/dist/entry-problems.d.ts +5 -7
- package/dist/entry-problems.js +1 -1
- package/dist/env-facts.js +2 -1
- package/dist/env-name-allowlist-knobs.d.ts +6 -5
- package/dist/env-name-allowlist-knobs.js +5 -0
- package/dist/env-witness.d.ts +7 -0
- package/dist/env-witness.js +16 -0
- package/dist/execution-lane-caps.d.ts +25 -23
- package/dist/execution-lane-caps.js +18 -26
- package/dist/execution-placement.d.ts +58 -18
- package/dist/execution-placement.js +41 -2
- package/dist/field-conflict.d.ts +7 -11
- package/dist/field-conflict.js +3 -3
- package/dist/file-history-capture.d.ts +3 -3
- package/dist/file-history-disclosure.js +1 -0
- package/dist/fleet/fleet-bus.d.ts +21 -3
- package/dist/fleet/fleet-bus.js +35 -25
- package/dist/fleet/fleet-reconciler.js +2 -2
- package/dist/fleet/serving-lease.js +3 -3
- package/dist/fleet-client.js +3 -3
- package/dist/fleet-lease.d.ts +0 -1
- package/dist/fleet-lease.js +4 -5
- package/dist/history-anchor.d.ts +23 -3
- package/dist/history-anchor.js +24 -4
- package/dist/hitl-delivery.d.ts +90 -0
- package/dist/hitl-delivery.js +98 -0
- package/dist/hooks/classic-stations.d.ts +8 -11
- package/dist/hooks/classic-stations.js +0 -7
- package/dist/hooks/command-spawn.d.ts +7 -2
- package/dist/hooks/command-spawn.js +13 -6
- package/dist/hooks/hook-llm.d.ts +5 -1
- package/dist/hooks/hook-llm.js +24 -15
- package/dist/hooks/hook-runner.d.ts +72 -57
- package/dist/hooks/hook-runner.js +271 -193
- package/dist/host-lsp-manager.d.ts +22 -8
- package/dist/host-lsp-manager.js +4 -1
- package/dist/http/active-run-conflict.d.ts +2 -43
- package/dist/http/active-run-conflict.js +3 -7
- package/dist/http/admission.d.ts +4 -18
- package/dist/http/admission.js +76 -79
- package/dist/http/approval-sweeps.d.ts +3 -3
- package/dist/http/approval-sweeps.js +56 -31
- package/dist/http/caller-trust.d.ts +8 -10
- package/dist/http/caller-trust.js +1 -2
- package/dist/http/claim-heartbeat.d.ts +49 -0
- package/dist/http/claim-heartbeat.js +46 -0
- package/dist/http/claimed-run.d.ts +16 -8
- package/dist/http/claimed-run.js +8 -0
- package/dist/http/dispatch.d.ts +8 -1
- package/dist/http/dispatch.js +78 -30
- package/dist/http/durable-run-leg.d.ts +11 -4
- package/dist/http/durable-run-leg.js +45 -21
- package/dist/http/execution-context.d.ts +122 -47
- package/dist/http/execution-context.js +135 -43
- package/dist/http/health-reader.d.ts +36 -0
- package/dist/http/health-reader.js +21 -0
- package/dist/http/health-self-report.d.ts +9 -9
- package/dist/http/health-self-report.js +4 -4
- package/dist/http/idempotency.d.ts +9 -5
- package/dist/http/idempotency.js +4 -4
- package/dist/http/memory-compliance-failure-reply.d.ts +15 -16
- package/dist/http/memory-compliance-failure-reply.js +4 -2
- package/dist/http/memory-face-fault-reply.d.ts +67 -0
- package/dist/http/memory-face-fault-reply.js +71 -0
- package/dist/http/memory-store-refusal-reply.d.ts +1 -1
- package/dist/http/memory-store-refusal-reply.js +3 -0
- package/dist/http/owner-access.d.ts +392 -67
- package/dist/http/owner-access.js +370 -35
- package/dist/http/principal-gate.d.ts +39 -89
- package/dist/http/principal-gate.js +26 -68
- package/dist/http/refusal-body.d.ts +35 -2
- package/dist/http/refusal-body.js +34 -0
- package/dist/http/request-guards.d.ts +9 -13
- package/dist/http/request-guards.js +34 -68
- package/dist/http/resume-composition.d.ts +37 -0
- package/dist/http/resume-composition.js +18 -0
- package/dist/http/resume-ctx-read.d.ts +46 -12
- package/dist/http/resume-ctx-read.js +31 -6
- package/dist/http/resume-legs.d.ts +54 -19
- package/dist/http/resume-legs.js +408 -196
- package/dist/http/retired-skill-manifest.d.ts +1 -1
- package/dist/http/route-ctx.d.ts +31 -32
- package/dist/http/routes/a2a-serve.d.ts +43 -5
- package/dist/http/routes/a2a-serve.js +60 -37
- package/dist/http/routes/admin-config-refresh.js +2 -2
- package/dist/http/routes/admin-drain.js +2 -2
- package/dist/http/routes/admin-memory-optout.js +4 -3
- package/dist/http/routes/adoption.d.ts +3 -0
- package/dist/http/routes/adoption.js +17 -10
- package/dist/http/routes/agents-roster.js +13 -7
- package/dist/http/routes/approvals-assistant.js +73 -67
- package/dist/http/routes/attachments.js +2 -2
- package/dist/http/routes/background.d.ts +3 -3
- package/dist/http/routes/background.js +9 -17
- package/dist/http/routes/capabilities.js +16 -19
- package/dist/http/routes/config-catalog.js +2 -2
- package/dist/http/routes/devices.d.ts +3 -3
- package/dist/http/routes/devices.js +4 -4
- package/dist/http/routes/diagnostics.d.ts +29 -3
- package/dist/http/routes/diagnostics.js +49 -18
- package/dist/http/routes/engine.js +2 -2
- package/dist/http/routes/fleet.js +5 -3
- package/dist/http/routes/images.js +10 -6
- package/dist/http/routes/leader.d.ts +7 -2
- package/dist/http/routes/leader.js +12 -3
- package/dist/http/routes/mcp-reconnect.d.ts +1 -1
- package/dist/http/routes/mcp-reconnect.js +7 -15
- package/dist/http/routes/memory-bundle.js +4 -7
- package/dist/http/routes/memory-compliance.js +4 -4
- package/dist/http/routes/memory-consolidation.js +6 -9
- package/dist/http/routes/memory-origin.d.ts +2 -0
- package/dist/http/routes/memory-origin.js +7 -8
- package/dist/http/routes/memory-policy.js +17 -12
- package/dist/http/routes/notify-wake.js +10 -19
- package/dist/http/routes/observability.js +3 -3
- package/dist/http/routes/principal-inbox.d.ts +4 -2
- package/dist/http/routes/principal-inbox.js +5 -4
- package/dist/http/routes/projects.d.ts +1 -1
- package/dist/http/routes/projects.js +3 -2
- package/dist/http/routes/retention-ops.js +6 -9
- package/dist/http/routes/rules.js +20 -5
- package/dist/http/routes/run-memory-capture.d.ts +2 -2
- package/dist/http/routes/run-memory-capture.js +6 -12
- package/dist/http/routes/run-permission-mode.d.ts +2 -2
- package/dist/http/routes/run-permission-mode.js +10 -17
- package/dist/http/routes/runs.js +155 -237
- package/dist/http/routes/session-memory-sync.d.ts +2 -2
- package/dist/http/routes/session-memory-sync.js +7 -13
- package/dist/http/routes/session-sync.d.ts +28 -7
- package/dist/http/routes/session-sync.js +63 -50
- package/dist/http/routes/sessions-list.d.ts +3 -3
- package/dist/http/routes/sessions-list.js +9 -9
- package/dist/http/routes/sessions.js +87 -124
- package/dist/http/routes/shared-memory.js +6 -6
- package/dist/http/routes/side-query.js +2 -2
- package/dist/http/routes/tasks.js +237 -187
- package/dist/http/routes/trace-usage.d.ts +0 -12
- package/dist/http/routes/trace-usage.js +40 -46
- package/dist/http/routes/workflows.d.ts +39 -4
- package/dist/http/routes/workflows.js +42 -14
- package/dist/http/run-concurrency-cap.d.ts +20 -12
- package/dist/http/run-concurrency-cap.js +39 -26
- package/dist/http/run-read-face.d.ts +3 -5
- package/dist/http/run-read-face.js +8 -13
- package/dist/http/send.d.ts +12 -3
- package/dist/http/send.js +42 -6
- package/dist/http/server.d.ts +43 -45
- package/dist/http/server.js +61 -11
- package/dist/http/sse-log.d.ts +17 -10
- package/dist/http/sse-log.js +7 -7
- package/dist/http/stored-body-replay.d.ts +12 -0
- package/dist/http/stored-body-replay.js +2 -2
- package/dist/http/submit-ctx.d.ts +17 -8
- package/dist/http/submit-ctx.js +8 -5
- package/dist/http/submit-replay.d.ts +19 -6
- package/dist/http/submit-replay.js +18 -6
- package/dist/http/sync-submit-body.d.ts +3 -4
- package/dist/http/sync-submit-body.js +4 -5
- package/dist/http/wire-types.d.ts +4 -3
- package/dist/identity-source.d.ts +36 -5
- package/dist/identity-source.js +27 -0
- package/dist/index.d.ts +4 -1
- package/dist/index.js +2 -0
- package/dist/key-resolver.d.ts +32 -0
- package/dist/key-resolver.js +23 -9
- package/dist/leader/diffup.js +2 -1
- package/dist/leader/endpoint.d.ts +26 -5
- package/dist/leader/endpoint.js +154 -14
- package/dist/leader/fanout.d.ts +3 -0
- package/dist/leader/fanout.js +78 -63
- package/dist/leader/leader.d.ts +16 -0
- package/dist/leader/leader.js +43 -3
- package/dist/leader/merge.d.ts +9 -1
- package/dist/leader/merge.js +16 -1
- package/dist/leader/repair-wire.js +1 -1
- package/dist/leader/wire.d.ts +36 -3
- package/dist/leader/wire.js +59 -18
- package/dist/leg-facts.d.ts +7 -2
- package/dist/leg-facts.js +1 -0
- package/dist/local-store-declaration.d.ts +54 -0
- package/dist/local-store-declaration.js +59 -0
- package/dist/lsp-evict.d.ts +6 -4
- package/dist/lsp-evict.js +2 -3
- package/dist/mcp-assertion-header.d.ts +1 -1
- package/dist/mcp-assertion-header.js +1 -1
- package/dist/memory-operator-faces.d.ts +5 -4
- package/dist/memory-operator-faces.js +1 -1
- package/dist/memory-project-layer.js +1 -1
- package/dist/memory-scope.d.ts +33 -6
- package/dist/memory-scope.js +68 -19
- package/dist/memory-store-refusal.d.ts +5 -2
- package/dist/memory-sync-client.d.ts +3 -2
- package/dist/memory-sync-client.js +8 -5
- package/dist/model-compat.d.ts +17 -8
- package/dist/model-compat.js +6 -2
- package/dist/model-context-window.d.ts +57 -0
- package/dist/model-context-window.js +21 -0
- package/dist/model-entry-headers.d.ts +46 -4
- package/dist/model-entry-headers.js +2 -2
- package/dist/model-entry-refusal.d.ts +40 -20
- package/dist/model-entry-refusal.js +57 -30
- package/dist/model-plane-face.d.ts +19 -11
- package/dist/model-plane-face.js +9 -1
- package/dist/model-plane-probe.d.ts +2 -0
- package/dist/model-plane-probe.js +17 -0
- package/dist/model-provider.d.ts +3 -3
- package/dist/model-reach-scope.d.ts +2 -1
- package/dist/model-route-endpoint.d.ts +9 -5
- package/dist/model-route-endpoint.js +29 -7
- package/dist/model-select.d.ts +16 -0
- package/dist/model-select.js +4 -0
- package/dist/mountinfo.d.ts +37 -0
- package/dist/mountinfo.js +47 -0
- package/dist/namespaced-rule-name.d.ts +23 -14
- package/dist/namespaced-rule-name.js +8 -11
- package/dist/net-address.d.ts +1 -1
- package/dist/observability/corrupt-read-seat.d.ts +4 -4
- package/dist/observability/corrupt-read-seat.js +5 -3
- package/dist/observability/fail-open.d.ts +72 -40
- package/dist/observability/fail-open.js +74 -40
- package/dist/observability/logger.d.ts +22 -1
- package/dist/observability/logger.js +89 -12
- package/dist/observability/metrics.js +4 -5
- package/dist/observability/otel-exporter.js +2 -1
- package/dist/observability/principal-context.d.ts +14 -7
- package/dist/observability/principal-context.js +8 -3
- package/dist/observability/run-terminal.d.ts +7 -1
- package/dist/observability/run-terminal.js +6 -2
- package/dist/observability/secret-env-scrub.d.ts +1 -1
- package/dist/observability/secret-env-scrub.js +1 -1
- package/dist/orchestration/hardened-vm-runner.d.ts +1 -0
- package/dist/orchestration/hardened-vm-runner.js +11 -5
- package/dist/orchestration/hardened-vm-worker-runner.d.ts +0 -14
- package/dist/orchestration/hardened-vm-worker-runner.js +5 -0
- package/dist/orchestration/hardened-vm-worker.js +2 -1
- package/dist/orchestration/workflow-completion-inbox.d.ts +3 -3
- package/dist/orchestration/workflow-completion-inbox.js +3 -2
- package/dist/org-delivery-gate.d.ts +36 -10
- package/dist/org-delivery-gate.js +12 -8
- package/dist/outbound-dispatcher.d.ts +1 -1
- package/dist/outbound-dispatcher.js +6 -12
- package/dist/owner-brands.d.ts +81 -0
- package/dist/owner-brands.js +42 -0
- package/dist/owner-faces.d.ts +532 -0
- package/dist/owner-faces.js +126 -0
- package/dist/park-row-commit.d.ts +67 -0
- package/dist/park-row-commit.js +76 -0
- package/dist/parked-decide.d.ts +76 -12
- package/dist/parked-decide.js +152 -11
- package/dist/parked-revive-surface.d.ts +14 -4
- package/dist/parked-revive-surface.js +5 -4
- package/dist/peer-directory.d.ts +7 -9
- package/dist/peer-directory.js +3 -2
- package/dist/permission-rule-vocab.d.ts +53 -8
- package/dist/permission-rule-vocab.js +30 -2
- package/dist/plugins/adoption-log-sql.d.ts +3 -25
- package/dist/plugins/adoption-log-sql.js +23 -21
- package/dist/plugins/approval-ask-retired-delete-by-task-m50.d.ts +7 -0
- package/dist/plugins/approval-ask-retired-delete-by-task-m50.js +17 -0
- package/dist/plugins/approval-ask-store-file.d.ts +18 -7
- package/dist/plugins/approval-ask-store-file.js +37 -14
- package/dist/plugins/approval-ask-store-memory.d.ts +12 -4
- package/dist/plugins/approval-ask-store-memory.js +24 -10
- package/dist/plugins/approval-ask-store-sql.d.ts +40 -21
- package/dist/plugins/approval-ask-store-sql.js +44 -15
- package/dist/plugins/approval-exemption-skill-cutoff.d.ts +64 -0
- package/dist/plugins/approval-exemption-skill-cutoff.js +122 -0
- package/dist/plugins/approval-exemption-skill-m46.d.ts +14 -0
- package/dist/plugins/approval-exemption-skill-m46.js +21 -0
- package/dist/plugins/approval-exemption-store.d.ts +32 -2
- package/dist/plugins/approval-exemption-store.js +42 -19
- package/dist/plugins/approval-nonce-store.d.ts +39 -12
- package/dist/plugins/approval-nonce-store.js +72 -23
- package/dist/plugins/blob-backend.d.ts +2 -0
- package/dist/plugins/blob-backend.js +9 -6
- package/dist/plugins/caching-session-store.d.ts +13 -1
- package/dist/plugins/caching-session-store.js +43 -4
- package/dist/plugins/checkpoint-index-columns.d.ts +32 -5
- package/dist/plugins/checkpoint-index-columns.js +36 -1
- package/dist/plugins/checkpoint-store-face.d.ts +83 -10
- package/dist/plugins/checkpoint-store-face.js +18 -1
- package/dist/plugins/device-store-sql.js +1 -0
- package/dist/plugins/ensure-index.d.ts +13 -1
- package/dist/plugins/ensure-index.js +154 -21
- package/dist/plugins/ensure-schema-lock-policy.d.ts +36 -18
- package/dist/plugins/ensure-schema-lock-policy.js +76 -9
- package/dist/plugins/file-run-store.d.ts +85 -32
- package/dist/plugins/file-run-store.js +177 -94
- package/dist/plugins/host-platform.d.ts +24 -3
- package/dist/plugins/host-platform.js +15 -1
- package/dist/plugins/image-bake-store-sql.js +2 -0
- package/dist/plugins/imported-layer-root-retirement.d.ts +2 -2
- package/dist/plugins/k8s-pod-reaper.d.ts +1 -3
- package/dist/plugins/k8s-pod-reaper.js +0 -1
- package/dist/plugins/leader-run-store-sql.d.ts +22 -0
- package/dist/plugins/leader-run-store-sql.js +34 -4
- package/dist/plugins/local-checkpoint-store.d.ts +62 -23
- package/dist/plugins/local-checkpoint-store.js +197 -77
- package/dist/plugins/local-data-dir-modes-m39.js +2 -1
- package/dist/plugins/local-data-root-admission.d.ts +52 -0
- package/dist/plugins/local-data-root-admission.js +100 -0
- package/dist/plugins/local-docker-capacity.d.ts +93 -0
- package/dist/plugins/local-docker-capacity.js +194 -0
- package/dist/plugins/local-docker-reaper.d.ts +92 -0
- package/dist/plugins/local-docker-reaper.js +102 -0
- package/dist/plugins/local-engine-high-water.d.ts +29 -6
- package/dist/plugins/local-engine-high-water.js +27 -19
- package/dist/plugins/local-session-store.d.ts +458 -140
- package/dist/plugins/local-session-store.js +906 -292
- package/dist/plugins/local-session-window.d.ts +3 -2
- package/dist/plugins/local-session-window.js +3 -2
- package/dist/plugins/local-sidecar-quarantine.js +3 -2
- package/dist/plugins/local-task-attachment-store.d.ts +18 -1
- package/dist/plugins/local-task-attachment-store.js +22 -1
- package/dist/plugins/memory-embedder.js +9 -7
- package/dist/plugins/memory-engine-pg.d.ts +3 -2
- package/dist/plugins/memory-engine-pg.js +14 -5
- package/dist/plugins/memory-engine-sql-apply.d.ts +8 -4
- package/dist/plugins/memory-engine-sql-apply.js +6 -8
- package/dist/plugins/memory-engine-tidb.d.ts +4 -2
- package/dist/plugins/memory-engine-tidb.js +11 -2
- package/dist/plugins/memory-optout-grant-store-sql.d.ts +1 -1
- package/dist/plugins/memory-optout-grant-store-sql.js +3 -3
- package/dist/plugins/memory-run-store.d.ts +53 -36
- package/dist/plugins/memory-run-store.js +116 -88
- package/dist/plugins/one-time-migration-marker.d.ts +26 -0
- package/dist/plugins/one-time-migration-marker.js +13 -0
- package/dist/plugins/one-time-migrations.d.ts +214 -47
- package/dist/plugins/one-time-migrations.js +481 -135
- package/dist/plugins/org-delivery-quota-store.d.ts +34 -11
- package/dist/plugins/org-delivery-quota-store.js +31 -15
- package/dist/plugins/permission-rule-store-file.d.ts +3 -3
- package/dist/plugins/permission-rule-store-sql.d.ts +5 -64
- package/dist/plugins/permission-rule-store-sql.js +11 -95
- package/dist/plugins/pg-pool.d.ts +2 -32
- package/dist/plugins/pg-pool.js +24 -17
- package/dist/plugins/remote-env-device.d.ts +3 -2
- package/dist/plugins/remote-env-e2b.d.ts +8 -32
- package/dist/plugins/remote-env-e2b.js +44 -32
- package/dist/plugins/remote-env-host.d.ts +51 -17
- package/dist/plugins/remote-env-host.js +111 -42
- package/dist/plugins/remote-env-k8s.d.ts +40 -45
- package/dist/plugins/remote-env-k8s.js +111 -60
- package/dist/plugins/remote-env-local-docker.d.ts +152 -15
- package/dist/plugins/remote-env-local-docker.js +352 -72
- package/dist/plugins/remote-scratchpad.js +4 -0
- package/dist/plugins/retention-deployment.d.ts +49 -17
- package/dist/plugins/retention-deployment.js +39 -8
- package/dist/plugins/run-preview-m45.d.ts +11 -0
- package/dist/plugins/run-preview-m45.js +19 -0
- package/dist/plugins/run-store-sql.d.ts +82 -75
- package/dist/plugins/run-store-sql.js +164 -125
- package/dist/plugins/s3-answer.d.ts +2 -1
- package/dist/plugins/sandbox-reaper.d.ts +26 -0
- package/dist/plugins/sandbox-reaper.js +2 -0
- package/dist/plugins/scenario-prefix-switch-m42.d.ts +56 -0
- package/dist/plugins/scenario-prefix-switch-m42.js +56 -0
- package/dist/plugins/scheduler-support.d.ts +16 -1
- package/dist/plugins/scheduler-support.js +22 -2
- package/dist/plugins/schema-consistency.d.ts +131 -14
- package/dist/plugins/schema-consistency.js +388 -18
- package/dist/plugins/schema-drift-sentence.d.ts +10 -6
- package/dist/plugins/schema-drift-sentence.js +15 -7
- package/dist/plugins/schema-ensure-legs.d.ts +9 -0
- package/dist/plugins/schema-ensure-legs.js +1 -1
- package/dist/plugins/schema-indexes.js +3 -0
- package/dist/plugins/schema-live-columns.d.ts +14 -5
- package/dist/plugins/schema-live-columns.js +10 -10
- package/dist/plugins/send-user-file.js +2 -1
- package/dist/plugins/session-birth.d.ts +37 -0
- package/dist/plugins/session-birth.js +38 -0
- package/dist/plugins/session-epoch-anchor.d.ts +40 -12
- package/dist/plugins/session-epoch-anchor.js +33 -11
- package/dist/plugins/session-ext-table.d.ts +27 -3
- package/dist/plugins/session-ext-table.js +19 -6
- package/dist/plugins/session-fork.d.ts +15 -1
- package/dist/plugins/session-fork.js +3 -0
- package/dist/plugins/session-ownership.d.ts +1 -1
- package/dist/plugins/session-placement.d.ts +27 -20
- package/dist/plugins/session-placement.js +15 -12
- package/dist/plugins/session-row-sql.d.ts +12 -0
- package/dist/plugins/session-row-sql.js +3 -3
- package/dist/plugins/session-run-rollup.d.ts +29 -0
- package/dist/plugins/session-run-rollup.js +40 -0
- package/dist/plugins/session-store-sql.d.ts +38 -12
- package/dist/plugins/session-store-sql.js +130 -30
- package/dist/plugins/session-withdraw-sql.d.ts +36 -0
- package/dist/plugins/session-withdraw-sql.js +42 -0
- package/dist/plugins/shared-memory-store-sql.d.ts +0 -69
- package/dist/plugins/shared-memory-store-sql.js +2 -1
- package/dist/plugins/shell-sentinel-owner-m48.d.ts +42 -0
- package/dist/plugins/shell-sentinel-owner-m48.js +9 -0
- package/dist/plugins/snapshot-bucket-presence.d.ts +2 -1
- package/dist/plugins/sql-driver.d.ts +1 -1
- package/dist/plugins/sql-driver.js +2 -1
- package/dist/plugins/sql-errors.d.ts +32 -5
- package/dist/plugins/sql-errors.js +55 -7
- package/dist/plugins/sql-json-column.d.ts +8 -7
- package/dist/plugins/sql-json-column.js +10 -6
- package/dist/plugins/stop-then-start-sentence.d.ts +16 -0
- package/dist/plugins/stop-then-start-sentence.js +7 -0
- package/dist/plugins/store-backend.d.ts +99 -16
- package/dist/plugins/store-backend.js +230 -65
- package/dist/plugins/store-contracts.d.ts +123 -33
- package/dist/plugins/store-contracts.js +38 -1
- package/dist/plugins/store-fault.d.ts +28 -2
- package/dist/plugins/store-fault.js +20 -2
- package/dist/plugins/task-attachment-store.d.ts +15 -3
- package/dist/plugins/task-attachment-store.js +22 -9
- package/dist/plugins/tidb-pool.d.ts +11 -6
- package/dist/plugins/tidb-pool.js +39 -18
- package/dist/plugins/web-search.js +5 -3
- package/dist/plugins/workflow-run-store-sql.d.ts +6 -1
- package/dist/plugins/workflow-run-store-sql.js +11 -5
- package/dist/plugins/workspace-custody.d.ts +44 -0
- package/dist/plugins/workspace-custody.js +47 -0
- package/dist/principal-jwt.d.ts +4 -4
- package/dist/principal-jwt.js +20 -5
- package/dist/principal-shape.d.ts +41 -0
- package/dist/principal-shape.js +19 -0
- package/dist/project-identity.d.ts +8 -7
- package/dist/project-identity.js +40 -17
- package/dist/project-layer-key.d.ts +13 -2
- package/dist/project-layer-key.js +9 -1
- package/dist/question.d.ts +13 -23
- package/dist/question.js +21 -39
- package/dist/read-deny-floor-notice.d.ts +36 -0
- package/dist/read-deny-floor-notice.js +40 -0
- package/dist/{plain-string-record.d.ts → request-declaration-disposition.d.ts} +9 -23
- package/dist/request-declaration-disposition.js +39 -0
- package/dist/request-declaration-refusal.d.ts +35 -12
- package/dist/request-declaration-refusal.js +21 -9
- package/dist/request-form.d.ts +58 -0
- package/dist/request-form.js +72 -0
- package/dist/request-image-urls.d.ts +8 -2
- package/dist/request-image-urls.js +2 -1
- package/dist/request-images.d.ts +20 -0
- package/dist/request-images.js +59 -0
- package/dist/request-key-closure.d.ts +6 -7
- package/dist/request-key-closure.js +15 -2
- package/dist/resource-suspend.d.ts +7 -16
- package/dist/resource-suspend.js +1 -1
- package/dist/retired-name-host-notice.d.ts +21 -0
- package/dist/retired-name-host-notice.js +12 -0
- package/dist/rule-entry-list.d.ts +2 -2
- package/dist/rule-entry-list.js +3 -4
- package/dist/rule-issue-reading.d.ts +58 -0
- package/dist/rule-issue-reading.js +14 -0
- package/dist/rules-consent.d.ts +5 -3
- package/dist/rules-consent.js +1 -0
- package/dist/run-acceptance.d.ts +3 -1
- package/dist/run-acceptance.js +3 -0
- package/dist/run-cancel-card.d.ts +28 -0
- package/dist/run-cancel-card.js +19 -0
- package/dist/run-cancel-context.d.ts +10 -0
- package/dist/run-cancel-context.js +1 -0
- package/dist/run-local.d.ts +14 -6
- package/dist/run-local.js +117 -90
- package/dist/run-stale-default.d.ts +7 -0
- package/dist/run-stale-default.js +2 -0
- package/dist/runs.d.ts +56 -21
- package/dist/runs.js +73 -43
- package/dist/runtime-caps-resolver.d.ts +21 -6
- package/dist/runtime-caps-resolver.js +17 -4
- package/dist/runtime-governance.d.ts +2 -2
- package/dist/runtime-governance.js +5 -3
- package/dist/sealed-key-layout.d.ts +12 -5
- package/dist/sealed-key-layout.js +5 -0
- package/dist/sealed-key.d.ts +12 -2
- package/dist/sealed-key.js +115 -27
- package/dist/security.d.ts +128 -158
- package/dist/security.js +163 -59
- package/dist/sema-config-dir.d.ts +20 -0
- package/dist/sema-config-dir.js +25 -0
- package/dist/server-secret-env.d.ts +55 -25
- package/dist/server-secret-env.js +75 -22
- package/dist/session-agent.d.ts +3 -2
- package/dist/session-children-retire.d.ts +13 -8
- package/dist/session-children-retire.js +9 -7
- package/dist/session-deletion.d.ts +88 -0
- package/dist/session-deletion.js +8 -0
- package/dist/session-erase.d.ts +145 -0
- package/dist/session-erase.js +115 -0
- package/dist/session-error-wire.d.ts +5 -5
- package/dist/session-error-wire.js +1 -1
- package/dist/session-incarnation.d.ts +52 -5
- package/dist/session-incarnation.js +19 -2
- package/dist/session-policy-wire.d.ts +6 -3
- package/dist/session-policy-wire.js +11 -1
- package/dist/session-resident-background.d.ts +0 -71
- package/dist/session-resident-background.js +4 -3
- package/dist/session-row.d.ts +2 -1
- package/dist/session-rules-seat.d.ts +12 -0
- package/dist/session-rules-seat.js +19 -0
- package/dist/session-titler.d.ts +7 -15
- package/dist/session-titler.js +1 -1
- package/dist/session-workspace.d.ts +3 -3
- package/dist/spec-fields.d.ts +57 -3
- package/dist/spec-fields.js +72 -51
- package/dist/store-admission.d.ts +33 -0
- package/dist/store-admission.js +49 -0
- package/dist/store-posture.d.ts +141 -20
- package/dist/store-posture.js +205 -3
- package/dist/stored-request-hooks-m20.js +2 -2
- package/dist/stores-sql/background-agent-store-sql.d.ts +11 -2
- package/dist/stores-sql/background-agent-store-sql.js +73 -20
- package/dist/stores-sql/checkpoint-store-sql.d.ts +34 -29
- package/dist/stores-sql/checkpoint-store-sql.js +78 -49
- package/dist/stores-sql/file-history-store-sql.d.ts +1 -1
- package/dist/stores-sql/file-history-store-sql.js +3 -5
- package/dist/stores-sql/mailbox-store-sql.d.ts +7 -4
- package/dist/stores-sql/mailbox-store-sql.js +31 -32
- package/dist/stores-sql/pg-session-storage.d.ts +7 -5
- package/dist/stores-sql/pg-session-storage.js +54 -46
- package/dist/stores-sql/retention-store-sql.d.ts +87 -19
- package/dist/stores-sql/retention-store-sql.js +92 -27
- package/dist/stores-sql/session-policy-store-sql.d.ts +32 -10
- package/dist/stores-sql/session-policy-store-sql.js +44 -36
- package/dist/stores-sql/session-write-hooks.d.ts +12 -6
- package/dist/stores-sql/tidb-session-storage.d.ts +4 -4
- package/dist/stores-sql/tidb-session-storage.js +13 -8
- package/dist/stores-sql/tidb-session-store.d.ts +36 -17
- package/dist/stores-sql/tidb-session-store.js +69 -39
- package/dist/stores-sql/tool-result-store-sql.d.ts +1 -1
- package/dist/stores-sql/tool-result-store-sql.js +4 -6
- package/dist/stores-sql/windowed-session-storage.d.ts +5 -0
- package/dist/stores-sql/windowed-session-storage.js +9 -0
- package/dist/submission-exit.d.ts +50 -0
- package/dist/submission-exit.js +108 -0
- package/dist/task-a2a.d.ts +3 -8
- package/dist/task-a2a.js +28 -30
- package/dist/task-cwd.d.ts +43 -7
- package/dist/task-cwd.js +11 -0
- package/dist/task-mcp.d.ts +3 -3
- package/dist/task-mcp.js +4 -4
- package/dist/task-settings.d.ts +14 -10
- package/dist/task-settings.js +19 -7
- package/dist/terminal.d.ts +27 -43
- package/dist/terminal.js +49 -14
- package/dist/tool-approval.d.ts +173 -163
- package/dist/tool-approval.js +247 -232
- package/dist/trace/core-keyset-guard.d.ts +13 -6
- package/dist/trace/core-vocab-wire.d.ts +95 -0
- package/dist/trace/core-vocab-wire.js +15 -0
- package/dist/trace/engine-notice-wire.d.ts +24 -21
- package/dist/trace/engine-notice-wire.js +7 -3
- package/dist/trace/exit-seat.d.ts +30 -4
- package/dist/trace/exit-seat.js +40 -36
- package/dist/trace/extension-call-face.d.ts +3 -2
- package/dist/trace/extension-call-face.js +3 -1
- package/dist/trace/ledger-events.d.ts +4 -7
- package/dist/trace/ledger-sink.d.ts +4 -31
- package/dist/trace/ledger-sink.js +0 -11
- package/dist/trace/model-segment.d.ts +5 -5
- package/dist/trace/model-segment.js +5 -5
- package/dist/trace/project.d.ts +59 -44
- package/dist/trace/project.js +60 -26
- package/dist/trace/redact.d.ts +135 -27
- package/dist/trace/redact.js +884 -260
- package/dist/trace/self-minted-wire.d.ts +567 -20
- package/dist/trace/self-minted-wire.js +205 -24
- package/dist/trace/wire-projection-faces.d.ts +5 -6
- package/dist/trace/wire-projection-faces.js +2 -2
- package/dist/upstream-body.d.ts +23 -0
- package/dist/upstream-body.js +16 -0
- package/dist/url-refusal.d.ts +3 -3
- package/dist/url-refusal.js +11 -4
- package/dist/user-authored-text.d.ts +1 -1
- package/dist/user-input-ledger.d.ts +7 -8
- package/dist/user-input-ledger.js +1 -1
- package/dist/web-admin-client/apply-effective.d.ts +6 -3
- package/dist/web-admin-client/apply-effective.js +33 -23
- package/dist/web-admin-client/apply-ledger.d.ts +16 -7
- package/dist/web-admin-client/apply-ledger.js +5 -2
- package/dist/web-admin-client/center-request.d.ts +2 -2
- package/dist/web-admin-client/center-request.js +15 -15
- package/dist/web-admin-client/effective-keys.d.ts +1 -1
- package/dist/web-admin-client/effective-keys.js +1 -1
- package/dist/web-admin-client/entry-metadata.d.ts +8 -0
- package/dist/web-admin-client/entry-metadata.js +13 -0
- package/dist/web-admin-client/http-client.d.ts +1 -1
- package/dist/web-admin-client/http-client.js +23 -4
- package/dist/web-admin-client/mcp-revocation.d.ts +1 -1
- package/dist/web-admin-client/mcp-revocation.js +2 -1
- package/dist/web-admin-client/read-warnings.d.ts +1 -0
- package/dist/web-admin-client/read-warnings.js +1 -0
- package/dist/web-admin-client/restart-signal.js +8 -4
- package/dist/web-admin-client/skills-mcp.d.ts +2 -2
- package/dist/web-admin-client/types.d.ts +1 -2
- package/dist/workspace-space.d.ts +3 -2
- package/docs/DEVICE-EXECUTOR-PROTOCOL.md +4 -4
- package/docs/error-text-lexicon.json +317 -0
- package/package.json +8 -3
- package/scripts/drain-check-local.mjs +118 -147
- package/scripts/drain-check.mysql.sql +22 -2
- package/scripts/drain-check.pg.sql +22 -2
- package/scripts/embed-minimal.mjs +183 -0
- package/wire-changes/server@7.148.0.json +1517 -0
- package/wire-changes/server@7.149.0.json +372 -0
- package/dist/http/memory-control-plane-corrupt-reply.d.ts +0 -25
- package/dist/http/memory-control-plane-corrupt-reply.js +0 -19
- package/dist/http/memory-layer-reply.d.ts +0 -30
- package/dist/http/memory-layer-reply.js +0 -24
- package/dist/lsp/e2b-bridge.d.ts +0 -57
- package/dist/lsp/e2b-bridge.js +0 -139
- package/dist/lsp/e2b-manager.d.ts +0 -93
- package/dist/lsp/e2b-manager.js +0 -178
- package/dist/lsp/lsp-frames.d.ts +0 -14
- package/dist/lsp/lsp-frames.js +0 -25
- package/dist/lsp/manager.d.ts +0 -129
- package/dist/lsp/manager.js +0 -127
- package/dist/lsp/types.d.ts +0 -12
- package/dist/lsp/types.js +0 -2
- package/dist/lsp/ws-transport.d.ts +0 -40
- package/dist/lsp/ws-transport.js +0 -210
- package/dist/plain-string-record.js +0 -70
|
@@ -27,6 +27,7 @@ export declare function createRepoClient(kind: GitApiKind, baseUrl: string, toke
|
|
|
27
27
|
export declare class GiteaClient implements RepoReadClient {
|
|
28
28
|
private readonly baseUrl;
|
|
29
29
|
private readonly token?;
|
|
30
|
+
/** 出站出口:Git host 回重定向 ⇒ 拒(`token` 凭据头只去被判过的那个根),不是静默跟随。 */
|
|
30
31
|
private readonly fetchImpl;
|
|
31
32
|
constructor(baseUrl: string, token?: string | undefined, fetchImpl?: typeof fetch);
|
|
32
33
|
private api;
|
|
@@ -51,6 +52,7 @@ export declare class GiteaClient implements RepoReadClient {
|
|
|
51
52
|
export declare class GitHubClient implements RepoReadClient {
|
|
52
53
|
private readonly baseUrl;
|
|
53
54
|
private readonly token?;
|
|
55
|
+
/** 出站出口:Git host 回重定向 ⇒ 拒(Bearer 凭据只去被判过的那个根),不是静默跟随。 */
|
|
54
56
|
private readonly fetchImpl;
|
|
55
57
|
constructor(baseUrl: string, token?: string | undefined, fetchImpl?: typeof fetch);
|
|
56
58
|
private api;
|
|
@@ -13,6 +13,8 @@ export function parseRepo(input) {
|
|
|
13
13
|
const MAX_FILE_BYTES = 96 * 1024;
|
|
14
14
|
const MAX_TREE_ENTRIES = 2000;
|
|
15
15
|
const REQUEST_TIMEOUT_MS = 15_000;
|
|
16
|
+
import { createEgressFetch } from "../egress-redirect.js";
|
|
17
|
+
import { readUpstreamJson } from "../upstream-body.js";
|
|
16
18
|
export { GIT_API_KINDS, isGitApiKind } from "../git-api-kind.js";
|
|
17
19
|
const RepoInfoWire = z.looseObject({ default_branch: z.string().optional() });
|
|
18
20
|
const TreeWire = z.looseObject({
|
|
@@ -32,7 +34,7 @@ function pathSegmentsRejectingTraversal(path) {
|
|
|
32
34
|
}
|
|
33
35
|
return segments;
|
|
34
36
|
}
|
|
35
|
-
export function createRepoClient(kind, baseUrl, token, fetchImpl
|
|
37
|
+
export function createRepoClient(kind, baseUrl, token, fetchImpl) {
|
|
36
38
|
switch (kind) {
|
|
37
39
|
case "gitea":
|
|
38
40
|
return new GiteaClient(baseUrl, token, fetchImpl);
|
|
@@ -48,10 +50,10 @@ export class GiteaClient {
|
|
|
48
50
|
baseUrl;
|
|
49
51
|
token;
|
|
50
52
|
fetchImpl;
|
|
51
|
-
constructor(baseUrl, token, fetchImpl
|
|
53
|
+
constructor(baseUrl, token, fetchImpl) {
|
|
52
54
|
this.baseUrl = baseUrl;
|
|
53
55
|
this.token = token;
|
|
54
|
-
this.fetchImpl = fetchImpl;
|
|
56
|
+
this.fetchImpl = createEgressFetch("declare the final address as GIT_API_BASEURL", fetchImpl);
|
|
55
57
|
}
|
|
56
58
|
async api(path, accept = "application/json") {
|
|
57
59
|
const headers = { accept };
|
|
@@ -66,12 +68,12 @@ export class GiteaClient {
|
|
|
66
68
|
return res;
|
|
67
69
|
}
|
|
68
70
|
async defaultBranch({ owner, repo }) {
|
|
69
|
-
const info = RepoInfoWire.parse(await (await this.api(`/repos/${owner}/${repo}`))
|
|
71
|
+
const info = RepoInfoWire.parse(await readUpstreamJson(await this.api(`/repos/${owner}/${repo}`)));
|
|
70
72
|
return info.default_branch || "main";
|
|
71
73
|
}
|
|
72
74
|
async tree(coords, ref) {
|
|
73
75
|
const { owner, repo } = coords;
|
|
74
|
-
const body = TreeWire.parse(await (await this.api(`/repos/${owner}/${repo}/git/trees/${encodeURIComponent(ref)}?recursive=true&per_page=${MAX_TREE_ENTRIES}`))
|
|
76
|
+
const body = TreeWire.parse(await readUpstreamJson(await this.api(`/repos/${owner}/${repo}/git/trees/${encodeURIComponent(ref)}?recursive=true&per_page=${MAX_TREE_ENTRIES}`)));
|
|
75
77
|
const paths = (body.tree ?? []).filter((e) => e.type === "blob").map((e) => e.path);
|
|
76
78
|
return body.truncated
|
|
77
79
|
? [...paths, `…[truncated, tree has more than ${MAX_TREE_ENTRIES} entries]`]
|
|
@@ -80,7 +82,7 @@ export class GiteaClient {
|
|
|
80
82
|
async readFile(coords, path, ref) {
|
|
81
83
|
const { owner, repo } = coords;
|
|
82
84
|
const segments = pathSegmentsRejectingTraversal(path);
|
|
83
|
-
const body = ContentsWire.parse(await (await this.api(`/repos/${owner}/${repo}/contents/${segments.map(encodeURIComponent).join("/")}?ref=${encodeURIComponent(ref)}`))
|
|
85
|
+
const body = ContentsWire.parse(await readUpstreamJson(await this.api(`/repos/${owner}/${repo}/contents/${segments.map(encodeURIComponent).join("/")}?ref=${encodeURIComponent(ref)}`)));
|
|
84
86
|
if (body.type !== "file" || body.content == null)
|
|
85
87
|
throw new Error(`not a file: ${path}`);
|
|
86
88
|
const text = body.encoding === "base64" ? Buffer.from(body.content, "base64").toString("utf8") : body.content;
|
|
@@ -99,10 +101,10 @@ export class GitHubClient {
|
|
|
99
101
|
baseUrl;
|
|
100
102
|
token;
|
|
101
103
|
fetchImpl;
|
|
102
|
-
constructor(baseUrl, token, fetchImpl
|
|
104
|
+
constructor(baseUrl, token, fetchImpl) {
|
|
103
105
|
this.baseUrl = baseUrl;
|
|
104
106
|
this.token = token;
|
|
105
|
-
this.fetchImpl = fetchImpl;
|
|
107
|
+
this.fetchImpl = createEgressFetch("declare the final address as GIT_API_BASEURL", fetchImpl);
|
|
106
108
|
}
|
|
107
109
|
async api(path, accept = "application/vnd.github+json") {
|
|
108
110
|
const headers = { accept, "x-github-api-version": "2022-11-28" };
|
|
@@ -117,12 +119,12 @@ export class GitHubClient {
|
|
|
117
119
|
return res;
|
|
118
120
|
}
|
|
119
121
|
async defaultBranch({ owner, repo }) {
|
|
120
|
-
const info = RepoInfoWire.parse(await (await this.api(`/repos/${owner}/${repo}`))
|
|
122
|
+
const info = RepoInfoWire.parse(await readUpstreamJson(await this.api(`/repos/${owner}/${repo}`)));
|
|
121
123
|
return info.default_branch || "main";
|
|
122
124
|
}
|
|
123
125
|
async tree(coords, ref) {
|
|
124
126
|
const { owner, repo } = coords;
|
|
125
|
-
const body = TreeWire.parse(await (await this.api(`/repos/${owner}/${repo}/git/trees/${encodeURIComponent(ref)}?recursive=1`))
|
|
127
|
+
const body = TreeWire.parse(await readUpstreamJson(await this.api(`/repos/${owner}/${repo}/git/trees/${encodeURIComponent(ref)}?recursive=1`)));
|
|
126
128
|
const paths = (body.tree ?? []).filter((e) => e.type === "blob").map((e) => e.path);
|
|
127
129
|
if (paths.length > MAX_TREE_ENTRIES) {
|
|
128
130
|
return [...paths.slice(0, MAX_TREE_ENTRIES), `…[truncated, tree has more than ${MAX_TREE_ENTRIES} entries]`];
|
|
@@ -134,7 +136,7 @@ export class GitHubClient {
|
|
|
134
136
|
async readFile(coords, path, ref) {
|
|
135
137
|
const { owner, repo } = coords;
|
|
136
138
|
const segments = pathSegmentsRejectingTraversal(path);
|
|
137
|
-
const body = ContentsWire.parse(await (await this.api(`/repos/${owner}/${repo}/contents/${segments.map(encodeURIComponent).join("/")}?ref=${encodeURIComponent(ref)}`))
|
|
139
|
+
const body = ContentsWire.parse(await readUpstreamJson(await this.api(`/repos/${owner}/${repo}/contents/${segments.map(encodeURIComponent).join("/")}?ref=${encodeURIComponent(ref)}`)));
|
|
138
140
|
if (body.type !== "file" || body.content == null)
|
|
139
141
|
throw new Error(`not a file: ${path}`);
|
|
140
142
|
if (body.encoding === "none") {
|
|
@@ -147,7 +149,7 @@ export class GitHubClient {
|
|
|
147
149
|
}
|
|
148
150
|
async pullDiff(coords, index) {
|
|
149
151
|
const { owner, repo } = coords;
|
|
150
|
-
const meta = PullMetaWire.parse(await (await this.api(`/repos/${owner}/${repo}/pulls/${index}`))
|
|
152
|
+
const meta = PullMetaWire.parse(await readUpstreamJson(await this.api(`/repos/${owner}/${repo}/pulls/${index}`)));
|
|
151
153
|
const res = await this.api(`/repos/${owner}/${repo}/pulls/${index}`, "application/vnd.github.v3.diff");
|
|
152
154
|
let text = await res.text();
|
|
153
155
|
const filesInDiff = (text.match(/^diff --git /gm) ?? []).length;
|
|
@@ -260,18 +260,6 @@ export declare const BUILTIN_SCENARIO_HANDS: {
|
|
|
260
260
|
readonly scan: "none";
|
|
261
261
|
readonly cowork: "full";
|
|
262
262
|
};
|
|
263
|
-
/**
|
|
264
|
-
* [ref]:内建场景的**技能范围**(技能 `scenarios` 标签按哪个名字匹配)—— **全仓唯一声明处**:各场景工厂交进 `TaskSpec` 的技能与场景卡上的技能清单都按这张表取范围,
|
|
265
|
-
* 再过同一只过滤(`skills.ts` 的 `skillsInScope`),两边因此恒为同一组技能。按 {@link BuiltinScenarioName} 键控 ⇒ 加 / 删一个内建场景而这里没跟 = 编译红。
|
|
266
|
-
* `code` 的范围是 `default`:它与 default 共用一只工厂(工具 / 技能面恒等由构造保证),打了 `scenarios: code` 的技能不进 code 的 run。center 场景的范围是它自己的名字。
|
|
267
|
-
*/
|
|
268
|
-
export declare const BUILTIN_SCENARIO_SKILL_SCOPE: {
|
|
269
|
-
readonly code: "default";
|
|
270
|
-
readonly default: "default";
|
|
271
|
-
readonly "code-review": "code-review";
|
|
272
|
-
readonly scan: "scan";
|
|
273
|
-
readonly cowork: "cowork";
|
|
274
|
-
};
|
|
275
263
|
/**
|
|
276
264
|
* `branded` = 这台部署是不是品牌部署 —— 部署座挂品牌行读的同一只判官(`brand-identity.ts` `isBrandedDeployment`)交进来;没有默认值:每个调用点说出这件事实。
|
|
277
265
|
* 品牌部署上,品牌行 `when.binding` 那张表里的场景(`BRAND_IDENTITY_SCENARIOS`)的 `promptSummary` 点名 Sema 产品身份 —— 读面说的就是模型收到的。
|
|
@@ -309,7 +297,6 @@ export type ScenarioAvailability = {
|
|
|
309
297
|
export declare function scenarioAvailability(deps: Pick<ScenarioDeps, "repoClient">, toolset: string): ScenarioAvailability;
|
|
310
298
|
/** 拒绝文案的唯一属主:闭集穷举 switch(新增原因词不在这里表态即编译红)。 */
|
|
311
299
|
export declare function scenarioUnavailableMessage(reason: ScenarioUnavailableReason, scenarioLabel: string): string;
|
|
312
|
-
export declare const SCENARIO_NAME_RE: RegExp;
|
|
313
300
|
/**
|
|
314
301
|
* Build the center-declared scenario overlay. Invalid specs are SKIPPED with a warning (never fail
|
|
315
302
|
* boot — same posture as skills/teams); valid ones become scenarios keyed by name, ready to be merged
|
|
@@ -423,9 +410,13 @@ export interface ScenarioGateSources {
|
|
|
423
410
|
} | undefined;
|
|
424
411
|
readonly logger?: Logger;
|
|
425
412
|
}
|
|
426
|
-
export
|
|
413
|
+
export interface ScenarioGate {
|
|
414
|
+
(principal: string | undefined, requested: unknown): Promise<string>;
|
|
415
|
+
/** 在册词表 —— 门判「在不在册」读的**同一张**场景表的自有键(活读,不抄快照)。请求的场景头在分派层判在册读它(读面没有体,不过整只门)。 */
|
|
416
|
+
readonly known: () => readonly string[];
|
|
417
|
+
}
|
|
427
418
|
/**
|
|
428
|
-
* 门问中心裁定走哪条腿(闭集;新增一词 ⇒ 下面的穷尽 `switch` 编译红)—— 与 `resolveRuntimeCaps` / `
|
|
419
|
+
* 门问中心裁定走哪条腿(闭集;新增一词 ⇒ 下面的穷尽 `switch` 编译红)—— 与 `resolveRuntimeCaps` / `peekRuntimeCapsReading` 是同一对:
|
|
429
420
|
* · `enforce` —— 任务提交腿:中心裁定走执法腿,center 硬失败铸下的 fail-closed 降级项两腿都认;
|
|
430
421
|
* · `peek` —— 读面(`GET /v1/capabilities/mcp` 状态面、`GET /v1/sessions/:id/mcp` / `…/a2a` 两张会话面板):只读腿,同一只缓存 / 同一条抓取 / 同一份读数(中心答不出 ⇒ 读面同拒),但硬失败铸的降级项只对读面自己算数,
|
|
431
422
|
* 不替这个主体的真提交留下 `{allowWorkflows:false, allowFork:false, autoMode:false}` 的短窗 deny(读面不许成为别人被拒的原因)。
|
|
@@ -7,6 +7,7 @@ import { createWebSearchBackend, judgeRequestWebSearch } from "../plugins/web-se
|
|
|
7
7
|
import { scenarioSkillEntries, skillsForScenario } from "./skills.js";
|
|
8
8
|
import { OFFICE_EXCLUDED_TOOL_NAMES, runHasWorkspace } from "./hands-lane.js";
|
|
9
9
|
import { BRAND_IDENTITY_SCENARIOS } from "./brand-identity.js";
|
|
10
|
+
import { SCENARIO_NAME_RE } from "../owner-brands.js";
|
|
10
11
|
export function buildPromptSeats(scenarioName, prompt, callerSystemPrompt) {
|
|
11
12
|
const parts = [prompt?.roleText, callerSystemPrompt].filter((t) => typeof t === "string" && t.length > 0);
|
|
12
13
|
const systemPrompt = parts.length > 0 ? parts.join("\n\n") : callerSystemPrompt;
|
|
@@ -69,7 +70,7 @@ export function buildScenarios(deps) {
|
|
|
69
70
|
}).filter((t) => t.name !== WEB_FETCH_TOOL_NAME || deps.requirePrincipal !== true),
|
|
70
71
|
],
|
|
71
72
|
hands: BUILTIN_SCENARIO_HANDS.default,
|
|
72
|
-
skills: skillsForScenario(deps.skills,
|
|
73
|
+
skills: skillsForScenario(deps.skills, "default"),
|
|
73
74
|
};
|
|
74
75
|
};
|
|
75
76
|
return {
|
|
@@ -77,7 +78,7 @@ export function buildScenarios(deps) {
|
|
|
77
78
|
code: (req, principal, ctx) => ({
|
|
78
79
|
...defaultScenario(req, principal, ctx),
|
|
79
80
|
hands: BUILTIN_SCENARIO_HANDS.code,
|
|
80
|
-
skills: skillsForScenario(deps.skills,
|
|
81
|
+
skills: skillsForScenario(deps.skills, "code"),
|
|
81
82
|
prompt: { role: "code" },
|
|
82
83
|
}),
|
|
83
84
|
"code-review": (req) => codeReview(deps, req),
|
|
@@ -89,13 +90,13 @@ export function buildScenarios(deps) {
|
|
|
89
90
|
return {
|
|
90
91
|
tools: [...repoToolsFor(repoClient, parseRepo(req.repo)), nowTool()],
|
|
91
92
|
hands: BUILTIN_SCENARIO_HANDS.scan,
|
|
92
|
-
skills: skillsForScenario(deps.skills,
|
|
93
|
+
skills: skillsForScenario(deps.skills, "scan"),
|
|
93
94
|
};
|
|
94
95
|
},
|
|
95
96
|
cowork: (req, principal, ctx) => ({
|
|
96
97
|
...defaultScenario(req, principal, ctx),
|
|
97
98
|
hands: BUILTIN_SCENARIO_HANDS.cowork,
|
|
98
|
-
skills: skillsForScenario(deps.skills,
|
|
99
|
+
skills: skillsForScenario(deps.skills, "cowork"),
|
|
99
100
|
excludeTools: OFFICE_EXCLUDED_TOOL_NAMES,
|
|
100
101
|
prompt: { role: "cowork" },
|
|
101
102
|
}),
|
|
@@ -125,13 +126,6 @@ export const BUILTIN_SCENARIO_HANDS = {
|
|
|
125
126
|
scan: "none",
|
|
126
127
|
cowork: "full",
|
|
127
128
|
};
|
|
128
|
-
export const BUILTIN_SCENARIO_SKILL_SCOPE = {
|
|
129
|
-
code: "default",
|
|
130
|
-
default: "default",
|
|
131
|
-
"code-review": "code-review",
|
|
132
|
-
scan: "scan",
|
|
133
|
-
cowork: "cowork",
|
|
134
|
-
};
|
|
135
129
|
export function builtinScenarioDetails(scenarios, deps, branded) {
|
|
136
130
|
const probe = (name, req, principal, fallback) => {
|
|
137
131
|
try {
|
|
@@ -146,7 +140,7 @@ export function builtinScenarioDetails(scenarios, deps, branded) {
|
|
|
146
140
|
name, source: "builtin", builtin: true, summary, toolset, tools, promptSummary, enabled: true,
|
|
147
141
|
...availabilityFields(deps, toolset),
|
|
148
142
|
attachmentSupplies: attachmentSuppliesFor(BUILTIN_SCENARIO_HANDS[name], deps.handsLane === true),
|
|
149
|
-
skills: scenarioSkillEntries(deps.skills,
|
|
143
|
+
skills: scenarioSkillEntries(deps.skills, name),
|
|
150
144
|
});
|
|
151
145
|
const brandedScenario = (name) => branded && BRAND_IDENTITY_SCENARIOS.includes(name);
|
|
152
146
|
const details = {
|
|
@@ -220,7 +214,6 @@ function requireRepoClient(deps, scenarioLabel) {
|
|
|
220
214
|
? `${scenarioLabel} scenario has no repo client although the availability owner reports it available (wiring defect)`
|
|
221
215
|
: scenarioUnavailableMessage(verdict.reason, scenarioLabel));
|
|
222
216
|
}
|
|
223
|
-
export const SCENARIO_NAME_RE = /^[a-z][a-z0-9-]{1,31}$/;
|
|
224
217
|
export function centerScenarios(deps, specs, builtinNames, logger) {
|
|
225
218
|
const overlay = {};
|
|
226
219
|
const shadows = [];
|
|
@@ -254,7 +247,7 @@ function codeReview(deps, req) {
|
|
|
254
247
|
}
|
|
255
248
|
const coords = parseRepo(req.repo);
|
|
256
249
|
const repoTools = repoToolsFor(repoClient, coords);
|
|
257
|
-
const skills = skillsForScenario(deps.skills,
|
|
250
|
+
const skills = skillsForScenario(deps.skills, "code-review");
|
|
258
251
|
const hands = BUILTIN_SCENARIO_HANDS["code-review"];
|
|
259
252
|
return { tools: [...repoTools, nowTool()], hands, skills, prompt: { roleText: REVIEWER_ROLE_TEXT } };
|
|
260
253
|
}
|
|
@@ -328,7 +321,7 @@ export function gateScenarioRequest(ruling, bodyScenario, defaultScenario, known
|
|
|
328
321
|
const refusal = danglingScenarioRefusal(name, source, known);
|
|
329
322
|
if (refusal !== undefined) {
|
|
330
323
|
logger?.warn("scenario_assignment_unknown", { scenario: name, source, ...(principal !== undefined ? { principal } : {}) });
|
|
331
|
-
throw createCodedHttpError(503, "state.scenario_assignment_unknown", refusal, {
|
|
324
|
+
throw createCodedHttpError(503, "state.scenario_assignment_unknown", refusal, { scenario: name, source });
|
|
332
325
|
}
|
|
333
326
|
return name;
|
|
334
327
|
}
|
|
@@ -345,6 +338,8 @@ export function createScenarioGate(sources, leg) {
|
|
|
345
338
|
}
|
|
346
339
|
}
|
|
347
340
|
};
|
|
348
|
-
|
|
341
|
+
const known = () => Object.keys(sources.scenarios);
|
|
342
|
+
const gate = async (principal, requested) => gateScenarioRequest(await rulingOf(principal), requested, sources.config.defaultScenario, known(), sources.logger, principal);
|
|
343
|
+
return Object.assign(gate, { known });
|
|
349
344
|
}
|
|
350
345
|
//# sourceMappingURL=scenarios.js.map
|
|
@@ -87,7 +87,7 @@ export declare function loadDeploymentSkills(config: {
|
|
|
87
87
|
readonly provider: ExecutionLane;
|
|
88
88
|
};
|
|
89
89
|
}, logger?: Logger): LoadedSkill[];
|
|
90
|
-
/** 一个技能范围交进 `TaskSpec` 的技能(场景工厂的 `skills`)
|
|
90
|
+
/** 一个技能范围交进 `TaskSpec` 的技能(场景工厂的 `skills`)。**技能范围 = 场景名**,内建与 center 声明的场景一律如此、一处读法(没有范围表):各工厂与场景卡直传自己的场景名。 */
|
|
91
91
|
export declare function skillsForScenario(loaded: readonly LoadedSkill[], scope: string): SkillSpec[];
|
|
92
92
|
/**
|
|
93
93
|
* 技能清单的一条 —— **一张形,两个面**:场景卡(`GET /v1/capabilities/scenarios/:name` 的 `skills[]`,[ref])与 run 级名册
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
* - 🔴 **候选 ≠ 延迟**(core 7.15.0 [ref] 的行为面收窄,本仓两条真后果见下):候选集整体受**一道**
|
|
13
13
|
* 阈值门,全或无 —— 候选的内联字节(name+description+schema)≥ `floor(上下文 token × 10%) × 3`
|
|
14
14
|
* 才延迟,否则**全内联且不挂 `ToolSearch`**。远端协议铸名因此**不再无条件占位**:本仓缺省窗
|
|
15
|
-
* (`
|
|
15
|
+
* (`ASSUMED_CONTEXT_WINDOW`,今天 131072 token)下阈值 = 39 321 字符,一个中小 MCP 名册够不着 ⇒ 首请求带全 schema。
|
|
16
16
|
* 唯一不受门的是调用方的 `TaskSpec.deferTools` 字面名单(按字面恒延迟、不计量)。
|
|
17
17
|
* - `RunnerDeps.deferMode:"auto"` 不是第二道门,而是把候选集**拓宽**到全部 caller spec 后走同一道门 ——
|
|
18
18
|
* 在本仓缺省场景下那会连 Agent 与 Task 四件一起卷进候选(与 CC 姿态相反),所以我们**刻意不开**;
|
|
@@ -25,7 +25,8 @@ import type { ServiceBlobExchange, ServiceFileHistoryStore } from "./plugins/sto
|
|
|
25
25
|
import { resolveStreamApprovalGate, type ApprovalFrameFamily } from "./tool-approval.js";
|
|
26
26
|
import { type WorkspaceSyncCapability } from "./workspace-space.js";
|
|
27
27
|
import type { WorkspaceCacheCapability } from "./workspace-cache.js";
|
|
28
|
-
import type
|
|
28
|
+
import { type HeadRead } from "./session-incarnation.js";
|
|
29
|
+
import type { HistoryAnchorReaders } from "./history-anchor.js";
|
|
29
30
|
import type { EngineHandoverDoor } from "./boot/engine-lease.js";
|
|
30
31
|
/** why 闭集:词 → 给运维看的一句义(诊断 / 测试读它;wire 上的拒句由各门自写)。 */
|
|
31
32
|
export declare const CAPABILITY_FACT_WHY: {
|
|
@@ -38,14 +39,14 @@ export declare const CAPABILITY_FACT_WHY: {
|
|
|
38
39
|
readonly checkpoint_store_absent: "no durable checkpoint store is wired (DURABLE_APPROVAL)";
|
|
39
40
|
readonly session_audit_absent: "no session audit view is wired (needs a durable session store)";
|
|
40
41
|
readonly session_watch_absent: "the session watch registry is not wired";
|
|
41
|
-
readonly session_lister_absent: "no session enumerator is wired (session store
|
|
42
|
+
readonly session_lister_absent: "no session enumerator is wired (the session store has no listSessions)";
|
|
42
43
|
readonly session_fork_face_absent: "the session store has no fork face";
|
|
43
44
|
readonly session_row_faces_absent: "the session store has no session-row faces (headOf / sessionSummaryOf / writeSessionRowCells)";
|
|
44
45
|
readonly session_purge_absent: "no session purge coordinator is wired";
|
|
45
46
|
readonly session_policy_store_absent: "no session policy store is wired";
|
|
46
47
|
readonly store_backend_absent: "no store backend is wired (DB_BACKEND=memory, multi-tenant bare boot, or half-configured SQL)";
|
|
47
48
|
readonly file_history_store_absent: "no file-history store is wired";
|
|
48
|
-
readonly resume_anchor_store_absent: "no rewind anchor map is wired (the handle → session-entry map a rewind target is read through)";
|
|
49
|
+
readonly resume_anchor_store_absent: "no rewind anchor map is wired (the handle → session-entry map a rewind target is read through, with the run store an unknown handle is checked against — both come from the store backend)";
|
|
49
50
|
readonly execution_lane_handless: "the execution lane mounts no execution environment (REMOTE_EXEC=none), so a session has no working tree to rewind";
|
|
50
51
|
readonly workspace_rebuilt_per_task: "each task's workspace is rebuilt when the task starts on this deployment (a fresh directory, container or sandbox, or a restore from the workspace snapshot store that a rewind cannot yet take part in), so a rewind would not land in the tree the next task starts from";
|
|
51
52
|
readonly session_store_shared: "the session store is shared by several server instances (DB_BACKEND=mysql|pg) and no durable claim spans an out-of-run rewind yet, so a rewind could interleave with a run or another rewind started on another instance";
|
|
@@ -101,6 +102,8 @@ export declare const CAPABILITY_FACT_WHY: {
|
|
|
101
102
|
readonly deployment_mod_packages_absent: "no operator-declared mod package was loaded at boot (MODS_ROOT / MODS_PACKAGES)";
|
|
102
103
|
readonly engine_handover_lane_absent: "the attachment lease has no handover lane here: the lease is not armed (neither ENGINE_AUTO_EXIT nor SEMA_PARENT_PID), or the deployment is multi-tenant (REQUIRE_PRINCIPAL=true)";
|
|
103
104
|
readonly engine_lease_stopped: "the attachment lease has stopped observing (this engine is shutting down)";
|
|
105
|
+
readonly auto_background_off: "AUTO_BACKGROUND_ON_TIMEOUT=false: a foreground command that outruns its own timeout is killed";
|
|
106
|
+
readonly lane_cannot_adopt_running_command: "the execution lane's environment cannot move a running command to the background (only the single-user host lane with HOST_BG_ENABLED on, k8s and e2b can), so a command that outruns its timeout is killed whatever AUTO_BACKGROUND_ON_TIMEOUT says";
|
|
104
107
|
};
|
|
105
108
|
export type CapabilityFactWhy = keyof typeof CAPABILITY_FACT_WHY;
|
|
106
109
|
/** 不可用臂。 */
|
|
@@ -170,8 +173,8 @@ export declare function sessionEventStream(d: Pick<Deps, "sessionWatch" | "sessi
|
|
|
170
173
|
sessionStorage: HeadReadingSessionStore;
|
|
171
174
|
}>;
|
|
172
175
|
type SessionLister = NonNullable<OwnerAwareSessionStore["listSessions"]>;
|
|
173
|
-
/**
|
|
174
|
-
export declare function sessionList(d: Pick<Deps, "sessionStorage"
|
|
176
|
+
/** 会话枚举面:会话店的 `listSessions` —— 唯一的会话 lister(run 店不列会话:只有 run 行、没有会话行的面答不了「有哪些会话」)。见证 = 已绑好宿主的那一只。 */
|
|
177
|
+
export declare function sessionList(d: Pick<Deps, "sessionStorage">): Fact<"session_lister_absent", {
|
|
175
178
|
lister: SessionLister;
|
|
176
179
|
}>;
|
|
177
180
|
export declare function sessionFork(d: Pick<Deps, "sessionStorage">): Fact<"session_fork_face_absent" | "session_head_face_absent", {
|
|
@@ -183,9 +186,17 @@ export declare function sessionFork(d: Pick<Deps, "sessionStorage">): Fact<"sess
|
|
|
183
186
|
export declare function sessionPatch(d: Pick<Deps, "sessionStorage">): Fact<"session_row_faces_absent", {
|
|
184
187
|
sessionStorage: WithMethods<OwnerAwareSessionStore, "headOf" | "writeSessionRowCells">;
|
|
185
188
|
}>;
|
|
189
|
+
/** 删除门读的会话店视图:按 id 读 = 删除门那一只头读,行格的 placement 问询 = 店自己的那一只。门照旧由属主存取器读头(`admitSessionById`),读的就是这一只。 */
|
|
190
|
+
type DeletionGateStore = Pick<OwnerAwareSessionStore, "placementOf"> & {
|
|
191
|
+
readonly headOf: HeadRead;
|
|
192
|
+
};
|
|
193
|
+
/**
|
|
194
|
+
* 会话删除面(purge 协调器 ∧ 删除门的头读)。见证 = 协调器 + 删除门的店视图 {@link DeletionGateStore}:按 id 读是 `deletionHeadReadOf`(local 店删到一半的行也答得出属主,
|
|
195
|
+
* 开始删它的那位重发收得完;别的店 = `headOf`)—— 与协调器围栏读同一只。
|
|
196
|
+
*/
|
|
186
197
|
export declare function sessionDelete(d: Pick<Deps, "purgeSession" | "sessionStorage">): Fact<"session_purge_absent" | "session_head_face_absent", {
|
|
187
198
|
purge: Store<"purgeSession">;
|
|
188
|
-
|
|
199
|
+
gateStore: DeletionGateStore;
|
|
189
200
|
}>;
|
|
190
201
|
export declare function sessionPolicy(d: Pick<Deps, "sessionPolicyStore" | "sessionStorage">): Fact<"session_policy_store_absent" | "session_head_face_absent", {
|
|
191
202
|
policyStore: Store<"sessionPolicyStore">;
|
|
@@ -212,16 +223,17 @@ type RewindFilesWhy = "file_history_store_absent" | "session_head_face_absent" |
|
|
|
212
223
|
/**
|
|
213
224
|
* run 外的「只恢复代码」口(`POST /v1/sessions/:id/rewind-files`,[ref])这台部署**解不解得出** —— 能力位 `sessionRewindFiles` 与该口的 501 读这一只。
|
|
214
225
|
* 四格缺一不可,每格都是那一口真要用的设施:文件历史店(引擎 `Runner.rewindFiles` 读的同一只;旋钮 `FILE_HISTORY_CAPTURE` 只关捕获、不摘店,
|
|
215
|
-
* 所以与它无关 —— 已存边界照常可回退)∧ 会话头读(属主门 + 坏档判据)∧
|
|
226
|
+
* 所以与它无关 —— 已存边界照常可回退)∧ 会话头读(属主门 + 坏档判据)∧ 锚店与 run 店(`to` 手柄经锚店翻成 entry id,未知手柄的 404 成因半句读 run 店,
|
|
227
|
+
* `history-anchor.ts`;两只同出存储后端,所以是同一格)∧ 执行车道有手
|
|
216
228
|
* (无手车道上引擎恒拒 `rewind.files_env_unsupported`:没有工作区可回退 —— 位说有而口恒拒不许发生)∧ 即时回退的工作区活过一次执行(部署形表行 `rewindableWorkspace`;
|
|
217
229
|
* 否则恢复的结果到不了下一次执行)∧ 会话店由本进程独占(local 后端:数据根被一个活进程锁住 ⇒ 引擎的进程内会话锁就是全局互斥;
|
|
218
230
|
* SQL 后端被多副本共用,而 run 外回退还没有一只跨副本的持久认领 —— 「先查认领再交引擎」只是检查不是互斥,所以在共享店上位为假、口 501,不留「检查即放行」)。
|
|
219
231
|
* 动词本身是引擎 `Runner` 的必有成员(型上必在),不是一格。
|
|
220
|
-
* 见证 =
|
|
232
|
+
* 见证 = 判过在场的设施(历史店 · 手柄翻译的两只读店 · 会话店);路由在拒臂之后只读见证。
|
|
221
233
|
*/
|
|
222
|
-
export declare function sessionRewindFiles(d: Pick<Deps, "fileHistoryStore" | "resumeAnchorStore" | "sessionStorage" | "config" | "backend">): Fact<RewindFilesWhy, {
|
|
234
|
+
export declare function sessionRewindFiles(d: Pick<Deps, "fileHistoryStore" | "resumeAnchorStore" | "runStore" | "sessionStorage" | "config" | "backend">): Fact<RewindFilesWhy, {
|
|
223
235
|
historyStore: ServiceFileHistoryStore;
|
|
224
|
-
anchors:
|
|
236
|
+
anchors: HistoryAnchorReaders;
|
|
225
237
|
sessionStorage: HeadReadingSessionStore;
|
|
226
238
|
}>;
|
|
227
239
|
/**
|
|
@@ -230,7 +242,7 @@ export declare function sessionRewindFiles(d: Pick<Deps, "fileHistoryStore" | "r
|
|
|
230
242
|
* `previewFileDelta` 不在 core 包根导出面上,本仓不另写一份 —— 等 core 导出它,SQL 店补这一座、本位随之转真,路由零改)。本位为假**不是**口不收 `dryRun`:口照收,答 `preview: null`
|
|
231
243
|
* (「这台给不出统计」≠「什么都不会变」);所以本事实没有 501 拒点,只有能力位读它。
|
|
232
244
|
*/
|
|
233
|
-
export declare function sessionRewindFilesPreview(d: Pick<Deps, "fileHistoryStore" | "resumeAnchorStore" | "sessionStorage" | "config" | "backend">): Fact<RewindFilesWhy | "file_history_preview_absent">;
|
|
245
|
+
export declare function sessionRewindFilesPreview(d: Pick<Deps, "fileHistoryStore" | "resumeAnchorStore" | "runStore" | "sessionStorage" | "config" | "backend">): Fact<RewindFilesWhy | "file_history_preview_absent">;
|
|
234
246
|
/** 持久审批底座(checkpoint 店)在场 —— `/v1/approvals/*` 与 `/v1/assistant/*` 整条车道、会话 wake 都站在它上面。 */
|
|
235
247
|
export declare function checkpointPark(d: Pick<Deps, "checkpointStore">): Fact<"checkpoint_store_absent", {
|
|
236
248
|
checkpointStore: Store<"checkpointStore">;
|
|
@@ -459,6 +471,22 @@ export declare function deploymentModPackages(d: Pick<Deps, "deploymentModPackag
|
|
|
459
471
|
}>;
|
|
460
472
|
/** 自唤醒调度器挂在宿主 env 上:`SCHEDULER_ENABLED` ∧ 单用户 ∧ host 车道。装配(`boot/execution-env.ts`)与能力位同调。 */
|
|
461
473
|
export declare function hostScheduler(c: Pick<ServiceConfig, "schedulerEnabled" | "requirePrincipal" | "remoteExec">): Fact<"scheduler_disabled" | "multi_tenant_deployment" | "not_host_lane">;
|
|
474
|
+
/**
|
|
475
|
+
* 前台命令超时转后台(`AUTO_BACKGROUND_ON_TIMEOUT`)在这台部署上生不生效:旋钮开 ∧ 本车道的执行环境能把**运行中的**命令领养成后台任务。
|
|
476
|
+
* 「能领养」就是执行环境的 `backgroundCapabilities.supportsDetach`,三只声明它的适配器(host / k8s / e2b)上它与后台 shell 的 `supported` 是同一个值,
|
|
477
|
+
* 这个值的**唯一**答者是部署形行 `DEPLOYMENT_SHAPE_PREDICATES.backgroundShell`(读能力表那一位:k8s / e2b 任何租户,host 只单主)—— 适配器与本事实读同一行,
|
|
478
|
+
* 本事实不再自己读能力表的三档。host 另有一个全局关停开关(`HOST_BG_ENABLED`),是旋钮不是部署形,所以只在 host 车道上、在行之上合取:
|
|
479
|
+
* 开关是第二参 `hostBackgroundShellOn`,调用方交 `hostBackgroundShellEnabled()`(host 适配器的能力位读同一只;本模块零 I/O,不自己读 env)。
|
|
480
|
+
* 同读钉 `test/auto-background-on-timeout.test.ts` ③ 逐车道 × 单主 / 多租拿装配出的真执行环境的 `supported` / `supportsDetach` 与本事实、行对读。
|
|
481
|
+
* 旋钮先判:关着的部署不论车道都答 `auto_background_off`(运维旋钮无条件,不支持的车道不拒启,只如实报)。
|
|
482
|
+
* `/health.autoBackgroundOnTimeout` 投它的三词({@link autoBackgroundOnTimeoutWord})。
|
|
483
|
+
*/
|
|
484
|
+
export declare function autoBackgroundOnTimeout(c: Pick<ServiceConfig, "autoBackgroundOnTimeout" | "requirePrincipal" | "remoteExec">, hostBackgroundShellOn: boolean): Fact<"auto_background_off" | "lane_cannot_adopt_running_command">;
|
|
485
|
+
/** `/health.autoBackgroundOnTimeout` 的三词闭集(顺序无语义):`armed` = 生效 · `off` = 部署关了 · `unsupported` = 旋钮开着,但本车道不能把运行中的命令转后台。 */
|
|
486
|
+
export declare const AUTO_BACKGROUND_ON_TIMEOUT_WORDS: readonly ["armed", "off", "unsupported"];
|
|
487
|
+
export type AutoBackgroundOnTimeoutWord = (typeof AUTO_BACKGROUND_ON_TIMEOUT_WORDS)[number];
|
|
488
|
+
/** 事实 → 三词(穷举:事实多一个 why 而这里不接 = 编译红)。 */
|
|
489
|
+
export declare function autoBackgroundOnTimeoutWord(f: ReturnType<typeof autoBackgroundOnTimeout>): AutoBackgroundOnTimeoutWord;
|
|
462
490
|
/** 引擎能力词的事实(core `ENGINE_CAPABILITIES` 每词一只谓词,值 = 本进程的事实;`/v1/capabilities` 以顶层布尔键展开它们)—— 住在
|
|
463
491
|
* `capabilities/engine-capabilities.ts`,这里只是把它纳入「能力位只投影事实」的同一张读面,静态门认 `facts.engineCapabilityBits()` 这一只展开。 */
|
|
464
492
|
export { engineCapabilityBits } from "./capabilities/engine-capabilities.js";
|
package/dist/capability-facts.js
CHANGED
|
@@ -7,7 +7,7 @@ import { centerEntitlementSourceWired } from "./runtime-caps-resolver.js";
|
|
|
7
7
|
import { WEB_ADMIN_ENV } from "@sema-agent/settings-schema";
|
|
8
8
|
import { blobExchangeOf, overwriteWipeIncapable } from "./session-sync.js";
|
|
9
9
|
import { WORKSPACE_PERSIST_DEFAULT, WORKSPACE_SNAPSHOT_KEEP_DEFAULT, workspaceSnapshotTimeoutOf } from "./workspace-space.js";
|
|
10
|
-
import { headReadOf } from "./session-incarnation.js";
|
|
10
|
+
import { deletionHeadReadOf, headReadOf } from "./session-incarnation.js";
|
|
11
11
|
import { laneWiresExecutionEnv } from "./execution-lane-caps.js";
|
|
12
12
|
export const CAPABILITY_FACT_WHY = {
|
|
13
13
|
run_store_absent: "no durable run store is wired (DB_BACKEND=mysql|pg|local)",
|
|
@@ -19,14 +19,14 @@ export const CAPABILITY_FACT_WHY = {
|
|
|
19
19
|
checkpoint_store_absent: "no durable checkpoint store is wired (DURABLE_APPROVAL)",
|
|
20
20
|
session_audit_absent: "no session audit view is wired (needs a durable session store)",
|
|
21
21
|
session_watch_absent: "the session watch registry is not wired",
|
|
22
|
-
session_lister_absent: "no session enumerator is wired (session store
|
|
22
|
+
session_lister_absent: "no session enumerator is wired (the session store has no listSessions)",
|
|
23
23
|
session_fork_face_absent: "the session store has no fork face",
|
|
24
24
|
session_row_faces_absent: "the session store has no session-row faces (headOf / sessionSummaryOf / writeSessionRowCells)",
|
|
25
25
|
session_purge_absent: "no session purge coordinator is wired",
|
|
26
26
|
session_policy_store_absent: "no session policy store is wired",
|
|
27
27
|
store_backend_absent: "no store backend is wired (DB_BACKEND=memory, multi-tenant bare boot, or half-configured SQL)",
|
|
28
28
|
file_history_store_absent: "no file-history store is wired",
|
|
29
|
-
resume_anchor_store_absent: "no rewind anchor map is wired (the handle → session-entry map a rewind target is read through)",
|
|
29
|
+
resume_anchor_store_absent: "no rewind anchor map is wired (the handle → session-entry map a rewind target is read through, with the run store an unknown handle is checked against — both come from the store backend)",
|
|
30
30
|
execution_lane_handless: "the execution lane mounts no execution environment (REMOTE_EXEC=none), so a session has no working tree to rewind",
|
|
31
31
|
workspace_rebuilt_per_task: "each task's workspace is rebuilt when the task starts on this deployment (a fresh directory, container or sandbox, or a restore from the workspace snapshot store that a rewind cannot yet take part in), so a rewind would not land in the tree the next task starts from",
|
|
32
32
|
session_store_shared: "the session store is shared by several server instances (DB_BACKEND=mysql|pg) and no durable claim spans an out-of-run rewind yet, so a rewind could interleave with a run or another rewind started on another instance",
|
|
@@ -82,6 +82,8 @@ export const CAPABILITY_FACT_WHY = {
|
|
|
82
82
|
deployment_mod_packages_absent: "no operator-declared mod package was loaded at boot (MODS_ROOT / MODS_PACKAGES)",
|
|
83
83
|
engine_handover_lane_absent: "the attachment lease has no handover lane here: the lease is not armed (neither ENGINE_AUTO_EXIT nor SEMA_PARENT_PID), or the deployment is multi-tenant (REQUIRE_PRINCIPAL=true)",
|
|
84
84
|
engine_lease_stopped: "the attachment lease has stopped observing (this engine is shutting down)",
|
|
85
|
+
auto_background_off: "AUTO_BACKGROUND_ON_TIMEOUT=false: a foreground command that outruns its own timeout is killed",
|
|
86
|
+
lane_cannot_adopt_running_command: "the execution lane's environment cannot move a running command to the background (only the single-user host lane with HOST_BG_ENABLED on, k8s and e2b can), so a command that outruns its timeout is killed whatever AUTO_BACKGROUND_ON_TIMEOUT says",
|
|
85
87
|
};
|
|
86
88
|
const no = (why) => ({ available: false, why });
|
|
87
89
|
const yes = (w) => ({ available: true, ...w });
|
|
@@ -147,7 +149,7 @@ export function sessionEventStream(d) {
|
|
|
147
149
|
return yes({ watch: d.sessionWatch, sessionStorage: owned.sessionStorage });
|
|
148
150
|
}
|
|
149
151
|
export function sessionList(d) {
|
|
150
|
-
const lister = d.sessionStorage?.listSessions?.bind(d.sessionStorage)
|
|
152
|
+
const lister = d.sessionStorage?.listSessions?.bind(d.sessionStorage);
|
|
151
153
|
return lister !== undefined ? yes({ lister }) : no("session_lister_absent");
|
|
152
154
|
}
|
|
153
155
|
export function sessionFork(d) {
|
|
@@ -170,7 +172,12 @@ export function sessionDelete(d) {
|
|
|
170
172
|
const owned = sessionOwnership(d);
|
|
171
173
|
if (!owned.available)
|
|
172
174
|
return owned;
|
|
173
|
-
|
|
175
|
+
const store = owned.sessionStorage;
|
|
176
|
+
const headOf = deletionHeadReadOf(store);
|
|
177
|
+
if (headOf === undefined)
|
|
178
|
+
return no("session_head_face_absent");
|
|
179
|
+
const placementOf = store.placementOf?.bind(store);
|
|
180
|
+
return yes({ purge: d.purgeSession, gateStore: { headOf, ...(placementOf !== undefined ? { placementOf } : {}) } });
|
|
174
181
|
}
|
|
175
182
|
export function sessionPolicy(d) {
|
|
176
183
|
if (d.sessionPolicyStore === undefined)
|
|
@@ -209,7 +216,7 @@ export function sessionRewindFiles(d) {
|
|
|
209
216
|
const owned = sessionOwnership(d);
|
|
210
217
|
if (!owned.available)
|
|
211
218
|
return owned;
|
|
212
|
-
if (d.resumeAnchorStore === undefined)
|
|
219
|
+
if (d.resumeAnchorStore === undefined || d.runStore === undefined)
|
|
213
220
|
return no("resume_anchor_store_absent");
|
|
214
221
|
if (!laneWiresExecutionEnv(d.config.remoteExec.provider))
|
|
215
222
|
return no("execution_lane_handless");
|
|
@@ -217,7 +224,7 @@ export function sessionRewindFiles(d) {
|
|
|
217
224
|
return no("workspace_rebuilt_per_task");
|
|
218
225
|
if (d.backend?.kind !== "local")
|
|
219
226
|
return no("session_store_shared");
|
|
220
|
-
return yes({ historyStore: d.fileHistoryStore, anchors: d.resumeAnchorStore, sessionStorage: owned.sessionStorage });
|
|
227
|
+
return yes({ historyStore: d.fileHistoryStore, anchors: { anchors: d.resumeAnchorStore, runs: d.runStore }, sessionStorage: owned.sessionStorage });
|
|
221
228
|
}
|
|
222
229
|
export function sessionRewindFilesPreview(d) {
|
|
223
230
|
const rewind = sessionRewindFiles(d);
|
|
@@ -493,5 +500,26 @@ export function hostScheduler(c) {
|
|
|
493
500
|
return no("not_host_lane");
|
|
494
501
|
return YES;
|
|
495
502
|
}
|
|
503
|
+
export function autoBackgroundOnTimeout(c, hostBackgroundShellOn) {
|
|
504
|
+
if (c.autoBackgroundOnTimeout !== true)
|
|
505
|
+
return no("auto_background_off");
|
|
506
|
+
const laneCanAdopt = DEPLOYMENT_SHAPE_PREDICATES.backgroundShell.holds(c) && (c.remoteExec.provider !== "host" || hostBackgroundShellOn);
|
|
507
|
+
return laneCanAdopt ? YES : no("lane_cannot_adopt_running_command");
|
|
508
|
+
}
|
|
509
|
+
export const AUTO_BACKGROUND_ON_TIMEOUT_WORDS = ["armed", "off", "unsupported"];
|
|
510
|
+
export function autoBackgroundOnTimeoutWord(f) {
|
|
511
|
+
if (f.available)
|
|
512
|
+
return "armed";
|
|
513
|
+
switch (f.why) {
|
|
514
|
+
case "auto_background_off":
|
|
515
|
+
return "off";
|
|
516
|
+
case "lane_cannot_adopt_running_command":
|
|
517
|
+
return "unsupported";
|
|
518
|
+
default: {
|
|
519
|
+
const unknownWhy = f.why;
|
|
520
|
+
throw new Error(`auto-background word: unknown why ${String(unknownWhy)}`);
|
|
521
|
+
}
|
|
522
|
+
}
|
|
523
|
+
}
|
|
496
524
|
export { engineCapabilityBits } from "./capabilities/engine-capabilities.js";
|
|
497
525
|
//# sourceMappingURL=capability-facts.js.map
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* **按令牌把一张 pending 卡 CAS expire —— 全仓唯一的读法**(状态读 `get` 交出的行状态,属主格读店的列,CAS 吃那一格)。六个读者同读这一只,没有第二份:
|
|
3
|
+
* · `POST /v1/runs/:id/cancel` 的停驻取消腿(`routes/runs.ts` 的 `cancelSuspended`);
|
|
4
|
+
* · 一条续跑腿被取消之后结算它续的那张卡(`resume-legs.ts` 的 `settleCardForCancel`);
|
|
5
|
+
* · 审批 SLA 拒扫腿对「准入策略挡住」的续跑当场过期该卡(`http/approval-sweeps.ts` 的 `expirePolicyBlockedCard`);
|
|
6
|
+
* · 会话删除 / 显式结清口带走停驻子代时作废它的卡(`session-children-retire.ts` 的 `expireParkedCard`);
|
|
7
|
+
* · 停驻写没落定就以失败收场时作废手里那张卡(`card-void.ts` 的 `voidPendingCard`);
|
|
8
|
+
* · 复活不了的停驻子代被 deny 时作废它的卡(`parked-decide.ts` 的 `voidUnrevivableCard`)。
|
|
9
|
+
*
|
|
10
|
+
* ## 规则一条:顺序恒为「先读状态、(要求归属就)再核归属、最后按存储列 expire」,不读行体里的属主格
|
|
11
|
+
* 一张停驻卡的事实在店里有两份:列(令牌、归属 run 的会话、门型、属主格 `scope` —— 引擎停驻时盖下,身份迁移时与行体里那一份一起迁)与行体(`checkpoint` 里的 JSON 快照)。
|
|
12
|
+
* `expire` 的 CAS 谓词吃的是列;拿行体里自带的那一份去配,行体与列不一致(手改 / 外来写者 / 迁移两腿之间)时只会把「列好体坏」说成「被并发决议了」,行体读不成检查点时更是读行体就抛。
|
|
13
|
+
* 1. **状态**:卡已不在待决面(已结 / 已不在)⇒ 不写 —— 已结的卡上 CAS 恒输,写一次只是多一次店写(店写口故障时那一次还会抛,把「本来什么都不用做」的收场变成失败)。
|
|
14
|
+
* 状态读 `get` 交出的行状态(状态列权威,不是行体快照里那一份);**读不成检查点的行体**({@link UnreadableCheckpointRowError})读不出状态 ⇒ 不替 CAS 判(「不知道」不当作「已结」),
|
|
15
|
+
* 下一步吃列的 CAS 自己判;其余读故障(连库 / 超时 / 程序错)原样上抛,店的故障不是答案。
|
|
16
|
+
* 2. **归属**(调用方要求时):卡的归属会话(`hostSessionOfCard`,列)必须就是调用方说的那只 —— 只作废**这一张**;读不出 / 对不上 ⇒ `host_mismatch`,不写。状态在归属之前:已结的卡不因归属对不上而报警。
|
|
17
|
+
* 3. **属主格**:`peekScopeByToken`(SQL = `scope` 列,local = 账本行),`null` 是店契约里的匿名值,按契约换成公共哨兵(两只真店的属主列非空,到不了这一臂)。
|
|
18
|
+
* 找「取消动词会结算哪一张卡」是取消口自己的事(`run-cancel-card.ts`);本模块只管拿到令牌之后怎么结算。
|
|
19
|
+
*/
|
|
20
|
+
import type { CheckpointToken } from "@sema-agent/core";
|
|
21
|
+
import type { CheckpointStoreFull } from "./plugins/store-backend.js";
|
|
22
|
+
/** 「这张卡此刻的状态」那一问要的店口(只读 `get` 交出的行状态;结构型 —— 真店的 `get` 直接对上)。 */
|
|
23
|
+
export interface CardStatusPort {
|
|
24
|
+
get(token: CheckpointToken): Promise<{
|
|
25
|
+
readonly status?: string;
|
|
26
|
+
} | null>;
|
|
27
|
+
}
|
|
28
|
+
/** 结算一张卡要的店口:状态 + 属主格(店的列)+ CAS expire。六个读者的依赖型都从这一份取,不各自另写一份 `Pick`。 */
|
|
29
|
+
export type CardSettlePort = CardStatusPort & Pick<CheckpointStoreFull, "peekScopeByToken" | "expire">;
|
|
30
|
+
/** 要求归属时多要的一口:卡归在哪只会话上(归属列)。 */
|
|
31
|
+
export type CardHostPort = Pick<CheckpointStoreFull, "hostSessionOfCard">;
|
|
32
|
+
/**
|
|
33
|
+
* 结算的结局(店的事实,不嗅文案):
|
|
34
|
+
* · `expired` —— 本调用亲手把一张 pending 的卡 expire 了;
|
|
35
|
+
* · `not_pending` —— 卡已不在待决面(已结 / 已不在),没写;
|
|
36
|
+
* · `lost` —— 读状态时还 pending、CAS 输给了并发的结算(决定 / 收割 / 别的作废者);
|
|
37
|
+
* · `host_mismatch` —— 调用方要求的归属对不上(或说不出),没写。
|
|
38
|
+
*/
|
|
39
|
+
export declare const CARD_EXPIRE_OUTCOME: {
|
|
40
|
+
readonly expired: "expired";
|
|
41
|
+
readonly notPending: "not_pending";
|
|
42
|
+
readonly lost: "lost";
|
|
43
|
+
readonly hostMismatch: "host_mismatch";
|
|
44
|
+
};
|
|
45
|
+
export type CardExpireOutcome = (typeof CARD_EXPIRE_OUTCOME)[keyof typeof CARD_EXPIRE_OUTCOME];
|
|
46
|
+
/** 调用方要求:这张卡必须归在 `hostSession` 这只会话上(`undefined` = 调用方说不出自己的会话 ⇒ 恒对不上)。 */
|
|
47
|
+
export interface CardHostGuard {
|
|
48
|
+
readonly hostSession: string | undefined;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* 按店里的属主格把 `token` 那张卡 CAS expire(≈ deny 的 reaper 终局;不是 resolve —— 取消意味着 run 死掉,deny-RESUME 会把拒绝喂回模型烧 token),次序见模块头注。
|
|
52
|
+
* 要求归属就给 `guard`(店口多带 {@link CardHostPort});不给 ⇒ 不核归属(令牌是调用方按列找来的,如取消口的 `runCancelCardOf`)。
|
|
53
|
+
*/
|
|
54
|
+
export declare function expireCardUnderStoredScope(cs: CardSettlePort, token: CheckpointToken): Promise<CardExpireOutcome>;
|
|
55
|
+
export declare function expireCardUnderStoredScope(cs: CardSettlePort & CardHostPort, token: CheckpointToken, guard: CardHostGuard): Promise<CardExpireOutcome>;
|
|
56
|
+
//# sourceMappingURL=card-settle-stored-scope.d.ts.map
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { UnreadableCheckpointRowError } from "./plugins/checkpoint-store-face.js";
|
|
2
|
+
import { CHECKPOINT_PUBLIC_SCOPE } from "./security.js";
|
|
3
|
+
export const CARD_EXPIRE_OUTCOME = { expired: "expired", notPending: "not_pending", lost: "lost", hostMismatch: "host_mismatch" };
|
|
4
|
+
async function cardLeftPending(cs, token) {
|
|
5
|
+
try {
|
|
6
|
+
const live = await cs.get(token);
|
|
7
|
+
return live === null || live.status !== "pending";
|
|
8
|
+
}
|
|
9
|
+
catch (e) {
|
|
10
|
+
if (e instanceof UnreadableCheckpointRowError)
|
|
11
|
+
return false;
|
|
12
|
+
throw e;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
export async function expireCardUnderStoredScope(cs, token, guard) {
|
|
16
|
+
if (await cardLeftPending(cs, token))
|
|
17
|
+
return CARD_EXPIRE_OUTCOME.notPending;
|
|
18
|
+
if (guard !== undefined) {
|
|
19
|
+
if (guard.hostSession === undefined || cs.hostSessionOfCard === undefined || (await cs.hostSessionOfCard(token)) !== guard.hostSession)
|
|
20
|
+
return CARD_EXPIRE_OUTCOME.hostMismatch;
|
|
21
|
+
}
|
|
22
|
+
const scope = await cs.peekScopeByToken(token);
|
|
23
|
+
if (scope === undefined)
|
|
24
|
+
return CARD_EXPIRE_OUTCOME.notPending;
|
|
25
|
+
return (await cs.expire(token, scope ?? CHECKPOINT_PUBLIC_SCOPE)) ? CARD_EXPIRE_OUTCOME.expired : CARD_EXPIRE_OUTCOME.lost;
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=card-settle-stored-scope.js.map
|