@askexenow/exe-os 0.9.263 → 0.9.265

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 (148) hide show
  1. package/deploy/stack-manifests/v0.9.json +1 -1
  2. package/dist/backfill-metadata-WM46YQZL.js +597 -0
  3. package/dist/bin/agentic-ontology-backfill.js +1 -1
  4. package/dist/bin/agentic-reflection-backfill.js +1 -1
  5. package/dist/bin/agentic-semantic-label.js +1 -1
  6. package/dist/bin/backfill-conversations.js +1 -1
  7. package/dist/bin/backfill-responses.js +1 -1
  8. package/dist/bin/backfill-vectors.js +2 -2
  9. package/dist/bin/bulk-sync-postgres.js +1 -1
  10. package/dist/bin/cleanup-stale-review-tasks.js +2 -2
  11. package/dist/bin/cli.js +5 -5
  12. package/dist/bin/exe-assign.js +1 -1
  13. package/dist/bin/exe-boot.js +3 -3
  14. package/dist/bin/exe-dispatch.js +2 -2
  15. package/dist/bin/exe-doctor.js +1 -1
  16. package/dist/bin/exe-export-behaviors.js +2 -2
  17. package/dist/bin/exe-forget.js +3 -3
  18. package/dist/bin/exe-gateway.js +5 -5
  19. package/dist/bin/exe-heartbeat.js +3 -3
  20. package/dist/bin/exe-kill.js +3 -3
  21. package/dist/bin/exe-launch-agent.js +3 -3
  22. package/dist/bin/exe-pending-messages.js +3 -3
  23. package/dist/bin/exe-pending-notifications.js +2 -2
  24. package/dist/bin/exe-pending-reviews.js +6 -4
  25. package/dist/bin/exe-review.js +3 -3
  26. package/dist/bin/exe-search.js +2 -2
  27. package/dist/bin/exe-session-cleanup.js +5 -5
  28. package/dist/bin/exe-start-codex.js +1 -1
  29. package/dist/bin/exe-start-opencode.js +1 -1
  30. package/dist/bin/exe-status.js +3 -3
  31. package/dist/bin/exe-support.js +1 -1
  32. package/dist/bin/exe-team.js +1 -1
  33. package/dist/bin/git-sweep.js +2 -2
  34. package/dist/bin/graph-backfill.js +1 -1
  35. package/dist/bin/graph-export.js +2 -2
  36. package/dist/bin/import-history.js +2 -2
  37. package/dist/bin/intercom-check.js +5 -4
  38. package/dist/bin/mcp-sessions.js +2 -2
  39. package/dist/bin/orchestration-metrics.js +1 -1
  40. package/dist/bin/scan-tasks.js +2 -2
  41. package/dist/bin/shard-migrate.js +1 -1
  42. package/dist/capacity-monitor-FZORNXTA.js +49 -0
  43. package/dist/catchup-brief-PRKHIRWW.js +151 -0
  44. package/dist/chunk-2GU3NYMB.js +813 -0
  45. package/dist/chunk-2VT7Z2E2.js +197 -0
  46. package/dist/chunk-3L6XLN4V.js +1090 -0
  47. package/dist/chunk-3T4PNG5O.js +447 -0
  48. package/dist/chunk-3W324KN7.js +13696 -0
  49. package/dist/{chunk-BJYXHSFN.js → chunk-3X555IGG.js} +1 -1
  50. package/dist/chunk-4IATAIAF.js +89 -0
  51. package/dist/chunk-5M4F2FVD.js +204 -0
  52. package/dist/chunk-5TANMPI4.js +377 -0
  53. package/dist/chunk-67E5WIMW.js +333 -0
  54. package/dist/chunk-6NRJIARA.js +346 -0
  55. package/dist/chunk-6O22GTSE.js +1148 -0
  56. package/dist/chunk-7O5CMDP6.js +1345 -0
  57. package/dist/chunk-7P2JKEO3.js +382 -0
  58. package/dist/chunk-A4UY44T7.js +486 -0
  59. package/dist/chunk-AZHPQGSI.js +159 -0
  60. package/dist/chunk-BQAC3GCO.js +127 -0
  61. package/dist/chunk-CIWJRYIC.js +244 -0
  62. package/dist/chunk-CZO2DGGF.js +214 -0
  63. package/dist/chunk-D55SXO3N.js +3951 -0
  64. package/dist/chunk-EPDSRI6O.js +284 -0
  65. package/dist/chunk-EU34R2A3.js +1073 -0
  66. package/dist/chunk-G4KEDLSM.js +488 -0
  67. package/dist/{chunk-235ZCOYB.js → chunk-IBGC6JFX.js} +2 -2
  68. package/dist/chunk-IODP4JNE.js +551 -0
  69. package/dist/chunk-IZ6LCET7.js +58 -0
  70. package/dist/chunk-LPG3U5UW.js +731 -0
  71. package/dist/chunk-NH6TPXZV.js +13696 -0
  72. package/dist/chunk-O5TZI7OZ.js +50 -0
  73. package/dist/chunk-Q3N4KHLM.js +330 -0
  74. package/dist/chunk-QHQTMWYH.js +54 -0
  75. package/dist/chunk-QNYOPM2L.js +1921 -0
  76. package/dist/chunk-SPOA7EOD.js +81 -0
  77. package/dist/chunk-TK23WXKB.js +128 -0
  78. package/dist/chunk-TOVXER6J.js +76 -0
  79. package/dist/chunk-UIPAZYP7.js +171 -0
  80. package/dist/chunk-WXW4GF6M.js +495 -0
  81. package/dist/{chunk-KQNVIDBP.js → chunk-XLYBSXWS.js} +4 -3
  82. package/dist/core-memory-QXMQ5I7S.js +110 -0
  83. package/dist/crm-webhook-CH5W633Y.js +10 -0
  84. package/dist/cto-delegation-gate-XY3NMGTE.js +206 -0
  85. package/dist/daemon-orchestration-LS62JMTI.js +135 -0
  86. package/dist/dreaming-ZBKE2GFX.js +32 -0
  87. package/dist/exe-export-JNSQRIWI.js +73 -0
  88. package/dist/exe-import-AVGWQZLU.js +76 -0
  89. package/dist/exe-key-WR6QEHYO.js +579 -0
  90. package/dist/exe-snapshot-U6K3J6BD.js +164 -0
  91. package/dist/fast-db-init-ZHRRYI7M.js +7 -0
  92. package/dist/gateway/index.js +6 -6
  93. package/dist/git-task-sweep-64KSWRUI.js +40 -0
  94. package/dist/hooks/bug-report-worker.js +4 -4
  95. package/dist/hooks/codex-stop-task-finalizer.js +4 -4
  96. package/dist/hooks/commit-complete.js +4 -4
  97. package/dist/hooks/error-recall.js +2 -2
  98. package/dist/hooks/ingest.js +2 -2
  99. package/dist/hooks/instructions-loaded.js +1 -1
  100. package/dist/hooks/manifest.json +18 -18
  101. package/dist/hooks/notification.js +1 -1
  102. package/dist/hooks/post-compact.js +2 -2
  103. package/dist/hooks/post-tool-combined.js +2 -2
  104. package/dist/hooks/pre-compact.js +3 -3
  105. package/dist/hooks/pre-tool-use.js +6 -6
  106. package/dist/hooks/prompt-submit.js +16 -11
  107. package/dist/hooks/session-end.js +5 -5
  108. package/dist/hooks/session-start.js +6 -6
  109. package/dist/hooks/stop.js +5 -5
  110. package/dist/hooks/subagent-stop.js +2 -2
  111. package/dist/hooks/summary-worker.js +5 -5
  112. package/dist/index.js +9 -9
  113. package/dist/lib/consolidation.js +2 -2
  114. package/dist/lib/exe-daemon.js +17 -17
  115. package/dist/lib/hybrid-search.js +2 -2
  116. package/dist/lib/messaging.js +2 -2
  117. package/dist/lib/schedules.js +2 -2
  118. package/dist/lib/store.js +1 -1
  119. package/dist/lib/tasks.js +3 -3
  120. package/dist/lib/tmux-routing.js +1 -1
  121. package/dist/mcp/register-tools.js +25 -25
  122. package/dist/mcp/server.js +26 -26
  123. package/dist/mcp/tools/create-task.js +4 -4
  124. package/dist/mcp/tools/list-tasks.js +4 -4
  125. package/dist/mcp/tools/send-message.js +3 -3
  126. package/dist/mcp/tools/update-task.js +4 -4
  127. package/dist/notifications-45QSHDFA.js +45 -0
  128. package/dist/orchestrator-7XBMFK7D.js +33 -0
  129. package/dist/pipeline-router-MQKRNCTR.js +13 -0
  130. package/dist/reranker-CJW3UYE2.js +19 -0
  131. package/dist/review-polling-RL75XLAY.js +124 -0
  132. package/dist/runtime/index.js +3 -3
  133. package/dist/session-events-ZULAN4XL.js +36 -0
  134. package/dist/session-scope-V2RSOTDU.js +86 -0
  135. package/dist/skill-refinement-BSX6Q6IN.js +157 -0
  136. package/dist/{support-outbox-SZVLHHZG.js → support-outbox-SO73Q5H2.js} +202 -7
  137. package/dist/task-enforcement-JRTAOYZT.js +333 -0
  138. package/dist/task-scope-GNCB2GAM.js +35 -0
  139. package/dist/tasks-crud-MZIOYF3R.js +77 -0
  140. package/dist/tasks-notify-7KNZ4ULO.js +38 -0
  141. package/dist/tasks-review-U5VEV4Y7.js +47 -0
  142. package/dist/telemetry-upload-BIB5TJA4.js +739 -0
  143. package/dist/tui/App.js +7 -7
  144. package/dist/tui-data-ZSB5DDEY.js +258 -0
  145. package/dist/worker-gate-TXLX33PX.js +21 -0
  146. package/dist/workflow-engine-3PIT3Y56.js +28 -0
  147. package/package.json +1 -1
  148. package/release-notes.json +27 -24
@@ -0,0 +1,284 @@
1
+ import {
2
+ routeTask
3
+ } from "./chunk-6WT44S2W.js";
4
+ import {
5
+ createTaskCore,
6
+ employeeSessionName,
7
+ ensureEmployee,
8
+ getSessionState,
9
+ isEmployeeAlive,
10
+ sessionScopeFilter,
11
+ updateTaskStatus
12
+ } from "./chunk-D55SXO3N.js";
13
+ import {
14
+ DEFAULT_COORDINATOR_TEMPLATE_NAME,
15
+ getCoordinatorName
16
+ } from "./chunk-QQZMP6QL.js";
17
+
18
+ // src/runtime/orchestrator.ts
19
+ var STALE_THRESHOLD_MS = 2 * 60 * 60 * 1e3;
20
+ var MultiAgentOrchestrator = class {
21
+ config;
22
+ constructor(config) {
23
+ this.config = config;
24
+ }
25
+ /**
26
+ * Route and dispatch a single task to the best-fit employee.
27
+ */
28
+ async dispatchTask(task) {
29
+ let targetEmployee;
30
+ let routingScore = 0;
31
+ if (task.assignTo) {
32
+ const found = this.config.employees.find((e) => e.name === task.assignTo);
33
+ if (!found) {
34
+ return {
35
+ employee: task.assignTo,
36
+ sessionName: "",
37
+ status: "failed",
38
+ routingScore: 0,
39
+ error: `Employee "${task.assignTo}" not found`
40
+ };
41
+ }
42
+ targetEmployee = found;
43
+ routingScore = 1;
44
+ } else {
45
+ const routed = await routeTask(
46
+ `${task.title}
47
+ ${task.context}`,
48
+ this.config.employees,
49
+ this.config.embedFn,
50
+ this.config.searchFn
51
+ );
52
+ targetEmployee = routed.employee;
53
+ routingScore = routed.score;
54
+ }
55
+ try {
56
+ await createTaskCore({
57
+ title: task.title,
58
+ assignedTo: targetEmployee.name,
59
+ assignedBy: getCoordinatorName(),
60
+ projectName: task.projectName,
61
+ priority: task.priority,
62
+ context: task.context,
63
+ baseDir: this.config.projectDir,
64
+ skipDispatch: true
65
+ });
66
+ } catch (err) {
67
+ return {
68
+ employee: targetEmployee.name,
69
+ sessionName: "",
70
+ status: "failed",
71
+ routingScore,
72
+ error: `Task creation failed: ${err instanceof Error ? err.message : String(err)}`
73
+ };
74
+ }
75
+ const result = ensureEmployee(
76
+ targetEmployee.name,
77
+ this.config.exeSession,
78
+ this.config.projectDir,
79
+ task.spawnOpts
80
+ );
81
+ return {
82
+ employee: targetEmployee.name,
83
+ sessionName: result.sessionName,
84
+ status: result.status === "failed" ? "failed" : result.status === "spawned" ? "dispatched" : "already_running",
85
+ routingScore,
86
+ error: result.error
87
+ };
88
+ }
89
+ /**
90
+ * Check health of all employees. Detect stuck and idle agents.
91
+ */
92
+ async healthCheck() {
93
+ const { getClient } = await import("./lib/database.js");
94
+ const client = getClient();
95
+ const employees = [];
96
+ const stuckAgents = [];
97
+ const idleAgents = [];
98
+ const crashedSessions = [];
99
+ let totalOpen = 0;
100
+ let totalInProgress = 0;
101
+ for (const emp of this.config.employees) {
102
+ const sessionName = employeeSessionName(emp.name, this.config.exeSession);
103
+ const alive = isEmployeeAlive(sessionName);
104
+ const state = alive ? getSessionState(sessionName) : "offline";
105
+ const oScope = sessionScopeFilter();
106
+ const tasks = await client.execute({
107
+ sql: `SELECT title, status, updated_at FROM tasks
108
+ WHERE assigned_to = ? AND status IN ('open', 'in_progress')${oScope.sql}
109
+ ORDER BY priority ASC`,
110
+ args: [emp.name, ...oScope.args]
111
+ });
112
+ const openCount = tasks.rows.filter((r) => r.status === "open").length;
113
+ const inProgressCount = tasks.rows.filter((r) => r.status === "in_progress").length;
114
+ totalOpen += openCount;
115
+ totalInProgress += inProgressCount;
116
+ const staleTasks = [];
117
+ for (const row of tasks.rows) {
118
+ if (row.status === "in_progress" && row.updated_at) {
119
+ const age = Date.now() - new Date(String(row.updated_at)).getTime();
120
+ if (age > STALE_THRESHOLD_MS) {
121
+ staleTasks.push(String(row.title));
122
+ }
123
+ }
124
+ }
125
+ const crashed = !alive && inProgressCount > 0;
126
+ if (staleTasks.length > 0) {
127
+ stuckAgents.push(emp.name);
128
+ }
129
+ if (crashed) {
130
+ crashedSessions.push(emp.name);
131
+ }
132
+ if (alive && state === "idle" && openCount + inProgressCount === 0) {
133
+ idleAgents.push(emp.name);
134
+ }
135
+ employees.push({
136
+ name: emp.name,
137
+ role: emp.role,
138
+ sessionName,
139
+ alive,
140
+ crashed,
141
+ state,
142
+ taskCount: openCount + inProgressCount,
143
+ inProgressCount,
144
+ staleTasks
145
+ });
146
+ }
147
+ return {
148
+ employees,
149
+ stuckAgents,
150
+ idleAgents,
151
+ crashedSessions,
152
+ totalOpenTasks: totalOpen,
153
+ totalInProgress
154
+ };
155
+ }
156
+ /**
157
+ * Process completed reviews. Auto-approve P2 tasks with passing results.
158
+ */
159
+ async processReviews() {
160
+ const { getClient } = await import("./lib/database.js");
161
+ const client = getClient();
162
+ const autoApproved = [];
163
+ const needsReview = [];
164
+ const coordinatorName = getCoordinatorName();
165
+ const rScope = sessionScopeFilter();
166
+ const reviews = await client.execute({
167
+ sql: `SELECT id, title, assigned_to, priority, result, task_file FROM tasks
168
+ WHERE (assigned_to = ? OR assigned_to = ?)
169
+ AND status IN ('open', 'in_progress')
170
+ AND task_file LIKE '%review-%'${rScope.sql}
171
+ ORDER BY priority ASC
172
+ LIMIT 20`,
173
+ args: [coordinatorName, DEFAULT_COORDINATOR_TEMPLATE_NAME, ...rScope.args]
174
+ });
175
+ for (const row of reviews.rows) {
176
+ const item = {
177
+ taskId: String(row.id),
178
+ title: String(row.title),
179
+ assignedTo: String(row.assigned_to),
180
+ priority: String(row.priority),
181
+ result: String(row.result ?? ""),
182
+ taskFile: String(row.task_file)
183
+ };
184
+ if (this.config.autoApproveP2 && item.priority === "p2" && /tests?\s+pass/i.test(item.result)) {
185
+ try {
186
+ await updateTaskStatus({
187
+ taskId: item.taskId,
188
+ status: "done",
189
+ result: `[auto-approved] ${item.result}`,
190
+ skipReviewCreation: true
191
+ });
192
+ } catch {
193
+ await client.execute({
194
+ sql: `UPDATE tasks SET status = 'done', result = ? WHERE id = ?`,
195
+ args: [`[auto-approved] ${item.result}`, item.taskId]
196
+ });
197
+ }
198
+ autoApproved.push(item);
199
+ } else {
200
+ needsReview.push(item);
201
+ }
202
+ }
203
+ return {
204
+ autoApproved,
205
+ needsReview,
206
+ processed: autoApproved.length + needsReview.length
207
+ };
208
+ }
209
+ /**
210
+ * Run one full orchestration cycle: health check + process reviews.
211
+ * Does NOT dispatch tasks — call dispatchTask() explicitly.
212
+ */
213
+ async tick() {
214
+ const health = await this.healthCheck();
215
+ const reviews = await this.processReviews();
216
+ for (const stuck of health.stuckAgents) {
217
+ const sessionName = employeeSessionName(stuck, this.config.exeSession);
218
+ if (isEmployeeAlive(sessionName)) {
219
+ const { sendIntercom } = await import("./lib/tmux-routing.js");
220
+ sendIntercom(sessionName);
221
+ }
222
+ }
223
+ for (const crashed of health.crashedSessions) {
224
+ this.recoverSession(crashed);
225
+ }
226
+ return {
227
+ dispatched: [],
228
+ health,
229
+ reviews,
230
+ timestamp: (/* @__PURE__ */ new Date()).toISOString()
231
+ };
232
+ }
233
+ /**
234
+ * Recover a crashed session by spawning a fresh CC session.
235
+ * The new session boots with identity via --system-prompt, finds existing in_progress tasks, and resumes.
236
+ */
237
+ recoverSession(employeeName) {
238
+ const sessionName = employeeSessionName(employeeName, this.config.exeSession);
239
+ const result = ensureEmployee(
240
+ employeeName,
241
+ this.config.exeSession,
242
+ this.config.projectDir
243
+ );
244
+ if (result.status === "failed") {
245
+ return { status: "failed", sessionName, error: result.error };
246
+ }
247
+ return { status: "recovered", sessionName: result.sessionName };
248
+ }
249
+ /**
250
+ * Dispatch a batch of tasks, auto-routing each to the best employee.
251
+ */
252
+ async dispatchBatch(tasks) {
253
+ const results = [];
254
+ for (const task of tasks) {
255
+ const result = await this.dispatchTask(task);
256
+ results.push(result);
257
+ }
258
+ return results;
259
+ }
260
+ /**
261
+ * Get a formatted status summary (matches exe boot brief style).
262
+ */
263
+ async getStatusSummary() {
264
+ const health = await this.healthCheck();
265
+ const lines = [];
266
+ lines.push("\u25B8 ORCHESTRATOR STATUS");
267
+ lines.push(` Tasks: ${health.totalOpenTasks} open, ${health.totalInProgress} in progress`);
268
+ lines.push(` Crashed: ${health.crashedSessions.length > 0 ? health.crashedSessions.join(", ") : "none"}`);
269
+ lines.push(` Stuck: ${health.stuckAgents.length > 0 ? health.stuckAgents.join(", ") : "none"}`);
270
+ lines.push(` Idle: ${health.idleAgents.length > 0 ? health.idleAgents.join(", ") : "none"}`);
271
+ lines.push("");
272
+ for (const emp of health.employees) {
273
+ const stateIcon = emp.alive ? emp.state === "idle" ? "\u{1F7E2}" : emp.state === "thinking" ? "\u{1F7E1}" : emp.state === "tool" ? "\u{1F535}" : "\u26AA" : "\u{1F534}";
274
+ const taskInfo = emp.taskCount > 0 ? `${emp.taskCount} task${emp.taskCount > 1 ? "s" : ""} (${emp.inProgressCount} active)` : "idle";
275
+ const staleWarning = emp.staleTasks.length > 0 ? ` \u26A0 stale: ${emp.staleTasks[0]}` : "";
276
+ lines.push(` ${stateIcon} ${emp.name} (${emp.role}): ${taskInfo}${staleWarning}`);
277
+ }
278
+ return lines.join("\n");
279
+ }
280
+ };
281
+
282
+ export {
283
+ MultiAgentOrchestrator
284
+ };