agent-relay-runner 0.78.5 → 0.78.7
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "agent-relay-runner",
|
|
3
|
-
"version": "0.78.
|
|
3
|
+
"version": "0.78.7",
|
|
4
4
|
"description": "Unified provider lifecycle runner for Agent Relay",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"directory": "runner"
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"agent-relay-sdk": "0.2.
|
|
23
|
+
"agent-relay-sdk": "0.2.57"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
26
|
"@types/bun": "latest",
|
|
@@ -1,16 +1,20 @@
|
|
|
1
1
|
type EmitAgentMessage = (body: string) => void;
|
|
2
|
+
type ResponseEntry = { itemId?: string; body: string };
|
|
3
|
+
type CompleteItemOptions = { includeInResponse?: boolean; phase?: unknown };
|
|
2
4
|
|
|
3
5
|
export class CodexAgentMessageCapture {
|
|
4
|
-
private segments:
|
|
5
|
-
private currentSegment:
|
|
6
|
+
private segments: ResponseEntry[][] = [];
|
|
7
|
+
private currentSegment: ResponseEntry[] = [];
|
|
6
8
|
private readonly buffers = new Map<string, string>();
|
|
7
9
|
private readonly flushedLengths = new Map<string, number>();
|
|
10
|
+
private readonly responseRecordedLengths = new Map<string, number>();
|
|
8
11
|
|
|
9
12
|
reset(): void {
|
|
10
13
|
this.segments = [];
|
|
11
14
|
this.currentSegment = [];
|
|
12
15
|
this.buffers.clear();
|
|
13
16
|
this.flushedLengths.clear();
|
|
17
|
+
this.responseRecordedLengths.clear();
|
|
14
18
|
}
|
|
15
19
|
|
|
16
20
|
appendDelta(itemId: string | undefined, delta: string): void {
|
|
@@ -18,8 +22,14 @@ export class CodexAgentMessageCapture {
|
|
|
18
22
|
this.buffers.set(itemId, `${this.buffers.get(itemId) ?? ""}${delta}`);
|
|
19
23
|
}
|
|
20
24
|
|
|
21
|
-
completeItem(itemId: string | undefined, text: string | undefined, emit: EmitAgentMessage): void {
|
|
22
|
-
|
|
25
|
+
completeItem(itemId: string | undefined, text: string | undefined, emit: EmitAgentMessage, options: CompleteItemOptions = {}): void {
|
|
26
|
+
const fullText = text ?? (itemId ? this.buffers.get(itemId) : undefined);
|
|
27
|
+
this.flushText(itemId, fullText, emit);
|
|
28
|
+
if (options.includeInResponse === false || options.phase === "commentary") {
|
|
29
|
+
this.forgetResponseItem(itemId);
|
|
30
|
+
} else {
|
|
31
|
+
this.recordResponseText(itemId, fullText);
|
|
32
|
+
}
|
|
23
33
|
if (!itemId) return;
|
|
24
34
|
this.buffers.delete(itemId);
|
|
25
35
|
this.flushedLengths.delete(itemId);
|
|
@@ -36,11 +46,14 @@ export class CodexAgentMessageCapture {
|
|
|
36
46
|
this.closeSegment(emit);
|
|
37
47
|
const finalSegment = this.segments.at(-1);
|
|
38
48
|
this.segments = [];
|
|
39
|
-
return finalSegment?.length ? finalSegment.join("\n\n").trim() : undefined;
|
|
49
|
+
return finalSegment?.length ? finalSegment.map((entry) => entry.body).join("\n\n").trim() : undefined;
|
|
40
50
|
}
|
|
41
51
|
|
|
42
52
|
private flushPending(emit: EmitAgentMessage): void {
|
|
43
|
-
for (const [itemId, text] of [...this.buffers.entries()])
|
|
53
|
+
for (const [itemId, text] of [...this.buffers.entries()]) {
|
|
54
|
+
this.flushText(itemId, text, emit);
|
|
55
|
+
this.recordResponseText(itemId, text);
|
|
56
|
+
}
|
|
44
57
|
}
|
|
45
58
|
|
|
46
59
|
private flushText(itemId: string | undefined, text: string | undefined, emit: EmitAgentMessage): void {
|
|
@@ -50,7 +63,30 @@ export class CodexAgentMessageCapture {
|
|
|
50
63
|
if (itemId) this.flushedLengths.set(itemId, text.length);
|
|
51
64
|
const body = chunk.trim();
|
|
52
65
|
if (!body) return;
|
|
53
|
-
this.currentSegment.push(body);
|
|
54
66
|
emit(body);
|
|
55
67
|
}
|
|
68
|
+
|
|
69
|
+
private recordResponseText(itemId: string | undefined, text: string | undefined): void {
|
|
70
|
+
if (!text) return;
|
|
71
|
+
const body = text.trim();
|
|
72
|
+
if (!body) return;
|
|
73
|
+
if (itemId) {
|
|
74
|
+
const offset = this.responseRecordedLengths.get(itemId) ?? 0;
|
|
75
|
+
const chunk = text.slice(offset).trim();
|
|
76
|
+
this.responseRecordedLengths.set(itemId, text.length);
|
|
77
|
+
if (!chunk) return;
|
|
78
|
+
this.currentSegment.push({ itemId, body: chunk });
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
this.currentSegment.push({ body });
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
private forgetResponseItem(itemId: string | undefined): void {
|
|
85
|
+
if (!itemId) return;
|
|
86
|
+
this.responseRecordedLengths.delete(itemId);
|
|
87
|
+
this.currentSegment = this.currentSegment.filter((entry) => entry.itemId !== itemId);
|
|
88
|
+
this.segments = this.segments
|
|
89
|
+
.map((segment) => segment.filter((entry) => entry.itemId !== itemId))
|
|
90
|
+
.filter((segment) => segment.length > 0);
|
|
91
|
+
}
|
|
56
92
|
}
|
package/src/adapters/codex.ts
CHANGED
|
@@ -504,7 +504,7 @@ export class CodexAdapter implements ProviderAdapter {
|
|
|
504
504
|
// buffered reasoning first so it lands in transcript order, ahead of this tool/message.
|
|
505
505
|
if (type !== "reasoning") this.flushBufferedReasoning();
|
|
506
506
|
if (type === "agentMessage") {
|
|
507
|
-
this.agentMessageCapture.completeItem(itemId, stringValue(item.text), (body) => this.emitAgentNarration(body));
|
|
507
|
+
this.agentMessageCapture.completeItem(itemId, stringValue(item.text), (body) => this.emitAgentNarration(body), { phase: item.phase });
|
|
508
508
|
return;
|
|
509
509
|
}
|
|
510
510
|
if (type === "userMessage") {
|