pi-better-server 0.4.0 → 0.6.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/package.json +8 -1
- package/scripts/copy-pi-test-providers.mjs +10 -0
- package/scripts/event-publication/README.md +26 -0
- package/scripts/event-publication/commit.mjs +21 -0
- package/scripts/event-publication/measure.mjs +87 -0
- package/scripts/event-publication/writer.mjs +6 -0
- package/scripts/measure-full-runtime/frontend.ts +24 -0
- package/scripts/measure-full-runtime/hosted-extension.ts +28 -0
- package/scripts/measure-full-runtime/probe.mjs +29 -0
- package/scripts/measure-full-runtime/recovery-trace-loader.mjs +51 -0
- package/scripts/measure-full-runtime/recovery-trace.mjs +16 -0
- package/scripts/measure-full-runtime.mjs +146 -0
- package/scripts/measure-shared-reads/probe.mjs +26 -2
- package/scripts/measure-shared-reads.mjs +44 -9
- package/scripts/private-runtime/package-lock.json +66 -4
- package/scripts/private-runtime/package.json +10 -2
- package/scripts/source-provenance.mjs +31 -0
- package/scripts/test-on-pi.sh +3 -9
- package/src/handshake.ts +1 -1
- package/src/hosted-session.ts +32 -4
- package/src/maintenance.ts +35 -7
- package/src/registry.ts +28 -4
- package/src/runtime/attempt-invalidation.ts +54 -0
- package/src/runtime/background-history.ts +151 -45
- package/src/runtime/background-policy.ts +27 -0
- package/src/runtime/background-tools.ts +389 -0
- package/src/runtime/background.ts +410 -48
- package/src/runtime/cancellation.ts +28 -7
- package/src/runtime/catalog-sources.ts +199 -0
- package/src/runtime/catalog.ts +53 -21
- package/src/runtime/client.ts +22 -2
- package/src/runtime/domain/assignment-inbox.mjs +119 -0
- package/src/runtime/domain/assignment-observation.d.mts +1 -1
- package/src/runtime/domain/assignment-observation.mjs +71 -33
- package/src/runtime/domain/background/process-identity.mjs +20 -2
- package/src/runtime/domain/background/process.mjs +3 -3
- package/src/runtime/domain/background/registry.mjs +89 -4
- package/src/runtime/domain/background/types.mjs +1 -0
- package/src/runtime/domain/background-service/adapter-contract.domain.mjs +83 -0
- package/src/runtime/domain/background-service/adapter-contract.ts +70 -0
- package/src/runtime/domain/background-service/batch.domain.mjs +91 -0
- package/src/runtime/domain/background-service/batch.ts +111 -0
- package/src/runtime/domain/background-service/conditions.domain.mjs +94 -0
- package/src/runtime/domain/background-service/conditions.ts +99 -0
- package/src/runtime/domain/background-service/delivery-observer.domain.mjs +37 -0
- package/src/runtime/domain/background-service/delivery-observer.ts +42 -0
- package/src/runtime/domain/background-service/failures.domain.mjs +209 -0
- package/src/runtime/domain/background-service/failures.ts +212 -0
- package/src/runtime/domain/background-service/goal-provider.domain.mjs +193 -0
- package/src/runtime/domain/background-service/goal-provider.ts +209 -0
- package/src/runtime/domain/background-service/index.domain.mjs +54 -0
- package/src/runtime/domain/background-service/index.ts +55 -0
- package/src/runtime/domain/background-service/logs.domain.mjs +129 -0
- package/src/runtime/domain/background-service/logs.ts +134 -0
- package/src/runtime/domain/background-service/maintenance.domain.mjs +95 -0
- package/src/runtime/domain/background-service/maintenance.ts +98 -0
- package/src/runtime/domain/background-service/managed-authority.domain.mjs +32 -0
- package/src/runtime/domain/background-service/managed-authority.ts +30 -0
- package/src/runtime/domain/background-service/managed-client.domain.mjs +79 -0
- package/src/runtime/domain/background-service/managed-client.ts +73 -0
- package/src/runtime/domain/background-service/managed-frontend.domain.mjs +225 -0
- package/src/runtime/domain/background-service/managed-frontend.ts +176 -0
- package/src/runtime/domain/background-service/navigator-provider.domain.mjs +492 -0
- package/src/runtime/domain/background-service/navigator-provider.ts +485 -0
- package/src/runtime/domain/background-service/observed-wait-client.domain.mjs +6 -0
- package/src/runtime/domain/background-service/observed-wait-client.ts +10 -0
- package/src/runtime/domain/background-service/observed-waits.domain.mjs +4080 -0
- package/src/runtime/domain/background-service/observed-waits.ts +4513 -0
- package/src/runtime/domain/background-service/output.domain.mjs +867 -0
- package/src/runtime/domain/background-service/output.ts +952 -0
- package/src/runtime/domain/background-service/process-identity.domain.mjs +129 -0
- package/src/runtime/domain/background-service/process-identity.ts +134 -0
- package/src/runtime/domain/background-service/process.domain.mjs +512 -0
- package/src/runtime/domain/background-service/process.ts +532 -0
- package/src/runtime/domain/background-service/prompt.domain.mjs +58 -0
- package/src/runtime/domain/background-service/prompt.ts +72 -0
- package/src/runtime/domain/background-service/registry.domain.mjs +460 -0
- package/src/runtime/domain/background-service/registry.ts +450 -0
- package/src/runtime/domain/background-service/remote-task-preset.domain.mjs +67 -0
- package/src/runtime/domain/background-service/remote-task-preset.ts +127 -0
- package/src/runtime/domain/background-service/runtime.domain.mjs +1511 -0
- package/src/runtime/domain/background-service/runtime.ts +1636 -0
- package/src/runtime/domain/background-service/sandbox.domain.mjs +735 -0
- package/src/runtime/domain/background-service/sandbox.ts +913 -0
- package/src/runtime/domain/background-service/shared-callback-batcher.domain.mjs +777 -0
- package/src/runtime/domain/background-service/shared-callback-batcher.ts +956 -0
- package/src/runtime/domain/background-service/shared-execution-policy.domain.mjs +50 -0
- package/src/runtime/domain/background-service/shared-execution-policy.ts +61 -0
- package/src/runtime/domain/background-service/shared-failure-observations.domain.mjs +1078 -0
- package/src/runtime/domain/background-service/shared-failure-observations.ts +1166 -0
- package/src/runtime/domain/background-service/shared-harness-settings.domain.mjs +126 -0
- package/src/runtime/domain/background-service/shared-harness-settings.ts +116 -0
- package/src/runtime/domain/background-service/shared-log-utils.domain.mjs +1223 -0
- package/src/runtime/domain/background-service/shared-log-utils.ts +1492 -0
- package/src/runtime/domain/background-service/shared-navigator-panels.domain.mjs +289 -0
- package/src/runtime/domain/background-service/shared-navigator-panels.ts +272 -0
- package/src/runtime/domain/background-service/shared-navigator.domain.mjs +1930 -0
- package/src/runtime/domain/background-service/shared-navigator.ts +1962 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/assignment-inbox.mjs +144 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/assignment-observation.mjs +189 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/index.domain.mjs +51 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/index.ts +122 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/assignment-changes.domain.mjs +75 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/assignment-changes.ts +73 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/assignment-outcomes.domain.mjs +163 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/assignment-outcomes.ts +174 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/background-parent-callbacks.domain.mjs +66 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/background-parent-callbacks.ts +68 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/background-requests.domain.mjs +87 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/background-requests.ts +90 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/discovery.domain.mjs +97 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/discovery.ts +139 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/errors.domain.mjs +12 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/errors.ts +79 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/operations.domain.mjs +342 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/operations.ts +513 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/outbox.domain.mjs +283 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/outbox.ts +458 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/recovery.domain.mjs +52 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/recovery.ts +55 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/result-supervision.domain.mjs +114 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/result-supervision.ts +140 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/rows.domain.mjs +280 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/rows.ts +442 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/schema.domain.mjs +420 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/schema.ts +441 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/sqlite.domain.mjs +194 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/sqlite.ts +239 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/store.domain.mjs +275 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/store.ts +585 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/subagent-launch.domain.mjs +120 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/subagent-launch.ts +142 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/task-cancellation.domain.mjs +188 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/task-cancellation.ts +224 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/types.domain.mjs +25 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/types.ts +707 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/upgrade.domain.mjs +22 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/upgrade.ts +22 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/validate.domain.mjs +234 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/validate.ts +241 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/waits.domain.mjs +851 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/waits.ts +1424 -0
- package/src/runtime/domain/background-service/shared-permission-blocker.domain.mjs +40 -0
- package/src/runtime/domain/background-service/shared-permission-blocker.ts +48 -0
- package/src/runtime/domain/background-service/shared-render-scheduler.domain.mjs +41 -0
- package/src/runtime/domain/background-service/shared-render-scheduler.ts +47 -0
- package/src/runtime/domain/background-service/shared-sandbox-core.domain.mjs +1531 -0
- package/src/runtime/domain/background-service/shared-sandbox-core.ts +1757 -0
- package/src/runtime/domain/background-service/shared-sandbox-diagnostics.domain.mjs +591 -0
- package/src/runtime/domain/background-service/shared-sandbox-diagnostics.ts +491 -0
- package/src/runtime/domain/background-service/shared-ssh-core/index.domain.mjs +698 -0
- package/src/runtime/domain/background-service/shared-ssh-core/index.ts +979 -0
- package/src/runtime/domain/background-service/shared-stall-detector.domain.mjs +37 -0
- package/src/runtime/domain/background-service/shared-stall-detector.ts +69 -0
- package/src/runtime/domain/background-service/shared-work-client.mjs +303 -0
- package/src/runtime/domain/background-service/stall-attention.domain.mjs +29 -0
- package/src/runtime/domain/background-service/stall-attention.ts +31 -0
- package/src/runtime/domain/background-service/stall.domain.mjs +57 -0
- package/src/runtime/domain/background-service/stall.ts +57 -0
- package/src/runtime/domain/background-service/supervisor/README.md +111 -0
- package/src/runtime/domain/background-service/supervisor/emit-runner.mjs +90 -0
- package/src/runtime/domain/background-service/supervisor/generated/conditions.mjs +96 -0
- package/src/runtime/domain/background-service/supervisor/generated/identity.mjs +95 -0
- package/src/runtime/domain/background-service/supervisor/generated/process-identity.mjs +131 -0
- package/src/runtime/domain/background-service/supervisor/generated/process.mjs +514 -0
- package/src/runtime/domain/background-service/supervisor/generated/runner.mjs +872 -0
- package/src/runtime/domain/background-service/supervisor/generated/store.mjs +609 -0
- package/src/runtime/domain/background-service/supervisor/generated/types.mjs +50 -0
- package/src/runtime/domain/background-service/supervisor/identity.domain.mjs +93 -0
- package/src/runtime/domain/background-service/supervisor/identity.ts +99 -0
- package/src/runtime/domain/background-service/supervisor/index.domain.mjs +22 -0
- package/src/runtime/domain/background-service/supervisor/index.ts +37 -0
- package/src/runtime/domain/background-service/supervisor/invocation.domain.mjs +30 -0
- package/src/runtime/domain/background-service/supervisor/invocation.ts +44 -0
- package/src/runtime/domain/background-service/supervisor/runner.domain.mjs +870 -0
- package/src/runtime/domain/background-service/supervisor/runner.ts +982 -0
- package/src/runtime/domain/background-service/supervisor/store.domain.mjs +605 -0
- package/src/runtime/domain/background-service/supervisor/store.ts +651 -0
- package/src/runtime/domain/background-service/supervisor/supervisor.domain.mjs +721 -0
- package/src/runtime/domain/background-service/supervisor/supervisor.ts +804 -0
- package/src/runtime/domain/background-service/supervisor/types.domain.mjs +48 -0
- package/src/runtime/domain/background-service/supervisor/types.ts +394 -0
- package/src/runtime/domain/background-service/task-diagnostics.domain.mjs +60 -0
- package/src/runtime/domain/background-service/task-diagnostics.ts +71 -0
- package/src/runtime/domain/background-service/tools.domain.mjs +1050 -0
- package/src/runtime/domain/background-service/tools.ts +1142 -0
- package/src/runtime/domain/background-service/types.domain.mjs +5 -0
- package/src/runtime/domain/background-service/types.ts +236 -0
- package/src/runtime/domain/background-service/work-observation.domain.mjs +176 -0
- package/src/runtime/domain/background-service/work-observation.ts +144 -0
- package/src/runtime/domain/catalog/catalog-store.d.mts +9 -1
- package/src/runtime/domain/catalog/catalog-store.mjs +20 -22
- package/src/runtime/domain/coordinator/src/assignment-changes.mjs +75 -0
- package/src/runtime/domain/coordinator/src/assignment-outcomes.mjs +2 -0
- package/src/runtime/domain/coordinator/src/background-parent-callbacks.mjs +65 -0
- package/src/runtime/domain/coordinator/src/background-requests.mjs +86 -0
- package/src/runtime/domain/coordinator/src/discovery.mjs +4 -2
- package/src/runtime/domain/coordinator/src/operations.mjs +44 -4
- package/src/runtime/domain/coordinator/src/result-supervision.mjs +12 -0
- package/src/runtime/domain/coordinator/src/rows.mjs +2 -0
- package/src/runtime/domain/coordinator/src/schema.mjs +73 -21
- package/src/runtime/domain/coordinator/src/store.mjs +32 -3
- package/src/runtime/domain/coordinator/src/subagent-launch.mjs +119 -0
- package/src/runtime/domain/coordinator/src/types.mjs +1 -1
- package/src/runtime/domain/coordinator/src/upgrade.mjs +22 -0
- package/src/runtime/domain/health-observation.d.mts +3 -1
- package/src/runtime/domain/health-observation.mjs +189 -190
- package/src/runtime/domain/log-cursor.d.mts +2 -0
- package/src/runtime/domain/log-cursor.mjs +85 -16
- package/src/runtime/domain/parse.d.mts +4 -1
- package/src/runtime/domain/parse.mjs +50 -5
- package/src/runtime/domain/sandbox-policy/README.md +633 -0
- package/src/runtime/domain/sandbox-policy/background-admission.domain.mjs +83 -0
- package/src/runtime/domain/sandbox-policy/background-admission.ts +75 -0
- package/src/runtime/domain/sandbox-policy/commands.domain.mjs +245 -0
- package/src/runtime/domain/sandbox-policy/commands.ts +336 -0
- package/src/runtime/domain/sandbox-policy/deny-rules.domain.mjs +440 -0
- package/src/runtime/domain/sandbox-policy/deny-rules.ts +620 -0
- package/src/runtime/domain/sandbox-policy/diagnostics-command.domain.mjs +30 -0
- package/src/runtime/domain/sandbox-policy/diagnostics-command.ts +27 -0
- package/src/runtime/domain/sandbox-policy/events.domain.mjs +49 -0
- package/src/runtime/domain/sandbox-policy/events.ts +85 -0
- package/src/runtime/domain/sandbox-policy/files.domain.mjs +153 -0
- package/src/runtime/domain/sandbox-policy/files.ts +224 -0
- package/src/runtime/domain/sandbox-policy/index.domain.mjs +289 -0
- package/src/runtime/domain/sandbox-policy/index.ts +386 -0
- package/src/runtime/domain/sandbox-policy/package.json +66 -0
- package/src/runtime/domain/sandbox-policy/permission-settings.domain.mjs +36 -0
- package/src/runtime/domain/sandbox-policy/permission-settings.ts +46 -0
- package/src/runtime/domain/sandbox-policy/permissions-page.domain.mjs +309 -0
- package/src/runtime/domain/sandbox-policy/permissions-page.ts +295 -0
- package/src/runtime/domain/sandbox-policy/permissions.domain.mjs +98 -0
- package/src/runtime/domain/sandbox-policy/permissions.ts +125 -0
- package/src/runtime/domain/sandbox-policy/policy.domain.mjs +80 -0
- package/src/runtime/domain/sandbox-policy/policy.ts +102 -0
- package/src/runtime/domain/sandbox-policy/preferences.domain.mjs +55 -0
- package/src/runtime/domain/sandbox-policy/preferences.ts +82 -0
- package/src/runtime/domain/sandbox-policy/rules-page.domain.mjs +138 -0
- package/src/runtime/domain/sandbox-policy/rules-page.ts +176 -0
- package/src/runtime/domain/sandbox-policy/session-permissions.domain.mjs +22 -0
- package/src/runtime/domain/sandbox-policy/session-permissions.ts +24 -0
- package/src/runtime/domain/sandbox-policy/shared-harness-settings.domain.mjs +126 -0
- package/src/runtime/domain/sandbox-policy/shared-harness-settings.ts +116 -0
- package/src/runtime/domain/sandbox-policy/shared-permission-blocker.domain.mjs +40 -0
- package/src/runtime/domain/sandbox-policy/shared-permission-blocker.ts +48 -0
- package/src/runtime/domain/sandbox-policy/shared-sandbox-core.domain.mjs +1531 -0
- package/src/runtime/domain/sandbox-policy/shared-sandbox-core.ts +1757 -0
- package/src/runtime/domain/sandbox-policy/shared-sandbox-diagnostics.domain.mjs +591 -0
- package/src/runtime/domain/sandbox-policy/shared-sandbox-diagnostics.ts +491 -0
- package/src/runtime/domain/sandbox-policy/shared-task-application.domain.mjs +185 -0
- package/src/runtime/domain/sandbox-policy/shared-task-application.ts +185 -0
- package/src/runtime/domain/sandbox-policy/shared-task-apply-patch.domain.mjs +416 -0
- package/src/runtime/domain/sandbox-policy/shared-task-apply-patch.ts +409 -0
- package/src/runtime/domain/sandbox-policy/shared-task-exec.domain.mjs +325 -0
- package/src/runtime/domain/sandbox-policy/shared-task-exec.ts +335 -0
- package/src/runtime/domain/sandbox-policy/shared-task-files.domain.mjs +346 -0
- package/src/runtime/domain/sandbox-policy/shared-task-files.ts +342 -0
- package/src/runtime/domain/sandbox-policy/shared-task-process-identity.domain.mjs +140 -0
- package/src/runtime/domain/sandbox-policy/shared-task-process-identity.ts +126 -0
- package/src/runtime/domain/sandbox-policy/shared-task-process-list.domain.mjs +220 -0
- package/src/runtime/domain/sandbox-policy/shared-task-process-list.ts +209 -0
- package/src/runtime/domain/sandbox-policy/shared-task-sandbox.domain.mjs +227 -0
- package/src/runtime/domain/sandbox-policy/shared-task-sandbox.ts +224 -0
- package/src/runtime/domain/sandbox-policy/shared-task-tools.domain.mjs +92 -0
- package/src/runtime/domain/sandbox-policy/shared-task-tools.ts +123 -0
- package/src/runtime/domain/sandbox-policy/shell.domain.mjs +93 -0
- package/src/runtime/domain/sandbox-policy/shell.ts +129 -0
- package/src/runtime/domain/sandbox-policy/state.domain.mjs +307 -0
- package/src/runtime/domain/sandbox-policy/state.ts +408 -0
- package/src/runtime/domain/sandbox-policy/status.domain.mjs +64 -0
- package/src/runtime/domain/sandbox-policy/status.ts +76 -0
- package/src/runtime/domain/sandbox-policy/subagent-admission.domain.mjs +69 -0
- package/src/runtime/domain/sandbox-policy/subagent-admission.ts +60 -0
- package/src/runtime/domain/subagents/CONTEXT.md +202 -0
- package/src/runtime/domain/subagents/PRODUCT.md +49 -0
- package/src/runtime/domain/subagents/README.md +201 -0
- package/src/runtime/domain/subagents/agent-catalog.mjs +64 -0
- package/src/runtime/domain/subagents/agent-commands.domain.mjs +822 -0
- package/src/runtime/domain/subagents/agent-commands.ts +905 -0
- package/src/runtime/domain/subagents/agent-inspection.domain.mjs +398 -0
- package/src/runtime/domain/subagents/agent-inspection.ts +574 -0
- package/src/runtime/domain/subagents/agent-operations.domain.mjs +40 -0
- package/src/runtime/domain/subagents/agent-operations.ts +61 -0
- package/src/runtime/domain/subagents/agent-session-settings.domain.mjs +112 -0
- package/src/runtime/domain/subagents/agent-session-settings.ts +118 -0
- package/src/runtime/domain/subagents/agents-catalog-tool.domain.mjs +84 -0
- package/src/runtime/domain/subagents/agents-catalog-tool.ts +118 -0
- package/src/runtime/domain/subagents/assignment-outcomes.domain.mjs +276 -0
- package/src/runtime/domain/subagents/assignment-outcomes.ts +212 -0
- package/src/runtime/domain/subagents/assignment-projection.mjs +261 -0
- package/src/runtime/domain/subagents/assignment-report.domain.mjs +174 -0
- package/src/runtime/domain/subagents/assignment-report.ts +156 -0
- package/src/runtime/domain/subagents/batch.mjs +275 -0
- package/src/runtime/domain/subagents/callback-fields.domain.mjs +72 -0
- package/src/runtime/domain/subagents/callback-fields.ts +95 -0
- package/src/runtime/domain/subagents/capacity.mjs +108 -0
- package/src/runtime/domain/subagents/catalog-editor.domain.mjs +98 -0
- package/src/runtime/domain/subagents/catalog-editor.ts +125 -0
- package/src/runtime/domain/subagents/catalog-host-admission.domain.mjs +104 -0
- package/src/runtime/domain/subagents/catalog-host-admission.ts +85 -0
- package/src/runtime/domain/subagents/catalog-identity.domain.mjs +222 -0
- package/src/runtime/domain/subagents/catalog-identity.ts +258 -0
- package/src/runtime/domain/subagents/catalog-overlay.domain.mjs +9 -0
- package/src/runtime/domain/subagents/catalog-overlay.ts +10 -0
- package/src/runtime/domain/subagents/catalog-preferences.domain.mjs +164 -0
- package/src/runtime/domain/subagents/catalog-preferences.ts +139 -0
- package/src/runtime/domain/subagents/catalog-resolver.domain.mjs +366 -0
- package/src/runtime/domain/subagents/catalog-resolver.ts +540 -0
- package/src/runtime/domain/subagents/catalog-runtime.domain.mjs +570 -0
- package/src/runtime/domain/subagents/catalog-runtime.ts +680 -0
- package/src/runtime/domain/subagents/catalog-schema.domain.mjs +1331 -0
- package/src/runtime/domain/subagents/catalog-schema.ts +1563 -0
- package/src/runtime/domain/subagents/catalog-skill-edits.domain.mjs +95 -0
- package/src/runtime/domain/subagents/catalog-skill-edits.ts +116 -0
- package/src/runtime/domain/subagents/catalog-store.domain.mjs +808 -0
- package/src/runtime/domain/subagents/catalog-store.ts +1006 -0
- package/src/runtime/domain/subagents/catalog-ui.domain.mjs +651 -0
- package/src/runtime/domain/subagents/catalog-ui.ts +611 -0
- package/src/runtime/domain/subagents/child-apply-patch.domain.mjs +13 -0
- package/src/runtime/domain/subagents/child-apply-patch.ts +13 -0
- package/src/runtime/domain/subagents/child-codemode.domain.mjs +16 -0
- package/src/runtime/domain/subagents/child-codemode.ts +17 -0
- package/src/runtime/domain/subagents/child-dependencies.mjs +193 -0
- package/src/runtime/domain/subagents/child-incidents.domain.mjs +170 -0
- package/src/runtime/domain/subagents/child-incidents.ts +169 -0
- package/src/runtime/domain/subagents/child-operations.domain.mjs +986 -0
- package/src/runtime/domain/subagents/child-operations.ts +1191 -0
- package/src/runtime/domain/subagents/child-ownership.domain.mjs +205 -0
- package/src/runtime/domain/subagents/child-ownership.ts +160 -0
- package/src/runtime/domain/subagents/child-preflight.mjs +38 -0
- package/src/runtime/domain/subagents/child-process-list.domain.mjs +7 -0
- package/src/runtime/domain/subagents/child-process-list.ts +8 -0
- package/src/runtime/domain/subagents/child-runtime.mjs +67 -0
- package/src/runtime/domain/subagents/child-steer.domain.mjs +109 -0
- package/src/runtime/domain/subagents/child-steer.ts +102 -0
- package/src/runtime/domain/subagents/cleanup.domain.mjs +818 -0
- package/src/runtime/domain/subagents/cleanup.ts +1017 -0
- package/src/runtime/domain/subagents/codex-import.domain.mjs +575 -0
- package/src/runtime/domain/subagents/codex-import.ts +717 -0
- package/src/runtime/domain/subagents/completion.domain.mjs +6 -0
- package/src/runtime/domain/subagents/completion.mjs +152 -0
- package/src/runtime/domain/subagents/completion.ts +11 -0
- package/src/runtime/domain/subagents/config.domain.mjs +248 -0
- package/src/runtime/domain/subagents/config.json +15 -0
- package/src/runtime/domain/subagents/config.ts +328 -0
- package/src/runtime/domain/subagents/continuation-authority.domain.mjs +38 -0
- package/src/runtime/domain/subagents/continuation-authority.ts +31 -0
- package/src/runtime/domain/subagents/continuation-runtime.domain.mjs +89 -0
- package/src/runtime/domain/subagents/continuation-runtime.ts +88 -0
- package/src/runtime/domain/subagents/continuation.domain.mjs +942 -0
- package/src/runtime/domain/subagents/continuation.ts +1051 -0
- package/src/runtime/domain/subagents/delegation.domain.mjs +19 -0
- package/src/runtime/domain/subagents/delegation.ts +24 -0
- package/src/runtime/domain/subagents/effective-settings.domain.mjs +130 -0
- package/src/runtime/domain/subagents/effective-settings.ts +184 -0
- package/src/runtime/domain/subagents/extensions.domain.mjs +6 -0
- package/src/runtime/domain/subagents/extensions.mjs +164 -0
- package/src/runtime/domain/subagents/extensions.ts +19 -0
- package/src/runtime/domain/subagents/failures.domain.mjs +362 -0
- package/src/runtime/domain/subagents/failures.ts +319 -0
- package/src/runtime/domain/subagents/finalization.domain.mjs +168 -0
- package/src/runtime/domain/subagents/finalization.ts +218 -0
- package/src/runtime/domain/subagents/git-remotes.domain.mjs +351 -0
- package/src/runtime/domain/subagents/git-remotes.ts +413 -0
- package/src/runtime/domain/subagents/git-workspace.domain.mjs +337 -0
- package/src/runtime/domain/subagents/git-workspace.ts +430 -0
- package/src/runtime/domain/subagents/goal-provider.domain.mjs +125 -0
- package/src/runtime/domain/subagents/goal-provider.ts +132 -0
- package/src/runtime/domain/subagents/health-observation.domain.mjs +617 -0
- package/src/runtime/domain/subagents/health-observation.ts +818 -0
- package/src/runtime/domain/subagents/health-surface.mjs +284 -0
- package/src/runtime/domain/subagents/health.domain.mjs +261 -0
- package/src/runtime/domain/subagents/health.ts +343 -0
- package/src/runtime/domain/subagents/historical-attention.domain.mjs +37 -0
- package/src/runtime/domain/subagents/historical-attention.ts +35 -0
- package/src/runtime/domain/subagents/incident-model.domain.mjs +322 -0
- package/src/runtime/domain/subagents/incident-model.ts +358 -0
- package/src/runtime/domain/subagents/index.domain.mjs +4731 -0
- package/src/runtime/domain/subagents/index.ts +4781 -0
- package/src/runtime/domain/subagents/launch-abort.domain.mjs +13 -0
- package/src/runtime/domain/subagents/launch-abort.ts +21 -0
- package/src/runtime/domain/subagents/launch-context.domain.mjs +24 -0
- package/src/runtime/domain/subagents/launch-context.ts +23 -0
- package/src/runtime/domain/subagents/launch-digest.mjs +6 -0
- package/src/runtime/domain/subagents/lifecycle.domain.mjs +265 -0
- package/src/runtime/domain/subagents/lifecycle.ts +360 -0
- package/src/runtime/domain/subagents/list.domain.mjs +2 -0
- package/src/runtime/domain/subagents/list.mjs +152 -0
- package/src/runtime/domain/subagents/list.ts +19 -0
- package/src/runtime/domain/subagents/log-cursor.domain.mjs +217 -0
- package/src/runtime/domain/subagents/log-cursor.ts +268 -0
- package/src/runtime/domain/subagents/managed-background-capability.domain.mjs +10 -0
- package/src/runtime/domain/subagents/managed-background-capability.ts +9 -0
- package/src/runtime/domain/subagents/managed-failure-worker.mjs +36 -0
- package/src/runtime/domain/subagents/managed-launch-bootstrap.mjs +48 -0
- package/src/runtime/domain/subagents/managed-launch-client.domain.mjs +75 -0
- package/src/runtime/domain/subagents/managed-launch-client.ts +59 -0
- package/src/runtime/domain/subagents/managed-launch-host.domain.mjs +627 -0
- package/src/runtime/domain/subagents/managed-launch-host.ts +504 -0
- package/src/runtime/domain/subagents/managed-launch-journal.mjs +17 -0
- package/src/runtime/domain/subagents/managed-launch-ownership.domain.mjs +29 -0
- package/src/runtime/domain/subagents/managed-launch-ownership.ts +22 -0
- package/src/runtime/domain/subagents/managed-launch-port.domain.mjs +2 -0
- package/src/runtime/domain/subagents/managed-launch-port.ts +25 -0
- package/src/runtime/domain/subagents/managed-launch-recovery.domain.mjs +29 -0
- package/src/runtime/domain/subagents/managed-launch-recovery.ts +45 -0
- package/src/runtime/domain/subagents/managed-worker-bridge.domain.mjs +63 -0
- package/src/runtime/domain/subagents/managed-worker-bridge.ts +48 -0
- package/src/runtime/domain/subagents/managed-worker.mjs +13 -0
- package/src/runtime/domain/subagents/model-resolution-core.domain.mjs +822 -0
- package/src/runtime/domain/subagents/model-resolution-core.ts +1074 -0
- package/src/runtime/domain/subagents/model-resolution.domain.mjs +22 -0
- package/src/runtime/domain/subagents/model-resolution.ts +32 -0
- package/src/runtime/domain/subagents/navigator.domain.mjs +6 -0
- package/src/runtime/domain/subagents/navigator.mjs +1233 -0
- package/src/runtime/domain/subagents/navigator.ts +39 -0
- package/src/runtime/domain/subagents/operation-bridge-types.domain.mjs +1012 -0
- package/src/runtime/domain/subagents/operation-bridge-types.ts +1156 -0
- package/src/runtime/domain/subagents/outage-observations.domain.mjs +84 -0
- package/src/runtime/domain/subagents/outage-observations.ts +73 -0
- package/src/runtime/domain/subagents/output-payload.domain.mjs +767 -0
- package/src/runtime/domain/subagents/output-payload.ts +987 -0
- package/src/runtime/domain/subagents/owned-exit.domain.mjs +12 -0
- package/src/runtime/domain/subagents/owned-exit.ts +12 -0
- package/src/runtime/domain/subagents/package.json +86 -0
- package/src/runtime/domain/subagents/park-checkpoint.domain.mjs +55 -0
- package/src/runtime/domain/subagents/park-checkpoint.ts +61 -0
- package/src/runtime/domain/subagents/parse.domain.mjs +1218 -0
- package/src/runtime/domain/subagents/parse.ts +1451 -0
- package/src/runtime/domain/subagents/permission-policy.domain.mjs +232 -0
- package/src/runtime/domain/subagents/permission-policy.ts +291 -0
- package/src/runtime/domain/subagents/process-identity.mjs +33 -0
- package/src/runtime/domain/subagents/registry.domain.mjs +1584 -0
- package/src/runtime/domain/subagents/registry.ts +1904 -0
- package/src/runtime/domain/subagents/role-assignment.domain.mjs +104 -0
- package/src/runtime/domain/subagents/role-assignment.ts +141 -0
- package/src/runtime/domain/subagents/roles/role.architect.md +13 -0
- package/src/runtime/domain/subagents/roles/role.developer.md +16 -0
- package/src/runtime/domain/subagents/roles/role.explorer.md +13 -0
- package/src/runtime/domain/subagents/roles/role.product-manager.md +13 -0
- package/src/runtime/domain/subagents/roles/role.researcher.md +13 -0
- package/src/runtime/domain/subagents/roles/role.reviewer.md +13 -0
- package/src/runtime/domain/subagents/roles/role.writer.md +12 -0
- package/src/runtime/domain/subagents/sandbox.domain.mjs +64 -0
- package/src/runtime/domain/subagents/sandbox.ts +92 -0
- package/src/runtime/domain/subagents/session-selection.domain.mjs +32 -0
- package/src/runtime/domain/subagents/session-selection.ts +35 -0
- package/src/runtime/domain/subagents/session-store.domain.mjs +489 -0
- package/src/runtime/domain/subagents/session-store.ts +468 -0
- package/src/runtime/domain/subagents/settings-page.domain.mjs +313 -0
- package/src/runtime/domain/subagents/settings-page.ts +363 -0
- package/src/runtime/domain/subagents/shared-callback-batcher.domain.mjs +777 -0
- package/src/runtime/domain/subagents/shared-callback-batcher.ts +956 -0
- package/src/runtime/domain/subagents/shared-catalog.domain.mjs +70 -0
- package/src/runtime/domain/subagents/shared-catalog.ts +61 -0
- package/src/runtime/domain/subagents/shared-execution-policy.domain.mjs +50 -0
- package/src/runtime/domain/subagents/shared-execution-policy.ts +61 -0
- package/src/runtime/domain/subagents/shared-failure-observations.domain.mjs +1078 -0
- package/src/runtime/domain/subagents/shared-failure-observations.ts +1166 -0
- package/src/runtime/domain/subagents/shared-harness-settings.domain.mjs +126 -0
- package/src/runtime/domain/subagents/shared-harness-settings.ts +116 -0
- package/src/runtime/domain/subagents/shared-log-utils.domain.mjs +1223 -0
- package/src/runtime/domain/subagents/shared-log-utils.ts +1492 -0
- package/src/runtime/domain/subagents/shared-navigator-panels.domain.mjs +289 -0
- package/src/runtime/domain/subagents/shared-navigator-panels.ts +272 -0
- package/src/runtime/domain/subagents/shared-navigator.domain.mjs +1930 -0
- package/src/runtime/domain/subagents/shared-navigator.ts +1962 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/assignment-inbox.mjs +144 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/assignment-observation.mjs +189 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/index.domain.mjs +51 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/index.ts +122 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/assignment-changes.domain.mjs +75 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/assignment-changes.ts +73 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/assignment-outcomes.domain.mjs +163 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/assignment-outcomes.ts +174 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/background-parent-callbacks.domain.mjs +66 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/background-parent-callbacks.ts +68 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/background-requests.domain.mjs +87 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/background-requests.ts +90 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/discovery.domain.mjs +97 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/discovery.ts +139 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/errors.domain.mjs +12 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/errors.ts +79 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/operations.domain.mjs +342 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/operations.ts +513 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/outbox.domain.mjs +283 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/outbox.ts +458 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/recovery.domain.mjs +52 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/recovery.ts +55 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/result-supervision.domain.mjs +114 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/result-supervision.ts +140 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/rows.domain.mjs +280 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/rows.ts +442 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/schema.domain.mjs +420 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/schema.ts +441 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/sqlite.domain.mjs +194 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/sqlite.ts +239 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/store.domain.mjs +275 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/store.ts +585 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/subagent-launch.domain.mjs +120 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/subagent-launch.ts +142 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/task-cancellation.domain.mjs +188 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/task-cancellation.ts +224 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/types.domain.mjs +25 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/types.ts +707 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/upgrade.domain.mjs +22 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/upgrade.ts +22 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/validate.domain.mjs +234 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/validate.ts +241 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/waits.domain.mjs +851 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/waits.ts +1424 -0
- package/src/runtime/domain/subagents/shared-permission-blocker.domain.mjs +40 -0
- package/src/runtime/domain/subagents/shared-permission-blocker.ts +48 -0
- package/src/runtime/domain/subagents/shared-render-scheduler.domain.mjs +41 -0
- package/src/runtime/domain/subagents/shared-render-scheduler.ts +47 -0
- package/src/runtime/domain/subagents/shared-sandbox-core.domain.mjs +1531 -0
- package/src/runtime/domain/subagents/shared-sandbox-core.ts +1757 -0
- package/src/runtime/domain/subagents/shared-sandbox-diagnostics.domain.mjs +591 -0
- package/src/runtime/domain/subagents/shared-sandbox-diagnostics.ts +491 -0
- package/src/runtime/domain/subagents/shared-stall-detector.domain.mjs +37 -0
- package/src/runtime/domain/subagents/shared-stall-detector.ts +69 -0
- package/src/runtime/domain/subagents/shared-task-application.domain.mjs +185 -0
- package/src/runtime/domain/subagents/shared-task-application.ts +185 -0
- package/src/runtime/domain/subagents/shared-task-apply-patch.domain.mjs +416 -0
- package/src/runtime/domain/subagents/shared-task-apply-patch.ts +409 -0
- package/src/runtime/domain/subagents/shared-task-exec.domain.mjs +325 -0
- package/src/runtime/domain/subagents/shared-task-exec.ts +335 -0
- package/src/runtime/domain/subagents/shared-task-files.domain.mjs +346 -0
- package/src/runtime/domain/subagents/shared-task-files.ts +342 -0
- package/src/runtime/domain/subagents/shared-task-process-identity.domain.mjs +140 -0
- package/src/runtime/domain/subagents/shared-task-process-identity.ts +126 -0
- package/src/runtime/domain/subagents/shared-task-process-list.domain.mjs +220 -0
- package/src/runtime/domain/subagents/shared-task-process-list.ts +209 -0
- package/src/runtime/domain/subagents/shared-task-sandbox.domain.mjs +227 -0
- package/src/runtime/domain/subagents/shared-task-sandbox.ts +224 -0
- package/src/runtime/domain/subagents/shared-task-tools.domain.mjs +92 -0
- package/src/runtime/domain/subagents/shared-task-tools.ts +123 -0
- package/src/runtime/domain/subagents/shared-work-client.mjs +303 -0
- package/src/runtime/domain/subagents/shared-worktree-context.domain.mjs +142 -0
- package/src/runtime/domain/subagents/shared-worktree-context.ts +158 -0
- package/src/runtime/domain/subagents/skill-picker.domain.mjs +316 -0
- package/src/runtime/domain/subagents/skill-picker.ts +353 -0
- package/src/runtime/domain/subagents/skills.domain.mjs +138 -0
- package/src/runtime/domain/subagents/skills.ts +183 -0
- package/src/runtime/domain/subagents/spawn.domain.mjs +72 -0
- package/src/runtime/domain/subagents/spawn.ts +80 -0
- package/src/runtime/domain/subagents/stop.domain.mjs +184 -0
- package/src/runtime/domain/subagents/stop.ts +217 -0
- package/src/runtime/domain/subagents/subagent-tools.domain.mjs +101 -0
- package/src/runtime/domain/subagents/subagent-tools.ts +137 -0
- package/src/runtime/domain/subagents/task-guard.domain.mjs +163 -0
- package/src/runtime/domain/subagents/task-guard.ts +144 -0
- package/src/runtime/domain/subagents/task-policy.domain.mjs +201 -0
- package/src/runtime/domain/subagents/task-policy.ts +236 -0
- package/src/runtime/domain/subagents/task-runtime.mjs +53 -0
- package/src/runtime/domain/subagents/task-tool-owner.domain.mjs +18 -0
- package/src/runtime/domain/subagents/task-tool-owner.ts +21 -0
- package/src/runtime/domain/subagents/thinking.domain.mjs +22 -0
- package/src/runtime/domain/subagents/thinking.ts +28 -0
- package/src/runtime/domain/subagents/tier-policy.domain.mjs +75 -0
- package/src/runtime/domain/subagents/tier-policy.ts +126 -0
- package/src/runtime/domain/subagents/timing-notifications.domain.mjs +51 -0
- package/src/runtime/domain/subagents/timing-notifications.ts +37 -0
- package/src/runtime/domain/subagents/timing.domain.mjs +487 -0
- package/src/runtime/domain/subagents/timing.ts +634 -0
- package/src/runtime/domain/subagents/tools.domain.mjs +558 -0
- package/src/runtime/domain/subagents/tools.ts +629 -0
- package/src/runtime/domain/subagents/widget.domain.mjs +6 -0
- package/src/runtime/domain/subagents/widget.mjs +246 -0
- package/src/runtime/domain/subagents/widget.ts +30 -0
- package/src/runtime/domain/subagents/work-observation.domain.mjs +316 -0
- package/src/runtime/domain/subagents/work-observation.ts +248 -0
- package/src/runtime/domain/subagents/worker-catalog.domain.mjs +120 -0
- package/src/runtime/domain/subagents/worker-catalog.ts +162 -0
- package/src/runtime/domain/subagents/worker-operations-host.domain.mjs +1009 -0
- package/src/runtime/domain/subagents/worker-operations-host.ts +1238 -0
- package/src/runtime/domain/subagents/worker-waits.domain.mjs +2336 -0
- package/src/runtime/domain/subagents/worker-waits.ts +2878 -0
- package/src/runtime/domain/subagents/workspace-scope.domain.mjs +52 -0
- package/src/runtime/domain/subagents/workspace-scope.ts +50 -0
- package/src/runtime/health-config.ts +27 -11
- package/src/runtime/log-checkpoints.ts +117 -0
- package/src/runtime/mutation-store.ts +5 -4
- package/src/runtime/queries.ts +27 -3
- package/src/runtime/query-executor.ts +178 -34
- package/src/runtime/query-worker.mjs +119 -22
- package/src/runtime/read-model.ts +939 -113
- package/src/runtime/read-watchdog-probe.ts +4 -0
- package/src/runtime/result-supervision.ts +188 -16
- package/src/runtime/source-watch.ts +175 -0
- package/src/runtime/subagent-launch.ts +73 -0
- package/src/runtime/work-budget.ts +130 -0
- package/src/runtime/work-client.d.mts +8 -0
- package/src/runtime/work-client.mjs +150 -7
- package/src/server.ts +185 -22
- package/src/session-activity.ts +26 -4
- package/src/version.ts +1 -1
|
@@ -0,0 +1,735 @@
|
|
|
1
|
+
// Generated fixed launch domain from packages/pi-better-background-tasks/src/sandbox.ts. Do not edit directly.
|
|
2
|
+
/**
|
|
3
|
+
* Background launch sandbox policy. New publishers provide a separate Background
|
|
4
|
+
* tasks profile; older publishers retain the historical Main-policy behavior.
|
|
5
|
+
* Every task keeps its policy snapshot for its whole lifetime.
|
|
6
|
+
*
|
|
7
|
+
* `pi-better-sandbox` owns the foreground policy and publishes an immutable
|
|
8
|
+
* snapshot of it on `pi.events`. This module is the consumer side of that wire
|
|
9
|
+
* contract: it mirrors the latest snapshot, and turns it into a confined
|
|
10
|
+
* command at the moment a local task launches.
|
|
11
|
+
*
|
|
12
|
+
* Two rules make the behaviour predictable:
|
|
13
|
+
*
|
|
14
|
+
* 1. **Snapshot at launch, never a live reference.** The wrapped executable and
|
|
15
|
+
* argv are resolved once, when the task starts, and are what the task keeps
|
|
16
|
+
* running. A later `/sandbox off` or deny-rule change therefore reaches only
|
|
17
|
+
* tasks launched after it.
|
|
18
|
+
* 2. **Opt-in, then fail closed.** `inactive` and explicitly `disabled` states
|
|
19
|
+
* launch unconfined. Once foreground policy says confinement applies, a
|
|
20
|
+
* missing or unusable backend blocks the launch and is never retried
|
|
21
|
+
* unconfined behind the operator's back.
|
|
22
|
+
*
|
|
23
|
+
* The contract is duplicated here rather than imported: `pi-better-sandbox` is
|
|
24
|
+
* an optional peer that this package must keep working without. Two channel
|
|
25
|
+
* names and a payload shape are the entire coupling, and both packages own
|
|
26
|
+
* tests that pin them.
|
|
27
|
+
*/
|
|
28
|
+
import { accessSync, constants, mkdirSync, realpathSync, statSync } from "node:fs";
|
|
29
|
+
import { homedir } from "node:os";
|
|
30
|
+
import { delimiter, dirname, isAbsolute, resolve } from "node:path";
|
|
31
|
+
import { commandExecution } from "./process.domain.mjs";
|
|
32
|
+
import { baseDir } from "./registry.domain.mjs";
|
|
33
|
+
import { canonicalizePath, compileWritePolicy, describeSandboxSupport, directApplicationTarget, maybeBuildSandboxCommand } from "./shared-sandbox-core.domain.mjs";
|
|
34
|
+
import { SandboxDiagnostics, diagnosticPackageVersion } from "./shared-sandbox-diagnostics.domain.mjs";
|
|
35
|
+
function backgroundDiagnostics(policy) {
|
|
36
|
+
try {
|
|
37
|
+
return new SandboxDiagnostics({ context: "background",
|
|
38
|
+
version: diagnosticPackageVersion(new URL("../package.json", import.meta.url)),
|
|
39
|
+
policy: () => policy,
|
|
40
|
+
backend: () => { const support = describeSandboxSupport(); return support.supported ? support.backend : undefined; },
|
|
41
|
+
onError: () => { console.error("Sandbox diagnostics collection gap; enforcement unchanged."); },
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
catch {
|
|
45
|
+
return undefined;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* What an operator can do about a missing backend here.
|
|
50
|
+
*
|
|
51
|
+
* A background task inherits the session's foreground policy, so its remedy is
|
|
52
|
+
* the session's: the slash command. `sandbox:false` is the subagent tool's
|
|
53
|
+
* opt-out and means nothing on this surface. The text is duplicated rather than
|
|
54
|
+
* imported for the same reason the rest of this contract is — `pi-better-sandbox`
|
|
55
|
+
* is an optional peer.
|
|
56
|
+
*/
|
|
57
|
+
export const FOREGROUND_SANDBOX_REMEDY = "Change the controlling Sandbox column in /sandbox, or work in a session that has a backend.";
|
|
58
|
+
/** Channel `pi-better-sandbox` publishes every effective-policy change on. */
|
|
59
|
+
export const FOREGROUND_SANDBOX_POLICY_CHANNEL = "pi-better-sandbox:policy";
|
|
60
|
+
/** Channel a consumer emits on to ask for the current policy. */
|
|
61
|
+
export const FOREGROUND_SANDBOX_POLICY_REQUEST_CHANNEL = "pi-better-sandbox:policy-request";
|
|
62
|
+
/** Largest single-command cap a timer can hold: 2_147_483 seconds is 2_147_483_000 ms. */
|
|
63
|
+
export const MAX_COMMAND_TIMEOUT_SECONDS = 2_147_483;
|
|
64
|
+
/** A positive finite number of seconds no larger than {@link MAX_COMMAND_TIMEOUT_SECONDS}. */
|
|
65
|
+
export function isCommandTimeoutSeconds(value) {
|
|
66
|
+
return typeof value === "number" && Number.isFinite(value) && value > 0 && value <= MAX_COMMAND_TIMEOUT_SECONDS;
|
|
67
|
+
}
|
|
68
|
+
/** Executables whose whole purpose is to interpret a shell command string. */
|
|
69
|
+
const SHELL_EXECUTABLES = Object.freeze([
|
|
70
|
+
"sh", "bash", "zsh", "dash", "ksh", "ksh93", "mksh", "pdksh", "ash", "csh", "tcsh", "fish",
|
|
71
|
+
"yash", "posh", "rbash", "busybox", "pwsh", "powershell", "cmd",
|
|
72
|
+
]);
|
|
73
|
+
const SHELL_NAMES = new Set(SHELL_EXECUTABLES);
|
|
74
|
+
function shellExecutableName(path) {
|
|
75
|
+
const normalized = String(path ?? "").replace(/\\/g, "/");
|
|
76
|
+
const name = normalized.slice(normalized.lastIndexOf("/") + 1).toLowerCase();
|
|
77
|
+
const stem = name.endsWith(".exe") ? name.slice(0, -4) : name;
|
|
78
|
+
return name.length > 0 && (SHELL_NAMES.has(name) || SHELL_NAMES.has(stem));
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Resolve an executable the way spawn will: a relative or bare name against the
|
|
82
|
+
* launch cwd, and a bare name through the launch's PATH. A relative PATH entry
|
|
83
|
+
* is itself resolved against the launch cwd, because the child changes directory
|
|
84
|
+
* before it searches PATH.
|
|
85
|
+
*
|
|
86
|
+
* The candidate must be a regular file this process may execute, so a
|
|
87
|
+
* non-executable shadow earlier on PATH does not stand in for the real target.
|
|
88
|
+
*/
|
|
89
|
+
function resolvedExecutablePath(executable, env, cwd) {
|
|
90
|
+
const value = String(executable ?? "");
|
|
91
|
+
if (value.includes("/") || (process.platform === "win32" && value.includes("\\"))) {
|
|
92
|
+
return resolve(cwd, value);
|
|
93
|
+
}
|
|
94
|
+
const path = env.PATH ?? env.Path;
|
|
95
|
+
if (!path)
|
|
96
|
+
return undefined;
|
|
97
|
+
for (const directory of path.split(delimiter)) {
|
|
98
|
+
const candidate = resolve(cwd, directory || ".", value);
|
|
99
|
+
try {
|
|
100
|
+
if (!statSync(candidate).isFile())
|
|
101
|
+
continue;
|
|
102
|
+
accessSync(candidate, constants.X_OK);
|
|
103
|
+
return candidate;
|
|
104
|
+
}
|
|
105
|
+
catch { /* A PATH entry may vanish, or not be executable. */ }
|
|
106
|
+
}
|
|
107
|
+
return undefined;
|
|
108
|
+
}
|
|
109
|
+
let shellIdentities;
|
|
110
|
+
/**
|
|
111
|
+
* Device/inode identities of the known shell binaries on this launch's PATH.
|
|
112
|
+
*
|
|
113
|
+
* A hardlink to a shell can carry any name, so a name check and a symlink's
|
|
114
|
+
* canonical target cannot see it. This mirrors the confined executor's identity
|
|
115
|
+
* check (`task-sandbox/exec.ts`), resolved against the launch cwd and PATH.
|
|
116
|
+
*/
|
|
117
|
+
function knownShellIdentities(env, cwd) {
|
|
118
|
+
const path = env.PATH ?? env.Path;
|
|
119
|
+
const cached = shellIdentities;
|
|
120
|
+
if (cached && cached.path === path && cached.cwd === cwd)
|
|
121
|
+
return cached.ids;
|
|
122
|
+
const ids = new Set();
|
|
123
|
+
for (const directory of (path ?? "").split(delimiter)) {
|
|
124
|
+
for (const name of SHELL_EXECUTABLES) {
|
|
125
|
+
try {
|
|
126
|
+
const info = statSync(resolve(cwd, directory || ".", name), { bigint: true });
|
|
127
|
+
if (info.isFile())
|
|
128
|
+
ids.add(`${info.dev}:${info.ino}`);
|
|
129
|
+
}
|
|
130
|
+
catch { /* Not present in this directory. */ }
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
shellIdentities = { path, cwd, ids };
|
|
134
|
+
return ids;
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* True when `argv[0]` names a shell interpreter directly.
|
|
138
|
+
*
|
|
139
|
+
* With Shell scripts Off, a `shell: false` argv is still a way to ask a shell to
|
|
140
|
+
* run a command (`["/bin/bash", "-c", ...]`). The requested name is checked
|
|
141
|
+
* first, then the executable spawn would resolve against `cwd` and the launch's
|
|
142
|
+
* PATH, then its canonical target, so a symlink or an alternate name pointing at
|
|
143
|
+
* a shell is still refused. A hardlink to a shell is refused by inode identity.
|
|
144
|
+
* Only a direct interpreter is refused: an application that happens to launch a
|
|
145
|
+
* shell itself is a different capability from asking Pi to interpret a command.
|
|
146
|
+
*/
|
|
147
|
+
export function isShellExecutable(executable, env = process.env, cwd = process.cwd()) {
|
|
148
|
+
if (shellExecutableName(executable))
|
|
149
|
+
return true;
|
|
150
|
+
const resolved = resolvedExecutablePath(String(executable ?? ""), env, cwd);
|
|
151
|
+
if (!resolved)
|
|
152
|
+
return false;
|
|
153
|
+
let canonical;
|
|
154
|
+
try {
|
|
155
|
+
canonical = realpathSync.native(resolved);
|
|
156
|
+
}
|
|
157
|
+
catch {
|
|
158
|
+
return false;
|
|
159
|
+
}
|
|
160
|
+
if (shellExecutableName(canonical))
|
|
161
|
+
return true;
|
|
162
|
+
try {
|
|
163
|
+
const info = statSync(canonical, { bigint: true });
|
|
164
|
+
if (knownShellIdentities(env, cwd).has(`${info.dev}:${info.ino}`))
|
|
165
|
+
return true;
|
|
166
|
+
}
|
|
167
|
+
catch { /* A missing file fails when the launch runs it. */ }
|
|
168
|
+
return false;
|
|
169
|
+
}
|
|
170
|
+
/** Thrown instead of launching a local task the foreground policy forbids. */
|
|
171
|
+
export class ForegroundSandboxBlockedError extends Error {
|
|
172
|
+
policy;
|
|
173
|
+
constructor(policy, detail) {
|
|
174
|
+
super(`${policy.policySource === "background" ? "Background tasks" : "Foreground"} sandbox is ${policy.state}; this local background task was blocked rather than launched unconfined. ${detail ?? policy.reason}`);
|
|
175
|
+
this.name = "ForegroundSandboxBlockedError";
|
|
176
|
+
this.policy = policy;
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
const UNCONFINED = { confined: false };
|
|
180
|
+
const launchPolicies = new WeakMap();
|
|
181
|
+
function capturePlan(plan, policy) {
|
|
182
|
+
const snapshot = { ...plan };
|
|
183
|
+
launchPolicies.set(snapshot, policy);
|
|
184
|
+
return snapshot;
|
|
185
|
+
}
|
|
186
|
+
const VALID_STATES = new Set(["inactive", "enabled", "disabled", "unavailable", "failed"]);
|
|
187
|
+
const mirrors = new WeakMap();
|
|
188
|
+
function eventBusOf(pi) {
|
|
189
|
+
const events = pi?.events;
|
|
190
|
+
if (!events || typeof events !== "object")
|
|
191
|
+
return undefined;
|
|
192
|
+
const candidate = events;
|
|
193
|
+
if (typeof candidate.on !== "function" || typeof candidate.emit !== "function")
|
|
194
|
+
return undefined;
|
|
195
|
+
return candidate;
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* Accept a published payload only when it carries a state this module
|
|
199
|
+
* understands, so an unrelated extension emitting on the channel cannot clear a
|
|
200
|
+
* real policy or invent one.
|
|
201
|
+
*/
|
|
202
|
+
function readPolicy(data, profile = "Main") {
|
|
203
|
+
if (!data || typeof data !== "object")
|
|
204
|
+
return undefined;
|
|
205
|
+
const value = data;
|
|
206
|
+
if (typeof value.state !== "string" || !VALID_STATES.has(value.state))
|
|
207
|
+
return undefined;
|
|
208
|
+
const writableRoot = typeof value.writableRoot === "string" ? value.writableRoot : undefined;
|
|
209
|
+
const denyWrite = Array.isArray(value.denyWrite)
|
|
210
|
+
? value.denyWrite.filter((entry) => typeof entry === "string")
|
|
211
|
+
: [];
|
|
212
|
+
const permissions = value.permissions === undefined ? undefined : readPermissions(value.permissions);
|
|
213
|
+
if (value.permissions !== undefined && !permissions) {
|
|
214
|
+
throw new Error(`Invalid ${profile} sandbox permission profile; update permissions in the sandbox UI.`);
|
|
215
|
+
}
|
|
216
|
+
return {
|
|
217
|
+
state: value.state,
|
|
218
|
+
writableRoot,
|
|
219
|
+
denyWrite: Object.freeze([...denyWrite]),
|
|
220
|
+
reason: typeof value.reason === "string" ? value.reason : "No reason was published.",
|
|
221
|
+
...(permissions ? { permissions } : {}),
|
|
222
|
+
};
|
|
223
|
+
}
|
|
224
|
+
function readPermissions(value) {
|
|
225
|
+
if (!value || typeof value !== "object")
|
|
226
|
+
return undefined;
|
|
227
|
+
const p = value;
|
|
228
|
+
const credential = (v) => v === "off" || v === "read" || v === "read-write";
|
|
229
|
+
const access = (v) => credential(v) || v === "write";
|
|
230
|
+
if (typeof p.enabled !== "boolean" || typeof p.commands !== "boolean" ||
|
|
231
|
+
typeof p.network !== "boolean" || !access(p.projectFiles) ||
|
|
232
|
+
!access(p.outsideProject) || !credential(p.storedCredentials) ||
|
|
233
|
+
(p.processAccess !== undefined && p.processAccess !== "off" && p.processAccess !== "read") ||
|
|
234
|
+
(p.shell !== undefined && typeof p.shell !== "boolean") ||
|
|
235
|
+
(p.commandTimeoutSeconds !== undefined && p.commandTimeoutSeconds !== null &&
|
|
236
|
+
!isCommandTimeoutSeconds(p.commandTimeoutSeconds)))
|
|
237
|
+
return undefined;
|
|
238
|
+
// Copy only what the publisher sent: absent optional settings keep their
|
|
239
|
+
// documented default meaning instead of being invented here.
|
|
240
|
+
return Object.freeze({
|
|
241
|
+
enabled: p.enabled, commands: p.commands, network: p.network,
|
|
242
|
+
projectFiles: p.projectFiles,
|
|
243
|
+
outsideProject: p.outsideProject,
|
|
244
|
+
storedCredentials: p.storedCredentials,
|
|
245
|
+
...(p.processAccess === undefined ? {} : { processAccess: p.processAccess }),
|
|
246
|
+
...(p.shell === undefined ? {} : { shell: p.shell }),
|
|
247
|
+
...(p.commandTimeoutSeconds === undefined ? {} : { commandTimeoutSeconds: p.commandTimeoutSeconds }),
|
|
248
|
+
});
|
|
249
|
+
}
|
|
250
|
+
/**
|
|
251
|
+
* Start mirroring foreground policy on this session's event bus.
|
|
252
|
+
*
|
|
253
|
+
* Idempotent, and safe in either extension load order. If `pi-better-sandbox`
|
|
254
|
+
* loaded first, its last publication is already gone (the bus has no replay), so
|
|
255
|
+
* we ask for a fresh one on the request channel. If it loads later, its own
|
|
256
|
+
* session-start publication reaches the subscription registered here.
|
|
257
|
+
*/
|
|
258
|
+
export function observeForegroundSandboxPolicy(pi) {
|
|
259
|
+
const events = eventBusOf(pi);
|
|
260
|
+
if (!events || mirrors.has(events))
|
|
261
|
+
return;
|
|
262
|
+
const mirror = { policy: undefined };
|
|
263
|
+
mirrors.set(events, mirror);
|
|
264
|
+
events.on(FOREGROUND_SANDBOX_POLICY_CHANNEL, (data) => {
|
|
265
|
+
try {
|
|
266
|
+
const published = data && typeof data === "object" ? data : undefined;
|
|
267
|
+
const hasBackground = published && Object.hasOwn(published, "background");
|
|
268
|
+
const main = readPolicy(data);
|
|
269
|
+
const policy = hasBackground ? readPolicy(published.background, "Background tasks") : main;
|
|
270
|
+
if (hasBackground && (!main || !policy))
|
|
271
|
+
throw new Error("Invalid Background tasks sandbox policy; update permissions in /sandbox.");
|
|
272
|
+
if (!policy || !main)
|
|
273
|
+
return;
|
|
274
|
+
const isOff = (scope) => scope.state === "disabled" || scope.state === "inactive";
|
|
275
|
+
const allowsRead = (scope) => scope.permissions !== undefined &&
|
|
276
|
+
(isOff(scope) || scope.permissions.processAccess === "read");
|
|
277
|
+
mirror.mainConfined = !isOff(main);
|
|
278
|
+
mirror.processAccess = allowsRead(main) && allowsRead(policy) ? "read" : "off";
|
|
279
|
+
Object.assign(policy, { policySource: hasBackground ? "background" : "main-legacy" });
|
|
280
|
+
mirror.policy = policy;
|
|
281
|
+
mirror.error = undefined;
|
|
282
|
+
}
|
|
283
|
+
catch (error) {
|
|
284
|
+
mirror.error = error;
|
|
285
|
+
mirror.processAccess = "off";
|
|
286
|
+
}
|
|
287
|
+
});
|
|
288
|
+
events.emit(FOREGROUND_SANDBOX_POLICY_REQUEST_CHANNEL, undefined);
|
|
289
|
+
}
|
|
290
|
+
/**
|
|
291
|
+
* The foreground policy as of right now, or `undefined` when no sandbox
|
|
292
|
+
* extension is publishing one.
|
|
293
|
+
*
|
|
294
|
+
* Asks for a re-publication first. Pi's event bus dispatches synchronously, so
|
|
295
|
+
* the answer to that request has already been mirrored by the time this
|
|
296
|
+
* returns; if a future bus were to defer, the last published snapshot is still
|
|
297
|
+
* returned rather than nothing.
|
|
298
|
+
*/
|
|
299
|
+
export function currentForegroundSandboxPolicy(pi) {
|
|
300
|
+
observeForegroundSandboxPolicy(pi);
|
|
301
|
+
const events = eventBusOf(pi);
|
|
302
|
+
if (!events)
|
|
303
|
+
return undefined;
|
|
304
|
+
events.emit(FOREGROUND_SANDBOX_POLICY_REQUEST_CHANNEL, undefined);
|
|
305
|
+
const mirror = mirrors.get(events);
|
|
306
|
+
if (mirror?.error)
|
|
307
|
+
throw mirror.error;
|
|
308
|
+
return mirror?.policy;
|
|
309
|
+
}
|
|
310
|
+
/** Current diagnostics permissions are independent of the task's launch snapshot. */
|
|
311
|
+
export function backgroundProcessDiagnosticsAccess(pi) {
|
|
312
|
+
try {
|
|
313
|
+
currentForegroundSandboxPolicy(pi);
|
|
314
|
+
}
|
|
315
|
+
catch {
|
|
316
|
+
return "off";
|
|
317
|
+
}
|
|
318
|
+
const events = eventBusOf(pi);
|
|
319
|
+
const mirror = events ? mirrors.get(events) : undefined;
|
|
320
|
+
const access = mirror?.processAccess ?? "unknown";
|
|
321
|
+
return access === "read" && mirror?.mainConfined ? "confined" : access;
|
|
322
|
+
}
|
|
323
|
+
export function sandboxProvenance(plan, remote = false) {
|
|
324
|
+
const policy = launchPolicies.get(plan);
|
|
325
|
+
const policySource = remote ? "remote" : policy?.policySource ?? (policy ? "main-legacy" : "no-publisher");
|
|
326
|
+
if (remote)
|
|
327
|
+
return { confinement: "unknown", policySource, policySummary: "Remote execution; local sandbox does not establish remote confinement.", changesAffectTask: false };
|
|
328
|
+
if (!plan.confined)
|
|
329
|
+
return { confinement: "unconfined", policySource,
|
|
330
|
+
policySummary: policy ? "Sandbox disabled at launch." : "No sandbox policy publisher at launch.", changesAffectTask: false };
|
|
331
|
+
const support = describeSandboxSupport();
|
|
332
|
+
const p = plan.permissions;
|
|
333
|
+
return { confinement: "confined", policySource, ...(support.supported ? { backend: support.backend } : {}),
|
|
334
|
+
policySummary: p ? `project=${p.projectFiles}; outside=${p.outsideProject}; credentials=${p.storedCredentials}; commands=${p.commands ? "on" : "off"}; network=${p.network ? "on" : "off"}`
|
|
335
|
+
: "Project write confinement with protected paths.", changesAffectTask: false };
|
|
336
|
+
}
|
|
337
|
+
/**
|
|
338
|
+
* Decide how a local launch must be confined, before the task has an id, a
|
|
339
|
+
* directory, or a log.
|
|
340
|
+
*
|
|
341
|
+
* Throws for every state that is neither confinable nor intentionally
|
|
342
|
+
* unconfined, which keeps a blocked launch from leaving task state behind.
|
|
343
|
+
*/
|
|
344
|
+
export function resolveForegroundSandboxPlan(pi, remote = false, operation, tool = "bg_task_spawn") {
|
|
345
|
+
const policy = currentForegroundSandboxPolicy(pi);
|
|
346
|
+
if (remote && !policy?.permissions)
|
|
347
|
+
return capturePlan(UNCONFINED, policy); // Preserve legacy SSH behavior.
|
|
348
|
+
try {
|
|
349
|
+
const plan = planFor(policy);
|
|
350
|
+
if (remote && plan.confined) {
|
|
351
|
+
throw new ForegroundSandboxBlockedError(policy, !plan.permissions?.network
|
|
352
|
+
? `${policy?.policySource === "background" ? "Background tasks" : "Main"} profile disables network. SSH launches are blocked.`
|
|
353
|
+
: `Structured SSH cannot apply local file and credential permissions yet. Use SSH through confined bash, or change ${policy?.policySource === "background" ? "Background tasks" : "Main"} permissions in /sandbox.`);
|
|
354
|
+
}
|
|
355
|
+
return capturePlan(plan, policy);
|
|
356
|
+
}
|
|
357
|
+
catch (error) {
|
|
358
|
+
if (error instanceof ForegroundSandboxBlockedError) {
|
|
359
|
+
const resource = policy?.permissions?.enabled && !policy.permissions.commands ? "command-execution"
|
|
360
|
+
: remote && policy?.permissions?.network === false ? "network-access" : "sandbox-backend";
|
|
361
|
+
backgroundDiagnostics(policy)?.observe({ tool, operation, resource, basis: "policy-refusal", outcome: "denied" });
|
|
362
|
+
}
|
|
363
|
+
throw error;
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
/** The plan for one already-read policy. Exposed for tests and reuse. */
|
|
367
|
+
export function planFor(policy) {
|
|
368
|
+
// No sandbox extension is publishing: this package is installed on its own and
|
|
369
|
+
// keeps its historical unsandboxed behaviour.
|
|
370
|
+
if (!policy)
|
|
371
|
+
return UNCONFINED;
|
|
372
|
+
if (policy.permissions?.enabled && !policy.permissions.commands) {
|
|
373
|
+
throw new ForegroundSandboxBlockedError(policy, `${policy.policySource === "background" ? "Background tasks" : "Main"} profile disables commands. Change permissions in /sandbox before launching background tasks.`);
|
|
374
|
+
}
|
|
375
|
+
if (policy.state === "inactive" || policy.state === "disabled")
|
|
376
|
+
return UNCONFINED;
|
|
377
|
+
if (policy.state !== "enabled" || !policy.writableRoot) {
|
|
378
|
+
throw new ForegroundSandboxBlockedError(policy);
|
|
379
|
+
}
|
|
380
|
+
const permissions = policy.permissions?.enabled ? {
|
|
381
|
+
projectFiles: policy.permissions.projectFiles,
|
|
382
|
+
outsideProject: policy.permissions.outsideProject,
|
|
383
|
+
storedCredentials: policy.permissions.storedCredentials,
|
|
384
|
+
commands: policy.permissions.commands,
|
|
385
|
+
network: policy.permissions.network,
|
|
386
|
+
...(policy.permissions.shell === undefined ? {} : { shell: policy.permissions.shell }),
|
|
387
|
+
...(policy.permissions.commandTimeoutSeconds === undefined ? {} : { commandTimeoutSeconds: policy.permissions.commandTimeoutSeconds }),
|
|
388
|
+
} : undefined;
|
|
389
|
+
return { confined: true, writableRoot: policy.writableRoot, denyWrite: policy.denyWrite,
|
|
390
|
+
...(permissions ? { permissions } : {}) };
|
|
391
|
+
}
|
|
392
|
+
/** Thrown when a parent-supplied worker policy is malformed; nothing was launched. */
|
|
393
|
+
export class InvalidWorkerSandboxPolicyError extends Error {
|
|
394
|
+
constructor(detail) {
|
|
395
|
+
super(`Invalid worker sandbox policy: ${detail}`);
|
|
396
|
+
this.name = "InvalidWorkerSandboxPolicyError";
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
const FILE_ACCESS_RANK = Object.freeze({ off: 0, read: 1, write: 2, "read-write": 3 });
|
|
400
|
+
const CREDENTIAL_ACCESS_RANK = Object.freeze({ off: 0, read: 1, "read-write": 2 });
|
|
401
|
+
/**
|
|
402
|
+
* Validate and normalize the parent-captured authority before anything else
|
|
403
|
+
* happens. Levels are checked as a whole profile so a typo cannot narrow itself
|
|
404
|
+
* silently, and a relative root or deny entry is refused rather than resolved
|
|
405
|
+
* against Pi's own cwd.
|
|
406
|
+
*/
|
|
407
|
+
function readWorkerAuthority(value) {
|
|
408
|
+
if (value === null || value === undefined)
|
|
409
|
+
return { confined: false };
|
|
410
|
+
if (typeof value !== "object" || Array.isArray(value)) {
|
|
411
|
+
throw new InvalidWorkerSandboxPolicyError("the parent-captured policy must be an object.");
|
|
412
|
+
}
|
|
413
|
+
const raw = value;
|
|
414
|
+
if (typeof raw.root !== "string" || raw.root.length === 0 || !isAbsolute(raw.root)) {
|
|
415
|
+
throw new InvalidWorkerSandboxPolicyError("root must be an absolute path.");
|
|
416
|
+
}
|
|
417
|
+
const root = canonicalizePath(raw.root);
|
|
418
|
+
if (root === dirname(root) || root === canonicalizePath(homedir())) {
|
|
419
|
+
throw new InvalidWorkerSandboxPolicyError("root must be a project directory, not the filesystem or home root.");
|
|
420
|
+
}
|
|
421
|
+
const denyWrite = raw.denyWrite;
|
|
422
|
+
if (denyWrite !== undefined && (!Array.isArray(denyWrite) ||
|
|
423
|
+
!denyWrite.every((entry) => typeof entry === "string" && isAbsolute(entry)))) {
|
|
424
|
+
throw new InvalidWorkerSandboxPolicyError("denyWrite must be a list of absolute paths.");
|
|
425
|
+
}
|
|
426
|
+
const deny = Object.freeze([...new Set(denyWrite ?? [])]);
|
|
427
|
+
if (raw.permissions === undefined) {
|
|
428
|
+
return { confined: true, root, denyWrite: deny };
|
|
429
|
+
}
|
|
430
|
+
const source = raw.permissions;
|
|
431
|
+
if (!source || typeof source !== "object" || Array.isArray(source)) {
|
|
432
|
+
throw new InvalidWorkerSandboxPolicyError("permissions must be an object.");
|
|
433
|
+
}
|
|
434
|
+
const p = source;
|
|
435
|
+
if (p.enabled !== undefined && typeof p.enabled !== "boolean") {
|
|
436
|
+
throw new InvalidWorkerSandboxPolicyError("permissions.enabled must be a boolean.");
|
|
437
|
+
}
|
|
438
|
+
// A PermissionProfile that is not enabled grants no task authority at all.
|
|
439
|
+
if (p.enabled === false)
|
|
440
|
+
return { confined: false };
|
|
441
|
+
if (typeof p.projectFiles !== "string" || !Object.hasOwn(FILE_ACCESS_RANK, p.projectFiles)) {
|
|
442
|
+
throw new InvalidWorkerSandboxPolicyError("permissions.projectFiles must be off, read, write or read-write.");
|
|
443
|
+
}
|
|
444
|
+
if (typeof p.outsideProject !== "string" || !Object.hasOwn(FILE_ACCESS_RANK, p.outsideProject)) {
|
|
445
|
+
throw new InvalidWorkerSandboxPolicyError("permissions.outsideProject must be off, read, write or read-write.");
|
|
446
|
+
}
|
|
447
|
+
if (typeof p.storedCredentials !== "string" || !Object.hasOwn(CREDENTIAL_ACCESS_RANK, p.storedCredentials)) {
|
|
448
|
+
throw new InvalidWorkerSandboxPolicyError("permissions.storedCredentials must be off, read or read-write.");
|
|
449
|
+
}
|
|
450
|
+
if (typeof p.commands !== "boolean") {
|
|
451
|
+
throw new InvalidWorkerSandboxPolicyError("permissions.commands must be a boolean.");
|
|
452
|
+
}
|
|
453
|
+
if (typeof p.network !== "boolean") {
|
|
454
|
+
throw new InvalidWorkerSandboxPolicyError("permissions.network must be a boolean.");
|
|
455
|
+
}
|
|
456
|
+
if (p.shell !== undefined && typeof p.shell !== "boolean") {
|
|
457
|
+
throw new InvalidWorkerSandboxPolicyError("permissions.shell must be a boolean.");
|
|
458
|
+
}
|
|
459
|
+
if (p.commandTimeoutSeconds !== undefined && p.commandTimeoutSeconds !== null && !isCommandTimeoutSeconds(p.commandTimeoutSeconds)) {
|
|
460
|
+
throw new InvalidWorkerSandboxPolicyError(`permissions.commandTimeoutSeconds must be null or a positive, finite number of seconds up to ${MAX_COMMAND_TIMEOUT_SECONDS}.`);
|
|
461
|
+
}
|
|
462
|
+
const permissions = {
|
|
463
|
+
projectFiles: p.projectFiles,
|
|
464
|
+
outsideProject: p.outsideProject,
|
|
465
|
+
storedCredentials: p.storedCredentials,
|
|
466
|
+
commands: p.commands,
|
|
467
|
+
network: p.network,
|
|
468
|
+
...(p.shell === undefined ? {} : { shell: p.shell }),
|
|
469
|
+
...(p.commandTimeoutSeconds === undefined ? {} : { commandTimeoutSeconds: p.commandTimeoutSeconds }),
|
|
470
|
+
};
|
|
471
|
+
return { confined: true, root, denyWrite: deny, permissions: Object.freeze(permissions) };
|
|
472
|
+
}
|
|
473
|
+
/** The weaker of two file-access levels; deletion is never broader than writes. */
|
|
474
|
+
function weakerFileAccess(a, b) {
|
|
475
|
+
return FILE_ACCESS_RANK[a] <= FILE_ACCESS_RANK[b] ? a : b;
|
|
476
|
+
}
|
|
477
|
+
function weakerCredentialAccess(a, b) {
|
|
478
|
+
return CREDENTIAL_ACCESS_RANK[a] <= CREDENTIAL_ACCESS_RANK[b] ? a : b;
|
|
479
|
+
}
|
|
480
|
+
/** Intersect two already-validated capability profiles. */
|
|
481
|
+
function intersectPermissions(background, worker) {
|
|
482
|
+
const backgroundCap = isCommandTimeoutSeconds(background.commandTimeoutSeconds) ? background.commandTimeoutSeconds : undefined;
|
|
483
|
+
const workerCap = isCommandTimeoutSeconds(worker.commandTimeoutSeconds) ? worker.commandTimeoutSeconds : undefined;
|
|
484
|
+
const cap = backgroundCap === undefined ? workerCap
|
|
485
|
+
: workerCap === undefined ? backgroundCap : Math.min(backgroundCap, workerCap);
|
|
486
|
+
const shellGiven = background.shell !== undefined || worker.shell !== undefined;
|
|
487
|
+
const capGiven = background.commandTimeoutSeconds !== undefined || worker.commandTimeoutSeconds !== undefined;
|
|
488
|
+
return Object.freeze({
|
|
489
|
+
projectFiles: weakerFileAccess(background.projectFiles, worker.projectFiles),
|
|
490
|
+
outsideProject: weakerFileAccess(background.outsideProject, worker.outsideProject),
|
|
491
|
+
storedCredentials: weakerCredentialAccess(background.storedCredentials, worker.storedCredentials),
|
|
492
|
+
commands: background.commands && worker.commands,
|
|
493
|
+
network: background.network && worker.network,
|
|
494
|
+
...(shellGiven ? { shell: background.shell !== false && worker.shell !== false } : {}),
|
|
495
|
+
...(capGiven ? { commandTimeoutSeconds: cap ?? null } : {}),
|
|
496
|
+
});
|
|
497
|
+
}
|
|
498
|
+
/**
|
|
499
|
+
* The policy snapshot stored behind a worker-authored plan, so provenance and
|
|
500
|
+
* {@link backgroundExecutionLimits} read the effective authority rather than
|
|
501
|
+
* the parent's published profile.
|
|
502
|
+
*/
|
|
503
|
+
function workerPlanPolicy(plan, reason) {
|
|
504
|
+
return Object.freeze({
|
|
505
|
+
state: "enabled",
|
|
506
|
+
writableRoot: plan.writableRoot,
|
|
507
|
+
denyWrite: Object.freeze([...plan.denyWrite]),
|
|
508
|
+
reason,
|
|
509
|
+
...(plan.permissions ? { permissions: Object.freeze({ ...plan.permissions, enabled: true }) } : {}),
|
|
510
|
+
policySource: "background",
|
|
511
|
+
});
|
|
512
|
+
}
|
|
513
|
+
/**
|
|
514
|
+
* Resolve how a worker-launched local background task must be confined.
|
|
515
|
+
*
|
|
516
|
+
* The effective authority is always the worker's captured task authority and
|
|
517
|
+
* the current Background tasks profile, never the parent session's sibling Main
|
|
518
|
+
* profile. When the publisher sends a Background column this reads that column;
|
|
519
|
+
* a legacy publisher with one profile keeps its historical meaning, which is
|
|
520
|
+
* already what Background tasks enforce.
|
|
521
|
+
*
|
|
522
|
+
* Validation runs before any task state exists. A malformed policy, an invalid
|
|
523
|
+
* command cap or level, a disabled worker command capability, differing
|
|
524
|
+
* canonical roots, or an unsupported intersection refuses the launch instead of
|
|
525
|
+
* dropping a rule. The returned plan is an immutable snapshot: it is captured
|
|
526
|
+
* through {@link capturePlan} so later command checks and
|
|
527
|
+
* {@link backgroundExecutionLimits} keep the authority this launch started with.
|
|
528
|
+
*/
|
|
529
|
+
export function resolveWorkerSandboxPlan(pi, workerPolicy, operation, tool = "bg_task_spawn") {
|
|
530
|
+
const background = currentForegroundSandboxPolicy(pi);
|
|
531
|
+
let worker;
|
|
532
|
+
try {
|
|
533
|
+
worker = readWorkerAuthority(workerPolicy);
|
|
534
|
+
}
|
|
535
|
+
catch (error) {
|
|
536
|
+
backgroundDiagnostics(background)?.observe({ tool, operation, resource: "sandbox-backend", basis: "policy-refusal", outcome: "denied" });
|
|
537
|
+
throw error;
|
|
538
|
+
}
|
|
539
|
+
// No captured authority: the current Background tasks profile is the whole
|
|
540
|
+
// answer, exactly as it is for a parent-launched task.
|
|
541
|
+
if (!worker.confined)
|
|
542
|
+
return capturePlan(planFor(background), background);
|
|
543
|
+
// Commands Off is the worker's master switch, independent of Background being
|
|
544
|
+
// on or off. It is checked before any plan is built.
|
|
545
|
+
if (worker.permissions && !worker.permissions.commands) {
|
|
546
|
+
const snapshot = { writableRoot: worker.root, denyWrite: worker.denyWrite, permissions: worker.permissions };
|
|
547
|
+
const policy = workerPlanPolicy(snapshot, "The worker task authority disables commands.");
|
|
548
|
+
backgroundDiagnostics(background)?.observe({ tool, operation, resource: "command-execution", basis: "policy-refusal", outcome: "denied" });
|
|
549
|
+
throw new ForegroundSandboxBlockedError(policy, "The worker task authority disables commands. Change the Subagents permissions before launching background tasks.");
|
|
550
|
+
}
|
|
551
|
+
const backgroundOff = !background || background.state === "inactive" || background.state === "disabled";
|
|
552
|
+
if (backgroundOff) {
|
|
553
|
+
// Preserve the worker's own confinement even though no Background profile is
|
|
554
|
+
// enforcing anything. Its settings are copied, never linked to the source.
|
|
555
|
+
const plan = {
|
|
556
|
+
confined: true,
|
|
557
|
+
writableRoot: worker.root,
|
|
558
|
+
denyWrite: Object.freeze([...worker.denyWrite]),
|
|
559
|
+
...(worker.permissions ? { permissions: worker.permissions } : {}),
|
|
560
|
+
};
|
|
561
|
+
return capturePlan(plan, workerPlanPolicy(plan, "Worker task authority applies; the Background tasks profile is off."));
|
|
562
|
+
}
|
|
563
|
+
try {
|
|
564
|
+
const base = planFor(background);
|
|
565
|
+
if (!base.confined)
|
|
566
|
+
throw new Error("Worker sandbox resolution expected a confined Background tasks plan.");
|
|
567
|
+
const backgroundRoot = canonicalizePath(base.writableRoot);
|
|
568
|
+
if (backgroundRoot !== worker.root) {
|
|
569
|
+
throw new ForegroundSandboxBlockedError(background, `Cannot intersect the Background tasks root ${JSON.stringify(backgroundRoot)} with the worker root ${JSON.stringify(worker.root)}: they confine different directories, so a correct intersection cannot be constructed. Refusing rather than dropping either side's rules.`);
|
|
570
|
+
}
|
|
571
|
+
if (!base.permissions || !worker.permissions) {
|
|
572
|
+
throw new ForegroundSandboxBlockedError(background, `Cannot intersect the Background tasks profile with the worker task authority because ${base.permissions ? "the worker" : "the Background tasks profile"} publishes no permission levels (file access, commands, network). Refusing rather than dropping the other side's controls; update the sandbox packages or set permissions in /sandbox.`);
|
|
573
|
+
}
|
|
574
|
+
const permissions = intersectPermissions(base.permissions, worker.permissions);
|
|
575
|
+
const denyWrite = Object.freeze([...new Set([...base.denyWrite, ...worker.denyWrite])]);
|
|
576
|
+
const plan = { confined: true, writableRoot: backgroundRoot, denyWrite, permissions };
|
|
577
|
+
return capturePlan(plan, workerPlanPolicy(plan, "Worker task authority intersected with the Background tasks profile (weaker levels, ANDed switches, smallest cap, deny paths unioned)."));
|
|
578
|
+
}
|
|
579
|
+
catch (error) {
|
|
580
|
+
if (error instanceof ForegroundSandboxBlockedError) {
|
|
581
|
+
backgroundDiagnostics(background)?.observe({ tool, operation, resource: "sandbox-backend", basis: "policy-refusal", outcome: "denied" });
|
|
582
|
+
}
|
|
583
|
+
throw error;
|
|
584
|
+
}
|
|
585
|
+
}
|
|
586
|
+
const UNLIMITED_EXECUTION = Object.freeze({ shell: true });
|
|
587
|
+
/** Read the immutable application switches captured for `plan`. */
|
|
588
|
+
export function backgroundExecutionLimits(plan) {
|
|
589
|
+
const permissions = launchPolicies.get(plan)?.permissions;
|
|
590
|
+
if (!permissions?.enabled)
|
|
591
|
+
return UNLIMITED_EXECUTION;
|
|
592
|
+
const cap = isCommandTimeoutSeconds(permissions.commandTimeoutSeconds)
|
|
593
|
+
? permissions.commandTimeoutSeconds
|
|
594
|
+
: undefined;
|
|
595
|
+
return Object.freeze({
|
|
596
|
+
shell: permissions.shell !== false,
|
|
597
|
+
...(cap === undefined ? {} : { commandTimeoutSeconds: cap }),
|
|
598
|
+
});
|
|
599
|
+
}
|
|
600
|
+
/**
|
|
601
|
+
* Refuse a launch the captured Background tasks application switches forbid.
|
|
602
|
+
*
|
|
603
|
+
* Called before any task id, directory, log, or metadata exists, so a refused
|
|
604
|
+
* launch leaves nothing behind. `commands: false` is still the master refusal
|
|
605
|
+
* and is raised by {@link planFor}; this is the narrower shell rule. With Shell
|
|
606
|
+
* scripts Off, only a direct executable through `shell: false` argv is allowed.
|
|
607
|
+
* A shell command string and a direct shell interpreter in argv[0] would both
|
|
608
|
+
* reintroduce shell interpretation, and structured SSH carries a remote shell
|
|
609
|
+
* command, so all three are refused.
|
|
610
|
+
*
|
|
611
|
+
* `cwd` is the launch directory the task will actually run in. A relative
|
|
612
|
+
* executable, a relative PATH entry, and an alias found only in that directory
|
|
613
|
+
* are resolved exactly as the launch resolves them, never against Pi's own
|
|
614
|
+
* process cwd.
|
|
615
|
+
*/
|
|
616
|
+
export function assertBackgroundExecutionAllowed(spec, plan, options = {}) {
|
|
617
|
+
const limits = backgroundExecutionLimits(plan);
|
|
618
|
+
if (limits.shell)
|
|
619
|
+
return;
|
|
620
|
+
const launchCwd = options.cwd ?? spec.cwd ?? process.cwd();
|
|
621
|
+
const detail = options.remote
|
|
622
|
+
? "Structured SSH carries a remote shell command, so it cannot run while Shell scripts is Off. Use a local shell:false argv launch, or turn Shell scripts on in /sandbox."
|
|
623
|
+
: spec.shell !== false
|
|
624
|
+
? "Background tasks profile disables shell commands. Pass shell:false with an argv for a direct executable, or turn Shell scripts on in /sandbox."
|
|
625
|
+
: isShellExecutable(spec.argv?.[0] ?? "", { ...process.env, ...spec.env }, launchCwd)
|
|
626
|
+
? "Background tasks profile disables shell commands. A direct shell executable is refused; launch the program itself with shell:false, or turn Shell scripts on in /sandbox."
|
|
627
|
+
: undefined;
|
|
628
|
+
if (detail === undefined)
|
|
629
|
+
return;
|
|
630
|
+
const policy = launchPolicies.get(plan) ?? {
|
|
631
|
+
state: "failed",
|
|
632
|
+
denyWrite: [],
|
|
633
|
+
reason: "The Background tasks profile disables shell commands.",
|
|
634
|
+
};
|
|
635
|
+
throw new ForegroundSandboxBlockedError(policy, detail);
|
|
636
|
+
}
|
|
637
|
+
/**
|
|
638
|
+
* Wrap a local command in the platform's write sandbox.
|
|
639
|
+
*
|
|
640
|
+
* The result is an ordinary `CommandSpec` whose argv is the backend wrapper
|
|
641
|
+
* around the exact executable and arguments the unconfined spec would have run,
|
|
642
|
+
* so spawning, streaming, timeouts, process-group termination, and env handling
|
|
643
|
+
* all stay on their existing code paths. The generated macOS profile is written
|
|
644
|
+
* to `profilePath`, which callers put inside the task's own directory so a
|
|
645
|
+
* resumed watch re-reads the policy it launched with.
|
|
646
|
+
*
|
|
647
|
+
* `seams` defaults to the real platform and PATH. It exists so a caller — in
|
|
648
|
+
* practice a test — can prove the argv this produces for a backend other than
|
|
649
|
+
* the one the host happens to have.
|
|
650
|
+
*/
|
|
651
|
+
export function confineCommandSpec(spec, plan, profilePath, seams = {},
|
|
652
|
+
/** Receives lines to show with the launch (e.g. a placeholder left in the user's files). */
|
|
653
|
+
onNotice = () => { }, tool = "bg_task_spawn") {
|
|
654
|
+
if (!plan.confined)
|
|
655
|
+
return spec;
|
|
656
|
+
const { execPath, execArgs } = commandExecution(spec);
|
|
657
|
+
const directOnly = spec.shell === false && plan.permissions?.shell === false;
|
|
658
|
+
const target = directOnly
|
|
659
|
+
? directApplicationTarget(execPath, execArgs, { ...process.env, ...spec.env }, false)
|
|
660
|
+
: { execPath, execArgs };
|
|
661
|
+
// The generated profile is written here, so its directory must exist before
|
|
662
|
+
// the backend builds the command.
|
|
663
|
+
mkdirSync(dirname(profilePath), { recursive: true });
|
|
664
|
+
// Task state is this package's control plane: `meta.json` carries the launch
|
|
665
|
+
// vector a resumed watch re-runs verbatim, and `sandbox.sb` is the profile the
|
|
666
|
+
// launch is confined by. It lives under the system temp directory, which both
|
|
667
|
+
// backends leave writable by design, so a confined task could otherwise
|
|
668
|
+
// rewrite what its own next poll executes and choose its own confinement.
|
|
669
|
+
//
|
|
670
|
+
// Denying the whole registry closes that without moving any state, and without
|
|
671
|
+
// costing the task anything it actually needs: pi writes the registry from
|
|
672
|
+
// outside the sandbox, and the task's log reaches it through a descriptor
|
|
673
|
+
// opened before the launch, which no later mount or profile can revoke.
|
|
674
|
+
//
|
|
675
|
+
// Created here rather than assumed, because the Linux backend materializes an
|
|
676
|
+
// absent denied path as an empty *file* and this one has to be a directory.
|
|
677
|
+
const controlPlane = baseDir();
|
|
678
|
+
mkdirSync(controlPlane, { recursive: true });
|
|
679
|
+
const denyWrite = [...plan.denyWrite, controlPlane];
|
|
680
|
+
const policy = {
|
|
681
|
+
writableRoot: plan.writableRoot,
|
|
682
|
+
denyWrite,
|
|
683
|
+
home: homedir(),
|
|
684
|
+
...(plan.permissions ? { permissions: plan.permissions } : {}),
|
|
685
|
+
};
|
|
686
|
+
let command;
|
|
687
|
+
try {
|
|
688
|
+
if (plan.permissions && !("permissions" in compileWritePolicy(policy))) {
|
|
689
|
+
throw new Error("permission-aware sandbox core is unavailable; update the sandbox packages before launching");
|
|
690
|
+
}
|
|
691
|
+
command = maybeBuildSandboxCommand({
|
|
692
|
+
profilePath,
|
|
693
|
+
policy,
|
|
694
|
+
...target,
|
|
695
|
+
...(directOnly ? { internalHelperExecutable: true } : {}),
|
|
696
|
+
},
|
|
697
|
+
// `explicitSandbox` because the foreground state already said a sandbox
|
|
698
|
+
// applies: an absent or unusable backend must throw here rather than hand
|
|
699
|
+
// back an unwrapped command. The remedy is the foreground one: this policy
|
|
700
|
+
// came from the session, and the session is where it is switched off.
|
|
701
|
+
{ sandboxEnabled: true, explicitSandbox: true, remedy: FOREGROUND_SANDBOX_REMEDY }, seams);
|
|
702
|
+
}
|
|
703
|
+
catch (error) {
|
|
704
|
+
backgroundDiagnostics(plan)?.observe({ tool, operation: spec, resource: "sandbox-backend", basis: "policy-refusal", outcome: "denied" });
|
|
705
|
+
throw blocked(plan, error instanceof Error ? error.message : String(error));
|
|
706
|
+
}
|
|
707
|
+
if (!command) {
|
|
708
|
+
backgroundDiagnostics(plan)?.observe({ tool, operation: spec, resource: "sandbox-backend", basis: "policy-refusal", outcome: "denied" });
|
|
709
|
+
throw blocked(plan, "no sandbox backend was applied");
|
|
710
|
+
}
|
|
711
|
+
for (const line of command.notices ?? [])
|
|
712
|
+
onNotice(line);
|
|
713
|
+
return { ...spec, ...(directOnly ? { env: { PATH: "/usr/bin:/bin", HOME: homedir() } } : {}),
|
|
714
|
+
argv: [command.file, ...command.fileArgs], shell: false };
|
|
715
|
+
}
|
|
716
|
+
function blocked(plan, detail) {
|
|
717
|
+
return new ForegroundSandboxBlockedError({
|
|
718
|
+
state: "failed",
|
|
719
|
+
policySource: launchPolicies.get(plan)?.policySource,
|
|
720
|
+
writableRoot: plan.writableRoot,
|
|
721
|
+
denyWrite: plan.denyWrite,
|
|
722
|
+
reason: detail,
|
|
723
|
+
}, detail);
|
|
724
|
+
}
|
|
725
|
+
/** Fixed server adapter clears only its own scope mirror before publishing another captured grant. */
|
|
726
|
+
export function clearForegroundSandboxPolicy(pi) {
|
|
727
|
+
observeForegroundSandboxPolicy(pi);
|
|
728
|
+
const events = eventBusOf(pi), mirror = events && mirrors.get(events);
|
|
729
|
+
if (mirror) {
|
|
730
|
+
mirror.policy = undefined;
|
|
731
|
+
mirror.error = undefined;
|
|
732
|
+
mirror.processAccess = "off";
|
|
733
|
+
mirror.mainConfined = false;
|
|
734
|
+
}
|
|
735
|
+
}
|