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
|
@@ -266,7 +266,7 @@ export function addPending(dataDir, handle, tool, queries, callerSessionId, clie
|
|
|
266
266
|
/**
|
|
267
267
|
* Best-effort check: is there at least one non-expired in-flight dispatch
|
|
268
268
|
* recorded for this dataDir? Used by the scheduler's idle-state probe so
|
|
269
|
-
* background tasks stay suppressed while
|
|
269
|
+
* background tasks stay suppressed while an agent dispatch is still
|
|
270
270
|
* running. Never throws.
|
|
271
271
|
*/
|
|
272
272
|
export function hasPending(dataDir) {
|
|
@@ -1,20 +1,17 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Internal hidden roles — Mixdog-managed, user-untouchable.
|
|
3
3
|
*
|
|
4
|
-
* Unlike
|
|
5
|
-
* these roles are NEVER exposed to callers of the `bridge` MCP tool. They are
|
|
4
|
+
* Unlike public workflow agents, these hidden roles are NEVER exposed to callers of the `agent` tool. They are
|
|
6
5
|
* invoked only by internal handlers (explore / recall / search) and carry
|
|
7
6
|
* their own system prompt + tool-set policy.
|
|
8
7
|
*
|
|
9
|
-
* Lookup order (
|
|
8
|
+
* Lookup order (agent-dispatch.resolvePresetName):
|
|
10
9
|
* 1. explicit preset arg
|
|
11
10
|
* 2. opts.preset
|
|
12
|
-
* 3. hidden-role registry (defaults/hidden-roles.json
|
|
13
|
-
* 4. user-workflow.json[role] ← user-owned
|
|
11
|
+
* 3. hidden-role registry (defaults/hidden-roles.json + systemFile frontmatter)
|
|
14
12
|
*
|
|
15
|
-
* Role definitions live in defaults/hidden-roles.json
|
|
16
|
-
*
|
|
17
|
-
* workflow JSON.
|
|
13
|
+
* Role definitions live in defaults/hidden-roles.json and the referenced
|
|
14
|
+
* systemFile markdown frontmatter. Editing those files is a Mixdog source change.
|
|
18
15
|
*
|
|
19
16
|
* The preset names refer to entries seeded in mixdog-config.json (agent.presets)
|
|
20
17
|
* via DEFAULT_PRESETS (see config.mjs). If the user deletes the referenced preset
|
|
@@ -28,41 +25,91 @@
|
|
|
28
25
|
* webhook). Receive only their own self section in BP2.
|
|
29
26
|
*
|
|
30
27
|
* Permission classification:
|
|
31
|
-
* - 'read' : read-only —
|
|
28
|
+
* - 'read' : read-only — apply_patch/shell blocked at loop.mjs runtime
|
|
32
29
|
* guard with the same error string public read-only roles see.
|
|
33
30
|
* - 'read-write' : full tool surface — used by hidden roles that legitimately
|
|
34
31
|
* mutate state (scheduler-task launches commands,
|
|
35
|
-
* webhook-handler persists payloads).
|
|
32
|
+
* webhook-handler persists payloads). agent-dispatch honors this
|
|
36
33
|
* declaratively instead of forcing every hidden role to 'read'.
|
|
37
34
|
*
|
|
38
35
|
* Tool schema profile:
|
|
39
|
-
* - '
|
|
40
|
-
* - '
|
|
36
|
+
* - 'none' : no tools exposed; pure transform/classifier roles.
|
|
37
|
+
* - 'read' : read/search/code-navigation tools only.
|
|
38
|
+
* - 'full' : shared agent tool schema for provider cache reuse.
|
|
41
39
|
*
|
|
42
|
-
*
|
|
43
|
-
*
|
|
40
|
+
* Role-specific instruction metadata (consumed by rules-builder.cjs
|
|
41
|
+
* buildAgentRoleSpecificContent + collect.mjs):
|
|
44
42
|
* - inboundEvent : role reports results back to Lead and must carry the
|
|
45
|
-
* skip-protocol rule (rules/
|
|
46
|
-
* in its BP2
|
|
43
|
+
* skip-protocol rule (rules/agent/20-skip-protocol.md)
|
|
44
|
+
* in its BP2 role-rule block so no-op outputs opt out of the Lead
|
|
47
45
|
* inject.
|
|
48
46
|
* - instructionDir : DATA_DIR subdir whose *.md tree is folded into the
|
|
49
|
-
* role's
|
|
47
|
+
* role's BP4-adjacent user/task data (webhook-handler →
|
|
50
48
|
* webhooks, scheduler-task → schedules).
|
|
51
49
|
*/
|
|
52
50
|
|
|
53
51
|
import { readFileSync, statSync } from 'fs'
|
|
54
52
|
import { join } from 'path'
|
|
55
53
|
import { mixdogRoot } from '../../shared/plugin-paths.mjs'
|
|
54
|
+
import {
|
|
55
|
+
normalizeAgentPermissionOrNone,
|
|
56
|
+
parseMarkdownFrontmatter,
|
|
57
|
+
} from '../../shared/markdown-frontmatter.mjs'
|
|
56
58
|
|
|
57
59
|
// Resolve the path to defaults/hidden-roles.json once.
|
|
60
|
+
const _MIXDOG_ROOT = mixdogRoot()
|
|
58
61
|
const _HIDDEN_ROLES_PATH = (() => {
|
|
59
|
-
|
|
60
|
-
return join(root, 'defaults', 'hidden-roles.json')
|
|
62
|
+
return join(_MIXDOG_ROOT, 'defaults', 'hidden-roles.json')
|
|
61
63
|
})()
|
|
62
64
|
|
|
63
65
|
/** @type {{ mtime: number, map: object } | null} */
|
|
64
66
|
let _hiddenRolesCache = null
|
|
65
67
|
|
|
68
|
+
function _mtimeSafe(file) {
|
|
69
|
+
try { return statSync(file).mtimeMs } catch { return 0 }
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
function _hiddenRolesDependencyMtime() {
|
|
73
|
+
let mtime = _mtimeSafe(_HIDDEN_ROLES_PATH)
|
|
74
|
+
try {
|
|
75
|
+
const raw = JSON.parse(readFileSync(_HIDDEN_ROLES_PATH, 'utf8'))
|
|
76
|
+
for (const entry of (raw.roles || [])) {
|
|
77
|
+
const systemFile = typeof entry?.systemFile === 'string' ? entry.systemFile.trim() : ''
|
|
78
|
+
if (!systemFile) continue
|
|
79
|
+
mtime = Math.max(mtime, _mtimeSafe(join(_MIXDOG_ROOT, systemFile)))
|
|
80
|
+
}
|
|
81
|
+
} catch {}
|
|
82
|
+
return mtime
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
function _loadHiddenRoleFrontmatter(systemFile) {
|
|
86
|
+
const rel = typeof systemFile === 'string' ? systemFile.trim() : ''
|
|
87
|
+
if (!rel) return {}
|
|
88
|
+
try {
|
|
89
|
+
return parseMarkdownFrontmatter(readFileSync(join(_MIXDOG_ROOT, rel), 'utf8'))
|
|
90
|
+
} catch {
|
|
91
|
+
return {}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
function _mergeHiddenRoleFrontmatter(entry) {
|
|
96
|
+
const fm = _loadHiddenRoleFrontmatter(entry.systemFile)
|
|
97
|
+
const merged = { ...entry }
|
|
98
|
+
const permission = normalizeAgentPermissionOrNone(fm.permission)
|
|
99
|
+
if (permission) merged.permission = permission
|
|
100
|
+
for (const key of ['toolSchemaProfile', 'kind', 'slot', 'maintKey', 'instructionDir']) {
|
|
101
|
+
if (typeof fm[key] === 'string' && fm[key].trim()) merged[key] = fm[key].trim()
|
|
102
|
+
}
|
|
103
|
+
for (const key of ['inboundEvent']) {
|
|
104
|
+
if (typeof fm[key] === 'string' && fm[key].trim()) {
|
|
105
|
+
const raw = fm[key].trim().toLowerCase()
|
|
106
|
+
if (raw === 'true') merged[key] = true
|
|
107
|
+
else if (raw === 'false') merged[key] = false
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
return merged
|
|
111
|
+
}
|
|
112
|
+
|
|
66
113
|
/**
|
|
67
114
|
* Read and parse defaults/hidden-roles.json. Throws on missing/malformed.
|
|
68
115
|
*/
|
|
@@ -71,7 +118,7 @@ function _loadHiddenRoles() {
|
|
|
71
118
|
const raw = JSON.parse(readFileSync(_HIDDEN_ROLES_PATH, 'utf8'))
|
|
72
119
|
const map = Object.create(null)
|
|
73
120
|
for (const entry of (raw.roles || [])) {
|
|
74
|
-
if (entry && entry.name) map[entry.name] = Object.freeze(
|
|
121
|
+
if (entry && entry.name) map[entry.name] = Object.freeze(_mergeHiddenRoleFrontmatter(entry))
|
|
75
122
|
}
|
|
76
123
|
return Object.freeze(map)
|
|
77
124
|
} catch (err) {
|
|
@@ -88,7 +135,7 @@ function _loadHiddenRoles() {
|
|
|
88
135
|
*/
|
|
89
136
|
function _getHiddenRoles() {
|
|
90
137
|
try {
|
|
91
|
-
const mtime =
|
|
138
|
+
const mtime = _hiddenRolesDependencyMtime()
|
|
92
139
|
if (_hiddenRolesCache && mtime <= _hiddenRolesCache.mtime) {
|
|
93
140
|
return _hiddenRolesCache.map
|
|
94
141
|
}
|
|
@@ -114,10 +161,11 @@ export function getHiddenRole(name) {
|
|
|
114
161
|
}
|
|
115
162
|
|
|
116
163
|
/**
|
|
117
|
-
* Resolve permission stamped on a
|
|
164
|
+
* Resolve permission stamped on a agent session. Hidden roles declared
|
|
118
165
|
* `permission: 'read'` are read-locked — caller opts cannot upgrade them.
|
|
166
|
+
* Other built-in permissions include `none`, `read-write`, `mcp`, and `full`.
|
|
119
167
|
*/
|
|
120
|
-
export function
|
|
168
|
+
export function resolveAgentSessionPermission(role, callerPermission) {
|
|
121
169
|
const hidden = getHiddenRole(role)
|
|
122
170
|
if (hidden && hidden.permission === 'read') return 'read'
|
|
123
171
|
if (callerPermission != null && callerPermission !== '') return callerPermission
|
|
@@ -126,7 +174,7 @@ export function resolveBridgeSessionPermission(role, callerPermission) {
|
|
|
126
174
|
}
|
|
127
175
|
|
|
128
176
|
/**
|
|
129
|
-
* Boolean check — useful for branching inside
|
|
177
|
+
* Boolean check — useful for branching inside agent-dispatch / session-manager.
|
|
130
178
|
*/
|
|
131
179
|
export function isHiddenRole(name) {
|
|
132
180
|
if (!name) return false
|
|
@@ -143,7 +191,7 @@ export function listHiddenRoleNames() {
|
|
|
143
191
|
|
|
144
192
|
/**
|
|
145
193
|
* List hidden role names matching a given kind ('retrieval' | 'maintenance').
|
|
146
|
-
* Consumed by collect.mjs to drive BP2
|
|
194
|
+
* Consumed by collect.mjs to drive BP2 role-shard classification dynamically
|
|
147
195
|
* instead of hard-coding role-name sets.
|
|
148
196
|
*/
|
|
149
197
|
export function listHiddenRolesByKind(kind) {
|
|
@@ -168,7 +216,7 @@ export function getRoleCatalogShareAgents(name) {
|
|
|
168
216
|
|
|
169
217
|
/**
|
|
170
218
|
* True when a hidden role reports results back to Lead and must carry the
|
|
171
|
-
* skip-protocol rule in its BP2
|
|
219
|
+
* skip-protocol rule in its BP2 role-rule block. Replaces the hard-coded
|
|
172
220
|
* INBOUND_EVENT_ROLES set in collect.mjs.
|
|
173
221
|
*/
|
|
174
222
|
export function isInboundEventRole(name) {
|
|
@@ -177,9 +225,9 @@ export function isInboundEventRole(name) {
|
|
|
177
225
|
}
|
|
178
226
|
|
|
179
227
|
/**
|
|
180
|
-
* Return the DATA_DIR subdir whose *.md tree
|
|
181
|
-
*
|
|
182
|
-
* webhook/scheduler ternary in rules-builder.cjs
|
|
228
|
+
* Return the DATA_DIR subdir whose *.md tree rides as BP4-adjacent
|
|
229
|
+
* user/task data, or null when the role declares none. Replaces the
|
|
230
|
+
* webhook/scheduler ternary in rules-builder.cjs buildAgentRoleSpecificContent.
|
|
183
231
|
*/
|
|
184
232
|
export function getRoleInstructionDir(name) {
|
|
185
233
|
const hidden = getHiddenRole(name)
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Internal tool registry — in-process tools exposed to external LLMs via
|
|
2
|
+
* Internal tool registry — in-process tools exposed to external LLMs via the agent runtime.
|
|
3
3
|
*
|
|
4
4
|
* Populated by agent/index.mjs.handleToolCall when the server injects a
|
|
5
5
|
* context carrying { toolExecutor, internalTools }. The executor dispatches
|
|
@@ -9,10 +9,10 @@
|
|
|
9
9
|
* Orchestrator modules (session/manager.mjs, session/loop.mjs) import from
|
|
10
10
|
* here instead of going through mcp/client.mjs for internal tools.
|
|
11
11
|
*
|
|
12
|
-
* Permission enforcement
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
12
|
+
* Permission enforcement has been removed (every tool call is trusted). The
|
|
13
|
+
* only remaining dispatch-time gate is the architectural scoping in
|
|
14
|
+
* _preDispatchDeny() in session/loop.mjs (agent-worker control-plane reject +
|
|
15
|
+
* no-tool role guard) — not a permission check. No gating is needed here.
|
|
16
16
|
*/
|
|
17
17
|
|
|
18
18
|
let _executor = null;
|
|
@@ -23,7 +23,6 @@ let _bootReady = false;
|
|
|
23
23
|
let _bootResolver = null;
|
|
24
24
|
const _bootPromise = new Promise((r) => { _bootResolver = r; });
|
|
25
25
|
export function markBootReady() { if (_bootReady) return; _bootReady = true; _bootResolver(); }
|
|
26
|
-
export async function awaitBootReady(timeoutMs = 2000) { if (_bootReady) return; await Promise.race([_bootPromise, new Promise((r) => setTimeout(r, timeoutMs))]); }
|
|
27
26
|
|
|
28
27
|
// Per-tool executor overrides. Populated by addInternalTools() for extra
|
|
29
28
|
// internal tools that bypass the main dispatch (tools.json + dispatchTool).
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
import { Client } from '@modelcontextprotocol/sdk/client/index.js';
|
|
2
|
-
import { StdioClientTransport } from '@modelcontextprotocol/sdk/client/stdio.js';
|
|
3
|
-
import { StreamableHTTPClientTransport } from '@modelcontextprotocol/sdk/client/streamableHttp.js';
|
|
4
1
|
import { readFileSync, existsSync, mkdirSync, writeFileSync } from 'fs';
|
|
5
2
|
import { join } from 'path';
|
|
6
3
|
import { tmpdir } from 'os';
|
|
@@ -19,6 +16,7 @@ const AUTO_DETECT_PORTS = {
|
|
|
19
16
|
const DEFAULT_MCP_CALL_TIMEOUT_MS = 0;
|
|
20
17
|
// --- State ---
|
|
21
18
|
const servers = new Map();
|
|
19
|
+
let mcpSdkPromise = null;
|
|
22
20
|
// Memo for mcpToolHasField(name, field) — keyed by `${toolName}|${field}`.
|
|
23
21
|
// The lookup (regex parse + servers Map get + tools.find + schema property
|
|
24
22
|
// inspection) runs on every MCP tool invocation but its result only changes
|
|
@@ -33,6 +31,19 @@ function mcpLog(line) {
|
|
|
33
31
|
if (process.env.MIXDOG_QUIET_MCP_LOG) return;
|
|
34
32
|
process.stderr.write(line);
|
|
35
33
|
}
|
|
34
|
+
|
|
35
|
+
async function loadMcpSdk() {
|
|
36
|
+
mcpSdkPromise ??= Promise.all([
|
|
37
|
+
import('@modelcontextprotocol/sdk/client/index.js'),
|
|
38
|
+
import('@modelcontextprotocol/sdk/client/stdio.js'),
|
|
39
|
+
import('@modelcontextprotocol/sdk/client/streamableHttp.js'),
|
|
40
|
+
]).then(([clientMod, stdioMod, httpMod]) => ({
|
|
41
|
+
Client: clientMod.Client,
|
|
42
|
+
StdioClientTransport: stdioMod.StdioClientTransport,
|
|
43
|
+
StreamableHTTPClientTransport: httpMod.StreamableHTTPClientTransport,
|
|
44
|
+
}));
|
|
45
|
+
return mcpSdkPromise;
|
|
46
|
+
}
|
|
36
47
|
// --- Public API ---
|
|
37
48
|
/**
|
|
38
49
|
* Connect to MCP servers defined in config.
|
|
@@ -253,7 +264,6 @@ export function mcpToolHasField(name, field) {
|
|
|
253
264
|
/**
|
|
254
265
|
* Disconnect all MCP servers.
|
|
255
266
|
*/
|
|
256
|
-
export const drainMcpClients = disconnectAll;
|
|
257
267
|
export async function disconnectAll() {
|
|
258
268
|
for (const [name, server] of servers) {
|
|
259
269
|
try {
|
|
@@ -264,12 +274,8 @@ export async function disconnectAll() {
|
|
|
264
274
|
}
|
|
265
275
|
_invalidateMcpToolFieldMemo();
|
|
266
276
|
}
|
|
267
|
-
/**
|
|
268
|
-
* Load MCP server configs from a JSON file.
|
|
269
|
-
* Supports both `{ mcpServers: { ... } }` and flat `{ name: { ... } }` format.
|
|
270
|
-
*/
|
|
271
|
-
|
|
272
277
|
async function connectServer(name, cfg) {
|
|
278
|
+
const { Client, StdioClientTransport, StreamableHTTPClientTransport } = await loadMcpSdk();
|
|
273
279
|
const client = new Client({ name: `mixdog-agent/${name}`, version: '1.0.0' });
|
|
274
280
|
let transport;
|
|
275
281
|
// Auto-detect: read port from a running service's port file
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
export const EXTENDED_CACHE_TTL_BETA_HEADER = 'extended-cache-ttl-2025-04-11';
|
|
2
|
+
export const INTERLEAVED_THINKING_BETA_HEADER = 'interleaved-thinking-2025-05-14';
|
|
2
3
|
export const FAST_MODE_BETA_HEADER = 'fast-mode-2026-02-01';
|
|
4
|
+
export const TOOL_SEARCH_BETA_HEADER = 'advanced-tool-use-2025-11-20';
|
|
3
5
|
|
|
4
6
|
export function supportsAnthropicFastMode(model) {
|
|
5
7
|
const id = String(model || '').toLowerCase().replace(/\./g, '-');
|
|
@@ -7,8 +9,9 @@ export function supportsAnthropicFastMode(model) {
|
|
|
7
9
|
}
|
|
8
10
|
|
|
9
11
|
export function buildAnthropicBetaHeaders({
|
|
10
|
-
base = EXTENDED_CACHE_TTL_BETA_HEADER
|
|
12
|
+
base = `${INTERLEAVED_THINKING_BETA_HEADER},${EXTENDED_CACHE_TTL_BETA_HEADER}`,
|
|
11
13
|
fastMode = false,
|
|
14
|
+
toolSearch = false,
|
|
12
15
|
} = {}) {
|
|
13
16
|
const headers = String(base || '')
|
|
14
17
|
.split(',')
|
|
@@ -17,5 +20,8 @@ export function buildAnthropicBetaHeaders({
|
|
|
17
20
|
if (fastMode && !headers.includes(FAST_MODE_BETA_HEADER)) {
|
|
18
21
|
headers.push(FAST_MODE_BETA_HEADER);
|
|
19
22
|
}
|
|
23
|
+
if (toolSearch && !headers.includes(TOOL_SEARCH_BETA_HEADER)) {
|
|
24
|
+
headers.push(TOOL_SEARCH_BETA_HEADER);
|
|
25
|
+
}
|
|
20
26
|
return headers.join(',');
|
|
21
27
|
}
|