micro-models-agent 0.55.0 → 0.55.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +358 -358
- package/dist/certification/certifications.json +493 -493
- package/dist/main.js +122 -55
- package/dist/modules/browser/bridge-server.mjs +202 -202
- package/dist/skills/builtin/git.md +36 -36
- package/dist/skills/builtin/typescript.md +35 -35
- package/package.json +1 -1
- package/dist/cli/commands.js +0 -447
- package/dist/cli/completer.js +0 -167
- package/dist/cli/index.js +0 -2
- package/dist/cli/main.js +0 -153
- package/dist/cli/plugin-commands.js +0 -36
- package/dist/cli/repl-commands.js +0 -761
- package/dist/cli/repl.js +0 -702
- package/dist/cli/run-result.js +0 -33
- package/dist/cli/security-commands.js +0 -164
- package/dist/cli/setup.js +0 -237
- package/dist/config/config.js +0 -276
- package/dist/config/defaults.js +0 -141
- package/dist/config/domains.js +0 -179
- package/dist/config/experts.js +0 -15
- package/dist/config/index.js +0 -4
- package/dist/config/security.js +0 -213
- package/dist/config/types.js +0 -1
- package/dist/core/agent-moe.js +0 -102
- package/dist/core/agent.js +0 -1018
- package/dist/core/bootstrap.js +0 -481
- package/dist/core/crash-handler.js +0 -51
- package/dist/core/environment.js +0 -199
- package/dist/core/index.js +0 -2
- package/dist/core/prompt-builder.js +0 -76
- package/dist/core/session-logger.js +0 -251
- package/dist/core/types.js +0 -1
- package/dist/core/version.js +0 -26
- package/dist/core/workspace.js +0 -76
- package/dist/i18n/en.json +0 -679
- package/dist/i18n/index.js +0 -46
- package/dist/i18n/ru.json +0 -679
- package/dist/index.js +0 -22
- package/dist/llm/image-utils.js +0 -143
- package/dist/llm/index.js +0 -4
- package/dist/llm/model-loader.js +0 -78
- package/dist/llm/openai-compat.js +0 -497
- package/dist/llm/orchestrator.js +0 -200
- package/dist/llm/provider.js +0 -10
- package/dist/llm/response.js +0 -39
- package/dist/llm/token-counter.js +0 -39
- package/dist/llm/types.js +0 -1
- package/dist/logger/app-logger.js +0 -189
- package/dist/logger/file-log.js +0 -151
- package/dist/logger/index.js +0 -1
- package/dist/migration/backup.js +0 -45
- package/dist/migration/detect.js +0 -50
- package/dist/migration/index.js +0 -2
- package/dist/modules/artifacts/store.js +0 -61
- package/dist/modules/browser/actions.js +0 -76
- package/dist/modules/browser/bridge-client.js +0 -199
- package/dist/modules/browser/bridge-path.js +0 -10
- package/dist/modules/browser/cookie-store.js +0 -24
- package/dist/modules/browser/driver.js +0 -136
- package/dist/modules/browser/index.js +0 -7
- package/dist/modules/browser/module.js +0 -29
- package/dist/modules/browser/session.js +0 -342
- package/dist/modules/browser/snapshot.js +0 -148
- package/dist/modules/browser/types.js +0 -12
- package/dist/modules/certification/cli.js +0 -213
- package/dist/modules/certification/fact-checker.js +0 -82
- package/dist/modules/certification/loader.js +0 -106
- package/dist/modules/certification/manifest.js +0 -58
- package/dist/modules/certification/runner.js +0 -245
- package/dist/modules/certification/scenarios.js +0 -407
- package/dist/modules/certification/types.js +0 -1
- package/dist/modules/context/chunk-query.js +0 -100
- package/dist/modules/context/fact-extractor.js +0 -168
- package/dist/modules/context/history.js +0 -15
- package/dist/modules/context/index.js +0 -1
- package/dist/modules/context/manager.js +0 -440
- package/dist/modules/execution/audit-runners.js +0 -206
- package/dist/modules/execution/auditor.js +0 -218
- package/dist/modules/execution/execution-plugin.js +0 -431
- package/dist/modules/execution/index.js +0 -8
- package/dist/modules/execution/module.js +0 -625
- package/dist/modules/execution/moe-executor.js +0 -304
- package/dist/modules/execution/plan-coverage.js +0 -68
- package/dist/modules/execution/plan-persister.js +0 -46
- package/dist/modules/execution/plan-store.js +0 -196
- package/dist/modules/execution/plan-tool.js +0 -677
- package/dist/modules/execution/plan-validator.js +0 -153
- package/dist/modules/execution/planner.js +0 -94
- package/dist/modules/execution/stuck-detector.js +0 -746
- package/dist/modules/execution/tracker.js +0 -69
- package/dist/modules/execution/types.js +0 -1
- package/dist/modules/execution/verifier.js +0 -235
- package/dist/modules/execution/windows-commands.js +0 -41
- package/dist/modules/hallucination/confidence.js +0 -66
- package/dist/modules/hallucination/consistency.js +0 -26
- package/dist/modules/hallucination/detector.js +0 -47
- package/dist/modules/hallucination/factual.js +0 -169
- package/dist/modules/hallucination/index.js +0 -5
- package/dist/modules/hallucination/js-identifiers.js +0 -262
- package/dist/modules/hallucination/llm-judge.js +0 -101
- package/dist/modules/index.js +0 -5
- package/dist/modules/indexer/cache.js +0 -40
- package/dist/modules/indexer/index.js +0 -3
- package/dist/modules/indexer/module.js +0 -246
- package/dist/modules/indexer/project-profile.js +0 -183
- package/dist/modules/indexer/walker.js +0 -101
- package/dist/modules/lsp/check-tool.js +0 -58
- package/dist/modules/lsp/client.js +0 -389
- package/dist/modules/lsp/command.js +0 -60
- package/dist/modules/lsp/config.js +0 -135
- package/dist/modules/lsp/index.js +0 -3
- package/dist/modules/lsp/module.js +0 -260
- package/dist/modules/lsp/probe.js +0 -86
- package/dist/modules/lsp/project-root.js +0 -32
- package/dist/modules/lsp/startup-check.js +0 -144
- package/dist/modules/lsp/types.js +0 -1
- package/dist/modules/mcp/client.js +0 -399
- package/dist/modules/mcp/index.js +0 -3
- package/dist/modules/mcp/module.js +0 -142
- package/dist/modules/mcp/registry.js +0 -15
- package/dist/modules/memory/index.js +0 -1
- package/dist/modules/memory/module.js +0 -96
- package/dist/modules/memory/search.js +0 -42
- package/dist/modules/memory/store.js +0 -69
- package/dist/modules/pipelines/engine.js +0 -60
- package/dist/modules/pipelines/index.js +0 -3
- package/dist/modules/pipelines/parser.js +0 -56
- package/dist/modules/pipelines/template.js +0 -14
- package/dist/modules/plugins/builtin/lint-on-write.js +0 -334
- package/dist/modules/plugins/builtin/notify.js +0 -9
- package/dist/modules/plugins/index.js +0 -1
- package/dist/modules/plugins/loader.js +0 -70
- package/dist/modules/plugins/manager.js +0 -261
- package/dist/modules/plugins/types.js +0 -1
- package/dist/modules/pricing/index.js +0 -61
- package/dist/modules/pricing/prices.js +0 -129
- package/dist/modules/processes/detect.js +0 -34
- package/dist/modules/processes/index.js +0 -2
- package/dist/modules/processes/registry.js +0 -327
- package/dist/modules/processes/runner.js +0 -23
- package/dist/modules/providers/create.js +0 -22
- package/dist/modules/providers/fallback.js +0 -79
- package/dist/modules/providers/health.js +0 -46
- package/dist/modules/providers/index.js +0 -5
- package/dist/modules/providers/manager.js +0 -161
- package/dist/modules/providers/presets.js +0 -128
- package/dist/modules/providers/registry.js +0 -22
- package/dist/modules/providers/types.js +0 -1
- package/dist/modules/registry.js +0 -48
- package/dist/modules/security/audit-log.js +0 -136
- package/dist/modules/security/audit-notifier.js +0 -292
- package/dist/modules/security/command-validator.js +0 -219
- package/dist/modules/security/content-scanner.js +0 -53
- package/dist/modules/security/data-sanitizer.js +0 -89
- package/dist/modules/security/encryption.js +0 -242
- package/dist/modules/security/index.js +0 -14
- package/dist/modules/security/network-validator.js +0 -88
- package/dist/modules/security/path-validator.js +0 -203
- package/dist/modules/security/rate-limiter.js +0 -119
- package/dist/modules/security/security-policies.js +0 -531
- package/dist/modules/security/session-encryption.js +0 -210
- package/dist/modules/security/session-isolation.js +0 -95
- package/dist/modules/session/index.js +0 -3
- package/dist/modules/session/manager.js +0 -172
- package/dist/modules/session/module.js +0 -24
- package/dist/modules/session/store.js +0 -222
- package/dist/modules/session/types.js +0 -1
- package/dist/modules/skills/index.js +0 -2
- package/dist/modules/skills/loader.js +0 -72
- package/dist/modules/skills/matcher.js +0 -27
- package/dist/modules/skills/module.js +0 -129
- package/dist/modules/types.js +0 -1
- package/dist/modules/updater/checker.js +0 -96
- package/dist/modules/updater/index.js +0 -2
- package/dist/modules/updater/module.js +0 -116
- package/dist/modules/user-profile/compressor.js +0 -16
- package/dist/modules/user-profile/index.js +0 -1
- package/dist/modules/user-profile/profile.js +0 -68
- package/dist/tools/approve.js +0 -33
- package/dist/tools/attach-image.js +0 -101
- package/dist/tools/bash.js +0 -519
- package/dist/tools/browser.js +0 -115
- package/dist/tools/chunk-query.js +0 -100
- package/dist/tools/create-dir.js +0 -56
- package/dist/tools/delete-file.js +0 -63
- package/dist/tools/download-file.js +0 -117
- package/dist/tools/edit-file.js +0 -80
- package/dist/tools/enable-tools.js +0 -59
- package/dist/tools/executor.js +0 -154
- package/dist/tools/file-info.js +0 -47
- package/dist/tools/filter-tools.js +0 -17
- package/dist/tools/glob-tool.js +0 -27
- package/dist/tools/grep-tool.js +0 -125
- package/dist/tools/hidden-tools-block.js +0 -37
- package/dist/tools/index.js +0 -78
- package/dist/tools/list-dir.js +0 -49
- package/dist/tools/load-skill.js +0 -43
- package/dist/tools/mcp-call.js +0 -69
- package/dist/tools/move-file.js +0 -86
- package/dist/tools/path-utils.js +0 -101
- package/dist/tools/pipeline-run.js +0 -145
- package/dist/tools/preview.js +0 -2
- package/dist/tools/process-kill.js +0 -40
- package/dist/tools/process-list.js +0 -37
- package/dist/tools/process-log.js +0 -54
- package/dist/tools/question.js +0 -141
- package/dist/tools/read-file.js +0 -179
- package/dist/tools/recall.js +0 -118
- package/dist/tools/registry.js +0 -47
- package/dist/tools/remember.js +0 -68
- package/dist/tools/scope-check.js +0 -32
- package/dist/tools/search-history.js +0 -85
- package/dist/tools/subagent.js +0 -196
- package/dist/tools/types.js +0 -1
- package/dist/tools/user-input.js +0 -123
- package/dist/tools/web-browse.js +0 -87
- package/dist/tools/web-fetch.js +0 -119
- package/dist/tools/web-search.js +0 -105
- package/dist/tools/write-file.js +0 -82
- package/dist/ui/box.js +0 -77
- package/dist/ui/colors.js +0 -4
- package/dist/ui/diff.js +0 -178
- package/dist/ui/index.js +0 -6
- package/dist/ui/line-editor.js +0 -822
- package/dist/ui/line-math.js +0 -73
- package/dist/ui/md-formatter.js +0 -212
- package/dist/ui/output.js +0 -13
- package/dist/ui/plan-view.js +0 -103
- package/dist/ui/renderer.js +0 -259
- package/dist/ui/spinner.js +0 -70
- package/dist/ui/table.js +0 -144
package/dist/main.js
CHANGED
|
@@ -2422,6 +2422,7 @@ The path was joined onto the working directory because it does not exist as give
|
|
|
2422
2422
|
"error.llm_stream_idle_toolcall": 'LLM stream stalled after a tool_call started — no data for {timeout}ms. The provider most likely buffers SSE instead of streaming tool-call argument deltas (seen with LM Studio). Raise "retry.noDataTimeoutMs" in ~/.mma/config.json (restart required)',
|
|
2423
2423
|
"error.llm_truncated": 'Response hit the completion token limit ({tokens}) and was cut off before any content arrived. Split the task into smaller outputs or raise "maxCompletionTokens" in the config',
|
|
2424
2424
|
"error.llm_truncated_toolcall": 'Response hit the completion token limit ({tokens}) in the middle of a tool_call — its arguments were cut off. Write the file in smaller chunks (several write_file/edit_file calls) or raise "maxCompletionTokens" in the config',
|
|
2425
|
+
"error.llm_provider_stream_error": "Provider returned an error mid-stream: {error}",
|
|
2425
2426
|
"error.llm_timeout": "LLM request timed out ({timeout}ms)",
|
|
2426
2427
|
"env.runtime_node": "Running under Node (v{version}) — clipboard image paste, subagent performance and LSP spawn on Windows degrade. Install Bun (https://bun.sh) for full features.",
|
|
2427
2428
|
"env.runtime_old": "Runtime version {version} is below the required engines {engine}.",
|
|
@@ -3166,6 +3167,7 @@ var init_ru = __esm(() => {
|
|
|
3166
3167
|
"error.llm_stream_idle_toolcall": 'Поток LLM завис после начала tool_call — нет данных {timeout}мс. Скорее всего провайдер буферизирует SSE вместо потоковой передачи аргументов tool_call (наблюдается в LM Studio). Увеличьте "retry.noDataTimeoutMs" в ~/.mma/config.json (нужен рестарт)',
|
|
3167
3168
|
"error.llm_truncated": 'Ответ упёрся в лимит токенов генерации ({tokens}) и был обрезан до какого-либо содержимого. Разбейте задачу на меньшие порции вывода или увеличьте "maxCompletionTokens" в конфиге',
|
|
3168
3169
|
"error.llm_truncated_toolcall": 'Ответ упёрся в лимит токенов генерации ({tokens}) посреди tool_call — его аргументы обрезаны. Пишите файл частями (несколько вызовов write_file/edit_file) или увеличьте "maxCompletionTokens" в конфиге',
|
|
3170
|
+
"error.llm_provider_stream_error": "Провайдер вернул ошибку посреди стрима: {error}",
|
|
3169
3171
|
"error.llm_timeout": "Время запроса LLM истекло ({timeout}мс)",
|
|
3170
3172
|
"env.runtime_node": "Запущено под Node (v{version}) — вставка изображений из буфера и LSP на Windows работают урезанно. Установите Bun (https://bun.sh) для полного функционала.",
|
|
3171
3173
|
"env.runtime_old": "Версия рантайма {version} ниже требуемой engines {engine}.",
|
|
@@ -5568,6 +5570,7 @@ class OpenAICompatProvider {
|
|
|
5568
5570
|
tokenCounter;
|
|
5569
5571
|
retryConfig;
|
|
5570
5572
|
rateLimiter;
|
|
5573
|
+
debug;
|
|
5571
5574
|
constructor(config) {
|
|
5572
5575
|
this.config = config;
|
|
5573
5576
|
this.model = config.model;
|
|
@@ -5581,6 +5584,7 @@ class OpenAICompatProvider {
|
|
|
5581
5584
|
noDataTimeoutMs: 180000
|
|
5582
5585
|
};
|
|
5583
5586
|
this.rateLimiter = createRateLimiter(config.rateLimits);
|
|
5587
|
+
this.debug = config.logger ? config.logger.debug.bind(config.logger) : null;
|
|
5584
5588
|
}
|
|
5585
5589
|
async* chat(messages, tools, signal, options) {
|
|
5586
5590
|
if (!this.rateLimiter.canMakeRequest()) {
|
|
@@ -5602,7 +5606,9 @@ class OpenAICompatProvider {
|
|
|
5602
5606
|
yield chunk;
|
|
5603
5607
|
}
|
|
5604
5608
|
if (!hasToolCall && !hasText) {
|
|
5609
|
+
this.debug?.("LLM streaming produced no text/tool_call — falling back to non-streaming");
|
|
5605
5610
|
const fallback = await this.doNonStreaming(effectiveMessages, tools, signal, options);
|
|
5611
|
+
this.debug?.("LLM non-streaming fallback result", { chunks: fallback.length });
|
|
5606
5612
|
for (const chunk of fallback) {
|
|
5607
5613
|
yield chunk;
|
|
5608
5614
|
}
|
|
@@ -5662,6 +5668,16 @@ class OpenAICompatProvider {
|
|
|
5662
5668
|
reasoningEffort: options?.reasoningEffort,
|
|
5663
5669
|
reasoningStrategy: options?.reasoningStrategy
|
|
5664
5670
|
});
|
|
5671
|
+
this.debug?.("LLM stream request", {
|
|
5672
|
+
baseUrl: this.config.baseUrl,
|
|
5673
|
+
model: this.model,
|
|
5674
|
+
stream: true,
|
|
5675
|
+
maxTokens,
|
|
5676
|
+
toolsCount: tools?.length ?? 0,
|
|
5677
|
+
reasoningEffort: options?.reasoningEffort,
|
|
5678
|
+
reasoningStrategy: options?.reasoningStrategy,
|
|
5679
|
+
messagesCount: messages.length
|
|
5680
|
+
});
|
|
5665
5681
|
const { headers, abortSignal, cleanup, isTimeout, flagTimeout, controller } = this.buildRequestSetup(signal);
|
|
5666
5682
|
let response;
|
|
5667
5683
|
try {
|
|
@@ -5689,6 +5705,11 @@ class OpenAICompatProvider {
|
|
|
5689
5705
|
err.llmTerminal = true;
|
|
5690
5706
|
throw err;
|
|
5691
5707
|
}
|
|
5708
|
+
const contentType = response.headers?.get?.("content-type") ?? "";
|
|
5709
|
+
this.debug?.("LLM stream response headers", {
|
|
5710
|
+
status: response.status,
|
|
5711
|
+
contentType
|
|
5712
|
+
});
|
|
5692
5713
|
const reader = response.body?.getReader();
|
|
5693
5714
|
if (!reader) {
|
|
5694
5715
|
cleanup();
|
|
@@ -5698,6 +5719,10 @@ class OpenAICompatProvider {
|
|
|
5698
5719
|
let buffer = "";
|
|
5699
5720
|
const toolCallAccs = new Map;
|
|
5700
5721
|
let sawToolCallStart = false;
|
|
5722
|
+
let nonDataLines = 0;
|
|
5723
|
+
const nonDataSamples = [];
|
|
5724
|
+
let parsedChunks = 0;
|
|
5725
|
+
let midStreamError = null;
|
|
5701
5726
|
let usage;
|
|
5702
5727
|
let sawDone = false;
|
|
5703
5728
|
let lastFinishReason;
|
|
@@ -5732,15 +5757,24 @@ class OpenAICompatProvider {
|
|
|
5732
5757
|
buffer = lines.pop() || "";
|
|
5733
5758
|
for (const line of lines) {
|
|
5734
5759
|
const trimmed = line.trim();
|
|
5735
|
-
if (!trimmed
|
|
5736
|
-
continue;
|
|
5737
|
-
const data = trimmed.slice(6);
|
|
5738
|
-
if (data === "[DONE]") {
|
|
5739
|
-
sawDone = true;
|
|
5760
|
+
if (!trimmed)
|
|
5740
5761
|
continue;
|
|
5762
|
+
let data;
|
|
5763
|
+
if (trimmed.startsWith("data: ")) {
|
|
5764
|
+
data = trimmed.slice(6);
|
|
5765
|
+
if (data === "[DONE]") {
|
|
5766
|
+
sawDone = true;
|
|
5767
|
+
continue;
|
|
5768
|
+
}
|
|
5769
|
+
} else {
|
|
5770
|
+
nonDataLines++;
|
|
5771
|
+
if (nonDataSamples.length < 5)
|
|
5772
|
+
nonDataSamples.push(trimmed.slice(0, 200));
|
|
5773
|
+
data = trimmed;
|
|
5741
5774
|
}
|
|
5742
5775
|
try {
|
|
5743
5776
|
const parsed = JSON.parse(data);
|
|
5777
|
+
parsedChunks++;
|
|
5744
5778
|
const choice = parsed.choices?.[0];
|
|
5745
5779
|
if (!choice) {
|
|
5746
5780
|
if (parsed.usage) {
|
|
@@ -5749,56 +5783,71 @@ class OpenAICompatProvider {
|
|
|
5749
5783
|
completionTokens: parsed.usage.completion_tokens ?? 0,
|
|
5750
5784
|
totalTokens: parsed.usage.total_tokens ?? 0
|
|
5751
5785
|
};
|
|
5786
|
+
this.debug?.("LLM stream usage", { ...usage });
|
|
5787
|
+
} else if (parsed.error) {
|
|
5788
|
+
midStreamError = String(parsed.error);
|
|
5752
5789
|
}
|
|
5753
|
-
|
|
5754
|
-
|
|
5755
|
-
|
|
5756
|
-
|
|
5757
|
-
|
|
5758
|
-
|
|
5759
|
-
|
|
5760
|
-
|
|
5761
|
-
|
|
5762
|
-
|
|
5763
|
-
|
|
5764
|
-
|
|
5765
|
-
|
|
5766
|
-
|
|
5767
|
-
|
|
5768
|
-
|
|
5769
|
-
}
|
|
5770
|
-
|
|
5771
|
-
|
|
5772
|
-
|
|
5773
|
-
|
|
5774
|
-
|
|
5775
|
-
|
|
5776
|
-
|
|
5790
|
+
} else {
|
|
5791
|
+
if (parsedChunks <= 3 || parsedChunks % 50 === 0) {
|
|
5792
|
+
const d = choice.delta ?? {};
|
|
5793
|
+
this.debug?.("LLM stream chunk", {
|
|
5794
|
+
n: parsedChunks,
|
|
5795
|
+
finishReason: choice.finish_reason ?? null,
|
|
5796
|
+
deltaKeys: Object.keys(d)
|
|
5797
|
+
});
|
|
5798
|
+
}
|
|
5799
|
+
const delta = choice.delta || {};
|
|
5800
|
+
const finishReason = choice.finish_reason;
|
|
5801
|
+
if (finishReason)
|
|
5802
|
+
lastFinishReason = finishReason;
|
|
5803
|
+
const reasoningDelta = delta.reasoning_content ?? delta.reasoning;
|
|
5804
|
+
if (reasoningDelta) {
|
|
5805
|
+
onEmit();
|
|
5806
|
+
yield { type: "reasoning", content: reasoningDelta };
|
|
5807
|
+
}
|
|
5808
|
+
if (delta.tool_calls) {
|
|
5809
|
+
sawToolCallStart = true;
|
|
5810
|
+
for (const tc of delta.tool_calls) {
|
|
5811
|
+
const idx = tc.index ?? 0;
|
|
5812
|
+
if (!toolCallAccs.has(idx)) {
|
|
5813
|
+
toolCallAccs.set(idx, { id: "", name: "", arguments: "" });
|
|
5814
|
+
}
|
|
5815
|
+
const acc = toolCallAccs.get(idx);
|
|
5816
|
+
if (tc.id)
|
|
5817
|
+
acc.id = tc.id;
|
|
5818
|
+
if (tc.function?.name)
|
|
5819
|
+
acc.name = tc.function.name;
|
|
5820
|
+
if (tc.function?.arguments) {
|
|
5821
|
+
acc.arguments += tc.function.arguments;
|
|
5822
|
+
}
|
|
5777
5823
|
}
|
|
5778
5824
|
}
|
|
5779
|
-
|
|
5780
|
-
|
|
5781
|
-
|
|
5782
|
-
|
|
5783
|
-
|
|
5784
|
-
|
|
5785
|
-
|
|
5786
|
-
|
|
5787
|
-
|
|
5788
|
-
|
|
5789
|
-
|
|
5790
|
-
|
|
5791
|
-
|
|
5792
|
-
|
|
5793
|
-
|
|
5794
|
-
|
|
5795
|
-
}
|
|
5796
|
-
}
|
|
5825
|
+
if (delta.content) {
|
|
5826
|
+
onEmit();
|
|
5827
|
+
sawText = true;
|
|
5828
|
+
yield { type: "text", content: delta.content };
|
|
5829
|
+
}
|
|
5830
|
+
if (finishReason === "tool_calls" && toolCallAccs.size > 0) {
|
|
5831
|
+
for (const [, acc] of toolCallAccs) {
|
|
5832
|
+
if (acc.name) {
|
|
5833
|
+
onEmit();
|
|
5834
|
+
yield {
|
|
5835
|
+
type: "tool_call",
|
|
5836
|
+
toolCall: {
|
|
5837
|
+
id: acc.id,
|
|
5838
|
+
name: acc.name,
|
|
5839
|
+
arguments: acc.arguments || "{}"
|
|
5840
|
+
}
|
|
5841
|
+
};
|
|
5842
|
+
}
|
|
5797
5843
|
}
|
|
5844
|
+
toolCallAccs.clear();
|
|
5798
5845
|
}
|
|
5799
|
-
toolCallAccs.clear();
|
|
5800
5846
|
}
|
|
5801
5847
|
} catch {}
|
|
5848
|
+
if (midStreamError) {
|
|
5849
|
+
throw new Error(t("error.llm_provider_stream_error", { error: midStreamError.slice(0, 300) }));
|
|
5850
|
+
}
|
|
5802
5851
|
}
|
|
5803
5852
|
}
|
|
5804
5853
|
if (usage) {
|
|
@@ -5819,6 +5868,15 @@ class OpenAICompatProvider {
|
|
|
5819
5868
|
} finally {
|
|
5820
5869
|
cleanup();
|
|
5821
5870
|
reader.releaseLock();
|
|
5871
|
+
this.debug?.("LLM stream finished", {
|
|
5872
|
+
sawDone,
|
|
5873
|
+
lastFinishReason: lastFinishReason ?? null,
|
|
5874
|
+
sawText,
|
|
5875
|
+
sawToolCallStart,
|
|
5876
|
+
parsedChunks,
|
|
5877
|
+
nonDataLines,
|
|
5878
|
+
nonDataSamples: nonDataLines > 0 ? nonDataSamples : undefined
|
|
5879
|
+
});
|
|
5822
5880
|
}
|
|
5823
5881
|
return sawDone;
|
|
5824
5882
|
}
|
|
@@ -5885,14 +5943,18 @@ class OpenAICompatProvider {
|
|
|
5885
5943
|
}));
|
|
5886
5944
|
}
|
|
5887
5945
|
const data = await response.json();
|
|
5946
|
+
if (data.error && !data.choices) {
|
|
5947
|
+
throw new Error(t("error.llm_provider_stream_error", { error: String(data.error).slice(0, 300) }));
|
|
5948
|
+
}
|
|
5888
5949
|
const choice = data.choices?.[0];
|
|
5889
5950
|
if (!choice) {
|
|
5890
5951
|
return [];
|
|
5891
5952
|
}
|
|
5892
5953
|
const msg = choice.message || {};
|
|
5893
5954
|
const chunks = [];
|
|
5894
|
-
|
|
5895
|
-
|
|
5955
|
+
const reasoning = msg.reasoning_content ?? msg.reasoning;
|
|
5956
|
+
if (reasoning) {
|
|
5957
|
+
chunks.push({ type: "reasoning", content: reasoning });
|
|
5896
5958
|
}
|
|
5897
5959
|
if (msg.content) {
|
|
5898
5960
|
chunks.push({ type: "text", content: msg.content });
|
|
@@ -6036,7 +6098,8 @@ function openaiCompat(opts) {
|
|
|
6036
6098
|
contextWindow: opts.contextWindow,
|
|
6037
6099
|
retry,
|
|
6038
6100
|
rateLimits,
|
|
6039
|
-
maxCompletionTokens: opts.maxCompletionTokens
|
|
6101
|
+
maxCompletionTokens: opts.maxCompletionTokens,
|
|
6102
|
+
logger: opts.logger
|
|
6040
6103
|
});
|
|
6041
6104
|
}
|
|
6042
6105
|
var OPENAI_COMPAT, OPENROUTER, OPENAI, ANTHROPIC, OPENCODE_ZEN, OPENCODE_GO, BUILTIN_PROVIDERS, HOSTED_BASE_URLS;
|
|
@@ -6290,7 +6353,8 @@ class ProviderManager {
|
|
|
6290
6353
|
contextWindow: entry.contextWindow ?? this.opts.contextWindow,
|
|
6291
6354
|
retry: entry.retry ?? this.opts.retry,
|
|
6292
6355
|
rateLimits: entry.rateLimits ?? this.opts.rateLimits,
|
|
6293
|
-
maxCompletionTokens: entry.maxCompletionTokens
|
|
6356
|
+
maxCompletionTokens: entry.maxCompletionTokens,
|
|
6357
|
+
logger: this.opts.logger
|
|
6294
6358
|
}, this.registry);
|
|
6295
6359
|
this.cache.set(key, provider);
|
|
6296
6360
|
return provider;
|
|
@@ -13644,7 +13708,8 @@ ${warnLine}
|
|
|
13644
13708
|
const manager = new ProviderManager(this.deps.config.provider, {
|
|
13645
13709
|
contextWindow: this.deps.config.contextWindow,
|
|
13646
13710
|
retry: this.deps.config.retry,
|
|
13647
|
-
rateLimits: this.deps.config.security?.rateLimits
|
|
13711
|
+
rateLimits: this.deps.config.security?.rateLimits,
|
|
13712
|
+
logger: this.deps.logger
|
|
13648
13713
|
});
|
|
13649
13714
|
manager.switch(name, model);
|
|
13650
13715
|
const providerCfg = manager.toConfig();
|
|
@@ -13670,7 +13735,8 @@ ${warnLine}
|
|
|
13670
13735
|
const manager = new ProviderManager(this.deps.config.provider, {
|
|
13671
13736
|
contextWindow: this.deps.config.contextWindow,
|
|
13672
13737
|
retry: this.deps.config.retry,
|
|
13673
|
-
rateLimits: this.deps.config.security?.rateLimits
|
|
13738
|
+
rateLimits: this.deps.config.security?.rateLimits,
|
|
13739
|
+
logger: this.deps.logger
|
|
13674
13740
|
});
|
|
13675
13741
|
manager.setModel(this.deps.config.model);
|
|
13676
13742
|
manager.switch(name);
|
|
@@ -23746,7 +23812,8 @@ async function bootstrap(configDir, projectDir, noAgentsMd, exitOnComplete, reas
|
|
|
23746
23812
|
const providerManager = new ProviderManager(config.provider, {
|
|
23747
23813
|
contextWindow: config.contextWindow,
|
|
23748
23814
|
retry: config.retry,
|
|
23749
|
-
rateLimits: config.security?.rateLimits
|
|
23815
|
+
rateLimits: config.security?.rateLimits,
|
|
23816
|
+
logger
|
|
23750
23817
|
});
|
|
23751
23818
|
providerManager.setModel(config.model);
|
|
23752
23819
|
let llmProvider = providerManager.active;
|