@nubl/maestro 0.0.1 → 0.1.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/README.md +55 -2
- package/dist/config.json.example +30 -0
- package/dist/maestro/adapters/fake/fake-harness-adapter.d.ts +24 -0
- package/dist/maestro/adapters/fake/fake-harness-adapter.d.ts.map +1 -0
- package/dist/maestro/adapters/fake/fake-harness-adapter.js +210 -0
- package/dist/maestro/adapters/fake/fake-harness-adapter.js.map +1 -0
- package/dist/maestro/adapters/pi/accept-groups.d.ts +35 -0
- package/dist/maestro/adapters/pi/accept-groups.d.ts.map +1 -0
- package/dist/maestro/adapters/pi/accept-groups.js +70 -0
- package/dist/maestro/adapters/pi/accept-groups.js.map +1 -0
- package/dist/maestro/adapters/pi/accept-runner.d.ts +37 -0
- package/dist/maestro/adapters/pi/accept-runner.d.ts.map +1 -0
- package/dist/maestro/adapters/pi/accept-runner.js +161 -0
- package/dist/maestro/adapters/pi/accept-runner.js.map +1 -0
- package/dist/maestro/adapters/pi/activity-file.d.ts +39 -0
- package/dist/maestro/adapters/pi/activity-file.d.ts.map +1 -0
- package/dist/maestro/adapters/pi/activity-file.js +454 -0
- package/dist/maestro/adapters/pi/activity-file.js.map +1 -0
- package/dist/maestro/adapters/pi/child/accept-check.d.ts +24 -0
- package/dist/maestro/adapters/pi/child/accept-check.d.ts.map +1 -0
- package/dist/maestro/adapters/pi/child/accept-check.js +82 -0
- package/dist/maestro/adapters/pi/child/accept-check.js.map +1 -0
- package/dist/maestro/adapters/pi/child/declared-skills.d.ts +51 -0
- package/dist/maestro/adapters/pi/child/declared-skills.d.ts.map +1 -0
- package/dist/maestro/adapters/pi/child/declared-skills.js +148 -0
- package/dist/maestro/adapters/pi/child/declared-skills.js.map +1 -0
- package/dist/maestro/adapters/pi/child/done-nudge.d.ts +38 -0
- package/dist/maestro/adapters/pi/child/done-nudge.d.ts.map +1 -0
- package/dist/maestro/adapters/pi/child/done-nudge.js +77 -0
- package/dist/maestro/adapters/pi/child/done-nudge.js.map +1 -0
- package/dist/maestro/adapters/pi/child/entry.d.ts +3 -0
- package/dist/maestro/adapters/pi/child/entry.d.ts.map +1 -0
- package/dist/maestro/adapters/pi/child/entry.js +3 -0
- package/dist/maestro/adapters/pi/child/entry.js.map +1 -0
- package/dist/maestro/adapters/pi/child/protocol.d.ts +56 -0
- package/dist/maestro/adapters/pi/child/protocol.d.ts.map +1 -0
- package/dist/maestro/adapters/pi/child/protocol.js +510 -0
- package/dist/maestro/adapters/pi/child/protocol.js.map +1 -0
- package/dist/maestro/adapters/pi/completion.d.ts +45 -0
- package/dist/maestro/adapters/pi/completion.d.ts.map +1 -0
- package/dist/maestro/adapters/pi/completion.js +295 -0
- package/dist/maestro/adapters/pi/completion.js.map +1 -0
- package/dist/maestro/adapters/pi/launch-command.d.ts +27 -0
- package/dist/maestro/adapters/pi/launch-command.d.ts.map +1 -0
- package/dist/maestro/adapters/pi/launch-command.js +75 -0
- package/dist/maestro/adapters/pi/launch-command.js.map +1 -0
- package/dist/maestro/adapters/pi/launch-operations.d.ts +78 -0
- package/dist/maestro/adapters/pi/launch-operations.d.ts.map +1 -0
- package/dist/maestro/adapters/pi/launch-operations.js +270 -0
- package/dist/maestro/adapters/pi/launch-operations.js.map +1 -0
- package/dist/maestro/adapters/pi/launch-resume.d.ts +4 -0
- package/dist/maestro/adapters/pi/launch-resume.d.ts.map +1 -0
- package/dist/maestro/adapters/pi/launch-resume.js +183 -0
- package/dist/maestro/adapters/pi/launch-resume.js.map +1 -0
- package/dist/maestro/adapters/pi/launch.d.ts +148 -0
- package/dist/maestro/adapters/pi/launch.d.ts.map +1 -0
- package/dist/maestro/adapters/pi/launch.js +655 -0
- package/dist/maestro/adapters/pi/launch.js.map +1 -0
- package/dist/maestro/adapters/pi/model-registry.d.ts +3 -0
- package/dist/maestro/adapters/pi/model-registry.d.ts.map +1 -0
- package/dist/maestro/adapters/pi/model-registry.js +29 -0
- package/dist/maestro/adapters/pi/model-registry.js.map +1 -0
- package/dist/maestro/adapters/pi/pi-harness-adapter.d.ts +95 -0
- package/dist/maestro/adapters/pi/pi-harness-adapter.d.ts.map +1 -0
- package/dist/maestro/adapters/pi/pi-harness-adapter.js +549 -0
- package/dist/maestro/adapters/pi/pi-harness-adapter.js.map +1 -0
- package/dist/maestro/adapters/pi/process-identity.d.ts +92 -0
- package/dist/maestro/adapters/pi/process-identity.d.ts.map +1 -0
- package/dist/maestro/adapters/pi/process-identity.js +248 -0
- package/dist/maestro/adapters/pi/process-identity.js.map +1 -0
- package/dist/maestro/adapters/pi/process-tree.d.ts +48 -0
- package/dist/maestro/adapters/pi/process-tree.d.ts.map +1 -0
- package/dist/maestro/adapters/pi/process-tree.js +69 -0
- package/dist/maestro/adapters/pi/process-tree.js.map +1 -0
- package/dist/maestro/adapters/pi/script-shell.d.ts +40 -0
- package/dist/maestro/adapters/pi/script-shell.d.ts.map +1 -0
- package/dist/maestro/adapters/pi/script-shell.js +43 -0
- package/dist/maestro/adapters/pi/script-shell.js.map +1 -0
- package/dist/maestro/adapters/pi/session.d.ts +207 -0
- package/dist/maestro/adapters/pi/session.d.ts.map +1 -0
- package/dist/maestro/adapters/pi/session.js +714 -0
- package/dist/maestro/adapters/pi/session.js.map +1 -0
- package/dist/maestro/adapters/pi/task-model-init.d.ts +4 -0
- package/dist/maestro/adapters/pi/task-model-init.d.ts.map +1 -0
- package/dist/maestro/adapters/pi/task-model-init.js +47 -0
- package/dist/maestro/adapters/pi/task-model-init.js.map +1 -0
- package/dist/maestro/core/accept.d.ts +150 -0
- package/dist/maestro/core/accept.d.ts.map +1 -0
- package/dist/maestro/core/accept.js +243 -0
- package/dist/maestro/core/accept.js.map +1 -0
- package/dist/maestro/core/activity.d.ts +4 -0
- package/dist/maestro/core/activity.d.ts.map +1 -0
- package/dist/maestro/core/activity.js +18 -0
- package/dist/maestro/core/activity.js.map +1 -0
- package/dist/maestro/core/child-busy.d.ts +14 -0
- package/dist/maestro/core/child-busy.d.ts.map +1 -0
- package/dist/maestro/core/child-busy.js +14 -0
- package/dist/maestro/core/child-busy.js.map +1 -0
- package/dist/maestro/core/config/guidelines-config.d.ts +8 -0
- package/dist/maestro/core/config/guidelines-config.d.ts.map +1 -0
- package/dist/maestro/core/config/guidelines-config.js +60 -0
- package/dist/maestro/core/config/guidelines-config.js.map +1 -0
- package/dist/maestro/core/config/herdr-config.d.ts +13 -0
- package/dist/maestro/core/config/herdr-config.d.ts.map +1 -0
- package/dist/maestro/core/config/herdr-config.js +65 -0
- package/dist/maestro/core/config/herdr-config.js.map +1 -0
- package/dist/maestro/core/config/model-config.d.ts +92 -0
- package/dist/maestro/core/config/model-config.d.ts.map +1 -0
- package/dist/maestro/core/config/model-config.js +522 -0
- package/dist/maestro/core/config/model-config.js.map +1 -0
- package/dist/maestro/core/config/outcome-ledger-config.d.ts +8 -0
- package/dist/maestro/core/config/outcome-ledger-config.d.ts.map +1 -0
- package/dist/maestro/core/config/outcome-ledger-config.js +49 -0
- package/dist/maestro/core/config/outcome-ledger-config.js.map +1 -0
- package/dist/maestro/core/config/pane-config.d.ts +15 -0
- package/dist/maestro/core/config/pane-config.d.ts.map +1 -0
- package/dist/maestro/core/config/pane-config.js +101 -0
- package/dist/maestro/core/config/pane-config.js.map +1 -0
- package/dist/maestro/core/config/persistent-config.d.ts +7 -0
- package/dist/maestro/core/config/persistent-config.d.ts.map +1 -0
- package/dist/maestro/core/config/persistent-config.js +72 -0
- package/dist/maestro/core/config/persistent-config.js.map +1 -0
- package/dist/maestro/core/config/role-config.d.ts +7 -0
- package/dist/maestro/core/config/role-config.d.ts.map +1 -0
- package/dist/maestro/core/config/role-config.js +74 -0
- package/dist/maestro/core/config/role-config.js.map +1 -0
- package/dist/maestro/core/config/spawning-config.d.ts +7 -0
- package/dist/maestro/core/config/spawning-config.d.ts.map +1 -0
- package/dist/maestro/core/config/spawning-config.js +65 -0
- package/dist/maestro/core/config/spawning-config.js.map +1 -0
- package/dist/maestro/core/config/supervision-config.d.ts +7 -0
- package/dist/maestro/core/config/supervision-config.d.ts.map +1 -0
- package/dist/maestro/core/config/supervision-config.js +69 -0
- package/dist/maestro/core/config/supervision-config.js.map +1 -0
- package/dist/maestro/core/config/task-model-init.d.ts +118 -0
- package/dist/maestro/core/config/task-model-init.d.ts.map +1 -0
- package/dist/maestro/core/config/task-model-init.js +168 -0
- package/dist/maestro/core/config/task-model-init.js.map +1 -0
- package/dist/maestro/core/config/task-model-types.d.ts +36 -0
- package/dist/maestro/core/config/task-model-types.d.ts.map +1 -0
- package/dist/maestro/core/config/task-model-types.js +17 -0
- package/dist/maestro/core/config/task-model-types.js.map +1 -0
- package/dist/maestro/core/config/type-guards.d.ts +22 -0
- package/dist/maestro/core/config/type-guards.d.ts.map +1 -0
- package/dist/maestro/core/config/type-guards.js +31 -0
- package/dist/maestro/core/config/type-guards.js.map +1 -0
- package/dist/maestro/core/deadline.d.ts +11 -0
- package/dist/maestro/core/deadline.d.ts.map +1 -0
- package/dist/maestro/core/deadline.js +30 -0
- package/dist/maestro/core/deadline.js.map +1 -0
- package/dist/maestro/core/declared-skills.d.ts +16 -0
- package/dist/maestro/core/declared-skills.d.ts.map +1 -0
- package/dist/maestro/core/declared-skills.js +52 -0
- package/dist/maestro/core/declared-skills.js.map +1 -0
- package/dist/maestro/core/delegation-depth.d.ts +38 -0
- package/dist/maestro/core/delegation-depth.d.ts.map +1 -0
- package/dist/maestro/core/delegation-depth.js +59 -0
- package/dist/maestro/core/delegation-depth.js.map +1 -0
- package/dist/maestro/core/git-environment.d.ts +3 -0
- package/dist/maestro/core/git-environment.d.ts.map +1 -0
- package/dist/maestro/core/git-environment.js +29 -0
- package/dist/maestro/core/git-environment.js.map +1 -0
- package/dist/maestro/core/harness-adapter.d.ts +89 -0
- package/dist/maestro/core/harness-adapter.d.ts.map +1 -0
- package/dist/maestro/core/harness-adapter.js +2 -0
- package/dist/maestro/core/harness-adapter.js.map +1 -0
- package/dist/maestro/core/host-text.d.ts +49 -0
- package/dist/maestro/core/host-text.d.ts.map +1 -0
- package/dist/maestro/core/host-text.js +106 -0
- package/dist/maestro/core/host-text.js.map +1 -0
- package/dist/maestro/core/index.d.ts +4 -0
- package/dist/maestro/core/index.d.ts.map +1 -0
- package/dist/maestro/core/index.js +2 -0
- package/dist/maestro/core/index.js.map +1 -0
- package/dist/maestro/core/lifecycle.d.ts +16 -0
- package/dist/maestro/core/lifecycle.d.ts.map +1 -0
- package/dist/maestro/core/lifecycle.js +429 -0
- package/dist/maestro/core/lifecycle.js.map +1 -0
- package/dist/maestro/core/opened-primary-workspace.d.ts +31 -0
- package/dist/maestro/core/opened-primary-workspace.d.ts.map +1 -0
- package/dist/maestro/core/opened-primary-workspace.js +49 -0
- package/dist/maestro/core/opened-primary-workspace.js.map +1 -0
- package/dist/maestro/core/platform-support.d.ts +15 -0
- package/dist/maestro/core/platform-support.d.ts.map +1 -0
- package/dist/maestro/core/platform-support.js +23 -0
- package/dist/maestro/core/platform-support.js.map +1 -0
- package/dist/maestro/core/realpath-without-opening.d.ts +9 -0
- package/dist/maestro/core/realpath-without-opening.d.ts.map +1 -0
- package/dist/maestro/core/realpath-without-opening.js +45 -0
- package/dist/maestro/core/realpath-without-opening.js.map +1 -0
- package/dist/maestro/core/roles/discovery.d.ts +64 -0
- package/dist/maestro/core/roles/discovery.d.ts.map +1 -0
- package/dist/maestro/core/roles/discovery.js +422 -0
- package/dist/maestro/core/roles/discovery.js.map +1 -0
- package/dist/maestro/core/routing.d.ts +115 -0
- package/dist/maestro/core/routing.d.ts.map +1 -0
- package/dist/maestro/core/routing.js +449 -0
- package/dist/maestro/core/routing.js.map +1 -0
- package/dist/maestro/core/script-launch.d.ts +47 -0
- package/dist/maestro/core/script-launch.d.ts.map +1 -0
- package/dist/maestro/core/script-launch.js +102 -0
- package/dist/maestro/core/script-launch.js.map +1 -0
- package/dist/maestro/core/shell.d.ts +2 -0
- package/dist/maestro/core/shell.d.ts.map +1 -0
- package/dist/maestro/core/shell.js +4 -0
- package/dist/maestro/core/shell.js.map +1 -0
- package/dist/maestro/core/specialist-notice.d.ts +36 -0
- package/dist/maestro/core/specialist-notice.d.ts.map +1 -0
- package/dist/maestro/core/specialist-notice.js +41 -0
- package/dist/maestro/core/specialist-notice.js.map +1 -0
- package/dist/maestro/core/status.d.ts +87 -0
- package/dist/maestro/core/status.d.ts.map +1 -0
- package/dist/maestro/core/status.js +369 -0
- package/dist/maestro/core/status.js.map +1 -0
- package/dist/maestro/core/supervision.d.ts +56 -0
- package/dist/maestro/core/supervision.d.ts.map +1 -0
- package/dist/maestro/core/supervision.js +249 -0
- package/dist/maestro/core/supervision.js.map +1 -0
- package/dist/maestro/core/surface-provider.d.ts +200 -0
- package/dist/maestro/core/surface-provider.d.ts.map +1 -0
- package/dist/maestro/core/surface-provider.js +71 -0
- package/dist/maestro/core/surface-provider.js.map +1 -0
- package/dist/maestro/core/types.d.ts +388 -0
- package/dist/maestro/core/types.d.ts.map +1 -0
- package/dist/maestro/core/types.js +2 -0
- package/dist/maestro/core/types.js.map +1 -0
- package/dist/maestro/core/undelivered-children.d.ts +27 -0
- package/dist/maestro/core/undelivered-children.d.ts.map +1 -0
- package/dist/maestro/core/undelivered-children.js +31 -0
- package/dist/maestro/core/undelivered-children.js.map +1 -0
- package/dist/maestro/core/wake.d.ts +32 -0
- package/dist/maestro/core/wake.d.ts.map +1 -0
- package/dist/maestro/core/wake.js +125 -0
- package/dist/maestro/core/wake.js.map +1 -0
- package/dist/maestro/core/worktree-cleanup.d.ts +75 -0
- package/dist/maestro/core/worktree-cleanup.d.ts.map +1 -0
- package/dist/maestro/core/worktree-cleanup.js +278 -0
- package/dist/maestro/core/worktree-cleanup.js.map +1 -0
- package/dist/maestro/core/worktree.d.ts +50 -0
- package/dist/maestro/core/worktree.d.ts.map +1 -0
- package/dist/maestro/core/worktree.js +23 -0
- package/dist/maestro/core/worktree.js.map +1 -0
- package/dist/maestro/engine.d.ts +5 -0
- package/dist/maestro/engine.d.ts.map +1 -0
- package/dist/maestro/engine.js +5 -0
- package/dist/maestro/engine.js.map +1 -0
- package/dist/maestro/pi/child.d.ts +8 -0
- package/dist/maestro/pi/child.d.ts.map +1 -0
- package/dist/maestro/pi/child.js +8 -0
- package/dist/maestro/pi/child.js.map +1 -0
- package/dist/maestro/pi/extension.d.ts +10 -0
- package/dist/maestro/pi/extension.d.ts.map +1 -0
- package/dist/maestro/pi/extension.js +8 -0
- package/dist/maestro/pi/extension.js.map +1 -0
- package/dist/maestro/pi/subagents-index.d.ts +9 -0
- package/dist/maestro/pi/subagents-index.d.ts.map +1 -0
- package/dist/maestro/pi/subagents-index.js +9 -0
- package/dist/maestro/pi/subagents-index.js.map +1 -0
- package/dist/maestro/pi.d.ts +9 -0
- package/dist/maestro/pi.d.ts.map +1 -0
- package/dist/maestro/pi.js +7 -0
- package/dist/maestro/pi.js.map +1 -0
- package/dist/maestro/runtime/accept-recheck.d.ts +32 -0
- package/dist/maestro/runtime/accept-recheck.d.ts.map +1 -0
- package/dist/maestro/runtime/accept-recheck.js +92 -0
- package/dist/maestro/runtime/accept-recheck.js.map +1 -0
- package/dist/maestro/runtime/delegated-marker.d.ts +112 -0
- package/dist/maestro/runtime/delegated-marker.d.ts.map +1 -0
- package/dist/maestro/runtime/delegated-marker.js +200 -0
- package/dist/maestro/runtime/delegated-marker.js.map +1 -0
- package/dist/maestro/runtime/host-surface-binding.d.ts +25 -0
- package/dist/maestro/runtime/host-surface-binding.d.ts.map +1 -0
- package/dist/maestro/runtime/host-surface-binding.js +2 -0
- package/dist/maestro/runtime/host-surface-binding.js.map +1 -0
- package/dist/maestro/runtime/index.d.ts +10 -0
- package/dist/maestro/runtime/index.d.ts.map +1 -0
- package/dist/maestro/runtime/index.js +6 -0
- package/dist/maestro/runtime/index.js.map +1 -0
- package/dist/maestro/runtime/pi-persistent-io.d.ts +7 -0
- package/dist/maestro/runtime/pi-persistent-io.d.ts.map +1 -0
- package/dist/maestro/runtime/pi-persistent-io.js +64 -0
- package/dist/maestro/runtime/pi-persistent-io.js.map +1 -0
- package/dist/maestro/runtime/pi-run-session-types.d.ts +328 -0
- package/dist/maestro/runtime/pi-run-session-types.d.ts.map +1 -0
- package/dist/maestro/runtime/pi-run-session-types.js +2 -0
- package/dist/maestro/runtime/pi-run-session-types.js.map +1 -0
- package/dist/maestro/runtime/pi-run-session.d.ts +12 -0
- package/dist/maestro/runtime/pi-run-session.d.ts.map +1 -0
- package/dist/maestro/runtime/pi-run-session.js +809 -0
- package/dist/maestro/runtime/pi-run-session.js.map +1 -0
- package/dist/maestro/runtime/run-session.d.ts +129 -0
- package/dist/maestro/runtime/run-session.d.ts.map +1 -0
- package/dist/maestro/runtime/run-session.js +680 -0
- package/dist/maestro/runtime/run-session.js.map +1 -0
- package/dist/maestro/runtime/surface-retention.d.ts +3 -0
- package/dist/maestro/runtime/surface-retention.d.ts.map +1 -0
- package/dist/maestro/runtime/surface-retention.js +5 -0
- package/dist/maestro/runtime/surface-retention.js.map +1 -0
- package/dist/maestro/runtime/task-model-init.d.ts +34 -0
- package/dist/maestro/runtime/task-model-init.d.ts.map +1 -0
- package/dist/maestro/runtime/task-model-init.js +78 -0
- package/dist/maestro/runtime/task-model-init.js.map +1 -0
- package/dist/maestro/runtime/worktree-operations.d.ts +31 -0
- package/dist/maestro/runtime/worktree-operations.d.ts.map +1 -0
- package/dist/maestro/runtime/worktree-operations.js +633 -0
- package/dist/maestro/runtime/worktree-operations.js.map +1 -0
- package/dist/maestro/surfaces/fake/fake-surface-provider.d.ts +54 -0
- package/dist/maestro/surfaces/fake/fake-surface-provider.d.ts.map +1 -0
- package/dist/maestro/surfaces/fake/fake-surface-provider.js +231 -0
- package/dist/maestro/surfaces/fake/fake-surface-provider.js.map +1 -0
- package/dist/maestro/testing/harness-adapter.conformance.d.ts +31 -0
- package/dist/maestro/testing/harness-adapter.conformance.d.ts.map +1 -0
- package/dist/maestro/testing/harness-adapter.conformance.js +181 -0
- package/dist/maestro/testing/harness-adapter.conformance.js.map +1 -0
- package/dist/maestro/testing/index.d.ts +5 -0
- package/dist/maestro/testing/index.d.ts.map +1 -0
- package/dist/maestro/testing/index.js +5 -0
- package/dist/maestro/testing/index.js.map +1 -0
- package/dist/maestro/testing/surface-provider.conformance.d.ts +20 -0
- package/dist/maestro/testing/surface-provider.conformance.d.ts.map +1 -0
- package/dist/maestro/testing/surface-provider.conformance.js +167 -0
- package/dist/maestro/testing/surface-provider.conformance.js.map +1 -0
- package/dist/pi-extension/subagents/catalog.d.ts +70 -0
- package/dist/pi-extension/subagents/catalog.d.ts.map +1 -0
- package/dist/pi-extension/subagents/catalog.js +231 -0
- package/dist/pi-extension/subagents/catalog.js.map +1 -0
- package/dist/pi-extension/subagents/config-path.d.ts +6 -0
- package/dist/pi-extension/subagents/config-path.d.ts.map +1 -0
- package/dist/pi-extension/subagents/config-path.js +21 -0
- package/dist/pi-extension/subagents/config-path.js.map +1 -0
- package/dist/pi-extension/subagents/control-tools.d.ts +21 -0
- package/dist/pi-extension/subagents/control-tools.d.ts.map +1 -0
- package/dist/pi-extension/subagents/control-tools.js +150 -0
- package/dist/pi-extension/subagents/control-tools.js.map +1 -0
- package/dist/pi-extension/subagents/controls.d.ts +52 -0
- package/dist/pi-extension/subagents/controls.d.ts.map +1 -0
- package/dist/pi-extension/subagents/controls.js +173 -0
- package/dist/pi-extension/subagents/controls.js.map +1 -0
- package/dist/pi-extension/subagents/deferred-tools.d.ts +43 -0
- package/dist/pi-extension/subagents/deferred-tools.d.ts.map +1 -0
- package/dist/pi-extension/subagents/deferred-tools.js +67 -0
- package/dist/pi-extension/subagents/deferred-tools.js.map +1 -0
- package/dist/pi-extension/subagents/delivery.d.ts +22 -0
- package/dist/pi-extension/subagents/delivery.d.ts.map +1 -0
- package/dist/pi-extension/subagents/delivery.js +365 -0
- package/dist/pi-extension/subagents/delivery.js.map +1 -0
- package/dist/pi-extension/subagents/extension.d.ts +100 -0
- package/dist/pi-extension/subagents/extension.d.ts.map +1 -0
- package/dist/pi-extension/subagents/extension.js +367 -0
- package/dist/pi-extension/subagents/extension.js.map +1 -0
- package/dist/pi-extension/subagents/launch-tools.d.ts +33 -0
- package/dist/pi-extension/subagents/launch-tools.d.ts.map +1 -0
- package/dist/pi-extension/subagents/launch-tools.js +373 -0
- package/dist/pi-extension/subagents/launch-tools.js.map +1 -0
- package/dist/pi-extension/subagents/launch.d.ts +86 -0
- package/dist/pi-extension/subagents/launch.d.ts.map +1 -0
- package/dist/pi-extension/subagents/launch.js +133 -0
- package/dist/pi-extension/subagents/launch.js.map +1 -0
- package/dist/pi-extension/subagents/model-registry.d.ts +13 -0
- package/dist/pi-extension/subagents/model-registry.d.ts.map +1 -0
- package/dist/pi-extension/subagents/model-registry.js +52 -0
- package/dist/pi-extension/subagents/model-registry.js.map +1 -0
- package/dist/pi-extension/subagents/observation.d.ts +38 -0
- package/dist/pi-extension/subagents/observation.d.ts.map +1 -0
- package/dist/pi-extension/subagents/observation.js +168 -0
- package/dist/pi-extension/subagents/observation.js.map +1 -0
- package/dist/pi-extension/subagents/persistent.d.ts +72 -0
- package/dist/pi-extension/subagents/persistent.d.ts.map +1 -0
- package/dist/pi-extension/subagents/persistent.js +322 -0
- package/dist/pi-extension/subagents/persistent.js.map +1 -0
- package/dist/pi-extension/subagents/presentation-hooks.d.ts +25 -0
- package/dist/pi-extension/subagents/presentation-hooks.d.ts.map +1 -0
- package/dist/pi-extension/subagents/presentation-hooks.js +2 -0
- package/dist/pi-extension/subagents/presentation-hooks.js.map +1 -0
- package/dist/pi-extension/subagents/presentation.d.ts +149 -0
- package/dist/pi-extension/subagents/presentation.d.ts.map +1 -0
- package/dist/pi-extension/subagents/presentation.js +419 -0
- package/dist/pi-extension/subagents/presentation.js.map +1 -0
- package/dist/pi-extension/subagents/state.d.ts +183 -0
- package/dist/pi-extension/subagents/state.d.ts.map +1 -0
- package/dist/pi-extension/subagents/state.js +92 -0
- package/dist/pi-extension/subagents/state.js.map +1 -0
- package/dist/pi-extension/subagents/task-models.d.ts +9 -0
- package/dist/pi-extension/subagents/task-models.d.ts.map +1 -0
- package/dist/pi-extension/subagents/task-models.js +293 -0
- package/dist/pi-extension/subagents/task-models.js.map +1 -0
- package/dist/pi-extension/subagents/tool-boundary.d.ts +16 -0
- package/dist/pi-extension/subagents/tool-boundary.d.ts.map +1 -0
- package/dist/pi-extension/subagents/tool-boundary.js +53 -0
- package/dist/pi-extension/subagents/tool-boundary.js.map +1 -0
- package/dist/pi-extension/subagents/worktree-tools.d.ts +16 -0
- package/dist/pi-extension/subagents/worktree-tools.d.ts.map +1 -0
- package/dist/pi-extension/subagents/worktree-tools.js +185 -0
- package/dist/pi-extension/subagents/worktree-tools.js.map +1 -0
- package/dist/provenance.json +5 -0
- package/package.json +540 -27
- package/index.d.ts +0 -1
- package/index.js +0 -2
|
@@ -0,0 +1,295 @@
|
|
|
1
|
+
import { existsSync, readFileSync, rmSync } from "node:fs";
|
|
2
|
+
import { Deadline } from "../../core/deadline.js";
|
|
3
|
+
import { isNonEmptyString, isString } from "../../core/config/type-guards.js";
|
|
4
|
+
import { parseChildAcceptReport, } from "../../core/accept.js";
|
|
5
|
+
const ABORT_MESSAGE = "Aborted while waiting for subagent to finish";
|
|
6
|
+
const TERMINAL_SENTINEL = /__SUBAGENT_DONE_(\d+)__/;
|
|
7
|
+
/**
|
|
8
|
+
* Where a persistent child's launch line records Pi's exit code once Pi has
|
|
9
|
+
* exited. Unlike the on-screen marker, a shell prompt cannot scroll it away.
|
|
10
|
+
*/
|
|
11
|
+
export function shellExitFileFor(sessionFile) {
|
|
12
|
+
return `${sessionFile}.shell-exit`;
|
|
13
|
+
}
|
|
14
|
+
function readShellExitCode(file) {
|
|
15
|
+
try {
|
|
16
|
+
const text = readFileSync(file, "utf8").trim();
|
|
17
|
+
return /^\d+$/.test(text) ? Number.parseInt(text, 10) : null;
|
|
18
|
+
}
|
|
19
|
+
catch {
|
|
20
|
+
return null;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
export function interpretExitSidecar(payload) {
|
|
24
|
+
if (payload?.type === "ping") {
|
|
25
|
+
return {
|
|
26
|
+
reason: "ping",
|
|
27
|
+
exitCode: 0,
|
|
28
|
+
ping: {
|
|
29
|
+
name: isString(payload.name) ? payload.name : "subagent",
|
|
30
|
+
message: isString(payload.message) ? payload.message : "",
|
|
31
|
+
},
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
if (payload?.type === "error") {
|
|
35
|
+
return isNonEmptyString(payload.errorMessage)
|
|
36
|
+
? {
|
|
37
|
+
reason: "error",
|
|
38
|
+
exitCode: 1,
|
|
39
|
+
errorMessage: payload.errorMessage,
|
|
40
|
+
errorSource: "child",
|
|
41
|
+
}
|
|
42
|
+
: {
|
|
43
|
+
reason: "error",
|
|
44
|
+
exitCode: 1,
|
|
45
|
+
errorMessage: "Subagent exited with stopReason=error (no errorMessage in sidecar).",
|
|
46
|
+
errorSource: "host",
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
if (payload?.type === "done") {
|
|
50
|
+
const accept = parseChildAcceptReport(payload.accept);
|
|
51
|
+
return accept
|
|
52
|
+
? { reason: "done", exitCode: 0, accept }
|
|
53
|
+
: { reason: "done", exitCode: 0 };
|
|
54
|
+
}
|
|
55
|
+
return {
|
|
56
|
+
reason: "error",
|
|
57
|
+
exitCode: 1,
|
|
58
|
+
errorMessage: "Invalid subagent completion sidecar: unsupported payload type.",
|
|
59
|
+
errorSource: "host",
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
function readExitSidecar(sessionFile, consume = true) {
|
|
63
|
+
if (!sessionFile)
|
|
64
|
+
return null;
|
|
65
|
+
const exitFile = `${sessionFile}.exit`;
|
|
66
|
+
if (!existsSync(exitFile))
|
|
67
|
+
return null;
|
|
68
|
+
try {
|
|
69
|
+
const result = interpretExitSidecar(JSON.parse(readFileSync(exitFile, "utf8")));
|
|
70
|
+
if (consume)
|
|
71
|
+
rmSync(exitFile, { force: true });
|
|
72
|
+
return result;
|
|
73
|
+
}
|
|
74
|
+
catch {
|
|
75
|
+
// The child may still be writing the file. Retry on the next polling cycle.
|
|
76
|
+
return null;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
function terminalExitCode(screen) {
|
|
80
|
+
const match = screen.match(TERMINAL_SENTINEL);
|
|
81
|
+
return match ? Number.parseInt(match[1], 10) : null;
|
|
82
|
+
}
|
|
83
|
+
function completionArtifact(options) {
|
|
84
|
+
return readExitSidecar(options.sessionFile, !options.requireProcessExit && !options.inspectExecution);
|
|
85
|
+
}
|
|
86
|
+
async function waitForDelayedSidecar(signal, options) {
|
|
87
|
+
const immediate = completionArtifact(options);
|
|
88
|
+
if (immediate)
|
|
89
|
+
return immediate;
|
|
90
|
+
const graceMs = Math.max(0, options.paneDisappearanceGraceMs ?? 500);
|
|
91
|
+
if (graceMs === 0)
|
|
92
|
+
return null;
|
|
93
|
+
const deadline = Deadline.after(graceMs);
|
|
94
|
+
while (!deadline.expired()) {
|
|
95
|
+
const remaining = deadline.remainingMs();
|
|
96
|
+
await abortableDelay(Math.min(25, remaining), signal);
|
|
97
|
+
const result = completionArtifact(options);
|
|
98
|
+
if (result)
|
|
99
|
+
return result;
|
|
100
|
+
}
|
|
101
|
+
return null;
|
|
102
|
+
}
|
|
103
|
+
function abortableDelay(milliseconds, signal) {
|
|
104
|
+
if (signal.aborted)
|
|
105
|
+
return Promise.reject(new Error(ABORT_MESSAGE));
|
|
106
|
+
return new Promise((resolve, reject) => {
|
|
107
|
+
const onAbort = () => {
|
|
108
|
+
clearTimeout(timer);
|
|
109
|
+
reject(new Error(ABORT_MESSAGE));
|
|
110
|
+
};
|
|
111
|
+
const timer = setTimeout(() => {
|
|
112
|
+
signal.removeEventListener("abort", onAbort);
|
|
113
|
+
resolve();
|
|
114
|
+
}, milliseconds);
|
|
115
|
+
signal.addEventListener("abort", onAbort, { once: true });
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
export async function waitForCompletion(signal, options) {
|
|
119
|
+
const result = await detectCompletion(signal, options);
|
|
120
|
+
if ((options.requireProcessExit || options.inspectExecution) &&
|
|
121
|
+
options.sessionFile) {
|
|
122
|
+
try {
|
|
123
|
+
rmSync(`${options.sessionFile}.exit`, { force: true });
|
|
124
|
+
}
|
|
125
|
+
catch {
|
|
126
|
+
// Exit is already verified; a failed artifact cleanup cannot undo it.
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
if (options.shellExitFile)
|
|
130
|
+
try {
|
|
131
|
+
rmSync(options.shellExitFile, { force: true });
|
|
132
|
+
}
|
|
133
|
+
catch {
|
|
134
|
+
// Same: the record has served its purpose.
|
|
135
|
+
}
|
|
136
|
+
return result;
|
|
137
|
+
}
|
|
138
|
+
async function detectCompletion(signal, options) {
|
|
139
|
+
const startedAt = Date.now();
|
|
140
|
+
// Coordinated supervision waits for its first shared epoch; legacy callers
|
|
141
|
+
// retain the immediate terminal probe.
|
|
142
|
+
let reconcile = !options.waitForNextCheck;
|
|
143
|
+
for (;;) {
|
|
144
|
+
if (signal.aborted)
|
|
145
|
+
throw new Error(ABORT_MESSAGE);
|
|
146
|
+
// The child writes .exit before ctx.shutdown(). Keep semantic evidence
|
|
147
|
+
// on disk until independent exit evidence permits releasing a persistent
|
|
148
|
+
// owner, including when all waiters abort and a later wait starts afresh.
|
|
149
|
+
const sidecarResult = readExitSidecar(options.sessionFile, !options.requireProcessExit && !options.inspectExecution);
|
|
150
|
+
if (sidecarResult &&
|
|
151
|
+
!options.requireProcessExit &&
|
|
152
|
+
!options.inspectExecution)
|
|
153
|
+
return sidecarResult;
|
|
154
|
+
options.onLocalEvidence?.();
|
|
155
|
+
if (options.inspectExecution) {
|
|
156
|
+
let execution;
|
|
157
|
+
try {
|
|
158
|
+
execution = await options.inspectExecution();
|
|
159
|
+
}
|
|
160
|
+
catch {
|
|
161
|
+
execution = { kind: "unavailable" };
|
|
162
|
+
}
|
|
163
|
+
if (execution.kind === "finished" || execution.kind === "missing") {
|
|
164
|
+
const completion = await waitForDelayedSidecar(signal, options);
|
|
165
|
+
if (completion)
|
|
166
|
+
return completion;
|
|
167
|
+
if (execution.kind === "finished") {
|
|
168
|
+
try {
|
|
169
|
+
const exitCode = terminalExitCode(await options.readTerminalTail());
|
|
170
|
+
options.onLocalEvidence?.();
|
|
171
|
+
const racedCompletion = completionArtifact(options);
|
|
172
|
+
if (racedCompletion)
|
|
173
|
+
return racedCompletion;
|
|
174
|
+
// Manual interactive exit may have no sidecar. The script's
|
|
175
|
+
// marker is admissible only after independent native exit,
|
|
176
|
+
// and must not contradict a known native exit code.
|
|
177
|
+
if (exitCode !== null &&
|
|
178
|
+
(execution.exitCode === undefined ||
|
|
179
|
+
execution.exitCode === exitCode))
|
|
180
|
+
return { reason: "sentinel", exitCode };
|
|
181
|
+
}
|
|
182
|
+
catch {
|
|
183
|
+
/* Native exit remains proven; missing output is not success. */
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
return {
|
|
187
|
+
reason: "error",
|
|
188
|
+
exitCode: execution.kind === "finished" ? (execution.exitCode ?? 1) : 1,
|
|
189
|
+
errorMessage: "Subagent native execution ended before completion evidence was recorded.",
|
|
190
|
+
errorSource: "host",
|
|
191
|
+
};
|
|
192
|
+
}
|
|
193
|
+
const observedAt = Date.now();
|
|
194
|
+
options.onPaneInspection?.(execution.kind === "unavailable"
|
|
195
|
+
? execution
|
|
196
|
+
: { kind: "present", agentStatus: "unknown", observedAt }, observedAt);
|
|
197
|
+
// Neither live nor unavailable can be overridden by stale terminal
|
|
198
|
+
// sentinels, agent status=done, sidecars, or shared-list absence.
|
|
199
|
+
options.onTick?.(Math.floor((Date.now() - startedAt) / 1000));
|
|
200
|
+
if (options.waitForNextCheck)
|
|
201
|
+
reconcile = (await options.waitForNextCheck(signal)) === "reconcile";
|
|
202
|
+
else
|
|
203
|
+
await abortableDelay(options.intervalMs, signal);
|
|
204
|
+
continue;
|
|
205
|
+
}
|
|
206
|
+
if (options.requireProcessExit && options.inspectProcess?.() === "exited") {
|
|
207
|
+
const completion = await waitForDelayedSidecar(signal, options);
|
|
208
|
+
return (completion ?? {
|
|
209
|
+
reason: "error",
|
|
210
|
+
exitCode: 1,
|
|
211
|
+
errorMessage: "Subagent process exited before completion evidence was recorded.",
|
|
212
|
+
errorSource: "host",
|
|
213
|
+
});
|
|
214
|
+
}
|
|
215
|
+
// The shell writes this only after Pi exits, so it proves exit wherever the
|
|
216
|
+
// on-screen marker has scrolled (#143). A known-live identity outranks it.
|
|
217
|
+
if (options.requireProcessExit &&
|
|
218
|
+
options.shellExitFile &&
|
|
219
|
+
options.inspectProcess?.() !== "alive") {
|
|
220
|
+
const exitCode = readShellExitCode(options.shellExitFile);
|
|
221
|
+
if (exitCode !== null) {
|
|
222
|
+
options.onLocalEvidence?.();
|
|
223
|
+
const completion = await waitForDelayedSidecar(signal, options);
|
|
224
|
+
return completion ?? { reason: "sentinel", exitCode };
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
if (reconcile)
|
|
228
|
+
try {
|
|
229
|
+
const exitCode = terminalExitCode(await options.readTerminalTail());
|
|
230
|
+
if (exitCode !== null &&
|
|
231
|
+
(!options.requireProcessExit ||
|
|
232
|
+
options.inspectProcess?.() !== "alive")) {
|
|
233
|
+
// The shell sentinel can become readable while the child publishes its
|
|
234
|
+
// authoritative semantic record. Always recheck after the asynchronous
|
|
235
|
+
// terminal read; a zero exit can race a ping or error just like a failure.
|
|
236
|
+
options.onLocalEvidence?.();
|
|
237
|
+
const racedCompletion = completionArtifact(options);
|
|
238
|
+
if (racedCompletion)
|
|
239
|
+
return racedCompletion;
|
|
240
|
+
if (exitCode !== 0) {
|
|
241
|
+
const delayedCompletion = await waitForDelayedSidecar(signal, options);
|
|
242
|
+
if (options.requireProcessExit &&
|
|
243
|
+
options.inspectProcess?.() === "alive")
|
|
244
|
+
continue;
|
|
245
|
+
if (delayedCompletion)
|
|
246
|
+
return delayedCompletion;
|
|
247
|
+
}
|
|
248
|
+
return { reason: "sentinel", exitCode };
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
catch {
|
|
252
|
+
// Terminal reads are only sentinel/output probes; Herdr status is polled
|
|
253
|
+
// independently below, even when terminal reads succeed.
|
|
254
|
+
}
|
|
255
|
+
if (reconcile && options.inspectPane) {
|
|
256
|
+
let inspection;
|
|
257
|
+
try {
|
|
258
|
+
inspection = await options.inspectPane();
|
|
259
|
+
}
|
|
260
|
+
catch {
|
|
261
|
+
inspection = { kind: "unavailable", error: "inspectPane threw" };
|
|
262
|
+
}
|
|
263
|
+
const observedAt = Date.now();
|
|
264
|
+
options.onPaneInspection?.(inspection, observedAt);
|
|
265
|
+
if (inspection.kind === "missing" &&
|
|
266
|
+
(!options.requireProcessExit || options.inspectProcess?.() !== "alive")) {
|
|
267
|
+
// Drain concurrent persistent events before accepting pane fallback.
|
|
268
|
+
options.onLocalEvidence?.();
|
|
269
|
+
// Pane closure and atomic artifact publication are separate operations.
|
|
270
|
+
// Allow a short bounded grace window before declaring evidence lost.
|
|
271
|
+
const racedCompletion = await waitForDelayedSidecar(signal, options);
|
|
272
|
+
if (options.requireProcessExit &&
|
|
273
|
+
options.inspectProcess?.() === "alive")
|
|
274
|
+
continue;
|
|
275
|
+
if (racedCompletion)
|
|
276
|
+
return racedCompletion;
|
|
277
|
+
return {
|
|
278
|
+
reason: "error",
|
|
279
|
+
exitCode: 1,
|
|
280
|
+
errorMessage: "Subagent pane disappeared before completion evidence was recorded.",
|
|
281
|
+
errorSource: "host",
|
|
282
|
+
};
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
options.onTick?.(Math.floor((Date.now() - startedAt) / 1000));
|
|
286
|
+
if (options.waitForNextCheck) {
|
|
287
|
+
reconcile = (await options.waitForNextCheck(signal)) === "reconcile";
|
|
288
|
+
}
|
|
289
|
+
else {
|
|
290
|
+
await abortableDelay(options.intervalMs, signal);
|
|
291
|
+
reconcile = true;
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
//# sourceMappingURL=completion.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YACnD,IACC,UAAU,CAAC,IAAI,KAAK,SAAS;gBAC7B,CAAC,CAAC,OAAO,CAAC,kBAAkB,IAAI,OAAO,CAAC,cAAc,EAAE,EAAE,KAAK,OAAO,CAAC,EACtE,CAAC;gBACF,qEAAqE;gBACrE,OAAO,CAAC,eAAe,EAAE,EAAE,CAAC;gBAC5B,wEAAwE;gBACxE,qEAAqE;gBACrE,MAAM,eAAe,GAAG,MAAM,qBAAqB,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;gBACrE,IACC,OAAO,CAAC,kBAAkB;oBAC1B,OAAO,CAAC,cAAc,EAAE,EAAE,KAAK,OAAO;oBAEtC,SAAS;gBACV,IAAI,eAAe;oBAAE,OAAO,eAAe,CAAC;gBAC5C,OAAO;oBACN,MAAM,EAAE,OAAO;oBACf,QAAQ,EAAE,CAAC;oBACX,YAAY,EACX,oEAAoE;oBACrE,WAAW,EAAE,MAAM;iBACnB,CAAC;YACH,CAAC;QACF,CAAC;QAED,OAAO,CAAC,MAAM,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,SAAS,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC;QAC9D,IAAI,OAAO,CAAC,gBAAgB,EAAE,CAAC;YAC9B,SAAS,GAAG,CAAC,MAAM,OAAO,CAAC,gBAAgB,CAAC,MAAM,CAAC,CAAC,KAAK,WAAW,CAAC;QACtE,CAAC;aAAM,CAAC;YACP,MAAM,cAAc,CAAC,OAAO,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC;YACjD,SAAS,GAAG,IAAI,CAAC;QAClB,CAAC;IACF,CAAC;AACF,CAAC","sourcesContent":["import { existsSync, readFileSync, rmSync } from \"node:fs\";\nimport type { NativeExecutionInspection } from \"../../core/surface-provider.ts\";\nimport { Deadline } from \"../../core/deadline.ts\";\n\nimport { isNonEmptyString, isString } from \"../../core/config/type-guards.ts\";\nimport {\n\tparseChildAcceptReport,\n\ttype ChildAcceptReport,\n} from \"../../core/accept.ts\";\n\nconst ABORT_MESSAGE = \"Aborted while waiting for subagent to finish\";\nconst TERMINAL_SENTINEL = /__SUBAGENT_DONE_(\\d+)__/;\n\n/**\n * Where a persistent child's launch line records Pi's exit code once Pi has\n * exited. Unlike the on-screen marker, a shell prompt cannot scroll it away.\n */\nexport function shellExitFileFor(sessionFile: string): string {\n\treturn `${sessionFile}.shell-exit`;\n}\n\nfunction readShellExitCode(file: string): number | null {\n\ttry {\n\t\tconst text = readFileSync(file, \"utf8\").trim();\n\t\treturn /^\\d+$/.test(text) ? Number.parseInt(text, 10) : null;\n\t} catch {\n\t\treturn null;\n\t}\n}\n\nexport interface CompletionResult {\n\treason: \"done\" | \"ping\" | \"sentinel\" | \"error\";\n\texitCode: number;\n\tping?: { name: string; message: string };\n\terrorMessage?: string;\n\t/** Who wrote errorMessage: the child's sidecar, or the host's own diagnostic. */\n\terrorSource?: \"child\" | \"host\";\n\t/** The child's own accept-check report; evidence, never the verdict. */\n\taccept?: ChildAcceptReport;\n}\n\nexport interface CompletionOptions {\n\t/** Native lifetime evidence is independent of OSC agent/task status. */\n\tinspectExecution?: () => Promise<NativeExecutionInspection>;\n\tintervalMs: number;\n\treadTerminalTail: () => Promise<string>;\n\tinspectPane?: () => Promise<import(\"../../core/types.ts\").PaneInspection>;\n\t/** Bounded artifact grace after explicit pane disappearance. Default: 500ms. */\n\tpaneDisappearanceGraceMs?: number;\n\tonPaneInspection?: (\n\t\tinspection: import(\"../../core/types.ts\").PaneInspection,\n\t\tobservedAt: number,\n\t) => void;\n\tsessionFile?: string;\n\t/** Persistent lifetime ownership cannot end on a pre-shutdown sidecar. */\n\trequireProcessExit?: boolean;\n\t/** Only launch-verified process identity, never transcript or activity state. */\n\tinspectProcess?: () => \"alive\" | \"exited\" | \"unknown\";\n\t/** The launch line's post-exit record ({@link shellExitFileFor}); admitted unless the identity is alive. */\n\tshellExitFile?: string;\n\tonTick?: (elapsedSeconds: number) => void;\n\t/** Wait for a local file wake-up or a scheduled reconciliation. */\n\twaitForNextCheck?: (signal: AbortSignal) => Promise<\"wake\" | \"reconcile\">;\n\t/** Drain local task evidence before any terminal fallback. */\n\tonLocalEvidence?: () => void;\n}\n\nexport function interpretExitSidecar(payload: any): CompletionResult {\n\tif (payload?.type === \"ping\") {\n\t\treturn {\n\t\t\treason: \"ping\",\n\t\t\texitCode: 0,\n\t\t\tping: {\n\t\t\t\tname: isString(payload.name) ? payload.name : \"subagent\",\n\t\t\t\tmessage: isString(payload.message) ? payload.message : \"\",\n\t\t\t},\n\t\t};\n\t}\n\n\tif (payload?.type === \"error\") {\n\t\treturn isNonEmptyString(payload.errorMessage)\n\t\t\t? {\n\t\t\t\t\treason: \"error\",\n\t\t\t\t\texitCode: 1,\n\t\t\t\t\terrorMessage: payload.errorMessage,\n\t\t\t\t\terrorSource: \"child\",\n\t\t\t\t}\n\t\t\t: {\n\t\t\t\t\treason: \"error\",\n\t\t\t\t\texitCode: 1,\n\t\t\t\t\terrorMessage:\n\t\t\t\t\t\t\"Subagent exited with stopReason=error (no errorMessage in sidecar).\",\n\t\t\t\t\terrorSource: \"host\",\n\t\t\t\t};\n\t}\n\n\tif (payload?.type === \"done\") {\n\t\tconst accept = parseChildAcceptReport(payload.accept);\n\t\treturn accept\n\t\t\t? { reason: \"done\", exitCode: 0, accept }\n\t\t\t: { reason: \"done\", exitCode: 0 };\n\t}\n\n\treturn {\n\t\treason: \"error\",\n\t\texitCode: 1,\n\t\terrorMessage:\n\t\t\t\"Invalid subagent completion sidecar: unsupported payload type.\",\n\t\terrorSource: \"host\",\n\t};\n}\n\nfunction readExitSidecar(\n\tsessionFile: string | undefined,\n\tconsume = true,\n): CompletionResult | null {\n\tif (!sessionFile) return null;\n\n\tconst exitFile = `${sessionFile}.exit`;\n\tif (!existsSync(exitFile)) return null;\n\n\ttry {\n\t\tconst result = interpretExitSidecar(\n\t\t\tJSON.parse(readFileSync(exitFile, \"utf8\")),\n\t\t);\n\t\tif (consume) rmSync(exitFile, { force: true });\n\t\treturn result;\n\t} catch {\n\t\t// The child may still be writing the file. Retry on the next polling cycle.\n\t\treturn null;\n\t}\n}\n\nfunction terminalExitCode(screen: string): number | null {\n\tconst match = screen.match(TERMINAL_SENTINEL);\n\treturn match ? Number.parseInt(match[1], 10) : null;\n}\n\nfunction completionArtifact(\n\toptions: CompletionOptions,\n): CompletionResult | null {\n\treturn readExitSidecar(\n\t\toptions.sessionFile,\n\t\t!options.requireProcessExit && !options.inspectExecution,\n\t);\n}\n\nasync function waitForDelayedSidecar(\n\tsignal: AbortSignal,\n\toptions: CompletionOptions,\n): Promise<CompletionResult | null> {\n\tconst immediate = completionArtifact(options);\n\tif (immediate) return immediate;\n\n\tconst graceMs = Math.max(0, options.paneDisappearanceGraceMs ?? 500);\n\tif (graceMs === 0) return null;\n\tconst deadline = Deadline.after(graceMs);\n\twhile (!deadline.expired()) {\n\t\tconst remaining = deadline.remainingMs();\n\t\tawait abortableDelay(Math.min(25, remaining), signal);\n\t\tconst result = completionArtifact(options);\n\t\tif (result) return result;\n\t}\n\treturn null;\n}\n\nfunction abortableDelay(\n\tmilliseconds: number,\n\tsignal: AbortSignal,\n): Promise<void> {\n\tif (signal.aborted) return Promise.reject(new Error(ABORT_MESSAGE));\n\n\treturn new Promise<void>((resolve, reject) => {\n\t\tconst onAbort = () => {\n\t\t\tclearTimeout(timer);\n\t\t\treject(new Error(ABORT_MESSAGE));\n\t\t};\n\t\tconst timer = setTimeout(() => {\n\t\t\tsignal.removeEventListener(\"abort\", onAbort);\n\t\t\tresolve();\n\t\t}, milliseconds);\n\t\tsignal.addEventListener(\"abort\", onAbort, { once: true });\n\t});\n}\n\nexport async function waitForCompletion(\n\tsignal: AbortSignal,\n\toptions: CompletionOptions,\n): Promise<CompletionResult> {\n\tconst result = await detectCompletion(signal, options);\n\tif (\n\t\t(options.requireProcessExit || options.inspectExecution) &&\n\t\toptions.sessionFile\n\t) {\n\t\ttry {\n\t\t\trmSync(`${options.sessionFile}.exit`, { force: true });\n\t\t} catch {\n\t\t\t// Exit is already verified; a failed artifact cleanup cannot undo it.\n\t\t}\n\t}\n\tif (options.shellExitFile)\n\t\ttry {\n\t\t\trmSync(options.shellExitFile, { force: true });\n\t\t} catch {\n\t\t\t// Same: the record has served its purpose.\n\t\t}\n\treturn result;\n}\n\nasync function detectCompletion(\n\tsignal: AbortSignal,\n\toptions: CompletionOptions,\n): Promise<CompletionResult> {\n\tconst startedAt = Date.now();\n\n\t// Coordinated supervision waits for its first shared epoch; legacy callers\n\t// retain the immediate terminal probe.\n\tlet reconcile = !options.waitForNextCheck;\n\tfor (;;) {\n\t\tif (signal.aborted) throw new Error(ABORT_MESSAGE);\n\n\t\t// The child writes .exit before ctx.shutdown(). Keep semantic evidence\n\t\t// on disk until independent exit evidence permits releasing a persistent\n\t\t// owner, including when all waiters abort and a later wait starts afresh.\n\t\tconst sidecarResult = readExitSidecar(\n\t\t\toptions.sessionFile,\n\t\t\t!options.requireProcessExit && !options.inspectExecution,\n\t\t);\n\t\tif (\n\t\t\tsidecarResult &&\n\t\t\t!options.requireProcessExit &&\n\t\t\t!options.inspectExecution\n\t\t)\n\t\t\treturn sidecarResult;\n\t\toptions.onLocalEvidence?.();\n\n\t\tif (options.inspectExecution) {\n\t\t\tlet execution: NativeExecutionInspection;\n\t\t\ttry {\n\t\t\t\texecution = await options.inspectExecution();\n\t\t\t} catch {\n\t\t\t\texecution = { kind: \"unavailable\" };\n\t\t\t}\n\t\t\tif (execution.kind === \"finished\" || execution.kind === \"missing\") {\n\t\t\t\tconst completion = await waitForDelayedSidecar(signal, options);\n\t\t\t\tif (completion) return completion;\n\t\t\t\tif (execution.kind === \"finished\") {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tconst exitCode = terminalExitCode(await options.readTerminalTail());\n\t\t\t\t\t\toptions.onLocalEvidence?.();\n\t\t\t\t\t\tconst racedCompletion = completionArtifact(options);\n\t\t\t\t\t\tif (racedCompletion) return racedCompletion;\n\t\t\t\t\t\t// Manual interactive exit may have no sidecar. The script's\n\t\t\t\t\t\t// marker is admissible only after independent native exit,\n\t\t\t\t\t\t// and must not contradict a known native exit code.\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\texitCode !== null &&\n\t\t\t\t\t\t\t(execution.exitCode === undefined ||\n\t\t\t\t\t\t\t\texecution.exitCode === exitCode)\n\t\t\t\t\t\t)\n\t\t\t\t\t\t\treturn { reason: \"sentinel\", exitCode };\n\t\t\t\t\t} catch {\n\t\t\t\t\t\t/* Native exit remains proven; missing output is not success. */\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn {\n\t\t\t\t\treason: \"error\",\n\t\t\t\t\texitCode:\n\t\t\t\t\t\texecution.kind === \"finished\" ? (execution.exitCode ?? 1) : 1,\n\t\t\t\t\terrorMessage:\n\t\t\t\t\t\t\"Subagent native execution ended before completion evidence was recorded.\",\n\t\t\t\t\terrorSource: \"host\",\n\t\t\t\t};\n\t\t\t}\n\t\t\tconst observedAt = Date.now();\n\t\t\toptions.onPaneInspection?.(\n\t\t\t\texecution.kind === \"unavailable\"\n\t\t\t\t\t? execution\n\t\t\t\t\t: { kind: \"present\", agentStatus: \"unknown\", observedAt },\n\t\t\t\tobservedAt,\n\t\t\t);\n\t\t\t// Neither live nor unavailable can be overridden by stale terminal\n\t\t\t// sentinels, agent status=done, sidecars, or shared-list absence.\n\t\t\toptions.onTick?.(Math.floor((Date.now() - startedAt) / 1000));\n\t\t\tif (options.waitForNextCheck)\n\t\t\t\treconcile = (await options.waitForNextCheck(signal)) === \"reconcile\";\n\t\t\telse await abortableDelay(options.intervalMs, signal);\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (options.requireProcessExit && options.inspectProcess?.() === \"exited\") {\n\t\t\tconst completion = await waitForDelayedSidecar(signal, options);\n\t\t\treturn (\n\t\t\t\tcompletion ?? {\n\t\t\t\t\treason: \"error\",\n\t\t\t\t\texitCode: 1,\n\t\t\t\t\terrorMessage:\n\t\t\t\t\t\t\"Subagent process exited before completion evidence was recorded.\",\n\t\t\t\t\terrorSource: \"host\",\n\t\t\t\t}\n\t\t\t);\n\t\t}\n\n\t\t// The shell writes this only after Pi exits, so it proves exit wherever the\n\t\t// on-screen marker has scrolled (#143). A known-live identity outranks it.\n\t\tif (\n\t\t\toptions.requireProcessExit &&\n\t\t\toptions.shellExitFile &&\n\t\t\toptions.inspectProcess?.() !== \"alive\"\n\t\t) {\n\t\t\tconst exitCode = readShellExitCode(options.shellExitFile);\n\t\t\tif (exitCode !== null) {\n\t\t\t\toptions.onLocalEvidence?.();\n\t\t\t\tconst completion = await waitForDelayedSidecar(signal, options);\n\t\t\t\treturn completion ?? { reason: \"sentinel\", exitCode };\n\t\t\t}\n\t\t}\n\n\t\tif (reconcile)\n\t\t\ttry {\n\t\t\t\tconst exitCode = terminalExitCode(await options.readTerminalTail());\n\t\t\t\tif (\n\t\t\t\t\texitCode !== null &&\n\t\t\t\t\t(!options.requireProcessExit ||\n\t\t\t\t\t\toptions.inspectProcess?.() !== \"alive\")\n\t\t\t\t) {\n\t\t\t\t\t// The shell sentinel can become readable while the child publishes its\n\t\t\t\t\t// authoritative semantic record. Always recheck after the asynchronous\n\t\t\t\t\t// terminal read; a zero exit can race a ping or error just like a failure.\n\t\t\t\t\toptions.onLocalEvidence?.();\n\t\t\t\t\tconst racedCompletion = completionArtifact(options);\n\t\t\t\t\tif (racedCompletion) return racedCompletion;\n\t\t\t\t\tif (exitCode !== 0) {\n\t\t\t\t\t\tconst delayedCompletion = await waitForDelayedSidecar(\n\t\t\t\t\t\t\tsignal,\n\t\t\t\t\t\t\toptions,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\toptions.requireProcessExit &&\n\t\t\t\t\t\t\toptions.inspectProcess?.() === \"alive\"\n\t\t\t\t\t\t)\n\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\tif (delayedCompletion) return delayedCompletion;\n\t\t\t\t\t}\n\t\t\t\t\treturn { reason: \"sentinel\", exitCode };\n\t\t\t\t}\n\t\t\t} catch {\n\t\t\t\t// Terminal reads are only sentinel/output probes; Herdr status is polled\n\t\t\t\t// independently below, even when terminal reads succeed.\n\t\t\t}\n\n\t\tif (reconcile && options.inspectPane) {\n\t\t\tlet inspection: import(\"../../core/types.ts\").PaneInspection;\n\t\t\ttry {\n\t\t\t\tinspection = await options.inspectPane();\n\t\t\t} catch {\n\t\t\t\tinspection = { kind: \"unavailable\", error: \"inspectPane threw\" };\n\t\t\t}\n\t\t\tconst observedAt = Date.now();\n\t\t\toptions.onPaneInspection?.(inspection, observedAt);\n\t\t\tif (\n\t\t\t\tinspection.kind === \"missing\" &&\n\t\t\t\t(!options.requireProcessExit || options.inspectProcess?.() !== \"alive\")\n\t\t\t) {\n\t\t\t\t// Drain concurrent persistent events before accepting pane fallback.\n\t\t\t\toptions.onLocalEvidence?.();\n\t\t\t\t// Pane closure and atomic artifact publication are separate operations.\n\t\t\t\t// Allow a short bounded grace window before declaring evidence lost.\n\t\t\t\tconst racedCompletion = await waitForDelayedSidecar(signal, options);\n\t\t\t\tif (\n\t\t\t\t\toptions.requireProcessExit &&\n\t\t\t\t\toptions.inspectProcess?.() === \"alive\"\n\t\t\t\t)\n\t\t\t\t\tcontinue;\n\t\t\t\tif (racedCompletion) return racedCompletion;\n\t\t\t\treturn {\n\t\t\t\t\treason: \"error\",\n\t\t\t\t\texitCode: 1,\n\t\t\t\t\terrorMessage:\n\t\t\t\t\t\t\"Subagent pane disappeared before completion evidence was recorded.\",\n\t\t\t\t\terrorSource: \"host\",\n\t\t\t\t};\n\t\t\t}\n\t\t}\n\n\t\toptions.onTick?.(Math.floor((Date.now() - startedAt) / 1000));\n\t\tif (options.waitForNextCheck) {\n\t\t\treconcile = (await options.waitForNextCheck(signal)) === \"reconcile\";\n\t\t} else {\n\t\t\tawait abortableDelay(options.intervalMs, signal);\n\t\t\treconcile = true;\n\t\t}\n\t}\n}\n"]}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The protocol-only child entry beside this module: `entry.js` when emitted,
|
|
3
|
+
* `entry.ts` when run from source. A terminal host passes its own wrapper.
|
|
4
|
+
*/
|
|
5
|
+
export declare const DEFAULT_CHILD_ENTRY_PATH: string;
|
|
6
|
+
/**
|
|
7
|
+
* `--models <refs>` for a scoped parent, or nothing when unscoped. Pi reads
|
|
8
|
+
* these as patterns, so this is only a hint for the child's own model
|
|
9
|
+
* cycling; {@link modelScopeAssignment} carries the enforced allowlist.
|
|
10
|
+
*/
|
|
11
|
+
export declare function modelScopeArgs(modelScope: readonly string[] | undefined): string[];
|
|
12
|
+
/**
|
|
13
|
+
* The exact allowlist the child's routing intersects with its own scope. Set
|
|
14
|
+
* on every launch, empty when unscoped, so a value left in the pane's shell
|
|
15
|
+
* never reaches the child.
|
|
16
|
+
*/
|
|
17
|
+
export declare function modelScopeAssignment(modelScope: readonly string[] | undefined): string;
|
|
18
|
+
/**
|
|
19
|
+
* Always set explicitly so a value left in the pane's shell never reaches the
|
|
20
|
+
* child. Throws when this session's own depth is unknown.
|
|
21
|
+
*/
|
|
22
|
+
export declare function childDepthAssignment(launch?: "child" | "handoff"): string;
|
|
23
|
+
export declare function buildSubagentToolAllowlist(tools?: string, autoExit?: boolean, notify?: boolean): string | null;
|
|
24
|
+
export declare function timestampForFile(includeMilliseconds?: boolean): string;
|
|
25
|
+
export declare function shellComment(value: string): string;
|
|
26
|
+
export declare function safeName(name: string): string;
|
|
27
|
+
//# sourceMappingURL=launch-command.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"launch-command.d.ts","sourceRoot":"","sources":["../../../../maestro/adapters/pi/launch-command.ts"],"names":[],"mappings":"AAYA;;;GAGG;AACH,eAAO,MAAM,wBAAwB,QAKpC,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,cAAc,CAC7B,UAAU,EAAE,SAAS,MAAM,EAAE,GAAG,SAAS,GACvC,MAAM,EAAE,CAUV;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CACnC,UAAU,EAAE,SAAS,MAAM,EAAE,GAAG,SAAS,GACvC,MAAM,CAER;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,CACnC,MAAM,GAAE,OAAO,GAAG,SAAmB,GACnC,MAAM,CAER;AAED,wBAAgB,0BAA0B,CACzC,KAAK,CAAC,EAAE,MAAM,EACd,QAAQ,UAAQ,EAChB,MAAM,UAAQ,GACZ,MAAM,GAAG,IAAI,CAaf;AAED,wBAAgB,gBAAgB,CAAC,mBAAmB,UAAO,GAAG,MAAM,CAQnE;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAElD;AAED,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAO7C"}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { fileURLToPath } from "node:url";
|
|
2
|
+
import { formatInheritedModelScope, MODEL_SCOPE_ENV, modelScopeOf, } from "../../core/routing.js";
|
|
3
|
+
import { childDelegationDepth, DELEGATION_DEPTH_ENV, } from "../../core/delegation-depth.js";
|
|
4
|
+
import { shellQuote } from "../../core/shell.js";
|
|
5
|
+
/**
|
|
6
|
+
* The protocol-only child entry beside this module: `entry.js` when emitted,
|
|
7
|
+
* `entry.ts` when run from source. A terminal host passes its own wrapper.
|
|
8
|
+
*/
|
|
9
|
+
export const DEFAULT_CHILD_ENTRY_PATH = fileURLToPath(new URL(import.meta.url.endsWith(".ts") ? "./child/entry.ts" : "./child/entry.js", import.meta.url));
|
|
10
|
+
/**
|
|
11
|
+
* `--models <refs>` for a scoped parent, or nothing when unscoped. Pi reads
|
|
12
|
+
* these as patterns, so this is only a hint for the child's own model
|
|
13
|
+
* cycling; {@link modelScopeAssignment} carries the enforced allowlist.
|
|
14
|
+
*/
|
|
15
|
+
export function modelScopeArgs(modelScope) {
|
|
16
|
+
const scope = modelScopeOf({ scope: modelScope });
|
|
17
|
+
if (!scope || scope.length === 0)
|
|
18
|
+
return [];
|
|
19
|
+
// Pi splits --models on commas; a ref containing one cannot be carried.
|
|
20
|
+
const unrepresentable = scope.find((ref) => ref.includes(","));
|
|
21
|
+
if (unrepresentable)
|
|
22
|
+
throw new Error(`Cannot pass the session model scope to the child: ${JSON.stringify(unrepresentable)} contains a comma`);
|
|
23
|
+
return ["--models", shellQuote(scope.join(","))];
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* The exact allowlist the child's routing intersects with its own scope. Set
|
|
27
|
+
* on every launch, empty when unscoped, so a value left in the pane's shell
|
|
28
|
+
* never reaches the child.
|
|
29
|
+
*/
|
|
30
|
+
export function modelScopeAssignment(modelScope) {
|
|
31
|
+
return `${MODEL_SCOPE_ENV}=${shellQuote(formatInheritedModelScope(modelScope))}`;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Always set explicitly so a value left in the pane's shell never reaches the
|
|
35
|
+
* child. Throws when this session's own depth is unknown.
|
|
36
|
+
*/
|
|
37
|
+
export function childDepthAssignment(launch = "child") {
|
|
38
|
+
return `${DELEGATION_DEPTH_ENV}=${childDelegationDepth(process.env[DELEGATION_DEPTH_ENV], launch)}`;
|
|
39
|
+
}
|
|
40
|
+
export function buildSubagentToolAllowlist(tools, autoExit = false, notify = false) {
|
|
41
|
+
const requested = (tools ?? "")
|
|
42
|
+
.split(",")
|
|
43
|
+
.map((tool) => tool.trim())
|
|
44
|
+
.filter(Boolean);
|
|
45
|
+
if (requested.length === 0)
|
|
46
|
+
return null;
|
|
47
|
+
const allow = new Set(requested);
|
|
48
|
+
allow.delete("subagent_done");
|
|
49
|
+
allow.delete("caller_notify");
|
|
50
|
+
allow.add("caller_ping");
|
|
51
|
+
if (notify)
|
|
52
|
+
allow.add("caller_notify");
|
|
53
|
+
if (!autoExit)
|
|
54
|
+
allow.add("subagent_done");
|
|
55
|
+
return [...allow].join(",");
|
|
56
|
+
}
|
|
57
|
+
export function timestampForFile(includeMilliseconds = true) {
|
|
58
|
+
return (new Date()
|
|
59
|
+
.toISOString()
|
|
60
|
+
.replace(/[:.]/g, "-")
|
|
61
|
+
.slice(0, includeMilliseconds ? 23 : 19) +
|
|
62
|
+
(includeMilliseconds ? "Z" : ""));
|
|
63
|
+
}
|
|
64
|
+
export function shellComment(value) {
|
|
65
|
+
return `# ${value.replace(/[\r\n\u2028\u2029]/g, " ")}`;
|
|
66
|
+
}
|
|
67
|
+
export function safeName(name) {
|
|
68
|
+
return name
|
|
69
|
+
.toLowerCase()
|
|
70
|
+
.replace(/[^a-z0-9\s-]/g, "")
|
|
71
|
+
.replace(/\s+/g, "-")
|
|
72
|
+
.replace(/-+/g, "-")
|
|
73
|
+
.replace(/^-|-$/g, "");
|
|
74
|
+
}
|
|
75
|
+
//# sourceMappingURL=launch-command.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"launch-command.js","sourceRoot":"","sources":["../../../../maestro/adapters/pi/launch-command.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EACN,yBAAyB,EACzB,eAAe,EACf,YAAY,GACZ,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACN,oBAAoB,EACpB,oBAAoB,GACpB,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAEjD;;;GAGG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,aAAa,CACpD,IAAI,GAAG,CACN,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,kBAAkB,CAAC,CAAC,CAAC,kBAAkB,EACzE,MAAM,CAAC,IAAI,CAAC,GAAG,CACf,CACD,CAAC;AAEF;;;;GAIG;AACH,MAAM,UAAU,cAAc,CAC7B,UAAyC;IAEzC,MAAM,KAAK,GAAG,YAAY,CAAC,EAAE,KAAK,EAAE,UAAU,EAAE,CAAC,CAAC;IAClD,IAAI,CAAC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9B,KAAK,CAAC,MAAM,CAAC,eAAe,CAAC,CAAC;IAC9B,KAAK,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC;IACzB,IAAI,MAAM;QAAE,KAAK,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC;IACvC,IAAI,CAAC,QAAQ;QAAE,KAAK,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC;IAC1C,OAAO,CAAC,GAAG,KAAK,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC7B,CAAC;AAED,MAAM,UAAU,gBAAgB,CAAC,mBAAmB,GAAG,IAAI;IAC1D,OAAO,CACN,IAAI,IAAI,EAAE;SACR,WAAW,EAAE;SACb,OAAO,CAAC,OAAO,EAAE,GAAG,CAAC;SACrB,KAAK,CAAC,CAAC,EAAE,mBAAmB,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACzC,CAAC,mBAAmB,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAChC,CAAC;AACH,CAAC;AAED,MAAM,UAAU,YAAY,CAAC,KAAa;IACzC,OAAO,KAAK,KAAK,CAAC,OAAO,CAAC,qBAAqB,EAAE,GAAG,CAAC,EAAE,CAAC;AACzD,CAAC;AAED,MAAM,UAAU,QAAQ,CAAC,IAAY;IACpC,OAAO,IAAI;SACT,WAAW,EAAE;SACb,OAAO,CAAC,eAAe,EAAE,EAAE,CAAC;SAC5B,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC;SACpB,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC;SACnB,OAAO,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;AACzB,CAAC","sourcesContent":["import { fileURLToPath } from \"node:url\";\nimport {\n\tformatInheritedModelScope,\n\tMODEL_SCOPE_ENV,\n\tmodelScopeOf,\n} from \"../../core/routing.ts\";\nimport {\n\tchildDelegationDepth,\n\tDELEGATION_DEPTH_ENV,\n} from \"../../core/delegation-depth.ts\";\nimport { shellQuote } from \"../../core/shell.ts\";\n\n/**\n * The protocol-only child entry beside this module: `entry.js` when emitted,\n * `entry.ts` when run from source. A terminal host passes its own wrapper.\n */\nexport const DEFAULT_CHILD_ENTRY_PATH = fileURLToPath(\n\tnew URL(\n\t\timport.meta.url.endsWith(\".ts\") ? \"./child/entry.ts\" : \"./child/entry.js\",\n\t\timport.meta.url,\n\t),\n);\n\n/**\n * `--models <refs>` for a scoped parent, or nothing when unscoped. Pi reads\n * these as patterns, so this is only a hint for the child's own model\n * cycling; {@link modelScopeAssignment} carries the enforced allowlist.\n */\nexport function modelScopeArgs(\n\tmodelScope: readonly string[] | undefined,\n): string[] {\n\tconst scope = modelScopeOf({ scope: modelScope });\n\tif (!scope || scope.length === 0) return [];\n\t// Pi splits --models on commas; a ref containing one cannot be carried.\n\tconst unrepresentable = scope.find((ref) => ref.includes(\",\"));\n\tif (unrepresentable)\n\t\tthrow new Error(\n\t\t\t`Cannot pass the session model scope to the child: ${JSON.stringify(unrepresentable)} contains a comma`,\n\t\t);\n\treturn [\"--models\", shellQuote(scope.join(\",\"))];\n}\n\n/**\n * The exact allowlist the child's routing intersects with its own scope. Set\n * on every launch, empty when unscoped, so a value left in the pane's shell\n * never reaches the child.\n */\nexport function modelScopeAssignment(\n\tmodelScope: readonly string[] | undefined,\n): string {\n\treturn `${MODEL_SCOPE_ENV}=${shellQuote(formatInheritedModelScope(modelScope))}`;\n}\n\n/**\n * Always set explicitly so a value left in the pane's shell never reaches the\n * child. Throws when this session's own depth is unknown.\n */\nexport function childDepthAssignment(\n\tlaunch: \"child\" | \"handoff\" = \"child\",\n): string {\n\treturn `${DELEGATION_DEPTH_ENV}=${childDelegationDepth(process.env[DELEGATION_DEPTH_ENV], launch)}`;\n}\n\nexport function buildSubagentToolAllowlist(\n\ttools?: string,\n\tautoExit = false,\n\tnotify = false,\n): string | null {\n\tconst requested = (tools ?? \"\")\n\t\t.split(\",\")\n\t\t.map((tool) => tool.trim())\n\t\t.filter(Boolean);\n\tif (requested.length === 0) return null;\n\tconst allow = new Set(requested);\n\tallow.delete(\"subagent_done\");\n\tallow.delete(\"caller_notify\");\n\tallow.add(\"caller_ping\");\n\tif (notify) allow.add(\"caller_notify\");\n\tif (!autoExit) allow.add(\"subagent_done\");\n\treturn [...allow].join(\",\");\n}\n\nexport function timestampForFile(includeMilliseconds = true): string {\n\treturn (\n\t\tnew Date()\n\t\t\t.toISOString()\n\t\t\t.replace(/[:.]/g, \"-\")\n\t\t\t.slice(0, includeMilliseconds ? 23 : 19) +\n\t\t(includeMilliseconds ? \"Z\" : \"\")\n\t);\n}\n\nexport function shellComment(value: string): string {\n\treturn `# ${value.replace(/[\\r\\n\\u2028\\u2029]/g, \" \")}`;\n}\n\nexport function safeName(name: string): string {\n\treturn name\n\t\t.toLowerCase()\n\t\t.replace(/[^a-z0-9\\s-]/g, \"\")\n\t\t.replace(/\\s+/g, \"-\")\n\t\t.replace(/-+/g, \"-\")\n\t\t.replace(/^-|-$/g, \"\");\n}\n"]}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import type { PaneConfig } from "../../core/config/pane-config.ts";
|
|
2
|
+
import type { SurfaceProvider, AcquisitionControl, NativeExecution } from "../../core/surface-provider.ts";
|
|
3
|
+
import type { WorktreeOperations } from "../../core/worktree.ts";
|
|
4
|
+
import { type PiProcessIdentity, type ProcessEnvironmentReader, type ProcessIdentityProbe } from "./process-identity.ts";
|
|
5
|
+
/** What a captured identity must match: this run, its session, and its pane. */
|
|
6
|
+
export interface ProcessIdentityExpectation {
|
|
7
|
+
file: string;
|
|
8
|
+
id: string;
|
|
9
|
+
sessionFile: string;
|
|
10
|
+
}
|
|
11
|
+
type MaybePromise<T> = T | Promise<T>;
|
|
12
|
+
export interface WorktreeSurfaceForLaunch {
|
|
13
|
+
path: string;
|
|
14
|
+
branch: string;
|
|
15
|
+
workspaceId: string;
|
|
16
|
+
paneId: string;
|
|
17
|
+
diagnostics?: string[];
|
|
18
|
+
}
|
|
19
|
+
export interface PiLaunchOperations {
|
|
20
|
+
/** Present only for atomic native program launches, without a shell pane. */
|
|
21
|
+
nativeExecution?: NativeExecution;
|
|
22
|
+
/** Required for managed worktree launches; ordinary panes need no Git effects. */
|
|
23
|
+
worktree?: WorktreeOperations;
|
|
24
|
+
createPane(name: string, cwd?: string, control?: AcquisitionControl): MaybePromise<string>;
|
|
25
|
+
createWorktree(name: string, cwd: string, branch: string, base: string, control?: AcquisitionControl): MaybePromise<WorktreeSurfaceForLaunch>;
|
|
26
|
+
waitForShellReady(surface: string): Promise<void>;
|
|
27
|
+
/**
|
|
28
|
+
* Rejects with a command-dispatch `AcquisitionUncertainError` only when Pi
|
|
29
|
+
* may have started; any other rejection means nothing was dispatched, so the
|
|
30
|
+
* launch rolls back as a definite failure.
|
|
31
|
+
*/
|
|
32
|
+
runScript(surface: string, command: string, options: {
|
|
33
|
+
scriptPath: string;
|
|
34
|
+
scriptPreamble: string;
|
|
35
|
+
}): MaybePromise<string>;
|
|
36
|
+
/** Rollback resolves only once this ordinary pane is confirmed absent. */
|
|
37
|
+
closePane(pane: string): MaybePromise<void>;
|
|
38
|
+
waitForPiReady?(surface: string, sessionFile: string, cwd: string): Promise<void>;
|
|
39
|
+
focusWorkspace?(workspaceId: string): MaybePromise<void>;
|
|
40
|
+
/** Bounded readiness capture of a worktree child's verified process identity. */
|
|
41
|
+
captureProcessIdentity?(surface: string, expected: ProcessIdentityExpectation, options?: {
|
|
42
|
+
timeoutMs?: number;
|
|
43
|
+
}): Promise<PiProcessIdentity>;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Names the launched session in the Pi process's exec-time environment. Pi
|
|
47
|
+
* rewrites its command line, so `--session` is never readiness evidence.
|
|
48
|
+
* Nothing inside Pi reads it.
|
|
49
|
+
*/
|
|
50
|
+
export declare const PI_LAUNCH_SESSION_ENV = "PI_HERDR_AGENTS_SESSION";
|
|
51
|
+
export declare function isExpectedPiProcess(process: {
|
|
52
|
+
pid: number;
|
|
53
|
+
name?: string;
|
|
54
|
+
argv0?: string;
|
|
55
|
+
argv?: string[];
|
|
56
|
+
cwd?: string;
|
|
57
|
+
}, sessionFile: string, cwd: string, readEnvironment?: ProcessEnvironmentReader, platform?: NodeJS.Platform): boolean;
|
|
58
|
+
/**
|
|
59
|
+
* Wait for the child to publish its own identity, then accept it only while
|
|
60
|
+
* that process is alive in this host's namespace as the Herdr pane shell or a
|
|
61
|
+
* descendant of it. Command-line text is never consulted: Pi rewrites it.
|
|
62
|
+
*/
|
|
63
|
+
export declare function captureSurfacePiProcessIdentity(provider: Pick<SurfaceProvider, "getProcessInfo">, surface: string, expected: ProcessIdentityExpectation, options?: {
|
|
64
|
+
timeoutMs?: number;
|
|
65
|
+
intervalMs?: number;
|
|
66
|
+
probe?: ProcessIdentityProbe;
|
|
67
|
+
}): Promise<PiProcessIdentity>;
|
|
68
|
+
/**
|
|
69
|
+
* The pending value if it settles before the deadline; otherwise undefined.
|
|
70
|
+
* A value that arrives after the deadline is dropped, never reported, even
|
|
71
|
+
* when a delayed event loop runs it before the overdue timer.
|
|
72
|
+
*/
|
|
73
|
+
export declare function settleBefore<T>(pending: Promise<T> | undefined, deadline: number, options?: {
|
|
74
|
+
unref?: boolean;
|
|
75
|
+
}): Promise<T | undefined>;
|
|
76
|
+
export declare function launchOperationsFromSurface(provider: SurfaceProvider, config: PaneConfig, worktree?: WorktreeOperations): PiLaunchOperations;
|
|
77
|
+
export {};
|
|
78
|
+
//# sourceMappingURL=launch-operations.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"launch-operations.d.ts","sourceRoot":"","sources":["../../../../maestro/adapters/pi/launch-operations.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kCAAkC,CAAC;AACnE,OAAO,KAAK,EACX,eAAe,EACf,kBAAkB,EAElB,eAAe,EACf,MAAM,gCAAgC,CAAC;AACxC,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAA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