clay-server 2.18.0-beta.2 → 2.18.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
@@ -3673,8 +3673,18 @@ function createProjectContext(opts) {
3673
3673
  var avatarStyle = (mate.profile && mate.profile.avatarStyle) || "bottts";
3674
3674
  var avatarSeed = (mate.profile && mate.profile.avatarSeed) || mate.id;
3675
3675
 
3676
+ // Build full mention text (include pasted content)
3677
+ var mentionFullInput = msg.text;
3678
+ if (msg.pastes && msg.pastes.length > 0) {
3679
+ for (var pi = 0; pi < msg.pastes.length; pi++) {
3680
+ if (mentionFullInput) mentionFullInput += "\n\n";
3681
+ mentionFullInput += msg.pastes[pi];
3682
+ }
3683
+ }
3684
+
3676
3685
  // Save mention user message to session history
3677
3686
  var mentionUserEntry = { type: "mention_user", text: msg.text, mateId: msg.mateId, mateName: mateName };
3687
+ if (msg.pastes && msg.pastes.length > 0) mentionUserEntry.pastes = msg.pastes;
3678
3688
  session.history.push(mentionUserEntry);
3679
3689
  sm.appendToSessionFile(session, mentionUserEntry);
3680
3690
  sendToSessionOthers(ws, session.localId, mentionUserEntry);
@@ -3769,7 +3779,7 @@ function createProjectContext(opts) {
3769
3779
  if (canContinue) {
3770
3780
  // Continue existing mention session with middle context
3771
3781
  var middleContext = buildMiddleContext(recentTurns, msg.mateId);
3772
- var continuationText = middleContext ? middleContext + "\n\n" + msg.text : msg.text;
3782
+ var continuationText = middleContext ? middleContext + "\n\n" + mentionFullInput : mentionFullInput;
3773
3783
  existingSession.pushMessage(continuationText, mentionCallbacks);
3774
3784
  } else {
3775
3785
  // Clean up old session if it exists
@@ -3787,18 +3797,74 @@ function createProjectContext(opts) {
3787
3797
  // CLAUDE.md may not exist for new mates
3788
3798
  }
3789
3799
 
3800
+ // Load recent session digests for context continuity
3801
+ var recentDigests = "";
3802
+ try {
3803
+ var digestFile = path.join(mateDir, "knowledge", "session-digests.jsonl");
3804
+ if (fs.existsSync(digestFile)) {
3805
+ var allLines = fs.readFileSync(digestFile, "utf8").trim().split("\n");
3806
+ var recent = allLines.slice(-5); // last 5 digests
3807
+ if (recent.length > 0) {
3808
+ recentDigests = "\n\nYour recent session memories (from past @mentions):\n";
3809
+ for (var di = 0; di < recent.length; di++) {
3810
+ try {
3811
+ var d = JSON.parse(recent[di]);
3812
+ recentDigests += "- [" + (d.date || "?") + "] " + (d.topic || "unknown") + ": " + (d.my_position || "") +
3813
+ (d.decisions ? " | Decisions: " + d.decisions : "") +
3814
+ (d.open_items ? " | Open: " + d.open_items : "") + "\n";
3815
+ } catch (e) {}
3816
+ }
3817
+ }
3818
+ }
3819
+ } catch (e) {}
3820
+
3790
3821
  // Build initial mention context
3791
- var mentionContext = buildMentionContext(userName, recentTurns);
3822
+ var mentionContext = buildMentionContext(userName, recentTurns) + recentDigests;
3792
3823
 
3793
3824
  // Create new persistent mention session
3794
3825
  sdk.createMentionSession({
3795
3826
  claudeMd: claudeMd,
3796
3827
  initialContext: mentionContext,
3797
- initialMessage: msg.text,
3828
+ initialMessage: mentionFullInput,
3798
3829
  onActivity: mentionCallbacks.onActivity,
3799
3830
  onDelta: mentionCallbacks.onDelta,
3800
3831
  onDone: mentionCallbacks.onDone,
3801
3832
  onError: mentionCallbacks.onError,
3833
+ canUseTool: function (toolName, input, toolOpts) {
3834
+ var autoAllow = { Read: true, Glob: true, Grep: true };
3835
+ if (autoAllow[toolName]) {
3836
+ return Promise.resolve({ behavior: "allow", updatedInput: input });
3837
+ }
3838
+ // Route through the project session's permission system
3839
+ return new Promise(function (resolve) {
3840
+ var requestId = crypto.randomUUID();
3841
+ session.pendingPermissions[requestId] = {
3842
+ resolve: resolve,
3843
+ requestId: requestId,
3844
+ toolName: toolName,
3845
+ toolInput: input,
3846
+ toolUseId: toolOpts ? toolOpts.toolUseID : undefined,
3847
+ decisionReason: (toolOpts && toolOpts.decisionReason) || "",
3848
+ };
3849
+ sendToSession(session.localId, {
3850
+ type: "permission_request",
3851
+ requestId: requestId,
3852
+ toolName: toolName,
3853
+ toolInput: input,
3854
+ toolUseId: toolOpts ? toolOpts.toolUseID : undefined,
3855
+ decisionReason: (toolOpts && toolOpts.decisionReason) || "",
3856
+ });
3857
+ onProcessingChanged();
3858
+ if (toolOpts && toolOpts.signal) {
3859
+ toolOpts.signal.addEventListener("abort", function () {
3860
+ delete session.pendingPermissions[requestId];
3861
+ sendToSession(session.localId, { type: "permission_cancel", requestId: requestId });
3862
+ onProcessingChanged();
3863
+ resolve({ behavior: "deny", message: "Request cancelled" });
3864
+ });
3865
+ }
3866
+ });
3867
+ },
3802
3868
  }).then(function (mentionSession) {
3803
3869
  if (mentionSession) {
3804
3870
  session._mentionSessions[msg.mateId] = mentionSession;
@@ -2002,10 +2002,14 @@ body.mate-dm-active .ask-user-container:not(.mate-ask-user),
2002
2002
  body.mate-dm-active .subagent-log,
2003
2003
  body.mate-dm-active .conflict-msg,
2004
2004
  body.mate-dm-active .context-overflow-msg,
2005
- body.mate-dm-active .sys-msg,
2006
- body.mate-dm-active .activity-inline:not(.mention-activity-bar) {
2005
+ body.mate-dm-active .sys-msg {
2007
2006
  display: none;
2008
2007
  }
2008
+ body.mate-dm-active .activity-inline:not(.mention-activity-bar) {
2009
+ padding-left: 60px;
2010
+ margin-left: 0;
2011
+ margin-right: 0;
2012
+ }
2009
2013
 
2010
2014
  /* ==========================================================================
2011
2015
  Mobile Mate DM Title Bar
@@ -92,9 +92,10 @@ export function sendMessage() {
92
92
  if (mention) {
93
93
  hideMentionMenu();
94
94
  if (ctx.hideSuggestionChips) ctx.hideSuggestionChips();
95
+ var mentionPastes = pendingPastes.map(function (p) { return p.text; });
95
96
  // Render user message with mention chip (same as history replay)
96
97
  renderMentionUser({ mateName: mention.mateName, text: mention.text });
97
- sendMention(mention.mateId, mention.text);
98
+ sendMention(mention.mateId, mention.text, mentionPastes);
98
99
  clearMentionState();
99
100
  ctx.inputEl.value = "";
100
101
  sendInputSync();
@@ -233,9 +233,11 @@ export function clearMentionState() {
233
233
  removeInputMentionChip();
234
234
  }
235
235
 
236
- export function sendMention(mateId, text) {
236
+ export function sendMention(mateId, text, pastes) {
237
237
  if (!ctx.ws || !ctx.connected) return;
238
- ctx.ws.send(JSON.stringify({ type: "mention", mateId: mateId, text: text }));
238
+ var payload = { type: "mention", mateId: mateId, text: text };
239
+ if (pastes && pastes.length > 0) payload.pastes = pastes;
240
+ ctx.ws.send(JSON.stringify(payload));
239
241
  }
240
242
 
241
243
  // --- Mention response rendering ---
package/lib/sdk-bridge.js CHANGED
@@ -1773,7 +1773,7 @@ function createSDKBridge(opts) {
1773
1773
  settingSources: ["user"],
1774
1774
  includePartialMessages: true,
1775
1775
  abortController: abortController,
1776
- canUseTool: function (toolName, input) {
1776
+ canUseTool: opts.canUseTool || function (toolName, input) {
1777
1777
  var allowed = { Read: true, Glob: true, Grep: true };
1778
1778
  if (allowed[toolName]) {
1779
1779
  return Promise.resolve({ behavior: "allow", updatedInput: input });
@@ -1866,16 +1866,21 @@ function createSDKBridge(opts) {
1866
1866
  } else if (sdkMsg.type === "result") {
1867
1867
  // One response complete. Signal done and reset for next message.
1868
1868
  if (currentOnActivity) currentOnActivity(null);
1869
- if (currentOnDone) {
1870
- currentOnDone(responseFullText);
1869
+ var doneRef = currentOnDone;
1870
+ if (doneRef) {
1871
+ doneRef(responseFullText);
1872
+ }
1873
+ // Only reset if pushMessage was not called during onDone
1874
+ // (pushMessage swaps callbacks and resets state itself)
1875
+ if (currentOnDone === doneRef) {
1876
+ currentOnDelta = null;
1877
+ currentOnDone = null;
1878
+ currentOnError = null;
1879
+ currentOnActivity = null;
1880
+ mentionBlocks = {};
1881
+ responseFullText = "";
1882
+ responseStreamedText = false;
1871
1883
  }
1872
- currentOnDelta = null;
1873
- currentOnDone = null;
1874
- currentOnError = null;
1875
- currentOnActivity = null;
1876
- mentionBlocks = {};
1877
- responseFullText = "";
1878
- responseStreamedText = false;
1879
1884
  }
1880
1885
  }
1881
1886
  } catch (err) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "clay-server",
3
- "version": "2.18.0-beta.2",
3
+ "version": "2.18.0-beta.4",
4
4
  "description": "Web UI for Claude Code. Any device. Push notifications.",
5
5
  "bin": {
6
6
  "clay-server": "./bin/cli.js",