@agentex/agent 0.0.33 → 0.0.35
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/CHANGELOG.md +204 -0
- package/README.md +2 -1
- package/dist/providers/claude/discovery.d.ts +64 -0
- package/dist/providers/claude/discovery.d.ts.map +1 -0
- package/dist/providers/claude/discovery.js +147 -0
- package/dist/providers/claude/discovery.js.map +1 -0
- package/dist/providers/claude/effort.d.ts +20 -0
- package/dist/providers/claude/effort.d.ts.map +1 -0
- package/dist/providers/claude/effort.js +32 -0
- package/dist/providers/claude/effort.js.map +1 -0
- package/dist/providers/claude/execute.d.ts.map +1 -1
- package/dist/providers/claude/execute.js +2 -1
- package/dist/providers/claude/execute.js.map +1 -1
- package/dist/providers/claude/index.d.ts.map +1 -1
- package/dist/providers/claude/index.js +2 -1
- package/dist/providers/claude/index.js.map +1 -1
- package/dist/providers/claude/parse.d.ts.map +1 -1
- package/dist/providers/claude/parse.js +26 -4
- package/dist/providers/claude/parse.js.map +1 -1
- package/dist/providers/claude/session.d.ts.map +1 -1
- package/dist/providers/claude/session.js +2 -1
- package/dist/providers/claude/session.js.map +1 -1
- package/dist/providers/codex/discovery.d.ts +20 -0
- package/dist/providers/codex/discovery.d.ts.map +1 -0
- package/dist/providers/codex/discovery.js +76 -0
- package/dist/providers/codex/discovery.js.map +1 -0
- package/dist/providers/codex/execute.d.ts.map +1 -1
- package/dist/providers/codex/execute.js +45 -3
- package/dist/providers/codex/execute.js.map +1 -1
- package/dist/providers/codex/index.d.ts.map +1 -1
- package/dist/providers/codex/index.js +2 -1
- package/dist/providers/codex/index.js.map +1 -1
- package/dist/providers/codex/parse.d.ts +14 -6
- package/dist/providers/codex/parse.d.ts.map +1 -1
- package/dist/providers/codex/parse.js +83 -1
- package/dist/providers/codex/parse.js.map +1 -1
- package/dist/providers/codex/session.d.ts +50 -1
- package/dist/providers/codex/session.d.ts.map +1 -1
- package/dist/providers/codex/session.js +611 -46
- package/dist/providers/codex/session.js.map +1 -1
- package/dist/providers/cursor/discovery.d.ts.map +1 -1
- package/dist/providers/cursor/discovery.js +4 -0
- package/dist/providers/cursor/discovery.js.map +1 -1
- package/dist/providers/opencode/discovery.d.ts.map +1 -1
- package/dist/providers/opencode/discovery.js +11 -8
- package/dist/providers/opencode/discovery.js.map +1 -1
- package/dist/providers/opencode/event-parse.d.ts +23 -0
- package/dist/providers/opencode/event-parse.d.ts.map +1 -1
- package/dist/providers/opencode/event-parse.js +44 -0
- package/dist/providers/opencode/event-parse.js.map +1 -1
- package/dist/providers/opencode/history.d.ts.map +1 -1
- package/dist/providers/opencode/history.js +25 -4
- package/dist/providers/opencode/history.js.map +1 -1
- package/dist/providers/opencode/http-session.d.ts.map +1 -1
- package/dist/providers/opencode/http-session.js +59 -8
- package/dist/providers/opencode/http-session.js.map +1 -1
- package/dist/types.d.ts +19 -5
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/model-cache.d.ts +33 -0
- package/dist/utils/model-cache.d.ts.map +1 -0
- package/dist/utils/model-cache.js +57 -0
- package/dist/utils/model-cache.js.map +1 -0
- package/package.json +1 -1
- package/src/providers/claude/discovery.ts +215 -0
- package/src/providers/claude/effort.ts +34 -0
- package/src/providers/claude/execute.ts +2 -1
- package/src/providers/claude/index.ts +2 -1
- package/src/providers/claude/parse.ts +27 -5
- package/src/providers/claude/session.ts +2 -1
- package/src/providers/codex/discovery.ts +91 -0
- package/src/providers/codex/execute.ts +42 -3
- package/src/providers/codex/index.ts +2 -1
- package/src/providers/codex/parse.ts +95 -3
- package/src/providers/codex/session.ts +691 -48
- package/src/providers/cursor/discovery.ts +5 -0
- package/src/providers/opencode/discovery.ts +10 -7
- package/src/providers/opencode/event-parse.ts +63 -0
- package/src/providers/opencode/history.ts +32 -4
- package/src/providers/opencode/http-session.ts +59 -8
- package/src/types.ts +19 -5
- package/src/utils/model-cache.ts +67 -0
|
@@ -64,6 +64,28 @@ function parseObject(value: unknown): Record<string, unknown> {
|
|
|
64
64
|
return {};
|
|
65
65
|
}
|
|
66
66
|
|
|
67
|
+
function parseStringArray(value: unknown): string[] {
|
|
68
|
+
return Array.isArray(value)
|
|
69
|
+
? value.filter((entry): entry is string => typeof entry === "string" && entry.length > 0)
|
|
70
|
+
: [];
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
function codexBackgroundTaskState(
|
|
74
|
+
value: unknown,
|
|
75
|
+
): { phase: "started" | "completed"; status: "running" | "completed" | "failed" | "stopped"; summary: string | null } {
|
|
76
|
+
const state = parseObject(value);
|
|
77
|
+
const nativeStatus = asString(state["status"], "");
|
|
78
|
+
const summary = asNullableString(state["message"]);
|
|
79
|
+
if (nativeStatus === "completed") return { phase: "completed", status: "completed", summary };
|
|
80
|
+
if (nativeStatus === "errored" || nativeStatus === "notFound") {
|
|
81
|
+
return { phase: "completed", status: "failed", summary };
|
|
82
|
+
}
|
|
83
|
+
if (nativeStatus === "interrupted" || nativeStatus === "shutdown") {
|
|
84
|
+
return { phase: "completed", status: "stopped", summary };
|
|
85
|
+
}
|
|
86
|
+
return { phase: "started", status: "running", summary };
|
|
87
|
+
}
|
|
88
|
+
|
|
67
89
|
/**
|
|
68
90
|
* Build base fields. For Codex, `eventId` is always null (neither wire
|
|
69
91
|
* format emits a per-line UUID). `sessionId` and `turnId` come from the
|
|
@@ -232,10 +254,10 @@ export function parseCodexJsonl(stdout: string): CodexParsedResult {
|
|
|
232
254
|
* v2 parses it from `params.threadId` directly and
|
|
233
255
|
* ignores this arg.
|
|
234
256
|
*/
|
|
235
|
-
|
|
257
|
+
function parseCodexStreamLineRaw(
|
|
236
258
|
line: string,
|
|
237
259
|
sessionId: string | null = null,
|
|
238
|
-
): StreamEvent | null {
|
|
260
|
+
): StreamEvent | StreamEvent[] | null {
|
|
239
261
|
const event = parseJson(line);
|
|
240
262
|
if (!event) return null;
|
|
241
263
|
|
|
@@ -252,7 +274,7 @@ export function parseCodexStreamLine(
|
|
|
252
274
|
// v2 JSON-RPC notifications (codex --json app-server mode)
|
|
253
275
|
// ---------------------------------------------------------------------------
|
|
254
276
|
|
|
255
|
-
function parseV2Notification(event: Record<string, unknown>): StreamEvent | null {
|
|
277
|
+
function parseV2Notification(event: Record<string, unknown>): StreamEvent | StreamEvent[] | null {
|
|
256
278
|
const method = asString(event["method"], "");
|
|
257
279
|
const params = parseObject(event["params"]);
|
|
258
280
|
|
|
@@ -435,6 +457,44 @@ function parseV2Notification(event: Record<string, unknown>): StreamEvent | null
|
|
|
435
457
|
...base,
|
|
436
458
|
};
|
|
437
459
|
}
|
|
460
|
+
if (itemType === "collabAgentToolCall") {
|
|
461
|
+
const tool = asString(item["tool"], "");
|
|
462
|
+
const states = parseObject(item["agentsStates"]);
|
|
463
|
+
// Every receiver, not just the first. One collab call can spawn a fan-out
|
|
464
|
+
// of children, and taking `[0]` reported one of them while the rest never
|
|
465
|
+
// existed as far as the host could tell. The session path already
|
|
466
|
+
// iterates all of them; this keeps the one-shot path consistent.
|
|
467
|
+
const taskIds = [...new Set([
|
|
468
|
+
...parseStringArray(item["receiverThreadIds"]),
|
|
469
|
+
...Object.keys(states),
|
|
470
|
+
])];
|
|
471
|
+
// A completed spawnAgent call means the child exists, not that the
|
|
472
|
+
// child's own turn is complete. Its state (usually pendingInit) and a
|
|
473
|
+
// later thread/read response carry the child lifecycle.
|
|
474
|
+
const tracked = taskIds.filter((id) => id && (tool === "spawnAgent" || id in states));
|
|
475
|
+
if (tracked.length === 0) {
|
|
476
|
+
return {
|
|
477
|
+
type: "unknown",
|
|
478
|
+
subtype: `item/completed:${itemType}`,
|
|
479
|
+
...base,
|
|
480
|
+
};
|
|
481
|
+
}
|
|
482
|
+
const description = asNullableString(item["prompt"]);
|
|
483
|
+
return tracked.map((taskId) => {
|
|
484
|
+
const state = codexBackgroundTaskState(states[taskId]);
|
|
485
|
+
return {
|
|
486
|
+
type: "background_task" as const,
|
|
487
|
+
taskId,
|
|
488
|
+
taskType: "subagent" as const,
|
|
489
|
+
phase: state.phase,
|
|
490
|
+
status: state.status,
|
|
491
|
+
description,
|
|
492
|
+
summary: state.summary,
|
|
493
|
+
parentTaskId: null,
|
|
494
|
+
...base,
|
|
495
|
+
};
|
|
496
|
+
});
|
|
497
|
+
}
|
|
438
498
|
if (itemType === "userMessage") {
|
|
439
499
|
// Consumer persists user input on the write path before calling send().
|
|
440
500
|
// We don't re-emit it here to keep a single source of truth.
|
|
@@ -510,6 +570,38 @@ function parseV2Notification(event: Record<string, unknown>): StreamEvent | null
|
|
|
510
570
|
};
|
|
511
571
|
}
|
|
512
572
|
|
|
573
|
+
/**
|
|
574
|
+
* Every event a single Codex stream line produces.
|
|
575
|
+
*
|
|
576
|
+
* One line is usually one event, but a collab tool call addressed to several
|
|
577
|
+
* receiver threads describes several children at once, and each needs its own
|
|
578
|
+
* `background_task` edge or the host never learns those children exist.
|
|
579
|
+
*/
|
|
580
|
+
export function parseCodexStreamLines(
|
|
581
|
+
line: string,
|
|
582
|
+
sessionId: string | null = null,
|
|
583
|
+
): StreamEvent[] {
|
|
584
|
+
const parsed = parseCodexStreamLineRaw(line, sessionId);
|
|
585
|
+
if (parsed === null) return [];
|
|
586
|
+
return Array.isArray(parsed) ? parsed : [parsed];
|
|
587
|
+
}
|
|
588
|
+
|
|
589
|
+
/**
|
|
590
|
+
* First event only.
|
|
591
|
+
*
|
|
592
|
+
* @internal
|
|
593
|
+
* @deprecated Use {@link parseCodexStreamLines}. This exists for tests that
|
|
594
|
+
* assert on a single event; on a collab fan-out it discards every child after
|
|
595
|
+
* the first, which is the bug `parseCodexStreamLines` was added to fix. It is
|
|
596
|
+
* not re-exported from the package root and has no production callers.
|
|
597
|
+
*/
|
|
598
|
+
export function parseCodexStreamLine(
|
|
599
|
+
line: string,
|
|
600
|
+
sessionId: string | null = null,
|
|
601
|
+
): StreamEvent | null {
|
|
602
|
+
return parseCodexStreamLines(line, sessionId)[0] ?? null;
|
|
603
|
+
}
|
|
604
|
+
|
|
513
605
|
function extractReasoningText(item: Record<string, unknown>): string {
|
|
514
606
|
// Codex reasoning items carry summary and content arrays. Concatenate
|
|
515
607
|
// any visible text fragments for display; fall back to "" if all empty
|