@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
|
@@ -0,0 +1,354 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import fs from "node:fs";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import { describe, it } from "node:test";
|
|
5
|
+
import { createResultWatcher } from "../../src/runs/background/result-watcher.ts";
|
|
6
|
+
import { createAsyncJobTracker } from "../../src/runs/background/async-job-tracker.ts";
|
|
7
|
+
import { SUBAGENT_ASYNC_COMPLETE_EVENT, type SubagentState } from "../../src/shared/types.ts";
|
|
8
|
+
import registerSubagentNotify from "../../src/runs/background/notify.ts";
|
|
9
|
+
import { makeAgent } from "../support/helpers.ts";
|
|
10
|
+
import {
|
|
11
|
+
installAsyncExecutionHooks, available, isAsyncAvailable, executeAsyncSingle, executeAsyncChain,
|
|
12
|
+
ASYNC_DIR, RESULTS_DIR, tempDir, mockPi,
|
|
13
|
+
} from "../support/async-execution-fixture.ts";
|
|
14
|
+
|
|
15
|
+
function fileBarrier(file: string): Promise<void> {
|
|
16
|
+
return new Promise((resolve, reject) => {
|
|
17
|
+
// libuv on Windows compares long event paths against this watch path; expand TEMP's 8.3 aliases.
|
|
18
|
+
const watcher = fs.watch(fs.realpathSync.native(path.dirname(file)), check);
|
|
19
|
+
const deadline = setTimeout(() => { watcher.close(); reject(new Error(`Missing barrier: ${file}`)); }, 15_000);
|
|
20
|
+
function check() {
|
|
21
|
+
if (!fs.existsSync(file)) return;
|
|
22
|
+
clearTimeout(deadline);
|
|
23
|
+
watcher.close();
|
|
24
|
+
resolve();
|
|
25
|
+
}
|
|
26
|
+
check();
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function publicationState(sessionId: string, owner: string): SubagentState {
|
|
31
|
+
return {
|
|
32
|
+
baseCwd: tempDir, currentSessionId: sessionId, completionOwnerId: owner,
|
|
33
|
+
asyncJobs: new Map(), foregroundControls: new Map(), lastForegroundControlId: null,
|
|
34
|
+
cleanupTimers: new Map(), lastUiContext: null, poller: null, completionSeen: new Map(),
|
|
35
|
+
watcher: null, watcherRestartTimer: null,
|
|
36
|
+
resultFileCoalescer: { schedule: () => false, clear() {} },
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
describe("native runner result publication", { skip: !available ? "pi packages unavailable" : undefined }, () => {
|
|
41
|
+
installAsyncExecutionHooks();
|
|
42
|
+
it("renews Darwin delivery after early native failure and deferred indexed publication", { timeout: 15_000, skip: !isAsyncAvailable() ? "jiti unavailable" : undefined }, async (t) => {
|
|
43
|
+
const root = path.join(tempDir, "early-terminal-barriers");
|
|
44
|
+
fs.mkdirSync(root);
|
|
45
|
+
fs.writeFileSync(path.join(root, "early-terminal"), "");
|
|
46
|
+
const id = "early-terminal-publication";
|
|
47
|
+
const sessionId = "publication-session";
|
|
48
|
+
const owner = "publication-owner";
|
|
49
|
+
const asyncDir = path.join(ASYNC_DIR, id);
|
|
50
|
+
const state = publicationState(sessionId, owner);
|
|
51
|
+
let delivered = 0;
|
|
52
|
+
let terminalRefreshes = 0;
|
|
53
|
+
let demandTick: (() => void) | undefined;
|
|
54
|
+
let trackerTick!: () => void;
|
|
55
|
+
let complete!: () => void;
|
|
56
|
+
const completion = new Promise<void>((resolve) => { complete = resolve; });
|
|
57
|
+
const pi = { events: { on: () => () => {}, emit(event: string) {
|
|
58
|
+
if (event === SUBAGENT_ASYNC_COMPLETE_EVENT) complete();
|
|
59
|
+
} }, sendMessage() { delivered++; } };
|
|
60
|
+
const notifier = registerSubagentNotify(pi, state, { batchConfig: { enabled: false } });
|
|
61
|
+
const watcher = createResultWatcher(pi, state, RESULTS_DIR, 60_000, {
|
|
62
|
+
platform: "darwin", coalesceDelayMs: 0, notifier,
|
|
63
|
+
// index.ts wiring: no foreground controls, scheduled observations or missions in this fixture.
|
|
64
|
+
hasDeliveryDemand: () => [...state.asyncJobs.values()].some((job) => job.status === "queued" || job.status === "running") || state.foregroundControls.size > 0,
|
|
65
|
+
timers: {
|
|
66
|
+
setTimeout, clearTimeout,
|
|
67
|
+
setInterval: ((handler: () => void, delay: number) => {
|
|
68
|
+
assert.equal(delay, 3000);
|
|
69
|
+
demandTick = handler;
|
|
70
|
+
return { unref() {} } as ReturnType<typeof setInterval>;
|
|
71
|
+
}) as typeof setInterval,
|
|
72
|
+
clearInterval: (() => { demandTick = undefined; }) as typeof clearInterval,
|
|
73
|
+
},
|
|
74
|
+
});
|
|
75
|
+
const tracker = createAsyncJobTracker(pi, state, ASYNC_DIR, {
|
|
76
|
+
platform: "darwin", resultsDir: RESULTS_DIR, widgetEnabled: false,
|
|
77
|
+
pollIntervalMs: 0, completionRetentionMs: 60_000,
|
|
78
|
+
onJobTerminal: () => { terminalRefreshes++; watcher.refreshResultDelivery(); },
|
|
79
|
+
});
|
|
80
|
+
const oldOptions = process.env.NODE_OPTIONS;
|
|
81
|
+
const oldRoot = process.env.RESULT_PUBLICATION_TEST_ROOT;
|
|
82
|
+
try {
|
|
83
|
+
process.env.NODE_OPTIONS = `${oldOptions ?? ""} --import=${new URL("../support/result-publication-capacity-preload.mjs", import.meta.url).href}`;
|
|
84
|
+
process.env.RESULT_PUBLICATION_TEST_ROOT = root;
|
|
85
|
+
mockPi.onCall({ output: "targets", structuredOutput: { items: [{ path: "a.ts" }, { path: "b.ts" }] } });
|
|
86
|
+
const receipt = executeAsyncChain(id, {
|
|
87
|
+
chain: [
|
|
88
|
+
{ agent: "producer", task: "Produce targets", as: "targets", outputSchema: { type: "object" } },
|
|
89
|
+
{
|
|
90
|
+
expand: { from: { output: "targets", path: "/items" }, item: "target", maxItems: 2 },
|
|
91
|
+
parallel: { agent: "reviewer", task: "Review {target.path}", output: "shared.md" },
|
|
92
|
+
collect: { as: "reviews" }, concurrency: 2,
|
|
93
|
+
},
|
|
94
|
+
],
|
|
95
|
+
agents: [makeAgent("producer", { completionGuard: false }), makeAgent("reviewer", { completionGuard: false })],
|
|
96
|
+
ctx: { pi: { events: { emit() {} } }, cwd: tempDir, currentSessionId: sessionId, completionOwnerId: owner },
|
|
97
|
+
artifactConfig: { enabled: false, includeInput: false, includeOutput: false, includeJsonl: false, includeMetadata: false, cleanupDays: 7 },
|
|
98
|
+
shareEnabled: false, maxSubagentDepth: 2, acceptance: false,
|
|
99
|
+
});
|
|
100
|
+
assert.notEqual(receipt.isError, true);
|
|
101
|
+
// Capture only the real tracker's liveness callback; execute it at explicit filesystem boundaries.
|
|
102
|
+
const intervalMock = t.mock.method(globalThis, "setInterval", ((handler: () => void) => {
|
|
103
|
+
trackerTick = handler;
|
|
104
|
+
return { unref() {} } as ReturnType<typeof setInterval>;
|
|
105
|
+
}) as typeof setInterval);
|
|
106
|
+
tracker.handleStarted({ id, asyncDir, sessionId, completionOwnerId: owner, mode: "chain" });
|
|
107
|
+
intervalMock.mock.restore();
|
|
108
|
+
watcher.startResultWatcher();
|
|
109
|
+
await fileBarrier(path.join(root, "blocked.json"));
|
|
110
|
+
await fileBarrier(path.join(root, "terminal.json"));
|
|
111
|
+
const early = JSON.parse(fs.readFileSync(path.join(asyncDir, "status.json"), "utf8"));
|
|
112
|
+
assert.equal(early.state, "failed", "early failure remains visible while publication is blocked");
|
|
113
|
+
assert.match(early.error, /materialized 2 items that resolve output to the same path/);
|
|
114
|
+
trackerTick();
|
|
115
|
+
assert.equal(state.asyncJobs.get(id)?.status, "failed");
|
|
116
|
+
assert.equal(terminalRefreshes, 1);
|
|
117
|
+
assert.equal(state.cleanupTimers.has(id), false, "retain the early terminal publisher beyond display retention");
|
|
118
|
+
assert.ok(demandTick);
|
|
119
|
+
demandTick(); // Real Darwin scan-before-stop callback, not elapsed silence.
|
|
120
|
+
assert.equal(demandTick, undefined);
|
|
121
|
+
assert.equal(delivered, 0);
|
|
122
|
+
assert.equal(fs.existsSync(path.join(RESULTS_DIR, "result-index", "sessions", sessionId, `${id}.json`)), false);
|
|
123
|
+
fs.writeFileSync(path.join(root, "release"), "");
|
|
124
|
+
await fileBarrier(path.join(root, "drained.json"));
|
|
125
|
+
const index = JSON.parse(fs.readFileSync(path.join(RESULTS_DIR, "result-index", "sessions", sessionId, `${id}.json`), "utf8"));
|
|
126
|
+
assert.equal(index.runId, id, "deferred publication committed its session index");
|
|
127
|
+
const publicPath = path.join(RESULTS_DIR, `${id}.json`);
|
|
128
|
+
const publishedPath = fs.existsSync(publicPath) ? publicPath : path.join(RESULTS_DIR, "result-pending", sessionId, `${id}.json`);
|
|
129
|
+
const published = JSON.parse(fs.readFileSync(publishedPath, "utf8"));
|
|
130
|
+
assert.equal(published.completionOwnerId, owner);
|
|
131
|
+
assert.equal(published.success, false);
|
|
132
|
+
assert.equal(mockPi.callCount(), 1, "dynamic failure occurs before reviewer children start");
|
|
133
|
+
trackerTick(); // Final failed-to-failed refresh through the actual tracker.
|
|
134
|
+
assert.equal(state.asyncJobs.get(id)?.status, "failed");
|
|
135
|
+
assert.equal(terminalRefreshes, 2, "settled publication renews delivery exactly once");
|
|
136
|
+
await completion;
|
|
137
|
+
assert.equal(delivered, 1, "actual notifier send, without an injected result refresh");
|
|
138
|
+
trackerTick();
|
|
139
|
+
assert.equal(terminalRefreshes, 2);
|
|
140
|
+
assert.equal(state.cleanupTimers.has(id), true, "settlement retires the publication obligation");
|
|
141
|
+
assert.equal(state.watcher, null, "Darwin has no native result watcher");
|
|
142
|
+
assert.equal(demandTick, undefined);
|
|
143
|
+
assert.equal(state.watcherRestartTimer, null);
|
|
144
|
+
} finally {
|
|
145
|
+
fs.writeFileSync(path.join(root, "release"), "");
|
|
146
|
+
tracker.resetJobs();
|
|
147
|
+
watcher.stopResultWatcher();
|
|
148
|
+
notifier.dispose();
|
|
149
|
+
if (oldOptions === undefined) delete process.env.NODE_OPTIONS; else process.env.NODE_OPTIONS = oldOptions;
|
|
150
|
+
if (oldRoot === undefined) delete process.env.RESULT_PUBLICATION_TEST_ROOT; else process.env.RESULT_PUBLICATION_TEST_ROOT = oldRoot;
|
|
151
|
+
}
|
|
152
|
+
});
|
|
153
|
+
for (const terminal of ["failed", "stopped"] as const) {
|
|
154
|
+
it(`keeps consumed ${terminal} publication settled before the first terminal refresh`, (t) => {
|
|
155
|
+
const id = `consumed-${terminal}`;
|
|
156
|
+
const asyncDir = path.join(ASYNC_DIR, id);
|
|
157
|
+
fs.mkdirSync(asyncDir, { recursive: true });
|
|
158
|
+
const state = publicationState("session", "owner");
|
|
159
|
+
fs.writeFileSync(path.join(asyncDir, "status.json"), JSON.stringify({
|
|
160
|
+
runId: id, sessionId: "session", completionOwnerId: "owner", mode: "single",
|
|
161
|
+
state: terminal, startedAt: Date.now(), steps: [],
|
|
162
|
+
processTerminal: { version: 1, state: "pending", runId: id, runnerProcessInstanceId: "instance" },
|
|
163
|
+
}));
|
|
164
|
+
let tick!: () => void;
|
|
165
|
+
let refreshes = 0;
|
|
166
|
+
const tracker = createAsyncJobTracker({ events: { emit() {} } }, state, ASYNC_DIR, {
|
|
167
|
+
platform: "darwin", widgetEnabled: false, resultsDir: RESULTS_DIR, pollIntervalMs: 0,
|
|
168
|
+
onJobTerminal: () => { refreshes++; },
|
|
169
|
+
});
|
|
170
|
+
const interval = t.mock.method(globalThis, "setInterval", ((handler: () => void) => {
|
|
171
|
+
tick = handler;
|
|
172
|
+
return { unref() {} } as ReturnType<typeof setInterval>;
|
|
173
|
+
}) as typeof setInterval);
|
|
174
|
+
try {
|
|
175
|
+
tracker.handleStarted({ id, asyncDir, sessionId: "session", completionOwnerId: "owner" });
|
|
176
|
+
interval.mock.restore();
|
|
177
|
+
// The result watcher has consumed the payload before status polling.
|
|
178
|
+
tracker.handleComplete({ id, sessionId: "session", state: terminal, success: false });
|
|
179
|
+
const cleanup = state.cleanupTimers.get(id);
|
|
180
|
+
assert.ok(cleanup);
|
|
181
|
+
tick();
|
|
182
|
+
tick();
|
|
183
|
+
assert.equal(state.asyncJobs.get(id)?.status, terminal);
|
|
184
|
+
assert.equal(state.cleanupTimers.get(id), cleanup, "consumed publication must not reopen or replace cleanup");
|
|
185
|
+
assert.equal(refreshes, 0, "consumed publication needs no delivery renewal");
|
|
186
|
+
} finally {
|
|
187
|
+
tracker.resetJobs();
|
|
188
|
+
}
|
|
189
|
+
});
|
|
190
|
+
it(`retires an early ${terminal} publisher on identity-proven close or reset`, (t) => {
|
|
191
|
+
const id = `closed-${terminal}`;
|
|
192
|
+
const asyncDir = path.join(ASYNC_DIR, id);
|
|
193
|
+
fs.mkdirSync(asyncDir);
|
|
194
|
+
const state = publicationState("session", "owner");
|
|
195
|
+
const proof = { version: 1, state: "pending", runId: id, runnerProcessInstanceId: "instance" };
|
|
196
|
+
fs.writeFileSync(path.join(asyncDir, "status.json"), JSON.stringify({
|
|
197
|
+
runId: id, sessionId: "session", completionOwnerId: "owner", mode: "single",
|
|
198
|
+
state: terminal, startedAt: Date.now(), steps: [], processTerminal: proof,
|
|
199
|
+
}));
|
|
200
|
+
let tick!: () => void;
|
|
201
|
+
let refreshes = 0;
|
|
202
|
+
const tracker = createAsyncJobTracker({ events: { emit() {} } }, state, ASYNC_DIR, {
|
|
203
|
+
platform: "darwin", widgetEnabled: false, resultsDir: RESULTS_DIR, pollIntervalMs: 0,
|
|
204
|
+
onJobTerminal: () => { refreshes++; },
|
|
205
|
+
});
|
|
206
|
+
const interval = t.mock.method(globalThis, "setInterval", ((handler: () => void) => {
|
|
207
|
+
tick = handler;
|
|
208
|
+
return { unref() {} } as ReturnType<typeof setInterval>;
|
|
209
|
+
}) as typeof setInterval);
|
|
210
|
+
try {
|
|
211
|
+
tracker.handleStarted({ id, asyncDir, sessionId: "session", completionOwnerId: "owner" });
|
|
212
|
+
interval.mock.restore();
|
|
213
|
+
tick();
|
|
214
|
+
assert.equal(state.asyncJobs.get(id)?.status, terminal);
|
|
215
|
+
assert.equal(state.cleanupTimers.has(id), false);
|
|
216
|
+
const closed = { ...proof, state: "observed", observedAt: Date.now(), instances: [{
|
|
217
|
+
kind: "runner", processInstanceId: "instance", closeObservedAt: Date.now(), exitCode: 1, signal: null,
|
|
218
|
+
}] };
|
|
219
|
+
fs.writeFileSync(path.join(asyncDir, "process-terminal.json"), JSON.stringify({ ...closed, runnerProcessInstanceId: "other" }));
|
|
220
|
+
tick();
|
|
221
|
+
assert.equal(state.cleanupTimers.has(id), false, "foreign/unknown process proof cannot discharge publication");
|
|
222
|
+
assert.equal(refreshes, 1);
|
|
223
|
+
if (terminal === "failed") {
|
|
224
|
+
fs.writeFileSync(path.join(asyncDir, "process-terminal.json"), JSON.stringify(closed));
|
|
225
|
+
tick();
|
|
226
|
+
assert.equal(state.cleanupTimers.has(id), true, "definitive publisher failure needs no further observation");
|
|
227
|
+
assert.equal(refreshes, 2, "close supplies a final scan for publication racing the proof read");
|
|
228
|
+
tick();
|
|
229
|
+
assert.equal(refreshes, 2);
|
|
230
|
+
}
|
|
231
|
+
} finally {
|
|
232
|
+
tracker.resetJobs();
|
|
233
|
+
}
|
|
234
|
+
assert.equal(state.poller, null);
|
|
235
|
+
assert.equal(state.asyncJobs.size, 0);
|
|
236
|
+
assert.equal(state.cleanupTimers.size, 0);
|
|
237
|
+
});
|
|
238
|
+
}
|
|
239
|
+
it("watches the canonical barrier directory through a path alias", async (t) => {
|
|
240
|
+
const directory = path.join(tempDir, "barrier-directory");
|
|
241
|
+
const alias = path.join(tempDir, "barrier-alias");
|
|
242
|
+
fs.mkdirSync(directory);
|
|
243
|
+
fs.symlinkSync(directory, alias, "junction");
|
|
244
|
+
const watch = fs.watch;
|
|
245
|
+
t.mock.method(fs, "watch", ((watched, ...args) => {
|
|
246
|
+
assert.equal(watched, fs.realpathSync.native(directory));
|
|
247
|
+
return Reflect.apply(watch, fs, [watched, ...args]);
|
|
248
|
+
}) as typeof fs.watch);
|
|
249
|
+
const file = path.join(alias, "ready");
|
|
250
|
+
const ready = fileBarrier(file);
|
|
251
|
+
fs.writeFileSync(file, "");
|
|
252
|
+
await ready;
|
|
253
|
+
});
|
|
254
|
+
for (const outcome of ["recovered", "retry-error"] as const) {
|
|
255
|
+
it(`keeps Darwin delivery demand until deferred indexed final result publication settles (${outcome})`, { skip: !isAsyncAvailable() ? "jiti unavailable" : undefined }, async () => {
|
|
256
|
+
const root = path.join(tempDir, "publication-barriers");
|
|
257
|
+
fs.mkdirSync(root);
|
|
258
|
+
if (outcome === "retry-error") fs.writeFileSync(path.join(root, "fail-on-recovery"), "");
|
|
259
|
+
const id = "publication-capacity";
|
|
260
|
+
const sessionId = "publication-session";
|
|
261
|
+
const owner = "publication-owner";
|
|
262
|
+
const asyncDir = path.join(ASYNC_DIR, id);
|
|
263
|
+
const resultPath = path.join(RESULTS_DIR, `${id}.json`);
|
|
264
|
+
const state = publicationState(sessionId, owner);
|
|
265
|
+
let poll: ReturnType<typeof setInterval> | undefined;
|
|
266
|
+
let delivered = 0;
|
|
267
|
+
let complete!: () => void;
|
|
268
|
+
let deliveryDeadline: ReturnType<typeof setTimeout> | undefined;
|
|
269
|
+
const completion = new Promise<void>((resolve) => { complete = resolve; });
|
|
270
|
+
const pi = {
|
|
271
|
+
events: { on: () => () => {}, emit(event: string, data: unknown) {
|
|
272
|
+
if (event !== SUBAGENT_ASYNC_COMPLETE_EVENT) return;
|
|
273
|
+
assert.equal((data as { completionOwnerId?: string }).completionOwnerId, owner);
|
|
274
|
+
complete();
|
|
275
|
+
} },
|
|
276
|
+
sendMessage() { delivered++; },
|
|
277
|
+
};
|
|
278
|
+
const notifier = registerSubagentNotify(pi, state, { batchConfig: { enabled: false } });
|
|
279
|
+
const watcher = createResultWatcher(pi, state, RESULTS_DIR, 60_000, {
|
|
280
|
+
platform: "darwin", coalesceDelayMs: 0,
|
|
281
|
+
hasDeliveryDemand: () => {
|
|
282
|
+
const statusPath = path.join(asyncDir, "status.json");
|
|
283
|
+
if (!fs.existsSync(statusPath)) return true;
|
|
284
|
+
const status = JSON.parse(fs.readFileSync(statusPath, "utf8"));
|
|
285
|
+
return status.state === "running" || status.state === "queued";
|
|
286
|
+
},
|
|
287
|
+
notifier,
|
|
288
|
+
timers: {
|
|
289
|
+
setTimeout, clearTimeout,
|
|
290
|
+
setInterval: ((handler: () => void, delay: number) => {
|
|
291
|
+
assert.equal(delay, 3000);
|
|
292
|
+
poll = setInterval(() => {
|
|
293
|
+
handler();
|
|
294
|
+
if (fs.existsSync(path.join(root, "blocked.json"))) fs.writeFileSync(path.join(root, "polled"), "");
|
|
295
|
+
}, delay);
|
|
296
|
+
return poll;
|
|
297
|
+
}) as typeof setInterval,
|
|
298
|
+
clearInterval: ((handle: ReturnType<typeof setInterval>) => { clearInterval(handle); poll = undefined; }) as typeof clearInterval,
|
|
299
|
+
},
|
|
300
|
+
});
|
|
301
|
+
const oldOptions = process.env.NODE_OPTIONS;
|
|
302
|
+
const oldRoot = process.env.RESULT_PUBLICATION_TEST_ROOT;
|
|
303
|
+
try {
|
|
304
|
+
process.env.NODE_OPTIONS = `${oldOptions ?? ""} --import=${new URL("../support/result-publication-capacity-preload.mjs", import.meta.url).href}`;
|
|
305
|
+
process.env.RESULT_PUBLICATION_TEST_ROOT = root;
|
|
306
|
+
mockPi.onCall({ output: "Indexed completion after capacity recovery" });
|
|
307
|
+
const receipt = executeAsyncSingle(id, {
|
|
308
|
+
agent: "worker", task: "Complete without a provider", agentConfig: makeAgent("worker", { completionGuard: false }),
|
|
309
|
+
ctx: { pi: { events: { emit() {} } }, cwd: tempDir, currentSessionId: sessionId, completionOwnerId: owner },
|
|
310
|
+
artifactConfig: { enabled: false, includeInput: false, includeOutput: false, includeJsonl: false, includeMetadata: false, cleanupDays: 7 },
|
|
311
|
+
shareEnabled: false, sessionRoot: path.join(tempDir, "sessions"), maxSubagentDepth: 2, acceptance: false,
|
|
312
|
+
});
|
|
313
|
+
assert.notEqual(receipt.isError, true);
|
|
314
|
+
watcher.startResultWatcher();
|
|
315
|
+
await fileBarrier(path.join(root, "blocked.json"));
|
|
316
|
+
const blocked = JSON.parse(fs.readFileSync(path.join(root, "blocked.json"), "utf8"));
|
|
317
|
+
assert.equal(blocked.statusDeferred, true, "exercise an older deferred status write too");
|
|
318
|
+
await fileBarrier(path.join(root, "polled")); // A real demand-interval tick while capacity is held.
|
|
319
|
+
assert.equal(blocked.state, "running", "terminal status must not precede indexed final result publication");
|
|
320
|
+
assert.equal(blocked.active, true, "older status retry must not remove the active index");
|
|
321
|
+
const events = fs.readFileSync(path.join(asyncDir, "events.jsonl"), "utf8").trim().split("\n").map((line) => JSON.parse(line));
|
|
322
|
+
assert.ok(events.some((event) => event.type === "subagent.steer.failed" && event.requestId === "publication-steer"), "exercise incidental status writing during finalization");
|
|
323
|
+
assert.ok(poll, "the demand interval must remain installed before recovery");
|
|
324
|
+
assert.equal(fs.existsSync(resultPath), false);
|
|
325
|
+
assert.equal(delivered, 0);
|
|
326
|
+
fs.writeFileSync(path.join(root, "release"), "");
|
|
327
|
+
await fileBarrier(path.join(root, "terminal.json"));
|
|
328
|
+
const terminal = JSON.parse(fs.readFileSync(path.join(root, "terminal.json"), "utf8"));
|
|
329
|
+
assert.equal(terminal.state, outcome === "recovered" ? "complete" : "failed");
|
|
330
|
+
if (outcome === "retry-error") assert.match(terminal.error, /injected non-capacity publication failure/);
|
|
331
|
+
const publishedPath = outcome === "recovered" ? resultPath : path.join(RESULTS_DIR, "result-pending", sessionId, `${id}.json`);
|
|
332
|
+
// An automatic tick may already have accepted and cleaned the indexed result.
|
|
333
|
+
assert.ok(fs.existsSync(publishedPath) || delivered === 1, "terminal result must be published or already delivered");
|
|
334
|
+
if (fs.existsSync(publishedPath)) assert.equal(JSON.parse(fs.readFileSync(publishedPath, "utf8")).completionOwnerId, owner);
|
|
335
|
+
await Promise.race([completion, new Promise((_, reject) => {
|
|
336
|
+
deliveryDeadline = setTimeout(() => reject(new Error("completion not delivered")), 5000);
|
|
337
|
+
})]);
|
|
338
|
+
clearTimeout(deliveryDeadline);
|
|
339
|
+
assert.equal(delivered, 1);
|
|
340
|
+
assert.equal(fs.existsSync(resultPath), false);
|
|
341
|
+
assert.equal(poll, undefined);
|
|
342
|
+
assert.equal(state.watcherRestartTimer, null);
|
|
343
|
+
await fileBarrier(path.join(asyncDir, "process-terminal-candidate.json"));
|
|
344
|
+
} finally {
|
|
345
|
+
clearTimeout(deliveryDeadline);
|
|
346
|
+
fs.writeFileSync(path.join(root, "release"), "");
|
|
347
|
+
watcher.stopResultWatcher();
|
|
348
|
+
notifier.dispose();
|
|
349
|
+
if (oldOptions === undefined) delete process.env.NODE_OPTIONS; else process.env.NODE_OPTIONS = oldOptions;
|
|
350
|
+
if (oldRoot === undefined) delete process.env.RESULT_PUBLICATION_TEST_ROOT; else process.env.RESULT_PUBLICATION_TEST_ROOT = oldRoot;
|
|
351
|
+
}
|
|
352
|
+
});
|
|
353
|
+
}
|
|
354
|
+
});
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import { ChildProcess } from "node:child_process";
|
|
3
|
+
import { channel } from "node:diagnostics_channel";
|
|
4
|
+
import * as fs from "node:fs";
|
|
5
|
+
import * as os from "node:os";
|
|
6
|
+
import * as path from "node:path";
|
|
7
|
+
import { test } from "node:test";
|
|
8
|
+
import { ASYNC_DIR, RESULTS_DIR, observeSharedCwdRunner } from "../support/async-execution-fixture.ts";
|
|
9
|
+
|
|
10
|
+
// Synthetic lifecycle only: no runner, providers, polling, or Windows control.
|
|
11
|
+
test("shared-cwd failure artifact preserves correlated allowlisted lifecycle once", () => {
|
|
12
|
+
const root = fs.mkdtempSync(path.join(os.tmpdir(), "terminal-evidence-"));
|
|
13
|
+
const previous = process.env.SELESAI_SUBAGENTS_TERMINAL_EVIDENCE_DIR;
|
|
14
|
+
process.env.SELESAI_SUBAGENTS_TERMINAL_EVIDENCE_DIR = path.join(root, "artifacts");
|
|
15
|
+
const id = `terminal-evidence-${process.pid}`;
|
|
16
|
+
const runDir = path.join(ASYNC_DIR, id);
|
|
17
|
+
const resultFile = path.join(RESULTS_DIR, `${id}.json`);
|
|
18
|
+
const observer = observeSharedCwdRunner(id);
|
|
19
|
+
const secret = "DO_NOT_PERSIST_TASK_RESULT_OR_SECRET";
|
|
20
|
+
try {
|
|
21
|
+
fs.mkdirSync(runDir, { recursive: true });
|
|
22
|
+
fs.mkdirSync(RESULTS_DIR, { recursive: true });
|
|
23
|
+
const proc = new ChildProcess();
|
|
24
|
+
proc.pid = process.pid;
|
|
25
|
+
observer.launch(() => {
|
|
26
|
+
channel("child_process").publish({ process: proc });
|
|
27
|
+
observer.emit("subagent:async-started", { id, pid: proc.pid, task: secret });
|
|
28
|
+
proc.emit("spawn");
|
|
29
|
+
proc.emit("exit", 0, null);
|
|
30
|
+
proc.emit("close", 0, null);
|
|
31
|
+
return { content: [], isError: false, details: { asyncId: id } };
|
|
32
|
+
});
|
|
33
|
+
const proof = { runId: id, runnerProcessInstanceId: "instance-1906", state: "pending", task: secret };
|
|
34
|
+
fs.writeFileSync(path.join(runDir, "process-terminal.json"), JSON.stringify(proof));
|
|
35
|
+
fs.writeFileSync(path.join(runDir, "process-terminal-candidate.json"), JSON.stringify({ ...proof, writers: { "0": [], "1": [] }, expectedWriters: { "0": 0, "1": 0 } }));
|
|
36
|
+
fs.writeFileSync(path.join(runDir, "status.json"), JSON.stringify({ ...proof, state: "complete", result: secret }));
|
|
37
|
+
fs.writeFileSync(resultFile, JSON.stringify({ runId: id, output: secret }));
|
|
38
|
+
fs.writeFileSync(path.join(runDir, "events.jsonl"), JSON.stringify({ ...proof, type: "subagent.run.completed", output: secret }) + "\n");
|
|
39
|
+
fs.writeFileSync(path.join(runDir, "runner.stderr.log"), `${secret}\n#1906 phase=dispose-return invocation=2 ts=123 pid=${proc.pid}\n#1906 phase=exit invocation=0 ts=124 pid=${proc.pid}\n#1906 phase=exit invocation=0 ts=124 pid=${proc.pid + 1}\n`);
|
|
40
|
+
fs.writeFileSync(path.join(runDir, "runner.stdout.log"), secret);
|
|
41
|
+
observer.marks.waitStartedAt = Date.now();
|
|
42
|
+
const diagnostics: string[] = [];
|
|
43
|
+
observer.reportFailure((message) => diagnostics.push(message));
|
|
44
|
+
const artifact = path.join(root, "artifacts", "shared-cwd-terminal.json");
|
|
45
|
+
const text = fs.readFileSync(artifact, "utf8");
|
|
46
|
+
assert.ok(Buffer.byteLength(text) <= 65536);
|
|
47
|
+
assert.equal(text.includes(secret), false);
|
|
48
|
+
assert.equal(diagnostics[0], `#1906 ${text}`);
|
|
49
|
+
const evidence = JSON.parse(text);
|
|
50
|
+
assert.equal(evidence.pid, process.pid);
|
|
51
|
+
assert.equal(evidence.correlatedProcesses, 1);
|
|
52
|
+
assert.deepEqual(evidence.processEvents[0].map((event: { type: string }) => event.type), ["spawn", "exit", "close"]);
|
|
53
|
+
const files = evidence.snapshot.files;
|
|
54
|
+
assert.equal(files.find((file: { name: string }) => file.name === "status.json").state, "complete");
|
|
55
|
+
assert.equal(files.find((file: { name: string }) => file.name === "process-terminal.json").runnerProcessInstanceId, "instance-1906");
|
|
56
|
+
assert.deepEqual(files.find((file: { name: string }) => file.name === "process-terminal-candidate.json").writers, [{ index: "0", count: 0, expected: 0 }, { index: "1", count: 0, expected: 0 }]);
|
|
57
|
+
const journal = files.find((file: { name: string }) => file.name === "events.jsonl");
|
|
58
|
+
assert.equal(journal.terminalPresentInRead, false);
|
|
59
|
+
assert.equal(journal.parseErrors, 0);
|
|
60
|
+
assert.equal(journal.lifecycle[0].type, "subagent.run.completed");
|
|
61
|
+
assert.deepEqual(files.find((file: { name: string }) => file.name === "runner.stderr.log").phases, [
|
|
62
|
+
{ phase: "dispose-return", invocation: 2, ts: 123, pid: process.pid },
|
|
63
|
+
{ phase: "exit", invocation: 0, ts: 124, pid: process.pid },
|
|
64
|
+
]);
|
|
65
|
+
fs.rmSync(runDir, { recursive: true, force: true });
|
|
66
|
+
fs.rmSync(resultFile, { force: true });
|
|
67
|
+
observer.snapshot = () => { throw new Error("must not capture again"); };
|
|
68
|
+
observer.reportFailure((message) => diagnostics.push(message));
|
|
69
|
+
assert.equal(diagnostics.length, 1);
|
|
70
|
+
assert.equal(fs.readFileSync(artifact, "utf8"), text, "artifact survives fixture cleanup");
|
|
71
|
+
assert.deepEqual(fs.readdirSync(path.dirname(artifact)), ["shared-cwd-terminal.json"]);
|
|
72
|
+
} finally {
|
|
73
|
+
observer.dispose();
|
|
74
|
+
if (previous === undefined) delete process.env.SELESAI_SUBAGENTS_TERMINAL_EVIDENCE_DIR;
|
|
75
|
+
else process.env.SELESAI_SUBAGENTS_TERMINAL_EVIDENCE_DIR = previous;
|
|
76
|
+
fs.rmSync(runDir, { recursive: true, force: true });
|
|
77
|
+
fs.rmSync(resultFile, { force: true });
|
|
78
|
+
fs.rmSync(root, { recursive: true, force: true });
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
test("shared-cwd evidence is failure-only and write errors retain safe log evidence", () => {
|
|
83
|
+
const root = fs.mkdtempSync(path.join(os.tmpdir(), "terminal-evidence-"));
|
|
84
|
+
const previous = process.env.SELESAI_SUBAGENTS_TERMINAL_EVIDENCE_DIR;
|
|
85
|
+
const destination = path.join(root, "artifacts");
|
|
86
|
+
process.env.SELESAI_SUBAGENTS_TERMINAL_EVIDENCE_DIR = destination;
|
|
87
|
+
const observer = observeSharedCwdRunner("terminal-evidence-no-run");
|
|
88
|
+
try {
|
|
89
|
+
observer.snapshot = () => { throw new Error("raw secret error"); };
|
|
90
|
+
observer.summary();
|
|
91
|
+
observer.dispose();
|
|
92
|
+
assert.equal(fs.existsSync(destination), false, "success does not create artifacts or snapshot");
|
|
93
|
+
const diagnostics: string[] = [];
|
|
94
|
+
observer.reportFailure((message) => diagnostics.push(message));
|
|
95
|
+
assert.deepEqual(diagnostics, ["#1906 failure snapshot unavailable (contents withheld)"]);
|
|
96
|
+
assert.equal(fs.existsSync(destination), false);
|
|
97
|
+
|
|
98
|
+
fs.writeFileSync(destination, "not a directory");
|
|
99
|
+
const failedWrite = observeSharedCwdRunner("terminal-evidence-no-run");
|
|
100
|
+
failedWrite.reportFailure((message) => diagnostics.push(message));
|
|
101
|
+
assert.match(diagnostics[1]!, /^#1906 \{"id":"terminal-evidence-no-run"/);
|
|
102
|
+
assert.equal(diagnostics[2], "#1906 failure artifact unavailable (contents withheld)");
|
|
103
|
+
assert.equal(diagnostics.join("\n").includes("raw secret error"), false);
|
|
104
|
+
failedWrite.dispose();
|
|
105
|
+
|
|
106
|
+
delete process.env.SELESAI_SUBAGENTS_TERMINAL_EVIDENCE_DIR;
|
|
107
|
+
const logOnly = observeSharedCwdRunner("terminal-evidence-no-run");
|
|
108
|
+
logOnly.reportFailure((message) => diagnostics.push(message));
|
|
109
|
+
assert.equal(diagnostics.length, 4, "unconfigured local failures remain log-only");
|
|
110
|
+
logOnly.dispose();
|
|
111
|
+
} finally {
|
|
112
|
+
observer.dispose();
|
|
113
|
+
if (previous === undefined) delete process.env.SELESAI_SUBAGENTS_TERMINAL_EVIDENCE_DIR;
|
|
114
|
+
else process.env.SELESAI_SUBAGENTS_TERMINAL_EVIDENCE_DIR = previous;
|
|
115
|
+
fs.rmSync(root, { recursive: true, force: true });
|
|
116
|
+
}
|
|
117
|
+
});
|