@rudderjs/ai 1.18.3 → 1.18.5

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 CHANGED
@@ -1,29 +1,34 @@
1
1
  # @rudderjs/ai
2
2
 
3
- > Deprecated. The AI engine moved to [`@gemstack/ai-sdk`](https://www.npmjs.com/package/@gemstack/ai-sdk).
3
+ > The AI engine moved to [`@gemstack/ai-sdk`](https://www.npmjs.com/package/@gemstack/ai-sdk). This package re-exports the engine for backwards compatibility **and** is the home of the Rudder-specific AI bindings that intentionally did not graduate to the framework-agnostic engine.
4
4
 
5
- This package is now a thin compatibility shim that re-exports `@gemstack/ai-sdk` (and every one of its subpaths) so existing Rudder apps and the internal dependents (`telescope`, `orm-prisma`, `orm-drizzle`) keep working unchanged.
5
+ ## Two kinds of module here
6
6
 
7
- ## Migrate
8
-
9
- Replace the import specifier; the API is identical.
7
+ **1. Re-exported engine subpaths** — thin `export *` over `@gemstack/ai-sdk`. Migrate these by swapping the specifier; the API is identical.
10
8
 
11
9
  ```diff
12
10
  - import { Agent } from '@rudderjs/ai'
13
11
  + import { Agent } from '@gemstack/ai-sdk'
14
12
  ```
15
13
 
16
- Subpaths map one to one:
17
-
18
- | Old | New |
14
+ | `@rudderjs/ai` subpath | `@gemstack/ai-sdk` equivalent |
19
15
  |---|---|
20
16
  | `@rudderjs/ai` | `@gemstack/ai-sdk` |
21
- | `@rudderjs/ai/server` | `@gemstack/ai-sdk/server` |
22
17
  | `@rudderjs/ai/node` | `@gemstack/ai-sdk/node` |
23
18
  | `@rudderjs/ai/mcp` | `@gemstack/ai-sdk/mcp` |
24
19
  | `@rudderjs/ai/eval` | `@gemstack/ai-sdk/eval` |
25
20
  | `@rudderjs/ai/computer-use` | `@gemstack/ai-sdk/computer-use` |
26
21
  | `@rudderjs/ai/react` | `@gemstack/ai-sdk/react` |
27
- | `@rudderjs/ai/*` | `@gemstack/ai-sdk/*` |
22
+ | `@rudderjs/ai/observers`, `/chat-mentions`, `/gateway` | same subpath on `@gemstack/ai-sdk` |
23
+
24
+ **2. Rudder bindings** — real implementations that couple the agnostic engine to a Rudder package, so they live here (no `@gemstack/ai-sdk` equivalent). Keep importing them from `@rudderjs/ai`:
25
+
26
+ | Subpath | Couples to | What it is |
27
+ |---|---|---|
28
+ | `@rudderjs/ai/server` | `@rudderjs/core` | `AiProvider` — reads `config('ai')`, wires providers/stores into the container |
29
+ | `@rudderjs/ai/commands/make-agent` | `@rudderjs/console` | `make:agent` scaffolder spec |
30
+ | `@rudderjs/ai/commands/ai-eval` | `@rudderjs/core` | `ai:eval` CLI command (discovers + runs eval suites) |
31
+ | `@rudderjs/ai/doctor` | `@rudderjs/console` | `ai:provider-keys` doctor check |
32
+ | `@rudderjs/ai/{conversation,memory,budget}-orm`, `/memory-embedding` | `@rudderjs/orm` | ORM-backed stores implementing the engine's neutral contracts |
28
33
 
29
- See the `@gemstack/ai-sdk` README for full documentation.
34
+ See the `@gemstack/ai-sdk` README for full engine documentation.
@@ -1,2 +1,98 @@
1
- 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 type { EvalSuite } from '@gemstack/ai-sdk/eval';
17
+ type Rudder = {
18
+ command(name: string, handler: (args: string[]) => void | Promise<void>): {
19
+ description(text: string): unknown;
20
+ };
21
+ };
22
+ /** CLI flags + positional name filter. */
23
+ export interface AiEvalOptions {
24
+ /** Substring filter (case-insensitive) applied to suite names. */
25
+ filter?: string;
26
+ /** Stop on the first failing suite. */
27
+ bail: boolean;
28
+ /** Emit `{ suites: [...] }` JSON to stdout. */
29
+ json: boolean;
30
+ /**
31
+ * Run against the real provider, capture each case's assistant
32
+ * turns to `evals/__fixtures__/<suite>/<case>.json`. Existing
33
+ * fixtures are overwritten — diff in your VCS to see what changed.
34
+ * Default `false`.
35
+ */
36
+ record?: boolean;
37
+ /**
38
+ * Swap the runtime with `AiFake.fake()` and feed each case its
39
+ * recorded fixture via `respondWithSequence`. Zero API calls,
40
+ * deterministic regression tests. Cases without a fixture fall
41
+ * through to a normal run with a stderr warning. Default `false`.
42
+ */
43
+ replay?: boolean;
44
+ /**
45
+ * Path for a self-contained HTML report (#A5 Phase 5). Pasteable
46
+ * into PR comments / Slack threads. Coexists with `--json` (JSON
47
+ * still goes to stdout, HTML goes to disk).
48
+ */
49
+ html?: string;
50
+ }
51
+ /**
52
+ * Test seam — every external dependency gets an injectable
53
+ * override. The CLI handler defaults each to its real impl.
54
+ */
55
+ export interface AiEvalDeps {
56
+ cwd?: string;
57
+ stdout?: {
58
+ write(s: string): boolean | void;
59
+ };
60
+ stderr?: {
61
+ write(s: string): boolean | void;
62
+ };
63
+ /** Override the file walk (test harness returns a virtual list). */
64
+ discover?: (cwd: string, pattern: string) => Promise<string[]>;
65
+ /** Override file → suite loader (test harness uses an in-memory map). */
66
+ loadSuite?: (absPath: string) => Promise<EvalSuite | null>;
67
+ /** Override config lookup (test harness skips `@rudderjs/core`). */
68
+ configPattern?: () => string | null | Promise<string | null>;
69
+ /**
70
+ * Override fixtures directory (defaults to `<cwd>/evals/__fixtures__`).
71
+ * Tests point to a tmpdir to keep round-trips off the source tree.
72
+ */
73
+ fixturesDir?: string;
74
+ }
75
+ /** Register the `ai:eval` command on the rudder runner. */
76
+ export declare function registerAiEvalCommand(rudder: Rudder): void;
77
+ /**
78
+ * Parse the rest-of-line. Recognizes:
79
+ * - boolean flags: `--bail`, `--json`, `--record`, `--replay`
80
+ * - value flags : `--html <path>` or `--html=<path>`
81
+ * - one positional name filter (anything not consumed above)
82
+ */
83
+ export declare function parseArgs(args: string[]): AiEvalOptions;
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 declare function runEvalCli(opts: AiEvalOptions, deps?: AiEvalDeps): Promise<number>;
91
+ /**
92
+ * Recursive walk constrained to a `<dir>/**\/*<suffix>` shape.
93
+ * Returns absolute paths sorted lexicographically for stable test
94
+ * output and predictable `--bail` ordering.
95
+ */
96
+ export declare function discoverSuiteFiles(cwd: string, pattern: string): Promise<string[]>;
97
+ export {};
2
98
  //# sourceMappingURL=ai-eval.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ai-eval.d.ts","sourceRoot":"","sources":["../../src/commands/ai-eval.ts"],"names":[],"mappings":"AAGA,cAAc,mCAAmC,CAAA"}
1
+ {"version":3,"file":"ai-eval.d.ts","sourceRoot":"","sources":["../../src/commands/ai-eval.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAgBH,OAAO,KAAK,EAAE,SAAS,EAA4C,MAAM,uBAAuB,CAAA;AAQhG,KAAK,MAAM,GAAG;IACZ,OAAO,CACL,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,GAChD;QAAE,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAA;KAAE,CAAA;CAC1C,CAAA;AAED,0CAA0C;AAC1C,MAAM,WAAW,aAAa;IAC5B,kEAAkE;IAClE,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,uCAAuC;IACvC,IAAI,EAAK,OAAO,CAAA;IACh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MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAMxF"}
@@ -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,CAA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CAAA;QAC3F,IAAI,OAAO,IAAI,CAAC,MAAM,KAAK,UAAU;YAAE,OAAO,IAAI,CAAA;QAClD,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,2 @@
1
- export * from '@gemstack/ai-sdk/server';
1
+ export { AiProvider } from './provider.js';
2
2
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/server/index.ts"],"names":[],"mappings":"AAGA,cAAc,yBAAyB,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/server/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA"}
@@ -1,5 +1,6 @@
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/server' directly in new code.
4
- export * from '@gemstack/ai-sdk/server';
1
+ // `@rudderjs/ai/server` the Rudder `ServiceProvider` binding for the AI
2
+ // engine. The engine itself lives in `@gemstack/ai-sdk`; this provider reads
3
+ // `config('ai')` and wires the engine into the Rudder container, so it lives
4
+ // on the Rudder side rather than in the framework-agnostic engine.
5
+ export { AiProvider } from './provider.js';
5
6
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/server/index.ts"],"names":[],"mappings":"AAAA,2EAA2E;AAC3E,qEAAqE;AACrE,kDAAkD;AAClD,cAAc,yBAAyB,CAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/server/index.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAC1E,6EAA6E;AAC7E,6EAA6E;AAC7E,mEAAmE;AACnE,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA"}
@@ -0,0 +1,31 @@
1
+ import { ServiceProvider } from '@rudderjs/core';
2
+ /**
3
+ * AI ServiceProvider — reads config from `config('ai')`.
4
+ *
5
+ * @example
6
+ * // bootstrap/providers.ts
7
+ * import { AiProvider } from '@rudderjs/ai/server'
8
+ * export default [AiProvider, ...]
9
+ */
10
+ export declare class AiProvider extends ServiceProvider {
11
+ register(): void;
12
+ boot(): Promise<void>;
13
+ /**
14
+ * Back the engine's `agent.queue('...').send()` / `.broadcast(channel)` with
15
+ * Rudder's queue and broadcast. Both are optional: when `@rudderjs/queue` is
16
+ * installed, queued AI jobs dispatch through it; when `@rudderjs/broadcast` is
17
+ * also installed, streaming jobs push progress to a channel. When neither is
18
+ * present the engine stays unconfigured and `agent.queue()` surfaces its
19
+ * "register a queue adapter" error at the use-site.
20
+ */
21
+ private configureQueueBridge;
22
+ /**
23
+ * Build a `GoogleCacheRegistry` for Gemini's `cachedContent` resources.
24
+ * When `@rudderjs/cache` is installed and booted, the registered cache
25
+ * adapter is plumbed in for cross-process / cross-restart persistence.
26
+ * Otherwise the registry uses an in-process `Map` and warns once on
27
+ * first use.
28
+ */
29
+ private buildGoogleCacheRegistry;
30
+ }
31
+ //# sourceMappingURL=provider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../../src/server/provider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAsB,MAAM,gBAAgB,CAAA;AA0HpE;;;;;;;GAOG;AACH,qBAAa,UAAW,SAAQ,eAAe;IAC7C,QAAQ,IAAI,IAAI;IAEV,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IA+C3B;;;;;;;OAOG;YACW,oBAAoB;IAelC;;;;;;OAMG;IACH,OAAO,CAAC,wBAAwB;CAOjC"}
@@ -0,0 +1,204 @@
1
+ import { ServiceProvider, config, bootNotice } from '@rudderjs/core';
2
+ import { AiRegistry, setConversationStore, setUserMemory, configureAiQueue, GoogleCacheRegistry, AnthropicProvider, OpenAIProvider, GoogleProvider, OllamaProvider, DeepSeekProvider, XaiProvider, GroqProvider, MistralProvider, AzureOpenAIProvider, OpenRouterProvider, BedrockProvider, ElevenLabsProvider, VoyageProvider, } from '@gemstack/ai-sdk';
3
+ /**
4
+ * Return the configured `apiKey`, or `null` when missing/empty.
5
+ *
6
+ * The config type lets `apiKey` be undefined (some drivers — ollama, bedrock —
7
+ * don't need one), so apiKey-requiring drivers use this gate. When the gate
8
+ * returns `null` the driver factory bails to `null` and `AiProvider.boot()`
9
+ * skips the provider with a warning instead of crashing — matches Laravel's
10
+ * "drivers as data, missing credentials don't kill the framework" pattern.
11
+ *
12
+ * Use-site (`AI.use('anthropic')`) will surface the standard
13
+ * "provider not registered" error so debugging stays actionable.
14
+ */
15
+ function requireKey(_name, cfg) {
16
+ return cfg.apiKey || null;
17
+ }
18
+ const DRIVERS = {
19
+ anthropic: (name, cfg) => {
20
+ const apiKey = requireKey(name, cfg);
21
+ if (apiKey === null)
22
+ return null;
23
+ return new AnthropicProvider({ apiKey, baseUrl: cfg.baseUrl });
24
+ },
25
+ openai: (name, cfg) => {
26
+ const apiKey = requireKey(name, cfg);
27
+ if (apiKey === null)
28
+ return null;
29
+ return new OpenAIProvider({
30
+ apiKey,
31
+ baseUrl: cfg.baseUrl,
32
+ organization: cfg['organization'],
33
+ });
34
+ },
35
+ google: (name, cfg, { googleCacheRegistry }) => {
36
+ const apiKey = requireKey(name, cfg);
37
+ if (apiKey === null)
38
+ return null;
39
+ return new GoogleProvider({ apiKey }, googleCacheRegistry);
40
+ },
41
+ ollama: (_name, cfg) => {
42
+ return new OllamaProvider({ baseUrl: cfg.baseUrl });
43
+ },
44
+ deepseek: (name, cfg) => {
45
+ const apiKey = requireKey(name, cfg);
46
+ if (apiKey === null)
47
+ return null;
48
+ return new DeepSeekProvider({ apiKey, baseUrl: cfg.baseUrl });
49
+ },
50
+ xai: (name, cfg) => {
51
+ const apiKey = requireKey(name, cfg);
52
+ if (apiKey === null)
53
+ return null;
54
+ return new XaiProvider({ apiKey, baseUrl: cfg.baseUrl });
55
+ },
56
+ groq: (name, cfg) => {
57
+ const apiKey = requireKey(name, cfg);
58
+ if (apiKey === null)
59
+ return null;
60
+ return new GroqProvider({ apiKey, baseUrl: cfg.baseUrl });
61
+ },
62
+ mistral: (name, cfg) => {
63
+ const apiKey = requireKey(name, cfg);
64
+ if (apiKey === null)
65
+ return null;
66
+ return new MistralProvider({ apiKey, baseUrl: cfg.baseUrl });
67
+ },
68
+ azure: (name, cfg) => {
69
+ const apiKey = requireKey(name, cfg);
70
+ if (apiKey === null)
71
+ return null;
72
+ if (!cfg.baseUrl) {
73
+ throw new Error(`[ai-sdk] config('ai').providers.${name} is missing baseUrl (driver "azure" requires it).`);
74
+ }
75
+ return new AzureOpenAIProvider({ apiKey, baseUrl: cfg.baseUrl });
76
+ },
77
+ openrouter: (name, cfg) => {
78
+ const apiKey = requireKey(name, cfg);
79
+ if (apiKey === null)
80
+ return null;
81
+ return new OpenRouterProvider({
82
+ apiKey,
83
+ baseUrl: cfg.baseUrl,
84
+ siteUrl: cfg['siteUrl'],
85
+ siteName: cfg['siteName'],
86
+ });
87
+ },
88
+ bedrock: (_name, cfg) => {
89
+ const region = cfg['region'] ?? 'us-east-1';
90
+ const credentials = cfg['credentials'];
91
+ return new BedrockProvider(credentials ? { region, credentials } : { region });
92
+ },
93
+ elevenlabs: (name, cfg) => {
94
+ const apiKey = requireKey(name, cfg);
95
+ if (apiKey === null)
96
+ return null;
97
+ return new ElevenLabsProvider({
98
+ apiKey,
99
+ ...(cfg.baseUrl ? { baseUrl: cfg.baseUrl } : {}),
100
+ ...(cfg['defaultTtsModelId'] ? { defaultTtsModelId: cfg['defaultTtsModelId'] } : {}),
101
+ });
102
+ },
103
+ voyage: (name, cfg) => {
104
+ const apiKey = requireKey(name, cfg);
105
+ if (apiKey === null)
106
+ return null;
107
+ return new VoyageProvider({
108
+ apiKey,
109
+ ...(cfg.baseUrl ? { baseUrl: cfg.baseUrl } : {}),
110
+ ...(cfg['defaultInputType'] ? { defaultInputType: cfg['defaultInputType'] } : {}),
111
+ });
112
+ },
113
+ };
114
+ /**
115
+ * AI ServiceProvider — reads config from `config('ai')`.
116
+ *
117
+ * @example
118
+ * // bootstrap/providers.ts
119
+ * import { AiProvider } from '@rudderjs/ai/server'
120
+ * export default [AiProvider, ...]
121
+ */
122
+ export class AiProvider extends ServiceProvider {
123
+ register() { }
124
+ async boot() {
125
+ const cfg = config('ai');
126
+ const googleCacheRegistry = this.buildGoogleCacheRegistry();
127
+ for (const [name, providerConfig] of Object.entries(cfg.providers)) {
128
+ const driver = providerConfig.driver ?? name;
129
+ const build = DRIVERS[driver];
130
+ if (!build)
131
+ continue;
132
+ const instance = build(name, providerConfig, { googleCacheRegistry });
133
+ if (instance === null) {
134
+ // Drivers that need an apiKey return null when it's missing/empty
135
+ // (see requireKey). Skip with a grouped boot notice so the app boots
136
+ // and `AI.use('${name}')` surfaces the standard "not registered"
137
+ // error at the use-site with a clear hint to set the env var.
138
+ bootNotice('ai', `${name} skipped, no API key (set it in .env)`);
139
+ continue;
140
+ }
141
+ AiRegistry.register(instance);
142
+ }
143
+ AiRegistry.setDefault(cfg.default);
144
+ AiRegistry.setModels(cfg.models ?? []);
145
+ this.app.instance('ai.registry', AiRegistry);
146
+ // Register conversation store if provided in config
147
+ if (cfg.conversations) {
148
+ setConversationStore(cfg.conversations);
149
+ this.app.instance('ai.conversations', cfg.conversations);
150
+ }
151
+ // Register user-memory store if provided in config (#A4)
152
+ if (cfg.memory) {
153
+ setUserMemory(cfg.memory);
154
+ this.app.instance('ai.memory', cfg.memory);
155
+ }
156
+ // Wire agent.queue() / .broadcast() to Rudder's queue + broadcast.
157
+ await this.configureQueueBridge();
158
+ // Register make:agent scaffolder
159
+ try {
160
+ const { registerMakeSpecs } = await import('@rudderjs/console');
161
+ const { makeAgentSpec } = await import('../commands/make-agent.js');
162
+ registerMakeSpecs(makeAgentSpec);
163
+ }
164
+ catch { /* rudder console not available */ }
165
+ }
166
+ /**
167
+ * Back the engine's `agent.queue('...').send()` / `.broadcast(channel)` with
168
+ * Rudder's queue and broadcast. Both are optional: when `@rudderjs/queue` is
169
+ * installed, queued AI jobs dispatch through it; when `@rudderjs/broadcast` is
170
+ * also installed, streaming jobs push progress to a channel. When neither is
171
+ * present the engine stays unconfigured and `agent.queue()` surfaces its
172
+ * "register a queue adapter" error at the use-site.
173
+ */
174
+ async configureQueueBridge() {
175
+ let dispatch;
176
+ try {
177
+ ({ dispatch } = await import('@rudderjs/queue'));
178
+ }
179
+ catch { /* @rudderjs/queue not installed - leave agent.queue() unconfigured */ }
180
+ if (!dispatch)
181
+ return;
182
+ let broadcast;
183
+ try {
184
+ ({ broadcast } = await import('@rudderjs/broadcast'));
185
+ }
186
+ catch { /* @rudderjs/broadcast not installed - .broadcast() errors if used */ }
187
+ configureAiQueue({ dispatch, broadcast: broadcast ?? null });
188
+ }
189
+ /**
190
+ * Build a `GoogleCacheRegistry` for Gemini's `cachedContent` resources.
191
+ * When `@rudderjs/cache` is installed and booted, the registered cache
192
+ * adapter is plumbed in for cross-process / cross-restart persistence.
193
+ * Otherwise the registry uses an in-process `Map` and warns once on
194
+ * first use.
195
+ */
196
+ buildGoogleCacheRegistry() {
197
+ if (this.app.container.has('cache')) {
198
+ const store = this.app.make('cache');
199
+ return new GoogleCacheRegistry({ store });
200
+ }
201
+ return new GoogleCacheRegistry();
202
+ }
203
+ }
204
+ //# sourceMappingURL=provider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"provider.js","sourceRoot":"","sources":["../../src/server/provider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AACpE,OAAO,EACL,UAAU,EACV,oBAAoB,EACpB,aAAa,EACb,gBAAgB,EAChB,mBAAmB,EACnB,iBAAiB,EACjB,cAAc,EACd,cAAc,EACd,cAAc,EACd,gBAAgB,EAChB,WAAW,EACX,YAAY,EACZ,eAAe,EACf,mBAAmB,EACnB,kBAAkB,EAClB,eAAe,EACf,kBAAkB,EAClB,cAAc,GAKf,MAAM,kBAAkB,CAAA;AAEzB;;;;;;;;;;;GAWG;AACH,SAAS,UAAU,CAAC,KAAa,EAAE,GAAqB;IACtD,OAAO,GAAG,CAAC,MAAM,IAAI,IAAI,CAAA;AAC3B,CAAC;AAKD,MAAM,OAAO,GAAkC;IAC7C,SAAS,EAAE,CAAC,IAAI,EAAE,GAAG,EAAE,EAAE;QACvB,MAAM,MAAM,GAAG,UAAU,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;QAAC,IAAI,MAAM,KAAK,IAAI;YAAE,OAAO,IAAI,CAAA;QACtE,OAAO,IAAI,iBAAiB,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,CAAC,OAAO,EAAE,CAAC,CAAA;IAChE,CAAC;IACD,MAAM,EAAE,CAAC,IAAI,EAAE,GAAG,EAAE,EAAE;QACpB,MAAM,MAAM,GAAG,UAAU,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;QAAC,IAAI,MAAM,KAAK,IAAI;YAAE,OAAO,IAAI,CAAA;QACtE,OAAO,IAAI,cAAc,CAAC;YACxB,MAAM;YACN,OAAO,EAAO,GAAG,CAAC,OAAO;YACzB,YAAY,EAAE,GAAG,CAAC,cAAc,CAAuB;SACx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AG,CAAC,SAAS,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC;YACpC,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAiB,OAAO,CAAC,CAAA;YACpD,OAAO,IAAI,mBAAmB,CAAC,EAAE,KAAK,EAAE,CAAC,CAAA;QAC3C,CAAC;QACD,OAAO,IAAI,mBAAmB,EAAE,CAAA;IAClC,CAAC;CACF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rudderjs/ai",
3
- "version": "1.18.3",
3
+ "version": "1.18.5",
4
4
  "description": "[Deprecated] Moved to @gemstack/ai-sdk. This package now re-exports it for backwards compatibility.",
5
5
  "rudderjs": {
6
6
  "provider": "AiProvider",
@@ -94,16 +94,21 @@
94
94
  },
95
95
  "dependencies": {
96
96
  "@gemstack/ai-mcp": "^0.1.0",
97
- "@gemstack/ai-sdk": "^0.3.0"
97
+ "@gemstack/ai-sdk": "^0.5.0"
98
98
  },
99
99
  "peerDependencies": {
100
100
  "@modelcontextprotocol/sdk": "^1.29.0",
101
101
  "react": ">=19.2.0",
102
+ "@rudderjs/broadcast": "^1.4.1",
102
103
  "@rudderjs/console": "^1.4.3",
103
- "@rudderjs/orm": "^1.22.0",
104
- "@rudderjs/core": "^1.13.3"
104
+ "@rudderjs/core": "^1.13.3",
105
+ "@rudderjs/queue": "^4.4.4",
106
+ "@rudderjs/orm": "^1.22.0"
105
107
  },
106
108
  "peerDependenciesMeta": {
109
+ "@rudderjs/broadcast": {
110
+ "optional": true
111
+ },
107
112
  "@rudderjs/console": {
108
113
  "optional": true
109
114
  },
@@ -113,6 +118,9 @@
113
118
  "@rudderjs/orm": {
114
119
  "optional": true
115
120
  },
121
+ "@rudderjs/queue": {
122
+ "optional": true
123
+ },
116
124
  "@modelcontextprotocol/sdk": {
117
125
  "optional": true
118
126
  },
@@ -129,7 +137,7 @@
129
137
  },
130
138
  "devDependencies": {
131
139
  "@gemstack/ai-mcp": "^0.1.0",
132
- "@gemstack/ai-sdk": "^0.3.0",
140
+ "@gemstack/ai-sdk": "^0.5.0",
133
141
  "@modelcontextprotocol/sdk": "^1.29.0",
134
142
  "@types/node": "^20.0.0",
135
143
  "@types/react": "^19.2.0",
@@ -137,7 +145,9 @@
137
145
  "typescript": "^5.4.0",
138
146
  "@rudderjs/console": "^1.4.3",
139
147
  "@rudderjs/core": "^1.13.3",
140
- "@rudderjs/orm": "^1.22.0"
148
+ "@rudderjs/orm": "^1.22.0",
149
+ "@rudderjs/queue": "^4.4.4",
150
+ "@rudderjs/broadcast": "^1.4.1"
141
151
  },
142
152
  "author": "Suleiman Shahbari",
143
153
  "scripts": {