@codexhost/cli-linux-arm64 0.19.0 → 0.21.0

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.
Files changed (63) hide show
  1. package/README.md +1 -1
  2. package/app/codexhost-distribution.json +1 -1
  3. package/app/console-server.mjs +45 -4
  4. package/app/console-web.js +1124 -684
  5. package/app/desktop-controller.mjs +197 -50
  6. package/app/host-runtime.mjs +36192 -29254
  7. package/app/plugins/antigravity/assets/icon.svg +1 -1
  8. package/app/plugins/antigravity/plugin.mjs +8863 -4094
  9. package/app/plugins/claude-code/plugin.mjs +173 -26
  10. package/app/plugins/codebuddy/plugin.mjs +71 -6
  11. package/app/plugins/codex-usage/plugin.mjs +56 -4
  12. package/app/plugins/copilot/plugin.mjs +48 -4
  13. package/app/plugins/cursor-cli/plugin.mjs +48 -4
  14. package/app/plugins/deepseek-harness/plugin.mjs +73 -9
  15. package/app/plugins/devin/plugin.mjs +47 -4
  16. package/app/plugins/grok/plugin.mjs +84 -13
  17. package/app/plugins/hermes/plugin.mjs +47 -4
  18. package/app/plugins/kimi-code/plugin.mjs +73 -14
  19. package/app/plugins/kiro-cli/plugin.mjs +48 -4
  20. package/app/plugins/omp/plugin.mjs +74 -7
  21. package/app/plugins/opencode/plugin.mjs +74 -13
  22. package/app/plugins/pi/plugin.mjs +75 -7
  23. package/app/plugins/qoder/plugin.mjs +85 -5
  24. package/app/plugins/qoder-cn/plugin.mjs +85 -5
  25. package/app/plugins/qwen-code/plugin.mjs +48 -4
  26. package/app/plugins/workbuddy/plugin.mjs +75 -9
  27. package/app/plugins/zcode/plugin.mjs +56 -4
  28. package/app/renderer-extension.js +1431 -737
  29. package/app/web/assets/index-BdmZfTRW.js +201 -0
  30. package/app/web/assets/index-DJW4bmyx.css +1 -0
  31. package/app/web/assets/langs/{graphql-B8vkg11W.js → graphql-ChAeyPkT.js} +1 -1
  32. package/app/web/assets/langs/{http-DmoDEjMt.js → http-BvreBIbD.js} +1 -1
  33. package/app/web/assets/langs/{php-DJ5ovfAM.js → php-D8omCIuJ.js} +1 -1
  34. package/app/web/assets/langs/{rst-U5-R5x3p.js → rst-Do7RLLCS.js} +1 -1
  35. package/app/web/assets/langs/{ruby-VKVsnS0H.js → ruby-rH_O_vse.js} +1 -1
  36. package/app/web/assets/langs/{svelte-C20lOv9V.js → svelte-xZy73wAj.js} +1 -1
  37. package/app/web/assets/langs/{vue-z6Y-lzP-.js → vue-C4DW8agZ.js} +1 -1
  38. package/app/web/assets/{vendor-dSL872WO.js → vendor-C9g2bw8s.js} +3 -3
  39. package/app/web/codexhost-settings.js +1130 -686
  40. package/app/web/index.html +4 -3
  41. package/app/web/plugins/deepseek-ai__dsh-api-gateway/client.js +2 -2
  42. package/app/web/plugins/deepseek-ai__dsh-api-remotes/client.js +1 -1
  43. package/app/web/plugins/deepseek-ai__dsh-api-session-controller/client.js +8 -8
  44. package/app/web/plugins/deepseek-ai__dsh-client-connection/client.js +1 -1
  45. package/app/web/plugins/deepseek-ai__dsh-client-ui-chat/client.js +74 -69
  46. package/app/web/plugins/deepseek-ai__dsh-client-ui-codexhost/client.js +7 -7
  47. package/app/web/plugins/deepseek-ai__dsh-client-ui-conversation/client.js +27 -27
  48. package/app/web/plugins/deepseek-ai__dsh-client-ui-input-trigger/client.js +1 -1
  49. package/app/web/plugins/deepseek-ai__dsh-client-ui-layout/client.js +2 -2
  50. package/app/web/plugins/deepseek-ai__dsh-client-ui-model-selection/client.js +1 -1
  51. package/app/web/plugins/deepseek-ai__dsh-client-ui-session/client.js +1 -1
  52. package/app/web/plugins/deepseek-ai__dsh-client-ui-settings-general/client.js +1 -1
  53. package/app/web/plugins/deepseek-ai__dsh-client-ui-sidebar/client.js +1 -1
  54. package/app/web/plugins/deepseek-ai__dsh-client-ui-sidebar-documentpreview/client.js +9 -9
  55. package/app/web/plugins/deepseek-ai__dsh-client-ui-tool/client.js +18 -18
  56. package/app/web/plugins/deepseek-ai__dsh-client-ui-workspace/client.js +7 -7
  57. package/app/web-modules/server.mjs +1144 -731
  58. package/bin/codexhost +0 -0
  59. package/libexec/codexhost-shim +0 -0
  60. package/libexec/codexhost-updater +0 -0
  61. package/package.json +1 -1
  62. package/app/web/assets/index-BNQIOOHE.css +0 -1
  63. package/app/web/assets/index-Feo4BkqN.js +0 -199
@@ -14662,13 +14662,25 @@ var threadPermissionModeSelectParamsSchema = external_exports.object({
14662
14662
  var nonNegativeSafeIntegerSchema = external_exports.number().int().safe().nonnegative();
14663
14663
  var finiteNonNegativeNumberSchema = external_exports.number().finite().nonnegative();
14664
14664
  var cacheHitRatePercentSchema = external_exports.number().finite().min(0).max(100);
14665
+ var usageOutputTimingSchema = external_exports.object({
14666
+ version: external_exports.union([external_exports.literal(3), external_exports.literal(4)]).optional(),
14667
+ requestId: external_exports.string().min(1),
14668
+ turnId: external_exports.string().min(1).max(1024),
14669
+ outputTokens: nonNegativeSafeIntegerSchema,
14670
+ startedAtMs: nonNegativeSafeIntegerSchema,
14671
+ completedAtMs: nonNegativeSafeIntegerSchema
14672
+ }).strict().refine((value) => value.completedAtMs > value.startedAtMs);
14665
14673
  var usageMeasurementSchema = external_exports.object({
14674
+ version: external_exports.union([external_exports.literal(2), external_exports.literal(3), external_exports.literal(4)]).optional(),
14666
14675
  value: finiteNonNegativeNumberSchema,
14667
14676
  turnId: external_exports.string().min(1).max(1024),
14668
14677
  at: nonNegativeSafeIntegerSchema
14669
14678
  }).strict();
14670
14679
  var usageMeasurementsSchema = external_exports.object({
14671
- outputTokensPerSecond: usageMeasurementSchema.optional(),
14680
+ // Older intervals can omit hidden thinking time; do not restore them into averages.
14681
+ outputTimings: external_exports.array(usageOutputTimingSchema).transform((values) => values.filter((value) => value.version === 4)).optional(),
14682
+ // Retain independent TTFT facts when dropping incompatible speed measurements.
14683
+ outputTokensPerSecond: usageMeasurementSchema.refine((value) => value.version === 4).optional().catch(void 0),
14672
14684
  timeToFirstOutputMs: usageMeasurementSchema.extend({ value: nonNegativeSafeIntegerSchema }).optional()
14673
14685
  }).strict();
14674
14686
  var indicatorTextSchema = (maximum) => harnessLocalizedTextSchema.refine((entries) => Object.values(entries).every((text2) => text2.length <= maximum));
@@ -14688,6 +14700,7 @@ var threadUsageSnapshotSchema = external_exports.object({
14688
14700
  cacheWriteInputTokens: nonNegativeSafeIntegerSchema.optional(),
14689
14701
  outputTokens: nonNegativeSafeIntegerSchema.optional(),
14690
14702
  outputTokensPerSecond: finiteNonNegativeNumberSchema.optional(),
14703
+ sessionOutputTokensPerSecond: finiteNonNegativeNumberSchema.optional(),
14691
14704
  apiOutputTokensPerSecond: finiteNonNegativeNumberSchema.optional(),
14692
14705
  reasoningOutputTokens: nonNegativeSafeIntegerSchema.optional(),
14693
14706
  totalTokens: nonNegativeSafeIntegerSchema.optional(),
@@ -15099,6 +15112,10 @@ var threadSteeringInspectResultSchema = external_exports.object({
15099
15112
  delivery: external_exports.enum(["official", "activeTurn", "newTurn"])
15100
15113
  }).strict();
15101
15114
 
15115
+ // ../../shared-contracts/dist/thread-archive-confirm.js
15116
+ var threadArchiveConfirmParamsSchema = external_exports.object({ threadId: hostThreadIdSchema }).strict();
15117
+ var threadArchiveConfirmResultSchema = external_exports.object({ confirmed: external_exports.boolean() }).strict();
15118
+
15102
15119
  // ../../shared-contracts/dist/client-channel.js
15103
15120
  var CLIENT_CHANNEL_VERSION = 1;
15104
15121
  var CLIENT_REQUEST_LIMIT_BYTES = 128 * 1024 * 1024;
@@ -15129,6 +15146,11 @@ var clientChannelEventSchema = external_exports.discriminatedUnion("type", [
15129
15146
  cursor: clientChannelCursorSchema,
15130
15147
  cwd: external_exports.string().optional()
15131
15148
  }),
15149
+ external_exports.object({
15150
+ type: external_exports.literal("harness-inspection-changed"),
15151
+ cursor: clientChannelCursorSchema,
15152
+ harnessId: external_exports.string().min(1)
15153
+ }),
15132
15154
  external_exports.object({ type: external_exports.literal("display-settings-changed"), cursor: clientChannelCursorSchema }),
15133
15155
  external_exports.object({
15134
15156
  type: external_exports.literal("preferences-changed"),
@@ -15200,6 +15222,8 @@ var clientItemTruncationSchema = external_exports.object({
15200
15222
  var clientTurnSchema = external_exports.object({
15201
15223
  id: external_exports.string().min(1),
15202
15224
  status: external_exports.string().min(1),
15225
+ /** Native history has no terminal evidence; Desktop's status vocabulary cannot express this. */
15226
+ codexhostTurnOutcome: external_exports.object({ status: external_exports.literal("unknown"), reason: external_exports.string() }).optional(),
15203
15227
  items: external_exports.array(external_exports.object({ id: external_exports.string().min(1), type: external_exports.string().min(1) }).passthrough()),
15204
15228
  /** Original file operations, independent of the cumulative Desktop fileChange card.
15205
15229
  * Insert before the named non-file Item; null appends at the end of the Turn.
@@ -15238,7 +15262,12 @@ var clientThreadSnapshotSchema = external_exports.object({
15238
15262
  /** Current interruptible Host Turn, including command Turns omitted from client history. */
15239
15263
  activeTurnId: external_exports.string().min(1).nullable().optional(),
15240
15264
  /** Most recent explicit command in this Host process; not native conversation history. */
15241
- command: external_exports.object({ name: external_exports.string().min(1), turn: clientTurnSchema }).optional(),
15265
+ command: external_exports.object({
15266
+ name: external_exports.string().min(1),
15267
+ turn: clientTurnSchema,
15268
+ /** First ordinary Turn started after this command; its retained result is not a new event. */
15269
+ subsequentTurnId: external_exports.string().min(1).optional()
15270
+ }).optional(),
15242
15271
  thread: external_exports.object({
15243
15272
  id: external_exports.string().min(1),
15244
15273
  cwd: external_exports.string(),
@@ -15446,7 +15475,6 @@ var webAccessStateSchema = external_exports.object({
15446
15475
  quotaUntil: external_exports.string().optional()
15447
15476
  }).strict().optional()
15448
15477
  }).strict();
15449
- var webLocalAccessRequiredDetailsSchema = external_exports.object({ url: external_exports.string() }).strict();
15450
15478
 
15451
15479
  // ../../shared-contracts/dist/delegation-read.js
15452
15480
  var REMOTE_THREAD_REPLY_MAX_BYTES = 16 * 1024 * 1024;
@@ -16412,6 +16440,7 @@ var THREAD_WATCH_NOTICE_OUTCOMES = [
16412
16440
  "completed",
16413
16441
  "failed",
16414
16442
  "interrupted",
16443
+ "needsInput",
16415
16444
  "timedOut",
16416
16445
  "unreadable",
16417
16446
  "notFound"
@@ -16458,13 +16487,25 @@ var target = { hostId: identity.regex(/^remote-(?:ssh(?:-|:)|control:)/u) };
16458
16487
  var thread = { ...target, threadId: identity };
16459
16488
  var remoteSessionOperationSchema = external_exports.discriminatedUnion("kind", [
16460
16489
  external_exports.strictObject({ kind: external_exports.literal("hosts") }),
16490
+ external_exports.strictObject({ kind: external_exports.literal("status"), ...thread }),
16461
16491
  external_exports.strictObject({
16462
16492
  kind: external_exports.literal("list"),
16463
16493
  ...target,
16464
16494
  cursor: external_exports.string().nullable(),
16465
16495
  archived: external_exports.boolean()
16466
16496
  }),
16467
- external_exports.strictObject({ kind: external_exports.literal("read"), ...thread }),
16497
+ external_exports.strictObject({
16498
+ kind: external_exports.literal("read"),
16499
+ ...thread,
16500
+ page: external_exports.strictObject({
16501
+ cursor: external_exports.string().min(1).max(8192).nullable(),
16502
+ epoch: identity.optional(),
16503
+ sortDirection: external_exports.enum(["asc", "desc"]).optional(),
16504
+ limit: external_exports.number().int().min(1).max(20).optional()
16505
+ }).refine((page) => page.cursor === null || page.epoch !== void 0, {
16506
+ message: "A history continuation requires its connection epoch"
16507
+ }).optional()
16508
+ }),
16468
16509
  external_exports.strictObject({
16469
16510
  kind: external_exports.literal("configure"),
16470
16511
  ...thread,
@@ -16729,6 +16770,7 @@ var usageFields = /* @__PURE__ */ new Set([
16729
16770
  "totalCredits",
16730
16771
  "contextUsagePercent",
16731
16772
  "outputTokensPerSecond",
16773
+ "sessionOutputTokensPerSecond",
16732
16774
  "apiOutputTokensPerSecond",
16733
16775
  "costSource",
16734
16776
  "unpricedModels"
@@ -16751,6 +16793,7 @@ function parseHostUsage(value) {
16751
16793
  for (const field2 of [
16752
16794
  "totalCredits",
16753
16795
  "contextUsagePercent",
16796
+ "sessionOutputTokensPerSecond",
16754
16797
  "apiOutputTokensPerSecond"
16755
16798
  ]) {
16756
16799
  const candidate = value[field2];
@@ -16829,6 +16872,7 @@ var requestTokenFields = [
16829
16872
  "cacheWrite1hInputTokens",
16830
16873
  "outputTokens",
16831
16874
  "reasoningOutputTokens",
16875
+ "timedOutputTokens",
16832
16876
  "startedAtMs",
16833
16877
  "completedAtMs"
16834
16878
  ];
@@ -16881,6 +16925,14 @@ function parseHostUsageRequest(value) {
16881
16925
  if (request.startedAtMs === void 0 !== (request.completedAtMs === void 0)) {
16882
16926
  throw new Error("Harness Usage request timing fields must be provided together");
16883
16927
  }
16928
+ if (request.timedOutputTokens !== void 0) {
16929
+ if (request.startedAtMs === void 0) {
16930
+ throw new Error("Harness Usage request 'timedOutputTokens' requires timing fields");
16931
+ }
16932
+ if (request.timedOutputTokens > request.outputTokens) {
16933
+ throw new Error("Harness Usage request 'timedOutputTokens' must not exceed 'outputTokens'");
16934
+ }
16935
+ }
16884
16936
  if (request.startedAtMs !== void 0 && request.completedAtMs !== void 0 && request.completedAtMs < request.startedAtMs) {
16885
16937
  throw new Error("Harness Usage request 'completedAtMs' must not precede 'startedAtMs'");
16886
16938
  }
@@ -55588,6 +55640,8 @@ function parseClaudeWorkflowAgents(value) {
55588
55640
  var ClaudeNativeTurnAccumulator = class {
55589
55641
  #provider;
55590
55642
  #activeRootStreamMessageId = null;
55643
+ /** Native record UUIDs already published, across stream and request message IDs. */
55644
+ #publishedCheckpointIds = /* @__PURE__ */ new Set();
55591
55645
  #assistantErrors = [];
55592
55646
  #cancelRequested = false;
55593
55647
  #compactionState = "idle";
@@ -55924,6 +55978,25 @@ var ClaudeNativeTurnAccumulator = class {
55924
55978
  const messageId = this.#activeRootStreamMessageId ?? nativeMessageId ?? checkpointId ?? this.#nextMessageId();
55925
55979
  const state = this.#messageState(messageId);
55926
55980
  if (state.completed) {
55981
+ const splitText = checkpointId && !this.#publishedCheckpointIds.has(checkpointId) ? assistantText(message) : null;
55982
+ if (checkpointId && splitText) {
55983
+ this.#publishedCheckpointIds.add(checkpointId);
55984
+ state.text += splitText;
55985
+ events.push({ type: "text.delta", messageId, delta: splitText });
55986
+ this.#consumeToolUseBlocks(message, events, true);
55987
+ if (!this.#protocolConflict && !this.#textConflict) {
55988
+ const usage2 = state.usagePublished ? void 0 : assistantRequestUsage(message, this.#provider);
55989
+ if (usage2)
55990
+ state.usagePublished = true;
55991
+ events.push({
55992
+ type: "message.completed",
55993
+ messageId,
55994
+ checkpointId,
55995
+ ...usage2 ? { lastRequestUsage: usage2 } : {}
55996
+ });
55997
+ }
55998
+ return;
55999
+ }
55927
56000
  this.#consumeToolUseBlocks(message, events, true);
55928
56001
  const usage = assistantRequestUsage(message, this.#provider);
55929
56002
  if (usage && !state.usagePublished) {
@@ -55964,6 +56037,8 @@ var ClaudeNativeTurnAccumulator = class {
55964
56037
  });
55965
56038
  }
55966
56039
  state.completed = true;
56040
+ if (checkpointId)
56041
+ this.#publishedCheckpointIds.add(checkpointId);
55967
56042
  if (this.#activeRootStreamMessageId === messageId)
55968
56043
  this.#activeRootStreamMessageId = null;
55969
56044
  }
@@ -56104,7 +56179,12 @@ var ClaudeNativeTurnAccumulator = class {
56104
56179
  const existing = this.#messages.get(messageId);
56105
56180
  if (existing)
56106
56181
  return existing;
56107
- const created = { completed: false, reasoning: "", text: "", usagePublished: false };
56182
+ const created = {
56183
+ completed: false,
56184
+ reasoning: "",
56185
+ text: "",
56186
+ usagePublished: false
56187
+ };
56108
56188
  this.#messages.set(messageId, created);
56109
56189
  return created;
56110
56190
  }
@@ -56136,6 +56216,25 @@ function readClaudeQueuedCommand(value, sessionId) {
56136
56216
 
56137
56217
  // dist/claude-history.js
56138
56218
  var claudeCodeHarnessId = harnessIdSchema.parse("claude-code");
56219
+ var CLAUDE_BLOCK_SPLIT_UUID_PATTERN = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-0{8}[0-9a-f]{4}$/iu;
56220
+ function matchesClaudeCheckpointId(persistedId, expectedId) {
56221
+ if (persistedId === expectedId)
56222
+ return true;
56223
+ if (!CLAUDE_BLOCK_SPLIT_UUID_PATTERN.test(expectedId))
56224
+ return false;
56225
+ return persistedId.length === 36 && persistedId.slice(0, 24).toLowerCase() === expectedId.slice(0, 24).toLowerCase();
56226
+ }
56227
+ function isPersistedClaudeMessageId(expectedId, persistedIds) {
56228
+ if (persistedIds.has(expectedId))
56229
+ return true;
56230
+ if (!CLAUDE_BLOCK_SPLIT_UUID_PATTERN.test(expectedId))
56231
+ return false;
56232
+ for (const id2 of persistedIds) {
56233
+ if (matchesClaudeCheckpointId(id2, expectedId))
56234
+ return true;
56235
+ }
56236
+ return false;
56237
+ }
56139
56238
  function isRecord9(value) {
56140
56239
  return typeof value === "object" && value !== null && !Array.isArray(value);
56141
56240
  }
@@ -56209,6 +56308,12 @@ function visibleUserTextParts(message) {
56209
56308
  return [];
56210
56309
  return parts.filter((part) => !isLocalCommandRecord(part) && !isTaskNotificationRecord(part));
56211
56310
  }
56311
+ function hasRootToolResult(message) {
56312
+ if (message.type !== "user" || message.nested || !Array.isArray(message.message.content)) {
56313
+ return false;
56314
+ }
56315
+ return message.message.content.some((block) => isRecord9(block) && block.type === "tool_result");
56316
+ }
56212
56317
  function isInterruptionRecord(value, promptId) {
56213
56318
  if (value.type !== "user" || promptId === null || value.promptId !== promptId || value.promptSource !== void 0 || !isRecord9(value.message))
56214
56319
  return false;
@@ -56268,7 +56373,7 @@ function conversationMessages(values, sessionId) {
56268
56373
  interrupted,
56269
56374
  startsTurn: false,
56270
56375
  ...isRecord9(value.forkedFrom) && typeof value.forkedFrom.messageUuid === "string" ? { forkSourceUuid: value.forkedFrom.messageUuid } : {},
56271
- syntheticUser: value.type === "user" && (interrupted || value.isSynthetic === true || value.isMeta === true || isTaskNotificationOrigin(value) || value.toolUseResult !== void 0 && value.toolUseResult !== null)
56376
+ syntheticUser: value.type === "user" && (interrupted || value.isSynthetic === true || value.isMeta === true || value.isCompactSummary === true || value.isVisibleInTranscriptOnly === true || isTaskNotificationOrigin(value) || value.toolUseResult !== void 0 && value.toolUseResult !== null)
56272
56377
  };
56273
56378
  const notification = message.type === "user" && !message.nested && (isTaskNotificationOrigin(value) || textParts(message.message.content).some(isTaskNotificationRecord));
56274
56379
  message.startsTurn = isHumanUser(message) || notification && !occupancy.unsettled && !pendingNotification;
@@ -56374,9 +56479,16 @@ function itemOutcome(outcome) {
56374
56479
  }
56375
56480
  return { status: "succeeded" };
56376
56481
  }
56482
+ function isCheckpointCandidate(message) {
56483
+ return !message.nested && (message.type === "assistant" || message.interrupted || hasRootToolResult(message));
56484
+ }
56377
56485
  function mapClaudeSnapshot(values, sessionId) {
56486
+ return mapClaudeSnapshotWithCheckpointIds(values, sessionId).snapshot;
56487
+ }
56488
+ function mapClaudeSnapshotWithCheckpointIds(values, sessionId) {
56378
56489
  const messages = conversationMessages(values, sessionId);
56379
56490
  const turns = [];
56491
+ const turnCheckpointIds = [];
56380
56492
  for (let index = 0; index < messages.length; ) {
56381
56493
  const user = messages[index];
56382
56494
  if (!user || !user.startsTurn) {
@@ -56391,12 +56503,13 @@ function mapClaudeSnapshot(values, sessionId) {
56391
56503
  const turnMessages = messages.slice(index, end);
56392
56504
  const outcome = turnOutcome(turnMessages);
56393
56505
  const results = toolResultBlocks(turnMessages);
56394
- const checkpointIndex = turnMessages.findLastIndex(({ type, interrupted, nested }) => !nested && (type === "assistant" || interrupted));
56506
+ const checkpointIndex = turnMessages.findLastIndex(isCheckpointCandidate);
56395
56507
  const lastSteering = turnMessages.findLastIndex(({ type }) => type === "steering");
56396
56508
  const checkpointMessage = checkpointIndex > lastSteering ? turnMessages[checkpointIndex] : void 0;
56397
56509
  let agentMessageOrdinal = 0;
56398
56510
  let reasoningOrdinal = 0;
56399
56511
  let toolOrdinal = 0;
56512
+ turnCheckpointIds.push(turnMessages.filter(isCheckpointCandidate).map((message) => message.uuid));
56400
56513
  turns.push({
56401
56514
  nativeTurnRef: nativeTurnRefSchema.parse({
56402
56515
  harnessId: claudeCodeHarnessId,
@@ -56540,7 +56653,7 @@ function mapClaudeSnapshot(values, sessionId) {
56540
56653
  });
56541
56654
  index = end;
56542
56655
  }
56543
- return { turns };
56656
+ return { snapshot: { turns }, turnCheckpointIds };
56544
56657
  }
56545
56658
  function toolResultBlocks(messages) {
56546
56659
  const results = /* @__PURE__ */ new Map();
@@ -56739,6 +56852,10 @@ function nativeIds(snapshot) {
56739
56852
  ]));
56740
56853
  }
56741
56854
  async function readSnapshot(dependencies, cwd, sessionId) {
56855
+ const history = await readHistory(dependencies, cwd, sessionId);
56856
+ return history.ok ? { ok: true, value: history.value.snapshot } : history;
56857
+ }
56858
+ async function readHistory(dependencies, cwd, sessionId) {
56742
56859
  let messages;
56743
56860
  try {
56744
56861
  messages = await dependencies.readSessionMessages({ cwd, sessionId }) ?? [];
@@ -56755,7 +56872,7 @@ async function readSnapshot(dependencies, cwd, sessionId) {
56755
56872
  };
56756
56873
  }
56757
56874
  try {
56758
- return { ok: true, value: mapClaudeSnapshot(messages, sessionId) };
56875
+ return { ok: true, value: mapClaudeSnapshotWithCheckpointIds(messages, sessionId) };
56759
56876
  } catch {
56760
56877
  return {
56761
56878
  ok: false,
@@ -56795,9 +56912,10 @@ async function forkClaudeSession(input) {
56795
56912
  error: error51("protocolError", "Claude Code Session working directory is unavailable", false)
56796
56913
  };
56797
56914
  }
56798
- const source = await readSnapshot(input.dependencies, input.cwd, sourceRef.data.nativeSessionId);
56799
- if (!source.ok)
56800
- return source;
56915
+ const sourceHistory = await readHistory(input.dependencies, input.cwd, sourceRef.data.nativeSessionId);
56916
+ if (!sourceHistory.ok)
56917
+ return sourceHistory;
56918
+ const source = { ok: true, value: sourceHistory.value.snapshot };
56801
56919
  if (input.kind === "rollbackLastTurn" && source.value.turns.length === 0) {
56802
56920
  return {
56803
56921
  ok: false,
@@ -56827,7 +56945,12 @@ async function forkClaudeSession(input) {
56827
56945
  value: { sessionId: nativeRef.nativeSessionId, nativeRef, openMode: "create" }
56828
56946
  };
56829
56947
  }
56830
- const boundaryIndex = input.kind === "rollbackLastTurn" ? source.value.turns.length - 2 : source.value.turns.findIndex((turn) => checkpoint?.success && turn.checkpoint?.checkpointId === checkpoint.data.checkpointId);
56948
+ const boundaryIndex = input.kind === "rollbackLastTurn" ? source.value.turns.length - 2 : (
56949
+ // A live checkpoint names the last root Assistant record seen while the Turn ran;
56950
+ // the persisted Turn checkpoint can be a later root tool_result of the same Turn.
56951
+ // Fork at that Turn's final checkpoint so the native prefix keeps the whole Turn.
56952
+ sourceHistory.value.turnCheckpointIds.findIndex((ids, index) => checkpoint?.success && source.value.turns[index]?.checkpoint !== void 0 && ids.some((id2) => matchesClaudeCheckpointId(id2, checkpoint.data.checkpointId)))
56953
+ );
56831
56954
  const retained = source.value.turns[boundaryIndex];
56832
56955
  const boundaryId = retained?.checkpoint?.checkpointId ?? (input.kind === "rollbackLastTurn" ? retained?.nativeTurnRef.nativeTurnKey : void 0);
56833
56956
  if (boundaryIndex < 0 || !boundaryId) {
@@ -56890,12 +57013,13 @@ async function forkClaudeSession(input) {
56890
57013
 
56891
57014
  // dist/claude-fork-references.js
56892
57015
  import { randomUUID as randomUUID4 } from "node:crypto";
56893
- import { readFile as readFile6, rename as rename4, rm as rm5, stat as stat5, writeFile as writeFile2 } from "node:fs/promises";
57016
+ import { readFile as readFile5, rename as rename4, rm as rm5, stat as stat5, writeFile as writeFile2 } from "node:fs/promises";
56894
57017
 
56895
57018
  // dist/claude-transcript.js
57019
+ import { createReadStream as createReadStream4 } from "node:fs";
56896
57020
  import os6 from "node:os";
56897
57021
  import path12 from "node:path";
56898
- import { readFile as readFile5, readdir as readdir3, stat as stat4 } from "node:fs/promises";
57022
+ import { readdir as readdir3, stat as stat4 } from "node:fs/promises";
56899
57023
  function projectDirectoryName(cwd) {
56900
57024
  return cwd.replace(/[^A-Za-z0-9]/gu, "-");
56901
57025
  }
@@ -56928,6 +57052,28 @@ async function findClaudeTranscript(input) {
56928
57052
  }
56929
57053
  return null;
56930
57054
  }
57055
+ async function* transcriptLines(transcript) {
57056
+ const stream = createReadStream4(transcript, { encoding: "utf8" });
57057
+ let pending = "";
57058
+ try {
57059
+ for await (const chunk of stream) {
57060
+ const contents = chunk;
57061
+ let start = 0;
57062
+ let newline;
57063
+ while ((newline = contents.indexOf("\n", start)) !== -1) {
57064
+ const line = pending + contents.slice(start, newline);
57065
+ pending = "";
57066
+ yield line;
57067
+ start = newline + 1;
57068
+ }
57069
+ pending += contents.slice(start);
57070
+ }
57071
+ if (pending.length > 0)
57072
+ yield pending;
57073
+ } finally {
57074
+ stream.destroy();
57075
+ }
57076
+ }
56931
57077
  function isRecord10(value) {
56932
57078
  return typeof value === "object" && value !== null && !Array.isArray(value);
56933
57079
  }
@@ -56935,9 +57081,8 @@ async function readClaudeTranscript(input) {
56935
57081
  const transcript = await findClaudeTranscript(input);
56936
57082
  if (!transcript)
56937
57083
  return null;
56938
- const contents = await readFile5(transcript, "utf8");
56939
57084
  const messages = /* @__PURE__ */ new Map();
56940
- for (const line of contents.split("\n")) {
57085
+ for await (const line of transcriptLines(transcript)) {
56941
57086
  if (line.trim().length === 0)
56942
57087
  continue;
56943
57088
  let entry;
@@ -56990,7 +57135,7 @@ async function remapForkedSessionReferences(input) {
56990
57135
  const transcript = await findClaudeTranscript(input);
56991
57136
  if (!transcript)
56992
57137
  return 0;
56993
- const contents = await readFile6(transcript, "utf8");
57138
+ const contents = await readFile5(transcript, "utf8");
56994
57139
  if (!contents.includes('"sameAs"'))
56995
57140
  return 0;
56996
57141
  const lines = contents.split("\n");
@@ -57030,7 +57175,7 @@ async function remapForkedSessionReferences(input) {
57030
57175
 
57031
57176
  // dist/model-catalog.js
57032
57177
  import { Buffer as Buffer2 } from "node:buffer";
57033
- import { readFile as readFile7 } from "node:fs/promises";
57178
+ import { readFile as readFile6 } from "node:fs/promises";
57034
57179
  import os7 from "node:os";
57035
57180
  import path13 from "node:path";
57036
57181
 
@@ -57083,7 +57228,7 @@ var CLAUDE_MODEL_VALUE_MAX_LENGTH = 512;
57083
57228
  var modelInfoSchema = external_exports.object({
57084
57229
  value: external_exports.string().trim().min(1).max(CLAUDE_MODEL_VALUE_MAX_LENGTH),
57085
57230
  displayName: external_exports.string().trim().min(1).max(HARNESS_MODEL_LABEL_MAX_LENGTH),
57086
- description: external_exports.string().trim().min(1).max(HARNESS_MODEL_LABEL_MAX_LENGTH).optional(),
57231
+ description: external_exports.string().trim().max(HARNESS_MODEL_LABEL_MAX_LENGTH).optional(),
57087
57232
  resolvedModel: harnessResolvedModelLabelSchema.optional()
57088
57233
  });
57089
57234
  var modelPickerOptionSchema = external_exports.object({
@@ -57170,7 +57315,7 @@ async function readClaudeUserModelPicker(environment = process.env) {
57170
57315
  const settingsPath = path13.join(resolveClaudeConfigDirectory(environment), "settings.json");
57171
57316
  let raw;
57172
57317
  try {
57173
- raw = await readFile7(settingsPath, "utf8");
57318
+ raw = await readFile6(settingsPath, "utf8");
57174
57319
  } catch {
57175
57320
  return void 0;
57176
57321
  }
@@ -59647,6 +59792,7 @@ var DEFAULT_CONTINUATION_QUIESCENCE_MS = 2e3;
59647
59792
  function isRecord15(value) {
59648
59793
  return typeof value === "object" && value !== null && !Array.isArray(value);
59649
59794
  }
59795
+ var SYNTHETIC_AUTONOMOUS_TURN_KEY_PATTERN = /^autonomous-\d+$/u;
59650
59796
  function safeNonNegativeInteger2(value) {
59651
59797
  return typeof value === "number" && Number.isSafeInteger(value) && value >= 0;
59652
59798
  }
@@ -59983,7 +60129,7 @@ var ClaudeHarnessSession = class {
59983
60129
  sessionId: this.#sessionId
59984
60130
  }) ?? [];
59985
60131
  const ids = new Set(messages.flatMap((message) => isRecord15(message) && typeof message.uuid === "string" ? [message.uuid] : []));
59986
- if (this.#unpersistedMessageIds.every((id2) => ids.has(id2))) {
60132
+ if (this.#unpersistedMessageIds.every((id2) => isPersistedClaudeMessageId(id2, ids))) {
59987
60133
  this.#unpersistedMessageIds = [];
59988
60134
  break;
59989
60135
  }
@@ -61864,11 +62010,12 @@ var ClaudeHarnessSession = class {
61864
62010
  checkpointId: active.checkpointId,
61865
62011
  formatVersion: 1
61866
62012
  }) : null;
61867
- if (active.userMessageId || active.checkpointId) {
62013
+ const trackUserMessageId = active.userMessageId !== null && !SYNTHETIC_AUTONOMOUS_TURN_KEY_PATTERN.test(active.userMessageId) && (outcome.status !== "cancelled" || active.checkpointId !== null);
62014
+ if (trackUserMessageId || active.checkpointId) {
61868
62015
  this.#unpersistedMessageIds = [
61869
62016
  .../* @__PURE__ */ new Set([
61870
62017
  ...this.#unpersistedMessageIds,
61871
- ...active.userMessageId ? [active.userMessageId] : [],
62018
+ ...trackUserMessageId && active.userMessageId ? [active.userMessageId] : [],
61872
62019
  ...active.checkpointId ? [active.checkpointId] : []
61873
62020
  ])
61874
62021
  ];
@@ -62463,11 +62610,11 @@ var ClaudeCodeAdapter = class {
62463
62610
  };
62464
62611
 
62465
62612
  // dist/installation.js
62466
- import { readFile as readFile8, realpath as realpath5 } from "node:fs/promises";
62613
+ import { readFile as readFile7, realpath as realpath5 } from "node:fs/promises";
62467
62614
  import { homedir as homedir2 } from "node:os";
62468
62615
  import path16 from "node:path";
62469
62616
  async function readSettings(file2) {
62470
- const text2 = await readFile8(file2, "utf8").catch((error52) => {
62617
+ const text2 = await readFile7(file2, "utf8").catch((error52) => {
62471
62618
  if (error52.code === "ENOENT")
62472
62619
  return "{}";
62473
62620
  throw error52;