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,11 +1,97 @@
|
|
|
1
1
|
// Generated fixed launch domain from packages/pi-better-background-tasks/src/shared-navigator.ts. Do not edit directly.
|
|
2
2
|
import { truncateToWidth as piTruncateToWidth, visibleWidth as piVisibleWidth } from "@earendil-works/pi-tui";
|
|
3
|
+
import { readHarnessSetting, updateHarnessSetting } from "./shared-harness-settings.domain.mjs";
|
|
3
4
|
import { createRenderScheduler } from "./shared-render-scheduler.domain.mjs";
|
|
4
5
|
import { setNavigatorPanel } from "./shared-navigator-panels.domain.mjs";
|
|
5
6
|
export default function navigatorExtension() {
|
|
6
7
|
// Internal shared package. Pi may scan its symlink in the extension directory
|
|
7
8
|
// for sibling relative imports; loading it directly should be harmless.
|
|
8
9
|
}
|
|
10
|
+
export function getNavigatorView() { return state().view ?? "flatten"; }
|
|
11
|
+
export function loadNavigatorView() {
|
|
12
|
+
const value = readHarnessSetting("navigatorView");
|
|
13
|
+
state().view = value === "tree" ? "tree" : "flatten";
|
|
14
|
+
}
|
|
15
|
+
export function setNavigatorView(value) {
|
|
16
|
+
if (value !== "tree" && value !== "flatten")
|
|
17
|
+
throw new Error("View must be tree or flatten.");
|
|
18
|
+
updateHarnessSetting("navigatorView", () => value);
|
|
19
|
+
state().view = value;
|
|
20
|
+
refreshBackgroundWorkNavigator();
|
|
21
|
+
}
|
|
22
|
+
/** UI time is independent of worker time; repeated refreshes never renew it. */
|
|
23
|
+
export function createTerminalRowRetention(retentionMs = 30_000) {
|
|
24
|
+
const held = new Map();
|
|
25
|
+
const dismissed = new Set();
|
|
26
|
+
return {
|
|
27
|
+
clear() { held.clear(); dismissed.clear(); },
|
|
28
|
+
dismiss(id) { held.delete(id); dismissed.add(id); },
|
|
29
|
+
merge(rows, now) {
|
|
30
|
+
const result = [];
|
|
31
|
+
const present = new Set(rows.map(row => row.id));
|
|
32
|
+
for (const id of dismissed)
|
|
33
|
+
if (!present.has(id))
|
|
34
|
+
dismissed.delete(id);
|
|
35
|
+
for (const row of rows) {
|
|
36
|
+
if (dismissed.has(row.id))
|
|
37
|
+
continue;
|
|
38
|
+
const terminal = ["completed", "succeeded", "failed", "cancelled", "killed", "lost", "timed_out"].includes(row.status);
|
|
39
|
+
if (!terminal) {
|
|
40
|
+
held.delete(row.id);
|
|
41
|
+
result.push(row);
|
|
42
|
+
continue;
|
|
43
|
+
}
|
|
44
|
+
let entry = held.get(row.id);
|
|
45
|
+
if (!entry) {
|
|
46
|
+
entry = { row, until: now + retentionMs };
|
|
47
|
+
held.set(row.id, entry);
|
|
48
|
+
}
|
|
49
|
+
entry.row = { ...row, expiresAt: entry.until };
|
|
50
|
+
if (now < entry.until)
|
|
51
|
+
result.push(entry.row);
|
|
52
|
+
}
|
|
53
|
+
for (const [id, entry] of held) {
|
|
54
|
+
if (present.has(id))
|
|
55
|
+
continue;
|
|
56
|
+
if (now < entry.until)
|
|
57
|
+
result.push(entry.row);
|
|
58
|
+
else
|
|
59
|
+
held.delete(id);
|
|
60
|
+
}
|
|
61
|
+
return result;
|
|
62
|
+
},
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
/** A frontend-only diagnostic, never an execution record or authority to retry. */
|
|
66
|
+
export async function observeNavigatorLaunch(ctx, providerId, key, name, launch) {
|
|
67
|
+
const scope = JSON.stringify([ctx.cwd, ctx.sessionManager?.getSessionId?.()]);
|
|
68
|
+
const report = (error) => {
|
|
69
|
+
const s = state();
|
|
70
|
+
if (!isNavigatorUiAvailable(s.uiCtx) || s.observationScope !== scope)
|
|
71
|
+
return;
|
|
72
|
+
const id = `launch-error-${key}`;
|
|
73
|
+
const primary = error instanceof Error ? error.message : String(error);
|
|
74
|
+
const failures = s.launchFailures ??= new Map();
|
|
75
|
+
const identity = rowKey(providerId, id);
|
|
76
|
+
failures.set(identity, { providerId, id, name, status: "failed", statusTone: "failed", kind: "launch-error", elapsed: "", primary,
|
|
77
|
+
secondary: "Launch failed or was not confirmed; inspect before retrying.", sortStartedAt: Date.now() });
|
|
78
|
+
// Diagnostics are session-local and bounded, including expired tombstones.
|
|
79
|
+
if (failures.size > 128)
|
|
80
|
+
failures.delete(failures.keys().next().value);
|
|
81
|
+
refreshBackgroundWorkNavigator();
|
|
82
|
+
};
|
|
83
|
+
try {
|
|
84
|
+
const result = await launch();
|
|
85
|
+
const response = result;
|
|
86
|
+
if (response?.isError)
|
|
87
|
+
report(response.content?.filter(item => item.type === "text").map(item => item.text).join("\n") || "Launch request failed");
|
|
88
|
+
return result;
|
|
89
|
+
}
|
|
90
|
+
catch (error) {
|
|
91
|
+
report(error);
|
|
92
|
+
throw error;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
9
95
|
const GLOBAL_KEY = Symbol.for("pi-better-harness.navigator.state");
|
|
10
96
|
const FACTORY_MARK = "__piBetterHarnessNavigatorFactory";
|
|
11
97
|
const FACTORY_REFRESH = "__piBetterHarnessNavigatorRefresh";
|
|
@@ -96,6 +182,20 @@ export function ensureBackgroundWorkNavigator(ctx, deps, owner) {
|
|
|
96
182
|
if (!isNavigatorUiAvailable(ctx))
|
|
97
183
|
return;
|
|
98
184
|
const s = state();
|
|
185
|
+
if (s.view === undefined) {
|
|
186
|
+
try {
|
|
187
|
+
loadNavigatorView();
|
|
188
|
+
}
|
|
189
|
+
catch {
|
|
190
|
+
s.view = "flatten";
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
const scope = JSON.stringify([ctx.cwd, ctx.sessionManager?.getSessionId?.()]);
|
|
194
|
+
if (s.observationScope !== scope) {
|
|
195
|
+
s.terminalRows?.clear();
|
|
196
|
+
s.launchFailures?.clear();
|
|
197
|
+
}
|
|
198
|
+
s.observationScope = scope;
|
|
99
199
|
s.uiCtx = ctx;
|
|
100
200
|
s.uiOwner = owner;
|
|
101
201
|
s.deps = {
|
|
@@ -142,6 +242,9 @@ export function disposeBackgroundWorkNavigator(ctx, owner) {
|
|
|
142
242
|
stopMainListWidget();
|
|
143
243
|
const activeCtx = ctx ?? s.uiCtx;
|
|
144
244
|
s.uiCtx = undefined;
|
|
245
|
+
s.terminalRows?.clear();
|
|
246
|
+
s.launchFailures?.clear();
|
|
247
|
+
s.observationScope = undefined;
|
|
145
248
|
s.uiOwner = undefined;
|
|
146
249
|
if (activeCtx && isNavigatorUiAvailable(activeCtx)) {
|
|
147
250
|
try {
|
|
@@ -243,7 +346,7 @@ function refreshMainListWidget() {
|
|
|
243
346
|
}
|
|
244
347
|
if (!s.mainListWidgetInstalled) {
|
|
245
348
|
try {
|
|
246
|
-
setNavigatorPanel(ctx, MAIN_LIST_WIDGET_KEY, (tui, theme) => createMainListWidget(tui, theme, deps), { placement: "aboveEditor" });
|
|
349
|
+
setNavigatorPanel(ctx, MAIN_LIST_WIDGET_KEY, (tui, theme, layout) => createMainListWidget(tui, theme, deps, layout), { placement: "aboveEditor" });
|
|
247
350
|
s.mainListWidgetInstalled = true;
|
|
248
351
|
}
|
|
249
352
|
catch { /* ignore */ }
|
|
@@ -266,7 +369,7 @@ const BACK_TO_MAIN = "← main (Esc)";
|
|
|
266
369
|
const BACK_TARGET = "back-to-main";
|
|
267
370
|
function highlightPointerTarget(theme, line, width) {
|
|
268
371
|
const colors = theme;
|
|
269
|
-
return colors?.bg?.("selectedBg", line + " ".repeat(Math.max(0, width -
|
|
372
|
+
return colors?.bg?.("selectedBg", line + " ".repeat(Math.max(0, width - piVisibleWidth(line))))
|
|
270
373
|
?? themeFgFromTheme(theme)("accent", line);
|
|
271
374
|
}
|
|
272
375
|
function createPointerNavigation(targetAt, activate) {
|
|
@@ -301,7 +404,7 @@ function createPointerNavigation(targetAt, activate) {
|
|
|
301
404
|
},
|
|
302
405
|
};
|
|
303
406
|
}
|
|
304
|
-
function createMainListWidget(tui, theme, deps) {
|
|
407
|
+
function createMainListWidget(tui, theme, deps, panelLayout = { availableRows: () => Infinity }) {
|
|
305
408
|
const requestRender = () => tui.requestRender?.();
|
|
306
409
|
state().mainListRequestRender = requestRender;
|
|
307
410
|
// navigatorId per rendered line, so a pointer row resolves by structure, never by row text.
|
|
@@ -339,8 +442,23 @@ function createMainListWidget(tui, theme, deps) {
|
|
|
339
442
|
}
|
|
340
443
|
lineWidth = renderWidth(width);
|
|
341
444
|
// The leading gap line belongs to the widget too, so its slot stays ownerless.
|
|
445
|
+
let rawLines = ["", ...layout.lines];
|
|
342
446
|
lineOwners = [undefined, ...layout.owners];
|
|
343
|
-
const
|
|
447
|
+
const budget = Math.max(0, Math.floor(panelLayout.availableRows()));
|
|
448
|
+
if (rawLines.length > budget) {
|
|
449
|
+
const selected = state().mainListFocused ? lineOwners.indexOf(state().mainListSelectedId) : -1;
|
|
450
|
+
const count = Math.max(0, budget - 1);
|
|
451
|
+
const start = selected >= 0 ? Math.max(0, Math.min(selected - Math.floor(count / 2), rawLines.length - count)) : 2;
|
|
452
|
+
rawLines = rawLines.slice(start, start + count);
|
|
453
|
+
lineOwners = lineOwners.slice(start, start + count);
|
|
454
|
+
const visible = new Set(lineOwners.filter(Boolean));
|
|
455
|
+
if (budget > 0) {
|
|
456
|
+
const hidden = rows.length - visible.size;
|
|
457
|
+
rawLines.push(deps.truncate(hidden ? ` +${hidden} tasks` : ` ${rows.length} tasks`, renderWidth(width)));
|
|
458
|
+
lineOwners.push(undefined);
|
|
459
|
+
}
|
|
460
|
+
}
|
|
461
|
+
const lines = rawLines.map((line, index) => pointer.hovered && lineOwners[index] === pointer.hovered ? highlightPointerTarget(theme, line, lineWidth) : line);
|
|
344
462
|
state().lastMainListLines = lines;
|
|
345
463
|
return lines;
|
|
346
464
|
},
|
|
@@ -383,6 +501,12 @@ function listRows(now = Date.now()) {
|
|
|
383
501
|
catch {
|
|
384
502
|
providerRows = [];
|
|
385
503
|
}
|
|
504
|
+
providerRows = [...providerRows, ...[...(state().launchFailures?.values() ?? [])].filter(row => row.providerId === provider.id)];
|
|
505
|
+
const retention = state().terminalRows ??= new Map();
|
|
506
|
+
if (!retention.has(provider.id))
|
|
507
|
+
retention.set(provider.id, createTerminalRowRetention());
|
|
508
|
+
if (isNavigatorUiAvailable(state().uiCtx))
|
|
509
|
+
providerRows = retention.get(provider.id).merge(providerRows, now);
|
|
386
510
|
const orderedProviderRows = [...providerRows].sort((a, b) => b.sortStartedAt - a.sortStartedAt || rowDisplayName(a).localeCompare(rowDisplayName(b)));
|
|
387
511
|
let showSection = orderedProviderRows.length > 0 || provider.parentRow !== undefined;
|
|
388
512
|
try {
|
|
@@ -391,7 +515,7 @@ function listRows(now = Date.now()) {
|
|
|
391
515
|
catch {
|
|
392
516
|
showSection = false;
|
|
393
517
|
}
|
|
394
|
-
if (!showSection)
|
|
518
|
+
if (!showSection && !(getNavigatorView() === "tree" && provider.parentRow))
|
|
395
519
|
continue;
|
|
396
520
|
let parentRow = null;
|
|
397
521
|
try {
|
|
@@ -412,7 +536,51 @@ function listRows(now = Date.now()) {
|
|
|
412
536
|
rows.push({ ...row, navigatorId: rowKey(provider.id, row.id), providerLabel: provider.label });
|
|
413
537
|
}
|
|
414
538
|
}
|
|
415
|
-
|
|
539
|
+
const conversations = mergeAgentAttempts(rows);
|
|
540
|
+
return getNavigatorView() === "tree" ? treeRows(conversations) : conversations;
|
|
541
|
+
}
|
|
542
|
+
/** A resumed execution is still the same agent in either layout. */
|
|
543
|
+
export function mergeAgentAttempts(rows) {
|
|
544
|
+
const latest = new Map();
|
|
545
|
+
for (const row of rows) {
|
|
546
|
+
if (row.providerId !== "subagents" || !row.agentId)
|
|
547
|
+
continue;
|
|
548
|
+
const previous = latest.get(row.agentId);
|
|
549
|
+
if (!previous || row.sortStartedAt > previous.sortStartedAt
|
|
550
|
+
|| (row.sortStartedAt === previous.sortStartedAt && row.id > previous.id))
|
|
551
|
+
latest.set(row.agentId, row);
|
|
552
|
+
}
|
|
553
|
+
return rows.filter(row => row.providerId !== "subagents" || !row.agentId || latest.get(row.agentId) === row);
|
|
554
|
+
}
|
|
555
|
+
/** Two levels only: agents are peers, tasks attach by captured conversation. */
|
|
556
|
+
export function treeRows(rows) {
|
|
557
|
+
const agents = new Map();
|
|
558
|
+
for (const row of rows.filter(row => row.providerId === "subagents")) {
|
|
559
|
+
const key = row.agentId ?? row.id;
|
|
560
|
+
const prior = agents.get(key);
|
|
561
|
+
if (!prior || row.sortStartedAt > prior.sortStartedAt)
|
|
562
|
+
agents.set(key, row);
|
|
563
|
+
}
|
|
564
|
+
const tasks = rows.filter(row => row.providerId !== "subagents");
|
|
565
|
+
const ordered = [...agents.entries()].sort(([a], [b]) => a === "main" ? -1 : b === "main" ? 1 : 0);
|
|
566
|
+
const result = [], attached = new Set();
|
|
567
|
+
for (const [key, agent] of ordered) {
|
|
568
|
+
const children = tasks.filter(row => (row.parentAgentId ?? "main") === key);
|
|
569
|
+
result.push({ ...agent, treeDepth: 0 });
|
|
570
|
+
children.forEach((row, i) => { result.push({ ...row, treeDepth: 1, lastChild: i === children.length - 1 }); attached.add(row); });
|
|
571
|
+
}
|
|
572
|
+
// Never hide live work when its owner's observation has not arrived yet.
|
|
573
|
+
const missing = new Map();
|
|
574
|
+
for (const row of tasks)
|
|
575
|
+
if (!attached.has(row)) {
|
|
576
|
+
const key = row.parentAgentId ?? "main";
|
|
577
|
+
missing.set(key, [...(missing.get(key) ?? []), row]);
|
|
578
|
+
}
|
|
579
|
+
for (const [key, children] of missing)
|
|
580
|
+
children.forEach((row, i) => result.push({ ...row,
|
|
581
|
+
treeDepth: 1, lastChild: i === children.length - 1,
|
|
582
|
+
ownerGroupLabel: i === 0 ? (key === "main" ? "Main" : `Agent ${key} · not running`) : undefined }));
|
|
583
|
+
return result;
|
|
416
584
|
}
|
|
417
585
|
function rowDisplayName(row) {
|
|
418
586
|
return singleLine(row.name || row.id);
|
|
@@ -476,6 +644,17 @@ function buildMainListLayout(rows, width, truncate, fg, options = {}) {
|
|
|
476
644
|
lines.push(line);
|
|
477
645
|
owners.push(owner);
|
|
478
646
|
};
|
|
647
|
+
if (getNavigatorView() === "tree") {
|
|
648
|
+
push(providerGroupLabel("work", fg));
|
|
649
|
+
for (const row of rows) {
|
|
650
|
+
if (row.ownerGroupLabel)
|
|
651
|
+
push(` ${dim(row.ownerGroupLabel, fg)}`);
|
|
652
|
+
push(formatMainListRow(row, options.focused === true && row.navigatorId === options.selectedId, fg, width), row.navigatorId);
|
|
653
|
+
}
|
|
654
|
+
push("");
|
|
655
|
+
push(shortcutsLine(options.focused === true, fg));
|
|
656
|
+
return { lines: lines.map(line => safeTruncate(line, width, truncate)), owners };
|
|
657
|
+
}
|
|
479
658
|
const grouped = new Map();
|
|
480
659
|
for (const row of rows) {
|
|
481
660
|
const existing = grouped.get(row.providerLabel) ?? [];
|
|
@@ -502,8 +681,9 @@ function buildMainListLayout(rows, width, truncate, fg, options = {}) {
|
|
|
502
681
|
return { lines: lines.map((line) => safeTruncate(line, width, truncate)), owners };
|
|
503
682
|
}
|
|
504
683
|
function shortcutsLine(focused, fg) {
|
|
684
|
+
const selected = state().mainListRows?.find(row => row.navigatorId === state().mainListSelectedId);
|
|
505
685
|
const keys = focused
|
|
506
|
-
?
|
|
686
|
+
? `↑↓ switch · Enter detail${selected?.readOnly || selected?.parentRow ? "" : " · x stop"} · Esc unfocus`
|
|
507
687
|
: "← work navigator";
|
|
508
688
|
return dim(keys, fg);
|
|
509
689
|
}
|
|
@@ -512,22 +692,22 @@ function providerGroupLabel(label, fg) {
|
|
|
512
692
|
return fg("warning", normalized);
|
|
513
693
|
}
|
|
514
694
|
function formatMainListRow(row, selected, fg, width) {
|
|
515
|
-
const prefix = selected ? fg("accent", "› ") : " ";
|
|
695
|
+
const prefix = (selected ? fg("accent", "› ") : " ") + (row.treeDepth === 1 ? dim(` ${row.lastChild ? "└─" : "├─"} `, fg) : "");
|
|
516
696
|
const name = row.name || row.id;
|
|
517
697
|
const indicator = statusIndicator(row);
|
|
518
698
|
const status = fg(indicator.color, indicator.glyph);
|
|
519
699
|
const elapsed = singleLine(row.elapsed || "-");
|
|
520
700
|
const available = Math.max(24, width || MAIN_LIST_FALLBACK_WIDTH);
|
|
521
|
-
const elapsedWidth = Math.min(Math.max(
|
|
701
|
+
const elapsedWidth = Math.min(Math.max(piVisibleWidth(elapsed), 4), 12);
|
|
522
702
|
const statusWidth = 2;
|
|
523
|
-
const leftPrefixWidth =
|
|
703
|
+
const leftPrefixWidth = piVisibleWidth(prefix) + statusWidth + 1;
|
|
524
704
|
const maxNameWidth = Math.max(8, Math.floor(available * 0.36));
|
|
525
705
|
const nameWidth = Math.max(8, Math.min(44, maxNameWidth, available - leftPrefixWidth - elapsedWidth - 10));
|
|
526
706
|
const rightWidth = Math.max(8, available - leftPrefixWidth - nameWidth - 1);
|
|
527
707
|
const summaryWidth = Math.max(1, rightWidth - elapsedWidth - 1);
|
|
528
708
|
const left = `${prefix}${fit(status, statusWidth)} ${fit(name, nameWidth)}`;
|
|
529
709
|
const right = `${dim(fitRight(rowSummary(row), summaryWidth), fg)} ${fitRight(elapsed, elapsedWidth)}`;
|
|
530
|
-
const gap = Math.max(1, available -
|
|
710
|
+
const gap = Math.max(1, available - piVisibleWidth(left) - piVisibleWidth(right));
|
|
531
711
|
return `${left}${" ".repeat(gap)}${right}`;
|
|
532
712
|
}
|
|
533
713
|
function statusGlyph(row) {
|
|
@@ -545,16 +725,20 @@ function statusIndicator(row, now = Date.now()) {
|
|
|
545
725
|
void now;
|
|
546
726
|
if (row.statusTone !== "running")
|
|
547
727
|
return { glyph: statusGlyph(row), color: toneColor(row.statusTone, row.status) };
|
|
548
|
-
|
|
728
|
+
const glyph = row.treeDepth === 1 && row.providerId === "background-tasks" ? ">_" : RUNNING_DOT_GLYPH;
|
|
729
|
+
return { glyph, color: "accent" };
|
|
549
730
|
}
|
|
550
731
|
function mainListSignature(rows, options = {}) {
|
|
551
732
|
return JSON.stringify({
|
|
733
|
+
view: getNavigatorView(),
|
|
552
734
|
focused: options.focused === true,
|
|
553
735
|
closeHint: options.closeHint ?? null,
|
|
554
736
|
selectedId: options.focused === true ? options.selectedId ?? null : null,
|
|
555
737
|
rows: rows.map((row) => ({
|
|
556
738
|
navigatorId: row.navigatorId,
|
|
557
739
|
providerLabel: row.providerLabel,
|
|
740
|
+
parentAgentId: row.parentAgentId,
|
|
741
|
+
agentId: row.agentId,
|
|
558
742
|
parentRow: row.parentRow === true,
|
|
559
743
|
providerId: row.providerId,
|
|
560
744
|
id: row.id,
|
|
@@ -578,6 +762,9 @@ function stableFacts(facts) {
|
|
|
578
762
|
return (facts ?? []).filter((fact) => !/\bleft$/.test(singleLine(fact)));
|
|
579
763
|
}
|
|
580
764
|
function rowSummary(row) {
|
|
765
|
+
if (getNavigatorView() === "tree" && row.providerId === "background-tasks") {
|
|
766
|
+
return [singleLine(row.status).replaceAll("_", " "), ...(row.facts ?? []).map(singleLine)].join(" · ");
|
|
767
|
+
}
|
|
581
768
|
if (row.providerId === "subagents") {
|
|
582
769
|
const attention = row.facts?.map(singleLine).filter(Boolean);
|
|
583
770
|
if (attention?.length)
|
|
@@ -622,16 +809,16 @@ function rowSummary(row) {
|
|
|
622
809
|
}
|
|
623
810
|
function fit(value, width) {
|
|
624
811
|
const str = singleLine(value);
|
|
625
|
-
const visible =
|
|
626
|
-
if (visible
|
|
627
|
-
return
|
|
812
|
+
const visible = piVisibleWidth(str);
|
|
813
|
+
if (visible > width)
|
|
814
|
+
return piTruncateToWidth(str, width);
|
|
628
815
|
return str + " ".repeat(width - visible);
|
|
629
816
|
}
|
|
630
817
|
function fitRight(value, width) {
|
|
631
818
|
const str = singleLine(value);
|
|
632
|
-
const visible =
|
|
633
|
-
if (visible
|
|
634
|
-
return
|
|
819
|
+
const visible = piVisibleWidth(str);
|
|
820
|
+
if (visible > width)
|
|
821
|
+
return piTruncateToWidth(str, width);
|
|
635
822
|
return " ".repeat(width - visible) + str;
|
|
636
823
|
}
|
|
637
824
|
function singleLine(value) {
|
|
@@ -646,6 +833,9 @@ function prepareDetail(navigatorId, options) {
|
|
|
646
833
|
}
|
|
647
834
|
function detailFor(navigatorId, now = Date.now(), options) {
|
|
648
835
|
const { providerId, id } = splitRowKey(navigatorId);
|
|
836
|
+
const failed = state().launchFailures?.get(navigatorId);
|
|
837
|
+
if (failed)
|
|
838
|
+
return { providerId, id, title: failed.name ?? "Launch failed", status: "failed", statusTone: "failed", metadata: [], evidence: { label: "Launch error", text: failed.primary } };
|
|
649
839
|
const provider = state().providers.get(providerId);
|
|
650
840
|
if (!provider)
|
|
651
841
|
return null;
|
|
@@ -657,20 +847,29 @@ function detailFor(navigatorId, now = Date.now(), options) {
|
|
|
657
847
|
}
|
|
658
848
|
}
|
|
659
849
|
function closeFor(row) {
|
|
660
|
-
if (row.parentRow)
|
|
850
|
+
if (row.parentRow || row.readOnly)
|
|
661
851
|
return { action: "not-closable", providerId: row.providerId, id: row.id };
|
|
662
852
|
const provider = state().providers.get(row.providerId);
|
|
853
|
+
if (state().launchFailures?.delete(row.navigatorId)) {
|
|
854
|
+
state().terminalRows?.get(row.providerId)?.dismiss(row.id);
|
|
855
|
+
return { action: "dismissed", providerId: row.providerId, id: row.id };
|
|
856
|
+
}
|
|
663
857
|
if (!provider)
|
|
664
858
|
return { action: "missing", providerId: row.providerId, id: row.id };
|
|
665
859
|
try {
|
|
666
|
-
|
|
860
|
+
const outcome = provider.close(row.id);
|
|
861
|
+
if (["dismissed", "stopped-and-dismissed"].includes(outcome.action)
|
|
862
|
+
|| outcome.action === "requested" && ["completed", "succeeded", "failed", "cancelled", "killed", "lost", "timed_out"].includes(row.status)) {
|
|
863
|
+
state().terminalRows?.get(row.providerId)?.dismiss(row.id);
|
|
864
|
+
}
|
|
865
|
+
return outcome;
|
|
667
866
|
}
|
|
668
867
|
catch {
|
|
669
868
|
return { action: "missing", providerId: row.providerId, id: row.id };
|
|
670
869
|
}
|
|
671
870
|
}
|
|
672
871
|
function closeHintFor(row) {
|
|
673
|
-
if (!row || row.parentRow)
|
|
872
|
+
if (!row || row.parentRow || row.readOnly)
|
|
674
873
|
return null;
|
|
675
874
|
const provider = state().providers.get(row.providerId);
|
|
676
875
|
if (!provider)
|
|
@@ -702,29 +901,49 @@ function installNavigatorEditor(ui, deps) {
|
|
|
702
901
|
function wrapEditor(inner, deps) {
|
|
703
902
|
if (inner && typeof inner.render === "function")
|
|
704
903
|
state().editorComponent = inner;
|
|
904
|
+
const methods = new Map();
|
|
905
|
+
const replacements = new Map();
|
|
705
906
|
const proxy = new Proxy(inner, {
|
|
706
907
|
get(target, prop) {
|
|
908
|
+
const value = Reflect.get(target, prop);
|
|
909
|
+
if (typeof value !== "function" || replacements.get(prop) === value)
|
|
910
|
+
return value;
|
|
911
|
+
const cached = methods.get(prop);
|
|
912
|
+
if (cached && cached.original === value)
|
|
913
|
+
return cached.exposed;
|
|
914
|
+
// Capture the method before another editor decorator replaces it.
|
|
915
|
+
// A decorator can retain this wrapper and call it as its delegate.
|
|
916
|
+
let exposed = value.bind(target);
|
|
707
917
|
if (prop === "handleInput") {
|
|
708
|
-
|
|
918
|
+
exposed = (data) => {
|
|
709
919
|
if (target.getText?.() === "" && handleMainListInput(data, deps)) {
|
|
710
920
|
return;
|
|
711
921
|
}
|
|
712
|
-
|
|
922
|
+
value.call(target, data);
|
|
713
923
|
};
|
|
714
924
|
}
|
|
715
|
-
if (prop === "render"
|
|
716
|
-
|
|
925
|
+
if (prop === "render") {
|
|
926
|
+
exposed = (...args) => {
|
|
717
927
|
const s = state();
|
|
718
928
|
if (s.editorFocusTarget === proxy)
|
|
719
929
|
s.editorRenders = (s.editorRenders ?? 0) + 1;
|
|
720
|
-
return
|
|
930
|
+
return value.apply(target, args);
|
|
721
931
|
};
|
|
722
932
|
}
|
|
723
|
-
|
|
724
|
-
return
|
|
933
|
+
methods.set(prop, { original: value, exposed });
|
|
934
|
+
return exposed;
|
|
725
935
|
},
|
|
726
936
|
set(target, prop, value) {
|
|
727
|
-
|
|
937
|
+
const cached = methods.get(prop);
|
|
938
|
+
const restoring = cached !== undefined && value === cached.exposed;
|
|
939
|
+
if (!Reflect.set(target, prop, restoring ? cached.original : value))
|
|
940
|
+
return false;
|
|
941
|
+
// Preserve replacement identity so the installing decorator can undo it.
|
|
942
|
+
if (!restoring && typeof value === "function")
|
|
943
|
+
replacements.set(prop, value);
|
|
944
|
+
else
|
|
945
|
+
replacements.delete(prop);
|
|
946
|
+
return true;
|
|
728
947
|
},
|
|
729
948
|
});
|
|
730
949
|
// Pi mounts and focuses whatever the factory returns; an extension that
|
|
@@ -734,6 +953,10 @@ function wrapEditor(inner, deps) {
|
|
|
734
953
|
}
|
|
735
954
|
function handleMainListInput(data, deps) {
|
|
736
955
|
const s = state();
|
|
956
|
+
if (!s.mainListFocused && deps.isOpenTrigger(data)) {
|
|
957
|
+
for (const provider of s.providers.values())
|
|
958
|
+
provider.onOpen?.();
|
|
959
|
+
}
|
|
737
960
|
const rows = listRows();
|
|
738
961
|
if (rows.length === 0) {
|
|
739
962
|
// Every row is gone, but an overlay that lost focus may still be mounted: Esc still closes it.
|
|
@@ -813,7 +1036,7 @@ function dismissOverlay() {
|
|
|
813
1036
|
}
|
|
814
1037
|
function handleMainListCloseKey() {
|
|
815
1038
|
const row = selectedMainListRow();
|
|
816
|
-
if (!row || row.parentRow)
|
|
1039
|
+
if (!row || row.parentRow || row.readOnly)
|
|
817
1040
|
return;
|
|
818
1041
|
const s = state();
|
|
819
1042
|
const now = Date.now();
|
|
@@ -855,6 +1078,8 @@ function openNavigator() {
|
|
|
855
1078
|
const deps = s.deps;
|
|
856
1079
|
if (!ctx || !deps || !isNavigatorUiAvailable(ctx))
|
|
857
1080
|
return;
|
|
1081
|
+
for (const provider of s.providers.values())
|
|
1082
|
+
provider.onOpen?.();
|
|
858
1083
|
const rows = listRows();
|
|
859
1084
|
if (rows.length === 0)
|
|
860
1085
|
return;
|
|
@@ -932,6 +1157,8 @@ function openNavigator() {
|
|
|
932
1157
|
catch { /* keep foreground usable */ }
|
|
933
1158
|
}
|
|
934
1159
|
function createOverlayComponent(initialRows, deps, tui, theme, done, onClosed, initialDetailId) {
|
|
1160
|
+
let editorRendersSeen = state().editorRenders ?? 0;
|
|
1161
|
+
let sawLiveEditor = liveEditorMounted(tui) === true;
|
|
935
1162
|
// The overlay only ever shows one row's detail; the rail below it is the list.
|
|
936
1163
|
const overlayState = { rows: initialRows, selected: 0 };
|
|
937
1164
|
let logTailRows = DEFAULT_LOG_TAIL_ROWS;
|
|
@@ -1056,7 +1283,7 @@ function createOverlayComponent(initialRows, deps, tui, theme, done, onClosed, i
|
|
|
1056
1283
|
}
|
|
1057
1284
|
function handleCloseKey() {
|
|
1058
1285
|
const row = selectedRow();
|
|
1059
|
-
if (!row || row.parentRow)
|
|
1286
|
+
if (!row || row.parentRow || row.readOnly)
|
|
1060
1287
|
return;
|
|
1061
1288
|
const now = Date.now();
|
|
1062
1289
|
if (closeArm?.id === row.navigatorId && now >= closeArm.armedAt && now < closeArm.armedAt + CLOSE_ARM_MS) {
|
|
@@ -1091,19 +1318,24 @@ function createOverlayComponent(initialRows, deps, tui, theme, done, onClosed, i
|
|
|
1091
1318
|
closeArmTimer.unref?.();
|
|
1092
1319
|
requestRender();
|
|
1093
1320
|
}
|
|
1094
|
-
let editorRendersSeen;
|
|
1095
1321
|
/**
|
|
1096
|
-
*
|
|
1097
|
-
*
|
|
1098
|
-
*
|
|
1099
|
-
* rendered since the previous overlay frame (Pi renders the editor before it composites overlays).
|
|
1322
|
+
* Close when a replacement editor takes over while the sheet is open (#332).
|
|
1323
|
+
* A wrapper inside another extension's editor still counts as live if it rendered since
|
|
1324
|
+
* the last overlay frame. Pi renders the editor before it composites overlays.
|
|
1100
1325
|
*/
|
|
1101
1326
|
function closeIfEditorReplaced() {
|
|
1102
|
-
const rendersBefore = editorRendersSeen;
|
|
1103
1327
|
const renders = state().editorRenders ?? 0;
|
|
1328
|
+
const rendered = renders !== editorRendersSeen;
|
|
1104
1329
|
editorRendersSeen = renders;
|
|
1105
|
-
state().editorRenderedLastFrame =
|
|
1106
|
-
if (closed
|
|
1330
|
+
state().editorRenderedLastFrame = rendered;
|
|
1331
|
+
if (closed)
|
|
1332
|
+
return;
|
|
1333
|
+
const mounted = liveEditorMounted(tui);
|
|
1334
|
+
if (rendered || mounted === true) {
|
|
1335
|
+
sawLiveEditor = true;
|
|
1336
|
+
return;
|
|
1337
|
+
}
|
|
1338
|
+
if (mounted !== false || !sawLiveEditor)
|
|
1107
1339
|
return;
|
|
1108
1340
|
// Not from inside pi-tui's render pass: hiding an overlay there would change the stack it is drawing.
|
|
1109
1341
|
queueMicrotask(() => {
|
|
@@ -1634,10 +1866,10 @@ function fill(glyph, label, width) {
|
|
|
1634
1866
|
return prefix + glyph.repeat(w - visibleWidth(prefix));
|
|
1635
1867
|
}
|
|
1636
1868
|
function safeTruncate(line, width, truncate) {
|
|
1637
|
-
if (
|
|
1869
|
+
if (piVisibleWidth(line) <= width)
|
|
1638
1870
|
return line;
|
|
1639
1871
|
const cut = truncate(line, width);
|
|
1640
|
-
return
|
|
1872
|
+
return piVisibleWidth(cut) > width ? piTruncateToWidth(cut, width) : cut;
|
|
1641
1873
|
}
|
|
1642
1874
|
const ANSI_RE = new RegExp("[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:[a-zA-Z\\d]*(?:;[a-zA-Z\\d]*)*)?\\u0007)|(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-ntqry=><~]))", "g");
|
|
1643
1875
|
const FORMATTING_PREFIX_RE = new RegExp(`^(?:${ANSI_RE.source}|<\\/?[a-zA-Z][\\w-]*>|</>)`);
|