cclawd 1.0.2 → 1.0.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.
Files changed (68) hide show
  1. package/dist/build-info.json +3 -3
  2. package/dist/plugin-sdk/active-listener-CN-tMEvN.js +35 -0
  3. package/dist/plugin-sdk/api-key-rotation-CimGYMBc.js +176 -0
  4. package/dist/plugin-sdk/audio-preflight-C-xXBoE2.js +51 -0
  5. package/dist/plugin-sdk/audio-transcription-runner-CTIHpebA.js +2173 -0
  6. package/dist/plugin-sdk/audit-membership-runtime-BFatB2LJ.js +58 -0
  7. package/dist/plugin-sdk/channel-activity-DO0FEzyj.js +95 -0
  8. package/dist/plugin-sdk/channel-web-Da-__nUF.js +2238 -0
  9. package/dist/plugin-sdk/commands-registry-6no2NNrY.js +1118 -0
  10. package/dist/plugin-sdk/compact.runtime-CCoclu5e.js +35 -0
  11. package/dist/plugin-sdk/config-B9ODwgpz.js +37426 -0
  12. package/dist/plugin-sdk/deliver-B1fFpKjV.js +1757 -0
  13. package/dist/plugin-sdk/deliver-runtime-DB-VRMe1.js +15 -0
  14. package/dist/plugin-sdk/deps-send-discord.runtime-DklqycYG.js +15 -0
  15. package/dist/plugin-sdk/deps-send-imessage.runtime-Chs8zeon.js +14 -0
  16. package/dist/plugin-sdk/deps-send-signal.runtime-clW9aSJP.js +13 -0
  17. package/dist/plugin-sdk/deps-send-slack.runtime-BUx0LYY1.js +13 -0
  18. package/dist/plugin-sdk/deps-send-telegram.runtime-LECSHgMG.js +16 -0
  19. package/dist/plugin-sdk/deps-send-whatsapp.runtime-D2d65fw0.js +40 -0
  20. package/dist/plugin-sdk/diagnostic-CxIvS-C2.js +315 -0
  21. package/dist/plugin-sdk/dispatch-BqlR4dPx.js +105863 -0
  22. package/dist/plugin-sdk/env-b9k1PHMI.js +34 -0
  23. package/dist/plugin-sdk/fetch-PoxzAANT.js +326 -0
  24. package/dist/plugin-sdk/fetch-guard-4UVSZ0uS.js +164 -0
  25. package/dist/plugin-sdk/image-Ch6M4tnJ.js +2420 -0
  26. package/dist/plugin-sdk/image-runtime-CSh2o5wY.js +8 -0
  27. package/dist/plugin-sdk/index.js +35 -35
  28. package/dist/plugin-sdk/ir-CugsqGH8.js +1312 -0
  29. package/dist/plugin-sdk/local-roots-adnEg9zb.js +217 -0
  30. package/dist/plugin-sdk/logger-D6zRubj0.js +1164 -0
  31. package/dist/plugin-sdk/login-CYvkQ0At.js +54 -0
  32. package/dist/plugin-sdk/login-qr-ll4NtaT5.js +316 -0
  33. package/dist/plugin-sdk/manager-CHy8IclH.js +3959 -0
  34. package/dist/plugin-sdk/manager-runtime-C70EkEr7.js +11 -0
  35. package/dist/plugin-sdk/outbound-Wzs2iN7X.js +216 -0
  36. package/dist/plugin-sdk/outbound-attachment-khXJwucX.js +17 -0
  37. package/dist/plugin-sdk/paths-BtVqCdw4.js +3063 -0
  38. package/dist/plugin-sdk/pi-model-discovery-Dh4ziodY.js +131 -0
  39. package/dist/plugin-sdk/pi-model-discovery-runtime-b83Xe-HT.js +8 -0
  40. package/dist/plugin-sdk/pi-tools.before-tool-call.runtime-C1z5CDBF.js +349 -0
  41. package/dist/plugin-sdk/proxy-fetch-CJEmoBxi.js +54 -0
  42. package/dist/plugin-sdk/pw-ai-Dj3Cvlzl.js +1990 -0
  43. package/dist/plugin-sdk/qmd-manager-egHUAseQ.js +1581 -0
  44. package/dist/plugin-sdk/resolve-outbound-target-BiICvIKs.js +38 -0
  45. package/dist/plugin-sdk/runtime-whatsapp-login.runtime-DNApufzW.js +9 -0
  46. package/dist/plugin-sdk/runtime-whatsapp-outbound.runtime-CBmtfIQ8.js +13 -0
  47. package/dist/plugin-sdk/send-CScblaI4.js +532 -0
  48. package/dist/plugin-sdk/send-CeHhnld6.js +407 -0
  49. package/dist/plugin-sdk/send-DP_c8JfR.js +3277 -0
  50. package/dist/plugin-sdk/send-Dc5fI6e8.js +495 -0
  51. package/dist/plugin-sdk/send-l-77_s1_.js +2507 -0
  52. package/dist/plugin-sdk/session-CkOKZaqa.js +166 -0
  53. package/dist/plugin-sdk/signal.js +2 -2
  54. package/dist/plugin-sdk/skill-commands-BohYCgkq.js +336 -0
  55. package/dist/plugin-sdk/slash-commands.runtime-DpLfVTM6.js +8 -0
  56. package/dist/plugin-sdk/slash-dispatch.runtime-CASMHwpm.js +35 -0
  57. package/dist/plugin-sdk/slash-skill-commands.runtime-D7rrJEci.js +9 -0
  58. package/dist/plugin-sdk/sqlite-CJE3X7Mv.js +1005 -0
  59. package/dist/plugin-sdk/subagent-registry-runtime-B1oo5bih.js +35 -0
  60. package/dist/plugin-sdk/tables-D5VgpTmm.js +53 -0
  61. package/dist/plugin-sdk/target-errors-C6zZ_OpA.js +191 -0
  62. package/dist/plugin-sdk/tokens-DUnJnpMS.js +50 -0
  63. package/dist/plugin-sdk/web-TfUM1nSi.js +39 -0
  64. package/dist/plugin-sdk/whatsapp-actions-DuWJ0j1r.js +71 -0
  65. package/extensions/mfa-auth/index.ts +36 -17
  66. package/extensions/mfa-auth/src/auth-manager.ts +4 -0
  67. package/extensions/mfa-auth/src/notification-service.ts +5 -1
  68. package/package.json +1 -1
@@ -0,0 +1,11 @@
1
+ import "./paths-BtVqCdw4.js";
2
+ import "./config-B9ODwgpz.js";
3
+ import "./paths-eFexkPEh.js";
4
+ import "./github-copilot-token-Cxf8QYZb.js";
5
+ import "./logger-D6zRubj0.js";
6
+ import "./env-b9k1PHMI.js";
7
+ import "./fetch-guard-4UVSZ0uS.js";
8
+ import "./api-key-rotation-CimGYMBc.js";
9
+ import "./sqlite-CJE3X7Mv.js";
10
+ import { n as closeAllMemoryIndexManagers, t as MemoryIndexManager } from "./manager-CHy8IclH.js";
11
+ export { MemoryIndexManager, closeAllMemoryIndexManagers };
@@ -0,0 +1,216 @@
1
+ import { Sl as redactIdentifier, Ua as resolveWhatsAppMediaMaxBytes, Va as resolveWhatsAppAccount, r as loadConfig, ts as generateSecureUuid } from "./config-B9ODwgpz.js";
2
+ import { K as getChildLogger, N as toWhatsappJid, a as createSubsystemLogger, v as escapeRegExp } from "./logger-D6zRubj0.js";
3
+ import { n as normalizePollInput } from "./polls-CL1LDouN.js";
4
+ import { i as resolveMarkdownTableMode, v as loadWebMedia } from "./ir-CugsqGH8.js";
5
+ import { t as convertMarkdownTables } from "./tables-D5VgpTmm.js";
6
+ import { n as requireActiveWebListener } from "./active-listener-CN-tMEvN.js";
7
+ //#region src/markdown/whatsapp.ts
8
+ /**
9
+ * Convert standard Markdown formatting to WhatsApp-compatible markup.
10
+ *
11
+ * WhatsApp uses its own formatting syntax:
12
+ * bold: *text*
13
+ * italic: _text_
14
+ * strikethrough: ~text~
15
+ * monospace: ```text```
16
+ *
17
+ * Standard Markdown uses:
18
+ * bold: **text** or __text__
19
+ * italic: *text* or _text_
20
+ * strikethrough: ~~text~~
21
+ * code: `text` (inline) or ```text``` (block)
22
+ *
23
+ * The conversion preserves fenced code blocks and inline code,
24
+ * then converts bold and strikethrough markers.
25
+ */
26
+ /** Placeholder tokens used during conversion to protect code spans. */
27
+ const FENCE_PLACEHOLDER = "\0FENCE";
28
+ const INLINE_CODE_PLACEHOLDER = "\0CODE";
29
+ /**
30
+ * Convert standard Markdown bold/italic/strikethrough to WhatsApp formatting.
31
+ *
32
+ * Order of operations matters:
33
+ * 1. Protect fenced code blocks (```...```) — already WhatsApp-compatible
34
+ * 2. Protect inline code (`...`) — leave as-is
35
+ * 3. Convert **bold** → *bold* and __bold__ → *bold*
36
+ * 4. Convert ~~strike~~ → ~strike~
37
+ * 5. Restore protected spans
38
+ *
39
+ * Italic *text* and _text_ are left alone since WhatsApp uses _text_ for italic
40
+ * and single * is already WhatsApp bold — no conversion needed for single markers.
41
+ */
42
+ function markdownToWhatsApp(text) {
43
+ if (!text) return text;
44
+ const fences = [];
45
+ let result = text.replace(/```[\s\S]*?```/g, (match) => {
46
+ fences.push(match);
47
+ return `${FENCE_PLACEHOLDER}${fences.length - 1}`;
48
+ });
49
+ const inlineCodes = [];
50
+ result = result.replace(/`[^`\n]+`/g, (match) => {
51
+ inlineCodes.push(match);
52
+ return `${INLINE_CODE_PLACEHOLDER}${inlineCodes.length - 1}`;
53
+ });
54
+ result = result.replace(/\*\*(.+?)\*\*/g, "*$1*");
55
+ result = result.replace(/__(.+?)__/g, "*$1*");
56
+ result = result.replace(/~~(.+?)~~/g, "~$1~");
57
+ result = result.replace(new RegExp(`${escapeRegExp(INLINE_CODE_PLACEHOLDER)}(\\d+)`, "g"), (_, idx) => inlineCodes[Number(idx)] ?? "");
58
+ result = result.replace(new RegExp(`${escapeRegExp(FENCE_PLACEHOLDER)}(\\d+)`, "g"), (_, idx) => fences[Number(idx)] ?? "");
59
+ return result;
60
+ }
61
+ //#endregion
62
+ //#region src/web/outbound.ts
63
+ const outboundLog = createSubsystemLogger("gateway/channels/whatsapp").child("outbound");
64
+ async function sendMessageWhatsApp(to, body, options) {
65
+ let text = body;
66
+ const correlationId = generateSecureUuid();
67
+ const startedAt = Date.now();
68
+ const { listener: active, accountId: resolvedAccountId } = requireActiveWebListener(options.accountId);
69
+ const cfg = options.cfg ?? loadConfig();
70
+ const account = resolveWhatsAppAccount({
71
+ cfg,
72
+ accountId: resolvedAccountId ?? options.accountId
73
+ });
74
+ const tableMode = resolveMarkdownTableMode({
75
+ cfg,
76
+ channel: "whatsapp",
77
+ accountId: resolvedAccountId ?? options.accountId
78
+ });
79
+ text = convertMarkdownTables(text ?? "", tableMode);
80
+ text = markdownToWhatsApp(text);
81
+ const redactedTo = redactIdentifier(to);
82
+ const logger = getChildLogger({
83
+ module: "web-outbound",
84
+ correlationId,
85
+ to: redactedTo
86
+ });
87
+ try {
88
+ const jid = toWhatsappJid(to);
89
+ const redactedJid = redactIdentifier(jid);
90
+ let mediaBuffer;
91
+ let mediaType;
92
+ let documentFileName;
93
+ if (options.mediaUrl) {
94
+ const media = await loadWebMedia(options.mediaUrl, {
95
+ maxBytes: resolveWhatsAppMediaMaxBytes(account),
96
+ localRoots: options.mediaLocalRoots
97
+ });
98
+ const caption = text || void 0;
99
+ mediaBuffer = media.buffer;
100
+ mediaType = media.contentType;
101
+ if (media.kind === "audio") mediaType = media.contentType === "audio/ogg" ? "audio/ogg; codecs=opus" : media.contentType ?? "application/octet-stream";
102
+ else if (media.kind === "video") text = caption ?? "";
103
+ else if (media.kind === "image") text = caption ?? "";
104
+ else {
105
+ text = caption ?? "";
106
+ documentFileName = media.fileName;
107
+ }
108
+ }
109
+ outboundLog.info(`Sending message -> ${redactedJid}${options.mediaUrl ? " (media)" : ""}`);
110
+ logger.info({
111
+ jid: redactedJid,
112
+ hasMedia: Boolean(options.mediaUrl)
113
+ }, "sending message");
114
+ await active.sendComposingTo(to);
115
+ const accountId = Boolean(options.accountId?.trim()) ? resolvedAccountId : void 0;
116
+ const sendOptions = options.gifPlayback || accountId || documentFileName ? {
117
+ ...options.gifPlayback ? { gifPlayback: true } : {},
118
+ ...documentFileName ? { fileName: documentFileName } : {},
119
+ accountId
120
+ } : void 0;
121
+ const messageId = (sendOptions ? await active.sendMessage(to, text, mediaBuffer, mediaType, sendOptions) : await active.sendMessage(to, text, mediaBuffer, mediaType))?.messageId ?? "unknown";
122
+ const durationMs = Date.now() - startedAt;
123
+ outboundLog.info(`Sent message ${messageId} -> ${redactedJid}${options.mediaUrl ? " (media)" : ""} (${durationMs}ms)`);
124
+ logger.info({
125
+ jid: redactedJid,
126
+ messageId
127
+ }, "sent message");
128
+ return {
129
+ messageId,
130
+ toJid: jid
131
+ };
132
+ } catch (err) {
133
+ logger.error({
134
+ err: String(err),
135
+ to: redactedTo,
136
+ hasMedia: Boolean(options.mediaUrl)
137
+ }, "failed to send via web session");
138
+ throw err;
139
+ }
140
+ }
141
+ async function sendReactionWhatsApp(chatJid, messageId, emoji, options) {
142
+ const correlationId = generateSecureUuid();
143
+ const { listener: active } = requireActiveWebListener(options.accountId);
144
+ const redactedChatJid = redactIdentifier(chatJid);
145
+ const logger = getChildLogger({
146
+ module: "web-outbound",
147
+ correlationId,
148
+ chatJid: redactedChatJid,
149
+ messageId
150
+ });
151
+ try {
152
+ const redactedJid = redactIdentifier(toWhatsappJid(chatJid));
153
+ outboundLog.info(`Sending reaction "${emoji}" -> message ${messageId}`);
154
+ logger.info({
155
+ chatJid: redactedJid,
156
+ messageId,
157
+ emoji
158
+ }, "sending reaction");
159
+ await active.sendReaction(chatJid, messageId, emoji, options.fromMe ?? false, options.participant);
160
+ outboundLog.info(`Sent reaction "${emoji}" -> message ${messageId}`);
161
+ logger.info({
162
+ chatJid: redactedJid,
163
+ messageId,
164
+ emoji
165
+ }, "sent reaction");
166
+ } catch (err) {
167
+ logger.error({
168
+ err: String(err),
169
+ chatJid: redactedChatJid,
170
+ messageId,
171
+ emoji
172
+ }, "failed to send reaction via web session");
173
+ throw err;
174
+ }
175
+ }
176
+ async function sendPollWhatsApp(to, poll, options) {
177
+ const correlationId = generateSecureUuid();
178
+ const startedAt = Date.now();
179
+ const { listener: active } = requireActiveWebListener(options.accountId);
180
+ const redactedTo = redactIdentifier(to);
181
+ const logger = getChildLogger({
182
+ module: "web-outbound",
183
+ correlationId,
184
+ to: redactedTo
185
+ });
186
+ try {
187
+ const jid = toWhatsappJid(to);
188
+ const redactedJid = redactIdentifier(jid);
189
+ const normalized = normalizePollInput(poll, { maxOptions: 12 });
190
+ outboundLog.info(`Sending poll -> ${redactedJid}`);
191
+ logger.info({
192
+ jid: redactedJid,
193
+ optionCount: normalized.options.length,
194
+ maxSelections: normalized.maxSelections
195
+ }, "sending poll");
196
+ const messageId = (await active.sendPoll(to, normalized))?.messageId ?? "unknown";
197
+ const durationMs = Date.now() - startedAt;
198
+ outboundLog.info(`Sent poll ${messageId} -> ${redactedJid} (${durationMs}ms)`);
199
+ logger.info({
200
+ jid: redactedJid,
201
+ messageId
202
+ }, "sent poll");
203
+ return {
204
+ messageId,
205
+ toJid: jid
206
+ };
207
+ } catch (err) {
208
+ logger.error({
209
+ err: String(err),
210
+ to: redactedTo
211
+ }, "failed to send poll via web session");
212
+ throw err;
213
+ }
214
+ }
215
+ //#endregion
216
+ export { markdownToWhatsApp as i, sendPollWhatsApp as n, sendReactionWhatsApp as r, sendMessageWhatsApp as t };
@@ -0,0 +1,17 @@
1
+ import { ws as saveMediaBuffer } from "./config-B9ODwgpz.js";
2
+ import { t as buildOutboundMediaLoadOptions } from "./load-options-CE0_U2E0.js";
3
+ import { v as loadWebMedia } from "./ir-CugsqGH8.js";
4
+ //#region src/media/outbound-attachment.ts
5
+ async function resolveOutboundAttachmentFromUrl(mediaUrl, maxBytes, options) {
6
+ const media = await loadWebMedia(mediaUrl, buildOutboundMediaLoadOptions({
7
+ maxBytes,
8
+ mediaLocalRoots: options?.localRoots
9
+ }));
10
+ const saved = await saveMediaBuffer(media.buffer, media.contentType ?? void 0, "outbound", maxBytes);
11
+ return {
12
+ path: saved.path,
13
+ contentType: saved.contentType
14
+ };
15
+ }
16
+ //#endregion
17
+ export { resolveOutboundAttachmentFromUrl as t };