@diegoaltoworks/chatter 0.61.0 → 0.63.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 +55 -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 +25 -6
  15. package/dist/channels/matrix/api.d.ts.map +1 -1
  16. package/dist/channels/matrix/channel.d.ts +4 -56
  17. package/dist/channels/matrix/channel.d.ts.map +1 -1
  18. package/dist/channels/matrix/handler.d.ts +16 -9
  19. package/dist/channels/matrix/handler.d.ts.map +1 -1
  20. package/dist/channels/matrix/index.d.ts +2 -2
  21. package/dist/channels/matrix/index.d.ts.map +1 -1
  22. package/dist/channels/matrix/index.js +196 -40
  23. package/dist/channels/matrix/index.mjs +189 -39
  24. package/dist/channels/matrix/sync.d.ts +4 -1
  25. package/dist/channels/matrix/sync.d.ts.map +1 -1
  26. package/dist/channels/matrix/updates.d.ts +39 -10
  27. package/dist/channels/matrix/updates.d.ts.map +1 -1
  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 +39 -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 +188 -66
  49. package/dist/channels/whatsapp/index.mjs +185 -66
  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 +6 -3
@@ -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,MAAM,gBAAgB,CAAC;AAC7C,OAAO,KAAK,EACV,mBAAmB,EACnB,mBAAmB,EACnB,iBAAiB,EAClB,MAAM,yBAAyB,CAAC;AAGjC,MAAM,WAAW,oBAAoB;IACnC,KAAK,EAAE,mBAAmB,CAAC;IAC3B,SAAS,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAC/B,kDAAkD;IAClD,KAAK,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CAC5B;AAED,qFAAqF;AACrF,MAAM,WAAW,gBAAgB;IAC/B,UAAU,EAAE;QACV,QAAQ,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,KAAK,OAAO,CAAC;QACnD,OAAO,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,KAAK,OAAO,CAAC;KACnD,CAAC;IACF,aAAa,EAAE,MAAM,mBAAmB,CAAC;IACzC,yBAAyB,EAAE,CACzB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAC3B,iBAAiB,CAAC,oBAAoB,CAAC,CAAC;CAC9C;AAiBD;;;;;GAKG;AACH,wBAAsB,iBAAiB,CACrC,EAAE,EAAE,MAAM,EACV,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,gBAAgB,GACxB,OAAO,CAAC,oBAAoB,CAAC,CA6E/B"}
1
+ {"version":3,"file":"authState.d.ts","sourceRoot":"","sources":["../../../src/channels/whatsapp/authState.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,KAAK,EACV,mBAAmB,EACnB,mBAAmB,EACnB,iBAAiB,EAClB,MAAM,yBAAyB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Q,EACf,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,gBAAgB,GACxB,OAAO,CAAC,oBAAoB,CAAC,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 {
@@ -82,6 +90,15 @@ export interface LeaseGatedConnectDeps {
82
90
  waitMs?: number;
83
91
  schedule?: (fn: () => void, ms: number) => void;
84
92
  logger?: Logger;
93
+ /**
94
+ * Recovery for a `connect` that threw, replacing the default (release the
95
+ * session, re-check after `waitMs`). The channel injects one so a thrown
96
+ * connect backs off on the same failure counter a closed connection uses
97
+ * instead of re-attempting at a flat interval. Whatever it does, it must
98
+ * end with another attempt scheduled: a session whose lease is held with
99
+ * no live socket and nothing pending never recovers on its own.
100
+ */
101
+ onConnectFailed?: (sessionId: string, error: unknown) => void;
85
102
  }
86
103
  /**
87
104
  * Acquire `sessionId`'s lease before connecting — two instances must never
@@ -91,9 +108,27 @@ export interface LeaseGatedConnectDeps {
91
108
  * heartbeat ever finds the lease gone (this instance went stale and another
92
109
  * took over), the session is torn down and this re-enters the same
93
110
  * wait-and-retry loop rather than staying connected alongside the new holder.
111
+ *
112
+ * Every failed connect attempt lands back here too, whether it threw on its
113
+ * first try or on a reconnect: this loop is the only way a session recovers,
114
+ * so an attempt that fails without leaving a socket behind (no socket, no
115
+ * future "close" event) must re-enter it rather than stop at a log line.
94
116
  */
95
117
  export declare function acquireSessionLease(sessionId: string, deps: LeaseGatedConnectDeps): Promise<void>;
96
118
  /** Sender-registry name for a session — the default session stays unprefixed so single-number deployments see a plain `"whatsapp"` name. */
97
119
  export declare function senderNameFor(channelName: string, sessionId: string): string;
120
+ /** `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. */
121
+ export interface WhatsAppMediaPayload {
122
+ url: string;
123
+ caption?: string;
124
+ }
125
+ /**
126
+ * Turns the registry's opaque `sendMedia` payload into what `sock.sendMessage`
127
+ * needs. `ChannelSender.sendMedia` types its payload as `unknown` (payload
128
+ * shapes are transport-defined), so this is where that unknown is checked:
129
+ * a malformed payload throws here, which the sender registry reports as
130
+ * `false` rather than sending Baileys a `{ image: { url: undefined } }`.
131
+ */
132
+ export declare function normalizeWaMediaPayload(payload: unknown): WhatsAppMediaPayload;
98
133
  export declare function createWhatsAppChannel(config: WhatsAppChannelConfig): Channel;
99
134
  //# sourceMappingURL=channel.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"channel.d.ts","sourceRoot":"","sources":["../../../src/channels/whatsapp/channel.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAGH,OAAO,KAAK,EAAE,SAAS,EAAgB,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AAEjF,OAAO,EAAuB,KAAK,MAAM,EAAE,MAAM,mBAAmB,CAAC;AACrE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAIxC,OAAO,EAAE,KAAK,OAAO,EAAmD,MAAM,WAAW,CAAC;AAC1F,OAAO,EAKL,KAAK,YAAY,EAClB,MAAM,SAAS,CAAC;AAKjB;gFACgF;AAChF,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAEzD;AAED,MAAM,WAAW,oBA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BAAgB,qBAAqB,CAAC,MAAM,EAAE,qBAAqB,GAAG,OAAO,CAsS5E"}
@@ -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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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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,KAAK,eAAe,EACpB,KAAK,qBAAqB,EAC1B,KAAK,oBAAoB,EACzB,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;AACl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