claude-code-session-manager 0.131.0 → 0.133.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 +3 -3
- package/dist/assets/{AgentLibrary-CYXre0J-.js → AgentLibrary-DOAG-mcG.js} +1 -1
- package/dist/assets/{AppSettings-xNSfCj8e.js → AppSettings-BHKM_AKh.js} +2 -2
- package/dist/assets/{Button-BWljh5IK.js → Button-CmO1wmPw.js} +1 -1
- package/dist/assets/{DocumentEditorPane-FUC2hZlp.js → DocumentEditorPane-8QMNrNRt.js} +1 -1
- package/dist/assets/{Extensions-CsyUoklz.js → Extensions-Boo21B3b.js} +2 -2
- package/dist/assets/{History-BvNmY9OQ.js → History-C4epd1hp.js} +1 -1
- package/dist/assets/{Library-DVXk77zA.js → Library-CrgzRQzL.js} +1 -1
- package/dist/assets/{ListDetail-DAAx__24.js → ListDetail-DA7y1DQ-.js} +1 -1
- package/dist/assets/{Panel-g2D-e-RM.js → Panel-D-WMBhKH.js} +1 -1
- package/dist/assets/{ProjectClaudeConfig-BDuHJwaO.js → ProjectClaudeConfig-CuUADpIu.js} +1 -1
- package/dist/assets/{ProvenanceBadge-wew4_nf3.js → ProvenanceBadge-B7AsoRk6.js} +1 -1
- package/dist/assets/{Scheduler-CbeUIqD-.js → Scheduler-C86gRh51.js} +1 -1
- package/dist/assets/{Settings-B23RsRfm.js → Settings-B4Q9DwVS.js} +1 -1
- package/dist/assets/{SkillReferenceGraph-BxQPCfsg.js → SkillReferenceGraph-DX4ZgvlY.js} +1 -1
- package/dist/assets/{Skills-4AR2FQrI.js → Skills-DqKI37yi.js} +1 -1
- package/dist/assets/{SourceChip-jrC0vjfw.js → SourceChip-C974LROr.js} +1 -1
- package/dist/assets/{SystemPrompt-hHoBEnYb.js → SystemPrompt-C502jIwO.js} +1 -1
- package/dist/assets/{TiptapBody-FkUqxO9u.js → TiptapBody-DwNXN6Ki.js} +1 -1
- package/dist/assets/{Toggle-DQMNWZKT.js → Toggle-C2OsxnPK.js} +1 -1
- package/dist/assets/{ViewTabs-DGU0ZuxB.js → ViewTabs-DBxKGbAK.js} +1 -1
- package/dist/assets/{VoiceButton-BPPvDllh.js → VoiceButton-C680wpmX.js} +1 -1
- package/dist/assets/{historyTotals-D8Oc3wUK.js → historyTotals-Cz-VYPEc.js} +1 -1
- package/dist/assets/{index-oXqzajWV.css → index-CMwAikUb.css} +1 -1
- package/dist/assets/index-Dh5geJe3.js +3111 -0
- package/dist/index.html +2 -2
- package/dist-web/app.css +1 -1
- package/dist-web/app.js +428 -414
- package/package.json +1 -1
- package/scripts/scheduler-mcp-server.cjs +12 -4
- package/src/main/build-info.json +4 -4
- package/src/main/chatRunner.cjs +77 -14
- package/src/main/index.cjs +15 -0
- package/src/main/ipcSchemas.cjs +54 -0
- package/src/main/lib/CLAUDE.md +2 -0
- package/src/main/lib/agent-cli/adapters/antigravity.cjs +147 -0
- package/src/main/lib/agent-cli/adapters/codex.cjs +170 -0
- package/src/main/lib/agent-cli/adapters/cursor.cjs +138 -0
- package/src/main/lib/agent-cli/adapters/gemini.cjs +119 -0
- package/src/main/lib/agent-cli/adapters/opencode.cjs +117 -0
- package/src/main/lib/agent-cli/agentCliEvents.cjs +94 -0
- package/src/main/lib/agent-cli/agentCliIpc.cjs +109 -0
- package/src/main/lib/agent-cli/agentCliRegistry.cjs +213 -0
- package/src/main/lib/agent-cli/agentCliSessionStore.cjs +152 -0
- package/src/main/lib/agent-cli/agentCliTurn.cjs +99 -0
- package/src/main/lib/app-preview/appPreviewIpc.cjs +125 -0
- package/src/main/lib/app-preview/appPreviewManager.cjs +317 -0
- package/src/main/lib/app-preview/appPreviewScripts.cjs +106 -0
- package/src/main/lib/app-preview/appPreviewSweep.cjs +92 -0
- package/src/main/lib/chatBootRecovery.cjs +41 -1
- package/src/main/lib/claude/agentEffortResolve.cjs +11 -3
- package/src/main/lib/epic/activeIndexMerge.cjs +25 -2
- package/src/main/lib/epic/archivedTranscript.cjs +39 -6
- package/src/main/lib/epic/epicChanges.cjs +466 -0
- package/src/main/lib/epic/epicMint.cjs +45 -1
- package/src/main/lib/epic/epicReopen.cjs +8 -2
- package/src/main/lib/epic/epicSpawnPlan.cjs +12 -0
- package/src/main/lib/epic/epicWorktreeMerge.cjs +39 -4
- package/src/main/lib/epic/promptSessionsCreateEpic.cjs +9 -4
- package/src/main/lib/feedback-remote/macroAdminRoutes.cjs +36 -13
- package/src/main/lib/feedback-remote/remoteIpcDispatch.cjs +2 -0
- package/src/main/lib/git/gitExec.cjs +9 -1
- package/src/main/lib/git/gitWorktree.cjs +94 -0
- package/src/main/lib/git/unifiedDiff.cjs +207 -0
- package/src/main/lib/mcpToolCatalog.cjs +15 -6
- package/src/main/lib/mdDocCensus.cjs +364 -0
- package/src/main/lib/mdDocRefs.cjs +249 -0
- package/src/main/lib/mdNetworkScan.cjs +158 -15
- package/src/main/lib/persona-macro/builtinMacros.cjs +17 -0
- package/src/main/lib/persona-macro/macroJobDispatch.cjs +4 -1
- package/src/main/lib/persona-macro/macroJobIpc.cjs +57 -11
- package/src/main/lib/persona-macro/macroLibrary.cjs +40 -10
- package/src/main/lib/prd/prdCreate.cjs +7 -2
- package/src/main/lib/prd/prdFrontmatter.cjs +10 -3
- package/src/main/lib/promptSessionSchema.cjs +6 -0
- package/src/main/lib/remoteTranscriptTail.cjs +23 -4
- package/src/main/lib/scheduler/landedSinceRun.cjs +2 -1
- package/src/main/lib/scheduler/scheduleJobSchema.cjs +2 -0
- package/src/main/lib/scheduler/schedulerPaths.cjs +3 -0
- package/src/main/projectPages.cjs +19 -4
- package/src/main/promptSessionEvents.cjs +10 -6
- package/src/main/scheduler/gitTreeGuard.cjs +2 -1
- package/src/main/scheduler/prdParser.cjs +2 -1
- package/src/main/scheduler.cjs +7 -2
- package/src/main/transcripts.cjs +18 -4
- package/src/main/webRemote.cjs +10 -5
- package/src/preload/api.d.ts +150 -3
- package/src/preload/apiSurface.json +56 -0
- package/src/preload/index.cjs +22 -0
- package/dist/assets/index-9ajPMXBg.js +0 -3097
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "claude-code-session-manager",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.133.0",
|
|
4
4
|
"description": "Local cockpit for the Claude Code CLI — multi-tab terminal, full config surface, scheduler, voice dictation, and live observability.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "src/main/index.cjs",
|
|
@@ -661,14 +661,14 @@ const TOOLS = [
|
|
|
661
661
|
type: 'object',
|
|
662
662
|
properties: {
|
|
663
663
|
cwd: { type: 'string', description: "Optional: absolute path to the target project. Defaults to the calling session's own project root (SM_PROJECT_ROOT or process.cwd()) when omitted." },
|
|
664
|
-
id: { type: 'string', description: 'Optional: id of an existing macro (already visible to this project) to update. Omit to create a new macro
|
|
664
|
+
id: { type: 'string', description: 'Optional: id of an existing macro (already visible to this project) to update. Omit to create a new macro.' },
|
|
665
665
|
label: { type: 'string', description: 'Short label shown on the HOT KEYS button.' },
|
|
666
666
|
agentName: { type: 'string', description: 'Persona to run the macro as (e.g. "builder").' },
|
|
667
667
|
tag: { type: 'string', description: 'Mission tag for the macro.' },
|
|
668
668
|
prompt: { type: 'string', description: 'The opening prompt the macro sends. Write input placeholders as {{name}}; each is filled from the matching entry in `inputs` when the macro is pressed.' },
|
|
669
|
-
surface: { type: 'string', enum: ['sessions', 'project-home'], description: "Where the macro shows: 'sessions' = Sessions HOT KEYS strip
|
|
669
|
+
surface: { type: 'string', enum: ['sessions', 'project-home'], description: "Where the macro shows: 'sessions' = Sessions HOT KEYS strip; 'project-home' = a tool in Project Home ▸ Tools, shown in every project (only what it generates is per project). A 'project-home' save needs humanRequestQuote and a Session Manager chat session." },
|
|
670
670
|
projects: { type: 'array', items: { type: 'string' }, description: 'Optional: only ["*"] is accepted, to show the macro in every project. Needs humanRequestQuote and a Session Manager chat session.' },
|
|
671
|
-
humanRequestQuote: { type: 'string', description:
|
|
671
|
+
humanRequestQuote: { type: 'string', description: "With projects [\"*\"] or surface 'project-home': the exact words the human typed in this chat asking for every project or for a Project Home tool." },
|
|
672
672
|
inputs: {
|
|
673
673
|
type: 'array',
|
|
674
674
|
description: 'Optional input fields the human fills in before the macro runs. Prompt placeholders are written as {{name}}. Omit on update to keep the existing inputs; pass [] to clear them.',
|
|
@@ -1127,7 +1127,15 @@ async function handleCallTool(request) {
|
|
|
1127
1127
|
if (missing.length > 0) {
|
|
1128
1128
|
return errorResult(`missing or invalid required argument(s): ${missing.join(', ')}`);
|
|
1129
1129
|
}
|
|
1130
|
-
|
|
1130
|
+
// A Project Home tool is shown in every project, so it gets the same
|
|
1131
|
+
// human-session refusal as projects ["*"].
|
|
1132
|
+
if (args.surface === 'project-home') {
|
|
1133
|
+
const refusal = humanSessionRefusal(
|
|
1134
|
+
'refused: a Project Home tool is shown in every project and is saved only in a Session Manager chat session where the human asked for it. '
|
|
1135
|
+
+ 'Say in your final result that the human can add it from Project Home ▸ Tools ▸ Add a tool.',
|
|
1136
|
+
);
|
|
1137
|
+
if (refusal) return refusal;
|
|
1138
|
+
} else if (args.projects !== undefined) {
|
|
1131
1139
|
const refusal = humanSessionRefusal(
|
|
1132
1140
|
'refused: a macro shown in every project is saved only in a Session Manager chat session where the human asked for it. '
|
|
1133
1141
|
+ 'Say in your final result that the human can set Show in every project in the macro editor.',
|
package/src/main/build-info.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "0.
|
|
3
|
-
"gitSha": "
|
|
4
|
-
"gitShortSha": "
|
|
2
|
+
"version": "0.133.0",
|
|
3
|
+
"gitSha": "994514120837c6c1b351c5c0dea8a402a3f555b3",
|
|
4
|
+
"gitShortSha": "99451412",
|
|
5
5
|
"gitBranch": "HEAD",
|
|
6
|
-
"builtAt": "2026-11-
|
|
6
|
+
"builtAt": "2026-11-13T16:16:40.136Z",
|
|
7
7
|
"dirty": false
|
|
8
8
|
}
|
package/src/main/chatRunner.cjs
CHANGED
|
@@ -57,6 +57,9 @@ const chatInflight = require('./lib/chatInflight.cjs');
|
|
|
57
57
|
const { feedChildStdin } = require('./lib/process/childStdin.cjs');
|
|
58
58
|
const memoryScope = require('./lib/process/memoryScope.cjs');
|
|
59
59
|
const { createHeadTailBuffer } = require('./lib/util/headTailBuffer.cjs');
|
|
60
|
+
const { isNonClaudeAgentCli } = require('./lib/agent-cli/agentCliEvents.cjs');
|
|
61
|
+
const { planAgentCliTurn } = require('./lib/agent-cli/agentCliTurn.cjs');
|
|
62
|
+
const { writeNativeSession } = require('./lib/agent-cli/agentCliSessionStore.cjs');
|
|
60
63
|
|
|
61
64
|
// Caps on per-run stream buffers (a run can last hours).
|
|
62
65
|
const STDERR_TAIL_MAX = 64 * 1024;
|
|
@@ -598,7 +601,13 @@ function executeRun({ tabId, sessionId, prompt, cwd, resume, silent, onSilentRes
|
|
|
598
601
|
});
|
|
599
602
|
};
|
|
600
603
|
|
|
601
|
-
|
|
604
|
+
// Non-Claude agent-CLI Epic (codex, gemini, …): the turn spawns that CLI's adapter command
|
|
605
|
+
// instead of claude; every Claude-only resolution below is skipped for it.
|
|
606
|
+
let agentEpic = null;
|
|
607
|
+
try { agentEpic = agentModelResolve.findEpicByClaudeSessionId(cwd, sessionId); } catch { agentEpic = null; }
|
|
608
|
+
const isAgentCli = !!(agentEpic && isNonClaudeAgentCli(agentEpic.agentCli));
|
|
609
|
+
|
|
610
|
+
const claudeBin = isAgentCli ? null : resolveClaudeBin();
|
|
602
611
|
// Carried down to any MCP server this run spawns (e.g.
|
|
603
612
|
// scripts/scheduler-mcp-server.cjs, inherited via the claude CLI's own
|
|
604
613
|
// child env) so scheduler_create_prd can auto-resolve sourcePromptId
|
|
@@ -627,16 +636,18 @@ function executeRun({ tabId, sessionId, prompt, cwd, resume, silent, onSilentRes
|
|
|
627
636
|
// throws; falls back to the hardcoded 'sonnet' literal when there's no
|
|
628
637
|
// Epic, no agentType, or the persona has no model/'inherit' — --model
|
|
629
638
|
// must never be left unpinned (CLAUDE.md model-pinning rule).
|
|
630
|
-
const model = agentModelResolve.resolveEpicModel({ cwd, claudeSessionId: sessionId });
|
|
639
|
+
const model = isAgentCli ? null : agentModelResolve.resolveEpicModel({ cwd, claudeSessionId: sessionId });
|
|
631
640
|
// Persona `effort:` (same overlay-aware persona, agentEffortResolve.cjs);
|
|
632
641
|
// effortArgs() yields NO tokens for inherit/absent/dangling.
|
|
633
|
-
const effortFlags = effortArgs(resolveEpicEffort({ cwd, claudeSessionId: sessionId }).effort);
|
|
642
|
+
const effortFlags = isAgentCli ? [] : effortArgs(resolveEpicEffort({ cwd, claudeSessionId: sessionId }).effort);
|
|
634
643
|
|
|
635
644
|
// Develop-loop-off Epics launch with the dev plugin disabled for this session only.
|
|
636
645
|
let loopOffArgs = [];
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
646
|
+
if (!isAgentCli) {
|
|
647
|
+
try {
|
|
648
|
+
loopOffArgs = developLoopOffSettingsArgs(agentModelResolve.findEpicByClaudeSessionId(cwd, sessionId));
|
|
649
|
+
} catch { /* lookup failure = launch as today */ }
|
|
650
|
+
}
|
|
640
651
|
|
|
641
652
|
// Main is authoritative about --resume vs --session-id AND the spawn cwd, and it decides
|
|
642
653
|
// them TOGETHER (epicSpawnPlan.cjs): a transcript under an encoding the spawn cwd cannot see
|
|
@@ -652,8 +663,25 @@ function executeRun({ tabId, sessionId, prompt, cwd, resume, silent, onSilentRes
|
|
|
652
663
|
settle();
|
|
653
664
|
return;
|
|
654
665
|
}
|
|
666
|
+
// Agent-CLI turn plan (agentCliTurn.cjs): command, argv, stdin, auth env, parser, transcript.
|
|
667
|
+
let agentPlan = null;
|
|
668
|
+
if (isAgentCli) {
|
|
669
|
+
agentPlan = planAgentCliTurn({ epic: agentEpic, claudeSessionId: sessionId, cwd: plan.execCwd, prompt: fullPrompt });
|
|
670
|
+
if (!agentPlan.ok) {
|
|
671
|
+
emitTerminal('chat:run:error', { tabId, sessionId, code: agentPlan.code, message: agentPlan.message });
|
|
672
|
+
if (silent && typeof onSilentError === 'function') {
|
|
673
|
+
try { onSilentError(agentPlan.message, agentPlan.code); } catch { /* caller bug must not wedge the lane */ }
|
|
674
|
+
}
|
|
675
|
+
settle();
|
|
676
|
+
return;
|
|
677
|
+
}
|
|
678
|
+
}
|
|
679
|
+
const agentEnv = agentPlan
|
|
680
|
+
? cleanChildEnv({ PATH: pathWithUserBins(), SM_CHAT_SESSION_ID: sessionId, SM_PROJECT_ROOT: cwd, ...agentPlan.envExtra })
|
|
681
|
+
: null;
|
|
682
|
+
|
|
655
683
|
const useResume = plan.useResume;
|
|
656
|
-
if (useResume !== !!resume) {
|
|
684
|
+
if (!agentPlan && useResume !== !!resume) {
|
|
657
685
|
try {
|
|
658
686
|
logs.writeLine({
|
|
659
687
|
scope: 'chatRunner',
|
|
@@ -764,8 +792,10 @@ function executeRun({ tabId, sessionId, prompt, cwd, resume, silent, onSilentRes
|
|
|
764
792
|
// A turn's background processes (dev server, local service) outlive it on
|
|
765
793
|
// purpose: the scope is never stopped; created --collect, systemd collects it once empty.
|
|
766
794
|
try {
|
|
767
|
-
const chatArgs = buildArgs(resumeFlag);
|
|
768
|
-
let target =
|
|
795
|
+
const chatArgs = agentPlan ? agentPlan.args : buildArgs(resumeFlag);
|
|
796
|
+
let target = agentPlan
|
|
797
|
+
? { command: agentPlan.command, args: chatArgs }
|
|
798
|
+
: claudeSpawnTarget('chat', sessionId, claudeBin, chatArgs);
|
|
769
799
|
// Limits first: with the cap off, never probe systemd.
|
|
770
800
|
const limits = memoryScope.memoryLimitsFor({ totalRamMb: Math.floor(require('node:os').totalmem() / 1048576) });
|
|
771
801
|
{
|
|
@@ -778,11 +808,12 @@ function executeRun({ tabId, sessionId, prompt, cwd, resume, silent, onSilentRes
|
|
|
778
808
|
target = { ...target, command: wrapped.command, args: wrapped.args, argv0: undefined };
|
|
779
809
|
}
|
|
780
810
|
}
|
|
811
|
+
if (agentPlan) agentPlan.transcript.userPrompt(fullPrompt);
|
|
781
812
|
thisChild = spawn(target.command, target.args || chatArgs, {
|
|
782
813
|
...(target.argv0 ? { argv0: target.argv0 } : {}),
|
|
783
814
|
...(target.windowsVerbatimArguments ? { windowsVerbatimArguments: true } : {}),
|
|
784
815
|
cwd: execCwd,
|
|
785
|
-
env: childEnv,
|
|
816
|
+
env: agentPlan ? agentEnv : childEnv,
|
|
786
817
|
stdio: ['pipe', 'pipe', 'pipe'],
|
|
787
818
|
...detachedSpawnOpts(), // own process group so killTree can SIGTERM descendants
|
|
788
819
|
});
|
|
@@ -799,7 +830,7 @@ function executeRun({ tabId, sessionId, prompt, cwd, resume, silent, onSilentRes
|
|
|
799
830
|
}
|
|
800
831
|
child = thisChild;
|
|
801
832
|
chatInflight.begin(sessionId, { tabId, cwd, pid: thisChild.pid, startedAt, resume, silent, promptId, origin, worktreeDirHint }).catch(() => {});
|
|
802
|
-
feedChildStdin(thisChild, fullPrompt, {
|
|
833
|
+
feedChildStdin(thisChild, agentPlan ? agentPlan.stdin : fullPrompt, {
|
|
803
834
|
log: (m) => logs.writeLine({ scope: 'chatRunner', level: 'warn', message: m }),
|
|
804
835
|
});
|
|
805
836
|
|
|
@@ -907,11 +938,37 @@ function executeRun({ tabId, sessionId, prompt, cwd, resume, silent, onSilentRes
|
|
|
907
938
|
}
|
|
908
939
|
};
|
|
909
940
|
|
|
941
|
+
// Agent-CLI turns: the adapter's parser translates each native line into Claude
|
|
942
|
+
// stream-json events, which are recorded and then fed through processLine unchanged.
|
|
943
|
+
let nativeIdSaved = false;
|
|
944
|
+
const processAgentEvents = (events) => {
|
|
945
|
+
for (const ev of Array.isArray(events) ? events : []) {
|
|
946
|
+
try { agentPlan.transcript.event(ev); } catch { /* transcript never fails a turn */ }
|
|
947
|
+
if (ev && ev.type === 'system' && ev.subtype === 'init' && typeof ev.session_id === 'string'
|
|
948
|
+
&& ev.session_id && !nativeIdSaved) {
|
|
949
|
+
nativeIdSaved = true;
|
|
950
|
+
try {
|
|
951
|
+
writeNativeSession(sessionId, { cli: agentPlan.cli, nativeSessionId: ev.session_id });
|
|
952
|
+
} catch (err) {
|
|
953
|
+
logs.writeLine({ scope: 'chatRunner', level: 'warn', message: `agent-cli native session write failed: ${err?.message ?? err}` });
|
|
954
|
+
}
|
|
955
|
+
}
|
|
956
|
+
processLine(JSON.stringify(ev));
|
|
957
|
+
}
|
|
958
|
+
};
|
|
959
|
+
const handleLine = (line) => {
|
|
960
|
+
if (!agentPlan) { processLine(line); return; }
|
|
961
|
+
if (!line) return;
|
|
962
|
+
let events = [];
|
|
963
|
+
try { events = agentPlan.parser.push(line); } catch { events = []; }
|
|
964
|
+
processAgentEvents(events);
|
|
965
|
+
};
|
|
966
|
+
|
|
910
967
|
thisChild.stdout.on('data', (chunk) => {
|
|
911
968
|
lineBuffer += chunk.toString('utf8');
|
|
912
969
|
let nl;
|
|
913
970
|
while ((nl = lineBuffer.indexOf('\n')) !== -1) {
|
|
914
|
-
|
|
971
|
+
handleLine(lineBuffer.slice(0, nl).trim());
|
|
915
972
|
lineBuffer = lineBuffer.slice(nl + 1);
|
|
916
973
|
}
|
|
917
974
|
if (lineBuffer.length > LINE_BUFFER_MAX) {
|
|
@@ -955,12 +1012,18 @@ function executeRun({ tabId, sessionId, prompt, cwd, resume, silent, onSilentRes
|
|
|
955
1012
|
// terminalSent latch.
|
|
956
1013
|
thisChild.on('close', (code, signal) => {
|
|
957
1014
|
// Flush any partial line that didn't end with \n
|
|
958
|
-
if (lineBuffer.trim())
|
|
1015
|
+
if (lineBuffer.trim()) handleLine(lineBuffer.trim());
|
|
1016
|
+
if (agentPlan) {
|
|
1017
|
+
let endEvents = [];
|
|
1018
|
+
try { endEvents = agentPlan.parser.end({ exitCode: code }); } catch { endEvents = []; }
|
|
1019
|
+
processAgentEvents(endEvents);
|
|
1020
|
+
try { agentPlan.transcript.close(); } catch { /* never fails a turn */ }
|
|
1021
|
+
}
|
|
959
1022
|
|
|
960
1023
|
// Flag-swap retry: the CLI rejected the session flag before doing any
|
|
961
1024
|
// work. Retry exactly once with the other flag; the timers, lane and
|
|
962
1025
|
// terminal latch stay at executeRun level, so this is still one turn.
|
|
963
|
-
if (!terminalSent && !killed && code !== 0 && attemptNo === 1
|
|
1026
|
+
if (!agentPlan && !terminalSent && !killed && code !== 0 && attemptNo === 1
|
|
964
1027
|
&& finalAssistantText === '' && recentToolUses.length === 0
|
|
965
1028
|
&& !/rate.?limit/i.test(stderrText())) {
|
|
966
1029
|
const swapTo = resumeFlag
|
package/src/main/index.cjs
CHANGED
|
@@ -75,6 +75,7 @@ const promptSessionsCreateEpic = require('./lib/epic/promptSessionsCreateEpic.cj
|
|
|
75
75
|
const customerFeedbackIpc = require('./lib/feedback-remote/customerFeedbackIpc.cjs');
|
|
76
76
|
const epicWorktreeMint = require('./lib/epic/epicWorktreeMint.cjs');
|
|
77
77
|
const epicWorktreeMerge = require('./lib/epic/epicWorktreeMerge.cjs');
|
|
78
|
+
const { registerAppPreviewHandlers, getAppPreviewManager } = require('./lib/app-preview/appPreviewIpc.cjs');
|
|
78
79
|
const epicWorktreeProjectConfig = require('./lib/epic/epicWorktreeProjectConfig.cjs');
|
|
79
80
|
const macroLibrary = require('./lib/persona-macro/macroLibrary.cjs');
|
|
80
81
|
const { resolveModelCatalog } = require('./lib/claude/modelCatalog.cjs');
|
|
@@ -623,6 +624,8 @@ require('./lib/persona-macro/macroJobIpc.cjs').registerMacroJobIpc(ipcMain, {
|
|
|
623
624
|
createPrd: (input) => prdCreate.createPrd(input, scheduler.remote),
|
|
624
625
|
loadJobs: async () => (await require('./lib/scheduler/queueStore.cjs').readMerged()).jobs || [],
|
|
625
626
|
archivePrd: (slug, cwd) => queueOps.archiveMany([slug], cwd),
|
|
627
|
+
// Durable 'job-not-queued' notice on the Epic when a dispatch fails (PRD 2950).
|
|
628
|
+
appendResponseEventWithReason: promptSessionEvents.appendResponseEventWithReason,
|
|
626
629
|
});
|
|
627
630
|
// claudeConfig (lib/claudeConfig.cjs): key-scoped read/patch of Claude's JSON config files.
|
|
628
631
|
// A successful patch broadcasts `config:changed` so renderer state refreshes.
|
|
@@ -1084,6 +1087,8 @@ require('./lib/epic/archivedTranscript.cjs').registerIpc(ipcMain);
|
|
|
1084
1087
|
customerFeedbackIpc.registerCustomerFeedbackHandlers();
|
|
1085
1088
|
epicWorktreeMint.registerEpicWorktreeMintHandlers();
|
|
1086
1089
|
epicWorktreeMerge.registerEpicWorktreeMergeHandlers();
|
|
1090
|
+
require('./lib/epic/epicChanges.cjs').registerEpicChangesHandlers();
|
|
1091
|
+
registerAppPreviewHandlers(ipcMain, { getWindow: () => mainWindow });
|
|
1087
1092
|
require('./lib/epic/epicReopen.cjs').registerEpicReopenHandlers();
|
|
1088
1093
|
epicWorktreeProjectConfig.registerEpicWorktreeProjectConfigHandlers();
|
|
1089
1094
|
registerMemoryAggregateIpc();
|
|
@@ -1113,6 +1118,7 @@ filesIpc.registerFilesHandlers();
|
|
|
1113
1118
|
registerDocEditHandlers();
|
|
1114
1119
|
webRemote.registerRemoteHandlers();
|
|
1115
1120
|
registerAgentsHandlers({ ipcMain, getWindow: () => mainWindow });
|
|
1121
|
+
require('./lib/agent-cli/agentCliIpc.cjs').registerAgentCliHandlers({ ipcMain });
|
|
1116
1122
|
try {
|
|
1117
1123
|
registerUpdaterIpc({ ipcMain, getWindow: () => mainWindow, ptyManager });
|
|
1118
1124
|
} catch (e) {
|
|
@@ -1283,6 +1289,12 @@ app.on('web-contents-created', (_e, wc) => {
|
|
|
1283
1289
|
|
|
1284
1290
|
app.whenReady().then(async () => {
|
|
1285
1291
|
logs.pruneOld();
|
|
1292
|
+
// Kill "Run preview" dev servers orphaned by a crashed previous run
|
|
1293
|
+
// (they outlive us when a child setsid'd out of the process group).
|
|
1294
|
+
try {
|
|
1295
|
+
const count = require('./lib/app-preview/appPreviewSweep.cjs').sweepOrphanedPreviews();
|
|
1296
|
+
if (count > 0) logs.writeLine({ scope: 'app-preview', level: 'warn', message: 'killed orphaned previews', meta: { count } });
|
|
1297
|
+
} catch { /* best-effort */ }
|
|
1286
1298
|
logs.writeLine({ scope: 'main', level: 'info', message: 'app start', meta: { version: app.getVersion(), platform: process.platform } });
|
|
1287
1299
|
logs.writeLine({ scope: 'main', level: 'info', message: 'ozone platform', meta: { ozonePlatform: app.commandLine.getSwitchValue('ozone-platform') || 'default', override: process.env.SM_OZONE_PLATFORM || null } });
|
|
1288
1300
|
|
|
@@ -1691,6 +1703,8 @@ function runShutdownCleanup() {
|
|
|
1691
1703
|
// later before-quit/will-quit firing is a safe no-op.
|
|
1692
1704
|
releaseSchedulerOwnership();
|
|
1693
1705
|
try { scheduler.stop(); } catch { /* */ }
|
|
1706
|
+
// App preview dev servers die with the app (sync SIGKILL of each tree).
|
|
1707
|
+
try { getAppPreviewManager().stopAll(); } catch { /* */ }
|
|
1694
1708
|
// PRD F1 v2 §IPC plumbing: must unregisterAll on will-quit.
|
|
1695
1709
|
try { globalShortcut.unregisterAll(); } catch { /* */ }
|
|
1696
1710
|
voiceHotkey.disposeOnQuit();
|
|
@@ -1721,6 +1735,7 @@ app.on('activate', () => {
|
|
|
1721
1735
|
app.on('before-quit', () => {
|
|
1722
1736
|
releaseSchedulerOwnership();
|
|
1723
1737
|
supervisor.stopSupervisor();
|
|
1738
|
+
try { getAppPreviewManager().stopAll(); } catch { /* */ }
|
|
1724
1739
|
ptyManager.killAll();
|
|
1725
1740
|
configMgr.closeAllWatchers();
|
|
1726
1741
|
closeAllProjectPagesWatchers();
|
package/src/main/ipcSchemas.cjs
CHANGED
|
@@ -15,6 +15,7 @@ const { PERSONA_NAME_RE } = require('./agentLibrary.cjs');
|
|
|
15
15
|
const { AgentPersonaSaveSchema, PersonaNameSchema, ProjectCwdSchema } = require('./lib/persona-macro/agentPersonaSchema.cjs');
|
|
16
16
|
const { MacroSaveSchema, MacroDeleteSchema, MacroSetProjectSchema, MacroRemoveFromProjectSchema, MacroInputSchema } = require('./lib/persona-macro/macroLibrary.cjs');
|
|
17
17
|
const { MAX_SLOTS } = require('./lib/scheduler/sessionSlots.cjs');
|
|
18
|
+
const { PRD_EFFORT_LEVELS } = require('./lib/prd/prdFrontmatter.cjs');
|
|
18
19
|
// Aliased: this file already has a looser, exchanges-only SESSION_ID_RE (Exchanges section).
|
|
19
20
|
const { SESSION_ID_RE: RESTORABLE_SESSION_ID_RE } = require('./lib/epic/restorableSessions.cjs');
|
|
20
21
|
|
|
@@ -241,6 +242,11 @@ const promptSessionsCreateEpic = z.object({
|
|
|
241
242
|
// it becomes a transcript filename) instead of minting a fresh one. Absent =
|
|
242
243
|
// a normal mint; ensureEpic's restore gate decides whether the id may be adopted.
|
|
243
244
|
restoreSessionId: z.string().regex(RESTORABLE_SESSION_ID_RE).optional(),
|
|
245
|
+
// Which agent CLI drives this Epic; absent = Claude Code. ensureEpic enforces
|
|
246
|
+
// the Claude-only rules (non-Claude => develop loop off, no restore).
|
|
247
|
+
agentCli: z.enum(['claude', 'codex', 'gemini', 'antigravity', 'cursor', 'opencode']).optional(),
|
|
248
|
+
// Model passed to a non-Claude CLI; absent = that CLI's own default.
|
|
249
|
+
agentCliModel: z.string().min(1).max(128).optional(),
|
|
244
250
|
});
|
|
245
251
|
|
|
246
252
|
// Renderer entry point for the "Restore a session" picker: this project's CLI
|
|
@@ -284,6 +290,33 @@ const promptSessionsMergeToMain = z.object({
|
|
|
284
290
|
carriedPaths: z.array(z.string().min(1).max(4096)).max(100000).optional(),
|
|
285
291
|
});
|
|
286
292
|
|
|
293
|
+
// Epic Changes view read (lib/epic/epicChanges.cjs getEpicChanges). Strict so
|
|
294
|
+
// an unknown key is refused; getEpicChanges re-validates cwd (absolute +
|
|
295
|
+
// validatePath) and epicId (isSafeEpicId) itself.
|
|
296
|
+
const epicChangesGet = z.object({
|
|
297
|
+
cwd: z.string().min(1),
|
|
298
|
+
epicId: z.string().min(1).max(200),
|
|
299
|
+
}).strict();
|
|
300
|
+
|
|
301
|
+
// App preview (lib/app-preview/appPreviewIpc.cjs). Main resolves the dev
|
|
302
|
+
// server's dir from the active index — the renderer sends only cwd + epicId,
|
|
303
|
+
// never a path to run in. The script regex mirrors appPreviewScripts.cjs's
|
|
304
|
+
// SCRIPT_NAME_RE (kept literal here; a test asserts they match): no leading
|
|
305
|
+
// '-' (so '--inspect' can't become an npm flag) and no shell metacharacters.
|
|
306
|
+
const APP_PREVIEW_SCRIPT_RE = /^[A-Za-z0-9@_][A-Za-z0-9:_.@/-]{0,99}$/;
|
|
307
|
+
const appPreviewScripts = z.object({
|
|
308
|
+
cwd: z.string().min(1).max(4096),
|
|
309
|
+
epicId: z.string().regex(PROMPT_SESSION_ID_RE),
|
|
310
|
+
});
|
|
311
|
+
const appPreviewStart = z.object({
|
|
312
|
+
cwd: z.string().min(1).max(4096),
|
|
313
|
+
epicId: z.string().regex(PROMPT_SESSION_ID_RE),
|
|
314
|
+
script: z.string().regex(APP_PREVIEW_SCRIPT_RE),
|
|
315
|
+
});
|
|
316
|
+
const appPreviewStop = z.object({
|
|
317
|
+
epicId: z.string().regex(PROMPT_SESSION_ID_RE),
|
|
318
|
+
});
|
|
319
|
+
|
|
287
320
|
// Renderer entry points for the per-project "disable Epic worktree
|
|
288
321
|
// isolation" UI toggle (lib/epic/epicWorktreeProjectConfig.cjs) — PRD 1035.
|
|
289
322
|
const promptSessionsGetWorktreeDisabled = z.object({
|
|
@@ -717,6 +750,7 @@ const macrosDispatchJob = z.object({
|
|
|
717
750
|
macroId: z.string().min(1).max(128),
|
|
718
751
|
epicId: z.string().min(1).max(200),
|
|
719
752
|
extraInstructions: z.string().max(4000).optional(),
|
|
753
|
+
effort: z.enum(/** @type {[string, ...string[]]} */ ([...PRD_EFFORT_LEVELS])).optional(),
|
|
720
754
|
});
|
|
721
755
|
const macrosJobStatus = z.object({ cwd: z.string().min(1).max(4096) });
|
|
722
756
|
|
|
@@ -879,6 +913,20 @@ const projectPagesCwd = z.object({
|
|
|
879
913
|
cwd: z.string().min(1).max(4096),
|
|
880
914
|
}).strict();
|
|
881
915
|
|
|
916
|
+
// project-pages:md-network — cwd plus optional human folder overrides for the
|
|
917
|
+
// census. Folders are repo-relative path PREFIXES used only for classification
|
|
918
|
+
// (never joined onto the fs), so the shape check here is the whole contract.
|
|
919
|
+
const mdNetworkFolder = z.string().min(1).max(512).refine(
|
|
920
|
+
(f) => !f.startsWith('/') && !f.includes('\\') && !f.includes('\0') && !f.split('/').includes('..'),
|
|
921
|
+
{ message: "folder must be repo-relative (no leading '/', backslash, NUL or '..' segment)" },
|
|
922
|
+
);
|
|
923
|
+
const mdNetworkFolderList = z.array(mdNetworkFolder).max(50);
|
|
924
|
+
const projectPagesMdNetwork = z.object({
|
|
925
|
+
cwd: z.string().min(1).max(4096),
|
|
926
|
+
recordFolders: mdNetworkFolderList.optional(),
|
|
927
|
+
docFolders: mdNetworkFolderList.optional(),
|
|
928
|
+
}).strict();
|
|
929
|
+
|
|
882
930
|
// ──────────────────────────────────────────── Project Home admin route
|
|
883
931
|
// Real path validation is projectRootResolve.cjs + config.cjs's validatePath;
|
|
884
932
|
// html content limits live in projectHomeAdminRoutes.cjs's validateHomeHtml.
|
|
@@ -1432,7 +1480,11 @@ module.exports = {
|
|
|
1432
1480
|
SAS_GATED_READS,
|
|
1433
1481
|
MUTATE_COMMANDS,
|
|
1434
1482
|
ALLOWED_COMMANDS,
|
|
1483
|
+
APP_PREVIEW_SCRIPT_RE,
|
|
1435
1484
|
schemas: {
|
|
1485
|
+
appPreviewScripts,
|
|
1486
|
+
appPreviewStart,
|
|
1487
|
+
appPreviewStop,
|
|
1436
1488
|
webRemotePair,
|
|
1437
1489
|
webRemoteRevokeDevice,
|
|
1438
1490
|
webRemoteAuditTail,
|
|
@@ -1509,6 +1561,7 @@ module.exports = {
|
|
|
1509
1561
|
memoryProposeFix,
|
|
1510
1562
|
projectBriefCwd,
|
|
1511
1563
|
projectPagesCwd,
|
|
1564
|
+
projectPagesMdNetwork,
|
|
1512
1565
|
projectPagesRename,
|
|
1513
1566
|
projectPagesDelete,
|
|
1514
1567
|
projectHomeAdminWriteBody,
|
|
@@ -1532,6 +1585,7 @@ module.exports = {
|
|
|
1532
1585
|
promptSessionsReadArchived,
|
|
1533
1586
|
promptSessionsReadSessionTranscript,
|
|
1534
1587
|
promptSessionsMergeToMain,
|
|
1588
|
+
epicChangesGet,
|
|
1535
1589
|
promptSessionsGetWorktreeDisabled,
|
|
1536
1590
|
promptSessionsSetWorktreeDisabled,
|
|
1537
1591
|
auditLogAppend,
|
package/src/main/lib/CLAUDE.md
CHANGED
|
@@ -4,6 +4,8 @@ Shared main-process helpers (CommonJS `.cjs`). Layout source of truth: `scripts/
|
|
|
4
4
|
|
|
5
5
|
## What's here
|
|
6
6
|
|
|
7
|
+
- `agent-cli/` — other agent CLIs: registry, adapters, session store, turn planner, IPC.
|
|
8
|
+
- `app-preview/` — Epic dev-server preview processes (spawn, URL detect, stop, orphan sweep).
|
|
7
9
|
- `claude/` — claude CLI binary, caps, model/effort resolution.
|
|
8
10
|
- `epic/` — Epic mint, worktrees, active index, spawn plan/cwd, transcripts.
|
|
9
11
|
- `feedback-remote/` — cross-project and customer feedback conduits.
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
// Google Antigravity CLI (`agy`) adapter: builds headless/interactive argv and
|
|
3
|
+
// translates agy's `--output-format stream-json` NDJSON (every line carries an
|
|
4
|
+
// `event` field: init / step_update / result) into the Claude stream-json
|
|
5
|
+
// events from ../agentCliEvents.cjs. The prompt is delivered over stdin as one
|
|
6
|
+
// `--input-format stream-json` user line, never in argv; agy exits after stdin
|
|
7
|
+
// closes. `--conversation <id>` resumes. Pure module.
|
|
8
|
+
|
|
9
|
+
const {
|
|
10
|
+
initEvent, textEvent, toolUseEvent, toolResultEvent, resultEvent, safeJsonLine,
|
|
11
|
+
} = require('../agentCliEvents.cjs');
|
|
12
|
+
|
|
13
|
+
const SKIP_PERMS = '--dangerously-skip-permissions';
|
|
14
|
+
const HEADLESS_FLAGS = ['--input-format', 'stream-json', '--output-format', 'stream-json', SKIP_PERMS];
|
|
15
|
+
|
|
16
|
+
const str = (v) => (typeof v === 'string' ? v : undefined);
|
|
17
|
+
const hasId = (id) => typeof id === 'string' && id.length > 0;
|
|
18
|
+
const isObj = (v) => !!v && typeof v === 'object' && !Array.isArray(v);
|
|
19
|
+
const sessionArgs = (id) => (hasId(id) ? ['--conversation', id] : []);
|
|
20
|
+
const modelArgs = (model) => (typeof model === 'string' && model ? ['--model', model] : []);
|
|
21
|
+
|
|
22
|
+
function headlessSpawn({ prompt, nativeSessionId, model } = {}) {
|
|
23
|
+
return {
|
|
24
|
+
args: [...HEADLESS_FLAGS, ...sessionArgs(nativeSessionId), ...modelArgs(model)],
|
|
25
|
+
stdin: JSON.stringify({ event: 'user', message: { content: typeof prompt === 'string' ? prompt : '' } }) + '\n',
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function interactiveArgs({ nativeSessionId, model } = {}) {
|
|
30
|
+
return [SKIP_PERMS, ...sessionArgs(nativeSessionId), ...modelArgs(model)];
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function pickUsage(u) {
|
|
34
|
+
if (!isObj(u)) return undefined;
|
|
35
|
+
const out = {};
|
|
36
|
+
for (const k of ['input_tokens', 'output_tokens']) {
|
|
37
|
+
if (typeof u[k] === 'number' && Number.isFinite(u[k])) out[k] = u[k];
|
|
38
|
+
}
|
|
39
|
+
return out;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function createParser() {
|
|
43
|
+
let sessionId = null;
|
|
44
|
+
let resultEmitted = false;
|
|
45
|
+
let initEmitted = false;
|
|
46
|
+
const texts = [];
|
|
47
|
+
const toolStarted = new Set();
|
|
48
|
+
const toolDone = new Set();
|
|
49
|
+
|
|
50
|
+
// conversation_id may sit at the top level or inside the event payload.
|
|
51
|
+
function convId(evt, payload) {
|
|
52
|
+
const id = str(evt.conversation_id) ?? (isObj(payload) ? str(payload.conversation_id) : undefined);
|
|
53
|
+
return hasId(id) ? id : undefined;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function adopt(id) {
|
|
57
|
+
if (id && !sessionId) sessionId = id;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
function handleStep(evt, out) {
|
|
61
|
+
const s = evt.step_update;
|
|
62
|
+
if (!isObj(s)) return;
|
|
63
|
+
adopt(convId(evt, s));
|
|
64
|
+
if (s.step_type === 'agent_response') {
|
|
65
|
+
const delta = str(s.text_delta);
|
|
66
|
+
if (delta) {
|
|
67
|
+
texts.push(delta);
|
|
68
|
+
out.push(textEvent(delta));
|
|
69
|
+
}
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
if (s.step_type !== 'tool') return; // user_input / checkpoint / unknown: ignored
|
|
73
|
+
const key = `${sessionId ?? convId(evt, s) ?? ''}:${s.step_index}`;
|
|
74
|
+
const startTool = () => {
|
|
75
|
+
if (toolStarted.has(key)) return;
|
|
76
|
+
toolStarted.add(key);
|
|
77
|
+
out.push(toolUseEvent({
|
|
78
|
+
id: key,
|
|
79
|
+
name: str(s.tool_name) ?? 'unknown',
|
|
80
|
+
input: isObj(s.tool_info) ? s.tool_info : {},
|
|
81
|
+
}));
|
|
82
|
+
};
|
|
83
|
+
if (s.state === 'ACTIVE') {
|
|
84
|
+
startTool();
|
|
85
|
+
} else if (s.state === 'DONE') {
|
|
86
|
+
if (toolDone.has(key)) return;
|
|
87
|
+
startTool(); // keep tool_use/tool_result paired if ACTIVE was never seen
|
|
88
|
+
toolDone.add(key);
|
|
89
|
+
out.push(toolResultEvent({ toolUseId: key, content: '', isError: false }));
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
function handleResult(evt, out) {
|
|
94
|
+
const r = evt.result;
|
|
95
|
+
if (!isObj(r) || resultEmitted) return;
|
|
96
|
+
resultEmitted = true;
|
|
97
|
+
adopt(convId(evt, r));
|
|
98
|
+
const text = texts.join('') || str(r.response) || str(r.error) || '';
|
|
99
|
+
out.push(resultEvent({
|
|
100
|
+
ok: r.status === 'SUCCESS',
|
|
101
|
+
text,
|
|
102
|
+
usage: pickUsage(r.usage),
|
|
103
|
+
nativeSessionId: sessionId ?? undefined,
|
|
104
|
+
}));
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
function handle(evt, out) {
|
|
108
|
+
switch (evt.event) {
|
|
109
|
+
case 'init': {
|
|
110
|
+
adopt(convId(evt, evt.init));
|
|
111
|
+
if (sessionId && !initEmitted) {
|
|
112
|
+
initEmitted = true;
|
|
113
|
+
out.push(initEvent(sessionId, 'antigravity'));
|
|
114
|
+
}
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
case 'step_update':
|
|
118
|
+
handleStep(evt, out);
|
|
119
|
+
return;
|
|
120
|
+
case 'result':
|
|
121
|
+
handleResult(evt, out);
|
|
122
|
+
return;
|
|
123
|
+
default:
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
return {
|
|
128
|
+
push(line) {
|
|
129
|
+
const out = [];
|
|
130
|
+
try {
|
|
131
|
+
const evt = safeJsonLine(line);
|
|
132
|
+
if (evt) handle(evt, out);
|
|
133
|
+
} catch {
|
|
134
|
+
return []; // never throw from push; drop the line
|
|
135
|
+
}
|
|
136
|
+
return out;
|
|
137
|
+
},
|
|
138
|
+
end() {
|
|
139
|
+
return [];
|
|
140
|
+
},
|
|
141
|
+
nativeSessionId() {
|
|
142
|
+
return sessionId;
|
|
143
|
+
},
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
module.exports = { id: 'antigravity', headlessSpawn, createParser, interactiveArgs };
|