mixdog 0.9.46 → 0.9.49
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/package.json +14 -4
- package/scripts/agent-parallel-smoke.mjs +4 -1
- package/scripts/agent-route-batch-test.mjs +40 -0
- package/scripts/code-graph-aggregate-cwd-test.mjs +154 -0
- package/scripts/code-graph-description-contract.mjs +185 -0
- package/scripts/code-graph-disk-hit-test.mjs +55 -0
- package/scripts/code-graph-dispatch-test.mjs +96 -0
- package/scripts/compact-pressure-test.mjs +40 -0
- package/scripts/deferred-tool-loading-test.mjs +233 -0
- package/scripts/execution-completion-dedup-test.mjs +48 -0
- package/scripts/explore-prompt-policy-test.mjs +88 -3
- package/scripts/live-worker-smoke.mjs +68 -16
- package/scripts/memory-core-input-test.mjs +33 -13
- package/scripts/native-edit-wire-test.mjs +152 -0
- package/scripts/openai-oauth-ws-1006-retry-test.mjs +294 -16
- package/scripts/patch-binary-cache-test.mjs +181 -0
- package/scripts/prompt-immediate-render-test.mjs +89 -0
- package/scripts/provider-toolcall-test.mjs +280 -15
- package/scripts/shell-failure-diagnostics-test.mjs +211 -0
- package/scripts/statusline-quota-hysteresis-test.mjs +26 -1
- package/scripts/streaming-tail-window-test.mjs +29 -0
- package/scripts/tool-failures.mjs +21 -3
- package/scripts/tool-smoke.mjs +263 -38
- package/scripts/tool-tui-presentation-test.mjs +17 -1
- package/scripts/tui-perf-run.ps1 +26 -0
- package/scripts/tui-transcript-perf-test.mjs +7 -1
- package/scripts/verify-release-assets-test.mjs +647 -0
- package/scripts/verify-release-assets.mjs +293 -0
- package/scripts/windows-hide-spawn-options-test.mjs +19 -0
- package/src/cli.mjs +1 -0
- package/src/defaults/cycle3-review-prompt.md +10 -4
- package/src/defaults/memory-promote-prompt.md +4 -3
- package/src/runtime/agent/orchestrator/agent-trace-format.mjs +16 -5
- package/src/runtime/agent/orchestrator/providers/anthropic-oauth.mjs +35 -11
- package/src/runtime/agent/orchestrator/providers/anthropic.mjs +35 -11
- package/src/runtime/agent/orchestrator/providers/custom-tool-wire.mjs +28 -0
- package/src/runtime/agent/orchestrator/providers/openai-compat-wire.mjs +1 -1
- package/src/runtime/agent/orchestrator/providers/openai-oauth-ws.mjs +34 -34
- package/src/runtime/agent/orchestrator/providers/openai-oauth.mjs +45 -38
- package/src/runtime/agent/orchestrator/providers/openai-ws-pool.mjs +36 -11
- package/src/runtime/agent/orchestrator/providers/retry-classifier.mjs +4 -4
- package/src/runtime/agent/orchestrator/session/eager-dispatch.mjs +10 -6
- package/src/runtime/agent/orchestrator/session/loop/deferred-call-through.mjs +4 -3
- package/src/runtime/agent/orchestrator/session/loop/recall-fasttrack.mjs +4 -3
- package/src/runtime/agent/orchestrator/session/loop/tool-helpers.mjs +16 -1
- package/src/runtime/agent/orchestrator/session/manager/ask-session.mjs +2 -2
- package/src/runtime/agent/orchestrator/session/manager/compaction-runner.mjs +0 -1
- package/src/runtime/agent/orchestrator/session/tool-batch.mjs +13 -8
- package/src/runtime/agent/orchestrator/tools/builtin/bash-tool.mjs +30 -16
- package/src/runtime/agent/orchestrator/tools/code-graph/build.mjs +25 -8
- package/src/runtime/agent/orchestrator/tools/code-graph/dispatch.mjs +69 -4
- package/src/runtime/agent/orchestrator/tools/code-graph-prewarm-worker.mjs +5 -4
- package/src/runtime/agent/orchestrator/tools/code-graph-tool-defs.mjs +1 -1
- package/src/runtime/agent/orchestrator/tools/graph-manifest.json +12 -12
- package/src/runtime/agent/orchestrator/tools/patch/native-server.mjs +12 -7
- package/src/runtime/agent/orchestrator/tools/patch-binary-fetcher.mjs +77 -18
- package/src/runtime/agent/orchestrator/tools/patch-manifest.json +11 -11
- package/src/runtime/agent/orchestrator/tools/shell-command.mjs +99 -24
- package/src/runtime/memory/lib/memory-action-handlers.mjs +21 -11
- package/src/runtime/memory/lib/memory-cycle2-gate.mjs +13 -5
- package/src/runtime/memory/lib/memory-cycle2.mjs +8 -5
- package/src/runtime/memory/lib/memory-cycle3.mjs +41 -6
- package/src/runtime/memory/lib/query-handlers.mjs +49 -6
- package/src/runtime/memory/lib/recall-format.mjs +21 -6
- package/src/runtime/memory/tool-defs.mjs +2 -3
- package/src/session-runtime/context-status.mjs +25 -16
- package/src/session-runtime/model-route-api.mjs +2 -0
- package/src/session-runtime/runtime-core.mjs +2 -2
- package/src/session-runtime/session-turn-api.mjs +4 -1
- package/src/session-runtime/tool-catalog.mjs +113 -19
- package/src/session-runtime/tool-defs.mjs +1 -0
- package/src/standalone/agent-tool/helpers.mjs +25 -6
- package/src/standalone/agent-tool.mjs +75 -41
- package/src/tui/App.jsx +4 -0
- package/src/tui/app/input-parsers.mjs +8 -9
- package/src/tui/components/Markdown.jsx +6 -1
- package/src/tui/components/Message.jsx +11 -2
- package/src/tui/components/PromptInput.jsx +19 -21
- package/src/tui/components/Spinner.jsx +4 -4
- package/src/tui/components/StatusLine.jsx +6 -6
- package/src/tui/components/TranscriptItem.jsx +2 -2
- package/src/tui/components/prompt-input/immediate-render.mjs +47 -0
- package/src/tui/components/tool-execution/surface-detail.mjs +14 -9
- package/src/tui/dist/index.mjs +130 -45
- package/src/tui/engine/agent-job-feed.mjs +21 -2
- package/src/tui/engine/turn.mjs +12 -1
- package/src/tui/markdown/measure-rendered-rows.mjs +1 -1
- package/src/tui/markdown/streaming-markdown.mjs +20 -0
- package/src/ui/statusline.mjs +5 -5
- package/src/vendor/statusline/src/gateway/session-routes.mjs +22 -10
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import test from 'node:test';
|
|
3
|
+
import assert from 'node:assert/strict';
|
|
4
|
+
|
|
5
|
+
import {
|
|
6
|
+
applyDeferredToolSurface,
|
|
7
|
+
rebuildDeferredToolSurfaceForProvider,
|
|
8
|
+
reconcileDeferredMcpToolCatalog,
|
|
9
|
+
renderToolSearch,
|
|
10
|
+
} from '../src/session-runtime/tool-catalog.mjs';
|
|
11
|
+
import { prepareDeferredToolCallThrough } from '../src/runtime/agent/orchestrator/session/loop/deferred-call-through.mjs';
|
|
12
|
+
import { buildRequestBody } from '../src/runtime/agent/orchestrator/providers/openai-oauth.mjs';
|
|
13
|
+
import { _buildRequestBodyForCacheSmoke as buildAnthropicRequestBody } from '../src/runtime/agent/orchestrator/providers/anthropic-oauth.mjs';
|
|
14
|
+
|
|
15
|
+
const schema = { type: 'object', properties: {} };
|
|
16
|
+
const catalog = [
|
|
17
|
+
{ name: 'load_tool', description: 'Load deferred tools.', annotations: { readOnlyHint: true }, inputSchema: schema },
|
|
18
|
+
{ name: 'read', description: 'Read.', annotations: { readOnlyHint: true }, inputSchema: schema },
|
|
19
|
+
{ name: 'mcp__demo__ping', description: 'Ping.', annotations: { readOnlyHint: true }, inputSchema: schema },
|
|
20
|
+
];
|
|
21
|
+
|
|
22
|
+
test('OpenAI first/repeated load uses history schemas and keeps base tools/cache key stable', () => {
|
|
23
|
+
const session = { id: 'deferred-openai', provider: 'openai-oauth', tools: [], messages: [] };
|
|
24
|
+
applyDeferredToolSurface(session, 'full', catalog, { provider: session.provider });
|
|
25
|
+
const baseTools = JSON.stringify(session.tools);
|
|
26
|
+
const firstBody = buildRequestBody(
|
|
27
|
+
[{ role: 'user', content: 'load ping' }],
|
|
28
|
+
'gpt-5.4',
|
|
29
|
+
session.tools,
|
|
30
|
+
{ sessionId: session.id, session },
|
|
31
|
+
);
|
|
32
|
+
|
|
33
|
+
const first = JSON.parse(renderToolSearch({ names: ['mcp__demo__ping'] }, session, 'full'));
|
|
34
|
+
assert.deepEqual(first.loaded, ['mcp__demo__ping']);
|
|
35
|
+
assert.equal(session.tools.some((tool) => tool.name === 'mcp__demo__ping'), false);
|
|
36
|
+
assert.equal(JSON.stringify(session.tools), baseTools);
|
|
37
|
+
|
|
38
|
+
const history = [
|
|
39
|
+
{ role: 'user', content: 'load ping' },
|
|
40
|
+
{
|
|
41
|
+
role: 'assistant',
|
|
42
|
+
content: '',
|
|
43
|
+
toolCalls: [{
|
|
44
|
+
id: 'search-1',
|
|
45
|
+
name: 'load_tool',
|
|
46
|
+
arguments: { names: ['mcp__demo__ping'] },
|
|
47
|
+
nativeType: 'tool_search_call',
|
|
48
|
+
}],
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
role: 'tool',
|
|
52
|
+
toolCallId: 'search-1',
|
|
53
|
+
content: first.nativeToolSearch.summary,
|
|
54
|
+
nativeToolSearch: first.nativeToolSearch,
|
|
55
|
+
},
|
|
56
|
+
];
|
|
57
|
+
const followup = buildRequestBody(history, 'gpt-5.4', session.tools, {
|
|
58
|
+
sessionId: session.id,
|
|
59
|
+
session,
|
|
60
|
+
});
|
|
61
|
+
assert.equal(JSON.stringify(followup.tools), JSON.stringify(firstBody.tools));
|
|
62
|
+
assert.equal(followup.prompt_cache_key, firstBody.prompt_cache_key);
|
|
63
|
+
assert.equal(followup.tools.some((tool) => tool.name === 'mcp__demo__ping'), false);
|
|
64
|
+
assert.equal(
|
|
65
|
+
followup.input.find((item) => item.type === 'tool_search_output').tools[0].name,
|
|
66
|
+
'mcp__demo__ping',
|
|
67
|
+
);
|
|
68
|
+
|
|
69
|
+
const repeated = JSON.parse(renderToolSearch({ names: ['mcp__demo__ping'] }, session, 'full'));
|
|
70
|
+
assert.deepEqual(repeated.loaded, []);
|
|
71
|
+
assert.deepEqual(repeated.alreadyActive, ['mcp__demo__ping']);
|
|
72
|
+
assert.deepEqual(repeated.nativeToolSearch.toolReferences, []);
|
|
73
|
+
assert.deepEqual(repeated.nativeToolSearch.openaiTools, []);
|
|
74
|
+
assert.equal(JSON.stringify(session.tools), baseTools);
|
|
75
|
+
|
|
76
|
+
const repeatedFollowup = buildRequestBody([
|
|
77
|
+
...history,
|
|
78
|
+
{
|
|
79
|
+
role: 'assistant',
|
|
80
|
+
content: '',
|
|
81
|
+
toolCalls: [{
|
|
82
|
+
id: 'search-2',
|
|
83
|
+
name: 'load_tool',
|
|
84
|
+
arguments: { names: ['mcp__demo__ping'] },
|
|
85
|
+
nativeType: 'tool_search_call',
|
|
86
|
+
}],
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
role: 'tool',
|
|
90
|
+
toolCallId: 'search-2',
|
|
91
|
+
content: repeated.nativeToolSearch.summary,
|
|
92
|
+
nativeToolSearch: repeated.nativeToolSearch,
|
|
93
|
+
},
|
|
94
|
+
], 'gpt-5.4', session.tools, { sessionId: session.id, session });
|
|
95
|
+
const repeatedOutput = repeatedFollowup.input.at(-1);
|
|
96
|
+
assert.equal(JSON.stringify(repeatedFollowup.tools), JSON.stringify(firstBody.tools));
|
|
97
|
+
assert.equal(repeatedFollowup.prompt_cache_key, firstBody.prompt_cache_key);
|
|
98
|
+
assert.equal(repeatedFollowup.input.at(-2).type, 'tool_search_call');
|
|
99
|
+
assert.equal(repeatedOutput.type, 'tool_search_output');
|
|
100
|
+
assert.deepEqual(repeatedOutput.tools, []);
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
test('Anthropic repeated native loads retain an empty provider envelope', () => {
|
|
104
|
+
const session = { provider: 'anthropic-oauth', tools: [], messages: [] };
|
|
105
|
+
applyDeferredToolSurface(session, 'full', catalog, { provider: session.provider });
|
|
106
|
+
const first = JSON.parse(renderToolSearch({ names: ['mcp__demo__ping'] }, session, 'full'));
|
|
107
|
+
const before = JSON.stringify(session.tools);
|
|
108
|
+
const repeated = JSON.parse(renderToolSearch({ names: ['mcp__demo__ping'] }, session, 'full'));
|
|
109
|
+
|
|
110
|
+
assert.deepEqual(first.nativeToolSearch.toolReferences, ['mcp__demo__ping']);
|
|
111
|
+
assert.deepEqual(repeated.loaded, []);
|
|
112
|
+
assert.deepEqual(repeated.alreadyActive, ['mcp__demo__ping']);
|
|
113
|
+
assert.deepEqual(repeated.nativeToolSearch.toolReferences, []);
|
|
114
|
+
assert.deepEqual(repeated.nativeToolSearch.openaiTools, []);
|
|
115
|
+
assert.equal(JSON.stringify(session.tools), before);
|
|
116
|
+
assert.equal(session.deferredCallableTools.includes('mcp__demo__ping'), true);
|
|
117
|
+
assert.equal(session.deferredDiscoveredTools.includes('mcp__demo__ping'), true);
|
|
118
|
+
|
|
119
|
+
const body = buildAnthropicRequestBody([
|
|
120
|
+
{
|
|
121
|
+
role: 'assistant',
|
|
122
|
+
content: '',
|
|
123
|
+
toolCalls: [{ id: 'load-a1', name: 'load_tool', arguments: { names: ['mcp__demo__ping'] } }],
|
|
124
|
+
},
|
|
125
|
+
{
|
|
126
|
+
role: 'tool',
|
|
127
|
+
toolCallId: 'load-a1',
|
|
128
|
+
content: first.nativeToolSearch.summary,
|
|
129
|
+
nativeToolSearch: first.nativeToolSearch,
|
|
130
|
+
},
|
|
131
|
+
{
|
|
132
|
+
role: 'assistant',
|
|
133
|
+
content: '',
|
|
134
|
+
toolCalls: [{ id: 'load-a2', name: 'load_tool', arguments: { names: ['mcp__demo__ping'] } }],
|
|
135
|
+
},
|
|
136
|
+
{
|
|
137
|
+
role: 'tool',
|
|
138
|
+
toolCallId: 'load-a2',
|
|
139
|
+
content: repeated.nativeToolSearch.summary,
|
|
140
|
+
nativeToolSearch: repeated.nativeToolSearch,
|
|
141
|
+
},
|
|
142
|
+
], 'claude-sonnet-4-6', session.tools, { session });
|
|
143
|
+
const results = body.messages.flatMap((message) => (
|
|
144
|
+
Array.isArray(message.content) ? message.content.filter((block) => block.type === 'tool_result') : []
|
|
145
|
+
));
|
|
146
|
+
assert.deepEqual(results.map((block) => block.tool_use_id), ['load-a1', 'load-a2']);
|
|
147
|
+
assert.deepEqual(results[0].content, [{ type: 'tool_reference', tool_name: 'mcp__demo__ping' }]);
|
|
148
|
+
assert.equal(results[1].content, 'Already active: mcp__demo__ping');
|
|
149
|
+
assert.equal(body.tools.find((tool) => tool.name === 'mcp__demo__ping')?.defer_loading, true);
|
|
150
|
+
});
|
|
151
|
+
|
|
152
|
+
test('OpenAI API-key path accepts its own native tool_search_output history', () => {
|
|
153
|
+
const session = { id: 'deferred-openai-direct', provider: 'openai', tools: [], messages: [] };
|
|
154
|
+
applyDeferredToolSurface(session, 'full', catalog, { provider: session.provider });
|
|
155
|
+
const loaded = JSON.parse(renderToolSearch({ names: ['mcp__demo__ping'] }, session, 'full'));
|
|
156
|
+
const body = buildRequestBody([
|
|
157
|
+
{
|
|
158
|
+
role: 'assistant',
|
|
159
|
+
content: '',
|
|
160
|
+
toolCalls: [{
|
|
161
|
+
id: 'search-direct',
|
|
162
|
+
name: 'load_tool',
|
|
163
|
+
arguments: { names: ['mcp__demo__ping'] },
|
|
164
|
+
nativeType: 'tool_search_call',
|
|
165
|
+
}],
|
|
166
|
+
},
|
|
167
|
+
{
|
|
168
|
+
role: 'tool',
|
|
169
|
+
toolCallId: 'search-direct',
|
|
170
|
+
content: loaded.nativeToolSearch.summary,
|
|
171
|
+
nativeToolSearch: loaded.nativeToolSearch,
|
|
172
|
+
},
|
|
173
|
+
], 'gpt-5.4', session.tools, {
|
|
174
|
+
sessionId: session.id,
|
|
175
|
+
session,
|
|
176
|
+
promptCacheProvider: 'openai',
|
|
177
|
+
});
|
|
178
|
+
assert.equal(body.input[0].type, 'tool_search_call');
|
|
179
|
+
assert.equal(body.input[1].type, 'tool_search_output');
|
|
180
|
+
});
|
|
181
|
+
|
|
182
|
+
test('subsequent ordinary MCP calls use the callable registry, not session.tools promotion', () => {
|
|
183
|
+
const session = { provider: 'openai-oauth', toolSpec: 'full', tools: [], messages: [] };
|
|
184
|
+
applyDeferredToolSurface(session, 'full', catalog, { provider: session.provider });
|
|
185
|
+
JSON.parse(renderToolSearch({ names: ['mcp__demo__ping'] }, session, 'full'));
|
|
186
|
+
const before = JSON.stringify(session.tools);
|
|
187
|
+
assert.equal(prepareDeferredToolCallThrough(session, 'mcp__demo__ping', {}), null);
|
|
188
|
+
assert.equal(JSON.stringify(session.tools), before);
|
|
189
|
+
assert.equal(session.deferredCallableTools.includes('mcp__demo__ping'), true);
|
|
190
|
+
});
|
|
191
|
+
|
|
192
|
+
test('xAI/Grok and unsupported providers use a fixed canonical non-native surface', () => {
|
|
193
|
+
for (const provider of ['xai', 'grok-oauth', 'opencode-go']) {
|
|
194
|
+
const session = { provider, tools: [], messages: [] };
|
|
195
|
+
applyDeferredToolSurface(session, 'full', catalog, { provider });
|
|
196
|
+
const before = JSON.stringify(session.tools);
|
|
197
|
+
const result = JSON.parse(renderToolSearch({ names: ['mcp__demo__ping'] }, session, 'full'));
|
|
198
|
+
assert.equal(session.deferredNativeTools, false);
|
|
199
|
+
assert.equal(result.nativeToolSearch, undefined);
|
|
200
|
+
assert.deepEqual(result.alreadyActive, ['mcp__demo__ping']);
|
|
201
|
+
assert.equal(JSON.stringify(session.tools), before);
|
|
202
|
+
}
|
|
203
|
+
});
|
|
204
|
+
|
|
205
|
+
test('Gemini manifest changes only at the next user-turn reconciliation', () => {
|
|
206
|
+
const session = { provider: 'gemini', tools: [], messages: [] };
|
|
207
|
+
applyDeferredToolSurface(session, 'full', catalog.slice(0, 2), { provider: session.provider });
|
|
208
|
+
const duringTurn = JSON.stringify(session.tools);
|
|
209
|
+
const orderedBaseNames = session.tools.map((tool) => tool.name);
|
|
210
|
+
assert.equal(JSON.stringify(session.tools), duringTurn);
|
|
211
|
+
|
|
212
|
+
reconcileDeferredMcpToolCatalog(session, [catalog[2]]);
|
|
213
|
+
assert.deepEqual(session.tools.map((tool) => tool.name), [...orderedBaseNames, 'mcp__demo__ping']);
|
|
214
|
+
assert.equal(session.deferredProviderMode, 'manifest');
|
|
215
|
+
});
|
|
216
|
+
|
|
217
|
+
test('live provider switching rebuilds native and canonical surfaces in both directions', () => {
|
|
218
|
+
const session = { provider: 'openai-oauth', tools: [], messages: [] };
|
|
219
|
+
applyDeferredToolSurface(session, 'full', catalog, { provider: session.provider });
|
|
220
|
+
assert.equal(session.tools.some((tool) => tool.name === 'mcp__demo__ping'), false);
|
|
221
|
+
|
|
222
|
+
rebuildDeferredToolSurfaceForProvider(session, 'xai');
|
|
223
|
+
session.provider = 'xai';
|
|
224
|
+
assert.equal(session.deferredProviderMode, 'canonical');
|
|
225
|
+
assert.deepEqual(session.tools.map((tool) => tool.name), session.deferredCallableTools);
|
|
226
|
+
assert.equal(session.tools.some((tool) => tool.name === 'mcp__demo__ping'), true);
|
|
227
|
+
|
|
228
|
+
rebuildDeferredToolSurfaceForProvider(session, 'openai');
|
|
229
|
+
session.provider = 'openai';
|
|
230
|
+
assert.equal(session.deferredProviderMode, 'native');
|
|
231
|
+
assert.equal(session.tools.some((tool) => tool.name === 'mcp__demo__ping'), false);
|
|
232
|
+
assert.equal(session.deferredCallableTools.includes('mcp__demo__ping'), false);
|
|
233
|
+
});
|
|
@@ -155,3 +155,51 @@ test('bodyless failure preview does not suppress its later body', () => {
|
|
|
155
155
|
deliver({ content: 'Async agent task task_fail completed.\n\nResult:\n> retry', meta: { type: 'background_task_result', execution_id: 'task_fail', status: 'finished' } });
|
|
156
156
|
assert.equal(cardPushes(), 2, 'same-body retry remains idempotent');
|
|
157
157
|
});
|
|
158
|
+
|
|
159
|
+
test('parallel agent status bursts coalesce to one status snapshot per frame', async () => {
|
|
160
|
+
let handler = null;
|
|
161
|
+
let setCalls = 0;
|
|
162
|
+
const statusArgs = [];
|
|
163
|
+
const feed = createAgentJobFeed({
|
|
164
|
+
runtime: { onNotification: (fn) => { handler = fn; return () => {}; } },
|
|
165
|
+
getState: () => ({ busy: false }),
|
|
166
|
+
set: () => { setCalls += 1; },
|
|
167
|
+
nextId: () => 'id',
|
|
168
|
+
getDisposed: () => false,
|
|
169
|
+
patchItem: () => {},
|
|
170
|
+
enqueue: () => true,
|
|
171
|
+
drain: () => Promise.resolve(),
|
|
172
|
+
pushUserOrSyntheticItem: () => {},
|
|
173
|
+
makeQueueEntry: (text, opts = {}) => ({ text, ...opts }),
|
|
174
|
+
getPending: () => [],
|
|
175
|
+
agentStatusState: (args) => {
|
|
176
|
+
statusArgs.push(args);
|
|
177
|
+
return {};
|
|
178
|
+
},
|
|
179
|
+
displayedExecutionNotificationKeys: new Set(),
|
|
180
|
+
pushNotice: () => {},
|
|
181
|
+
});
|
|
182
|
+
const unsubscribe = feed.subscribeRuntimeNotifications();
|
|
183
|
+
|
|
184
|
+
for (let i = 0; i < 24; i += 1) {
|
|
185
|
+
handler({
|
|
186
|
+
content: `agent task: burst_${i}\nstatus: running`,
|
|
187
|
+
meta: { type: 'agent_task_status', execution_id: `burst_${i}`, status: 'running' },
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
assert.equal(setCalls, 0, 'burst stays deferred until the coalesce boundary');
|
|
191
|
+
await new Promise((resolve) => setTimeout(resolve, 30));
|
|
192
|
+
assert.equal(setCalls, 1);
|
|
193
|
+
assert.equal(statusArgs.length, 1);
|
|
194
|
+
|
|
195
|
+
for (let i = 0; i < 24; i += 1) {
|
|
196
|
+
handler({
|
|
197
|
+
content: `agent task: burst_${i}\nstatus: completed`,
|
|
198
|
+
meta: { type: 'agent_task_result', execution_id: `burst_${i}`, status: 'completed' },
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
await new Promise((resolve) => setTimeout(resolve, 30));
|
|
202
|
+
assert.equal(setCalls, 2);
|
|
203
|
+
assert.deepEqual(statusArgs.at(-1), { force: true }, 'terminal burst forces one fresh snapshot');
|
|
204
|
+
unsubscribe();
|
|
205
|
+
});
|
|
@@ -6,7 +6,14 @@ import { buildExplorerPrompt } from '../src/standalone/explore-tool.mjs';
|
|
|
6
6
|
import { EXPLORE_TOOL } from '../src/standalone/explore-tool.mjs';
|
|
7
7
|
import { BUILTIN_TOOLS } from '../src/runtime/agent/orchestrator/tools/builtin/builtin-tools.mjs';
|
|
8
8
|
import { CODE_GRAPH_TOOL_DEFS } from '../src/runtime/agent/orchestrator/tools/code-graph-tool-defs.mjs';
|
|
9
|
-
import {
|
|
9
|
+
import { TOOL_SEARCH_TOOL } from '../src/session-runtime/tool-defs.mjs';
|
|
10
|
+
import { createEagerDispatcher } from '../src/runtime/agent/orchestrator/session/eager-dispatch.mjs';
|
|
11
|
+
import { crossTurnSignature } from '../src/runtime/agent/orchestrator/session/loop/completion-guards.mjs';
|
|
12
|
+
import {
|
|
13
|
+
isEagerDispatchable,
|
|
14
|
+
isToolCallDedupEligible,
|
|
15
|
+
} from '../src/runtime/agent/orchestrator/session/loop/tool-helpers.mjs';
|
|
16
|
+
import { assertCodeGraphDescriptionContract } from './code-graph-description-contract.mjs';
|
|
10
17
|
|
|
11
18
|
test('explore per-query prompt contains only escaped query XML', () => {
|
|
12
19
|
const prompt = buildExplorerPrompt('display model usage show usage model_usage provider_usage session cache usage state');
|
|
@@ -89,9 +96,19 @@ test('explorer locator policy retains its compact behavioral contract', () => {
|
|
|
89
96
|
});
|
|
90
97
|
|
|
91
98
|
test('canonical schemas advertise safe batching without changing tool shapes', () => {
|
|
92
|
-
const graph =
|
|
99
|
+
const graph = CODE_GRAPH_TOOL_DEFS[0];
|
|
93
100
|
const patch = readFileSync(new URL('../src/runtime/agent/orchestrator/tools/patch-tool-defs.mjs', import.meta.url), 'utf8');
|
|
94
|
-
|
|
101
|
+
const mode = graph?.inputSchema?.properties?.mode?.description || '';
|
|
102
|
+
const description = graph?.description || '';
|
|
103
|
+
const symbols = graph?.inputSchema?.properties?.symbols?.description || '';
|
|
104
|
+
assert.doesNotThrow(() => assertCodeGraphDescriptionContract({
|
|
105
|
+
description,
|
|
106
|
+
modeDescription: mode,
|
|
107
|
+
symbolsDescription: symbols,
|
|
108
|
+
}));
|
|
109
|
+
assert.deepEqual(graph?.inputSchema?.required, ['mode']);
|
|
110
|
+
assert.equal(graph?.inputSchema?.properties?.file, undefined);
|
|
111
|
+
assert.equal(graph?.inputSchema?.properties?.symbol, undefined);
|
|
95
112
|
assert.match(patch, /one patch/i);
|
|
96
113
|
assert.match(patch, /one file block per target/i);
|
|
97
114
|
});
|
|
@@ -121,6 +138,74 @@ test('code graph and eager-dispatch boundaries preserve runtime shape', () => {
|
|
|
121
138
|
assert.equal(isEagerDispatchable('shell', tools), false);
|
|
122
139
|
assert.equal(isEagerDispatchable('mcp_read', tools), true);
|
|
123
140
|
assert.equal(isEagerDispatchable('mcp_write', tools), false);
|
|
141
|
+
assert.equal(isToolCallDedupEligible('read', tools), true);
|
|
142
|
+
assert.equal(isToolCallDedupEligible('mcp_read', tools), true);
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
test('same-batch load_tool and legacy tool_search repeats all execute eagerly', async () => {
|
|
146
|
+
const tools = [...BUILTIN_TOOLS, TOOL_SEARCH_TOOL];
|
|
147
|
+
assert.equal(isEagerDispatchable('load_tool', tools), true);
|
|
148
|
+
assert.equal(isEagerDispatchable('tool_search', tools), true);
|
|
149
|
+
assert.equal(isToolCallDedupEligible('load_tool', tools), false);
|
|
150
|
+
assert.equal(isToolCallDedupEligible('tool_search', tools), false);
|
|
151
|
+
assert.equal(isToolCallDedupEligible('read', tools), true);
|
|
152
|
+
|
|
153
|
+
const args = { names: ['shell'] };
|
|
154
|
+
const calls = [
|
|
155
|
+
{ id: 'load-1', name: 'load_tool', arguments: args },
|
|
156
|
+
{ id: 'load-2', name: 'load_tool', arguments: args },
|
|
157
|
+
{ id: 'legacy-1', name: 'tool_search', arguments: args },
|
|
158
|
+
{ id: 'legacy-2', name: 'tool_search', arguments: args },
|
|
159
|
+
];
|
|
160
|
+
const executed = [];
|
|
161
|
+
const crossTurnCalls = new Map([
|
|
162
|
+
[crossTurnSignature('load_tool', args), { count: 1, firstIteration: 1 }],
|
|
163
|
+
[crossTurnSignature('tool_search', args), { count: 1, firstIteration: 1 }],
|
|
164
|
+
]);
|
|
165
|
+
const dispatcher = createEagerDispatcher({
|
|
166
|
+
tools,
|
|
167
|
+
cwd: process.cwd(),
|
|
168
|
+
sessionId: null,
|
|
169
|
+
sessionRef: {},
|
|
170
|
+
signal: null,
|
|
171
|
+
opts: {},
|
|
172
|
+
crossTurnCalls,
|
|
173
|
+
getIterations: () => 2,
|
|
174
|
+
getNextIteration: () => 2,
|
|
175
|
+
repeatFailLimit: 3,
|
|
176
|
+
executeToolFn: async (name) => {
|
|
177
|
+
executed.push(name);
|
|
178
|
+
return '{}';
|
|
179
|
+
},
|
|
180
|
+
});
|
|
181
|
+
dispatcher.startEagerRun(calls, 0, new Set());
|
|
182
|
+
assert.equal(dispatcher.pending.size, 4);
|
|
183
|
+
await Promise.all([...dispatcher.pending.values()].map((entry) => entry.promise));
|
|
184
|
+
assert.deepEqual(executed, ['load_tool', 'load_tool', 'tool_search', 'tool_search']);
|
|
185
|
+
|
|
186
|
+
const normalExecuted = [];
|
|
187
|
+
const normalDispatcher = createEagerDispatcher({
|
|
188
|
+
tools,
|
|
189
|
+
cwd: process.cwd(),
|
|
190
|
+
sessionId: null,
|
|
191
|
+
sessionRef: {},
|
|
192
|
+
signal: null,
|
|
193
|
+
opts: {},
|
|
194
|
+
crossTurnCalls: new Map(),
|
|
195
|
+
getIterations: () => 1,
|
|
196
|
+
getNextIteration: () => 1,
|
|
197
|
+
repeatFailLimit: 3,
|
|
198
|
+
executeToolFn: async (name) => {
|
|
199
|
+
normalExecuted.push(name);
|
|
200
|
+
return 'ok';
|
|
201
|
+
},
|
|
202
|
+
});
|
|
203
|
+
normalDispatcher.startEagerRun([
|
|
204
|
+
{ id: 'read-1', name: 'read', arguments: { path: 'same.txt' } },
|
|
205
|
+
{ id: 'read-2', name: 'read', arguments: { path: 'same.txt' } },
|
|
206
|
+
], 0, new Set());
|
|
207
|
+
await Promise.all([...normalDispatcher.pending.values()].map((entry) => entry.promise));
|
|
208
|
+
assert.deepEqual(normalExecuted, ['read']);
|
|
124
209
|
});
|
|
125
210
|
|
|
126
211
|
test('code graph descriptions partition file and symbol targets', () => {
|
|
@@ -19,6 +19,10 @@ const root = mkdtempSync(join(tmpdir(), 'mixdog-live-worker-'));
|
|
|
19
19
|
const dataDir = join(root, '.mixdog-data');
|
|
20
20
|
let activeAsks = 0;
|
|
21
21
|
let maxActiveAsks = 0;
|
|
22
|
+
let releaseBusyGate = null;
|
|
23
|
+
let busySafetyTimer = null;
|
|
24
|
+
let agentRunner = null;
|
|
25
|
+
let runnerClosed = false;
|
|
22
26
|
|
|
23
27
|
function assert(condition, message) {
|
|
24
28
|
if (!condition) throw new Error(message);
|
|
@@ -28,6 +32,33 @@ function sleep(ms) {
|
|
|
28
32
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
29
33
|
}
|
|
30
34
|
|
|
35
|
+
function waitForBusyRelease() {
|
|
36
|
+
return new Promise((resolve) => {
|
|
37
|
+
const release = () => {
|
|
38
|
+
if (busySafetyTimer) clearTimeout(busySafetyTimer);
|
|
39
|
+
busySafetyTimer = null;
|
|
40
|
+
if (releaseBusyGate === release) releaseBusyGate = null;
|
|
41
|
+
resolve();
|
|
42
|
+
};
|
|
43
|
+
releaseBusyGate = release;
|
|
44
|
+
busySafetyTimer = setTimeout(release, 10_000);
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function releaseBusyWorker() {
|
|
49
|
+
const release = releaseBusyGate;
|
|
50
|
+
releaseBusyGate = null;
|
|
51
|
+
if (busySafetyTimer) clearTimeout(busySafetyTimer);
|
|
52
|
+
busySafetyTimer = null;
|
|
53
|
+
release?.();
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function closeAgentRunner() {
|
|
57
|
+
if (!agentRunner || runnerClosed) return;
|
|
58
|
+
runnerClosed = true;
|
|
59
|
+
agentRunner.closeAll('live-worker-smoke-end');
|
|
60
|
+
}
|
|
61
|
+
|
|
31
62
|
function taskId(text) {
|
|
32
63
|
return String(text).match(/agent task: (\S+)/)?.[1] || null;
|
|
33
64
|
}
|
|
@@ -45,13 +76,16 @@ async function main() {
|
|
|
45
76
|
.split(/[.!?]\s+|;|,\s+(?=(?:but|however|yet)\b)/)
|
|
46
77
|
.some((clause) => {
|
|
47
78
|
const hasReview = /\b(review|reviewer|verification)\b/.test(clause);
|
|
48
|
-
const hasSkip = /\b(skip|skipping|skipped|omit|omits|omitting|omitted)\b/.test(clause) ||
|
|
79
|
+
const hasSkip = /\b(skip|skipping|skipped|skippable|omit|omits|omitting|omitted)\b/.test(clause) ||
|
|
49
80
|
/\bwithout\s+(?:any\s+)?(?:a\s+)?(?:review|reviewer|verification)\b/.test(clause);
|
|
50
|
-
const
|
|
51
|
-
|
|
81
|
+
const weakRequirement = /\b(?:optional|unnecessary|not required|need not)\b/.test(clause);
|
|
82
|
+
const negated = /\b(?:never|(?:must|shall|may)\s+not|can(?:not|'t)|do\s+not|don't|not)\b[^;]{0,40}\b(?:skip|skipping|skipped|skippable|omit|omitting|omitted)\b/.test(clause) ||
|
|
83
|
+
/\b(?:skip|skipping|skipped|skippable|omit|omitting|omitted)\b[^;]{0,40}\b(?:not allowed|forbidden|prohibited)\b/.test(clause) ||
|
|
52
84
|
/\b(?:never|(?:must|shall|may)\s+not|can(?:not|'t)|do\s+not|don't|not)\b[^;]{0,40}\bwithout\s+(?:any\s+)?(?:a\s+)?(?:review|reviewer|verification)\b/.test(clause);
|
|
85
|
+
const negatedWeakRequirement = /\b(?:not|never)\s+(?:optional|unnecessary)\b/.test(clause);
|
|
53
86
|
const exception = /\b(?:unless|except(?:\s+when)?|only\s+if)\b/.test(clause);
|
|
54
|
-
return hasReview && hasSkip && (!negated || exception)
|
|
87
|
+
return hasReview && ((hasSkip && (!negated || exception)) ||
|
|
88
|
+
(weakRequirement && (!negatedWeakRequirement || exception)));
|
|
55
89
|
});
|
|
56
90
|
for (const [phrase, expected] of [
|
|
57
91
|
['Never skip Reviewer verification', false],
|
|
@@ -63,16 +97,24 @@ async function main() {
|
|
|
63
97
|
['Never skip review only if low-risk', true],
|
|
64
98
|
['May omit review', true],
|
|
65
99
|
['Proceed without review', true],
|
|
100
|
+
['Review is optional', true],
|
|
101
|
+
['Review is unnecessary', true],
|
|
102
|
+
['Review is not required', true],
|
|
103
|
+
['Review is skippable for low-risk work', true],
|
|
104
|
+
['Review is not optional', false],
|
|
105
|
+
['Review is not unnecessary', false],
|
|
66
106
|
]) assert(reviewSkipViolation(phrase) === expected, `review-skip detector case failed: ${phrase}`);
|
|
67
107
|
const skipsReview = reviewSkipViolation(workflow);
|
|
68
108
|
assert(hasAll(lead, 'write-role agents self-verify', 'cross-scope verification', 'benches', 'all git', 'current project/workspace'), 'lead tool rules must preserve verification, git, and workspace ownership');
|
|
69
|
-
assert(hasAll(workflow, '
|
|
70
|
-
assert(hasAll(workflow, '
|
|
71
|
-
assert(hasAll(workflow, 'implementation/
|
|
72
|
-
assert(hasAll(workflow, '
|
|
73
|
-
assert(hasAll(workflow, '
|
|
109
|
+
assert(hasAll(workflow, 'before the user explicitly approves the latest plan', 'no edits, no state mutation, no delegation'), 'default workflow must require latest-plan approval before work');
|
|
110
|
+
assert(hasAll(workflow, 'on approval, fan out at maximum width', 'one agent per independent scope', 'all spawned in one turn'), 'default workflow must fan out independent scopes at maximum width');
|
|
111
|
+
assert(hasAll(workflow, 'simple, well-understood implementation goes to worker', 'complex or investigative implementation goes to heavy worker', 'lead itself edits only a local, one-turn configuration/git change', 'debugger only on a defect needing deep root-cause analysis or a bug surviving 2+ review/fix cycles'), 'default workflow must enforce role routing and Lead/Debugger limits');
|
|
112
|
+
assert(hasAll(workflow, 'every implementation gets its own reviewer, attached per scope', 'only the local lead-direct edits above are exempt', 'lead itself edits only a local, one-turn configuration/git change', 'keep the same reviewer through the fix loop', 'fix -> re-verify until clean', 'lead cross-verifies'), 'default workflow must require a Reviewer for every implementation except local Lead-direct one-turn config/git edits');
|
|
113
|
+
assert(hasAll(workflow, 'build, deploy, commit, and push happen only on an explicit user request', 'on direction change, pause and re-consult the user'), 'default workflow must require user authorization and re-consultation');
|
|
74
114
|
assert(!skipsReview, 'default workflow must not permit delegated-review skips');
|
|
75
|
-
assert(hasAll(solo, '
|
|
115
|
+
assert(hasAll(solo, 'before the user explicitly approves the latest plan', 'read-only investigation and planning — no edits, no state mutation', 'a new or changed request resets planning; a scope change requires fresh approval'), 'Solo workflow must require latest-plan approval and reset it for request or scope changes');
|
|
116
|
+
assert(hasAll(solo, 'on approval, lead executes all work itself', 'never spawn, send, or delegate to agents', 'verify directly: check and fix until clean, or report the blocker'), 'Solo workflow must keep work with Lead, forbid delegation, and verify directly');
|
|
117
|
+
assert(hasAll(solo, 'build, deploy, commit, and push happen only on an explicit user request', 'on direction change, pause and re-consult the user'), 'Solo workflow must require user authorization and re-consultation');
|
|
76
118
|
assert(/always start background tasks/i.test(AGENT_TOOL.description || '') && /distinct tags?/i.test(AGENT_TOOL.description || '') && /completion notification/i.test(AGENT_TOOL.description || ''), 'agent tool description must expose async parallel tags');
|
|
77
119
|
|
|
78
120
|
mkdirSync(dataDir, { recursive: true });
|
|
@@ -112,7 +154,7 @@ async function main() {
|
|
|
112
154
|
maxActiveAsks = Math.max(maxActiveAsks, activeAsks);
|
|
113
155
|
try {
|
|
114
156
|
if (/parallel slow/i.test(prompt)) await sleep(600);
|
|
115
|
-
if (/long busy/i.test(prompt)) await
|
|
157
|
+
if (/long busy/i.test(prompt)) await waitForBusyRelease();
|
|
116
158
|
if (/write implementation/i.test(prompt)) {
|
|
117
159
|
const out = await executePatchTool('apply_patch', {
|
|
118
160
|
base_path: cwdOverride,
|
|
@@ -163,7 +205,7 @@ async function main() {
|
|
|
163
205
|
getSessionLastProgressAt,
|
|
164
206
|
askSession: fakeAskSession,
|
|
165
207
|
};
|
|
166
|
-
|
|
208
|
+
agentRunner = createStandaloneAgent({ cfgMod, reg, mgr, dataDir, cwd: root, defaultMode: 'async' });
|
|
167
209
|
|
|
168
210
|
async function waitJob(out, pattern, label) {
|
|
169
211
|
const id = taskId(out);
|
|
@@ -180,10 +222,11 @@ async function main() {
|
|
|
180
222
|
|
|
181
223
|
async function waitAgentTag(tag, label) {
|
|
182
224
|
for (let i = 0; i < 20; i += 1) {
|
|
183
|
-
if (
|
|
225
|
+
if (agentRunner.getStatus({ cwd: root }).workers
|
|
226
|
+
.some((worker) => worker?.tag === tag && worker.status === 'running')) return;
|
|
184
227
|
await sleep(25);
|
|
185
228
|
}
|
|
186
|
-
throw new Error(`${label} did not
|
|
229
|
+
throw new Error(`${label} did not start agent tag ${tag}`);
|
|
187
230
|
}
|
|
188
231
|
|
|
189
232
|
const spawnOut = await agentRunner.execute({
|
|
@@ -265,17 +308,26 @@ async function main() {
|
|
|
265
308
|
message: 'follow-up while still busy',
|
|
266
309
|
}, { invocationSource: 'model-tool', cwd: root });
|
|
267
310
|
assert(/agent message queued/.test(queued), `busy send should queue, got ${queued}`);
|
|
311
|
+
releaseBusyWorker();
|
|
268
312
|
await waitJob(busyOut, /ack worker/, 'busy worker');
|
|
269
313
|
|
|
270
314
|
const missing = await agentRunner.execute({ type: 'read', task_id: 'task_missing_live_smoke' }, { invocationSource: 'model-tool', cwd: root });
|
|
271
315
|
assert(/^Error[\s:[]/.test(missing), 'missing agent task should be Error result');
|
|
272
316
|
assert(readFileSync(join(root, 'feature.txt'), 'utf8').includes('beta from worker'), 'final file missing worker edit');
|
|
273
|
-
|
|
317
|
+
closeAgentRunner();
|
|
274
318
|
process.stdout.write('live worker smoke passed\n');
|
|
275
319
|
}
|
|
276
320
|
|
|
277
321
|
try {
|
|
278
322
|
await main();
|
|
279
323
|
} finally {
|
|
280
|
-
|
|
324
|
+
try {
|
|
325
|
+
releaseBusyWorker();
|
|
326
|
+
} finally {
|
|
327
|
+
try {
|
|
328
|
+
closeAgentRunner();
|
|
329
|
+
} finally {
|
|
330
|
+
rmSync(root, { recursive: true, force: true });
|
|
331
|
+
}
|
|
332
|
+
}
|
|
281
333
|
}
|