@artyfacts/claude 1.3.24 → 1.3.25
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/chunk-7QRIXWMF.mjs +1085 -0
- package/dist/chunk-HPMSVN7C.mjs +1084 -0
- package/dist/cli.js +145 -77
- package/dist/cli.mjs +49 -32
- package/dist/index.d.mts +100 -29
- package/dist/index.d.ts +100 -29
- package/dist/index.js +231 -80
- package/dist/index.mjs +135 -35
- package/package.json +9 -9
- package/src/cli.ts +79 -46
- package/src/context.ts +117 -41
- package/src/executor.ts +52 -26
- package/src/listener.ts +42 -15
- package/src/tools/handlers.ts +90 -17
- package/src/tools/registry.ts +90 -20
- package/src/tools/types.ts +87 -0
package/dist/cli.js
CHANGED
|
@@ -258,12 +258,13 @@ You have access to Artyfacts MCP tools. USE THEM to complete your task:
|
|
|
258
258
|
- **create_artifact** - Create new artifacts (documents, specs, reports)
|
|
259
259
|
- **create_section** - Add sections to artifacts (content, tasks, decisions)
|
|
260
260
|
- **update_section** - Update existing sections
|
|
261
|
-
- **
|
|
262
|
-
- **
|
|
263
|
-
- **
|
|
264
|
-
- **complete_task** - Mark a task as complete
|
|
261
|
+
- **create_task** - Create new tasks under a goal
|
|
262
|
+
- **claim_task** - Claim a task for execution
|
|
263
|
+
- **complete_task** - Mark a task as complete (returns unblocked tasks)
|
|
265
264
|
- **block_task** - Block a task with a reason
|
|
266
|
-
- **
|
|
265
|
+
- **list_tasks** - Query tasks from the queue
|
|
266
|
+
- **list_inbox** - Check pending decisions/approvals
|
|
267
|
+
- **resolve_inbox** - Resolve an inbox item
|
|
267
268
|
|
|
268
269
|
IMPORTANT: When asked to create agents or update artifacts, USE THE TOOLS. Don't just describe what you would do - actually do it with the tools.
|
|
269
270
|
|
|
@@ -272,7 +273,7 @@ IMPORTANT: When asked to create agents or update artifacts, USE THE TOOLS. Don't
|
|
|
272
273
|
- Be thorough but concise
|
|
273
274
|
- USE THE TOOLS to take action, don't just analyze
|
|
274
275
|
- If the task requires creating something, use create_artifact or create_section
|
|
275
|
-
- If
|
|
276
|
+
- If you complete a task, check the response for unblocked_tasks to see follow-up work
|
|
276
277
|
- If you cannot complete the task, explain why
|
|
277
278
|
|
|
278
279
|
Format your response as follows:
|
|
@@ -296,37 +297,69 @@ Format your response as follows:
|
|
|
296
297
|
}
|
|
297
298
|
parts.push("");
|
|
298
299
|
}
|
|
299
|
-
|
|
300
|
-
if (
|
|
301
|
-
parts.push(
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
if (relatedSections.length > 0) {
|
|
312
|
-
parts.push("### Related Sections:");
|
|
313
|
-
for (const section of relatedSections) {
|
|
314
|
-
const preview = section.content ? section.content.substring(0, 200) + (section.content.length > 200 ? "..." : "") : "No content";
|
|
315
|
-
const statusBadge = section.task_status ? ` [${section.task_status}]` : "";
|
|
316
|
-
parts.push(`- **${section.heading}**${statusBadge}: ${preview}`);
|
|
300
|
+
const goal = context.goal || context.artifact;
|
|
301
|
+
if (goal) {
|
|
302
|
+
parts.push(`## Goal: ${goal.title}`);
|
|
303
|
+
if (goal.objective) {
|
|
304
|
+
parts.push(`**Objective:** ${goal.objective}`);
|
|
305
|
+
}
|
|
306
|
+
if (goal.summary) {
|
|
307
|
+
parts.push(goal.summary);
|
|
308
|
+
}
|
|
309
|
+
if (goal.description) {
|
|
310
|
+
parts.push("");
|
|
311
|
+
parts.push(goal.description);
|
|
317
312
|
}
|
|
318
313
|
parts.push("");
|
|
314
|
+
if (goal.tasks && goal.tasks.length > 0) {
|
|
315
|
+
const relatedTasks = goal.tasks.filter((t) => t.id !== context.task.id);
|
|
316
|
+
if (relatedTasks.length > 0) {
|
|
317
|
+
parts.push("### Related Tasks:");
|
|
318
|
+
for (const task of relatedTasks) {
|
|
319
|
+
const statusEmoji = {
|
|
320
|
+
pending: "\u23F3",
|
|
321
|
+
in_progress: "\u{1F504}",
|
|
322
|
+
blocked: "\u{1F6AB}",
|
|
323
|
+
done: "\u2705"
|
|
324
|
+
}[task.status] || "\u2753";
|
|
325
|
+
const priorityBadge = task.priority ? ` [${task.priority}]` : "";
|
|
326
|
+
parts.push(`- ${statusEmoji} **${task.title}**${priorityBadge}`);
|
|
327
|
+
}
|
|
328
|
+
parts.push("");
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
if (goal.sections && goal.sections.length > 0) {
|
|
332
|
+
const relatedSections = goal.sections.filter((s) => s.id !== context.task.id);
|
|
333
|
+
if (relatedSections.length > 0) {
|
|
334
|
+
parts.push("### Related Sections:");
|
|
335
|
+
for (const section of relatedSections) {
|
|
336
|
+
const preview = section.content ? section.content.substring(0, 200) + (section.content.length > 200 ? "..." : "") : "No content";
|
|
337
|
+
const statusBadge = section.task_status ? ` [${section.task_status}]` : "";
|
|
338
|
+
parts.push(`- **${section.heading}**${statusBadge}: ${preview}`);
|
|
339
|
+
}
|
|
340
|
+
parts.push("");
|
|
341
|
+
}
|
|
342
|
+
}
|
|
319
343
|
}
|
|
320
344
|
parts.push("---");
|
|
321
345
|
parts.push("");
|
|
322
|
-
|
|
346
|
+
const taskTitle = context.task.title || context.task.heading;
|
|
347
|
+
parts.push(`## Your Task: ${taskTitle}`);
|
|
323
348
|
if (context.task.priority) {
|
|
324
|
-
const
|
|
325
|
-
|
|
349
|
+
const priorityEmoji = {
|
|
350
|
+
high: "\u{1F534} High",
|
|
351
|
+
medium: "\u{1F7E1} Medium",
|
|
352
|
+
low: "\u{1F7E2} Low"
|
|
353
|
+
}[context.task.priority] || "\u{1F7E1} Medium";
|
|
354
|
+
parts.push(`**Priority:** ${priorityEmoji}`);
|
|
355
|
+
}
|
|
356
|
+
if (context.task.depends_on && context.task.depends_on.length > 0) {
|
|
357
|
+
parts.push(`**Dependencies:** ${context.task.depends_on.length} task(s)`);
|
|
326
358
|
}
|
|
327
359
|
parts.push("");
|
|
328
360
|
parts.push("### Description");
|
|
329
|
-
|
|
361
|
+
const taskDescription = context.task.description || context.task.content;
|
|
362
|
+
parts.push(taskDescription || "No additional description provided.");
|
|
330
363
|
parts.push("");
|
|
331
364
|
if (context.task.expected_output) {
|
|
332
365
|
parts.push("### Expected Output");
|
|
@@ -443,9 +476,13 @@ var ClaudeExecutor = class {
|
|
|
443
476
|
const useFullContext = this.config.useFullContext !== false && this.contextFetcher;
|
|
444
477
|
if (useFullContext) {
|
|
445
478
|
try {
|
|
446
|
-
|
|
479
|
+
const taskId = task.id || task.taskId;
|
|
480
|
+
if (!taskId) {
|
|
481
|
+
throw new Error("Task ID required for context fetch");
|
|
482
|
+
}
|
|
483
|
+
fullContext = await this.contextFetcher.fetchTaskContext(taskId);
|
|
447
484
|
prompt = buildPromptWithContext(fullContext);
|
|
448
|
-
console.log(" \u{1F4DA} Using full context (org, project,
|
|
485
|
+
console.log(" \u{1F4DA} Using full context (org, project, goal, related tasks)");
|
|
449
486
|
} catch (contextError) {
|
|
450
487
|
console.warn(" \u26A0\uFE0F Could not fetch full context, using minimal prompt");
|
|
451
488
|
console.warn(` ${contextError instanceof Error ? contextError.message : contextError}`);
|
|
@@ -455,7 +492,8 @@ var ClaudeExecutor = class {
|
|
|
455
492
|
prompt = this.buildTaskPrompt(task);
|
|
456
493
|
}
|
|
457
494
|
const output = await this.runClaude(prompt);
|
|
458
|
-
const
|
|
495
|
+
const taskTitle = task.title || task.heading || "Task";
|
|
496
|
+
const { content, summary } = this.parseResponse(output, taskTitle);
|
|
459
497
|
return {
|
|
460
498
|
success: true,
|
|
461
499
|
output: content,
|
|
@@ -530,7 +568,7 @@ var ClaudeExecutor = class {
|
|
|
530
568
|
});
|
|
531
569
|
}
|
|
532
570
|
/**
|
|
533
|
-
* Build the task prompt
|
|
571
|
+
* Build the task prompt (v2)
|
|
534
572
|
*/
|
|
535
573
|
buildTaskPrompt(task) {
|
|
536
574
|
const parts = [];
|
|
@@ -541,18 +579,25 @@ ${DEFAULT_SYSTEM_PROMPT}` : DEFAULT_SYSTEM_PROMPT;
|
|
|
541
579
|
parts.push("");
|
|
542
580
|
parts.push("---");
|
|
543
581
|
parts.push("");
|
|
544
|
-
|
|
582
|
+
const taskTitle = task.title || task.heading;
|
|
583
|
+
parts.push(`# Task: ${taskTitle}`);
|
|
545
584
|
parts.push("");
|
|
546
|
-
|
|
547
|
-
|
|
585
|
+
const goalTitle = task.goalTitle || task.artifactTitle;
|
|
586
|
+
if (goalTitle) {
|
|
587
|
+
parts.push(`**Goal:** ${goalTitle}`);
|
|
548
588
|
}
|
|
549
589
|
if (task.priority) {
|
|
550
|
-
const
|
|
551
|
-
|
|
590
|
+
const priorityEmoji = {
|
|
591
|
+
high: "\u{1F534} High",
|
|
592
|
+
medium: "\u{1F7E1} Medium",
|
|
593
|
+
low: "\u{1F7E2} Low"
|
|
594
|
+
}[task.priority] || "\u{1F7E1} Medium";
|
|
595
|
+
parts.push(`**Priority:** ${priorityEmoji}`);
|
|
552
596
|
}
|
|
553
597
|
parts.push("");
|
|
554
598
|
parts.push("## Description");
|
|
555
|
-
|
|
599
|
+
const taskDescription = task.description || task.content;
|
|
600
|
+
parts.push(taskDescription || "No additional description provided.");
|
|
556
601
|
parts.push("");
|
|
557
602
|
if (task.context && Object.keys(task.context).length > 0) {
|
|
558
603
|
parts.push("## Additional Context");
|
|
@@ -742,16 +787,22 @@ var ArtyfactsListener = class {
|
|
|
742
787
|
try {
|
|
743
788
|
const data = JSON.parse(event.data);
|
|
744
789
|
const rawData = data.data || data;
|
|
745
|
-
const normalizedData = rawData.task_id ? {
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
790
|
+
const normalizedData = rawData.id || rawData.task_id ? {
|
|
791
|
+
// v2 fields (primary)
|
|
792
|
+
id: rawData.id || rawData.task_id,
|
|
793
|
+
goalId: rawData.goal_id || rawData.artifact_id,
|
|
794
|
+
goalTitle: rawData.goal_title || rawData.artifact_title,
|
|
795
|
+
title: rawData.title || rawData.heading,
|
|
796
|
+
description: rawData.description || rawData.content,
|
|
797
|
+
priority: rawData.priority,
|
|
752
798
|
assignedTo: rawData.assigned_to,
|
|
753
799
|
assignedAt: rawData.assigned_at,
|
|
754
|
-
|
|
800
|
+
// Deprecated fields for backwards compatibility
|
|
801
|
+
taskId: rawData.id || rawData.task_id,
|
|
802
|
+
artifactId: rawData.goal_id || rawData.artifact_id,
|
|
803
|
+
artifactTitle: rawData.goal_title || rawData.artifact_title,
|
|
804
|
+
heading: rawData.title || rawData.heading,
|
|
805
|
+
content: rawData.description || rawData.content,
|
|
755
806
|
...rawData
|
|
756
807
|
// Keep original fields too
|
|
757
808
|
} : rawData;
|
|
@@ -1178,13 +1229,16 @@ async function checkAndClaimTasks(baseUrl, apiKey, agentId, activeTasks, executo
|
|
|
1178
1229
|
continue;
|
|
1179
1230
|
}
|
|
1180
1231
|
console.log(`
|
|
1181
|
-
[Claiming] ${task.
|
|
1232
|
+
[Claiming] ${task.title} (as ${task.agent_name || task.agent_id || "unknown"})`);
|
|
1182
1233
|
const claimResponse = await fetch(`${baseUrl}/tasks/${task.id}/claim`, {
|
|
1183
1234
|
method: "POST",
|
|
1184
1235
|
headers: {
|
|
1185
1236
|
"Authorization": `Bearer ${apiKey}`,
|
|
1186
1237
|
"Content-Type": "application/json"
|
|
1187
|
-
}
|
|
1238
|
+
},
|
|
1239
|
+
body: JSON.stringify({
|
|
1240
|
+
agent_id: task.agent_id
|
|
1241
|
+
})
|
|
1188
1242
|
});
|
|
1189
1243
|
if (!claimResponse.ok) {
|
|
1190
1244
|
const error = await claimResponse.json().catch(() => ({}));
|
|
@@ -1196,7 +1250,7 @@ async function checkAndClaimTasks(baseUrl, apiKey, agentId, activeTasks, executo
|
|
|
1196
1250
|
return { task: { id: task.id } };
|
|
1197
1251
|
});
|
|
1198
1252
|
const taskUuid = claimData.task?.id || task.id;
|
|
1199
|
-
|
|
1253
|
+
const goalTitle = claimData.task?.goal_title || task.goal_title;
|
|
1200
1254
|
activeTasks.add(task.id);
|
|
1201
1255
|
console.log(" \u2713 Claimed!");
|
|
1202
1256
|
if (dryRun) {
|
|
@@ -1206,14 +1260,19 @@ async function checkAndClaimTasks(baseUrl, apiKey, agentId, activeTasks, executo
|
|
|
1206
1260
|
}
|
|
1207
1261
|
console.log(" \u2192 Executing with Claude...");
|
|
1208
1262
|
try {
|
|
1263
|
+
const priorityMap = {
|
|
1264
|
+
"urgent": "high",
|
|
1265
|
+
"high": "high",
|
|
1266
|
+
"medium": "medium",
|
|
1267
|
+
"low": "low"
|
|
1268
|
+
};
|
|
1209
1269
|
const result = await executor.execute({
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
priority: task.priority
|
|
1270
|
+
id: taskUuid,
|
|
1271
|
+
title: task.title,
|
|
1272
|
+
description: task.description || "",
|
|
1273
|
+
goalId: task.goal_id,
|
|
1274
|
+
goalTitle,
|
|
1275
|
+
priority: priorityMap[task.priority] || "medium"
|
|
1217
1276
|
});
|
|
1218
1277
|
if (result.success) {
|
|
1219
1278
|
try {
|
|
@@ -1336,39 +1395,50 @@ async function runAgent(options) {
|
|
|
1336
1395
|
});
|
|
1337
1396
|
listener.on("task_assigned", async (event) => {
|
|
1338
1397
|
const task = event.data;
|
|
1339
|
-
|
|
1398
|
+
const taskId = task.id || task.taskId || "";
|
|
1399
|
+
const taskTitle = task.title || task.heading || "Untitled Task";
|
|
1400
|
+
const taskDescription = task.description || task.content || "";
|
|
1401
|
+
const goalId = task.goalId || task.artifactId || "";
|
|
1402
|
+
const goalTitle = task.goalTitle || task.artifactTitle;
|
|
1403
|
+
if (!taskId || activeTasks.has(taskId)) {
|
|
1340
1404
|
return;
|
|
1341
1405
|
}
|
|
1342
|
-
activeTasks.add(
|
|
1406
|
+
activeTasks.add(taskId);
|
|
1343
1407
|
console.log(`
|
|
1344
|
-
[Task received] ${
|
|
1408
|
+
[Task received] ${taskTitle}`);
|
|
1345
1409
|
if (options.dryRun) {
|
|
1346
1410
|
console.log(" \u{1F4CB} Dry run - not executing");
|
|
1347
|
-
console.log(` \u{1F4C4}
|
|
1348
|
-
console.log(` \u{1F4DD}
|
|
1349
|
-
activeTasks.delete(
|
|
1411
|
+
console.log(` \u{1F4C4} Goal: ${goalTitle || goalId}`);
|
|
1412
|
+
console.log(` \u{1F4DD} Description: ${taskDescription.substring(0, 100)}...`);
|
|
1413
|
+
activeTasks.delete(taskId);
|
|
1350
1414
|
return;
|
|
1351
1415
|
}
|
|
1352
1416
|
console.log(" \u2192 Executing with Claude...");
|
|
1353
1417
|
try {
|
|
1354
1418
|
const taskContext = {
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1419
|
+
id: taskId,
|
|
1420
|
+
title: taskTitle,
|
|
1421
|
+
description: taskDescription,
|
|
1422
|
+
goalId,
|
|
1423
|
+
goalTitle,
|
|
1360
1424
|
priority: task.priority
|
|
1361
1425
|
};
|
|
1362
1426
|
const result = await executor.execute(taskContext);
|
|
1363
1427
|
if (result.success) {
|
|
1364
1428
|
try {
|
|
1365
|
-
await completeTask({
|
|
1429
|
+
const completionResult = await completeTask({
|
|
1366
1430
|
baseUrl: options.baseUrl,
|
|
1367
1431
|
apiKey: credentials.apiKey,
|
|
1368
|
-
taskId
|
|
1432
|
+
taskId,
|
|
1369
1433
|
output: result.output,
|
|
1370
1434
|
summary: result.summary
|
|
1371
1435
|
});
|
|
1436
|
+
if (completionResult.unblocked_tasks && completionResult.unblocked_tasks.length > 0) {
|
|
1437
|
+
console.log(` \u2192 \u{1F513} Unblocked ${completionResult.unblocked_tasks.length} task(s):`);
|
|
1438
|
+
for (const unblocked of completionResult.unblocked_tasks) {
|
|
1439
|
+
console.log(` - ${unblocked.title} (${unblocked.id})`);
|
|
1440
|
+
}
|
|
1441
|
+
}
|
|
1372
1442
|
} catch (err) {
|
|
1373
1443
|
const errMsg = err instanceof Error ? err.message : String(err);
|
|
1374
1444
|
if (!errMsg.includes("already complete")) {
|
|
@@ -1381,14 +1451,14 @@ async function runAgent(options) {
|
|
|
1381
1451
|
await blockTask({
|
|
1382
1452
|
baseUrl: options.baseUrl,
|
|
1383
1453
|
apiKey: credentials.apiKey,
|
|
1384
|
-
taskId
|
|
1454
|
+
taskId,
|
|
1385
1455
|
reason: result.error || "Execution failed"
|
|
1386
1456
|
});
|
|
1387
1457
|
}
|
|
1388
1458
|
} catch (error) {
|
|
1389
1459
|
console.error(` \u2192 \u274C Error:`, error instanceof Error ? error.message : error);
|
|
1390
1460
|
} finally {
|
|
1391
|
-
activeTasks.delete(
|
|
1461
|
+
activeTasks.delete(taskId);
|
|
1392
1462
|
}
|
|
1393
1463
|
});
|
|
1394
1464
|
listener.connect();
|
|
@@ -1417,16 +1487,15 @@ async function completeTask(options) {
|
|
|
1417
1487
|
"Content-Type": "application/json"
|
|
1418
1488
|
},
|
|
1419
1489
|
body: JSON.stringify({
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
summary: options.summary,
|
|
1423
|
-
output: options.output
|
|
1490
|
+
output_text: options.summary || options.output,
|
|
1491
|
+
output_url: options.output?.startsWith("http") ? options.output : void 0
|
|
1424
1492
|
})
|
|
1425
1493
|
});
|
|
1426
1494
|
if (!response.ok) {
|
|
1427
1495
|
const error = await response.text();
|
|
1428
1496
|
throw new Error(`Failed to complete task: ${error}`);
|
|
1429
1497
|
}
|
|
1498
|
+
return response.json();
|
|
1430
1499
|
}
|
|
1431
1500
|
async function blockTask(options) {
|
|
1432
1501
|
const response = await fetch(`${options.baseUrl}/tasks/${options.taskId}/block`, {
|
|
@@ -1436,8 +1505,7 @@ async function blockTask(options) {
|
|
|
1436
1505
|
"Content-Type": "application/json"
|
|
1437
1506
|
},
|
|
1438
1507
|
body: JSON.stringify({
|
|
1439
|
-
|
|
1440
|
-
blocked_reason: options.reason
|
|
1508
|
+
reason: options.reason
|
|
1441
1509
|
})
|
|
1442
1510
|
});
|
|
1443
1511
|
if (!response.ok) {
|
package/dist/cli.mjs
CHANGED
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
getCredentials,
|
|
8
8
|
loadCredentials,
|
|
9
9
|
promptForApiKey
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-7QRIXWMF.mjs";
|
|
11
11
|
|
|
12
12
|
// src/cli.ts
|
|
13
13
|
import { Command } from "commander";
|
|
@@ -143,13 +143,16 @@ async function checkAndClaimTasks(baseUrl, apiKey, agentId, activeTasks, executo
|
|
|
143
143
|
continue;
|
|
144
144
|
}
|
|
145
145
|
console.log(`
|
|
146
|
-
[Claiming] ${task.
|
|
146
|
+
[Claiming] ${task.title} (as ${task.agent_name || task.agent_id || "unknown"})`);
|
|
147
147
|
const claimResponse = await fetch(`${baseUrl}/tasks/${task.id}/claim`, {
|
|
148
148
|
method: "POST",
|
|
149
149
|
headers: {
|
|
150
150
|
"Authorization": `Bearer ${apiKey}`,
|
|
151
151
|
"Content-Type": "application/json"
|
|
152
|
-
}
|
|
152
|
+
},
|
|
153
|
+
body: JSON.stringify({
|
|
154
|
+
agent_id: task.agent_id
|
|
155
|
+
})
|
|
153
156
|
});
|
|
154
157
|
if (!claimResponse.ok) {
|
|
155
158
|
const error = await claimResponse.json().catch(() => ({}));
|
|
@@ -161,7 +164,7 @@ async function checkAndClaimTasks(baseUrl, apiKey, agentId, activeTasks, executo
|
|
|
161
164
|
return { task: { id: task.id } };
|
|
162
165
|
});
|
|
163
166
|
const taskUuid = claimData.task?.id || task.id;
|
|
164
|
-
|
|
167
|
+
const goalTitle = claimData.task?.goal_title || task.goal_title;
|
|
165
168
|
activeTasks.add(task.id);
|
|
166
169
|
console.log(" \u2713 Claimed!");
|
|
167
170
|
if (dryRun) {
|
|
@@ -171,14 +174,19 @@ async function checkAndClaimTasks(baseUrl, apiKey, agentId, activeTasks, executo
|
|
|
171
174
|
}
|
|
172
175
|
console.log(" \u2192 Executing with Claude...");
|
|
173
176
|
try {
|
|
177
|
+
const priorityMap = {
|
|
178
|
+
"urgent": "high",
|
|
179
|
+
"high": "high",
|
|
180
|
+
"medium": "medium",
|
|
181
|
+
"low": "low"
|
|
182
|
+
};
|
|
174
183
|
const result = await executor.execute({
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
priority: task.priority
|
|
184
|
+
id: taskUuid,
|
|
185
|
+
title: task.title,
|
|
186
|
+
description: task.description || "",
|
|
187
|
+
goalId: task.goal_id,
|
|
188
|
+
goalTitle,
|
|
189
|
+
priority: priorityMap[task.priority] || "medium"
|
|
182
190
|
});
|
|
183
191
|
if (result.success) {
|
|
184
192
|
try {
|
|
@@ -301,39 +309,50 @@ async function runAgent(options) {
|
|
|
301
309
|
});
|
|
302
310
|
listener.on("task_assigned", async (event) => {
|
|
303
311
|
const task = event.data;
|
|
304
|
-
|
|
312
|
+
const taskId = task.id || task.taskId || "";
|
|
313
|
+
const taskTitle = task.title || task.heading || "Untitled Task";
|
|
314
|
+
const taskDescription = task.description || task.content || "";
|
|
315
|
+
const goalId = task.goalId || task.artifactId || "";
|
|
316
|
+
const goalTitle = task.goalTitle || task.artifactTitle;
|
|
317
|
+
if (!taskId || activeTasks.has(taskId)) {
|
|
305
318
|
return;
|
|
306
319
|
}
|
|
307
|
-
activeTasks.add(
|
|
320
|
+
activeTasks.add(taskId);
|
|
308
321
|
console.log(`
|
|
309
|
-
[Task received] ${
|
|
322
|
+
[Task received] ${taskTitle}`);
|
|
310
323
|
if (options.dryRun) {
|
|
311
324
|
console.log(" \u{1F4CB} Dry run - not executing");
|
|
312
|
-
console.log(` \u{1F4C4}
|
|
313
|
-
console.log(` \u{1F4DD}
|
|
314
|
-
activeTasks.delete(
|
|
325
|
+
console.log(` \u{1F4C4} Goal: ${goalTitle || goalId}`);
|
|
326
|
+
console.log(` \u{1F4DD} Description: ${taskDescription.substring(0, 100)}...`);
|
|
327
|
+
activeTasks.delete(taskId);
|
|
315
328
|
return;
|
|
316
329
|
}
|
|
317
330
|
console.log(" \u2192 Executing with Claude...");
|
|
318
331
|
try {
|
|
319
332
|
const taskContext = {
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
333
|
+
id: taskId,
|
|
334
|
+
title: taskTitle,
|
|
335
|
+
description: taskDescription,
|
|
336
|
+
goalId,
|
|
337
|
+
goalTitle,
|
|
325
338
|
priority: task.priority
|
|
326
339
|
};
|
|
327
340
|
const result = await executor.execute(taskContext);
|
|
328
341
|
if (result.success) {
|
|
329
342
|
try {
|
|
330
|
-
await completeTask({
|
|
343
|
+
const completionResult = await completeTask({
|
|
331
344
|
baseUrl: options.baseUrl,
|
|
332
345
|
apiKey: credentials.apiKey,
|
|
333
|
-
taskId
|
|
346
|
+
taskId,
|
|
334
347
|
output: result.output,
|
|
335
348
|
summary: result.summary
|
|
336
349
|
});
|
|
350
|
+
if (completionResult.unblocked_tasks && completionResult.unblocked_tasks.length > 0) {
|
|
351
|
+
console.log(` \u2192 \u{1F513} Unblocked ${completionResult.unblocked_tasks.length} task(s):`);
|
|
352
|
+
for (const unblocked of completionResult.unblocked_tasks) {
|
|
353
|
+
console.log(` - ${unblocked.title} (${unblocked.id})`);
|
|
354
|
+
}
|
|
355
|
+
}
|
|
337
356
|
} catch (err) {
|
|
338
357
|
const errMsg = err instanceof Error ? err.message : String(err);
|
|
339
358
|
if (!errMsg.includes("already complete")) {
|
|
@@ -346,14 +365,14 @@ async function runAgent(options) {
|
|
|
346
365
|
await blockTask({
|
|
347
366
|
baseUrl: options.baseUrl,
|
|
348
367
|
apiKey: credentials.apiKey,
|
|
349
|
-
taskId
|
|
368
|
+
taskId,
|
|
350
369
|
reason: result.error || "Execution failed"
|
|
351
370
|
});
|
|
352
371
|
}
|
|
353
372
|
} catch (error) {
|
|
354
373
|
console.error(` \u2192 \u274C Error:`, error instanceof Error ? error.message : error);
|
|
355
374
|
} finally {
|
|
356
|
-
activeTasks.delete(
|
|
375
|
+
activeTasks.delete(taskId);
|
|
357
376
|
}
|
|
358
377
|
});
|
|
359
378
|
listener.connect();
|
|
@@ -382,16 +401,15 @@ async function completeTask(options) {
|
|
|
382
401
|
"Content-Type": "application/json"
|
|
383
402
|
},
|
|
384
403
|
body: JSON.stringify({
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
summary: options.summary,
|
|
388
|
-
output: options.output
|
|
404
|
+
output_text: options.summary || options.output,
|
|
405
|
+
output_url: options.output?.startsWith("http") ? options.output : void 0
|
|
389
406
|
})
|
|
390
407
|
});
|
|
391
408
|
if (!response.ok) {
|
|
392
409
|
const error = await response.text();
|
|
393
410
|
throw new Error(`Failed to complete task: ${error}`);
|
|
394
411
|
}
|
|
412
|
+
return response.json();
|
|
395
413
|
}
|
|
396
414
|
async function blockTask(options) {
|
|
397
415
|
const response = await fetch(`${options.baseUrl}/tasks/${options.taskId}/block`, {
|
|
@@ -401,8 +419,7 @@ async function blockTask(options) {
|
|
|
401
419
|
"Content-Type": "application/json"
|
|
402
420
|
},
|
|
403
421
|
body: JSON.stringify({
|
|
404
|
-
|
|
405
|
-
blocked_reason: options.reason
|
|
422
|
+
reason: options.reason
|
|
406
423
|
})
|
|
407
424
|
});
|
|
408
425
|
if (!response.ok) {
|