@autohq/cli 0.1.590 → 0.1.592

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.
@@ -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.590",
37739
+ version: "0.1.592",
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(),
@@ -46975,37 +47084,18 @@ var TEAM_TEMPLATES = [
46975
47084
  id: "staff-engineer",
46976
47085
  roleLine: "Owns each task end to end through CI and review."
46977
47086
  },
46978
- {
46979
- id: "senior-engineer",
46980
- roleLine: "Handles complex scoped implementation work."
46981
- },
46982
47087
  {
46983
47088
  id: "junior-engineer",
46984
47089
  roleLine: "Takes mechanical and batch coding work."
46985
47090
  },
46986
- {
46987
- id: "designer",
46988
- roleLine: "Iterates on live UI and graduates it to a production PR."
46989
- },
46990
47091
  {
46991
47092
  id: "pr-review",
46992
47093
  roleLine: "Reviews every pull request against the current head."
46993
47094
  },
46994
- {
46995
- id: "intern",
46996
- roleLine: "Handles quick questions, small fixes, and grunt work."
46997
- },
46998
- {
46999
- id: "ship-digest",
47000
- roleLine: "Summarizes what shipped and what needs attention."
47001
- },
47002
- {
47003
- id: "workforce-optimization-consultant",
47004
- roleLine: "Produces weekly evidence-based team scorecards."
47005
- },
47006
47095
  SELF_IMPROVEMENT
47007
47096
  ],
47008
47097
  availability: "available",
47098
+ onboardingPickerEnabled: true,
47009
47099
  legacyKits: [
47010
47100
  {
47011
47101
  id: "startup",
@@ -47089,6 +47179,7 @@ var TEAM_TEMPLATES = [
47089
47179
  SELF_IMPROVEMENT
47090
47180
  ],
47091
47181
  availability: "available",
47182
+ onboardingPickerEnabled: false,
47092
47183
  legacyKits: [
47093
47184
  {
47094
47185
  id: "code-quality",
@@ -47149,6 +47240,7 @@ var TEAM_TEMPLATES = [
47149
47240
  SELF_IMPROVEMENT
47150
47241
  ],
47151
47242
  availability: "available",
47243
+ onboardingPickerEnabled: false,
47152
47244
  legacyKits: [
47153
47245
  {
47154
47246
  id: "ops",
@@ -47176,6 +47268,7 @@ var TEAM_TEMPLATES = [
47176
47268
  }
47177
47269
  ],
47178
47270
  availability: "available",
47271
+ onboardingPickerEnabled: true,
47179
47272
  legacyKits: [{ id: "custom", name: "Custom", agents: [] }]
47180
47273
  }
47181
47274
  ];
@@ -82965,7 +83058,10 @@ var UiMessagePartTracker = class {
82965
83058
  toolCallId: chunk.toolCallId,
82966
83059
  toolName: chunk.toolName,
82967
83060
  dynamic: chunk.dynamic,
82968
- state: "input-streaming"
83061
+ state: "input-streaming",
83062
+ title: chunk.title,
83063
+ toolMetadata: chunk.toolMetadata,
83064
+ providerExecuted: chunk.providerExecuted
82969
83065
  })
82970
83066
  );
82971
83067
  this.toolPartIndexByCallId.set(chunk.toolCallId, index);
@@ -82978,11 +83074,13 @@ var UiMessagePartTracker = class {
82978
83074
  toolCallId: chunk.toolCallId,
82979
83075
  toolName: chunk.toolName,
82980
83076
  dynamic: chunk.dynamic,
82981
- state: pendingApproval ? "approval-requested" : "input-available"
83077
+ state: pendingApproval ? "approval-requested" : "input-available",
83078
+ title: chunk.title,
83079
+ toolMetadata: chunk.toolMetadata,
83080
+ providerExecuted: chunk.providerExecuted
82982
83081
  }),
82983
83082
  input: chunk.input,
82984
83083
  ...pendingApproval ? { approval: pendingApproval } : {},
82985
- ...chunk.providerExecuted !== void 0 ? { providerExecuted: chunk.providerExecuted } : {},
82986
83084
  ...chunk.providerMetadata !== void 0 ? { callProviderMetadata: chunk.providerMetadata } : {}
82987
83085
  });
82988
83086
  return this.persistable(index);
@@ -82993,10 +83091,14 @@ var UiMessagePartTracker = class {
82993
83091
  toolCallId: chunk.toolCallId,
82994
83092
  toolName: chunk.toolName,
82995
83093
  dynamic: chunk.dynamic,
82996
- state: "output-error"
83094
+ state: "output-error",
83095
+ title: chunk.title,
83096
+ toolMetadata: chunk.toolMetadata,
83097
+ providerExecuted: chunk.providerExecuted
82997
83098
  }),
82998
83099
  input: chunk.input,
82999
- errorText: chunk.errorText
83100
+ errorText: chunk.errorText,
83101
+ ...chunk.providerMetadata !== void 0 ? { callProviderMetadata: chunk.providerMetadata } : {}
83000
83102
  });
83001
83103
  return this.persistable(index);
83002
83104
  }
@@ -83030,6 +83132,15 @@ var UiMessagePartTracker = class {
83030
83132
  part.state = "output-available";
83031
83133
  part.output = chunk.output;
83032
83134
  part.preliminary = chunk.preliminary;
83135
+ if (chunk.toolMetadata !== void 0) {
83136
+ part.toolMetadata = chunk.toolMetadata;
83137
+ }
83138
+ if (chunk.providerMetadata !== void 0) {
83139
+ part.resultProviderMetadata = chunk.providerMetadata;
83140
+ }
83141
+ if (chunk.providerExecuted !== void 0) {
83142
+ part.providerExecuted = chunk.providerExecuted;
83143
+ }
83033
83144
  this.settleApproval(part, chunk.toolCallId, { approved: true });
83034
83145
  return this.persistable(index);
83035
83146
  }
@@ -83057,6 +83168,15 @@ var UiMessagePartTracker = class {
83057
83168
  }
83058
83169
  part.state = "output-error";
83059
83170
  part.errorText = chunk.errorText;
83171
+ if (chunk.toolMetadata !== void 0) {
83172
+ part.toolMetadata = chunk.toolMetadata;
83173
+ }
83174
+ if (chunk.providerMetadata !== void 0) {
83175
+ part.resultProviderMetadata = chunk.providerMetadata;
83176
+ }
83177
+ if (chunk.providerExecuted !== void 0) {
83178
+ part.providerExecuted = chunk.providerExecuted;
83179
+ }
83060
83180
  this.settleApproval(part, chunk.toolCallId, { approved: true });
83061
83181
  return this.persistable(index);
83062
83182
  }
@@ -83188,18 +83308,23 @@ var UiMessagePartTracker = class {
83188
83308
  }
83189
83309
  };
83190
83310
  function toolPartShape(input) {
83311
+ const common = {
83312
+ toolCallId: input.toolCallId,
83313
+ state: input.state,
83314
+ ...input.title !== void 0 ? { title: input.title } : {},
83315
+ ...input.toolMetadata !== void 0 ? { toolMetadata: input.toolMetadata } : {},
83316
+ ...input.providerExecuted !== void 0 ? { providerExecuted: input.providerExecuted } : {}
83317
+ };
83191
83318
  if (input.dynamic) {
83192
83319
  return {
83193
83320
  type: "dynamic-tool",
83194
83321
  toolName: input.toolName,
83195
- toolCallId: input.toolCallId,
83196
- state: input.state
83322
+ ...common
83197
83323
  };
83198
83324
  }
83199
83325
  return {
83200
83326
  type: `tool-${input.toolName}`,
83201
- toolCallId: input.toolCallId,
83202
- state: input.state
83327
+ ...common
83203
83328
  };
83204
83329
  }
83205
83330
  function providerMetadataField(providerMetadata) {
@@ -83478,6 +83603,10 @@ var AgentBridgeOutputBuffer = class {
83478
83603
  }
83479
83604
  await this.flushPendingUiDelta();
83480
83605
  this.pendingUiDelta = { context, chunk: { ...chunk }, createdAt: now2() };
83606
+ if (uiDeltaTextLength(chunk) >= AGENT_BRIDGE_OUTPUT_UI_DELTA_MAX_CHARS) {
83607
+ await this.flushPendingUiDelta();
83608
+ return;
83609
+ }
83481
83610
  this.scheduleUiDeltaFlush();
83482
83611
  }
83483
83612
  scheduleUiDeltaFlush() {
@@ -83520,9 +83649,9 @@ var AgentBridgeOutputBuffer = class {
83520
83649
  await this.drainPendingOutputs();
83521
83650
  }
83522
83651
  // Turns the parked coalesced chunk into a queued envelope and applies it to
83523
- // the part tracker and message assembler, exactly as its source chunks would
83524
- // have applied one by one (delta chunks never settle a part or complete a
83525
- // message, so tracker/assembler side effects reduce to text accumulation).
83652
+ // the part tracker and message assembler. Text/input deltas concatenate;
83653
+ // preliminary tool output is already cumulative, so only its latest snapshot
83654
+ // is retained before the final result flushes it.
83526
83655
  // Does not drain: the drain loop calls this mid-loop and keeps pulling.
83527
83656
  async materializePendingUiDelta() {
83528
83657
  const pending = this.pendingUiDelta;
@@ -83889,6 +84018,9 @@ function legacyToolEntries(chunk) {
83889
84018
  }
83890
84019
  ];
83891
84020
  case "tool-output-available":
84021
+ if (chunk.preliminary) {
84022
+ return [];
84023
+ }
83892
84024
  return [
83893
84025
  {
83894
84026
  role: "tool",
@@ -83979,6 +84111,12 @@ function coalescibleUiDeltaChunk(projection) {
83979
84111
  return chunk.providerMetadata === void 0 ? chunk : null;
83980
84112
  case "tool-input-delta":
83981
84113
  return chunk;
84114
+ case "tool-output-available":
84115
+ return chunk.preliminary === true && typeof chunk.output === "string" ? {
84116
+ ...chunk,
84117
+ output: chunk.output,
84118
+ preliminary: true
84119
+ } : null;
83982
84120
  default:
83983
84121
  return null;
83984
84122
  }
@@ -83990,7 +84128,10 @@ function canCoalesceUiDelta(pending, context, chunk) {
83990
84128
  if (pending.chunk.type === "tool-input-delta" && chunk.type === "tool-input-delta") {
83991
84129
  return pending.chunk.toolCallId === chunk.toolCallId;
83992
84130
  }
83993
- if (pending.chunk.type !== "tool-input-delta" && chunk.type !== "tool-input-delta") {
84131
+ if (pending.chunk.type === "tool-output-available" && chunk.type === "tool-output-available") {
84132
+ return pending.chunk.toolCallId === chunk.toolCallId;
84133
+ }
84134
+ if ((pending.chunk.type === "text-delta" || pending.chunk.type === "reasoning-delta") && (chunk.type === "text-delta" || chunk.type === "reasoning-delta")) {
83994
84135
  return pending.chunk.id === chunk.id;
83995
84136
  }
83996
84137
  return false;
@@ -84002,7 +84143,10 @@ function mergeUiDeltaChunks(pending, chunk) {
84002
84143
  inputTextDelta: pending.inputTextDelta + chunk.inputTextDelta
84003
84144
  };
84004
84145
  }
84005
- if (pending.type !== "tool-input-delta" && chunk.type !== "tool-input-delta") {
84146
+ if (pending.type === "tool-output-available" && chunk.type === "tool-output-available") {
84147
+ return chunk;
84148
+ }
84149
+ if ((pending.type === "text-delta" || pending.type === "reasoning-delta") && (chunk.type === "text-delta" || chunk.type === "reasoning-delta")) {
84006
84150
  return { ...pending, delta: pending.delta + chunk.delta };
84007
84151
  }
84008
84152
  throw new Error(
@@ -84010,7 +84154,14 @@ function mergeUiDeltaChunks(pending, chunk) {
84010
84154
  );
84011
84155
  }
84012
84156
  function uiDeltaTextLength(chunk) {
84013
- return chunk.type === "tool-input-delta" ? chunk.inputTextDelta.length : chunk.delta.length;
84157
+ switch (chunk.type) {
84158
+ case "tool-input-delta":
84159
+ return chunk.inputTextDelta.length;
84160
+ case "tool-output-available":
84161
+ return chunk.output.length;
84162
+ default:
84163
+ return chunk.delta.length;
84164
+ }
84014
84165
  }
84015
84166
  function canCoalesceDelta(pending, context, delta) {
84016
84167
  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 +87232,19 @@ function commandLogContext(delivery, fields = {}) {
87081
87232
  }
87082
87233
 
87083
87234
  // src/commands/agent-bridge/harness/codex/projector.ts
87235
+ import { Buffer as Buffer3 } from "buffer";
87236
+ var CODEX_COMMAND_OUTPUT_MAX_BYTES = 32 * 1024;
87237
+ var CODEX_COMMAND_OUTPUT_TRUNCATION_MARKER = `
87238
+ [codex command output truncated at the ${CODEX_COMMAND_OUTPUT_MAX_BYTES.toString()}-byte live-stream limit]`;
87239
+ var CODEX_COMMAND_OUTPUT_CONTENT_MAX_BYTES = CODEX_COMMAND_OUTPUT_MAX_BYTES - Buffer3.byteLength(CODEX_COMMAND_OUTPUT_TRUNCATION_MARKER, "utf8");
87084
87240
  var CodexProjector = class {
87085
87241
  activeAgentMessages = /* @__PURE__ */ new Set();
87242
+ agentMessagePhases = /* @__PURE__ */ new Map();
87243
+ activeReasoningParts = /* @__PURE__ */ new Map();
87244
+ streamedReasoningIndexes = /* @__PURE__ */ new Map();
87086
87245
  activeToolCalls = /* @__PURE__ */ new Set();
87246
+ activeToolMetadata = /* @__PURE__ */ new Map();
87247
+ activeToolOutput = /* @__PURE__ */ new Map();
87087
87248
  activeResponseMessageId = null;
87088
87249
  project(notification) {
87089
87250
  switch (notification.type) {
@@ -87095,15 +87256,37 @@ var CodexProjector = class {
87095
87256
  notification.delta
87096
87257
  )
87097
87258
  ];
87259
+ case "reasoningSummaryPartAdded":
87260
+ return this.projectReasoningSummaryPartAdded(
87261
+ notification.itemId,
87262
+ notification.summaryIndex
87263
+ );
87264
+ case "reasoningSummaryTextDelta":
87265
+ return this.projectReasoningSummaryTextDelta(
87266
+ notification.itemId,
87267
+ notification.summaryIndex,
87268
+ notification.delta
87269
+ );
87270
+ case "commandExecutionOutputDelta":
87271
+ return this.projectCommandExecutionOutputDelta(
87272
+ notification.itemId,
87273
+ notification.delta
87274
+ );
87098
87275
  case "itemStarted":
87099
87276
  return this.projectItem(notification.item, "started");
87100
87277
  case "itemCompleted":
87101
87278
  return this.projectItem(notification.item, "completed");
87102
- case "turnCompleted":
87279
+ case "turnCompleted": {
87280
+ const outputs = this.endAllReasoningParts();
87103
87281
  this.activeResponseMessageId = null;
87104
87282
  this.activeAgentMessages.clear();
87283
+ this.agentMessagePhases.clear();
87284
+ this.streamedReasoningIndexes.clear();
87105
87285
  this.activeToolCalls.clear();
87106
- return [turnCompletionEntry(notification)];
87286
+ this.activeToolMetadata.clear();
87287
+ this.activeToolOutput.clear();
87288
+ return [...outputs, turnCompletionEntry(notification)];
87289
+ }
87107
87290
  case "error":
87108
87291
  return [errorEntry(notification)];
87109
87292
  default:
@@ -87156,25 +87339,78 @@ var CodexProjector = class {
87156
87339
  const outputs = [];
87157
87340
  if (!this.activeAgentMessages.has(itemId)) {
87158
87341
  this.activeAgentMessages.add(itemId);
87159
- outputs.push(uiChunk2({ type: "text-start", id: textPartId(itemId) }));
87342
+ outputs.push(
87343
+ textBoundaryChunk(
87344
+ "text-start",
87345
+ itemId,
87346
+ this.agentMessagePhases.get(itemId)
87347
+ )
87348
+ );
87160
87349
  }
87161
87350
  outputs.push(
87162
87351
  uiChunk2({ type: "text-delta", id: textPartId(itemId), delta })
87163
87352
  );
87164
87353
  return outputs;
87165
87354
  }
87355
+ projectReasoningSummaryPartAdded(itemId, summaryIndex) {
87356
+ const active = this.activeReasoningParts.get(itemId);
87357
+ return active && active.summaryIndex !== summaryIndex ? this.endReasoningPart(itemId) : [];
87358
+ }
87359
+ projectReasoningSummaryTextDelta(itemId, summaryIndex, delta) {
87360
+ if (delta.length === 0) {
87361
+ return [];
87362
+ }
87363
+ const outputs = this.ensureResponseStarted(itemId);
87364
+ const active = this.activeReasoningParts.get(itemId);
87365
+ if (active && active.summaryIndex !== summaryIndex) {
87366
+ outputs.push(...this.endReasoningPart(itemId));
87367
+ }
87368
+ if (!this.activeReasoningParts.has(itemId)) {
87369
+ const id = reasoningPartId(itemId, summaryIndex);
87370
+ this.activeReasoningParts.set(itemId, { id, summaryIndex });
87371
+ outputs.push(uiChunk2({ type: "reasoning-start", id }));
87372
+ }
87373
+ const current = this.activeReasoningParts.get(itemId);
87374
+ if (current) {
87375
+ outputs.push(uiChunk2({ type: "reasoning-delta", id: current.id, delta }));
87376
+ const streamed = this.streamedReasoningIndexes.get(itemId) ?? /* @__PURE__ */ new Set();
87377
+ streamed.add(summaryIndex);
87378
+ this.streamedReasoningIndexes.set(itemId, streamed);
87379
+ }
87380
+ return outputs;
87381
+ }
87382
+ projectCommandExecutionOutputDelta(itemId, delta) {
87383
+ if (!this.activeToolCalls.has(itemId) || delta.length === 0) {
87384
+ return [];
87385
+ }
87386
+ const current = this.activeToolOutput.get(itemId) ?? emptyToolOutput();
87387
+ const next = appendCommandOutput(current, delta);
87388
+ if (next === current) {
87389
+ return [];
87390
+ }
87391
+ this.activeToolOutput.set(itemId, next);
87392
+ return [
87393
+ toolOutputChunk({
87394
+ itemId,
87395
+ output: next.output,
87396
+ isError: false,
87397
+ preliminary: true,
87398
+ toolMetadata: this.activeToolMetadata.get(itemId)
87399
+ })
87400
+ ];
87401
+ }
87166
87402
  projectItem(item, phase) {
87167
87403
  switch (item.type) {
87168
87404
  case "agentMessage":
87405
+ if (item.phase) {
87406
+ this.agentMessagePhases.set(item.id, item.phase);
87407
+ }
87169
87408
  return [
87170
87409
  ...this.ensureResponseStarted(item.id),
87171
87410
  ...this.projectAgentMessageItem(item, phase)
87172
87411
  ];
87173
87412
  case "reasoning":
87174
- return phase === "completed" ? [
87175
- ...this.ensureResponseStarted(item.id),
87176
- ...reasoningItemChunks(item)
87177
- ] : [];
87413
+ return this.projectReasoningItem(item, phase);
87178
87414
  case "commandExecution":
87179
87415
  return this.projectToolItem({
87180
87416
  phase,
@@ -87189,7 +87425,9 @@ var CodexProjector = class {
87189
87425
  isError: isFailedStatus(item.status) || (item.exitCode ?? 0) !== 0,
87190
87426
  title: item.command,
87191
87427
  toolMetadata: statusMetadata(item.status, {
87192
- ...item.exitCode !== void 0 ? { exitCode: item.exitCode } : {}
87428
+ ...(item.commandActions?.length ?? 0) > 0 ? { activities: commandActivities(item.commandActions ?? []) } : {},
87429
+ ...item.exitCode != null ? { exitCode: item.exitCode } : {},
87430
+ ...item.durationMs != null ? { durationMs: item.durationMs } : {}
87193
87431
  })
87194
87432
  });
87195
87433
  case "fileChange":
@@ -87218,7 +87456,8 @@ var CodexProjector = class {
87218
87456
  title: `${item.server}.${item.tool}`,
87219
87457
  toolMetadata: statusMetadata(item.status, {
87220
87458
  server: item.server,
87221
- tool: item.tool
87459
+ tool: item.tool,
87460
+ ...item.durationMs != null ? { durationMs: item.durationMs } : {}
87222
87461
  })
87223
87462
  });
87224
87463
  default:
@@ -87228,29 +87467,42 @@ var CodexProjector = class {
87228
87467
  projectToolItem(input) {
87229
87468
  const outputs = [];
87230
87469
  outputs.push(...this.ensureResponseStarted(input.itemId));
87470
+ if (input.toolMetadata) {
87471
+ this.activeToolMetadata.set(input.itemId, input.toolMetadata);
87472
+ }
87231
87473
  if (input.phase === "started" || !this.activeToolCalls.has(input.itemId)) {
87232
87474
  outputs.push(toolInputChunk(input));
87233
87475
  this.activeToolCalls.add(input.itemId);
87234
87476
  }
87235
87477
  if (input.phase === "started") {
87478
+ this.activeToolOutput.set(input.itemId, emptyToolOutput());
87236
87479
  return outputs;
87237
87480
  }
87481
+ if (input.output === "" && this.activeToolOutput.has(input.itemId)) {
87482
+ input.output = this.activeToolOutput.get(input.itemId)?.output ?? "";
87483
+ }
87238
87484
  outputs.push(toolOutputChunk(input));
87239
87485
  outputs.push(uiChunk2({ type: "finish-step" }));
87240
87486
  this.activeToolCalls.delete(input.itemId);
87487
+ this.activeToolMetadata.delete(input.itemId);
87488
+ this.activeToolOutput.delete(input.itemId);
87241
87489
  return outputs;
87242
87490
  }
87243
87491
  projectAgentMessageItem(item, phase) {
87492
+ if (item.phase) {
87493
+ this.agentMessagePhases.set(item.id, item.phase);
87494
+ }
87495
+ const messagePhase = item.phase ?? this.agentMessagePhases.get(item.id);
87244
87496
  if (phase === "started") {
87245
87497
  if (this.activeAgentMessages.has(item.id)) {
87246
87498
  return [];
87247
87499
  }
87248
87500
  this.activeAgentMessages.add(item.id);
87249
- return [uiChunk2({ type: "text-start", id: textPartId(item.id) })];
87501
+ return [textBoundaryChunk("text-start", item.id, messagePhase)];
87250
87502
  }
87251
87503
  const outputs = [];
87252
87504
  if (!this.activeAgentMessages.has(item.id)) {
87253
- outputs.push(uiChunk2({ type: "text-start", id: textPartId(item.id) }));
87505
+ outputs.push(textBoundaryChunk("text-start", item.id, messagePhase));
87254
87506
  if (item.text.length > 0) {
87255
87507
  outputs.push(
87256
87508
  uiChunk2({
@@ -87262,12 +87514,45 @@ var CodexProjector = class {
87262
87514
  }
87263
87515
  }
87264
87516
  outputs.push(
87265
- uiChunk2({ type: "text-end", id: textPartId(item.id) }),
87517
+ textBoundaryChunk("text-end", item.id, messagePhase),
87266
87518
  uiChunk2({ type: "finish-step" })
87267
87519
  );
87268
87520
  this.activeAgentMessages.delete(item.id);
87521
+ this.agentMessagePhases.delete(item.id);
87269
87522
  return outputs;
87270
87523
  }
87524
+ projectReasoningItem(item, phase) {
87525
+ if (phase === "started") {
87526
+ return [];
87527
+ }
87528
+ const outputs = this.endReasoningPart(item.id);
87529
+ const streamedIndexes = this.streamedReasoningIndexes.get(item.id);
87530
+ this.streamedReasoningIndexes.delete(item.id);
87531
+ if (streamedIndexes && streamedIndexes.size > 0) {
87532
+ outputs.push(...reasoningItemChunks(item, streamedIndexes));
87533
+ outputs.push(uiChunk2({ type: "finish-step" }));
87534
+ return outputs;
87535
+ }
87536
+ const completedChunks = reasoningItemChunks(item);
87537
+ return completedChunks.length > 0 ? [
87538
+ ...this.ensureResponseStarted(item.id),
87539
+ ...completedChunks,
87540
+ uiChunk2({ type: "finish-step" })
87541
+ ] : [];
87542
+ }
87543
+ endReasoningPart(itemId) {
87544
+ const active = this.activeReasoningParts.get(itemId);
87545
+ if (!active) {
87546
+ return [];
87547
+ }
87548
+ this.activeReasoningParts.delete(itemId);
87549
+ return [uiChunk2({ type: "reasoning-end", id: active.id })];
87550
+ }
87551
+ endAllReasoningParts() {
87552
+ return [...this.activeReasoningParts.keys()].flatMap(
87553
+ (itemId) => this.endReasoningPart(itemId)
87554
+ );
87555
+ }
87271
87556
  ensureResponseStarted(messageId) {
87272
87557
  if (this.activeResponseMessageId !== null) {
87273
87558
  return [];
@@ -87276,18 +87561,65 @@ var CodexProjector = class {
87276
87561
  return [uiChunk2({ type: "start", messageId })];
87277
87562
  }
87278
87563
  };
87279
- function reasoningItemChunks(item) {
87280
- const text2 = item.summary.map((line) => line.trim()).filter(Boolean).join("\n\n");
87281
- if (text2.length === 0) {
87564
+ function emptyToolOutput() {
87565
+ return { bytes: 0, output: "", truncated: false };
87566
+ }
87567
+ function appendCommandOutput(current, delta) {
87568
+ if (current.truncated) {
87569
+ return current;
87570
+ }
87571
+ const deltaBytes = Buffer3.byteLength(delta, "utf8");
87572
+ if (current.bytes + deltaBytes <= CODEX_COMMAND_OUTPUT_MAX_BYTES) {
87573
+ return {
87574
+ bytes: current.bytes + deltaBytes,
87575
+ output: current.output + delta,
87576
+ truncated: false
87577
+ };
87578
+ }
87579
+ const retainedOutput = utf8Prefix(
87580
+ current.output,
87581
+ CODEX_COMMAND_OUTPUT_CONTENT_MAX_BYTES
87582
+ );
87583
+ const retainedBytes = Buffer3.byteLength(retainedOutput, "utf8");
87584
+ const retainedDelta = utf8Prefix(
87585
+ delta,
87586
+ CODEX_COMMAND_OUTPUT_CONTENT_MAX_BYTES - retainedBytes
87587
+ );
87588
+ const output = `${retainedOutput}${retainedDelta}${CODEX_COMMAND_OUTPUT_TRUNCATION_MARKER}`;
87589
+ return {
87590
+ bytes: Buffer3.byteLength(output, "utf8"),
87591
+ output,
87592
+ truncated: true
87593
+ };
87594
+ }
87595
+ function utf8Prefix(value2, maxBytes) {
87596
+ let bytes = 0;
87597
+ let end = 0;
87598
+ for (const character of value2) {
87599
+ const characterBytes = Buffer3.byteLength(character, "utf8");
87600
+ if (bytes + characterBytes > maxBytes) {
87601
+ break;
87602
+ }
87603
+ bytes += characterBytes;
87604
+ end += character.length;
87605
+ }
87606
+ return value2.slice(0, end);
87607
+ }
87608
+ function reasoningItemChunks(item, excludedIndexes = /* @__PURE__ */ new Set()) {
87609
+ const parts2 = item.summary.map((text2, summaryIndex) => ({ summaryIndex, text: text2.trim() })).filter(
87610
+ (part) => part.text.length > 0 && !excludedIndexes.has(part.summaryIndex)
87611
+ );
87612
+ if (parts2.length === 0) {
87282
87613
  return [];
87283
87614
  }
87284
- const id = reasoningPartId(item.id);
87285
- return [
87286
- uiChunk2({ type: "reasoning-start", id }),
87287
- uiChunk2({ type: "reasoning-delta", id, delta: text2 }),
87288
- uiChunk2({ type: "reasoning-end", id }),
87289
- uiChunk2({ type: "finish-step" })
87290
- ];
87615
+ return parts2.flatMap(({ summaryIndex, text: text2 }) => {
87616
+ const id = reasoningPartId(item.id, summaryIndex);
87617
+ return [
87618
+ uiChunk2({ type: "reasoning-start", id }),
87619
+ uiChunk2({ type: "reasoning-delta", id, delta: text2 }),
87620
+ uiChunk2({ type: "reasoning-end", id })
87621
+ ];
87622
+ });
87291
87623
  }
87292
87624
  function toolInputChunk(input) {
87293
87625
  return uiChunk2({
@@ -87316,10 +87648,41 @@ function toolOutputChunk(input) {
87316
87648
  type: "tool-output-available",
87317
87649
  toolCallId: input.itemId,
87318
87650
  output: input.output,
87651
+ ...input.preliminary !== void 0 ? { preliminary: input.preliminary } : {},
87319
87652
  ...input.toolMetadata ? { toolMetadata: input.toolMetadata } : {}
87320
87653
  }
87321
87654
  );
87322
87655
  }
87656
+ function textBoundaryChunk(type, itemId, phase) {
87657
+ const providerMetadata = transcriptMessagePhaseProviderMetadata(phase);
87658
+ return uiChunk2({
87659
+ type,
87660
+ id: textPartId(itemId),
87661
+ ...providerMetadata ? { providerMetadata } : {}
87662
+ });
87663
+ }
87664
+ function commandActivities(actions) {
87665
+ return actions.map((action) => {
87666
+ switch (action.type) {
87667
+ case "read":
87668
+ return {
87669
+ type: "read",
87670
+ path: action.path,
87671
+ name: action.name
87672
+ };
87673
+ case "listFiles":
87674
+ return { type: "list", path: action.path };
87675
+ case "search":
87676
+ return {
87677
+ type: "search",
87678
+ path: action.path,
87679
+ query: action.query
87680
+ };
87681
+ case "unknown":
87682
+ return { type: "run", command: action.command };
87683
+ }
87684
+ });
87685
+ }
87323
87686
  function turnCompletionEntry(notification) {
87324
87687
  if (notification.status === "failed") {
87325
87688
  const detail = notification.errorMessage ?? "unknown error";
@@ -87370,8 +87733,8 @@ function approvalQuestion(request) {
87370
87733
  function textPartId(itemId) {
87371
87734
  return `${itemId}:text`;
87372
87735
  }
87373
- function reasoningPartId(itemId) {
87374
- return `${itemId}:reasoning`;
87736
+ function reasoningPartId(itemId, summaryIndex) {
87737
+ return `${itemId}:reasoning:${summaryIndex.toString()}`;
87375
87738
  }
87376
87739
  function isFailedStatus(status) {
87377
87740
  return status === "failed" || status === "declined";