@agentex/agent 0.0.31 → 0.0.33

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.
Files changed (40) hide show
  1. package/CHANGELOG.md +63 -0
  2. package/README.md +30 -5
  3. package/dist/index.d.ts +1 -1
  4. package/dist/index.d.ts.map +1 -1
  5. package/dist/index.js.map +1 -1
  6. package/dist/providers/claude/index.d.ts.map +1 -1
  7. package/dist/providers/claude/index.js +1 -0
  8. package/dist/providers/claude/index.js.map +1 -1
  9. package/dist/providers/claude/parse.d.ts +4 -6
  10. package/dist/providers/claude/parse.d.ts.map +1 -1
  11. package/dist/providers/claude/parse.js +79 -25
  12. package/dist/providers/claude/parse.js.map +1 -1
  13. package/dist/providers/codex/history.d.ts.map +1 -1
  14. package/dist/providers/codex/history.js +3 -1
  15. package/dist/providers/codex/history.js.map +1 -1
  16. package/dist/providers/codex/index.d.ts.map +1 -1
  17. package/dist/providers/codex/index.js +1 -0
  18. package/dist/providers/codex/index.js.map +1 -1
  19. package/dist/providers/codex/parse.d.ts.map +1 -1
  20. package/dist/providers/codex/parse.js +37 -5
  21. package/dist/providers/codex/parse.js.map +1 -1
  22. package/dist/providers/codex/session.d.ts +56 -1
  23. package/dist/providers/codex/session.d.ts.map +1 -1
  24. package/dist/providers/codex/session.js +400 -18
  25. package/dist/providers/codex/session.js.map +1 -1
  26. package/dist/providers/codex/transcript-normalize.js +10 -1
  27. package/dist/providers/codex/transcript-normalize.js.map +1 -1
  28. package/dist/types.d.ts +35 -0
  29. package/dist/types.d.ts.map +1 -1
  30. package/dist/types.js.map +1 -1
  31. package/package.json +1 -1
  32. package/src/index.ts +3 -0
  33. package/src/providers/claude/index.ts +1 -0
  34. package/src/providers/claude/parse.ts +81 -23
  35. package/src/providers/codex/history.ts +3 -1
  36. package/src/providers/codex/index.ts +1 -0
  37. package/src/providers/codex/parse.ts +38 -5
  38. package/src/providers/codex/session.ts +431 -18
  39. package/src/providers/codex/transcript-normalize.ts +11 -1
  40. package/src/types.ts +48 -1
@@ -53,6 +53,10 @@ function asNullableNumber(value: unknown): number | null {
53
53
  return typeof value === "number" && Number.isFinite(value) ? value : null;
54
54
  }
55
55
 
56
+ function asMessagePhase(value: unknown): "commentary" | "final_answer" | undefined {
57
+ return value === "commentary" || value === "final_answer" ? value : undefined;
58
+ }
59
+
56
60
  function parseObject(value: unknown): Record<string, unknown> {
57
61
  if (typeof value === "object" && value !== null && !Array.isArray(value)) {
58
62
  return value as Record<string, unknown>;
@@ -333,10 +337,11 @@ function parseV2Notification(event: Record<string, unknown>): StreamEvent | null
333
337
  asNullableString(item["id"]) ??
334
338
  asNullableString(item["call_id"]);
335
339
  const base = makeBase(itemId);
340
+ const isCommandExecution = itemType === "command_execution" || itemType === "commandExecution";
336
341
 
337
342
  // Tool starts — emit tool_call on item/started only.
338
343
  if (method === "item/started") {
339
- if (itemType === "command_execution") {
344
+ if (isCommandExecution) {
340
345
  return {
341
346
  type: "tool_call",
342
347
  toolCallId: itemId,
@@ -359,14 +364,15 @@ function parseV2Notification(event: Record<string, unknown>): StreamEvent | null
359
364
  }
360
365
 
361
366
  // item/completed — emit the terminal event for each item type.
362
- if (itemType === "command_execution") {
363
- const exitCode = asNullableNumber(item["exit_code"]);
367
+ if (isCommandExecution) {
368
+ const exitCode = asNullableNumber(item["exit_code"] ?? item["exitCode"]);
369
+ const status = asString(item["status"], "");
364
370
  return {
365
371
  type: "tool_result",
366
372
  toolCallId: itemId,
367
373
  toolName: "command_execution",
368
- content: asString(item["aggregated_output"], ""),
369
- isError: exitCode !== null && exitCode !== 0,
374
+ content: asString(item["aggregated_output"], asString(item["aggregatedOutput"], "")),
375
+ isError: status === "failed" || status === "declined" || (exitCode !== null && exitCode !== 0),
370
376
  exitCode,
371
377
  ...base,
372
378
  };
@@ -386,9 +392,11 @@ function parseV2Notification(event: Record<string, unknown>): StreamEvent | null
386
392
  if (itemType === "agentMessage") {
387
393
  const directText = asString(item["text"], "");
388
394
  if (directText || directText === "") {
395
+ const phase = asMessagePhase(item["phase"]);
389
396
  return {
390
397
  type: "assistant",
391
398
  text: directText,
399
+ ...(phase ? { phase } : {}),
392
400
  ...base,
393
401
  };
394
402
  }
@@ -405,6 +413,28 @@ function parseV2Notification(event: Record<string, unknown>): StreamEvent | null
405
413
  ...base,
406
414
  };
407
415
  }
416
+ if (itemType === "subAgentActivity") {
417
+ const taskId = asString(item["agentThreadId"], "");
418
+ const kind = asString(item["kind"], "");
419
+ if (!taskId || (kind !== "started" && kind !== "interacted" && kind !== "interrupted")) {
420
+ return {
421
+ type: "unknown",
422
+ subtype: `item/completed:${itemType}`,
423
+ ...base,
424
+ };
425
+ }
426
+ return {
427
+ type: "background_task",
428
+ taskId,
429
+ taskType: "subagent",
430
+ phase: kind === "started" ? "started" : kind === "interrupted" ? "completed" : "progress",
431
+ status: kind === "interrupted" ? "stopped" : "running",
432
+ description: asNullableString(item["agentPath"]),
433
+ summary: null,
434
+ parentTaskId: null,
435
+ ...base,
436
+ };
437
+ }
408
438
  if (itemType === "userMessage") {
409
439
  // Consumer persists user input on the write path before calling send().
410
440
  // We don't re-emit it here to keep a single source of truth.
@@ -575,11 +605,13 @@ function parseNdjsonEvent(
575
605
  };
576
606
  }
577
607
  if (itemType === "agent_message") {
608
+ const phase = asMessagePhase(item["phase"]);
578
609
  const directText = asString(item["text"], "");
579
610
  if (directText) {
580
611
  return {
581
612
  type: "assistant",
582
613
  text: directText,
614
+ ...(phase ? { phase } : {}),
583
615
  ...base,
584
616
  };
585
617
  }
@@ -591,6 +623,7 @@ function parseNdjsonEvent(
591
623
  return {
592
624
  type: "assistant",
593
625
  text: asString(block["text"], ""),
626
+ ...(phase ? { phase } : {}),
594
627
  ...base,
595
628
  };
596
629
  }