remote-codex 0.11.25 → 0.11.26

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.
@@ -10903,6 +10903,23 @@ function compactJson(value) {
10903
10903
  return String(value);
10904
10904
  }
10905
10905
  }
10906
+ function joinReasoningText(left, right) {
10907
+ if (!left) {
10908
+ return right;
10909
+ }
10910
+ if (!right) {
10911
+ return left;
10912
+ }
10913
+ if (right.startsWith(left)) {
10914
+ return right;
10915
+ }
10916
+ if (left.endsWith(right)) {
10917
+ return left;
10918
+ }
10919
+ return `${left}
10920
+
10921
+ ${right}`;
10922
+ }
10906
10923
  function readableToolName(toolName) {
10907
10924
  if (CLAUDE_TOOL_LABELS[toolName]) {
10908
10925
  return CLAUDE_TOOL_LABELS[toolName];
@@ -11207,11 +11224,16 @@ function assistantMessageToHistoryItems(input) {
11207
11224
  if (type === "thinking") {
11208
11225
  const thinking = thinkingTextFromBlock(block);
11209
11226
  if (thinking) {
11210
- items.push({
11211
- id: `${input.messageId}:content:${index}`,
11212
- kind: "reasoning",
11213
- text: thinking
11214
- });
11227
+ const previous = items.at(-1);
11228
+ if (previous?.kind === "reasoning") {
11229
+ previous.text = joinReasoningText(previous.text, thinking);
11230
+ } else {
11231
+ items.push({
11232
+ id: `${input.messageId}:content:${index}`,
11233
+ kind: "reasoning",
11234
+ text: thinking
11235
+ });
11236
+ }
11215
11237
  }
11216
11238
  continue;
11217
11239
  }
@@ -11403,12 +11425,15 @@ function resultForToolUse(input) {
11403
11425
  };
11404
11426
  }
11405
11427
  function buildAgentTurn(input) {
11428
+ const startedAt = input.startedAt ?? null;
11406
11429
  const turn = {
11407
11430
  providerTurnId: input.providerTurnId,
11408
- startedAt: input.startedAt ?? null,
11431
+ startedAt,
11409
11432
  status: input.status,
11410
11433
  error: input.error ? { message: input.error } : null,
11411
- items: input.items
11434
+ items: input.items.map(
11435
+ (item) => item.createdAt || !startedAt ? item : { ...item, createdAt: startedAt }
11436
+ )
11412
11437
  };
11413
11438
  if (input.rawTurn !== void 0) {
11414
11439
  turn.rawTurn = input.rawTurn;
@@ -11955,6 +11980,9 @@ function streamMessageId(event) {
11955
11980
  const message = event.message;
11956
11981
  return messageIdFromPayload(message);
11957
11982
  }
11983
+ function sessionMessageTimestamp(message) {
11984
+ return typeof message.uuid === "string" ? isoFromUuidV7(message.uuid) : null;
11985
+ }
11958
11986
  function addOrUpdateItem(state, item) {
11959
11987
  if (!state.items.has(item.id)) {
11960
11988
  state.itemOrder.push(item.id);
@@ -11964,6 +11992,53 @@ function addOrUpdateItem(state, item) {
11964
11992
  function orderedItems(state) {
11965
11993
  return state.itemOrder.map((id) => state.items.get(id)).filter((item) => Boolean(item));
11966
11994
  }
11995
+ function withHistoryItemCreatedAt(item, createdAt) {
11996
+ if (item.createdAt || !createdAt) {
11997
+ return item;
11998
+ }
11999
+ return { ...item, createdAt };
12000
+ }
12001
+ function latestReasoningItem(state) {
12002
+ const lastItemId = state.itemOrder.at(-1);
12003
+ const lastItem = lastItemId ? state.items.get(lastItemId) : null;
12004
+ return lastItem?.kind === "reasoning" ? lastItem : null;
12005
+ }
12006
+ function joinReasoningText2(left, right) {
12007
+ if (!left) {
12008
+ return right;
12009
+ }
12010
+ if (!right) {
12011
+ return left;
12012
+ }
12013
+ if (right.startsWith(left)) {
12014
+ return right;
12015
+ }
12016
+ if (left.endsWith(right)) {
12017
+ return left;
12018
+ }
12019
+ return `${left}
12020
+
12021
+ ${right}`;
12022
+ }
12023
+ function isRunningHistoryItemStatus(status) {
12024
+ const normalized = status?.trim().toLowerCase();
12025
+ return normalized === "running" || normalized === "pending" || normalized === "in_progress" || normalized === "in progress";
12026
+ }
12027
+ function finalizeTurnItems(state, status, completedAt) {
12028
+ return orderedItems(state).map((item) => {
12029
+ if (item.kind === "userMessage") {
12030
+ return item;
12031
+ }
12032
+ if (status === "completed" && isRunningHistoryItemStatus(item.status)) {
12033
+ return {
12034
+ ...item,
12035
+ status: "completed",
12036
+ createdAt: item.createdAt ?? completedAt
12037
+ };
12038
+ }
12039
+ return withHistoryItemCreatedAt(item, completedAt);
12040
+ });
12041
+ }
11967
12042
  function stringFromRecord(value, key) {
11968
12043
  const raw = value[key];
11969
12044
  return typeof raw === "string" && raw.trim() ? raw : null;
@@ -12286,7 +12361,13 @@ var ClaudeRuntimeAdapter = class extends EventEmitter5 {
12286
12361
  const sessions = await this.withClaudeConfigEnv(() => this.listSessionsFn({}));
12287
12362
  return sessions.map((session) => {
12288
12363
  this.knownSessionIds.add(session.sessionId);
12289
- return sessionSummaryFromInfo(session);
12364
+ const summary = sessionSummaryFromInfo(session);
12365
+ const activeTurn = this.activeTurnForSession(summary.providerSessionId);
12366
+ return activeTurn ? {
12367
+ ...summary,
12368
+ status: "running",
12369
+ updatedAt: summary.updatedAt ?? activeTurn.startedAt
12370
+ } : summary;
12290
12371
  });
12291
12372
  }
12292
12373
  async listLoadedSessions() {
@@ -12453,9 +12534,12 @@ var ClaudeRuntimeAdapter = class extends EventEmitter5 {
12453
12534
  tools: { type: "preset", preset: "claude_code" }
12454
12535
  })
12455
12536
  });
12456
- const userItem = userMessageToHistoryItem(`${providerTurnId}:user`, {
12457
- content: input.prompt
12458
- });
12537
+ const userItem = withHistoryItemCreatedAt(
12538
+ userMessageToHistoryItem(`${providerTurnId}:user`, {
12539
+ content: input.prompt
12540
+ }),
12541
+ startedAt
12542
+ );
12459
12543
  const initialItems = input.hidden ? [] : [userItem];
12460
12544
  const state = {
12461
12545
  providerSessionId: input.providerSessionId,
@@ -12538,6 +12622,14 @@ var ClaudeRuntimeAdapter = class extends EventEmitter5 {
12538
12622
  this.liveUserPrompts.delete(state.providerSessionId);
12539
12623
  }
12540
12624
  }
12625
+ activeTurnForSession(providerSessionId) {
12626
+ for (const state of this.activeTurns.values()) {
12627
+ if (state.providerSessionId === providerSessionId && !state.completed) {
12628
+ return state;
12629
+ }
12630
+ }
12631
+ return null;
12632
+ }
12541
12633
  reconcileActiveTranscriptTurn(providerSessionId, turns, activeTurn) {
12542
12634
  if (!activeTurn || turns.length === 0) {
12543
12635
  return turns;
@@ -12590,37 +12682,24 @@ var ClaudeRuntimeAdapter = class extends EventEmitter5 {
12590
12682
  }
12591
12683
  async consumeQuery(state) {
12592
12684
  const rawMessages = [];
12685
+ let terminalStatus = null;
12686
+ let terminalError = null;
12593
12687
  try {
12594
12688
  for await (const message of state.query) {
12595
12689
  rawMessages.push(message);
12596
- if (state.completed) {
12597
- continue;
12598
- }
12599
12690
  this.consumeMessage(state, message);
12600
12691
  const status = queryResultStatus(message);
12601
12692
  if (status) {
12602
- state.completed = true;
12603
- this.deleteActiveTurn(state);
12604
- this.emitUsage(state);
12605
- this.emitRuntimeEvent({
12606
- type: "turn.completed",
12607
- provider: "claude",
12608
- providerSessionId: state.providerSessionId,
12609
- turn: buildAgentTurn({
12610
- providerTurnId: state.providerTurnId,
12611
- startedAt: state.startedAt,
12612
- status: state.interrupted ? "interrupted" : status,
12613
- error: queryResultError(message),
12614
- items: orderedItems(state),
12615
- rawTurn: rawMessages
12616
- })
12617
- });
12693
+ terminalStatus = status;
12694
+ terminalError = queryResultError(message);
12618
12695
  }
12619
12696
  }
12620
12697
  if (!state.completed) {
12621
12698
  state.completed = true;
12622
12699
  this.deleteActiveTurn(state);
12623
12700
  this.emitUsage(state);
12701
+ const completedAt = (/* @__PURE__ */ new Date()).toISOString();
12702
+ const status = state.interrupted ? "interrupted" : terminalStatus ?? "completed";
12624
12703
  this.emitRuntimeEvent({
12625
12704
  type: "turn.completed",
12626
12705
  provider: "claude",
@@ -12628,8 +12707,9 @@ var ClaudeRuntimeAdapter = class extends EventEmitter5 {
12628
12707
  turn: buildAgentTurn({
12629
12708
  providerTurnId: state.providerTurnId,
12630
12709
  startedAt: state.startedAt,
12631
- status: state.interrupted ? "interrupted" : "completed",
12632
- items: orderedItems(state),
12710
+ status,
12711
+ error: terminalError,
12712
+ items: finalizeTurnItems(state, status, completedAt),
12633
12713
  rawTurn: rawMessages
12634
12714
  })
12635
12715
  });
@@ -12650,6 +12730,7 @@ var ClaudeRuntimeAdapter = class extends EventEmitter5 {
12650
12730
  }
12651
12731
  consumeMessage(state, message) {
12652
12732
  this.captureUsage(state, message);
12733
+ const messageCreatedAt = (/* @__PURE__ */ new Date()).toISOString();
12653
12734
  if (message.type === "system" && message.subtype === "init") {
12654
12735
  this.updateToolboxItemsFromSystemInit(message);
12655
12736
  if (message.session_id) {
@@ -12669,8 +12750,9 @@ var ClaudeRuntimeAdapter = class extends EventEmitter5 {
12669
12750
  event: message.event
12670
12751
  });
12671
12752
  if (toolItem) {
12672
- addOrUpdateItem(state, toolItem);
12673
- this.emitItem(state, toolItem, "item.started");
12753
+ const nextItem = withHistoryItemCreatedAt(toolItem, messageCreatedAt);
12754
+ addOrUpdateItem(state, nextItem);
12755
+ this.emitItem(state, nextItem, "item.started");
12674
12756
  return;
12675
12757
  }
12676
12758
  const reasoningItem = partialReasoningDelta({
@@ -12679,14 +12761,15 @@ var ClaudeRuntimeAdapter = class extends EventEmitter5 {
12679
12761
  });
12680
12762
  if (reasoningItem) {
12681
12763
  const existing = state.items.get(reasoningItem.id);
12682
- const nextItem = existing?.kind === "reasoning" ? {
12683
- ...existing,
12684
- text: `${existing.text}${reasoningItem.text}`,
12685
- status: reasoningItem.status ?? existing.status ?? null
12686
- } : reasoningItem;
12764
+ const previousReasoning = existing?.kind === "reasoning" ? existing : latestReasoningItem(state);
12765
+ const nextItem = previousReasoning ? {
12766
+ ...previousReasoning,
12767
+ text: previousReasoning.id === reasoningItem.id ? `${previousReasoning.text}${reasoningItem.text}` : joinReasoningText2(previousReasoning.text, reasoningItem.text),
12768
+ status: reasoningItem.status ?? previousReasoning.status ?? null
12769
+ } : withHistoryItemCreatedAt(reasoningItem, messageCreatedAt);
12687
12770
  addOrUpdateItem(state, nextItem);
12688
- this.emitItem(state, nextItem, existing ? "item.completed" : "item.started", {
12689
- force: Boolean(existing)
12771
+ this.emitItem(state, nextItem, previousReasoning ? "item.completed" : "item.started", {
12772
+ force: Boolean(previousReasoning)
12690
12773
  });
12691
12774
  return;
12692
12775
  }
@@ -12701,6 +12784,7 @@ var ClaudeRuntimeAdapter = class extends EventEmitter5 {
12701
12784
  text: `${existing.text}${delta.delta}`
12702
12785
  }) : markTransientAgentHistoryItem({
12703
12786
  id: delta.itemId,
12787
+ createdAt: messageCreatedAt,
12704
12788
  kind: "agentMessage",
12705
12789
  text: delta.delta
12706
12790
  });
@@ -12728,8 +12812,9 @@ var ClaudeRuntimeAdapter = class extends EventEmitter5 {
12728
12812
  result: message.tool_use_result ?? toolResult.result,
12729
12813
  previous: state.items.get(toolResult.toolUseId) ?? null
12730
12814
  });
12731
- addOrUpdateItem(state, item);
12732
- this.emitItem(state, item, "item.completed");
12815
+ const nextItem = withHistoryItemCreatedAt(item, messageCreatedAt);
12816
+ addOrUpdateItem(state, nextItem);
12817
+ this.emitItem(state, nextItem, "item.completed");
12733
12818
  }
12734
12819
  return;
12735
12820
  }
@@ -12760,12 +12845,13 @@ var ClaudeRuntimeAdapter = class extends EventEmitter5 {
12760
12845
  messageId: assistantMessageId,
12761
12846
  message: payload
12762
12847
  })) {
12763
- const existing = state.items.get(item.id);
12764
- addOrUpdateItem(state, item);
12765
- if (item.kind !== "agentMessage" && !existing) {
12766
- this.emitItem(state, item, "item.started");
12767
- } else if (item.kind !== "agentMessage" && existing) {
12768
- this.emitItem(state, item, "item.started", { force: true });
12848
+ const nextItem = withHistoryItemCreatedAt(item, messageCreatedAt);
12849
+ const existing = state.items.get(nextItem.id);
12850
+ addOrUpdateItem(state, nextItem);
12851
+ if (nextItem.kind !== "agentMessage" && !existing) {
12852
+ this.emitItem(state, nextItem, "item.started");
12853
+ } else if (nextItem.kind !== "agentMessage" && existing) {
12854
+ this.emitItem(state, nextItem, "item.started", { force: true });
12769
12855
  }
12770
12856
  }
12771
12857
  return;
@@ -12779,8 +12865,9 @@ var ClaudeRuntimeAdapter = class extends EventEmitter5 {
12779
12865
  result: message.tool_use_result ?? message.message,
12780
12866
  previous: state.items.get(message.parent_tool_use_id) ?? null
12781
12867
  });
12782
- addOrUpdateItem(state, item);
12783
- this.emitItem(state, item, "item.completed");
12868
+ const nextItem = withHistoryItemCreatedAt(item, messageCreatedAt);
12869
+ addOrUpdateItem(state, nextItem);
12870
+ this.emitItem(state, nextItem, "item.completed");
12784
12871
  return;
12785
12872
  }
12786
12873
  if (message.type === "tool_progress") {
@@ -12799,8 +12886,9 @@ var ClaudeRuntimeAdapter = class extends EventEmitter5 {
12799
12886
  status: "running"
12800
12887
  });
12801
12888
  if (item) {
12802
- addOrUpdateItem(state, item);
12803
- this.emitItem(state, item, "item.started");
12889
+ const nextItem = withHistoryItemCreatedAt(item, messageCreatedAt);
12890
+ addOrUpdateItem(state, nextItem);
12891
+ this.emitItem(state, nextItem, "item.started");
12804
12892
  } else {
12805
12893
  state.suppressedToolUseIds.add(toolUseId);
12806
12894
  }
@@ -12819,13 +12907,15 @@ var ClaudeRuntimeAdapter = class extends EventEmitter5 {
12819
12907
  detailText: [previous.detailText ?? previous.text, "", message.message].join("\n")
12820
12908
  } : {
12821
12909
  id: toolUseId,
12910
+ createdAt: messageCreatedAt,
12822
12911
  kind: "toolCall",
12823
12912
  text: `${message.tool_name} denied`,
12824
12913
  detailText: typeof message.message === "string" ? message.message : null,
12825
12914
  status: "denied"
12826
12915
  };
12827
- addOrUpdateItem(state, item);
12828
- this.emitItem(state, item, "item.completed");
12916
+ const nextItem = withHistoryItemCreatedAt(item, messageCreatedAt);
12917
+ addOrUpdateItem(state, nextItem);
12918
+ this.emitItem(state, nextItem, "item.completed");
12829
12919
  }
12830
12920
  }
12831
12921
  captureUsage(state, message) {
@@ -12996,6 +13086,18 @@ var ClaudeRuntimeAdapter = class extends EventEmitter5 {
12996
13086
  itemsById: /* @__PURE__ */ new Map()
12997
13087
  };
12998
13088
  }
13089
+ const previous = current.items.at(-1);
13090
+ if (item.kind === "reasoning" && previous?.kind === "reasoning") {
13091
+ const merged = {
13092
+ ...previous,
13093
+ text: joinReasoningText2(previous.text, item.text),
13094
+ status: item.status ?? previous.status ?? null
13095
+ };
13096
+ current.items[current.items.length - 1] = merged;
13097
+ current.itemsById.set(previous.id, merged);
13098
+ current.itemsById.set(item.id, merged);
13099
+ return;
13100
+ }
12999
13101
  const existingIndex = current.items.findIndex((entry) => entry.id === item.id);
13000
13102
  if (existingIndex >= 0) {
13001
13103
  current.items[existingIndex] = item;
@@ -13013,11 +13115,16 @@ var ClaudeRuntimeAdapter = class extends EventEmitter5 {
13013
13115
  if (toolResults.length > 0) {
13014
13116
  for (const toolResult of toolResults) {
13015
13117
  const previous = current?.itemsById.get(toolResult.toolUseId) ?? null;
13016
- upsertCurrentItem(resultForToolUse({
13017
- toolUseId: toolResult.toolUseId,
13018
- result: toolResult.result,
13019
- previous
13020
- }));
13118
+ upsertCurrentItem(
13119
+ withHistoryItemCreatedAt(
13120
+ resultForToolUse({
13121
+ toolUseId: toolResult.toolUseId,
13122
+ result: toolResult.result,
13123
+ previous
13124
+ }),
13125
+ sessionMessageTimestamp(message) ?? current?.startedAt
13126
+ )
13127
+ );
13021
13128
  }
13022
13129
  continue;
13023
13130
  }
@@ -13044,16 +13151,18 @@ var ClaudeRuntimeAdapter = class extends EventEmitter5 {
13044
13151
  }));
13045
13152
  }
13046
13153
  const messageUuid2 = message.uuid ?? randomUUID2();
13154
+ const userStartedAt = isoFromUuidV7(messageUuid2);
13047
13155
  const userItem = await this.userMessageToHistoryItem(
13048
13156
  messageUuid2,
13049
13157
  message.message,
13050
13158
  context
13051
13159
  );
13160
+ const stampedUserItem = withHistoryItemCreatedAt(userItem, userStartedAt);
13052
13161
  current = {
13053
13162
  providerTurnId: `claude-turn-${messageUuid2}`,
13054
- startedAt: isoFromUuidV7(messageUuid2),
13055
- items: [userItem],
13056
- itemsById: /* @__PURE__ */ new Map([[messageUuid2, userItem]])
13163
+ startedAt: userStartedAt,
13164
+ items: [stampedUserItem],
13165
+ itemsById: /* @__PURE__ */ new Map([[messageUuid2, stampedUserItem]])
13057
13166
  };
13058
13167
  continue;
13059
13168
  }
@@ -13061,6 +13170,7 @@ var ClaudeRuntimeAdapter = class extends EventEmitter5 {
13061
13170
  continue;
13062
13171
  }
13063
13172
  if (message.type === "assistant") {
13173
+ const assistantCreatedAt = sessionMessageTimestamp(message) ?? current?.startedAt;
13064
13174
  for (const toolUseId of suppressedClaudeToolUseIds(message.message)) {
13065
13175
  suppressedToolUseIds.add(toolUseId);
13066
13176
  current?.itemsById.delete(toolUseId);
@@ -13069,7 +13179,7 @@ var ClaudeRuntimeAdapter = class extends EventEmitter5 {
13069
13179
  messageId: message.uuid ?? randomUUID2(),
13070
13180
  message: message.message
13071
13181
  })) {
13072
- upsertCurrentItem(item);
13182
+ upsertCurrentItem(withHistoryItemCreatedAt(item, assistantCreatedAt));
13073
13183
  }
13074
13184
  continue;
13075
13185
  }
@@ -13078,11 +13188,16 @@ var ClaudeRuntimeAdapter = class extends EventEmitter5 {
13078
13188
  continue;
13079
13189
  }
13080
13190
  const previous = current?.itemsById.get(message.parent_tool_use_id) ?? null;
13081
- upsertCurrentItem(resultForToolUse({
13082
- toolUseId: message.parent_tool_use_id,
13083
- result: isRecord8(message.message) && "content" in message.message ? message.message.content : message.message,
13084
- previous
13085
- }));
13191
+ upsertCurrentItem(
13192
+ withHistoryItemCreatedAt(
13193
+ resultForToolUse({
13194
+ toolUseId: message.parent_tool_use_id,
13195
+ result: isRecord8(message.message) && "content" in message.message ? message.message.content : message.message,
13196
+ previous
13197
+ }),
13198
+ sessionMessageTimestamp(message) ?? current?.startedAt
13199
+ )
13200
+ );
13086
13201
  }
13087
13202
  }
13088
13203
  if (current && current.items.length > 0) {
@@ -14954,7 +15069,7 @@ var E2EFakeRuntime = class extends EventEmitter7 {
14954
15069
  permissionRequests: false,
14955
15070
  sandboxMode: false,
14956
15071
  performanceMode: false,
14957
- goals: false
15072
+ goals: true
14958
15073
  },
14959
15074
  management: {
14960
15075
  models: true,
@@ -14970,6 +15085,12 @@ var E2EFakeRuntime = class extends EventEmitter7 {
14970
15085
  managementSchema = {
14971
15086
  hostConfigFiles: [],
14972
15087
  toolboxItems: [
15088
+ {
15089
+ action: "goal",
15090
+ command: "/goal",
15091
+ label: "Goal",
15092
+ description: "Manage the current goal."
15093
+ },
14973
15094
  {
14974
15095
  action: "fork",
14975
15096
  command: "/fork",
@@ -14996,6 +15117,7 @@ var E2EFakeRuntime = class extends EventEmitter7 {
14996
15117
  };
14997
15118
  sessions = /* @__PURE__ */ new Map();
14998
15119
  providerRequests = /* @__PURE__ */ new Map();
15120
+ goals = /* @__PURE__ */ new Map();
14999
15121
  activeTurnId = null;
15000
15122
  startedAt = null;
15001
15123
  getStatus() {
@@ -15107,6 +15229,42 @@ var E2EFakeRuntime = class extends EventEmitter7 {
15107
15229
  rawSession: session
15108
15230
  };
15109
15231
  }
15232
+ async getGoal(providerSessionId) {
15233
+ return this.goals.get(providerSessionId) ?? null;
15234
+ }
15235
+ async setGoal(input) {
15236
+ const existing = this.goals.get(input.providerSessionId);
15237
+ const now = Date.now();
15238
+ const goal = {
15239
+ providerSessionId: input.providerSessionId,
15240
+ objective: input.objective ?? existing?.objective ?? "E2E shared goal",
15241
+ status: input.status ?? existing?.status ?? "active",
15242
+ tokenBudget: input.tokenBudget !== void 0 ? input.tokenBudget : existing?.tokenBudget ?? null,
15243
+ tokensUsed: existing?.tokensUsed ?? 0,
15244
+ timeUsedSeconds: existing?.timeUsedSeconds ?? 0,
15245
+ createdAt: existing?.createdAt ?? now,
15246
+ updatedAt: now,
15247
+ rawGoal: null
15248
+ };
15249
+ this.goals.set(input.providerSessionId, goal);
15250
+ this.emitRuntimeEvent({
15251
+ type: "goal.updated",
15252
+ provider,
15253
+ providerSessionId: input.providerSessionId,
15254
+ providerTurnId: null,
15255
+ goal
15256
+ });
15257
+ return goal;
15258
+ }
15259
+ async clearGoal(providerSessionId) {
15260
+ const existed = this.goals.delete(providerSessionId);
15261
+ this.emitRuntimeEvent({
15262
+ type: "goal.cleared",
15263
+ provider,
15264
+ providerSessionId
15265
+ });
15266
+ return existed;
15267
+ }
15110
15268
  async startTurn(input) {
15111
15269
  const session = await this.readSession(input.providerSessionId);
15112
15270
  const providerTurnId = `e2e-turn-${session.turns.length + 1}`;
@@ -16369,7 +16527,7 @@ function deferLargeHistoryItemDetails(turn, deferredDetails) {
16369
16527
  };
16370
16528
  }
16371
16529
  function shouldPersistLiveHistoryItem(item) {
16372
- return item.kind === "commandExecution" || item.kind === "fileChange" || item.kind === "fileRead" || item.kind === "hook" || item.kind === "agentToolCall" || item.kind === "skillToolCall" || item.kind === "toolCall" || item.kind === "webSearch";
16530
+ return item.kind === "commandExecution" || item.kind === "fileChange" || item.kind === "fileRead" || item.kind === "hook" || item.kind === "agentToolCall" || item.kind === "skillToolCall" || item.kind === "toolCall" || item.kind === "reasoning" || item.kind === "webSearch";
16373
16531
  }
16374
16532
  function shouldPersistFinalHistoryItem(item) {
16375
16533
  return item.kind === "agentMessage" || shouldPersistLiveHistoryItem(item);
@@ -17419,7 +17577,7 @@ var ThreadRuntimeEventProjector = class {
17419
17577
  const sequence = liveState.recordTurnItemOrder(record.id, turnId, item.id);
17420
17578
  const eventTimestamp = (/* @__PURE__ */ new Date()).toISOString();
17421
17579
  const orderedLiveItem = {
17422
- ...withHistoryItemCreatedAt(item, eventTimestamp),
17580
+ ...withHistoryItemCreatedAt2(item, eventTimestamp),
17423
17581
  sequence
17424
17582
  };
17425
17583
  const transportLiveItem = deferHistoryItemDetailForTransport(orderedLiveItem);
@@ -17470,7 +17628,7 @@ var ThreadRuntimeEventProjector = class {
17470
17628
  }
17471
17629
  const eventTimestamp = (/* @__PURE__ */ new Date()).toISOString();
17472
17630
  const liveItem = {
17473
- ...withHistoryItemCreatedAt(event.item, eventTimestamp),
17631
+ ...withHistoryItemCreatedAt2(event.item, eventTimestamp),
17474
17632
  sequence: liveState.recordTurnItemOrder(record.id, turnId, event.item.id)
17475
17633
  };
17476
17634
  const transportLiveItem = deferHistoryItemDetailForTransport(liveItem);
@@ -17503,7 +17661,7 @@ var ThreadRuntimeEventProjector = class {
17503
17661
  );
17504
17662
  const eventTimestamp = (/* @__PURE__ */ new Date()).toISOString();
17505
17663
  const orderedLiveItem = {
17506
- ...withHistoryItemCreatedAt(event.item, eventTimestamp),
17664
+ ...withHistoryItemCreatedAt2(event.item, eventTimestamp),
17507
17665
  sequence
17508
17666
  };
17509
17667
  const transportLiveItem = deferHistoryItemDetailForTransport(orderedLiveItem);
@@ -17676,7 +17834,7 @@ var ThreadRuntimeEventProjector = class {
17676
17834
  return typeof value === "object" && value !== null && !Array.isArray(value);
17677
17835
  }
17678
17836
  };
17679
- function withHistoryItemCreatedAt(item, createdAt) {
17837
+ function withHistoryItemCreatedAt2(item, createdAt) {
17680
17838
  return item.createdAt ? item : { ...item, createdAt };
17681
17839
  }
17682
17840