muonroi-cli 1.7.2 → 1.8.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/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 +143 -6
- 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 +7 -4
- 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 +36 -1
- 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/flow/compaction/index.d.ts +1 -0
- package/dist/src/flow/compaction/index.js +4 -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 +59 -62
- 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 +13 -5
- package/dist/src/lsp/manager.test.js +41 -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/auto-setup.js +0 -8
- 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/self-verify-jobs.d.ts +1 -0
- package/dist/src/mcp/self-verify-jobs.js +1 -3
- package/dist/src/mcp/self-verify-runner.js +1 -1
- package/dist/src/models/catalog-gemini.test.js +12 -10
- package/dist/src/models/catalog.json +106 -38
- 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 +3 -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 +2 -0
- package/dist/src/orchestrator/__tests__/prompts.test.d.ts +1 -0
- package/dist/src/orchestrator/__tests__/prompts.test.js +88 -0
- package/dist/src/orchestrator/__tests__/stream-runner.test.js +29 -0
- package/dist/src/orchestrator/__tests__/sub-session-delegation.test.d.ts +1 -0
- package/dist/src/orchestrator/__tests__/sub-session-delegation.test.js +507 -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 +366 -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 +23 -5
- package/dist/src/orchestrator/message-processor.js +226 -2573
- package/dist/src/orchestrator/orchestrator.d.ts +11 -2
- package/dist/src/orchestrator/orchestrator.js +530 -43
- package/dist/src/orchestrator/pending-calls.js +2 -1
- package/dist/src/orchestrator/preprocessor.d.ts +13 -0
- package/dist/src/orchestrator/preprocessor.js +146 -0
- package/dist/src/orchestrator/prompts.d.ts +16 -0
- package/dist/src/orchestrator/prompts.js +130 -67
- 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-cap.d.ts +2 -0
- package/dist/src/orchestrator/sub-agent-cap.js +12 -4
- package/dist/src/orchestrator/sub-agent-model-tier.js +1 -1
- package/dist/src/orchestrator/subagent-compactor.d.ts +21 -0
- package/dist/src/orchestrator/subagent-compactor.js +148 -24
- package/dist/src/orchestrator/subagent-compactor.spec.js +249 -1
- 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 +153 -0
- package/dist/src/orchestrator/tool-engine.js +3138 -0
- package/dist/src/orchestrator/turn-runner-deps.d.ts +3 -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__/llm-classify.test.js +79 -1
- 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 +62 -7
- 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.d.ts +11 -0
- package/dist/src/pil/llm-classify.js +196 -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/gather.js +19 -5
- package/dist/src/product-loop/loop-driver.js +2 -2
- 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/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/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/self-qa/agentic-loop.js +30 -21
- 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__/hierarchical-session.test.d.ts +1 -0
- package/dist/src/storage/__tests__/hierarchical-session.test.js +161 -0
- package/dist/src/storage/__tests__/sweep-stale-pending.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/migrations.js +13 -1
- package/dist/src/storage/transcript-response-entry.test.js +18 -5
- package/dist/src/storage/transcript-view.js +7 -1
- package/dist/src/storage/transcript.d.ts +3 -0
- package/dist/src/storage/transcript.js +254 -73
- package/dist/src/storage/ui-interaction-log.d.ts +17 -0
- package/dist/src/storage/usage.js +22 -5
- 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 +66 -1
- 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 +6 -0
- package/dist/src/tools/registry.js +215 -13
- package/dist/src/types/index.d.ts +8 -2
- 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/expand.js +14 -1
- 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/__tests__/llm-deadline.test.js +16 -4
- package/dist/src/utils/__tests__/logger.test.d.ts +1 -0
- package/dist/src/utils/__tests__/logger.test.js +115 -0
- package/dist/src/utils/__tests__/settings-agent-first.test.d.ts +1 -0
- package/dist/src/utils/__tests__/settings-agent-first.test.js +48 -0
- package/dist/src/utils/install-manager.d.ts +1 -0
- package/dist/src/utils/install-manager.js +76 -7
- package/dist/src/utils/install-manager.test.js +43 -1
- package/dist/src/utils/llm-deadline.d.ts +9 -1
- package/dist/src/utils/llm-deadline.js +31 -2
- package/dist/src/utils/logger.d.ts +28 -0
- package/dist/src/utils/logger.js +171 -0
- 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 +36 -32
- package/dist/src/utils/settings.js +151 -123
- package/dist/src/utils/update-checker.test.js +5 -1
- package/package.json +1 -1
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { getCompactionSummaryText } from "../orchestrator/compaction.js";
|
|
2
2
|
import { getResponseTaskType, isResponseTool } from "../pil/response-tools.js";
|
|
3
|
+
import { logger } from "../utils/logger.js";
|
|
3
4
|
import { getDatabase, withTransaction } from "./db.js";
|
|
4
5
|
import { extractToolResultFromOutput, getOutputKind, isOutputSuccess } from "./tool-results.js";
|
|
5
6
|
import { buildEffectiveTranscript } from "./transcript-view.js";
|
|
@@ -327,16 +328,15 @@ export function markMessageErrored(sessionId, seq) {
|
|
|
327
328
|
*/
|
|
328
329
|
export function sweepStalePendingRows(staleAfterMs = 5 * 60 * 1000) {
|
|
329
330
|
const cutoff = new Date(Date.now() - staleAfterMs).toISOString();
|
|
330
|
-
const now = new Date().toISOString();
|
|
331
331
|
try {
|
|
332
332
|
const db = getDatabase();
|
|
333
333
|
const toolCalls = db
|
|
334
334
|
.prepare(`
|
|
335
335
|
UPDATE tool_calls
|
|
336
|
-
SET status = 'aborted', completed_at =
|
|
336
|
+
SET status = 'aborted', completed_at = started_at
|
|
337
337
|
WHERE status = 'pending' AND started_at < ?
|
|
338
338
|
`)
|
|
339
|
-
.run(
|
|
339
|
+
.run(cutoff);
|
|
340
340
|
const messages = db
|
|
341
341
|
.prepare(`
|
|
342
342
|
UPDATE messages
|
|
@@ -379,90 +379,247 @@ export function appendCompaction(sessionId, firstKeptSeq, summary, tokensBefore)
|
|
|
379
379
|
`).run(new Date().toISOString(), sessionId);
|
|
380
380
|
});
|
|
381
381
|
}
|
|
382
|
-
export function
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
382
|
+
export function revertLatestCompaction(sessionId) {
|
|
383
|
+
withTransaction((db) => {
|
|
384
|
+
db.prepare(`
|
|
385
|
+
DELETE FROM compactions
|
|
386
|
+
WHERE session_id = ?
|
|
387
|
+
AND id = (SELECT MAX(id) FROM compactions WHERE session_id = ?)
|
|
388
|
+
`).run(sessionId, sessionId);
|
|
389
|
+
db.prepare(`
|
|
390
|
+
UPDATE sessions
|
|
391
|
+
SET updated_at = ?
|
|
392
|
+
WHERE id = ?
|
|
393
|
+
`).run(new Date().toISOString(), sessionId);
|
|
394
|
+
});
|
|
395
|
+
}
|
|
396
|
+
export function getSessionChain(sessionId) {
|
|
397
|
+
logger.debug("storage", "Resolving session chain", { sessionId });
|
|
398
|
+
const db = getDatabase();
|
|
399
|
+
// 1. Walk up to the root parent
|
|
400
|
+
let rootId = sessionId;
|
|
401
|
+
const visitedUp = new Set();
|
|
402
|
+
while (rootId && !visitedUp.has(rootId)) {
|
|
403
|
+
visitedUp.add(rootId);
|
|
404
|
+
try {
|
|
405
|
+
const row = db.prepare("SELECT parent_session_id FROM sessions WHERE id = ?").get(rootId);
|
|
406
|
+
if (row?.parent_session_id) {
|
|
407
|
+
rootId = row.parent_session_id;
|
|
392
408
|
}
|
|
393
|
-
|
|
409
|
+
else {
|
|
410
|
+
break;
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
catch {
|
|
414
|
+
break;
|
|
394
415
|
}
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
416
|
+
}
|
|
417
|
+
// 2. Find all descendants of the root session using a BFS queue to handle multiple child branches
|
|
418
|
+
const allIds = new Set([rootId]);
|
|
419
|
+
const queue = [rootId];
|
|
420
|
+
while (queue.length > 0) {
|
|
421
|
+
const currentId = queue.shift();
|
|
422
|
+
try {
|
|
423
|
+
const children = db.prepare("SELECT id FROM sessions WHERE parent_session_id = ?").all(currentId);
|
|
424
|
+
for (const child of children) {
|
|
425
|
+
if (!allIds.has(child.id)) {
|
|
426
|
+
allIds.add(child.id);
|
|
427
|
+
queue.push(child.id);
|
|
428
|
+
}
|
|
406
429
|
}
|
|
407
|
-
continue;
|
|
408
430
|
}
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
431
|
+
catch (err) {
|
|
432
|
+
logger.error("storage", `Failed to query child sessions for ${currentId} during walk`, { error: err });
|
|
433
|
+
}
|
|
434
|
+
}
|
|
435
|
+
// 3. Sort chronologically by querying the database for all matched sessions ordered by created_at
|
|
436
|
+
let chain = [];
|
|
437
|
+
try {
|
|
438
|
+
const placeholders = Array.from(allIds)
|
|
439
|
+
.map(() => "?")
|
|
440
|
+
.join(",");
|
|
441
|
+
const sortedRows = db
|
|
442
|
+
.prepare(`
|
|
443
|
+
SELECT id FROM sessions
|
|
444
|
+
WHERE id IN (${placeholders})
|
|
445
|
+
ORDER BY created_at ASC
|
|
446
|
+
`)
|
|
447
|
+
.all(...Array.from(allIds));
|
|
448
|
+
chain = sortedRows.map((r) => r.id);
|
|
449
|
+
}
|
|
450
|
+
catch (err) {
|
|
451
|
+
logger.error("storage", `Failed to sort session chain for root ${rootId}`, { error: err });
|
|
452
|
+
// Fallback to unsorted array if query fails
|
|
453
|
+
chain = Array.from(allIds);
|
|
454
|
+
}
|
|
455
|
+
logger.debug("storage", "Resolved session chain successfully", { sessionId, chainLength: chain.length, chain });
|
|
456
|
+
return chain;
|
|
457
|
+
}
|
|
458
|
+
export function buildChatEntries(sessionId) {
|
|
459
|
+
const chain = getSessionChain(sessionId);
|
|
460
|
+
logger.debug("storage", "Building chat entries from session chain", { sessionId, chainLength: chain.length });
|
|
461
|
+
const toolResults = new Map();
|
|
462
|
+
for (const sid of chain) {
|
|
463
|
+
const results = loadStoredToolResults(sid);
|
|
464
|
+
for (const [k, v] of results) {
|
|
465
|
+
toolResults.set(k, v);
|
|
466
|
+
}
|
|
467
|
+
}
|
|
468
|
+
// Load parent/child session metadata to reconcile user prompt timestamps across rotation/sub-session boundaries
|
|
469
|
+
const db = getDatabase();
|
|
470
|
+
const sessionMeta = new Map();
|
|
471
|
+
try {
|
|
472
|
+
if (chain.length > 1) {
|
|
473
|
+
const placeholders = chain.map(() => "?").join(",");
|
|
474
|
+
const rows = db
|
|
475
|
+
.prepare(`SELECT id, parent_session_id, created_at FROM sessions WHERE id IN (${placeholders})`)
|
|
476
|
+
.all(...chain);
|
|
477
|
+
for (const r of rows) {
|
|
478
|
+
sessionMeta.set(r.id, { parent_session_id: r.parent_session_id, created_at: r.created_at });
|
|
413
479
|
}
|
|
414
|
-
continue;
|
|
415
480
|
}
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
481
|
+
}
|
|
482
|
+
catch (err) {
|
|
483
|
+
logger.error("storage", "Failed to load session metadata for chain in buildChatEntries", { error: err });
|
|
484
|
+
}
|
|
485
|
+
// Map each child sub-session's initial user prompt to its creation timestamp
|
|
486
|
+
const childPrompts = new Map();
|
|
487
|
+
for (let i = 1; i < chain.length; i++) {
|
|
488
|
+
const sid = chain[i];
|
|
489
|
+
const meta = sessionMeta.get(sid);
|
|
490
|
+
if (meta && meta.parent_session_id) {
|
|
491
|
+
const records = buildEffectiveMessageRecords(sid);
|
|
492
|
+
const firstUser = records.find((r) => r.message.role === "user");
|
|
493
|
+
if (firstUser) {
|
|
494
|
+
const content = renderUserContent(firstUser.message.content);
|
|
495
|
+
if (content) {
|
|
496
|
+
childPrompts.set(content, new Date(meta.created_at));
|
|
497
|
+
}
|
|
498
|
+
}
|
|
499
|
+
}
|
|
500
|
+
}
|
|
501
|
+
const callMap = new Map();
|
|
502
|
+
const entries = [];
|
|
503
|
+
const renderedResponseCallIds = new Set();
|
|
504
|
+
let lastTimestamp;
|
|
505
|
+
for (let i = 0; i < chain.length; i++) {
|
|
506
|
+
const sid = chain[i];
|
|
507
|
+
const records = buildEffectiveMessageRecords(sid);
|
|
508
|
+
const isChildSession = i > 0;
|
|
509
|
+
for (let j = 0; j < records.length; j++) {
|
|
510
|
+
const { message, timestamp } = records[j];
|
|
511
|
+
lastTimestamp = timestamp;
|
|
512
|
+
if (message.role === "user") {
|
|
513
|
+
const content = renderUserContent(message.content);
|
|
514
|
+
if (isChildSession && childPrompts.has(content)) {
|
|
515
|
+
// Skip B's user message because it's a duplicate of A's user message
|
|
516
|
+
continue;
|
|
517
|
+
}
|
|
518
|
+
if (content) {
|
|
519
|
+
entries.push({ type: "user", content, timestamp });
|
|
520
|
+
}
|
|
521
|
+
continue;
|
|
522
|
+
}
|
|
523
|
+
if (message.role === "system") {
|
|
524
|
+
const summaryText = getCompactionSummaryText(message);
|
|
525
|
+
if (isChildSession && j === 0 && summaryText !== null) {
|
|
526
|
+
// Skip the first message in a child session if it's the parent compaction summary
|
|
527
|
+
// to keep the visual timeline clean, since the user already sees the parent history.
|
|
419
528
|
continue;
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
529
|
+
}
|
|
530
|
+
const content = summaryText ?? (typeof message.content === "string" ? message.content.trim() : "");
|
|
531
|
+
if (content && !isInternalCouncilMarker(content)) {
|
|
532
|
+
entries.push(summaryText !== null
|
|
533
|
+
? { type: "assistant", content, timestamp, sourceLabel: "⋯ context checkpoint (auto-compacted)" }
|
|
534
|
+
: { type: "assistant", content, timestamp });
|
|
535
|
+
}
|
|
536
|
+
continue;
|
|
537
|
+
}
|
|
538
|
+
if (message.role === "assistant") {
|
|
539
|
+
const text = renderAssistantContent(message.content, callMap);
|
|
540
|
+
if (text) {
|
|
541
|
+
entries.push({ type: "assistant", content: text, timestamp });
|
|
542
|
+
}
|
|
543
|
+
continue;
|
|
544
|
+
}
|
|
545
|
+
if (message.role === "tool" && Array.isArray(message.content)) {
|
|
546
|
+
for (const part of message.content) {
|
|
547
|
+
if (part.type !== "tool-result")
|
|
548
|
+
continue;
|
|
549
|
+
if (isResponseTool(part.toolName)) {
|
|
550
|
+
renderedResponseCallIds.add(part.toolCallId);
|
|
551
|
+
const rawOutput = part.output;
|
|
552
|
+
const unwrapped = rawOutput && typeof rawOutput === "object" && rawOutput.type === "json"
|
|
553
|
+
? (rawOutput.value ?? {})
|
|
554
|
+
: (rawOutput ?? {});
|
|
555
|
+
entries.push({
|
|
556
|
+
type: "structured_response",
|
|
557
|
+
content: "",
|
|
558
|
+
timestamp,
|
|
559
|
+
structuredResponse: {
|
|
560
|
+
taskType: getResponseTaskType(part.toolName) ?? part.toolName,
|
|
561
|
+
data: unwrapped,
|
|
562
|
+
},
|
|
563
|
+
});
|
|
564
|
+
continue;
|
|
565
|
+
}
|
|
566
|
+
const toolCall = callMap.get(part.toolCallId) ?? toFallbackToolCall(part.toolCallId, part.toolName);
|
|
567
|
+
const toolResult = toolResults.get(part.toolCallId) ??
|
|
568
|
+
extractToolResultFromOutput(part.output) ?? {
|
|
569
|
+
success: isOutputSuccess(part.output),
|
|
570
|
+
output: JSON.stringify(part.output),
|
|
571
|
+
};
|
|
439
572
|
entries.push({
|
|
440
|
-
type: "
|
|
441
|
-
content: "",
|
|
573
|
+
type: "tool_result",
|
|
574
|
+
content: toolResult.success ? toolResult.output || "Success" : toolResult.error || "Error",
|
|
442
575
|
timestamp,
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
data: unwrapped,
|
|
446
|
-
},
|
|
576
|
+
toolCall,
|
|
577
|
+
toolResult,
|
|
447
578
|
});
|
|
448
|
-
continue;
|
|
449
579
|
}
|
|
450
|
-
const toolCall = callMap.get(part.toolCallId) ?? toFallbackToolCall(part.toolCallId, part.toolName);
|
|
451
|
-
const toolResult = toolResults.get(part.toolCallId) ??
|
|
452
|
-
extractToolResultFromOutput(part.output) ?? {
|
|
453
|
-
success: isOutputSuccess(part.output),
|
|
454
|
-
output: JSON.stringify(part.output),
|
|
455
|
-
};
|
|
456
|
-
entries.push({
|
|
457
|
-
type: "tool_result",
|
|
458
|
-
content: toolResult.success ? toolResult.output || "Success" : toolResult.error || "Error",
|
|
459
|
-
timestamp,
|
|
460
|
-
toolCall,
|
|
461
|
-
toolResult,
|
|
462
|
-
});
|
|
463
580
|
}
|
|
464
581
|
}
|
|
465
582
|
}
|
|
583
|
+
// Recover response-tool answers that were CALLED but never produced a
|
|
584
|
+
// tool-result row (execution ERRORED). The payload lives in the call args.
|
|
585
|
+
// Without this, a respond_* that errored after the council debate is dropped
|
|
586
|
+
// on finalize and only the last debate round stays visible.
|
|
587
|
+
for (const [callId, call] of callMap) {
|
|
588
|
+
if (renderedResponseCallIds.has(callId))
|
|
589
|
+
continue;
|
|
590
|
+
if (!isResponseTool(call.function.name))
|
|
591
|
+
continue;
|
|
592
|
+
let data;
|
|
593
|
+
try {
|
|
594
|
+
data = JSON.parse(call.function.arguments || "{}");
|
|
595
|
+
}
|
|
596
|
+
catch {
|
|
597
|
+
// Args unparseable — nothing to recover for this call.
|
|
598
|
+
continue;
|
|
599
|
+
}
|
|
600
|
+
entries.push({
|
|
601
|
+
type: "structured_response",
|
|
602
|
+
content: "",
|
|
603
|
+
timestamp: lastTimestamp ?? new Date(),
|
|
604
|
+
structuredResponse: {
|
|
605
|
+
taskType: getResponseTaskType(call.function.name) ?? call.function.name,
|
|
606
|
+
data,
|
|
607
|
+
},
|
|
608
|
+
});
|
|
609
|
+
}
|
|
610
|
+
// Adjust parent user message timestamps to match their corresponding child session creation time
|
|
611
|
+
for (const entry of entries) {
|
|
612
|
+
if (entry.type === "user") {
|
|
613
|
+
const content = entry.content.trim();
|
|
614
|
+
const childTime = childPrompts.get(content);
|
|
615
|
+
if (childTime) {
|
|
616
|
+
entry.timestamp = childTime;
|
|
617
|
+
}
|
|
618
|
+
}
|
|
619
|
+
}
|
|
620
|
+
// Sort entries chronologically by timestamp (stable sort)
|
|
621
|
+
entries.sort((a, b) => a.timestamp.getTime() - b.timestamp.getTime());
|
|
622
|
+
logger.debug("storage", "Built chat entries successfully", { sessionId, count: entries.length });
|
|
466
623
|
return entries;
|
|
467
624
|
}
|
|
468
625
|
function getNextSequence(db, sessionId) {
|
|
@@ -540,4 +697,28 @@ function toFallbackToolCall(toolCallId, toolName) {
|
|
|
540
697
|
},
|
|
541
698
|
};
|
|
542
699
|
}
|
|
700
|
+
export function getLastTodoWriteArgs(sessionId) {
|
|
701
|
+
const chain = getSessionChain(sessionId);
|
|
702
|
+
const db = getDatabase();
|
|
703
|
+
for (let i = chain.length - 1; i >= 0; i--) {
|
|
704
|
+
try {
|
|
705
|
+
const row = db
|
|
706
|
+
.prepare(`
|
|
707
|
+
SELECT args_json
|
|
708
|
+
FROM tool_calls
|
|
709
|
+
WHERE session_id = ? AND tool_name = 'todo_write'
|
|
710
|
+
ORDER BY id DESC
|
|
711
|
+
LIMIT 1
|
|
712
|
+
`)
|
|
713
|
+
.get(chain[i]);
|
|
714
|
+
if (row?.args_json) {
|
|
715
|
+
return row.args_json;
|
|
716
|
+
}
|
|
717
|
+
}
|
|
718
|
+
catch {
|
|
719
|
+
// ignore and check parent
|
|
720
|
+
}
|
|
721
|
+
}
|
|
722
|
+
return null;
|
|
723
|
+
}
|
|
543
724
|
//# sourceMappingURL=transcript.js.map
|
|
@@ -107,6 +107,20 @@ interface InitNewRetryPayload {
|
|
|
107
107
|
feStack: string;
|
|
108
108
|
bbTemplate: string | null;
|
|
109
109
|
}
|
|
110
|
+
/** Auto-resolved loop-cap event (no user prompt). Replaces the old askcard_open for tool-loop-cap. */
|
|
111
|
+
interface LoopCapAutoPayload {
|
|
112
|
+
questionId: string;
|
|
113
|
+
phase: "tool-loop-cap";
|
|
114
|
+
autoVerdict: "continue" | "stop";
|
|
115
|
+
kind: "pattern" | "cap";
|
|
116
|
+
stepNumber: number;
|
|
117
|
+
/** Only present for pattern kind. */
|
|
118
|
+
toolName?: string;
|
|
119
|
+
count?: number;
|
|
120
|
+
naturalCeiling?: number | null;
|
|
121
|
+
/** Only present for cap kind. */
|
|
122
|
+
cap?: number;
|
|
123
|
+
}
|
|
110
124
|
type Payload = {
|
|
111
125
|
subtype: "route_decision";
|
|
112
126
|
data: RouteDecisionPayload;
|
|
@@ -146,6 +160,9 @@ type Payload = {
|
|
|
146
160
|
} | {
|
|
147
161
|
subtype: "init_new_retry";
|
|
148
162
|
data: InitNewRetryPayload;
|
|
163
|
+
} | {
|
|
164
|
+
subtype: "loop_cap_auto";
|
|
165
|
+
data: LoopCapAutoPayload;
|
|
149
166
|
};
|
|
150
167
|
/**
|
|
151
168
|
* Persist a UI lifecycle event. Caller passes a discriminated payload so
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { getModelInfo } from "../models/registry.js";
|
|
2
|
+
import { logger } from "../utils/logger.js";
|
|
2
3
|
import { getDatabase } from "./db.js";
|
|
4
|
+
import { getSessionChain } from "./transcript.js";
|
|
3
5
|
export function recordUsageEvent(sessionId, source, model, usage, messageSeq, pilActive = false, enrichmentDelta = 0, providerOptionsShape = null) {
|
|
4
6
|
if (!usage)
|
|
5
7
|
return;
|
|
@@ -21,24 +23,39 @@ export function recordUsageEvent(sessionId, source, model, usage, messageSeq, pi
|
|
|
21
23
|
.run(sessionId, messageSeq ?? null, source, model, inputTokens, outputTokens, totalTokens, costMicros, new Date().toISOString(), pilActive ? 1 : 0, enrichmentDelta, cacheReadTokens, cacheCreationTokens, providerOptionsShape);
|
|
22
24
|
}
|
|
23
25
|
export function getSessionTotalTokens(sessionId) {
|
|
26
|
+
const chain = getSessionChain(sessionId);
|
|
27
|
+
const placeholders = chain.map(() => "?").join(",");
|
|
24
28
|
const row = getDatabase()
|
|
25
29
|
.prepare(`
|
|
26
30
|
SELECT COALESCE(SUM(total_tokens), 0) AS total_tokens
|
|
27
31
|
FROM usage_events
|
|
28
|
-
WHERE session_id
|
|
32
|
+
WHERE session_id IN (${placeholders})
|
|
29
33
|
`)
|
|
30
|
-
.get(
|
|
31
|
-
|
|
34
|
+
.get(...chain);
|
|
35
|
+
const total = row?.total_tokens ?? 0;
|
|
36
|
+
logger.debug("storage", "Calculated session total tokens from chain", {
|
|
37
|
+
sessionId,
|
|
38
|
+
chainLength: chain.length,
|
|
39
|
+
totalTokens: total,
|
|
40
|
+
});
|
|
41
|
+
return total;
|
|
32
42
|
}
|
|
33
43
|
export function listSessionUsage(sessionId) {
|
|
44
|
+
const chain = getSessionChain(sessionId);
|
|
45
|
+
const placeholders = chain.map(() => "?").join(",");
|
|
34
46
|
const rows = getDatabase()
|
|
35
47
|
.prepare(`
|
|
36
48
|
SELECT id, session_id, message_seq, source, model, input_tokens, output_tokens, total_tokens, cost_micros, created_at, cache_read_tokens, cache_creation_tokens
|
|
37
49
|
FROM usage_events
|
|
38
|
-
WHERE session_id
|
|
50
|
+
WHERE session_id IN (${placeholders})
|
|
39
51
|
ORDER BY id ASC
|
|
40
52
|
`)
|
|
41
|
-
.all(
|
|
53
|
+
.all(...chain);
|
|
54
|
+
logger.debug("storage", "Retrieved session usage events from chain", {
|
|
55
|
+
sessionId,
|
|
56
|
+
chainLength: chain.length,
|
|
57
|
+
eventCount: rows.length,
|
|
58
|
+
});
|
|
42
59
|
return rows.map((row) => ({
|
|
43
60
|
id: row.id,
|
|
44
61
|
sessionId: row.session_id,
|
|
@@ -33,6 +33,12 @@ describe("registerNativeMuonroiTools", () => {
|
|
|
33
33
|
registerNativeMuonroiTools(tools);
|
|
34
34
|
expect(await exec(tools, "ee_feedback", { verdict: "followed" })).toMatch(/invalid_args/);
|
|
35
35
|
});
|
|
36
|
+
it("ee_write rejects a too-short lesson (no network call)", async () => {
|
|
37
|
+
const tools = {};
|
|
38
|
+
registerNativeMuonroiTools(tools);
|
|
39
|
+
expect(await exec(tools, "ee_write", { lesson: "oops" })).toMatch(/invalid_args/);
|
|
40
|
+
expect(await exec(tools, "ee_write", {})).toMatch(/invalid_args/);
|
|
41
|
+
});
|
|
36
42
|
it("selfverify_status returns not_found for an unknown runId (shared JobManager)", async () => {
|
|
37
43
|
const tools = {};
|
|
38
44
|
registerNativeMuonroiTools(tools);
|
package/dist/src/tools/bash.d.ts
CHANGED
|
@@ -14,7 +14,13 @@ export interface BackgroundProcess {
|
|
|
14
14
|
exitCode: number | null;
|
|
15
15
|
}
|
|
16
16
|
interface BashToolOptions {
|
|
17
|
-
|
|
17
|
+
/**
|
|
18
|
+
* Accepted for backward compatibility with callers that pass sandboxMode.
|
|
19
|
+
* Sandbox has been removed; this value is ignored — mode is always "off".
|
|
20
|
+
* Will be repurposed when the new sandbox is implemented.
|
|
21
|
+
* @deprecated
|
|
22
|
+
*/
|
|
23
|
+
sandboxMode?: string;
|
|
18
24
|
sandboxSettings?: SandboxSettings;
|
|
19
25
|
shellSettings?: ShellSettings;
|
|
20
26
|
}
|
|
@@ -22,12 +28,17 @@ export declare class BashTool {
|
|
|
22
28
|
private cwd;
|
|
23
29
|
private bgProcesses;
|
|
24
30
|
private tmpDir;
|
|
25
|
-
private sandboxMode;
|
|
26
|
-
private sandboxSettings;
|
|
27
31
|
private shellSettings;
|
|
28
32
|
private resolvedShell;
|
|
29
|
-
private
|
|
33
|
+
private sandboxSettings;
|
|
30
34
|
constructor(initialCwd?: string, options?: BashToolOptions);
|
|
35
|
+
/**
|
|
36
|
+
* Sandbox has been removed. Always returns "off".
|
|
37
|
+
* Kept for backward compatibility with orchestrator / stream-runner callers.
|
|
38
|
+
*/
|
|
39
|
+
getSandboxMode(): SandboxMode;
|
|
40
|
+
getSandboxSettings(): SandboxSettings;
|
|
41
|
+
setSandboxSettings(settings: SandboxSettings): void;
|
|
31
42
|
private ensureTmpDir;
|
|
32
43
|
execute(command: string, timeout?: number, abortSignal?: AbortSignal): Promise<ToolResult>;
|
|
33
44
|
startBackground(command: string): Promise<ToolResult>;
|
|
@@ -37,29 +48,31 @@ export declare class BashTool {
|
|
|
37
48
|
cleanup(): Promise<void>;
|
|
38
49
|
getCwd(): string;
|
|
39
50
|
setCwd(next: string): void;
|
|
40
|
-
getSandboxMode(): SandboxMode;
|
|
41
|
-
setSandboxMode(mode: SandboxMode): void;
|
|
42
|
-
/**
|
|
43
|
-
* The sandbox mode that actually takes effect. When "shuru" is configured but
|
|
44
|
-
* the current platform cannot run Shuru (non-macOS/arm64), the sandbox is
|
|
45
|
-
* inert: every wrapped command would fail with the macOS-only error, and the
|
|
46
|
-
* tool description would still advertise a `/workspace` mount that does not
|
|
47
|
-
* exist — so the model `cd`s into a phantom dir and abandons verification.
|
|
48
|
-
* Degrade to "off" (host execution) with a one-time warning so bash keeps
|
|
49
|
-
* working and the description reflects reality. A stale checked-in project
|
|
50
|
-
* `sandboxMode: "shuru"` therefore no longer bricks the shell off-platform.
|
|
51
|
-
*/
|
|
52
|
-
private effectiveSandboxMode;
|
|
53
|
-
getSandboxSettings(): SandboxSettings;
|
|
54
|
-
setSandboxSettings(settings: SandboxSettings): void;
|
|
55
51
|
getToolDescription(): string;
|
|
56
52
|
getResolvedShell(): ResolvedShell;
|
|
57
53
|
private spawnInvocation;
|
|
54
|
+
/**
|
|
55
|
+
* Pre-execution command preparation.
|
|
56
|
+
*
|
|
57
|
+
* Layer 1 — Catastrophic hard-block: checks the command against
|
|
58
|
+
* CATASTROPHIC_PATTERNS in permission-mode.ts. These are irreversible or
|
|
59
|
+
* severely dangerous operations that are blocked regardless of permission
|
|
60
|
+
* mode (safe / auto-edit / yolo) and regardless of sandbox state.
|
|
61
|
+
*
|
|
62
|
+
* Layer 2 — Future sandbox: when a new sandbox is wired in, wrap the
|
|
63
|
+
* command here before returning.
|
|
64
|
+
*/
|
|
65
|
+
/**
|
|
66
|
+
* Pre-execution command preparation with two-layer safety.
|
|
67
|
+
*
|
|
68
|
+
* Layer 1 — Catastrophic hard-block: checks the command against
|
|
69
|
+
* CATASTROPHIC_PATTERNS in permission-mode.ts. Returns structured block
|
|
70
|
+
* result so callers can route to askcard approval flow.
|
|
71
|
+
*
|
|
72
|
+
* Layer 2 — Future sandbox: when a new sandbox is wired in, wrap the
|
|
73
|
+
* command here before returning.
|
|
74
|
+
*/
|
|
58
75
|
private prepareCommand;
|
|
59
|
-
private formatSandboxRuntimeError;
|
|
60
76
|
}
|
|
61
|
-
export declare function wrapCommandForShuru(cwd: string, command: string, settings?: SandboxSettings): string;
|
|
62
|
-
export declare function shouldRunOnHostInSandboxMode(command: string, settings?: SandboxSettings): boolean;
|
|
63
77
|
export declare function wrapHostBrowserCommand(command: string): string;
|
|
64
|
-
export declare function getSandboxMutationBlockReason(command: string, settings?: SandboxSettings): string | null;
|
|
65
78
|
export {};
|