@hyperwindmill/caretaker-cli 0.22.0 → 0.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/dist/cli/web/scheduler/locks.d.ts +3 -3
- package/dist/cli/web/scheduler/task_roles.js +1 -1
- package/dist/cli/web/scheduler/task_strategy.js +4 -4
- package/dist/cli/web/server.d.ts.map +1 -1
- package/dist/cli/web/server.js +61 -26
- package/dist/harness/tools/builtin/task_tools.js +37 -37
- package/dist/lib/docker.d.ts +1 -1
- package/dist/lib/docker.d.ts.map +1 -1
- package/dist/lib/docker.js +2 -2
- package/dist/lib/project_slug.d.ts +29 -0
- package/dist/lib/project_slug.d.ts.map +1 -0
- package/dist/lib/project_slug.js +41 -0
- package/dist/lib/task_git.d.ts +5 -5
- package/dist/lib/task_git.d.ts.map +1 -1
- package/dist/lib/task_git.js +8 -6
- package/dist/store/db.d.ts +12 -7
- package/dist/store/db.d.ts.map +1 -1
- package/dist/store/db.js +59 -15
- package/dist/store/json.d.ts +1 -0
- package/dist/store/json.d.ts.map +1 -1
- package/dist/store/json.js +6 -1
- package/dist/webview/standalone.js +45 -19
- package/dist/webview/standalone.js.map +2 -2
- package/package.json +3 -3
|
@@ -11,13 +11,13 @@ export declare const runningTasks: Set<string>;
|
|
|
11
11
|
* for the current cycle to burn through its turns — the whole point of Pause
|
|
12
12
|
* when an agent has gone off the rails.
|
|
13
13
|
*/
|
|
14
|
-
export declare const runningTaskControllers: Map<
|
|
14
|
+
export declare const runningTaskControllers: Map<string, AbortController>;
|
|
15
15
|
/** Abort the in-flight run for a task, if one is registered. Returns whether it fired. */
|
|
16
|
-
export declare function abortRunningTask(taskId:
|
|
16
|
+
export declare function abortRunningTask(taskId: string): boolean;
|
|
17
17
|
/**
|
|
18
18
|
* Project ids with a repository sync (clone/pull) in flight — shared between
|
|
19
19
|
* the heartbeat's pre-worktree sync and POST /api/projects/:id/sync so the
|
|
20
20
|
* two can never race a clone. Derived state only; never persisted.
|
|
21
21
|
*/
|
|
22
|
-
export declare const syncingProjects: Set<
|
|
22
|
+
export declare const syncingProjects: Set<string>;
|
|
23
23
|
//# sourceMappingURL=locks.d.ts.map
|
|
@@ -51,7 +51,7 @@ export function resolveSddEnabled(task, project) {
|
|
|
51
51
|
export async function activationStatus(task, project) {
|
|
52
52
|
if (!resolvePlanningEnabled(task, project))
|
|
53
53
|
return 'active';
|
|
54
|
-
const messages = (await runQuery(`SELECT * FROM task_messages WHERE taskId = ${task.id}`));
|
|
54
|
+
const messages = (await runQuery(`SELECT * FROM task_messages WHERE taskId = '${task.id}'`));
|
|
55
55
|
return messages.some((m) => m.messageType === 'plan') ? 'active' : 'planning';
|
|
56
56
|
}
|
|
57
57
|
/** Builtins the planner must not have: everything that mutates the workspace.
|
|
@@ -173,7 +173,7 @@ export async function runTaskHeartbeatTick(now) {
|
|
|
173
173
|
mountRoot = task.worktreePath;
|
|
174
174
|
}
|
|
175
175
|
else if (await isGitRepo(baseWorkingDir)) {
|
|
176
|
-
const wt = await ensureWorktree(baseWorkingDir, task.
|
|
176
|
+
const wt = await ensureWorktree(baseWorkingDir, task.id, task.title, task.branch);
|
|
177
177
|
task.branch = wt.branch;
|
|
178
178
|
task.worktreePath = wt.worktreePath;
|
|
179
179
|
await saveTask(task);
|
|
@@ -190,7 +190,7 @@ export async function runTaskHeartbeatTick(now) {
|
|
|
190
190
|
let dockerContainer;
|
|
191
191
|
let dockerHasGit = true;
|
|
192
192
|
if (dockerImage) {
|
|
193
|
-
const name = containerName(task.
|
|
193
|
+
const name = containerName(task.id);
|
|
194
194
|
// Also mount the git common dir so a linked worktree's gitdir resolves
|
|
195
195
|
// inside the container (identical-path). Only for git-worktree tasks.
|
|
196
196
|
const extraMounts = [];
|
|
@@ -341,7 +341,7 @@ export async function runTaskHeartbeatTick(now) {
|
|
|
341
341
|
}
|
|
342
342
|
};
|
|
343
343
|
// Load full history for replay
|
|
344
|
-
const historyMessages = (await runQuery(`SELECT * FROM task_messages WHERE taskId = ${task.id}`));
|
|
344
|
+
const historyMessages = (await runQuery(`SELECT * FROM task_messages WHERE taskId = '${task.id}'`));
|
|
345
345
|
historyMessages.sort((a, b) => new Date(a.createdAt).getTime() - new Date(b.createdAt).getTime());
|
|
346
346
|
// Map history to loop-compatible message records
|
|
347
347
|
const historyRecords = historyMessages
|
|
@@ -584,7 +584,7 @@ async function runReviewCycle(opts) {
|
|
|
584
584
|
// Finalize the agent's last work so the branch is complete before review.
|
|
585
585
|
await commitWip(task.worktreePath, task.title);
|
|
586
586
|
// Round is derived from the review-message stream, never a stored counter.
|
|
587
|
-
const priorReviews = (await runQuery(`SELECT * FROM task_messages WHERE taskId = ${task.id}`)).filter((m) => m.messageType === 'review').length;
|
|
587
|
+
const priorReviews = (await runQuery(`SELECT * FROM task_messages WHERE taskId = '${task.id}'`)).filter((m) => m.messageType === 'review').length;
|
|
588
588
|
const round = priorReviews + 1;
|
|
589
589
|
let verdict = 'pass';
|
|
590
590
|
let reviewText = '';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../../src/cli/web/server.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,OAAO,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../../src/cli/web/server.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,OAAO,MAAM,wBAAwB,CAAC;AA0ClD,OAAO,KAAK,EAAE,WAAW,EAAE,cAAc,EAAgC,MAAM,gBAAgB,CAAC;AAChG,OAAO,KAAK,EAAE,eAAe,EAA0B,MAAM,mBAAmB,CAAC;AAgBjF,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IAChC,UAAU,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IACnC,UAAU,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE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CAGd;AAED,wBAAsB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CA2nC3E"}
|
package/dist/cli/web/server.js
CHANGED
|
@@ -12,6 +12,7 @@ import { getDb, getTaskById, saveTask, createTask, addTaskMessage, deleteTask, r
|
|
|
12
12
|
import { discardWorktree, syncProjectRepo, projectRepoStatus, managedRepoDir } from '../../lib/task_git.js';
|
|
13
13
|
import { removeContainer } from '../../lib/docker.js';
|
|
14
14
|
import { validateRepositoryUrl } from '../../lib/repo_url.js';
|
|
15
|
+
import { validateProjectSlug, validateProjectIds } from '../../lib/project_slug.js';
|
|
15
16
|
import { runningTasks, abortRunningTask, syncingProjects } from './scheduler/locks.js';
|
|
16
17
|
import { registerTaskBridge, setTaskBridgeUrl } from './mcp_bridge.js';
|
|
17
18
|
import { loadAgents, loadConfig, dataDir, saveAgents, saveConfig, loadPlugins, loadMcpServers, } from '../../store/json.js';
|
|
@@ -235,13 +236,19 @@ export async function startServer(port, host) {
|
|
|
235
236
|
if (repoUrlError) {
|
|
236
237
|
return c.json({ error: repoUrlError }, 400);
|
|
237
238
|
}
|
|
239
|
+
const id = String(body.id || '').trim();
|
|
240
|
+
const slugError = validateProjectSlug(id);
|
|
241
|
+
if (slugError)
|
|
242
|
+
return c.json({ error: slugError }, 400);
|
|
238
243
|
const config = await loadConfig();
|
|
244
|
+
if ((config.projects || []).some((p) => p.id === id)) {
|
|
245
|
+
return c.json({ error: `Project id "${id}" already exists.` }, 400);
|
|
246
|
+
}
|
|
239
247
|
if (!config.projects) {
|
|
240
248
|
config.projects = [];
|
|
241
249
|
}
|
|
242
|
-
const nextId = config.projects.length > 0 ? Math.max(...config.projects.map((p) => p.id)) + 1 : 1;
|
|
243
250
|
const project = {
|
|
244
|
-
id
|
|
251
|
+
id,
|
|
245
252
|
name,
|
|
246
253
|
description: description || '',
|
|
247
254
|
workingDir,
|
|
@@ -272,23 +279,22 @@ export async function startServer(port, host) {
|
|
|
272
279
|
});
|
|
273
280
|
app.delete('/api/projects/:id', async (c) => {
|
|
274
281
|
try {
|
|
275
|
-
const id =
|
|
282
|
+
const id = c.req.param('id');
|
|
283
|
+
if (!/^[a-z0-9][a-z0-9-]*$/.test(id))
|
|
284
|
+
return c.json({ error: 'Invalid id' }, 400);
|
|
276
285
|
const config = await loadConfig();
|
|
277
286
|
const project = (config.projects || []).find((p) => p.id === id);
|
|
278
287
|
if (config.projects) {
|
|
279
288
|
config.projects = config.projects.filter((p) => p.id !== id);
|
|
280
289
|
await saveConfig(config);
|
|
281
290
|
}
|
|
282
|
-
//
|
|
283
|
-
// reuses the id — and with it ~/.caretaker/repos/<id>, which the new
|
|
284
|
-
// project would silently inherit (old code, old origin). Remove the
|
|
285
|
-
// managed clone; a user-chosen workingDir is never touched.
|
|
291
|
+
// Remove the managed clone; a user-chosen workingDir is never touched.
|
|
286
292
|
const managed = project ? managedRepoDir(project) : null;
|
|
287
293
|
if (managed)
|
|
288
294
|
await fs.promises.rm(managed, { recursive: true, force: true });
|
|
289
295
|
// Delete task messages first, then tasks — avoids orphaned message rows.
|
|
290
|
-
await runQuery(`DELETE FROM task_messages WHERE taskId IN (SELECT id FROM tasks WHERE projectId = ${id})`);
|
|
291
|
-
await runQuery(`DELETE FROM tasks WHERE projectId = ${id}`);
|
|
296
|
+
await runQuery(`DELETE FROM task_messages WHERE taskId IN (SELECT id FROM tasks WHERE projectId = '${id}')`);
|
|
297
|
+
await runQuery(`DELETE FROM tasks WHERE projectId = '${id}'`);
|
|
292
298
|
return c.json({ ok: true });
|
|
293
299
|
}
|
|
294
300
|
catch (err) {
|
|
@@ -299,7 +305,9 @@ export async function startServer(port, host) {
|
|
|
299
305
|
// ndjson (voice-backend pattern); failures travel in-band as an `error` line
|
|
300
306
|
// so URL/token problems are diagnosable from the UI.
|
|
301
307
|
app.post('/api/projects/:id/sync', async (c) => {
|
|
302
|
-
const id =
|
|
308
|
+
const id = c.req.param('id');
|
|
309
|
+
if (!/^[a-z0-9][a-z0-9-]*$/.test(id))
|
|
310
|
+
return c.json({ error: 'Invalid id' }, 400);
|
|
303
311
|
const config = await loadConfig();
|
|
304
312
|
const project = (config.projects || []).find((p) => p.id === id);
|
|
305
313
|
if (!project)
|
|
@@ -327,7 +335,9 @@ export async function startServer(port, host) {
|
|
|
327
335
|
});
|
|
328
336
|
// Derived repo state — disk + in-flight set at request time, nothing stored.
|
|
329
337
|
app.get('/api/projects/:id/repo-status', async (c) => {
|
|
330
|
-
const id =
|
|
338
|
+
const id = c.req.param('id');
|
|
339
|
+
if (!/^[a-z0-9][a-z0-9-]*$/.test(id))
|
|
340
|
+
return c.json({ error: 'Invalid id' }, 400);
|
|
331
341
|
const config = await loadConfig();
|
|
332
342
|
const project = (config.projects || []).find((p) => p.id === id);
|
|
333
343
|
if (!project)
|
|
@@ -340,10 +350,12 @@ export async function startServer(port, host) {
|
|
|
340
350
|
});
|
|
341
351
|
// Tasks REST endpoints
|
|
342
352
|
app.get('/api/projects/:id/tasks', async (c) => {
|
|
343
|
-
const id =
|
|
353
|
+
const id = c.req.param('id');
|
|
354
|
+
if (!/^[a-z0-9][a-z0-9-]*$/.test(id))
|
|
355
|
+
return c.json({ error: 'Invalid id' }, 400);
|
|
344
356
|
const includeArchived = c.req.query('archived') === 'true';
|
|
345
357
|
try {
|
|
346
|
-
const rows = (await runQuery(`SELECT * FROM tasks WHERE projectId = ${id}`));
|
|
358
|
+
const rows = (await runQuery(`SELECT * FROM tasks WHERE projectId = '${id}'`));
|
|
347
359
|
const filtered = includeArchived ? rows : rows.filter((t) => !t.archived);
|
|
348
360
|
return c.json(filtered);
|
|
349
361
|
}
|
|
@@ -352,7 +364,9 @@ export async function startServer(port, host) {
|
|
|
352
364
|
}
|
|
353
365
|
});
|
|
354
366
|
app.post('/api/projects/:id/tasks', async (c) => {
|
|
355
|
-
const projectId =
|
|
367
|
+
const projectId = c.req.param('id');
|
|
368
|
+
if (!/^[a-z0-9][a-z0-9-]*$/.test(projectId))
|
|
369
|
+
return c.json({ error: 'Invalid id' }, 400);
|
|
356
370
|
const body = await c.req.json();
|
|
357
371
|
const { title, objective, checklist, startActive, agentId, plannerAgentId, reviewerAgentId, planningEnabled, reviewEnabled, sddEnabled, maxRunSeconds } = body;
|
|
358
372
|
// Validate that the specified agents exist (if provided).
|
|
@@ -398,9 +412,11 @@ export async function startServer(port, host) {
|
|
|
398
412
|
return c.json({ ok: true });
|
|
399
413
|
});
|
|
400
414
|
app.get('/api/tasks/:id/messages', async (c) => {
|
|
401
|
-
const taskId =
|
|
415
|
+
const taskId = c.req.param('id');
|
|
416
|
+
if (!/^[a-z0-9][a-z0-9-]*$/.test(taskId))
|
|
417
|
+
return c.json([], 200);
|
|
402
418
|
try {
|
|
403
|
-
const rows = (await runQuery(`SELECT * FROM task_messages WHERE taskId = ${taskId}`));
|
|
419
|
+
const rows = (await runQuery(`SELECT * FROM task_messages WHERE taskId = '${taskId}'`));
|
|
404
420
|
rows.sort((a, b) => new Date(a.createdAt).getTime() - new Date(b.createdAt).getTime());
|
|
405
421
|
return c.json(rows);
|
|
406
422
|
}
|
|
@@ -409,7 +425,7 @@ export async function startServer(port, host) {
|
|
|
409
425
|
}
|
|
410
426
|
});
|
|
411
427
|
app.post('/api/tasks/:id/messages', async (c) => {
|
|
412
|
-
const taskId =
|
|
428
|
+
const taskId = c.req.param('id');
|
|
413
429
|
const body = await c.req.json();
|
|
414
430
|
const { content } = body;
|
|
415
431
|
await addTaskMessage({
|
|
@@ -432,7 +448,7 @@ export async function startServer(port, host) {
|
|
|
432
448
|
return c.json({ ok: true });
|
|
433
449
|
});
|
|
434
450
|
app.post('/api/tasks/:id/status', async (c) => {
|
|
435
|
-
const taskId =
|
|
451
|
+
const taskId = c.req.param('id');
|
|
436
452
|
const body = await c.req.json();
|
|
437
453
|
const { status } = body;
|
|
438
454
|
const task = await getTaskById(taskId);
|
|
@@ -456,7 +472,7 @@ export async function startServer(port, host) {
|
|
|
456
472
|
return c.json({ ok: true });
|
|
457
473
|
});
|
|
458
474
|
app.post('/api/tasks/:id/discard-worktree', async (c) => {
|
|
459
|
-
const taskId =
|
|
475
|
+
const taskId = c.req.param('id');
|
|
460
476
|
const task = await getTaskById(taskId);
|
|
461
477
|
if (!task)
|
|
462
478
|
return c.json({ ok: false, error: 'not found' }, 404);
|
|
@@ -492,7 +508,7 @@ export async function startServer(port, host) {
|
|
|
492
508
|
return c.json({ ok: true, branch: task.branch });
|
|
493
509
|
});
|
|
494
510
|
app.post('/api/tasks/:id/archive', async (c) => {
|
|
495
|
-
const taskId =
|
|
511
|
+
const taskId = c.req.param('id');
|
|
496
512
|
const task = await getTaskById(taskId);
|
|
497
513
|
if (!task)
|
|
498
514
|
return c.json({ ok: false, error: 'not found' }, 404);
|
|
@@ -511,7 +527,7 @@ export async function startServer(port, host) {
|
|
|
511
527
|
return c.json({ ok: true });
|
|
512
528
|
});
|
|
513
529
|
app.post('/api/tasks/:id/unarchive', async (c) => {
|
|
514
|
-
const taskId =
|
|
530
|
+
const taskId = c.req.param('id');
|
|
515
531
|
const task = await getTaskById(taskId);
|
|
516
532
|
if (!task)
|
|
517
533
|
return c.json({ ok: false, error: 'not found' }, 404);
|
|
@@ -527,7 +543,7 @@ export async function startServer(port, host) {
|
|
|
527
543
|
return c.json({ ok: true });
|
|
528
544
|
});
|
|
529
545
|
app.delete('/api/tasks/:id', async (c) => {
|
|
530
|
-
const taskId =
|
|
546
|
+
const taskId = c.req.param('id');
|
|
531
547
|
const task = await getTaskById(taskId);
|
|
532
548
|
if (!task)
|
|
533
549
|
return c.json({ ok: false, error: 'not found' }, 404);
|
|
@@ -573,7 +589,7 @@ export async function startServer(port, host) {
|
|
|
573
589
|
return c.json({ ok: true });
|
|
574
590
|
});
|
|
575
591
|
app.post('/api/tasks/:id/checklist-item', async (c) => {
|
|
576
|
-
const taskId =
|
|
592
|
+
const taskId = c.req.param('id');
|
|
577
593
|
const body = await c.req.json();
|
|
578
594
|
const { itemId, status: statusInput } = body;
|
|
579
595
|
const status = tryNormalizeChecklistStatus(statusInput);
|
|
@@ -589,7 +605,7 @@ export async function startServer(port, host) {
|
|
|
589
605
|
return c.json({ ok: true });
|
|
590
606
|
});
|
|
591
607
|
app.patch('/api/tasks/:id/agent', async (c) => {
|
|
592
|
-
const taskId =
|
|
608
|
+
const taskId = c.req.param('id');
|
|
593
609
|
const body = await c.req.json();
|
|
594
610
|
const { agentId, role } = body;
|
|
595
611
|
const task = await getTaskById(taskId);
|
|
@@ -619,7 +635,7 @@ export async function startServer(port, host) {
|
|
|
619
635
|
return c.json({ ok: true, role: targetRole, agentId: agentId || null });
|
|
620
636
|
});
|
|
621
637
|
app.patch('/api/tasks/:id/flags', async (c) => {
|
|
622
|
-
const taskId =
|
|
638
|
+
const taskId = c.req.param('id');
|
|
623
639
|
const body = await c.req.json();
|
|
624
640
|
const task = await getTaskById(taskId);
|
|
625
641
|
if (!task)
|
|
@@ -650,7 +666,7 @@ export async function startServer(port, host) {
|
|
|
650
666
|
// guard (unlike …/agent): the objective is read at the start of each cycle, so
|
|
651
667
|
// an edit simply lands on the next one — no reason to force a pause for a typo.
|
|
652
668
|
app.patch('/api/tasks/:id', async (c) => {
|
|
653
|
-
const taskId =
|
|
669
|
+
const taskId = c.req.param('id');
|
|
654
670
|
const body = await c.req.json();
|
|
655
671
|
const hasTitle = 'title' in body;
|
|
656
672
|
const hasObjective = 'objective' in body;
|
|
@@ -1010,6 +1026,25 @@ export async function startServer(port, host) {
|
|
|
1010
1026
|
return;
|
|
1011
1027
|
case 'saveConfig':
|
|
1012
1028
|
try {
|
|
1029
|
+
const idError = validateProjectIds(msg.config.projects || []);
|
|
1030
|
+
if (idError) {
|
|
1031
|
+
post({ type: 'error', message: idError });
|
|
1032
|
+
return;
|
|
1033
|
+
}
|
|
1034
|
+
// A project that still has tasks must be deleted through DELETE /api/projects/:id
|
|
1035
|
+
// (which removes tasks, worktrees and the managed clone) — not silently dropped
|
|
1036
|
+
// from a config save. Also blocks id "renames", which arrive as drop+add.
|
|
1037
|
+
const prev = await loadConfig();
|
|
1038
|
+
const incomingIds = new Set((msg.config.projects || []).map((p) => p.id));
|
|
1039
|
+
for (const old of prev.projects || []) {
|
|
1040
|
+
if (incomingIds.has(old.id))
|
|
1041
|
+
continue;
|
|
1042
|
+
const remaining = (await runQuery(`SELECT * FROM tasks WHERE projectId = '${old.id}'`));
|
|
1043
|
+
if (remaining.length > 0) {
|
|
1044
|
+
post({ type: 'error', message: `Project "${old.name}" still has ${remaining.length} task(s) — delete it from the Projects panel instead.` });
|
|
1045
|
+
return;
|
|
1046
|
+
}
|
|
1047
|
+
}
|
|
1013
1048
|
// The settings form saves the whole config through here, so this
|
|
1014
1049
|
// — not POST /api/projects — is the write path that actually
|
|
1015
1050
|
// needs to enforce the repository-URL rules.
|
|
@@ -17,19 +17,19 @@ export const getTaskStateTool = {
|
|
|
17
17
|
parameters: {
|
|
18
18
|
type: 'object',
|
|
19
19
|
properties: {
|
|
20
|
-
task_id: { type: '
|
|
20
|
+
task_id: { type: 'string' },
|
|
21
21
|
},
|
|
22
22
|
required: ['task_id'],
|
|
23
23
|
},
|
|
24
24
|
execute: async (args) => {
|
|
25
25
|
const db = getDb();
|
|
26
|
-
const taskId =
|
|
26
|
+
const taskId = String(args.task_id);
|
|
27
27
|
const task = await getTaskById(taskId);
|
|
28
28
|
if (!task)
|
|
29
29
|
return err(`Task ${taskId} not found`);
|
|
30
30
|
const config = await loadConfig();
|
|
31
31
|
const project = (config.projects || []).find((p) => p.id === task.projectId) || null;
|
|
32
|
-
const messages = (await db.query(`SELECT * FROM task_messages WHERE taskId = ${taskId}`));
|
|
32
|
+
const messages = (await db.query(`SELECT * FROM task_messages WHERE taskId = '${taskId}'`));
|
|
33
33
|
messages.sort((a, b) => new Date(a.createdAt).getTime() - new Date(b.createdAt).getTime());
|
|
34
34
|
return {
|
|
35
35
|
content: JSON.stringify({
|
|
@@ -66,7 +66,7 @@ export const updateChecklistItemTool = {
|
|
|
66
66
|
parameters: {
|
|
67
67
|
type: 'object',
|
|
68
68
|
properties: {
|
|
69
|
-
task_id: { type: '
|
|
69
|
+
task_id: { type: 'string' },
|
|
70
70
|
item_id: { type: 'string' },
|
|
71
71
|
status: { type: 'string', enum: ['pending', 'in_progress', 'done', 'skipped'] },
|
|
72
72
|
},
|
|
@@ -74,7 +74,7 @@ export const updateChecklistItemTool = {
|
|
|
74
74
|
},
|
|
75
75
|
execute: async (args) => {
|
|
76
76
|
const db = getDb();
|
|
77
|
-
const taskId =
|
|
77
|
+
const taskId = String(args.task_id);
|
|
78
78
|
const itemId = String(args.item_id);
|
|
79
79
|
const statusInput = args.status;
|
|
80
80
|
const status = tryNormalizeChecklistStatus(statusInput);
|
|
@@ -97,7 +97,7 @@ export const updateChecklistTool = {
|
|
|
97
97
|
parameters: {
|
|
98
98
|
type: 'object',
|
|
99
99
|
properties: {
|
|
100
|
-
task_id: { type: '
|
|
100
|
+
task_id: { type: 'string' },
|
|
101
101
|
checklist: {
|
|
102
102
|
type: 'array',
|
|
103
103
|
items: {
|
|
@@ -115,7 +115,7 @@ export const updateChecklistTool = {
|
|
|
115
115
|
},
|
|
116
116
|
execute: async (args) => {
|
|
117
117
|
const db = getDb();
|
|
118
|
-
const taskId =
|
|
118
|
+
const taskId = String(args.task_id);
|
|
119
119
|
const checklistInput = args.checklist;
|
|
120
120
|
const task = await getTaskById(taskId);
|
|
121
121
|
if (!task)
|
|
@@ -146,14 +146,14 @@ export const taskUpdateDetailsTool = {
|
|
|
146
146
|
parameters: {
|
|
147
147
|
type: 'object',
|
|
148
148
|
properties: {
|
|
149
|
-
task_id: { type: '
|
|
149
|
+
task_id: { type: 'string' },
|
|
150
150
|
title: { type: 'string' },
|
|
151
151
|
objective: { type: 'string' },
|
|
152
152
|
},
|
|
153
153
|
required: ['task_id'],
|
|
154
154
|
},
|
|
155
155
|
execute: async (args) => {
|
|
156
|
-
const taskId =
|
|
156
|
+
const taskId = String(args.task_id);
|
|
157
157
|
const hasTitle = args.title !== undefined;
|
|
158
158
|
const hasObjective = args.objective !== undefined;
|
|
159
159
|
if (!hasTitle && !hasObjective)
|
|
@@ -214,14 +214,14 @@ export const addMessageTool = {
|
|
|
214
214
|
parameters: {
|
|
215
215
|
type: 'object',
|
|
216
216
|
properties: {
|
|
217
|
-
task_id: { type: '
|
|
217
|
+
task_id: { type: 'string' },
|
|
218
218
|
content: { type: 'string' },
|
|
219
219
|
},
|
|
220
220
|
required: ['task_id', 'content'],
|
|
221
221
|
},
|
|
222
222
|
execute: async (args) => {
|
|
223
223
|
const db = getDb();
|
|
224
|
-
const taskId =
|
|
224
|
+
const taskId = String(args.task_id);
|
|
225
225
|
const content = String(args.content);
|
|
226
226
|
await addTaskMessage({
|
|
227
227
|
taskId,
|
|
@@ -245,14 +245,14 @@ export const completeTaskTool = {
|
|
|
245
245
|
parameters: {
|
|
246
246
|
type: 'object',
|
|
247
247
|
properties: {
|
|
248
|
-
task_id: { type: '
|
|
248
|
+
task_id: { type: 'string' },
|
|
249
249
|
summary: { type: 'string' },
|
|
250
250
|
},
|
|
251
251
|
required: ['task_id'],
|
|
252
252
|
},
|
|
253
253
|
execute: async (args) => {
|
|
254
254
|
const db = getDb();
|
|
255
|
-
const taskId =
|
|
255
|
+
const taskId = String(args.task_id);
|
|
256
256
|
const summary = args.summary ? String(args.summary) : '';
|
|
257
257
|
const task = await getTaskById(taskId);
|
|
258
258
|
if (!task)
|
|
@@ -287,14 +287,14 @@ export const blockTaskTool = {
|
|
|
287
287
|
parameters: {
|
|
288
288
|
type: 'object',
|
|
289
289
|
properties: {
|
|
290
|
-
task_id: { type: '
|
|
290
|
+
task_id: { type: 'string' },
|
|
291
291
|
reason: { type: 'string' },
|
|
292
292
|
},
|
|
293
293
|
required: ['task_id', 'reason'],
|
|
294
294
|
},
|
|
295
295
|
execute: async (args) => {
|
|
296
296
|
const db = getDb();
|
|
297
|
-
const taskId =
|
|
297
|
+
const taskId = String(args.task_id);
|
|
298
298
|
const reason = String(args.reason);
|
|
299
299
|
const task = await getTaskById(taskId);
|
|
300
300
|
if (!task)
|
|
@@ -320,14 +320,14 @@ export const yieldTaskTool = {
|
|
|
320
320
|
parameters: {
|
|
321
321
|
type: 'object',
|
|
322
322
|
properties: {
|
|
323
|
-
task_id: { type: '
|
|
323
|
+
task_id: { type: 'string' },
|
|
324
324
|
notes: { type: 'string' },
|
|
325
325
|
},
|
|
326
326
|
required: ['task_id'],
|
|
327
327
|
},
|
|
328
328
|
execute: async (args) => {
|
|
329
329
|
const db = getDb();
|
|
330
|
-
const taskId =
|
|
330
|
+
const taskId = String(args.task_id);
|
|
331
331
|
const notes = args.notes ? String(args.notes) : '';
|
|
332
332
|
const task = await getTaskById(taskId);
|
|
333
333
|
if (!task)
|
|
@@ -380,7 +380,7 @@ export const taskCreateTool = {
|
|
|
380
380
|
parameters: {
|
|
381
381
|
type: 'object',
|
|
382
382
|
properties: {
|
|
383
|
-
project_id: { type: '
|
|
383
|
+
project_id: { type: 'string' },
|
|
384
384
|
title: { type: 'string' },
|
|
385
385
|
objective: { type: 'string' },
|
|
386
386
|
checklist: {
|
|
@@ -402,7 +402,7 @@ export const taskCreateTool = {
|
|
|
402
402
|
},
|
|
403
403
|
execute: async (args) => {
|
|
404
404
|
const db = getDb();
|
|
405
|
-
const projectId =
|
|
405
|
+
const projectId = String(args.project_id);
|
|
406
406
|
const title = String(args.title);
|
|
407
407
|
const objective = String(args.objective);
|
|
408
408
|
const checklistInput = args.checklist;
|
|
@@ -496,14 +496,14 @@ export const taskUnblockTool = {
|
|
|
496
496
|
parameters: {
|
|
497
497
|
type: 'object',
|
|
498
498
|
properties: {
|
|
499
|
-
task_id: { type: '
|
|
499
|
+
task_id: { type: 'string' },
|
|
500
500
|
message: { type: 'string' },
|
|
501
501
|
},
|
|
502
502
|
required: ['task_id'],
|
|
503
503
|
},
|
|
504
504
|
execute: async (args) => {
|
|
505
505
|
const db = getDb();
|
|
506
|
-
const taskId =
|
|
506
|
+
const taskId = String(args.task_id);
|
|
507
507
|
const message = args.message ? String(args.message) : '';
|
|
508
508
|
const task = await getTaskById(taskId);
|
|
509
509
|
if (!task)
|
|
@@ -533,13 +533,13 @@ export const taskActivateTool = {
|
|
|
533
533
|
parameters: {
|
|
534
534
|
type: 'object',
|
|
535
535
|
properties: {
|
|
536
|
-
task_id: { type: '
|
|
536
|
+
task_id: { type: 'string' },
|
|
537
537
|
},
|
|
538
538
|
required: ['task_id'],
|
|
539
539
|
},
|
|
540
540
|
execute: async (args) => {
|
|
541
541
|
const db = getDb();
|
|
542
|
-
const taskId =
|
|
542
|
+
const taskId = String(args.task_id);
|
|
543
543
|
const task = await getTaskById(taskId);
|
|
544
544
|
if (!task)
|
|
545
545
|
return err(`Task ${taskId} not found`);
|
|
@@ -566,14 +566,14 @@ export const taskUnpauseTool = {
|
|
|
566
566
|
parameters: {
|
|
567
567
|
type: 'object',
|
|
568
568
|
properties: {
|
|
569
|
-
task_id: { type: '
|
|
569
|
+
task_id: { type: 'string' },
|
|
570
570
|
message: { type: 'string' },
|
|
571
571
|
},
|
|
572
572
|
required: ['task_id'],
|
|
573
573
|
},
|
|
574
574
|
execute: async (args) => {
|
|
575
575
|
const db = getDb();
|
|
576
|
-
const taskId =
|
|
576
|
+
const taskId = String(args.task_id);
|
|
577
577
|
const message = args.message ? String(args.message) : '';
|
|
578
578
|
const task = await getTaskById(taskId);
|
|
579
579
|
if (!task)
|
|
@@ -603,12 +603,12 @@ export const taskDiscardWorktreeTool = {
|
|
|
603
603
|
parameters: {
|
|
604
604
|
type: 'object',
|
|
605
605
|
properties: {
|
|
606
|
-
task_id: { type: '
|
|
606
|
+
task_id: { type: 'string' },
|
|
607
607
|
},
|
|
608
608
|
required: ['task_id'],
|
|
609
609
|
},
|
|
610
610
|
execute: async (args) => {
|
|
611
|
-
const taskId =
|
|
611
|
+
const taskId = String(args.task_id);
|
|
612
612
|
const task = await getTaskById(taskId);
|
|
613
613
|
if (!task)
|
|
614
614
|
return err(`Task ${taskId} not found`);
|
|
@@ -646,12 +646,12 @@ export const taskArchiveTool = {
|
|
|
646
646
|
parameters: {
|
|
647
647
|
type: 'object',
|
|
648
648
|
properties: {
|
|
649
|
-
task_id: { type: '
|
|
649
|
+
task_id: { type: 'string' },
|
|
650
650
|
},
|
|
651
651
|
required: ['task_id'],
|
|
652
652
|
},
|
|
653
653
|
execute: async (args) => {
|
|
654
|
-
const taskId =
|
|
654
|
+
const taskId = String(args.task_id);
|
|
655
655
|
const task = await getTaskById(taskId);
|
|
656
656
|
if (!task)
|
|
657
657
|
return err(`Task ${taskId} not found`);
|
|
@@ -678,12 +678,12 @@ export const taskUnarchiveTool = {
|
|
|
678
678
|
parameters: {
|
|
679
679
|
type: 'object',
|
|
680
680
|
properties: {
|
|
681
|
-
task_id: { type: '
|
|
681
|
+
task_id: { type: 'string' },
|
|
682
682
|
},
|
|
683
683
|
required: ['task_id'],
|
|
684
684
|
},
|
|
685
685
|
execute: async (args) => {
|
|
686
|
-
const taskId =
|
|
686
|
+
const taskId = String(args.task_id);
|
|
687
687
|
const task = await getTaskById(taskId);
|
|
688
688
|
if (!task)
|
|
689
689
|
return err(`Task ${taskId} not found`);
|
|
@@ -706,12 +706,12 @@ export const taskDeleteTool = {
|
|
|
706
706
|
parameters: {
|
|
707
707
|
type: 'object',
|
|
708
708
|
properties: {
|
|
709
|
-
task_id: { type: '
|
|
709
|
+
task_id: { type: 'string' },
|
|
710
710
|
},
|
|
711
711
|
required: ['task_id'],
|
|
712
712
|
},
|
|
713
713
|
execute: async (args) => {
|
|
714
|
-
const taskId =
|
|
714
|
+
const taskId = String(args.task_id);
|
|
715
715
|
const task = await getTaskById(taskId);
|
|
716
716
|
if (!task)
|
|
717
717
|
return err(`Task ${taskId} not found`);
|
|
@@ -764,7 +764,7 @@ export const taskSetAgentTool = {
|
|
|
764
764
|
parameters: {
|
|
765
765
|
type: 'object',
|
|
766
766
|
properties: {
|
|
767
|
-
task_id: { type: '
|
|
767
|
+
task_id: { type: 'string' },
|
|
768
768
|
agent_id: { type: 'string', description: 'The agent ID to assign, or null to clear the override.' },
|
|
769
769
|
role: {
|
|
770
770
|
type: 'string',
|
|
@@ -775,7 +775,7 @@ export const taskSetAgentTool = {
|
|
|
775
775
|
required: ['task_id'],
|
|
776
776
|
},
|
|
777
777
|
execute: async (args) => {
|
|
778
|
-
const taskId =
|
|
778
|
+
const taskId = String(args.task_id);
|
|
779
779
|
const agentId = args.agent_id != null ? String(args.agent_id) : null;
|
|
780
780
|
const role = args.role === 'planner' || args.role === 'reviewer' ? args.role : 'developer';
|
|
781
781
|
const task = await getTaskById(taskId);
|
|
@@ -810,13 +810,13 @@ export const submitPlanTool = {
|
|
|
810
810
|
parameters: {
|
|
811
811
|
type: 'object',
|
|
812
812
|
properties: {
|
|
813
|
-
task_id: { type: '
|
|
813
|
+
task_id: { type: 'string' },
|
|
814
814
|
plan: { type: 'string', description: 'The full implementation plan, markdown.' },
|
|
815
815
|
},
|
|
816
816
|
required: ['task_id', 'plan'],
|
|
817
817
|
},
|
|
818
818
|
execute: async (args) => {
|
|
819
|
-
const taskId =
|
|
819
|
+
const taskId = String(args.task_id);
|
|
820
820
|
const plan = String(args.plan ?? '').trim();
|
|
821
821
|
if (!plan)
|
|
822
822
|
return err('Plan must not be empty.');
|
package/dist/lib/docker.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/** Deterministic container name for a task — the caller's naming policy. */
|
|
2
|
-
export declare function containerName(
|
|
2
|
+
export declare function containerName(taskId: string): string;
|
|
3
3
|
/** `docker run` argv. Mount is identical-path (`-v <root>:<root>`) so host and
|
|
4
4
|
* container agree on absolute paths. `--user` keeps written files owned by the
|
|
5
5
|
* host user (else root-owned files break the host WIP commit / review diff).
|
package/dist/lib/docker.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"docker.d.ts","sourceRoot":"","sources":["../../src/lib/docker.ts"],"names":[],"mappings":"AASA,4EAA4E;AAC5E,wBAAgB,a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Ae,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAEjE;AAED,6DAA6D;AAC7D,wBAAsB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAErE;AAED;;qFAEqF;AACrF,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAEvD;AAED;;2DAE2D;AAC3D,wBAAsB,UAAU,CAC9B,cAAc,EAAE,MAAM,EACtB,UAAU,EAAE,MAAM,EAClB,GAAG,EAAE,MAAM,GACV,OAAO,CAAC,IAAI,CAAC,CAWf;AAKD,eAAO,MAAM,uBAAuB,ojBAYnC,CAAC;AAEF,wBAAgB,oBAAoB,CAClC,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,MAAM,EACf,cAAc,EAAE,MAAM,GACrB,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAWzB;AAED;;;;;;wFAMwF;AACxF,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,EAAE,CAY5D"}
|
package/dist/lib/docker.js
CHANGED
|
@@ -6,8 +6,8 @@ import { promisify } from 'node:util';
|
|
|
6
6
|
import { commandEnv } from '../harness/tools/builtin/shell-env.js';
|
|
7
7
|
const exec = promisify(execFile);
|
|
8
8
|
/** Deterministic container name for a task — the caller's naming policy. */
|
|
9
|
-
export function containerName(
|
|
10
|
-
return `caretaker-task-${
|
|
9
|
+
export function containerName(taskId) {
|
|
10
|
+
return `caretaker-task-${taskId}`;
|
|
11
11
|
}
|
|
12
12
|
/** `docker run` argv. Mount is identical-path (`-v <root>:<root>`) so host and
|
|
13
13
|
* container agree on absolute paths. `--user` keeps written files owned by the
|