clay-server 2.34.0-beta.2 → 2.34.0-beta.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/project.js CHANGED
@@ -162,7 +162,7 @@ function createProjectContext(opts) {
162
162
  var latestVersion = null;
163
163
 
164
164
  // --- YOKE adapters (multi-vendor, lazy init) ---
165
- var _yokeState = yoke.createAdapters({ cwd: cwd });
165
+ var _yokeState = yoke.createAdapters({ cwd: cwd, slug: slug });
166
166
  var adapters = _yokeState.adapters;
167
167
  var defaultVendor = adapters.claude ? "claude" : Object.keys(adapters)[0] || "claude";
168
168
  var adapter = adapters[defaultVendor] || null;
@@ -496,6 +496,63 @@ function createProjectContext(opts) {
496
496
  console.error("[project] Failed to create debate MCP server:", e.message);
497
497
  }
498
498
 
499
+ // Ask-user MCP server (mates only)
500
+ if (isMate) {
501
+ try {
502
+ var askUserMcp = require("./ask-user-mcp-server");
503
+ var askUserToolDefs = askUserMcp.getToolDefs(function onAsk(input) {
504
+ // Stateless: the tool's job is to *post* the question card.
505
+ // We do NOT hold a promise open waiting for the user. When the
506
+ // user answers, the answer is injected as a fresh user message
507
+ // on the next turn (see project-sessions.js ask_user_response).
508
+ // This avoids HTTP long-poll timeouts on the MCP bridge and
509
+ // matches the natural multi-turn agent loop.
510
+ var session = sm.getActiveSession();
511
+ if (!session) {
512
+ // No active session means we have no way to show a card or
513
+ // route the answer. Fail closed rather than pretend success.
514
+ return Promise.resolve({
515
+ content: [{ type: "text", text: "Error: no active session in " + slug + "; cannot display question card." }],
516
+ isError: true,
517
+ });
518
+ }
519
+ if (session.loop && session.loop.active && session.loop.role !== "crafting") {
520
+ return Promise.resolve({
521
+ content: [{ type: "text", text: "Error: Autonomous mode. Make your own decision." }],
522
+ isError: true,
523
+ });
524
+ }
525
+
526
+ var toolId = "ask_" + Date.now() + "_" + crypto.randomUUID().slice(0, 8);
527
+ // Track for UI card lifecycle + answer routing. No resolve function.
528
+ session.pendingAskUser[toolId] = {
529
+ input: input,
530
+ mode: "mcp",
531
+ sessionId: session.localId,
532
+ postedAt: Date.now(),
533
+ };
534
+
535
+ sm.sendAndRecord(session, {
536
+ type: "tool_executing",
537
+ id: toolId,
538
+ name: "AskUserQuestion",
539
+ input: input,
540
+ });
541
+
542
+ return Promise.resolve({
543
+ content: [{
544
+ type: "text",
545
+ text: "The question card has been posted to the user. End this turn now without further commentary; the user's answer will arrive as the next user message.",
546
+ }],
547
+ });
548
+ });
549
+ var askUserMcpConfig = adapter.createToolServer({ name: "clay-ask-user", version: "1.0.0", tools: askUserToolDefs });
550
+ if (askUserMcpConfig) servers[askUserMcpConfig.name || "clay-ask-user"] = askUserMcpConfig;
551
+ } catch (e) {
552
+ console.error("[project] Failed to create ask-user MCP server:", e.message);
553
+ }
554
+ }
555
+
499
556
  // Browser MCP server (main project only, not mates)
500
557
  if (!isMate) {
501
558
  try {
@@ -1318,6 +1375,13 @@ function createProjectContext(opts) {
1318
1375
  getLatestVersion: function () { return latestVersion; },
1319
1376
  getTitle: function () { return title; },
1320
1377
  getProject: function () { return project; },
1378
+ // Exposed so the first websocket connection can lazily warm up the
1379
+ // adapters for this project (see project-connection handleConnection).
1380
+ warmup: function () {
1381
+ sdk.warmup();
1382
+ sdk.startIdleReaper();
1383
+ sm.migrateSessionTitles(adapter, cwd);
1384
+ },
1321
1385
  });
1322
1386
 
1323
1387
  // --- Destroy ---
@@ -1376,6 +1440,15 @@ function createProjectContext(opts) {
1376
1440
  var tmpDir = path.join(os.tmpdir(), "clay-" + cwdHash);
1377
1441
  fs.rmSync(tmpDir, { recursive: true, force: true });
1378
1442
  } catch (e) {}
1443
+
1444
+ var codexShutdown = Promise.resolve(true);
1445
+ if (adapters && adapters.codex && typeof adapters.codex.shutdown === "function") {
1446
+ codexShutdown = adapters.codex.shutdown().catch(function(err) {
1447
+ console.error("[project] Codex shutdown failed for " + slug + ":", err && err.message ? err.message : err);
1448
+ return false;
1449
+ });
1450
+ }
1451
+ return codexShutdown;
1379
1452
  }
1380
1453
 
1381
1454
  // --- Status info ---
@@ -1523,15 +1596,9 @@ function createProjectContext(opts) {
1523
1596
  broadcastClientCount();
1524
1597
  broadcastPresence();
1525
1598
  },
1526
- warmup: function () {
1527
- sdk.warmup();
1528
- sdk.startIdleReaper();
1529
- // Migrate existing relay session titles to SDK format (one-time, async)
1530
- sm.migrateSessionTitles(adapter, cwd);
1531
- },
1532
1599
  destroy: function () {
1533
1600
  sdk.stopIdleReaper();
1534
- destroy();
1601
+ return destroy();
1535
1602
  },
1536
1603
  };
1537
1604
  }
@@ -410,18 +410,18 @@
410
410
  line-height: 1.4;
411
411
  }
412
412
 
413
- /* Step 4: Autonomy options */
414
- .mate-autonomy-options {
413
+ /* Step 4: Vendor options */
414
+ .mate-vendor-option-list {
415
415
  display: flex;
416
416
  flex-direction: column;
417
- gap: 8px;
417
+ gap: 10px;
418
418
  }
419
- .mate-autonomy-btn {
419
+ .mate-vendor-option-btn {
420
420
  display: flex;
421
- flex-direction: column;
421
+ flex-direction: row;
422
422
  align-items: flex-start;
423
- gap: 2px;
424
- padding: 12px 16px;
423
+ gap: 14px;
424
+ padding: 14px 16px;
425
425
  background: var(--input-bg, #1a1a2e);
426
426
  border: 2px solid var(--border, #333);
427
427
  border-radius: 10px;
@@ -430,21 +430,36 @@
430
430
  text-align: left;
431
431
  color: var(--text, #fff);
432
432
  font-family: inherit;
433
+ width: 100%;
433
434
  }
434
- .mate-autonomy-btn:hover {
435
+ .mate-vendor-option-btn:hover {
435
436
  border-color: var(--text-dimmer, #6272a4);
436
437
  }
437
- .mate-autonomy-btn.active {
438
+ .mate-vendor-option-btn.active {
438
439
  border-color: var(--accent, #6c5ce7);
439
440
  background: var(--accent-bg, rgba(108,92,231,0.12));
440
441
  }
441
- .mate-autonomy-title {
442
+ .mate-vendor-option-icon {
443
+ width: 36px;
444
+ height: 36px;
445
+ border-radius: 8px;
446
+ flex-shrink: 0;
447
+ object-fit: cover;
448
+ }
449
+ .mate-vendor-option-text {
450
+ display: flex;
451
+ flex-direction: column;
452
+ gap: 4px;
453
+ min-width: 0;
454
+ }
455
+ .mate-vendor-option-title {
442
456
  font-weight: 600;
443
457
  font-size: 14px;
444
458
  }
445
- .mate-autonomy-desc {
459
+ .mate-vendor-option-desc {
446
460
  font-size: 12px;
447
461
  color: var(--text-muted, #9ea8c7);
462
+ line-height: 1.4;
448
463
  }
449
464
 
450
465
  /* Footer */
@@ -1997,19 +2012,60 @@ body.mate-dm-active #layout.sidebar-collapsed .mate-collapsed-info {
1997
2012
  }
1998
2013
 
1999
2014
  /* Mate datastore inspector */
2000
- #mate-sidebar-datastore {
2015
+ #mate-datastore-panel {
2016
+ position: absolute;
2017
+ inset: 0;
2018
+ z-index: 40;
2019
+ background: var(--bg);
2001
2020
  display: flex;
2002
2021
  flex-direction: column;
2003
- flex: 1;
2004
- min-height: 0;
2022
+ overflow: hidden;
2023
+ }
2024
+
2025
+ #mate-datastore-panel.hidden {
2026
+ display: none !important;
2005
2027
  }
2006
2028
 
2007
- #mate-sidebar-datastore.hidden {
2029
+ #main-column.mate-datastore-open > .title-bar-content,
2030
+ #main-column.mate-datastore-open > .dm-header-bar,
2031
+ #main-column.mate-datastore-open > #main-panels {
2008
2032
  display: none !important;
2009
2033
  }
2010
2034
 
2035
+ .mate-datastore-top-bar {
2036
+ display: flex;
2037
+ align-items: center;
2038
+ justify-content: space-between;
2039
+ height: 48px;
2040
+ padding: 0 16px;
2041
+ border-bottom: 1px solid var(--border-subtle);
2042
+ flex-shrink: 0;
2043
+ }
2044
+
2045
+ .mate-datastore-top-title {
2046
+ display: flex;
2047
+ align-items: center;
2048
+ gap: 6px;
2049
+ font-weight: 700;
2050
+ font-size: 15px;
2051
+ color: var(--text);
2052
+ }
2053
+
2054
+ .mate-datastore-top-title .lucide {
2055
+ width: 14px;
2056
+ height: 14px;
2057
+ color: var(--accent);
2058
+ opacity: 0.85;
2059
+ }
2060
+
2061
+ .mate-datastore-top-actions {
2062
+ display: flex;
2063
+ align-items: center;
2064
+ gap: 8px;
2065
+ }
2066
+
2011
2067
  .mate-db-status {
2012
- padding: 8px 12px 0;
2068
+ padding: 10px 14px 0;
2013
2069
  font-size: 12px;
2014
2070
  color: var(--text-secondary, #8e8e8e);
2015
2071
  }
@@ -2028,9 +2084,9 @@ body.mate-dm-active #layout.sidebar-collapsed .mate-collapsed-info {
2028
2084
 
2029
2085
  .mate-db-layout {
2030
2086
  display: grid;
2031
- grid-template-columns: 130px minmax(0, 1fr);
2087
+ grid-template-columns: 220px minmax(0, 1fr);
2032
2088
  gap: 10px;
2033
- padding: 8px 8px 12px;
2089
+ padding: 12px 10px 10px;
2034
2090
  min-height: 0;
2035
2091
  flex: 1;
2036
2092
  }
@@ -2044,10 +2100,10 @@ body.mate-dm-active #layout.sidebar-collapsed .mate-collapsed-info {
2044
2100
 
2045
2101
  .mate-db-table-list {
2046
2102
  overflow-y: auto;
2047
- border: 1px solid var(--border-subtle, rgba(255,255,255,0.08));
2048
- border-radius: 10px;
2049
- background: var(--bg-alt, rgba(255,255,255,0.03));
2050
- padding: 4px;
2103
+ border: 1px solid var(--border-subtle, rgba(255,255,255,0.06));
2104
+ border-radius: 12px;
2105
+ background: var(--sidebar-bg, rgba(255,255,255,0.03));
2106
+ padding: 6px;
2051
2107
  flex: 1;
2052
2108
  }
2053
2109
 
@@ -2123,46 +2179,32 @@ body.mate-dm-active #layout.sidebar-collapsed .mate-collapsed-info {
2123
2179
  }
2124
2180
 
2125
2181
  .mate-db-table-schema {
2126
- max-height: 120px;
2182
+ max-height: 180px;
2127
2183
  }
2128
2184
 
2129
- .mate-db-query,
2130
- .mate-db-params {
2131
- width: 100%;
2132
- min-height: 72px;
2133
- padding: 10px;
2134
- border-radius: 10px;
2135
- border: 1px solid var(--border-subtle, rgba(255,255,255,0.1));
2136
- background: var(--bg-secondary, rgba(255,255,255,0.04));
2137
- color: var(--text, #fff);
2138
- font-family: var(--mono-font, ui-monospace, SFMono-Regular, Menlo, Consolas, monospace);
2139
- font-size: 11px;
2140
- resize: vertical;
2185
+ @media (max-width: 900px) {
2186
+ .mate-db-layout {
2187
+ grid-template-columns: 1fr;
2188
+ }
2141
2189
  }
2142
2190
 
2143
- .mate-db-params {
2144
- min-height: 54px;
2191
+ body.mate-dm-active .mate-datastore-top-bar {
2192
+ background: var(--mate-color);
2193
+ color: #fff;
2145
2194
  }
2146
2195
 
2147
- .mate-db-actions {
2148
- display: flex;
2149
- gap: 8px;
2196
+ body.mate-dm-active .mate-datastore-top-title,
2197
+ body.mate-dm-active .mate-datastore-top-title .lucide {
2198
+ color: #fff;
2150
2199
  }
2151
2200
 
2152
- .mate-db-actions button {
2153
- flex: 1;
2154
- height: 30px;
2155
- border: none;
2156
- border-radius: 8px;
2157
- background: var(--sidebar-active, rgba(255,255,255,0.08));
2158
- color: var(--text, #fff);
2159
- font-size: 12px;
2160
- font-weight: 600;
2161
- cursor: pointer;
2201
+ body.mate-dm-active .mate-datastore-top-bar .scheduler-close-btn {
2202
+ color: rgba(255, 255, 255, 0.85);
2162
2203
  }
2163
2204
 
2164
- .mate-db-actions button:hover {
2165
- background: var(--sidebar-hover, rgba(255,255,255,0.12));
2205
+ body.mate-dm-active .mate-datastore-top-bar .scheduler-close-btn:hover {
2206
+ color: #fff;
2207
+ background: rgba(255, 255, 255, 0.15);
2166
2208
  }
2167
2209
 
2168
2210
  .mate-session-item.search-match {
@@ -270,7 +270,6 @@
270
270
  <div class="mate-sidebar-sessions-header">
271
271
  <span>Conversations</span>
272
272
  <div class="mate-sidebar-actions">
273
- <button id="mate-data-btn" type="button" title="Data inspector"><i data-lucide="database"></i></button>
274
273
  <button id="mate-search-session-btn" type="button" title="Search sessions"><i data-lucide="search"></i></button>
275
274
  <button id="mate-new-session-btn" type="button" title="New session"><i data-lucide="plus"></i></button>
276
275
  </div>
@@ -281,33 +280,6 @@
281
280
  </div>
282
281
  <div id="mate-session-list" class="mate-session-list"></div>
283
282
  </div>
284
- <div id="mate-sidebar-datastore" class="hidden">
285
- <div class="mate-sidebar-sessions-header">
286
- <span>Data</span>
287
- <div class="mate-sidebar-actions">
288
- <button id="mate-db-refresh-btn" type="button" title="Refresh tables"><i data-lucide="refresh-cw"></i></button>
289
- <button id="mate-db-back-btn" type="button" title="Back to conversations"><i data-lucide="x"></i></button>
290
- </div>
291
- </div>
292
- <div class="mate-db-status" id="mate-db-status"></div>
293
- <div class="mate-db-layout">
294
- <div class="mate-db-table-column">
295
- <div class="mate-db-section-title">Objects</div>
296
- <div id="mate-db-table-list" class="mate-db-table-list"></div>
297
- </div>
298
- <div class="mate-db-detail">
299
- <div class="mate-db-section-title" id="mate-db-table-name">No table selected</div>
300
- <pre id="mate-db-table-schema" class="mate-db-table-schema"></pre>
301
- <textarea id="mate-db-query" class="mate-db-query" spellcheck="false" placeholder="SELECT * FROM table LIMIT 50;"></textarea>
302
- <textarea id="mate-db-params" class="mate-db-params" spellcheck="false" placeholder='[]'></textarea>
303
- <div class="mate-db-actions">
304
- <button id="mate-db-query-btn" type="button">Query</button>
305
- <button id="mate-db-exec-btn" type="button">Exec</button>
306
- </div>
307
- <pre id="mate-db-result" class="mate-db-result"></pre>
308
- </div>
309
- </div>
310
- </div>
311
283
  <div id="mate-sidebar-memory" class="hidden"></div>
312
284
  <div id="mate-sidebar-knowledge" class="hidden">
313
285
  <div class="mate-sidebar-sessions-header">
@@ -1883,7 +1855,7 @@
1883
1855
  <div class="mate-intro-step"><span class="mate-intro-step-num">2</span> Have a short interview where your Mate gets to know you</div>
1884
1856
  <div class="mate-intro-step"><span class="mate-intro-step-num">3</span> Start talking</div>
1885
1857
  </div>
1886
- <p class="mate-intro-privacy">Mates run on Claude Code. No separate API keys or external services needed. Your conversations stay on your Clay server and are never stored elsewhere.</p>
1858
+ <p class="mate-intro-privacy">Mates run on Claude Code or ChatGPT Codex, your choice. No separate API keys or external services needed. Your conversations stay on your Clay server and are never stored elsewhere.</p>
1887
1859
  </div>
1888
1860
  </div>
1889
1861
  <!-- Step 1: Relationship -->
@@ -2024,26 +1996,24 @@
2024
1996
  </div>
2025
1997
  </div>
2026
1998
 
2027
- <!-- Step 4: Autonomy -->
1999
+ <!-- Step 4: Vendor -->
2028
2000
  <div class="mate-step" data-step="4">
2029
- <h3>How much should they do on their own?</h3>
2030
- <p class="mate-hint">This is about how much freedom your mate gets before checking with you.</p>
2031
- <div class="mate-autonomy-options">
2032
- <button class="mate-autonomy-btn" data-value="always_ask">
2033
- <span class="mate-autonomy-title">Ask me everything</span>
2034
- <span class="mate-autonomy-desc">"Before you do anything, run it by me first."</span>
2035
- </button>
2036
- <button class="mate-autonomy-btn active" data-value="minor_stuff_ok">
2037
- <span class="mate-autonomy-title">Small stuff is fine</span>
2038
- <span class="mate-autonomy-desc">"Little things, just do it. Anything big, ask me."</span>
2039
- </button>
2040
- <button class="mate-autonomy-btn" data-value="mostly_autonomous">
2041
- <span class="mate-autonomy-title">Mostly free</span>
2042
- <span class="mate-autonomy-desc">"Do your thing. Only check if it's really important."</span>
2001
+ <h3>Which model should power them?</h3>
2002
+ <p class="mate-hint">You can switch this anytime from the mate's settings.</p>
2003
+ <div class="mate-vendor-option-list">
2004
+ <button class="mate-vendor-option-btn active" data-value="claude">
2005
+ <img src="/claude-code-avatar.png" class="mate-vendor-option-icon" alt="Claude Code">
2006
+ <div class="mate-vendor-option-text">
2007
+ <span class="mate-vendor-option-title">Claude Code</span>
2008
+ <span class="mate-vendor-option-desc">Anthropic's Claude. Thoughtful, conversational, strong at nuanced reasoning and long-form writing. A good default for most mates.</span>
2009
+ </div>
2043
2010
  </button>
2044
- <button class="mate-autonomy-btn" data-value="fully_autonomous">
2045
- <span class="mate-autonomy-title">Full freedom</span>
2046
- <span class="mate-autonomy-desc">"Just get it done and tell me after."</span>
2011
+ <button class="mate-vendor-option-btn" data-value="codex">
2012
+ <img src="/codex-avatar.png" class="mate-vendor-option-icon" alt="ChatGPT Codex">
2013
+ <div class="mate-vendor-option-text">
2014
+ <span class="mate-vendor-option-title">ChatGPT Codex</span>
2015
+ <span class="mate-vendor-option-desc">OpenAI's GPT coding agent. Fast and direct, strong at code generation and tight execution loops. Good for builder-type mates.</span>
2016
+ </div>
2047
2017
  </button>
2048
2018
  </div>
2049
2019
  </div>
@@ -474,8 +474,6 @@ export function buildMateInterviewPrompt(mate) {
474
474
  var styles = sd.communicationStyle.map(function (s) { return styleLabels[s] || s.replace(/_/g, " "); });
475
475
  parts.push("Communication: " + styles.join(", "));
476
476
  }
477
- if (sd.autonomy) parts.push("Autonomy: " + sd.autonomy.replace(/_/g, " "));
478
-
479
477
  return "Use the /clay-mate-interview skill to start the interview.\n\n" +
480
478
  "Mate ID: " + mate.id + "\n" +
481
479
  "Mate Directory: .claude/mates/" + mate.id + "\n\n" +
@@ -14,7 +14,7 @@ import { renderSessionList, updateSessionPresence, populateCliSessionList, handl
14
14
  import { updateDmBadge, renderSidebarPresence, setMentionActive, renderUserStrip } from './sidebar-mates.js';
15
15
  import { refreshMobileChatSheet } from './sidebar-mobile.js';
16
16
  import { renderMateSessionList, handleMateSearchResults, updateMateSidebarProfile } from './mate-sidebar.js';
17
- import { handleMateDatastoreTablesResult, handleMateDatastoreDescribeResult, handleMateDatastoreQueryResult, handleMateDatastoreExecResult, handleMateDatastoreError, handleMateDatastoreChange } from './mate-datastore-ui.js';
17
+ import { handleMateDatastoreTablesResult, handleMateDatastoreDescribeResult, handleMateDatastoreQueryResult, handleMateDatastoreError, handleMateDatastoreChange } from './mate-datastore-ui.js';
18
18
  import { renderKnowledgeList, handleKnowledgeContent } from './mate-knowledge.js';
19
19
  import { renderMemoryList } from './mate-memory.js';
20
20
  import { handlePaletteSessionSwitch, setPaletteVersion } from './command-palette.js';
@@ -288,10 +288,6 @@ export function processMessage(msg) {
288
288
  handleMateDatastoreQueryResult(msg);
289
289
  break;
290
290
 
291
- case "mate_db_exec_result":
292
- handleMateDatastoreExecResult(msg);
293
- break;
294
-
295
291
  case "mate_db_error":
296
292
  handleMateDatastoreError(msg);
297
293
  break;
@@ -736,6 +732,8 @@ export function processMessage(msg) {
736
732
  getTools()[msg.id] = { el: null, name: msg.name, input: null, done: true, hidden: true };
737
733
  } else if (msg.name === "propose_debate" || (msg.name && msg.name.indexOf("propose_debate") !== -1)) {
738
734
  getTools()[msg.id] = { el: null, name: msg.name, input: null, done: true, hidden: true };
735
+ } else if (msg.name === "ask_user_questions") {
736
+ getTools()[msg.id] = { el: null, name: msg.name, input: null, done: true, hidden: true };
739
737
  } else if (getTodoTools()[msg.name]) {
740
738
  getTools()[msg.id] = { el: null, name: msg.name, input: null, done: true, hidden: true };
741
739
  } else {
@@ -17,12 +17,10 @@ import { getScheduledMsgEl } from './app-rate-limit.js';
17
17
  export var VENDOR_AVATARS = {
18
18
  claude: "/claude-code-avatar.png",
19
19
  codex: "/codex-avatar.png",
20
- gemini: "/claude-code-avatar.png",
21
20
  };
22
21
  export var VENDOR_NAMES = {
23
22
  claude: "Claude Code",
24
23
  codex: "Codex",
25
- gemini: "Gemini",
26
24
  };
27
25
  var NEW_MSG_BTN_DEFAULT = "\u2193 Latest";
28
26
  var NEW_MSG_BTN_ACTIVITY = "\u2193 New activity";