memeloop 0.2.3 → 0.2.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.
Files changed (96) hide show
  1. package/dist/browser.d.cts +26 -21
  2. package/dist/browser.d.ts +26 -21
  3. package/dist/chunk-4OITUYFC.js +37 -0
  4. package/dist/chunk-4OITUYFC.js.map +1 -0
  5. package/dist/{chunk-HY3U3GLE.js → chunk-5EUJNLVW.js} +1 -1
  6. package/dist/chunk-5EUJNLVW.js.map +1 -0
  7. package/dist/{chunk-KXVZQLJL.js → chunk-645GZGNM.js} +3 -2
  8. package/dist/chunk-645GZGNM.js.map +1 -0
  9. package/dist/{chunk-EPHRIRAL.js → chunk-6OLAL5CW.js} +16 -1
  10. package/dist/chunk-6OLAL5CW.js.map +1 -0
  11. package/dist/{chunk-LGUGYRR4.js → chunk-HVLCOJWI.js} +11 -6
  12. package/dist/{chunk-LGUGYRR4.js.map → chunk-HVLCOJWI.js.map} +1 -1
  13. package/dist/{chunk-5VYZV33O.js → chunk-KTZDDC7M.js} +64 -79
  14. package/dist/chunk-KTZDDC7M.js.map +1 -0
  15. package/dist/{chunk-K5KZJNDP.js → chunk-ROPAEJIM.js} +2 -2
  16. package/dist/{chunk-GYIOMQMY.js → chunk-UB77WKAU.js} +305 -429
  17. package/dist/chunk-UB77WKAU.js.map +1 -0
  18. package/dist/{chunk-KV6TC5UJ.js → chunk-XIEXGFPY.js} +3 -3
  19. package/dist/conversation.d.cts +4 -3
  20. package/dist/conversation.d.ts +4 -3
  21. package/dist/device-network-portable.cjs +2 -1
  22. package/dist/device-network-portable.cjs.map +1 -1
  23. package/dist/device-network-portable.d.cts +9 -7
  24. package/dist/device-network-portable.d.ts +9 -7
  25. package/dist/device-network-portable.js +1 -1
  26. package/dist/device-network.cjs +17 -1
  27. package/dist/device-network.cjs.map +1 -1
  28. package/dist/device-network.d.cts +6 -5
  29. package/dist/device-network.d.ts +6 -5
  30. package/dist/device-network.js +2 -2
  31. package/dist/{fetchProvider-B_vva3b3.d.ts → fetchProvider-Do8Hf1BN.d.ts} +1 -1
  32. package/dist/{fetchProvider-Bz4CE3_R.d.cts → fetchProvider-tMo6gc6N.d.cts} +1 -1
  33. package/dist/index.cjs +465 -537
  34. package/dist/index.cjs.map +1 -1
  35. package/dist/index.d.cts +20 -26
  36. package/dist/index.d.ts +20 -26
  37. package/dist/index.js +47 -52
  38. package/dist/index.js.map +1 -1
  39. package/dist/{interface-3C3eG8Hn.d.cts → interface-C54gkLA3.d.ts} +3 -110
  40. package/dist/{interface-3C3eG8Hn.d.ts → interface-CECFnbzR.d.cts} +3 -110
  41. package/dist/llm-providers.cjs.map +1 -1
  42. package/dist/llm-providers.d.cts +3 -2
  43. package/dist/llm-providers.d.ts +3 -2
  44. package/dist/llm-providers.js +1 -1
  45. package/dist/llm-providers.js.map +1 -1
  46. package/dist/loop-api.cjs +88 -89
  47. package/dist/loop-api.cjs.map +1 -1
  48. package/dist/loop-api.d.cts +8 -7
  49. package/dist/loop-api.d.ts +8 -7
  50. package/dist/loop-api.js +5 -5
  51. package/dist/mobile.cjs +10 -5
  52. package/dist/mobile.cjs.map +1 -1
  53. package/dist/mobile.d.cts +6 -5
  54. package/dist/mobile.d.ts +6 -5
  55. package/dist/mobile.js +3 -3
  56. package/dist/{orchestration-portable-B4udCSVd.d.ts → orchestration-portable-CQRrnoEw.d.ts} +15 -5
  57. package/dist/{orchestration-portable-BWaCsCGK.d.cts → orchestration-portable-D4KBEYQb.d.cts} +15 -5
  58. package/dist/orchestration-portable.cjs +201 -343
  59. package/dist/orchestration-portable.cjs.map +1 -1
  60. package/dist/orchestration-portable.d.cts +6 -5
  61. package/dist/orchestration-portable.d.ts +6 -5
  62. package/dist/orchestration-portable.js +1 -1
  63. package/dist/{pairingInvite-C12n-7Ak.d.cts → pairingInvite-BmCQ-bHt.d.cts} +3 -3
  64. package/dist/{pairingInvite-CPQkuhLQ.d.ts → pairingInvite-CsfsexXC.d.ts} +3 -3
  65. package/dist/{promptConcat-VLe5SEN4.d.cts → promptConcat-BqImJtVh.d.cts} +7 -4
  66. package/dist/{promptConcat-CUEIA_3T.d.ts → promptConcat-C5SEgESi.d.ts} +7 -4
  67. package/dist/{providerRegistry-CaFK_aUd.d.ts → providerRegistry-BGrwd7Zl.d.cts} +2 -2
  68. package/dist/{providerRegistry-BDGGs5gz.d.cts → providerRegistry-Bs2lJpj9.d.ts} +2 -2
  69. package/dist/{registry-DNSEVYug.d.cts → registry-CelnriUR.d.cts} +3 -3
  70. package/dist/{registry-yGnYHWhq.d.ts → registry-DVv_RVPZ.d.ts} +3 -3
  71. package/dist/{remoteClient-DwBCoHpc.d.ts → remoteClient-D1gPizds.d.ts} +1 -1
  72. package/dist/{remoteClient-DFIyCZEv.d.cts → remoteClient-DxCHC4_Z.d.cts} +1 -1
  73. package/dist/{runtime-6EELHWVB.js → runtime-SASMRN4I.js} +3 -3
  74. package/dist/{scriptDeploymentPipeline-B1q-UhrO.d.ts → scriptDeploymentPipeline-CdDLEDMS.d.cts} +10 -1
  75. package/dist/{scriptDeploymentPipeline-XJzQyYys.d.cts → scriptDeploymentPipeline-DU6sor6Y.d.ts} +10 -1
  76. package/dist/{syncCloudDevices-C8fCUhnX.d.ts → syncCloudDevices-3RmB41sA.d.cts} +6 -2
  77. package/dist/{syncCloudDevices-BFw_c1g5.d.cts → syncCloudDevices-CSLbMESm.d.ts} +6 -2
  78. package/dist/tools.cjs +63 -0
  79. package/dist/tools.cjs.map +1 -0
  80. package/dist/tools.d.cts +12 -0
  81. package/dist/tools.d.ts +12 -0
  82. package/dist/tools.js +7 -0
  83. package/dist/tools.js.map +1 -0
  84. package/dist/{types-CcFFIk8W.d.ts → types-C29NBZ2w.d.ts} +1 -1
  85. package/dist/types-CcoJ_fdH.d.cts +110 -0
  86. package/dist/types-CcoJ_fdH.d.ts +110 -0
  87. package/dist/{types-C8gnhG9M.d.cts → types-D1rAJy9l.d.cts} +1 -1
  88. package/package.json +6 -1
  89. package/dist/chunk-5VYZV33O.js.map +0 -1
  90. package/dist/chunk-EPHRIRAL.js.map +0 -1
  91. package/dist/chunk-GYIOMQMY.js.map +0 -1
  92. package/dist/chunk-HY3U3GLE.js.map +0 -1
  93. package/dist/chunk-KXVZQLJL.js.map +0 -1
  94. /package/dist/{chunk-K5KZJNDP.js.map → chunk-ROPAEJIM.js.map} +0 -0
  95. /package/dist/{chunk-KV6TC5UJ.js.map → chunk-XIEXGFPY.js.map} +0 -0
  96. /package/dist/{runtime-6EELHWVB.js.map → runtime-SASMRN4I.js.map} +0 -0
@@ -1,3 +1,5 @@
1
+ import { A as AgentDefinition, d as AgentInstanceMeta } from './types-CcoJ_fdH.js';
2
+
1
3
  declare const ORCHESTRATION_ERROR_CODES: readonly ["UNSUPPORTED", "FORBIDDEN", "CONFLICT", "STALE_EPOCH", "NOT_FOUND", "INVALID", "EXHAUSTED", "UNAVAILABLE", "TIMEOUT", "CANCELLED", "UNKNOWN_EFFECT", "WATCH_COMPACTED", "INTERNAL"];
2
4
  type OrchestrationErrorCode = typeof ORCHESTRATION_ERROR_CODES[number];
3
5
  interface OrchestrationErrorData {
@@ -189,115 +191,6 @@ interface AgentOrchestrationClient {
189
191
  delete(reference: OrchestrationResourceReference, options?: OrchestrationDeleteOptions): Promise<OrchestrationDeleteResult>;
190
192
  }
191
193
 
192
- interface PromptNode {
193
- id: string;
194
- text?: string;
195
- /** TidGi IPrompt 兼容 */
196
- caption?: string;
197
- role?: 'system' | 'user' | 'assistant' | 'tool';
198
- enabled?: boolean;
199
- children?: PromptNode[];
200
- /** UI 溯源,可选 */
201
- source?: unknown;
202
- /**
203
- * 与插件 `dynamicPosition` 配合:用户轮次 ≥2 时将根级该节点移到列表末尾。
204
- */
205
- dynamicPosition?: 'deferToEnd';
206
- }
207
- /** 与 TidGi `IPrompt` 对齐的别名 */
208
- type IPrompt = PromptNode;
209
- interface PromptPluginConfig {
210
- id: string;
211
- toolId: string;
212
- enabled?: boolean;
213
- /** defineTool:`approval`(mode / allowPatterns / denyPatterns)等,类型见 `tools/types` */
214
- [key: string]: unknown;
215
- }
216
- interface AgentFrameworkConfig {
217
- prompts: PromptNode[];
218
- response?: unknown[];
219
- plugins: PromptPluginConfig[];
220
- }
221
- interface AgentPromptDescription {
222
- agentFrameworkConfig?: AgentFrameworkConfig;
223
- }
224
-
225
- interface AgentDefinitionModelConfig {
226
- provider?: string;
227
- model?: string;
228
- temperature?: number;
229
- maxTokens?: number;
230
- }
231
- interface ModelSelection {
232
- provider: string;
233
- model: string;
234
- [key: string]: unknown;
235
- }
236
- interface ModelParameters {
237
- temperature?: number;
238
- maxTokens?: number;
239
- topP?: number;
240
- [key: string]: unknown;
241
- }
242
- interface AiAPIConfig {
243
- default?: ModelSelection;
244
- embedding?: ModelSelection;
245
- speech?: ModelSelection;
246
- imageGeneration?: ModelSelection;
247
- transcriptions?: ModelSelection;
248
- free?: ModelSelection;
249
- modelParameters: ModelParameters;
250
- [key: string]: unknown;
251
- }
252
- interface AgentHeartbeatConfig {
253
- enabled: boolean;
254
- intervalSeconds: number;
255
- message: string;
256
- activeHoursStart?: string;
257
- activeHoursEnd?: string;
258
- }
259
- interface AgentDefinitionToolConfig {
260
- toolId: string;
261
- enabled?: boolean;
262
- parameters?: Record<string, unknown>;
263
- tags?: string[];
264
- }
265
- type HostAgentToolConfig = AgentDefinitionToolConfig;
266
- interface AgentDefinition {
267
- id: string;
268
- name: string;
269
- description: string;
270
- systemPrompt: string;
271
- tools: string[];
272
- modelConfig?: AgentDefinitionModelConfig;
273
- promptSchema?: unknown;
274
- /**
275
- * TidGi-Desktop / memeloop:prompt 树、插件、maxIterations 等(结构见 memeloop prompt 类型)
276
- * Typed as `AgentFrameworkConfig` so all hosts share a single canonical shape.
277
- */
278
- agentFrameworkConfig?: AgentFrameworkConfig;
279
- /** Host-specific explicit tool configuration. Hosts map this to prompt plugins at runtime. */
280
- agentTools?: AgentDefinitionToolConfig[];
281
- /** Host-specific avatar or icon URL. */
282
- avatarUrl?: string;
283
- /** Host-specific agent handler / framework ID. */
284
- agentFrameworkID?: string;
285
- /** Periodic auto-wake configuration. */
286
- heartbeat?: AgentHeartbeatConfig;
287
- /** Host-specific AI API config override. */
288
- aiApiConfig?: AiAPIConfig;
289
- version: string;
290
- }
291
- interface AgentInstanceMeta {
292
- instanceId: string;
293
- definitionId: string;
294
- nodeId: string;
295
- conversationId: string;
296
- createdAt: number;
297
- updatedAt: number;
298
- definitionDelta?: Partial<AgentDefinition>;
299
- }
300
-
301
194
  interface AttachmentReference {
302
195
  contentHash: string;
303
196
  filename: string;
@@ -502,4 +395,4 @@ interface FullAgentStorage extends ConversationEventStore, ConversationDirectory
502
395
  */
503
396
  type IAgentStorage = FullAgentStorage;
504
397
 
505
- export { type FullAgentStorage as $, type AttachmentReference as A, type OrchestrationObjectMetadata as B, type ConversationMeta as C, type DetailRefType as D, type OrchestrationResourceStatus as E, type OrchestrationResourceReference as F, type GetMessagesOptions as G, type HostAgentToolConfig as H, type IAgentStorage as I, type OrchestrationGetOptions as J, type OrchestrationResource as K, type ListConversationsOptions as L, type ModelParameters as M, type OrchestrationResourceQuery as N, type OrchestrationErrorData as O, type OrchestrationListOptions as P, type OrchestrationResourceList as Q, type OrchestrationWatchOptions as R, type OrchestrationWatchEvent as S, type ToolCall as T, type OrchestrationDeleteOptions as U, type VersionRange as V, type OrchestrationDeleteResult as W, type AgentFrameworkConfig as X, type IPrompt as Y, type PromptNode as Z, type AgentPromptDescription as _, type ConversationMetadataPage as a, type AgentInfrastructureInterface as a0, type AgentInstanceStore as a1, type AgentOrchestrationCapabilities as a2, type AgentOrchestrationOperation as a3, type BlobStore as a4, type ConversationDirectoryStore as a5, type DefinitionStore as a6, type IMChannel as a7, type IMChannelBinding as a8, type IMPlatformType as a9, type ImBindingStore as aa, type ImChannelBindingRecord as ab, ORCHESTRATION_ERROR_CODES as ac, type OrchestrationApplyOptions as ad, type OrchestrationBookmarkWatchEvent as ae, type OrchestrationCondition as af, type OrchestrationConditionStatus as ag, OrchestrationError as ah, type OrchestrationErrorCode as ai, type OrchestrationErrorWatchEvent as aj, type OrchestrationEvent as ak, type OrchestrationEventSeverity as al, type OrchestrationManifestMetadata as am, type OrchestrationPreconditions as an, type OrchestrationResourceWatchEvent as ao, type OrchestrationResourceWatchEventType as ap, type PromptPluginConfig as aq, isOrchestrationError as ar, toOrchestrationErrorData as as, type VersionVector as b, computeMissingVersionRanges as c, type ChatAttachmentPart as d, type ChatMessage as e, type ChatMessagePart as f, type ChatReasoningPart as g, type ChatRole as h, isConversationMeta as i, type ChatTextPart as j, type ChatToolCallPart as k, type ChatToolResultPart as l, type ConversationQueryMode as m, type DetailReference as n, type ConversationEventStore as o, type AgentDefinition as p, type AgentDefinitionModelConfig as q, type AgentDefinitionToolConfig as r, type AgentHeartbeatConfig as s, type AgentInstanceMeta as t, type AiAPIConfig as u, type ModelSelection as v, type AgentOrchestrationClient as w, type OrchestrationResourceManifest as x, type OrchestrationOwnerReference as y, type OrchestrationTypeMeta as z };
398
+ export { ORCHESTRATION_ERROR_CODES as $, type AttachmentReference as A, type OrchestrationResourceList as B, type ConversationMeta as C, type DetailRefType as D, type OrchestrationWatchOptions as E, type OrchestrationWatchEvent as F, type GetMessagesOptions as G, type OrchestrationDeleteOptions as H, type IAgentStorage as I, type OrchestrationDeleteResult as J, type FullAgentStorage as K, type ListConversationsOptions as L, type AgentInfrastructureInterface as M, type AgentInstanceStore as N, type OrchestrationErrorData as O, type AgentOrchestrationCapabilities as P, type AgentOrchestrationOperation as Q, type BlobStore as R, type ConversationDirectoryStore as S, type ToolCall as T, type DefinitionStore as U, type VersionRange as V, type IMChannel as W, type IMChannelBinding as X, type IMPlatformType as Y, type ImBindingStore as Z, type ImChannelBindingRecord as _, type ConversationMetadataPage as a, type OrchestrationApplyOptions as a0, type OrchestrationBookmarkWatchEvent as a1, type OrchestrationCondition as a2, type OrchestrationConditionStatus as a3, OrchestrationError as a4, type OrchestrationErrorCode as a5, type OrchestrationErrorWatchEvent as a6, type OrchestrationEvent as a7, type OrchestrationEventSeverity as a8, type OrchestrationManifestMetadata as a9, type OrchestrationPreconditions as aa, type OrchestrationResourceWatchEvent as ab, type OrchestrationResourceWatchEventType as ac, isOrchestrationError as ad, toOrchestrationErrorData as ae, type VersionVector as b, computeMissingVersionRanges as c, type ChatAttachmentPart as d, type ChatMessage as e, type ChatMessagePart as f, type ChatReasoningPart as g, type ChatRole as h, isConversationMeta as i, type ChatTextPart as j, type ChatToolCallPart as k, type ChatToolResultPart as l, type ConversationQueryMode as m, type DetailReference as n, type ConversationEventStore as o, type AgentOrchestrationClient as p, type OrchestrationResourceManifest as q, type OrchestrationOwnerReference as r, type OrchestrationTypeMeta as s, type OrchestrationObjectMetadata as t, type OrchestrationResourceStatus as u, type OrchestrationResourceReference as v, type OrchestrationGetOptions as w, type OrchestrationResource as x, type OrchestrationResourceQuery as y, type OrchestrationListOptions as z };
@@ -1,3 +1,5 @@
1
+ import { A as AgentDefinition, d as AgentInstanceMeta } from './types-CcoJ_fdH.cjs';
2
+
1
3
  declare const ORCHESTRATION_ERROR_CODES: readonly ["UNSUPPORTED", "FORBIDDEN", "CONFLICT", "STALE_EPOCH", "NOT_FOUND", "INVALID", "EXHAUSTED", "UNAVAILABLE", "TIMEOUT", "CANCELLED", "UNKNOWN_EFFECT", "WATCH_COMPACTED", "INTERNAL"];
2
4
  type OrchestrationErrorCode = typeof ORCHESTRATION_ERROR_CODES[number];
3
5
  interface OrchestrationErrorData {
@@ -189,115 +191,6 @@ interface AgentOrchestrationClient {
189
191
  delete(reference: OrchestrationResourceReference, options?: OrchestrationDeleteOptions): Promise<OrchestrationDeleteResult>;
190
192
  }
191
193
 
192
- interface PromptNode {
193
- id: string;
194
- text?: string;
195
- /** TidGi IPrompt 兼容 */
196
- caption?: string;
197
- role?: 'system' | 'user' | 'assistant' | 'tool';
198
- enabled?: boolean;
199
- children?: PromptNode[];
200
- /** UI 溯源,可选 */
201
- source?: unknown;
202
- /**
203
- * 与插件 `dynamicPosition` 配合:用户轮次 ≥2 时将根级该节点移到列表末尾。
204
- */
205
- dynamicPosition?: 'deferToEnd';
206
- }
207
- /** 与 TidGi `IPrompt` 对齐的别名 */
208
- type IPrompt = PromptNode;
209
- interface PromptPluginConfig {
210
- id: string;
211
- toolId: string;
212
- enabled?: boolean;
213
- /** defineTool:`approval`(mode / allowPatterns / denyPatterns)等,类型见 `tools/types` */
214
- [key: string]: unknown;
215
- }
216
- interface AgentFrameworkConfig {
217
- prompts: PromptNode[];
218
- response?: unknown[];
219
- plugins: PromptPluginConfig[];
220
- }
221
- interface AgentPromptDescription {
222
- agentFrameworkConfig?: AgentFrameworkConfig;
223
- }
224
-
225
- interface AgentDefinitionModelConfig {
226
- provider?: string;
227
- model?: string;
228
- temperature?: number;
229
- maxTokens?: number;
230
- }
231
- interface ModelSelection {
232
- provider: string;
233
- model: string;
234
- [key: string]: unknown;
235
- }
236
- interface ModelParameters {
237
- temperature?: number;
238
- maxTokens?: number;
239
- topP?: number;
240
- [key: string]: unknown;
241
- }
242
- interface AiAPIConfig {
243
- default?: ModelSelection;
244
- embedding?: ModelSelection;
245
- speech?: ModelSelection;
246
- imageGeneration?: ModelSelection;
247
- transcriptions?: ModelSelection;
248
- free?: ModelSelection;
249
- modelParameters: ModelParameters;
250
- [key: string]: unknown;
251
- }
252
- interface AgentHeartbeatConfig {
253
- enabled: boolean;
254
- intervalSeconds: number;
255
- message: string;
256
- activeHoursStart?: string;
257
- activeHoursEnd?: string;
258
- }
259
- interface AgentDefinitionToolConfig {
260
- toolId: string;
261
- enabled?: boolean;
262
- parameters?: Record<string, unknown>;
263
- tags?: string[];
264
- }
265
- type HostAgentToolConfig = AgentDefinitionToolConfig;
266
- interface AgentDefinition {
267
- id: string;
268
- name: string;
269
- description: string;
270
- systemPrompt: string;
271
- tools: string[];
272
- modelConfig?: AgentDefinitionModelConfig;
273
- promptSchema?: unknown;
274
- /**
275
- * TidGi-Desktop / memeloop:prompt 树、插件、maxIterations 等(结构见 memeloop prompt 类型)
276
- * Typed as `AgentFrameworkConfig` so all hosts share a single canonical shape.
277
- */
278
- agentFrameworkConfig?: AgentFrameworkConfig;
279
- /** Host-specific explicit tool configuration. Hosts map this to prompt plugins at runtime. */
280
- agentTools?: AgentDefinitionToolConfig[];
281
- /** Host-specific avatar or icon URL. */
282
- avatarUrl?: string;
283
- /** Host-specific agent handler / framework ID. */
284
- agentFrameworkID?: string;
285
- /** Periodic auto-wake configuration. */
286
- heartbeat?: AgentHeartbeatConfig;
287
- /** Host-specific AI API config override. */
288
- aiApiConfig?: AiAPIConfig;
289
- version: string;
290
- }
291
- interface AgentInstanceMeta {
292
- instanceId: string;
293
- definitionId: string;
294
- nodeId: string;
295
- conversationId: string;
296
- createdAt: number;
297
- updatedAt: number;
298
- definitionDelta?: Partial<AgentDefinition>;
299
- }
300
-
301
194
  interface AttachmentReference {
302
195
  contentHash: string;
303
196
  filename: string;
@@ -502,4 +395,4 @@ interface FullAgentStorage extends ConversationEventStore, ConversationDirectory
502
395
  */
503
396
  type IAgentStorage = FullAgentStorage;
504
397
 
505
- export { type FullAgentStorage as $, type AttachmentReference as A, type OrchestrationObjectMetadata as B, type ConversationMeta as C, type DetailRefType as D, type OrchestrationResourceStatus as E, type OrchestrationResourceReference as F, type GetMessagesOptions as G, type HostAgentToolConfig as H, type IAgentStorage as I, type OrchestrationGetOptions as J, type OrchestrationResource as K, type ListConversationsOptions as L, type ModelParameters as M, type OrchestrationResourceQuery as N, type OrchestrationErrorData as O, type OrchestrationListOptions as P, type OrchestrationResourceList as Q, type OrchestrationWatchOptions as R, type OrchestrationWatchEvent as S, type ToolCall as T, type OrchestrationDeleteOptions as U, type VersionRange as V, type OrchestrationDeleteResult as W, type AgentFrameworkConfig as X, type IPrompt as Y, type PromptNode as Z, type AgentPromptDescription as _, type ConversationMetadataPage as a, type AgentInfrastructureInterface as a0, type AgentInstanceStore as a1, type AgentOrchestrationCapabilities as a2, type AgentOrchestrationOperation as a3, type BlobStore as a4, type ConversationDirectoryStore as a5, type DefinitionStore as a6, type IMChannel as a7, type IMChannelBinding as a8, type IMPlatformType as a9, type ImBindingStore as aa, type ImChannelBindingRecord as ab, ORCHESTRATION_ERROR_CODES as ac, type OrchestrationApplyOptions as ad, type OrchestrationBookmarkWatchEvent as ae, type OrchestrationCondition as af, type OrchestrationConditionStatus as ag, OrchestrationError as ah, type OrchestrationErrorCode as ai, type OrchestrationErrorWatchEvent as aj, type OrchestrationEvent as ak, type OrchestrationEventSeverity as al, type OrchestrationManifestMetadata as am, type OrchestrationPreconditions as an, type OrchestrationResourceWatchEvent as ao, type OrchestrationResourceWatchEventType as ap, type PromptPluginConfig as aq, isOrchestrationError as ar, toOrchestrationErrorData as as, type VersionVector as b, computeMissingVersionRanges as c, type ChatAttachmentPart as d, type ChatMessage as e, type ChatMessagePart as f, type ChatReasoningPart as g, type ChatRole as h, isConversationMeta as i, type ChatTextPart as j, type ChatToolCallPart as k, type ChatToolResultPart as l, type ConversationQueryMode as m, type DetailReference as n, type ConversationEventStore as o, type AgentDefinition as p, type AgentDefinitionModelConfig as q, type AgentDefinitionToolConfig as r, type AgentHeartbeatConfig as s, type AgentInstanceMeta as t, type AiAPIConfig as u, type ModelSelection as v, type AgentOrchestrationClient as w, type OrchestrationResourceManifest as x, type OrchestrationOwnerReference as y, type OrchestrationTypeMeta as z };
398
+ export { ORCHESTRATION_ERROR_CODES as $, type AttachmentReference as A, type OrchestrationResourceList as B, type ConversationMeta as C, type DetailRefType as D, type OrchestrationWatchOptions as E, type OrchestrationWatchEvent as F, type GetMessagesOptions as G, type OrchestrationDeleteOptions as H, type IAgentStorage as I, type OrchestrationDeleteResult as J, type FullAgentStorage as K, type ListConversationsOptions as L, type AgentInfrastructureInterface as M, type AgentInstanceStore as N, type OrchestrationErrorData as O, type AgentOrchestrationCapabilities as P, type AgentOrchestrationOperation as Q, type BlobStore as R, type ConversationDirectoryStore as S, type ToolCall as T, type DefinitionStore as U, type VersionRange as V, type IMChannel as W, type IMChannelBinding as X, type IMPlatformType as Y, type ImBindingStore as Z, type ImChannelBindingRecord as _, type ConversationMetadataPage as a, type OrchestrationApplyOptions as a0, type OrchestrationBookmarkWatchEvent as a1, type OrchestrationCondition as a2, type OrchestrationConditionStatus as a3, OrchestrationError as a4, type OrchestrationErrorCode as a5, type OrchestrationErrorWatchEvent as a6, type OrchestrationEvent as a7, type OrchestrationEventSeverity as a8, type OrchestrationManifestMetadata as a9, type OrchestrationPreconditions as aa, type OrchestrationResourceWatchEvent as ab, type OrchestrationResourceWatchEventType as ac, isOrchestrationError as ad, toOrchestrationErrorData as ae, type VersionVector as b, computeMissingVersionRanges as c, type ChatAttachmentPart as d, type ChatMessage as e, type ChatMessagePart as f, type ChatReasoningPart as g, type ChatRole as h, isConversationMeta as i, type ChatTextPart as j, type ChatToolCallPart as k, type ChatToolResultPart as l, type ConversationQueryMode as m, type DetailReference as n, type ConversationEventStore as o, type AgentOrchestrationClient as p, type OrchestrationResourceManifest as q, type OrchestrationOwnerReference as r, type OrchestrationTypeMeta as s, type OrchestrationObjectMetadata as t, type OrchestrationResourceStatus as u, type OrchestrationResourceReference as v, type OrchestrationGetOptions as w, type OrchestrationResource as x, type OrchestrationResourceQuery as y, type OrchestrationListOptions as z };
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/llm-providers.ts","../src/llm/fetchProvider.ts"],"sourcesContent":["/**\n * Pre-built, config-driven LLM providers.\n *\n * Exposes every major @ai-sdk/* provider through a single entry point so hosts\n * can switch providers by changing a string in user config — no need to install\n * AI SDK packages individually.\n *\n * ```ts\n * import { createLLMProvider } from 'memeloop/llm-providers';\n *\n * const provider = createLLMProvider({\n * provider: 'openai',\n * baseUrl: 'https://api.openai.com/v1',\n * apiKey: process.env.OPENAI_API_KEY,\n * model: 'gpt-4o',\n * });\n * ```\n *\n * For custom providers, or to keep bundle size minimal, use the generic\n * `createFetchLLMProvider` exported from `memeloop` and supply your own\n * `createModel` factory.\n *\n * `createLLMProvider` is async because it dynamically imports the selected\n * AI SDK provider on first use. Host bundlers can then decide whether to\n * bundle, split, or externalize those provider dependencies for their runtime.\n */\n\nimport type { LanguageModel } from 'ai';\n\nimport { createFetchLLMProvider } from './llm/fetchProvider.js';\nimport type { ILLMProvider } from './types.js';\n\n// ─── Provider ids ──────────────────────────────────────────────────────\n\nexport type LLMProviderId =\n | 'openai'\n | 'anthropic'\n | 'google'\n | 'deepseek'\n | 'groq'\n | 'mistral'\n | 'cohere'\n | 'xai'\n | 'togetherai'\n | 'perplexity'\n | 'azure'\n | 'google-vertex'\n | 'ollama';\n\n// ─── Config ────────────────────────────────────────────────────────────\n\nexport interface LLMProviderConfig {\n /** Provider id. */\n provider: LLMProviderId;\n /** Display name (defaults to provider id). */\n name?: string;\n /** API key or credential. */\n apiKey?: string;\n /** Override the provider's default API base URL. */\n baseUrl?: string;\n /** Default model id. When omitted a provider-specific default is used. */\n model?: string;\n /** Provider-specific options passed through to the AI SDK factory. */\n options?: Record<string, unknown>;\n /** OpenAI wire API selected for this model. Defaults to Chat Completions. */\n openAIApiMode?: 'chat-completions' | 'responses';\n}\n\n/** A provider entry from any host config (loose shape used by CLI/Desktop). */\nexport interface ConfiguredProviderEntry {\n /** Provider id matching LLMProviderId. */\n name: string;\n /** API base URL. */\n baseUrl?: string;\n /** API key. */\n apiKey?: string;\n /** Provider-specific options. */\n options?: Record<string, unknown>;\n /** Available models; the first key is used as the default model. */\n models?: Record<string, { name: string }>;\n}\n\n// ─── Defaults ──────────────────────────────────────────────────────────\n\nconst defaultModels: Record<LLMProviderId, string> = {\n openai: 'gpt-4o-mini',\n anthropic: 'claude-3-5-sonnet-20241022',\n google: 'gemini-1.5-flash',\n deepseek: 'deepseek-chat',\n groq: 'llama-3.1-8b-instant',\n mistral: 'mistral-small-latest',\n cohere: 'command-r-plus',\n xai: 'grok-beta',\n togetherai: 'meta-llama/Llama-3.1-8B-Instruct-Turbo',\n perplexity: 'sonar',\n azure: '',\n 'google-vertex': '',\n ollama: 'llama3.1',\n};\n\n// ─── Unified factory ───────────────────────────────────────────────────\n\n/**\n * Dynamic loader for AI SDK provider factories.\n *\n * Each provider is imported on demand so that hosts only load the SDK packages\n * they actually use. This avoids eagerly loading Node-only providers in hosts\n * that bundle or externalize this entry for multiple runtimes.\n */\nasync function loadProviderFactory(\n provider: LLMProviderId,\n openAIApiMode: LLMProviderConfig['openAIApiMode'],\n): Promise<\n (\n apiKey: string | undefined,\n baseUrl: string | undefined,\n options: Record<string, unknown> | undefined,\n ) => (modelId: string) => LanguageModel\n> {\n switch (provider) {\n case 'openai': {\n const { createOpenAI } = await import('@ai-sdk/openai');\n return (apiKey, baseUrl, options) => {\n const sdk = createOpenAI({ apiKey, baseURL: baseUrl, ...options });\n // Keep Chat Completions as the compatibility default. Hosts may opt a\n // specific model into Responses without splitting a shared provider.\n return (modelId) =>\n (openAIApiMode === 'responses'\n ? sdk.responses(modelId)\n : sdk.chat(modelId)) as unknown as LanguageModel;\n };\n }\n case 'anthropic': {\n const { createAnthropic } = await import('@ai-sdk/anthropic');\n return (apiKey, baseUrl, options) => {\n const sdk = createAnthropic({ apiKey, baseURL: baseUrl, ...options });\n return (modelId) => sdk(modelId) as unknown as LanguageModel;\n };\n }\n case 'google': {\n const { createGoogleGenerativeAI } = await import('@ai-sdk/google');\n return (apiKey, baseUrl, options) => {\n const sdk = createGoogleGenerativeAI({ apiKey, baseURL: baseUrl, ...options });\n return (modelId) => sdk(modelId) as unknown as LanguageModel;\n };\n }\n case 'deepseek': {\n const { createDeepSeek } = await import('@ai-sdk/deepseek');\n return (apiKey, baseUrl, options) => {\n const sdk = createDeepSeek({ apiKey, baseURL: baseUrl, ...options });\n return (modelId) => sdk(modelId) as unknown as LanguageModel;\n };\n }\n case 'groq': {\n const { createGroq } = await import('@ai-sdk/groq');\n return (apiKey, baseUrl, options) => {\n const sdk = createGroq({ apiKey, baseURL: baseUrl, ...options });\n return (modelId) => sdk(modelId) as unknown as LanguageModel;\n };\n }\n case 'mistral': {\n const { createMistral } = await import('@ai-sdk/mistral');\n return (apiKey, baseUrl, options) => {\n const sdk = createMistral({ apiKey, baseURL: baseUrl, ...options });\n return (modelId) => sdk(modelId) as unknown as LanguageModel;\n };\n }\n case 'cohere': {\n const { createCohere } = await import('@ai-sdk/cohere');\n return (apiKey, baseUrl, options) => {\n const sdk = createCohere({ apiKey, baseURL: baseUrl, ...options });\n return (modelId) => sdk(modelId) as unknown as LanguageModel;\n };\n }\n case 'xai': {\n const { createXai } = await import('@ai-sdk/xai');\n return (apiKey, baseUrl, options) => {\n const sdk = createXai({ apiKey, baseURL: baseUrl, ...options });\n return (modelId) => sdk(modelId) as unknown as LanguageModel;\n };\n }\n case 'togetherai': {\n const { createTogetherAI } = await import('@ai-sdk/togetherai');\n return (apiKey, baseUrl, options) => {\n const sdk = createTogetherAI({ apiKey, baseURL: baseUrl, ...options });\n return (modelId) => sdk(modelId) as unknown as LanguageModel;\n };\n }\n case 'perplexity': {\n const { createPerplexity } = await import('@ai-sdk/perplexity');\n return (apiKey, baseUrl, options) => {\n const sdk = createPerplexity({ apiKey, baseURL: baseUrl, ...options });\n return (modelId) => sdk(modelId) as unknown as LanguageModel;\n };\n }\n case 'azure': {\n const { createAzure } = await import('@ai-sdk/azure');\n return (apiKey, _baseUrl, options) => {\n const sdk = createAzure({ apiKey, ...options });\n return (modelId) => sdk(modelId) as unknown as LanguageModel;\n };\n }\n case 'google-vertex': {\n const { createVertex } = await import('@ai-sdk/google-vertex');\n return (_apiKey, _baseUrl, options) => {\n const sdk = createVertex({ ...options });\n return (modelId) => sdk(modelId) as unknown as LanguageModel;\n };\n }\n case 'ollama': {\n const { createOllama } = await import('ollama-ai-provider-v2');\n return (_apiKey, baseUrl, options) => {\n const sdk = createOllama({ baseURL: baseUrl, ...options });\n return (modelId) => sdk(modelId) as unknown as LanguageModel;\n };\n }\n default: {\n const exhaustive: never = provider;\n throw new Error(`Unsupported provider: ${String(exhaustive)}`);\n }\n }\n}\n\n/**\n * Create an `ILLMProvider` from a config-driven provider id.\n *\n * Switches implementation based on `config.provider`.\n * The selected provider's AI SDK package is loaded on demand, so hosts only\n * pay the dependency cost for providers they actually use.\n */\nexport async function createLLMProvider(config: LLMProviderConfig): Promise<ILLMProvider> {\n const name = config.name ?? config.provider;\n\n function resolveModel(modelId?: string): string {\n return modelId ?? config.model ?? defaultModels[config.provider] ?? '';\n }\n\n const createProviderModel = await loadProviderFactory(config.provider, config.openAIApiMode);\n const modelFactory = createProviderModel(config.apiKey, config.baseUrl, config.options);\n\n return createFetchLLMProvider({\n name,\n modelId: resolveModel(),\n createModel: (modelId?: string) => modelFactory(resolveModel(modelId)),\n });\n}\n\n/** Fallback OpenAI-compatible provider for unknown provider ids. */\nasync function createOpenAICompatibleProvider(\n config: Omit<LLMProviderConfig, 'provider'> & { provider: string },\n): Promise<ILLMProvider> {\n const name = config.name ?? config.provider;\n const { createOpenAICompatible } = await import('@ai-sdk/openai-compatible');\n\n function resolveModel(modelId?: string): string {\n return modelId ?? config.model ?? 'gpt-4o-mini';\n }\n\n const sdk = createOpenAICompatible({\n name: config.provider,\n baseURL: config.baseUrl ?? 'https://api.openai.com/v1',\n apiKey: config.apiKey,\n ...config.options,\n });\n\n return createFetchLLMProvider({\n name,\n modelId: resolveModel(),\n createModel: (modelId?: string) => sdk(resolveModel(modelId)) as unknown as LanguageModel,\n });\n}\n\n// ─── Convenience per-provider factories ────────────────────────────────\n\ntype ProviderConfigWithoutId = Omit<LLMProviderConfig, 'provider'>;\n\n/** Convenience factory for OpenAI. */\nexport function createOpenaiProvider(config: ProviderConfigWithoutId = {}): Promise<ILLMProvider> {\n return createLLMProvider({ provider: 'openai', ...config });\n}\n\n/** Convenience factory for Anthropic. */\nexport function createAnthropicProvider(\n config: ProviderConfigWithoutId = {},\n): Promise<ILLMProvider> {\n return createLLMProvider({ provider: 'anthropic', ...config });\n}\n\n/** Convenience factory for Google Generative AI. */\nexport function createGoogleProvider(config: ProviderConfigWithoutId = {}): Promise<ILLMProvider> {\n return createLLMProvider({ provider: 'google', ...config });\n}\n\n/** Convenience factory for DeepSeek. */\nexport function createDeepseekProvider(\n config: ProviderConfigWithoutId = {},\n): Promise<ILLMProvider> {\n return createLLMProvider({ provider: 'deepseek', ...config });\n}\n\n/** Convenience factory for Groq. */\nexport function createGroqProvider(config: ProviderConfigWithoutId = {}): Promise<ILLMProvider> {\n return createLLMProvider({ provider: 'groq', ...config });\n}\n\n/** Convenience factory for Mistral. */\nexport function createMistralProvider(config: ProviderConfigWithoutId = {}): Promise<ILLMProvider> {\n return createLLMProvider({ provider: 'mistral', ...config });\n}\n\n/** Convenience factory for Cohere. */\nexport function createCohereProvider(config: ProviderConfigWithoutId = {}): Promise<ILLMProvider> {\n return createLLMProvider({ provider: 'cohere', ...config });\n}\n\n/** Convenience factory for xAI. */\nexport function createXaiProvider(config: ProviderConfigWithoutId = {}): Promise<ILLMProvider> {\n return createLLMProvider({ provider: 'xai', ...config });\n}\n\n/** Convenience factory for Together AI. */\nexport function createTogetheraiProvider(\n config: ProviderConfigWithoutId = {},\n): Promise<ILLMProvider> {\n return createLLMProvider({ provider: 'togetherai', ...config });\n}\n\n/** Convenience factory for Perplexity. */\nexport function createPerplexityProvider(\n config: ProviderConfigWithoutId = {},\n): Promise<ILLMProvider> {\n return createLLMProvider({ provider: 'perplexity', ...config });\n}\n\n/** Convenience factory for Azure OpenAI. */\nexport function createAzureProvider(config: ProviderConfigWithoutId = {}): Promise<ILLMProvider> {\n return createLLMProvider({ provider: 'azure', ...config });\n}\n\n/** Convenience factory for Google Vertex. */\nexport function createGoogleVertexProvider(\n config: ProviderConfigWithoutId = {},\n): Promise<ILLMProvider> {\n return createLLMProvider({ provider: 'google-vertex', ...config });\n}\n\n/** Convenience factory for Ollama. */\nexport function createOllamaProvider(config: ProviderConfigWithoutId = {}): Promise<ILLMProvider> {\n return createLLMProvider({ provider: 'ollama', ...config });\n}\n\n// ─── Host config mapping ───────────────────────────────────────────────\n\n/**\n * Resolve the default model name from a host config entry.\n * Uses the first key in `entry.models` if present, otherwise falls back\n * to the provider-specific default.\n */\nexport function resolveProviderModelId(entry: ConfiguredProviderEntry): string {\n const firstModelKey = entry.models ? Object.keys(entry.models)[0] : undefined;\n if (firstModelKey) {\n return `${entry.name}/${firstModelKey}`;\n }\n return entry.name;\n}\n\n/**\n * Convert a loose host config entry into an `ILLMProvider` via the core registry.\n * Provider id is taken from `entry.name`. Model id is inferred from `entry.models`\n * or the provider-specific default.\n *\n * Unknown provider names fall back to OpenAI-compatible mode, preserving CLI/Desktop\n * behavior where arbitrary OpenAI-compatible endpoints can be configured with any name.\n */\nexport function createProviderFromEntry(entry: ConfiguredProviderEntry): Promise<ILLMProvider> {\n const providerId = entry.name as LLMProviderId;\n const firstModelKey = entry.models ? Object.keys(entry.models)[0] : undefined;\n const firstModelName = firstModelKey ? entry.models?.[firstModelKey]?.name : undefined;\n const configWithoutProvider = {\n name: entry.name,\n apiKey: entry.apiKey,\n baseUrl: entry.baseUrl,\n model: firstModelName,\n options: entry.options,\n };\n\n if (!defaultModels[providerId]) {\n return createOpenAICompatibleProvider({ provider: entry.name, ...configWithoutProvider });\n }\n\n return createLLMProvider({\n provider: providerId,\n ...configWithoutProvider,\n });\n}\n","/**\n * Provider-agnostic LLM provider — wraps a current Vercel AI SDK LanguageModel.\n *\n * The core does NOT depend on @ai-sdk/openai or any specific provider.\n * Hosts inject their own `createModel` factory:\n *\n * import { createOpenAI } from '@ai-sdk/openai';\n * const openai = createOpenAI({ baseURL: '...', apiKey: '...' });\n * const provider = createFetchLLMProvider({\n * name: 'openai',\n * createModel: (id) => openai(id ?? 'gpt-4o-mini'),\n * });\n *\n * Or for Anthropic:\n * import { createAnthropic } from '@ai-sdk/anthropic';\n * const anthropic = createAnthropic({ apiKey: '...' });\n * const provider = createFetchLLMProvider({\n * name: 'claude',\n * createModel: (id) => anthropic(id ?? 'claude-3-5-sonnet-20241022'),\n * });\n *\n * Works with every @ai-sdk/* provider: openai, anthropic, google, deepseek,\n * cohere, mistral, azure, bedrock, groq, ollama, openrouter, together, etc.\n */\n\nimport type { JSONValue, LanguageModel } from 'ai';\nimport { generateText, streamText } from 'ai';\n\nimport type { ILLMProvider } from '../types.js';\n\nexport interface FetchLLMChatRequest {\n messages?: Array<{ role: string; content: string }>;\n model?: string;\n stream?: boolean;\n /** Legacy OpenAI-compatible spelling retained for host adapters. */\n max_tokens?: number;\n /** AI SDK spelling. Takes precedence over max_tokens. */\n maxOutputTokens?: number;\n temperature?: number;\n topP?: number;\n providerOptions?: Record<string, Record<string, JSONValue>>;\n system?: string;\n abortSignal?: AbortSignal;\n}\n\nexport function resolveFetchLLMCallSettings(body: FetchLLMChatRequest): {\n maxOutputTokens: number | undefined;\n temperature: number | undefined;\n topP: number | undefined;\n providerOptions: Record<string, Record<string, JSONValue>> | undefined;\n abortSignal: AbortSignal | undefined;\n} {\n return {\n maxOutputTokens: body.maxOutputTokens ?? body.max_tokens,\n temperature: body.temperature,\n topP: body.topP,\n providerOptions: body.providerOptions,\n abortSignal: body.abortSignal,\n };\n}\n\n// ─── Config ────────────────────────────────────────────────────────────\n\nexport interface FetchLLMProviderConfig {\n /** Display name. */\n name: string;\n /** Serializable default model identity for scheduling and audit records. */\n modelId?: string;\n /**\n * Factory: given an optional model id, return a LanguageModel from any @ai-sdk/* provider.\n * The factory is responsible for picking a default model when `modelId` is omitted.\n */\n createModel: (modelId?: string) => LanguageModel;\n}\n\n// ─── Factory ───────────────────────────────────────────────────────────\n\n/**\n * Create an `ILLMProvider` that delegates to the Vercel AI SDK.\n *\n * Provider-agnostic — hosts supply their own `createModel` factory.\n * Supports every @ai-sdk/* provider (OpenAI, Anthropic, Google, DeepSeek,\n * Groq, Ollama, OpenRouter, Together, Bedrock, Azure, Mistral, Cohere…).\n *\n * @example\n * ```ts\n * import { createOpenAI } from '@ai-sdk/openai';\n * const openai = createOpenAI({ baseURL: 'https://api.openai.com/v1', apiKey });\n * const provider = createFetchLLMProvider({\n * name: 'openai',\n * createModel: (modelId) => openai(modelId ?? 'gpt-4o-mini'),\n * });\n * ```\n */\nexport function createFetchLLMProvider(config: FetchLLMProviderConfig): ILLMProvider {\n return {\n name: config.name,\n ...(config.modelId !== undefined ? { modelId: config.modelId } : {}),\n // Store the factory so hosts can introspect or extend\n model: config.createModel as unknown as LanguageModel,\n async chat(request: unknown) {\n const body = (typeof request === 'object' && request !== null ? request : {}) as FetchLLMChatRequest;\n\n const model = config.createModel(body.model);\n const specificationVersion = (\n model as { specificationVersion?: unknown } | null\n )?.specificationVersion;\n if (\n model === null ||\n typeof model !== 'object' ||\n !['v2', 'v3', 'v4'].includes(String(specificationVersion))\n ) {\n throw new Error(\n `LLM provider '${config.name}' returned an incompatible AI SDK model for '${\n typeof body.model === 'string' ? body.model : (config.modelId ?? 'default')\n }' (expected specificationVersion v2, v3, or v4; received ${String(specificationVersion)})`,\n );\n }\n\n const systemMessages = (body.messages ?? [])\n .filter((message) => message.role === 'system')\n .map((message) => message.content);\n const messages = (body.messages ?? [])\n .filter((message) => message.role !== 'system')\n .map((message) => {\n // AI SDK model messages do not accept a bare textual tool role.\n // MemeLoop stores tool results as role='tool'; promote them to user\n // messages while preserving the result text in conversation history.\n const role = message.role === 'tool' ? 'user' : (message.role as 'user' | 'assistant');\n return {\n role,\n content: message.content,\n };\n });\n\n const system = body.system ?? (\n systemMessages.length > 0 ? systemMessages.join('\\n\\n') : undefined\n );\n const { abortSignal, maxOutputTokens, providerOptions, temperature, topP } = resolveFetchLLMCallSettings(body);\n\n if (body.stream !== false) {\n let streamingError: unknown;\n const result = streamText({\n model,\n instructions: system,\n messages,\n maxOutputTokens,\n temperature,\n topP,\n providerOptions,\n abortSignal,\n onError: ({ error }) => {\n streamingError = error;\n },\n });\n return (async function*() {\n for await (const chunk of result.textStream) {\n yield chunk;\n }\n if (streamingError !== undefined) {\n throw streamingError instanceof Error\n ? streamingError\n : new Error('The model stream failed', { cause: streamingError });\n }\n })();\n }\n\n const result = await generateText({\n model,\n instructions: system,\n messages,\n maxOutputTokens,\n temperature,\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AAkB;AAAA,IACvB,UAAU;AAAA,IACV,GAAG;AAAA,EACL,CAAC;AACH;","names":["result"]}
1
+ {"version":3,"sources":["../src/llm-providers.ts","../src/llm/fetchProvider.ts"],"sourcesContent":["/**\n * Pre-built, config-driven LLM providers.\n *\n * Exposes every major @ai-sdk/* provider through a single entry point so hosts\n * can switch providers by changing a string in user config — no need to install\n * AI SDK packages individually.\n *\n * ```ts\n * import { createLLMProvider } from 'memeloop/llm-providers';\n *\n * const provider = createLLMProvider({\n * provider: 'openai',\n * baseUrl: 'https://api.openai.com/v1',\n * apiKey: process.env.OPENAI_API_KEY,\n * model: 'gpt-4o',\n * });\n * ```\n *\n * For custom providers, or to keep bundle size minimal, use the generic\n * `createFetchLLMProvider` exported from `memeloop` and supply your own\n * `createModel` factory.\n *\n * `createLLMProvider` is async because it dynamically imports the selected\n * AI SDK provider on first use. Host bundlers can then decide whether to\n * bundle, split, or externalize those provider dependencies for their runtime.\n */\n\nimport type { LanguageModel } from 'ai';\n\nimport { createFetchLLMProvider } from './llm/fetchProvider.js';\nimport type { ILLMProvider } from './types.js';\n\n// ─── Provider ids ──────────────────────────────────────────────────────\n\nexport type LLMProviderId =\n | 'openai'\n | 'anthropic'\n | 'google'\n | 'deepseek'\n | 'groq'\n | 'mistral'\n | 'cohere'\n | 'xai'\n | 'togetherai'\n | 'perplexity'\n | 'azure'\n | 'google-vertex'\n | 'ollama';\n\n// ─── Config ────────────────────────────────────────────────────────────\n\nexport interface LLMProviderConfig {\n /** Provider id. */\n provider: LLMProviderId;\n /** Display name (defaults to provider id). */\n name?: string;\n /** API key or credential. */\n apiKey?: string;\n /** Override the provider's default API base URL. */\n baseUrl?: string;\n /** Default model id. When omitted a provider-specific default is used. */\n model?: string;\n /** Provider-specific options passed through to the AI SDK factory. */\n options?: Record<string, unknown>;\n /** OpenAI wire API selected for this model. Defaults to Chat Completions. */\n openAIApiMode?: 'chat-completions' | 'responses';\n}\n\n/** A provider entry from any host config (loose shape used by CLI/Desktop). */\nexport interface ConfiguredProviderEntry {\n /** Provider id matching LLMProviderId. */\n name: string;\n /** API base URL. */\n baseUrl?: string;\n /** API key. */\n apiKey?: string;\n /** Provider-specific options. */\n options?: Record<string, unknown>;\n /** Available models; the first key is used as the default model. */\n models?: Record<string, { name: string }>;\n}\n\n// ─── Defaults ──────────────────────────────────────────────────────────\n\nconst defaultModels: Record<LLMProviderId, string> = {\n openai: 'gpt-4o-mini',\n anthropic: 'claude-3-5-sonnet-20241022',\n google: 'gemini-1.5-flash',\n deepseek: 'deepseek-chat',\n groq: 'llama-3.1-8b-instant',\n mistral: 'mistral-small-latest',\n cohere: 'command-r-plus',\n xai: 'grok-beta',\n togetherai: 'meta-llama/Llama-3.1-8B-Instruct-Turbo',\n perplexity: 'sonar',\n azure: '',\n 'google-vertex': '',\n ollama: 'llama3.1',\n};\n\n// ─── Unified factory ───────────────────────────────────────────────────\n\n/**\n * Dynamic loader for AI SDK provider factories.\n *\n * Each provider is imported on demand so that hosts only load the SDK packages\n * they actually use. This avoids eagerly loading Node-only providers in hosts\n * that bundle or externalize this entry for multiple runtimes.\n */\nasync function loadProviderFactory(\n provider: LLMProviderId,\n openAIApiMode: LLMProviderConfig['openAIApiMode'],\n): Promise<\n (\n apiKey: string | undefined,\n baseUrl: string | undefined,\n options: Record<string, unknown> | undefined,\n ) => (modelId: string) => LanguageModel\n> {\n switch (provider) {\n case 'openai': {\n const { createOpenAI } = await import('@ai-sdk/openai');\n return (apiKey, baseUrl, options) => {\n const sdk = createOpenAI({ apiKey, baseURL: baseUrl, ...options });\n // Keep Chat Completions as the compatibility default. Hosts may opt a\n // specific model into Responses without splitting a shared provider.\n return (modelId) => openAIApiMode === 'responses' ? sdk.responses(modelId) : sdk.chat(modelId);\n };\n }\n case 'anthropic': {\n const { createAnthropic } = await import('@ai-sdk/anthropic');\n return (apiKey, baseUrl, options) => {\n const sdk = createAnthropic({ apiKey, baseURL: baseUrl, ...options });\n return (modelId) => sdk(modelId);\n };\n }\n case 'google': {\n const { createGoogleGenerativeAI } = await import('@ai-sdk/google');\n return (apiKey, baseUrl, options) => {\n const sdk = createGoogleGenerativeAI({ apiKey, baseURL: baseUrl, ...options });\n return (modelId) => sdk(modelId);\n };\n }\n case 'deepseek': {\n const { createDeepSeek } = await import('@ai-sdk/deepseek');\n return (apiKey, baseUrl, options) => {\n const sdk = createDeepSeek({ apiKey, baseURL: baseUrl, ...options });\n return (modelId) => sdk(modelId);\n };\n }\n case 'groq': {\n const { createGroq } = await import('@ai-sdk/groq');\n return (apiKey, baseUrl, options) => {\n const sdk = createGroq({ apiKey, baseURL: baseUrl, ...options });\n return (modelId) => sdk(modelId);\n };\n }\n case 'mistral': {\n const { createMistral } = await import('@ai-sdk/mistral');\n return (apiKey, baseUrl, options) => {\n const sdk = createMistral({ apiKey, baseURL: baseUrl, ...options });\n return (modelId) => sdk(modelId);\n };\n }\n case 'cohere': {\n const { createCohere } = await import('@ai-sdk/cohere');\n return (apiKey, baseUrl, options) => {\n const sdk = createCohere({ apiKey, baseURL: baseUrl, ...options });\n return (modelId) => sdk(modelId);\n };\n }\n case 'xai': {\n const { createXai } = await import('@ai-sdk/xai');\n return (apiKey, baseUrl, options) => {\n const sdk = createXai({ apiKey, baseURL: baseUrl, ...options });\n return (modelId) => sdk(modelId);\n };\n }\n case 'togetherai': {\n const { createTogetherAI } = await import('@ai-sdk/togetherai');\n return (apiKey, baseUrl, options) => {\n const sdk = createTogetherAI({ apiKey, baseURL: baseUrl, ...options });\n return (modelId) => sdk(modelId);\n };\n }\n case 'perplexity': {\n const { createPerplexity } = await import('@ai-sdk/perplexity');\n return (apiKey, baseUrl, options) => {\n const sdk = createPerplexity({ apiKey, baseURL: baseUrl, ...options });\n return (modelId) => sdk(modelId);\n };\n }\n case 'azure': {\n const { createAzure } = await import('@ai-sdk/azure');\n return (apiKey, _baseUrl, options) => {\n const sdk = createAzure({ apiKey, ...options });\n return (modelId) => sdk(modelId);\n };\n }\n case 'google-vertex': {\n const { createVertex } = await import('@ai-sdk/google-vertex');\n return (_apiKey, _baseUrl, options) => {\n const sdk = createVertex({ ...options });\n return (modelId) => sdk(modelId);\n };\n }\n case 'ollama': {\n const { createOllama } = await import('ollama-ai-provider-v2');\n return (_apiKey, baseUrl, options) => {\n const sdk = createOllama({ baseURL: baseUrl, ...options });\n return (modelId) => sdk(modelId);\n };\n }\n default: {\n const exhaustive: never = provider;\n throw new Error(`Unsupported provider: ${String(exhaustive)}`);\n }\n }\n}\n\n/**\n * Create an `ILLMProvider` from a config-driven provider id.\n *\n * Switches implementation based on `config.provider`.\n * The selected provider's AI SDK package is loaded on demand, so hosts only\n * pay the dependency cost for providers they actually use.\n */\nexport async function createLLMProvider(config: LLMProviderConfig): Promise<ILLMProvider> {\n const name = config.name ?? config.provider;\n\n function resolveModel(modelId?: string): string {\n return modelId ?? config.model ?? defaultModels[config.provider] ?? '';\n }\n\n const createProviderModel = await loadProviderFactory(config.provider, config.openAIApiMode);\n const modelFactory = createProviderModel(config.apiKey, config.baseUrl, config.options);\n\n return createFetchLLMProvider({\n name,\n modelId: resolveModel(),\n createModel: (modelId?: string) => modelFactory(resolveModel(modelId)),\n });\n}\n\n/** Fallback OpenAI-compatible provider for unknown provider ids. */\nasync function createOpenAICompatibleProvider(\n config: Omit<LLMProviderConfig, 'provider'> & { provider: string },\n): Promise<ILLMProvider> {\n const name = config.name ?? config.provider;\n const { createOpenAICompatible } = await import('@ai-sdk/openai-compatible');\n\n function resolveModel(modelId?: string): string {\n return modelId ?? config.model ?? 'gpt-4o-mini';\n }\n\n const sdk = createOpenAICompatible({\n name: config.provider,\n baseURL: config.baseUrl ?? 'https://api.openai.com/v1',\n apiKey: config.apiKey,\n ...config.options,\n });\n\n return createFetchLLMProvider({\n name,\n modelId: resolveModel(),\n createModel: (modelId?: string) => sdk(resolveModel(modelId)),\n });\n}\n\n// ─── Convenience per-provider factories ────────────────────────────────\n\ntype ProviderConfigWithoutId = Omit<LLMProviderConfig, 'provider'>;\n\n/** Convenience factory for OpenAI. */\nexport function createOpenaiProvider(config: ProviderConfigWithoutId = {}): Promise<ILLMProvider> {\n return createLLMProvider({ provider: 'openai', ...config });\n}\n\n/** Convenience factory for Anthropic. */\nexport function createAnthropicProvider(\n config: ProviderConfigWithoutId = {},\n): Promise<ILLMProvider> {\n return createLLMProvider({ provider: 'anthropic', ...config });\n}\n\n/** Convenience factory for Google Generative AI. */\nexport function createGoogleProvider(config: ProviderConfigWithoutId = {}): Promise<ILLMProvider> {\n return createLLMProvider({ provider: 'google', ...config });\n}\n\n/** Convenience factory for DeepSeek. */\nexport function createDeepseekProvider(\n config: ProviderConfigWithoutId = {},\n): Promise<ILLMProvider> {\n return createLLMProvider({ provider: 'deepseek', ...config });\n}\n\n/** Convenience factory for Groq. */\nexport function createGroqProvider(config: ProviderConfigWithoutId = {}): Promise<ILLMProvider> {\n return createLLMProvider({ provider: 'groq', ...config });\n}\n\n/** Convenience factory for Mistral. */\nexport function createMistralProvider(config: ProviderConfigWithoutId = {}): Promise<ILLMProvider> {\n return createLLMProvider({ provider: 'mistral', ...config });\n}\n\n/** Convenience factory for Cohere. */\nexport function createCohereProvider(config: ProviderConfigWithoutId = {}): Promise<ILLMProvider> {\n return createLLMProvider({ provider: 'cohere', ...config });\n}\n\n/** Convenience factory for xAI. */\nexport function createXaiProvider(config: ProviderConfigWithoutId = {}): Promise<ILLMProvider> {\n return createLLMProvider({ provider: 'xai', ...config });\n}\n\n/** Convenience factory for Together AI. */\nexport function createTogetheraiProvider(\n config: ProviderConfigWithoutId = {},\n): Promise<ILLMProvider> {\n return createLLMProvider({ provider: 'togetherai', ...config });\n}\n\n/** Convenience factory for Perplexity. */\nexport function createPerplexityProvider(\n config: ProviderConfigWithoutId = {},\n): Promise<ILLMProvider> {\n return createLLMProvider({ provider: 'perplexity', ...config });\n}\n\n/** Convenience factory for Azure OpenAI. */\nexport function createAzureProvider(config: ProviderConfigWithoutId = {}): Promise<ILLMProvider> {\n return createLLMProvider({ provider: 'azure', ...config });\n}\n\n/** Convenience factory for Google Vertex. */\nexport function createGoogleVertexProvider(\n config: ProviderConfigWithoutId = {},\n): Promise<ILLMProvider> {\n return createLLMProvider({ provider: 'google-vertex', ...config });\n}\n\n/** Convenience factory for Ollama. */\nexport function createOllamaProvider(config: ProviderConfigWithoutId = {}): Promise<ILLMProvider> {\n return createLLMProvider({ provider: 'ollama', ...config });\n}\n\n// ─── Host config mapping ───────────────────────────────────────────────\n\n/**\n * Resolve the default model name from a host config entry.\n * Uses the first key in `entry.models` if present, otherwise falls back\n * to the provider-specific default.\n */\nexport function resolveProviderModelId(entry: ConfiguredProviderEntry): string {\n const firstModelKey = entry.models ? Object.keys(entry.models)[0] : undefined;\n if (firstModelKey) {\n return `${entry.name}/${firstModelKey}`;\n }\n return entry.name;\n}\n\n/**\n * Convert a loose host config entry into an `ILLMProvider` via the core registry.\n * Provider id is taken from `entry.name`. Model id is inferred from `entry.models`\n * or the provider-specific default.\n *\n * Unknown provider names fall back to OpenAI-compatible mode, preserving CLI/Desktop\n * behavior where arbitrary OpenAI-compatible endpoints can be configured with any name.\n */\nexport function createProviderFromEntry(entry: ConfiguredProviderEntry): Promise<ILLMProvider> {\n const providerId = entry.name as LLMProviderId;\n const firstModelKey = entry.models ? Object.keys(entry.models)[0] : undefined;\n const firstModelName = firstModelKey ? entry.models?.[firstModelKey]?.name : undefined;\n const configWithoutProvider = {\n name: entry.name,\n apiKey: entry.apiKey,\n baseUrl: entry.baseUrl,\n model: firstModelName,\n options: entry.options,\n };\n\n if (!defaultModels[providerId]) {\n return createOpenAICompatibleProvider({ provider: entry.name, ...configWithoutProvider });\n }\n\n return createLLMProvider({\n provider: providerId,\n ...configWithoutProvider,\n });\n}\n","/**\n * Provider-agnostic LLM provider — wraps a current Vercel AI SDK LanguageModel.\n *\n * The core does NOT depend on @ai-sdk/openai or any specific provider.\n * Hosts inject their own `createModel` factory:\n *\n * import { createOpenAI } from '@ai-sdk/openai';\n * const openai = createOpenAI({ baseURL: '...', apiKey: '...' });\n * const provider = createFetchLLMProvider({\n * name: 'openai',\n * createModel: (id) => openai(id ?? 'gpt-4o-mini'),\n * });\n *\n * Or for Anthropic:\n * import { createAnthropic } from '@ai-sdk/anthropic';\n * const anthropic = createAnthropic({ apiKey: '...' });\n * const provider = createFetchLLMProvider({\n * name: 'claude',\n * createModel: (id) => anthropic(id ?? 'claude-3-5-sonnet-20241022'),\n * });\n *\n * Works with every @ai-sdk/* provider: openai, anthropic, google, deepseek,\n * cohere, mistral, azure, bedrock, groq, ollama, openrouter, together, etc.\n */\n\nimport type { JSONValue, LanguageModel } from 'ai';\nimport { generateText, streamText } from 'ai';\n\nimport type { ILLMProvider } from '../types.js';\n\nexport interface FetchLLMChatRequest {\n messages?: Array<{ role: string; content: string }>;\n model?: string;\n stream?: boolean;\n /** Legacy OpenAI-compatible spelling retained for host adapters. */\n max_tokens?: number;\n /** AI SDK spelling. Takes precedence over max_tokens. */\n maxOutputTokens?: number;\n temperature?: number;\n topP?: number;\n providerOptions?: Record<string, Record<string, JSONValue>>;\n system?: string;\n abortSignal?: AbortSignal;\n}\n\nexport function resolveFetchLLMCallSettings(body: FetchLLMChatRequest): {\n maxOutputTokens: number | undefined;\n temperature: number | undefined;\n topP: number | undefined;\n providerOptions: Record<string, Record<string, JSONValue>> | undefined;\n abortSignal: AbortSignal | undefined;\n} {\n return {\n maxOutputTokens: body.maxOutputTokens ?? body.max_tokens,\n temperature: body.temperature,\n topP: body.topP,\n providerOptions: body.providerOptions,\n abortSignal: body.abortSignal,\n };\n}\n\n// ─── Config ────────────────────────────────────────────────────────────\n\nexport interface FetchLLMProviderConfig {\n /** Display name. */\n name: string;\n /** Serializable default model identity for scheduling and audit records. */\n modelId?: string;\n /**\n * Factory: given an optional model id, return a LanguageModel from any @ai-sdk/* provider.\n * The factory is responsible for picking a default model when `modelId` is omitted.\n */\n createModel: (modelId?: string) => LanguageModel;\n}\n\n// ─── Factory ───────────────────────────────────────────────────────────\n\n/**\n * Create an `ILLMProvider` that delegates to the Vercel AI SDK.\n *\n * Provider-agnostic — hosts supply their own `createModel` factory.\n * Supports every @ai-sdk/* provider (OpenAI, Anthropic, Google, DeepSeek,\n * Groq, Ollama, OpenRouter, Together, Bedrock, Azure, Mistral, Cohere…).\n *\n * @example\n * ```ts\n * import { createOpenAI } from '@ai-sdk/openai';\n * const openai = createOpenAI({ baseURL: 'https://api.openai.com/v1', apiKey });\n * const provider = createFetchLLMProvider({\n * name: 'openai',\n * createModel: (modelId) => openai(modelId ?? 'gpt-4o-mini'),\n * });\n * ```\n */\nexport function createFetchLLMProvider(config: FetchLLMProviderConfig): ILLMProvider {\n return {\n name: config.name,\n ...(config.modelId !== undefined ? { modelId: config.modelId } : {}),\n // Store the factory so hosts can introspect or extend\n model: config.createModel,\n async chat(request: unknown) {\n const body = (typeof request === 'object' && request !== null ? request : {}) as FetchLLMChatRequest;\n\n const model = config.createModel(body.model);\n const specificationVersion = (\n model as { specificationVersion?: unknown } | null\n )?.specificationVersion;\n if (\n model === null ||\n typeof model !== 'object' ||\n !['v2', 'v3', 'v4'].includes(String(specificationVersion))\n ) {\n throw new Error(\n `LLM provider '${config.name}' returned an incompatible AI SDK model for '${\n typeof body.model === 'string' ? body.model : (config.modelId ?? 'default')\n }' (expected specificationVersion v2, v3, or v4; received ${String(specificationVersion)})`,\n );\n }\n\n const systemMessages = (body.messages ?? [])\n .filter((message) => message.role === 'system')\n .map((message) => message.content);\n const messages = (body.messages ?? [])\n .filter((message) => message.role !== 'system')\n .map((message) => {\n // AI SDK model messages do not accept a bare textual tool role.\n // MemeLoop stores tool results as role='tool'; promote them to user\n // messages while preserving the result text in conversation history.\n const role = message.role === 'tool' ? 'user' : (message.role as 'user' | 'assistant');\n return {\n role,\n content: message.content,\n };\n });\n\n const system = body.system ?? (\n systemMessages.length > 0 ? systemMessages.join('\\n\\n') : undefined\n );\n const { abortSignal, maxOutputTokens, providerOptions, temperature, topP } = resolveFetchLLMCallSettings(body);\n\n if (body.stream !== false) {\n let streamingError: unknown;\n const result = streamText({\n model,\n instructions: system,\n messages,\n maxOutputTokens,\n temperature,\n topP,\n providerOptions,\n abortSignal,\n onError: ({ error }) => {\n streamingError = error;\n },\n });\n return (async function*() {\n for await (const chunk of result.textStream) {\n yield chunk;\n }\n if (streamingError !== undefined) {\n throw streamingError instanceof Error\n ? streamingError\n : new Error('The model stream failed', { cause: streamingError });\n }\n })();\n }\n\n const result = await generateText({\n model,\n instructions: system,\n messages,\n maxOutputTokens,\n temperature,\n topP,\n providerOptions,\n abortSignal,\n });\n return result.text;\n },\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;AC0BA,gBAAyC;AAmBlC,SAAS,4BAA4B,MAM1C;AACA,SAAO;AAAA,IACL,iBAAiB,KAAK,mBAAmB,KAAK;AAAA,IAC9C,aAAa,KAAK;AAAA,IAClB,MAAM,KAAK;AAAA,IACX,iBAAiB,KAAK;AAAA,IACtB,aAAa,KAAK;AAAA,EACpB;AACF;AAmCO,SAAS,uBAAuB,QAA8C;AACnF,SAAO;AAAA,IACL,MAAM,OAAO;AAAA,IACb,GAAI,OAAO,YAAY,SAAY,EAAE,SAAS,OAAO,QAAQ,IAAI,CAAC;AAAA;AAAA,IAElE,OAAO,OAAO;AAAA,IACd,MAAM,KAAK,SAAkB;AAC3B,YAAM,OAAQ,OAAO,YAAY,YAAY,YAAY,OAAO,UAAU,CAAC;AAE3E,YAAM,QAAQ,OAAO,YAAY,KAAK,KAAK;AAC3C,YAAM,uBACJ,OACC;AACH,UACE,UAAU,QACV,OAAO,UAAU,YACjB,CAAC,CAAC,MAAM,MAAM,IAAI,EAAE,SAAS,OAAO,oBAAoB,CAAC,GACzD;AACA,cAAM,IAAI;AAAA,UACR,iBAAiB,OAAO,IAAI,gDAC1B,OAAO,KAAK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AM,SAAS,aAAa,GAAG,OAAO;AAC7E,QAAM,wBAAwB;AAAA,IAC5B,MAAM,MAAM;AAAA,IACZ,QAAQ,MAAM;AAAA,IACd,SAAS,MAAM;AAAA,IACf,OAAO;AAAA,IACP,SAAS,MAAM;AAAA,EACjB;AAEA,MAAI,CAAC,cAAc,UAAU,GAAG;AAC9B,WAAO,+BAA+B,EAAE,UAAU,MAAM,MAAM,GAAG,sBAAsB,CAAC;AAAA,EAC1F;AAEA,SAAO,kBAAkB;AAAA,IACvB,UAAU;AAAA,IACV,GAAG;AAAA,EACL,CAAC;AACH;","names":["result"]}
@@ -1,5 +1,6 @@
1
- import { k as ILLMProvider } from './scriptDeploymentPipeline-XJzQyYys.cjs';
2
- import './interface-3C3eG8Hn.cjs';
1
+ import { k as ILLMProvider } from './scriptDeploymentPipeline-CdDLEDMS.cjs';
2
+ import './types-CcoJ_fdH.cjs';
3
+ import './interface-CECFnbzR.cjs';
3
4
 
4
5
  /**
5
6
  * Pre-built, config-driven LLM providers.
@@ -1,5 +1,6 @@
1
- import { k as ILLMProvider } from './scriptDeploymentPipeline-B1q-UhrO.js';
2
- import './interface-3C3eG8Hn.js';
1
+ import { k as ILLMProvider } from './scriptDeploymentPipeline-DU6sor6Y.js';
2
+ import './types-CcoJ_fdH.js';
3
+ import './interface-C54gkLA3.js';
3
4
 
4
5
  /**
5
6
  * Pre-built, config-driven LLM providers.
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  createFetchLLMProvider
3
- } from "./chunk-HY3U3GLE.js";
3
+ } from "./chunk-5EUJNLVW.js";
4
4
 
5
5
  // src/llm-providers.ts
6
6
  var defaultModels = {
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/llm-providers.ts"],"sourcesContent":["/**\n * Pre-built, config-driven LLM providers.\n *\n * Exposes every major @ai-sdk/* provider through a single entry point so hosts\n * can switch providers by changing a string in user config — no need to install\n * AI SDK packages individually.\n *\n * ```ts\n * import { createLLMProvider } from 'memeloop/llm-providers';\n *\n * const provider = createLLMProvider({\n * provider: 'openai',\n * baseUrl: 'https://api.openai.com/v1',\n * apiKey: process.env.OPENAI_API_KEY,\n * model: 'gpt-4o',\n * });\n * ```\n *\n * For custom providers, or to keep bundle size minimal, use the generic\n * `createFetchLLMProvider` exported from `memeloop` and supply your own\n * `createModel` factory.\n *\n * `createLLMProvider` is async because it dynamically imports the selected\n * AI SDK provider on first use. Host bundlers can then decide whether to\n * bundle, split, or externalize those provider dependencies for their runtime.\n */\n\nimport type { LanguageModel } from 'ai';\n\nimport { createFetchLLMProvider } from './llm/fetchProvider.js';\nimport type { ILLMProvider } from './types.js';\n\n// ─── Provider ids ──────────────────────────────────────────────────────\n\nexport type LLMProviderId =\n | 'openai'\n | 'anthropic'\n | 'google'\n | 'deepseek'\n | 'groq'\n | 'mistral'\n | 'cohere'\n | 'xai'\n | 'togetherai'\n | 'perplexity'\n | 'azure'\n | 'google-vertex'\n | 'ollama';\n\n// ─── Config ────────────────────────────────────────────────────────────\n\nexport interface LLMProviderConfig {\n /** Provider id. */\n provider: LLMProviderId;\n /** Display name (defaults to provider id). */\n name?: string;\n /** API key or credential. */\n apiKey?: string;\n /** Override the provider's default API base URL. */\n baseUrl?: string;\n /** Default model id. When omitted a provider-specific default is used. */\n model?: string;\n /** Provider-specific options passed through to the AI SDK factory. */\n options?: Record<string, unknown>;\n /** OpenAI wire API selected for this model. Defaults to Chat Completions. */\n openAIApiMode?: 'chat-completions' | 'responses';\n}\n\n/** A provider entry from any host config (loose shape used by CLI/Desktop). */\nexport interface ConfiguredProviderEntry {\n /** Provider id matching LLMProviderId. */\n name: string;\n /** API base URL. */\n baseUrl?: string;\n /** API key. */\n apiKey?: string;\n /** Provider-specific options. */\n options?: Record<string, unknown>;\n /** Available models; the first key is used as the default model. */\n models?: Record<string, { name: string }>;\n}\n\n// ─── Defaults ──────────────────────────────────────────────────────────\n\nconst defaultModels: Record<LLMProviderId, string> = {\n openai: 'gpt-4o-mini',\n anthropic: 'claude-3-5-sonnet-20241022',\n google: 'gemini-1.5-flash',\n deepseek: 'deepseek-chat',\n groq: 'llama-3.1-8b-instant',\n mistral: 'mistral-small-latest',\n cohere: 'command-r-plus',\n xai: 'grok-beta',\n togetherai: 'meta-llama/Llama-3.1-8B-Instruct-Turbo',\n perplexity: 'sonar',\n azure: '',\n 'google-vertex': '',\n ollama: 'llama3.1',\n};\n\n// ─── Unified factory ───────────────────────────────────────────────────\n\n/**\n * Dynamic loader for AI SDK provider factories.\n *\n * Each provider is imported on demand so that hosts only load the SDK packages\n * they actually use. This avoids eagerly loading Node-only providers in hosts\n * that bundle or externalize this entry for multiple runtimes.\n */\nasync function loadProviderFactory(\n provider: LLMProviderId,\n openAIApiMode: LLMProviderConfig['openAIApiMode'],\n): Promise<\n (\n apiKey: string | undefined,\n baseUrl: string | undefined,\n options: Record<string, unknown> | undefined,\n ) => (modelId: string) => LanguageModel\n> {\n switch (provider) {\n case 'openai': {\n const { createOpenAI } = await import('@ai-sdk/openai');\n return (apiKey, baseUrl, options) => {\n const sdk = createOpenAI({ apiKey, baseURL: baseUrl, ...options });\n // Keep Chat Completions as the compatibility default. Hosts may opt a\n // specific model into Responses without splitting a shared provider.\n return (modelId) =>\n (openAIApiMode === 'responses'\n ? sdk.responses(modelId)\n : sdk.chat(modelId)) as unknown as LanguageModel;\n };\n }\n case 'anthropic': {\n const { createAnthropic } = await import('@ai-sdk/anthropic');\n return (apiKey, baseUrl, options) => {\n const sdk = createAnthropic({ apiKey, baseURL: baseUrl, ...options });\n return (modelId) => sdk(modelId) as unknown as LanguageModel;\n };\n }\n case 'google': {\n const { createGoogleGenerativeAI } = await import('@ai-sdk/google');\n return (apiKey, baseUrl, options) => {\n const sdk = createGoogleGenerativeAI({ apiKey, baseURL: baseUrl, ...options });\n return (modelId) => sdk(modelId) as unknown as LanguageModel;\n };\n }\n case 'deepseek': {\n const { createDeepSeek } = await import('@ai-sdk/deepseek');\n return (apiKey, baseUrl, options) => {\n const sdk = createDeepSeek({ apiKey, baseURL: baseUrl, ...options });\n return (modelId) => sdk(modelId) as unknown as LanguageModel;\n };\n }\n case 'groq': {\n const { createGroq } = await import('@ai-sdk/groq');\n return (apiKey, baseUrl, options) => {\n const sdk = createGroq({ apiKey, baseURL: baseUrl, ...options });\n return (modelId) => sdk(modelId) as unknown as LanguageModel;\n };\n }\n case 'mistral': {\n const { createMistral } = await import('@ai-sdk/mistral');\n return (apiKey, baseUrl, options) => {\n const sdk = createMistral({ apiKey, baseURL: baseUrl, ...options });\n return (modelId) => sdk(modelId) as unknown as LanguageModel;\n };\n }\n case 'cohere': {\n const { createCohere } = await import('@ai-sdk/cohere');\n return (apiKey, baseUrl, options) => {\n const sdk = createCohere({ apiKey, baseURL: baseUrl, ...options });\n return (modelId) => sdk(modelId) as unknown as LanguageModel;\n };\n }\n case 'xai': {\n const { createXai } = await import('@ai-sdk/xai');\n return (apiKey, baseUrl, options) => {\n const sdk = createXai({ apiKey, baseURL: baseUrl, ...options });\n return (modelId) => sdk(modelId) as unknown as LanguageModel;\n };\n }\n case 'togetherai': {\n const { createTogetherAI } = await import('@ai-sdk/togetherai');\n return (apiKey, baseUrl, options) => {\n const sdk = createTogetherAI({ apiKey, baseURL: baseUrl, ...options });\n return (modelId) => sdk(modelId) as unknown as LanguageModel;\n };\n }\n case 'perplexity': {\n const { createPerplexity } = await import('@ai-sdk/perplexity');\n return (apiKey, baseUrl, options) => {\n const sdk = createPerplexity({ apiKey, baseURL: baseUrl, ...options });\n return (modelId) => sdk(modelId) as unknown as LanguageModel;\n };\n }\n case 'azure': {\n const { createAzure } = await import('@ai-sdk/azure');\n return (apiKey, _baseUrl, options) => {\n const sdk = createAzure({ apiKey, ...options });\n return (modelId) => sdk(modelId) as unknown as LanguageModel;\n };\n }\n case 'google-vertex': {\n const { createVertex } = await import('@ai-sdk/google-vertex');\n return (_apiKey, _baseUrl, options) => {\n const sdk = createVertex({ ...options });\n return (modelId) => sdk(modelId) as unknown as LanguageModel;\n };\n }\n case 'ollama': {\n const { createOllama } = await import('ollama-ai-provider-v2');\n return (_apiKey, baseUrl, options) => {\n const sdk = createOllama({ baseURL: baseUrl, ...options });\n return (modelId) => sdk(modelId) as unknown as LanguageModel;\n };\n }\n default: {\n const exhaustive: never = provider;\n throw new Error(`Unsupported provider: ${String(exhaustive)}`);\n }\n }\n}\n\n/**\n * Create an `ILLMProvider` from a config-driven provider id.\n *\n * Switches implementation based on `config.provider`.\n * The selected provider's AI SDK package is loaded on demand, so hosts only\n * pay the dependency cost for providers they actually use.\n */\nexport async function createLLMProvider(config: LLMProviderConfig): Promise<ILLMProvider> {\n const name = config.name ?? config.provider;\n\n function resolveModel(modelId?: string): string {\n return modelId ?? config.model ?? defaultModels[config.provider] ?? '';\n }\n\n const createProviderModel = await loadProviderFactory(config.provider, config.openAIApiMode);\n const modelFactory = createProviderModel(config.apiKey, config.baseUrl, config.options);\n\n return createFetchLLMProvider({\n name,\n modelId: resolveModel(),\n createModel: (modelId?: string) => modelFactory(resolveModel(modelId)),\n });\n}\n\n/** Fallback OpenAI-compatible provider for unknown provider ids. */\nasync function createOpenAICompatibleProvider(\n config: Omit<LLMProviderConfig, 'provider'> & { provider: string },\n): Promise<ILLMProvider> {\n const name = config.name ?? config.provider;\n const { createOpenAICompatible } = await import('@ai-sdk/openai-compatible');\n\n function resolveModel(modelId?: string): string {\n return modelId ?? config.model ?? 'gpt-4o-mini';\n }\n\n const sdk = createOpenAICompatible({\n name: config.provider,\n baseURL: config.baseUrl ?? 'https://api.openai.com/v1',\n apiKey: config.apiKey,\n ...config.options,\n });\n\n return createFetchLLMProvider({\n name,\n modelId: resolveModel(),\n createModel: (modelId?: string) => sdk(resolveModel(modelId)) as unknown as LanguageModel,\n });\n}\n\n// ─── Convenience per-provider factories ────────────────────────────────\n\ntype ProviderConfigWithoutId = Omit<LLMProviderConfig, 'provider'>;\n\n/** Convenience factory for OpenAI. */\nexport function createOpenaiProvider(config: ProviderConfigWithoutId = {}): Promise<ILLMProvider> {\n return createLLMProvider({ provider: 'openai', ...config });\n}\n\n/** Convenience factory for Anthropic. */\nexport function createAnthropicProvider(\n config: ProviderConfigWithoutId = {},\n): Promise<ILLMProvider> {\n return createLLMProvider({ provider: 'anthropic', ...config });\n}\n\n/** Convenience factory for Google Generative AI. */\nexport function createGoogleProvider(config: ProviderConfigWithoutId = {}): Promise<ILLMProvider> {\n return createLLMProvider({ provider: 'google', ...config });\n}\n\n/** Convenience factory for DeepSeek. */\nexport function createDeepseekProvider(\n config: ProviderConfigWithoutId = {},\n): Promise<ILLMProvider> {\n return createLLMProvider({ provider: 'deepseek', ...config });\n}\n\n/** Convenience factory for Groq. */\nexport function createGroqProvider(config: ProviderConfigWithoutId = {}): Promise<ILLMProvider> {\n return createLLMProvider({ provider: 'groq', ...config });\n}\n\n/** Convenience factory for Mistral. */\nexport function createMistralProvider(config: ProviderConfigWithoutId = {}): Promise<ILLMProvider> {\n return createLLMProvider({ provider: 'mistral', ...config });\n}\n\n/** Convenience factory for Cohere. */\nexport function createCohereProvider(config: ProviderConfigWithoutId = {}): Promise<ILLMProvider> {\n return createLLMProvider({ provider: 'cohere', ...config });\n}\n\n/** Convenience factory for xAI. */\nexport function createXaiProvider(config: ProviderConfigWithoutId = {}): Promise<ILLMProvider> {\n return createLLMProvider({ provider: 'xai', ...config });\n}\n\n/** Convenience factory for Together AI. */\nexport function createTogetheraiProvider(\n config: ProviderConfigWithoutId = {},\n): Promise<ILLMProvider> {\n return createLLMProvider({ provider: 'togetherai', ...config });\n}\n\n/** Convenience factory for Perplexity. */\nexport function createPerplexityProvider(\n config: ProviderConfigWithoutId = {},\n): Promise<ILLMProvider> {\n return createLLMProvider({ provider: 'perplexity', ...config });\n}\n\n/** Convenience factory for Azure OpenAI. */\nexport function createAzureProvider(config: ProviderConfigWithoutId = {}): Promise<ILLMProvider> {\n return createLLMProvider({ provider: 'azure', ...config });\n}\n\n/** Convenience factory for Google Vertex. */\nexport function createGoogleVertexProvider(\n config: ProviderConfigWithoutId = {},\n): Promise<ILLMProvider> {\n return createLLMProvider({ provider: 'google-vertex', ...config });\n}\n\n/** Convenience factory for Ollama. */\nexport function createOllamaProvider(config: ProviderConfigWithoutId = {}): Promise<ILLMProvider> {\n return createLLMProvider({ provider: 'ollama', ...config });\n}\n\n// ─── Host config mapping ───────────────────────────────────────────────\n\n/**\n * Resolve the default model name from a host config entry.\n * Uses the first key in `entry.models` if present, otherwise falls back\n * to the provider-specific default.\n */\nexport function resolveProviderModelId(entry: ConfiguredProviderEntry): string {\n const firstModelKey = entry.models ? Object.keys(entry.models)[0] : undefined;\n if (firstModelKey) {\n return `${entry.name}/${firstModelKey}`;\n }\n return entry.name;\n}\n\n/**\n * Convert a loose host config entry into an `ILLMProvider` via the core registry.\n * Provider id is taken from `entry.name`. Model id is inferred from `entry.models`\n * or the provider-specific default.\n *\n * Unknown provider names fall back to OpenAI-compatible mode, preserving CLI/Desktop\n * behavior where arbitrary OpenAI-compatible endpoints can be configured with any name.\n */\nexport function createProviderFromEntry(entry: ConfiguredProviderEntry): Promise<ILLMProvider> {\n const providerId = entry.name as LLMProviderId;\n const firstModelKey = entry.models ? Object.keys(entry.models)[0] : undefined;\n const firstModelName = firstModelKey ? entry.models?.[firstModelKey]?.name : undefined;\n const configWithoutProvider = {\n name: entry.name,\n apiKey: entry.apiKey,\n baseUrl: entry.baseUrl,\n model: firstModelName,\n options: entry.options,\n };\n\n if (!defaultModels[providerId]) {\n return createOpenAICompatibleProvider({ provider: entry.name, ...configWithoutProvider });\n }\n\n return createLLMProvider({\n provider: providerId,\n ...configWithoutProvider,\n });\n}\n"],"mappings":";;;;;AAoFA,IAAM,gBAA+C;AAAA,EACnD,QAAQ;AAAA,EACR,WAAW;AAAA,EACX,QAAQ;AAAA,EACR,UAAU;AAAA,EACV,MAAM;AAAA,EACN,SAAS;AAAA,EACT,QAAQ;AAAA,EACR,KAAK;AAAA,EACL,YAAY;AAAA,EACZ,YAAY;AAAA,EACZ,OAAO;AAAA,EACP,iBAAiB;AAAA,EACjB,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;AAAA,EAC1F;AAEA,SAAO,kBAAkB;AAAA,IACvB,UAAU;AAAA,IACV,GAAG;AAAA,EACL,CAAC;AACH;","names":[]}
1
+ {"version":3,"sources":["../src/llm-providers.ts"],"sourcesContent":["/**\n * Pre-built, config-driven LLM providers.\n *\n * Exposes every major @ai-sdk/* provider through a single entry point so hosts\n * can switch providers by changing a string in user config — no need to install\n * AI SDK packages individually.\n *\n * ```ts\n * import { createLLMProvider } from 'memeloop/llm-providers';\n *\n * const provider = createLLMProvider({\n * provider: 'openai',\n * baseUrl: 'https://api.openai.com/v1',\n * apiKey: process.env.OPENAI_API_KEY,\n * model: 'gpt-4o',\n * });\n * ```\n *\n * For custom providers, or to keep bundle size minimal, use the generic\n * `createFetchLLMProvider` exported from `memeloop` and supply your own\n * `createModel` factory.\n *\n * `createLLMProvider` is async because it dynamically imports the selected\n * AI SDK provider on first use. Host bundlers can then decide whether to\n * bundle, split, or externalize those provider dependencies for their runtime.\n */\n\nimport type { LanguageModel } from 'ai';\n\nimport { createFetchLLMProvider } from './llm/fetchProvider.js';\nimport type { ILLMProvider } from './types.js';\n\n// ─── Provider ids ──────────────────────────────────────────────────────\n\nexport type LLMProviderId =\n | 'openai'\n | 'anthropic'\n | 'google'\n | 'deepseek'\n | 'groq'\n | 'mistral'\n | 'cohere'\n | 'xai'\n | 'togetherai'\n | 'perplexity'\n | 'azure'\n | 'google-vertex'\n | 'ollama';\n\n// ─── Config ────────────────────────────────────────────────────────────\n\nexport interface LLMProviderConfig {\n /** Provider id. */\n provider: LLMProviderId;\n /** Display name (defaults to provider id). */\n name?: string;\n /** API key or credential. */\n apiKey?: string;\n /** Override the provider's default API base URL. */\n baseUrl?: string;\n /** Default model id. When omitted a provider-specific default is used. */\n model?: string;\n /** Provider-specific options passed through to the AI SDK factory. */\n options?: Record<string, unknown>;\n /** OpenAI wire API selected for this model. Defaults to Chat Completions. */\n openAIApiMode?: 'chat-completions' | 'responses';\n}\n\n/** A provider entry from any host config (loose shape used by CLI/Desktop). */\nexport interface ConfiguredProviderEntry {\n /** Provider id matching LLMProviderId. */\n name: string;\n /** API base URL. */\n baseUrl?: string;\n /** API key. */\n apiKey?: string;\n /** Provider-specific options. */\n options?: Record<string, unknown>;\n /** Available models; the first key is used as the default model. */\n models?: Record<string, { name: string }>;\n}\n\n// ─── Defaults ──────────────────────────────────────────────────────────\n\nconst defaultModels: Record<LLMProviderId, string> = {\n openai: 'gpt-4o-mini',\n anthropic: 'claude-3-5-sonnet-20241022',\n google: 'gemini-1.5-flash',\n deepseek: 'deepseek-chat',\n groq: 'llama-3.1-8b-instant',\n mistral: 'mistral-small-latest',\n cohere: 'command-r-plus',\n xai: 'grok-beta',\n togetherai: 'meta-llama/Llama-3.1-8B-Instruct-Turbo',\n perplexity: 'sonar',\n azure: '',\n 'google-vertex': '',\n ollama: 'llama3.1',\n};\n\n// ─── Unified factory ───────────────────────────────────────────────────\n\n/**\n * Dynamic loader for AI SDK provider factories.\n *\n * Each provider is imported on demand so that hosts only load the SDK packages\n * they actually use. This avoids eagerly loading Node-only providers in hosts\n * that bundle or externalize this entry for multiple runtimes.\n */\nasync function loadProviderFactory(\n provider: LLMProviderId,\n openAIApiMode: LLMProviderConfig['openAIApiMode'],\n): Promise<\n (\n apiKey: string | undefined,\n baseUrl: string | undefined,\n options: Record<string, unknown> | undefined,\n ) => (modelId: string) => LanguageModel\n> {\n switch (provider) {\n case 'openai': {\n const { createOpenAI } = await import('@ai-sdk/openai');\n return (apiKey, baseUrl, options) => {\n const sdk = createOpenAI({ apiKey, baseURL: baseUrl, ...options });\n // Keep Chat Completions as the compatibility default. Hosts may opt a\n // specific model into Responses without splitting a shared provider.\n return (modelId) => openAIApiMode === 'responses' ? sdk.responses(modelId) : sdk.chat(modelId);\n };\n }\n case 'anthropic': {\n const { createAnthropic } = await import('@ai-sdk/anthropic');\n return (apiKey, baseUrl, options) => {\n const sdk = createAnthropic({ apiKey, baseURL: baseUrl, ...options });\n return (modelId) => sdk(modelId);\n };\n }\n case 'google': {\n const { createGoogleGenerativeAI } = await import('@ai-sdk/google');\n return (apiKey, baseUrl, options) => {\n const sdk = createGoogleGenerativeAI({ apiKey, baseURL: baseUrl, ...options });\n return (modelId) => sdk(modelId);\n };\n }\n case 'deepseek': {\n const { createDeepSeek } = await import('@ai-sdk/deepseek');\n return (apiKey, baseUrl, options) => {\n const sdk = createDeepSeek({ apiKey, baseURL: baseUrl, ...options });\n return (modelId) => sdk(modelId);\n };\n }\n case 'groq': {\n const { createGroq } = await import('@ai-sdk/groq');\n return (apiKey, baseUrl, options) => {\n const sdk = createGroq({ apiKey, baseURL: baseUrl, ...options });\n return (modelId) => sdk(modelId);\n };\n }\n case 'mistral': {\n const { createMistral } = await import('@ai-sdk/mistral');\n return (apiKey, baseUrl, options) => {\n const sdk = createMistral({ apiKey, baseURL: baseUrl, ...options });\n return (modelId) => sdk(modelId);\n };\n }\n case 'cohere': {\n const { createCohere } = await import('@ai-sdk/cohere');\n return (apiKey, baseUrl, options) => {\n const sdk = createCohere({ apiKey, baseURL: baseUrl, ...options });\n return (modelId) => sdk(modelId);\n };\n }\n case 'xai': {\n const { createXai } = await import('@ai-sdk/xai');\n return (apiKey, baseUrl, options) => {\n const sdk = createXai({ apiKey, baseURL: baseUrl, ...options });\n return (modelId) => sdk(modelId);\n };\n }\n case 'togetherai': {\n const { createTogetherAI } = await import('@ai-sdk/togetherai');\n return (apiKey, baseUrl, options) => {\n const sdk = createTogetherAI({ apiKey, baseURL: baseUrl, ...options });\n return (modelId) => sdk(modelId);\n };\n }\n case 'perplexity': {\n const { createPerplexity } = await import('@ai-sdk/perplexity');\n return (apiKey, baseUrl, options) => {\n const sdk = createPerplexity({ apiKey, baseURL: baseUrl, ...options });\n return (modelId) => sdk(modelId);\n };\n }\n case 'azure': {\n const { createAzure } = await import('@ai-sdk/azure');\n return (apiKey, _baseUrl, options) => {\n const sdk = createAzure({ apiKey, ...options });\n return (modelId) => sdk(modelId);\n };\n }\n case 'google-vertex': {\n const { createVertex } = await import('@ai-sdk/google-vertex');\n return (_apiKey, _baseUrl, options) => {\n const sdk = createVertex({ ...options });\n return (modelId) => sdk(modelId);\n };\n }\n case 'ollama': {\n const { createOllama } = await import('ollama-ai-provider-v2');\n return (_apiKey, baseUrl, options) => {\n const sdk = createOllama({ baseURL: baseUrl, ...options });\n return (modelId) => sdk(modelId);\n };\n }\n default: {\n const exhaustive: never = provider;\n throw new Error(`Unsupported provider: ${String(exhaustive)}`);\n }\n }\n}\n\n/**\n * Create an `ILLMProvider` from a config-driven provider id.\n *\n * Switches implementation based on `config.provider`.\n * The selected provider's AI SDK package is loaded on demand, so hosts only\n * pay the dependency cost for providers they actually use.\n */\nexport async function createLLMProvider(config: LLMProviderConfig): Promise<ILLMProvider> {\n const name = config.name ?? config.provider;\n\n function resolveModel(modelId?: string): string {\n return modelId ?? config.model ?? defaultModels[config.provider] ?? '';\n }\n\n const createProviderModel = await loadProviderFactory(config.provider, config.openAIApiMode);\n const modelFactory = createProviderModel(config.apiKey, config.baseUrl, config.options);\n\n return createFetchLLMProvider({\n name,\n modelId: resolveModel(),\n createModel: (modelId?: string) => modelFactory(resolveModel(modelId)),\n });\n}\n\n/** Fallback OpenAI-compatible provider for unknown provider ids. */\nasync function createOpenAICompatibleProvider(\n config: Omit<LLMProviderConfig, 'provider'> & { provider: string },\n): Promise<ILLMProvider> {\n const name = config.name ?? config.provider;\n const { createOpenAICompatible } = await import('@ai-sdk/openai-compatible');\n\n function resolveModel(modelId?: string): string {\n return modelId ?? config.model ?? 'gpt-4o-mini';\n }\n\n const sdk = createOpenAICompatible({\n name: config.provider,\n baseURL: config.baseUrl ?? 'https://api.openai.com/v1',\n apiKey: config.apiKey,\n ...config.options,\n });\n\n return createFetchLLMProvider({\n name,\n modelId: resolveModel(),\n createModel: (modelId?: string) => sdk(resolveModel(modelId)),\n });\n}\n\n// ─── Convenience per-provider factories ────────────────────────────────\n\ntype ProviderConfigWithoutId = Omit<LLMProviderConfig, 'provider'>;\n\n/** Convenience factory for OpenAI. */\nexport function createOpenaiProvider(config: ProviderConfigWithoutId = {}): Promise<ILLMProvider> {\n return createLLMProvider({ provider: 'openai', ...config });\n}\n\n/** Convenience factory for Anthropic. */\nexport function createAnthropicProvider(\n config: ProviderConfigWithoutId = {},\n): Promise<ILLMProvider> {\n return createLLMProvider({ provider: 'anthropic', ...config });\n}\n\n/** Convenience factory for Google Generative AI. */\nexport function createGoogleProvider(config: ProviderConfigWithoutId = {}): Promise<ILLMProvider> {\n return createLLMProvider({ provider: 'google', ...config });\n}\n\n/** Convenience factory for DeepSeek. */\nexport function createDeepseekProvider(\n config: ProviderConfigWithoutId = {},\n): Promise<ILLMProvider> {\n return createLLMProvider({ provider: 'deepseek', ...config });\n}\n\n/** Convenience factory for Groq. */\nexport function createGroqProvider(config: ProviderConfigWithoutId = {}): Promise<ILLMProvider> {\n return createLLMProvider({ provider: 'groq', ...config });\n}\n\n/** Convenience factory for Mistral. */\nexport function createMistralProvider(config: ProviderConfigWithoutId = {}): Promise<ILLMProvider> {\n return createLLMProvider({ provider: 'mistral', ...config });\n}\n\n/** Convenience factory for Cohere. */\nexport function createCohereProvider(config: ProviderConfigWithoutId = {}): Promise<ILLMProvider> {\n return createLLMProvider({ provider: 'cohere', ...config });\n}\n\n/** Convenience factory for xAI. */\nexport function createXaiProvider(config: ProviderConfigWithoutId = {}): Promise<ILLMProvider> {\n return createLLMProvider({ provider: 'xai', ...config });\n}\n\n/** Convenience factory for Together AI. */\nexport function createTogetheraiProvider(\n config: ProviderConfigWithoutId = {},\n): Promise<ILLMProvider> {\n return createLLMProvider({ provider: 'togetherai', ...config });\n}\n\n/** Convenience factory for Perplexity. */\nexport function createPerplexityProvider(\n config: ProviderConfigWithoutId = {},\n): Promise<ILLMProvider> {\n return createLLMProvider({ provider: 'perplexity', ...config });\n}\n\n/** Convenience factory for Azure OpenAI. */\nexport function createAzureProvider(config: ProviderConfigWithoutId = {}): Promise<ILLMProvider> {\n return createLLMProvider({ provider: 'azure', ...config });\n}\n\n/** Convenience factory for Google Vertex. */\nexport function createGoogleVertexProvider(\n config: ProviderConfigWithoutId = {},\n): Promise<ILLMProvider> {\n return createLLMProvider({ provider: 'google-vertex', ...config });\n}\n\n/** Convenience factory for Ollama. */\nexport function createOllamaProvider(config: ProviderConfigWithoutId = {}): Promise<ILLMProvider> {\n return createLLMProvider({ provider: 'ollama', ...config });\n}\n\n// ─── Host config mapping ───────────────────────────────────────────────\n\n/**\n * Resolve the default model name from a host config entry.\n * Uses the first key in `entry.models` if present, otherwise falls back\n * to the provider-specific default.\n */\nexport function resolveProviderModelId(entry: ConfiguredProviderEntry): string {\n const firstModelKey = entry.models ? Object.keys(entry.models)[0] : undefined;\n if (firstModelKey) {\n return `${entry.name}/${firstModelKey}`;\n }\n return entry.name;\n}\n\n/**\n * Convert a loose host config entry into an `ILLMProvider` via the core registry.\n * Provider id is taken from `entry.name`. Model id is inferred from `entry.models`\n * or the provider-specific default.\n *\n * Unknown provider names fall back to OpenAI-compatible mode, preserving CLI/Desktop\n * behavior where arbitrary OpenAI-compatible endpoints can be configured with any name.\n */\nexport function createProviderFromEntry(entry: ConfiguredProviderEntry): Promise<ILLMProvider> {\n const providerId = entry.name as LLMProviderId;\n const firstModelKey = entry.models ? Object.keys(entry.models)[0] : undefined;\n const firstModelName = firstModelKey ? entry.models?.[firstModelKey]?.name : undefined;\n const configWithoutProvider = {\n name: entry.name,\n apiKey: entry.apiKey,\n baseUrl: entry.baseUrl,\n model: firstModelName,\n options: entry.options,\n };\n\n if (!defaultModels[providerId]) {\n return createOpenAICompatibleProvider({ provider: entry.name, ...configWithoutProvider });\n }\n\n return createLLMProvider({\n provider: providerId,\n ...configWithoutProvider,\n });\n}\n"],"mappings":";;;;;AAoFA,IAAM,gBAA+C;AAAA,EACnD,QAAQ;AAAA,EACR,WAAW;AAAA,EACX,QAAQ;AAAA,EACR,UAAU;AAAA,EACV,MAAM;AAAA,EACN,SAAS;AAAA,EACT,QAAQ;AAAA,EACR,KAA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