mixdog 0.9.75 → 0.9.76
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 +1 -1
- package/src/runtime/agent/orchestrator/session/manager/ask-session.mjs +11 -1
- package/src/runtime/agent/orchestrator/session/manager/turn-interruption.mjs +23 -1
- package/src/runtime/agent/orchestrator/tools/bash-session.mjs +3 -1
- package/src/runtime/agent/orchestrator/tools/builtin/bash-tool.mjs +2 -1
- package/src/runtime/agent/orchestrator/tools/builtin/shell-job-spawn.mjs +3 -3
- package/src/runtime/agent/orchestrator/tools/env-scrub.mjs +14 -0
- package/src/runtime/agent/orchestrator/tools/shell-snapshot.mjs +3 -1
package/package.json
CHANGED
|
@@ -848,7 +848,17 @@ export async function askSession(sessionId, prompt, context, onToolCall, cwdOver
|
|
|
848
848
|
activeSession.messages = finalized.messages;
|
|
849
849
|
if (!finalized.responsePreserved) {
|
|
850
850
|
releasePendingMessages(sessionId, _turnPendingEntries);
|
|
851
|
-
|
|
851
|
+
if (finalized.userTurnPreserved) {
|
|
852
|
+
// Non-user abort (app quit / engine dispose /
|
|
853
|
+
// watchdog): the just-sent user turn stays in
|
|
854
|
+
// history, so the session-start meta it carries
|
|
855
|
+
// remains consumed, and the opaque provider
|
|
856
|
+
// continuation no longer matches — force full
|
|
857
|
+
// transcript replay on the next send.
|
|
858
|
+
activeSession.providerState = undefined;
|
|
859
|
+
} else {
|
|
860
|
+
activeSession.sessionStartMetaInjected = _sessionStartMetaInjectedBeforeTurn;
|
|
861
|
+
}
|
|
852
862
|
} else {
|
|
853
863
|
recordPendingMessageDelivery(activeSession, _turnPendingEntries);
|
|
854
864
|
// The opaque provider continuation now points at a
|
|
@@ -10,6 +10,16 @@ const INTERRUPT_MESSAGE_FOR_TOOL_USE = '[Request interrupted by user for tool us
|
|
|
10
10
|
const STREAMING_INTERRUPTED_TOOL_RESULT = 'Interrupted by user';
|
|
11
11
|
const TOOL_USE_REJECT_RESULT = "The user doesn't want to proceed with this tool use. The tool use was rejected (eg. if it was a file edit, the new_string was NOT written to the file). STOP what you are doing and wait for the user to tell you how to proceed.";
|
|
12
12
|
|
|
13
|
+
// Abort reasons that represent an EXPLICIT user cancellation of this turn.
|
|
14
|
+
// Only these rewind a not-yet-answered user turn out of history — the TUI/
|
|
15
|
+
// desktop restore the prompt into the input box on user cancel, so keeping
|
|
16
|
+
// the message would duplicate it on resubmit. Any other closeReason (engine
|
|
17
|
+
// shutdown `cli-react-exit`, watchdog, idle-sweep, runner-crash, …) must
|
|
18
|
+
// PRESERVE the just-sent user turn: nothing restores the prompt there, and
|
|
19
|
+
// rewinding erases the user's message from the persisted transcript (the
|
|
20
|
+
// exact loss seen when the desktop app quits mid-turn).
|
|
21
|
+
const USER_CANCEL_ABORT_REASONS = new Set(['cli-abort', 'user-cancel', 'turn-abort']);
|
|
22
|
+
|
|
13
23
|
function assistantToolCallIds(message) {
|
|
14
24
|
if (!message || message.role !== 'assistant') return [];
|
|
15
25
|
const ids = [];
|
|
@@ -60,9 +70,21 @@ function finalizeInterruptedTurn({
|
|
|
60
70
|
const preserveResponse = responseStarted
|
|
61
71
|
&& !isInternalRuntimeNotificationText(currentUserContent);
|
|
62
72
|
if (!preserveResponse) {
|
|
73
|
+
// Null/unknown reasons keep the legacy rewind (status quo for wrapped
|
|
74
|
+
// aborts without a closeReason enum); named non-user reasons preserve.
|
|
75
|
+
const userCancelled = abortReason == null
|
|
76
|
+
|| USER_CANCEL_ABORT_REASONS.has(abortReason);
|
|
77
|
+
if (!userCancelled) {
|
|
78
|
+
return {
|
|
79
|
+
messages,
|
|
80
|
+
responsePreserved: false,
|
|
81
|
+
userTurnPreserved: true,
|
|
82
|
+
};
|
|
83
|
+
}
|
|
63
84
|
return {
|
|
64
85
|
messages: rewindProvisionalUserTurn(messages, currentUserContent),
|
|
65
86
|
responsePreserved: false,
|
|
87
|
+
userTurnPreserved: false,
|
|
66
88
|
};
|
|
67
89
|
}
|
|
68
90
|
|
|
@@ -132,7 +154,7 @@ function finalizeInterruptedTurn({
|
|
|
132
154
|
: INTERRUPT_MESSAGE,
|
|
133
155
|
});
|
|
134
156
|
}
|
|
135
|
-
return { messages: pairedMessages, responsePreserved: true };
|
|
157
|
+
return { messages: pairedMessages, responsePreserved: true, userTurnPreserved: true };
|
|
136
158
|
}
|
|
137
159
|
|
|
138
160
|
export function createTurnInterruptionTracker() {
|
|
@@ -45,7 +45,7 @@ import { markCodeGraphDirtyPaths, drainCodeGraphCache } from './code-graph-state
|
|
|
45
45
|
import { maybeRewriteWmicProcessCommand } from './shell-policy.mjs';
|
|
46
46
|
import { _maybeEncodePowerShellCommand } from './shell-command.mjs';
|
|
47
47
|
import { _captureTrackedMtimes, _trackedDriftNoteAfter, getDedupedDestructiveWarnings } from './builtin/bash-tool.mjs';
|
|
48
|
-
import { scrubLoaderVars, scrubProviderSecrets } from './env-scrub.mjs';
|
|
48
|
+
import { scrubLoaderVars, scrubProviderSecrets, scrubRuntimeRootVars } from './env-scrub.mjs';
|
|
49
49
|
import { checkExecPolicyMessage } from './bash-policy-scan.mjs';
|
|
50
50
|
import { startChildGuardian } from '../../../shared/child-guardian.mjs';
|
|
51
51
|
import { resourceAdmission } from '../../../shared/resource-admission.mjs';
|
|
@@ -342,6 +342,8 @@ function buildBashEnv() {
|
|
|
342
342
|
scrubProviderSecrets(env);
|
|
343
343
|
// R11 loader/execution scrub (NODE_OPTIONS, LD_PRELOAD, DYLD_*, …).
|
|
344
344
|
scrubLoaderVars(env);
|
|
345
|
+
// Runtime-root isolation — see env-scrub.mjs scrubRuntimeRootVars.
|
|
346
|
+
scrubRuntimeRootVars(env);
|
|
345
347
|
return env;
|
|
346
348
|
}
|
|
347
349
|
|
|
@@ -44,7 +44,7 @@ import { normalizeOutputPath } from './path-utils.mjs';
|
|
|
44
44
|
import { normalizeErrorMessage } from './path-diagnostics.mjs';
|
|
45
45
|
import { invalidateBuiltinResultCache } from './cache-layers.mjs';
|
|
46
46
|
import { resolveOptionalCwd } from './cwd-utils.mjs';
|
|
47
|
-
import { scrubLoaderVars, scrubProviderSecrets } from '../env-scrub.mjs';
|
|
47
|
+
import { scrubLoaderVars, scrubProviderSecrets, scrubRuntimeRootVars } from '../env-scrub.mjs';
|
|
48
48
|
import { resolveSessionCwd, stateFilePath, wrapPowerShellWithCwdProbe, wrapBashWithCwdProbe } from '../shell-state.mjs';
|
|
49
49
|
import { resourceAdmission } from '../../../../shared/resource-admission.mjs';
|
|
50
50
|
|
|
@@ -407,6 +407,7 @@ export async function executeBashTool(args, workDir, options = {}) {
|
|
|
407
407
|
// R5/R11: same scrub as background/persistent spawn sites (env-scrub.mjs).
|
|
408
408
|
scrubProviderSecrets(spawnEnv);
|
|
409
409
|
scrubLoaderVars(spawnEnv);
|
|
410
|
+
scrubRuntimeRootVars(spawnEnv);
|
|
410
411
|
let wrappedCommand;
|
|
411
412
|
// PowerShell UTF-8 prefix is PS-only: the Windows Git Bash path
|
|
412
413
|
// (shellType==='posix') must NOT receive it. Snapshot wrapper stays
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { spawn } from 'child_process';
|
|
3
3
|
import { existsSync, readFileSync, statSync, unlinkSync, watch as fsWatch, writeFileSync } from 'fs';
|
|
4
4
|
import { basename } from 'path';
|
|
5
|
-
import { scrubLoaderVars, scrubProviderSecrets } from '../env-scrub.mjs';
|
|
5
|
+
import { scrubLoaderVars, scrubProviderSecrets, scrubRuntimeRootVars } from '../env-scrub.mjs';
|
|
6
6
|
import {
|
|
7
7
|
normalizeToolNotifyContext,
|
|
8
8
|
notifyToolCompletion,
|
|
@@ -169,7 +169,7 @@ export async function _startBackgroundShellJobImpl({
|
|
|
169
169
|
try {
|
|
170
170
|
child = spawnFn(shell, [wrappedTempPath], {
|
|
171
171
|
cwd: workDir,
|
|
172
|
-
env: scrubLoaderVars(scrubProviderSecrets({ ...spawnEnv })),
|
|
172
|
+
env: scrubRuntimeRootVars(scrubLoaderVars(scrubProviderSecrets({ ...spawnEnv }))),
|
|
173
173
|
stdio: 'ignore',
|
|
174
174
|
...detachedSpawnOpts,
|
|
175
175
|
});
|
|
@@ -398,7 +398,7 @@ async function startBackgroundPowerShellJob({
|
|
|
398
398
|
try {
|
|
399
399
|
child = spawnFn(shell, wrapperArgs, {
|
|
400
400
|
cwd: workDir,
|
|
401
|
-
env: scrubLoaderVars(scrubProviderSecrets({ ...spawnEnv })),
|
|
401
|
+
env: scrubRuntimeRootVars(scrubLoaderVars(scrubProviderSecrets({ ...spawnEnv }))),
|
|
402
402
|
detached: false,
|
|
403
403
|
stdio: 'ignore',
|
|
404
404
|
windowsHide: true,
|
|
@@ -98,3 +98,17 @@ export function scrubProviderSecrets(env) {
|
|
|
98
98
|
}
|
|
99
99
|
return env;
|
|
100
100
|
}
|
|
101
|
+
|
|
102
|
+
// Runtime-root isolation: MIXDOG_ROOT is a runtime-internal alias for THIS
|
|
103
|
+
// process's install/resource root (a packaged desktop host points it at
|
|
104
|
+
// resources/runtime.asar/...). Model-spawned shells must never inherit it —
|
|
105
|
+
// a dev-tree test run inside such a shell would resolve defaults/agents.json
|
|
106
|
+
// and friends from the INSTALLED app instead of the repo under test (plain
|
|
107
|
+
// node can't even read asar paths → ENOENT). Internal worker spawns that need
|
|
108
|
+
// the root re-set it explicitly and are unaffected: only shell spawn sites
|
|
109
|
+
// call this.
|
|
110
|
+
export function scrubRuntimeRootVars(env) {
|
|
111
|
+
if (!env || typeof env !== 'object') return env;
|
|
112
|
+
delete env.MIXDOG_ROOT;
|
|
113
|
+
return env;
|
|
114
|
+
}
|
|
@@ -18,7 +18,7 @@ import { join } from 'node:path';
|
|
|
18
18
|
import { homedir } from 'node:os';
|
|
19
19
|
import { randomUUID } from 'node:crypto';
|
|
20
20
|
import { getPluginData } from '../config.mjs';
|
|
21
|
-
import { scrubLoaderVars, scrubProviderSecrets } from './env-scrub.mjs';
|
|
21
|
+
import { scrubLoaderVars, scrubProviderSecrets, scrubRuntimeRootVars } from './env-scrub.mjs';
|
|
22
22
|
|
|
23
23
|
const SNAPSHOT_TIMEOUT_MS = 10_000;
|
|
24
24
|
|
|
@@ -191,6 +191,8 @@ function _runSnapshot(shellPath, snapshotPath, configFileExists) {
|
|
|
191
191
|
// provider/cloud tokens before exposing the env to that script.
|
|
192
192
|
// Shared with bash-session and shell-jobs via env-scrub.mjs.
|
|
193
193
|
scrubProviderSecrets(e);
|
|
194
|
+
// Runtime-root isolation — see env-scrub.mjs scrubRuntimeRootVars.
|
|
195
|
+
scrubRuntimeRootVars(e);
|
|
194
196
|
return e;
|
|
195
197
|
})(),
|
|
196
198
|
windowsHide: true,
|