muonroi-cli 1.7.2 → 1.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/LICENSE +21 -21
- package/README.md +122 -122
- package/dist/packages/agent-harness-core/src/event-filter.js +1 -0
- package/dist/packages/agent-harness-core/src/event-redact.js +8 -0
- package/dist/packages/agent-harness-core/src/mcp-server.d.ts +16 -0
- package/dist/packages/agent-harness-core/src/mcp-server.js +88 -10
- package/dist/packages/agent-harness-core/src/protocol.d.ts +15 -0
- package/dist/packages/agent-harness-core/src/selector.js +2 -2
- package/dist/packages/agent-harness-core/src/transports/sidechannel.js +1 -1
- package/dist/packages/agent-harness-opentui/src/agent-mode.js +1 -1
- package/dist/packages/agent-harness-opentui/src/install.js +1 -1
- package/dist/src/__test-stubs__/vitest-setup.js +4 -0
- package/dist/src/agent-harness/__tests__/mock-model.spec.js +54 -0
- package/dist/src/agent-harness/mock-model.d.ts +1 -1
- package/dist/src/agent-harness/mock-model.js +32 -3
- package/dist/src/agent-harness/test-spawn.js +3 -1
- package/dist/src/chat/chat-keychain.js +9 -1
- package/dist/src/cli/cost-forensics.js +12 -12
- package/dist/src/cli/keys.d.ts +2 -2
- package/dist/src/cli/keys.js +107 -28
- package/dist/src/cli/usage-report.js +2 -2
- package/dist/src/council/__tests__/abort-threading.test.d.ts +1 -0
- package/dist/src/council/__tests__/abort-threading.test.js +193 -0
- package/dist/src/council/__tests__/clarification-prompt.test.js +21 -1
- package/dist/src/council/__tests__/council-turn-length-emit.test.d.ts +1 -0
- package/dist/src/council/__tests__/council-turn-length-emit.test.js +130 -0
- package/dist/src/council/__tests__/debate-round-budget.test.d.ts +1 -0
- package/dist/src/council/__tests__/debate-round-budget.test.js +45 -0
- package/dist/src/council/__tests__/evaluator-metrics.test.js +3 -0
- package/dist/src/council/__tests__/post-debate-recommendation.test.d.ts +1 -0
- package/dist/src/council/__tests__/post-debate-recommendation.test.js +58 -0
- package/dist/src/council/__tests__/research-tools.test.js +4 -0
- package/dist/src/council/__tests__/round-tools.test.js +6 -0
- package/dist/src/council/clarifier-question-cap.test.d.ts +12 -0
- package/dist/src/council/clarifier-question-cap.test.js +73 -0
- package/dist/src/council/clarifier.d.ts +29 -1
- package/dist/src/council/clarifier.js +64 -1
- package/dist/src/council/debate-planner.d.ts +2 -1
- package/dist/src/council/debate-planner.js +5 -3
- package/dist/src/council/debate.d.ts +9 -0
- package/dist/src/council/debate.js +88 -8
- package/dist/src/council/index.d.ts +46 -1
- package/dist/src/council/index.js +125 -19
- package/dist/src/council/llm.js +41 -13
- package/dist/src/council/prompts.js +56 -21
- package/dist/src/council/types.d.ts +14 -1
- package/dist/src/ee/__tests__/export-transcripts.test.js +1 -1
- package/dist/src/ee/bridge.d.ts +3 -1
- package/dist/src/ee/bridge.js +9 -3
- package/dist/src/ee/bridge.test.js +1 -2
- package/dist/src/ee/client.js +15 -2
- package/dist/src/ee/recall-ledger.d.ts +20 -0
- package/dist/src/ee/recall-ledger.js +40 -1
- package/dist/src/ee/search.d.ts +25 -0
- package/dist/src/ee/search.js +73 -0
- package/dist/src/ee/types.d.ts +15 -1
- package/dist/src/ee/who-am-i.d.ts +41 -0
- package/dist/src/ee/who-am-i.js +143 -0
- package/dist/src/ee/who-am-i.test.d.ts +1 -0
- package/dist/src/ee/who-am-i.test.js +101 -0
- package/dist/src/generated/version.d.ts +1 -1
- package/dist/src/generated/version.js +1 -1
- package/dist/src/headless/council-answers.js +1 -0
- package/dist/src/headless/output.d.ts +30 -1
- package/dist/src/headless/output.js +180 -0
- package/dist/src/headless/output.test.js +61 -1
- package/dist/src/hooks/index.js +48 -2
- package/dist/src/index.d.ts +2 -0
- package/dist/src/index.js +55 -60
- package/dist/src/lsp/client-normalize.test.d.ts +12 -0
- package/dist/src/lsp/client-normalize.test.js +34 -0
- package/dist/src/lsp/client.d.ts +1 -0
- package/dist/src/lsp/client.js +10 -2
- package/dist/src/lsp/manager.d.ts +1 -1
- package/dist/src/lsp/manager.js +2 -2
- package/dist/src/lsp/manager.test.js +2 -2
- package/dist/src/lsp/runtime.d.ts +1 -1
- package/dist/src/lsp/runtime.js +2 -2
- package/dist/src/maintain/__tests__/gh-create-pr.test.js +7 -3
- package/dist/src/maintain/__tests__/pr-builder.test.js +7 -3
- package/dist/src/mcp/__tests__/client-pool.spec.js +3 -3
- package/dist/src/mcp/__tests__/ee-tools.test.js +42 -14
- package/dist/src/mcp/__tests__/forensics-tools.test.js +3 -3
- package/dist/src/mcp/__tests__/lsp-tools.test.js +4 -4
- package/dist/src/mcp/client-pool.d.ts +1 -1
- package/dist/src/mcp/client-pool.js +25 -9
- package/dist/src/mcp/ee-tools.d.ts +10 -0
- package/dist/src/mcp/ee-tools.js +34 -0
- package/dist/src/mcp/oauth-callback.js +2 -2
- package/dist/src/mcp/parse-headers.test.js +14 -14
- package/dist/src/mcp/self-verify-jobs.js +1 -3
- package/dist/src/mcp/setup-guide-text.js +74 -74
- package/dist/src/mcp/smoke.test.js +43 -43
- package/dist/src/models/catalog-gemini.test.js +12 -10
- package/dist/src/models/catalog.json +106 -38
- package/dist/src/ops/doctor.js +7 -7
- package/dist/src/orchestrator/__tests__/auto-commit.test.d.ts +1 -0
- package/dist/src/orchestrator/__tests__/auto-commit.test.js +142 -0
- package/dist/src/orchestrator/__tests__/batch-turn-runner.test.js +2 -0
- package/dist/src/orchestrator/__tests__/delegations.test.d.ts +1 -0
- package/dist/src/orchestrator/__tests__/delegations.test.js +96 -0
- package/dist/src/orchestrator/__tests__/message-processor.test.js +1 -0
- package/dist/src/orchestrator/__tests__/stream-runner.test.js +29 -0
- package/dist/src/orchestrator/agent.test.js +5 -2
- package/dist/src/orchestrator/auto-commit.d.ts +110 -0
- package/dist/src/orchestrator/auto-commit.js +364 -0
- package/dist/src/orchestrator/batch-turn-runner.d.ts +3 -2
- package/dist/src/orchestrator/batch-turn-runner.js +2 -1
- package/dist/src/orchestrator/compaction-proposer-prompt.d.ts +8 -0
- package/dist/src/orchestrator/compaction-proposer-prompt.js +43 -0
- package/dist/src/orchestrator/compaction.d.ts +22 -0
- package/dist/src/orchestrator/compaction.js +42 -0
- package/dist/src/orchestrator/delegations.d.ts +1 -0
- package/dist/src/orchestrator/delegations.js +41 -0
- package/dist/src/orchestrator/error-utils.js +27 -2
- package/dist/src/orchestrator/message-processor.d.ts +21 -5
- package/dist/src/orchestrator/message-processor.js +219 -2573
- package/dist/src/orchestrator/orchestrator.d.ts +8 -2
- package/dist/src/orchestrator/orchestrator.js +187 -34
- package/dist/src/orchestrator/preprocessor.d.ts +13 -0
- package/dist/src/orchestrator/preprocessor.js +145 -0
- package/dist/src/orchestrator/prompts.d.ts +8 -0
- package/dist/src/orchestrator/prompts.js +76 -60
- package/dist/src/orchestrator/safety-askcard.d.ts +66 -0
- package/dist/src/orchestrator/safety-askcard.js +74 -0
- package/dist/src/orchestrator/sandbox.test.js +8 -5
- package/dist/src/orchestrator/scope-ceiling.js +1 -1
- package/dist/src/orchestrator/stall-watchdog.d.ts +47 -0
- package/dist/src/orchestrator/stall-watchdog.js +23 -0
- package/dist/src/orchestrator/stall-watchdog.test.js +36 -1
- package/dist/src/orchestrator/stream-runner.js +52 -30
- package/dist/src/orchestrator/sub-agent-model-tier.js +1 -1
- package/dist/src/orchestrator/subagent-compactor.d.ts +14 -0
- package/dist/src/orchestrator/subagent-compactor.js +83 -10
- package/dist/src/orchestrator/subagent-compactor.spec.js +132 -0
- package/dist/src/orchestrator/text-tool-call-detector.d.ts +9 -5
- package/dist/src/orchestrator/text-tool-call-detector.js +16 -12
- package/dist/src/orchestrator/text-tool-call-detector.test.js +66 -8
- package/dist/src/orchestrator/tool-args-repair.js +1 -1
- package/dist/src/orchestrator/tool-engine.d.ts +151 -0
- package/dist/src/orchestrator/tool-engine.js +3079 -0
- package/dist/src/orchestrator/turn-runner-deps.d.ts +1 -0
- package/dist/src/pil/__tests__/discovery-types.test.js +15 -4
- package/dist/src/pil/__tests__/discovery.test.js +89 -145
- package/dist/src/pil/__tests__/dual-run.test.js +2 -0
- package/dist/src/pil/__tests__/layer1-intent-trace.test.js +3 -0
- package/dist/src/pil/__tests__/layer1-intent.test.js +3 -0
- package/dist/src/pil/__tests__/layer16-clarity.test.js +35 -32
- package/dist/src/pil/__tests__/layer18-acceptance.test.js +1 -78
- package/dist/src/pil/__tests__/layer2_5-ponytail.test.d.ts +1 -0
- package/dist/src/pil/__tests__/layer2_5-ponytail.test.js +53 -0
- package/dist/src/pil/__tests__/layer3-ee-injection.test.js +67 -4
- package/dist/src/pil/__tests__/layer3-injected-chunk.test.js +14 -2
- package/dist/src/pil/__tests__/layer4-gsd.test.js +30 -0
- package/dist/src/pil/__tests__/layer5-context.test.js +39 -1
- package/dist/src/pil/__tests__/layer6-output.test.js +30 -2
- package/dist/src/pil/__tests__/orchestrator-integration.test.js +3 -1
- package/dist/src/pil/__tests__/pipeline.test.js +11 -8
- package/dist/src/pil/__tests__/response-tools.test.js +52 -0
- package/dist/src/pil/agent-operating-contract.d.ts +1 -1
- package/dist/src/pil/agent-operating-contract.js +5 -3
- package/dist/src/pil/agent-operating-contract.test.js +2 -2
- package/dist/src/pil/cheap-model-playbook.d.ts +1 -1
- package/dist/src/pil/cheap-model-playbook.js +1 -1
- package/dist/src/pil/cheap-model-workbooks.d.ts +1 -1
- package/dist/src/pil/cheap-model-workbooks.js +1 -1
- package/dist/src/pil/config.d.ts +20 -0
- package/dist/src/pil/config.js +35 -0
- package/dist/src/pil/discovery-types.d.ts +32 -9
- package/dist/src/pil/discovery.d.ts +3 -3
- package/dist/src/pil/discovery.js +138 -244
- package/dist/src/pil/index.d.ts +1 -1
- package/dist/src/pil/index.js +1 -1
- package/dist/src/pil/layer1-intent.d.ts +9 -1
- package/dist/src/pil/layer1-intent.js +99 -44
- package/dist/src/pil/layer1-intent.test.js +112 -2
- package/dist/src/pil/layer15-context-scan.js +1 -1
- package/dist/src/pil/layer16-clarity.d.ts +21 -25
- package/dist/src/pil/layer16-clarity.js +52 -88
- package/dist/src/pil/layer18-acceptance.d.ts +13 -3
- package/dist/src/pil/layer18-acceptance.js +1 -75
- package/dist/src/pil/layer2-personality.js +7 -8
- package/dist/src/pil/layer2_5-ponytail.d.ts +2 -0
- package/dist/src/pil/layer2_5-ponytail.js +41 -0
- package/dist/src/pil/layer3-ee-injection.js +180 -14
- package/dist/src/pil/layer4-gsd.js +22 -8
- package/dist/src/pil/layer5-context.d.ts +1 -0
- package/dist/src/pil/layer5-context.js +26 -11
- package/dist/src/pil/layer6-output.js +23 -5
- package/dist/src/pil/llm-classify.js +3 -3
- package/dist/src/pil/native-capabilities-workbook.d.ts +1 -1
- package/dist/src/pil/native-capabilities-workbook.js +4 -3
- package/dist/src/pil/pipeline.js +15 -1
- package/dist/src/pil/response-tools.d.ts +16 -0
- package/dist/src/pil/response-tools.js +41 -0
- package/dist/src/pil/schema.d.ts +8 -0
- package/dist/src/pil/schema.js +24 -3
- package/dist/src/pil/task-tier-map.js +7 -7
- package/dist/src/pil/types.d.ts +9 -3
- package/dist/src/product-loop/__tests__/discovery-interview.test.js +103 -1
- package/dist/src/product-loop/__tests__/gather-selectable-alts.test.js +34 -0
- package/dist/src/product-loop/__tests__/sprint-self-verify.test.js +12 -12
- package/dist/src/product-loop/discovery-interview.d.ts +20 -0
- package/dist/src/product-loop/discovery-interview.js +121 -7
- package/dist/src/product-loop/done-gate.js +3 -3
- package/dist/src/product-loop/gather.js +19 -5
- package/dist/src/product-loop/loop-driver.js +20 -20
- package/dist/src/product-loop/progress-snapshot.js +4 -4
- package/dist/src/product-loop/sprint-self-verify.js +2 -2
- package/dist/src/providers/__tests__/reasoning-roundtrip.test.js +12 -0
- package/dist/src/providers/auth/__tests__/gemini-oauth.test.d.ts +1 -5
- package/dist/src/providers/auth/__tests__/gemini-oauth.test.js +1 -5
- package/dist/src/providers/auth/gcloud.d.ts +28 -0
- package/dist/src/providers/auth/gcloud.js +102 -0
- package/dist/src/providers/auth/gemini-oauth.d.ts +46 -19
- package/dist/src/providers/auth/gemini-oauth.js +292 -105
- package/dist/src/providers/auth/grok-oauth.d.ts +1 -1
- package/dist/src/providers/auth/grok-oauth.js +1 -1
- package/dist/src/providers/auth/registry.js +28 -6
- package/dist/src/providers/gemini.d.ts +1 -1
- package/dist/src/providers/gemini.js +10 -3
- package/dist/src/providers/keychain.d.ts +2 -2
- package/dist/src/providers/keychain.js +20 -2
- package/dist/src/providers/mcp-vision-bridge.js +48 -48
- package/dist/src/providers/openai.js +5 -1
- package/dist/src/providers/runtime.d.ts +1 -1
- package/dist/src/providers/runtime.js +11 -2
- package/dist/src/providers/siliconflow-sse-repair.js +1 -1
- package/dist/src/providers/strategies/google.strategy.d.ts +9 -2
- package/dist/src/providers/strategies/google.strategy.js +159 -9
- package/dist/src/providers/strategies/thinking-mode.js +19 -6
- package/dist/src/providers/types.d.ts +1 -1
- package/dist/src/reporter/index.js +1 -1
- package/dist/src/router/decide.test.js +40 -8
- package/dist/src/router/step-router.d.ts +20 -0
- package/dist/src/router/step-router.js +73 -0
- package/dist/src/scaffold/bb-ecosystem-apply.js +47 -47
- package/dist/src/scaffold/bb-quality-gate.js +5 -5
- package/dist/src/scaffold/continuation-prompt.js +60 -60
- package/dist/src/scaffold/init-new.js +453 -453
- package/dist/src/self-qa/__tests__/scenario-planner.test.js +3 -3
- package/dist/src/self-qa/agentic-loop.js +19 -19
- package/dist/src/self-qa/orchestrator.js +5 -5
- package/dist/src/self-qa/scenario-planner.js +1 -1
- package/dist/src/self-qa/spec-emitter.js +4 -4
- package/dist/src/storage/__tests__/migrations.test.js +2 -2
- package/dist/src/storage/index.d.ts +1 -1
- package/dist/src/storage/index.js +1 -1
- package/dist/src/storage/interaction-log.js +5 -5
- package/dist/src/storage/migrations.js +122 -122
- package/dist/src/storage/session-experience-store.js +4 -4
- package/dist/src/storage/sessions.js +43 -43
- package/dist/src/storage/transcript-view.js +7 -1
- package/dist/src/storage/transcript.d.ts +1 -0
- package/dist/src/storage/transcript.js +55 -0
- package/dist/src/storage/ui-interaction-log.d.ts +17 -0
- package/dist/src/storage/usage.js +14 -14
- package/dist/src/storage/workspaces.js +12 -12
- package/dist/src/tools/__tests__/native-tools.test.js +6 -0
- package/dist/src/tools/bash.d.ts +36 -23
- package/dist/src/tools/bash.js +59 -301
- package/dist/src/tools/bash.test.js +2 -257
- package/dist/src/tools/file-tracker.d.ts +5 -0
- package/dist/src/tools/file-tracker.js +14 -0
- package/dist/src/tools/file.js +2 -0
- package/dist/src/tools/git-safety.d.ts +38 -1
- package/dist/src/tools/git-safety.js +94 -4
- package/dist/src/tools/git-safety.test.js +45 -1
- package/dist/src/tools/native-tools.d.ts +1 -1
- package/dist/src/tools/native-tools.js +56 -0
- package/dist/src/tools/registry-bash-empty-command.test.js +4 -3
- package/dist/src/tools/registry-git-safety.test.js +17 -6
- package/dist/src/tools/registry.d.ts +5 -0
- package/dist/src/tools/registry.js +185 -11
- package/dist/src/types/index.d.ts +7 -1
- package/dist/src/ui/app.d.ts +1 -0
- package/dist/src/ui/app.js +0 -0
- package/dist/src/ui/components/council-question-card.js +1 -0
- package/dist/src/ui/components/message-view.js +37 -3
- package/dist/src/ui/components/structured-response-view.js +7 -0
- package/dist/src/ui/components/task-list-panel.js +3 -12
- package/dist/src/ui/containers/chat-feed.d.ts +40 -0
- package/dist/src/ui/containers/chat-feed.js +66 -0
- package/dist/src/ui/containers/modals-layer.d.ts +87 -0
- package/dist/src/ui/containers/modals-layer.js +18 -0
- package/dist/src/ui/slash/__tests__/menu-parity.test.d.ts +1 -0
- package/dist/src/ui/slash/__tests__/menu-parity.test.js +1 -0
- package/dist/src/ui/slash/__tests__/ponytail.test.d.ts +1 -0
- package/dist/src/ui/slash/__tests__/ponytail.test.js +37 -0
- package/dist/src/ui/slash/council-inspect.js +4 -4
- package/dist/src/ui/slash/export.js +16 -1
- package/dist/src/ui/slash/menu-items.js +1 -0
- package/dist/src/ui/slash/ponytail.d.ts +2 -0
- package/dist/src/ui/slash/ponytail.js +19 -0
- package/dist/src/ui/status-bar/store.js +0 -1
- package/dist/src/ui/status-bar/store.test.js +2 -2
- package/dist/src/ui/use-app-logic.d.ts +26 -0
- package/dist/src/ui/use-app-logic.js +0 -0
- package/dist/src/ui/utils/relaunch.js +1 -1
- package/dist/src/ui/utils/text.d.ts +11 -0
- package/dist/src/ui/utils/text.js +21 -1
- package/dist/src/ui/utils/text.test.js +25 -1
- package/dist/src/ui/utils/tools.js +3 -1
- package/dist/src/usage/cost-log.js +2 -2
- package/dist/src/usage/estimator.d.ts +14 -0
- package/dist/src/usage/estimator.js +22 -0
- package/dist/src/utils/__tests__/compaction-caps.test.d.ts +21 -0
- package/dist/src/utils/__tests__/compaction-caps.test.js +187 -0
- package/dist/src/utils/__tests__/llm-deadline-abort.test.d.ts +1 -0
- package/dist/src/utils/__tests__/llm-deadline-abort.test.js +33 -0
- package/dist/src/utils/clipboard-image.js +23 -23
- package/dist/src/utils/llm-deadline.d.ts +9 -1
- package/dist/src/utils/llm-deadline.js +31 -2
- package/dist/src/utils/permission-mode.d.ts +33 -0
- package/dist/src/utils/permission-mode.js +164 -3
- package/dist/src/utils/permission-mode.test.js +92 -1
- package/dist/src/utils/settings.d.ts +27 -31
- package/dist/src/utils/settings.js +100 -109
- package/dist/src/utils/side-question.js +2 -2
- package/dist/src/utils/skills.js +3 -3
- package/dist/src/verify/__tests__/coverage-parsers.test.js +30 -30
- package/package.json +1 -1
|
@@ -107,6 +107,47 @@ export class DelegationManager {
|
|
|
107
107
|
return `Delegation "${id}" completed, but its saved output could not be read.`;
|
|
108
108
|
}
|
|
109
109
|
}
|
|
110
|
+
async kill(id) {
|
|
111
|
+
const record = await this.getById(id);
|
|
112
|
+
if (!record) {
|
|
113
|
+
return {
|
|
114
|
+
success: false,
|
|
115
|
+
output: `Delegation "${id}" not found.`,
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
if (record.status !== "running") {
|
|
119
|
+
return {
|
|
120
|
+
success: false,
|
|
121
|
+
output: `Delegation "${id}" is not running (status: ${record.status}).`,
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
const pid = record.pid;
|
|
125
|
+
if (!pid) {
|
|
126
|
+
const jobPath = path.join(await ensureDelegationsDir(this.getCwd()), `${id}.json`);
|
|
127
|
+
await failDelegation(jobPath, "Cancelled: Process PID was not recorded.");
|
|
128
|
+
return {
|
|
129
|
+
success: true,
|
|
130
|
+
output: `Delegation "${id}" marked as cancelled (no active process ID was found).`,
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
try {
|
|
134
|
+
if (process.platform === "win32") {
|
|
135
|
+
spawn("taskkill", ["/F", "/T", "/PID", pid.toString()]).unref();
|
|
136
|
+
}
|
|
137
|
+
else {
|
|
138
|
+
process.kill(pid, "SIGTERM");
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
catch (err) {
|
|
142
|
+
// ignore
|
|
143
|
+
}
|
|
144
|
+
const jobPath = path.join(await ensureDelegationsDir(this.getCwd()), `${id}.json`);
|
|
145
|
+
await failDelegation(jobPath, "Cancelled by user.");
|
|
146
|
+
return {
|
|
147
|
+
success: true,
|
|
148
|
+
output: `Delegation "${id}" (PID: ${pid}) has been terminated.`,
|
|
149
|
+
};
|
|
150
|
+
}
|
|
110
151
|
async consumeNotifications() {
|
|
111
152
|
const dir = await ensureDelegationsDir(this.getCwd());
|
|
112
153
|
const files = await readDelegationFiles(dir);
|
|
@@ -67,10 +67,24 @@ function humanizeApiErrorBase(error) {
|
|
|
67
67
|
}
|
|
68
68
|
if (APICallError.isInstance(error)) {
|
|
69
69
|
const detail = extractResponseDetail(error.responseBody);
|
|
70
|
+
const status = error.statusCode;
|
|
71
|
+
// 5xx response bodies are usually generic server-side noise that MASKS the
|
|
72
|
+
// actionable status. Verified live: SiliconFlow returns a 500 with body
|
|
73
|
+
// {code:60000,message:"Request failed: Unknown error."} — surfacing that
|
|
74
|
+
// string told the user nothing and hid the fact it was a retryable 500.
|
|
75
|
+
// For 5xx prefer the canned "retry later" message + the status code; keep a
|
|
76
|
+
// body detail only when it actually adds information.
|
|
77
|
+
if (status && status >= 500) {
|
|
78
|
+
const canned = STATUS_MESSAGES[status] ?? "The API server returned an error. Please try again later.";
|
|
79
|
+
if (!detail || isOpaqueDetail(detail))
|
|
80
|
+
return `${canned} (HTTP ${status})`;
|
|
81
|
+
return `${detail} (HTTP ${status})`;
|
|
82
|
+
}
|
|
83
|
+
// 4xx: the body almost always says WHAT was wrong — keep it verbatim.
|
|
70
84
|
if (detail)
|
|
71
85
|
return detail;
|
|
72
|
-
if (
|
|
73
|
-
return STATUS_MESSAGES[
|
|
86
|
+
if (status && STATUS_MESSAGES[status]) {
|
|
87
|
+
return STATUS_MESSAGES[status];
|
|
74
88
|
}
|
|
75
89
|
}
|
|
76
90
|
const raw = error instanceof Error ? error.message : String(error);
|
|
@@ -99,6 +113,17 @@ function extractResponseDetail(body) {
|
|
|
99
113
|
}
|
|
100
114
|
return null;
|
|
101
115
|
}
|
|
116
|
+
/**
|
|
117
|
+
* A provider "detail" string that carries no diagnostic value — generic
|
|
118
|
+
* server-error phrasing that masks the more useful HTTP status. Verified live:
|
|
119
|
+
* SiliconFlow 500s carry message "Request failed: Unknown error.". Used only on
|
|
120
|
+
* the 5xx path so an informative server message is still preferred when present.
|
|
121
|
+
*/
|
|
122
|
+
function isOpaqueDetail(detail) {
|
|
123
|
+
const s = detail.trim().toLowerCase();
|
|
124
|
+
return (s.length < 4 ||
|
|
125
|
+
/unknown error|request failed|internal server error|service (unavailable|temporarily)|bad gateway|gateway time-?out|^error\.?$|^failed\.?$/.test(s));
|
|
126
|
+
}
|
|
102
127
|
const RESPONSE_BODY_CAP = 1000;
|
|
103
128
|
export function summarizeApiErrorForLog(error) {
|
|
104
129
|
if (!APICallError.isInstance(error))
|
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
import { type ModelMessage } from "ai";
|
|
2
|
-
import {
|
|
2
|
+
import type { getModelInfo } from "../models/registry.js";
|
|
3
|
+
import { resolveModelRuntime } from "../providers/runtime.js";
|
|
3
4
|
import type { ProviderId } from "../providers/types.js";
|
|
4
5
|
import { type SessionStore } from "../storage/index.js";
|
|
5
6
|
import type { SessionInfo, StreamChunk, SubagentStatus } from "../types/index.js";
|
|
6
7
|
import { type PermissionMode } from "../utils/permission-mode.js";
|
|
7
|
-
import { loadValidSubAgents } from "../utils/settings.js";
|
|
8
8
|
import type { AbortContext } from "./abort.js";
|
|
9
9
|
import type { LegacyProvider, ProcessMessageObserver } from "./agent-options.js";
|
|
10
10
|
import type { CouncilManager } from "./council-manager.js";
|
|
11
11
|
import type { CrossTurnDedup } from "./cross-turn-dedup.js";
|
|
12
12
|
import type { PendingCallsLog } from "./pending-calls.js";
|
|
13
13
|
import type { ReadPathBudget } from "./read-path-budget.js";
|
|
14
|
+
import type { SafetyOverrideAskInfo, SafetyOverrideVerdict } from "./safety-askcard.js";
|
|
14
15
|
import { type ToolLoopCapAsk } from "./tool-loop-cap.js";
|
|
15
16
|
import type { TurnRunnerDepsBase } from "./turn-runner-deps.js";
|
|
16
17
|
/**
|
|
@@ -108,7 +109,10 @@ export interface MessageProcessorDeps extends TurnRunnerDepsBase {
|
|
|
108
109
|
drainSteerMessages?: () => {
|
|
109
110
|
text: string;
|
|
110
111
|
}[];
|
|
112
|
+
appendMidTurnMessages?: (msgs: ModelMessage[]) => void;
|
|
111
113
|
askToolLoopContinue?: ToolLoopCapAsk;
|
|
114
|
+
/** Safety override handler — invoked when a tool call is blocked by the safety filter. */
|
|
115
|
+
askSafetyOverride?: (info: SafetyOverrideAskInfo) => Promise<SafetyOverrideVerdict>;
|
|
112
116
|
runCouncilV2(userMessage: string, opts: {
|
|
113
117
|
skipClarification: boolean;
|
|
114
118
|
observer?: ProcessMessageObserver;
|
|
@@ -121,15 +125,26 @@ export interface MessageProcessorDeps extends TurnRunnerDepsBase {
|
|
|
121
125
|
}>): AsyncGenerator<StreamChunk, void, unknown>;
|
|
122
126
|
processMessageBatchTurn(args: {
|
|
123
127
|
userModelMessage: ModelMessage;
|
|
128
|
+
userEnrichedMessage: ModelMessage;
|
|
124
129
|
observer?: ProcessMessageObserver;
|
|
125
130
|
provider: LegacyProvider;
|
|
126
|
-
subagents:
|
|
131
|
+
subagents: unknown[];
|
|
127
132
|
system: string;
|
|
128
|
-
runtime:
|
|
129
|
-
modelInfo:
|
|
133
|
+
runtime: ReturnType<typeof resolveModelRuntime>;
|
|
134
|
+
modelInfo: ReturnType<typeof getModelInfo>;
|
|
130
135
|
signal: AbortSignal;
|
|
131
136
|
}): AsyncGenerator<StreamChunk, void, unknown>;
|
|
132
137
|
}
|
|
138
|
+
/**
|
|
139
|
+
* Rewrites tool-result parts in the AI SDK's final response history if the
|
|
140
|
+
* user manually approved a safety-blocked command. This ensures the model sees
|
|
141
|
+
* its own retry context accurately (as a success) rather than a repeated block
|
|
142
|
+
* message, avoiding infinite retry loops or hallucinated failures.
|
|
143
|
+
*/
|
|
144
|
+
export declare function rewriteSafetyApprovedToolResults<T extends {
|
|
145
|
+
role: string;
|
|
146
|
+
content?: any;
|
|
147
|
+
}>(messages: T[]): T[];
|
|
133
148
|
export declare class MessageProcessor {
|
|
134
149
|
private deps;
|
|
135
150
|
constructor(deps: MessageProcessorDeps);
|
|
@@ -139,3 +154,4 @@ export declare class MessageProcessor {
|
|
|
139
154
|
base64: string;
|
|
140
155
|
}>): AsyncGenerator<StreamChunk, void, unknown>;
|
|
141
156
|
}
|
|
157
|
+
export declare function stripDsmlMarkup(text: string): string;
|