mixdog 0.8.0 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +47 -23
- package/package.json +33 -27
- package/scripts/_test-folder-dialog.mjs +30 -0
- package/scripts/agent-parallel-smoke.mjs +388 -0
- package/scripts/agent-tag-reuse-smoke.mjs +183 -0
- package/scripts/background-task-meta-smoke.mjs +38 -0
- package/scripts/boot-smoke.mjs +52 -9
- package/scripts/build-runtime-linux.sh +348 -0
- package/scripts/build-runtime-macos.sh +217 -0
- package/scripts/build-runtime-windows.ps1 +242 -0
- package/scripts/compact-active-turn-test.mjs +68 -0
- package/scripts/compact-smoke.mjs +859 -129
- package/scripts/compact-trigger-migration-smoke.mjs +187 -0
- package/scripts/fix-brief-fn.mjs +35 -0
- package/scripts/fix-format-tool-surface.mjs +24 -0
- package/scripts/fix-tool-exec-visible.mjs +42 -0
- package/scripts/generate-runtime-manifest.mjs +166 -0
- package/scripts/hook-bus-test.mjs +330 -0
- package/scripts/lead-workflow-smoke.mjs +33 -39
- package/scripts/live-worker-smoke.mjs +43 -37
- package/scripts/llm-trace-summary.mjs +315 -0
- package/scripts/memory-meta-concurrency-test.mjs +20 -0
- package/scripts/output-style-smoke.mjs +56 -15
- package/scripts/parent-abort-link-test.mjs +44 -0
- package/scripts/patch-agent-brief.mjs +48 -0
- package/scripts/patch-app.mjs +21 -0
- package/scripts/patch-app2.mjs +18 -0
- package/scripts/patch-dist-brief.mjs +96 -0
- package/scripts/patch-tool-exec.mjs +70 -0
- package/scripts/pretool-ask-runtime-test.mjs +54 -0
- package/scripts/provider-toolcall-test.mjs +376 -0
- package/scripts/reactive-compact-persist-smoke.mjs +124 -0
- package/scripts/sanitize-tool-pairs-test.mjs +260 -0
- package/scripts/session-context-bench.mjs +344 -0
- package/scripts/session-ingest-smoke.mjs +177 -0
- package/scripts/set-effort-config-test.mjs +41 -0
- package/scripts/smoke-runtime-negative.ps1 +106 -0
- package/scripts/smoke-runtime-negative.sh +97 -0
- package/scripts/smoke.mjs +25 -0
- package/scripts/tool-result-hook-test.mjs +48 -0
- package/scripts/tool-smoke.mjs +1223 -95
- package/scripts/toolcall-args-test.mjs +150 -0
- package/scripts/tui-background-failure-smoke.mjs +73 -0
- package/scripts/usage-metrics-epoch-smoke.mjs +114 -0
- package/src/agents/debugger/AGENT.md +8 -0
- package/src/agents/explore/AGENT.md +4 -0
- package/src/agents/heavy-worker/AGENT.md +9 -3
- package/src/agents/maintainer/AGENT.md +4 -0
- package/src/agents/reviewer/AGENT.md +8 -0
- package/src/agents/scheduler-task/AGENT.md +12 -0
- package/src/agents/scheduler-task/agent.json +6 -0
- package/src/agents/webhook-handler/AGENT.md +12 -0
- package/src/agents/webhook-handler/agent.json +6 -0
- package/src/agents/worker/AGENT.md +9 -3
- package/src/app.mjs +77 -3
- package/src/defaults/hidden-roles.json +17 -12
- package/src/headless-role.mjs +117 -0
- package/src/help.mjs +30 -0
- package/src/hooks/lib/permission-evaluator.cjs +11 -475
- package/src/lib/keychain-cjs.cjs +9 -1
- package/src/lib/mixdog-debug.cjs +0 -7
- package/src/lib/rules-builder.cjs +240 -96
- package/src/lib/text-utils.cjs +1 -1
- package/src/mixdog-session-runtime.mjs +2325 -450
- package/src/output-styles/default.md +12 -28
- package/src/output-styles/extreme-simple.md +9 -6
- package/src/output-styles/simple.md +22 -9
- package/src/repl.mjs +118 -59
- package/src/rules/agent/00-common.md +15 -0
- package/src/rules/{bridge → agent}/20-skip-protocol.md +1 -2
- package/src/rules/agent/30-explorer.md +22 -0
- package/src/rules/{bridge → agent}/40-cycle1-agent.md +7 -0
- package/src/rules/{bridge → agent}/41-cycle2-agent.md +7 -0
- package/src/rules/{bridge → agent}/42-cycle3-agent.md +7 -0
- package/src/rules/lead/01-general.md +9 -5
- package/src/rules/lead/04-workflow.md +51 -12
- package/src/rules/lead/lead-tool.md +6 -0
- package/src/rules/shared/01-tool.md +12 -1
- package/src/runtime/agent/orchestrator/activity-bus.mjs +7 -18
- package/src/runtime/agent/orchestrator/agent-owner.mjs +11 -0
- package/src/runtime/agent/orchestrator/{smart-bridge/bridge-llm.mjs → agent-runtime/agent-dispatch.mjs} +138 -111
- package/src/runtime/agent/orchestrator/agent-runtime/agent-progress-watchdog.mjs +94 -0
- package/src/runtime/agent/orchestrator/{smart-bridge → agent-runtime}/cache-strategy.mjs +32 -23
- package/src/runtime/agent/orchestrator/{smart-bridge → agent-runtime}/session-builder.mjs +33 -27
- package/src/runtime/agent/orchestrator/{bridge-trace.mjs → agent-trace.mjs} +132 -81
- package/src/runtime/agent/orchestrator/cache-mtime.mjs +0 -21
- package/src/runtime/agent/orchestrator/config.mjs +174 -55
- package/src/runtime/agent/orchestrator/context/collect.mjs +195 -487
- package/src/runtime/agent/orchestrator/dispatch-persist.mjs +1 -1
- package/src/runtime/agent/orchestrator/internal-roles.mjs +77 -29
- package/src/runtime/agent/orchestrator/internal-tools.mjs +5 -6
- package/src/runtime/agent/orchestrator/mcp/client.mjs +15 -9
- package/src/runtime/agent/orchestrator/providers/anthropic-betas.mjs +7 -1
- package/src/runtime/agent/orchestrator/providers/anthropic-oauth.mjs +377 -243
- package/src/runtime/agent/orchestrator/providers/anthropic.mjs +146 -93
- package/src/runtime/agent/orchestrator/providers/api-usage.mjs +236 -4
- package/src/runtime/agent/orchestrator/providers/custom-tool-wire.mjs +49 -0
- package/src/runtime/agent/orchestrator/providers/gemini.mjs +58 -13
- package/src/runtime/agent/orchestrator/providers/grok-oauth.mjs +67 -149
- package/src/runtime/agent/orchestrator/providers/media-normalization.mjs +132 -2
- package/src/runtime/agent/orchestrator/providers/model-catalog.mjs +4 -1
- package/src/runtime/agent/orchestrator/providers/oauth-credential-probes.mjs +45 -0
- package/src/runtime/agent/orchestrator/providers/oauth-usage.mjs +61 -116
- package/src/runtime/agent/orchestrator/providers/openai-compat-presets.mjs +25 -0
- package/src/runtime/agent/orchestrator/providers/openai-compat-stream.mjs +79 -255
- package/src/runtime/agent/orchestrator/providers/openai-compat.mjs +221 -70
- package/src/runtime/agent/orchestrator/providers/openai-oauth-ws.mjs +477 -147
- package/src/runtime/agent/orchestrator/providers/openai-oauth.mjs +343 -496
- package/src/runtime/agent/orchestrator/providers/openai-ws.mjs +6 -6
- package/src/runtime/agent/orchestrator/providers/registry.mjs +88 -51
- package/src/runtime/agent/orchestrator/providers/retry-classifier.mjs +31 -11
- package/src/runtime/agent/orchestrator/providers/statusline-route-meta.mjs +41 -8
- package/src/runtime/agent/orchestrator/session/cache/post-edit-marks.mjs +4 -4
- package/src/runtime/agent/orchestrator/session/cache/read-cache.mjs +1 -1
- package/src/runtime/agent/orchestrator/session/compact.mjs +1173 -267
- package/src/runtime/agent/orchestrator/session/context-utils.mjs +199 -36
- package/src/runtime/agent/orchestrator/session/loop.mjs +851 -674
- package/src/runtime/agent/orchestrator/session/manager.mjs +1593 -466
- package/src/runtime/agent/orchestrator/session/manager.reactive-persist.test.mjs +107 -0
- package/src/runtime/agent/orchestrator/session/store.mjs +291 -46
- package/src/runtime/agent/orchestrator/session/tool-result-offload.mjs +2 -2
- package/src/runtime/agent/orchestrator/stall-policy.mjs +31 -16
- package/src/runtime/agent/orchestrator/tool-loop-guard.mjs +3 -219
- package/src/runtime/agent/orchestrator/tools/bash-session.mjs +34 -7
- package/src/runtime/agent/orchestrator/tools/builtin/advisory-lock.mjs +1 -1
- package/src/runtime/agent/orchestrator/tools/builtin/arg-guard.mjs +19 -0
- package/src/runtime/agent/orchestrator/tools/builtin/bash-tool.mjs +9 -9
- package/src/runtime/agent/orchestrator/tools/builtin/builtin-tools.mjs +60 -37
- package/src/runtime/agent/orchestrator/tools/builtin/cache-layers.mjs +21 -2
- package/src/runtime/agent/orchestrator/tools/builtin/device-paths.mjs +1 -1
- package/src/runtime/agent/orchestrator/tools/builtin/diagnostics-tool.mjs +0 -7
- package/src/runtime/agent/orchestrator/tools/builtin/glob-walk.mjs +1 -3
- package/src/runtime/agent/orchestrator/tools/builtin/list-tool.mjs +36 -12
- package/src/runtime/agent/orchestrator/tools/builtin/read-args.mjs +2 -0
- package/src/runtime/agent/orchestrator/tools/builtin/read-constants.mjs +2 -2
- package/src/runtime/agent/orchestrator/tools/builtin/read-formatting.mjs +5 -12
- package/src/runtime/agent/orchestrator/tools/builtin/read-image-resize.mjs +1 -1
- package/src/runtime/agent/orchestrator/tools/builtin/read-single-tool.mjs +4 -36
- package/src/runtime/agent/orchestrator/tools/builtin/read-tool.mjs +2 -40
- package/src/runtime/agent/orchestrator/tools/builtin/rg-runner.mjs +148 -27
- package/src/runtime/agent/orchestrator/tools/builtin/search-builders.mjs +2 -2
- package/src/runtime/agent/orchestrator/tools/builtin/search-tool.mjs +43 -75
- package/src/runtime/agent/orchestrator/tools/builtin/shell-jobs.mjs +90 -20
- package/src/runtime/agent/orchestrator/tools/builtin/snapshot-store.mjs +1 -1
- package/src/runtime/agent/orchestrator/tools/builtin.mjs +59 -5
- package/src/runtime/agent/orchestrator/tools/code-graph-state.mjs +86 -0
- package/src/runtime/agent/orchestrator/tools/code-graph-tool-defs.mjs +11 -11
- package/src/runtime/agent/orchestrator/tools/code-graph.mjs +4106 -4019
- package/src/runtime/agent/orchestrator/tools/patch-tool-defs.mjs +33 -4
- package/src/runtime/agent/orchestrator/tools/patch.mjs +90 -6
- package/src/runtime/agent/orchestrator/tools/progress-message.mjs +6 -4
- package/src/runtime/agent/orchestrator/tools/result-compression.mjs +4 -4
- package/src/runtime/agent/orchestrator/tools/shell-command.mjs +8 -1
- package/src/runtime/agent/orchestrator/tools/shell-snapshot.mjs +4 -4
- package/src/runtime/channels/index.mjs +152 -24
- package/src/runtime/channels/lib/scheduler.mjs +18 -14
- package/src/runtime/channels/lib/session-discovery.mjs +3 -2
- package/src/runtime/channels/lib/tool-format.mjs +0 -2
- package/src/runtime/channels/lib/transcript-discovery.mjs +3 -2
- package/src/runtime/channels/lib/webhook.mjs +1 -1
- package/src/runtime/channels/tool-defs.mjs +29 -29
- package/src/runtime/memory/index.mjs +635 -107
- package/src/runtime/memory/lib/agent-ipc.mjs +29 -12
- package/src/runtime/memory/lib/core-memory-store.mjs +2 -2
- package/src/runtime/memory/lib/embedding-model-config.mjs +55 -0
- package/src/runtime/memory/lib/embedding-provider.mjs +31 -4
- package/src/runtime/memory/lib/embedding-worker.mjs +19 -10
- package/src/runtime/memory/lib/memory-cycle1.mjs +38 -17
- package/src/runtime/memory/lib/memory-cycle2.mjs +6 -7
- package/src/runtime/memory/lib/memory-cycle3.mjs +4 -4
- package/src/runtime/memory/lib/memory-ops-policy.mjs +2 -1
- package/src/runtime/memory/lib/memory-session-merge.mjs +38 -0
- package/src/runtime/memory/lib/memory.mjs +88 -9
- package/src/runtime/memory/lib/model-profile.mjs +1 -1
- package/src/runtime/memory/lib/pg/adapter.mjs +15 -1
- package/src/runtime/memory/lib/pg/supervisor.mjs +12 -0
- package/src/runtime/memory/lib/runtime-fetcher.mjs +37 -3
- package/src/runtime/memory/lib/session-ingest.mjs +194 -0
- package/src/runtime/memory/lib/trace-store.mjs +96 -51
- package/src/runtime/memory/tool-defs.mjs +46 -37
- package/src/runtime/search/index.mjs +102 -466
- package/src/runtime/search/lib/web-tools.mjs +45 -25
- package/src/runtime/search/tool-defs.mjs +16 -23
- package/src/runtime/shared/abort-controller.mjs +1 -1
- package/src/runtime/shared/atomic-file.mjs +4 -3
- package/src/runtime/shared/background-tasks.mjs +122 -11
- package/src/runtime/shared/child-spawn-gate.mjs +145 -0
- package/src/runtime/shared/config.mjs +7 -4
- package/src/runtime/shared/err-text.mjs +131 -4
- package/src/runtime/shared/llm/cost.mjs +2 -2
- package/src/runtime/shared/llm/http-agent.mjs +23 -7
- package/src/runtime/shared/llm/index.mjs +34 -11
- package/src/runtime/shared/llm/usage-log.mjs +4 -4
- package/src/runtime/shared/markdown-frontmatter.mjs +56 -0
- package/src/runtime/shared/singleton-owner.mjs +104 -0
- package/src/runtime/shared/tool-execution-contract.mjs +199 -20
- package/src/runtime/shared/tool-execution-contract.test.mjs +183 -0
- package/src/runtime/shared/tool-surface.mjs +624 -98
- package/src/runtime/shared/user-data-guard.mjs +0 -2
- package/src/standalone/agent-task-status.mjs +203 -0
- package/src/standalone/agent-task-status.test.mjs +76 -0
- package/src/standalone/agent-tool.mjs +1913 -0
- package/src/standalone/channel-worker.mjs +370 -14
- package/src/standalone/explore-tool.mjs +165 -70
- package/src/standalone/folder-dialog.mjs +314 -0
- package/src/standalone/hook-bus.mjs +898 -22
- package/src/standalone/memory-runtime-proxy.mjs +320 -0
- package/src/standalone/projects.mjs +226 -0
- package/src/standalone/provider-admin.mjs +41 -24
- package/src/standalone/seeds.mjs +2 -69
- package/src/standalone/usage-dashboard.mjs +96 -8
- package/src/tui/App.jsx +4798 -2153
- package/src/tui/components/AnsiText.jsx +39 -28
- package/src/tui/components/ContextPanel.jsx +87 -29
- package/src/tui/components/Markdown.jsx +43 -77
- package/src/tui/components/MarkdownTable.jsx +9 -184
- package/src/tui/components/Message.jsx +28 -11
- package/src/tui/components/Picker.jsx +95 -56
- package/src/tui/components/PromptInput.jsx +367 -239
- package/src/tui/components/QueuedCommands.jsx +1 -1
- package/src/tui/components/SlashCommandPalette.jsx +27 -21
- package/src/tui/components/Spinner.jsx +67 -38
- package/src/tui/components/StatusLine.jsx +606 -38
- package/src/tui/components/TextEntryPanel.jsx +128 -9
- package/src/tui/components/ToolExecution.jsx +617 -368
- package/src/tui/components/TurnDone.jsx +3 -3
- package/src/tui/components/UsagePanel.jsx +3 -5
- package/src/tui/components/tool-output-format.mjs +365 -0
- package/src/tui/components/tool-output-format.test.mjs +220 -0
- package/src/tui/dist/index.mjs +8915 -2418
- package/src/tui/engine-runtime-notification.test.mjs +115 -0
- package/src/tui/engine-tool-result-text.test.mjs +75 -0
- package/src/tui/engine.mjs +1455 -279
- package/src/tui/figures.mjs +21 -40
- package/src/tui/index.jsx +75 -31
- package/src/tui/input-editing.mjs +25 -0
- package/src/tui/markdown/format-token.mjs +511 -68
- package/src/tui/markdown/format-token.test.mjs +216 -0
- package/src/tui/markdown/render-ansi.mjs +94 -0
- package/src/tui/markdown/render-ansi.test.mjs +108 -0
- package/src/tui/markdown/stream-fence.mjs +34 -0
- package/src/tui/markdown/stream-fence.test.mjs +26 -0
- package/src/tui/markdown/table-layout.mjs +250 -0
- package/src/tui/paste-attachments.mjs +0 -7
- package/src/tui/spinner-verbs.mjs +1 -2
- package/src/tui/statusline-ansi-bridge.mjs +172 -0
- package/src/tui/statusline-ansi-bridge.test.mjs +159 -0
- package/src/tui/theme.mjs +746 -24
- package/src/tui/time-format.mjs +1 -1
- package/src/tui/transcript-tool-failures.mjs +67 -0
- package/src/tui/transcript-tool-failures.test.mjs +111 -0
- package/src/ui/ansi.mjs +1 -2
- package/src/ui/markdown.mjs +85 -26
- package/src/ui/markdown.test.mjs +70 -0
- package/src/ui/model-display.mjs +121 -0
- package/src/ui/session-stats.mjs +44 -0
- package/src/ui/statusline-context-label.test.mjs +15 -0
- package/src/ui/statusline.mjs +386 -178
- package/src/ui/tool-card.mjs +3 -16
- package/src/vendor/statusline/bin/statusline-lib.mjs +8 -4
- package/src/vendor/statusline/bin/statusline-route.mjs +169 -37
- package/src/vendor/statusline/bin/statusline-route.test.mjs +80 -0
- package/src/vendor/statusline/scripts/lib/gateway-settings.mjs +3 -3
- package/src/vendor/statusline/src/gateway/claude-current.mjs +1 -1
- package/src/vendor/statusline/src/gateway/route-meta.mjs +44 -6
- package/src/vendor/statusline/src/gateway/session-routes.mjs +1 -1
- package/src/workflows/default/WORKFLOW.md +12 -5
- package/src/workflows/default/workflow.json +0 -1
- package/src/workflows/solo/WORKFLOW.md +15 -0
- package/src/workflows/solo/workflow.json +7 -0
- package/vendor/ink/build/output.js +6 -1
- package/src/agents/scheduler-task.md +0 -3
- package/src/agents/web-researcher/AGENT.md +0 -3
- package/src/agents/web-researcher/agent.json +0 -6
- package/src/agents/webhook-handler.md +0 -3
- package/src/rules/bridge/00-common.md +0 -5
- package/src/rules/bridge/30-explorer.md +0 -4
- package/src/rules/lead/00-tool-lead.md +0 -5
- package/src/rules/shared/00-language.md +0 -3
- package/src/runtime/agent/orchestrator/tools/builtin/native-edit-runner.mjs +0 -110
- package/src/runtime/agent/orchestrator/tools/mutation-content-cache.mjs +0 -67
- package/src/runtime/memory/lib/bridge-trace-queries.mjs +0 -120
- package/src/runtime/shared/llm/pid-cleanup.mjs +0 -27
- package/src/standalone/bridge-tool.mjs +0 -1414
- package/src/tui/runtime/shared/process-shutdown.mjs +0 -1
|
@@ -1,25 +1,31 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Agent Runtime — Cache Strategy
|
|
3
3
|
*
|
|
4
4
|
* Provider-level cache policy. Anthropic supports explicit cache_control
|
|
5
|
-
* breakpoints (up to 4 per request) — we
|
|
6
|
-
*
|
|
5
|
+
* breakpoints (up to 4 per request) — we spend them on the stable system /
|
|
6
|
+
* session prefix plus the reusable message tail. Non-breakpoint providers
|
|
7
|
+
* rely on provider-managed prefix routing or provider-local cache objects.
|
|
7
8
|
*
|
|
8
|
-
* Anthropic 4-BP layout
|
|
9
|
-
* BP_1
|
|
10
|
-
* BP_2 system
|
|
11
|
-
* BP_3
|
|
12
|
-
* BP_4 messages
|
|
9
|
+
* Anthropic 4-BP layout:
|
|
10
|
+
* BP_1 system#1 (1h) — shared tool policy + compact skill manifest
|
|
11
|
+
* BP_2 system#2 (1h) — role/system rules (Lead / agent / hidden role)
|
|
12
|
+
* BP_3 system#3 (1h) — stable memory/meta marker (sessionMarker system block; tier3)
|
|
13
|
+
* BP_4 messages (1h/5m) — sliding tool_result / prior user-text tail
|
|
13
14
|
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
* the
|
|
15
|
+
* Tool schemas still sit before system in the provider prompt prefix. We do
|
|
16
|
+
* not spend a separate cache_control slot on tools; the first system BP covers
|
|
17
|
+
* the preceding tool prefix via Anthropic prefix caching semantics. Keeping
|
|
18
|
+
* agent worker tool schemas byte-stable is therefore still load-bearing.
|
|
19
|
+
*
|
|
20
|
+
* Tier 3 gets its own BP because memory/meta context is stable within the
|
|
21
|
+
* session. The sliding messages BP handles tool_result accumulation and
|
|
22
|
+
* per-call task/event data without pinning volatile text into the 1h tier.
|
|
17
23
|
*
|
|
18
24
|
* Non-breakpoint providers:
|
|
19
25
|
* - OpenAI (public): prompt_cache_key + prompt_cache_retention=24h
|
|
20
|
-
* - OpenAI OAuth
|
|
21
|
-
* - Gemini:
|
|
22
|
-
*
|
|
26
|
+
* - OpenAI OAuth: prompt_cache_key only (server in-memory 5-10min)
|
|
27
|
+
* - Gemini: provider-managed explicit cachedContents with 1h TTL, plus
|
|
28
|
+
* implicit caching as a fallback when the prefix is below cache minimums.
|
|
23
29
|
* - xAI: x-grok-conv-id (server routing pin) + prompt_cache_key on
|
|
24
30
|
* Responses API. Treat as key-prefix, not implicit.
|
|
25
31
|
* - DeepSeek / OpenCode Go: automatic KV/prefix cache; observe provider
|
|
@@ -34,7 +40,7 @@ import { getHiddenRole } from '../internal-roles.mjs';
|
|
|
34
40
|
/**
|
|
35
41
|
* One-shot, LLM-only maintenance hidden roles (cycle1/cycle2/cycle3-agent):
|
|
36
42
|
* a fresh stateless session is created per call, asked exactly once, and
|
|
37
|
-
* closed (
|
|
43
|
+
* closed (agent-dispatch.mjs) — the per-batch user prompt can NEVER be reused.
|
|
38
44
|
* Writing a message-tail cache breakpoint on it just pays the 1.25x write
|
|
39
45
|
* premium for content read back 0 times. Identified by the declarative
|
|
40
46
|
* (kind:'maintenance' + toolSchemaProfile:'llm-only') pair rather than
|
|
@@ -60,7 +66,7 @@ function isOneShotMaintenanceRole(role) {
|
|
|
60
66
|
* '5m' → ephemeral 5m TTL (1.25x write premium, 0.1x read)
|
|
61
67
|
* 'none' → no breakpoint written on this layer
|
|
62
68
|
*
|
|
63
|
-
* Public
|
|
69
|
+
* Public agents stay resumable for up to 1h (the terminal-reap window)
|
|
64
70
|
* for same-task reuse, so their message tail uses 1h too. Hidden multi-turn
|
|
65
71
|
* roles (explorer / scheduler / webhook) run a single fan-out or entry-driven
|
|
66
72
|
* session that is not resumed for same-task reuse, so their volatile tail stays
|
|
@@ -80,10 +86,10 @@ export function resolveCacheStrategy(role) {
|
|
|
80
86
|
return { tools: 'none', system: 'none', tier3: 'none', messages: 'none' };
|
|
81
87
|
}
|
|
82
88
|
if (getHiddenRole(role)) {
|
|
83
|
-
return { tools: '
|
|
89
|
+
return { tools: 'none', system: '1h', tier3: '1h', messages: '5m' };
|
|
84
90
|
}
|
|
85
|
-
// Public
|
|
86
|
-
return { tools: '
|
|
91
|
+
// Public agents: resumable up to 1h for same-task reuse -> 1h tail.
|
|
92
|
+
return { tools: 'none', system: '1h', tier3: '1h', messages: '1h' };
|
|
87
93
|
}
|
|
88
94
|
|
|
89
95
|
/**
|
|
@@ -98,6 +104,7 @@ export function resolveCacheStrategy(role) {
|
|
|
98
104
|
// Provider cache capability kinds:
|
|
99
105
|
// 'explicit-breakpoint' — explicit provider-side cache_control writes
|
|
100
106
|
// 'key-prefix' — provider-managed shard keyed by cache key/session
|
|
107
|
+
// 'managed-explicit' — provider object creates/attaches explicit caches
|
|
101
108
|
// 'implicit-observed' — cache hits are observable but not guaranteed warm
|
|
102
109
|
// 'none' — no API-level cache knob/metric
|
|
103
110
|
const PROVIDER_CACHE_CAPABILITY = Object.freeze({
|
|
@@ -107,7 +114,7 @@ const PROVIDER_CACHE_CAPABILITY = Object.freeze({
|
|
|
107
114
|
'openai-oauth': 'key-prefix',
|
|
108
115
|
'xai': 'key-prefix',
|
|
109
116
|
'grok-oauth': 'key-prefix',
|
|
110
|
-
'gemini': '
|
|
117
|
+
'gemini': 'managed-explicit',
|
|
111
118
|
'deepseek': 'implicit-observed',
|
|
112
119
|
'opencode-go': 'implicit-observed',
|
|
113
120
|
});
|
|
@@ -118,7 +125,9 @@ export function cacheCapabilityForProvider(provider) {
|
|
|
118
125
|
|
|
119
126
|
export function shouldMarkWarmForProvider(provider) {
|
|
120
127
|
const capability = cacheCapabilityForProvider(provider);
|
|
121
|
-
return capability === 'explicit-breakpoint'
|
|
128
|
+
return capability === 'explicit-breakpoint'
|
|
129
|
+
|| capability === 'key-prefix'
|
|
130
|
+
|| capability === 'managed-explicit';
|
|
122
131
|
}
|
|
123
132
|
|
|
124
133
|
export function shouldRecordObservedForProvider(provider) {
|
|
@@ -183,7 +192,7 @@ function cleanString(value) {
|
|
|
183
192
|
|
|
184
193
|
function normalizePromptCacheNamespace(value) {
|
|
185
194
|
const s = String(value || '').trim() || 'mixdog-shared';
|
|
186
|
-
// Keep the key boring for OpenAI
|
|
195
|
+
// Keep the key boring for OpenAI OAuth's 64-char prompt_cache_key cap while
|
|
187
196
|
// preserving user overrides as much as possible.
|
|
188
197
|
return s.replace(/[^A-Za-z0-9_-]+/g, '-').replace(/^-+|-+$/g, '') || 'mixdog-shared';
|
|
189
198
|
}
|
|
@@ -358,7 +367,7 @@ export function buildProviderCacheOpts(provider, sessionId, role) {
|
|
|
358
367
|
}
|
|
359
368
|
if (provider === 'openai') {
|
|
360
369
|
// Public OpenAI API: prompt_cache_retention extends prefix retention.
|
|
361
|
-
// openai-oauth
|
|
370
|
+
// openai-oauth rejects the header — falls through to default.
|
|
362
371
|
return { cacheRetention: '24h' };
|
|
363
372
|
}
|
|
364
373
|
return {};
|
|
@@ -1,28 +1,26 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Agent Runtime — shared session builder.
|
|
3
3
|
*
|
|
4
|
-
* Single source of truth for
|
|
4
|
+
* Single source of truth for agent session creation + role/preset
|
|
5
5
|
* telemetry. Both entry points route through this helper:
|
|
6
6
|
*
|
|
7
|
-
* - `
|
|
7
|
+
* - `agent-runtime/agent-dispatch.mjs` — internal callers
|
|
8
8
|
* (memory-cycle, scheduler, webhook) dispatching via
|
|
9
|
-
* `
|
|
10
|
-
* -
|
|
11
|
-
* bridge dispatches into user-workflow roles.
|
|
9
|
+
* `makeAgentDispatch`.
|
|
10
|
+
* - Lead-originated agent dispatches into configured workflow agents.
|
|
12
11
|
*
|
|
13
12
|
* Before this helper, the two paths carried separate `createSession` +
|
|
14
|
-
* `
|
|
15
|
-
* the trace so cache-hit analysis missed every
|
|
13
|
+
* `traceAgentPreset` blocks. Lead-direct dispatches silently skipped
|
|
14
|
+
* the trace so cache-hit analysis missed every public agent call.
|
|
16
15
|
*
|
|
17
16
|
* Preset resolution stays with each caller since they read from
|
|
18
|
-
* different sources
|
|
19
|
-
* hidden-role map first, then user-workflow.json). The helper takes
|
|
20
|
-
* already-resolved primitives.
|
|
17
|
+
* different sources. The helper takes already-resolved primitives.
|
|
21
18
|
*/
|
|
22
19
|
|
|
23
20
|
import { createSession } from '../session/manager.mjs';
|
|
24
|
-
import {
|
|
25
|
-
import {
|
|
21
|
+
import { traceAgentPreset } from '../agent-trace.mjs';
|
|
22
|
+
import { resolveAgentSessionPermission } from '../internal-roles.mjs';
|
|
23
|
+
import { loadConfig } from '../config.mjs';
|
|
26
24
|
|
|
27
25
|
/**
|
|
28
26
|
* @param {object} opts
|
|
@@ -30,10 +28,10 @@ import { resolveBridgeSessionPermission } from '../internal-roles.mjs';
|
|
|
30
28
|
* @param {string} opts.presetName — resolved preset identifier
|
|
31
29
|
* @param {object} opts.preset — resolved preset object from agent-config
|
|
32
30
|
* @param {object} opts.runtimeSpec — resolveRuntimeSpec output; must carry .scopeKey / .lane
|
|
33
|
-
* @param {string} [opts.permission] — 'read' | 'read-write' |
|
|
34
|
-
* @param {string|null} [opts.cwd] — absolute working dir; null is the fixed
|
|
35
|
-
* @param {string} [opts.owner='
|
|
36
|
-
* @param {string} [opts.permissionMode] —
|
|
31
|
+
* @param {string} [opts.permission] — 'none' | 'read' | 'read-write' | 'mcp' | 'full' | null
|
|
32
|
+
* @param {string|null} [opts.cwd] — absolute working dir; null is the fixed agent sentinel meaning "no caller workspace context"
|
|
33
|
+
* @param {string} [opts.owner='agent']
|
|
34
|
+
* @param {string} [opts.permissionMode] — permissionMode forwarded from the MCP payload ('bypassPermissions', 'acceptEdits', 'plan', 'dontAsk', 'default')
|
|
37
35
|
* @param {string[]} [opts.schemaAllowedTools] — schema-level allowlist from a hidden-role toolSchemaProfile
|
|
38
36
|
* @param {string} [opts.sourceType]
|
|
39
37
|
* @param {string} [opts.sourceName]
|
|
@@ -41,17 +39,16 @@ import { resolveBridgeSessionPermission } from '../internal-roles.mjs';
|
|
|
41
39
|
* @param {number} [opts.maxLoopIterations]
|
|
42
40
|
* @param {string} [opts.parentSessionId]
|
|
43
41
|
* @param {string|null} [opts.ownerSessionId] - owning Mixdog MCP instance id for statusline isolation
|
|
44
|
-
* @param {boolean} [opts.skipRoleReminder=false] — Pool C suppresses Tier 3 reminder
|
|
45
42
|
* @returns {{ session: object, effectiveCwd: string|null }}
|
|
46
43
|
*/
|
|
47
|
-
export function
|
|
44
|
+
export function prepareAgentSession({
|
|
48
45
|
role,
|
|
49
46
|
presetName,
|
|
50
47
|
preset,
|
|
51
48
|
runtimeSpec,
|
|
52
49
|
permission,
|
|
53
50
|
cwd,
|
|
54
|
-
owner = '
|
|
51
|
+
owner = 'agent',
|
|
55
52
|
permissionMode,
|
|
56
53
|
sourceType,
|
|
57
54
|
sourceName,
|
|
@@ -60,13 +57,12 @@ export function prepareBridgeSession({
|
|
|
60
57
|
parentSessionId,
|
|
61
58
|
ownerSessionId,
|
|
62
59
|
clientHostPid,
|
|
63
|
-
|
|
64
|
-
skipRoleReminder = false,
|
|
60
|
+
agentTag,
|
|
65
61
|
cacheKeyOverride,
|
|
66
62
|
schemaAllowedTools,
|
|
67
63
|
}) {
|
|
68
|
-
const effectivePermission =
|
|
69
|
-
// Pass cwd through verbatim — null is the fixed
|
|
64
|
+
const effectivePermission = resolveAgentSessionPermission(role, permission);
|
|
65
|
+
// Pass cwd through verbatim — null is the fixed agent sentinel meaning
|
|
70
66
|
// "no caller workspace context" (cycle1-agent shards, etc). Upgrading
|
|
71
67
|
// null → process.cwd() here would defeat cache-shard fork suppression.
|
|
72
68
|
// Downstream collectors (collect.mjs) handle null as "no project cwd".
|
|
@@ -74,6 +70,16 @@ export function prepareBridgeSession({
|
|
|
74
70
|
const effectiveOwnerSessionId = ownerSessionId === undefined
|
|
75
71
|
? (process.env.MIXDOG_OWNER_SESSION_ID || null)
|
|
76
72
|
: ownerSessionId;
|
|
73
|
+
let compaction = null;
|
|
74
|
+
try {
|
|
75
|
+
const cfg = loadConfig({ secrets: false });
|
|
76
|
+
// Agent worker sessions should keep the higher-quality semantic compact
|
|
77
|
+
// path even when the Lead session uses recall-fasttrack for cheap
|
|
78
|
+
// auto-clear/auto-compact. Cycle maintenance prompts are small enough
|
|
79
|
+
// that this normally only matters for long-lived worker conversations.
|
|
80
|
+
const base = cfg?.compaction && typeof cfg.compaction === 'object' ? cfg.compaction : {};
|
|
81
|
+
compaction = { ...base, type: '1', compactType: '1' };
|
|
82
|
+
} catch { /* config is best-effort for agent compaction policy */ }
|
|
77
83
|
const sessionOpts = {
|
|
78
84
|
preset,
|
|
79
85
|
owner,
|
|
@@ -87,18 +93,18 @@ export function prepareBridgeSession({
|
|
|
87
93
|
sourceName: sourceName || undefined,
|
|
88
94
|
ownerSessionId: effectiveOwnerSessionId || null,
|
|
89
95
|
clientHostPid: clientHostPid || null,
|
|
96
|
+
compaction: compaction || undefined,
|
|
90
97
|
};
|
|
91
|
-
if (
|
|
98
|
+
if (agentTag) sessionOpts.agentTag = agentTag;
|
|
92
99
|
if (effectivePermission) sessionOpts.permission = effectivePermission;
|
|
93
100
|
if (permissionMode) sessionOpts.permissionMode = permissionMode;
|
|
94
|
-
if (skipRoleReminder) sessionOpts.skipRoleReminder = true;
|
|
95
101
|
if (cacheKeyOverride) sessionOpts.cacheKeyOverride = cacheKeyOverride;
|
|
96
102
|
if (Array.isArray(schemaAllowedTools)) {
|
|
97
103
|
sessionOpts.schemaAllowedTools = schemaAllowedTools;
|
|
98
104
|
}
|
|
99
105
|
const session = createSession(sessionOpts);
|
|
100
106
|
try {
|
|
101
|
-
|
|
107
|
+
traceAgentPreset({
|
|
102
108
|
sessionId: session.id,
|
|
103
109
|
role: role || null,
|
|
104
110
|
presetName: presetName || null,
|