@easynet/agent-llm 1.0.2 → 1.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/config.ts","../src/providers/openai.ts","../src/providers/index.ts","../src/factory.ts","../src/chatModelRegistry.ts","../src/llmAdapter.ts","../src/loadLLMExtensions.ts"],"sourcesContent":["/**\n * Parse agent.yaml llm section into normalized LLMConfig[] and default id.\n * Supports: flat (每个模型一个 name 为 key)、instances[]、或单对象。\n */\n\nimport type { LLMConfig } from \"./types.js\";\n\nconst DEFAULT_LLM_ID = \"default\";\n\nconst RESERVED_KEYS = new Set([\n \"default\",\n \"instances\",\n \"catalog\",\n \"provider\",\n \"model\",\n \"temperature\",\n \"apiKey\",\n \"baseURL\",\n \"base_url\",\n \"type\",\n \"id\",\n]);\n\n/**\n * 解析 llm section:扁平(每个模型一个 name 为 key)或 default+instances 或单对象。\n */\nexport function parseLlmSection(section: unknown): { defaultId: string; configs: LLMConfig[] } {\n if (section == null || typeof section !== \"object\") {\n return { defaultId: DEFAULT_LLM_ID, configs: [] };\n }\n\n if (Array.isArray(section)) {\n const configs = section\n .filter((i): i is Record<string, unknown> => i != null && typeof i === \"object\")\n .map((item, i) => normalizeLlmConfig({ ...item, id: item.id ?? item.name ?? String(i) }))\n .filter((c): c is LLMConfig => c != null);\n const defaultId = configs.length > 0 ? configs[0]!.id : DEFAULT_LLM_ID;\n return { defaultId, configs };\n }\n\n const s = section as Record<string, unknown>;\n\n const flatEntries = Object.entries(s).filter(\n ([k, v]) => !RESERVED_KEYS.has(k) && v != null && typeof v === \"object\" && !Array.isArray(v)\n );\n if (flatEntries.length > 0) {\n const configs: LLMConfig[] = [];\n for (const [id, entry] of flatEntries) {\n const c = entryToLlmConfig(id, entry as Record<string, unknown>);\n if (c) configs.push(c);\n }\n const defaultId =\n typeof s.default === \"string\" && s.default && flatEntries.some(([k]) => k === s.default)\n ? s.default\n : configs.length > 0\n ? configs[0]!.id\n : DEFAULT_LLM_ID;\n return { defaultId, configs };\n }\n\n if (Array.isArray(s.instances)) {\n const configs = (s.instances as unknown[])\n .filter((i): i is Record<string, unknown> => i != null && typeof i === \"object\")\n .map((i) => normalizeLlmConfig(i))\n .filter((c): c is LLMConfig => c != null);\n const defaultId =\n typeof s.default === \"string\" && s.default\n ? s.default\n : configs.length > 0\n ? configs[0]!.id\n : DEFAULT_LLM_ID;\n return { defaultId, configs };\n }\n\n if (typeof s.provider === \"string\" || typeof s.model === \"string\" || typeof (s as { name?: string }).name === \"string\") {\n const one = singleObjectToLlmConfig(s);\n return { defaultId: one.id, configs: [one] };\n }\n\n return { defaultId: DEFAULT_LLM_ID, configs: [] };\n}\n\nconst EXTENSION_OPTION_KEYS = [\"featureKey\", \"tenant\", \"authToken\", \"verifySSL\", \"bypassAuth\", \"host\", \"resolveHost\", \"timeoutMs\", \"options\"];\n\nfunction entryToLlmConfig(id: string, entry: Record<string, unknown>): LLMConfig | null {\n const opts = entry.options as Record<string, unknown> | undefined;\n const baseURL =\n typeof entry.base_url === \"string\"\n ? entry.base_url\n : typeof entry.baseURL === \"string\"\n ? entry.baseURL\n : undefined;\n const model = typeof entry.name === \"string\" ? entry.name : typeof entry.model === \"string\" ? entry.model : undefined;\n const provider = typeof entry.provider === \"string\" && entry.provider ? entry.provider : \"openai\";\n const config: LLMConfig = {\n id,\n type: \"chat\",\n provider,\n model,\n temperature: typeof opts?.temperature === \"number\" ? opts.temperature : typeof entry.temperature === \"number\" ? entry.temperature : undefined,\n apiKey: typeof opts?.apiKey === \"string\" ? opts.apiKey : typeof entry.apiKey === \"string\" ? entry.apiKey : undefined,\n baseURL,\n };\n if (typeof entry.type === \"string\" && entry.type === \"image\") config.type = \"image\";\n if (opts && typeof opts === \"object\") (config as Record<string, unknown>).options = opts;\n for (const k of EXTENSION_OPTION_KEYS) {\n if (entry[k] !== undefined) (config as Record<string, unknown>)[k] = entry[k];\n else if (opts && opts[k] !== undefined) (config as Record<string, unknown>)[k] = opts[k];\n }\n return config;\n}\n\nfunction singleObjectToLlmConfig(s: Record<string, unknown>): LLMConfig {\n const one: LLMConfig = {\n id: DEFAULT_LLM_ID,\n type: \"chat\",\n provider: typeof s.provider === \"string\" ? s.provider : \"openai\",\n model: typeof s.model === \"string\" ? s.model : (typeof (s as { name?: string }).name === \"string\" ? (s as { name: string }).name : undefined),\n temperature: typeof s.temperature === \"number\" ? s.temperature : undefined,\n apiKey: typeof s.apiKey === \"string\" ? s.apiKey : undefined,\n baseURL:\n typeof s.baseURL === \"string\" ? s.baseURL : typeof s.base_url === \"string\" ? s.base_url : undefined,\n };\n Object.keys(s).forEach((k) => {\n if (![\"id\", \"type\", \"provider\", \"model\", \"name\", \"temperature\", \"apiKey\", \"baseURL\", \"base_url\", \"default\", \"instances\"].includes(k)) {\n (one as Record<string, unknown>)[k] = s[k];\n }\n });\n return one;\n}\n\nfunction normalizeLlmConfig(o: Record<string, unknown>): LLMConfig | null {\n const id = typeof o.id === \"string\" && o.id ? o.id : DEFAULT_LLM_ID;\n const type = o.type === \"image\" ? \"image\" : \"chat\";\n const provider = typeof o.provider === \"string\" && o.provider ? o.provider : \"openai\";\n const config: LLMConfig = {\n id,\n type,\n provider,\n model: typeof o.model === \"string\" ? o.model : (typeof o.name === \"string\" ? o.name : undefined),\n temperature: typeof o.temperature === \"number\" ? o.temperature : undefined,\n apiKey: typeof o.apiKey === \"string\" ? o.apiKey : undefined,\n baseURL: typeof o.baseURL === \"string\" ? o.baseURL : (typeof o.base_url === \"string\" ? o.base_url : undefined),\n };\n Object.keys(o).forEach((k) => {\n if (![\"id\", \"type\", \"provider\", \"model\", \"name\", \"temperature\", \"apiKey\", \"baseURL\", \"base_url\"].includes(k)) {\n (config as Record<string, unknown>)[k] = o[k];\n }\n });\n return config;\n}\n","/**\n * OpenAI 兼容格式:chat (/v1/chat/completions) 与 image。\n * 支持 baseURL 以对接 Azure、本地代理等兼容端点。\n */\n\nimport OpenAI from \"openai\";\nimport type {\n LLMConfig,\n ChatMessage,\n ChatResult,\n ImageResult,\n ILLMClient,\n ChatWithToolsMessage,\n ChatWithToolsResult,\n ToolDefinition,\n} from \"../types.js\";\n\nfunction getApiKey(config: LLMConfig): string {\n const key = config.apiKey ?? process.env.OPENAI_API_KEY ?? \"\";\n if (!key) throw new Error(\"OpenAI-compatible apiKey required (config.apiKey or OPENAI_API_KEY)\");\n return key;\n}\n\nfunction createOpenAIClientOptions(config: LLMConfig): { apiKey: string; baseURL?: string } {\n const opts: { apiKey: string; baseURL?: string } = { apiKey: getApiKey(config) };\n if (typeof config.baseURL === \"string\" && config.baseURL) opts.baseURL = config.baseURL;\n return opts;\n}\n\nfunction serializeMessage(\n m: ChatWithToolsMessage\n): OpenAI.Chat.Completions.ChatCompletionMessageParam {\n if (m.role === \"tool\")\n return { role: \"tool\", content: m.content, tool_call_id: m.tool_call_id };\n if (m.role === \"assistant\" && \"tool_calls\" in m && m.tool_calls?.length) {\n return {\n role: \"assistant\",\n content: m.content ?? null,\n tool_calls: m.tool_calls.map((tc) => ({\n id: tc.id,\n type: \"function\" as const,\n function: { name: tc.function.name, arguments: tc.function.arguments },\n })),\n };\n }\n return { role: m.role, content: (m as ChatMessage).content };\n}\n\nexport function createOpenAIChatClient(config: LLMConfig): ILLMClient {\n const client = new OpenAI(createOpenAIClientOptions(config));\n const model = config.model ?? process.env.OPENAI_MODEL ?? \"gpt-4o-mini\";\n const temperature = config.temperature ?? 0;\n\n return {\n id: config.id,\n type: \"chat\",\n async chat(messages: ChatMessage[]): Promise<ChatResult> {\n const resp = await client.chat.completions.create({\n model,\n temperature,\n messages: messages.map((m) => ({ role: m.role, content: m.content })),\n });\n const content = resp.choices[0]?.message?.content ?? \"\";\n const usage = resp.usage\n ? { promptTokens: resp.usage.prompt_tokens, completionTokens: resp.usage.completion_tokens }\n : undefined;\n return { content, usage };\n },\n async chatWithTools(\n messages: ChatWithToolsMessage[],\n tools: ToolDefinition[],\n _options?: { timeoutMs?: number }\n ): Promise<ChatWithToolsResult> {\n const resp = await client.chat.completions.create({\n model,\n temperature,\n messages: messages.map(serializeMessage),\n tools: tools.map((t) => ({\n type: \"function\" as const,\n function: {\n name: t.function.name,\n description: t.function.description,\n parameters: (t.function.parameters ?? undefined) as Record<string, unknown> | undefined,\n },\n })),\n });\n const msg = resp.choices[0]?.message;\n const usage = resp.usage\n ? { promptTokens: resp.usage.prompt_tokens, completionTokens: resp.usage.completion_tokens }\n : undefined;\n return {\n message: {\n role: \"assistant\",\n content: msg?.content ?? null,\n tool_calls: msg?.tool_calls?.map((tc) => ({\n id: tc.id,\n type: \"function\" as const,\n function: {\n name: tc.function?.name ?? \"\",\n arguments: tc.function?.arguments ?? \"\",\n },\n })),\n },\n usage,\n };\n },\n };\n}\n\nexport function createOpenAIImageClient(config: LLMConfig): ILLMClient {\n const client = new OpenAI(createOpenAIClientOptions(config));\n const model = (config.model as string) ?? \"dall-e-3\";\n\n return {\n id: config.id,\n type: \"image\",\n async chat(): Promise<ChatResult> {\n throw new Error(\"OpenAI image model does not support chat; use generateImage()\");\n },\n async generateImage(options: { prompt: string; size?: string; n?: number }): Promise<ImageResult> {\n const resp = await client.images.generate({\n model,\n prompt: options.prompt,\n size: (options.size as \"1024x1024\" | \"1792x1024\" | \"1024x1792\") ?? \"1024x1024\",\n n: options.n ?? 1,\n response_format: \"url\",\n });\n const url = resp.data?.[0]?.url ?? undefined;\n return { url };\n },\n };\n}\n\nexport function createOpenAIClient(config: LLMConfig): ILLMClient {\n if (config.type === \"image\") return createOpenAIImageClient(config);\n return createOpenAIChatClient(config);\n}\n","/**\n * Supports OpenAI-compatible and extension providers.\n */\n\nimport type { LLMConfig, ILLMClient } from \"../types.js\";\nimport { createOpenAIClient } from \"./openai.js\";\n\nconst OPENAI_COMPATIBLE = \"openai-compatible\";\n\nfunction createOpenAICompat(config: LLMConfig): ILLMClient {\n return createOpenAIClient(config);\n}\n\nconst PROVIDERS: Record<string, (config: LLMConfig) => ILLMClient> = {\n openai: createOpenAICompat,\n [OPENAI_COMPATIBLE]: createOpenAICompat,\n};\n\nexport function createClient(config: LLMConfig): ILLMClient {\n const p = (config.provider ?? \"\").toLowerCase();\n const fn = PROVIDERS[p];\n if (!fn) {\n const supported = [...new Set([...Object.keys(PROVIDERS), \"extension providers\"])].sort().join(\", \");\n throw new Error(\n `Unsupported LLM provider: ${config.provider}. Supported: ${supported}.`\n );\n }\n return fn(config);\n}\n\nexport function registerProvider(name: string, factory: (config: LLMConfig) => ILLMClient): void {\n PROVIDERS[name.toLowerCase()] = factory;\n}\n","/**\n * Create LLM registry from agent.yaml llm section.\n */\n\nimport { parseLlmSection } from \"./config.js\";\nimport { createClient } from \"./providers/index.js\";\nimport type { AgentConfigLlmSection, ILLMClient, ILLMRegistry } from \"./types.js\";\n\nexport interface CreateLLMRegistryOptions {\n /** 已解析的 llm section(来自 loadAgentConfig 的 config.llm) */\n llmSection: AgentConfigLlmSection | null | undefined;\n}\n\n/**\n * 从 agent config 的 llm 段创建 LLM 注册表;支持多 provider、多模型、每 LLM 有 id 与 type。\n */\nexport function createLLMRegistry(options: CreateLLMRegistryOptions): ILLMRegistry {\n const { defaultId, configs } = parseLlmSection(options.llmSection);\n const map = new Map<string, ILLMClient>();\n\n for (const config of configs) {\n try {\n const client = createClient(config);\n map.set(config.id, client);\n } catch (err) {\n console.warn(`[agent-llm] Skip LLM \"${config.id}\": ${err instanceof Error ? err.message : String(err)}`);\n }\n }\n\n return {\n get(id: string): ILLMClient | undefined {\n return map.get(id);\n },\n defaultId(): string | undefined {\n if (map.has(defaultId)) return defaultId;\n return map.size > 0 ? [...map.keys()][0] : undefined;\n },\n ids(): string[] {\n return [...map.keys()];\n },\n };\n}\n","/**\n * Registry for LangChain ChatModel by provider name.\n * Extensions register via registerChatModelProvider; llmAdapter uses getChatModelFactory.\n */\n\nimport type { BaseChatModel } from \"@langchain/core/language_models/chat_models\";\nimport type { LLMConfig } from \"./types.js\";\n\nexport type ChatModelFactory = (config: LLMConfig) => BaseChatModel;\n\nconst CHAT_MODEL_FACTORIES = new Map<string, ChatModelFactory>();\n\n/**\n * Register a ChatModel factory for a provider name.\n * Called by extensions (e.g. wallee-llm) on load.\n */\nexport function registerChatModelProvider(providerName: string, factory: ChatModelFactory): void {\n CHAT_MODEL_FACTORIES.set(providerName.toLowerCase(), factory);\n}\n\n/**\n * Get the ChatModel factory for a provider name, if registered.\n */\nexport function getChatModelFactory(providerName: string): ChatModelFactory | undefined {\n return CHAT_MODEL_FACTORIES.get(providerName.toLowerCase());\n}\n","/**\n * Build LangChain ChatModel from agent.yaml llm section.\n * Supports single object, default + instances, and flat keyed configs.\n * When provider is registered by an extension, uses that extension's ChatModel;\n * otherwise uses ChatOpenAI.\n */\n\nimport { ChatOpenAI } from \"@langchain/openai\";\nimport type { BaseChatModel } from \"@langchain/core/language_models/chat_models\";\nimport { parseLlmSection } from \"./config.js\";\nimport { getChatModelFactory } from \"./chatModelRegistry.js\";\n\nconst DEFAULT_MODEL = \"gpt-4o-mini\";\n\nexport interface CreateChatModelFromLlmConfigOptions {\n /** agent.yaml llm section (raw or parsed); compatible with AgentConfigLlmSection / AgentConfigLlm */\n llmSection?: unknown;\n /** Override model from env */\n modelEnv?: string;\n /** Override API key from env */\n apiKeyEnv?: string;\n}\n\n/**\n * Create a LangChain ChatModel from agent config llm section.\n * Uses extension-registered ChatModel when available; otherwise ChatOpenAI.\n */\nexport function createChatModelFromLlmConfig(\n options: CreateChatModelFromLlmConfigOptions\n): BaseChatModel {\n const { llmSection, modelEnv, apiKeyEnv } = options;\n const { defaultId, configs } = parseLlmSection(llmSection ?? null);\n const defaultConfig = configs.find((c) => c.id === defaultId) ?? configs[0];\n\n if (!defaultConfig) {\n const model =\n modelEnv ?? process.env.OPENAI_MODEL ?? DEFAULT_MODEL;\n const apiKey = apiKeyEnv ?? process.env.OPENAI_API_KEY;\n return new ChatOpenAI({\n model,\n temperature: 0,\n ...(apiKey ? { apiKey } : {}),\n });\n }\n\n const provider = (defaultConfig as { provider?: string }).provider ?? \"openai\";\n const chatModelFactory = getChatModelFactory(provider);\n if (chatModelFactory) {\n const config = {\n ...defaultConfig,\n model:\n modelEnv ??\n defaultConfig.model ??\n (provider === \"cis\" ? process.env.CIS_MODEL ?? \"gcp/gemini-2.5-pro\" : defaultConfig.model),\n temperature:\n typeof defaultConfig.temperature === \"number\"\n ? defaultConfig.temperature\n : 0,\n };\n return chatModelFactory(config);\n }\n\n const model =\n modelEnv ??\n defaultConfig?.model ??\n process.env.OPENAI_MODEL ??\n DEFAULT_MODEL;\n\n const apiKey =\n apiKeyEnv ?? defaultConfig?.apiKey ?? process.env.OPENAI_API_KEY;\n\n const temperature =\n typeof defaultConfig?.temperature === \"number\" ? defaultConfig.temperature : 0;\n\n const baseURL = defaultConfig?.baseURL;\n\n const constructorOptions: ConstructorParameters<typeof ChatOpenAI>[0] = {\n model,\n temperature,\n ...(apiKey ? { apiKey } : {}),\n ...(baseURL ? { configuration: { baseURL } } : {}),\n };\n\n return new ChatOpenAI(constructorOptions);\n}\n","/**\n * Load optional LLM extensions by npm package name (e.g. wallee-llm).\n * Call before createChatModelFromLlmConfig when using extension providers.\n * Config llm.type = npm package name(s); we dynamic load those packages. No extensions field.\n */\n\nconst loadedPackages = new Set<string>();\n\nconst DEFAULT_EXTENSIONS = [\"wallee-llm\"];\n\n/**\n * Resolve llm.type to a list of npm package names to load.\n * type is the npm package name or array of package names; we load them directly (no mapping).\n */\nexport function resolveLLMExtensionPackages(types?: string | string[]): string[] {\n const typeList = types == null ? [] : Array.isArray(types) ? types : [types];\n const packages = typeList.filter(\n (t): t is string => typeof t === \"string\" && t.length > 0\n );\n return packages.length > 0 ? packages : DEFAULT_EXTENSIONS;\n}\n\n/**\n * Dynamically load LLM extensions by npm package name.\n * Each package must export registerLLMExtension() and will register its provider(s) and ChatModel factory.\n * Safe to call multiple times; each package is loaded at most once.\n * @param extensionPackages npm package names; default [\"wallee-llm\"] when omitted\n */\nexport async function loadLLMExtensions(\n extensionPackages?: string[]\n): Promise<void> {\n const packages = extensionPackages ?? DEFAULT_EXTENSIONS;\n for (const pkg of packages) {\n if (loadedPackages.has(pkg)) continue;\n loadedPackages.add(pkg);\n try {\n const m = await import(/* @vite-ignore */ pkg);\n if (\n typeof (m as { registerLLMExtension?: () => void })\n .registerLLMExtension === \"function\"\n ) {\n (m as { registerLLMExtension: () => void }).registerLLMExtension();\n }\n } catch {\n // extension not installed or load failed\n }\n }\n}\n"],"mappings":";AAOA,IAAM,iBAAiB;AAEvB,IAAM,gBAAgB,oBAAI,IAAI;AAAA,EAC5B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,CAAC;AAKM,SAAS,gBAAgB,SAA+D;AAC7F,MAAI,WAAW,QAAQ,OAAO,YAAY,UAAU;AAClD,WAAO,EAAE,WAAW,gBAAgB,SAAS,CAAC,EAAE;AAAA,EAClD;AAEA,MAAI,MAAM,QAAQ,OAAO,GAAG;AAC1B,UAAM,UAAU,QACb,OAAO,CAAC,MAAoC,KAAK,QAAQ,OAAO,MAAM,QAAQ,EAC9E,IAAI,CAAC,MAAM,MAAM,mBAAmB,EAAE,GAAG,MAAM,IAAI,KAAK,MAAM,KAAK,QAAQ,OAAO,CAAC,EAAE,CAAC,CAAC,EACvF,OAAO,CAAC,MAAsB,KAAK,IAAI;AAC1C,UAAM,YAAY,QAAQ,SAAS,IAAI,QAAQ,CAAC,EAAG,KAAK;AACxD,WAAO,EAAE,WAAW,QAAQ;AAAA,EAC9B;AAEA,QAAM,IAAI;AAEV,QAAM,cAAc,OAAO,QAAQ,CAAC,EAAE;AAAA,IACpC,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,cAAc,IAAI,CAAC,KAAK,KAAK,QAAQ,OAAO,MAAM,YAAY,CAAC,MAAM,QAAQ,CAAC;AAAA,EAC7F;AACA,MAAI,YA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":[],"mappings":"","names":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"llmAdapter.d.ts","sourceRoot":"","sources":["../src/llmAdapter.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,6CAA6C,CAAC;AAMjF,MAAM,WAAW,mCAAmC;IAClD,qGAAqG;IACrG,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,8BAA8B;IAC9B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,gCAAgC;IAChC,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;GAGG;AACH,wBAAgB,4BAA4B,CAC1C,OAAO,EAAE,mCAAmC,GAC3C,aAAa,CAuDf"}
1
+ {"version":3,"file":"llmAdapter.d.ts","sourceRoot":"","sources":["../src/llmAdapter.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,6CAA6C,CAAC;AAMjF,MAAM,WAAW,mCAAmC;IAClD,qGAAqG;IACrG,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,8BAA8B;IAC9B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,gCAAgC;IAChC,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;GAGG;AACH,wBAAgB,4BAA4B,CAC1C,OAAO,EAAE,mCAAmC,GAC3C,aAAa,CA2Df"}
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Load and parse LLM config from YAML (e.g. config/llm.yaml).
3
+ * Supports ${VAR} substitution from process.env.
4
+ */
5
+ export interface LoadLlmConfigOptions {
6
+ /** Replace ${VAR} with process.env.VAR. Default true. */
7
+ substituteEnv?: boolean;
8
+ }
9
+ /**
10
+ * Recursively replace ${VAR} in strings with process.env.VAR.
11
+ */
12
+ export declare function substituteEnv(obj: unknown): unknown;
13
+ /**
14
+ * Parse YAML string and return the llm section (top-level key "llm").
15
+ * Returns undefined if content has no llm key.
16
+ */
17
+ export declare function parseLlmYaml(content: string, options?: LoadLlmConfigOptions): unknown;
18
+ /**
19
+ * Load LLM config from a YAML file (e.g. config/llm.yaml).
20
+ * Returns the llm section for use with createChatModelFromLlmConfig or parseLlmSection.
21
+ * Returns null if file does not exist or has no llm key.
22
+ */
23
+ export declare function loadLlmConfig(filePath: string, options?: LoadLlmConfigOptions): unknown | null;
24
+ //# sourceMappingURL=loadLlmConfig.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"loadLlmConfig.d.ts","sourceRoot":"","sources":["../src/loadLlmConfig.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,MAAM,WAAW,oBAAoB;IACnC,yDAAyD;IACzD,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,OAAO,GAAG,OAAO,CAanD;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAC1B,OAAO,EAAE,MAAM,EACf,OAAO,GAAE,oBAAyB,GACjC,OAAO,CAMT;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAC3B,QAAQ,EAAE,MAAM,EAChB,OAAO,GAAE,oBAAyB,GACjC,OAAO,GAAG,IAAI,CAShB"}
@@ -0,0 +1,61 @@
1
+ /**
2
+ * npm: protocol in provider — specify an npm package name (and optional version) in config's model provider.
3
+ * Format: npm:<package-name> or npm:<package-name>@<version> or npm:<package-name>#<provider-name> or npm:<package-name>@<version>#<provider-name>
4
+ * When installNpmIfMissing is true, the framework will run npm install <package>[@version] if the package is not found.
5
+ */
6
+ import type { CreateChatModelFromLlmConfigOptions } from "./llmAdapter.js";
7
+ import type { BaseChatModel } from "@langchain/core/language_models/chat_models";
8
+ export declare const NPM_PROTOCOL_PREFIX = "npm:";
9
+ /** Parse npm: spec into package name, optional version, and optional #provider fragment. */
10
+ export declare function parseNpmProviderSpec(spec: string): {
11
+ packageName: string;
12
+ version?: string;
13
+ provider?: string;
14
+ } | null;
15
+ export interface EnsureNpmPackageInstalledOptions {
16
+ /** Version to install (e.g. 0.1.0, latest). If set, runs npm install <package>@<version>. */
17
+ version?: string;
18
+ /** Working directory for npm install. Default: process.cwd() */
19
+ cwd?: string;
20
+ }
21
+ /**
22
+ * Check if a provider spec uses the npm: protocol.
23
+ */
24
+ export declare function isNpmProviderSpec(spec: unknown): spec is string;
25
+ /**
26
+ * Ensure an npm package is installed: if it cannot be resolved, run npm install <packageName>[@version] from cwd.
27
+ * Call this before loading a provider package when the config uses npm:<package-name>[@version].
28
+ */
29
+ export declare function ensureNpmPackageInstalled(packageName: string, options?: EnsureNpmPackageInstalledOptions): Promise<void>;
30
+ export interface ResolveNpmProviderOptions {
31
+ /** If true (default), run npm install <package> when the package is not found. */
32
+ installNpmIfMissing?: boolean;
33
+ /** Working directory for npm install. Default: process.cwd() */
34
+ cwd?: string;
35
+ }
36
+ /**
37
+ * Resolve an npm provider spec to the concrete provider name.
38
+ * - npm:wallee-llm → load wallee-llm, use its default provider (e.g. cis)
39
+ * - npm:wallee-llm@0.1.0 → load wallee-llm@0.1.0, use its default provider
40
+ * - npm:wallee-llm#cis → load wallee-llm, use provider "cis"
41
+ * - npm:wallee-llm@0.1.0#cis → load wallee-llm@0.1.0, use provider "cis"
42
+ * When installNpmIfMissing is true, installs the package (with optional version) if not found.
43
+ * Returns the provider name to use, or null if spec is not npm: protocol.
44
+ */
45
+ export declare function resolveNpmProvider(spec: string, options?: ResolveNpmProviderOptions): Promise<string | null>;
46
+ export interface ResolveLlmSectionWithNpmOptions extends ResolveNpmProviderOptions {
47
+ }
48
+ /**
49
+ * Recursively resolve all provider values that use the npm: protocol in a clone of the llm section.
50
+ * When installNpmIfMissing is true, installs any npm: package that is not found.
51
+ */
52
+ export declare function resolveLlmSectionWithNpm(llmSection: unknown, options?: ResolveLlmSectionWithNpmOptions): Promise<unknown>;
53
+ export interface CreateChatModelFromLlmConfigWithNpmOptions extends CreateChatModelFromLlmConfigOptions, ResolveNpmProviderOptions {
54
+ }
55
+ /**
56
+ * Create a LangChain ChatModel from llm section, resolving any provider values that use the npm: protocol.
57
+ * Use when config has provider: "npm:wallee-llm" or provider: "npm:wallee-llm#cis".
58
+ * When installNpmIfMissing is true (default), the framework will run npm install <package> if the package is not found.
59
+ */
60
+ export declare function createChatModelFromLlmConfigWithNpm(options: CreateChatModelFromLlmConfigWithNpmOptions): Promise<BaseChatModel>;
61
+ //# sourceMappingURL=npmProviderProtocol.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"npmProviderProtocol.d.ts","sourceRoot":"","sources":["../src/npmProviderProtocol.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAKH,OAAO,KAAK,EAAE,mCAAmC,EAAE,MAAM,iBAAiB,CAAC;AAC3E,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,6CAA6C,CAAC;AAEjF,eAAO,MAAM,mBAAmB,SAAS,CAAC;AAE1C,4FAA4F;AAC5F,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,MAAM,GAAG;IAAE,WAAW,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAYtH;AAED,MAAM,WAAW,gCAAgC;IAC/C,6FAA6F;IAC7F,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,gEAAgE;IAChE,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI,IAAI,MAAM,CAE/D;AAYD;;;GAGG;AACH,wBAAsB,yBAAyB,CAC7C,WAAW,EAAE,MAAM,EACnB,OAAO,GAAE,gCAAqC,GAC7C,OAAO,CAAC,IAAI,CAAC,CAef;AAED,MAAM,WAAW,yBAAyB;IACxC,kFAAkF;IAClF,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,gEAAgE;IAChE,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAED;;;;;;;;GAQG;AACH,wBAAsB,kBAAkB,CACtC,IAAI,EAAE,MAAM,EACZ,OAAO,GAAE,yBAA8B,GACtC,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAsCxB;AAED,MAAM,WAAW,+BAAgC,SAAQ,yBAAyB;CAAG;AAErF;;;GAGG;AACH,wBAAsB,wBAAwB,CAC5C,UAAU,EAAE,OAAO,EACnB,OAAO,GAAE,+BAAoC,GAC5C,OAAO,CAAC,OAAO,CAAC,CAsBlB;AAED,MAAM,WAAW,0CACf,SAAQ,mCAAmC,EACzC,yBAAyB;CAAG;AAEhC;;;;GAIG;AACH,wBAAsB,mCAAmC,CACvD,OAAO,EAAE,0CAA0C,GAClD,OAAO,CAAC,aAAa,CAAC,CAUxB"}
@@ -1,6 +1,6 @@
1
1
  /**
2
- * OpenAI 兼容格式:chat (/v1/chat/completions) image
3
- * 支持 baseURL 以对接 Azure、本地代理等兼容端点。
2
+ * OpenAI-compatible format: chat (/v1/chat/completions) and image.
3
+ * Supports baseURL for Azure, local proxy, and other compatible endpoints.
4
4
  */
5
5
  import type { LLMConfig, ILLMClient } from "../types.js";
6
6
  export declare function createOpenAIChatClient(config: LLMConfig): ILLMClient;
package/dist/types.d.ts CHANGED
@@ -1,37 +1,37 @@
1
1
  /**
2
- * Agent LLM: 暂时只支持 OpenAI 兼容格式(/v1/chat/completions 等)。
3
- * 多实例,每 LLM idtype;可选 baseURL 对接其他兼容端点。
2
+ * Agent LLM: OpenAI-compatible format only (/v1/chat/completions etc.).
3
+ * Multi-instance: each LLM has id and type; optional baseURL for other compatible endpoints.
4
4
  */
5
- /** LLM 类型:chat=对话,image=图像生成(OpenAI 兼容格式) */
5
+ /** LLM type: chat = conversation, image = image generation (OpenAI-compatible format) */
6
6
  export type LLMType = "chat" | "image";
7
- /** 单条 LLM 配置:idtypemodel;仅支持 OpenAI 兼容 API */
7
+ /** Single LLM config: id, type, model; OpenAI-compatible API only */
8
8
  export interface LLMConfig {
9
- /** 唯一 id,用于从 registry 获取实例 */
9
+ /** Unique id for fetching the instance from the registry */
10
10
  id: string;
11
11
  /** chat | image */
12
12
  type: LLMType;
13
- /** 固定为 openai openai-compatible;暂时只支持此格式 */
13
+ /** Must be openai or openai-compatible; only this format is supported */
14
14
  provider: string;
15
- /** 模型名,如 gpt-4o-minidall-e-3 */
15
+ /** Model name, e.g. gpt-4o-mini, dall-e-3 */
16
16
  model?: string;
17
- /** 温度等;chat 常用 */
17
+ /** Temperature etc.; commonly used for chat */
18
18
  temperature?: number;
19
- /** API key;也可用环境变量 */
19
+ /** API key; can also be set via env */
20
20
  apiKey?: string;
21
- /** OpenAI 兼容端点 baseURL(如 Azure、本地代理、其他兼容 /v1 的厂商) */
21
+ /** OpenAI-compatible endpoint baseURL (e.g. Azure, local proxy, other /v1-compatible vendors) */
22
22
  baseURL?: string;
23
- /** 其他选项(透传) */
23
+ /** Other options (passed through) */
24
24
  [key: string]: unknown;
25
25
  }
26
- /** agent.yaml llm 段:扁平(每个模型一个 name key)或 default+instances 或单对象 */
26
+ /** agent.yaml llm section: flat (each model keyed by name), default+instances, or single object */
27
27
  export interface AgentConfigLlmSection {
28
- /** 默认使用的模型 nameid */
28
+ /** Default model name (id) to use */
29
29
  default?: string;
30
- /** npm 包名或包名数组,动态加载;如 "wallee-llm" ["wallee-llm"] */
30
+ /** npm package name or array for dynamic load; e.g. "wallee-llm" or ["wallee-llm"] */
31
31
  type?: string | string[];
32
- /** 多个 LLM 配置(数组格式) */
32
+ /** Array of LLM configs */
33
33
  instances?: LLMConfig[];
34
- /** 兼容单对象:providermodel 等,解析为 id=default chat */
34
+ /** Single-object form: provider, model etc., parsed as id=default chat */
35
35
  provider?: string;
36
36
  model?: string;
37
37
  name?: string;
@@ -39,15 +39,15 @@ export interface AgentConfigLlmSection {
39
39
  apiKey?: string;
40
40
  baseURL?: string;
41
41
  base_url?: string;
42
- /** 扁平:strong/medium/fast name → 配置(providerbase_urlnameoptions */
42
+ /** Flat: strong/medium/fast etc. name → config (provider, base_url, name, options) */
43
43
  [key: string]: unknown;
44
44
  }
45
- /** 单条聊天消息 */
45
+ /** Single chat message */
46
46
  export interface ChatMessage {
47
47
  role: "system" | "user" | "assistant";
48
48
  content: string;
49
49
  }
50
- /** 极简聊天结果 */
50
+ /** Minimal chat result */
51
51
  export interface ChatResult {
52
52
  content: string;
53
53
  usage?: {
@@ -55,7 +55,7 @@ export interface ChatResult {
55
55
  completionTokens?: number;
56
56
  };
57
57
  }
58
- /** OpenAI 兼容的工具定义(function */
58
+ /** OpenAI-compatible tool definition (function) */
59
59
  export interface ToolDefinition {
60
60
  type: "function";
61
61
  function: {
@@ -64,7 +64,7 @@ export interface ToolDefinition {
64
64
  parameters?: object;
65
65
  };
66
66
  }
67
- /** tool 调用的消息(assistant 可能含 tool_callstool 为工具结果) */
67
+ /** Message with tool calls (assistant may include tool_calls; tool = tool result) */
68
68
  export type ChatWithToolsMessage = ChatMessage | {
69
69
  role: "tool";
70
70
  content: string;
@@ -81,7 +81,7 @@ export type ChatWithToolsMessage = ChatMessage | {
81
81
  };
82
82
  }>;
83
83
  };
84
- /** 带工具调用的聊天结果 */
84
+ /** Chat result with tool calls */
85
85
  export interface ChatWithToolsResult {
86
86
  message: {
87
87
  role: "assistant";
@@ -100,29 +100,29 @@ export interface ChatWithToolsResult {
100
100
  completionTokens?: number;
101
101
  };
102
102
  }
103
- /** 图像生成结果 */
103
+ /** Image generation result */
104
104
  export interface ImageResult {
105
105
  url?: string;
106
106
  b64?: string;
107
107
  }
108
108
  /**
109
- * 单个 LLM 实例的极简调用接口。
110
- * type=chat 时提供 chattype=image 时提供 generateImage
111
- * chat 型可选提供 chatWithTools 以支持 ReAct/Agent 工具调用。
109
+ * Minimal interface for a single LLM instance.
110
+ * type=chat provides chat; type=image provides generateImage.
111
+ * chat type may optionally provide chatWithTools for ReAct/Agent tool calling.
112
112
  */
113
113
  export interface ILLMClient {
114
114
  readonly id: string;
115
115
  readonly type: LLMType;
116
- /** 对话(type=chat 时可用) */
116
+ /** Chat (available when type=chat) */
117
117
  chat(messages: ChatMessage[]): Promise<ChatResult>;
118
118
  /**
119
- * 带工具调用的对话(type=chat 时可选;用于 ReAct/Agent)。
120
- * 若未实现,调用方可用 chat 轮询或使用其他客户端。
119
+ * Chat with tools (optional when type=chat; for ReAct/Agent).
120
+ * If not implemented, caller may poll with chat or use another client.
121
121
  */
122
122
  chatWithTools?(messages: ChatWithToolsMessage[], tools: ToolDefinition[], options?: {
123
123
  timeoutMs?: number;
124
124
  }): Promise<ChatWithToolsResult>;
125
- /** 图像生成(type=image 时可用);否则可抛错或忽略 */
125
+ /** Image generation (when type=image); otherwise may throw or be ignored */
126
126
  generateImage?(options: {
127
127
  prompt: string;
128
128
  size?: string;
@@ -130,7 +130,7 @@ export interface ILLMClient {
130
130
  }): Promise<ImageResult>;
131
131
  }
132
132
  /**
133
- * llm section 创建的 LLM 注册表:按 id 获取实例。
133
+ * LLM registry created from llm section: get instance by id.
134
134
  */
135
135
  export interface ILLMRegistry {
136
136
  get(id: string): ILLMClient | undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,6CAA6C;AAC7C,MAAM,MAAM,OAAO,GAAG,MAAM,GAAG,OAAO,CAAC;AAEvC,gDAAgD;AAChD,MAAM,WAAW,SAAS;IACxB,8BAA8B;IAC9B,EAAE,EAAE,MAAM,CAAC;IACX,mBAAmB;IACnB,IAAI,EAAE,OAAO,CAAC;IACd,8CAA8C;IAC9C,QAAQ,EAAE,MAAM,CAAC;IACjB,iCAAiC;IACjC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,kBAAkB;IAClB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,sBAAsB;IACtB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,qDAAqD;IACrD,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,eAAe;IACf,CAAC,GAAG,EAAE,MAA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AI,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC;CAC9F;AAED;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,GAAG,CAAC,EAAE,EAAE,MAAM,GAAG,UAAU,GAAG,SAAS,CAAC;IACxC,SAAS,IAAI,MAAM,GAAG,SAAS,CAAC;IAChC,GAAG,IAAI,MAAM,EAAE,CAAC;CACjB"}
package/package.json CHANGED
@@ -1,8 +1,12 @@
1
1
  {
2
2
  "name": "@easynet/agent-llm",
3
- "version": "1.0.2",
3
+ "version": "1.0.4",
4
4
  "description": "Agent LLM: multi-provider, multi-model, simple chat/image API. Consumes agent.yaml llm section.",
5
5
  "type": "module",
6
+ "bin": {
7
+ "agent-llm": "./dist/cli.js",
8
+ "@easynet/agent-llm": "./dist/cli.js"
9
+ },
6
10
  "main": "./dist/index.js",
7
11
  "types": "./dist/index.d.ts",
8
12
  "scripts": {
@@ -11,14 +15,17 @@
11
15
  "test": "vitest run",
12
16
  "test:watch": "vitest",
13
17
  "test:llm-live": "vitest run llm-live.test.ts",
14
- "test:link": "vitest run -t 'connects to CIS'",
18
+ "test:link": "vitest run -t 'invokes OpenAI-compatible API'",
19
+ "example:agent": "cd examples && npm run start",
15
20
  "typecheck": "tsc --noEmit"
16
21
  },
17
22
  "dependencies": {
18
- "@langchain/core": ">=0.3.0",
19
- "@langchain/openai": "^1.2.3",
23
+ "@langchain/core": ">=0.3.58 <0.4.0",
24
+ "@langchain/openai": "^0.5.0",
20
25
  "axios": "^1.7.0",
21
- "openai": "^4.77.0"
26
+ "openai": "^4.77.0",
27
+ "yaml": "^2.7.0",
28
+ "zod": "^3.23.0"
22
29
  },
23
30
  "devDependencies": {
24
31
  "@semantic-release/git": "^10.0.1",