pi-better-server 0.4.0 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +8 -1
- package/scripts/copy-pi-test-providers.mjs +10 -0
- package/scripts/event-publication/README.md +26 -0
- package/scripts/event-publication/commit.mjs +21 -0
- package/scripts/event-publication/measure.mjs +87 -0
- package/scripts/event-publication/writer.mjs +6 -0
- package/scripts/measure-full-runtime/frontend.ts +24 -0
- package/scripts/measure-full-runtime/hosted-extension.ts +28 -0
- package/scripts/measure-full-runtime/probe.mjs +29 -0
- package/scripts/measure-full-runtime/recovery-trace-loader.mjs +51 -0
- package/scripts/measure-full-runtime/recovery-trace.mjs +16 -0
- package/scripts/measure-full-runtime.mjs +146 -0
- package/scripts/measure-shared-reads/probe.mjs +26 -2
- package/scripts/measure-shared-reads.mjs +44 -9
- package/scripts/private-runtime/package-lock.json +66 -4
- package/scripts/private-runtime/package.json +10 -2
- package/scripts/source-provenance.mjs +31 -0
- package/scripts/test-on-pi.sh +3 -9
- package/src/handshake.ts +1 -1
- package/src/hosted-session.ts +32 -4
- package/src/maintenance.ts +35 -7
- package/src/registry.ts +28 -4
- package/src/runtime/attempt-invalidation.ts +54 -0
- package/src/runtime/background-history.ts +151 -45
- package/src/runtime/background-policy.ts +27 -0
- package/src/runtime/background-tools.ts +389 -0
- package/src/runtime/background.ts +410 -48
- package/src/runtime/cancellation.ts +28 -7
- package/src/runtime/catalog-sources.ts +199 -0
- package/src/runtime/catalog.ts +53 -21
- package/src/runtime/client.ts +22 -2
- package/src/runtime/domain/assignment-inbox.mjs +119 -0
- package/src/runtime/domain/assignment-observation.d.mts +1 -1
- package/src/runtime/domain/assignment-observation.mjs +71 -33
- package/src/runtime/domain/background/process-identity.mjs +20 -2
- package/src/runtime/domain/background/process.mjs +3 -3
- package/src/runtime/domain/background/registry.mjs +89 -4
- package/src/runtime/domain/background/types.mjs +1 -0
- package/src/runtime/domain/background-service/adapter-contract.domain.mjs +83 -0
- package/src/runtime/domain/background-service/adapter-contract.ts +70 -0
- package/src/runtime/domain/background-service/batch.domain.mjs +91 -0
- package/src/runtime/domain/background-service/batch.ts +111 -0
- package/src/runtime/domain/background-service/conditions.domain.mjs +94 -0
- package/src/runtime/domain/background-service/conditions.ts +99 -0
- package/src/runtime/domain/background-service/delivery-observer.domain.mjs +37 -0
- package/src/runtime/domain/background-service/delivery-observer.ts +42 -0
- package/src/runtime/domain/background-service/failures.domain.mjs +209 -0
- package/src/runtime/domain/background-service/failures.ts +212 -0
- package/src/runtime/domain/background-service/goal-provider.domain.mjs +193 -0
- package/src/runtime/domain/background-service/goal-provider.ts +209 -0
- package/src/runtime/domain/background-service/index.domain.mjs +54 -0
- package/src/runtime/domain/background-service/index.ts +55 -0
- package/src/runtime/domain/background-service/logs.domain.mjs +129 -0
- package/src/runtime/domain/background-service/logs.ts +134 -0
- package/src/runtime/domain/background-service/maintenance.domain.mjs +95 -0
- package/src/runtime/domain/background-service/maintenance.ts +98 -0
- package/src/runtime/domain/background-service/managed-authority.domain.mjs +32 -0
- package/src/runtime/domain/background-service/managed-authority.ts +30 -0
- package/src/runtime/domain/background-service/managed-client.domain.mjs +79 -0
- package/src/runtime/domain/background-service/managed-client.ts +73 -0
- package/src/runtime/domain/background-service/managed-frontend.domain.mjs +225 -0
- package/src/runtime/domain/background-service/managed-frontend.ts +176 -0
- package/src/runtime/domain/background-service/navigator-provider.domain.mjs +492 -0
- package/src/runtime/domain/background-service/navigator-provider.ts +485 -0
- package/src/runtime/domain/background-service/observed-wait-client.domain.mjs +6 -0
- package/src/runtime/domain/background-service/observed-wait-client.ts +10 -0
- package/src/runtime/domain/background-service/observed-waits.domain.mjs +4080 -0
- package/src/runtime/domain/background-service/observed-waits.ts +4513 -0
- package/src/runtime/domain/background-service/output.domain.mjs +867 -0
- package/src/runtime/domain/background-service/output.ts +952 -0
- package/src/runtime/domain/background-service/process-identity.domain.mjs +129 -0
- package/src/runtime/domain/background-service/process-identity.ts +134 -0
- package/src/runtime/domain/background-service/process.domain.mjs +512 -0
- package/src/runtime/domain/background-service/process.ts +532 -0
- package/src/runtime/domain/background-service/prompt.domain.mjs +58 -0
- package/src/runtime/domain/background-service/prompt.ts +72 -0
- package/src/runtime/domain/background-service/registry.domain.mjs +460 -0
- package/src/runtime/domain/background-service/registry.ts +450 -0
- package/src/runtime/domain/background-service/remote-task-preset.domain.mjs +67 -0
- package/src/runtime/domain/background-service/remote-task-preset.ts +127 -0
- package/src/runtime/domain/background-service/runtime.domain.mjs +1511 -0
- package/src/runtime/domain/background-service/runtime.ts +1636 -0
- package/src/runtime/domain/background-service/sandbox.domain.mjs +735 -0
- package/src/runtime/domain/background-service/sandbox.ts +913 -0
- package/src/runtime/domain/background-service/shared-callback-batcher.domain.mjs +777 -0
- package/src/runtime/domain/background-service/shared-callback-batcher.ts +956 -0
- package/src/runtime/domain/background-service/shared-execution-policy.domain.mjs +50 -0
- package/src/runtime/domain/background-service/shared-execution-policy.ts +61 -0
- package/src/runtime/domain/background-service/shared-failure-observations.domain.mjs +1078 -0
- package/src/runtime/domain/background-service/shared-failure-observations.ts +1166 -0
- package/src/runtime/domain/background-service/shared-harness-settings.domain.mjs +126 -0
- package/src/runtime/domain/background-service/shared-harness-settings.ts +116 -0
- package/src/runtime/domain/background-service/shared-log-utils.domain.mjs +1223 -0
- package/src/runtime/domain/background-service/shared-log-utils.ts +1492 -0
- package/src/runtime/domain/background-service/shared-navigator-panels.domain.mjs +289 -0
- package/src/runtime/domain/background-service/shared-navigator-panels.ts +272 -0
- package/src/runtime/domain/background-service/shared-navigator.domain.mjs +1930 -0
- package/src/runtime/domain/background-service/shared-navigator.ts +1962 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/assignment-inbox.mjs +144 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/assignment-observation.mjs +189 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/index.domain.mjs +51 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/index.ts +122 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/assignment-changes.domain.mjs +75 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/assignment-changes.ts +73 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/assignment-outcomes.domain.mjs +163 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/assignment-outcomes.ts +174 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/background-parent-callbacks.domain.mjs +66 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/background-parent-callbacks.ts +68 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/background-requests.domain.mjs +87 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/background-requests.ts +90 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/discovery.domain.mjs +97 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/discovery.ts +139 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/errors.domain.mjs +12 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/errors.ts +79 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/operations.domain.mjs +342 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/operations.ts +513 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/outbox.domain.mjs +283 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/outbox.ts +458 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/recovery.domain.mjs +52 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/recovery.ts +55 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/result-supervision.domain.mjs +114 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/result-supervision.ts +140 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/rows.domain.mjs +280 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/rows.ts +442 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/schema.domain.mjs +420 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/schema.ts +441 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/sqlite.domain.mjs +194 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/sqlite.ts +239 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/store.domain.mjs +275 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/store.ts +585 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/subagent-launch.domain.mjs +120 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/subagent-launch.ts +142 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/task-cancellation.domain.mjs +188 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/task-cancellation.ts +224 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/types.domain.mjs +25 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/types.ts +707 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/upgrade.domain.mjs +22 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/upgrade.ts +22 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/validate.domain.mjs +234 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/validate.ts +241 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/waits.domain.mjs +851 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/waits.ts +1424 -0
- package/src/runtime/domain/background-service/shared-permission-blocker.domain.mjs +40 -0
- package/src/runtime/domain/background-service/shared-permission-blocker.ts +48 -0
- package/src/runtime/domain/background-service/shared-render-scheduler.domain.mjs +41 -0
- package/src/runtime/domain/background-service/shared-render-scheduler.ts +47 -0
- package/src/runtime/domain/background-service/shared-sandbox-core.domain.mjs +1531 -0
- package/src/runtime/domain/background-service/shared-sandbox-core.ts +1757 -0
- package/src/runtime/domain/background-service/shared-sandbox-diagnostics.domain.mjs +591 -0
- package/src/runtime/domain/background-service/shared-sandbox-diagnostics.ts +491 -0
- package/src/runtime/domain/background-service/shared-ssh-core/index.domain.mjs +698 -0
- package/src/runtime/domain/background-service/shared-ssh-core/index.ts +979 -0
- package/src/runtime/domain/background-service/shared-stall-detector.domain.mjs +37 -0
- package/src/runtime/domain/background-service/shared-stall-detector.ts +69 -0
- package/src/runtime/domain/background-service/shared-work-client.mjs +303 -0
- package/src/runtime/domain/background-service/stall-attention.domain.mjs +29 -0
- package/src/runtime/domain/background-service/stall-attention.ts +31 -0
- package/src/runtime/domain/background-service/stall.domain.mjs +57 -0
- package/src/runtime/domain/background-service/stall.ts +57 -0
- package/src/runtime/domain/background-service/supervisor/README.md +111 -0
- package/src/runtime/domain/background-service/supervisor/emit-runner.mjs +90 -0
- package/src/runtime/domain/background-service/supervisor/generated/conditions.mjs +96 -0
- package/src/runtime/domain/background-service/supervisor/generated/identity.mjs +95 -0
- package/src/runtime/domain/background-service/supervisor/generated/process-identity.mjs +131 -0
- package/src/runtime/domain/background-service/supervisor/generated/process.mjs +514 -0
- package/src/runtime/domain/background-service/supervisor/generated/runner.mjs +872 -0
- package/src/runtime/domain/background-service/supervisor/generated/store.mjs +609 -0
- package/src/runtime/domain/background-service/supervisor/generated/types.mjs +50 -0
- package/src/runtime/domain/background-service/supervisor/identity.domain.mjs +93 -0
- package/src/runtime/domain/background-service/supervisor/identity.ts +99 -0
- package/src/runtime/domain/background-service/supervisor/index.domain.mjs +22 -0
- package/src/runtime/domain/background-service/supervisor/index.ts +37 -0
- package/src/runtime/domain/background-service/supervisor/invocation.domain.mjs +30 -0
- package/src/runtime/domain/background-service/supervisor/invocation.ts +44 -0
- package/src/runtime/domain/background-service/supervisor/runner.domain.mjs +870 -0
- package/src/runtime/domain/background-service/supervisor/runner.ts +982 -0
- package/src/runtime/domain/background-service/supervisor/store.domain.mjs +605 -0
- package/src/runtime/domain/background-service/supervisor/store.ts +651 -0
- package/src/runtime/domain/background-service/supervisor/supervisor.domain.mjs +721 -0
- package/src/runtime/domain/background-service/supervisor/supervisor.ts +804 -0
- package/src/runtime/domain/background-service/supervisor/types.domain.mjs +48 -0
- package/src/runtime/domain/background-service/supervisor/types.ts +394 -0
- package/src/runtime/domain/background-service/task-diagnostics.domain.mjs +60 -0
- package/src/runtime/domain/background-service/task-diagnostics.ts +71 -0
- package/src/runtime/domain/background-service/tools.domain.mjs +1050 -0
- package/src/runtime/domain/background-service/tools.ts +1142 -0
- package/src/runtime/domain/background-service/types.domain.mjs +5 -0
- package/src/runtime/domain/background-service/types.ts +236 -0
- package/src/runtime/domain/background-service/work-observation.domain.mjs +176 -0
- package/src/runtime/domain/background-service/work-observation.ts +144 -0
- package/src/runtime/domain/catalog/catalog-store.d.mts +9 -1
- package/src/runtime/domain/catalog/catalog-store.mjs +20 -22
- package/src/runtime/domain/coordinator/src/assignment-changes.mjs +75 -0
- package/src/runtime/domain/coordinator/src/assignment-outcomes.mjs +2 -0
- package/src/runtime/domain/coordinator/src/background-parent-callbacks.mjs +65 -0
- package/src/runtime/domain/coordinator/src/background-requests.mjs +86 -0
- package/src/runtime/domain/coordinator/src/discovery.mjs +4 -2
- package/src/runtime/domain/coordinator/src/operations.mjs +44 -4
- package/src/runtime/domain/coordinator/src/result-supervision.mjs +12 -0
- package/src/runtime/domain/coordinator/src/rows.mjs +2 -0
- package/src/runtime/domain/coordinator/src/schema.mjs +73 -21
- package/src/runtime/domain/coordinator/src/store.mjs +32 -3
- package/src/runtime/domain/coordinator/src/subagent-launch.mjs +119 -0
- package/src/runtime/domain/coordinator/src/types.mjs +1 -1
- package/src/runtime/domain/coordinator/src/upgrade.mjs +22 -0
- package/src/runtime/domain/health-observation.d.mts +3 -1
- package/src/runtime/domain/health-observation.mjs +189 -190
- package/src/runtime/domain/log-cursor.d.mts +2 -0
- package/src/runtime/domain/log-cursor.mjs +85 -16
- package/src/runtime/domain/parse.d.mts +4 -1
- package/src/runtime/domain/parse.mjs +50 -5
- package/src/runtime/domain/sandbox-policy/README.md +633 -0
- package/src/runtime/domain/sandbox-policy/background-admission.domain.mjs +83 -0
- package/src/runtime/domain/sandbox-policy/background-admission.ts +75 -0
- package/src/runtime/domain/sandbox-policy/commands.domain.mjs +245 -0
- package/src/runtime/domain/sandbox-policy/commands.ts +336 -0
- package/src/runtime/domain/sandbox-policy/deny-rules.domain.mjs +440 -0
- package/src/runtime/domain/sandbox-policy/deny-rules.ts +620 -0
- package/src/runtime/domain/sandbox-policy/diagnostics-command.domain.mjs +30 -0
- package/src/runtime/domain/sandbox-policy/diagnostics-command.ts +27 -0
- package/src/runtime/domain/sandbox-policy/events.domain.mjs +49 -0
- package/src/runtime/domain/sandbox-policy/events.ts +85 -0
- package/src/runtime/domain/sandbox-policy/files.domain.mjs +153 -0
- package/src/runtime/domain/sandbox-policy/files.ts +224 -0
- package/src/runtime/domain/sandbox-policy/index.domain.mjs +289 -0
- package/src/runtime/domain/sandbox-policy/index.ts +386 -0
- package/src/runtime/domain/sandbox-policy/package.json +66 -0
- package/src/runtime/domain/sandbox-policy/permission-settings.domain.mjs +36 -0
- package/src/runtime/domain/sandbox-policy/permission-settings.ts +46 -0
- package/src/runtime/domain/sandbox-policy/permissions-page.domain.mjs +309 -0
- package/src/runtime/domain/sandbox-policy/permissions-page.ts +295 -0
- package/src/runtime/domain/sandbox-policy/permissions.domain.mjs +98 -0
- package/src/runtime/domain/sandbox-policy/permissions.ts +125 -0
- package/src/runtime/domain/sandbox-policy/policy.domain.mjs +80 -0
- package/src/runtime/domain/sandbox-policy/policy.ts +102 -0
- package/src/runtime/domain/sandbox-policy/preferences.domain.mjs +55 -0
- package/src/runtime/domain/sandbox-policy/preferences.ts +82 -0
- package/src/runtime/domain/sandbox-policy/rules-page.domain.mjs +138 -0
- package/src/runtime/domain/sandbox-policy/rules-page.ts +176 -0
- package/src/runtime/domain/sandbox-policy/session-permissions.domain.mjs +22 -0
- package/src/runtime/domain/sandbox-policy/session-permissions.ts +24 -0
- package/src/runtime/domain/sandbox-policy/shared-harness-settings.domain.mjs +126 -0
- package/src/runtime/domain/sandbox-policy/shared-harness-settings.ts +116 -0
- package/src/runtime/domain/sandbox-policy/shared-permission-blocker.domain.mjs +40 -0
- package/src/runtime/domain/sandbox-policy/shared-permission-blocker.ts +48 -0
- package/src/runtime/domain/sandbox-policy/shared-sandbox-core.domain.mjs +1531 -0
- package/src/runtime/domain/sandbox-policy/shared-sandbox-core.ts +1757 -0
- package/src/runtime/domain/sandbox-policy/shared-sandbox-diagnostics.domain.mjs +591 -0
- package/src/runtime/domain/sandbox-policy/shared-sandbox-diagnostics.ts +491 -0
- package/src/runtime/domain/sandbox-policy/shared-task-application.domain.mjs +185 -0
- package/src/runtime/domain/sandbox-policy/shared-task-application.ts +185 -0
- package/src/runtime/domain/sandbox-policy/shared-task-apply-patch.domain.mjs +416 -0
- package/src/runtime/domain/sandbox-policy/shared-task-apply-patch.ts +409 -0
- package/src/runtime/domain/sandbox-policy/shared-task-exec.domain.mjs +325 -0
- package/src/runtime/domain/sandbox-policy/shared-task-exec.ts +335 -0
- package/src/runtime/domain/sandbox-policy/shared-task-files.domain.mjs +346 -0
- package/src/runtime/domain/sandbox-policy/shared-task-files.ts +342 -0
- package/src/runtime/domain/sandbox-policy/shared-task-process-identity.domain.mjs +140 -0
- package/src/runtime/domain/sandbox-policy/shared-task-process-identity.ts +126 -0
- package/src/runtime/domain/sandbox-policy/shared-task-process-list.domain.mjs +220 -0
- package/src/runtime/domain/sandbox-policy/shared-task-process-list.ts +209 -0
- package/src/runtime/domain/sandbox-policy/shared-task-sandbox.domain.mjs +227 -0
- package/src/runtime/domain/sandbox-policy/shared-task-sandbox.ts +224 -0
- package/src/runtime/domain/sandbox-policy/shared-task-tools.domain.mjs +92 -0
- package/src/runtime/domain/sandbox-policy/shared-task-tools.ts +123 -0
- package/src/runtime/domain/sandbox-policy/shell.domain.mjs +93 -0
- package/src/runtime/domain/sandbox-policy/shell.ts +129 -0
- package/src/runtime/domain/sandbox-policy/state.domain.mjs +307 -0
- package/src/runtime/domain/sandbox-policy/state.ts +408 -0
- package/src/runtime/domain/sandbox-policy/status.domain.mjs +64 -0
- package/src/runtime/domain/sandbox-policy/status.ts +76 -0
- package/src/runtime/domain/sandbox-policy/subagent-admission.domain.mjs +69 -0
- package/src/runtime/domain/sandbox-policy/subagent-admission.ts +60 -0
- package/src/runtime/domain/subagents/CONTEXT.md +202 -0
- package/src/runtime/domain/subagents/PRODUCT.md +49 -0
- package/src/runtime/domain/subagents/README.md +201 -0
- package/src/runtime/domain/subagents/agent-catalog.mjs +64 -0
- package/src/runtime/domain/subagents/agent-commands.domain.mjs +822 -0
- package/src/runtime/domain/subagents/agent-commands.ts +905 -0
- package/src/runtime/domain/subagents/agent-inspection.domain.mjs +398 -0
- package/src/runtime/domain/subagents/agent-inspection.ts +574 -0
- package/src/runtime/domain/subagents/agent-operations.domain.mjs +40 -0
- package/src/runtime/domain/subagents/agent-operations.ts +61 -0
- package/src/runtime/domain/subagents/agent-session-settings.domain.mjs +112 -0
- package/src/runtime/domain/subagents/agent-session-settings.ts +118 -0
- package/src/runtime/domain/subagents/agents-catalog-tool.domain.mjs +84 -0
- package/src/runtime/domain/subagents/agents-catalog-tool.ts +118 -0
- package/src/runtime/domain/subagents/assignment-outcomes.domain.mjs +276 -0
- package/src/runtime/domain/subagents/assignment-outcomes.ts +212 -0
- package/src/runtime/domain/subagents/assignment-projection.mjs +261 -0
- package/src/runtime/domain/subagents/assignment-report.domain.mjs +174 -0
- package/src/runtime/domain/subagents/assignment-report.ts +156 -0
- package/src/runtime/domain/subagents/batch.mjs +275 -0
- package/src/runtime/domain/subagents/callback-fields.domain.mjs +72 -0
- package/src/runtime/domain/subagents/callback-fields.ts +95 -0
- package/src/runtime/domain/subagents/capacity.mjs +108 -0
- package/src/runtime/domain/subagents/catalog-editor.domain.mjs +98 -0
- package/src/runtime/domain/subagents/catalog-editor.ts +125 -0
- package/src/runtime/domain/subagents/catalog-host-admission.domain.mjs +104 -0
- package/src/runtime/domain/subagents/catalog-host-admission.ts +85 -0
- package/src/runtime/domain/subagents/catalog-identity.domain.mjs +222 -0
- package/src/runtime/domain/subagents/catalog-identity.ts +258 -0
- package/src/runtime/domain/subagents/catalog-overlay.domain.mjs +9 -0
- package/src/runtime/domain/subagents/catalog-overlay.ts +10 -0
- package/src/runtime/domain/subagents/catalog-preferences.domain.mjs +164 -0
- package/src/runtime/domain/subagents/catalog-preferences.ts +139 -0
- package/src/runtime/domain/subagents/catalog-resolver.domain.mjs +366 -0
- package/src/runtime/domain/subagents/catalog-resolver.ts +540 -0
- package/src/runtime/domain/subagents/catalog-runtime.domain.mjs +570 -0
- package/src/runtime/domain/subagents/catalog-runtime.ts +680 -0
- package/src/runtime/domain/subagents/catalog-schema.domain.mjs +1331 -0
- package/src/runtime/domain/subagents/catalog-schema.ts +1563 -0
- package/src/runtime/domain/subagents/catalog-skill-edits.domain.mjs +95 -0
- package/src/runtime/domain/subagents/catalog-skill-edits.ts +116 -0
- package/src/runtime/domain/subagents/catalog-store.domain.mjs +808 -0
- package/src/runtime/domain/subagents/catalog-store.ts +1006 -0
- package/src/runtime/domain/subagents/catalog-ui.domain.mjs +651 -0
- package/src/runtime/domain/subagents/catalog-ui.ts +611 -0
- package/src/runtime/domain/subagents/child-apply-patch.domain.mjs +13 -0
- package/src/runtime/domain/subagents/child-apply-patch.ts +13 -0
- package/src/runtime/domain/subagents/child-codemode.domain.mjs +16 -0
- package/src/runtime/domain/subagents/child-codemode.ts +17 -0
- package/src/runtime/domain/subagents/child-dependencies.mjs +193 -0
- package/src/runtime/domain/subagents/child-incidents.domain.mjs +170 -0
- package/src/runtime/domain/subagents/child-incidents.ts +169 -0
- package/src/runtime/domain/subagents/child-operations.domain.mjs +986 -0
- package/src/runtime/domain/subagents/child-operations.ts +1191 -0
- package/src/runtime/domain/subagents/child-ownership.domain.mjs +205 -0
- package/src/runtime/domain/subagents/child-ownership.ts +160 -0
- package/src/runtime/domain/subagents/child-preflight.mjs +38 -0
- package/src/runtime/domain/subagents/child-process-list.domain.mjs +7 -0
- package/src/runtime/domain/subagents/child-process-list.ts +8 -0
- package/src/runtime/domain/subagents/child-runtime.mjs +67 -0
- package/src/runtime/domain/subagents/child-steer.domain.mjs +109 -0
- package/src/runtime/domain/subagents/child-steer.ts +102 -0
- package/src/runtime/domain/subagents/cleanup.domain.mjs +818 -0
- package/src/runtime/domain/subagents/cleanup.ts +1017 -0
- package/src/runtime/domain/subagents/codex-import.domain.mjs +575 -0
- package/src/runtime/domain/subagents/codex-import.ts +717 -0
- package/src/runtime/domain/subagents/completion.domain.mjs +6 -0
- package/src/runtime/domain/subagents/completion.mjs +152 -0
- package/src/runtime/domain/subagents/completion.ts +11 -0
- package/src/runtime/domain/subagents/config.domain.mjs +248 -0
- package/src/runtime/domain/subagents/config.json +15 -0
- package/src/runtime/domain/subagents/config.ts +328 -0
- package/src/runtime/domain/subagents/continuation-authority.domain.mjs +38 -0
- package/src/runtime/domain/subagents/continuation-authority.ts +31 -0
- package/src/runtime/domain/subagents/continuation-runtime.domain.mjs +89 -0
- package/src/runtime/domain/subagents/continuation-runtime.ts +88 -0
- package/src/runtime/domain/subagents/continuation.domain.mjs +942 -0
- package/src/runtime/domain/subagents/continuation.ts +1051 -0
- package/src/runtime/domain/subagents/delegation.domain.mjs +19 -0
- package/src/runtime/domain/subagents/delegation.ts +24 -0
- package/src/runtime/domain/subagents/effective-settings.domain.mjs +130 -0
- package/src/runtime/domain/subagents/effective-settings.ts +184 -0
- package/src/runtime/domain/subagents/extensions.domain.mjs +6 -0
- package/src/runtime/domain/subagents/extensions.mjs +164 -0
- package/src/runtime/domain/subagents/extensions.ts +19 -0
- package/src/runtime/domain/subagents/failures.domain.mjs +362 -0
- package/src/runtime/domain/subagents/failures.ts +319 -0
- package/src/runtime/domain/subagents/finalization.domain.mjs +168 -0
- package/src/runtime/domain/subagents/finalization.ts +218 -0
- package/src/runtime/domain/subagents/git-remotes.domain.mjs +351 -0
- package/src/runtime/domain/subagents/git-remotes.ts +413 -0
- package/src/runtime/domain/subagents/git-workspace.domain.mjs +337 -0
- package/src/runtime/domain/subagents/git-workspace.ts +430 -0
- package/src/runtime/domain/subagents/goal-provider.domain.mjs +125 -0
- package/src/runtime/domain/subagents/goal-provider.ts +132 -0
- package/src/runtime/domain/subagents/health-observation.domain.mjs +617 -0
- package/src/runtime/domain/subagents/health-observation.ts +818 -0
- package/src/runtime/domain/subagents/health-surface.mjs +284 -0
- package/src/runtime/domain/subagents/health.domain.mjs +261 -0
- package/src/runtime/domain/subagents/health.ts +343 -0
- package/src/runtime/domain/subagents/historical-attention.domain.mjs +37 -0
- package/src/runtime/domain/subagents/historical-attention.ts +35 -0
- package/src/runtime/domain/subagents/incident-model.domain.mjs +322 -0
- package/src/runtime/domain/subagents/incident-model.ts +358 -0
- package/src/runtime/domain/subagents/index.domain.mjs +4731 -0
- package/src/runtime/domain/subagents/index.ts +4781 -0
- package/src/runtime/domain/subagents/launch-abort.domain.mjs +13 -0
- package/src/runtime/domain/subagents/launch-abort.ts +21 -0
- package/src/runtime/domain/subagents/launch-context.domain.mjs +24 -0
- package/src/runtime/domain/subagents/launch-context.ts +23 -0
- package/src/runtime/domain/subagents/launch-digest.mjs +6 -0
- package/src/runtime/domain/subagents/lifecycle.domain.mjs +265 -0
- package/src/runtime/domain/subagents/lifecycle.ts +360 -0
- package/src/runtime/domain/subagents/list.domain.mjs +2 -0
- package/src/runtime/domain/subagents/list.mjs +152 -0
- package/src/runtime/domain/subagents/list.ts +19 -0
- package/src/runtime/domain/subagents/log-cursor.domain.mjs +217 -0
- package/src/runtime/domain/subagents/log-cursor.ts +268 -0
- package/src/runtime/domain/subagents/managed-background-capability.domain.mjs +10 -0
- package/src/runtime/domain/subagents/managed-background-capability.ts +9 -0
- package/src/runtime/domain/subagents/managed-failure-worker.mjs +36 -0
- package/src/runtime/domain/subagents/managed-launch-bootstrap.mjs +48 -0
- package/src/runtime/domain/subagents/managed-launch-client.domain.mjs +75 -0
- package/src/runtime/domain/subagents/managed-launch-client.ts +59 -0
- package/src/runtime/domain/subagents/managed-launch-host.domain.mjs +627 -0
- package/src/runtime/domain/subagents/managed-launch-host.ts +504 -0
- package/src/runtime/domain/subagents/managed-launch-journal.mjs +17 -0
- package/src/runtime/domain/subagents/managed-launch-ownership.domain.mjs +29 -0
- package/src/runtime/domain/subagents/managed-launch-ownership.ts +22 -0
- package/src/runtime/domain/subagents/managed-launch-port.domain.mjs +2 -0
- package/src/runtime/domain/subagents/managed-launch-port.ts +25 -0
- package/src/runtime/domain/subagents/managed-launch-recovery.domain.mjs +29 -0
- package/src/runtime/domain/subagents/managed-launch-recovery.ts +45 -0
- package/src/runtime/domain/subagents/managed-worker-bridge.domain.mjs +63 -0
- package/src/runtime/domain/subagents/managed-worker-bridge.ts +48 -0
- package/src/runtime/domain/subagents/managed-worker.mjs +13 -0
- package/src/runtime/domain/subagents/model-resolution-core.domain.mjs +822 -0
- package/src/runtime/domain/subagents/model-resolution-core.ts +1074 -0
- package/src/runtime/domain/subagents/model-resolution.domain.mjs +22 -0
- package/src/runtime/domain/subagents/model-resolution.ts +32 -0
- package/src/runtime/domain/subagents/navigator.domain.mjs +6 -0
- package/src/runtime/domain/subagents/navigator.mjs +1233 -0
- package/src/runtime/domain/subagents/navigator.ts +39 -0
- package/src/runtime/domain/subagents/operation-bridge-types.domain.mjs +1012 -0
- package/src/runtime/domain/subagents/operation-bridge-types.ts +1156 -0
- package/src/runtime/domain/subagents/outage-observations.domain.mjs +84 -0
- package/src/runtime/domain/subagents/outage-observations.ts +73 -0
- package/src/runtime/domain/subagents/output-payload.domain.mjs +767 -0
- package/src/runtime/domain/subagents/output-payload.ts +987 -0
- package/src/runtime/domain/subagents/owned-exit.domain.mjs +12 -0
- package/src/runtime/domain/subagents/owned-exit.ts +12 -0
- package/src/runtime/domain/subagents/package.json +86 -0
- package/src/runtime/domain/subagents/park-checkpoint.domain.mjs +55 -0
- package/src/runtime/domain/subagents/park-checkpoint.ts +61 -0
- package/src/runtime/domain/subagents/parse.domain.mjs +1218 -0
- package/src/runtime/domain/subagents/parse.ts +1451 -0
- package/src/runtime/domain/subagents/permission-policy.domain.mjs +232 -0
- package/src/runtime/domain/subagents/permission-policy.ts +291 -0
- package/src/runtime/domain/subagents/process-identity.mjs +33 -0
- package/src/runtime/domain/subagents/registry.domain.mjs +1584 -0
- package/src/runtime/domain/subagents/registry.ts +1904 -0
- package/src/runtime/domain/subagents/role-assignment.domain.mjs +104 -0
- package/src/runtime/domain/subagents/role-assignment.ts +141 -0
- package/src/runtime/domain/subagents/roles/role.architect.md +13 -0
- package/src/runtime/domain/subagents/roles/role.developer.md +16 -0
- package/src/runtime/domain/subagents/roles/role.explorer.md +13 -0
- package/src/runtime/domain/subagents/roles/role.product-manager.md +13 -0
- package/src/runtime/domain/subagents/roles/role.researcher.md +13 -0
- package/src/runtime/domain/subagents/roles/role.reviewer.md +13 -0
- package/src/runtime/domain/subagents/roles/role.writer.md +12 -0
- package/src/runtime/domain/subagents/sandbox.domain.mjs +64 -0
- package/src/runtime/domain/subagents/sandbox.ts +92 -0
- package/src/runtime/domain/subagents/session-selection.domain.mjs +32 -0
- package/src/runtime/domain/subagents/session-selection.ts +35 -0
- package/src/runtime/domain/subagents/session-store.domain.mjs +489 -0
- package/src/runtime/domain/subagents/session-store.ts +468 -0
- package/src/runtime/domain/subagents/settings-page.domain.mjs +313 -0
- package/src/runtime/domain/subagents/settings-page.ts +363 -0
- package/src/runtime/domain/subagents/shared-callback-batcher.domain.mjs +777 -0
- package/src/runtime/domain/subagents/shared-callback-batcher.ts +956 -0
- package/src/runtime/domain/subagents/shared-catalog.domain.mjs +70 -0
- package/src/runtime/domain/subagents/shared-catalog.ts +61 -0
- package/src/runtime/domain/subagents/shared-execution-policy.domain.mjs +50 -0
- package/src/runtime/domain/subagents/shared-execution-policy.ts +61 -0
- package/src/runtime/domain/subagents/shared-failure-observations.domain.mjs +1078 -0
- package/src/runtime/domain/subagents/shared-failure-observations.ts +1166 -0
- package/src/runtime/domain/subagents/shared-harness-settings.domain.mjs +126 -0
- package/src/runtime/domain/subagents/shared-harness-settings.ts +116 -0
- package/src/runtime/domain/subagents/shared-log-utils.domain.mjs +1223 -0
- package/src/runtime/domain/subagents/shared-log-utils.ts +1492 -0
- package/src/runtime/domain/subagents/shared-navigator-panels.domain.mjs +289 -0
- package/src/runtime/domain/subagents/shared-navigator-panels.ts +272 -0
- package/src/runtime/domain/subagents/shared-navigator.domain.mjs +1930 -0
- package/src/runtime/domain/subagents/shared-navigator.ts +1962 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/assignment-inbox.mjs +144 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/assignment-observation.mjs +189 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/index.domain.mjs +51 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/index.ts +122 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/assignment-changes.domain.mjs +75 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/assignment-changes.ts +73 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/assignment-outcomes.domain.mjs +163 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/assignment-outcomes.ts +174 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/background-parent-callbacks.domain.mjs +66 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/background-parent-callbacks.ts +68 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/background-requests.domain.mjs +87 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/background-requests.ts +90 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/discovery.domain.mjs +97 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/discovery.ts +139 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/errors.domain.mjs +12 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/errors.ts +79 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/operations.domain.mjs +342 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/operations.ts +513 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/outbox.domain.mjs +283 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/outbox.ts +458 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/recovery.domain.mjs +52 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/recovery.ts +55 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/result-supervision.domain.mjs +114 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/result-supervision.ts +140 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/rows.domain.mjs +280 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/rows.ts +442 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/schema.domain.mjs +420 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/schema.ts +441 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/sqlite.domain.mjs +194 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/sqlite.ts +239 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/store.domain.mjs +275 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/store.ts +585 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/subagent-launch.domain.mjs +120 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/subagent-launch.ts +142 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/task-cancellation.domain.mjs +188 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/task-cancellation.ts +224 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/types.domain.mjs +25 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/types.ts +707 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/upgrade.domain.mjs +22 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/upgrade.ts +22 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/validate.domain.mjs +234 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/validate.ts +241 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/waits.domain.mjs +851 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/waits.ts +1424 -0
- package/src/runtime/domain/subagents/shared-permission-blocker.domain.mjs +40 -0
- package/src/runtime/domain/subagents/shared-permission-blocker.ts +48 -0
- package/src/runtime/domain/subagents/shared-render-scheduler.domain.mjs +41 -0
- package/src/runtime/domain/subagents/shared-render-scheduler.ts +47 -0
- package/src/runtime/domain/subagents/shared-sandbox-core.domain.mjs +1531 -0
- package/src/runtime/domain/subagents/shared-sandbox-core.ts +1757 -0
- package/src/runtime/domain/subagents/shared-sandbox-diagnostics.domain.mjs +591 -0
- package/src/runtime/domain/subagents/shared-sandbox-diagnostics.ts +491 -0
- package/src/runtime/domain/subagents/shared-stall-detector.domain.mjs +37 -0
- package/src/runtime/domain/subagents/shared-stall-detector.ts +69 -0
- package/src/runtime/domain/subagents/shared-task-application.domain.mjs +185 -0
- package/src/runtime/domain/subagents/shared-task-application.ts +185 -0
- package/src/runtime/domain/subagents/shared-task-apply-patch.domain.mjs +416 -0
- package/src/runtime/domain/subagents/shared-task-apply-patch.ts +409 -0
- package/src/runtime/domain/subagents/shared-task-exec.domain.mjs +325 -0
- package/src/runtime/domain/subagents/shared-task-exec.ts +335 -0
- package/src/runtime/domain/subagents/shared-task-files.domain.mjs +346 -0
- package/src/runtime/domain/subagents/shared-task-files.ts +342 -0
- package/src/runtime/domain/subagents/shared-task-process-identity.domain.mjs +140 -0
- package/src/runtime/domain/subagents/shared-task-process-identity.ts +126 -0
- package/src/runtime/domain/subagents/shared-task-process-list.domain.mjs +220 -0
- package/src/runtime/domain/subagents/shared-task-process-list.ts +209 -0
- package/src/runtime/domain/subagents/shared-task-sandbox.domain.mjs +227 -0
- package/src/runtime/domain/subagents/shared-task-sandbox.ts +224 -0
- package/src/runtime/domain/subagents/shared-task-tools.domain.mjs +92 -0
- package/src/runtime/domain/subagents/shared-task-tools.ts +123 -0
- package/src/runtime/domain/subagents/shared-work-client.mjs +303 -0
- package/src/runtime/domain/subagents/shared-worktree-context.domain.mjs +142 -0
- package/src/runtime/domain/subagents/shared-worktree-context.ts +158 -0
- package/src/runtime/domain/subagents/skill-picker.domain.mjs +316 -0
- package/src/runtime/domain/subagents/skill-picker.ts +353 -0
- package/src/runtime/domain/subagents/skills.domain.mjs +138 -0
- package/src/runtime/domain/subagents/skills.ts +183 -0
- package/src/runtime/domain/subagents/spawn.domain.mjs +72 -0
- package/src/runtime/domain/subagents/spawn.ts +80 -0
- package/src/runtime/domain/subagents/stop.domain.mjs +184 -0
- package/src/runtime/domain/subagents/stop.ts +217 -0
- package/src/runtime/domain/subagents/subagent-tools.domain.mjs +101 -0
- package/src/runtime/domain/subagents/subagent-tools.ts +137 -0
- package/src/runtime/domain/subagents/task-guard.domain.mjs +163 -0
- package/src/runtime/domain/subagents/task-guard.ts +144 -0
- package/src/runtime/domain/subagents/task-policy.domain.mjs +201 -0
- package/src/runtime/domain/subagents/task-policy.ts +236 -0
- package/src/runtime/domain/subagents/task-runtime.mjs +53 -0
- package/src/runtime/domain/subagents/task-tool-owner.domain.mjs +18 -0
- package/src/runtime/domain/subagents/task-tool-owner.ts +21 -0
- package/src/runtime/domain/subagents/thinking.domain.mjs +22 -0
- package/src/runtime/domain/subagents/thinking.ts +28 -0
- package/src/runtime/domain/subagents/tier-policy.domain.mjs +75 -0
- package/src/runtime/domain/subagents/tier-policy.ts +126 -0
- package/src/runtime/domain/subagents/timing-notifications.domain.mjs +51 -0
- package/src/runtime/domain/subagents/timing-notifications.ts +37 -0
- package/src/runtime/domain/subagents/timing.domain.mjs +487 -0
- package/src/runtime/domain/subagents/timing.ts +634 -0
- package/src/runtime/domain/subagents/tools.domain.mjs +558 -0
- package/src/runtime/domain/subagents/tools.ts +629 -0
- package/src/runtime/domain/subagents/widget.domain.mjs +6 -0
- package/src/runtime/domain/subagents/widget.mjs +246 -0
- package/src/runtime/domain/subagents/widget.ts +30 -0
- package/src/runtime/domain/subagents/work-observation.domain.mjs +316 -0
- package/src/runtime/domain/subagents/work-observation.ts +248 -0
- package/src/runtime/domain/subagents/worker-catalog.domain.mjs +120 -0
- package/src/runtime/domain/subagents/worker-catalog.ts +162 -0
- package/src/runtime/domain/subagents/worker-operations-host.domain.mjs +1009 -0
- package/src/runtime/domain/subagents/worker-operations-host.ts +1238 -0
- package/src/runtime/domain/subagents/worker-waits.domain.mjs +2336 -0
- package/src/runtime/domain/subagents/worker-waits.ts +2878 -0
- package/src/runtime/domain/subagents/workspace-scope.domain.mjs +52 -0
- package/src/runtime/domain/subagents/workspace-scope.ts +50 -0
- package/src/runtime/health-config.ts +27 -11
- package/src/runtime/log-checkpoints.ts +117 -0
- package/src/runtime/mutation-store.ts +5 -4
- package/src/runtime/queries.ts +27 -3
- package/src/runtime/query-executor.ts +178 -34
- package/src/runtime/query-worker.mjs +119 -22
- package/src/runtime/read-model.ts +939 -113
- package/src/runtime/read-watchdog-probe.ts +4 -0
- package/src/runtime/result-supervision.ts +188 -16
- package/src/runtime/source-watch.ts +175 -0
- package/src/runtime/subagent-launch.ts +73 -0
- package/src/runtime/work-budget.ts +130 -0
- package/src/runtime/work-client.d.mts +8 -0
- package/src/runtime/work-client.mjs +150 -7
- package/src/server.ts +185 -22
- package/src/session-activity.ts +26 -4
- package/src/version.ts +1 -1
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
// Generated fixed launch domain from packages/pi-better-subagents/skills.ts. Do not edit directly.
|
|
2
|
+
/**
|
|
3
|
+
* Skill exposure for one subagent launch (#664).
|
|
4
|
+
*
|
|
5
|
+
* A child launched by `subagent_spawn` otherwise inherits the whole user-level
|
|
6
|
+
* skills catalog, which is most of a long system prompt even when the task names
|
|
7
|
+
* the one `SKILL.md` it needs by path. Pi's CLI has exactly three observable
|
|
8
|
+
* states, and this module maps a launch onto them:
|
|
9
|
+
*
|
|
10
|
+
* | Choice | Child argv | Meaning |
|
|
11
|
+
* | --- | --- | --- |
|
|
12
|
+
* | absent | (no flag) | discovery of the user catalog |
|
|
13
|
+
* | `[]` | `--no-skills` | no skills at all |
|
|
14
|
+
* | `["/abs/SKILL.md", …]` | `--no-skills --skill <path>…` | exactly those skills |
|
|
15
|
+
*
|
|
16
|
+
* An absent value therefore means "inherit", an empty array means "none", and a
|
|
17
|
+
* non-empty array means "exactly these". The three cases stay distinct because
|
|
18
|
+
* `[]` is a real choice, not a missing one.
|
|
19
|
+
*
|
|
20
|
+
* `exclude_skills` is deliberately not part of this contract: Pi cannot remove a
|
|
21
|
+
* single entry from a discovered catalog without also taking over discovery.
|
|
22
|
+
*/
|
|
23
|
+
import { isAbsolute, resolve } from "node:path";
|
|
24
|
+
/**
|
|
25
|
+
* Turn the saved global `defaultSkills` value into the same three states a
|
|
26
|
+
* launch uses. An absent key and `null` both mean discovery; `[]` is the
|
|
27
|
+
* explicit "none" choice and paths are exactly those skills.
|
|
28
|
+
*/
|
|
29
|
+
export function configuredSkillExposure(value) {
|
|
30
|
+
if (value === undefined)
|
|
31
|
+
return { mode: "inherit", paths: [], source: "default" };
|
|
32
|
+
const paths = normalizeSkillExposure(value, "config defaultSkills");
|
|
33
|
+
if (paths === undefined)
|
|
34
|
+
return { mode: "inherit", paths: [], source: "config" };
|
|
35
|
+
if (paths.length === 0)
|
|
36
|
+
return { mode: "none", paths: [], source: "config" };
|
|
37
|
+
return { mode: "explicit", paths, source: "config" };
|
|
38
|
+
}
|
|
39
|
+
const LABELS = {
|
|
40
|
+
launch: "skills",
|
|
41
|
+
catalog: "the catalog definition's skills",
|
|
42
|
+
session: "session skills default",
|
|
43
|
+
config: "config defaultSkills",
|
|
44
|
+
};
|
|
45
|
+
/**
|
|
46
|
+
* Shape-only validation: `undefined`/`null` mean "not set", and an array of
|
|
47
|
+
* non-empty strings is accepted as written. Absolutizing happens later, because
|
|
48
|
+
* the workspace a relative path belongs to is only known once it is resolved.
|
|
49
|
+
*/
|
|
50
|
+
export function normalizeSkillExposure(value, label) {
|
|
51
|
+
if (value === undefined || value === null)
|
|
52
|
+
return undefined;
|
|
53
|
+
if (!Array.isArray(value)) {
|
|
54
|
+
throw new Error(`${label} must be an array of absolute paths to a SKILL.md file or a skill directory. ` +
|
|
55
|
+
`Omit it to inherit skill discovery, or pass [] to load no skills.`);
|
|
56
|
+
}
|
|
57
|
+
return value.map((entry, index) => {
|
|
58
|
+
if (typeof entry !== "string" || entry.trim() === "") {
|
|
59
|
+
throw new Error(`${label}[${index}] must be a non-empty path to a SKILL.md file or a skill directory.`);
|
|
60
|
+
}
|
|
61
|
+
return entry.trim();
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
/** Resolve paths against the child's workspace so a frozen recipe replays the same files. */
|
|
65
|
+
export function absolutizeSkillPaths(paths, cwd) {
|
|
66
|
+
return paths.map((path) => {
|
|
67
|
+
if (cwd === undefined)
|
|
68
|
+
return isAbsolute(path) ? resolve(path) : path;
|
|
69
|
+
return isAbsolute(path) ? resolve(path) : resolve(cwd, path);
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Resolve the effective exposure for an attempt.
|
|
74
|
+
*
|
|
75
|
+
* Precedence, highest first: the frozen recipe (continuation), the launch
|
|
76
|
+
* option, the catalog role/agent choice, the current-session default, the saved
|
|
77
|
+
* global config default, discovery. Every level distinguishes "not set" from
|
|
78
|
+
* `[]`; an absent session override falls through, a present one decides even
|
|
79
|
+
* when it means discovery.
|
|
80
|
+
*/
|
|
81
|
+
export function resolveSkillExposure(input) {
|
|
82
|
+
if (input.saved) {
|
|
83
|
+
// A recipe written before this option existed has no key at all. That is
|
|
84
|
+
// the same "not set" the launch level uses, so it keeps discovery instead
|
|
85
|
+
// of reading as an explicit "none".
|
|
86
|
+
if (input.saved.paths === undefined)
|
|
87
|
+
return { mode: "inherit", paths: [], source: "recipe" };
|
|
88
|
+
return exposureFrom([...input.saved.paths], "recipe");
|
|
89
|
+
}
|
|
90
|
+
for (const source of ["launch", "catalog"]) {
|
|
91
|
+
const value = source === "launch" ? input.requested : input.catalog;
|
|
92
|
+
const normalized = normalizeSkillExposure(value, LABELS[source]);
|
|
93
|
+
if (normalized === undefined)
|
|
94
|
+
continue;
|
|
95
|
+
return exposureFrom(absolutizeSkillPaths(normalized, input.cwd), source);
|
|
96
|
+
}
|
|
97
|
+
if (input.session) {
|
|
98
|
+
const normalized = normalizeSkillExposure(input.session.value, LABELS.session);
|
|
99
|
+
if (normalized === undefined)
|
|
100
|
+
return { mode: "inherit", paths: [], source: "session" };
|
|
101
|
+
return exposureFrom(absolutizeSkillPaths(normalized, input.cwd), "session");
|
|
102
|
+
}
|
|
103
|
+
const configured = normalizeSkillExposure(input.configured, LABELS.config);
|
|
104
|
+
if (configured !== undefined)
|
|
105
|
+
return exposureFrom(absolutizeSkillPaths(configured, input.cwd), "config");
|
|
106
|
+
return { mode: "inherit", paths: [], source: "default" };
|
|
107
|
+
}
|
|
108
|
+
function exposureFrom(paths, source) {
|
|
109
|
+
if (paths.length === 0)
|
|
110
|
+
return { mode: "none", paths: [], source };
|
|
111
|
+
return { mode: "explicit", paths, source };
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* The child's argv for this exposure, in flag order.
|
|
115
|
+
*
|
|
116
|
+
* `inherit` emits nothing at all, which is what keeps every existing launch
|
|
117
|
+
* byte-identical. The other two states always disable discovery first; Pi merges
|
|
118
|
+
* `--skill` into that reduced set rather than re-enabling discovery.
|
|
119
|
+
*/
|
|
120
|
+
export function skillLaunchArgs(exposure) {
|
|
121
|
+
if (exposure.mode === "inherit")
|
|
122
|
+
return [];
|
|
123
|
+
return ["--no-skills", ...exposure.paths.flatMap((path) => ["--skill", path])];
|
|
124
|
+
}
|
|
125
|
+
/** One line for a launch confirmation or a continuation message. */
|
|
126
|
+
export function describeSkillExposure(exposure) {
|
|
127
|
+
if (exposure.mode === "inherit") {
|
|
128
|
+
// An ordinary launch chose nothing, so naming a source would only add
|
|
129
|
+
// noise. A session override that chose discovery is different: the user
|
|
130
|
+
// needs to see that the saved path list is not in effect.
|
|
131
|
+
const source = exposure.source === "session" ? " · source session" : "";
|
|
132
|
+
return `Skills: discovery (user catalog)${source}`;
|
|
133
|
+
}
|
|
134
|
+
const detail = exposure.mode === "none"
|
|
135
|
+
? "none (--no-skills)"
|
|
136
|
+
: `${exposure.paths.length} explicit (${exposure.paths.join(", ")})`;
|
|
137
|
+
return `Skills: ${detail} · source ${exposure.source}`;
|
|
138
|
+
}
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Skill exposure for one subagent launch (#664).
|
|
3
|
+
*
|
|
4
|
+
* A child launched by `subagent_spawn` otherwise inherits the whole user-level
|
|
5
|
+
* skills catalog, which is most of a long system prompt even when the task names
|
|
6
|
+
* the one `SKILL.md` it needs by path. Pi's CLI has exactly three observable
|
|
7
|
+
* states, and this module maps a launch onto them:
|
|
8
|
+
*
|
|
9
|
+
* | Choice | Child argv | Meaning |
|
|
10
|
+
* | --- | --- | --- |
|
|
11
|
+
* | absent | (no flag) | discovery of the user catalog |
|
|
12
|
+
* | `[]` | `--no-skills` | no skills at all |
|
|
13
|
+
* | `["/abs/SKILL.md", …]` | `--no-skills --skill <path>…` | exactly those skills |
|
|
14
|
+
*
|
|
15
|
+
* An absent value therefore means "inherit", an empty array means "none", and a
|
|
16
|
+
* non-empty array means "exactly these". The three cases stay distinct because
|
|
17
|
+
* `[]` is a real choice, not a missing one.
|
|
18
|
+
*
|
|
19
|
+
* `exclude_skills` is deliberately not part of this contract: Pi cannot remove a
|
|
20
|
+
* single entry from a discovered catalog without also taking over discovery.
|
|
21
|
+
*/
|
|
22
|
+
import { isAbsolute, resolve } from "node:path";
|
|
23
|
+
|
|
24
|
+
export type SkillExposureMode = "inherit" | "none" | "explicit";
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Where the effective choice came from. `recipe` is a continuation replaying a
|
|
28
|
+
* frozen launch, and `default` is the ultimate fallback: discovery.
|
|
29
|
+
*/
|
|
30
|
+
export type SkillExposureSource = "launch" | "catalog" | "session" | "config" | "default" | "recipe";
|
|
31
|
+
|
|
32
|
+
export interface SkillExposure {
|
|
33
|
+
mode: SkillExposureMode;
|
|
34
|
+
/** Absolute paths, in the order the flag appears. Empty unless `explicit`. */
|
|
35
|
+
paths: readonly string[];
|
|
36
|
+
source: SkillExposureSource;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export interface ConfiguredSkillExposure {
|
|
40
|
+
mode: SkillExposureMode;
|
|
41
|
+
paths: string[];
|
|
42
|
+
/** `config` when the key is present (including null/[]), `default` when absent. */
|
|
43
|
+
source: "config" | "default";
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Turn the saved global `defaultSkills` value into the same three states a
|
|
48
|
+
* launch uses. An absent key and `null` both mean discovery; `[]` is the
|
|
49
|
+
* explicit "none" choice and paths are exactly those skills.
|
|
50
|
+
*/
|
|
51
|
+
export function configuredSkillExposure(value: unknown): ConfiguredSkillExposure {
|
|
52
|
+
if (value === undefined) return { mode: "inherit", paths: [], source: "default" };
|
|
53
|
+
const paths = normalizeSkillExposure(value, "config defaultSkills");
|
|
54
|
+
if (paths === undefined) return { mode: "inherit", paths: [], source: "config" };
|
|
55
|
+
if (paths.length === 0) return { mode: "none", paths: [], source: "config" };
|
|
56
|
+
return { mode: "explicit", paths, source: "config" };
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export interface SkillExposureInput {
|
|
60
|
+
/**
|
|
61
|
+
* Present only on a continuation. The frozen recipe decides, including its
|
|
62
|
+
* absence: a recipe that recorded no `skills` keeps discovery instead of
|
|
63
|
+
* picking up a catalog or config choice that appeared later.
|
|
64
|
+
*/
|
|
65
|
+
saved?: { paths?: readonly string[] };
|
|
66
|
+
/** Per-launch (or batch-merged) `skills` option. */
|
|
67
|
+
requested?: unknown;
|
|
68
|
+
/** Catalog role/agent choice for this launch. */
|
|
69
|
+
catalog?: unknown;
|
|
70
|
+
/**
|
|
71
|
+
* A current-session override. Presence is the choice: `{}` means discovery,
|
|
72
|
+
* `{ value: [] }` means none, and `{ value: paths }` means exactly those.
|
|
73
|
+
* It must beat the saved config without reopening discovery.
|
|
74
|
+
*/
|
|
75
|
+
session?: { value?: unknown };
|
|
76
|
+
/** Global `defaultSkills` from the subagent config. */
|
|
77
|
+
configured?: unknown;
|
|
78
|
+
/** Workspace the child runs in; relative paths are resolved against it. */
|
|
79
|
+
cwd?: string;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
const LABELS = {
|
|
83
|
+
launch: "skills",
|
|
84
|
+
catalog: "the catalog definition's skills",
|
|
85
|
+
session: "session skills default",
|
|
86
|
+
config: "config defaultSkills",
|
|
87
|
+
} as const;
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Shape-only validation: `undefined`/`null` mean "not set", and an array of
|
|
91
|
+
* non-empty strings is accepted as written. Absolutizing happens later, because
|
|
92
|
+
* the workspace a relative path belongs to is only known once it is resolved.
|
|
93
|
+
*/
|
|
94
|
+
export function normalizeSkillExposure(value: unknown, label: string): string[] | undefined {
|
|
95
|
+
if (value === undefined || value === null) return undefined;
|
|
96
|
+
if (!Array.isArray(value)) {
|
|
97
|
+
throw new Error(
|
|
98
|
+
`${label} must be an array of absolute paths to a SKILL.md file or a skill directory. ` +
|
|
99
|
+
`Omit it to inherit skill discovery, or pass [] to load no skills.`,
|
|
100
|
+
);
|
|
101
|
+
}
|
|
102
|
+
return value.map((entry, index) => {
|
|
103
|
+
if (typeof entry !== "string" || entry.trim() === "") {
|
|
104
|
+
throw new Error(
|
|
105
|
+
`${label}[${index}] must be a non-empty path to a SKILL.md file or a skill directory.`,
|
|
106
|
+
);
|
|
107
|
+
}
|
|
108
|
+
return entry.trim();
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/** Resolve paths against the child's workspace so a frozen recipe replays the same files. */
|
|
113
|
+
export function absolutizeSkillPaths(paths: readonly string[], cwd: string | undefined): string[] {
|
|
114
|
+
return paths.map((path) => {
|
|
115
|
+
if (cwd === undefined) return isAbsolute(path) ? resolve(path) : path;
|
|
116
|
+
return isAbsolute(path) ? resolve(path) : resolve(cwd, path);
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* Resolve the effective exposure for an attempt.
|
|
122
|
+
*
|
|
123
|
+
* Precedence, highest first: the frozen recipe (continuation), the launch
|
|
124
|
+
* option, the catalog role/agent choice, the current-session default, the saved
|
|
125
|
+
* global config default, discovery. Every level distinguishes "not set" from
|
|
126
|
+
* `[]`; an absent session override falls through, a present one decides even
|
|
127
|
+
* when it means discovery.
|
|
128
|
+
*/
|
|
129
|
+
export function resolveSkillExposure(input: SkillExposureInput): SkillExposure {
|
|
130
|
+
if (input.saved) {
|
|
131
|
+
// A recipe written before this option existed has no key at all. That is
|
|
132
|
+
// the same "not set" the launch level uses, so it keeps discovery instead
|
|
133
|
+
// of reading as an explicit "none".
|
|
134
|
+
if (input.saved.paths === undefined) return { mode: "inherit", paths: [], source: "recipe" };
|
|
135
|
+
return exposureFrom([...input.saved.paths], "recipe");
|
|
136
|
+
}
|
|
137
|
+
for (const source of ["launch", "catalog"] as const) {
|
|
138
|
+
const value = source === "launch" ? input.requested : input.catalog;
|
|
139
|
+
const normalized = normalizeSkillExposure(value, LABELS[source]);
|
|
140
|
+
if (normalized === undefined) continue;
|
|
141
|
+
return exposureFrom(absolutizeSkillPaths(normalized, input.cwd), source);
|
|
142
|
+
}
|
|
143
|
+
if (input.session) {
|
|
144
|
+
const normalized = normalizeSkillExposure(input.session.value, LABELS.session);
|
|
145
|
+
if (normalized === undefined) return { mode: "inherit", paths: [], source: "session" };
|
|
146
|
+
return exposureFrom(absolutizeSkillPaths(normalized, input.cwd), "session");
|
|
147
|
+
}
|
|
148
|
+
const configured = normalizeSkillExposure(input.configured, LABELS.config);
|
|
149
|
+
if (configured !== undefined) return exposureFrom(absolutizeSkillPaths(configured, input.cwd), "config");
|
|
150
|
+
return { mode: "inherit", paths: [], source: "default" };
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
function exposureFrom(paths: readonly string[], source: SkillExposureSource): SkillExposure {
|
|
154
|
+
if (paths.length === 0) return { mode: "none", paths: [], source };
|
|
155
|
+
return { mode: "explicit", paths, source };
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* The child's argv for this exposure, in flag order.
|
|
160
|
+
*
|
|
161
|
+
* `inherit` emits nothing at all, which is what keeps every existing launch
|
|
162
|
+
* byte-identical. The other two states always disable discovery first; Pi merges
|
|
163
|
+
* `--skill` into that reduced set rather than re-enabling discovery.
|
|
164
|
+
*/
|
|
165
|
+
export function skillLaunchArgs(exposure: SkillExposure): string[] {
|
|
166
|
+
if (exposure.mode === "inherit") return [];
|
|
167
|
+
return ["--no-skills", ...exposure.paths.flatMap((path) => ["--skill", path])];
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
/** One line for a launch confirmation or a continuation message. */
|
|
171
|
+
export function describeSkillExposure(exposure: SkillExposure): string {
|
|
172
|
+
if (exposure.mode === "inherit") {
|
|
173
|
+
// An ordinary launch chose nothing, so naming a source would only add
|
|
174
|
+
// noise. A session override that chose discovery is different: the user
|
|
175
|
+
// needs to see that the saved path list is not in effect.
|
|
176
|
+
const source = exposure.source === "session" ? " · source session" : "";
|
|
177
|
+
return `Skills: discovery (user catalog)${source}`;
|
|
178
|
+
}
|
|
179
|
+
const detail = exposure.mode === "none"
|
|
180
|
+
? "none (--no-skills)"
|
|
181
|
+
: `${exposure.paths.length} explicit (${exposure.paths.join(", ")})`;
|
|
182
|
+
return `Skills: ${detail} · source ${exposure.source}`;
|
|
183
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
// Generated fixed launch domain from packages/pi-better-subagents/spawn.ts. Do not edit directly.
|
|
2
|
+
/**
|
|
3
|
+
* Detached child-process spawn with file-backed output.
|
|
4
|
+
*
|
|
5
|
+
* Self-contained (adapted from the pi-patty-bg-tasks process model): the kernel
|
|
6
|
+
* writes the child's stdout+stderr straight to a log file with zero JS in the
|
|
7
|
+
* data path, and the child is `detached` + `unref`'d so it is fully isolated
|
|
8
|
+
* from the foreground pi turn. Progress is read back later by tailing the file.
|
|
9
|
+
*/
|
|
10
|
+
import { spawn } from "node:child_process";
|
|
11
|
+
import { closeSync, mkdirSync, openSync, unlinkSync } from "node:fs";
|
|
12
|
+
import { dirname } from "node:path";
|
|
13
|
+
/** Spawn `file fileArgs`, streaming stdout+stderr to `logPath`. Detached. */
|
|
14
|
+
export function spawnDetached(args) {
|
|
15
|
+
mkdirSync(dirname(args.logPath), { recursive: true });
|
|
16
|
+
const outFd = openSync(args.logPath, "w");
|
|
17
|
+
let proc;
|
|
18
|
+
try {
|
|
19
|
+
proc = spawn(args.file, args.fileArgs, {
|
|
20
|
+
stdio: ["ignore", outFd, outFd],
|
|
21
|
+
cwd: args.cwd,
|
|
22
|
+
detached: true,
|
|
23
|
+
env: { ...process.env, ...(args.env ?? {}) },
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
finally {
|
|
27
|
+
closeSync(outFd);
|
|
28
|
+
}
|
|
29
|
+
// Build the exit promise and attach the 'error' listener BEFORE any throw,
|
|
30
|
+
// so an async spawn failure (ENOENT / EMFILE / EAGAIN) can never surface as
|
|
31
|
+
// an uncaught exception that takes the foreground pi down.
|
|
32
|
+
const exit = new Promise((resolve) => {
|
|
33
|
+
proc.on("close", (code) => resolve(code));
|
|
34
|
+
proc.on("error", () => resolve(1));
|
|
35
|
+
});
|
|
36
|
+
if (!proc.pid) {
|
|
37
|
+
try {
|
|
38
|
+
unlinkSync(args.logPath);
|
|
39
|
+
}
|
|
40
|
+
catch { /* best-effort */ }
|
|
41
|
+
throw new Error("Failed to spawn subagent process");
|
|
42
|
+
}
|
|
43
|
+
const pid = proc.pid;
|
|
44
|
+
proc.unref();
|
|
45
|
+
return { pid, exit };
|
|
46
|
+
}
|
|
47
|
+
/** Kill an entire process group via negative-PID signal; fall back to the PID. */
|
|
48
|
+
export function killProcessTree(pid, signal = "SIGTERM") {
|
|
49
|
+
if (typeof pid !== "number" || pid <= 0)
|
|
50
|
+
return;
|
|
51
|
+
try {
|
|
52
|
+
process.kill(-pid, signal);
|
|
53
|
+
}
|
|
54
|
+
catch {
|
|
55
|
+
try {
|
|
56
|
+
process.kill(pid, signal);
|
|
57
|
+
}
|
|
58
|
+
catch { /* already dead */ }
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
/** Cheap liveness probe via signal 0. */
|
|
62
|
+
export function processExists(pid) {
|
|
63
|
+
if (typeof pid !== "number" || pid <= 0)
|
|
64
|
+
return false;
|
|
65
|
+
try {
|
|
66
|
+
process.kill(pid, 0);
|
|
67
|
+
return true;
|
|
68
|
+
}
|
|
69
|
+
catch (err) {
|
|
70
|
+
return err.code === "EPERM";
|
|
71
|
+
}
|
|
72
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Detached child-process spawn with file-backed output.
|
|
3
|
+
*
|
|
4
|
+
* Self-contained (adapted from the pi-patty-bg-tasks process model): the kernel
|
|
5
|
+
* writes the child's stdout+stderr straight to a log file with zero JS in the
|
|
6
|
+
* data path, and the child is `detached` + `unref`'d so it is fully isolated
|
|
7
|
+
* from the foreground pi turn. Progress is read back later by tailing the file.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import { spawn } from "node:child_process";
|
|
11
|
+
import { closeSync, mkdirSync, openSync, unlinkSync } from "node:fs";
|
|
12
|
+
import { dirname } from "node:path";
|
|
13
|
+
|
|
14
|
+
export interface SpawnResult {
|
|
15
|
+
pid: number;
|
|
16
|
+
/** Resolves with the child's exit code (null on signal exit). Never rejects. */
|
|
17
|
+
exit: Promise<number | null>;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/** Spawn `file fileArgs`, streaming stdout+stderr to `logPath`. Detached. */
|
|
21
|
+
export function spawnDetached(args: {
|
|
22
|
+
file: string;
|
|
23
|
+
fileArgs: string[];
|
|
24
|
+
cwd: string;
|
|
25
|
+
logPath: string;
|
|
26
|
+
/** Extra environment for the child, layered over this process's environment. */
|
|
27
|
+
env?: Record<string, string>;
|
|
28
|
+
}): SpawnResult {
|
|
29
|
+
mkdirSync(dirname(args.logPath), { recursive: true });
|
|
30
|
+
const outFd = openSync(args.logPath, "w");
|
|
31
|
+
|
|
32
|
+
let proc;
|
|
33
|
+
try {
|
|
34
|
+
proc = spawn(args.file, args.fileArgs, {
|
|
35
|
+
stdio: ["ignore", outFd, outFd],
|
|
36
|
+
cwd: args.cwd,
|
|
37
|
+
detached: true,
|
|
38
|
+
env: { ...process.env, ...(args.env ?? {}) },
|
|
39
|
+
});
|
|
40
|
+
} finally {
|
|
41
|
+
closeSync(outFd);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// Build the exit promise and attach the 'error' listener BEFORE any throw,
|
|
45
|
+
// so an async spawn failure (ENOENT / EMFILE / EAGAIN) can never surface as
|
|
46
|
+
// an uncaught exception that takes the foreground pi down.
|
|
47
|
+
const exit = new Promise<number | null>((resolve) => {
|
|
48
|
+
proc.on("close", (code) => resolve(code));
|
|
49
|
+
proc.on("error", () => resolve(1));
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
if (!proc.pid) {
|
|
53
|
+
try { unlinkSync(args.logPath); } catch { /* best-effort */ }
|
|
54
|
+
throw new Error("Failed to spawn subagent process");
|
|
55
|
+
}
|
|
56
|
+
const pid = proc.pid;
|
|
57
|
+
proc.unref();
|
|
58
|
+
return { pid, exit };
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/** Kill an entire process group via negative-PID signal; fall back to the PID. */
|
|
62
|
+
export function killProcessTree(pid: number | undefined, signal: NodeJS.Signals = "SIGTERM"): void {
|
|
63
|
+
if (typeof pid !== "number" || pid <= 0) return;
|
|
64
|
+
try {
|
|
65
|
+
process.kill(-pid, signal);
|
|
66
|
+
} catch {
|
|
67
|
+
try { process.kill(pid, signal); } catch { /* already dead */ }
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/** Cheap liveness probe via signal 0. */
|
|
72
|
+
export function processExists(pid: number | undefined): boolean {
|
|
73
|
+
if (typeof pid !== "number" || pid <= 0) return false;
|
|
74
|
+
try {
|
|
75
|
+
process.kill(pid, 0);
|
|
76
|
+
return true;
|
|
77
|
+
} catch (err) {
|
|
78
|
+
return (err as NodeJS.ErrnoException).code === "EPERM";
|
|
79
|
+
}
|
|
80
|
+
}
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
// Generated fixed launch domain from packages/pi-better-subagents/stop.ts. Do not edit directly.
|
|
2
|
+
/**
|
|
3
|
+
* Shared stop / orphaned-cleanup semantics for subagent runs.
|
|
4
|
+
*
|
|
5
|
+
* `stopRun` is the single stop path used by BOTH the model-facing
|
|
6
|
+
* `subagent_stop` tool and the TUI navigator close action (issues #44/#47/#68),
|
|
7
|
+
* so process-group termination and terminal-status recording can never diverge
|
|
8
|
+
* between the two surfaces.
|
|
9
|
+
*
|
|
10
|
+
* Race safety: the run's metadata and effective status are re-read from disk
|
|
11
|
+
* at call time, never taken from a caller's cached copy. A run that finished
|
|
12
|
+
* while a confirmation was pending is reported as not-running instead of
|
|
13
|
+
* being "terminated" against stale state.
|
|
14
|
+
*
|
|
15
|
+
* Orphaned cleanup (#68): when related process-group work is still alive,
|
|
16
|
+
* SIGTERM the recorded group and record durable `killed`. When no related
|
|
17
|
+
* process-group evidence remains, reread the child log and finalize from
|
|
18
|
+
* coherent terminal evidence (`completed` / `failed`) or record `lost`.
|
|
19
|
+
*
|
|
20
|
+
* Terminal completion (#624): every terminal write here also records the run's
|
|
21
|
+
* pending completion marker, so a stopped, killed, or cleanup-finalized run
|
|
22
|
+
* still produces exactly one completion callback (delivered at the next
|
|
23
|
+
* boundary, or recovered by the next Pi instance after `/reload`).
|
|
24
|
+
*
|
|
25
|
+
* Process-group-only contract (ADR 0002): related work is the captured
|
|
26
|
+
* process group (pgid, falling back to pid for old metadata). Escaped /
|
|
27
|
+
* reparented descendants outside that group are out of contract and are
|
|
28
|
+
* never scanned for.
|
|
29
|
+
*/
|
|
30
|
+
import { realProcessProbe } from "./health.domain.mjs";
|
|
31
|
+
import { classifyChildExit } from "./lifecycle.domain.mjs";
|
|
32
|
+
import { parseRunForLifecycle } from "./parse.domain.mjs";
|
|
33
|
+
import { effectiveStatus, launchAttemptInProgress, purgeAbandonedLaunch, readMeta, writeMeta, } from "./registry.domain.mjs";
|
|
34
|
+
import { killProcessTree } from "./spawn.domain.mjs";
|
|
35
|
+
/** Recorded process group for related-work signals (ADR 0002). */
|
|
36
|
+
export function relatedProcessGroupId(meta) {
|
|
37
|
+
const pgid = meta.pgid ?? meta.pid;
|
|
38
|
+
return typeof pgid === "number" && pgid > 0 ? pgid : undefined;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* True when stop/close may still act on this effective status.
|
|
42
|
+
* `running` is the supervised path; `orphaned` is the #68 cleanup path.
|
|
43
|
+
*/
|
|
44
|
+
export function isStoppableStatus(status) {
|
|
45
|
+
return status === "running" || status === "orphaned";
|
|
46
|
+
}
|
|
47
|
+
/** SIGTERM the run's related process group. Returns whether a group target existed. */
|
|
48
|
+
function terminateRelatedWork(meta) {
|
|
49
|
+
const pgid = relatedProcessGroupId(meta);
|
|
50
|
+
if (pgid === undefined)
|
|
51
|
+
return undefined;
|
|
52
|
+
killProcessTree(pgid, "SIGTERM");
|
|
53
|
+
return pgid;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Record the one durable terminal-completion obligation (#624).
|
|
57
|
+
*
|
|
58
|
+
* Every terminal transition owes its caller exactly one completion callback:
|
|
59
|
+
* the callback batcher delivers it once at the next boundary and writes the
|
|
60
|
+
* sent marker, and `/reload` recovers a record that is still marked pending.
|
|
61
|
+
* A stop is a terminal transition like any other, so it must set the marker —
|
|
62
|
+
* otherwise a killed run stays silent now and after `session_start` recovery,
|
|
63
|
+
* which is the case the caller can only notice by polling (or never).
|
|
64
|
+
*
|
|
65
|
+
* `callback:false` runs owe no model message, and an existing marker (sent,
|
|
66
|
+
* suppressed, or already pending) is never moved or reintroduced.
|
|
67
|
+
*/
|
|
68
|
+
function oweTerminalCompletion(meta, now) {
|
|
69
|
+
if (meta.callback === false)
|
|
70
|
+
return;
|
|
71
|
+
if (meta.completionCallbackPendingAt !== undefined
|
|
72
|
+
|| meta.completionCallbackSentAt !== undefined
|
|
73
|
+
|| meta.completionCallbackSuppressedAt !== undefined)
|
|
74
|
+
return;
|
|
75
|
+
meta.completionCallbackPendingAt = now;
|
|
76
|
+
}
|
|
77
|
+
function recordKilled(meta, now) {
|
|
78
|
+
meta.status = "killed";
|
|
79
|
+
meta.lifecycleClassification = "killed";
|
|
80
|
+
meta.endedAt = now;
|
|
81
|
+
oweTerminalCompletion(meta, now);
|
|
82
|
+
writeMeta(meta);
|
|
83
|
+
return { action: "stopped", id: meta.id };
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* No related process-group evidence remains. Reread logs, then finalize from
|
|
87
|
+
* coherent terminal stream evidence or record durable `lost`.
|
|
88
|
+
*/
|
|
89
|
+
function finalizeOrphanedWithoutProcess(meta, now) {
|
|
90
|
+
// Log authority is reread at cleanup time — never trust a cached parse.
|
|
91
|
+
const run = parseRunForLifecycle(meta.id);
|
|
92
|
+
if (run.sawEnd && run.unmatchedToolCalls.length === 0) {
|
|
93
|
+
// Terminal evidence is not success evidence: an exit-0 stream can end on a
|
|
94
|
+
// failed model request, which classifyChildExit reports as failed.
|
|
95
|
+
const outcome = classifyChildExit(meta.exitCode ?? 0, run);
|
|
96
|
+
meta.status = outcome.status;
|
|
97
|
+
meta.lifecycleClassification = outcome.classification;
|
|
98
|
+
if (meta.exitCode === undefined)
|
|
99
|
+
meta.exitCode = 0;
|
|
100
|
+
meta.endedAt = now;
|
|
101
|
+
oweTerminalCompletion(meta, now);
|
|
102
|
+
writeMeta(meta);
|
|
103
|
+
return { action: "finalized", id: meta.id, status: outcome.status };
|
|
104
|
+
}
|
|
105
|
+
if (run.sawEnd && run.unmatchedToolCalls.length > 0) {
|
|
106
|
+
meta.status = "failed";
|
|
107
|
+
meta.lifecycleClassification = "incomplete_open_tools";
|
|
108
|
+
meta.failureReason = "incomplete-stream";
|
|
109
|
+
meta.endedAt = now;
|
|
110
|
+
oweTerminalCompletion(meta, now);
|
|
111
|
+
writeMeta(meta);
|
|
112
|
+
return { action: "finalized", id: meta.id, status: "failed" };
|
|
113
|
+
}
|
|
114
|
+
// No coherent terminal completion evidence and no related process remains.
|
|
115
|
+
// `lost` is the one terminal outcome that does NOT owe a completion callback:
|
|
116
|
+
// its dedicated health callback (subagent-health) is the terminal notice, so
|
|
117
|
+
// marking a completion here would report the same run twice.
|
|
118
|
+
meta.status = "lost";
|
|
119
|
+
meta.lifecycleClassification = "lost";
|
|
120
|
+
meta.lostAt = now;
|
|
121
|
+
meta.endedAt = now;
|
|
122
|
+
writeMeta(meta);
|
|
123
|
+
return { action: "finalized", id: meta.id, status: "lost" };
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Cleanup path for a durable orphaned run (#68).
|
|
127
|
+
* Shares kill + killed recording with the running-run stop path when the
|
|
128
|
+
* captured process group is still alive; otherwise finalizes from logs.
|
|
129
|
+
*/
|
|
130
|
+
function cleanupOrphanedRun(meta, probe, now) {
|
|
131
|
+
const pgid = relatedProcessGroupId(meta);
|
|
132
|
+
if (pgid !== undefined && probe.groupAlive(pgid)) {
|
|
133
|
+
terminateRelatedWork(meta);
|
|
134
|
+
return recordKilled(meta, now);
|
|
135
|
+
}
|
|
136
|
+
return finalizeOrphanedWithoutProcess(meta, now);
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Stop or resolve a run by id.
|
|
140
|
+
*
|
|
141
|
+
* - `running` → SIGTERM related process group, durable `killed`.
|
|
142
|
+
* - `orphaned` → terminate identifiable process-group members when alive;
|
|
143
|
+
* otherwise reread logs and finalize completed/failed/lost.
|
|
144
|
+
* - other statuses → not-running (on-disk record untouched).
|
|
145
|
+
*
|
|
146
|
+
* An id with no metadata is either unknown or an abandoned launch record (a
|
|
147
|
+
* launch that never wrote `meta.json` and never started a child). The latter is
|
|
148
|
+
* purged, so the operator can clear launch debris (#623) without waiting for the
|
|
149
|
+
* sweep's grace period. A concurrent launch that owns the record — published, or
|
|
150
|
+
* still preparing under its claim — is preserved, never deleted (#623 R1).
|
|
151
|
+
* Anything else stays an unknown id.
|
|
152
|
+
*
|
|
153
|
+
* Throws on an unknown id (same contract as the stop tool).
|
|
154
|
+
*/
|
|
155
|
+
export function stopRun(id, deps = {}) {
|
|
156
|
+
const meta = readMeta(id);
|
|
157
|
+
if (!meta) {
|
|
158
|
+
const purge = purgeAbandonedLaunch(id);
|
|
159
|
+
if (purge === "purged")
|
|
160
|
+
return { action: "purged", id };
|
|
161
|
+
// The purge re-checks under the run's metadata lock, so a launch may have
|
|
162
|
+
// become visible while we waited. Preserve it and say what it is.
|
|
163
|
+
const published = readMeta(id);
|
|
164
|
+
if (published)
|
|
165
|
+
return { action: "preserved", id, status: effectiveStatus(published) };
|
|
166
|
+
if (purge === "retained" || launchAttemptInProgress(id)) {
|
|
167
|
+
return { action: "preserved", id, status: "launching" };
|
|
168
|
+
}
|
|
169
|
+
throw new Error(`Unknown run id: ${id}`);
|
|
170
|
+
}
|
|
171
|
+
const probe = deps.probe ?? realProcessProbe;
|
|
172
|
+
const now = typeof deps.now === "function" ? deps.now() : Date.now();
|
|
173
|
+
const status = effectiveStatus(meta);
|
|
174
|
+
if (status === "running") {
|
|
175
|
+
// Supervised path: same process-group kill + killed write as before.
|
|
176
|
+
// Prefer recorded pgid so running and orphaned share one target rule.
|
|
177
|
+
terminateRelatedWork(meta);
|
|
178
|
+
return recordKilled(meta, now);
|
|
179
|
+
}
|
|
180
|
+
if (status === "orphaned") {
|
|
181
|
+
return cleanupOrphanedRun(meta, probe, now);
|
|
182
|
+
}
|
|
183
|
+
return { action: "not-running", id, status };
|
|
184
|
+
}
|