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,558 @@
|
|
|
1
|
+
// Generated fixed launch domain from packages/pi-better-subagents/tools.ts. Do not edit directly.
|
|
2
|
+
/**
|
|
3
|
+
* Model-facing tool definitions — the seam between pi registration and tests.
|
|
4
|
+
*
|
|
5
|
+
* index.ts registers EXACTLY the objects these factories return
|
|
6
|
+
* (`pi.registerTool(subagentListTool(Type))`), so a test that invokes a
|
|
7
|
+
* factory-built tool's `execute` exercises the same handler logic the model
|
|
8
|
+
* reaches — there is no second, drift-prone copy of the list/output/result/
|
|
9
|
+
* stop behavior.
|
|
10
|
+
*
|
|
11
|
+
* The factories take the `Type` schema builder as a parameter instead of
|
|
12
|
+
* importing `@earendil-works/pi-ai` directly: that package only exists inside
|
|
13
|
+
* the pi runtime, and keeping this module free of it lets `node --test` load
|
|
14
|
+
* the handlers with a trivial stub (the parameters schema is inert data as
|
|
15
|
+
* far as `execute` is concerned).
|
|
16
|
+
*/
|
|
17
|
+
import { createHash } from "node:crypto";
|
|
18
|
+
import { assignmentFor, projectAssignment, createAssignmentProjector, withAssignmentObservations } from "./assignment-projection.mjs";
|
|
19
|
+
import { readMeta, listRunRecords, effectiveStatus, isFinalResultStatus } from "./registry.domain.mjs";
|
|
20
|
+
import { buildSubagentResultPayload } from "./finalization.domain.mjs";
|
|
21
|
+
import { stopRun } from "./stop.domain.mjs";
|
|
22
|
+
import { SUBAGENT_LIST_DEFAULT_LIMIT, SUBAGENT_LIST_MAX_LIMIT, SUBAGENT_LIST_STATUSES, collectSubagentList, formatSubagentListRow, listFolderScopeKey, normalizeSubagentListOptions, } from "./list.domain.mjs";
|
|
23
|
+
import { assembleOrphanedResult, assembleRunningResult, assembleSubagentListPayload, assembleSubagentOutput, assembleUnreadableMetadata, listIncidentCount, formatIncidentLabel, listRevisions, requestScopeKey, resolveActiveOrigin, resolveRunAccess, unknownRunError, } from "./output-payload.domain.mjs";
|
|
24
|
+
import { budgetFor, readOutputControls } from "./shared-log-utils.domain.mjs";
|
|
25
|
+
import { readRunFailures } from "./failures.domain.mjs";
|
|
26
|
+
import { actionablePermissionBlockers } from "./shared-failure-observations.domain.mjs";
|
|
27
|
+
import { describeTiming } from "./timing.domain.mjs";
|
|
28
|
+
import { extractChildEventFactsFromLog, loadHealthThresholdsFromConfig, observeRunHealth, } from "./health-observation.domain.mjs";
|
|
29
|
+
import { formatHealthDiagnosticLine, statusThemeColor, truncateToVisibleWidth, } from "./health-surface.mjs";
|
|
30
|
+
/** Observe one run for list/output/result diagnostics (#66/#67). Best-effort. */
|
|
31
|
+
function observeMetaHealth(meta, now = Date.now()) {
|
|
32
|
+
// Observation uses durable RunStatus (orphaned/lost/running/…); transient
|
|
33
|
+
// effective "exited" falls back to meta.status so process liveness stays truthful.
|
|
34
|
+
const eff = effectiveStatus(meta);
|
|
35
|
+
const status = eff === "exited" ? meta.status : eff;
|
|
36
|
+
const { facts, rawLog } = extractChildEventFactsFromLog(meta.id, { now });
|
|
37
|
+
return observeRunHealth({
|
|
38
|
+
status,
|
|
39
|
+
now,
|
|
40
|
+
facts,
|
|
41
|
+
rawLog,
|
|
42
|
+
thresholds: loadHealthThresholdsFromConfig(),
|
|
43
|
+
startedAt: meta.startedAt,
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
/** Health diagnostics plus the harness timing reason (deadline / ceiling / stuck), one line each. */
|
|
47
|
+
function diagnosticLines(meta) {
|
|
48
|
+
const status = String(effectiveStatus(meta));
|
|
49
|
+
return [formatHealthDiagnosticLine(observeMetaHealth(meta)), describeTiming({ ...meta, status: status === "exited" ? meta.status : status })?.line]
|
|
50
|
+
.filter(Boolean).join("\n");
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Resolve public output-control names (#321): canonical `max_bytes` / `lines`,
|
|
54
|
+
* deprecated `maxBytes` / `tail_lines`; the canonical name wins when both are
|
|
55
|
+
* given. The payload assemblers only see the normalized `maxBytes` / `lines`.
|
|
56
|
+
*/
|
|
57
|
+
function normalizeOutputRequest(params) {
|
|
58
|
+
const controls = readOutputControls(params);
|
|
59
|
+
const { max_bytes: _canonicalBytes, tail_lines: _aliasLines, ...rest } = params;
|
|
60
|
+
return {
|
|
61
|
+
...rest,
|
|
62
|
+
maxBytes: controls.maxBytes,
|
|
63
|
+
lines: controls.lines,
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
const MAX_BYTES_ALIAS_DESCRIPTION = "Deprecated alias for max_bytes. max_bytes wins when both are given.";
|
|
67
|
+
const HISTORY_DESCRIPTION = "If true, return an incident page that also lists failure history: unclassified child tool errors, expected failures, and recovered or superseded incidents. Default output lists only failures that need action and counts the rest.";
|
|
68
|
+
const TAIL_DESCRIPTION = "With mode=raw: read from the newest retained byte first instead of byte 0. The page is end-anchored and nextCursor then pages toward the oldest bytes; once the start is reached the cursor reads only bytes appended later. Use this to reach the end of a multi-MB log without paging from byte zero.";
|
|
69
|
+
const INCLUDE_DESCRIPTION = "Explicit opt-in facts omitted by default: \"cost\" adds one token/cost spend line, \"tools\" adds one tool-call count line with the distinct tool names.";
|
|
70
|
+
/** pi's tool-result text shape. */
|
|
71
|
+
export const text = (t) => ({ content: [{ type: "text", text: t }] });
|
|
72
|
+
/** Metadata has its own bounded allowance; it never embeds raw evidence or unbounded history. */
|
|
73
|
+
function permissionDetails(id, maxBytes) {
|
|
74
|
+
const all = actionablePermissionBlockers(readRunFailures(id));
|
|
75
|
+
if (!all.length)
|
|
76
|
+
return {};
|
|
77
|
+
const permissionBlockers = [];
|
|
78
|
+
const allowance = Math.min(4096, maxBytes);
|
|
79
|
+
if (Buffer.byteLength(JSON.stringify({ permissionBlockers, permissionBlockersOmitted: all.length })) > allowance) {
|
|
80
|
+
throw new Error("Permission blocker metadata cannot fit this budget; retry with a larger max_bytes.");
|
|
81
|
+
}
|
|
82
|
+
for (const blocker of all) {
|
|
83
|
+
if (permissionBlockers.length === 32 || Buffer.byteLength(JSON.stringify({ permissionBlockers: [...permissionBlockers, blocker],
|
|
84
|
+
permissionBlockersOmitted: all.length - permissionBlockers.length - 1 })) > allowance)
|
|
85
|
+
break;
|
|
86
|
+
permissionBlockers.push(blocker);
|
|
87
|
+
}
|
|
88
|
+
return { permissionBlockers, ...(all.length > permissionBlockers.length ? { permissionBlockersOmitted: all.length - permissionBlockers.length } : {}) };
|
|
89
|
+
}
|
|
90
|
+
const SUBAGENT_RESULT_PREVIEW_LINES = 8;
|
|
91
|
+
function resultTextContent(result) {
|
|
92
|
+
const content = result?.content;
|
|
93
|
+
if (!Array.isArray(content))
|
|
94
|
+
return "";
|
|
95
|
+
return content
|
|
96
|
+
.filter((c) => c && (c.type === undefined || c.type === "text"))
|
|
97
|
+
.map((c) => c.text ?? "")
|
|
98
|
+
.join("\n");
|
|
99
|
+
}
|
|
100
|
+
function parseSubagentResultHead(head) {
|
|
101
|
+
const raw = String(head ?? "");
|
|
102
|
+
const match = raw.match(/^\[([^\s\]]+)\s+·\s+([^·\]]+)/);
|
|
103
|
+
if (!match)
|
|
104
|
+
return {};
|
|
105
|
+
return { id: match[1], status: match[2]?.trim() };
|
|
106
|
+
}
|
|
107
|
+
function nonEmptyPreviewLines(lines) {
|
|
108
|
+
const preview = [];
|
|
109
|
+
for (const line of lines) {
|
|
110
|
+
if (/^---\s+raw log tail\s+---$/i.test(line.trim()))
|
|
111
|
+
break;
|
|
112
|
+
if (line.trim() === "")
|
|
113
|
+
continue;
|
|
114
|
+
preview.push(line);
|
|
115
|
+
if (preview.length >= SUBAGENT_RESULT_PREVIEW_LINES)
|
|
116
|
+
break;
|
|
117
|
+
}
|
|
118
|
+
return preview;
|
|
119
|
+
}
|
|
120
|
+
export function buildSubagentResultDisplayDetails(body) {
|
|
121
|
+
const fullLines = String(body ?? "").split(/\r?\n/);
|
|
122
|
+
const head = fullLines[0] || "subagent_result";
|
|
123
|
+
const { id, status } = parseSubagentResultHead(head);
|
|
124
|
+
const rest = fullLines.slice(1);
|
|
125
|
+
const compactLines = nonEmptyPreviewLines(rest);
|
|
126
|
+
return {
|
|
127
|
+
kind: "subagent-result-display",
|
|
128
|
+
id,
|
|
129
|
+
status,
|
|
130
|
+
head,
|
|
131
|
+
fullLineCount: fullLines.length,
|
|
132
|
+
compactLines,
|
|
133
|
+
foldedLineCount: Math.max(0, rest.length - compactLines.length),
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
function subagentResultText(body) {
|
|
137
|
+
return {
|
|
138
|
+
content: [{ type: "text", text: body }],
|
|
139
|
+
details: buildSubagentResultDisplayDetails(body),
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
function themed(theme, color, value) {
|
|
143
|
+
const fg = theme?.fg;
|
|
144
|
+
return typeof fg === "function" ? fg(color, value) : value;
|
|
145
|
+
}
|
|
146
|
+
function wrapLineToVisibleWidth(line, width) {
|
|
147
|
+
const str = String(line ?? "");
|
|
148
|
+
const max = Math.max(1, Number(width) || 80);
|
|
149
|
+
if (truncateToVisibleWidth(str, max) === str)
|
|
150
|
+
return [str];
|
|
151
|
+
const out = [];
|
|
152
|
+
let current = "";
|
|
153
|
+
let visible = 0;
|
|
154
|
+
let i = 0;
|
|
155
|
+
while (i < str.length) {
|
|
156
|
+
if (str[i] === "\u001b" || str[i] === "\u009b") {
|
|
157
|
+
const match = str.slice(i).match(/^[\u001B\u009B][[\]()#;?]*(?:(?:(?:[a-zA-Z\d]*(?:;[a-zA-Z\d]*)*)?\u0007)|(?:(?:\d{1,4}(?:;\d{0,4})*)?[\dA-PR-TZcf-ntqry=><~]))/);
|
|
158
|
+
if (match) {
|
|
159
|
+
current += match[0];
|
|
160
|
+
i += match[0].length;
|
|
161
|
+
continue;
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
if (str[i] === "<") {
|
|
165
|
+
const close = str.indexOf(">", i);
|
|
166
|
+
if (close !== -1) {
|
|
167
|
+
const tag = str.slice(i, close + 1);
|
|
168
|
+
if (/^<\/?[a-zA-Z][\w-]*>$/.test(tag) || tag === "</>") {
|
|
169
|
+
current += tag;
|
|
170
|
+
i = close + 1;
|
|
171
|
+
continue;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
if (visible >= max) {
|
|
176
|
+
out.push(current);
|
|
177
|
+
current = "";
|
|
178
|
+
visible = 0;
|
|
179
|
+
}
|
|
180
|
+
current += str[i];
|
|
181
|
+
visible += 1;
|
|
182
|
+
i += 1;
|
|
183
|
+
}
|
|
184
|
+
out.push(current);
|
|
185
|
+
return out;
|
|
186
|
+
}
|
|
187
|
+
function renderLines(lines, mode = "truncate") {
|
|
188
|
+
return {
|
|
189
|
+
render(width = 80) {
|
|
190
|
+
return mode === "wrap"
|
|
191
|
+
? lines.flatMap((line) => wrapLineToVisibleWidth(line, width))
|
|
192
|
+
: lines.map((line) => truncateToVisibleWidth(line, width));
|
|
193
|
+
},
|
|
194
|
+
invalidate() { },
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
export function renderSubagentResultDisplay(result, options = {}, theme = {}) {
|
|
198
|
+
const fullText = resultTextContent(result);
|
|
199
|
+
const details = result?.details
|
|
200
|
+
?? buildSubagentResultDisplayDetails(fullText);
|
|
201
|
+
const expanded = options?.expanded === true;
|
|
202
|
+
const status = details.status ?? "result";
|
|
203
|
+
const statusText = themed(theme, displayThemeColor(status), status);
|
|
204
|
+
const meta = [details.id, `${details.fullLineCount} lines`].filter(Boolean).join(" · ");
|
|
205
|
+
if (expanded) {
|
|
206
|
+
return renderLines([
|
|
207
|
+
`${themed(theme, "accent", "subagent_result")} ${statusText}${meta ? themed(theme, "dim", ` · ${meta}`) : ""}`,
|
|
208
|
+
themed(theme, "dim", "Full displayed result. Click or collapse to fold."),
|
|
209
|
+
"",
|
|
210
|
+
...fullText.split(/\r?\n/),
|
|
211
|
+
], "wrap");
|
|
212
|
+
}
|
|
213
|
+
const folded = details.foldedLineCount > 0
|
|
214
|
+
? themed(theme, "dim", `Folded ${details.foldedLineCount} display lines. Click or expand for full result. Model payload unchanged.`)
|
|
215
|
+
: themed(theme, "dim", "Compact result. Expand for full display if needed.");
|
|
216
|
+
return renderLines([
|
|
217
|
+
`${themed(theme, "accent", "subagent_result")} ${statusText}${meta ? themed(theme, "dim", ` · ${meta}`) : ""}`,
|
|
218
|
+
details.head,
|
|
219
|
+
"",
|
|
220
|
+
themed(theme, "dim", "preview"),
|
|
221
|
+
...details.compactLines,
|
|
222
|
+
folded,
|
|
223
|
+
]);
|
|
224
|
+
}
|
|
225
|
+
function displayThemeColor(status) {
|
|
226
|
+
const color = statusThemeColor(status);
|
|
227
|
+
return color === "danger" ? "error" : color;
|
|
228
|
+
}
|
|
229
|
+
/** The session provider bound to this tool call's host context. */
|
|
230
|
+
function forCall(session, ctx) {
|
|
231
|
+
const provider = session.getActiveOrigin;
|
|
232
|
+
if (typeof provider !== "function")
|
|
233
|
+
return session;
|
|
234
|
+
return { ...session, getActiveOrigin: () => provider(ctx) };
|
|
235
|
+
}
|
|
236
|
+
/**
|
|
237
|
+
* Folder this list call runs in. `ctx.cwd` is the foreground's live workspace
|
|
238
|
+
* and wins; a readable origin is the fallback for hosts that omit it. Listing
|
|
239
|
+
* by folder never needs a foreground session id, so an unavailable origin does
|
|
240
|
+
* not narrow the default scope.
|
|
241
|
+
*/
|
|
242
|
+
function listCwd(ctx, origin) {
|
|
243
|
+
const ctxCwd = ctx?.cwd;
|
|
244
|
+
if (typeof ctxCwd === "string" && ctxCwd !== "")
|
|
245
|
+
return ctxCwd;
|
|
246
|
+
return origin?.cwd ?? process.cwd();
|
|
247
|
+
}
|
|
248
|
+
export function subagentListTool(Type, baseSession = {}) {
|
|
249
|
+
return {
|
|
250
|
+
name: "subagent_list",
|
|
251
|
+
label: "List Subagents",
|
|
252
|
+
description: `List background subagent runs with compact status rows. Non-blocking. ` +
|
|
253
|
+
`Default: current folder and its descendants across foreground sessions, newest first, ` +
|
|
254
|
+
`limit ${SUBAGENT_LIST_DEFAULT_LIMIT} (1 KiB page). ` +
|
|
255
|
+
`Pass all:true for machine-global; limit is clamped to max ${SUBAGENT_LIST_MAX_LIMIT}. ` +
|
|
256
|
+
`Pass cursor to continue. Incident counts are compact; full failure text lives on subagent_result/output.`,
|
|
257
|
+
promptSnippet: "List background subagent runs and their status",
|
|
258
|
+
parameters: Type.Object({
|
|
259
|
+
all: Type.Optional(Type.Boolean({ description: "If true, list every run on this machine. Default false = current folder and its descendants, regardless of foreground session." })),
|
|
260
|
+
limit: Type.Optional(Type.Number({ description: `Maximum rows to display (default ${SUBAGENT_LIST_DEFAULT_LIMIT}, max ${SUBAGENT_LIST_MAX_LIMIT}; larger values are clamped).` })),
|
|
261
|
+
status: Type.Optional(Type.Array(Type.String(), { description: `Effective statuses to include: ${SUBAGENT_LIST_STATUSES.join(", ")}.` })),
|
|
262
|
+
cursor: Type.Optional(Type.String({ description: "Caller-owned page or status cursor from a previous list response." })),
|
|
263
|
+
max_bytes: Type.Optional(Type.Number({ description: "UTF-8 byte budget for this page (default 1 KiB, max 4 KiB)." })),
|
|
264
|
+
maxBytes: Type.Optional(Type.Number({ description: MAX_BYTES_ALIAS_DESCRIPTION })),
|
|
265
|
+
}),
|
|
266
|
+
async execute(_toolCallId, params, _signal, _onUpdate, ctx) {
|
|
267
|
+
const session = forCall(baseSession, ctx);
|
|
268
|
+
const p = normalizeOutputRequest((params ?? {}));
|
|
269
|
+
const now = Date.now();
|
|
270
|
+
if (session.observeList) {
|
|
271
|
+
const options = normalizeSubagentListOptions(p);
|
|
272
|
+
const cwd = listCwd(ctx, resolveActiveOrigin(session).origin);
|
|
273
|
+
const statusCursor = p.cursor?.startsWith("work-status:") ? p.cursor.slice("work-status:".length) : undefined;
|
|
274
|
+
const snapshot = await session.observeList({ ...(options.all ? {} : { cwd }),
|
|
275
|
+
...(options.statuses ? { statuses: [...options.statuses] } : {}), limit: Math.max(1, options.limit),
|
|
276
|
+
...(p.cursor && !statusCursor ? { cursor: p.cursor } : {}) });
|
|
277
|
+
const incidents = new Map(snapshot.rows.map((row) => [row.meta.id, listIncidentCount(row.meta.id, row.meta.cwd, !["running", "orphaned"].includes(row.meta.status))]));
|
|
278
|
+
const revision = createHash("sha256").update(JSON.stringify([snapshot.scopeRevision,
|
|
279
|
+
[...incidents].map(([id, incident]) => [id, incident.revision])])).digest("hex");
|
|
280
|
+
const status = `work-status:${revision}`;
|
|
281
|
+
if (statusCursor === revision && snapshot.status === "ready")
|
|
282
|
+
return text(`Subagents unchanged. statusCursor=${status}`);
|
|
283
|
+
const budget = budgetFor("list", p.maxBytes);
|
|
284
|
+
const header = [...options.warnings, `Subagents: ${snapshot.totalMatching} matching${snapshot.status === "ready" ? "" : `; ${snapshot.status}: ${snapshot.reason ?? "source verification pending"}`}.`].join("\n");
|
|
285
|
+
const lines = [header];
|
|
286
|
+
let last;
|
|
287
|
+
for (const row of options.limit === 0 ? [] : snapshot.rows) {
|
|
288
|
+
const incident = incidents.get(row.meta.id);
|
|
289
|
+
const line = formatSubagentListRow(row.meta, { assignment: row.assignment, status: row.assignment.state,
|
|
290
|
+
processStatus: row.assignment.processStatus, now, compact: true,
|
|
291
|
+
health: row.health ? observeRunHealth({ ...row.health, status: row.assignment.processStatus === "exited" ? row.meta.status : row.assignment.processStatus, now, startedAt: row.meta.startedAt }) : undefined,
|
|
292
|
+
failure: formatIncidentLabel(incident.count, incident.actionRequired) });
|
|
293
|
+
const footer = `\nnextCursor=${row.cursor}\nstatusCursor=${status}`;
|
|
294
|
+
if (Buffer.byteLength([...lines, line].join("\n") + footer) > budget)
|
|
295
|
+
break;
|
|
296
|
+
lines.push(line);
|
|
297
|
+
last = row;
|
|
298
|
+
}
|
|
299
|
+
if (!last && snapshot.rows.length && options.limit > 0)
|
|
300
|
+
throw new Error("The list row and cursor cannot fit max_bytes; retry with a larger budget.");
|
|
301
|
+
if (last && (snapshot.nextCursor || last !== snapshot.rows.at(-1)))
|
|
302
|
+
lines.push(`nextCursor=${last.cursor}`);
|
|
303
|
+
lines.push(`statusCursor=${status}`);
|
|
304
|
+
return { ...text(lines.join("\n")), details: { snapshot: { ...snapshot, rows: snapshot.rows.slice(0, last ? snapshot.rows.indexOf(last) + 1 : 0) } } };
|
|
305
|
+
}
|
|
306
|
+
const index = listRunRecords();
|
|
307
|
+
const metas = index.metas;
|
|
308
|
+
const resolved = resolveActiveOrigin(session);
|
|
309
|
+
// List scope is a folder, not a session: peers in the same folder
|
|
310
|
+
// are listed even when they were spawned by another foreground.
|
|
311
|
+
const cwd = listCwd(ctx, resolved.origin);
|
|
312
|
+
const scopeKey = listFolderScopeKey(p.all === true, cwd);
|
|
313
|
+
const project = createAssignmentProjector();
|
|
314
|
+
const assignments = new Map();
|
|
315
|
+
const assignmentOf = (meta) => {
|
|
316
|
+
let assignment = assignments.get(meta.id);
|
|
317
|
+
if (!assignment) {
|
|
318
|
+
assignment = project(meta, effectiveStatus(meta));
|
|
319
|
+
assignments.set(meta.id, assignment);
|
|
320
|
+
}
|
|
321
|
+
return assignment;
|
|
322
|
+
};
|
|
323
|
+
const healthCache = new Map();
|
|
324
|
+
const healthById = (id) => {
|
|
325
|
+
const hit = healthCache.get(id);
|
|
326
|
+
if (hit)
|
|
327
|
+
return hit;
|
|
328
|
+
const meta = metas.find((m) => m.id === id) ?? readMeta(id);
|
|
329
|
+
if (!meta)
|
|
330
|
+
return undefined;
|
|
331
|
+
const obs = observeMetaHealth(meta, now);
|
|
332
|
+
healthCache.set(id, obs);
|
|
333
|
+
return obs;
|
|
334
|
+
};
|
|
335
|
+
const collected = collectSubagentList({
|
|
336
|
+
metas,
|
|
337
|
+
params: p,
|
|
338
|
+
cwd,
|
|
339
|
+
now,
|
|
340
|
+
statusOf: (meta) => assignmentOf(meta).state,
|
|
341
|
+
assignmentOf,
|
|
342
|
+
healthById,
|
|
343
|
+
});
|
|
344
|
+
const items = collected.items;
|
|
345
|
+
const incidents = new Map(items.map((row) => [row.meta.id, listIncidentCount(row.meta.id, row.meta.cwd, row.meta.status !== "running" && row.meta.status !== "orphaned")]));
|
|
346
|
+
const revisions = listRevisions(items.map((row) => ({ id: row.meta.id, status: String(row.status), meta: row.meta })), items.map((row) => incidents.get(row.meta.id)?.revision ?? ""), assignmentOf);
|
|
347
|
+
const statusesKey = Array.isArray(p.status) ? [...p.status].map(String).sort().join(",") : String(p.status ?? "");
|
|
348
|
+
const incidentRuns = items.filter((row) => (incidents.get(row.meta.id)?.count ?? 0) > 0).length;
|
|
349
|
+
return text(assembleSubagentListPayload({
|
|
350
|
+
warnings: collected.warnings,
|
|
351
|
+
items,
|
|
352
|
+
render: (row) => {
|
|
353
|
+
const incident = incidents.get(row.meta.id);
|
|
354
|
+
return formatSubagentListRow(row.meta, {
|
|
355
|
+
assignment: assignmentOf(row.meta),
|
|
356
|
+
processStatus: effectiveStatus(row.meta),
|
|
357
|
+
status: row.status,
|
|
358
|
+
now,
|
|
359
|
+
health: healthById(row.meta.id),
|
|
360
|
+
failure: formatIncidentLabel(incident?.count ?? 0, incident?.actionRequired ?? 0),
|
|
361
|
+
});
|
|
362
|
+
},
|
|
363
|
+
limit: Math.max(1, collected.limit),
|
|
364
|
+
cursor: p.cursor,
|
|
365
|
+
maxBytes: p.maxBytes,
|
|
366
|
+
contentRevision: revisions.contentRevision,
|
|
367
|
+
failureRevision: revisions.failureRevision,
|
|
368
|
+
scopeKey,
|
|
369
|
+
statusesKey,
|
|
370
|
+
unreadable: index.unreadable,
|
|
371
|
+
abandonedLaunches: index.abandoned,
|
|
372
|
+
indexError: index.indexError,
|
|
373
|
+
incidentRuns,
|
|
374
|
+
}));
|
|
375
|
+
},
|
|
376
|
+
};
|
|
377
|
+
}
|
|
378
|
+
// ---- subagent_output ------------------------------------------------------
|
|
379
|
+
export function subagentOutputTool(Type, baseSession = {}) {
|
|
380
|
+
return {
|
|
381
|
+
name: "subagent_output",
|
|
382
|
+
label: "Subagent Output",
|
|
383
|
+
description: "Read a subagent run's current output without waiting. Default is a 1 KiB / 10-line excerpt of the current session. " +
|
|
384
|
+
"Pass all:true to read a foreign-session id. Pass mode=raw for retained-log pages (16 KiB default, 64 KiB cap). " +
|
|
385
|
+
"Pass tail:true with mode=raw to start from the newest retained bytes and page toward the oldest. " +
|
|
386
|
+
"Pass cursor to continue or to poll for failure-only changes. Missing or unreadable logs are reported as gaps, not as empty healthy output. " +
|
|
387
|
+
"Spend and tool counts are omitted unless include:[\"cost\",\"tools\"] asks for them.",
|
|
388
|
+
promptSnippet: "Peek at a subagent's current output without waiting",
|
|
389
|
+
promptGuidelines: [
|
|
390
|
+
"Use subagent_output only when the user explicitly asks how a run is progressing. It never waits — do not call it in a loop.",
|
|
391
|
+
"Do not poll unchanged output. If the response says no new evidence since a cursor, stop.",
|
|
392
|
+
],
|
|
393
|
+
parameters: Type.Object({
|
|
394
|
+
id: Type.String({ description: "Run id from subagent_spawn." }),
|
|
395
|
+
lines: Type.Optional(Type.Number({ description: "Max lines in the default excerpt (default 10)." })),
|
|
396
|
+
tail_lines: Type.Optional(Type.Number({ description: "Deprecated alias for lines. lines wins when both are given." })),
|
|
397
|
+
cursor: Type.Optional(Type.String({ description: "Caller-owned page or status cursor from a previous response." })),
|
|
398
|
+
max_bytes: Type.Optional(Type.Number({ description: "UTF-8 byte budget for this page (default 1 KiB, max 4 KiB; raw default 16 KiB, max 64 KiB)." })),
|
|
399
|
+
maxBytes: Type.Optional(Type.Number({ description: MAX_BYTES_ALIAS_DESCRIPTION })),
|
|
400
|
+
mode: Type.Optional(Type.String({ description: "raw = page retained log bytes. Default is the bounded assembled excerpt." })),
|
|
401
|
+
tail: Type.Optional(Type.Boolean({ description: TAIL_DESCRIPTION })),
|
|
402
|
+
include: Type.Optional(Type.Array(Type.String(), { description: INCLUDE_DESCRIPTION })),
|
|
403
|
+
history: Type.Optional(Type.Boolean({ description: HISTORY_DESCRIPTION })),
|
|
404
|
+
all: Type.Optional(Type.Boolean({ description: "If true, allow a foreign-session id. Default is current session only." })),
|
|
405
|
+
}),
|
|
406
|
+
async execute(_id, params, _signal, _onUpdate, ctx) {
|
|
407
|
+
const session = forCall(baseSession, ctx);
|
|
408
|
+
const p = normalizeOutputRequest(params);
|
|
409
|
+
const access = resolveRunAccess(p.id, p, session);
|
|
410
|
+
if (access.kind === "missing")
|
|
411
|
+
throw unknownRunError(p.id);
|
|
412
|
+
if (access.kind === "unreadable")
|
|
413
|
+
return text(assembleUnreadableMetadata(p.id, access.detail, p));
|
|
414
|
+
if (access.kind === "denied")
|
|
415
|
+
return text(access.payload);
|
|
416
|
+
const scopeKey = requestScopeKey(p, session);
|
|
417
|
+
const healthLine = diagnosticLines(access.meta);
|
|
418
|
+
const result = text(assembleSubagentOutput(p.id, access.meta, p, healthLine, scopeKey));
|
|
419
|
+
const details = permissionDetails(p.id, budgetFor("log", p.maxBytes));
|
|
420
|
+
return { ...result, details: { ...details, assignment: assignmentFor(access.meta, effectiveStatus(access.meta)) } };
|
|
421
|
+
},
|
|
422
|
+
};
|
|
423
|
+
}
|
|
424
|
+
// ---- subagent_result ------------------------------------------------------
|
|
425
|
+
export function subagentResultTool(Type, baseSession = {}) {
|
|
426
|
+
return {
|
|
427
|
+
name: "subagent_result",
|
|
428
|
+
label: "Subagent Result",
|
|
429
|
+
description: "Read a subagent's final output if it has finished. NEVER waits. Default current session. Ordinary answers are preserved verbatim in a 2048-byte UTF-8 page (max_bytes up to 8192 bytes, optional lines cap); pass cursor to reconstruct the rest. Pass all:true for a foreign-session id. mode=raw pages retained log bytes (16 KiB default, 64 KiB cap) and tail:true with mode=raw starts from the newest bytes. Failures and exceptional lifecycle facts come before progress. No tool-name histories or default cost lines; pass include:[\"cost\",\"tools\"] to opt in.",
|
|
430
|
+
promptSnippet: "Read a finished subagent's final result (never waits)",
|
|
431
|
+
promptGuidelines: [
|
|
432
|
+
"Use subagent_result to collect a finished run's output. If it reports the run is still going, stop — do not poll; you'll be notified when it finishes.",
|
|
433
|
+
"If the response includes nextCursor, call again with that cursor to read the rest of the answer. Do not summarize away unread pages.",
|
|
434
|
+
"For a durable assignment outcome, inspect its evidence, then call subagent_result with the exact outcome_revision, disposition consumed or dismissed, and an interpretation note. Delivery and reading never acknowledge the worker's dependency wait.",
|
|
435
|
+
],
|
|
436
|
+
parameters: Type.Object({
|
|
437
|
+
operation_id: Type.Optional(Type.String({ description: "Assignment dependency whose bounded retained log to inspect." })),
|
|
438
|
+
outcome_revision: Type.Optional(Type.Number({ description: "Exact assignment outcome revision being disposed." })),
|
|
439
|
+
disposition: Type.Optional(Type.String({ description: "consumed or dismissed; records parent outcome disposition, never worker acknowledgement." })),
|
|
440
|
+
note: Type.Optional(Type.String({ description: "Parent interpretation of the inspected outcome." })),
|
|
441
|
+
id: Type.String({ description: "Run id from subagent_spawn." }),
|
|
442
|
+
cursor: Type.Optional(Type.String({ description: "Caller-owned answer page or status cursor from a previous response." })),
|
|
443
|
+
max_bytes: Type.Optional(Type.Number({ description: "UTF-8 byte budget for this page (default 2048 bytes, max 8192 bytes)." })),
|
|
444
|
+
maxBytes: Type.Optional(Type.Number({ description: MAX_BYTES_ALIAS_DESCRIPTION })),
|
|
445
|
+
lines: Type.Optional(Type.Number({ description: "Optional line cap for each answer page (default: bytes only). nextCursor continues after the last line shown." })),
|
|
446
|
+
tail_lines: Type.Optional(Type.Number({ description: "Deprecated alias for lines. lines wins when both are given." })),
|
|
447
|
+
mode: Type.Optional(Type.String({ description: "raw = page retained log bytes (16 KiB default, 64 KiB cap). Default is the bounded assembled result." })),
|
|
448
|
+
tail: Type.Optional(Type.Boolean({ description: TAIL_DESCRIPTION })),
|
|
449
|
+
include: Type.Optional(Type.Array(Type.String(), { description: INCLUDE_DESCRIPTION })),
|
|
450
|
+
history: Type.Optional(Type.Boolean({ description: HISTORY_DESCRIPTION })),
|
|
451
|
+
all: Type.Optional(Type.Boolean({ description: "If true, allow a foreign-session id. Default is current session only." })),
|
|
452
|
+
}),
|
|
453
|
+
renderResult(result, options, theme) {
|
|
454
|
+
return renderSubagentResultDisplay(result, options, theme);
|
|
455
|
+
},
|
|
456
|
+
async execute(_id, params, _signal, _onUpdate, ctx) {
|
|
457
|
+
const session = forCall(baseSession, ctx);
|
|
458
|
+
const p = normalizeOutputRequest(params);
|
|
459
|
+
const access = resolveRunAccess(p.id, p, session);
|
|
460
|
+
if (access.kind === "missing")
|
|
461
|
+
throw unknownRunError(p.id);
|
|
462
|
+
if (access.kind === "unreadable") {
|
|
463
|
+
return subagentResultText(assembleUnreadableMetadata(p.id, access.detail, p));
|
|
464
|
+
}
|
|
465
|
+
if (access.kind === "denied")
|
|
466
|
+
return subagentResultText(access.payload);
|
|
467
|
+
const meta = access.meta;
|
|
468
|
+
const observed = await session.observeAssignment?.(meta.id);
|
|
469
|
+
const outcome = meta.assignment ? baseSession.inspectOutcome?.(meta, params, ctx) : undefined;
|
|
470
|
+
// Exact inspection has already checked recipient and read authority.
|
|
471
|
+
// Its immutable terminal record supersedes an older shared projection
|
|
472
|
+
// without adding another read or changing the snapshot provenance.
|
|
473
|
+
const inspected = outcome;
|
|
474
|
+
const assignment = inspected?.outcome ? projectAssignment(meta, effectiveStatus(meta), {
|
|
475
|
+
verified: true, waits: inspected.dependencies ?? [], ...{ outcome: inspected.outcome },
|
|
476
|
+
}) : observed?.assignment;
|
|
477
|
+
return withAssignmentObservations(assignment ? [{ meta, assignment }] : [], () => {
|
|
478
|
+
const resultText = (body) => {
|
|
479
|
+
const evidence = outcome;
|
|
480
|
+
const operations = evidence?.dependencies?.flatMap((wait) => wait.dependencies.map((dependency) => dependency.operationId)).slice(0, 5) ?? [];
|
|
481
|
+
const header = evidence?.outcome ? `Outcome r${evidence.outcome.revision}: ${evidence.outcome.outcome}. ${evidence.outcome.reason.slice(0, 256)}${operations.length ? `\nEvidence operations: ${operations.join(", ")}` : ""}\n` : "";
|
|
482
|
+
const result = subagentResultText(header + body);
|
|
483
|
+
return { ...result, details: { ...result.details, outcome, outcomeSupport: meta.outcomeSupport, assignment: assignment ?? assignmentFor(meta, effectiveStatus(meta)), snapshot: observed?.snapshot, ...permissionDetails(p.id, budgetFor("answer", p.maxBytes)) } };
|
|
484
|
+
};
|
|
485
|
+
if (params.operation_id && outcome) {
|
|
486
|
+
const evidence = outcome;
|
|
487
|
+
const text = `Assignment outcome r${evidence.outcome.revision}: ${evidence.outcome.outcome}\n${evidence.outcome.reason}\n${evidence.logs.map((log) => log.text).join("\n")}`;
|
|
488
|
+
const bytes = Buffer.from(text);
|
|
489
|
+
return resultText(bytes.subarray(0, budgetFor("answer", p.maxBytes)).toString("utf8"));
|
|
490
|
+
}
|
|
491
|
+
const scopeKey = requestScopeKey(p, session);
|
|
492
|
+
const st = effectiveStatus(meta);
|
|
493
|
+
const healthLine = diagnosticLines(meta);
|
|
494
|
+
if (!isFinalResultStatus(st)) {
|
|
495
|
+
if (st === "orphaned") {
|
|
496
|
+
return resultText(assembleOrphanedResult(p.id, meta, healthLine, p, scopeKey));
|
|
497
|
+
}
|
|
498
|
+
return resultText(assembleRunningResult(p.id, meta, p, scopeKey, healthLine));
|
|
499
|
+
}
|
|
500
|
+
const body = buildSubagentResultPayload(p.id, p, healthLine, scopeKey);
|
|
501
|
+
if (body === null) {
|
|
502
|
+
return resultText(assembleRunningResult(p.id, meta, p, scopeKey, healthLine));
|
|
503
|
+
}
|
|
504
|
+
return resultText(body);
|
|
505
|
+
});
|
|
506
|
+
},
|
|
507
|
+
};
|
|
508
|
+
}
|
|
509
|
+
// ---- subagent_stop --------------------------------------------------------
|
|
510
|
+
/**
|
|
511
|
+
* Stop is the one tool with a UI side effect (widget redraw after a kill);
|
|
512
|
+
* the caller injects it so the factory stays loadable without a TUI context.
|
|
513
|
+
* The hook receives the run id so the host can also queue the run's one
|
|
514
|
+
* terminal completion callback (#624).
|
|
515
|
+
*/
|
|
516
|
+
export function subagentStopTool(Type, deps = {}) {
|
|
517
|
+
return {
|
|
518
|
+
name: "subagent_stop",
|
|
519
|
+
label: "Stop Subagent",
|
|
520
|
+
description: "Stop a running or orphaned subagent. Terminates identifiable related " +
|
|
521
|
+
"process-group members when present; otherwise finalizes from log " +
|
|
522
|
+
"evidence (completed/failed) or records lost. " +
|
|
523
|
+
"An abandoned launch record (a launch that never wrote metadata and never " +
|
|
524
|
+
"started a child) is removed instead; a launch that is still preparing or " +
|
|
525
|
+
"published concurrently is preserved.",
|
|
526
|
+
promptSnippet: "Stop a running or orphaned background subagent",
|
|
527
|
+
parameters: Type.Object({
|
|
528
|
+
id: Type.String({ description: "Run id from subagent_spawn." }),
|
|
529
|
+
}),
|
|
530
|
+
async execute(_id, params) {
|
|
531
|
+
const p = params;
|
|
532
|
+
// Shared stop semantics with the TUI navigator close action (#44/#68):
|
|
533
|
+
// stopRun rereads meta + effective status from disk before acting.
|
|
534
|
+
const outcome = stopRun(p.id);
|
|
535
|
+
if (outcome.action === "purged") {
|
|
536
|
+
// No run record exists, so the stop hook's completion half is a
|
|
537
|
+
// no-op (#624); the widget/ticker refresh still applies.
|
|
538
|
+
deps.onStopped?.(p.id);
|
|
539
|
+
return text(`Removed abandoned launch record ${p.id} (no run metadata was written, so no child ever ran).`);
|
|
540
|
+
}
|
|
541
|
+
if (outcome.action === "preserved") {
|
|
542
|
+
// Nothing stopped: a live run owes no terminal completion, so the
|
|
543
|
+
// stop hook is deliberately not fired here (#624).
|
|
544
|
+
return text(outcome.status === "launching"
|
|
545
|
+
? `Preserved ${p.id}: a launch is still preparing it (no metadata yet), so nothing was removed. Retry after it publishes, or after it fails.`
|
|
546
|
+
: `Preserved ${p.id}: a concurrent launch published this run (${outcome.status}), so nothing was removed. Call subagent_stop again to stop the run.`);
|
|
547
|
+
}
|
|
548
|
+
if (outcome.action === "not-running") {
|
|
549
|
+
return text(`Run ${p.id} is not running (${outcome.status}).`);
|
|
550
|
+
}
|
|
551
|
+
deps.onStopped?.(p.id);
|
|
552
|
+
if (outcome.action === "finalized") {
|
|
553
|
+
return text(`Resolved orphaned subagent ${p.id} → ${outcome.status}.`);
|
|
554
|
+
}
|
|
555
|
+
return text(`Stopped subagent ${p.id}.`);
|
|
556
|
+
},
|
|
557
|
+
};
|
|
558
|
+
}
|