clay-server 2.18.0-beta.2 → 2.18.0-beta.3

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
@@ -3794,11 +3804,46 @@ function createProjectContext(opts) {
3794
3804
  sdk.createMentionSession({
3795
3805
  claudeMd: claudeMd,
3796
3806
  initialContext: mentionContext,
3797
- initialMessage: msg.text,
3807
+ initialMessage: mentionFullInput,
3798
3808
  onActivity: mentionCallbacks.onActivity,
3799
3809
  onDelta: mentionCallbacks.onDelta,
3800
3810
  onDone: mentionCallbacks.onDone,
3801
3811
  onError: mentionCallbacks.onError,
3812
+ canUseTool: function (toolName, input, toolOpts) {
3813
+ var autoAllow = { Read: true, Glob: true, Grep: true };
3814
+ if (autoAllow[toolName]) {
3815
+ return Promise.resolve({ behavior: "allow", updatedInput: input });
3816
+ }
3817
+ // Route through the project session's permission system
3818
+ return new Promise(function (resolve) {
3819
+ var requestId = crypto.randomUUID();
3820
+ session.pendingPermissions[requestId] = {
3821
+ resolve: resolve,
3822
+ requestId: requestId,
3823
+ toolName: toolName,
3824
+ toolInput: input,
3825
+ toolUseId: toolOpts ? toolOpts.toolUseID : undefined,
3826
+ decisionReason: (toolOpts && toolOpts.decisionReason) || "",
3827
+ };
3828
+ sendToSession(session.localId, {
3829
+ type: "permission_request",
3830
+ requestId: requestId,
3831
+ toolName: toolName,
3832
+ toolInput: input,
3833
+ toolUseId: toolOpts ? toolOpts.toolUseID : undefined,
3834
+ decisionReason: (toolOpts && toolOpts.decisionReason) || "",
3835
+ });
3836
+ onProcessingChanged();
3837
+ if (toolOpts && toolOpts.signal) {
3838
+ toolOpts.signal.addEventListener("abort", function () {
3839
+ delete session.pendingPermissions[requestId];
3840
+ sendToSession(session.localId, { type: "permission_cancel", requestId: requestId });
3841
+ onProcessingChanged();
3842
+ resolve({ behavior: "deny", message: "Request cancelled" });
3843
+ });
3844
+ }
3845
+ });
3846
+ },
3802
3847
  }).then(function (mentionSession) {
3803
3848
  if (mentionSession) {
3804
3849
  session._mentionSessions[msg.mateId] = mentionSession;
@@ -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.3",
4
4
  "description": "Web UI for Claude Code. Any device. Push notifications.",
5
5
  "bin": {
6
6
  "clay-server": "./bin/cli.js",