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 { mkdtempSync, rmSync } from 'node:fs';
|
|
3
|
-
import { tmpdir } from 'node:os';
|
|
4
|
-
import { join } from 'node:path';
|
|
5
|
-
import test from 'node:test';
|
|
6
|
-
|
|
7
|
-
import {
|
|
8
|
-
cleanupBackgroundTasks,
|
|
9
|
-
completeBackgroundTask,
|
|
10
|
-
getBackgroundTask,
|
|
11
|
-
registerBackgroundTask,
|
|
12
|
-
renderBackgroundTask,
|
|
13
|
-
} from './background-tasks.mjs';
|
|
14
|
-
import { modelVisibleToolCompletionMessage } from './tool-execution-contract.mjs';
|
|
15
|
-
import { executeTaskTool } from '../agent/orchestrator/tools/builtin/task-tool.mjs';
|
|
16
|
-
import {
|
|
17
|
-
_dropPendingMessageState,
|
|
18
|
-
_settlePendingMessageWrites,
|
|
19
|
-
drainPendingMessages,
|
|
20
|
-
enqueuePendingMessage,
|
|
21
|
-
markCompletionEntry,
|
|
22
|
-
} from '../agent/orchestrator/session/manager/pending-messages.mjs';
|
|
23
|
-
import { _clearDeliveredCompletions } from '../agent/orchestrator/session/manager/delivered-completions.mjs';
|
|
24
|
-
|
|
25
|
-
test('terminal task read ACKs queued and racing completion notifications', async () => {
|
|
26
|
-
const root = mkdtempSync(join(tmpdir(), 'mixdog-task-read-ack-'));
|
|
27
|
-
const previousDataDir = process.env.MIXDOG_DATA_DIR;
|
|
28
|
-
const sessionId = `sess_task_read_ack_${process.pid}`;
|
|
29
|
-
const taskId = `task_read_ack_${process.pid}`;
|
|
30
|
-
process.env.MIXDOG_DATA_DIR = root;
|
|
31
|
-
try {
|
|
32
|
-
const task = registerBackgroundTask({
|
|
33
|
-
taskId,
|
|
34
|
-
surface: 'shell',
|
|
35
|
-
operation: 'shell',
|
|
36
|
-
context: { callerSessionId: sessionId },
|
|
37
|
-
});
|
|
38
|
-
const instruction = `Async shell task ${taskId} (completed, exit 0) finished.`;
|
|
39
|
-
completeBackgroundTask(taskId, {
|
|
40
|
-
status: 'completed',
|
|
41
|
-
resultText: 'command output',
|
|
42
|
-
resultType: 'shell_task_result',
|
|
43
|
-
instruction,
|
|
44
|
-
notify: false,
|
|
45
|
-
});
|
|
46
|
-
const completionText = renderBackgroundTask(task, { includeResult: true });
|
|
47
|
-
const visible = modelVisibleToolCompletionMessage(completionText, {
|
|
48
|
-
type: 'shell_task_result',
|
|
49
|
-
execution_surface: 'shell',
|
|
50
|
-
execution_id: taskId,
|
|
51
|
-
status: 'completed',
|
|
52
|
-
instruction,
|
|
53
|
-
});
|
|
54
|
-
const entry = markCompletionEntry(visible, { executionId: taskId });
|
|
55
|
-
assert.ok(enqueuePendingMessage(sessionId, entry) > 0);
|
|
56
|
-
await _settlePendingMessageWrites();
|
|
57
|
-
|
|
58
|
-
assert.match(
|
|
59
|
-
await executeTaskTool({ action: 'read', task_id: taskId }, { sessionId }),
|
|
60
|
-
/status: completed/,
|
|
61
|
-
);
|
|
62
|
-
assert.equal(getBackgroundTask(taskId).completionAcknowledged, true);
|
|
63
|
-
|
|
64
|
-
// Covers both orderings: already queued before the read, and a fallback
|
|
65
|
-
// enqueue that races in after the read ACK.
|
|
66
|
-
assert.ok(enqueuePendingMessage(sessionId, entry) > 0);
|
|
67
|
-
assert.deepEqual(drainPendingMessages(sessionId), []);
|
|
68
|
-
await _settlePendingMessageWrites();
|
|
69
|
-
} finally {
|
|
70
|
-
_dropPendingMessageState(sessionId);
|
|
71
|
-
await _settlePendingMessageWrites().catch(() => {});
|
|
72
|
-
cleanupBackgroundTasks({ force: true });
|
|
73
|
-
_clearDeliveredCompletions();
|
|
74
|
-
if (previousDataDir === undefined) delete process.env.MIXDOG_DATA_DIR;
|
|
75
|
-
else process.env.MIXDOG_DATA_DIR = previousDataDir;
|
|
76
|
-
rmSync(root, { recursive: true, force: true });
|
|
77
|
-
}
|
|
78
|
-
});
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import assert from 'node:assert/strict';
|
|
2
|
-
import { existsSync, mkdtempSync, readFileSync, rmSync } from 'node:fs';
|
|
3
|
-
import { tmpdir } from 'node:os';
|
|
4
|
-
import { join } from 'node:path';
|
|
5
|
-
import test from 'node:test';
|
|
6
|
-
|
|
7
|
-
import { readResponseBuffer, streamResponseToFile } from './bounded-download.mjs';
|
|
8
|
-
|
|
9
|
-
test('bounded downloads enforce declared and streamed byte limits', async () => {
|
|
10
|
-
const root = mkdtempSync(join(tmpdir(), 'mixdog-bounded-download-'));
|
|
11
|
-
try {
|
|
12
|
-
const good = join(root, 'good.bin');
|
|
13
|
-
await streamResponseToFile(new Response('hello', {
|
|
14
|
-
headers: { 'content-length': '5' },
|
|
15
|
-
}), good, { maxBytes: 5, expectedBytes: 5, label: 'fixture' });
|
|
16
|
-
assert.equal(readFileSync(good, 'utf8'), 'hello');
|
|
17
|
-
|
|
18
|
-
const oversized = join(root, 'oversized.bin');
|
|
19
|
-
await assert.rejects(
|
|
20
|
-
streamResponseToFile(new Response('too large'), oversized, {
|
|
21
|
-
maxBytes: 3,
|
|
22
|
-
label: 'fixture',
|
|
23
|
-
}),
|
|
24
|
-
/byte limit/,
|
|
25
|
-
);
|
|
26
|
-
assert.equal(existsSync(oversized), false);
|
|
27
|
-
} finally {
|
|
28
|
-
rmSync(root, { recursive: true, force: true });
|
|
29
|
-
}
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
test('bounded response buffers reject advertised and streamed overflow', async () => {
|
|
33
|
-
assert.equal(
|
|
34
|
-
(await readResponseBuffer(new Response('hello'), { maxBytes: 5, label: 'fixture' })).toString(),
|
|
35
|
-
'hello',
|
|
36
|
-
);
|
|
37
|
-
await assert.rejects(
|
|
38
|
-
readResponseBuffer(new Response('overflow'), { maxBytes: 3, label: 'fixture' }),
|
|
39
|
-
/byte limit/,
|
|
40
|
-
);
|
|
41
|
-
});
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import assert from 'node:assert/strict';
|
|
2
|
-
import test from 'node:test';
|
|
3
|
-
|
|
4
|
-
import {
|
|
5
|
-
channelNotificationModelContent,
|
|
6
|
-
channelNotificationSessionId,
|
|
7
|
-
} from './channel-notification-routing.mjs';
|
|
8
|
-
|
|
9
|
-
test('channel inbound targets the reserved session before first chat', () => {
|
|
10
|
-
assert.equal(channelNotificationSessionId(null, 'sess_reserved'), 'sess_reserved');
|
|
11
|
-
assert.equal(channelNotificationSessionId({ id: 'sess_live' }, 'sess_reserved'), 'sess_live');
|
|
12
|
-
assert.equal(channelNotificationSessionId(null, null), null);
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
test('channel inbound content and silent routing remain explicit', () => {
|
|
16
|
-
assert.equal(channelNotificationModelContent({ content: 'discord inbound' }), 'discord inbound');
|
|
17
|
-
assert.equal(channelNotificationModelContent({
|
|
18
|
-
content: 'ignored',
|
|
19
|
-
meta: { instruction: 'respond now' },
|
|
20
|
-
}), 'respond now');
|
|
21
|
-
assert.equal(channelNotificationModelContent({
|
|
22
|
-
content: 'ignored',
|
|
23
|
-
meta: { silent_to_agent: true },
|
|
24
|
-
}), '');
|
|
25
|
-
});
|
|
@@ -1,124 +0,0 @@
|
|
|
1
|
-
// Machine-wide child-spawn budget: every runtime shard must stay on the
|
|
2
|
-
// daemon-owned gate. Two ways that silently breaks (and multiplies the cap by
|
|
3
|
-
// the shard count) are covered here: an inherited env flag activating the
|
|
4
|
-
// process-local lane in a grandchild, and one failed lease latching a shard
|
|
5
|
-
// off the remote budget for the rest of its life.
|
|
6
|
-
import assert from 'node:assert/strict';
|
|
7
|
-
import { fork } from 'node:child_process';
|
|
8
|
-
import { mkdtemp, rm, writeFile } from 'node:fs/promises';
|
|
9
|
-
import { tmpdir } from 'node:os';
|
|
10
|
-
import { join } from 'node:path';
|
|
11
|
-
import { fileURLToPath } from 'node:url';
|
|
12
|
-
import test from 'node:test';
|
|
13
|
-
|
|
14
|
-
import { isSessionRuntimeWorkerProcess } from './child-spawn-remote.mjs';
|
|
15
|
-
|
|
16
|
-
const REMOTE_URL = new URL('./child-spawn-remote.mjs', import.meta.url).href;
|
|
17
|
-
const GATE_URL = new URL('./child-spawn-gate.mjs', import.meta.url).href;
|
|
18
|
-
|
|
19
|
-
const CHILD_SOURCE = `
|
|
20
|
-
const inherited = process.env.STUB_PID_MODE === 'inherited';
|
|
21
|
-
process.env.MIXDOG_SESSION_RUNTIME_WORKER = '1';
|
|
22
|
-
// A grandchild inherits BOTH variables; only its own pid differs.
|
|
23
|
-
process.env.MIXDOG_SESSION_RUNTIME_WORKER_PID = inherited
|
|
24
|
-
? String(process.pid + 1)
|
|
25
|
-
: String(process.pid);
|
|
26
|
-
const remote = await import(process.env.REMOTE_URL);
|
|
27
|
-
const gate = await import(process.env.GATE_URL);
|
|
28
|
-
const report = { enabled: remote.remoteSpawnLeasesEnabled(), mode: gate.snapshot().mode };
|
|
29
|
-
if (!inherited) {
|
|
30
|
-
try {
|
|
31
|
-
await remote.acquireRemoteSpawnLease({ lane: 'search', ownerKey: 'test', waitTimeoutMs: 30000 });
|
|
32
|
-
report.firstLease = 'granted';
|
|
33
|
-
} catch (error) {
|
|
34
|
-
report.firstLease = String(error?.code || error?.message || error);
|
|
35
|
-
}
|
|
36
|
-
report.enabledAfterFailure = remote.remoteSpawnLeasesEnabled();
|
|
37
|
-
report.modeAfterFailure = gate.snapshot().mode;
|
|
38
|
-
const release = await remote.acquireRemoteSpawnLease({ lane: 'search', ownerKey: 'test', waitTimeoutMs: 30000 });
|
|
39
|
-
report.secondLease = typeof release === 'function' ? 'granted' : 'unexpected';
|
|
40
|
-
release();
|
|
41
|
-
}
|
|
42
|
-
process.send({ type: 'report', report });
|
|
43
|
-
setTimeout(() => process.exit(0), 50).unref?.();
|
|
44
|
-
`;
|
|
45
|
-
|
|
46
|
-
async function runChild(mode, { onLease = () => {} } = {}) {
|
|
47
|
-
const dir = await mkdtemp(join(tmpdir(), 'mixdog-spawn-remote-'));
|
|
48
|
-
const entry = join(dir, 'child.mjs');
|
|
49
|
-
await writeFile(entry, CHILD_SOURCE, 'utf8');
|
|
50
|
-
try {
|
|
51
|
-
return await new Promise((resolve, reject) => {
|
|
52
|
-
const child = fork(entry, [], {
|
|
53
|
-
stdio: ['ignore', 'ignore', 'pipe', 'ipc'],
|
|
54
|
-
env: {
|
|
55
|
-
...process.env,
|
|
56
|
-
STUB_PID_MODE: mode,
|
|
57
|
-
REMOTE_URL,
|
|
58
|
-
GATE_URL,
|
|
59
|
-
},
|
|
60
|
-
});
|
|
61
|
-
const timer = setTimeout(() => {
|
|
62
|
-
try { child.kill(); } catch {}
|
|
63
|
-
reject(new Error('child spawn-lease probe timed out'));
|
|
64
|
-
}, 20_000);
|
|
65
|
-
let stderr = '';
|
|
66
|
-
child.stderr?.on('data', (chunk) => { stderr += String(chunk); });
|
|
67
|
-
child.on('message', (message) => {
|
|
68
|
-
if (message?.type === 'spawn-lease') {
|
|
69
|
-
onLease(child, message);
|
|
70
|
-
return;
|
|
71
|
-
}
|
|
72
|
-
if (message?.type !== 'report') return;
|
|
73
|
-
clearTimeout(timer);
|
|
74
|
-
try { child.kill(); } catch {}
|
|
75
|
-
resolve({ ...message.report, stderr });
|
|
76
|
-
});
|
|
77
|
-
child.on('error', reject);
|
|
78
|
-
});
|
|
79
|
-
} finally {
|
|
80
|
-
await rm(dir, { recursive: true, force: true });
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
test('only the pid-scoped runtime worker uses the machine-wide spawn budget', () => {
|
|
85
|
-
assert.equal(isSessionRuntimeWorkerProcess({ MIXDOG_SESSION_RUNTIME_WORKER_PID: '4242' }, 4242), true);
|
|
86
|
-
assert.equal(isSessionRuntimeWorkerProcess({ MIXDOG_SESSION_RUNTIME_WORKER_PID: '4242' }, 99), false);
|
|
87
|
-
// The inheritable flag alone can never claim the runtime IPC channel.
|
|
88
|
-
assert.equal(isSessionRuntimeWorkerProcess({ MIXDOG_SESSION_RUNTIME_WORKER: '1' }, 99), false);
|
|
89
|
-
assert.equal(isSessionRuntimeWorkerProcess({}, 99), false);
|
|
90
|
-
});
|
|
91
|
-
|
|
92
|
-
test('a grandchild that inherited the worker flag stays on its own local lane', async () => {
|
|
93
|
-
const report = await runChild('inherited');
|
|
94
|
-
assert.equal(report.enabled, false);
|
|
95
|
-
assert.equal(report.mode, 'local');
|
|
96
|
-
});
|
|
97
|
-
|
|
98
|
-
test('a failed lease never latches a shard off the machine-wide budget', async () => {
|
|
99
|
-
let leases = 0;
|
|
100
|
-
const report = await runChild('shard', {
|
|
101
|
-
onLease: (child, message) => {
|
|
102
|
-
leases += 1;
|
|
103
|
-
// First lease fails the way a momentarily unreachable pool does.
|
|
104
|
-
child.send(leases === 1
|
|
105
|
-
? {
|
|
106
|
-
type: 'spawn-lease-result',
|
|
107
|
-
leaseId: message.leaseId,
|
|
108
|
-
ok: false,
|
|
109
|
-
error: 'pool channel unavailable',
|
|
110
|
-
code: 'ELEASEFALLBACK',
|
|
111
|
-
}
|
|
112
|
-
: { type: 'spawn-lease-result', leaseId: message.leaseId, ok: true });
|
|
113
|
-
},
|
|
114
|
-
});
|
|
115
|
-
assert.equal(report.enabled, true);
|
|
116
|
-
assert.equal(report.mode, 'remote-lease');
|
|
117
|
-
assert.equal(report.firstLease, 'ELEASEFALLBACK');
|
|
118
|
-
// Recovery: the shard is still on the daemon budget and the next lease is
|
|
119
|
-
// granted remotely instead of silently using a per-process lane.
|
|
120
|
-
assert.equal(report.enabledAfterFailure, true);
|
|
121
|
-
assert.equal(report.modeAfterFailure, 'remote-lease');
|
|
122
|
-
assert.equal(report.secondLease, 'granted');
|
|
123
|
-
assert.equal(leases, 2);
|
|
124
|
-
});
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import assert from 'node:assert/strict';
|
|
2
|
-
import { mkdtempSync, rmSync, writeFileSync } from 'node:fs';
|
|
3
|
-
import { tmpdir } from 'node:os';
|
|
4
|
-
import { join } from 'node:path';
|
|
5
|
-
import test from 'node:test';
|
|
6
|
-
import { readRemoteIntent, remoteIntentMatchesSession } from './remote-intent.mjs';
|
|
7
|
-
|
|
8
|
-
test('remote intent matches only its own session and cwd', () => {
|
|
9
|
-
const dir = mkdtempSync(join(tmpdir(), 'mixdog-remote-intent-'));
|
|
10
|
-
const path = join(dir, 'channel-remote-intent.json');
|
|
11
|
-
try {
|
|
12
|
-
writeFileSync(path, JSON.stringify({
|
|
13
|
-
version: 1,
|
|
14
|
-
sessionId: 'sess_link',
|
|
15
|
-
transcriptPath: join(dir, 'sess_link.jsonl'),
|
|
16
|
-
cwd: dir,
|
|
17
|
-
updatedAt: Date.now(),
|
|
18
|
-
}));
|
|
19
|
-
assert.equal(readRemoteIntent(path)?.sessionId, 'sess_link');
|
|
20
|
-
assert.equal(remoteIntentMatchesSession('sess_link', dir, path), true);
|
|
21
|
-
assert.equal(remoteIntentMatchesSession('sess_other', dir, path), false);
|
|
22
|
-
assert.equal(remoteIntentMatchesSession('sess_link', join(dir, 'nested'), path), false);
|
|
23
|
-
assert.equal(remoteIntentMatchesSession('', dir, path), false);
|
|
24
|
-
assert.equal(remoteIntentMatchesSession('sess_link', dir, join(dir, 'missing.json')), false);
|
|
25
|
-
} finally {
|
|
26
|
-
rmSync(dir, { recursive: true, force: true });
|
|
27
|
-
}
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
test('a malformed intent record never claims a session', () => {
|
|
31
|
-
const dir = mkdtempSync(join(tmpdir(), 'mixdog-remote-intent-bad-'));
|
|
32
|
-
const path = join(dir, 'channel-remote-intent.json');
|
|
33
|
-
try {
|
|
34
|
-
writeFileSync(path, JSON.stringify({ sessionId: 'sess_link' }));
|
|
35
|
-
assert.equal(readRemoteIntent(path), null);
|
|
36
|
-
assert.equal(remoteIntentMatchesSession('sess_link', dir, path), false);
|
|
37
|
-
} finally {
|
|
38
|
-
rmSync(dir, { recursive: true, force: true });
|
|
39
|
-
}
|
|
40
|
-
});
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import assert from 'node:assert/strict';
|
|
2
|
-
import test from 'node:test';
|
|
3
|
-
|
|
4
|
-
import { ResourceAdmissionController } from './resource-admission.mjs';
|
|
5
|
-
|
|
6
|
-
test('provider-style waits yield and reacquire the current agent lease', async () => {
|
|
7
|
-
const admission = new ResourceAdmissionController({
|
|
8
|
-
limits: {
|
|
9
|
-
maxAgents: 1,
|
|
10
|
-
maxShells: 1,
|
|
11
|
-
maxHighLoad: 1,
|
|
12
|
-
maxQueue: 8,
|
|
13
|
-
},
|
|
14
|
-
});
|
|
15
|
-
const first = await admission.acquire('agent', { ownerKey: 'first' });
|
|
16
|
-
const waitStarted = Promise.withResolvers();
|
|
17
|
-
const finishWait = Promise.withResolvers();
|
|
18
|
-
let yieldedFinished = false;
|
|
19
|
-
|
|
20
|
-
const yielding = admission.runWithLease(first, () => admission.runYielded(async () => {
|
|
21
|
-
waitStarted.resolve();
|
|
22
|
-
await finishWait.promise;
|
|
23
|
-
return 'provider-result';
|
|
24
|
-
})).then((value) => {
|
|
25
|
-
yieldedFinished = true;
|
|
26
|
-
return value;
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
await waitStarted.promise;
|
|
30
|
-
assert.equal(admission.snapshot().active.agent, 0);
|
|
31
|
-
const second = await admission.acquire('agent', { ownerKey: 'second' });
|
|
32
|
-
assert.equal(admission.snapshot().active.agent, 1);
|
|
33
|
-
|
|
34
|
-
finishWait.resolve();
|
|
35
|
-
await new Promise((resolve) => setImmediate(resolve));
|
|
36
|
-
assert.equal(yieldedFinished, false, 'the first continuation waits to reacquire its slot');
|
|
37
|
-
|
|
38
|
-
await second.release();
|
|
39
|
-
assert.equal(await yielding, 'provider-result');
|
|
40
|
-
assert.equal(admission.snapshot().active.agent, 1);
|
|
41
|
-
await first.release();
|
|
42
|
-
assert.equal(admission.snapshot().active.agent, 0);
|
|
43
|
-
});
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import assert from 'node:assert/strict';
|
|
2
|
-
import { mkdtempSync, rmSync, statSync } from 'node:fs';
|
|
3
|
-
import { tmpdir } from 'node:os';
|
|
4
|
-
import { join } from 'node:path';
|
|
5
|
-
import test from 'node:test';
|
|
6
|
-
|
|
7
|
-
import {
|
|
8
|
-
ensurePrivateRuntimeRoot,
|
|
9
|
-
isolatedRuntimeRoot,
|
|
10
|
-
} from './runtime-root.mjs';
|
|
11
|
-
|
|
12
|
-
test('runtime roots isolate POSIX users without changing the Windows temp layout', () => {
|
|
13
|
-
assert.equal(
|
|
14
|
-
isolatedRuntimeRoot({ platform: 'linux', tempDir: '/var/tmp', uid: 1001 }),
|
|
15
|
-
join('/var/tmp', 'mixdog-1001'),
|
|
16
|
-
);
|
|
17
|
-
assert.equal(
|
|
18
|
-
isolatedRuntimeRoot({ platform: 'win32', tempDir: '/temp', uid: null }),
|
|
19
|
-
join('/temp', 'mixdog'),
|
|
20
|
-
);
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
test('runtime root creation is owner-only on POSIX', () => {
|
|
24
|
-
const parent = mkdtempSync(join(tmpdir(), 'mixdog-runtime-root-'));
|
|
25
|
-
const root = join(parent, 'runtime');
|
|
26
|
-
try {
|
|
27
|
-
assert.equal(ensurePrivateRuntimeRoot(root), root);
|
|
28
|
-
if (process.platform !== 'win32') {
|
|
29
|
-
assert.equal(statSync(root).mode & 0o777, 0o700);
|
|
30
|
-
}
|
|
31
|
-
} finally {
|
|
32
|
-
rmSync(parent, { recursive: true, force: true });
|
|
33
|
-
}
|
|
34
|
-
});
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import assert from 'node:assert/strict';
|
|
2
|
-
import test from 'node:test';
|
|
3
|
-
|
|
4
|
-
import { computeSnapshot } from '../channels/lib/status-snapshot.mjs';
|
|
5
|
-
import { resolveScheduleTimezone, validateScheduleCron } from './schedule-time.mjs';
|
|
6
|
-
|
|
7
|
-
test('schedule registration validates cron and persists an explicit timezone', () => {
|
|
8
|
-
assert.equal(validateScheduleCron('0 9 * * 1-5'), '0 9 * * 1-5');
|
|
9
|
-
assert.throws(() => validateScheduleCron('61 9 * * *'), /invalid cron expression/);
|
|
10
|
-
assert.equal(resolveScheduleTimezone('Asia/Seoul'), 'Asia/Seoul');
|
|
11
|
-
assert.throws(() => resolveScheduleTimezone('Mars/Olympus'), /invalid schedule timezone/);
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
test('schedule status uses the node-cron v4 getNextRun API', async () => {
|
|
15
|
-
const fireAt = new Date('2026-08-19T00:00:00.000Z');
|
|
16
|
-
const snapshot = await computeSnapshot({
|
|
17
|
-
cronJobs: new Map([['daily', { getNextRun: () => fireAt }]]),
|
|
18
|
-
oneShotTimers: new Map(),
|
|
19
|
-
nonInteractive: [],
|
|
20
|
-
interactive: [],
|
|
21
|
-
deferred: new Map(),
|
|
22
|
-
shouldSkip: () => false,
|
|
23
|
-
});
|
|
24
|
-
assert.deepEqual(snapshot.schedules.next, {
|
|
25
|
-
name: 'daily',
|
|
26
|
-
fireAt: fireAt.getTime(),
|
|
27
|
-
kind: 'cron',
|
|
28
|
-
});
|
|
29
|
-
});
|
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
import assert from 'node:assert/strict';
|
|
2
|
-
import test from 'node:test';
|
|
3
|
-
|
|
4
|
-
import {
|
|
5
|
-
createRuntimeLagTracker,
|
|
6
|
-
recordRuntimeDirectoryReadSuccess,
|
|
7
|
-
reportRuntimeAbortListenerPressure,
|
|
8
|
-
RUNTIME_LAG_DEFAULTS,
|
|
9
|
-
startRuntimeEventLoopLagMonitor,
|
|
10
|
-
} from './session-runtime-health.mjs';
|
|
11
|
-
|
|
12
|
-
test('sustained event-loop lag degrades a shard, a single spike does not', () => {
|
|
13
|
-
const tracker = createRuntimeLagTracker();
|
|
14
|
-
const spike = { p99Ms: RUNTIME_LAG_DEFAULTS.degradedP99Ms + 500 };
|
|
15
|
-
assert.equal(tracker.record(spike).degraded, false);
|
|
16
|
-
assert.equal(tracker.record(spike).degraded, false);
|
|
17
|
-
const degraded = tracker.record(spike);
|
|
18
|
-
assert.equal(degraded.degraded, true);
|
|
19
|
-
assert.equal(degraded.changed, true);
|
|
20
|
-
// Already degraded: no repeated transition.
|
|
21
|
-
assert.equal(tracker.record(spike).changed, false);
|
|
22
|
-
assert.equal(tracker.degraded, true);
|
|
23
|
-
|
|
24
|
-
// Hysteresis: still-elevated lag keeps the quarantine, a clean sample lifts it.
|
|
25
|
-
assert.equal(tracker.record({ p99Ms: RUNTIME_LAG_DEFAULTS.degradedP99Ms - 1 }).degraded, true);
|
|
26
|
-
const recovered = tracker.record({ p99Ms: 10 });
|
|
27
|
-
assert.equal(recovered.degraded, false);
|
|
28
|
-
assert.equal(recovered.changed, true);
|
|
29
|
-
|
|
30
|
-
// A fresh process starts from a clean slate.
|
|
31
|
-
tracker.record(spike);
|
|
32
|
-
tracker.reset();
|
|
33
|
-
assert.equal(tracker.degraded, false);
|
|
34
|
-
assert.equal(tracker.sample, null);
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
test('the event-loop lag monitor samples this process and stops cleanly', async () => {
|
|
38
|
-
const samples = [];
|
|
39
|
-
const stop = startRuntimeEventLoopLagMonitor({
|
|
40
|
-
intervalMs: 20,
|
|
41
|
-
onSample: (sample) => samples.push(sample),
|
|
42
|
-
});
|
|
43
|
-
try {
|
|
44
|
-
const deadline = Date.now() + 2_000;
|
|
45
|
-
while (samples.length === 0 && Date.now() < deadline) {
|
|
46
|
-
await new Promise((resolve) => setTimeout(resolve, 20));
|
|
47
|
-
}
|
|
48
|
-
} finally {
|
|
49
|
-
stop();
|
|
50
|
-
}
|
|
51
|
-
assert.ok(samples.length > 0, 'monitor produced at least one sample');
|
|
52
|
-
const [sample] = samples;
|
|
53
|
-
for (const key of ['p50Ms', 'p95Ms', 'p99Ms', 'maxMs']) {
|
|
54
|
-
assert.equal(Number.isFinite(sample[key]), true, `${key} is numeric`);
|
|
55
|
-
assert.ok(sample[key] >= 0);
|
|
56
|
-
}
|
|
57
|
-
const seen = samples.length;
|
|
58
|
-
await new Promise((resolve) => setTimeout(resolve, 80));
|
|
59
|
-
assert.equal(samples.length, seen, 'no samples after stop');
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
test('repeated AbortSignal listener pressure marks only the session runtime worker unhealthy', () => {
|
|
63
|
-
const originalRuntimeWorkerPid = process.env.MIXDOG_SESSION_RUNTIME_WORKER_PID;
|
|
64
|
-
let detail = null;
|
|
65
|
-
const onUnhealthy = (value) => { detail = value; };
|
|
66
|
-
process.env.MIXDOG_SESSION_RUNTIME_WORKER_PID = String(process.pid);
|
|
67
|
-
process.on('mixdog:session-runtime-worker-unhealthy', onUnhealthy);
|
|
68
|
-
recordRuntimeDirectoryReadSuccess();
|
|
69
|
-
try {
|
|
70
|
-
const warning = new Error('51 abort listeners added to [AbortSignal]');
|
|
71
|
-
assert.equal(reportRuntimeAbortListenerPressure(warning, 500, 0), false);
|
|
72
|
-
assert.equal(reportRuntimeAbortListenerPressure(warning, 1_000, 51), false);
|
|
73
|
-
assert.equal(reportRuntimeAbortListenerPressure(warning, 2_000, 51), false);
|
|
74
|
-
assert.equal(reportRuntimeAbortListenerPressure(warning, 3_000, 51), true);
|
|
75
|
-
assert.equal(detail?.code, 'ABORT_LISTENER_PRESSURE');
|
|
76
|
-
assert.equal(detail?.retainedListeners, 51);
|
|
77
|
-
} finally {
|
|
78
|
-
recordRuntimeDirectoryReadSuccess();
|
|
79
|
-
process.off('mixdog:session-runtime-worker-unhealthy', onUnhealthy);
|
|
80
|
-
if (originalRuntimeWorkerPid === undefined) delete process.env.MIXDOG_SESSION_RUNTIME_WORKER_PID;
|
|
81
|
-
else process.env.MIXDOG_SESSION_RUNTIME_WORKER_PID = originalRuntimeWorkerPid;
|
|
82
|
-
}
|
|
83
|
-
});
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
import assert from 'node:assert/strict';
|
|
2
|
-
import test from 'node:test';
|
|
3
|
-
|
|
4
|
-
import {
|
|
5
|
-
createSkillDocument,
|
|
6
|
-
parseSkillDocument,
|
|
7
|
-
updateSkillDocument,
|
|
8
|
-
validateSkillName,
|
|
9
|
-
} from './skill-document.mjs';
|
|
10
|
-
|
|
11
|
-
test('parses standard multiline YAML and the Markdown instructions body', () => {
|
|
12
|
-
const parsed = parseSkillDocument([
|
|
13
|
-
'---',
|
|
14
|
-
'name: imported-skill',
|
|
15
|
-
'description: >',
|
|
16
|
-
' Use when an imported skill',
|
|
17
|
-
' needs multiline matching.',
|
|
18
|
-
'metadata:',
|
|
19
|
-
' author: example',
|
|
20
|
-
'allowed-tools:',
|
|
21
|
-
' - shell',
|
|
22
|
-
'---',
|
|
23
|
-
'',
|
|
24
|
-
'# Instructions',
|
|
25
|
-
'',
|
|
26
|
-
'Read `references/guide.md`.',
|
|
27
|
-
'',
|
|
28
|
-
].join('\n'));
|
|
29
|
-
|
|
30
|
-
assert.equal(parsed.name, 'imported-skill');
|
|
31
|
-
assert.equal(parsed.description,
|
|
32
|
-
'Use when an imported skill needs multiline matching.');
|
|
33
|
-
assert.deepEqual(parsed.frontmatter.metadata, { author: 'example' });
|
|
34
|
-
assert.deepEqual(parsed.frontmatter['allowed-tools'], ['shell']);
|
|
35
|
-
assert.match(parsed.body, /^# Instructions/);
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
test('updates the three editable fields without dropping optional frontmatter', () => {
|
|
39
|
-
const source = [
|
|
40
|
-
'---',
|
|
41
|
-
'# retained comment',
|
|
42
|
-
'name: old-name',
|
|
43
|
-
'description: Old trigger.',
|
|
44
|
-
'license: MIT',
|
|
45
|
-
'compatibility: Requires Python.',
|
|
46
|
-
'metadata:',
|
|
47
|
-
' author: example',
|
|
48
|
-
'allowed-tools: shell',
|
|
49
|
-
'---',
|
|
50
|
-
'',
|
|
51
|
-
'Old instructions.',
|
|
52
|
-
'',
|
|
53
|
-
].join('\n');
|
|
54
|
-
|
|
55
|
-
const updated = updateSkillDocument(source, {
|
|
56
|
-
name: 'new-name',
|
|
57
|
-
description: 'Use when the new trigger matches.',
|
|
58
|
-
body: '# New instructions',
|
|
59
|
-
});
|
|
60
|
-
const parsed = parseSkillDocument(updated);
|
|
61
|
-
|
|
62
|
-
assert.equal(parsed.name, 'new-name');
|
|
63
|
-
assert.equal(parsed.description, 'Use when the new trigger matches.');
|
|
64
|
-
assert.equal(parsed.body, '# New instructions\n');
|
|
65
|
-
assert.equal(parsed.frontmatter.license, 'MIT');
|
|
66
|
-
assert.equal(parsed.frontmatter.compatibility, 'Requires Python.');
|
|
67
|
-
assert.deepEqual(parsed.frontmatter.metadata, { author: 'example' });
|
|
68
|
-
assert.equal(parsed.frontmatter['allowed-tools'], 'shell');
|
|
69
|
-
assert.match(updated, /# retained comment/);
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
test('creates a standard document and rejects non-standard names', () => {
|
|
73
|
-
const source = createSkillDocument({
|
|
74
|
-
name: 'project-skill',
|
|
75
|
-
description: 'Use when this project needs the skill.',
|
|
76
|
-
body: '# Instructions',
|
|
77
|
-
});
|
|
78
|
-
assert.equal(parseSkillDocument(source).name, 'project-skill');
|
|
79
|
-
assert.throws(() => validateSkillName('Project_Skill'), /lowercase letters/);
|
|
80
|
-
assert.throws(() => validateSkillName('project--skill'), /consecutive hyphens/);
|
|
81
|
-
});
|
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
import assert from 'node:assert/strict';
|
|
2
|
-
import test from 'node:test';
|
|
3
|
-
|
|
4
|
-
import {
|
|
5
|
-
aggregateDoneCategories,
|
|
6
|
-
formatAggregateHeader,
|
|
7
|
-
formatToolActionHeader,
|
|
8
|
-
isTaskWaitToolCall,
|
|
9
|
-
toolLoadingTargets,
|
|
10
|
-
} from './tool-surface.mjs';
|
|
11
|
-
import { deriveToolCardModel } from './tool-card-model.mjs';
|
|
12
|
-
|
|
13
|
-
test('git has a first-class completed action label', () => {
|
|
14
|
-
const args = { command: 'git status --short' };
|
|
15
|
-
const categories = aggregateDoneCategories([
|
|
16
|
-
{ name: 'git', args },
|
|
17
|
-
]);
|
|
18
|
-
|
|
19
|
-
assert.equal(formatAggregateHeader(categories), 'Ran 1 Git command');
|
|
20
|
-
assert.equal(formatToolActionHeader('git', args), 'Ran 1 Git command');
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
test('git batches aggregate without falling through to unknown tools', () => {
|
|
24
|
-
const header = formatAggregateHeader(aggregateDoneCategories([
|
|
25
|
-
{ name: 'git', args: { command: 'git status --short' } },
|
|
26
|
-
{ name: 'git', args: { command: 'git diff --stat' } },
|
|
27
|
-
]));
|
|
28
|
-
|
|
29
|
-
assert.equal(header, 'Ran 2 Git commands');
|
|
30
|
-
assert.doesNotMatch(header, /Called .* tool/);
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
test('agent spawn and terminal result use distinct lifecycle labels', () => {
|
|
34
|
-
assert.equal(
|
|
35
|
-
formatToolActionHeader('agent', { type: 'spawn', tag: 'review' }),
|
|
36
|
-
'Called 1 agent',
|
|
37
|
-
);
|
|
38
|
-
assert.equal(
|
|
39
|
-
formatToolActionHeader('agent', { type: 'result', status: 'completed', task_id: 'task-agent-1' }),
|
|
40
|
-
'Completed 1 agent',
|
|
41
|
-
);
|
|
42
|
-
assert.equal(
|
|
43
|
-
formatAggregateHeader(aggregateDoneCategories([
|
|
44
|
-
{ name: 'agent', args: { type: 'result', status: 'completed', task_id: 'task-agent-1' } },
|
|
45
|
-
])),
|
|
46
|
-
'Completed 1 agent',
|
|
47
|
-
);
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
test('deferred tool headers list every selected tool in input order', () => {
|
|
51
|
-
const args = { names: ['grep', 'code_graph', 'grep', 'memory'] };
|
|
52
|
-
assert.deepEqual(toolLoadingTargets('load_tool', args), ['grep', 'code_graph', 'memory']);
|
|
53
|
-
assert.equal(formatToolActionHeader('load_tool', args, { pending: true }), 'Loading grep, code_graph, memory');
|
|
54
|
-
assert.equal(formatToolActionHeader('load_tool', args), 'Loaded grep, code_graph, memory');
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
test('skill headers show the loaded skill name', () => {
|
|
58
|
-
assert.equal(
|
|
59
|
-
formatToolActionHeader('Skill', { name: 'gamerscroll-article' }, { pending: true }),
|
|
60
|
-
'Loading gamerscroll-article',
|
|
61
|
-
);
|
|
62
|
-
assert.equal(
|
|
63
|
-
formatToolActionHeader('Skill', { name: 'gamerscroll-article' }),
|
|
64
|
-
'Loaded gamerscroll-article',
|
|
65
|
-
);
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
test('aggregate loading cards preserve comma-separated tool and skill names', () => {
|
|
69
|
-
const model = deriveToolCardModel({
|
|
70
|
-
name: '__aggregate__',
|
|
71
|
-
aggregate: true,
|
|
72
|
-
args: { loadingTargets: ['grep', 'setup', 'memory'] },
|
|
73
|
-
categories: { Load: 2, Skill: 1 },
|
|
74
|
-
doneCategories: { Load: 2, Skill: 1 },
|
|
75
|
-
count: 3,
|
|
76
|
-
completedCount: 3,
|
|
77
|
-
result: 'Finished',
|
|
78
|
-
});
|
|
79
|
-
assert.equal(model.labelText, 'Loaded grep, setup, memory');
|
|
80
|
-
});
|
|
81
|
-
|
|
82
|
-
test('task wait display policy is scoped to the wait action', () => {
|
|
83
|
-
assert.equal(isTaskWaitToolCall('task', { action: 'wait', task_id: 'task_1' }), true);
|
|
84
|
-
assert.equal(isTaskWaitToolCall('functions.task', '{"action":"WAIT","task_id":"task_1"}'), true);
|
|
85
|
-
assert.equal(isTaskWaitToolCall('task', { action: 'read', task_id: 'task_1' }), false);
|
|
86
|
-
assert.equal(isTaskWaitToolCall('shell', { action: 'wait' }), false);
|
|
87
|
-
});
|