@gaunt-sloth/core 0.1.7 → 2.0.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.gsloth.exec.md +26 -0
- package/dist/config.d.ts +81 -1
- package/dist/config.js +118 -3
- package/dist/config.js.map +1 -1
- package/dist/constants.d.ts +1 -0
- package/dist/constants.js +1 -0
- package/dist/constants.js.map +1 -1
- package/dist/core/GthAbstractAgent.d.ts +73 -0
- package/dist/core/GthAbstractAgent.js +448 -0
- package/dist/core/GthAbstractAgent.js.map +1 -0
- package/dist/core/GthAgentRunner.d.ts +21 -2
- package/dist/core/GthAgentRunner.js +30 -2
- package/dist/core/GthAgentRunner.js.map +1 -1
- package/dist/core/GthLangChainAgent.d.ts +9 -75
- package/dist/core/GthLangChainAgent.js +13 -433
- package/dist/core/GthLangChainAgent.js.map +1 -1
- package/dist/core/types.d.ts +63 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/providers/anthropic.js +2 -2
- package/dist/providers/deepseek.js +2 -2
- package/dist/providers/deepseek.js.map +1 -1
- package/dist/providers/google-genai.js +2 -2
- package/dist/providers/google-genai.js.map +1 -1
- package/dist/providers/modelDiscovery.d.ts +196 -0
- package/dist/providers/modelDiscovery.js +362 -0
- package/dist/providers/modelDiscovery.js.map +1 -0
- package/dist/providers/ollama.d.ts +5 -0
- package/dist/providers/ollama.js +79 -0
- package/dist/providers/ollama.js.map +1 -0
- package/dist/providers/openai.js +28 -2
- package/dist/providers/openai.js.map +1 -1
- package/dist/providers/vertexai.js +2 -2
- package/dist/providers/vertexai.js.map +1 -1
- package/dist/providers/xai.js +2 -2
- package/dist/providers/xai.js.map +1 -1
- package/dist/runtime/singleShot.d.ts +19 -0
- package/dist/runtime/singleShot.js +62 -0
- package/dist/runtime/singleShot.js.map +1 -0
- package/dist/utils/fileUtils.d.ts +6 -0
- package/dist/utils/fileUtils.js +17 -0
- package/dist/utils/fileUtils.js.map +1 -1
- package/dist/utils/globalConfigUtils.d.ts +21 -0
- package/dist/utils/globalConfigUtils.js +25 -0
- package/dist/utils/globalConfigUtils.js.map +1 -1
- package/dist/utils/llmUtils.d.ts +1 -0
- package/dist/utils/llmUtils.js +4 -1
- package/dist/utils/llmUtils.js.map +1 -1
- package/dist/utils/systemUtils.d.ts +10 -0
- package/dist/utils/systemUtils.js +18 -1
- package/dist/utils/systemUtils.js.map +1 -1
- package/package.json +17 -14
package/dist/core/types.d.ts
CHANGED
|
@@ -20,13 +20,75 @@ export declare enum StatusLevel {
|
|
|
20
20
|
ERROR = 5,
|
|
21
21
|
STREAM = 6
|
|
22
22
|
}
|
|
23
|
-
export type GthCommand = 'ask' | 'pr' | 'review' | 'chat' | 'code' | 'api';
|
|
23
|
+
export type GthCommand = 'ask' | 'pr' | 'review' | 'chat' | 'code' | 'api' | 'exec';
|
|
24
|
+
/**
|
|
25
|
+
* Typed events emitted by the agent's {@link GthAgentInterface#streamWithEvents} path.
|
|
26
|
+
* This is the renderer contract shared by every consumer of an agent run — the AG-UI
|
|
27
|
+
* SSE encoder, the (future) TUI, and any embedder — so it is intentionally agnostic of
|
|
28
|
+
* how the underlying graph was built (lean `createAgent` or `createDeepAgent`).
|
|
29
|
+
*/
|
|
30
|
+
export type AgentStreamEvent = {
|
|
31
|
+
type: 'text';
|
|
32
|
+
delta: string;
|
|
33
|
+
} | {
|
|
34
|
+
type: 'reasoning_start';
|
|
35
|
+
} | {
|
|
36
|
+
type: 'reasoning_delta';
|
|
37
|
+
delta: string;
|
|
38
|
+
} | {
|
|
39
|
+
type: 'reasoning_end';
|
|
40
|
+
} | {
|
|
41
|
+
type: 'tool_start';
|
|
42
|
+
id: string;
|
|
43
|
+
name: string;
|
|
44
|
+
} | {
|
|
45
|
+
type: 'tool_args';
|
|
46
|
+
id: string;
|
|
47
|
+
delta: string;
|
|
48
|
+
} | {
|
|
49
|
+
type: 'tool_end';
|
|
50
|
+
id: string;
|
|
51
|
+
} | {
|
|
52
|
+
type: 'tool_result';
|
|
53
|
+
id: string;
|
|
54
|
+
content: string;
|
|
55
|
+
};
|
|
56
|
+
/**
|
|
57
|
+
* The minimal structural surface of a compiled LangGraph agent that the shared agent
|
|
58
|
+
* plumbing in {@link GthAbstractAgent} drives. Both `createAgent` (lean) and
|
|
59
|
+
* `createDeepAgent` return graphs that satisfy this, so the base class can stream/invoke
|
|
60
|
+
* either without knowing which builder produced it. Inputs are intentionally loose
|
|
61
|
+
* (`any`) so concrete builder return types assign without casts; the base re-applies
|
|
62
|
+
* precise typing at the point of use via `AIMessage`/`AIMessageChunk` guards.
|
|
63
|
+
*/
|
|
64
|
+
export interface GthCompiledGraph {
|
|
65
|
+
invoke(input: any, config?: RunnableConfig): Promise<{
|
|
66
|
+
messages: BaseMessage[];
|
|
67
|
+
}>;
|
|
68
|
+
stream(input: any, config?: any): Promise<IterableReadableStream<any>>;
|
|
69
|
+
}
|
|
24
70
|
export interface GthAgentInterface {
|
|
25
71
|
init(command: GthCommand | undefined, configIn: GthConfig, checkpointSaver?: BaseCheckpointSaver | undefined): Promise<void>;
|
|
26
72
|
invoke(messages: Message[], runConfig: RunnableConfig): Promise<string>;
|
|
27
73
|
stream(messages: Message[], runConfig: RunnableConfig): Promise<IterableReadableStream<string>>;
|
|
74
|
+
/**
|
|
75
|
+
* Stream the run as typed {@link AgentStreamEvent}s. If a client tool triggers
|
|
76
|
+
* `interrupt()` the underlying graph suspends; this generator ends cleanly so the
|
|
77
|
+
* transport can finish the run with the tool call hanging. Resume via
|
|
78
|
+
* {@link streamWithEventsResume} on the same `thread_id`.
|
|
79
|
+
*/
|
|
80
|
+
streamWithEvents(messages: Message[], runConfig: RunnableConfig, signal?: AbortSignal): AsyncGenerator<AgentStreamEvent>;
|
|
81
|
+
/** Resume a graph suspended via `interrupt()` with the supplied value. */
|
|
82
|
+
streamWithEventsResume(resumeValue: unknown, runConfig: RunnableConfig, queuedMessages?: BaseMessage[], signal?: AbortSignal): AsyncGenerator<AgentStreamEvent>;
|
|
28
83
|
cleanup?(): Promise<void>;
|
|
29
84
|
}
|
|
85
|
+
/**
|
|
86
|
+
* Factory that produces a {@link GthAgentInterface} implementation. Injected into
|
|
87
|
+
* {@link GthAgentRunner} so embedders can swap the lean `GthLangChainAgent` (default,
|
|
88
|
+
* in core) for a deep `GthDeepAgent` (in `@gaunt-sloth/agent`) without core ever
|
|
89
|
+
* importing deepagents.
|
|
90
|
+
*/
|
|
91
|
+
export type GthAgentFactory = (statusUpdate: StatusUpdateCallback, resolvers?: AgentResolvers) => GthAgentInterface;
|
|
30
92
|
export type ToolsResolver = (config: GthConfig, command?: GthCommand) => Promise<StructuredToolInterface[]>;
|
|
31
93
|
export type ToolsCleanup = () => Promise<void>;
|
|
32
94
|
export type MiddlewareResolver = (middleware: any[] | undefined, config: GthConfig) => Promise<any[]>;
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AACnC,cAAc,gBAAgB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AACnC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,kCAAkC,CAAC"}
|
|
@@ -12,13 +12,13 @@ export async function processJsonConfig(llmConfig) {
|
|
|
12
12
|
return new anthropic.ChatAnthropic({
|
|
13
13
|
...llmConfig,
|
|
14
14
|
apiKey: anthropicApiKey,
|
|
15
|
-
model: llmConfig.model || 'claude-sonnet-4-
|
|
15
|
+
model: llmConfig.model || 'claude-sonnet-4-6',
|
|
16
16
|
});
|
|
17
17
|
}
|
|
18
18
|
const jsonContent = `{
|
|
19
19
|
"llm": {
|
|
20
20
|
"type": "anthropic",
|
|
21
|
-
"model": "claude-sonnet-4-
|
|
21
|
+
"model": "claude-sonnet-4-6"
|
|
22
22
|
}
|
|
23
23
|
}`;
|
|
24
24
|
// noinspection JSUnusedGlobalSymbols
|
|
@@ -9,13 +9,13 @@ export async function processJsonConfig(llmConfig) {
|
|
|
9
9
|
return new deepseek.ChatDeepSeek({
|
|
10
10
|
...llmConfig,
|
|
11
11
|
apiKey: deepseekApiKey,
|
|
12
|
-
model: llmConfig.model || 'deepseek-
|
|
12
|
+
model: llmConfig.model || 'deepseek-v4-pro',
|
|
13
13
|
});
|
|
14
14
|
}
|
|
15
15
|
const jsonContent = `{
|
|
16
16
|
"llm": {
|
|
17
17
|
"type": "deepseek",
|
|
18
|
-
"model": "deepseek-
|
|
18
|
+
"model": "deepseek-v4-pro"
|
|
19
19
|
}
|
|
20
20
|
}`;
|
|
21
21
|
export function init(configFileName) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deepseek.js","sourceRoot":"","sources":["../../src/providers/deepseek.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,EAAE,GAAG,EAAE,MAAM,2BAA2B,CAAC;AAOhD,OAAO,EAAE,gCAAgC,EAAE,MAAM,yBAAyB,CAAC;AAE3E,mEAAmE;AACnE,MAAM,CAAC,KAAK,UAAU,iBAAiB,CACrC,SAAkD;IAElD,MAAM,QAAQ,GAAG,MAAM,MAAM,CAAC,qBAAqB,CAAC,CAAC;IACrD,yEAAyE;IACzE,MAAM,cAAc,GAAG,SAAS,CAAC,MAAM,IAAI,GAAG,CAAC,gBAAgB,CAAC;IAChE,OAAO,IAAI,QAAQ,CAAC,YAAY,CAAC;QAC/B,GAAG,SAAS;QACZ,MAAM,EAAE,cAAc;QACtB,KAAK,EAAE,SAAS,CAAC,KAAK,IAAI,
|
|
1
|
+
{"version":3,"file":"deepseek.js","sourceRoot":"","sources":["../../src/providers/deepseek.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,EAAE,GAAG,EAAE,MAAM,2BAA2B,CAAC;AAOhD,OAAO,EAAE,gCAAgC,EAAE,MAAM,yBAAyB,CAAC;AAE3E,mEAAmE;AACnE,MAAM,CAAC,KAAK,UAAU,iBAAiB,CACrC,SAAkD;IAElD,MAAM,QAAQ,GAAG,MAAM,MAAM,CAAC,qBAAqB,CAAC,CAAC;IACrD,yEAAyE;IACzE,MAAM,cAAc,GAAG,SAAS,CAAC,MAAM,IAAI,GAAG,CAAC,gBAAgB,CAAC;IAChE,OAAO,IAAI,QAAQ,CAAC,YAAY,CAAC;QAC/B,GAAG,SAAS;QACZ,MAAM,EAAE,cAAc;QACtB,KAAK,EAAE,SAAS,CAAC,KAAK,IAAI,iBAAiB;KAC5C,CAAC,CAAC;AACL,CAAC;AAED,MAAM,WAAW,GAAG;;;;;EAKlB,CAAC;AAEH,MAAM,UAAU,IAAI,CAAC,cAAsB;IACzC,yDAAyD;IACzD,IAAI,CAAC,cAAc,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC;QACtC,MAAM,IAAI,KAAK,CAAC,gCAAgC,CAAC,CAAC;IACpD,CAAC;IAED,gCAAgC,CAAC,cAAc,EAAE,WAAW,CAAC,CAAC;IAC9D,cAAc,CACZ,2BAA2B,cAAc,iCAAiC;QACxE,kDAAkD,CACrD,CAAC;AACJ,CAAC"}
|
|
@@ -9,7 +9,7 @@ export async function processJsonConfig(llmConfig) {
|
|
|
9
9
|
const configFields = {
|
|
10
10
|
...llmConfig,
|
|
11
11
|
apiKey: googleApiKey,
|
|
12
|
-
model: llmConfig.model || 'gemini-
|
|
12
|
+
model: llmConfig.model || 'gemini-3.5-flash',
|
|
13
13
|
platformType: 'gai',
|
|
14
14
|
};
|
|
15
15
|
delete configFields.type;
|
|
@@ -19,7 +19,7 @@ export async function processJsonConfig(llmConfig) {
|
|
|
19
19
|
const jsonContent = `{
|
|
20
20
|
"llm": {
|
|
21
21
|
"type": "google-genai",
|
|
22
|
-
"model": "gemini-
|
|
22
|
+
"model": "gemini-3.5-flash"
|
|
23
23
|
}
|
|
24
24
|
}`;
|
|
25
25
|
export function init(configFileName) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"google-genai.js","sourceRoot":"","sources":["../../src/providers/google-genai.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,EAAE,GAAG,EAAE,MAAM,2BAA2B,CAAC;AAIhD,OAAO,EAAE,gCAAgC,EAAE,MAAM,yBAAyB,CAAC;AAE3E,uEAAuE;AACvE,MAAM,CAAC,KAAK,UAAU,iBAAiB,CACrC,SAAmF;IAEnF,MAAM,EAAE,UAAU,EAAE,GAAG,MAAM,MAAM,CAAC,wBAAwB,CAAC,CAAC;IAC9D,wEAAwE;IACxE,MAAM,YAAY,GAAG,SAAS,CAAC,MAAM,IAAI,GAAG,CAAC,cAAc,CAAC;IAC5D,MAAM,YAAY,GAAG;QACnB,GAAG,SAAS;QACZ,MAAM,EAAE,YAAY;QACpB,KAAK,EAAE,SAAS,CAAC,KAAK,IAAI,
|
|
1
|
+
{"version":3,"file":"google-genai.js","sourceRoot":"","sources":["../../src/providers/google-genai.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,EAAE,GAAG,EAAE,MAAM,2BAA2B,CAAC;AAIhD,OAAO,EAAE,gCAAgC,EAAE,MAAM,yBAAyB,CAAC;AAE3E,uEAAuE;AACvE,MAAM,CAAC,KAAK,UAAU,iBAAiB,CACrC,SAAmF;IAEnF,MAAM,EAAE,UAAU,EAAE,GAAG,MAAM,MAAM,CAAC,wBAAwB,CAAC,CAAC;IAC9D,wEAAwE;IACxE,MAAM,YAAY,GAAG,SAAS,CAAC,MAAM,IAAI,GAAG,CAAC,cAAc,CAAC;IAC5D,MAAM,YAAY,GAAG;QACnB,GAAG,SAAS;QACZ,MAAM,EAAE,YAAY;QACpB,KAAK,EAAE,SAAS,CAAC,KAAK,IAAI,kBAAkB;QAC5C,YAAY,EAAE,KAAc;KAC7B,CAAC;IACF,OAAO,YAAY,CAAC,IAAI,CAAC;IACzB,OAAO,YAAY,CAAC,yBAAyB,CAAC;IAC9C,OAAO,IAAI,UAAU,CAAC,YAAY,CAAC,CAAC;AACtC,CAAC;AAED,MAAM,WAAW,GAAG;;;;;EAKlB,CAAC;AAEH,MAAM,UAAU,IAAI,CAAC,cAAsB;IACzC,yDAAyD;IACzD,IAAI,CAAC,cAAc,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC;QACtC,MAAM,IAAI,KAAK,CAAC,gCAAgC,CAAC,CAAC;IACpD,CAAC;IAED,gCAAgC,CAAC,cAAc,EAAE,WAAW,CAAC,CAAC;IAC9D,cAAc,CACZ,2BAA2B,cAAc,qCAAqC;QAC5E,gDAAgD,CACnD,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @packageDocumentation
|
|
3
|
+
* Provider / API-key detection and per-provider model listing.
|
|
4
|
+
*
|
|
5
|
+
* This is the data layer that powers the first-run configuration dialog (CFG-2),
|
|
6
|
+
* ACP model selection (CFG-5) and downstream propagation (CFG-6). It answers two
|
|
7
|
+
* questions without ever instantiating an LLM:
|
|
8
|
+
*
|
|
9
|
+
* 1. **Which providers are usable on this machine?** — by inspecting the
|
|
10
|
+
* environment (and config) for API keys, and by probing for a local Ollama.
|
|
11
|
+
* 2. **What models does each usable provider offer?** — a live `GET /v1/models`
|
|
12
|
+
* query for providers that expose an OpenAI-compatible (or, for Anthropic, a
|
|
13
|
+
* native) models endpoint, falling back to a curated ⭐ "preferred" / tested
|
|
14
|
+
* list when the live query is unavailable, errors, or is empty.
|
|
15
|
+
*
|
|
16
|
+
* Live discovery (CFG-12) is best-effort and never fatal: a bad key, an offline
|
|
17
|
+
* machine, or a malformed response simply degrades to the curated catalog so the
|
|
18
|
+
* first-run dialog always has something to show. The curated `preferredModels`
|
|
19
|
+
* therefore do double duty — the ⭐ ranking overlay over live ids **and** the
|
|
20
|
+
* offline/timeout fallback.
|
|
21
|
+
*
|
|
22
|
+
* The provider ids here are the same strings used by {@link LLMConfig.type} and
|
|
23
|
+
* the provider factory in `#src/providers/<type>.js`, so a selected
|
|
24
|
+
* `{ providerId, model }` maps directly onto a `RawGthConfig.llm`.
|
|
25
|
+
*/
|
|
26
|
+
import { type ConfigType } from '#src/config.js';
|
|
27
|
+
/**
|
|
28
|
+
* Provider identifiers understood by model discovery. These match the provider
|
|
29
|
+
* factory module names (`#src/providers/<id>.js`) and {@link LLMConfig.type},
|
|
30
|
+
* plus `ollama` for locally-served models.
|
|
31
|
+
*/
|
|
32
|
+
export type ProviderId = ConfigType | 'ollama';
|
|
33
|
+
/**
|
|
34
|
+
* A single model offered by a provider.
|
|
35
|
+
*/
|
|
36
|
+
export interface ModelInfo {
|
|
37
|
+
/** Model id as it should be written into config (`llm.model`). */
|
|
38
|
+
id: string;
|
|
39
|
+
/**
|
|
40
|
+
* Whether this is a ⭐ "preferred" / tested model. The first-run dialog
|
|
41
|
+
* should surface preferred models first / pre-selected.
|
|
42
|
+
*/
|
|
43
|
+
preferred: boolean;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* How a provider's live model catalog can be queried.
|
|
47
|
+
*
|
|
48
|
+
* - `openai` — an OpenAI-compatible `GET /v1/models` (`{ data: [{ id }] }`).
|
|
49
|
+
* Covers openai, openrouter, groq, deepseek, xai and ollama (local).
|
|
50
|
+
* - `anthropic` — Anthropic's native `GET /v1/models`
|
|
51
|
+
* (`{ data: [{ type, id, display_name }] }`) with `x-api-key` auth.
|
|
52
|
+
* - `none` — no cheap live endpoint; stay on the curated list
|
|
53
|
+
* (google-genai, vertexai).
|
|
54
|
+
*/
|
|
55
|
+
export type DiscoveryKind = 'openai' | 'anthropic' | 'none';
|
|
56
|
+
/**
|
|
57
|
+
* Per-provider live-discovery adapter. Bundled on the {@link ProviderDescriptor}
|
|
58
|
+
* so {@link discoverModels} can be fully data-driven.
|
|
59
|
+
*/
|
|
60
|
+
export interface DiscoveryConfig {
|
|
61
|
+
kind: DiscoveryKind;
|
|
62
|
+
/**
|
|
63
|
+
* The models endpoint to fetch. `host` is supplied only for ollama (the
|
|
64
|
+
* resolved daemon host); cloud providers ignore it and return a fixed URL.
|
|
65
|
+
*/
|
|
66
|
+
modelsUrl?: (host?: string) => string;
|
|
67
|
+
/** Build the auth headers from the resolved API key (may be empty for ollama). */
|
|
68
|
+
authHeader?: (key: string) => Record<string, string>;
|
|
69
|
+
/**
|
|
70
|
+
* Keep only chat-capable model ids. Live endpoints return embeddings, TTS,
|
|
71
|
+
* whisper, image, guard, etc. alongside chat models; this prunes them.
|
|
72
|
+
* When omitted, all returned ids are kept.
|
|
73
|
+
*/
|
|
74
|
+
filter?: (id: string) => boolean;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Static description of a provider: how to detect its key, how to discover its
|
|
78
|
+
* live models, and which models we recommend. Used to build
|
|
79
|
+
* {@link DetectedProvider}s.
|
|
80
|
+
*/
|
|
81
|
+
export interface ProviderDescriptor {
|
|
82
|
+
id: ProviderId;
|
|
83
|
+
/** Human-friendly name for dialogs. */
|
|
84
|
+
label: string;
|
|
85
|
+
/**
|
|
86
|
+
* Environment variables that, when set to a non-empty value, indicate this
|
|
87
|
+
* provider has a usable API key. Checked in order; the first match wins.
|
|
88
|
+
* Empty for providers that don't authenticate via an env var (`vertexai`,
|
|
89
|
+
* which uses gcloud ADC, and `ollama`, which is local).
|
|
90
|
+
*/
|
|
91
|
+
apiKeyEnvironmentVariables: string[];
|
|
92
|
+
/**
|
|
93
|
+
* Curated ⭐ "preferred" / tested models for this provider, most-recommended
|
|
94
|
+
* first. Used as the ⭐ ranking overlay over live-discovered ids and as the
|
|
95
|
+
* fallback catalog when live discovery is unavailable.
|
|
96
|
+
*/
|
|
97
|
+
preferredModels: string[];
|
|
98
|
+
/** Live-discovery adapter for this provider. */
|
|
99
|
+
discovery: DiscoveryConfig;
|
|
100
|
+
/**
|
|
101
|
+
* True when usability cannot be determined from an env var alone.
|
|
102
|
+
* `vertexai` relies on gcloud Application Default Credentials and `ollama`
|
|
103
|
+
* on a running local daemon, so both are reported as `available: false` by
|
|
104
|
+
* env inspection (ollama is then confirmed by a live probe in
|
|
105
|
+
* {@link detectProviders}).
|
|
106
|
+
*/
|
|
107
|
+
requiresExternalAuth?: boolean;
|
|
108
|
+
}
|
|
109
|
+
/** Default Ollama host, matching the Ollama CLI/library default. */
|
|
110
|
+
export declare const DEFAULT_OLLAMA_HOST = "http://127.0.0.1:11434";
|
|
111
|
+
/**
|
|
112
|
+
* Provider registry. The curated `preferredModels` are the models we have
|
|
113
|
+
* tested with Gaunt Sloth's agent loop; defaults mirror the `init` templates in
|
|
114
|
+
* each `#src/providers/<id>.js` factory.
|
|
115
|
+
*/
|
|
116
|
+
export declare const PROVIDER_DESCRIPTORS: readonly ProviderDescriptor[];
|
|
117
|
+
/**
|
|
118
|
+
* Result of detecting one provider.
|
|
119
|
+
*/
|
|
120
|
+
export interface DetectedProvider {
|
|
121
|
+
id: ProviderId;
|
|
122
|
+
label: string;
|
|
123
|
+
/**
|
|
124
|
+
* True when the provider looks usable on this machine: an API key env var is
|
|
125
|
+
* set, or (for ollama) a local daemon responded.
|
|
126
|
+
*/
|
|
127
|
+
available: boolean;
|
|
128
|
+
/**
|
|
129
|
+
* The environment variable that supplied the key, when {@link available} via
|
|
130
|
+
* an env var. Undefined for env-less providers (vertexai, ollama).
|
|
131
|
+
*/
|
|
132
|
+
apiKeyEnvironmentVariable?: string;
|
|
133
|
+
/** True when this provider authenticates outside of an env var. */
|
|
134
|
+
requiresExternalAuth: boolean;
|
|
135
|
+
/** Models offered by this provider, ⭐ preferred ones flagged. */
|
|
136
|
+
models: ModelInfo[];
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Resolve the API key for a cloud provider by checking its env vars in order.
|
|
140
|
+
* @returns the matching env var name, or undefined when none is set.
|
|
141
|
+
*/
|
|
142
|
+
export declare function findApiKeyEnvVar(descriptor: ProviderDescriptor): string | undefined;
|
|
143
|
+
/**
|
|
144
|
+
* Build the {@link ModelInfo} list for a provider given the descriptor and an
|
|
145
|
+
* optional set of model ids known to actually exist (e.g. from a live
|
|
146
|
+
* `/v1/models` query or the local Ollama daemon).
|
|
147
|
+
*
|
|
148
|
+
* - When `discoveredModels` is omitted, the curated `preferredModels` are
|
|
149
|
+
* returned, all flagged ⭐ preferred.
|
|
150
|
+
* - When provided, every discovered model is listed; those that also appear in
|
|
151
|
+
* the curated `preferredModels` are flagged ⭐ preferred.
|
|
152
|
+
*/
|
|
153
|
+
export declare function buildModelList(descriptor: ProviderDescriptor, discoveredModels?: string[]): ModelInfo[];
|
|
154
|
+
/**
|
|
155
|
+
* Discover the models for a single provider.
|
|
156
|
+
*
|
|
157
|
+
* - `kind: 'none'` → returns the curated `buildModelList(descriptor)`.
|
|
158
|
+
* - `kind: 'openai' | 'anthropic'` → fetches the models endpoint with a short
|
|
159
|
+
* timeout, parses `data[].id`, applies the chat-only `filter`, and overlays
|
|
160
|
+
* the ⭐ preferred flags via `buildModelList(descriptor, liveIds)`.
|
|
161
|
+
*
|
|
162
|
+
* Best-effort: any error / non-2xx / malformed / empty payload falls back to
|
|
163
|
+
* the curated list. This function NEVER throws — a bad key must degrade to the
|
|
164
|
+
* curated catalog, not break first-run config.
|
|
165
|
+
*
|
|
166
|
+
* Cloud providers are only probed live when an API key is present; without a key
|
|
167
|
+
* the curated catalog is returned directly. Ollama (no key, local daemon) is
|
|
168
|
+
* always probed.
|
|
169
|
+
*/
|
|
170
|
+
export declare function discoverModels(providerId: ProviderId): Promise<ModelInfo[]>;
|
|
171
|
+
/**
|
|
172
|
+
* List the models for a single provider.
|
|
173
|
+
*
|
|
174
|
+
* Live-discovers from the provider's models endpoint where possible (with a
|
|
175
|
+
* curated fallback); returns the curated set for `kind: 'none'` providers. Does
|
|
176
|
+
* not require the provider to be "available".
|
|
177
|
+
*/
|
|
178
|
+
export declare function listModels(providerId: ProviderId): Promise<ModelInfo[]>;
|
|
179
|
+
/**
|
|
180
|
+
* Detect every known provider on this machine and list its models.
|
|
181
|
+
*
|
|
182
|
+
* - Cloud providers are `available` when one of their API-key env vars is set;
|
|
183
|
+
* their model list is live-discovered (curated fallback) when a key is present.
|
|
184
|
+
* - `vertexai` is reported with `requiresExternalAuth: true` and
|
|
185
|
+
* `available: false`; usability via gcloud ADC cannot be cheaply verified
|
|
186
|
+
* here and is left to the caller / a live run.
|
|
187
|
+
* - `ollama` is `available` when the local daemon's `/v1/models` responds, and
|
|
188
|
+
* its model list is that live inventory.
|
|
189
|
+
*
|
|
190
|
+
* @param options.includeUnavailable when true (default), every provider is
|
|
191
|
+
* returned (so a dialog can offer "set a key" flows); when false, only
|
|
192
|
+
* available providers are returned.
|
|
193
|
+
*/
|
|
194
|
+
export declare function detectProviders(options?: {
|
|
195
|
+
includeUnavailable?: boolean;
|
|
196
|
+
}): Promise<DetectedProvider[]>;
|