@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/agent-bridge.js
CHANGED
|
@@ -37736,7 +37736,7 @@ Object.assign(lookup, {
|
|
|
37736
37736
|
// package.json
|
|
37737
37737
|
var package_default = {
|
|
37738
37738
|
name: "@autohq/cli",
|
|
37739
|
-
version: "0.1.
|
|
37739
|
+
version: "0.1.591",
|
|
37740
37740
|
license: "SEE LICENSE IN README.md",
|
|
37741
37741
|
publishConfig: {
|
|
37742
37742
|
access: "public"
|
|
@@ -40393,6 +40393,41 @@ function usdAmount(value2) {
|
|
|
40393
40393
|
return value2;
|
|
40394
40394
|
}
|
|
40395
40395
|
|
|
40396
|
+
// ../../packages/schemas/src/transcript-activity.ts
|
|
40397
|
+
var TranscriptActivitySchema = external_exports.discriminatedUnion("type", [
|
|
40398
|
+
external_exports.object({
|
|
40399
|
+
type: external_exports.literal("read"),
|
|
40400
|
+
path: external_exports.string(),
|
|
40401
|
+
name: external_exports.string().optional()
|
|
40402
|
+
}),
|
|
40403
|
+
external_exports.object({
|
|
40404
|
+
type: external_exports.literal("list"),
|
|
40405
|
+
path: external_exports.string().nullable()
|
|
40406
|
+
}),
|
|
40407
|
+
external_exports.object({
|
|
40408
|
+
type: external_exports.literal("search"),
|
|
40409
|
+
path: external_exports.string().nullable(),
|
|
40410
|
+
query: external_exports.string().nullable()
|
|
40411
|
+
}),
|
|
40412
|
+
external_exports.object({
|
|
40413
|
+
type: external_exports.literal("run"),
|
|
40414
|
+
command: external_exports.string()
|
|
40415
|
+
})
|
|
40416
|
+
]);
|
|
40417
|
+
var TranscriptToolMetadataSchema = external_exports.object({
|
|
40418
|
+
activities: external_exports.array(TranscriptActivitySchema).optional(),
|
|
40419
|
+
durationMs: external_exports.number().nonnegative().optional(),
|
|
40420
|
+
exitCode: external_exports.number().optional(),
|
|
40421
|
+
status: external_exports.string().optional()
|
|
40422
|
+
}).passthrough();
|
|
40423
|
+
var TranscriptMessagePhaseSchema = external_exports.enum([
|
|
40424
|
+
"commentary",
|
|
40425
|
+
"final_answer"
|
|
40426
|
+
]);
|
|
40427
|
+
function transcriptMessagePhaseProviderMetadata(phase) {
|
|
40428
|
+
return phase ? { auto: { messagePhase: phase } } : void 0;
|
|
40429
|
+
}
|
|
40430
|
+
|
|
40396
40431
|
// ../../packages/schemas/src/codex.ts
|
|
40397
40432
|
var CodexRequestIdSchema = external_exports.union([external_exports.string(), external_exports.number()]);
|
|
40398
40433
|
var CodexTurnStatusSchema = external_exports.enum([
|
|
@@ -40405,21 +40440,47 @@ var CodexUserMessageItemSchema = external_exports.object({ type: external_export
|
|
|
40405
40440
|
var CodexAgentMessageItemSchema = external_exports.object({
|
|
40406
40441
|
type: external_exports.literal("agentMessage"),
|
|
40407
40442
|
id: external_exports.string(),
|
|
40408
|
-
text: external_exports.string().default("")
|
|
40443
|
+
text: external_exports.string().default(""),
|
|
40444
|
+
phase: TranscriptMessagePhaseSchema.nullish()
|
|
40409
40445
|
}).passthrough();
|
|
40410
40446
|
var CodexReasoningItemSchema = external_exports.object({
|
|
40411
40447
|
type: external_exports.literal("reasoning"),
|
|
40412
40448
|
id: external_exports.string(),
|
|
40413
40449
|
summary: external_exports.array(external_exports.string()).default([])
|
|
40414
40450
|
}).passthrough();
|
|
40451
|
+
var CodexCommandActionSchema = external_exports.discriminatedUnion("type", [
|
|
40452
|
+
external_exports.object({
|
|
40453
|
+
type: external_exports.literal("read"),
|
|
40454
|
+
command: external_exports.string(),
|
|
40455
|
+
name: external_exports.string(),
|
|
40456
|
+
path: external_exports.string()
|
|
40457
|
+
}).passthrough(),
|
|
40458
|
+
external_exports.object({
|
|
40459
|
+
type: external_exports.literal("listFiles"),
|
|
40460
|
+
command: external_exports.string(),
|
|
40461
|
+
path: external_exports.string().nullable()
|
|
40462
|
+
}).passthrough(),
|
|
40463
|
+
external_exports.object({
|
|
40464
|
+
type: external_exports.literal("search"),
|
|
40465
|
+
command: external_exports.string(),
|
|
40466
|
+
query: external_exports.string().nullable(),
|
|
40467
|
+
path: external_exports.string().nullable()
|
|
40468
|
+
}).passthrough(),
|
|
40469
|
+
external_exports.object({
|
|
40470
|
+
type: external_exports.literal("unknown"),
|
|
40471
|
+
command: external_exports.string()
|
|
40472
|
+
}).passthrough()
|
|
40473
|
+
]);
|
|
40415
40474
|
var CodexCommandExecutionItemSchema = external_exports.object({
|
|
40416
40475
|
type: external_exports.literal("commandExecution"),
|
|
40417
40476
|
id: external_exports.string(),
|
|
40418
40477
|
command: external_exports.string().default(""),
|
|
40419
40478
|
cwd: external_exports.string().optional(),
|
|
40420
40479
|
status: external_exports.string().optional(),
|
|
40480
|
+
commandActions: external_exports.array(CodexCommandActionSchema).optional(),
|
|
40421
40481
|
aggregatedOutput: external_exports.string().nullish(),
|
|
40422
|
-
exitCode: external_exports.number().nullish()
|
|
40482
|
+
exitCode: external_exports.number().nullish(),
|
|
40483
|
+
durationMs: external_exports.number().nonnegative().nullish()
|
|
40423
40484
|
}).passthrough();
|
|
40424
40485
|
var CodexFileChangeItemSchema = external_exports.object({
|
|
40425
40486
|
type: external_exports.literal("fileChange"),
|
|
@@ -40435,7 +40496,8 @@ var CodexMcpToolCallItemSchema = external_exports.object({
|
|
|
40435
40496
|
status: external_exports.string().optional(),
|
|
40436
40497
|
arguments: external_exports.unknown().optional(),
|
|
40437
40498
|
result: external_exports.unknown().nullish(),
|
|
40438
|
-
error: external_exports.object({ message: external_exports.string() }).passthrough().nullish()
|
|
40499
|
+
error: external_exports.object({ message: external_exports.string() }).passthrough().nullish(),
|
|
40500
|
+
durationMs: external_exports.number().nonnegative().nullish()
|
|
40439
40501
|
}).passthrough();
|
|
40440
40502
|
var CodexItemSchema = external_exports.discriminatedUnion("type", [
|
|
40441
40503
|
CodexUserMessageItemSchema,
|
|
@@ -40567,6 +40629,53 @@ function parseNotification(method, params) {
|
|
|
40567
40629
|
delta: parsed.data.delta
|
|
40568
40630
|
} : null;
|
|
40569
40631
|
}
|
|
40632
|
+
case "item/reasoning/summaryPartAdded": {
|
|
40633
|
+
const parsed = external_exports.object({
|
|
40634
|
+
threadId: external_exports.string(),
|
|
40635
|
+
turnId: external_exports.string(),
|
|
40636
|
+
itemId: external_exports.string(),
|
|
40637
|
+
summaryIndex: external_exports.number().int().nonnegative()
|
|
40638
|
+
}).passthrough().safeParse(params);
|
|
40639
|
+
return parsed.success ? {
|
|
40640
|
+
type: "reasoningSummaryPartAdded",
|
|
40641
|
+
threadId: parsed.data.threadId,
|
|
40642
|
+
turnId: parsed.data.turnId,
|
|
40643
|
+
itemId: parsed.data.itemId,
|
|
40644
|
+
summaryIndex: parsed.data.summaryIndex
|
|
40645
|
+
} : null;
|
|
40646
|
+
}
|
|
40647
|
+
case "item/reasoning/summaryTextDelta": {
|
|
40648
|
+
const parsed = external_exports.object({
|
|
40649
|
+
threadId: external_exports.string(),
|
|
40650
|
+
turnId: external_exports.string(),
|
|
40651
|
+
itemId: external_exports.string(),
|
|
40652
|
+
summaryIndex: external_exports.number().int().nonnegative(),
|
|
40653
|
+
delta: external_exports.string()
|
|
40654
|
+
}).passthrough().safeParse(params);
|
|
40655
|
+
return parsed.success ? {
|
|
40656
|
+
type: "reasoningSummaryTextDelta",
|
|
40657
|
+
threadId: parsed.data.threadId,
|
|
40658
|
+
turnId: parsed.data.turnId,
|
|
40659
|
+
itemId: parsed.data.itemId,
|
|
40660
|
+
summaryIndex: parsed.data.summaryIndex,
|
|
40661
|
+
delta: parsed.data.delta
|
|
40662
|
+
} : null;
|
|
40663
|
+
}
|
|
40664
|
+
case "item/commandExecution/outputDelta": {
|
|
40665
|
+
const parsed = external_exports.object({
|
|
40666
|
+
threadId: external_exports.string(),
|
|
40667
|
+
turnId: external_exports.string(),
|
|
40668
|
+
itemId: external_exports.string(),
|
|
40669
|
+
delta: external_exports.string()
|
|
40670
|
+
}).passthrough().safeParse(params);
|
|
40671
|
+
return parsed.success ? {
|
|
40672
|
+
type: "commandExecutionOutputDelta",
|
|
40673
|
+
threadId: parsed.data.threadId,
|
|
40674
|
+
turnId: parsed.data.turnId,
|
|
40675
|
+
itemId: parsed.data.itemId,
|
|
40676
|
+
delta: parsed.data.delta
|
|
40677
|
+
} : null;
|
|
40678
|
+
}
|
|
40570
40679
|
case "error": {
|
|
40571
40680
|
const parsed = external_exports.object({
|
|
40572
40681
|
error: external_exports.object({ message: external_exports.string() }).passthrough(),
|
|
@@ -82965,7 +83074,10 @@ var UiMessagePartTracker = class {
|
|
|
82965
83074
|
toolCallId: chunk.toolCallId,
|
|
82966
83075
|
toolName: chunk.toolName,
|
|
82967
83076
|
dynamic: chunk.dynamic,
|
|
82968
|
-
state: "input-streaming"
|
|
83077
|
+
state: "input-streaming",
|
|
83078
|
+
title: chunk.title,
|
|
83079
|
+
toolMetadata: chunk.toolMetadata,
|
|
83080
|
+
providerExecuted: chunk.providerExecuted
|
|
82969
83081
|
})
|
|
82970
83082
|
);
|
|
82971
83083
|
this.toolPartIndexByCallId.set(chunk.toolCallId, index);
|
|
@@ -82978,11 +83090,13 @@ var UiMessagePartTracker = class {
|
|
|
82978
83090
|
toolCallId: chunk.toolCallId,
|
|
82979
83091
|
toolName: chunk.toolName,
|
|
82980
83092
|
dynamic: chunk.dynamic,
|
|
82981
|
-
state: pendingApproval ? "approval-requested" : "input-available"
|
|
83093
|
+
state: pendingApproval ? "approval-requested" : "input-available",
|
|
83094
|
+
title: chunk.title,
|
|
83095
|
+
toolMetadata: chunk.toolMetadata,
|
|
83096
|
+
providerExecuted: chunk.providerExecuted
|
|
82982
83097
|
}),
|
|
82983
83098
|
input: chunk.input,
|
|
82984
83099
|
...pendingApproval ? { approval: pendingApproval } : {},
|
|
82985
|
-
...chunk.providerExecuted !== void 0 ? { providerExecuted: chunk.providerExecuted } : {},
|
|
82986
83100
|
...chunk.providerMetadata !== void 0 ? { callProviderMetadata: chunk.providerMetadata } : {}
|
|
82987
83101
|
});
|
|
82988
83102
|
return this.persistable(index);
|
|
@@ -82993,10 +83107,14 @@ var UiMessagePartTracker = class {
|
|
|
82993
83107
|
toolCallId: chunk.toolCallId,
|
|
82994
83108
|
toolName: chunk.toolName,
|
|
82995
83109
|
dynamic: chunk.dynamic,
|
|
82996
|
-
state: "output-error"
|
|
83110
|
+
state: "output-error",
|
|
83111
|
+
title: chunk.title,
|
|
83112
|
+
toolMetadata: chunk.toolMetadata,
|
|
83113
|
+
providerExecuted: chunk.providerExecuted
|
|
82997
83114
|
}),
|
|
82998
83115
|
input: chunk.input,
|
|
82999
|
-
errorText: chunk.errorText
|
|
83116
|
+
errorText: chunk.errorText,
|
|
83117
|
+
...chunk.providerMetadata !== void 0 ? { callProviderMetadata: chunk.providerMetadata } : {}
|
|
83000
83118
|
});
|
|
83001
83119
|
return this.persistable(index);
|
|
83002
83120
|
}
|
|
@@ -83030,6 +83148,15 @@ var UiMessagePartTracker = class {
|
|
|
83030
83148
|
part.state = "output-available";
|
|
83031
83149
|
part.output = chunk.output;
|
|
83032
83150
|
part.preliminary = chunk.preliminary;
|
|
83151
|
+
if (chunk.toolMetadata !== void 0) {
|
|
83152
|
+
part.toolMetadata = chunk.toolMetadata;
|
|
83153
|
+
}
|
|
83154
|
+
if (chunk.providerMetadata !== void 0) {
|
|
83155
|
+
part.resultProviderMetadata = chunk.providerMetadata;
|
|
83156
|
+
}
|
|
83157
|
+
if (chunk.providerExecuted !== void 0) {
|
|
83158
|
+
part.providerExecuted = chunk.providerExecuted;
|
|
83159
|
+
}
|
|
83033
83160
|
this.settleApproval(part, chunk.toolCallId, { approved: true });
|
|
83034
83161
|
return this.persistable(index);
|
|
83035
83162
|
}
|
|
@@ -83057,6 +83184,15 @@ var UiMessagePartTracker = class {
|
|
|
83057
83184
|
}
|
|
83058
83185
|
part.state = "output-error";
|
|
83059
83186
|
part.errorText = chunk.errorText;
|
|
83187
|
+
if (chunk.toolMetadata !== void 0) {
|
|
83188
|
+
part.toolMetadata = chunk.toolMetadata;
|
|
83189
|
+
}
|
|
83190
|
+
if (chunk.providerMetadata !== void 0) {
|
|
83191
|
+
part.resultProviderMetadata = chunk.providerMetadata;
|
|
83192
|
+
}
|
|
83193
|
+
if (chunk.providerExecuted !== void 0) {
|
|
83194
|
+
part.providerExecuted = chunk.providerExecuted;
|
|
83195
|
+
}
|
|
83060
83196
|
this.settleApproval(part, chunk.toolCallId, { approved: true });
|
|
83061
83197
|
return this.persistable(index);
|
|
83062
83198
|
}
|
|
@@ -83188,18 +83324,23 @@ var UiMessagePartTracker = class {
|
|
|
83188
83324
|
}
|
|
83189
83325
|
};
|
|
83190
83326
|
function toolPartShape(input) {
|
|
83327
|
+
const common = {
|
|
83328
|
+
toolCallId: input.toolCallId,
|
|
83329
|
+
state: input.state,
|
|
83330
|
+
...input.title !== void 0 ? { title: input.title } : {},
|
|
83331
|
+
...input.toolMetadata !== void 0 ? { toolMetadata: input.toolMetadata } : {},
|
|
83332
|
+
...input.providerExecuted !== void 0 ? { providerExecuted: input.providerExecuted } : {}
|
|
83333
|
+
};
|
|
83191
83334
|
if (input.dynamic) {
|
|
83192
83335
|
return {
|
|
83193
83336
|
type: "dynamic-tool",
|
|
83194
83337
|
toolName: input.toolName,
|
|
83195
|
-
|
|
83196
|
-
state: input.state
|
|
83338
|
+
...common
|
|
83197
83339
|
};
|
|
83198
83340
|
}
|
|
83199
83341
|
return {
|
|
83200
83342
|
type: `tool-${input.toolName}`,
|
|
83201
|
-
|
|
83202
|
-
state: input.state
|
|
83343
|
+
...common
|
|
83203
83344
|
};
|
|
83204
83345
|
}
|
|
83205
83346
|
function providerMetadataField(providerMetadata) {
|
|
@@ -83478,6 +83619,10 @@ var AgentBridgeOutputBuffer = class {
|
|
|
83478
83619
|
}
|
|
83479
83620
|
await this.flushPendingUiDelta();
|
|
83480
83621
|
this.pendingUiDelta = { context, chunk: { ...chunk }, createdAt: now2() };
|
|
83622
|
+
if (uiDeltaTextLength(chunk) >= AGENT_BRIDGE_OUTPUT_UI_DELTA_MAX_CHARS) {
|
|
83623
|
+
await this.flushPendingUiDelta();
|
|
83624
|
+
return;
|
|
83625
|
+
}
|
|
83481
83626
|
this.scheduleUiDeltaFlush();
|
|
83482
83627
|
}
|
|
83483
83628
|
scheduleUiDeltaFlush() {
|
|
@@ -83520,9 +83665,9 @@ var AgentBridgeOutputBuffer = class {
|
|
|
83520
83665
|
await this.drainPendingOutputs();
|
|
83521
83666
|
}
|
|
83522
83667
|
// Turns the parked coalesced chunk into a queued envelope and applies it to
|
|
83523
|
-
// the part tracker and message assembler
|
|
83524
|
-
//
|
|
83525
|
-
//
|
|
83668
|
+
// the part tracker and message assembler. Text/input deltas concatenate;
|
|
83669
|
+
// preliminary tool output is already cumulative, so only its latest snapshot
|
|
83670
|
+
// is retained before the final result flushes it.
|
|
83526
83671
|
// Does not drain: the drain loop calls this mid-loop and keeps pulling.
|
|
83527
83672
|
async materializePendingUiDelta() {
|
|
83528
83673
|
const pending = this.pendingUiDelta;
|
|
@@ -83889,6 +84034,9 @@ function legacyToolEntries(chunk) {
|
|
|
83889
84034
|
}
|
|
83890
84035
|
];
|
|
83891
84036
|
case "tool-output-available":
|
|
84037
|
+
if (chunk.preliminary) {
|
|
84038
|
+
return [];
|
|
84039
|
+
}
|
|
83892
84040
|
return [
|
|
83893
84041
|
{
|
|
83894
84042
|
role: "tool",
|
|
@@ -83979,6 +84127,12 @@ function coalescibleUiDeltaChunk(projection) {
|
|
|
83979
84127
|
return chunk.providerMetadata === void 0 ? chunk : null;
|
|
83980
84128
|
case "tool-input-delta":
|
|
83981
84129
|
return chunk;
|
|
84130
|
+
case "tool-output-available":
|
|
84131
|
+
return chunk.preliminary === true && typeof chunk.output === "string" ? {
|
|
84132
|
+
...chunk,
|
|
84133
|
+
output: chunk.output,
|
|
84134
|
+
preliminary: true
|
|
84135
|
+
} : null;
|
|
83982
84136
|
default:
|
|
83983
84137
|
return null;
|
|
83984
84138
|
}
|
|
@@ -83990,7 +84144,10 @@ function canCoalesceUiDelta(pending, context, chunk) {
|
|
|
83990
84144
|
if (pending.chunk.type === "tool-input-delta" && chunk.type === "tool-input-delta") {
|
|
83991
84145
|
return pending.chunk.toolCallId === chunk.toolCallId;
|
|
83992
84146
|
}
|
|
83993
|
-
if (pending.chunk.type
|
|
84147
|
+
if (pending.chunk.type === "tool-output-available" && chunk.type === "tool-output-available") {
|
|
84148
|
+
return pending.chunk.toolCallId === chunk.toolCallId;
|
|
84149
|
+
}
|
|
84150
|
+
if ((pending.chunk.type === "text-delta" || pending.chunk.type === "reasoning-delta") && (chunk.type === "text-delta" || chunk.type === "reasoning-delta")) {
|
|
83994
84151
|
return pending.chunk.id === chunk.id;
|
|
83995
84152
|
}
|
|
83996
84153
|
return false;
|
|
@@ -84002,7 +84159,10 @@ function mergeUiDeltaChunks(pending, chunk) {
|
|
|
84002
84159
|
inputTextDelta: pending.inputTextDelta + chunk.inputTextDelta
|
|
84003
84160
|
};
|
|
84004
84161
|
}
|
|
84005
|
-
if (pending.type
|
|
84162
|
+
if (pending.type === "tool-output-available" && chunk.type === "tool-output-available") {
|
|
84163
|
+
return chunk;
|
|
84164
|
+
}
|
|
84165
|
+
if ((pending.type === "text-delta" || pending.type === "reasoning-delta") && (chunk.type === "text-delta" || chunk.type === "reasoning-delta")) {
|
|
84006
84166
|
return { ...pending, delta: pending.delta + chunk.delta };
|
|
84007
84167
|
}
|
|
84008
84168
|
throw new Error(
|
|
@@ -84010,7 +84170,14 @@ function mergeUiDeltaChunks(pending, chunk) {
|
|
|
84010
84170
|
);
|
|
84011
84171
|
}
|
|
84012
84172
|
function uiDeltaTextLength(chunk) {
|
|
84013
|
-
|
|
84173
|
+
switch (chunk.type) {
|
|
84174
|
+
case "tool-input-delta":
|
|
84175
|
+
return chunk.inputTextDelta.length;
|
|
84176
|
+
case "tool-output-available":
|
|
84177
|
+
return chunk.output.length;
|
|
84178
|
+
default:
|
|
84179
|
+
return chunk.delta.length;
|
|
84180
|
+
}
|
|
84014
84181
|
}
|
|
84015
84182
|
function canCoalesceDelta(pending, context, delta) {
|
|
84016
84183
|
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;
|
|
@@ -87081,9 +87248,19 @@ function commandLogContext(delivery, fields = {}) {
|
|
|
87081
87248
|
}
|
|
87082
87249
|
|
|
87083
87250
|
// src/commands/agent-bridge/harness/codex/projector.ts
|
|
87251
|
+
import { Buffer as Buffer3 } from "buffer";
|
|
87252
|
+
var CODEX_COMMAND_OUTPUT_MAX_BYTES = 32 * 1024;
|
|
87253
|
+
var CODEX_COMMAND_OUTPUT_TRUNCATION_MARKER = `
|
|
87254
|
+
[codex command output truncated at the ${CODEX_COMMAND_OUTPUT_MAX_BYTES.toString()}-byte live-stream limit]`;
|
|
87255
|
+
var CODEX_COMMAND_OUTPUT_CONTENT_MAX_BYTES = CODEX_COMMAND_OUTPUT_MAX_BYTES - Buffer3.byteLength(CODEX_COMMAND_OUTPUT_TRUNCATION_MARKER, "utf8");
|
|
87084
87256
|
var CodexProjector = class {
|
|
87085
87257
|
activeAgentMessages = /* @__PURE__ */ new Set();
|
|
87258
|
+
agentMessagePhases = /* @__PURE__ */ new Map();
|
|
87259
|
+
activeReasoningParts = /* @__PURE__ */ new Map();
|
|
87260
|
+
streamedReasoningIndexes = /* @__PURE__ */ new Map();
|
|
87086
87261
|
activeToolCalls = /* @__PURE__ */ new Set();
|
|
87262
|
+
activeToolMetadata = /* @__PURE__ */ new Map();
|
|
87263
|
+
activeToolOutput = /* @__PURE__ */ new Map();
|
|
87087
87264
|
activeResponseMessageId = null;
|
|
87088
87265
|
project(notification) {
|
|
87089
87266
|
switch (notification.type) {
|
|
@@ -87095,15 +87272,37 @@ var CodexProjector = class {
|
|
|
87095
87272
|
notification.delta
|
|
87096
87273
|
)
|
|
87097
87274
|
];
|
|
87275
|
+
case "reasoningSummaryPartAdded":
|
|
87276
|
+
return this.projectReasoningSummaryPartAdded(
|
|
87277
|
+
notification.itemId,
|
|
87278
|
+
notification.summaryIndex
|
|
87279
|
+
);
|
|
87280
|
+
case "reasoningSummaryTextDelta":
|
|
87281
|
+
return this.projectReasoningSummaryTextDelta(
|
|
87282
|
+
notification.itemId,
|
|
87283
|
+
notification.summaryIndex,
|
|
87284
|
+
notification.delta
|
|
87285
|
+
);
|
|
87286
|
+
case "commandExecutionOutputDelta":
|
|
87287
|
+
return this.projectCommandExecutionOutputDelta(
|
|
87288
|
+
notification.itemId,
|
|
87289
|
+
notification.delta
|
|
87290
|
+
);
|
|
87098
87291
|
case "itemStarted":
|
|
87099
87292
|
return this.projectItem(notification.item, "started");
|
|
87100
87293
|
case "itemCompleted":
|
|
87101
87294
|
return this.projectItem(notification.item, "completed");
|
|
87102
|
-
case "turnCompleted":
|
|
87295
|
+
case "turnCompleted": {
|
|
87296
|
+
const outputs = this.endAllReasoningParts();
|
|
87103
87297
|
this.activeResponseMessageId = null;
|
|
87104
87298
|
this.activeAgentMessages.clear();
|
|
87299
|
+
this.agentMessagePhases.clear();
|
|
87300
|
+
this.streamedReasoningIndexes.clear();
|
|
87105
87301
|
this.activeToolCalls.clear();
|
|
87106
|
-
|
|
87302
|
+
this.activeToolMetadata.clear();
|
|
87303
|
+
this.activeToolOutput.clear();
|
|
87304
|
+
return [...outputs, turnCompletionEntry(notification)];
|
|
87305
|
+
}
|
|
87107
87306
|
case "error":
|
|
87108
87307
|
return [errorEntry(notification)];
|
|
87109
87308
|
default:
|
|
@@ -87156,25 +87355,78 @@ var CodexProjector = class {
|
|
|
87156
87355
|
const outputs = [];
|
|
87157
87356
|
if (!this.activeAgentMessages.has(itemId)) {
|
|
87158
87357
|
this.activeAgentMessages.add(itemId);
|
|
87159
|
-
outputs.push(
|
|
87358
|
+
outputs.push(
|
|
87359
|
+
textBoundaryChunk(
|
|
87360
|
+
"text-start",
|
|
87361
|
+
itemId,
|
|
87362
|
+
this.agentMessagePhases.get(itemId)
|
|
87363
|
+
)
|
|
87364
|
+
);
|
|
87160
87365
|
}
|
|
87161
87366
|
outputs.push(
|
|
87162
87367
|
uiChunk2({ type: "text-delta", id: textPartId(itemId), delta })
|
|
87163
87368
|
);
|
|
87164
87369
|
return outputs;
|
|
87165
87370
|
}
|
|
87371
|
+
projectReasoningSummaryPartAdded(itemId, summaryIndex) {
|
|
87372
|
+
const active = this.activeReasoningParts.get(itemId);
|
|
87373
|
+
return active && active.summaryIndex !== summaryIndex ? this.endReasoningPart(itemId) : [];
|
|
87374
|
+
}
|
|
87375
|
+
projectReasoningSummaryTextDelta(itemId, summaryIndex, delta) {
|
|
87376
|
+
if (delta.length === 0) {
|
|
87377
|
+
return [];
|
|
87378
|
+
}
|
|
87379
|
+
const outputs = this.ensureResponseStarted(itemId);
|
|
87380
|
+
const active = this.activeReasoningParts.get(itemId);
|
|
87381
|
+
if (active && active.summaryIndex !== summaryIndex) {
|
|
87382
|
+
outputs.push(...this.endReasoningPart(itemId));
|
|
87383
|
+
}
|
|
87384
|
+
if (!this.activeReasoningParts.has(itemId)) {
|
|
87385
|
+
const id = reasoningPartId(itemId, summaryIndex);
|
|
87386
|
+
this.activeReasoningParts.set(itemId, { id, summaryIndex });
|
|
87387
|
+
outputs.push(uiChunk2({ type: "reasoning-start", id }));
|
|
87388
|
+
}
|
|
87389
|
+
const current = this.activeReasoningParts.get(itemId);
|
|
87390
|
+
if (current) {
|
|
87391
|
+
outputs.push(uiChunk2({ type: "reasoning-delta", id: current.id, delta }));
|
|
87392
|
+
const streamed = this.streamedReasoningIndexes.get(itemId) ?? /* @__PURE__ */ new Set();
|
|
87393
|
+
streamed.add(summaryIndex);
|
|
87394
|
+
this.streamedReasoningIndexes.set(itemId, streamed);
|
|
87395
|
+
}
|
|
87396
|
+
return outputs;
|
|
87397
|
+
}
|
|
87398
|
+
projectCommandExecutionOutputDelta(itemId, delta) {
|
|
87399
|
+
if (!this.activeToolCalls.has(itemId) || delta.length === 0) {
|
|
87400
|
+
return [];
|
|
87401
|
+
}
|
|
87402
|
+
const current = this.activeToolOutput.get(itemId) ?? emptyToolOutput();
|
|
87403
|
+
const next = appendCommandOutput(current, delta);
|
|
87404
|
+
if (next === current) {
|
|
87405
|
+
return [];
|
|
87406
|
+
}
|
|
87407
|
+
this.activeToolOutput.set(itemId, next);
|
|
87408
|
+
return [
|
|
87409
|
+
toolOutputChunk({
|
|
87410
|
+
itemId,
|
|
87411
|
+
output: next.output,
|
|
87412
|
+
isError: false,
|
|
87413
|
+
preliminary: true,
|
|
87414
|
+
toolMetadata: this.activeToolMetadata.get(itemId)
|
|
87415
|
+
})
|
|
87416
|
+
];
|
|
87417
|
+
}
|
|
87166
87418
|
projectItem(item, phase) {
|
|
87167
87419
|
switch (item.type) {
|
|
87168
87420
|
case "agentMessage":
|
|
87421
|
+
if (item.phase) {
|
|
87422
|
+
this.agentMessagePhases.set(item.id, item.phase);
|
|
87423
|
+
}
|
|
87169
87424
|
return [
|
|
87170
87425
|
...this.ensureResponseStarted(item.id),
|
|
87171
87426
|
...this.projectAgentMessageItem(item, phase)
|
|
87172
87427
|
];
|
|
87173
87428
|
case "reasoning":
|
|
87174
|
-
return phase
|
|
87175
|
-
...this.ensureResponseStarted(item.id),
|
|
87176
|
-
...reasoningItemChunks(item)
|
|
87177
|
-
] : [];
|
|
87429
|
+
return this.projectReasoningItem(item, phase);
|
|
87178
87430
|
case "commandExecution":
|
|
87179
87431
|
return this.projectToolItem({
|
|
87180
87432
|
phase,
|
|
@@ -87189,7 +87441,9 @@ var CodexProjector = class {
|
|
|
87189
87441
|
isError: isFailedStatus(item.status) || (item.exitCode ?? 0) !== 0,
|
|
87190
87442
|
title: item.command,
|
|
87191
87443
|
toolMetadata: statusMetadata(item.status, {
|
|
87192
|
-
...item.
|
|
87444
|
+
...(item.commandActions?.length ?? 0) > 0 ? { activities: commandActivities(item.commandActions ?? []) } : {},
|
|
87445
|
+
...item.exitCode != null ? { exitCode: item.exitCode } : {},
|
|
87446
|
+
...item.durationMs != null ? { durationMs: item.durationMs } : {}
|
|
87193
87447
|
})
|
|
87194
87448
|
});
|
|
87195
87449
|
case "fileChange":
|
|
@@ -87218,7 +87472,8 @@ var CodexProjector = class {
|
|
|
87218
87472
|
title: `${item.server}.${item.tool}`,
|
|
87219
87473
|
toolMetadata: statusMetadata(item.status, {
|
|
87220
87474
|
server: item.server,
|
|
87221
|
-
tool: item.tool
|
|
87475
|
+
tool: item.tool,
|
|
87476
|
+
...item.durationMs != null ? { durationMs: item.durationMs } : {}
|
|
87222
87477
|
})
|
|
87223
87478
|
});
|
|
87224
87479
|
default:
|
|
@@ -87228,29 +87483,42 @@ var CodexProjector = class {
|
|
|
87228
87483
|
projectToolItem(input) {
|
|
87229
87484
|
const outputs = [];
|
|
87230
87485
|
outputs.push(...this.ensureResponseStarted(input.itemId));
|
|
87486
|
+
if (input.toolMetadata) {
|
|
87487
|
+
this.activeToolMetadata.set(input.itemId, input.toolMetadata);
|
|
87488
|
+
}
|
|
87231
87489
|
if (input.phase === "started" || !this.activeToolCalls.has(input.itemId)) {
|
|
87232
87490
|
outputs.push(toolInputChunk(input));
|
|
87233
87491
|
this.activeToolCalls.add(input.itemId);
|
|
87234
87492
|
}
|
|
87235
87493
|
if (input.phase === "started") {
|
|
87494
|
+
this.activeToolOutput.set(input.itemId, emptyToolOutput());
|
|
87236
87495
|
return outputs;
|
|
87237
87496
|
}
|
|
87497
|
+
if (input.output === "" && this.activeToolOutput.has(input.itemId)) {
|
|
87498
|
+
input.output = this.activeToolOutput.get(input.itemId)?.output ?? "";
|
|
87499
|
+
}
|
|
87238
87500
|
outputs.push(toolOutputChunk(input));
|
|
87239
87501
|
outputs.push(uiChunk2({ type: "finish-step" }));
|
|
87240
87502
|
this.activeToolCalls.delete(input.itemId);
|
|
87503
|
+
this.activeToolMetadata.delete(input.itemId);
|
|
87504
|
+
this.activeToolOutput.delete(input.itemId);
|
|
87241
87505
|
return outputs;
|
|
87242
87506
|
}
|
|
87243
87507
|
projectAgentMessageItem(item, phase) {
|
|
87508
|
+
if (item.phase) {
|
|
87509
|
+
this.agentMessagePhases.set(item.id, item.phase);
|
|
87510
|
+
}
|
|
87511
|
+
const messagePhase = item.phase ?? this.agentMessagePhases.get(item.id);
|
|
87244
87512
|
if (phase === "started") {
|
|
87245
87513
|
if (this.activeAgentMessages.has(item.id)) {
|
|
87246
87514
|
return [];
|
|
87247
87515
|
}
|
|
87248
87516
|
this.activeAgentMessages.add(item.id);
|
|
87249
|
-
return [
|
|
87517
|
+
return [textBoundaryChunk("text-start", item.id, messagePhase)];
|
|
87250
87518
|
}
|
|
87251
87519
|
const outputs = [];
|
|
87252
87520
|
if (!this.activeAgentMessages.has(item.id)) {
|
|
87253
|
-
outputs.push(
|
|
87521
|
+
outputs.push(textBoundaryChunk("text-start", item.id, messagePhase));
|
|
87254
87522
|
if (item.text.length > 0) {
|
|
87255
87523
|
outputs.push(
|
|
87256
87524
|
uiChunk2({
|
|
@@ -87262,12 +87530,45 @@ var CodexProjector = class {
|
|
|
87262
87530
|
}
|
|
87263
87531
|
}
|
|
87264
87532
|
outputs.push(
|
|
87265
|
-
|
|
87533
|
+
textBoundaryChunk("text-end", item.id, messagePhase),
|
|
87266
87534
|
uiChunk2({ type: "finish-step" })
|
|
87267
87535
|
);
|
|
87268
87536
|
this.activeAgentMessages.delete(item.id);
|
|
87537
|
+
this.agentMessagePhases.delete(item.id);
|
|
87269
87538
|
return outputs;
|
|
87270
87539
|
}
|
|
87540
|
+
projectReasoningItem(item, phase) {
|
|
87541
|
+
if (phase === "started") {
|
|
87542
|
+
return [];
|
|
87543
|
+
}
|
|
87544
|
+
const outputs = this.endReasoningPart(item.id);
|
|
87545
|
+
const streamedIndexes = this.streamedReasoningIndexes.get(item.id);
|
|
87546
|
+
this.streamedReasoningIndexes.delete(item.id);
|
|
87547
|
+
if (streamedIndexes && streamedIndexes.size > 0) {
|
|
87548
|
+
outputs.push(...reasoningItemChunks(item, streamedIndexes));
|
|
87549
|
+
outputs.push(uiChunk2({ type: "finish-step" }));
|
|
87550
|
+
return outputs;
|
|
87551
|
+
}
|
|
87552
|
+
const completedChunks = reasoningItemChunks(item);
|
|
87553
|
+
return completedChunks.length > 0 ? [
|
|
87554
|
+
...this.ensureResponseStarted(item.id),
|
|
87555
|
+
...completedChunks,
|
|
87556
|
+
uiChunk2({ type: "finish-step" })
|
|
87557
|
+
] : [];
|
|
87558
|
+
}
|
|
87559
|
+
endReasoningPart(itemId) {
|
|
87560
|
+
const active = this.activeReasoningParts.get(itemId);
|
|
87561
|
+
if (!active) {
|
|
87562
|
+
return [];
|
|
87563
|
+
}
|
|
87564
|
+
this.activeReasoningParts.delete(itemId);
|
|
87565
|
+
return [uiChunk2({ type: "reasoning-end", id: active.id })];
|
|
87566
|
+
}
|
|
87567
|
+
endAllReasoningParts() {
|
|
87568
|
+
return [...this.activeReasoningParts.keys()].flatMap(
|
|
87569
|
+
(itemId) => this.endReasoningPart(itemId)
|
|
87570
|
+
);
|
|
87571
|
+
}
|
|
87271
87572
|
ensureResponseStarted(messageId) {
|
|
87272
87573
|
if (this.activeResponseMessageId !== null) {
|
|
87273
87574
|
return [];
|
|
@@ -87276,18 +87577,65 @@ var CodexProjector = class {
|
|
|
87276
87577
|
return [uiChunk2({ type: "start", messageId })];
|
|
87277
87578
|
}
|
|
87278
87579
|
};
|
|
87279
|
-
function
|
|
87280
|
-
|
|
87281
|
-
|
|
87580
|
+
function emptyToolOutput() {
|
|
87581
|
+
return { bytes: 0, output: "", truncated: false };
|
|
87582
|
+
}
|
|
87583
|
+
function appendCommandOutput(current, delta) {
|
|
87584
|
+
if (current.truncated) {
|
|
87585
|
+
return current;
|
|
87586
|
+
}
|
|
87587
|
+
const deltaBytes = Buffer3.byteLength(delta, "utf8");
|
|
87588
|
+
if (current.bytes + deltaBytes <= CODEX_COMMAND_OUTPUT_MAX_BYTES) {
|
|
87589
|
+
return {
|
|
87590
|
+
bytes: current.bytes + deltaBytes,
|
|
87591
|
+
output: current.output + delta,
|
|
87592
|
+
truncated: false
|
|
87593
|
+
};
|
|
87594
|
+
}
|
|
87595
|
+
const retainedOutput = utf8Prefix(
|
|
87596
|
+
current.output,
|
|
87597
|
+
CODEX_COMMAND_OUTPUT_CONTENT_MAX_BYTES
|
|
87598
|
+
);
|
|
87599
|
+
const retainedBytes = Buffer3.byteLength(retainedOutput, "utf8");
|
|
87600
|
+
const retainedDelta = utf8Prefix(
|
|
87601
|
+
delta,
|
|
87602
|
+
CODEX_COMMAND_OUTPUT_CONTENT_MAX_BYTES - retainedBytes
|
|
87603
|
+
);
|
|
87604
|
+
const output = `${retainedOutput}${retainedDelta}${CODEX_COMMAND_OUTPUT_TRUNCATION_MARKER}`;
|
|
87605
|
+
return {
|
|
87606
|
+
bytes: Buffer3.byteLength(output, "utf8"),
|
|
87607
|
+
output,
|
|
87608
|
+
truncated: true
|
|
87609
|
+
};
|
|
87610
|
+
}
|
|
87611
|
+
function utf8Prefix(value2, maxBytes) {
|
|
87612
|
+
let bytes = 0;
|
|
87613
|
+
let end = 0;
|
|
87614
|
+
for (const character of value2) {
|
|
87615
|
+
const characterBytes = Buffer3.byteLength(character, "utf8");
|
|
87616
|
+
if (bytes + characterBytes > maxBytes) {
|
|
87617
|
+
break;
|
|
87618
|
+
}
|
|
87619
|
+
bytes += characterBytes;
|
|
87620
|
+
end += character.length;
|
|
87621
|
+
}
|
|
87622
|
+
return value2.slice(0, end);
|
|
87623
|
+
}
|
|
87624
|
+
function reasoningItemChunks(item, excludedIndexes = /* @__PURE__ */ new Set()) {
|
|
87625
|
+
const parts2 = item.summary.map((text2, summaryIndex) => ({ summaryIndex, text: text2.trim() })).filter(
|
|
87626
|
+
(part) => part.text.length > 0 && !excludedIndexes.has(part.summaryIndex)
|
|
87627
|
+
);
|
|
87628
|
+
if (parts2.length === 0) {
|
|
87282
87629
|
return [];
|
|
87283
87630
|
}
|
|
87284
|
-
|
|
87285
|
-
|
|
87286
|
-
|
|
87287
|
-
|
|
87288
|
-
|
|
87289
|
-
|
|
87290
|
-
|
|
87631
|
+
return parts2.flatMap(({ summaryIndex, text: text2 }) => {
|
|
87632
|
+
const id = reasoningPartId(item.id, summaryIndex);
|
|
87633
|
+
return [
|
|
87634
|
+
uiChunk2({ type: "reasoning-start", id }),
|
|
87635
|
+
uiChunk2({ type: "reasoning-delta", id, delta: text2 }),
|
|
87636
|
+
uiChunk2({ type: "reasoning-end", id })
|
|
87637
|
+
];
|
|
87638
|
+
});
|
|
87291
87639
|
}
|
|
87292
87640
|
function toolInputChunk(input) {
|
|
87293
87641
|
return uiChunk2({
|
|
@@ -87316,10 +87664,41 @@ function toolOutputChunk(input) {
|
|
|
87316
87664
|
type: "tool-output-available",
|
|
87317
87665
|
toolCallId: input.itemId,
|
|
87318
87666
|
output: input.output,
|
|
87667
|
+
...input.preliminary !== void 0 ? { preliminary: input.preliminary } : {},
|
|
87319
87668
|
...input.toolMetadata ? { toolMetadata: input.toolMetadata } : {}
|
|
87320
87669
|
}
|
|
87321
87670
|
);
|
|
87322
87671
|
}
|
|
87672
|
+
function textBoundaryChunk(type, itemId, phase) {
|
|
87673
|
+
const providerMetadata = transcriptMessagePhaseProviderMetadata(phase);
|
|
87674
|
+
return uiChunk2({
|
|
87675
|
+
type,
|
|
87676
|
+
id: textPartId(itemId),
|
|
87677
|
+
...providerMetadata ? { providerMetadata } : {}
|
|
87678
|
+
});
|
|
87679
|
+
}
|
|
87680
|
+
function commandActivities(actions) {
|
|
87681
|
+
return actions.map((action) => {
|
|
87682
|
+
switch (action.type) {
|
|
87683
|
+
case "read":
|
|
87684
|
+
return {
|
|
87685
|
+
type: "read",
|
|
87686
|
+
path: action.path,
|
|
87687
|
+
name: action.name
|
|
87688
|
+
};
|
|
87689
|
+
case "listFiles":
|
|
87690
|
+
return { type: "list", path: action.path };
|
|
87691
|
+
case "search":
|
|
87692
|
+
return {
|
|
87693
|
+
type: "search",
|
|
87694
|
+
path: action.path,
|
|
87695
|
+
query: action.query
|
|
87696
|
+
};
|
|
87697
|
+
case "unknown":
|
|
87698
|
+
return { type: "run", command: action.command };
|
|
87699
|
+
}
|
|
87700
|
+
});
|
|
87701
|
+
}
|
|
87323
87702
|
function turnCompletionEntry(notification) {
|
|
87324
87703
|
if (notification.status === "failed") {
|
|
87325
87704
|
const detail = notification.errorMessage ?? "unknown error";
|
|
@@ -87370,8 +87749,8 @@ function approvalQuestion(request) {
|
|
|
87370
87749
|
function textPartId(itemId) {
|
|
87371
87750
|
return `${itemId}:text`;
|
|
87372
87751
|
}
|
|
87373
|
-
function reasoningPartId(itemId) {
|
|
87374
|
-
return `${itemId}:reasoning`;
|
|
87752
|
+
function reasoningPartId(itemId, summaryIndex) {
|
|
87753
|
+
return `${itemId}:reasoning:${summaryIndex.toString()}`;
|
|
87375
87754
|
}
|
|
87376
87755
|
function isFailedStatus(status) {
|
|
87377
87756
|
return status === "failed" || status === "declined";
|