@diegoaltoworks/chatter 0.60.0 → 0.62.0

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 (125) hide show
  1. package/README.md +56 -17
  2. package/dist/auth/secretStrength.d.ts +1 -1
  3. package/dist/auth/secretStrength.d.ts.map +1 -1
  4. package/dist/bin/create-apikey.js +45 -28
  5. package/dist/bin/wa-pair.js +113 -46
  6. package/dist/channels/backoff.d.ts +10 -0
  7. package/dist/channels/backoff.d.ts.map +1 -0
  8. package/dist/channels/gates.d.ts +15 -8
  9. package/dist/channels/gates.d.ts.map +1 -1
  10. package/dist/channels/index.d.ts +1 -1
  11. package/dist/channels/index.d.ts.map +1 -1
  12. package/dist/channels/index.js +38 -5
  13. package/dist/channels/index.mjs +37 -5
  14. package/dist/channels/matrix/api.d.ts +152 -0
  15. package/dist/channels/matrix/api.d.ts.map +1 -0
  16. package/dist/channels/matrix/channel.d.ts +46 -0
  17. package/dist/channels/matrix/channel.d.ts.map +1 -0
  18. package/dist/channels/matrix/handler.d.ts +58 -0
  19. package/dist/channels/matrix/handler.d.ts.map +1 -0
  20. package/dist/channels/matrix/index.d.ts +37 -0
  21. package/dist/channels/matrix/index.d.ts.map +1 -0
  22. package/dist/channels/matrix/index.js +1128 -0
  23. package/dist/channels/matrix/index.mjs +1079 -0
  24. package/dist/channels/matrix/sync.d.ts +53 -0
  25. package/dist/channels/matrix/sync.d.ts.map +1 -0
  26. package/dist/channels/matrix/updates.d.ts +104 -0
  27. package/dist/channels/matrix/updates.d.ts.map +1 -0
  28. package/dist/channels/pipeline.d.ts +14 -14
  29. package/dist/channels/pipeline.d.ts.map +1 -1
  30. package/dist/channels/polling.d.ts +67 -0
  31. package/dist/channels/polling.d.ts.map +1 -0
  32. package/dist/channels/telegram/channel.d.ts +2 -56
  33. package/dist/channels/telegram/channel.d.ts.map +1 -1
  34. package/dist/channels/telegram/index.js +53 -23
  35. package/dist/channels/telegram/index.mjs +53 -23
  36. package/dist/channels/telegram/poll.d.ts +5 -1
  37. package/dist/channels/telegram/poll.d.ts.map +1 -1
  38. package/dist/channels/telegram/webhook.d.ts +2 -10
  39. package/dist/channels/telegram/webhook.d.ts.map +1 -1
  40. package/dist/channels/whatsapp/authState.d.ts +40 -9
  41. package/dist/channels/whatsapp/authState.d.ts.map +1 -1
  42. package/dist/channels/whatsapp/channel.d.ts +25 -4
  43. package/dist/channels/whatsapp/channel.d.ts.map +1 -1
  44. package/dist/channels/whatsapp/inbound.d.ts +23 -25
  45. package/dist/channels/whatsapp/inbound.d.ts.map +1 -1
  46. package/dist/channels/whatsapp/index.d.ts +3 -3
  47. package/dist/channels/whatsapp/index.d.ts.map +1 -1
  48. package/dist/channels/whatsapp/index.js +123 -41
  49. package/dist/channels/whatsapp/index.mjs +120 -41
  50. package/dist/channels/whatsapp/pairing.d.ts.map +1 -1
  51. package/dist/client/src/Chat.d.ts.map +1 -1
  52. package/dist/client/src/ChatButton.d.ts.map +1 -1
  53. package/dist/client/src/browser.d.ts.map +1 -1
  54. package/dist/core/answer.d.ts +8 -0
  55. package/dist/core/answer.d.ts.map +1 -1
  56. package/dist/core/buildLock.d.ts +52 -0
  57. package/dist/core/buildLock.d.ts.map +1 -0
  58. package/dist/core/pipeline.d.ts +42 -5
  59. package/dist/core/pipeline.d.ts.map +1 -1
  60. package/dist/core/prompts.d.ts +2 -0
  61. package/dist/core/prompts.d.ts.map +1 -1
  62. package/dist/core/retrieval.d.ts +100 -25
  63. package/dist/core/retrieval.d.ts.map +1 -1
  64. package/dist/core/session.d.ts +8 -0
  65. package/dist/core/session.d.ts.map +1 -1
  66. package/dist/flows/index.d.ts +1 -1
  67. package/dist/flows/index.d.ts.map +1 -1
  68. package/dist/flows/index.js +8 -6
  69. package/dist/flows/index.mjs +7 -6
  70. package/dist/flows/intent.d.ts +1 -1
  71. package/dist/flows/intent.d.ts.map +1 -1
  72. package/dist/flows/loader.d.ts +1 -2
  73. package/dist/flows/loader.d.ts.map +1 -1
  74. package/dist/flows/params.d.ts +1 -1
  75. package/dist/flows/params.d.ts.map +1 -1
  76. package/dist/flows/session.d.ts +4 -2
  77. package/dist/flows/session.d.ts.map +1 -1
  78. package/dist/flows/types.d.ts +2 -3
  79. package/dist/flows/types.d.ts.map +1 -1
  80. package/dist/history/index.d.ts +1 -1
  81. package/dist/history/index.d.ts.map +1 -1
  82. package/dist/history/index.js +6 -3
  83. package/dist/history/index.mjs +5 -3
  84. package/dist/history/tursoStore.d.ts +6 -4
  85. package/dist/history/tursoStore.d.ts.map +1 -1
  86. package/dist/images/index.js +2 -2
  87. package/dist/images/index.mjs +2 -2
  88. package/dist/index.d.ts +7 -5
  89. package/dist/index.d.ts.map +1 -1
  90. package/dist/index.js +596 -295
  91. package/dist/index.mjs +595 -295
  92. package/dist/mcp-server/index.d.ts +5 -5
  93. package/dist/mcp-server/index.d.ts.map +1 -1
  94. package/dist/mcp-server/logger.d.ts +12 -2
  95. package/dist/mcp-server/logger.d.ts.map +1 -1
  96. package/dist/mcp-server/rate-limiter.d.ts +10 -3
  97. package/dist/mcp-server/rate-limiter.d.ts.map +1 -1
  98. package/dist/mcp-server/types.d.ts +20 -5
  99. package/dist/mcp-server/types.d.ts.map +1 -1
  100. package/dist/mcp-server.js +479 -244
  101. package/dist/mcp-server.mjs +485 -244
  102. package/dist/middleware/apiKey.d.ts +10 -0
  103. package/dist/middleware/apiKey.d.ts.map +1 -0
  104. package/dist/middleware/auth.d.ts.map +1 -1
  105. package/dist/middleware/cors.d.ts.map +1 -1
  106. package/dist/middleware/ratelimit.d.ts.map +1 -1
  107. package/dist/middleware/referrer.d.ts.map +1 -1
  108. package/dist/middleware/session.d.ts +1 -1
  109. package/dist/middleware/session.d.ts.map +1 -1
  110. package/dist/routes/demo.d.ts.map +1 -1
  111. package/dist/routes/openai.d.ts.map +1 -1
  112. package/dist/routes/private.d.ts.map +1 -1
  113. package/dist/routes/public.d.ts.map +1 -1
  114. package/dist/scheduler/index.js +1 -1
  115. package/dist/scheduler/index.mjs +1 -1
  116. package/dist/scheduler/scheduler.d.ts +9 -1
  117. package/dist/scheduler/scheduler.d.ts.map +1 -1
  118. package/dist/server.d.ts.map +1 -1
  119. package/dist/server.js +491 -268
  120. package/dist/server.mjs +497 -268
  121. package/dist/shortener.d.ts +5 -4
  122. package/dist/shortener.d.ts.map +1 -1
  123. package/dist/types.d.ts +129 -75
  124. package/dist/types.d.ts.map +1 -1
  125. package/package.json +11 -2
@@ -249,7 +249,8 @@ async function answerOnce({
249
249
  async function applyTransformReply(transformReply, input, logger) {
250
250
  if (!transformReply) return input.text;
251
251
  try {
252
- return await transformReply(input);
252
+ const result = await transformReply(input);
253
+ return typeof result === "string" ? result : null;
253
254
  } catch (error) {
254
255
  logger?.error(
255
256
  `transformReply threw for channel "${input.channel}"; sending the original reply`,
@@ -311,6 +312,7 @@ async function prepareChat({
311
312
  sender,
312
313
  rewriteQuery,
313
314
  rerankContext,
315
+ fallbackFn,
314
316
  logger
315
317
  }) {
316
318
  const lastUserMsg = lastUserMessage(messages);
@@ -327,21 +329,39 @@ async function prepareChat({
327
329
  logger?.error("rewriteQuery threw; falling back to the original query", error);
328
330
  }
329
331
  }
330
- let ctx = await store.query(query, topK, buckets ?? defaultBuckets(mode));
332
+ const resolvedBuckets = buckets ?? defaultBuckets(mode);
333
+ const retrievedChunks = await store.query(query, topK, resolvedBuckets);
334
+ let ctx = retrievedChunks;
331
335
  if (rerankContext) {
332
336
  try {
333
- const reranked = await rerankContext({ query, chunks: ctx });
337
+ const reranked = await rerankContext({ query, chunks: [...ctx] });
334
338
  if (Array.isArray(reranked) && reranked.every((c) => typeof c === "string")) ctx = reranked;
335
339
  } catch (error) {
336
340
  logger?.error("rerankContext threw; falling back to the original chunks", error);
337
341
  }
338
342
  }
343
+ let fallback;
344
+ if (ctx.length === 0 && fallbackFn) {
345
+ try {
346
+ const guidance = await fallbackFn({
347
+ query,
348
+ mode,
349
+ buckets: resolvedBuckets,
350
+ sender,
351
+ retrievedChunks
352
+ });
353
+ if (typeof guidance === "string" && guidance.trim()) fallback = guidance.trim();
354
+ } catch (error) {
355
+ logger?.error("fallbackFn threw; proceeding without fallback guidance", error);
356
+ }
357
+ }
339
358
  const persona = personaLayer?.trim() || (mode === "private" ? prompts.privatePersona : prompts.publicPersona);
340
359
  const hint = channelHint?.trim();
341
360
  const system = [
342
361
  prompts.baseSystemRules,
343
362
  persona,
344
363
  ...hint ? [hint] : [],
364
+ ...fallback ? [fallback] : [],
345
365
  `${label}:
346
366
  ${ctx.join("\n\n")}`
347
367
  ].join("\n\n");
@@ -349,7 +369,7 @@ ${ctx.join("\n\n")}`
349
369
  }
350
370
 
351
371
  // src/history/compaction.ts
352
- var DEFAULT_TIMEOUT_MS = 8e3;
372
+ var COMPACTION_TIMEOUT_MS = 8e3;
353
373
  var LOAD_ALL = Number.MAX_SAFE_INTEGER;
354
374
  var SUMMARY_PREFIX = "Summary of earlier conversation: ";
355
375
  function defaultSummarize(client, model) {
@@ -377,7 +397,7 @@ function createHistoryCompactor(deps, options) {
377
397
  throw new Error(`Invalid history compaction keep: ${keep}`);
378
398
  }
379
399
  const summarize = options.summarize ?? defaultSummarize(deps.client, options.model);
380
- const timeoutMs = options.timeoutMs ?? DEFAULT_TIMEOUT_MS;
400
+ const timeoutMs = options.timeoutMs ?? COMPACTION_TIMEOUT_MS;
381
401
  return {
382
402
  async maybeCompact(store, conversationId) {
383
403
  const turns = await store.load(conversationId, LOAD_ALL);
@@ -468,6 +488,16 @@ function underReplyRateLimit(msg, limiters) {
468
488
  }
469
489
 
470
490
  // src/channels/pipeline.ts
491
+ function resolveBrainHooks(config, fallback) {
492
+ return {
493
+ answerFn: config.answerFn ?? fallback?.answerFn,
494
+ bucketsFor: config.bucketsFor ?? fallback?.bucketsFor,
495
+ rewriteQuery: config.rewriteQuery ?? fallback?.rewriteQuery,
496
+ rerankContext: config.rerankContext ?? fallback?.rerankContext,
497
+ fallbackFn: config.fallbackFn ?? fallback?.fallbackFn,
498
+ transformReply: config.transformReply ?? fallback?.transformReply
499
+ };
500
+ }
471
501
  var DEFAULT_HISTORY_LIMIT = 20;
472
502
  var DEFAULT_GROUP_RATE_LIMIT = { max: 30, windowMs: 60 * 60 * 1e3 };
473
503
  var DEFAULT_DM_RATE_LIMIT = { max: 20, windowMs: 60 * 60 * 1e3 };
@@ -552,6 +582,7 @@ function createInboundPipeline(deps, config) {
552
582
  sender,
553
583
  rewriteQuery: config.rewriteQuery,
554
584
  rerankContext: config.rerankContext,
585
+ fallbackFn: config.fallbackFn,
555
586
  logger: config.logger
556
587
  });
557
588
  const { content: produced } = await answerOnce({
@@ -588,6 +619,14 @@ function createInboundPipeline(deps, config) {
588
619
  };
589
620
  }
590
621
 
622
+ // src/channels/polling.ts
623
+ function defaultSleep(ms) {
624
+ return new Promise((resolve) => {
625
+ const timer = setTimeout(resolve, ms);
626
+ if (typeof timer === "object" && "unref" in timer) timer.unref();
627
+ });
628
+ }
629
+
591
630
  // src/channels/telegram/updates.ts
592
631
  function messageText(message) {
593
632
  return message.text ?? message.caption ?? "";
@@ -666,11 +705,16 @@ function createTelegramSender(api) {
666
705
  };
667
706
  }
668
707
 
708
+ // src/channels/backoff.ts
709
+ function exponentialBackoffMs(baseMs, maxMs, n) {
710
+ return Math.min(baseMs * 2 ** Math.max(0, Math.min(n, 20)), maxMs);
711
+ }
712
+
669
713
  // src/channels/telegram/poll.ts
670
714
  var BASE_DELAY_MS = 1e3;
671
715
  var MAX_DELAY_MS = 6e4;
672
716
  function pollBackoffMs(failures) {
673
- return Math.min(BASE_DELAY_MS * 2 ** Math.min(failures, 20), MAX_DELAY_MS);
717
+ return exponentialBackoffMs(BASE_DELAY_MS, MAX_DELAY_MS, failures);
674
718
  }
675
719
  function retryDelayMs(error, failures) {
676
720
  const retryAfterMs = error instanceof TelegramApiError ? error.retryAfterMs : void 0;
@@ -695,9 +739,9 @@ async function runLongPoll(deps) {
695
739
  }
696
740
  failures = 0;
697
741
  for (const update of updates) {
742
+ if (deps.isStopped()) break;
698
743
  offset = nextOffset(update);
699
744
  deps.onOffset?.(offset);
700
- if (deps.isStopped()) break;
701
745
  try {
702
746
  await deps.handleUpdate(update);
703
747
  } catch (error) {
@@ -710,12 +754,6 @@ async function runLongPoll(deps) {
710
754
 
711
755
  // src/channels/telegram/channel.ts
712
756
  var DEFAULT_POLL_TIMEOUT_SECONDS = 30;
713
- function defaultSleep(ms) {
714
- return new Promise((resolve) => {
715
- const timer = setTimeout(resolve, ms);
716
- if (typeof timer === "object" && "unref" in timer) timer.unref();
717
- });
718
- }
719
757
  function createTelegramChannel(config) {
720
758
  const channelName = config.name ?? "telegram";
721
759
  const allowedChats = config.allowedChats ?? [];
@@ -743,11 +781,7 @@ function createTelegramChannel(config) {
743
781
  { client: deps.client, store: deps.store, prompts: deps.prompts },
744
782
  {
745
783
  channel: channelName,
746
- answerFn: config.answerFn ?? deps.config.answerFn,
747
- bucketsFor: config.bucketsFor ?? deps.config.bucketsFor,
748
- rewriteQuery: config.rewriteQuery ?? deps.config.rewriteQuery,
749
- rerankContext: config.rerankContext ?? deps.config.rerankContext,
750
- transformReply: config.transformReply ?? deps.config.transformReply,
784
+ ...resolveBrainHooks(config, deps.config),
751
785
  model: config.model,
752
786
  channelHint: config.channelHint ?? "Channel: Telegram.",
753
787
  personaResolver: config.personaResolver,
@@ -926,11 +960,7 @@ function createTelegramWebhookRoute(config) {
926
960
  { client: deps.client, store: deps.store, prompts: deps.prompts },
927
961
  {
928
962
  channel: channelName,
929
- answerFn: config.answerFn ?? deps.config.answerFn,
930
- bucketsFor: config.bucketsFor ?? deps.config.bucketsFor,
931
- rewriteQuery: config.rewriteQuery ?? deps.config.rewriteQuery,
932
- rerankContext: config.rerankContext ?? deps.config.rerankContext,
933
- transformReply: config.transformReply ?? deps.config.transformReply,
963
+ ...resolveBrainHooks(config, deps.config),
934
964
  model: config.model,
935
965
  channelHint: config.channelHint ?? "Channel: Telegram.",
936
966
  personaResolver: config.personaResolver,
@@ -41,7 +41,11 @@ export interface LongPollDeps {
41
41
  *
42
42
  * The offset advances BEFORE the update is handled: a handler that throws on
43
43
  * one specific update must not make Telegram redeliver it forever, which would
44
- * wedge the loop on a single poison message and starve every later one.
44
+ * wedge the loop on a single poison message and starve every later one. It
45
+ * advances only for an update this loop is actually going to handle, though:
46
+ * a stop that lands mid-batch leaves the offset where it was, so a restart
47
+ * resumes at the unhandled update rather than past it (matching
48
+ * `../matrix/sync.ts`'s `since`-token ordering).
45
49
  */
46
50
  export declare function runLongPoll(deps: LongPollDeps): Promise<number | undefined>;
47
51
  //# sourceMappingURL=poll.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"poll.d.ts","sourceRoot":"","sources":["../../../src/channels/telegram/poll.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAuB,KAAK,MAAM,EAAE,MAAM,mBAAmB,CAAC;AACrE,OAAO,EAAoB,KAAK,cAAc,EAAE,MAAM,OAAO,CAAC;AAM9D,mHAAmH;AACnH,wBAAgB,aAAa,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAEtD;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAGrE;AAED,MAAM,WAAW,YAAY;IAC3B,iFAAiF;IACjF,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,CAAC,cAAc,EAAE,CAAC,CAAC;IAClE,4FAA4F;IAC5F,YAAY,CAAC,MAAM,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACpD,+HAA+H;IAC/H,SAAS,IAAI,OAAO,CAAC;IACrB,+EAA+E;IAC/E,KAAK,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACjC,qFAAqF;IACrF,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,+EAA+E;IAC/E,QAAQ,CAAC,CAAC,MA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H,wBAAsB,WAAW,CAAC,IAAI,EAAE,YAAY,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAuCjF"}
@@ -19,15 +19,12 @@
19
19
  * });
20
20
  * ```
21
21
  */
22
- import type { AnswerFn, TransformReply } from "../../core/answer";
23
- import type { BucketsFor } from "../../core/buckets";
24
22
  import { type Logger } from "../../core/logger";
25
- import type { RerankContext, RewriteQuery } from "../../core/pipeline";
26
23
  import type { HistoryCompactionOptions } from "../../history/compaction";
27
24
  import type { HistoryStore } from "../../history/types";
28
- import type { CustomRoutes } from "../../types";
25
+ import type { BrainHooks, CustomRoutes } from "../../types";
29
26
  import { type TelegramApi } from "./api";
30
- export interface TelegramWebhookConfig {
27
+ export interface TelegramWebhookConfig extends BrainHooks {
31
28
  /** From @BotFather. A credential — pass it from the environment, never commit it. */
32
29
  botToken: string;
33
30
  /**
@@ -44,11 +41,6 @@ export interface TelegramWebhookConfig {
44
41
  name?: string;
45
42
  /** Group chats eligible for a reply. Empty (default) = every group. Has no effect on DMs, which always reply. */
46
43
  allowedChats?: string[];
47
- answerFn?: AnswerFn;
48
- bucketsFor?: BucketsFor;
49
- rewriteQuery?: RewriteQuery;
50
- rerankContext?: RerankContext;
51
- transformReply?: TransformReply;
52
44
  model?: string;
53
45
  /** Extra system-prompt section describing the delivery channel; passed through to `prepareChat`. @default "Channel: Telegram." */
54
46
  channelHint?: string;
@@ -1 +1 @@
1
- {"version":3,"file":"webhook.d.ts","sourceRoot":"","sources":["../../../src/channels/telegram/webhook.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAGH,OAAO,KAAK,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAClE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAuB,KAAK,MAAM,EAAE,MAAM,mBAAmB,CAAC;AACrE,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,M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qJAAqJ;IACrJ,GAAG,CAAC,EAAE,WAAW,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAeD;;;;;;GAMG;AACH,wBAAgB,0BAA0B,CAAC,MAAM,EAAE,qBAAqB,GAAG,YAAY,CA8GtF"}
@@ -1,16 +1,18 @@
1
1
  /**
2
- * Turso/libsql-backed Baileys auth state, encrypted at rest.
2
+ * Baileys auth state, encrypted at rest, over an injectable {@link WaAuthKV}.
3
3
  *
4
4
  * Same contract as Baileys' own `useMultiFileAuthState`, but rows in a
5
- * `wa_auth` table instead of files, AES-GCM encrypted (see `crypto.ts`) so
6
- * session material — which grants full account access — is never stored
7
- * readable.
5
+ * key-value store instead of files, AES-GCM encrypted (see `crypto.ts`) so
6
+ * session material - which grants full account access - is never stored
7
+ * readable. The store itself only ever sees ciphertext: encryption lives in
8
+ * this module, above the store, so a custom `WaAuthKV` cannot accidentally
9
+ * persist plaintext session material.
8
10
  *
9
11
  * Only Baileys *types* are imported here (erased at compile time, so they add
10
12
  * no runtime dependency); the few Baileys runtime values this module needs
11
13
  * (`BufferJSON`, `initAuthCreds`, the app-state-sync-key constructor) are
12
14
  * passed in by the caller, which already holds them from the dynamic import
13
- * in `baileys.ts` — see that module for why the import is dynamic.
15
+ * in `baileys.ts` - see that module for why the import is dynamic.
14
16
  */
15
17
  import type { Client } from "@libsql/client";
16
18
  import type { AuthenticationCreds, AuthenticationState, SignalDataTypeMap } from "@whiskeysockets/baileys";
@@ -30,10 +32,39 @@ export interface AuthStateRuntime {
30
32
  appStateSyncKeyFromObject: (value: Record<string, unknown>) => SignalDataTypeMap["app-state-sync-key"];
31
33
  }
32
34
  /**
33
- * Sessions share the `wa_auth` table, namespaced by row-id prefix. The
34
- * "default" session uses UNPREFIXED ids — exactly a single-session layout —
35
- * so an existing default session needs no migration when multi-session
36
- * support is introduced.
35
+ * Raw storage for Baileys auth rows, keyed by an already session-scoped
36
+ * `id` (see `useAuthState`'s `rowId`). Values are opaque ciphertext strings -
37
+ * this layer has no encryption knowledge, only persistence.
37
38
  */
39
+ export interface WaAuthKV {
40
+ read(id: string): Promise<string | null>;
41
+ write(id: string, value: string): Promise<void>;
42
+ remove(id: string): Promise<void>;
43
+ /**
44
+ * Deletes every row belonging to `sessionId` and no other session's -
45
+ * use {@link isAuthRowForSession} to decide which stored ids qualify
46
+ * rather than re-deriving the "default" session's unprefixed special case
47
+ * by hand; getting this wrong logs out a sibling number.
48
+ */
49
+ clear(sessionId: string): Promise<void>;
50
+ }
51
+ /**
52
+ * Pure: does row id `id` (as stored - already passed through `rowId`) belong
53
+ * to `sessionId`? Mirrors `useAuthState`'s `rowId` and the SQL in
54
+ * `createTursoWaAuthKV`'s `clear` - keep the three in sync. The "default"
55
+ * session's rows are UNPREFIXED (see `useAuthState`), so its scope is
56
+ * everything *not* claimed by a named session's `s:<sessionId>/` prefix.
57
+ */
58
+ export declare function isAuthRowForSession(id: string, sessionId: string): boolean;
59
+ /** The shipped `WaAuthKV`: a `wa_auth` table in the same libsql database the rest of chatter uses. */
60
+ export declare function createTursoWaAuthKV(db: Client): WaAuthKV;
61
+ /**
62
+ * Sessions share one `WaAuthKV`, namespaced by row-id prefix. The "default"
63
+ * session uses UNPREFIXED ids - exactly a single-session layout - so an
64
+ * existing default session needs no migration when multi-session support is
65
+ * introduced.
66
+ */
67
+ export declare function useAuthState(store: WaAuthKV, secret: string, sessionId: string, runtime: AuthStateRuntime): Promise<TursoAuthStateResult>;
68
+ /** Convenience wrapper over `useAuthState` for the shipped Turso-backed `WaAuthKV`. */
38
69
  export declare function useTursoAuthState(db: Client, secret: string, sessionId: string, runtime: AuthStateRuntime): Promise<TursoAuthStateResult>;
39
70
  //# sourceMappingURL=authState.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"authState.d.ts","sourceRoot":"","sources":["../../../src/channels/whatsapp/authState.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAA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CA2D/B;AAED,uFAAuF;AACvF,wBAAsB,iBAAiB,CACrC,EAAE,EAAE,MAAM,EACV,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,gBAAgB,GACxB,OAAO,CAAC,oBAAoB,CAAC,CAE/B"}
@@ -1,10 +1,11 @@
1
1
  /**
2
2
  * WhatsApp web-client transport: a {@link Channel} that runs one Baileys
3
3
  * socket per configured session id (one WhatsApp number each), auth state
4
- * encrypted in the host's own database (`deps.db` — no second connection
5
- * opened), and a deploy lease so two overlapping instances can never hold the
6
- * same session's socket at once (WhatsApp treats a second connection as a
7
- * takeover and logs the first one out).
4
+ * encrypted above an injectable {@link WaAuthKV} (defaults to a table in the
5
+ * host's own database, `deps.db` - no second connection opened), and a
6
+ * deploy lease behind an injectable `WaLeaseStore` so two overlapping
7
+ * instances can never hold the same session's socket at once (WhatsApp
8
+ * treats a second connection as a takeover and logs the first one out).
8
9
  *
9
10
  * Message INTERPRETATION — mention/reply detection, allowlists, loop guards —
10
11
  * is deliberately not this module's job; it hands every raw inbound message
@@ -18,6 +19,7 @@
18
19
  import type { WAMessage, WASocket } from "@whiskeysockets/baileys";
19
20
  import { type Logger } from "../../core/logger";
20
21
  import type { Channel } from "../index";
22
+ import type { WaAuthKV } from "./authState";
21
23
  import { type Baileys } from "./baileys";
22
24
  import { type WaLeaseStore } from "./lease";
23
25
  /** Exponential backoff: 5s, 10s, 20s ... capped at 10 minutes. Hammering
@@ -31,6 +33,8 @@ export interface WhatsAppMessageEvent {
31
33
  export interface WhatsAppChannelConfig {
32
34
  /** Passphrase that encrypts auth state at rest (AES-256-GCM key material). Keep it stable across restarts and deploys — losing it means re-pairing. */
33
35
  sessionSecret: string;
36
+ /** Channel and sender-registry name prefix (see {@link senderNameFor}). Override to run more than one WhatsApp channel in one process. @default "whatsapp" */
37
+ name?: string;
34
38
  /** One Baileys connection per id, each a separate WhatsApp number. Defaults to `["default"]`, whose auth rows are unprefixed (a pre-multi-session deployment needs no migration). */
35
39
  sessionIds?: string[];
36
40
  /**
@@ -52,6 +56,10 @@ export interface WhatsAppChannelConfig {
52
56
  waitMs?: number;
53
57
  /** Logger for connection/lease lifecycle events. Default: a console logger writing to stderr. */
54
58
  logger?: Logger;
59
+ /** Deploy-overlap lease. Defaults to a `wa_lease` table in `deps.db`; inject your own to run this channel without a libsql database (see docs/patterns/adding-a-store.md). */
60
+ leaseStore?: WaLeaseStore;
61
+ /** Baileys auth-state persistence, encrypted above this seam. Defaults to a `wa_auth` table in `deps.db`; inject your own to run this channel without a libsql database. */
62
+ authStore?: WaAuthKV;
55
63
  }
56
64
  /** A live, leased session: what `stop()` (or losing the lease) must tear down. */
57
65
  export interface WaSessionHandle {
@@ -95,5 +103,18 @@ export interface LeaseGatedConnectDeps {
95
103
  export declare function acquireSessionLease(sessionId: string, deps: LeaseGatedConnectDeps): Promise<void>;
96
104
  /** Sender-registry name for a session — the default session stays unprefixed so single-number deployments see a plain `"whatsapp"` name. */
97
105
  export declare function senderNameFor(channelName: string, sessionId: string): string;
106
+ /** `ChannelSender.sendMedia`'s payload shape for this channel: a URL Baileys fetches itself, matching `./images`' own `{ image: { url } }` usage. A bare string is shorthand for the URL, the same convention `./telegram` and `./matrix` use. */
107
+ export interface WhatsAppMediaPayload {
108
+ url: string;
109
+ caption?: string;
110
+ }
111
+ /**
112
+ * Turns the registry's opaque `sendMedia` payload into what `sock.sendMessage`
113
+ * needs. `ChannelSender.sendMedia` types its payload as `unknown` (payload
114
+ * shapes are transport-defined), so this is where that unknown is checked:
115
+ * a malformed payload throws here, which the sender registry reports as
116
+ * `false` rather than sending Baileys a `{ image: { url: undefined } }`.
117
+ */
118
+ export declare function normalizeWaMediaPayload(payload: unknown): WhatsAppMediaPayload;
98
119
  export declare function createWhatsAppChannel(config: WhatsAppChannelConfig): Channel;
99
120
  //# sourceMappingURL=channel.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"channel.d.ts","sourceRoot":"","sources":["../../../src/channels/wh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C1B,OAAO,CAAC,IAAI,CAAC,CA4Df;AAED,4IAA4I;AAC5I,wBAAgB,aAAa,CAAC,WAAW,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,CAE5E;AAED,kPAAkP;AAClP,MAAM,WAAW,oBAAoB;IACnC,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;;;;;GAMG;AACH,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,OAAO,GAAG,oBAAoB,CAS9E;AAED,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,qBAAqB,GAAG,OAAO,CAiO5E"}
@@ -6,12 +6,12 @@
6
6
  * interpretation.
7
7
  *
8
8
  * Message-shape parsing (text/caption extraction, contextInfo mentions and
9
- * quoted-reply resolution) is genericized from the reference implementation:
10
- * text AND contextInfo live in a DIFFERENT place per message shape — plain
11
- * text carries both on `extendedTextMessage`, but a photo/video/document
12
- * carries its caption on its own message type and its contextInfo there too.
13
- * Missing that meant mentions in photo captions were invisible and group
14
- * photo requests were silently ignored.
9
+ * quoted-reply resolution) accounts for a Baileys quirk: text AND contextInfo
10
+ * live in a DIFFERENT place per message shape - plain text carries both on
11
+ * `extendedTextMessage`, but a photo/video/document carries its caption on
12
+ * its own message type and its contextInfo there too. Missing that meant
13
+ * mentions in photo captions were invisible and group photo requests were
14
+ * silently ignored.
15
15
  *
16
16
  * `createWhatsAppInboundHandler` needs `ServerDependencies`
17
17
  * (`client`/`store`/`prompts`), which only exists once `createServer` builds
@@ -34,11 +34,10 @@
34
34
  * client: deps.client,
35
35
  * store: deps.store,
36
36
  * prompts: deps.prompts,
37
- * answerFn: deps.config.answerFn,
38
- * bucketsFor: deps.config.bucketsFor,
39
- * rewriteQuery: deps.config.rewriteQuery,
40
- * rerankContext: deps.config.rerankContext,
41
- * transformReply: deps.config.transformReply,
37
+ * // Falls back to deps.config.{answerFn,bucketsFor,rewriteQuery,
38
+ * // rerankContext,fallbackFn,transformReply} for whichever of those
39
+ * // this config doesn't set itself.
40
+ * serverConfig: deps.config,
42
41
  * registry: new Map(),
43
42
  * logger: deps.logger,
44
43
  * });
@@ -48,14 +47,12 @@
48
47
  */
49
48
  import type { WAMessage, WASocket } from "@whiskeysockets/baileys";
50
49
  import type OpenAI from "openai";
51
- import type { AnswerFn, TransformReply } from "../../core/answer";
52
- import type { BucketsFor } from "../../core/buckets";
53
50
  import { type Logger } from "../../core/logger";
54
- import type { RerankContext, RewriteQuery } from "../../core/pipeline";
55
51
  import type { PromptLoader } from "../../core/prompts";
56
- import type { VectorStore } from "../../core/retrieval";
52
+ import type { Retriever } from "../../core/retrieval";
57
53
  import type { HistoryCompactionOptions } from "../../history/compaction";
58
54
  import type { HistoryStore } from "../../history/types";
55
+ import type { BrainHooks } from "../../types";
59
56
  import { type ChannelMessage, type SessionIdentityRegistry } from "../gates";
60
57
  import type { WhatsAppMessageEvent } from "./channel";
61
58
  import type { WhatsAppImageHandler } from "./images";
@@ -127,18 +124,19 @@ export interface ResolvedWaMessage {
127
124
  * multiplies this work.
128
125
  */
129
126
  export declare function resolveWaMessage(event: WhatsAppMessageEvent, registry: SessionIdentityRegistry): ResolvedWaMessage;
130
- export interface WhatsAppInboundConfig {
127
+ export interface WhatsAppInboundConfig extends BrainHooks {
131
128
  client: OpenAI;
132
- store: VectorStore;
129
+ store: Retriever;
133
130
  prompts: PromptLoader;
134
- answerFn?: AnswerFn;
135
- bucketsFor?: BucketsFor;
136
- /** Rewrites the retrieval query before it reaches the vector store — see `ChatterConfig.rewriteQuery`. */
137
- rewriteQuery?: RewriteQuery;
138
- /** Post-processes retrieved chunks before they're folded into the prompt — see `ChatterConfig.rerankContext`. */
139
- rerankContext?: RerankContext;
140
- /** Modifies or vetoes the produced reply before delivery — see `ChatterConfig.transformReply`. */
141
- transformReply?: TransformReply;
131
+ /**
132
+ * Fallback source for the brain hooks above, each consulted only when this
133
+ * config's own field is unset. Pass `deps.config` from the `customRoutes`
134
+ * callback (see the module docstring) so this handler automatically
135
+ * honours a server-level hook, the same precedence `./telegram` and
136
+ * `./matrix` apply internally via `resolveBrainHooks`. Unset: only this
137
+ * config's own fields count.
138
+ */
139
+ serverConfig?: BrainHooks;
142
140
  model?: string;
143
141
  /**
144
142
  * Own identities per session — share ONE registry across every session
@@ -1 +1 @@
1
- {"version":3,"file":"inbound.d.ts","sourceRoot":"","sources":["../../../src/channels/whatsapp/inbound.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+CG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AACnE,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAC;AACjC,OAAO,KAAK,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAClE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAuB,KAAK,MAAM,EAAE,MAAM,mBAAmB,CAAC;AACrE,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACvE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,0BAA0B,CAAC;AACzE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EACL,KAAK,cAAc,EAGnB,KAAK,uBAAuB,EAC7B,MAAM,UAAU,CAAC;AAElB,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAC;AACtD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAIrD,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAE/C;AAOD,kGAAkG;AAClG,wBAAgB,SA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,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE,CAAC;IAChD,cAAc,CAAC,EAAE;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE,CAAC;IACnD,oGAAoG;IACpG,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;;;;OAKG;IACH,eAAe,CAAC,EAAE,CAAC,GAAG,EAAE;QACtB,WAAW,EAAE,MAAM,CAAC;QACpB,IAAI,EAAE,MAAM,CAAC;KACd,KAAK,MAAM,GAAG,SAAS,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAAC;IACvD;;;;;;OAMG;IACH,MAAM,CAAC,EAAE,oBAAoB,CAAC;IAC9B;;;;;OAKG;IACH,OAAO,CAAC,EAAE;QACR,KAAK,EAAE,YAAY,CAAC;QACpB,uDAAuD;QACvD,KAAK,CAAC,EAAE,MAAM,CAAC;QACf;;;;WAIG;QACH,iBAAiB,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;QACnE;;;;WAIG;QACH,UAAU,CAAC,EAAE,wBAAwB,CAAC;KACvC,CAAC;IACF,GAAG,CAAC,EAAE,MAAM,MAAM,CAAC;IACnB,yFAAyF;IACzF,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,uTAAuT;AACvT,wBAAgB,4BAA4B,CAC1C,MAAM,EAAE,qBAAqB,GAC5B,CAAC,KAAK,EAAE,oBAAoB,KAAK,OAAO,CAAC,IAAI,CAAC,CA+FhD"}
@@ -23,11 +23,11 @@
23
23
  *
24
24
  * @packageDocumentation
25
25
  */
26
- export type { AuthStateRuntime, TursoAuthStateResult } from "./authState";
27
- export { useTursoAuthState } from "./authState";
26
+ export type { AuthStateRuntime, TursoAuthStateResult, WaAuthKV } from "./authState";
27
+ export { createTursoWaAuthKV, useAuthState, useTursoAuthState } from "./authState";
28
28
  export type { Baileys } from "./baileys";
29
29
  export { loadBaileys } from "./baileys";
30
- export { acquireSessionLease, createWhatsAppChannel, type LeaseGatedConnectDeps, reconnectDelayMs, senderNameFor, shutdownWaSessions, type WaSessionHandle, type WhatsAppChannelConfig, type WhatsAppMessageEvent, } from "./channel";
30
+ export { acquireSessionLease, createWhatsAppChannel, type LeaseGatedConnectDeps, normalizeWaMediaPayload, reconnectDelayMs, senderNameFor, shutdownWaSessions, type WaSessionHandle, type WhatsAppChannelConfig, type WhatsAppMediaPayload, type WhatsAppMessageEvent, } from "./channel";
31
31
  export { decrypt, encrypt } from "./crypto";
32
32
  export { createWhatsAppImageHandler, type DrawRequestDetectorConfig, drawSubject, isDrawRequest, type WhatsAppImageHandler, type WhatsAppImageHandlerDeps, type WhatsAppImageRequestContext, type WhatsAppImageStrings, } from "./images";
33
33
  export { createWhatsAppInboundHandler, extractText, isGroupJid, jidsMatch, jidToPhoneNumber, messageContext, type ResolvedWaMessage, resolveWaMessage, senderPhoneFor, stripOwnMentions, type WaMessageContext, type WhatsAppInboundConfig, } from "./inbound";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/channels/whatsapp/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,YAAY,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAC1E,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChD,YAAY,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AACxC,OAAO,EACL,mBAAmB,EACnB,qBAAqB,EACrB,KAAK,qBAAqB,EAC1B,gBAAgB,EAChB,aAAa,EACb,kBAAkB,EAClB,KAAK,eAAe,EACpB,KAAK,qBAAqB,EAC1B,KAAK,oBAAoB,GAC1B,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAC5C,OAAO,EACL,0BAA0B,EAC1B,KAAK,yBAAyB,EAC9B,WAAW,EACX,aAAa,EACb,KAAK,oBAAoB,EACzB,KAAK,wBAAwB,EAC7B,KAAK,2BAA2B,EAChC,KAAK,oBAAoB,GAC1B,MAAM,UAAU,CAAC;AAClB,OAAO,EACL,4BAA4B,EAC5B,WAAW,EACX,UAAU,EACV,SAAS,EACT,gBAAgB,EAChB,cAAc,EACd,KAAK,iBAAiB,EACtB,gBAAgB,EAChB,cAAc,EACd,gBAAgB,EAChB,KAAK,gBAAgB,EACrB,KAAK,qBAAqB,GAC3B,MAAM,WAAW,CAAC;AACnB,OAAO,EACL,eAAe,EACf,uBAAuB,EACvB,kBAAkB,EAClB,cAAc,EACd,aAAa,EACb,KAAK,UAAU,EACf,KAAK,YAAY,GAClB,MAAM,SAAS,CAAC;AACjB,OAAO,EACL,2BAA2B,EAC3B,KAAK,eAAe,EACpB,KAAK,gBAAgB,EACrB,KAAK,eAAe,EACpB,KAAK,iBAAiB,EACtB,KAAK,2BAA2B,GACjC,MAAM,UAAU,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/channels/whatsapp/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,YAAY,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACpF,OAAO,EAAE,mBAAmB,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AACnF,YAAY,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AACxC,OAAO,EACL,mBAAmB,EACnB,qBAAqB,EACrB,KAAK,qBAAqB,EAC1B,uBAAuB,EACvB,gBAAgB,EAChB,aAAa,EACb,kBAAkB,EAClB,KA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