@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.
- package/README.md +56 -17
- package/dist/auth/secretStrength.d.ts +1 -1
- package/dist/auth/secretStrength.d.ts.map +1 -1
- package/dist/bin/create-apikey.js +45 -28
- package/dist/bin/wa-pair.js +113 -46
- package/dist/channels/backoff.d.ts +10 -0
- package/dist/channels/backoff.d.ts.map +1 -0
- package/dist/channels/gates.d.ts +15 -8
- package/dist/channels/gates.d.ts.map +1 -1
- package/dist/channels/index.d.ts +1 -1
- package/dist/channels/index.d.ts.map +1 -1
- package/dist/channels/index.js +38 -5
- package/dist/channels/index.mjs +37 -5
- package/dist/channels/matrix/api.d.ts +152 -0
- package/dist/channels/matrix/api.d.ts.map +1 -0
- package/dist/channels/matrix/channel.d.ts +46 -0
- package/dist/channels/matrix/channel.d.ts.map +1 -0
- package/dist/channels/matrix/handler.d.ts +58 -0
- package/dist/channels/matrix/handler.d.ts.map +1 -0
- package/dist/channels/matrix/index.d.ts +37 -0
- package/dist/channels/matrix/index.d.ts.map +1 -0
- package/dist/channels/matrix/index.js +1128 -0
- package/dist/channels/matrix/index.mjs +1079 -0
- package/dist/channels/matrix/sync.d.ts +53 -0
- package/dist/channels/matrix/sync.d.ts.map +1 -0
- package/dist/channels/matrix/updates.d.ts +104 -0
- package/dist/channels/matrix/updates.d.ts.map +1 -0
- package/dist/channels/pipeline.d.ts +14 -14
- package/dist/channels/pipeline.d.ts.map +1 -1
- package/dist/channels/polling.d.ts +67 -0
- package/dist/channels/polling.d.ts.map +1 -0
- package/dist/channels/telegram/channel.d.ts +2 -56
- package/dist/channels/telegram/channel.d.ts.map +1 -1
- package/dist/channels/telegram/index.js +53 -23
- package/dist/channels/telegram/index.mjs +53 -23
- package/dist/channels/telegram/poll.d.ts +5 -1
- package/dist/channels/telegram/poll.d.ts.map +1 -1
- package/dist/channels/telegram/webhook.d.ts +2 -10
- package/dist/channels/telegram/webhook.d.ts.map +1 -1
- package/dist/channels/whatsapp/authState.d.ts +40 -9
- package/dist/channels/whatsapp/authState.d.ts.map +1 -1
- package/dist/channels/whatsapp/channel.d.ts +25 -4
- package/dist/channels/whatsapp/channel.d.ts.map +1 -1
- package/dist/channels/whatsapp/inbound.d.ts +23 -25
- package/dist/channels/whatsapp/inbound.d.ts.map +1 -1
- package/dist/channels/whatsapp/index.d.ts +3 -3
- package/dist/channels/whatsapp/index.d.ts.map +1 -1
- package/dist/channels/whatsapp/index.js +123 -41
- package/dist/channels/whatsapp/index.mjs +120 -41
- package/dist/channels/whatsapp/pairing.d.ts.map +1 -1
- package/dist/client/src/Chat.d.ts.map +1 -1
- package/dist/client/src/ChatButton.d.ts.map +1 -1
- package/dist/client/src/browser.d.ts.map +1 -1
- package/dist/core/answer.d.ts +8 -0
- package/dist/core/answer.d.ts.map +1 -1
- package/dist/core/buildLock.d.ts +52 -0
- package/dist/core/buildLock.d.ts.map +1 -0
- package/dist/core/pipeline.d.ts +42 -5
- package/dist/core/pipeline.d.ts.map +1 -1
- package/dist/core/prompts.d.ts +2 -0
- package/dist/core/prompts.d.ts.map +1 -1
- package/dist/core/retrieval.d.ts +100 -25
- package/dist/core/retrieval.d.ts.map +1 -1
- package/dist/core/session.d.ts +8 -0
- package/dist/core/session.d.ts.map +1 -1
- package/dist/flows/index.d.ts +1 -1
- package/dist/flows/index.d.ts.map +1 -1
- package/dist/flows/index.js +8 -6
- package/dist/flows/index.mjs +7 -6
- package/dist/flows/intent.d.ts +1 -1
- package/dist/flows/intent.d.ts.map +1 -1
- package/dist/flows/loader.d.ts +1 -2
- package/dist/flows/loader.d.ts.map +1 -1
- package/dist/flows/params.d.ts +1 -1
- package/dist/flows/params.d.ts.map +1 -1
- package/dist/flows/session.d.ts +4 -2
- package/dist/flows/session.d.ts.map +1 -1
- package/dist/flows/types.d.ts +2 -3
- package/dist/flows/types.d.ts.map +1 -1
- package/dist/history/index.d.ts +1 -1
- package/dist/history/index.d.ts.map +1 -1
- package/dist/history/index.js +6 -3
- package/dist/history/index.mjs +5 -3
- package/dist/history/tursoStore.d.ts +6 -4
- package/dist/history/tursoStore.d.ts.map +1 -1
- package/dist/images/index.js +2 -2
- package/dist/images/index.mjs +2 -2
- package/dist/index.d.ts +7 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +596 -295
- package/dist/index.mjs +595 -295
- package/dist/mcp-server/index.d.ts +5 -5
- package/dist/mcp-server/index.d.ts.map +1 -1
- package/dist/mcp-server/logger.d.ts +12 -2
- package/dist/mcp-server/logger.d.ts.map +1 -1
- package/dist/mcp-server/rate-limiter.d.ts +10 -3
- package/dist/mcp-server/rate-limiter.d.ts.map +1 -1
- package/dist/mcp-server/types.d.ts +20 -5
- package/dist/mcp-server/types.d.ts.map +1 -1
- package/dist/mcp-server.js +479 -244
- package/dist/mcp-server.mjs +485 -244
- package/dist/middleware/apiKey.d.ts +10 -0
- package/dist/middleware/apiKey.d.ts.map +1 -0
- package/dist/middleware/auth.d.ts.map +1 -1
- package/dist/middleware/cors.d.ts.map +1 -1
- package/dist/middleware/ratelimit.d.ts.map +1 -1
- package/dist/middleware/referrer.d.ts.map +1 -1
- package/dist/middleware/session.d.ts +1 -1
- package/dist/middleware/session.d.ts.map +1 -1
- package/dist/routes/demo.d.ts.map +1 -1
- package/dist/routes/openai.d.ts.map +1 -1
- package/dist/routes/private.d.ts.map +1 -1
- package/dist/routes/public.d.ts.map +1 -1
- package/dist/scheduler/index.js +1 -1
- package/dist/scheduler/index.mjs +1 -1
- package/dist/scheduler/scheduler.d.ts +9 -1
- package/dist/scheduler/scheduler.d.ts.map +1 -1
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +491 -268
- package/dist/server.mjs +497 -268
- package/dist/shortener.d.ts +5 -4
- package/dist/shortener.d.ts.map +1 -1
- package/dist/types.d.ts +129 -75
- package/dist/types.d.ts.map +1 -1
- package/package.json +11 -2
package/dist/core/answer.d.ts
CHANGED
|
@@ -95,6 +95,14 @@ export type TransformReply = (input: TransformReplyInput) => string | null | Pro
|
|
|
95
95
|
* Runs `transformReply` if configured. A throw/rejection is logged and the
|
|
96
96
|
* ORIGINAL text is returned — the delivery invariant: a bug in a plugin hook
|
|
97
97
|
* must never silently swallow an answer the model already produced.
|
|
98
|
+
*
|
|
99
|
+
* The result crosses the same plugin boundary `runAnswerFn` does, so it gets
|
|
100
|
+
* the same treatment: anything that isn't a string is coerced to `null`
|
|
101
|
+
* (treated as a veto) rather than passed through as whatever a
|
|
102
|
+
* non-conforming hook happened to return (`undefined` from a missing
|
|
103
|
+
* `return`, say). Every call site already treats a falsy result as "nothing
|
|
104
|
+
* delivered", but only a normalized `string | null` matches this function's
|
|
105
|
+
* own declared return type.
|
|
98
106
|
*/
|
|
99
107
|
export declare function applyTransformReply(transformReply: TransformReply | undefined, input: TransformReplyInput, logger?: Pick<Logger, "error">): Promise<string | null>;
|
|
100
108
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"answer.d.ts","sourceRoot":"","sources":["../../src/core/answer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAC;AAGjC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AACvC,OAAO,KAAK,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAEhE,gDAAgD;AAChD,MAAM,WAAW,WAAW;IAC1B,aAAa,EAAE,MAAM,CAAC;IACtB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,YAAY,EAAE,MAAM,CAAC;CACtB;AAKD,qEAAqE;AACrE,MAAM,WAAW,aAAa;IAC5B,uDAAuD;IACvD,MAAM,EAAE,MAAM,CAAC;IACf,4BAA4B;IAC5B,QAAQ,EAAE,eAAe,EAAE,CAAC;IAC5B,uCAAuC;IACvC,IAAI,EAAE,YAAY,CAAC;IACnB,mEAAmE;IACnE,MAAM,C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
|
|
2
|
+
* Single-writer lock around the destructive half of a knowledge-base build.
|
|
3
|
+
*
|
|
4
|
+
* `VectorStore.build()` is a read-diff-delete-insert sequence: it reads the
|
|
5
|
+
* chunk ids already in the database, computes the ids its own `knowledgeDir`
|
|
6
|
+
* produces, and deletes everything not in that set. Two instances booting
|
|
7
|
+
* against the same database at the same time (a rolling deploy, a manual
|
|
8
|
+
* deploy racing an automated one) each run that sequence against a view of
|
|
9
|
+
* the data the other is still mutating, so one boot's cleanup can delete
|
|
10
|
+
* chunks the other has just written or has not finished writing.
|
|
11
|
+
*
|
|
12
|
+
* The lock lives in the same database (`chatter_build_lock`) so it is visible
|
|
13
|
+
* to every instance, and acquiring or renewing it is a single atomic upsert
|
|
14
|
+
* (see `createTursoBuildLock`) - two instances racing the same key can never
|
|
15
|
+
* both believe they hold it. A holder that dies without releasing leaves a
|
|
16
|
+
* stale row instead of wedging every future boot: after `staleMs` with no
|
|
17
|
+
* heartbeat, the next instance may take it over.
|
|
18
|
+
*/
|
|
19
|
+
import type { Client } from "@libsql/client";
|
|
20
|
+
/** Lock key for the knowledge-base build. One build runs per database at a time. */
|
|
21
|
+
export declare const BUILD_LOCK_KEY = "knowledge_build";
|
|
22
|
+
/**
|
|
23
|
+
* A held lock this old with no heartbeat is treated as abandoned. Generous
|
|
24
|
+
* because a first build embeds every chunk it loads, which can take minutes;
|
|
25
|
+
* a holder renews the lock as it goes (see `VectorStore.build`), so only a
|
|
26
|
+
* process that actually died lets the lock go stale.
|
|
27
|
+
*/
|
|
28
|
+
export declare const BUILD_LOCK_STALE_MS: number;
|
|
29
|
+
export interface BuildLockRow {
|
|
30
|
+
holderId: string;
|
|
31
|
+
heartbeatAt: number;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Pure: may `holderId` take (or keep) the build lock right now, given the
|
|
35
|
+
* current row (null = never held)? Mirrors the SQL WHERE clause in
|
|
36
|
+
* `createTursoBuildLock` - keep the two in sync.
|
|
37
|
+
*/
|
|
38
|
+
export declare function canAcquireBuildLock(existing: BuildLockRow | null, holderId: string, now: number, staleMs?: number): boolean;
|
|
39
|
+
export interface BuildLock {
|
|
40
|
+
/** Atomically acquires or renews the lock; resolves true iff `holderId` now holds it. */
|
|
41
|
+
tryAcquire(key: string, holderId: string, now: number, staleMs: number): Promise<boolean>;
|
|
42
|
+
/** Releases the lock iff still held by `holderId` (no-op otherwise, so a late release never undoes a takeover). */
|
|
43
|
+
release(key: string, holderId: string): Promise<void>;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* A libsql-backed {@link BuildLock}. The WHERE clause on DO UPDATE encodes
|
|
47
|
+
* `canAcquireBuildLock`: SQLite skips the update (and RETURNING yields no
|
|
48
|
+
* row) when it is false, so a losing racer sees zero rows back - no separate
|
|
49
|
+
* read-then-write, no race window.
|
|
50
|
+
*/
|
|
51
|
+
export declare function createTursoBuildLock(client: Client): BuildLock;
|
|
52
|
+
//# sourceMappingURL=buildLock.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"buildLock.d.ts","sourceRoot":"","sources":["../../src/core/buildLock.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAE7C,oFAAoF;AACpF,eAAO,MAAM,cAAc,oBAAoB,CAAC;AAEhD;;;;;GAKG;AACH,eAAO,MAAM,mBAAmB,QAAc,CAAC;AAE/C,MAAM,WAAW,YAAY;IAC3B,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;CACrB;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,CACjC,QAAQ,EAAE,YAAY,GAAG,IAAI,EAC7B,QAAQ,EAAE,MAAM,EAChB,GAAG,EAAE,MAAM,EACX,OAAO,GAAE,MAA4B,GACpC,OAAO,CAIT;AAED,MAAM,WAAW,SAAS;IACxB,yFAAyF;IACzF,UAAU,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IAC1F,mHAAmH;IACnH,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACvD;AAwBD;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAyB9D"}
|
package/dist/core/pipeline.d.ts
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
*/
|
|
11
11
|
import type { Logger } from "./logger";
|
|
12
12
|
import type { PromptLoader } from "./prompts";
|
|
13
|
-
import type {
|
|
13
|
+
import type { Retriever } from "./retrieval";
|
|
14
14
|
export type PipelineMode = "public" | "private";
|
|
15
15
|
export interface PipelineMessage {
|
|
16
16
|
role: "user" | "assistant";
|
|
@@ -60,11 +60,43 @@ export interface RerankContextArgs {
|
|
|
60
60
|
* fails closed by design; use this hook for relevance/ordering only.
|
|
61
61
|
*/
|
|
62
62
|
export type RerankContext = (ctx: RerankContextArgs) => string[] | Promise<string[]>;
|
|
63
|
+
/** What `fallbackFn` sees for a turn where retrieval came back empty. */
|
|
64
|
+
export interface FallbackContext {
|
|
65
|
+
/** The query retrieval actually ran with, post-`rewriteQuery` if configured. */
|
|
66
|
+
query: string;
|
|
67
|
+
mode: PipelineMode;
|
|
68
|
+
/** Buckets retrieval ran against for this turn. */
|
|
69
|
+
buckets: string[];
|
|
70
|
+
/** Caller identity, where the surface has one. Absent on anonymous surfaces. */
|
|
71
|
+
sender?: string;
|
|
72
|
+
/**
|
|
73
|
+
* What `store.query` returned, before `rerankContext` ran: always
|
|
74
|
+
* non-empty when this is empty because `rerankContext` filtered
|
|
75
|
+
* everything out, and always empty when the store itself found nothing.
|
|
76
|
+
* A hook can use this to tell "some low-confidence signal existed" apart
|
|
77
|
+
* from "nothing matched at all".
|
|
78
|
+
*/
|
|
79
|
+
retrievedChunks: string[];
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Runs only when retrieval produced no chunks for a turn (after
|
|
83
|
+
* `rerankContext`, if configured), the deterministic, testable alternative
|
|
84
|
+
* to baking "what if there's nothing to retrieve" judgment calls into
|
|
85
|
+
* freeform system-prompt text. Return a string to inject as an extra system
|
|
86
|
+
* prompt layer scoped to this turn only (e.g. "no matching context was
|
|
87
|
+
* found; offer a clearly-labelled guess or decline"); return `undefined` to
|
|
88
|
+
* leave the prompt exactly as it would be otherwise.
|
|
89
|
+
*
|
|
90
|
+
* A throw/rejection is caught by `prepareChat`, which proceeds without
|
|
91
|
+
* fallback guidance: a broken hook must never break the chat path.
|
|
92
|
+
*/
|
|
93
|
+
export type FallbackFn = (ctx: FallbackContext) => string | undefined | Promise<string | undefined>;
|
|
63
94
|
/**
|
|
64
95
|
* Run retrieval for the latest user message and assemble the system prompt.
|
|
65
96
|
*
|
|
66
97
|
* The assembled system prompt is layered, in order:
|
|
67
|
-
* base rules → persona → channel hint (optional) →
|
|
98
|
+
* base rules → persona → channel hint (optional) → fallback guidance
|
|
99
|
+
* (optional, only when retrieval came back empty) → retrieved context.
|
|
68
100
|
*
|
|
69
101
|
* `personaLayer` and `channelHint` let a caller shape those middle layers
|
|
70
102
|
* without hand-rolling its own sandwich around `store`/`prompts`. Both are
|
|
@@ -83,10 +115,13 @@ export type RerankContext = (ctx: RerankContextArgs) => string[] | Promise<strin
|
|
|
83
115
|
* value falls back to what retrieval would have done unmodified, so a buggy
|
|
84
116
|
* hook degrades relevance rather than breaking the chat path.
|
|
85
117
|
*
|
|
118
|
+
* `fallbackFn` runs after both, only when the chunks folded into the prompt
|
|
119
|
+
* would otherwise be empty, see {@link FallbackFn}.
|
|
120
|
+
*
|
|
86
121
|
* @throws if the conversation contains no user message
|
|
87
122
|
*/
|
|
88
|
-
export declare function prepareChat({ store, prompts, mode, messages, personaLayer, channelHint, buckets, sender, rewriteQuery, rerankContext, logger, }: {
|
|
89
|
-
store:
|
|
123
|
+
export declare function prepareChat({ store, prompts, mode, messages, personaLayer, channelHint, buckets, sender, rewriteQuery, rerankContext, fallbackFn, logger, }: {
|
|
124
|
+
store: Retriever;
|
|
90
125
|
prompts: PromptLoader;
|
|
91
126
|
mode: PipelineMode;
|
|
92
127
|
messages: PipelineMessage[];
|
|
@@ -105,7 +140,9 @@ export declare function prepareChat({ store, prompts, mode, messages, personaLay
|
|
|
105
140
|
rewriteQuery?: RewriteQuery;
|
|
106
141
|
/** Post-processes retrieved chunks before they're folded into the prompt — see {@link RerankContext}. */
|
|
107
142
|
rerankContext?: RerankContext;
|
|
108
|
-
/**
|
|
143
|
+
/** Injects fallback guidance when retrieval comes back empty, see {@link FallbackFn}. */
|
|
144
|
+
fallbackFn?: FallbackFn;
|
|
145
|
+
/** Logs a `rewriteQuery`/`rerankContext`/`fallbackFn` throw before falling back. Unset: the failure is silent. */
|
|
109
146
|
logger?: Pick<Logger, "error">;
|
|
110
147
|
}): Promise<PreparedChat>;
|
|
111
148
|
//# sourceMappingURL=pipeline.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pipeline.d.ts","sourceRoot":"","sources":["../../src/core/pipeline.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAGH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAEvC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAC9C,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"pipeline.d.ts","sourceRoot":"","sources":["../../src/core/pipeline.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAGH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAEvC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAC9C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;A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,GAAG,CAAC,GAAG,EAAE,eAAe,KAAK,MAAM,GAAG,SAAS,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAAC;AAOpG;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,wBAAsB,WAAW,CAAC,EAChC,KAAK,EACL,OAAO,EACP,IAAI,EACJ,QAAQ,EACR,YAAY,EACZ,WAAW,EACX,OAAO,EACP,MAAM,EACN,YAAY,EACZ,aAAa,EACb,UAAU,EACV,MAAM,GACP,EAAE;IACD,KAAK,EAAE,SAAS,CAAC;IACjB,OAAO,EAAE,YAAY,CAAC;IACtB,IAAI,EAAE,YAAY,CAAC;IACnB,QAAQ,EAAE,eAAe,EAAE,CAAC;IAC5B,gEAAgE;IAChE,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,kEAAkE;IAClE,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,uFAAuF;IACvF,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,yFAAyF;IACzF,YAAY,CAAC,EAAE,YAAY,CAAC;IAC5B,yGAAyG;IACzG,aAAa,CAAC,EAAE,aAAa,CAAC;IAC9B,yFAAyF;IACzF,UAAU,CAAC,EAAE,UAAU,CAAC;IACxB,kHAAkH;IAClH,MAAM,CAAC,EAAE,IAAI,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAChC,GAAG,OAAO,CAAC,YAAY,CAAC,CA6DxB"}
|
package/dist/core/prompts.d.ts
CHANGED
|
@@ -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"}
|
package/dist/core/retrieval.d.ts
CHANGED
|
@@ -1,43 +1,118 @@
|
|
|
1
|
-
import {
|
|
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
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
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
|
|
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
|
-
*
|
|
33
|
-
*
|
|
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
|
-
|
|
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,
|
|
1
|
+
{"version":3,"file":"retrieval.d.ts","sourceRoot":"","sources":["../../src/core/retrieval.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,IAAI,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC7D,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAC;AACjC,OAAO,EAGL,KAAK,SAAS,EAEf,MAAM,aAAa,CAAC;AAErB,OAAO,EAAuB,KAAK,MAAM,EAAE,MAAM,UAAU,CAAC;AAI5D,kFAAkF;AAClF,eAAO,MAAM,qBAAqB,uBAAuB,CAAC;AAE1D;;;;;;;;GAQG;AACH,MAAM,W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CAAC,YAAY,CAAS;IAC7B,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,SAAS,CAAY;IAC7B,OAAO,CAAC,UAAU,CAAS;IAC3B,OAAO,CAAC,gBAAgB,CAAS;IAEjC,YACU,KAAK,EAAE,QAAQ,EACvB,OAAO,EAAE,kBAAkB,EAQ5B;IAED;;;;;;;;;;OAUG;IACG,KAAK,kBAyBV;IAED,0FAA0F;IAC1F,OAAO,CAAC,cAAc;IAStB,kEAAkE;YACpD,cAAc;YA8Gd,kBAAkB;IAqChC,OAAO,CAAC,MAAM,CAAC,MAAM;IAYrB;;;;;;;;;;OAUG;IACG,KAAK,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,SAAI,EAAE,OAAO,GAAE,MAAM,EAAa,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAuB7E;CACF"}
|
package/dist/core/session.d.ts
CHANGED
|
@@ -10,6 +10,14 @@ interface SessionData {
|
|
|
10
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;
|
|
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;AAED,qJAAqJ;AACrJ,eAAO,MAAM,kBAAkB,aAAa,CAAC;AAE7C,oFAAoF;AACpF,eAAO,MAAM,4BAA4B,KAAK,CAAC;AAE/C,oGAAoG;AACpG,eAAO,MAAM,2BAA2B,OAAO,CAAC;AAEhD,4DAA4D;AAC5D,eAAO,MAAM,yBAAyB,QAAgB,CAAC;AAavD,eAAO,MAAM,cAAc,gBAOE,CAAC;AAG9B,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,CAqB7E;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAoBpD;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,WAAW,GAAG,IAAI,CAE9D;AAED;;GAEG;AACH,wBAAgB,iBAAiB,IAAI,MAAM,CAE1C"}
|
package/dist/flows/index.d.ts
CHANGED
|
@@ -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;
|
|
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"}
|
package/dist/flows/index.js
CHANGED
|
@@ -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
|
-
|
|
166
|
-
|
|
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
|
-
|
|
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,
|
package/dist/flows/index.mjs
CHANGED
|
@@ -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
|
-
|
|
133
|
-
|
|
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
|
-
|
|
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,
|
package/dist/flows/intent.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* LLM-powered intent detection
|
|
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,
|
|
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"}
|
package/dist/flows/loader.d.ts
CHANGED
|
@@ -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).
|
|
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
|
|
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"}
|
package/dist/flows/params.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Schema-driven parameter extraction
|
|
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,
|
|
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"}
|
package/dist/flows/session.d.ts
CHANGED
|
@@ -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
|
|
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,
|
|
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"}
|
package/dist/flows/types.d.ts
CHANGED
|
@@ -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).
|
|
8
|
-
*
|
|
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
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/flows/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;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,cA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AE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,qFAAqF;AACrF,MAAM,WAAW,gBAAgB;IAC/B,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAChC,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;;;;GAKG;AACH,MAAM,WAAW,gBAAgB;IAC/B,GAAG,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,GAAG,IAAI,CAAC,CAAC;IAC1D,GAAG,CAAC,UAAU,EAAE,MAAM,EAAE,KAAK,EAAE,gBAAgB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAChE,KAAK,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,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"}
|
package/dist/history/index.d.ts
CHANGED
|
@@ -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;
|
|
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"}
|