@the-open-engine/zeroshot 6.21.0 → 6.23.0
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/lib/agent-cli-provider/adapters/omp.d.ts +3 -1
- package/lib/agent-cli-provider/adapters/omp.d.ts.map +1 -1
- package/lib/agent-cli-provider/adapters/omp.js +252 -269
- package/lib/agent-cli-provider/adapters/omp.js.map +1 -1
- package/lib/agent-cli-provider/contract-invoke.d.ts.map +1 -1
- package/lib/agent-cli-provider/contract-invoke.js +68 -14
- package/lib/agent-cli-provider/contract-invoke.js.map +1 -1
- package/lib/agent-cli-provider/contract-options.d.ts.map +1 -1
- package/lib/agent-cli-provider/contract-options.js +5 -3
- package/lib/agent-cli-provider/contract-options.js.map +1 -1
- package/lib/agent-cli-provider/index.d.ts +6 -0
- package/lib/agent-cli-provider/index.d.ts.map +1 -1
- package/lib/agent-cli-provider/index.js +12 -1
- package/lib/agent-cli-provider/index.js.map +1 -1
- package/lib/agent-cli-provider/omp-release.d.ts +3 -1
- package/lib/agent-cli-provider/omp-release.d.ts.map +1 -1
- package/lib/agent-cli-provider/omp-release.js +22 -2
- package/lib/agent-cli-provider/omp-release.js.map +1 -1
- package/lib/agent-cli-provider/omp-rpc-bounds.d.ts +7 -0
- package/lib/agent-cli-provider/omp-rpc-bounds.d.ts.map +1 -0
- package/lib/agent-cli-provider/omp-rpc-bounds.js +27 -0
- package/lib/agent-cli-provider/omp-rpc-bounds.js.map +1 -0
- package/lib/agent-cli-provider/omp-rpc-driver.d.ts +40 -0
- package/lib/agent-cli-provider/omp-rpc-driver.d.ts.map +1 -0
- package/lib/agent-cli-provider/omp-rpc-driver.js +494 -0
- package/lib/agent-cli-provider/omp-rpc-driver.js.map +1 -0
- package/lib/agent-cli-provider/omp-rpc-events.d.ts +28 -0
- package/lib/agent-cli-provider/omp-rpc-events.d.ts.map +1 -0
- package/lib/agent-cli-provider/omp-rpc-events.js +264 -0
- package/lib/agent-cli-provider/omp-rpc-events.js.map +1 -0
- package/lib/agent-cli-provider/omp-rpc-protocol.d.ts +1 -1
- package/lib/agent-cli-provider/omp-rpc-protocol.d.ts.map +1 -1
- package/lib/agent-cli-provider/omp-rpc-protocol.js +8 -3
- package/lib/agent-cli-provider/omp-rpc-protocol.js.map +1 -1
- package/lib/agent-cli-provider/omp-rpc-session.d.ts +17 -0
- package/lib/agent-cli-provider/omp-rpc-session.d.ts.map +1 -0
- package/lib/agent-cli-provider/omp-rpc-session.js +6 -0
- package/lib/agent-cli-provider/omp-rpc-session.js.map +1 -0
- package/lib/agent-cli-provider/provider-registry.d.ts +15 -11
- package/lib/agent-cli-provider/provider-registry.d.ts.map +1 -1
- package/lib/agent-cli-provider/provider-registry.js +16 -5
- package/lib/agent-cli-provider/provider-registry.js.map +1 -1
- package/lib/agent-cli-provider/types.d.ts +13 -11
- package/lib/agent-cli-provider/types.d.ts.map +1 -1
- package/lib/agent-cli-provider/types.js.map +1 -1
- package/package.json +2 -1
- package/src/agent-cli-provider/adapters/omp.ts +276 -329
- package/src/agent-cli-provider/contract-invoke.ts +86 -15
- package/src/agent-cli-provider/contract-options.ts +5 -3
- package/src/agent-cli-provider/index.ts +13 -0
- package/src/agent-cli-provider/omp-release.ts +24 -1
- package/src/agent-cli-provider/omp-rpc-bounds.ts +28 -0
- package/src/agent-cli-provider/omp-rpc-driver.ts +611 -0
- package/src/agent-cli-provider/omp-rpc-events.ts +318 -0
- package/src/agent-cli-provider/omp-rpc-protocol.ts +8 -3
- package/src/agent-cli-provider/omp-rpc-session.ts +20 -0
- package/src/agent-cli-provider/provider-registry.ts +26 -7
- package/src/agent-cli-provider/types.ts +14 -11
- package/src/command-cleanup-ownership.js +307 -0
- package/src/omp-config-overlay.js +96 -0
- package/src/orchestrator.js +20 -5
- package/src/preflight.js +35 -3
- package/src/watcher-prompt-channel.js +209 -0
- package/task-lib/command-spec-cleanup.js +1 -262
- package/task-lib/provider-helper-runtime.js +6 -0
- package/task-lib/rpc-watcher.js +186 -0
- package/task-lib/runner.js +40 -6
- package/task-lib/watcher-output-runtime.js +32 -0
package/task-lib/runner.js
CHANGED
|
@@ -6,7 +6,11 @@ import { addTask, generateId, ensureDirs } from './store.js';
|
|
|
6
6
|
import { createRequire } from 'module';
|
|
7
7
|
|
|
8
8
|
const require = createRequire(import.meta.url);
|
|
9
|
-
const {
|
|
9
|
+
const {
|
|
10
|
+
buildOmpPrompt,
|
|
11
|
+
getProviderRegistryEntry,
|
|
12
|
+
prepareSingleAgentProviderCommand,
|
|
13
|
+
} = require('./provider-helper-runtime.js');
|
|
10
14
|
const {
|
|
11
15
|
ISOLATED_SETTINGS_FILE_ENV,
|
|
12
16
|
ISOLATED_SETTINGS_FILE_MARKER,
|
|
@@ -18,6 +22,7 @@ const {
|
|
|
18
22
|
isClaudeSettingsOverlayPath,
|
|
19
23
|
} = require('../src/worktree-claude-config');
|
|
20
24
|
const { TASK_SPAWN_OWNERSHIP_TOKEN_ENV } = require('../src/task-spawn-cleanup-ownership');
|
|
25
|
+
const { sendWatcherPrompt } = require('../src/watcher-prompt-channel');
|
|
21
26
|
export {
|
|
22
27
|
isOwnedProcessTreeRunning,
|
|
23
28
|
isProcessRunning,
|
|
@@ -79,6 +84,12 @@ export function spawnTask(prompt, options = {}) {
|
|
|
79
84
|
logFile,
|
|
80
85
|
finalArgs: commandSpec.args,
|
|
81
86
|
watcherConfig,
|
|
87
|
+
// Prompt bytes never enter argv: the rpc-stdio watcher receives them over a private pipe
|
|
88
|
+
// (src/watcher-prompt-channel.js). Every other lane passes the prompt to the provider through
|
|
89
|
+
// commandSpec.args, which the provider process — not a long-lived watcher — then owns.
|
|
90
|
+
...(isRpcStdioLane(providerName)
|
|
91
|
+
? { rpcPrompt: buildOmpPrompt(prompt, prepared.options || {}) }
|
|
92
|
+
: {}),
|
|
82
93
|
});
|
|
83
94
|
|
|
84
95
|
return task;
|
|
@@ -250,6 +261,13 @@ export function buildTaskRecord({
|
|
|
250
261
|
};
|
|
251
262
|
}
|
|
252
263
|
|
|
264
|
+
function isRpcStdioLane(providerName) {
|
|
265
|
+
return getProviderRegistryEntry(providerName).invoke.lane === 'rpc-stdio';
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
// The returned object is JSON-serialized into the detached watcher's argv, so it must never carry
|
|
269
|
+
// prompt or other task content: `ps` and /proc/<pid>/cmdline expose argv to every local user for
|
|
270
|
+
// the whole lifetime of the watcher.
|
|
253
271
|
function buildWatcherConfig(outputFormat, jsonSchema, options, providerName, commandSpec) {
|
|
254
272
|
return {
|
|
255
273
|
outputFormat,
|
|
@@ -259,13 +277,13 @@ function buildWatcherConfig(outputFormat, jsonSchema, options, providerName, com
|
|
|
259
277
|
provider: providerName,
|
|
260
278
|
command: commandSpec.binary,
|
|
261
279
|
env: commandSpec.env || {},
|
|
262
|
-
commandSpec: buildWatcherCommandSpec(commandSpec),
|
|
280
|
+
commandSpec: buildWatcherCommandSpec(commandSpec, isRpcStdioLane(providerName)),
|
|
263
281
|
};
|
|
264
282
|
}
|
|
265
283
|
|
|
266
|
-
function buildWatcherCommandSpec(commandSpec) {
|
|
284
|
+
function buildWatcherCommandSpec(commandSpec, keepArgs = false) {
|
|
267
285
|
const watcherCommandSpec = { ...commandSpec };
|
|
268
|
-
delete watcherCommandSpec.args;
|
|
286
|
+
if (!keepArgs) delete watcherCommandSpec.args;
|
|
269
287
|
return watcherCommandSpec;
|
|
270
288
|
}
|
|
271
289
|
|
|
@@ -274,6 +292,12 @@ export function shouldUseAttachableWatcher(options, providerName) {
|
|
|
274
292
|
return false;
|
|
275
293
|
}
|
|
276
294
|
|
|
295
|
+
// The rpc-stdio lane owns bidirectional correlated RPC over stdio itself (see
|
|
296
|
+
// omp-rpc-driver.ts) and always uses rpc-watcher.js instead of the attachable PTY watcher.
|
|
297
|
+
if (isRpcStdioLane(providerName)) {
|
|
298
|
+
return false;
|
|
299
|
+
}
|
|
300
|
+
|
|
277
301
|
// Claude strict structured output still needs the non-PTY watcher. Claude
|
|
278
302
|
// can treat PTY notifications as streaming commands and reject the run.
|
|
279
303
|
// Other providers, including Codex, support their structured-output mode in
|
|
@@ -282,23 +306,33 @@ export function shouldUseAttachableWatcher(options, providerName) {
|
|
|
282
306
|
}
|
|
283
307
|
|
|
284
308
|
function resolveWatcherScript(options, providerName) {
|
|
309
|
+
if (isRpcStdioLane(providerName)) {
|
|
310
|
+
return join(__dirname, 'rpc-watcher.js');
|
|
311
|
+
}
|
|
285
312
|
const useAttachable = shouldUseAttachableWatcher(options, providerName);
|
|
286
313
|
return useAttachable ? join(__dirname, 'attachable-watcher.js') : join(__dirname, 'watcher.js');
|
|
287
314
|
}
|
|
288
315
|
|
|
289
|
-
function spawnWatcher({ watcherScript, id, cwd, logFile, finalArgs, watcherConfig }) {
|
|
316
|
+
function spawnWatcher({ watcherScript, id, cwd, logFile, finalArgs, watcherConfig, rpcPrompt }) {
|
|
317
|
+
const sendsPrompt = typeof rpcPrompt === 'string';
|
|
290
318
|
const watcherEnv = buildWatcherEnv();
|
|
291
319
|
const watcher = fork(
|
|
292
320
|
watcherScript,
|
|
293
321
|
[id, cwd, logFile, JSON.stringify(finalArgs), JSON.stringify(watcherConfig)],
|
|
294
322
|
{
|
|
295
323
|
detached: true,
|
|
296
|
-
|
|
324
|
+
// A prompt-carrying lane needs a real pipe on fd 0 to receive it; every other lane keeps
|
|
325
|
+
// stdio fully ignored. fork() requires an explicit 'ipc' slot once stdio is an array.
|
|
326
|
+
stdio: sendsPrompt ? ['pipe', 'ignore', 'ignore', 'ipc'] : 'ignore',
|
|
297
327
|
windowsHide: true,
|
|
298
328
|
env: watcherEnv,
|
|
299
329
|
}
|
|
300
330
|
);
|
|
301
331
|
|
|
332
|
+
// Only the pipe write holds the event loop (until it drains), never the watcher itself: the
|
|
333
|
+
// parent still exits without waiting for the detached task to finish.
|
|
334
|
+
if (sendsPrompt) sendWatcherPrompt(watcher.stdin, rpcPrompt);
|
|
335
|
+
|
|
302
336
|
watcher.unref();
|
|
303
337
|
watcher.disconnect(); // Close IPC channel so parent can exit
|
|
304
338
|
}
|
|
@@ -140,6 +140,38 @@ export function completeWatcherFailure({ error, source, ...completionOptions })
|
|
|
140
140
|
});
|
|
141
141
|
}
|
|
142
142
|
|
|
143
|
+
/**
|
|
144
|
+
* Output runtime for the rpc-stdio lane (see task-lib/rpc-watcher.js). Unlike
|
|
145
|
+
* createWatcherOutputRuntime, there is no raw stdout/stderr byte stream to parse: the
|
|
146
|
+
* OMP RPC driver (omp-rpc-driver.ts) already normalizes every frame into an OutputEvent before
|
|
147
|
+
* calling onEvent, so this runtime only ever logs already-normalized events — never raw RPC
|
|
148
|
+
* frames, prompt text, or control payloads.
|
|
149
|
+
*/
|
|
150
|
+
export function createRpcWatcherOutputRuntime({ log }) {
|
|
151
|
+
function logEvent(event) {
|
|
152
|
+
log(`[${Date.now()}]${JSON.stringify(event)}\n`);
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
function complete(result) {
|
|
156
|
+
const lastResult = [...result.events].reverse().find((event) => event.type === 'result');
|
|
157
|
+
const turnFailed = lastResult !== undefined && lastResult.success === false;
|
|
158
|
+
const success = result.stopReason === 'completed' && !turnFailed;
|
|
159
|
+
const resolvedCode = success ? 0 : 1;
|
|
160
|
+
log(`\n${'='.repeat(50)}\n`);
|
|
161
|
+
log(`Finished: ${new Date().toISOString()}\n`);
|
|
162
|
+
log(
|
|
163
|
+
`Stop reason: ${result.stopReason}, Exit code: ${result.exitCode}, Signal: ${result.signal}\n`
|
|
164
|
+
);
|
|
165
|
+
return {
|
|
166
|
+
resolvedCode,
|
|
167
|
+
status: success ? 'completed' : 'failed',
|
|
168
|
+
error: success ? null : (lastResult && lastResult.error) || result.stopReason,
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
return { logEvent, complete };
|
|
173
|
+
}
|
|
174
|
+
|
|
143
175
|
export function createWatcherOutputRuntime({
|
|
144
176
|
config,
|
|
145
177
|
providerName,
|