@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
@@ -3,6 +3,8 @@
3
3
  * Loads prompt templates and interpolates bot configuration
4
4
  */
5
5
  import type { BotIdentity } from "../types";
6
+ /** Default prompts directory when a caller's `config.promptsDir` is unset. */
7
+ export declare const DEFAULT_PROMPTS_DIR = "./config/prompts";
6
8
  /**
7
9
  * Prompt loader class that loads and interpolates prompt templates
8
10
  * with bot identity information
@@ -1 +1 @@
1
- {"version":3,"file":"prompts.d.ts","sourceRoot":"","sources":["../../src/core/prompts.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAE5C;;;GAGG;AACH,qBAAa,YAAY;IAErB,OAAO,CAAC,UAAU;IAClB,OAAO,CAAC,GAAG;IAFb,YACU,UAAU,EAAE,MAAM,EAClB,GAAG,EAAE,WAAW,EACtB;IAEJ;;OAEG;IACH,OAAO,CAAC,IAAI;IAcZ,+BAA+B;IAC/B,IAAI,eAAe,IAAI,MAAM,CAE5B;IAED,4BAA4B;IAC5B,IAAI,aAAa,IAAI,MAAM,CAE1B;IAED,6BAA6B;IAC7B,IAAI,cAAc,IAAI,MAAM,CAE3B;CACF"}
1
+ {"version":3,"file":"prompts.d.ts","sourceRoot":"","sources":["../../src/core/prompts.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAE5C,8EAA8E;AAC9E,eAAO,MAAM,mBAAmB,qBAAqB,CAAC;AAEtD;;;GAGG;AACH,qBAAa,YAAY;IAErB,OAAO,CAAC,UAAU;IAClB,OAAO,CAAC,GAAG;IAFb,YACU,UAAU,EAAE,MAAM,EAClB,GAAG,EAAE,WAAW,EACtB;IAEJ;;OAEG;IACH,OAAO,CAAC,IAAI;IAcZ,+BAA+B;IAC/B,IAAI,eAAe,IAAI,MAAM,CAE5B;IAED,4BAA4B;IAC5B,IAAI,aAAa,IAAI,MAAM,CAE1B;IAED,6BAA6B;IAC7B,IAAI,cAAc,IAAI,MAAM,CAE3B;CACF"}
@@ -1,43 +1,118 @@
1
- import { type Client as LibsqlClient } from "@libsql/client";
1
+ import type { Client as LibsqlClient } from "@libsql/client";
2
2
  import type OpenAI from "openai";
3
+ import { type BuildLock } from "./buildLock";
3
4
  import { type Logger } from "./logger";
5
+ /** Default knowledge directory when a caller's `config.knowledgeDir` is unset. */
6
+ export declare const DEFAULT_KNOWLEDGE_DIR = "./config/knowledge";
4
7
  /**
5
- * How a {@link VectorStore} obtains its database connection: either credentials
6
- * to open its own, or an existing libsql client to reuse.
7
- *
8
- * Reusing a client is preferred when the store lives alongside other consumers
9
- * of the same database (route factories, custom routes) — the process then
10
- * holds one connection instead of one per consumer.
8
+ * The retrieval seam `prepareChat` runs against: given a query, return up to
9
+ * `k` chunks drawn only from `allowedBuckets`. {@link VectorStore} is the
10
+ * shipped implementation (brute-force cosine similarity over embeddings in
11
+ * Turso) - this interface is the scaling path for a host that outgrows it
12
+ * (pgvector, sqlite-vec, Qdrant, a managed vector database) without touching
13
+ * `prepareChat`, `ServerDependencies`, or any chat surface. See
14
+ * [patterns/adding-a-retriever.md](../../docs/patterns/adding-a-retriever.md).
11
15
  */
12
- export type VectorStoreOptions = {
16
+ export interface Retriever {
17
+ /** Retrieve up to `k` chunks across `allowedBuckets` for `query`, most relevant first. */
18
+ query(query: string, k: number, allowedBuckets: string[]): Promise<string[]>;
19
+ /**
20
+ * Optional one-time ingest/warm-up step, run once at server startup before
21
+ * the store answers any query. Omit it for a retriever that is always
22
+ * already up to date (a remote index another process maintains).
23
+ */
24
+ build?(): Promise<void>;
25
+ }
26
+ /**
27
+ * Embeds a batch of texts into vectors, in input order. Lets
28
+ * {@link VectorStore} stay decoupled from any specific embeddings provider -
29
+ * {@link createOpenAIEmbedder} is the shipped adapter for OpenAI's API.
30
+ */
31
+ export type Embedder = (input: string[]) => Promise<number[][]>;
32
+ /**
33
+ * Wraps an OpenAI client's `embeddings.create` as an {@link Embedder}, pinned
34
+ * to the same model `VectorStore` has always used - the model isn't a
35
+ * parameter because `VectorStore` labels every stored row with `EMB_MODEL`
36
+ * and never re-embeds rows written under a different one, so swapping models
37
+ * here without also handling that migration would silently corrupt search
38
+ * quality.
39
+ */
40
+ export declare function createOpenAIEmbedder(client: OpenAI): Embedder;
41
+ /** Thrown by `createServer`/`createMCPServer` when neither `config.retriever` nor `config.database` is set. Single-sourced so both surfaces state the same requirement. */
42
+ export declare const DATABASE_CONFIG_REQUIRED_MESSAGE: string;
43
+ /** Wraps a failed dynamic import of the optional `@libsql/client` peer in an actionable message. Exported separately so the message content is unit-testable without simulating a real missing module. */
44
+ export declare function wrapMissingLibsqlError(cause: unknown): Error;
45
+ /**
46
+ * Opens a libsql client for `database`, the one place `createServer`/
47
+ * `createMCPServer` touch `@libsql/client` at runtime - called lazily, only
48
+ * when a connection is actually needed, so a host running with
49
+ * `config.retriever` and no `config.database` never imports it at all.
50
+ */
51
+ export declare function openLibsqlClient(database: {
52
+ url: string;
53
+ authToken: string;
54
+ }): Promise<LibsqlClient>;
55
+ /**
56
+ * `VectorStore` always takes an already-open libsql client rather than
57
+ * credentials to open its own - the same rule every other store in this
58
+ * codebase follows (see
59
+ * [patterns/adding-a-store.md](../../docs/patterns/adding-a-store.md)), so
60
+ * `@libsql/client`'s runtime is never imported here: the caller (`createServer`,
61
+ * `createMCPServer`, or your own code) opens the connection and this module
62
+ * only ever sees the resulting value. Reusing one client is also what lets
63
+ * `ServerDependencies.db` and the store share a single connection instead of
64
+ * opening a second one.
65
+ */
66
+ export interface VectorStoreOptions {
67
+ /** An existing libsql client this store queries and writes through. */
68
+ databaseClient: LibsqlClient;
13
69
  /** Directory of markdown knowledge files. Default: `./config/knowledge` */
14
70
  knowledgeDir?: string;
15
71
  /** Logger for build progress. Default: a console logger writing to stderr. */
16
72
  logger?: Logger;
17
- } & ({
18
- /** Turso database URL */
19
- databaseUrl: string;
20
- /** Turso auth token */
21
- databaseAuthToken: string;
22
- databaseClient?: never;
23
- } | {
24
- /** An existing libsql client to reuse instead of opening a second connection */
25
- databaseClient: LibsqlClient;
26
- databaseUrl?: never;
27
- databaseAuthToken?: never;
28
- });
29
- export declare class VectorStore {
30
- private client;
31
73
  /**
32
- * The libsql client backing this store. When a client was injected this is
33
- * that same instance, so callers holding it (e.g. `ServerDependencies.db`)
74
+ * Single-writer lock `build()` holds while it rewrites the knowledge base,
75
+ * so two instances booting against one database cannot delete each other's
76
+ * chunks. Default: a lock table in `databaseClient` (see
77
+ * [buildLock.ts](./buildLock.ts)); supply your own to back it with
78
+ * something else, or a lock that always grants to opt out.
79
+ */
80
+ buildLock?: BuildLock;
81
+ /** Identifies this process while it holds the build lock. Default: a random id per store. */
82
+ instanceId?: string;
83
+ /** How long a held build lock survives with no heartbeat before another instance may take it over. Default: 10 minutes. */
84
+ buildLockStaleMs?: number;
85
+ }
86
+ export declare class VectorStore implements Retriever {
87
+ private embed;
88
+ /**
89
+ * The libsql client backing this store - the same instance passed in as
90
+ * `databaseClient`, so callers holding it (e.g. `ServerDependencies.db`)
34
91
  * and the store share one connection.
35
92
  */
36
93
  readonly db: LibsqlClient;
37
94
  private knowledgeDir;
38
95
  private logger;
39
- constructor(client: OpenAI, options: VectorStoreOptions);
96
+ private buildLock;
97
+ private instanceId;
98
+ private buildLockStaleMs;
99
+ constructor(embed: Embedder, options: VectorStoreOptions);
100
+ /**
101
+ * On boot: ingest new chunks and embed only missing ones.
102
+ *
103
+ * The whole ingest runs under a single-writer lock held in the database
104
+ * (see [buildLock.ts](./buildLock.ts)), because the cleanup step deletes
105
+ * every chunk id the current `knowledgeDir` did not produce. Without the
106
+ * lock, a second instance booting mid-build diffs against a database the
107
+ * first one is still writing and deletes its chunks. An instance that
108
+ * cannot take the lock skips its build entirely and serves what the holder
109
+ * has already written, rather than racing it.
110
+ */
40
111
  build(): Promise<void>;
112
+ /** Acquires the build lock, or refreshes the heartbeat if this store already holds it. */
113
+ private renewBuildLock;
114
+ /** The ingest itself. Only ever runs with the build lock held. */
115
+ private buildUnderLock;
41
116
  private cleanupStaleChunks;
42
117
  private static cosine;
43
118
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"retrieval.d.ts","sourceRoot":"","sources":["../../src/core/retrieval.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,KAAK,MAAM,IAAI,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC3E,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAC;AAEjC,OAAO,EAAuB,KAAK,MAAM,EAAE,MAAM,UAAU,CAAC;AAyB5D;;;;;;;GAOG;AACH,MAAM,MAAM,kBAAkB,GAAG;IAC/B,2EAA2E;IAC3E,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,8EAA8E;IAC9E,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,GAAG,CACA;IACE,yBAAyB;IACzB,WAAW,EAAE,MAAM,CAAC;IACpB,uBAAuB;IACvB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,cAAc,CAAC,EAAE,KAAK,CAAC;CACxB,GACD;IACE,gFAAgF;IAChF,cAAc,EAAE,YAAY,CAAC;IAC7B,WAAW,CAAC,EAAE,KAAK,CAAC;IACpB,iBAAiB,CAAC,EAAE,KAAK,CAAC;CAC3B,CACJ,CAAC;AAEF,qBAAa,WAAW;IAWpB,OAAO,CAAC,MAAM;IAVhB;;;;OAIG;IACH,QAAQ,CAAC,EAAE,EAAE,YAAY,CAAC;IAC1B,OAAO,CAAC,YAAY,CAAS;IAC7B,OAAO,CAAC,MAAM,CAAS;IAEvB,YACU,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
10
  expiresAt: number;
11
11
  metadata?: Record<string, unknown>;
12
12
  }
13
+ /** Prefix that marks an `x-api-key` value as a temporary session key rather than a JWT API key - checked by the auth/referrer/session middleware. */
14
+ export declare const SESSION_KEY_PREFIX = "session_";
15
+ /** Default max requests for a session created without an explicit `maxRequests`. */
16
+ export declare const DEFAULT_SESSION_MAX_REQUESTS = 20;
17
+ /** Default session lifetime in seconds (1 hour) for a session created without an explicit `ttl`. */
18
+ export declare const DEFAULT_SESSION_TTL_SECONDS = 3600;
19
+ /** How often the expired-session sweep runs (5 minutes). */
20
+ export declare const SESSION_SWEEP_INTERVAL_MS: number;
13
21
  export declare const sessionSweeper: NodeJS.Timeout;
14
22
  export interface CreateSessionOptions {
15
23
  /** Max requests allowed for this session (default: 20) */
@@ -1 +1 @@
1
- {"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../../src/core/session.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,UAAU,WAAW;IACnB,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACpC;AAaD,eAAO,MAAM,cAAc,gBAU1B,CAAC;AAGF,MAAM,WAAW,oBAAoB;IACnC,0DAA0D;IAC1D,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,2DAA2D;IAC3D,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,kDAAkD;IAClD,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACpC;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,OAAO,GAAE,oBAAyB,GAAG,WAAW,CAiB7E;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAoBpD;AAED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"}
@@ -19,7 +19,7 @@ export { loadFlowsFromDirectory } from "./loader";
19
19
  export { extractParameters } from "./params";
20
20
  export type { FlowRegistry } from "./registry";
21
21
  export { createFlowRegistry } from "./registry";
22
- export { createTursoFlowSessionStore } from "./session";
22
+ export { createTursoFlowSessionStore, DEFAULT_FLOW_SESSION_TABLE } from "./session";
23
23
  export type { FlowDefinition, FlowExtractionResult, FlowHandler, FlowHandlerContext, FlowHandlerResult, FlowPrefill, FlowResult, FlowSchema, FlowSchemaProperty, FlowSessionState, FlowSessionStore, IntentDetection, LoadedFlow, } from "./types";
24
24
  export { CURRENT_FLOW_CONTRACT_VERSION } from "./types";
25
25
  export { shouldExitFlow } from "./utils";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/flows/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,YAAY,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAC9D,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAC5C,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AACxC,OAAO,EAAE,sBAAsB,EAAE,MAAM,UAAU,CAAC;AAClD,OAAO,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAC7C,YAAY,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC/C,OAAO,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAChD,OAAO,EAAE,2BAA2B,EAAE,MAAM,WAAW,CAAC;AACxD,YAAY,EACV,cAAc,EACd,oBAAoB,EACpB,WAAW,EACX,kBAAkB,EAClB,iBAAiB,EACjB,WAAW,EACX,UAAU,EACV,UAAU,EACV,kBAAkB,EAClB,gBAAgB,EAChB,gBAAgB,EAChB,eAAe,EACf,UAAU,GACX,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,6BAA6B,EAAE,MAAM,SAAS,CAAC;AACxD,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/flows/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,YAAY,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAC9D,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAC5C,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AACxC,OAAO,EAAE,sBAAsB,EAAE,MAAM,UAAU,CAAC;AAClD,OAAO,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAC7C,YAAY,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC/C,OAAO,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAChD,OAAO,EAAE,2BAA2B,EAAE,0BAA0B,EAAE,MAAM,WAAW,CAAC;AACpF,YAAY,EACV,cAAc,EACd,oBAAoB,EACpB,WAAW,EACX,kBAAkB,EAClB,iBAAiB,EACjB,WAAW,EACX,UAAU,EACV,UAAU,EACV,kBAAkB,EAClB,gBAAgB,EAChB,gBAAgB,EAChB,eAAe,EACf,UAAU,GACX,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,6BAA6B,EAAE,MAAM,SAAS,CAAC;AACxD,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC"}
@@ -21,6 +21,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
21
21
  var index_exports = {};
22
22
  __export(index_exports, {
23
23
  CURRENT_FLOW_CONTRACT_VERSION: () => CURRENT_FLOW_CONTRACT_VERSION,
24
+ DEFAULT_FLOW_SESSION_TABLE: () => DEFAULT_FLOW_SESSION_TABLE,
24
25
  createFlowEngine: () => createFlowEngine,
25
26
  createFlowRegistry: () => createFlowRegistry,
26
27
  createTursoFlowSessionStore: () => createTursoFlowSessionStore,
@@ -155,16 +156,15 @@ async function loadFlow(flowsDir, flowName, logger) {
155
156
  const definitionPath = (0, import_node_path.join)(flowPath, "flow.json");
156
157
  const instructionsPath = (0, import_node_path.join)(flowPath, "instructions.md");
157
158
  if (!(0, import_node_fs.existsSync)(definitionPath)) {
158
- throw new Error(`flow.json not found for ${flowName}`);
159
+ throw new Error(`flow.json not found for ${flowName} (looked for ${definitionPath})`);
159
160
  }
160
161
  if (!(0, import_node_fs.existsSync)(instructionsPath)) {
161
- throw new Error(`instructions.md not found for ${flowName}`);
162
+ throw new Error(`instructions.md not found for ${flowName} (looked for ${instructionsPath})`);
162
163
  }
163
164
  const handlerPath = findModulePath(flowPath, "handler");
164
165
  if (!handlerPath) {
165
- throw new Error(
166
- `no handler found for ${flowName} (looked for ${MODULE_EXTENSIONS.map((ext) => `handler.${ext}`).join(", ")})`
167
- );
166
+ const candidates = MODULE_EXTENSIONS.map((ext) => (0, import_node_path.join)(flowPath, `handler.${ext}`)).join(", ");
167
+ throw new Error(`no handler found for ${flowName} (looked for ${candidates})`);
168
168
  }
169
169
  const rawDefinition = JSON.parse((0, import_node_fs.readFileSync)(definitionPath, "utf-8"));
170
170
  validateFlowDefinition(rawDefinition, flowName);
@@ -491,7 +491,8 @@ function ensureSessionSchema(client, tableName) {
491
491
  return ready;
492
492
  }
493
493
  var VALID_TABLE_NAME = /^[A-Za-z_][A-Za-z0-9_]*$/;
494
- function createTursoFlowSessionStore(client, tableName = "flow_sessions") {
494
+ var DEFAULT_FLOW_SESSION_TABLE = "flow_sessions";
495
+ function createTursoFlowSessionStore(client, tableName = DEFAULT_FLOW_SESSION_TABLE) {
495
496
  if (!VALID_TABLE_NAME.test(tableName)) {
496
497
  throw new Error(`Invalid flow session store table name: ${tableName}`);
497
498
  }
@@ -537,6 +538,7 @@ function createTursoFlowSessionStore(client, tableName = "flow_sessions") {
537
538
  // Annotate the CommonJS export names for ESM import in node:
538
539
  0 && (module.exports = {
539
540
  CURRENT_FLOW_CONTRACT_VERSION,
541
+ DEFAULT_FLOW_SESSION_TABLE,
540
542
  createFlowEngine,
541
543
  createFlowRegistry,
542
544
  createTursoFlowSessionStore,
@@ -122,16 +122,15 @@ async function loadFlow(flowsDir, flowName, logger) {
122
122
  const definitionPath = join(flowPath, "flow.json");
123
123
  const instructionsPath = join(flowPath, "instructions.md");
124
124
  if (!existsSync(definitionPath)) {
125
- throw new Error(`flow.json not found for ${flowName}`);
125
+ throw new Error(`flow.json not found for ${flowName} (looked for ${definitionPath})`);
126
126
  }
127
127
  if (!existsSync(instructionsPath)) {
128
- throw new Error(`instructions.md not found for ${flowName}`);
128
+ throw new Error(`instructions.md not found for ${flowName} (looked for ${instructionsPath})`);
129
129
  }
130
130
  const handlerPath = findModulePath(flowPath, "handler");
131
131
  if (!handlerPath) {
132
- throw new Error(
133
- `no handler found for ${flowName} (looked for ${MODULE_EXTENSIONS.map((ext) => `handler.${ext}`).join(", ")})`
134
- );
132
+ const candidates = MODULE_EXTENSIONS.map((ext) => join(flowPath, `handler.${ext}`)).join(", ");
133
+ throw new Error(`no handler found for ${flowName} (looked for ${candidates})`);
135
134
  }
136
135
  const rawDefinition = JSON.parse(readFileSync(definitionPath, "utf-8"));
137
136
  validateFlowDefinition(rawDefinition, flowName);
@@ -458,7 +457,8 @@ function ensureSessionSchema(client, tableName) {
458
457
  return ready;
459
458
  }
460
459
  var VALID_TABLE_NAME = /^[A-Za-z_][A-Za-z0-9_]*$/;
461
- function createTursoFlowSessionStore(client, tableName = "flow_sessions") {
460
+ var DEFAULT_FLOW_SESSION_TABLE = "flow_sessions";
461
+ function createTursoFlowSessionStore(client, tableName = DEFAULT_FLOW_SESSION_TABLE) {
462
462
  if (!VALID_TABLE_NAME.test(tableName)) {
463
463
  throw new Error(`Invalid flow session store table name: ${tableName}`);
464
464
  }
@@ -503,6 +503,7 @@ function createTursoFlowSessionStore(client, tableName = "flow_sessions") {
503
503
  }
504
504
  export {
505
505
  CURRENT_FLOW_CONTRACT_VERSION,
506
+ DEFAULT_FLOW_SESSION_TABLE,
506
507
  createFlowEngine,
507
508
  createFlowRegistry,
508
509
  createTursoFlowSessionStore,
@@ -1,5 +1,5 @@
1
1
  /**
2
- * LLM-powered intent detection — classifies a message into a flow id, or the
2
+ * LLM-powered intent detection - classifies a message into a flow id, or the
3
3
  * `chatbot` fallback, using the caller's OpenAI client (never a raw fetch, so
4
4
  * the same client tests already fake for chat completions covers this too).
5
5
  */
@@ -1 +1 @@
1
- {"version":3,"file":"intent.d.ts","sourceRoot":"","sources":["../../src/flows/intent.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAC;AACjC,OAAO,EAAuB,KAAK,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAClE,OAAO,KAAK,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAE3D,yEAAyE;AACzE,wBAAsB,YAAY,CAChC,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,MAAM,EACf,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,UAAU,CAAC,EAC9B,mBAAmB,CAAC,EAAE,MAAM,EAAE,EAC9B,MAAM,GAAE,MAA8B,GACrC,OAAO,CAAC,eAAe,CAAC,CAyD1B"}
1
+ {"version":3,"file":"intent.d.ts","sourceRoot":"","sources":["../../src/flows/intent.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAC;AACjC,OAAO,EAAuB,KAAK,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAClE,OAAO,KAAK,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAE3D,yEAAyE;AACzE,wBAAsB,YAAY,CAChC,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,MAAM,EACf,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,UAAU,CAAC,EAC9B,mBAAmB,CAAC,EAAE,MAAM,EAAE,EAC9B,MAAM,GAAE,MAA8B,GACrC,OAAO,CAAC,eAAe,CAAC,CA+D1B"}
@@ -3,8 +3,7 @@
3
3
  *
4
4
  * Discovers flow directories on disk and loads each one's contract, validated
5
5
  * against the versioned flow.json contract (see {@link CURRENT_FLOW_CONTRACT_VERSION}
6
- * in ./types). Kept compatible with the reference implementation's on-disk
7
- * shape, so existing flow directories load unchanged.
6
+ * in ./types).
8
7
  */
9
8
  import { type Logger } from "../core/logger";
10
9
  import type { LoadedFlow } from "./types";
@@ -1 +1 @@
1
- {"version":3,"file":"loader.d.ts","sourceRoot":"","sources":["../../src/flows/loader.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAIH,OAAO,EAAuB,KAAK,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAClE,OAAO,KAAK,EAA4C,UAAU,EAAE,MAAM,SAAS,CAAC;AAQpF,gHAAgH;AAChH,wBAAsB,sBAAsB,CAC1C,QAAQ,EAAE,MAAM,EAChB,MAAM,GAAE,MAA8B,GACrC,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC,CAwBlC"}
1
+ {"version":3,"file":"loader.d.ts","sourceRoot":"","sources":["../../src/flows/loader.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,OAAO,EAAuB,KAAK,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAClE,OAAO,KAAK,EAA4C,UAAU,EAAE,MAAM,SAAS,CAAC;AAQpF,gHAAgH;AAChH,wBAAsB,sBAAsB,CAC1C,QAAQ,EAAE,MAAM,EAChB,MAAM,GAAE,MAA8B,GACrC,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC,CAwBlC"}
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Schema-driven parameter extraction — pulls structured params out of a
2
+ * Schema-driven parameter extraction - pulls structured params out of a
3
3
  * message using the flow's `instructions.md` and JSON schema, across as many
4
4
  * turns as it takes to fill every required field.
5
5
  */
@@ -1 +1 @@
1
- {"version":3,"file":"params.d.ts","sourceRoot":"","sources":["../../src/flows/params.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAC;AACjC,OAAO,KAAK,EAAE,oBAAoB,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAOhE;;;;;GAKG;AACH,wBAAsB,iBAAiB,CACrC,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,UAAU,EAChB,OAAO,EAAE,MAAM,EACf,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACvC,GAAG,GAAE,MAAM,MAAiB,GAC3B,OAAO,CAAC,oBAAoB,CAAC,CA6F/B"}
1
+ {"version":3,"file":"params.d.ts","sourceRoot":"","sources":["../../src/flows/params.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAC;AACjC,OAAO,KAAK,EAAE,oBAAoB,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAOhE;;;;;GAKG;AACH,wBAAsB,iBAAiB,CACrC,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,UAAU,EAChB,OAAO,EAAE,MAAM,EACf,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACvC,GAAG,GAAE,MAAM,MAAiB,GAC3B,OAAO,CAAC,oBAAoB,CAAC,CAiG/B"}
@@ -2,14 +2,16 @@
2
2
  * Turso/libsql-backed {@link FlowSessionStore}.
3
3
  *
4
4
  * Session state lives in the database rather than process memory because
5
- * deployments run multiple instances — the instance that handles turn 2 of a
6
- * multi-turn flow is not guaranteed to be the one that handled turn 1.
5
+ * deployments run multiple instances, and the instance that handles turn 2
6
+ * of a multi-turn flow is not guaranteed to be the one that handled turn 1.
7
7
  *
8
8
  * `@libsql/client` is imported for its type alone, so this module adds no
9
9
  * runtime dependency to anyone importing `./flows` for the pure engine.
10
10
  */
11
11
  import type { Client } from "@libsql/client";
12
12
  import type { FlowSessionStore } from "./types";
13
+ /** Default table name for {@link createTursoFlowSessionStore} when no `tableName` is given, mirroring `scheduler`'s `DEFAULT_CLAIM_TABLE`. */
14
+ export declare const DEFAULT_FLOW_SESSION_TABLE = "flow_sessions";
13
15
  /** Creates a session store keyed by an arbitrary session id (phone number, WhatsApp JID, web session id) on `tableName`. */
14
16
  export declare function createTursoFlowSessionStore(client: Client, tableName?: string): FlowSessionStore;
15
17
  //# sourceMappingURL=session.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../../src/flows/session.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,KAAK,EAAoB,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAyClE,4HAA4H;AAC5H,wBAAgB,2BAA2B,CACzC,MAAM,EAAE,MAAM,EACd,SAAS,SAAkB,GAC1B,gBAAgB,CA6ClB"}
1
+ {"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../../src/flows/session.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,KAAK,EAAoB,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAyClE,8IAA8I;AAC9I,eAAO,MAAM,0BAA0B,kBAAkB,CAAC;AAE1D,4HAA4H;AAC5H,wBAAgB,2BAA2B,CACzC,MAAM,EAAE,MAAM,EACd,SAAS,SAA6B,GACrC,gBAAgB,CA6ClB"}
@@ -4,9 +4,8 @@
4
4
  * A flow is a directory-loaded contract: `flow.json` (id/name/description/
5
5
  * triggerKeywords/schema), `handler.ts` (an `execute` export) and
6
6
  * `instructions.md` (the prompt fed to parameter extraction), with an
7
- * optional `prefill.ts` (`prefillFromContext` export). This is the same
8
- * on-disk shape the reference implementation used — existing flow
9
- * directories load unchanged.
7
+ * optional `prefill.ts` (`prefillFromContext` export). A stable on-disk
8
+ * contract, versioned via `contractVersion` below.
10
9
  */
11
10
  export interface FlowSchemaProperty {
12
11
  type: "string" | "number" | "boolean";
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/flows/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,QAAQ,GAAG,QAAQ,GAAG,SAAS,CAAC;IACtC,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,QAAQ,CAAC;IACf,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,kBAAkB,CAAC,CAAC;IAC/C,QAAQ,EAAE,MAAM,EAAE,CAAC;CACpB;AAED;;;;;GAKG;AACH,eAAO,MAAM,6BAA6B,IAAI,CAAC;AAE/C,0BAA0B;AAC1B,MAAM,WAAW,cAAc;IAC7B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,eAAe,EAAE,MAAM,EAAE,CAAC;IAC1B,MAAM,EAAE,UAAU,CAAC;IACnB,6EAA6E;IAC7E,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED,8DAA8D;AAC9D,MAAM,WAAW,kBAAkB;IACjC,6HAA6H;IAC7H,UAAU,EAAE,MAAM,CAAC;IACnB,yFAAyF;IACzF,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;;;;;GAMG;AACH,MAAM,WAAW,iBAAiB;IAChC;;;;;OAKG;IACH,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAED,MAAM,MAAM,WAAW,GAAG,CACxB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC/B,OAAO,EAA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O,CAAC,IAAI,CAAC,CAAC;CAC1C;AAED,MAAM,WAAW,UAAU;IACzB,YAAY,EAAE,OAAO,CAAC;IACtB,OAAO,EAAE,MAAM,CAAC;IAChB,aAAa,EAAE,OAAO,CAAC;IACvB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,2CAA2C;IAC3C,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,kFAAkF;IAClF,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB"}
@@ -20,6 +20,6 @@
20
20
  export type { HistoryCompactionOptions, HistoryCompactor, SummarizeFn, SummarizeRequest, } from "./compaction";
21
21
  export { createHistoryCompactor, SUMMARY_PREFIX } from "./compaction";
22
22
  export type { TursoHistoryStoreOptions } from "./tursoStore";
23
- export { createTursoHistoryStore } from "./tursoStore";
23
+ export { createTursoHistoryStore, DEFAULT_HISTORY_TABLE } from "./tursoStore";
24
24
  export type { HistoryMessage, HistoryStore } from "./types";
25
25
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/history/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,YAAY,EACV,wBAAwB,EACxB,gBAAgB,EAChB,WAAW,EACX,gBAAgB,GACjB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,sBAAsB,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AACtE,YAAY,EAAE,wBAAwB,EAAE,MAAM,cAAc,CAAC;AAC7D,OAAO,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAC;AACvD,YAAY,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/history/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,YAAY,EACV,wBAAwB,EACxB,gBAAgB,EAChB,WAAW,EACX,gBAAgB,GACjB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,sBAAsB,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AACtE,YAAY,EAAE,wBAAwB,EAAE,MAAM,cAAc,CAAC;AAC7D,OAAO,EAAE,uBAAuB,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AAC9E,YAAY,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC"}
@@ -20,6 +20,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
20
20
  // src/history/index.ts
21
21
  var index_exports = {};
22
22
  __export(index_exports, {
23
+ DEFAULT_HISTORY_TABLE: () => DEFAULT_HISTORY_TABLE,
23
24
  SUMMARY_PREFIX: () => SUMMARY_PREFIX,
24
25
  createHistoryCompactor: () => createHistoryCompactor,
25
26
  createTursoHistoryStore: () => createTursoHistoryStore
@@ -97,7 +98,7 @@ async function answerOnce({
97
98
  }
98
99
 
99
100
  // src/history/compaction.ts
100
- var DEFAULT_TIMEOUT_MS = 8e3;
101
+ var COMPACTION_TIMEOUT_MS = 8e3;
101
102
  var LOAD_ALL = Number.MAX_SAFE_INTEGER;
102
103
  var SUMMARY_PREFIX = "Summary of earlier conversation: ";
103
104
  function defaultSummarize(client, model) {
@@ -125,7 +126,7 @@ function createHistoryCompactor(deps, options) {
125
126
  throw new Error(`Invalid history compaction keep: ${keep}`);
126
127
  }
127
128
  const summarize = options.summarize ?? defaultSummarize(deps.client, options.model);
128
- const timeoutMs = options.timeoutMs ?? DEFAULT_TIMEOUT_MS;
129
+ const timeoutMs = options.timeoutMs ?? COMPACTION_TIMEOUT_MS;
129
130
  return {
130
131
  async maybeCompact(store, conversationId) {
131
132
  const turns = await store.load(conversationId, LOAD_ALL);
@@ -199,7 +200,8 @@ function ensureHistorySchema(client, tableName) {
199
200
  var VALID_TABLE_NAME = /^[A-Za-z_][A-Za-z0-9_]*$/;
200
201
  var VALID_ROLES = /* @__PURE__ */ new Set(["user", "assistant"]);
201
202
  var DEFAULT_MAX_PER_CONVERSATION = 200;
202
- function createTursoHistoryStore(client, tableName = "chat_history", maxPerConversation = DEFAULT_MAX_PER_CONVERSATION, options) {
203
+ var DEFAULT_HISTORY_TABLE = "chat_history";
204
+ function createTursoHistoryStore(client, tableName = DEFAULT_HISTORY_TABLE, maxPerConversation = DEFAULT_MAX_PER_CONVERSATION, options) {
203
205
  if (!VALID_TABLE_NAME.test(tableName)) {
204
206
  throw new Error(`Invalid history store table name: ${tableName}`);
205
207
  }
@@ -258,6 +260,7 @@ function createTursoHistoryStore(client, tableName = "chat_history", maxPerConve
258
260
  }
259
261
  // Annotate the CommonJS export names for ESM import in node:
260
262
  0 && (module.exports = {
263
+ DEFAULT_HISTORY_TABLE,
261
264
  SUMMARY_PREFIX,
262
265
  createHistoryCompactor,
263
266
  createTursoHistoryStore
@@ -69,7 +69,7 @@ async function answerOnce({
69
69
  }
70
70
 
71
71
  // src/history/compaction.ts
72
- var DEFAULT_TIMEOUT_MS = 8e3;
72
+ var COMPACTION_TIMEOUT_MS = 8e3;
73
73
  var LOAD_ALL = Number.MAX_SAFE_INTEGER;
74
74
  var SUMMARY_PREFIX = "Summary of earlier conversation: ";
75
75
  function defaultSummarize(client, model) {
@@ -97,7 +97,7 @@ function createHistoryCompactor(deps, options) {
97
97
  throw new Error(`Invalid history compaction keep: ${keep}`);
98
98
  }
99
99
  const summarize = options.summarize ?? defaultSummarize(deps.client, options.model);
100
- const timeoutMs = options.timeoutMs ?? DEFAULT_TIMEOUT_MS;
100
+ const timeoutMs = options.timeoutMs ?? COMPACTION_TIMEOUT_MS;
101
101
  return {
102
102
  async maybeCompact(store, conversationId) {
103
103
  const turns = await store.load(conversationId, LOAD_ALL);
@@ -171,7 +171,8 @@ function ensureHistorySchema(client, tableName) {
171
171
  var VALID_TABLE_NAME = /^[A-Za-z_][A-Za-z0-9_]*$/;
172
172
  var VALID_ROLES = /* @__PURE__ */ new Set(["user", "assistant"]);
173
173
  var DEFAULT_MAX_PER_CONVERSATION = 200;
174
- function createTursoHistoryStore(client, tableName = "chat_history", maxPerConversation = DEFAULT_MAX_PER_CONVERSATION, options) {
174
+ var DEFAULT_HISTORY_TABLE = "chat_history";
175
+ function createTursoHistoryStore(client, tableName = DEFAULT_HISTORY_TABLE, maxPerConversation = DEFAULT_MAX_PER_CONVERSATION, options) {
175
176
  if (!VALID_TABLE_NAME.test(tableName)) {
176
177
  throw new Error(`Invalid history store table name: ${tableName}`);
177
178
  }
@@ -229,6 +230,7 @@ function createTursoHistoryStore(client, tableName = "chat_history", maxPerConve
229
230
  };
230
231
  }
231
232
  export {
233
+ DEFAULT_HISTORY_TABLE,
232
234
  SUMMARY_PREFIX,
233
235
  createHistoryCompactor,
234
236
  createTursoHistoryStore
@@ -2,18 +2,20 @@
2
2
  * Turso/libsql-backed {@link HistoryStore}.
3
3
  *
4
4
  * History lives in the database rather than process memory because
5
- * deployments run multiple instances — the instance that handles turn 2 of a
6
- * conversation is not guaranteed to be the one that handled turn 1.
5
+ * deployments run multiple instances, and the instance that handles turn 2
6
+ * of a conversation is not guaranteed to be the one that handled turn 1.
7
7
  *
8
8
  * `@libsql/client` is imported for its type alone, so this module adds no
9
9
  * runtime dependency to anyone importing `./history` for the store contract.
10
10
  */
11
11
  import type { Client } from "@libsql/client";
12
12
  import type { HistoryStore } from "./types";
13
+ /** Default table name for {@link createTursoHistoryStore} when no `tableName` is given, mirroring `scheduler`'s `DEFAULT_CLAIM_TABLE`. */
14
+ export declare const DEFAULT_HISTORY_TABLE = "chat_history";
13
15
  export interface TursoHistoryStoreOptions {
14
16
  /**
15
17
  * Retention window: rows older than this are pruned whenever the
16
- * conversation they belong to is accessed (`append` or `load`) — there is
18
+ * conversation they belong to is accessed (`append` or `load`); there is
17
19
  * no background sweep. Unset: rows never expire on their own (only the
18
20
  * `maxPerConversation` count cap and explicit `clear` remove them). Must be
19
21
  * a positive integer, validated at construction like `maxPerConversation`.
@@ -28,7 +30,7 @@ export interface TursoHistoryStoreOptions {
28
30
  *
29
31
  * `append` prunes each conversation back down to `maxPerConversation` after
30
32
  * every write, so the table stays bounded even for a conversation nobody
31
- * ever calls `load` on with a small `limit` — a caller's `limit` shapes what
33
+ * ever calls `load` on with a small `limit`; a caller's `limit` shapes what
32
34
  * a single `load` returns, not how much history physically accumulates. A
33
35
  * non-positive `maxPerConversation` would prune every write to nothing (`0`)
34
36
  * or disable pruning entirely (SQLite reads a negative `LIMIT` as
@@ -1 +1 @@
1
- {"version":3,"file":"tursoStore.d.ts","sourceRoot":"","sources":["../../src/history/tursoStore.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,KAAK,EAAkB,YAAY,EAAE,MAAM,SAAS,CAAC;AAkD5D,MAAM,WAAW,wBAAwB;IACvC;;;;;;OAMG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,oDAAoD;IACpD,GAAG,CAAC,EAAE,MAAM,MAAM,CAAC;CACpB;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,uBAAuB,CACrC,MAAM,EAAE,MAAM,EACd,SAAS,SAAiB,EAC1B,kBAAkB,SAA+B,EACjD,OAAO,CAAC,EAAE,wBAAwB,GACjC,YAAY,CAyEd"}
1
+ {"version":3,"file":"tursoStore.d.ts","sourceRoot":"","sources":["../../src/history/tursoStore.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,KAAK,EAAkB,YAAY,EAAE,MAAM,SAAS,CAAC;AAkD5D,0IAA0I;AAC1I,eAAO,MAAM,qBAAqB,iBAAiB,CAAC;AAEpD,MAAM,WAAW,wBAAwB;IACvC;;;;;;OAMG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,oDAAoD;IACpD,GAAG,CAAC,EAAE,MAAM,MAAM,CAAC;CACpB;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,uBAAuB,CACrC,MAAM,EAAE,MAAM,EACd,SAAS,SAAwB,EACjC,kBAAkB,SAA+B,EACjD,OAAO,CAAC,EAAE,wBAAwB,GACjC,YAAY,CAyEd"}
@@ -120,11 +120,11 @@ function createTursoImageCacheStore(client, tableName) {
120
120
  }
121
121
 
122
122
  // src/images/captionComposer.ts
123
- var DEFAULT_TIMEOUT_MS = 8e3;
123
+ var CAPTION_TIMEOUT_MS = 8e3;
124
124
  var MAX_COMPOSED_LENGTH = 300;
125
125
  function createCaptionComposer(options) {
126
126
  const { pool } = options;
127
- const timeoutMs = options.timeoutMs ?? DEFAULT_TIMEOUT_MS;
127
+ const timeoutMs = options.timeoutMs ?? CAPTION_TIMEOUT_MS;
128
128
  const random = options.random ?? Math.random;
129
129
  function randomCaption(subject) {
130
130
  if (pool.length === 0) return "";
@@ -66,11 +66,11 @@ function createTursoImageCacheStore(client, tableName) {
66
66
  }
67
67
 
68
68
  // src/images/captionComposer.ts
69
- var DEFAULT_TIMEOUT_MS = 8e3;
69
+ var CAPTION_TIMEOUT_MS = 8e3;
70
70
  var MAX_COMPOSED_LENGTH = 300;
71
71
  function createCaptionComposer(options) {
72
72
  const { pool } = options;
73
- const timeoutMs = options.timeoutMs ?? DEFAULT_TIMEOUT_MS;
73
+ const timeoutMs = options.timeoutMs ?? CAPTION_TIMEOUT_MS;
74
74
  const random = options.random ?? Math.random;
75
75
  function randomCaption(subject) {
76
76
  if (pool.length === 0) return "";
package/dist/index.d.ts CHANGED
@@ -18,6 +18,8 @@ export type { AnswerFn, AnswerFnInput, AnswerFnResult, AnswerOptions, AnswerUsag
18
18
  export { answerOnce, answerStream, applyTransformReply } from "./core/answer";
19
19
  export type { BucketsFor, BucketsForContext } from "./core/buckets";
20
20
  export { defaultBuckets, resolveBuckets } from "./core/buckets";
21
+ export type { BuildLock, BuildLockRow } from "./core/buildLock";
22
+ export { BUILD_LOCK_KEY, BUILD_LOCK_STALE_MS, canAcquireBuildLock, createTursoBuildLock, } from "./core/buildLock";
21
23
  export { detectLeakage, guardOutput, scrubOutput } from "./core/guardrails";
22
24
  export { completeOnce, completeStream, DEFAULT_MODEL } from "./core/llm";
23
25
  export { loadKnowledge } from "./core/loaders";
@@ -25,11 +27,11 @@ export type { Logger, LogLevel } from "./core/logger";
25
27
  export { createConsoleLogger } from "./core/logger";
26
28
  export type { NormalizedChatBody } from "./core/messages";
27
29
  export { normalizeChatBody, normalizeMessages } from "./core/messages";
28
- export type { PipelineMessage, PipelineMode, PreparedChat, RerankContext, RerankContextArgs, RewriteQuery, RewriteQueryArgs, } from "./core/pipeline";
30
+ export type { FallbackContext, FallbackFn, PipelineMessage, PipelineMode, PreparedChat, RerankContext, RerankContextArgs, RewriteQuery, RewriteQueryArgs, } from "./core/pipeline";
29
31
  export { prepareChat } from "./core/pipeline";
30
- export { PromptLoader } from "./core/prompts";
31
- export type { VectorStoreOptions } from "./core/retrieval";
32
- export { VectorStore } from "./core/retrieval";
32
+ export { DEFAULT_PROMPTS_DIR, PromptLoader } from "./core/prompts";
33
+ export type { Embedder, Retriever, VectorStoreOptions } from "./core/retrieval";
34
+ export { createOpenAIEmbedder, DEFAULT_KNOWLEDGE_DIR, VectorStore } from "./core/retrieval";
33
35
  export { createSession, getActiveSessions, getSessionInfo, validateSession, } from "./core/session";
34
36
  export type { MCPServerOptions, MCPTransportMode } from "./mcp-server";
35
37
  export { createMCPServer } from "./mcp-server";
@@ -49,5 +51,5 @@ export type { ChatterApp } from "./server";
49
51
  export { createServer } from "./server";
50
52
  export type { Shortener, ShortenerConfig } from "./shortener";
51
53
  export { createShortener } from "./shortener";
52
- export type { BotBranding, BotChatConfig, BotIdentity, ChatterConfig, CustomRoutes, EmbeddingChunk, KnowledgeDocument, PricingRates, ServerDependencies, } from "./types";
54
+ export type { BotBranding, BotChatConfig, BotIdentity, BrainHooks, ChatterConfig, CustomRoutes, EmbeddingChunk, KnowledgeDocument, PricingRates, ServerDependencies, } from "./types";
53
55
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,YAAY,EAAE,aAAa,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAEzE,OAAO,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AAIvC,YAAY,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAG1C,YAAY,EACV,aAAa,EACb,gBAAgB,EAChB,UAAU,EACV,WAAW,EACX,QAAQ,EACR,eAAe,GAChB,MAAM,UAAU,CAAC;AAClB,YAAY,EACV,QAAQ,EACR,aAAa,EACb,cAAc,EACd,aAAa,EACb,WAAW,EACX,cAAc,EACd,mBAAmB,GACpB,MAAM,eAAe,CAAC;AAEvB,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAC9E,YAAY,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAEpE,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAChE,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAC5E,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AACzE,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC/C,YAAY,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAGtD,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AACpD,YAAY,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAG1D,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACvE,YAAY,EACV,eAAe,EACf,YAAY,EACZ,YAAY,E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