@noorm/marie-cli 0.1.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/JOY_ZONING.md +200 -0
- package/LICENSE.md +190 -0
- package/README.md +94 -0
- package/dist/cli-new/components/App.js +138 -0
- package/dist/cli-new/components/App.js.map +1 -0
- package/dist/cli-new/components/ApprovalDialog.js +31 -0
- package/dist/cli-new/components/ApprovalDialog.js.map +1 -0
- package/dist/cli-new/components/Banner.js +23 -0
- package/dist/cli-new/components/Banner.js.map +1 -0
- package/dist/cli-new/components/ChatArea.js +49 -0
- package/dist/cli-new/components/ChatArea.js.map +1 -0
- package/dist/cli-new/components/Header.js +20 -0
- package/dist/cli-new/components/Header.js.map +1 -0
- package/dist/cli-new/components/InputArea.js +97 -0
- package/dist/cli-new/components/InputArea.js.map +1 -0
- package/dist/cli-new/components/MessageBubble.js +114 -0
- package/dist/cli-new/components/MessageBubble.js.map +1 -0
- package/dist/cli-new/components/SessionSwitcher.js +46 -0
- package/dist/cli-new/components/SessionSwitcher.js.map +1 -0
- package/dist/cli-new/components/SetupWizard.js +283 -0
- package/dist/cli-new/components/SetupWizard.js.map +1 -0
- package/dist/cli-new/components/ToolCallDisplay.js +45 -0
- package/dist/cli-new/components/ToolCallDisplay.js.map +1 -0
- package/dist/cli-new/hooks/useGit.js +99 -0
- package/dist/cli-new/hooks/useGit.js.map +1 -0
- package/dist/cli-new/hooks/useMarie.js +249 -0
- package/dist/cli-new/hooks/useMarie.js.map +1 -0
- package/dist/cli-new/hooks/useSessions.js +75 -0
- package/dist/cli-new/hooks/useSessions.js.map +1 -0
- package/dist/cli-new/index.js +52 -0
- package/dist/cli-new/index.js.map +1 -0
- package/dist/cli-new/styles/theme.js +68 -0
- package/dist/cli-new/styles/theme.js.map +1 -0
- package/dist/cli-new/types/cli.js +2 -0
- package/dist/cli-new/types/cli.js.map +1 -0
- package/dist/extension.cjs +655 -0
- package/dist/monolith/adapters/CliMarieAdapter.js +72 -0
- package/dist/monolith/adapters/CliMarieAdapter.js.map +1 -0
- package/dist/monolith/adapters/VscodeMarieAdapter.js +81 -0
- package/dist/monolith/adapters/VscodeMarieAdapter.js.map +1 -0
- package/dist/monolith/cli/CliFileSystemPort.js +83 -0
- package/dist/monolith/cli/CliFileSystemPort.js.map +1 -0
- package/dist/monolith/cli/MarieToolDefinitionsCLI.js +438 -0
- package/dist/monolith/cli/MarieToolDefinitionsCLI.js.map +1 -0
- package/dist/monolith/cli/index.js +272 -0
- package/dist/monolith/cli/index.js.map +1 -0
- package/dist/monolith/cli/services/JoyAutomationServiceCLI.js +80 -0
- package/dist/monolith/cli/services/JoyAutomationServiceCLI.js.map +1 -0
- package/dist/monolith/cli/services/JoyServiceCLI.js +63 -0
- package/dist/monolith/cli/services/JoyServiceCLI.js.map +1 -0
- package/dist/monolith/cli/storage.js +119 -0
- package/dist/monolith/cli/storage.js.map +1 -0
- package/dist/monolith/domain/joy/JoyTools.js +513 -0
- package/dist/monolith/domain/joy/JoyTools.js.map +1 -0
- package/dist/monolith/domain/joy/RitualService.js +51 -0
- package/dist/monolith/domain/joy/RitualService.js.map +1 -0
- package/dist/monolith/domain/marie/MarieTypes.js +2 -0
- package/dist/monolith/domain/marie/MarieTypes.js.map +1 -0
- package/dist/monolith/infrastructure/ai/agents/MarieAscendant.js +230 -0
- package/dist/monolith/infrastructure/ai/agents/MarieAscendant.js.map +1 -0
- package/dist/monolith/infrastructure/ai/agents/MarieYOLO.js +207 -0
- package/dist/monolith/infrastructure/ai/agents/MarieYOLO.js.map +1 -0
- package/dist/monolith/infrastructure/ai/context/ContextArchiveService.js +129 -0
- package/dist/monolith/infrastructure/ai/context/ContextArchiveService.js.map +1 -0
- package/dist/monolith/infrastructure/ai/context/ContextManager.js +118 -0
- package/dist/monolith/infrastructure/ai/context/ContextManager.js.map +1 -0
- package/dist/monolith/infrastructure/ai/core/FileSystemPort.js +2 -0
- package/dist/monolith/infrastructure/ai/core/FileSystemPort.js.map +1 -0
- package/dist/monolith/infrastructure/ai/core/GhostPort.js +2 -0
- package/dist/monolith/infrastructure/ai/core/GhostPort.js.map +1 -0
- package/dist/monolith/infrastructure/ai/core/MarieAscensionTypes.js +2 -0
- package/dist/monolith/infrastructure/ai/core/MarieAscensionTypes.js.map +1 -0
- package/dist/monolith/infrastructure/ai/core/MarieEngine.js +590 -0
- package/dist/monolith/infrastructure/ai/core/MarieEngine.js.map +1 -0
- package/dist/monolith/infrastructure/ai/core/MarieEventDispatcher.js +161 -0
- package/dist/monolith/infrastructure/ai/core/MarieEventDispatcher.js.map +1 -0
- package/dist/monolith/infrastructure/ai/core/MarieLockManager.js +121 -0
- package/dist/monolith/infrastructure/ai/core/MarieLockManager.js.map +1 -0
- package/dist/monolith/infrastructure/ai/core/MarieProgressTracker.js +256 -0
- package/dist/monolith/infrastructure/ai/core/MarieProgressTracker.js.map +1 -0
- package/dist/monolith/infrastructure/ai/core/MariePulseService.js +67 -0
- package/dist/monolith/infrastructure/ai/core/MariePulseService.js.map +1 -0
- package/dist/monolith/infrastructure/ai/core/MarieResponse.js +101 -0
- package/dist/monolith/infrastructure/ai/core/MarieResponse.js.map +1 -0
- package/dist/monolith/infrastructure/ai/core/MarieSanitizer.js +86 -0
- package/dist/monolith/infrastructure/ai/core/MarieSanitizer.js.map +1 -0
- package/dist/monolith/infrastructure/ai/core/MarieSession.js +202 -0
- package/dist/monolith/infrastructure/ai/core/MarieSession.js.map +1 -0
- package/dist/monolith/infrastructure/ai/core/MarieStabilityMonitor.js +58 -0
- package/dist/monolith/infrastructure/ai/core/MarieStabilityMonitor.js.map +1 -0
- package/dist/monolith/infrastructure/ai/core/MarieToolMender.js +127 -0
- package/dist/monolith/infrastructure/ai/core/MarieToolMender.js.map +1 -0
- package/dist/monolith/infrastructure/ai/core/MarieToolProcessor.js +548 -0
- package/dist/monolith/infrastructure/ai/core/MarieToolProcessor.js.map +1 -0
- package/dist/monolith/infrastructure/ai/core/MarieYOLOTypes.js +2 -0
- package/dist/monolith/infrastructure/ai/core/MarieYOLOTypes.js.map +1 -0
- package/dist/monolith/infrastructure/ai/core/ReasoningBudget.js +125 -0
- package/dist/monolith/infrastructure/ai/core/ReasoningBudget.js.map +1 -0
- package/dist/monolith/infrastructure/ai/core/VscodeFileSystemPort.js +30 -0
- package/dist/monolith/infrastructure/ai/core/VscodeFileSystemPort.js.map +1 -0
- package/dist/monolith/infrastructure/ai/providers/AIProvider.js +2 -0
- package/dist/monolith/infrastructure/ai/providers/AIProvider.js.map +1 -0
- package/dist/monolith/infrastructure/ai/providers/AnthropicProvider.js +148 -0
- package/dist/monolith/infrastructure/ai/providers/AnthropicProvider.js.map +1 -0
- package/dist/monolith/infrastructure/ai/providers/CerebrasProvider.js +208 -0
- package/dist/monolith/infrastructure/ai/providers/CerebrasProvider.js.map +1 -0
- package/dist/monolith/infrastructure/ai/providers/OpenRouterProvider.js +404 -0
- package/dist/monolith/infrastructure/ai/providers/OpenRouterProvider.js.map +1 -0
- package/dist/monolith/infrastructure/ai/providers/OpenRouterStreamParser.js +283 -0
- package/dist/monolith/infrastructure/ai/providers/OpenRouterStreamParser.js.map +1 -0
- package/dist/monolith/infrastructure/config/ConfigService.js +398 -0
- package/dist/monolith/infrastructure/config/ConfigService.js.map +1 -0
- package/dist/monolith/infrastructure/services/MarieMemoryStore.js +140 -0
- package/dist/monolith/infrastructure/services/MarieMemoryStore.js.map +1 -0
- package/dist/monolith/infrastructure/tools/MarieToolDefinitions.js +1568 -0
- package/dist/monolith/infrastructure/tools/MarieToolDefinitions.js.map +1 -0
- package/dist/monolith/infrastructure/tools/PureStreamParser.js +147 -0
- package/dist/monolith/infrastructure/tools/PureStreamParser.js.map +1 -0
- package/dist/monolith/infrastructure/tools/SharedToolDefinitions.js +223 -0
- package/dist/monolith/infrastructure/tools/SharedToolDefinitions.js.map +1 -0
- package/dist/monolith/infrastructure/tools/ToolRegistry.js +29 -0
- package/dist/monolith/infrastructure/tools/ToolRegistry.js.map +1 -0
- package/dist/monolith/infrastructure/tools/ToolUtils.js +59 -0
- package/dist/monolith/infrastructure/tools/ToolUtils.js.map +1 -0
- package/dist/monolith/plumbing/analysis/CodeHealthService.js +146 -0
- package/dist/monolith/plumbing/analysis/CodeHealthService.js.map +1 -0
- package/dist/monolith/plumbing/analysis/ComplexityService.js +43 -0
- package/dist/monolith/plumbing/analysis/ComplexityService.js.map +1 -0
- package/dist/monolith/plumbing/analysis/DependencyService.js +51 -0
- package/dist/monolith/plumbing/analysis/DependencyService.js.map +1 -0
- package/dist/monolith/plumbing/analysis/DiscoveryService.js +49 -0
- package/dist/monolith/plumbing/analysis/DiscoveryService.js.map +1 -0
- package/dist/monolith/plumbing/analysis/JoyMapService.js +66 -0
- package/dist/monolith/plumbing/analysis/JoyMapService.js.map +1 -0
- package/dist/monolith/plumbing/analysis/LintService.js +132 -0
- package/dist/monolith/plumbing/analysis/LintService.js.map +1 -0
- package/dist/monolith/plumbing/analysis/MarieSentinelService.js +276 -0
- package/dist/monolith/plumbing/analysis/MarieSentinelService.js.map +1 -0
- package/dist/monolith/plumbing/analysis/QualityGuardrailService.js +119 -0
- package/dist/monolith/plumbing/analysis/QualityGuardrailService.js.map +1 -0
- package/dist/monolith/plumbing/analysis/SurgicalMender.js +70 -0
- package/dist/monolith/plumbing/analysis/SurgicalMender.js.map +1 -0
- package/dist/monolith/plumbing/analysis/TestService.js +104 -0
- package/dist/monolith/plumbing/analysis/TestService.js.map +1 -0
- package/dist/monolith/plumbing/filesystem/FileService.js +406 -0
- package/dist/monolith/plumbing/filesystem/FileService.js.map +1 -0
- package/dist/monolith/plumbing/filesystem/PathResolver.js +26 -0
- package/dist/monolith/plumbing/filesystem/PathResolver.js.map +1 -0
- package/dist/monolith/plumbing/git/GitService.js +71 -0
- package/dist/monolith/plumbing/git/GitService.js.map +1 -0
- package/dist/monolith/plumbing/lsp/SymbolService.js +36 -0
- package/dist/monolith/plumbing/lsp/SymbolService.js.map +1 -0
- package/dist/monolith/plumbing/terminal/ProcessRegistry.js +31 -0
- package/dist/monolith/plumbing/terminal/ProcessRegistry.js.map +1 -0
- package/dist/monolith/plumbing/terminal/TerminalService.js +180 -0
- package/dist/monolith/plumbing/terminal/TerminalService.js.map +1 -0
- package/dist/monolith/plumbing/ui/DecorationService.js +54 -0
- package/dist/monolith/plumbing/ui/DecorationService.js.map +1 -0
- package/dist/monolith/plumbing/utils/ErrorUtils.js +11 -0
- package/dist/monolith/plumbing/utils/ErrorUtils.js.map +1 -0
- package/dist/monolith/plumbing/utils/JsonUtils.js +360 -0
- package/dist/monolith/plumbing/utils/JsonUtils.js.map +1 -0
- package/dist/monolith/plumbing/utils/PrefixTree.js +153 -0
- package/dist/monolith/plumbing/utils/PrefixTree.js.map +1 -0
- package/dist/monolith/plumbing/utils/RetryUtils.js +141 -0
- package/dist/monolith/plumbing/utils/RetryUtils.js.map +1 -0
- package/dist/monolith/plumbing/utils/StreamTagDetector.js +128 -0
- package/dist/monolith/plumbing/utils/StreamTagDetector.js.map +1 -0
- package/dist/monolith/plumbing/utils/StringUtils.js +97 -0
- package/dist/monolith/plumbing/utils/StringUtils.js.map +1 -0
- package/dist/monolith/plumbing/utils/TimeoutUtils.js +21 -0
- package/dist/monolith/plumbing/utils/TimeoutUtils.js.map +1 -0
- package/dist/monolith/runtime/MarieRuntime.js +354 -0
- package/dist/monolith/runtime/MarieRuntime.js.map +1 -0
- package/dist/monolith/runtime/RuntimeAdapterBase.js +59 -0
- package/dist/monolith/runtime/RuntimeAdapterBase.js.map +1 -0
- package/dist/monolith/runtime/providerFactory.js +11 -0
- package/dist/monolith/runtime/providerFactory.js.map +1 -0
- package/dist/monolith/runtime/types.js +2 -0
- package/dist/monolith/runtime/types.js.map +1 -0
- package/dist/monolith/services/HealthService.js +38 -0
- package/dist/monolith/services/HealthService.js.map +1 -0
- package/dist/monolith/services/JoyAutomationService.js +131 -0
- package/dist/monolith/services/JoyAutomationService.js.map +1 -0
- package/dist/monolith/services/JoyLogService.js +48 -0
- package/dist/monolith/services/JoyLogService.js.map +1 -0
- package/dist/monolith/services/JoyService.js +190 -0
- package/dist/monolith/services/JoyService.js.map +1 -0
- package/dist/monolith/services/MarieGhostService.js +168 -0
- package/dist/monolith/services/MarieGhostService.js.map +1 -0
- package/dist/monolith/services/MarieSCMProvider.js +41 -0
- package/dist/monolith/services/MarieSCMProvider.js.map +1 -0
- package/package.json +168 -0
|
@@ -0,0 +1,404 @@
|
|
|
1
|
+
import { ConfigService } from "../../config/ConfigService.js";
|
|
2
|
+
import { getErrorMessage } from "../../../plumbing/utils/ErrorUtils.js";
|
|
3
|
+
import { JsonUtils } from "../../../plumbing/utils/JsonUtils.js";
|
|
4
|
+
import { OpenRouterStreamParser } from "./OpenRouterStreamParser.js";
|
|
5
|
+
export class OpenRouterProvider {
|
|
6
|
+
apiKey;
|
|
7
|
+
baseUrl = "https://openrouter.ai/api/v1";
|
|
8
|
+
constructor(apiKey) {
|
|
9
|
+
this.apiKey = apiKey;
|
|
10
|
+
}
|
|
11
|
+
async createMessage(params) {
|
|
12
|
+
const translatedModel = this.translateModelName(params.model);
|
|
13
|
+
const response = await fetch(`${this.baseUrl}/chat/completions`, {
|
|
14
|
+
method: "POST",
|
|
15
|
+
headers: {
|
|
16
|
+
Authorization: `Bearer ${this.apiKey}`,
|
|
17
|
+
"HTTP-Referer": "https://github.com/bozoegg/MarieCoder",
|
|
18
|
+
"X-Title": "MarieCoder VS Code Extension",
|
|
19
|
+
"Content-Type": "application/json",
|
|
20
|
+
Accept: "application/json",
|
|
21
|
+
},
|
|
22
|
+
body: JSON.stringify({
|
|
23
|
+
model: translatedModel,
|
|
24
|
+
messages: this.getOpenAiMessages(params),
|
|
25
|
+
tools: this.getOpenAiTools(params),
|
|
26
|
+
max_tokens: params.max_tokens || 1024,
|
|
27
|
+
}),
|
|
28
|
+
});
|
|
29
|
+
if (!response.ok) {
|
|
30
|
+
let errorMsg = `OpenRouter API error: ${response.status} ${response.statusText} (model: ${translatedModel})`;
|
|
31
|
+
try {
|
|
32
|
+
const errorJson = (await response.json());
|
|
33
|
+
if (errorJson.error?.message)
|
|
34
|
+
errorMsg = `OpenRouter API error: ${errorJson.error.message} (model: ${translatedModel})`;
|
|
35
|
+
}
|
|
36
|
+
catch (e) {
|
|
37
|
+
const text = await response.text().catch(() => "");
|
|
38
|
+
if (text)
|
|
39
|
+
errorMsg += ` - ${text}`;
|
|
40
|
+
}
|
|
41
|
+
throw new Error(errorMsg);
|
|
42
|
+
}
|
|
43
|
+
const data = (await response.json());
|
|
44
|
+
if (!data.choices || data.choices.length === 0)
|
|
45
|
+
throw new Error("OpenRouter API returned no choices.");
|
|
46
|
+
const choice = data.choices[0].message;
|
|
47
|
+
if (choice.tool_calls && choice.tool_calls.length > 0) {
|
|
48
|
+
try {
|
|
49
|
+
const toolUses = choice.tool_calls.map((tc) => ({
|
|
50
|
+
id: tc.id,
|
|
51
|
+
name: tc.function.name,
|
|
52
|
+
input: JsonUtils.safeParseJson(tc.function.arguments),
|
|
53
|
+
}));
|
|
54
|
+
return {
|
|
55
|
+
role: "assistant",
|
|
56
|
+
content: choice.content || "",
|
|
57
|
+
tool_uses: toolUses,
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
catch (error) {
|
|
61
|
+
console.error("Failed to parse tool arguments from OpenRouter:", getErrorMessage(error));
|
|
62
|
+
return {
|
|
63
|
+
role: "assistant",
|
|
64
|
+
content: choice.content || `(Message error: Malformed tool arguments)`,
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
return {
|
|
69
|
+
role: "assistant",
|
|
70
|
+
content: choice.content || "",
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
async createMessageStream(params, onUpdate, signal) {
|
|
74
|
+
const controller = new AbortController();
|
|
75
|
+
let isTimeout = false;
|
|
76
|
+
const timeoutId = setTimeout(() => {
|
|
77
|
+
isTimeout = true;
|
|
78
|
+
controller.abort();
|
|
79
|
+
}, 120000);
|
|
80
|
+
let isUserAbort = false;
|
|
81
|
+
const onAbort = () => {
|
|
82
|
+
isUserAbort = true;
|
|
83
|
+
controller.abort();
|
|
84
|
+
};
|
|
85
|
+
if (signal)
|
|
86
|
+
signal.addEventListener("abort", onAbort);
|
|
87
|
+
try {
|
|
88
|
+
const translatedModel = this.translateModelName(params.model);
|
|
89
|
+
const response = await fetch(`${this.baseUrl}/chat/completions`, {
|
|
90
|
+
method: "POST",
|
|
91
|
+
headers: {
|
|
92
|
+
Authorization: `Bearer ${this.apiKey}`,
|
|
93
|
+
"HTTP-Referer": "https://github.com/bozoegg/MarieCoder",
|
|
94
|
+
"X-Title": "MarieCoder VS Code Extension",
|
|
95
|
+
"Content-Type": "application/json",
|
|
96
|
+
Accept: "text/event-stream",
|
|
97
|
+
"Cache-Control": "no-cache",
|
|
98
|
+
Connection: "keep-alive",
|
|
99
|
+
},
|
|
100
|
+
body: JSON.stringify({
|
|
101
|
+
model: translatedModel,
|
|
102
|
+
messages: this.getOpenAiMessages(params),
|
|
103
|
+
tools: this.getOpenAiTools(params),
|
|
104
|
+
max_tokens: params.max_tokens || 1024,
|
|
105
|
+
stream: true,
|
|
106
|
+
include_reasoning: true,
|
|
107
|
+
}),
|
|
108
|
+
signal: controller.signal,
|
|
109
|
+
});
|
|
110
|
+
if (!response.ok) {
|
|
111
|
+
throw new Error(`OpenRouter API error: ${response.status} (model: ${translatedModel})`);
|
|
112
|
+
}
|
|
113
|
+
if (!response.body)
|
|
114
|
+
throw new Error("OpenRouter API returned no body.");
|
|
115
|
+
const reader = response.body.getReader();
|
|
116
|
+
const decoder = new TextDecoder();
|
|
117
|
+
const contentParts = [];
|
|
118
|
+
const reasoningParts = [];
|
|
119
|
+
const bufferParts = [];
|
|
120
|
+
const toolCalls = {};
|
|
121
|
+
const startTime = Date.now();
|
|
122
|
+
onUpdate({ type: "run_started", timestamp: startTime });
|
|
123
|
+
onUpdate({
|
|
124
|
+
type: "stage_change",
|
|
125
|
+
stage: "thinking",
|
|
126
|
+
label: "Processing request...",
|
|
127
|
+
});
|
|
128
|
+
const streamParser = new OpenRouterStreamParser();
|
|
129
|
+
try {
|
|
130
|
+
while (true) {
|
|
131
|
+
const { done, value } = await reader.read();
|
|
132
|
+
if (done)
|
|
133
|
+
break;
|
|
134
|
+
const chunk = decoder.decode(value, { stream: true });
|
|
135
|
+
bufferParts.push(chunk);
|
|
136
|
+
const buffer = bufferParts.join("");
|
|
137
|
+
const lines = buffer.split("\n");
|
|
138
|
+
const remainder = lines.pop() || "";
|
|
139
|
+
bufferParts.length = 0;
|
|
140
|
+
if (remainder)
|
|
141
|
+
bufferParts.push(remainder);
|
|
142
|
+
for (const line of lines) {
|
|
143
|
+
const trimmedLine = line.trim();
|
|
144
|
+
if (!trimmedLine || trimmedLine.startsWith(":"))
|
|
145
|
+
continue;
|
|
146
|
+
if (trimmedLine.startsWith("data: ")) {
|
|
147
|
+
const dataStr = trimmedLine.slice(6);
|
|
148
|
+
if (dataStr === "[DONE]")
|
|
149
|
+
continue;
|
|
150
|
+
try {
|
|
151
|
+
const data = JSON.parse(dataStr);
|
|
152
|
+
const choice = data.choices?.[0];
|
|
153
|
+
if (!choice)
|
|
154
|
+
continue;
|
|
155
|
+
const delta = choice.delta;
|
|
156
|
+
if (delta?.content) {
|
|
157
|
+
const events = streamParser.processContent(delta.content);
|
|
158
|
+
for (const event of events) {
|
|
159
|
+
if (event.type === "content_delta")
|
|
160
|
+
contentParts.push(event.text);
|
|
161
|
+
if (event.type === "reasoning_delta")
|
|
162
|
+
reasoningParts.push(event.text);
|
|
163
|
+
onUpdate(event);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
if (delta?.tool_calls) {
|
|
167
|
+
onUpdate({
|
|
168
|
+
type: "stage_change",
|
|
169
|
+
stage: "calling_tool",
|
|
170
|
+
label: "Using tool...",
|
|
171
|
+
});
|
|
172
|
+
for (const tc of delta.tool_calls) {
|
|
173
|
+
const idx = tc.index;
|
|
174
|
+
if (!toolCalls[idx]) {
|
|
175
|
+
toolCalls[idx] = {
|
|
176
|
+
id: tc.id || "",
|
|
177
|
+
name: tc.function?.name || "",
|
|
178
|
+
argumentsParts: [],
|
|
179
|
+
};
|
|
180
|
+
}
|
|
181
|
+
else {
|
|
182
|
+
if (tc.id)
|
|
183
|
+
toolCalls[idx].id = tc.id;
|
|
184
|
+
if (tc.function?.name)
|
|
185
|
+
toolCalls[idx].name += tc.function.name;
|
|
186
|
+
}
|
|
187
|
+
if (tc.function?.arguments) {
|
|
188
|
+
toolCalls[idx].argumentsParts.push(tc.function.arguments);
|
|
189
|
+
onUpdate({
|
|
190
|
+
type: "tool_call_delta",
|
|
191
|
+
index: idx,
|
|
192
|
+
id: toolCalls[idx].id,
|
|
193
|
+
name: toolCalls[idx].name,
|
|
194
|
+
argumentsDelta: tc.function.arguments,
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
if (data.usage) {
|
|
200
|
+
onUpdate({
|
|
201
|
+
type: "usage",
|
|
202
|
+
usage: {
|
|
203
|
+
inputTokens: data.usage.prompt_tokens,
|
|
204
|
+
outputTokens: data.usage.completion_tokens,
|
|
205
|
+
totalTokens: data.usage.total_tokens,
|
|
206
|
+
reasoningTokens: data.usage.reasoning_tokens,
|
|
207
|
+
},
|
|
208
|
+
});
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
catch (e) {
|
|
212
|
+
// Ignore parsing errors for individual chunks
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
finally {
|
|
219
|
+
reader.releaseLock();
|
|
220
|
+
}
|
|
221
|
+
// Join all array buffers into final strings
|
|
222
|
+
const fullContent = contentParts.join("");
|
|
223
|
+
const fullReasoning = reasoningParts.join("");
|
|
224
|
+
const finalEvents = streamParser.finalize(fullContent);
|
|
225
|
+
for (const event of finalEvents)
|
|
226
|
+
onUpdate(event);
|
|
227
|
+
const endTime = Date.now();
|
|
228
|
+
onUpdate({
|
|
229
|
+
type: "run_completed",
|
|
230
|
+
timestamp: endTime,
|
|
231
|
+
durationMs: endTime - startTime,
|
|
232
|
+
});
|
|
233
|
+
const llamaCalls = streamParser.getCollectedToolCalls();
|
|
234
|
+
for (const idx in llamaCalls) {
|
|
235
|
+
const call = llamaCalls[idx];
|
|
236
|
+
toolCalls[parseInt(idx) + 1000] = {
|
|
237
|
+
id: call.id,
|
|
238
|
+
name: call.name,
|
|
239
|
+
argumentsParts: [call.arguments], // Wrap string as array for consistency
|
|
240
|
+
};
|
|
241
|
+
}
|
|
242
|
+
const finalToolUses = [];
|
|
243
|
+
for (const idx in toolCalls) {
|
|
244
|
+
const tc = toolCalls[idx];
|
|
245
|
+
try {
|
|
246
|
+
const args = tc.argumentsParts.join("");
|
|
247
|
+
finalToolUses.push({
|
|
248
|
+
id: tc.id,
|
|
249
|
+
name: tc.name,
|
|
250
|
+
input: JsonUtils.safeParseJson(args),
|
|
251
|
+
});
|
|
252
|
+
}
|
|
253
|
+
catch (e) {
|
|
254
|
+
// Ignore tool call parsing errors in stream
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
const blocks = [];
|
|
258
|
+
if (fullReasoning)
|
|
259
|
+
blocks.push({ type: "thought", text: fullReasoning });
|
|
260
|
+
if (fullContent)
|
|
261
|
+
blocks.push({ type: "text", text: fullContent });
|
|
262
|
+
return {
|
|
263
|
+
role: "assistant",
|
|
264
|
+
content: blocks.length > 0 ? blocks : fullContent,
|
|
265
|
+
tool_uses: finalToolUses.length > 0 ? finalToolUses : undefined,
|
|
266
|
+
};
|
|
267
|
+
}
|
|
268
|
+
catch (error) {
|
|
269
|
+
if (error instanceof Error && error.name === "AbortError") {
|
|
270
|
+
// Distinguish between user manual stop and actual timeout
|
|
271
|
+
if (isUserAbort) {
|
|
272
|
+
throw new Error("Request stopped by user");
|
|
273
|
+
}
|
|
274
|
+
else if (isTimeout) {
|
|
275
|
+
throw new Error("OpenRouter timeout");
|
|
276
|
+
}
|
|
277
|
+
else {
|
|
278
|
+
throw new Error("Request aborted");
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
throw error;
|
|
282
|
+
}
|
|
283
|
+
finally {
|
|
284
|
+
clearTimeout(timeoutId);
|
|
285
|
+
if (signal)
|
|
286
|
+
signal.removeEventListener("abort", onAbort);
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
/**
|
|
290
|
+
* Translates Anthropic model names to OpenRouter format.
|
|
291
|
+
* OpenRouter expects format like "anthropic/claude-3.5-sonnet"
|
|
292
|
+
*/
|
|
293
|
+
translateModelName(model) {
|
|
294
|
+
const normalized = (model || "").trim();
|
|
295
|
+
if (!normalized) {
|
|
296
|
+
return "anthropic/claude-3.5-sonnet";
|
|
297
|
+
}
|
|
298
|
+
// If already in OpenRouter format, return as-is
|
|
299
|
+
if (normalized.includes("/")) {
|
|
300
|
+
return normalized;
|
|
301
|
+
}
|
|
302
|
+
// Map Anthropic model names to OpenRouter format
|
|
303
|
+
const modelMap = {
|
|
304
|
+
"claude-3-5-sonnet-20241022": "anthropic/claude-3.5-sonnet",
|
|
305
|
+
"claude-3-5-sonnet": "anthropic/claude-3.5-sonnet",
|
|
306
|
+
"claude-3-5-haiku-20241022": "anthropic/claude-3.5-haiku",
|
|
307
|
+
"claude-3-5-haiku": "anthropic/claude-3.5-haiku",
|
|
308
|
+
"claude-3-opus-20240229": "anthropic/claude-3-opus",
|
|
309
|
+
"claude-3-opus": "anthropic/claude-3-opus",
|
|
310
|
+
"claude-3-sonnet-20240229": "anthropic/claude-3-sonnet",
|
|
311
|
+
"claude-3-sonnet": "anthropic/claude-3-sonnet",
|
|
312
|
+
"claude-3-haiku-20240307": "anthropic/claude-3-haiku",
|
|
313
|
+
"claude-3-haiku": "anthropic/claude-3-haiku",
|
|
314
|
+
};
|
|
315
|
+
if (modelMap[normalized]) {
|
|
316
|
+
return modelMap[normalized];
|
|
317
|
+
}
|
|
318
|
+
// Try to convert claude models that aren't in the map.
|
|
319
|
+
// Examples:
|
|
320
|
+
// - claude-3-5-sonnet-20241022 => anthropic/claude-3.5-sonnet
|
|
321
|
+
// - claude-3-7-sonnet => anthropic/claude-3.7-sonnet
|
|
322
|
+
if (normalized.startsWith("claude-")) {
|
|
323
|
+
const withoutDateSuffix = normalized.replace(/-20\d{6}$/, "");
|
|
324
|
+
const claudeVersioned = withoutDateSuffix.match(/^claude-(\d+)-(\d+)(-.+)$/);
|
|
325
|
+
if (claudeVersioned) {
|
|
326
|
+
const major = claudeVersioned[1];
|
|
327
|
+
const minor = claudeVersioned[2];
|
|
328
|
+
const variant = claudeVersioned[3];
|
|
329
|
+
return `anthropic/claude-${major}.${minor}${variant}`;
|
|
330
|
+
}
|
|
331
|
+
return `anthropic/${withoutDateSuffix}`;
|
|
332
|
+
}
|
|
333
|
+
// Return as-is if we can't translate
|
|
334
|
+
return normalized;
|
|
335
|
+
}
|
|
336
|
+
getOpenAiMessages(params) {
|
|
337
|
+
const messages = [];
|
|
338
|
+
if (params.system)
|
|
339
|
+
messages.push({ role: "system", content: params.system });
|
|
340
|
+
for (const msg of params.messages) {
|
|
341
|
+
if (typeof msg.content === "string") {
|
|
342
|
+
messages.push({ role: msg.role, content: msg.content });
|
|
343
|
+
}
|
|
344
|
+
else if (Array.isArray(msg.content)) {
|
|
345
|
+
let text = "";
|
|
346
|
+
const tools = [];
|
|
347
|
+
for (const block of msg.content) {
|
|
348
|
+
if (block.type === "text")
|
|
349
|
+
text += block.text;
|
|
350
|
+
else if (block.type === "tool_use")
|
|
351
|
+
tools.push({
|
|
352
|
+
id: block.id,
|
|
353
|
+
type: "function",
|
|
354
|
+
function: {
|
|
355
|
+
name: block.name,
|
|
356
|
+
arguments: JSON.stringify(block.input),
|
|
357
|
+
},
|
|
358
|
+
});
|
|
359
|
+
else if (block.type === "tool_result") {
|
|
360
|
+
messages.push({
|
|
361
|
+
role: "tool",
|
|
362
|
+
tool_call_id: block.tool_use_id,
|
|
363
|
+
content: typeof block.content === "string"
|
|
364
|
+
? block.content
|
|
365
|
+
: JSON.stringify(block.content),
|
|
366
|
+
});
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
if (msg.role === "assistant" && (text || tools.length > 0)) {
|
|
370
|
+
const m = { role: "assistant", content: text || null };
|
|
371
|
+
if (tools.length > 0)
|
|
372
|
+
m.tool_calls = tools;
|
|
373
|
+
messages.push(m);
|
|
374
|
+
}
|
|
375
|
+
else if (msg.role === "user" && text) {
|
|
376
|
+
messages.push({ role: "user", content: text });
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
return messages;
|
|
381
|
+
}
|
|
382
|
+
getOpenAiTools(params) {
|
|
383
|
+
if (!params.tools)
|
|
384
|
+
return undefined;
|
|
385
|
+
return params.tools.map((tool) => ({
|
|
386
|
+
type: "function",
|
|
387
|
+
function: {
|
|
388
|
+
name: tool.name,
|
|
389
|
+
description: tool.description,
|
|
390
|
+
parameters: tool.input_schema,
|
|
391
|
+
},
|
|
392
|
+
}));
|
|
393
|
+
}
|
|
394
|
+
estimateTokens(text) {
|
|
395
|
+
return Math.ceil(text.length * ConfigService.getTokensPerChar());
|
|
396
|
+
}
|
|
397
|
+
async listModels() {
|
|
398
|
+
return [
|
|
399
|
+
{ id: "anthropic/claude-3.5-sonnet", name: "Claude 3.5 Sonnet" },
|
|
400
|
+
{ id: "google/gemini-2.0-flash-001", name: "Gemini 2.0 Flash" },
|
|
401
|
+
];
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
//# sourceMappingURL=OpenRouterProvider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OpenRouterProvider.js","sourceRoot":"","sources":["../../../../../src/monolith/infrastructure/ai/providers/OpenRouterProvider.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAC9D,OAAO,EAAE,eAAe,EAAE,MAAM,uCAAuC,CAAC;AACxE,OAAO,EAAE,SAAS,EA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