@autohq/cli 0.1.590 → 0.1.591
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/agent-bridge.js +422 -43
- package/dist/index.js +432 -44
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -17043,6 +17043,48 @@ var init_claude_code = __esm({
|
|
|
17043
17043
|
}
|
|
17044
17044
|
});
|
|
17045
17045
|
|
|
17046
|
+
// ../../packages/schemas/src/transcript-activity.ts
|
|
17047
|
+
function transcriptMessagePhaseProviderMetadata(phase) {
|
|
17048
|
+
return phase ? { auto: { messagePhase: phase } } : void 0;
|
|
17049
|
+
}
|
|
17050
|
+
var TranscriptActivitySchema, TranscriptToolMetadataSchema, TranscriptMessagePhaseSchema;
|
|
17051
|
+
var init_transcript_activity = __esm({
|
|
17052
|
+
"../../packages/schemas/src/transcript-activity.ts"() {
|
|
17053
|
+
"use strict";
|
|
17054
|
+
init_zod();
|
|
17055
|
+
TranscriptActivitySchema = external_exports.discriminatedUnion("type", [
|
|
17056
|
+
external_exports.object({
|
|
17057
|
+
type: external_exports.literal("read"),
|
|
17058
|
+
path: external_exports.string(),
|
|
17059
|
+
name: external_exports.string().optional()
|
|
17060
|
+
}),
|
|
17061
|
+
external_exports.object({
|
|
17062
|
+
type: external_exports.literal("list"),
|
|
17063
|
+
path: external_exports.string().nullable()
|
|
17064
|
+
}),
|
|
17065
|
+
external_exports.object({
|
|
17066
|
+
type: external_exports.literal("search"),
|
|
17067
|
+
path: external_exports.string().nullable(),
|
|
17068
|
+
query: external_exports.string().nullable()
|
|
17069
|
+
}),
|
|
17070
|
+
external_exports.object({
|
|
17071
|
+
type: external_exports.literal("run"),
|
|
17072
|
+
command: external_exports.string()
|
|
17073
|
+
})
|
|
17074
|
+
]);
|
|
17075
|
+
TranscriptToolMetadataSchema = external_exports.object({
|
|
17076
|
+
activities: external_exports.array(TranscriptActivitySchema).optional(),
|
|
17077
|
+
durationMs: external_exports.number().nonnegative().optional(),
|
|
17078
|
+
exitCode: external_exports.number().optional(),
|
|
17079
|
+
status: external_exports.string().optional()
|
|
17080
|
+
}).passthrough();
|
|
17081
|
+
TranscriptMessagePhaseSchema = external_exports.enum([
|
|
17082
|
+
"commentary",
|
|
17083
|
+
"final_answer"
|
|
17084
|
+
]);
|
|
17085
|
+
}
|
|
17086
|
+
});
|
|
17087
|
+
|
|
17046
17088
|
// ../../packages/schemas/src/codex.ts
|
|
17047
17089
|
function parseCodexServerFrame(raw) {
|
|
17048
17090
|
const frame = CodexFrameSchema.parse(raw);
|
|
@@ -17125,6 +17167,53 @@ function parseNotification(method, params) {
|
|
|
17125
17167
|
delta: parsed.data.delta
|
|
17126
17168
|
} : null;
|
|
17127
17169
|
}
|
|
17170
|
+
case "item/reasoning/summaryPartAdded": {
|
|
17171
|
+
const parsed = external_exports.object({
|
|
17172
|
+
threadId: external_exports.string(),
|
|
17173
|
+
turnId: external_exports.string(),
|
|
17174
|
+
itemId: external_exports.string(),
|
|
17175
|
+
summaryIndex: external_exports.number().int().nonnegative()
|
|
17176
|
+
}).passthrough().safeParse(params);
|
|
17177
|
+
return parsed.success ? {
|
|
17178
|
+
type: "reasoningSummaryPartAdded",
|
|
17179
|
+
threadId: parsed.data.threadId,
|
|
17180
|
+
turnId: parsed.data.turnId,
|
|
17181
|
+
itemId: parsed.data.itemId,
|
|
17182
|
+
summaryIndex: parsed.data.summaryIndex
|
|
17183
|
+
} : null;
|
|
17184
|
+
}
|
|
17185
|
+
case "item/reasoning/summaryTextDelta": {
|
|
17186
|
+
const parsed = external_exports.object({
|
|
17187
|
+
threadId: external_exports.string(),
|
|
17188
|
+
turnId: external_exports.string(),
|
|
17189
|
+
itemId: external_exports.string(),
|
|
17190
|
+
summaryIndex: external_exports.number().int().nonnegative(),
|
|
17191
|
+
delta: external_exports.string()
|
|
17192
|
+
}).passthrough().safeParse(params);
|
|
17193
|
+
return parsed.success ? {
|
|
17194
|
+
type: "reasoningSummaryTextDelta",
|
|
17195
|
+
threadId: parsed.data.threadId,
|
|
17196
|
+
turnId: parsed.data.turnId,
|
|
17197
|
+
itemId: parsed.data.itemId,
|
|
17198
|
+
summaryIndex: parsed.data.summaryIndex,
|
|
17199
|
+
delta: parsed.data.delta
|
|
17200
|
+
} : null;
|
|
17201
|
+
}
|
|
17202
|
+
case "item/commandExecution/outputDelta": {
|
|
17203
|
+
const parsed = external_exports.object({
|
|
17204
|
+
threadId: external_exports.string(),
|
|
17205
|
+
turnId: external_exports.string(),
|
|
17206
|
+
itemId: external_exports.string(),
|
|
17207
|
+
delta: external_exports.string()
|
|
17208
|
+
}).passthrough().safeParse(params);
|
|
17209
|
+
return parsed.success ? {
|
|
17210
|
+
type: "commandExecutionOutputDelta",
|
|
17211
|
+
threadId: parsed.data.threadId,
|
|
17212
|
+
turnId: parsed.data.turnId,
|
|
17213
|
+
itemId: parsed.data.itemId,
|
|
17214
|
+
delta: parsed.data.delta
|
|
17215
|
+
} : null;
|
|
17216
|
+
}
|
|
17128
17217
|
case "error": {
|
|
17129
17218
|
const parsed = external_exports.object({
|
|
17130
17219
|
error: external_exports.object({ message: external_exports.string() }).passthrough(),
|
|
@@ -17187,13 +17276,14 @@ function parseApprovalRequest(method, requestId, params) {
|
|
|
17187
17276
|
return null;
|
|
17188
17277
|
}
|
|
17189
17278
|
}
|
|
17190
|
-
var CodexRequestIdSchema, CodexTurnStatusSchema, CodexUserMessageItemSchema, CodexAgentMessageItemSchema, CodexReasoningItemSchema, CodexCommandExecutionItemSchema, CodexFileChangeItemSchema, CodexMcpToolCallItemSchema, CodexItemSchema, OptionalCodexItemSchema, CodexItemEnvelopeSchema, CodexTurnEnvelopeSchema, CodexTokenUsageSchema, CodexTokenUsageEnvelopeSchema, CodexFrameSchema, APPROVE_OPTION_LABEL, DECLINE_OPTION_LABEL;
|
|
17279
|
+
var CodexRequestIdSchema, CodexTurnStatusSchema, CodexUserMessageItemSchema, CodexAgentMessageItemSchema, CodexReasoningItemSchema, CodexCommandActionSchema, CodexCommandExecutionItemSchema, CodexFileChangeItemSchema, CodexMcpToolCallItemSchema, CodexItemSchema, OptionalCodexItemSchema, CodexItemEnvelopeSchema, CodexTurnEnvelopeSchema, CodexTokenUsageSchema, CodexTokenUsageEnvelopeSchema, CodexFrameSchema, APPROVE_OPTION_LABEL, DECLINE_OPTION_LABEL;
|
|
17191
17280
|
var init_codex = __esm({
|
|
17192
17281
|
"../../packages/schemas/src/codex.ts"() {
|
|
17193
17282
|
"use strict";
|
|
17194
17283
|
init_zod();
|
|
17195
17284
|
init_primitives();
|
|
17196
17285
|
init_tool_errors();
|
|
17286
|
+
init_transcript_activity();
|
|
17197
17287
|
CodexRequestIdSchema = external_exports.union([external_exports.string(), external_exports.number()]);
|
|
17198
17288
|
CodexTurnStatusSchema = external_exports.enum([
|
|
17199
17289
|
"completed",
|
|
@@ -17205,21 +17295,47 @@ var init_codex = __esm({
|
|
|
17205
17295
|
CodexAgentMessageItemSchema = external_exports.object({
|
|
17206
17296
|
type: external_exports.literal("agentMessage"),
|
|
17207
17297
|
id: external_exports.string(),
|
|
17208
|
-
text: external_exports.string().default("")
|
|
17298
|
+
text: external_exports.string().default(""),
|
|
17299
|
+
phase: TranscriptMessagePhaseSchema.nullish()
|
|
17209
17300
|
}).passthrough();
|
|
17210
17301
|
CodexReasoningItemSchema = external_exports.object({
|
|
17211
17302
|
type: external_exports.literal("reasoning"),
|
|
17212
17303
|
id: external_exports.string(),
|
|
17213
17304
|
summary: external_exports.array(external_exports.string()).default([])
|
|
17214
17305
|
}).passthrough();
|
|
17306
|
+
CodexCommandActionSchema = external_exports.discriminatedUnion("type", [
|
|
17307
|
+
external_exports.object({
|
|
17308
|
+
type: external_exports.literal("read"),
|
|
17309
|
+
command: external_exports.string(),
|
|
17310
|
+
name: external_exports.string(),
|
|
17311
|
+
path: external_exports.string()
|
|
17312
|
+
}).passthrough(),
|
|
17313
|
+
external_exports.object({
|
|
17314
|
+
type: external_exports.literal("listFiles"),
|
|
17315
|
+
command: external_exports.string(),
|
|
17316
|
+
path: external_exports.string().nullable()
|
|
17317
|
+
}).passthrough(),
|
|
17318
|
+
external_exports.object({
|
|
17319
|
+
type: external_exports.literal("search"),
|
|
17320
|
+
command: external_exports.string(),
|
|
17321
|
+
query: external_exports.string().nullable(),
|
|
17322
|
+
path: external_exports.string().nullable()
|
|
17323
|
+
}).passthrough(),
|
|
17324
|
+
external_exports.object({
|
|
17325
|
+
type: external_exports.literal("unknown"),
|
|
17326
|
+
command: external_exports.string()
|
|
17327
|
+
}).passthrough()
|
|
17328
|
+
]);
|
|
17215
17329
|
CodexCommandExecutionItemSchema = external_exports.object({
|
|
17216
17330
|
type: external_exports.literal("commandExecution"),
|
|
17217
17331
|
id: external_exports.string(),
|
|
17218
17332
|
command: external_exports.string().default(""),
|
|
17219
17333
|
cwd: external_exports.string().optional(),
|
|
17220
17334
|
status: external_exports.string().optional(),
|
|
17335
|
+
commandActions: external_exports.array(CodexCommandActionSchema).optional(),
|
|
17221
17336
|
aggregatedOutput: external_exports.string().nullish(),
|
|
17222
|
-
exitCode: external_exports.number().nullish()
|
|
17337
|
+
exitCode: external_exports.number().nullish(),
|
|
17338
|
+
durationMs: external_exports.number().nonnegative().nullish()
|
|
17223
17339
|
}).passthrough();
|
|
17224
17340
|
CodexFileChangeItemSchema = external_exports.object({
|
|
17225
17341
|
type: external_exports.literal("fileChange"),
|
|
@@ -17235,7 +17351,8 @@ var init_codex = __esm({
|
|
|
17235
17351
|
status: external_exports.string().optional(),
|
|
17236
17352
|
arguments: external_exports.unknown().optional(),
|
|
17237
17353
|
result: external_exports.unknown().nullish(),
|
|
17238
|
-
error: external_exports.object({ message: external_exports.string() }).passthrough().nullish()
|
|
17354
|
+
error: external_exports.object({ message: external_exports.string() }).passthrough().nullish(),
|
|
17355
|
+
durationMs: external_exports.number().nonnegative().nullish()
|
|
17239
17356
|
}).passthrough();
|
|
17240
17357
|
CodexItemSchema = external_exports.discriminatedUnion("type", [
|
|
17241
17358
|
CodexUserMessageItemSchema,
|
|
@@ -87056,6 +87173,7 @@ var init_src = __esm({
|
|
|
87056
87173
|
init_tools();
|
|
87057
87174
|
init_tool_errors();
|
|
87058
87175
|
init_trigger_router();
|
|
87176
|
+
init_transcript_activity();
|
|
87059
87177
|
init_url_slugs();
|
|
87060
87178
|
init_usage();
|
|
87061
87179
|
init_user_subscriptions();
|
|
@@ -89819,7 +89937,7 @@ var init_package = __esm({
|
|
|
89819
89937
|
"package.json"() {
|
|
89820
89938
|
package_default = {
|
|
89821
89939
|
name: "@autohq/cli",
|
|
89822
|
-
version: "0.1.
|
|
89940
|
+
version: "0.1.591",
|
|
89823
89941
|
license: "SEE LICENSE IN README.md",
|
|
89824
89942
|
publishConfig: {
|
|
89825
89943
|
access: "public"
|
|
@@ -103316,7 +103434,10 @@ var UiMessagePartTracker = class {
|
|
|
103316
103434
|
toolCallId: chunk.toolCallId,
|
|
103317
103435
|
toolName: chunk.toolName,
|
|
103318
103436
|
dynamic: chunk.dynamic,
|
|
103319
|
-
state: "input-streaming"
|
|
103437
|
+
state: "input-streaming",
|
|
103438
|
+
title: chunk.title,
|
|
103439
|
+
toolMetadata: chunk.toolMetadata,
|
|
103440
|
+
providerExecuted: chunk.providerExecuted
|
|
103320
103441
|
})
|
|
103321
103442
|
);
|
|
103322
103443
|
this.toolPartIndexByCallId.set(chunk.toolCallId, index);
|
|
@@ -103329,11 +103450,13 @@ var UiMessagePartTracker = class {
|
|
|
103329
103450
|
toolCallId: chunk.toolCallId,
|
|
103330
103451
|
toolName: chunk.toolName,
|
|
103331
103452
|
dynamic: chunk.dynamic,
|
|
103332
|
-
state: pendingApproval ? "approval-requested" : "input-available"
|
|
103453
|
+
state: pendingApproval ? "approval-requested" : "input-available",
|
|
103454
|
+
title: chunk.title,
|
|
103455
|
+
toolMetadata: chunk.toolMetadata,
|
|
103456
|
+
providerExecuted: chunk.providerExecuted
|
|
103333
103457
|
}),
|
|
103334
103458
|
input: chunk.input,
|
|
103335
103459
|
...pendingApproval ? { approval: pendingApproval } : {},
|
|
103336
|
-
...chunk.providerExecuted !== void 0 ? { providerExecuted: chunk.providerExecuted } : {},
|
|
103337
103460
|
...chunk.providerMetadata !== void 0 ? { callProviderMetadata: chunk.providerMetadata } : {}
|
|
103338
103461
|
});
|
|
103339
103462
|
return this.persistable(index);
|
|
@@ -103344,10 +103467,14 @@ var UiMessagePartTracker = class {
|
|
|
103344
103467
|
toolCallId: chunk.toolCallId,
|
|
103345
103468
|
toolName: chunk.toolName,
|
|
103346
103469
|
dynamic: chunk.dynamic,
|
|
103347
|
-
state: "output-error"
|
|
103470
|
+
state: "output-error",
|
|
103471
|
+
title: chunk.title,
|
|
103472
|
+
toolMetadata: chunk.toolMetadata,
|
|
103473
|
+
providerExecuted: chunk.providerExecuted
|
|
103348
103474
|
}),
|
|
103349
103475
|
input: chunk.input,
|
|
103350
|
-
errorText: chunk.errorText
|
|
103476
|
+
errorText: chunk.errorText,
|
|
103477
|
+
...chunk.providerMetadata !== void 0 ? { callProviderMetadata: chunk.providerMetadata } : {}
|
|
103351
103478
|
});
|
|
103352
103479
|
return this.persistable(index);
|
|
103353
103480
|
}
|
|
@@ -103381,6 +103508,15 @@ var UiMessagePartTracker = class {
|
|
|
103381
103508
|
part.state = "output-available";
|
|
103382
103509
|
part.output = chunk.output;
|
|
103383
103510
|
part.preliminary = chunk.preliminary;
|
|
103511
|
+
if (chunk.toolMetadata !== void 0) {
|
|
103512
|
+
part.toolMetadata = chunk.toolMetadata;
|
|
103513
|
+
}
|
|
103514
|
+
if (chunk.providerMetadata !== void 0) {
|
|
103515
|
+
part.resultProviderMetadata = chunk.providerMetadata;
|
|
103516
|
+
}
|
|
103517
|
+
if (chunk.providerExecuted !== void 0) {
|
|
103518
|
+
part.providerExecuted = chunk.providerExecuted;
|
|
103519
|
+
}
|
|
103384
103520
|
this.settleApproval(part, chunk.toolCallId, { approved: true });
|
|
103385
103521
|
return this.persistable(index);
|
|
103386
103522
|
}
|
|
@@ -103408,6 +103544,15 @@ var UiMessagePartTracker = class {
|
|
|
103408
103544
|
}
|
|
103409
103545
|
part.state = "output-error";
|
|
103410
103546
|
part.errorText = chunk.errorText;
|
|
103547
|
+
if (chunk.toolMetadata !== void 0) {
|
|
103548
|
+
part.toolMetadata = chunk.toolMetadata;
|
|
103549
|
+
}
|
|
103550
|
+
if (chunk.providerMetadata !== void 0) {
|
|
103551
|
+
part.resultProviderMetadata = chunk.providerMetadata;
|
|
103552
|
+
}
|
|
103553
|
+
if (chunk.providerExecuted !== void 0) {
|
|
103554
|
+
part.providerExecuted = chunk.providerExecuted;
|
|
103555
|
+
}
|
|
103411
103556
|
this.settleApproval(part, chunk.toolCallId, { approved: true });
|
|
103412
103557
|
return this.persistable(index);
|
|
103413
103558
|
}
|
|
@@ -103539,18 +103684,23 @@ var UiMessagePartTracker = class {
|
|
|
103539
103684
|
}
|
|
103540
103685
|
};
|
|
103541
103686
|
function toolPartShape(input) {
|
|
103687
|
+
const common = {
|
|
103688
|
+
toolCallId: input.toolCallId,
|
|
103689
|
+
state: input.state,
|
|
103690
|
+
...input.title !== void 0 ? { title: input.title } : {},
|
|
103691
|
+
...input.toolMetadata !== void 0 ? { toolMetadata: input.toolMetadata } : {},
|
|
103692
|
+
...input.providerExecuted !== void 0 ? { providerExecuted: input.providerExecuted } : {}
|
|
103693
|
+
};
|
|
103542
103694
|
if (input.dynamic) {
|
|
103543
103695
|
return {
|
|
103544
103696
|
type: "dynamic-tool",
|
|
103545
103697
|
toolName: input.toolName,
|
|
103546
|
-
|
|
103547
|
-
state: input.state
|
|
103698
|
+
...common
|
|
103548
103699
|
};
|
|
103549
103700
|
}
|
|
103550
103701
|
return {
|
|
103551
103702
|
type: `tool-${input.toolName}`,
|
|
103552
|
-
|
|
103553
|
-
state: input.state
|
|
103703
|
+
...common
|
|
103554
103704
|
};
|
|
103555
103705
|
}
|
|
103556
103706
|
function providerMetadataField(providerMetadata) {
|
|
@@ -103829,6 +103979,10 @@ var AgentBridgeOutputBuffer = class {
|
|
|
103829
103979
|
}
|
|
103830
103980
|
await this.flushPendingUiDelta();
|
|
103831
103981
|
this.pendingUiDelta = { context, chunk: { ...chunk }, createdAt: now2() };
|
|
103982
|
+
if (uiDeltaTextLength(chunk) >= AGENT_BRIDGE_OUTPUT_UI_DELTA_MAX_CHARS) {
|
|
103983
|
+
await this.flushPendingUiDelta();
|
|
103984
|
+
return;
|
|
103985
|
+
}
|
|
103832
103986
|
this.scheduleUiDeltaFlush();
|
|
103833
103987
|
}
|
|
103834
103988
|
scheduleUiDeltaFlush() {
|
|
@@ -103871,9 +104025,9 @@ var AgentBridgeOutputBuffer = class {
|
|
|
103871
104025
|
await this.drainPendingOutputs();
|
|
103872
104026
|
}
|
|
103873
104027
|
// Turns the parked coalesced chunk into a queued envelope and applies it to
|
|
103874
|
-
// the part tracker and message assembler
|
|
103875
|
-
//
|
|
103876
|
-
//
|
|
104028
|
+
// the part tracker and message assembler. Text/input deltas concatenate;
|
|
104029
|
+
// preliminary tool output is already cumulative, so only its latest snapshot
|
|
104030
|
+
// is retained before the final result flushes it.
|
|
103877
104031
|
// Does not drain: the drain loop calls this mid-loop and keeps pulling.
|
|
103878
104032
|
async materializePendingUiDelta() {
|
|
103879
104033
|
const pending = this.pendingUiDelta;
|
|
@@ -104240,6 +104394,9 @@ function legacyToolEntries(chunk) {
|
|
|
104240
104394
|
}
|
|
104241
104395
|
];
|
|
104242
104396
|
case "tool-output-available":
|
|
104397
|
+
if (chunk.preliminary) {
|
|
104398
|
+
return [];
|
|
104399
|
+
}
|
|
104243
104400
|
return [
|
|
104244
104401
|
{
|
|
104245
104402
|
role: "tool",
|
|
@@ -104330,6 +104487,12 @@ function coalescibleUiDeltaChunk(projection) {
|
|
|
104330
104487
|
return chunk.providerMetadata === void 0 ? chunk : null;
|
|
104331
104488
|
case "tool-input-delta":
|
|
104332
104489
|
return chunk;
|
|
104490
|
+
case "tool-output-available":
|
|
104491
|
+
return chunk.preliminary === true && typeof chunk.output === "string" ? {
|
|
104492
|
+
...chunk,
|
|
104493
|
+
output: chunk.output,
|
|
104494
|
+
preliminary: true
|
|
104495
|
+
} : null;
|
|
104333
104496
|
default:
|
|
104334
104497
|
return null;
|
|
104335
104498
|
}
|
|
@@ -104341,7 +104504,10 @@ function canCoalesceUiDelta(pending, context, chunk) {
|
|
|
104341
104504
|
if (pending.chunk.type === "tool-input-delta" && chunk.type === "tool-input-delta") {
|
|
104342
104505
|
return pending.chunk.toolCallId === chunk.toolCallId;
|
|
104343
104506
|
}
|
|
104344
|
-
if (pending.chunk.type
|
|
104507
|
+
if (pending.chunk.type === "tool-output-available" && chunk.type === "tool-output-available") {
|
|
104508
|
+
return pending.chunk.toolCallId === chunk.toolCallId;
|
|
104509
|
+
}
|
|
104510
|
+
if ((pending.chunk.type === "text-delta" || pending.chunk.type === "reasoning-delta") && (chunk.type === "text-delta" || chunk.type === "reasoning-delta")) {
|
|
104345
104511
|
return pending.chunk.id === chunk.id;
|
|
104346
104512
|
}
|
|
104347
104513
|
return false;
|
|
@@ -104353,7 +104519,10 @@ function mergeUiDeltaChunks(pending, chunk) {
|
|
|
104353
104519
|
inputTextDelta: pending.inputTextDelta + chunk.inputTextDelta
|
|
104354
104520
|
};
|
|
104355
104521
|
}
|
|
104356
|
-
if (pending.type
|
|
104522
|
+
if (pending.type === "tool-output-available" && chunk.type === "tool-output-available") {
|
|
104523
|
+
return chunk;
|
|
104524
|
+
}
|
|
104525
|
+
if ((pending.type === "text-delta" || pending.type === "reasoning-delta") && (chunk.type === "text-delta" || chunk.type === "reasoning-delta")) {
|
|
104357
104526
|
return { ...pending, delta: pending.delta + chunk.delta };
|
|
104358
104527
|
}
|
|
104359
104528
|
throw new Error(
|
|
@@ -104361,7 +104530,14 @@ function mergeUiDeltaChunks(pending, chunk) {
|
|
|
104361
104530
|
);
|
|
104362
104531
|
}
|
|
104363
104532
|
function uiDeltaTextLength(chunk) {
|
|
104364
|
-
|
|
104533
|
+
switch (chunk.type) {
|
|
104534
|
+
case "tool-input-delta":
|
|
104535
|
+
return chunk.inputTextDelta.length;
|
|
104536
|
+
case "tool-output-available":
|
|
104537
|
+
return chunk.output.length;
|
|
104538
|
+
default:
|
|
104539
|
+
return chunk.delta.length;
|
|
104540
|
+
}
|
|
104365
104541
|
}
|
|
104366
104542
|
function canCoalesceDelta(pending, context, delta) {
|
|
104367
104543
|
return pending.context.sessionId === context.sessionId && pending.context.runtimeId === context.runtimeId && pending.context.bridgeLeaseId === context.bridgeLeaseId && pending.delta.messageId === delta.messageId && pending.delta.partId === delta.partId && pending.delta.role === delta.role && pending.delta.kind === delta.kind && pending.delta.delta.type === delta.delta.type;
|
|
@@ -107443,9 +107619,19 @@ init_src();
|
|
|
107443
107619
|
|
|
107444
107620
|
// src/commands/agent-bridge/harness/codex/projector.ts
|
|
107445
107621
|
init_src();
|
|
107622
|
+
import { Buffer as Buffer3 } from "buffer";
|
|
107623
|
+
var CODEX_COMMAND_OUTPUT_MAX_BYTES = 32 * 1024;
|
|
107624
|
+
var CODEX_COMMAND_OUTPUT_TRUNCATION_MARKER = `
|
|
107625
|
+
[codex command output truncated at the ${CODEX_COMMAND_OUTPUT_MAX_BYTES.toString()}-byte live-stream limit]`;
|
|
107626
|
+
var CODEX_COMMAND_OUTPUT_CONTENT_MAX_BYTES = CODEX_COMMAND_OUTPUT_MAX_BYTES - Buffer3.byteLength(CODEX_COMMAND_OUTPUT_TRUNCATION_MARKER, "utf8");
|
|
107446
107627
|
var CodexProjector = class {
|
|
107447
107628
|
activeAgentMessages = /* @__PURE__ */ new Set();
|
|
107629
|
+
agentMessagePhases = /* @__PURE__ */ new Map();
|
|
107630
|
+
activeReasoningParts = /* @__PURE__ */ new Map();
|
|
107631
|
+
streamedReasoningIndexes = /* @__PURE__ */ new Map();
|
|
107448
107632
|
activeToolCalls = /* @__PURE__ */ new Set();
|
|
107633
|
+
activeToolMetadata = /* @__PURE__ */ new Map();
|
|
107634
|
+
activeToolOutput = /* @__PURE__ */ new Map();
|
|
107449
107635
|
activeResponseMessageId = null;
|
|
107450
107636
|
project(notification) {
|
|
107451
107637
|
switch (notification.type) {
|
|
@@ -107457,15 +107643,37 @@ var CodexProjector = class {
|
|
|
107457
107643
|
notification.delta
|
|
107458
107644
|
)
|
|
107459
107645
|
];
|
|
107646
|
+
case "reasoningSummaryPartAdded":
|
|
107647
|
+
return this.projectReasoningSummaryPartAdded(
|
|
107648
|
+
notification.itemId,
|
|
107649
|
+
notification.summaryIndex
|
|
107650
|
+
);
|
|
107651
|
+
case "reasoningSummaryTextDelta":
|
|
107652
|
+
return this.projectReasoningSummaryTextDelta(
|
|
107653
|
+
notification.itemId,
|
|
107654
|
+
notification.summaryIndex,
|
|
107655
|
+
notification.delta
|
|
107656
|
+
);
|
|
107657
|
+
case "commandExecutionOutputDelta":
|
|
107658
|
+
return this.projectCommandExecutionOutputDelta(
|
|
107659
|
+
notification.itemId,
|
|
107660
|
+
notification.delta
|
|
107661
|
+
);
|
|
107460
107662
|
case "itemStarted":
|
|
107461
107663
|
return this.projectItem(notification.item, "started");
|
|
107462
107664
|
case "itemCompleted":
|
|
107463
107665
|
return this.projectItem(notification.item, "completed");
|
|
107464
|
-
case "turnCompleted":
|
|
107666
|
+
case "turnCompleted": {
|
|
107667
|
+
const outputs = this.endAllReasoningParts();
|
|
107465
107668
|
this.activeResponseMessageId = null;
|
|
107466
107669
|
this.activeAgentMessages.clear();
|
|
107670
|
+
this.agentMessagePhases.clear();
|
|
107671
|
+
this.streamedReasoningIndexes.clear();
|
|
107467
107672
|
this.activeToolCalls.clear();
|
|
107468
|
-
|
|
107673
|
+
this.activeToolMetadata.clear();
|
|
107674
|
+
this.activeToolOutput.clear();
|
|
107675
|
+
return [...outputs, turnCompletionEntry(notification)];
|
|
107676
|
+
}
|
|
107469
107677
|
case "error":
|
|
107470
107678
|
return [errorEntry(notification)];
|
|
107471
107679
|
default:
|
|
@@ -107518,25 +107726,78 @@ var CodexProjector = class {
|
|
|
107518
107726
|
const outputs = [];
|
|
107519
107727
|
if (!this.activeAgentMessages.has(itemId)) {
|
|
107520
107728
|
this.activeAgentMessages.add(itemId);
|
|
107521
|
-
outputs.push(
|
|
107729
|
+
outputs.push(
|
|
107730
|
+
textBoundaryChunk(
|
|
107731
|
+
"text-start",
|
|
107732
|
+
itemId,
|
|
107733
|
+
this.agentMessagePhases.get(itemId)
|
|
107734
|
+
)
|
|
107735
|
+
);
|
|
107522
107736
|
}
|
|
107523
107737
|
outputs.push(
|
|
107524
107738
|
uiChunk2({ type: "text-delta", id: textPartId(itemId), delta })
|
|
107525
107739
|
);
|
|
107526
107740
|
return outputs;
|
|
107527
107741
|
}
|
|
107742
|
+
projectReasoningSummaryPartAdded(itemId, summaryIndex) {
|
|
107743
|
+
const active = this.activeReasoningParts.get(itemId);
|
|
107744
|
+
return active && active.summaryIndex !== summaryIndex ? this.endReasoningPart(itemId) : [];
|
|
107745
|
+
}
|
|
107746
|
+
projectReasoningSummaryTextDelta(itemId, summaryIndex, delta) {
|
|
107747
|
+
if (delta.length === 0) {
|
|
107748
|
+
return [];
|
|
107749
|
+
}
|
|
107750
|
+
const outputs = this.ensureResponseStarted(itemId);
|
|
107751
|
+
const active = this.activeReasoningParts.get(itemId);
|
|
107752
|
+
if (active && active.summaryIndex !== summaryIndex) {
|
|
107753
|
+
outputs.push(...this.endReasoningPart(itemId));
|
|
107754
|
+
}
|
|
107755
|
+
if (!this.activeReasoningParts.has(itemId)) {
|
|
107756
|
+
const id = reasoningPartId(itemId, summaryIndex);
|
|
107757
|
+
this.activeReasoningParts.set(itemId, { id, summaryIndex });
|
|
107758
|
+
outputs.push(uiChunk2({ type: "reasoning-start", id }));
|
|
107759
|
+
}
|
|
107760
|
+
const current = this.activeReasoningParts.get(itemId);
|
|
107761
|
+
if (current) {
|
|
107762
|
+
outputs.push(uiChunk2({ type: "reasoning-delta", id: current.id, delta }));
|
|
107763
|
+
const streamed = this.streamedReasoningIndexes.get(itemId) ?? /* @__PURE__ */ new Set();
|
|
107764
|
+
streamed.add(summaryIndex);
|
|
107765
|
+
this.streamedReasoningIndexes.set(itemId, streamed);
|
|
107766
|
+
}
|
|
107767
|
+
return outputs;
|
|
107768
|
+
}
|
|
107769
|
+
projectCommandExecutionOutputDelta(itemId, delta) {
|
|
107770
|
+
if (!this.activeToolCalls.has(itemId) || delta.length === 0) {
|
|
107771
|
+
return [];
|
|
107772
|
+
}
|
|
107773
|
+
const current = this.activeToolOutput.get(itemId) ?? emptyToolOutput();
|
|
107774
|
+
const next = appendCommandOutput(current, delta);
|
|
107775
|
+
if (next === current) {
|
|
107776
|
+
return [];
|
|
107777
|
+
}
|
|
107778
|
+
this.activeToolOutput.set(itemId, next);
|
|
107779
|
+
return [
|
|
107780
|
+
toolOutputChunk({
|
|
107781
|
+
itemId,
|
|
107782
|
+
output: next.output,
|
|
107783
|
+
isError: false,
|
|
107784
|
+
preliminary: true,
|
|
107785
|
+
toolMetadata: this.activeToolMetadata.get(itemId)
|
|
107786
|
+
})
|
|
107787
|
+
];
|
|
107788
|
+
}
|
|
107528
107789
|
projectItem(item, phase) {
|
|
107529
107790
|
switch (item.type) {
|
|
107530
107791
|
case "agentMessage":
|
|
107792
|
+
if (item.phase) {
|
|
107793
|
+
this.agentMessagePhases.set(item.id, item.phase);
|
|
107794
|
+
}
|
|
107531
107795
|
return [
|
|
107532
107796
|
...this.ensureResponseStarted(item.id),
|
|
107533
107797
|
...this.projectAgentMessageItem(item, phase)
|
|
107534
107798
|
];
|
|
107535
107799
|
case "reasoning":
|
|
107536
|
-
return phase
|
|
107537
|
-
...this.ensureResponseStarted(item.id),
|
|
107538
|
-
...reasoningItemChunks(item)
|
|
107539
|
-
] : [];
|
|
107800
|
+
return this.projectReasoningItem(item, phase);
|
|
107540
107801
|
case "commandExecution":
|
|
107541
107802
|
return this.projectToolItem({
|
|
107542
107803
|
phase,
|
|
@@ -107551,7 +107812,9 @@ var CodexProjector = class {
|
|
|
107551
107812
|
isError: isFailedStatus(item.status) || (item.exitCode ?? 0) !== 0,
|
|
107552
107813
|
title: item.command,
|
|
107553
107814
|
toolMetadata: statusMetadata(item.status, {
|
|
107554
|
-
...item.
|
|
107815
|
+
...(item.commandActions?.length ?? 0) > 0 ? { activities: commandActivities(item.commandActions ?? []) } : {},
|
|
107816
|
+
...item.exitCode != null ? { exitCode: item.exitCode } : {},
|
|
107817
|
+
...item.durationMs != null ? { durationMs: item.durationMs } : {}
|
|
107555
107818
|
})
|
|
107556
107819
|
});
|
|
107557
107820
|
case "fileChange":
|
|
@@ -107580,7 +107843,8 @@ var CodexProjector = class {
|
|
|
107580
107843
|
title: `${item.server}.${item.tool}`,
|
|
107581
107844
|
toolMetadata: statusMetadata(item.status, {
|
|
107582
107845
|
server: item.server,
|
|
107583
|
-
tool: item.tool
|
|
107846
|
+
tool: item.tool,
|
|
107847
|
+
...item.durationMs != null ? { durationMs: item.durationMs } : {}
|
|
107584
107848
|
})
|
|
107585
107849
|
});
|
|
107586
107850
|
default:
|
|
@@ -107590,29 +107854,42 @@ var CodexProjector = class {
|
|
|
107590
107854
|
projectToolItem(input) {
|
|
107591
107855
|
const outputs = [];
|
|
107592
107856
|
outputs.push(...this.ensureResponseStarted(input.itemId));
|
|
107857
|
+
if (input.toolMetadata) {
|
|
107858
|
+
this.activeToolMetadata.set(input.itemId, input.toolMetadata);
|
|
107859
|
+
}
|
|
107593
107860
|
if (input.phase === "started" || !this.activeToolCalls.has(input.itemId)) {
|
|
107594
107861
|
outputs.push(toolInputChunk(input));
|
|
107595
107862
|
this.activeToolCalls.add(input.itemId);
|
|
107596
107863
|
}
|
|
107597
107864
|
if (input.phase === "started") {
|
|
107865
|
+
this.activeToolOutput.set(input.itemId, emptyToolOutput());
|
|
107598
107866
|
return outputs;
|
|
107599
107867
|
}
|
|
107868
|
+
if (input.output === "" && this.activeToolOutput.has(input.itemId)) {
|
|
107869
|
+
input.output = this.activeToolOutput.get(input.itemId)?.output ?? "";
|
|
107870
|
+
}
|
|
107600
107871
|
outputs.push(toolOutputChunk(input));
|
|
107601
107872
|
outputs.push(uiChunk2({ type: "finish-step" }));
|
|
107602
107873
|
this.activeToolCalls.delete(input.itemId);
|
|
107874
|
+
this.activeToolMetadata.delete(input.itemId);
|
|
107875
|
+
this.activeToolOutput.delete(input.itemId);
|
|
107603
107876
|
return outputs;
|
|
107604
107877
|
}
|
|
107605
107878
|
projectAgentMessageItem(item, phase) {
|
|
107879
|
+
if (item.phase) {
|
|
107880
|
+
this.agentMessagePhases.set(item.id, item.phase);
|
|
107881
|
+
}
|
|
107882
|
+
const messagePhase = item.phase ?? this.agentMessagePhases.get(item.id);
|
|
107606
107883
|
if (phase === "started") {
|
|
107607
107884
|
if (this.activeAgentMessages.has(item.id)) {
|
|
107608
107885
|
return [];
|
|
107609
107886
|
}
|
|
107610
107887
|
this.activeAgentMessages.add(item.id);
|
|
107611
|
-
return [
|
|
107888
|
+
return [textBoundaryChunk("text-start", item.id, messagePhase)];
|
|
107612
107889
|
}
|
|
107613
107890
|
const outputs = [];
|
|
107614
107891
|
if (!this.activeAgentMessages.has(item.id)) {
|
|
107615
|
-
outputs.push(
|
|
107892
|
+
outputs.push(textBoundaryChunk("text-start", item.id, messagePhase));
|
|
107616
107893
|
if (item.text.length > 0) {
|
|
107617
107894
|
outputs.push(
|
|
107618
107895
|
uiChunk2({
|
|
@@ -107624,12 +107901,45 @@ var CodexProjector = class {
|
|
|
107624
107901
|
}
|
|
107625
107902
|
}
|
|
107626
107903
|
outputs.push(
|
|
107627
|
-
|
|
107904
|
+
textBoundaryChunk("text-end", item.id, messagePhase),
|
|
107628
107905
|
uiChunk2({ type: "finish-step" })
|
|
107629
107906
|
);
|
|
107630
107907
|
this.activeAgentMessages.delete(item.id);
|
|
107908
|
+
this.agentMessagePhases.delete(item.id);
|
|
107631
107909
|
return outputs;
|
|
107632
107910
|
}
|
|
107911
|
+
projectReasoningItem(item, phase) {
|
|
107912
|
+
if (phase === "started") {
|
|
107913
|
+
return [];
|
|
107914
|
+
}
|
|
107915
|
+
const outputs = this.endReasoningPart(item.id);
|
|
107916
|
+
const streamedIndexes = this.streamedReasoningIndexes.get(item.id);
|
|
107917
|
+
this.streamedReasoningIndexes.delete(item.id);
|
|
107918
|
+
if (streamedIndexes && streamedIndexes.size > 0) {
|
|
107919
|
+
outputs.push(...reasoningItemChunks(item, streamedIndexes));
|
|
107920
|
+
outputs.push(uiChunk2({ type: "finish-step" }));
|
|
107921
|
+
return outputs;
|
|
107922
|
+
}
|
|
107923
|
+
const completedChunks = reasoningItemChunks(item);
|
|
107924
|
+
return completedChunks.length > 0 ? [
|
|
107925
|
+
...this.ensureResponseStarted(item.id),
|
|
107926
|
+
...completedChunks,
|
|
107927
|
+
uiChunk2({ type: "finish-step" })
|
|
107928
|
+
] : [];
|
|
107929
|
+
}
|
|
107930
|
+
endReasoningPart(itemId) {
|
|
107931
|
+
const active = this.activeReasoningParts.get(itemId);
|
|
107932
|
+
if (!active) {
|
|
107933
|
+
return [];
|
|
107934
|
+
}
|
|
107935
|
+
this.activeReasoningParts.delete(itemId);
|
|
107936
|
+
return [uiChunk2({ type: "reasoning-end", id: active.id })];
|
|
107937
|
+
}
|
|
107938
|
+
endAllReasoningParts() {
|
|
107939
|
+
return [...this.activeReasoningParts.keys()].flatMap(
|
|
107940
|
+
(itemId) => this.endReasoningPart(itemId)
|
|
107941
|
+
);
|
|
107942
|
+
}
|
|
107633
107943
|
ensureResponseStarted(messageId) {
|
|
107634
107944
|
if (this.activeResponseMessageId !== null) {
|
|
107635
107945
|
return [];
|
|
@@ -107638,18 +107948,65 @@ var CodexProjector = class {
|
|
|
107638
107948
|
return [uiChunk2({ type: "start", messageId })];
|
|
107639
107949
|
}
|
|
107640
107950
|
};
|
|
107641
|
-
function
|
|
107642
|
-
|
|
107643
|
-
|
|
107951
|
+
function emptyToolOutput() {
|
|
107952
|
+
return { bytes: 0, output: "", truncated: false };
|
|
107953
|
+
}
|
|
107954
|
+
function appendCommandOutput(current, delta) {
|
|
107955
|
+
if (current.truncated) {
|
|
107956
|
+
return current;
|
|
107957
|
+
}
|
|
107958
|
+
const deltaBytes = Buffer3.byteLength(delta, "utf8");
|
|
107959
|
+
if (current.bytes + deltaBytes <= CODEX_COMMAND_OUTPUT_MAX_BYTES) {
|
|
107960
|
+
return {
|
|
107961
|
+
bytes: current.bytes + deltaBytes,
|
|
107962
|
+
output: current.output + delta,
|
|
107963
|
+
truncated: false
|
|
107964
|
+
};
|
|
107965
|
+
}
|
|
107966
|
+
const retainedOutput = utf8Prefix(
|
|
107967
|
+
current.output,
|
|
107968
|
+
CODEX_COMMAND_OUTPUT_CONTENT_MAX_BYTES
|
|
107969
|
+
);
|
|
107970
|
+
const retainedBytes = Buffer3.byteLength(retainedOutput, "utf8");
|
|
107971
|
+
const retainedDelta = utf8Prefix(
|
|
107972
|
+
delta,
|
|
107973
|
+
CODEX_COMMAND_OUTPUT_CONTENT_MAX_BYTES - retainedBytes
|
|
107974
|
+
);
|
|
107975
|
+
const output = `${retainedOutput}${retainedDelta}${CODEX_COMMAND_OUTPUT_TRUNCATION_MARKER}`;
|
|
107976
|
+
return {
|
|
107977
|
+
bytes: Buffer3.byteLength(output, "utf8"),
|
|
107978
|
+
output,
|
|
107979
|
+
truncated: true
|
|
107980
|
+
};
|
|
107981
|
+
}
|
|
107982
|
+
function utf8Prefix(value, maxBytes) {
|
|
107983
|
+
let bytes = 0;
|
|
107984
|
+
let end = 0;
|
|
107985
|
+
for (const character of value) {
|
|
107986
|
+
const characterBytes = Buffer3.byteLength(character, "utf8");
|
|
107987
|
+
if (bytes + characterBytes > maxBytes) {
|
|
107988
|
+
break;
|
|
107989
|
+
}
|
|
107990
|
+
bytes += characterBytes;
|
|
107991
|
+
end += character.length;
|
|
107992
|
+
}
|
|
107993
|
+
return value.slice(0, end);
|
|
107994
|
+
}
|
|
107995
|
+
function reasoningItemChunks(item, excludedIndexes = /* @__PURE__ */ new Set()) {
|
|
107996
|
+
const parts = item.summary.map((text, summaryIndex) => ({ summaryIndex, text: text.trim() })).filter(
|
|
107997
|
+
(part) => part.text.length > 0 && !excludedIndexes.has(part.summaryIndex)
|
|
107998
|
+
);
|
|
107999
|
+
if (parts.length === 0) {
|
|
107644
108000
|
return [];
|
|
107645
108001
|
}
|
|
107646
|
-
|
|
107647
|
-
|
|
107648
|
-
|
|
107649
|
-
|
|
107650
|
-
|
|
107651
|
-
|
|
107652
|
-
|
|
108002
|
+
return parts.flatMap(({ summaryIndex, text }) => {
|
|
108003
|
+
const id = reasoningPartId(item.id, summaryIndex);
|
|
108004
|
+
return [
|
|
108005
|
+
uiChunk2({ type: "reasoning-start", id }),
|
|
108006
|
+
uiChunk2({ type: "reasoning-delta", id, delta: text }),
|
|
108007
|
+
uiChunk2({ type: "reasoning-end", id })
|
|
108008
|
+
];
|
|
108009
|
+
});
|
|
107653
108010
|
}
|
|
107654
108011
|
function toolInputChunk(input) {
|
|
107655
108012
|
return uiChunk2({
|
|
@@ -107678,10 +108035,41 @@ function toolOutputChunk(input) {
|
|
|
107678
108035
|
type: "tool-output-available",
|
|
107679
108036
|
toolCallId: input.itemId,
|
|
107680
108037
|
output: input.output,
|
|
108038
|
+
...input.preliminary !== void 0 ? { preliminary: input.preliminary } : {},
|
|
107681
108039
|
...input.toolMetadata ? { toolMetadata: input.toolMetadata } : {}
|
|
107682
108040
|
}
|
|
107683
108041
|
);
|
|
107684
108042
|
}
|
|
108043
|
+
function textBoundaryChunk(type, itemId, phase) {
|
|
108044
|
+
const providerMetadata = transcriptMessagePhaseProviderMetadata(phase);
|
|
108045
|
+
return uiChunk2({
|
|
108046
|
+
type,
|
|
108047
|
+
id: textPartId(itemId),
|
|
108048
|
+
...providerMetadata ? { providerMetadata } : {}
|
|
108049
|
+
});
|
|
108050
|
+
}
|
|
108051
|
+
function commandActivities(actions) {
|
|
108052
|
+
return actions.map((action) => {
|
|
108053
|
+
switch (action.type) {
|
|
108054
|
+
case "read":
|
|
108055
|
+
return {
|
|
108056
|
+
type: "read",
|
|
108057
|
+
path: action.path,
|
|
108058
|
+
name: action.name
|
|
108059
|
+
};
|
|
108060
|
+
case "listFiles":
|
|
108061
|
+
return { type: "list", path: action.path };
|
|
108062
|
+
case "search":
|
|
108063
|
+
return {
|
|
108064
|
+
type: "search",
|
|
108065
|
+
path: action.path,
|
|
108066
|
+
query: action.query
|
|
108067
|
+
};
|
|
108068
|
+
case "unknown":
|
|
108069
|
+
return { type: "run", command: action.command };
|
|
108070
|
+
}
|
|
108071
|
+
});
|
|
108072
|
+
}
|
|
107685
108073
|
function turnCompletionEntry(notification) {
|
|
107686
108074
|
if (notification.status === "failed") {
|
|
107687
108075
|
const detail = notification.errorMessage ?? "unknown error";
|
|
@@ -107732,8 +108120,8 @@ function approvalQuestion(request) {
|
|
|
107732
108120
|
function textPartId(itemId) {
|
|
107733
108121
|
return `${itemId}:text`;
|
|
107734
108122
|
}
|
|
107735
|
-
function reasoningPartId(itemId) {
|
|
107736
|
-
return `${itemId}:reasoning`;
|
|
108123
|
+
function reasoningPartId(itemId, summaryIndex) {
|
|
108124
|
+
return `${itemId}:reasoning:${summaryIndex.toString()}`;
|
|
107737
108125
|
}
|
|
107738
108126
|
function isFailedStatus(status) {
|
|
107739
108127
|
return status === "failed" || status === "declined";
|