@privateclaw/privateclaw 0.1.16 → 0.1.18

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 (42) hide show
  1. package/README.md +44 -1
  2. package/dist/audio-transcriber.d.ts +46 -0
  3. package/dist/audio-transcriber.js +433 -0
  4. package/dist/audio-transcriber.js.map +1 -0
  5. package/dist/bridges/openai-compatible-bridge.js +1 -0
  6. package/dist/bridges/openai-compatible-bridge.js.map +1 -1
  7. package/dist/bridges/openclaw-agent-bridge.d.ts +10 -2
  8. package/dist/bridges/openclaw-agent-bridge.js +632 -73
  9. package/dist/bridges/openclaw-agent-bridge.js.map +1 -1
  10. package/dist/cli.js +57 -6
  11. package/dist/cli.js.map +1 -1
  12. package/dist/openclaw-plugin.js +150 -51
  13. package/dist/openclaw-plugin.js.map +1 -1
  14. package/dist/pair-daemon.d.ts +2 -0
  15. package/dist/pair-daemon.js +2 -0
  16. package/dist/pair-daemon.js.map +1 -1
  17. package/dist/provider.d.ts +14 -1
  18. package/dist/provider.js +262 -20
  19. package/dist/provider.js.map +1 -1
  20. package/dist/session-control.d.ts +7 -0
  21. package/dist/session-control.js +122 -0
  22. package/dist/session-control.js.map +1 -1
  23. package/dist/text.d.ts +2 -0
  24. package/dist/text.js +3 -1
  25. package/dist/text.js.map +1 -1
  26. package/dist/types.d.ts +21 -2
  27. package/package.json +2 -2
  28. package/src/audio-transcriber.test.ts +299 -0
  29. package/src/audio-transcriber.ts +615 -0
  30. package/src/bridges/openai-compatible-bridge.ts +1 -0
  31. package/src/bridges/openclaw-agent-bridge.test.ts +644 -7
  32. package/src/bridges/openclaw-agent-bridge.ts +817 -81
  33. package/src/cli.ts +73 -5
  34. package/src/openclaw-plugin.test.ts +12 -2
  35. package/src/openclaw-plugin.ts +191 -54
  36. package/src/pair-daemon.ts +4 -0
  37. package/src/provider.test.ts +679 -0
  38. package/src/provider.ts +349 -28
  39. package/src/session-control.test.ts +80 -0
  40. package/src/session-control.ts +151 -0
  41. package/src/text.ts +12 -2
  42. package/src/types.ts +29 -1
package/dist/provider.js CHANGED
@@ -4,7 +4,7 @@ import QRCode from "qrcode";
4
4
  import { PRIVATECLAW_QR_ERROR_CORRECTION_LEVEL, PRIVATECLAW_QR_IMAGE_MARGIN, PRIVATECLAW_QR_PNG_WIDTH, PRIVATECLAW_QR_SVG_MARGIN, PRIVATECLAW_QR_TERMINAL_MARGIN, } from "./qr-options.js";
5
5
  import { RelayProviderClient } from "./relay-provider-client.js";
6
6
  import { buildInviteAnnouncementText, formatBilingualInline, formatBilingualText, PRIVATECLAW_MUTE_BOT_DESCRIPTION, PRIVATECLAW_RENEW_SESSION_DESCRIPTION, PRIVATECLAW_SESSION_QR_DESCRIPTION, PRIVATECLAW_UNMUTE_BOT_DESCRIPTION, } from "./text.js";
7
- export const DEFAULT_SESSION_TTL_MS = 8 * 60 * 60 * 1000;
7
+ export const DEFAULT_SESSION_TTL_MS = 24 * 60 * 60 * 1000;
8
8
  const RENEW_SESSION_TTL_MS = DEFAULT_SESSION_TTL_MS;
9
9
  const SESSION_RENEWAL_REMINDER_WINDOW_MS = 30 * 60 * 1000;
10
10
  const PARTICIPANT_LABEL_MAX_CHARS = 12;
@@ -39,12 +39,27 @@ function normalizeBridgeMessages(response) {
39
39
  function nowIso() {
40
40
  return new Date().toISOString();
41
41
  }
42
+ function readNonEmptyString(value) {
43
+ if (typeof value !== "string") {
44
+ return undefined;
45
+ }
46
+ const trimmed = value.trim();
47
+ return trimmed === "" ? undefined : trimmed;
48
+ }
42
49
  function buildMessageId(prefix) {
43
50
  return `${prefix}-${randomUUID()}`;
44
51
  }
45
52
  function buildPendingAssistantMessageId(replyTo) {
46
53
  return `pending-${replyTo}`;
47
54
  }
55
+ function buildThinkingMessageId(replyTo) {
56
+ return `thinking-${replyTo}`;
57
+ }
58
+ function cloneThinkingEntry(entry) {
59
+ return {
60
+ ...entry,
61
+ };
62
+ }
48
63
  function sanitizeParticipantLabel(raw) {
49
64
  if (!raw) {
50
65
  return undefined;
@@ -110,8 +125,37 @@ function cloneConversationTurn(turn) {
110
125
  })),
111
126
  }
112
127
  : {}),
128
+ ...(turn.thinkingEntries
129
+ ? {
130
+ thinkingEntries: turn.thinkingEntries.map(cloneThinkingEntry),
131
+ }
132
+ : {}),
113
133
  };
114
134
  }
135
+ function countPayloadAttachments(payload) {
136
+ return Array.isArray(payload.attachments) ? payload.attachments.length : 0;
137
+ }
138
+ function toUnknownRecord(value) {
139
+ return value;
140
+ }
141
+ function summarizePayload(payload) {
142
+ const record = toUnknownRecord(payload);
143
+ const text = typeof record.text === "string" ? record.text : "";
144
+ const message = typeof record.message === "string" ? record.message : "";
145
+ const senderAppId = readNonEmptyString(record.senderAppId);
146
+ const targetAppId = readNonEmptyString(record.targetAppId);
147
+ const replyTo = readNonEmptyString(record.replyTo);
148
+ return [
149
+ `kind=${payload.kind}`,
150
+ `textChars=${text.length}`,
151
+ `messageChars=${message.length}`,
152
+ `attachments=${countPayloadAttachments(record)}`,
153
+ `replyTo=${JSON.stringify(replyTo ?? "none")}`,
154
+ `senderAppId=${JSON.stringify(senderAppId ?? "none")}`,
155
+ `targetAppId=${JSON.stringify(targetAppId ?? "broadcast")}`,
156
+ `pending=${record.pending === true}`,
157
+ ].join(" ");
158
+ }
115
159
  function buildRelayLabel(appWsUrl) {
116
160
  try {
117
161
  const url = new URL(appWsUrl);
@@ -169,9 +213,9 @@ function fromProviderSessionHandoff(snapshot) {
169
213
  function buildRenewalReminderMessage(session) {
170
214
  const command = "/renew-session";
171
215
  if (session.groupMode) {
172
- return formatBilingualText(`这个 PrivateClaw 群聊会话将在 30 分钟内过期(${session.invite.expiresAt})。任意参与者都可以发送 ${command} 将它延长 8 小时。`, `This PrivateClaw group session will expire in less than 30 minutes (at ${session.invite.expiresAt}). Any participant can send ${command} to extend it by 8 hours.`);
216
+ return formatBilingualText(`这个 PrivateClaw 群聊会话将在 30 分钟内过期(${session.invite.expiresAt})。任意参与者都可以发送 ${command} 将它延长 24 小时。`, `This PrivateClaw group session will expire in less than 30 minutes (at ${session.invite.expiresAt}). Any participant can send ${command} to extend it by 24 hours.`);
173
217
  }
174
- return formatBilingualText(`这个 PrivateClaw 会话将在 30 分钟内过期(${session.invite.expiresAt})。发送 ${command} 可将它延长 8 小时。`, `This PrivateClaw session will expire in less than 30 minutes (at ${session.invite.expiresAt}). Send ${command} to extend it by 8 hours.`);
218
+ return formatBilingualText(`这个 PrivateClaw 会话将在 30 分钟内过期(${session.invite.expiresAt})。发送 ${command} 可将它延长 24 小时。`, `This PrivateClaw session will expire in less than 30 minutes (at ${session.invite.expiresAt}). Send ${command} to extend it by 24 hours.`);
175
219
  }
176
220
  function buildSessionQrMessage(session) {
177
221
  if (session.groupMode) {
@@ -197,6 +241,13 @@ function formatBridgeHistoryTurn(turn) {
197
241
  text: `${turn.participantLabel}: ${turn.text}`,
198
242
  };
199
243
  }
244
+ function normalizeBridgeSlashCommandText(text) {
245
+ const trimmed = text.trim();
246
+ return trimmed.startsWith("/") ? trimmed : undefined;
247
+ }
248
+ function cloneThinkingEntries(entries) {
249
+ return entries.map(cloneThinkingEntry);
250
+ }
200
251
  function isAudioAttachment(attachment) {
201
252
  const normalizedMimeType = attachment.mimeType.trim().toLowerCase();
202
253
  if (normalizedMimeType.startsWith("audio/")) {
@@ -358,8 +409,19 @@ export class PrivateClawProvider {
358
409
  },
359
410
  });
360
411
  }
412
+ isVerboseLoggingEnabled() {
413
+ return this.options.verboseController?.enabled === true;
414
+ }
415
+ verboseLog(message) {
416
+ if (!this.isVerboseLoggingEnabled()) {
417
+ return;
418
+ }
419
+ this.options.onLog?.(`[provider][verbose] ${message}`);
420
+ }
361
421
  async connect() {
422
+ this.verboseLog(`connect_start providerId=${this.relayClient.getProviderId()} relay=${JSON.stringify(this.options.providerWsUrl)}`);
362
423
  await this.relayClient.connect();
424
+ this.verboseLog(`connect_complete providerId=${this.relayClient.getProviderId()} activeSessions=${this.sessions.size}`);
363
425
  }
364
426
  async dispose(params) {
365
427
  const closeSessions = params?.closeSessions !== false;
@@ -480,34 +542,80 @@ export class PrivateClawProvider {
480
542
  return session;
481
543
  }
482
544
  buildBridgeHistory(session) {
483
- return session.history.map(formatBridgeHistoryTurn);
545
+ return session.history
546
+ .filter((turn) => turn.role !== "thinking")
547
+ .map(formatBridgeHistoryTurn);
484
548
  }
485
549
  async prepareUserMessage(session, payload, participant) {
486
550
  const allAttachments = payload.attachments ?? [];
551
+ const directBridgeSlashCommand = normalizeBridgeSlashCommandText(payload.text);
487
552
  const audioAttachments = allAttachments.filter(isAudioAttachment);
553
+ const providerAudioTranscriber = this.options.audioTranscriber;
554
+ const bridgeAudioTranscriber = this.options.bridge.transcribeAudioAttachments
555
+ ? {
556
+ transcribeAudioAttachments: this.options.bridge.transcribeAudioAttachments.bind(this.options.bridge),
557
+ }
558
+ : undefined;
559
+ const availableAudioTranscribers = [
560
+ ...(providerAudioTranscriber
561
+ ? [{ via: "provider", transcriber: providerAudioTranscriber }]
562
+ : []),
563
+ ...(bridgeAudioTranscriber
564
+ ? [{ via: "bridge", transcriber: bridgeAudioTranscriber }]
565
+ : []),
566
+ ];
488
567
  if (audioAttachments.length === 0 ||
489
- !this.options.bridge.transcribeAudioAttachments) {
568
+ availableAudioTranscribers.length === 0) {
569
+ this.verboseLog(`prepared_user_message session=${session.invite.sessionId} request=${payload.clientMessageId} voiceTranscribed=false textChars=${payload.text.length} attachments=${allAttachments.length} bridgeAttachments=${allAttachments.length}`);
490
570
  return {
491
571
  text: payload.text,
572
+ ...(directBridgeSlashCommand
573
+ ? {
574
+ bridgeText: directBridgeSlashCommand,
575
+ historyBridgeText: directBridgeSlashCommand,
576
+ }
577
+ : {}),
492
578
  ...(allAttachments.length > 0 ? { attachments: allAttachments } : {}),
493
579
  ...(allAttachments.length > 0 ? { bridgeAttachments: allAttachments } : {}),
494
580
  };
495
581
  }
496
- this.options.onLog?.(`[provider] voice_transcription_start session=${session.invite.sessionId} request=${payload.clientMessageId} audioAttachments=${audioAttachments.length}`);
497
- const transcript = (await this.options.bridge.transcribeAudioAttachments({
498
- sessionId: session.invite.sessionId,
499
- requestId: payload.clientMessageId,
500
- attachments: audioAttachments,
501
- })).trim();
502
- if (transcript === "") {
503
- throw new Error("OpenClaw STT returned an empty transcript.");
582
+ let transcript = "";
583
+ let transcriptVia;
584
+ const transcriptionFailures = [];
585
+ for (let index = 0; index < availableAudioTranscribers.length; index += 1) {
586
+ const candidate = availableAudioTranscribers[index];
587
+ const nextCandidate = availableAudioTranscribers[index + 1];
588
+ this.options.onLog?.(`[provider] voice_transcription_start session=${session.invite.sessionId} request=${payload.clientMessageId} audioAttachments=${audioAttachments.length} via=${candidate.via}`);
589
+ try {
590
+ transcript = (await candidate.transcriber.transcribeAudioAttachments({
591
+ sessionId: session.invite.sessionId,
592
+ requestId: payload.clientMessageId,
593
+ attachments: audioAttachments,
594
+ })).trim();
595
+ if (transcript === "") {
596
+ throw new Error("OpenClaw STT returned an empty transcript.");
597
+ }
598
+ transcriptVia = candidate.via;
599
+ break;
600
+ }
601
+ catch (error) {
602
+ const detail = error instanceof Error ? error.message : String(error);
603
+ transcriptionFailures.push(`${candidate.via}: ${detail}`);
604
+ if (nextCandidate) {
605
+ this.options.onLog?.(`[provider] voice_transcription_fallback session=${session.invite.sessionId} request=${payload.clientMessageId} from=${candidate.via} to=${nextCandidate.via} reason=${JSON.stringify(detail.slice(0, 300))}`);
606
+ }
607
+ }
608
+ }
609
+ if (!transcriptVia) {
610
+ throw new Error(`OpenClaw STT failed for ${payload.clientMessageId}: ${transcriptionFailures.join(" | ")}`);
504
611
  }
505
612
  const text = mergeVoiceTranscriptText(transcript, payload.text);
506
613
  const speakerName = participant?.displayName ??
507
614
  sanitizeParticipantLabel(payload.displayName) ??
508
615
  "用户";
509
616
  const passthroughAttachments = allAttachments.filter((attachment) => !isAudioAttachment(attachment));
510
- this.options.onLog?.(`[provider] voice_transcription_complete session=${session.invite.sessionId} request=${payload.clientMessageId} transcriptChars=${transcript.length} passthroughAttachments=${passthroughAttachments.length}`);
617
+ this.options.onLog?.(`[provider] voice_transcription_complete session=${session.invite.sessionId} request=${payload.clientMessageId} transcriptChars=${transcript.length} passthroughAttachments=${passthroughAttachments.length} via=${transcriptVia}`);
618
+ this.verboseLog(`prepared_user_message session=${session.invite.sessionId} request=${payload.clientMessageId} voiceTranscribed=true transcriptChars=${transcript.length} textChars=${payload.text.length} passthroughAttachments=${passthroughAttachments.length} bridgeTextChars=${buildVoiceBridgePromptText(speakerName, text).length}`);
511
619
  return {
512
620
  text: payload.text,
513
621
  bridgeText: buildVoiceBridgePromptText(speakerName, text),
@@ -571,9 +679,13 @@ export class PrivateClawProvider {
571
679
  ...existing,
572
680
  ...(params.deviceLabel ? { deviceLabel: params.deviceLabel } : {}),
573
681
  ...(requestedDisplayName ? { displayName: requestedDisplayName } : {}),
682
+ ...(typeof params.supportsThinkingTrace === "boolean"
683
+ ? { supportsThinkingTrace: params.supportsThinkingTrace }
684
+ : {}),
574
685
  lastSeenAt: params.sentAt,
575
686
  };
576
687
  session.participants.set(normalizedAppId, participant);
688
+ this.verboseLog(`participant_upsert session=${sessionId} appId=${JSON.stringify(normalizedAppId)} isNew=false displayName=${JSON.stringify(participant.displayName)} participants=${session.participants.size}`);
577
689
  return { participant, isNew: false };
578
690
  }
579
691
  const participant = {
@@ -581,13 +693,18 @@ export class PrivateClawProvider {
581
693
  displayName: requestedDisplayName ??
582
694
  buildGeneratedParticipantLabel(sessionId, normalizedAppId, usedLabels),
583
695
  ...(params.deviceLabel ? { deviceLabel: params.deviceLabel } : {}),
696
+ ...(typeof params.supportsThinkingTrace === "boolean"
697
+ ? { supportsThinkingTrace: params.supportsThinkingTrace }
698
+ : {}),
584
699
  joinedAt: params.sentAt,
585
700
  lastSeenAt: params.sentAt,
586
701
  };
587
702
  session.participants.set(normalizedAppId, participant);
703
+ this.verboseLog(`participant_upsert session=${sessionId} appId=${JSON.stringify(normalizedAppId)} isNew=true displayName=${JSON.stringify(participant.displayName)} participants=${session.participants.size}`);
588
704
  return { participant, isNew: true };
589
705
  }
590
706
  async sendPayloadWithSessionKey(sessionId, sessionKey, payload, targetAppId) {
707
+ this.verboseLog(`payload_out session=${sessionId} ${summarizePayload(payload)} target=${JSON.stringify(targetAppId ?? "broadcast")}`);
591
708
  await this.relayClient.sendFrame(sessionId, encryptPayload({
592
709
  sessionId,
593
710
  sessionKey,
@@ -622,6 +739,40 @@ export class PrivateClawProvider {
622
739
  ...(params.attachments ? { attachments: params.attachments } : {}),
623
740
  }, params.targetAppId);
624
741
  }
742
+ async sendThinkingMessage(sessionId, params) {
743
+ const sentAt = params.sentAt ?? nowIso();
744
+ const session = this.requireSession(sessionId);
745
+ if (params.storeHistory !== false) {
746
+ this.upsertThinkingHistoryTurn(session, {
747
+ messageId: params.messageId,
748
+ sentAt,
749
+ status: params.status,
750
+ summary: params.summary,
751
+ entries: params.entries,
752
+ ...(params.replyTo ? { replyTo: params.replyTo } : {}),
753
+ });
754
+ }
755
+ const targetAppIds = params.targetAppId
756
+ ? (session.participants.get(params.targetAppId)?.supportsThinkingTrace === true
757
+ ? [params.targetAppId]
758
+ : [])
759
+ : [...session.participants.values()]
760
+ .filter((participant) => participant.supportsThinkingTrace === true)
761
+ .map((participant) => participant.appId);
762
+ if (targetAppIds.length === 0) {
763
+ return;
764
+ }
765
+ const payload = {
766
+ kind: "thinking_message",
767
+ messageId: params.messageId,
768
+ status: params.status,
769
+ summary: params.summary,
770
+ entries: cloneThinkingEntries(params.entries),
771
+ sentAt,
772
+ ...(params.replyTo ? { replyTo: params.replyTo } : {}),
773
+ };
774
+ await Promise.all(targetAppIds.map((targetAppId) => this.sendPayload(sessionId, payload, targetAppId)));
775
+ }
625
776
  async sendPendingAssistantStatus(sessionId, params) {
626
777
  await this.sendAssistantMessage(sessionId, {
627
778
  text: "",
@@ -746,6 +897,24 @@ export class PrivateClawProvider {
746
897
  ...(params.attachments ? { attachments: params.attachments } : {}),
747
898
  });
748
899
  }
900
+ upsertThinkingHistoryTurn(session, params) {
901
+ const turn = {
902
+ messageId: params.messageId,
903
+ role: "thinking",
904
+ text: params.summary,
905
+ sentAt: params.sentAt,
906
+ thinkingStatus: params.status,
907
+ thinkingSummary: params.summary,
908
+ thinkingEntries: cloneThinkingEntries(params.entries),
909
+ ...(params.replyTo ? { replyTo: params.replyTo } : {}),
910
+ };
911
+ const existingIndex = session.history.findIndex((item) => item.messageId === params.messageId);
912
+ if (existingIndex >= 0) {
913
+ session.history[existingIndex] = turn;
914
+ return;
915
+ }
916
+ session.history.push(turn);
917
+ }
749
918
  updateStoredUserBridgeText(session, messageId, bridgeText) {
750
919
  for (let index = session.history.length - 1; index >= 0; index -= 1) {
751
920
  const turn = session.history[index];
@@ -798,13 +967,15 @@ export class PrivateClawProvider {
798
967
  const currentParticipant = params?.targetAppId
799
968
  ? session.participants.get(params.targetAppId)
800
969
  : undefined;
970
+ const commands = await this.listAvailableCommands(session);
971
+ this.verboseLog(`capabilities_out session=${sessionId} targetAppId=${JSON.stringify(params?.targetAppId ?? "broadcast")} includeCurrentIdentity=${params?.includeCurrentIdentity === true} commands=${commands.length} participants=${session.participants.size} groupMode=${session.groupMode}`);
801
972
  await this.sendPayload(sessionId, {
802
973
  kind: "provider_capabilities",
803
974
  sentAt: nowIso(),
804
975
  expiresAt: session.invite.expiresAt,
805
976
  ...(session.groupMode ? { groupMode: true } : {}),
806
977
  ...(session.groupMode ? { botMuted: session.botMuted } : {}),
807
- commands: await this.listAvailableCommands(session),
978
+ commands,
808
979
  ...(session.groupMode
809
980
  ? { participants: this.listParticipants(session) }
810
981
  : {}),
@@ -821,6 +992,7 @@ export class PrivateClawProvider {
821
992
  }
822
993
  async sendHistorySnapshot(sessionId, targetAppId) {
823
994
  const session = this.requireSession(sessionId);
995
+ this.verboseLog(`history_snapshot_out session=${sessionId} targetAppId=${JSON.stringify(targetAppId)} turns=${session.history.length}`);
824
996
  for (const turn of session.history) {
825
997
  switch (turn.role) {
826
998
  case "assistant":
@@ -842,6 +1014,18 @@ export class PrivateClawProvider {
842
1014
  storeHistory: false,
843
1015
  });
844
1016
  break;
1017
+ case "thinking":
1018
+ await this.sendThinkingMessage(sessionId, {
1019
+ messageId: turn.messageId,
1020
+ status: turn.thinkingStatus ?? "completed",
1021
+ summary: turn.thinkingSummary ?? turn.text,
1022
+ entries: turn.thinkingEntries ?? [],
1023
+ sentAt: turn.sentAt,
1024
+ targetAppId,
1025
+ storeHistory: false,
1026
+ ...(turn.replyTo ? { replyTo: turn.replyTo } : {}),
1027
+ });
1028
+ break;
845
1029
  case "user":
846
1030
  if (!session.groupMode || !turn.appId || !turn.participantLabel) {
847
1031
  break;
@@ -901,6 +1085,8 @@ export class PrivateClawProvider {
901
1085
  sessionKey: session.invite.sessionKey,
902
1086
  envelope,
903
1087
  });
1088
+ const payloadRecord = toUnknownRecord(payload);
1089
+ this.verboseLog(`payload_in session=${sessionId} kind=${payload.kind} state=${session.state} appId=${JSON.stringify(readNonEmptyString(payloadRecord.appId) ?? "none")} textChars=${typeof payloadRecord.text === "string" ? payloadRecord.text.length : 0} attachments=${countPayloadAttachments(payloadRecord)}`);
904
1090
  switch (payload.kind) {
905
1091
  case "client_hello": {
906
1092
  const normalizedAppId = payload.appId?.trim() || "legacy-app";
@@ -910,6 +1096,7 @@ export class PrivateClawProvider {
910
1096
  }
911
1097
  const participantState = await this.upsertParticipant(sessionId, {
912
1098
  sentAt: payload.sentAt,
1099
+ supportsThinkingTrace: payload.supportsThinkingTrace === true,
913
1100
  ...(payload.appId ? { appId: normalizedAppId } : {}),
914
1101
  ...(payload.deviceLabel
915
1102
  ? { deviceLabel: payload.deviceLabel }
@@ -921,6 +1108,7 @@ export class PrivateClawProvider {
921
1108
  const participant = participantState.participant;
922
1109
  const wasAwaitingHello = session.state !== "active";
923
1110
  const wasRenewing = Boolean(session.pendingRenewal);
1111
+ this.verboseLog(`client_hello_processed session=${sessionId} appId=${JSON.stringify(participant.appId)} isNew=${participantState.isNew} participants=${session.participants.size} awaitingHello=${wasAwaitingHello} renewing=${wasRenewing} groupMode=${session.groupMode}`);
924
1112
  session.state = "active";
925
1113
  if (wasRenewing) {
926
1114
  session.history.push({
@@ -980,6 +1168,7 @@ export class PrivateClawProvider {
980
1168
  ? [...session.participants.values()][0]
981
1169
  : undefined);
982
1170
  const normalizedCommand = payload.text.trim().toLowerCase();
1171
+ const directBridgeSlashCommand = normalizeBridgeSlashCommandText(payload.text);
983
1172
  const isRenewCommand = normalizedCommand === "/renew-session" ||
984
1173
  normalizedCommand === "/session_renew";
985
1174
  const hasRenewCommandArgs = normalizedCommand.startsWith("/renew-session ") ||
@@ -1138,7 +1327,7 @@ export class PrivateClawProvider {
1138
1327
  });
1139
1328
  }
1140
1329
  }
1141
- if (session.groupMode && session.botMuted) {
1330
+ if (session.groupMode && session.botMuted && !directBridgeSlashCommand) {
1142
1331
  if (!shouldHandleVoiceAsynchronously) {
1143
1332
  await this.sendParticipantMessage(sessionId, {
1144
1333
  text: payload.text,
@@ -1200,11 +1389,26 @@ export class PrivateClawProvider {
1200
1389
  : {}),
1201
1390
  });
1202
1391
  }
1392
+ const bridgeMessage = preparedMessage.bridgeText ??
1393
+ (session.groupMode && participant
1394
+ ? `${participant.displayName}: ${preparedMessage.text}`
1395
+ : preparedMessage.text);
1396
+ const supportsThinkingTrace = this.options.bridge.supportsThinkingTrace === true;
1397
+ const thinkingMessageId = buildThinkingMessageId(payload.clientMessageId);
1398
+ let latestThinkingSummary = "";
1399
+ let latestThinkingEntries = [];
1203
1400
  try {
1204
- const bridgeMessage = preparedMessage.bridgeText ??
1205
- (session.groupMode && participant
1206
- ? `${participant.displayName}: ${preparedMessage.text}`
1207
- : preparedMessage.text);
1401
+ if (supportsThinkingTrace) {
1402
+ await this.sendThinkingMessage(sessionId, {
1403
+ messageId: thinkingMessageId,
1404
+ status: "started",
1405
+ summary: "",
1406
+ entries: [],
1407
+ replyTo: payload.clientMessageId,
1408
+ sentAt: payload.sentAt,
1409
+ storeHistory: false,
1410
+ });
1411
+ }
1208
1412
  const bridgeResponse = await this.options.bridge.handleUserMessage({
1209
1413
  sessionId,
1210
1414
  invite: session.invite,
@@ -1215,7 +1419,34 @@ export class PrivateClawProvider {
1215
1419
  ? { attachments: preparedMessage.attachments }
1216
1420
  : {}),
1217
1421
  history: this.buildBridgeHistory(session),
1422
+ ...(supportsThinkingTrace
1423
+ ? {
1424
+ onThinkingTrace: async (snapshot) => {
1425
+ latestThinkingSummary = snapshot.summary;
1426
+ latestThinkingEntries = cloneThinkingEntries(snapshot.entries);
1427
+ await this.sendThinkingMessage(sessionId, {
1428
+ messageId: thinkingMessageId,
1429
+ status: "streaming",
1430
+ summary: snapshot.summary,
1431
+ entries: snapshot.entries,
1432
+ replyTo: payload.clientMessageId,
1433
+ sentAt: snapshot.sentAt,
1434
+ storeHistory: snapshot.entries.length > 0,
1435
+ });
1436
+ },
1437
+ }
1438
+ : {}),
1218
1439
  });
1440
+ if (supportsThinkingTrace) {
1441
+ await this.sendThinkingMessage(sessionId, {
1442
+ messageId: thinkingMessageId,
1443
+ status: "completed",
1444
+ summary: latestThinkingSummary,
1445
+ entries: latestThinkingEntries,
1446
+ replyTo: payload.clientMessageId,
1447
+ storeHistory: latestThinkingEntries.length > 0,
1448
+ });
1449
+ }
1219
1450
  for (const message of normalizeBridgeMessages(bridgeResponse)) {
1220
1451
  this.options.onLog?.(`[provider] bridge_message_out session=${sessionId} textChars=${message.text.length} attachments=${message.attachments?.length ?? 0}`);
1221
1452
  for (const attachment of message.attachments ?? []) {
@@ -1229,6 +1460,16 @@ export class PrivateClawProvider {
1229
1460
  }
1230
1461
  }
1231
1462
  catch (error) {
1463
+ if (supportsThinkingTrace) {
1464
+ await this.sendThinkingMessage(sessionId, {
1465
+ messageId: thinkingMessageId,
1466
+ status: "failed",
1467
+ summary: latestThinkingSummary,
1468
+ entries: latestThinkingEntries,
1469
+ replyTo: payload.clientMessageId,
1470
+ storeHistory: latestThinkingEntries.length > 0,
1471
+ });
1472
+ }
1232
1473
  await this.sendSystemMessage(sessionId, buildBridgeErrorMessage(error instanceof Error ? error.message : String(error)), "error", payload.clientMessageId, voiceFeedbackParams);
1233
1474
  }
1234
1475
  return;
@@ -1293,6 +1534,7 @@ export class PrivateClawProvider {
1293
1534
  state: "awaiting_hello",
1294
1535
  });
1295
1536
  this.scheduleRenewalReminder(sessionId);
1537
+ this.verboseLog(`session_created session=${sessionId} groupMode=${groupMode} label=${JSON.stringify(params?.label ?? "")} expiresAt=${JSON.stringify(expiresAt)} relayLabel=${JSON.stringify(relayLabel ?? "")} ttlMs=${params?.ttlMs ?? this.options.defaultTtlMs ?? DEFAULT_SESSION_TTL_MS}`);
1296
1538
  return this.buildInviteBundleForInvite(invite);
1297
1539
  }
1298
1540
  decodeInvite(uri) {