@selesai/code 0.13.15 → 0.13.18
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/CHANGELOG.md +37 -0
- package/README.md +2 -14
- package/dist/bun/cli.d.ts +3 -1
- package/dist/bun/cli.js +3 -9
- package/dist/bun/{register-bedrock.js → runtime-setup.js} +5 -0
- package/dist/bun/sandbox-env-setup.d.ts +1 -0
- package/dist/bun/sandbox-env-setup.js +3 -0
- package/dist/cli/auth-command.d.ts +23 -0
- package/dist/cli/auth-command.js +102 -0
- package/dist/cli/config-selector.js +2 -1
- package/dist/cli/setup.d.ts +1 -0
- package/dist/cli/setup.js +11 -0
- package/dist/cli.js +2 -14
- package/dist/config.d.ts +3 -2
- package/dist/config.js +9 -4
- package/dist/core/agent-session-runtime.js +15 -7
- package/dist/core/agent-session.d.ts +2 -6
- package/dist/core/agent-session.js +15 -4
- package/dist/core/compaction/branch-summarization.d.ts +1 -1
- package/dist/core/compaction/branch-summarization.js +2 -1
- package/dist/core/extensions/loader.js +3 -0
- package/dist/core/extensions/types.d.ts +16 -2
- package/dist/core/http-dispatcher.js +2 -0
- package/dist/core/keybindings.d.ts +5 -0
- package/dist/core/keybindings.js +4 -0
- package/dist/core/messages.d.ts +1 -1
- package/dist/core/model-config.d.ts +15 -0
- package/dist/core/model-config.js +3 -0
- package/dist/core/model-runtime.d.ts +1 -0
- package/dist/core/model-runtime.js +5 -2
- package/dist/core/provider-composer.js +8 -2
- package/dist/core/session-export.d.ts +3 -0
- package/dist/core/session-export.js +31 -0
- package/dist/core/session-manager.d.ts +3 -2
- package/dist/core/session-manager.js +40 -13
- package/dist/core/skills.d.ts +1 -1
- package/dist/core/skills.js +4 -2
- package/dist/core/system-prompt.js +10 -10
- package/dist/core/tools/bash.js +3 -117
- package/dist/core/tools/edit.d.ts +1 -12
- package/dist/core/tools/edit.js +5 -163
- package/dist/core/tools/find.js +4 -55
- package/dist/core/tools/grep.js +4 -60
- package/dist/core/tools/ls.js +4 -49
- package/dist/core/tools/read.d.ts +4 -0
- package/dist/core/tools/read.js +10 -122
- package/dist/core/tools/renderers/bash.d.ts +11 -0
- package/dist/core/tools/renderers/bash.js +129 -0
- package/dist/core/tools/renderers/edit.d.ts +22 -0
- package/dist/core/tools/renderers/edit.js +166 -0
- package/dist/core/tools/renderers/find.d.ts +9 -0
- package/dist/core/tools/renderers/find.js +63 -0
- package/dist/core/tools/renderers/grep.d.ts +9 -0
- package/dist/core/tools/renderers/grep.js +68 -0
- package/dist/core/tools/renderers/index.d.ts +27 -0
- package/dist/core/tools/renderers/index.js +46 -0
- package/dist/core/tools/renderers/ls.d.ts +9 -0
- package/dist/core/tools/renderers/ls.js +57 -0
- package/dist/core/tools/renderers/read.d.ts +10 -0
- package/dist/core/tools/renderers/read.js +128 -0
- package/dist/core/tools/renderers/write.d.ts +9 -0
- package/dist/core/tools/renderers/write.js +152 -0
- package/dist/core/tools/write.js +5 -146
- package/dist/extensions/capability-gateway/index.ts +12 -1
- package/dist/extensions/capability-gateway/integration.test.ts +23 -0
- package/dist/extensions/pi-hermes-memory/CHANGELOG.md +18 -0
- package/dist/extensions/pi-hermes-memory/README.md +16 -12
- package/dist/extensions/pi-hermes-memory/docs/ROADMAP.md +1 -1
- package/dist/extensions/pi-hermes-memory/package-lock.json +587 -62
- package/dist/extensions/pi-hermes-memory/package.json +4 -4
- package/dist/extensions/pi-hermes-memory/src/config.ts +32 -0
- package/dist/extensions/pi-hermes-memory/src/constants.ts +12 -2
- package/dist/extensions/pi-hermes-memory/src/handlers/background-review.ts +109 -51
- package/dist/extensions/pi-hermes-memory/src/handlers/index-sessions.ts +9 -3
- package/dist/extensions/pi-hermes-memory/src/handlers/review-memory-ops.ts +257 -98
- package/dist/extensions/pi-hermes-memory/src/handlers/session-backfill.ts +9 -2
- package/dist/extensions/pi-hermes-memory/src/handlers/sync-markdown-memories.ts +5 -0
- package/dist/extensions/pi-hermes-memory/src/index.ts +22 -2
- package/dist/extensions/pi-hermes-memory/src/paths.ts +1 -1
- package/dist/extensions/pi-hermes-memory/src/store/db.ts +6 -0
- package/dist/extensions/pi-hermes-memory/src/store/fts-query.ts +58 -1
- package/dist/extensions/pi-hermes-memory/src/store/memory-store.ts +60 -8
- package/dist/extensions/pi-hermes-memory/src/store/session-indexer.ts +169 -7
- package/dist/extensions/pi-hermes-memory/src/store/session-search.ts +7 -21
- package/dist/extensions/pi-hermes-memory/src/store/sqlite-memory-store.ts +134 -15
- package/dist/extensions/pi-hermes-memory/src/tools/memory-search-tool.ts +4 -2
- package/dist/extensions/pi-hermes-memory/src/tools/memory-tool.ts +24 -9
- package/dist/extensions/pi-hermes-memory/src/types.ts +11 -0
- package/dist/extensions/pi-hermes-memory/tests/config.test.ts +42 -0
- package/dist/extensions/pi-hermes-memory/tests/handlers/background-review.test.ts +159 -3
- package/dist/extensions/pi-hermes-memory/tests/handlers/review-memory-ops.test.ts +452 -0
- package/dist/extensions/pi-hermes-memory/tests/handlers/session-backfill.test.ts +39 -0
- package/dist/extensions/pi-hermes-memory/tests/integration/corruption-recovery-integration.test.ts +91 -0
- package/dist/extensions/pi-hermes-memory/tests/store/db.test.ts +29 -0
- package/dist/extensions/pi-hermes-memory/tests/store/fts-query.test.ts +116 -0
- package/dist/extensions/pi-hermes-memory/tests/store/memory-store.test.ts +163 -0
- package/dist/extensions/pi-hermes-memory/tests/store/session-indexer.test.ts +233 -0
- package/dist/extensions/pi-hermes-memory/tests/store/session-search.test.ts +12 -0
- package/dist/extensions/pi-hermes-memory/tests/store/sqlite-memory-store.test.ts +175 -0
- package/dist/extensions/pi-hermes-memory/tests/store/sqlite-native.test.ts +2 -2
- package/dist/extensions/pi-hermes-memory/tests/tools/memory-search-tool.test.ts +22 -0
- package/dist/extensions/pi-hermes-memory/tests/tools/memory-tool.test.ts +37 -1
- package/dist/extensions/pi-intercom/CHANGELOG.md +13 -0
- package/dist/extensions/pi-intercom/README.md +16 -2
- package/dist/extensions/pi-intercom/broker/spawn.test.ts +19 -2
- package/dist/extensions/pi-intercom/broker/spawn.ts +4 -4
- package/dist/extensions/pi-intercom/index.ts +1 -1
- package/dist/extensions/pi-intercom/intercom.integration.test.ts +121 -2
- package/dist/extensions/pi-intercom/package.json +1 -1
- package/dist/extensions/pi-intercom/project-agent.test.ts +1 -1
- package/dist/extensions/pi-intercom/project-agent.ts +1 -6
- package/dist/extensions/pi-intercom/skills/pi-intercom/SKILL.md +7 -6
- package/dist/extensions/pi-rewind-hook/index.test.ts +7 -0
- package/dist/extensions/pi-subagents/.github/workflows/test.yml +36 -4
- package/dist/extensions/pi-subagents/CHANGELOG.md +120 -0
- package/dist/extensions/pi-subagents/README.md +3 -3
- package/dist/extensions/pi-subagents/agents/researcher.md +23 -13
- package/dist/extensions/pi-subagents/agents/reviewer.md +1 -1
- package/dist/extensions/pi-subagents/agents/scout.md +1 -1
- package/dist/extensions/pi-subagents/docs/agents.md +32 -16
- package/dist/extensions/pi-subagents/docs/configuration.md +41 -15
- package/dist/extensions/pi-subagents/docs/extension-api.md +109 -6
- package/dist/extensions/pi-subagents/docs/missions.md +2 -0
- package/dist/extensions/pi-subagents/docs/models.md +58 -1
- package/dist/extensions/pi-subagents/docs/observability.md +50 -12
- package/dist/extensions/pi-subagents/docs/tool-reference.md +17 -10
- package/dist/extensions/pi-subagents/docs/watchdog.md +1 -1
- package/dist/extensions/pi-subagents/docs/workflows.md +26 -9
- package/dist/extensions/pi-subagents/package-lock.json +747 -177
- package/dist/extensions/pi-subagents/package.json +6 -4
- package/dist/extensions/pi-subagents/runner-server-preload.mjs +13 -0
- package/dist/extensions/pi-subagents/skills/pi-subagents/SKILL.md +2 -1
- package/dist/extensions/pi-subagents/skills/pi-subagents/references/constraints-and-recipes.md +1 -1
- package/dist/extensions/pi-subagents/skills/pi-subagents/references/execution-controls.md +21 -4
- package/dist/extensions/pi-subagents/skills/pi-subagents/references/management-authoring-rpc.md +2 -1
- package/dist/extensions/pi-subagents/skills/pi-subagents/references/multi-lane-orchestration.md +2 -0
- package/dist/extensions/pi-subagents/src/agents/advertised-agent-prompt.ts +63 -0
- package/dist/extensions/pi-subagents/src/agents/agent-management.ts +61 -16
- package/dist/extensions/pi-subagents/src/agents/agent-serializer.ts +2 -0
- package/dist/extensions/pi-subagents/src/agents/agents.ts +8 -0
- package/dist/extensions/pi-subagents/src/api/capability-ceiling.ts +0 -1
- package/dist/extensions/pi-subagents/src/api/{pi-args.ts → child-tool-plan.ts} +1 -1
- package/dist/extensions/pi-subagents/src/api/preflight.ts +7 -4
- package/dist/extensions/pi-subagents/src/api/shared-types.ts +2 -2
- package/dist/extensions/pi-subagents/src/api/workflow-resources.ts +6 -0
- package/dist/extensions/pi-subagents/src/extension/config.ts +4 -2
- package/dist/extensions/pi-subagents/src/extension/doctor.ts +2 -10
- package/dist/extensions/pi-subagents/src/extension/fanout-child.ts +9 -11
- package/dist/extensions/pi-subagents/src/extension/index.ts +99 -10
- package/dist/extensions/pi-subagents/src/extension/public-execution.ts +13 -0
- package/dist/extensions/pi-subagents/src/extension/rpc.ts +7 -23
- package/dist/extensions/pi-subagents/src/extension/schemas.ts +11 -8
- package/dist/extensions/pi-subagents/src/extension/tool-description.ts +25 -7
- package/dist/extensions/pi-subagents/src/integrations/pi-web-session-liveness.ts +73 -0
- package/dist/extensions/pi-subagents/src/intercom/native-supervisor-channel.ts +228 -136
- package/dist/extensions/pi-subagents/src/intercom/supervisor-ui.ts +244 -0
- package/dist/extensions/pi-subagents/src/missions/workflow-state.ts +37 -16
- package/dist/extensions/pi-subagents/src/runs/background/active-async-capacity.ts +18 -18
- package/dist/extensions/pi-subagents/src/runs/background/async-execution.ts +51 -25
- package/dist/extensions/pi-subagents/src/runs/background/async-job-tracker.ts +46 -3
- package/dist/extensions/pi-subagents/src/runs/background/async-resume.ts +14 -3
- package/dist/extensions/pi-subagents/src/runs/background/async-retention.ts +9 -0
- package/dist/extensions/pi-subagents/src/runs/background/async-status-snapshot.ts +10 -12
- package/dist/extensions/pi-subagents/src/runs/background/async-status.ts +18 -15
- package/dist/extensions/pi-subagents/src/runs/background/auto-drain.ts +40 -29
- package/dist/extensions/pi-subagents/src/runs/background/chain-root-attachment.ts +8 -0
- package/dist/extensions/pi-subagents/src/runs/background/control-channel.ts +79 -247
- package/dist/extensions/pi-subagents/src/runs/background/notify.ts +88 -12
- package/dist/extensions/pi-subagents/src/runs/background/owned-process-tree.ts +6 -6
- package/dist/extensions/pi-subagents/src/runs/background/process-terminal.ts +24 -24
- package/dist/extensions/pi-subagents/src/runs/background/retained-nested-route-tracker.ts +96 -0
- package/dist/extensions/pi-subagents/src/runs/background/run-child-session.ts +642 -0
- package/dist/extensions/pi-subagents/src/runs/background/run-status.ts +75 -6
- package/dist/extensions/pi-subagents/src/runs/background/runner-aliases.ts +163 -0
- package/dist/extensions/pi-subagents/src/runs/background/runner-child-launch.ts +86 -0
- package/dist/extensions/pi-subagents/src/runs/background/runner-child-sessions.ts +31 -0
- package/dist/extensions/pi-subagents/src/runs/background/scheduled-runs.ts +18 -4
- package/dist/extensions/pi-subagents/src/runs/background/stale-run-reconciler.ts +3 -1
- package/dist/extensions/pi-subagents/src/runs/background/subagent-runner.ts +597 -1092
- package/dist/extensions/pi-subagents/src/runs/background/subagent-wait.ts +3 -0
- package/dist/extensions/pi-subagents/src/runs/background/wait-completions.ts +4 -0
- package/dist/extensions/pi-subagents/src/runs/foreground/async-steering-action.ts +20 -17
- package/dist/extensions/pi-subagents/src/runs/foreground/execution.ts +296 -394
- package/dist/extensions/pi-subagents/src/runs/foreground/foreground-control.ts +4 -0
- package/dist/extensions/pi-subagents/src/runs/foreground/foreground-history.ts +3 -1
- package/dist/extensions/pi-subagents/src/runs/foreground/prompt-audit.ts +9 -5
- package/dist/extensions/pi-subagents/src/runs/foreground/subagent-executor.ts +630 -283
- package/dist/extensions/pi-subagents/src/runs/foreground/workflow-detach-reconcile.ts +8 -5
- package/dist/extensions/pi-subagents/src/runs/foreground/workflow-foreground-steering.ts +78 -98
- package/dist/extensions/pi-subagents/src/runs/shared/abort-recovery.ts +3 -3
- package/dist/extensions/pi-subagents/src/runs/shared/acceptance.ts +16 -3
- package/dist/extensions/pi-subagents/src/runs/shared/agent-contract.ts +1 -1
- package/dist/extensions/pi-subagents/src/runs/shared/async-status-projection.ts +47 -47
- package/dist/extensions/pi-subagents/src/runs/shared/capability-ceiling.ts +1 -2
- package/dist/extensions/pi-subagents/src/runs/shared/child-hooks.ts +174 -0
- package/dist/extensions/pi-subagents/src/runs/shared/child-identity.ts +14 -3
- package/dist/extensions/pi-subagents/src/runs/shared/child-launch.ts +319 -0
- package/dist/extensions/pi-subagents/src/runs/shared/child-lifecycle.ts +25 -0
- package/dist/extensions/pi-subagents/src/runs/shared/child-runtime-config.ts +126 -0
- package/dist/extensions/pi-subagents/src/runs/shared/child-session.ts +373 -0
- package/dist/extensions/pi-subagents/src/runs/shared/child-tool-plan.ts +530 -0
- package/dist/extensions/pi-subagents/src/runs/shared/completion-evidence.ts +2 -2
- package/dist/extensions/pi-subagents/src/runs/shared/completion-guard.ts +2 -1
- package/dist/extensions/pi-subagents/src/runs/shared/external-cli-preflight.ts +16 -0
- package/dist/extensions/pi-subagents/src/runs/shared/host-step-status.ts +11 -11
- package/dist/extensions/pi-subagents/src/runs/shared/llm-intent-arbiter.ts +30 -20
- package/dist/extensions/pi-subagents/src/runs/shared/mcp-direct-tool-allowlist.ts +5 -4
- package/dist/extensions/pi-subagents/src/runs/shared/model-exclusions.ts +84 -15
- package/dist/extensions/pi-subagents/src/runs/shared/model-fallback.ts +88 -12
- package/dist/extensions/pi-subagents/src/runs/shared/nested-events.ts +37 -53
- package/dist/extensions/pi-subagents/src/runs/shared/nested-path.ts +1 -1
- package/dist/extensions/pi-subagents/src/runs/shared/orca-progress-tabs.ts +18 -7
- package/dist/extensions/pi-subagents/src/runs/shared/parallel-handoff.ts +57 -12
- package/dist/extensions/pi-subagents/src/runs/shared/parallel-utils.ts +3 -4
- package/dist/extensions/pi-subagents/src/runs/shared/permissions.ts +0 -11
- package/dist/extensions/pi-subagents/src/runs/shared/process-signal.ts +4 -1
- package/dist/extensions/pi-subagents/src/runs/shared/readonly-drain-observation.ts +42 -0
- package/dist/extensions/pi-subagents/src/runs/shared/readonly-model-continuation.ts +69 -0
- package/dist/extensions/pi-subagents/src/runs/shared/readonly-session-evidence.ts +307 -0
- package/dist/extensions/pi-subagents/src/runs/shared/run-fanout-budget.ts +8 -21
- package/dist/extensions/pi-subagents/src/runs/shared/runtime-acknowledged-extensions.ts +3 -30
- package/dist/extensions/pi-subagents/src/runs/shared/structured-output.ts +17 -4
- package/dist/extensions/pi-subagents/src/runs/shared/subagent-control.ts +2 -0
- package/dist/extensions/pi-subagents/src/runs/shared/subagent-prompt-runtime.ts +99 -386
- package/dist/extensions/pi-subagents/src/runs/shared/tool-availability.ts +18 -62
- package/dist/extensions/pi-subagents/src/runs/shared/tool-budget.ts +0 -14
- package/dist/extensions/pi-subagents/src/runs/shared/worktree-cleanup-plan.ts +31 -9
- package/dist/extensions/pi-subagents/src/runs/shared/worktree-setup-command.ts +190 -0
- package/dist/extensions/pi-subagents/src/runs/shared/worktree.ts +506 -226
- package/dist/extensions/pi-subagents/src/shared/child-session-name.ts +1 -1
- package/dist/extensions/pi-subagents/src/shared/jsonl-writer.ts +11 -0
- package/dist/extensions/pi-subagents/src/shared/model-response-aliases.ts +13 -0
- package/dist/extensions/pi-subagents/src/shared/thinking-ceiling.ts +0 -6
- package/dist/extensions/pi-subagents/src/shared/types.ts +145 -89
- package/dist/extensions/pi-subagents/src/shared/utils.ts +13 -6
- package/dist/extensions/pi-subagents/src/shared/watch-strategy.ts +2 -0
- package/dist/extensions/pi-subagents/src/shared/workflow-child-permit.ts +18 -13
- package/dist/extensions/pi-subagents/src/slash/slash-commands.ts +0 -6
- package/dist/extensions/pi-subagents/src/tui/fleet-status.ts +1 -1
- package/dist/extensions/pi-subagents/src/tui/fleet.ts +11 -6
- package/dist/extensions/pi-subagents/src/tui/render.ts +277 -46
- package/dist/extensions/pi-subagents/src/watchdog/child-status.ts +0 -1
- package/dist/extensions/pi-subagents/src/watchdog/register-child.ts +12 -12
- package/dist/extensions/pi-subagents/src/workflows/chat-progress.ts +3 -3
- package/dist/extensions/pi-subagents/src/workflows/scripted-workflow.ts +116 -15
- package/dist/extensions/pi-subagents/src/workflows/workflow-checklist.ts +15 -18
- package/dist/extensions/pi-subagents/src/workflows/workflow-child-summary.ts +57 -8
- package/dist/extensions/pi-subagents/src/workflows/workflow-preflight.ts +19 -19
- package/dist/extensions/pi-subagents/src/workflows/workflow-receipt.ts +3 -3
- package/dist/extensions/pi-subagents/src/workflows/workflow-resources.ts +97 -22
- package/dist/extensions/pi-subagents/src/workflows/workflow-settlement.ts +3 -0
- package/dist/extensions/pi-subagents/test/integration/acceptance-file-report.test.ts +336 -21
- package/dist/extensions/pi-subagents/test/integration/async-execution.part-1.test.ts +1181 -0
- package/dist/extensions/pi-subagents/test/integration/async-execution.part-2.test.ts +2240 -0
- package/dist/extensions/pi-subagents/test/integration/async-execution.part-3.test.ts +2268 -0
- package/dist/extensions/pi-subagents/test/integration/async-execution.part-4.test.ts +1512 -0
- package/dist/extensions/pi-subagents/test/integration/async-job-tracker.test.ts +231 -16
- package/dist/extensions/pi-subagents/test/integration/error-handling.test.ts +4 -18
- package/dist/extensions/pi-subagents/test/integration/foreign-workflow-steering.test.ts +95 -0
- package/dist/extensions/pi-subagents/test/integration/fork-context-execution.test.ts +9 -15
- package/dist/extensions/pi-subagents/test/integration/in-process-child.test.ts +374 -0
- package/dist/extensions/pi-subagents/test/integration/intercom-result-delivery.test.ts +20 -10
- package/dist/extensions/pi-subagents/test/integration/orca-progress-tabs.test.ts +18 -6
- package/dist/extensions/pi-subagents/test/integration/recovered-assistant-error.test.ts +151 -0
- package/dist/extensions/pi-subagents/test/integration/render-fork-badge.test.ts +42 -1
- package/dist/extensions/pi-subagents/test/integration/render-widget.test.ts +150 -25
- package/dist/extensions/pi-subagents/test/integration/result-publication.test.ts +354 -0
- package/dist/extensions/pi-subagents/test/integration/shared-cwd-terminal-evidence.test.ts +117 -0
- package/dist/extensions/pi-subagents/test/integration/single-execution.part-1.test.ts +3678 -0
- package/dist/extensions/pi-subagents/test/integration/{single-execution.test.ts → single-execution.part-2.test.ts} +500 -4207
- package/dist/extensions/pi-subagents/test/integration/slash-commands.test.ts +1 -2
- package/dist/extensions/pi-subagents/test/integration/workflow-result-publication.test.ts +127 -0
- package/dist/extensions/pi-subagents/test/integration/workflow-steer-inbox.test.ts +365 -0
- package/dist/extensions/pi-subagents/test/smoke/pi085-child.ts +31 -0
- package/dist/extensions/pi-subagents/test/smoke/pi085-clean-install.mjs +74 -0
- package/dist/extensions/pi-subagents/test/smoke/pi085-extension.ts +16 -0
- package/dist/extensions/pi-subagents/test/support/async-execution-fixture.ts +699 -0
- package/dist/extensions/pi-subagents/test/support/fake-child-session.ts +418 -0
- package/dist/extensions/pi-subagents/test/support/foreign-workflow-steer-host.mjs +13 -0
- package/dist/extensions/pi-subagents/test/support/mock-pi.ts +30 -76
- package/dist/extensions/pi-subagents/test/support/notify-diagnostics-fixture.ts +84 -0
- package/dist/extensions/pi-subagents/test/support/result-publication-capacity-preload.mjs +70 -0
- package/dist/extensions/pi-subagents/test/support/runner-child-session-factory.ts +17 -0
- package/dist/extensions/pi-subagents/test/support/single-execution-fixture.ts +390 -0
- package/dist/extensions/pi-subagents/test/unit/acceptance-compaction.test.ts +120 -0
- package/dist/extensions/pi-subagents/test/unit/acceptance.test.ts +24 -3
- package/dist/extensions/pi-subagents/test/unit/advertised-agent-prompt.test.ts +87 -0
- package/dist/extensions/pi-subagents/test/unit/advertised-agent-refresh.test.ts +163 -0
- package/dist/extensions/pi-subagents/test/unit/agent-frontmatter.test.ts +70 -31
- package/dist/extensions/pi-subagents/test/unit/agent-management.test.ts +78 -3
- package/dist/extensions/pi-subagents/test/unit/agent-overrides.test.ts +2 -8
- package/dist/extensions/pi-subagents/test/unit/async-execution.test.ts +1 -1
- package/dist/extensions/pi-subagents/test/unit/async-interrupt-action.test.ts +73 -66
- package/dist/extensions/pi-subagents/test/unit/async-recovery-descriptor.test.ts +51 -1
- package/dist/extensions/pi-subagents/test/unit/async-retention.test.ts +49 -1
- package/dist/extensions/pi-subagents/test/unit/async-spawn-preload.test.ts +103 -0
- package/dist/extensions/pi-subagents/test/unit/async-status-projection.test.ts +3 -3
- package/dist/extensions/pi-subagents/test/unit/capability-ceiling-agent-allowlist.test.ts +9 -8
- package/dist/extensions/pi-subagents/test/unit/capability-ceiling.test.ts +10 -7
- package/dist/extensions/pi-subagents/test/unit/chain-root-attachment.test.ts +48 -6
- package/dist/extensions/pi-subagents/test/unit/child-runtime-config.test.ts +90 -0
- package/dist/extensions/pi-subagents/test/unit/{pi-args-permission-system.test.ts → child-tool-plan-permission-system.test.ts} +48 -86
- package/dist/extensions/pi-subagents/test/unit/child-tool-plan.test.ts +33 -0
- package/dist/extensions/pi-subagents/test/unit/compaction-resume.test.ts +18 -18
- package/dist/extensions/pi-subagents/test/unit/completion-evidence.test.ts +9 -9
- package/dist/extensions/pi-subagents/test/unit/completion-guard.test.ts +8 -7
- package/dist/extensions/pi-subagents/test/unit/control-channel.test.ts +225 -65
- package/dist/extensions/pi-subagents/test/unit/extension-bindings.test.ts +17 -22
- package/dist/extensions/pi-subagents/test/unit/fleet-status.test.ts +11 -1
- package/dist/extensions/pi-subagents/test/unit/fleet.test.ts +47 -3
- package/dist/extensions/pi-subagents/test/unit/foreign-workflow-steering.test.ts +74 -0
- package/dist/extensions/pi-subagents/test/unit/fork-cache-key.test.ts +23 -29
- package/dist/extensions/pi-subagents/test/unit/host-peer-runtime-imports.test.ts +96 -4
- package/dist/extensions/pi-subagents/test/unit/host-step-status.test.ts +4 -4
- package/dist/extensions/pi-subagents/test/unit/index-child-registration.test.ts +116 -55
- package/dist/extensions/pi-subagents/test/unit/index-segment.test.ts +58 -1
- package/dist/extensions/pi-subagents/test/unit/llm-intent-arbiter.test.ts +104 -3
- package/dist/extensions/pi-subagents/test/unit/mission-lifecycle.test.ts +10 -1
- package/dist/extensions/pi-subagents/test/unit/mission-store.test.ts +31 -1
- package/dist/extensions/pi-subagents/test/unit/model-exclusions.test.ts +102 -51
- package/dist/extensions/pi-subagents/test/unit/model-fallback.test.ts +196 -6
- package/dist/extensions/pi-subagents/test/unit/native-supervisor-channel.test.ts +181 -38
- package/dist/extensions/pi-subagents/test/unit/nested-control.test.ts +62 -70
- package/dist/extensions/pi-subagents/test/unit/nested-events.test.ts +58 -53
- package/dist/extensions/pi-subagents/test/unit/notify-diagnostics.test.ts +42 -0
- package/dist/extensions/pi-subagents/test/unit/notify.test.ts +84 -0
- package/dist/extensions/pi-subagents/test/unit/orca-progress-tabs.test.ts +13 -5
- package/dist/extensions/pi-subagents/test/unit/package-manifest.test.ts +21 -5
- package/dist/extensions/pi-subagents/test/unit/parallel-handoff.test.ts +5 -4
- package/dist/extensions/pi-subagents/test/unit/permissions.test.ts +2 -6
- package/dist/extensions/pi-subagents/test/unit/pi-coding-agent-dir.test.ts +28 -2
- package/dist/extensions/pi-subagents/test/unit/pi-web-session-liveness.test.ts +209 -0
- package/dist/extensions/pi-subagents/test/unit/preflight.test.ts +38 -1
- package/dist/extensions/pi-subagents/test/unit/prompt-audit-optional-peers.test.ts +43 -0
- package/dist/extensions/pi-subagents/test/unit/public-execution.test.ts +24 -2
- package/dist/extensions/pi-subagents/test/unit/readonly-drain-observation.test.ts +174 -0
- package/dist/extensions/pi-subagents/test/unit/readonly-model-continuation.test.ts +94 -0
- package/dist/extensions/pi-subagents/test/unit/readonly-session-evidence.test.ts +1329 -0
- package/dist/extensions/pi-subagents/test/unit/recursion-guard.test.ts +29 -80
- package/dist/extensions/pi-subagents/test/unit/render-helpers.test.ts +11 -8
- package/dist/extensions/pi-subagents/test/unit/result-files.test.ts +2 -2
- package/dist/extensions/pi-subagents/test/unit/retained-nested-route-tracker.test.ts +175 -0
- package/dist/extensions/pi-subagents/test/unit/rpc.test.ts +38 -12
- package/dist/extensions/pi-subagents/test/unit/run-fanout-budget.test.ts +2 -5
- package/dist/extensions/pi-subagents/test/unit/run-status.test.ts +89 -1
- package/dist/extensions/pi-subagents/test/unit/runtime-acknowledged-extensions.test.ts +2 -16
- package/dist/extensions/pi-subagents/test/unit/scheduled-runs.test.ts +27 -3
- package/dist/extensions/pi-subagents/test/unit/scheduled-supervisor-demand.test.ts +215 -0
- package/dist/extensions/pi-subagents/test/unit/schemas.test.ts +15 -11
- package/dist/extensions/pi-subagents/test/unit/scripted-workflow.test.ts +237 -1
- package/dist/extensions/pi-subagents/test/unit/steering-action.test.ts +2 -5
- package/dist/extensions/pi-subagents/test/unit/streamed-progress-bounds.test.ts +2 -2
- package/dist/extensions/pi-subagents/test/unit/subagent-guide.test.ts +14 -1
- package/dist/extensions/pi-subagents/test/unit/subagent-prompt-runtime.test.ts +130 -739
- package/dist/extensions/pi-subagents/test/unit/supervisor-ask-registration.test.ts +682 -0
- package/dist/extensions/pi-subagents/test/unit/supervisor-ui.test.ts +137 -0
- package/dist/extensions/pi-subagents/test/unit/tool-budget.test.ts +1 -11
- package/dist/extensions/pi-subagents/test/unit/tool-description.test.ts +23 -3
- package/dist/extensions/pi-subagents/test/unit/wait-completions.test.ts +8 -1
- package/dist/extensions/pi-subagents/test/unit/watchdog-tool-actions.test.ts +19 -1
- package/dist/extensions/pi-subagents/test/unit/workflow-chat-progress.test.ts +72 -4
- package/dist/extensions/pi-subagents/test/unit/workflow-checklist.test.ts +17 -3
- package/dist/extensions/pi-subagents/test/unit/workflow-child-summary.test.ts +34 -0
- package/dist/extensions/pi-subagents/test/unit/workflow-detach-reconcile.test.ts +12 -2
- package/dist/extensions/pi-subagents/test/unit/workflow-launch-params.test.ts +46 -6
- package/dist/extensions/pi-subagents/test/unit/workflow-receipt.test.ts +3 -3
- package/dist/extensions/pi-subagents/test/unit/workflow-resources.test.ts +133 -1
- package/dist/extensions/pi-subagents/test/unit/workflow-resume-hint.test.ts +53 -2
- package/dist/extensions/pi-subagents/test/unit/worktree-cleanup-plan.test.ts +222 -14
- package/dist/extensions/pi-subagents/test/unit/worktree.test.ts +526 -85
- package/dist/extensions/pi-web-agent/src/backends/config.ts +1 -0
- package/dist/extensions/pi-web-agent/src/backends/settings-reader.ts +5 -3
- package/dist/extensions/pi-web-agent/src/search/tokenin.ts +7 -3
- package/dist/extensions/pi-web-agent/src/types.ts +1 -1
- package/dist/extensions/pi-zentui/README.md +17 -0
- package/dist/extensions/pi-zentui/assets/screenshots/footer-status-hyperlink.png +0 -0
- package/dist/extensions/pi-zentui/docs/configuration.md +71 -2
- package/dist/extensions/pi-zentui/extensions/zentui/config.ts +11 -0
- package/dist/extensions/pi-zentui/extensions/zentui/editor-transfer.ts +14 -0
- package/dist/extensions/pi-zentui/extensions/zentui/extension-status.ts +29 -13
- package/dist/extensions/pi-zentui/extensions/zentui/footer-layout.ts +5 -4
- package/dist/extensions/pi-zentui/extensions/zentui/footer-text.ts +11 -0
- package/dist/extensions/pi-zentui/extensions/zentui/footer.ts +11 -10
- package/dist/extensions/pi-zentui/extensions/zentui/index.ts +77 -3
- package/dist/extensions/pi-zentui/extensions/zentui/presets.ts +77 -0
- package/dist/extensions/pi-zentui/extensions/zentui/settings-command.ts +103 -2
- package/dist/extensions/pi-zentui/extensions/zentui/working-line-extension-segments.ts +115 -0
- package/dist/extensions/pi-zentui/extensions/zentui/working-line.ts +87 -5
- package/dist/extensions/pi-zentui/package-lock.json +277 -517
- package/dist/extensions/pi-zentui/package.json +7 -4
- package/dist/extensions/pi-zentui/test/config-presets.test.ts +238 -0
- package/dist/extensions/pi-zentui/test/editor-transfer.test.ts +24 -1
- package/dist/extensions/pi-zentui/test/extension-compliance.test.ts +570 -2
- package/dist/extensions/pi-zentui/test/extension-status.test.ts +90 -0
- package/dist/extensions/pi-zentui/test/footer-hyperlink.test.ts +243 -0
- package/dist/extensions/pi-zentui/test/package-contents.mjs +1 -0
- package/dist/extensions/pi-zentui/test/presets.test.ts +121 -0
- package/dist/extensions/pi-zentui/test/settings-command.test.ts +205 -1
- package/dist/extensions/pi-zentui/test/working-line-extension-segments.test.ts +139 -0
- package/dist/extensions/pi-zentui/test/working-line-lifecycle.integration.test.ts +237 -3
- package/dist/extensions/pi-zentui/test/working-line.test.ts +94 -2
- package/dist/index.d.ts +1 -1
- package/dist/main.js +4 -1
- package/dist/modes/interactive/chat-viewport.d.ts +19 -0
- package/dist/modes/interactive/chat-viewport.js +27 -0
- package/dist/modes/interactive/components/assistant-message.d.ts +6 -2
- package/dist/modes/interactive/components/assistant-message.js +30 -13
- package/dist/modes/interactive/components/custom-editor.d.ts +10 -1
- package/dist/modes/interactive/components/custom-editor.js +39 -1
- package/dist/modes/interactive/components/first-time-setup.js +1 -1
- package/dist/modes/interactive/components/index.d.ts +1 -1
- package/dist/modes/interactive/components/markdown-transform.d.ts +2 -0
- package/dist/modes/interactive/components/markdown-transform.js +18 -0
- package/dist/modes/interactive/components/model-selector.js +19 -17
- package/dist/modes/interactive/components/scoped-models-selector.js +21 -23
- package/dist/modes/interactive/components/settings-selector.d.ts +7 -1
- package/dist/modes/interactive/components/settings-selector.js +128 -20
- package/dist/modes/interactive/components/settings-submenu.d.ts +71 -0
- package/dist/modes/interactive/components/settings-submenu.js +164 -0
- package/dist/modes/interactive/components/status-indicator.d.ts +3 -1
- package/dist/modes/interactive/components/status-indicator.js +10 -3
- package/dist/modes/interactive/components/thinking-selector.d.ts +15 -3
- package/dist/modes/interactive/components/thinking-selector.js +75 -18
- package/dist/modes/interactive/components/tool-execution.d.ts +21 -4
- package/dist/modes/interactive/components/tool-execution.js +35 -33
- package/dist/modes/interactive/components/trust-selector.js +2 -2
- package/dist/modes/interactive/interactive-mode.d.ts +13 -15
- package/dist/modes/interactive/interactive-mode.js +144 -80
- package/dist/modes/interactive/session-share.d.ts +15 -0
- package/dist/modes/interactive/session-share.js +183 -0
- package/dist/modes/interactive/theme/dark.json +2 -1
- package/dist/modes/interactive/theme/light.json +2 -1
- package/dist/modes/interactive/theme/theme-controller.d.ts +1 -0
- package/dist/modes/interactive/theme/theme-controller.js +5 -0
- package/dist/modes/interactive/theme/theme-json.d.ts +83 -0
- package/dist/modes/interactive/theme/theme-json.js +129 -0
- package/dist/modes/interactive/theme/theme-schema.json +9 -1
- package/dist/modes/interactive/theme/theme.d.ts +14 -5
- package/dist/modes/interactive/theme/theme.js +18 -119
- package/dist/modes/interactive/tui-renderer.d.ts +20 -0
- package/dist/modes/interactive/tui-renderer.js +65 -0
- package/dist/utils/exif-orientation.js +2 -3
- package/dist/utils/management-http.d.ts +24 -0
- package/dist/utils/management-http.js +53 -0
- package/dist/utils/text.d.ts +7 -0
- package/dist/utils/text.js +8 -0
- package/dist/utils/tools-manager.d.ts +1 -0
- package/dist/utils/tools-manager.js +43 -21
- package/docs/docs.json +0 -4
- package/package.json +4 -4
- package/dist/extensions/pi-subagents/src/runs/shared/child-protocol.ts +0 -415
- package/dist/extensions/pi-subagents/src/runs/shared/pi-args.ts +0 -1059
- package/dist/extensions/pi-subagents/src/runs/shared/subagent-startup-retry.ts +0 -116
- package/dist/extensions/pi-subagents/src/shared/post-exit-stdio-guard.ts +0 -85
- package/dist/extensions/pi-subagents/test/e2e/real-session-subagent.test.ts +0 -224
- package/dist/extensions/pi-subagents/test/integration/async-execution.test.ts +0 -6986
- package/dist/extensions/pi-subagents/test/support/mock-pi-script.mjs +0 -447
- package/dist/extensions/pi-subagents/test/support/real-session-child-cli.mjs +0 -185
- package/dist/extensions/pi-subagents/test/support/real-session-runner.ts +0 -311
- package/dist/extensions/pi-subagents/test/unit/capability-ceiling-pi-args.test.ts +0 -84
- package/dist/extensions/pi-subagents/test/unit/child-protocol.test.ts +0 -202
- package/dist/extensions/pi-subagents/test/unit/close-grace-timer.test.ts +0 -101
- package/dist/extensions/pi-subagents/test/unit/pi-args.test.ts +0 -2347
- package/dist/extensions/pi-subagents/test/unit/subagent-startup-retry.test.ts +0 -104
- package/dist/extensions/pi-subagents/test/unit/windows-hide-spawn.test.ts +0 -49
- package/dist/skills/imagegen-frontend-mobile/SKILL.md +0 -1465
- package/dist/skills/imagegen-frontend-web/SKILL.md +0 -987
- package/dist/skills/implanger/SKILL.md +0 -70
- package/dist/skills/output/SKILL.md +0 -49
- package/dist/skills/planger/SKILL.md +0 -167
- package/dist/skills/workflow/SKILL.md +0 -95
- package/docs/workflows.md +0 -18
- /package/dist/bun/{register-bedrock.d.ts → runtime-setup.d.ts} +0 -0
|
@@ -3,14 +3,19 @@
|
|
|
3
3
|
* child wrote to its configured output file (recovered from its write tool
|
|
4
4
|
* calls) versus the assistant text, ordered by outputMode, including parallel
|
|
5
5
|
* children with the distinct configured paths required after #420. Runs the
|
|
6
|
-
* full
|
|
6
|
+
* full launch, event, and acceptance pipeline against the scripted child session.
|
|
7
7
|
*/
|
|
8
8
|
import { after, afterEach, before, beforeEach, describe, it } from "node:test";
|
|
9
9
|
import assert from "node:assert/strict";
|
|
10
|
+
import { ChildProcess, execFileSync } from "node:child_process";
|
|
11
|
+
import { channel } from "node:diagnostics_channel";
|
|
10
12
|
import * as fs from "node:fs";
|
|
11
13
|
import * as path from "node:path";
|
|
14
|
+
import { pathToFileURL } from "node:url";
|
|
15
|
+
import { readProcessTerminal } from "../../src/runs/background/process-terminal.ts";
|
|
16
|
+
import { childSessionFactoryModule, setChildSessionFactoryModule } from "../../src/runs/shared/child-session.ts";
|
|
12
17
|
import type { MockPi } from "../support/helpers.ts";
|
|
13
|
-
import { createEventBus, createMockPi, createTempDir, events, makeAgent, makeAgentConfigs, makeMinimalCtx,
|
|
18
|
+
import { createEventBus, createMockPi, createTempDir, events, makeAgent, makeAgentConfigs, makeMinimalCtx, tryImport } from "../support/helpers.ts";
|
|
14
19
|
|
|
15
20
|
interface AcceptanceSummary {
|
|
16
21
|
status?: string;
|
|
@@ -111,18 +116,263 @@ function acceptanceReport(criterionStatus: "satisfied" | "not-satisfied", eviden
|
|
|
111
116
|
}
|
|
112
117
|
|
|
113
118
|
async function waitForAsyncResult(id: string, timeoutMs = 15_000): Promise<AsyncResultPayload> {
|
|
119
|
+
const marks = ownedRunners.get(id)?.marks;
|
|
120
|
+
if (marks) marks.resultWaitStartedAt = Date.now();
|
|
114
121
|
const resultPath = path.join(RESULTS_DIR!, `${id}.json`);
|
|
115
122
|
const deadline = Date.now() + timeoutMs;
|
|
116
123
|
while (!fs.existsSync(resultPath)) {
|
|
117
124
|
if (Date.now() > deadline) assert.fail(`Timed out waiting for async result file: ${resultPath}`);
|
|
118
125
|
await new Promise((resolve) => setTimeout(resolve, 100));
|
|
119
126
|
}
|
|
120
|
-
|
|
127
|
+
const payload = JSON.parse(fs.readFileSync(resultPath, "utf-8")) as AsyncResultPayload;
|
|
128
|
+
if (marks) marks.resultReadAt = Date.now();
|
|
129
|
+
return payload;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
// Diagnostic only: retaining ChildProcess objects may perturb observer lifetime.
|
|
133
|
+
// Neither callbacks nor these projections authorize cleanup.
|
|
134
|
+
const ownedRunners = new Map<string, ReturnType<typeof observeRunner>>();
|
|
135
|
+
function observeRunner(id: string, bodyStartedAt: number, disableCompileCache: boolean) {
|
|
136
|
+
const record = (value: unknown): Record<string, unknown> => value !== null && typeof value === "object" ? value as Record<string, unknown> : {};
|
|
137
|
+
const number = (value: unknown) => typeof value === "number" && Number.isFinite(value) ? value : undefined;
|
|
138
|
+
const known = (value: unknown, values: string[]) => typeof value === "string" && values.includes(value) ? value : undefined;
|
|
139
|
+
const errorCode = (error: unknown) => known(record(error).code, ["ENOENT", "EACCES", "EPERM", "EBUSY", "EIO", "EMFILE", "ENFILE", "ENOSPC"]) ?? "other";
|
|
140
|
+
const project = (value: unknown) => {
|
|
141
|
+
const raw = record(value);
|
|
142
|
+
return {
|
|
143
|
+
runMatches: (raw.runId ?? raw.id) === id,
|
|
144
|
+
runnerProcessInstanceId: typeof raw.runnerProcessInstanceId === "string" && /^[a-zA-Z0-9:-]{1,128}$/.test(raw.runnerProcessInstanceId) ? raw.runnerProcessInstanceId : undefined,
|
|
145
|
+
state: known(raw.state, ["pending", "running", "complete", "failed", "stopped", "paused", "observed", "unknown", "not-started"]),
|
|
146
|
+
reason: known(raw.reason, ["runner-candidate-missing", "runner-instance-mismatch", "writer-close-unverified", "process-tree-unverified", "canonical-session-unavailable", "canonical-session-lease-active", "canonical-session-release-unverified", "proof-write-failed"]),
|
|
147
|
+
pid: number(raw.pid), startedAt: number(raw.startedAt), endedAt: number(raw.endedAt), observedAt: number(raw.observedAt),
|
|
148
|
+
success: typeof raw.success === "boolean" ? raw.success : undefined,
|
|
149
|
+
writerCount: Array.isArray(record(raw.writers)["0"]) ? record(raw.writers)["0"].length : undefined,
|
|
150
|
+
expectedWriters: number(record(raw.expectedWriters)["0"]),
|
|
151
|
+
};
|
|
152
|
+
};
|
|
153
|
+
const marks: Record<string, number> = { bodyStartedAt, launchStartedAt: Date.now() };
|
|
154
|
+
let pid: number | undefined;
|
|
155
|
+
let identity: Record<string, unknown> | undefined;
|
|
156
|
+
const notifications: unknown[] = [];
|
|
157
|
+
const processes: Array<{ proc: ChildProcess; events: unknown[]; dispose: () => void }> = [];
|
|
158
|
+
const diagnosticChannel = channel("child_process");
|
|
159
|
+
const onProcess = (message: unknown) => {
|
|
160
|
+
const proc = record(message).process;
|
|
161
|
+
if (!(proc instanceof ChildProcess) || processes.length >= 8) return;
|
|
162
|
+
const events: unknown[] = [];
|
|
163
|
+
const add = (type: string, code?: number | null, signal?: string | null) => events.push({ type, at: Date.now(), code, signal: signal === null ? null : known(signal, ["SIGTERM", "SIGKILL", "SIGINT", "SIGABRT", "SIGSEGV"]) });
|
|
164
|
+
const spawn = () => add("spawn");
|
|
165
|
+
const error = (err: Error) => events.push({ type: "error", at: Date.now(), code: errorCode(err) });
|
|
166
|
+
const exit = (code: number | null, signal: string | null) => add("exit", code, signal);
|
|
167
|
+
const close = (code: number | null, signal: string | null) => add("close", code, signal);
|
|
168
|
+
proc.once("spawn", spawn).once("error", error).once("exit", exit).once("close", close);
|
|
169
|
+
processes.push({ proc, events, dispose: () => { proc.off("spawn", spawn).off("error", error).off("exit", exit).off("close", close); } });
|
|
170
|
+
};
|
|
171
|
+
function queryIdentity(proc: ChildProcess | undefined): Record<string, unknown> {
|
|
172
|
+
const at = Date.now();
|
|
173
|
+
const config = proc?.spawnargs.at(-1);
|
|
174
|
+
if (process.platform !== "win32") return { at, state: "unavailable", reason: "platform" };
|
|
175
|
+
if (!proc || !path.isAbsolute(proc.spawnfile) || !config || !path.isAbsolute(config) || path.basename(config) !== `async-cfg-${id}.json`) {
|
|
176
|
+
return { at, state: "unavailable", reason: "correlation" };
|
|
177
|
+
}
|
|
178
|
+
try {
|
|
179
|
+
// CommandLineToArgvW avoids substring/quoting guesses. Only fixed projections leave PowerShell.
|
|
180
|
+
const script = `
|
|
181
|
+
$ErrorActionPreference = 'Stop'
|
|
182
|
+
try {
|
|
183
|
+
$p = Get-CimInstance Win32_Process -Filter 'ProcessId=${pid}' -Property CreationDate,ExecutablePath,CommandLine
|
|
184
|
+
if ($null -eq $p) { '{"state":"missing"}'; return }
|
|
185
|
+
if (!$p.CreationDate -or !$p.ExecutablePath -or !$p.CommandLine) { '{"state":"unavailable"}'; return }
|
|
186
|
+
Add-Type -TypeDefinition @'
|
|
187
|
+
using System;
|
|
188
|
+
using System.Runtime.InteropServices;
|
|
189
|
+
public static class AcceptanceIdentity {
|
|
190
|
+
[DllImport("shell32.dll", CharSet = CharSet.Unicode, SetLastError = true)]
|
|
191
|
+
static extern IntPtr CommandLineToArgvW(string line, out int count);
|
|
192
|
+
[DllImport("kernel32.dll")]
|
|
193
|
+
static extern IntPtr LocalFree(IntPtr memory);
|
|
194
|
+
public static bool Matches(string line, string config, int expectedCount) {
|
|
195
|
+
int count;
|
|
196
|
+
IntPtr args = CommandLineToArgvW(line, out count);
|
|
197
|
+
if (args == IntPtr.Zero) throw new InvalidOperationException();
|
|
198
|
+
try {
|
|
199
|
+
if (count != expectedCount) return false;
|
|
200
|
+
int matches = 0;
|
|
201
|
+
for (int i = 1; i < count; i++) {
|
|
202
|
+
string arg = Marshal.PtrToStringUni(Marshal.ReadIntPtr(args, i * IntPtr.Size));
|
|
203
|
+
if (String.Equals(arg, config, StringComparison.Ordinal)) matches++;
|
|
204
|
+
if (i == count - 1 && !String.Equals(arg, config, StringComparison.Ordinal)) return false;
|
|
205
|
+
}
|
|
206
|
+
return matches == 1;
|
|
207
|
+
} finally { LocalFree(args); }
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
'@
|
|
211
|
+
$exe = [string]::Equals($p.ExecutablePath, $env:ACCEPTANCE_EXPECTED_EXE, [StringComparison]::OrdinalIgnoreCase)
|
|
212
|
+
$config = [AcceptanceIdentity]::Matches($p.CommandLine, $env:ACCEPTANCE_EXPECTED_CONFIG, ${proc.spawnargs.length})
|
|
213
|
+
$state = if ($exe -and $config) { 'matched' } else { 'mismatch' }
|
|
214
|
+
@{ state=$state; creationTime=$p.CreationDate.ToUniversalTime().ToString('o'); executableMatches=$exe; configArgumentMatches=$config } | ConvertTo-Json -Compress
|
|
215
|
+
} catch {
|
|
216
|
+
if ($_.Exception -is [UnauthorizedAccessException] -or $_.Exception.NativeErrorCode -eq 2) { '{"state":"permission-denied"}' }
|
|
217
|
+
else { '{"state":"unavailable"}' }
|
|
218
|
+
}
|
|
219
|
+
`;
|
|
220
|
+
const raw = record(JSON.parse(execFileSync("powershell.exe", ["-NoLogo", "-NoProfile", "-NonInteractive", "-Command", script], {
|
|
221
|
+
encoding: "utf-8", stdio: ["ignore", "pipe", "ignore"], timeout: 2000, maxBuffer: 4096, windowsHide: true,
|
|
222
|
+
env: { ...process.env, ACCEPTANCE_EXPECTED_EXE: proc.spawnfile, ACCEPTANCE_EXPECTED_CONFIG: config },
|
|
223
|
+
})));
|
|
224
|
+
const state = known(raw.state, ["matched", "mismatch", "missing", "permission-denied", "unavailable"]) ?? "unavailable";
|
|
225
|
+
if (state !== "matched" && state !== "mismatch") return { at, completedAt: Date.now(), state };
|
|
226
|
+
if (typeof raw.creationTime !== "string" || !/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{7}Z$/.test(raw.creationTime)
|
|
227
|
+
|| typeof raw.executableMatches !== "boolean" || typeof raw.configArgumentMatches !== "boolean"
|
|
228
|
+
|| (state === "matched") !== (raw.executableMatches && raw.configArgumentMatches)) {
|
|
229
|
+
return { at, completedAt: Date.now(), state: "unavailable", reason: "invalid-response" };
|
|
230
|
+
}
|
|
231
|
+
return { at, completedAt: Date.now(), state, creationTime: raw.creationTime, executableMatches: raw.executableMatches, configArgumentMatches: raw.configArgumentMatches };
|
|
232
|
+
} catch (error) {
|
|
233
|
+
const code = record(error).code;
|
|
234
|
+
return { at, completedAt: Date.now(), state: code === "ETIMEDOUT" ? "timeout" : code === "EACCES" || code === "EPERM" ? "permission-denied" : "unavailable" };
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
return {
|
|
238
|
+
marks,
|
|
239
|
+
emit(type: string, value: unknown) {
|
|
240
|
+
const raw = record(value);
|
|
241
|
+
if (type === "subagent:async-started" && raw.id === id) pid = number(raw.pid);
|
|
242
|
+
else if (type !== "subagent:process-terminal" || raw.runId !== id) return;
|
|
243
|
+
if (notifications.length < 8) notifications.push({ type, at: Date.now(), ...project(raw) });
|
|
244
|
+
},
|
|
245
|
+
launch(run: () => unknown) {
|
|
246
|
+
const nodeOptions = process.env.NODE_OPTIONS;
|
|
247
|
+
const previousDisableCompileCache = process.env.NODE_DISABLE_COMPILE_CACHE;
|
|
248
|
+
diagnosticChannel.subscribe(onProcess);
|
|
249
|
+
try {
|
|
250
|
+
process.env.NODE_OPTIONS = `${nodeOptions ?? ""} --trace-exit`;
|
|
251
|
+
if (disableCompileCache) process.env.NODE_DISABLE_COMPILE_CACHE = "1";
|
|
252
|
+
return run();
|
|
253
|
+
}
|
|
254
|
+
finally {
|
|
255
|
+
if (disableCompileCache) {
|
|
256
|
+
if (previousDisableCompileCache === undefined) delete process.env.NODE_DISABLE_COMPILE_CACHE;
|
|
257
|
+
else process.env.NODE_DISABLE_COMPILE_CACHE = previousDisableCompileCache;
|
|
258
|
+
}
|
|
259
|
+
if (nodeOptions === undefined) delete process.env.NODE_OPTIONS;
|
|
260
|
+
else process.env.NODE_OPTIONS = nodeOptions;
|
|
261
|
+
marks.launchFinishedAt = Date.now();
|
|
262
|
+
diagnosticChannel.unsubscribe(onProcess);
|
|
263
|
+
for (const entry of processes) if (pid === undefined || entry.proc.pid !== pid) entry.dispose();
|
|
264
|
+
}
|
|
265
|
+
},
|
|
266
|
+
readEvidence(file: string, kind: "json" | "phases" | "journal" = "json") {
|
|
267
|
+
const matched = processes.filter(({ proc }) => pid !== undefined && Number.isSafeInteger(pid) && pid > 0 && proc.pid === pid);
|
|
268
|
+
const readAt = Date.now();
|
|
269
|
+
try {
|
|
270
|
+
const fd = fs.openSync(file, "r");
|
|
271
|
+
try {
|
|
272
|
+
const size = fs.fstatSync(fd).size;
|
|
273
|
+
const limit = kind === "phases" ? 8192 : 65536;
|
|
274
|
+
if (kind === "json" && size > limit) return { readAt, size, io: "oversized", truncated: true };
|
|
275
|
+
const offset = kind === "json" ? 0 : Math.max(0, size - limit);
|
|
276
|
+
const buffer = Buffer.alloc(Math.min(size, limit));
|
|
277
|
+
const bytes = fs.readSync(fd, buffer, 0, buffer.length, offset);
|
|
278
|
+
const text = buffer.toString("utf-8", 0, bytes);
|
|
279
|
+
const base = { readAt, size, bytes, io: "readable", truncated: offset > 0 };
|
|
280
|
+
if (kind === "json") return { ...base, ...project(JSON.parse(text)) };
|
|
281
|
+
const lines = text.split("\n").slice(offset > 0 ? 1 : 0);
|
|
282
|
+
const entries: unknown[] = [];
|
|
283
|
+
let parseErrors = 0;
|
|
284
|
+
for (const line of lines.filter(Boolean)) {
|
|
285
|
+
if (kind === "phases") {
|
|
286
|
+
if (matched.length !== 1) continue;
|
|
287
|
+
// Native Environment::Exit follows AtExit, precedes shutdown, and has no timestamp.
|
|
288
|
+
const trace = /^\(node:(\d{1,16})\) WARNING: Exited the environment with code (-?\d{1,10})\r?$/.exec(line);
|
|
289
|
+
if (trace && Number(trace[1]) === pid) {
|
|
290
|
+
entries.push({ phase: "native-trace-exit", pid, code: Number(trace[2]) });
|
|
291
|
+
continue;
|
|
292
|
+
}
|
|
293
|
+
const runtime = /^#1916 runtime node=(v\d{1,3}\.\d{1,3}\.\d{1,3}) uv=(\d{1,3}\.\d{1,3}\.\d{1,3}) cacheEnabled=(true|false|unavailable) pid=(\d{1,16})$/.exec(line);
|
|
294
|
+
if (runtime && Number(runtime[4]) === pid) {
|
|
295
|
+
entries.push({ phase: "runtime", node: runtime[1], uv: runtime[2], cacheEnabled: runtime[3] === "unavailable" ? "unavailable" : runtime[3] === "true", pid });
|
|
296
|
+
continue;
|
|
297
|
+
}
|
|
298
|
+
const match = /^#1918 phase=(dispose-entry|dispose-return|dispose-rejection|exit|exit-request|exit-dispatch-return|exit-dispatch-throw) invocation=(\d{1,16}) ts=(\d{1,16}) pid=(\d{1,16})$/.exec(line);
|
|
299
|
+
if (!match) continue;
|
|
300
|
+
const [invocation, ts, markerPid] = match.slice(2).map(Number);
|
|
301
|
+
if (![invocation, ts, markerPid].every(Number.isSafeInteger) || markerPid !== pid || ts <= 0) continue;
|
|
302
|
+
if (match[1]!.startsWith("exit") ? invocation !== 0 : invocation < 1 || invocation > 8) continue;
|
|
303
|
+
entries.push({ phase: match[1], invocation, ts, pid: markerPid });
|
|
304
|
+
} else {
|
|
305
|
+
try {
|
|
306
|
+
const event = record(JSON.parse(line));
|
|
307
|
+
const type = known(event.type, ["subagent.run.started", "subagent.run.completed", "subagent.run.process_terminal"]);
|
|
308
|
+
if (type && event.runId === id) entries.push({ type, ts: number(event.ts), ...project(event), proof: project(event.processTerminal) });
|
|
309
|
+
} catch { parseErrors++; }
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
return { ...base, parseErrors, entries: entries.slice(-16), entriesTruncated: entries.length > 16 };
|
|
313
|
+
} finally { fs.closeSync(fd); }
|
|
314
|
+
} catch (error) { return { readAt, io: error instanceof SyntaxError ? "invalid-json" : errorCode(error) }; }
|
|
315
|
+
},
|
|
316
|
+
snapshot(proof: unknown) {
|
|
317
|
+
const snapshotAt = Date.now();
|
|
318
|
+
const matched = processes.filter(({ proc }) => pid !== undefined && Number.isSafeInteger(pid) && pid > 0 && proc.pid === pid);
|
|
319
|
+
const read = this.readEvidence;
|
|
320
|
+
const asyncDir = path.join(ASYNC_DIR!, id);
|
|
321
|
+
const snapshot = {
|
|
322
|
+
id, pid, marks, notifications, lastProof: project(proof), snapshotAt,
|
|
323
|
+
capturedProcesses: processes.length,
|
|
324
|
+
processes: processes.filter(({ proc }) => pid !== undefined && proc.pid === pid).map(({ proc, events }) => ({ pid: proc.pid, exitCode: proc.exitCode, signalCode: known(proc.signalCode, ["SIGTERM", "SIGKILL", "SIGINT", "SIGABRT", "SIGSEGV"]), events })),
|
|
325
|
+
status: read(path.join(asyncDir, "status.json")), result: read(path.join(RESULTS_DIR!, `${id}.json`)),
|
|
326
|
+
candidate: read(path.join(asyncDir, "process-terminal-candidate.json")), proof: read(path.join(asyncDir, "process-terminal.json")),
|
|
327
|
+
phases: read(path.join(asyncDir, "runner.stderr.log"), "phases"), journal: read(path.join(asyncDir, "events.jsonl"), "journal"),
|
|
328
|
+
};
|
|
329
|
+
// One failure-only query, after the original evidence snapshot. Never cleanup authority.
|
|
330
|
+
identity ??= queryIdentity(matched.length === 1 ? matched[0]!.proc : undefined);
|
|
331
|
+
return { ...snapshot, identity };
|
|
332
|
+
},
|
|
333
|
+
measureControl(proof: unknown) {
|
|
334
|
+
if (!disableCompileCache) return;
|
|
335
|
+
try {
|
|
336
|
+
console.log("#1947 cache-disable-control " + JSON.stringify({
|
|
337
|
+
id, pid, measuredAt: Date.now(), proof: project(proof),
|
|
338
|
+
processes: processes.filter(({ proc }) => pid !== undefined && proc.pid === pid).map(({ proc, events }) => ({ pid: proc.pid, exitCode: proc.exitCode, events })),
|
|
339
|
+
phases: this.readEvidence(path.join(ASYNC_DIR!, id, "runner.stderr.log"), "phases"),
|
|
340
|
+
}));
|
|
341
|
+
}
|
|
342
|
+
catch { console.log('#1947 cache-disable-control {"measurement":"unavailable"}'); }
|
|
343
|
+
},
|
|
344
|
+
dispose() { for (const entry of processes) entry.dispose(); },
|
|
345
|
+
};
|
|
121
346
|
}
|
|
122
347
|
|
|
123
348
|
describe("acceptance file reports", { skip: !runSync ? "pi packages not available" : undefined }, () => {
|
|
124
349
|
let tempDir: string;
|
|
125
350
|
let mockPi: MockPi;
|
|
351
|
+
let bodyStartedAt: number;
|
|
352
|
+
let terminalBarrier: Promise<void> | undefined;
|
|
353
|
+
|
|
354
|
+
async function waitForOwnedRunner(id: string): Promise<void> {
|
|
355
|
+
const diagnostic = ownedRunners.get(id)!;
|
|
356
|
+
diagnostic.marks.teardownStartedAt = Date.now();
|
|
357
|
+
const asyncDir = path.join(ASYNC_DIR!, id);
|
|
358
|
+
const deadline = Date.now() + 10_000;
|
|
359
|
+
let proof;
|
|
360
|
+
do {
|
|
361
|
+
// The reader validates identity/shape and treats absent or partial I/O as unproven.
|
|
362
|
+
proof = readProcessTerminal(asyncDir, { runId: id });
|
|
363
|
+
if (proof?.state === "observed") {
|
|
364
|
+
diagnostic.measureControl(proof);
|
|
365
|
+
diagnostic.dispose();
|
|
366
|
+
return;
|
|
367
|
+
}
|
|
368
|
+
await new Promise((resolve) => setTimeout(resolve, 50));
|
|
369
|
+
} while (Date.now() <= deadline);
|
|
370
|
+
let evidence: unknown;
|
|
371
|
+
try { evidence = diagnostic.snapshot(proof); }
|
|
372
|
+
catch { evidence = { snapshot: "unavailable" }; }
|
|
373
|
+
finally { diagnostic.dispose(); }
|
|
374
|
+
assert.fail(`No terminal proof for owned runner ${id}; retaining ${tempDir} and mock queue ${mockPi.dir}. Diagnostics: ${JSON.stringify(evidence)}`);
|
|
375
|
+
}
|
|
126
376
|
|
|
127
377
|
before(() => {
|
|
128
378
|
mockPi = createMockPi();
|
|
@@ -130,16 +380,24 @@ describe("acceptance file reports", { skip: !runSync ? "pi packages not availabl
|
|
|
130
380
|
});
|
|
131
381
|
|
|
132
382
|
after(() => {
|
|
383
|
+
assert.equal(ownedRunners.size, 0, "Unproven owned runners: retain the mock queue");
|
|
133
384
|
mockPi.uninstall();
|
|
134
385
|
});
|
|
135
386
|
|
|
136
387
|
beforeEach(() => {
|
|
388
|
+
assert.equal(ownedRunners.size, 0, "Unproven owned runners: do not reset the mock queue");
|
|
389
|
+
terminalBarrier = undefined;
|
|
137
390
|
tempDir = createTempDir();
|
|
138
391
|
mockPi.reset();
|
|
392
|
+
bodyStartedAt = Date.now();
|
|
139
393
|
});
|
|
140
394
|
|
|
141
|
-
afterEach(() => {
|
|
142
|
-
|
|
395
|
+
afterEach(async () => {
|
|
396
|
+
// Result publication precedes runner close. Also drain on assertion/result-wait failure.
|
|
397
|
+
// Cache a failed barrier so later hooks cannot retry cleanup or reset shared state.
|
|
398
|
+
terminalBarrier ??= Promise.all([...ownedRunners.keys()].map(waitForOwnedRunner)).then(() => { ownedRunners.clear(); });
|
|
399
|
+
await terminalBarrier;
|
|
400
|
+
fs.rmSync(tempDir, { recursive: true, force: true });
|
|
143
401
|
});
|
|
144
402
|
|
|
145
403
|
function conflictingReportsCall(outputPath: string, fileStatus: "satisfied" | "not-satisfied", textStatus: "satisfied" | "not-satisfied") {
|
|
@@ -405,27 +663,84 @@ describe("acceptance file reports", { skip: !runSync ? "pi packages not availabl
|
|
|
405
663
|
});
|
|
406
664
|
|
|
407
665
|
describe("background runner", { skip: isAsyncAvailable && !isAsyncAvailable() ? "jiti not available" : undefined }, () => {
|
|
408
|
-
function runAsyncSingle(id: string, outputPath: string, outputMode: "inline" | "file-only", artifactConfig = DISABLED_ARTIFACTS) {
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
666
|
+
function runAsyncSingle(id: string, outputPath: string, outputMode: "inline" | "file-only", artifactConfig = DISABLED_ARTIFACTS, disableCompileCache = false) {
|
|
667
|
+
const originalFactoryModule = childSessionFactoryModule();
|
|
668
|
+
assert.ok(originalFactoryModule, "expected the installed scripted runner factory");
|
|
669
|
+
const factoryPath = path.join(tempDir, "acceptance-exit-phases.mjs");
|
|
670
|
+
fs.writeFileSync(factoryPath, `
|
|
671
|
+
import { writeSync } from "node:fs";
|
|
672
|
+
import nodeModule from "node:module";
|
|
673
|
+
import createFactory from ${JSON.stringify(pathToFileURL(originalFactoryModule).href)};
|
|
674
|
+
export default function() {
|
|
675
|
+
const factory = createFactory();
|
|
676
|
+
let invocation = 0;
|
|
677
|
+
const mark = (phase, call) => {
|
|
678
|
+
if (call > 8) return;
|
|
679
|
+
try { writeSync(process.stderr.fd, "#1918 phase=" + phase + " invocation=" + call + " ts=" + Date.now() + " pid=" + process.pid + "\\n"); } catch {}
|
|
680
|
+
};
|
|
681
|
+
process.once("exit", () => mark("exit", 0));
|
|
682
|
+
const originalExit = process.exit;
|
|
683
|
+
const originalEmit = process.emit;
|
|
684
|
+
process.exit = function(...args) {
|
|
685
|
+
mark("exit-request", 0);
|
|
686
|
+
return Reflect.apply(originalExit, this, args);
|
|
687
|
+
};
|
|
688
|
+
process.emit = function(...args) {
|
|
689
|
+
if (args[0] !== "exit") return Reflect.apply(originalEmit, this, args);
|
|
690
|
+
try {
|
|
691
|
+
const result = Reflect.apply(originalEmit, this, args);
|
|
692
|
+
mark("exit-dispatch-return", 0);
|
|
693
|
+
return result;
|
|
694
|
+
} catch (error) { mark("exit-dispatch-throw", 0); throw error; }
|
|
695
|
+
};
|
|
696
|
+
try {
|
|
697
|
+
const cacheEnabled = typeof nodeModule.getCompileCacheDir === "function" ? Boolean(nodeModule.getCompileCacheDir()) : "unavailable";
|
|
698
|
+
writeSync(process.stderr.fd, "#1916 runtime node=" + process.version + " uv=" + process.versions.uv + " cacheEnabled=" + cacheEnabled + " pid=" + process.pid + "\\n");
|
|
699
|
+
} catch {}
|
|
700
|
+
return {
|
|
701
|
+
create(...args) { return factory.create(...args); },
|
|
702
|
+
async dispose() {
|
|
703
|
+
const call = ++invocation;
|
|
704
|
+
mark("dispose-entry", call);
|
|
705
|
+
try {
|
|
706
|
+
const result = await factory.dispose();
|
|
707
|
+
mark("dispose-return", call);
|
|
708
|
+
return result;
|
|
709
|
+
} catch (error) { mark("dispose-rejection", call); throw error; }
|
|
710
|
+
},
|
|
711
|
+
};
|
|
712
|
+
}
|
|
713
|
+
`);
|
|
714
|
+
const diagnostic = observeRunner(id, bodyStartedAt, disableCompileCache);
|
|
715
|
+
// Register before launch so even a throwing launch cannot escape teardown ownership.
|
|
716
|
+
ownedRunners.set(id, diagnostic);
|
|
717
|
+
try {
|
|
718
|
+
setChildSessionFactoryModule(factoryPath);
|
|
719
|
+
diagnostic.launch(() => executeAsyncSingle!(id, {
|
|
720
|
+
agent: "worker",
|
|
721
|
+
task: "Write the findings report.",
|
|
722
|
+
agentConfig: makeAgent("worker", { completionGuard: false }),
|
|
723
|
+
ctx: { pi: { events: { emit: diagnostic.emit } }, cwd: tempDir, currentSessionId: "session-file-report" },
|
|
724
|
+
artifactConfig,
|
|
725
|
+
artifactsDir: path.join(tempDir, ".pi-subagents", "artifacts"),
|
|
726
|
+
shareEnabled: false,
|
|
727
|
+
maxSubagentDepth: 2,
|
|
728
|
+
output: outputPath,
|
|
729
|
+
outputMode,
|
|
730
|
+
acceptance: { level: "checked", criteria: ["Report the findings"] },
|
|
731
|
+
}));
|
|
732
|
+
} finally {
|
|
733
|
+
// Launch captures the module path synchronously; restoring it does not release owned fixtures.
|
|
734
|
+
setChildSessionFactoryModule(originalFactoryModule);
|
|
735
|
+
}
|
|
422
736
|
}
|
|
423
737
|
|
|
424
738
|
it("file-only mode accepts from the child-written file when the text report fails", async () => {
|
|
425
739
|
const outputPath = path.join(tempDir, "async-report.md");
|
|
426
740
|
conflictingReportsCall(outputPath, "satisfied", "not-satisfied");
|
|
427
741
|
const id = `acceptance-file-report-${Date.now().toString(36)}`;
|
|
428
|
-
|
|
742
|
+
// One-variable control: only this launch disables Node's compile cache, not Jiti's transform cache.
|
|
743
|
+
runAsyncSingle(id, outputPath, "file-only", DISABLED_ARTIFACTS, true);
|
|
429
744
|
|
|
430
745
|
const payload = await waitForAsyncResult(id);
|
|
431
746
|
assert.equal(payload.success, true);
|
|
@@ -469,4 +784,4 @@ describe("acceptance file reports", { skip: !runSync ? "pi packages not availabl
|
|
|
469
784
|
assert.doesNotMatch(payload.results[0]?.output ?? "", /```acceptance-report/);
|
|
470
785
|
});
|
|
471
786
|
});
|
|
472
|
-
});
|
|
787
|
+
});
|