@codexhost/cli-darwin-x64 0.10.2 → 0.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -3229,8 +3229,8 @@ var require_utils = __commonJS({
3229
3229
  }
3230
3230
  return ind;
3231
3231
  }
3232
- function removeDotSegments(path4) {
3233
- let input = path4;
3232
+ function removeDotSegments(path6) {
3233
+ let input = path6;
3234
3234
  const output = [];
3235
3235
  let nextSlash = -1;
3236
3236
  let len = 0;
@@ -3482,8 +3482,8 @@ var require_schemes = __commonJS({
3482
3482
  wsComponent.secure = void 0;
3483
3483
  }
3484
3484
  if (wsComponent.resourceName) {
3485
- const [path4, query] = wsComponent.resourceName.split("?");
3486
- wsComponent.path = path4 && path4 !== "/" ? path4 : void 0;
3485
+ const [path6, query] = wsComponent.resourceName.split("?");
3486
+ wsComponent.path = path6 && path6 !== "/" ? path6 : void 0;
3487
3487
  wsComponent.query = query;
3488
3488
  wsComponent.resourceName = void 0;
3489
3489
  }
@@ -12592,7 +12592,7 @@ var require_dist = __commonJS({
12592
12592
 
12593
12593
  // ../qoder/dist/qoder-adapter.js
12594
12594
  import { randomUUID as randomUUID2 } from "node:crypto";
12595
- import path3 from "node:path";
12595
+ import path5 from "node:path";
12596
12596
 
12597
12597
  // ../../../node_modules/zod/v4/classic/external.js
12598
12598
  var external_exports = {};
@@ -13360,10 +13360,10 @@ function mergeDefs(...defs) {
13360
13360
  function cloneDef(schema) {
13361
13361
  return mergeDefs(schema._zod.def);
13362
13362
  }
13363
- function getElementAtPath(obj, path4) {
13364
- if (!path4)
13363
+ function getElementAtPath(obj, path6) {
13364
+ if (!path6)
13365
13365
  return obj;
13366
- return path4.reduce((acc, key) => acc?.[key], obj);
13366
+ return path6.reduce((acc, key) => acc?.[key], obj);
13367
13367
  }
13368
13368
  function promiseAllObject(promisesObj) {
13369
13369
  const keys = Object.keys(promisesObj);
@@ -13772,11 +13772,11 @@ function explicitlyAborted(x3, startIndex = 0) {
13772
13772
  }
13773
13773
  return false;
13774
13774
  }
13775
- function prefixIssues(path4, issues) {
13775
+ function prefixIssues(path6, issues) {
13776
13776
  return issues.map((iss) => {
13777
13777
  var _a5;
13778
13778
  (_a5 = iss).path ?? (_a5.path = []);
13779
- iss.path.unshift(path4);
13779
+ iss.path.unshift(path6);
13780
13780
  return iss;
13781
13781
  });
13782
13782
  }
@@ -13923,16 +13923,16 @@ function flattenError(error51, mapper = (issue2) => issue2.message) {
13923
13923
  }
13924
13924
  function formatError(error51, mapper = (issue2) => issue2.message) {
13925
13925
  const fieldErrors = { _errors: [] };
13926
- const processError = (error52, path4 = []) => {
13926
+ const processError = (error52, path6 = []) => {
13927
13927
  for (const issue2 of error52.issues) {
13928
13928
  if (issue2.code === "invalid_union" && issue2.errors.length) {
13929
- issue2.errors.map((issues) => processError({ issues }, [...path4, ...issue2.path]));
13929
+ issue2.errors.map((issues) => processError({ issues }, [...path6, ...issue2.path]));
13930
13930
  } else if (issue2.code === "invalid_key") {
13931
- processError({ issues: issue2.issues }, [...path4, ...issue2.path]);
13931
+ processError({ issues: issue2.issues }, [...path6, ...issue2.path]);
13932
13932
  } else if (issue2.code === "invalid_element") {
13933
- processError({ issues: issue2.issues }, [...path4, ...issue2.path]);
13933
+ processError({ issues: issue2.issues }, [...path6, ...issue2.path]);
13934
13934
  } else {
13935
- const fullpath = [...path4, ...issue2.path];
13935
+ const fullpath = [...path6, ...issue2.path];
13936
13936
  if (fullpath.length === 0) {
13937
13937
  fieldErrors._errors.push(mapper(issue2));
13938
13938
  } else {
@@ -13959,17 +13959,17 @@ function formatError(error51, mapper = (issue2) => issue2.message) {
13959
13959
  }
13960
13960
  function treeifyError(error51, mapper = (issue2) => issue2.message) {
13961
13961
  const result = { errors: [] };
13962
- const processError = (error52, path4 = []) => {
13962
+ const processError = (error52, path6 = []) => {
13963
13963
  var _a5, _b;
13964
13964
  for (const issue2 of error52.issues) {
13965
13965
  if (issue2.code === "invalid_union" && issue2.errors.length) {
13966
- issue2.errors.map((issues) => processError({ issues }, [...path4, ...issue2.path]));
13966
+ issue2.errors.map((issues) => processError({ issues }, [...path6, ...issue2.path]));
13967
13967
  } else if (issue2.code === "invalid_key") {
13968
- processError({ issues: issue2.issues }, [...path4, ...issue2.path]);
13968
+ processError({ issues: issue2.issues }, [...path6, ...issue2.path]);
13969
13969
  } else if (issue2.code === "invalid_element") {
13970
- processError({ issues: issue2.issues }, [...path4, ...issue2.path]);
13970
+ processError({ issues: issue2.issues }, [...path6, ...issue2.path]);
13971
13971
  } else {
13972
- const fullpath = [...path4, ...issue2.path];
13972
+ const fullpath = [...path6, ...issue2.path];
13973
13973
  if (fullpath.length === 0) {
13974
13974
  result.errors.push(mapper(issue2));
13975
13975
  continue;
@@ -14001,8 +14001,8 @@ function treeifyError(error51, mapper = (issue2) => issue2.message) {
14001
14001
  }
14002
14002
  function toDotPath(_path) {
14003
14003
  const segs = [];
14004
- const path4 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
14005
- for (const seg of path4) {
14004
+ const path6 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
14005
+ for (const seg of path6) {
14006
14006
  if (typeof seg === "number")
14007
14007
  segs.push(`[${seg}]`);
14008
14008
  else if (typeof seg === "symbol")
@@ -26694,13 +26694,13 @@ function resolveRef(ref, ctx) {
26694
26694
  if (!ref.startsWith("#")) {
26695
26695
  throw new Error("External $ref is not supported, only local refs (#/...) are allowed");
26696
26696
  }
26697
- const path4 = ref.slice(1).split("/").filter(Boolean);
26698
- if (path4.length === 0) {
26697
+ const path6 = ref.slice(1).split("/").filter(Boolean);
26698
+ if (path6.length === 0) {
26699
26699
  return ctx.rootSchema;
26700
26700
  }
26701
26701
  const defsKey = ctx.version === "draft-2020-12" ? "$defs" : "definitions";
26702
- if (path4[0] === defsKey) {
26703
- const key = path4[1];
26702
+ if (path6[0] === defsKey) {
26703
+ const key = path6[1];
26704
26704
  if (!key || !ctx.defs[key]) {
26705
26705
  throw new Error(`Reference not found: ${ref}`);
26706
26706
  }
@@ -27163,6 +27163,55 @@ var credentialImportsParamsSchema = external_exports.object({
27163
27163
  request: credentialImportsRequestSchema
27164
27164
  }).strict();
27165
27165
 
27166
+ // ../../shared-contracts/dist/harness-display-settings.js
27167
+ var harnessDisplayEntriesSchema = external_exports.array(external_exports.strictObject({
27168
+ agent: external_exports.string().min(1).max(128),
27169
+ section: external_exports.enum(["main", "more", "auto"])
27170
+ })).max(256).refine((entries) => new Set(entries.map((entry) => entry.agent)).size === entries.length, "Duplicate Harness IDs");
27171
+ var harnessDisplaySettingsSchema = external_exports.strictObject({
27172
+ entries: harnessDisplayEntriesSchema.nullable()
27173
+ });
27174
+ var harnessDisplayGetSchema = external_exports.strictObject({});
27175
+ var harnessDisplaySetSchema = external_exports.strictObject({
27176
+ entries: harnessDisplayEntriesSchema,
27177
+ /** Import legacy Desktop preferences only if no shared settings exist yet. */
27178
+ initializeOnly: external_exports.boolean().optional()
27179
+ });
27180
+
27181
+ // ../../shared-contracts/dist/console.js
27182
+ var consoleAnnouncementSchema = external_exports.strictObject({
27183
+ title: external_exports.string().trim().min(1).max(200),
27184
+ type: external_exports.enum(["info", "warning", "danger"]),
27185
+ body: external_exports.string().trim().min(1).max(16 * 1024)
27186
+ });
27187
+ var consoleOpenParamsSchema = external_exports.strictObject({});
27188
+ var consoleOpenResultSchema = external_exports.strictObject({
27189
+ /** The console address. */
27190
+ url: external_exports.string().max(2048).regex(/^http:\/\/(?:127\.0\.0\.1|localhost):\d{1,5}\/(?:\?.*)?$/u)
27191
+ });
27192
+ var CONSOLE_HOST_METHODS = Object.freeze([
27193
+ "codexhost/harness/plugins/list",
27194
+ "codexhost/harness/display-settings/get",
27195
+ "codexhost/harness/display-settings/set",
27196
+ "codexhost/harness/inspect",
27197
+ "codexhost/harness/launch-settings/get",
27198
+ "codexhost/harness/launch-settings/set",
27199
+ "codexhost/harness/web-ui/open",
27200
+ "codexhost/harness/accounts/sources",
27201
+ "codexhost/harness/accounts/list",
27202
+ "codexhost/harness/accounts/inspect",
27203
+ "codexhost/harness/credential-imports",
27204
+ "codexhost/harness/session-import/sources",
27205
+ "codexhost/harness/session-import/list",
27206
+ "codexhost/harness/session-import/import",
27207
+ "codexhost/account/list",
27208
+ "codexhost/account/refresh",
27209
+ "codexhost/account/usage/inspect",
27210
+ "codexhost/update/check",
27211
+ "codexhost/update/start",
27212
+ "codexhost/update/status"
27213
+ ]);
27214
+
27166
27215
  // ../../shared-contracts/dist/version.js
27167
27216
  var WORKSPACE_CONTRACT_VERSION = 1;
27168
27217
 
@@ -27216,6 +27265,12 @@ var hostTurnIdSchema = opaqueIdSchema.brand();
27216
27265
  var hostItemIdSchema = opaqueIdSchema.brand();
27217
27266
  var hostInteractionIdSchema = opaqueIdSchema.brand();
27218
27267
 
27268
+ // ../../shared-contracts/dist/manual-compaction.js
27269
+ var threadManualCompactionStartedSchema = external_exports.strictObject({
27270
+ threadId: hostThreadIdSchema,
27271
+ turnId: hostTurnIdSchema
27272
+ });
27273
+
27219
27274
  // ../../shared-contracts/dist/thread-usage.js
27220
27275
  var nonNegativeSafeIntegerSchema = external_exports.number().int().safe().nonnegative();
27221
27276
  var finiteNonNegativeNumberSchema = external_exports.number().finite().nonnegative();
@@ -27276,6 +27331,10 @@ var threadUsageSnapshotSchema = external_exports.object({
27276
27331
  var usagePercentSchema = external_exports.number().finite().min(0).max(100);
27277
27332
  var accountCreditsProductUsageSchema = external_exports.object({
27278
27333
  product: external_exports.string().min(1),
27334
+ used: external_exports.number().finite().nonnegative().optional(),
27335
+ // Zero is a real empty cap, not an absent field.
27336
+ limit: external_exports.number().finite().nonnegative().optional(),
27337
+ unit: external_exports.string().min(1).max(32).optional(),
27279
27338
  usagePercent: usagePercentSchema,
27280
27339
  resetsAt: external_exports.string().min(1).optional()
27281
27340
  }).strict();
@@ -27285,6 +27344,10 @@ var accountResetCreditsSchema = external_exports.object({
27285
27344
  expiresAt: external_exports.array(external_exports.string().min(1)).min(1).max(32).optional()
27286
27345
  }).strict();
27287
27346
  var accountCreditsSnapshotSchema = external_exports.object({
27347
+ used: external_exports.number().finite().nonnegative().optional(),
27348
+ // Zero is a real empty cap, not an absent field.
27349
+ limit: external_exports.number().finite().nonnegative().optional(),
27350
+ unit: external_exports.string().min(1).max(32).optional(),
27288
27351
  /** Native label when the primary limit is scoped to a model or product group. */
27289
27352
  label: external_exports.string().min(1).optional(),
27290
27353
  usedPercent: usagePercentSchema,
@@ -27304,12 +27367,27 @@ var threadUsageInspectionSchema = external_exports.object({
27304
27367
  }).strict();
27305
27368
 
27306
27369
  // ../../shared-contracts/dist/harness-accounts.js
27307
- var harnessAccountSnapshotSchema = external_exports.object({
27370
+ var accountBalanceSnapshotSchema = external_exports.object({
27371
+ amount: external_exports.number().finite().nonnegative(),
27372
+ /** ISO 4217 code as reported by the Provider, for example `CNY`. */
27373
+ currency: external_exports.string().trim().min(1).max(8),
27374
+ /** Native label when the Harness exposes several Billing Sources. */
27375
+ label: external_exports.string().trim().min(1).max(128).optional()
27376
+ }).strict();
27377
+ var harnessAccountSnapshotObject = external_exports.object({
27308
27378
  email: external_exports.string().trim().min(1).max(320).optional(),
27309
27379
  label: external_exports.string().trim().min(1).max(256).optional(),
27310
27380
  plan: external_exports.string().trim().min(1).max(128).optional(),
27311
- credits: accountCreditsSnapshotSchema
27381
+ credits: accountCreditsSnapshotSchema.optional(),
27382
+ balance: accountBalanceSnapshotSchema.optional()
27312
27383
  }).strict();
27384
+ function requireReportedQuota(schema) {
27385
+ return schema.refine((value) => {
27386
+ const reported = value;
27387
+ return reported.credits !== void 0 || reported.balance !== void 0;
27388
+ }, { message: "Account must report either credits or a balance" });
27389
+ }
27390
+ var harnessAccountSnapshotSchema = requireReportedQuota(harnessAccountSnapshotObject);
27313
27391
  var harnessAccountIdentityShape = {
27314
27392
  harnessId: harnessIdSchema,
27315
27393
  harnessName: external_exports.string().trim().min(1).max(128)
@@ -27320,11 +27398,13 @@ var harnessAccountSourceListResultSchema = external_exports.object({ sources: ex
27320
27398
  var harnessAccountInspectParamsSchema = external_exports.object({ harnessId: harnessIdSchema, refresh: external_exports.boolean().optional() }).strict();
27321
27399
  var harnessAccountInspectResultSchema = external_exports.object({
27322
27400
  ...harnessAccountIdentityShape,
27323
- account: harnessAccountSnapshotSchema.nullable()
27401
+ account: harnessAccountSnapshotSchema.nullable(),
27402
+ /** Every Billing Source from one Harness; `account` remains the first for older clients. */
27403
+ accounts: external_exports.array(harnessAccountSnapshotSchema).max(8).optional()
27324
27404
  }).strict();
27325
27405
  var harnessAccountListParamsSchema = external_exports.object({ refresh: external_exports.boolean().optional() }).strict();
27326
27406
  var harnessAccountListResultSchema = external_exports.object({
27327
- accounts: external_exports.array(harnessAccountSnapshotSchema.extend(harnessAccountIdentityShape)).max(128)
27407
+ accounts: external_exports.array(requireReportedQuota(harnessAccountSnapshotObject.extend(harnessAccountIdentityShape))).max(128)
27328
27408
  }).strict();
27329
27409
 
27330
27410
  // ../../shared-contracts/dist/json-value.js
@@ -27462,6 +27542,8 @@ var harnessModelSchema = external_exports.object({
27462
27542
  ref: harnessModelRefSchema,
27463
27543
  label: nonBlankTextSchema2.max(HARNESS_MODEL_LABEL_MAX_LENGTH),
27464
27544
  resolvedModelLabel: harnessResolvedModelLabelSchema.optional(),
27545
+ /** Optional opaque selection for this same Model with priority processing enabled. */
27546
+ fastModel: harnessModelRefSchema.optional(),
27465
27547
  supportedThinkingOptionIds: external_exports.array(harnessThinkingOptionIdSchema).optional()
27466
27548
  }).strict();
27467
27549
  var harnessThinkingOptionsSchema = external_exports.array(harnessThinkingOptionSchema).superRefine((options, context) => {
@@ -27494,6 +27576,16 @@ var harnessModelCatalogSchema = external_exports.object({
27494
27576
  });
27495
27577
  }
27496
27578
  refs.add(model.ref.id);
27579
+ if (model.fastModel) {
27580
+ if (refs.has(model.fastModel.id) || catalog.models.some((entry) => entry.ref.id === model.fastModel?.id)) {
27581
+ context.addIssue({
27582
+ code: "custom",
27583
+ message: "Fast Model refs must be distinct and unique",
27584
+ path: ["models", index, "fastModel"]
27585
+ });
27586
+ }
27587
+ refs.add(model.fastModel.id);
27588
+ }
27497
27589
  const supportedThinkingIds = /* @__PURE__ */ new Set();
27498
27590
  for (const [optionIndex, optionId] of (model.supportedThinkingOptionIds ?? []).entries()) {
27499
27591
  if (supportedThinkingIds.has(optionId)) {
@@ -27613,11 +27705,13 @@ var threadThinkingSelectParamsSchema = external_exports.object({
27613
27705
  thinkingOptionId: harnessThinkingOptionIdSchema
27614
27706
  }).strict();
27615
27707
  var threadInspectionParamsSchema = external_exports.object({
27616
- threadId: hostThreadIdSchema
27708
+ threadId: hostThreadIdSchema,
27709
+ includeReferenceCapability: external_exports.boolean().optional()
27617
27710
  }).strict();
27618
27711
  var codexThreadInspectionSchema = external_exports.object({
27619
27712
  owner: external_exports.literal("codex"),
27620
- locked: external_exports.literal(true)
27713
+ locked: external_exports.literal(true),
27714
+ supportsThreadReferences: external_exports.literal(true).optional()
27621
27715
  }).strict();
27622
27716
  var externalThreadInspectionSchema = external_exports.object({
27623
27717
  owner: external_exports.literal("external"),
@@ -27743,6 +27837,19 @@ var harnessLaunchSettingsSchema = external_exports.object({
27743
27837
  restartRequired: external_exports.boolean()
27744
27838
  }).strict();
27745
27839
 
27840
+ // ../../shared-contracts/dist/harness-installation.js
27841
+ var harnessInstallationParamsSchema = external_exports.object({
27842
+ harnessId: harnessIdSchema,
27843
+ action: external_exports.enum(["check", "update"])
27844
+ }).strict();
27845
+ var harnessInstallationStateSchema = external_exports.object({
27846
+ currentVersion: external_exports.string().min(1).max(128),
27847
+ latestVersion: external_exports.string().min(1).max(128),
27848
+ updateAvailable: external_exports.boolean(),
27849
+ canUpdate: external_exports.boolean(),
27850
+ message: external_exports.string().max(2048).optional()
27851
+ }).strict();
27852
+
27746
27853
  // ../../shared-contracts/dist/codex-accounts.js
27747
27854
  var accountIdSchema = external_exports.string().min(1).max(256).regex(/^[A-Za-z0-9._~-]+$/u);
27748
27855
  var nonBlankTextSchema3 = external_exports.string().trim().min(1);
@@ -28046,7 +28153,7 @@ var updateStatusResultSchema = external_exports.strictObject({
28046
28153
  var workspaceContractVersionSchema = external_exports.literal(WORKSPACE_CONTRACT_VERSION);
28047
28154
 
28048
28155
  // ../qoder/dist/qoder-command.js
28049
- import path2 from "node:path";
28156
+ import path4 from "node:path";
28050
28157
 
28051
28158
  // ../../harness-discovery/dist/environment.js
28052
28159
  import fs from "node:fs";
@@ -28094,6 +28201,36 @@ function newestFirst(names) {
28094
28201
  return [...names].sort((left, right) => right.localeCompare(left, void 0, { numeric: true }));
28095
28202
  }
28096
28203
 
28204
+ // ../../harness-discovery/dist/invocation.js
28205
+ import path2 from "node:path";
28206
+ function commandInvocation(command, arguments_, environment, platform = process.platform) {
28207
+ const extension = path2.win32.extname(command).toLowerCase();
28208
+ if (platform !== "win32" || ![".cmd", ".bat"].includes(extension)) {
28209
+ return { command, arguments: [...arguments_], windowsVerbatimArguments: false };
28210
+ }
28211
+ const quote = (value) => `"${value.replaceAll("%", "%%").replaceAll('"', '""')}"`;
28212
+ const commandLine = [command, ...arguments_].map(quote).join(" ");
28213
+ return {
28214
+ command: environmentValue(environment, "ComSpec") ?? "cmd.exe",
28215
+ arguments: ["/d", "/v:off", "/s", "/c", `"${commandLine}"`],
28216
+ windowsVerbatimArguments: true
28217
+ };
28218
+ }
28219
+
28220
+ // ../../harness-discovery/dist/node-runtime.js
28221
+ import path3 from "node:path";
28222
+ function withNodeRuntimeOnPath(environment, runtimeExecutable = process.execPath, platform = process.platform) {
28223
+ const pathKey = Object.keys(environment).find((name) => name.toLowerCase() === "path") ?? "PATH";
28224
+ const delimiter = platform === "win32" ? ";" : ":";
28225
+ const runtimeDirectory = path3.dirname(runtimeExecutable);
28226
+ const directories = (environment[pathKey] ?? "").split(delimiter).filter(Boolean);
28227
+ const equal = platform === "win32" ? (value) => value.toLowerCase() : (value) => value;
28228
+ if (!directories.some((directory) => equal(directory) === equal(runtimeDirectory))) {
28229
+ directories.push(runtimeDirectory);
28230
+ }
28231
+ return { ...environment, [pathKey]: directories.join(delimiter) };
28232
+ }
28233
+
28097
28234
  // ../../harness-discovery/dist/resolve.js
28098
28235
  import os from "node:os";
28099
28236
 
@@ -28257,6 +28394,101 @@ function resolveHarnessExecutable(spec, input, dependencies = {}) {
28257
28394
  return void 0;
28258
28395
  }
28259
28396
 
28397
+ // ../../harness-discovery/dist/installation.js
28398
+ import { execFile } from "node:child_process";
28399
+ import { homedir } from "node:os";
28400
+ function runInstallationCommand(command, args, environment, timeout = 3e4) {
28401
+ const env = withNodeRuntimeOnPath(environment);
28402
+ const invocation = /\.[cm]?js$/i.test(command) ? commandInvocation(process.execPath, [command, ...args], env) : commandInvocation(command, args, env);
28403
+ return new Promise((resolve, reject) => {
28404
+ const child = execFile(invocation.command, invocation.arguments, {
28405
+ env,
28406
+ cwd: env.HOME ?? env.USERPROFILE ?? homedir(),
28407
+ encoding: "utf8",
28408
+ timeout,
28409
+ killSignal: "SIGKILL",
28410
+ maxBuffer: 1024 * 1024,
28411
+ windowsHide: true,
28412
+ windowsVerbatimArguments: invocation.windowsVerbatimArguments
28413
+ }, (error51, stdout, stderr) => {
28414
+ if (error51)
28415
+ reject(new Error(error51.killed ? "Harness command timed out" : "Harness command failed; check the native installation and retry"));
28416
+ else
28417
+ resolve((stdout || stderr).trim());
28418
+ });
28419
+ child.stdin?.end();
28420
+ });
28421
+ }
28422
+ function installationVersion(value) {
28423
+ if (typeof value !== "string" || !/^v?\d+(?:\.\d+){1,3}(?:-[\w.-]+)?(?:\+[\w.-]+)?$/.test(value.trim()))
28424
+ throw new Error("Harness returned an invalid version");
28425
+ return value.trim().replace(/^v/, "");
28426
+ }
28427
+ function versionFromOutput(output) {
28428
+ return installationVersion(output.match(/\b\d+(?:\.\d+){1,3}(?:-[\w.-]+)?(?:\+[\w.-]+)?\b/)?.[0]);
28429
+ }
28430
+ function newerInstallationVersion(current, latest) {
28431
+ const a = installationVersion(current).replace(/\+.*/, "");
28432
+ const b = installationVersion(latest).replace(/\+.*/, "");
28433
+ const coreA = a.replace(/-.*/, "").split(".").map(BigInt);
28434
+ const coreB = b.replace(/-.*/, "").split(".").map(BigInt);
28435
+ for (let i = 0; i < Math.max(coreA.length, coreB.length); i++) {
28436
+ if ((coreA[i] ?? 0n) !== (coreB[i] ?? 0n))
28437
+ return (coreB[i] ?? 0n) > (coreA[i] ?? 0n);
28438
+ }
28439
+ const preA = a.includes("-") ? a.slice(a.indexOf("-") + 1).split(".") : [];
28440
+ const preB = b.includes("-") ? b.slice(b.indexOf("-") + 1).split(".") : [];
28441
+ if (!preA.length || !preB.length)
28442
+ return !!preA.length && !preB.length;
28443
+ for (let i = 0; i < Math.max(preA.length, preB.length); i++) {
28444
+ const x3 = preA[i];
28445
+ const y = preB[i];
28446
+ if (x3 === y)
28447
+ continue;
28448
+ if (x3 === void 0 || y === void 0)
28449
+ return x3 === void 0;
28450
+ const numericX = /^\d+$/.test(x3);
28451
+ const numericY = /^\d+$/.test(y);
28452
+ if (numericX && numericY) {
28453
+ if (BigInt(x3) === BigInt(y))
28454
+ continue;
28455
+ return BigInt(y) > BigInt(x3);
28456
+ }
28457
+ if (numericX !== numericY)
28458
+ return numericX;
28459
+ return y > x3;
28460
+ }
28461
+ return false;
28462
+ }
28463
+ function createInstallationManager(options) {
28464
+ let checking;
28465
+ let updating;
28466
+ const check2 = () => checking ??= options.check().finally(() => {
28467
+ checking = void 0;
28468
+ });
28469
+ return (action) => {
28470
+ if (updating)
28471
+ return updating;
28472
+ if (action === "check")
28473
+ return check2();
28474
+ updating = (async () => {
28475
+ const before = await check2();
28476
+ if (!before.updateAvailable)
28477
+ return before;
28478
+ if (!before.canUpdate)
28479
+ throw new Error(before.message ?? "This installation cannot be updated automatically");
28480
+ await options.update(before);
28481
+ const after = await check2();
28482
+ if (after.currentVersion === before.currentVersion)
28483
+ throw new Error("The Harness version did not change; check the native updater and retry");
28484
+ return after;
28485
+ })().finally(() => {
28486
+ updating = void 0;
28487
+ });
28488
+ return updating;
28489
+ };
28490
+ }
28491
+
28260
28492
  // ../qoder/dist/qoder-command.js
28261
28493
  var QoderExecutableError = class extends Error {
28262
28494
  code = "QODER_NOT_FOUND";
@@ -28320,7 +28552,52 @@ function resolveQoderExecutable(input = {}, dependencies = {}) {
28320
28552
  }, dependencies);
28321
28553
  if (!resolution)
28322
28554
  throw new QoderExecutableError("Qoder CLI is not installed");
28323
- return targetPath(platform).isAbsolute(resolution.executable) ? resolution.executable : path2.resolve(resolution.executable);
28555
+ return targetPath(platform).isAbsolute(resolution.executable) ? resolution.executable : path4.resolve(resolution.executable);
28556
+ }
28557
+
28558
+ // ../qoder/dist/qoder-account.js
28559
+ var record2 = (value) => value && typeof value === "object" && !Array.isArray(value) ? value : {};
28560
+ var nonnegative = (value) => typeof value === "number" && Number.isFinite(value) && value >= 0;
28561
+ function creditAmount(used, limit, unit) {
28562
+ if (!nonnegative(used) || !nonnegative(limit))
28563
+ return void 0;
28564
+ return {
28565
+ used,
28566
+ limit,
28567
+ unit: typeof unit === "string" && unit.trim() ? unit : "credits"
28568
+ };
28569
+ }
28570
+ function projectQoderAccount(usage, identity) {
28571
+ const data = record2(usage);
28572
+ const account = record2(identity);
28573
+ const quota = record2(data.userQuota);
28574
+ const shared = record2(data.orgResourcePackage);
28575
+ const nativePercent = quota.percentage ?? data.totalUsagePercentage;
28576
+ const usedPercent = nonnegative(nativePercent) ? Math.min(100, nativePercent) : nonnegative(quota.used) && nonnegative(quota.total) && quota.total > 0 ? Math.min(100, quota.used / quota.total * 100) : void 0;
28577
+ if (usedPercent === void 0)
28578
+ return null;
28579
+ const result = harnessAccountSnapshotSchema.safeParse({
28580
+ ...typeof account.email === "string" && account.email ? { email: account.email } : {},
28581
+ ...typeof account.subscriptionType === "string" && account.subscriptionType ? { plan: account.subscriptionType } : typeof data.userType === "string" ? { plan: data.userType } : {},
28582
+ credits: {
28583
+ usedPercent,
28584
+ periodType: "unknown",
28585
+ label: "Plan credits",
28586
+ ...shared.available === true && nonnegative(shared.percentage) && nonnegative(shared.used) && nonnegative(shared.cap) && shared.cap > 0 ? {
28587
+ productUsage: [
28588
+ {
28589
+ product: "Shared resource credits",
28590
+ usagePercent: Math.min(100, shared.percentage),
28591
+ used: shared.used,
28592
+ limit: shared.cap,
28593
+ unit: typeof shared.unit === "string" ? shared.unit : "credits"
28594
+ }
28595
+ ]
28596
+ } : {},
28597
+ ...creditAmount(quota.used, quota.total, quota.unit)
28598
+ }
28599
+ });
28600
+ return result.success ? result.data : null;
28324
28601
  }
28325
28602
 
28326
28603
  // ../qoder/dist/qoder-errors.js
@@ -29819,8 +30096,8 @@ function getErrorMap2() {
29819
30096
 
29820
30097
  // ../../../node_modules/zod/v3/helpers/parseUtil.js
29821
30098
  var makeIssue = (params) => {
29822
- const { data, path: path4, errorMaps, issueData } = params;
29823
- const fullPath = [...path4, ...issueData.path || []];
30099
+ const { data, path: path6, errorMaps, issueData } = params;
30100
+ const fullPath = [...path6, ...issueData.path || []];
29824
30101
  const fullIssue = {
29825
30102
  ...issueData,
29826
30103
  path: fullPath
@@ -29935,11 +30212,11 @@ var errorUtil;
29935
30212
 
29936
30213
  // ../../../node_modules/zod/v3/types.js
29937
30214
  var ParseInputLazyPath = class {
29938
- constructor(parent, value, path4, key) {
30215
+ constructor(parent, value, path6, key) {
29939
30216
  this._cachedPath = [];
29940
30217
  this.parent = parent;
29941
30218
  this.data = value;
29942
- this._path = path4;
30219
+ this._path = path6;
29943
30220
  this._key = key;
29944
30221
  }
29945
30222
  get path() {
@@ -33466,11 +33743,11 @@ function normalizeObjectSchema(schema) {
33466
33743
  }
33467
33744
  return void 0;
33468
33745
  }
33469
- function getDotPath(path4) {
33470
- if (path4.length === 0) {
33746
+ function getDotPath(path6) {
33747
+ if (path6.length === 0) {
33471
33748
  return "object root";
33472
33749
  }
33473
- return path4.reduce((acc, seg, index) => {
33750
+ return path6.reduce((acc, seg, index) => {
33474
33751
  if (index === 0) {
33475
33752
  return String(seg);
33476
33753
  }
@@ -52073,6 +52350,40 @@ var QoderAdapter = class {
52073
52350
  this.#getAvailableModels = options.getAvailableModels;
52074
52351
  this.#resolveExecutable = options.resolveExecutable ?? ((input, dependencies) => resolveQoderExecutable({ ...input, variant: this.#variant }, dependencies));
52075
52352
  }
52353
+ async inspectAccount() {
52354
+ let probe;
52355
+ let timer;
52356
+ try {
52357
+ const executable = this.#resolveExecutable({
52358
+ ...this.#commandOverride ? { command: this.#commandOverride } : {},
52359
+ environment: this.#environment,
52360
+ platform: this.#platform
52361
+ });
52362
+ probe = this.#queryFactory({
52363
+ prompt: "",
52364
+ options: {
52365
+ cwd: process.cwd(),
52366
+ pathToQoderCLIExecutable: executable,
52367
+ ...this.#environment ? { env: this.#environment } : {},
52368
+ auth: qoderAuthForEnvironment(this.#variant, this.#environment)
52369
+ }
52370
+ });
52371
+ return await Promise.race([
52372
+ Promise.all([probe.getUsageInfo?.(), probe.accountInfo?.().catch(() => void 0)]).then(([usage, identity]) => projectQoderAccount(usage, identity)),
52373
+ new Promise((resolve) => {
52374
+ timer = setTimeout(() => resolve(null), 1e4);
52375
+ })
52376
+ ]);
52377
+ } catch {
52378
+ return null;
52379
+ } finally {
52380
+ clearTimeout(timer);
52381
+ try {
52382
+ await probe?.close();
52383
+ } catch {
52384
+ }
52385
+ }
52386
+ }
52076
52387
  async inspect(input) {
52077
52388
  const cacheKey = input?.cwd ?? "";
52078
52389
  if (input?.refresh) {
@@ -52245,7 +52556,7 @@ var QoderAdapter = class {
52245
52556
  sourceInfo = await this.#getSessionInfo(sourceRef.data.nativeSessionId, { dir: input.cwd });
52246
52557
  } catch {
52247
52558
  }
52248
- if (sourceInfo?.cwd && path3.resolve(sourceInfo.cwd) !== path3.resolve(input.cwd)) {
52559
+ if (sourceInfo?.cwd && path5.resolve(sourceInfo.cwd) !== path5.resolve(input.cwd)) {
52249
52560
  return {
52250
52561
  ok: false,
52251
52562
  error: {
@@ -52399,13 +52710,59 @@ var QoderAdapter = class {
52399
52710
  }
52400
52711
  };
52401
52712
 
52713
+ // ../qoder/dist/installation.js
52714
+ function createQoderInstallation(environment, command, variant = "global") {
52715
+ const run = (args, timeout) => runInstallationCommand(resolveQoderExecutable({ environment, variant, ...command ? { command } : {} }), args, environment, timeout);
52716
+ return createInstallationManager({
52717
+ async check() {
52718
+ const currentVersion = versionFromOutput(await run(["--version"]));
52719
+ if (variant === "cn" && !(await run(["update", "--help"]).catch(() => "")).includes("--check"))
52720
+ return {
52721
+ currentVersion,
52722
+ latestVersion: "Unknown",
52723
+ updateAvailable: false,
52724
+ canUpdate: false,
52725
+ message: "This Qoder China release does not expose a non-installing update check. Use its original installer."
52726
+ };
52727
+ const output = await run(["update", "--check"]);
52728
+ const available = output.match(/Update available:\s*\S+\s*(?:->|\u2192)\s*(\S+)/i);
52729
+ if (available?.[1])
52730
+ return {
52731
+ currentVersion,
52732
+ latestVersion: installationVersion(available[1]),
52733
+ updateAvailable: newerInstallationVersion(currentVersion, installationVersion(available[1])),
52734
+ canUpdate: true
52735
+ };
52736
+ if (!/already\s+(?:on|at)\s+(?:the\s+)?latest|up.to.date|no updates?\s+available/i.test(output))
52737
+ throw new Error("Qoder update check returned an unknown response");
52738
+ return {
52739
+ currentVersion,
52740
+ latestVersion: currentVersion,
52741
+ updateAvailable: false,
52742
+ canUpdate: true
52743
+ };
52744
+ },
52745
+ async update() {
52746
+ await run(["update"], 3e5);
52747
+ }
52748
+ });
52749
+ }
52750
+
52751
+ // ../qoder/dist/plugin.js
52752
+ function createHarnessAdapter(context, variant = "global") {
52753
+ const environment = { ...context.environment };
52754
+ const command = environment[variant === "cn" ? CODEXHOST_QODERCN_COMMAND : CODEXHOST_QODER_COMMAND];
52755
+ return Object.assign(new QoderAdapter({
52756
+ ...command ? { commandOverride: command } : {},
52757
+ variant,
52758
+ environment,
52759
+ platform: context.platform
52760
+ }), { installation: createQoderInstallation(environment, command, variant) });
52761
+ }
52762
+
52402
52763
  // dist/plugin.js
52403
52764
  function createHarnessAdapter2(context) {
52404
- return new QoderAdapter({
52405
- variant: "cn",
52406
- environment: { ...context.environment },
52407
- platform: context.platform
52408
- });
52765
+ return createHarnessAdapter(context, "cn");
52409
52766
  }
52410
52767
  export {
52411
52768
  createHarnessAdapter2 as createHarnessAdapter