@sema-agent/server 7.145.0 → 7.147.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 +876 -0
- package/README.md +1 -1
- package/README.zh-CN.md +1 -1
- package/USAGE.md +374 -99
- package/deploy/facts/CHANGES.json +25 -0
- package/deploy/facts/README.md +57 -0
- package/deploy/facts/lanes.json +61 -0
- package/deploy/facts/lanes.schema.json +57 -0
- package/deploy/facts/sandbox-rbac.json +113 -0
- package/deploy/facts/sandbox-rbac.schema.json +74 -0
- package/deploy/facts/sealed-key.json +9 -0
- package/deploy/facts/sealed-key.schema.json +52 -0
- package/deploy/sema-up/README.md +2 -2
- package/deploy/sema-up/chart/templates/_helpers.tpl +41 -0
- package/deploy/sema-up/chart/templates/sandbox-rbac.yaml +47 -7
- package/deploy/sema-up/chart/templates/server-v4pro.yaml +9 -4
- package/deploy/sema-up/chart/templates/server.yaml +9 -4
- package/deploy/sema-up/chart/values.yaml +8 -1
- package/deploy/sema-up/cluster-up.sh +2 -1
- package/deploy/sema-up/lib/flagshape.sh +4 -0
- package/deploy/sema-up/lib/lanes.json +2 -5
- package/deploy/sema-up/sema-up.sh +12 -9
- package/deploy/sema-up/stack/compose.yaml +5 -4
- package/deploy/sema-up/stack/sema-stack-cluster.yaml +34 -17
- package/dist/adoption/import-limits.d.ts +6 -0
- package/dist/adoption/import-limits.js +7 -0
- package/dist/adoption/import.d.ts +62 -0
- package/dist/adoption/import.js +107 -0
- package/dist/adoption/wire.d.ts +52 -0
- package/dist/adoption/wire.js +9 -0
- package/dist/approval-ask-machine.d.ts +2 -2
- package/dist/approval-card.d.ts +7 -16
- package/dist/approval-card.js +0 -4
- package/dist/approval-gate-currency.d.ts +1 -1
- package/dist/approval-gate-currency.js +1 -1
- package/dist/approval-reconciler.d.ts +1 -1
- package/dist/approval.d.ts +3 -3
- package/dist/audit.js +2 -2
- package/dist/bench/s1/live-deps.js +3 -1
- package/dist/boot/crash-last.js +2 -1
- package/dist/boot/deployment-mods.d.ts +11 -1
- package/dist/boot/deployment-mods.js +15 -2
- package/dist/boot/device-lane.js +7 -5
- package/dist/boot/engine-lease.d.ts +195 -22
- package/dist/boot/engine-lease.js +146 -20
- package/dist/boot/execution-env.d.ts +5 -0
- package/dist/boot/execution-env.js +57 -33
- package/dist/boot/execution-lane.d.ts +37 -9
- package/dist/boot/execution-lane.js +74 -20
- package/dist/boot/exit-boundary.d.ts +50 -0
- package/dist/boot/exit-boundary.js +32 -0
- package/dist/boot/exit-last.d.ts +20 -4
- package/dist/boot/exit-last.js +23 -5
- package/dist/boot/governance-seams.d.ts +2 -2
- package/dist/boot/governance-seams.js +1 -0
- package/dist/boot/leader.js +1 -1
- package/dist/boot/memory-boundary.d.ts +11 -11
- package/dist/boot/memory-boundary.js +3 -3
- package/dist/boot/memory-consolidation.d.ts +42 -41
- package/dist/boot/memory-consolidation.js +26 -28
- package/dist/boot/org-memory.js +3 -2
- package/dist/boot/parked-revive-gate.d.ts +1 -1
- package/dist/boot/parked-revive-gate.js +1 -1
- package/dist/boot/reapers.d.ts +12 -4
- package/dist/boot/reapers.js +40 -16
- package/dist/boot/resolve-spec.d.ts +2 -0
- package/dist/boot/resolve-spec.js +126 -123
- package/dist/boot/retention-lane.d.ts +4 -42
- package/dist/boot/runner-deps.js +1 -1
- package/dist/boot/session-faces.d.ts +1 -0
- package/dist/boot/session-faces.js +11 -3
- package/dist/boot/shutdown.js +27 -9
- package/dist/boot/stage-01-config.d.ts +1 -1
- package/dist/boot/stage-01-config.js +7 -3
- package/dist/boot/stage-02-web-admin-pull.d.ts +1 -1
- package/dist/boot/stage-02-web-admin-pull.js +10 -8
- package/dist/boot/stage-03-store-backend.d.ts +2 -1
- package/dist/boot/stage-03-store-backend.js +2 -2
- package/dist/boot/stage-04-stores.d.ts +2 -1
- package/dist/boot/stage-05-execution-env.d.ts +4 -1
- package/dist/boot/stage-05-execution-env.js +6 -6
- package/dist/boot/stage-06-runners.d.ts +5 -2
- package/dist/boot/stage-06-runners.js +12 -13
- package/dist/boot/stage-07-capability-layer.d.ts +5 -2
- package/dist/boot/stage-07-capability-layer.js +7 -7
- package/dist/boot/stage-08-reapers.d.ts +5 -2
- package/dist/boot/stage-08-reapers.js +3 -3
- package/dist/boot/stage-09-leader.d.ts +6 -2
- package/dist/boot/stage-10-http-server.d.ts +6 -2
- package/dist/boot/stage-10-http-server.js +5 -3
- package/dist/boot/stores.d.ts +10 -0
- package/dist/boot/stores.js +53 -26
- package/dist/boot/web-admin.js +3 -3
- package/dist/boot/workflow-orchestration.d.ts +1 -1
- package/dist/boot/workflow-orchestration.js +2 -1
- package/dist/capabilities/center-plugins.d.ts +2 -0
- package/dist/capabilities/center-plugins.js +6 -2
- package/dist/capabilities/composite-members.d.ts +4 -1
- package/dist/capabilities/composite-members.js +4 -1
- package/dist/capabilities/execution-lane.d.ts +7 -7
- package/dist/capabilities/execution-lane.js +2 -2
- package/dist/capabilities/hands-lane.d.ts +1 -1
- package/dist/capabilities/scenarios.d.ts +34 -20
- package/dist/capabilities/scenarios.js +13 -9
- package/dist/capabilities/settings-contract.d.ts +29 -0
- package/dist/capabilities/settings-contract.js +14 -0
- package/dist/capabilities/skills.d.ts +5 -5
- package/dist/capability-facts.d.ts +56 -1
- package/dist/capability-facts.js +59 -8
- package/dist/center-credential-renewer.js +3 -2
- package/dist/checkpoint-ctx-seal-m28.d.ts +1 -1
- package/dist/config-catalog.js +19 -9
- package/dist/config-invariants.d.ts +18 -3
- package/dist/config-invariants.js +36 -19
- package/dist/config-lkg.d.ts +1 -1
- package/dist/config-lkg.js +5 -6
- package/dist/config-provider.d.ts +2 -2
- package/dist/config-provider.js +2 -0
- package/dist/config-types.d.ts +228 -185
- package/dist/config.d.ts +74 -6
- package/dist/config.js +146 -64
- package/dist/degenerate-instrument.js +1 -1
- package/dist/deleted-session-ids.d.ts +19 -0
- package/dist/deleted-session-ids.js +26 -0
- package/dist/deploy-facts.d.ts +155 -0
- package/dist/deploy-facts.js +95 -0
- package/dist/deployment-shape.d.ts +21 -12
- package/dist/deployment-shape.js +24 -6
- package/dist/device-ws-hub.d.ts +48 -3
- package/dist/device-ws-hub.js +48 -2
- package/dist/env-facts.d.ts +7 -5
- package/dist/env-facts.js +10 -6
- package/dist/error-code-family.d.ts +35 -0
- package/dist/error-code-family.js +26 -0
- package/dist/execution-config-root.d.ts +5 -5
- package/dist/execution-config-root.js +5 -5
- package/dist/execution-env-purpose.d.ts +14 -0
- package/dist/execution-env-purpose.js +29 -0
- package/dist/execution-lane-caps.d.ts +49 -86
- package/dist/execution-lane-caps.js +52 -62
- package/dist/execution-placement.d.ts +18 -2
- package/dist/execution-placement.js +19 -0
- package/dist/file-history-disclosure.d.ts +2 -2
- package/dist/fleet/drain-entry.d.ts +46 -3
- package/dist/fleet/drain-entry.js +6 -0
- package/dist/fleet/fleet-bus.d.ts +2 -1
- package/dist/fleet/serving-lease.js +3 -4
- package/dist/history-anchor.d.ts +22 -0
- package/dist/history-anchor.js +14 -0
- package/dist/hooks/branch-transcript.d.ts +1 -1
- package/dist/hooks/branch-transcript.js +1 -0
- package/dist/hooks/classic-stations.d.ts +25 -8
- package/dist/hooks/classic-stations.js +29 -3
- package/dist/hooks/command-spawn.d.ts +1 -4
- package/dist/hooks/command-spawn.js +0 -11
- package/dist/hooks/hook-runner.d.ts +85 -24
- package/dist/hooks/hook-runner.js +326 -109
- package/dist/hooks/hook-source.d.ts +14 -2
- package/dist/hooks/hook-source.js +8 -0
- package/dist/http/active-run-conflict.d.ts +1 -1
- package/dist/http/active-run-conflict.js +1 -1
- package/dist/http/admission.js +11 -1
- package/dist/http/approval-sweeps.d.ts +2 -5
- package/dist/http/approval-sweeps.js +3 -2
- package/dist/http/checkpoint-ctx.d.ts +76 -71
- package/dist/http/checkpoint-ctx.js +40 -40
- package/dist/http/claim-latency.d.ts +10 -0
- package/dist/http/claim-latency.js +12 -0
- package/dist/http/dispatch.js +19 -3
- package/dist/http/durable-run-leg.d.ts +5 -0
- package/dist/http/durable-run-leg.js +3 -1
- package/dist/http/execution-context.d.ts +7 -1
- package/dist/http/execution-context.js +13 -0
- package/dist/http/health-self-report.d.ts +6 -2
- package/dist/http/health-self-report.js +3 -2
- package/dist/http/memory-compliance-failure-reply.d.ts +2 -2
- package/dist/http/memory-compliance-failure-reply.js +5 -15
- package/dist/http/memory-control-plane-corrupt-reply.d.ts +25 -0
- package/dist/http/memory-control-plane-corrupt-reply.js +19 -0
- package/dist/http/memory-store-refusal-reply.d.ts +3 -3
- package/dist/http/memory-store-refusal-reply.js +3 -0
- package/dist/http/owner-access.d.ts +11 -0
- package/dist/http/owner-access.js +7 -4
- package/dist/http/principal-gate.d.ts +28 -16
- package/dist/http/principal-gate.js +10 -19
- package/dist/http/request-guards.d.ts +2 -2
- package/dist/http/request-guards.js +5 -5
- package/dist/http/resume-legs.d.ts +29 -10
- package/dist/http/resume-legs.js +94 -56
- package/dist/http/rewind-files-reply.d.ts +34 -0
- package/dist/http/rewind-files-reply.js +36 -0
- package/dist/http/route-ctx.d.ts +43 -26
- package/dist/http/route-table.js +4 -0
- package/dist/http/routes/adoption.d.ts +11 -0
- package/dist/http/routes/adoption.js +80 -6
- package/dist/http/routes/agents-roster.js +1 -0
- package/dist/http/routes/approvals-assistant.js +7 -26
- package/dist/http/routes/background.js +1 -0
- package/dist/http/routes/capabilities.js +12 -3
- package/dist/http/routes/devices.js +1 -1
- package/dist/http/routes/diagnostics.d.ts +9 -14
- package/dist/http/routes/diagnostics.js +10 -20
- package/dist/http/routes/engine.d.ts +31 -0
- package/dist/http/routes/engine.js +81 -0
- package/dist/http/routes/memory-bundle.js +3 -0
- package/dist/http/routes/memory-consolidation.js +3 -5
- package/dist/http/routes/memory-origin.d.ts +2 -2
- package/dist/http/routes/memory-origin.js +2 -4
- package/dist/http/routes/memory-policy.js +5 -1
- package/dist/http/routes/notify-wake.js +2 -1
- package/dist/http/routes/observability.js +3 -6
- package/dist/http/routes/projects.d.ts +70 -0
- package/dist/http/routes/projects.js +86 -0
- package/dist/http/routes/rules.js +30 -2
- package/dist/http/routes/runs.js +15 -11
- package/dist/http/routes/session-sync.js +39 -35
- package/dist/http/routes/sessions-list.d.ts +1 -1
- package/dist/http/routes/sessions.d.ts +7 -1
- package/dist/http/routes/sessions.js +108 -2
- package/dist/http/routes/tasks.js +32 -8
- package/dist/http/routes/trace-usage.js +1 -1
- package/dist/http/run-concurrency-cap.d.ts +86 -0
- package/dist/http/run-concurrency-cap.js +54 -0
- package/dist/http/server.d.ts +31 -14
- package/dist/http/server.js +29 -3
- package/dist/http/stored-body-replay.d.ts +12 -7
- package/dist/http/stored-body-replay.js +28 -5
- package/dist/http/wire-types.d.ts +27 -13
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/instruction-source-notice.d.ts +1 -1
- package/dist/json-body-limit.d.ts +8 -0
- package/dist/json-body-limit.js +2 -0
- package/dist/leader/diffout.d.ts +1 -1
- package/dist/local-data-root.d.ts +2 -2
- package/dist/memory-embedder-reembed.d.ts +38 -0
- package/dist/memory-embedder-reembed.js +20 -0
- package/dist/memory-incident-sink.d.ts +0 -28
- package/dist/memory-incident-sink.js +5 -0
- package/dist/memory-operator-faces.d.ts +9 -4
- package/dist/memory-scope-stores.d.ts +9 -7
- package/dist/memory-scope-stores.js +3 -14
- package/dist/memory-scope.d.ts +38 -2
- package/dist/memory-scope.js +33 -2
- package/dist/memory-store-refusal.d.ts +17 -4
- package/dist/memory-store-refusal.js +1 -1
- package/dist/memory-sync-client.d.ts +2 -0
- package/dist/memory-sync-client.js +13 -11
- package/dist/memory-sync.js +1 -1
- package/dist/model-compat.d.ts +35 -21
- package/dist/model-compat.js +49 -21
- package/dist/model-entry-refusal.d.ts +11 -1
- package/dist/model-entry-refusal.js +7 -0
- package/dist/namespaced-rule-name.d.ts +18 -1
- package/dist/namespaced-rule-name.js +12 -0
- package/dist/net-address.d.ts +53 -0
- package/dist/net-address.js +111 -0
- package/dist/observability/fail-open.d.ts +29 -17
- package/dist/observability/fail-open.js +29 -17
- package/dist/observability/metrics.d.ts +2 -0
- package/dist/observability/metrics.js +2 -0
- package/dist/observability/secret-env-scrub.d.ts +30 -4
- package/dist/observability/secret-env-scrub.js +15 -3
- package/dist/orchestration/workflow-agent-session-index.d.ts +7 -12
- package/dist/orchestration/workflow-agent-session-index.js +1 -6
- package/dist/orchestration/workflow-completion-inbox.d.ts +26 -6
- package/dist/orchestration/workflow-completion-inbox.js +63 -45
- package/dist/orchestration/workflow-notify-journal.js +2 -3
- package/dist/org-delivery-gate.js +1 -1
- package/dist/org-memory-admission.d.ts +5 -2
- package/dist/org-memory-admission.js +25 -10
- package/dist/parked-decide.d.ts +33 -26
- package/dist/parked-decide.js +36 -44
- package/dist/peer-directory.d.ts +6 -12
- package/dist/peer-directory.js +5 -1
- package/dist/plugins/approval-ask-store-file.d.ts +10 -2
- package/dist/plugins/approval-ask-store-file.js +37 -4
- package/dist/plugins/approval-ask-store-memory.d.ts +5 -3
- package/dist/plugins/approval-ask-store-memory.js +11 -2
- package/dist/plugins/approval-ask-store-sql.d.ts +3 -0
- package/dist/plugins/approval-ask-store-sql.js +3 -1
- package/dist/plugins/blob-backend.d.ts +38 -195
- package/dist/plugins/blob-backend.js +33 -229
- package/dist/plugins/caching-session-store.d.ts +12 -5
- package/dist/plugins/caching-session-store.js +3 -0
- package/dist/plugins/checkpoint-index-columns.d.ts +1 -1
- package/dist/plugins/checkpoint-index-columns.js +3 -2
- package/dist/plugins/checkpoint-store-face.d.ts +426 -0
- package/dist/plugins/checkpoint-store-face.js +152 -0
- package/dist/plugins/device-store-sql.d.ts +2 -2
- package/dist/plugins/device-store-sql.js +5 -10
- package/dist/plugins/execution-lane-rename-m40.d.ts +20 -0
- package/dist/plugins/execution-lane-rename-m40.js +10 -0
- package/dist/plugins/execution-placement-sql.d.ts +63 -88
- package/dist/plugins/execution-placement-sql.js +94 -54
- package/dist/plugins/file-run-store.d.ts +26 -18
- package/dist/plugins/file-run-store.js +64 -75
- package/dist/plugins/fork-routing-session-store.d.ts +6 -2
- package/dist/plugins/fork-routing-session-store.js +2 -2
- package/dist/plugins/imported-layer-root-retirement.d.ts +22 -11
- package/dist/plugins/imported-layer-root-retirement.js +4 -8
- package/dist/plugins/inbox-payload-column.d.ts +14 -0
- package/dist/plugins/inbox-payload-column.js +13 -0
- package/dist/plugins/local-checkpoint-store.d.ts +7 -2
- package/dist/plugins/local-checkpoint-store.js +13 -8
- package/dist/plugins/local-data-dir-modes-m39.d.ts +48 -0
- package/dist/plugins/local-data-dir-modes-m39.js +182 -0
- package/dist/plugins/local-engine-high-water.d.ts +11 -0
- package/dist/plugins/local-engine-high-water.js +59 -0
- package/dist/plugins/local-session-store.d.ts +119 -30
- package/dist/plugins/local-session-store.js +156 -53
- package/dist/plugins/local-task-attachment-store.d.ts +2 -0
- package/dist/plugins/local-task-attachment-store.js +10 -11
- package/dist/plugins/memory-embedder-fingerprint.d.ts +33 -10
- package/dist/plugins/memory-embedder-fingerprint.js +52 -12
- package/dist/plugins/memory-embedder.d.ts +1 -1
- package/dist/plugins/memory-embedder.js +2 -2
- package/dist/plugins/memory-engine-pg.d.ts +30 -6
- package/dist/plugins/memory-engine-pg.js +96 -214
- package/dist/plugins/memory-engine-sql-apply.d.ts +130 -0
- package/dist/plugins/memory-engine-sql-apply.js +358 -0
- package/dist/plugins/memory-engine-tidb.d.ts +38 -9
- package/dist/plugins/memory-engine-tidb.js +99 -230
- package/dist/plugins/memory-key-guards.d.ts +1 -1
- package/dist/plugins/memory-origin-law.d.ts +3 -3
- package/dist/plugins/one-time-migrations.d.ts +169 -83
- package/dist/plugins/one-time-migrations.js +295 -235
- package/dist/plugins/owner-only-file-mode.d.ts +29 -0
- package/dist/plugins/owner-only-file-mode.js +141 -0
- package/dist/plugins/permission-rule-store-file.d.ts +17 -3
- package/dist/plugins/permission-rule-store-file.js +20 -1
- package/dist/plugins/pg-pool.d.ts +2 -1
- package/dist/plugins/pg-pool.js +12 -5
- package/dist/plugins/release-version.d.ts +20 -0
- package/dist/plugins/release-version.js +28 -0
- package/dist/plugins/remote-env-adb.d.ts +20 -4
- package/dist/plugins/remote-env-adb.js +39 -11
- package/dist/plugins/remote-env-e2b.d.ts +12 -3
- package/dist/plugins/remote-env-e2b.js +6 -4
- package/dist/plugins/remote-env-host.d.ts +9 -1
- package/dist/plugins/remote-env-host.js +6 -5
- package/dist/plugins/remote-env-k8s.d.ts +5 -2
- package/dist/plugins/remote-env-k8s.js +15 -4
- package/dist/plugins/remote-env-local-docker.d.ts +4 -1
- package/dist/plugins/remote-env-local-docker.js +3 -3
- package/dist/plugins/remote-env-ssh.d.ts +8 -2
- package/dist/plugins/remote-env-ssh.js +26 -24
- package/dist/plugins/remote-shell.d.ts +59 -30
- package/dist/plugins/remote-shell.js +175 -62
- package/dist/plugins/retention-declaration.d.ts +37 -0
- package/dist/plugins/retention-declaration.js +9 -0
- package/dist/plugins/retention-deployment.d.ts +126 -0
- package/dist/plugins/retention-deployment.js +88 -0
- package/dist/plugins/retention-lane-store-sql.d.ts +74 -4
- package/dist/plugins/retention-lane-store-sql.js +103 -1
- package/dist/plugins/retention-sql.d.ts +29 -0
- package/dist/plugins/retention-sql.js +8 -0
- package/dist/plugins/run-store-sql.js +2 -2
- package/dist/plugins/schema-consistency.d.ts +0 -6
- package/dist/plugins/schema-consistency.js +1 -2
- package/dist/plugins/schema-ensure-legs.d.ts +1 -1
- package/dist/plugins/schema-ensure-legs.js +13 -3
- package/dist/plugins/session-ext-table.d.ts +74 -0
- package/dist/plugins/session-ext-table.js +121 -0
- package/dist/plugins/session-fork.d.ts +31 -9
- package/dist/plugins/session-fork.js +3 -2
- package/dist/plugins/session-placement.d.ts +4 -2
- package/dist/plugins/session-row-sql.d.ts +8 -7
- package/dist/plugins/session-row-sql.js +15 -7
- package/dist/plugins/session-store-sql.d.ts +131 -0
- package/dist/plugins/session-store-sql.js +298 -0
- package/dist/plugins/session-workspace-cell.d.ts +2 -2
- package/dist/plugins/session-workspace-cell.js +2 -2
- package/dist/plugins/shared-memory-store-sql.d.ts +10 -0
- package/dist/plugins/shared-memory-store-sql.js +13 -13
- package/dist/plugins/snapshot-bucket-presence.js +1 -1
- package/dist/plugins/sql-driver.d.ts +23 -7
- package/dist/plugins/sql-driver.js +41 -8
- package/dist/plugins/sql-errors.d.ts +5 -2
- package/dist/plugins/sql-errors.js +4 -0
- package/dist/plugins/sql-json-column.d.ts +5 -1
- package/dist/plugins/store-backend.d.ts +46 -16
- package/dist/plugins/store-backend.js +192 -69
- package/dist/plugins/store-contracts.d.ts +10 -13
- package/dist/plugins/store-contracts.js +1 -9
- package/dist/plugins/store-sweep.d.ts +63 -0
- package/dist/plugins/store-sweep.js +48 -0
- package/dist/plugins/task-attachment-store.d.ts +6 -8
- package/dist/plugins/task-attachment-store.js +15 -10
- package/dist/plugins/task-list-store-sql.d.ts +1 -1
- package/dist/plugins/text-column-capacity.d.ts +21 -0
- package/dist/plugins/text-column-capacity.js +5 -0
- package/dist/plugins/tidb-pool.d.ts +3 -2
- package/dist/plugins/tidb-pool.js +20 -32
- package/dist/plugins/user-input-ledger-sql.d.ts +1 -1
- package/dist/prompt-screen.d.ts +6 -9
- package/dist/prompt-screen.js +2 -5
- package/dist/read-face-posture.d.ts +6 -6
- package/dist/read-face-posture.js +2 -2
- package/dist/request-value-closure.d.ts +5 -5
- package/dist/request-value-closure.js +1 -1
- package/dist/rules-consent.d.ts +48 -27
- package/dist/rules-consent.js +147 -23
- package/dist/run-cancel-context.d.ts +4 -1
- package/dist/run-cancel-context.js +2 -1
- package/dist/run-local.js +17 -13
- package/dist/runs.d.ts +48 -30
- package/dist/runs.js +27 -17
- package/dist/runtime-caps-resolver.d.ts +15 -8
- package/dist/runtime-caps-resolver.js +14 -10
- package/dist/sandbox-egress-policy.js +6 -11
- package/dist/sandbox-rbac-rules.d.ts +88 -0
- package/dist/sandbox-rbac-rules.js +80 -0
- package/dist/sealed-key-layout.d.ts +16 -0
- package/dist/sealed-key-layout.js +3 -0
- package/dist/sealed-key.js +8 -6
- package/dist/security.d.ts +43 -9
- package/dist/security.js +9 -2
- package/dist/sema-config-dir.js +2 -2
- package/dist/server-secret-env.d.ts +2 -0
- package/dist/service-version.d.ts +2 -1
- package/dist/service-version.js +2 -2
- package/dist/session-error-wire.d.ts +1 -1
- package/dist/session-incarnation.d.ts +8 -5
- package/dist/session-notify-door.d.ts +5 -3
- package/dist/session-resident-background.d.ts +110 -0
- package/dist/session-resident-background.js +88 -0
- package/dist/session-row.d.ts +1 -1
- package/dist/session-sync-kernel.d.ts +53 -14
- package/dist/session-sync-kernel.js +70 -1
- package/dist/session-sync.d.ts +5 -3
- package/dist/session-workspace.d.ts +12 -2
- package/dist/session-workspace.js +6 -0
- package/dist/sighup-idle.d.ts +9 -7
- package/dist/sighup-idle.js +4 -5
- package/dist/spec-fields.d.ts +16 -0
- package/dist/spec-fields.js +7 -0
- package/dist/store-posture.d.ts +2 -1
- package/dist/stored-request-env-credentials-m38.d.ts +3 -0
- package/dist/stored-request-env-credentials-m38.js +8 -0
- package/dist/stored-request-hooks-m20.d.ts +3 -2
- package/dist/stored-request-hooks-m20.js +19 -14
- package/dist/stored-request-prompt-profile-m30.d.ts +1 -1
- package/dist/stores-sql/blob-index-sql.d.ts +148 -0
- package/dist/stores-sql/blob-index-sql.js +154 -0
- package/dist/{plugins → stores-sql}/checkpoint-store-sql.d.ts +14 -428
- package/dist/{plugins → stores-sql}/checkpoint-store-sql.js +43 -220
- package/dist/{plugins → stores-sql}/file-history-store-sql.d.ts +23 -11
- package/dist/{plugins → stores-sql}/file-history-store-sql.js +23 -18
- package/dist/{plugins → stores-sql}/mailbox-store-sql.d.ts +2 -2
- package/dist/{plugins → stores-sql}/mailbox-store-sql.js +4 -4
- package/dist/{plugins → stores-sql}/pg-session-storage.d.ts +27 -67
- package/dist/{plugins → stores-sql}/pg-session-storage.js +82 -207
- package/dist/{plugins → stores-sql}/retention-store-sql.d.ts +123 -217
- package/dist/{plugins → stores-sql}/retention-store-sql.js +66 -190
- package/dist/{plugins → stores-sql}/roster-store-sql.d.ts +2 -2
- package/dist/{plugins → stores-sql}/roster-store-sql.js +1 -1
- package/dist/{plugins → stores-sql}/session-event-payload.d.ts +1 -1
- package/dist/{plugins → stores-sql}/session-event-payload.js +1 -1
- package/dist/stores-sql/session-policy-store-sql.d.ts +1 -1
- package/dist/stores-sql/session-write-hooks.d.ts +59 -0
- package/dist/stores-sql/session-write-hooks.js +2 -0
- package/dist/{plugins → stores-sql}/tidb-session-storage.d.ts +10 -11
- package/dist/{plugins → stores-sql}/tidb-session-storage.js +10 -21
- package/dist/{plugins → stores-sql}/tidb-session-store.d.ts +35 -112
- package/dist/{plugins → stores-sql}/tidb-session-store.js +73 -169
- package/dist/{plugins → stores-sql}/tool-result-store-sql.d.ts +3 -3
- package/dist/{plugins → stores-sql}/tool-result-store-sql.js +6 -6
- package/dist/stores-sql/windowed-session-storage.d.ts +56 -0
- package/dist/stores-sql/windowed-session-storage.js +61 -0
- package/dist/{plugins → stores-sql}/workflow-journal-store-sql.d.ts +7 -12
- package/dist/{plugins → stores-sql}/workflow-journal-store-sql.js +3 -8
- package/dist/task-a2a.d.ts +7 -1
- package/dist/task-a2a.js +15 -14
- package/dist/task-cwd.d.ts +11 -3
- package/dist/task-cwd.js +17 -1
- package/dist/task-mcp.d.ts +10 -2
- package/dist/task-mcp.js +13 -16
- package/dist/task-settings.d.ts +68 -8
- package/dist/task-settings.js +63 -6
- package/dist/tool-approval.d.ts +23 -10
- package/dist/tool-approval.js +10 -6
- package/dist/trace/core-keyset-guard.d.ts +17 -10
- package/dist/trace/engine-notice-wire.d.ts +1 -1
- package/dist/trace/engine-notice-wire.js +4 -0
- package/dist/trace/exit-seat.d.ts +29 -1
- package/dist/trace/exit-seat.js +4 -0
- package/dist/trace/project.d.ts +33 -16
- package/dist/trace/project.js +21 -9
- package/dist/trace/redact.d.ts +13 -2
- package/dist/trace/redact.js +347 -78
- package/dist/trace/self-minted-wire.d.ts +587 -16
- package/dist/trace/self-minted-wire.js +215 -9
- package/dist/trace/sema-provenance.d.ts +45 -41
- package/dist/trace/sema-provenance.js +81 -10
- package/dist/trace/task-notification-facets.d.ts +70 -2
- package/dist/trace/task-notification-facets.js +71 -1
- package/dist/trace/wire-projection-faces.d.ts +39 -3
- package/dist/trace/wire-projection-faces.js +27 -2
- package/dist/unread-request-members.d.ts +66 -0
- package/dist/unread-request-members.js +41 -0
- package/dist/usage-analytics.d.ts +4 -0
- package/dist/user-input-ledger.d.ts +2 -2
- package/dist/web-admin-client/apply-effective.js +22 -26
- package/dist/web-admin-client/candidate-gate.d.ts +35 -3
- package/dist/web-admin-client/candidate-gate.js +53 -5
- package/dist/web-admin-client/center-request.d.ts +4 -1
- package/dist/web-admin-client/center-request.js +2 -1
- package/dist/web-admin-client/effective-keys.js +0 -1
- package/dist/web-admin-client/facade.d.ts +1 -1
- package/dist/web-admin-client/http-client.d.ts +1 -0
- package/dist/web-admin-client/http-client.js +17 -9
- package/dist/web-admin-client/restart-signal.js +5 -2
- package/dist/web-admin-client/skills-mcp.d.ts +20 -6
- package/dist/web-admin-client/skills-mcp.js +26 -21
- package/dist/web-admin-client/types.d.ts +34 -49
- package/docs/DEVICE-EXECUTOR-PROTOCOL.md +2 -2
- package/package.json +22 -13
- package/scripts/drain-check-local.mjs +8 -55
- package/scripts/drain-check.mysql.sql +3 -40
- package/scripts/drain-check.pg.sql +3 -40
- package/skills/update-config.md +1 -1
- package/wire-changes/server@7.146.0.json +3221 -0
- package/wire-changes/server@7.147.0.json +813 -0
- package/dist/approval-batch-census.d.ts +0 -27
- package/dist/approval-batch-census.js +0 -27
package/dist/http/route-ctx.d.ts
CHANGED
|
@@ -19,7 +19,7 @@ import type { HostDecision } from "../host-decision.js";
|
|
|
19
19
|
import type { EntryProblem } from "../entry-problems.js";
|
|
20
20
|
import type { SessionOwnerCell } from "../security.js";
|
|
21
21
|
import type { SessionNotifyDoor } from "../session-notify-door.js";
|
|
22
|
-
import type { TaskStream, TaskSpec, TaskResult, QuestionAnswer, Checkpoint, CheckpointToken, ResumeOutcome, RunInternals, Runner, EngineNotice } from "@sema-agent/core";
|
|
22
|
+
import type { TaskStream, TaskSpec, TaskResult, QuestionAnswer, Checkpoint, CheckpointToken, ResumeOutcome, RunInternals, Runner, EngineNotice, PendingSteerInput } from "@sema-agent/core";
|
|
23
23
|
import type { FlatServiceDeps, RequestAuth } from "./server.js";
|
|
24
24
|
import type { TaskRequestBody, DecideBinding } from "./wire-types.js";
|
|
25
25
|
import type { IdempotencyCache, SubmitOutcome } from "./idempotency.js";
|
|
@@ -36,6 +36,7 @@ import type { PeerLease } from "../peer-seat.js";
|
|
|
36
36
|
import type { RootedTaskSpec } from "./execution-context.js";
|
|
37
37
|
import type { GateCommitment, GateSettlementEvidence } from "../gate-settlement.js";
|
|
38
38
|
import type { ResumeRestatement } from "./resume-restatement.js";
|
|
39
|
+
import type { RememberLaneCannotRecord } from "../parked-decide.js";
|
|
39
40
|
/** 跨域可变状态 = lens1 §C2 实测的那 8 条「运行期登记簿」,一个对象。
|
|
40
41
|
* [ref]:`cancelledViaVerb`(按 taskId 键控的「这次是取消动词」旁表)删除 —— 中止成因改挂在每条腿自己的
|
|
41
42
|
* {@link RunAbort} 句柄上(`inflightRuns` 的值),同寿同删,不再有一张与腿不同寿的旁表。 */
|
|
@@ -79,6 +80,12 @@ export interface RouteHelpers {
|
|
|
79
80
|
ownerLeaseDenied(res: ServerResponse, owner: string | undefined): Promise<boolean>;
|
|
80
81
|
/** [ref]-T1:治理窗 pre-admission(异步 202 车道的唯一 429 出路;key 公式与 core 单源)。 */
|
|
81
82
|
usageWindowDenied(req: IncomingMessage, res: ServerResponse): Promise<boolean>;
|
|
83
|
+
/**
|
|
84
|
+
* 在飞 run 并发帽的提交门准入(`RUN_MAX_CONCURRENT*`,缺省关;判据、席位与拒的形全文在 `http/run-concurrency-cap.ts`):放行 ⇒ 席位(登记那一拍与 `finally` 放);
|
|
85
|
+
* 超帽 ⇒ 已应答 429 + `Retry-After`、回 `undefined`。只挂**新提交**门(`createDurableRun` / `POST /v1/tasks` / `POST /v1/tasks/stream`),
|
|
86
|
+
* 排在幂等重放与 `usageWindowDenied` 之后、任何建行 / 认领 / SSE 头之前。
|
|
87
|
+
*/
|
|
88
|
+
admitRun(req: IncomingMessage, res: ServerResponse): import("./run-concurrency-cap.js").RunSlot | undefined;
|
|
82
89
|
safeDecode(seg: string): string | null;
|
|
83
90
|
/** run 面的属主门(谓词 `runOwnerReadable`;非属主 ⇒ 404 `not_found.run` + 长文,与 run 读口的 unknown 臂同码同串,[ref])。 */
|
|
84
91
|
runOwnerOk(req: IncomingMessage, res: ServerResponse, owner: string | null): boolean;
|
|
@@ -191,17 +198,10 @@ export interface CheckpointCtx {
|
|
|
191
198
|
* 传原 ctx / 其展开 ⇒ 标随行。缺席 = 不是无人值守腿(HTTP 提交腿;7.106.0 前落盘的行 —— 那时这些腿不铸模式,checkpoint 里也没有)。
|
|
192
199
|
*/
|
|
193
200
|
unattendedLeg?: true;
|
|
194
|
-
/**
|
|
195
|
-
* 体里 `settings.permissions.allow` 的**读法记号**(闭集只有当前读法一词 `"allow_layer"`):在场 = 这一行是当前读法下写下的、体里带非空 `allow`,
|
|
196
|
-
* 它按「交给引擎的 allow 层」写、也按它读。**服务端写、不来自请求体**(与 {@link unattendedLeg} 同为 `body` 的兄弟键)。
|
|
197
|
-
* 缺席(≤7.114.0,名单时代)或旧词 `"statement"`(7.115.0–7.116.x,表态时代)而体里带非空 `allow` ⇒ 续跑腿响亮拒、行字节不动(规则与删除条件的属主 = `http/checkpoint-ctx.ts` 顶注)。
|
|
198
|
-
* 写点只有 `buildCheckpointCtx`(同模块;新的持久化写);续跑腿的写回传原 ctx / 其展开 ⇒ 记号随行。体里没有 `allow` 的行不写它。
|
|
199
|
-
*/
|
|
200
|
-
permissionsAllowReading?: import("./checkpoint-ctx.js").PermissionsAllowReading;
|
|
201
201
|
/**
|
|
202
202
|
* 体里**模式词的读法记号**(闭集只有当前一词 `"entry_word"`):在场 = 这一行体的顶层 `permissionMode` 是这条 run 模式词唯一的源(提交入口盖过运维
|
|
203
203
|
* `AUTONOMY=plan` 的地板;`plan_review` 写回改它),续跑照它读。**服务端写、不来自请求体**。缺席(7.121.x 及以前写下的行 —— 那时运维的 plan 由治理层每段重钳)
|
|
204
|
-
* 而本部署此刻有入口地板、体的词被地板钳会变 ⇒ 续跑腿响亮拒、行字节不动(规则与删除条件的属主 = `http/checkpoint-ctx.ts`
|
|
204
|
+
* 而本部署此刻有入口地板、体的词被地板钳会变 ⇒ 续跑腿响亮拒、行字节不动(规则与删除条件的属主 = `http/checkpoint-ctx.ts` 顶注「模式词问」)。
|
|
205
205
|
* 写点两个(写模式词的人盖记号,同模块):`buildCheckpointCtx`(每一次新的持久化写都写)与 `withPermissionModeRewritten`(`plan_review` 改词的写回);
|
|
206
206
|
* 不改词的续跑腿写回传原 ctx ⇒ 记号随行。
|
|
207
207
|
*/
|
|
@@ -210,8 +210,10 @@ export interface CheckpointCtx {
|
|
|
210
210
|
* 🔴 [ref] —— **写这份上下文的服务版本**(`package.json` 的 `version`),**服务端写、不来自请求体**(与 {@link unattendedLeg} 同为 `body` 的兄弟键)。
|
|
211
211
|
* 写点两个:`buildCheckpointCtx`(每一次新的持久化写)与续跑腿的写回({@link DriveResumeArgs.resumeCtx} 的唯一写点,CAS 赢点盖本进程的版本 —— 接下来写下一张停车行的就是它)。
|
|
212
212
|
* 读者:`checkpoint.unsupported_version` 的 409 体 —— 原样带出 `writerVersion`,与本引擎的 `readerVersion` 并列(运维据此知道该回哪一版去决);
|
|
213
|
-
* 两键唯一铸法 `checkpoint-ctx.ts` `buildCheckpointVersionKeys
|
|
214
|
-
*
|
|
213
|
+
* 两键唯一铸法 `checkpoint-ctx.ts` `buildCheckpointVersionKeys`,本码每个铸点同调。
|
|
214
|
+
* 另一个读者(唯一的拒因读者):存体重放判据的 allow 读法问(`checkpoint-ctx.ts` 顶注)—— 体里带非空 `settings.permissions.allow` 而本格证不出 ≥ 7.117.0 ⇒ 拒。
|
|
215
|
+
* 所以写点守一条律:盖本格的写只在本进程按当前读法读过这份体之后(新提交;或已过存体重放判据的续跑写回),在判据之前盖 = 把旧行洗成新行。
|
|
216
|
+
* 缺席 = 7.124.0 之前写下的行(不回填):那一码的体不带两键,如实不猜;allow 读法问把它读作「证不出」。不是一次性迁移 —— 这一格是常设的事实位,没有删除条件。
|
|
215
217
|
*/
|
|
216
218
|
writerVersion?: string;
|
|
217
219
|
/**
|
|
@@ -420,6 +422,7 @@ export interface PreparedPlanReview {
|
|
|
420
422
|
readonly sessionId: string;
|
|
421
423
|
readonly token: CheckpointToken;
|
|
422
424
|
readonly cp: Checkpoint;
|
|
425
|
+
/** 这条决断唯一的一次 ctx 读,**已盖过**续跑请求的重述键(缺席 = 存量体原样):存体预判判的、驱动段重建与写回读的都是这一份。 */
|
|
423
426
|
readonly ctx: CheckpointCtx;
|
|
424
427
|
}
|
|
425
428
|
/** 提交/续跑「腿」= 跨域共享的**有状态**长流程(不像 {@link RouteHelpers} 那样只依赖 deps/config:它们要写
|
|
@@ -458,14 +461,8 @@ export interface RouteLegs {
|
|
|
458
461
|
/** 这次决定落在哪一个动作上:调用方点名它看到的那一对(`boundCallId` + `boundInputHash`);缺任一 ⇒ 400 `decide_requires_binding`
|
|
459
462
|
* (判在门型守卫之后,判官 `decidedActionOf`)。本函数从不拿当前停驻行补。 */
|
|
460
463
|
binding: DecideBinding,
|
|
461
|
-
/**
|
|
462
|
-
|
|
463
|
-
* 载入 cp** 的可记工具名(`rememberableToolName`,非 tool_approval / AskUserQuestion / legacy null / [ref] 强制卡 ⇒ `null`
|
|
464
|
-
* = 无可记)一并回传,路由只对这个逐字落店。`overrideSessionId` = parked 腿的 root/host 会话 grant 锚。 */
|
|
465
|
-
onResumeCommitted?: (grant: {
|
|
466
|
-
overrideSessionId?: string;
|
|
467
|
-
rememberableToolName: string | null;
|
|
468
|
-
}) => Promise<void>,
|
|
464
|
+
/** 这次决定带着「本会话放行」请求({@link RememberSessionRequest})⇒ 本函数是它的**唯一铸点**,结局的 `rememberApplied` 是它的答({@link ResumeCheckpointOutcome})。 */
|
|
465
|
+
remember?: RememberSessionRequest,
|
|
469
466
|
/** [ref]:透传给 {@link DriveResumeArgs.acceptEarly}(200 受理语义)。HTTP `/decide` 腿传 `true`;
|
|
470
467
|
* 内部 D-D SLA deny-sweep 不传 —— 它没有在等响应的人,提前受理对它零收益而少一条同步失败面。 */
|
|
471
468
|
acceptEarly?: boolean,
|
|
@@ -476,7 +473,7 @@ export interface RouteLegs {
|
|
|
476
473
|
explicitOperator: boolean;
|
|
477
474
|
},
|
|
478
475
|
/** 续跑请求的重述键(`mcpServers` / `a2aPeers`),门读出并判过的那一份;缺席 = 冻结读法。语义属主 = `resume-restatement.ts` 顶注。 */
|
|
479
|
-
restatement?: ResumeRestatement): Promise<
|
|
476
|
+
restatement?: ResumeRestatement): Promise<ResumeCheckpointOutcome>;
|
|
480
477
|
/** 全 resume 家族的共同下半场(lease admission + 写 run log + fleet 发布)。 */
|
|
481
478
|
driveResumeIntoRunLog(args: DriveResumeArgs): Promise<ResumeLegOutcome>;
|
|
482
479
|
/** assistant 抢占腿的复位(gate-kind 守卫 + 行级属主复核 + 驱动)。 */
|
|
@@ -492,7 +489,9 @@ export interface RouteLegs {
|
|
|
492
489
|
/** 续跑请求的重述键(同 {@link RouteLegs.resumeCheckpoint} 末参)。 */
|
|
493
490
|
restatement?: ResumeRestatement): Promise<ResumeLegOutcome>;
|
|
494
491
|
/** notify-wake 域:唤醒一条 parked checkpoint。 */
|
|
495
|
-
resumeWake(sessionId: string,
|
|
492
|
+
resumeWake(sessionId: string,
|
|
493
|
+
/** 续跑首轮那段话连同框架位,由文本出处在铸点定好(HTTP `/wake` 正文 ⇒ `trusted: false`);语义属主 = `resume-legs.ts` 同名形参顶注。 */
|
|
494
|
+
message: PendingSteerInput | undefined, caller: string | undefined, req: IncomingMessage | undefined,
|
|
496
495
|
/** [ref] 件 S-1:透传给 {@link DriveResumeArgs.acceptEarly}(200 受理语义)。HTTP `/wake` 腿传 `true`
|
|
497
496
|
* —— 本腿走 `mintFreshRun`,受理体里的 `taskId` 因此是**新铸的**那个(壳的 poll 锚)。 */
|
|
498
497
|
acceptEarly?: boolean,
|
|
@@ -521,7 +520,9 @@ export interface RouteLegs {
|
|
|
521
520
|
explicitOperator: boolean;
|
|
522
521
|
},
|
|
523
522
|
/** [ref]:决断方看到的那道门(决断体的 `checkpointId`);不是当前门 ⇒ `409 approval_stale`(`approval_stale` 律,语义属主 = `resume-legs.ts` 的同名形参顶注)。 */
|
|
524
|
-
sighting?: GateSighting
|
|
523
|
+
sighting?: GateSighting,
|
|
524
|
+
/** 续跑请求的重述键(同 {@link RouteLegs.resumeCheckpoint} 末参):盖在这一次 ctx 读上,存体预判按盖过的体判。 */
|
|
525
|
+
restatement?: ResumeRestatement): Promise<{
|
|
525
526
|
readonly ok: false;
|
|
526
527
|
readonly answer: {
|
|
527
528
|
status: number;
|
|
@@ -539,9 +540,7 @@ export interface RouteLegs {
|
|
|
539
540
|
acceptEarly?: boolean,
|
|
540
541
|
/** [ref]:批准之后这条会话继续用的 permission mode(闭集 `PLAN_APPROVE_PERMISSION_MODES_AFTER`;只在把计划带出 plan 的决定
|
|
541
542
|
* —— `approve` / `edit` —— 上有意义,缺席 ⇒ `"default"`)。语义与判据的唯一属主 = `resume-legs.ts` 的同名形参顶注。 */
|
|
542
|
-
permissionModeAfter?: PlanApprovePermissionModeAfter
|
|
543
|
-
/** 续跑请求的重述键(同 {@link RouteLegs.resumeCheckpoint} 末参)。 */
|
|
544
|
-
restatement?: ResumeRestatement): Promise<ResumeLegOutcome>;
|
|
543
|
+
permissionModeAfter?: PlanApprovePermissionModeAfter): Promise<ResumeLegOutcome>;
|
|
545
544
|
/** 会话通知门(`POST /v1/sessions/:id/notify` 与 Runner 之外的后台子代完成共用的那一只;活流登记簿是本服务的,门随服务建一次)。 */
|
|
546
545
|
sessionNotify: SessionNotifyDoor;
|
|
547
546
|
}
|
|
@@ -693,7 +692,7 @@ interface RouteDeclIdentity {
|
|
|
693
692
|
readonly methods: readonly RouteMethod[];
|
|
694
693
|
/**
|
|
695
694
|
* 「这条 GET 开的是一条**只读订阅**」—— 一条 SSE 读面(推送队列 / 账本 tail),它看着别人干活,自己不是活([ref])。
|
|
696
|
-
* 在场 ⇒ 分派器不把它记进在飞(`
|
|
695
|
+
* 在场 ⇒ 分派器不把它记进在飞(`http` 项:`/health.inflight` 报的总数与排空等的、SIGHUP 空闲窗与附着租约读的阻断集都从它起算),只记进附着
|
|
697
696
|
* (`attachedStreams()`:壳还挂在这只引擎上);排空进入那一拍(以及硬停起点)由分派器发一帧 `draining` 终帧后关掉它
|
|
698
697
|
* (`drainState.endSubscriptions`)。闭集 = 八条 GET SSE 读面,逐行理由见各行注;**唯一**一条「在飞腿的流」`POST /v1/tasks/stream`
|
|
699
698
|
* 不带它 —— 那条流就是 sync 腿本身(关流 = 断连语义),照旧算在飞。漏标一条订阅的方向是**多算在飞**(排空多等),不是少等。
|
|
@@ -739,6 +738,24 @@ export interface ResumeLegOutcome {
|
|
|
739
738
|
status: number;
|
|
740
739
|
body: object;
|
|
741
740
|
}
|
|
741
|
+
/**
|
|
742
|
+
* 「本会话不再询问」的请求 —— **两扇门同一只**:`/decide` 体上的 `remember:"session"`、应答口(`POST /v1/tool-approvals/:id/respond`)命中停驻行的
|
|
743
|
+
* `allow_session`。铸点只有一只:{@link RouteLegs.resumeCheckpoint} —— 可记与否从**已属主校验的载入停驻行**判(`standingAnswerDurablyRecordable`,
|
|
744
|
+
* 与运维队列行的 `rememberRefused` 同一只判据)、锚由车道定(任务级 = 这个会话;bg 停驻子代 = 行的 root/host 会话)、落豁免店**只在**这次决定
|
|
745
|
+
* 被证明已结清之后(`decisionCommittedOf`)、`rememberApplied` = 落没落(店抛 ⇒ `false` + warn,这次的放行不回滚)。门自己不写店、不判可记。
|
|
746
|
+
* 两口唯一的差 = `laneCannotRecord`(记不住的车道上怎么答;闭集与理由的属主 = `parked-decide.ts` 的 {@link RememberLaneCannotRecord})。
|
|
747
|
+
*/
|
|
748
|
+
export interface RememberSessionRequest {
|
|
749
|
+
/** 豁免行的签发人(`grantedBy`)= 门已验的身份(`/decide` 的决断方 / 应答口的调用方);匿名开放部署 ⇒ `null`。 */
|
|
750
|
+
readonly grantedBy: string | null;
|
|
751
|
+
readonly laneCannotRecord: RememberLaneCannotRecord;
|
|
752
|
+
}
|
|
753
|
+
/** {@link RouteLegs.resumeCheckpoint} 的结局 = 腿的应答 + 带了「本会话放行」请求时铸点的答(`rememberApplied`:落没落)。键只在证得出提交的两条车道
|
|
754
|
+
* (bg 停驻子代赎回 / 任务级续跑)的结清点上铸;其余出口(拒 / workflow 投递 / 抛)键缺席 ⇒ 门读作「没记住」(`=== true`)。
|
|
755
|
+
* 这一位是进程内的结局位,不进 `body` —— 由门决定挂不挂到回执上(两扇门都只挂在这次真做了授予判定的回执上;幂等回放不挂)。 */
|
|
756
|
+
export type ResumeCheckpointOutcome = ResumeLegOutcome & {
|
|
757
|
+
readonly rememberApplied?: boolean;
|
|
758
|
+
};
|
|
742
759
|
/**
|
|
743
760
|
* **「决定/续跑已受理」那一枚 200 收据的单一铸点**([ref])。
|
|
744
761
|
*
|
package/dist/http/route-table.js
CHANGED
|
@@ -4,6 +4,7 @@ import { handleDiagnostics, DIAGNOSTICS_ROUTES } from "./routes/diagnostics.js";
|
|
|
4
4
|
import { handleAdoption, ADOPTION_ROUTES } from "./routes/adoption.js";
|
|
5
5
|
import { handleRetention, RETENTION_ROUTES } from "./routes/retention-ops.js";
|
|
6
6
|
import { handleAdminDrain, ADMIN_DRAIN_ROUTES } from "./routes/admin-drain.js";
|
|
7
|
+
import { handleEngine, ENGINE_ROUTES } from "./routes/engine.js";
|
|
7
8
|
import { handleDevices, DEVICES_ROUTES } from "./routes/devices.js";
|
|
8
9
|
import { handleAdminConfigRefresh, ADMIN_CONFIG_REFRESH_ROUTES } from "./routes/admin-config-refresh.js";
|
|
9
10
|
import { handleConfigCatalog, CONFIG_CATALOG_ROUTES } from "./routes/config-catalog.js";
|
|
@@ -18,6 +19,7 @@ import { handlePrincipalInbox, PRINCIPAL_INBOX_ROUTES } from "./routes/principal
|
|
|
18
19
|
import { handleRules, RULES_ROUTES } from "./routes/rules.js";
|
|
19
20
|
import { handleSessionsList, SESSIONS_LIST_ROUTES } from "./routes/sessions-list.js";
|
|
20
21
|
import { handleAgentRoster, AGENT_ROSTER_ROUTES } from "./routes/agents-roster.js";
|
|
22
|
+
import { handleProjects, PROJECTS_ROUTES } from "./routes/projects.js";
|
|
21
23
|
import { handleSessions, SESSIONS_ROUTES } from "./routes/sessions.js";
|
|
22
24
|
import { handleSessionSync, SESSION_SYNC_ROUTES } from "./routes/session-sync.js";
|
|
23
25
|
import { handleAttachments, ATTACHMENTS_ROUTES } from "./routes/attachments.js";
|
|
@@ -65,6 +67,7 @@ export const ROUTES = [
|
|
|
65
67
|
row({ handler: handleAdoption, decls: ADOPTION_ROUTES, position: "post-credential", label: "adoption" }),
|
|
66
68
|
row({ handler: handleRetention, decls: RETENTION_ROUTES, position: "post-credential", label: "retention" }),
|
|
67
69
|
row({ handler: handleAdminDrain, decls: ADMIN_DRAIN_ROUTES, position: "post-credential", label: "admin-drain" }),
|
|
70
|
+
row({ handler: handleEngine, decls: ENGINE_ROUTES, position: "post-credential", label: "engine" }),
|
|
68
71
|
row({ handler: handleDevices, decls: DEVICES_ROUTES, position: "post-credential", label: "devices" }),
|
|
69
72
|
row({ handler: handleAdminConfigRefresh, decls: ADMIN_CONFIG_REFRESH_ROUTES, position: "post-credential", label: "admin-config-refresh" }),
|
|
70
73
|
row({ handler: handleConfigCatalog, decls: CONFIG_CATALOG_ROUTES, position: "post-credential", label: "config-catalog" }),
|
|
@@ -79,6 +82,7 @@ export const ROUTES = [
|
|
|
79
82
|
row({ handler: handlePrincipalInbox, decls: PRINCIPAL_INBOX_ROUTES, position: "post-credential", label: "principal-inbox" }),
|
|
80
83
|
row({ handler: handleSessionsList, decls: SESSIONS_LIST_ROUTES, position: "post-credential", label: "sessions-list" }),
|
|
81
84
|
row({ handler: handleAgentRoster, decls: AGENT_ROSTER_ROUTES, position: "post-credential", label: "agent-roster" }),
|
|
85
|
+
row({ handler: handleProjects, decls: PROJECTS_ROUTES, position: "post-credential", label: "projects" }),
|
|
82
86
|
row({ handler: handleSessions, decls: SESSIONS_ROUTES, position: "post-credential", label: "sessions" }),
|
|
83
87
|
row({ handler: handleSessionSync, decls: SESSION_SYNC_ROUTES, position: "post-credential", label: "session-sync" }),
|
|
84
88
|
row({ handler: handleAttachments, decls: ATTACHMENTS_ROUTES, position: "post-credential", label: "attachments" }),
|
|
@@ -18,6 +18,11 @@
|
|
|
18
18
|
* 一次落库,此后原样回放)。并发同参 POST 由 `adoption_log.from_principal` 的 UNIQUE 仲裁:恰一行落库,
|
|
19
19
|
* 两条连接拿到同一个 adoptionId、同一份回执。
|
|
20
20
|
*
|
|
21
|
+
* ── 第二条车道:源主体的批量导入 `POST /v1/adoption/:id/sessions` ─────────────────────────────────────────────
|
|
22
|
+
* 不是 operator 面:调用者是那条收编行的**源主体本人**(逐字;operator 不能代),把本地会话导进目的主体名下。门序 = 身份(401)→ 设施(501)→
|
|
23
|
+
* 行(404 `not_found.adoption`)→ 源主体(403 `auth.adoption_source_only`,不降级成 404:无行与不匹配同形是一种查不出根因的二义)→ 收编态
|
|
24
|
+
* (409 `adoption.not_adopted`)→ 体形(400)→ 条数帽(400)→ 逐元素(200 + 结局数组)。判断全在 `adoption/import.ts`,本模块只下发。
|
|
25
|
+
*
|
|
21
26
|
* 分层:本模块不值 import `server.ts`(那条边闭合运行时装载环),只 `import type`。
|
|
22
27
|
*/
|
|
23
28
|
import type { IncomingMessage, ServerResponse } from "node:http";
|
|
@@ -33,6 +38,12 @@ export declare const ADOPTION_ROUTES: readonly [{
|
|
|
33
38
|
readonly pattern: RegExp;
|
|
34
39
|
readonly label: "/v1/adoption/:id";
|
|
35
40
|
readonly methods: readonly ["GET"];
|
|
41
|
+
}, {
|
|
42
|
+
readonly id: "adoption-sessions-import";
|
|
43
|
+
readonly pattern: RegExp;
|
|
44
|
+
readonly label: "/v1/adoption/:id/sessions";
|
|
45
|
+
readonly credentialGated: readonly ["POST"];
|
|
46
|
+
readonly methods: readonly ["POST"];
|
|
36
47
|
}];
|
|
37
48
|
/** 本域可分派行的 `id` 闭集 —— handler 的 `switch` 按它判穷尽(漏一口 = 编译红)。 */
|
|
38
49
|
export type AdoptionRouteId = RouteIdsOf<typeof ADOPTION_ROUTES>;
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { createAdoptionRunner } from "../../adoption/runner.js";
|
|
2
2
|
import { AdoptionRequestSchema } from "../../adoption/wire.js";
|
|
3
3
|
import { checkAdoptionPrincipalShape, checkAdoptionWidths } from "../../adoption/plan.js";
|
|
4
|
+
import { judgeAdoptionImportBinding, readAdoptionImportBody, runAdoptionImport } from "../../adoption/import.js";
|
|
5
|
+
import { limitRefusal } from "../../limit-refusal.js";
|
|
4
6
|
import { sendJson, sendError } from "../send.js";
|
|
5
7
|
import { gatedPrincipal, explicitOperatorOk, sendOperatorPrincipalsRequired, sendPrincipalRefusal } from "../principal-gate.js";
|
|
6
8
|
import { assertNever } from "../route-ctx.js";
|
|
@@ -39,7 +41,21 @@ function sendOutcome(res, out) {
|
|
|
39
41
|
function assertNoRejectCodeLeft(unhandled) {
|
|
40
42
|
throw new Error(`adoption: unhandled reject code ${JSON.stringify(unhandled)} — the wire contract's closed set and this switch have drifted apart`);
|
|
41
43
|
}
|
|
44
|
+
function sendAdoptionStoreRequired(res) {
|
|
45
|
+
sendError(res, 501, "capability.adoption_store_required", "adoption requires a SQL store backend (DB_BACKEND=mysql|pg)");
|
|
46
|
+
}
|
|
42
47
|
export async function handleAdoption(req, res, match, ctx) {
|
|
48
|
+
switch (match.decl.id) {
|
|
49
|
+
case "adoption-submit":
|
|
50
|
+
case "adoption-detail":
|
|
51
|
+
return operatorLane(req, res, match.decl.id, match.params, ctx);
|
|
52
|
+
case "adoption-sessions-import":
|
|
53
|
+
return sourceLane(req, res, match.params, ctx);
|
|
54
|
+
default:
|
|
55
|
+
return assertNever(match.decl.id);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
async function operatorLane(req, res, id, params, ctx) {
|
|
43
59
|
const { deps } = ctx;
|
|
44
60
|
const { readJson } = ctx.helpers;
|
|
45
61
|
const principal = gatedPrincipal(req, deps.config);
|
|
@@ -59,7 +75,7 @@ export async function handleAdoption(req, res, match, ctx) {
|
|
|
59
75
|
if (!fact.available) {
|
|
60
76
|
switch (fact.why) {
|
|
61
77
|
case "adoption_store_absent":
|
|
62
|
-
|
|
78
|
+
sendAdoptionStoreRequired(res);
|
|
63
79
|
return;
|
|
64
80
|
case "operator_principals_empty":
|
|
65
81
|
sendOperatorPrincipalsRequired(res);
|
|
@@ -70,14 +86,14 @@ export async function handleAdoption(req, res, match, ctx) {
|
|
|
70
86
|
}
|
|
71
87
|
const store = fact.backend.adoptionLog();
|
|
72
88
|
const runner = createAdoptionRunner({ store, dialect: deps.backend?.kind === "pg" ? "pg" : "mysql", now: Date.now, logger: deps.logger });
|
|
73
|
-
switch (
|
|
89
|
+
switch (id) {
|
|
74
90
|
case "adoption-detail": {
|
|
75
|
-
const
|
|
76
|
-
if (
|
|
91
|
+
const adoptionId = ctx.helpers.safeDecode(params.id);
|
|
92
|
+
if (adoptionId === null) {
|
|
77
93
|
sendError(res, 400, "request.id_invalid", "invalid adoption id");
|
|
78
94
|
return;
|
|
79
95
|
}
|
|
80
|
-
const out = await runner.get(
|
|
96
|
+
const out = await runner.get(adoptionId);
|
|
81
97
|
if (!out) {
|
|
82
98
|
sendError(res, 404, "not_found.adoption", "adoption not found");
|
|
83
99
|
return;
|
|
@@ -112,11 +128,69 @@ export async function handleAdoption(req, res, match, ctx) {
|
|
|
112
128
|
return;
|
|
113
129
|
}
|
|
114
130
|
default:
|
|
115
|
-
return assertNever(
|
|
131
|
+
return assertNever(id);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
async function sourceLane(req, res, params, ctx) {
|
|
135
|
+
const { deps } = ctx;
|
|
136
|
+
if (ctx.helpers.rateLimited(req, res))
|
|
137
|
+
return;
|
|
138
|
+
const principal = gatedPrincipal(req, deps.config);
|
|
139
|
+
if (principal === undefined) {
|
|
140
|
+
sendPrincipalRefusal(res, req, deps.config);
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
const face = facts.adoptionSessionImport(deps);
|
|
144
|
+
if (!face.available) {
|
|
145
|
+
switch (face.why) {
|
|
146
|
+
case "adoption_store_absent":
|
|
147
|
+
sendAdoptionStoreRequired(res);
|
|
148
|
+
return;
|
|
149
|
+
case "session_import_staging_absent":
|
|
150
|
+
sendError(res, 501, "capability.session_store_required", "importing sessions requires a durable session store (DB_BACKEND=mysql|pg|local)");
|
|
151
|
+
return;
|
|
152
|
+
default:
|
|
153
|
+
return assertNever(face.why);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
const adoptionId = ctx.helpers.safeDecode(params.id);
|
|
157
|
+
if (adoptionId === null) {
|
|
158
|
+
sendError(res, 400, "request.id_invalid", "invalid adoption id");
|
|
159
|
+
return;
|
|
160
|
+
}
|
|
161
|
+
const binding = judgeAdoptionImportBinding(await face.backend.adoptionLog().getById(adoptionId), principal);
|
|
162
|
+
switch (binding.kind) {
|
|
163
|
+
case "absent":
|
|
164
|
+
sendError(res, 404, "not_found.adoption", "adoption not found");
|
|
165
|
+
return;
|
|
166
|
+
case "not_source":
|
|
167
|
+
sendError(res, 403, "auth.adoption_source_only", "only this adoption's source principal may import sessions into it (verbatim; an operator cannot import on its behalf)");
|
|
168
|
+
return;
|
|
169
|
+
case "not_adopted":
|
|
170
|
+
sendError(res, 409, "adoption.not_adopted", "this adoption has not completed (it is still in flight, or it was rejected); sessions can be imported once the operator's adoption reaches status adopted");
|
|
171
|
+
return;
|
|
172
|
+
case "bound":
|
|
173
|
+
break;
|
|
174
|
+
default:
|
|
175
|
+
return assertNever(binding);
|
|
176
|
+
}
|
|
177
|
+
const sessions = readAdoptionImportBody(await ctx.helpers.readJson(req));
|
|
178
|
+
if (sessions === undefined) {
|
|
179
|
+
sendError(res, 400, "request.body_shape", "invalid import body — expected exactly {sessions: [...]} (the destination is the adoption's; the body cannot name one)");
|
|
180
|
+
return;
|
|
181
|
+
}
|
|
182
|
+
const cap = deps.config.adoptionImportMaxSessions;
|
|
183
|
+
if (sessions.length > cap) {
|
|
184
|
+
const refusal = limitRefusal("sessions", "entries", sessions.length, cap, { tail: "split the batch (the current cap is capabilities.adoptionImport.maxSessions), or have the operator raise ADOPTION_IMPORT_MAX_SESSIONS" });
|
|
185
|
+
sendError(res, 400, "request.field_invalid", refusal.message, refusal.facts);
|
|
186
|
+
return;
|
|
116
187
|
}
|
|
188
|
+
const results = await runAdoptionImport({ adoptionId: binding.adoptionId, toPrincipal: binding.toPrincipal, maxSessionBytes: deps.config.adoptionImportMaxSessionBytes, sessionStorage: face.sessionStorage }, sessions);
|
|
189
|
+
sendJson(res, 200, { results });
|
|
117
190
|
}
|
|
118
191
|
export const ADOPTION_ROUTES = [
|
|
119
192
|
{ id: "adoption-submit", path: "/v1/adoption", credentialGated: ["POST"], methods: ["POST"] },
|
|
120
193
|
{ id: "adoption-detail", pattern: /^\/v1\/adoption\/(?<id>[^/]+)$/, label: "/v1/adoption/:id", methods: ["GET"] },
|
|
194
|
+
{ id: "adoption-sessions-import", pattern: /^\/v1\/adoption\/(?<id>[^/]+)\/sessions$/, label: "/v1/adoption/:id/sessions", credentialGated: ["POST"], methods: ["POST"] },
|
|
121
195
|
];
|
|
122
196
|
//# sourceMappingURL=adoption.js.map
|
|
@@ -3,7 +3,8 @@ import { skillCardFacts } from "../../approval-card.js";
|
|
|
3
3
|
import { hostDecisionFacts, readDecider, retiredDecisionKeyFacts, DECIDED_BY_NOT_IN_PROOF } from "../../host-decision.js";
|
|
4
4
|
import { sameExecutionRecord } from "@sema-agent/core";
|
|
5
5
|
import { findParkedAgentForCheckpoint } from "../../parked-decide.js";
|
|
6
|
-
import { DECIDED_REPLAY_SCAN_CAP
|
|
6
|
+
import { DECIDED_REPLAY_SCAN_CAP } from "../../plugins/checkpoint-store-face.js";
|
|
7
|
+
import { approvalPayloadFingerprint } from "../../plugins/approval-payload-fingerprint.js";
|
|
7
8
|
import { carriesDeploymentListQuestion, standingAnswerDurablyRecordable } from "../../tool-approval.js";
|
|
8
9
|
import { APPROVAL_GATE_KINDS } from "../../approval-content-kind.js";
|
|
9
10
|
import { isParkedRunStatus } from "../../plugins/store-contracts.js";
|
|
@@ -31,7 +32,7 @@ import { recordFailOpen } from "../../observability/fail-open.js";
|
|
|
31
32
|
import { MAX_CHECKPOINT_ID_CHARS, durableRowIdentity } from "../../checkpoint-identity.js";
|
|
32
33
|
import { MAX_KEY_ECHO, keyClosureClause, scanKeyClosure } from "../../request-key-closure.js";
|
|
33
34
|
import { fieldConflictFacts } from "../../field-conflict.js";
|
|
34
|
-
import { buildSettlementEvidence
|
|
35
|
+
import { buildSettlementEvidence } from "../../gate-settlement.js";
|
|
35
36
|
import { seatText } from "../../trace/exit-seat.js";
|
|
36
37
|
import { approvalQueueKindOfDoorId } from "../../approval-queue-kind.js";
|
|
37
38
|
import { defaultPeerInboundFace, parsePeerInboundId, peerBoxScope } from "../../peer-inbound-face.js";
|
|
@@ -700,7 +701,7 @@ export async function handleApprovalsAssistant(req, res, match, ctx) {
|
|
|
700
701
|
sendError(res, 404, "not_found.run", "task not found");
|
|
701
702
|
return;
|
|
702
703
|
}
|
|
703
|
-
const plan = await preparePlanReview(run.sessionId, { taskId, principalPresent: principal !== undefined }, { principal: deciderPrincipal, explicitOperator }, sighting);
|
|
704
|
+
const plan = await preparePlanReview(run.sessionId, { taskId, principalPresent: principal !== undefined }, { principal: deciderPrincipal, explicitOperator }, sighting, restated.restatement);
|
|
704
705
|
if (!plan.ok) {
|
|
705
706
|
sendResumeOutcome(res, plan.answer, deps.logger);
|
|
706
707
|
return;
|
|
@@ -724,7 +725,7 @@ export async function handleApprovalsAssistant(req, res, match, ctx) {
|
|
|
724
725
|
return;
|
|
725
726
|
}
|
|
726
727
|
}
|
|
727
|
-
const out = await drivePlanReview(plan.prepared, decision, decision === "edit" ? body.editedPlan : undefined, typeof body.reason === "string" ? body.reason : undefined, hostDecisionFacts(decidedByReading.decider, deciderPrincipal), req, true, isPlanApprovePermissionModeAfter(body.permissionModeAfter) ? body.permissionModeAfter : undefined
|
|
728
|
+
const out = await drivePlanReview(plan.prepared, decision, decision === "edit" ? body.editedPlan : undefined, typeof body.reason === "string" ? body.reason : undefined, hostDecisionFacts(decidedByReading.decider, deciderPrincipal), req, true, isPlanApprovePermissionModeAfter(body.permissionModeAfter) ? body.permissionModeAfter : undefined);
|
|
728
729
|
sendResumeOutcome(res, out, deps.logger);
|
|
729
730
|
return;
|
|
730
731
|
}
|
|
@@ -892,27 +893,7 @@ export async function handleApprovalsAssistant(req, res, match, ctx) {
|
|
|
892
893
|
return;
|
|
893
894
|
}
|
|
894
895
|
}
|
|
895
|
-
|
|
896
|
-
let pendingGrant;
|
|
897
|
-
const grantOnCommit = remember && deps.approvalExemptionStore
|
|
898
|
-
? async (grant) => {
|
|
899
|
-
const canonical = grant.rememberableToolName;
|
|
900
|
-
if (!canonical)
|
|
901
|
-
return;
|
|
902
|
-
pendingGrant = { sessionId: grant.overrideSessionId ?? sessionId, toolName: canonical };
|
|
903
|
-
}
|
|
904
|
-
: undefined;
|
|
905
|
-
const out = await resumeCheckpoint(sessionId, decision, body.reason ?? undefined, hostDecisionFacts(decider, deciderPrincipal), req, answer, binding, grantOnCommit, true, { principal: deciderPrincipal, explicitOperator }, restated.restatement);
|
|
906
|
-
if (pendingGrant !== undefined && decisionCommittedOf(out) && deps.approvalExemptionStore) {
|
|
907
|
-
try {
|
|
908
|
-
await deps.approvalExemptionStore.grant(pendingGrant.sessionId, pendingGrant.toolName, deciderPrincipal ?? null);
|
|
909
|
-
rememberApplied = true;
|
|
910
|
-
deps.logger?.info?.("approval_exemption_granted", { sessionId: pendingGrant.sessionId, toolName: pendingGrant.toolName, grantedBy: deciderPrincipal ?? null });
|
|
911
|
-
}
|
|
912
|
-
catch (e) {
|
|
913
|
-
deps.logger?.warn?.("approval_exemption_grant_failed", { sessionId: pendingGrant.sessionId, toolName: pendingGrant.toolName, error: String(e).slice(0, 200) });
|
|
914
|
-
}
|
|
915
|
-
}
|
|
896
|
+
const out = await resumeCheckpoint(sessionId, decision, body.reason ?? undefined, hostDecisionFacts(decider, deciderPrincipal), req, answer, binding, remember ? { grantedBy: deciderPrincipal ?? null, laneCannotRecord: "refuse" } : undefined, true, { principal: deciderPrincipal, explicitOperator }, restated.restatement);
|
|
916
897
|
const replay = await decideIdempotentReplay(cs, {
|
|
917
898
|
sessionId,
|
|
918
899
|
out,
|
|
@@ -932,7 +913,7 @@ export async function handleApprovalsAssistant(req, res, match, ctx) {
|
|
|
932
913
|
sendResumeOutcome(res, replay, deps.logger);
|
|
933
914
|
return;
|
|
934
915
|
}
|
|
935
|
-
sendResumeOutcome(res, out, deps.logger, remember
|
|
916
|
+
sendResumeOutcome(res, out, deps.logger, remember ? { rememberApplied: out.rememberApplied === true } : undefined);
|
|
936
917
|
return;
|
|
937
918
|
}
|
|
938
919
|
}
|
|
@@ -25,6 +25,7 @@ import { projectWriteProtectionCapability } from "../../write-protection.js";
|
|
|
25
25
|
import { projectStoreCapability } from "../../store-posture.js";
|
|
26
26
|
import { projectWebSearchCapability } from "../../plugins/web-search.js";
|
|
27
27
|
import { projectExecutionLaneCapability } from "../../capabilities/execution-lane.js";
|
|
28
|
+
import { SETTINGS_CONTRACT_CAPABILITY } from "../../capabilities/settings-contract.js";
|
|
28
29
|
import { judgeSandboxGitPlane, sandboxGitPlanePremisesOf } from "../../sandbox-git-plane.js";
|
|
29
30
|
import { MCP_ASSERTION_HEADER_SENT, MCP_REQUEST_TRANSPORT_KINDS } from "../../mcp-assertion-header.js";
|
|
30
31
|
import { gateCompositeMembers } from "../../capabilities/composite-members.js";
|
|
@@ -35,6 +36,7 @@ import * as facts from "../../capability-facts.js";
|
|
|
35
36
|
import { judgeAutoModeArming } from "../../auto-mode-face.js";
|
|
36
37
|
import { coercePermissionModeStrict, PERMISSION_MODE_WORDS, taskHooksHonored } from "../../task-settings.js";
|
|
37
38
|
import { gatedPrincipal, sendPrincipalRefusal } from "../principal-gate.js";
|
|
39
|
+
import { readAdoptionImportCapability } from "../../adoption/import.js";
|
|
38
40
|
import { headReadOf } from "../../session-incarnation.js";
|
|
39
41
|
import { callerTrust } from "../caller-trust.js";
|
|
40
42
|
import { sessionRulesNamespaceFormsHonored } from "../../session-policy-wire.js";
|
|
@@ -95,10 +97,10 @@ export async function handleCapabilities(req, res, match, ctx) {
|
|
|
95
97
|
? {
|
|
96
98
|
enabled: true,
|
|
97
99
|
protocolVersion: DEVICE_PROTOCOL_VERSION,
|
|
98
|
-
maxInflightPerDevice: deps.config.remoteExec
|
|
100
|
+
maxInflightPerDevice: deps.config.remoteExec.provider === "device" ? (deps.config.remoteExec.maxInflightPerDevice ?? 4) : 4,
|
|
99
101
|
wsPath: DEVICE_WS_PATH,
|
|
100
102
|
management: facts.deviceManagement(deps).available,
|
|
101
|
-
...(deps.config.remoteExec
|
|
103
|
+
...(deps.config.remoteExec.provider === "device" && deps.config.remoteExec.relay.kind === "url" ? { relayUrl: deps.config.remoteExec.relay.url } : {}),
|
|
102
104
|
}
|
|
103
105
|
: false,
|
|
104
106
|
sessionEvents: facts.sessionEventStream(deps).available,
|
|
@@ -121,6 +123,7 @@ export async function handleCapabilities(req, res, match, ctx) {
|
|
|
121
123
|
sharedMemory: facts.sharedMemoryRead(deps).available,
|
|
122
124
|
principalInboxDelivery: facts.principalInboxDelivery(deps).available,
|
|
123
125
|
adoption: facts.adoption(deps).available,
|
|
126
|
+
adoptionImport: await readAdoptionImportCapability(facts.adoptionSessionImport(deps), gatedPrincipal(req, deps.config), deps.config),
|
|
124
127
|
memoryBundle: facts.memoryBundle(deps).available,
|
|
125
128
|
memoryCompliance: facts.memoryCompliance(deps).available,
|
|
126
129
|
memoryOrigin: facts.memoryOrigin(deps).available,
|
|
@@ -147,8 +150,9 @@ export async function handleCapabilities(req, res, match, ctx) {
|
|
|
147
150
|
scratchpadDir: true,
|
|
148
151
|
subagentSteer: facts.subagentSteer(deps).available,
|
|
149
152
|
subagentResume: facts.subagentSteer(deps).available,
|
|
150
|
-
taskSettings: { permissions: true, permissionMode: true, model: true, outputStyle: true, env: DEPLOYMENT_SHAPE_PREDICATES.callerCwd.holds(deps.config), hooks: taskHooksHonored(deps.config), pluginHooks: taskHooksHonored(deps.config), managedHookGroups: taskHooksHonored(deps.config), httpHookAllowlists: taskHooksHonored(deps.config), tightenOnlySeats: true, approvalFrameFamilies: true },
|
|
153
|
+
taskSettings: { permissions: true, permissionMode: true, model: true, outputStyle: true, env: DEPLOYMENT_SHAPE_PREDICATES.callerCwd.holds(deps.config), hooks: taskHooksHonored(deps.config), pluginHooks: taskHooksHonored(deps.config), managedHookGroups: taskHooksHonored(deps.config), httpHookAllowlists: taskHooksHonored(deps.config), tightenOnlySeats: true, approvalFrameFamilies: true, autoCompactEnabled: true },
|
|
151
154
|
settings: { permissions: { allowGrant: true, allowLayer: true, layers: true, layeredAllow: true, callerTrust: callerTrust(req, deps.config).trust } },
|
|
155
|
+
settingsContract: SETTINGS_CONTRACT_CAPABILITY,
|
|
152
156
|
permissionModeAuto: {
|
|
153
157
|
accepted: true,
|
|
154
158
|
classifierSeat: deps.autoModeFace?.seatMounted === true,
|
|
@@ -187,6 +191,7 @@ export async function handleCapabilities(req, res, match, ctx) {
|
|
|
187
191
|
mcpProbe: true,
|
|
188
192
|
mcpAssertionHeaderSent: MCP_ASSERTION_HEADER_SENT,
|
|
189
193
|
mcpTransportKinds: [...MCP_REQUEST_TRANSPORT_KINDS],
|
|
194
|
+
engine: { handover: facts.engineHandover(deps).available },
|
|
190
195
|
mcpElicitation: facts.elicitation(deps).available,
|
|
191
196
|
askUserQuestion: facts.askUserQuestion(deps).available,
|
|
192
197
|
toolApproval: facts.toolApproval(deps).available,
|
|
@@ -201,6 +206,7 @@ export async function handleCapabilities(req, res, match, ctx) {
|
|
|
201
206
|
sessionReadRedaction: true,
|
|
202
207
|
sideQuery: true,
|
|
203
208
|
agentRoster: facts.agentRoster(deps).available,
|
|
209
|
+
projects: facts.projectRegistry(deps).available,
|
|
204
210
|
retention: retentionAdvertisement(deps.config),
|
|
205
211
|
peerLane: Boolean(deps.peerDirectory),
|
|
206
212
|
sessionList: facts.sessionList(deps).available,
|
|
@@ -214,6 +220,8 @@ export async function handleCapabilities(req, res, match, ctx) {
|
|
|
214
220
|
rewindFiles: Boolean(deps.fileHistoryStore),
|
|
215
221
|
restoreFiles: Boolean(deps.fileHistoryStore),
|
|
216
222
|
rewindFilesTo: Boolean(deps.fileHistoryStore && deps.resumeAnchorStore && headReadOf(deps.sessionStorage)),
|
|
223
|
+
sessionRewindFiles: facts.sessionRewindFiles(deps).available,
|
|
224
|
+
sessionRewindFilesPreview: facts.sessionRewindFilesPreview(deps).available,
|
|
217
225
|
fileHistoryCapture: fileHistoryCaptureOf(deps.fileHistoryStore, deps.config.fileHistoryCapture),
|
|
218
226
|
scheduler: facts.hostScheduler(deps.config).available,
|
|
219
227
|
sessionSync: facts.sessionSync(deps).available,
|
|
@@ -295,6 +303,7 @@ export async function handleCapabilities(req, res, match, ctx) {
|
|
|
295
303
|
...(m.maxTokens ? { maxOutputTokens: m.maxTokens } : {}),
|
|
296
304
|
...((levels) => (levels !== undefined ? { supportedEffortLevels: [...levels] } : {}))(reasoningEffortLevelsOf(m)),
|
|
297
305
|
...(m.compat !== undefined ? { compat: m.compat } : {}),
|
|
306
|
+
...(m.thinkingLevelMap !== undefined ? { thinkingLevelMap: m.thinkingLevelMap } : {}),
|
|
298
307
|
...mentionBit(name),
|
|
299
308
|
routePairing: routePairingOf(deps, name, m),
|
|
300
309
|
}));
|
|
@@ -163,7 +163,7 @@ export async function handleDevices(req, res, match, ctx) {
|
|
|
163
163
|
}
|
|
164
164
|
if ((await readClosedBody(req, res, readJson, [])) === null)
|
|
165
165
|
return;
|
|
166
|
-
const ttlSeconds = (deps.config.remoteExec
|
|
166
|
+
const ttlSeconds = (deps.config.remoteExec.provider === "device" ? deps.config.remoteExec.enrollTokenTtlSec : undefined) ?? DEFAULT_ENROLL_TOKEN_TTL_SEC;
|
|
167
167
|
const issued = await enrollment.issueEnrollToken({ target: domain, createdBy: domain.subject, ttlSeconds });
|
|
168
168
|
if (!issued.ok) {
|
|
169
169
|
sendDeviceRejection(res, issued.reject);
|
|
@@ -13,6 +13,7 @@ import { type PostureKnobReading, type PostureSource } from "../../posture-sourc
|
|
|
13
13
|
import type { IncomingMessage, ServerResponse } from "node:http";
|
|
14
14
|
import type { WiringManifest } from "@sema-agent/core";
|
|
15
15
|
import { type StreamApprovalGate, type StreamApprovalGateInput } from "../../tool-approval.js";
|
|
16
|
+
import { verifiedIdentitySource } from "../principal-gate.js";
|
|
16
17
|
import type { RouteCtx, RouteMatch, RouteIdsOf } from "../route-ctx.js";
|
|
17
18
|
/** 流内审批门的读数形:上场即 `"active"`,否则是那**四**个合取项里**第一个**不满足的原因词
|
|
18
19
|
* (与 `resolveStreamApprovalGate` 同一闭集,词表**取型**自它 ⇒ 增删 reason 在此处自动跟随/编译红;
|
|
@@ -82,23 +83,17 @@ export declare function assertStaticWiringConsistent(facts: StaticWiringFacts, l
|
|
|
82
83
|
warn: (msg: string, meta?: Record<string, unknown>) => void;
|
|
83
84
|
} | undefined): StaticWiringAudit;
|
|
84
85
|
/**
|
|
85
|
-
* [ref]③ clay 裁 (b)
|
|
86
|
-
*
|
|
86
|
+
* 诊断面的**远程来源门**(单一属主,端点与测试同吃;[ref]③ clay 裁 (b) 的那只门,7.63.0 起按身份判):远程请求后面没有
|
|
87
|
+
* **验过的身份**(`verifiedIdentitySource`:service 凭据 / 鉴权桥登录令牌 / 直连门签名令牌)⇒ 拒;本机(loopback)照读。
|
|
87
88
|
*
|
|
88
|
-
*
|
|
89
|
-
*
|
|
90
|
-
*
|
|
91
|
-
* (壳缺省钉 BIND_HOST=127.0.0.1,local curl 照常),对远程侦察 fail-closed;配了 token 的部署远程读
|
|
92
|
-
* 走认证(全局门),不进本臂。
|
|
89
|
+
* 名单里的名字、单用户声明放进来的「每个调用方」,都只在这次请求带可验身份时才是身份 —— 没有凭据可验的部署上,主体头是谁都能写的
|
|
90
|
+
* 字符串,端口误暴露到公网就是侦察面(装配拓扑 / 治理姿态 / 写保护名表)。配了 service 凭据的部署上,到得了这里的请求都过了全局凭据门、
|
|
91
|
+
* 必然带着验过的身份,本判不咬;不要求静态凭据在场(鉴权桥的登录令牌就是身份)。
|
|
93
92
|
*
|
|
94
|
-
*
|
|
95
|
-
*
|
|
96
|
-
* 边界由反代+token 承担)。`remoteAddress` 缺席(socket 已断等边缘)⇒ 判拒(fail-closed,安全轴方向)。
|
|
93
|
+
* 判源 = TCP 对端地址(`req.socket.remoteAddress`),**非任何头**(XFF 类头在无反代形上是自造面;有反代的部署必然配凭据)。
|
|
94
|
+
* `remoteAddress` 缺席(socket 已断等边缘)⇒ 判拒(fail-closed)。
|
|
97
95
|
*/
|
|
98
|
-
export declare function
|
|
99
|
-
authToken?: string;
|
|
100
|
-
authTokens?: Record<string, string>;
|
|
101
|
-
}): boolean;
|
|
96
|
+
export declare function remoteWithoutVerifiedIdentity(req: IncomingMessage, config: Parameters<typeof verifiedIdentitySource>[1]): boolean;
|
|
102
97
|
export declare function handleDiagnostics(req: IncomingMessage, res: ServerResponse, match: RouteMatch<DiagnosticsRouteId>, ctx: RouteCtx): Promise<void>;
|
|
103
98
|
export declare const DIAGNOSTICS_ROUTES: readonly [{
|
|
104
99
|
readonly id: "diagnostics-wiring";
|
|
@@ -95,32 +95,22 @@ export function assertStaticWiringConsistent(facts, logger) {
|
|
|
95
95
|
}
|
|
96
96
|
return audit;
|
|
97
97
|
}
|
|
98
|
-
export function
|
|
99
|
-
|
|
100
|
-
if (anyServiceAuth)
|
|
101
|
-
return false;
|
|
102
|
-
return !isLoopbackAddress(remoteAddress);
|
|
98
|
+
export function remoteWithoutVerifiedIdentity(req, config) {
|
|
99
|
+
return !isLoopbackAddress(req.socket.remoteAddress) && verifiedIdentitySource(req, config) === undefined;
|
|
103
100
|
}
|
|
104
101
|
export async function handleDiagnostics(req, res, match, ctx) {
|
|
105
102
|
const { deps } = ctx;
|
|
106
103
|
switch (match.decl.id) {
|
|
107
104
|
case "diagnostics-wiring": {
|
|
108
|
-
if (
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
sendError(res, 403, "auth.operator_only", "wiring diagnostics are operator-only on a multi-tenant worker");
|
|
116
|
-
return;
|
|
117
|
-
}
|
|
118
|
-
if (!isLoopbackAddress(req.socket.remoteAddress) && verifiedIdentitySource(req, deps.config) === undefined) {
|
|
119
|
-
sendError(res, 403, "auth.loopback_only", "wiring diagnostics on a zero-credential deployment are readable from loopback only — configure SERVICE_AUTH_TOKEN to read remotely");
|
|
120
|
-
return;
|
|
121
|
-
}
|
|
105
|
+
if (!facts.operatorLane(deps).available) {
|
|
106
|
+
sendOperatorPrincipalsRequired(res);
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
if (!explicitOperatorOk(gatedPrincipal(req, deps.config), deps.config)) {
|
|
110
|
+
sendError(res, 403, "auth.operator_only", "wiring diagnostics are operator-only");
|
|
111
|
+
return;
|
|
122
112
|
}
|
|
123
|
-
|
|
113
|
+
if (remoteWithoutVerifiedIdentity(req, deps.config)) {
|
|
124
114
|
sendError(res, 403, "auth.loopback_only", "wiring diagnostics on a zero-credential deployment are readable from loopback only — configure SERVICE_AUTH_TOKEN to read remotely");
|
|
125
115
|
return;
|
|
126
116
|
}
|