@karlorz/codexhost-cli-win32-arm64 0.13.3-6 → 0.14.0-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 (34) hide show
  1. package/README.md +1 -1
  2. package/app/codexhost-distribution.json +1 -1
  3. package/app/console-server.mjs +539 -95
  4. package/app/console-web.js +879 -73
  5. package/app/cpa-live-voice-hook.js +605 -37
  6. package/app/desktop-controller.mjs +94 -9
  7. package/app/host-runtime.mjs +1662 -642
  8. package/app/plugins/antigravity/plugin.mjs +113 -13
  9. package/app/plugins/claude-code/plugin.mjs +429 -26
  10. package/app/plugins/codebuddy/plugin.mjs +139 -22
  11. package/app/plugins/codex-usage/plugin.mjs +198 -74
  12. package/app/plugins/copilot/assets/icon.png +0 -0
  13. package/app/plugins/copilot/manifest.json +26 -0
  14. package/app/plugins/copilot/plugin.mjs +34645 -0
  15. package/app/plugins/cursor-cli/plugin.mjs +20877 -44973
  16. package/app/plugins/deepseek-harness/plugin.mjs +105 -11
  17. package/app/plugins/enabled.json +1 -0
  18. package/app/plugins/grok/plugin.mjs +1073 -214
  19. package/app/plugins/hermes/plugin.mjs +102 -9
  20. package/app/plugins/kimi-code/plugin.mjs +98 -7
  21. package/app/plugins/kiro-cli/plugin.mjs +98 -7
  22. package/app/plugins/omp/plugin.mjs +2177 -2000
  23. package/app/plugins/opencode/plugin.mjs +107 -11
  24. package/app/plugins/pi/plugin.mjs +2554 -2285
  25. package/app/plugins/qoder/plugin.mjs +105 -11
  26. package/app/plugins/qoder-cn/plugin.mjs +105 -11
  27. package/app/plugins/workbuddy/plugin.mjs +400 -46
  28. package/app/plugins/zcode/plugin.mjs +106 -11
  29. package/app/renderer-extension.js +2717 -1237
  30. package/bin/codexhost.exe +0 -0
  31. package/libexec/codexhost-node-repl.exe +0 -0
  32. package/libexec/codexhost-shim.exe +0 -0
  33. package/libexec/codexhost-updater.exe +0 -0
  34. package/package.json +1 -1
@@ -14662,10 +14662,19 @@ var model = external_exports.string().min(1).max(512);
14662
14662
  var project = external_exports.string().min(1).max(4096);
14663
14663
  var usageStatisticsParamsSchema = external_exports.strictObject({
14664
14664
  range: external_exports.enum(USAGE_STATISTICS_RANGES),
14665
+ /** Display timezone for ranges, dates and hourly buckets; omitted means the Host's local zone. */
14666
+ timeZone: external_exports.string().min(1).max(128).refine((value) => {
14667
+ try {
14668
+ new Intl.DateTimeFormat("en", { timeZone: value });
14669
+ return true;
14670
+ } catch {
14671
+ return false;
14672
+ }
14673
+ }, "Unsupported usage statistics timezone").optional(),
14665
14674
  harness: harness.optional(),
14666
14675
  model: model.nullable().optional(),
14667
14676
  project: project.nullable().optional(),
14668
- /** One local date inside the range. */
14677
+ /** One date in the query timezone inside the range. */
14669
14678
  date: localDate.optional()
14670
14679
  });
14671
14680
  var usageStatisticsTotalsSchema = external_exports.strictObject({
@@ -14701,7 +14710,7 @@ var usageStatisticsSessionSchema = external_exports.strictObject({
14701
14710
  });
14702
14711
  var usageStatisticsResultSchema = external_exports.strictObject({
14703
14712
  range: external_exports.enum(USAGE_STATISTICS_RANGES),
14704
- /** First local date of the range; null for all time. */
14713
+ /** First date in the query timezone (Host local when omitted); null for all time. */
14705
14714
  from: localDate.nullable(),
14706
14715
  to: localDate,
14707
14716
  /** The filters these figures apply, echoed so a late answer to older filters is recognised. */
@@ -14741,7 +14750,7 @@ var usageStatisticsResultSchema = external_exports.strictObject({
14741
14750
  totals: usageStatisticsTotalsSchema,
14742
14751
  /** Each date and Harness of the range: every filter except the day. */
14743
14752
  daily: external_exports.array(external_exports.strictObject({ date: localDate, harness, ...totals })).max(2e5),
14744
- /** Local weekday (0 = Sunday) and hour, all filters applied. */
14753
+ /** Weekday (0 = Sunday) and hour in the query timezone, all filters applied. */
14745
14754
  hourly: external_exports.array(external_exports.strictObject({
14746
14755
  weekday: external_exports.number().int().min(0).max(6),
14747
14756
  hour: external_exports.number().int().min(0).max(23),
@@ -14832,8 +14841,12 @@ var CONSOLE_HOST_METHODS = Object.freeze([
14832
14841
  "codexhost/harness/display-settings/set",
14833
14842
  "codexhost/harness/inspect",
14834
14843
  "codexhost/harness/installation",
14844
+ "codexhost/harness/installation/start",
14845
+ "codexhost/harness/installation/status",
14835
14846
  "codexhost/harness/launch-settings/get",
14836
14847
  "codexhost/harness/launch-settings/set",
14848
+ "codexhost/harness/grok-computer-use/get",
14849
+ "codexhost/harness/grok-computer-use/set",
14837
14850
  "codexhost/harness/web-ui/open",
14838
14851
  "codexhost/harness/accounts/sources",
14839
14852
  "codexhost/harness/accounts/list",
@@ -14907,7 +14920,18 @@ var threadManualCompactionStartedSchema = external_exports.strictObject({
14907
14920
  var nonNegativeSafeIntegerSchema = external_exports.number().int().safe().nonnegative();
14908
14921
  var finiteNonNegativeNumberSchema = external_exports.number().finite().nonnegative();
14909
14922
  var cacheHitRatePercentSchema = external_exports.number().finite().min(0).max(100);
14923
+ var indicatorTextSchema = (maximum) => harnessLocalizedTextSchema.refine((entries) => Object.values(entries).every((text2) => text2.length <= maximum));
14924
+ var composerIndicatorsSchema = external_exports.array(external_exports.object({
14925
+ kind: external_exports.literal("countdown"),
14926
+ id: external_exports.string().min(1).max(64),
14927
+ expiresAtUnix: nonNegativeSafeIntegerSchema,
14928
+ label: indicatorTextSchema(256).optional(),
14929
+ tooltip: indicatorTextSchema(1024).optional()
14930
+ }).strict()).max(2).refine((entries) => new Set(entries.map(({ id: id2 }) => id2)).size === entries.length, {
14931
+ message: "Composer indicator IDs must be unique"
14932
+ });
14910
14933
  var threadUsageSnapshotSchema = external_exports.object({
14934
+ composerIndicators: composerIndicatorsSchema.optional(),
14911
14935
  inputTokens: nonNegativeSafeIntegerSchema.optional(),
14912
14936
  cachedInputTokens: nonNegativeSafeIntegerSchema.optional(),
14913
14937
  cacheWriteInputTokens: nonNegativeSafeIntegerSchema.optional(),
@@ -15315,7 +15339,9 @@ var harnessSessionCapabilitiesSchema = external_exports.object({
15315
15339
  }).strict().optional(),
15316
15340
  autonomousTurns: external_exports.object({
15317
15341
  observe: external_exports.boolean()
15318
- }).strict().optional()
15342
+ }).strict().optional(),
15343
+ /** True only when `turn.steer` delivers input into the active Turn through a native primitive. */
15344
+ steer: external_exports.boolean().optional()
15319
15345
  }).strict();
15320
15346
  var harnessConfigurationStateSchema = external_exports.object({
15321
15347
  effectiveModel: harnessModelRefSchema.optional(),
@@ -15362,7 +15388,9 @@ var harnessInspectionSchema = external_exports.union([
15362
15388
  var harnessInspectParamsSchema = external_exports.object({
15363
15389
  harnessId: harnessIdSchema,
15364
15390
  cwd: nonBlankTextSchema2.max(16384).optional(),
15365
- refresh: external_exports.boolean().optional()
15391
+ refresh: external_exports.boolean().optional(),
15392
+ /** `availability` asks only whether the Harness can run; see `InspectHarnessInput.purpose`. */
15393
+ purpose: external_exports.literal("availability").optional()
15366
15394
  }).strict();
15367
15395
  var harnessWebUiOpenParamsSchema = external_exports.object({
15368
15396
  harnessId: harnessIdSchema
@@ -15445,6 +15473,15 @@ var threadOwnershipListResultSchema = external_exports.object({
15445
15473
  seen.add(thread.threadId);
15446
15474
  }
15447
15475
  });
15476
+ var threadSteeringInspectParamsSchema = external_exports.object({
15477
+ threadId: hostThreadIdSchema,
15478
+ /** The text about to be steered; a Harness command always stops and restarts. */
15479
+ text: external_exports.string().optional()
15480
+ }).strict();
15481
+ var threadSteerDeliverySchema = external_exports.enum(["activeTurn", "newTurn"]);
15482
+ var threadSteeringInspectResultSchema = external_exports.object({
15483
+ delivery: external_exports.enum(["official", "activeTurn", "newTurn"])
15484
+ }).strict();
15448
15485
 
15449
15486
  // ../../shared-contracts/dist/harness-plugins.js
15450
15487
  var HARNESS_PLUGIN_MANIFEST_MAX_BYTES = 32 * 1024;
@@ -15536,6 +15573,26 @@ var harnessLaunchSettingsSchema = external_exports.object({
15536
15573
  restartRequired: external_exports.boolean()
15537
15574
  }).strict();
15538
15575
 
15576
+ // ../../shared-contracts/dist/grok-computer-use.js
15577
+ var grokComputerUseGetSchema = external_exports.object({}).strict();
15578
+ var grokComputerUseSetSchema = external_exports.object({
15579
+ enabled: external_exports.boolean().optional(),
15580
+ browser: external_exports.boolean().optional()
15581
+ }).strict().refine((value) => value.enabled !== void 0 || value.browser !== void 0, {
15582
+ message: "Expected enabled or browser"
15583
+ });
15584
+ var grokComputerUseSettingsSchema = external_exports.object({
15585
+ enabled: external_exports.boolean(),
15586
+ available: external_exports.boolean(),
15587
+ unavailableReason: external_exports.string().min(1).max(500).optional(),
15588
+ browser: external_exports.boolean().optional(),
15589
+ browserFilesPresent: external_exports.boolean().optional(),
15590
+ browserAvailable: external_exports.boolean().optional(),
15591
+ browserUnavailableReason: external_exports.string().min(1).max(500).optional(),
15592
+ applyFailed: external_exports.boolean().optional(),
15593
+ applyError: external_exports.string().min(1).max(500).optional()
15594
+ }).strict();
15595
+
15539
15596
  // ../../shared-contracts/dist/harness-installation.js
15540
15597
  var harnessInstallationParamsSchema = external_exports.object({
15541
15598
  harnessId: harnessIdSchema,
@@ -15546,6 +15603,10 @@ var harnessInstallationStateSchema = external_exports.object({
15546
15603
  latestVersion: external_exports.string().min(1).max(128),
15547
15604
  updateAvailable: external_exports.boolean(),
15548
15605
  canUpdate: external_exports.boolean(),
15606
+ /** Defaults to CLI; some Harnesses ship only inside a desktop application. */
15607
+ versionKind: external_exports.enum(["cli", "application"]).optional(),
15608
+ /** Official download opened by the user; does not imply an automatic installation. */
15609
+ manualUpdateUrl: external_exports.url().max(2048).refine((value) => /^https:\/\/[^/?#@]+(?:[/?#]|$)/iu.test(value), "Manual updates require a credential-free HTTPS URL").optional(),
15549
15610
  // Adapter-owned diagnostic text; UI uses messageCode rather than displaying it verbatim.
15550
15611
  message: external_exports.string().max(2048).optional(),
15551
15612
  messageCode: external_exports.string().min(1).max(128).optional(),
@@ -15553,6 +15614,20 @@ var harnessInstallationStateSchema = external_exports.object({
15553
15614
  notice: harnessLocalizedTextSchema.optional(),
15554
15615
  latestVersionKind: external_exports.enum(["unknown", "tracking-branch"]).optional()
15555
15616
  }).strict();
15617
+ var harnessInstallationTaskParamsSchema = external_exports.object({ taskId: external_exports.string().uuid() }).strict();
15618
+ var harnessInstallationTaskSchema = external_exports.discriminatedUnion("status", [
15619
+ external_exports.object({ taskId: external_exports.string().uuid(), status: external_exports.literal("running") }).strict(),
15620
+ external_exports.object({
15621
+ taskId: external_exports.string().uuid(),
15622
+ status: external_exports.literal("succeeded"),
15623
+ result: harnessInstallationStateSchema
15624
+ }).strict(),
15625
+ external_exports.object({
15626
+ taskId: external_exports.string().uuid(),
15627
+ status: external_exports.literal("failed"),
15628
+ error: external_exports.object({ code: external_exports.number().int(), message: external_exports.string().min(1).max(2048) }).strict()
15629
+ }).strict()
15630
+ ]);
15556
15631
 
15557
15632
  // ../../shared-contracts/dist/codex-accounts.js
15558
15633
  var accountIdSchema = external_exports.string().min(1).max(256).regex(/^[A-Za-z0-9._~-]+$/u);
@@ -16111,6 +16186,7 @@ var usageFields = /* @__PURE__ */ new Set([
16111
16186
  ...safeIntegerFields,
16112
16187
  ...percentFields,
16113
16188
  "sessionCacheUsage",
16189
+ "composerIndicators",
16114
16190
  "totalCostUsd",
16115
16191
  "totalCredits",
16116
16192
  "contextUsagePercent",
@@ -16133,6 +16209,7 @@ function parseHostUsage(value) {
16133
16209
  throw new Error(`Harness Usage contains unknown field '${key}'`);
16134
16210
  }
16135
16211
  }
16212
+ const indicators = value.composerIndicators === void 0 ? {} : { composerIndicators: composerIndicatorsSchema.parse(value.composerIndicators) };
16136
16213
  for (const field of [
16137
16214
  "totalCredits",
16138
16215
  "contextUsagePercent",
@@ -16203,9 +16280,9 @@ function parseHostUsage(value) {
16203
16280
  if (value.costSource !== "publicPrice") {
16204
16281
  throw new Error("Harness Usage 'unpricedModels' must be provided with a 'publicPrice' cost");
16205
16282
  }
16206
- return { ...value, unpricedModels: [...models] };
16283
+ return { ...value, ...indicators, unpricedModels: [...models] };
16207
16284
  }
16208
- return { ...value };
16285
+ return { ...value, ...indicators };
16209
16286
  }
16210
16287
  var requestTokenFields = [
16211
16288
  "inputTokens",
@@ -16404,6 +16481,7 @@ var harnessBrokerMethodSchema = external_exports.enum([
16404
16481
  "adapter.open",
16405
16482
  "adapter.subagent.readSnapshot",
16406
16483
  "session.readSnapshot",
16484
+ "session.readCapabilities",
16407
16485
  "session.refreshUsage",
16408
16486
  "session.execute",
16409
16487
  "session.commands.list",
@@ -16584,6 +16662,11 @@ var turnStartSchema = external_exports.object({
16584
16662
  turnId: hostTurnIdSchema,
16585
16663
  input: external_exports.array(textInputSchema)
16586
16664
  }).strict();
16665
+ var turnSteerSchema = external_exports.object({
16666
+ type: external_exports.literal("turn.steer"),
16667
+ turnId: hostTurnIdSchema,
16668
+ input: external_exports.array(textInputSchema)
16669
+ }).strict();
16587
16670
  var turnCancelSchema = external_exports.object({ type: external_exports.literal("turn.cancel"), turnId: hostTurnIdSchema }).strict();
16588
16671
  var interactionResponseSchema = external_exports.union([
16589
16672
  external_exports.object({
@@ -16609,6 +16692,7 @@ var permissionSelectSchema = external_exports.object({
16609
16692
  }).strict();
16610
16693
  var brokerHostCommandSchema = external_exports.discriminatedUnion("type", [
16611
16694
  turnStartSchema,
16695
+ turnSteerSchema,
16612
16696
  turnCancelSchema,
16613
16697
  interactionRespondSchema,
16614
16698
  modelSelectSchema,
@@ -16801,6 +16885,7 @@ function parseSessionMetadata(value) {
16801
16885
  sessionId: candidate.sessionId,
16802
16886
  sessionGeneration: candidate.sessionGeneration,
16803
16887
  capabilities: harnessSessionCapabilitiesSchema.parse(candidate.capabilities),
16888
+ readCapabilities: candidate.readCapabilities === true,
16804
16889
  initialState: state,
16805
16890
  initialUsage: candidate.initialUsage === null ? null : parseHostUsage(candidate.initialUsage),
16806
16891
  commands: candidate.commands === true
@@ -17152,6 +17237,11 @@ var BrokeredHarnessSession = class {
17152
17237
  event: { type: "session.faulted", error: unavailable(error52.message) }
17153
17238
  });
17154
17239
  }
17240
+ async readCapabilities() {
17241
+ if (!this.#metadata.readCapabilities)
17242
+ return { ...this.capabilities, steer: false };
17243
+ return harnessSessionCapabilitiesSchema.parse(await this.#request("session.readCapabilities", {}));
17244
+ }
17155
17245
  async refreshUsage() {
17156
17246
  await this.#request("session.refreshUsage", {});
17157
17247
  }
@@ -17183,6 +17273,8 @@ var BrokeredHarnessSession = class {
17183
17273
  try {
17184
17274
  return parseHarnessResult(await this.#request("session.execute", { command }));
17185
17275
  } catch (error52) {
17276
+ if (command.type === "turn.steer")
17277
+ throw error52;
17186
17278
  return {
17187
17279
  ok: false,
17188
17280
  error: unavailable(error52 instanceof Error ? error52.message : String(error52))
@@ -17569,10 +17661,13 @@ function usageSessionTitle(value) {
17569
17661
  return void 0;
17570
17662
  if (normalized.length <= MAX_SESSION_TITLE_LENGTH)
17571
17663
  return normalized;
17572
- const characters = [...normalized];
17573
- if (characters.length <= MAX_SESSION_TITLE_LENGTH)
17574
- return normalized;
17575
- return `${characters.slice(0, MAX_SESSION_TITLE_LENGTH - 1).join("").trimEnd()}…`;
17664
+ let title = "";
17665
+ for (const character of normalized) {
17666
+ if (title.length + character.length >= MAX_SESSION_TITLE_LENGTH)
17667
+ break;
17668
+ title += character;
17669
+ }
17670
+ return `${title.trimEnd()}…`;
17576
17671
  }
17577
17672
  function sessionIdOk(value) {
17578
17673
  return typeof value === "string" && value.length > 0 && value.length <= MAX_SESSION_ID_LENGTH;
@@ -17725,6 +17820,31 @@ function createClaudeUsageStatistics(environment) {
17725
17820
  });
17726
17821
  }
17727
17822
 
17823
+ // dist/claude-prompt-cache.js
17824
+ function lastClaudeAssistantResponseUnix(messages) {
17825
+ let latest;
17826
+ for (const entry of messages) {
17827
+ if (typeof entry !== "object" || entry === null || !("type" in entry) || entry.type !== "assistant" || "isSidechain" in entry && entry.isSidechain === true || "parent_tool_use_id" in entry && entry.parent_tool_use_id != null || !("timestamp" in entry) || typeof entry.timestamp !== "string")
17828
+ continue;
17829
+ const time3 = Math.floor(Date.parse(entry.timestamp) / 1e3);
17830
+ if (Number.isSafeInteger(time3) && time3 >= 0)
17831
+ latest = Math.max(latest ?? 0, time3);
17832
+ }
17833
+ return latest;
17834
+ }
17835
+ function claudePromptCacheIndicators(accountCreditsSupported, lastResponseAtUnix) {
17836
+ if (!accountCreditsSupported || lastResponseAtUnix === void 0)
17837
+ return [];
17838
+ return [
17839
+ {
17840
+ kind: "countdown",
17841
+ id: "prompt-cache",
17842
+ expiresAtUnix: lastResponseAtUnix + 3600,
17843
+ label: { en: "Prompt cache", "zh-CN": "提示词缓存" }
17844
+ }
17845
+ ];
17846
+ }
17847
+
17728
17848
  // dist/claude-code-adapter.js
17729
17849
  import { randomUUID as randomUUID5 } from "node:crypto";
17730
17850
  import path16 from "node:path";
@@ -54543,11 +54663,20 @@ function parseResultModelUsage(value) {
54543
54663
  if (!isRecord7(value))
54544
54664
  return void 0;
54545
54665
  const usage = [];
54546
- for (const entry of Object.values(value)) {
54666
+ for (const [model2, entry] of Object.entries(value)) {
54547
54667
  if (!isRecord7(entry) || !safeNonNegativeInteger(entry.inputTokens) || !safeNonNegativeInteger(entry.outputTokens)) {
54548
54668
  return void 0;
54549
54669
  }
54550
- usage.push({ inputTokens: entry.inputTokens, outputTokens: entry.outputTokens });
54670
+ const cacheRead = safeNonNegativeInteger(entry.cacheReadInputTokens) ? entry.cacheReadInputTokens : 0;
54671
+ const cacheWrite = safeNonNegativeInteger(entry.cacheCreationInputTokens) ? entry.cacheCreationInputTokens : 0;
54672
+ const promptTokens = entry.inputTokens + cacheRead + cacheWrite;
54673
+ usage.push({
54674
+ model: model2,
54675
+ inputTokens: entry.inputTokens,
54676
+ outputTokens: entry.outputTokens,
54677
+ ...Number.isSafeInteger(promptTokens) ? { promptTokens } : {},
54678
+ ...safeNonNegativeInteger(entry.contextWindow) && entry.contextWindow > 0 ? { contextWindowTokens: entry.contextWindow } : {}
54679
+ });
54551
54680
  }
54552
54681
  return usage;
54553
54682
  }
@@ -54904,6 +55033,7 @@ var ClaudeNativeTurnAccumulator = class {
54904
55033
  events.push({
54905
55034
  type: "message.completed",
54906
55035
  messageId,
55036
+ localCommand: true,
54907
55037
  ...checkpointId ? { checkpointId } : {}
54908
55038
  });
54909
55039
  }
@@ -55386,6 +55516,10 @@ function conversationMessages(values, sessionId) {
55386
55516
  const messages = [];
55387
55517
  const ids = /* @__PURE__ */ new Set();
55388
55518
  let promptId = null;
55519
+ const occupancy = new ClaudeBackgroundOccupancy();
55520
+ let accumulator = new ClaudeNativeTurnAccumulator();
55521
+ const sends = /* @__PURE__ */ new Set();
55522
+ let pendingNotification = false;
55389
55523
  for (const value of values) {
55390
55524
  if (!isRecord8(value))
55391
55525
  throw new Error("Claude history contains a malformed message");
@@ -55404,8 +55538,46 @@ function conversationMessages(values, sessionId) {
55404
55538
  message: value.message,
55405
55539
  nested: typeof value.parent_tool_use_id === "string" && value.parent_tool_use_id.length > 0,
55406
55540
  interrupted,
55541
+ startsTurn: false,
55407
55542
  syntheticUser: value.type === "user" && (interrupted || value.isSynthetic === true || value.isMeta === true || isTaskNotificationOrigin(value) || value.toolUseResult !== void 0 && value.toolUseResult !== null)
55408
55543
  };
55544
+ const notification = message.type === "user" && !message.nested && (isTaskNotificationOrigin(value) || textParts(message.message.content).some(isTaskNotificationRecord));
55545
+ message.startsTurn = isHumanUser(message) || notification && !occupancy.unsettled && !pendingNotification;
55546
+ if (message.startsTurn) {
55547
+ occupancy.clear();
55548
+ sends.clear();
55549
+ accumulator = new ClaudeNativeTurnAccumulator();
55550
+ }
55551
+ for (const event of accumulator.consume(value).events) {
55552
+ if (event.type === "subagent.started") {
55553
+ if (event.operation === "send") {
55554
+ sends.add(event.callId);
55555
+ if (event.nativeSubagentId)
55556
+ occupancy.occupyAgent(event.nativeSubagentId);
55557
+ } else if (event.background)
55558
+ occupancy.occupySpawn(event.callId, event.nativeSubagentId);
55559
+ } else if (event.type === "subagent.completed") {
55560
+ if (!event.isError && (event.continuesInBackground || sends.has(event.callId))) {
55561
+ occupancy.occupySpawn(event.callId, event.nativeSubagentId);
55562
+ } else
55563
+ occupancy.release(event.callId, event.nativeSubagentId);
55564
+ sends.delete(event.callId);
55565
+ } else if (event.type === "workflow.launched" && event.background && !event.isError) {
55566
+ occupancy.occupySpawn(event.callId, event.taskId);
55567
+ } else if (event.type === "subagent.settled") {
55568
+ occupancy.notify(event.callId, event.nativeSubagentId);
55569
+ }
55570
+ }
55571
+ if (notification)
55572
+ pendingNotification = true;
55573
+ if (message.type === "assistant" && !message.nested) {
55574
+ pendingNotification = false;
55575
+ if (["end_turn", "stop_sequence", "max_tokens"].includes(String(message.message.stop_reason))) {
55576
+ occupancy.releaseContinuations();
55577
+ }
55578
+ }
55579
+ if (interrupted)
55580
+ occupancy.clear();
55409
55581
  messages.push(message);
55410
55582
  if (isHumanUser(message)) {
55411
55583
  promptId = typeof value.promptId === "string" && value.promptId.length > 0 ? value.promptId : null;
@@ -55462,17 +55634,17 @@ function mapClaudeSnapshot(values, sessionId) {
55462
55634
  const turns = [];
55463
55635
  for (let index = 0; index < messages.length; ) {
55464
55636
  const user = messages[index];
55465
- if (!user || !isHumanUser(user)) {
55637
+ if (!user || !user.startsTurn) {
55466
55638
  index += 1;
55467
55639
  continue;
55468
55640
  }
55469
55641
  let end = index + 1;
55470
- while (end < messages.length && !isHumanUser(messages[end]))
55642
+ while (end < messages.length && !messages[end]?.startsTurn)
55471
55643
  end += 1;
55472
55644
  const turnMessages = messages.slice(index, end);
55473
55645
  const outcome = turnOutcome(turnMessages);
55474
55646
  const results = toolResultBlocks(turnMessages);
55475
- const checkpointMessage = turnMessages.findLast(({ type, interrupted }) => type === "assistant" || interrupted);
55647
+ const checkpointMessage = turnMessages.findLast(({ type, interrupted, nested }) => !nested && (type === "assistant" || interrupted));
55476
55648
  let agentMessageOrdinal = 0;
55477
55649
  let reasoningOrdinal = 0;
55478
55650
  let toolOrdinal = 0;
@@ -56636,12 +56808,21 @@ async function closeClaudeProcessGroup(child, timeoutMs) {
56636
56808
  throw new Error("Claude SDK process group did not exit");
56637
56809
  }
56638
56810
 
56811
+ // dist/transport.js
56812
+ var ClaudeSteerMissedTurnError = class extends Error {
56813
+ constructor() {
56814
+ super("Claude Code steer missed the active Turn");
56815
+ this.name = "ClaudeSteerMissedTurnError";
56816
+ }
56817
+ };
56818
+
56639
56819
  // dist/sdk-transport.js
56640
56820
  var CLIENT_APP = "codexhost-claude-code-adapter/0.0.0";
56641
56821
  var SESSION_ENTRYPOINT = "codexhost-sdk";
56642
56822
  var APPROVAL_TITLE_MAX_LENGTH = 120;
56643
56823
  var APPROVAL_DESCRIPTION_MAX_LENGTH = 500;
56644
56824
  var DEFAULT_ABORT_TIMEOUT_MS = 2e3;
56825
+ var DEFAULT_STEER_QUEUED_TIMEOUT_MS = 5e3;
56645
56826
  var WORKFLOW_AGENT_LABEL_LIMIT = 1e3;
56646
56827
  var INTERRUPT_TIMEOUT_MESSAGE = "Claude SDK interrupt timed out";
56647
56828
  var PushableInput = class {
@@ -56897,6 +57078,11 @@ var ClaudeSdkTransport = class {
56897
57078
  #queryFactory;
56898
57079
  #thinkingOptionId;
56899
57080
  #active = null;
57081
+ #steerQueuedTimeoutMs;
57082
+ #nativeSteer = false;
57083
+ /** Root tool calls of the requested Turn that have started and not yet returned a result. */
57084
+ #rootToolCalls = /* @__PURE__ */ new Set();
57085
+ #pendingSteers = /* @__PURE__ */ new Map();
56900
57086
  #autonomous = null;
56901
57087
  #autonomousTurnHandler = null;
56902
57088
  #idleHandler = null;
@@ -56920,6 +57106,7 @@ var ClaudeSdkTransport = class {
56920
57106
  this.sessionId = options.sessionId;
56921
57107
  this.#cwd = options.cwd;
56922
57108
  this.#abortTimeoutMs = options.abortTimeoutMs ?? DEFAULT_ABORT_TIMEOUT_MS;
57109
+ this.#steerQueuedTimeoutMs = options.steerQueuedTimeoutMs ?? DEFAULT_STEER_QUEUED_TIMEOUT_MS;
56923
57110
  this.#closeTimeoutMs = options.closeTimeoutMs;
56924
57111
  this.#command = options.command;
56925
57112
  this.#environment = options.environment ?? process.env;
@@ -56974,7 +57161,8 @@ var ClaudeSdkTransport = class {
56974
57161
  thinking: thinking.enabled ? { type: "adaptive", display: "summarized" } : { type: "disabled" },
56975
57162
  ...thinking.effort ? { effort: thinking.effort } : {},
56976
57163
  pathToClaudeCodeExecutable: executable,
56977
- settingSources: ["user"],
57164
+ // Omitted settingSources loads user, project and local settings like the
57165
+ // Claude Code CLI, so project CLAUDE.md and .claude/skills apply.
56978
57166
  permissionMode: this.#permissionMode,
56979
57167
  ...this.#allowDangerouslySkipPermissions ? { allowDangerouslySkipPermissions: true } : {},
56980
57168
  canUseTool: (toolName, input, options) => this.#canUseTool(toolName, input, options),
@@ -57011,6 +57199,40 @@ var ClaudeSdkTransport = class {
57011
57199
  return null;
57012
57200
  return { commands: this.#slashCommands, skillNames: this.#skillNames };
57013
57201
  }
57202
+ supportsNativeSteer() {
57203
+ return this.#nativeSteer;
57204
+ }
57205
+ /**
57206
+ * `priority: "next"` joins after the current tool call, and a tool result is always followed by
57207
+ * another model request. So a steer written while a root tool call runs folds into this Turn;
57208
+ * one written while Claude streams its final text may instead run as the next Turn.
57209
+ */
57210
+ canSteerActiveTurn() {
57211
+ return this.#nativeSteer && this.#active !== null && this.#rootToolCalls.size > 0;
57212
+ }
57213
+ #observeRootToolCalls(message) {
57214
+ if (!isRecord11(message) || message.parent_tool_use_id != null)
57215
+ return;
57216
+ if (message.type !== "assistant" && message.type !== "user")
57217
+ return;
57218
+ const body = message.message;
57219
+ if (!isRecord11(body) || !Array.isArray(body.content))
57220
+ return;
57221
+ for (const block of body.content) {
57222
+ if (!isRecord11(block))
57223
+ continue;
57224
+ if (message.type === "assistant" && block.type === "tool_use" && typeof block.id === "string") {
57225
+ this.#rootToolCalls.add(block.id);
57226
+ } else if (message.type === "user" && block.type === "tool_result" && typeof block.tool_use_id === "string") {
57227
+ this.#rootToolCalls.delete(block.tool_use_id);
57228
+ }
57229
+ }
57230
+ }
57231
+ #observeNativeCapabilities(message) {
57232
+ if (!isRecord11(message) || message.type !== "system" || message.subtype !== "init")
57233
+ return;
57234
+ this.#nativeSteer = Array.isArray(message.capabilities) && message.capabilities.includes("msg_lifecycle_v1");
57235
+ }
57014
57236
  #observeSlashCommands(message) {
57015
57237
  if (!isRecord11(message) || message.type !== "system")
57016
57238
  return;
@@ -57133,6 +57355,7 @@ var ClaudeSdkTransport = class {
57133
57355
  const unclaimed = this.#autonomous?.events ?? [];
57134
57356
  this.#autonomous = null;
57135
57357
  const promise2 = new Promise((resolve5, reject) => {
57358
+ this.#rootToolCalls.clear();
57136
57359
  this.#active = {
57137
57360
  accumulator: new ClaudeNativeTurnAccumulator(this.#provider ? { provider: this.#provider } : {}),
57138
57361
  onEvent,
@@ -57152,6 +57375,51 @@ var ClaudeSdkTransport = class {
57152
57375
  });
57153
57376
  return promise2;
57154
57377
  }
57378
+ /**
57379
+ * Claude accepts the input with `queued`; Claude Code 2.1.280 then emits `started` after the
57380
+ * current tool call, when `priority: "next"` joins the running Turn. Waiting for `started` would
57381
+ * hold the caller for a whole tool call.
57382
+ *
57383
+ * Once written, the input cannot be recalled: Claude delivers it in this Turn or runs it next.
57384
+ * The Turn ending first therefore does not reject it, and a missing `queued` receipt resolves
57385
+ * after a bounded wait so callers that serialize requests are never held indefinitely.
57386
+ */
57387
+ steer(text2, messageId) {
57388
+ if (this.#closePromise || !this.#started || !this.#query || !this.canSteerActiveTurn()) {
57389
+ return Promise.reject(new ClaudeSteerMissedTurnError());
57390
+ }
57391
+ const promise2 = new Promise((resolve5, reject) => {
57392
+ this.#pendingSteers.set(messageId, { resolve: resolve5, reject, timer: void 0 });
57393
+ });
57394
+ try {
57395
+ this.#input.push({
57396
+ type: "user",
57397
+ message: { role: "user", content: text2 },
57398
+ parent_tool_use_id: null,
57399
+ session_id: this.sessionId,
57400
+ uuid: messageId,
57401
+ origin: { kind: "human" },
57402
+ priority: "next"
57403
+ });
57404
+ } catch {
57405
+ this.#pendingSteers.delete(messageId);
57406
+ return Promise.reject(new ClaudeSteerMissedTurnError());
57407
+ }
57408
+ const pending = this.#pendingSteers.get(messageId);
57409
+ if (pending) {
57410
+ pending.timer = setTimeout(() => this.#acceptSteer(messageId), this.#steerQueuedTimeoutMs);
57411
+ pending.timer.unref?.();
57412
+ }
57413
+ return promise2;
57414
+ }
57415
+ #acceptSteer(messageId) {
57416
+ const pending = this.#pendingSteers.get(messageId);
57417
+ if (!pending)
57418
+ return;
57419
+ this.#pendingSteers.delete(messageId);
57420
+ clearTimeout(pending.timer);
57421
+ pending.resolve();
57422
+ }
57155
57423
  respondToInteraction(response) {
57156
57424
  const pending = this.#interactions.get(response.requestId);
57157
57425
  if (!pending) {
@@ -57323,6 +57591,7 @@ var ClaudeSdkTransport = class {
57323
57591
  }
57324
57592
  }
57325
57593
  async #close() {
57594
+ this.#rejectPendingSteers();
57326
57595
  const failures = [];
57327
57596
  this.#closeInteractions("all", "cancelled");
57328
57597
  try {
@@ -57376,6 +57645,7 @@ var ClaudeSdkTransport = class {
57376
57645
  }
57377
57646
  this.#query = null;
57378
57647
  const active = this.#active;
57648
+ this.#rootToolCalls.clear();
57379
57649
  this.#active = null;
57380
57650
  this.#autonomous = null;
57381
57651
  this.#idleAccumulator = null;
@@ -57430,6 +57700,26 @@ var ClaudeSdkTransport = class {
57430
57700
  await delay(10);
57431
57701
  }
57432
57702
  }
57703
+ #rejectPendingSteers() {
57704
+ const pending = [...this.#pendingSteers.values()];
57705
+ this.#pendingSteers.clear();
57706
+ const error52 = new Error("Claude Code steer receipt was lost after input was written");
57707
+ for (const entry of pending) {
57708
+ clearTimeout(entry.timer);
57709
+ entry.reject(error52);
57710
+ }
57711
+ }
57712
+ /** `queued` is Claude's acceptance of this message into the running Session. */
57713
+ #observeSteer(message) {
57714
+ if (this.#pendingSteers.size === 0 || !isRecord11(message) || message.type !== "command_lifecycle") {
57715
+ return;
57716
+ }
57717
+ if (message.state !== "queued")
57718
+ return;
57719
+ if (typeof message.command_uuid !== "string" || message.command_uuid.length === 0)
57720
+ return;
57721
+ this.#acceptSteer(message.command_uuid);
57722
+ }
57433
57723
  #observeBackgroundTasks(message) {
57434
57724
  if (!isRecord11(message) || message.type !== "system")
57435
57725
  return;
@@ -57470,6 +57760,7 @@ var ClaudeSdkTransport = class {
57470
57760
  this.#observeBackgroundTasks(message);
57471
57761
  this.#observeWorkflowAgents(message);
57472
57762
  this.#observeSlashCommands(message);
57763
+ this.#observeNativeCapabilities(message);
57473
57764
  const permissionMode = permissionModeFromMessage(message);
57474
57765
  if (permissionMode && permissionMode !== this.#permissionMode) {
57475
57766
  this.#permissionMode = permissionMode;
@@ -57478,13 +57769,16 @@ var ClaudeSdkTransport = class {
57478
57769
  const planLimit = parseClaudePlanLimitEvent(message);
57479
57770
  if (planLimit)
57480
57771
  this.#onPlanLimit(planLimit);
57772
+ this.#observeSteer(message);
57481
57773
  const active = this.#active;
57482
57774
  if (active) {
57775
+ this.#observeRootToolCalls(message);
57483
57776
  const interpreted2 = active.accumulator.consume(message);
57484
57777
  for (const event of interpreted2.events)
57485
57778
  active.onEvent(event);
57486
57779
  if (interpreted2.terminal) {
57487
57780
  this.#closeInteractions("root", "superseded");
57781
+ this.#rootToolCalls.clear();
57488
57782
  this.#active = null;
57489
57783
  active.resolve(interpreted2.terminal);
57490
57784
  }
@@ -57538,6 +57832,8 @@ var ClaudeSdkTransport = class {
57538
57832
  } catch (error52) {
57539
57833
  const active = this.#active;
57540
57834
  this.#closeInteractions("all", "cancelled");
57835
+ this.#rejectPendingSteers();
57836
+ this.#rootToolCalls.clear();
57541
57837
  this.#active = null;
57542
57838
  active?.reject(error52);
57543
57839
  if (!this.#closePromise)
@@ -58727,7 +59023,7 @@ function projectClaudePlanLimitToCredits(planLimit) {
58727
59023
  }
58728
59024
  var ClaudeHarnessSession = class {
58729
59025
  harnessId = claudeCodeHarnessId2;
58730
- capabilities = {
59026
+ capabilities = /* @__PURE__ */ ((session) => ({
58731
59027
  configuration: {
58732
59028
  selectModel: true,
58733
59029
  selectThinkingOption: true,
@@ -58735,11 +59031,16 @@ var ClaudeHarnessSession = class {
58735
59031
  permissionModeScope: "live"
58736
59032
  },
58737
59033
  history: { fork: true, forkAcrossCwd: false, rollbackLastTurn: true },
58738
- subagents: { observe: true, readTranscript: true }
58739
- };
59034
+ subagents: { observe: true, readTranscript: true },
59035
+ // Read live: native delivery joins this Turn only while a requested Turn runs a root tool call
59036
+ // on a CLI that confirms steers (`msg_lifecycle_v1`). Otherwise the Host stops and restarts.
59037
+ get steer() {
59038
+ return session.#transport?.canSteerActiveTurn?.() === true;
59039
+ }
59040
+ }))(this);
58740
59041
  commands;
58741
59042
  initialState;
58742
- initialUsage = null;
59043
+ initialUsage;
58743
59044
  outputs;
58744
59045
  #channel = new HarnessOutputChannel();
58745
59046
  #cancelTimeoutMs;
@@ -58778,7 +59079,10 @@ var ClaudeHarnessSession = class {
58778
59079
  #hardCancelTask = null;
58779
59080
  #usageGeneration = 0;
58780
59081
  #latestUsage = null;
59082
+ #lastAssistantResponseAtUnix;
59083
+ #accountCreditsSupported;
58781
59084
  #minimumContextUsedTokens = null;
59085
+ #latestRequestModel = null;
58782
59086
  #calibratedInputTokens = 0;
58783
59087
  #calibratedOutputTokens = 0;
58784
59088
  #calibratedCostUsd = 0;
@@ -58796,6 +59100,11 @@ var ClaudeHarnessSession = class {
58796
59100
  #continuationQuiescence = null;
58797
59101
  constructor(cwd, dependencies, closeTimeoutMs, onClosed, onPlanLimitObserved, options) {
58798
59102
  this.#cwd = cwd;
59103
+ this.#lastAssistantResponseAtUnix = options.usageHistory.lastResponseAtUnix;
59104
+ this.#accountCreditsSupported = options.accountCreditsSupported;
59105
+ const composerIndicators = claudePromptCacheIndicators(this.#accountCreditsSupported, this.#lastAssistantResponseAtUnix);
59106
+ this.initialUsage = composerIndicators.length ? { composerIndicators } : null;
59107
+ this.#latestUsage = this.initialUsage;
58799
59108
  this.#pendingSessions = options.pendingSessions;
58800
59109
  const environment = options.environment;
58801
59110
  this.#createTransport = environment ? (input) => dependencies.createTransport({ ...input, environment }) : dependencies.createTransport;
@@ -58950,6 +59259,8 @@ var ClaudeHarnessSession = class {
58950
59259
  }
58951
59260
  if (command.type === "turn.cancel")
58952
59261
  return this.#cancel(command);
59262
+ if (command.type === "turn.steer")
59263
+ return this.#steer(command);
58953
59264
  if (command.type === "interaction.respond")
58954
59265
  return this.#respond(command);
58955
59266
  if (command.type === "model.select")
@@ -59086,6 +59397,45 @@ var ClaudeHarnessSession = class {
59086
59397
  }
59087
59398
  return { ok: true, value: { turnId: command.turnId } };
59088
59399
  }
59400
+ async #steer(command) {
59401
+ if (!this.#active || this.#active.command.turnId !== command.turnId) {
59402
+ return { ok: false, error: invalidState("Claude Code steer target is not the active Turn") };
59403
+ }
59404
+ const text2 = command.input.map((input) => input.text).join("\n");
59405
+ if (text2.length === 0) {
59406
+ return {
59407
+ ok: false,
59408
+ error: {
59409
+ code: "invalidRequest",
59410
+ message: "Claude Code steer text must not be empty",
59411
+ retryable: false
59412
+ }
59413
+ };
59414
+ }
59415
+ const transport = this.#transport;
59416
+ if (!transport) {
59417
+ return { ok: false, error: invalidState("Claude Code steer missed the active Turn") };
59418
+ }
59419
+ if (transport.supportsNativeSteer?.() !== true) {
59420
+ return {
59421
+ ok: false,
59422
+ error: {
59423
+ code: "unsupported",
59424
+ message: "This Claude Code version does not confirm native steering",
59425
+ retryable: false
59426
+ }
59427
+ };
59428
+ }
59429
+ try {
59430
+ await transport.steer(text2, this.#randomUUID());
59431
+ } catch (error52) {
59432
+ if (error52 instanceof ClaudeSteerMissedTurnError) {
59433
+ return { ok: false, error: invalidState("Claude Code steer missed the active Turn") };
59434
+ }
59435
+ throw error52;
59436
+ }
59437
+ return { ok: true, value: { accepted: true } };
59438
+ }
59089
59439
  /** Built-ins plus the live commands and skills of the started native Session. */
59090
59440
  #liveCommandCatalog() {
59091
59441
  return claudeLiveCommandCatalog(claudeCommandCatalog, this.#transport?.slashCommands?.() ?? null);
@@ -59856,6 +60206,10 @@ var ClaudeHarnessSession = class {
59856
60206
  this.#completeReasoning(active, event.messageId, { status: "succeeded" });
59857
60207
  return;
59858
60208
  case "message.completed": {
60209
+ if (!event.localCommand) {
60210
+ this.#lastAssistantResponseAtUnix = Math.floor(Date.now() / 1e3);
60211
+ this.publishAccountCreditsSupport(this.#accountCreditsSupported);
60212
+ }
59859
60213
  this.#observeRootOutput(active);
59860
60214
  if (event.lastRequestUsage) {
59861
60215
  this.#requestUsageBoundary += 1;
@@ -59917,9 +60271,7 @@ var ClaudeHarnessSession = class {
59917
60271
  case "subagent.completed": {
59918
60272
  const subagent = active.subagents.complete(active.command.turnId, event, active.cancellationRequested);
59919
60273
  if (subagent.status === "running") {
59920
- if (subagent.nativeSubagentId) {
59921
- this.#occupancy.bind(event.callId, subagent.nativeSubagentId);
59922
- }
60274
+ this.#occupancy.occupySpawn(event.callId, subagent.nativeSubagentId);
59923
60275
  return;
59924
60276
  }
59925
60277
  this.#occupancy.release(event.callId, subagent.nativeSubagentId);
@@ -60478,6 +60830,8 @@ var ClaudeHarnessSession = class {
60478
60830
  const promptTokens = usage.inputTokens + usage.cacheCreationInputTokens + usage.cacheReadInputTokens;
60479
60831
  if (promptTokens > 0)
60480
60832
  this.#minimumContextUsedTokens = promptTokens;
60833
+ if (usage.model)
60834
+ this.#latestRequestModel = usage.model;
60481
60835
  const cacheHitRatePercent = claudeCacheHitRatePercent(usage);
60482
60836
  const contextWindowTokens = this.#latestUsage?.contextWindowTokens;
60483
60837
  this.#mergeAndPublishUsage({
@@ -60519,8 +60873,24 @@ var ClaudeHarnessSession = class {
60519
60873
  if (cacheHitRatePercent !== void 0)
60520
60874
  delta.cacheHitRatePercent = cacheHitRatePercent;
60521
60875
  }
60876
+ if (this.#latestUsage?.contextWindowTokens === void 0 && this.#minimumContextUsedTokens !== null) {
60877
+ const contextWindowTokens = this.#resultContextWindow(event.modelUsage);
60878
+ if (contextWindowTokens !== void 0) {
60879
+ delta.contextUsedTokens = this.#minimumContextUsedTokens;
60880
+ delta.contextWindowTokens = contextWindowTokens;
60881
+ }
60882
+ }
60522
60883
  this.#mergeAndPublishUsage(delta, active.command.turnId);
60523
60884
  }
60885
+ /** The latest request's Model, else the Model that carried the most prompt tokens. */
60886
+ #resultContextWindow(modelUsage) {
60887
+ if (!modelUsage?.length)
60888
+ return void 0;
60889
+ const latest = this.#latestRequestModel;
60890
+ const matched = latest ? modelUsage.find(({ model: model2 }) => model2 === latest) : void 0;
60891
+ const main = matched ?? modelUsage.reduce((best, entry) => (entry.promptTokens ?? entry.inputTokens) > (best.promptTokens ?? best.inputTokens) ? entry : best);
60892
+ return main.contextWindowTokens;
60893
+ }
60524
60894
  /**
60525
60895
  * Plan usage is account-wide, not Thread-scoped, so every observation is
60526
60896
  * offered to the Adapter's shared cache regardless of this Session's own
@@ -60533,6 +60903,15 @@ var ClaudeHarnessSession = class {
60533
60903
  if (effective)
60534
60904
  this.publishPlanLimit(effective);
60535
60905
  }
60906
+ publishAccountCreditsSupport(supported) {
60907
+ if (this.#phase !== "open")
60908
+ return;
60909
+ this.#accountCreditsSupported = supported;
60910
+ const composerIndicators = claudePromptCacheIndicators(supported, this.#lastAssistantResponseAtUnix);
60911
+ if (composerIndicators[0]?.expiresAtUnix === this.#latestUsage?.composerIndicators?.[0]?.expiresAtUnix)
60912
+ return;
60913
+ this.#mergeAndPublishUsage({ composerIndicators }, this.#active?.command.turnId);
60914
+ }
60536
60915
  publishPlanLimit(planLimit) {
60537
60916
  if (this.#phase !== "open")
60538
60917
  return;
@@ -60808,6 +61187,7 @@ var ClaudeCodeAdapter = class {
60808
61187
  #closePromise = null;
60809
61188
  #latestPlanLimit = null;
60810
61189
  #accountInspection = null;
61190
+ #accountCreditsSupported = false;
60811
61191
  constructor(options = {}, dependencies) {
60812
61192
  const environment = options.environment ?? process.env;
60813
61193
  this.#environment = environment;
@@ -60919,12 +61299,20 @@ var ClaudeCodeAdapter = class {
60919
61299
  return this.#accountInspection;
60920
61300
  }
60921
61301
  async #readAccount() {
61302
+ const planLimitAtStart = this.#latestPlanLimit;
60922
61303
  let inspector;
60923
61304
  try {
60924
61305
  this.#dependencies.inspectInstallation();
60925
61306
  inspector = this.#dependencies.createInspector({ cwd: process.cwd() });
60926
61307
  this.#inspectors.add(inspector);
60927
- return await inspector.inspectAccount?.() ?? null;
61308
+ const account = await inspector.inspectAccount?.() ?? null;
61309
+ if (this.#latestPlanLimit === planLimitAtStart) {
61310
+ this.#accountCreditsSupported = account?.credits !== void 0;
61311
+ for (const session of this.#sessions) {
61312
+ session.publishAccountCreditsSupport(this.#accountCreditsSupported);
61313
+ }
61314
+ }
61315
+ return account;
60928
61316
  } catch {
60929
61317
  return null;
60930
61318
  } finally {
@@ -61167,6 +61555,7 @@ var ClaudeCodeAdapter = class {
61167
61555
  ...durableRef ? { nativeRef: durableRef } : {},
61168
61556
  sessionId,
61169
61557
  usageHistory,
61558
+ accountCreditsSupported: this.#accountCreditsSupported,
61170
61559
  ...requestedModel ? { requestedModel } : {},
61171
61560
  requestedPermissionModeId,
61172
61561
  requestedThinkingOptionId,
@@ -61186,7 +61575,13 @@ var ClaudeCodeAdapter = class {
61186
61575
  return { requests: [], complete: true };
61187
61576
  try {
61188
61577
  const messages = await this.#dependencies.readSessionMessages({ cwd, sessionId });
61189
- return messages === null ? { requests: [], complete: false } : claudeUsageHistory(messages);
61578
+ if (messages === null)
61579
+ return { requests: [], complete: false };
61580
+ const lastResponseAtUnix = lastClaudeAssistantResponseUnix(messages);
61581
+ return {
61582
+ ...claudeUsageHistory(messages),
61583
+ ...lastResponseAtUnix !== void 0 ? { lastResponseAtUnix } : {}
61584
+ };
61190
61585
  } catch {
61191
61586
  return { requests: [], complete: false };
61192
61587
  }
@@ -61198,9 +61593,17 @@ var ClaudeCodeAdapter = class {
61198
61593
  next.fiveHour = planLimit.fiveHour;
61199
61594
  if (planLimit.sevenDay)
61200
61595
  next.sevenDay = planLimit.sevenDay;
61596
+ try {
61597
+ if (!accountCreditsSnapshotSchema.safeParse(projectClaudePlanLimitToCredits(next)).success)
61598
+ return null;
61599
+ } catch {
61600
+ return null;
61601
+ }
61201
61602
  this.#latestPlanLimit = next.fiveHour || next.sevenDay ? next : null;
61202
61603
  if (this.#latestPlanLimit) {
61604
+ this.#accountCreditsSupported = true;
61203
61605
  for (const session of this.#sessions) {
61606
+ session.publishAccountCreditsSupport(true);
61204
61607
  if (session !== origin)
61205
61608
  session.publishPlanLimit(this.#latestPlanLimit);
61206
61609
  }