@chinhae/codex-connect-linux-arm64 0.11.0 → 0.12.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.
@@ -776,10 +776,10 @@ function mergeDefs(...defs) {
776
776
  function cloneDef(schema) {
777
777
  return mergeDefs(schema._zod.def);
778
778
  }
779
- function getElementAtPath(obj, path14) {
780
- if (!path14)
779
+ function getElementAtPath(obj, path15) {
780
+ if (!path15)
781
781
  return obj;
782
- return path14.reduce((acc, key) => acc?.[key], obj);
782
+ return path15.reduce((acc, key) => acc?.[key], obj);
783
783
  }
784
784
  function promiseAllObject(promisesObj) {
785
785
  const keys = Object.keys(promisesObj);
@@ -1188,11 +1188,11 @@ function explicitlyAborted(x2, startIndex = 0) {
1188
1188
  }
1189
1189
  return false;
1190
1190
  }
1191
- function prefixIssues(path14, issues) {
1191
+ function prefixIssues(path15, issues) {
1192
1192
  return issues.map((iss) => {
1193
1193
  var _a4;
1194
1194
  (_a4 = iss).path ?? (_a4.path = []);
1195
- iss.path.unshift(path14);
1195
+ iss.path.unshift(path15);
1196
1196
  return iss;
1197
1197
  });
1198
1198
  }
@@ -1339,16 +1339,16 @@ function flattenError(error52, mapper = (issue2) => issue2.message) {
1339
1339
  }
1340
1340
  function formatError(error52, mapper = (issue2) => issue2.message) {
1341
1341
  const fieldErrors = { _errors: [] };
1342
- const processError = (error53, path14 = []) => {
1342
+ const processError = (error53, path15 = []) => {
1343
1343
  for (const issue2 of error53.issues) {
1344
1344
  if (issue2.code === "invalid_union" && issue2.errors.length) {
1345
- issue2.errors.map((issues) => processError({ issues }, [...path14, ...issue2.path]));
1345
+ issue2.errors.map((issues) => processError({ issues }, [...path15, ...issue2.path]));
1346
1346
  } else if (issue2.code === "invalid_key") {
1347
- processError({ issues: issue2.issues }, [...path14, ...issue2.path]);
1347
+ processError({ issues: issue2.issues }, [...path15, ...issue2.path]);
1348
1348
  } else if (issue2.code === "invalid_element") {
1349
- processError({ issues: issue2.issues }, [...path14, ...issue2.path]);
1349
+ processError({ issues: issue2.issues }, [...path15, ...issue2.path]);
1350
1350
  } else {
1351
- const fullpath = [...path14, ...issue2.path];
1351
+ const fullpath = [...path15, ...issue2.path];
1352
1352
  if (fullpath.length === 0) {
1353
1353
  fieldErrors._errors.push(mapper(issue2));
1354
1354
  } else {
@@ -1375,17 +1375,17 @@ function formatError(error52, mapper = (issue2) => issue2.message) {
1375
1375
  }
1376
1376
  function treeifyError(error52, mapper = (issue2) => issue2.message) {
1377
1377
  const result = { errors: [] };
1378
- const processError = (error53, path14 = []) => {
1378
+ const processError = (error53, path15 = []) => {
1379
1379
  var _a4, _b2;
1380
1380
  for (const issue2 of error53.issues) {
1381
1381
  if (issue2.code === "invalid_union" && issue2.errors.length) {
1382
- issue2.errors.map((issues) => processError({ issues }, [...path14, ...issue2.path]));
1382
+ issue2.errors.map((issues) => processError({ issues }, [...path15, ...issue2.path]));
1383
1383
  } else if (issue2.code === "invalid_key") {
1384
- processError({ issues: issue2.issues }, [...path14, ...issue2.path]);
1384
+ processError({ issues: issue2.issues }, [...path15, ...issue2.path]);
1385
1385
  } else if (issue2.code === "invalid_element") {
1386
- processError({ issues: issue2.issues }, [...path14, ...issue2.path]);
1386
+ processError({ issues: issue2.issues }, [...path15, ...issue2.path]);
1387
1387
  } else {
1388
- const fullpath = [...path14, ...issue2.path];
1388
+ const fullpath = [...path15, ...issue2.path];
1389
1389
  if (fullpath.length === 0) {
1390
1390
  result.errors.push(mapper(issue2));
1391
1391
  continue;
@@ -1417,8 +1417,8 @@ function treeifyError(error52, mapper = (issue2) => issue2.message) {
1417
1417
  }
1418
1418
  function toDotPath(_path) {
1419
1419
  const segs = [];
1420
- const path14 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
1421
- for (const seg of path14) {
1420
+ const path15 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
1421
+ for (const seg of path15) {
1422
1422
  if (typeof seg === "number")
1423
1423
  segs.push(`[${seg}]`);
1424
1424
  else if (typeof seg === "symbol")
@@ -4646,8 +4646,8 @@ function az_default() {
4646
4646
  }
4647
4647
 
4648
4648
  // ../../../node_modules/zod/v4/locales/be.js
4649
- function getBelarusianPlural(count, one, few, many) {
4650
- const absCount = Math.abs(count);
4649
+ function getBelarusianPlural(count3, one, few, many) {
4650
+ const absCount = Math.abs(count3);
4651
4651
  const lastDigit = absCount % 10;
4652
4652
  const lastTwoDigits = absCount % 100;
4653
4653
  if (lastTwoDigits >= 11 && lastTwoDigits <= 19) {
@@ -6725,8 +6725,8 @@ function hu_default() {
6725
6725
  }
6726
6726
 
6727
6727
  // ../../../node_modules/zod/v4/locales/hy.js
6728
- function getArmenianPlural(count, one, many) {
6729
- return Math.abs(count) === 1 ? one : many;
6728
+ function getArmenianPlural(count3, one, many) {
6729
+ return Math.abs(count3) === 1 ? one : many;
6730
6730
  }
6731
6731
  function withDefiniteArticle(word) {
6732
6732
  if (!word)
@@ -7648,8 +7648,8 @@ function ko_default() {
7648
7648
  }
7649
7649
 
7650
7650
  // ../../../node_modules/zod/v4/locales/lt.js
7651
- var capitalizeFirstCharacter = (text) => {
7652
- return text.charAt(0).toUpperCase() + text.slice(1);
7651
+ var capitalizeFirstCharacter = (text2) => {
7652
+ return text2.charAt(0).toUpperCase() + text2.slice(1);
7653
7653
  };
7654
7654
  function getUnitTypeFromNumber(number4) {
7655
7655
  const abs = Math.abs(number4);
@@ -8854,8 +8854,8 @@ function ro_default() {
8854
8854
  }
8855
8855
 
8856
8856
  // ../../../node_modules/zod/v4/locales/ru.js
8857
- function getRussianPlural(count, one, few, many) {
8858
- const absCount = Math.abs(count);
8857
+ function getRussianPlural(count3, one, few, many) {
8858
+ const absCount = Math.abs(count3);
8859
8859
  const lastDigit = absCount % 10;
8860
8860
  const lastTwoDigits = absCount % 100;
8861
8861
  if (lastTwoDigits >= 11 && lastTwoDigits <= 19) {
@@ -14110,13 +14110,13 @@ function resolveRef(ref, ctx) {
14110
14110
  if (!ref.startsWith("#")) {
14111
14111
  throw new Error("External $ref is not supported, only local refs (#/...) are allowed");
14112
14112
  }
14113
- const path14 = ref.slice(1).split("/").filter(Boolean);
14114
- if (path14.length === 0) {
14113
+ const path15 = ref.slice(1).split("/").filter(Boolean);
14114
+ if (path15.length === 0) {
14115
14115
  return ctx.rootSchema;
14116
14116
  }
14117
14117
  const defsKey = ctx.version === "draft-2020-12" ? "$defs" : "definitions";
14118
- if (path14[0] === defsKey) {
14119
- const key = path14[1];
14118
+ if (path15[0] === defsKey) {
14119
+ const key = path15[1];
14120
14120
  if (!key || !ctx.defs[key]) {
14121
14121
  throw new Error(`Reference not found: ${ref}`);
14122
14122
  }
@@ -14632,6 +14632,304 @@ var hostTurnIdSchema = opaqueIdSchema.brand();
14632
14632
  var hostItemIdSchema = opaqueIdSchema.brand();
14633
14633
  var hostInteractionIdSchema = opaqueIdSchema.brand();
14634
14634
 
14635
+ // ../../shared-contracts/dist/harness-plugins.js
14636
+ var HARNESS_PLUGIN_MANIFEST_MAX_BYTES = 32 * 1024;
14637
+ var HARNESS_PLUGIN_ICON_MAX_BYTES = 128 * 1024;
14638
+ var HARNESS_PLUGIN_LIMIT = 128;
14639
+ var harnessPluginIdSchema = external_exports.string().min(1).max(128).regex(/^[a-z][a-z0-9]*(?:[._-][a-z0-9]+)*$/u).refine((id) => id !== "codex", "The official Codex identity is reserved").pipe(harnessIdSchema);
14640
+ var relativeResourceSchema = external_exports.string().min(1).max(512).refine((value) => !/[\\\u0000:#?]/u.test(value) && !value.startsWith("/") && !value.split("/").some((part) => part === ".." || part === ""), "Plugin resources must be relative paths inside the plugin");
14641
+ var documentationUrlSchema = external_exports.url().refine((value) => /^https:\/\/[^/?#@]+(?:[/?#]|$)/iu.test(value), "Plugin documentation links must be credential-free HTTPS URLs");
14642
+ var pluginPresentationShape = {
14643
+ id: harnessPluginIdSchema,
14644
+ name: external_exports.string().trim().min(1).max(128),
14645
+ version: external_exports.string().min(1).max(128),
14646
+ /** The factory accepts a persisted local entrypoint through its construction context. */
14647
+ launchCommand: external_exports.literal(true).optional(),
14648
+ links: external_exports.object({
14649
+ documentation: documentationUrlSchema.optional(),
14650
+ installation: documentationUrlSchema.optional()
14651
+ }).strict().optional()
14652
+ };
14653
+ var harnessPluginManifestSchema = external_exports.object({
14654
+ manifestVersion: external_exports.literal(1),
14655
+ ...pluginPresentationShape,
14656
+ adapterApiVersion: external_exports.number().int().positive(),
14657
+ entry: relativeResourceSchema,
14658
+ icon: relativeResourceSchema.optional()
14659
+ }).strict();
14660
+ var harnessPluginIconSchema = external_exports.string().max(Math.ceil(HARNESS_PLUGIN_ICON_MAX_BYTES / 3) * 4 + 64).regex(/^data:image\/(?:png|jpeg|webp|svg\+xml);base64,[A-Za-z0-9+/]+={0,2}$/u);
14661
+ var harnessPluginDescriptorSchema = external_exports.object({
14662
+ ...pluginPresentationShape,
14663
+ icon: harnessPluginIconSchema.optional()
14664
+ }).strict();
14665
+ var harnessPluginListParamsSchema = external_exports.object({}).strict();
14666
+ var harnessPluginListResultSchema = external_exports.object({
14667
+ plugins: external_exports.array(harnessPluginDescriptorSchema).max(HARNESS_PLUGIN_LIMIT)
14668
+ }).strict();
14669
+ var harnessPluginConfigurationSchema = external_exports.object({
14670
+ version: external_exports.literal(1),
14671
+ enabled: external_exports.array(harnessPluginIdSchema).max(HARNESS_PLUGIN_LIMIT)
14672
+ }).strict().refine((value) => new Set(value.enabled).size === value.enabled.length, {
14673
+ message: "Enabled plugin IDs must be unique",
14674
+ path: ["enabled"]
14675
+ });
14676
+
14677
+ // ../../shared-contracts/dist/local-usage.js
14678
+ var LOCAL_USAGE_CUSTOM_RANGE_MAX_DAYS = 3660;
14679
+ var LOCAL_USAGE_DAILY_MAX_LENGTH = LOCAL_USAGE_CUSTOM_RANGE_MAX_DAYS + 1;
14680
+ var LOCAL_USAGE_HARNESS_MAX_LENGTH = 128;
14681
+ var LOCAL_USAGE_HARNESS_NAME_MAX_LENGTH = 128;
14682
+ var LOCAL_USAGE_PROVIDER_MAX_LENGTH = 128;
14683
+ var LOCAL_USAGE_PROVIDER_NAME_MAX_LENGTH = 1024;
14684
+ var LOCAL_USAGE_PROJECT_MAX_LENGTH = 1e3;
14685
+ var LOCAL_USAGE_PROJECT_NAME_MAX_LENGTH = 1024;
14686
+ var LOCAL_USAGE_TIME_ZONE_MAX_LENGTH = 64;
14687
+ var DAY_MS = 864e5;
14688
+ function dateValue(value) {
14689
+ return Date.parse(`${value}T00:00:00.000Z`);
14690
+ }
14691
+ var localUsageDateSchema = external_exports.string().regex(/^\d{4}-\d{2}-\d{2}$/u).refine((value) => {
14692
+ const time3 = dateValue(value);
14693
+ return Number.isFinite(time3) && new Date(time3).toISOString().slice(0, 10) === value;
14694
+ }, "Invalid calendar date");
14695
+ var timeZoneSchema = external_exports.string().min(1).max(LOCAL_USAGE_TIME_ZONE_MAX_LENGTH).refine((value) => {
14696
+ try {
14697
+ new Intl.DateTimeFormat("en-US", { timeZone: value });
14698
+ return true;
14699
+ } catch {
14700
+ return false;
14701
+ }
14702
+ }, "Unknown time zone");
14703
+ var localUsagePeriodSchema = external_exports.discriminatedUnion("kind", [
14704
+ external_exports.strictObject({ kind: external_exports.literal("day") }),
14705
+ // Weeks start on Monday.
14706
+ external_exports.strictObject({ kind: external_exports.literal("week") }),
14707
+ external_exports.strictObject({ kind: external_exports.literal("month") }),
14708
+ // The first day of the month 23 months ago through today.
14709
+ external_exports.strictObject({ kind: external_exports.literal("total") }),
14710
+ external_exports.strictObject({
14711
+ kind: external_exports.literal("custom"),
14712
+ from: localUsageDateSchema,
14713
+ to: localUsageDateSchema
14714
+ }).superRefine((period, context) => {
14715
+ const days = (dateValue(period.to) - dateValue(period.from)) / DAY_MS;
14716
+ if (days < 0) {
14717
+ context.addIssue({ code: "custom", path: ["to"], message: "Range ends before it starts" });
14718
+ } else if (days >= LOCAL_USAGE_CUSTOM_RANGE_MAX_DAYS) {
14719
+ context.addIssue({ code: "custom", path: ["to"], message: "Range is too long" });
14720
+ }
14721
+ })
14722
+ ]);
14723
+ var localUsageQueryParamsSchema = external_exports.strictObject({
14724
+ period: localUsagePeriodSchema,
14725
+ /** IANA zone used to assign usage to calendar days. */
14726
+ timeZone: timeZoneSchema,
14727
+ /** Read new native records before answering; otherwise reuse this Host's last read. */
14728
+ refresh: external_exports.boolean()
14729
+ });
14730
+ var countSchema = external_exports.number().int().nonnegative().safe();
14731
+ var tokenTotalsShape = {
14732
+ total: countSchema,
14733
+ /** Input tokens excluding cache reads and writes. */
14734
+ input: countSchema,
14735
+ cacheRead: countSchema,
14736
+ cacheWrite: countSchema,
14737
+ output: countSchema,
14738
+ reasoning: countSchema
14739
+ };
14740
+ var usageHarnessIdSchema = external_exports.union([external_exports.literal("codex"), harnessPluginIdSchema]);
14741
+ var localUsageViewSchema = external_exports.strictObject({
14742
+ status: external_exports.literal("ready"),
14743
+ range: external_exports.strictObject({ from: localUsageDateSchema, to: localUsageDateSchema }),
14744
+ totals: external_exports.strictObject({ ...tokenTotalsShape, conversations: countSchema }).refine((totals) => totals.total === totals.input + totals.cacheRead + totals.cacheWrite + totals.output + totals.reasoning, { path: ["total"], message: "Total must equal its parts" }),
14745
+ /**
14746
+ * Estimated Cost of the range in USD: Harness-reported cost where present, otherwise public
14747
+ * model prices applied when queried. Models without a price add 0.
14748
+ */
14749
+ estimatedCostUsd: external_exports.number().nonnegative().finite(),
14750
+ /** Distinct Models with usage in the range, across Harnesses. */
14751
+ models: countSchema,
14752
+ harnesses: external_exports.array(external_exports.strictObject({
14753
+ harnessId: usageHarnessIdSchema,
14754
+ name: external_exports.string().trim().min(1).max(LOCAL_USAGE_HARNESS_NAME_MAX_LENGTH),
14755
+ totalTokens: countSchema,
14756
+ models: countSchema,
14757
+ /** Providers the Harness recorded, by usage; empty when it records none. */
14758
+ providers: external_exports.array(external_exports.strictObject({
14759
+ provider: external_exports.string().min(1).max(LOCAL_USAGE_PROVIDER_NAME_MAX_LENGTH),
14760
+ totalTokens: countSchema,
14761
+ models: countSchema
14762
+ })).max(LOCAL_USAGE_PROVIDER_MAX_LENGTH)
14763
+ }).refine((harness) => harness.providers.reduce((sum, provider) => sum + provider.totalTokens, 0) <= harness.totalTokens, { path: ["providers"], message: "Providers are part of their Harness" })).max(LOCAL_USAGE_HARNESS_MAX_LENGTH),
14764
+ /** Days with usage, newest first. `cacheRead` is the daily cache column. */
14765
+ daily: external_exports.array(external_exports.strictObject({
14766
+ date: localUsageDateSchema,
14767
+ total: countSchema,
14768
+ input: countSchema,
14769
+ output: countSchema,
14770
+ cacheRead: countSchema,
14771
+ reasoning: countSchema,
14772
+ conversations: countSchema
14773
+ })).max(LOCAL_USAGE_DAILY_MAX_LENGTH),
14774
+ /**
14775
+ * Usage with a known working directory, by project, most used first: `owner/repo` from the Git
14776
+ * remote, otherwise the folder name. Only the most used projects are listed.
14777
+ */
14778
+ projects: external_exports.array(external_exports.strictObject({
14779
+ project: external_exports.string().min(1).max(LOCAL_USAGE_PROJECT_NAME_MAX_LENGTH),
14780
+ totalTokens: countSchema,
14781
+ /** Harnesses used in the project, most used first. */
14782
+ harnessIds: external_exports.array(usageHarnessIdSchema).min(1).max(LOCAL_USAGE_HARNESS_MAX_LENGTH)
14783
+ })).max(LOCAL_USAGE_PROJECT_MAX_LENGTH),
14784
+ /** Harnesses whose last read failed; their totals are from their last successful read. */
14785
+ failures: external_exports.array(external_exports.strictObject({
14786
+ harnessId: usageHarnessIdSchema,
14787
+ name: external_exports.string().trim().min(1).max(LOCAL_USAGE_HARNESS_NAME_MAX_LENGTH)
14788
+ })).max(LOCAL_USAGE_HARNESS_MAX_LENGTH),
14789
+ /**
14790
+ * Independent of the selected period. Windows end today; an active day has tokens.
14791
+ * `dailyAverage` is the last 30 days' total over their active days, rounded.
14792
+ */
14793
+ stats: external_exports.strictObject({
14794
+ last7Days: countSchema,
14795
+ last30Days: countSchema,
14796
+ dailyAverage: countSchema,
14797
+ /** Active days across all counted history, not only the "total" period. */
14798
+ activeDays: countSchema,
14799
+ firstActiveDate: localUsageDateSchema.nullable()
14800
+ }).superRefine((stats, context) => {
14801
+ if (stats.firstActiveDate === null !== (stats.activeDays === 0)) {
14802
+ context.addIssue({
14803
+ code: "custom",
14804
+ path: ["firstActiveDate"],
14805
+ message: "First active date exists exactly when there are active days"
14806
+ });
14807
+ }
14808
+ if (stats.last7Days > stats.last30Days) {
14809
+ context.addIssue({
14810
+ code: "custom",
14811
+ path: ["last7Days"],
14812
+ message: "The last 7 days are part of the last 30 days"
14813
+ });
14814
+ }
14815
+ })
14816
+ });
14817
+ var localUsageReadingSchema = external_exports.strictObject({
14818
+ status: external_exports.literal("reading"),
14819
+ /** Native record files read so far by the sources that report progress. */
14820
+ progress: external_exports.strictObject({ processed: countSchema, total: countSchema }).refine((progress) => progress.processed <= progress.total, {
14821
+ path: ["processed"],
14822
+ message: "Processed files are part of the total"
14823
+ })
14824
+ });
14825
+ var localUsageQueryResultSchema = external_exports.discriminatedUnion("status", [
14826
+ localUsageReadingSchema,
14827
+ localUsageViewSchema
14828
+ ]);
14829
+
14830
+ // ../../shared-contracts/dist/harness-session-import.js
14831
+ var HARNESS_SESSION_IMPORT_ID_MAX_LENGTH = 1024;
14832
+ var HARNESS_SESSION_IMPORT_CWD_MAX_LENGTH = 16384;
14833
+ var HARNESS_SESSION_IMPORT_TITLE_MAX_LENGTH = 4096;
14834
+ var HARNESS_SESSION_IMPORT_LIST_MAX_LENGTH = 1e3;
14835
+ var HARNESS_SESSION_IMPORT_UPDATED_AT_MAX = 864e13;
14836
+ var nonBlankTextSchema = external_exports.string().refine((value) => value.trim().length > 0, "Value must not be empty or whitespace").refine((value) => !value.includes("\0"), "Value must not contain NUL");
14837
+ var harnessSessionImportIdSchema = nonBlankTextSchema.max(HARNESS_SESSION_IMPORT_ID_MAX_LENGTH);
14838
+ var harnessSessionImportCandidateSchema = external_exports.object({
14839
+ nativeSessionId: harnessSessionImportIdSchema,
14840
+ title: nonBlankTextSchema.max(HARNESS_SESSION_IMPORT_TITLE_MAX_LENGTH).nullable(),
14841
+ updatedAt: external_exports.number().int().nonnegative().max(HARNESS_SESSION_IMPORT_UPDATED_AT_MAX),
14842
+ cwd: nonBlankTextSchema.max(HARNESS_SESSION_IMPORT_CWD_MAX_LENGTH),
14843
+ // Native file discovery cannot reliably observe another process's activity.
14844
+ running: external_exports.boolean().nullable()
14845
+ }).strict();
14846
+ var harnessSessionImportSourcesParamsSchema = external_exports.object({}).strict();
14847
+ var harnessSessionImportSourcesResultSchema = external_exports.object({
14848
+ harnesses: external_exports.array(external_exports.object({
14849
+ harnessId: harnessPluginIdSchema,
14850
+ name: nonBlankTextSchema.max(128)
14851
+ }).strict()).max(128)
14852
+ }).strict();
14853
+ var harnessSessionListParamsSchema = external_exports.object({
14854
+ harnessId: harnessPluginIdSchema,
14855
+ query: external_exports.string().trim().max(4096).refine((value) => !value.includes("\0")).optional(),
14856
+ offset: external_exports.number().int().nonnegative().safe().optional(),
14857
+ limit: external_exports.number().int().min(1).max(HARNESS_SESSION_IMPORT_LIST_MAX_LENGTH).optional()
14858
+ }).strict();
14859
+ var harnessSessionListResultSchema = external_exports.object({
14860
+ candidates: external_exports.array(harnessSessionImportCandidateSchema).max(HARNESS_SESSION_IMPORT_LIST_MAX_LENGTH),
14861
+ total: external_exports.number().int().nonnegative().safe()
14862
+ }).strict();
14863
+ var harnessSessionImportParamsSchema = external_exports.object({
14864
+ harnessId: harnessPluginIdSchema,
14865
+ nativeSessionId: harnessSessionImportIdSchema
14866
+ }).strict();
14867
+ var harnessSessionImportResultSchema = external_exports.object({
14868
+ threadId: nonBlankTextSchema.max(1024).pipe(hostThreadIdSchema)
14869
+ }).strict();
14870
+
14871
+ // ../../shared-contracts/dist/local-sessions.js
14872
+ var LOCAL_SESSIONS_MAX_LENGTH = 1e5;
14873
+ var LOCAL_SESSIONS_MODEL_MAX_LENGTH = 1024;
14874
+ var LOCAL_SESSIONS_RESUME_COMMAND_MAX_LENGTH = 256;
14875
+ var LOCAL_SESSIONS_RESUME_COMMAND_PATTERN = /^[A-Za-z0-9][A-Za-z0-9 ._:=/-]*$/u;
14876
+ var countSchema2 = external_exports.number().int().nonnegative().safe();
14877
+ var timeSchema = countSchema2;
14878
+ var sessionHarnessIdSchema = external_exports.union([external_exports.literal("codex"), harnessPluginIdSchema]);
14879
+ var harnessNameSchema = external_exports.string().trim().min(1).max(LOCAL_USAGE_HARNESS_NAME_MAX_LENGTH);
14880
+ var localSessionsQueryParamsSchema = external_exports.strictObject({
14881
+ /** Read native records added since the last read before answering. */
14882
+ refresh: external_exports.boolean()
14883
+ });
14884
+ var localSessionSchema = external_exports.strictObject({
14885
+ harnessId: sessionHarnessIdSchema,
14886
+ nativeSessionId: harnessSessionImportIdSchema,
14887
+ /** The Harness's own name for the Session; null shows the project instead. */
14888
+ title: external_exports.string().min(1).max(HARNESS_SESSION_IMPORT_TITLE_MAX_LENGTH).nullable(),
14889
+ /** Working directory, used to copy the project path or a resume command. */
14890
+ cwd: external_exports.string().min(1).max(HARNESS_SESSION_IMPORT_CWD_MAX_LENGTH).nullable(),
14891
+ /** `owner/repo` from the Git remote, otherwise the folder name. */
14892
+ project: external_exports.string().min(1).max(LOCAL_USAGE_PROJECT_NAME_MAX_LENGTH).nullable(),
14893
+ model: external_exports.string().min(1).max(LOCAL_SESSIONS_MODEL_MAX_LENGTH).nullable(),
14894
+ startedAt: timeSchema.nullable(),
14895
+ lastActivityAt: timeSchema,
14896
+ /** Null for Sessions known only from Session import, which has no native usage. */
14897
+ activeMs: countSchema2.nullable(),
14898
+ usage: external_exports.strictObject({
14899
+ /** Includes folded subagents. */
14900
+ totalTokens: countSchema2,
14901
+ estimatedCostUsd: external_exports.number().nonnegative().finite()
14902
+ }).nullable(),
14903
+ turns: countSchema2.nullable(),
14904
+ edits: countSchema2.nullable(),
14905
+ /** Subagent and child Sessions folded into this one. */
14906
+ subagents: countSchema2,
14907
+ /** The Thread this Session is already mapped to. */
14908
+ threadId: hostThreadIdSchema.nullable(),
14909
+ /** Whether Resume can open it as a Thread. */
14910
+ resumable: external_exports.boolean(),
14911
+ /** Null when the Harness cannot tell whether another client is running it. */
14912
+ running: external_exports.boolean().nullable(),
14913
+ /**
14914
+ * Resumes the Session in its Harness's own CLI when run from `cwd`; null when the Harness has
14915
+ * no such command or the Session ID is not safe to paste into a terminal.
14916
+ */
14917
+ resumeCommand: external_exports.string().max(LOCAL_SESSIONS_RESUME_COMMAND_MAX_LENGTH).regex(LOCAL_SESSIONS_RESUME_COMMAND_PATTERN).nullable()
14918
+ });
14919
+ var localSessionsViewSchema = external_exports.strictObject({
14920
+ status: external_exports.literal("ready"),
14921
+ /** Most recently active first. */
14922
+ sessions: external_exports.array(localSessionSchema).max(LOCAL_SESSIONS_MAX_LENGTH),
14923
+ /** Harnesses with listed Sessions, by name. */
14924
+ harnesses: external_exports.array(external_exports.strictObject({ harnessId: sessionHarnessIdSchema, name: harnessNameSchema })).max(LOCAL_USAGE_HARNESS_MAX_LENGTH),
14925
+ /** Sources whose last read failed; their Sessions are from their last successful read. */
14926
+ failures: external_exports.array(external_exports.strictObject({ harnessId: sessionHarnessIdSchema, name: harnessNameSchema })).max(LOCAL_USAGE_HARNESS_MAX_LENGTH)
14927
+ });
14928
+ var localSessionsQueryResultSchema = external_exports.discriminatedUnion("status", [
14929
+ localUsageReadingSchema,
14930
+ localSessionsViewSchema
14931
+ ]);
14932
+
14635
14933
  // ../../shared-contracts/dist/thread-usage.js
14636
14934
  var nonNegativeSafeIntegerSchema = external_exports.number().int().safe().nonnegative();
14637
14935
  var finiteNonNegativeNumberSchema = external_exports.number().finite().nonnegative();
@@ -14695,10 +14993,18 @@ var accountCreditsProductUsageSchema = external_exports.object({
14695
14993
  usagePercent: usagePercentSchema,
14696
14994
  resetsAt: external_exports.string().min(1).optional()
14697
14995
  }).strict();
14996
+ var ACCOUNT_RESET_CREDITS_MAX_LENGTH = 32;
14997
+ var ACCOUNT_RESET_CREDIT_TIME_MAX_LENGTH = 64;
14998
+ var resetCreditTimeSchema = external_exports.string().min(1).max(ACCOUNT_RESET_CREDIT_TIME_MAX_LENGTH);
14999
+ var accountResetCreditSchema = external_exports.object({
15000
+ expiresAt: resetCreditTimeSchema,
15001
+ grantedAt: resetCreditTimeSchema.optional()
15002
+ }).strict();
14698
15003
  var accountResetCreditsSchema = external_exports.object({
14699
15004
  availableCount: external_exports.number().int().safe().positive(),
14700
15005
  nextExpiresAt: external_exports.string().min(1).optional(),
14701
- expiresAt: external_exports.array(external_exports.string().min(1)).min(1).max(32).optional()
15006
+ expiresAt: external_exports.array(external_exports.string().min(1)).min(1).max(ACCOUNT_RESET_CREDITS_MAX_LENGTH).optional(),
15007
+ credits: external_exports.array(accountResetCreditSchema).min(1).max(ACCOUNT_RESET_CREDITS_MAX_LENGTH).optional()
14702
15008
  }).strict();
14703
15009
  var accountCreditsSnapshotSchema = external_exports.object({
14704
15010
  /** Native label when the primary limit is scoped to a model or product group. */
@@ -14818,14 +15124,14 @@ var HARNESS_PERMISSION_MODE_ID_MAX_LENGTH = 128;
14818
15124
  var HARNESS_PERMISSION_MODE_LABEL_MAX_LENGTH = 256;
14819
15125
  var HARNESS_PERMISSION_MODE_DESCRIPTION_MAX_LENGTH = 1024;
14820
15126
  var HARNESS_PERMISSION_MODE_CATALOG_MAX_LENGTH = 32;
14821
- var nonBlankTextSchema = external_exports.string().refine((value) => value.trim().length > 0, {
15127
+ var nonBlankTextSchema2 = external_exports.string().refine((value) => value.trim().length > 0, {
14822
15128
  message: "Value must not be empty or whitespace"
14823
15129
  });
14824
- var harnessPermissionModeIdSchema = nonBlankTextSchema.max(HARNESS_PERMISSION_MODE_ID_MAX_LENGTH).regex(/^[A-Za-z0-9._~-]+$/u, "Permission Mode ID must use transport-safe characters").brand();
15130
+ var harnessPermissionModeIdSchema = nonBlankTextSchema2.max(HARNESS_PERMISSION_MODE_ID_MAX_LENGTH).regex(/^[A-Za-z0-9._~-]+$/u, "Permission Mode ID must use transport-safe characters").brand();
14825
15131
  var harnessPermissionModeSchema = external_exports.object({
14826
15132
  id: harnessPermissionModeIdSchema,
14827
- label: nonBlankTextSchema.max(HARNESS_PERMISSION_MODE_LABEL_MAX_LENGTH),
14828
- description: nonBlankTextSchema.max(HARNESS_PERMISSION_MODE_DESCRIPTION_MAX_LENGTH).optional(),
15133
+ label: nonBlankTextSchema2.max(HARNESS_PERMISSION_MODE_LABEL_MAX_LENGTH),
15134
+ description: nonBlankTextSchema2.max(HARNESS_PERMISSION_MODE_DESCRIPTION_MAX_LENGTH).optional(),
14829
15135
  dangerous: external_exports.boolean().optional()
14830
15136
  }).strict();
14831
15137
  var harnessPermissionModeCatalogSchema = external_exports.object({
@@ -14861,22 +15167,22 @@ var HARNESS_MODEL_REF_MAX_LENGTH = 512;
14861
15167
  var HARNESS_MODEL_LABEL_MAX_LENGTH = 256;
14862
15168
  var HARNESS_THINKING_OPTION_ID_MAX_LENGTH = 128;
14863
15169
  var THREAD_OWNERSHIP_LIST_MAX_LENGTH = 100;
14864
- var nonBlankTextSchema2 = external_exports.string().refine((value) => value.trim().length > 0, {
15170
+ var nonBlankTextSchema3 = external_exports.string().refine((value) => value.trim().length > 0, {
14865
15171
  message: "Value must not be empty or whitespace"
14866
15172
  });
14867
- var harnessModelRefIdSchema = nonBlankTextSchema2.max(HARNESS_MODEL_REF_MAX_LENGTH).regex(/^[A-Za-z0-9._~-]+$/u, "Model Ref must use transport-safe opaque characters").brand();
15173
+ var harnessModelRefIdSchema = nonBlankTextSchema3.max(HARNESS_MODEL_REF_MAX_LENGTH).regex(/^[A-Za-z0-9._~-]+$/u, "Model Ref must use transport-safe opaque characters").brand();
14868
15174
  var harnessModelRefSchema = external_exports.object({
14869
15175
  id: harnessModelRefIdSchema
14870
15176
  }).strict();
14871
- var harnessThinkingOptionIdSchema = nonBlankTextSchema2.max(HARNESS_THINKING_OPTION_ID_MAX_LENGTH).regex(/^[A-Za-z0-9._~-]+$/u, "Thinking option ID must use transport-safe characters").brand();
14872
- var harnessResolvedModelLabelSchema = nonBlankTextSchema2.max(HARNESS_MODEL_LABEL_MAX_LENGTH);
15177
+ var harnessThinkingOptionIdSchema = nonBlankTextSchema3.max(HARNESS_THINKING_OPTION_ID_MAX_LENGTH).regex(/^[A-Za-z0-9._~-]+$/u, "Thinking option ID must use transport-safe characters").brand();
15178
+ var harnessResolvedModelLabelSchema = nonBlankTextSchema3.max(HARNESS_MODEL_LABEL_MAX_LENGTH);
14873
15179
  var harnessThinkingOptionSchema = external_exports.object({
14874
15180
  id: harnessThinkingOptionIdSchema,
14875
- label: nonBlankTextSchema2.max(HARNESS_MODEL_LABEL_MAX_LENGTH)
15181
+ label: nonBlankTextSchema3.max(HARNESS_MODEL_LABEL_MAX_LENGTH)
14876
15182
  }).strict();
14877
15183
  var harnessModelSchema = external_exports.object({
14878
15184
  ref: harnessModelRefSchema,
14879
- label: nonBlankTextSchema2.max(HARNESS_MODEL_LABEL_MAX_LENGTH),
15185
+ label: nonBlankTextSchema3.max(HARNESS_MODEL_LABEL_MAX_LENGTH),
14880
15186
  resolvedModelLabel: harnessResolvedModelLabelSchema.optional(),
14881
15187
  supportedThinkingOptionIds: external_exports.array(harnessThinkingOptionIdSchema).optional()
14882
15188
  }).strict();
@@ -15013,7 +15319,7 @@ var harnessInspectionSchema = external_exports.union([
15013
15319
  ]);
15014
15320
  var harnessInspectParamsSchema = external_exports.object({
15015
15321
  harnessId: harnessIdSchema,
15016
- cwd: nonBlankTextSchema2.max(16384).optional(),
15322
+ cwd: nonBlankTextSchema3.max(16384).optional(),
15017
15323
  refresh: external_exports.boolean().optional()
15018
15324
  }).strict();
15019
15325
  var harnessWebUiOpenParamsSchema = external_exports.object({
@@ -15037,8 +15343,8 @@ var codexThreadInspectionSchema = external_exports.object({
15037
15343
  }).strict();
15038
15344
  var externalThreadInspectionSchema = external_exports.object({
15039
15345
  owner: external_exports.literal("external"),
15040
- harnessId: nonBlankTextSchema2.max(256),
15041
- transportModelId: nonBlankTextSchema2.max(1024),
15346
+ harnessId: nonBlankTextSchema3.max(256),
15347
+ transportModelId: nonBlankTextSchema3.max(1024),
15042
15348
  effectiveModel: harnessModelRefSchema.optional(),
15043
15349
  resolvedModelLabel: harnessResolvedModelLabelSchema.optional(),
15044
15350
  effectiveThinkingOptionId: harnessThinkingOptionIdSchema.optional(),
@@ -15096,48 +15402,6 @@ var threadOwnershipListResultSchema = external_exports.object({
15096
15402
  }
15097
15403
  });
15098
15404
 
15099
- // ../../shared-contracts/dist/harness-plugins.js
15100
- var HARNESS_PLUGIN_MANIFEST_MAX_BYTES = 32 * 1024;
15101
- var HARNESS_PLUGIN_ICON_MAX_BYTES = 128 * 1024;
15102
- var HARNESS_PLUGIN_LIMIT = 128;
15103
- var harnessPluginIdSchema = external_exports.string().min(1).max(128).regex(/^[a-z][a-z0-9]*(?:[._-][a-z0-9]+)*$/u).refine((id) => id !== "codex", "The official Codex identity is reserved").pipe(harnessIdSchema);
15104
- var relativeResourceSchema = external_exports.string().min(1).max(512).refine((value) => !/[\\\u0000:#?]/u.test(value) && !value.startsWith("/") && !value.split("/").some((part) => part === ".." || part === ""), "Plugin resources must be relative paths inside the plugin");
15105
- var documentationUrlSchema = external_exports.url().refine((value) => /^https:\/\/[^/?#@]+(?:[/?#]|$)/iu.test(value), "Plugin documentation links must be credential-free HTTPS URLs");
15106
- var pluginPresentationShape = {
15107
- id: harnessPluginIdSchema,
15108
- name: external_exports.string().trim().min(1).max(128),
15109
- version: external_exports.string().min(1).max(128),
15110
- /** The factory accepts a persisted local entrypoint through its construction context. */
15111
- launchCommand: external_exports.literal(true).optional(),
15112
- links: external_exports.object({
15113
- documentation: documentationUrlSchema.optional(),
15114
- installation: documentationUrlSchema.optional()
15115
- }).strict().optional()
15116
- };
15117
- var harnessPluginManifestSchema = external_exports.object({
15118
- manifestVersion: external_exports.literal(1),
15119
- ...pluginPresentationShape,
15120
- adapterApiVersion: external_exports.number().int().positive(),
15121
- entry: relativeResourceSchema,
15122
- icon: relativeResourceSchema.optional()
15123
- }).strict();
15124
- var harnessPluginIconSchema = external_exports.string().max(Math.ceil(HARNESS_PLUGIN_ICON_MAX_BYTES / 3) * 4 + 64).regex(/^data:image\/(?:png|jpeg|webp|svg\+xml);base64,[A-Za-z0-9+/]+={0,2}$/u);
15125
- var harnessPluginDescriptorSchema = external_exports.object({
15126
- ...pluginPresentationShape,
15127
- icon: harnessPluginIconSchema.optional()
15128
- }).strict();
15129
- var harnessPluginListParamsSchema = external_exports.object({}).strict();
15130
- var harnessPluginListResultSchema = external_exports.object({
15131
- plugins: external_exports.array(harnessPluginDescriptorSchema).max(HARNESS_PLUGIN_LIMIT)
15132
- }).strict();
15133
- var harnessPluginConfigurationSchema = external_exports.object({
15134
- version: external_exports.literal(1),
15135
- enabled: external_exports.array(harnessPluginIdSchema).max(HARNESS_PLUGIN_LIMIT)
15136
- }).strict().refine((value) => new Set(value.enabled).size === value.enabled.length, {
15137
- message: "Enabled plugin IDs must be unique",
15138
- path: ["enabled"]
15139
- });
15140
-
15141
15405
  // ../../shared-contracts/dist/harness-route.js
15142
15406
  var harnessPluginRouteSchema = external_exports.object({
15143
15407
  harnessId: harnessPluginIdSchema,
@@ -15161,7 +15425,7 @@ var harnessLaunchSettingsSchema = external_exports.object({
15161
15425
 
15162
15426
  // ../../shared-contracts/dist/codex-accounts.js
15163
15427
  var accountIdSchema = external_exports.string().min(1).max(256).regex(/^[A-Za-z0-9._~-]+$/u);
15164
- var nonBlankTextSchema3 = external_exports.string().trim().min(1);
15428
+ var nonBlankTextSchema4 = external_exports.string().trim().min(1);
15165
15429
  var codexAccountPlanTypeSchema = external_exports.enum([
15166
15430
  "free",
15167
15431
  "go",
@@ -15183,7 +15447,7 @@ var codexAccountPlanTypeSchema = external_exports.enum([
15183
15447
  ]);
15184
15448
  var codexAccountSchema = external_exports.object({
15185
15449
  accountId: accountIdSchema,
15186
- label: nonBlankTextSchema3.max(256),
15450
+ label: nonBlankTextSchema4.max(256),
15187
15451
  email: external_exports.string().email().max(320).optional(),
15188
15452
  planType: codexAccountPlanTypeSchema.optional()
15189
15453
  }).strict();
@@ -15193,7 +15457,7 @@ var codexAccountListResultSchema = external_exports.object({
15193
15457
  currentAccountId: accountIdSchema.nullable(),
15194
15458
  phase: codexAccountPhaseSchema,
15195
15459
  revision: external_exports.number().int().nonnegative(),
15196
- instanceId: nonBlankTextSchema3.max(1024).optional(),
15460
+ instanceId: nonBlankTextSchema4.max(1024).optional(),
15197
15461
  accounts: external_exports.array(codexAccountSchema).max(1)
15198
15462
  }).strict();
15199
15463
  var codexAccountUsageParamsSchema = external_exports.object({ accountId: accountIdSchema, refresh: external_exports.boolean().optional() }).strict();
@@ -15205,47 +15469,6 @@ var codexAccountUsageResultSchema = external_exports.object({
15205
15469
  observedAt: external_exports.string().datetime().nullable()
15206
15470
  }).strict();
15207
15471
 
15208
- // ../../shared-contracts/dist/harness-session-import.js
15209
- var HARNESS_SESSION_IMPORT_ID_MAX_LENGTH = 1024;
15210
- var HARNESS_SESSION_IMPORT_CWD_MAX_LENGTH = 16384;
15211
- var HARNESS_SESSION_IMPORT_TITLE_MAX_LENGTH = 4096;
15212
- var HARNESS_SESSION_IMPORT_LIST_MAX_LENGTH = 1e3;
15213
- var HARNESS_SESSION_IMPORT_UPDATED_AT_MAX = 864e13;
15214
- var nonBlankTextSchema4 = external_exports.string().refine((value) => value.trim().length > 0, "Value must not be empty or whitespace").refine((value) => !value.includes("\0"), "Value must not contain NUL");
15215
- var harnessSessionImportIdSchema = nonBlankTextSchema4.max(HARNESS_SESSION_IMPORT_ID_MAX_LENGTH);
15216
- var harnessSessionImportCandidateSchema = external_exports.object({
15217
- nativeSessionId: harnessSessionImportIdSchema,
15218
- title: nonBlankTextSchema4.max(HARNESS_SESSION_IMPORT_TITLE_MAX_LENGTH).nullable(),
15219
- updatedAt: external_exports.number().int().nonnegative().max(HARNESS_SESSION_IMPORT_UPDATED_AT_MAX),
15220
- cwd: nonBlankTextSchema4.max(HARNESS_SESSION_IMPORT_CWD_MAX_LENGTH),
15221
- // Native file discovery cannot reliably observe another process's activity.
15222
- running: external_exports.boolean().nullable()
15223
- }).strict();
15224
- var harnessSessionImportSourcesParamsSchema = external_exports.object({}).strict();
15225
- var harnessSessionImportSourcesResultSchema = external_exports.object({
15226
- harnesses: external_exports.array(external_exports.object({
15227
- harnessId: harnessPluginIdSchema,
15228
- name: nonBlankTextSchema4.max(128)
15229
- }).strict()).max(128)
15230
- }).strict();
15231
- var harnessSessionListParamsSchema = external_exports.object({
15232
- harnessId: harnessPluginIdSchema,
15233
- query: external_exports.string().trim().max(4096).refine((value) => !value.includes("\0")).optional(),
15234
- offset: external_exports.number().int().nonnegative().safe().optional(),
15235
- limit: external_exports.number().int().min(1).max(HARNESS_SESSION_IMPORT_LIST_MAX_LENGTH).optional()
15236
- }).strict();
15237
- var harnessSessionListResultSchema = external_exports.object({
15238
- candidates: external_exports.array(harnessSessionImportCandidateSchema).max(HARNESS_SESSION_IMPORT_LIST_MAX_LENGTH),
15239
- total: external_exports.number().int().nonnegative().safe()
15240
- }).strict();
15241
- var harnessSessionImportParamsSchema = external_exports.object({
15242
- harnessId: harnessPluginIdSchema,
15243
- nativeSessionId: harnessSessionImportIdSchema
15244
- }).strict();
15245
- var harnessSessionImportResultSchema = external_exports.object({
15246
- threadId: nonBlankTextSchema4.max(1024).pipe(hostThreadIdSchema)
15247
- }).strict();
15248
-
15249
15472
  // ../../shared-contracts/dist/deepseek-modern-sessions.js
15250
15473
  var DEEPSEEK_MODERN_SESSION_LIST_MAX_LENGTH = HARNESS_SESSION_IMPORT_LIST_MAX_LENGTH;
15251
15474
  var DEEPSEEK_MODERN_HOST_THREAD_ID_MAX_LENGTH = 1024;
@@ -15653,6 +15876,61 @@ function parseHostUsage(value) {
15653
15876
  return { ...value };
15654
15877
  }
15655
15878
 
15879
+ // ../../harness-adapter/dist/native-session-summary.js
15880
+ var NATIVE_SESSION_IDLE_GAP_MS = 30 * 6e4;
15881
+ function emptyNativeSessionActivity() {
15882
+ return {
15883
+ firstActivityAt: null,
15884
+ lastActivityAt: null,
15885
+ activeMs: 0,
15886
+ turns: 0,
15887
+ edits: 0,
15888
+ editing: false
15889
+ };
15890
+ }
15891
+ function count(value) {
15892
+ return typeof value === "number" && Number.isSafeInteger(value) && value >= 0;
15893
+ }
15894
+ function parseNativeSessionActivity(value) {
15895
+ if (typeof value !== "object" || value === null)
15896
+ return null;
15897
+ const activity = value;
15898
+ const time3 = (field) => field === null || count(field);
15899
+ return time3(activity.firstActivityAt) && time3(activity.lastActivityAt) && count(activity.activeMs) && count(activity.turns) && count(activity.edits) && typeof activity.editing === "boolean" ? {
15900
+ firstActivityAt: activity.firstActivityAt,
15901
+ lastActivityAt: activity.lastActivityAt,
15902
+ activeMs: activity.activeMs,
15903
+ turns: activity.turns,
15904
+ edits: activity.edits,
15905
+ editing: activity.editing
15906
+ } : null;
15907
+ }
15908
+ function recordNativeSessionActivity(activity, time3) {
15909
+ if (activity.firstActivityAt === null || time3 < activity.firstActivityAt) {
15910
+ activity.firstActivityAt = time3;
15911
+ }
15912
+ if (activity.lastActivityAt !== null) {
15913
+ const gap = time3 - activity.lastActivityAt;
15914
+ if (gap > 0 && gap <= NATIVE_SESSION_IDLE_GAP_MS)
15915
+ activity.activeMs += gap;
15916
+ if (gap <= 0)
15917
+ return;
15918
+ }
15919
+ activity.lastActivityAt = time3;
15920
+ }
15921
+ function startNativeSessionTurn(activity) {
15922
+ if (activity.editing)
15923
+ activity.edits += 1;
15924
+ activity.editing = false;
15925
+ activity.turns += 1;
15926
+ }
15927
+ function recordNativeSessionEdit(activity) {
15928
+ activity.editing = true;
15929
+ }
15930
+ function nativeSessionEdits(activity) {
15931
+ return activity.edits + (activity.editing ? 1 : 0);
15932
+ }
15933
+
15656
15934
  // ../../harness-adapter/dist/live-command-catalog.js
15657
15935
  var COMMON_EXCLUDED_LIVE_COMMANDS = /* @__PURE__ */ new Set([
15658
15936
  // Session lifecycle
@@ -15734,8 +16012,8 @@ function liveHarnessCommandPrompt(catalog, idPrefix, commandId, argumentText) {
15734
16012
  const descriptor = catalog.commands.find(({ id }) => id === commandId);
15735
16013
  if (!descriptor)
15736
16014
  return null;
15737
- const text = typeof argumentText === "string" ? argumentText.trim() : "";
15738
- return text ? `${descriptor.invocation} ${text}` : descriptor.invocation;
16015
+ const text2 = typeof argumentText === "string" ? argumentText.trim() : "";
16016
+ return text2 ? `${descriptor.invocation} ${text2}` : descriptor.invocation;
15739
16017
  }
15740
16018
  function mergeLiveHarnessCommands(builtIns, idPrefix, live, exclusions = {}) {
15741
16019
  if (!live)
@@ -16680,7 +16958,7 @@ var BrokeredHarnessAdapter = class {
16680
16958
 
16681
16959
  // dist/claude-code-adapter.js
16682
16960
  import { randomUUID as randomUUID3 } from "node:crypto";
16683
- import path12 from "node:path";
16961
+ import path13 from "node:path";
16684
16962
 
16685
16963
  // ../../../node_modules/@anthropic-ai/claude-agent-sdk/sdk.mjs
16686
16964
  import { createRequire as DW } from "node:module";
@@ -42371,6 +42649,11 @@ var ClaudeBackgroundOccupancy = class {
42371
42649
  }
42372
42650
  };
42373
42651
 
42652
+ // dist/claude-native-usage.js
42653
+ import { createReadStream as createReadStream2 } from "node:fs";
42654
+ import { opendir as opendir2, stat as stat2 } from "node:fs/promises";
42655
+ import path3 from "node:path";
42656
+
42374
42657
  // dist/claude-session-import.js
42375
42658
  import { createReadStream } from "node:fs";
42376
42659
  import { opendir, realpath, stat } from "node:fs/promises";
@@ -42408,8 +42691,8 @@ function userText(message) {
42408
42691
  if (!isRecord2(message) || message.role !== "user")
42409
42692
  return null;
42410
42693
  const { content } = message;
42411
- const text = typeof content === "string" ? cleanText(content) : Array.isArray(content) ? cleanText(content.filter((block) => isRecord2(block) && block.type === "text" && typeof block.text === "string").map((block) => String(block.text)).join(" ")) : null;
42412
- return text && !CLAUDE_INTERNAL_USER_TEXT.test(text) ? text : null;
42694
+ const text2 = typeof content === "string" ? cleanText(content) : Array.isArray(content) ? cleanText(content.filter((block) => isRecord2(block) && block.type === "text" && typeof block.text === "string").map((block) => String(block.text)).join(" ")) : null;
42695
+ return text2 && !CLAUDE_INTERNAL_USER_TEXT.test(text2) ? text2 : null;
42413
42696
  }
42414
42697
  function claudeProjectsDirectory(environment) {
42415
42698
  const home = (process.platform === "win32" ? environment.USERPROFILE : environment.HOME) || os2.homedir();
@@ -42582,14 +42865,338 @@ var ClaudeSessionImportIndex = class {
42582
42865
  }
42583
42866
  };
42584
42867
 
42868
+ // dist/claude-native-usage.js
42869
+ var NEWLINE = 10;
42870
+ var STREAMING_WINDOW_MS = 60 * 6e4;
42871
+ var offsetSchema = external_exports.number().int().nonnegative().safe();
42872
+ var knownTextSchema = external_exports.string().min(1).nullable();
42873
+ var fileSummarySchema = external_exports.strictObject({
42874
+ customTitle: knownTextSchema,
42875
+ aiTitle: knownTextSchema,
42876
+ cwd: knownTextSchema,
42877
+ model: knownTextSchema,
42878
+ activity: external_exports.custom((value) => parseNativeSessionActivity(value) !== null)
42879
+ });
42880
+ var claudeUsageCursorSchema = external_exports.strictObject({
42881
+ // Version 1 had no Session summaries; such a cursor reads everything again.
42882
+ formatVersion: external_exports.literal(2),
42883
+ /** Keyed by path relative to the projects directory. */
42884
+ files: external_exports.record(external_exports.string(), external_exports.strictObject({
42885
+ ino: external_exports.string(),
42886
+ /** Where the next usage read starts; an unfinished response is read again. */
42887
+ offset: offsetSchema,
42888
+ /** Lines before this offset are already in `summary`. */
42889
+ summarized: offsetSchema,
42890
+ summary: fileSummarySchema
42891
+ }))
42892
+ });
42893
+ var NOT_A_TURN = ["[Request interrupted by user", "<task-notification>"];
42894
+ var EDIT_TOOLS = /* @__PURE__ */ new Set(["edit", "write", "multiedit", "notebookedit"]);
42895
+ function isRecord3(value) {
42896
+ return typeof value === "object" && value !== null && !Array.isArray(value);
42897
+ }
42898
+ function missing2(error52) {
42899
+ return isRecord3(error52) && error52.code === "ENOENT";
42900
+ }
42901
+ function count2(value) {
42902
+ return typeof value === "number" && Number.isSafeInteger(value) && value > 0 ? value : 0;
42903
+ }
42904
+ function text(value) {
42905
+ return typeof value === "string" && value.length > 0 ? value : void 0;
42906
+ }
42907
+ function occurredAt(value) {
42908
+ if (typeof value !== "string")
42909
+ return null;
42910
+ const time3 = Date.parse(value);
42911
+ return Number.isFinite(time3) ? time3 : null;
42912
+ }
42913
+ async function directoryEntries(directory) {
42914
+ try {
42915
+ return await opendir2(directory);
42916
+ } catch (error52) {
42917
+ if (missing2(error52))
42918
+ return null;
42919
+ throw error52;
42920
+ }
42921
+ }
42922
+ async function usageFiles(projects) {
42923
+ const files = [];
42924
+ const projectEntries = await directoryEntries(projects);
42925
+ if (!projectEntries)
42926
+ return files;
42927
+ for await (const project of projectEntries) {
42928
+ if (!project.isDirectory())
42929
+ continue;
42930
+ const entries = await directoryEntries(path3.join(projects, project.name));
42931
+ if (!entries)
42932
+ continue;
42933
+ for await (const entry of entries) {
42934
+ if (entry.isFile() && entry.name.endsWith(".jsonl")) {
42935
+ files.push({ relative: path3.join(project.name, entry.name), main: true });
42936
+ } else if (entry.isDirectory()) {
42937
+ const subagents = path3.join(project.name, entry.name, "subagents");
42938
+ const agentEntries = await directoryEntries(path3.join(projects, subagents));
42939
+ if (!agentEntries)
42940
+ continue;
42941
+ for await (const agent of agentEntries) {
42942
+ if (agent.isFile() && agent.name.endsWith(".jsonl")) {
42943
+ files.push({ relative: path3.join(subagents, agent.name), main: false });
42944
+ }
42945
+ }
42946
+ }
42947
+ }
42948
+ }
42949
+ return files;
42950
+ }
42951
+ async function* completeLines(file2, start, end) {
42952
+ if (end <= start)
42953
+ return;
42954
+ let carry = Buffer.alloc(0);
42955
+ let carryStart = start;
42956
+ for await (const chunk of createReadStream2(file2, { start, end: end - 1 })) {
42957
+ const buffer = carry.length > 0 ? Buffer.concat([carry, chunk]) : chunk;
42958
+ let lineStart = 0;
42959
+ let newline = buffer.indexOf(NEWLINE, lineStart);
42960
+ while (newline !== -1) {
42961
+ yield {
42962
+ line: buffer.toString("utf8", lineStart, newline),
42963
+ start: carryStart + lineStart,
42964
+ end: carryStart + newline + 1
42965
+ };
42966
+ lineStart = newline + 1;
42967
+ newline = buffer.indexOf(NEWLINE, lineStart);
42968
+ }
42969
+ carry = buffer.subarray(lineStart);
42970
+ carryStart += lineStart;
42971
+ }
42972
+ }
42973
+ function usageTokens(usage) {
42974
+ const cacheWrite = count2(usage.cache_creation_input_tokens);
42975
+ const cacheWrite1h = isRecord3(usage.cache_creation) ? Math.min(count2(usage.cache_creation.ephemeral_1h_input_tokens), cacheWrite) : 0;
42976
+ return {
42977
+ input: count2(usage.input_tokens),
42978
+ cacheRead: count2(usage.cache_read_input_tokens),
42979
+ cacheWrite,
42980
+ ...cacheWrite1h > 0 ? { cacheWrite1h } : {},
42981
+ output: count2(usage.output_tokens),
42982
+ // Claude transcripts report thinking only as part of output_tokens.
42983
+ reasoning: 0
42984
+ };
42985
+ }
42986
+ function zeroTokens(tokens) {
42987
+ return tokens.input + tokens.cacheRead + tokens.cacheWrite + tokens.output + tokens.reasoning === 0;
42988
+ }
42989
+ function startsTurn(entry) {
42990
+ if (entry.isMeta === true || !isRecord3(entry.message))
42991
+ return false;
42992
+ const { content } = entry.message;
42993
+ let prompt;
42994
+ if (typeof content === "string") {
42995
+ prompt = content.trim();
42996
+ } else if (Array.isArray(content)) {
42997
+ if (content.length > 0 && content.every((block) => isRecord3(block) && block.type === "tool_result")) {
42998
+ return false;
42999
+ }
43000
+ prompt = content.flatMap((block) => isRecord3(block) && typeof block.text === "string" && block.type === "text" ? [block.text] : []).join("\n").trim();
43001
+ } else {
43002
+ return false;
43003
+ }
43004
+ return prompt.length > 0 && !NOT_A_TURN.some((notice) => prompt.startsWith(notice));
43005
+ }
43006
+ function summarize(summary, entry) {
43007
+ const cwd = text(entry.cwd);
43008
+ if (cwd)
43009
+ summary.cwd = cwd;
43010
+ const time3 = occurredAt(entry.timestamp);
43011
+ if (time3 !== null)
43012
+ recordNativeSessionActivity(summary.activity, time3);
43013
+ if (entry.type === "custom-title") {
43014
+ const title = cleanText(entry.customTitle);
43015
+ if (title)
43016
+ summary.customTitle = title;
43017
+ } else if (entry.type === "ai-title") {
43018
+ const title = cleanText(entry.aiTitle);
43019
+ if (title)
43020
+ summary.aiTitle = title;
43021
+ } else if (entry.type === "user") {
43022
+ if (startsTurn(entry))
43023
+ startNativeSessionTurn(summary.activity);
43024
+ } else if (entry.type === "assistant" && isRecord3(entry.message)) {
43025
+ const model = text(entry.message.model);
43026
+ if (model && model !== "<synthetic>")
43027
+ summary.model = model;
43028
+ const { content } = entry.message;
43029
+ if (Array.isArray(content) && content.some((block) => isRecord3(block) && block.type === "tool_use" && typeof block.name === "string" && EDIT_TOOLS.has(block.name.toLowerCase()))) {
43030
+ recordNativeSessionEdit(summary.activity);
43031
+ }
43032
+ }
43033
+ }
43034
+ function emptyFileSummary() {
43035
+ return {
43036
+ customTitle: null,
43037
+ aiTitle: null,
43038
+ cwd: null,
43039
+ model: null,
43040
+ activity: emptyNativeSessionActivity()
43041
+ };
43042
+ }
43043
+ function sessionSummary(relative, main, summary) {
43044
+ const { activity } = summary;
43045
+ const sessionId = main ? path3.basename(relative, ".jsonl") : path3.basename(path3.dirname(path3.dirname(relative)));
43046
+ if (activity.firstActivityAt === null || activity.lastActivityAt === null)
43047
+ return null;
43048
+ const title = summary.customTitle ?? summary.aiTitle;
43049
+ return {
43050
+ key: relative,
43051
+ ...main ? { nativeSessionId: sessionId } : {
43052
+ nativeSessionId: `${sessionId}/${path3.basename(relative, ".jsonl")}`,
43053
+ parentSessionId: sessionId
43054
+ },
43055
+ ...title ? { title } : {},
43056
+ ...summary.cwd ? { cwd: summary.cwd } : {},
43057
+ ...summary.model ? { model: summary.model } : {},
43058
+ firstActivityAt: activity.firstActivityAt,
43059
+ lastActivityAt: activity.lastActivityAt,
43060
+ activeMs: activity.activeMs,
43061
+ turns: activity.turns,
43062
+ edits: nativeSessionEdits(activity)
43063
+ };
43064
+ }
43065
+ function typedPrompt(entry) {
43066
+ if (entry.type !== "user" || entry.isSidechain === true || !isRecord3(entry.message))
43067
+ return false;
43068
+ const { content } = entry.message;
43069
+ return typeof content === "string" || Array.isArray(content) && content.some((block) => isRecord3(block) && block.type === "text");
43070
+ }
43071
+ function baseRecord(entry, dedupeKey, time3) {
43072
+ const nativeSessionId = text(entry.sessionId);
43073
+ if (!nativeSessionId)
43074
+ return null;
43075
+ const cwd = text(entry.cwd);
43076
+ return {
43077
+ dedupeKey,
43078
+ occurredAt: time3,
43079
+ nativeSessionId,
43080
+ ...cwd ? { cwd } : {},
43081
+ tokens: { input: 0, cacheRead: 0, cacheWrite: 0, output: 0, reasoning: 0 },
43082
+ conversations: 0
43083
+ };
43084
+ }
43085
+ async function readFileUsage(file2, input, records) {
43086
+ const { main, start, end } = input;
43087
+ const responses = /* @__PURE__ */ new Map();
43088
+ let consumed = start;
43089
+ for await (const { line, start: lineStart, end: lineEnd } of completeLines(file2, start, end)) {
43090
+ consumed = lineEnd;
43091
+ const summarizing = lineStart >= input.summarized;
43092
+ if (!summarizing && !line.includes('"usage"') && !line.includes('"type":"user"'))
43093
+ continue;
43094
+ let entry;
43095
+ try {
43096
+ entry = JSON.parse(line);
43097
+ } catch {
43098
+ continue;
43099
+ }
43100
+ if (!isRecord3(entry))
43101
+ continue;
43102
+ if (summarizing)
43103
+ summarize(input.summary, entry);
43104
+ const message = isRecord3(entry.message) ? entry.message : null;
43105
+ if (entry.type === "user") {
43106
+ const uuid3 = text(entry.uuid);
43107
+ const time4 = occurredAt(entry.timestamp);
43108
+ if (!main || !uuid3 || time4 === null || !typedPrompt(entry))
43109
+ continue;
43110
+ const record3 = baseRecord(entry, `prompt:${uuid3}`, time4);
43111
+ if (record3)
43112
+ records.push({ ...record3, conversations: 1 });
43113
+ continue;
43114
+ }
43115
+ if (entry.type !== "assistant" || !message || !isRecord3(message.usage))
43116
+ continue;
43117
+ const messageId = text(message.id);
43118
+ const time3 = occurredAt(entry.timestamp);
43119
+ if (!messageId || time3 === null)
43120
+ continue;
43121
+ const requestId = text(entry.requestId);
43122
+ const key = requestId ? `message:${messageId}:${requestId}` : `message:${messageId}`;
43123
+ const base = baseRecord(entry, key, time3);
43124
+ if (!base)
43125
+ continue;
43126
+ const model = text(message.model);
43127
+ const record2 = { ...base, ...model ? { model } : {}, tokens: usageTokens(message.usage) };
43128
+ const previous = responses.get(key);
43129
+ responses.set(key, {
43130
+ record: record2,
43131
+ firstLineStart: previous?.firstLineStart ?? lineStart,
43132
+ finished: message.stop_reason !== null && message.stop_reason !== void 0
43133
+ });
43134
+ }
43135
+ let resumeAt = consumed;
43136
+ for (const response of responses.values()) {
43137
+ if (!response.finished && input.mayStillStream) {
43138
+ resumeAt = Math.min(resumeAt, response.firstLineStart);
43139
+ continue;
43140
+ }
43141
+ if (!zeroTokens(response.record.tokens))
43142
+ records.push(response.record);
43143
+ }
43144
+ return { offset: resumeAt, consumed };
43145
+ }
43146
+ async function readClaudeNativeUsage(environment, cursor, signal, onProgress) {
43147
+ const projects = claudeProjectsDirectory(environment);
43148
+ const previous = claudeUsageCursorSchema.safeParse(cursor).data ?? {
43149
+ formatVersion: 2,
43150
+ files: {}
43151
+ };
43152
+ const next = { formatVersion: 2, files: {} };
43153
+ const records = [];
43154
+ const sessions = [];
43155
+ const files = await usageFiles(projects);
43156
+ onProgress?.({ processed: 0, total: files.length });
43157
+ for (const [index, { relative, main }] of files.entries()) {
43158
+ signal.throwIfAborted();
43159
+ const file2 = path3.join(projects, relative);
43160
+ try {
43161
+ const metadata = await stat2(file2, { bigint: true });
43162
+ const ino = metadata.ino.toString();
43163
+ const size = Number(metadata.size);
43164
+ const known = previous.files[relative];
43165
+ const continued = known && known.ino === ino && known.summarized <= size ? known : null;
43166
+ const summary = continued ? structuredClone(continued.summary) : emptyFileSummary();
43167
+ const summarized = continued?.summarized ?? 0;
43168
+ const { offset, consumed } = await readFileUsage(file2, {
43169
+ main,
43170
+ start: continued?.offset ?? 0,
43171
+ end: size,
43172
+ mayStillStream: Date.now() - Number(metadata.mtimeMs) < STREAMING_WINDOW_MS,
43173
+ summarized,
43174
+ summary
43175
+ }, records);
43176
+ const summarizedNow = Math.max(summarized, consumed);
43177
+ next.files[relative] = { ino, offset, summarized: summarizedNow, summary };
43178
+ if (summarizedNow > summarized || !continued) {
43179
+ const session = sessionSummary(relative, main, summary);
43180
+ if (session)
43181
+ sessions.push(session);
43182
+ }
43183
+ } catch (error52) {
43184
+ if (!missing2(error52))
43185
+ throw error52;
43186
+ }
43187
+ onProgress?.({ processed: index + 1, total: files.length });
43188
+ }
43189
+ return { records, sessions, cursor: next };
43190
+ }
43191
+
42585
43192
  // dist/command.js
42586
- import path5 from "node:path";
43193
+ import path6 from "node:path";
42587
43194
 
42588
43195
  // ../../harness-discovery/dist/environment.js
42589
43196
  import fs from "node:fs";
42590
- import path3 from "node:path";
43197
+ import path4 from "node:path";
42591
43198
  function targetPath(platform) {
42592
- return platform === "win32" ? path3.win32 : path3.posix;
43199
+ return platform === "win32" ? path4.win32 : path4.posix;
42593
43200
  }
42594
43201
  function environmentValue(environment, name) {
42595
43202
  const lowered = name.toLowerCase();
@@ -42632,11 +43239,11 @@ function newestFirst(names) {
42632
43239
  }
42633
43240
 
42634
43241
  // ../../harness-discovery/dist/node-runtime.js
42635
- import path4 from "node:path";
43242
+ import path5 from "node:path";
42636
43243
  function withNodeRuntimeOnPath(environment, runtimeExecutable = process.execPath, platform = process.platform) {
42637
43244
  const pathKey = Object.keys(environment).find((name) => name.toLowerCase() === "path") ?? "PATH";
42638
43245
  const delimiter = platform === "win32" ? ";" : ":";
42639
- const runtimeDirectory = path4.dirname(runtimeExecutable);
43246
+ const runtimeDirectory = path5.dirname(runtimeExecutable);
42640
43247
  const directories = (environment[pathKey] ?? "").split(delimiter).filter(Boolean);
42641
43248
  const equal = platform === "win32" ? (value) => value.toLowerCase() : (value) => value;
42642
43249
  if (!directories.some((directory) => equal(directory) === equal(runtimeDirectory))) {
@@ -42854,14 +43461,14 @@ function resolveClaudeCodeExecutable(input = {}, dependencies = {}) {
42854
43461
  }, dependencies);
42855
43462
  if (!resolution)
42856
43463
  throw new ClaudeCodeExecutableError("Claude Code is not installed");
42857
- return targetPath(platform).isAbsolute(resolution.executable) ? resolution.executable : path5.resolve(resolution.executable);
43464
+ return targetPath(platform).isAbsolute(resolution.executable) ? resolution.executable : path6.resolve(resolution.executable);
42858
43465
  }
42859
43466
 
42860
43467
  // dist/pending-session.js
42861
43468
  import { randomUUID as randomUUID2 } from "node:crypto";
42862
- import { mkdir, open, readFile as readFile2, rename, rm as rm2, stat as stat2, unlink } from "node:fs/promises";
43469
+ import { mkdir, open, readFile as readFile2, rename, rm as rm2, stat as stat3, unlink } from "node:fs/promises";
42863
43470
  import os4 from "node:os";
42864
- import path6 from "node:path";
43471
+ import path7 from "node:path";
42865
43472
  var reservationSchema = external_exports.strictObject({
42866
43473
  version: external_exports.literal(1),
42867
43474
  sessionId: external_exports.uuid(),
@@ -42874,13 +43481,13 @@ function isPendingClaudeSession(ref) {
42874
43481
  var ClaudePendingSessions = class {
42875
43482
  #directory;
42876
43483
  constructor(environment) {
42877
- this.#directory = path6.join(path6.resolve(environment.CLAUDE_CONFIG_DIR ?? path6.join(os4.homedir(), ".claude")), "codexhost", "pending-sessions");
43484
+ this.#directory = path7.join(path7.resolve(environment.CLAUDE_CONFIG_DIR ?? path7.join(os4.homedir(), ".claude")), "codexhost", "pending-sessions");
42878
43485
  }
42879
43486
  #path(ref, cwd) {
42880
- if (ref.harnessId !== "claude-code" || !external_exports.uuid().safeParse(ref.nativeSessionId).success || !external_exports.strictObject({ pendingSession: external_exports.literal(1) }).safeParse(ref.locator).success || !path6.isAbsolute(cwd)) {
43487
+ if (ref.harnessId !== "claude-code" || !external_exports.uuid().safeParse(ref.nativeSessionId).success || !external_exports.strictObject({ pendingSession: external_exports.literal(1) }).safeParse(ref.locator).success || !path7.isAbsolute(cwd)) {
42881
43488
  throw new Error("Claude Code pending Session identity is invalid");
42882
43489
  }
42883
- return path6.join(this.#directory, ref.nativeSessionId);
43490
+ return path7.join(this.#directory, ref.nativeSessionId);
42884
43491
  }
42885
43492
  async create(cwd, configuration) {
42886
43493
  const ref = nativeSessionRefSchema.parse({
@@ -42899,7 +43506,7 @@ var ClaudePendingSessions = class {
42899
43506
  await mkdir(this.#directory, { recursive: true, mode: 448 });
42900
43507
  await mkdir(directory, { mode: 448 });
42901
43508
  try {
42902
- const file2 = await open(path6.join(directory, "session.json"), "wx", 384);
43509
+ const file2 = await open(path7.join(directory, "session.json"), "wx", 384);
42903
43510
  try {
42904
43511
  await file2.writeFile(JSON.stringify(reservation));
42905
43512
  await file2.sync();
@@ -42916,13 +43523,13 @@ var ClaudePendingSessions = class {
42916
43523
  }
42917
43524
  async read(ref, cwd) {
42918
43525
  const directory = this.#path(ref, cwd);
42919
- const reservation = reservationSchema.parse(JSON.parse(await readFile2(path6.join(directory, "session.json"), "utf8")));
43526
+ const reservation = reservationSchema.parse(JSON.parse(await readFile2(path7.join(directory, "session.json"), "utf8")));
42920
43527
  if (reservation.sessionId !== ref.nativeSessionId || reservation.cwd !== cwd) {
42921
43528
  throw new Error("Claude Code pending Session does not belong to this working directory");
42922
43529
  }
42923
43530
  let started = false;
42924
43531
  try {
42925
- const claim = await stat2(path6.join(directory, "started"));
43532
+ const claim = await stat3(path7.join(directory, "started"));
42926
43533
  if (!claim.isFile())
42927
43534
  throw new Error("Claude Code pending Session claim is invalid");
42928
43535
  started = true;
@@ -42935,7 +43542,7 @@ var ClaudePendingSessions = class {
42935
43542
  async saveConfiguration(ref, cwd, configuration) {
42936
43543
  await this.read(ref, cwd);
42937
43544
  const directory = this.#path(ref, cwd);
42938
- const temporary = path6.join(directory, `${randomUUID2()}.tmp`);
43545
+ const temporary = path7.join(directory, `${randomUUID2()}.tmp`);
42939
43546
  try {
42940
43547
  const file2 = await open(temporary, "wx", 384);
42941
43548
  try {
@@ -42949,7 +43556,7 @@ var ClaudePendingSessions = class {
42949
43556
  } finally {
42950
43557
  await file2.close();
42951
43558
  }
42952
- await rename(temporary, path6.join(directory, "session.json"));
43559
+ await rename(temporary, path7.join(directory, "session.json"));
42953
43560
  await this.#sync(directory);
42954
43561
  } finally {
42955
43562
  await rm2(temporary, { force: true });
@@ -42967,7 +43574,7 @@ var ClaudePendingSessions = class {
42967
43574
  }
42968
43575
  async claim(ref, cwd) {
42969
43576
  await this.read(ref, cwd);
42970
- const claim = await open(path6.join(this.#path(ref, cwd), "started"), "wx", 384);
43577
+ const claim = await open(path7.join(this.#path(ref, cwd), "started"), "wx", 384);
42971
43578
  try {
42972
43579
  await claim.sync();
42973
43580
  } finally {
@@ -42977,7 +43584,7 @@ var ClaudePendingSessions = class {
42977
43584
  }
42978
43585
  /** Only the claim owner may release, after proven close and before submitting any native input. */
42979
43586
  async release(ref, cwd) {
42980
- await unlink(path6.join(this.#path(ref, cwd), "started"));
43587
+ await unlink(path7.join(this.#path(ref, cwd), "started"));
42981
43588
  await this.#sync(this.#path(ref, cwd));
42982
43589
  }
42983
43590
  async discard(ref, cwd) {
@@ -42986,7 +43593,7 @@ var ClaudePendingSessions = class {
42986
43593
  };
42987
43594
 
42988
43595
  // dist/claude-fork.js
42989
- import path7 from "node:path";
43596
+ import path8 from "node:path";
42990
43597
  import { isDeepStrictEqual } from "node:util";
42991
43598
 
42992
43599
  // dist/item-identity.js
@@ -42996,7 +43603,7 @@ function claudeTranscriptItemId(nativeTurnKey, kind, ordinal) {
42996
43603
 
42997
43604
  // dist/claude-history.js
42998
43605
  var claudeCodeHarnessId = harnessIdSchema.parse("claude-code");
42999
- function isRecord3(value) {
43606
+ function isRecord4(value) {
43000
43607
  return typeof value === "object" && value !== null && !Array.isArray(value);
43001
43608
  }
43002
43609
  function textParts(value) {
@@ -43004,12 +43611,12 @@ function textParts(value) {
43004
43611
  return value.length > 0 ? [value] : [];
43005
43612
  if (!Array.isArray(value))
43006
43613
  return [];
43007
- return value.flatMap((part) => isRecord3(part) && part.type === "text" && typeof part.text === "string" ? [part.text] : []);
43614
+ return value.flatMap((part) => isRecord4(part) && part.type === "text" && typeof part.text === "string" ? [part.text] : []);
43008
43615
  }
43009
43616
  function thinkingParts(value) {
43010
43617
  if (!Array.isArray(value))
43011
43618
  return [];
43012
- return value.flatMap((part) => isRecord3(part) && part.type === "thinking" && typeof part.thinking === "string" ? [part.thinking] : []);
43619
+ return value.flatMap((part) => isRecord4(part) && part.type === "thinking" && typeof part.thinking === "string" ? [part.thinking] : []);
43013
43620
  }
43014
43621
  var localCommandRecordPattern = /^\s*<(local-command-(?:stdout|caveat))>[\s\S]*<\/\1>\s*$/u;
43015
43622
  var taskNotificationRecordPattern = /^\s*<task-notification>[\s\S]*<\/task-notification>\s*$/u;
@@ -43018,33 +43625,33 @@ var controlCommandNamePattern = /<command-name>\s*\/(?:model|compact)\s*<\/comma
43018
43625
  var recapCommandNamePattern = /<command-name>\s*\/recap\s*<\/command-name>/u;
43019
43626
  var initCommandNamePattern = /<command-name>\s*\/init\s*<\/command-name>/u;
43020
43627
  var localCommandStdoutPattern = /^\s*<local-command-stdout>([\s\S]*)<\/local-command-stdout>\s*$/u;
43021
- function isLocalCommandRecord(text) {
43022
- return localCommandRecordPattern.test(text);
43628
+ function isLocalCommandRecord(text2) {
43629
+ return localCommandRecordPattern.test(text2);
43023
43630
  }
43024
- function isTaskNotificationRecord(text) {
43025
- return taskNotificationRecordPattern.test(text);
43631
+ function isTaskNotificationRecord(text2) {
43632
+ return taskNotificationRecordPattern.test(text2);
43026
43633
  }
43027
- function isControlCommandEnvelope(text) {
43028
- return commandEnvelopePattern.test(text) && controlCommandNamePattern.test(text);
43634
+ function isControlCommandEnvelope(text2) {
43635
+ return commandEnvelopePattern.test(text2) && controlCommandNamePattern.test(text2);
43029
43636
  }
43030
- function isNamedCommandEnvelope(text, namePattern) {
43031
- return commandEnvelopePattern.test(text) && namePattern.test(text);
43637
+ function isNamedCommandEnvelope(text2, namePattern) {
43638
+ return commandEnvelopePattern.test(text2) && namePattern.test(text2);
43032
43639
  }
43033
- function displayedUserText(text) {
43034
- if (isNamedCommandEnvelope(text, initCommandNamePattern))
43640
+ function displayedUserText(text2) {
43641
+ if (isNamedCommandEnvelope(text2, initCommandNamePattern))
43035
43642
  return "/init";
43036
- if (isNamedCommandEnvelope(text, recapCommandNamePattern))
43643
+ if (isNamedCommandEnvelope(text2, recapCommandNamePattern))
43037
43644
  return "/recap";
43038
- return text;
43645
+ return text2;
43039
43646
  }
43040
- function localCommandStdoutText(text) {
43041
- const match = localCommandStdoutPattern.exec(text);
43647
+ function localCommandStdoutText(text2) {
43648
+ const match = localCommandStdoutPattern.exec(text2);
43042
43649
  if (!match)
43043
43650
  return null;
43044
43651
  return match[1] ?? "";
43045
43652
  }
43046
43653
  function isTaskNotificationOrigin(value) {
43047
- return isRecord3(value.origin) && value.origin.kind === "task-notification";
43654
+ return isRecord4(value.origin) && value.origin.kind === "task-notification";
43048
43655
  }
43049
43656
  function visibleUserTextParts(message) {
43050
43657
  if (message.type !== "user" || message.syntheticUser)
@@ -43055,24 +43662,24 @@ function visibleUserTextParts(message) {
43055
43662
  return parts.filter((part) => !isLocalCommandRecord(part) && !isTaskNotificationRecord(part));
43056
43663
  }
43057
43664
  function isInterruptionRecord(value, promptId) {
43058
- if (value.type !== "user" || promptId === null || value.promptId !== promptId || value.promptSource !== void 0 || !isRecord3(value.message))
43665
+ if (value.type !== "user" || promptId === null || value.promptId !== promptId || value.promptSource !== void 0 || !isRecord4(value.message))
43059
43666
  return false;
43060
43667
  const content = value.message.content;
43061
43668
  if (!Array.isArray(content) || content.length !== 1)
43062
43669
  return false;
43063
43670
  const part = content[0];
43064
- return isRecord3(part) && part.type === "text" && (part.text === "[Request interrupted by user]" || part.text === "[Request interrupted by user for tool use]");
43671
+ return isRecord4(part) && part.type === "text" && (part.text === "[Request interrupted by user]" || part.text === "[Request interrupted by user for tool use]");
43065
43672
  }
43066
43673
  function conversationMessages(values, sessionId) {
43067
43674
  const messages = [];
43068
43675
  const ids = /* @__PURE__ */ new Set();
43069
43676
  let promptId = null;
43070
43677
  for (const value of values) {
43071
- if (!isRecord3(value))
43678
+ if (!isRecord4(value))
43072
43679
  throw new Error("Claude history contains a malformed message");
43073
43680
  if (value.type === "system")
43074
43681
  continue;
43075
- if (value.type !== "user" && value.type !== "assistant" || typeof value.uuid !== "string" || value.uuid.length === 0 || value.session_id !== sessionId || !isRecord3(value.message) || value.message.role !== value.type) {
43682
+ if (value.type !== "user" && value.type !== "assistant" || typeof value.uuid !== "string" || value.uuid.length === 0 || value.session_id !== sessionId || !isRecord4(value.message) || value.message.role !== value.type) {
43076
43683
  throw new Error("Claude history contains an invalid message identity");
43077
43684
  }
43078
43685
  if (ids.has(value.uuid))
@@ -43163,13 +43770,13 @@ function mapClaudeSnapshot(values, sessionId) {
43163
43770
  formatVersion: 1
43164
43771
  })
43165
43772
  } : {},
43166
- input: visibleUserTextParts(user).map((text) => ({
43773
+ input: visibleUserTextParts(user).map((text2) => ({
43167
43774
  type: "text",
43168
- text: displayedUserText(text)
43775
+ text: displayedUserText(text2)
43169
43776
  })),
43170
43777
  items: turnMessages.flatMap((message) => {
43171
43778
  if (message.type === "user") {
43172
- const recapOutput = visibleUserTextParts(user).some((text2) => isNamedCommandEnvelope(text2, recapCommandNamePattern)) ? textParts(message.message.content).map(localCommandStdoutText).find((text2) => text2 !== null && text2.length > 0) : void 0;
43779
+ const recapOutput = visibleUserTextParts(user).some((text3) => isNamedCommandEnvelope(text3, recapCommandNamePattern)) ? textParts(message.message.content).map(localCommandStdoutText).find((text3) => text3 !== null && text3.length > 0) : void 0;
43173
43780
  if (!recapOutput)
43174
43781
  return [];
43175
43782
  return [
@@ -43186,15 +43793,15 @@ function mapClaudeSnapshot(values, sessionId) {
43186
43793
  if (message.type !== "assistant")
43187
43794
  return [];
43188
43795
  const content = message.message.content;
43189
- const text = textParts(content).join("");
43796
+ const text2 = textParts(content).join("");
43190
43797
  const reasoning = thinkingParts(content).join("");
43191
43798
  if (!Array.isArray(content)) {
43192
- return text.length > 0 ? [
43799
+ return text2.length > 0 ? [
43193
43800
  {
43194
43801
  item: {
43195
43802
  type: "agentMessage",
43196
43803
  itemId: claudeTranscriptItemId(user.uuid, "agentMessage", agentMessageOrdinal += 1),
43197
- text
43804
+ text: text2
43198
43805
  },
43199
43806
  outcome: itemOutcome(outcome)
43200
43807
  }
@@ -43204,7 +43811,7 @@ function mapClaudeSnapshot(values, sessionId) {
43204
43811
  let projectedReasoning = false;
43205
43812
  let projectedText = false;
43206
43813
  for (const [blockIndex, block] of content.entries()) {
43207
- if (!isRecord3(block))
43814
+ if (!isRecord4(block))
43208
43815
  continue;
43209
43816
  if (block.type === "thinking" && !projectedReasoning && reasoning.length > 0) {
43210
43817
  items.push({
@@ -43218,12 +43825,12 @@ function mapClaudeSnapshot(values, sessionId) {
43218
43825
  projectedReasoning = true;
43219
43826
  continue;
43220
43827
  }
43221
- if (block.type === "text" && !projectedText && text.length > 0) {
43828
+ if (block.type === "text" && !projectedText && text2.length > 0) {
43222
43829
  items.push({
43223
43830
  item: {
43224
43831
  type: "agentMessage",
43225
43832
  itemId: claudeTranscriptItemId(user.uuid, "agentMessage", agentMessageOrdinal += 1),
43226
- text
43833
+ text: text2
43227
43834
  },
43228
43835
  outcome: itemOutcome(outcome)
43229
43836
  });
@@ -43247,7 +43854,7 @@ function mapClaudeSnapshot(values, sessionId) {
43247
43854
  }
43248
43855
  } : { status: "succeeded" };
43249
43856
  const itemId = hostItemIdSchema.parse(`claude-item-v1-${message.uuid}-tool-${blockIndex}`);
43250
- if (block.name === "Bash" && isRecord3(block.input) && typeof block.input.command === "string") {
43857
+ if (block.name === "Bash" && isRecord4(block.input) && typeof block.input.command === "string") {
43251
43858
  items.push({
43252
43859
  item: {
43253
43860
  type: "commandExecution",
@@ -43285,7 +43892,7 @@ function toolResultBlocks(messages) {
43285
43892
  if (message.type !== "user" || !Array.isArray(message.message.content))
43286
43893
  continue;
43287
43894
  for (const block of message.message.content) {
43288
- if (isRecord3(block) && block.type === "tool_result" && typeof block.tool_use_id === "string") {
43895
+ if (isRecord4(block) && block.type === "tool_result" && typeof block.tool_use_id === "string") {
43289
43896
  results.set(block.tool_use_id, block);
43290
43897
  }
43291
43898
  }
@@ -43295,12 +43902,12 @@ function toolResultBlocks(messages) {
43295
43902
  function toolResultOutput(block) {
43296
43903
  if (!block)
43297
43904
  return void 0;
43298
- const text = textParts(block.content).join("");
43299
- return text.length > 0 ? text : void 0;
43905
+ const text2 = textParts(block.content).join("");
43906
+ return text2.length > 0 ? text2 : void 0;
43300
43907
  }
43301
43908
  function resultSubagentId(value, block) {
43302
43909
  const nativeResult = value.tool_use_result;
43303
- if (isRecord3(nativeResult)) {
43910
+ if (isRecord4(nativeResult)) {
43304
43911
  const structured = nativeResult.agentId ?? nativeResult.agent_id ?? nativeResult.task_id;
43305
43912
  if (typeof structured === "string" && structured.length > 0)
43306
43913
  return structured;
@@ -43311,13 +43918,13 @@ function resultSubagentId(value, block) {
43311
43918
  function subagentPrompt(values, nativeSubagentId2) {
43312
43919
  const toolUses = /* @__PURE__ */ new Map();
43313
43920
  for (const value of values) {
43314
- if (!isRecord3(value) || !isRecord3(value.message) || !Array.isArray(value.message.content)) {
43921
+ if (!isRecord4(value) || !isRecord4(value.message) || !Array.isArray(value.message.content)) {
43315
43922
  continue;
43316
43923
  }
43317
43924
  for (const block of value.message.content) {
43318
- if (!isRecord3(block))
43925
+ if (!isRecord4(block))
43319
43926
  continue;
43320
- if (block.type === "tool_use" && typeof block.id === "string" && (block.name === "Agent" || block.name === "Task") && isRecord3(block.input) && typeof block.input.prompt === "string" && block.input.prompt.length > 0) {
43927
+ if (block.type === "tool_use" && typeof block.id === "string" && (block.name === "Agent" || block.name === "Task") && isRecord4(block.input) && typeof block.input.prompt === "string" && block.input.prompt.length > 0) {
43321
43928
  toolUses.set(block.id, block.input.prompt);
43322
43929
  continue;
43323
43930
  }
@@ -43331,7 +43938,7 @@ function subagentPrompt(values, nativeSubagentId2) {
43331
43938
  return void 0;
43332
43939
  }
43333
43940
  function mapClaudeSubagentSnapshot(values, parentSessionId, nativeSubagentId2, parentValues = []) {
43334
- const messages = conversationMessages(values.map((value) => isRecord3(value) ? { ...value, session_id: parentSessionId } : value), parentSessionId);
43941
+ const messages = conversationMessages(values.map((value) => isRecord4(value) ? { ...value, session_id: parentSessionId } : value), parentSessionId);
43335
43942
  const turns = [];
43336
43943
  for (let index = 0; index < messages.length; ) {
43337
43944
  const first = messages[index];
@@ -43358,7 +43965,7 @@ function mapClaudeSubagentSnapshot(values, parentSessionId, nativeSubagentId2, p
43358
43965
  const content = Array.isArray(message.message.content) ? message.message.content : [{ type: "text", text: message.message.content }];
43359
43966
  for (let blockIndex = 0; blockIndex < content.length; blockIndex += 1) {
43360
43967
  const block = content[blockIndex];
43361
- if (!isRecord3(block))
43968
+ if (!isRecord4(block))
43362
43969
  continue;
43363
43970
  const itemId = hostItemIdSchema.parse(`claude-subagent-item-v2-${nativeSubagentId2}-${message.uuid}-${blockIndex}`);
43364
43971
  if (block.type === "thinking" && typeof block.thinking === "string") {
@@ -43395,7 +44002,7 @@ function mapClaudeSubagentSnapshot(values, parentSessionId, nativeSubagentId2, p
43395
44002
  retryable: false
43396
44003
  }
43397
44004
  } : { status: "succeeded" };
43398
- if (block.name === "Bash" && isRecord3(block.input) && typeof block.input.command === "string") {
44005
+ if (block.name === "Bash" && isRecord4(block.input) && typeof block.input.command === "string") {
43399
44006
  items.push({
43400
44007
  item: {
43401
44008
  type: "commandExecution",
@@ -43437,7 +44044,7 @@ function mapClaudeSubagentSnapshot(values, parentSessionId, nativeSubagentId2, p
43437
44044
  formatVersion: 1
43438
44045
  })
43439
44046
  } : {},
43440
- input: user ? visibleUserTextParts(user).map((text) => ({ type: "text", text })) : turns.length === 0 ? [subagentPrompt(parentValues, nativeSubagentId2)].filter((text) => text !== void 0).map((text) => ({ type: "text", text })) : [],
44047
+ input: user ? visibleUserTextParts(user).map((text2) => ({ type: "text", text: text2 })) : turns.length === 0 ? [subagentPrompt(parentValues, nativeSubagentId2)].filter((text2) => text2 !== void 0).map((text2) => ({ type: "text", text: text2 })) : [],
43441
44048
  items,
43442
44049
  outcome
43443
44050
  });
@@ -43525,7 +44132,7 @@ async function forkClaudeSession(input) {
43525
44132
  error: error51("protocolError", "Claude Code Session working directory is unavailable", false)
43526
44133
  };
43527
44134
  }
43528
- if (path7.resolve(sourceInfo.cwd) !== input.cwd) {
44135
+ if (path8.resolve(sourceInfo.cwd) !== input.cwd) {
43529
44136
  return {
43530
44137
  ok: false,
43531
44138
  error: error51("unsupported", "Claude Code cannot Fork across working directories", false)
@@ -43626,25 +44233,25 @@ async function forkClaudeSession(input) {
43626
44233
 
43627
44234
  // dist/claude-transcript.js
43628
44235
  import os5 from "node:os";
43629
- import path8 from "node:path";
43630
- import { readFile as readFile3, readdir, stat as stat3 } from "node:fs/promises";
44236
+ import path9 from "node:path";
44237
+ import { readFile as readFile3, readdir, stat as stat4 } from "node:fs/promises";
43631
44238
  function projectDirectoryName(cwd) {
43632
44239
  return cwd.replace(/[^A-Za-z0-9]/gu, "-");
43633
44240
  }
43634
44241
  function configDirectory(environment) {
43635
- return environment.CLAUDE_CONFIG_DIR ? path8.resolve(environment.CLAUDE_CONFIG_DIR) : path8.join(os5.homedir(), ".claude");
44242
+ return environment.CLAUDE_CONFIG_DIR ? path9.resolve(environment.CLAUDE_CONFIG_DIR) : path9.join(os5.homedir(), ".claude");
43636
44243
  }
43637
44244
  async function existingFile(file2) {
43638
44245
  try {
43639
- return (await stat3(file2)).isFile();
44246
+ return (await stat4(file2)).isFile();
43640
44247
  } catch {
43641
44248
  return false;
43642
44249
  }
43643
44250
  }
43644
44251
  async function findTranscript(input) {
43645
- const projectsDirectory = path8.join(configDirectory(input.environment), "projects");
44252
+ const projectsDirectory = path9.join(configDirectory(input.environment), "projects");
43646
44253
  const name = `${input.sessionId}.jsonl`;
43647
- const expected = path8.join(projectsDirectory, projectDirectoryName(input.cwd), name);
44254
+ const expected = path9.join(projectsDirectory, projectDirectoryName(input.cwd), name);
43648
44255
  if (await existingFile(expected))
43649
44256
  return expected;
43650
44257
  let projects;
@@ -43654,13 +44261,13 @@ async function findTranscript(input) {
43654
44261
  return null;
43655
44262
  }
43656
44263
  for (const project of projects) {
43657
- const candidate = path8.join(projectsDirectory, project, name);
44264
+ const candidate = path9.join(projectsDirectory, project, name);
43658
44265
  if (await existingFile(candidate))
43659
44266
  return candidate;
43660
44267
  }
43661
44268
  return null;
43662
44269
  }
43663
- function isRecord4(value) {
44270
+ function isRecord5(value) {
43664
44271
  return typeof value === "object" && value !== null && !Array.isArray(value);
43665
44272
  }
43666
44273
  async function readClaudeTranscript(input) {
@@ -43678,7 +44285,7 @@ async function readClaudeTranscript(input) {
43678
44285
  } catch {
43679
44286
  continue;
43680
44287
  }
43681
- if (!isRecord4(entry) || entry.type !== "user" && entry.type !== "assistant" || typeof entry.uuid !== "string" || !isRecord4(entry.message)) {
44288
+ if (!isRecord5(entry) || entry.type !== "user" && entry.type !== "assistant" || typeof entry.uuid !== "string" || !isRecord5(entry.message)) {
43682
44289
  continue;
43683
44290
  }
43684
44291
  messages.push({ ...entry, session_id: input.sessionId });
@@ -43690,7 +44297,7 @@ async function readClaudeTranscript(input) {
43690
44297
  import { Buffer as Buffer2 } from "node:buffer";
43691
44298
  import { readFile as readFile4 } from "node:fs/promises";
43692
44299
  import os6 from "node:os";
43693
- import path9 from "node:path";
44300
+ import path10 from "node:path";
43694
44301
 
43695
44302
  // dist/thinking-options.js
43696
44303
  var option = (id, label) => ({
@@ -43772,7 +44379,7 @@ function decodeClaudeModelRef(ref) {
43772
44379
  return value === "default" ? void 0 : value;
43773
44380
  }
43774
44381
  function resolveClaudeConfigDirectory(environment = process.env) {
43775
- return path9.resolve(environment.CLAUDE_CONFIG_DIR ?? path9.join(os6.homedir(), ".claude"));
44382
+ return path10.resolve(environment.CLAUDE_CONFIG_DIR ?? path10.join(os6.homedir(), ".claude"));
43776
44383
  }
43777
44384
  function parseModelPickerOptions(value) {
43778
44385
  if (!Array.isArray(value))
@@ -43814,7 +44421,7 @@ function parseClaudeModelPickerSettings(value) {
43814
44421
  };
43815
44422
  }
43816
44423
  async function readClaudeUserModelPicker(environment = process.env) {
43817
- const settingsPath = path9.join(resolveClaudeConfigDirectory(environment), "settings.json");
44424
+ const settingsPath = path10.join(resolveClaudeConfigDirectory(environment), "settings.json");
43818
44425
  let raw;
43819
44426
  try {
43820
44427
  raw = await readFile4(settingsPath, "utf8");
@@ -44125,7 +44732,7 @@ function projectClaudeAccountUsage(usage, account) {
44125
44732
  }
44126
44733
 
44127
44734
  // dist/file-change.js
44128
- import path10 from "node:path";
44735
+ import path11 from "node:path";
44129
44736
  var hunkSchema = external_exports.object({
44130
44737
  oldStart: external_exports.number().int().nonnegative(),
44131
44738
  oldLines: external_exports.number().int().nonnegative(),
@@ -44133,7 +44740,7 @@ var hunkSchema = external_exports.object({
44133
44740
  newLines: external_exports.number().int().nonnegative(),
44134
44741
  lines: external_exports.array(external_exports.string())
44135
44742
  }).strict();
44136
- function isRecord5(value) {
44743
+ function isRecord6(value) {
44137
44744
  return typeof value === "object" && value !== null && !Array.isArray(value);
44138
44745
  }
44139
44746
  function validNativePath(value) {
@@ -44157,7 +44764,7 @@ function validHunk(value) {
44157
44764
  return hunk;
44158
44765
  }
44159
44766
  function parseClaudeNativeFileChange(toolName, value) {
44160
- if (toolName !== "Edit" && toolName !== "Write" || !isRecord5(value))
44767
+ if (toolName !== "Edit" && toolName !== "Write" || !isRecord6(value))
44161
44768
  return null;
44162
44769
  if (!validNativePath(value.filePath) || !Array.isArray(value.structuredPatch))
44163
44770
  return null;
@@ -44173,10 +44780,10 @@ function parseClaudeNativeFileChange(toolName, value) {
44173
44780
  };
44174
44781
  }
44175
44782
  function displayPath(nativePath, cwd) {
44176
- const resolvedCwd = path10.resolve(cwd);
44177
- const resolvedPath = path10.isAbsolute(nativePath) ? path10.resolve(nativePath) : path10.resolve(cwd, nativePath);
44178
- const relative = path10.relative(resolvedCwd, resolvedPath);
44179
- const selected = relative.length > 0 && relative !== ".." && !relative.startsWith(`..${path10.sep}`) ? relative : resolvedPath;
44783
+ const resolvedCwd = path11.resolve(cwd);
44784
+ const resolvedPath = path11.isAbsolute(nativePath) ? path11.resolve(nativePath) : path11.resolve(cwd, nativePath);
44785
+ const relative = path11.relative(resolvedCwd, resolvedPath);
44786
+ const selected = relative.length > 0 && relative !== ".." && !relative.startsWith(`..${path11.sep}`) ? relative : resolvedPath;
44180
44787
  const normalized = selected.replaceAll("\\", "/");
44181
44788
  return validNativePath(normalized) && normalized !== "." ? normalized : null;
44182
44789
  }
@@ -44188,7 +44795,7 @@ function projectClaudeFileChange(value, cwd) {
44188
44795
  `@@ -${hunk.oldStart},${hunk.oldLines} +${hunk.newStart},${hunk.newLines} @@`,
44189
44796
  ...hunk.lines
44190
44797
  ]);
44191
- const absoluteDisplayPath = path10.posix.isAbsolute(normalizedPath);
44798
+ const absoluteDisplayPath = path11.posix.isAbsolute(normalizedPath);
44192
44799
  const oldHeader = value.kind === "add" ? "/dev/null" : absoluteDisplayPath ? normalizedPath : `a/${normalizedPath}`;
44193
44800
  const newHeader = absoluteDisplayPath ? normalizedPath : `b/${normalizedPath}`;
44194
44801
  const unifiedDiff = [`--- ${oldHeader}`, `+++ ${newHeader}`, ...body, ""].join("\n");
@@ -44201,7 +44808,7 @@ var AUTHENTICATION_ERRORS = /* @__PURE__ */ new Set(["authentication_failed", "o
44201
44808
  var SUBAGENT_TOOLS = /* @__PURE__ */ new Set(["Agent", "Task", "SendMessage"]);
44202
44809
  var SUBAGENT_DESCRIPTION_LIMIT = 500;
44203
44810
  var SUBAGENT_SUMMARY_LIMIT = 2e3;
44204
- function isRecord6(value) {
44811
+ function isRecord7(value) {
44205
44812
  return typeof value === "object" && value !== null && !Array.isArray(value);
44206
44813
  }
44207
44814
  function nativeUuid(message) {
@@ -44211,12 +44818,12 @@ function parentToolUseId(message) {
44211
44818
  return typeof message.parent_tool_use_id === "string" && message.parent_tool_use_id.length > 0 ? message.parent_tool_use_id : null;
44212
44819
  }
44213
44820
  function assistantNativeMessageId(message) {
44214
- if (!isRecord6(message.message))
44821
+ if (!isRecord7(message.message))
44215
44822
  return null;
44216
44823
  return typeof message.message.id === "string" && message.message.id.length > 0 ? message.message.id : null;
44217
44824
  }
44218
44825
  function assistantContent(message) {
44219
- if (message.type !== "assistant" || !isRecord6(message.message))
44826
+ if (message.type !== "assistant" || !isRecord7(message.message))
44220
44827
  return null;
44221
44828
  return Array.isArray(message.message.content) ? message.message.content : null;
44222
44829
  }
@@ -44224,10 +44831,10 @@ function assistantText(message) {
44224
44831
  const content = assistantContent(message);
44225
44832
  if (!content)
44226
44833
  return null;
44227
- return content.flatMap((block) => isRecord6(block) && block.type === "text" && typeof block.text === "string" ? [block.text] : []).join("");
44834
+ return content.flatMap((block) => isRecord7(block) && block.type === "text" && typeof block.text === "string" ? [block.text] : []).join("");
44228
44835
  }
44229
44836
  function assistantError(message) {
44230
- return isRecord6(message) && message.type === "assistant" && typeof message.error === "string" ? message.error : null;
44837
+ return isRecord7(message) && message.type === "assistant" && typeof message.error === "string" ? message.error : null;
44231
44838
  }
44232
44839
  function boundedString(value, limit) {
44233
44840
  if (typeof value !== "string")
@@ -44238,33 +44845,33 @@ function boundedString(value, limit) {
44238
44845
  return trimmed.slice(0, limit);
44239
44846
  }
44240
44847
  function subagentDescription(argumentsValue, toolName) {
44241
- if (!isRecord6(argumentsValue))
44848
+ if (!isRecord7(argumentsValue))
44242
44849
  return `${toolName} delegation`;
44243
44850
  return boundedString(argumentsValue.description, SUBAGENT_DESCRIPTION_LIMIT) ?? boundedString(argumentsValue.summary, SUBAGENT_DESCRIPTION_LIMIT) ?? boundedString(argumentsValue.name, SUBAGENT_DESCRIPTION_LIMIT) ?? `${toolName} delegation`;
44244
44851
  }
44245
44852
  function subagentPrompt2(argumentsValue) {
44246
- if (!isRecord6(argumentsValue))
44853
+ if (!isRecord7(argumentsValue))
44247
44854
  return void 0;
44248
44855
  return boundedString(argumentsValue.prompt ?? argumentsValue.message, SUBAGENT_SUMMARY_LIMIT);
44249
44856
  }
44250
44857
  function subagentRole(argumentsValue) {
44251
- if (!isRecord6(argumentsValue))
44858
+ if (!isRecord7(argumentsValue))
44252
44859
  return void 0;
44253
44860
  return boundedString(argumentsValue.subagent_type ?? argumentsValue.agent_type, SUBAGENT_DESCRIPTION_LIMIT);
44254
44861
  }
44255
44862
  function subagentBackground(argumentsValue) {
44256
- return isRecord6(argumentsValue) && argumentsValue.run_in_background === true;
44863
+ return isRecord7(argumentsValue) && argumentsValue.run_in_background === true;
44257
44864
  }
44258
44865
  function targetedSubagentId(argumentsValue) {
44259
- if (!isRecord6(argumentsValue))
44866
+ if (!isRecord7(argumentsValue))
44260
44867
  return void 0;
44261
44868
  return boundedString(argumentsValue.to ?? argumentsValue.recipient ?? argumentsValue.agentId, SUBAGENT_DESCRIPTION_LIMIT);
44262
44869
  }
44263
44870
  function includesAuthenticationFailure(message, errors) {
44264
44871
  if (errors.some((error52) => AUTHENTICATION_ERRORS.has(error52)))
44265
44872
  return true;
44266
- const text = [message.result, ...Array.isArray(message.errors) ? message.errors : []].filter((value) => typeof value === "string").join(" ").toLowerCase();
44267
- return text.includes("not logged in") || text.includes("invalid api key") || text.includes("oauth");
44873
+ const text2 = [message.result, ...Array.isArray(message.errors) ? message.errors : []].filter((value) => typeof value === "string").join(" ").toLowerCase();
44874
+ return text2.includes("not logged in") || text2.includes("invalid api key") || text2.includes("oauth");
44268
44875
  }
44269
44876
  function failure(kind) {
44270
44877
  return { status: "failed", kind };
@@ -44276,11 +44883,11 @@ function finiteNonNegativeNumber(value) {
44276
44883
  return typeof value === "number" && Number.isFinite(value) && value >= 0;
44277
44884
  }
44278
44885
  function parseResultModelUsage(value) {
44279
- if (!isRecord6(value))
44886
+ if (!isRecord7(value))
44280
44887
  return void 0;
44281
44888
  const usage = [];
44282
44889
  for (const entry of Object.values(value)) {
44283
- if (!isRecord6(entry) || !safeNonNegativeInteger(entry.inputTokens) || !safeNonNegativeInteger(entry.outputTokens)) {
44890
+ if (!isRecord7(entry) || !safeNonNegativeInteger(entry.inputTokens) || !safeNonNegativeInteger(entry.outputTokens)) {
44284
44891
  return void 0;
44285
44892
  }
44286
44893
  usage.push({ inputTokens: entry.inputTokens, outputTokens: entry.outputTokens });
@@ -44288,7 +44895,7 @@ function parseResultModelUsage(value) {
44288
44895
  return usage;
44289
44896
  }
44290
44897
  function parseLastRequestUsage(value, attribution = {}) {
44291
- if (!isRecord6(value))
44898
+ if (!isRecord7(value))
44292
44899
  return void 0;
44293
44900
  const inputTokens = value.input_tokens;
44294
44901
  const outputTokens = value.output_tokens;
@@ -44311,7 +44918,7 @@ function parseLastRequestUsage(value, attribution = {}) {
44311
44918
  };
44312
44919
  }
44313
44920
  function assistantRequestUsage(message, provider) {
44314
- if (!isRecord6(message.message))
44921
+ if (!isRecord7(message.message))
44315
44922
  return void 0;
44316
44923
  return parseLastRequestUsage(message.message.usage, {
44317
44924
  requestId: message.message.id ?? message.request_id,
@@ -44334,7 +44941,7 @@ function parseResultUsageEvent(message) {
44334
44941
  };
44335
44942
  }
44336
44943
  function parsePlanLimitWindow(value) {
44337
- if (!isRecord6(value))
44944
+ if (!isRecord7(value))
44338
44945
  return void 0;
44339
44946
  const utilization = value.utilization;
44340
44947
  if (typeof utilization !== "number" || !Number.isFinite(utilization) || utilization < 0) {
@@ -44346,12 +44953,12 @@ function parsePlanLimitWindow(value) {
44346
44953
  return { utilizationPercent, ...resetsAtUnix !== void 0 ? { resetsAtUnix } : {} };
44347
44954
  }
44348
44955
  function parseClaudePlanLimitEvent(message) {
44349
- if (!isRecord6(message) || message.type !== "rate_limit_event")
44956
+ if (!isRecord7(message) || message.type !== "rate_limit_event")
44350
44957
  return null;
44351
44958
  const info = message.rate_limit_info;
44352
- if (!isRecord6(info))
44959
+ if (!isRecord7(info))
44353
44960
  return null;
44354
- const windows = isRecord6(info.unifiedWindows) ? info.unifiedWindows : void 0;
44961
+ const windows = isRecord7(info.unifiedWindows) ? info.unifiedWindows : void 0;
44355
44962
  let fiveHour = parsePlanLimitWindow(windows?.five_hour);
44356
44963
  let sevenDay = parsePlanLimitWindow(windows?.seven_day);
44357
44964
  if (!fiveHour && !sevenDay) {
@@ -44369,7 +44976,7 @@ function parseClaudePlanLimitEvent(message) {
44369
44976
  };
44370
44977
  }
44371
44978
  function nativeSubagentId(nativeResult, outputText) {
44372
- if (isRecord6(nativeResult)) {
44979
+ if (isRecord7(nativeResult)) {
44373
44980
  const structured = boundedString(nativeResult.agentId ?? nativeResult.agent_id ?? nativeResult.task_id, SUBAGENT_DESCRIPTION_LIMIT);
44374
44981
  if (structured)
44375
44982
  return structured;
@@ -44377,7 +44984,7 @@ function nativeSubagentId(nativeResult, outputText) {
44377
44984
  return boundedString(/agentId:\s*([A-Za-z0-9_-]+)/u.exec(outputText ?? "")?.[1], SUBAGENT_DESCRIPTION_LIMIT);
44378
44985
  }
44379
44986
  function subagentContinuesInBackground(nativeResult, outputText) {
44380
- if (isRecord6(nativeResult)) {
44987
+ if (isRecord7(nativeResult)) {
44381
44988
  if (nativeResult.isAsync === true || nativeResult.is_async === true)
44382
44989
  return true;
44383
44990
  if (nativeResult.status === "async_launched")
@@ -44386,15 +44993,15 @@ function subagentContinuesInBackground(nativeResult, outputText) {
44386
44993
  return outputText?.includes("The agent is working in the background.") ?? false;
44387
44994
  }
44388
44995
  function resultText(content, nativeResult) {
44389
- let text = "";
44996
+ let text2 = "";
44390
44997
  if (typeof content === "string") {
44391
- text = content;
44998
+ text2 = content;
44392
44999
  } else if (Array.isArray(content)) {
44393
- text = content.flatMap((block) => isRecord6(block) && block.type === "text" && typeof block.text === "string" ? [block.text] : []).join("");
45000
+ text2 = content.flatMap((block) => isRecord7(block) && block.type === "text" && typeof block.text === "string" ? [block.text] : []).join("");
44394
45001
  }
44395
- if (text.length > 0)
44396
- return text;
44397
- if (!isRecord6(nativeResult))
45002
+ if (text2.length > 0)
45003
+ return text2;
45004
+ if (!isRecord7(nativeResult))
44398
45005
  return void 0;
44399
45006
  const stdout = typeof nativeResult.stdout === "string" ? nativeResult.stdout : "";
44400
45007
  const stderr = typeof nativeResult.stderr === "string" ? nativeResult.stderr : "";
@@ -44406,13 +45013,13 @@ function userMessageText(content) {
44406
45013
  return content;
44407
45014
  if (!Array.isArray(content))
44408
45015
  return null;
44409
- const text = content.flatMap((block) => isRecord6(block) && block.type === "text" && typeof block.text === "string" ? [block.text] : []).join("");
44410
- return text.length > 0 ? text : null;
45016
+ const text2 = content.flatMap((block) => isRecord7(block) && block.type === "text" && typeof block.text === "string" ? [block.text] : []).join("");
45017
+ return text2.length > 0 ? text2 : null;
44411
45018
  }
44412
45019
  function parseClaudeTaskNotification(message) {
44413
- if (!isRecord6(message) || message.type !== "user" || !isRecord6(message.message))
45020
+ if (!isRecord7(message) || message.type !== "user" || !isRecord7(message.message))
44414
45021
  return null;
44415
- if (isRecord6(message.origin) && message.origin.kind !== "task-notification")
45022
+ if (isRecord7(message.origin) && message.origin.kind !== "task-notification")
44416
45023
  return null;
44417
45024
  const content = userMessageText(message.message.content);
44418
45025
  if (!content || !content.includes("<task-notification>"))
@@ -44471,7 +45078,7 @@ var ClaudeNativeTurnAccumulator = class {
44471
45078
  this.#cancelRequested = true;
44472
45079
  }
44473
45080
  consume(message) {
44474
- if (this.#completed || !isRecord6(message))
45081
+ if (this.#completed || !isRecord7(message))
44475
45082
  return { events: [] };
44476
45083
  const events = [];
44477
45084
  this.#consumeSegmentLevel(message, events);
@@ -44485,7 +45092,7 @@ var ClaudeNativeTurnAccumulator = class {
44485
45092
  this.#consumeCompaction(message, events);
44486
45093
  this.#consumeLocalCommandOutput(message, events);
44487
45094
  }
44488
- if (message.type === "stream_event" && isRecord6(message.event)) {
45095
+ if (message.type === "stream_event" && isRecord7(message.event)) {
44489
45096
  if (!nested)
44490
45097
  this.#consumeStreamEvent(message, events);
44491
45098
  } else if (message.type === "tool_progress") {
@@ -44592,7 +45199,7 @@ var ClaudeNativeTurnAccumulator = class {
44592
45199
  if (message.subtype !== "background_tasks_changed" || !Array.isArray(message.tasks))
44593
45200
  return;
44594
45201
  const nativeSubagentIds = message.tasks.flatMap((task) => {
44595
- if (!isRecord6(task))
45202
+ if (!isRecord7(task))
44596
45203
  return [];
44597
45204
  const taskId = boundedString(task.task_id, SUBAGENT_DESCRIPTION_LIMIT);
44598
45205
  return taskId ? [taskId] : [];
@@ -44652,7 +45259,7 @@ var ClaudeNativeTurnAccumulator = class {
44652
45259
  });
44653
45260
  return;
44654
45261
  }
44655
- if (message.subtype === "task_updated" && isRecord6(message.patch)) {
45262
+ if (message.subtype === "task_updated" && isRecord7(message.patch)) {
44656
45263
  const status = taskStatus(message.patch.status);
44657
45264
  if (!status)
44658
45265
  return;
@@ -44671,14 +45278,14 @@ var ClaudeNativeTurnAccumulator = class {
44671
45278
  }
44672
45279
  #consumeStreamEvent(message, events) {
44673
45280
  const event = message.event;
44674
- if (!isRecord6(event))
45281
+ if (!isRecord7(event))
44675
45282
  return;
44676
- if (event.type === "message_start" && isRecord6(event.message) && typeof event.message.id === "string" && event.message.id.length > 0) {
45283
+ if (event.type === "message_start" && isRecord7(event.message) && typeof event.message.id === "string" && event.message.id.length > 0) {
44677
45284
  this.#activeRootStreamMessageId = event.message.id;
44678
45285
  this.#messageState(event.message.id);
44679
45286
  return;
44680
45287
  }
44681
- if (event.type !== "content_block_delta" || !isRecord6(event.delta))
45288
+ if (event.type !== "content_block_delta" || !isRecord7(event.delta))
44682
45289
  return;
44683
45290
  const messageId = this.#activeRootStreamMessageId ?? nativeUuid(message) ?? this.#nextMessageId();
44684
45291
  if (!this.#activeRootStreamMessageId)
@@ -44754,7 +45361,7 @@ var ClaudeNativeTurnAccumulator = class {
44754
45361
  }
44755
45362
  #consumeToolUseBlocks(message, events, ignoreKnownIds) {
44756
45363
  for (const block of assistantContent(message) ?? []) {
44757
- if (!isRecord6(block) || block.type !== "tool_use")
45364
+ if (!isRecord7(block) || block.type !== "tool_use")
44758
45365
  continue;
44759
45366
  const argumentsResult = jsonValueSchema.safeParse(block.input);
44760
45367
  if (typeof block.id !== "string" || block.id.length === 0 || typeof block.name !== "string" || block.name.length === 0 || !argumentsResult.success) {
@@ -44806,9 +45413,9 @@ var ClaudeNativeTurnAccumulator = class {
44806
45413
  events.push(settled);
44807
45414
  }
44808
45415
  #consumeToolResults(message, events, ignoreUnknown) {
44809
- if (!isRecord6(message.message) || !Array.isArray(message.message.content))
45416
+ if (!isRecord7(message.message) || !Array.isArray(message.message.content))
44810
45417
  return;
44811
- const resultBlocks = message.message.content.filter((block) => isRecord6(block) && block.type === "tool_result");
45418
+ const resultBlocks = message.message.content.filter((block) => isRecord7(block) && block.type === "tool_result");
44812
45419
  if (resultBlocks.length === 0)
44813
45420
  return;
44814
45421
  if (resultBlocks.length > 1 && message.tool_use_result !== void 0) {
@@ -44877,7 +45484,7 @@ var ClaudeNativeTurnAccumulator = class {
44877
45484
 
44878
45485
  // dist/process-fence.js
44879
45486
  import { execFile } from "node:child_process";
44880
- import path11 from "node:path";
45487
+ import path12 from "node:path";
44881
45488
  import { setTimeout as setTimeout2 } from "node:timers/promises";
44882
45489
  import { promisify } from "node:util";
44883
45490
  var executeFile = promisify(execFile);
@@ -44901,9 +45508,9 @@ async function closeClaudeProcessGroup(child, timeoutMs) {
44901
45508
  if (child.exitCode !== null || child.signalCode !== null)
44902
45509
  throw new Error("Claude process tree cannot be confirmed after its Windows root exited");
44903
45510
  const root = process.env.SystemRoot ?? process.env.SYSTEMROOT;
44904
- if (!root || !path11.win32.isAbsolute(root))
45511
+ if (!root || !path12.win32.isAbsolute(root))
44905
45512
  throw new Error("Windows SystemRoot is unavailable");
44906
- await executeFile(path11.win32.join(root, "System32", "taskkill.exe"), ["/PID", String(pid), "/T", "/F"], {
45513
+ await executeFile(path12.win32.join(root, "System32", "taskkill.exe"), ["/PID", String(pid), "/T", "/F"], {
44907
45514
  timeout: timeoutMs,
44908
45515
  windowsHide: true
44909
45516
  });
@@ -44990,17 +45597,17 @@ function allowsDangerouslySkipPermissions(getuid = process.getuid) {
44990
45597
  function processExited(child) {
44991
45598
  return child.exitCode !== null || child.signalCode !== null;
44992
45599
  }
44993
- function isRecord7(value) {
45600
+ function isRecord8(value) {
44994
45601
  return typeof value === "object" && value !== null && !Array.isArray(value);
44995
45602
  }
44996
45603
  function permissionModeFromMessage(value) {
44997
- if (!isRecord7(value) || value.type !== "system" || value.subtype !== "init" && value.subtype !== "status" || !("permissionMode" in value) || value.permissionMode === void 0) {
45604
+ if (!isRecord8(value) || value.type !== "system" || value.subtype !== "init" && value.subtype !== "status" || !("permissionMode" in value) || value.permissionMode === void 0) {
44998
45605
  return void 0;
44999
45606
  }
45000
45607
  return isClaudePermissionMode(value.permissionMode) ? value.permissionMode : void 0;
45001
45608
  }
45002
45609
  function parseContextUsage(value) {
45003
- if (!isRecord7(value))
45610
+ if (!isRecord8(value))
45004
45611
  throw new Error("Claude SDK context Usage is invalid");
45005
45612
  const usedTokens = value.totalTokens;
45006
45613
  const maxTokens = value.maxTokens;
@@ -45017,7 +45624,7 @@ function parseQuestions(input) {
45017
45624
  const questions = [];
45018
45625
  const questionTexts = /* @__PURE__ */ new Set();
45019
45626
  for (const value of input.questions) {
45020
- if (!isRecord7(value))
45627
+ if (!isRecord8(value))
45021
45628
  return null;
45022
45629
  const question = value.question;
45023
45630
  const header = value.header;
@@ -45028,7 +45635,7 @@ function parseQuestions(input) {
45028
45635
  const labels = /* @__PURE__ */ new Set();
45029
45636
  const options = [];
45030
45637
  for (const option2 of value.options) {
45031
- if (!isRecord7(option2) || typeof option2.label !== "string" || option2.label.length === 0 || labels.has(option2.label) || typeof option2.description !== "string") {
45638
+ if (!isRecord8(option2) || typeof option2.label !== "string" || option2.label.length === 0 || labels.has(option2.label) || typeof option2.description !== "string") {
45032
45639
  return null;
45033
45640
  }
45034
45641
  labels.add(option2.label);
@@ -45042,8 +45649,8 @@ function parseQuestions(input) {
45042
45649
  function boundedDisplayText(value, maxLength) {
45043
45650
  if (typeof value !== "string")
45044
45651
  return null;
45045
- const text = value.trim();
45046
- return text.length > 0 && text.length <= maxLength ? text : null;
45652
+ const text2 = value.trim();
45653
+ return text2.length > 0 && text2.length <= maxLength ? text2 : null;
45047
45654
  }
45048
45655
  var SESSION_PERMISSION_DESTINATIONS = /* @__PURE__ */ new Set(["session", "cliArg"]);
45049
45656
  var PERSISTENT_PERMISSION_DESTINATIONS = /* @__PURE__ */ new Set([
@@ -45070,7 +45677,7 @@ function permissionUpdateDestination(value) {
45070
45677
  return void 0;
45071
45678
  }
45072
45679
  function isPermissionUpdate(value) {
45073
- if (!isRecord7(value) || !permissionUpdateDestination(value.destination))
45680
+ if (!isRecord8(value) || !permissionUpdateDestination(value.destination))
45074
45681
  return false;
45075
45682
  if (value.type === "setMode") {
45076
45683
  return typeof value.mode === "string" && PERMISSION_MODES.has(value.mode);
@@ -45079,7 +45686,7 @@ function isPermissionUpdate(value) {
45079
45686
  return Array.isArray(value.directories) && value.directories.every((directory) => typeof directory === "string");
45080
45687
  }
45081
45688
  if (value.type === "addRules" || value.type === "replaceRules" || value.type === "removeRules") {
45082
- return typeof value.behavior === "string" && PERMISSION_BEHAVIORS.has(value.behavior) && Array.isArray(value.rules) && value.rules.every((rule) => isRecord7(rule) && typeof rule.toolName === "string" && (rule.ruleContent === void 0 || typeof rule.ruleContent === "string"));
45689
+ return typeof value.behavior === "string" && PERMISSION_BEHAVIORS.has(value.behavior) && Array.isArray(value.rules) && value.rules.every((rule) => isRecord8(rule) && typeof rule.toolName === "string" && (rule.ruleContent === void 0 || typeof rule.ruleContent === "string"));
45083
45690
  }
45084
45691
  return false;
45085
45692
  }
@@ -45251,7 +45858,7 @@ var ClaudeSdkTransport = class {
45251
45858
  return { commands: this.#slashCommands, skillNames: this.#skillNames };
45252
45859
  }
45253
45860
  #observeSlashCommands(message) {
45254
- if (!isRecord7(message) || message.type !== "system")
45861
+ if (!isRecord8(message) || message.type !== "system")
45255
45862
  return;
45256
45863
  if (message.subtype === "init" && Array.isArray(message.skills)) {
45257
45864
  this.#skillNames = new Set(message.skills.filter((name) => typeof name === "string"));
@@ -45301,7 +45908,7 @@ var ClaudeSdkTransport = class {
45301
45908
  recap(userMessageId, onEvent) {
45302
45909
  return this.runTurn("/recap", userMessageId, onEvent);
45303
45910
  }
45304
- runTurn(text, userMessageId, onEvent) {
45911
+ runTurn(text2, userMessageId, onEvent) {
45305
45912
  if (this.#closePromise || !this.#started || !this.#query) {
45306
45913
  return Promise.reject(new Error("Claude SDK transport is not started"));
45307
45914
  }
@@ -45319,7 +45926,7 @@ var ClaudeSdkTransport = class {
45319
45926
  });
45320
45927
  this.#input.push({
45321
45928
  type: "user",
45322
- message: { role: "user", content: text },
45929
+ message: { role: "user", content: text2 },
45323
45930
  parent_tool_use_id: null,
45324
45931
  session_id: this.sessionId,
45325
45932
  uuid: userMessageId,
@@ -45535,10 +46142,10 @@ var ClaudeSdkTransport = class {
45535
46142
  }
45536
46143
  }
45537
46144
  #observeBackgroundTasks(message) {
45538
- if (!isRecord7(message) || message.type !== "system")
46145
+ if (!isRecord8(message) || message.type !== "system")
45539
46146
  return;
45540
46147
  if (message.subtype === "background_tasks_changed" && Array.isArray(message.tasks)) {
45541
- this.#backgroundTasks = new Set(message.tasks.flatMap((task) => isRecord7(task) && typeof task.task_id === "string" ? [task.task_id] : []));
46148
+ this.#backgroundTasks = new Set(message.tasks.flatMap((task) => isRecord8(task) && typeof task.task_id === "string" ? [task.task_id] : []));
45542
46149
  } else if (message.subtype === "task_started" && typeof message.task_id === "string") {
45543
46150
  this.#backgroundTasks.add(message.task_id);
45544
46151
  } else if (message.subtype === "task_notification" && typeof message.task_id === "string" && ["completed", "failed", "stopped"].includes(String(message.status))) {
@@ -45588,7 +46195,7 @@ var ClaudeSdkTransport = class {
45588
46195
  events: [],
45589
46196
  nativeTurnKey: null
45590
46197
  });
45591
- if (autonomous.nativeTurnKey === null && isRecord7(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) {
46198
+ if (autonomous.nativeTurnKey === null && isRecord8(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) {
45592
46199
  autonomous.nativeTurnKey = message.uuid;
45593
46200
  }
45594
46201
  const interpreted = autonomous.accumulator.consume(message);
@@ -45931,11 +46538,11 @@ var ClaudeSubagentLifecycle = class {
45931
46538
  };
45932
46539
 
45933
46540
  // dist/task-tracker.js
45934
- function isRecord8(value) {
46541
+ function isRecord9(value) {
45935
46542
  return typeof value === "object" && value !== null && !Array.isArray(value);
45936
46543
  }
45937
46544
  function stringField(value, keys) {
45938
- if (!isRecord8(value))
46545
+ if (!isRecord9(value))
45939
46546
  return void 0;
45940
46547
  for (const key of keys) {
45941
46548
  const field = value[key];
@@ -45970,7 +46577,7 @@ var ClaudeTaskTracker = class {
45970
46577
  };
45971
46578
  }
45972
46579
  #create(args, result) {
45973
- if (!isRecord8(result) || !isRecord8(result.task))
46580
+ if (!isRecord9(result) || !isRecord9(result.task))
45974
46581
  return;
45975
46582
  const id = stringField(result.task, ["id"]);
45976
46583
  const subject = stringField(args, ["subject"]) ?? stringField(result.task, ["subject"]);
@@ -45988,7 +46595,7 @@ var ClaudeTaskTracker = class {
45988
46595
  const id = stringField(args, ["taskId", "id", "task_id"]);
45989
46596
  if (!id)
45990
46597
  return;
45991
- const status = isRecord8(args) ? taskStatus2(args.status) : void 0;
46598
+ const status = isRecord9(args) ? taskStatus2(args.status) : void 0;
45992
46599
  if (status === "deleted") {
45993
46600
  this.#tasks.delete(id);
45994
46601
  return;
@@ -46006,13 +46613,13 @@ var ClaudeTaskTracker = class {
46006
46613
  });
46007
46614
  }
46008
46615
  #replace(result) {
46009
- if (!isRecord8(result) || !Array.isArray(result.tasks))
46616
+ if (!isRecord9(result) || !Array.isArray(result.tasks))
46010
46617
  return;
46011
46618
  const next = /* @__PURE__ */ new Map();
46012
46619
  for (const value of result.tasks) {
46013
46620
  const id = stringField(value, ["id"]);
46014
46621
  const subject = stringField(value, ["subject"]);
46015
- const status = isRecord8(value) ? taskStatus2(value.status) : void 0;
46622
+ const status = isRecord9(value) ? taskStatus2(value.status) : void 0;
46016
46623
  if (!id || !subject || !status || status === "deleted")
46017
46624
  continue;
46018
46625
  const existing = this.#tasks.get(id);
@@ -46030,11 +46637,11 @@ var ClaudeTaskTracker = class {
46030
46637
  };
46031
46638
 
46032
46639
  // dist/tool-lifecycle.js
46033
- function isRecord9(value) {
46640
+ function isRecord10(value) {
46034
46641
  return typeof value === "object" && value !== null && !Array.isArray(value);
46035
46642
  }
46036
46643
  function stringField2(value, key) {
46037
- return isRecord9(value) && typeof value[key] === "string" ? value[key] : void 0;
46644
+ return isRecord10(value) && typeof value[key] === "string" ? value[key] : void 0;
46038
46645
  }
46039
46646
  function toolFailure(toolName) {
46040
46647
  return {
@@ -46043,17 +46650,17 @@ function toolFailure(toolName) {
46043
46650
  retryable: false
46044
46651
  };
46045
46652
  }
46046
- function boundedToolOutput(text, limit) {
46047
- if (!text || text.length === 0)
46653
+ function boundedToolOutput(text2, limit) {
46654
+ if (!text2 || text2.length === 0)
46048
46655
  return void 0;
46049
- const truncated = text.length > limit;
46656
+ const truncated = text2.length > limit;
46050
46657
  return {
46051
- content: [{ type: "text", text: truncated ? text.slice(0, limit) : text }],
46658
+ content: [{ type: "text", text: truncated ? text2.slice(0, limit) : text2 }],
46052
46659
  ...truncated ? { truncated: true } : {}
46053
46660
  };
46054
46661
  }
46055
46662
  function toolOutputText(output) {
46056
- return output?.content.filter((content) => content.type === "text").map(({ text }) => text).join("") ?? "";
46663
+ return output?.content.filter((content) => content.type === "text").map(({ text: text2 }) => text2).join("") ?? "";
46057
46664
  }
46058
46665
  var ClaudeToolLifecycle = class {
46059
46666
  #cwd;
@@ -46282,7 +46889,7 @@ var CONTEXT_USAGE_TTL_MS = 1e4;
46282
46889
  var CONTEXT_USAGE_FAILURE_COOLDOWN_MS = 5e3;
46283
46890
  var REQUEST_USAGE_RETRY_DELAYS_MS = [0, 100, 250, 500, 1e3];
46284
46891
  var DEFAULT_CONTINUATION_QUIESCENCE_MS = 2e3;
46285
- function isRecord10(value) {
46892
+ function isRecord11(value) {
46286
46893
  return typeof value === "object" && value !== null && !Array.isArray(value);
46287
46894
  }
46288
46895
  function safeNonNegativeInteger2(value) {
@@ -46291,7 +46898,7 @@ function safeNonNegativeInteger2(value) {
46291
46898
  function transcriptRequestUsage(messages, messageId) {
46292
46899
  for (let index = messages.length - 1; index >= 0; index -= 1) {
46293
46900
  const entry = messages[index];
46294
- if (!isRecord10(entry) || entry.type !== "assistant" || entry.parent_tool_use_id !== null && entry.parent_tool_use_id !== void 0 || !isRecord10(entry.message) || entry.message.id !== messageId || !isRecord10(entry.message.usage)) {
46901
+ if (!isRecord11(entry) || entry.type !== "assistant" || entry.parent_tool_use_id !== null && entry.parent_tool_use_id !== void 0 || !isRecord11(entry.message) || entry.message.id !== messageId || !isRecord11(entry.message.usage)) {
46295
46902
  continue;
46296
46903
  }
46297
46904
  const inputTokens = entry.message.usage.input_tokens;
@@ -46340,8 +46947,8 @@ function startupFailure(error52) {
46340
46947
  if (error52 instanceof ClaudeCodeExecutableError) {
46341
46948
  return { code: "notInstalled", message: error52.message, retryable: false };
46342
46949
  }
46343
- const text = error52 instanceof Error ? error52.message.toLowerCase() : "";
46344
- if (text.includes("not logged in") || text.includes("authentication") || text.includes("api key")) {
46950
+ const text2 = error52 instanceof Error ? error52.message.toLowerCase() : "";
46951
+ if (text2.includes("not logged in") || text2.includes("authentication") || text2.includes("api key")) {
46345
46952
  return {
46346
46953
  code: "authenticationRequired",
46347
46954
  message: "Claude Code authentication is required",
@@ -46543,7 +47150,7 @@ var ClaudeHarnessSession = class {
46543
47150
  cwd: this.#cwd,
46544
47151
  sessionId: this.#sessionId
46545
47152
  });
46546
- const ids = new Set(messages.flatMap((message) => isRecord10(message) && typeof message.uuid === "string" ? [message.uuid] : []));
47153
+ const ids = new Set(messages.flatMap((message) => isRecord11(message) && typeof message.uuid === "string" ? [message.uuid] : []));
46547
47154
  if (this.#unpersistedMessageIds.every((id) => ids.has(id))) {
46548
47155
  this.#unpersistedMessageIds = [];
46549
47156
  break;
@@ -46639,8 +47246,8 @@ var ClaudeHarnessSession = class {
46639
47246
  }
46640
47247
  };
46641
47248
  }
46642
- const text = command.input.map((input) => input.text).join("\n");
46643
- if (text.length === 0) {
47249
+ const text2 = command.input.map((input) => input.text).join("\n");
47250
+ if (text2.length === 0) {
46644
47251
  return {
46645
47252
  ok: false,
46646
47253
  error: {
@@ -46727,7 +47334,7 @@ var ClaudeHarnessSession = class {
46727
47334
  nativeTurnKey,
46728
47335
  formatVersion: 1
46729
47336
  });
46730
- const running = transport.runTurn(text, nativeTurnRef.nativeTurnKey, (event) => {
47337
+ const running = transport.runTurn(text2, nativeTurnRef.nativeTurnKey, (event) => {
46731
47338
  this.#handleTurnEvent(active, event);
46732
47339
  });
46733
47340
  active.nativeTurnRef = nativeTurnRef;
@@ -48162,6 +48769,10 @@ var ClaudeCodeAdapter = class {
48162
48769
  };
48163
48770
  }
48164
48771
  });
48772
+ nativeUsage = Object.freeze({
48773
+ read: (cursor, onProgress) => this.#readImport((signal) => readClaudeNativeUsage(this.#environment, cursor, signal, onProgress), "Claude Code usage records could not be read; check storage access and retry"),
48774
+ resumeCommand: (nativeSessionId) => `claude --resume ${nativeSessionId}`
48775
+ });
48165
48776
  subagents = {
48166
48777
  readSnapshot: async (input) => {
48167
48778
  if (input.parent.harnessId !== this.harnessId || input.nativeSubagentId.trim().length === 0) {
@@ -48205,6 +48816,7 @@ var ClaudeCodeAdapter = class {
48205
48816
  #cancelTimeoutMs;
48206
48817
  #closeTimeoutMs;
48207
48818
  #dependencies;
48819
+ #environment;
48208
48820
  #importAbort = new AbortController();
48209
48821
  #importIndex;
48210
48822
  #importRequests = /* @__PURE__ */ new Set();
@@ -48220,6 +48832,7 @@ var ClaudeCodeAdapter = class {
48220
48832
  #accountInspection = null;
48221
48833
  constructor(options = {}, dependencies) {
48222
48834
  const environment = options.environment ?? process.env;
48835
+ this.#environment = environment;
48223
48836
  this.#importIndex = new ClaudeSessionImportIndex(environment);
48224
48837
  this.#pendingSessions = new ClaudePendingSessions(environment);
48225
48838
  this.#closeTimeoutMs = options.closeTimeoutMs ?? DEFAULT_CLOSE_TIMEOUT_MS;
@@ -48275,7 +48888,7 @@ var ClaudeCodeAdapter = class {
48275
48888
  readSubagentMessages: ({ cwd, sessionId, nativeSubagentId: nativeSubagentId2 }) => jkt(sessionId, nativeSubagentId2, { dir: cwd })
48276
48889
  };
48277
48890
  }
48278
- #readImport(operation) {
48891
+ #readImport(operation, failureMessage = "Claude Code Session discovery failed; check storage access and duplicate Session identities, then retry after closing native clients") {
48279
48892
  if (this.#importAbort.signal.aborted) {
48280
48893
  return Promise.resolve({
48281
48894
  ok: false,
@@ -48284,11 +48897,7 @@ var ClaudeCodeAdapter = class {
48284
48897
  }
48285
48898
  const request = operation(this.#importAbort.signal).then((value) => ({ ok: true, value })).catch(() => ({
48286
48899
  ok: false,
48287
- error: {
48288
- code: "unavailable",
48289
- message: "Claude Code Session discovery failed; check storage access and duplicate Session identities, then retry after closing native clients",
48290
- retryable: true
48291
- }
48900
+ error: { code: "unavailable", message: failureMessage, retryable: true }
48292
48901
  })).finally(() => this.#importRequests.delete(request));
48293
48902
  this.#importRequests.add(request);
48294
48903
  return request;
@@ -48300,7 +48909,7 @@ var ClaudeCodeAdapter = class {
48300
48909
  error: invalidState("Claude Code Adapter is closing")
48301
48910
  };
48302
48911
  }
48303
- const cwd = path12.resolve(input.cwd ?? process.cwd());
48912
+ const cwd = path13.resolve(input.cwd ?? process.cwd());
48304
48913
  if (!input.refresh) {
48305
48914
  const cached2 = this.#inspectionCache.get(cwd);
48306
48915
  if (cached2)
@@ -48481,7 +49090,7 @@ var ClaudeCodeAdapter = class {
48481
49090
  }
48482
49091
  };
48483
49092
  }
48484
- const cwd = path12.resolve(input.cwd);
49093
+ const cwd = path13.resolve(input.cwd);
48485
49094
  if (input.kind === "rollbackLastTurn") {
48486
49095
  for (const source of this.#sessions) {
48487
49096
  const ready = await source.prepareRollback(input.sourceRef.nativeSessionId);
@@ -48604,7 +49213,7 @@ var ClaudeCodeAdapter = class {
48604
49213
  };
48605
49214
 
48606
49215
  // dist/user-shell-environment.js
48607
- import path13 from "node:path";
49216
+ import path14 from "node:path";
48608
49217
  import { execFile as execFile2 } from "node:child_process";
48609
49218
  var ENVIRONMENT_MARKER = Buffer.from("\0CODEXHOST_USER_SHELL_ENV_V1\0");
48610
49219
  var ENVIRONMENT_COMMAND = "printf '\\0CODEXHOST_USER_SHELL_ENV_V1\\0'; /usr/bin/env -0";
@@ -48647,7 +49256,7 @@ async function withUserShellEnvironment(environment, dependencies) {
48647
49256
  if (platform === "win32" || !environment.HOME)
48648
49257
  return environment;
48649
49258
  const shell = environment.SHELL?.trim() || defaultShell(platform);
48650
- if (!shell || !SUPPORTED_SHELLS.has(path13.basename(shell)))
49259
+ if (!shell || !SUPPORTED_SHELLS.has(path14.basename(shell)))
48651
49260
  return environment;
48652
49261
  const cacheKey = `${platform}\0${shell}\0${environment.HOME}`;
48653
49262
  const cached2 = dependencies ? void 0 : shellEnvironmentCache.get(cacheKey);