pi-better-server 0.5.0 → 0.7.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 +7 -3
- 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 +37 -5
- package/scripts/event-publication/writer.mjs +3 -8
- package/scripts/measure-full-runtime/frontend.ts +10 -2
- package/scripts/measure-full-runtime/probe.mjs +4 -2
- 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 +2 -0
- package/scripts/measure-shared-reads.mjs +2 -1
- package/scripts/private-runtime/package-lock.json +18 -0
- package/scripts/private-runtime/package.json +4 -1
- package/scripts/source-provenance.mjs +2 -2
- package/scripts/test-on-pi.sh +2 -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 +9 -4
- package/src/runtime/background-tools.ts +181 -27
- package/src/runtime/background.ts +365 -70
- 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 +43 -35
- package/src/runtime/domain/background/process-identity.mjs +20 -2
- package/src/runtime/domain/background/process.mjs +52 -14
- package/src/runtime/domain/background/registry.mjs +61 -3
- package/src/runtime/domain/background/supervisor/store.mjs +3 -3
- package/src/runtime/domain/background/supervisor/supervisor.mjs +9 -3
- package/src/runtime/domain/background/types.mjs +1 -0
- package/src/runtime/domain/background-service/adapter-contract.domain.mjs +1 -1
- package/src/runtime/domain/background-service/adapter-contract.ts +1 -1
- package/src/runtime/domain/background-service/goal-provider.domain.mjs +35 -16
- package/src/runtime/domain/background-service/goal-provider.ts +31 -16
- package/src/runtime/domain/background-service/index.domain.mjs +25 -9
- package/src/runtime/domain/background-service/index.ts +25 -9
- package/src/runtime/domain/background-service/managed-authority.domain.mjs +6 -3
- package/src/runtime/domain/background-service/managed-authority.ts +5 -3
- package/src/runtime/domain/background-service/managed-client.domain.mjs +21 -7
- package/src/runtime/domain/background-service/managed-client.ts +20 -7
- package/src/runtime/domain/background-service/managed-frontend.domain.mjs +159 -19
- package/src/runtime/domain/background-service/managed-frontend.ts +135 -19
- package/src/runtime/domain/background-service/navigator-provider.domain.mjs +21 -5
- package/src/runtime/domain/background-service/navigator-provider.ts +19 -5
- 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 +372 -57
- package/src/runtime/domain/background-service/observed-waits.ts +321 -53
- package/src/runtime/domain/background-service/process-identity.domain.mjs +20 -2
- package/src/runtime/domain/background-service/process-identity.ts +18 -2
- package/src/runtime/domain/background-service/process.domain.mjs +52 -14
- package/src/runtime/domain/background-service/process.ts +48 -14
- package/src/runtime/domain/background-service/registry.domain.mjs +61 -3
- package/src/runtime/domain/background-service/registry.ts +53 -5
- package/src/runtime/domain/background-service/review-settings.domain.mjs +16 -0
- package/src/runtime/domain/background-service/review-settings.ts +18 -0
- package/src/runtime/domain/background-service/runtime.domain.mjs +40 -86
- package/src/runtime/domain/background-service/runtime.ts +27 -82
- package/src/runtime/domain/background-service/sandbox.domain.mjs +14 -15
- package/src/runtime/domain/background-service/sandbox.ts +14 -11
- package/src/runtime/domain/background-service/shared-callback-batcher.domain.mjs +8 -1
- package/src/runtime/domain/background-service/shared-callback-batcher.ts +11 -2
- package/src/runtime/domain/background-service/shared-navigator-panels.domain.mjs +24 -2
- package/src/runtime/domain/background-service/shared-navigator-panels.ts +26 -4
- package/src/runtime/domain/background-service/shared-navigator.domain.mjs +273 -41
- package/src/runtime/domain/background-service/shared-navigator.ts +244 -40
- 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 +53 -41
- 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 +2 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/assignment-outcomes.ts +2 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/background-requests.domain.mjs +11 -2
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/background-requests.ts +14 -3
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/discovery.domain.mjs +4 -2
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/discovery.ts +5 -3
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/operations.domain.mjs +44 -4
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/operations.ts +50 -2
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/outbox.domain.mjs +7 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/outbox.ts +9 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/result-supervision.domain.mjs +12 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/result-supervision.ts +12 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/rows.domain.mjs +2 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/rows.ts +2 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/schema.domain.mjs +42 -21
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/schema.ts +40 -24
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/store.domain.mjs +26 -4
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/store.ts +40 -8
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/subagent-launch.domain.mjs +23 -1
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/subagent-launch.ts +24 -1
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/types.domain.mjs +1 -1
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/types.ts +5 -1
- package/src/runtime/domain/background-service/shared-sandbox-core.ts +1 -1
- package/src/runtime/domain/background-service/shared-work-client.mjs +174 -7
- package/src/runtime/domain/background-service/stall.domain.mjs +5 -3
- package/src/runtime/domain/background-service/stall.ts +7 -4
- package/src/runtime/domain/background-service/supervised-progress.domain.mjs +42 -0
- package/src/runtime/domain/background-service/supervised-progress.ts +43 -0
- package/src/runtime/domain/background-service/supervisor/README.md +1 -4
- package/src/runtime/domain/background-service/supervisor/emit-runner.mjs +1 -0
- package/src/runtime/domain/background-service/supervisor/generated/process-identity.mjs +20 -2
- package/src/runtime/domain/background-service/supervisor/generated/process.mjs +52 -14
- package/src/runtime/domain/background-service/supervisor/generated/runner.mjs +47 -4
- package/src/runtime/domain/background-service/supervisor/generated/store.mjs +3 -3
- package/src/runtime/domain/background-service/supervisor/generated/watch-fingerprint.mjs +69 -0
- package/src/runtime/domain/background-service/supervisor/runner.domain.mjs +47 -4
- package/src/runtime/domain/background-service/supervisor/runner.ts +38 -3
- package/src/runtime/domain/background-service/supervisor/store.domain.mjs +3 -3
- package/src/runtime/domain/background-service/supervisor/store.ts +3 -3
- package/src/runtime/domain/background-service/supervisor/supervisor.domain.mjs +9 -3
- package/src/runtime/domain/background-service/supervisor/supervisor.ts +6 -3
- package/src/runtime/domain/background-service/task-diagnostics.domain.mjs +1 -1
- package/src/runtime/domain/background-service/task-diagnostics.ts +1 -1
- package/src/runtime/domain/background-service/tools.domain.mjs +53 -40
- package/src/runtime/domain/background-service/tools.ts +67 -54
- package/src/runtime/domain/background-service/types.domain.mjs +1 -0
- package/src/runtime/domain/background-service/types.ts +7 -3
- package/src/runtime/domain/background-service/watch-fingerprint.domain.mjs +67 -0
- package/src/runtime/domain/background-service/watch-fingerprint.ts +70 -0
- package/src/runtime/domain/background-service/work-observation.domain.mjs +46 -20
- package/src/runtime/domain/background-service/work-observation.ts +46 -19
- 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-requests.mjs +11 -2
- 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/outbox.mjs +7 -0
- 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 +42 -21
- package/src/runtime/domain/coordinator/src/store.mjs +26 -4
- package/src/runtime/domain/coordinator/src/subagent-launch.mjs +23 -1
- package/src/runtime/domain/coordinator/src/types.mjs +1 -1
- 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/log-paths.mjs +8 -1
- package/src/runtime/domain/parse.d.mts +4 -1
- package/src/runtime/domain/parse.mjs +58 -9
- package/src/runtime/domain/sandbox-policy/README.md +63 -65
- package/src/runtime/domain/sandbox-policy/commands.domain.mjs +11 -8
- package/src/runtime/domain/sandbox-policy/commands.ts +12 -7
- package/src/runtime/domain/sandbox-policy/index.domain.mjs +53 -9
- package/src/runtime/domain/sandbox-policy/index.ts +52 -9
- package/src/runtime/domain/sandbox-policy/package.json +1 -1
- package/src/runtime/domain/sandbox-policy/permission-settings.domain.mjs +5 -2
- package/src/runtime/domain/sandbox-policy/permission-settings.ts +9 -2
- package/src/runtime/domain/sandbox-policy/permissions-page.domain.mjs +56 -137
- package/src/runtime/domain/sandbox-policy/permissions-page.ts +52 -130
- package/src/runtime/domain/sandbox-policy/permissions.domain.mjs +1 -6
- package/src/runtime/domain/sandbox-policy/permissions.ts +1 -6
- package/src/runtime/domain/sandbox-policy/shared-sandbox-core.ts +1 -1
- package/src/runtime/domain/sandbox-policy/shared-task-exec.domain.mjs +14 -1
- package/src/runtime/domain/sandbox-policy/shared-task-exec.ts +12 -1
- 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 +3 -2
- package/src/runtime/domain/sandbox-policy/shared-task-process-list.ts +8 -2
- package/src/runtime/domain/sandbox-policy/shared-task-sandbox.domain.mjs +4 -3
- package/src/runtime/domain/sandbox-policy/shared-task-sandbox.ts +5 -3
- package/src/runtime/domain/sandbox-policy/shared-task-tools.domain.mjs +8 -5
- package/src/runtime/domain/sandbox-policy/shared-task-tools.ts +8 -5
- package/src/runtime/domain/session-store.mjs +7 -0
- package/src/runtime/domain/subagents/README.md +13 -11
- package/src/runtime/domain/subagents/assignment-outcomes.domain.mjs +10 -7
- package/src/runtime/domain/subagents/assignment-outcomes.ts +9 -6
- package/src/runtime/domain/subagents/assignment-report.domain.mjs +109 -24
- package/src/runtime/domain/subagents/assignment-report.ts +103 -19
- package/src/runtime/domain/subagents/batch.mjs +13 -5
- package/src/runtime/domain/subagents/catalog-host-admission.domain.mjs +21 -3
- package/src/runtime/domain/subagents/catalog-host-admission.ts +19 -3
- package/src/runtime/domain/subagents/catalog-preferences.ts +1 -1
- package/src/runtime/domain/subagents/catalog-resolver.domain.mjs +35 -1
- package/src/runtime/domain/subagents/catalog-resolver.ts +35 -1
- package/src/runtime/domain/subagents/catalog-store.domain.mjs +20 -22
- package/src/runtime/domain/subagents/catalog-store.ts +27 -20
- 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-dependencies.mjs +27 -15
- package/src/runtime/domain/subagents/child-operations.domain.mjs +80 -2
- package/src/runtime/domain/subagents/child-operations.ts +80 -1
- package/src/runtime/domain/subagents/child-preflight.mjs +9 -2
- 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/cleanup.domain.mjs +11 -2
- package/src/runtime/domain/subagents/cleanup.ts +10 -2
- package/src/runtime/domain/subagents/config.domain.mjs +54 -2
- package/src/runtime/domain/subagents/config.ts +53 -3
- package/src/runtime/domain/subagents/continuation-authority.domain.mjs +5 -1
- package/src/runtime/domain/subagents/continuation-authority.ts +3 -1
- 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 +4 -2
- package/src/runtime/domain/subagents/continuation.ts +4 -2
- package/src/runtime/domain/subagents/extensions.mjs +11 -13
- package/src/runtime/domain/subagents/failures.domain.mjs +11 -2
- package/src/runtime/domain/subagents/failures.ts +10 -2
- package/src/runtime/domain/subagents/finalization.domain.mjs +16 -1
- package/src/runtime/domain/subagents/finalization.ts +21 -1
- package/src/runtime/domain/subagents/goal-provider.domain.mjs +44 -2
- package/src/runtime/domain/subagents/goal-provider.ts +44 -2
- package/src/runtime/domain/subagents/health-observation.domain.mjs +189 -190
- package/src/runtime/domain/subagents/health-observation.ts +43 -48
- package/src/runtime/domain/subagents/index.domain.mjs +457 -182
- package/src/runtime/domain/subagents/index.ts +417 -155
- package/src/runtime/domain/subagents/isolated-workspace.domain.mjs +515 -0
- package/src/runtime/domain/subagents/isolated-workspace.ts +557 -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/list.mjs +2 -2
- package/src/runtime/domain/subagents/log-cursor.domain.mjs +85 -16
- package/src/runtime/domain/subagents/log-cursor.ts +91 -15
- package/src/runtime/domain/subagents/managed-launch-bootstrap.mjs +2 -2
- package/src/runtime/domain/subagents/managed-launch-client.domain.mjs +27 -7
- package/src/runtime/domain/subagents/managed-launch-client.ts +28 -8
- package/src/runtime/domain/subagents/managed-launch-host.domain.mjs +222 -14
- package/src/runtime/domain/subagents/managed-launch-host.ts +168 -15
- package/src/runtime/domain/subagents/managed-launch-journal.mjs +1 -5
- package/src/runtime/domain/subagents/managed-launch-port.ts +4 -0
- package/src/runtime/domain/subagents/operation-bridge-types.domain.mjs +27 -2
- package/src/runtime/domain/subagents/operation-bridge-types.ts +27 -2
- package/src/runtime/domain/subagents/output-payload.domain.mjs +24 -9
- package/src/runtime/domain/subagents/output-payload.ts +26 -12
- 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 +4 -2
- package/src/runtime/domain/subagents/parse.domain.mjs +58 -9
- package/src/runtime/domain/subagents/parse.ts +57 -10
- package/src/runtime/domain/subagents/permission-policy.domain.mjs +32 -8
- package/src/runtime/domain/subagents/permission-policy.ts +41 -8
- package/src/runtime/domain/subagents/process-identity.mjs +33 -0
- package/src/runtime/domain/subagents/registry.domain.mjs +71 -51
- package/src/runtime/domain/subagents/registry.ts +77 -38
- package/src/runtime/domain/subagents/retained-result.domain.mjs +56 -0
- package/src/runtime/domain/subagents/retained-result.ts +65 -0
- package/src/runtime/domain/subagents/session-selection.domain.mjs +3 -1
- package/src/runtime/domain/subagents/session-selection.ts +2 -1
- package/src/runtime/domain/subagents/session-store.domain.mjs +7 -0
- package/src/runtime/domain/subagents/session-store.ts +9 -0
- package/src/runtime/domain/subagents/settings-page.domain.mjs +151 -107
- package/src/runtime/domain/subagents/settings-page.ts +147 -108
- package/src/runtime/domain/subagents/shared-callback-batcher.domain.mjs +8 -1
- package/src/runtime/domain/subagents/shared-callback-batcher.ts +11 -2
- package/src/runtime/domain/subagents/shared-catalog.domain.mjs +28 -29
- package/src/runtime/domain/subagents/shared-catalog.ts +29 -21
- package/src/runtime/domain/subagents/shared-navigator-panels.domain.mjs +24 -2
- package/src/runtime/domain/subagents/shared-navigator-panels.ts +26 -4
- package/src/runtime/domain/subagents/shared-navigator.domain.mjs +273 -41
- package/src/runtime/domain/subagents/shared-navigator.ts +244 -40
- package/src/runtime/domain/subagents/shared-operation-coordinator/assignment-inbox.mjs +144 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/assignment-observation.mjs +53 -41
- 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 +2 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/assignment-outcomes.ts +2 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/background-requests.domain.mjs +11 -2
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/background-requests.ts +14 -3
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/discovery.domain.mjs +4 -2
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/discovery.ts +5 -3
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/operations.domain.mjs +44 -4
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/operations.ts +50 -2
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/outbox.domain.mjs +7 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/outbox.ts +9 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/result-supervision.domain.mjs +12 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/result-supervision.ts +12 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/rows.domain.mjs +2 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/rows.ts +2 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/schema.domain.mjs +42 -21
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/schema.ts +40 -24
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/store.domain.mjs +26 -4
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/store.ts +40 -8
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/subagent-launch.domain.mjs +23 -1
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/subagent-launch.ts +24 -1
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/types.domain.mjs +1 -1
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/types.ts +5 -1
- package/src/runtime/domain/subagents/shared-sandbox-core.ts +1 -1
- package/src/runtime/domain/subagents/shared-task-exec.domain.mjs +14 -1
- package/src/runtime/domain/subagents/shared-task-exec.ts +12 -1
- 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 +3 -2
- package/src/runtime/domain/subagents/shared-task-process-list.ts +8 -2
- package/src/runtime/domain/subagents/shared-task-sandbox.domain.mjs +4 -3
- package/src/runtime/domain/subagents/shared-task-sandbox.ts +5 -3
- package/src/runtime/domain/subagents/shared-task-tools.domain.mjs +8 -5
- package/src/runtime/domain/subagents/shared-task-tools.ts +8 -5
- package/src/runtime/domain/subagents/shared-work-client.mjs +174 -7
- package/src/runtime/domain/subagents/subagent-tools.domain.mjs +22 -38
- package/src/runtime/domain/subagents/subagent-tools.ts +28 -34
- package/src/runtime/domain/subagents/task-guard.domain.mjs +14 -1
- package/src/runtime/domain/subagents/task-guard.ts +13 -1
- package/src/runtime/domain/subagents/task-policy.domain.mjs +3 -2
- package/src/runtime/domain/subagents/task-policy.ts +8 -2
- package/src/runtime/domain/subagents/timing.domain.mjs +10 -1
- package/src/runtime/domain/subagents/timing.ts +10 -1
- package/src/runtime/domain/subagents/tools.domain.mjs +4 -8
- package/src/runtime/domain/subagents/tools.ts +4 -7
- package/src/runtime/domain/subagents/work-observation.domain.mjs +102 -17
- package/src/runtime/domain/subagents/work-observation.ts +91 -17
- package/src/runtime/domain/subagents/worker-operations-host.domain.mjs +9 -4
- package/src/runtime/domain/subagents/worker-operations-host.ts +12 -4
- package/src/runtime/domain/subagents/worker-waits.domain.mjs +89 -35
- package/src/runtime/domain/subagents/worker-waits.ts +93 -34
- package/src/runtime/domain/subagents/workspace-files.domain.mjs +103 -0
- package/src/runtime/domain/subagents/workspace-files.ts +114 -0
- package/src/runtime/domain/subagents/workspace-scope.domain.d.mts +38 -0
- package/src/runtime/domain/subagents/workspace-scope.domain.mjs +5 -0
- package/src/runtime/domain/subagents/workspace-scope.ts +6 -0
- package/src/runtime/domain/subagents/worktree-feedback.domain.mjs +55 -0
- package/src/runtime/domain/subagents/worktree-feedback.ts +77 -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 +25 -2
- package/src/runtime/query-executor.ts +149 -28
- package/src/runtime/query-worker.mjs +106 -21
- package/src/runtime/read-model.ts +849 -121
- package/src/runtime/read-watchdog-probe.ts +4 -0
- package/src/runtime/result-supervision.ts +188 -16
- package/src/runtime/root.ts +5 -2
- package/src/runtime/source-watch.ts +175 -0
- package/src/runtime/subagent-launch.ts +11 -4
- 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 +104 -23
- package/src/session-activity.ts +26 -4
- package/src/version.ts +1 -1
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { retainedLogPath } from "./session-store.mjs";
|
|
2
|
+
import { existsSync, realpathSync } from "node:fs";
|
|
2
3
|
import { tmpdir } from "node:os";
|
|
3
4
|
import { join } from "node:path";
|
|
4
5
|
/** Root of the VOLATILE runtime registry, deliberately OUTSIDE any repo. */
|
|
@@ -11,3 +12,9 @@ export function runDir(id) {
|
|
|
11
12
|
export function logPathFor(id) {
|
|
12
13
|
return join(runDir(id), "output.log");
|
|
13
14
|
}
|
|
15
|
+
export function evidenceLogPath(id) {
|
|
16
|
+
const live = logPathFor(id);
|
|
17
|
+
if (existsSync(live) || existsSync(runDir(id)))
|
|
18
|
+
return live;
|
|
19
|
+
return retainedLogPath(id) ?? live;
|
|
20
|
+
}
|
|
@@ -1,2 +1,5 @@
|
|
|
1
|
-
export function parseRun(id: string, options?: { logPath?: string }): { usage: any; toolCalls: string[] };
|
|
1
|
+
export function parseRun(id: string, options?: { logPath?: string; states?: Map<any, any>; summaryOnly?: boolean }): { usage: any; toolCalls: string[]; diagnostics: string[] };
|
|
2
|
+
export function encodeParseLogState(state: any): any;
|
|
3
|
+
export function decodeParseLogState(state: any): any;
|
|
4
|
+
export function parseRunDisplay(id: string, options: { logPath?: string; states: Map<any, any>; summaryOnly?: boolean }): { usage: any; tool: string; diagnostics: string[] };
|
|
2
5
|
export function readRunTranscript(id: string, options?: { logPath?: string }): any;
|
|
@@ -22,8 +22,8 @@
|
|
|
22
22
|
*/
|
|
23
23
|
import { closeSync, openSync, readSync, statSync, } from "node:fs";
|
|
24
24
|
import { readBoundedTail, tailTerminalDisplay } from "./shared-log-utils.mjs";
|
|
25
|
-
import { readAppendedLines } from "./log-cursor.mjs";
|
|
26
|
-
import {
|
|
25
|
+
import { readAppendedLines, parseLogEvent, logReadMetrics } from "./log-cursor.mjs";
|
|
26
|
+
import { evidenceLogPath } from "./log-paths.mjs";
|
|
27
27
|
const DEFAULT_PARSE_TAIL_BYTES = 32 * 1024 * 1024; // 32 MiB
|
|
28
28
|
const DEFAULT_RAW_TAIL_BYTES = 256 * 1024; // 256 KiB
|
|
29
29
|
function envBytes(name, fallback) {
|
|
@@ -58,7 +58,7 @@ function fmtBytes(n) {
|
|
|
58
58
|
const readTail = readBoundedTail;
|
|
59
59
|
/** Last `n` terminal display rows of a run's log, or a placeholder if empty/unreadable. */
|
|
60
60
|
export function tailLog(id, n, maxBytes = maxRawTailBytes()) {
|
|
61
|
-
const tail = readTail(
|
|
61
|
+
const tail = readTail(evidenceLogPath(id), maxBytes);
|
|
62
62
|
if (tail.error || tail.text.trim() === "")
|
|
63
63
|
return "(no output yet)";
|
|
64
64
|
const out = tailTerminalDisplay(tail.text, n).trim();
|
|
@@ -97,7 +97,7 @@ function transcriptContent(msg) {
|
|
|
97
97
|
export function readRunTranscript(id, options = {}) {
|
|
98
98
|
const maxBytes = Math.max(1024, options.maxBytes ?? DEFAULT_TRANSCRIPT_TAIL_BYTES);
|
|
99
99
|
const maxEntries = Math.max(1, options.maxEntries ?? DEFAULT_TRANSCRIPT_ENTRIES);
|
|
100
|
-
const tail = readTail(options.logPath ??
|
|
100
|
+
const tail = readTail(options.logPath ?? evidenceLogPath(id), maxBytes);
|
|
101
101
|
if (tail.error)
|
|
102
102
|
return { entries: [], truncated: false, diagnostic: `Log unreadable: ${tail.error}` };
|
|
103
103
|
const lines = tail.text.split(/\r?\n/);
|
|
@@ -724,7 +724,7 @@ function feedStructuralRecordChar(scan, ch) {
|
|
|
724
724
|
* only after a record is grammar-valid; unfinished/malformed records fail closed.
|
|
725
725
|
*/
|
|
726
726
|
export function scanLifecycleEvidence(id) {
|
|
727
|
-
const path =
|
|
727
|
+
const path = evidenceLogPath(id);
|
|
728
728
|
let totalBytes = 0;
|
|
729
729
|
try {
|
|
730
730
|
totalBytes = statSync(path).size;
|
|
@@ -885,6 +885,15 @@ function peekType(line) {
|
|
|
885
885
|
/** Runs tracked at once; a backstop against unbounded state, not a policy. */
|
|
886
886
|
const MAX_TRACKED_PARSE_RUNS = 64;
|
|
887
887
|
const parseStates = new Map();
|
|
888
|
+
export function encodeParseLogState(state) {
|
|
889
|
+
return { ...state, openToolCalls: [...state.openToolCalls] };
|
|
890
|
+
}
|
|
891
|
+
export function decodeParseLogState(saved) {
|
|
892
|
+
if (!saved?.usage || !Array.isArray(saved.openToolCalls) || !Array.isArray(saved.toolCalls)
|
|
893
|
+
|| !Number.isSafeInteger(saved.cursor?.offset) || saved.cursor.offset < 0)
|
|
894
|
+
throw new Error("Invalid display checkpoint");
|
|
895
|
+
return { ...saved, openToolCalls: new Map(saved.openToolCalls) };
|
|
896
|
+
}
|
|
888
897
|
/** Forget a run's accumulated parse (or all of them). */
|
|
889
898
|
export function resetParseRunCursor(id) {
|
|
890
899
|
if (id === undefined)
|
|
@@ -974,7 +983,7 @@ function selectParsableLines(lines) {
|
|
|
974
983
|
}
|
|
975
984
|
function tryParse(line) {
|
|
976
985
|
try {
|
|
977
|
-
return
|
|
986
|
+
return parseLogEvent(line);
|
|
978
987
|
}
|
|
979
988
|
catch {
|
|
980
989
|
return undefined;
|
|
@@ -995,6 +1004,7 @@ function activityTextOf(e) {
|
|
|
995
1004
|
}
|
|
996
1005
|
/** Fold one event into the run's accumulated state. */
|
|
997
1006
|
function foldParseEvent(state, e) {
|
|
1007
|
+
logReadMetrics.displayFolded++;
|
|
998
1008
|
const type = e.type;
|
|
999
1009
|
state.sawAnyEvent = true;
|
|
1000
1010
|
// Authoritative final answer: the last assistant message at run end.
|
|
@@ -1073,6 +1083,9 @@ function foldParseEvent(state, e) {
|
|
|
1073
1083
|
state.openToolCalls.set(toolCallId ?? `anonymous:${state.anonymousToolCall++}`, { id: toolCallId, toolName });
|
|
1074
1084
|
}
|
|
1075
1085
|
if (type === "tool_execution_end") {
|
|
1086
|
+
const operation = e.result?.details?.deniedWorktreeGitOperation;
|
|
1087
|
+
if (e.isError && typeof operation === "string" && /^[a-z-]{1,24}$/.test(operation))
|
|
1088
|
+
state.deniedWorktreeGitOperation = operation;
|
|
1076
1089
|
if (toolCallId) {
|
|
1077
1090
|
state.openToolCalls.delete(toolCallId);
|
|
1078
1091
|
}
|
|
@@ -1093,16 +1106,29 @@ function foldParseEvent(state, e) {
|
|
|
1093
1106
|
*/
|
|
1094
1107
|
export function parseRun(id, options = {}) {
|
|
1095
1108
|
const key = options.logPath ?? id;
|
|
1096
|
-
const
|
|
1097
|
-
const
|
|
1109
|
+
const states = options.states ?? parseStates;
|
|
1110
|
+
const previous = states.get(key);
|
|
1111
|
+
const path = options.logPath ?? evidenceLogPath(id);
|
|
1112
|
+
let catchUp = false;
|
|
1113
|
+
if (options.summaryOnly) {
|
|
1114
|
+
try {
|
|
1115
|
+
catchUp = statSync(path).size > 1024 * 1024;
|
|
1116
|
+
}
|
|
1117
|
+
catch { /* read reports errors */ }
|
|
1118
|
+
}
|
|
1119
|
+
const read = readAppendedLines(path, previous?.cursor, catchUp ? Math.min(maxParseBytes(), 1024 * 1024) : maxParseBytes(), catchUp);
|
|
1098
1120
|
const state = read.restarted || !previous ? freshState(read.cursor) : previous;
|
|
1099
1121
|
state.cursor = read.cursor;
|
|
1122
|
+
state.catchingUp = read.more;
|
|
1100
1123
|
if (read.totalBytes > 0)
|
|
1101
1124
|
state.totalBytes = read.totalBytes;
|
|
1102
1125
|
if (read.truncated)
|
|
1103
1126
|
state.windowTruncated = true;
|
|
1104
1127
|
state.error = read.error;
|
|
1105
|
-
|
|
1128
|
+
if (options.states)
|
|
1129
|
+
states.set(key, state);
|
|
1130
|
+
else
|
|
1131
|
+
rememberParseState(key, state);
|
|
1106
1132
|
if (read.error !== undefined) {
|
|
1107
1133
|
return {
|
|
1108
1134
|
finalText: "", lastActivity: "", toolCalls: [], unmatchedToolCalls: [], sawEnd: false,
|
|
@@ -1112,6 +1138,11 @@ export function parseRun(id, options = {}) {
|
|
|
1112
1138
|
}
|
|
1113
1139
|
for (const { event } of selectParsableLines(read.lines))
|
|
1114
1140
|
foldParseEvent(state, event);
|
|
1141
|
+
if (options.summaryOnly) {
|
|
1142
|
+
state.finalText = "";
|
|
1143
|
+
state.lastActivity = "";
|
|
1144
|
+
state.toolCalls = state.toolCalls.slice(-256);
|
|
1145
|
+
}
|
|
1115
1146
|
// A log whose final line was never terminated — a writer mid-event, or one
|
|
1116
1147
|
// that simply did not end with a newline — still has to be readable. Fold it
|
|
1117
1148
|
// into a COPY: the cursor has not consumed those bytes, so the same line
|
|
@@ -1123,6 +1154,10 @@ export function parseRun(id, options = {}) {
|
|
|
1123
1154
|
foldParseEvent(view, event);
|
|
1124
1155
|
}
|
|
1125
1156
|
const diagnostics = [];
|
|
1157
|
+
if (state.catchingUp)
|
|
1158
|
+
diagnostics.push(`Usage catch-up pending after byte ${state.cursor.offset} of ${state.totalBytes}.`);
|
|
1159
|
+
if (options.summaryOnly && state.cursor.missing)
|
|
1160
|
+
diagnostics.push(`Incomplete usage: missing bytes [${state.cursor.missing[0]}, ${state.cursor.missing[1]}).`);
|
|
1126
1161
|
if (view.windowTruncated) {
|
|
1127
1162
|
diagnostics.push(`Log truncated: this session began reading at the last ${fmtBytes(maxParseBytes())} ` +
|
|
1128
1163
|
`of ${fmtBytes(view.totalBytes)}. Events before that point are not counted in tokens/tools.`);
|
|
@@ -1140,6 +1175,7 @@ export function parseRun(id, options = {}) {
|
|
|
1140
1175
|
return {
|
|
1141
1176
|
finalText: view.finalText,
|
|
1142
1177
|
lastActivity: view.lastActivity,
|
|
1178
|
+
...(view.deniedWorktreeGitOperation ? { deniedWorktreeGitOperation: view.deniedWorktreeGitOperation } : {}),
|
|
1143
1179
|
toolCalls: [...view.toolCalls],
|
|
1144
1180
|
toolCallCount: view.toolCallCount,
|
|
1145
1181
|
unmatchedToolCalls: [...view.openToolCalls.values()],
|
|
@@ -1149,6 +1185,19 @@ export function parseRun(id, options = {}) {
|
|
|
1149
1185
|
diagnostics,
|
|
1150
1186
|
};
|
|
1151
1187
|
}
|
|
1188
|
+
/** Keep only the incremental facts needed by task-list displays. Detail reads use their own cursor. */
|
|
1189
|
+
export function parseRunDisplay(id, options) {
|
|
1190
|
+
const parsed = parseRun(id, options);
|
|
1191
|
+
const state = options.states.get(options.logPath ?? id);
|
|
1192
|
+
if (state) {
|
|
1193
|
+
state.finalText = "";
|
|
1194
|
+
state.lastActivity = "";
|
|
1195
|
+
state.toolCalls = state.toolCalls.slice(-1);
|
|
1196
|
+
state.openToolCalls.clear();
|
|
1197
|
+
state.modelError = undefined;
|
|
1198
|
+
}
|
|
1199
|
+
return { usage: parsed.usage, tool: parsed.toolCalls.at(-1) ?? "", diagnostics: parsed.diagnostics };
|
|
1200
|
+
}
|
|
1152
1201
|
/** Build the human-readable body for subagent_output. Exported for unit testing. */
|
|
1153
1202
|
export function formatSubagentOutputBody(head, tools, parsedBody, rawTail, diagnostics) {
|
|
1154
1203
|
let body;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# pi-better-sandbox
|
|
2
2
|
|
|
3
|
-
Sandbox permissions for Pi's foreground tools, detached subagents, and local background tasks.
|
|
3
|
+
Sandbox permissions for Pi's foreground tools, detached subagents, and local background tasks. See the [sandbox tool-loading and permission contract](https://github.com/1aboveio/pi-better-harness/blob/main/docs/adr/0027-sandbox-tools-and-permissions.md).
|
|
4
4
|
|
|
5
5
|

|
|
6
6
|
|
|
@@ -18,7 +18,14 @@ enabled switches, keep their values. Open `/sandbox` to change any column, or us
|
|
|
18
18
|
saved to the current session branch. **Ctrl+S** saves all three profiles as
|
|
19
19
|
defaults for new sessions.
|
|
20
20
|
|
|
21
|
+
Press **Tab** to switch between **Tool loading** and **Use permissions**. Tool
|
|
22
|
+
loading lists the active Main tools and the providers for ordinary subagent
|
|
23
|
+
defaults. A role, explicit tool list, or exclusion changes the selection for a
|
|
24
|
+
particular launch. Local Background tasks launch commands through the Background
|
|
25
|
+
adapter. Use permissions shows resource rules for the three profiles.
|
|
26
|
+
|
|
21
27
|
```text
|
|
28
|
+
Tool loading Use permissions Tab switch
|
|
22
29
|
Sandbox permissions Main Subagents Background tasks
|
|
23
30
|
|
|
24
31
|
Sandbox Off Off Off
|
|
@@ -32,62 +39,18 @@ Command time limit - - -
|
|
|
32
39
|
Network access - - -
|
|
33
40
|
Process access - - -
|
|
34
41
|
|
|
35
|
-
|
|
36
|
-
Guarded (follows the file rules)
|
|
37
|
-
[x] apply_patch harness adapter
|
|
38
|
-
Trusted (runs outside the file rules)
|
|
39
|
-
> [x] @juicesharp/rpiv-web-tools 2/2
|
|
40
|
-
> [ ] <other installed package> 0/1
|
|
41
|
-
|
|
42
|
-
↑↓ Select · ←→ Column/fold · Space Toggle · ctrl+s Save default · Enter Fold · Esc Back
|
|
42
|
+
↑↓ Select · ←→ Column · Space Toggle · ctrl+s Save default · Esc Back
|
|
43
43
|
```
|
|
44
44
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
only from the package you ticked. Known network tool names are refused while
|
|
55
|
-
Network access is Off: `web_fetch`, `web_search`, `firecrawl_scrape`, `firecrawl_extract`, `mcp`, `mcpScript`, `remote_bash`,
|
|
56
|
-
`ssh_profile`, `ssh_mux`, and any `mcp__*` name. That is a name list, not a network sandbox.
|
|
57
|
-
|
|
58
|
-
Trusted tools use two levels: a package/provider group, then its individual tools.
|
|
59
|
-
Non-MCP tools are grouped by exact owning package; `mcp__<provider>__...` tools
|
|
60
|
-
are grouped by provider and owning package together. Groups start collapsed.
|
|
61
|
-
File-backed extensions explicitly marked `builtin` by Pi display as `built-in`,
|
|
62
|
-
not their package path (which can be `.`). This is a display label only: saved
|
|
63
|
-
choices and admission still use the original owning package. An unmarked `.`
|
|
64
|
-
package is not built-in, and an unavailable saved tool keeps its package label
|
|
65
|
-
until Pi reports its provenance again. Core tools with synthetic source paths
|
|
66
|
-
remain excluded from trusted candidates.
|
|
67
|
-
`>` means collapsed and `v` means expanded. Their checkbox shows `[x]` when
|
|
68
|
-
all children are selected, `[-]` when some are selected, and `[ ]` when none
|
|
69
|
-
are; the count is selected/total. Right expands a group. Left collapses a group,
|
|
70
|
-
or moves from a child to its parent and collapses it. Enter folds the selected
|
|
71
|
-
group. Space on a group selects all children when none or only some are selected,
|
|
72
|
-
or deselects them all when all are selected. Every toggle applies on one Space;
|
|
73
|
-
Ctrl+S saves defaults and reports anything loosened. Only individual tool
|
|
74
|
-
entries are saved, never a package/provider wildcard or the open/closed state.
|
|
75
|
-
|
|
76
|
-
Defaults: `apply_patch`, `web_fetch`, and `web_search` on; everything else off.
|
|
77
|
-
The `pi-better-ssh` trusted group offers `ssh_profile`, `remote_bash`, and
|
|
78
|
-
`ssh_mux`, all off by default. Expand it with Right and toggle individual tools
|
|
79
|
-
with Space, or toggle the group to select all three. Keep Subagents Network
|
|
80
|
-
access On. A ticked tool automatically loads its owning extension into new
|
|
81
|
-
subagents; no separate extension mapping is needed. Default launches include
|
|
82
|
-
ticked tools; an explicit spawn `tools` list must include the SSH tools needed,
|
|
83
|
-
and `clean:true` does not load extensions. Ctrl+S saves these choices for new
|
|
84
|
-
sessions. Running subagents keep their launch policy.
|
|
85
|
-
|
|
86
|
-
Trusted SSH tools run outside local file, credential-file, and command rules;
|
|
87
|
-
remote effects are not confined either. Only enable them when you trust the
|
|
88
|
-
extension and the subagent's access to your SSH configuration and credentials.
|
|
89
|
-
Other harness packages remain excluded from trusted candidates.
|
|
90
|
-
See [ADR 0009](../../docs/adr/0009-guarded-and-trusted-subagent-tools.md).
|
|
45
|
+
Loading a tool for a task permits that task to call it. The role, tool list and
|
|
46
|
+
exclusions determine what loads. The active profile governs each operation.
|
|
47
|
+
|
|
48
|
+
Editable workers get `apply_patch` by default. With Subagents On, Harness binds
|
|
49
|
+
the guarded adapter and checks every patch target against the file rules.
|
|
50
|
+
Extension tools use the selected provider. A configured worker mapping or an
|
|
51
|
+
active user-installed provider can supply the implementation. The child verifies
|
|
52
|
+
its source before dispatch. Known network tools require Network access On.
|
|
53
|
+
Extension code runs inside the trusted Pi process, outside guarded file operations.
|
|
91
54
|
|
|
92
55
|
Project files and Outside project cycle through four levels:
|
|
93
56
|
|
|
@@ -201,7 +164,7 @@ Linux could separate removal from writing with Landlock (5.19+), but nothing
|
|
|
201
164
|
here can apply it: Node has no binding and `bwrap` does not expose it. Windows
|
|
202
165
|
could use NTFS `DELETE` rights with a restricted token or AppContainer, which
|
|
203
166
|
would need a native launcher. Both are tracked as follow-ups; see
|
|
204
|
-
[ADR 0008](
|
|
167
|
+
[ADR 0008](https://github.com/1aboveio/pi-better-harness/blob/main/docs/adr/0008-write-without-delete.md).
|
|
205
168
|
|
|
206
169
|
### Recovery snapshot (macOS)
|
|
207
170
|
|
|
@@ -234,9 +197,29 @@ literal name filtering and a bounded result limit. It does not expose command
|
|
|
234
197
|
arguments, environment variables, debugger attachment, signals, termination,
|
|
235
198
|
or emulator/ADB operations. Explicit saved values are preserved, and legacy
|
|
236
199
|
saved profiles without this setting stay Off until a human enables Read;
|
|
237
|
-
subagents snapshot the setting at launch.
|
|
238
|
-
|
|
239
|
-
|
|
200
|
+
subagents snapshot the setting at launch. Use `/sandbox status` to see Main's
|
|
201
|
+
`process_list` setting and where this session got it. While Main confinement is
|
|
202
|
+
Off, its retained Process access setting cannot deny the fixed inventory tool.
|
|
203
|
+
To change the value for confined use, edit **Main > Process access** in `/sandbox`
|
|
204
|
+
(Main confinement must be On to edit the detail rows).
|
|
205
|
+
No restart is needed for a local edit. Defaults saved in another session do not
|
|
206
|
+
change an already running session, and reloading a saved branch restores its
|
|
207
|
+
branch settings. Start a new session to use the saved defaults instead.
|
|
208
|
+
|
|
209
|
+
A worker launch reports confinement and Process access separately. A fresh
|
|
210
|
+
worker uses the current session's Subagents profile unless the launch requests
|
|
211
|
+
confinement explicitly. A continuation keeps its saved recipe's confinement
|
|
212
|
+
choice but applies the current Subagents permissions only if that profile is On.
|
|
213
|
+
Switching Subagents confinement Off does not unconfine a saved confined recipe:
|
|
214
|
+
its task sandbox uses the default permissions with guarded Process Read, subject
|
|
215
|
+
to any independent captured authority. If the current profile requires
|
|
216
|
+
confinement but the recipe is unconfined, the continuation is refused. Start a
|
|
217
|
+
new run for a new recipe. A continuation cannot silently drop `process_list`
|
|
218
|
+
if the saved loadout requires it and an active profile sets Process access Off.
|
|
219
|
+
|
|
220
|
+
Background tasks uses this row for explicit task-status process diagnostics, not
|
|
221
|
+
`process_list`. An active Background tasks profile must allow Process Read.
|
|
222
|
+
Those diagnostics check a registered
|
|
240
223
|
PID's start identity and can report state, CPU time and wait evidence without
|
|
241
224
|
arguments or environment values. They are unavailable under Main confinement;
|
|
242
225
|
no unconfined fallback runs. Task confinement remains the policy recorded when
|
|
@@ -253,7 +236,23 @@ hidden-root profiles without `/proc` fail rather than gaining a new host mount.
|
|
|
253
236
|
|
|
254
237
|
On macOS, `/bin/ps` is setuid and can be refused at execution by Seatbelt even
|
|
255
238
|
when process information reads are allowed. Enabling Process access provides
|
|
256
|
-
`process_list
|
|
239
|
+
`process_list`. With Run applications enabled, Main and Subagents also prepend
|
|
240
|
+
a runtime-owned `ps` compatibility entry to task command PATH. It supports only
|
|
241
|
+
`ps -p PID -o lstart= -o comm=` for a current-user process, preserving the system
|
|
242
|
+
command's timestamp/path output. Unsupported arguments fail explicitly; callers
|
|
243
|
+
that reset PATH or use absolute `/bin/ps` retain the OS restriction.
|
|
244
|
+
|
|
245
|
+
The compatibility entry is compiled once per session control directory from
|
|
246
|
+
fixed harness source with `/usr/bin/clang` (Xcode Command Line Tools required).
|
|
247
|
+
It is non-setuid, protected from task writes, integrity-checked before reuse,
|
|
248
|
+
and runs inside the same sandbox. It checks UID, executable path and stable
|
|
249
|
+
kernel start time before emitting output; no argv, environment or process control
|
|
250
|
+
is exposed. The legacy text format has second-level start-time precision and is
|
|
251
|
+
not a durable process handle. Process Off does not install the entry; it remains
|
|
252
|
+
an adapter control, not a syscall-wide prohibition. Compiler failure leaves an
|
|
253
|
+
explicitly unavailable entry and does not block unrelated commands. Install the
|
|
254
|
+
toolchain and restart the session to retry. Linux and Background execution are
|
|
255
|
+
unchanged. No raw `/bin/ps` or unconfined fallback is authorized.
|
|
257
256
|
|
|
258
257
|
File and shell operations use the kernel: macOS uses Seatbelt (`sandbox-exec`)
|
|
259
258
|
and Linux uses Bubblewrap (`bwrap`). `read`, `write`, and `edit` keep Pi's normal
|
|
@@ -281,8 +280,8 @@ are not writable. Credential-file and Pi control-path protections still win.
|
|
|
281
280
|
Outside Off does not expose these host runtime directories.
|
|
282
281
|
|
|
283
282
|
The currently admitted model-tool implementations are `read`, `write`, `edit`,
|
|
284
|
-
`bash`, and guarded `run_application`, plus, for Subagents, the guarded `apply_patch` and
|
|
285
|
-
|
|
283
|
+
`bash`, and guarded `run_application`, plus, for Subagents, the guarded `apply_patch` and selected extension tools
|
|
284
|
+
with verified providers. User-entered `!` and `!!` commands use the same
|
|
286
285
|
shell policy. Other model-callable tools require a verified execution adapter
|
|
287
286
|
and are refused while that actor's sandbox is enabled; enabling network alone
|
|
288
287
|
does not admit them. Subagent launch output identifies requested tools that are
|
|
@@ -298,8 +297,7 @@ under broader file grants. Task access to `~/.pi` does not receive a blanket
|
|
|
298
297
|
write allowance or lock-file exception.
|
|
299
298
|
|
|
300
299
|
Local confinement cannot govern a remote host's filesystem. SSH tools are
|
|
301
|
-
available to confined Subagents
|
|
302
|
-
Subagents · Tools, with Network access On. They run outside local task rules.
|
|
300
|
+
available to confined Subagents when selected with a verified provider and Network access On. They run outside local task rules.
|
|
303
301
|
Main SSH tools, and unadmitted MCP, scripting, background, and nested-agent
|
|
304
302
|
tools, still lack admission adapters and fail closed under an enabled actor
|
|
305
303
|
profile. SSH through confined `bash` receives local file, credential, and network
|
|
@@ -311,7 +309,7 @@ schema identity before admitting local spawn/watch and explicit registry
|
|
|
311
309
|
operations. Background's column controls the executable, independently of
|
|
312
310
|
Main's commands switch. Missing or incompatible adapters fail closed when
|
|
313
311
|
Background confinement is enabled, even with Main Off. Remote stop receives no
|
|
314
|
-
local-adapter exemption under Main confinement. See [ADR 0017](
|
|
312
|
+
local-adapter exemption under Main confinement. See [ADR 0017](https://github.com/1aboveio/pi-better-harness/blob/main/docs/adr/0017-background-adapter-admission.md).
|
|
315
313
|
|
|
316
314
|
Overriding `write` and `edit` changes nothing you can see: the parameter
|
|
317
315
|
schemas, prompt guidance, call rendering, write previews, edit diffs, result
|
|
@@ -20,6 +20,7 @@ export const SANDBOX_COMMAND_DESCRIPTION = "Configure Main, Subagents, and Backg
|
|
|
20
20
|
const USAGE = [
|
|
21
21
|
"Usage:",
|
|
22
22
|
" /sandbox",
|
|
23
|
+
" /sandbox status",
|
|
23
24
|
" /sandbox on",
|
|
24
25
|
" /sandbox off",
|
|
25
26
|
" /sandbox default on",
|
|
@@ -53,7 +54,7 @@ const DEFAULT_OFF_MESSAGE = [
|
|
|
53
54
|
].join("\n");
|
|
54
55
|
const RESET_TITLE = "Restore the packaged write-deny defaults?";
|
|
55
56
|
/** Build the `/sandbox` handler. Exported so its behaviour is directly testable. */
|
|
56
|
-
export function createSandboxCommandHandler({ controller, denyRules, onStateChange, setDefault, setSessionEnabled, openPermissions, }) {
|
|
57
|
+
export function createSandboxCommandHandler({ controller, denyRules, onStateChange, setDefault, setSessionEnabled, describeProcessAccess, openPermissions, }) {
|
|
57
58
|
return async function handleSandboxCommand(args, ctx) {
|
|
58
59
|
// Only the verbs are case-folded. Everything after them is a path, and
|
|
59
60
|
// paths are case-sensitive on the filesystems this package supports.
|
|
@@ -65,12 +66,13 @@ export function createSandboxCommandHandler({ controller, denyRules, onStateChan
|
|
|
65
66
|
await handleDiagnosticsCommand(rest, ctx);
|
|
66
67
|
return;
|
|
67
68
|
}
|
|
68
|
-
if (subcommand === "") {
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
69
|
+
if (subcommand === "" && openPermissions && ctx.mode === "tui") {
|
|
70
|
+
await openPermissions(ctx);
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
if (subcommand === "" || subcommand === "status") {
|
|
74
|
+
const status = controller.status();
|
|
75
|
+
ctx.ui.notify([formatSandboxReport(status), describeProcessAccess?.(status)].filter(Boolean).join("\n\n"), "info");
|
|
74
76
|
return;
|
|
75
77
|
}
|
|
76
78
|
if (subcommand === "on") {
|
|
@@ -198,9 +200,10 @@ function announce(ctx, change) {
|
|
|
198
200
|
throw error;
|
|
199
201
|
}
|
|
200
202
|
}
|
|
201
|
-
const SUBCOMMANDS = ["on", "off", "default", "deny", "rules", "diagnostics"];
|
|
203
|
+
const SUBCOMMANDS = ["on", "off", "default", "deny", "rules", "diagnostics", "status"];
|
|
202
204
|
const DENY_ACTIONS = ["list", "add", "remove", "reset"];
|
|
203
205
|
const COMPLETION_DESCRIPTIONS = {
|
|
206
|
+
status: "Show effective Main sandbox and process-tool access",
|
|
204
207
|
on: "Enable confinement for this session",
|
|
205
208
|
off: "Disable confinement for this session",
|
|
206
209
|
default: "Change the persistent activation default",
|
|
@@ -33,6 +33,7 @@ export const SANDBOX_COMMAND_DESCRIPTION =
|
|
|
33
33
|
const USAGE = [
|
|
34
34
|
"Usage:",
|
|
35
35
|
" /sandbox",
|
|
36
|
+
" /sandbox status",
|
|
36
37
|
" /sandbox on",
|
|
37
38
|
" /sandbox off",
|
|
38
39
|
" /sandbox default on",
|
|
@@ -84,6 +85,7 @@ export type SandboxCommandDeps = {
|
|
|
84
85
|
setDefault: (enabled: boolean) => ForegroundSandboxStatus;
|
|
85
86
|
/** Persist the session change before mutating enforcement. */
|
|
86
87
|
setSessionEnabled?: (enabled: boolean) => ForegroundSandboxStatus;
|
|
88
|
+
describeProcessAccess?: (status: ForegroundSandboxStatus) => string;
|
|
87
89
|
openPermissions?: (ctx: ExtensionCommandContext) => Promise<void>;
|
|
88
90
|
};
|
|
89
91
|
|
|
@@ -94,6 +96,7 @@ export function createSandboxCommandHandler({
|
|
|
94
96
|
onStateChange,
|
|
95
97
|
setDefault,
|
|
96
98
|
setSessionEnabled,
|
|
99
|
+
describeProcessAccess,
|
|
97
100
|
openPermissions,
|
|
98
101
|
}: SandboxCommandDeps) {
|
|
99
102
|
return async function handleSandboxCommand(
|
|
@@ -112,12 +115,13 @@ export function createSandboxCommandHandler({
|
|
|
112
115
|
return;
|
|
113
116
|
}
|
|
114
117
|
|
|
115
|
-
if (subcommand === "") {
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
118
|
+
if (subcommand === "" && openPermissions && ctx.mode === "tui") {
|
|
119
|
+
await openPermissions(ctx);
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
if (subcommand === "" || subcommand === "status") {
|
|
123
|
+
const status = controller.status();
|
|
124
|
+
ctx.ui.notify([formatSandboxReport(status), describeProcessAccess?.(status)].filter(Boolean).join("\n\n"), "info");
|
|
121
125
|
return;
|
|
122
126
|
}
|
|
123
127
|
|
|
@@ -280,10 +284,11 @@ function announce(ctx: ExtensionCommandContext, change: () => DenyRuleReport): v
|
|
|
280
284
|
}
|
|
281
285
|
}
|
|
282
286
|
|
|
283
|
-
const SUBCOMMANDS = ["on", "off", "default", "deny", "rules", "diagnostics"] as const;
|
|
287
|
+
const SUBCOMMANDS = ["on", "off", "default", "deny", "rules", "diagnostics", "status"] as const;
|
|
284
288
|
const DENY_ACTIONS = ["list", "add", "remove", "reset"] as const;
|
|
285
289
|
|
|
286
290
|
const COMPLETION_DESCRIPTIONS: Readonly<Record<string, string>> = {
|
|
291
|
+
status: "Show effective Main sandbox and process-tool access",
|
|
287
292
|
on: "Enable confinement for this session",
|
|
288
293
|
off: "Disable confinement for this session",
|
|
289
294
|
default: "Change the persistent activation default",
|
|
@@ -21,17 +21,33 @@ import { createBackgroundAdmission, isBackgroundLaunch } from "./background-admi
|
|
|
21
21
|
import { DenyRuleManager } from "./deny-rules.domain.mjs";
|
|
22
22
|
import { FOREGROUND_SANDBOX_POLICY_REQUEST_CHANNEL, publishForegroundSandboxPolicy, } from "./events.domain.mjs";
|
|
23
23
|
import { installTaskTools, runtimeCodeRoot } from "./shared-task-sandbox.domain.mjs";
|
|
24
|
-
import {
|
|
24
|
+
import { toolPackage } from "./shared-task-tools.domain.mjs";
|
|
25
25
|
import { writeSandboxDefault } from "./preferences.domain.mjs";
|
|
26
|
-
import { readPermissionSettings, writePermissionSettings } from "./permission-settings.domain.mjs";
|
|
26
|
+
import { loadPermissionSettings, readPermissionSettings, writePermissionSettings } from "./permission-settings.domain.mjs";
|
|
27
27
|
import { defaultSandboxPermissions, describeLoosening } from "./permissions.domain.mjs";
|
|
28
28
|
import { openPermissionsPage } from "./permissions-page.domain.mjs";
|
|
29
29
|
import { appendSessionPermissions, readSessionPermissions } from "./session-permissions.domain.mjs";
|
|
30
|
-
import { createSubagentExecutionAdmission
|
|
30
|
+
import { createSubagentExecutionAdmission } from "./subagent-admission.domain.mjs";
|
|
31
31
|
import { ForegroundSandboxController } from "./state.domain.mjs";
|
|
32
32
|
import { SandboxDiagnostics, diagnosticPackageVersion } from "./shared-sandbox-diagnostics.domain.mjs";
|
|
33
33
|
export default function piBetterSandbox(pi) {
|
|
34
34
|
const controller = new ForegroundSandboxController();
|
|
35
|
+
let permissionSource = "session not started";
|
|
36
|
+
const mainProcessAccess = () => {
|
|
37
|
+
const main = controller.permissionSettings()?.main;
|
|
38
|
+
return main && !main.enabled ? "read" : main?.processAccess ?? "off";
|
|
39
|
+
};
|
|
40
|
+
const mainProcessSummary = () => {
|
|
41
|
+
const main = controller.permissionSettings()?.main;
|
|
42
|
+
const setting = main?.processAccess === "read" ? "Read" : "Off";
|
|
43
|
+
if (main && !main.enabled) {
|
|
44
|
+
return `Main process_list: allowed by policy (Main confinement Off; retained Process access: ${setting}, from ${permissionSource}).`;
|
|
45
|
+
}
|
|
46
|
+
return `Main process_list: Process access is ${setting} (${permissionSource}).`;
|
|
47
|
+
};
|
|
48
|
+
const mainProcessOffHelp = () => permissionSource === "session not started"
|
|
49
|
+
? "Wait for Pi to finish starting the session."
|
|
50
|
+
: "Set Main > Process access to Read in /sandbox; edits here apply without a restart. Subagents settings do not control this tool.";
|
|
35
51
|
let diagnosticsWarning;
|
|
36
52
|
const diagnostics = new SandboxDiagnostics({ context: "foreground",
|
|
37
53
|
version: diagnosticPackageVersion(new URL("./package.json", import.meta.url)),
|
|
@@ -49,7 +65,8 @@ export default function piBetterSandbox(pi) {
|
|
|
49
65
|
const subagentExecutionAdmission = createSubagentExecutionAdmission(pi);
|
|
50
66
|
const boundary = installTaskTools(pi, { controller, cwd: process.cwd(), shellPath: () => shellPath,
|
|
51
67
|
admitExtensionTool: (name, input, sourcePath) => backgroundAdmission(name, input, sourcePath) !== undefined,
|
|
52
|
-
processAccess:
|
|
68
|
+
processAccess: mainProcessAccess,
|
|
69
|
+
processAccessDenied: () => `Sandbox: ${mainProcessSummary()} ${mainProcessOffHelp()}`,
|
|
53
70
|
diagnostics,
|
|
54
71
|
trustedSources: [ownEntry,
|
|
55
72
|
join(dirname(ownEntry), "../../extensions/sandbox/index.ts"),
|
|
@@ -65,8 +82,7 @@ export default function piBetterSandbox(pi) {
|
|
|
65
82
|
const backgroundLaunch = isBackgroundLaunch(name, event.input);
|
|
66
83
|
const admission = backgroundAdmission(name, event.input);
|
|
67
84
|
const child = status.subagentPermissions;
|
|
68
|
-
if ((name === "subagent_spawn" || name === "subagent_spawn_batch") && child?.commands &&
|
|
69
|
-
(child.enabled || requestsSubagentSandbox(name, event.input)) &&
|
|
85
|
+
if ((name === "subagent_spawn" || name === "subagent_spawn_batch") && child?.enabled && child.commands &&
|
|
70
86
|
(child.shell === false || child.commandTimeoutSeconds != null) && !subagentExecutionAdmission(name)) {
|
|
71
87
|
return block("Sandbox: subagent launch has no compatible application execution adapter. Update pi-better-subagents before using Shell scripts or Command time limit restrictions.", "tool-admission");
|
|
72
88
|
}
|
|
@@ -113,9 +129,18 @@ export default function piBetterSandbox(pi) {
|
|
|
113
129
|
try {
|
|
114
130
|
const sessionPermissions = readSessionPermissions(ctx);
|
|
115
131
|
hasSessionPolicy = sessionPermissions !== undefined;
|
|
116
|
-
|
|
132
|
+
if (sessionPermissions) {
|
|
133
|
+
settings = sessionPermissions;
|
|
134
|
+
permissionSource = "this session branch";
|
|
135
|
+
}
|
|
136
|
+
else {
|
|
137
|
+
const loaded = loadPermissionSettings();
|
|
138
|
+
settings = loaded.settings;
|
|
139
|
+
permissionSource = loaded.source;
|
|
140
|
+
}
|
|
117
141
|
}
|
|
118
142
|
catch (error) {
|
|
143
|
+
permissionSource = "settings load failed";
|
|
119
144
|
controller.beginSession(ctx.cwd, true);
|
|
120
145
|
const message = `Sandbox permissions could not be loaded: ${error instanceof Error ? error.message : String(error)}`;
|
|
121
146
|
settings.main.enabled = true;
|
|
@@ -168,10 +193,20 @@ export default function piBetterSandbox(pi) {
|
|
|
168
193
|
const openSettings = async (ctx) => {
|
|
169
194
|
await openPermissionsPage(ctx, {
|
|
170
195
|
getConfig: () => controller.permissionSettings() ?? defaultSandboxPermissions(),
|
|
171
|
-
|
|
172
|
-
|
|
196
|
+
toolLoading: () => {
|
|
197
|
+
const active = new Set(pi.getActiveTools());
|
|
198
|
+
const main = pi.getAllTools().filter(tool => active.has(tool.name))
|
|
199
|
+
.map(tool => ({ name: tool.name, provider: toolPackage(tool)?.package ?? tool.sourceInfo?.source ?? "Pi" }))
|
|
200
|
+
.sort((a, b) => a.name.localeCompare(b.name));
|
|
201
|
+
let subagents;
|
|
202
|
+
pi.events.emit("pi-better-subagents:default-tool-loading", {
|
|
203
|
+
reply: (rows) => { subagents = rows; },
|
|
204
|
+
});
|
|
205
|
+
return subagents === undefined ? { main } : { main, subagents };
|
|
206
|
+
},
|
|
173
207
|
change: (settings) => {
|
|
174
208
|
appendSessionPermissions(pi, settings);
|
|
209
|
+
permissionSource = "this session branch";
|
|
175
210
|
announce(controller.setPermissionSettings(settings));
|
|
176
211
|
},
|
|
177
212
|
save: (settings) => writePermissionSettings(settings),
|
|
@@ -209,6 +244,7 @@ export default function piBetterSandbox(pi) {
|
|
|
209
244
|
const settings = controller.permissionSettings() ?? defaultSandboxPermissions();
|
|
210
245
|
settings.main.enabled = enabled;
|
|
211
246
|
appendSessionPermissions(pi, settings);
|
|
247
|
+
permissionSource = "this session branch";
|
|
212
248
|
return enabled ? controller.enable() : controller.disable();
|
|
213
249
|
},
|
|
214
250
|
setDefault: (enabled) => {
|
|
@@ -217,8 +253,16 @@ export default function piBetterSandbox(pi) {
|
|
|
217
253
|
writePermissionSettings(settings);
|
|
218
254
|
writeSandboxDefault(enabled ? "on" : "off");
|
|
219
255
|
appendSessionPermissions(pi, settings);
|
|
256
|
+
permissionSource = "this session branch";
|
|
220
257
|
return controller.setPermissionSettings(settings);
|
|
221
258
|
},
|
|
259
|
+
describeProcessAccess: (status) => [
|
|
260
|
+
mainProcessSummary(),
|
|
261
|
+
status.state === "unavailable" || status.state === "failed" ? "Main sandbox cannot launch the inventory helper." : undefined,
|
|
262
|
+
mainProcessAccess() === "off" ? mainProcessOffHelp() : undefined,
|
|
263
|
+
status.state === "enabled" && status.backend === "macos-seatbelt" ? "macOS Seatbelt can deny absolute /bin/ps even with Process Read." : undefined,
|
|
264
|
+
"Edits in this session apply immediately. Saved defaults from another session apply to new sessions; a saved branch policy survives reload.",
|
|
265
|
+
].filter(Boolean).join("\n"),
|
|
222
266
|
openPermissions: openSettings,
|
|
223
267
|
}),
|
|
224
268
|
});
|