arco-workbench 0.1.8 → 0.1.9
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/CONTRIBUTING.md +11 -0
- package/README.md +7 -5
- package/client/dist/assets/{PhosphorBackdrop-D7jdAV_G.js → PhosphorBackdrop-DRu16-Is.js} +1 -1
- package/client/dist/assets/{ThemedBackgroundShaderImpl-DrDm60h8.js → ThemedBackgroundShaderImpl-BLdwwQ4D.js} +1 -1
- package/client/dist/assets/{XtermView-BGFujb1e.js → XtermView-Xk7_9JaH.js} +1 -1
- package/client/dist/assets/{galleryEditor-D951A2sE.js → galleryEditor-CI8ClzBa.js} +1 -1
- package/client/dist/assets/{index-DD9kFGsF.css → index-BEFgrUJJ.css} +1 -1
- package/client/dist/assets/{index-CsVy3eZm.js → index-C7WzZfsr.js} +246 -244
- package/client/dist/index.html +2 -2
- package/client/src/App.tsx +2 -0
- package/client/src/components/ChatMessage.tsx +33 -8
- package/client/src/components/ChatModeView.tsx +2 -0
- package/client/src/components/ClusterRightPanel/SkillsControl.tsx +25 -8
- package/client/src/components/CodexLateCommand.tsx +34 -0
- package/client/src/components/DialogShell.tsx +2 -0
- package/client/src/components/MemberCard.tsx +4 -1
- package/client/src/components/MemberPane.tsx +3 -1
- package/client/src/components/PhoneUpload.tsx +288 -0
- package/client/src/components/PrimaryStatus.tsx +14 -6
- package/client/src/components/RuntimeStateBanner.tsx +5 -0
- package/client/src/components/SkillEditorDialog.tsx +2 -2
- package/client/src/components/SkillsSettings.tsx +17 -5
- package/client/src/components/TerminalInput.tsx +3 -1
- package/client/src/components/WorkflowView.tsx +2 -0
- package/client/src/explorer/ArtifactsLens.tsx +37 -28
- package/client/src/explorer/ExplorerApp.tsx +5 -4
- package/client/src/explorer/types.ts +8 -3
- package/client/src/help/content/cluster.tsx +11 -1
- package/client/src/help/content/composer.tsx +18 -1
- package/client/src/help/content/header.tsx +2 -1
- package/client/src/help/content/misc.tsx +1 -1
- package/client/src/help/content/settings.tsx +1 -1
- package/client/src/help/manualSections/clusters.tsx +3 -0
- package/client/src/help/manualSections/configuration.tsx +3 -1
- package/client/src/help/manualSections/gettingStarted.tsx +4 -4
- package/client/src/help/manualSections/maintenance.tsx +7 -6
- package/client/src/help/manualSections/powerFeatures.tsx +3 -2
- package/client/src/help/manualSections/workspace.tsx +30 -0
- package/client/src/stores/appStore.ts +7 -0
- package/client/src/stores/appStore.types.ts +4 -0
- package/client/src/styles/global.css +109 -0
- package/client/src/utils/phoneTheme.ts +38 -0
- package/client/src/utils/phoneUploadApi.ts +10 -0
- package/client/src/ws/handleServerMessage.ts +23 -6
- package/docs/CLIENT.md +7 -1
- package/docs/FEATURES.md +6 -3
- package/docs/GETTING_STARTED.md +8 -3
- package/docs/INDEX.md +1 -1
- package/docs/OPERATIONS.md +199 -48
- package/docs/PROTOCOL_CLUSTER.md +9 -1
- package/docs/PROVIDERS.md +34 -0
- package/docs/SETTINGS.md +5 -3
- package/native/darwin-arm64/manifest.json +1 -1
- package/native/linux-x64/manifest.json +1 -1
- package/native/win32-x64/manifest.json +1 -1
- package/node_modules/@arco/shared/dist/protocol/chat.d.ts +1 -0
- package/node_modules/@arco/shared/dist/protocol/clusters.d.ts +2 -0
- package/node_modules/@arco/shared/dist/protocol/serverMessages.d.ts +11 -0
- package/node_modules/@arco/shared/dist/protocol/workflows.d.ts +1 -0
- package/node_modules/@arco/shared/package.json +1 -1
- package/package.json +2 -2
- package/server/dist/clusterDirector.js +1 -0
- package/server/dist/clusterPeerOps.js +4 -1
- package/server/dist/clusterRehydrate.js +2 -0
- package/server/dist/explorerDocs.d.ts +10 -6
- package/server/dist/explorerDocs.js +75 -34
- package/server/dist/http/attachmentUpload.d.ts +13 -0
- package/server/dist/http/attachmentUpload.js +38 -0
- package/server/dist/http/browserWorktrees.d.ts +23 -0
- package/server/dist/http/browserWorktrees.js +120 -0
- package/server/dist/http/phoneUploadDrafts.d.ts +13 -0
- package/server/dist/http/phoneUploadDrafts.js +125 -0
- package/server/dist/http/phoneUploadListener.d.ts +17 -0
- package/server/dist/http/phoneUploadListener.js +81 -0
- package/server/dist/http/phoneUploadNetwork.d.ts +9 -0
- package/server/dist/http/phoneUploadNetwork.js +106 -0
- package/server/dist/http/phoneUploadPage.d.ts +2 -0
- package/server/dist/http/phoneUploadPage.js +136 -0
- package/server/dist/http/phoneUploadRouteHistory.d.ts +4 -0
- package/server/dist/http/phoneUploadRouteHistory.js +72 -0
- package/server/dist/http/phoneUploadRoutes.d.ts +4 -0
- package/server/dist/http/phoneUploadRoutes.js +419 -0
- package/server/dist/http/phoneUploadTheme.d.ts +17 -0
- package/server/dist/http/phoneUploadTheme.js +96 -0
- package/server/dist/http/projectBinding.d.ts +1 -0
- package/server/dist/http/projectBinding.js +3 -2
- package/server/dist/http/readConfinement.js +5 -1
- package/server/dist/http/router.js +13 -24
- package/server/dist/http/writeConfinement.js +19 -2
- package/server/dist/primitives/seedWorker.d.ts +1 -0
- package/server/dist/primitives/seedWorker.js +2 -1
- package/server/dist/providers/codex-appserver/heldCommands.d.ts +14 -0
- package/server/dist/providers/codex-appserver/heldCommands.js +54 -0
- package/server/dist/providers/codex-appserver/index.d.ts +52 -2
- package/server/dist/providers/codex-appserver/index.js +239 -21
- package/server/dist/providers/codex-appserver/lateCommands.d.ts +62 -0
- package/server/dist/providers/codex-appserver/lateCommands.js +195 -0
- package/server/dist/providers/codex-appserver/worker.d.ts +23 -1
- package/server/dist/providers/codex-appserver/worker.js +89 -20
- package/server/dist/providers/codex.js +2 -2
- package/server/dist/providers/codexCodeMode.d.ts +2 -1
- package/server/dist/providers/codexCodeMode.js +7 -3
- package/server/dist/workers/WorkerManager.d.ts +1 -0
- package/server/dist/workers/WorkerManager.js +1 -0
- package/server/dist/workers/processKill.d.ts +9 -1
- package/server/dist/workers/processKill.js +26 -10
- package/server/dist/ws/handoffHandlers.js +2 -0
- package/server/dist/ws/turnEngine.js +17 -0
- package/server/package.json +1 -1
- package/server/src/clusterDirector.ts +1 -0
- package/server/src/clusterPeerOps.ts +4 -1
- package/server/src/clusterRehydrate.ts +2 -0
- package/server/src/explorerDocs.ts +75 -34
- package/server/src/http/attachmentUpload.ts +49 -0
- package/server/src/http/browserWorktrees.ts +124 -0
- package/server/src/http/phoneUploadDrafts.ts +118 -0
- package/server/src/http/phoneUploadListener.ts +96 -0
- package/server/src/http/phoneUploadNetwork.ts +117 -0
- package/server/src/http/phoneUploadPage.ts +137 -0
- package/server/src/http/phoneUploadRouteHistory.ts +73 -0
- package/server/src/http/phoneUploadRoutes.ts +398 -0
- package/server/src/http/phoneUploadTheme.ts +97 -0
- package/server/src/http/projectBinding.ts +3 -2
- package/server/src/http/readConfinement.ts +5 -1
- package/server/src/http/router.ts +11 -25
- package/server/src/http/writeConfinement.ts +13 -2
- package/server/src/primitives/seedWorker.ts +3 -1
- package/server/src/providers/codex-appserver/heldCommands.ts +58 -0
- package/server/src/providers/codex-appserver/index.ts +222 -20
- package/server/src/providers/codex-appserver/lateCommands.ts +225 -0
- package/server/src/providers/codex-appserver/worker.ts +85 -21
- package/server/src/providers/codex.ts +2 -2
- package/server/src/providers/codexCodeMode.ts +8 -3
- package/server/src/workers/WorkerManager.ts +2 -0
- package/server/src/workers/processKill.ts +35 -7
- package/server/src/ws/handoffHandlers.ts +2 -0
- package/server/src/ws/turnEngine.ts +15 -0
- package/shared/dist/protocol/chat.d.ts +1 -0
- package/shared/dist/protocol/clusters.d.ts +2 -0
- package/shared/dist/protocol/serverMessages.d.ts +11 -0
- package/shared/dist/protocol/workflows.d.ts +1 -0
- package/shared/src/protocol/chat.ts +1 -0
- package/shared/src/protocol/clusters.ts +4 -5
- package/shared/src/protocol/serverMessages.ts +11 -0
- package/shared/src/protocol/workflows.ts +4 -0
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
const DISPLAY_MS = 5 * 60_000;
|
|
2
|
+
const MAX_COMMANDS = 64;
|
|
3
|
+
// A program meant to keep running (a server or a watcher) must never hold a
|
|
4
|
+
// turn open. Programs the shell put in the background (`&`, `nohup`) end the
|
|
5
|
+
// shell at once, so Codex completes their item inside the turn; only a known
|
|
6
|
+
// long-running program started in the foreground needs this pattern. Kept
|
|
7
|
+
// narrower than the preview detector's pattern: `vite build` or `deno run
|
|
8
|
+
// script.ts` end on their own and must still be waited on.
|
|
9
|
+
const LONG_RUNNING_RE = new RegExp([
|
|
10
|
+
String.raw `\b(?:npm|pnpm|yarn|bun)\s+(?:run\s+)?(?:dev|start|serve|watch)\b`,
|
|
11
|
+
String.raw `\b(?:vite|next|astro|nuxt|remix|gatsby|docusaurus)\s+(?:dev|develop|start|serve|preview)\b`,
|
|
12
|
+
String.raw `\bvite\s*(?:$|['"]|--(?:host|port)\b)`,
|
|
13
|
+
String.raw `\bpython3?\s+-m\s+http\.server\b`,
|
|
14
|
+
String.raw `\buvicorn\b`, String.raw `\bflask\s+run\b`, String.raw `\brails\s+s(?:erver)?\b`, String.raw `\bphp\s+-S\b`,
|
|
15
|
+
String.raw `(?:^|\s)--watch\b`, String.raw `\bwatch\s+-n\b`, String.raw `\btail\s+(?:-\w+\s+)*-\w*[fF]\b`,
|
|
16
|
+
String.raw `\bsleep\s+infinity\b`,
|
|
17
|
+
String.raw `\bdocker[\s-]compose\s+(?:\S+\s+)*up\b(?![^|;&]*\s(?:-d|--detach)\b)`,
|
|
18
|
+
].join('|'));
|
|
19
|
+
export function isLongRunningProgram(command) {
|
|
20
|
+
return LONG_RUNNING_RE.test(command);
|
|
21
|
+
}
|
|
22
|
+
export function commandText(event) {
|
|
23
|
+
try {
|
|
24
|
+
const parsed = JSON.parse(event.input);
|
|
25
|
+
return {
|
|
26
|
+
command: typeof parsed.command === 'string' ? parsed.command : 'a shell command',
|
|
27
|
+
...(typeof parsed.cwd === 'string' ? { cwd: parsed.cwd } : {}),
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
catch {
|
|
31
|
+
return { command: 'a shell command' };
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
export class CodexLateCommands {
|
|
35
|
+
publish;
|
|
36
|
+
onHeldChange;
|
|
37
|
+
commands = new Map();
|
|
38
|
+
// Ended held commands whose result has not yet been delivered to the agent.
|
|
39
|
+
results = [];
|
|
40
|
+
constructor(publish, onHeldChange = () => { }) {
|
|
41
|
+
this.publish = publish;
|
|
42
|
+
this.onHeldChange = onHeldChange;
|
|
43
|
+
}
|
|
44
|
+
start(turnId, event) {
|
|
45
|
+
if (!event.itemId || this.commands.has(event.itemId))
|
|
46
|
+
return;
|
|
47
|
+
if (this.commands.size >= MAX_COMMANDS) {
|
|
48
|
+
const oldest = this.commands.keys().next().value;
|
|
49
|
+
if (oldest) {
|
|
50
|
+
const previous = this.commands.get(oldest);
|
|
51
|
+
if (previous.waitingUntil)
|
|
52
|
+
this.notify(previous, 'untracked');
|
|
53
|
+
clearTimeout(previous.timer);
|
|
54
|
+
this.commands.delete(oldest);
|
|
55
|
+
if (previous.held)
|
|
56
|
+
this.onHeldChange();
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
this.commands.set(event.itemId, { turnId, event, startedAt: Date.now() });
|
|
60
|
+
}
|
|
61
|
+
/** True once the long-lived publisher owns this completion. */
|
|
62
|
+
complete(turnId, event) {
|
|
63
|
+
const id = event.itemId;
|
|
64
|
+
const command = id ? this.commands.get(id) : undefined;
|
|
65
|
+
if (!id || !command || command.turnId !== turnId)
|
|
66
|
+
return false;
|
|
67
|
+
this.commands.delete(id);
|
|
68
|
+
clearTimeout(command.timer);
|
|
69
|
+
if (!command.waitingUntil)
|
|
70
|
+
return false;
|
|
71
|
+
this.notify(command, 'finished', event);
|
|
72
|
+
if (command.held) {
|
|
73
|
+
this.results.push(this.result(command, event));
|
|
74
|
+
this.onHeldChange();
|
|
75
|
+
}
|
|
76
|
+
return true;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* A command that ended inside its own turn after the agent's final answer
|
|
80
|
+
* had started: the model never saw the result, so it is kept for delivery
|
|
81
|
+
* once that turn has completed. The completion is still shown in the turn.
|
|
82
|
+
* False when the command is unknown, belongs to another turn or has
|
|
83
|
+
* already outlived its turn.
|
|
84
|
+
*/
|
|
85
|
+
completeUnseen(turnId, event) {
|
|
86
|
+
const id = event.itemId;
|
|
87
|
+
const command = id ? this.commands.get(id) : undefined;
|
|
88
|
+
if (!id || !command || command.turnId !== turnId || command.waitingUntil)
|
|
89
|
+
return false;
|
|
90
|
+
this.commands.delete(id);
|
|
91
|
+
clearTimeout(command.timer);
|
|
92
|
+
if (!isLongRunningProgram(commandText(command.event).command)) {
|
|
93
|
+
this.results.push(this.result(command, event));
|
|
94
|
+
this.onHeldChange();
|
|
95
|
+
}
|
|
96
|
+
return true;
|
|
97
|
+
}
|
|
98
|
+
settle(turnId) {
|
|
99
|
+
let held = false;
|
|
100
|
+
for (const command of this.commands.values()) {
|
|
101
|
+
if (command.turnId !== turnId || command.waitingUntil)
|
|
102
|
+
continue;
|
|
103
|
+
command.waitingUntil = Date.now() + DISPLAY_MS;
|
|
104
|
+
command.held = !isLongRunningProgram(commandText(command.event).command);
|
|
105
|
+
held ||= command.held;
|
|
106
|
+
this.notify(command, 'running');
|
|
107
|
+
command.timer = setTimeout(() => this.notify(command, 'untracked'), DISPLAY_MS);
|
|
108
|
+
command.timer.unref();
|
|
109
|
+
}
|
|
110
|
+
if (held)
|
|
111
|
+
this.onHeldChange();
|
|
112
|
+
}
|
|
113
|
+
/** Commands the agent still waits on, oldest first. */
|
|
114
|
+
running() {
|
|
115
|
+
return [...this.commands.values()].flatMap(command => command.held && command.event.itemId
|
|
116
|
+
? [{ itemId: command.event.itemId, command: commandText(command.event).command, startedAt: command.startedAt }] : []);
|
|
117
|
+
}
|
|
118
|
+
hasResults() { return this.results.length > 0; }
|
|
119
|
+
hasFailedResult() { return this.results.some(result => result.failed); }
|
|
120
|
+
/** Ended results; each is handed out exactly once. */
|
|
121
|
+
takeResults() { return this.results.splice(0); }
|
|
122
|
+
/** Put back results whose delivery failed, ahead of any newer ones. */
|
|
123
|
+
restoreResults(results) {
|
|
124
|
+
if (results.length)
|
|
125
|
+
this.results.unshift(...results);
|
|
126
|
+
}
|
|
127
|
+
/** The Arco turn now waits on the held commands, at most until `until`. */
|
|
128
|
+
hold(until) {
|
|
129
|
+
for (const command of this.commands.values()) {
|
|
130
|
+
if (!command.held || !command.waitingUntil)
|
|
131
|
+
continue;
|
|
132
|
+
command.waiting = true;
|
|
133
|
+
if (command.waitingUntil < until) {
|
|
134
|
+
command.waitingUntil = until;
|
|
135
|
+
clearTimeout(command.timer);
|
|
136
|
+
command.timer = setTimeout(() => this.notify(command, 'untracked'), Math.max(0, until - Date.now()));
|
|
137
|
+
command.timer.unref();
|
|
138
|
+
}
|
|
139
|
+
this.notify(command, 'running');
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
/** The turn no longer waits (it continued, ended or was stopped). */
|
|
143
|
+
release() {
|
|
144
|
+
for (const command of this.commands.values()) {
|
|
145
|
+
if (!command.waiting)
|
|
146
|
+
continue;
|
|
147
|
+
command.waiting = false;
|
|
148
|
+
this.notify(command, 'running');
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Nobody waits on these commands any more (STOP, the wait limit, a failed
|
|
153
|
+
* turn). They keep running and their rows still record how they end, but
|
|
154
|
+
* no result reaches the agent.
|
|
155
|
+
*/
|
|
156
|
+
abandon() {
|
|
157
|
+
this.release();
|
|
158
|
+
this.results.length = 0;
|
|
159
|
+
for (const command of this.commands.values())
|
|
160
|
+
command.held = false;
|
|
161
|
+
}
|
|
162
|
+
snapshot() {
|
|
163
|
+
const now = Date.now();
|
|
164
|
+
return [...this.commands.values()].flatMap(({ event, startedAt, waitingUntil, waiting }) => event.itemId && waitingUntil && waitingUntil > now
|
|
165
|
+
? [{ itemId: event.itemId, input: event.input, startedAt, waitingUntil, ...(waiting ? { waiting } : {}) }] : []);
|
|
166
|
+
}
|
|
167
|
+
disconnect() {
|
|
168
|
+
const held = this.results.length > 0 || [...this.commands.values()].some(command => command.held);
|
|
169
|
+
for (const command of this.commands.values()) {
|
|
170
|
+
clearTimeout(command.timer);
|
|
171
|
+
this.notify(command, 'lost');
|
|
172
|
+
}
|
|
173
|
+
this.commands.clear();
|
|
174
|
+
this.results.length = 0;
|
|
175
|
+
if (held)
|
|
176
|
+
this.onHeldChange();
|
|
177
|
+
}
|
|
178
|
+
result(command, event) {
|
|
179
|
+
const { command: text, cwd } = commandText(command.event);
|
|
180
|
+
return {
|
|
181
|
+
itemId: command.event.itemId, command: text, ...(cwd ? { cwd } : {}),
|
|
182
|
+
startedAt: command.startedAt, endedAt: Date.now(),
|
|
183
|
+
...(typeof event.exitCode === 'number' ? { exitCode: event.exitCode } : {}),
|
|
184
|
+
...(typeof event.output === 'string' ? { output: event.output } : {}),
|
|
185
|
+
failed: event.status === 'failed' || (typeof event.exitCode === 'number' && event.exitCode !== 0),
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
notify(command, state, result) {
|
|
189
|
+
this.publish(result ?? command.event, {
|
|
190
|
+
state, startedAt: command.startedAt, waitingUntil: command.waitingUntil ?? Date.now(),
|
|
191
|
+
...(command.waiting && state === 'running' ? { waiting: true } : {}),
|
|
192
|
+
});
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
//# sourceMappingURL=lateCommands.js.map
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type HeldCommandResult } from './lateCommands.js';
|
|
1
2
|
import { EventEmitter } from 'events';
|
|
2
3
|
import { type ProviderName, type WorkerConfig } from '@arco/shared';
|
|
3
4
|
import type { ThreadStartParams } from './bindings/v2/ThreadStartParams.js';
|
|
@@ -81,7 +82,9 @@ export declare class CodexAppServerWorker extends EventEmitter {
|
|
|
81
82
|
updateConfig(next: WorkerConfig): void;
|
|
82
83
|
ensureStarted(): Promise<void>;
|
|
83
84
|
private clearThreadGoal;
|
|
84
|
-
beginTurn(prompt: string, appendSystemPrompt: string | undefined
|
|
85
|
+
beginTurn(prompt: string, appendSystemPrompt: string | undefined, options?: {
|
|
86
|
+
continuation?: boolean;
|
|
87
|
+
}): Promise<void>;
|
|
85
88
|
private cancellation;
|
|
86
89
|
cancelCurrentTurn(): Promise<void>;
|
|
87
90
|
private interruptCurrentTurn;
|
|
@@ -96,6 +99,25 @@ export declare class CodexAppServerWorker extends EventEmitter {
|
|
|
96
99
|
private requeueSteer;
|
|
97
100
|
dispose(): Promise<void>;
|
|
98
101
|
private buildSandboxPolicy;
|
|
102
|
+
private readonly lateCommands;
|
|
103
|
+
get runningLateCommands(): import("@arco/shared").CodexLateCommand[];
|
|
104
|
+
get heldCommands(): {
|
|
105
|
+
itemId: string;
|
|
106
|
+
command: string;
|
|
107
|
+
startedAt: number;
|
|
108
|
+
}[];
|
|
109
|
+
hasHeldResults(): boolean;
|
|
110
|
+
hasFailedHeldResult(): boolean;
|
|
111
|
+
takeHeldResults(): HeldCommandResult[];
|
|
112
|
+
restoreHeldResults(results: HeldCommandResult[]): void;
|
|
113
|
+
showHeldUntil(until: number): void;
|
|
114
|
+
releaseHeldWait(): void;
|
|
115
|
+
get acceptsResultSteer(): boolean;
|
|
116
|
+
abandonHeldCommands(): void;
|
|
117
|
+
/** Add Arco's text to the running turn. False when no turn takes it. */
|
|
118
|
+
steerText(text: string): Promise<boolean>;
|
|
119
|
+
private commandToolUse;
|
|
120
|
+
private handleCommandItem;
|
|
99
121
|
private onNotification;
|
|
100
122
|
private countedCompactionTurns;
|
|
101
123
|
private countCompaction;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { CodexLateCommands } from './lateCommands.js';
|
|
1
2
|
import { historyBinding } from '../handoffHistoryBinding.js';
|
|
2
3
|
import { codexWebSearchMode } from '../codexWebSearch.js';
|
|
3
4
|
import { codexImageToolConfig } from '../codexImageTool.js';
|
|
@@ -208,6 +209,7 @@ function emptyTurnState() {
|
|
|
208
209
|
transientNoticeKey: null,
|
|
209
210
|
transientNoticeCount: 0,
|
|
210
211
|
lastAgentMsgItemId: null,
|
|
212
|
+
finalAnswerStarted: false,
|
|
211
213
|
artifacts: new Set(),
|
|
212
214
|
settling: false,
|
|
213
215
|
};
|
|
@@ -513,7 +515,7 @@ export class CodexAppServerWorker extends EventEmitter {
|
|
|
513
515
|
// element. Empty prompt + image-only payload is a valid request shape now
|
|
514
516
|
// that images are first-class — no more "Please inspect the attached
|
|
515
517
|
// image(s)." synthetic fallback.
|
|
516
|
-
async beginTurn(prompt, appendSystemPrompt) {
|
|
518
|
+
async beginTurn(prompt, appendSystemPrompt, options = {}) {
|
|
517
519
|
if (this.disposed)
|
|
518
520
|
throw new Error('codex app-server worker disposed');
|
|
519
521
|
if (!this.rpc || !this.threadId) {
|
|
@@ -526,7 +528,8 @@ export class CodexAppServerWorker extends EventEmitter {
|
|
|
526
528
|
throw new Error('codex app-server worker has a compaction in flight');
|
|
527
529
|
}
|
|
528
530
|
const preparationGeneration = this.preparationGeneration;
|
|
529
|
-
|
|
531
|
+
// A continuation carries command results, never the operator's files again.
|
|
532
|
+
const prepared = await prepareProviderAttachments(options.continuation ? undefined : this.config.attachments, true, undefined, false, this.config.interactionMode === 'chat' && !this.config.voiceOperator);
|
|
530
533
|
if (preparationGeneration !== this.preparationGeneration)
|
|
531
534
|
throw new Error('Worker killed');
|
|
532
535
|
const modelImages = await persistProviderImages(prepared.images);
|
|
@@ -903,6 +906,71 @@ export class CodexAppServerWorker extends EventEmitter {
|
|
|
903
906
|
};
|
|
904
907
|
}
|
|
905
908
|
// ── Notification handling ────────────────────────────────────────────
|
|
909
|
+
lateCommands = new CodexLateCommands((event, state) => {
|
|
910
|
+
this.emit('late_command', event, state);
|
|
911
|
+
}, () => this.emit('held_commands'));
|
|
912
|
+
get runningLateCommands() { return this.lateCommands.snapshot(); }
|
|
913
|
+
// Commands the agent waits on after its Codex turn ended. The per-turn
|
|
914
|
+
// wrapper holds the Arco turn open for them and delivers each result once.
|
|
915
|
+
get heldCommands() { return this.lateCommands.running(); }
|
|
916
|
+
hasHeldResults() { return this.lateCommands.hasResults(); }
|
|
917
|
+
hasFailedHeldResult() { return this.lateCommands.hasFailedResult(); }
|
|
918
|
+
takeHeldResults() { return this.lateCommands.takeResults(); }
|
|
919
|
+
restoreHeldResults(results) { this.lateCommands.restoreResults(results); }
|
|
920
|
+
showHeldUntil(until) { this.lateCommands.hold(until); }
|
|
921
|
+
releaseHeldWait() { this.lateCommands.release(); }
|
|
922
|
+
// Arco's text may join the running turn only before its final answer starts.
|
|
923
|
+
get acceptsResultSteer() { return !!this.current.turnId && !this.current.finalAnswerStarted; }
|
|
924
|
+
abandonHeldCommands() { this.lateCommands.abandon(); }
|
|
925
|
+
/** Add Arco's text to the running turn. False when no turn takes it. */
|
|
926
|
+
async steerText(text) {
|
|
927
|
+
const turn = this.current;
|
|
928
|
+
if (!this.rpc || !this.threadId || !turn.turnId)
|
|
929
|
+
return false;
|
|
930
|
+
try {
|
|
931
|
+
await this.rpc.request('turn/steer', {
|
|
932
|
+
threadId: this.threadId, input: buildSteerInput([{ content: text }]),
|
|
933
|
+
responsesapiClientMetadata: null, expectedTurnId: turn.turnId,
|
|
934
|
+
});
|
|
935
|
+
return true;
|
|
936
|
+
}
|
|
937
|
+
catch (err) {
|
|
938
|
+
console.warn(`[appserver:${this.workflowId.slice(0, 8)}] command result steer failed: ${err instanceof Error ? err.message : String(err)}`);
|
|
939
|
+
return false;
|
|
940
|
+
}
|
|
941
|
+
}
|
|
942
|
+
commandToolUse(item, completed) {
|
|
943
|
+
return {
|
|
944
|
+
name: 'Bash',
|
|
945
|
+
input: JSON.stringify({ command: item.command, cwd: item.cwd }),
|
|
946
|
+
status: completed ? (item.exitCode === 0 ? 'completed' : 'failed') : 'started',
|
|
947
|
+
provider: appServerProvider(this.config), itemType: 'command_execution', itemId: item.id,
|
|
948
|
+
...(completed && item.aggregatedOutput != null ? { output: item.aggregatedOutput } : {}),
|
|
949
|
+
...(completed && item.exitCode != null ? { exitCode: item.exitCode } : {}),
|
|
950
|
+
};
|
|
951
|
+
}
|
|
952
|
+
handleCommandItem(p, completed) {
|
|
953
|
+
if (p.item.type !== 'commandExecution')
|
|
954
|
+
return false;
|
|
955
|
+
if (p.threadId !== this.threadId || appServerProvider(this.config) !== 'codex')
|
|
956
|
+
return false;
|
|
957
|
+
const active = this.current.startedAt && (!this.current.turnId || p.turnId === this.current.turnId);
|
|
958
|
+
const event = this.commandToolUse(p.item, completed);
|
|
959
|
+
if (completed) {
|
|
960
|
+
// One completion per command: one that ended after the agent's final
|
|
961
|
+
// answer began is kept for after this turn; one from a turn that has
|
|
962
|
+
// already completed belongs to the long-lived publisher.
|
|
963
|
+
if (active && this.current.finalAnswerStarted)
|
|
964
|
+
this.lateCommands.completeUnseen(p.turnId, event);
|
|
965
|
+
else if (this.lateCommands.complete(p.turnId, event))
|
|
966
|
+
return true;
|
|
967
|
+
}
|
|
968
|
+
else if (active)
|
|
969
|
+
this.lateCommands.start(p.turnId, event);
|
|
970
|
+
if (active)
|
|
971
|
+
this.emit('tool_use', event);
|
|
972
|
+
return true;
|
|
973
|
+
}
|
|
906
974
|
onNotification(n) {
|
|
907
975
|
switch (n.method) {
|
|
908
976
|
case 'serverRequest/resolved': {
|
|
@@ -911,6 +979,13 @@ export class CodexAppServerWorker extends EventEmitter {
|
|
|
911
979
|
this.operatorQuestions.resolvedRpc(p.requestId);
|
|
912
980
|
return;
|
|
913
981
|
}
|
|
982
|
+
case 'thread/closed': {
|
|
983
|
+
// Codex unloaded the thread and stopped its terminals: no held
|
|
984
|
+
// command will report an end any more.
|
|
985
|
+
if (n.params.threadId === this.threadId)
|
|
986
|
+
this.lateCommands.disconnect();
|
|
987
|
+
return;
|
|
988
|
+
}
|
|
914
989
|
case 'thread/started': {
|
|
915
990
|
const p = n.params;
|
|
916
991
|
this.threadId = p.thread.id;
|
|
@@ -987,12 +1062,17 @@ export class CodexAppServerWorker extends EventEmitter {
|
|
|
987
1062
|
}
|
|
988
1063
|
case 'item/started': {
|
|
989
1064
|
const p = n.params;
|
|
990
|
-
|
|
1065
|
+
if (p.item.type === 'agentMessage' && p.item.phase === 'final_answer' && p.threadId === this.threadId
|
|
1066
|
+
&& this.current.startedAt && (!this.current.turnId || p.turnId === this.current.turnId))
|
|
1067
|
+
this.current.finalAnswerStarted = true;
|
|
1068
|
+
if (!this.handleCommandItem(p, false))
|
|
1069
|
+
this.emitToolUseFromItem(p.item, 'started');
|
|
991
1070
|
return;
|
|
992
1071
|
}
|
|
993
1072
|
case 'item/completed': {
|
|
994
1073
|
const p = n.params;
|
|
995
|
-
this.
|
|
1074
|
+
if (!this.handleCommandItem(p, true))
|
|
1075
|
+
this.emitToolUseFromItem(p.item, 'completed');
|
|
996
1076
|
const asyncItem = p.item;
|
|
997
1077
|
if (asyncItem.type === 'agentMessage' && asyncItem.delivery === 'async' && p.threadId === this.threadId && this.current.startedAt && (!this.current.turnId || p.turnId === this.current.turnId)) {
|
|
998
1078
|
try {
|
|
@@ -1114,23 +1194,9 @@ export class CodexAppServerWorker extends EventEmitter {
|
|
|
1114
1194
|
// unchanged on appserver tabs.
|
|
1115
1195
|
const provider = appServerProvider(this.config);
|
|
1116
1196
|
switch (item.type) {
|
|
1117
|
-
case 'commandExecution':
|
|
1118
|
-
|
|
1119
|
-
const finalStatus = completed ? (item.exitCode === 0 ? 'completed' : 'failed') : 'started';
|
|
1120
|
-
this.emit('tool_use', {
|
|
1121
|
-
name: 'Bash',
|
|
1122
|
-
input: JSON.stringify({ command: item.command, cwd: item.cwd }),
|
|
1123
|
-
status: finalStatus,
|
|
1124
|
-
provider,
|
|
1125
|
-
itemType: 'command_execution',
|
|
1126
|
-
itemId: item.id,
|
|
1127
|
-
...(completed && item.aggregatedOutput !== null
|
|
1128
|
-
? { output: item.aggregatedOutput }
|
|
1129
|
-
: {}),
|
|
1130
|
-
...(completed && item.exitCode !== null ? { exitCode: item.exitCode } : {}),
|
|
1131
|
-
});
|
|
1197
|
+
case 'commandExecution':
|
|
1198
|
+
this.emit('tool_use', this.commandToolUse(item, status === 'completed'));
|
|
1132
1199
|
return;
|
|
1133
|
-
}
|
|
1134
1200
|
case 'fileChange': {
|
|
1135
1201
|
const completed = status === 'completed';
|
|
1136
1202
|
const finalStatus = completed ? (item.status === 'completed' ? 'completed' : 'failed') : 'started';
|
|
@@ -1496,6 +1562,8 @@ export class CodexAppServerWorker extends EventEmitter {
|
|
|
1496
1562
|
this.emit('turn_settled', data);
|
|
1497
1563
|
return;
|
|
1498
1564
|
}
|
|
1565
|
+
if (this.current.turnId)
|
|
1566
|
+
this.lateCommands.settle(this.current.turnId);
|
|
1499
1567
|
this.current = emptyTurnState();
|
|
1500
1568
|
if (data.error && data.error !== 'Worker killed') {
|
|
1501
1569
|
// Also run the stderr fallback throttle sniffer in case the protocol
|
|
@@ -1519,6 +1587,7 @@ export class CodexAppServerWorker extends EventEmitter {
|
|
|
1519
1587
|
this.emit('fatal', reason);
|
|
1520
1588
|
}
|
|
1521
1589
|
teardownProcess() {
|
|
1590
|
+
this.lateCommands.disconnect();
|
|
1522
1591
|
this.operatorQuestions.cancel('The Codex connection closed.');
|
|
1523
1592
|
if (this.rpc) {
|
|
1524
1593
|
try {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { codexTurnWaitInstructions } from './codexCodeMode.js';
|
|
2
2
|
import { prepareProviderHistory, historyBinding } from './handoffHistoryBinding.js';
|
|
3
3
|
import { prepareLocalFileContext, combineChatAttachments } from './localFileMedia.js';
|
|
4
4
|
import { codexChatOverrides, requireCodexChatCapabilities } from './codexChatBoundary.js';
|
|
@@ -107,7 +107,7 @@ class CodexWorkerProcess extends EventEmitter {
|
|
|
107
107
|
// prefix cache like the rest of the framing. Covers operator turns AND
|
|
108
108
|
// primitive seeds (both carry config.goal). Absent / blank ⇒ no change.
|
|
109
109
|
// The output-style addendum closes the prefix, as on app-server.
|
|
110
|
-
const prefixParts = [
|
|
110
|
+
const prefixParts = [codexTurnWaitInstructions(this.config.clusterRole), goalBlock(this.config.goal), this.config.appendSystemPrompt, cliFileReadGuidance(this.config), outputStyleAddendum(this.config.outputStyle)]
|
|
111
111
|
.filter((s) => typeof s === 'string' && s.length > 0);
|
|
112
112
|
const prefixSp = prefixParts.length > 0 ? prefixParts.join('\n\n') : undefined;
|
|
113
113
|
const fullPrompt = prefixSp
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { WorkerConfig } from '@arco/shared';
|
|
2
2
|
export declare function codexModelUsesCodeMode(modelId: string, codexHome?: string): boolean | null;
|
|
3
3
|
export declare function codexCodeModeClusterAddendum(): string;
|
|
4
|
-
export declare const CODEX_TURN_DISCIPLINE
|
|
4
|
+
export declare const CODEX_TURN_DISCIPLINE: string;
|
|
5
|
+
export declare function codexTurnWaitInstructions(role: string | undefined): string;
|
|
5
6
|
export declare function codexClusterDeveloperInstructions(config: WorkerConfig): string | null;
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
import * as fs from 'node:fs';
|
|
12
12
|
import { resolveCodexHome } from './codexHome.js';
|
|
13
13
|
import * as path from 'node:path';
|
|
14
|
-
import { AGENT_TURN_WAIT, buildTurnWaitInstructions } from '@arco/shared';
|
|
14
|
+
import { AGENT_TURN_WAIT, buildTurnWaitInstructions, isClusterDirector } from '@arco/shared';
|
|
15
15
|
import { buildClusterDirectorDoctrine } from '../clusterDirector.js';
|
|
16
16
|
// Keyed by resolved models_cache.json path; revalidated by mtime so a codex
|
|
17
17
|
// catalog refresh (hourly, or on CLI upgrade) is picked up next turn.
|
|
@@ -81,7 +81,11 @@ export function codexCodeModeClusterAddendum() {
|
|
|
81
81
|
].join('\n');
|
|
82
82
|
}
|
|
83
83
|
// Standing turn discipline for every Codex workflow (cluster and single).
|
|
84
|
-
|
|
84
|
+
const CODEX_COMMAND_WAIT = 'A command reply with a session ID and no exit code means it is still running. Poll that session until it exits before reporting, and do not end the turn saying you are waiting for it. Start a program meant to keep running, such as a server or a watcher, in the background with & or nohup, so Arco does not wait for it.';
|
|
85
|
+
export const CODEX_TURN_DISCIPLINE = AGENT_TURN_WAIT + ' ' + CODEX_COMMAND_WAIT;
|
|
86
|
+
export function codexTurnWaitInstructions(role) {
|
|
87
|
+
return isClusterDirector(role) ? buildTurnWaitInstructions(role) : CODEX_TURN_DISCIPLINE;
|
|
88
|
+
}
|
|
85
89
|
// app-server can place Arco's durable cluster identity at developer level
|
|
86
90
|
// when a thread starts/resumes. Per-turn plan content still rides in user
|
|
87
91
|
// input because it is mutable; the stable role and tool contract do not need
|
|
@@ -91,7 +95,7 @@ export const CODEX_TURN_DISCIPLINE = AGENT_TURN_WAIT;
|
|
|
91
95
|
export function codexClusterDeveloperInstructions(config) {
|
|
92
96
|
if (config.provider !== 'codex')
|
|
93
97
|
return null;
|
|
94
|
-
const blocks = [
|
|
98
|
+
const blocks = [codexTurnWaitInstructions(config.clusterRole)];
|
|
95
99
|
if (config.clusterId) {
|
|
96
100
|
blocks.push('--- Arco cluster identity ---', config.clusterRole ? `Your operator-assigned role in the Arco cluster is: ${config.clusterRole.trim()}` : '', buildClusterDirectorDoctrine(config.clusterRole) ?? '');
|
|
97
101
|
if (codexModelUsesCodeMode(config.model, config.codexHome) !== false) {
|
|
@@ -54,6 +54,7 @@ export declare class WorkerManager {
|
|
|
54
54
|
}) => void;
|
|
55
55
|
drainSteer?: WorkerConfig['drainSteer'];
|
|
56
56
|
peekSteer?: WorkerConfig['peekSteer'];
|
|
57
|
+
pendingInput?: WorkerConfig['pendingInput'];
|
|
57
58
|
requeueSteer?: WorkerConfig['requeueSteer'];
|
|
58
59
|
onSteerDelivered?: WorkerConfig['onSteerDelivered'];
|
|
59
60
|
codexTransport?: WorkerConfig['codexTransport'];
|
|
@@ -65,6 +65,7 @@ export class WorkerManager {
|
|
|
65
65
|
incognito: options?.incognito,
|
|
66
66
|
drainSteer: options?.drainSteer,
|
|
67
67
|
peekSteer: options?.peekSteer,
|
|
68
|
+
pendingInput: options?.pendingInput,
|
|
68
69
|
requeueSteer: options?.requeueSteer,
|
|
69
70
|
onSteerDelivered: options?.onSteerDelivered,
|
|
70
71
|
// Phase 6 — workflowId is required for per-workflow-lifetime providers
|
|
@@ -27,9 +27,17 @@ export declare function spawnShellChild(run: ShellChildRun, options: SpawnOption
|
|
|
27
27
|
/** Tests: the tag spawnShellChild gave a child, if any. */
|
|
28
28
|
export declare function _shellTreeTagForTest(child: ChildProcess): string | undefined;
|
|
29
29
|
export declare const MSYS_TREE_SWEEP: string;
|
|
30
|
-
|
|
30
|
+
interface MsysSweepObservation {
|
|
31
|
+
code: number | null;
|
|
32
|
+
signal: NodeJS.Signals | null;
|
|
33
|
+
error?: string;
|
|
34
|
+
stdout: string;
|
|
35
|
+
stderr: string;
|
|
36
|
+
}
|
|
37
|
+
export declare function msysTreeSweep(bash: string, tag: string, platform?: NodeJS.Platform, observe?: (result: MsysSweepObservation) => void): Promise<number[]>;
|
|
31
38
|
/** Spawn options for such a child: its own process group on Unix, no console window on Windows. */
|
|
32
39
|
export declare function shellChildSpawnOptions(platform?: NodeJS.Platform): {
|
|
33
40
|
detached: boolean;
|
|
34
41
|
windowsHide: true;
|
|
35
42
|
};
|
|
43
|
+
export {};
|
|
@@ -163,9 +163,15 @@ export function _shellTreeTagForTest(child) {
|
|
|
163
163
|
// Prints, one per line, the Windows process id (or, outside Windows, the
|
|
164
164
|
// process id) of every MSYS process whose environment holds the tag. Bash
|
|
165
165
|
// built-ins only, so it starts nothing per process.
|
|
166
|
+
// Test observations on stderr contain process IDs and readability only.
|
|
166
167
|
export const MSYS_TREE_SWEEP = [
|
|
167
168
|
'tag=$1',
|
|
169
|
+
'if [ -n "$2" ]; then exec 3>&2; fi',
|
|
168
170
|
'for d in /proc/[0-9]*; do',
|
|
171
|
+
' if [ -n "$2" ]; then',
|
|
172
|
+
' readable=no; [ -r "$d/environ" ] && readable=yes',
|
|
173
|
+
' printf \'entry %s readable=%s\\n\' "${d#/proc/}" "$readable" >&3',
|
|
174
|
+
' fi',
|
|
169
175
|
' [ -r "$d/environ" ] || continue',
|
|
170
176
|
' hit=',
|
|
171
177
|
' while IFS= read -r -d \'\' e || [ -n "$e" ]; do',
|
|
@@ -174,6 +180,7 @@ export const MSYS_TREE_SWEEP = [
|
|
|
174
180
|
' [ -n "$hit" ] || continue',
|
|
175
181
|
' w=',
|
|
176
182
|
' [ -r "$d/winpid" ] && read -r w < "$d/winpid"',
|
|
183
|
+
' if [ -n "$2" ]; then printf \'match %s pid=%s\\n\' "${d#/proc/}" "$w" >&3; fi',
|
|
177
184
|
' printf \'%s\\n\' "${w:-${d#/proc/}}"',
|
|
178
185
|
'done 2>/dev/null',
|
|
179
186
|
'',
|
|
@@ -184,36 +191,45 @@ const SWEEP_TIMEOUT_MS = 5_000;
|
|
|
184
191
|
function listMsysTree(tree) {
|
|
185
192
|
return msysTreeSweep(tree.bash, tree.tag, process.platform);
|
|
186
193
|
}
|
|
187
|
-
export function msysTreeSweep(bash, tag, platform = process.platform) {
|
|
194
|
+
export function msysTreeSweep(bash, tag, platform = process.platform, observe) {
|
|
188
195
|
return new Promise((resolve) => {
|
|
189
196
|
const env = { ...process.env };
|
|
190
197
|
delete env[PROCESS_TREE_ENV];
|
|
191
198
|
let out = '';
|
|
199
|
+
let stderr = '';
|
|
192
200
|
let done = false;
|
|
193
|
-
const finish = () => {
|
|
201
|
+
const finish = (code, signal, error) => {
|
|
194
202
|
if (done)
|
|
195
203
|
return;
|
|
196
204
|
done = true;
|
|
197
205
|
clearTimeout(timer);
|
|
206
|
+
observe?.({ code, signal, error, stdout: out, stderr });
|
|
198
207
|
resolve(out.split(/\r?\n/).filter((l) => /^\d+$/.test(l.trim())).map((l) => Number(l.trim())));
|
|
199
208
|
};
|
|
200
|
-
const timer = setTimeout(() => {
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
209
|
+
const timer = setTimeout(() => {
|
|
210
|
+
try {
|
|
211
|
+
sweeper?.kill();
|
|
212
|
+
}
|
|
213
|
+
catch { /* gone */ }
|
|
214
|
+
finish(null, null, 'sweep timed out');
|
|
215
|
+
}, SWEEP_TIMEOUT_MS);
|
|
204
216
|
let sweeper;
|
|
205
217
|
try {
|
|
206
|
-
const
|
|
218
|
+
const args = ['-c', MSYS_TREE_SWEEP, 'arco-sweep', tag];
|
|
219
|
+
if (observe)
|
|
220
|
+
args.push('observe');
|
|
221
|
+
const plan = shellSpawnPlan({ file: bash, args, msys: true }, { env, stdio: ['ignore', 'pipe', observe ? 'pipe' : 'ignore'] }, platform);
|
|
207
222
|
// The sweep itself must not carry a tag, or it would list itself.
|
|
208
223
|
if (plan.options.env)
|
|
209
224
|
delete plan.options.env[PROCESS_TREE_ENV];
|
|
210
225
|
sweeper = spawn(plan.file, plan.args, plan.options);
|
|
211
226
|
sweeper.stdout?.on('data', (b) => { out += b.toString('utf8'); });
|
|
212
|
-
sweeper.on('
|
|
227
|
+
sweeper.stderr?.on('data', (b) => { stderr += b.toString('utf8'); });
|
|
228
|
+
sweeper.on('error', (error) => finish(null, null, error.code ?? error.name));
|
|
213
229
|
sweeper.on('close', finish);
|
|
214
230
|
}
|
|
215
|
-
catch {
|
|
216
|
-
finish();
|
|
231
|
+
catch (error) {
|
|
232
|
+
finish(null, null, error.code ?? 'sweep spawn failed');
|
|
217
233
|
}
|
|
218
234
|
});
|
|
219
235
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { runningCodexLateCommands } from '../providers/codex-appserver/index.js';
|
|
1
2
|
import { ensureWorkflowMetadata, providerConversationState, saveProviderSession } from '../providerConversation.js';
|
|
2
3
|
import { isClaudeNativeTaskActive } from '../providers/claude-native/index.js';
|
|
3
4
|
import { appendHandoffNotice } from '../handoffHistoryTool.js';
|
|
@@ -1834,6 +1835,7 @@ export async function rehydrateOneWorkflow(ws, workflowId, wf, clientLastSeq, op
|
|
|
1834
1835
|
const msg = {
|
|
1835
1836
|
type: 'workflow_state_snapshot',
|
|
1836
1837
|
workflowId,
|
|
1838
|
+
...(wf.primary.provider === 'codex' ? { codexLateCommands: runningCodexLateCommands(workflowId) } : {}),
|
|
1837
1839
|
...(conversationState ? { providerConversation: conversationState } : {}),
|
|
1838
1840
|
workers: {},
|
|
1839
1841
|
busy: wf.busy,
|
|
@@ -76,6 +76,7 @@ import { foldClaudeNativeWorker } from '../providers/claude-native/index.js';
|
|
|
76
76
|
import { maybeFreshComputerContext } from '../voice/computerContext.js';
|
|
77
77
|
import { takeQueuedTurn } from './messageQueue.js';
|
|
78
78
|
import { awaitModelImages } from '../providers/attachments.js';
|
|
79
|
+
import { adoptPhoneDrafts } from '../http/phoneUploadDrafts.js';
|
|
79
80
|
const PUBLIC_REPO_SAFETY_SYSTEM_BLOCK = [
|
|
80
81
|
'Genesis public repository safety:',
|
|
81
82
|
'This workflow is attached to a Genesis project configured for a public GitHub repository.',
|
|
@@ -1499,6 +1500,10 @@ opts) {
|
|
|
1499
1500
|
type: 'system_notice', workflowId,
|
|
1500
1501
|
content: '[INTERRUPT & SEND] No interruptible Claude or Codex primary turn is running. Your message is queued as a follow-up.',
|
|
1501
1502
|
});
|
|
1503
|
+
if (!isolatedMember && !adoptPhoneDrafts(workflowId, attachments)) {
|
|
1504
|
+
send(ws, { type: 'error', workflowId, message: 'A phone attachment expired or belongs to another conversation.' });
|
|
1505
|
+
return;
|
|
1506
|
+
}
|
|
1502
1507
|
const arr = bucket === 'steer' ? wf.queue.steering : wf.queue.followUp;
|
|
1503
1508
|
const queuedAttachments = [...new Set([...(attachments ?? []), ...contextAttachments])];
|
|
1504
1509
|
const queuedItem = { clusterBusyReminder: opts?.clusterBusyReminder, automaticKind: opts?.automaticKind, content, attachments: isolatedMember || !queuedAttachments.length ? undefined : queuedAttachments, clientMessageId, expandedContext, pickedSkills, editPickedSkills, ollamaInputSeq: undefined, ...(interrupt ? { interrupt: true } : {}) };
|
|
@@ -1576,6 +1581,10 @@ opts) {
|
|
|
1576
1581
|
// Refuse before taking queued input: a restore admitted during preflight
|
|
1577
1582
|
// must leave the queue available for an explicit later attempt.
|
|
1578
1583
|
assertCheckoutAvailable(workflowWritePaths(wf));
|
|
1584
|
+
if (!fromQueue && !isolatedMember && !adoptPhoneDrafts(workflowId, attachments)) {
|
|
1585
|
+
send(ws, { type: 'error', workflowId, message: 'A phone attachment expired or belongs to another conversation.' });
|
|
1586
|
+
return;
|
|
1587
|
+
}
|
|
1579
1588
|
let activeOllamaInputSeqs = [];
|
|
1580
1589
|
let activeInputClientIds = [];
|
|
1581
1590
|
if (fromQueue) {
|
|
@@ -2539,6 +2548,14 @@ opts) {
|
|
|
2539
2548
|
return [];
|
|
2540
2549
|
return wf.queue.steering;
|
|
2541
2550
|
},
|
|
2551
|
+
pendingInput: () => {
|
|
2552
|
+
if (!dispatchCurrent() || wf.queue.steering.some((item) => item.interrupt))
|
|
2553
|
+
return undefined;
|
|
2554
|
+
const direct = (item) => item.automaticKind !== 'auto-pickup';
|
|
2555
|
+
if (!wf.primaryTurn?.holdSteer && wf.queue.steering.some(direct))
|
|
2556
|
+
return 'steer';
|
|
2557
|
+
return wf.queue.followUp.some(direct) ? 'follow-up' : undefined;
|
|
2558
|
+
},
|
|
2542
2559
|
requeueSteer: (items, bucket) => {
|
|
2543
2560
|
if (workflows.get(workflowId) === wf && (busyRevocations.get(wf) ?? 0) === interruptEpoch)
|
|
2544
2561
|
requeueSteerForWorker(workflowId, ws, items, bucket);
|