@telora/daemon 0.16.7 → 0.16.16
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/build-info.json +7 -3
- package/dist/audit-phase.d.ts +14 -0
- package/dist/audit-phase.d.ts.map +1 -1
- package/dist/audit-phase.js +52 -12
- package/dist/audit-phase.js.map +1 -1
- package/dist/backends/agent-backend.d.ts +63 -0
- package/dist/backends/agent-backend.d.ts.map +1 -0
- package/dist/backends/agent-backend.js +19 -0
- package/dist/backends/agent-backend.js.map +1 -0
- package/dist/backends/availability.d.ts +28 -0
- package/dist/backends/availability.d.ts.map +1 -0
- package/dist/backends/availability.js +49 -0
- package/dist/backends/availability.js.map +1 -0
- package/dist/backends/claude/claude-backend.d.ts +12 -0
- package/dist/backends/claude/claude-backend.d.ts.map +1 -0
- package/dist/backends/claude/claude-backend.js +86 -0
- package/dist/backends/claude/claude-backend.js.map +1 -0
- package/dist/backends/codex/codex-backend.d.ts +23 -0
- package/dist/backends/codex/codex-backend.d.ts.map +1 -0
- package/dist/backends/codex/codex-backend.js +116 -0
- package/dist/backends/codex/codex-backend.js.map +1 -0
- package/dist/backends/index.d.ts +13 -0
- package/dist/backends/index.d.ts.map +1 -0
- package/dist/backends/index.js +20 -0
- package/dist/backends/index.js.map +1 -0
- package/dist/backends/registry.d.ts +29 -0
- package/dist/backends/registry.d.ts.map +1 -0
- package/dist/backends/registry.js +45 -0
- package/dist/backends/registry.js.map +1 -0
- package/dist/backends/resolve.d.ts +44 -0
- package/dist/backends/resolve.d.ts.map +1 -0
- package/dist/backends/resolve.js +57 -0
- package/dist/backends/resolve.js.map +1 -0
- package/dist/completion-detector.d.ts +18 -16
- package/dist/completion-detector.d.ts.map +1 -1
- package/dist/completion-detector.js +36 -36
- package/dist/completion-detector.js.map +1 -1
- package/dist/directive-executor.d.ts +6 -1
- package/dist/directive-executor.d.ts.map +1 -1
- package/dist/directive-executor.js +26 -11
- package/dist/directive-executor.js.map +1 -1
- package/dist/focus-completion-event.d.ts +20 -7
- package/dist/focus-completion-event.d.ts.map +1 -1
- package/dist/focus-completion-event.js +29 -10
- package/dist/focus-completion-event.js.map +1 -1
- package/dist/focus-executor.d.ts +15 -1
- package/dist/focus-executor.d.ts.map +1 -1
- package/dist/focus-executor.js +129 -62
- package/dist/focus-executor.js.map +1 -1
- package/dist/focus-spawn-helpers.d.ts +2 -0
- package/dist/focus-spawn-helpers.d.ts.map +1 -1
- package/dist/focus-spawn-helpers.js +42 -37
- package/dist/focus-spawn-helpers.js.map +1 -1
- package/dist/git-merge.d.ts.map +1 -1
- package/dist/git-merge.js +42 -16
- package/dist/git-merge.js.map +1 -1
- package/dist/heartbeat.d.ts.map +1 -1
- package/dist/heartbeat.js +7 -0
- package/dist/heartbeat.js.map +1 -1
- package/dist/listener.d.ts.map +1 -1
- package/dist/listener.js +4 -1
- package/dist/listener.js.map +1 -1
- package/dist/merge-back-loop.d.ts.map +1 -1
- package/dist/merge-back-loop.js +1 -0
- package/dist/merge-back-loop.js.map +1 -1
- package/dist/output-monitor.d.ts +11 -6
- package/dist/output-monitor.d.ts.map +1 -1
- package/dist/output-monitor.js +53 -41
- package/dist/output-monitor.js.map +1 -1
- package/dist/queries/deliveries.d.ts +15 -0
- package/dist/queries/deliveries.d.ts.map +1 -1
- package/dist/queries/deliveries.js +6 -0
- package/dist/queries/deliveries.js.map +1 -1
- package/dist/queries/focuses.d.ts +13 -1
- package/dist/queries/focuses.d.ts.map +1 -1
- package/dist/queries/focuses.js +17 -1
- package/dist/queries/focuses.js.map +1 -1
- package/dist/queries/schemas.d.ts +12 -0
- package/dist/queries/schemas.d.ts.map +1 -1
- package/dist/queries/schemas.js +15 -0
- package/dist/queries/schemas.js.map +1 -1
- package/dist/session-lifecycle.d.ts.map +1 -1
- package/dist/session-lifecycle.js +4 -2
- package/dist/session-lifecycle.js.map +1 -1
- package/dist/session-lineage.d.ts +68 -0
- package/dist/session-lineage.d.ts.map +1 -0
- package/dist/session-lineage.js +63 -0
- package/dist/session-lineage.js.map +1 -0
- package/dist/spawn-environment.d.ts +11 -0
- package/dist/spawn-environment.d.ts.map +1 -1
- package/dist/spawn-environment.js +27 -0
- package/dist/spawn-environment.js.map +1 -1
- package/dist/spawner-lifecycle.d.ts +27 -7
- package/dist/spawner-lifecycle.d.ts.map +1 -1
- package/dist/spawner-lifecycle.js +40 -21
- package/dist/spawner-lifecycle.js.map +1 -1
- package/dist/spawner-stream-handlers.d.ts +3 -2
- package/dist/spawner-stream-handlers.d.ts.map +1 -1
- package/dist/spawner-stream-handlers.js +37 -34
- package/dist/spawner-stream-handlers.js.map +1 -1
- package/dist/spawner.d.ts +8 -17
- package/dist/spawner.d.ts.map +1 -1
- package/dist/spawner.js +8 -319
- package/dist/spawner.js.map +1 -1
- package/dist/team-prompt-base.d.ts +35 -2
- package/dist/team-prompt-base.d.ts.map +1 -1
- package/dist/team-prompt-base.js +93 -9
- package/dist/team-prompt-base.js.map +1 -1
- package/dist/team-spawner.d.ts +21 -3
- package/dist/team-spawner.d.ts.map +1 -1
- package/dist/team-spawner.js +49 -34
- package/dist/team-spawner.js.map +1 -1
- package/dist/types/config.d.ts +2 -0
- package/dist/types/config.d.ts.map +1 -1
- package/dist/types/focus.d.ts +10 -0
- package/dist/types/focus.d.ts.map +1 -1
- package/dist/types/session.d.ts +4 -4
- package/dist/types/session.d.ts.map +1 -1
- package/dist/types/workflow.d.ts +17 -0
- package/dist/types/workflow.d.ts.map +1 -1
- package/package.json +3 -3
package/dist/spawner.js
CHANGED
|
@@ -1,39 +1,21 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Spawner lifecycle/state re-export hub.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
* -
|
|
6
|
-
* - Delivery details (name, description, acceptance criteria, tech context)
|
|
7
|
-
* - All context groups and tasks within the delivery
|
|
4
|
+
* The per-delivery spawn function (spawnAgentForDelivery) was removed —
|
|
5
|
+
* delivery-level execution is now handled by the focus-level team spawner.
|
|
8
6
|
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
7
|
+
* This module re-exports lifecycle helpers and running-agent state accessors
|
|
8
|
+
* that are consumed by the rest of the daemon.
|
|
11
9
|
*
|
|
12
10
|
* Stream/process handling: ./spawner-stream-handlers.ts
|
|
13
11
|
* Lifecycle management: ./spawner-lifecycle.ts
|
|
14
12
|
*/
|
|
15
|
-
import {
|
|
16
|
-
import { mkdirSync, existsSync } from 'node:fs';
|
|
17
|
-
import { join } from 'node:path';
|
|
18
|
-
import { updateSession, createSession, getDeliveryContext, fetchEffectiveWorkflow, getResolvedTransitionBlockForDelivery, reportGitState } from './supabase.js';
|
|
19
|
-
import { buildSpawnEnvironment } from './spawn-environment.js';
|
|
20
|
-
import { sanitizeGitSegment } from './git-utils.js';
|
|
21
|
-
import { createWorktree, removeWorktree, syncIntegrationWithMain } from './git.js';
|
|
22
|
-
import { getRunningAgents as _getRunningAgents, recordActivity } from './agent-state.js';
|
|
23
|
-
import { getStageByName } from './workflow-engine.js';
|
|
24
|
-
import { StreamJsonParser, sendMessage, buildStreamJsonArgs, createLogStream } from '@telora/daemon-core';
|
|
25
|
-
import { CompletionDetector } from './completion-detector.js';
|
|
26
|
-
import { buildDeliveryPrompt } from './prompt-builder.js';
|
|
27
|
-
import { attachStreamHandlers, attachProcessHandlers, safeSendSignal, safeCloseStdin } from './spawner-stream-handlers.js';
|
|
13
|
+
import { getRunningAgents as _getRunningAgents } from './agent-state.js';
|
|
28
14
|
import { terminateAgent as _terminateAgent, terminateAllAgents as _terminateAllAgents, isAgentRunning as _isAgentRunning, getRunningAgentCount as _getRunningAgentCount, } from './spawner-lifecycle.js';
|
|
29
15
|
// Running agents map: shared via agent-state module
|
|
30
16
|
const runningAgents = _getRunningAgents();
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
/** Inject the resource governor for global concurrency limiting. */
|
|
34
|
-
export function initGovernor(gov) {
|
|
35
|
-
governor = gov;
|
|
36
|
-
}
|
|
17
|
+
/** No-op. The per-delivery spawn path was removed; governor is managed by team-spawner. */
|
|
18
|
+
export function initGovernor(_gov) { }
|
|
37
19
|
/**
|
|
38
20
|
* Get map of running agents.
|
|
39
21
|
* Re-exported from agent-state for backward compatibility.
|
|
@@ -64,297 +46,4 @@ export { spawnResolutionAgent } from './spawner-lifecycle.js';
|
|
|
64
46
|
export { spawnAuditAgent } from './spawner-lifecycle.js';
|
|
65
47
|
/** Re-export stale agent liveness checks. */
|
|
66
48
|
export { isProcessAlive, checkAgentLiveness } from './spawner-liveness.js';
|
|
67
|
-
// ── Spawn helpers ───────────────────────────────────────────────────
|
|
68
|
-
/**
|
|
69
|
-
* Build Claude Code CLI arguments for stream-json I/O.
|
|
70
|
-
*
|
|
71
|
-
* Uses the shared base args from daemon-core, then appends daemon-specific flags.
|
|
72
|
-
*/
|
|
73
|
-
function buildClaudeCodeArgs(_config) {
|
|
74
|
-
const args = buildStreamJsonArgs();
|
|
75
|
-
// Skip user-level settings (hooks etc.) that can block headless execution
|
|
76
|
-
args.push('--setting-sources', 'project,local');
|
|
77
|
-
console.log(` Stream-JSON mode (structured I/O)`);
|
|
78
|
-
// Agent Teams always enabled -- focus-level execution model
|
|
79
|
-
args.push('--teammate-mode', 'in-process');
|
|
80
|
-
console.log(` + Agent Teams (in-process teammates)`);
|
|
81
|
-
return args;
|
|
82
|
-
}
|
|
83
|
-
/**
|
|
84
|
-
* Set up per-agent timeout enforcement with warning at 80% and escalating shutdown.
|
|
85
|
-
*
|
|
86
|
-
* Returns a `timedOut` accessor function (closure over mutable state).
|
|
87
|
-
*/
|
|
88
|
-
function setupTimeoutEnforcement(config, runningAgent, deliveryName, sessionId) {
|
|
89
|
-
let timedOut = false;
|
|
90
|
-
const timeoutMs = config.sessionTimeoutMs;
|
|
91
|
-
if (timeoutMs <= 0) {
|
|
92
|
-
return { getTimedOut: () => timedOut };
|
|
93
|
-
}
|
|
94
|
-
// Warning at 80% of timeout -- send warning via stdin
|
|
95
|
-
const warningMs = Math.floor(timeoutMs * 0.8);
|
|
96
|
-
runningAgent.warningTimer = setTimeout(() => {
|
|
97
|
-
const remaining = Math.ceil((timeoutMs - warningMs) / 60000);
|
|
98
|
-
console.warn(`[timeout] Agent for "${deliveryName}" at 80% of timeout limit. ` +
|
|
99
|
-
`Sending warning via stdin. ~${remaining} min remaining.`);
|
|
100
|
-
sendMessage(runningAgent.stdin, `WARNING: You have approximately ${remaining} minutes remaining before the session ` +
|
|
101
|
-
`is terminated. Please wrap up your current work, commit changes, and prepare to exit.`);
|
|
102
|
-
}, warningMs);
|
|
103
|
-
// Hard timeout -- escalating shutdown: message -> close stdin -> SIGTERM -> SIGKILL
|
|
104
|
-
runningAgent.timeoutTimer = setTimeout(() => {
|
|
105
|
-
timedOut = true;
|
|
106
|
-
console.error(`[timeout] Agent for "${deliveryName}" exceeded ${timeoutMs / 60000} min timeout. ` +
|
|
107
|
-
`Sending shutdown message...`);
|
|
108
|
-
runningAgent.streamState = 'shutting_down';
|
|
109
|
-
sendMessage(runningAgent.stdin, `TIMEOUT: Session time limit reached. Stop all work immediately, commit any changes, and exit now.`);
|
|
110
|
-
scheduleTimeoutEscalation(runningAgent, deliveryName, sessionId);
|
|
111
|
-
}, timeoutMs);
|
|
112
|
-
return { getTimedOut: () => timedOut };
|
|
113
|
-
}
|
|
114
|
-
/**
|
|
115
|
-
* Schedule escalating shutdown steps after the initial timeout message:
|
|
116
|
-
* stdin close -> SIGTERM -> SIGKILL
|
|
117
|
-
*/
|
|
118
|
-
function scheduleTimeoutEscalation(agent, deliveryName, sessionId) {
|
|
119
|
-
// Close stdin after a short grace period to signal EOF
|
|
120
|
-
setTimeout(() => safeCloseStdin(agent.stdin), 10000);
|
|
121
|
-
// SIGTERM after stdin close grace period
|
|
122
|
-
setTimeout(() => {
|
|
123
|
-
if (!runningAgents.has(sessionId))
|
|
124
|
-
return;
|
|
125
|
-
console.error(`[timeout] Agent for "${deliveryName}" did not exit after stdin close. Sending SIGTERM...`);
|
|
126
|
-
safeSendSignal(agent.pid, 'SIGTERM');
|
|
127
|
-
}, 20000);
|
|
128
|
-
// SIGKILL as absolute last resort
|
|
129
|
-
setTimeout(() => {
|
|
130
|
-
if (!runningAgents.has(sessionId))
|
|
131
|
-
return;
|
|
132
|
-
console.error(`[timeout] Agent for "${deliveryName}" still running. Sending SIGKILL...`);
|
|
133
|
-
safeSendSignal(agent.pid, 'SIGKILL');
|
|
134
|
-
}, 30000);
|
|
135
|
-
}
|
|
136
|
-
/**
|
|
137
|
-
* Fetch the guard directive for a delivery, if one exists.
|
|
138
|
-
* When a delivery resumes after a transition block is resolved,
|
|
139
|
-
* the directive template is injected into the agent prompt.
|
|
140
|
-
* Returns null if no directive is found or on any error.
|
|
141
|
-
*/
|
|
142
|
-
async function fetchGuardDirective(deliveryId) {
|
|
143
|
-
try {
|
|
144
|
-
const resolvedBlock = await getResolvedTransitionBlockForDelivery(deliveryId);
|
|
145
|
-
if (!resolvedBlock?.directive_template)
|
|
146
|
-
return null;
|
|
147
|
-
console.log(` Injecting guard directive from block ${resolvedBlock.block.id} (path: ${resolvedBlock.block.decision_path})`);
|
|
148
|
-
return resolvedBlock.directive_template;
|
|
149
|
-
}
|
|
150
|
-
catch (e) {
|
|
151
|
-
console.debug(`[spawner] Guard directive lookup failed for delivery ${deliveryId} (non-fatal):`, e.message);
|
|
152
|
-
return null;
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
/**
|
|
156
|
-
* Generate branch name for delivery work.
|
|
157
|
-
*/
|
|
158
|
-
function generateBranchName(role, deliveryName) {
|
|
159
|
-
const sanitizedRoleName = sanitizeGitSegment(role.name);
|
|
160
|
-
const sanitizedDeliveryName = sanitizeGitSegment(deliveryName);
|
|
161
|
-
return `agent/${sanitizedRoleName}/${sanitizedDeliveryName}`;
|
|
162
|
-
}
|
|
163
|
-
// ── Core spawn function ─────────────────────────────────────────────
|
|
164
|
-
/**
|
|
165
|
-
* Spawn a Claude Code agent to work on a delivery.
|
|
166
|
-
*
|
|
167
|
-
* The agent runs in an isolated git worktree created from the integration branch.
|
|
168
|
-
* On successful completion, the agent's changes are merged back to integration.
|
|
169
|
-
*/
|
|
170
|
-
export async function spawnAgentForDelivery(config, deliveryId, role, focusId) {
|
|
171
|
-
// Get full delivery context — failures are caught and skipped (retried next cycle)
|
|
172
|
-
let context;
|
|
173
|
-
try {
|
|
174
|
-
context = await getDeliveryContext(deliveryId);
|
|
175
|
-
}
|
|
176
|
-
catch (err) {
|
|
177
|
-
console.error(`Error fetching context for delivery ${deliveryId}:`, err.message);
|
|
178
|
-
return; // Will be retried next polling cycle
|
|
179
|
-
}
|
|
180
|
-
if (!context) {
|
|
181
|
-
console.error(`Failed to get context for delivery ${deliveryId}`);
|
|
182
|
-
return;
|
|
183
|
-
}
|
|
184
|
-
// Fetch effective workflow (cached for this session's lifetime)
|
|
185
|
-
let workflow;
|
|
186
|
-
try {
|
|
187
|
-
workflow = await fetchEffectiveWorkflow(deliveryId);
|
|
188
|
-
}
|
|
189
|
-
catch (err) {
|
|
190
|
-
console.error(`Error fetching workflow for delivery ${deliveryId}:`, err.message);
|
|
191
|
-
return; // Will be retried next polling cycle
|
|
192
|
-
}
|
|
193
|
-
const branchName = generateBranchName(role, context.delivery.name);
|
|
194
|
-
// Ensure log directory exists with restrictive permissions (owner-only)
|
|
195
|
-
if (!existsSync(config.logDir)) {
|
|
196
|
-
mkdirSync(config.logDir, { recursive: true, mode: 0o700 });
|
|
197
|
-
}
|
|
198
|
-
// Check for resolved transition block directive (when resuming after human routing)
|
|
199
|
-
const guardDirective = await fetchGuardDirective(deliveryId);
|
|
200
|
-
// Build prompt with full delivery context (+ optional guard directive)
|
|
201
|
-
const prompt = buildDeliveryPrompt(role, context, guardDirective);
|
|
202
|
-
// Log file paths
|
|
203
|
-
const timestamp = new Date().toISOString().replace(/[:.]/g, '-');
|
|
204
|
-
const stdoutPath = join(config.logDir, `${branchName.replace(/\//g, '-')}-${timestamp}.stdout.log`);
|
|
205
|
-
const stderrPath = join(config.logDir, `${branchName.replace(/\//g, '-')}-${timestamp}.stderr.log`);
|
|
206
|
-
// Create session in database — failures are caught and skipped
|
|
207
|
-
let session;
|
|
208
|
-
try {
|
|
209
|
-
const codingStageForSession = getStageByName(workflow, 'coding');
|
|
210
|
-
session = await createSession({
|
|
211
|
-
organizationId: context.delivery.organization_id,
|
|
212
|
-
roleId: role.id,
|
|
213
|
-
issueId: null, // No single issue - working on whole delivery
|
|
214
|
-
deliveryId,
|
|
215
|
-
branchName,
|
|
216
|
-
workflowStageId: codingStageForSession?.id ?? null,
|
|
217
|
-
});
|
|
218
|
-
}
|
|
219
|
-
catch (err) {
|
|
220
|
-
console.error(`Error creating session for delivery "${context.delivery.name}":`, err.message);
|
|
221
|
-
return; // Will be retried next polling cycle
|
|
222
|
-
}
|
|
223
|
-
recordActivity();
|
|
224
|
-
console.log(`Spawning agent for delivery "${context.delivery.name}"`);
|
|
225
|
-
console.log(` Role: ${role.name}`);
|
|
226
|
-
console.log(` Session: ${session.id}`);
|
|
227
|
-
console.log(` Branch: ${branchName}`);
|
|
228
|
-
console.log(` Workflow: ${workflow.id} (${workflow.stages.map(s => s.name).join(' -> ')})`);
|
|
229
|
-
console.log(` Context Groups/Items: ${context.contextGroups.length}`);
|
|
230
|
-
// Sync integration branch with main before creating worktree
|
|
231
|
-
try {
|
|
232
|
-
const syncResult = await syncIntegrationWithMain(config);
|
|
233
|
-
if (syncResult.success) {
|
|
234
|
-
console.log(` Synced integration with main before worktree creation`);
|
|
235
|
-
}
|
|
236
|
-
else {
|
|
237
|
-
console.warn(` Could not sync integration with main: ${syncResult.error}`);
|
|
238
|
-
// Continue anyway — stale code is better than not spawning
|
|
239
|
-
}
|
|
240
|
-
}
|
|
241
|
-
catch (err) {
|
|
242
|
-
console.warn(` Sync failed (continuing): ${err instanceof Error ? err.message : String(err)}`);
|
|
243
|
-
}
|
|
244
|
-
// Create worktree for this agent (branches from integration)
|
|
245
|
-
let worktreePath;
|
|
246
|
-
try {
|
|
247
|
-
worktreePath = await createWorktree(config, branchName);
|
|
248
|
-
console.log(` Worktree: ${worktreePath}`);
|
|
249
|
-
reportGitState(deliveryId, 'worktree_created', branchName).catch(err => console.warn('[spawner] reportGitState worktree_created failed:', err.message));
|
|
250
|
-
}
|
|
251
|
-
catch (err) {
|
|
252
|
-
console.error(`Failed to create worktree for ${branchName}:`, err instanceof Error ? err.message : String(err));
|
|
253
|
-
await updateSession(session.id, {
|
|
254
|
-
status: 'failed',
|
|
255
|
-
exit_reason: 'Failed to create worktree',
|
|
256
|
-
ended_at: new Date().toISOString(),
|
|
257
|
-
});
|
|
258
|
-
return;
|
|
259
|
-
}
|
|
260
|
-
// Build Claude Code arguments and spawn environment
|
|
261
|
-
const args = buildClaudeCodeArgs(config);
|
|
262
|
-
const spawnEnv = buildSpawnEnvironment(config, {
|
|
263
|
-
orgId: config.organizationId,
|
|
264
|
-
focusId,
|
|
265
|
-
deliveryId,
|
|
266
|
-
sessionId: session.id,
|
|
267
|
-
// Per-delivery coding agent runs the execute phase.
|
|
268
|
-
phase: 'execute',
|
|
269
|
-
});
|
|
270
|
-
// Update session to starting
|
|
271
|
-
await updateSession(session.id, {
|
|
272
|
-
status: 'starting',
|
|
273
|
-
started_at: new Date().toISOString(),
|
|
274
|
-
stdout_path: stdoutPath,
|
|
275
|
-
stderr_path: stderrPath,
|
|
276
|
-
});
|
|
277
|
-
// Open log files with restrictive permissions (owner-only read/write)
|
|
278
|
-
const stdoutLogStream = createLogStream(stdoutPath);
|
|
279
|
-
const stderrStream = createLogStream(stderrPath);
|
|
280
|
-
// Raw NDJSON stream log for all agents
|
|
281
|
-
const jsonlPath = join(config.logDir, `${branchName.replace(/\//g, '-')}-${timestamp}.stream.jsonl`);
|
|
282
|
-
const jsonlStream = createLogStream(jsonlPath);
|
|
283
|
-
// Acquire governor slot (if governor is configured)
|
|
284
|
-
if (governor) {
|
|
285
|
-
try {
|
|
286
|
-
await governor.acquireSlot('focus');
|
|
287
|
-
}
|
|
288
|
-
catch (err) {
|
|
289
|
-
console.warn(`[spawner] Governor denied slot for "${context.delivery.name}":`, err.message);
|
|
290
|
-
await updateSession(session.id, {
|
|
291
|
-
status: 'failed',
|
|
292
|
-
exit_reason: 'Governor denied slot',
|
|
293
|
-
ended_at: new Date().toISOString(),
|
|
294
|
-
});
|
|
295
|
-
removeWorktree(config.repoPath, worktreePath, {
|
|
296
|
-
branchName,
|
|
297
|
-
integrationBranch: config.integrationBranch,
|
|
298
|
-
deliveryName: context.delivery.name,
|
|
299
|
-
mergeSucceeded: false,
|
|
300
|
-
});
|
|
301
|
-
return;
|
|
302
|
-
}
|
|
303
|
-
}
|
|
304
|
-
// Spawn Claude Code — stdin is always piped for stream-json prompt delivery
|
|
305
|
-
const proc = spawn(config.claudeCodePath, args, {
|
|
306
|
-
cwd: worktreePath,
|
|
307
|
-
env: spawnEnv,
|
|
308
|
-
stdio: ['pipe', 'pipe', 'pipe'],
|
|
309
|
-
});
|
|
310
|
-
// Track running agent — declared before parser setup so closures can reference it
|
|
311
|
-
const streamParser = new StreamJsonParser();
|
|
312
|
-
const completionDetector = new CompletionDetector();
|
|
313
|
-
const runningAgent = {
|
|
314
|
-
sessionId: session.id,
|
|
315
|
-
roleId: role.id,
|
|
316
|
-
roleName: role.name,
|
|
317
|
-
focusId,
|
|
318
|
-
deliveryId,
|
|
319
|
-
deliveryName: context.delivery.name,
|
|
320
|
-
workflow,
|
|
321
|
-
branchName,
|
|
322
|
-
worktreePath,
|
|
323
|
-
repoPath: config.repoPath,
|
|
324
|
-
pid: proc.pid,
|
|
325
|
-
startedAt: new Date(),
|
|
326
|
-
stdoutPath,
|
|
327
|
-
stderrPath,
|
|
328
|
-
enableTeams: true,
|
|
329
|
-
stdin: proc.stdin,
|
|
330
|
-
streamParser,
|
|
331
|
-
streamState: 'starting',
|
|
332
|
-
};
|
|
333
|
-
runningAgents.set(session.id, runningAgent);
|
|
334
|
-
// Wire up stream parsing, logging, and event tracking
|
|
335
|
-
const activityTracker = attachStreamHandlers({
|
|
336
|
-
proc, streamParser, completionDetector, runningAgent,
|
|
337
|
-
deliveryId, deliveryName: context.delivery.name, branchName,
|
|
338
|
-
stdoutLogStream, jsonlStream, runningAgents,
|
|
339
|
-
});
|
|
340
|
-
// Send the initial prompt via stdin as stream-json
|
|
341
|
-
sendMessage(proc.stdin, prompt);
|
|
342
|
-
// Stderr always pipes directly to log file
|
|
343
|
-
proc.stderr?.pipe(stderrStream);
|
|
344
|
-
// Set up per-agent timeout enforcement
|
|
345
|
-
const { getTimedOut } = setupTimeoutEnforcement(config, runningAgent, context.delivery.name, session.id);
|
|
346
|
-
// Update session with PID
|
|
347
|
-
await updateSession(session.id, {
|
|
348
|
-
status: 'running',
|
|
349
|
-
pid: proc.pid,
|
|
350
|
-
});
|
|
351
|
-
// Handle process exit and error — delegates to completion-handler module
|
|
352
|
-
attachProcessHandlers({
|
|
353
|
-
proc, config, context: context, runningAgent, workflow,
|
|
354
|
-
branchName, worktreePath, deliveryId,
|
|
355
|
-
sessionId: session.id, completionDetector, activityTracker,
|
|
356
|
-
stdoutLogStream, stderrStream, jsonlStream,
|
|
357
|
-
getTimedOut, runningAgents, governor,
|
|
358
|
-
});
|
|
359
|
-
}
|
|
360
49
|
//# sourceMappingURL=spawner.js.map
|
package/dist/spawner.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"spawner.js","sourceRoot":"","sources":["../src/spawner.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAChD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,kBAAkB,EAAE,sBAAsB,EAAE,qCAAqC,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAChK,OAAO,EAAE,qB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CAAC"}
|
|
@@ -40,6 +40,12 @@ export interface FocusTeamPromptContext {
|
|
|
40
40
|
* "reality-trees-crt-frt-planning-layer".
|
|
41
41
|
*/
|
|
42
42
|
focusDescription?: string | null;
|
|
43
|
+
/**
|
|
44
|
+
* Resolved engine backend id ('claude' | 'codex' | ...). Selects the
|
|
45
|
+
* engine-specific orchestration vocabulary in the lead prompt (how the lead
|
|
46
|
+
* spawns workers). Defaults to 'claude' when absent.
|
|
47
|
+
*/
|
|
48
|
+
engineId?: string;
|
|
43
49
|
}
|
|
44
50
|
/**
|
|
45
51
|
* Build the role context section from the agent role's system prompt template.
|
|
@@ -52,7 +58,7 @@ export declare function buildDomainBoundariesSection(role: AgentRole): string[];
|
|
|
52
58
|
/**
|
|
53
59
|
* Build the team lead role description section.
|
|
54
60
|
*/
|
|
55
|
-
export declare function buildTeamLeadRoleSection(): string[];
|
|
61
|
+
export declare function buildTeamLeadRoleSection(engineId?: string): string[];
|
|
56
62
|
/**
|
|
57
63
|
* Build the read-only audit mode notice section.
|
|
58
64
|
* Returns empty array if not in read-only mode.
|
|
@@ -123,7 +129,7 @@ export declare function buildExecutionInstructionsSection(productId: string): st
|
|
|
123
129
|
* tools do not apply here.
|
|
124
130
|
*/
|
|
125
131
|
export declare function buildSessionConstraintsSection(): string[];
|
|
126
|
-
export declare function buildWorkerManagementSection(maxWorkers: number): string[];
|
|
132
|
+
export declare function buildWorkerManagementSection(maxWorkers: number, engineId?: string): string[];
|
|
127
133
|
/**
|
|
128
134
|
* Build the delivery stage progression section (Phase 3 / TEL-5).
|
|
129
135
|
*/
|
|
@@ -255,6 +261,33 @@ export declare function buildCloseLoopDriftCheckSection(focusDescription: string
|
|
|
255
261
|
* Build the completion section.
|
|
256
262
|
*/
|
|
257
263
|
export declare function buildCompletionSection(): string[];
|
|
264
|
+
/** Inputs for the incremental resume-delta message. */
|
|
265
|
+
export interface ResumeDeltaContext {
|
|
266
|
+
/** Lineage being resumed (e.g. 'coding', 'review'). */
|
|
267
|
+
lineage: string;
|
|
268
|
+
/** Focus name for the framing line. */
|
|
269
|
+
focusName: string;
|
|
270
|
+
/** Assembled git.diff_against_base content (may be empty). */
|
|
271
|
+
gitDiff: string;
|
|
272
|
+
/**
|
|
273
|
+
* Open review-filed issues from the prior cycle. For the review lineage these
|
|
274
|
+
* are findings to re-verify; for coding they are defects to address.
|
|
275
|
+
*/
|
|
276
|
+
priorFindings: FocusIssueInfo[];
|
|
277
|
+
}
|
|
278
|
+
/**
|
|
279
|
+
* Build the incremental delta message sent when a lineage's session is RESUMED
|
|
280
|
+
* (INJ-D). A resumed Claude session already holds its role framework, tools,
|
|
281
|
+
* status rules, and accumulated context -- re-sending the full prompt wastes
|
|
282
|
+
* tokens and re-anchors. The delta carries only what changed since the last
|
|
283
|
+
* cycle (the diff) plus the prior findings, deliberately omitting the
|
|
284
|
+
* role-framework sections.
|
|
285
|
+
*
|
|
286
|
+
* Anti-anchoring: for the review lineage the prior findings are framed as "to
|
|
287
|
+
* VERIFY, not trust" -- the diff and acceptance criteria remain ground truth
|
|
288
|
+
* each cycle, so a resumed reviewer re-examines rather than rubber-stamping.
|
|
289
|
+
*/
|
|
290
|
+
export declare function buildResumeDeltaMessage(ctx: ResumeDeltaContext): string;
|
|
258
291
|
/**
|
|
259
292
|
* Build the role framework prompt -- sections that apply to every stage.
|
|
260
293
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"team-prompt-base.d.ts","sourceRoot":"","sources":["../src/team-prompt-base.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EACV,SAAS,EACT,iBAAiB,EACjB,cAAc,EACd,oBAAoB,EACpB,cAAc,EACf,MAAM,YAAY,CAAC;AACpB,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAG9D,MAAM,WAAW,gCAAgC;IAC/C,IAAI,EAAE,MAAM,CAAC;IACb,eAAe,EAAE,MAAM,GAAG,IAAI,CAAC;IAC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wBAAgB,yBAAyB,IAAI,MAAM,EAAE,CAoBpD;AAED;;;;GAIG;AACH,wBAAgB,2BAA2B,IAAI,MAAM,EAAE,CA8BtD;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,wBAAgB,+BAA+B,IAAI,MAAM,CAuDxD;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,+BAA+B,CAC7C,gBAAgB,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAC1C,MAAM,EAAE,CAqCV;AAED;;GAEG;AACH,wBAAgB,sBAAsB,IAAI,MAAM,EAAE,CAajD;AAMD,uDAAuD;AACvD,MAAM,WAAW,kBAAkB;IACjC,uDAAuD;IACvD,OAAO,EAAE,MAAM,CAAC;IAChB,uCAAuC;IACvC,SAAS,EAAE,MAAM,CAAC;IAClB,8DAA8D;IAC9D,OAAO,EAAE,MAAM,CAAC;IAChB;;;OAGG;IACH,aAAa,EAAE,cAAc,EAAE,CAAC;CACjC;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,uBAAuB,CAAC,GAAG,EAAE,kBAAkB,GAAG,MAAM,CA+CvE;AAMD;;;;;;;;;;GAUG;AACH,wBAAgB,wBAAwB,CACtC,IAAI,EAAE,SAAS,EACf,OAAO,EAAE,sBAAsB,GAC9B,MAAM,CAgCR;AAMD;;;;;;;;;GASG;AACH,wBAAgB,oBAAoB,CAClC,IAAI,EAAE,SAAS,EACf,OAAO,EAAE,sBAAsB,GAC9B,MAAM,CAqCR"}
|
package/dist/team-prompt-base.js
CHANGED
|
@@ -7,6 +7,30 @@
|
|
|
7
7
|
* Extracted from focus-prompt-builder.ts for maintainability.
|
|
8
8
|
*/
|
|
9
9
|
import { isStatusAgentActionable } from './stage-classifier.js';
|
|
10
|
+
function orchestrationVocabulary(engineId) {
|
|
11
|
+
if (engineId === 'codex') {
|
|
12
|
+
return {
|
|
13
|
+
spawnStep: '3. Spawn worker subagents (delegate via the Codex agent tool) for parallelizable work',
|
|
14
|
+
workerMechanism: 'You manage worker execution by spawning worker subagents. Workers are subagents\n' +
|
|
15
|
+
'that execute individual issues.',
|
|
16
|
+
caveat: [
|
|
17
|
+
'',
|
|
18
|
+
'**Codex subagent spawns -- spawn cleanly:**',
|
|
19
|
+
'- Do NOT pass `agent_type`, `model`, or `reasoning_effort` when delegating a',
|
|
20
|
+
' full-history fork: forked agents inherit the parent\'s type/model/effort and',
|
|
21
|
+
' the router rejects the call otherwise. Omit those fields (or spawn without a',
|
|
22
|
+
' full-history fork).',
|
|
23
|
+
],
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
// Default: Claude Code (in-process teammates via the Task tool).
|
|
27
|
+
return {
|
|
28
|
+
spawnStep: '3. Spawn workers (using the Task tool) for parallelizable work',
|
|
29
|
+
workerMechanism: 'You manage worker execution using the Task tool. Workers are subagents\n' +
|
|
30
|
+
'that execute individual issues.',
|
|
31
|
+
caveat: [],
|
|
32
|
+
};
|
|
33
|
+
}
|
|
10
34
|
// ---------------------------------------------------------------------------
|
|
11
35
|
// Section builders -- each produces a string[] of prompt lines for one section
|
|
12
36
|
// ---------------------------------------------------------------------------
|
|
@@ -39,7 +63,8 @@ export function buildDomainBoundariesSection(role) {
|
|
|
39
63
|
/**
|
|
40
64
|
* Build the team lead role description section.
|
|
41
65
|
*/
|
|
42
|
-
export function buildTeamLeadRoleSection() {
|
|
66
|
+
export function buildTeamLeadRoleSection(engineId) {
|
|
67
|
+
const vocab = orchestrationVocabulary(engineId);
|
|
43
68
|
return [
|
|
44
69
|
'## Your Role: Focus Team Lead',
|
|
45
70
|
'',
|
|
@@ -49,7 +74,7 @@ export function buildTeamLeadRoleSection() {
|
|
|
49
74
|
'**Core responsibilities:**',
|
|
50
75
|
'1. Read all deliveries and issues for the focus',
|
|
51
76
|
'2. Build a task execution plan respecting delivery priority and file overlap',
|
|
52
|
-
|
|
77
|
+
vocab.spawnStep,
|
|
53
78
|
'4. Track issue completion and advance delivery stages',
|
|
54
79
|
'5. Poll for new deliveries added during execution',
|
|
55
80
|
'6. Handle errors, escalate blockers, and report progress',
|
|
@@ -535,12 +560,13 @@ export function buildSessionConstraintsSection() {
|
|
|
535
560
|
'',
|
|
536
561
|
];
|
|
537
562
|
}
|
|
538
|
-
export function buildWorkerManagementSection(maxWorkers) {
|
|
563
|
+
export function buildWorkerManagementSection(maxWorkers, engineId) {
|
|
564
|
+
const vocab = orchestrationVocabulary(engineId);
|
|
539
565
|
return [
|
|
540
566
|
'### Phase 2: Worker Management',
|
|
541
567
|
'',
|
|
542
|
-
|
|
543
|
-
|
|
568
|
+
...vocab.workerMechanism.split('\n'),
|
|
569
|
+
...vocab.caveat,
|
|
544
570
|
'',
|
|
545
571
|
'**Spawning workers:**',
|
|
546
572
|
`- Spawn up to ${maxWorkers} workers at a time`,
|
|
@@ -1029,6 +1055,64 @@ export function buildCompletionSection() {
|
|
|
1029
1055
|
'',
|
|
1030
1056
|
];
|
|
1031
1057
|
}
|
|
1058
|
+
/**
|
|
1059
|
+
* Build the incremental delta message sent when a lineage's session is RESUMED
|
|
1060
|
+
* (INJ-D). A resumed Claude session already holds its role framework, tools,
|
|
1061
|
+
* status rules, and accumulated context -- re-sending the full prompt wastes
|
|
1062
|
+
* tokens and re-anchors. The delta carries only what changed since the last
|
|
1063
|
+
* cycle (the diff) plus the prior findings, deliberately omitting the
|
|
1064
|
+
* role-framework sections.
|
|
1065
|
+
*
|
|
1066
|
+
* Anti-anchoring: for the review lineage the prior findings are framed as "to
|
|
1067
|
+
* VERIFY, not trust" -- the diff and acceptance criteria remain ground truth
|
|
1068
|
+
* each cycle, so a resumed reviewer re-examines rather than rubber-stamping.
|
|
1069
|
+
*/
|
|
1070
|
+
export function buildResumeDeltaMessage(ctx) {
|
|
1071
|
+
const isReview = ctx.lineage === 'review';
|
|
1072
|
+
const lines = [];
|
|
1073
|
+
lines.push(`## Resuming Your ${isReview ? 'Review' : 'Work'} Session (Incremental Update)`);
|
|
1074
|
+
lines.push('');
|
|
1075
|
+
lines.push(`You are resuming your prior \`${ctx.lineage}\` session on focus "${ctx.focusName}".`);
|
|
1076
|
+
lines.push('Your role, tools, status-update rules, and the context you accumulated in');
|
|
1077
|
+
lines.push('earlier cycles are intact -- this message is ONLY what changed since your last');
|
|
1078
|
+
lines.push('cycle. Do not restart from scratch and do not re-read the full role framework.');
|
|
1079
|
+
lines.push('The diff below and the acceptance criteria (re-read via MCP if needed) are the');
|
|
1080
|
+
lines.push('ground truth for this cycle.');
|
|
1081
|
+
lines.push('');
|
|
1082
|
+
if (ctx.priorFindings.length > 0) {
|
|
1083
|
+
if (isReview) {
|
|
1084
|
+
lines.push('### Prior findings to VERIFY (do not trust)');
|
|
1085
|
+
lines.push('');
|
|
1086
|
+
lines.push('Last cycle you filed the issues below. Do NOT assume they were fixed.');
|
|
1087
|
+
lines.push('For each, check the diff and the current code to confirm it was actually');
|
|
1088
|
+
lines.push('addressed. If it was genuinely resolved, leave it; if not, keep or refile');
|
|
1089
|
+
lines.push('the issue with the specific remaining gap. Your memory is not evidence --');
|
|
1090
|
+
lines.push('the diff is.');
|
|
1091
|
+
}
|
|
1092
|
+
else {
|
|
1093
|
+
lines.push('### Open items from review to address');
|
|
1094
|
+
lines.push('');
|
|
1095
|
+
lines.push('Review filed the issues below against your prior work. Address each as a');
|
|
1096
|
+
lines.push('defect to fix and confirm the fix in the diff. Do not widen scope.');
|
|
1097
|
+
}
|
|
1098
|
+
lines.push('');
|
|
1099
|
+
for (const f of ctx.priorFindings) {
|
|
1100
|
+
lines.push(`- ${f.key}: ${f.title} (${f.status})`);
|
|
1101
|
+
}
|
|
1102
|
+
lines.push('');
|
|
1103
|
+
}
|
|
1104
|
+
lines.push('### What changed since your last cycle (diff against base)');
|
|
1105
|
+
lines.push('');
|
|
1106
|
+
if (ctx.gitDiff.trim()) {
|
|
1107
|
+
lines.push(ctx.gitDiff.trim());
|
|
1108
|
+
}
|
|
1109
|
+
else {
|
|
1110
|
+
lines.push('_The diff resolver returned no content. Run `git diff` against the');
|
|
1111
|
+
lines.push('integration base yourself to see the current state of the worktree._');
|
|
1112
|
+
}
|
|
1113
|
+
lines.push('');
|
|
1114
|
+
return lines.join('\n');
|
|
1115
|
+
}
|
|
1032
1116
|
// ---------------------------------------------------------------------------
|
|
1033
1117
|
// Role framework prompt (stage-agnostic)
|
|
1034
1118
|
// ---------------------------------------------------------------------------
|
|
@@ -1047,7 +1131,7 @@ export function buildRoleFrameworkPrompt(role, context) {
|
|
|
1047
1131
|
const sections = [
|
|
1048
1132
|
buildRoleSection(role),
|
|
1049
1133
|
buildDomainBoundariesSection(role),
|
|
1050
|
-
buildTeamLeadRoleSection(),
|
|
1134
|
+
buildTeamLeadRoleSection(context.engineId),
|
|
1051
1135
|
buildReadOnlyAuditSection(context.readOnly),
|
|
1052
1136
|
buildFocusContextSection(context),
|
|
1053
1137
|
buildRemediationDirectiveSection(context.reviewFiledOpenCount ?? 0),
|
|
@@ -1055,7 +1139,7 @@ export function buildRoleFrameworkPrompt(role, context) {
|
|
|
1055
1139
|
buildExecutionConfigSection(context.executionConfig),
|
|
1056
1140
|
buildStatusUpdateRulesSection(),
|
|
1057
1141
|
buildSessionConstraintsSection(),
|
|
1058
|
-
buildWorkerManagementSection(context.executionConfig.maxWorkers),
|
|
1142
|
+
buildWorkerManagementSection(context.executionConfig.maxWorkers, context.engineId),
|
|
1059
1143
|
buildDeliveryStageProgressionSection(),
|
|
1060
1144
|
buildScopingMandateSection(),
|
|
1061
1145
|
buildRescopingSection(context.focusId, context.productId),
|
|
@@ -1091,7 +1175,7 @@ export function buildFocusTeamPrompt(role, context) {
|
|
|
1091
1175
|
const sections = [
|
|
1092
1176
|
buildRoleSection(role),
|
|
1093
1177
|
buildDomainBoundariesSection(role),
|
|
1094
|
-
buildTeamLeadRoleSection(),
|
|
1178
|
+
buildTeamLeadRoleSection(context.engineId),
|
|
1095
1179
|
buildReadOnlyAuditSection(context.readOnly),
|
|
1096
1180
|
buildFocusContextSection(context),
|
|
1097
1181
|
buildRemediationDirectiveSection(context.reviewFiledOpenCount ?? 0),
|
|
@@ -1103,7 +1187,7 @@ export function buildFocusTeamPrompt(role, context) {
|
|
|
1103
1187
|
buildDeliveryListingSection(context.deliveries, context.issues),
|
|
1104
1188
|
buildStatusUpdateRulesSection(),
|
|
1105
1189
|
buildExecutionInstructionsSection(context.productId),
|
|
1106
|
-
buildWorkerManagementSection(context.executionConfig.maxWorkers),
|
|
1190
|
+
buildWorkerManagementSection(context.executionConfig.maxWorkers, context.engineId),
|
|
1107
1191
|
buildDeliveryStageProgressionSection(),
|
|
1108
1192
|
buildScopingMandateSection(),
|
|
1109
1193
|
buildRescopingSection(context.focusId, context.productId),
|