@sema-agent/server 7.146.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 +384 -0
- package/README.md +1 -1
- package/README.zh-CN.md +1 -1
- package/USAGE.md +170 -66
- package/deploy/facts/lanes.json +7 -0
- package/deploy/sema-up/README.md +2 -2
- package/deploy/sema-up/chart/templates/_helpers.tpl +22 -0
- package/deploy/sema-up/chart/templates/server-v4pro.yaml +5 -4
- package/deploy/sema-up/chart/templates/server.yaml +5 -4
- package/deploy/sema-up/chart/values.yaml +1 -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 +4 -3
- package/dist/approval-card.d.ts +4 -4
- 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/device-lane.js +5 -5
- package/dist/boot/engine-lease.d.ts +12 -11
- package/dist/boot/execution-env.d.ts +2 -1
- package/dist/boot/execution-env.js +45 -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 +1 -1
- package/dist/boot/exit-last.js +2 -1
- package/dist/boot/governance-seams.d.ts +2 -2
- 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 +13 -24
- package/dist/boot/memory-consolidation.js +0 -13
- 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.js +1 -1
- package/dist/boot/resolve-spec.js +91 -111
- package/dist/boot/retention-lane.d.ts +4 -42
- package/dist/boot/session-faces.d.ts +1 -0
- package/dist/boot/session-faces.js +8 -2
- package/dist/boot/stage-01-config.d.ts +1 -1
- package/dist/boot/stage-01-config.js +6 -2
- 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 +1 -1
- package/dist/boot/stage-04-stores.d.ts +1 -1
- package/dist/boot/stage-05-execution-env.d.ts +2 -2
- package/dist/boot/stage-05-execution-env.js +3 -3
- package/dist/boot/stage-06-runners.d.ts +3 -3
- package/dist/boot/stage-06-runners.js +1 -3
- package/dist/boot/stage-07-capability-layer.d.ts +3 -3
- package/dist/boot/stage-07-capability-layer.js +4 -9
- package/dist/boot/stage-08-reapers.d.ts +3 -3
- package/dist/boot/stage-09-leader.d.ts +4 -3
- package/dist/boot/stage-10-http-server.d.ts +4 -3
- package/dist/boot/stage-10-http-server.js +2 -1
- package/dist/boot/stores.d.ts +9 -0
- package/dist/boot/stores.js +18 -7
- package/dist/boot/web-admin.js +3 -3
- package/dist/capabilities/center-plugins.d.ts +2 -0
- package/dist/capabilities/center-plugins.js +6 -2
- package/dist/capabilities/composite-members.d.ts +1 -0
- package/dist/capabilities/composite-members.js +1 -0
- 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 +32 -18
- 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 +38 -0
- package/dist/capability-facts.js +34 -1
- package/dist/center-credential-renewer.js +3 -2
- package/dist/config-catalog.js +6 -5
- 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.js +2 -0
- package/dist/config-types.d.ts +190 -186
- package/dist/config.d.ts +68 -5
- package/dist/config.js +80 -54
- package/dist/degenerate-instrument.js +1 -1
- package/dist/deploy-facts.js +3 -2
- package/dist/deployment-shape.d.ts +21 -12
- package/dist/deployment-shape.js +24 -6
- package/dist/env-facts.d.ts +7 -5
- package/dist/env-facts.js +10 -6
- 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 +17 -10
- package/dist/fleet/drain-entry.js +1 -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/command-spawn.d.ts +1 -4
- package/dist/hooks/command-spawn.js +0 -11
- package/dist/hooks/hook-runner.d.ts +52 -8
- package/dist/hooks/hook-runner.js +160 -36
- package/dist/http/approval-sweeps.d.ts +2 -5
- package/dist/http/approval-sweeps.js +3 -2
- package/dist/http/checkpoint-ctx.d.ts +17 -0
- package/dist/http/checkpoint-ctx.js +6 -0
- package/dist/http/claim-latency.d.ts +10 -0
- package/dist/http/claim-latency.js +12 -0
- package/dist/http/dispatch.js +1 -1
- package/dist/http/durable-run-leg.js +2 -1
- package/dist/http/execution-context.d.ts +3 -1
- package/dist/http/execution-context.js +4 -0
- package/dist/http/memory-compliance-failure-reply.d.ts +1 -1
- package/dist/http/memory-compliance-failure-reply.js +3 -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 +3 -14
- package/dist/http/principal-gate.js +0 -13
- package/dist/http/request-guards.d.ts +1 -1
- package/dist/http/resume-legs.d.ts +7 -10
- package/dist/http/resume-legs.js +79 -50
- 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 +32 -16
- package/dist/http/route-table.js +2 -0
- package/dist/http/routes/approvals-assistant.js +5 -25
- package/dist/http/routes/capabilities.js +8 -2
- package/dist/http/routes/devices.js +1 -1
- package/dist/http/routes/memory-origin.d.ts +1 -1
- package/dist/http/routes/notify-wake.js +2 -1
- 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 +8 -8
- package/dist/http/routes/session-sync.js +27 -10
- package/dist/http/routes/sessions.d.ts +7 -1
- package/dist/http/routes/sessions.js +104 -2
- package/dist/http/routes/tasks.js +9 -3
- package/dist/http/server.d.ts +24 -10
- package/dist/http/server.js +17 -6
- package/dist/http/stored-body-replay.d.ts +5 -3
- package/dist/http/stored-body-replay.js +10 -1
- package/dist/http/wire-types.d.ts +19 -10
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/instruction-source-notice.d.ts +1 -1
- 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-scope.d.ts +2 -2
- package/dist/memory-scope.js +1 -1
- 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/observability/fail-open.d.ts +17 -9
- package/dist/observability/fail-open.js +17 -9
- 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/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/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 +9 -4
- 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 +1 -1
- 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 -12
- package/dist/plugins/file-run-store.js +63 -63
- package/dist/plugins/imported-layer-root-retirement.d.ts +17 -8
- 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 +5 -0
- package/dist/plugins/local-checkpoint-store.js +11 -7
- 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 +91 -25
- package/dist/plugins/local-session-store.js +124 -45
- 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 +4 -3
- package/dist/plugins/memory-engine-pg.js +4 -4
- package/dist/plugins/memory-engine-sql-apply.d.ts +13 -4
- package/dist/plugins/memory-engine-sql-apply.js +1 -1
- package/dist/plugins/memory-engine-tidb.d.ts +8 -5
- package/dist/plugins/memory-engine-tidb.js +7 -8
- package/dist/plugins/one-time-migrations.d.ts +145 -35
- package/dist/plugins/one-time-migrations.js +272 -120
- 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 +8 -8
- package/dist/plugins/permission-rule-store-file.js +14 -2
- package/dist/plugins/pg-pool.d.ts +2 -1
- package/dist/plugins/pg-pool.js +11 -4
- 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/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 +11 -1
- 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 +1 -1
- 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/store-backend.d.ts +35 -8
- package/dist/plugins/store-backend.js +184 -62
- package/dist/plugins/store-contracts.d.ts +9 -2
- package/dist/plugins/store-contracts.js +1 -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 +19 -31
- package/dist/plugins/user-input-ledger-sql.d.ts +1 -1
- 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 +41 -13
- package/dist/rules-consent.js +101 -53
- package/dist/run-local.js +17 -13
- package/dist/runs.d.ts +48 -30
- package/dist/runs.js +26 -16
- package/dist/runtime-caps-resolver.d.ts +15 -8
- package/dist/runtime-caps-resolver.js +14 -10
- package/dist/sealed-key-layout.d.ts +2 -3
- package/dist/sealed-key-layout.js +0 -1
- package/dist/sealed-key.js +7 -5
- package/dist/security.d.ts +5 -3
- 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-resident-background.d.ts +85 -32
- package/dist/session-resident-background.js +75 -7
- package/dist/session-row.d.ts +1 -1
- package/dist/session-sync-kernel.d.ts +1 -1
- package/dist/session-workspace.d.ts +11 -2
- package/dist/session-workspace.js +5 -0
- package/dist/sighup-idle.d.ts +1 -1
- package/dist/store-posture.d.ts +2 -1
- package/dist/stored-request-hooks-m20.d.ts +3 -2
- package/dist/stored-request-hooks-m20.js +19 -14
- package/dist/stores-sql/blob-index-sql.d.ts +148 -0
- package/dist/stores-sql/blob-index-sql.js +154 -0
- package/dist/stores-sql/checkpoint-store-sql.d.ts +1 -1
- package/dist/stores-sql/checkpoint-store-sql.js +11 -27
- 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}/pg-session-storage.d.ts +23 -76
- package/dist/{plugins → stores-sql}/pg-session-storage.js +80 -209
- 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}/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 +32 -122
- package/dist/{plugins → stores-sql}/tidb-session-store.js +71 -171
- package/dist/stores-sql/tool-result-store-sql.d.ts +1 -1
- package/dist/stores-sql/tool-result-store-sql.js +1 -1
- package/dist/stores-sql/windowed-session-storage.d.ts +56 -0
- package/dist/stores-sql/windowed-session-storage.js +61 -0
- 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 +9 -4
- package/dist/task-settings.js +17 -6
- package/dist/tool-approval.d.ts +21 -8
- package/dist/tool-approval.js +10 -6
- package/dist/trace/core-keyset-guard.d.ts +9 -3
- package/dist/trace/engine-notice-wire.d.ts +1 -1
- package/dist/trace/engine-notice-wire.js +2 -0
- package/dist/trace/exit-seat.d.ts +23 -1
- package/dist/trace/exit-seat.js +3 -0
- package/dist/trace/project.d.ts +33 -16
- package/dist/trace/project.js +12 -9
- package/dist/trace/redact.d.ts +1 -1
- package/dist/trace/redact.js +61 -73
- package/dist/trace/self-minted-wire.d.ts +263 -10
- package/dist/trace/self-minted-wire.js +90 -2
- 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 +38 -2
- package/dist/trace/wire-projection-faces.js +26 -1
- package/dist/unread-request-members.d.ts +66 -0
- package/dist/unread-request-members.js +41 -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 +13 -12
- package/scripts/drain-check-local.mjs +2 -28
- package/scripts/drain-check.mysql.sql +2 -18
- package/scripts/drain-check.pg.sql +2 -18
- package/wire-changes/server@7.147.0.json +813 -0
package/dist/config.js
CHANGED
|
@@ -3,7 +3,7 @@ import { DEFAULT_AT_MENTION, DEFAULT_MODEL_REF, mintCapabilityKeys } from "./mod
|
|
|
3
3
|
import { homedir } from "node:os";
|
|
4
4
|
import { isAbsolute, join, posix as posixPath } from "node:path";
|
|
5
5
|
import { fileURLToPath } from "node:url";
|
|
6
|
-
import { compileAllowList, inheritEnvPolicyProblem, BUILTIN_COMPLIANCE_DENIES, COMPLIANCE_CAPABILITIES, CROSS_SESSION_INBOUND_SETTINGS, CROSS_SESSION_DIALOG_EXPIRY_VALUES, compileReadDeny, resolveReadDenyBuiltins, isModelPriced, PROTOCOL_TABLE, RECOMMENDED_SENSITIVE_PATTERNS, judgeRuleToolName, resolveFileHistoryRetention, resolveLockedKeys, validatePermissionRules, WRITE_PROTECTED_DEFAULT_TABLE, resolveWriteProtectedTable, principalInboxConsumerOf, carriesCredential, isReplicableScope } from "@sema-agent/core";
|
|
6
|
+
import { compileAllowList, inheritEnvPolicyProblem, BUILTIN_COMPLIANCE_DENIES, COMPLIANCE_CAPABILITIES, CROSS_SESSION_INBOUND_SETTINGS, CROSS_SESSION_DIALOG_EXPIRY_VALUES, compileReadDeny, resolveReadDenyBuiltins, isModelPriced, PROTOCOL_TABLE, RECOMMENDED_SENSITIVE_PATTERNS, judgeRuleToolName, resolveFileHistoryRetention, resolveLockedKeys, validatePermissionRules, WRITE_PROTECTED_DEFAULT_TABLE, resolveWriteProtectedTable, principalInboxConsumerOf, carriesCredential, isReplicableScope, resolveBashTimeoutCaps } from "@sema-agent/core";
|
|
7
7
|
import { ROSTER_PRIMARY_ROLES, ROSTER_CHEAP_ROLES, WEB_ADMIN_ENV, retiredEnvRefusal, stripControlAndBidi } from "@sema-agent/settings-schema";
|
|
8
8
|
import { parseApprovalHmacKeys, parsePrincipalJwks } from "./auth-keys.js";
|
|
9
9
|
import { DEFAULT_ELICITATION_THROTTLE } from "./elicitation.js";
|
|
@@ -11,6 +11,7 @@ import { buildRuleListJudgeOptions } from "./permission-rule-list.js";
|
|
|
11
11
|
import { isV2ScopeKey, memoryReplicationCoverage, replicatesProjectLayersOf } from "./memory-scope.js";
|
|
12
12
|
import { memorySyncPeerOf } from "./memory-sync-client.js";
|
|
13
13
|
import { buildMemorySyncIdentityBootRefusal, declaredMemorySyncIdentityFlaw } from "./memory-sync-identity.js";
|
|
14
|
+
import { formatEmbedderIdentityToken, formatReembedAssignment, parseEmbedderIdentityToken } from "./memory-embedder-reembed.js";
|
|
14
15
|
import { assertProjectLayerOwnable } from "./project-identity.js";
|
|
15
16
|
import { projectLayerOwnerOf } from "./project-layer-key.js";
|
|
16
17
|
import { DEFAULT_QUESTION_THROTTLE } from "./question.js";
|
|
@@ -24,11 +25,10 @@ import { centerLaneConfigured, pathBaseUrlRefusal } from "./web-admin-client/cen
|
|
|
24
25
|
import { resolveLocalDataRoot } from "./local-data-root.js";
|
|
25
26
|
import { buildWriteProtectionPosture } from "./write-protection.js";
|
|
26
27
|
import { normalizeSshFingerprint } from "./ssh-host-key.js";
|
|
27
|
-
import { buildReadFacePostureNotice, settleDerivedReadFace } from "./read-face-posture.js";
|
|
28
28
|
import { THINKING_LEVELS, THINKING_FORMATS, buildModelCompat, isThinkingFormat, isThinkingTier } from "./model-compat.js";
|
|
29
29
|
import {} from "./posture-source.js";
|
|
30
30
|
import { COST_QUOTA_WINDOW_SEC_RANGE, costQuotaWindowSecInRange } from "./observability/cost-quota.js";
|
|
31
|
-
import { NAME_TABLE_BEHAVIOR, TOOL_NAME_ROSTER, describeUnmatchableRuleName, ruleEntryToolName, unmatchableRuleNameOf } from "./namespaced-rule-name.js";
|
|
31
|
+
import { NAME_TABLE_BEHAVIOR, TOOL_NAME_ROSTER, describeUnmatchableRuleName, isRetiredWithoutSuccessor, retiredWithoutSuccessorEntries, ruleEntryToolName, unmatchableRuleNameOf } from "./namespaced-rule-name.js";
|
|
32
32
|
import { bakeOperatorPrincipalsRefusal, bakeRunnerCredentialRefusal, centerIdentityRefusal, halfOpenDirectDoorRefusal, leaderDurableStoreRefusal, operatorPrincipalsRequiredRefusal, operatorSingleUserRefusal, remoteConfigProviderUrlRefusal, retentionLaneRefusal, workflowParkDecisionDomainRefusal } from "./config-invariants.js";
|
|
33
33
|
import { declaredSemaConfigDir } from "./sema-config-dir.js";
|
|
34
34
|
import { lkgPathOverrideOf } from "./config-lkg.js";
|
|
@@ -39,7 +39,7 @@ import { SANDBOX_IPV6_DEFAULT, SANDBOX_IPV6_WORDS } from "./sandbox-egress-polic
|
|
|
39
39
|
import { WORKSPACE_CACHE_DEFAULT, WORKSPACE_CACHE_MOUNT_DEFAULT, WORKSPACE_CACHE_MOUNT_RESERVED, WORKSPACE_CACHE_SIZE_DEFAULT, WORKSPACE_CACHE_WORDS, isK8sQuantity, mountsOverlap, reservedMountCollision } from "./workspace-cache.js";
|
|
40
40
|
import { DEPLOYMENT_SHAPE_PREDICATES } from "./deployment-shape.js";
|
|
41
41
|
import { sandboxForwardedEnvOf } from "./execution-config-root.js";
|
|
42
|
-
import { SANDBOX_READ_FLOOR_DEFAULT, SANDBOX_READ_FLOOR_WORDS,
|
|
42
|
+
import { SANDBOX_READ_FLOOR_DEFAULT, SANDBOX_READ_FLOOR_WORDS, laneMissingEnv, readDeclaredLaneTable } from "./execution-lane-caps.js";
|
|
43
43
|
import { MEMORY_ENGINE_BACKENDS, SESSION_BACKENDS, STORE_BACKENDS } from "@sema-agent/settings-schema/execution-lanes";
|
|
44
44
|
import { AUTONOMY_MODES } from "./runtime-governance.js";
|
|
45
45
|
import { MAX_NAMED_INERT_ENTRIES, allowLayerEntryCountIssue, describeInertRuleEntries, inertRuleEntriesOf, inertRuleEntryGuidance, ruleEntryListShapeOk } from "./rule-entry-list.js";
|
|
@@ -192,14 +192,6 @@ const CONFIG_NOTICES = [];
|
|
|
192
192
|
export function drainConfigNotices() {
|
|
193
193
|
return CONFIG_NOTICES.splice(0, CONFIG_NOTICES.length);
|
|
194
194
|
}
|
|
195
|
-
let EXEC_LANE_NOTICE;
|
|
196
|
-
function buildExecLaneNotice(remoteExec) {
|
|
197
|
-
const lane = executionLaneOf(remoteExec?.provider);
|
|
198
|
-
return {
|
|
199
|
-
lane,
|
|
200
|
-
source: lane === "in-process" ? "default-unset" : DEPLOYMENT_SHAPE_PREDICATES.singleMachineDefaultLane.holds({ remoteExec }) ? "default-local-provider" : "explicit-env",
|
|
201
|
-
};
|
|
202
|
-
}
|
|
203
195
|
const ENV_VALUE_ECHO_CHARS = 120;
|
|
204
196
|
export function parseConfigProvider() {
|
|
205
197
|
const raw = process.env.CONFIG_PROVIDER;
|
|
@@ -208,7 +200,7 @@ export function parseConfigProvider() {
|
|
|
208
200
|
const word = CONFIG_PROVIDER_WORDS.find((w) => w === raw);
|
|
209
201
|
if (word === undefined) {
|
|
210
202
|
throw new Error(`env CONFIG_PROVIDER="${echoCallerText(raw, { maxChars: ENV_VALUE_ECHO_CHARS })}" must be one of: ${CONFIG_PROVIDER_WORDS.join(", ")} — or leave it unset (then ${WEB_ADMIN_ENV.url}, if set, selects the center as the config source; otherwise this worker is env-only). ` +
|
|
211
|
-
`The word is matched exactly (no trimming, no case folding). Refusing to boot rather than guessing: the config source
|
|
203
|
+
`The word is matched exactly (no trimming, no case folding). Refusing to boot rather than guessing: the config source and the local config root both key on this one word.`);
|
|
212
204
|
}
|
|
213
205
|
return word;
|
|
214
206
|
}
|
|
@@ -254,10 +246,6 @@ export function logConfigDiagnostics(logger) {
|
|
|
254
246
|
}
|
|
255
247
|
}
|
|
256
248
|
}
|
|
257
|
-
const laneNotice = EXEC_LANE_NOTICE;
|
|
258
|
-
EXEC_LANE_NOTICE = undefined;
|
|
259
|
-
if (laneNotice && logger.info)
|
|
260
|
-
logger.info("exec_lane_selected", { lane: laneNotice.lane, source: laneNotice.source });
|
|
261
249
|
if (logger.debug) {
|
|
262
250
|
for (const k of configKnobTable()) {
|
|
263
251
|
logger.debug("config_knob_polarity", {
|
|
@@ -407,8 +395,21 @@ function parseDeviceRelayUrlEnv(raw) {
|
|
|
407
395
|
}
|
|
408
396
|
return { kind: "url", url: raw };
|
|
409
397
|
}
|
|
398
|
+
export function entryDeclarableRemoteExec(lane) {
|
|
399
|
+
switch (lane) {
|
|
400
|
+
case "host":
|
|
401
|
+
return {
|
|
402
|
+
provider: "host",
|
|
403
|
+
...(process.env.HOST_WORKSPACE_BASE ? { workspaceBase: process.env.HOST_WORKSPACE_BASE } : {}),
|
|
404
|
+
...((n) => (n !== undefined ? { commandTimeoutMs: n } : {}))(optNumEnvStrict("HOST_COMMAND_TIMEOUT_MS")),
|
|
405
|
+
};
|
|
406
|
+
case "none":
|
|
407
|
+
return { provider: "none" };
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
const envNamesNoLane = (raw) => raw === undefined || raw === "";
|
|
410
411
|
function declaredExecutionLane(raw) {
|
|
411
|
-
if (raw
|
|
412
|
+
if (envNamesNoLane(raw))
|
|
412
413
|
return undefined;
|
|
413
414
|
const table = readDeclaredLaneTable(raw);
|
|
414
415
|
if ("refusal" in table)
|
|
@@ -422,7 +423,7 @@ function declaredExecutionLane(raw) {
|
|
|
422
423
|
const missing = laneMissingEnv(lane, process.env);
|
|
423
424
|
if (missing.length > 0) {
|
|
424
425
|
throw new Error(`REMOTE_EXEC=${lane} but required env ${missing.join(", ")} ${missing.length === 1 ? "is" : "are"} unset, empty or whitespace-only — it counts as absent: ` +
|
|
425
|
-
`refusing to start rather than silently
|
|
426
|
+
`refusing to start rather than silently running on another lane (#157; set ${missing.length === 1 ? "it" : "them"}, or declare REMOTE_EXEC=none if the agent's tools need no execution environment).`);
|
|
426
427
|
}
|
|
427
428
|
return lane;
|
|
428
429
|
}
|
|
@@ -563,9 +564,9 @@ function ownCredentialNameProblem(name, channel) {
|
|
|
563
564
|
}
|
|
564
565
|
const NAMES_IN_FORCE = {
|
|
565
566
|
LSP_ENV_ALLOW: (c) => c.lspEnvAllow,
|
|
566
|
-
E2B_SANDBOX_ENV: (c) => (c.remoteExec
|
|
567
|
-
K8S_SANDBOX_ENV: (c) => (c.remoteExec
|
|
568
|
-
DOCKER_SANDBOX_ENV: (c) => (c.remoteExec
|
|
567
|
+
E2B_SANDBOX_ENV: (c) => (c.remoteExec.provider === "e2b" ? Object.keys(sandboxForwardedEnvOf(c)) : []),
|
|
568
|
+
K8S_SANDBOX_ENV: (c) => (c.remoteExec.provider === "k8s" ? Object.keys(sandboxForwardedEnvOf(c)) : []),
|
|
569
|
+
DOCKER_SANDBOX_ENV: (c) => (c.remoteExec.provider === "local-docker" ? Object.keys(sandboxForwardedEnvOf(c)) : []),
|
|
569
570
|
};
|
|
570
571
|
const SERVER_ENV_NAME_ALLOWLIST_KNOBS = Object.keys(NAMES_IN_FORCE);
|
|
571
572
|
export function sandboxEnvNamesInForce(seats) {
|
|
@@ -1060,16 +1061,17 @@ function parseModelDomain() {
|
|
|
1060
1061
|
}
|
|
1061
1062
|
const extraBody = buildExtraBody();
|
|
1062
1063
|
const thinkingDefault = parseDefaultThinking(process.env.MODEL_DEFAULT_THINKING);
|
|
1063
|
-
const
|
|
1064
|
+
const envApi = provider === "anthropic" ? "anthropic-messages" : "openai-completions";
|
|
1065
|
+
const envCompatDeclared = buildModelCompat("openai-completions", {
|
|
1064
1066
|
reasoningEffortLevels: parseReasoningEffortLevels(csv("MODEL_REASONING_EFFORT_LEVELS")),
|
|
1065
1067
|
thinkingFormat: parseThinkingFormat(process.env.MODEL_THINKING_FORMAT),
|
|
1066
1068
|
});
|
|
1067
|
-
const envCompat =
|
|
1069
|
+
const envCompat = envApi === "openai-completions" ? envCompatDeclared : undefined;
|
|
1068
1070
|
const modelCapability = { reasoning: parseBoolWord("MODEL_REASONING", process.env.MODEL_REASONING), vision: parseBoolWord("MODEL_VISION", process.env.MODEL_VISION) };
|
|
1069
1071
|
const model = {
|
|
1070
1072
|
id: modelId,
|
|
1071
1073
|
name: modelId,
|
|
1072
|
-
api:
|
|
1074
|
+
api: envApi,
|
|
1073
1075
|
provider,
|
|
1074
1076
|
baseUrl: "",
|
|
1075
1077
|
...mintCapabilityKeys(modelCapability),
|
|
@@ -1312,7 +1314,8 @@ function findUnmatchableToolNames(names, opts) {
|
|
|
1312
1314
|
}
|
|
1313
1315
|
}
|
|
1314
1316
|
const subject = opts.consumer === "tool-name-table" ? name : ruleEntryToolName(name);
|
|
1315
|
-
const
|
|
1317
|
+
const judged = unmatchableRuleNameOf(subject, opts.behavior);
|
|
1318
|
+
const verdict = opts.noticeSeat !== undefined && isRetiredWithoutSuccessor(judged) ? undefined : judged;
|
|
1316
1319
|
if (verdict?.kind === "retired") {
|
|
1317
1320
|
out.push({ name, guidance: describeUnmatchableRuleName(verdict, subject), reason: verdict.kind });
|
|
1318
1321
|
continue;
|
|
@@ -1425,9 +1428,21 @@ function parseApprovalDomain(ctx) {
|
|
|
1425
1428
|
const dgHmacKeys = parseApprovalHmacKeys(process.env.APPROVAL_HMAC_KEYS, announceKeySetRejection("APPROVAL_HMAC_KEYS"));
|
|
1426
1429
|
const durableApproval = postureOn("DURABLE_APPROVAL", infraReady);
|
|
1427
1430
|
const rejectUnmatchableToolNames = (envName, names) => {
|
|
1428
|
-
const unmatchable = unmatchableToolNamesRefusal(envName, names, { consumer: "tool-name-table", behavior: NAME_TABLE_BEHAVIOR });
|
|
1431
|
+
const unmatchable = unmatchableToolNamesRefusal(envName, names, { consumer: "tool-name-table", behavior: NAME_TABLE_BEHAVIOR, noticeSeat: "server" });
|
|
1429
1432
|
if (unmatchable !== undefined)
|
|
1430
1433
|
throw new Error(unmatchable.message);
|
|
1434
|
+
const skipped = retiredWithoutSuccessorEntries(names, NAME_TABLE_BEHAVIOR);
|
|
1435
|
+
if (skipped.length > 0) {
|
|
1436
|
+
CONFIG_NOTICES.push({
|
|
1437
|
+
level: "warn",
|
|
1438
|
+
event: "approval_list_legacy_tool_name",
|
|
1439
|
+
fields: {
|
|
1440
|
+
env: envName,
|
|
1441
|
+
entries: JSON.stringify(skipped.map((s) => s.entry)),
|
|
1442
|
+
note: `${skipped.map((s) => `${displayListEntry(s.entry)} (${s.guidance})`).join("; ")} — ${skipped.length === 1 ? "a tool name" : "tool names"} the engine retired with no successor: ${skipped.length === 1 ? "it reaches" : "they reach"} no tool this server knows, so ${skipped.length === 1 ? "the entry guards" : "the entries guard"} nothing (kept as written: a tool of that exact name mounted by an embedder is still matched) and the server starts. Remove ${skipped.length === 1 ? "it" : "them"} from ${envName} if written for the retired tool.`,
|
|
1443
|
+
},
|
|
1444
|
+
});
|
|
1445
|
+
}
|
|
1431
1446
|
return names;
|
|
1432
1447
|
};
|
|
1433
1448
|
return {
|
|
@@ -1659,6 +1674,7 @@ function parseMemoryEmbedder(ctx) {
|
|
|
1659
1674
|
const dimRaw = process.env.MEMORY_EMBEDDER_DIM || undefined;
|
|
1660
1675
|
const apiKey = process.env.MEMORY_EMBEDDER_API_KEY || undefined;
|
|
1661
1676
|
const timeoutRaw = process.env.MEMORY_EMBEDDER_TIMEOUT_MS || undefined;
|
|
1677
|
+
const reembedRaw = process.env.MEMORY_EMBEDDER_REEMBED || undefined;
|
|
1662
1678
|
const trio = [
|
|
1663
1679
|
["MEMORY_EMBEDDER_ENDPOINT", endpoint],
|
|
1664
1680
|
["MEMORY_EMBEDDER_MODEL", model],
|
|
@@ -1666,8 +1682,11 @@ function parseMemoryEmbedder(ctx) {
|
|
|
1666
1682
|
];
|
|
1667
1683
|
const missing = trio.filter(([, v]) => v === undefined).map(([name]) => name);
|
|
1668
1684
|
if (missing.length === 3) {
|
|
1669
|
-
|
|
1670
|
-
|
|
1685
|
+
const dependents = [["MEMORY_EMBEDDER_TIMEOUT_MS", timeoutRaw], ["MEMORY_EMBEDDER_API_KEY", apiKey], ["MEMORY_EMBEDDER_REEMBED", reembedRaw]]
|
|
1686
|
+
.filter(([, v]) => v !== undefined)
|
|
1687
|
+
.map(([name]) => name);
|
|
1688
|
+
if (dependents.length > 0) {
|
|
1689
|
+
throw new Error(`${dependents.join("/")} ${dependents.length === 1 ? "is" : "are"} set but the embedder itself is not configured — refusing to start half-configured (set MEMORY_EMBEDDER_ENDPOINT, MEMORY_EMBEDDER_MODEL and MEMORY_EMBEDDER_DIM to enable the memory vector plane, or unset the other MEMORY_EMBEDDER_* keys)`);
|
|
1671
1690
|
}
|
|
1672
1691
|
return undefined;
|
|
1673
1692
|
}
|
|
@@ -1690,12 +1709,26 @@ function parseMemoryEmbedder(ctx) {
|
|
|
1690
1709
|
if (!ctx.memoryEngineEnabled) {
|
|
1691
1710
|
throw new Error("MEMORY_EMBEDDER_* is set but MEMORY_ENGINE=off — the memory engine is not wired at all, so the embedder would never be called; unset one of the two (#228)");
|
|
1692
1711
|
}
|
|
1712
|
+
if (reembedRaw !== undefined) {
|
|
1713
|
+
const configured = formatEmbedderIdentityToken({ model, dimensions });
|
|
1714
|
+
const confirmed = parseEmbedderIdentityToken(reembedRaw);
|
|
1715
|
+
if (confirmed === undefined) {
|
|
1716
|
+
throw new Error(`MEMORY_EMBEDDER_REEMBED=${JSON.stringify(reembedRaw.length > 200 ? `${reembedRaw.slice(0, 200)}…` : reembedRaw)} is not a re-embed confirmation — the value must name the embedder identity being confirmed as <model>/<dimensions> ` +
|
|
1717
|
+
`(for this configuration: ${formatReembedAssignment({ model, dimensions })}). It confirms that the memory vector column may be cleared and re-embedded into that identity when the recorded identity does not match; ` +
|
|
1718
|
+
"an on/off value is refused because it would also confirm the NEXT model change. Fix the value or unset it.");
|
|
1719
|
+
}
|
|
1720
|
+
if (confirmed.model !== model || confirmed.dimensions !== dimensions) {
|
|
1721
|
+
throw new Error(`MEMORY_EMBEDDER_REEMBED=${formatEmbedderIdentityToken(confirmed)} confirms re-embedding into a different identity than the configured embedder ${configured} ` +
|
|
1722
|
+
`(MEMORY_EMBEDDER_MODEL / MEMORY_EMBEDDER_DIM) — a stale confirmation never clears vectors for another model. Set ${formatReembedAssignment({ model, dimensions })} to confirm this change, or unset it.`);
|
|
1723
|
+
}
|
|
1724
|
+
}
|
|
1693
1725
|
return {
|
|
1694
1726
|
endpoint,
|
|
1695
1727
|
model,
|
|
1696
1728
|
dimensions,
|
|
1697
1729
|
timeoutMs: numEnvBounded("MEMORY_EMBEDDER_TIMEOUT_MS", "30000", 1000, 300_000),
|
|
1698
1730
|
...(apiKey !== undefined ? { apiKey } : {}),
|
|
1731
|
+
...(reembedRaw !== undefined ? { reembedConfirmed: true } : {}),
|
|
1699
1732
|
};
|
|
1700
1733
|
}
|
|
1701
1734
|
function parseMemoryConsolidationDriver() {
|
|
@@ -1959,8 +1992,14 @@ function parseAuthDomain(ctx) {
|
|
|
1959
1992
|
principalJwtMaxTtlSec,
|
|
1960
1993
|
};
|
|
1961
1994
|
}
|
|
1995
|
+
export const BG_AGENT_SILENCE_FLOOR_MS = 10 * 60_000;
|
|
1996
|
+
export function backgroundAgentStallFloorMs(f) {
|
|
1997
|
+
const personWaitMs = Math.max(f.streamApproval.windowMs, f.streamApproval.unreachedTtlMs, (f.questionThrottle ?? DEFAULT_QUESTION_THROTTLE).ttlMs, f.mcpElicitation.throttle.ttlMs);
|
|
1998
|
+
return Math.max(BG_AGENT_SILENCE_FLOOR_MS, personWaitMs + f.commandCeilingMs);
|
|
1999
|
+
}
|
|
1962
2000
|
function parseOrchestrationDomain(ctx) {
|
|
1963
2001
|
const { postureOn, singleUserTurnkey } = ctx;
|
|
2002
|
+
const backgroundAgentStallFloor = backgroundAgentStallFloorMs({ ...ctx.personGates, commandCeilingMs: resolveBashTimeoutCaps().maxMs });
|
|
1964
2003
|
const workflowSizeGuidelineRaw = process.env.WORKFLOW_SIZE_GUIDELINE;
|
|
1965
2004
|
if (workflowSizeGuidelineRaw !== undefined && !["small", "medium", "large", "unrestricted"].includes(workflowSizeGuidelineRaw)) {
|
|
1966
2005
|
throw new Error(`WORKFLOW_SIZE_GUIDELINE must be small|medium|large|unrestricted, got "${workflowSizeGuidelineRaw}"`);
|
|
@@ -1983,7 +2022,6 @@ function parseOrchestrationDomain(ctx) {
|
|
|
1983
2022
|
? { readFace: enumEnv("READ_FACE", "roots", ["open", "roots"]), readFaceSource: "env" }
|
|
1984
2023
|
: { readFaceSource: "engine-default" };
|
|
1985
2024
|
return {
|
|
1986
|
-
requireExecutionLane: boolEnv("REQUIRE_EXECUTION_LANE", false),
|
|
1987
2025
|
...readFaceFacts,
|
|
1988
2026
|
...optionalEnumKey("taskWriteFaceEscalation", "TASK_WRITE_FACE_ESCALATION", process.env.TASK_WRITE_FACE_ESCALATION, TASK_WRITE_FACE_ESCALATIONS),
|
|
1989
2027
|
...(process.env.READ_DENY_PATTERNS !== undefined ? { readDenyPatterns: parseReadDenyPatternsEnv(process.env.READ_DENY_PATTERNS) } : {}),
|
|
@@ -2064,12 +2102,8 @@ function parseOrchestrationDomain(ctx) {
|
|
|
2064
2102
|
...(process.env.ADB_MOUNT_PATH ? { mountPath: process.env.ADB_MOUNT_PATH } : {}),
|
|
2065
2103
|
}
|
|
2066
2104
|
:
|
|
2067
|
-
declaredLane === "host"
|
|
2068
|
-
?
|
|
2069
|
-
provider: "host",
|
|
2070
|
-
...(process.env.HOST_WORKSPACE_BASE ? { workspaceBase: process.env.HOST_WORKSPACE_BASE } : {}),
|
|
2071
|
-
...((n) => (n !== undefined ? { commandTimeoutMs: n } : {}))(optNumEnvStrict("HOST_COMMAND_TIMEOUT_MS")),
|
|
2072
|
-
}
|
|
2105
|
+
declaredLane === "host" || declaredLane === "none"
|
|
2106
|
+
? entryDeclarableRemoteExec(declaredLane)
|
|
2073
2107
|
:
|
|
2074
2108
|
declaredLane === "local-docker" && process.env.DOCKER_IMAGE
|
|
2075
2109
|
? {
|
|
@@ -2103,9 +2137,7 @@ function parseOrchestrationDomain(ctx) {
|
|
|
2103
2137
|
...(process.env.DEVICE_SUPERSEDE ? { supersede: enumEnv("DEVICE_SUPERSEDE", "stale_only", ["stale_only", "deny"]) } : {}),
|
|
2104
2138
|
}
|
|
2105
2139
|
:
|
|
2106
|
-
|
|
2107
|
-
? { provider: "host", singleMachineDefault: true }
|
|
2108
|
-
: undefined,
|
|
2140
|
+
undefined,
|
|
2109
2141
|
worktreeIsolation: boolEnv("WORKTREE_ISOLATION_ENABLED", false) && process.env.WORKTREE_REPO_ROOT
|
|
2110
2142
|
? {
|
|
2111
2143
|
repoRoot: process.env.WORKTREE_REPO_ROOT,
|
|
@@ -2136,7 +2168,8 @@ function parseOrchestrationDomain(ctx) {
|
|
|
2136
2168
|
workflowRunRetentionMs: clampEnvWithWarn("WORKFLOW_RUN_RETENTION_MS", String(30 * 24 * 60 * 60 * 1000), 60_000),
|
|
2137
2169
|
...(usageWindows ? { usageWindows } : {}),
|
|
2138
2170
|
backgroundAgentRetentionMs: clampEnvWithWarn("BG_AGENT_RETENTION_MS", String(7 * 24 * 60 * 60 * 1000), 60_000),
|
|
2139
|
-
backgroundAgentStaleRunningMs: clampEnvWithWarn("BG_AGENT_STALE_RUNNING_MS", String(15 * 60_000),
|
|
2171
|
+
backgroundAgentStaleRunningMs: clampEnvWithWarn("BG_AGENT_STALE_RUNNING_MS", String(15 * 60_000), BG_AGENT_SILENCE_FLOOR_MS),
|
|
2172
|
+
backgroundAgentStallMs: clampEnvWithWarn("BG_AGENT_STALL_MS", String(backgroundAgentStallFloor), backgroundAgentStallFloor),
|
|
2140
2173
|
backgroundAgentParkClaimStaleMs: clampEnvWithWarn("BG_AGENT_PARK_CLAIM_STALE_MS", String(60 * 60_000), 60_000),
|
|
2141
2174
|
rosterRetentionMs: clampEnvWithWarn("ROSTER_RETENTION_MS", String(30 * 24 * 60 * 60 * 1000), 60_000),
|
|
2142
2175
|
leaderRunStaleMs: clampEnvWithWarn("LEADER_RUN_STALE_MS", String(26 * 60 * 60 * 1000), 60_000),
|
|
@@ -2541,11 +2574,11 @@ const AUTH_GROUP_KEYS = [
|
|
|
2541
2574
|
"principalJwtMaxTtlSec", "authBridgeIssuer", "bindHost", "bindHostSource",
|
|
2542
2575
|
];
|
|
2543
2576
|
const ORCHESTRATION_GROUP_KEYS = [
|
|
2544
|
-
"sandboxGit", "remoteExec", "remoteExecHomeDir", "
|
|
2577
|
+
"sandboxGit", "remoteExec", "remoteExecHomeDir", "worktreeIsolation", "leaderEnabled", "leaderFanoutEnabled", "routerEnabled", "selfOrchestrationEnabled",
|
|
2545
2578
|
"selfOrchestrationModels", "selfOrchestrationWorkerIsolation", "forkEnabled", "experimentalObserverAgents",
|
|
2546
2579
|
"schedulerEnabled", "schedulerSessionWakeup", "schedulerSessionLifetime", "schedulerStorePath", "planModeEnabled", "hooksTimeoutMs", "workflowRunStoreBackend",
|
|
2547
2580
|
"workflowOrphanGraceMs", "workflowJournalRetentionMs", "workflowRunRetentionMs", "usageWindows", "workflowAgentsReadOnly",
|
|
2548
|
-
"workflowSizeGuideline", "backgroundAgentRetentionMs", "backgroundAgentStaleRunningMs",
|
|
2581
|
+
"workflowSizeGuideline", "backgroundAgentRetentionMs", "backgroundAgentStaleRunningMs", "backgroundAgentStallMs",
|
|
2549
2582
|
"backgroundAgentParkClaimStaleMs", "delegationEntryCaps", "rosterRetentionMs", "leaderRunStaleMs", "scratchpadSweepTtlMs", "sandboxPkgSource", "sandboxPkgSourceCustom",
|
|
2550
2583
|
"sessionAutoTitle", "sessionAutoTitleSource", "selectEnvironmentTool", "envFactsEnabled", "toolDeferLongtail", "lspEnabled", "lspHostEnabled", "lspEnvAllow",
|
|
2551
2584
|
"imageBakes", "readFace", "readFaceSource", "taskWriteFaceEscalation", "readDenyPatterns", "readDenyBuiltinTiers", "readDenyBuiltinExclude", "readDenyFloorRequired", "sandboxReadFloor",
|
|
@@ -2599,6 +2632,9 @@ export function attachConfigGroups(flat) {
|
|
|
2599
2632
|
}
|
|
2600
2633
|
return flat;
|
|
2601
2634
|
}
|
|
2635
|
+
function attachLoadedConfigGroups(flat) {
|
|
2636
|
+
return attachConfigGroups(flat);
|
|
2637
|
+
}
|
|
2602
2638
|
function k8sWorkspaceStore() {
|
|
2603
2639
|
const workspacePersist = enumEnv("WORKSPACE_PERSIST", WORKSPACE_PERSIST_DEFAULT, WORKSPACE_PERSIST_WORDS);
|
|
2604
2640
|
const workspaceSnapshotKeep = numEnvBounded("WORKSPACE_SNAPSHOT_KEEP", String(WORKSPACE_SNAPSHOT_KEEP_DEFAULT), WORKSPACE_SNAPSHOT_KEEP_RANGE.min, WORKSPACE_SNAPSHOT_KEEP_RANGE.max);
|
|
@@ -2669,7 +2705,6 @@ function k8sWorkspaceCache() {
|
|
|
2669
2705
|
return { mount, size };
|
|
2670
2706
|
}
|
|
2671
2707
|
export function loadConfig() {
|
|
2672
|
-
EXEC_LANE_NOTICE = undefined;
|
|
2673
2708
|
rejectRetiredEnvs();
|
|
2674
2709
|
CONFIG_WARNINGS.length = 0;
|
|
2675
2710
|
CONFIG_NOTICES.length = 0;
|
|
@@ -2689,11 +2724,7 @@ export function loadConfig() {
|
|
|
2689
2724
|
const approval = parseApprovalDomain({ postureOn, singleUserTurnkey, infraReady: durableStoreReady });
|
|
2690
2725
|
const memory = parseMemoryDomain({ requirePrincipal });
|
|
2691
2726
|
const auth = parseAuthDomain({ requirePrincipal });
|
|
2692
|
-
const orchestration = parseOrchestrationDomain({ postureOn, singleUserTurnkey,
|
|
2693
|
-
settleDerivedReadFace(orchestration, singleUserTurnkey);
|
|
2694
|
-
const readFaceNotice = buildReadFacePostureNotice(orchestration);
|
|
2695
|
-
if (readFaceNotice !== undefined)
|
|
2696
|
-
CONFIG_NOTICES.push({ level: "info", ...readFaceNotice });
|
|
2727
|
+
const orchestration = parseOrchestrationDomain({ postureOn, singleUserTurnkey, personGates: approval });
|
|
2697
2728
|
const limitsHttp = parseLimitsHttpDomain();
|
|
2698
2729
|
const observability = parseObservabilityDomain();
|
|
2699
2730
|
const integrations = parseIntegrationsDomain({ requirePrincipal, configProvider });
|
|
@@ -2755,12 +2786,7 @@ export function loadConfig() {
|
|
|
2755
2786
|
if (parkDecisionDomainRefusal !== undefined) {
|
|
2756
2787
|
throw new Error(parkDecisionDomainRefusal);
|
|
2757
2788
|
}
|
|
2758
|
-
|
|
2759
|
-
if (laneRequiredRefusal !== undefined) {
|
|
2760
|
-
throw new Error(laneRequiredRefusal);
|
|
2761
|
-
}
|
|
2762
|
-
EXEC_LANE_NOTICE = buildExecLaneNotice(orchestration.remoteExec);
|
|
2763
|
-
return attachConfigGroups({
|
|
2789
|
+
return attachLoadedConfigGroups({
|
|
2764
2790
|
...store,
|
|
2765
2791
|
...modelPlane,
|
|
2766
2792
|
...approval,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { failureCodeOf } from "./terminal.js";
|
|
2
2
|
import { StoredSession } from "@sema-agent/core";
|
|
3
|
-
import { TiDBSessionStorage } from "./
|
|
3
|
+
import { TiDBSessionStorage } from "./stores-sql/tidb-session-storage.js";
|
|
4
4
|
const SUBSTANTIVE_CHARS = 200;
|
|
5
5
|
const REP_WINDOW = 8192;
|
|
6
6
|
const MIN_REPEATS = 3;
|
package/dist/deploy-facts.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { TENANT_SEPARATION_WORDS } from "@sema-agent/settings-schema/execution-lanes";
|
|
2
|
-
import { CHECKPOINT_CTX_KEY_SUBDIR, SEALED_KEY_DIR_MODE
|
|
2
|
+
import { CHECKPOINT_CTX_KEY_SUBDIR, SEALED_KEY_DIR_MODE } from "./sealed-key-layout.js";
|
|
3
|
+
import { OWNER_ONLY_FILE_MODE } from "./plugins/owner-only-file-mode.js";
|
|
3
4
|
export const DEPLOY_FACTS_DIR = "deploy/facts";
|
|
4
5
|
export const DEPLOY_FACTS_MEMBERS = ["lanes", "sandbox-rbac", "sealed-key"];
|
|
5
6
|
export const DEPLOY_FACTS_CHANGES_FILE = "CHANGES.json";
|
|
@@ -65,7 +66,7 @@ export const SEALED_KEY_FACTS = {
|
|
|
65
66
|
dirPath: SEALED_KEY_DIR_PATH_FORMS[0],
|
|
66
67
|
subdirs: [CHECKPOINT_CTX_KEY_SUBDIR],
|
|
67
68
|
dirMode: octal(SEALED_KEY_DIR_MODE),
|
|
68
|
-
fileMode: octal(
|
|
69
|
+
fileMode: octal(OWNER_ONLY_FILE_MODE),
|
|
69
70
|
requirements: SEALED_KEY_REQUIREMENTS,
|
|
70
71
|
};
|
|
71
72
|
export const SEALED_KEY_FACTS_SCHEMA = {
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
* ## 两根轴,每根轴一个读口(原始配置键只在这两个函数里被读)
|
|
10
10
|
* · `principal` —— 运维的 `REQUIRE_PRINCIPAL` 声明({@link readPrincipalAxis})。
|
|
11
11
|
* · `lane` —— `REMOTE_EXEC` 的归一车道词(`executionLaneOf`,认不出 ⇒ `undefined`,行必须 fail-closed)+ 那条车道的能力表行 +
|
|
12
|
-
* 这份部署上执行环境的能力块(唯一作者 `capabilitiesFor`;k8s 的快照店是它的输入)+ 车道子旋钮(k8s
|
|
12
|
+
* 这份部署上执行环境的能力块(唯一作者 `capabilitiesFor`;k8s 的快照店是它的输入)+ 车道子旋钮(k8s 运行时类)({@link readLaneAxis})。
|
|
13
13
|
*
|
|
14
14
|
* ## 轴列不是注释,是型
|
|
15
15
|
* 每行的判官只收到它**声明**的那几根轴的事实({@link DeploymentShapeFacts}),读不到配置本身 —— 判官碰一根没声明的轴 = 编译红;
|
|
@@ -34,14 +34,14 @@ export interface PrincipalAxisFacts {
|
|
|
34
34
|
/** 运维声明了 `REQUIRE_PRINCIPAL=true`。 */
|
|
35
35
|
readonly declared: boolean;
|
|
36
36
|
}
|
|
37
|
-
/** `lane`
|
|
37
|
+
/** `lane` 轴读的配置键:**已合成**的 `remoteExec` 里本表用得到的那几键(`ServiceConfig` 的判别联合每一臂结构上都满足;车道必在 ——
|
|
38
|
+
* 没有声明的部署在执行车道合成步拒启)。`provider` 收开放串:手搓的部署形 / 外部输入上认不出的词 ⇒ 行在 `lane` 那一格 fail-closed。 */
|
|
38
39
|
export interface LaneAxisInput {
|
|
39
|
-
readonly remoteExec
|
|
40
|
-
readonly provider
|
|
40
|
+
readonly remoteExec: {
|
|
41
|
+
readonly provider: string;
|
|
41
42
|
readonly runtimeClass?: string | undefined;
|
|
42
43
|
readonly s3Snapshot?: unknown;
|
|
43
|
-
|
|
44
|
-
} | undefined;
|
|
44
|
+
};
|
|
45
45
|
}
|
|
46
46
|
/** `lane` 轴的事实。 */
|
|
47
47
|
export interface LaneAxisFacts {
|
|
@@ -53,8 +53,6 @@ export interface LaneAxisFacts {
|
|
|
53
53
|
readonly block: ExecutionEnvCapabilities | undefined;
|
|
54
54
|
/** k8s 的 `runtimeClass`(别的车道 `undefined`)。 */
|
|
55
55
|
readonly k8sRuntimeClass: string | undefined;
|
|
56
|
-
/** host 车道值上带「单机形缺省」记号(唯一写者 = `config.ts` 三元链的隐式 host 尾臂;显式 `REMOTE_EXEC=host` 与文件覆写都不带)。 */
|
|
57
|
-
readonly singleMachineDefault: boolean;
|
|
58
56
|
}
|
|
59
57
|
/** 轴全集(闭集)→ 读入形与事实型。加一根轴 = 在这里加一键 + {@link readAxis} 的穷举 switch 加一臂(漏一处即编译红)。 */
|
|
60
58
|
interface AxisShapes {
|
|
@@ -99,8 +97,8 @@ export declare const DEPLOYMENT_SHAPE_PREDICATES: Readonly<{
|
|
|
99
97
|
callerOwnsWorkerDisk: DeploymentShapePredicate<"lane" | "principal">;
|
|
100
98
|
/** wire `executionLane.toolsOnThisHost` 与出厂 / 中心技能的 `baseDir`:只问文件系统同一性,与租户无关(出厂内容每个租户拿到同一份)。 */
|
|
101
99
|
toolsOnThisHost: DeploymentShapePredicate<"lane">;
|
|
102
|
-
/** `
|
|
103
|
-
|
|
100
|
+
/** 无手形(声明 `none`;判据读执行环境块 `io`,不点名车道词)且单主:进程级消费者(hooks 命令、项目上下文本机读、卡批规则 root)看到的就是引擎自己的进程 cwd / env。 */
|
|
101
|
+
noHandsSingleUser: DeploymentShapePredicate<"lane" | "principal">;
|
|
104
102
|
/** 任务层替部署声明宿主姿态(bypassPermissions 开写面 / host shell 继承整份环境)的射程:device 车道上跨租户宿主穿越结构性不存在(clay 裁定③)。 */
|
|
105
103
|
taskHostPostureDeclarations: DeploymentShapePredicate<"lane" | "principal">;
|
|
106
104
|
/** 写门走代理裁决(执行环境块 `hostLocalPaths` 为假:路径不是本 worker 盘上的文件);认不出的词 ⇒ 走代理(代理 slot 空 ⇒ 写门 fail-closed)。 */
|
|
@@ -121,8 +119,19 @@ export declare const DEPLOYMENT_SHAPE_PREDICATES: Readonly<{
|
|
|
121
119
|
* 读者:boot `remote_exec_enabled.suspendable`。
|
|
122
120
|
*/
|
|
123
121
|
suspendableHands: DeploymentShapePredicate<"lane">;
|
|
124
|
-
/**
|
|
125
|
-
|
|
122
|
+
/**
|
|
123
|
+
* 即时回退的工作区是否活过一次执行 —— run 外回退口(`POST /v1/sessions/:id/rewind-files`)写下的文件要落在一棵下一次执行就从它开始的工作区里;
|
|
124
|
+
* 工作区随执行结束一起没了(或下一次执行从别处重建它)的部署上,引擎照样恢复、台账照样报「恢复了」,结果却到不了任何人手里(静默的写面 fail-open)。
|
|
125
|
+
* 按车道穷举(新车道 = 编译红;认不出的车道 ⇒ 不成立):
|
|
126
|
+
* · `host`:调用方声明的项目目录 ⇔ 车道能力 `callerCwd` 在这台部署上成立(单主;多租形上每个任务一只用完即删的目录)。单只会话还要本进程登记过它的 cwd、且那只目录实在 —— 那一半是口的 409,不是部署形;
|
|
127
|
+
* · `device` / `ssh` / `adb`:一台常驻的真机器,环境拆毁 = 断连,不删文件;
|
|
128
|
+
* · `local-docker`(拆毁 = `docker rm -f`)/ `e2b`(拆毁 = 杀 VM):每个任务一只新环境;
|
|
129
|
+
* · `k8s`:不开工作区持久化 ⇒ 一次性 pod;开了 ⇒ 下一次执行从快照店恢复工作区,而工作区填充链(恢复后的附件填充)与拆毁时的快照持久化都还没纳入回退用途
|
|
130
|
+
* (回退那一次取环境照样填充附件、存新快照,存失败也进不了回退的应答)⇒ 本版不成立,重开另票(用途感知的填充 + 持久化结果进回退应答);
|
|
131
|
+
* · `none`:没有执行环境(能力事实先判无手车道,这里照样表态)。
|
|
132
|
+
* 读者:能力事实 `sessionRewindFiles`(能力位与该口的 501 同读这一行)。
|
|
133
|
+
*/
|
|
134
|
+
rewindableWorkspace: DeploymentShapePredicate<"lane" | "principal">;
|
|
126
135
|
}>;
|
|
127
136
|
export {};
|
|
128
137
|
//# sourceMappingURL=deployment-shape.d.ts.map
|
package/dist/deployment-shape.js
CHANGED
|
@@ -1,16 +1,15 @@
|
|
|
1
|
-
import { capabilitiesFor, executionLaneCaps, executionLaneOf, handsOnWorkerFilePlane } from "./execution-lane-caps.js";
|
|
1
|
+
import { capabilitiesFor, executionLaneCaps, executionLaneOf, handsOnWorkerFilePlane, laneWiresExecutionEnv } from "./execution-lane-caps.js";
|
|
2
2
|
function readPrincipalAxis(deployment) {
|
|
3
3
|
return { declared: deployment.requirePrincipal === true };
|
|
4
4
|
}
|
|
5
5
|
function readLaneAxis(deployment) {
|
|
6
6
|
const declaration = deployment.remoteExec;
|
|
7
|
-
const lane = executionLaneOf(declaration
|
|
7
|
+
const lane = executionLaneOf(declaration.provider);
|
|
8
8
|
return {
|
|
9
9
|
lane,
|
|
10
10
|
caps: lane === undefined ? undefined : executionLaneCaps(lane),
|
|
11
11
|
block: capabilitiesFor(deployment),
|
|
12
|
-
k8sRuntimeClass: lane === "k8s" ? declaration
|
|
13
|
-
singleMachineDefault: lane === "host" && declaration?.singleMachineDefault === true,
|
|
12
|
+
k8sRuntimeClass: lane === "k8s" ? declaration.runtimeClass : undefined,
|
|
14
13
|
};
|
|
15
14
|
}
|
|
16
15
|
function readAxis(axis, deployment) {
|
|
@@ -52,7 +51,7 @@ export const DEPLOYMENT_SHAPE_PREDICATES = Object.freeze({
|
|
|
52
51
|
callerCwd: createPredicate(["lane", "principal"], "车道 × 租户 / 设备归属:调用方送来的 cwd(与 settings.env)被尊重 —— host 车道且单主,或 device 车道。", ({ lane, principal }) => lane.caps !== undefined && capabilityHolds(lane.caps.callerCwd, principal)),
|
|
53
52
|
callerOwnsWorkerDisk: createPredicate(["lane", "principal"], "车道 × 租户:手就在本 worker 的盘上且部署只有一个主人 —— 这块盘上的路径就是调用方自己的。", ({ lane, principal }) => lane.lane !== undefined && handsOnWorkerFilePlane(lane.lane) && !principal.declared),
|
|
54
53
|
toolsOnThisHost: createPredicate(["lane"], "车道:工具跑的那台机器就是本进程这台(手挂上了且文件平面在本 worker 盘上;车道列 handsOnWorkerFilePlane)。", ({ lane }) => lane.lane !== undefined && handsOnWorkerFilePlane(lane.lane)),
|
|
55
|
-
|
|
54
|
+
noHandsSingleUser: createPredicate(["lane", "principal"], "车道 × 租户:无手车道(声明 none;车道列 laneWiresExecutionEnv 为假)且部署只有一个主人。", ({ lane, principal }) => lane.lane !== undefined && !laneWiresExecutionEnv(lane.lane) && !principal.declared),
|
|
56
55
|
taskHostPostureDeclarations: createPredicate(["lane", "principal"], "车道 × 租户 / 设备归属:任务层可以替部署声明宿主姿态 —— device 车道(发起者自己的设备),或单主部署。", ({ lane, principal }) => lane.lane === "device" || !principal.declared),
|
|
57
56
|
sandboxPathAdjudication: createPredicate(["lane"], "车道:写门的路径事实要经代理到执行环境里取(文件平面不在本 worker 盘上;认不出的车道也走代理)。", ({ lane }) => lane.block === undefined || !lane.block.hostLocalPaths),
|
|
58
57
|
sandboxSendUserFile: createPredicate(["lane", "principal"], "车道 × 租户:SendUserFile 的沙箱直传腿可以挂(沙箱盘 = 租户自己的任务工作区,或共享真机上的单主部署)。", ({ lane, principal }) => lane.caps !== undefined && capabilityHolds(lane.caps.sandboxSendUserFile, principal)),
|
|
@@ -67,6 +66,25 @@ export const DEPLOYMENT_SHAPE_PREDICATES = Object.freeze({
|
|
|
67
66
|
return runtimeClass.startsWith("kata") || VM_ISOLATION_RUNTIME_CLASSES.has(runtimeClass);
|
|
68
67
|
}),
|
|
69
68
|
suspendableHands: createPredicate(["lane"], "车道:执行环境可挂起(e2b;k8s 以配了 S3 工作区快照店为前提)。", ({ lane }) => lane.block?.suspendable === true),
|
|
70
|
-
|
|
69
|
+
rewindableWorkspace: createPredicate(["lane", "principal"], "车道 × 租户:即时回退的工作区活过一次执行 —— 单主 host、device、ssh、adb 成立;多租 host、local-docker、e2b 每个任务重建工作区;k8s 的工作区填充与快照持久化尚未纳入回退。", ({ lane, principal }) => {
|
|
70
|
+
switch (lane.lane) {
|
|
71
|
+
case "host":
|
|
72
|
+
return lane.caps !== undefined && capabilityHolds(lane.caps.callerCwd, principal);
|
|
73
|
+
case "device":
|
|
74
|
+
case "ssh":
|
|
75
|
+
case "adb":
|
|
76
|
+
return true;
|
|
77
|
+
case "k8s":
|
|
78
|
+
case "local-docker":
|
|
79
|
+
case "e2b":
|
|
80
|
+
case "none":
|
|
81
|
+
case undefined:
|
|
82
|
+
return false;
|
|
83
|
+
default: {
|
|
84
|
+
const unhandled = lane.lane;
|
|
85
|
+
throw new Error(`rewindableWorkspace: no ruling for lane ${String(unhandled)}`);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}),
|
|
71
89
|
});
|
|
72
90
|
//# sourceMappingURL=deployment-shape.js.map
|
package/dist/env-facts.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ImageCapabilities } from "./plugins/store-contracts.js";
|
|
2
|
-
import type {
|
|
2
|
+
import type { ExecutionLane } from "./execution-lane-caps.js";
|
|
3
3
|
export interface SandboxEnvFacts {
|
|
4
4
|
profile?: string;
|
|
5
5
|
capabilities?: string[];
|
|
@@ -54,7 +54,7 @@ export declare function buildEnvFacts(opts: {
|
|
|
54
54
|
* codex 复审 medium:k8s 必须按**有效快照能力**分叉,不能只看车道名——s3Snapshot 未配=park-only,
|
|
55
55
|
* resume 是全新 pod 且**工作区不恢复**,「文件已从快照恢复」那句会让模型信赖不存在的文件(比缺席
|
|
56
56
|
* 更糟的谎)。 */
|
|
57
|
-
export declare function resumeFactsForLane(provider:
|
|
57
|
+
export declare function resumeFactsForLane(provider: ExecutionLane, // 车道词 = settings-schema 词表正本(经本仓读口取型,不手抄;表加词 ⇒ 下方穷举 switch 编译红)
|
|
58
58
|
caps?: {
|
|
59
59
|
k8sSnapshot?: boolean;
|
|
60
60
|
}): SandboxEnvFacts["resumeFacts"] | undefined;
|
|
@@ -73,6 +73,8 @@ export declare function scratchpadSessionSegment(sessionId: string): string;
|
|
|
73
73
|
* intermediate artifacts survive across turns/resume legs). Exported as the single source both the envFacts
|
|
74
74
|
* composer (below) and the future createFsWriteGatePolicy `exemptDirs` wiring ([ref]①, 1.290) must use. */
|
|
75
75
|
export declare function scratchpadDirFor(localDataRoot: string, sessionId: string): string;
|
|
76
|
+
/** 所有会话段的父目录 `<localDataRoot>/scratchpad`(段路径、过期清扫与一次性迁移 M39 的名册同读这一只)。 */
|
|
77
|
+
export declare function scratchpadRootFor(localDataRoot: string): string;
|
|
76
78
|
/** Resolve + CREATE the session scratchpad dir (mkdir -p, idempotent). Returns the path, or undefined when
|
|
77
79
|
* creation fails (honest-facts posture: never advertise a directory that does not exist — same class as
|
|
78
80
|
* egress/pkgSource "don't declare what you don't know"). Lifecycle: the reaper primitives live below —
|
|
@@ -149,7 +151,7 @@ export declare function screenShellScratchpadDir(raw: unknown, opts: {
|
|
|
149
151
|
* 就是凭空多一条 400)。只判其一会留一条**跨请求**的洞:一条请求供一只合法壳 scratchpad 把判据引开、
|
|
150
152
|
* 同时把 cwd 指进自算那只,放行后 cwd 坐进会话表,下一条不带路径字段的请求回落自算形、死在引擎构造期,
|
|
151
153
|
* 而它根本没送过 cwd(codex r2 [medium] 实证);
|
|
152
|
-
* ·
|
|
154
|
+
* · **无手的 `none` 车道不在射程**:那条腿的门根是**进程自己的 cwd**,与请求字段无关 ——
|
|
153
155
|
* 对着一个请求字段拒一件不是它造成的事,是把诊断指向错的地方(如实登记,不假装覆盖)。
|
|
154
156
|
*/
|
|
155
157
|
export declare function scratchpadCoveringTaskRoot(args: {
|
|
@@ -183,7 +185,7 @@ export declare function sweepStaleScratchpads(localDataRoot: string, opts: {
|
|
|
183
185
|
}): Promise<number>;
|
|
184
186
|
/** Map the exec-lane posture to the egress fact (the model must know when downloads can't work). */
|
|
185
187
|
export declare function egressForRemoteExec(remoteExec: {
|
|
186
|
-
provider
|
|
188
|
+
provider: string;
|
|
187
189
|
allowInternetAccess?: boolean;
|
|
188
|
-
}
|
|
190
|
+
}): "none" | "full" | undefined;
|
|
189
191
|
//# sourceMappingURL=env-facts.d.ts.map
|
package/dist/env-facts.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { isAbsolute, join, resolve, sep } from "node:path";
|
|
2
2
|
import { mkdir, readdir, rm, stat } from "node:fs/promises";
|
|
3
|
+
import { ensureDir } from "@sema-agent/core";
|
|
3
4
|
import { createHash } from "node:crypto";
|
|
4
5
|
import { isAbsoluteHostPath } from "@sema-agent/settings-schema";
|
|
5
6
|
import { dirCoversPath, normalizeAbsolutePathLexically } from "./task-cwd.js";
|
|
@@ -41,7 +42,7 @@ export function resumeFactsForLane(provider, caps) {
|
|
|
41
42
|
case "device":
|
|
42
43
|
return { scratch: "preserved" };
|
|
43
44
|
case "host":
|
|
44
|
-
case
|
|
45
|
+
case "none":
|
|
45
46
|
return { scratch: "preserved" };
|
|
46
47
|
case "local-docker":
|
|
47
48
|
return undefined;
|
|
@@ -57,7 +58,10 @@ export function scratchpadSessionSegment(sessionId) {
|
|
|
57
58
|
return `${cleaned.length > 0 ? cleaned : "_"}-${digest}`;
|
|
58
59
|
}
|
|
59
60
|
export function scratchpadDirFor(localDataRoot, sessionId) {
|
|
60
|
-
return join(localDataRoot,
|
|
61
|
+
return join(scratchpadRootFor(localDataRoot), scratchpadSessionSegment(sessionId));
|
|
62
|
+
}
|
|
63
|
+
export function scratchpadRootFor(localDataRoot) {
|
|
64
|
+
return join(localDataRoot, "scratchpad");
|
|
61
65
|
}
|
|
62
66
|
export async function ensureScratchpadDir(localDataRoot, sessionId, warn) {
|
|
63
67
|
const dir = scratchpadDirFor(localDataRoot, sessionId);
|
|
@@ -71,7 +75,7 @@ export async function ensureScratchpadDir(localDataRoot, sessionId, warn) {
|
|
|
71
75
|
return undefined;
|
|
72
76
|
}
|
|
73
77
|
try {
|
|
74
|
-
|
|
78
|
+
ensureDir(dir);
|
|
75
79
|
return dir;
|
|
76
80
|
}
|
|
77
81
|
catch {
|
|
@@ -147,7 +151,7 @@ export async function purgeScratchpadDir(localDataRoot, sessionId) {
|
|
|
147
151
|
}
|
|
148
152
|
}
|
|
149
153
|
export async function sweepStaleScratchpads(localDataRoot, opts) {
|
|
150
|
-
const root =
|
|
154
|
+
const root = scratchpadRootFor(localDataRoot);
|
|
151
155
|
let names;
|
|
152
156
|
try {
|
|
153
157
|
names = await readdir(root);
|
|
@@ -175,9 +179,9 @@ export async function sweepStaleScratchpads(localDataRoot, opts) {
|
|
|
175
179
|
return removed;
|
|
176
180
|
}
|
|
177
181
|
export function egressForRemoteExec(remoteExec) {
|
|
178
|
-
if (remoteExec
|
|
182
|
+
if (remoteExec.provider === "e2b")
|
|
179
183
|
return remoteExec.allowInternetAccess === false ? "none" : "full";
|
|
180
|
-
if (remoteExec
|
|
184
|
+
if (remoteExec.provider === "k8s")
|
|
181
185
|
return "full";
|
|
182
186
|
return undefined;
|
|
183
187
|
}
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type ExecutionLane, type LaneHomeDeployment } from "./execution-lane-caps.js";
|
|
2
2
|
/** 选中车道转进沙箱的 env 那一座(`ServiceConfig.remoteExec` 的判别联合每一臂结构上都满足:e2b / k8s 的 `sandboxEnv`、local-docker 的 `env`,别的臂两键都没有)。 */
|
|
3
3
|
export interface SandboxEnvSeat {
|
|
4
|
-
readonly remoteExec
|
|
5
|
-
readonly provider:
|
|
4
|
+
readonly remoteExec: {
|
|
5
|
+
readonly provider: ExecutionLane;
|
|
6
6
|
readonly sandboxEnv?: Readonly<Record<string, string>> | undefined;
|
|
7
7
|
readonly env?: Readonly<Record<string, string>> | undefined;
|
|
8
|
-
}
|
|
8
|
+
};
|
|
9
9
|
}
|
|
10
10
|
/** 求配置根要读的部署事实(`ServiceConfig` 结构上满足;存体预判的问点传活配置整份)。 */
|
|
11
11
|
export interface ExecutionConfigRootDeployment extends LaneHomeDeployment, SandboxEnvSeat {
|
|
12
12
|
readonly agentConfigDir?: string;
|
|
13
|
-
readonly remoteExec
|
|
13
|
+
readonly remoteExec: SandboxEnvSeat["remoteExec"];
|
|
14
14
|
}
|
|
15
15
|
/**
|
|
16
16
|
* 被选中的沙箱车道上运维点名转进沙箱的 env(e2b / k8s 的 `sandboxEnv`、local-docker 的 `env` —— 名单型旋钮经 `allowlistedEnv` 取的原值);
|