@hasna/todos 0.11.82 → 0.11.83
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/cloud-router.d.ts +65 -1
- package/dist/cli/cloud-router.d.ts.map +1 -1
- package/dist/cli/commands/agent-commands.d.ts.map +1 -1
- package/dist/cli/commands/mcp-hooks-commands.d.ts.map +1 -1
- package/dist/cli/commands/project-commands.d.ts.map +1 -1
- package/dist/cli/commands/task-commands.d.ts.map +1 -1
- package/dist/cli/index.js +353 -25
- package/dist/index.js +113 -4
- package/dist/mcp/index.js +234 -5
- package/dist/mcp/tools/agents.d.ts.map +1 -1
- package/dist/release-provenance.json +3 -3
- package/dist/server/index.js +252 -23
- package/dist/server/v1.d.ts.map +1 -1
- package/dist/storage/interfaces.d.ts +52 -1
- package/dist/storage/interfaces.d.ts.map +1 -1
- package/dist/storage/postgres-adapter.d.ts.map +1 -1
- package/dist/storage.js +110 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -23525,7 +23525,18 @@ function createPostgresTodosStorageAdapter(options) {
|
|
|
23525
23525
|
claimNext: (agentId, filters) => claimNextTask2(agentId, filters, store),
|
|
23526
23526
|
getNext: (_agentId, filters) => getNextTask2(filters, store),
|
|
23527
23527
|
getActiveWork: (filters) => getActiveWork2(filters, store),
|
|
23528
|
-
getChangedSince: (since, filters) => getChangedSince(since, filters, store)
|
|
23528
|
+
getChangedSince: (since, filters) => getChangedSince(since, filters, store),
|
|
23529
|
+
lock: (id, agentId) => lockTask2(id, agentId, store),
|
|
23530
|
+
unlock: (id, agentId) => unlockTask2(id, agentId, store)
|
|
23531
|
+
},
|
|
23532
|
+
dependencies: {
|
|
23533
|
+
add: (taskId, dependsOn, context) => addDependency2(taskId, dependsOn, store, context),
|
|
23534
|
+
remove: (taskId, dependsOn) => removeDependency2(taskId, dependsOn, store),
|
|
23535
|
+
list: (taskId) => listDependencies(taskId, store)
|
|
23536
|
+
},
|
|
23537
|
+
verifications: {
|
|
23538
|
+
add: (input, context) => addVerification(input, store, context),
|
|
23539
|
+
list: (taskId) => listVerifications(taskId, store)
|
|
23529
23540
|
},
|
|
23530
23541
|
projects: {
|
|
23531
23542
|
create: (input, context) => createProject2(input, store, context),
|
|
@@ -23980,6 +23991,104 @@ async function patchTask(task2, patch, store) {
|
|
|
23980
23991
|
await store.upsert("tasks", updated);
|
|
23981
23992
|
return updated;
|
|
23982
23993
|
}
|
|
23994
|
+
var CLOUD_LOCK_EXPIRY_MINUTES = 30;
|
|
23995
|
+
function cloudLockExpired(lockedAt) {
|
|
23996
|
+
if (!lockedAt)
|
|
23997
|
+
return true;
|
|
23998
|
+
return new Date(lockedAt).getTime() + CLOUD_LOCK_EXPIRY_MINUTES * 60 * 1000 < Date.now();
|
|
23999
|
+
}
|
|
24000
|
+
function cloudLockExpiresAt(lockedAt) {
|
|
24001
|
+
return new Date(new Date(lockedAt).getTime() + CLOUD_LOCK_EXPIRY_MINUTES * 60 * 1000).toISOString();
|
|
24002
|
+
}
|
|
24003
|
+
async function lockTask2(id, agentId, store) {
|
|
24004
|
+
const task2 = await requireRecord("tasks", id, store);
|
|
24005
|
+
if (task2.status === "completed" || task2.status === "cancelled") {
|
|
24006
|
+
return { success: false, error: `Task is ${task2.status} and cannot be locked` };
|
|
24007
|
+
}
|
|
24008
|
+
if (task2.locked_by && task2.locked_by !== agentId && !cloudLockExpired(task2.locked_at)) {
|
|
24009
|
+
return { success: false, locked_by: task2.locked_by, locked_at: task2.locked_at ?? undefined, error: `Task is locked by ${task2.locked_by}` };
|
|
24010
|
+
}
|
|
24011
|
+
const timestamp2 = new Date().toISOString();
|
|
24012
|
+
await patchTask(task2, { locked_by: agentId, locked_at: timestamp2 }, store);
|
|
24013
|
+
return { success: true, locked_by: agentId, locked_at: timestamp2, expires_at: cloudLockExpiresAt(timestamp2) };
|
|
24014
|
+
}
|
|
24015
|
+
async function unlockTask2(id, agentId, store) {
|
|
24016
|
+
const task2 = await requireRecord("tasks", id, store);
|
|
24017
|
+
if (agentId && task2.locked_by && task2.locked_by !== agentId) {
|
|
24018
|
+
throw new Error(`Task ${id} is locked by ${task2.locked_by}, not ${agentId}`);
|
|
24019
|
+
}
|
|
24020
|
+
await patchTask(task2, { locked_by: null, locked_at: null }, store);
|
|
24021
|
+
return true;
|
|
24022
|
+
}
|
|
24023
|
+
function dependencyId(taskId, dependsOn) {
|
|
24024
|
+
return `${taskId}::${dependsOn}`;
|
|
24025
|
+
}
|
|
24026
|
+
async function addDependency2(taskId, dependsOn, store, context) {
|
|
24027
|
+
if (taskId === dependsOn)
|
|
24028
|
+
throw new Error("A task cannot depend on itself");
|
|
24029
|
+
if (!await store.get("tasks", taskId))
|
|
24030
|
+
throw new Error(`Task not found: ${taskId}`);
|
|
24031
|
+
if (!await store.get("tasks", dependsOn))
|
|
24032
|
+
throw new Error(`Task not found: ${dependsOn}`);
|
|
24033
|
+
const edges = await store.list("dependencies");
|
|
24034
|
+
const adjacency = new Map;
|
|
24035
|
+
for (const edge of edges) {
|
|
24036
|
+
if (!adjacency.has(edge.task_id))
|
|
24037
|
+
adjacency.set(edge.task_id, []);
|
|
24038
|
+
adjacency.get(edge.task_id).push(edge.depends_on);
|
|
24039
|
+
}
|
|
24040
|
+
const queue = [dependsOn];
|
|
24041
|
+
const seen = new Set;
|
|
24042
|
+
while (queue.length) {
|
|
24043
|
+
const node = queue.shift();
|
|
24044
|
+
if (node === taskId)
|
|
24045
|
+
throw new Error(`Adding dependency ${taskId} -> ${dependsOn} would create a cycle`);
|
|
24046
|
+
if (seen.has(node))
|
|
24047
|
+
continue;
|
|
24048
|
+
seen.add(node);
|
|
24049
|
+
for (const next of adjacency.get(node) ?? [])
|
|
24050
|
+
queue.push(next);
|
|
24051
|
+
}
|
|
24052
|
+
const timestamp2 = new Date().toISOString();
|
|
24053
|
+
const record = { id: dependencyId(taskId, dependsOn), task_id: taskId, depends_on: dependsOn, created_at: timestamp2, updated_at: timestamp2 };
|
|
24054
|
+
await store.upsert("dependencies", record, context);
|
|
24055
|
+
return { task_id: taskId, depends_on: dependsOn };
|
|
24056
|
+
}
|
|
24057
|
+
async function removeDependency2(taskId, dependsOn, store) {
|
|
24058
|
+
const existing = await store.get("dependencies", dependencyId(taskId, dependsOn));
|
|
24059
|
+
if (!existing)
|
|
24060
|
+
return false;
|
|
24061
|
+
await store.delete("dependencies", dependencyId(taskId, dependsOn));
|
|
24062
|
+
return true;
|
|
24063
|
+
}
|
|
24064
|
+
async function listDependencies(taskId, store) {
|
|
24065
|
+
const edges = await store.list("dependencies");
|
|
24066
|
+
return {
|
|
24067
|
+
dependencies: edges.filter((edge) => edge.task_id === taskId).map((edge) => ({ task_id: edge.task_id, depends_on: edge.depends_on })),
|
|
24068
|
+
blocked_by: edges.filter((edge) => edge.depends_on === taskId).map((edge) => ({ task_id: edge.task_id, depends_on: edge.depends_on }))
|
|
24069
|
+
};
|
|
24070
|
+
}
|
|
24071
|
+
async function addVerification(input, store, context) {
|
|
24072
|
+
if (!await store.get("tasks", input.task_id))
|
|
24073
|
+
throw new Error(`Task not found: ${input.task_id}`);
|
|
24074
|
+
const timestamp2 = new Date().toISOString();
|
|
24075
|
+
const verification = {
|
|
24076
|
+
id: randomUUID3(),
|
|
24077
|
+
task_id: input.task_id,
|
|
24078
|
+
command: input.command,
|
|
24079
|
+
status: input.status ?? "unknown",
|
|
24080
|
+
output_summary: input.output_summary ?? null,
|
|
24081
|
+
artifact_path: input.artifact_path ?? null,
|
|
24082
|
+
agent_id: input.agent_id ?? context?.agentId ?? null,
|
|
24083
|
+
run_at: timestamp2,
|
|
24084
|
+
created_at: timestamp2
|
|
24085
|
+
};
|
|
24086
|
+
await store.upsert("verifications", { ...verification, updated_at: timestamp2 }, context);
|
|
24087
|
+
return verification;
|
|
24088
|
+
}
|
|
24089
|
+
async function listVerifications(taskId, store) {
|
|
24090
|
+
return (await store.list("verifications")).filter((verification) => verification.task_id === taskId).sort((a, b) => b.run_at.localeCompare(a.run_at));
|
|
24091
|
+
}
|
|
23983
24092
|
var TASK_ORDER_BY = "ORDER BY CASE payload->>'priority' WHEN 'critical' THEN 0 WHEN 'high' THEN 1 WHEN 'medium' THEN 2 WHEN 'low' THEN 3 ELSE 4 END ASC, payload->>'created_at' ASC, payload->>'id' ASC";
|
|
23984
24093
|
function toFilterArray(value) {
|
|
23985
24094
|
return Array.isArray(value) ? value : [value];
|
|
@@ -31783,13 +31892,13 @@ function importTodosMarkdown(markdown, options = {}, db) {
|
|
|
31783
31892
|
if (!taskId)
|
|
31784
31893
|
continue;
|
|
31785
31894
|
for (const dependencyTitle of item.depends_on_titles) {
|
|
31786
|
-
const
|
|
31787
|
-
if (!
|
|
31895
|
+
const dependencyId2 = taskByTitle.get(dependencyTitle);
|
|
31896
|
+
if (!dependencyId2) {
|
|
31788
31897
|
skipped.task_dependencies++;
|
|
31789
31898
|
issues.push(`missing dependency task: ${dependencyTitle}`);
|
|
31790
31899
|
continue;
|
|
31791
31900
|
}
|
|
31792
|
-
addDependency(taskId,
|
|
31901
|
+
addDependency(taskId, dependencyId2, d);
|
|
31793
31902
|
inserted.task_dependencies++;
|
|
31794
31903
|
}
|
|
31795
31904
|
}
|
package/dist/mcp/index.js
CHANGED
|
@@ -22863,6 +22863,13 @@ async function cloudCountTasks(client, filter = {}) {
|
|
|
22863
22863
|
const tasks = await cloudListTasks(client, rest);
|
|
22864
22864
|
return tasks.length;
|
|
22865
22865
|
}
|
|
22866
|
+
async function cloudRegisterAgent(client, input) {
|
|
22867
|
+
const raw = await client.transport.post("/agents", input);
|
|
22868
|
+
if (raw && typeof raw === "object" && "agent" in raw) {
|
|
22869
|
+
return raw.agent;
|
|
22870
|
+
}
|
|
22871
|
+
return raw;
|
|
22872
|
+
}
|
|
22866
22873
|
var _cache;
|
|
22867
22874
|
var init_cloud_router = __esm(() => {
|
|
22868
22875
|
init_storage();
|
|
@@ -44195,6 +44202,33 @@ function registerAgentTools(server, { shouldRegisterTool, resolveId, formatError
|
|
|
44195
44202
|
force: exports_external.boolean().optional().describe("Force takeover of an active agent's name. Use with caution \u2014 only when you know the previous session is dead.")
|
|
44196
44203
|
}, async ({ name, description, role, title, level, permissions, capabilities, session_id, working_dir, force }) => {
|
|
44197
44204
|
try {
|
|
44205
|
+
const cloud = getTodosCloudClient();
|
|
44206
|
+
if (cloud) {
|
|
44207
|
+
const agent2 = await cloudRegisterAgent(cloud, {
|
|
44208
|
+
name,
|
|
44209
|
+
description,
|
|
44210
|
+
role,
|
|
44211
|
+
title,
|
|
44212
|
+
level,
|
|
44213
|
+
permissions,
|
|
44214
|
+
capabilities,
|
|
44215
|
+
session_id,
|
|
44216
|
+
working_dir,
|
|
44217
|
+
force
|
|
44218
|
+
});
|
|
44219
|
+
return {
|
|
44220
|
+
content: [{
|
|
44221
|
+
type: "text",
|
|
44222
|
+
text: `Agent registered:
|
|
44223
|
+
ID: ${agent2.id}
|
|
44224
|
+
Name: ${agent2.name}${agent2.description ? `
|
|
44225
|
+
Description: ${agent2.description}` : ""}
|
|
44226
|
+
Session: ${agent2.session_id ?? "unbound"}
|
|
44227
|
+
Created: ${agent2.created_at}
|
|
44228
|
+
Last seen: ${agent2.last_seen_at}`
|
|
44229
|
+
}]
|
|
44230
|
+
};
|
|
44231
|
+
}
|
|
44198
44232
|
const pool = getAgentPoolForProject(working_dir);
|
|
44199
44233
|
const result = registerAgent({ name, description, role, title, level, permissions, capabilities, session_id, working_dir, force, pool: pool || undefined });
|
|
44200
44234
|
if (isAgentConflict(result)) {
|
|
@@ -48094,7 +48128,18 @@ function createPostgresTodosStorageAdapter(options) {
|
|
|
48094
48128
|
claimNext: (agentId, filters) => claimNextTask2(agentId, filters, store),
|
|
48095
48129
|
getNext: (_agentId, filters) => getNextTask2(filters, store),
|
|
48096
48130
|
getActiveWork: (filters) => getActiveWork2(filters, store),
|
|
48097
|
-
getChangedSince: (since, filters) => getChangedSince(since, filters, store)
|
|
48131
|
+
getChangedSince: (since, filters) => getChangedSince(since, filters, store),
|
|
48132
|
+
lock: (id, agentId) => lockTask2(id, agentId, store),
|
|
48133
|
+
unlock: (id, agentId) => unlockTask2(id, agentId, store)
|
|
48134
|
+
},
|
|
48135
|
+
dependencies: {
|
|
48136
|
+
add: (taskId, dependsOn, context) => addDependency2(taskId, dependsOn, store, context),
|
|
48137
|
+
remove: (taskId, dependsOn) => removeDependency2(taskId, dependsOn, store),
|
|
48138
|
+
list: (taskId) => listDependencies(taskId, store)
|
|
48139
|
+
},
|
|
48140
|
+
verifications: {
|
|
48141
|
+
add: (input, context) => addVerification(input, store, context),
|
|
48142
|
+
list: (taskId) => listVerifications(taskId, store)
|
|
48098
48143
|
},
|
|
48099
48144
|
projects: {
|
|
48100
48145
|
create: (input, context) => createProject2(input, store, context),
|
|
@@ -48549,6 +48594,103 @@ async function patchTask(task2, patch, store) {
|
|
|
48549
48594
|
await store.upsert("tasks", updated);
|
|
48550
48595
|
return updated;
|
|
48551
48596
|
}
|
|
48597
|
+
function cloudLockExpired(lockedAt) {
|
|
48598
|
+
if (!lockedAt)
|
|
48599
|
+
return true;
|
|
48600
|
+
return new Date(lockedAt).getTime() + CLOUD_LOCK_EXPIRY_MINUTES * 60 * 1000 < Date.now();
|
|
48601
|
+
}
|
|
48602
|
+
function cloudLockExpiresAt(lockedAt) {
|
|
48603
|
+
return new Date(new Date(lockedAt).getTime() + CLOUD_LOCK_EXPIRY_MINUTES * 60 * 1000).toISOString();
|
|
48604
|
+
}
|
|
48605
|
+
async function lockTask2(id, agentId, store) {
|
|
48606
|
+
const task2 = await requireRecord("tasks", id, store);
|
|
48607
|
+
if (task2.status === "completed" || task2.status === "cancelled") {
|
|
48608
|
+
return { success: false, error: `Task is ${task2.status} and cannot be locked` };
|
|
48609
|
+
}
|
|
48610
|
+
if (task2.locked_by && task2.locked_by !== agentId && !cloudLockExpired(task2.locked_at)) {
|
|
48611
|
+
return { success: false, locked_by: task2.locked_by, locked_at: task2.locked_at ?? undefined, error: `Task is locked by ${task2.locked_by}` };
|
|
48612
|
+
}
|
|
48613
|
+
const timestamp3 = new Date().toISOString();
|
|
48614
|
+
await patchTask(task2, { locked_by: agentId, locked_at: timestamp3 }, store);
|
|
48615
|
+
return { success: true, locked_by: agentId, locked_at: timestamp3, expires_at: cloudLockExpiresAt(timestamp3) };
|
|
48616
|
+
}
|
|
48617
|
+
async function unlockTask2(id, agentId, store) {
|
|
48618
|
+
const task2 = await requireRecord("tasks", id, store);
|
|
48619
|
+
if (agentId && task2.locked_by && task2.locked_by !== agentId) {
|
|
48620
|
+
throw new Error(`Task ${id} is locked by ${task2.locked_by}, not ${agentId}`);
|
|
48621
|
+
}
|
|
48622
|
+
await patchTask(task2, { locked_by: null, locked_at: null }, store);
|
|
48623
|
+
return true;
|
|
48624
|
+
}
|
|
48625
|
+
function dependencyId(taskId, dependsOn) {
|
|
48626
|
+
return `${taskId}::${dependsOn}`;
|
|
48627
|
+
}
|
|
48628
|
+
async function addDependency2(taskId, dependsOn, store, context) {
|
|
48629
|
+
if (taskId === dependsOn)
|
|
48630
|
+
throw new Error("A task cannot depend on itself");
|
|
48631
|
+
if (!await store.get("tasks", taskId))
|
|
48632
|
+
throw new Error(`Task not found: ${taskId}`);
|
|
48633
|
+
if (!await store.get("tasks", dependsOn))
|
|
48634
|
+
throw new Error(`Task not found: ${dependsOn}`);
|
|
48635
|
+
const edges = await store.list("dependencies");
|
|
48636
|
+
const adjacency = new Map;
|
|
48637
|
+
for (const edge of edges) {
|
|
48638
|
+
if (!adjacency.has(edge.task_id))
|
|
48639
|
+
adjacency.set(edge.task_id, []);
|
|
48640
|
+
adjacency.get(edge.task_id).push(edge.depends_on);
|
|
48641
|
+
}
|
|
48642
|
+
const queue = [dependsOn];
|
|
48643
|
+
const seen = new Set;
|
|
48644
|
+
while (queue.length) {
|
|
48645
|
+
const node = queue.shift();
|
|
48646
|
+
if (node === taskId)
|
|
48647
|
+
throw new Error(`Adding dependency ${taskId} -> ${dependsOn} would create a cycle`);
|
|
48648
|
+
if (seen.has(node))
|
|
48649
|
+
continue;
|
|
48650
|
+
seen.add(node);
|
|
48651
|
+
for (const next of adjacency.get(node) ?? [])
|
|
48652
|
+
queue.push(next);
|
|
48653
|
+
}
|
|
48654
|
+
const timestamp3 = new Date().toISOString();
|
|
48655
|
+
const record = { id: dependencyId(taskId, dependsOn), task_id: taskId, depends_on: dependsOn, created_at: timestamp3, updated_at: timestamp3 };
|
|
48656
|
+
await store.upsert("dependencies", record, context);
|
|
48657
|
+
return { task_id: taskId, depends_on: dependsOn };
|
|
48658
|
+
}
|
|
48659
|
+
async function removeDependency2(taskId, dependsOn, store) {
|
|
48660
|
+
const existing = await store.get("dependencies", dependencyId(taskId, dependsOn));
|
|
48661
|
+
if (!existing)
|
|
48662
|
+
return false;
|
|
48663
|
+
await store.delete("dependencies", dependencyId(taskId, dependsOn));
|
|
48664
|
+
return true;
|
|
48665
|
+
}
|
|
48666
|
+
async function listDependencies(taskId, store) {
|
|
48667
|
+
const edges = await store.list("dependencies");
|
|
48668
|
+
return {
|
|
48669
|
+
dependencies: edges.filter((edge) => edge.task_id === taskId).map((edge) => ({ task_id: edge.task_id, depends_on: edge.depends_on })),
|
|
48670
|
+
blocked_by: edges.filter((edge) => edge.depends_on === taskId).map((edge) => ({ task_id: edge.task_id, depends_on: edge.depends_on }))
|
|
48671
|
+
};
|
|
48672
|
+
}
|
|
48673
|
+
async function addVerification(input, store, context) {
|
|
48674
|
+
if (!await store.get("tasks", input.task_id))
|
|
48675
|
+
throw new Error(`Task not found: ${input.task_id}`);
|
|
48676
|
+
const timestamp3 = new Date().toISOString();
|
|
48677
|
+
const verification = {
|
|
48678
|
+
id: randomUUID3(),
|
|
48679
|
+
task_id: input.task_id,
|
|
48680
|
+
command: input.command,
|
|
48681
|
+
status: input.status ?? "unknown",
|
|
48682
|
+
output_summary: input.output_summary ?? null,
|
|
48683
|
+
artifact_path: input.artifact_path ?? null,
|
|
48684
|
+
agent_id: input.agent_id ?? context?.agentId ?? null,
|
|
48685
|
+
run_at: timestamp3,
|
|
48686
|
+
created_at: timestamp3
|
|
48687
|
+
};
|
|
48688
|
+
await store.upsert("verifications", { ...verification, updated_at: timestamp3 }, context);
|
|
48689
|
+
return verification;
|
|
48690
|
+
}
|
|
48691
|
+
async function listVerifications(taskId, store) {
|
|
48692
|
+
return (await store.list("verifications")).filter((verification) => verification.task_id === taskId).sort((a, b) => b.run_at.localeCompare(a.run_at));
|
|
48693
|
+
}
|
|
48552
48694
|
function toFilterArray(value) {
|
|
48553
48695
|
return Array.isArray(value) ? value : [value];
|
|
48554
48696
|
}
|
|
@@ -48922,7 +49064,7 @@ function compareClock(left, right) {
|
|
|
48922
49064
|
function numberValue3(value) {
|
|
48923
49065
|
return typeof value === "number" && Number.isSafeInteger(value) ? value : null;
|
|
48924
49066
|
}
|
|
48925
|
-
var TASK_ORDER_BY = "ORDER BY CASE payload->>'priority' WHEN 'critical' THEN 0 WHEN 'high' THEN 1 WHEN 'medium' THEN 2 WHEN 'low' THEN 3 ELSE 4 END ASC, payload->>'created_at' ASC, payload->>'id' ASC";
|
|
49067
|
+
var CLOUD_LOCK_EXPIRY_MINUTES = 30, TASK_ORDER_BY = "ORDER BY CASE payload->>'priority' WHEN 'critical' THEN 0 WHEN 'high' THEN 1 WHEN 'medium' THEN 2 WHEN 'low' THEN 3 ELSE 4 END ASC, payload->>'created_at' ASC, payload->>'id' ASC";
|
|
48926
49068
|
var init_postgres_adapter = () => {};
|
|
48927
49069
|
|
|
48928
49070
|
// src/server/cloud.ts
|
|
@@ -49420,6 +49562,7 @@ async function handleV1Request(req, url) {
|
|
|
49420
49562
|
const resource = segments[1];
|
|
49421
49563
|
const id = segments[2];
|
|
49422
49564
|
const action = segments[3];
|
|
49565
|
+
const subId = segments[4];
|
|
49423
49566
|
try {
|
|
49424
49567
|
if (resource === "tasks") {
|
|
49425
49568
|
if (id === "exists" && !action) {
|
|
@@ -49495,6 +49638,89 @@ async function handleV1Request(req, url) {
|
|
|
49495
49638
|
}
|
|
49496
49639
|
return error(405, `method ${method} not allowed on /v1/tasks/:id/comments`);
|
|
49497
49640
|
}
|
|
49641
|
+
if (action === "lock" || action === "unlock") {
|
|
49642
|
+
if (method !== "POST")
|
|
49643
|
+
return error(405, `method ${method} not allowed on /v1/tasks/:id/${action}`);
|
|
49644
|
+
if (typeof store.tasks.lock !== "function" || typeof store.tasks.unlock !== "function") {
|
|
49645
|
+
return error(501, "task locking is not supported by this storage backend");
|
|
49646
|
+
}
|
|
49647
|
+
const body2 = await readJson(req) ?? {};
|
|
49648
|
+
if (!await store.tasks.get(id))
|
|
49649
|
+
return error(404, "task not found");
|
|
49650
|
+
if (action === "lock") {
|
|
49651
|
+
const agentId2 = body2.agent_id || principal.agent || "todos-serve";
|
|
49652
|
+
return json2({ result: await store.tasks.lock(id, agentId2) });
|
|
49653
|
+
}
|
|
49654
|
+
const released = await store.tasks.unlock(id, body2.agent_id || principal.agent || undefined);
|
|
49655
|
+
return json2({ success: released });
|
|
49656
|
+
}
|
|
49657
|
+
if (action === "dependencies") {
|
|
49658
|
+
if (!store.dependencies)
|
|
49659
|
+
return error(501, "dependencies are not supported by this storage backend");
|
|
49660
|
+
if (method === "GET") {
|
|
49661
|
+
if (!await store.tasks.get(id))
|
|
49662
|
+
return error(404, "task not found");
|
|
49663
|
+
const edges = await store.dependencies.list(id);
|
|
49664
|
+
return json2(edges);
|
|
49665
|
+
}
|
|
49666
|
+
if (method === "POST") {
|
|
49667
|
+
const body2 = await readJson(req) ?? {};
|
|
49668
|
+
if (typeof body2.depends_on !== "string" || !body2.depends_on.trim()) {
|
|
49669
|
+
return error(400, "depends_on is required");
|
|
49670
|
+
}
|
|
49671
|
+
try {
|
|
49672
|
+
const dependency = await store.dependencies.add(id, body2.depends_on, contextFromPrincipal(principal));
|
|
49673
|
+
return json2({ dependency }, 201);
|
|
49674
|
+
} catch (e) {
|
|
49675
|
+
const msg = e.message || "";
|
|
49676
|
+
if (msg.includes("not found"))
|
|
49677
|
+
return error(404, msg);
|
|
49678
|
+
if (msg.includes("cycle") || msg.includes("itself"))
|
|
49679
|
+
return error(409, msg);
|
|
49680
|
+
throw e;
|
|
49681
|
+
}
|
|
49682
|
+
}
|
|
49683
|
+
if (method === "DELETE") {
|
|
49684
|
+
if (!subId)
|
|
49685
|
+
return error(400, "dependency target id is required (/v1/tasks/:id/dependencies/:dep)");
|
|
49686
|
+
const removed = await store.dependencies.remove(id, subId);
|
|
49687
|
+
return json2({ removed });
|
|
49688
|
+
}
|
|
49689
|
+
return error(405, `method ${method} not allowed on /v1/tasks/:id/dependencies`);
|
|
49690
|
+
}
|
|
49691
|
+
if (action === "verifications") {
|
|
49692
|
+
if (!store.verifications)
|
|
49693
|
+
return error(501, "verifications are not supported by this storage backend");
|
|
49694
|
+
if (method === "GET") {
|
|
49695
|
+
if (!await store.tasks.get(id))
|
|
49696
|
+
return error(404, "task not found");
|
|
49697
|
+
const verifications = await store.verifications.list(id);
|
|
49698
|
+
return json2({ verifications, count: verifications.length });
|
|
49699
|
+
}
|
|
49700
|
+
if (method === "POST") {
|
|
49701
|
+
const body2 = await readJson(req) ?? {};
|
|
49702
|
+
if (typeof body2.command !== "string" || !body2.command.trim()) {
|
|
49703
|
+
return error(400, "command is required");
|
|
49704
|
+
}
|
|
49705
|
+
try {
|
|
49706
|
+
const verification = await store.verifications.add({
|
|
49707
|
+
task_id: id,
|
|
49708
|
+
command: body2.command,
|
|
49709
|
+
status: body2.status,
|
|
49710
|
+
output_summary: body2.output_summary,
|
|
49711
|
+
artifact_path: body2.artifact_path,
|
|
49712
|
+
agent_id: body2.agent_id
|
|
49713
|
+
}, contextFromPrincipal(principal, body2));
|
|
49714
|
+
return json2({ verification }, 201);
|
|
49715
|
+
} catch (e) {
|
|
49716
|
+
const msg = e.message || "";
|
|
49717
|
+
if (msg.includes("not found"))
|
|
49718
|
+
return error(404, msg);
|
|
49719
|
+
throw e;
|
|
49720
|
+
}
|
|
49721
|
+
}
|
|
49722
|
+
return error(405, `method ${method} not allowed on /v1/tasks/:id/verifications`);
|
|
49723
|
+
}
|
|
49498
49724
|
const body = await readJson(req) ?? {};
|
|
49499
49725
|
const agentId = body.agent_id || principal.agent || "todos-serve";
|
|
49500
49726
|
if (action === "start" && method === "POST") {
|
|
@@ -49599,10 +49825,13 @@ async function handleV1Request(req, url) {
|
|
|
49599
49825
|
}
|
|
49600
49826
|
if (!id && method === "POST") {
|
|
49601
49827
|
const body = await readJson(req);
|
|
49602
|
-
if (!body || typeof body.name !== "string")
|
|
49828
|
+
if (!body || typeof body.name !== "string" || !body.name.trim())
|
|
49603
49829
|
return error(400, "name is required");
|
|
49604
|
-
const
|
|
49605
|
-
|
|
49830
|
+
const result = await store.agents.register(body, contextFromPrincipal(principal));
|
|
49831
|
+
if (result && typeof result === "object" && "conflict" in result) {
|
|
49832
|
+
return error(409, result.message ?? "agent name conflict", { conflict: true });
|
|
49833
|
+
}
|
|
49834
|
+
return json2({ agent: result }, 201);
|
|
49606
49835
|
}
|
|
49607
49836
|
if (id && method === "GET") {
|
|
49608
49837
|
const agent = await store.agents.get(id);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agents.d.ts","sourceRoot":"","sources":["../../../src/mcp/tools/agents.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAOzE,UAAU,UAAU;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,KAAK,OAAO,GAAG;IACb,kBAAkB,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC;IAC9C,SAAS,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,KAAK,MAAM,CAAC;IAClD,WAAW,EAAE,CAAC,CAAC,EAAE,OAAO,KAAK,MAAM,CAAC;IACpC,aAAa,EAAE,GAAG,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;IACvC,aAAa,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,UAAU,GAAG,SAAS,CAAC;CAC5D,CAAC;AAEF,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,SAAS,EAAE,EAAE,kBAAkB,EAAE,SAAS,EAAE,WAAW,EAAE,aAAa,EAAE,aAAa,EAAE,EAAE,OAAO,GAAG,IAAI,
|
|
1
|
+
{"version":3,"file":"agents.d.ts","sourceRoot":"","sources":["../../../src/mcp/tools/agents.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAOzE,UAAU,UAAU;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,KAAK,OAAO,GAAG;IACb,kBAAkB,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC;IAC9C,SAAS,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,KAAK,MAAM,CAAC;IAClD,WAAW,EAAE,CAAC,CAAC,EAAE,OAAO,KAAK,MAAM,CAAC;IACpC,aAAa,EAAE,GAAG,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;IACvC,aAAa,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,UAAU,GAAG,SAAS,CAAC;CAC5D,CAAC;AAEF,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,SAAS,EAAE,EAAE,kBAAkB,EAAE,SAAS,EAAE,WAAW,EAAE,aAAa,EAAE,aAAa,EAAE,EAAE,OAAO,GAAG,IAAI,CA6cjJ"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"packageName": "@hasna/todos",
|
|
3
|
-
"packageVersion": "0.11.
|
|
3
|
+
"packageVersion": "0.11.83",
|
|
4
4
|
"repository": "https://github.com/hasna/todos.git",
|
|
5
|
-
"gitCommit": "
|
|
6
|
-
"generatedAt": "2026-07-
|
|
5
|
+
"gitCommit": "69a46e4c566599f0e473686aa6c49aa6df6be20d",
|
|
6
|
+
"generatedAt": "2026-07-08T14:22:35.687Z"
|
|
7
7
|
}
|