clay-server 4.3.0-beta.3 → 4.3.0-beta.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.
@@ -365,31 +365,35 @@ body.pane-mode #input-area {
365
365
  line-height: 1;
366
366
  }
367
367
 
368
- /* Header-scoped (two-class) selectors: pane.css loads BEFORE menus.css in
369
- style.css, so the base .session-full-access rules would win a specificity
370
- tie and keep the pill at its 22px title-bar size inside the 24px pane
371
- header. Scope under .split-pane-header to outrank them. */
368
+ /* Header-scoped selectors keep the compact permission control clear of the
369
+ title and close affordance while preserving the shared header rhythm. */
370
+ .split-pane-header {
371
+ height: 28px;
372
+ min-height: 28px;
373
+ }
374
+
372
375
  .split-pane-header .split-pane-full-access {
373
- height: 22px;
376
+ height: 24px;
374
377
  align-self: center;
375
378
  margin-left: 0;
376
379
  padding: 0;
377
380
  gap: 4px;
378
- font-size: 10px;
381
+ font-size: 11px;
379
382
  letter-spacing: 0.02em;
380
383
  flex-wrap: nowrap;
381
384
  flex: 0 0 auto;
382
- overflow: hidden;
383
385
  }
384
386
 
385
387
  .split-pane-header .session-permission-segmented button {
386
- min-height: 18px;
387
- padding: 3px 6px;
388
- font-size: 10px;
388
+ min-height: 20px;
389
+ height: 20px;
390
+ font-size: 11px;
389
391
  }
390
392
 
391
- .split-pane-header .permission-label-long { display: none; }
392
- .split-pane-header .permission-label-short { display: inline; }
393
+ .split-pane-header .session-permission-segmented {
394
+ height: 24px;
395
+ padding: 1px;
396
+ }
393
397
 
394
398
  .split-pane-header .session-permission-status {
395
399
  flex: 0 0 auto;
@@ -410,9 +410,9 @@
410
410
  <button id="header-info-btn" type="button" title="Session info"><i data-lucide="info"></i></button>
411
411
  <div id="header-full-access-btn" class="session-permission-control hidden" role="group" aria-label="Session permission mode">
412
412
  <div class="session-permission-segmented">
413
- <button type="button" data-permission-mode="default"><span class="permission-label">Ask</span><span class="permission-spinner" aria-hidden="true"></span></button>
414
- <button type="button" data-permission-mode="auto"><span class="permission-label">Auto</span><span class="permission-spinner" aria-hidden="true"></span></button>
415
- <button type="button" data-permission-mode="bypassPermissions" aria-label="Skip permissions" title="Skip permissions"><span class="permission-label-long permission-label">Skip permissions</span><span class="permission-label-short permission-label" aria-hidden="true">Skip</span><span class="permission-spinner" aria-hidden="true"></span></button>
413
+ <button type="button" data-permission-mode="default" aria-label="Ask permissions" title="Ask permissions"><span class="permission-label">Ask</span><span class="permission-spinner" aria-hidden="true"></span></button>
414
+ <button type="button" data-permission-mode="auto" aria-label="Auto permissions" title="Auto permissions"><span class="permission-label">Auto</span><span class="permission-spinner" aria-hidden="true"></span></button>
415
+ <button type="button" data-permission-mode="bypassPermissions" aria-label="Skip permissions" title="Skip permissions"><span class="permission-label">Skip</span><span class="permission-spinner" aria-hidden="true"></span></button>
416
416
  </div>
417
417
  <span class="session-permission-status hidden" aria-live="polite"></span>
418
418
  </div>
@@ -62,6 +62,7 @@ import { handleShellCommandResult } from './shell-command.js';
62
62
  import { handleLoopRegistryUpdated, handleScheduleRunStarted, handleScheduleRunFinished, handleLoopScheduled, isSchedulerOpen, enterCraftingMode, exitCraftingMode, handleLoopRegistryFiles } from './scheduler.js';
63
63
  import { handleScheduledTaskMessage, handleScheduledTaskSessionSwitched } from './scheduled-tasks.js';
64
64
  import { renderGeneratedImage, renderImageGenerationProgress, clearImageGenerationProgress, clearAllImageGenerationProgress } from './generated-images.js';
65
+ import { clearPairResultStatus, handlePairResultStatus } from './pair-result-status.js';
65
66
 
66
67
  // --- App module imports ---
67
68
  import { scrollToBottom, addToMessages, addUserMessage, addSystemMessage, removeMatePreThinking, appendDelta, finalizeAssistantBlock, addConflictMessage, addContextOverflowMessage, showSuggestionChips, armStickyBottom, VENDOR_AVATARS, VENDOR_NAMES } from './app-rendering.js';
@@ -243,6 +244,7 @@ export function processMessage(msg) {
243
244
  // Restore cached rich context usage BEFORE updateContextPanel runs
244
245
  if (msg.contextUsage && !msg.contextUsage.unavailable) store.set({ richContextUsage: msg.contextUsage });
245
246
  else markContextUnavailable();
247
+
246
248
  // Restore accurate context data from the last result in full history
247
249
  if (msg.lastUsage || msg.lastModelUsage) {
248
250
  accumulateContext(msg.lastCost, msg.lastUsage, msg.lastModelUsage, msg.lastStreamInputTokens);
@@ -804,6 +806,10 @@ export function processMessage(msg) {
804
806
  handleRemoteSelection(msg);
805
807
  break;
806
808
 
809
+ case "pair_result_status":
810
+ handlePairResultStatus(msg);
811
+ break;
812
+
807
813
  case "session_io":
808
814
  blinkSessionDot(msg.id);
809
815
  break;
@@ -823,6 +829,7 @@ export function processMessage(msg) {
823
829
  break;
824
830
 
825
831
  case "session_switched":
832
+ clearPairResultStatus();
826
833
  syncAutonomousRunForSession(msg.autonomousRun || null);
827
834
  closeWhatsNewArticle();
828
835
  // Save draft from outgoing session
@@ -0,0 +1,87 @@
1
+ import { store } from './store.js';
2
+ import { getWs } from './ws-ref.js';
3
+ import { showConfirm } from './app-misc.js';
4
+
5
+ var statusGeneration = 0;
6
+
7
+ function retrySource(item) {
8
+ return { item: item, generation: statusGeneration, projectSlug: store.get("currentSlug") || store.get("activeProjectSlug") || null,
9
+ sessionId: store.get("activeSessionId"), userId: store.get("myUserId") || null, ws: getWs() };
10
+ }
11
+
12
+ function sendRetry(source, confirmed) {
13
+ var ws = getWs();
14
+ var projectSlug = store.get("currentSlug") || store.get("activeProjectSlug") || null;
15
+ var items = store.get("pairResultStatus") || [];
16
+ var stillVisible = items.some(function (item) { return item.id === source.item.id; });
17
+ if (!ws || ws !== source.ws || ws.readyState !== 1 || statusGeneration !== source.generation ||
18
+ store.get("activeSessionId") !== source.sessionId || projectSlug !== source.projectSlug ||
19
+ (store.get("myUserId") || null) !== source.userId || !stillVisible) return false;
20
+ ws.send(JSON.stringify({ type: "pair_result_retry", id: source.item.id, confirmDuplicate: confirmed === true,
21
+ sessionId: source.sessionId, projectSlug: source.projectSlug }));
22
+ return true;
23
+ }
24
+
25
+ function retry(item) {
26
+ var source = retrySource(item);
27
+ if (item.confirmDuplicate) {
28
+ showConfirm("The Driver may already have received this completed result. Retry delivery anyway? This can cause a duplicate result receipt.", function () {
29
+ sendRetry(source, true);
30
+ }, "Retry delivery", false);
31
+ return;
32
+ }
33
+ sendRetry(source, false);
34
+ }
35
+
36
+ function renderPairResultStatus() {
37
+ var existing = document.getElementById("pair-result-status");
38
+ if (existing) existing.remove();
39
+ var items = store.get("pairResultStatus") || [];
40
+ if (!items.length) return;
41
+ var messages = document.getElementById("messages");
42
+ if (!messages || !messages.parentElement) return;
43
+ var section = document.createElement("section");
44
+ section.id = "pair-result-status";
45
+ section.className = "pair-result-status";
46
+ section.setAttribute("role", "status");
47
+ for (var i = 0; i < items.length; i++) {
48
+ var item = items[i], card = document.createElement("div");
49
+ card.className = "pair-result-status-card pair-result-status-" + item.state;
50
+ var title = document.createElement("strong");
51
+ title.textContent = item.state === "blocked" ? "Split Worker result blocked" :
52
+ (item.state === "uncertain" ? (item.hasCompletedResult === false ? "Split Worker recovery uncertain" : "Split Worker result delivery uncertain") : "Split Worker result pending");
53
+ var message = document.createElement("span");
54
+ message.textContent = item.message || "The completed result is retained.";
55
+ card.appendChild(title); card.appendChild(message);
56
+ if (item.hasCompletedResult !== false) {
57
+ var details = document.createElement("details"), summary = document.createElement("summary"), body = document.createElement("pre");
58
+ summary.textContent = "View completed result";
59
+ body.textContent = item.error ? "Error: " + item.error : (item.response || "No text response was recorded.");
60
+ details.appendChild(summary); details.appendChild(body); card.appendChild(details);
61
+ }
62
+ if (item.canRetry) {
63
+ var button = document.createElement("button");
64
+ button.type = "button"; button.className = "confirm-btn confirm-ok pair-result-status-retry"; button.textContent = "Retry delivery";
65
+ button.addEventListener("click", retry.bind(null, item));
66
+ card.appendChild(button);
67
+ }
68
+ section.appendChild(card);
69
+ }
70
+ messages.parentElement.insertBefore(section, messages);
71
+ }
72
+
73
+ function handlePairResultStatus(msg) {
74
+ if (!msg || msg.sessionId !== store.get("activeSessionId")) return false;
75
+ statusGeneration++;
76
+ store.set({ pairResultStatus: Array.isArray(msg.items) ? msg.items : [] });
77
+ renderPairResultStatus();
78
+ return true;
79
+ }
80
+
81
+ function clearPairResultStatus() {
82
+ statusGeneration++;
83
+ store.set({ pairResultStatus: [] });
84
+ renderPairResultStatus();
85
+ }
86
+
87
+ export { clearPairResultStatus, handlePairResultStatus, renderPairResultStatus };
@@ -46,9 +46,9 @@ export function createPermissionControl(className, ariaLabel) {
46
46
  control.setAttribute("role", "group");
47
47
  control.setAttribute("aria-label", ariaLabel || "Session permission mode");
48
48
  control.innerHTML = '<div class="session-permission-segmented">' +
49
- '<button type="button" data-permission-mode="default"><span class="permission-label">Ask</span><span class="permission-spinner" aria-hidden="true"></span></button>' +
50
- '<button type="button" data-permission-mode="auto"><span class="permission-label">Auto</span><span class="permission-spinner" aria-hidden="true"></span></button>' +
51
- '<button type="button" data-permission-mode="bypassPermissions" aria-label="Skip permissions" title="Skip permissions"><span class="permission-label-long permission-label">Skip permissions</span><span class="permission-label-short permission-label" aria-hidden="true">Skip</span><span class="permission-spinner" aria-hidden="true"></span></button>' +
49
+ '<button type="button" data-permission-mode="default" aria-label="Ask permissions" title="Ask permissions"><span class="permission-label">Ask</span><span class="permission-spinner" aria-hidden="true"></span></button>' +
50
+ '<button type="button" data-permission-mode="auto" aria-label="Auto permissions" title="Auto permissions"><span class="permission-label">Auto</span><span class="permission-spinner" aria-hidden="true"></span></button>' +
51
+ '<button type="button" data-permission-mode="bypassPermissions" aria-label="Skip permissions" title="Skip permissions"><span class="permission-label">Skip</span><span class="permission-spinner" aria-hidden="true"></span></button>' +
52
52
  '</div><span class="session-permission-status" aria-live="polite"></span>';
53
53
  control.querySelector(".session-permission-status").setAttribute("aria-atomic", "true");
54
54
  return control;
@@ -101,6 +101,7 @@ export function renderPermissionControl(control, state) {
101
101
  control.classList.toggle("permission-globally-forced", globallyForced);
102
102
  control.classList.toggle("permission-runtime-fallback", state.permissionMode === "auto" && !!state.effectivePermissionMode && state.effectivePermissionMode !== "auto");
103
103
  control.setAttribute("aria-busy", pending ? "true" : "false");
104
+ var buttonTitles = { default: "Ask permissions", auto: "Auto permissions", bypassPermissions: "Skip permissions" };
104
105
  var buttons = control.querySelectorAll("[data-permission-mode]");
105
106
  for (var i = 0; i < buttons.length; i++) {
106
107
  var mode = buttons[i].dataset.permissionMode;
@@ -113,8 +114,7 @@ export function renderPermissionControl(control, state) {
113
114
  buttons[i].classList.toggle("pending", requested);
114
115
  buttons[i].setAttribute("aria-pressed", selected ? "true" : "false");
115
116
  buttons[i].setAttribute("aria-busy", requested ? "true" : "false");
116
- if (unsupported) buttons[i].title = "Auto permissions are unavailable for this Claude session.";
117
- else buttons[i].removeAttribute("title");
117
+ buttons[i].title = unsupported ? "Auto permissions are unavailable for this Claude session." : buttonTitles[mode];
118
118
  }
119
119
  var status = control.querySelector(".session-permission-status");
120
120
  if (status) {
@@ -19,7 +19,7 @@ function getToolDefs(handlers, options) {
19
19
  description: "Delegate one concrete follow-up task to the existing visible Split Worker. This tool is exposed only after the user has configured and accepted an exact pair. A completed turn does not end the Split Worker session: reuse the same Split Worker for follow-up implementation and corrections instead of taking over its work. Detached completions are pushed back automatically. A delegated turn cannot delegate back, so keep orchestration one hop deep.",
20
20
  inputSchema: buildShape({
21
21
  message: { type: "string", description: "The complete task or question for the partner." },
22
- wait: { type: "boolean", description: "Wait for the partner's turn to finish. Defaults to true." },
22
+ wait: { type: "boolean", description: "Wait for the partner's turn to finish. Defaults to false; set true for an explicit blocking wait." },
23
23
  timeoutSeconds: { type: "number", description: "Maximum wait in seconds, from 1 to 900. Defaults to 300." },
24
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
25
  taskId: { type: "string", description: "Optional stable task id for generation and completion correlation." },
@@ -28,7 +28,7 @@ function getToolDefs(handlers, options) {
28
28
  },
29
29
  {
30
30
  name: "read_partner",
31
- description: "Read the Split Worker's current status and recent conversation turns, plus the same bounded capacity report partner_status returns. Use this for an interim check after a non-waiting delegation or timeout; completed results are pushed automatically.",
31
+ description: "Read the Split Worker's current status and recent conversation turns, plus the same bounded capacity report partner_status returns. Use only for a requested status, concrete failure or stall diagnosis, or capacity/queue decision; do not poll routinely. Completed results are pushed automatically.",
32
32
  inputSchema: buildShape({
33
33
  lastTurns: { type: "number", description: "Number of recent user-message-delimited turns, from 0 to 5. Use 0 for status only. Defaults to 1." },
34
34
  }),
@@ -76,7 +76,13 @@ var DRIVER_CORE = [
76
76
  "ambiguous and a visible pair exists, prefer the visible Split Worker. If review or user feedback requires",
77
77
  "corrections to the Split Worker's implementation, delegate a follow-up turn to that Split Worker instead of",
78
78
  "editing its files yourself. If a non-waiting delegation finishes later, Clay pushes the result back and",
79
- "resumes you automatically. You also decide the Split Worker's tool-permission requests when they arise;",
79
+ "resumes you automatically. send_to_partner returns immediately by default; set wait to true only when you",
80
+ "explicitly need the final result in the same tool call. Do useful independent work after a non-waiting",
81
+ "delegation, then yield for Clay's automatic completion callback; do not poll read_partner or partner_status,",
82
+ "or sleep while waiting. Use those reads only for a user-requested status, concrete failure or stall diagnosis,",
83
+ "capacity/reuse decision, or exact queue inspection before mutation. Do not send the same correction as both",
84
+ "a live message and a queued task; consolidate review feedback into one bounded follow-up. You also decide",
85
+ "the Split Worker's tool-permission requests when they arise;",
80
86
  "approve only what falls inside the task the user authorized. Integrate and verify the final outcome. Do not",
81
87
  "search the project for implementations of these tools, and do not delegate work that must be performed",
82
88
  "sequentially in this same session.",
package/lib/sessions.js CHANGED
@@ -230,7 +230,7 @@ function createSessionManager(opts) {
230
230
  }
231
231
 
232
232
  function appendToSessionFile(session, obj) {
233
- if (!session.cliSessionId) return;
233
+ if (!session.cliSessionId) return true;
234
234
  session.lastActivity = Date.now();
235
235
  try {
236
236
  var afPath = sessionFilePath(session.cliSessionId);
@@ -238,8 +238,10 @@ function createSessionManager(opts) {
238
238
  if (process.platform !== "win32") {
239
239
  try { fs.chmodSync(afPath, 0o600); } catch (chmodErr) {}
240
240
  }
241
+ return true;
241
242
  } catch(e) {
242
243
  console.error("[session] Failed to append to session file:", e.message);
244
+ return false;
243
245
  }
244
246
  }
245
247
 
@@ -1031,7 +1033,7 @@ function createSessionManager(opts) {
1031
1033
  var outgoingObj = clientObj || obj;
1032
1034
  if (!outgoingObj._ts) outgoingObj._ts = obj._ts;
1033
1035
  session.history.push(obj);
1034
- appendToSessionFile(session, obj);
1036
+ if (appendToSessionFile(session, obj) === false) return false;
1035
1037
  // Per-session out-of-band subscribers mirror mate session events into
1036
1038
  // a parallel UI without joining the project's
1037
1039
  // ws clients set). Subscribers receive the same obj that goes to ws
@@ -1087,6 +1089,33 @@ function createSessionManager(opts) {
1087
1089
  }
1088
1090
  // Notify server for cross-project unread tracking
1089
1091
  if (obj.type === "done") onSessionDone(session);
1092
+ return true;
1093
+ }
1094
+
1095
+ function sendAndRecordDurably(session, obj, clientObj) {
1096
+ if (!session || !session.cliSessionId) return false;
1097
+ var saved;
1098
+ try { saved = doSendAndRecord(session, obj, clientObj); }
1099
+ catch (error) {
1100
+ var exact = JSON.stringify(obj);
1101
+ if (hasDurableSessionRecord(session, function (record) { return JSON.stringify(record) === exact; })) return true;
1102
+ if (session.history[session.history.length - 1] === obj) session.history.pop();
1103
+ throw error;
1104
+ }
1105
+ if (saved === false && session.history[session.history.length - 1] === obj) session.history.pop();
1106
+ return saved === true;
1107
+ }
1108
+
1109
+ function hasDurableSessionRecord(session, predicate) {
1110
+ if (!session || !session.cliSessionId || typeof predicate !== "function") return false;
1111
+ try {
1112
+ var lines = fs.readFileSync(sessionFilePath(session.cliSessionId), "utf8").split("\n");
1113
+ for (var i = lines.length - 1; i >= 0; i--) {
1114
+ if (!lines[i]) continue;
1115
+ try { if (predicate(JSON.parse(lines[i]))) return true; } catch (error) {}
1116
+ }
1117
+ } catch (error) {}
1118
+ return false;
1090
1119
  }
1091
1120
 
1092
1121
  function resumeSession(cliSessionId, opts, targetWs) {
@@ -1384,6 +1413,8 @@ function createSessionManager(opts) {
1384
1413
  saveSessionFile: saveSessionFile,
1385
1414
  appendToSessionFile: appendToSessionFile,
1386
1415
  sendAndRecord: doSendAndRecord,
1416
+ sendAndRecordDurably: sendAndRecordDurably,
1417
+ hasDurableSessionRecord: hasDurableSessionRecord,
1387
1418
  subscribeSession: function (localId, cb) {
1388
1419
  var session = sessions.get(localId);
1389
1420
  if (!session) return null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "clay-server",
3
- "version": "4.3.0-beta.3",
3
+ "version": "4.3.0-beta.5",
4
4
  "description": "Self-hosted team workspace for Claude Code and Codex. Multi-user, browser-based, with persistent AI mates.",
5
5
  "bin": {
6
6
  "clay-server": "./bin/cli.js"