@link-assistant/agent 0.14.0 → 0.16.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@link-assistant/agent",
3
- "version": "0.14.0",
3
+ "version": "0.16.0",
4
4
  "description": "A minimal, public domain AI CLI agent compatible with OpenCode's JSON interface. Bun-only runtime.",
5
5
  "main": "src/index.js",
6
6
  "type": "module",
@@ -54,8 +54,18 @@
54
54
  "@actions/core": "^1.11.1",
55
55
  "@actions/github": "^6.0.1",
56
56
  "@agentclientprotocol/sdk": "^0.5.1",
57
+ "@ai-sdk/amazon-bedrock": "^3.0.74",
58
+ "@ai-sdk/anthropic": "^2.0.58",
59
+ "@ai-sdk/azure": "^2.0.91",
60
+ "@ai-sdk/google": "^2.0.52",
61
+ "@ai-sdk/google-vertex": "^3.0.98",
62
+ "@ai-sdk/groq": "^2.0.34",
57
63
  "@ai-sdk/mcp": "^0.0.8",
64
+ "@ai-sdk/mistral": "^2.0.27",
65
+ "@ai-sdk/openai": "^2.0.89",
66
+ "@ai-sdk/openai-compatible": "^1.0.32",
58
67
  "@ai-sdk/xai": "^2.0.33",
68
+ "@openrouter/ai-sdk-provider": "^1.5.4",
59
69
  "@clack/prompts": "^0.11.0",
60
70
  "@hono/standard-validator": "^0.2.0",
61
71
  "@hono/zod-validator": "^0.7.5",
@@ -18,9 +18,48 @@ import { createEchoModel } from './echo';
18
18
  import { createCacheModel } from './cache';
19
19
  import { RetryFetch } from './retry-fetch';
20
20
 
21
+ // Direct imports for bundled providers - these are pre-installed to avoid runtime installation hangs
22
+ // @see https://github.com/link-assistant/agent/issues/173
23
+ // @see https://github.com/oven-sh/bun/issues/5831 (bun install hangs sporadically)
24
+ import { createAmazonBedrock } from '@ai-sdk/amazon-bedrock';
25
+ import { createAnthropic } from '@ai-sdk/anthropic';
26
+ import { createAzure } from '@ai-sdk/azure';
27
+ import { createGoogleGenerativeAI } from '@ai-sdk/google';
28
+ import { createVertex } from '@ai-sdk/google-vertex';
29
+ import { createOpenAI } from '@ai-sdk/openai';
30
+ import { createOpenAICompatible } from '@ai-sdk/openai-compatible';
31
+ import { createOpenRouter } from '@openrouter/ai-sdk-provider';
32
+ import { createXai } from '@ai-sdk/xai';
33
+ import { createMistral } from '@ai-sdk/mistral';
34
+ import { createGroq } from '@ai-sdk/groq';
35
+
21
36
  export namespace Provider {
22
37
  const log = Log.create({ service: 'provider' });
23
38
 
39
+ /**
40
+ * Bundled providers - these are pre-installed and imported statically
41
+ * to avoid runtime package installation which can hang or timeout.
42
+ *
43
+ * When a provider's npm package is in this map, we use the pre-installed
44
+ * version instead of dynamically installing via `bun add`.
45
+ *
46
+ * @see https://github.com/link-assistant/agent/issues/173
47
+ * @see https://github.com/Kilo-Org/kilo (reference implementation)
48
+ */
49
+ const BUNDLED_PROVIDERS: Record<string, (options: any) => SDK> = {
50
+ '@ai-sdk/amazon-bedrock': createAmazonBedrock,
51
+ '@ai-sdk/anthropic': createAnthropic,
52
+ '@ai-sdk/azure': createAzure,
53
+ '@ai-sdk/google': createGoogleGenerativeAI,
54
+ '@ai-sdk/google-vertex': createVertex,
55
+ '@ai-sdk/openai': createOpenAI,
56
+ '@ai-sdk/openai-compatible': createOpenAICompatible,
57
+ '@openrouter/ai-sdk-provider': createOpenRouter,
58
+ '@ai-sdk/xai': createXai,
59
+ '@ai-sdk/mistral': createMistral,
60
+ '@ai-sdk/groq': createGroq,
61
+ };
62
+
24
63
  type CustomLoader = (provider: ModelsDev.Provider) => Promise<{
25
64
  autoload: boolean;
26
65
  getModel?: (
@@ -1128,37 +1167,7 @@ export namespace Provider {
1128
1167
  const existing = s.sdk.get(key);
1129
1168
  if (existing) return existing;
1130
1169
 
1131
- let installedPath: string;
1132
- if (!pkg.startsWith('file://')) {
1133
- log.info(() => ({
1134
- message: 'installing provider package',
1135
- providerID: provider.id,
1136
- pkg,
1137
- version: 'latest',
1138
- }));
1139
- installedPath = await BunProc.install(pkg, 'latest');
1140
- log.info(() => ({
1141
- message: 'provider package installed successfully',
1142
- providerID: provider.id,
1143
- pkg,
1144
- installedPath,
1145
- }));
1146
- } else {
1147
- log.info(() => ({ message: 'loading local provider', pkg }));
1148
- installedPath = pkg;
1149
- }
1150
-
1151
- // The `google-vertex-anthropic` provider points to the `@ai-sdk/google-vertex` package.
1152
- // Ref: https://github.com/sst/models.dev/blob/0a87de42ab177bebad0620a889e2eb2b4a5dd4ab/providers/google-vertex-anthropic/provider.toml
1153
- // However, the actual export is at the subpath `@ai-sdk/google-vertex/anthropic`.
1154
- // Ref: https://ai-sdk.dev/providers/ai-sdk-providers/google-vertex#google-vertex-anthropic-provider-usage
1155
- // In addition, Bun's dynamic import logic does not support subpath imports,
1156
- // so we patch the import path to load directly from `dist`.
1157
- const modPath =
1158
- provider.id === 'google-vertex-anthropic'
1159
- ? `${installedPath}/dist/anthropic/index.mjs`
1160
- : installedPath;
1161
- const mod = await import(modPath);
1170
+ // Apply timeout wrapper to options if timeout is specified
1162
1171
  if (options['timeout'] !== undefined && options['timeout'] !== null) {
1163
1172
  // Preserve custom fetch if it exists, wrap it with timeout logic
1164
1173
  const customFetch = options['fetch'];
@@ -1192,6 +1201,58 @@ export namespace Provider {
1192
1201
  sessionID: provider.id,
1193
1202
  });
1194
1203
 
1204
+ // Check if we have a bundled provider first - this avoids runtime package installation
1205
+ // which can hang or timeout due to known Bun issues
1206
+ // @see https://github.com/link-assistant/agent/issues/173
1207
+ // @see https://github.com/oven-sh/bun/issues/5831
1208
+ const bundledFn = BUNDLED_PROVIDERS[pkg];
1209
+ if (bundledFn) {
1210
+ log.info(() => ({
1211
+ message: 'using bundled provider (no installation needed)',
1212
+ providerID: provider.id,
1213
+ pkg,
1214
+ }));
1215
+ const loaded = bundledFn({
1216
+ name: provider.id,
1217
+ ...options,
1218
+ });
1219
+ s.sdk.set(key, loaded);
1220
+ return loaded as SDK;
1221
+ }
1222
+
1223
+ // Fall back to dynamic installation for non-bundled providers
1224
+ let installedPath: string;
1225
+ if (!pkg.startsWith('file://')) {
1226
+ log.info(() => ({
1227
+ message: 'installing provider package (not bundled)',
1228
+ providerID: provider.id,
1229
+ pkg,
1230
+ version: 'latest',
1231
+ }));
1232
+ installedPath = await BunProc.install(pkg, 'latest');
1233
+ log.info(() => ({
1234
+ message: 'provider package installed successfully',
1235
+ providerID: provider.id,
1236
+ pkg,
1237
+ installedPath,
1238
+ }));
1239
+ } else {
1240
+ log.info(() => ({ message: 'loading local provider', pkg }));
1241
+ installedPath = pkg;
1242
+ }
1243
+
1244
+ // The `google-vertex-anthropic` provider points to the `@ai-sdk/google-vertex` package.
1245
+ // Ref: https://github.com/sst/models.dev/blob/0a87de42ab177bebad0620a889e2eb2b4a5dd4ab/providers/google-vertex-anthropic/provider.toml
1246
+ // However, the actual export is at the subpath `@ai-sdk/google-vertex/anthropic`.
1247
+ // Ref: https://ai-sdk.dev/providers/ai-sdk-providers/google-vertex#google-vertex-anthropic-provider-usage
1248
+ // In addition, Bun's dynamic import logic does not support subpath imports,
1249
+ // so we patch the import path to load directly from `dist`.
1250
+ const modPath =
1251
+ provider.id === 'google-vertex-anthropic'
1252
+ ? `${installedPath}/dist/anthropic/index.mjs`
1253
+ : installedPath;
1254
+ const mod = await import(modPath);
1255
+
1195
1256
  const fn = mod[Object.keys(mod).find((key) => key.startsWith('create'))!];
1196
1257
  const loaded = fn({
1197
1258
  name: provider.id,