pi-better-server 0.4.0 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +8 -1
- package/scripts/copy-pi-test-providers.mjs +10 -0
- package/scripts/event-publication/README.md +26 -0
- package/scripts/event-publication/commit.mjs +21 -0
- package/scripts/event-publication/measure.mjs +87 -0
- package/scripts/event-publication/writer.mjs +6 -0
- package/scripts/measure-full-runtime/frontend.ts +24 -0
- package/scripts/measure-full-runtime/hosted-extension.ts +28 -0
- package/scripts/measure-full-runtime/probe.mjs +29 -0
- package/scripts/measure-full-runtime/recovery-trace-loader.mjs +51 -0
- package/scripts/measure-full-runtime/recovery-trace.mjs +16 -0
- package/scripts/measure-full-runtime.mjs +146 -0
- package/scripts/measure-shared-reads/probe.mjs +26 -2
- package/scripts/measure-shared-reads.mjs +44 -9
- package/scripts/private-runtime/package-lock.json +66 -4
- package/scripts/private-runtime/package.json +10 -2
- package/scripts/source-provenance.mjs +31 -0
- package/scripts/test-on-pi.sh +3 -9
- package/src/handshake.ts +1 -1
- package/src/hosted-session.ts +32 -4
- package/src/maintenance.ts +35 -7
- package/src/registry.ts +28 -4
- package/src/runtime/attempt-invalidation.ts +54 -0
- package/src/runtime/background-history.ts +151 -45
- package/src/runtime/background-policy.ts +27 -0
- package/src/runtime/background-tools.ts +389 -0
- package/src/runtime/background.ts +410 -48
- package/src/runtime/cancellation.ts +28 -7
- package/src/runtime/catalog-sources.ts +199 -0
- package/src/runtime/catalog.ts +53 -21
- package/src/runtime/client.ts +22 -2
- package/src/runtime/domain/assignment-inbox.mjs +119 -0
- package/src/runtime/domain/assignment-observation.d.mts +1 -1
- package/src/runtime/domain/assignment-observation.mjs +71 -33
- package/src/runtime/domain/background/process-identity.mjs +20 -2
- package/src/runtime/domain/background/process.mjs +3 -3
- package/src/runtime/domain/background/registry.mjs +89 -4
- package/src/runtime/domain/background/types.mjs +1 -0
- package/src/runtime/domain/background-service/adapter-contract.domain.mjs +83 -0
- package/src/runtime/domain/background-service/adapter-contract.ts +70 -0
- package/src/runtime/domain/background-service/batch.domain.mjs +91 -0
- package/src/runtime/domain/background-service/batch.ts +111 -0
- package/src/runtime/domain/background-service/conditions.domain.mjs +94 -0
- package/src/runtime/domain/background-service/conditions.ts +99 -0
- package/src/runtime/domain/background-service/delivery-observer.domain.mjs +37 -0
- package/src/runtime/domain/background-service/delivery-observer.ts +42 -0
- package/src/runtime/domain/background-service/failures.domain.mjs +209 -0
- package/src/runtime/domain/background-service/failures.ts +212 -0
- package/src/runtime/domain/background-service/goal-provider.domain.mjs +193 -0
- package/src/runtime/domain/background-service/goal-provider.ts +209 -0
- package/src/runtime/domain/background-service/index.domain.mjs +54 -0
- package/src/runtime/domain/background-service/index.ts +55 -0
- package/src/runtime/domain/background-service/logs.domain.mjs +129 -0
- package/src/runtime/domain/background-service/logs.ts +134 -0
- package/src/runtime/domain/background-service/maintenance.domain.mjs +95 -0
- package/src/runtime/domain/background-service/maintenance.ts +98 -0
- package/src/runtime/domain/background-service/managed-authority.domain.mjs +32 -0
- package/src/runtime/domain/background-service/managed-authority.ts +30 -0
- package/src/runtime/domain/background-service/managed-client.domain.mjs +79 -0
- package/src/runtime/domain/background-service/managed-client.ts +73 -0
- package/src/runtime/domain/background-service/managed-frontend.domain.mjs +225 -0
- package/src/runtime/domain/background-service/managed-frontend.ts +176 -0
- package/src/runtime/domain/background-service/navigator-provider.domain.mjs +492 -0
- package/src/runtime/domain/background-service/navigator-provider.ts +485 -0
- package/src/runtime/domain/background-service/observed-wait-client.domain.mjs +6 -0
- package/src/runtime/domain/background-service/observed-wait-client.ts +10 -0
- package/src/runtime/domain/background-service/observed-waits.domain.mjs +4080 -0
- package/src/runtime/domain/background-service/observed-waits.ts +4513 -0
- package/src/runtime/domain/background-service/output.domain.mjs +867 -0
- package/src/runtime/domain/background-service/output.ts +952 -0
- package/src/runtime/domain/background-service/process-identity.domain.mjs +129 -0
- package/src/runtime/domain/background-service/process-identity.ts +134 -0
- package/src/runtime/domain/background-service/process.domain.mjs +512 -0
- package/src/runtime/domain/background-service/process.ts +532 -0
- package/src/runtime/domain/background-service/prompt.domain.mjs +58 -0
- package/src/runtime/domain/background-service/prompt.ts +72 -0
- package/src/runtime/domain/background-service/registry.domain.mjs +460 -0
- package/src/runtime/domain/background-service/registry.ts +450 -0
- package/src/runtime/domain/background-service/remote-task-preset.domain.mjs +67 -0
- package/src/runtime/domain/background-service/remote-task-preset.ts +127 -0
- package/src/runtime/domain/background-service/runtime.domain.mjs +1511 -0
- package/src/runtime/domain/background-service/runtime.ts +1636 -0
- package/src/runtime/domain/background-service/sandbox.domain.mjs +735 -0
- package/src/runtime/domain/background-service/sandbox.ts +913 -0
- package/src/runtime/domain/background-service/shared-callback-batcher.domain.mjs +777 -0
- package/src/runtime/domain/background-service/shared-callback-batcher.ts +956 -0
- package/src/runtime/domain/background-service/shared-execution-policy.domain.mjs +50 -0
- package/src/runtime/domain/background-service/shared-execution-policy.ts +61 -0
- package/src/runtime/domain/background-service/shared-failure-observations.domain.mjs +1078 -0
- package/src/runtime/domain/background-service/shared-failure-observations.ts +1166 -0
- package/src/runtime/domain/background-service/shared-harness-settings.domain.mjs +126 -0
- package/src/runtime/domain/background-service/shared-harness-settings.ts +116 -0
- package/src/runtime/domain/background-service/shared-log-utils.domain.mjs +1223 -0
- package/src/runtime/domain/background-service/shared-log-utils.ts +1492 -0
- package/src/runtime/domain/background-service/shared-navigator-panels.domain.mjs +289 -0
- package/src/runtime/domain/background-service/shared-navigator-panels.ts +272 -0
- package/src/runtime/domain/background-service/shared-navigator.domain.mjs +1930 -0
- package/src/runtime/domain/background-service/shared-navigator.ts +1962 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/assignment-inbox.mjs +144 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/assignment-observation.mjs +189 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/index.domain.mjs +51 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/index.ts +122 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/assignment-changes.domain.mjs +75 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/assignment-changes.ts +73 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/assignment-outcomes.domain.mjs +163 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/assignment-outcomes.ts +174 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/background-parent-callbacks.domain.mjs +66 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/background-parent-callbacks.ts +68 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/background-requests.domain.mjs +87 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/background-requests.ts +90 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/discovery.domain.mjs +97 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/discovery.ts +139 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/errors.domain.mjs +12 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/errors.ts +79 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/operations.domain.mjs +342 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/operations.ts +513 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/outbox.domain.mjs +283 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/outbox.ts +458 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/recovery.domain.mjs +52 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/recovery.ts +55 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/result-supervision.domain.mjs +114 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/result-supervision.ts +140 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/rows.domain.mjs +280 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/rows.ts +442 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/schema.domain.mjs +420 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/schema.ts +441 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/sqlite.domain.mjs +194 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/sqlite.ts +239 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/store.domain.mjs +275 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/store.ts +585 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/subagent-launch.domain.mjs +120 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/subagent-launch.ts +142 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/task-cancellation.domain.mjs +188 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/task-cancellation.ts +224 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/types.domain.mjs +25 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/types.ts +707 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/upgrade.domain.mjs +22 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/upgrade.ts +22 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/validate.domain.mjs +234 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/validate.ts +241 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/waits.domain.mjs +851 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/waits.ts +1424 -0
- package/src/runtime/domain/background-service/shared-permission-blocker.domain.mjs +40 -0
- package/src/runtime/domain/background-service/shared-permission-blocker.ts +48 -0
- package/src/runtime/domain/background-service/shared-render-scheduler.domain.mjs +41 -0
- package/src/runtime/domain/background-service/shared-render-scheduler.ts +47 -0
- package/src/runtime/domain/background-service/shared-sandbox-core.domain.mjs +1531 -0
- package/src/runtime/domain/background-service/shared-sandbox-core.ts +1757 -0
- package/src/runtime/domain/background-service/shared-sandbox-diagnostics.domain.mjs +591 -0
- package/src/runtime/domain/background-service/shared-sandbox-diagnostics.ts +491 -0
- package/src/runtime/domain/background-service/shared-ssh-core/index.domain.mjs +698 -0
- package/src/runtime/domain/background-service/shared-ssh-core/index.ts +979 -0
- package/src/runtime/domain/background-service/shared-stall-detector.domain.mjs +37 -0
- package/src/runtime/domain/background-service/shared-stall-detector.ts +69 -0
- package/src/runtime/domain/background-service/shared-work-client.mjs +303 -0
- package/src/runtime/domain/background-service/stall-attention.domain.mjs +29 -0
- package/src/runtime/domain/background-service/stall-attention.ts +31 -0
- package/src/runtime/domain/background-service/stall.domain.mjs +57 -0
- package/src/runtime/domain/background-service/stall.ts +57 -0
- package/src/runtime/domain/background-service/supervisor/README.md +111 -0
- package/src/runtime/domain/background-service/supervisor/emit-runner.mjs +90 -0
- package/src/runtime/domain/background-service/supervisor/generated/conditions.mjs +96 -0
- package/src/runtime/domain/background-service/supervisor/generated/identity.mjs +95 -0
- package/src/runtime/domain/background-service/supervisor/generated/process-identity.mjs +131 -0
- package/src/runtime/domain/background-service/supervisor/generated/process.mjs +514 -0
- package/src/runtime/domain/background-service/supervisor/generated/runner.mjs +872 -0
- package/src/runtime/domain/background-service/supervisor/generated/store.mjs +609 -0
- package/src/runtime/domain/background-service/supervisor/generated/types.mjs +50 -0
- package/src/runtime/domain/background-service/supervisor/identity.domain.mjs +93 -0
- package/src/runtime/domain/background-service/supervisor/identity.ts +99 -0
- package/src/runtime/domain/background-service/supervisor/index.domain.mjs +22 -0
- package/src/runtime/domain/background-service/supervisor/index.ts +37 -0
- package/src/runtime/domain/background-service/supervisor/invocation.domain.mjs +30 -0
- package/src/runtime/domain/background-service/supervisor/invocation.ts +44 -0
- package/src/runtime/domain/background-service/supervisor/runner.domain.mjs +870 -0
- package/src/runtime/domain/background-service/supervisor/runner.ts +982 -0
- package/src/runtime/domain/background-service/supervisor/store.domain.mjs +605 -0
- package/src/runtime/domain/background-service/supervisor/store.ts +651 -0
- package/src/runtime/domain/background-service/supervisor/supervisor.domain.mjs +721 -0
- package/src/runtime/domain/background-service/supervisor/supervisor.ts +804 -0
- package/src/runtime/domain/background-service/supervisor/types.domain.mjs +48 -0
- package/src/runtime/domain/background-service/supervisor/types.ts +394 -0
- package/src/runtime/domain/background-service/task-diagnostics.domain.mjs +60 -0
- package/src/runtime/domain/background-service/task-diagnostics.ts +71 -0
- package/src/runtime/domain/background-service/tools.domain.mjs +1050 -0
- package/src/runtime/domain/background-service/tools.ts +1142 -0
- package/src/runtime/domain/background-service/types.domain.mjs +5 -0
- package/src/runtime/domain/background-service/types.ts +236 -0
- package/src/runtime/domain/background-service/work-observation.domain.mjs +176 -0
- package/src/runtime/domain/background-service/work-observation.ts +144 -0
- package/src/runtime/domain/catalog/catalog-store.d.mts +9 -1
- package/src/runtime/domain/catalog/catalog-store.mjs +20 -22
- package/src/runtime/domain/coordinator/src/assignment-changes.mjs +75 -0
- package/src/runtime/domain/coordinator/src/assignment-outcomes.mjs +2 -0
- package/src/runtime/domain/coordinator/src/background-parent-callbacks.mjs +65 -0
- package/src/runtime/domain/coordinator/src/background-requests.mjs +86 -0
- package/src/runtime/domain/coordinator/src/discovery.mjs +4 -2
- package/src/runtime/domain/coordinator/src/operations.mjs +44 -4
- package/src/runtime/domain/coordinator/src/result-supervision.mjs +12 -0
- package/src/runtime/domain/coordinator/src/rows.mjs +2 -0
- package/src/runtime/domain/coordinator/src/schema.mjs +73 -21
- package/src/runtime/domain/coordinator/src/store.mjs +32 -3
- package/src/runtime/domain/coordinator/src/subagent-launch.mjs +119 -0
- package/src/runtime/domain/coordinator/src/types.mjs +1 -1
- package/src/runtime/domain/coordinator/src/upgrade.mjs +22 -0
- package/src/runtime/domain/health-observation.d.mts +3 -1
- package/src/runtime/domain/health-observation.mjs +189 -190
- package/src/runtime/domain/log-cursor.d.mts +2 -0
- package/src/runtime/domain/log-cursor.mjs +85 -16
- package/src/runtime/domain/parse.d.mts +4 -1
- package/src/runtime/domain/parse.mjs +50 -5
- package/src/runtime/domain/sandbox-policy/README.md +633 -0
- package/src/runtime/domain/sandbox-policy/background-admission.domain.mjs +83 -0
- package/src/runtime/domain/sandbox-policy/background-admission.ts +75 -0
- package/src/runtime/domain/sandbox-policy/commands.domain.mjs +245 -0
- package/src/runtime/domain/sandbox-policy/commands.ts +336 -0
- package/src/runtime/domain/sandbox-policy/deny-rules.domain.mjs +440 -0
- package/src/runtime/domain/sandbox-policy/deny-rules.ts +620 -0
- package/src/runtime/domain/sandbox-policy/diagnostics-command.domain.mjs +30 -0
- package/src/runtime/domain/sandbox-policy/diagnostics-command.ts +27 -0
- package/src/runtime/domain/sandbox-policy/events.domain.mjs +49 -0
- package/src/runtime/domain/sandbox-policy/events.ts +85 -0
- package/src/runtime/domain/sandbox-policy/files.domain.mjs +153 -0
- package/src/runtime/domain/sandbox-policy/files.ts +224 -0
- package/src/runtime/domain/sandbox-policy/index.domain.mjs +289 -0
- package/src/runtime/domain/sandbox-policy/index.ts +386 -0
- package/src/runtime/domain/sandbox-policy/package.json +66 -0
- package/src/runtime/domain/sandbox-policy/permission-settings.domain.mjs +36 -0
- package/src/runtime/domain/sandbox-policy/permission-settings.ts +46 -0
- package/src/runtime/domain/sandbox-policy/permissions-page.domain.mjs +309 -0
- package/src/runtime/domain/sandbox-policy/permissions-page.ts +295 -0
- package/src/runtime/domain/sandbox-policy/permissions.domain.mjs +98 -0
- package/src/runtime/domain/sandbox-policy/permissions.ts +125 -0
- package/src/runtime/domain/sandbox-policy/policy.domain.mjs +80 -0
- package/src/runtime/domain/sandbox-policy/policy.ts +102 -0
- package/src/runtime/domain/sandbox-policy/preferences.domain.mjs +55 -0
- package/src/runtime/domain/sandbox-policy/preferences.ts +82 -0
- package/src/runtime/domain/sandbox-policy/rules-page.domain.mjs +138 -0
- package/src/runtime/domain/sandbox-policy/rules-page.ts +176 -0
- package/src/runtime/domain/sandbox-policy/session-permissions.domain.mjs +22 -0
- package/src/runtime/domain/sandbox-policy/session-permissions.ts +24 -0
- package/src/runtime/domain/sandbox-policy/shared-harness-settings.domain.mjs +126 -0
- package/src/runtime/domain/sandbox-policy/shared-harness-settings.ts +116 -0
- package/src/runtime/domain/sandbox-policy/shared-permission-blocker.domain.mjs +40 -0
- package/src/runtime/domain/sandbox-policy/shared-permission-blocker.ts +48 -0
- package/src/runtime/domain/sandbox-policy/shared-sandbox-core.domain.mjs +1531 -0
- package/src/runtime/domain/sandbox-policy/shared-sandbox-core.ts +1757 -0
- package/src/runtime/domain/sandbox-policy/shared-sandbox-diagnostics.domain.mjs +591 -0
- package/src/runtime/domain/sandbox-policy/shared-sandbox-diagnostics.ts +491 -0
- package/src/runtime/domain/sandbox-policy/shared-task-application.domain.mjs +185 -0
- package/src/runtime/domain/sandbox-policy/shared-task-application.ts +185 -0
- package/src/runtime/domain/sandbox-policy/shared-task-apply-patch.domain.mjs +416 -0
- package/src/runtime/domain/sandbox-policy/shared-task-apply-patch.ts +409 -0
- package/src/runtime/domain/sandbox-policy/shared-task-exec.domain.mjs +325 -0
- package/src/runtime/domain/sandbox-policy/shared-task-exec.ts +335 -0
- package/src/runtime/domain/sandbox-policy/shared-task-files.domain.mjs +346 -0
- package/src/runtime/domain/sandbox-policy/shared-task-files.ts +342 -0
- package/src/runtime/domain/sandbox-policy/shared-task-process-identity.domain.mjs +140 -0
- package/src/runtime/domain/sandbox-policy/shared-task-process-identity.ts +126 -0
- package/src/runtime/domain/sandbox-policy/shared-task-process-list.domain.mjs +220 -0
- package/src/runtime/domain/sandbox-policy/shared-task-process-list.ts +209 -0
- package/src/runtime/domain/sandbox-policy/shared-task-sandbox.domain.mjs +227 -0
- package/src/runtime/domain/sandbox-policy/shared-task-sandbox.ts +224 -0
- package/src/runtime/domain/sandbox-policy/shared-task-tools.domain.mjs +92 -0
- package/src/runtime/domain/sandbox-policy/shared-task-tools.ts +123 -0
- package/src/runtime/domain/sandbox-policy/shell.domain.mjs +93 -0
- package/src/runtime/domain/sandbox-policy/shell.ts +129 -0
- package/src/runtime/domain/sandbox-policy/state.domain.mjs +307 -0
- package/src/runtime/domain/sandbox-policy/state.ts +408 -0
- package/src/runtime/domain/sandbox-policy/status.domain.mjs +64 -0
- package/src/runtime/domain/sandbox-policy/status.ts +76 -0
- package/src/runtime/domain/sandbox-policy/subagent-admission.domain.mjs +69 -0
- package/src/runtime/domain/sandbox-policy/subagent-admission.ts +60 -0
- package/src/runtime/domain/subagents/CONTEXT.md +202 -0
- package/src/runtime/domain/subagents/PRODUCT.md +49 -0
- package/src/runtime/domain/subagents/README.md +201 -0
- package/src/runtime/domain/subagents/agent-catalog.mjs +64 -0
- package/src/runtime/domain/subagents/agent-commands.domain.mjs +822 -0
- package/src/runtime/domain/subagents/agent-commands.ts +905 -0
- package/src/runtime/domain/subagents/agent-inspection.domain.mjs +398 -0
- package/src/runtime/domain/subagents/agent-inspection.ts +574 -0
- package/src/runtime/domain/subagents/agent-operations.domain.mjs +40 -0
- package/src/runtime/domain/subagents/agent-operations.ts +61 -0
- package/src/runtime/domain/subagents/agent-session-settings.domain.mjs +112 -0
- package/src/runtime/domain/subagents/agent-session-settings.ts +118 -0
- package/src/runtime/domain/subagents/agents-catalog-tool.domain.mjs +84 -0
- package/src/runtime/domain/subagents/agents-catalog-tool.ts +118 -0
- package/src/runtime/domain/subagents/assignment-outcomes.domain.mjs +276 -0
- package/src/runtime/domain/subagents/assignment-outcomes.ts +212 -0
- package/src/runtime/domain/subagents/assignment-projection.mjs +261 -0
- package/src/runtime/domain/subagents/assignment-report.domain.mjs +174 -0
- package/src/runtime/domain/subagents/assignment-report.ts +156 -0
- package/src/runtime/domain/subagents/batch.mjs +275 -0
- package/src/runtime/domain/subagents/callback-fields.domain.mjs +72 -0
- package/src/runtime/domain/subagents/callback-fields.ts +95 -0
- package/src/runtime/domain/subagents/capacity.mjs +108 -0
- package/src/runtime/domain/subagents/catalog-editor.domain.mjs +98 -0
- package/src/runtime/domain/subagents/catalog-editor.ts +125 -0
- package/src/runtime/domain/subagents/catalog-host-admission.domain.mjs +104 -0
- package/src/runtime/domain/subagents/catalog-host-admission.ts +85 -0
- package/src/runtime/domain/subagents/catalog-identity.domain.mjs +222 -0
- package/src/runtime/domain/subagents/catalog-identity.ts +258 -0
- package/src/runtime/domain/subagents/catalog-overlay.domain.mjs +9 -0
- package/src/runtime/domain/subagents/catalog-overlay.ts +10 -0
- package/src/runtime/domain/subagents/catalog-preferences.domain.mjs +164 -0
- package/src/runtime/domain/subagents/catalog-preferences.ts +139 -0
- package/src/runtime/domain/subagents/catalog-resolver.domain.mjs +366 -0
- package/src/runtime/domain/subagents/catalog-resolver.ts +540 -0
- package/src/runtime/domain/subagents/catalog-runtime.domain.mjs +570 -0
- package/src/runtime/domain/subagents/catalog-runtime.ts +680 -0
- package/src/runtime/domain/subagents/catalog-schema.domain.mjs +1331 -0
- package/src/runtime/domain/subagents/catalog-schema.ts +1563 -0
- package/src/runtime/domain/subagents/catalog-skill-edits.domain.mjs +95 -0
- package/src/runtime/domain/subagents/catalog-skill-edits.ts +116 -0
- package/src/runtime/domain/subagents/catalog-store.domain.mjs +808 -0
- package/src/runtime/domain/subagents/catalog-store.ts +1006 -0
- package/src/runtime/domain/subagents/catalog-ui.domain.mjs +651 -0
- package/src/runtime/domain/subagents/catalog-ui.ts +611 -0
- package/src/runtime/domain/subagents/child-apply-patch.domain.mjs +13 -0
- package/src/runtime/domain/subagents/child-apply-patch.ts +13 -0
- package/src/runtime/domain/subagents/child-codemode.domain.mjs +16 -0
- package/src/runtime/domain/subagents/child-codemode.ts +17 -0
- package/src/runtime/domain/subagents/child-dependencies.mjs +193 -0
- package/src/runtime/domain/subagents/child-incidents.domain.mjs +170 -0
- package/src/runtime/domain/subagents/child-incidents.ts +169 -0
- package/src/runtime/domain/subagents/child-operations.domain.mjs +986 -0
- package/src/runtime/domain/subagents/child-operations.ts +1191 -0
- package/src/runtime/domain/subagents/child-ownership.domain.mjs +205 -0
- package/src/runtime/domain/subagents/child-ownership.ts +160 -0
- package/src/runtime/domain/subagents/child-preflight.mjs +38 -0
- package/src/runtime/domain/subagents/child-process-list.domain.mjs +7 -0
- package/src/runtime/domain/subagents/child-process-list.ts +8 -0
- package/src/runtime/domain/subagents/child-runtime.mjs +67 -0
- package/src/runtime/domain/subagents/child-steer.domain.mjs +109 -0
- package/src/runtime/domain/subagents/child-steer.ts +102 -0
- package/src/runtime/domain/subagents/cleanup.domain.mjs +818 -0
- package/src/runtime/domain/subagents/cleanup.ts +1017 -0
- package/src/runtime/domain/subagents/codex-import.domain.mjs +575 -0
- package/src/runtime/domain/subagents/codex-import.ts +717 -0
- package/src/runtime/domain/subagents/completion.domain.mjs +6 -0
- package/src/runtime/domain/subagents/completion.mjs +152 -0
- package/src/runtime/domain/subagents/completion.ts +11 -0
- package/src/runtime/domain/subagents/config.domain.mjs +248 -0
- package/src/runtime/domain/subagents/config.json +15 -0
- package/src/runtime/domain/subagents/config.ts +328 -0
- package/src/runtime/domain/subagents/continuation-authority.domain.mjs +38 -0
- package/src/runtime/domain/subagents/continuation-authority.ts +31 -0
- package/src/runtime/domain/subagents/continuation-runtime.domain.mjs +89 -0
- package/src/runtime/domain/subagents/continuation-runtime.ts +88 -0
- package/src/runtime/domain/subagents/continuation.domain.mjs +942 -0
- package/src/runtime/domain/subagents/continuation.ts +1051 -0
- package/src/runtime/domain/subagents/delegation.domain.mjs +19 -0
- package/src/runtime/domain/subagents/delegation.ts +24 -0
- package/src/runtime/domain/subagents/effective-settings.domain.mjs +130 -0
- package/src/runtime/domain/subagents/effective-settings.ts +184 -0
- package/src/runtime/domain/subagents/extensions.domain.mjs +6 -0
- package/src/runtime/domain/subagents/extensions.mjs +164 -0
- package/src/runtime/domain/subagents/extensions.ts +19 -0
- package/src/runtime/domain/subagents/failures.domain.mjs +362 -0
- package/src/runtime/domain/subagents/failures.ts +319 -0
- package/src/runtime/domain/subagents/finalization.domain.mjs +168 -0
- package/src/runtime/domain/subagents/finalization.ts +218 -0
- package/src/runtime/domain/subagents/git-remotes.domain.mjs +351 -0
- package/src/runtime/domain/subagents/git-remotes.ts +413 -0
- package/src/runtime/domain/subagents/git-workspace.domain.mjs +337 -0
- package/src/runtime/domain/subagents/git-workspace.ts +430 -0
- package/src/runtime/domain/subagents/goal-provider.domain.mjs +125 -0
- package/src/runtime/domain/subagents/goal-provider.ts +132 -0
- package/src/runtime/domain/subagents/health-observation.domain.mjs +617 -0
- package/src/runtime/domain/subagents/health-observation.ts +818 -0
- package/src/runtime/domain/subagents/health-surface.mjs +284 -0
- package/src/runtime/domain/subagents/health.domain.mjs +261 -0
- package/src/runtime/domain/subagents/health.ts +343 -0
- package/src/runtime/domain/subagents/historical-attention.domain.mjs +37 -0
- package/src/runtime/domain/subagents/historical-attention.ts +35 -0
- package/src/runtime/domain/subagents/incident-model.domain.mjs +322 -0
- package/src/runtime/domain/subagents/incident-model.ts +358 -0
- package/src/runtime/domain/subagents/index.domain.mjs +4731 -0
- package/src/runtime/domain/subagents/index.ts +4781 -0
- package/src/runtime/domain/subagents/launch-abort.domain.mjs +13 -0
- package/src/runtime/domain/subagents/launch-abort.ts +21 -0
- package/src/runtime/domain/subagents/launch-context.domain.mjs +24 -0
- package/src/runtime/domain/subagents/launch-context.ts +23 -0
- package/src/runtime/domain/subagents/launch-digest.mjs +6 -0
- package/src/runtime/domain/subagents/lifecycle.domain.mjs +265 -0
- package/src/runtime/domain/subagents/lifecycle.ts +360 -0
- package/src/runtime/domain/subagents/list.domain.mjs +2 -0
- package/src/runtime/domain/subagents/list.mjs +152 -0
- package/src/runtime/domain/subagents/list.ts +19 -0
- package/src/runtime/domain/subagents/log-cursor.domain.mjs +217 -0
- package/src/runtime/domain/subagents/log-cursor.ts +268 -0
- package/src/runtime/domain/subagents/managed-background-capability.domain.mjs +10 -0
- package/src/runtime/domain/subagents/managed-background-capability.ts +9 -0
- package/src/runtime/domain/subagents/managed-failure-worker.mjs +36 -0
- package/src/runtime/domain/subagents/managed-launch-bootstrap.mjs +48 -0
- package/src/runtime/domain/subagents/managed-launch-client.domain.mjs +75 -0
- package/src/runtime/domain/subagents/managed-launch-client.ts +59 -0
- package/src/runtime/domain/subagents/managed-launch-host.domain.mjs +627 -0
- package/src/runtime/domain/subagents/managed-launch-host.ts +504 -0
- package/src/runtime/domain/subagents/managed-launch-journal.mjs +17 -0
- package/src/runtime/domain/subagents/managed-launch-ownership.domain.mjs +29 -0
- package/src/runtime/domain/subagents/managed-launch-ownership.ts +22 -0
- package/src/runtime/domain/subagents/managed-launch-port.domain.mjs +2 -0
- package/src/runtime/domain/subagents/managed-launch-port.ts +25 -0
- package/src/runtime/domain/subagents/managed-launch-recovery.domain.mjs +29 -0
- package/src/runtime/domain/subagents/managed-launch-recovery.ts +45 -0
- package/src/runtime/domain/subagents/managed-worker-bridge.domain.mjs +63 -0
- package/src/runtime/domain/subagents/managed-worker-bridge.ts +48 -0
- package/src/runtime/domain/subagents/managed-worker.mjs +13 -0
- package/src/runtime/domain/subagents/model-resolution-core.domain.mjs +822 -0
- package/src/runtime/domain/subagents/model-resolution-core.ts +1074 -0
- package/src/runtime/domain/subagents/model-resolution.domain.mjs +22 -0
- package/src/runtime/domain/subagents/model-resolution.ts +32 -0
- package/src/runtime/domain/subagents/navigator.domain.mjs +6 -0
- package/src/runtime/domain/subagents/navigator.mjs +1233 -0
- package/src/runtime/domain/subagents/navigator.ts +39 -0
- package/src/runtime/domain/subagents/operation-bridge-types.domain.mjs +1012 -0
- package/src/runtime/domain/subagents/operation-bridge-types.ts +1156 -0
- package/src/runtime/domain/subagents/outage-observations.domain.mjs +84 -0
- package/src/runtime/domain/subagents/outage-observations.ts +73 -0
- package/src/runtime/domain/subagents/output-payload.domain.mjs +767 -0
- package/src/runtime/domain/subagents/output-payload.ts +987 -0
- package/src/runtime/domain/subagents/owned-exit.domain.mjs +12 -0
- package/src/runtime/domain/subagents/owned-exit.ts +12 -0
- package/src/runtime/domain/subagents/package.json +86 -0
- package/src/runtime/domain/subagents/park-checkpoint.domain.mjs +55 -0
- package/src/runtime/domain/subagents/park-checkpoint.ts +61 -0
- package/src/runtime/domain/subagents/parse.domain.mjs +1218 -0
- package/src/runtime/domain/subagents/parse.ts +1451 -0
- package/src/runtime/domain/subagents/permission-policy.domain.mjs +232 -0
- package/src/runtime/domain/subagents/permission-policy.ts +291 -0
- package/src/runtime/domain/subagents/process-identity.mjs +33 -0
- package/src/runtime/domain/subagents/registry.domain.mjs +1584 -0
- package/src/runtime/domain/subagents/registry.ts +1904 -0
- package/src/runtime/domain/subagents/role-assignment.domain.mjs +104 -0
- package/src/runtime/domain/subagents/role-assignment.ts +141 -0
- package/src/runtime/domain/subagents/roles/role.architect.md +13 -0
- package/src/runtime/domain/subagents/roles/role.developer.md +16 -0
- package/src/runtime/domain/subagents/roles/role.explorer.md +13 -0
- package/src/runtime/domain/subagents/roles/role.product-manager.md +13 -0
- package/src/runtime/domain/subagents/roles/role.researcher.md +13 -0
- package/src/runtime/domain/subagents/roles/role.reviewer.md +13 -0
- package/src/runtime/domain/subagents/roles/role.writer.md +12 -0
- package/src/runtime/domain/subagents/sandbox.domain.mjs +64 -0
- package/src/runtime/domain/subagents/sandbox.ts +92 -0
- package/src/runtime/domain/subagents/session-selection.domain.mjs +32 -0
- package/src/runtime/domain/subagents/session-selection.ts +35 -0
- package/src/runtime/domain/subagents/session-store.domain.mjs +489 -0
- package/src/runtime/domain/subagents/session-store.ts +468 -0
- package/src/runtime/domain/subagents/settings-page.domain.mjs +313 -0
- package/src/runtime/domain/subagents/settings-page.ts +363 -0
- package/src/runtime/domain/subagents/shared-callback-batcher.domain.mjs +777 -0
- package/src/runtime/domain/subagents/shared-callback-batcher.ts +956 -0
- package/src/runtime/domain/subagents/shared-catalog.domain.mjs +70 -0
- package/src/runtime/domain/subagents/shared-catalog.ts +61 -0
- package/src/runtime/domain/subagents/shared-execution-policy.domain.mjs +50 -0
- package/src/runtime/domain/subagents/shared-execution-policy.ts +61 -0
- package/src/runtime/domain/subagents/shared-failure-observations.domain.mjs +1078 -0
- package/src/runtime/domain/subagents/shared-failure-observations.ts +1166 -0
- package/src/runtime/domain/subagents/shared-harness-settings.domain.mjs +126 -0
- package/src/runtime/domain/subagents/shared-harness-settings.ts +116 -0
- package/src/runtime/domain/subagents/shared-log-utils.domain.mjs +1223 -0
- package/src/runtime/domain/subagents/shared-log-utils.ts +1492 -0
- package/src/runtime/domain/subagents/shared-navigator-panels.domain.mjs +289 -0
- package/src/runtime/domain/subagents/shared-navigator-panels.ts +272 -0
- package/src/runtime/domain/subagents/shared-navigator.domain.mjs +1930 -0
- package/src/runtime/domain/subagents/shared-navigator.ts +1962 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/assignment-inbox.mjs +144 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/assignment-observation.mjs +189 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/index.domain.mjs +51 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/index.ts +122 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/assignment-changes.domain.mjs +75 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/assignment-changes.ts +73 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/assignment-outcomes.domain.mjs +163 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/assignment-outcomes.ts +174 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/background-parent-callbacks.domain.mjs +66 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/background-parent-callbacks.ts +68 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/background-requests.domain.mjs +87 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/background-requests.ts +90 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/discovery.domain.mjs +97 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/discovery.ts +139 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/errors.domain.mjs +12 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/errors.ts +79 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/operations.domain.mjs +342 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/operations.ts +513 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/outbox.domain.mjs +283 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/outbox.ts +458 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/recovery.domain.mjs +52 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/recovery.ts +55 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/result-supervision.domain.mjs +114 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/result-supervision.ts +140 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/rows.domain.mjs +280 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/rows.ts +442 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/schema.domain.mjs +420 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/schema.ts +441 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/sqlite.domain.mjs +194 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/sqlite.ts +239 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/store.domain.mjs +275 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/store.ts +585 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/subagent-launch.domain.mjs +120 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/subagent-launch.ts +142 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/task-cancellation.domain.mjs +188 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/task-cancellation.ts +224 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/types.domain.mjs +25 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/types.ts +707 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/upgrade.domain.mjs +22 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/upgrade.ts +22 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/validate.domain.mjs +234 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/validate.ts +241 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/waits.domain.mjs +851 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/waits.ts +1424 -0
- package/src/runtime/domain/subagents/shared-permission-blocker.domain.mjs +40 -0
- package/src/runtime/domain/subagents/shared-permission-blocker.ts +48 -0
- package/src/runtime/domain/subagents/shared-render-scheduler.domain.mjs +41 -0
- package/src/runtime/domain/subagents/shared-render-scheduler.ts +47 -0
- package/src/runtime/domain/subagents/shared-sandbox-core.domain.mjs +1531 -0
- package/src/runtime/domain/subagents/shared-sandbox-core.ts +1757 -0
- package/src/runtime/domain/subagents/shared-sandbox-diagnostics.domain.mjs +591 -0
- package/src/runtime/domain/subagents/shared-sandbox-diagnostics.ts +491 -0
- package/src/runtime/domain/subagents/shared-stall-detector.domain.mjs +37 -0
- package/src/runtime/domain/subagents/shared-stall-detector.ts +69 -0
- package/src/runtime/domain/subagents/shared-task-application.domain.mjs +185 -0
- package/src/runtime/domain/subagents/shared-task-application.ts +185 -0
- package/src/runtime/domain/subagents/shared-task-apply-patch.domain.mjs +416 -0
- package/src/runtime/domain/subagents/shared-task-apply-patch.ts +409 -0
- package/src/runtime/domain/subagents/shared-task-exec.domain.mjs +325 -0
- package/src/runtime/domain/subagents/shared-task-exec.ts +335 -0
- package/src/runtime/domain/subagents/shared-task-files.domain.mjs +346 -0
- package/src/runtime/domain/subagents/shared-task-files.ts +342 -0
- package/src/runtime/domain/subagents/shared-task-process-identity.domain.mjs +140 -0
- package/src/runtime/domain/subagents/shared-task-process-identity.ts +126 -0
- package/src/runtime/domain/subagents/shared-task-process-list.domain.mjs +220 -0
- package/src/runtime/domain/subagents/shared-task-process-list.ts +209 -0
- package/src/runtime/domain/subagents/shared-task-sandbox.domain.mjs +227 -0
- package/src/runtime/domain/subagents/shared-task-sandbox.ts +224 -0
- package/src/runtime/domain/subagents/shared-task-tools.domain.mjs +92 -0
- package/src/runtime/domain/subagents/shared-task-tools.ts +123 -0
- package/src/runtime/domain/subagents/shared-work-client.mjs +303 -0
- package/src/runtime/domain/subagents/shared-worktree-context.domain.mjs +142 -0
- package/src/runtime/domain/subagents/shared-worktree-context.ts +158 -0
- package/src/runtime/domain/subagents/skill-picker.domain.mjs +316 -0
- package/src/runtime/domain/subagents/skill-picker.ts +353 -0
- package/src/runtime/domain/subagents/skills.domain.mjs +138 -0
- package/src/runtime/domain/subagents/skills.ts +183 -0
- package/src/runtime/domain/subagents/spawn.domain.mjs +72 -0
- package/src/runtime/domain/subagents/spawn.ts +80 -0
- package/src/runtime/domain/subagents/stop.domain.mjs +184 -0
- package/src/runtime/domain/subagents/stop.ts +217 -0
- package/src/runtime/domain/subagents/subagent-tools.domain.mjs +101 -0
- package/src/runtime/domain/subagents/subagent-tools.ts +137 -0
- package/src/runtime/domain/subagents/task-guard.domain.mjs +163 -0
- package/src/runtime/domain/subagents/task-guard.ts +144 -0
- package/src/runtime/domain/subagents/task-policy.domain.mjs +201 -0
- package/src/runtime/domain/subagents/task-policy.ts +236 -0
- package/src/runtime/domain/subagents/task-runtime.mjs +53 -0
- package/src/runtime/domain/subagents/task-tool-owner.domain.mjs +18 -0
- package/src/runtime/domain/subagents/task-tool-owner.ts +21 -0
- package/src/runtime/domain/subagents/thinking.domain.mjs +22 -0
- package/src/runtime/domain/subagents/thinking.ts +28 -0
- package/src/runtime/domain/subagents/tier-policy.domain.mjs +75 -0
- package/src/runtime/domain/subagents/tier-policy.ts +126 -0
- package/src/runtime/domain/subagents/timing-notifications.domain.mjs +51 -0
- package/src/runtime/domain/subagents/timing-notifications.ts +37 -0
- package/src/runtime/domain/subagents/timing.domain.mjs +487 -0
- package/src/runtime/domain/subagents/timing.ts +634 -0
- package/src/runtime/domain/subagents/tools.domain.mjs +558 -0
- package/src/runtime/domain/subagents/tools.ts +629 -0
- package/src/runtime/domain/subagents/widget.domain.mjs +6 -0
- package/src/runtime/domain/subagents/widget.mjs +246 -0
- package/src/runtime/domain/subagents/widget.ts +30 -0
- package/src/runtime/domain/subagents/work-observation.domain.mjs +316 -0
- package/src/runtime/domain/subagents/work-observation.ts +248 -0
- package/src/runtime/domain/subagents/worker-catalog.domain.mjs +120 -0
- package/src/runtime/domain/subagents/worker-catalog.ts +162 -0
- package/src/runtime/domain/subagents/worker-operations-host.domain.mjs +1009 -0
- package/src/runtime/domain/subagents/worker-operations-host.ts +1238 -0
- package/src/runtime/domain/subagents/worker-waits.domain.mjs +2336 -0
- package/src/runtime/domain/subagents/worker-waits.ts +2878 -0
- package/src/runtime/domain/subagents/workspace-scope.domain.mjs +52 -0
- package/src/runtime/domain/subagents/workspace-scope.ts +50 -0
- package/src/runtime/health-config.ts +27 -11
- package/src/runtime/log-checkpoints.ts +117 -0
- package/src/runtime/mutation-store.ts +5 -4
- package/src/runtime/queries.ts +27 -3
- package/src/runtime/query-executor.ts +178 -34
- package/src/runtime/query-worker.mjs +119 -22
- package/src/runtime/read-model.ts +939 -113
- package/src/runtime/read-watchdog-probe.ts +4 -0
- package/src/runtime/result-supervision.ts +188 -16
- package/src/runtime/source-watch.ts +175 -0
- package/src/runtime/subagent-launch.ts +73 -0
- package/src/runtime/work-budget.ts +130 -0
- package/src/runtime/work-client.d.mts +8 -0
- package/src/runtime/work-client.mjs +150 -7
- package/src/server.ts +185 -22
- package/src/session-activity.ts +26 -4
- package/src/version.ts +1 -1
|
@@ -1,6 +1,16 @@
|
|
|
1
1
|
// Generated from packages/operation-coordinator/assignment-observation.mjs. Do not edit directly.
|
|
2
2
|
import { createRequire } from "node:module";
|
|
3
|
-
import {
|
|
3
|
+
import { AssignmentInbox } from "./assignment-inbox.mjs";
|
|
4
|
+
import { pathToFileURL } from "node:url";
|
|
5
|
+
|
|
6
|
+
// Only first-party source SQL passes this facade; quoted values stay untouched.
|
|
7
|
+
const sourceTables = new Set(["schema_meta", "sqlite_master", "sqlite_schema", "assignment_change_source", "assignment_changes",
|
|
8
|
+
"waits", "wait_dependencies", "resume_claims", "operations", "coordinator_state", "assignment_outcomes",
|
|
9
|
+
"subagent_launch_intents", "background_input_versions", "background_parent_callbacks", "assignments", "assignment_bindings", "assignment_attempts"]);
|
|
10
|
+
function sourceSQL(sql) {
|
|
11
|
+
if (/^PRAGMA\s+data_version\s*$/i.test(sql)) return "PRAGMA coordinator_source.data_version";
|
|
12
|
+
return sql.replace(/'(?:''|[^'])*'|\b[A-Za-z_][A-Za-z_0-9]*\b/g, token => sourceTables.has(token) ? `coordinator_source.${token}` : token);
|
|
13
|
+
}
|
|
4
14
|
|
|
5
15
|
/** Read-only, bounded projection input. Never creates/migrates a database. */
|
|
6
16
|
export function readAssignmentWaits(path, owner, connection) {
|
|
@@ -44,42 +54,66 @@ export function readAssignmentWaits(path, owner, connection) {
|
|
|
44
54
|
}
|
|
45
55
|
|
|
46
56
|
/** A root read model owns this connection; ordinary observers remain one-shot. */
|
|
47
|
-
export function createAssignmentReader(path) {
|
|
57
|
+
export function createAssignmentReader(path, inboxPath = ":memory:", derivedConnection, options = {}) {
|
|
58
|
+
const inbox = new AssignmentInbox(inboxPath, derivedConnection);
|
|
48
59
|
let db;
|
|
49
60
|
let identity;
|
|
50
61
|
let snapshot = false;
|
|
62
|
+
const composed = options.composed === true;
|
|
63
|
+
const owner = derivedConnection;
|
|
64
|
+
const dropSource = () => {
|
|
65
|
+
if (composed) { if (db) owner.exec("DETACH DATABASE coordinator_source"); }
|
|
66
|
+
else db?.close();
|
|
67
|
+
db = undefined; statements.clear();
|
|
68
|
+
};
|
|
51
69
|
const statements = new Map();
|
|
52
|
-
|
|
70
|
+
const reader = {
|
|
53
71
|
revision() {
|
|
54
72
|
const { statSync } = createRequire(import.meta.url)("node:fs");
|
|
55
73
|
const stat = statSync(path, { bigint: true });
|
|
56
74
|
const next = `${stat.dev}:${stat.ino}`;
|
|
57
75
|
if (identity !== next) {
|
|
58
76
|
if (snapshot) throw new Error("Coordinator identity changed during observation");
|
|
59
|
-
|
|
60
|
-
db = undefined;
|
|
61
|
-
statements.clear();
|
|
77
|
+
dropSource();
|
|
62
78
|
identity = next;
|
|
63
79
|
}
|
|
64
80
|
const { DatabaseSync } = createRequire(import.meta.url)("node:sqlite");
|
|
65
|
-
|
|
81
|
+
if (!db) {
|
|
82
|
+
if (composed) {
|
|
83
|
+
const uri = pathToFileURL(path); uri.searchParams.set("mode", "ro");
|
|
84
|
+
owner.prepare("ATTACH DATABASE ? AS coordinator_source").run(uri.href);
|
|
85
|
+
db = { prepare: sql => owner.prepare(sourceSQL(sql)), get observationActive() { return snapshot; }, beginSnapshot: () => reader.beginSnapshot() };
|
|
86
|
+
} else db = new DatabaseSync(path, { readOnly: true });
|
|
87
|
+
}
|
|
66
88
|
return `${identity}:${db.prepare("PRAGMA data_version").get().data_version}`;
|
|
67
89
|
},
|
|
90
|
+
connection(refresh = true) { if (refresh) this.revision(); return db; },
|
|
91
|
+
changes() { this.revision(); return inbox.receive(db, identity); },
|
|
92
|
+
acknowledgeChanges(batch, complete) { inbox.acknowledge(batch, complete); },
|
|
93
|
+
get changeMetrics() { return inbox.metrics; },
|
|
94
|
+
get snapshotActive() { return snapshot; },
|
|
95
|
+
|
|
68
96
|
beginSnapshot() {
|
|
69
97
|
this.revision();
|
|
70
98
|
if (snapshot) throw new Error("Coordinator snapshot already open");
|
|
71
|
-
db
|
|
99
|
+
const transaction = composed ? owner : db;
|
|
100
|
+
transaction.exec("BEGIN");
|
|
72
101
|
snapshot = true;
|
|
73
102
|
const release = () => {
|
|
74
103
|
if (!snapshot) return;
|
|
75
|
-
try {
|
|
104
|
+
try { transaction.exec("ROLLBACK"); } finally { snapshot = false; }
|
|
76
105
|
};
|
|
77
106
|
try {
|
|
78
107
|
// Pin the WAL read view before recording its revision; other writers keep advancing.
|
|
79
108
|
db.prepare("SELECT count(*) FROM sqlite_schema").get();
|
|
80
|
-
return { revision: this.revision(), release
|
|
109
|
+
return { revision: this.revision(), release, commit: () => {
|
|
110
|
+
if (!snapshot) return;
|
|
111
|
+
transaction.exec("COMMIT");
|
|
112
|
+
snapshot = false;
|
|
113
|
+
} };
|
|
81
114
|
} catch (error) { release(); throw error; }
|
|
82
115
|
},
|
|
116
|
+
|
|
83
117
|
read(owner) {
|
|
84
118
|
try {
|
|
85
119
|
this.revision();
|
|
@@ -91,30 +125,34 @@ export function createAssignmentReader(path) {
|
|
|
91
125
|
return { verified: false, waits: [], reason: "Coordinator state is unverified; compatible supervision is unavailable." };
|
|
92
126
|
}
|
|
93
127
|
},
|
|
94
|
-
|
|
95
|
-
try {
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
for (const row of db.prepare("SELECT record_json FROM assignment_outcomes ORDER BY assignment_id").all()) {
|
|
112
|
-
const record = JSON.parse(row.record_json);
|
|
113
|
-
add(record.owner.sessionId, record.owner.workspace, record);
|
|
128
|
+
upgradeObligations() {
|
|
129
|
+
try { this.revision(); } catch (error) {
|
|
130
|
+
if (error.code === "ENOENT") return [];
|
|
131
|
+
throw error;
|
|
132
|
+
}
|
|
133
|
+
const version = db.prepare("SELECT value FROM schema_meta WHERE key='schema_version'").get()?.value;
|
|
134
|
+
if (!["1", "2", "3", "4"].includes(version)) throw new Error("Unsupported coordinator schema during upgrade");
|
|
135
|
+
const obligations = db.prepare("SELECT operation_id, task_id, observer_kind FROM operations WHERE phase='running' AND terminal_revision=0").all()
|
|
136
|
+
.map(row => ({ kind: "unsettled-operation", id: row.task_id, operationId: row.operation_id, observer: row.observer_kind }));
|
|
137
|
+
const reasons = db.prepare("SELECT claim_id AS id, state FROM resume_claims WHERE state IN ('claimed', 'published')").all()
|
|
138
|
+
.map(row => ({ kind: "resume-claim", id: row.id, state: row.state }));
|
|
139
|
+
for (const row of db.prepare("SELECT wait_id, generation, phase FROM waits WHERE owner_kind='worker-conversation' AND phase NOT IN ('consumed', 'cancelled') AND dispatch_disarmed=0").all()) {
|
|
140
|
+
reasons.push({ kind: "worker-wait", id: row.wait_id, generation: row.generation, phase: row.phase });
|
|
141
|
+
}
|
|
142
|
+
if (db.prepare("SELECT 1 FROM sqlite_master WHERE type='table' AND name='subagent_launch_intents'").get()) {
|
|
143
|
+
for (const row of db.prepare("SELECT owner, request_key, attempts FROM subagent_launch_intents WHERE state='accepted'").all()) {
|
|
144
|
+
reasons.push({ kind: "launch-intent", id: row.request_key, owner: row.owner, attempts: JSON.parse(row.attempts).map(attempt => attempt.id) });
|
|
114
145
|
}
|
|
115
|
-
|
|
116
|
-
|
|
146
|
+
}
|
|
147
|
+
for (const row of db.prepare("SELECT value FROM coordinator_state WHERE key LIKE 'background-request-v1:%'").all()) {
|
|
148
|
+
const request = JSON.parse(row.value);
|
|
149
|
+
if (request.state !== 'returned') reasons.push({kind:'background-request', id:request.key, owner:request.owner});
|
|
150
|
+
}
|
|
151
|
+
return [...obligations, ...reasons];
|
|
117
152
|
},
|
|
118
|
-
|
|
153
|
+
|
|
154
|
+
close() { if (snapshot) { (composed ? owner : db).exec("ROLLBACK"); snapshot = false; } dropSource(); identity = undefined; inbox.close(); },
|
|
155
|
+
|
|
119
156
|
};
|
|
157
|
+
return reader;
|
|
120
158
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { readFileSync } from "node:fs";
|
|
1
2
|
import { execFileSync } from "node:child_process";
|
|
2
3
|
/**
|
|
3
4
|
* Process start-token reads.
|
|
@@ -20,11 +21,12 @@ const TOKEN_MEMO_TTL_MS = 1_000;
|
|
|
20
21
|
/** Bound on memo entries; the panel is small, but a long session is not. */
|
|
21
22
|
const TOKEN_MEMO_MAX_ENTRIES = 512;
|
|
22
23
|
const tokenMemo = new Map();
|
|
23
|
-
function readTokenUncached(pid) {
|
|
24
|
+
function readTokenUncached(pid, admission = false) {
|
|
24
25
|
if (!Number.isInteger(pid) || pid <= 0 || process.platform === "win32")
|
|
25
26
|
return undefined;
|
|
26
27
|
try {
|
|
27
|
-
const output = execFileSync("ps", ["-o", "lstart=", "-p", String(pid)], {
|
|
28
|
+
const output = execFileSync(admission ? "/bin/ps" : "ps", ["-o", "lstart=", "-p", String(pid)], {
|
|
29
|
+
env: admission ? { LC_ALL: "C", TZ: "UTC0", PATH: "/usr/bin:/bin" } : process.env,
|
|
28
30
|
encoding: "utf8",
|
|
29
31
|
stdio: ["ignore", "pipe", "ignore"],
|
|
30
32
|
timeout: 2_000,
|
|
@@ -35,6 +37,22 @@ function readTokenUncached(pid) {
|
|
|
35
37
|
return undefined;
|
|
36
38
|
}
|
|
37
39
|
}
|
|
40
|
+
// Admission crosses process environments; stored task tokens retain their original format.
|
|
41
|
+
export function readAdmissionStartToken(pid) {
|
|
42
|
+
if (process.platform !== "linux")
|
|
43
|
+
return readTokenUncached(pid, true);
|
|
44
|
+
if (!Number.isInteger(pid) || pid <= 0)
|
|
45
|
+
return undefined;
|
|
46
|
+
try {
|
|
47
|
+
const stat = readFileSync(`/proc/${pid}/stat`, "utf8");
|
|
48
|
+
// Fields after the parenthesized command start at field 3. Start time is field 22.
|
|
49
|
+
const start = stat.slice(stat.lastIndexOf(")") + 2).split(" ")[19];
|
|
50
|
+
return start && /^\d+$/.test(start) ? start : undefined;
|
|
51
|
+
}
|
|
52
|
+
catch {
|
|
53
|
+
return undefined;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
38
56
|
function remember(pid, token, now) {
|
|
39
57
|
if (tokenMemo.size >= TOKEN_MEMO_MAX_ENTRIES) {
|
|
40
58
|
// Drop expired entries first; only evict live ones if that was not enough.
|
|
@@ -59,8 +59,8 @@ export function validateCommandSpec(spec) {
|
|
|
59
59
|
/** Convert a Windows path to the `/c/...` form MSYS bash resolves in redirections. Exposed for tests and reuse. */
|
|
60
60
|
export function toMsysPath(path) {
|
|
61
61
|
const forward = path.replace(/\\/g, "/");
|
|
62
|
-
const drive = /^([A-Za-z]):(\/.+)$/.exec(forward);
|
|
63
|
-
return drive ? `/${drive
|
|
62
|
+
const [, drive, rest] = /^([A-Za-z]):(\/.+)$/.exec(forward) ?? [];
|
|
63
|
+
return drive && rest ? `/${drive.toLowerCase()}${rest}` : forward;
|
|
64
64
|
}
|
|
65
65
|
/** Single-quote a value for safe literal use in a bash script line. Exposed for tests and reuse. */
|
|
66
66
|
export function bashSingleQuote(value) {
|
|
@@ -144,7 +144,7 @@ export function parseStepGateFailure(logText, id) {
|
|
|
144
144
|
if (!line.startsWith(marker) || !line.endsWith(" ---"))
|
|
145
145
|
continue;
|
|
146
146
|
const match = /^--- step gate \[[^\]]+\]: first failing step exit=(-?\d+); shell exit=(-?\d+): (.*) ---$/.exec(line);
|
|
147
|
-
if (!match)
|
|
147
|
+
if (!match || match[3] === undefined)
|
|
148
148
|
continue;
|
|
149
149
|
const stepExitCode = Number(match[1]);
|
|
150
150
|
const shellExitCode = Number(match[2]);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createHash } from "node:crypto";
|
|
2
|
-
import { mkdirSync, readFileSync, readdirSync, rmSync, statSync, unlinkSync, writeFileSync } from "node:fs";
|
|
2
|
+
import { mkdirSync, readFileSync, readdirSync, renameSync, rmSync, statSync, unlinkSync, writeFileSync } from "node:fs";
|
|
3
3
|
import { tmpdir } from "node:os";
|
|
4
4
|
import { join } from "node:path";
|
|
5
5
|
import { isTerminalStatus } from "./types.mjs";
|
|
@@ -10,7 +10,7 @@ const metaCache = new Map();
|
|
|
10
10
|
const indexIdsCache = new Map();
|
|
11
11
|
const initializedIndexes = new Set();
|
|
12
12
|
const metaChangedListeners = new Set();
|
|
13
|
-
const registryIo = { fullDirectoryReads: 0, indexDirectoryReads: 0, metadataFileReads: 0, indexRevisionChecks: 0 };
|
|
13
|
+
const registryIo = { fullDirectoryReads: 0, indexDirectoryReads: 0, metadataFileReads: 0, terminalMetadataFileReads: 0, indexRevisionChecks: 0 };
|
|
14
14
|
export function getRegistryIoMetrics() {
|
|
15
15
|
return { ...registryIo };
|
|
16
16
|
}
|
|
@@ -18,6 +18,7 @@ export function resetRegistryIoMetrics() {
|
|
|
18
18
|
registryIo.fullDirectoryReads = 0;
|
|
19
19
|
registryIo.indexDirectoryReads = 0;
|
|
20
20
|
registryIo.metadataFileReads = 0;
|
|
21
|
+
registryIo.terminalMetadataFileReads = 0;
|
|
21
22
|
registryIo.indexRevisionChecks = 0;
|
|
22
23
|
}
|
|
23
24
|
export function baseDir() {
|
|
@@ -63,7 +64,7 @@ export function writeMeta(meta) {
|
|
|
63
64
|
indexMeta(meta);
|
|
64
65
|
for (const listener of metaChangedListeners) {
|
|
65
66
|
try {
|
|
66
|
-
listener();
|
|
67
|
+
listener(meta);
|
|
67
68
|
}
|
|
68
69
|
catch { /* best effort */ }
|
|
69
70
|
}
|
|
@@ -104,6 +105,8 @@ export function inspectMeta(id) {
|
|
|
104
105
|
const raw = readFileSync(path, "utf8");
|
|
105
106
|
try {
|
|
106
107
|
const meta = JSON.parse(raw);
|
|
108
|
+
if (isTerminalStatus(meta.status))
|
|
109
|
+
registryIo.terminalMetadataFileReads++;
|
|
107
110
|
const invalid = metaShapeProblem(meta, id);
|
|
108
111
|
if (invalid) {
|
|
109
112
|
metaCache.delete(id);
|
|
@@ -159,9 +162,10 @@ export function removeMeta(meta) {
|
|
|
159
162
|
metaCache.delete(meta.id);
|
|
160
163
|
removeIndexEntry(originIndexDir(originOf(meta)), meta.id);
|
|
161
164
|
removeIndexEntry(originActiveIndexDir(originOf(meta)), meta.id);
|
|
165
|
+
removeIndexEntry(recentPath(originOf(meta)), meta.id);
|
|
162
166
|
for (const listener of metaChangedListeners) {
|
|
163
167
|
try {
|
|
164
|
-
listener();
|
|
168
|
+
listener(meta);
|
|
165
169
|
}
|
|
166
170
|
catch { /* best effort */ }
|
|
167
171
|
}
|
|
@@ -198,6 +202,25 @@ export function listMetasForOrigin(origin) {
|
|
|
198
202
|
.filter((meta) => meta !== undefined && belongsToOrigin(meta, origin))
|
|
199
203
|
.sort((a, b) => b.startedAt - a.startedAt);
|
|
200
204
|
}
|
|
205
|
+
/** Durable pending callbacks are independent of the Navigator's terminal retention. */
|
|
206
|
+
export function listPendingCallbackMetasForOrigin(origin) {
|
|
207
|
+
const directory = join(baseDir(), 'by-origin-callback', originKey(origin));
|
|
208
|
+
if (!initializedIndexes.has(directory)) {
|
|
209
|
+
try {
|
|
210
|
+
readFileSync(join(directory, '.initialized'));
|
|
211
|
+
}
|
|
212
|
+
catch {
|
|
213
|
+
for (const meta of listMetasForOrigin(origin))
|
|
214
|
+
if (pendingCallback(meta))
|
|
215
|
+
writeIndexEntry(directory, meta.id);
|
|
216
|
+
mkdirSync(directory, { recursive: true });
|
|
217
|
+
writeFileSync(join(directory, '.initialized'), '1');
|
|
218
|
+
}
|
|
219
|
+
initializedIndexes.add(directory);
|
|
220
|
+
}
|
|
221
|
+
return readIndexIds(directory).map(readOwnedMeta).filter((meta) => !!meta && belongsToOrigin(meta, origin) && pendingCallback(meta));
|
|
222
|
+
}
|
|
223
|
+
function pendingCallback(meta) { return isTerminalStatus(meta.status) && meta.status !== 'cancelled' && meta.callback !== false && !meta.callbackSentAt && !meta.callbackSuppressedAt; }
|
|
201
224
|
export function listActiveMetasForOrigin(origin) {
|
|
202
225
|
const directory = originActiveIndexDir(origin);
|
|
203
226
|
ensureOriginActiveIndex(origin, directory);
|
|
@@ -210,6 +233,7 @@ export function listActiveMetasForOrigin(origin) {
|
|
|
210
233
|
export function observeMetasForOrigin(origin, activeOnly = true) {
|
|
211
234
|
const directory = activeOnly ? originActiveIndexDir(origin) : originIndexDir(origin);
|
|
212
235
|
let ids;
|
|
236
|
+
registryIo.indexDirectoryReads++;
|
|
213
237
|
try {
|
|
214
238
|
ids = readdirSync(directory).filter(id => id !== ".initialized");
|
|
215
239
|
}
|
|
@@ -226,6 +250,50 @@ export function observeMetasForOrigin(origin, activeOnly = true) {
|
|
|
226
250
|
}).filter((meta) => !!meta && !!meta.callbackOrigin && belongsToOrigin(meta, origin)
|
|
227
251
|
&& (!activeOnly || meta.status === "running")).sort((a, b) => b.startedAt - a.startedAt);
|
|
228
252
|
}
|
|
253
|
+
const RECENT_LIMIT = 256;
|
|
254
|
+
const RECENT_MS = 30000;
|
|
255
|
+
function recentPath(origin) {
|
|
256
|
+
return join(baseDir(), "by-origin-recent", originKey(origin));
|
|
257
|
+
}
|
|
258
|
+
function recentEntries(origin) {
|
|
259
|
+
const directory = recentPath(origin);
|
|
260
|
+
try {
|
|
261
|
+
registryIo.indexDirectoryReads++;
|
|
262
|
+
const entries = readdirSync(directory).filter(id => !id.startsWith(".")).flatMap(id => {
|
|
263
|
+
try {
|
|
264
|
+
registryIo.indexRevisionChecks++;
|
|
265
|
+
return [{ id, observedAt: statSync(join(directory, id)).mtimeMs }];
|
|
266
|
+
}
|
|
267
|
+
catch (error) {
|
|
268
|
+
if (error.code === "ENOENT")
|
|
269
|
+
return [];
|
|
270
|
+
throw error;
|
|
271
|
+
}
|
|
272
|
+
}).sort((a, b) => b.observedAt - a.observedAt || b.id.localeCompare(a.id));
|
|
273
|
+
return entries.filter(entry => Date.now() - entry.observedAt < RECENT_MS).slice(0, RECENT_LIMIT);
|
|
274
|
+
}
|
|
275
|
+
catch (error) {
|
|
276
|
+
if (error.code === "ENOENT")
|
|
277
|
+
return [];
|
|
278
|
+
throw error;
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
export function recentMetaDeadline(origin) {
|
|
282
|
+
return recentEntries(origin).map(entry => entry.observedAt + RECENT_MS);
|
|
283
|
+
}
|
|
284
|
+
/** Exact cooperative source identity; no metadata or historical enumeration. */
|
|
285
|
+
export function observationRevisionForOrigin(origin) {
|
|
286
|
+
return [originActiveIndexDir(origin), recentPath(origin)].map(indexDirectorySignature).join(";");
|
|
287
|
+
}
|
|
288
|
+
/** Bounded cooperative writes, including results written before the first reader. */
|
|
289
|
+
export function observeRecentMetasForOrigin(origin) {
|
|
290
|
+
return recentEntries(origin).map(entry => {
|
|
291
|
+
const record = inspectMeta(entry.id);
|
|
292
|
+
if (record.found && !record.meta)
|
|
293
|
+
throw new Error(`Unverified background task ${entry.id}: ${record.error}`);
|
|
294
|
+
return record.meta;
|
|
295
|
+
}).filter((meta) => !!meta && belongsToOrigin(meta, origin) && meta.dismissedAt === undefined);
|
|
296
|
+
}
|
|
229
297
|
function readMetaForSweep(id) {
|
|
230
298
|
const cached = metaCache.get(id);
|
|
231
299
|
if (cached && isTerminalStatus(cached.status))
|
|
@@ -264,11 +332,28 @@ function indexMeta(meta) {
|
|
|
264
332
|
try {
|
|
265
333
|
const directory = originIndexDir(originOf(meta));
|
|
266
334
|
writeIndexEntry(directory, meta.id);
|
|
335
|
+
const callbackDirectory = join(baseDir(), 'by-origin-callback', originKey(originOf(meta)));
|
|
336
|
+
if (pendingCallback(meta))
|
|
337
|
+
writeIndexEntry(callbackDirectory, meta.id);
|
|
338
|
+
else
|
|
339
|
+
removeIndexEntry(callbackDirectory, meta.id);
|
|
267
340
|
const activeDirectory = originActiveIndexDir(originOf(meta));
|
|
268
341
|
if (meta.status === "running")
|
|
269
342
|
writeIndexEntry(activeDirectory, meta.id);
|
|
270
343
|
else
|
|
271
344
|
removeIndexEntry(activeDirectory, meta.id);
|
|
345
|
+
const origin = originOf(meta), recentDirectory = recentPath(origin);
|
|
346
|
+
mkdirSync(recentDirectory, { recursive: true });
|
|
347
|
+
// Independent pointers preserve concurrent writers; prune only this bounded
|
|
348
|
+
// recent-write accelerator, never the authoritative metadata or history.
|
|
349
|
+
const candidates = readdirSync(recentDirectory).filter(id => !id.startsWith("."));
|
|
350
|
+
const retained = new Set(recentEntries(origin).filter(entry => entry.id !== meta.id).slice(0, RECENT_LIMIT - 1).map(entry => entry.id));
|
|
351
|
+
for (const id of candidates)
|
|
352
|
+
if (id !== meta.id && !retained.has(id))
|
|
353
|
+
removeIndexEntry(recentDirectory, id);
|
|
354
|
+
const temporary = join(recentDirectory, `.${meta.id}.${process.pid}.next`);
|
|
355
|
+
writeFileSync(temporary, "");
|
|
356
|
+
renameSync(temporary, join(recentDirectory, meta.id));
|
|
272
357
|
}
|
|
273
358
|
catch {
|
|
274
359
|
// Indexes are accelerators; meta.json remains authoritative.
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
// Generated fixed launch domain from packages/pi-better-background-tasks/src/adapter-contract.ts. Do not edit directly.
|
|
2
|
+
import { getObservedWaitHost } from "./observed-wait-client.domain.mjs";
|
|
3
|
+
import { inspectMeta } from "./registry.domain.mjs";
|
|
4
|
+
/** Optional-peer contract, mirrored by pi-better-sandbox/background-admission.ts. */
|
|
5
|
+
export const BACKGROUND_ADAPTER_REQUEST = "pi-better-background-tasks:adapter-request";
|
|
6
|
+
export const BACKGROUND_ADAPTER_VERSION = 1;
|
|
7
|
+
/** The schemas belong to one registerTools invocation, never to a module singleton. */
|
|
8
|
+
export function advertiseBackgroundAdapter(pi, schemas) {
|
|
9
|
+
const unsubscribe = pi.events?.on(BACKGROUND_ADAPTER_REQUEST, (data) => {
|
|
10
|
+
const request = data;
|
|
11
|
+
if (request?.version !== BACKGROUND_ADAPTER_VERSION || typeof request.name !== "string" ||
|
|
12
|
+
typeof request.reply !== "function")
|
|
13
|
+
return;
|
|
14
|
+
const parameters = schemas.get(request.name);
|
|
15
|
+
if (!parameters)
|
|
16
|
+
return;
|
|
17
|
+
const admission = classify(pi, request.name, request.input);
|
|
18
|
+
if (admission)
|
|
19
|
+
request.reply({ version: BACKGROUND_ADAPTER_VERSION, parameters, admission, executionControls: 1 });
|
|
20
|
+
});
|
|
21
|
+
pi.on("session_shutdown", () => { if (typeof unsubscribe === "function")
|
|
22
|
+
unsubscribe(); });
|
|
23
|
+
}
|
|
24
|
+
function classify(pi, name, input) {
|
|
25
|
+
if (!input || typeof input !== "object" || Array.isArray(input))
|
|
26
|
+
return;
|
|
27
|
+
const params = input;
|
|
28
|
+
let action;
|
|
29
|
+
switch (name) {
|
|
30
|
+
case "bg_task_spawn":
|
|
31
|
+
action = "spawn";
|
|
32
|
+
break;
|
|
33
|
+
case "bg_task_spawn_batch": {
|
|
34
|
+
// A batch is a local launch only when no job is remote: per-job ssh options
|
|
35
|
+
// are decided by the batch launcher, not in this trusted process.
|
|
36
|
+
const jobs = Array.isArray(params.jobs) ? params.jobs : [];
|
|
37
|
+
const remote = jobs.some((job) => job !== null && typeof job === "object" &&
|
|
38
|
+
Boolean(job.ssh));
|
|
39
|
+
return remote ? undefined : "local-launch";
|
|
40
|
+
}
|
|
41
|
+
case "bg_task_watch":
|
|
42
|
+
action = "watch";
|
|
43
|
+
break;
|
|
44
|
+
case "bg_task_list":
|
|
45
|
+
action = "list";
|
|
46
|
+
break;
|
|
47
|
+
case "bg_task_status":
|
|
48
|
+
action = "status";
|
|
49
|
+
break;
|
|
50
|
+
case "bg_task_log":
|
|
51
|
+
action = "log";
|
|
52
|
+
break;
|
|
53
|
+
case "bg_task_stop":
|
|
54
|
+
action = "stop";
|
|
55
|
+
break;
|
|
56
|
+
case "bg_task":
|
|
57
|
+
action = params.action;
|
|
58
|
+
break;
|
|
59
|
+
case "bg_status":
|
|
60
|
+
if (params.action === "spawn" || params.action === "watch")
|
|
61
|
+
return;
|
|
62
|
+
action = params.action;
|
|
63
|
+
break;
|
|
64
|
+
default: return;
|
|
65
|
+
}
|
|
66
|
+
if (action === "spawn" || action === "watch")
|
|
67
|
+
return params.ssh ? undefined : "local-launch";
|
|
68
|
+
if (action === "list" || action === "status" || action === "log" || action === "clear")
|
|
69
|
+
return "registry";
|
|
70
|
+
if (action !== "stop" || typeof params.id !== "string" || !params.id)
|
|
71
|
+
return;
|
|
72
|
+
// Never trust caller flags about locality. Missing/corrupt metadata is not proof
|
|
73
|
+
// of a local stop; a remote stop can execute SSH in the trusted Pi process.
|
|
74
|
+
const meta = inspectMeta(params.id).meta;
|
|
75
|
+
if (meta && !meta.ssh && !meta.remote && (meta.kind === "process" || meta.kind === "command_watch"))
|
|
76
|
+
return "registry";
|
|
77
|
+
// A durable local task has no legacy registry meta. Only the currently active
|
|
78
|
+
// owning session/workspace may admit it as a registry operation; the exact tool
|
|
79
|
+
// source and schema are still verified by the caller before this reply is
|
|
80
|
+
// trusted. A foreign session or worker-owned id stays unauthorized.
|
|
81
|
+
if (getObservedWaitHost(pi)?.ownsDurableTask(params.id) === true)
|
|
82
|
+
return "registry";
|
|
83
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
|
|
2
|
+
import { getObservedWaitHost } from "./observed-wait-client.js";
|
|
3
|
+
import { inspectMeta } from "./registry.js";
|
|
4
|
+
|
|
5
|
+
/** Optional-peer contract, mirrored by pi-better-sandbox/background-admission.ts. */
|
|
6
|
+
export const BACKGROUND_ADAPTER_REQUEST = "pi-better-background-tasks:adapter-request";
|
|
7
|
+
export const BACKGROUND_ADAPTER_VERSION = 1;
|
|
8
|
+
|
|
9
|
+
type Admission = "local-launch" | "registry";
|
|
10
|
+
type Request = {
|
|
11
|
+
version: number;
|
|
12
|
+
name: string;
|
|
13
|
+
input: unknown;
|
|
14
|
+
executionControls?: boolean;
|
|
15
|
+
reply(value: { version: number; parameters: object; admission: Admission; executionControls: 1 }): void;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
/** The schemas belong to one registerTools invocation, never to a module singleton. */
|
|
19
|
+
export function advertiseBackgroundAdapter(pi: ExtensionAPI, schemas: ReadonlyMap<string, object>): void {
|
|
20
|
+
const unsubscribe = pi.events?.on(BACKGROUND_ADAPTER_REQUEST, (data: unknown) => {
|
|
21
|
+
const request = data as Partial<Request> | undefined;
|
|
22
|
+
if (request?.version !== BACKGROUND_ADAPTER_VERSION || typeof request.name !== "string" ||
|
|
23
|
+
typeof request.reply !== "function") return;
|
|
24
|
+
const parameters = schemas.get(request.name);
|
|
25
|
+
if (!parameters) return;
|
|
26
|
+
const admission = classify(pi, request.name, request.input);
|
|
27
|
+
if (admission) request.reply({ version: BACKGROUND_ADAPTER_VERSION, parameters, admission, executionControls: 1 });
|
|
28
|
+
});
|
|
29
|
+
pi.on("session_shutdown", () => { if (typeof unsubscribe === "function") unsubscribe(); });
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function classify(pi: ExtensionAPI, name: string, input: unknown): Admission | undefined {
|
|
33
|
+
if (!input || typeof input !== "object" || Array.isArray(input)) return;
|
|
34
|
+
const params = input as Record<string, unknown>;
|
|
35
|
+
let action: unknown;
|
|
36
|
+
switch (name) {
|
|
37
|
+
case "bg_task_spawn": action = "spawn"; break;
|
|
38
|
+
case "bg_task_spawn_batch": {
|
|
39
|
+
// A batch is a local launch only when no job is remote: per-job ssh options
|
|
40
|
+
// are decided by the batch launcher, not in this trusted process.
|
|
41
|
+
const jobs = Array.isArray(params.jobs) ? params.jobs : [];
|
|
42
|
+
const remote = jobs.some((job) => job !== null && typeof job === "object" &&
|
|
43
|
+
Boolean((job as Record<string, unknown>).ssh));
|
|
44
|
+
return remote ? undefined : "local-launch";
|
|
45
|
+
}
|
|
46
|
+
case "bg_task_watch": action = "watch"; break;
|
|
47
|
+
case "bg_task_list": action = "list"; break;
|
|
48
|
+
case "bg_task_status": action = "status"; break;
|
|
49
|
+
case "bg_task_log": action = "log"; break;
|
|
50
|
+
case "bg_task_stop": action = "stop"; break;
|
|
51
|
+
case "bg_task": action = params.action; break;
|
|
52
|
+
case "bg_status":
|
|
53
|
+
if (params.action === "spawn" || params.action === "watch") return;
|
|
54
|
+
action = params.action;
|
|
55
|
+
break;
|
|
56
|
+
default: return;
|
|
57
|
+
}
|
|
58
|
+
if (action === "spawn" || action === "watch") return params.ssh ? undefined : "local-launch";
|
|
59
|
+
if (action === "list" || action === "status" || action === "log" || action === "clear") return "registry";
|
|
60
|
+
if (action !== "stop" || typeof params.id !== "string" || !params.id) return;
|
|
61
|
+
// Never trust caller flags about locality. Missing/corrupt metadata is not proof
|
|
62
|
+
// of a local stop; a remote stop can execute SSH in the trusted Pi process.
|
|
63
|
+
const meta = inspectMeta(params.id).meta;
|
|
64
|
+
if (meta && !meta.ssh && !meta.remote && (meta.kind === "process" || meta.kind === "command_watch")) return "registry";
|
|
65
|
+
// A durable local task has no legacy registry meta. Only the currently active
|
|
66
|
+
// owning session/workspace may admit it as a registry operation; the exact tool
|
|
67
|
+
// source and schema are still verified by the caller before this reply is
|
|
68
|
+
// trusted. A foreign session or worker-owned id stays unauthorized.
|
|
69
|
+
if (getObservedWaitHost(pi)?.ownsDurableTask(params.id) === true) return "registry";
|
|
70
|
+
}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
// Generated fixed launch domain from packages/pi-better-background-tasks/src/batch.ts. Do not edit directly.
|
|
2
|
+
import { randomUUID } from "node:crypto";
|
|
3
|
+
import { readTaskIntent } from "./failures.domain.mjs";
|
|
4
|
+
import { validateCommandSpec } from "./process.domain.mjs";
|
|
5
|
+
import { resolveSshCommand } from "./shared-ssh-core/index.domain.mjs";
|
|
6
|
+
import { spawnTask } from "./runtime.domain.mjs";
|
|
7
|
+
/** Undefined inherits; false, zero, and explicit-null intent declarations override. */
|
|
8
|
+
function mergeJob(shared, job) {
|
|
9
|
+
return { ...shared, ...Object.fromEntries(Object.entries(job).filter(([, value]) => value !== undefined)) };
|
|
10
|
+
}
|
|
11
|
+
export function spawnTaskBatch(pi, params, defaultCwd, callbackOrigin, getActiveSession, dependencies = {}, runtime = { spawnTask }) {
|
|
12
|
+
// Jobs launch through the owning factory's runtime, never the default singleton.
|
|
13
|
+
const spawnOne = runtime.spawnTask;
|
|
14
|
+
if (!Array.isArray(params.jobs) || params.jobs.length < 1 || params.jobs.length > 100) {
|
|
15
|
+
throw new Error("jobs must contain between 1 and 100 background tasks.");
|
|
16
|
+
}
|
|
17
|
+
for (const field of ["name", "command", "argv", "batchId", "batchName"]) {
|
|
18
|
+
if (params.shared && Object.hasOwn(params.shared, field)) {
|
|
19
|
+
throw new Error(`Invalid batch shared field ${field}: each job must supply its own command, argv, and name; batch identity is assigned by the launcher.`);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
// Preflight the whole batch before any process, task directory, or SSH connection exists.
|
|
23
|
+
const jobs = params.jobs.map((job, index) => {
|
|
24
|
+
try {
|
|
25
|
+
if (!job || typeof job !== "object" || Array.isArray(job))
|
|
26
|
+
throw new Error("job must be an object");
|
|
27
|
+
const merged = mergeJob(params.shared, job);
|
|
28
|
+
readTaskIntent(merged);
|
|
29
|
+
validateLaunchStrings({
|
|
30
|
+
command: merged.command,
|
|
31
|
+
argv: merged.argv,
|
|
32
|
+
cwd: merged.cwd ?? defaultCwd,
|
|
33
|
+
env: merged.env,
|
|
34
|
+
ssh: merged.ssh,
|
|
35
|
+
remote: merged.remote,
|
|
36
|
+
});
|
|
37
|
+
if (merged.ssh) {
|
|
38
|
+
resolveSshCommand({ command: merged.command, cwd: merged.cwd ?? defaultCwd, env: merged.env, ssh: merged.ssh });
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
validateCommandSpec(merged);
|
|
42
|
+
}
|
|
43
|
+
return merged;
|
|
44
|
+
}
|
|
45
|
+
catch (error) {
|
|
46
|
+
throw new Error(`Invalid batch job ${index + 1}: ${errorMessage(error)}`);
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
const result = {
|
|
50
|
+
batchId: `bg_batch_${randomUUID()}`,
|
|
51
|
+
...(params.batchName !== undefined ? { batchName: params.batchName } : {}),
|
|
52
|
+
launched: [],
|
|
53
|
+
failed: [],
|
|
54
|
+
};
|
|
55
|
+
for (const [index, job] of jobs.entries()) {
|
|
56
|
+
try {
|
|
57
|
+
const meta = spawnOne(pi, { ...job, batchId: result.batchId, batchName: result.batchName }, defaultCwd, callbackOrigin, getActiveSession, dependencies);
|
|
58
|
+
result.launched.push({ job: index + 1, id: meta.id, ...(meta.name !== undefined ? { name: meta.name } : {}) });
|
|
59
|
+
}
|
|
60
|
+
catch (error) {
|
|
61
|
+
result.failed.push({ job: index + 1, ...(job.name !== undefined ? { name: job.name } : {}), error: errorMessage(error) });
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
return result;
|
|
65
|
+
}
|
|
66
|
+
export function formatBatchLaunch(result) {
|
|
67
|
+
const label = result.batchName ? `${result.batchName} (${result.batchId})` : result.batchId;
|
|
68
|
+
return [
|
|
69
|
+
`Batch ${label}: ${result.launched.length} launched, ${result.failed.length} failed to launch.`,
|
|
70
|
+
...result.launched.map((job) => `Job ${job.job}${job.name ? ` (${job.name})` : ""}: ${job.id}`),
|
|
71
|
+
...result.failed.map((job) => `Job ${job.job}${job.name ? ` (${job.name})` : ""}: failed to launch: ${job.error}`),
|
|
72
|
+
"Inspect, log, or stop each task by its id. Do not wait or poll in the foreground.",
|
|
73
|
+
].join("\n");
|
|
74
|
+
}
|
|
75
|
+
// Node rejects NULs synchronously, even when the rest of the command spec is valid.
|
|
76
|
+
function validateLaunchStrings(value, path = "launch") {
|
|
77
|
+
if (typeof value === "string") {
|
|
78
|
+
if (value.includes("\0"))
|
|
79
|
+
throw new Error(`${path} must not contain NUL bytes`);
|
|
80
|
+
}
|
|
81
|
+
else if (value && typeof value === "object") {
|
|
82
|
+
for (const [key, child] of Object.entries(value)) {
|
|
83
|
+
if (key.includes("\0"))
|
|
84
|
+
throw new Error(`${path} keys must not contain NUL bytes`);
|
|
85
|
+
validateLaunchStrings(child, `${path}.${key}`);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
function errorMessage(error) {
|
|
90
|
+
return error instanceof Error ? error.message : String(error);
|
|
91
|
+
}
|