agent-bober 0.6.2 → 0.8.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/README.md +220 -30
- package/dist/cli/commands/eval.d.ts +2 -0
- package/dist/cli/commands/eval.d.ts.map +1 -1
- package/dist/cli/commands/eval.js +10 -0
- package/dist/cli/commands/eval.js.map +1 -1
- package/dist/cli/commands/init.d.ts.map +1 -1
- package/dist/cli/commands/init.js +357 -62
- package/dist/cli/commands/init.js.map +1 -1
- package/dist/cli/commands/plan.d.ts +2 -0
- package/dist/cli/commands/plan.d.ts.map +1 -1
- package/dist/cli/commands/plan.js +10 -0
- package/dist/cli/commands/plan.js.map +1 -1
- package/dist/cli/commands/run.d.ts +2 -0
- package/dist/cli/commands/run.d.ts.map +1 -1
- package/dist/cli/commands/run.js +10 -0
- package/dist/cli/commands/run.js.map +1 -1
- package/dist/cli/commands/sprint.d.ts +2 -0
- package/dist/cli/commands/sprint.d.ts.map +1 -1
- package/dist/cli/commands/sprint.js +10 -0
- package/dist/cli/commands/sprint.js.map +1 -1
- package/dist/cli/index.js +22 -2
- package/dist/cli/index.js.map +1 -1
- package/dist/config/schema.d.ts +160 -43
- package/dist/config/schema.d.ts.map +1 -1
- package/dist/config/schema.js +11 -7
- package/dist/config/schema.js.map +1 -1
- package/dist/contracts/sprint-contract.d.ts +8 -8
- package/dist/discovery/config-generator.d.ts +28 -0
- package/dist/discovery/config-generator.d.ts.map +1 -0
- package/dist/discovery/config-generator.js +225 -0
- package/dist/discovery/config-generator.js.map +1 -0
- package/dist/discovery/index.d.ts +20 -0
- package/dist/discovery/index.d.ts.map +1 -0
- package/dist/discovery/index.js +19 -0
- package/dist/discovery/index.js.map +1 -0
- package/dist/discovery/scanner.d.ts +17 -0
- package/dist/discovery/scanner.d.ts.map +1 -0
- package/dist/discovery/scanner.js +120 -0
- package/dist/discovery/scanner.js.map +1 -0
- package/dist/discovery/scanners/ci-checks.d.ts +10 -0
- package/dist/discovery/scanners/ci-checks.d.ts.map +1 -0
- package/dist/discovery/scanners/ci-checks.js +169 -0
- package/dist/discovery/scanners/ci-checks.js.map +1 -0
- package/dist/discovery/scanners/code-conventions.d.ts +12 -0
- package/dist/discovery/scanners/code-conventions.d.ts.map +1 -0
- package/dist/discovery/scanners/code-conventions.js +216 -0
- package/dist/discovery/scanners/code-conventions.js.map +1 -0
- package/dist/discovery/scanners/documentation.d.ts +17 -0
- package/dist/discovery/scanners/documentation.d.ts.map +1 -0
- package/dist/discovery/scanners/documentation.js +92 -0
- package/dist/discovery/scanners/documentation.js.map +1 -0
- package/dist/discovery/scanners/git-conventions.d.ts +11 -0
- package/dist/discovery/scanners/git-conventions.d.ts.map +1 -0
- package/dist/discovery/scanners/git-conventions.js +128 -0
- package/dist/discovery/scanners/git-conventions.js.map +1 -0
- package/dist/discovery/scanners/package-scripts.d.ts +9 -0
- package/dist/discovery/scanners/package-scripts.d.ts.map +1 -0
- package/dist/discovery/scanners/package-scripts.js +112 -0
- package/dist/discovery/scanners/package-scripts.js.map +1 -0
- package/dist/discovery/scanners/test-conventions.d.ts +9 -0
- package/dist/discovery/scanners/test-conventions.d.ts.map +1 -0
- package/dist/discovery/scanners/test-conventions.js +231 -0
- package/dist/discovery/scanners/test-conventions.js.map +1 -0
- package/dist/discovery/synthesizer.d.ts +30 -0
- package/dist/discovery/synthesizer.d.ts.map +1 -0
- package/dist/discovery/synthesizer.js +348 -0
- package/dist/discovery/synthesizer.js.map +1 -0
- package/dist/discovery/types.d.ts +160 -0
- package/dist/discovery/types.d.ts.map +1 -0
- package/dist/discovery/types.js +9 -0
- package/dist/discovery/types.js.map +1 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +12 -0
- package/dist/index.js.map +1 -1
- package/dist/mcp/index.d.ts +4 -0
- package/dist/mcp/index.d.ts.map +1 -0
- package/dist/mcp/index.js +4 -0
- package/dist/mcp/index.js.map +1 -0
- package/dist/mcp/run-manager.d.ts +47 -0
- package/dist/mcp/run-manager.d.ts.map +1 -0
- package/dist/mcp/run-manager.js +79 -0
- package/dist/mcp/run-manager.js.map +1 -0
- package/dist/mcp/server.d.ts +15 -0
- package/dist/mcp/server.d.ts.map +1 -0
- package/dist/mcp/server.js +107 -0
- package/dist/mcp/server.js.map +1 -0
- package/dist/mcp/tools/config.d.ts +2 -0
- package/dist/mcp/tools/config.d.ts.map +1 -0
- package/dist/mcp/tools/config.js +153 -0
- package/dist/mcp/tools/config.js.map +1 -0
- package/dist/mcp/tools/contracts.d.ts +2 -0
- package/dist/mcp/tools/contracts.d.ts.map +1 -0
- package/dist/mcp/tools/contracts.js +61 -0
- package/dist/mcp/tools/contracts.js.map +1 -0
- package/dist/mcp/tools/eval.d.ts +2 -0
- package/dist/mcp/tools/eval.d.ts.map +1 -0
- package/dist/mcp/tools/eval.js +157 -0
- package/dist/mcp/tools/eval.js.map +1 -0
- package/dist/mcp/tools/index.d.ts +20 -0
- package/dist/mcp/tools/index.d.ts.map +1 -0
- package/dist/mcp/tools/index.js +47 -0
- package/dist/mcp/tools/index.js.map +1 -0
- package/dist/mcp/tools/init.d.ts +2 -0
- package/dist/mcp/tools/init.d.ts.map +1 -0
- package/dist/mcp/tools/init.js +222 -0
- package/dist/mcp/tools/init.js.map +1 -0
- package/dist/mcp/tools/plan.d.ts +2 -0
- package/dist/mcp/tools/plan.d.ts.map +1 -0
- package/dist/mcp/tools/plan.js +97 -0
- package/dist/mcp/tools/plan.js.map +1 -0
- package/dist/mcp/tools/principles.d.ts +2 -0
- package/dist/mcp/tools/principles.d.ts.map +1 -0
- package/dist/mcp/tools/principles.js +66 -0
- package/dist/mcp/tools/principles.js.map +1 -0
- package/dist/mcp/tools/registry.d.ts +45 -0
- package/dist/mcp/tools/registry.d.ts.map +1 -0
- package/dist/mcp/tools/registry.js +23 -0
- package/dist/mcp/tools/registry.js.map +1 -0
- package/dist/mcp/tools/run.d.ts +2 -0
- package/dist/mcp/tools/run.d.ts.map +1 -0
- package/dist/mcp/tools/run.js +66 -0
- package/dist/mcp/tools/run.js.map +1 -0
- package/dist/mcp/tools/spec.d.ts +2 -0
- package/dist/mcp/tools/spec.d.ts.map +1 -0
- package/dist/mcp/tools/spec.js +32 -0
- package/dist/mcp/tools/spec.js.map +1 -0
- package/dist/mcp/tools/sprint.d.ts +2 -0
- package/dist/mcp/tools/sprint.d.ts.map +1 -0
- package/dist/mcp/tools/sprint.js +243 -0
- package/dist/mcp/tools/sprint.js.map +1 -0
- package/dist/mcp/tools/status.d.ts +2 -0
- package/dist/mcp/tools/status.d.ts.map +1 -0
- package/dist/mcp/tools/status.js +76 -0
- package/dist/mcp/tools/status.js.map +1 -0
- package/dist/orchestrator/agentic-loop.d.ts +7 -6
- package/dist/orchestrator/agentic-loop.d.ts.map +1 -1
- package/dist/orchestrator/agentic-loop.js +33 -40
- package/dist/orchestrator/agentic-loop.js.map +1 -1
- package/dist/orchestrator/context-handoff.d.ts +20 -20
- package/dist/orchestrator/evaluator-agent.d.ts.map +1 -1
- package/dist/orchestrator/evaluator-agent.js +2 -2
- package/dist/orchestrator/evaluator-agent.js.map +1 -1
- package/dist/orchestrator/generator-agent.d.ts.map +1 -1
- package/dist/orchestrator/generator-agent.js +2 -2
- package/dist/orchestrator/generator-agent.js.map +1 -1
- package/dist/orchestrator/model-resolver.d.ts +35 -4
- package/dist/orchestrator/model-resolver.d.ts.map +1 -1
- package/dist/orchestrator/model-resolver.js +68 -15
- package/dist/orchestrator/model-resolver.js.map +1 -1
- package/dist/orchestrator/planner-agent.d.ts.map +1 -1
- package/dist/orchestrator/planner-agent.js +2 -2
- package/dist/orchestrator/planner-agent.js.map +1 -1
- package/dist/orchestrator/tools/index.d.ts +3 -4
- package/dist/orchestrator/tools/index.d.ts.map +1 -1
- package/dist/orchestrator/tools/index.js.map +1 -1
- package/dist/orchestrator/tools/schemas.d.ts +11 -12
- package/dist/orchestrator/tools/schemas.d.ts.map +1 -1
- package/dist/orchestrator/tools/schemas.js +3 -2
- package/dist/orchestrator/tools/schemas.js.map +1 -1
- package/dist/providers/anthropic.d.ts +15 -0
- package/dist/providers/anthropic.d.ts.map +1 -0
- package/dist/providers/anthropic.js +133 -0
- package/dist/providers/anthropic.js.map +1 -0
- package/dist/providers/factory.d.ts +37 -0
- package/dist/providers/factory.d.ts.map +1 -0
- package/dist/providers/factory.js +119 -0
- package/dist/providers/factory.js.map +1 -0
- package/dist/providers/google.d.ts +39 -0
- package/dist/providers/google.d.ts.map +1 -0
- package/dist/providers/google.js +195 -0
- package/dist/providers/google.js.map +1 -0
- package/dist/providers/index.d.ts +7 -0
- package/dist/providers/index.d.ts.map +1 -0
- package/dist/providers/index.js +6 -0
- package/dist/providers/index.js.map +1 -0
- package/dist/providers/openai-compat.d.ts +39 -0
- package/dist/providers/openai-compat.d.ts.map +1 -0
- package/dist/providers/openai-compat.js +42 -0
- package/dist/providers/openai-compat.js.map +1 -0
- package/dist/providers/openai.d.ts +41 -0
- package/dist/providers/openai.d.ts.map +1 -0
- package/dist/providers/openai.js +205 -0
- package/dist/providers/openai.js.map +1 -0
- package/dist/providers/types.d.ts +144 -0
- package/dist/providers/types.d.ts.map +1 -0
- package/dist/providers/types.js +8 -0
- package/dist/providers/types.js.map +1 -0
- package/package.json +22 -4
- package/skills/bober.principles/SKILL.md +36 -3
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import Anthropic from "@anthropic-ai/sdk";
|
|
2
|
+
// ── Conversion helpers ──────────────────────────────────────────────
|
|
3
|
+
/**
|
|
4
|
+
* Convert a provider-agnostic ToolDef to Anthropic's Tool format.
|
|
5
|
+
*
|
|
6
|
+
* ToolDef.input_schema maps directly to Anthropic's input_schema field,
|
|
7
|
+
* so this is a straightforward cast with a rename of the top-level key.
|
|
8
|
+
*/
|
|
9
|
+
function toAnthropicTool(tool) {
|
|
10
|
+
return {
|
|
11
|
+
name: tool.name,
|
|
12
|
+
description: tool.description,
|
|
13
|
+
input_schema: tool.input_schema,
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Normalize Anthropic's stop_reason to our StopReason type.
|
|
18
|
+
*/
|
|
19
|
+
function normalizeStopReason(reason) {
|
|
20
|
+
switch (reason) {
|
|
21
|
+
case "end_turn":
|
|
22
|
+
return "end";
|
|
23
|
+
case "tool_use":
|
|
24
|
+
return "tool_use";
|
|
25
|
+
case "max_tokens":
|
|
26
|
+
return "max_tokens";
|
|
27
|
+
default:
|
|
28
|
+
return reason ?? "end";
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Extract normalized text and tool calls from Anthropic content blocks.
|
|
33
|
+
*/
|
|
34
|
+
function normalizeContent(content) {
|
|
35
|
+
let text = "";
|
|
36
|
+
const toolCalls = [];
|
|
37
|
+
for (const block of content) {
|
|
38
|
+
if (block.type === "text") {
|
|
39
|
+
text += block.text;
|
|
40
|
+
}
|
|
41
|
+
else if (block.type === "tool_use") {
|
|
42
|
+
toolCalls.push({
|
|
43
|
+
id: block.id,
|
|
44
|
+
name: block.name,
|
|
45
|
+
input: block.input,
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
return { text, toolCalls };
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Convert a provider-agnostic Message to an Anthropic MessageParam.
|
|
53
|
+
*
|
|
54
|
+
* Handles three message variants:
|
|
55
|
+
* - TextMessage: plain string content for user or assistant
|
|
56
|
+
* - AssistantMessage: assistant turn with optional text + tool_use blocks
|
|
57
|
+
* - ToolResultMessage: user turn carrying tool_result blocks
|
|
58
|
+
*/
|
|
59
|
+
function toAnthropicMessage(message) {
|
|
60
|
+
// ToolResultMessage: user turn with tool results
|
|
61
|
+
if ("toolResults" in message) {
|
|
62
|
+
const content = message.toolResults.map((tr) => ({
|
|
63
|
+
type: "tool_result",
|
|
64
|
+
tool_use_id: tr.toolUseId,
|
|
65
|
+
content: tr.content,
|
|
66
|
+
is_error: tr.isError ?? false,
|
|
67
|
+
}));
|
|
68
|
+
return { role: "user", content };
|
|
69
|
+
}
|
|
70
|
+
// AssistantMessage: assistant turn with tool calls (and optional text)
|
|
71
|
+
if ("toolCalls" in message && message.toolCalls.length > 0) {
|
|
72
|
+
const content = [];
|
|
73
|
+
// Include text block if there is text content
|
|
74
|
+
if (message.content) {
|
|
75
|
+
content.push({ type: "text", text: message.content });
|
|
76
|
+
}
|
|
77
|
+
// Append tool_use blocks
|
|
78
|
+
for (const tc of message.toolCalls) {
|
|
79
|
+
content.push({
|
|
80
|
+
type: "tool_use",
|
|
81
|
+
id: tc.id,
|
|
82
|
+
name: tc.name,
|
|
83
|
+
input: tc.input,
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
return { role: "assistant", content };
|
|
87
|
+
}
|
|
88
|
+
// TextMessage: plain string content
|
|
89
|
+
return {
|
|
90
|
+
role: message.role,
|
|
91
|
+
content: message.content,
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
// ── AnthropicAdapter ────────────────────────────────────────────────
|
|
95
|
+
/**
|
|
96
|
+
* LLMClient implementation that wraps the Anthropic SDK.
|
|
97
|
+
*
|
|
98
|
+
* Converts ToolDef[] to Anthropic.Messages.Tool[] before each request,
|
|
99
|
+
* converts provider-agnostic Message[] (including tool call/result variants)
|
|
100
|
+
* to Anthropic MessageParam[], and normalizes Anthropic responses to
|
|
101
|
+
* ChatResponse after each call.
|
|
102
|
+
*/
|
|
103
|
+
export class AnthropicAdapter {
|
|
104
|
+
client;
|
|
105
|
+
constructor(apiKey) {
|
|
106
|
+
this.client = new Anthropic({ apiKey });
|
|
107
|
+
}
|
|
108
|
+
async chat(params) {
|
|
109
|
+
const { model, system, messages, tools, maxTokens = 16384 } = params;
|
|
110
|
+
// Convert provider-agnostic Message[] to Anthropic MessageParam[]
|
|
111
|
+
const anthropicMessages = messages.map(toAnthropicMessage);
|
|
112
|
+
// Convert ToolDef[] to Anthropic.Messages.Tool[]
|
|
113
|
+
const anthropicTools = tools && tools.length > 0 ? tools.map(toAnthropicTool) : undefined;
|
|
114
|
+
const response = await this.client.messages.create({
|
|
115
|
+
model,
|
|
116
|
+
max_tokens: maxTokens,
|
|
117
|
+
system,
|
|
118
|
+
messages: anthropicMessages,
|
|
119
|
+
tools: anthropicTools,
|
|
120
|
+
});
|
|
121
|
+
const { text, toolCalls } = normalizeContent(response.content);
|
|
122
|
+
return {
|
|
123
|
+
text,
|
|
124
|
+
toolCalls,
|
|
125
|
+
stopReason: normalizeStopReason(response.stop_reason),
|
|
126
|
+
usage: {
|
|
127
|
+
inputTokens: response.usage.input_tokens,
|
|
128
|
+
outputTokens: response.usage.output_tokens,
|
|
129
|
+
},
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
//# sourceMappingURL=anthropic.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"anthropic.js","sourceRoot":"","sources":["../../src/providers/anthropic.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,mBAAmB,CAAC;AAY1C,uEAAuE;AAEvE;;;;;GAKG;AACH,SAAS,eAAe,CAAC,IAAa;IACpC,OAAO;QACL,IAAI,EAAE,IAAI,CAAC,IAAI;QACf,WAAW,EAAE,IAAI,CAAC,WAAW;QAC7B,YAAY,EAAE,IAAI,CAAC,YAAuD;KAC3E,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,SAAS,mBAAmB,CAC1B,MAAiD;IAEjD,QAAQ,MAAM,EAAE,CAAC;QACf,KAAK,UAAU;YACb,OAAO,KAAK,CAAC;QACf,KAAK,UAAU;YACb,OAAO,UAAU,CAAC;QACpB,KAAK,YAAY;YACf,OAAO,YAAY,CAAC;QACtB;YACE,OAAO,MAAM,IAAI,KAAK,CAAC;IAC3B,CAAC;AACH,CAAC;AAED;;GAEG;AACH,SAAS,gBAAgB,CACvB,OAA0C;IAE1C,IAAI,IAAI,GAAG,EAAE,CAAC;IACd,MAAM,SAAS,GAAe,EAAE,C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CAAC,CAAC;QAEH,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,GAAG,gBAAgB,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;QAE/D,OAAO;YACL,IAAI;YACJ,SAAS;YACT,UAAU,EAAE,mBAAmB,CAAC,QAAQ,CAAC,WAAW,CAAC;YACrD,KAAK,EAAE;gBACL,WAAW,EAAE,QAAQ,CAAC,KAAK,CAAC,YAAY;gBACxC,YAAY,EAAE,QAAQ,CAAC,KAAK,CAAC,aAAa;aAC3C;SACF,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { LLMClient } from "./types.js";
|
|
2
|
+
/**
|
|
3
|
+
* The set of provider names currently supported.
|
|
4
|
+
*/
|
|
5
|
+
export type ProviderName = "anthropic" | "openai" | "google" | "openai-compat";
|
|
6
|
+
/**
|
|
7
|
+
* Validate that the required API key environment variable is set for a given provider.
|
|
8
|
+
*
|
|
9
|
+
* @param resolvedProvider - The resolved provider name.
|
|
10
|
+
* @param role - Optional role label (e.g. "Planner", "Generator", "Evaluator") for the error message.
|
|
11
|
+
* @param apiKey - Optional explicit API key from providerConfig (skips env var check if set).
|
|
12
|
+
* @throws If the required environment variable is missing and no explicit apiKey was provided.
|
|
13
|
+
*/
|
|
14
|
+
export declare function validateApiKey(resolvedProvider: string, role?: string, apiKey?: string): void;
|
|
15
|
+
/**
|
|
16
|
+
* Create an LLMClient for the given provider.
|
|
17
|
+
*
|
|
18
|
+
* Provider resolution order:
|
|
19
|
+
* 1. If `provider` is explicitly set, use it directly with `model` as-is.
|
|
20
|
+
* 2. If `model` is set but `provider` is not, infer the provider from the
|
|
21
|
+
* model shorthand using resolveProviderModel().
|
|
22
|
+
* 3. If neither is set, default to "anthropic".
|
|
23
|
+
*
|
|
24
|
+
* API key validation is performed before constructing any adapter. Pass a
|
|
25
|
+
* `role` string (e.g. "Planner") so error messages identify which role is
|
|
26
|
+
* misconfigured.
|
|
27
|
+
*
|
|
28
|
+
* @param provider - Optional provider name. When omitted, inferred from model.
|
|
29
|
+
* @param endpoint - Optional base URL override (used by OpenAI-compat adapters).
|
|
30
|
+
* @param providerConfig - Optional provider-specific configuration (e.g., apiKey).
|
|
31
|
+
* @param model - Optional model string used for provider inference when provider is not set.
|
|
32
|
+
* @param role - Optional role label used in API key error messages.
|
|
33
|
+
* @returns An LLMClient instance for the resolved provider.
|
|
34
|
+
* @throws If the resolved provider is unsupported or the required API key is missing.
|
|
35
|
+
*/
|
|
36
|
+
export declare function createClient(provider?: string | null, endpoint?: string | null, providerConfig?: Record<string, unknown>, model?: string, role?: string): LLMClient;
|
|
37
|
+
//# sourceMappingURL=factory.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../../src/providers/factory.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAG5C;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG,WAAW,GAAG,QAAQ,GAAG,QAAQ,GAAG,eAAe,CAAC;AAE/E;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAC5B,gBAAgB,EAAE,MAAM,EACxB,IAAI,CAAC,EAAE,MAAM,EACb,MAAM,CAAC,EAAE,MAAM,GACd,IAAI,CA4CN;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,YAAY,CAC1B,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,EACxB,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,EACxB,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACxC,KAAK,CAAC,EAAE,MAAM,EACd,IAAI,CAAC,EAAE,MAAM,GACZ,SAAS,CAmEX"}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { AnthropicAdapter } from "./anthropic.js";
|
|
2
|
+
import { OpenAIAdapter } from "./openai.js";
|
|
3
|
+
import { GoogleAdapter } from "./google.js";
|
|
4
|
+
import { OpenAICompatAdapter } from "./openai-compat.js";
|
|
5
|
+
import { resolveProviderModel } from "../orchestrator/model-resolver.js";
|
|
6
|
+
/**
|
|
7
|
+
* Validate that the required API key environment variable is set for a given provider.
|
|
8
|
+
*
|
|
9
|
+
* @param resolvedProvider - The resolved provider name.
|
|
10
|
+
* @param role - Optional role label (e.g. "Planner", "Generator", "Evaluator") for the error message.
|
|
11
|
+
* @param apiKey - Optional explicit API key from providerConfig (skips env var check if set).
|
|
12
|
+
* @throws If the required environment variable is missing and no explicit apiKey was provided.
|
|
13
|
+
*/
|
|
14
|
+
export function validateApiKey(resolvedProvider, role, apiKey) {
|
|
15
|
+
const roleLabel = role ?? resolvedProvider;
|
|
16
|
+
switch (resolvedProvider) {
|
|
17
|
+
case "anthropic": {
|
|
18
|
+
const key = apiKey ?? process.env["ANTHROPIC_API_KEY"];
|
|
19
|
+
if (!key) {
|
|
20
|
+
throw new Error(`${roleLabel} is configured to use Anthropic but ANTHROPIC_API_KEY is not set. ` +
|
|
21
|
+
`Set the ANTHROPIC_API_KEY environment variable and try again.`);
|
|
22
|
+
}
|
|
23
|
+
break;
|
|
24
|
+
}
|
|
25
|
+
case "openai": {
|
|
26
|
+
const key = apiKey ?? process.env["OPENAI_API_KEY"];
|
|
27
|
+
if (!key) {
|
|
28
|
+
throw new Error(`${roleLabel} is configured to use OpenAI but OPENAI_API_KEY is not set. ` +
|
|
29
|
+
`Set the OPENAI_API_KEY environment variable and try again.`);
|
|
30
|
+
}
|
|
31
|
+
break;
|
|
32
|
+
}
|
|
33
|
+
case "google": {
|
|
34
|
+
const key = apiKey ??
|
|
35
|
+
process.env["GOOGLE_API_KEY"] ??
|
|
36
|
+
process.env["GEMINI_API_KEY"];
|
|
37
|
+
if (!key) {
|
|
38
|
+
throw new Error(`${roleLabel} is configured to use Google Gemini but neither GOOGLE_API_KEY nor GEMINI_API_KEY is set. ` +
|
|
39
|
+
`Set one of those environment variables and try again.`);
|
|
40
|
+
}
|
|
41
|
+
break;
|
|
42
|
+
}
|
|
43
|
+
case "openai-compat":
|
|
44
|
+
// API key is optional for Ollama and other local servers — skip validation.
|
|
45
|
+
break;
|
|
46
|
+
default:
|
|
47
|
+
// Unknown providers: no validation, let createClient handle the error.
|
|
48
|
+
break;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Create an LLMClient for the given provider.
|
|
53
|
+
*
|
|
54
|
+
* Provider resolution order:
|
|
55
|
+
* 1. If `provider` is explicitly set, use it directly with `model` as-is.
|
|
56
|
+
* 2. If `model` is set but `provider` is not, infer the provider from the
|
|
57
|
+
* model shorthand using resolveProviderModel().
|
|
58
|
+
* 3. If neither is set, default to "anthropic".
|
|
59
|
+
*
|
|
60
|
+
* API key validation is performed before constructing any adapter. Pass a
|
|
61
|
+
* `role` string (e.g. "Planner") so error messages identify which role is
|
|
62
|
+
* misconfigured.
|
|
63
|
+
*
|
|
64
|
+
* @param provider - Optional provider name. When omitted, inferred from model.
|
|
65
|
+
* @param endpoint - Optional base URL override (used by OpenAI-compat adapters).
|
|
66
|
+
* @param providerConfig - Optional provider-specific configuration (e.g., apiKey).
|
|
67
|
+
* @param model - Optional model string used for provider inference when provider is not set.
|
|
68
|
+
* @param role - Optional role label used in API key error messages.
|
|
69
|
+
* @returns An LLMClient instance for the resolved provider.
|
|
70
|
+
* @throws If the resolved provider is unsupported or the required API key is missing.
|
|
71
|
+
*/
|
|
72
|
+
export function createClient(provider, endpoint, providerConfig, model, role) {
|
|
73
|
+
// endpoint is used by OpenAI and openai-compat adapters as a base URL
|
|
74
|
+
// Resolve provider: explicit wins; otherwise infer from model shorthand
|
|
75
|
+
let resolvedProvider;
|
|
76
|
+
if (provider) {
|
|
77
|
+
resolvedProvider = provider;
|
|
78
|
+
}
|
|
79
|
+
else if (model) {
|
|
80
|
+
const resolved = resolveProviderModel(model);
|
|
81
|
+
resolvedProvider = resolved.provider;
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
resolvedProvider = "anthropic";
|
|
85
|
+
}
|
|
86
|
+
const apiKey = typeof providerConfig?.["apiKey"] === "string"
|
|
87
|
+
? providerConfig["apiKey"]
|
|
88
|
+
: undefined;
|
|
89
|
+
// Validate API key before constructing the adapter.
|
|
90
|
+
validateApiKey(resolvedProvider, role, apiKey);
|
|
91
|
+
// Resolve the model ID (for cases where provider was inferred from shorthand)
|
|
92
|
+
const resolvedModelId = !provider && model
|
|
93
|
+
? resolveProviderModel(model).modelId
|
|
94
|
+
: model ?? resolvedProvider;
|
|
95
|
+
switch (resolvedProvider) {
|
|
96
|
+
case "anthropic":
|
|
97
|
+
return new AnthropicAdapter(apiKey);
|
|
98
|
+
case "openai":
|
|
99
|
+
return new OpenAIAdapter(resolvedModelId, apiKey ?? process.env["OPENAI_API_KEY"], endpoint ?? undefined, providerConfig);
|
|
100
|
+
case "google":
|
|
101
|
+
return new GoogleAdapter(resolvedModelId, apiKey ?? process.env["GOOGLE_API_KEY"] ?? process.env["GEMINI_API_KEY"]);
|
|
102
|
+
case "openai-compat": {
|
|
103
|
+
// Resolve endpoint: explicit arg wins, then model resolution (for ollama/ prefix),
|
|
104
|
+
// then providerConfig, then error.
|
|
105
|
+
const resolvedEndpoint = endpoint ??
|
|
106
|
+
(!provider && model ? resolveProviderModel(model).endpoint : undefined) ??
|
|
107
|
+
(typeof providerConfig?.["endpoint"] === "string"
|
|
108
|
+
? providerConfig["endpoint"]
|
|
109
|
+
: undefined);
|
|
110
|
+
if (!resolvedEndpoint) {
|
|
111
|
+
throw new Error('OpenAI-compatible provider requires an endpoint. Set endpoint in provider config or use the "ollama/" model prefix.');
|
|
112
|
+
}
|
|
113
|
+
return new OpenAICompatAdapter(resolvedEndpoint, resolvedModelId, apiKey);
|
|
114
|
+
}
|
|
115
|
+
default:
|
|
116
|
+
throw new Error(`Unsupported provider: "${resolvedProvider}". Supported providers: anthropic, openai, google, openai-compat.`);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
//# sourceMappingURL=factory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"factory.js","sourceRoot":"","sources":["../../src/providers/factory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAEzD,OAAO,EAAE,oBAAoB,EAAE,MAAM,mCAAmC,CAAC;AAOzE;;;;;;;GAOG;AACH,MAAM,UAAU,cAAc,CAC5B,gBAAwB,EACxB,IAAa,EACb,MAAe;IAEf,MAAM,SAAS,GAAG,IAAI,IAAI,gBAAgB,CAAC;IAE3C,QAAQ,gBAAgB,EAAE,CAAC;QACzB,KAAK,WAAW,CAAC,CAAC,CAAC;YACjB,MAAM,GAAG,GAAG,MAAM,IAAI,OAAO,CAAC,GAAG,CAAC,mBAAmB,CAAC,CAAC;YACvD,IAAI,CAAC,GAAG,EAAE,CAAC;gBACT,MAAM,IAAI,KAAK,CACb,GAAG,SAAS,oEAAoE;oBAC9E,+DAA+D,CAClE,CAAC;YACJ,CAAC;YACD,MAAM;QACR,CAAC;QACD,KAAK,QAAQ,CAAC,CAAC,CAAC;YACd,MAAM,GAAG,GAAG,MAAM,IAAI,OAAO,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAAC;YACpD,IAAI,CAAC,GAAG,EAAE,CAAC;gBACT,MAAM,IAAI,KAAK,CACb,GAAG,SAAS,8DAA8D;oBACxE,4DAA4D,CAC/D,CAAC;YACJ,CAAC;YACD,MAAM;QACR,CAAC;QACD,KAAK,QAAQ,CAAC,CAAC,CAAC;YACd,MAAM,GAAG,GACP,MAAM;gBACN,OAAO,CAAC,GAAG,CAAC,gBAAgB,CAAC;gBAC7B,OAAO,CAAC,GAAG,CAAC,gB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AQ;YACX,OAAO,IAAI,aAAa,CACtB,eAAe,EACf,MAAM,IAAI,OAAO,CAAC,GAAG,CAAC,gBAAgB,CAAC,EACvC,QAAQ,IAAI,SAAS,EACrB,cAAc,CACf,CAAC;QACJ,KAAK,QAAQ;YACX,OAAO,IAAI,aAAa,CACtB,eAAe,EACf,MAAM,IAAI,OAAO,CAAC,GAAG,CAAC,gBAAgB,CAAC,IAAI,OAAO,CAAC,GAAG,CAAC,gBAAgB,CAAC,CACzE,CAAC;QACJ,KAAK,eAAe,CAAC,CAAC,CAAC;YACrB,mFAAmF;YACnF,mCAAmC;YACnC,MAAM,gBAAgB,GACpB,QAAQ;gBACR,CAAC,CAAC,QAAQ,IAAI,KAAK,CAAC,CAAC,CAAC,oBAAoB,CAAC,KAAK,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC;gBACvE,CAAC,OAAO,cAAc,EAAE,CAAC,UAAU,CAAC,KAAK,QAAQ;oBAC/C,CAAC,CAAC,cAAc,CAAC,UAAU,CAAC;oBAC5B,CAAC,CAAC,SAAS,CAAC,CAAC;YAEjB,IAAI,CAAC,gBAAgB,EAAE,CAAC;gBACtB,MAAM,IAAI,KAAK,CACb,qHAAqH,CACtH,CAAC;YACJ,CAAC;YAED,OAAO,IAAI,mBAAmB,CAAC,gBAAgB,EAAE,eAAe,EAAE,MAAM,CAAC,CAAC;QAC5E,CAAC;QACD;YACE,MAAM,IAAI,KAAK,CACb,0BAA0B,gBAAgB,mEAAmE,CAC9G,CAAC;IACN,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Google Gemini provider adapter.
|
|
3
|
+
*
|
|
4
|
+
* Uses a dynamic import so the `@google/generative-ai` package is an optional
|
|
5
|
+
* peer dependency. If the package is not installed, a clear installation error
|
|
6
|
+
* is thrown at call-time rather than at module load time.
|
|
7
|
+
*
|
|
8
|
+
* All Gemini SDK types are inlined below so this file compiles without the
|
|
9
|
+
* `@google/generative-ai` package present in node_modules.
|
|
10
|
+
*/
|
|
11
|
+
import type { LLMClient, ChatParams, ChatResponse } from "./types.js";
|
|
12
|
+
/**
|
|
13
|
+
* LLMClient implementation that wraps the Google Gemini API.
|
|
14
|
+
*
|
|
15
|
+
* The `@google/generative-ai` npm package is dynamically imported so it
|
|
16
|
+
* remains an optional peer dependency. If the package is absent a descriptive
|
|
17
|
+
* install error is thrown on the first call.
|
|
18
|
+
*
|
|
19
|
+
* Supports:
|
|
20
|
+
* - Function/tool calling via functionDeclarations format
|
|
21
|
+
* - System instruction passed via model config
|
|
22
|
+
* - Message history with user/model/function roles
|
|
23
|
+
*/
|
|
24
|
+
export declare class GoogleAdapter implements LLMClient {
|
|
25
|
+
private readonly model;
|
|
26
|
+
private readonly apiKey;
|
|
27
|
+
/** Lazily initialised after the dynamic import succeeds. */
|
|
28
|
+
private genAI;
|
|
29
|
+
constructor(model: string, apiKey?: string);
|
|
30
|
+
/**
|
|
31
|
+
* Lazily import the `@google/generative-ai` package and return the
|
|
32
|
+
* initialised GoogleGenerativeAI client.
|
|
33
|
+
*
|
|
34
|
+
* @throws If the `@google/generative-ai` package is not installed.
|
|
35
|
+
*/
|
|
36
|
+
private getGenAI;
|
|
37
|
+
chat(params: ChatParams): Promise<ChatResponse>;
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=google.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"google.d.ts","sourceRoot":"","sources":["../../src/providers/google.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EACV,SAAS,EACT,UAAU,EACV,YAAY,EAIb,MAAM,YAAY,CAAC;AAqLpB;;;;;;;;;;;GAWG;AACH,qBAAa,aAAc,YAAW,SAAS;IAC7C,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAS;IAC/B,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAqB;IAE5C,4DAA4D;IAC5D,OAAO,CAAC,KAAK,CAAmC;gBAEpC,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM;IAK1C;;;;;OAKG;YACW,QAAQ;IAmChB,IAAI,CAAC,MAAM,EAAE,UAAU,GAAG,OAAO,CAAC,YAAY,CAAC;CAkDtD"}
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Google Gemini provider adapter.
|
|
3
|
+
*
|
|
4
|
+
* Uses a dynamic import so the `@google/generative-ai` package is an optional
|
|
5
|
+
* peer dependency. If the package is not installed, a clear installation error
|
|
6
|
+
* is thrown at call-time rather than at module load time.
|
|
7
|
+
*
|
|
8
|
+
* All Gemini SDK types are inlined below so this file compiles without the
|
|
9
|
+
* `@google/generative-ai` package present in node_modules.
|
|
10
|
+
*/
|
|
11
|
+
// ── Conversion helpers ───────────────────────────────────────────────
|
|
12
|
+
/**
|
|
13
|
+
* Convert a provider-agnostic ToolDef to Gemini functionDeclarations format.
|
|
14
|
+
*/
|
|
15
|
+
function toGeminiTool(tools) {
|
|
16
|
+
return {
|
|
17
|
+
functionDeclarations: tools.map((tool) => ({
|
|
18
|
+
name: tool.name,
|
|
19
|
+
description: tool.description,
|
|
20
|
+
parameters: tool.input_schema,
|
|
21
|
+
})),
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Normalize a Gemini finishReason to our StopReason type.
|
|
26
|
+
*/
|
|
27
|
+
function normalizeStopReason(finishReason) {
|
|
28
|
+
switch (finishReason) {
|
|
29
|
+
case "STOP":
|
|
30
|
+
return "end";
|
|
31
|
+
case "MAX_TOKENS":
|
|
32
|
+
return "max_tokens";
|
|
33
|
+
default:
|
|
34
|
+
return "end";
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Convert a provider-agnostic Message to Gemini content format.
|
|
39
|
+
*
|
|
40
|
+
* Returns an array because ToolResultMessage may need special handling —
|
|
41
|
+
* Gemini uses role "function" with functionResponse parts for tool results.
|
|
42
|
+
*/
|
|
43
|
+
function toGeminiContents(message) {
|
|
44
|
+
// ToolResultMessage → role:"function" with functionResponse parts
|
|
45
|
+
if ("toolResults" in message) {
|
|
46
|
+
return message.toolResults.map((tr) => ({
|
|
47
|
+
role: "function",
|
|
48
|
+
parts: [
|
|
49
|
+
{
|
|
50
|
+
functionResponse: {
|
|
51
|
+
name: tr.toolUseId,
|
|
52
|
+
response: { content: tr.content },
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
],
|
|
56
|
+
}));
|
|
57
|
+
}
|
|
58
|
+
// AssistantMessage (with tool calls) → role:"model" with functionCall parts
|
|
59
|
+
if ("toolCalls" in message && message.toolCalls.length > 0) {
|
|
60
|
+
const parts = [];
|
|
61
|
+
if (message.content) {
|
|
62
|
+
parts.push({ text: message.content });
|
|
63
|
+
}
|
|
64
|
+
for (const tc of message.toolCalls) {
|
|
65
|
+
parts.push({
|
|
66
|
+
functionCall: {
|
|
67
|
+
name: tc.name,
|
|
68
|
+
args: tc.input,
|
|
69
|
+
},
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
return [{ role: "model", parts }];
|
|
73
|
+
}
|
|
74
|
+
// TextMessage — map "user" → "user", "assistant" → "model"
|
|
75
|
+
const textMsg = message;
|
|
76
|
+
const geminiRole = textMsg.role === "assistant" ? "model" : "user";
|
|
77
|
+
return [{ role: geminiRole, parts: [{ text: textMsg.content }] }];
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Extract normalized text and tool calls from Gemini response parts.
|
|
81
|
+
*/
|
|
82
|
+
function normalizeResponseParts(parts) {
|
|
83
|
+
let text = "";
|
|
84
|
+
const toolCalls = [];
|
|
85
|
+
for (const part of parts) {
|
|
86
|
+
if ("text" in part && typeof part.text === "string") {
|
|
87
|
+
text += part.text;
|
|
88
|
+
}
|
|
89
|
+
else if ("functionCall" in part) {
|
|
90
|
+
// Gemini does not provide a stable call ID — synthesize one from index
|
|
91
|
+
const callId = `gemini-call-${toolCalls.length}-${part.functionCall.name}`;
|
|
92
|
+
toolCalls.push({
|
|
93
|
+
id: callId,
|
|
94
|
+
name: part.functionCall.name,
|
|
95
|
+
input: part.functionCall.args ?? {},
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
return { text, toolCalls };
|
|
100
|
+
}
|
|
101
|
+
// ── GoogleAdapter ────────────────────────────────────────────────────
|
|
102
|
+
/**
|
|
103
|
+
* LLMClient implementation that wraps the Google Gemini API.
|
|
104
|
+
*
|
|
105
|
+
* The `@google/generative-ai` npm package is dynamically imported so it
|
|
106
|
+
* remains an optional peer dependency. If the package is absent a descriptive
|
|
107
|
+
* install error is thrown on the first call.
|
|
108
|
+
*
|
|
109
|
+
* Supports:
|
|
110
|
+
* - Function/tool calling via functionDeclarations format
|
|
111
|
+
* - System instruction passed via model config
|
|
112
|
+
* - Message history with user/model/function roles
|
|
113
|
+
*/
|
|
114
|
+
export class GoogleAdapter {
|
|
115
|
+
model;
|
|
116
|
+
apiKey;
|
|
117
|
+
/** Lazily initialised after the dynamic import succeeds. */
|
|
118
|
+
genAI = null;
|
|
119
|
+
constructor(model, apiKey) {
|
|
120
|
+
this.model = model;
|
|
121
|
+
this.apiKey = apiKey;
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Lazily import the `@google/generative-ai` package and return the
|
|
125
|
+
* initialised GoogleGenerativeAI client.
|
|
126
|
+
*
|
|
127
|
+
* @throws If the `@google/generative-ai` package is not installed.
|
|
128
|
+
*/
|
|
129
|
+
async getGenAI() {
|
|
130
|
+
if (this.genAI) {
|
|
131
|
+
return this.genAI;
|
|
132
|
+
}
|
|
133
|
+
let GoogleGenerativeAI;
|
|
134
|
+
try {
|
|
135
|
+
// Construct the specifier at runtime so TypeScript does not attempt
|
|
136
|
+
// to statically resolve the optional peer dependency at compile time.
|
|
137
|
+
const specifier = "@google/generative-ai";
|
|
138
|
+
const mod = (await import(/* @vite-ignore */ specifier));
|
|
139
|
+
// Handle both ESM default export and CommonJS-style .default wrapping
|
|
140
|
+
GoogleGenerativeAI = (mod["GoogleGenerativeAI"] ?? mod["default"]);
|
|
141
|
+
}
|
|
142
|
+
catch {
|
|
143
|
+
throw new Error('Google provider requires the "@google/generative-ai" package. Run: npm install @google/generative-ai');
|
|
144
|
+
}
|
|
145
|
+
const apiKey = this.apiKey ??
|
|
146
|
+
process.env["GOOGLE_API_KEY"] ??
|
|
147
|
+
process.env["GEMINI_API_KEY"];
|
|
148
|
+
if (!apiKey) {
|
|
149
|
+
throw new Error("Google provider requires an API key. Set GOOGLE_API_KEY or GEMINI_API_KEY environment variable.");
|
|
150
|
+
}
|
|
151
|
+
this.genAI = new GoogleGenerativeAI(apiKey);
|
|
152
|
+
return this.genAI;
|
|
153
|
+
}
|
|
154
|
+
async chat(params) {
|
|
155
|
+
const { model, system, messages, tools, maxTokens: _maxTokens = 16384 } = params;
|
|
156
|
+
const genAI = await this.getGenAI();
|
|
157
|
+
// Get the generative model — system instruction set at model config level
|
|
158
|
+
const generativeModel = genAI.getGenerativeModel({
|
|
159
|
+
model: model || this.model,
|
|
160
|
+
...(system ? { systemInstruction: system } : {}),
|
|
161
|
+
});
|
|
162
|
+
// Convert provider-agnostic Message[] to Gemini contents format
|
|
163
|
+
const contents = messages.flatMap(toGeminiContents);
|
|
164
|
+
// Convert ToolDef[] to Gemini tools format (all declarations in one tool)
|
|
165
|
+
const geminiTools = tools && tools.length > 0 ? [toGeminiTool(tools)] : undefined;
|
|
166
|
+
const result = await generativeModel.generateContent({
|
|
167
|
+
contents,
|
|
168
|
+
...(geminiTools ? { tools: geminiTools } : {}),
|
|
169
|
+
});
|
|
170
|
+
const candidate = result.response.candidates?.[0];
|
|
171
|
+
if (!candidate) {
|
|
172
|
+
return {
|
|
173
|
+
text: "",
|
|
174
|
+
toolCalls: [],
|
|
175
|
+
stopReason: "error",
|
|
176
|
+
usage: { inputTokens: 0, outputTokens: 0 },
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
const parts = candidate.content?.parts ?? [];
|
|
180
|
+
const { text, toolCalls } = normalizeResponseParts(parts);
|
|
181
|
+
const stopReason = normalizeStopReason(candidate.finishReason);
|
|
182
|
+
// Determine stopReason based on whether there are tool calls
|
|
183
|
+
const finalStopReason = toolCalls.length > 0 ? "tool_use" : stopReason;
|
|
184
|
+
return {
|
|
185
|
+
text,
|
|
186
|
+
toolCalls,
|
|
187
|
+
stopReason: finalStopReason,
|
|
188
|
+
usage: {
|
|
189
|
+
inputTokens: result.response.usageMetadata?.promptTokenCount ?? 0,
|
|
190
|
+
outputTokens: result.response.usageMetadata?.candidatesTokenCount ?? 0,
|
|
191
|
+
},
|
|
192
|
+
};
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
//# sourceMappingURL=google.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"google.js","sourceRoot":"","sources":["../../src/providers/google.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAoFH,wEAAwE;AAExE;;GAEG;AACH,SAAS,YAAY,CAAC,KAAgB;IACpC,OAAO;QACL,oBAAoB,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;YACzC,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,WAAW,EAAE,IAAI,CAAC,WAAW;YAC7B,UAAU,EAAE,IAAI,CAAC,YAAuC;SACzD,CAAC,CAAC;KACJ,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,SAAS,mBAAmB,CAAC,YAAgC;IAC3D,QAAQ,YAAY,EAAE,CAAC;QACrB,KAAK,MAAM;YACT,OAAO,KAAK,CAAC;QACf,KAAK,YAAY;YACf,OAAO,YAAY,CAAC;QACtB;YACE,OAAO,KAAK,CAAC;IACjB,CAAC;AACH,CAAC;AAED;;;;;GAKG;AACH,SAAS,gBAAgB,CAAC,OAAgB;IACxC,kEAAkE;IAClE,IAAI,aAAa,IAAI,OAAO,EAAE,CA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export type { JsonSchemaProperty, JsonSchemaObject, ToolDef, ToolCall, ToolResult, TextMessage, AssistantMessage, ToolResultMessage, Message, ChatParams, ChatResponse, StopReason, LLMClient, } from "./types.js";
|
|
2
|
+
export { AnthropicAdapter } from "./anthropic.js";
|
|
3
|
+
export { OpenAIAdapter } from "./openai.js";
|
|
4
|
+
export { GoogleAdapter } from "./google.js";
|
|
5
|
+
export { OpenAICompatAdapter } from "./openai-compat.js";
|
|
6
|
+
export { createClient, type ProviderName } from "./factory.js";
|
|
7
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/providers/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,kBAAkB,EAClB,gBAAgB,EAChB,OAAO,EACP,QAAQ,EACR,UAAU,EACV,WAAW,EACX,gBAAgB,EAChB,iBAAiB,EACjB,OAAO,EACP,UAAU,EACV,YAAY,EACZ,UAAU,EACV,SAAS,GACV,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAEzD,OAAO,EAAE,YAAY,EAAE,KAAK,YAAY,EAAE,MAAM,cAAc,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { AnthropicAdapter } from "./anthropic.js";
|
|
2
|
+
export { OpenAIAdapter } from "./openai.js";
|
|
3
|
+
export { GoogleAdapter } from "./google.js";
|
|
4
|
+
export { OpenAICompatAdapter } from "./openai-compat.js";
|
|
5
|
+
export { createClient } from "./factory.js";
|
|
6
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/providers/index.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAEzD,OAAO,EAAE,YAAY,EAAqB,MAAM,cAAc,CAAC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OpenAI-compatible provider adapter.
|
|
3
|
+
*
|
|
4
|
+
* Creates an OpenAI client pointed at a custom base URL, enabling use with
|
|
5
|
+
* any OpenAI-compatible API server (e.g. Ollama, LM Studio, vLLM, Together AI).
|
|
6
|
+
*
|
|
7
|
+
* Reuses all tool conversion, message conversion, and response normalisation
|
|
8
|
+
* logic from OpenAIAdapter by extending it with a custom base URL and a
|
|
9
|
+
* default API key of "not-needed" (required by the openai SDK but ignored
|
|
10
|
+
* by servers like Ollama that don't require authentication).
|
|
11
|
+
*/
|
|
12
|
+
import { OpenAIAdapter } from "./openai.js";
|
|
13
|
+
import type { LLMClient } from "./types.js";
|
|
14
|
+
/**
|
|
15
|
+
* LLMClient implementation for OpenAI-compatible endpoints.
|
|
16
|
+
*
|
|
17
|
+
* Extends OpenAIAdapter with a required `endpoint` (baseURL) parameter.
|
|
18
|
+
* All tool conversion and response normalisation is inherited from
|
|
19
|
+
* OpenAIAdapter — only the client configuration differs.
|
|
20
|
+
*
|
|
21
|
+
* Usage example (Ollama):
|
|
22
|
+
* ```ts
|
|
23
|
+
* const client = new OpenAICompatAdapter(
|
|
24
|
+
* "http://localhost:11434/v1",
|
|
25
|
+
* "llama3",
|
|
26
|
+
* );
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
export declare class OpenAICompatAdapter extends OpenAIAdapter implements LLMClient {
|
|
30
|
+
/**
|
|
31
|
+
* @param endpoint - Required base URL of the OpenAI-compatible server
|
|
32
|
+
* (e.g. "http://localhost:11434/v1" for Ollama).
|
|
33
|
+
* @param model - Model identifier to use with this server.
|
|
34
|
+
* @param apiKey - Optional API key. Defaults to "not-needed" for servers
|
|
35
|
+
* that do not require authentication (e.g. Ollama).
|
|
36
|
+
*/
|
|
37
|
+
constructor(endpoint: string, model: string, apiKey?: string);
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=openai-compat.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"openai-compat.d.ts","sourceRoot":"","sources":["../../src/providers/openai-compat.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAE5C;;;;;;;;;;;;;;GAcG;AACH,qBAAa,mBAAoB,SAAQ,aAAc,YAAW,SAAS;IACzE;;;;;;OAMG;gBACS,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM;CAK7D"}
|