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
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
import assert from 'node:assert/strict';
|
|
2
|
-
import test from 'node:test';
|
|
3
|
-
|
|
4
|
-
import {
|
|
5
|
-
activeTaskWaitCountForSession,
|
|
6
|
-
beginInterruptibleTaskWait,
|
|
7
|
-
interruptTaskWaitForSession,
|
|
8
|
-
} from './task-wait-control.mjs';
|
|
9
|
-
import {
|
|
10
|
-
cancelBackgroundTask,
|
|
11
|
-
getBackgroundTask,
|
|
12
|
-
registerBackgroundTask,
|
|
13
|
-
} from '../../../shared/background-tasks.mjs';
|
|
14
|
-
import { executeTaskTool } from '../tools/builtin/task-tool.mjs';
|
|
15
|
-
|
|
16
|
-
test('user input interrupts only task waits in its session', () => {
|
|
17
|
-
const first = beginInterruptibleTaskWait('sess_wait_1');
|
|
18
|
-
const second = beginInterruptibleTaskWait('sess_wait_1');
|
|
19
|
-
const other = beginInterruptibleTaskWait('sess_wait_2');
|
|
20
|
-
|
|
21
|
-
assert.equal(activeTaskWaitCountForSession('sess_wait_1'), 2);
|
|
22
|
-
assert.equal(interruptTaskWaitForSession('sess_wait_1'), 2);
|
|
23
|
-
assert.equal(first.signal.aborted, true);
|
|
24
|
-
assert.equal(second.signal.aborted, true);
|
|
25
|
-
assert.equal(first.interruptedByUser, true);
|
|
26
|
-
assert.equal(second.interruptedByUser, true);
|
|
27
|
-
assert.equal(other.signal.aborted, false);
|
|
28
|
-
|
|
29
|
-
first.dispose();
|
|
30
|
-
second.dispose();
|
|
31
|
-
other.dispose();
|
|
32
|
-
assert.equal(activeTaskWaitCountForSession('sess_wait_1'), 0);
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
test('turn cancellation propagates without masquerading as user input', () => {
|
|
36
|
-
const parent = new AbortController();
|
|
37
|
-
const wait = beginInterruptibleTaskWait('sess_parent_abort', parent.signal);
|
|
38
|
-
|
|
39
|
-
parent.abort('turn-cancelled');
|
|
40
|
-
assert.equal(wait.signal.aborted, true);
|
|
41
|
-
assert.equal(wait.interruptedByUser, false);
|
|
42
|
-
|
|
43
|
-
wait.dispose();
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
test('task wait returns on user input without cancelling the background task', async () => {
|
|
47
|
-
const sessionId = 'sess_task_wait_integration';
|
|
48
|
-
const taskId = 'task_shell_wait_integration';
|
|
49
|
-
const task = registerBackgroundTask({
|
|
50
|
-
taskId,
|
|
51
|
-
surface: 'shell',
|
|
52
|
-
operation: 'run',
|
|
53
|
-
context: {
|
|
54
|
-
callerSessionId: sessionId,
|
|
55
|
-
routingSessionId: sessionId,
|
|
56
|
-
},
|
|
57
|
-
});
|
|
58
|
-
task.promise = new Promise(() => {});
|
|
59
|
-
|
|
60
|
-
const interruptTimer = setTimeout(
|
|
61
|
-
() => interruptTaskWaitForSession(sessionId),
|
|
62
|
-
20,
|
|
63
|
-
);
|
|
64
|
-
const startedAt = Date.now();
|
|
65
|
-
try {
|
|
66
|
-
const result = await executeTaskTool(
|
|
67
|
-
{ action: 'wait', task_id: taskId, timeout_ms: 10_000 },
|
|
68
|
-
{ sessionId, callerSessionId: sessionId, routingSessionId: sessionId },
|
|
69
|
-
);
|
|
70
|
-
|
|
71
|
-
assert.ok(Date.now() - startedAt < 1_000, 'wait should return before its ceiling');
|
|
72
|
-
assert.match(result, /Wait interrupted by new user input/);
|
|
73
|
-
assert.equal(getBackgroundTask(taskId)?.status, 'running');
|
|
74
|
-
} finally {
|
|
75
|
-
clearTimeout(interruptTimer);
|
|
76
|
-
cancelBackgroundTask(taskId, 'test cleanup');
|
|
77
|
-
}
|
|
78
|
-
});
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
// Absence absorption: a conclusive "no such path" (read/list) and git's
|
|
2
|
-
// exit-128 state verdict are ANSWERS, not tool failures. The full diagnostic
|
|
3
|
-
// body is preserved — only the error envelope is dropped, so the caller acts
|
|
4
|
-
// on the evidence instead of entering error recovery.
|
|
5
|
-
import assert from 'node:assert/strict';
|
|
6
|
-
import { mkdtempSync, rmSync } from 'node:fs';
|
|
7
|
-
import { tmpdir } from 'node:os';
|
|
8
|
-
import { join } from 'node:path';
|
|
9
|
-
import test from 'node:test';
|
|
10
|
-
|
|
11
|
-
import { executeBuiltinTool } from '../builtin.mjs';
|
|
12
|
-
import { executeGitTool } from './git-command-tool.mjs';
|
|
13
|
-
|
|
14
|
-
test('read of a conclusively missing path answers [path absent], not Error', async (t) => {
|
|
15
|
-
const root = mkdtempSync(join(tmpdir(), 'mixdog-absent-read-'));
|
|
16
|
-
t.after(() => rmSync(root, { recursive: true, force: true }));
|
|
17
|
-
const out = String(await executeBuiltinTool('read', { path: join(root, 'no-such-file.txt') }, root));
|
|
18
|
-
assert.match(out, /^\[path absent\]/);
|
|
19
|
-
assert.match(out, /ENOENT/);
|
|
20
|
-
assert.doesNotMatch(out, /^Error:/);
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
test('list of a conclusively missing directory answers [path absent], not Error', async (t) => {
|
|
24
|
-
const root = mkdtempSync(join(tmpdir(), 'mixdog-absent-list-'));
|
|
25
|
-
t.after(() => rmSync(root, { recursive: true, force: true }));
|
|
26
|
-
const out = String(await executeBuiltinTool('list', { path: join(root, 'no-such-dir') }, root));
|
|
27
|
-
assert.match(out, /^\[path absent\]/);
|
|
28
|
-
assert.doesNotMatch(out, /^Error:/);
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
test('git exit 128 returns the state verdict as a non-error envelope', async (t) => {
|
|
32
|
-
const root = mkdtempSync(join(tmpdir(), 'mixdog-absent-git128-'));
|
|
33
|
-
t.after(() => rmSync(root, { recursive: true, force: true }));
|
|
34
|
-
const repo = join(root, 'repo');
|
|
35
|
-
await executeGitTool({ command: `git init "${repo}"` }, root);
|
|
36
|
-
// Unborn branch: `git log` exits 128 with git's own explanation.
|
|
37
|
-
const out = String(await executeGitTool({ command: `git -C "${repo}" log` }, repo));
|
|
38
|
-
assert.doesNotMatch(out, /^Error:/);
|
|
39
|
-
const parsed = JSON.parse(out);
|
|
40
|
-
assert.equal(parsed.ok, false);
|
|
41
|
-
assert.equal(parsed.exit, 128);
|
|
42
|
-
assert.ok(String(parsed.stderr || parsed.reason || '').length > 0);
|
|
43
|
-
});
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
// An absolute glob is expanded straight off the filesystem when the inventory
|
|
2
|
-
// walker cannot see its targets (symlink farms such as /sys and /proc). The
|
|
3
|
-
// pattern bounds the walk; anything unbounded or unsupported declines.
|
|
4
|
-
import assert from 'node:assert/strict';
|
|
5
|
-
import { mkdir, mkdtemp, rm, writeFile } from 'node:fs/promises';
|
|
6
|
-
import { tmpdir } from 'node:os';
|
|
7
|
-
import { join } from 'node:path';
|
|
8
|
-
import test from 'node:test';
|
|
9
|
-
|
|
10
|
-
import { expandAbsoluteGlob, expandAbsoluteGlobs } from './lib/absolute-glob-expand.mjs';
|
|
11
|
-
|
|
12
|
-
async function withBlockTree(run) {
|
|
13
|
-
const root = await mkdtemp(join(tmpdir(), 'mixdog-abs-glob-'));
|
|
14
|
-
try {
|
|
15
|
-
for (const disk of ['sda', 'sdb', 'nvme0n1']) {
|
|
16
|
-
await mkdir(join(root, 'block', disk, 'device'), { recursive: true });
|
|
17
|
-
await writeFile(join(root, 'block', disk, 'size'), '2048\n');
|
|
18
|
-
await writeFile(join(root, 'block', disk, 'device', 'model'), `${disk}-model\n`);
|
|
19
|
-
}
|
|
20
|
-
return await run(root);
|
|
21
|
-
} finally {
|
|
22
|
-
await rm(root, { recursive: true, force: true });
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
test('a magic middle segment expands to every matching path', async () => {
|
|
27
|
-
await withBlockTree(async (root) => {
|
|
28
|
-
const sizes = await expandAbsoluteGlob(join(root, 'block', 'sd*', 'size'));
|
|
29
|
-
assert.equal(sizes.length, 2);
|
|
30
|
-
assert.ok(sizes.every((p) => p.endsWith('/size')));
|
|
31
|
-
assert.ok(sizes.some((p) => p.includes('/sda/')));
|
|
32
|
-
assert.ok(sizes.some((p) => p.includes('/sdb/')));
|
|
33
|
-
|
|
34
|
-
const models = await expandAbsoluteGlob(join(root, 'block', '*', 'device', 'model'));
|
|
35
|
-
assert.equal(models.length, 3);
|
|
36
|
-
});
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
test('a pattern with no matches answers empty, not null', async () => {
|
|
40
|
-
await withBlockTree(async (root) => {
|
|
41
|
-
assert.deepEqual(await expandAbsoluteGlob(join(root, 'block', 'hd*', 'size')), []);
|
|
42
|
-
});
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
test('unbounded or non-absolute patterns decline so the caller keeps its answer', async () => {
|
|
46
|
-
await withBlockTree(async (root) => {
|
|
47
|
-
assert.equal(await expandAbsoluteGlob(join(root, '**', 'size')), null);
|
|
48
|
-
assert.equal(await expandAbsoluteGlob('block/sd*/size'), null);
|
|
49
|
-
assert.equal(await expandAbsoluteGlob(join(root, 'block', 'sda', 'size')), null);
|
|
50
|
-
});
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
test('the batch form dedupes and honours its limit', async () => {
|
|
54
|
-
await withBlockTree(async (root) => {
|
|
55
|
-
const found = await expandAbsoluteGlobs([
|
|
56
|
-
join(root, 'block', 'sd*', 'size'),
|
|
57
|
-
join(root, 'block', 's*a', 'size'),
|
|
58
|
-
], { limit: 5 });
|
|
59
|
-
assert.equal(found.length, 2);
|
|
60
|
-
const limited = await expandAbsoluteGlobs([join(root, 'block', '*', 'size')], { limit: 1 });
|
|
61
|
-
assert.equal(limited.length, 1);
|
|
62
|
-
});
|
|
63
|
-
});
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import assert from 'node:assert/strict';
|
|
2
|
-
import test from 'node:test';
|
|
3
|
-
|
|
4
|
-
import { buildShellSpawnEnv } from './bash-tool.mjs';
|
|
5
|
-
|
|
6
|
-
test('shell child receives the caller session cwd without mutating the daemon env', () => {
|
|
7
|
-
const base = {
|
|
8
|
-
PATH: process.env.PATH || '',
|
|
9
|
-
MIXDOG_SESSION_CWD: 'C:\\wrong-session',
|
|
10
|
-
};
|
|
11
|
-
const env = buildShellSpawnEnv('C:\\Project\\mixdog', base);
|
|
12
|
-
assert.equal(env.MIXDOG_SESSION_CWD, 'C:\\Project\\mixdog');
|
|
13
|
-
assert.equal(base.MIXDOG_SESSION_CWD, 'C:\\wrong-session');
|
|
14
|
-
});
|
|
@@ -1,224 +0,0 @@
|
|
|
1
|
-
// Windows-first edit fidelity: the file's line endings and its encoding decide
|
|
2
|
-
// how old_string/new_string are matched and written back.
|
|
3
|
-
import { test } from 'node:test';
|
|
4
|
-
import assert from 'node:assert/strict';
|
|
5
|
-
import { mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
|
|
6
|
-
import { tmpdir } from 'node:os';
|
|
7
|
-
import { join } from 'node:path';
|
|
8
|
-
import { tryExecuteExternalToolAdapter } from './external-tool-adapters.mjs';
|
|
9
|
-
import { closeNativePatchServerForTests } from '../patch/native-server.mjs';
|
|
10
|
-
import { sliceReadBodyByLines } from './read-batch.mjs';
|
|
11
|
-
|
|
12
|
-
function makeDir() {
|
|
13
|
-
return mkdtempSync(join(tmpdir(), 'mixdog-edit-enc-'));
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
test('a multiline LF old_string matches a CRLF file and keeps CRLF', async (t) => {
|
|
17
|
-
const dir = makeDir();
|
|
18
|
-
const file = join(dir, 'crlf.txt');
|
|
19
|
-
t.after(() => { rmSync(dir, { recursive: true, force: true }); void closeNativePatchServerForTests?.(); });
|
|
20
|
-
writeFileSync(file, 'one\r\ntwo\r\nthree\r\n');
|
|
21
|
-
|
|
22
|
-
const result = await tryExecuteExternalToolAdapter('edit', {
|
|
23
|
-
file_path: file,
|
|
24
|
-
old_string: 'one\ntwo',
|
|
25
|
-
new_string: 'one\nTWO',
|
|
26
|
-
}, dir, {});
|
|
27
|
-
|
|
28
|
-
assert.match(String(result), /^Updated /);
|
|
29
|
-
assert.equal(readFileSync(file, 'utf8'), 'one\r\nTWO\r\nthree\r\n');
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
test('a replacement never injects LF endings into a CRLF file', async (t) => {
|
|
33
|
-
const dir = makeDir();
|
|
34
|
-
const file = join(dir, 'crlf-insert.txt');
|
|
35
|
-
t.after(() => { rmSync(dir, { recursive: true, force: true }); void closeNativePatchServerForTests?.(); });
|
|
36
|
-
writeFileSync(file, 'one\r\ntwo\r\n');
|
|
37
|
-
|
|
38
|
-
const result = await tryExecuteExternalToolAdapter('edit', {
|
|
39
|
-
file_path: file,
|
|
40
|
-
old_string: 'two',
|
|
41
|
-
new_string: 'two\nthree',
|
|
42
|
-
}, dir, {});
|
|
43
|
-
|
|
44
|
-
assert.match(String(result), /^Updated /);
|
|
45
|
-
assert.equal(readFileSync(file, 'utf8'), 'one\r\ntwo\r\nthree\r\n');
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
test('a UTF-16LE file is edited in place instead of transcoded', async (t) => {
|
|
49
|
-
const dir = makeDir();
|
|
50
|
-
const file = join(dir, 'utf16.txt');
|
|
51
|
-
t.after(() => { rmSync(dir, { recursive: true, force: true }); void closeNativePatchServerForTests?.(); });
|
|
52
|
-
writeFileSync(file, Buffer.concat([
|
|
53
|
-
Buffer.from([0xFF, 0xFE]),
|
|
54
|
-
Buffer.from('alpha\r\nkeep\r\n', 'utf16le'),
|
|
55
|
-
]));
|
|
56
|
-
|
|
57
|
-
const result = await tryExecuteExternalToolAdapter('edit', {
|
|
58
|
-
file_path: file,
|
|
59
|
-
old_string: 'alpha',
|
|
60
|
-
new_string: 'omega',
|
|
61
|
-
}, dir, {});
|
|
62
|
-
|
|
63
|
-
assert.match(String(result), /^Updated /);
|
|
64
|
-
const raw = readFileSync(file);
|
|
65
|
-
assert.deepEqual([raw[0], raw[1]], [0xFF, 0xFE]);
|
|
66
|
-
assert.equal(raw.subarray(2).toString('utf16le'), 'omega\r\nkeep\r\n');
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
test('a file that is neither UTF-8 nor UTF-16 is refused, not rewritten', async (t) => {
|
|
70
|
-
const dir = makeDir();
|
|
71
|
-
const file = join(dir, 'latin1.txt');
|
|
72
|
-
t.after(() => { rmSync(dir, { recursive: true, force: true }); void closeNativePatchServerForTests?.(); });
|
|
73
|
-
const bytes = Buffer.from([0x61, 0xE9, 0x62, 0x0A]); // latin-1 "aéb\n"
|
|
74
|
-
writeFileSync(file, bytes);
|
|
75
|
-
|
|
76
|
-
const result = String(await tryExecuteExternalToolAdapter('edit', {
|
|
77
|
-
file_path: file,
|
|
78
|
-
old_string: 'a',
|
|
79
|
-
new_string: 'z',
|
|
80
|
-
}, dir, {}));
|
|
81
|
-
|
|
82
|
-
assert.match(result, /not decidable text/);
|
|
83
|
-
assert.deepEqual([...readFileSync(file)], [...bytes]);
|
|
84
|
-
});
|
|
85
|
-
|
|
86
|
-
test('a UTF-16BE file keeps its byte order and BOM', async (t) => {
|
|
87
|
-
const dir = makeDir();
|
|
88
|
-
const file = join(dir, 'utf16be.txt');
|
|
89
|
-
t.after(() => { rmSync(dir, { recursive: true, force: true }); void closeNativePatchServerForTests?.(); });
|
|
90
|
-
writeFileSync(file, Buffer.concat([
|
|
91
|
-
Buffer.from([0xFE, 0xFF]),
|
|
92
|
-
Buffer.from('alpha\r\nkeep\r\n', 'utf16le').swap16(),
|
|
93
|
-
]));
|
|
94
|
-
|
|
95
|
-
const result = await tryExecuteExternalToolAdapter('edit', {
|
|
96
|
-
file_path: file,
|
|
97
|
-
old_string: 'alpha',
|
|
98
|
-
new_string: 'omega',
|
|
99
|
-
}, dir, {});
|
|
100
|
-
|
|
101
|
-
assert.match(String(result), /^Updated /);
|
|
102
|
-
const raw = readFileSync(file);
|
|
103
|
-
assert.deepEqual([raw[0], raw[1]], [0xFE, 0xFF]);
|
|
104
|
-
assert.equal(Buffer.from(raw.subarray(2)).swap16().toString('utf16le'), 'omega\r\nkeep\r\n');
|
|
105
|
-
});
|
|
106
|
-
|
|
107
|
-
test('a UTF-8 BOM survives and a BOM-less file never gains one', async (t) => {
|
|
108
|
-
const dir = makeDir();
|
|
109
|
-
const withBom = join(dir, 'bom.txt');
|
|
110
|
-
const noBom = join(dir, 'nobom.txt');
|
|
111
|
-
t.after(() => { rmSync(dir, { recursive: true, force: true }); void closeNativePatchServerForTests?.(); });
|
|
112
|
-
writeFileSync(withBom, Buffer.concat([Buffer.from([0xEF, 0xBB, 0xBF]), Buffer.from('alpha\nkeep\n')]));
|
|
113
|
-
writeFileSync(noBom, 'alpha\nkeep\n');
|
|
114
|
-
|
|
115
|
-
for (const file of [withBom, noBom]) {
|
|
116
|
-
const result = await tryExecuteExternalToolAdapter('edit', {
|
|
117
|
-
file_path: file,
|
|
118
|
-
old_string: 'alpha',
|
|
119
|
-
new_string: 'omega',
|
|
120
|
-
}, dir, {});
|
|
121
|
-
assert.match(String(result), /^Updated /);
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
assert.deepEqual([...readFileSync(withBom)], [
|
|
125
|
-
0xEF, 0xBB, 0xBF, ...Buffer.from('omega\nkeep\n'),
|
|
126
|
-
]);
|
|
127
|
-
assert.deepEqual([...readFileSync(noBom)], [...Buffer.from('omega\nkeep\n')]);
|
|
128
|
-
});
|
|
129
|
-
|
|
130
|
-
test('a missing final newline is not added back', async (t) => {
|
|
131
|
-
const dir = makeDir();
|
|
132
|
-
const file = join(dir, 'nofinal.txt');
|
|
133
|
-
t.after(() => { rmSync(dir, { recursive: true, force: true }); void closeNativePatchServerForTests?.(); });
|
|
134
|
-
writeFileSync(file, 'alpha\nkeep');
|
|
135
|
-
|
|
136
|
-
const result = await tryExecuteExternalToolAdapter('edit', {
|
|
137
|
-
file_path: file,
|
|
138
|
-
old_string: 'keep',
|
|
139
|
-
new_string: 'kept',
|
|
140
|
-
}, dir, {});
|
|
141
|
-
|
|
142
|
-
assert.match(String(result), /^Updated /);
|
|
143
|
-
assert.equal(readFileSync(file, 'utf8'), 'alpha\nkept');
|
|
144
|
-
});
|
|
145
|
-
|
|
146
|
-
test('malformed UTF-16 (odd trailing byte) is refused, not silently truncated', async (t) => {
|
|
147
|
-
const dir = makeDir();
|
|
148
|
-
const file = join(dir, 'odd-utf16.txt');
|
|
149
|
-
t.after(() => { rmSync(dir, { recursive: true, force: true }); void closeNativePatchServerForTests?.(); });
|
|
150
|
-
const bytes = Buffer.concat([
|
|
151
|
-
Buffer.from([0xFF, 0xFE]),
|
|
152
|
-
Buffer.from('alpha', 'utf16le'),
|
|
153
|
-
Buffer.from([0x41]), // dangling byte: undecodable, unrepresentable
|
|
154
|
-
]);
|
|
155
|
-
writeFileSync(file, bytes);
|
|
156
|
-
|
|
157
|
-
const result = String(await tryExecuteExternalToolAdapter('edit', {
|
|
158
|
-
file_path: file,
|
|
159
|
-
old_string: 'alpha',
|
|
160
|
-
new_string: 'omega',
|
|
161
|
-
}, dir, {}));
|
|
162
|
-
|
|
163
|
-
assert.match(result, /malformed UTF-16 with an odd trailing byte/);
|
|
164
|
-
assert.deepEqual([...readFileSync(file)], [...bytes]);
|
|
165
|
-
});
|
|
166
|
-
|
|
167
|
-
test('a mixed-EOL file keeps every terminator the edit did not replace', async (t) => {
|
|
168
|
-
const dir = makeDir();
|
|
169
|
-
const file = join(dir, 'mixed.txt');
|
|
170
|
-
t.after(() => { rmSync(dir, { recursive: true, force: true }); void closeNativePatchServerForTests?.(); });
|
|
171
|
-
const before = 'one\r\ntwo\nthree\r\nfour\n';
|
|
172
|
-
writeFileSync(file, before);
|
|
173
|
-
|
|
174
|
-
const result = await tryExecuteExternalToolAdapter('edit', {
|
|
175
|
-
file_path: file,
|
|
176
|
-
old_string: 'three',
|
|
177
|
-
new_string: 'THREE',
|
|
178
|
-
}, dir, {});
|
|
179
|
-
|
|
180
|
-
assert.match(String(result), /^Updated /);
|
|
181
|
-
const after = readFileSync(file, 'utf8');
|
|
182
|
-
assert.equal(after, 'one\r\ntwo\nthree\r\nfour\n'.replace('three', 'THREE'));
|
|
183
|
-
// Byte-level: everything outside the replaced span is untouched.
|
|
184
|
-
const at = before.indexOf('three');
|
|
185
|
-
assert.equal(after.slice(0, at), before.slice(0, at));
|
|
186
|
-
assert.equal(after.slice(at + 'THREE'.length), before.slice(at + 'three'.length));
|
|
187
|
-
});
|
|
188
|
-
|
|
189
|
-
test('an inserted line adopts the convention of the line it replaces, not the file', async (t) => {
|
|
190
|
-
const dir = makeDir();
|
|
191
|
-
const crlfLine = join(dir, 'mixed-crlf-line.txt');
|
|
192
|
-
const lfFile = join(dir, 'lf.txt');
|
|
193
|
-
t.after(() => { rmSync(dir, { recursive: true, force: true }); void closeNativePatchServerForTests?.(); });
|
|
194
|
-
// LF-dominant file, but the replaced line itself ends with CRLF.
|
|
195
|
-
writeFileSync(crlfLine, 'a\nb\r\nc\nd\n');
|
|
196
|
-
writeFileSync(lfFile, 'a\nb\n');
|
|
197
|
-
|
|
198
|
-
assert.match(String(await tryExecuteExternalToolAdapter('edit', {
|
|
199
|
-
file_path: crlfLine,
|
|
200
|
-
old_string: 'b',
|
|
201
|
-
new_string: 'b\nb2',
|
|
202
|
-
}, dir, {})), /^Updated /);
|
|
203
|
-
assert.equal(readFileSync(crlfLine, 'utf8'), 'a\nb\r\nb2\r\nc\nd\n');
|
|
204
|
-
|
|
205
|
-
// CRLF replacement text in an LF file normalizes to the local LF.
|
|
206
|
-
assert.match(String(await tryExecuteExternalToolAdapter('edit', {
|
|
207
|
-
file_path: lfFile,
|
|
208
|
-
old_string: 'b',
|
|
209
|
-
new_string: 'b\r\nb2',
|
|
210
|
-
}, dir, {})), /^Updated /);
|
|
211
|
-
assert.equal(readFileSync(lfFile, 'utf8'), 'a\nb\nb2\n');
|
|
212
|
-
});
|
|
213
|
-
|
|
214
|
-
test('a coalesced slice past the returned window never fabricates a footer', () => {
|
|
215
|
-
const body = ['1→a', '2→b', '3→c', '[lines 1-3 of 100; output truncated at 64 KB]'].join('\n');
|
|
216
|
-
|
|
217
|
-
const past = sliceReadBodyByLines(body, 10, 5);
|
|
218
|
-
assert.doesNotMatch(past, /\[lines \d+-\d+ of/);
|
|
219
|
-
assert.match(past, /NOT returned/);
|
|
220
|
-
|
|
221
|
-
const inside = sliceReadBodyByLines(body, 1, 5);
|
|
222
|
-
assert.match(inside, /^\[lines 2-3 of 100/m);
|
|
223
|
-
assert.match(inside, /2→b/);
|
|
224
|
-
});
|
|
@@ -1,224 +0,0 @@
|
|
|
1
|
-
// Same-anchor batch occupation: N edit calls sharing one old_string consume
|
|
2
|
-
// document-order occurrences in call order (tool-batch passes the remaining
|
|
3
|
-
// count via options.editOccurrence). Count drift must fall through to the
|
|
4
|
-
// native engine's strict ambiguity reject.
|
|
5
|
-
import { test } from 'node:test';
|
|
6
|
-
import assert from 'node:assert/strict';
|
|
7
|
-
import { mkdtempSync, readFileSync, rmSync, statSync, writeFileSync } from 'node:fs';
|
|
8
|
-
import { tmpdir } from 'node:os';
|
|
9
|
-
import { join } from 'node:path';
|
|
10
|
-
import { tryExecuteExternalToolAdapter } from './external-tool-adapters.mjs';
|
|
11
|
-
import { executeBuiltinTool } from '../builtin.mjs';
|
|
12
|
-
import { recordReadSnapshot } from './read-snapshot-runtime.mjs';
|
|
13
|
-
import { executePatchTool } from '../patch.mjs';
|
|
14
|
-
import { closeNativePatchServerForTests } from '../patch/native-server.mjs';
|
|
15
|
-
import { classifyToolFailure } from '../../agent-trace-format.mjs';
|
|
16
|
-
|
|
17
|
-
const ANCHOR = '#if 0\n"""\n#endif';
|
|
18
|
-
|
|
19
|
-
function makeTempFile(content) {
|
|
20
|
-
const dir = mkdtempSync(join(tmpdir(), 'mixdog-edit-seq-'));
|
|
21
|
-
const file = join(dir, 'poly.c');
|
|
22
|
-
writeFileSync(file, content, 'utf8');
|
|
23
|
-
return { dir, file };
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
test('occupation consumes the first occurrence, then the sibling resolves as unique', async (t) => {
|
|
27
|
-
const { dir, file } = makeTempFile(`${ANCHOR}\nmiddle\n${ANCHOR}\n`);
|
|
28
|
-
t.after(() => { rmSync(dir, { recursive: true, force: true }); void closeNativePatchServerForTests?.(); });
|
|
29
|
-
|
|
30
|
-
const first = await tryExecuteExternalToolAdapter('edit', {
|
|
31
|
-
file_path: file,
|
|
32
|
-
old_string: ANCHOR,
|
|
33
|
-
new_string: '#if 0\n""" "\n#endif',
|
|
34
|
-
}, dir, { editOccurrence: { expected: 2 } });
|
|
35
|
-
assert.match(String(first), /^Updated /);
|
|
36
|
-
|
|
37
|
-
const second = await tryExecuteExternalToolAdapter('edit', {
|
|
38
|
-
file_path: file,
|
|
39
|
-
old_string: ANCHOR,
|
|
40
|
-
new_string: '#if 0\n" """\n#endif',
|
|
41
|
-
}, dir, {});
|
|
42
|
-
assert.match(String(second), /^Updated /);
|
|
43
|
-
|
|
44
|
-
assert.equal(
|
|
45
|
-
readFileSync(file, 'utf8'),
|
|
46
|
-
'#if 0\n""" "\n#endif\nmiddle\n#if 0\n" """\n#endif\n',
|
|
47
|
-
);
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
test('count drift falls through to the strict ambiguity reject', async (t) => {
|
|
51
|
-
const { dir, file } = makeTempFile(`${ANCHOR}\n${ANCHOR}\n${ANCHOR}\n`);
|
|
52
|
-
t.after(() => { rmSync(dir, { recursive: true, force: true }); void closeNativePatchServerForTests?.(); });
|
|
53
|
-
|
|
54
|
-
const result = await tryExecuteExternalToolAdapter('edit', {
|
|
55
|
-
file_path: file,
|
|
56
|
-
old_string: ANCHOR,
|
|
57
|
-
new_string: 'changed',
|
|
58
|
-
}, dir, { editOccurrence: { expected: 2 } });
|
|
59
|
-
assert.match(String(result), /old_string found 3 times/);
|
|
60
|
-
assert.match(String(result), /current file excerpt lines/);
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
test('an edit on a body the session already read makes a follow-up read return unchanged', async (t) => {
|
|
64
|
-
const { dir, file } = makeTempFile('alpha\nkeep\n');
|
|
65
|
-
const sessionId = `edit-known-current-${process.pid}`;
|
|
66
|
-
t.after(() => { rmSync(dir, { recursive: true, force: true }); void closeNativePatchServerForTests?.(); });
|
|
67
|
-
|
|
68
|
-
// The "unchanged" stub is sound only because the model already holds the
|
|
69
|
-
// pre-edit body: deliver it first.
|
|
70
|
-
const firstRead = await executeBuiltinTool('read', { path: file }, dir, { sessionId });
|
|
71
|
-
assert.match(String(firstRead), /alpha/);
|
|
72
|
-
|
|
73
|
-
const result = await tryExecuteExternalToolAdapter('edit', {
|
|
74
|
-
file_path: file,
|
|
75
|
-
old_string: 'alpha',
|
|
76
|
-
new_string: 'omega',
|
|
77
|
-
}, dir, { sessionId });
|
|
78
|
-
assert.match(String(result), /^Updated /);
|
|
79
|
-
|
|
80
|
-
const reread = await executeBuiltinTool('read', { path: file }, dir, { sessionId });
|
|
81
|
-
assert.equal(reread, `[file unchanged: ${file.replaceAll('\\', '/')}]`);
|
|
82
|
-
});
|
|
83
|
-
|
|
84
|
-
test('an edit on a never-read file still delivers the body on the next read', async (t) => {
|
|
85
|
-
const { dir, file } = makeTempFile('alpha\nkeep\n');
|
|
86
|
-
const sessionId = `edit-unseen-body-${process.pid}`;
|
|
87
|
-
t.after(() => { rmSync(dir, { recursive: true, force: true }); void closeNativePatchServerForTests?.(); });
|
|
88
|
-
|
|
89
|
-
const result = await tryExecuteExternalToolAdapter('edit', {
|
|
90
|
-
file_path: file,
|
|
91
|
-
old_string: 'alpha',
|
|
92
|
-
new_string: 'omega',
|
|
93
|
-
}, dir, { sessionId });
|
|
94
|
-
assert.match(String(result), /^Updated /);
|
|
95
|
-
|
|
96
|
-
const reread = String(await executeBuiltinTool('read', { path: file }, dir, { sessionId }));
|
|
97
|
-
assert.doesNotMatch(reread, /file unchanged/);
|
|
98
|
-
assert.match(reread, /omega/);
|
|
99
|
-
});
|
|
100
|
-
|
|
101
|
-
test('an apply_patch on a body the session already read makes a follow-up read return unchanged', async (t) => {
|
|
102
|
-
const { dir, file } = makeTempFile('alpha\nkeep\n');
|
|
103
|
-
const sessionId = `patch-known-current-${process.pid}`;
|
|
104
|
-
t.after(() => { rmSync(dir, { recursive: true, force: true }); void closeNativePatchServerForTests?.(); });
|
|
105
|
-
|
|
106
|
-
const firstRead = await executeBuiltinTool('read', { path: file }, dir, { sessionId });
|
|
107
|
-
assert.match(String(firstRead), /alpha/);
|
|
108
|
-
|
|
109
|
-
const result = await executePatchTool('apply_patch', {
|
|
110
|
-
base_path: dir,
|
|
111
|
-
patch: `*** Begin Patch
|
|
112
|
-
*** Update File: poly.c
|
|
113
|
-
@@
|
|
114
|
-
-alpha
|
|
115
|
-
+omega
|
|
116
|
-
keep
|
|
117
|
-
*** End Patch
|
|
118
|
-
`,
|
|
119
|
-
}, dir, { sessionId });
|
|
120
|
-
// Executor (Native vs JS) depends on the engine-contract gate; the
|
|
121
|
-
// snapshot contract is what this test pins.
|
|
122
|
-
assert.match(String(result), /^Applied 1 File/);
|
|
123
|
-
|
|
124
|
-
const reread = await executeBuiltinTool('read', { path: file }, dir, { sessionId });
|
|
125
|
-
assert.equal(reread, `[file unchanged: ${file.replaceAll('\\', '/')}]`);
|
|
126
|
-
});
|
|
127
|
-
|
|
128
|
-
test('an external write between read and edit is never hidden by "file unchanged"', async (t) => {
|
|
129
|
-
const { dir, file } = makeTempFile('alpha\nkeep\n');
|
|
130
|
-
const sessionId = `edit-stale-prior-${process.pid}`;
|
|
131
|
-
t.after(() => { rmSync(dir, { recursive: true, force: true }); void closeNativePatchServerForTests?.(); });
|
|
132
|
-
|
|
133
|
-
const firstRead = await executeBuiltinTool('read', { path: file }, dir, { sessionId });
|
|
134
|
-
assert.match(String(firstRead), /alpha/);
|
|
135
|
-
|
|
136
|
-
// Someone else changes the file AFTER the session read it.
|
|
137
|
-
writeFileSync(file, 'alpha\nEXTERNAL\nkeep\n', 'utf8');
|
|
138
|
-
|
|
139
|
-
const result = await tryExecuteExternalToolAdapter('edit', {
|
|
140
|
-
file_path: file,
|
|
141
|
-
old_string: 'alpha',
|
|
142
|
-
new_string: 'omega',
|
|
143
|
-
}, dir, { sessionId });
|
|
144
|
-
assert.match(String(result), /^Updated /);
|
|
145
|
-
|
|
146
|
-
const reread = String(await executeBuiltinTool('read', { path: file }, dir, { sessionId }));
|
|
147
|
-
assert.doesNotMatch(reread, /file unchanged/);
|
|
148
|
-
assert.match(reread, /EXTERNAL/);
|
|
149
|
-
});
|
|
150
|
-
|
|
151
|
-
test('stale read snapshot does not block a still-unique current old_string', async (t) => {
|
|
152
|
-
const { dir, file } = makeTempFile('alpha\nkeep\n');
|
|
153
|
-
const sessionId = `edit-stale-safe-${process.pid}`;
|
|
154
|
-
t.after(() => { rmSync(dir, { recursive: true, force: true }); void closeNativePatchServerForTests?.(); });
|
|
155
|
-
recordReadSnapshot(file, statSync(file), sessionId, {
|
|
156
|
-
source: 'read',
|
|
157
|
-
isPartialView: false,
|
|
158
|
-
replaceExisting: true,
|
|
159
|
-
});
|
|
160
|
-
writeFileSync(file, 'external\nalpha\nkeep\n', 'utf8');
|
|
161
|
-
|
|
162
|
-
const result = await tryExecuteExternalToolAdapter('edit', {
|
|
163
|
-
file_path: file,
|
|
164
|
-
old_string: 'alpha',
|
|
165
|
-
new_string: 'omega',
|
|
166
|
-
}, dir, { sessionId });
|
|
167
|
-
|
|
168
|
-
assert.match(String(result), /^Updated /);
|
|
169
|
-
assert.equal(readFileSync(file, 'utf8'), 'external\nomega\nkeep\n');
|
|
170
|
-
});
|
|
171
|
-
|
|
172
|
-
test('edit failure excerpt centres on a distinctive token from any old_string line', async (t) => {
|
|
173
|
-
const { dir, file } = makeTempFile('const alpha = 1;\nconst beta = 2;\nconst DISTINCTIVE_TOKEN = 3;\ntail\n');
|
|
174
|
-
t.after(() => { rmSync(dir, { recursive: true, force: true }); void closeNativePatchServerForTests?.(); });
|
|
175
|
-
|
|
176
|
-
// The first old_string line carries no usable keyword. Scanning only that
|
|
177
|
-
// line returned no excerpt at all, and a bare "not found" was the edit
|
|
178
|
-
// failure that reliably produced identical retries.
|
|
179
|
-
const result = String(await tryExecuteExternalToolAdapter('edit', {
|
|
180
|
-
file_path: file,
|
|
181
|
-
old_string: '}\nconst DISTINCTIVE_TOKEN = 3;\nmissing_tail();',
|
|
182
|
-
new_string: 'irrelevant',
|
|
183
|
-
}, dir, {}));
|
|
184
|
-
assert.match(result, /old_string not found/);
|
|
185
|
-
assert.match(result, /current file excerpt lines/);
|
|
186
|
-
assert.match(result, /DISTINCTIVE_TOKEN/);
|
|
187
|
-
});
|
|
188
|
-
|
|
189
|
-
test('edit failure states plainly when nothing in the file resembles old_string', async (t) => {
|
|
190
|
-
const { dir, file } = makeTempFile('\n\n\n');
|
|
191
|
-
t.after(() => { rmSync(dir, { recursive: true, force: true }); void closeNativePatchServerForTests?.(); });
|
|
192
|
-
|
|
193
|
-
const result = String(await tryExecuteExternalToolAdapter('edit', {
|
|
194
|
-
file_path: file,
|
|
195
|
-
old_string: 'zzz',
|
|
196
|
-
new_string: 'yyy',
|
|
197
|
-
}, dir, {}));
|
|
198
|
-
assert.match(result, /contains nothing resembling old_string/);
|
|
199
|
-
});
|
|
200
|
-
|
|
201
|
-
test('a swallowed V4A envelope marker reports patch structure, not a context miss', async (t) => {
|
|
202
|
-
const { dir } = makeTempFile('alpha\nkeep\ntail\n');
|
|
203
|
-
t.after(() => { rmSync(dir, { recursive: true, force: true }); void closeNativePatchServerForTests?.(); });
|
|
204
|
-
|
|
205
|
-
const result = String(await executePatchTool('apply_patch', {
|
|
206
|
-
base_path: dir,
|
|
207
|
-
patch: `*** Begin Patch
|
|
208
|
-
*** Update File: poly.c
|
|
209
|
-
@@
|
|
210
|
-
alpha
|
|
211
|
-
keep
|
|
212
|
-
tail
|
|
213
|
-
*** End Patch ***
|
|
214
|
-
-gone
|
|
215
|
-
+kept
|
|
216
|
-
*** End Patch
|
|
217
|
-
`,
|
|
218
|
-
}, dir, {}));
|
|
219
|
-
assert.match(result, /structure error \(malformed patch envelope\)/);
|
|
220
|
-
assert.match(result, /appears as a content line at old\[4\]/);
|
|
221
|
-
assert.doesNotMatch(result, /context not found/);
|
|
222
|
-
// A patch-text defect must not be filed as stale edit evidence.
|
|
223
|
-
assert.equal(classifyToolFailure(result, 'apply_patch'), 'patch/parse');
|
|
224
|
-
});
|