@codexhost/cli-win32-arm64 0.13.1 → 0.13.3

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.
@@ -14604,6 +14604,15 @@ var harnessDisplaySetSchema = external_exports.strictObject({
14604
14604
  initializeOnly: external_exports.boolean().optional()
14605
14605
  });
14606
14606
 
14607
+ // ../../shared-contracts/dist/harness-presentation.js
14608
+ var localeSchema = external_exports.string().max(64).regex(/^[a-z]{2,3}(?:-[A-Za-z0-9]{2,8})*$/u);
14609
+ var displayText = (maximum) => external_exports.string().min(1).max(maximum).refine((text2) => text2.trim().length > 0);
14610
+ var harnessLocalizationsSchema = external_exports.record(localeSchema, external_exports.object({
14611
+ label: displayText(256).optional(),
14612
+ description: displayText(1024).optional()
14613
+ }).strict()).refine((entries) => Object.keys(entries).length <= 16, "Too many locales");
14614
+ var harnessLocalizedTextSchema = external_exports.record(localeSchema, displayText(4096)).refine((entries) => typeof entries.en === "string", "English fallback is required").refine((entries) => Object.keys(entries).length <= 16, "Too many locales");
14615
+
14607
14616
  // ../../shared-contracts/dist/model-price-overrides.js
14608
14617
  var usdPerMillionTokens = external_exports.number().finite().nonnegative();
14609
14618
  var modelPriceOverrideSchema = external_exports.strictObject({
@@ -14940,8 +14949,24 @@ var threadUsageSnapshotSchema = external_exports.object({
14940
14949
  }
14941
14950
  });
14942
14951
  var usagePercentSchema = external_exports.number().finite().min(0).max(100);
14952
+ var accountCreditsPeriodSchema = external_exports.enum([
14953
+ "weekly",
14954
+ "monthly",
14955
+ "five_hour",
14956
+ "seven_day",
14957
+ "unknown"
14958
+ ]);
14959
+ var accountCreditsScopeSchema = external_exports.object({
14960
+ id: external_exports.string().min(1).max(256),
14961
+ label: external_exports.string().min(1).max(256),
14962
+ localizations: harnessLocalizationsSchema.optional()
14963
+ }).strict();
14943
14964
  var accountCreditsProductUsageSchema = external_exports.object({
14944
14965
  product: external_exports.string().min(1),
14966
+ /** Native period and scope, never inferred from the display name. */
14967
+ periodType: accountCreditsPeriodSchema.optional(),
14968
+ scope: accountCreditsScopeSchema.optional(),
14969
+ localizations: harnessLocalizationsSchema.optional(),
14945
14970
  used: external_exports.number().finite().nonnegative().optional(),
14946
14971
  // Zero is a real empty cap, not an absent field.
14947
14972
  limit: external_exports.number().finite().nonnegative().optional(),
@@ -14961,9 +14986,11 @@ var accountCreditsSnapshotSchema = external_exports.object({
14961
14986
  unit: external_exports.string().min(1).max(32).optional(),
14962
14987
  /** Native label when the primary limit is scoped to a model or product group. */
14963
14988
  label: external_exports.string().min(1).optional(),
14989
+ scope: accountCreditsScopeSchema.optional(),
14990
+ localizations: harnessLocalizationsSchema.optional(),
14964
14991
  usedPercent: usagePercentSchema,
14965
14992
  resetsAt: external_exports.string().min(1).optional(),
14966
- periodType: external_exports.enum(["weekly", "monthly", "five_hour", "seven_day", "unknown"]),
14993
+ periodType: accountCreditsPeriodSchema,
14967
14994
  productUsage: external_exports.array(accountCreditsProductUsageSchema).min(1).optional(),
14968
14995
  resetCredits: accountResetCreditsSchema.optional()
14969
14996
  }).strict();
@@ -14974,7 +15001,9 @@ var threadUsageInspectionParamsSchema = external_exports.object({
14974
15001
  var threadUsageInspectionSchema = external_exports.object({
14975
15002
  threadId: hostThreadIdSchema,
14976
15003
  usage: threadUsageSnapshotSchema.nullable(),
14977
- accountCredits: accountCreditsSnapshotSchema.optional()
15004
+ accountCredits: accountCreditsSnapshotSchema.optional(),
15005
+ /** Whether this source can provide cached account quota independently of usage. */
15006
+ accountCreditsSupported: external_exports.boolean().optional()
14978
15007
  }).strict();
14979
15008
 
14980
15009
  // ../../shared-contracts/dist/harness-accounts.js
@@ -15101,7 +15130,8 @@ var harnessPermissionModeSchema = external_exports.object({
15101
15130
  id: harnessPermissionModeIdSchema,
15102
15131
  label: nonBlankTextSchema.max(HARNESS_PERMISSION_MODE_LABEL_MAX_LENGTH),
15103
15132
  description: nonBlankTextSchema.max(HARNESS_PERMISSION_MODE_DESCRIPTION_MAX_LENGTH).optional(),
15104
- dangerous: external_exports.boolean().optional()
15133
+ dangerous: external_exports.boolean().optional(),
15134
+ localizations: harnessLocalizationsSchema.optional()
15105
15135
  }).strict();
15106
15136
  var harnessPermissionModeCatalogSchema = external_exports.object({
15107
15137
  modes: external_exports.array(harnessPermissionModeSchema).min(1).max(HARNESS_PERMISSION_MODE_CATALOG_MAX_LENGTH),
@@ -15488,6 +15518,8 @@ var harnessInstallationStateSchema = external_exports.object({
15488
15518
  // Adapter-owned diagnostic text; UI uses messageCode rather than displaying it verbatim.
15489
15519
  message: external_exports.string().max(2048).optional(),
15490
15520
  messageCode: external_exports.string().min(1).max(128).optional(),
15521
+ /** Safe plugin-owned explanation, distinct from raw diagnostic message. */
15522
+ notice: harnessLocalizedTextSchema.optional(),
15491
15523
  latestVersionKind: external_exports.enum(["unknown", "tracking-branch"]).optional()
15492
15524
  }).strict();
15493
15525
 
@@ -15614,6 +15646,7 @@ var harnessCommandDescriptorSchema = external_exports.object({
15614
15646
  invocation: commandInvocationSchema,
15615
15647
  label: commandLabelSchema,
15616
15648
  description: commandDescriptionSchema.optional(),
15649
+ localizations: harnessLocalizationsSchema.optional(),
15617
15650
  argumentMode: external_exports.enum(["none", "text"]),
15618
15651
  /**
15619
15652
  * Native distinction reported by the Harness. Omitted when the Harness does
@@ -17160,6 +17193,8 @@ var BrokeredHarnessAdapter = class {
17160
17193
  commandCatalog;
17161
17194
  liveCommandCatalog;
17162
17195
  harnessId;
17196
+ credits;
17197
+ refreshCredits;
17163
17198
  #descriptorPath;
17164
17199
  #forwardEnvironment;
17165
17200
  #isInstalled;
@@ -17180,6 +17215,10 @@ var BrokeredHarnessAdapter = class {
17180
17215
  };
17181
17216
  constructor(input = {}) {
17182
17217
  this.harnessId = harnessPluginIdSchema.parse(input.harnessId ?? "claude-code");
17218
+ if (input.accountCredits !== false) {
17219
+ this.credits = () => this.#credits;
17220
+ this.refreshCredits = () => this.#refreshAccountCredits();
17221
+ }
17183
17222
  this.#forwardEnvironment = input.forwardDelegationEnvironment === true;
17184
17223
  if (input.commandCatalog)
17185
17224
  this.commandCatalog = input.commandCatalog;
@@ -17191,10 +17230,7 @@ var BrokeredHarnessAdapter = class {
17191
17230
  this.#startBroker = input.startBroker === false ? void 0 : input.startBroker ?? (process.platform === "darwin" && !input.descriptorPath ? () => startBrokerLaunchAgent(this.harnessId, environment) : void 0);
17192
17231
  this.#startTimeoutMs = input.startTimeoutMs ?? BROKER_START_TIMEOUT_MS;
17193
17232
  }
17194
- credits() {
17195
- return this.#credits;
17196
- }
17197
- refreshCredits() {
17233
+ #refreshAccountCredits() {
17198
17234
  if (this.#closed)
17199
17235
  return Promise.resolve(null);
17200
17236
  if (this.#creditsRefresh)
@@ -17613,7 +17649,7 @@ function createClaudeUsageStatistics(environment) {
17613
17649
  }
17614
17650
 
17615
17651
  // dist/claude-code-adapter.js
17616
- import { randomUUID as randomUUID4 } from "node:crypto";
17652
+ import { randomUUID as randomUUID5 } from "node:crypto";
17617
17653
  import path16 from "node:path";
17618
17654
 
17619
17655
  // ../../../node_modules/@anthropic-ai/claude-agent-sdk/sdk.mjs
@@ -55821,6 +55857,10 @@ async function forkClaudeSession(input) {
55821
55857
  return { ok: true, value: { sessionId: derivedSessionId } };
55822
55858
  }
55823
55859
 
55860
+ // dist/claude-fork-references.js
55861
+ import { randomUUID as randomUUID4 } from "node:crypto";
55862
+ import { readFile as readFile6, rename as rename4, rm as rm5, stat as stat5, writeFile as writeFile2 } from "node:fs/promises";
55863
+
55824
55864
  // dist/claude-transcript.js
55825
55865
  import os6 from "node:os";
55826
55866
  import path13 from "node:path";
@@ -55838,7 +55878,7 @@ async function existingFile(file2) {
55838
55878
  return false;
55839
55879
  }
55840
55880
  }
55841
- async function findTranscript(input) {
55881
+ async function findClaudeTranscript(input) {
55842
55882
  const projectsDirectory = path13.join(configDirectory(input.environment), "projects");
55843
55883
  const name = `${input.sessionId}.jsonl`;
55844
55884
  const expected = path13.join(projectsDirectory, projectDirectoryName(input.cwd), name);
@@ -55861,7 +55901,7 @@ function isRecord9(value) {
55861
55901
  return typeof value === "object" && value !== null && !Array.isArray(value);
55862
55902
  }
55863
55903
  async function readClaudeTranscript(input) {
55864
- const transcript = await findTranscript(input);
55904
+ const transcript = await findClaudeTranscript(input);
55865
55905
  if (!transcript)
55866
55906
  return null;
55867
55907
  const contents = await readFile5(transcript, "utf8");
@@ -55883,9 +55923,83 @@ async function readClaudeTranscript(input) {
55883
55923
  return [...messages.values()];
55884
55924
  }
55885
55925
 
55926
+ // dist/claude-fork-references.js
55927
+ function isRecord10(value) {
55928
+ return typeof value === "object" && value !== null && !Array.isArray(value);
55929
+ }
55930
+ function parseEntry(line) {
55931
+ if (line.trim().length === 0)
55932
+ return null;
55933
+ try {
55934
+ const entry = JSON.parse(line);
55935
+ return isRecord10(entry) ? entry : null;
55936
+ } catch {
55937
+ return null;
55938
+ }
55939
+ }
55940
+ function remapSameAs(value, copies) {
55941
+ if (Array.isArray(value)) {
55942
+ return value.reduce((count4, item) => count4 + remapSameAs(item, copies), 0);
55943
+ }
55944
+ if (!isRecord10(value))
55945
+ return 0;
55946
+ let count3 = 0;
55947
+ for (const [key, child] of Object.entries(value)) {
55948
+ const copy = key === "sameAs" && typeof child === "string" ? copies.get(child) : void 0;
55949
+ if (copy) {
55950
+ value[key] = copy;
55951
+ count3 += 1;
55952
+ } else {
55953
+ count3 += remapSameAs(child, copies);
55954
+ }
55955
+ }
55956
+ return count3;
55957
+ }
55958
+ async function remapForkedSessionReferences(input) {
55959
+ const transcript = await findClaudeTranscript(input);
55960
+ if (!transcript)
55961
+ return 0;
55962
+ const contents = await readFile6(transcript, "utf8");
55963
+ if (!contents.includes('"sameAs"'))
55964
+ return 0;
55965
+ const lines = contents.split("\n");
55966
+ const entries = lines.map(parseEntry);
55967
+ const copies = /* @__PURE__ */ new Map();
55968
+ for (const entry of entries) {
55969
+ const source = entry?.forkedFrom;
55970
+ if (typeof entry?.uuid === "string" && isRecord10(source) && typeof source.messageUuid === "string") {
55971
+ copies.set(source.messageUuid, entry.uuid);
55972
+ }
55973
+ }
55974
+ let remapped = 0;
55975
+ const output = lines.map((line, index) => {
55976
+ const entry = entries[index];
55977
+ if (entry?.type !== "attachment")
55978
+ return line;
55979
+ const count3 = remapSameAs(entry.attachment, copies);
55980
+ if (count3 === 0)
55981
+ return line;
55982
+ remapped += count3;
55983
+ return JSON.stringify(entry);
55984
+ });
55985
+ if (remapped === 0)
55986
+ return 0;
55987
+ const temporary = `${transcript}.${randomUUID4()}.tmp`;
55988
+ try {
55989
+ await writeFile2(temporary, output.join("\n"), {
55990
+ flag: "wx",
55991
+ mode: (await stat5(transcript)).mode & 511
55992
+ });
55993
+ await rename4(temporary, transcript);
55994
+ } finally {
55995
+ await rm5(temporary, { force: true });
55996
+ }
55997
+ return remapped;
55998
+ }
55999
+
55886
56000
  // dist/model-catalog.js
55887
56001
  import { Buffer as Buffer2 } from "node:buffer";
55888
- import { readFile as readFile6 } from "node:fs/promises";
56002
+ import { readFile as readFile7 } from "node:fs/promises";
55889
56003
  import os7 from "node:os";
55890
56004
  import path14 from "node:path";
55891
56005
 
@@ -56025,7 +56139,7 @@ async function readClaudeUserModelPicker(environment = process.env) {
56025
56139
  const settingsPath = path14.join(resolveClaudeConfigDirectory(environment), "settings.json");
56026
56140
  let raw;
56027
56141
  try {
56028
- raw = await readFile6(settingsPath, "utf8");
56142
+ raw = await readFile7(settingsPath, "utf8");
56029
56143
  } catch {
56030
56144
  return void 0;
56031
56145
  }
@@ -56184,26 +56298,38 @@ var claudePermissionModes = [
56184
56298
  {
56185
56299
  id: "plan",
56186
56300
  label: "Plan mode",
56301
+ localizations: {
56302
+ "zh-CN": {
56303
+ label: "规划模式",
56304
+ description: "探索并制定计划;批准计划后退出规划,恢复此前的权限模式。"
56305
+ }
56306
+ },
56187
56307
  description: "Explore and prepare a plan; approval exits planning and resumes the previous permission mode."
56188
56308
  },
56189
56309
  {
56190
56310
  id: "default",
56191
56311
  label: "Default",
56312
+ localizations: { "zh-CN": { label: "默认", description: "编辑和其他受保护操作前询问。" } },
56192
56313
  description: "Ask before edits and other protected actions."
56193
56314
  },
56194
56315
  {
56195
56316
  id: "acceptEdits",
56196
56317
  label: "Accept edits",
56318
+ localizations: {
56319
+ "zh-CN": { label: "接受编辑", description: "允许文件编辑;其他受保护操作前询问。" }
56320
+ },
56197
56321
  description: "Allow file edits and ask for other protected actions."
56198
56322
  },
56199
56323
  {
56200
56324
  id: "auto",
56201
56325
  label: "Auto mode",
56326
+ localizations: { "zh-CN": { label: "自动模式", description: "由 Claude 判断权限请求。" } },
56202
56327
  description: "Let Claude classify permission requests."
56203
56328
  },
56204
56329
  {
56205
56330
  id: "bypassPermissions",
56206
56331
  label: "Bypass permissions",
56332
+ localizations: { "zh-CN": { label: "绕过权限", description: "跳过 Claude Code 权限检查。" } },
56207
56333
  description: "Skip Claude Code permission checks.",
56208
56334
  dangerous: true
56209
56335
  }
@@ -56310,23 +56436,24 @@ function projectClaudeAccountUsage(usage, account) {
56310
56436
  return null;
56311
56437
  const limits = usage.rate_limits;
56312
56438
  const windows = [];
56313
- const add = (product, periodType, value) => {
56439
+ const add = (product, periodType, value, scope) => {
56314
56440
  if (!value || typeof value.utilization !== "number" || !Number.isFinite(value.utilization) || value.utilization < 0 || value.utilization > 100)
56315
56441
  return;
56316
56442
  windows.push({
56317
56443
  product,
56318
56444
  periodType,
56445
+ ...scope ? { scope: { id: scope, label: scope } } : {},
56319
56446
  usagePercent: value.utilization,
56320
56447
  ...value.resets_at && Number.isFinite(Date.parse(value.resets_at)) ? { resetsAt: value.resets_at } : {}
56321
56448
  });
56322
56449
  };
56323
56450
  add("5-hour window", "five_hour", limits.five_hour);
56324
56451
  add("7-day window", "seven_day", limits.seven_day);
56325
- add("OAuth apps · 7-day", "seven_day", limits.seven_day_oauth_apps);
56326
- add("Opus · 7-day", "seven_day", limits.seven_day_opus);
56327
- add("Sonnet · 7-day", "seven_day", limits.seven_day_sonnet);
56452
+ add("OAuth apps · 7-day", "seven_day", limits.seven_day_oauth_apps, "OAuth apps");
56453
+ add("Opus · 7-day", "seven_day", limits.seven_day_opus, "Opus");
56454
+ add("Sonnet · 7-day", "seven_day", limits.seven_day_sonnet, "Sonnet");
56328
56455
  for (const window2 of limits.model_scoped ?? [])
56329
- add(`${window2.display_name} · 7-day`, "seven_day", window2);
56456
+ add(`${window2.display_name} · 7-day`, "seven_day", window2, window2.display_name);
56330
56457
  const [primary, ...others] = windows;
56331
56458
  if (!primary)
56332
56459
  return null;
@@ -56337,11 +56464,14 @@ function projectClaudeAccountUsage(usage, account) {
56337
56464
  credits: {
56338
56465
  usedPercent: primary.usagePercent,
56339
56466
  periodType: primary.periodType,
56467
+ ...primary.scope ? { scope: primary.scope } : {},
56340
56468
  ...!genericPrimary ? { label: primary.product } : {},
56341
56469
  ...primary.resetsAt ? { resetsAt: primary.resetsAt } : {},
56342
56470
  ...others.length ? {
56343
- productUsage: others.map(({ product, usagePercent, resetsAt }) => ({
56471
+ productUsage: others.map(({ product, periodType, scope, usagePercent, resetsAt }) => ({
56344
56472
  product,
56473
+ periodType,
56474
+ ...scope ? { scope } : {},
56345
56475
  usagePercent,
56346
56476
  ...resetsAt ? { resetsAt } : {}
56347
56477
  }))
@@ -56463,17 +56593,17 @@ function rejectAfter(milliseconds, message) {
56463
56593
  function processExited(child) {
56464
56594
  return child.exitCode !== null || child.signalCode !== null;
56465
56595
  }
56466
- function isRecord10(value) {
56596
+ function isRecord11(value) {
56467
56597
  return typeof value === "object" && value !== null && !Array.isArray(value);
56468
56598
  }
56469
56599
  function permissionModeFromMessage(value) {
56470
- if (!isRecord10(value) || value.type !== "system" || value.subtype !== "init" && value.subtype !== "status" || !("permissionMode" in value) || value.permissionMode === void 0) {
56600
+ if (!isRecord11(value) || value.type !== "system" || value.subtype !== "init" && value.subtype !== "status" || !("permissionMode" in value) || value.permissionMode === void 0) {
56471
56601
  return void 0;
56472
56602
  }
56473
56603
  return isClaudePermissionMode(value.permissionMode) ? value.permissionMode : void 0;
56474
56604
  }
56475
56605
  function parseContextUsage(value) {
56476
- if (!isRecord10(value))
56606
+ if (!isRecord11(value))
56477
56607
  throw new Error("Claude SDK context Usage is invalid");
56478
56608
  const usedTokens = value.totalTokens;
56479
56609
  const maxTokens = value.maxTokens;
@@ -56490,7 +56620,7 @@ function parseQuestions(input) {
56490
56620
  const questions = [];
56491
56621
  const questionTexts = /* @__PURE__ */ new Set();
56492
56622
  for (const value of input.questions) {
56493
- if (!isRecord10(value))
56623
+ if (!isRecord11(value))
56494
56624
  return null;
56495
56625
  const question = value.question;
56496
56626
  const header = value.header;
@@ -56501,7 +56631,7 @@ function parseQuestions(input) {
56501
56631
  const labels = /* @__PURE__ */ new Set();
56502
56632
  const options = [];
56503
56633
  for (const option2 of value.options) {
56504
- if (!isRecord10(option2) || typeof option2.label !== "string" || option2.label.length === 0 || labels.has(option2.label) || typeof option2.description !== "string") {
56634
+ if (!isRecord11(option2) || typeof option2.label !== "string" || option2.label.length === 0 || labels.has(option2.label) || typeof option2.description !== "string") {
56505
56635
  return null;
56506
56636
  }
56507
56637
  labels.add(option2.label);
@@ -56543,7 +56673,7 @@ function permissionUpdateDestination(value) {
56543
56673
  return void 0;
56544
56674
  }
56545
56675
  function isPermissionUpdate(value) {
56546
- if (!isRecord10(value) || !permissionUpdateDestination(value.destination))
56676
+ if (!isRecord11(value) || !permissionUpdateDestination(value.destination))
56547
56677
  return false;
56548
56678
  if (value.type === "setMode") {
56549
56679
  return typeof value.mode === "string" && PERMISSION_MODES.has(value.mode);
@@ -56552,7 +56682,7 @@ function isPermissionUpdate(value) {
56552
56682
  return Array.isArray(value.directories) && value.directories.every((directory) => typeof directory === "string");
56553
56683
  }
56554
56684
  if (value.type === "addRules" || value.type === "replaceRules" || value.type === "removeRules") {
56555
- return typeof value.behavior === "string" && PERMISSION_BEHAVIORS.has(value.behavior) && Array.isArray(value.rules) && value.rules.every((rule) => isRecord10(rule) && typeof rule.toolName === "string" && (rule.ruleContent === void 0 || typeof rule.ruleContent === "string"));
56685
+ return typeof value.behavior === "string" && PERMISSION_BEHAVIORS.has(value.behavior) && Array.isArray(value.rules) && value.rules.every((rule) => isRecord11(rule) && typeof rule.toolName === "string" && (rule.ruleContent === void 0 || typeof rule.ruleContent === "string"));
56556
56686
  }
56557
56687
  return false;
56558
56688
  }
@@ -56779,7 +56909,7 @@ var ClaudeSdkTransport = class {
56779
56909
  return { commands: this.#slashCommands, skillNames: this.#skillNames };
56780
56910
  }
56781
56911
  #observeSlashCommands(message) {
56782
- if (!isRecord10(message) || message.type !== "system")
56912
+ if (!isRecord11(message) || message.type !== "system")
56783
56913
  return;
56784
56914
  if (message.subtype === "init" && Array.isArray(message.skills)) {
56785
56915
  this.#skillNames = new Set(message.skills.filter((name) => typeof name === "string"));
@@ -57198,10 +57328,10 @@ var ClaudeSdkTransport = class {
57198
57328
  }
57199
57329
  }
57200
57330
  #observeBackgroundTasks(message) {
57201
- if (!isRecord10(message) || message.type !== "system")
57331
+ if (!isRecord11(message) || message.type !== "system")
57202
57332
  return;
57203
57333
  if (message.subtype === "background_tasks_changed" && Array.isArray(message.tasks)) {
57204
- this.#backgroundTasks = new Set(message.tasks.flatMap((task) => isRecord10(task) && typeof task.task_id === "string" ? [task.task_id] : []));
57334
+ this.#backgroundTasks = new Set(message.tasks.flatMap((task) => isRecord11(task) && typeof task.task_id === "string" ? [task.task_id] : []));
57205
57335
  } else if (message.subtype === "task_started" && typeof message.task_id === "string") {
57206
57336
  this.#backgroundTasks.add(message.task_id);
57207
57337
  } else if (message.subtype === "task_notification" && typeof message.task_id === "string" && ["completed", "failed", "stopped"].includes(String(message.status))) {
@@ -57211,13 +57341,13 @@ var ClaudeSdkTransport = class {
57211
57341
  /** Starts the Segment's autonomous Turn and releases the events it held, in native order. */
57212
57342
  #startAutonomousTurn(autonomous, handler) {
57213
57343
  autonomous.live = true;
57214
- handler.start(autonomous.nativeTurnKey ?? `autonomous-${Date.now()}`);
57344
+ handler.start(autonomous.userMessageId ?? `autonomous-${Date.now()}`, autonomous.userMessageId);
57215
57345
  for (const event of autonomous.events.splice(0))
57216
57346
  handler.onEvent(event);
57217
57347
  }
57218
57348
  /** Remembers Workflow agent labels so their approvals can name the agent asking. */
57219
57349
  #observeWorkflowAgents(message) {
57220
- if (!isRecord10(message) || message.type !== "system" || message.subtype !== "task_progress") {
57350
+ if (!isRecord11(message) || message.type !== "system" || message.subtype !== "task_progress") {
57221
57351
  return;
57222
57352
  }
57223
57353
  for (const agent of parseClaudeWorkflowAgents(message.workflow_progress) ?? []) {
@@ -57275,11 +57405,11 @@ var ClaudeSdkTransport = class {
57275
57405
  const autonomous = this.#autonomous ?? (this.#autonomous = {
57276
57406
  accumulator: new ClaudeNativeTurnAccumulator(this.#provider ? { provider: this.#provider } : {}),
57277
57407
  events: [],
57278
- nativeTurnKey: null,
57408
+ userMessageId: null,
57279
57409
  live: false
57280
57410
  });
57281
- if (autonomous.nativeTurnKey === null && isRecord10(message) && message.type === "user" && (message.parent_tool_use_id === null || message.parent_tool_use_id === void 0) && typeof message.uuid === "string" && message.uuid.length > 0) {
57282
- autonomous.nativeTurnKey = message.uuid;
57411
+ if (autonomous.userMessageId === null && isRecord11(message) && message.type === "user" && (message.parent_tool_use_id === null || message.parent_tool_use_id === void 0) && typeof message.uuid === "string" && message.uuid.length > 0) {
57412
+ autonomous.userMessageId = message.uuid;
57283
57413
  }
57284
57414
  const interpreted = autonomous.accumulator.consume(message);
57285
57415
  for (const event of interpreted.events) {
@@ -57806,11 +57936,11 @@ var ClaudeWorkflowLifecycle = class {
57806
57936
  };
57807
57937
 
57808
57938
  // dist/task-tracker.js
57809
- function isRecord11(value) {
57939
+ function isRecord12(value) {
57810
57940
  return typeof value === "object" && value !== null && !Array.isArray(value);
57811
57941
  }
57812
57942
  function stringField(value, keys) {
57813
- if (!isRecord11(value))
57943
+ if (!isRecord12(value))
57814
57944
  return void 0;
57815
57945
  for (const key of keys) {
57816
57946
  const field = value[key];
@@ -57845,7 +57975,7 @@ var ClaudeTaskTracker = class {
57845
57975
  };
57846
57976
  }
57847
57977
  #create(args, result) {
57848
- if (!isRecord11(result) || !isRecord11(result.task))
57978
+ if (!isRecord12(result) || !isRecord12(result.task))
57849
57979
  return;
57850
57980
  const id2 = stringField(result.task, ["id"]);
57851
57981
  const subject = stringField(args, ["subject"]) ?? stringField(result.task, ["subject"]);
@@ -57863,7 +57993,7 @@ var ClaudeTaskTracker = class {
57863
57993
  const id2 = stringField(args, ["taskId", "id", "task_id"]);
57864
57994
  if (!id2)
57865
57995
  return;
57866
- const status = isRecord11(args) ? taskStatus2(args.status) : void 0;
57996
+ const status = isRecord12(args) ? taskStatus2(args.status) : void 0;
57867
57997
  if (status === "deleted") {
57868
57998
  this.#tasks.delete(id2);
57869
57999
  return;
@@ -57881,13 +58011,13 @@ var ClaudeTaskTracker = class {
57881
58011
  });
57882
58012
  }
57883
58013
  #replace(result) {
57884
- if (!isRecord11(result) || !Array.isArray(result.tasks))
58014
+ if (!isRecord12(result) || !Array.isArray(result.tasks))
57885
58015
  return;
57886
58016
  const next = /* @__PURE__ */ new Map();
57887
58017
  for (const value of result.tasks) {
57888
58018
  const id2 = stringField(value, ["id"]);
57889
58019
  const subject = stringField(value, ["subject"]);
57890
- const status = isRecord11(value) ? taskStatus2(value.status) : void 0;
58020
+ const status = isRecord12(value) ? taskStatus2(value.status) : void 0;
57891
58021
  if (!id2 || !subject || !status || status === "deleted")
57892
58022
  continue;
57893
58023
  const existing = this.#tasks.get(id2);
@@ -58054,11 +58184,11 @@ var ClaudeBackgroundCommandItems = class {
58054
58184
  };
58055
58185
 
58056
58186
  // dist/tool-lifecycle.js
58057
- function isRecord12(value) {
58187
+ function isRecord13(value) {
58058
58188
  return typeof value === "object" && value !== null && !Array.isArray(value);
58059
58189
  }
58060
58190
  function stringField2(value, key) {
58061
- return isRecord12(value) && typeof value[key] === "string" ? value[key] : void 0;
58191
+ return isRecord13(value) && typeof value[key] === "string" ? value[key] : void 0;
58062
58192
  }
58063
58193
  function toolFailure(toolName) {
58064
58194
  return {
@@ -58248,6 +58378,7 @@ var claudeCommandCatalog = harnessCommandCatalogSchema.parse({
58248
58378
  {
58249
58379
  id: "claude.compact",
58250
58380
  invocation: "/compact",
58381
+ localizations: { "zh-CN": { label: "压缩上下文", description: "压缩当前对话上下文" } },
58251
58382
  label: "Compact context",
58252
58383
  description: "Compact the current conversation context",
58253
58384
  argumentMode: "text"
@@ -58324,7 +58455,7 @@ var CONTEXT_USAGE_TTL_MS = 1e4;
58324
58455
  var CONTEXT_USAGE_FAILURE_COOLDOWN_MS = 5e3;
58325
58456
  var REQUEST_USAGE_RETRY_DELAYS_MS = [0, 100, 250, 500, 1e3];
58326
58457
  var DEFAULT_CONTINUATION_QUIESCENCE_MS = 2e3;
58327
- function isRecord13(value) {
58458
+ function isRecord14(value) {
58328
58459
  return typeof value === "object" && value !== null && !Array.isArray(value);
58329
58460
  }
58330
58461
  function safeNonNegativeInteger2(value) {
@@ -58333,7 +58464,7 @@ function safeNonNegativeInteger2(value) {
58333
58464
  function transcriptRequestUsage(messages, messageId) {
58334
58465
  for (let index = messages.length - 1; index >= 0; index -= 1) {
58335
58466
  const entry = messages[index];
58336
- if (!isRecord13(entry) || entry.type !== "assistant" || entry.parent_tool_use_id !== null && entry.parent_tool_use_id !== void 0 || !isRecord13(entry.message) || entry.message.id !== messageId || !isRecord13(entry.message.usage)) {
58467
+ if (!isRecord14(entry) || entry.type !== "assistant" || entry.parent_tool_use_id !== null && entry.parent_tool_use_id !== void 0 || !isRecord14(entry.message) || entry.message.id !== messageId || !isRecord14(entry.message.usage)) {
58337
58468
  continue;
58338
58469
  }
58339
58470
  const inputTokens = entry.message.usage.input_tokens;
@@ -58481,6 +58612,7 @@ function projectClaudePlanLimitToCredits(planLimit) {
58481
58612
  productUsage: [
58482
58613
  {
58483
58614
  product: "7-day window",
58615
+ periodType: "seven_day",
58484
58616
  usagePercent: other.utilizationPercent,
58485
58617
  ...other.resetsAtUnix !== void 0 ? { resetsAt: isoFromUnix(other.resetsAtUnix) } : {}
58486
58618
  }
@@ -58635,7 +58767,7 @@ var ClaudeHarnessSession = class {
58635
58767
  cwd: this.#cwd,
58636
58768
  sessionId: this.#sessionId
58637
58769
  }) ?? [];
58638
- const ids = new Set(messages.flatMap((message) => isRecord13(message) && typeof message.uuid === "string" ? [message.uuid] : []));
58770
+ const ids = new Set(messages.flatMap((message) => isRecord14(message) && typeof message.uuid === "string" ? [message.uuid] : []));
58639
58771
  if (this.#unpersistedMessageIds.every((id2) => ids.has(id2))) {
58640
58772
  this.#unpersistedMessageIds = [];
58641
58773
  break;
@@ -58810,6 +58942,7 @@ var ClaudeHarnessSession = class {
58810
58942
  interactionByRequestId: /* @__PURE__ */ new Map(),
58811
58943
  agentScopedRequestIds: /* @__PURE__ */ new Set(),
58812
58944
  checkpointId: null,
58945
+ userMessageId: null,
58813
58946
  nativeTurnKey,
58814
58947
  nativeTurnRef: null,
58815
58948
  cancellationRequested: false,
@@ -58840,6 +58973,7 @@ var ClaudeHarnessSession = class {
58840
58973
  const running = transport.runTurn(text2, nativeTurnRef.nativeTurnKey, (event) => {
58841
58974
  this.#handleTurnEvent(active, event);
58842
58975
  });
58976
+ active.userMessageId = nativeTurnRef.nativeTurnKey;
58843
58977
  active.nativeTurnRef = nativeTurnRef;
58844
58978
  void running.then((result) => this.#finishResult(active, result), () => this.#handleTurnTransportFailure(active));
58845
58979
  } catch {
@@ -58939,6 +59073,7 @@ var ClaudeHarnessSession = class {
58939
59073
  interactionByRequestId: /* @__PURE__ */ new Map(),
58940
59074
  agentScopedRequestIds: /* @__PURE__ */ new Set(),
58941
59075
  checkpointId: null,
59076
+ userMessageId: null,
58942
59077
  nativeTurnKey,
58943
59078
  nativeTurnRef: null,
58944
59079
  cancellationRequested: false,
@@ -59483,8 +59618,8 @@ var ClaudeHarnessSession = class {
59483
59618
  });
59484
59619
  this.#transport = transport;
59485
59620
  transport.setAutonomousTurnHandler({
59486
- start: (nativeTurnKey) => {
59487
- this.#autonomousTarget = this.#startAutonomousTurn(nativeTurnKey);
59621
+ start: (nativeTurnKey, userMessageId) => {
59622
+ this.#autonomousTarget = this.#startAutonomousTurn(nativeTurnKey, userMessageId);
59488
59623
  },
59489
59624
  onEvent: (event) => this.#deliverLiveEvent(this.#autonomousTarget, event),
59490
59625
  onTerminal: (result) => {
@@ -59966,7 +60101,7 @@ var ClaudeHarnessSession = class {
59966
60101
  * it; otherwise it becomes a live autonomous Turn, so the Thread shows it running and a new
59967
60102
  * request waits instead of absorbing it.
59968
60103
  */
59969
- #startAutonomousTurn(segmentKey) {
60104
+ #startAutonomousTurn(segmentKey, userMessageId) {
59970
60105
  if (this.#phase !== "open")
59971
60106
  return null;
59972
60107
  const current = this.#active;
@@ -60016,6 +60151,7 @@ var ClaudeHarnessSession = class {
60016
60151
  interactionByRequestId: /* @__PURE__ */ new Map(),
60017
60152
  agentScopedRequestIds: /* @__PURE__ */ new Set(),
60018
60153
  checkpointId: null,
60154
+ userMessageId,
60019
60155
  nativeTurnKey,
60020
60156
  nativeTurnRef: nativeTurnRefSchema.parse({
60021
60157
  harnessId: this.harnessId,
@@ -60410,12 +60546,15 @@ var ClaudeHarnessSession = class {
60410
60546
  checkpointId: active.checkpointId,
60411
60547
  formatVersion: 1
60412
60548
  }) : null;
60413
- this.#unpersistedMessageIds = [
60414
- .../* @__PURE__ */ new Set([
60415
- ...active.nativeTurnRef ? [active.nativeTurnRef.nativeTurnKey] : [],
60416
- ...active.checkpointId ? [active.checkpointId] : []
60417
- ])
60418
- ];
60549
+ if (active.userMessageId || active.checkpointId) {
60550
+ this.#unpersistedMessageIds = [
60551
+ .../* @__PURE__ */ new Set([
60552
+ ...this.#unpersistedMessageIds,
60553
+ ...active.userMessageId ? [active.userMessageId] : [],
60554
+ ...active.checkpointId ? [active.checkpointId] : []
60555
+ ])
60556
+ ];
60557
+ }
60419
60558
  this.#event({
60420
60559
  type: "turn.completed",
60421
60560
  turnId: active.command.turnId,
@@ -60547,6 +60686,7 @@ var ClaudeCodeAdapter = class {
60547
60686
  #cancelTimeoutMs;
60548
60687
  #closeTimeoutMs;
60549
60688
  #dependencies;
60689
+ #environment;
60550
60690
  #importIndex;
60551
60691
  #importScope = new SessionImportScope({
60552
60692
  closedMessage: "Claude Code Adapter is closed",
@@ -60565,6 +60705,7 @@ var ClaudeCodeAdapter = class {
60565
60705
  #accountInspection = null;
60566
60706
  constructor(options = {}, dependencies) {
60567
60707
  const environment = options.environment ?? process.env;
60708
+ this.#environment = environment;
60568
60709
  this.#importIndex = new ClaudeSessionImportIndex(environment);
60569
60710
  this.usageStatistics = createClaudeUsageStatistics(environment);
60570
60711
  this.#pendingSessions = new ClaudePendingSessions(environment);
@@ -60582,7 +60723,7 @@ var ClaudeCodeAdapter = class {
60582
60723
  throw new RangeError("Claude Code continuation quiescence must be a positive safe integer");
60583
60724
  }
60584
60725
  this.#dependencies = dependencies ?? {
60585
- randomUUID: randomUUID4,
60726
+ randomUUID: randomUUID5,
60586
60727
  bypassPermissionsAvailable: (environment2) => claudeBypassPermissionsAvailable(environment2 ?? options.environment ?? process.env),
60587
60728
  inspectInstallation: () => {
60588
60729
  resolveClaudeCodeExecutable({
@@ -60604,7 +60745,18 @@ var ClaudeCodeAdapter = class {
60604
60745
  abortTimeoutMs: this.#cancelTimeoutMs
60605
60746
  }),
60606
60747
  deleteSession: ({ cwd, sessionId }) => M5t(sessionId, { dir: cwd }),
60607
- forkSession: ({ checkpointId, cwd, sourceSessionId }) => U5t(sourceSessionId, { dir: cwd, upToMessageId: checkpointId }),
60748
+ forkSession: async ({ checkpointId, cwd, sourceSessionId }) => {
60749
+ const forked = await U5t(sourceSessionId, {
60750
+ dir: cwd,
60751
+ upToMessageId: checkpointId
60752
+ });
60753
+ await remapForkedSessionReferences({
60754
+ cwd,
60755
+ environment: options.environment ?? process.env,
60756
+ sessionId: forked.sessionId
60757
+ }).catch(() => void 0);
60758
+ return forked;
60759
+ },
60608
60760
  getSessionInfo: async ({ sessionId }) => {
60609
60761
  const info = await D5t(sessionId);
60610
60762
  if (!info)
@@ -60810,7 +60962,8 @@ var ClaudeCodeAdapter = class {
60810
60962
  }
60811
60963
  };
60812
60964
  }
60813
- const bypassPermissionsAvailable = this.#dependencies.bypassPermissionsAvailable(input.environment);
60965
+ const environment = input.environment ? { ...this.#environment, ...input.environment } : void 0;
60966
+ const bypassPermissionsAvailable = this.#dependencies.bypassPermissionsAvailable(environment);
60814
60967
  if (!bypassPermissionsAvailable && requestedPermissionModeId === "bypassPermissions") {
60815
60968
  if (input.kind === "create") {
60816
60969
  return {
@@ -60901,7 +61054,7 @@ var ClaudeCodeAdapter = class {
60901
61054
  const sessionId = forked?.ok ? forked.value.sessionId : nativeRef?.success ? nativeRef.data.nativeSessionId : this.#dependencies.randomUUID();
60902
61055
  const usageHistory = await this.#readUsageHistory(cwd, sessionId, openMode);
60903
61056
  const session = new ClaudeHarnessSession(cwd, this.#dependencies, this.#closeTimeoutMs, () => this.#sessions.delete(session), (planLimit) => this.#recordPlanLimit(session, planLimit), {
60904
- ...input.environment ? { environment: input.environment } : {},
61057
+ ...environment ? { environment } : {},
60905
61058
  bypassPermissionsAvailable,
60906
61059
  openMode,
60907
61060
  pendingSessions: this.#pendingSessions,
@@ -60967,11 +61120,11 @@ var ClaudeCodeAdapter = class {
60967
61120
  };
60968
61121
 
60969
61122
  // dist/installation.js
60970
- import { readFile as readFile7, realpath as realpath5 } from "node:fs/promises";
61123
+ import { readFile as readFile8, realpath as realpath5 } from "node:fs/promises";
60971
61124
  import { homedir as homedir2 } from "node:os";
60972
61125
  import path17 from "node:path";
60973
61126
  async function readSettings(file2) {
60974
- const text2 = await readFile7(file2, "utf8").catch((error52) => {
61127
+ const text2 = await readFile8(file2, "utf8").catch((error52) => {
60975
61128
  if (error52.code === "ENOENT")
60976
61129
  return "{}";
60977
61130
  throw error52;
@@ -61022,6 +61175,12 @@ function createClaudeInstallation(environment, command) {
61022
61175
  canUpdate,
61023
61176
  ...!canUpdate ? {
61024
61177
  messageCode: blocked ? "claude-policy-restricted" : "original-installer",
61178
+ ...blocked ? {
61179
+ notice: {
61180
+ en: "Claude updates are restricted by the installation's settings or policy.",
61181
+ "zh-CN": "此 Claude 安装的设置或策略限制了更新。"
61182
+ }
61183
+ } : {},
61025
61184
  message: blocked ? "Claude updates are restricted by the installation's settings or policy." : "Use the original installer or package manager for this Claude installation."
61026
61185
  } : {}
61027
61186
  };
@@ -61114,6 +61273,7 @@ async function createHarnessAdapter(context) {
61114
61273
  const environment = await withUserShellEnvironment({ ...context.environment });
61115
61274
  if (context.platform === "darwin" && context.managedRemoteHost) {
61116
61275
  return new BrokeredHarnessAdapter({
61276
+ forwardDelegationEnvironment: true,
61117
61277
  commandCatalog: claudeCommandCatalog,
61118
61278
  liveCommandCatalog: true,
61119
61279
  environment,