@codexhost/cli-linux-arm64 0.15.0 → 0.16.1

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.
@@ -15089,6 +15089,8 @@ var usageStatisticsTotalsSchema = external_exports.strictObject({
15089
15089
  cachedInputTokens: count,
15090
15090
  cacheWriteInputTokens: count,
15091
15091
  cacheKnownInputTokens: count,
15092
+ cacheHitCachedInputTokens: count,
15093
+ cacheHitInputTokens: count,
15092
15094
  outputTokens: count,
15093
15095
  reasoningOutputTokens: count,
15094
15096
  /** USD at the public price, summed over the priced requests only. */
@@ -15975,7 +15977,10 @@ var harnessPluginRouteSchema = external_exports.object({
15975
15977
  harnessId: harnessPluginIdSchema,
15976
15978
  model: harnessModelRefSchema.optional(),
15977
15979
  thinkingOptionId: harnessThinkingOptionIdSchema.optional(),
15978
- permissionModeId: harnessPermissionModeIdSchema.optional()
15980
+ permissionModeId: harnessPermissionModeIdSchema.optional(),
15981
+ /** A draft prewarm create: stays unsubmitted until the user's first Turn.
15982
+ * Desktop forwards only the Model of a main-process prewarm to thread/start. */
15983
+ prewarm: external_exports.literal(true).optional()
15979
15984
  }).strict();
15980
15985
 
15981
15986
  // ../../shared-contracts/dist/harness-launch-settings.js
@@ -14683,6 +14683,8 @@ var usageStatisticsTotalsSchema = external_exports.strictObject({
14683
14683
  cachedInputTokens: count,
14684
14684
  cacheWriteInputTokens: count,
14685
14685
  cacheKnownInputTokens: count,
14686
+ cacheHitCachedInputTokens: count,
14687
+ cacheHitInputTokens: count,
14686
14688
  outputTokens: count,
14687
14689
  reasoningOutputTokens: count,
14688
14690
  /** USD at the public price, summed over the priced requests only. */
@@ -15569,7 +15571,10 @@ var harnessPluginRouteSchema = external_exports.object({
15569
15571
  harnessId: harnessPluginIdSchema,
15570
15572
  model: harnessModelRefSchema.optional(),
15571
15573
  thinkingOptionId: harnessThinkingOptionIdSchema.optional(),
15572
- permissionModeId: harnessPermissionModeIdSchema.optional()
15574
+ permissionModeId: harnessPermissionModeIdSchema.optional(),
15575
+ /** A draft prewarm create: stays unsubmitted until the user's first Turn.
15576
+ * Desktop forwards only the Model of a main-process prewarm to thread/start. */
15577
+ prewarm: external_exports.literal(true).optional()
15573
15578
  }).strict();
15574
15579
 
15575
15580
  // ../../shared-contracts/dist/harness-launch-settings.js
@@ -57290,11 +57295,11 @@ var ClaudeSdkTransport = class {
57290
57295
  this.#slashCommands = parseClaudeSlashCommands(message.commands);
57291
57296
  }
57292
57297
  }
57293
- async getContextUsage() {
57298
+ async getContextUsage(detail = "full") {
57294
57299
  const activeQuery = this.#query;
57295
57300
  if (!this.#started || !activeQuery)
57296
57301
  return null;
57297
- return parseContextUsage(await activeQuery.getContextUsage());
57302
+ return parseContextUsage(await activeQuery.getContextUsage({ detail }));
57298
57303
  }
57299
57304
  getPermissionMode() {
57300
57305
  if (!this.#started || !this.#query)
@@ -59153,7 +59158,6 @@ var ClaudeHarnessSession = class {
59153
59158
  #lastAssistantResponseAtUnix;
59154
59159
  #accountCreditsSupported;
59155
59160
  #minimumContextUsedTokens = null;
59156
- #latestRequestModel = null;
59157
59161
  #calibratedInputTokens = 0;
59158
59162
  #calibratedOutputTokens = 0;
59159
59163
  #calibratedCostUsd = 0;
@@ -59660,15 +59664,16 @@ var ClaudeHarnessSession = class {
59660
59664
  };
59661
59665
  }
59662
59666
  }
59663
- refreshUsage() {
59667
+ async refreshUsage() {
59668
+ await this.#contextRefreshInFlight;
59664
59669
  if (this.#phase !== "open" || !this.#transport)
59665
- return Promise.resolve();
59670
+ return;
59666
59671
  const now = Date.now();
59667
59672
  if (now < this.#contextUsageFreshUntilMs || now < this.#contextUsageCooldownUntilMs) {
59668
- return Promise.resolve();
59673
+ return;
59669
59674
  }
59670
59675
  this.#requestContextUsage(this.#transport, this.#active?.command.turnId, CONTEXT_USAGE_RETRY_DELAYS_MS);
59671
- return this.#contextRefreshInFlight ?? Promise.resolve();
59676
+ await this.#contextRefreshInFlight;
59672
59677
  }
59673
59678
  blocksRollback(sessionId) {
59674
59679
  return this.#sessionId === sessionId && (this.#phase !== "open" || this.#active !== null || this.#acceptingTurn || this.#configurationTask !== null || this.#readingHistory);
@@ -60802,7 +60807,7 @@ var ClaudeHarnessSession = class {
60802
60807
  this.#finishFailed(active, transportFailure(result.kind));
60803
60808
  }
60804
60809
  }
60805
- #requestContextUsage(transport, turnId, retryDelaysMs) {
60810
+ #requestContextUsage(transport, turnId, retryDelaysMs, detail = "full") {
60806
60811
  if (this.#phase !== "open" || this.#transport !== transport)
60807
60812
  return;
60808
60813
  if (this.#contextRefreshInFlight)
@@ -60811,7 +60816,8 @@ var ClaudeHarnessSession = class {
60811
60816
  transport,
60812
60817
  ...turnId !== void 0 ? { turnId } : {},
60813
60818
  generation: this.#usageGeneration,
60814
- retryDelaysMs
60819
+ retryDelaysMs,
60820
+ detail
60815
60821
  };
60816
60822
  this.#contextRefreshInFlight = this.#drainContextUsage();
60817
60823
  }
@@ -60837,14 +60843,16 @@ var ClaudeHarnessSession = class {
60837
60843
  return;
60838
60844
  }
60839
60845
  try {
60840
- const context = await request.transport.getContextUsage();
60846
+ const context = await request.transport.getContextUsage(request.detail);
60841
60847
  if (this.#phase !== "open" || this.#transport !== request.transport || this.#usageGeneration !== request.generation || this.#contextRefreshPending !== null) {
60842
60848
  return;
60843
60849
  }
60844
60850
  if (context === null)
60845
60851
  continue;
60846
- this.#contextUsageFreshUntilMs = Date.now() + CONTEXT_USAGE_TTL_MS;
60847
- this.#contextUsageCooldownUntilMs = 0;
60852
+ if (request.detail === "full") {
60853
+ this.#contextUsageFreshUntilMs = Date.now() + CONTEXT_USAGE_TTL_MS;
60854
+ this.#contextUsageCooldownUntilMs = 0;
60855
+ }
60848
60856
  this.#mergeAndPublishUsage({
60849
60857
  contextUsedTokens: Math.max(context.usedTokens, this.#minimumContextUsedTokens ?? 0),
60850
60858
  contextWindowTokens: context.maxTokens
@@ -60853,7 +60861,7 @@ var ClaudeHarnessSession = class {
60853
60861
  } catch {
60854
60862
  }
60855
60863
  }
60856
- if (this.#phase === "open" && this.#transport === request.transport && this.#usageGeneration === request.generation) {
60864
+ if (request.detail === "full" && this.#phase === "open" && this.#transport === request.transport && this.#usageGeneration === request.generation) {
60857
60865
  this.#contextUsageCooldownUntilMs = Date.now() + CONTEXT_USAGE_FAILURE_COOLDOWN_MS;
60858
60866
  }
60859
60867
  }
@@ -60919,8 +60927,6 @@ var ClaudeHarnessSession = class {
60919
60927
  const promptTokens = usage.inputTokens + usage.cacheCreationInputTokens + usage.cacheReadInputTokens;
60920
60928
  if (promptTokens > 0)
60921
60929
  this.#minimumContextUsedTokens = promptTokens;
60922
- if (usage.model)
60923
- this.#latestRequestModel = usage.model;
60924
60930
  const cacheHitRatePercent = claudeCacheHitRatePercent(usage);
60925
60931
  const contextWindowTokens = this.#latestUsage?.contextWindowTokens;
60926
60932
  this.#mergeAndPublishUsage({
@@ -60962,24 +60968,11 @@ var ClaudeHarnessSession = class {
60962
60968
  if (cacheHitRatePercent !== void 0)
60963
60969
  delta.cacheHitRatePercent = cacheHitRatePercent;
60964
60970
  }
60965
- if (this.#latestUsage?.contextWindowTokens === void 0 && this.#minimumContextUsedTokens !== null) {
60966
- const contextWindowTokens = this.#resultContextWindow(event.modelUsage);
60967
- if (contextWindowTokens !== void 0) {
60968
- delta.contextUsedTokens = this.#minimumContextUsedTokens;
60969
- delta.contextWindowTokens = contextWindowTokens;
60970
- }
60971
+ if (this.#transport && this.#minimumContextUsedTokens !== null && event.modelUsage?.some(({ contextWindowTokens }) => contextWindowTokens !== void 0)) {
60972
+ this.#requestContextUsage(this.#transport, active.command.turnId, [0], "summary");
60971
60973
  }
60972
60974
  this.#mergeAndPublishUsage(delta, active.command.turnId);
60973
60975
  }
60974
- /** The latest request's Model, else the Model that carried the most prompt tokens. */
60975
- #resultContextWindow(modelUsage) {
60976
- if (!modelUsage?.length)
60977
- return void 0;
60978
- const latest = this.#latestRequestModel;
60979
- const matched = latest ? modelUsage.find(({ model: model2 }) => model2 === latest) : void 0;
60980
- const main = matched ?? modelUsage.reduce((best, entry) => (entry.promptTokens ?? entry.inputTokens) > (best.promptTokens ?? best.inputTokens) ? entry : best);
60981
- return main.contextWindowTokens;
60982
- }
60983
60976
  /**
60984
60977
  * Plan usage is account-wide, not Thread-scoped, so every observation is
60985
60978
  * offered to the Adapter's shared cache regardless of this Session's own
@@ -15159,6 +15159,8 @@ var usageStatisticsTotalsSchema = external_exports.strictObject({
15159
15159
  cachedInputTokens: count,
15160
15160
  cacheWriteInputTokens: count,
15161
15161
  cacheKnownInputTokens: count,
15162
+ cacheHitCachedInputTokens: count,
15163
+ cacheHitInputTokens: count,
15162
15164
  outputTokens: count,
15163
15165
  reasoningOutputTokens: count,
15164
15166
  /** USD at the public price, summed over the priced requests only. */
@@ -16045,7 +16047,10 @@ var harnessPluginRouteSchema = external_exports.object({
16045
16047
  harnessId: harnessPluginIdSchema,
16046
16048
  model: harnessModelRefSchema.optional(),
16047
16049
  thinkingOptionId: harnessThinkingOptionIdSchema.optional(),
16048
- permissionModeId: harnessPermissionModeIdSchema.optional()
16050
+ permissionModeId: harnessPermissionModeIdSchema.optional(),
16051
+ /** A draft prewarm create: stays unsubmitted until the user's first Turn.
16052
+ * Desktop forwards only the Model of a main-process prewarm to thread/start. */
16053
+ prewarm: external_exports.literal(true).optional()
16049
16054
  }).strict();
16050
16055
 
16051
16056
  // ../../shared-contracts/dist/harness-launch-settings.js
@@ -18240,7 +18245,17 @@ function pendingNativeHistoryRewind(contents) {
18240
18245
  const last = parseRows(contents).findLast((row) => row.type === "resend-fork-notice" || NATIVE_MESSAGE_TYPES.has(text(row.type)));
18241
18246
  return last?.type === "resend-fork-notice" ? { forkPointId: text(last.parentId) || null } : void 0;
18242
18247
  }
18248
+ function isNativeCompactionSummary(row) {
18249
+ const data = record2(row.providerData);
18250
+ return row.type === "message" && row.role === "user" && data.isCompactInternal === true;
18251
+ }
18243
18252
  function nativeHistoryRows(contents) {
18253
+ return collectNativeHistoryRows(contents, false);
18254
+ }
18255
+ function nativeDisplayHistoryRows(contents) {
18256
+ return collectNativeHistoryRows(contents, true);
18257
+ }
18258
+ function collectNativeHistoryRows(contents, followCompactionParent) {
18244
18259
  const entries = /* @__PURE__ */ new Map();
18245
18260
  let leaf = "";
18246
18261
  for (const row of parseRows(contents)) {
@@ -18265,10 +18280,16 @@ function nativeHistoryRows(contents) {
18265
18280
  throw new CodeBuddyError("protocolError", "Native history parent is missing");
18266
18281
  chain.push(row);
18267
18282
  leaf = text(row.parentId);
18283
+ if (!leaf && followCompactionParent && isNativeCompactionSummary(row)) {
18284
+ const logicalParent = text(row.logicalParentId);
18285
+ if (logicalParent && !entries.has(logicalParent))
18286
+ throw new CodeBuddyError("protocolError", "Native compaction parent is missing");
18287
+ leaf = logicalParent;
18288
+ }
18268
18289
  }
18269
18290
  return chain.reverse();
18270
18291
  }
18271
- function snapshotFromHistory(contents, ref, cwd, profile = CODEBUDDY_RUNTIME_PROFILE) {
18292
+ function snapshotFromHistory(contents, ref, cwd, profile = CODEBUDDY_RUNTIME_PROFILE, options = {}) {
18272
18293
  const supportsNativeCommands = nativeCommandsEnabled(profile);
18273
18294
  const supportsFork = capabilitiesForProfile(profile).history.fork;
18274
18295
  const turns = [];
@@ -18294,7 +18315,8 @@ function snapshotFromHistory(contents, ref, cwd, profile = CODEBUDDY_RUNTIME_PRO
18294
18315
  snapshot.item.outputTruncated = Boolean(output.truncated);
18295
18316
  }
18296
18317
  };
18297
- const history = nativeHistoryRows(contents);
18318
+ const includeCompactionHistory = options.includeCompactionHistory !== false;
18319
+ const history = includeCompactionHistory ? nativeDisplayHistoryRows(contents) : nativeHistoryRows(contents);
18298
18320
  const manualCompactions = /* @__PURE__ */ new Set();
18299
18321
  let compactUser;
18300
18322
  if (supportsNativeCommands)
@@ -18328,6 +18350,22 @@ function snapshotFromHistory(contents, ref, cwd, profile = CODEBUDDY_RUNTIME_PRO
18328
18350
  continue;
18329
18351
  if (supportsNativeCommands && row.type === "message" && row.role === "user" && data.agent === "compact" && !manualCompactions.has(text(row.id)))
18330
18352
  continue;
18353
+ if (includeCompactionHistory && isNativeCompactionSummary(row)) {
18354
+ if (supportsNativeCommands && current) {
18355
+ const outcome = data.isCompacted === true ? { status: "succeeded" } : {
18356
+ status: "failed",
18357
+ error: nativeError(new CodeBuddyError("nativeFailure", "Native compaction did not complete"), profile)
18358
+ };
18359
+ current.items.push({
18360
+ item: {
18361
+ type: "contextCompaction",
18362
+ itemId: hostItemIdSchema.parse(`compact-${text(row.id)}`)
18363
+ },
18364
+ outcome
18365
+ });
18366
+ }
18367
+ continue;
18368
+ }
18331
18369
  if (row.type === "message" && row.role === "user") {
18332
18370
  current = {
18333
18371
  nativeTurnRef: nativeTurnRefSchema.parse({
@@ -23309,7 +23347,9 @@ function commandCaveat(row) {
23309
23347
  }
23310
23348
  function retainedRowCount(input, contents, sourceCwd = input.cwd, profile = CODEBUDDY_RUNTIME_PROFILE) {
23311
23349
  const rows2 = nativeHistoryRows(contents);
23312
- const turns = snapshotFromHistory(contents, input.sourceRef, sourceCwd, profile).turns;
23350
+ const turns = snapshotFromHistory(contents, input.sourceRef, sourceCwd, profile, {
23351
+ includeCompactionHistory: false
23352
+ }).turns;
23313
23353
  let excluded2;
23314
23354
  if (input.kind === "rollbackLastTurn") {
23315
23355
  if (!turns.length)
@@ -14677,6 +14677,8 @@ var usageStatisticsTotalsSchema = external_exports.strictObject({
14677
14677
  cachedInputTokens: count,
14678
14678
  cacheWriteInputTokens: count,
14679
14679
  cacheKnownInputTokens: count,
14680
+ cacheHitCachedInputTokens: count,
14681
+ cacheHitInputTokens: count,
14680
14682
  outputTokens: count,
14681
14683
  reasoningOutputTokens: count,
14682
14684
  /** USD at the public price, summed over the priced requests only. */
@@ -15563,7 +15565,10 @@ var harnessPluginRouteSchema = external_exports.object({
15563
15565
  harnessId: harnessPluginIdSchema,
15564
15566
  model: harnessModelRefSchema.optional(),
15565
15567
  thinkingOptionId: harnessThinkingOptionIdSchema.optional(),
15566
- permissionModeId: harnessPermissionModeIdSchema.optional()
15568
+ permissionModeId: harnessPermissionModeIdSchema.optional(),
15569
+ /** A draft prewarm create: stays unsubmitted until the user's first Turn.
15570
+ * Desktop forwards only the Model of a main-process prewarm to thread/start. */
15571
+ prewarm: external_exports.literal(true).optional()
15567
15572
  }).strict();
15568
15573
 
15569
15574
  // ../../shared-contracts/dist/harness-launch-settings.js
@@ -18734,6 +18734,8 @@ var usageStatisticsTotalsSchema = external_exports.strictObject({
18734
18734
  cachedInputTokens: count,
18735
18735
  cacheWriteInputTokens: count,
18736
18736
  cacheKnownInputTokens: count,
18737
+ cacheHitCachedInputTokens: count,
18738
+ cacheHitInputTokens: count,
18737
18739
  outputTokens: count,
18738
18740
  reasoningOutputTokens: count,
18739
18741
  /** USD at the public price, summed over the priced requests only. */
@@ -19620,7 +19622,10 @@ var harnessPluginRouteSchema = external_exports.object({
19620
19622
  harnessId: harnessPluginIdSchema,
19621
19623
  model: harnessModelRefSchema.optional(),
19622
19624
  thinkingOptionId: harnessThinkingOptionIdSchema.optional(),
19623
- permissionModeId: harnessPermissionModeIdSchema.optional()
19625
+ permissionModeId: harnessPermissionModeIdSchema.optional(),
19626
+ /** A draft prewarm create: stays unsubmitted until the user's first Turn.
19627
+ * Desktop forwards only the Model of a main-process prewarm to thread/start. */
19628
+ prewarm: external_exports.literal(true).optional()
19624
19629
  }).strict();
19625
19630
 
19626
19631
  // ../../shared-contracts/dist/harness-launch-settings.js
@@ -15044,6 +15044,8 @@ var usageStatisticsTotalsSchema = external_exports.strictObject({
15044
15044
  cachedInputTokens: count,
15045
15045
  cacheWriteInputTokens: count,
15046
15046
  cacheKnownInputTokens: count,
15047
+ cacheHitCachedInputTokens: count,
15048
+ cacheHitInputTokens: count,
15047
15049
  outputTokens: count,
15048
15050
  reasoningOutputTokens: count,
15049
15051
  /** USD at the public price, summed over the priced requests only. */
@@ -15930,7 +15932,10 @@ var harnessPluginRouteSchema = external_exports.object({
15930
15932
  harnessId: harnessPluginIdSchema,
15931
15933
  model: harnessModelRefSchema.optional(),
15932
15934
  thinkingOptionId: harnessThinkingOptionIdSchema.optional(),
15933
- permissionModeId: harnessPermissionModeIdSchema.optional()
15935
+ permissionModeId: harnessPermissionModeIdSchema.optional(),
15936
+ /** A draft prewarm create: stays unsubmitted until the user's first Turn.
15937
+ * Desktop forwards only the Model of a main-process prewarm to thread/start. */
15938
+ prewarm: external_exports.literal(true).optional()
15934
15939
  }).strict();
15935
15940
 
15936
15941
  // ../../shared-contracts/dist/harness-launch-settings.js
@@ -18924,6 +18924,8 @@ var usageStatisticsTotalsSchema = external_exports.strictObject({
18924
18924
  cachedInputTokens: count,
18925
18925
  cacheWriteInputTokens: count,
18926
18926
  cacheKnownInputTokens: count,
18927
+ cacheHitCachedInputTokens: count,
18928
+ cacheHitInputTokens: count,
18927
18929
  outputTokens: count,
18928
18930
  reasoningOutputTokens: count,
18929
18931
  /** USD at the public price, summed over the priced requests only. */
@@ -19810,7 +19812,10 @@ var harnessPluginRouteSchema = external_exports.object({
19810
19812
  harnessId: harnessPluginIdSchema,
19811
19813
  model: harnessModelRefSchema.optional(),
19812
19814
  thinkingOptionId: harnessThinkingOptionIdSchema.optional(),
19813
- permissionModeId: harnessPermissionModeIdSchema.optional()
19815
+ permissionModeId: harnessPermissionModeIdSchema.optional(),
19816
+ /** A draft prewarm create: stays unsubmitted until the user's first Turn.
19817
+ * Desktop forwards only the Model of a main-process prewarm to thread/start. */
19818
+ prewarm: external_exports.literal(true).optional()
19814
19819
  }).strict();
19815
19820
 
19816
19821
  // ../../shared-contracts/dist/harness-launch-settings.js
@@ -26295,15 +26300,24 @@ function attachedKnownInvocation(value, sinks) {
26295
26300
  return { event: value.event, eventId: value.eventId, agentId: value.agentId };
26296
26301
  }
26297
26302
  function parseApprovalRequest(value) {
26298
- if (!hasOnlyKeys(value, ["toolName"], ["callId", "reason"]) || !nonBlankString3(value.toolName) || Object.hasOwn(value, "callId") && !nonBlankString3(value.callId) || Object.hasOwn(value, "reason") && !boundedString3(value.reason)) {
26303
+ if (!hasOnlyKeys(value, ["toolName"], ["callId", "reason", "displayReason"]) || !nonBlankString3(value.toolName) || Object.hasOwn(value, "callId") && !nonBlankString3(value.callId) || Object.hasOwn(value, "reason") && !boundedString3(value.reason) || Object.hasOwn(value, "displayReason") && !isApprovalDisplayReason(value.displayReason)) {
26299
26304
  throw invalidFrame();
26300
26305
  }
26301
26306
  return {
26302
26307
  toolName: value.toolName,
26303
26308
  ...typeof value.callId === "string" ? { callId: value.callId } : {},
26304
- ...typeof value.reason === "string" ? { reason: value.reason } : {}
26309
+ ...typeof value.reason === "string" ? { reason: value.reason } : {},
26310
+ ...Object.hasOwn(value, "displayReason") ? { displayReason: value.displayReason } : {}
26305
26311
  };
26306
26312
  }
26313
+ function isApprovalDisplayReason(value) {
26314
+ if (!isPlainRecord6(value))
26315
+ return false;
26316
+ const entries = Object.entries(value);
26317
+ if (entries.length === 0)
26318
+ return false;
26319
+ return entries.every(([locale, text]) => locale.length > 0 && nonBlankString3(text) && boundedString3(text));
26320
+ }
26307
26321
  function parseQuestionRequest(value) {
26308
26322
  if (!hasOnlyKeys(value, ["questions"], ["wait"]) || !Array.isArray(value.questions)) {
26309
26323
  throw invalidFrame();
@@ -28261,7 +28275,7 @@ function validateInboxSplice(data, profile) {
28261
28275
  }
28262
28276
  }
28263
28277
  function validateApprovalAsked(data) {
28264
- requiredOptionalKeys(data, ["id", "toolName"], ["callId", "reason"]);
28278
+ requiredOptionalKeys(data, ["id", "toolName"], ["callId", "reason", "displayReason"]);
28265
28279
  requiredString(data.id, "approval/asked id");
28266
28280
  requiredString(data.toolName, "approval/asked toolName");
28267
28281
  if (data.callId !== void 0)
@@ -28269,6 +28283,17 @@ function validateApprovalAsked(data) {
28269
28283
  if (data.reason !== void 0 && typeof data.reason !== "string") {
28270
28284
  fail("Modern history approval/asked reason is malformed");
28271
28285
  }
28286
+ if (data.displayReason !== void 0 && !isApprovalDisplayReason2(data.displayReason)) {
28287
+ fail("Modern history approval/asked displayReason is malformed");
28288
+ }
28289
+ }
28290
+ function isApprovalDisplayReason2(value) {
28291
+ if (!isRecord4(value))
28292
+ return false;
28293
+ const entries = Object.entries(value);
28294
+ if (entries.length === 0)
28295
+ return false;
28296
+ return entries.every(([locale, text]) => locale.length > 0 && typeof text === "string" && text.length > 0 && nonBlankString(text));
28272
28297
  }
28273
28298
  function validateApprovalDecided(data) {
28274
28299
  exactKeys(data, ["id", "outcome"]);
@@ -29182,7 +29207,7 @@ var ModernHarnessSession = class {
29182
29207
  type: "approval",
29183
29208
  interactionId,
29184
29209
  turnId: active.turnId,
29185
- title: delivery.request.reason ?? `Allow ${delivery.request.toolName}?`,
29210
+ title: delivery.request.displayReason?.en ?? delivery.request.reason ?? `Allow ${delivery.request.toolName}?`,
29186
29211
  description: delivery.request.callId ? `${delivery.request.toolName} (${delivery.request.callId})` : delivery.request.toolName,
29187
29212
  subject: { type: "nativeAction" },
29188
29213
  actions: [
@@ -15277,6 +15277,8 @@ var usageStatisticsTotalsSchema = external_exports.strictObject({
15277
15277
  cachedInputTokens: count2,
15278
15278
  cacheWriteInputTokens: count2,
15279
15279
  cacheKnownInputTokens: count2,
15280
+ cacheHitCachedInputTokens: count2,
15281
+ cacheHitInputTokens: count2,
15280
15282
  outputTokens: count2,
15281
15283
  reasoningOutputTokens: count2,
15282
15284
  /** USD at the public price, summed over the priced requests only. */
@@ -16163,7 +16165,10 @@ var harnessPluginRouteSchema = external_exports.object({
16163
16165
  harnessId: harnessPluginIdSchema,
16164
16166
  model: harnessModelRefSchema.optional(),
16165
16167
  thinkingOptionId: harnessThinkingOptionIdSchema.optional(),
16166
- permissionModeId: harnessPermissionModeIdSchema.optional()
16168
+ permissionModeId: harnessPermissionModeIdSchema.optional(),
16169
+ /** A draft prewarm create: stays unsubmitted until the user's first Turn.
16170
+ * Desktop forwards only the Model of a main-process prewarm to thread/start. */
16171
+ prewarm: external_exports.literal(true).optional()
16167
16172
  }).strict();
16168
16173
 
16169
16174
  // ../../shared-contracts/dist/harness-launch-settings.js
@@ -15044,6 +15044,8 @@ var usageStatisticsTotalsSchema = external_exports.strictObject({
15044
15044
  cachedInputTokens: count,
15045
15045
  cacheWriteInputTokens: count,
15046
15046
  cacheKnownInputTokens: count,
15047
+ cacheHitCachedInputTokens: count,
15048
+ cacheHitInputTokens: count,
15047
15049
  outputTokens: count,
15048
15050
  reasoningOutputTokens: count,
15049
15051
  /** USD at the public price, summed over the priced requests only. */
@@ -15930,7 +15932,10 @@ var harnessPluginRouteSchema = external_exports.object({
15930
15932
  harnessId: harnessPluginIdSchema,
15931
15933
  model: harnessModelRefSchema.optional(),
15932
15934
  thinkingOptionId: harnessThinkingOptionIdSchema.optional(),
15933
- permissionModeId: harnessPermissionModeIdSchema.optional()
15935
+ permissionModeId: harnessPermissionModeIdSchema.optional(),
15936
+ /** A draft prewarm create: stays unsubmitted until the user's first Turn.
15937
+ * Desktop forwards only the Model of a main-process prewarm to thread/start. */
15938
+ prewarm: external_exports.literal(true).optional()
15934
15939
  }).strict();
15935
15940
 
15936
15941
  // ../../shared-contracts/dist/harness-launch-settings.js
@@ -15164,6 +15164,8 @@ var usageStatisticsTotalsSchema = external_exports.strictObject({
15164
15164
  cachedInputTokens: count,
15165
15165
  cacheWriteInputTokens: count,
15166
15166
  cacheKnownInputTokens: count,
15167
+ cacheHitCachedInputTokens: count,
15168
+ cacheHitInputTokens: count,
15167
15169
  outputTokens: count,
15168
15170
  reasoningOutputTokens: count,
15169
15171
  /** USD at the public price, summed over the priced requests only. */
@@ -16050,7 +16052,10 @@ var harnessPluginRouteSchema = external_exports.object({
16050
16052
  harnessId: harnessPluginIdSchema,
16051
16053
  model: harnessModelRefSchema.optional(),
16052
16054
  thinkingOptionId: harnessThinkingOptionIdSchema.optional(),
16053
- permissionModeId: harnessPermissionModeIdSchema.optional()
16055
+ permissionModeId: harnessPermissionModeIdSchema.optional(),
16056
+ /** A draft prewarm create: stays unsubmitted until the user's first Turn.
16057
+ * Desktop forwards only the Model of a main-process prewarm to thread/start. */
16058
+ prewarm: external_exports.literal(true).optional()
16054
16059
  }).strict();
16055
16060
 
16056
16061
  // ../../shared-contracts/dist/harness-launch-settings.js
@@ -15023,6 +15023,8 @@ var usageStatisticsTotalsSchema = external_exports.strictObject({
15023
15023
  cachedInputTokens: count,
15024
15024
  cacheWriteInputTokens: count,
15025
15025
  cacheKnownInputTokens: count,
15026
+ cacheHitCachedInputTokens: count,
15027
+ cacheHitInputTokens: count,
15026
15028
  outputTokens: count,
15027
15029
  reasoningOutputTokens: count,
15028
15030
  /** USD at the public price, summed over the priced requests only. */
@@ -15909,7 +15911,10 @@ var harnessPluginRouteSchema = external_exports.object({
15909
15911
  harnessId: harnessPluginIdSchema,
15910
15912
  model: harnessModelRefSchema.optional(),
15911
15913
  thinkingOptionId: harnessThinkingOptionIdSchema.optional(),
15912
- permissionModeId: harnessPermissionModeIdSchema.optional()
15914
+ permissionModeId: harnessPermissionModeIdSchema.optional(),
15915
+ /** A draft prewarm create: stays unsubmitted until the user's first Turn.
15916
+ * Desktop forwards only the Model of a main-process prewarm to thread/start. */
15917
+ prewarm: external_exports.literal(true).optional()
15913
15918
  }).strict();
15914
15919
 
15915
15920
  // ../../shared-contracts/dist/harness-launch-settings.js
@@ -15226,6 +15226,8 @@ var usageStatisticsTotalsSchema = external_exports.strictObject({
15226
15226
  cachedInputTokens: count,
15227
15227
  cacheWriteInputTokens: count,
15228
15228
  cacheKnownInputTokens: count,
15229
+ cacheHitCachedInputTokens: count,
15230
+ cacheHitInputTokens: count,
15229
15231
  outputTokens: count,
15230
15232
  reasoningOutputTokens: count,
15231
15233
  /** USD at the public price, summed over the priced requests only. */
@@ -16112,7 +16114,10 @@ var harnessPluginRouteSchema = external_exports.object({
16112
16114
  harnessId: harnessPluginIdSchema,
16113
16115
  model: harnessModelRefSchema.optional(),
16114
16116
  thinkingOptionId: harnessThinkingOptionIdSchema.optional(),
16115
- permissionModeId: harnessPermissionModeIdSchema.optional()
16117
+ permissionModeId: harnessPermissionModeIdSchema.optional(),
16118
+ /** A draft prewarm create: stays unsubmitted until the user's first Turn.
16119
+ * Desktop forwards only the Model of a main-process prewarm to thread/start. */
16120
+ prewarm: external_exports.literal(true).optional()
16116
16121
  }).strict();
16117
16122
 
16118
16123
  // ../../shared-contracts/dist/harness-launch-settings.js
@@ -15223,6 +15223,8 @@ var usageStatisticsTotalsSchema = external_exports.strictObject({
15223
15223
  cachedInputTokens: count,
15224
15224
  cacheWriteInputTokens: count,
15225
15225
  cacheKnownInputTokens: count,
15226
+ cacheHitCachedInputTokens: count,
15227
+ cacheHitInputTokens: count,
15226
15228
  outputTokens: count,
15227
15229
  reasoningOutputTokens: count,
15228
15230
  /** USD at the public price, summed over the priced requests only. */
@@ -16109,7 +16111,10 @@ var harnessPluginRouteSchema = external_exports.object({
16109
16111
  harnessId: harnessPluginIdSchema,
16110
16112
  model: harnessModelRefSchema.optional(),
16111
16113
  thinkingOptionId: harnessThinkingOptionIdSchema.optional(),
16112
- permissionModeId: harnessPermissionModeIdSchema.optional()
16114
+ permissionModeId: harnessPermissionModeIdSchema.optional(),
16115
+ /** A draft prewarm create: stays unsubmitted until the user's first Turn.
16116
+ * Desktop forwards only the Model of a main-process prewarm to thread/start. */
16117
+ prewarm: external_exports.literal(true).optional()
16113
16118
  }).strict();
16114
16119
 
16115
16120
  // ../../shared-contracts/dist/harness-launch-settings.js
@@ -15223,6 +15223,8 @@ var usageStatisticsTotalsSchema = external_exports.strictObject({
15223
15223
  cachedInputTokens: count,
15224
15224
  cacheWriteInputTokens: count,
15225
15225
  cacheKnownInputTokens: count,
15226
+ cacheHitCachedInputTokens: count,
15227
+ cacheHitInputTokens: count,
15226
15228
  outputTokens: count,
15227
15229
  reasoningOutputTokens: count,
15228
15230
  /** USD at the public price, summed over the priced requests only. */
@@ -16109,7 +16111,10 @@ var harnessPluginRouteSchema = external_exports.object({
16109
16111
  harnessId: harnessPluginIdSchema,
16110
16112
  model: harnessModelRefSchema.optional(),
16111
16113
  thinkingOptionId: harnessThinkingOptionIdSchema.optional(),
16112
- permissionModeId: harnessPermissionModeIdSchema.optional()
16114
+ permissionModeId: harnessPermissionModeIdSchema.optional(),
16115
+ /** A draft prewarm create: stays unsubmitted until the user's first Turn.
16116
+ * Desktop forwards only the Model of a main-process prewarm to thread/start. */
16117
+ prewarm: external_exports.literal(true).optional()
16113
16118
  }).strict();
16114
16119
 
16115
16120
  // ../../shared-contracts/dist/harness-launch-settings.js
@@ -18492,7 +18497,7 @@ function normalizePiThinkingOptions(levels) {
18492
18497
  label: PI_THINKING_LABELS[id] ?? fallbackThinkingLabel(id)
18493
18498
  }));
18494
18499
  }
18495
- function normalizePiModelCatalog(nativeModels, effectiveModel, thinkingLevels, effectiveThinkingOptionId) {
18500
+ function normalizePiModelCatalog(nativeModels, effectiveModel, thinkingLevels, effectiveThinkingOptionId, effectiveModelReasoning = null) {
18496
18501
  const byRef = /* @__PURE__ */ new Map();
18497
18502
  for (const native of nativeModels) {
18498
18503
  const ref = encodePiModelRef(native);
@@ -18508,12 +18513,21 @@ function normalizePiModelCatalog(nativeModels, effectiveModel, thinkingLevels, e
18508
18513
  ref,
18509
18514
  label: `${native.provider} / ${native.id}`
18510
18515
  },
18511
- reasoning: native.reasoning
18516
+ reasoning: native.reasoning,
18517
+ synthesized: false
18512
18518
  });
18513
18519
  }
18514
18520
  const defaultModel = effectiveModel ? encodePiModelRef(effectiveModel) : void 0;
18515
- if (defaultModel && !byRef.has(defaultModel.id)) {
18516
- throw new Error("Pi effective Model is absent from the available Model catalog");
18521
+ if (effectiveModel && defaultModel && !byRef.has(defaultModel.id)) {
18522
+ const reasoning = effectiveThinkingOptionId && effectiveThinkingOptionId !== "off" || (effectiveModelReasoning ?? Boolean(thinkingLevels && thinkingLevels.some((level) => level !== "off")));
18523
+ byRef.set(defaultModel.id, {
18524
+ model: {
18525
+ ref: defaultModel,
18526
+ label: `${effectiveModel.provider} / ${effectiveModel.id}`
18527
+ },
18528
+ reasoning,
18529
+ synthesized: true
18530
+ });
18517
18531
  }
18518
18532
  if (thinkingLevels && effectiveThinkingOptionId && !thinkingLevels.includes(effectiveThinkingOptionId)) {
18519
18533
  throw new Error("Pi effective Thinking option is absent from the available option catalog");
@@ -18524,9 +18538,10 @@ function normalizePiModelCatalog(nativeModels, effectiveModel, thinkingLevels, e
18524
18538
  const thinkingOptions = thinkingLevels ? normalizePiThinkingOptions(PI_DRAFT_THINKING_OPTION_IDS) : [];
18525
18539
  const allThinkingOptionIds = thinkingOptions.map(({ id }) => id);
18526
18540
  const offThinkingOptionId = thinkingOptions.find(({ id }) => id === "off")?.id;
18527
- const models = [...byRef.values()].map(({ model: model2, reasoning }) => ({
18541
+ const effectiveThinkingOptionIds = thinkingLevels ? allThinkingOptionIds.filter((id) => thinkingLevels.includes(id)) : allThinkingOptionIds;
18542
+ const models = [...byRef.values()].map(({ model: model2, reasoning, synthesized }) => ({
18528
18543
  ...model2,
18529
- supportedThinkingOptionIds: reasoning ? allThinkingOptionIds : offThinkingOptionId ? [offThinkingOptionId] : []
18544
+ supportedThinkingOptionIds: reasoning ? synthesized ? effectiveThinkingOptionIds : allThinkingOptionIds : offThinkingOptionId ? [offThinkingOptionId] : []
18530
18545
  })).sort((left, right) => compareText(left.label, right.label) || compareText(left.ref.id, right.ref.id));
18531
18546
  const defaultThinkingOptionId = thinkingOptions.find(({ id }) => id === effectiveThinkingOptionId)?.id;
18532
18547
  return harnessModelCatalogSchema.parse({
@@ -20234,6 +20249,7 @@ function sessionStateData(response) {
20234
20249
  function parseSessionState(response) {
20235
20250
  const data = sessionStateData(response);
20236
20251
  const model2 = parseNativeModel(data.model, "state");
20252
+ const modelReasoning = isRecord8(data.model) && typeof data.model.reasoning === "boolean" ? data.model.reasoning : null;
20237
20253
  if (!nonBlankString(data.sessionId)) {
20238
20254
  throw new PiRpcFaultError("protocolError", "Pi RPC state has no stable Session identity");
20239
20255
  }
@@ -20246,6 +20262,7 @@ function parseSessionState(response) {
20246
20262
  sessionFile: typeof data.sessionFile === "string" ? data.sessionFile : null,
20247
20263
  provider: model2?.provider ?? null,
20248
20264
  modelId: model2?.id ?? null,
20265
+ ...modelReasoning === null ? {} : { modelReasoning },
20249
20266
  thinkingLevel: thinkingLevel?.data ?? null,
20250
20267
  contextUsage: optionalPiStateContextUsage(data.contextUsage)
20251
20268
  };
@@ -23027,7 +23044,7 @@ var PiAdapter = class {
23027
23044
  stage = "capabilities";
23028
23045
  const thinkingLevels = await transport.getAvailableThinkingLevels();
23029
23046
  this.#thinkingSelectionSupported = thinkingLevels !== null;
23030
- const normalized = normalizePiModelCatalog(models, nativeModelFromState(transport.state), thinkingLevels, transport.state.thinkingLevel);
23047
+ const normalized = normalizePiModelCatalog(models, nativeModelFromState(transport.state), thinkingLevels, transport.state.thinkingLevel, transport.state.modelReasoning ?? null);
23031
23048
  const fastModels = await transport.supportsFastMode?.() ? piFastModelKeys(models) : /* @__PURE__ */ new Set();
23032
23049
  const catalog = withPiFast(normalized, fastModels);
23033
23050
  await transport.close();