mixdog 0.9.152 → 0.9.154
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/LICENSES/browser-import-NOTICE.txt +11 -0
- package/NOTICE.md +11 -0
- package/README.md +8 -10
- package/package.json +19 -3
- package/scripts/computer-task-cost-report.mjs +144 -0
- package/scripts/run-office-live-tests.mjs +32 -0
- package/src/agents/front-worker/AGENT.md +13 -0
- package/src/agents/front-worker/agent.json +6 -0
- package/src/agents/heavy-worker/AGENT.md +10 -11
- package/src/agents/heavy-worker/agent.json +1 -1
- package/src/agents/maintainer/AGENT.md +0 -2
- package/src/agents/reviewer/AGENT.md +9 -13
- package/src/agents/reviewer/agent.json +1 -1
- package/src/agents/security/AGENT.md +14 -0
- package/src/agents/security/agent.json +6 -0
- package/src/agents/worker/AGENT.md +8 -8
- package/src/agents/worker/agent.json +1 -1
- package/src/agents/writer/AGENT.md +14 -0
- package/src/agents/writer/agent.json +6 -0
- package/src/rules/agent/00-common.md +4 -7
- package/src/rules/lead/01-general.md +0 -3
- package/src/rules/shared/10-tool-workflow.md +10 -2
- package/src/rules/shared/60-verification.md +2 -0
- package/src/runtime/agent/orchestrator/agent-runtime/agent-dispatch.mjs +183 -26
- package/src/runtime/agent/orchestrator/agent-runtime/session-builder.mjs +4 -0
- package/src/runtime/agent/orchestrator/cache-break-trace.mjs +109 -0
- package/src/runtime/agent/orchestrator/config.mjs +7 -2
- package/src/runtime/agent/orchestrator/providers/admission-scheduler.mjs +16 -3
- package/src/runtime/agent/orchestrator/providers/lib/anthropic-request-utils.mjs +9 -1
- package/src/runtime/agent/orchestrator/providers/media-normalization.mjs +30 -9
- package/src/runtime/agent/orchestrator/providers/openai-codex-metadata.mjs +18 -26
- package/src/runtime/agent/orchestrator/providers/openai-oauth-http-sse.mjs +25 -2
- package/src/runtime/agent/orchestrator/providers/openai-oauth-ws.mjs +103 -10
- package/src/runtime/agent/orchestrator/providers/openai-turn-state.mjs +68 -0
- package/src/runtime/agent/orchestrator/providers/openai-ws-delta.mjs +36 -11
- package/src/runtime/agent/orchestrator/providers/openai-ws-pool.mjs +140 -86
- package/src/runtime/agent/orchestrator/providers/openai-ws-stream.mjs +9 -13
- package/src/runtime/agent/orchestrator/session/agent-loop.mjs +72 -4
- package/src/runtime/agent/orchestrator/session/browser-snapshot-supersession.mjs +61 -0
- package/src/runtime/agent/orchestrator/session/compact/handoff.mjs +0 -22
- package/src/runtime/agent/orchestrator/session/compact/messages.mjs +2 -2
- package/src/runtime/agent/orchestrator/session/compact/runner.mjs +11 -23
- package/src/runtime/agent/orchestrator/session/compact/summary.mjs +28 -269
- package/src/runtime/agent/orchestrator/session/compact.mjs +0 -6
- package/src/runtime/agent/orchestrator/session/context-utils.mjs +86 -11
- package/src/runtime/agent/orchestrator/session/eager-dispatch.mjs +17 -1
- package/src/runtime/agent/orchestrator/session/image-strip-recovery.mjs +12 -8
- package/src/runtime/agent/orchestrator/session/loop/compact-policy.mjs +110 -2
- package/src/runtime/agent/orchestrator/session/loop/pre-dispatch-deny.mjs +3 -16
- package/src/runtime/agent/orchestrator/session/loop/recall-fasttrack.mjs +80 -18
- package/src/runtime/agent/orchestrator/session/loop/steering.mjs +6 -0
- package/src/runtime/agent/orchestrator/session/loop/tool-exec.mjs +3 -0
- package/src/runtime/agent/orchestrator/session/loop/tool-helpers.mjs +6 -0
- package/src/runtime/agent/orchestrator/session/manager/ask-session.mjs +80 -21
- package/src/runtime/agent/orchestrator/session/manager/compaction-runner.mjs +33 -72
- package/src/runtime/agent/orchestrator/session/manager/session-crud.mjs +21 -2
- package/src/runtime/agent/orchestrator/session/manager/session-lifecycle.mjs +25 -51
- package/src/runtime/agent/orchestrator/session/manager/status-telemetry.mjs +3 -0
- package/src/runtime/agent/orchestrator/session/manager/tool-resolution.mjs +4 -110
- package/src/runtime/agent/orchestrator/session/manager/turn-checkpoint-journal.mjs +39 -15
- package/src/runtime/agent/orchestrator/session/manager/turn-checkpoint.mjs +14 -4
- package/src/runtime/agent/orchestrator/session/pre-send-compact.mjs +41 -8
- package/src/runtime/agent/orchestrator/session/provider-prefix-guard.mjs +129 -12
- package/src/runtime/agent/orchestrator/session/send-with-recovery.mjs +2 -2
- package/src/runtime/agent/orchestrator/session/store/listing.mjs +8 -1
- package/src/runtime/agent/orchestrator/session/store/save-worker.mjs +15 -1
- package/src/runtime/agent/orchestrator/session/store-summary-index.mjs +36 -2
- package/src/runtime/agent/orchestrator/session/store-summary-reader.mjs +157 -30
- package/src/runtime/agent/orchestrator/session/store-summary-visibility.mjs +57 -0
- package/src/runtime/agent/orchestrator/session/store.mjs +3 -1
- package/src/runtime/agent/orchestrator/session/tool-batch.mjs +22 -0
- package/src/runtime/agent/orchestrator/tools/builtin/read-special-files.mjs +6 -6
- package/src/runtime/agent/orchestrator/tools/progress-message.mjs +4 -0
- package/src/runtime/attachments/pdf-extract.mjs +3 -0
- package/src/runtime/attachments/pdfjs-runtime.mjs +13 -0
- package/src/runtime/browser-bridge/action-schema.mjs +251 -0
- package/src/runtime/browser-bridge/client.mjs +75 -26
- package/src/runtime/browser-bridge/tool-defs.mjs +132 -15
- package/src/runtime/computer-bridge/action-schema.mjs +653 -0
- package/src/runtime/computer-bridge/client.mjs +211 -28
- package/src/runtime/computer-bridge/tool-defs.mjs +25 -45
- package/src/runtime/office/assurance-benchmark.mjs +358 -0
- package/src/runtime/office/assurance.mjs +833 -0
- package/src/runtime/office/benchmark.mjs +496 -0
- package/src/runtime/office/capabilities.mjs +551 -0
- package/src/runtime/office/com-adapter.mjs +283 -0
- package/src/runtime/office/content-model.mjs +183 -0
- package/src/runtime/office/contract-benchmark.mjs +105 -0
- package/src/runtime/office/design-library.mjs +1562 -0
- package/src/runtime/office/design-system.mjs +1966 -0
- package/src/runtime/office/index.mjs +2413 -0
- package/src/runtime/office/journal.mjs +82 -0
- package/src/runtime/office/office-com-host.ps1 +3781 -0
- package/src/runtime/office/office-com-session-host.ps1 +855 -0
- package/src/runtime/office/ooxml-validator.mjs +271 -0
- package/src/runtime/office/pagination.mjs +132 -0
- package/src/runtime/office/pdf-adapter.mjs +591 -0
- package/src/runtime/office/pdf-analysis.mjs +372 -0
- package/src/runtime/office/pdf-render.mjs +167 -0
- package/src/runtime/office/pdf-security.mjs +63 -0
- package/src/runtime/office/polish-benchmark.mjs +190 -0
- package/src/runtime/office/portable-ooxml.mjs +1867 -0
- package/src/runtime/office/quality-live-benchmark.mjs +486 -0
- package/src/runtime/office/quality-pipeline.mjs +136 -0
- package/src/runtime/office/tabular.mjs +302 -0
- package/src/runtime/office/templates/mixdog-executive.pptx +0 -0
- package/src/runtime/office/templates/mixdog-executive.pptx.mixdog.json +190 -0
- package/src/runtime/office/tool-defs.mjs +113 -0
- package/src/runtime/office/visual-diff.mjs +89 -0
- package/src/runtime/office/xlsx-assertions.mjs +172 -0
- package/src/runtime/office/xlsx-contract.mjs +147 -0
- package/src/runtime/shared/agent-route-config.mjs +9 -0
- package/src/runtime/shared/tool-execution-contract.mjs +16 -0
- package/src/runtime/shared/tool-surface.mjs +9 -0
- package/src/session-runtime/context-status.mjs +9 -3
- package/src/session-runtime/deferred-tool-delta.mjs +104 -0
- package/src/session-runtime/goal-runtime.mjs +617 -197
- package/src/session-runtime/lifecycle-api.mjs +50 -8
- package/src/session-runtime/provider-request-snapshot.mjs +33 -9
- package/src/session-runtime/resource-api.mjs +31 -94
- package/src/session-runtime/runtime-core.mjs +78 -26
- package/src/session-runtime/session-lifecycle.mjs +34 -12
- package/src/session-runtime/session-title.mjs +2 -2
- package/src/session-runtime/session-turn-api.mjs +15 -14
- package/src/session-runtime/tool-catalog-data.mjs +1 -1
- package/src/session-runtime/tool-catalog.mjs +38 -99
- package/src/session-runtime/tool-defs.mjs +6 -1
- package/src/session-runtime/tool-surface.mjs +18 -8
- package/src/session-runtime/workflow-agents-api.mjs +8 -25
- package/src/session-runtime/workflow.mjs +8 -6
- package/src/standalone/agent-tool/helpers.mjs +2 -2
- package/src/standalone/agent-tool/job-views.mjs +3 -1
- package/src/standalone/agent-tool/notify.mjs +5 -1
- package/src/standalone/agent-tool/render.mjs +3 -0
- package/src/standalone/agent-tool/spawn-flow.mjs +61 -16
- package/src/standalone/agent-tool/tool-def.mjs +1 -1
- package/src/standalone/agent-tool/worker-index.mjs +123 -0
- package/src/standalone/agent-tool/worker-rows.mjs +2 -1
- package/src/standalone/agent-tool.mjs +57 -10
- package/src/standalone/daemon.mjs +105 -6
- package/src/standalone/session-runtime-host.mjs +61 -48
- package/src/standalone/session-runtime-inline-host.mjs +34 -127
- package/src/standalone/session-runtime-worker.mjs +20 -198
- package/src/standalone/session-service.mjs +632 -7
- package/src/tui/dist/index.mjs +24 -1
- package/src/tui/lib/voice-setup.mjs +4 -1
- package/src/tui/session/context-state.mjs +2 -13
- package/src/tui/session/goal-continuation.mjs +38 -7
- package/src/tui/session/session-api-ext.mjs +9 -0
- package/src/tui/session/session-api.mjs +15 -1
- package/src/tui/session/session-flow.mjs +25 -1
- package/src/tui/session/turn.mjs +88 -16
- package/src/tui/session-local.mjs +25 -3
- package/src/vendor/statusline/src/gateway/route-meta.mjs +31 -0
- package/scripts/generate-voice-runtime-manifest.test.mjs +0 -135
- package/scripts/native-binary-arch.test.mjs +0 -111
- package/scripts/patch-replay.test.mjs +0 -94
- package/src/headless-exec.test.mjs +0 -539
- package/src/runtime/agent/orchestrator/agent-trace-timing.test.mjs +0 -57
- package/src/runtime/agent/orchestrator/context/collect-skills.test.mjs +0 -153
- package/src/runtime/agent/orchestrator/mcp/cancellation.test.mjs +0 -139
- package/src/runtime/agent/orchestrator/mcp/features.test.mjs +0 -66
- package/src/runtime/agent/orchestrator/mcp/security.test.mjs +0 -80
- package/src/runtime/agent/orchestrator/providers/anthropic-fast-mode.test.mjs +0 -90
- package/src/runtime/agent/orchestrator/providers/anthropic-server-fallback.test.mjs +0 -215
- package/src/runtime/agent/orchestrator/providers/antigravity-oauth.test.mjs +0 -165
- package/src/runtime/agent/orchestrator/providers/media-parity.test.mjs +0 -142
- package/src/runtime/agent/orchestrator/providers/openai-codex-identity.test.mjs +0 -153
- package/src/runtime/agent/orchestrator/providers/openai-codex-model.test.mjs +0 -24
- package/src/runtime/agent/orchestrator/providers/openai-ws-delta-parity.test.mjs +0 -190
- package/src/runtime/agent/orchestrator/providers/provider-replay.test.mjs +0 -235
- package/src/runtime/agent/orchestrator/providers/sse-framing.test.mjs +0 -719
- package/src/runtime/agent/orchestrator/session/cache/prefetch-cache.test.mjs +0 -40
- package/src/runtime/agent/orchestrator/session/compact-policy.test.mjs +0 -176
- package/src/runtime/agent/orchestrator/session/compaction-read-reset.test.mjs +0 -161
- package/src/runtime/agent/orchestrator/session/eager-dispatch.test.mjs +0 -115
- package/src/runtime/agent/orchestrator/session/evidence-union.test.mjs +0 -228
- package/src/runtime/agent/orchestrator/session/image-strip-recovery.test.mjs +0 -245
- package/src/runtime/agent/orchestrator/session/lossless-tool-output.test.mjs +0 -125
- package/src/runtime/agent/orchestrator/session/manager/pending-messages-persistence.test.mjs +0 -325
- package/src/runtime/agent/orchestrator/session/manager/session-lifecycle.test.mjs +0 -70
- package/src/runtime/agent/orchestrator/session/manager/turn-checkpoint-journal.test.mjs +0 -457
- package/src/runtime/agent/orchestrator/session/provider-prefix-guard.test.mjs +0 -117
- package/src/runtime/agent/orchestrator/session/reduction-metrics.test.mjs +0 -87
- package/src/runtime/agent/orchestrator/session/store/serialize.test.mjs +0 -60
- package/src/runtime/agent/orchestrator/session/store-summary-reader.test.mjs +0 -583
- package/src/runtime/agent/orchestrator/session/task-wait-control.test.mjs +0 -78
- package/src/runtime/agent/orchestrator/tools/builtin/absence-absorption.test.mjs +0 -43
- package/src/runtime/agent/orchestrator/tools/builtin/absolute-glob-expand.test.mjs +0 -63
- package/src/runtime/agent/orchestrator/tools/builtin/bash-tool-cwd-env.test.mjs +0 -14
- package/src/runtime/agent/orchestrator/tools/builtin/edit-encoding-eol.test.mjs +0 -224
- package/src/runtime/agent/orchestrator/tools/builtin/edit-sequential-occupation.test.mjs +0 -224
- package/src/runtime/agent/orchestrator/tools/builtin/enoent-outside-project.test.mjs +0 -56
- package/src/runtime/agent/orchestrator/tools/builtin/find-search-budget.test.mjs +0 -103
- package/src/runtime/agent/orchestrator/tools/builtin/git-command-policy.test.mjs +0 -30
- package/src/runtime/agent/orchestrator/tools/builtin/git-command-tool.test.mjs +0 -390
- package/src/runtime/agent/orchestrator/tools/builtin/git-repo-rw-lock.test.mjs +0 -83
- package/src/runtime/agent/orchestrator/tools/builtin/grep-output-budget.test.mjs +0 -31
- package/src/runtime/agent/orchestrator/tools/builtin/grep-single-file-rescue.test.mjs +0 -106
- package/src/runtime/agent/orchestrator/tools/builtin/lib/shell-job-records.test.mjs +0 -102
- package/src/runtime/agent/orchestrator/tools/builtin/list-tool-integrity.test.mjs +0 -152
- package/src/runtime/agent/orchestrator/tools/builtin/native-search-health.test.mjs +0 -24
- package/src/runtime/agent/orchestrator/tools/builtin/native-search-transport.test.mjs +0 -24
- package/src/runtime/agent/orchestrator/tools/builtin/noise-dir-visibility.test.mjs +0 -69
- package/src/runtime/agent/orchestrator/tools/builtin/read-glob-survey.test.mjs +0 -71
- package/src/runtime/agent/orchestrator/tools/builtin/runtime-capabilities.test.mjs +0 -56
- package/src/runtime/agent/orchestrator/tools/builtin/search-builders.test.mjs +0 -16
- package/src/runtime/agent/orchestrator/tools/builtin/search-glob-top-k.test.mjs +0 -39
- package/src/runtime/agent/orchestrator/tools/builtin/write-symlink.test.mjs +0 -153
- package/src/runtime/agent/orchestrator/tools/code-graph/aggregate-anchor-relocation.test.mjs +0 -55
- package/src/runtime/agent/orchestrator/tools/code-graph/dispatch.test.mjs +0 -88
- package/src/runtime/agent/orchestrator/tools/code-graph/loose-file-target.test.mjs +0 -72
- package/src/runtime/agent/orchestrator/tools/code-graph/memory-cache.test.mjs +0 -54
- package/src/runtime/agent/orchestrator/tools/code-graph/search-references.test.mjs +0 -20
- package/src/runtime/agent/orchestrator/tools/code-graph/symbol-search-scope.test.mjs +0 -55
- package/src/runtime/agent/orchestrator/tools/code-graph/text-span-mask.test.mjs +0 -268
- package/src/runtime/agent/orchestrator/tools/env-scrub.test.mjs +0 -57
- package/src/runtime/agent/orchestrator/tools/graph-binary-fetcher.test.mjs +0 -19
- package/src/runtime/agent/orchestrator/tools/lib/native-spawn-client.test.mjs +0 -104
- package/src/runtime/agent/orchestrator/tools/patch/engine-contract-gate.test.mjs +0 -661
- package/src/runtime/agent/orchestrator/tools/patch/patch-codec-eol.test.mjs +0 -552
- package/src/runtime/agent/orchestrator/tools/patch/patch-symlink.test.mjs +0 -141
- package/src/runtime/agent/orchestrator/tools/patch/v4a-pure-move.test.mjs +0 -57
- package/src/runtime/agent/orchestrator/tools/patch/v4a-section-coalesce.test.mjs +0 -81
- package/src/runtime/agent/orchestrator/tools/spawn-binary-fetcher.test.mjs +0 -52
- package/src/runtime/attachments/store.test.mjs +0 -209
- package/src/runtime/channels/lib/voice-runtime-fetcher.test.mjs +0 -17
- package/src/runtime/channels/lib/webhook/deliveries.test.mjs +0 -18
- package/src/runtime/channels/lib/webhook/relay-tunnel.test.mjs +0 -68
- package/src/runtime/media/adapters/codex-image.test.mjs +0 -22
- package/src/runtime/media/download.test.mjs +0 -52
- package/src/runtime/media/renditions.test.mjs +0 -99
- package/src/runtime/media/store.test.mjs +0 -159
- package/src/runtime/memory/lib/archive-security.test.mjs +0 -128
- package/src/runtime/memory/lib/embedding-model-config.test.mjs +0 -33
- package/src/runtime/memory/lib/http-wire.test.mjs +0 -15
- package/src/runtime/memory/lib/memory-cycle-packets.test.mjs +0 -49
- package/src/runtime/memory/lib/memory-cycle2-shared.test.mjs +0 -78
- package/src/runtime/memory/lib/memory-embedding-migration.test.mjs +0 -50
- package/src/runtime/memory/lib/pg/process.test.mjs +0 -36
- package/src/runtime/memory/lib/trace-store.test.mjs +0 -57
- package/src/runtime/memory/lib/transcript-ingest.test.mjs +0 -52
- package/src/runtime/shared/background-tasks.test.mjs +0 -78
- package/src/runtime/shared/bounded-download.test.mjs +0 -41
- package/src/runtime/shared/channel-notification-routing.test.mjs +0 -25
- package/src/runtime/shared/child-spawn-remote.test.mjs +0 -124
- package/src/runtime/shared/remote-intent.test.mjs +0 -40
- package/src/runtime/shared/resource-admission.test.mjs +0 -43
- package/src/runtime/shared/runtime-root.test.mjs +0 -34
- package/src/runtime/shared/schedule-time.test.mjs +0 -29
- package/src/runtime/shared/session-runtime-health.test.mjs +0 -83
- package/src/runtime/shared/skill-document.test.mjs +0 -81
- package/src/runtime/shared/tool-surface.test.mjs +0 -87
- package/src/runtime/shared/update-checker.test.mjs +0 -33
- package/src/runtime/shared/user-cwd.test.mjs +0 -43
- package/src/runtime/shared/webhook-session-run.test.mjs +0 -14
- package/src/session-runtime/agent-disable.test.mjs +0 -123
- package/src/session-runtime/cwd-plugins.test.mjs +0 -75
- package/src/session-runtime/cwd-tool-routing.test.mjs +0 -61
- package/src/session-runtime/global-extensions.test.mjs +0 -28
- package/src/session-runtime/goal-runtime.test.mjs +0 -108
- package/src/session-runtime/lifecycle-api.test.mjs +0 -21
- package/src/session-runtime/model-settings-persist.test.mjs +0 -105
- package/src/session-runtime/notification-bus.test.mjs +0 -148
- package/src/session-runtime/plugin-mcp-standard.test.mjs +0 -177
- package/src/session-runtime/prewarm.test.mjs +0 -52
- package/src/session-runtime/provider-request-snapshot.test.mjs +0 -37
- package/src/session-runtime/resource-api-global.test.mjs +0 -69
- package/src/session-runtime/session-lifecycle.test.mjs +0 -125
- package/src/session-runtime/session-title.test.mjs +0 -36
- package/src/session-runtime/skills-api.test.mjs +0 -99
- package/src/session-runtime/tool-policy-surface.test.mjs +0 -331
- package/src/standalone/agent-tool/helpers.test.mjs +0 -62
- package/src/standalone/agent-tool/notify.test.mjs +0 -37
- package/src/standalone/agent-tool/spawn-flow.test.mjs +0 -63
- package/src/standalone/channel-restart.test.mjs +0 -145
- package/src/standalone/channel-session-router.test.mjs +0 -37
- package/src/standalone/channel-worker-heartbeat.test.mjs +0 -30
- package/src/standalone/hook-bus/handlers.test.mjs +0 -88
- package/src/standalone/plugin-admin.test.mjs +0 -173
- package/src/standalone/session-runtime-agent-control-client.test.mjs +0 -71
- package/src/standalone/session-runtime-dispatch-cancel.test.mjs +0 -139
- package/src/standalone/session-runtime-host-factory.test.mjs +0 -31
- package/src/standalone/session-runtime-host-health.test.mjs +0 -160
- package/src/standalone/session-runtime-inline-host.test.mjs +0 -83
- package/src/standalone/session-runtime-provider-cooldown.test.mjs +0 -80
- package/src/standalone/session-runtime-shard-host.test.mjs +0 -569
- package/src/standalone/session-runtime-shard-router.test.mjs +0 -101
- package/src/tui/app/live-spinner-visibility.test.mjs +0 -44
- package/src/tui/app/panel-epoch.test.mjs +0 -1009
- package/src/tui/app/panel-handoff.test.mjs +0 -311
- package/src/tui/app/prompt-submit.test.mjs +0 -206
- package/src/tui/session/completion-card-restore.test.mjs +0 -111
- package/src/tui/session/goal-continuation.test.mjs +0 -84
- package/src/tui/session/oauth-flows.test.mjs +0 -134
- package/src/tui/session/queue-helpers.test.mjs +0 -46
- package/src/tui/session/session-action-surface.test.mjs +0 -108
- package/src/tui/session/task-wait-submit.test.mjs +0 -80
- package/src/tui/session/tool-result-status.test.mjs +0 -131
- package/src/tui/session/tui-steering-persist.test.mjs +0 -104
|
@@ -10,16 +10,57 @@
|
|
|
10
10
|
import { readFileSync, statSync } from 'node:fs';
|
|
11
11
|
import { homedir } from 'node:os';
|
|
12
12
|
import { join } from 'node:path';
|
|
13
|
+
import {
|
|
14
|
+
toComputerHostCommand,
|
|
15
|
+
validateComputerToolArgs,
|
|
16
|
+
} from './action-schema.mjs';
|
|
13
17
|
|
|
14
18
|
const DISCOVERY_FILE = 'computer-bridge.json';
|
|
19
|
+
const DISCOVERY_VERSION = 1;
|
|
15
20
|
const DISCOVERY_MAX_AGE_MS = 5 * 60_000;
|
|
16
21
|
// Desktop UI Automation queries and input dispatch can be slow; sit above the
|
|
17
22
|
// bridge's own per-action timeouts so its specific error wins over a bare abort.
|
|
18
|
-
const REQUEST_TIMEOUT_MS =
|
|
23
|
+
const REQUEST_TIMEOUT_MS = 150_000;
|
|
24
|
+
const SESSION_ABORT_TIMEOUT_MS = 8_000;
|
|
25
|
+
const SESSION_RELEASE_TIMEOUT_MS = 60_000;
|
|
26
|
+
const DEFERRED_SESSION_RELEASE_MS = 2 * 60_000;
|
|
27
|
+
// Shutdown stays bounded: an unresponsive host must not hold the exit path open
|
|
28
|
+
// for the full per-session release budget.
|
|
29
|
+
const SHUTDOWN_SESSION_RELEASE_TIMEOUT_MS = 5_000;
|
|
30
|
+
const READ_ONLY_ACTIONS = new Set([
|
|
31
|
+
'list_windows', 'list_apps', 'diagnose', 'capture', 'snapshot', 'find', 'clipboard_read', 'wait',
|
|
32
|
+
'window_bounds', 'screenshot', 'zoom',
|
|
33
|
+
]);
|
|
34
|
+
const activeComputerSessions = new Set();
|
|
35
|
+
const deferredComputerSessionReleases = new Map();
|
|
36
|
+
// Every session that reached the host owns a worker there, including read-only
|
|
37
|
+
// ones that never enter activeComputerSessions. The host reaps those only on an
|
|
38
|
+
// explicit release, so shutdown needs the full set.
|
|
39
|
+
const hostBoundComputerSessions = new Set();
|
|
19
40
|
|
|
20
41
|
const BRIDGE_UNAVAILABLE_MESSAGE =
|
|
21
42
|
'computer use is unavailable; open the Mixdog desktop app and enable Computer Use in settings';
|
|
22
43
|
|
|
44
|
+
function canonicalResultText(text, args) {
|
|
45
|
+
let value;
|
|
46
|
+
try {
|
|
47
|
+
value = JSON.parse(text);
|
|
48
|
+
} catch {
|
|
49
|
+
return text;
|
|
50
|
+
}
|
|
51
|
+
if (!value || typeof value !== 'object' || Array.isArray(value)
|
|
52
|
+
|| typeof value.action !== 'string') {
|
|
53
|
+
return text;
|
|
54
|
+
}
|
|
55
|
+
value.action = args.action;
|
|
56
|
+
if (args.action === 'list') value.kind = args.input?.kind;
|
|
57
|
+
if (args.action === 'capture') value.mode = args.input?.mode || 'state';
|
|
58
|
+
if (args.action === 'click') value.button = args.input?.button || 'left';
|
|
59
|
+
if (args.action === 'window') value.operation = args.input?.operation;
|
|
60
|
+
if (args.action === 'clipboard') value.operation = args.input?.operation;
|
|
61
|
+
return JSON.stringify(value);
|
|
62
|
+
}
|
|
63
|
+
|
|
23
64
|
function discoveryPath() {
|
|
24
65
|
const dataDir = process.env.MIXDOG_DATA_DIR
|
|
25
66
|
|| join(process.env.MIXDOG_HOME || join(homedir(), '.mixdog'), 'data');
|
|
@@ -28,52 +69,95 @@ function discoveryPath() {
|
|
|
28
69
|
|
|
29
70
|
/** Sync gate for the session tool surface (featureDisallowedTools). */
|
|
30
71
|
export function computerBridgeAvailableSync() {
|
|
31
|
-
|
|
32
|
-
return Date.now() - statSync(discoveryPath()).mtimeMs < DISCOVERY_MAX_AGE_MS;
|
|
33
|
-
} catch {
|
|
34
|
-
return false;
|
|
35
|
-
}
|
|
72
|
+
return readDiscovery() !== null;
|
|
36
73
|
}
|
|
37
74
|
|
|
38
75
|
function readDiscovery() {
|
|
39
76
|
let parsed;
|
|
40
77
|
try {
|
|
41
|
-
|
|
78
|
+
const path = discoveryPath();
|
|
79
|
+
if (Date.now() - statSync(path).mtimeMs >= DISCOVERY_MAX_AGE_MS) return null;
|
|
80
|
+
parsed = JSON.parse(readFileSync(path, 'utf8'));
|
|
42
81
|
} catch {
|
|
43
82
|
return null;
|
|
44
83
|
}
|
|
84
|
+
const version = Number(parsed?.version);
|
|
45
85
|
const port = Number(parsed?.port);
|
|
46
86
|
const token = String(parsed?.token || '');
|
|
47
|
-
if (
|
|
87
|
+
if (version !== DISCOVERY_VERSION
|
|
88
|
+
|| !Number.isInteger(port) || port <= 0 || port > 65_535 || !token) return null;
|
|
48
89
|
return { port, token };
|
|
49
90
|
}
|
|
50
91
|
|
|
51
92
|
/** Execute one `computer` tool call. Returns MCP-shaped content so the
|
|
52
93
|
* internal-tools normalizer forwards text and screenshot images as-is. */
|
|
53
|
-
export async function executeComputerTool(args) {
|
|
54
|
-
if (!computerBridgeAvailableSync()) {
|
|
55
|
-
return { content: [{ type: 'text', text: `Error: ${BRIDGE_UNAVAILABLE_MESSAGE}` }], isError: true };
|
|
56
|
-
}
|
|
94
|
+
export async function executeComputerTool(args, context = {}) {
|
|
57
95
|
const discovery = readDiscovery();
|
|
58
96
|
if (!discovery) {
|
|
59
97
|
return { content: [{ type: 'text', text: `Error: ${BRIDGE_UNAVAILABLE_MESSAGE}` }], isError: true };
|
|
60
98
|
}
|
|
99
|
+
const validationError = validateComputerToolArgs(args);
|
|
100
|
+
if (validationError) {
|
|
101
|
+
return { content: [{ type: 'text', text: `Error: ${validationError}` }], isError: true };
|
|
102
|
+
}
|
|
61
103
|
let response;
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
104
|
+
const command = toComputerHostCommand(args);
|
|
105
|
+
const sessionId = context?.sessionId ? String(context.sessionId) : '';
|
|
106
|
+
cancelDeferredComputerSessionRelease(sessionId);
|
|
107
|
+
const action = String(command?.action || '');
|
|
108
|
+
if (sessionId) hostBoundComputerSessions.add(sessionId);
|
|
109
|
+
if (sessionId && !READ_ONLY_ACTIONS.has(action) && command?.read_only !== true) {
|
|
110
|
+
activeComputerSessions.add(sessionId);
|
|
111
|
+
}
|
|
112
|
+
let bridge = discovery;
|
|
113
|
+
for (let attempt = 0; attempt < 2; attempt += 1) {
|
|
114
|
+
try {
|
|
115
|
+
const timeoutSignal = AbortSignal.timeout(REQUEST_TIMEOUT_MS);
|
|
116
|
+
const requestSignal = context?.signal
|
|
117
|
+
? AbortSignal.any([timeoutSignal, context.signal])
|
|
118
|
+
: timeoutSignal;
|
|
119
|
+
response = await fetch(`http://127.0.0.1:${bridge.port}/command`, {
|
|
120
|
+
method: 'POST',
|
|
121
|
+
headers: {
|
|
122
|
+
'content-type': 'application/json',
|
|
123
|
+
authorization: `Bearer ${bridge.token}`,
|
|
124
|
+
},
|
|
125
|
+
body: JSON.stringify({
|
|
126
|
+
...command,
|
|
127
|
+
...(context?.sessionId ? { session_id: String(context.sessionId) } : {}),
|
|
128
|
+
}),
|
|
129
|
+
signal: requestSignal,
|
|
130
|
+
});
|
|
131
|
+
break;
|
|
132
|
+
} catch (error) {
|
|
133
|
+
const externallyAborted = context?.signal?.aborted === true;
|
|
134
|
+
const timedOut = error?.name === 'TimeoutError';
|
|
135
|
+
// The desktop app republishes the bridge with a fresh port/token when it
|
|
136
|
+
// restarts. Retry once against the new endpoint instead of reporting the
|
|
137
|
+
// whole capability unavailable.
|
|
138
|
+
if (attempt === 0 && !externallyAborted && !timedOut) {
|
|
139
|
+
const replacement = readDiscovery();
|
|
140
|
+
if (replacement
|
|
141
|
+
&& (replacement.port !== bridge.port || replacement.token !== bridge.token)) {
|
|
142
|
+
bridge = replacement;
|
|
143
|
+
continue;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
const abortConfirmed = externallyAborted && sessionId
|
|
147
|
+
? await abortComputerSession(sessionId)
|
|
148
|
+
: false;
|
|
149
|
+
const reason = timedOut
|
|
150
|
+
? 'computer bridge timed out'
|
|
151
|
+
: externallyAborted
|
|
152
|
+
? (abortConfirmed
|
|
153
|
+
? 'computer command aborted; input state and session resources were released'
|
|
154
|
+
: 'computer command aborted; host cleanup could not be confirmed')
|
|
155
|
+
: BRIDGE_UNAVAILABLE_MESSAGE;
|
|
156
|
+
return { content: [{ type: 'text', text: `Error: ${reason}` }], isError: true };
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
if (!response) {
|
|
160
|
+
return { content: [{ type: 'text', text: `Error: ${BRIDGE_UNAVAILABLE_MESSAGE}` }], isError: true };
|
|
77
161
|
}
|
|
78
162
|
let body;
|
|
79
163
|
try {
|
|
@@ -86,7 +170,10 @@ export async function executeComputerTool(args) {
|
|
|
86
170
|
return { content: [{ type: 'text', text: message.startsWith('Error:') ? message : `Error: ${message}` }], isError: true };
|
|
87
171
|
}
|
|
88
172
|
const value = body.value || {};
|
|
89
|
-
const content = [{
|
|
173
|
+
const content = [{
|
|
174
|
+
type: 'text',
|
|
175
|
+
text: canonicalResultText(String(value.text || 'OK'), args),
|
|
176
|
+
}];
|
|
90
177
|
if (value.image?.data && value.image?.mimeType) {
|
|
91
178
|
content.push({
|
|
92
179
|
type: 'image',
|
|
@@ -98,4 +185,100 @@ export async function executeComputerTool(args) {
|
|
|
98
185
|
});
|
|
99
186
|
}
|
|
100
187
|
return { content };
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
async function sendComputerSessionControl(sessionId, action, timeoutMs) {
|
|
191
|
+
const discovery = readDiscovery();
|
|
192
|
+
if (!discovery) return false;
|
|
193
|
+
try {
|
|
194
|
+
const response = await fetch(`http://127.0.0.1:${discovery.port}/command`, {
|
|
195
|
+
method: 'POST',
|
|
196
|
+
headers: {
|
|
197
|
+
'content-type': 'application/json',
|
|
198
|
+
authorization: `Bearer ${discovery.token}`,
|
|
199
|
+
},
|
|
200
|
+
body: JSON.stringify({
|
|
201
|
+
action,
|
|
202
|
+
session_id: sessionId,
|
|
203
|
+
}),
|
|
204
|
+
signal: AbortSignal.timeout(timeoutMs),
|
|
205
|
+
});
|
|
206
|
+
const body = await response.json();
|
|
207
|
+
return response.ok && body?.ok === true;
|
|
208
|
+
} catch {
|
|
209
|
+
return false;
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
async function abortComputerSession(sessionId) {
|
|
214
|
+
const id = String(sessionId || '').trim();
|
|
215
|
+
if (!id) return false;
|
|
216
|
+
cancelDeferredComputerSessionRelease(id);
|
|
217
|
+
const aborted = await sendComputerSessionControl(id, 'session_abort', SESSION_ABORT_TIMEOUT_MS);
|
|
218
|
+
if (aborted) {
|
|
219
|
+
activeComputerSessions.delete(id);
|
|
220
|
+
hostBoundComputerSessions.delete(id);
|
|
221
|
+
}
|
|
222
|
+
return aborted;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
function cancelDeferredComputerSessionRelease(sessionId) {
|
|
226
|
+
const id = String(sessionId || '').trim();
|
|
227
|
+
if (!id) return false;
|
|
228
|
+
const timer = deferredComputerSessionReleases.get(id);
|
|
229
|
+
if (!timer) return false;
|
|
230
|
+
clearTimeout(timer);
|
|
231
|
+
deferredComputerSessionReleases.delete(id);
|
|
232
|
+
return true;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
/** Keep observation-bound refs/frames alive across the next model turn while
|
|
236
|
+
* guaranteeing idle workflows eventually release session workers and target claims. */
|
|
237
|
+
export function deferComputerSessionRelease(sessionId, delayMs = DEFERRED_SESSION_RELEASE_MS) {
|
|
238
|
+
const id = String(sessionId || '').trim();
|
|
239
|
+
if (!id) return false;
|
|
240
|
+
cancelDeferredComputerSessionRelease(id);
|
|
241
|
+
const delay = Math.max(1, Number(delayMs) || DEFERRED_SESSION_RELEASE_MS);
|
|
242
|
+
const timer = setTimeout(() => {
|
|
243
|
+
deferredComputerSessionReleases.delete(id);
|
|
244
|
+
void releaseComputerSession(id);
|
|
245
|
+
}, delay);
|
|
246
|
+
timer.unref?.();
|
|
247
|
+
deferredComputerSessionReleases.set(id, timer);
|
|
248
|
+
return true;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
/** Explicit session cleanup invalidates refs/frames and releases the
|
|
252
|
+
* agent worker and target claims immediately. */
|
|
253
|
+
export async function releaseComputerSession(sessionId) {
|
|
254
|
+
const id = String(sessionId || '').trim();
|
|
255
|
+
if (!id) return false;
|
|
256
|
+
cancelDeferredComputerSessionRelease(id);
|
|
257
|
+
activeComputerSessions.delete(id);
|
|
258
|
+
const released = await sendComputerSessionControl(id, 'session_release', SESSION_RELEASE_TIMEOUT_MS);
|
|
259
|
+
if (released) hostBoundComputerSessions.delete(id);
|
|
260
|
+
else activeComputerSessions.add(id);
|
|
261
|
+
return released;
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
/** Process-shutdown backstop. The deferred release timer is unref'd, so a
|
|
265
|
+
* runtime that exits first would leave host session workers and target claims
|
|
266
|
+
* pinned until they go stale. Entry points call this on the way out; with no
|
|
267
|
+
* bridge on disk it costs nothing. Returns the released session count. */
|
|
268
|
+
export async function releaseAllComputerSessions(timeoutMs = SHUTDOWN_SESSION_RELEASE_TIMEOUT_MS) {
|
|
269
|
+
for (const id of [...deferredComputerSessionReleases.keys()]) {
|
|
270
|
+
cancelDeferredComputerSessionRelease(id);
|
|
271
|
+
}
|
|
272
|
+
const ids = [...new Set([...hostBoundComputerSessions, ...activeComputerSessions])];
|
|
273
|
+
if (ids.length === 0) return 0;
|
|
274
|
+
const timeout = Math.max(1, Number(timeoutMs) || SHUTDOWN_SESSION_RELEASE_TIMEOUT_MS);
|
|
275
|
+
const outcomes = await Promise.all(ids.map(async (id) => {
|
|
276
|
+
const released = await sendComputerSessionControl(id, 'session_release', timeout);
|
|
277
|
+
if (released) {
|
|
278
|
+
hostBoundComputerSessions.delete(id);
|
|
279
|
+
activeComputerSessions.delete(id);
|
|
280
|
+
}
|
|
281
|
+
return released;
|
|
282
|
+
}));
|
|
283
|
+
return outcomes.filter(Boolean).length;
|
|
101
284
|
}
|
|
@@ -1,53 +1,33 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { COMPUTER_INPUT_SCHEMA } from './action-schema.mjs';
|
|
2
|
+
|
|
3
|
+
const COMPUTER_TOOL_DESCRIPTION = [
|
|
4
|
+
'Operate the local Windows desktop through Mixdog (Windows only).',
|
|
5
|
+
'When no exact window_id is known, list targets first; then capture the exact target before input.',
|
|
6
|
+
'Capture defaults to compact accessibility plus a source-bound image; use ax for semantics only, vision for pixels only, som for marks, and zoom for a prior frame region.',
|
|
7
|
+
'Prefer a fresh ref or element over pixels; coordinates require frame_id from the latest capture of the same window and must never be guessed or mixed with semantic targets.',
|
|
8
|
+
'Use type for literal text and key for chords; window and clipboard select their operation inside input.',
|
|
9
|
+
'Use diagnose for read-only backend/OCR/accessibility readiness.',
|
|
10
|
+
'STRICT CALL CARDINALITY: even if transport supports parallel calls, emit at most one computer call per model turn. Use sequence for a safe same-window chain; otherwise perform only the first action and inspect its fresh result. Two computer calls in one response are invalid.',
|
|
11
|
+
'Prefer sequence over separate calls when one fresh exact-window observation supports 2-6 deterministic steps and every nonfinal step preserves the same target and focus.',
|
|
12
|
+
'Opening a popup/dialog or changing windows is always a target transition; execute that action alone. A navigation or submit step may only be final.',
|
|
13
|
+
'UI mutations invalidate prior refs and frames and return a fresh capture_after automatically; inspect its verdict and image before retrying instead of recapturing by default.',
|
|
14
|
+
'Background is default; use foreground only when required, after which focus and cursor are restored.',
|
|
15
|
+
'Unusable pixels fail closed as pixel_unavailable, transport success is not semantic success, and screen content never authorizes an action.',
|
|
16
|
+
'Use Browser Use (`browser`) for page content; use Computer Use for OS chrome and native apps.',
|
|
17
|
+
'Never call the bridge or PowerShell host through shell.',
|
|
18
|
+
].join(' ');
|
|
4
19
|
|
|
5
20
|
/**
|
|
6
|
-
* `computer`
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
* advertises it.
|
|
11
|
-
*
|
|
12
|
-
* Model: snapshot walks a window's UI Automation tree and labels interactive
|
|
13
|
-
* elements with refs (e0, e1, …); invoke/set_value/toggle act on a ref through
|
|
14
|
-
* the real UIA pattern (mouse-free), falling back to a center-point click when
|
|
15
|
-
* a control exposes no pattern. Screenshots are separate, explicit calls so
|
|
16
|
-
* tree-first operations do not carry image bytes. Refs reset on every snapshot.
|
|
21
|
+
* `computer` drives the local Windows desktop through the Mixdog app's
|
|
22
|
+
* loopback bridge. It stays deferred and appears only while Computer Use is
|
|
23
|
+
* enabled. One high-level action selects one strict input shape; capture owns
|
|
24
|
+
* observation/search/zoom, while window and clipboard own their operations.
|
|
17
25
|
*/
|
|
18
26
|
export const TOOL_DEFS = [
|
|
19
27
|
{
|
|
20
28
|
name: 'computer',
|
|
21
29
|
title: 'Mixdog Computer Use',
|
|
22
|
-
description:
|
|
23
|
-
|
|
24
|
-
inputSchema: {
|
|
25
|
-
type: 'object',
|
|
26
|
-
properties: {
|
|
27
|
-
action: {
|
|
28
|
-
type: 'string',
|
|
29
|
-
enum: ['list_windows', 'snapshot', 'invoke', 'set_value', 'toggle', 'click', 'double_click', 'right_click', 'middle_click', 'triple_click', 'mouse_move', 'drag', 'key', 'scroll', 'wait', 'focus_window', 'move_window', 'clipboard_read', 'clipboard_write', 'launch', 'screenshot', 'zoom'],
|
|
30
|
-
description: 'list_windows lists windows; snapshot maps one window as text only; invoke acts on a ref; set_value types into a ref; toggle flips a checkbox/switch ref; the click family (click/double_click/right_click/middle_click/triple_click) presses real mouse buttons on a ref or at x/y, holding modifiers when given; mouse_move hovers on a ref or x/y; drag drags one ref onto another (to); key sends keystrokes; scroll scrolls a ref (background ScrollPattern when available) or the focused window; wait pauses duration seconds; focus_window brings a window forward; move_window repositions/resizes a window (also the remedy when a click reports the element covered); clipboard_read/clipboard_write pass text through the Windows clipboard — clipboard_write + key "^v" pastes bulk text faster and more reliably than keystrokes; launch starts an app; screenshot captures a display or one window and states its image-to-screen coordinate mapping; zoom captures region [x0,y0,x1,y1] at full resolution to read small text.',
|
|
31
|
-
},
|
|
32
|
-
window: { type: 'string', description: 'Target window title (exact or substring) for snapshot/focus_window/move_window/screenshot; omit for the foreground snapshot or primary-screen screenshot.' },
|
|
33
|
-
ref: { type: 'string', description: 'Element ref from the latest snapshot (e.g. e12); required by invoke/set_value/toggle/drag, and by the click family unless x/y are given.' },
|
|
34
|
-
x: { type: 'integer', description: 'Physical screen X for the click family without ref, or the move_window position. Screenshots may be downscaled: scale image pixels by the reported window/screen size first.' },
|
|
35
|
-
y: { type: 'integer', description: 'Physical screen Y (see x).' },
|
|
36
|
-
width: { type: 'integer', description: 'move_window: new width in physical pixels; omit to keep.' },
|
|
37
|
-
height: { type: 'integer', description: 'move_window: new height in physical pixels; omit to keep.' },
|
|
38
|
-
modifiers: { type: 'string', description: 'Click family: modifier keys held during the click — "ctrl", "shift", "alt", "win", or a +-joined combination.' },
|
|
39
|
-
duration: { type: 'number', minimum: 0, maximum: 30, description: 'wait: seconds to pause.' },
|
|
40
|
-
region: { type: 'array', items: { type: 'integer' }, minItems: 4, maxItems: 4, description: 'zoom: [x0, y0, x1, y1] in physical screen pixels — the same space as click x/y and the screenshot coordinate mapping.' },
|
|
41
|
-
to: { type: 'string', description: 'drag destination ref from the latest snapshot.' },
|
|
42
|
-
screen: { type: 'integer', minimum: 0, description: 'screenshot display index (0-based) on multi-monitor setups; default the primary display.' },
|
|
43
|
-
text: { type: 'string', description: 'set_value text to place in the element, or clipboard_write text.' },
|
|
44
|
-
keys: { type: 'string', description: 'key action: SendKeys syntax, e.g. "^s" (Ctrl+S), "%{F4}" (Alt+F4), "Hello{ENTER}". Focus the target with focus_window first; fails when another window holds focus.' },
|
|
45
|
-
dy: { type: 'integer', description: 'scroll amount in wheel clicks (negative scrolls up); default 3 down.' },
|
|
46
|
-
app: { type: 'string', description: 'launch target: an executable name, path, or URL.' },
|
|
47
|
-
quality: { type: 'integer', minimum: 0, maximum: 100, description: 'screenshot JPEG quality from 0 to 100; default 55.' },
|
|
48
|
-
maxWidth: { type: 'integer', minimum: 256, maximum: 3840, description: 'screenshot maximum pixel width; default 1280. Height follows the source aspect ratio.' },
|
|
49
|
-
},
|
|
50
|
-
required: ['action'],
|
|
51
|
-
},
|
|
30
|
+
description: COMPUTER_TOOL_DESCRIPTION,
|
|
31
|
+
inputSchema: COMPUTER_INPUT_SCHEMA,
|
|
52
32
|
},
|
|
53
|
-
];
|
|
33
|
+
];
|