@telora/daemon 0.15.3 → 0.15.5

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.
Files changed (115) hide show
  1. package/build-info.json +2 -2
  2. package/dist/directive-executor.d.ts +18 -3
  3. package/dist/directive-executor.d.ts.map +1 -1
  4. package/dist/directive-executor.js +45 -4
  5. package/dist/directive-executor.js.map +1 -1
  6. package/dist/focus-completion.js +12 -12
  7. package/dist/focus-completion.js.map +1 -1
  8. package/dist/focus-executor.d.ts.map +1 -1
  9. package/dist/focus-executor.js +30 -13
  10. package/dist/focus-executor.js.map +1 -1
  11. package/dist/focus-phase.d.ts +22 -0
  12. package/dist/focus-phase.d.ts.map +1 -0
  13. package/dist/focus-phase.js +54 -0
  14. package/dist/focus-phase.js.map +1 -0
  15. package/dist/focus-team-state.d.ts +6 -0
  16. package/dist/focus-team-state.d.ts.map +1 -1
  17. package/dist/focus-team-state.js +13 -0
  18. package/dist/focus-team-state.js.map +1 -1
  19. package/dist/index.js +0 -0
  20. package/dist/listener.d.ts.map +1 -1
  21. package/dist/listener.js +0 -5
  22. package/dist/listener.js.map +1 -1
  23. package/dist/queries/focuses.d.ts +5 -0
  24. package/dist/queries/focuses.d.ts.map +1 -1
  25. package/dist/queries/focuses.js +15 -0
  26. package/dist/queries/focuses.js.map +1 -1
  27. package/dist/review-defect-detector.d.ts +16 -95
  28. package/dist/review-defect-detector.d.ts.map +1 -1
  29. package/dist/review-defect-detector.js +19 -211
  30. package/dist/review-defect-detector.js.map +1 -1
  31. package/dist/state-cascade.d.ts +45 -41
  32. package/dist/state-cascade.d.ts.map +1 -1
  33. package/dist/state-cascade.js +123 -215
  34. package/dist/state-cascade.js.map +1 -1
  35. package/package.json +2 -2
  36. package/dist/listener-review.d.ts +0 -37
  37. package/dist/listener-review.d.ts.map +0 -1
  38. package/dist/listener-review.js +0 -217
  39. package/dist/listener-review.js.map +0 -1
  40. package/dist/queries/strategies.d.ts +0 -97
  41. package/dist/queries/strategies.d.ts.map +0 -1
  42. package/dist/queries/strategies.js +0 -136
  43. package/dist/queries/strategies.js.map +0 -1
  44. package/dist/review-spawner.d.ts +0 -32
  45. package/dist/review-spawner.d.ts.map +0 -1
  46. package/dist/review-spawner.js +0 -170
  47. package/dist/review-spawner.js.map +0 -1
  48. package/dist/strategy-completion-event.d.ts +0 -63
  49. package/dist/strategy-completion-event.d.ts.map +0 -1
  50. package/dist/strategy-completion-event.js +0 -138
  51. package/dist/strategy-completion-event.js.map +0 -1
  52. package/dist/strategy-completion.d.ts +0 -85
  53. package/dist/strategy-completion.d.ts.map +0 -1
  54. package/dist/strategy-completion.js +0 -459
  55. package/dist/strategy-completion.js.map +0 -1
  56. package/dist/strategy-engine.d.ts +0 -47
  57. package/dist/strategy-engine.d.ts.map +0 -1
  58. package/dist/strategy-engine.js +0 -421
  59. package/dist/strategy-engine.js.map +0 -1
  60. package/dist/strategy-executor.d.ts +0 -55
  61. package/dist/strategy-executor.d.ts.map +0 -1
  62. package/dist/strategy-executor.js +0 -519
  63. package/dist/strategy-executor.js.map +0 -1
  64. package/dist/strategy-lifecycle.d.ts +0 -61
  65. package/dist/strategy-lifecycle.d.ts.map +0 -1
  66. package/dist/strategy-lifecycle.js +0 -544
  67. package/dist/strategy-lifecycle.js.map +0 -1
  68. package/dist/strategy-merge.d.ts +0 -77
  69. package/dist/strategy-merge.d.ts.map +0 -1
  70. package/dist/strategy-merge.js +0 -378
  71. package/dist/strategy-merge.js.map +0 -1
  72. package/dist/strategy-prompt-builder.d.ts +0 -24
  73. package/dist/strategy-prompt-builder.d.ts.map +0 -1
  74. package/dist/strategy-prompt-builder.js +0 -87
  75. package/dist/strategy-prompt-builder.js.map +0 -1
  76. package/dist/strategy-provisioning.d.ts +0 -16
  77. package/dist/strategy-provisioning.d.ts.map +0 -1
  78. package/dist/strategy-provisioning.js +0 -119
  79. package/dist/strategy-provisioning.js.map +0 -1
  80. package/dist/strategy-spawn-helpers.d.ts +0 -67
  81. package/dist/strategy-spawn-helpers.d.ts.map +0 -1
  82. package/dist/strategy-spawn-helpers.js +0 -160
  83. package/dist/strategy-spawn-helpers.js.map +0 -1
  84. package/dist/strategy-team-lifecycle.d.ts +0 -50
  85. package/dist/strategy-team-lifecycle.d.ts.map +0 -1
  86. package/dist/strategy-team-lifecycle.js +0 -256
  87. package/dist/strategy-team-lifecycle.js.map +0 -1
  88. package/dist/strategy-team-state.d.ts +0 -24
  89. package/dist/strategy-team-state.d.ts.map +0 -1
  90. package/dist/strategy-team-state.js +0 -43
  91. package/dist/strategy-team-state.js.map +0 -1
  92. package/dist/strategy-teardown.d.ts +0 -24
  93. package/dist/strategy-teardown.d.ts.map +0 -1
  94. package/dist/strategy-teardown.js +0 -158
  95. package/dist/strategy-teardown.js.map +0 -1
  96. package/dist/strategy-worktree-state.d.ts +0 -47
  97. package/dist/strategy-worktree-state.d.ts.map +0 -1
  98. package/dist/strategy-worktree-state.js +0 -104
  99. package/dist/strategy-worktree-state.js.map +0 -1
  100. package/dist/team-prompt-variants.d.ts +0 -17
  101. package/dist/team-prompt-variants.d.ts.map +0 -1
  102. package/dist/team-prompt-variants.js +0 -79
  103. package/dist/team-prompt-variants.js.map +0 -1
  104. package/dist/types/strategy.d.ts +0 -180
  105. package/dist/types/strategy.d.ts.map +0 -1
  106. package/dist/types/strategy.js +0 -5
  107. package/dist/types/strategy.js.map +0 -1
  108. package/dist/worktree-merge.d.ts +0 -23
  109. package/dist/worktree-merge.d.ts.map +0 -1
  110. package/dist/worktree-merge.js +0 -57
  111. package/dist/worktree-merge.js.map +0 -1
  112. package/dist/worktree-strategy.d.ts +0 -69
  113. package/dist/worktree-strategy.d.ts.map +0 -1
  114. package/dist/worktree-strategy.js +0 -214
  115. package/dist/worktree-strategy.js.map +0 -1
@@ -1,119 +0,0 @@
1
- /**
2
- * Persistent worktree provisioning for active strategies.
3
- *
4
- * Creates worktrees for active strategies that don't have one yet,
5
- * adopts existing worktrees on disk, and rebases onto integration.
6
- */
7
- import { existsSync } from 'node:fs';
8
- import { join } from 'node:path';
9
- import { installAuditPreCommitHook } from './audit-hooks.js';
10
- import { getReadyStrategies } from './supabase.js';
11
- import { createWorktree, syncIntegrationWithMain, runGitSync, generateMcpConfigInWorktree } from './git.js';
12
- import { symlinkEnvFiles } from './qa-provisioner.js';
13
- import { generateStrategyBranchName } from './strategy-executor.js';
14
- import { setStrategyWorktree, hasStrategyWorktree, } from './strategy-worktree-state.js';
15
- /**
16
- * Ensure persistent worktrees exist for all active strategies.
17
- *
18
- * Called each poll cycle BEFORE processReadyStrategies(). Creates
19
- * worktrees for active strategies that don't have one yet.
20
- * Syncs integration with main once per cycle (not per strategy).
21
- */
22
- export async function ensureStrategyWorktrees(config, roles) {
23
- let readyStrategies;
24
- try {
25
- readyStrategies = await getReadyStrategies(config.organizationId, config.productId);
26
- }
27
- catch (err) {
28
- console.warn(`[strategy-lifecycle] Failed to query ready strategies for worktree provisioning: ${err.message}`);
29
- return;
30
- }
31
- // Find strategies that need worktrees
32
- const needsWorktree = readyStrategies.filter(s => !hasStrategyWorktree(s.strategy_id));
33
- if (needsWorktree.length === 0)
34
- return;
35
- // Sync integration with main once before creating any worktrees
36
- try {
37
- const syncResult = await syncIntegrationWithMain(config);
38
- if (syncResult.success) {
39
- console.log(`[strategy-lifecycle] Synced integration with main before worktree provisioning`);
40
- }
41
- else {
42
- console.warn(`[strategy-lifecycle] Could not sync integration with main: ${syncResult.error}`);
43
- }
44
- }
45
- catch (err) {
46
- console.warn(`[strategy-lifecycle] Sync failed (continuing): ${err instanceof Error ? err.message : String(err)}`);
47
- }
48
- for (const strategy of needsWorktree) {
49
- const role = roles.get(strategy.assigned_agent_role_id);
50
- if (!role) {
51
- console.warn(`[strategy-lifecycle] Unknown agent role ${strategy.assigned_agent_role_id} for strategy "${strategy.strategy_name}", skipping worktree`);
52
- continue;
53
- }
54
- const branchName = generateStrategyBranchName(role, strategy.strategy_name, strategy.strategy_id);
55
- const worktreePath = join(config.worktreeDir, branchName.replace(/\//g, '-'));
56
- // Check if a valid worktree already exists on disk (e.g., after daemon restart
57
- // or reactivation). Adopt it instead of destroying and rebuilding.
58
- if (existsSync(worktreePath)) {
59
- const gitDirResult = runGitSync(['rev-parse', '--git-dir'], worktreePath);
60
- const branchResult = runGitSync(['rev-parse', '--abbrev-ref', 'HEAD'], worktreePath);
61
- if (gitDirResult.success && branchResult.success && branchResult.output === branchName) {
62
- // Valid worktree on the expected branch -- adopt it
63
- console.log(`[strategy-lifecycle] Adopting existing worktree for "${strategy.strategy_name}": ${worktreePath}`);
64
- setStrategyWorktree(strategy.strategy_id, {
65
- strategyId: strategy.strategy_id,
66
- strategyName: strategy.strategy_name,
67
- worktreePath,
68
- branchName,
69
- createdAt: new Date(),
70
- hasQaDevServer: false,
71
- });
72
- // Rebase onto integration to bring it current
73
- const rebaseResult = runGitSync(['rebase', config.integrationBranch], worktreePath);
74
- if (!rebaseResult.success) {
75
- runGitSync(['rebase', '--abort'], worktreePath);
76
- console.warn(`[strategy-lifecycle] Could not rebase adopted worktree for "${strategy.strategy_name}" onto integration. Continuing with existing state.`);
77
- }
78
- else {
79
- console.log(`[strategy-lifecycle] Rebased adopted worktree for "${strategy.strategy_name}" onto ${config.integrationBranch}`);
80
- }
81
- // Symlink env files and generate .mcp.json in worktree
82
- symlinkEnvFiles(config.repoPath, worktreePath);
83
- generateMcpConfigInWorktree(worktreePath, config);
84
- // Install audit pre-commit hook for read-only strategies
85
- if (strategy.read_only) {
86
- installAuditPreCommitHook(worktreePath);
87
- console.log(`[strategy-lifecycle] Installed audit pre-commit hook for "${strategy.strategy_name}"`);
88
- }
89
- continue;
90
- }
91
- // Directory exists but is not a valid worktree for this branch -- fall through to createWorktree
92
- console.log(`[strategy-lifecycle] Existing directory at ${worktreePath} is not a valid worktree for ${branchName}, recreating`);
93
- }
94
- try {
95
- const createdPath = await createWorktree(config, branchName);
96
- setStrategyWorktree(strategy.strategy_id, {
97
- strategyId: strategy.strategy_id,
98
- strategyName: strategy.strategy_name,
99
- worktreePath: createdPath,
100
- branchName,
101
- createdAt: new Date(),
102
- hasQaDevServer: false,
103
- });
104
- console.log(`[strategy-lifecycle] Created persistent worktree for "${strategy.strategy_name}": ${createdPath}`);
105
- // Symlink env files from main repo into worktree
106
- symlinkEnvFiles(config.repoPath, createdPath);
107
- // Install audit pre-commit hook for read-only strategies
108
- if (strategy.read_only) {
109
- installAuditPreCommitHook(createdPath);
110
- console.log(`[strategy-lifecycle] Installed audit pre-commit hook for "${strategy.strategy_name}"`);
111
- }
112
- }
113
- catch (err) {
114
- console.error(`[strategy-lifecycle] Failed to create worktree for "${strategy.strategy_name}": ${err instanceof Error ? err.message : String(err)}`);
115
- // Continue with other strategies
116
- }
117
- }
118
- }
119
- //# sourceMappingURL=strategy-provisioning.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"strategy-provisioning.js","sourceRoot":"","sources":["../src/strategy-provisioning.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,OAAO,EAAE,yBAAyB,EAAE,MAAM,kBAAkB,CAAC;AAC7D,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AACnD,OAAO,EAAE,cAAc,EAAE,uBAAuB,EAAE,UAAU,EAAE,2BAA2B,EAAE,MAAM,UAAU,CAAC;AAC5G,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAE,0BAA0B,EAAE,MAAM,wBAAwB,CAAC;AACpE,OAAO,EACL,mBAAmB,EACnB,mBAAmB,GACpB,MAAM,8BAA8B,CAAC;AAEtC;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,uBAAuB,CAC3C,MAAoB,EACpB,KAA6B;IAE7B,IAAI,eAAe,CAAC;IACpB,IAAI,CAAC;QACH,eAAe,GAAG,MAAM,kBAAkB,CAAC,MAA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,CAAC,CAAC;YACtG,CAAC;QACH,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,OAAO,CAAC,KAAK,CAAC,uDAAuD,QAAQ,CAAC,aAAa,MAAM,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;YACrJ,iCAAiC;QACnC,CAAC;IACH,CAAC;AACH,CAAC"}
@@ -1,67 +0,0 @@
1
- /**
2
- * Strategy spawn helpers - log streams, stream handlers, and process close handling.
3
- *
4
- * Extracted from strategy-executor.ts. These are internal helpers used by
5
- * spawnStrategyTeam() -- not a public API surface.
6
- */
7
- import type { ChildProcess } from 'node:child_process';
8
- import { createWriteStream } from 'node:fs';
9
- import type { DaemonConfig, StrategyTeamState } from './types.js';
10
- import { CompletionDetector } from './completion-detector.js';
11
- import { ActivityTracker } from './activity-tracker.js';
12
- import type { SpawnStrategyTeamParams } from './strategy-executor.js';
13
- import type { ResourceGovernor } from '@telora/daemon-core';
14
- export interface TeamLogStreams {
15
- stdoutPath: string;
16
- stderrPath: string;
17
- jsonlPath: string;
18
- stdoutLogStream: ReturnType<typeof createWriteStream>;
19
- stderrStream: ReturnType<typeof createWriteStream>;
20
- jsonlStream: ReturnType<typeof createWriteStream>;
21
- }
22
- export interface AttachStreamHandlersParams {
23
- proc: ChildProcess;
24
- teamState: StrategyTeamState;
25
- strategyId: string;
26
- strategyName: string;
27
- sessionId: string;
28
- logs: TeamLogStreams;
29
- }
30
- export interface AttachStreamHandlersResult {
31
- completionDetector: CompletionDetector;
32
- activityTracker: ActivityTracker;
33
- }
34
- export interface HandleTeamProcessCloseParams {
35
- code: number | null;
36
- signal: string | null;
37
- strategyName: string;
38
- strategyId: string;
39
- resumeId: string | null;
40
- spawnedAt: number;
41
- teamState: StrategyTeamState;
42
- sessionId: string;
43
- config: DaemonConfig;
44
- completionDetector: CompletionDetector;
45
- activityTracker: ActivityTracker;
46
- logs: TeamLogStreams;
47
- params: SpawnStrategyTeamParams;
48
- governor: ResourceGovernor | null;
49
- spawnStrategyTeam: (params: SpawnStrategyTeamParams) => Promise<void>;
50
- }
51
- /**
52
- * Create log file paths and writable streams for a team's output.
53
- */
54
- export declare function setupTeamLogStreams(logDir: string, branchName: string, strategyName: string): TeamLogStreams;
55
- /**
56
- * Attach stream parser, completion detector, activity tracker, and event
57
- * handlers to the spawned team lead process.
58
- */
59
- export declare function attachStreamHandlers(params: AttachStreamHandlersParams): AttachStreamHandlersResult;
60
- /**
61
- * Handle the team lead process 'close' event.
62
- *
63
- * Detects --resume failures and retries without resume, otherwise
64
- * runs normal cleanup (governor release, stream close, completion handling).
65
- */
66
- export declare function handleTeamProcessClose(ctx: HandleTeamProcessCloseParams): Promise<void>;
67
- //# sourceMappingURL=strategy-spawn-helpers.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"strategy-spawn-helpers.d.ts","sourceRoot":"","sources":["../src/strategy-spawn-helpers.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAE5C,OAAO,KAAK,EACV,YAAY,EACZ,iBAAiB,EAClB,MAAM,YAAY,CAAC;AAMpB,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAC9D,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAIxD,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AACtE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAI5D,MAAM,WAAW,cAAc;IAC7B,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,eAAe,EAAE,UAAU,CAAC,OAAO,iBAAiB,CAAC,CAAC;I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CAwDnG;AAED;;;;;GAKG;AACH,wBAAsB,sBAAsB,CAAC,GAAG,EAAE,4BAA4B,GAAG,OAAO,CAAC,IAAI,CAAC,CAmE7F"}
@@ -1,160 +0,0 @@
1
- /**
2
- * Strategy spawn helpers - log streams, stream handlers, and process close handling.
3
- *
4
- * Extracted from strategy-executor.ts. These are internal helpers used by
5
- * spawnStrategyTeam() -- not a public API surface.
6
- */
7
- import { createWriteStream } from 'node:fs';
8
- import { join } from 'node:path';
9
- import { updateSession, } from './supabase.js';
10
- import { StreamJsonParser, formatEventForLog } from '@telora/daemon-core';
11
- import { recordActivity, setNarration } from './heartbeat.js';
12
- import { CompletionDetector } from './completion-detector.js';
13
- import { ActivityTracker } from './activity-tracker.js';
14
- import { getActiveTeams } from './strategy-team-state.js';
15
- import { handleTeamCompletion } from './strategy-completion.js';
16
- import { updateStrategyClaudeSessionId } from './queries/strategies.js';
17
- // ── Functions ───────────────────────────────────────────────────────────
18
- /**
19
- * Create log file paths and writable streams for a team's output.
20
- */
21
- export function setupTeamLogStreams(logDir, branchName, strategyName) {
22
- const timestamp = new Date().toISOString().replace(/[:.]/g, '-');
23
- const logPrefix = `strategy-${branchName.replace(/\//g, '-')}-${timestamp}`;
24
- const stdoutPath = join(logDir, `${logPrefix}.stdout.log`);
25
- const stderrPath = join(logDir, `${logPrefix}.stderr.log`);
26
- const jsonlPath = join(logDir, `${logPrefix}.stream.jsonl`);
27
- const stdoutLogStream = createWriteStream(stdoutPath, { mode: 0o600 });
28
- const stderrStream = createWriteStream(stderrPath, { mode: 0o600 });
29
- const jsonlStream = createWriteStream(jsonlPath, { mode: 0o600 });
30
- // Attach error handlers to prevent unhandled 'error' events from crashing the daemon
31
- stdoutLogStream.on('error', (err) => {
32
- console.warn(`[strategy-executor] stdout log stream error for "${strategyName}": ${err.message}`);
33
- });
34
- stderrStream.on('error', (err) => {
35
- console.warn(`[strategy-executor] stderr log stream error for "${strategyName}": ${err.message}`);
36
- });
37
- jsonlStream.on('error', (err) => {
38
- console.warn(`[strategy-executor] jsonl log stream error for "${strategyName}": ${err.message}`);
39
- });
40
- return { stdoutPath, stderrPath, jsonlPath, stdoutLogStream, stderrStream, jsonlStream };
41
- }
42
- /**
43
- * Attach stream parser, completion detector, activity tracker, and event
44
- * handlers to the spawned team lead process.
45
- */
46
- export function attachStreamHandlers(params) {
47
- const { proc, teamState, strategyId, strategyName, sessionId, logs } = params;
48
- const streamParser = new StreamJsonParser();
49
- const completionDetector = new CompletionDetector();
50
- streamParser.attach(proc.stdout);
51
- completionDetector.attach(streamParser);
52
- teamState.completionDetector = completionDetector;
53
- // Attach activity tracker for live activity snapshots
54
- const activityTracker = new ActivityTracker(sessionId);
55
- activityTracker.onNarration((text) => setNarration(strategyId, text));
56
- activityTracker.attach(streamParser);
57
- // Write raw NDJSON lines to jsonl log file
58
- streamParser.on('event', (event) => {
59
- logs.jsonlStream.write(JSON.stringify(event) + '\n');
60
- });
61
- // Write human-readable lines to stdout log
62
- streamParser.on('event', (event) => {
63
- const line = formatEventForLog(event);
64
- if (line) {
65
- logs.stdoutLogStream.write(line + '\n');
66
- }
67
- });
68
- // Track session state from stream events
69
- streamParser.on('init', (event) => {
70
- console.log(` [strategy-team] Session initialized (model: ${event.model}, tools: ${event.tools.length})`);
71
- teamState.claudeSessionId = event.session_id;
72
- // Persist session ID for --resume support on re-spawn
73
- updateStrategyClaudeSessionId(strategyId, event.session_id).catch((err) => {
74
- console.warn(`[strategy-executor] Failed to persist Claude session ID for "${strategyName}":`, err.message);
75
- });
76
- });
77
- streamParser.on('teammate', (event) => {
78
- if (event.subtype === 'teammate_spawned') {
79
- console.log(` [strategy-team] Worker spawned: ${event.agent_name}`);
80
- }
81
- else if (event.subtype === 'teammate_completed') {
82
- const status = event.is_error ? 'FAILED' : 'completed';
83
- console.log(` [strategy-team] Worker ${status}: ${event.agent_name}`);
84
- }
85
- });
86
- streamParser.on('result', (result) => {
87
- const cost = result.total_cost_usd?.toFixed(4) ?? '?';
88
- console.log(` [strategy-team] Result: ${result.is_error ? 'ERROR' : 'Success'}: ${result.num_turns} turns, $${cost}`);
89
- });
90
- // Stderr pipes to log
91
- proc.stderr?.pipe(logs.stderrStream);
92
- return { completionDetector, activityTracker };
93
- }
94
- /**
95
- * Handle the team lead process 'close' event.
96
- *
97
- * Detects --resume failures and retries without resume, otherwise
98
- * runs normal cleanup (governor release, stream close, completion handling).
99
- */
100
- export async function handleTeamProcessClose(ctx) {
101
- const { code, signal, strategyName, strategyId, resumeId, spawnedAt, teamState, sessionId, config: cfg, completionDetector, activityTracker, logs, params: spawnParams, governor, spawnStrategyTeam: spawnFn, } = ctx;
102
- const activeTeams = getActiveTeams();
103
- console.log(`[strategy-executor] Team lead for "${strategyName}" exited (code: ${code}, signal: ${signal})`);
104
- // Detect --resume failure: if the process exits quickly with a non-zero
105
- // code and --resume was used, retry without resume.
106
- const RESUME_FAILURE_THRESHOLD_MS = 15_000;
107
- const elapsedMs = Date.now() - spawnedAt;
108
- if (resumeId && code !== 0 && code !== null && elapsedMs < RESUME_FAILURE_THRESHOLD_MS) {
109
- console.warn(`[strategy-executor] Resume failed for "${strategyName}" (exited in ${elapsedMs}ms), retrying without resume`);
110
- // Release governor slot and clean up minimal state
111
- governor?.releaseSlot('strategy');
112
- completionDetector.destroy();
113
- logs.stdoutLogStream.end();
114
- logs.stderrStream.end();
115
- logs.jsonlStream.end();
116
- // Clean up session and team state
117
- try {
118
- await updateSession(sessionId, {
119
- status: 'failed',
120
- exit_reason: `Resume failed (code ${code}), retrying without resume`,
121
- exit_category: 'internal',
122
- ended_at: new Date().toISOString(),
123
- });
124
- }
125
- catch (updateErr) {
126
- console.warn('[strategy-executor] Failed to update session after resume failure:', updateErr.message);
127
- }
128
- teamState.phase = 'terminated';
129
- activeTeams.delete(strategyId);
130
- // Re-spawn without --resume
131
- await spawnFn({ ...spawnParams, lastClaudeSessionId: null });
132
- return;
133
- }
134
- // Release governor slot (if governor is configured)
135
- governor?.releaseSlot('strategy');
136
- // Null out stdin so post-exit merge logic falls through to the
137
- // fallback resolution agent instead of sending messages to a dead process.
138
- teamState.leadStdin = null;
139
- // Final activity flush before cleanup
140
- try {
141
- await activityTracker.finalFlush();
142
- }
143
- catch (err) {
144
- console.warn('[strategy-executor] activityTracker.finalFlush failed:', err.message);
145
- }
146
- // Clean up streams
147
- completionDetector.destroy();
148
- logs.stdoutLogStream.end();
149
- logs.stderrStream.end();
150
- logs.jsonlStream.end();
151
- recordActivity();
152
- await handleTeamCompletion({
153
- config: cfg,
154
- teamState,
155
- sessionId,
156
- code,
157
- signal,
158
- });
159
- }
160
- //# sourceMappingURL=strategy-spawn-helpers.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"strategy-spawn-helpers.js","sourceRoot":"","sources":["../src/strategy-spawn-helpers.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAC5C,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAKjC,OAAO,EACL,aAAa,GACd,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAC1E,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9D,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAC9D,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAChE,OAAO,EAAE,6BAA6B,EAAE,MAAM,yBAAyB,CAAC;AA+CxE,2EAA2E;AAE3E;;GAEG;AACH,MAAM,UAAU,mBAAmB,CAAC,MAAc,EAAE,UAAkB,EAAE,YAAoB;IAC1F,MAAM,SAAS,GAAG,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC,OAAO,CA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;QACT,SAAS;QACT,IAAI;QACJ,MAAM;KACP,CAAC,CAAC;AACL,CAAC"}
@@ -1,50 +0,0 @@
1
- /**
2
- * Strategy team lifecycle management - terminate, wait, detect deactivated.
3
- *
4
- * Extracted from strategy-executor.ts. These functions manage the lifecycle
5
- * of running strategy teams (shutdown, deactivation detection, merge checks).
6
- */
7
- import type { DaemonConfig } from './types.js';
8
- /**
9
- * Terminate a strategy team.
10
- *
11
- * Sends a deactivation message via stdin (if open) before SIGTERM
12
- * to allow the team lead to process the shutdown gracefully.
13
- */
14
- export declare function terminateTeam(strategyId: string): boolean;
15
- /**
16
- * Wait for a team's process to exit (leave activeTeams).
17
- *
18
- * Polls activeTeams until the strategy is no longer present,
19
- * which happens when handleTeamCompletion runs on the 'close' event.
20
- * If the timeout expires, sends SIGKILL and waits briefly.
21
- *
22
- * @param strategyId - Strategy to wait for
23
- * @param timeoutMs - Max wait time in ms (default 30s)
24
- * @returns true if team exited within timeout, false if forced
25
- */
26
- export declare function waitForTeamExit(strategyId: string, timeoutMs?: number): Promise<boolean>;
27
- /**
28
- * Terminate all active teams.
29
- */
30
- export declare function terminateAllTeams(): void;
31
- /**
32
- * Detect strategies that have been deactivated (agent role removed)
33
- * and shut down their active teams.
34
- */
35
- export declare function detectDeactivatedStrategies(config: DaemonConfig): Promise<void>;
36
- /**
37
- * Check active teams for newly completed deliveries and merge
38
- * the strategy branch to integration incrementally.
39
- *
40
- * Called from the poll loop. For each active team, queries delivery
41
- * statuses and triggers a merge when any delivery reaches verify/done
42
- * that hasn't already been merged mid-flight.
43
- *
44
- * After processing merges, checks if ALL active deliveries are terminal
45
- * and merged. If so, terminates the team proactively since no more work
46
- * remains. The strategy stays active in the DB -- if new deliveries
47
- * arrive later, the next poll cycle spawns a fresh team.
48
- */
49
- export declare function checkAndMergeCompletedDeliveries(config: DaemonConfig): Promise<void>;
50
- //# sourceMappingURL=strategy-team-lifecycle.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"strategy-team-lifecycle.d.ts","sourceRoot":"","sources":["../src/strategy-team-lifecycle.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAgB/C;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CA2CzD;AAED;;;;;;;;;;GAUG;AACH,wBAAsB,eAAe,CAAC,UAAU,EAAE,MAAM,EAAE,SAAS,SAAQ,GAAG,OAAO,CAAC,OAAO,CAAC,CAsB7F;AAED;;GAEG;AACH,wBAAgB,iBAAiB,IAAI,IAAI,CAKxC;AAED;;;GAGG;AACH,wBAAsB,2BAA2B,CAC/C,MAAM,EAAE,YAAY,GACnB,OAAO,CAAC,IAAI,CAAC,CAyBf;AAED;;;;;;;;;;;;GAYG;AACH,wBAAsB,gCAAgC,CACpD,MAAM,EAAE,YAAY,GACnB,OAAO,CAAC,IAAI,CAAC,CAqIf"}