@alexkroman1/aai 1.6.0 → 1.6.1

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.
@@ -1,5 +1,5 @@
1
1
 
2
- > @alexkroman1/aai@1.6.0 build /home/runner/work/agent/agent/packages/aai
2
+ > @alexkroman1/aai@1.6.1 build /home/runner/work/agent/agent/packages/aai
3
3
  > tsdown && tsc -p tsconfig.build.json
4
4
 
5
5
  ℹ tsdown v0.21.7 powered by rolldown v1.0.0-rc.12
@@ -8,7 +8,7 @@
8
8
  ℹ target: node22
9
9
  ℹ tsconfig: tsconfig.json
10
10
  ℹ Build start
11
- ℹ dist/host/runtime-barrel.js 103.81 kB │ gzip: 29.39 kB
11
+ ℹ dist/host/runtime-barrel.js 102.24 kB │ gzip: 28.92 kB
12
12
  ℹ dist/sdk/protocol.js  4.75 kB │ gzip: 1.76 kB
13
13
  ℹ dist/index.js  2.88 kB │ gzip: 1.24 kB
14
14
  ℹ dist/sdk/manifest-barrel.js  0.36 kB │ gzip: 0.20 kB
@@ -22,5 +22,5 @@
22
22
  ℹ dist/xai-jfQsxxPZ.js  1.18 kB │ gzip: 0.35 kB
23
23
  ℹ dist/ws-upgrade-BeOQ7fXL.js  1.14 kB │ gzip: 0.54 kB
24
24
  ℹ dist/cartesia-BfQPOQ7Y.js  1.08 kB │ gzip: 0.50 kB
25
- ℹ 14 files, total: 132.56 kB
26
- ✔ Build complete in 43ms
25
+ ℹ 14 files, total: 130.99 kB
26
+ ✔ Build complete in 50ms
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @alexkroman1/aai
2
2
 
3
+ ## 1.6.1
4
+
5
+ ### Patch Changes
6
+
7
+ - da84b47: Move @ai-sdk/_ LLM provider packages from optional peerDependencies to dependencies. Self-hosted deployments no longer need to install the @ai-sdk/_ packages separately, and prod deploys (where pnpm install --prod previously stripped optional peer deps) now resolve them reliably.
8
+
3
9
  ## 1.6.0
4
10
 
5
11
  ### Minor Changes
@@ -5,17 +5,11 @@
5
5
  * holds `SttProvider` / `LlmProvider` / `TtsProvider` **descriptors** —
6
6
  * plain `{ kind, options }` data. At session start the runtime calls the
7
7
  * resolvers here to turn each descriptor into its openable / callable
8
- * host-side counterpart, importing the third-party SDK only at that point.
8
+ * host-side counterpart.
9
9
  *
10
10
  * The guest sandbox never imports these functions, which is how the agent
11
11
  * bundle stays free of `@ai-sdk/anthropic` / `assemblyai` /
12
12
  * `@cartesia/cartesia-js`.
13
- *
14
- * `@ai-sdk/*` packages are loaded via `createRequire` lazily so self-hosted
15
- * users only need to install the providers they actually reference. A
16
- * missing package is reported as a friendly "package not installed" error
17
- * at first session start, not as a module-load failure when the host
18
- * package itself is imported.
19
13
  */
20
14
  import type { LanguageModel } from "ai";
21
15
  import type { LlmProvider, SttOpener, SttProvider, TtsOpener, TtsProvider } from "../../sdk/providers.ts";
@@ -6,12 +6,17 @@ import { a as toAgentConfig, c as makeSttError, i as agentToolsToSchemas, l as m
6
6
  import { a as ASSEMBLYAI_KIND, r as ELEVENLABS_KIND, s as DEEPGRAM_KIND, t as SONIOX_KIND } from "../soniox-DCQ3GqJq.js";
7
7
  import { a as RIME_KIND, n as CARTESIA_KIND } from "../cartesia-BfQPOQ7Y.js";
8
8
  import { a as MISTRAL_KIND, d as ANTHROPIC_KIND, l as GOOGLE_KIND, r as OPENAI_KIND, s as GROQ_KIND } from "../xai-jfQsxxPZ.js";
9
- import { createRequire } from "node:module";
10
9
  import { z } from "zod";
11
10
  import { convert } from "html-to-text";
12
11
  import vm from "node:vm";
13
12
  import pTimeout from "p-timeout";
14
13
  import { createStorage, prefixStorage } from "unstorage";
14
+ import { createAnthropic } from "@ai-sdk/anthropic";
15
+ import { createGoogleGenerativeAI } from "@ai-sdk/google";
16
+ import { createGroq } from "@ai-sdk/groq";
17
+ import { createMistral } from "@ai-sdk/mistral";
18
+ import { createOpenAI } from "@ai-sdk/openai";
19
+ import { createXai } from "@ai-sdk/xai";
15
20
  import { AssemblyAI } from "assemblyai";
16
21
  import { createNanoEvents } from "nanoevents";
17
22
  import { DeepgramClient } from "@deepgram/sdk";
@@ -1200,19 +1205,12 @@ function openRime(opts) {
1200
1205
  * holds `SttProvider` / `LlmProvider` / `TtsProvider` **descriptors** —
1201
1206
  * plain `{ kind, options }` data. At session start the runtime calls the
1202
1207
  * resolvers here to turn each descriptor into its openable / callable
1203
- * host-side counterpart, importing the third-party SDK only at that point.
1208
+ * host-side counterpart.
1204
1209
  *
1205
1210
  * The guest sandbox never imports these functions, which is how the agent
1206
1211
  * bundle stays free of `@ai-sdk/anthropic` / `assemblyai` /
1207
1212
  * `@cartesia/cartesia-js`.
1208
- *
1209
- * `@ai-sdk/*` packages are loaded via `createRequire` lazily so self-hosted
1210
- * users only need to install the providers they actually reference. A
1211
- * missing package is reported as a friendly "package not installed" error
1212
- * at first session start, not as a module-load failure when the host
1213
- * package itself is imported.
1214
1213
  */
1215
- const requireFromHere = createRequire(import.meta.url);
1216
1214
  /**
1217
1215
  * Look up a provider API key: agent env first (set via `aai secret put` or
1218
1216
  * `.env`), then the host's `process.env` as a fallback for self-hosted mode.
@@ -1249,39 +1247,15 @@ function resolveTts(descriptor) {
1249
1247
  */
1250
1248
  function resolveLlm(descriptor, env) {
1251
1249
  switch (descriptor.kind) {
1252
- case ANTHROPIC_KIND: {
1253
- const apiKey = requireKey(env, "ANTHROPIC_API_KEY", "Anthropic");
1254
- const { createAnthropic } = loadProviderPackage("@ai-sdk/anthropic", "Anthropic");
1255
- return createAnthropic({
1256
- apiKey,
1257
- baseURL: "https://api.anthropic.com/v1"
1258
- })(descriptor.options.model);
1259
- }
1260
- case OPENAI_KIND: {
1261
- const apiKey = requireKey(env, "OPENAI_API_KEY", "OpenAI");
1262
- const { createOpenAI } = loadProviderPackage("@ai-sdk/openai", "OpenAI");
1263
- return createOpenAI({ apiKey })(descriptor.options.model);
1264
- }
1265
- case GOOGLE_KIND: {
1266
- const apiKey = requireKey(env, "GOOGLE_GENERATIVE_AI_API_KEY", "Google");
1267
- const { createGoogleGenerativeAI } = loadProviderPackage("@ai-sdk/google", "Google");
1268
- return createGoogleGenerativeAI({ apiKey })(descriptor.options.model);
1269
- }
1270
- case MISTRAL_KIND: {
1271
- const apiKey = requireKey(env, "MISTRAL_API_KEY", "Mistral");
1272
- const { createMistral } = loadProviderPackage("@ai-sdk/mistral", "Mistral");
1273
- return createMistral({ apiKey })(descriptor.options.model);
1274
- }
1275
- case "xai": {
1276
- const apiKey = requireKey(env, "XAI_API_KEY", "xAI");
1277
- const { createXai } = loadProviderPackage("@ai-sdk/xai", "xAI");
1278
- return createXai({ apiKey })(descriptor.options.model);
1279
- }
1280
- case GROQ_KIND: {
1281
- const apiKey = requireKey(env, "GROQ_API_KEY", "Groq");
1282
- const { createGroq } = loadProviderPackage("@ai-sdk/groq", "Groq");
1283
- return createGroq({ apiKey })(descriptor.options.model);
1284
- }
1250
+ case ANTHROPIC_KIND: return createAnthropic({
1251
+ apiKey: requireKey(env, "ANTHROPIC_API_KEY", "Anthropic"),
1252
+ baseURL: "https://api.anthropic.com/v1"
1253
+ })(descriptor.options.model);
1254
+ case OPENAI_KIND: return createOpenAI({ apiKey: requireKey(env, "OPENAI_API_KEY", "OpenAI") })(descriptor.options.model);
1255
+ case GOOGLE_KIND: return createGoogleGenerativeAI({ apiKey: requireKey(env, "GOOGLE_GENERATIVE_AI_API_KEY", "Google") })(descriptor.options.model);
1256
+ case MISTRAL_KIND: return createMistral({ apiKey: requireKey(env, "MISTRAL_API_KEY", "Mistral") })(descriptor.options.model);
1257
+ case "xai": return createXai({ apiKey: requireKey(env, "XAI_API_KEY", "xAI") })(descriptor.options.model);
1258
+ case GROQ_KIND: return createGroq({ apiKey: requireKey(env, "GROQ_API_KEY", "Groq") })(descriptor.options.model);
1285
1259
  default: throw new Error(`Unknown LLM provider kind: "${descriptor.kind}". Supported: ${ANTHROPIC_KIND}, ${OPENAI_KIND}, ${GOOGLE_KIND}, ${MISTRAL_KIND}, xai, ${GROQ_KIND}.`);
1286
1260
  }
1287
1261
  }
@@ -1290,26 +1264,6 @@ function requireKey(env, name, label) {
1290
1264
  if (!key) throw new Error(`${label} LLM: missing API key. Set ${name} in the agent env.`);
1291
1265
  return key;
1292
1266
  }
1293
- /**
1294
- * Synchronously load an optional `@ai-sdk/*` package via `createRequire`.
1295
- * Throws a friendly install-hint error if the package isn't installed,
1296
- * so users see "Run `pnpm add @ai-sdk/openai`" rather than a cryptic
1297
- * Node module-resolution stack trace.
1298
- */
1299
- function loadProviderPackage(name, label) {
1300
- try {
1301
- return requireFromHere(name);
1302
- } catch (err) {
1303
- if (isModuleNotFound(err, name)) throw new Error(`${label} LLM: package \`${name}\` is not installed. Run \`pnpm add ${name}\`.`, { cause: err });
1304
- throw err;
1305
- }
1306
- }
1307
- function isModuleNotFound(err, name) {
1308
- if (!(err instanceof Error)) return false;
1309
- const code = err.code;
1310
- if (code !== "MODULE_NOT_FOUND" && code !== "ERR_MODULE_NOT_FOUND") return false;
1311
- return err.message.includes(name);
1312
- }
1313
1267
  //#endregion
1314
1268
  //#region host/runtime-config.ts
1315
1269
  /**
@@ -6,20 +6,19 @@
6
6
  * holds `SttProvider` / `LlmProvider` / `TtsProvider` **descriptors** —
7
7
  * plain `{ kind, options }` data. At session start the runtime calls the
8
8
  * resolvers here to turn each descriptor into its openable / callable
9
- * host-side counterpart, importing the third-party SDK only at that point.
9
+ * host-side counterpart.
10
10
  *
11
11
  * The guest sandbox never imports these functions, which is how the agent
12
12
  * bundle stays free of `@ai-sdk/anthropic` / `assemblyai` /
13
13
  * `@cartesia/cartesia-js`.
14
- *
15
- * `@ai-sdk/*` packages are loaded via `createRequire` lazily so self-hosted
16
- * users only need to install the providers they actually reference. A
17
- * missing package is reported as a friendly "package not installed" error
18
- * at first session start, not as a module-load failure when the host
19
- * package itself is imported.
20
14
  */
21
15
 
22
- import { createRequire } from "node:module";
16
+ import { createAnthropic } from "@ai-sdk/anthropic";
17
+ import { createGoogleGenerativeAI } from "@ai-sdk/google";
18
+ import { createGroq } from "@ai-sdk/groq";
19
+ import { createMistral } from "@ai-sdk/mistral";
20
+ import { createOpenAI } from "@ai-sdk/openai";
21
+ import { createXai } from "@ai-sdk/xai";
23
22
  import type { LanguageModel } from "ai";
24
23
  import { ANTHROPIC_KIND, type AnthropicOptions } from "../../sdk/providers/llm/anthropic.ts";
25
24
  import { GOOGLE_KIND, type GoogleOptions } from "../../sdk/providers/llm/google.ts";
@@ -47,8 +46,6 @@ import { openSoniox } from "./stt/soniox.ts";
47
46
  import { openCartesia } from "./tts/cartesia.ts";
48
47
  import { openRime } from "./tts/rime.ts";
49
48
 
50
- const requireFromHere = createRequire(import.meta.url);
51
-
52
49
  /**
53
50
  * Look up a provider API key: agent env first (set via `aai secret put` or
54
51
  * `.env`), then the host's `process.env` as a fallback for self-hosted mode.
@@ -103,10 +100,6 @@ export function resolveLlm(descriptor: LlmProvider, env: Record<string, string>)
103
100
  switch (descriptor.kind) {
104
101
  case ANTHROPIC_KIND: {
105
102
  const apiKey = requireKey(env, "ANTHROPIC_API_KEY", "Anthropic");
106
- const { createAnthropic } = loadProviderPackage<typeof import("@ai-sdk/anthropic")>(
107
- "@ai-sdk/anthropic",
108
- "Anthropic",
109
- );
110
103
  // Pass baseURL explicitly so the SDK's loadOptionalSetting returns
111
104
  // before reading process.env["ANTHROPIC_BASE_URL"]. Without this,
112
105
  // the Deno platform server needs --allow-env to start a session.
@@ -116,41 +109,24 @@ export function resolveLlm(descriptor: LlmProvider, env: Record<string, string>)
116
109
  }
117
110
  case OPENAI_KIND: {
118
111
  const apiKey = requireKey(env, "OPENAI_API_KEY", "OpenAI");
119
- const { createOpenAI } = loadProviderPackage<typeof import("@ai-sdk/openai")>(
120
- "@ai-sdk/openai",
121
- "OpenAI",
122
- );
123
112
  return createOpenAI({ apiKey })((descriptor.options as unknown as OpenAIOptions).model);
124
113
  }
125
114
  case GOOGLE_KIND: {
126
115
  const apiKey = requireKey(env, "GOOGLE_GENERATIVE_AI_API_KEY", "Google");
127
- const { createGoogleGenerativeAI } = loadProviderPackage<typeof import("@ai-sdk/google")>(
128
- "@ai-sdk/google",
129
- "Google",
130
- );
131
116
  return createGoogleGenerativeAI({ apiKey })(
132
117
  (descriptor.options as unknown as GoogleOptions).model,
133
118
  );
134
119
  }
135
120
  case MISTRAL_KIND: {
136
121
  const apiKey = requireKey(env, "MISTRAL_API_KEY", "Mistral");
137
- const { createMistral } = loadProviderPackage<typeof import("@ai-sdk/mistral")>(
138
- "@ai-sdk/mistral",
139
- "Mistral",
140
- );
141
122
  return createMistral({ apiKey })((descriptor.options as unknown as MistralOptions).model);
142
123
  }
143
124
  case XAI_KIND: {
144
125
  const apiKey = requireKey(env, "XAI_API_KEY", "xAI");
145
- const { createXai } = loadProviderPackage<typeof import("@ai-sdk/xai")>("@ai-sdk/xai", "xAI");
146
126
  return createXai({ apiKey })((descriptor.options as unknown as XaiOptions).model);
147
127
  }
148
128
  case GROQ_KIND: {
149
129
  const apiKey = requireKey(env, "GROQ_API_KEY", "Groq");
150
- const { createGroq } = loadProviderPackage<typeof import("@ai-sdk/groq")>(
151
- "@ai-sdk/groq",
152
- "Groq",
153
- );
154
130
  return createGroq({ apiKey })((descriptor.options as unknown as GroqOptions).model);
155
131
  }
156
132
  default:
@@ -170,32 +146,3 @@ function requireKey(env: Record<string, string>, name: string, label: string): s
170
146
  }
171
147
  return key;
172
148
  }
173
-
174
- /**
175
- * Synchronously load an optional `@ai-sdk/*` package via `createRequire`.
176
- * Throws a friendly install-hint error if the package isn't installed,
177
- * so users see "Run `pnpm add @ai-sdk/openai`" rather than a cryptic
178
- * Node module-resolution stack trace.
179
- */
180
- function loadProviderPackage<T>(name: string, label: string): T {
181
- try {
182
- return requireFromHere(name) as T;
183
- } catch (err: unknown) {
184
- if (isModuleNotFound(err, name)) {
185
- throw new Error(
186
- `${label} LLM: package \`${name}\` is not installed. Run \`pnpm add ${name}\`.`,
187
- { cause: err },
188
- );
189
- }
190
- throw err;
191
- }
192
- }
193
-
194
- function isModuleNotFound(err: unknown, name: string): boolean {
195
- if (!(err instanceof Error)) return false;
196
- const code = (err as NodeJS.ErrnoException).code;
197
- if (code !== "MODULE_NOT_FOUND" && code !== "ERR_MODULE_NOT_FOUND") return false;
198
- // Defensive: only treat as missing-package if the error is about *this*
199
- // package, not some transitive dep that failed to resolve.
200
- return err.message.includes(name);
201
- }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alexkroman1/aai",
3
- "version": "1.6.0",
3
+ "version": "1.6.1",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {
@@ -40,6 +40,12 @@
40
40
  }
41
41
  },
42
42
  "dependencies": {
43
+ "@ai-sdk/anthropic": "^3.0.0",
44
+ "@ai-sdk/google": "^3.0.0",
45
+ "@ai-sdk/groq": "^3.0.0",
46
+ "@ai-sdk/mistral": "^3.0.0",
47
+ "@ai-sdk/openai": "^3.0.0",
48
+ "@ai-sdk/xai": "^3.0.0",
43
49
  "@cartesia/cartesia-js": "^3.0.0",
44
50
  "@deepgram/sdk": "^5.0.0",
45
51
  "@elevenlabs/elevenlabs-js": "^2.43.0",
@@ -54,41 +60,7 @@
54
60
  "ws": "^8.20.0",
55
61
  "zod": "^4.3.6"
56
62
  },
57
- "peerDependencies": {
58
- "@ai-sdk/anthropic": "^3.0.0",
59
- "@ai-sdk/google": "^3.0.0",
60
- "@ai-sdk/groq": "^3.0.0",
61
- "@ai-sdk/mistral": "^3.0.0",
62
- "@ai-sdk/openai": "^3.0.0",
63
- "@ai-sdk/xai": "^3.0.0"
64
- },
65
- "peerDependenciesMeta": {
66
- "@ai-sdk/anthropic": {
67
- "optional": true
68
- },
69
- "@ai-sdk/google": {
70
- "optional": true
71
- },
72
- "@ai-sdk/groq": {
73
- "optional": true
74
- },
75
- "@ai-sdk/mistral": {
76
- "optional": true
77
- },
78
- "@ai-sdk/openai": {
79
- "optional": true
80
- },
81
- "@ai-sdk/xai": {
82
- "optional": true
83
- }
84
- },
85
63
  "devDependencies": {
86
- "@ai-sdk/anthropic": "^3.0.0",
87
- "@ai-sdk/google": "^3.0.0",
88
- "@ai-sdk/groq": "^3.0.0",
89
- "@ai-sdk/mistral": "^3.0.0",
90
- "@ai-sdk/openai": "^3.0.0",
91
- "@ai-sdk/xai": "^3.0.0",
92
64
  "@types/escape-html": "^1.0.4",
93
65
  "@types/html-to-text": "^9.0.4",
94
66
  "@types/json-schema": "^7.0.15",