aiwcli 0.15.7 → 0.17.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +106 -1125
- package/bin/run.js +0 -4
- package/dist/capabilities/installation/control-plane/clear-command.d.ts +2 -0
- package/dist/capabilities/installation/control-plane/clear-command.js +32 -3
- package/dist/capabilities/installation/control-plane/init-command.js +2 -2
- package/dist/capabilities/launch/contracts.d.ts +39 -4
- package/dist/capabilities/launch/control-plane/execute-launch.js +158 -119
- package/dist/capabilities/launch/runtime-core/launch-decisions.d.ts +82 -0
- package/dist/capabilities/launch/runtime-core/launch-decisions.js +202 -0
- package/dist/commands/branch.d.ts +1 -1
- package/dist/commands/branch.js +1 -1
- package/dist/commands/launch.d.ts +0 -5
- package/dist/commands/launch.js +2 -37
- package/dist/lib/config.js +1 -2
- package/dist/lib/context/context-store.js +28 -2
- package/dist/lib/core-installer.d.ts +1 -1
- package/dist/lib/core-installer.js +6 -27
- package/dist/lib/debug.d.ts +0 -10
- package/dist/lib/debug.js +0 -10
- package/dist/lib/env-sanitizer.d.ts +25 -0
- package/dist/lib/env-sanitizer.js +46 -0
- package/dist/lib/errors.d.ts +0 -13
- package/dist/lib/errors.js +0 -15
- package/dist/lib/git-exclude-manager.js +1 -1
- package/dist/lib/hooks/context-monitor-logic.d.ts +6 -0
- package/dist/lib/hooks/context-monitor-logic.js +25 -0
- package/dist/lib/hooks/hook-utils.js +11 -0
- package/dist/lib/hooks/prompt-binding-logic.d.ts +7 -0
- package/dist/lib/hooks/prompt-binding-logic.js +50 -0
- package/dist/lib/hooks/session-end-logic.js +2 -14
- package/dist/lib/install-state.js +6 -13
- package/dist/lib/json-io.d.ts +12 -0
- package/dist/lib/json-io.js +30 -0
- package/dist/lib/multiplexer.d.ts +43 -35
- package/dist/lib/multiplexer.js +21 -2
- package/dist/lib/multiplexers/psmux.d.ts +14 -34
- package/dist/lib/multiplexers/psmux.js +70 -130
- package/dist/lib/multiplexers/tmux.d.ts +11 -19
- package/dist/lib/multiplexers/tmux.js +79 -120
- package/dist/lib/multiplexers/wezterm.d.ts +38 -0
- package/dist/lib/multiplexers/wezterm.js +225 -0
- package/dist/lib/mux-utils.d.ts +4 -3
- package/dist/lib/mux-utils.js +7 -13
- package/dist/lib/prompt-file-manager.d.ts +23 -0
- package/dist/lib/prompt-file-manager.js +41 -0
- package/dist/lib/runtime/agent-launcher.d.ts +67 -0
- package/dist/lib/runtime/agent-launcher.js +262 -0
- package/dist/lib/runtime/aiw-cli.d.ts +2 -0
- package/dist/lib/runtime/aiw-cli.js +3 -1
- package/dist/lib/runtime/cli-args.d.ts +5 -2
- package/dist/lib/runtime/cli-args.js +18 -3
- package/dist/lib/runtime/inference.js +3 -14
- package/dist/lib/runtime/models.d.ts +6 -0
- package/dist/lib/runtime/models.js +6 -0
- package/dist/lib/runtime/state-io.d.ts +2 -1
- package/dist/lib/runtime/state-io.js +9 -4
- package/dist/lib/runtime/utils.d.ts +8 -0
- package/dist/lib/runtime/utils.js +31 -1
- package/dist/lib/schemas.d.ts +250 -0
- package/dist/lib/schemas.js +216 -0
- package/dist/lib/sentinel-manager.d.ts +32 -0
- package/dist/lib/sentinel-manager.js +62 -0
- package/dist/lib/sentinel-wrapper.d.ts +1 -0
- package/dist/lib/sentinel-wrapper.js +12 -3
- package/dist/lib/settings-hierarchy.js +3 -20
- package/dist/lib/shell-adapters/bash-adapter.d.ts +18 -0
- package/dist/lib/shell-adapters/bash-adapter.js +69 -0
- package/dist/lib/shell-adapters/index.d.ts +5 -0
- package/dist/lib/shell-adapters/index.js +7 -0
- package/dist/lib/shell-adapters/powershell-adapter.d.ts +18 -0
- package/dist/lib/shell-adapters/powershell-adapter.js +62 -0
- package/dist/lib/shell-adapters/shell-adapter.d.ts +45 -0
- package/dist/lib/shell-adapters/shell-adapter.js +5 -0
- package/dist/lib/spawn-errors.d.ts +3 -0
- package/dist/lib/spawn-errors.js +15 -1
- package/dist/lib/spinner.d.ts +0 -5
- package/dist/lib/spinner.js +0 -16
- package/dist/lib/template-installer.d.ts +10 -0
- package/dist/lib/template-installer.js +4 -4
- package/dist/lib/terminal-strategy.d.ts +1 -0
- package/dist/lib/terminal-strategy.js +12 -6
- package/dist/lib/terminal.d.ts +7 -5
- package/dist/lib/terminal.js +42 -19
- package/dist/lib/tmux-primitives.d.ts +0 -2
- package/dist/lib/tmux-primitives.js +0 -4
- package/dist/lib/tmux-session.js +2 -1
- package/dist/lib/windsurf-hooks-hierarchy.js +6 -23
- package/dist/platform/launch.d.ts +2 -1
- package/dist/platform/launch.js +1 -0
- package/dist/templates/CLAUDE.md +0 -1
- package/dist/templates/cc-native/.claude/settings.json +0 -10
- package/dist/templates/cc-native/TEMPLATE-SCHEMA.md +11 -4
- package/dist/templates/cc-native/_cc-native/cc-native.config.json +3 -7
- package/dist/templates/cc-native/_cc-native/hooks/CLAUDE.md +26 -47
- package/dist/templates/cc-native/_cc-native/hooks/cc-native-plan-review.ts +7 -9
- package/dist/templates/cc-native/_cc-native/hooks/enhance_plan_post_write.ts +2 -3
- package/dist/templates/cc-native/_cc-native/hooks/mark_questions_asked.ts +2 -2
- package/dist/templates/cc-native/_cc-native/hooks/plan_questions_early.ts +0 -25
- package/dist/templates/cc-native/_cc-native/hooks/validate_task_prompt.ts +4 -4
- package/dist/templates/cc-native/_cc-native/lib-ts/.mocharc.json +9 -0
- package/dist/templates/cc-native/_cc-native/lib-ts/__tests__/aggregate-agents.test.ts +118 -0
- package/dist/templates/cc-native/_cc-native/lib-ts/__tests__/artifacts.test.ts +234 -0
- package/dist/templates/cc-native/_cc-native/lib-ts/__tests__/cc-native-state.test.ts +170 -0
- package/dist/templates/cc-native/_cc-native/lib-ts/__tests__/cli-output-parser.test.ts +73 -0
- package/dist/templates/cc-native/_cc-native/lib-ts/__tests__/config.test.ts +64 -0
- package/dist/templates/cc-native/_cc-native/lib-ts/__tests__/constants.test.ts +40 -0
- package/dist/templates/cc-native/_cc-native/lib-ts/__tests__/debug.test.ts +42 -0
- package/dist/templates/cc-native/_cc-native/lib-ts/__tests__/exports.test.ts +58 -0
- package/dist/templates/cc-native/_cc-native/lib-ts/__tests__/helpers.ts +107 -0
- package/dist/templates/cc-native/_cc-native/lib-ts/__tests__/hooks/add-plan-context.hook.test.ts +97 -0
- package/dist/templates/cc-native/_cc-native/lib-ts/__tests__/hooks/plan-questions.hook.test.ts +81 -0
- package/dist/templates/cc-native/_cc-native/lib-ts/__tests__/hooks/plan-review.hook.test.ts +71 -0
- package/dist/templates/cc-native/_cc-native/lib-ts/__tests__/json-parser.test.ts +99 -0
- package/dist/templates/cc-native/_cc-native/lib-ts/__tests__/orchestrator-agent.test.ts +288 -0
- package/dist/templates/cc-native/_cc-native/lib-ts/__tests__/orchestrator.test.ts +48 -0
- package/dist/templates/cc-native/_cc-native/lib-ts/__tests__/reviewers.test.ts +32 -0
- package/dist/templates/cc-native/_cc-native/lib-ts/__tests__/state.test.ts +124 -0
- package/dist/templates/cc-native/_cc-native/lib-ts/__tests__/verdict.test.ts +93 -0
- package/dist/templates/cc-native/_cc-native/lib-ts/agent-selection.ts +163 -0
- package/dist/templates/cc-native/_cc-native/lib-ts/aggregate-agents.ts +6 -14
- package/dist/templates/cc-native/_cc-native/{artifacts/lib → lib-ts/artifacts}/format.ts +597 -599
- package/dist/templates/cc-native/_cc-native/{artifacts/lib → lib-ts/artifacts}/index.ts +26 -26
- package/dist/templates/cc-native/_cc-native/{artifacts/lib → lib-ts/artifacts}/tracker.ts +106 -107
- package/dist/templates/cc-native/_cc-native/{artifacts/lib → lib-ts/artifacts}/write.ts +118 -119
- package/dist/templates/cc-native/_cc-native/lib-ts/artifacts.ts +21 -0
- package/dist/templates/cc-native/_cc-native/lib-ts/cc-native-state.ts +16 -15
- package/dist/templates/cc-native/_cc-native/lib-ts/cli-output-parser.ts +132 -10
- package/dist/templates/cc-native/_cc-native/lib-ts/constants.ts +6 -6
- package/dist/templates/cc-native/_cc-native/{plan-review/lib → lib-ts}/corroboration.ts +119 -119
- package/dist/templates/cc-native/_cc-native/lib-ts/debug.ts +1 -2
- package/dist/templates/cc-native/_cc-native/{plan-review/lib → lib-ts}/graduation.ts +132 -132
- package/dist/templates/cc-native/_cc-native/lib-ts/index.ts +88 -86
- package/dist/templates/cc-native/_cc-native/lib-ts/json-parser.ts +5 -6
- package/dist/templates/cc-native/_cc-native/{plan-review/lib → lib-ts}/orchestrator.ts +70 -70
- package/dist/templates/cc-native/_cc-native/{plan-review/lib → lib-ts}/output-builder.ts +130 -121
- package/dist/templates/cc-native/_cc-native/lib-ts/package-lock.json +1679 -0
- package/dist/templates/cc-native/_cc-native/lib-ts/package.json +24 -0
- package/dist/templates/cc-native/_cc-native/lib-ts/plan-discovery.ts +4 -4
- package/dist/templates/cc-native/_cc-native/lib-ts/plan-enhancement.ts +1 -6
- package/dist/templates/cc-native/_cc-native/{plan-review/lib → lib-ts}/plan-questions.ts +101 -101
- package/dist/templates/cc-native/_cc-native/{plan-review/lib → lib-ts}/review-pipeline.ts +511 -543
- package/dist/templates/cc-native/_cc-native/lib-ts/reviewers/__tests__/agent-providers.test.ts +262 -0
- package/dist/templates/cc-native/_cc-native/{plan-review/lib → lib-ts}/reviewers/agent.ts +71 -85
- package/dist/templates/{core/lib-ts/agent-exec → cc-native/_cc-native/lib-ts/reviewers/base}/base-agent.ts +138 -152
- package/dist/templates/cc-native/_cc-native/{plan-review/lib → lib-ts}/reviewers/index.ts +12 -12
- package/dist/templates/cc-native/_cc-native/{plan-review/lib → lib-ts}/reviewers/providers/claude-agent.ts +66 -57
- package/dist/templates/cc-native/_cc-native/{plan-review/lib → lib-ts}/reviewers/providers/codex-agent.ts +185 -200
- package/dist/templates/cc-native/_cc-native/{plan-review/lib → lib-ts}/reviewers/providers/gemini-agent.ts +39 -40
- package/dist/templates/cc-native/_cc-native/{plan-review/lib → lib-ts}/reviewers/providers/orchestrator-claude-agent.ts +196 -224
- package/dist/templates/cc-native/_cc-native/{plan-review/lib → lib-ts}/reviewers/schemas.ts +201 -201
- package/dist/templates/cc-native/_cc-native/{plan-review/lib → lib-ts}/reviewers/types.ts +21 -23
- package/dist/templates/cc-native/_cc-native/lib-ts/rlm/__tests__/hyde.test.ts +365 -0
- package/dist/templates/cc-native/_cc-native/lib-ts/rlm/__tests__/ollama-client.test.ts +223 -0
- package/dist/templates/cc-native/_cc-native/lib-ts/rlm/embedding-indexer.ts +12 -16
- package/dist/templates/cc-native/_cc-native/lib-ts/rlm/hyde.ts +3 -2
- package/dist/templates/cc-native/_cc-native/lib-ts/rlm/index.ts +31 -31
- package/dist/templates/cc-native/_cc-native/lib-ts/rlm/logger.ts +6 -7
- package/dist/templates/cc-native/_cc-native/lib-ts/rlm/ollama-client.ts +7 -9
- package/dist/templates/cc-native/_cc-native/lib-ts/rlm/retrieval-pipeline.ts +14 -17
- package/dist/templates/cc-native/_cc-native/lib-ts/rlm/transcript-indexer.ts +37 -41
- package/dist/templates/cc-native/_cc-native/lib-ts/rlm/transcript-loader.ts +33 -43
- package/dist/templates/cc-native/_cc-native/lib-ts/rlm/transcript-searcher.ts +20 -20
- package/dist/templates/cc-native/_cc-native/lib-ts/rlm/types.ts +8 -9
- package/dist/templates/cc-native/_cc-native/lib-ts/rlm/vector-store.ts +3 -4
- package/dist/templates/cc-native/_cc-native/lib-ts/settings.ts +50 -126
- package/dist/templates/cc-native/_cc-native/lib-ts/state.ts +19 -21
- package/dist/templates/cc-native/_cc-native/lib-ts/types.ts +13 -88
- package/dist/templates/cc-native/_cc-native/{plan-review/lib → lib-ts}/verdict.ts +72 -72
- package/dist/templates/cc-native/_cc-native/plan-review/CLAUDE.md +35 -0
- package/dist/templates/cc-native/_cc-native/plan-review/lib/agent-selection.ts +1 -1
- package/dist/templates/cc-native/_cc-native/scripts/council_debate.ts +242 -0
- package/dist/templates/cc-native/_cc-native/scripts/council_debate_simple.ts +294 -0
- package/dist/templates/cc-native/_cc-native/{plan-review/workflows → workflows}/specdev.md +9 -9
- package/dist/templates/core/.claude/skills/codex/SKILL.md +25 -0
- package/dist/templates/core/.claude/skills/devin/SKILL.md +25 -0
- package/dist/templates/core/.claude/skills/handoff/SKILL.md +11 -0
- package/dist/templates/core/.claude/skills/handoff-resume/SKILL.md +11 -0
- package/dist/templates/core/.claude/skills/meta-plan/SKILL.md +13 -0
- package/dist/templates/core/.codex/skills/codex/SKILL.md +13 -0
- package/dist/templates/core/.codex/skills/devin/SKILL.md +19 -0
- package/dist/templates/core/.codex/skills/handoff/SKILL.md +11 -0
- package/dist/templates/core/.codex/skills/handoff-resume/SKILL.md +11 -0
- package/dist/templates/core/.codex/{workflows/meta-plan.md → skills/meta-plan/SKILL.md} +6 -0
- package/dist/templates/core/{.cognition → .devin}/AGENTS.md +2 -2
- package/dist/templates/core/.devin/skills/codex/SKILL.md +19 -0
- package/dist/templates/core/.devin/skills/devin/SKILL.md +13 -0
- package/dist/templates/core/.devin/skills/handoff/SKILL.md +11 -0
- package/dist/templates/core/.devin/skills/handoff-resume/SKILL.md +11 -0
- package/dist/templates/core/.devin/skills/meta-plan/SKILL.md +13 -0
- package/dist/templates/core/.windsurf/workflows/handoff-resume.md +9 -0
- package/dist/templates/core/hooks-ts/archive_plan.ts +1 -21
- package/dist/templates/core/hooks-ts/file-suggestion.ts +1 -19
- package/dist/templates/core/hooks-ts/pre_compact.ts +5 -18
- package/dist/templates/core/lib-ts/context/context-store.ts +29 -2
- package/dist/templates/core/lib-ts/hooks/hook-utils.ts +11 -0
- package/dist/templates/core/lib-ts/hooks/session-end-logic.ts +2 -13
- package/dist/templates/core/lib-ts/runtime/agent-launcher.ts +74 -0
- package/dist/templates/core/lib-ts/runtime/aiw-cli.ts +4 -2
- package/dist/templates/core/lib-ts/runtime/cli-args.ts +18 -4
- package/dist/templates/core/lib-ts/runtime/inference.ts +3 -15
- package/dist/templates/core/lib-ts/runtime/models.ts +7 -0
- package/dist/templates/core/lib-ts/runtime/state-io.ts +9 -4
- package/dist/templates/core/lib-ts/runtime/utils.ts +30 -1
- package/dist/templates/core/lib-ts/schemas.ts +233 -0
- package/dist/templates/core/scripts/resolve-run.ts +34 -2
- package/dist/templates/core/scripts/status_line.ts +1 -1
- package/dist/templates/core/skills/codex/CLAUDE.md +9 -4
- package/dist/templates/core/skills/codex/SKILL.md +6 -0
- package/dist/templates/core/skills/codex/lib/codex-watcher.ts +3 -10
- package/dist/templates/core/skills/codex/scripts/launch-codex.ts +26 -26
- package/dist/templates/core/skills/devin/CLAUDE.md +63 -6
- package/dist/templates/core/skills/devin/lib/devin-watcher.ts +116 -96
- package/dist/templates/core/skills/devin/scripts/launch-devin.ts +22 -21
- package/dist/templates/core/skills/handoff-system/CLAUDE.md +1 -1
- package/oclif.manifest.json +4 -4
- package/package.json +4 -4
- package/dist/lib/base-command.d.ts +0 -1
- package/dist/lib/base-command.js +0 -1
- package/dist/lib/env-compat.d.ts +0 -18
- package/dist/lib/env-compat.js +0 -23
- package/dist/lib/launch-options.d.ts +0 -1
- package/dist/lib/launch-options.js +0 -1
- package/dist/lib/stdin.d.ts +0 -48
- package/dist/lib/stdin.js +0 -60
- package/dist/templates/cc-native/_cc-native/CLAUDE.md +0 -73
- package/dist/templates/cc-native/_cc-native/artifacts/CLAUDE.md +0 -64
- package/dist/templates/cc-native/_cc-native/lib-ts/CLAUDE.md +0 -70
- package/dist/templates/cc-native/_cc-native/plan-review/CODING-STANDARDS-CHECKLIST.md +0 -75
- package/dist/templates/cc-native/_cc-native/plan-review/agents/CLAUDE.md +0 -143
- package/dist/templates/cc-native/_cc-native/plan-review/agents/PLAN-ORCHESTRATOR.md +0 -213
- package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-questions/PLAN-QUESTIONER.md +0 -70
- package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/ARCH-EVOLUTION.md +0 -62
- package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/ARCH-PATTERNS.md +0 -61
- package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/ARCH-STRUCTURE.md +0 -62
- package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/ASSUMPTION-TRACER.md +0 -56
- package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/CLARITY-AUDITOR.md +0 -53
- package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/COMPLETENESS-FEASIBILITY.md +0 -66
- package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/COMPLETENESS-GAPS.md +0 -70
- package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/COMPLETENESS-ORDERING.md +0 -62
- package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/CONSTRAINT-VALIDATOR.md +0 -72
- package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/DESIGN-ADR-VALIDATOR.md +0 -61
- package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/DESIGN-SCALE-MATCHER.md +0 -64
- package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/DEVILS-ADVOCATE.md +0 -56
- package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/DOCUMENTATION-PHILOSOPHY.md +0 -86
- package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/HANDOFF-READINESS.md +0 -59
- package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/HIDDEN-COMPLEXITY.md +0 -58
- package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/INCREMENTAL-DELIVERY.md +0 -66
- package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/RISK-DEPENDENCY.md +0 -62
- package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/RISK-FMEA.md +0 -66
- package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/RISK-PREMORTEM.md +0 -71
- package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/RISK-REVERSIBILITY.md +0 -74
- package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/SCOPE-BOUNDARY.md +0 -77
- package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/SIMPLICITY-GUARDIAN.md +0 -62
- package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/SKEPTIC.md +0 -68
- package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/TESTDRIVEN-BEHAVIOR-AUDITOR.md +0 -61
- package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/TESTDRIVEN-CHARACTERIZATION.md +0 -71
- package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/TESTDRIVEN-FIRST-VALIDATOR.md +0 -61
- package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/TESTDRIVEN-PYRAMID-ANALYZER.md +0 -61
- package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/TRADEOFF-COSTS.md +0 -67
- package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/TRADEOFF-STAKEHOLDERS.md +0 -65
- package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/VERIFY-COVERAGE.md +0 -74
- package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/VERIFY-STRENGTH.md +0 -69
- package/dist/templates/cc-native/_cc-native/plan-review/lib/reviewers/base/base-agent.ts +0 -7
- package/dist/templates/core/.codex/workflows/codex.md +0 -17
- package/dist/templates/core/.codex/workflows/handoff.md +0 -5
- package/dist/templates/core/lib-ts/agent-exec/backends/headless.ts +0 -34
- package/dist/templates/core/lib-ts/agent-exec/backends/index.ts +0 -6
- package/dist/templates/core/lib-ts/agent-exec/backends/tmux.ts +0 -148
- package/dist/templates/core/lib-ts/agent-exec/execution-backend.ts +0 -50
- package/dist/templates/core/lib-ts/agent-exec/index.ts +0 -6
- package/dist/templates/core/lib-ts/agent-exec/structured-output.ts +0 -165
- /package/dist/templates/core/{.cognition → .devin}/config.json +0 -0
|
@@ -1,148 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Tmux execution backend — runs CLI agents in visible tmux panes
|
|
3
|
-
* with sentinel-file-based output capture.
|
|
4
|
-
*
|
|
5
|
-
* Self-contained tmux interaction — does not depend on tmux-driver.ts
|
|
6
|
-
* or the pane launcher stack (those are consolidated into the `aiw` CLI).
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
import * as fs from "node:fs";
|
|
10
|
-
import path from "node:path";
|
|
11
|
-
|
|
12
|
-
import {
|
|
13
|
-
buildShellCaptureScript,
|
|
14
|
-
cleanupSentinelIpc,
|
|
15
|
-
createSentinelIpcPaths,
|
|
16
|
-
readSentinelExitCode,
|
|
17
|
-
readTextIfExists,
|
|
18
|
-
waitForSentinelFile,
|
|
19
|
-
} from "../../runtime/sentinel-ipc.js";
|
|
20
|
-
import { execFileAsync, findExecutable } from "../../runtime/subprocess-utils.js";
|
|
21
|
-
import { findPsmux } from "../../runtime/tmux-preflight.js";
|
|
22
|
-
import type { ExecutionBackend, ExecutionRequest, ExecutionResult } from "../execution-backend.js";
|
|
23
|
-
|
|
24
|
-
export interface TmuxBackendOptions {
|
|
25
|
-
splitFlag?: string;
|
|
26
|
-
splitTarget?: string;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
function quoteForSh(input: string): string {
|
|
30
|
-
return `'${input.replaceAll("'", "'\"'\"'")}'`;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
function normalizeSplitFlag(value: string | undefined): "-h" | "-v" {
|
|
34
|
-
return value?.trim() === "-v" ? "-v" : "-h";
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
export class TmuxBackend implements ExecutionBackend {
|
|
38
|
-
private options: TmuxBackendOptions;
|
|
39
|
-
|
|
40
|
-
constructor(options?: TmuxBackendOptions) {
|
|
41
|
-
this.options = options ?? {};
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
async execute(request: ExecutionRequest): Promise<ExecutionResult> {
|
|
45
|
-
// On Windows, use psmux (native ConPTY multiplexer) instead of tmux
|
|
46
|
-
const isWindows = process.platform === "win32";
|
|
47
|
-
const muxBinary = isWindows ? "psmux" : "tmux";
|
|
48
|
-
|
|
49
|
-
if (!isWindows && !process.env.TMUX) {
|
|
50
|
-
return {
|
|
51
|
-
stdout: "",
|
|
52
|
-
stderr: "tmux pane launch failed: TMUX is not set",
|
|
53
|
-
exitCode: 1,
|
|
54
|
-
killed: false,
|
|
55
|
-
signal: null,
|
|
56
|
-
};
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
const tmuxPath = isWindows ? findPsmux() : findExecutable("tmux");
|
|
60
|
-
if (!tmuxPath) {
|
|
61
|
-
return {
|
|
62
|
-
stdout: "",
|
|
63
|
-
stderr: `${muxBinary} pane launch failed: ${muxBinary} not found on PATH`,
|
|
64
|
-
exitCode: 1,
|
|
65
|
-
killed: false,
|
|
66
|
-
signal: null,
|
|
67
|
-
};
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
const agentName = path.basename(request.cliPath).replace(/\.[^.]+$/, "");
|
|
71
|
-
const ipc = createSentinelIpcPaths(`aiwcli-agent-${agentName}`);
|
|
72
|
-
|
|
73
|
-
try {
|
|
74
|
-
fs.writeFileSync(ipc.inputPath, request.input, "utf8");
|
|
75
|
-
|
|
76
|
-
const envEntries = Object.entries(request.env).filter(
|
|
77
|
-
([, value]) => value !== undefined,
|
|
78
|
-
) as Array<[string, string]>;
|
|
79
|
-
const envPrefix = envEntries
|
|
80
|
-
.map(([key, value]) => `${key}=${quoteForSh(value)}`)
|
|
81
|
-
.join(" ");
|
|
82
|
-
|
|
83
|
-
const quotedArgs = request.args.map((arg) => quoteForSh(arg)).join(" ");
|
|
84
|
-
const command = `${envPrefix} ${quoteForSh(request.cliPath)} ${quotedArgs}`.trim();
|
|
85
|
-
const script = buildShellCaptureScript(command, ipc, quoteForSh);
|
|
86
|
-
|
|
87
|
-
const splitFlag = normalizeSplitFlag(this.options.splitFlag);
|
|
88
|
-
const tmuxArgs = ["split-window", splitFlag, "-P", "-F", "#{pane_id}"];
|
|
89
|
-
if (this.options.splitTarget) {
|
|
90
|
-
tmuxArgs.push("-t", this.options.splitTarget);
|
|
91
|
-
}
|
|
92
|
-
// On Windows (psmux), run directly — no bash wrapper needed.
|
|
93
|
-
// On Unix (tmux), wrap in bash login shell.
|
|
94
|
-
if (isWindows) {
|
|
95
|
-
tmuxArgs.push(script);
|
|
96
|
-
} else {
|
|
97
|
-
tmuxArgs.push(`bash -lc ${quoteForSh(script)}`);
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
const split = await execFileAsync(tmuxPath, tmuxArgs, { timeout: 5000 });
|
|
101
|
-
if (split.exitCode !== 0) {
|
|
102
|
-
return {
|
|
103
|
-
stdout: "",
|
|
104
|
-
stderr: `tmux pane launch failed: ${split.stderr.trim()}`,
|
|
105
|
-
exitCode: 1,
|
|
106
|
-
killed: false,
|
|
107
|
-
signal: null,
|
|
108
|
-
};
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
const paneId = split.stdout.trim().split(/\r?\n/).pop() ?? "";
|
|
112
|
-
const finished = await waitForSentinelFile(ipc.sentinelPath, request.timeoutMs);
|
|
113
|
-
|
|
114
|
-
if (!finished) {
|
|
115
|
-
if (paneId) {
|
|
116
|
-
await execFileAsync(tmuxPath, ["kill-pane", "-t", paneId], { timeout: 3000 });
|
|
117
|
-
}
|
|
118
|
-
return {
|
|
119
|
-
stdout: "",
|
|
120
|
-
stderr: "",
|
|
121
|
-
exitCode: -1,
|
|
122
|
-
killed: true,
|
|
123
|
-
signal: "SIGTERM",
|
|
124
|
-
};
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
const exitCode = readSentinelExitCode(ipc.sentinelPath, 1);
|
|
128
|
-
const stdout = readTextIfExists(ipc.stdoutPath);
|
|
129
|
-
const stderr = readTextIfExists(ipc.stderrPath);
|
|
130
|
-
|
|
131
|
-
if (request.outputFilePath && fs.existsSync(request.outputFilePath)) {
|
|
132
|
-
return {
|
|
133
|
-
stdout: fs.readFileSync(request.outputFilePath, "utf8"),
|
|
134
|
-
stderr,
|
|
135
|
-
exitCode,
|
|
136
|
-
killed: false,
|
|
137
|
-
signal: null,
|
|
138
|
-
};
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
return { stdout, stderr, exitCode, killed: false, signal: null };
|
|
142
|
-
} finally {
|
|
143
|
-
cleanupSentinelIpc(ipc);
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Execution backend interfaces for CLI agent subprocess invocations.
|
|
3
|
-
* Decouples agent logic (prompt building, output parsing) from execution
|
|
4
|
-
* strategy (headless subprocess vs tmux pane).
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
// ---------------------------------------------------------------------------
|
|
8
|
-
// Execution Request / Result
|
|
9
|
-
// ---------------------------------------------------------------------------
|
|
10
|
-
|
|
11
|
-
/** Request to execute a CLI subprocess. */
|
|
12
|
-
export interface ExecutionRequest {
|
|
13
|
-
cliPath: string;
|
|
14
|
-
args: string[];
|
|
15
|
-
input: string;
|
|
16
|
-
env: Record<string, string | undefined>;
|
|
17
|
-
timeoutMs: number;
|
|
18
|
-
/** If set, read output from this file instead of stdout (Codex pattern). */
|
|
19
|
-
outputFilePath?: string;
|
|
20
|
-
maxBuffer?: number;
|
|
21
|
-
shell?: boolean;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
/** Result from a CLI subprocess execution. */
|
|
25
|
-
export interface ExecutionResult {
|
|
26
|
-
stdout: string;
|
|
27
|
-
stderr: string;
|
|
28
|
-
exitCode: number;
|
|
29
|
-
killed: boolean;
|
|
30
|
-
signal: string | null;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
// ---------------------------------------------------------------------------
|
|
34
|
-
// Execution Backend
|
|
35
|
-
// ---------------------------------------------------------------------------
|
|
36
|
-
|
|
37
|
-
/** Strategy interface for running CLI agent subprocesses. */
|
|
38
|
-
export interface ExecutionBackend {
|
|
39
|
-
execute(request: ExecutionRequest): Promise<ExecutionResult>;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
// ---------------------------------------------------------------------------
|
|
43
|
-
// Debug Logger
|
|
44
|
-
// ---------------------------------------------------------------------------
|
|
45
|
-
|
|
46
|
-
/** Injectable debug logger for agents running in core context. */
|
|
47
|
-
export interface AgentDebugLogger {
|
|
48
|
-
log(contextPath: string, sessionName: string, component: string, message: string, data?: unknown): void;
|
|
49
|
-
raw(contextPath: string, sessionName: string, component: string, label: string, raw: string): void;
|
|
50
|
-
}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
export { HeadlessBackend } from "./backends/headless.js";
|
|
2
|
-
export { TmuxBackend } from "./backends/tmux.js";
|
|
3
|
-
export { type AgentExecutionConfig, BaseCliAgent } from "./base-agent.js";
|
|
4
|
-
export type { AgentDebugLogger, ExecutionBackend, ExecutionRequest, ExecutionResult } from "./execution-backend.js";
|
|
5
|
-
export { parseJsonObjectMaybe, parseStructuredOutput } from "./structured-output.js";
|
|
6
|
-
export type { StructuredOutputParseOptions } from "./structured-output.js";
|
|
@@ -1,165 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Shared structured output parsing utilities for CLI-based agents.
|
|
3
|
-
* Supports Claude/Codex-style envelopes and heuristic JSON extraction.
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
import { logDebug, logError, logWarn } from "../runtime/logger.js";
|
|
7
|
-
|
|
8
|
-
export interface StructuredOutputParseOptions {
|
|
9
|
-
requireFields?: string[];
|
|
10
|
-
loggerTag?: string;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
const DEFAULT_LOG_TAG = "structured_output";
|
|
14
|
-
|
|
15
|
-
function getTag(options?: StructuredOutputParseOptions): string {
|
|
16
|
-
return options?.loggerTag ?? DEFAULT_LOG_TAG;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
function validateRequiredFields(
|
|
20
|
-
obj: Record<string, unknown>,
|
|
21
|
-
parseMethod: "strict" | "heuristic",
|
|
22
|
-
options?: StructuredOutputParseOptions,
|
|
23
|
-
): Record<string, unknown> | null {
|
|
24
|
-
const required = options?.requireFields;
|
|
25
|
-
if (!required || required.length === 0) return obj;
|
|
26
|
-
|
|
27
|
-
const missing = required.filter((field) => !(field in obj) || obj[field] === undefined || obj[field] === null);
|
|
28
|
-
if (missing.length === 0) return obj;
|
|
29
|
-
|
|
30
|
-
const tag = getTag(options);
|
|
31
|
-
logWarn(tag, `Parsed JSON (${parseMethod}) missing required fields: ${JSON.stringify(missing)}`);
|
|
32
|
-
logDebug(tag, `Parsed keys: ${JSON.stringify(Object.keys(obj))}`);
|
|
33
|
-
|
|
34
|
-
// Heuristic extraction often grabs the wrong JSON blob. Reject in that case.
|
|
35
|
-
if (parseMethod === "heuristic") {
|
|
36
|
-
return null;
|
|
37
|
-
}
|
|
38
|
-
return obj;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* Parse a JSON object from text using strict parse first, then heuristic
|
|
43
|
-
* extraction of the first object-like block.
|
|
44
|
-
*/
|
|
45
|
-
export function parseJsonObjectMaybe(
|
|
46
|
-
text: string,
|
|
47
|
-
options?: StructuredOutputParseOptions,
|
|
48
|
-
): Record<string, unknown> | null {
|
|
49
|
-
const tag = getTag(options);
|
|
50
|
-
const trimmed = text.trim();
|
|
51
|
-
if (!trimmed) return null;
|
|
52
|
-
|
|
53
|
-
// Strict parse first.
|
|
54
|
-
try {
|
|
55
|
-
const parsed: unknown = JSON.parse(trimmed);
|
|
56
|
-
if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) {
|
|
57
|
-
return validateRequiredFields(parsed as Record<string, unknown>, "strict", options);
|
|
58
|
-
}
|
|
59
|
-
} catch {
|
|
60
|
-
// Fall through to heuristic extraction.
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
// Heuristic parse: extract the first object-like block.
|
|
64
|
-
const start = trimmed.indexOf("{");
|
|
65
|
-
const end = trimmed.lastIndexOf("}");
|
|
66
|
-
if (start === -1 || end === -1 || end <= start) return null;
|
|
67
|
-
|
|
68
|
-
const candidate = trimmed.slice(start, end + 1);
|
|
69
|
-
try {
|
|
70
|
-
const parsed: unknown = JSON.parse(candidate);
|
|
71
|
-
if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) {
|
|
72
|
-
logDebug(tag, `Used heuristic JSON extraction (chars ${start}-${end})`);
|
|
73
|
-
return validateRequiredFields(parsed as Record<string, unknown>, "heuristic", options);
|
|
74
|
-
}
|
|
75
|
-
} catch {
|
|
76
|
-
logDebug(tag, `Heuristic JSON extraction failed (chars ${start}-${end})`);
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
return null;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
function parseAssistantEnvelope(
|
|
83
|
-
envelope: Record<string, unknown>,
|
|
84
|
-
options?: StructuredOutputParseOptions,
|
|
85
|
-
): Record<string, unknown> | null {
|
|
86
|
-
const tag = getTag(options);
|
|
87
|
-
const {message} = envelope;
|
|
88
|
-
if (!message || typeof message !== "object") return null;
|
|
89
|
-
|
|
90
|
-
const {content} = (message as Record<string, unknown>);
|
|
91
|
-
if (!Array.isArray(content)) return null;
|
|
92
|
-
|
|
93
|
-
for (const item of content) {
|
|
94
|
-
if (!item || typeof item !== "object") continue;
|
|
95
|
-
const toolUse = item as Record<string, unknown>;
|
|
96
|
-
if (toolUse.name !== "StructuredOutput") continue;
|
|
97
|
-
if (toolUse.input && typeof toolUse.input === "object" && !Array.isArray(toolUse.input)) {
|
|
98
|
-
logDebug(tag, "Found StructuredOutput in assistant envelope");
|
|
99
|
-
return toolUse.input as Record<string, unknown>;
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
return null;
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
/**
|
|
106
|
-
* Parse structured output across known CLI envelope formats.
|
|
107
|
-
* Falls back to generic JSON extraction when no recognized envelope exists.
|
|
108
|
-
*/
|
|
109
|
-
export function parseStructuredOutput(
|
|
110
|
-
raw: string,
|
|
111
|
-
options?: StructuredOutputParseOptions,
|
|
112
|
-
): Record<string, unknown> | null {
|
|
113
|
-
const tag = getTag(options);
|
|
114
|
-
|
|
115
|
-
try {
|
|
116
|
-
const parsed: unknown = JSON.parse(raw);
|
|
117
|
-
|
|
118
|
-
if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) {
|
|
119
|
-
const obj = parsed as Record<string, unknown>;
|
|
120
|
-
|
|
121
|
-
if (obj.structured_output && typeof obj.structured_output === "object" && !Array.isArray(obj.structured_output)) {
|
|
122
|
-
logDebug(tag, "Found structured_output in root object");
|
|
123
|
-
return validateRequiredFields(obj.structured_output as Record<string, unknown>, "strict", options);
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
const assistantResult = parseAssistantEnvelope(obj, options);
|
|
127
|
-
if (assistantResult) return assistantResult;
|
|
128
|
-
|
|
129
|
-
// Session result envelope (no structured output tool call).
|
|
130
|
-
if (obj.type === "result" || ("duration_ms" in obj && "session_id" in obj)) {
|
|
131
|
-
if (obj.is_error === true || (Array.isArray(obj.errors) && obj.errors.length > 0)) {
|
|
132
|
-
logWarn(tag, `CLI returned error envelope: ${JSON.stringify(obj.errors ?? "is_error=true")}`);
|
|
133
|
-
return null;
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
if (typeof obj.result === "string" && obj.result.trim().length > 0) {
|
|
137
|
-
logDebug(tag, "Found text result in session envelope, attempting JSON extraction");
|
|
138
|
-
const extracted = parseJsonObjectMaybe(obj.result, options);
|
|
139
|
-
if (extracted) return extracted;
|
|
140
|
-
logWarn(tag, "Session envelope result contained no extractable JSON object");
|
|
141
|
-
}
|
|
142
|
-
return null;
|
|
143
|
-
}
|
|
144
|
-
} else if (Array.isArray(parsed)) {
|
|
145
|
-
for (const [i, event] of parsed.entries()) {
|
|
146
|
-
if (!event || typeof event !== "object") continue;
|
|
147
|
-
const eventObj = event as Record<string, unknown>;
|
|
148
|
-
const assistantResult = parseAssistantEnvelope(eventObj, options);
|
|
149
|
-
if (assistantResult) {
|
|
150
|
-
logDebug(tag, `Found StructuredOutput in event[${i}]`);
|
|
151
|
-
return assistantResult;
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
} catch (error: unknown) {
|
|
156
|
-
if (error instanceof SyntaxError) {
|
|
157
|
-
logWarn(tag, `JSON decode error: ${error.message}`);
|
|
158
|
-
} else {
|
|
159
|
-
logError(tag, `Unexpected parse error: ${error}`);
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
logDebug(tag, "No structured envelope found, falling back to generic JSON extraction");
|
|
164
|
-
return parseJsonObjectMaybe(raw, options);
|
|
165
|
-
}
|
|
File without changes
|