@kendoo.agentdesk/agentdesk 0.6.2 → 0.6.4
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/team.mjs +40 -2
- package/package.json +1 -1
package/cli/team.mjs
CHANGED
|
@@ -122,6 +122,7 @@ export async function runTeam(taskId, opts = {}) {
|
|
|
122
122
|
createInstr += `Create a GitHub issue:\n- Run: gh issue create --title "..." --body "..."\n- After creation, use the returned issue number as the task ID for the rest of the session\n`;
|
|
123
123
|
}
|
|
124
124
|
createInstr += `\nTask description: ${description}\n`;
|
|
125
|
+
createInstr += `\nIMPORTANT: After creating the task, Jane MUST immediately announce the new task ID on its own line in this exact format:\nTASK_ID: <identifier>\nExample: TASK_ID: KEN-530\nThis is required so the session can be linked to the correct task.\n`;
|
|
125
126
|
prompt += createInstr;
|
|
126
127
|
}
|
|
127
128
|
|
|
@@ -324,12 +325,25 @@ export async function runTeam(taskId, opts = {}) {
|
|
|
324
325
|
console.log("\n━━━ INTAKE ━━━\n");
|
|
325
326
|
vizSend({ type: "phase:change", phase: "INTAKE" });
|
|
326
327
|
|
|
328
|
+
let totalInputTokens = 0;
|
|
329
|
+
let totalOutputTokens = 0;
|
|
330
|
+
|
|
327
331
|
const rl = createInterface({ input: child.stdout });
|
|
328
332
|
|
|
329
333
|
for await (const line of rl) {
|
|
330
334
|
try {
|
|
331
335
|
const event = JSON.parse(line);
|
|
332
336
|
|
|
337
|
+
// Track token usage from any event that reports it
|
|
338
|
+
if (event.usage) {
|
|
339
|
+
if (event.usage.input_tokens) totalInputTokens = Math.max(totalInputTokens, event.usage.input_tokens);
|
|
340
|
+
if (event.usage.output_tokens) totalOutputTokens += (event.usage.output_tokens_delta || 0);
|
|
341
|
+
}
|
|
342
|
+
if (event.message?.usage) {
|
|
343
|
+
if (event.message.usage.input_tokens) totalInputTokens = Math.max(totalInputTokens, event.message.usage.input_tokens);
|
|
344
|
+
if (event.message.usage.output_tokens) totalOutputTokens = Math.max(totalOutputTokens, event.message.usage.output_tokens);
|
|
345
|
+
}
|
|
346
|
+
|
|
333
347
|
if (event.type === "assistant" && event.message?.content) {
|
|
334
348
|
for (const block of event.message.content) {
|
|
335
349
|
if (block.type === "text" && block.text.trim()) {
|
|
@@ -342,6 +356,24 @@ export async function runTeam(taskId, opts = {}) {
|
|
|
342
356
|
continue;
|
|
343
357
|
}
|
|
344
358
|
|
|
359
|
+
// Detect TASK_ID announcement from Jane
|
|
360
|
+
const taskIdMatch = text.match(/TASK_ID:\s*(\S+)/);
|
|
361
|
+
if (taskIdMatch && createTask) {
|
|
362
|
+
const newTaskId = taskIdMatch[1];
|
|
363
|
+
taskId = newTaskId;
|
|
364
|
+
// Build task link for the real task
|
|
365
|
+
if (tracker === "linear" && config.linear?.workspace) {
|
|
366
|
+
taskLink = `https://linear.app/${config.linear.workspace}/issue/${newTaskId}`;
|
|
367
|
+
} else if (tracker === "jira" && config.jira?.baseUrl) {
|
|
368
|
+
taskLink = `${config.jira.baseUrl}/browse/${newTaskId}`;
|
|
369
|
+
} else if (tracker === "github") {
|
|
370
|
+
const repo = config.github?.repo || "";
|
|
371
|
+
if (repo) taskLink = `https://github.com/${repo}/issues/${newTaskId}`;
|
|
372
|
+
}
|
|
373
|
+
console.log(`\n # Task: ${newTaskId}${taskLink ? ` (${taskLink})` : ""}\n`);
|
|
374
|
+
vizSend({ type: "session:update", taskId: newTaskId, taskLink, title: description || newTaskId });
|
|
375
|
+
}
|
|
376
|
+
|
|
345
377
|
const textLines = text.split("\n");
|
|
346
378
|
let i = 0;
|
|
347
379
|
while (i < textLines.length) {
|
|
@@ -418,10 +450,16 @@ export async function runTeam(taskId, opts = {}) {
|
|
|
418
450
|
}
|
|
419
451
|
|
|
420
452
|
if (event.type === "result") {
|
|
453
|
+
// Final usage from result event
|
|
454
|
+
if (event.usage) {
|
|
455
|
+
if (event.usage.input_tokens) totalInputTokens = Math.max(totalInputTokens, event.usage.input_tokens);
|
|
456
|
+
if (event.usage.output_tokens) totalOutputTokens = Math.max(totalOutputTokens, event.usage.output_tokens);
|
|
457
|
+
}
|
|
458
|
+
const totalTokens = totalInputTokens + totalOutputTokens;
|
|
421
459
|
const totalTime = ((Date.now() - startTime) / 1000).toFixed(1);
|
|
422
460
|
console.log(`\n━━━ DONE ━━━`);
|
|
423
|
-
console.log(` ${totalTime}s | ${stepCount} steps\n`);
|
|
424
|
-
vizSend({ type: "session:end", duration: `${totalTime}s`, steps: stepCount });
|
|
461
|
+
console.log(` ${totalTime}s | ${stepCount} steps${totalTokens ? ` | ${totalTokens.toLocaleString()} tokens` : ""}\n`);
|
|
462
|
+
vizSend({ type: "session:end", duration: `${totalTime}s`, steps: stepCount, inputTokens: totalInputTokens, outputTokens: totalOutputTokens });
|
|
425
463
|
clearInterval(inboxTimer);
|
|
426
464
|
setTimeout(() => { try { vizWs?.close(); } catch {} }, 500);
|
|
427
465
|
}
|