@the-open-engine/zeroshot 6.7.0 → 6.7.1
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/cli/commands/providers.js +4 -1
- package/cli/index.js +18 -12
- package/lib/agent-cli-provider/adapters/claude.d.ts.map +1 -1
- package/lib/agent-cli-provider/adapters/claude.js +23 -10
- package/lib/agent-cli-provider/adapters/claude.js.map +1 -1
- package/lib/agent-cli-provider/adapters/codex.d.ts.map +1 -1
- package/lib/agent-cli-provider/adapters/codex.js +4 -0
- package/lib/agent-cli-provider/adapters/codex.js.map +1 -1
- package/lib/agent-cli-provider/adapters/common.d.ts.map +1 -1
- package/lib/agent-cli-provider/adapters/common.js +2 -1
- package/lib/agent-cli-provider/adapters/common.js.map +1 -1
- package/lib/agent-cli-provider/contract-options.d.ts.map +1 -1
- package/lib/agent-cli-provider/contract-options.js +2 -1
- package/lib/agent-cli-provider/contract-options.js.map +1 -1
- package/lib/agent-cli-provider/index.d.ts +1 -1
- package/lib/agent-cli-provider/index.d.ts.map +1 -1
- package/lib/agent-cli-provider/index.js.map +1 -1
- package/lib/agent-cli-provider/provider-registry.d.ts +1 -1
- package/lib/agent-cli-provider/provider-registry.js +1 -1
- package/lib/agent-cli-provider/provider-registry.js.map +1 -1
- package/lib/agent-cli-provider/single-agent-runtime.js +6 -2
- package/lib/agent-cli-provider/single-agent-runtime.js.map +1 -1
- package/lib/agent-cli-provider/types.d.ts +3 -1
- package/lib/agent-cli-provider/types.d.ts.map +1 -1
- package/lib/agent-cli-provider/types.js.map +1 -1
- package/lib/settings.js +1 -0
- package/package.json +1 -1
- package/scripts/run-lint-staged-no-stash.js +68 -0
- package/src/agent/agent-lifecycle.js +368 -91
- package/src/agent/agent-task-executor.js +384 -101
- package/src/agent-cli-provider/adapters/claude.ts +29 -11
- package/src/agent-cli-provider/adapters/codex.ts +4 -0
- package/src/agent-cli-provider/adapters/common.ts +2 -1
- package/src/agent-cli-provider/contract-options.ts +2 -1
- package/src/agent-cli-provider/index.ts +1 -0
- package/src/agent-cli-provider/provider-registry.ts +1 -1
- package/src/agent-cli-provider/single-agent-runtime.ts +8 -2
- package/src/agent-cli-provider/types.ts +3 -1
- package/src/agent-wrapper.js +9 -2
- package/src/config-validator.js +10 -11
- package/src/orchestrator.js +18 -6
- package/task-lib/attachable-watcher.js +10 -1
- package/task-lib/commands/kill.js +34 -9
- package/task-lib/commands/status.js +13 -3
- package/task-lib/process-termination.js +202 -0
- package/task-lib/runner.js +8 -20
- package/task-lib/store.js +28 -6
- package/task-lib/watcher.js +14 -2
package/task-lib/runner.js
CHANGED
|
@@ -7,6 +7,12 @@ import { createRequire } from 'module';
|
|
|
7
7
|
|
|
8
8
|
const require = createRequire(import.meta.url);
|
|
9
9
|
const { prepareSingleAgentProviderCommand } = require('./provider-helper-runtime.js');
|
|
10
|
+
export {
|
|
11
|
+
isOwnedProcessTreeRunning,
|
|
12
|
+
isProcessRunning,
|
|
13
|
+
killTask,
|
|
14
|
+
terminateProcess,
|
|
15
|
+
} from './process-termination.js';
|
|
10
16
|
|
|
11
17
|
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
12
18
|
|
|
@@ -136,6 +142,8 @@ function buildTaskRecord({ id, prompt, cwd, options, logFile, providerName, mode
|
|
|
136
142
|
// Attach support
|
|
137
143
|
socketPath: null,
|
|
138
144
|
attachable: false,
|
|
145
|
+
processGroupId: null,
|
|
146
|
+
terminationStrategy: null,
|
|
139
147
|
};
|
|
140
148
|
}
|
|
141
149
|
|
|
@@ -176,23 +184,3 @@ function spawnWatcher({ watcherScript, id, cwd, logFile, finalArgs, watcherConfi
|
|
|
176
184
|
watcher.unref();
|
|
177
185
|
watcher.disconnect(); // Close IPC channel so parent can exit
|
|
178
186
|
}
|
|
179
|
-
|
|
180
|
-
export function isProcessRunning(pid) {
|
|
181
|
-
if (!pid) return false;
|
|
182
|
-
try {
|
|
183
|
-
process.kill(pid, 0);
|
|
184
|
-
return true;
|
|
185
|
-
} catch {
|
|
186
|
-
return false;
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
export function killTask(pid) {
|
|
191
|
-
if (!pid) return false;
|
|
192
|
-
try {
|
|
193
|
-
process.kill(pid, 'SIGTERM');
|
|
194
|
-
return true;
|
|
195
|
-
} catch {
|
|
196
|
-
return false;
|
|
197
|
-
}
|
|
198
|
-
}
|
package/task-lib/store.js
CHANGED
|
@@ -50,7 +50,9 @@ function getDb() {
|
|
|
50
50
|
model TEXT,
|
|
51
51
|
schedule_id TEXT,
|
|
52
52
|
socket_path TEXT,
|
|
53
|
-
attachable INTEGER DEFAULT 0
|
|
53
|
+
attachable INTEGER DEFAULT 0,
|
|
54
|
+
process_group_id INTEGER,
|
|
55
|
+
termination_strategy TEXT
|
|
54
56
|
);
|
|
55
57
|
|
|
56
58
|
CREATE INDEX IF NOT EXISTS idx_tasks_status ON tasks(status);
|
|
@@ -75,9 +77,19 @@ function getDb() {
|
|
|
75
77
|
CREATE INDEX IF NOT EXISTS idx_schedules_enabled ON schedules(enabled);
|
|
76
78
|
`);
|
|
77
79
|
|
|
80
|
+
ensureTaskColumn(db, 'process_group_id', 'INTEGER');
|
|
81
|
+
ensureTaskColumn(db, 'termination_strategy', 'TEXT');
|
|
82
|
+
|
|
78
83
|
return db;
|
|
79
84
|
}
|
|
80
85
|
|
|
86
|
+
function ensureTaskColumn(database, name, definition) {
|
|
87
|
+
const columns = database.pragma('table_info(tasks)');
|
|
88
|
+
if (!columns.some((column) => column.name === name)) {
|
|
89
|
+
database.exec(`ALTER TABLE tasks ADD COLUMN ${name} ${definition}`);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
81
93
|
export function ensureDirs() {
|
|
82
94
|
if (!existsSync(TASKS_DIR)) mkdirSync(TASKS_DIR, { recursive: true });
|
|
83
95
|
if (!existsSync(LOGS_DIR)) mkdirSync(LOGS_DIR, { recursive: true });
|
|
@@ -110,6 +122,8 @@ function rowToTask(row) {
|
|
|
110
122
|
scheduleId: row.schedule_id,
|
|
111
123
|
socketPath: row.socket_path,
|
|
112
124
|
attachable: Boolean(row.attachable),
|
|
125
|
+
processGroupId: row.process_group_id,
|
|
126
|
+
terminationStrategy: row.termination_strategy,
|
|
113
127
|
};
|
|
114
128
|
}
|
|
115
129
|
|
|
@@ -137,11 +151,11 @@ export function saveTasks(tasks) {
|
|
|
137
151
|
INSERT OR REPLACE INTO tasks (
|
|
138
152
|
id, prompt, full_prompt, cwd, status, pid, session_id, log_file,
|
|
139
153
|
created_at, updated_at, exit_code, error, provider, model,
|
|
140
|
-
schedule_id, socket_path, attachable
|
|
154
|
+
schedule_id, socket_path, attachable, process_group_id, termination_strategy
|
|
141
155
|
) VALUES (
|
|
142
156
|
@id, @prompt, @fullPrompt, @cwd, @status, @pid, @sessionId, @logFile,
|
|
143
157
|
@createdAt, @updatedAt, @exitCode, @error, @provider, @model,
|
|
144
|
-
@scheduleId, @socketPath, @attachable
|
|
158
|
+
@scheduleId, @socketPath, @attachable, @processGroupId, @terminationStrategy
|
|
145
159
|
)
|
|
146
160
|
`);
|
|
147
161
|
|
|
@@ -168,6 +182,8 @@ export function saveTasks(tasks) {
|
|
|
168
182
|
scheduleId: task.scheduleId || null,
|
|
169
183
|
socketPath: task.socketPath || null,
|
|
170
184
|
attachable: task.attachable ? 1 : 0,
|
|
185
|
+
processGroupId: task.processGroupId || null,
|
|
186
|
+
terminationStrategy: task.terminationStrategy || null,
|
|
171
187
|
});
|
|
172
188
|
}
|
|
173
189
|
});
|
|
@@ -232,7 +248,9 @@ export function updateTask(id, updates) {
|
|
|
232
248
|
model = @model,
|
|
233
249
|
schedule_id = @scheduleId,
|
|
234
250
|
socket_path = @socketPath,
|
|
235
|
-
attachable = @attachable
|
|
251
|
+
attachable = @attachable,
|
|
252
|
+
process_group_id = @processGroupId,
|
|
253
|
+
termination_strategy = @terminationStrategy
|
|
236
254
|
WHERE id = @id
|
|
237
255
|
`
|
|
238
256
|
)
|
|
@@ -253,6 +271,8 @@ export function updateTask(id, updates) {
|
|
|
253
271
|
scheduleId: updated.scheduleId || null,
|
|
254
272
|
socketPath: updated.socketPath || null,
|
|
255
273
|
attachable: updated.attachable ? 1 : 0,
|
|
274
|
+
processGroupId: updated.processGroupId || null,
|
|
275
|
+
terminationStrategy: updated.terminationStrategy || null,
|
|
256
276
|
});
|
|
257
277
|
|
|
258
278
|
return updated;
|
|
@@ -277,11 +297,11 @@ export function addTask(task) {
|
|
|
277
297
|
INSERT INTO tasks (
|
|
278
298
|
id, prompt, full_prompt, cwd, status, pid, session_id, log_file,
|
|
279
299
|
created_at, updated_at, exit_code, error, provider, model,
|
|
280
|
-
schedule_id, socket_path, attachable
|
|
300
|
+
schedule_id, socket_path, attachable, process_group_id, termination_strategy
|
|
281
301
|
) VALUES (
|
|
282
302
|
@id, @prompt, @fullPrompt, @cwd, @status, @pid, @sessionId, @logFile,
|
|
283
303
|
@createdAt, @updatedAt, @exitCode, @error, @provider, @model,
|
|
284
|
-
@scheduleId, @socketPath, @attachable
|
|
304
|
+
@scheduleId, @socketPath, @attachable, @processGroupId, @terminationStrategy
|
|
285
305
|
)
|
|
286
306
|
`
|
|
287
307
|
)
|
|
@@ -303,6 +323,8 @@ export function addTask(task) {
|
|
|
303
323
|
scheduleId: fullTask.scheduleId || null,
|
|
304
324
|
socketPath: fullTask.socketPath || null,
|
|
305
325
|
attachable: fullTask.attachable ? 1 : 0,
|
|
326
|
+
processGroupId: fullTask.processGroupId || null,
|
|
327
|
+
terminationStrategy: fullTask.terminationStrategy || null,
|
|
306
328
|
});
|
|
307
329
|
|
|
308
330
|
return fullTask;
|
package/task-lib/watcher.js
CHANGED
|
@@ -45,10 +45,15 @@ const child = spawn(command, finalArgs, {
|
|
|
45
45
|
cwd: commandSpec.cwd || cwd,
|
|
46
46
|
env,
|
|
47
47
|
stdio: ['ignore', 'pipe', 'pipe'],
|
|
48
|
+
detached: process.platform !== 'win32',
|
|
48
49
|
windowsHide: true,
|
|
49
50
|
});
|
|
50
51
|
|
|
51
|
-
updateTask(taskId, {
|
|
52
|
+
updateTask(taskId, {
|
|
53
|
+
pid: child.pid,
|
|
54
|
+
processGroupId: process.platform === 'win32' ? null : child.pid,
|
|
55
|
+
terminationStrategy: process.platform === 'win32' ? 'process-tree' : 'process-group',
|
|
56
|
+
});
|
|
52
57
|
|
|
53
58
|
const silentJsonMode =
|
|
54
59
|
config.outputFormat === 'json' &&
|
|
@@ -285,6 +290,8 @@ child.on('close', async (code, signal) => {
|
|
|
285
290
|
try {
|
|
286
291
|
await updateTask(taskId, {
|
|
287
292
|
status,
|
|
293
|
+
pid: null,
|
|
294
|
+
processGroupId: null,
|
|
288
295
|
exitCode: resolvedCode,
|
|
289
296
|
error: fatalError || (resolvedCode !== 0 && signal ? `Killed by ${signal}` : null),
|
|
290
297
|
});
|
|
@@ -298,7 +305,12 @@ child.on('error', async (err) => {
|
|
|
298
305
|
log(`\nError: ${err.message}\n`);
|
|
299
306
|
cleanupCommandSpecSync();
|
|
300
307
|
try {
|
|
301
|
-
await updateTask(taskId, {
|
|
308
|
+
await updateTask(taskId, {
|
|
309
|
+
status: 'failed',
|
|
310
|
+
pid: null,
|
|
311
|
+
processGroupId: null,
|
|
312
|
+
error: err.message,
|
|
313
|
+
});
|
|
302
314
|
} catch (updateError) {
|
|
303
315
|
log(`[${Date.now()}][ERROR] Failed to update task status: ${updateError.message}\n`);
|
|
304
316
|
}
|