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,16 @@
|
|
|
1
|
+
// Generated fixed launch domain from packages/pi-better-subagents/child-codemode.ts. Do not edit directly.
|
|
2
|
+
/** Native Pi codemode, explicitly loaded because children disable extension discovery. */
|
|
3
|
+
import * as SDK from "@earendil-works/pi-coding-agent";
|
|
4
|
+
/** Older supported SDKs have no native codemode; keep their existing tool set. */
|
|
5
|
+
export function installChildCodemode(pi, confined = false) {
|
|
6
|
+
const factory = SDK.createCodemodeExtension;
|
|
7
|
+
if (typeof factory !== "function")
|
|
8
|
+
return false;
|
|
9
|
+
// Model globals make direct provider calls outside nested tool hooks.
|
|
10
|
+
// Confined children get only tool dispatch, which passes through the guard.
|
|
11
|
+
factory(confined ? { models: false } : {})(pi);
|
|
12
|
+
return true;
|
|
13
|
+
}
|
|
14
|
+
export default function childCodemode(pi) {
|
|
15
|
+
installChildCodemode(pi);
|
|
16
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/** Native Pi codemode, explicitly loaded because children disable extension discovery. */
|
|
2
|
+
import * as SDK from "@earendil-works/pi-coding-agent";
|
|
3
|
+
import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
|
|
4
|
+
|
|
5
|
+
/** Older supported SDKs have no native codemode; keep their existing tool set. */
|
|
6
|
+
export function installChildCodemode(pi: ExtensionAPI, confined = false): boolean {
|
|
7
|
+
const factory = (SDK as any).createCodemodeExtension;
|
|
8
|
+
if (typeof factory !== "function") return false;
|
|
9
|
+
// Model globals make direct provider calls outside nested tool hooks.
|
|
10
|
+
// Confined children get only tool dispatch, which passes through the guard.
|
|
11
|
+
factory(confined ? { models: false } : {})(pi);
|
|
12
|
+
return true;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export default function childCodemode(pi: ExtensionAPI): void {
|
|
16
|
+
installChildCodemode(pi);
|
|
17
|
+
}
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
// Generated fixed launch domain from packages/pi-better-subagents/child-dependencies.mjs. Do not edit directly.
|
|
2
|
+
/** Declared child dependency closure. Reading a contract never initializes its extension. */
|
|
3
|
+
import { readFileSync, existsSync, statSync, realpathSync } from 'node:fs';
|
|
4
|
+
import { dirname, join, resolve, isAbsolute } from 'node:path';
|
|
5
|
+
import { createRequire } from 'node:module';
|
|
6
|
+
import { pathToFileURL, fileURLToPath } from 'node:url';
|
|
7
|
+
import { createHash } from 'node:crypto';
|
|
8
|
+
import { BUILTIN_PROVIDER_EXTENSIONS, providerOf } from './extensions.mjs';
|
|
9
|
+
export function packageRoot(path) {
|
|
10
|
+
let dir = statSync(path).isDirectory() ? path : dirname(path);
|
|
11
|
+
while (!existsSync(join(dir, 'package.json'))) {
|
|
12
|
+
const parent = dirname(dir);
|
|
13
|
+
if (parent === dir)
|
|
14
|
+
return undefined;
|
|
15
|
+
dir = parent;
|
|
16
|
+
}
|
|
17
|
+
return realpathSync(dir);
|
|
18
|
+
}
|
|
19
|
+
/** Search the declaring package's dependencies first, then the caller's installed roots. */
|
|
20
|
+
export function installedPackage(name, roots) {
|
|
21
|
+
for (const root of roots.filter(Boolean)) {
|
|
22
|
+
let dir = root;
|
|
23
|
+
while (true) {
|
|
24
|
+
const candidate = join(dir, 'node_modules', name);
|
|
25
|
+
if (existsSync(join(candidate, 'package.json')))
|
|
26
|
+
return realpathSync(candidate);
|
|
27
|
+
const parent = dirname(dir);
|
|
28
|
+
if (parent === dir)
|
|
29
|
+
break;
|
|
30
|
+
dir = parent;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
export async function loadContract(path) {
|
|
35
|
+
// Use the host's TS loader, with fresh module state for every declaration read.
|
|
36
|
+
const sdkRequire = createRequire(fileURLToPath(import.meta.resolve('@earendil-works/pi-coding-agent')));
|
|
37
|
+
const { createJiti } = await import(pathToFileURL(sdkRequire.resolve('jiti')).href);
|
|
38
|
+
return createJiti(import.meta.url, { tryNative: false, fsCache: false, moduleCache: false })
|
|
39
|
+
.import(path, { default: true });
|
|
40
|
+
}
|
|
41
|
+
function strings(value, label) {
|
|
42
|
+
if (!Array.isArray(value) || value.some(x => typeof x !== 'string' || !x.trim()))
|
|
43
|
+
throw new Error(`Invalid child declaration: ${label} must be an array of nonempty strings.`);
|
|
44
|
+
return value;
|
|
45
|
+
}
|
|
46
|
+
export function validateRequirements(value) {
|
|
47
|
+
if (!value || typeof value !== 'object')
|
|
48
|
+
throw new Error('Invalid childRequirements result.');
|
|
49
|
+
strings(value.providers, 'providers');
|
|
50
|
+
if (!Array.isArray(value.modelGroups))
|
|
51
|
+
throw new Error('Invalid childRequirements modelGroups.');
|
|
52
|
+
for (const group of value.modelGroups) {
|
|
53
|
+
if (!group || typeof group.provider !== 'string' || !group.provider.trim())
|
|
54
|
+
throw new Error('Invalid model group provider.');
|
|
55
|
+
strings(group.ids, 'modelGroups.ids');
|
|
56
|
+
if (group.prefix !== undefined && (typeof group.prefix !== 'string' || !group.prefix))
|
|
57
|
+
throw new Error('Invalid model group prefix.');
|
|
58
|
+
if (!group.ids.length && !group.prefix)
|
|
59
|
+
throw new Error('Empty child model group.');
|
|
60
|
+
}
|
|
61
|
+
return value;
|
|
62
|
+
}
|
|
63
|
+
export function fingerprint(path) {
|
|
64
|
+
return existsSync(path) ? createHash('sha256').update(readFileSync(path)).digest('hex') : null;
|
|
65
|
+
}
|
|
66
|
+
// Credential refresh and catalog caches are runtime state, not dependency configuration.
|
|
67
|
+
const CONFIG_INPUTS = ['settings.json', 'harness-settings.json', 'model-router.json', 'models.json'];
|
|
68
|
+
export function configSnapshot(directories) {
|
|
69
|
+
return directories.map(dir => ({ dir, files: CONFIG_INPUTS.map(name => ({ name, hash: fingerprint(join(dir, name)) })) }));
|
|
70
|
+
}
|
|
71
|
+
export async function resolveChildClosure({ resolution, model, virtual = false, config = {}, resolvePath, load = loadContract, configPaths = [] }) {
|
|
72
|
+
const result = { ...resolution, specs: [], reasons: { ...resolution.reasons }, paths: {}, declarations: [],
|
|
73
|
+
providers: [], modelGroups: [], fingerprints: configPaths.map(path => ({ path, hash: fingerprint(path) })) };
|
|
74
|
+
function requiredPath(spec, from) {
|
|
75
|
+
const path = resolvePath(spec, from);
|
|
76
|
+
if (path)
|
|
77
|
+
return path;
|
|
78
|
+
const reason = (resolution.reasons[spec] ?? []).join(', ');
|
|
79
|
+
throw new Error(`Child dependency ${spec}${from ? ` required by ${from}` : ''} is not installed.${reason ? ` Selected for ${reason}.` : ''}`);
|
|
80
|
+
}
|
|
81
|
+
if (resolution.mode !== 'isolated') {
|
|
82
|
+
if (virtual)
|
|
83
|
+
throw new Error(`Virtual model ${model} requires isolated mode with a declared supplier; ${resolution.mode} mode is unsupported.`);
|
|
84
|
+
return { ...result, specs: resolution.specs, paths: Object.fromEntries(resolution.specs.map(spec => [spec, requiredPath(spec)])) };
|
|
85
|
+
}
|
|
86
|
+
const providerMap = { ...BUILTIN_PROVIDER_EXTENSIONS, ...(config.providerExtensions ?? {}) };
|
|
87
|
+
const active = [], done = new Set(), entrypoints = new Set();
|
|
88
|
+
let ownsVirtual = false;
|
|
89
|
+
const visit = async (spec, from) => {
|
|
90
|
+
const path = requiredPath(spec, from);
|
|
91
|
+
const root = packageRoot(path);
|
|
92
|
+
const identity = root ?? realpathSync(path);
|
|
93
|
+
if (active.includes(identity))
|
|
94
|
+
throw new Error(`Child dependency cycle: ${[...active, identity].join(' -> ')}`);
|
|
95
|
+
// Different tool entrypoints can share a package and its dependency manifest.
|
|
96
|
+
const entrypoint = realpathSync(path);
|
|
97
|
+
if (entrypoints.has(entrypoint))
|
|
98
|
+
return;
|
|
99
|
+
entrypoints.add(entrypoint);
|
|
100
|
+
// Two packages may declare the same relative spec against different roots.
|
|
101
|
+
const key = result.paths[spec] && result.paths[spec] !== path ? path : spec;
|
|
102
|
+
result.specs.push(key);
|
|
103
|
+
result.paths[key] = path;
|
|
104
|
+
if (done.has(identity))
|
|
105
|
+
return;
|
|
106
|
+
active.push(identity);
|
|
107
|
+
if (root) {
|
|
108
|
+
const manifestPath = join(root, 'package.json');
|
|
109
|
+
const manifest = JSON.parse(readFileSync(manifestPath, 'utf8'));
|
|
110
|
+
result.fingerprints.push({ path: manifestPath, hash: fingerprint(manifestPath) });
|
|
111
|
+
const declaration = manifest.pi ?? {};
|
|
112
|
+
for (const dependency of strings(declaration.childDependencies ?? [], 'pi.childDependencies'))
|
|
113
|
+
await visit(dependency, root);
|
|
114
|
+
if (declaration.childRequirements !== undefined) {
|
|
115
|
+
if (typeof declaration.childRequirements !== 'string' || isAbsolute(declaration.childRequirements))
|
|
116
|
+
throw new Error(`Invalid childRequirements path in ${root}`);
|
|
117
|
+
const entry = resolve(root, declaration.childRequirements);
|
|
118
|
+
if (!entry.startsWith(root + '/'))
|
|
119
|
+
throw new Error(`childRequirements escapes ${root}`);
|
|
120
|
+
const fn = await load(entry);
|
|
121
|
+
if (typeof fn !== 'function')
|
|
122
|
+
throw new Error(`childRequirements in ${root} has no default function.`);
|
|
123
|
+
const requirements = await fn({ model });
|
|
124
|
+
result.fingerprints.push({ path: entry, hash: fingerprint(entry) });
|
|
125
|
+
result.declarations.push({ entry, requirements: requirements ?? null });
|
|
126
|
+
if (requirements !== undefined) {
|
|
127
|
+
validateRequirements(requirements);
|
|
128
|
+
if ((resolution.reasons[spec] ?? []).includes(`provider:${providerOf(model)}`))
|
|
129
|
+
ownsVirtual = true;
|
|
130
|
+
result.providers.push(...requirements.providers);
|
|
131
|
+
result.modelGroups.push(...requirements.modelGroups);
|
|
132
|
+
for (const provider of requirements.providers) {
|
|
133
|
+
const mapped = providerMap[provider];
|
|
134
|
+
for (const supplier of typeof mapped === 'string' ? [mapped] : mapped ?? [])
|
|
135
|
+
await visit(supplier, root);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
active.pop();
|
|
141
|
+
done.add(identity);
|
|
142
|
+
};
|
|
143
|
+
for (const spec of resolution.specs)
|
|
144
|
+
await visit(spec);
|
|
145
|
+
if (virtual && !ownsVirtual)
|
|
146
|
+
throw new Error(`Virtual model ${model} has no mapped supplier with a childRequirements contract for this selection.`);
|
|
147
|
+
result.providers = [...new Set(result.providers)];
|
|
148
|
+
return result;
|
|
149
|
+
}
|
|
150
|
+
/** Both passes start with declared roots; expanded specs retain their declaring context only inside a traversal. */
|
|
151
|
+
export async function resolveChildLaunch(options, trustedPaths = []) {
|
|
152
|
+
const resolution = await resolveChildClosure(options);
|
|
153
|
+
const fullResolution = await resolveChildClosure({ ...options, resolution: {
|
|
154
|
+
...options.resolution, specs: [...options.resolution.specs, ...new Set(trustedPaths)],
|
|
155
|
+
} });
|
|
156
|
+
return { resolution, fullResolution };
|
|
157
|
+
}
|
|
158
|
+
/** Validate actual child registration, never the parent's catalog. Groups require one physical candidate. */
|
|
159
|
+
export async function checkChildPreflight(plan, { registry, tools, registeredTools = [], model }, load = loadContract) {
|
|
160
|
+
if (plan.configSnapshot && JSON.stringify(configSnapshot(plan.configSnapshot.map(item => item.dir))) !== JSON.stringify(plan.configSnapshot))
|
|
161
|
+
throw new Error('Child configuration drift: agent or project JSON configuration changed. Launch again.');
|
|
162
|
+
for (const item of plan.fingerprints)
|
|
163
|
+
if (fingerprint(item.path) !== item.hash)
|
|
164
|
+
throw new Error(`Child configuration/declaration drift: ${item.path}. Launch again with current configuration.`);
|
|
165
|
+
for (const declaration of plan.declarations) {
|
|
166
|
+
const fn = await load(declaration.entry);
|
|
167
|
+
const current = await fn({ model: plan.model });
|
|
168
|
+
if (JSON.stringify(current ?? null) !== JSON.stringify(declaration.requirements))
|
|
169
|
+
throw new Error(`Child requirements changed: ${declaration.entry}. Launch again.`);
|
|
170
|
+
}
|
|
171
|
+
if (plan.model && (!model || `${model.provider}/${model.id}` !== plan.model))
|
|
172
|
+
throw new Error(`Selected child model ${plan.model} is missing or changed.`);
|
|
173
|
+
const available = registry.getAvailable();
|
|
174
|
+
if (plan.model && !available.some(m => `${m.provider}/${m.id}` === plan.model))
|
|
175
|
+
throw new Error(`Selected child model ${plan.model} is not available; check its provider and credentials.`);
|
|
176
|
+
for (const provider of plan.providers)
|
|
177
|
+
if (!available.some(m => m.provider === provider && m.api !== 'pi-virtual'))
|
|
178
|
+
throw new Error(`Child requires available provider ${provider}; check its extension and credentials.`);
|
|
179
|
+
for (const group of plan.modelGroups)
|
|
180
|
+
if (!available.some(m => m.provider === group.provider && m.api !== 'pi-virtual' &&
|
|
181
|
+
(group.ids.includes(m.id) || (group.prefix && m.id.startsWith(group.prefix)))))
|
|
182
|
+
throw new Error(`Child has no available candidate for ${group.provider}: ${group.ids.join(', ')}${group.prefix ? ` (prefix ${group.prefix})` : ''}. Check extension, models and credentials.`);
|
|
183
|
+
const inactive = [];
|
|
184
|
+
for (const tool of plan.tools) {
|
|
185
|
+
if (tools.includes(tool))
|
|
186
|
+
continue;
|
|
187
|
+
if (!plan.optionalTrustedTools?.includes(tool) || !registeredTools.includes(tool)) {
|
|
188
|
+
throw new Error(`Child requested tool ${tool} is unavailable.`);
|
|
189
|
+
}
|
|
190
|
+
inactive.push(tool);
|
|
191
|
+
}
|
|
192
|
+
return inactive;
|
|
193
|
+
}
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
// Generated fixed launch domain from packages/pi-better-subagents/child-incidents.ts. Do not edit directly.
|
|
2
|
+
/**
|
|
3
|
+
* Child-side structured failure intent (#315), installed by the trusted task runtime.
|
|
4
|
+
*
|
|
5
|
+
* - `bash` accepts optional `operationId`, `attemptId`, and `expectedExitCodes`. They are
|
|
6
|
+
* validated before the command runs. A declared exit code returns a non-error result
|
|
7
|
+
* whose details carry the structured exit code; every other non-zero exit, timeout, or
|
|
8
|
+
* abort stays an ordinary tool error.
|
|
9
|
+
* - `failure_disposition` lets the agent that owns an incident classify it explicitly.
|
|
10
|
+
* It validates against the same incident model the parent scanner replays, so the
|
|
11
|
+
* parent journals exactly what the child accepted and nothing else.
|
|
12
|
+
*/
|
|
13
|
+
import * as PiCodingAgent from "@earendil-works/pi-coding-agent";
|
|
14
|
+
// The intent validator is shared with background tasks through the vendored failure-observations module (#325).
|
|
15
|
+
import { emptyFailureState, reduceFailure, INTENT_ID_PATTERN, MAX_EXPECTED_EXIT_CODES, readCommandIntent, withoutAbsentIntent } from "./shared-failure-observations.domain.mjs";
|
|
16
|
+
import { DISPOSITION_TOOL, describeOpenTargets, foldToolEnd, foldToolStart, newIncidentModel, readDispositionRequest, resolveDisposition } from "./incident-model.domain.mjs";
|
|
17
|
+
const { createBashToolDefinition } = PiCodingAgent;
|
|
18
|
+
import { PERMISSION_RESOURCES } from "./shared-permission-blocker.domain.mjs";
|
|
19
|
+
// Each intent field also admits `null`, which means "not declared" (withoutAbsentIntent). Models send
|
|
20
|
+
// optional fields as explicit null; accepting it in the schema means Pi hands execute the same raw
|
|
21
|
+
// arguments the process log and session record keep, on every Pi version (0.82 rejected a null
|
|
22
|
+
// before execute, 0.87 silently drops it), so the child and the parent's replay read one input.
|
|
23
|
+
// `anyOf` rather than a `type` array: Pi 0.82's TypeBox compiler crashes on `["array", "null"]` + `items`.
|
|
24
|
+
const nullable = (schema) => ({ anyOf: [schema, { type: "null" }] });
|
|
25
|
+
const intentProperties = {
|
|
26
|
+
operationId: { ...nullable({ type: "string", pattern: INTENT_ID_PATTERN }),
|
|
27
|
+
description: "Optional stable id for one logical operation. Reuse it on a modified retry (changed scope, timeout, or flags) so a later success recovers the earlier failure." },
|
|
28
|
+
attemptId: { ...nullable({ type: "string", pattern: INTENT_ID_PATTERN }),
|
|
29
|
+
description: "Optional unique id for this execution, for use as evidence in failure_disposition." },
|
|
30
|
+
expectedExitCodes: { ...nullable({ type: "array", items: { type: "integer", minimum: 0, maximum: 255 }, minItems: 1, maxItems: MAX_EXPECTED_EXIT_CODES }),
|
|
31
|
+
// Distinctness is enforced by readCommandIntent, not `uniqueItems`: OpenAI rejects that keyword
|
|
32
|
+
// in function schemas, which failed every confined child's first request.
|
|
33
|
+
description: "Optional distinct non-zero exit codes that are intentional for this command (for example [1] for an rg/grep no-match or git diff --exit-code probe). 0 is allowed and ignored: exit 0 is already success. Declared before the command runs; the final shell exit code is what is classified." },
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* Every tool call the child session has recorded, in append order, across all branches (#325).
|
|
37
|
+
* The parent scans the child's whole process log, not one session branch, so the child reads the
|
|
38
|
+
* whole session too: after a branch switch or compaction the two views still agree. Session
|
|
39
|
+
* entries are a superset of the log's tool starts (an assistant message is recorded before its
|
|
40
|
+
* tools run), so a reuse the parent sees is always one the child also saw and refused.
|
|
41
|
+
*/
|
|
42
|
+
function sessionToolCalls(ctx) {
|
|
43
|
+
const manager = ctx?.sessionManager;
|
|
44
|
+
const branch = (manager?.getEntries?.() ?? manager?.getBranch?.() ?? []);
|
|
45
|
+
const rows = [];
|
|
46
|
+
let pendingEnds = [];
|
|
47
|
+
const flush = () => { rows.push(...pendingEnds); pendingEnds = []; };
|
|
48
|
+
for (const entry of branch) {
|
|
49
|
+
const message = entry?.type === "message" ? entry.message : undefined;
|
|
50
|
+
if (!message)
|
|
51
|
+
continue;
|
|
52
|
+
if (message.role === "assistant") {
|
|
53
|
+
flush();
|
|
54
|
+
for (const part of Array.isArray(message.content) ? message.content : []) {
|
|
55
|
+
if (part?.type === "toolCall" && typeof part.id === "string") {
|
|
56
|
+
rows.push({ type: "tool_execution_start", toolCallId: part.id, toolName: part.name, args: part.arguments });
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
else if (message.role === "toolResult" && typeof message.toolCallId === "string") {
|
|
61
|
+
pendingEnds.push({ type: "tool_execution_end", toolCallId: message.toolCallId, toolName: message.toolName,
|
|
62
|
+
isError: message.isError === true, result: { content: message.content, details: message.details } });
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
flush();
|
|
66
|
+
return rows;
|
|
67
|
+
}
|
|
68
|
+
/** Rebuild the child's view of its own incidents from the durable session record (every branch). */
|
|
69
|
+
export function childIncidentView(ctx, cwd) {
|
|
70
|
+
let state = emptyFailureState();
|
|
71
|
+
let at = 0;
|
|
72
|
+
const sink = {
|
|
73
|
+
observe: (events) => { for (const event of events)
|
|
74
|
+
state = reduceFailure(state, event, ++at); return state; },
|
|
75
|
+
dispose: (event) => { state = reduceFailure(state, event, ++at); },
|
|
76
|
+
state: () => state,
|
|
77
|
+
};
|
|
78
|
+
const model = newIncidentModel(true);
|
|
79
|
+
for (const row of sessionToolCalls(ctx)) {
|
|
80
|
+
if (row.type === "tool_execution_start")
|
|
81
|
+
foldToolStart(model, row, cwd, sink);
|
|
82
|
+
else
|
|
83
|
+
foldToolEnd(model, row, cwd, "session", sink);
|
|
84
|
+
}
|
|
85
|
+
return { model, state };
|
|
86
|
+
}
|
|
87
|
+
/** Bash with structured intent, delegating execution to the given operations. */
|
|
88
|
+
export function intentBashDefinition(cwd, operations) {
|
|
89
|
+
const base = createBashToolDefinition(cwd, { operations });
|
|
90
|
+
const parameters = { ...base.parameters, properties: { ...base.parameters.properties, ...intentProperties } };
|
|
91
|
+
return {
|
|
92
|
+
...base,
|
|
93
|
+
parameters,
|
|
94
|
+
async execute(toolCallId, params, signal, onUpdate, ctx) {
|
|
95
|
+
const { intent, error } = readCommandIntent(params);
|
|
96
|
+
if (error)
|
|
97
|
+
throw new Error(`Invalid command intent: ${error}. The command was not run.`);
|
|
98
|
+
if (intent.attemptId) {
|
|
99
|
+
const reused = sessionToolCalls(ctx).some((row) => row.type === "tool_execution_start" && row.toolName === "bash" &&
|
|
100
|
+
row.toolCallId !== toolCallId && withoutAbsentIntent(row.args)?.attemptId === intent.attemptId);
|
|
101
|
+
if (reused)
|
|
102
|
+
throw new Error(`Invalid command intent: attemptId ${intent.attemptId} was already used. The command was not run.`);
|
|
103
|
+
}
|
|
104
|
+
const { operationId: _o, attemptId: _a, expectedExitCodes: _e, ...command } = params ?? {};
|
|
105
|
+
let exitCode;
|
|
106
|
+
const observed = { ...operations, exec: async (...args) => {
|
|
107
|
+
const result = await operations.exec(...args);
|
|
108
|
+
exitCode = result.exitCode;
|
|
109
|
+
return result;
|
|
110
|
+
} };
|
|
111
|
+
const run = createBashToolDefinition(cwd, { operations: observed });
|
|
112
|
+
try {
|
|
113
|
+
return await run.execute(toolCallId, command, signal, onUpdate, ctx);
|
|
114
|
+
}
|
|
115
|
+
catch (failure) {
|
|
116
|
+
if (typeof exitCode === "number" && intent.expectedExitCodes?.includes(exitCode) && !signal?.aborted) {
|
|
117
|
+
const message = failure instanceof Error ? failure.message : String(failure);
|
|
118
|
+
return { content: [{ type: "text", text: `${message}\n(Exit code ${exitCode} was declared expected.)` }],
|
|
119
|
+
details: { exitCode, expectedExit: true, ...(intent.operationId ? { operationId: intent.operationId } : {}),
|
|
120
|
+
...(intent.attemptId ? { attemptId: intent.attemptId } : {}) } };
|
|
121
|
+
}
|
|
122
|
+
throw failure;
|
|
123
|
+
}
|
|
124
|
+
},
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
export function failureDispositionTool(cwd) {
|
|
128
|
+
return {
|
|
129
|
+
name: DISPOSITION_TOOL,
|
|
130
|
+
label: "Failure disposition",
|
|
131
|
+
description: [
|
|
132
|
+
"Classify your own earlier tool failures so the parent is not told about problems you already handled.",
|
|
133
|
+
"recovered: the same operation later passed (evidence = that attempt). superseded: a different verification or remediation established the outcome (evidence = the successful attempt).",
|
|
134
|
+
"expected: the failure was intentional. open: it still needs the parent's action (this asks for attention).",
|
|
135
|
+
"targets: incident ids, the attemptId/operationId you declared on bash, or tool call ids. Unknown or already-disposed incidents are rejected.",
|
|
136
|
+
"Never claim recovery without a successful later attempt as evidence.",
|
|
137
|
+
"For open only, permissionResource optionally reports a permission blocker on the failed attempt; this is agent-reported, not a proven policy denial or remote authorization outcome.",
|
|
138
|
+
].join(" "),
|
|
139
|
+
promptSnippet: "Classify handled tool failures (recovered, superseded, expected) or flag one as open for the parent.",
|
|
140
|
+
parameters: {
|
|
141
|
+
type: "object",
|
|
142
|
+
properties: {
|
|
143
|
+
disposition: { type: "string", enum: ["recovered", "superseded", "expected", "open"] },
|
|
144
|
+
targets: { type: "array", items: { type: "string", minLength: 1, maxLength: 200 }, minItems: 1, maxItems: 20 },
|
|
145
|
+
reason: { type: "string", minLength: 1, maxLength: 400 },
|
|
146
|
+
evidence: { ...nullable({ type: "string", minLength: 1, maxLength: 200 }), description: "attemptId or tool call id of the successful later attempt; required for recovered and superseded." },
|
|
147
|
+
permissionResource: { ...nullable({ type: "string", enum: [...PERMISSION_RESOURCES] }), description: "Optional permission resource for open only. Bound to an unresolved failed worker attempt; remote outcome remains unknown." },
|
|
148
|
+
},
|
|
149
|
+
required: ["disposition", "targets", "reason"],
|
|
150
|
+
additionalProperties: false,
|
|
151
|
+
},
|
|
152
|
+
async execute(toolCallId, params, _signal, _onUpdate, ctx) {
|
|
153
|
+
const parsed = readDispositionRequest(params);
|
|
154
|
+
if (!parsed.request)
|
|
155
|
+
throw new Error(`Disposition rejected: ${parsed.error}.`);
|
|
156
|
+
const { model, state } = childIncidentView(ctx, cwd());
|
|
157
|
+
const outcome = resolveDisposition(model, state, parsed.request, toolCallId);
|
|
158
|
+
if (!outcome.event) {
|
|
159
|
+
const open = describeOpenTargets(model, state);
|
|
160
|
+
throw new Error(`Disposition rejected: ${outcome.error}.` + (open.length ? `\nOpen incidents:\n${open.join("\n")}` : "\nNo open incidents."));
|
|
161
|
+
}
|
|
162
|
+
const incidents = outcome.event.incidents ?? [];
|
|
163
|
+
return {
|
|
164
|
+
content: [{ type: "text", text: `Recorded ${parsed.request.disposition} for ${incidents.length} incident${incidents.length === 1 ? "" : "s"}: ${incidents.join(", ")}.` }],
|
|
165
|
+
details: { disposition: parsed.request.disposition, incidents,
|
|
166
|
+
...(outcome.event.permissionBlockers ? { permissionBlockers: outcome.event.permissionBlockers } : {}) },
|
|
167
|
+
};
|
|
168
|
+
},
|
|
169
|
+
};
|
|
170
|
+
}
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Child-side structured failure intent (#315), installed by the trusted task runtime.
|
|
3
|
+
*
|
|
4
|
+
* - `bash` accepts optional `operationId`, `attemptId`, and `expectedExitCodes`. They are
|
|
5
|
+
* validated before the command runs. A declared exit code returns a non-error result
|
|
6
|
+
* whose details carry the structured exit code; every other non-zero exit, timeout, or
|
|
7
|
+
* abort stays an ordinary tool error.
|
|
8
|
+
* - `failure_disposition` lets the agent that owns an incident classify it explicitly.
|
|
9
|
+
* It validates against the same incident model the parent scanner replays, so the
|
|
10
|
+
* parent journals exactly what the child accepted and nothing else.
|
|
11
|
+
*/
|
|
12
|
+
import * as PiCodingAgent from "@earendil-works/pi-coding-agent";
|
|
13
|
+
import type { BashOperations, ExtensionContext } from "@earendil-works/pi-coding-agent";
|
|
14
|
+
// The intent validator is shared with background tasks through the vendored failure-observations module (#325).
|
|
15
|
+
import { emptyFailureState, reduceFailure, INTENT_ID_PATTERN, MAX_EXPECTED_EXIT_CODES, readCommandIntent, withoutAbsentIntent,
|
|
16
|
+
type FailureEvent, type FailureState } from "./shared-failure-observations.ts";
|
|
17
|
+
import { DISPOSITION_TOOL, describeOpenTargets, foldToolEnd, foldToolStart,
|
|
18
|
+
newIncidentModel, readDispositionRequest, resolveDisposition, type IncidentModel, type IncidentSink } from "./incident-model.ts";
|
|
19
|
+
|
|
20
|
+
const { createBashToolDefinition } = PiCodingAgent;
|
|
21
|
+
import { PERMISSION_RESOURCES } from "./shared-permission-blocker.ts";
|
|
22
|
+
|
|
23
|
+
// Each intent field also admits `null`, which means "not declared" (withoutAbsentIntent). Models send
|
|
24
|
+
// optional fields as explicit null; accepting it in the schema means Pi hands execute the same raw
|
|
25
|
+
// arguments the process log and session record keep, on every Pi version (0.82 rejected a null
|
|
26
|
+
// before execute, 0.87 silently drops it), so the child and the parent's replay read one input.
|
|
27
|
+
// `anyOf` rather than a `type` array: Pi 0.82's TypeBox compiler crashes on `["array", "null"]` + `items`.
|
|
28
|
+
const nullable = (schema: Record<string, unknown>) => ({ anyOf: [schema, { type: "null" }] });
|
|
29
|
+
const intentProperties = {
|
|
30
|
+
operationId: { ...nullable({ type: "string", pattern: INTENT_ID_PATTERN }),
|
|
31
|
+
description: "Optional stable id for one logical operation. Reuse it on a modified retry (changed scope, timeout, or flags) so a later success recovers the earlier failure." },
|
|
32
|
+
attemptId: { ...nullable({ type: "string", pattern: INTENT_ID_PATTERN }),
|
|
33
|
+
description: "Optional unique id for this execution, for use as evidence in failure_disposition." },
|
|
34
|
+
expectedExitCodes: { ...nullable({ type: "array", items: { type: "integer", minimum: 0, maximum: 255 }, minItems: 1, maxItems: MAX_EXPECTED_EXIT_CODES }),
|
|
35
|
+
// Distinctness is enforced by readCommandIntent, not `uniqueItems`: OpenAI rejects that keyword
|
|
36
|
+
// in function schemas, which failed every confined child's first request.
|
|
37
|
+
description: "Optional distinct non-zero exit codes that are intentional for this command (for example [1] for an rg/grep no-match or git diff --exit-code probe). 0 is allowed and ignored: exit 0 is already success. Declared before the command runs; the final shell exit code is what is classified." },
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Every tool call the child session has recorded, in append order, across all branches (#325).
|
|
42
|
+
* The parent scans the child's whole process log, not one session branch, so the child reads the
|
|
43
|
+
* whole session too: after a branch switch or compaction the two views still agree. Session
|
|
44
|
+
* entries are a superset of the log's tool starts (an assistant message is recorded before its
|
|
45
|
+
* tools run), so a reuse the parent sees is always one the child also saw and refused.
|
|
46
|
+
*/
|
|
47
|
+
function sessionToolCalls(ctx: ExtensionContext | undefined): Array<{ type: string; [key: string]: unknown }> {
|
|
48
|
+
const manager = ctx?.sessionManager;
|
|
49
|
+
const branch = (manager?.getEntries?.() ?? manager?.getBranch?.() ?? []) as any[];
|
|
50
|
+
const rows: Array<{ type: string; [key: string]: unknown }> = [];
|
|
51
|
+
let pendingEnds: any[] = [];
|
|
52
|
+
const flush = () => { rows.push(...pendingEnds); pendingEnds = []; };
|
|
53
|
+
for (const entry of branch) {
|
|
54
|
+
const message = entry?.type === "message" ? entry.message : undefined;
|
|
55
|
+
if (!message) continue;
|
|
56
|
+
if (message.role === "assistant") {
|
|
57
|
+
flush();
|
|
58
|
+
for (const part of Array.isArray(message.content) ? message.content : []) {
|
|
59
|
+
if (part?.type === "toolCall" && typeof part.id === "string") {
|
|
60
|
+
rows.push({ type: "tool_execution_start", toolCallId: part.id, toolName: part.name, args: part.arguments });
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
} else if (message.role === "toolResult" && typeof message.toolCallId === "string") {
|
|
64
|
+
pendingEnds.push({ type: "tool_execution_end", toolCallId: message.toolCallId, toolName: message.toolName,
|
|
65
|
+
isError: message.isError === true, result: { content: message.content, details: message.details } });
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
flush();
|
|
69
|
+
return rows;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/** Rebuild the child's view of its own incidents from the durable session record (every branch). */
|
|
73
|
+
export function childIncidentView(ctx: ExtensionContext | undefined, cwd: string): { model: IncidentModel; state: FailureState } {
|
|
74
|
+
let state = emptyFailureState();
|
|
75
|
+
let at = 0;
|
|
76
|
+
const sink: IncidentSink = {
|
|
77
|
+
observe: (events: FailureEvent[]) => { for (const event of events) state = reduceFailure(state, event, ++at); return state; },
|
|
78
|
+
dispose: (event: FailureEvent) => { state = reduceFailure(state, event, ++at); },
|
|
79
|
+
state: () => state,
|
|
80
|
+
};
|
|
81
|
+
const model = newIncidentModel(true);
|
|
82
|
+
for (const row of sessionToolCalls(ctx)) {
|
|
83
|
+
if (row.type === "tool_execution_start") foldToolStart(model, row, cwd, sink);
|
|
84
|
+
else foldToolEnd(model, row, cwd, "session", sink);
|
|
85
|
+
}
|
|
86
|
+
return { model, state };
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/** Bash with structured intent, delegating execution to the given operations. */
|
|
90
|
+
export function intentBashDefinition(cwd: string, operations: BashOperations) {
|
|
91
|
+
const base = createBashToolDefinition(cwd, { operations });
|
|
92
|
+
const parameters = { ...base.parameters, properties: { ...(base.parameters as any).properties, ...intentProperties } };
|
|
93
|
+
return {
|
|
94
|
+
...base,
|
|
95
|
+
parameters,
|
|
96
|
+
async execute(toolCallId: string, params: any, signal: AbortSignal | undefined, onUpdate: any, ctx: ExtensionContext) {
|
|
97
|
+
const { intent, error } = readCommandIntent(params);
|
|
98
|
+
if (error) throw new Error(`Invalid command intent: ${error}. The command was not run.`);
|
|
99
|
+
if (intent.attemptId) {
|
|
100
|
+
const reused = sessionToolCalls(ctx).some((row) => row.type === "tool_execution_start" && row.toolName === "bash" &&
|
|
101
|
+
row.toolCallId !== toolCallId && (withoutAbsentIntent(row.args) as any)?.attemptId === intent.attemptId);
|
|
102
|
+
if (reused) throw new Error(`Invalid command intent: attemptId ${intent.attemptId} was already used. The command was not run.`);
|
|
103
|
+
}
|
|
104
|
+
const { operationId: _o, attemptId: _a, expectedExitCodes: _e, ...command } = params ?? {};
|
|
105
|
+
let exitCode: number | null | undefined;
|
|
106
|
+
const observed: BashOperations = { ...operations, exec: async (...args: Parameters<BashOperations["exec"]>) => {
|
|
107
|
+
const result = await operations.exec(...args);
|
|
108
|
+
exitCode = result.exitCode;
|
|
109
|
+
return result;
|
|
110
|
+
} };
|
|
111
|
+
const run = createBashToolDefinition(cwd, { operations: observed });
|
|
112
|
+
try {
|
|
113
|
+
return await run.execute(toolCallId, command, signal, onUpdate, ctx);
|
|
114
|
+
} catch (failure) {
|
|
115
|
+
if (typeof exitCode === "number" && intent.expectedExitCodes?.includes(exitCode) && !signal?.aborted) {
|
|
116
|
+
const message = failure instanceof Error ? failure.message : String(failure);
|
|
117
|
+
return { content: [{ type: "text" as const, text: `${message}\n(Exit code ${exitCode} was declared expected.)` }],
|
|
118
|
+
details: { exitCode, expectedExit: true, ...(intent.operationId ? { operationId: intent.operationId } : {}),
|
|
119
|
+
...(intent.attemptId ? { attemptId: intent.attemptId } : {}) } as any };
|
|
120
|
+
}
|
|
121
|
+
throw failure;
|
|
122
|
+
}
|
|
123
|
+
},
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
export function failureDispositionTool(cwd: () => string) {
|
|
128
|
+
return {
|
|
129
|
+
name: DISPOSITION_TOOL,
|
|
130
|
+
label: "Failure disposition",
|
|
131
|
+
description: [
|
|
132
|
+
"Classify your own earlier tool failures so the parent is not told about problems you already handled.",
|
|
133
|
+
"recovered: the same operation later passed (evidence = that attempt). superseded: a different verification or remediation established the outcome (evidence = the successful attempt).",
|
|
134
|
+
"expected: the failure was intentional. open: it still needs the parent's action (this asks for attention).",
|
|
135
|
+
"targets: incident ids, the attemptId/operationId you declared on bash, or tool call ids. Unknown or already-disposed incidents are rejected.",
|
|
136
|
+
"Never claim recovery without a successful later attempt as evidence.",
|
|
137
|
+
"For open only, permissionResource optionally reports a permission blocker on the failed attempt; this is agent-reported, not a proven policy denial or remote authorization outcome.",
|
|
138
|
+
].join(" "),
|
|
139
|
+
promptSnippet: "Classify handled tool failures (recovered, superseded, expected) or flag one as open for the parent.",
|
|
140
|
+
parameters: {
|
|
141
|
+
type: "object",
|
|
142
|
+
properties: {
|
|
143
|
+
disposition: { type: "string", enum: ["recovered", "superseded", "expected", "open"] },
|
|
144
|
+
targets: { type: "array", items: { type: "string", minLength: 1, maxLength: 200 }, minItems: 1, maxItems: 20 },
|
|
145
|
+
reason: { type: "string", minLength: 1, maxLength: 400 },
|
|
146
|
+
evidence: { ...nullable({ type: "string", minLength: 1, maxLength: 200 }), description: "attemptId or tool call id of the successful later attempt; required for recovered and superseded." },
|
|
147
|
+
permissionResource: { ...nullable({ type: "string", enum: [...PERMISSION_RESOURCES] }), description: "Optional permission resource for open only. Bound to an unresolved failed worker attempt; remote outcome remains unknown." },
|
|
148
|
+
},
|
|
149
|
+
required: ["disposition", "targets", "reason"],
|
|
150
|
+
additionalProperties: false,
|
|
151
|
+
},
|
|
152
|
+
async execute(toolCallId: string, params: unknown, _signal: AbortSignal | undefined, _onUpdate: unknown, ctx: ExtensionContext) {
|
|
153
|
+
const parsed = readDispositionRequest(params);
|
|
154
|
+
if (!parsed.request) throw new Error(`Disposition rejected: ${parsed.error}.`);
|
|
155
|
+
const { model, state } = childIncidentView(ctx, cwd());
|
|
156
|
+
const outcome = resolveDisposition(model, state, parsed.request, toolCallId);
|
|
157
|
+
if (!outcome.event) {
|
|
158
|
+
const open = describeOpenTargets(model, state);
|
|
159
|
+
throw new Error(`Disposition rejected: ${outcome.error}.` + (open.length ? `\nOpen incidents:\n${open.join("\n")}` : "\nNo open incidents."));
|
|
160
|
+
}
|
|
161
|
+
const incidents = outcome.event.incidents ?? [];
|
|
162
|
+
return {
|
|
163
|
+
content: [{ type: "text" as const, text: `Recorded ${parsed.request.disposition} for ${incidents.length} incident${incidents.length === 1 ? "" : "s"}: ${incidents.join(", ")}.` }],
|
|
164
|
+
details: { disposition: parsed.request.disposition, incidents,
|
|
165
|
+
...(outcome.event.permissionBlockers ? { permissionBlockers: outcome.event.permissionBlockers } : {}) },
|
|
166
|
+
};
|
|
167
|
+
},
|
|
168
|
+
};
|
|
169
|
+
}
|