qlogicagent 2.10.0 → 2.10.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/dist/agent.js +16 -16
- package/dist/cli.js +263 -264
- package/dist/index.js +262 -263
- package/dist/types/cli/handlers/settings-handler.d.ts +3 -15
- package/dist/types/cli/handlers/settings-handler.remote-catalog.test.d.ts +1 -0
- package/dist/types/runtime/infra/llmrouter-catalog.d.ts +49 -0
- package/dist/types/runtime/infra/model-registry.d.ts +36 -101
- package/package.json +1 -1
- package/dist/types/runtime/infra/builtin-providers.d.ts +0 -36
|
@@ -1,24 +1,12 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Settings RPC handlers — model management system.
|
|
3
|
-
*
|
|
4
|
-
* All model pool operations go through ModelRegistry (single source of truth).
|
|
5
|
-
* Handles: settings.listSupportedProviders, settings.addKey, settings.removeKey,
|
|
6
|
-
* settings.toggleKey, settings.listModels, settings.setActiveModel,
|
|
7
|
-
* settings.getActiveModel, settings.getOverview, settings.refreshModels
|
|
8
|
-
*/
|
|
9
1
|
import type { AgentRpcRequest } from "../../protocol/wire/agent-rpc.js";
|
|
10
|
-
export declare function handleSettingsListProviders(this: any, msg: AgentRpcRequest): void
|
|
2
|
+
export declare function handleSettingsListProviders(this: any, msg: AgentRpcRequest): Promise<void>;
|
|
11
3
|
export declare function handleSettingsAddKey(this: any, msg: AgentRpcRequest): Promise<void>;
|
|
12
4
|
export declare function handleSettingsRemoveKey(this: any, msg: AgentRpcRequest): void;
|
|
13
5
|
export declare function handleSettingsToggleKey(this: any, msg: AgentRpcRequest): void;
|
|
14
6
|
export declare function handleSettingsToggleModel(this: any, msg: AgentRpcRequest): void;
|
|
15
|
-
export declare function handleSettingsListModels(this: any, msg: AgentRpcRequest): void
|
|
7
|
+
export declare function handleSettingsListModels(this: any, msg: AgentRpcRequest): Promise<void>;
|
|
16
8
|
export declare function handleSettingsSetActiveModel(this: any, msg: AgentRpcRequest): void;
|
|
17
9
|
export declare function handleSettingsGetActiveModel(this: any, msg: AgentRpcRequest): void;
|
|
18
|
-
export declare function handleSettingsGetOverview(this: any, msg: AgentRpcRequest): void
|
|
10
|
+
export declare function handleSettingsGetOverview(this: any, msg: AgentRpcRequest): Promise<void>;
|
|
19
11
|
export declare function handleSettingsRefreshModels(this: any, msg: AgentRpcRequest): Promise<void>;
|
|
20
|
-
/**
|
|
21
|
-
* Validate a provider API key by making a minimal /models list request.
|
|
22
|
-
* Does not store the key; just verifies connectivity + auth.
|
|
23
|
-
*/
|
|
24
12
|
export declare function handleSettingsValidateKey(this: any, msg: AgentRpcRequest): Promise<void>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type { ModelEntry, ModelRegistry } from "./model-registry.js";
|
|
2
|
+
export declare const LLMROUTER_CATALOG_UNAVAILABLE_MESSAGE = "\u65E0\u6CD5\u8FDE\u63A5 llmrouter \u6A21\u578B\u76EE\u5F55";
|
|
3
|
+
export declare class LlmrouterCatalogUnavailableError extends Error {
|
|
4
|
+
constructor(message?: string);
|
|
5
|
+
}
|
|
6
|
+
export interface LlmrouterCatalogProvider {
|
|
7
|
+
id: string;
|
|
8
|
+
name?: string;
|
|
9
|
+
displayName?: string;
|
|
10
|
+
baseUrl?: string;
|
|
11
|
+
base_url?: string;
|
|
12
|
+
transport?: string;
|
|
13
|
+
models?: Array<{
|
|
14
|
+
id?: string;
|
|
15
|
+
}>;
|
|
16
|
+
}
|
|
17
|
+
export interface LlmrouterCatalogModel {
|
|
18
|
+
id: string;
|
|
19
|
+
public_model?: string;
|
|
20
|
+
publicModel?: string;
|
|
21
|
+
provider?: string;
|
|
22
|
+
owned_by?: string;
|
|
23
|
+
native_model_id?: string;
|
|
24
|
+
nativeModelId?: string;
|
|
25
|
+
display_name?: string;
|
|
26
|
+
displayName?: string;
|
|
27
|
+
name?: string;
|
|
28
|
+
category?: string;
|
|
29
|
+
purposes?: string[];
|
|
30
|
+
baseUrl?: string;
|
|
31
|
+
base_url?: string;
|
|
32
|
+
provider_transport?: string;
|
|
33
|
+
providerTransport?: string;
|
|
34
|
+
context_window?: number;
|
|
35
|
+
contextWindow?: number;
|
|
36
|
+
max_output?: number;
|
|
37
|
+
maxOutput?: number;
|
|
38
|
+
stream_required?: boolean;
|
|
39
|
+
streamRequired?: boolean;
|
|
40
|
+
capabilities?: string[];
|
|
41
|
+
pricing?: Record<string, unknown>;
|
|
42
|
+
}
|
|
43
|
+
export declare function listLlmrouterCatalogProviders(): Promise<LlmrouterCatalogProvider[]>;
|
|
44
|
+
export declare function listLlmrouterCatalogModels(): Promise<LlmrouterCatalogModel[]>;
|
|
45
|
+
export declare function providerDisplayName(provider: LlmrouterCatalogProvider): string;
|
|
46
|
+
export declare function providerBaseUrl(provider: LlmrouterCatalogProvider): string | undefined;
|
|
47
|
+
export declare function getLlmrouterCatalogProvider(providerId: string): Promise<LlmrouterCatalogProvider | null>;
|
|
48
|
+
export declare function refreshRegistryFromLlmrouterCatalog(registry: ModelRegistry): Promise<ModelEntry[]>;
|
|
49
|
+
export declare function toModelEntry(model: LlmrouterCatalogModel): ModelEntry | null;
|
|
@@ -1,19 +1,24 @@
|
|
|
1
|
-
|
|
2
|
-
* Model Registry — centralized model pool + per-purpose binding.
|
|
3
|
-
*
|
|
4
|
-
* Architecture: User adds Provider keys → enables models → binds each purpose to a model.
|
|
5
|
-
* Any code needing a model calls `registry.getActiveModel(purpose)`.
|
|
6
|
-
* Turn handler, media handler, STT, TTS — all go through this single source of truth.
|
|
7
|
-
*
|
|
8
|
-
* Persistence: ~/.qlogicagent/settings.json
|
|
9
|
-
* Runtime state (key health, inFlight): in-memory via KeyPool
|
|
10
|
-
*/
|
|
11
|
-
import { type ProviderPoolConfig, type KeyConfig, type LoadBalanceStrategy, type KeyHandle, type PoolStatus } from "./key-pool.js";
|
|
12
|
-
import { type ModelInfo, type ProviderDef } from "@qlogic/provider-core";
|
|
1
|
+
import { type KeyConfig, type KeyHandle, type LoadBalanceStrategy, type PoolStatus, type ProviderPoolConfig } from "./key-pool.js";
|
|
13
2
|
export type RegistryChangeCallback = () => void;
|
|
14
|
-
/** Purpose categories for model routing. */
|
|
15
3
|
export type ModelPurpose = "textGeneration" | "smallModel" | "stt" | "tts" | "imageGeneration" | "imageUnderstanding" | "videoGeneration" | "videoUnderstanding" | "threeDGeneration" | "embedding" | "voiceClone" | "musicGeneration" | "realtimeAudio" | "realtimeVideo";
|
|
16
|
-
|
|
4
|
+
export interface ModelInfo {
|
|
5
|
+
id: string;
|
|
6
|
+
name?: string;
|
|
7
|
+
contextWindow?: number;
|
|
8
|
+
maxOutput?: number;
|
|
9
|
+
streamRequired?: boolean;
|
|
10
|
+
vision?: boolean;
|
|
11
|
+
mediaType?: string;
|
|
12
|
+
}
|
|
13
|
+
export interface ProviderDef {
|
|
14
|
+
id: string;
|
|
15
|
+
name: string;
|
|
16
|
+
transport: string;
|
|
17
|
+
baseUrl: string;
|
|
18
|
+
defaultModel?: string;
|
|
19
|
+
group?: string;
|
|
20
|
+
models?: ModelInfo[];
|
|
21
|
+
}
|
|
17
22
|
export interface ModelEntry {
|
|
18
23
|
id: string;
|
|
19
24
|
provider: string;
|
|
@@ -22,17 +27,23 @@ export interface ModelEntry {
|
|
|
22
27
|
purposes: ModelPurpose[];
|
|
23
28
|
baseUrl?: string;
|
|
24
29
|
enabled: boolean;
|
|
30
|
+
transport?: string;
|
|
31
|
+
contextWindow?: number;
|
|
32
|
+
maxOutput?: number;
|
|
33
|
+
streamRequired?: boolean;
|
|
34
|
+
capabilities?: string[];
|
|
35
|
+
pricing?: Record<string, unknown>;
|
|
25
36
|
}
|
|
26
|
-
/** Per-purpose binding: maps purpose → model ID. */
|
|
27
37
|
export type PurposeBindings = Partial<Record<ModelPurpose, string>>;
|
|
28
|
-
/** Persistent settings.json schema (new architecture). */
|
|
29
38
|
export interface ModelRegistryConfig {
|
|
30
39
|
providers: ProviderPoolConfig[];
|
|
31
|
-
models:
|
|
40
|
+
models: Array<{
|
|
41
|
+
id: string;
|
|
42
|
+
enabled?: boolean;
|
|
43
|
+
}>;
|
|
32
44
|
bindings: PurposeBindings;
|
|
33
45
|
tunables?: Record<string, unknown>;
|
|
34
46
|
}
|
|
35
|
-
/** Resolved model ready for API call. */
|
|
36
47
|
export interface ResolvedModel {
|
|
37
48
|
provider: string;
|
|
38
49
|
model: string;
|
|
@@ -40,34 +51,18 @@ export interface ResolvedModel {
|
|
|
40
51
|
baseUrl?: string;
|
|
41
52
|
keyHandle: KeyHandle;
|
|
42
53
|
}
|
|
54
|
+
export declare const ALL_PURPOSES: ModelPurpose[];
|
|
43
55
|
export declare class ModelRegistry {
|
|
44
56
|
private keyPool;
|
|
45
57
|
private models;
|
|
58
|
+
private modelEnabledOverrides;
|
|
46
59
|
private bindings;
|
|
47
60
|
private settingsPath;
|
|
48
61
|
private changeListeners;
|
|
49
62
|
constructor(config?: ModelRegistryConfig);
|
|
50
|
-
/**
|
|
51
|
-
* Get the currently bound model for a purpose, with a live API key from the pool.
|
|
52
|
-
* Returns null if purpose is not bound or no key is available.
|
|
53
|
-
*
|
|
54
|
-
* IMPORTANT: Caller MUST call result.keyHandle.release({ success, tokens? }) when done.
|
|
55
|
-
*/
|
|
56
63
|
getActiveModel(purpose: ModelPurpose): ResolvedModel | null;
|
|
57
|
-
/**
|
|
58
|
-
* Peek at the bound model for a purpose WITHOUT acquiring a key.
|
|
59
|
-
* Useful for UI display, description generation, etc.
|
|
60
|
-
*/
|
|
61
64
|
peekActiveModel(purpose: ModelPurpose): ModelEntry | null;
|
|
62
|
-
/**
|
|
63
|
-
* Check if a purpose has an available model + key (without acquiring).
|
|
64
|
-
*/
|
|
65
65
|
isAvailable(purpose: ModelPurpose): boolean;
|
|
66
|
-
/**
|
|
67
|
-
* Resolve a model name for a purpose, falling back to textGeneration if not bound.
|
|
68
|
-
* Returns the raw model string (e.g. "deepseek-v4-flash") or null if nothing configured.
|
|
69
|
-
* Does NOT acquire a key — use for cases where the caller already has transport/key.
|
|
70
|
-
*/
|
|
71
66
|
resolveModelForPurpose(purpose: ModelPurpose): string | null;
|
|
72
67
|
addProvider(providerId: string, opts?: {
|
|
73
68
|
baseUrl?: string;
|
|
@@ -89,6 +84,8 @@ export declare class ModelRegistry {
|
|
|
89
84
|
addModel(entry: Omit<ModelEntry, "id"> & {
|
|
90
85
|
id?: string;
|
|
91
86
|
}): string;
|
|
87
|
+
replaceCatalogModels(entries: ModelEntry[]): void;
|
|
88
|
+
migrateModelIds(aliasToNative: Map<string, string>): void;
|
|
92
89
|
removeModel(id: string): void;
|
|
93
90
|
enableModel(id: string): void;
|
|
94
91
|
disableModel(id: string): void;
|
|
@@ -104,84 +101,22 @@ export declare class ModelRegistry {
|
|
|
104
101
|
getAllBindings(): Record<string, ModelEntry | null>;
|
|
105
102
|
getProviderStatus(providerId: string): PoolStatus | null;
|
|
106
103
|
getAllProviderStatus(): PoolStatus[];
|
|
107
|
-
/** Save current config to settings.json. Preserves non-model fields (tunables, theme, etc.). */
|
|
108
104
|
save(): void;
|
|
109
|
-
/** Load config from settings.json. Returns false if file not found or parse error. */
|
|
110
105
|
load(): boolean;
|
|
111
|
-
/** Export full config (for serialization/transfer). */
|
|
112
106
|
exportConfig(): ModelRegistryConfig;
|
|
113
|
-
/**
|
|
114
|
-
* Read a tunable value from settings.json tunables section.
|
|
115
|
-
* Returns undefined if not set. Does NOT write — read-only accessor.
|
|
116
|
-
*/
|
|
117
107
|
getTunable<T = unknown>(key: string): T | undefined;
|
|
118
|
-
private _providerRegistry;
|
|
119
|
-
private getProviderRegistry;
|
|
120
|
-
/**
|
|
121
|
-
* Get model metadata (streamRequired, contextWindow, etc.) from the merged
|
|
122
|
-
* provider-core registry. Replaces direct `this.registry.getModelInfo(...)`.
|
|
123
|
-
*/
|
|
124
108
|
getModelInfo(providerId: string, modelId: string): ModelInfo | undefined;
|
|
125
|
-
/**
|
|
126
|
-
* Get the default model id for a provider (from builtin-providers).
|
|
127
|
-
* Replaces `this.registry.getProvider(provider)?.defaultModel`.
|
|
128
|
-
*/
|
|
129
109
|
getProviderDefaultModel(providerId: string): string | undefined;
|
|
130
|
-
/**
|
|
131
|
-
* List all known provider definitions (builtin + catalog).
|
|
132
|
-
* Replaces `this.registry.listProviders()`.
|
|
133
|
-
*/
|
|
134
110
|
listProviderDefs(): ProviderDef[];
|
|
135
|
-
/**
|
|
136
|
-
* Resolve an API key for a provider via env vars (fallback when KeyPool has no key).
|
|
137
|
-
* Replaces `this.registry.resolveApiKey(providerId)`.
|
|
138
|
-
*/
|
|
139
111
|
resolveProviderApiKey(providerId: string): string | undefined;
|
|
140
|
-
/**
|
|
141
|
-
* Register a callback to be notified when registry state changes
|
|
142
|
-
* (binding change, model add/remove, key change, save/load).
|
|
143
|
-
* Returns an unsubscribe function.
|
|
144
|
-
*/
|
|
145
112
|
onChange(callback: RegistryChangeCallback): () => void;
|
|
146
|
-
private emitChange;
|
|
147
|
-
/**
|
|
148
|
-
* Snapshot one available key for a provider WITHOUT holding it (for legacy flat-map consumers).
|
|
149
|
-
* Returns null if no healthy key exists.
|
|
150
|
-
*/
|
|
151
113
|
getKeyForProvider(providerId: string): string | null;
|
|
152
|
-
/**
|
|
153
|
-
* Snapshot one key per provider (for media tools flat apiKeys map).
|
|
154
|
-
*/
|
|
155
114
|
snapshotProviderKeys(): Record<string, string>;
|
|
156
115
|
private getProviderBaseUrl;
|
|
116
|
+
private loadModelState;
|
|
117
|
+
private exportModelState;
|
|
118
|
+
private emitChange;
|
|
157
119
|
}
|
|
158
|
-
export declare const ALL_PURPOSES: ModelPurpose[];
|
|
159
|
-
/**
|
|
160
|
-
* Get the global ModelRegistry singleton.
|
|
161
|
-
* Lazily loads from settings.json on first access.
|
|
162
|
-
*/
|
|
163
120
|
export declare function getModelRegistry(): ModelRegistry;
|
|
164
|
-
/**
|
|
165
|
-
* Reset the global singleton (for testing or hot-reload).
|
|
166
|
-
*/
|
|
167
121
|
export declare function resetModelRegistry(): void;
|
|
168
|
-
/**
|
|
169
|
-
* Derive which purposes a model supports from its ModelInfo metadata.
|
|
170
|
-
* Layer 1: ModelCatalog (models.dev) modalities → purpose mapping.
|
|
171
|
-
*
|
|
172
|
-
* Priority: mediaType field → vision field → fallback to textGeneration.
|
|
173
|
-
*/
|
|
174
122
|
export declare function deriveModelPurposes(model: ModelInfo): ModelPurpose[];
|
|
175
|
-
/**
|
|
176
|
-
* Layer 3: Name-based heuristic for models not in ModelCatalog or builtin-providers.
|
|
177
|
-
*/
|
|
178
|
-
export declare function heuristicModelPurposes(modelId: string): ModelPurpose[];
|
|
179
|
-
/**
|
|
180
|
-
* Refresh models from ModelCatalog (remote models.dev + disk cache) for given providers.
|
|
181
|
-
* Merges discovered models into the registry without overwriting user-modified entries.
|
|
182
|
-
*/
|
|
183
|
-
export declare function refreshModelsFromCatalog(registry: ModelRegistry, providerIds: string[]): void;
|
|
184
|
-
/**
|
|
185
|
-
* Force refresh the ModelCatalog from remote, then merge into registry.
|
|
186
|
-
*/
|
|
187
|
-
export declare function forceRefreshCatalog(registry: ModelRegistry, providerIds: string[]): Promise<boolean>;
|
package/package.json
CHANGED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Supported provider metadata for settings RPC.
|
|
3
|
-
*
|
|
4
|
-
* Bridges provider-core's BUILTIN_PROVIDERS into the ModelPurpose system.
|
|
5
|
-
* This is the authoritative list of providers shown in "Add Key" UI.
|
|
6
|
-
*
|
|
7
|
-
* IMPORTANT: Model lists here are the Layer 2 (offline fallback) data source.
|
|
8
|
-
* Layer 1 is ModelCatalog (models.dev remote). These two are the ONLY sources.
|
|
9
|
-
*/
|
|
10
|
-
import type { ModelPurpose } from "./model-registry.js";
|
|
11
|
-
export interface KnownModelMeta {
|
|
12
|
-
model: string;
|
|
13
|
-
displayName: string;
|
|
14
|
-
purposes: ModelPurpose[];
|
|
15
|
-
baseUrl?: string;
|
|
16
|
-
}
|
|
17
|
-
export interface SupportedProviderMeta {
|
|
18
|
-
id: string;
|
|
19
|
-
displayName: string;
|
|
20
|
-
baseUrl: string;
|
|
21
|
-
defaultRateLimit?: {
|
|
22
|
-
rpm?: number;
|
|
23
|
-
tpm?: number;
|
|
24
|
-
};
|
|
25
|
-
knownModels: KnownModelMeta[];
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* Minimal offline fallback providers.
|
|
29
|
-
* Remote catalog (Layer 1) has text generation models; this Layer 2 keeps ONLY
|
|
30
|
-
* specialized models that remote may not cover: embedding, TTS, STT, image gen,
|
|
31
|
-
* video gen, music gen, 3D gen, realtime voice/video, voice clone.
|
|
32
|
-
*
|
|
33
|
-
* All providers are kept (for Add Key UI dropdown + baseUrl lookup).
|
|
34
|
-
* Text generation / image understanding models are NOT listed here — remote always has them.
|
|
35
|
-
*/
|
|
36
|
-
export declare const SUPPORTED_PROVIDERS: SupportedProviderMeta[];
|