@mizchi/vlmkit-ai 0.8.1 → 0.9.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -3,7 +3,7 @@
3
3
  VLM / LLM clients and reasoning pipeline used by VRT to interpret diff
4
4
  images and natural-language intent.
5
5
 
6
- Part of the [`vrt`](https://github.com/mizchi/vrt) monorepo.
6
+ Part of the [`vlmkit`](https://github.com/mizchi/vlmkit) monorepo.
7
7
 
8
8
  ## Install
9
9
 
@@ -41,9 +41,9 @@ const reasoning = await runReasoning({ /* diff context */ });
41
41
 
42
42
  | Variable | Purpose |
43
43
  |---|---|
44
- | `VRT_LLM_PROVIDER` | `gemini` (default) \| `anthropic` |
45
- | `VRT_LLM_MODEL` | Override provider default model |
46
- | `VRT_VLM_MODEL` | OpenRouter VLM model id |
44
+ | `VLMKIT_LLM_PROVIDER` | `gemini` (default) \| `anthropic` |
45
+ | `VLMKIT_LLM_MODEL` | Override provider default model |
46
+ | `VLMKIT_VLM_MODEL` | OpenRouter VLM model id |
47
47
  | `OPENROUTER_API_KEY` | VLM access |
48
48
  | `GEMINI_API_KEY` | Gemini LLM access |
49
49
  | `ANTHROPIC_API_KEY` | Anthropic LLM access |
package/dist/errors.d.mts CHANGED
@@ -15,7 +15,7 @@
15
15
  * Codes are stable; new ones can only be added (never renumbered or
16
16
  * removed) in minor versions.
17
17
  */
18
- type VrtConfigErrorCode = /** Required env var (`OPENROUTER_API_KEY`, `GEMINI_API_KEY`, `ANTHROPIC_API_KEY`) not set. */"MISSING_KEY" /** Provider/model id doesn't resolve. */ | "INVALID_MODEL" /** Model substring matches more than one candidate. */ | "MULTIPLE_MATCHES" /** `VRT_LLM_PROVIDER` value is not one of the known providers. */ | "INVALID_PROVIDER" /** No provider in the fallback chain has an API key configured. */ | "NO_PROVIDER_AVAILABLE" /** An optional runtime dependency (e.g. `@google/generative-ai`) failed to import. */ | "MISSING_DEPENDENCY" /** Caller-supplied request parameters are malformed (empty prompt, out-of-range size, etc.). */ | "INVALID_REQUEST";
18
+ type VrtConfigErrorCode = /** Required env var (`OPENROUTER_API_KEY`, `GEMINI_API_KEY`, `ANTHROPIC_API_KEY`) not set. */"MISSING_KEY" /** Provider/model id doesn't resolve. */ | "INVALID_MODEL" /** Model substring matches more than one candidate. */ | "MULTIPLE_MATCHES" /** `VLMKIT_LLM_PROVIDER` value is not one of the known providers. */ | "INVALID_PROVIDER" /** No provider in the fallback chain has an API key configured. */ | "NO_PROVIDER_AVAILABLE" /** An optional runtime dependency (e.g. `@google/generative-ai`) failed to import. */ | "MISSING_DEPENDENCY" /** Caller-supplied request parameters are malformed (empty prompt, out-of-range size, etc.). */ | "INVALID_REQUEST";
19
19
  declare class VrtConfigError extends Error {
20
20
  readonly code: VrtConfigErrorCode;
21
21
  constructor(code: VrtConfigErrorCode, message: string);
@@ -58,7 +58,7 @@ type LLMProviderName = "gemini" | "anthropic" | "openrouter";
58
58
  /**
59
59
  * Create a unified LLM client.
60
60
  *
61
- * Provider is set via `VRT_LLM_PROVIDER` env var (default: `gemini`).
61
+ * Provider is set via `VLMKIT_LLM_PROVIDER` env var (default: `gemini`).
62
62
  *
63
63
  * Throws `VrtConfigError` when the resolved provider has no API key
64
64
  * (`code: "MISSING_KEY"`) or the provider value is unknown
@@ -75,7 +75,7 @@ interface CreateLLMProviderOptions {
75
75
  }
76
76
  /**
77
77
  * Backwards-compatible: returns the existing `LLMProvider` interface.
78
- * Uses the provider specified by `VRT_LLM_PROVIDER`. Falls back to
78
+ * Uses the provider specified by `VLMKIT_LLM_PROVIDER`. Falls back to
79
79
  * other providers if the requested key is missing.
80
80
  *
81
81
  * Throws `VrtConfigError` (`code: "NO_PROVIDER_AVAILABLE"`) when no
@@ -1,4 +1,5 @@
1
1
  import { VrtConfigError } from "./errors.mjs";
2
+ import { readEnv } from "@mizchi/vlmkit-core/project-config.ts";
2
3
  //#region src/llm-client.ts
3
4
  function createAnthropicClient(apiKey, model) {
4
5
  const modelId = model ?? "claude-sonnet-4-6";
@@ -218,21 +219,21 @@ const VALID_PROVIDERS = new Set([
218
219
  /**
219
220
  * Resolve provider and key from environment variables.
220
221
  *
221
- * VRT_LLM_PROVIDER: gemini (default) | anthropic | openrouter
222
- * VRT_LLM_MODEL: model ID (defaults to provider's default)
222
+ * VLMKIT_LLM_PROVIDER: gemini (default) | anthropic | openrouter
223
+ * VLMKIT_LLM_MODEL: model ID (defaults to provider's default)
223
224
  *
224
225
  * Returns a config, or describes why no config was available. The
225
226
  * factory decides whether to throw based on `throwIfMissing`.
226
227
  */
227
228
  function resolveProviderConfig(options) {
228
- const rawProvider = options?.provider ?? process.env.VRT_LLM_PROVIDER ?? "gemini";
229
+ const rawProvider = options?.provider ?? readEnv("LLM_PROVIDER") ?? "gemini";
229
230
  if (!VALID_PROVIDERS.has(rawProvider)) return {
230
231
  ok: false,
231
232
  code: "INVALID_PROVIDER",
232
- message: `Unknown VRT_LLM_PROVIDER "${rawProvider}". Expected: gemini | anthropic | openrouter.`
233
+ message: `Unknown VLMKIT_LLM_PROVIDER "${rawProvider}". Expected: gemini | anthropic | openrouter.`
233
234
  };
234
235
  const provider = rawProvider;
235
- const model = options?.model ?? process.env.VRT_LLM_MODEL ?? void 0;
236
+ const model = options?.model ?? readEnv("LLM_MODEL") ?? void 0;
236
237
  const keyMap = {
237
238
  gemini: process.env.GEMINI_API_KEY ?? process.env.GOOGLE_AI_API_KEY,
238
239
  anthropic: process.env.ANTHROPIC_API_KEY,
@@ -259,7 +260,7 @@ function resolveProviderConfig(options) {
259
260
  /**
260
261
  * Create a unified LLM client.
261
262
  *
262
- * Provider is set via `VRT_LLM_PROVIDER` env var (default: `gemini`).
263
+ * Provider is set via `VLMKIT_LLM_PROVIDER` env var (default: `gemini`).
263
264
  *
264
265
  * Throws `VrtConfigError` when the resolved provider has no API key
265
266
  * (`code: "MISSING_KEY"`) or the provider value is unknown
@@ -281,7 +282,7 @@ function createUnifiedLLMClient(options) {
281
282
  }
282
283
  /**
283
284
  * Backwards-compatible: returns the existing `LLMProvider` interface.
284
- * Uses the provider specified by `VRT_LLM_PROVIDER`. Falls back to
285
+ * Uses the provider specified by `VLMKIT_LLM_PROVIDER`. Falls back to
285
286
  * other providers if the requested key is missing.
286
287
  *
287
288
  * Throws `VrtConfigError` (`code: "NO_PROVIDER_AVAILABLE"`) when no
@@ -35,7 +35,7 @@ interface FixSuggestion {
35
35
  interface PipelineConfig {
36
36
  /** Stage 1: VLM for image analysis (default: qwen3-vl-8b via OpenRouter) */
37
37
  vlmModel?: string;
38
- /** Stage 2: LLM for code generation (default: from VRT_LLM_PROVIDER) */
38
+ /** Stage 2: LLM for code generation (default: from VLMKIT_LLM_PROVIDER) */
39
39
  llmProvider?: "gemini" | "anthropic" | "openrouter";
40
40
  llmModel?: string;
41
41
  /** Image resolution (default: medium = 400x300) */
@@ -1,6 +1,7 @@
1
1
  import { VrtConfigError } from "./errors.mjs";
2
2
  import { createUnifiedLLMClient } from "./llm-client.mjs";
3
3
  import { createVlmClient, resolveModel } from "./vlm-client.mjs";
4
+ import { readEnv } from "@mizchi/vlmkit-core/project-config.ts";
4
5
  import { resizeBase64Png } from "@mizchi/vlmkit-core/image-resize.ts";
5
6
  //#region src/reasoning-pipeline.ts
6
7
  /**
@@ -133,7 +134,7 @@ function parseStage2Response(raw) {
133
134
  function createReasoningPipeline(config) {
134
135
  const throwIfMissing = config?.throwIfMissing ?? true;
135
136
  let vlmClient = null;
136
- let vlmModelId = config?.vlmModel ?? process.env.VRT_VLM_MODEL ?? "bytedance/ui-tars-1.5-7b";
137
+ let vlmModelId = config?.vlmModel ?? readEnv("VLM_MODEL") ?? "bytedance/ui-tars-1.5-7b";
137
138
  let llmClient = createUnifiedLLMClient({
138
139
  provider: config?.llmProvider,
139
140
  model: config?.llmModel,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mizchi/vlmkit-ai",
3
- "version": "0.8.1",
3
+ "version": "0.9.1",
4
4
  "description": "VLM / LLM clients, reasoning pipeline, and NLP helpers used by VRT to interpret diff images and natural-language intent.",
5
5
  "license": "MIT",
6
6
  "author": "mizchi",
@@ -37,7 +37,7 @@
37
37
  },
38
38
  "dependencies": {
39
39
  "@google/generative-ai": "^0.24.1",
40
- "@mizchi/vlmkit-core": "0.8.1"
40
+ "@mizchi/vlmkit-core": "0.9.1"
41
41
  },
42
42
  "scripts": {
43
43
  "build": "pnpm --dir ../.. exec tsdown --config tsdown.packages.config.ts --filter @mizchi/vlmkit-ai",