clay-server 4.0.1-beta.1 → 4.1.0-beta.10

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 (206) hide show
  1. package/LICENSE +661 -21
  2. package/LICENSES/MIT-legacy.txt +21 -0
  3. package/LICENSES/README.md +7 -0
  4. package/README.md +2 -2
  5. package/bin/cli.js +1 -3
  6. package/lib/ask-user-request-identity.js +23 -0
  7. package/lib/autonomous-run-record.js +32 -0
  8. package/lib/autonomous-run-scheduler.js +92 -0
  9. package/lib/context-usage.js +47 -0
  10. package/lib/daemon-project-access.js +118 -0
  11. package/lib/daemon-projects.js +19 -5
  12. package/lib/daemon.js +19 -20
  13. package/lib/default-ai-runtime.js +117 -0
  14. package/lib/durable-scheduler-record.js +61 -0
  15. package/lib/durable-scheduler-store.js +185 -0
  16. package/lib/durable-scheduler.js +495 -0
  17. package/lib/git-cli.js +1 -0
  18. package/lib/issue-work-session.js +10 -0
  19. package/lib/issues-comments.js +40 -0
  20. package/lib/issues-commit-verification.js +30 -0
  21. package/lib/issues-mcp-server.js +27 -0
  22. package/lib/issues-schema.js +119 -0
  23. package/lib/issues-service.js +339 -0
  24. package/lib/issues-store.js +210 -0
  25. package/lib/loop-cron.js +47 -0
  26. package/lib/loop-durable-schedule.js +159 -0
  27. package/lib/loop-guidance.js +35 -0
  28. package/lib/loop-registry-occurrence.js +76 -0
  29. package/lib/model-entry.js +15 -0
  30. package/lib/project-ask-user.js +4 -1
  31. package/lib/project-autonomous-run.js +498 -0
  32. package/lib/project-capsule-turn.js +1 -0
  33. package/lib/project-connection.js +8 -1
  34. package/lib/project-delegated-session.js +1 -0
  35. package/lib/project-filesystem.js +10 -10
  36. package/lib/project-full-access.js +86 -0
  37. package/lib/project-http.js +3 -1
  38. package/lib/project-issue-launch.js +154 -0
  39. package/lib/project-issues.js +58 -0
  40. package/lib/project-logs-access-scope.js +94 -0
  41. package/lib/project-logs-mcp-server.js +8 -12
  42. package/lib/project-logs-query.js +3 -0
  43. package/lib/project-logs-service.js +86 -84
  44. package/lib/project-logs-store.js +5 -3
  45. package/lib/project-loop-interview.js +163 -0
  46. package/lib/project-loop.js +150 -64
  47. package/lib/project-message-delivery.js +4 -2
  48. package/lib/project-models.js +71 -3
  49. package/lib/project-notifications.js +1 -1
  50. package/lib/project-pair-autonomous-stop.js +16 -0
  51. package/lib/project-pair-lifecycle.js +140 -102
  52. package/lib/project-pair-message.js +50 -0
  53. package/lib/project-pair-owned-stop.js +18 -0
  54. package/lib/project-pair-replacement-state.js +72 -0
  55. package/lib/project-pair-task-control.js +277 -0
  56. package/lib/project-pair-usage.js +76 -0
  57. package/lib/project-pending-message-queue.js +328 -0
  58. package/lib/project-scheduled-messages.js +499 -0
  59. package/lib/project-scheduled-task-execution.js +236 -0
  60. package/lib/project-scheduled-tasks.js +481 -0
  61. package/lib/project-session-notes.js +11 -4
  62. package/lib/project-session-pair.js +123 -127
  63. package/lib/project-sessions.js +143 -32
  64. package/lib/project-tool-llm-runtime.js +48 -0
  65. package/lib/project-user-message.js +224 -62
  66. package/lib/project-worker-proposal.js +69 -58
  67. package/lib/project-workspace-query.js +25 -0
  68. package/lib/project.js +396 -73
  69. package/lib/public/app.js +96 -26
  70. package/lib/public/css/default-ai.css +33 -0
  71. package/lib/public/css/home-hub.css +15 -2
  72. package/lib/public/css/home-sidebar.css +50 -2
  73. package/lib/public/css/icon-strip.css +40 -0
  74. package/lib/public/css/input.css +160 -114
  75. package/lib/public/css/issues.css +101 -0
  76. package/lib/public/css/mates.css +0 -1
  77. package/lib/public/css/messages.css +19 -0
  78. package/lib/public/css/pane.css +98 -2
  79. package/lib/public/css/pending-message-queue.css +190 -0
  80. package/lib/public/css/rewind.css +11 -2
  81. package/lib/public/css/scheduled-tasks.css +122 -0
  82. package/lib/public/css/sticky-notes.css +24 -4
  83. package/lib/public/index.html +43 -150
  84. package/lib/public/modules/app-connection.js +3 -0
  85. package/lib/public/modules/app-cursors.js +29 -12
  86. package/lib/public/modules/app-loop-ui.js +4 -8
  87. package/lib/public/modules/app-message-router.js +8 -0
  88. package/lib/public/modules/app-messages.js +38 -22
  89. package/lib/public/modules/app-notifications.js +2 -0
  90. package/lib/public/modules/app-panels.js +9 -1
  91. package/lib/public/modules/app-projects.js +3 -0
  92. package/lib/public/modules/app-rate-limit.js +0 -179
  93. package/lib/public/modules/ask-user-state.js +66 -0
  94. package/lib/public/modules/autonomous-run.js +285 -0
  95. package/lib/public/modules/chat-render-runtime.js +0 -2
  96. package/lib/public/modules/clay-file-links.js +111 -0
  97. package/lib/public/modules/clay-issue-links.js +131 -0
  98. package/lib/public/modules/clay-log-links.js +2 -0
  99. package/lib/public/modules/cursor-sharing-preference.js +38 -0
  100. package/lib/public/modules/default-ai.js +377 -0
  101. package/lib/public/modules/filebrowser.js +43 -2
  102. package/lib/public/modules/home-sidebar.js +16 -8
  103. package/lib/public/modules/home-surface.js +5 -0
  104. package/lib/public/modules/input.js +92 -40
  105. package/lib/public/modules/issues-context.js +117 -0
  106. package/lib/public/modules/issues-render.js +29 -0
  107. package/lib/public/modules/issues.js +270 -0
  108. package/lib/public/modules/loop-interview.js +151 -0
  109. package/lib/public/modules/markdown.js +4 -0
  110. package/lib/public/modules/message-delivery.js +5 -3
  111. package/lib/public/modules/pending-message-image-editor.js +143 -0
  112. package/lib/public/modules/pending-message-queue-model.js +22 -0
  113. package/lib/public/modules/pending-message-queue.js +491 -0
  114. package/lib/public/modules/permission-hints.js +13 -0
  115. package/lib/public/modules/project-access.js +141 -0
  116. package/lib/public/modules/project-grouping.js +22 -0
  117. package/lib/public/modules/project-logs.js +2 -2
  118. package/lib/public/modules/scheduled-message-state.js +22 -0
  119. package/lib/public/modules/scheduled-task-edit-state.js +7 -0
  120. package/lib/public/modules/scheduled-task-engine.js +48 -0
  121. package/lib/public/modules/scheduled-task-form.js +122 -0
  122. package/lib/public/modules/scheduled-task-recurrence.js +46 -0
  123. package/lib/public/modules/scheduled-task-schedule-rule.js +115 -0
  124. package/lib/public/modules/scheduled-tasks.js +459 -0
  125. package/lib/public/modules/scheduler-config.js +6 -52
  126. package/lib/public/modules/scheduler.js +9 -21
  127. package/lib/public/modules/sidebar-mobile.js +3 -0
  128. package/lib/public/modules/sidebar-projects.js +14 -171
  129. package/lib/public/modules/sidebar.js +0 -11
  130. package/lib/public/modules/split-pair-ui.js +5 -0
  131. package/lib/public/modules/split-view.js +3 -0
  132. package/lib/public/modules/sticky-note-markdown.js +1 -0
  133. package/lib/public/modules/sticky-notes-browser.js +1 -1
  134. package/lib/public/modules/sticky-notes.js +117 -4
  135. package/lib/public/modules/terminal.js +2 -0
  136. package/lib/public/modules/tool-palette-order.js +3 -3
  137. package/lib/public/modules/tools.js +26 -5
  138. package/lib/public/modules/worker-proposal.js +4 -0
  139. package/lib/public/style.css +3 -0
  140. package/lib/record-revision.js +11 -0
  141. package/lib/schedule-rule.js +151 -0
  142. package/lib/schedule-validation.js +124 -0
  143. package/lib/scheduled-run-state.js +87 -0
  144. package/lib/scheduled-task-records.js +127 -0
  145. package/lib/scheduler.js +179 -196
  146. package/lib/sdk-bridge.js +191 -22
  147. package/lib/sdk-message-processor.js +32 -2
  148. package/lib/sdk-turn-queue.js +14 -0
  149. package/lib/server-admin.js +3 -3
  150. package/lib/server-cursor-sharing.js +65 -0
  151. package/lib/server-default-ai.js +265 -0
  152. package/lib/server-durable-scheduler.js +26 -0
  153. package/lib/server-global-ws.js +10 -0
  154. package/lib/server-home-chat.js +29 -9
  155. package/lib/server-home-clay-entry.js +4 -1
  156. package/lib/server-home-debate-planning.js +32 -14
  157. package/lib/server-home-mate-creation.js +30 -11
  158. package/lib/server-home-models.js +14 -6
  159. package/lib/server-issue-links.js +18 -0
  160. package/lib/server-mates.js +4 -3
  161. package/lib/server-palette.js +17 -14
  162. package/lib/server.js +247 -102
  163. package/lib/session-notes-mcp-server.js +2 -2
  164. package/lib/session-pair-factory.js +45 -4
  165. package/lib/session-pair-history.js +40 -0
  166. package/lib/session-pair-mcp-server.js +22 -4
  167. package/lib/session-pair-operation.js +11 -0
  168. package/lib/session-pair-prompts.js +31 -2
  169. package/lib/session-pair-query-start.js +22 -0
  170. package/lib/session-pair-turn-control.js +8 -3
  171. package/lib/session-provenance.js +1 -0
  172. package/lib/session-query-tool-bridge.js +52 -0
  173. package/lib/session-search.js +4 -1
  174. package/lib/session-spawn-mcp-server.js +2 -1
  175. package/lib/session-split-groups.js +35 -1
  176. package/lib/sessions.js +53 -3
  177. package/lib/tool-llm.js +1 -0
  178. package/lib/users-default-ai-preferences.js +80 -0
  179. package/lib/users-home-surface-preferences.js +2 -1
  180. package/lib/users-preferences.js +35 -0
  181. package/lib/users-scheduled-task-preferences.js +44 -0
  182. package/lib/users.js +16 -0
  183. package/lib/worker-proposal-control.js +69 -0
  184. package/lib/worker-proposal-decision.js +7 -0
  185. package/lib/worker-runtime-catalog.js +52 -0
  186. package/lib/workspace-query-access.js +3 -2
  187. package/lib/workspace-query-projection.js +29 -0
  188. package/lib/workspace-query-service.js +20 -30
  189. package/lib/worktree.js +8 -4
  190. package/lib/ws-schema.js +62 -1
  191. package/lib/yoke/adapters/antigravity.js +1 -0
  192. package/lib/yoke/adapters/claude-worker.js +22 -18
  193. package/lib/yoke/adapters/claude.js +85 -16
  194. package/lib/yoke/adapters/codex.js +28 -7
  195. package/lib/yoke/claude-context-usage.js +57 -0
  196. package/lib/yoke/claude-message-correlation.js +31 -0
  197. package/lib/yoke/claude-model-switch.js +15 -0
  198. package/lib/yoke/claude-user-input.js +2 -0
  199. package/lib/yoke/index.js +2 -0
  200. package/lib/yoke/mcp-bridge-server.js +7 -1
  201. package/lib/yoke/package.json +1 -1
  202. package/lib/yoke/session-tool-transport.js +53 -0
  203. package/lib/yoke/user-input.js +21 -7
  204. package/package.json +9 -10
  205. package/bin/claude-relay.js +0 -6
  206. package/lib/public/modules/app-loop-wizard.js +0 -439
@@ -42,6 +42,9 @@ function attachPairFactory(ctx) {
42
42
  function validateVendor(vendor) {
43
43
  var installed = sm.installedVendors || [];
44
44
  if (!vendor || installed.indexOf(vendor) === -1) throw new Error("vendor is not installed: " + (vendor || "unknown"));
45
+ if (Array.isArray(sm.availableVendors) && sm.availableVendors.indexOf(vendor) === -1) {
46
+ throw new Error("vendor runtime is temporarily unavailable: " + vendor);
47
+ }
45
48
  return vendor;
46
49
  }
47
50
 
@@ -64,11 +67,11 @@ function attachPairFactory(ctx) {
64
67
  throw new Error("model is not available for vendor \"" + vendor + "\": " + requested);
65
68
  }
66
69
 
67
- function validateEffort(vendor, effort) {
70
+ function validateEffort(vendor, effort, exact) {
68
71
  var requested = typeof effort === "string" ? effort.trim() : "";
69
72
  var fallback = (sm.currentEffortByVendor && sm.currentEffortByVendor[vendor]) || sm.currentEffort || "medium";
70
73
  var clamped = yoke.clampEffort(vendor, requested || fallback) || null;
71
- if (requested && !clamped) {
74
+ if (requested && (!clamped || (exact && clamped !== requested))) {
72
75
  throw new Error("reasoning effort is not supported for vendor \"" + vendor + "\": " + requested);
73
76
  }
74
77
  return clamped;
@@ -76,13 +79,16 @@ function attachPairFactory(ctx) {
76
79
 
77
80
  // Resolve and validate one session runtime request without creating
78
81
  // anything. Throws on the first unusable field.
79
- function preflightRuntime(spec, defaultVendor) {
82
+ function preflightRuntime(spec, defaultVendor, exact) {
80
83
  var request = spec || {};
81
84
  var vendor = validateVendor((typeof request.vendor === "string" && request.vendor.trim()) || defaultVendor);
85
+ var info = yoke.getVendorInfo(vendor) || {};
86
+ if (exact && !(typeof request.model === "string" && request.model.trim())) throw new Error("an explicit model is required for vendor \"" + vendor + "\"");
87
+ if (exact && Array.isArray(info.effortLevels) && info.effortLevels.length && !(typeof request.effort === "string" && request.effort.trim())) throw new Error("an explicit reasoning effort is required for vendor \"" + vendor + "\"");
82
88
  return {
83
89
  vendor: vendor,
84
90
  model: validateModel(vendor, request.model),
85
- effort: validateEffort(vendor, request.effort),
91
+ effort: validateEffort(vendor, request.effort, exact),
86
92
  explicitEffort: !!(typeof request.effort === "string" && request.effort.trim()),
87
93
  };
88
94
  }
@@ -224,6 +230,39 @@ function attachPairFactory(ctx) {
224
230
  return created;
225
231
  }
226
232
 
233
+ function createOwnedPair(ownerId, args) {
234
+ if (ctx.isMate) throw new Error("Pair sessions are only available in projects");
235
+ var request = args || {};
236
+ var driverRuntime = preflightRuntime(request.driver || {}, "claude");
237
+ var workerRuntime = preflightRuntime(request.worker || {}, null);
238
+ var driver = sm.createSessionRaw({ ownerId: ownerId || null, vendor: driverRuntime.vendor, model: driverRuntime.model, effort: driverRuntime.effort });
239
+ var worker = null;
240
+ try {
241
+ driver.title = request.name ? request.name + " · Driver" : "Scheduled task · Driver";
242
+ if (driverRuntime.explicitEffort) driver.loopSettings = { effort: driverRuntime.effort };
243
+ worker = sm.createSessionRaw({ ownerId: ownerId || null, vendor: workerRuntime.vendor, model: workerRuntime.model, effort: workerRuntime.effort });
244
+ worker.title = request.name ? request.name + " · Split Worker" : "Scheduled task · Split Worker";
245
+ if (workerRuntime.explicitEffort) worker.loopSettings = { effort: workerRuntime.effort };
246
+ sessionProvenance.markWorker(driver, worker, sm.sessions);
247
+ if (typeof sm.saveSessionFile === "function") { sm.saveSessionFile(driver); sm.saveSessionFile(worker); }
248
+ var result = store.createOwned(ownerId || null, { members: [driver.localId, worker.localId], pair: { driverId: driver.localId, workerId: worker.localId }, name: request.name || "Scheduled task" });
249
+ if (!result.ok) throw new Error(result.error);
250
+ sm.broadcastSessionList();
251
+ return { driver: driver, worker: worker, group: result.group };
252
+ } catch (error) {
253
+ removeCreated(worker);
254
+ removeCreated(driver);
255
+ throw error;
256
+ }
257
+ }
258
+
259
+ function removeOwnedPair(ownerId, created) {
260
+ if (!created || !created.group || !store.dissolveOwned(ownerId || null, created.group.id)) return false;
261
+ removeCreated(created.worker);
262
+ removeCreated(created.driver);
263
+ return true;
264
+ }
265
+
227
266
  function createPair(ws, msg) {
228
267
  try {
229
268
  var created = createPairRecord(ws, msg);
@@ -237,6 +276,8 @@ function attachPairFactory(ctx) {
237
276
  createPair: createPair,
238
277
  createPairRecord: createPairRecord,
239
278
  createWorkerForDriver: createWorkerForDriver,
279
+ createOwnedPair: createOwnedPair,
280
+ removeOwnedPair: removeOwnedPair,
240
281
  preflightRuntime: preflightRuntime,
241
282
  preflightWorkerForDriver: preflightWorkerForDriver,
242
283
  validateModel: validateModel,
@@ -0,0 +1,40 @@
1
+ var MAX_RESPONSE_CHARS = 30000;
2
+
3
+ function responseText(history, fromIndex) {
4
+ var text = "";
5
+ for (var i = Math.max(0, fromIndex || 0); i < history.length; i++) {
6
+ if (history[i] && history[i].type === "delta" && history[i].text) text += history[i].text;
7
+ }
8
+ return text.length > MAX_RESPONSE_CHARS ? text.slice(-MAX_RESPONSE_CHARS) : text;
9
+ }
10
+
11
+ function errorSince(history, fromIndex) {
12
+ for (var i = history.length - 1; i >= Math.max(0, fromIndex || 0); i--) {
13
+ if (history[i] && history[i].type === "error") return history[i].text || "partner turn failed";
14
+ }
15
+ return null;
16
+ }
17
+
18
+ function recentTurns(session, count) {
19
+ var history = session.history || [];
20
+ var starts = [];
21
+ for (var i = 0; i < history.length; i++) if (history[i] && history[i].type === "user_message") starts.push(i);
22
+ var from = starts.length > 0 ? starts[Math.max(0, starts.length - count)] : 0;
23
+ var turns = [];
24
+ var current = null;
25
+ for (var j = from; j < history.length; j++) {
26
+ var item = history[j];
27
+ if (!item) continue;
28
+ if (item.type === "user_message") {
29
+ current = { user: item.text || "", delegated: !!item.delegated, response: "" };
30
+ turns.push(current);
31
+ } else if (item.type === "delta" && item.text) {
32
+ if (!current) { current = { user: "", delegated: false, response: "" }; turns.push(current); }
33
+ current.response += item.text;
34
+ if (current.response.length > MAX_RESPONSE_CHARS) current.response = current.response.slice(-MAX_RESPONSE_CHARS);
35
+ }
36
+ }
37
+ return turns;
38
+ }
39
+
40
+ module.exports = { errorSince: errorSince, recentTurns: recentTurns, responseText: responseText };
@@ -1,6 +1,13 @@
1
1
  // Partner-control tools for sessions that belong to a split group.
2
2
 
3
3
  var buildShape = require("./session-spawn-mcp-server").buildShape;
4
+ var z;
5
+ try { z = require("zod"); } catch (e) { z = null; }
6
+ var EVALUATION_OUTCOMES = ["succeeded", "partial", "failed", "abandoned"];
7
+ var evaluationSchema = z ? z.union([
8
+ z.enum(EVALUATION_OUTCOMES),
9
+ z.object({ outcome: z.enum(EVALUATION_OUTCOMES), note: z.string().optional() }),
10
+ ]) : null;
4
11
 
5
12
  // `options.lifecycle` adds the autonomous management tools. They are omitted
6
13
  // for a plain side-by-side split, which has no Driver role to exercise them.
@@ -15,6 +22,7 @@ function getToolDefs(handlers, options) {
15
22
  wait: { type: "boolean", description: "Wait for the partner's turn to finish. Defaults to true." },
16
23
  timeoutSeconds: { type: "number", description: "Maximum wait in seconds, from 1 to 900. Defaults to 300." },
17
24
  operationId: { type: "string", description: "Optional stable id for this delegation. Reusing it within the same human turn returns the original operation instead of sending twice." },
25
+ taskId: { type: "string", description: "Optional stable task id for generation and completion correlation." },
18
26
  }, ["message"]),
19
27
  handler: function (args) { return handlers.send(args || {}); },
20
28
  },
@@ -29,7 +37,7 @@ function getToolDefs(handlers, options) {
29
37
  {
30
38
  name: "interrupt_partner",
31
39
  description: "Interrupt the Split Worker's current task. Use this when the task is going in the wrong direction, needs to be reprioritized, or must stop before the next instruction. The Split Worker returns any partial result to you for review.",
32
- inputSchema: buildShape({}),
40
+ inputSchema: buildShape({ reason: { type: "string", description: "Why the Driver is interrupting this task." } }),
33
41
  handler: function (args) { return handlers.interrupt(args || {}); },
34
42
  },
35
43
  {
@@ -41,6 +49,15 @@ function getToolDefs(handlers, options) {
41
49
  ];
42
50
  if (!lifecycle) return defs;
43
51
  return defs.concat([
52
+ {
53
+ name: "message_partner",
54
+ description: "Queue a non-interrupting message on the active Split Worker's runtime input without creating a delegated follow-up. Returns queued or rejected with an exact request id; queued does not claim model execution.",
55
+ inputSchema: buildShape({
56
+ message: { type: "string", description: "Bounded correction or context for the current active Worker turn." },
57
+ requestId: { type: "string", description: "Optional stable request id. Reuse it to deduplicate a retried delivery within this human turn." },
58
+ }, ["message"]),
59
+ handler: function (args) { return handlers.message(args || {}); },
60
+ },
44
61
  {
45
62
  name: "partner_status",
46
63
  description: "Bounded capacity and continuity report for your Split Worker, for deciding reuse against replacement: context tokens used and the ratio of its window, current task and activity, vendor/model/effort, history size and idle time, whether it is safe to replace right now, and your own recorded results for earlier Worker generations. Returns no transcript. Prefer this over reading turns when you only need to decide.",
@@ -58,10 +75,11 @@ function getToolDefs(handlers, options) {
58
75
  workerEffort: { type: "string", description: "Optional reasoning effort for the new Worker." },
59
76
  recommendationRationale: { type: "string", description: "Concise Driver-authored explanation of why the recommended replacement vendor, model, and effort fit the next task." },
60
77
  evaluation: {
61
- type: "object",
62
- description: "Optional bounded assessment of the Worker being replaced, recorded against that exact generation.",
78
+ schema: evaluationSchema,
79
+ description: "Optional assessment of the Worker being replaced. Use succeeded, partial, failed, or abandoned, or an object with outcome set to one of those values and an optional note. Omit when no assessment is needed.",
63
80
  },
64
81
  operationId: { type: "string", description: "Optional stable id for this replacement. Reusing it within the same human turn returns the original operation instead of replacing twice." },
82
+ supersedeProposalId: { type: "string", description: "Exact pending replacement proposal id to supersede with this new configuration." },
65
83
  }, ["message", "recommendationRationale"]),
66
84
  handler: function (args) { return handlers.replace(args || {}); },
67
85
  },
@@ -69,7 +87,7 @@ function getToolDefs(handlers, options) {
69
87
  name: "record_partner_evaluation",
70
88
  description: "Record a bounded assessment of one Split Worker generation so your later model choices can use observed outcomes instead of re-reading transcripts. Records your judgement alongside the objective signals Clay already measured (turns, errors, interruption, context used). This is scoped to your own pair and forms no global model ranking.",
71
89
  inputSchema: buildShape({
72
- outcome: { type: "string", description: 'One of "succeeded", "partial", "failed", "abandoned".' },
90
+ outcome: { enum: EVALUATION_OUTCOMES, description: 'One of "succeeded", "partial", "failed", "abandoned".' },
73
91
  note: { type: "string", description: "Optional short reason, up to 400 characters." },
74
92
  generation: { type: "number", description: "Optional generation number. Defaults to the current Worker." },
75
93
  }, ["outcome"]),
@@ -0,0 +1,11 @@
1
+ function fingerprint(args, fields) {
2
+ var source = args || {};
3
+ var value = {};
4
+ for (var i = 0; i < fields.length; i++) {
5
+ var name = fields[i];
6
+ value[name] = Object.prototype.hasOwnProperty.call(source, name) ? source[name] : null;
7
+ }
8
+ return JSON.stringify(value);
9
+ }
10
+
11
+ module.exports = { fingerprint: fingerprint };
@@ -3,6 +3,26 @@
3
3
  // Pure data, extracted from project-session-pair.js so that module stays under
4
4
  // the size limit and so the guidance can be reviewed as prose.
5
5
 
6
+ var WORKER_RUNTIME_SELECTION = [
7
+ "Use a high-low model mix by default: keep decomposition, judgment, review, and independent verification",
8
+ "with the Driver. Give the Split Worker concrete, bounded execution tasks with clear acceptance criteria.",
9
+ "For routine bounded implementation, start with a lightweight Worker at low effort. When the installed",
10
+ "catalog offers it, codex / gpt-5.6-luna / low is the starting recommendation; otherwise choose a comparable",
11
+ "lightweight option from the offered catalog. Do not routinely recommend gpt-5.6-sol at high effort.",
12
+ "Do not mirror the Driver's model or default to the",
13
+ "strongest available model merely because it is available. Explicitly fill the vendor, model, and thinking",
14
+ "effort recommendation fields for both creation and replacement; never leave model selection to card defaults.",
15
+ "Select model capability and thinking effort separately. Start with the lowest effort adequate for the task,",
16
+ "not high effort by habit. Choose from the installed, offered catalog; do not invent model availability or prices.",
17
+ "Explain why the lighter choice can handle the task. Escalate only for a concrete requirement beyond its",
18
+ "capabilities or observed failures it cannot adequately resolve, and state that reason. Small corrections",
19
+ "found during Driver review are not by themselves a reason to escalate. Send those corrections back to the",
20
+ "Worker and verify the final result. Optimize for time to a completed, verified outcome, not first-draft speed.",
21
+ "Use recorded Worker outcomes when available,",
22
+ "and reconsider a lighter model for the next bounded task after an escalation. Honor the user's explicit",
23
+ "runtime choice; this is a recommendation policy, not a restriction on which model the user may select.",
24
+ ].join(" ").replace(/ {2,}/g, " ");
25
+
6
26
  var DRIVER_DELEGATION = [
7
27
  "Your management objective: protect your own context, keep the Split Worker compact, and put execution where",
8
28
  "it runs best. Delegate implementation-heavy work rather than doing it here. Treat work spanning multiple modules,",
@@ -13,9 +33,10 @@ var DRIVER_DELEGATION = [
13
33
  ].join(" ").replace(/ {2,}/g, " ");
14
34
 
15
35
  var DRIVER_CORE = [
36
+ WORKER_RUNTIME_SELECTION,
16
37
  "You are the Driver of a visible Driver/Split Worker pair, and you manage that Split Worker yourself.",
17
- "The tools send_to_partner, read_partner, partner_status, replace_partner, interrupt_partner, close_partner,",
18
- "and record_partner_evaluation are provided directly to you.",
38
+ "The pair tools distinguish a live message, a queued follow-up, an interrupt-and-replace task, resumption,",
39
+ "and replacement of the Worker runtime. Inspect exact task and proposal ids before changing queued work.",
19
40
  "",
20
41
  "Reuse the existing Split Worker",
21
42
  "only when its accumulated context genuinely helps the next task; when it is context-bloated, stale, or",
@@ -34,6 +55,8 @@ var DRIVER_CORE = [
34
55
  "interrupt true, which stops it first only after acceptance. A human Stop",
35
56
  "is authoritative: do not retry, send more work, or replace the Worker in the same turn. Clay blocks those",
36
57
  "actions until the human sends a new Driver message. Use close_partner when they ask to close the pane.",
58
+ "A Worker outcome envelope is Worker-reported evidence, not Driver verification. Preserve partial results and",
59
+ "correlate completions to their task and generation; never attach a late old-generation result to a new Worker.",
37
60
  "",
38
61
  "Recommend a Worker vendor, model, and effort from what is actually installed and offered, and include a concise",
39
62
  "rationale explaining why all three fit the task. The card remains visible as an audit trail even when full access",
@@ -56,7 +79,12 @@ var DRIVER_CORE = [
56
79
 
57
80
  var DRIVER = DRIVER_CORE + " " + DRIVER_DELEGATION;
58
81
 
82
+ function worker(taskId) {
83
+ return "You are the configured Split Worker. For task " + (taskId || "unknown") + ", call report_partner_outcome before finishing when the tool is available. Report only what you observed: changed files, verification commands/results, unverified work, running processes, and next action. Never claim Driver verification.";
84
+ }
85
+
59
86
  var UNPAIRED = [
87
+ WORKER_RUNTIME_SELECTION,
60
88
  "Infer the user's intended target from conversational and UI context. References to a user-visible paired or",
61
89
  "split pane, its session, its activity or status, or a collaborator the user wants opened resolve to Clay's",
62
90
  "Split Worker and its partner tools. Internal Sub-agents are a distinct execution mechanism, not a lexical",
@@ -76,4 +104,5 @@ module.exports = {
76
104
  DRIVER_CORE: DRIVER_CORE,
77
105
  DRIVER_DELEGATION: DRIVER_DELEGATION,
78
106
  UNPAIRED: UNPAIRED,
107
+ worker: worker,
79
108
  };
@@ -0,0 +1,22 @@
1
+ function beginPairQuery(ctx, session, text) {
2
+ session._queryStartTs = Date.now();
3
+ var promise = ctx.sdk.startQuery(session, text, undefined, ctx.linuxUser);
4
+ var owner = {
5
+ session: session,
6
+ generation: Number(session._queryGeneration || 0),
7
+ };
8
+ session._pairResumeQuery = owner;
9
+ Promise.resolve(promise).catch(function (error) {
10
+ var current = ctx.sm.sessions.get(session.localId);
11
+ var ownsCurrent = current === session && session._pairResumeQuery === owner &&
12
+ Number(session._queryGeneration || 0) === owner.generation;
13
+ if (!ownsCurrent) return;
14
+ delete session._pairResumeQuery;
15
+ session.isProcessing = false;
16
+ ctx.sm.sendAndRecord(session, { type: "error", text: error.message || String(error) });
17
+ ctx.onProcessingChanged();
18
+ });
19
+ return owner;
20
+ }
21
+
22
+ module.exports = { beginPairQuery: beginPairQuery };
@@ -111,14 +111,19 @@ function attachPairTurnControl(ctx) {
111
111
  return clean;
112
112
  }
113
113
 
114
- function runOperation(driver, kind, rawId, fn) {
114
+ function runOperation(driver, kind, rawId, fn, fingerprint) {
115
115
  var id = operationId(rawId);
116
116
  if (!id) return Promise.resolve().then(fn);
117
117
  var state = stateFor(driver);
118
118
  var key = kind + ":" + id;
119
- if (state.operations[key]) return state.operations[key];
119
+ if (state.operations[key]) {
120
+ if (fingerprint !== undefined && state.operations[key].fingerprint !== fingerprint) {
121
+ return Promise.reject(new Error("operation id was already used with different input"));
122
+ }
123
+ return state.operations[key].promise;
124
+ }
120
125
  var promise = Promise.resolve().then(fn);
121
- state.operations[key] = promise;
126
+ state.operations[key] = { fingerprint: fingerprint, promise: promise };
122
127
  return promise;
123
128
  }
124
129
 
@@ -69,6 +69,7 @@ function restore(meta, session) {
69
69
  createdVia: stored.createdVia === "split-worker" ? "split-worker" : null,
70
70
  createdAt: typeof stored.createdAt === "number" && isFinite(stored.createdAt) ? stored.createdAt : null,
71
71
  };
72
+ session._pairGeneration = session.sessionProvenance.generation;
72
73
  return storedOriginId !== session.sessionOriginId || JSON.stringify(stored) !== JSON.stringify(session.sessionProvenance);
73
74
  }
74
75
 
@@ -0,0 +1,52 @@
1
+ // Exact-query projection of SDK-owned tools into the project stdio MCP bridge.
2
+
3
+ var sessionToolTransport = require("./yoke/session-tool-transport");
4
+
5
+ function normalizeInputSchema(inputSchema) {
6
+ if (inputSchema && typeof inputSchema.type === "string") return inputSchema;
7
+ try {
8
+ var zod = require("zod");
9
+ var schema = inputSchema && inputSchema.safeParse ? inputSchema : zod.object(inputSchema || {});
10
+ return zod.toJSONSchema(schema);
11
+ } catch (e) {
12
+ return { type: "object", properties: {} };
13
+ }
14
+ }
15
+
16
+ function createSessionQueryToolBridge(ctx) {
17
+ function defs(queryGeneration) {
18
+ if (!ctx.session || !ctx.sdk || !Number.isInteger(queryGeneration)) return [];
19
+ return ctx.sdk.getQueryToolDefs(ctx.session, queryGeneration) || [];
20
+ }
21
+
22
+ function listTools(queryGeneration, normalizeToolSchema) {
23
+ var tools = [];
24
+ var queryTools = defs(queryGeneration);
25
+ var normalize = normalizeToolSchema || normalizeInputSchema;
26
+ for (var i = 0; i < queryTools.length; i++) {
27
+ var server = sessionToolTransport.bridgeServerForTool(queryTools[i].name);
28
+ if (!server) continue;
29
+ tools.push({
30
+ server: server,
31
+ name: queryTools[i].name,
32
+ description: queryTools[i].description || queryTools[i].name,
33
+ inputSchema: normalize(queryTools[i].inputSchema),
34
+ });
35
+ }
36
+ return tools;
37
+ }
38
+
39
+ function callTool(queryGeneration, serverName, toolName, args) {
40
+ var queryTools = defs(queryGeneration);
41
+ for (var i = 0; i < queryTools.length; i++) {
42
+ if (sessionToolTransport.bridgeServerForTool(queryTools[i].name) !== serverName || queryTools[i].name !== toolName) continue;
43
+ if (typeof queryTools[i].handler !== "function") return Promise.reject(new Error("Session tool handler unavailable: " + serverName + "/" + toolName));
44
+ return Promise.resolve(queryTools[i].handler(args || {}));
45
+ }
46
+ return null;
47
+ }
48
+
49
+ return { listTools: listTools, callTool: callTool };
50
+ }
51
+
52
+ module.exports = { createSessionQueryToolBridge: createSessionQueryToolBridge, normalizeInputSchema: normalizeInputSchema };
@@ -576,7 +576,10 @@ function searchPalette(projectSessions, query, opts) {
576
576
  if (allDocs.length === 0) return [];
577
577
 
578
578
  var index = buildIndex(allDocs);
579
- var raw = searchIndex(index, query, maxResults * 3); // over-fetch for dedup
579
+ // Rank every matching document before deduplication. A session with many
580
+ // matching turns must not consume the over-fetch window and hide other
581
+ // matching sessions from the palette.
582
+ var raw = searchIndex(index, query, allDocs.length);
580
583
 
581
584
  // Deduplicate: keep best match per session
582
585
  var bestPerSession = {};
@@ -12,7 +12,8 @@ function buildShape(props, required) {
12
12
  var key = keys[i];
13
13
  var prop = props[key];
14
14
  var field;
15
- if (prop.type === "number") field = z.number();
15
+ if (prop.schema) field = prop.schema;
16
+ else if (prop.type === "number") field = z.number();
16
17
  else if (prop.type === "boolean") field = z.boolean();
17
18
  else if (prop.enum) field = z.enum(prop.enum);
18
19
  else field = z.string();
@@ -179,6 +179,40 @@ function createSplitGroupStore(opts) {
179
179
  return { ok: true, group: group };
180
180
  }
181
181
 
182
+ function createOwned(ownerId, msg) {
183
+ var members = msg && msg.members;
184
+ if (!Array.isArray(members) || members.length !== 2) return { ok: false, error: "A split group requires exactly two sessions" };
185
+ var left = sessions.get(members[0]);
186
+ var right = sessions.get(members[1]);
187
+ if (!left || !right || left === right) return { ok: false, error: "Session not found" };
188
+ if ((left.ownerId || null) !== (ownerId || null) || (right.ownerId || null) !== (ownerId || null)) return { ok: false, error: "Session owner does not match the scheduled task owner" };
189
+ if (groupForMember(left.localId) || groupForMember(right.localId)) return { ok: false, error: "A session can belong to only one split group" };
190
+ var pair = msg && msg.pair;
191
+ if (!pair || pair.driverId !== left.localId || pair.workerId !== right.localId) return { ok: false, error: "Pair roles must reference both split group members" };
192
+ var requestedName = typeof msg.name === "string" ? msg.name.trim().slice(0, 80) : "";
193
+ var group = {
194
+ id: "sg_" + Date.now().toString(36) + "_" + crypto.randomBytes(3).toString("hex"),
195
+ name: requestedName || autoGroupName(left.title, right.title), nameCustomized: !!requestedName,
196
+ ownerId: ownerId || null, members: members.slice(),
197
+ pair: { driverId: pair.driverId, workerId: pair.workerId }, createdAt: Date.now(),
198
+ };
199
+ groups.push(group);
200
+ try { save(); } catch (error) { groups.pop(); return { ok: false, error: error.message || String(error) }; }
201
+ broadcast();
202
+ onPairChanged(group);
203
+ return { ok: true, group: group };
204
+ }
205
+
206
+ function dissolveOwned(ownerId, id) {
207
+ var index = groups.findIndex(function (item) { return item.id === id && (item.ownerId || null) === (ownerId || null); });
208
+ if (index === -1) return false;
209
+ var removed = groups.splice(index, 1)[0];
210
+ try { save(); } catch (error) { groups.splice(index, 0, removed); return false; }
211
+ broadcast();
212
+ onPairChanged(removed);
213
+ return true;
214
+ }
215
+
182
216
  function rename(ws, msg) {
183
217
  var group = groups.find(function (item) { return item.id === (msg && msg.id); });
184
218
  if (!group) return { ok: false, error: "Split group not found" };
@@ -265,7 +299,7 @@ function createSplitGroupStore(opts) {
265
299
  }
266
300
 
267
301
  load();
268
- return { create: create, rename: rename, setPair: setPair, dissolve: dissolve, dissolveBySession: dissolveBySession,
302
+ return { create: create, createOwned: createOwned, dissolveOwned: dissolveOwned, rename: rename, setPair: setPair, dissolve: dissolve, dissolveBySession: dissolveBySession,
269
303
  refreshAutoName: refreshAutoName, refreshAnchors: refreshAnchors,
270
304
  listFor: listFor, groupForMember: groupForMember, get groups() { return groups; } };
271
305
  }
package/lib/sessions.js CHANGED
@@ -8,6 +8,8 @@ var hygiene = require("./session-hygiene");
8
8
  var backgroundTaskTiming = require("./background-task-timing");
9
9
  var sessionProvenance = require("./session-provenance");
10
10
  var sessionVisibility = require("./session-visibility");
11
+ var projectAutonomousRun = require("./project-autonomous-run").projectAutonomousRun;
12
+ var restoreStoredRun = require("./project-autonomous-run").restoreStoredRun;
11
13
 
12
14
  function createSessionManager(opts) {
13
15
  var cwd = opts.cwd;
@@ -17,6 +19,8 @@ function createSessionManager(opts) {
17
19
  var sendAndRecord = null; // set after init via setSendAndRecord
18
20
  var onSessionDone = opts.onSessionDone || function () {};
19
21
  var onSessionDeleted = opts.onSessionDeleted || function () {};
22
+ var sessionDeletedListeners = [];
23
+ var sessionViewedListeners = [];
20
24
  var onSessionRenamed = opts.onSessionRenamed || function () {};
21
25
  var onSessionIdentityAssigned = opts.onSessionIdentityAssigned || function () {};
22
26
 
@@ -153,6 +157,7 @@ function createSessionManager(opts) {
153
157
  };
154
158
  if (session.ownerId) metaObj.ownerId = session.ownerId;
155
159
  if (session.vendor) metaObj.vendor = session.vendor;
160
+ if (session.codexDynamicToolCatalogVersion) metaObj.codexDynamicToolCatalogVersion = session.codexDynamicToolCatalogVersion;
156
161
  if (session.model) metaObj.model = session.model;
157
162
  if (session.effort) metaObj.effort = session.effort;
158
163
  // Persist the session's "born" mode so TUI sessions reappear after a
@@ -167,6 +172,11 @@ function createSessionManager(opts) {
167
172
  if (session.dangerouslySkipPermissions) metaObj.dangerouslySkipPermissions = true;
168
173
  if (session.permissionMode) metaObj.permissionMode = session.permissionMode;
169
174
  if (session.permissionModeBeforeFullAccess) metaObj.permissionModeBeforeFullAccess = session.permissionModeBeforeFullAccess;
175
+ if (session.autonomousRun) metaObj.autonomousRun = session.autonomousRun;
176
+ if (session.loopInterviewBrief) metaObj.loopInterviewBrief = session.loopInterviewBrief;
177
+ if (session.loopInterviewHandoff) metaObj.loopInterviewHandoff = session.loopInterviewHandoff;
178
+ if (session.scheduledTaskDraft) metaObj.scheduledTaskDraft = session.scheduledTaskDraft;
179
+ if (session.scheduledTaskRun) metaObj.scheduledTaskRun = session.scheduledTaskRun;
170
180
  metaObj.sessionVisibility = sessionVisibility.normalize(session.sessionVisibility);
171
181
  if (session.sessionVisibilityExplicit) metaObj.sessionVisibilityExplicit = true;
172
182
  if (session.bookmarked) metaObj.bookmarked = true;
@@ -186,6 +196,7 @@ function createSessionManager(opts) {
186
196
  var provenanceMeta = sessionProvenance.metadata(session);
187
197
  metaObj.sessionOriginId = provenanceMeta.sessionOriginId;
188
198
  if (provenanceMeta.sessionProvenance) metaObj.sessionProvenance = provenanceMeta.sessionProvenance;
199
+ if (Array.isArray(session._workerGenerations)) metaObj.workerGenerations = session._workerGenerations;
189
200
  var meta = JSON.stringify(metaObj);
190
201
  var lines = [meta];
191
202
  for (var i = 0; i < session.history.length; i++) {
@@ -292,6 +303,7 @@ function createSessionManager(opts) {
292
303
  lastRewindUuid: m.lastRewindUuid || null,
293
304
  };
294
305
  if (m.vendor) session.vendor = m.vendor;
306
+ session.codexDynamicToolCatalogVersion = Number(m.codexDynamicToolCatalogVersion || 0);
295
307
  session.model = m.model || deriveSessionModel(loaded[i].history);
296
308
  session.effort = m.effort || null;
297
309
  if (m.loop) session.loop = m.loop;
@@ -308,6 +320,7 @@ function createSessionManager(opts) {
308
320
  if (m.ownerId) session.ownerId = m.ownerId;
309
321
  session.sessionOriginId = m.sessionOriginId || null;
310
322
  session._provenanceMigrationNeeded = sessionProvenance.restore(m, session);
323
+ if (Array.isArray(m.workerGenerations)) session._workerGenerations = m.workerGenerations;
311
324
  // Born-TUI session: PTY is gone after restart, but the cliSessionId
312
325
  // is still resumable via `claude --resume <id>`. We mark the mode
313
326
  // here so it shows up in the sidebar with the right icon; the
@@ -320,6 +333,11 @@ function createSessionManager(opts) {
320
333
  session.dangerouslySkipPermissions = session.mode === "tui" && !!m.dangerouslySkipPermissions;
321
334
  session.permissionMode = m.permissionMode || (session.mode === "gui" && m.dangerouslySkipPermissions ? "bypassPermissions" : null);
322
335
  session.permissionModeBeforeFullAccess = m.permissionModeBeforeFullAccess || null;
336
+ session.autonomousRun = restoreStoredRun(m.autonomousRun);
337
+ session.loopInterviewBrief = m.loopInterviewBrief && typeof m.loopInterviewBrief === "object" ? m.loopInterviewBrief : null;
338
+ session.loopInterviewHandoff = m.loopInterviewHandoff && typeof m.loopInterviewHandoff === "object" ? m.loopInterviewHandoff : null;
339
+ session.scheduledTaskDraft = m.scheduledTaskDraft && typeof m.scheduledTaskDraft === "object" ? m.scheduledTaskDraft : null;
340
+ session.scheduledTaskRun = m.scheduledTaskRun && typeof m.scheduledTaskRun === "object" ? m.scheduledTaskRun : null;
323
341
  session.terminalId = null;
324
342
  session.runtimeMode = null;
325
343
  session.runtimeTerminalId = null;
@@ -552,6 +570,13 @@ function createSessionManager(opts) {
552
570
  runtimeTerminalId: typeof s.runtimeTerminalId === "number" ? s.runtimeTerminalId : null,
553
571
  dangerouslySkipPermissions: !!s.dangerouslySkipPermissions,
554
572
  permissionMode: s.permissionMode || null,
573
+ autonomousRun: s.autonomousRun ? {
574
+ id: s.autonomousRun.id,
575
+ state: s.autonomousRun.state,
576
+ continuationCount: s.autonomousRun.continuationCount || 0,
577
+ maxContinuations: s.autonomousRun.maxContinuations,
578
+ deadlineAt: s.autonomousRun.deadlineAt || null,
579
+ } : null,
555
580
  };
556
581
  }
557
582
 
@@ -634,6 +659,11 @@ function createSessionManager(opts) {
634
659
  dangerouslySkipPermissions: !!(sessionOpts && sessionOpts.mode === "tui" && sessionOpts.dangerouslySkipPermissions),
635
660
  permissionMode: (sessionOpts && sessionOpts.permissionMode) || null,
636
661
  permissionModeBeforeFullAccess: null,
662
+ autonomousRun: null,
663
+ loopInterviewBrief: null,
664
+ loopInterviewHandoff: null,
665
+ scheduledTaskDraft: null,
666
+ scheduledTaskRun: null,
637
667
  terminalId: null,
638
668
  sessionOriginId: null,
639
669
  };
@@ -676,6 +706,11 @@ function createSessionManager(opts) {
676
706
  dangerouslySkipPermissions: !!(sessionOpts && sessionOpts.mode === "tui" && sessionOpts.dangerouslySkipPermissions),
677
707
  permissionMode: (sessionOpts && sessionOpts.permissionMode) || null,
678
708
  permissionModeBeforeFullAccess: null,
709
+ autonomousRun: null,
710
+ loopInterviewBrief: null,
711
+ loopInterviewHandoff: null,
712
+ scheduledTaskDraft: null,
713
+ scheduledTaskRun: null,
679
714
  terminalId: null,
680
715
  sessionOriginId: null,
681
716
  };
@@ -736,6 +771,9 @@ function createSessionManager(opts) {
736
771
  }
737
772
 
738
773
  _send({ type: "history_done", lastUsage: lastUsage, lastModelUsage: lastModelUsage, lastCost: lastCost, lastStreamInputTokens: lastStreamInputTokens, contextUsage: session.lastContextUsage || null });
774
+ for (var vi = 0; vi < sessionViewedListeners.length; vi++) {
775
+ try { sessionViewedListeners[vi](session, targetWs, _send); } catch (e) {}
776
+ }
739
777
  }
740
778
 
741
779
  function switchSession(localId, targetWs, transform) {
@@ -766,7 +804,7 @@ function createSessionManager(opts) {
766
804
  var _capsByVendor = capabilitiesByVendor || {};
767
805
  var _sessionVendor = session.vendor || defaultVendor || "claude";
768
806
  var _vendorCaps = _capsByVendor[_sessionVendor] || {};
769
- _send({ type: "session_switched", id: localId, cliSessionId: session.cliSessionId || null, loop: session.loop || null, vendor: session.vendor || null, model: session.model || null, effort: session.effort || null, hasHistory: (session.history && session.history.length > 0), capabilities: _vendorCaps, isProcessing: !!session.isProcessing, mode: session.mode || "gui", terminalId: typeof session.terminalId === "number" ? session.terminalId : null, runtimeMode: session.runtimeMode || null, runtimeTerminalId: typeof session.runtimeTerminalId === "number" ? session.runtimeTerminalId : null, tuiSuspended: !!session.tuiSuspended, dangerouslySkipPermissions: !!session.dangerouslySkipPermissions, permissionMode: session.permissionMode || null });
807
+ _send({ type: "session_switched", id: localId, cliSessionId: session.cliSessionId || null, loop: session.loop || null, vendor: session.vendor || null, model: session.model || null, effort: session.effort || null, hasHistory: (session.history && session.history.length > 0), capabilities: _vendorCaps, isProcessing: !!session.isProcessing, mode: session.mode || "gui", terminalId: typeof session.terminalId === "number" ? session.terminalId : null, runtimeMode: session.runtimeMode || null, runtimeTerminalId: typeof session.runtimeTerminalId === "number" ? session.runtimeTerminalId : null, tuiSuspended: !!session.tuiSuspended, dangerouslySkipPermissions: !!session.dangerouslySkipPermissions, permissionMode: session.permissionMode || null, autonomousRun: projectAutonomousRun(session.autonomousRun), loopInterviewBrief: session.loopInterviewBrief || null, loopInterviewHandoff: session.loopInterviewHandoff || null, scheduledTaskDraft: session.scheduledTaskDraft || null });
770
808
  // Send vendor-specific slash commands
771
809
  var _vendorCmds = slashCommandsByVendor[_sessionVendor] || slashCommands || [];
772
810
  _send({ type: "slash_commands", commands: _vendorCmds, vendor: _sessionVendor });
@@ -839,9 +877,14 @@ function createSessionManager(opts) {
839
877
  }
840
878
 
841
879
  sessions.delete(localId);
842
- try { onSessionDeleted(localId); } catch (e) {
880
+ try { onSessionDeleted(localId, session); } catch (e) {
843
881
  console.error("[session] Session deletion hook failed:", e.message || e);
844
882
  }
883
+ for (var di = 0; di < sessionDeletedListeners.length; di++) {
884
+ try { sessionDeletedListeners[di](localId, session); } catch (e) {
885
+ console.error("[session] Session deletion listener failed:", e.message || e);
886
+ }
887
+ }
845
888
 
846
889
  if (activeSessionId === localId) {
847
890
  var remaining = [...sessions.keys()];
@@ -880,9 +923,14 @@ function createSessionManager(opts) {
880
923
  try { fs.unlinkSync(sessionFilePath(session.cliSessionId)); } catch(e) {}
881
924
  }
882
925
  sessions.delete(localId);
883
- try { onSessionDeleted(localId); } catch (e) {
926
+ try { onSessionDeleted(localId, session); } catch (e) {
884
927
  console.error("[session] Session deletion hook failed:", e.message || e);
885
928
  }
929
+ for (var di = 0; di < sessionDeletedListeners.length; di++) {
930
+ try { sessionDeletedListeners[di](localId, session); } catch (e) {
931
+ console.error("[session] Session deletion listener failed:", e.message || e);
932
+ }
933
+ }
886
934
  }
887
935
 
888
936
  function deleteSessionsBulk(localIds, targetWs) {
@@ -1248,6 +1296,8 @@ function createSessionManager(opts) {
1248
1296
  sessions: sessions,
1249
1297
  sessionsDir: sessionsDir,
1250
1298
  setOnSessionDeleted: function (fn) { onSessionDeleted = fn || function () {}; },
1299
+ addOnSessionDeleted: function (fn) { if (typeof fn === "function") sessionDeletedListeners.push(fn); },
1300
+ addOnSessionViewed: function (fn) { if (typeof fn === "function") sessionViewedListeners.push(fn); },
1251
1301
  setOnSessionRenamed: function (fn) { onSessionRenamed = fn || function () {}; },
1252
1302
  setOnSessionIdentityAssigned: function (fn) { onSessionIdentityAssigned = fn || function () {}; },
1253
1303
  notifySessionRenamed: function (localId) { onSessionRenamed(localId); },
package/lib/tool-llm.js CHANGED
@@ -32,6 +32,7 @@ async function complete(opts) {
32
32
  query: {
33
33
  cwd: opts.cwd,
34
34
  linuxUser: opts.linuxUser || undefined,
35
+ effort: selection.effort || undefined,
35
36
  skipProjectInstructions: true,
36
37
  skipSkills: true,
37
38
  canUseTool: function () { return Promise.resolve({ behavior: "deny", message: "Capsule LLM calls cannot use tools." }); },