ai-advisory-board 0.4.0 → 0.5.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/CHANGELOG.md +11 -0
- package/dist/bin/aab.js +172 -84
- package/dist/bin/aab.js.map +1 -1
- package/gui/app.js +64 -4
- package/gui/index.html +3 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
# CHANGELOG — AI Advisory Board CLI
|
|
2
2
|
|
|
3
|
+
## 0.5.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- bd9f86e: Skill Planner / Solve recon is faster, observable, and cancellable.
|
|
8
|
+
|
|
9
|
+
- **Live recon progress:** the planner progress modal no longer leaves Wiki recon and Web research on `queued` for the whole (multi-minute) parallel block. Each phase now reports `running` the moment it starts and `done` the moment IT settles (independently), with a live elapsed timer and a per-pass heartbeat (e.g. "researching 3 app(s) + general best-practices — 4 in parallel", "app 2/4 done").
|
|
10
|
+
- **Parallel web research:** the general + per-app web-research passes now run through a concurrency-capped pool (default 4 in flight) instead of sequentially. After evaluating Claude Code subagents and agent teams (sequential / lossy / experimental / interactive-only), N parallel `claude -p` processes were the right fit — each keeps its own structured JSON, timeout, and cost cap. Cuts the worst-case ~20 min recon to roughly the slowest 1–2 waves.
|
|
11
|
+
- **Cancel button:** the planner progress modal has a "Cancel plan" button. It aborts the run server-side, killing the in-flight recon/planner `claude` children so the token burn stops immediately.
|
|
12
|
+
- **Skip MCP startup tax:** recon + planner `claude` spawns now pass `--strict-mcp-config`, so they no longer load the user's configured MCP servers (Gmail, Slack, Google, …) on startup — those calls only need WebSearch/WebFetch/Read/Grep/Glob.
|
|
13
|
+
|
|
3
14
|
## 0.4.0
|
|
4
15
|
|
|
5
16
|
### Minor Changes
|
package/dist/bin/aab.js
CHANGED
|
@@ -154,6 +154,7 @@ async function runClaude(opts) {
|
|
|
154
154
|
}
|
|
155
155
|
if (opts.maxTurns) args.push("--max-turns", String(opts.maxTurns));
|
|
156
156
|
if (opts.maxBudgetUsd) args.push("--max-budget-usd", String(opts.maxBudgetUsd));
|
|
157
|
+
if (opts.strictMcpConfig) args.push("--strict-mcp-config");
|
|
157
158
|
if (opts.dangerouslySkipPermissions !== false) {
|
|
158
159
|
args.push("--dangerously-skip-permissions");
|
|
159
160
|
}
|
|
@@ -1193,6 +1194,8 @@ async function runPlanner(opts) {
|
|
|
1193
1194
|
cwd: opts.workspace.root,
|
|
1194
1195
|
maxBudgetUsd: budgetCap,
|
|
1195
1196
|
timeoutMs: 10 * 6e4,
|
|
1197
|
+
strictMcpConfig: true,
|
|
1198
|
+
signal: opts.signal,
|
|
1196
1199
|
onEvent: opts.onEvent ? (evt) => {
|
|
1197
1200
|
opts.onEvent?.({
|
|
1198
1201
|
type: "tokens",
|
|
@@ -10306,7 +10309,9 @@ async function runWikiRecon(opts) {
|
|
|
10306
10309
|
maxTurns,
|
|
10307
10310
|
cwd: opts.workspace.root,
|
|
10308
10311
|
maxBudgetUsd: opts.settings.perCallBudgetUsd,
|
|
10309
|
-
timeoutMs: 3 * 6e4
|
|
10312
|
+
timeoutMs: 3 * 6e4,
|
|
10313
|
+
strictMcpConfig: true,
|
|
10314
|
+
signal: opts.signal
|
|
10310
10315
|
});
|
|
10311
10316
|
const costUsd = result.json?.cost_usd ?? 0;
|
|
10312
10317
|
const text = extractText(result);
|
|
@@ -10561,59 +10566,92 @@ async function runWebRecon(opts) {
|
|
|
10561
10566
|
const generalMaxTurns = opts.generalMaxTurns ?? 12;
|
|
10562
10567
|
const perAppMaxTurns = opts.perAppMaxTurns ?? 6;
|
|
10563
10568
|
const topAppCount = opts.topAppCount ?? 5;
|
|
10569
|
+
const concurrency = Math.max(1, opts.concurrency ?? 4);
|
|
10564
10570
|
let costUsd = 0;
|
|
10565
10571
|
let warning;
|
|
10566
|
-
|
|
10567
|
-
try {
|
|
10568
|
-
const prompt2 = GENERAL_PROMPT.replace("{{ACTION_TITLE}}", escapeForPrompt2(opts.actionTitle)).replace("{{ACTION_DESCRIPTION}}", escapeForPrompt2(opts.actionDescription ?? ""));
|
|
10569
|
-
const result = await runClaude({
|
|
10570
|
-
prompt: prompt2,
|
|
10571
|
-
model,
|
|
10572
|
-
allowedTools: ["WebSearch", "WebFetch"],
|
|
10573
|
-
maxTurns: generalMaxTurns,
|
|
10574
|
-
cwd: opts.cwd,
|
|
10575
|
-
maxBudgetUsd: opts.settings.perCallBudgetUsd,
|
|
10576
|
-
timeoutMs: 5 * 6e4
|
|
10577
|
-
});
|
|
10578
|
-
costUsd += result.json?.cost_usd ?? 0;
|
|
10579
|
-
general = parseGeneral(extractText(result));
|
|
10580
|
-
} catch (err) {
|
|
10581
|
-
logger.debug("[web-recon] pass1 failed", { error: err instanceof Error ? err.message : String(err) });
|
|
10582
|
-
warning = `general web research failed: ${err instanceof Error ? err.message.slice(0, 160) : "unknown"}`;
|
|
10583
|
-
}
|
|
10584
|
-
const topApps = pickTopAppsForResearch(opts.apps, opts.actionTitle, opts.actionDescription, topAppCount);
|
|
10572
|
+
const out = { general: null };
|
|
10585
10573
|
const surfaces = [];
|
|
10586
|
-
|
|
10574
|
+
const topApps = pickTopAppsForResearch(opts.apps, opts.actionTitle, opts.actionDescription, topAppCount);
|
|
10575
|
+
const total = 1 + topApps.length;
|
|
10576
|
+
let completed = 0;
|
|
10577
|
+
const tick = (label) => {
|
|
10578
|
+
completed++;
|
|
10579
|
+
opts.onProgress?.(`${label} (${completed}/${total} passes done)`);
|
|
10580
|
+
};
|
|
10581
|
+
opts.onProgress?.(`researching ${topApps.length} app(s) + general best-practices \u2014 ${Math.min(concurrency, total)} in parallel`);
|
|
10582
|
+
const tasks = [];
|
|
10583
|
+
tasks.push(async () => {
|
|
10587
10584
|
try {
|
|
10588
|
-
const prompt2 =
|
|
10585
|
+
const prompt2 = GENERAL_PROMPT.replace("{{ACTION_TITLE}}", escapeForPrompt2(opts.actionTitle)).replace("{{ACTION_DESCRIPTION}}", escapeForPrompt2(opts.actionDescription ?? ""));
|
|
10589
10586
|
const result = await runClaude({
|
|
10590
10587
|
prompt: prompt2,
|
|
10591
10588
|
model,
|
|
10592
10589
|
allowedTools: ["WebSearch", "WebFetch"],
|
|
10593
|
-
maxTurns:
|
|
10590
|
+
maxTurns: generalMaxTurns,
|
|
10594
10591
|
cwd: opts.cwd,
|
|
10595
10592
|
maxBudgetUsd: opts.settings.perCallBudgetUsd,
|
|
10596
|
-
timeoutMs:
|
|
10593
|
+
timeoutMs: 5 * 6e4,
|
|
10594
|
+
strictMcpConfig: true,
|
|
10595
|
+
signal: opts.signal
|
|
10597
10596
|
});
|
|
10598
10597
|
costUsd += result.json?.cost_usd ?? 0;
|
|
10599
|
-
|
|
10600
|
-
if (surface) surfaces.push(surface);
|
|
10598
|
+
out.general = parseGeneral(extractText(result));
|
|
10601
10599
|
} catch (err) {
|
|
10602
|
-
logger.debug("[web-recon]
|
|
10600
|
+
logger.debug("[web-recon] pass1 failed", { error: err instanceof Error ? err.message : String(err) });
|
|
10601
|
+
warning = `general web research failed: ${err instanceof Error ? err.message.slice(0, 160) : "unknown"}`;
|
|
10602
|
+
} finally {
|
|
10603
|
+
tick("general best-practices");
|
|
10603
10604
|
}
|
|
10605
|
+
});
|
|
10606
|
+
for (const app of topApps) {
|
|
10607
|
+
tasks.push(async () => {
|
|
10608
|
+
try {
|
|
10609
|
+
const prompt2 = PER_APP_PROMPT.replace("{{ACTION_TITLE}}", escapeForPrompt2(opts.actionTitle)).replace("{{ACTION_DESCRIPTION}}", escapeForPrompt2(opts.actionDescription ?? "")).replace(/{{APP_NAME}}/g, escapeForPrompt2(app.name)).replace("{{APP_VERSION_OR_NONE}}", app.version ?? "");
|
|
10610
|
+
const result = await runClaude({
|
|
10611
|
+
prompt: prompt2,
|
|
10612
|
+
model,
|
|
10613
|
+
allowedTools: ["WebSearch", "WebFetch"],
|
|
10614
|
+
maxTurns: perAppMaxTurns,
|
|
10615
|
+
cwd: opts.cwd,
|
|
10616
|
+
maxBudgetUsd: opts.settings.perCallBudgetUsd,
|
|
10617
|
+
timeoutMs: 3 * 6e4,
|
|
10618
|
+
strictMcpConfig: true,
|
|
10619
|
+
signal: opts.signal
|
|
10620
|
+
});
|
|
10621
|
+
costUsd += result.json?.cost_usd ?? 0;
|
|
10622
|
+
const surface = parseAppSurface(extractText(result), app.name);
|
|
10623
|
+
if (surface) surfaces.push(surface);
|
|
10624
|
+
} catch (err) {
|
|
10625
|
+
logger.debug("[web-recon] per-app pass failed", { app: app.name, error: err instanceof Error ? err.message : String(err) });
|
|
10626
|
+
} finally {
|
|
10627
|
+
tick(app.name);
|
|
10628
|
+
}
|
|
10629
|
+
});
|
|
10604
10630
|
}
|
|
10631
|
+
await runWithConcurrency(tasks, concurrency);
|
|
10605
10632
|
return {
|
|
10606
|
-
taskDomain: general?.taskDomain ?? opts.actionTitle.slice(0, 60),
|
|
10607
|
-
bestPracticePatterns: general?.bestPracticePatterns ?? [],
|
|
10608
|
-
recommendedTools: general?.recommendedTools ?? [],
|
|
10609
|
-
recentInnovations: general?.recentInnovations ?? [],
|
|
10610
|
-
warningsAndPitfalls: general?.warningsAndPitfalls ?? [],
|
|
10633
|
+
taskDomain: out.general?.taskDomain ?? opts.actionTitle.slice(0, 60),
|
|
10634
|
+
bestPracticePatterns: out.general?.bestPracticePatterns ?? [],
|
|
10635
|
+
recommendedTools: out.general?.recommendedTools ?? [],
|
|
10636
|
+
recentInnovations: out.general?.recentInnovations ?? [],
|
|
10637
|
+
warningsAndPitfalls: out.general?.warningsAndPitfalls ?? [],
|
|
10611
10638
|
appIntegrationSurfaces: surfaces,
|
|
10612
|
-
webPassesCompleted: { general: general !== null, perAppCount: surfaces.length },
|
|
10639
|
+
webPassesCompleted: { general: out.general !== null, perAppCount: surfaces.length },
|
|
10613
10640
|
costUsd,
|
|
10614
10641
|
warning
|
|
10615
10642
|
};
|
|
10616
10643
|
}
|
|
10644
|
+
async function runWithConcurrency(tasks, limit) {
|
|
10645
|
+
let next = 0;
|
|
10646
|
+
const worker = async () => {
|
|
10647
|
+
while (next < tasks.length) {
|
|
10648
|
+
const idx = next++;
|
|
10649
|
+
await tasks[idx]();
|
|
10650
|
+
}
|
|
10651
|
+
};
|
|
10652
|
+
const workers = Array.from({ length: Math.min(limit, tasks.length) }, () => worker());
|
|
10653
|
+
await Promise.all(workers);
|
|
10654
|
+
}
|
|
10617
10655
|
function emptyContext2(actionTitle, warning) {
|
|
10618
10656
|
return {
|
|
10619
10657
|
taskDomain: actionTitle.slice(0, 60),
|
|
@@ -10759,6 +10797,7 @@ function nonNull2(v) {
|
|
|
10759
10797
|
async function runRecon(opts) {
|
|
10760
10798
|
const started = Date.now();
|
|
10761
10799
|
const warnings = [];
|
|
10800
|
+
opts.onPhaseStart?.("pc-scan");
|
|
10762
10801
|
let pc;
|
|
10763
10802
|
if (opts.skipPcScan) {
|
|
10764
10803
|
pc = emptyPc("skipped via --planner-no-pc-scan");
|
|
@@ -10774,13 +10813,16 @@ async function runRecon(opts) {
|
|
|
10774
10813
|
"pc-scan",
|
|
10775
10814
|
`${pc.apps.length} apps, ${pc.cliTools.length} CLI tools, ${pc.mcpServers.length} MCP, ${pc.envVars.length} env`
|
|
10776
10815
|
);
|
|
10816
|
+
opts.onPhaseStart?.("wiki-recon");
|
|
10817
|
+
opts.onPhaseStart?.("web-research");
|
|
10777
10818
|
const wikiPromise = runWikiRecon({
|
|
10778
10819
|
workspace: opts.workspace,
|
|
10779
10820
|
settings: opts.settings,
|
|
10780
10821
|
actionTitle: opts.actionTitle,
|
|
10781
10822
|
actionDescription: opts.actionDescription,
|
|
10782
10823
|
discussionSummary: opts.discussionSummary,
|
|
10783
|
-
skip: opts.skipWiki
|
|
10824
|
+
skip: opts.skipWiki,
|
|
10825
|
+
signal: opts.signal
|
|
10784
10826
|
});
|
|
10785
10827
|
const webPromise = runWebRecon({
|
|
10786
10828
|
settings: opts.settings,
|
|
@@ -10789,49 +10831,68 @@ async function runRecon(opts) {
|
|
|
10789
10831
|
apps: pc.apps,
|
|
10790
10832
|
skip: opts.skipWeb,
|
|
10791
10833
|
topAppCount: opts.topAppCount,
|
|
10792
|
-
cwd: opts.workspace.root
|
|
10834
|
+
cwd: opts.workspace.root,
|
|
10835
|
+
onProgress: (detail) => opts.onPhaseProgress?.("web-research", detail),
|
|
10836
|
+
signal: opts.signal
|
|
10793
10837
|
});
|
|
10794
|
-
const [
|
|
10795
|
-
|
|
10796
|
-
|
|
10797
|
-
|
|
10798
|
-
|
|
10799
|
-
|
|
10800
|
-
|
|
10801
|
-
|
|
10802
|
-
|
|
10803
|
-
|
|
10804
|
-
|
|
10805
|
-
|
|
10806
|
-
|
|
10807
|
-
|
|
10808
|
-
|
|
10809
|
-
|
|
10810
|
-
|
|
10811
|
-
|
|
10812
|
-
|
|
10813
|
-
|
|
10814
|
-
|
|
10815
|
-
|
|
10816
|
-
|
|
10817
|
-
|
|
10818
|
-
|
|
10819
|
-
|
|
10820
|
-
|
|
10821
|
-
|
|
10822
|
-
|
|
10823
|
-
|
|
10824
|
-
|
|
10825
|
-
|
|
10826
|
-
|
|
10827
|
-
|
|
10828
|
-
|
|
10829
|
-
|
|
10830
|
-
|
|
10831
|
-
|
|
10832
|
-
|
|
10833
|
-
|
|
10834
|
-
|
|
10838
|
+
const [wiki, web] = await Promise.all([
|
|
10839
|
+
(async () => {
|
|
10840
|
+
let w;
|
|
10841
|
+
try {
|
|
10842
|
+
w = await wikiPromise;
|
|
10843
|
+
} catch (err) {
|
|
10844
|
+
w = {
|
|
10845
|
+
playbooks: [],
|
|
10846
|
+
templates: [],
|
|
10847
|
+
domainKnowledge: [],
|
|
10848
|
+
pastLessons: [],
|
|
10849
|
+
stakeholders: [],
|
|
10850
|
+
endorsedDirections: [],
|
|
10851
|
+
vetoes: [],
|
|
10852
|
+
pastDecisions: [],
|
|
10853
|
+
relevantPages: [],
|
|
10854
|
+
costUsd: 0,
|
|
10855
|
+
warning: err instanceof Error ? err.message : "wiki recon failed"
|
|
10856
|
+
};
|
|
10857
|
+
}
|
|
10858
|
+
if (w.warning) warnings.push({ phase: "wiki-recon", severity: "warn", message: w.warning });
|
|
10859
|
+
opts.onPhaseDone?.(
|
|
10860
|
+
"wiki-recon",
|
|
10861
|
+
`${w.playbooks.length} playbooks, ${w.templates.length} templates, ${w.domainKnowledge.length} knowledge, ${w.stakeholders.length} stakeholders, ${w.vetoes.length} vetoes`
|
|
10862
|
+
);
|
|
10863
|
+
return w;
|
|
10864
|
+
})(),
|
|
10865
|
+
(async () => {
|
|
10866
|
+
let v;
|
|
10867
|
+
try {
|
|
10868
|
+
v = await webPromise;
|
|
10869
|
+
} catch (err) {
|
|
10870
|
+
v = {
|
|
10871
|
+
taskDomain: opts.actionTitle.slice(0, 60),
|
|
10872
|
+
bestPracticePatterns: [],
|
|
10873
|
+
recommendedTools: [],
|
|
10874
|
+
recentInnovations: [],
|
|
10875
|
+
warningsAndPitfalls: [],
|
|
10876
|
+
appIntegrationSurfaces: [],
|
|
10877
|
+
webPassesCompleted: { general: false, perAppCount: 0 },
|
|
10878
|
+
costUsd: 0,
|
|
10879
|
+
warning: err instanceof Error ? err.message : "web recon failed"
|
|
10880
|
+
};
|
|
10881
|
+
}
|
|
10882
|
+
if (!v.webPassesCompleted.general) {
|
|
10883
|
+
warnings.push({
|
|
10884
|
+
phase: "web-research-general",
|
|
10885
|
+
severity: "warn",
|
|
10886
|
+
message: v.warning ?? "general web pass returned no parseable output"
|
|
10887
|
+
});
|
|
10888
|
+
}
|
|
10889
|
+
opts.onPhaseDone?.(
|
|
10890
|
+
"web-research",
|
|
10891
|
+
`${v.bestPracticePatterns.length} patterns, ${v.recommendedTools.length} tools, ${v.appIntegrationSurfaces.length} app surfaces`
|
|
10892
|
+
);
|
|
10893
|
+
return v;
|
|
10894
|
+
})()
|
|
10895
|
+
]);
|
|
10835
10896
|
return {
|
|
10836
10897
|
pc,
|
|
10837
10898
|
wiki,
|
|
@@ -11739,6 +11800,11 @@ async function runSolve(opts) {
|
|
|
11739
11800
|
}
|
|
11740
11801
|
}
|
|
11741
11802
|
opts.onEvent?.({ type: "planner_started", payload: { runId } });
|
|
11803
|
+
const reconCallbacks = {
|
|
11804
|
+
onPhaseStart: (phase) => opts.onEvent?.({ type: "planner_recon_progress", payload: { runId, phase, status: "running" } }),
|
|
11805
|
+
onPhaseProgress: (phase, detail) => opts.onEvent?.({ type: "planner_recon_progress", payload: { runId, phase, status: "running", detail } }),
|
|
11806
|
+
onPhaseDone: (phase, summary) => opts.onEvent?.({ type: "planner_recon_progress", payload: { runId, phase, status: "done", summary } })
|
|
11807
|
+
};
|
|
11742
11808
|
const reconNeeded = !opts.preAcceptedProfile && !opts.noPlanner;
|
|
11743
11809
|
let recon;
|
|
11744
11810
|
if (!reconNeeded && opts.preAcceptedProfile) {
|
|
@@ -11752,9 +11818,8 @@ async function runSolve(opts) {
|
|
|
11752
11818
|
skipPcScan: opts.skipPcScan,
|
|
11753
11819
|
skipWiki: true,
|
|
11754
11820
|
skipWeb: true,
|
|
11755
|
-
|
|
11756
|
-
|
|
11757
|
-
}
|
|
11821
|
+
signal: opts.signal,
|
|
11822
|
+
...reconCallbacks
|
|
11758
11823
|
});
|
|
11759
11824
|
} else {
|
|
11760
11825
|
recon = await runRecon({
|
|
@@ -11766,11 +11831,11 @@ async function runSolve(opts) {
|
|
|
11766
11831
|
skipPcScan: opts.skipPcScan,
|
|
11767
11832
|
skipWiki: opts.skipWiki,
|
|
11768
11833
|
skipWeb: opts.skipWeb,
|
|
11769
|
-
|
|
11770
|
-
|
|
11771
|
-
}
|
|
11834
|
+
signal: opts.signal,
|
|
11835
|
+
...reconCallbacks
|
|
11772
11836
|
});
|
|
11773
11837
|
}
|
|
11838
|
+
if (opts.signal?.aborted) throw new CancelledError("Plan cancelled by user.");
|
|
11774
11839
|
opts.onEvent?.({ type: "planner_recon_done", payload: { runId, recon: summarizeReconForEvent(recon) } });
|
|
11775
11840
|
let capabilityProfile;
|
|
11776
11841
|
if (opts.preAcceptedProfile) {
|
|
@@ -11784,6 +11849,7 @@ async function runSolve(opts) {
|
|
|
11784
11849
|
const MAX_REPLANS = 3;
|
|
11785
11850
|
while (attempts <= MAX_REPLANS) {
|
|
11786
11851
|
attempts++;
|
|
11852
|
+
if (opts.signal?.aborted) throw new CancelledError("Plan cancelled by user.");
|
|
11787
11853
|
let plannerResult;
|
|
11788
11854
|
try {
|
|
11789
11855
|
plannerResult = await runPlanner({
|
|
@@ -11793,9 +11859,11 @@ async function runSolve(opts) {
|
|
|
11793
11859
|
discussionSummary: opts.discussionSummary,
|
|
11794
11860
|
recon,
|
|
11795
11861
|
maxTier: opts.plannerTierCap ?? "maximalist",
|
|
11796
|
-
userReplanFeedback: replanFeedback
|
|
11862
|
+
userReplanFeedback: replanFeedback,
|
|
11863
|
+
signal: opts.signal
|
|
11797
11864
|
});
|
|
11798
11865
|
} catch (err) {
|
|
11866
|
+
if (opts.signal?.aborted) throw new CancelledError("Plan cancelled by user.");
|
|
11799
11867
|
opts.onEvent?.({ type: "planner_failed", payload: { runId, error: err instanceof Error ? err.message : String(err) } });
|
|
11800
11868
|
throw err;
|
|
11801
11869
|
}
|
|
@@ -13942,6 +14010,7 @@ async function startUiServer(opts) {
|
|
|
13942
14010
|
}
|
|
13943
14011
|
});
|
|
13944
14012
|
const planCache = /* @__PURE__ */ new Map();
|
|
14013
|
+
const runningPlans = /* @__PURE__ */ new Map();
|
|
13945
14014
|
app.post("/api/actions/:id/plan", async (req, res) => {
|
|
13946
14015
|
try {
|
|
13947
14016
|
const actions = await opts.storage.loadActionItems();
|
|
@@ -13954,6 +14023,8 @@ async function startUiServer(opts) {
|
|
|
13954
14023
|
const body = req.body ?? {};
|
|
13955
14024
|
const discussion = action.discussionId ? await opts.storage.loadDiscussionById(action.discussionId) : null;
|
|
13956
14025
|
const planId = generateUUID();
|
|
14026
|
+
const controller = new AbortController();
|
|
14027
|
+
runningPlans.set(planId, controller);
|
|
13957
14028
|
broadcast({ type: "planner_started", planId, actionItemId: action.id });
|
|
13958
14029
|
(async () => {
|
|
13959
14030
|
try {
|
|
@@ -13971,12 +14042,19 @@ async function startUiServer(opts) {
|
|
|
13971
14042
|
yes: true,
|
|
13972
14043
|
projectRoot: process.cwd(),
|
|
13973
14044
|
runId: planId,
|
|
14045
|
+
signal: controller.signal,
|
|
13974
14046
|
onEvent: (evt) => broadcast(coerceSolveEventForWs(evt, planId))
|
|
13975
14047
|
});
|
|
13976
14048
|
planCache.set(planId, result.capabilityProfile);
|
|
13977
14049
|
broadcast({ type: "planner_proposal_ready", planId, proposal: result.proposal });
|
|
13978
14050
|
} catch (err) {
|
|
13979
|
-
|
|
14051
|
+
if (controller.signal.aborted) {
|
|
14052
|
+
broadcast({ type: "planner_cancelled", planId });
|
|
14053
|
+
} else {
|
|
14054
|
+
broadcast({ type: "planner_failed", planId, reason: "error", errorMessage: err instanceof Error ? err.message : String(err) });
|
|
14055
|
+
}
|
|
14056
|
+
} finally {
|
|
14057
|
+
runningPlans.delete(planId);
|
|
13980
14058
|
}
|
|
13981
14059
|
})();
|
|
13982
14060
|
res.status(202).json({ planId, status: "running" });
|
|
@@ -13996,6 +14074,16 @@ async function startUiServer(opts) {
|
|
|
13996
14074
|
}
|
|
13997
14075
|
res.json({ planId: req.params.planId, profile });
|
|
13998
14076
|
});
|
|
14077
|
+
app.post("/api/plans/:planId/cancel", (req, res) => {
|
|
14078
|
+
const controller = runningPlans.get(req.params.planId);
|
|
14079
|
+
if (!controller) {
|
|
14080
|
+
res.status(404).json({ error: "No running plan with that id (already finished or never started)." });
|
|
14081
|
+
return;
|
|
14082
|
+
}
|
|
14083
|
+
controller.abort();
|
|
14084
|
+
broadcast({ type: "planner_cancelled", planId: req.params.planId });
|
|
14085
|
+
res.json({ cancelled: true });
|
|
14086
|
+
});
|
|
13999
14087
|
app.post("/api/plans/:planId/replan", async (req, res) => {
|
|
14000
14088
|
try {
|
|
14001
14089
|
const existing = planCache.get(req.params.planId);
|