@rudderjs/ai 1.18.2 → 1.18.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. package/README.md +16 -11
  2. package/dist/budget-orm/index.d.ts +95 -1
  3. package/dist/budget-orm/index.d.ts.map +1 -1
  4. package/dist/budget-orm/index.js +176 -4
  5. package/dist/budget-orm/index.js.map +1 -1
  6. package/dist/commands/ai-eval.d.ts +97 -1
  7. package/dist/commands/ai-eval.d.ts.map +1 -1
  8. package/dist/commands/ai-eval.js +379 -4
  9. package/dist/commands/ai-eval.js.map +1 -1
  10. package/dist/commands/make-agent.d.ts +2 -1
  11. package/dist/commands/make-agent.d.ts.map +1 -1
  12. package/dist/commands/make-agent.js +22 -4
  13. package/dist/commands/make-agent.js.map +1 -1
  14. package/dist/conversation-orm/index.d.ts +115 -1
  15. package/dist/conversation-orm/index.d.ts.map +1 -1
  16. package/dist/conversation-orm/index.js +214 -4
  17. package/dist/conversation-orm/index.js.map +1 -1
  18. package/dist/doctor.d.ts +1 -1
  19. package/dist/doctor.d.ts.map +1 -1
  20. package/dist/doctor.js +67 -4
  21. package/dist/doctor.js.map +1 -1
  22. package/dist/memory-embedding/index.d.ts +120 -1
  23. package/dist/memory-embedding/index.d.ts.map +1 -1
  24. package/dist/memory-embedding/index.js +228 -4
  25. package/dist/memory-embedding/index.js.map +1 -1
  26. package/dist/memory-orm/index.d.ts +117 -1
  27. package/dist/memory-orm/index.d.ts.map +1 -1
  28. package/dist/memory-orm/index.js +186 -4
  29. package/dist/memory-orm/index.js.map +1 -1
  30. package/dist/server/index.d.ts +1 -1
  31. package/dist/server/index.d.ts.map +1 -1
  32. package/dist/server/index.js +5 -4
  33. package/dist/server/index.js.map +1 -1
  34. package/dist/server/provider.d.ts +22 -0
  35. package/dist/server/provider.d.ts.map +1 -0
  36. package/dist/server/provider.js +179 -0
  37. package/dist/server/provider.js.map +1 -0
  38. package/package.json +12 -6
@@ -1,5 +1,380 @@
1
- // @rudderjs/ai is deprecated. The AI engine now lives in @gemstack/ai-sdk.
2
- // This module re-exports it for backwards compatibility; import from
3
- // '@gemstack/ai-sdk/commands/ai-eval' directly in new code.
4
- export * from '@gemstack/ai-sdk/commands/ai-eval';
1
+ /**
2
+ * `pnpm rudder ai:eval` discover `evals/**\/*.eval.ts` suites,
3
+ * run each, and report. Console reporter by default; `--json` emits
4
+ * a machine-readable envelope to stdout for CI.
5
+ *
6
+ * This is a Rudder CLI binding: it reads `config('ai')` via
7
+ * `@rudderjs/core` and registers onto the Rudder runner, so it lives
8
+ * on the Rudder side. The eval framework it drives (`runSuite`,
9
+ * reporters, fixtures) lives in the agnostic `@gemstack/ai-sdk/eval`.
10
+ *
11
+ * Registered from the CLI loader (`packages/cli/src/index.ts`)
12
+ * — the AiProvider doesn't own this so it surfaces even when the
13
+ * user app fails to boot, matching the `command:list --json`
14
+ * graceful-degradation pattern from #349.
15
+ */
16
+ import { readdir } from 'node:fs/promises';
17
+ import path from 'node:path';
18
+ import { pathToFileURL } from 'node:url';
19
+ import { runSuite, reportConsole, evalSuite, stepsFromResponse, reportJson, reportHtml, defaultFixturesDir, readFixture, writeFixture, } from '@gemstack/ai-sdk/eval';
20
+ import { AiFake } from '@gemstack/ai-sdk';
21
+ /** Register the `ai:eval` command on the rudder runner. */
22
+ export function registerAiEvalCommand(rudder) {
23
+ rudder.command('ai:eval', async (rawArgs) => {
24
+ const code = await runEvalCli(parseArgs(rawArgs));
25
+ if (code !== 0)
26
+ process.exit(code);
27
+ }).description('Run eval suites — pnpm rudder ai:eval [name-pattern] [--bail] [--json] [--record|--replay] [--html <path>]');
28
+ }
29
+ // ─── Args parser ─────────────────────────────────────────
30
+ const VALUE_FLAGS = new Set(['--html']);
31
+ /**
32
+ * Parse the rest-of-line. Recognizes:
33
+ * - boolean flags: `--bail`, `--json`, `--record`, `--replay`
34
+ * - value flags : `--html <path>` or `--html=<path>`
35
+ * - one positional name filter (anything not consumed above)
36
+ */
37
+ export function parseArgs(args) {
38
+ const positional = [];
39
+ const opts = { bail: false, json: false };
40
+ for (let i = 0; i < args.length; i++) {
41
+ const a = args[i];
42
+ if (!a.startsWith('--')) {
43
+ positional.push(a);
44
+ continue;
45
+ }
46
+ // `--flag=value` form
47
+ const eq = a.indexOf('=');
48
+ const name = eq >= 0 ? a.slice(0, eq) : a;
49
+ const inline = eq >= 0 ? a.slice(eq + 1) : undefined;
50
+ if (name === '--bail') {
51
+ opts.bail = true;
52
+ continue;
53
+ }
54
+ if (name === '--json') {
55
+ opts.json = true;
56
+ continue;
57
+ }
58
+ if (name === '--record') {
59
+ opts.record = true;
60
+ continue;
61
+ }
62
+ if (name === '--replay') {
63
+ opts.replay = true;
64
+ continue;
65
+ }
66
+ if (VALUE_FLAGS.has(name)) {
67
+ const value = inline ?? args[i + 1];
68
+ if (!inline)
69
+ i++; // consumed the next arg
70
+ if (!value)
71
+ throw new Error(`[ai:eval] ${name} requires a value`);
72
+ if (name === '--html')
73
+ opts.html = value;
74
+ continue;
75
+ }
76
+ // unknown flag — surface as positional so the user sees the typo
77
+ positional.push(a);
78
+ }
79
+ if (positional[0])
80
+ opts.filter = positional[0];
81
+ return opts;
82
+ }
83
+ // ─── Runner ──────────────────────────────────────────────
84
+ /**
85
+ * Execute the CLI flow. Returns the process exit code (0 = all pass,
86
+ * 1 = at least one suite had a failure or no suites discovered).
87
+ *
88
+ * The handler is `process.exit`-free so tests can drive it directly.
89
+ */
90
+ export async function runEvalCli(opts, deps = {}) {
91
+ const cwd = deps.cwd ?? process.cwd();
92
+ const stdout = deps.stdout ?? process.stdout;
93
+ const stderr = deps.stderr ?? process.stderr;
94
+ if (opts.record && opts.replay) {
95
+ stderr.write('[ai:eval] --record and --replay are mutually exclusive\n');
96
+ return 1;
97
+ }
98
+ const pattern = await Promise.resolve((deps.configPattern ?? loadConfigPattern)()) ?? 'evals/**/*.eval.ts';
99
+ const discover = deps.discover ?? discoverSuiteFiles;
100
+ const files = await discover(cwd, pattern);
101
+ if (files.length === 0) {
102
+ stderr.write(`[ai:eval] no suites found matching ${pattern}\n`);
103
+ return opts.json ? emitJson(stdout, []) : 1;
104
+ }
105
+ const loader = deps.loadSuite ?? defaultSuiteLoader;
106
+ const fixturesDir = deps.fixturesDir ?? defaultFixturesDir(cwd);
107
+ const reports = [];
108
+ const fullReports = [];
109
+ let exitCode = 0;
110
+ // `--replay` swaps the global runtime once, restored when we're done.
111
+ // The per-case fixture is set on the AiFake instance inside the
112
+ // wrapped agent factory just before each case's `agent.prompt()`.
113
+ let fake = null;
114
+ if (opts.replay)
115
+ fake = AiFake.fake();
116
+ try {
117
+ for (const file of files) {
118
+ let suite;
119
+ try {
120
+ suite = await loader(file);
121
+ }
122
+ catch (err) {
123
+ stderr.write(`[ai:eval] failed to load ${path.relative(cwd, file)}: ${formatError(err)}\n`);
124
+ exitCode = 1;
125
+ if (opts.bail)
126
+ break;
127
+ continue;
128
+ }
129
+ if (!suite) {
130
+ stderr.write(`[ai:eval] ${path.relative(cwd, file)} has no default eval suite — skipping\n`);
131
+ continue;
132
+ }
133
+ if (opts.filter && !suite.name.toLowerCase().includes(opts.filter.toLowerCase()))
134
+ continue;
135
+ const decorated = await decorateForMode(suite, opts, { fixturesDir, stderr, fake });
136
+ const report = await runSuite(decorated);
137
+ fullReports.push(report);
138
+ if (opts.json) {
139
+ reports.push(reportJson(report));
140
+ }
141
+ else {
142
+ reportConsole(report, { log: (s) => stdout.write(`${s}\n`) });
143
+ }
144
+ if (report.failed > 0) {
145
+ exitCode = 1;
146
+ if (opts.bail)
147
+ break;
148
+ }
149
+ }
150
+ }
151
+ finally {
152
+ if (fake)
153
+ fake.restore();
154
+ }
155
+ if (opts.json)
156
+ emitJson(stdout, reports);
157
+ if (opts.html)
158
+ await writeHtmlReport(opts.html, fullReports, cwd, stderr);
159
+ return exitCode;
160
+ }
161
+ async function writeHtmlReport(htmlPath, reports, cwd, stderr) {
162
+ const { writeFile, mkdir } = await import('node:fs/promises');
163
+ const abs = path.isAbsolute(htmlPath) ? htmlPath : path.resolve(cwd, htmlPath);
164
+ try {
165
+ await mkdir(path.dirname(abs), { recursive: true });
166
+ await writeFile(abs, reportHtml(reports));
167
+ stderr.write(`[ai:eval] wrote HTML report → ${path.relative(cwd, abs)}\n`);
168
+ }
169
+ catch (err) {
170
+ stderr.write(`[ai:eval] failed to write HTML report ${abs}: ${formatError(err)}\n`);
171
+ }
172
+ }
173
+ function emitJson(stdout, suites) {
174
+ stdout.write(`${JSON.stringify({ suites }, null, 2)}\n`);
175
+ return 0;
176
+ }
177
+ function formatError(err) {
178
+ return err instanceof Error ? err.message : String(err);
179
+ }
180
+ /**
181
+ * Wrap a suite so each case captures the response (`--record`) or
182
+ * pre-loads the fake's sequence (`--replay`) before running. A
183
+ * normal run returns the suite untouched.
184
+ *
185
+ * Implemented as a per-case `agent` / `assert` decoration so the
186
+ * runner stays unchanged — `runSuite` doesn't need to know about
187
+ * the fixture format. The original `agent`/`assert` for each case
188
+ * are still called; we just slip work in around them.
189
+ *
190
+ * For replay, fixtures load up-front (sync factory contract) so the
191
+ * AiFake is primed before each `agent.prompt()` runs.
192
+ */
193
+ async function decorateForMode(suite, opts, ctx) {
194
+ if (!opts.record && !opts.replay)
195
+ return suite;
196
+ // Pre-load every fixture for replay so the per-case factory can
197
+ // call `respondWithSequence` synchronously.
198
+ const replaySteps = new Map();
199
+ if (opts.replay) {
200
+ for (let i = 0; i < suite.spec.cases.length; i++) {
201
+ const c = suite.spec.cases[i];
202
+ const caseName = c.name ?? `case-${i}`;
203
+ try {
204
+ const fixture = await readFixture(ctx.fixturesDir, suite.name, caseName);
205
+ if (fixture)
206
+ replaySteps.set(caseName, fixture.steps);
207
+ else
208
+ ctx.stderr.write(`[ai:eval] no fixture for ${suite.name}/${caseName} — running against live provider\n`);
209
+ }
210
+ catch (err) {
211
+ ctx.stderr.write(`[ai:eval] fixture load error for ${suite.name}/${caseName}: ${formatError(err)}\n`);
212
+ }
213
+ }
214
+ }
215
+ const wrapped = suite.spec.cases.map((c, i) => {
216
+ const caseName = c.name ?? `case-${i}`;
217
+ const baseFactory = c.agent ?? suite.spec.agent;
218
+ const baseAssert = c.assert;
219
+ const factory = opts.replay
220
+ ? wrapReplayFactory(baseFactory, replaySteps.get(caseName), ctx.fake)
221
+ : baseFactory;
222
+ const assert = opts.record
223
+ ? wrapRecordAssert(baseAssert, suite.name, caseName, c.input, ctx)
224
+ : baseAssert;
225
+ const out = {
226
+ input: c.input,
227
+ assert,
228
+ agent: factory,
229
+ };
230
+ if (c.name)
231
+ out.name = c.name;
232
+ if (c.timeout !== undefined)
233
+ out.timeout = c.timeout;
234
+ if (c.skip !== undefined)
235
+ out.skip = c.skip;
236
+ return out;
237
+ });
238
+ const newSpec = {
239
+ agent: suite.spec.agent,
240
+ cases: wrapped,
241
+ };
242
+ if (suite.spec.timeout !== undefined)
243
+ newSpec.timeout = suite.spec.timeout;
244
+ return evalSuite(suite.name, newSpec);
245
+ }
246
+ /**
247
+ * Replay path: before each case runs, prime the shared `AiFake`
248
+ * with the case's recorded steps. When the fixture is missing the
249
+ * factory still returns the agent — it'll hit whatever the AiFake
250
+ * is currently scripted to return (typically falling back to the
251
+ * default ambient response, which surfaces as an obvious diff in
252
+ * the case's assertion).
253
+ */
254
+ function wrapReplayFactory(base, steps, fake) {
255
+ return () => {
256
+ if (fake && steps)
257
+ fake.respondWithSequence(steps);
258
+ return base();
259
+ };
260
+ }
261
+ /**
262
+ * Record path: after each case's assertion runs, capture the
263
+ * agent response's assistant turns to the fixture file. Wrapping
264
+ * the assert is the cleanest hook — the runner already passes
265
+ * `response` into it, and the wrapped fn still returns the
266
+ * original assertion's result.
267
+ */
268
+ function wrapRecordAssert(base, suite, caseName, input, ctx) {
269
+ return async (response, mctx) => {
270
+ try {
271
+ const file = await writeFixture(ctx.fixturesDir, suite, caseName, {
272
+ input,
273
+ steps: stepsFromResponse(response),
274
+ });
275
+ ctx.stderr.write(`[ai:eval] recorded ${path.relative(process.cwd(), file)}\n`);
276
+ }
277
+ catch (err) {
278
+ ctx.stderr.write(`[ai:eval] failed to record ${suite}/${caseName}: ${formatError(err)}\n`);
279
+ }
280
+ return base(response, mctx);
281
+ };
282
+ }
283
+ // ─── File discovery ──────────────────────────────────────
284
+ /**
285
+ * Recursive walk constrained to a `<dir>/**\/*<suffix>` shape.
286
+ * Returns absolute paths sorted lexicographically for stable test
287
+ * output and predictable `--bail` ordering.
288
+ */
289
+ export async function discoverSuiteFiles(cwd, pattern) {
290
+ const { root, suffix } = parsePattern(pattern);
291
+ const absRoot = path.resolve(cwd, root);
292
+ const out = [];
293
+ await walk(absRoot, suffix, out);
294
+ return out.sort();
295
+ }
296
+ /**
297
+ * Tiny pattern parser — supports `<dir>/**\/*<suffix>` and bare
298
+ * `*<suffix>` (current directory). Anything more elaborate is
299
+ * deferred to userland (run a custom script that imports `runSuite`).
300
+ *
301
+ * Examples:
302
+ * `evals/**\/*.eval.ts` → root=`evals`, suffix=`.eval.ts`
303
+ * `tests/agents/**\/*.ts` → root=`tests/agents`, suffix=`.ts`
304
+ * `*.eval.ts` → root=`.`, suffix=`.eval.ts`
305
+ */
306
+ function parsePattern(pattern) {
307
+ const doubleStar = pattern.indexOf('**');
308
+ let prefix;
309
+ let postfix;
310
+ if (doubleStar >= 0) {
311
+ prefix = pattern.slice(0, doubleStar).replace(/\/$/, '');
312
+ postfix = pattern.slice(doubleStar + 2).replace(/^\//, '');
313
+ }
314
+ else {
315
+ const lastSlash = pattern.lastIndexOf('/');
316
+ prefix = lastSlash >= 0 ? pattern.slice(0, lastSlash) : '';
317
+ postfix = lastSlash >= 0 ? pattern.slice(lastSlash + 1) : pattern;
318
+ }
319
+ if (!postfix.startsWith('*')) {
320
+ throw new Error(`[ai:eval] Unsupported eval pattern "${pattern}". ` +
321
+ `Expected <dir>/**/*<suffix> or *<suffix>.`);
322
+ }
323
+ return {
324
+ root: prefix || '.',
325
+ suffix: postfix.slice(1),
326
+ };
327
+ }
328
+ async function walk(dir, suffix, out) {
329
+ let entries;
330
+ try {
331
+ entries = await readdir(dir, { withFileTypes: true });
332
+ }
333
+ catch (err) {
334
+ if (err.code === 'ENOENT')
335
+ return;
336
+ throw err;
337
+ }
338
+ for (const entry of entries) {
339
+ const p = path.join(dir, entry.name);
340
+ if (entry.isDirectory()) {
341
+ if (entry.name === 'node_modules' || entry.name.startsWith('.'))
342
+ continue;
343
+ await walk(p, suffix, out);
344
+ }
345
+ else if (entry.isFile() && entry.name.endsWith(suffix)) {
346
+ out.push(p);
347
+ }
348
+ }
349
+ }
350
+ // ─── Suite loader ────────────────────────────────────────
351
+ async function defaultSuiteLoader(file) {
352
+ const mod = await import(pathToFileURL(file).href);
353
+ const candidate = (mod['default'] ?? mod['suite']);
354
+ if (!candidate || typeof candidate.name !== 'string' || !candidate.spec)
355
+ return null;
356
+ return candidate;
357
+ }
358
+ // ─── Config lookup ───────────────────────────────────────
359
+ /**
360
+ * Read `config('ai').eval.pattern` from the booted app. Returns
361
+ * `null` (default pattern) when `@rudderjs/core` isn't loadable
362
+ * or the app didn't boot — the CLI must still work in
363
+ * introspective mode (#349).
364
+ */
365
+ async function loadConfigPattern() {
366
+ try {
367
+ // Dynamic import so the static graph doesn't pin `@rudderjs/core`
368
+ // (optional peer). Falls back to default when core isn't loadable
369
+ // or the app didn't boot.
370
+ const core = await import('@rudderjs/core');
371
+ if (typeof core.config !== 'function')
372
+ return null;
373
+ const cfg = core.config('ai');
374
+ return cfg?.eval?.pattern ?? null;
375
+ }
376
+ catch {
377
+ return null;
378
+ }
379
+ }
5
380
  //# sourceMappingURL=ai-eval.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ai-eval.js","sourceRoot":"","sources":["../../src/commands/ai-eval.ts"],"names":[],"mappings":"AAAA,2EAA2E;AAC3E,qEAAqE;AACrE,4DAA4D;AAC5D,cAAc,mCAAmC,CAAA"}
1
+ {"version":3,"file":"ai-eval.js","sourceRoot":"","sources":["../../src/commands/ai-eval.ts"],"names":[],"mappings":"AA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D,MAAM,GAAG,GAAG,IAAI,CAAC,MAAM,CAA8C,IAAI,CAAC,CAAA;QAC1E,OAAO,GAAG,EAAE,IAAI,EAAE,OAAO,IAAI,IAAI,CAAA;IACnC,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAA;IACb,CAAC;AACH,CAAC"}
@@ -1,2 +1,3 @@
1
- export * from '@gemstack/ai-sdk/commands/make-agent';
1
+ import type { MakeSpec } from '@rudderjs/console';
2
+ export declare const makeAgentSpec: MakeSpec;
2
3
  //# sourceMappingURL=make-agent.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"make-agent.d.ts","sourceRoot":"","sources":["../../src/commands/make-agent.ts"],"names":[],"mappings":"AAGA,cAAc,sCAAsC,CAAA"}
1
+ {"version":3,"file":"make-agent.d.ts","sourceRoot":"","sources":["../../src/commands/make-agent.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAEjD,eAAO,MAAM,aAAa,EAAE,QAqB3B,CAAA"}
@@ -1,5 +1,23 @@
1
- // @rudderjs/ai is deprecated. The AI engine now lives in @gemstack/ai-sdk.
2
- // This module re-exports it for backwards compatibility; import from
3
- // '@gemstack/ai-sdk/commands/make-agent' directly in new code.
4
- export * from '@gemstack/ai-sdk/commands/make-agent';
1
+ export const makeAgentSpec = {
2
+ command: 'make:agent',
3
+ description: 'Create a new AI agent class',
4
+ label: 'Agent created',
5
+ suffix: 'Agent',
6
+ directory: 'app/Agents',
7
+ stub: (className) => `import { Agent } from '@gemstack/ai-sdk'
8
+ import type { HasTools, AnyTool } from '@gemstack/ai-sdk'
9
+
10
+ export class ${className} extends Agent implements HasTools {
11
+ instructions(): string {
12
+ return 'You are a helpful assistant.'
13
+ }
14
+
15
+ // model(): string | undefined { return 'anthropic/claude-sonnet-4-5' }
16
+
17
+ tools(): AnyTool[] {
18
+ return []
19
+ }
20
+ }
21
+ `,
22
+ };
5
23
  //# sourceMappingURL=make-agent.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"make-agent.js","sourceRoot":"","sources":["../../src/commands/make-agent.ts"],"names":[],"mappings":"AAAA,2EAA2E;AAC3E,qEAAqE;AACrE,+DAA+D;AAC/D,cAAc,sCAAsC,CAAA"}
1
+ {"version":3,"file":"make-agent.js","sourceRoot":"","sources":["../../src/commands/make-agent.ts"],"names":[],"mappings":"AAMA,MAAM,CAAC,MAAM,aAAa,GAAa;IACrC,OAAO,EAAM,YAAY;IACzB,WAAW,EAAE,6BAA6B;IAC1C,KAAK,EAAQ,eAAe;IAC5B,MAAM,EAAO,OAAO;IACpB,SAAS,EAAI,YAAY;IACzB,IAAI,EAAE,CAAC,SAAS,EAAE,EAAE,CAAC;;;eAGR,SAAS;;;;;;;;;;;CAWvB;CACA,CAAA"}
@@ -1,2 +1,116 @@
1
- export * from '@gemstack/ai-sdk/conversation-orm';
1
+ /**
2
+ * `@rudderjs/ai/conversation-orm` - ORM-backed {@link ConversationStore}.
3
+ *
4
+ * Production-grade replacement for `MemoryConversationStore` (which is
5
+ * single-process, in-memory, and loses every thread on restart). Persists
6
+ * conversation threads and their messages via the registered `@rudderjs/orm`
7
+ * adapter - works across web processes, queue workers, and horizontally
8
+ * scaled deployments. Mirrors the `@rudderjs/ai/memory-orm` /
9
+ * `@rudderjs/ai/budget-orm` pattern.
10
+ *
11
+ * Wire it as the conversation store:
12
+ *
13
+ * ```ts
14
+ * import { setConversationStore } from '@gemstack/ai-sdk'
15
+ * import { OrmConversationStore } from '@rudderjs/ai/conversation-orm'
16
+ *
17
+ * setConversationStore(new OrmConversationStore())
18
+ * ```
19
+ *
20
+ * The schema lives at {@link conversationOrmPrismaSchema} - copy it into your
21
+ * Prisma schema (or a new `prisma/schema/<file>.prisma` if you use the
22
+ * multi-file setup). On the native engine, add an equivalent migration; on
23
+ * Drizzle, define matching tables and register them via `tables: { ... }`.
24
+ *
25
+ * # Adapter coverage
26
+ *
27
+ * - Prisma - works out of the box; copy {@link conversationOrmPrismaSchema}.
28
+ * - Native - add a migration with the same columns.
29
+ * - Drizzle - define the two tables and register them on the `drizzle()`
30
+ * config.
31
+ *
32
+ * # Ordering & concurrency
33
+ *
34
+ * Messages carry a monotonic per-thread `position` so `load()` returns them
35
+ * in append order regardless of timestamp granularity. `append()` reads the
36
+ * current max position and assigns the next slots; like
37
+ * `OrmBudgetStorage.checkAndDebit`, the read-then-write is not isolated, so
38
+ * two concurrent appends to the SAME thread could collide on a position.
39
+ * Conversation threads are single-writer in practice (one user, one turn at
40
+ * a time), so this is a non-issue for typical apps. File an issue if you hit
41
+ * it; strict ordering needs a serializable transaction or a DB sequence.
42
+ */
43
+ import { Model } from '@rudderjs/orm';
44
+ import type { AiMessage, ConversationStore, ConversationStoreMeta } from '@gemstack/ai-sdk';
45
+ /**
46
+ * Entry shape returned by {@link ConversationStore.list}. Derived from the
47
+ * engine's exported `ConversationStore` interface so it stays in lockstep
48
+ * without depending on the type being exported by name.
49
+ */
50
+ type ConversationStoreListEntry = Awaited<ReturnType<ConversationStore['list']>>[number];
51
+ /**
52
+ * The thread row backing {@link OrmConversationStore}. Exposed so apps that
53
+ * want their own queries (admin views, analytics) can use
54
+ * `AiConversationRecord.where(...).get()` directly.
55
+ *
56
+ * `userId` / `agent` mirror {@link ConversationStoreMeta} - `userId` scopes
57
+ * `list()`, `agent` carries the thread-segregation key the auto-persist
58
+ * machinery uses to keep one user's threads per agent class apart.
59
+ */
60
+ export declare class AiConversationRecord extends Model {
61
+ static table: string;
62
+ static fillable: string[];
63
+ id: string;
64
+ title: string;
65
+ userId: string | null;
66
+ agent: string | null;
67
+ createdAt: Date;
68
+ updatedAt: Date | null;
69
+ }
70
+ /**
71
+ * One message row in a thread. `content` and `toolCalls` are JSON-encoded
72
+ * strings (so a `string` content and a `ContentPart[]` content both
73
+ * round-trip through a portable `text` column); `position` orders them.
74
+ */
75
+ export declare class AiConversationMessageRecord extends Model {
76
+ static table: string;
77
+ static fillable: string[];
78
+ id: string;
79
+ conversationId: string;
80
+ position: number;
81
+ role: string;
82
+ /** JSON-encoded `string | ContentPart[]`. */
83
+ content: string;
84
+ toolCallId: string | null;
85
+ /** JSON-encoded `ToolCall[]` or null. */
86
+ toolCalls: string | null;
87
+ createdAt: Date;
88
+ }
89
+ /**
90
+ * {@link ConversationStore} implementation that persists rows to the
91
+ * registered ORM adapter. Designed for production use - the in-process
92
+ * `MemoryConversationStore` is for tests and dev.
93
+ */
94
+ export declare class OrmConversationStore implements ConversationStore {
95
+ create(title?: string, meta?: ConversationStoreMeta): Promise<string>;
96
+ load(conversationId: string): Promise<AiMessage[]>;
97
+ append(conversationId: string, messages: AiMessage[]): Promise<void>;
98
+ setTitle(conversationId: string, title: string): Promise<void>;
99
+ list(userId?: string): Promise<ConversationStoreListEntry[]>;
100
+ delete(conversationId: string): Promise<void>;
101
+ /** Throw the same not-found error shape as `MemoryConversationStore`. */
102
+ private requireThread;
103
+ /** Next monotonic position for the thread (0 when empty). */
104
+ private nextPosition;
105
+ }
106
+ /** Convenience factory mirroring `ormBudgetStorage()` / `OrmUserMemory`. */
107
+ export declare function ormConversationStore(): OrmConversationStore;
108
+ /**
109
+ * Reference Prisma schema for `OrmConversationStore`. Copy into your
110
+ * `prisma/schema/<file>.prisma`. SQLite stores the `text` content as TEXT;
111
+ * Postgres as `text`. The `@@index` keeps `list()` (by user) and `load()`
112
+ * (by thread, ordered) cheap.
113
+ */
114
+ export declare const conversationOrmPrismaSchema = "model AiConversation {\n id String @id @default(cuid())\n title String\n userId String?\n /// Thread-segregation key - the agent class name by default\n agent String?\n createdAt DateTime @default(now())\n updatedAt DateTime @updatedAt\n\n @@index([userId])\n}\n\nmodel AiConversationMessage {\n id String @id @default(cuid())\n conversationId String\n /// Monotonic per-thread ordering\n position Int\n role String\n /// JSON-encoded `string | ContentPart[]`\n content String\n toolCallId String?\n /// JSON-encoded `ToolCall[]` or null\n toolCalls String?\n createdAt DateTime @default(now())\n\n @@index([conversationId, position])\n}\n";
115
+ export {};
2
116
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/conversation-orm/index.ts"],"names":[],"mappings":"AAGA,cAAc,mCAAmC,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/conversation-orm/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AAEH,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAA;AAErC,OAAO,KAAK,EACV,SAAS,EACT,iBAAiB,EACjB,qBAAqB,EAEtB,MAAM,kBAAkB,CAAA;AAEzB;;;;GAIG;AACH,KAAK,0BAA0B,GAAG,OAAO,CAAC,UAAU,CAAC,iBAAiB,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAA;AAIxF;;;;;;;;GAQG;AACH,qBAAa,oBAAqB,SAAQ,KAAK;IAC7C,OAAgB,KAAK,SAAsB;IAC3C,OAAgB,QAAQ,WAA4C;IAE5D,EAAE,EAAS,MAAM,CAAA;IACjB,KAAK,EAAM,MAAM,CAAA;IACjB,MAAM,EAAK,MAAM,GAAG,IAAI,CAAA;IACxB,KAAK,EAAM,MAAM,GAAG,IAAI,CAAA;IACxB,SAAS,EAAE,IAAI,CAAA;IACf,SAAS,EAAE,IAAI,GAAG,IAAI,CAAA;CAC/B;AAED;;;;GAIG;AACH,qBAAa,2BAA4B,SAAQ,KAAK;IACpD,OAAgB,KAAK,SAA6B;IAClD,OAAgB,QAAQ,WAA+E;IAE/F,EAAE,EAAc,MAAM,CAAA;IACtB,cAAc,EAAE,MAAM,CAAA;IACtB,QAAQ,EAAQ,MAAM,CAAA;IACtB,IAAI,EAAY,MAAM,CAAA;IAC9B,6CAA6C;IACrC,OAAO,EAAS,MAAM,CAAA;IACtB,UAAU,EAAM,MAAM,GAAG,IAAI,CAAA;IACrC,yCAAyC;IACjC,SAAS,EAAO,MAAM,GAA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