@sashabogi/foundation 0.1.5 → 0.1.7
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/cli/setup-wizard.d.ts +30 -0
- package/dist/cli/setup-wizard.d.ts.map +1 -0
- package/dist/cli/setup-wizard.js +1645 -0
- package/dist/cli/setup-wizard.js.map +1 -0
- package/dist/cli/test-connection.d.ts +76 -0
- package/dist/cli/test-connection.d.ts.map +1 -0
- package/dist/cli/test-connection.js +697 -0
- package/dist/cli/test-connection.js.map +1 -0
- package/dist/cli.d.ts +3 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +133 -5
- package/dist/cli.js.map +1 -1
- package/dist/providers/anthropic.d.ts +178 -0
- package/dist/providers/anthropic.d.ts.map +1 -0
- package/dist/providers/anthropic.js +514 -0
- package/dist/providers/anthropic.js.map +1 -0
- package/dist/providers/base.d.ts +154 -0
- package/dist/providers/base.d.ts.map +1 -0
- package/dist/providers/base.js +227 -0
- package/dist/providers/base.js.map +1 -0
- package/dist/providers/deepseek.d.ts +23 -0
- package/dist/providers/deepseek.d.ts.map +1 -0
- package/dist/providers/deepseek.js +31 -0
- package/dist/providers/deepseek.js.map +1 -0
- package/dist/providers/fireworks.d.ts +23 -0
- package/dist/providers/fireworks.d.ts.map +1 -0
- package/dist/providers/fireworks.js +31 -0
- package/dist/providers/fireworks.js.map +1 -0
- package/dist/providers/gemini.d.ts +85 -0
- package/dist/providers/gemini.d.ts.map +1 -0
- package/dist/providers/gemini.js +414 -0
- package/dist/providers/gemini.js.map +1 -0
- package/dist/providers/groq.d.ts +23 -0
- package/dist/providers/groq.d.ts.map +1 -0
- package/dist/providers/groq.js +31 -0
- package/dist/providers/groq.js.map +1 -0
- package/dist/providers/index.d.ts +23 -0
- package/dist/providers/index.d.ts.map +1 -0
- package/dist/providers/index.js +27 -0
- package/dist/providers/index.js.map +1 -0
- package/dist/providers/kimi-code.d.ts +32 -0
- package/dist/providers/kimi-code.d.ts.map +1 -0
- package/dist/providers/kimi-code.js +46 -0
- package/dist/providers/kimi-code.js.map +1 -0
- package/dist/providers/kimi.d.ts +19 -0
- package/dist/providers/kimi.d.ts.map +1 -0
- package/dist/providers/kimi.js +27 -0
- package/dist/providers/kimi.js.map +1 -0
- package/dist/providers/manager.d.ts +144 -0
- package/dist/providers/manager.d.ts.map +1 -0
- package/dist/providers/manager.js +279 -0
- package/dist/providers/manager.js.map +1 -0
- package/dist/providers/ollama.d.ts +83 -0
- package/dist/providers/ollama.d.ts.map +1 -0
- package/dist/providers/ollama.js +450 -0
- package/dist/providers/ollama.js.map +1 -0
- package/dist/providers/openai.d.ts +91 -0
- package/dist/providers/openai.d.ts.map +1 -0
- package/dist/providers/openai.js +445 -0
- package/dist/providers/openai.js.map +1 -0
- package/dist/providers/openrouter.d.ts +23 -0
- package/dist/providers/openrouter.d.ts.map +1 -0
- package/dist/providers/openrouter.js +31 -0
- package/dist/providers/openrouter.js.map +1 -0
- package/dist/providers/perplexity.d.ts +34 -0
- package/dist/providers/perplexity.d.ts.map +1 -0
- package/dist/providers/perplexity.js +58 -0
- package/dist/providers/perplexity.js.map +1 -0
- package/dist/providers/together.d.ts +23 -0
- package/dist/providers/together.d.ts.map +1 -0
- package/dist/providers/together.js +31 -0
- package/dist/providers/together.js.map +1 -0
- package/dist/providers/types.d.ts +229 -0
- package/dist/providers/types.d.ts.map +1 -0
- package/dist/providers/types.js +73 -0
- package/dist/providers/types.js.map +1 -0
- package/dist/providers/zai.d.ts +19 -0
- package/dist/providers/zai.d.ts.map +1 -0
- package/dist/providers/zai.js +27 -0
- package/dist/providers/zai.js.map +1 -0
- package/dist/services/provider.service.d.ts +28 -0
- package/dist/services/provider.service.d.ts.map +1 -1
- package/dist/services/provider.service.js +137 -13
- package/dist/services/provider.service.js.map +1 -1
- package/dist/tools/demerzel/engine.d.ts +67 -0
- package/dist/tools/demerzel/engine.d.ts.map +1 -0
- package/dist/tools/demerzel/engine.js +401 -0
- package/dist/tools/demerzel/engine.js.map +1 -0
- package/dist/tools/demerzel/enhanced-snapshot.d.ts +67 -0
- package/dist/tools/demerzel/enhanced-snapshot.d.ts.map +1 -0
- package/dist/tools/demerzel/enhanced-snapshot.js +481 -0
- package/dist/tools/demerzel/enhanced-snapshot.js.map +1 -0
- package/dist/tools/demerzel/index.d.ts +11 -0
- package/dist/tools/demerzel/index.d.ts.map +1 -1
- package/dist/tools/demerzel/index.js +656 -85
- package/dist/tools/demerzel/index.js.map +1 -1
- package/dist/tools/demerzel/prompts.d.ts +26 -0
- package/dist/tools/demerzel/prompts.d.ts.map +1 -0
- package/dist/tools/demerzel/prompts.js +181 -0
- package/dist/tools/demerzel/prompts.js.map +1 -0
- package/dist/tools/demerzel/semantic-search.d.ts +54 -0
- package/dist/tools/demerzel/semantic-search.d.ts.map +1 -0
- package/dist/tools/demerzel/semantic-search.js +205 -0
- package/dist/tools/demerzel/semantic-search.js.map +1 -0
- package/dist/tools/demerzel/snapshot.d.ts +30 -0
- package/dist/tools/demerzel/snapshot.d.ts.map +1 -0
- package/dist/tools/demerzel/snapshot.js +169 -0
- package/dist/tools/demerzel/snapshot.js.map +1 -0
- package/package.json +2 -1
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Together AI Provider Implementation
|
|
3
|
+
*
|
|
4
|
+
* Together AI provides access to 200+ open models with sub-100ms latency.
|
|
5
|
+
* It uses an OpenAI-compatible API format.
|
|
6
|
+
* This provider extends OpenAIProvider with the correct name identifier.
|
|
7
|
+
*/
|
|
8
|
+
import { OpenAIProvider } from './openai.js';
|
|
9
|
+
// Default base URL for Together AI API
|
|
10
|
+
const TOGETHER_BASE_URL = 'https://api.together.xyz/v1';
|
|
11
|
+
/**
|
|
12
|
+
* Together AI API provider adapter.
|
|
13
|
+
*
|
|
14
|
+
* Uses OpenAI-compatible API format with Together AI endpoints.
|
|
15
|
+
* Provides access to 200+ open models with sub-100ms latency.
|
|
16
|
+
*
|
|
17
|
+
* Default base URL: https://api.together.xyz/v1
|
|
18
|
+
* Available models: meta-llama/Llama-3.3-70B-Instruct-Turbo, deepseek-ai/DeepSeek-V3, Qwen/Qwen2.5-72B-Instruct-Turbo
|
|
19
|
+
*/
|
|
20
|
+
export class TogetherProvider extends OpenAIProvider {
|
|
21
|
+
name = 'together';
|
|
22
|
+
constructor(config) {
|
|
23
|
+
// Ensure base_url defaults to Together AI endpoint if not specified
|
|
24
|
+
const configWithDefaults = {
|
|
25
|
+
...config,
|
|
26
|
+
base_url: config.base_url ?? TOGETHER_BASE_URL,
|
|
27
|
+
};
|
|
28
|
+
super(configWithDefaults);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=together.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"together.js","sourceRoot":"","sources":["../../src/providers/together.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAG7C,uCAAuC;AACvC,MAAM,iBAAiB,GAAG,6BAA6B,CAAC;AAExD;;;;;;;;GAQG;AACH,MAAM,OAAO,gBAAiB,SAAQ,cAAc;IACzB,IAAI,GAAG,UAAU,CAAC;IAE3C,YAAY,MAAsB;QAChC,oEAAoE;QACpE,MAAM,kBAAkB,GAAmB;YACzC,GAAG,MAAM;YACT,QAAQ,EAAE,MAAM,CAAC,QAAQ,IAAI,iBAAiB;SAC/C,CAAC;QACF,KAAK,CAAC,kBAAkB,CAAC,CAAC;IAC5B,CAAC;CACF"}
|
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Provider Type Definitions
|
|
3
|
+
*
|
|
4
|
+
* Core type definitions for the provider system.
|
|
5
|
+
* These types define the data structures for provider configuration,
|
|
6
|
+
* requests, responses, and streaming.
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Access mode for Anthropic provider.
|
|
10
|
+
* - 'api': Direct HTTP calls to Anthropic API
|
|
11
|
+
* - 'session': Returns delegation response for current Claude session (recommended for Claude Code)
|
|
12
|
+
* - 'auto': Auto-detect best method based on environment
|
|
13
|
+
*/
|
|
14
|
+
export type AccessMode = 'api' | 'session' | 'auto';
|
|
15
|
+
/**
|
|
16
|
+
* Provider-specific configuration.
|
|
17
|
+
* Contains credentials and settings for connecting to an LLM provider.
|
|
18
|
+
*/
|
|
19
|
+
export interface ProviderConfig {
|
|
20
|
+
/** Access mode: "api", "session", or "auto" */
|
|
21
|
+
access_mode?: AccessMode;
|
|
22
|
+
/** API key for authentication (supports ${ENV_VAR} interpolation) */
|
|
23
|
+
api_key?: string;
|
|
24
|
+
/** Base URL for the provider API (for self-hosted or proxy setups) */
|
|
25
|
+
base_url?: string;
|
|
26
|
+
/** Default model for this provider */
|
|
27
|
+
default_model?: string;
|
|
28
|
+
/** Organization ID (OpenAI) */
|
|
29
|
+
organization?: string;
|
|
30
|
+
/** Project ID (Google Cloud / Vertex AI) */
|
|
31
|
+
project?: string;
|
|
32
|
+
/** Region/location (Google Cloud / Vertex AI) */
|
|
33
|
+
location?: string;
|
|
34
|
+
/** Additional headers to include in API requests */
|
|
35
|
+
headers?: Record<string, string>;
|
|
36
|
+
/** System prompt for session delegation mode (injected by role resolver) */
|
|
37
|
+
system_prompt?: string;
|
|
38
|
+
/** Role name for session delegation mode (injected by role resolver) */
|
|
39
|
+
role_name?: string;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Chat message in the conversation.
|
|
43
|
+
* Used for building request messages to providers.
|
|
44
|
+
*/
|
|
45
|
+
export interface Message {
|
|
46
|
+
/** Message role: user or assistant */
|
|
47
|
+
role: 'user' | 'assistant';
|
|
48
|
+
/** Message content (string or content blocks) */
|
|
49
|
+
content: string | ContentBlock[];
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Content block within a message.
|
|
53
|
+
* Supports text, tool use requests, and tool results.
|
|
54
|
+
*/
|
|
55
|
+
export interface ContentBlock {
|
|
56
|
+
/** Type of content block */
|
|
57
|
+
type: 'text' | 'tool_use' | 'tool_result';
|
|
58
|
+
/** Text content (for type: "text") */
|
|
59
|
+
text?: string;
|
|
60
|
+
/** Tool use ID (for type: "tool_use") */
|
|
61
|
+
id?: string;
|
|
62
|
+
/** Tool name (for type: "tool_use") */
|
|
63
|
+
name?: string;
|
|
64
|
+
/** Tool input parameters (for type: "tool_use") */
|
|
65
|
+
input?: Record<string, unknown>;
|
|
66
|
+
/** Reference to tool_use ID (for type: "tool_result") */
|
|
67
|
+
tool_use_id?: string;
|
|
68
|
+
/** Tool result content (for type: "tool_result") */
|
|
69
|
+
content?: string;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Tool definition for agent tool use.
|
|
73
|
+
* Follows the Anthropic tool schema format.
|
|
74
|
+
*/
|
|
75
|
+
export interface Tool {
|
|
76
|
+
/** Tool name (must be unique within a request) */
|
|
77
|
+
name: string;
|
|
78
|
+
/** Human-readable description of what the tool does */
|
|
79
|
+
description: string;
|
|
80
|
+
/** JSON Schema for the tool's input parameters */
|
|
81
|
+
input_schema: {
|
|
82
|
+
type: 'object';
|
|
83
|
+
properties: Record<string, unknown>;
|
|
84
|
+
required?: string[];
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Request to complete a conversation.
|
|
89
|
+
* Sent to providers after translation.
|
|
90
|
+
*/
|
|
91
|
+
export interface CompletionRequest {
|
|
92
|
+
/** Model identifier */
|
|
93
|
+
model: string;
|
|
94
|
+
/** Conversation messages */
|
|
95
|
+
messages: Message[];
|
|
96
|
+
/** Temperature for response generation (0-2) */
|
|
97
|
+
temperature?: number;
|
|
98
|
+
/** Maximum tokens to generate */
|
|
99
|
+
max_tokens?: number;
|
|
100
|
+
/** Timeout in milliseconds for this request */
|
|
101
|
+
timeout_ms?: number;
|
|
102
|
+
/** Tools available for the model to use */
|
|
103
|
+
tools?: Tool[];
|
|
104
|
+
/** Whether to stream the response */
|
|
105
|
+
stream?: boolean;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Response from a completion request.
|
|
109
|
+
* Normalized format returned by all providers.
|
|
110
|
+
*/
|
|
111
|
+
export interface CompletionResponse {
|
|
112
|
+
/** Unique response ID from the provider */
|
|
113
|
+
id: string;
|
|
114
|
+
/** Response content blocks */
|
|
115
|
+
content: ContentBlock[];
|
|
116
|
+
/** Model that generated the response */
|
|
117
|
+
model: string;
|
|
118
|
+
/** Reason the generation stopped (e.g., "end_turn", "tool_use") */
|
|
119
|
+
stop_reason: string;
|
|
120
|
+
/** Token usage information */
|
|
121
|
+
usage?: UsageInfo;
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Token usage information for a request/response.
|
|
125
|
+
*/
|
|
126
|
+
export interface UsageInfo {
|
|
127
|
+
/** Number of tokens in the input/prompt */
|
|
128
|
+
input_tokens: number;
|
|
129
|
+
/** Number of tokens in the output/completion */
|
|
130
|
+
output_tokens: number;
|
|
131
|
+
/** Tokens used to create prompt cache (Anthropic) */
|
|
132
|
+
cache_creation_input_tokens?: number;
|
|
133
|
+
/** Tokens read from prompt cache (Anthropic) */
|
|
134
|
+
cache_read_input_tokens?: number;
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Response returned when using session delegation mode.
|
|
138
|
+
* Instead of making an API call, the MCP tool returns instructions
|
|
139
|
+
* for the current Claude session to handle the request directly.
|
|
140
|
+
*/
|
|
141
|
+
export interface SessionDelegationResponse {
|
|
142
|
+
/** Marker that this is a delegation, not a completion */
|
|
143
|
+
delegation: true;
|
|
144
|
+
/** The role being delegated (e.g., "orchestrator", "reviewer") */
|
|
145
|
+
role: string;
|
|
146
|
+
/** The system prompt for the role (from config) */
|
|
147
|
+
system_prompt: string;
|
|
148
|
+
/** The original task to execute */
|
|
149
|
+
task: string;
|
|
150
|
+
/** Optional context from the caller */
|
|
151
|
+
context?: string;
|
|
152
|
+
/** Human-readable instructions for the current session */
|
|
153
|
+
instructions: string;
|
|
154
|
+
/** The model that was requested (for reference) */
|
|
155
|
+
model?: string;
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Type guard to check if a response is a session delegation
|
|
159
|
+
*/
|
|
160
|
+
export declare function isSessionDelegation(response: unknown): response is SessionDelegationResponse;
|
|
161
|
+
/**
|
|
162
|
+
* Chunk of a streaming response.
|
|
163
|
+
*/
|
|
164
|
+
export interface StreamChunk {
|
|
165
|
+
/** Type of streaming event */
|
|
166
|
+
type: 'content_block_start' | 'content_block_delta' | 'message_stop';
|
|
167
|
+
/** Index of the content block (for multi-block responses) */
|
|
168
|
+
index?: number;
|
|
169
|
+
/** Content block being started (for content_block_start) */
|
|
170
|
+
content_block?: ContentBlock;
|
|
171
|
+
/** Delta update to content (for content_block_delta) */
|
|
172
|
+
delta?: {
|
|
173
|
+
type: string;
|
|
174
|
+
text?: string;
|
|
175
|
+
};
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* Provider interface that all provider adapters must implement.
|
|
179
|
+
*/
|
|
180
|
+
export interface Provider {
|
|
181
|
+
/** Provider name identifier */
|
|
182
|
+
name: string;
|
|
183
|
+
/** Execute a completion request and return the full response (or session delegation) */
|
|
184
|
+
complete(request: CompletionRequest): Promise<CompletionResponse | SessionDelegationResponse>;
|
|
185
|
+
/** Execute a streaming completion request */
|
|
186
|
+
completeStream(request: CompletionRequest): AsyncIterable<StreamChunk>;
|
|
187
|
+
/** Check if the provider is available and configured correctly */
|
|
188
|
+
healthCheck(): Promise<void>;
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* Supported LLM provider types.
|
|
192
|
+
*/
|
|
193
|
+
export type ProviderType = 'anthropic' | 'openai' | 'google' | 'deepseek' | 'zai' | 'kimi' | 'kimi-code' | 'ollama' | 'openrouter' | 'perplexity' | 'groq' | 'together' | 'fireworks';
|
|
194
|
+
/**
|
|
195
|
+
* Base error class for provider errors.
|
|
196
|
+
*/
|
|
197
|
+
export declare class ProviderError extends Error {
|
|
198
|
+
readonly provider: string;
|
|
199
|
+
readonly statusCode?: number | undefined;
|
|
200
|
+
readonly code: string;
|
|
201
|
+
constructor(message: string, provider: string, statusCode?: number | undefined, cause?: Error);
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* Error thrown when hitting rate limits.
|
|
205
|
+
*/
|
|
206
|
+
export declare class RateLimitError extends ProviderError {
|
|
207
|
+
readonly retryAfterMs?: number | undefined;
|
|
208
|
+
constructor(provider: string, retryAfterMs?: number | undefined, cause?: Error);
|
|
209
|
+
}
|
|
210
|
+
/**
|
|
211
|
+
* Error thrown when authentication fails.
|
|
212
|
+
*/
|
|
213
|
+
export declare class AuthenticationError extends ProviderError {
|
|
214
|
+
constructor(provider: string, cause?: Error);
|
|
215
|
+
}
|
|
216
|
+
/**
|
|
217
|
+
* Error thrown when a request times out.
|
|
218
|
+
*/
|
|
219
|
+
export declare class TimeoutError extends ProviderError {
|
|
220
|
+
constructor(provider: string, timeoutMs: number, cause?: Error);
|
|
221
|
+
}
|
|
222
|
+
/**
|
|
223
|
+
* Error thrown when configuration is invalid.
|
|
224
|
+
*/
|
|
225
|
+
export declare class ConfigurationError extends Error {
|
|
226
|
+
readonly code: string;
|
|
227
|
+
constructor(message: string, cause?: Error);
|
|
228
|
+
}
|
|
229
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/providers/types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAMH;;;;;GAKG;AACH,MAAM,MAAM,UAAU,GAAG,KAAK,GAAG,SAAS,GAAG,MAAM,CAAC;AAEpD;;;GAGG;AACH,MAAM,WAAW,cAAc;IAC7B,+CAA+C;IAC/C,WAAW,CAAC,EAAE,UAAU,CAAC;IACzB,qEAAqE;IACrE,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,sEAAsE;IACtE,QAAQ,CAAC,EAAE,MAAM,CAA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AAE,MAAM,CAAoB;gBAG9C,OAAO,EAAE,MAAM,EACC,QAAQ,EAAE,MAAM,EAChB,UAAU,CAAC,EAAE,MAAM,YAAA,EACnC,KAAK,CAAC,EAAE,KAAK;CAKhB;AAED;;GAEG;AACH,qBAAa,cAAe,SAAQ,aAAa;aAG7B,YAAY,CAAC,EAAE,MAAM;gBADrC,QAAQ,EAAE,MAAM,EACA,YAAY,CAAC,EAAE,MAAM,YAAA,EACrC,KAAK,CAAC,EAAE,KAAK;CAKhB;AAED;;GAEG;AACH,qBAAa,mBAAoB,SAAQ,aAAa;gBACxC,QAAQ,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,KAAK;CAI5C;AAED;;GAEG;AACH,qBAAa,YAAa,SAAQ,aAAa;gBACjC,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,KAAK;CAI/D;AAED;;GAEG;AACH,qBAAa,kBAAmB,SAAQ,KAAK;IAC3C,SAAgB,IAAI,EAAE,MAAM,CAAyB;gBAEzC,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,KAAK;CAI3C"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Provider Type Definitions
|
|
3
|
+
*
|
|
4
|
+
* Core type definitions for the provider system.
|
|
5
|
+
* These types define the data structures for provider configuration,
|
|
6
|
+
* requests, responses, and streaming.
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Type guard to check if a response is a session delegation
|
|
10
|
+
*/
|
|
11
|
+
export function isSessionDelegation(response) {
|
|
12
|
+
return (typeof response === 'object' &&
|
|
13
|
+
response !== null &&
|
|
14
|
+
'delegation' in response &&
|
|
15
|
+
response.delegation === true);
|
|
16
|
+
}
|
|
17
|
+
// ============================================================================
|
|
18
|
+
// Error Types
|
|
19
|
+
// ============================================================================
|
|
20
|
+
/**
|
|
21
|
+
* Base error class for provider errors.
|
|
22
|
+
*/
|
|
23
|
+
export class ProviderError extends Error {
|
|
24
|
+
provider;
|
|
25
|
+
statusCode;
|
|
26
|
+
code = 'PROVIDER_ERROR';
|
|
27
|
+
constructor(message, provider, statusCode, cause) {
|
|
28
|
+
super(message, { cause });
|
|
29
|
+
this.provider = provider;
|
|
30
|
+
this.statusCode = statusCode;
|
|
31
|
+
this.name = 'ProviderError';
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Error thrown when hitting rate limits.
|
|
36
|
+
*/
|
|
37
|
+
export class RateLimitError extends ProviderError {
|
|
38
|
+
retryAfterMs;
|
|
39
|
+
constructor(provider, retryAfterMs, cause) {
|
|
40
|
+
super(`Rate limit exceeded for provider: ${provider}`, provider, 429, cause);
|
|
41
|
+
this.retryAfterMs = retryAfterMs;
|
|
42
|
+
this.name = 'RateLimitError';
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Error thrown when authentication fails.
|
|
47
|
+
*/
|
|
48
|
+
export class AuthenticationError extends ProviderError {
|
|
49
|
+
constructor(provider, cause) {
|
|
50
|
+
super(`Authentication failed for provider: ${provider}`, provider, 401, cause);
|
|
51
|
+
this.name = 'AuthenticationError';
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Error thrown when a request times out.
|
|
56
|
+
*/
|
|
57
|
+
export class TimeoutError extends ProviderError {
|
|
58
|
+
constructor(provider, timeoutMs, cause) {
|
|
59
|
+
super(`Request to ${provider} timed out after ${timeoutMs}ms`, provider, undefined, cause);
|
|
60
|
+
this.name = 'TimeoutError';
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Error thrown when configuration is invalid.
|
|
65
|
+
*/
|
|
66
|
+
export class ConfigurationError extends Error {
|
|
67
|
+
code = 'CONFIGURATION_ERROR';
|
|
68
|
+
constructor(message, cause) {
|
|
69
|
+
super(message, { cause });
|
|
70
|
+
this.name = 'ConfigurationError';
|
|
71
|
+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,GAAG,qBAAqB,CAAC;IACpC,CAAC;CACF;AAED;;GAEG;AACH,MAAM,OAAO,YAAa,SAAQ,aAAa;IAC7C,YAAY,QAAgB,EAAE,SAAiB,EAAE,KAAa;QAC5D,KAAK,CAAC,cAAc,QAAQ,oBAAoB,SAAS,IAAI,EAAE,QAAQ,EAAE,SAAS,EAAE,KAAK,CAAC,CAAC;QAC3F,IAAI,CAAC,IAAI,GAAG,cAAc,CAAC;IAC7B,CAAC;CACF;AAED;;GAEG;AACH,MAAM,OAAO,kBAAmB,SAAQ,KAAK;IAC3B,IAAI,GAAW,qBAAqB,CAAC;IAErD,YAAY,OAAe,EAAE,KAAa;QACxC,KAAK,CAAC,OAAO,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC;QAC1B,IAAI,CAAC,IAAI,GAAG,oBAAoB,CAAC;IACnC,CAAC;CACF"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Z.AI Provider Implementation
|
|
3
|
+
*
|
|
4
|
+
* Z.AI (GLM models) uses an OpenAI-compatible API format.
|
|
5
|
+
* This provider extends OpenAIProvider with the correct name identifier.
|
|
6
|
+
*/
|
|
7
|
+
import { OpenAIProvider } from './openai.js';
|
|
8
|
+
import type { ProviderConfig } from './types.js';
|
|
9
|
+
/**
|
|
10
|
+
* Z.AI (GLM) API provider adapter.
|
|
11
|
+
*
|
|
12
|
+
* Uses OpenAI-compatible API format but with Z.AI endpoints.
|
|
13
|
+
* Default base URL: https://api.z.ai/api/paas/v4
|
|
14
|
+
*/
|
|
15
|
+
export declare class ZAIProvider extends OpenAIProvider {
|
|
16
|
+
readonly name = "zai";
|
|
17
|
+
constructor(config: ProviderConfig);
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=zai.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"zai.d.ts","sourceRoot":"","sources":["../../src/providers/zai.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAKjD;;;;;GAKG;AACH,qBAAa,WAAY,SAAQ,cAAc;IAC7C,SAAyB,IAAI,SAAS;gBAE1B,MAAM,EAAE,cAAc;CAQnC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Z.AI Provider Implementation
|
|
3
|
+
*
|
|
4
|
+
* Z.AI (GLM models) uses an OpenAI-compatible API format.
|
|
5
|
+
* This provider extends OpenAIProvider with the correct name identifier.
|
|
6
|
+
*/
|
|
7
|
+
import { OpenAIProvider } from './openai.js';
|
|
8
|
+
// Default base URL for Z.AI API
|
|
9
|
+
const ZAI_BASE_URL = 'https://api.z.ai/api/paas/v4';
|
|
10
|
+
/**
|
|
11
|
+
* Z.AI (GLM) API provider adapter.
|
|
12
|
+
*
|
|
13
|
+
* Uses OpenAI-compatible API format but with Z.AI endpoints.
|
|
14
|
+
* Default base URL: https://api.z.ai/api/paas/v4
|
|
15
|
+
*/
|
|
16
|
+
export class ZAIProvider extends OpenAIProvider {
|
|
17
|
+
name = 'zai';
|
|
18
|
+
constructor(config) {
|
|
19
|
+
// Ensure base_url defaults to Z.AI endpoint if not specified
|
|
20
|
+
const configWithDefaults = {
|
|
21
|
+
...config,
|
|
22
|
+
base_url: config.base_url ?? ZAI_BASE_URL,
|
|
23
|
+
};
|
|
24
|
+
super(configWithDefaults);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=zai.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"zai.js","sourceRoot":"","sources":["../../src/providers/zai.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAG7C,gCAAgC;AAChC,MAAM,YAAY,GAAG,8BAA8B,CAAC;AAEpD;;;;;GAKG;AACH,MAAM,OAAO,WAAY,SAAQ,cAAc;IACpB,IAAI,GAAG,KAAK,CAAC;IAEtC,YAAY,MAAsB;QAChC,6DAA6D;QAC7D,MAAM,kBAAkB,GAAmB;YACzC,GAAG,MAAM;YACT,QAAQ,EAAE,MAAM,CAAC,QAAQ,IAAI,YAAY;SAC1C,CAAC;QACF,KAAK,CAAC,kBAAkB,CAAC,CAAC;IAC5B,CAAC;CACF"}
|
|
@@ -23,6 +23,7 @@
|
|
|
23
23
|
* - Session delegation for Anthropic
|
|
24
24
|
*/
|
|
25
25
|
import type { FoundationConfig, ProviderName, AgentRole, ProviderHealth, ProviderInvokeResult } from '../types/index.js';
|
|
26
|
+
import { ProviderManager } from '../providers/index.js';
|
|
26
27
|
export interface InvokeOptions {
|
|
27
28
|
role: AgentRole;
|
|
28
29
|
task: string;
|
|
@@ -35,6 +36,7 @@ export declare class ProviderService {
|
|
|
35
36
|
private static instance;
|
|
36
37
|
private config;
|
|
37
38
|
private storage;
|
|
39
|
+
private providerManager;
|
|
38
40
|
private initialized;
|
|
39
41
|
private constructor();
|
|
40
42
|
static getInstance(): ProviderService;
|
|
@@ -42,6 +44,10 @@ export declare class ProviderService {
|
|
|
42
44
|
* Initialize with configuration
|
|
43
45
|
*/
|
|
44
46
|
init(config: FoundationConfig): Promise<void>;
|
|
47
|
+
/**
|
|
48
|
+
* Configure providers from Foundation config
|
|
49
|
+
*/
|
|
50
|
+
private configureProviders;
|
|
45
51
|
/**
|
|
46
52
|
* Invoke an agent role with a task
|
|
47
53
|
*/
|
|
@@ -54,6 +60,15 @@ export declare class ProviderService {
|
|
|
54
60
|
* Invoke a specific provider
|
|
55
61
|
*/
|
|
56
62
|
private invokeProvider;
|
|
63
|
+
/**
|
|
64
|
+
* Build the prompt from invoke options
|
|
65
|
+
*/
|
|
66
|
+
private buildPrompt;
|
|
67
|
+
/**
|
|
68
|
+
* Handle session delegation response
|
|
69
|
+
* Returns formatted instructions for the current Claude session
|
|
70
|
+
*/
|
|
71
|
+
private handleSessionDelegation;
|
|
57
72
|
/**
|
|
58
73
|
* List available providers
|
|
59
74
|
*/
|
|
@@ -70,5 +85,18 @@ export declare class ProviderService {
|
|
|
70
85
|
latencyMs: number;
|
|
71
86
|
error?: string;
|
|
72
87
|
}>;
|
|
88
|
+
/**
|
|
89
|
+
* Test all configured providers
|
|
90
|
+
*/
|
|
91
|
+
testAllProviders(): Promise<Map<string, {
|
|
92
|
+
success: boolean;
|
|
93
|
+
latencyMs: number;
|
|
94
|
+
error?: string;
|
|
95
|
+
}>>;
|
|
96
|
+
/**
|
|
97
|
+
* Get the underlying provider manager
|
|
98
|
+
* Useful for advanced use cases
|
|
99
|
+
*/
|
|
100
|
+
getProviderManager(): ProviderManager;
|
|
73
101
|
}
|
|
74
102
|
//# sourceMappingURL=provider.service.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"provider.service.d.ts","sourceRoot":"","sources":["../../src/services/provider.service.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,KAAK,EACV,gBAAgB,EAChB,YAAY,EACZ,SAAS,EACT,cAAc,EACd,oBAAoB,EAErB,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"provider.service.d.ts","sourceRoot":"","sources":["../../src/services/provider.service.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,KAAK,EACV,gBAAgB,EAChB,YAAY,EACZ,SAAS,EACT,cAAc,EACd,oBAAoB,EAErB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EACL,eAAe,EAOhB,MAAM,uBAAuB,CAAC;AAE/B,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,SAAS,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,WAAW,CAAC,EAAE,MAAM,CAAC;I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