@codexhost/cli-linux-arm64 0.10.2 → 0.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (33) hide show
  1. package/README.md +1 -1
  2. package/THIRD_PARTY_NOTICES.txt +4 -0
  3. package/app/codexhost-distribution.json +1 -1
  4. package/app/console-server.mjs +18001 -0
  5. package/app/console-web.js +27674 -0
  6. package/app/desktop-controller.mjs +452 -110
  7. package/app/host-runtime.mjs +6670 -1272
  8. package/app/plugins/antigravity/plugin.mjs +686 -305
  9. package/app/plugins/claude-code/plugin.mjs +2283 -1450
  10. package/app/plugins/codebuddy/plugin.mjs +1272 -506
  11. package/app/plugins/cursor-cli/manifest.json +1 -1
  12. package/app/plugins/cursor-cli/plugin.mjs +1295 -497
  13. package/app/plugins/deepseek-harness/plugin.mjs +4718 -4925
  14. package/app/plugins/enabled.json +2 -1
  15. package/app/plugins/grok/plugin.mjs +1012 -369
  16. package/app/plugins/hermes/plugin.mjs +18587 -22714
  17. package/app/plugins/kimi-code/plugin.mjs +1283 -355
  18. package/app/plugins/kiro-cli/plugin.mjs +840 -299
  19. package/app/plugins/omp/plugin.mjs +1045 -328
  20. package/app/plugins/opencode/plugin.mjs +5341 -1686
  21. package/app/plugins/pi/plugin.mjs +1343 -534
  22. package/app/plugins/qoder/plugin.mjs +913 -258
  23. package/app/plugins/qoder-cn/plugin.mjs +712 -49
  24. package/app/plugins/workbuddy/plugin.mjs +531 -44
  25. package/app/plugins/zcode/assets/icon.svg +8 -0
  26. package/app/plugins/zcode/manifest.json +14 -0
  27. package/app/plugins/zcode/plugin.mjs +19202 -0
  28. package/app/renderer-extension.js +5011 -1899
  29. package/bin/codexhost +0 -0
  30. package/libexec/codexhost-shim +0 -0
  31. package/libexec/codexhost-updater +0 -0
  32. package/licenses/OpenCode-v2-Client-LICENSE.txt +21 -0
  33. package/package.json +1 -1
@@ -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(path7) {
3233
+ let input = path7;
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 [path7, query] = wsComponent.resourceName.split("?");
3486
+ wsComponent.path = path7 && path7 !== "/" ? path7 : 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 path6 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, path7) {
13364
+ if (!path7)
13365
13365
  return obj;
13366
- return path4.reduce((acc, key) => acc?.[key], obj);
13366
+ return path7.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(path7, 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(path7);
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, path7 = []) => {
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 }, [...path7, ...issue2.path]));
13930
13930
  } else if (issue2.code === "invalid_key") {
13931
- processError({ issues: issue2.issues }, [...path4, ...issue2.path]);
13931
+ processError({ issues: issue2.issues }, [...path7, ...issue2.path]);
13932
13932
  } else if (issue2.code === "invalid_element") {
13933
- processError({ issues: issue2.issues }, [...path4, ...issue2.path]);
13933
+ processError({ issues: issue2.issues }, [...path7, ...issue2.path]);
13934
13934
  } else {
13935
- const fullpath = [...path4, ...issue2.path];
13935
+ const fullpath = [...path7, ...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, path7 = []) => {
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 }, [...path7, ...issue2.path]));
13967
13967
  } else if (issue2.code === "invalid_key") {
13968
- processError({ issues: issue2.issues }, [...path4, ...issue2.path]);
13968
+ processError({ issues: issue2.issues }, [...path7, ...issue2.path]);
13969
13969
  } else if (issue2.code === "invalid_element") {
13970
- processError({ issues: issue2.issues }, [...path4, ...issue2.path]);
13970
+ processError({ issues: issue2.issues }, [...path7, ...issue2.path]);
13971
13971
  } else {
13972
- const fullpath = [...path4, ...issue2.path];
13972
+ const fullpath = [...path7, ...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 path7 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
14005
+ for (const seg of path7) {
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 path7 = ref.slice(1).split("/").filter(Boolean);
26698
+ if (path7.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 (path7[0] === defsKey) {
26703
+ const key = path7[1];
26704
26704
  if (!key || !ctx.defs[key]) {
26705
26705
  throw new Error(`Reference not found: ${ref}`);
26706
26706
  }
@@ -27163,6 +27163,56 @@ 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/installation",
27198
+ "codexhost/harness/launch-settings/get",
27199
+ "codexhost/harness/launch-settings/set",
27200
+ "codexhost/harness/web-ui/open",
27201
+ "codexhost/harness/accounts/sources",
27202
+ "codexhost/harness/accounts/list",
27203
+ "codexhost/harness/accounts/inspect",
27204
+ "codexhost/harness/credential-imports",
27205
+ "codexhost/harness/session-import/sources",
27206
+ "codexhost/harness/session-import/list",
27207
+ "codexhost/harness/session-import/import",
27208
+ "codexhost/account/list",
27209
+ "codexhost/account/refresh",
27210
+ "codexhost/account/usage/inspect",
27211
+ "codexhost/update/check",
27212
+ "codexhost/update/start",
27213
+ "codexhost/update/status"
27214
+ ]);
27215
+
27166
27216
  // ../../shared-contracts/dist/version.js
27167
27217
  var WORKSPACE_CONTRACT_VERSION = 1;
27168
27218
 
@@ -27216,6 +27266,12 @@ var hostTurnIdSchema = opaqueIdSchema.brand();
27216
27266
  var hostItemIdSchema = opaqueIdSchema.brand();
27217
27267
  var hostInteractionIdSchema = opaqueIdSchema.brand();
27218
27268
 
27269
+ // ../../shared-contracts/dist/manual-compaction.js
27270
+ var threadManualCompactionStartedSchema = external_exports.strictObject({
27271
+ threadId: hostThreadIdSchema,
27272
+ turnId: hostTurnIdSchema
27273
+ });
27274
+
27219
27275
  // ../../shared-contracts/dist/thread-usage.js
27220
27276
  var nonNegativeSafeIntegerSchema = external_exports.number().int().safe().nonnegative();
27221
27277
  var finiteNonNegativeNumberSchema = external_exports.number().finite().nonnegative();
@@ -27276,6 +27332,10 @@ var threadUsageSnapshotSchema = external_exports.object({
27276
27332
  var usagePercentSchema = external_exports.number().finite().min(0).max(100);
27277
27333
  var accountCreditsProductUsageSchema = external_exports.object({
27278
27334
  product: external_exports.string().min(1),
27335
+ used: external_exports.number().finite().nonnegative().optional(),
27336
+ // Zero is a real empty cap, not an absent field.
27337
+ limit: external_exports.number().finite().nonnegative().optional(),
27338
+ unit: external_exports.string().min(1).max(32).optional(),
27279
27339
  usagePercent: usagePercentSchema,
27280
27340
  resetsAt: external_exports.string().min(1).optional()
27281
27341
  }).strict();
@@ -27285,6 +27345,10 @@ var accountResetCreditsSchema = external_exports.object({
27285
27345
  expiresAt: external_exports.array(external_exports.string().min(1)).min(1).max(32).optional()
27286
27346
  }).strict();
27287
27347
  var accountCreditsSnapshotSchema = external_exports.object({
27348
+ used: external_exports.number().finite().nonnegative().optional(),
27349
+ // Zero is a real empty cap, not an absent field.
27350
+ limit: external_exports.number().finite().nonnegative().optional(),
27351
+ unit: external_exports.string().min(1).max(32).optional(),
27288
27352
  /** Native label when the primary limit is scoped to a model or product group. */
27289
27353
  label: external_exports.string().min(1).optional(),
27290
27354
  usedPercent: usagePercentSchema,
@@ -27304,12 +27368,27 @@ var threadUsageInspectionSchema = external_exports.object({
27304
27368
  }).strict();
27305
27369
 
27306
27370
  // ../../shared-contracts/dist/harness-accounts.js
27307
- var harnessAccountSnapshotSchema = external_exports.object({
27371
+ var accountBalanceSnapshotSchema = external_exports.object({
27372
+ amount: external_exports.number().finite().nonnegative(),
27373
+ /** ISO 4217 code as reported by the Provider, for example `CNY`. */
27374
+ currency: external_exports.string().trim().min(1).max(8),
27375
+ /** Native label when the Harness exposes several Billing Sources. */
27376
+ label: external_exports.string().trim().min(1).max(128).optional()
27377
+ }).strict();
27378
+ var harnessAccountSnapshotObject = external_exports.object({
27308
27379
  email: external_exports.string().trim().min(1).max(320).optional(),
27309
27380
  label: external_exports.string().trim().min(1).max(256).optional(),
27310
27381
  plan: external_exports.string().trim().min(1).max(128).optional(),
27311
- credits: accountCreditsSnapshotSchema
27382
+ credits: accountCreditsSnapshotSchema.optional(),
27383
+ balance: accountBalanceSnapshotSchema.optional()
27312
27384
  }).strict();
27385
+ function requireReportedQuota(schema) {
27386
+ return schema.refine((value) => {
27387
+ const reported = value;
27388
+ return reported.credits !== void 0 || reported.balance !== void 0;
27389
+ }, { message: "Account must report either credits or a balance" });
27390
+ }
27391
+ var harnessAccountSnapshotSchema = requireReportedQuota(harnessAccountSnapshotObject);
27313
27392
  var harnessAccountIdentityShape = {
27314
27393
  harnessId: harnessIdSchema,
27315
27394
  harnessName: external_exports.string().trim().min(1).max(128)
@@ -27320,11 +27399,13 @@ var harnessAccountSourceListResultSchema = external_exports.object({ sources: ex
27320
27399
  var harnessAccountInspectParamsSchema = external_exports.object({ harnessId: harnessIdSchema, refresh: external_exports.boolean().optional() }).strict();
27321
27400
  var harnessAccountInspectResultSchema = external_exports.object({
27322
27401
  ...harnessAccountIdentityShape,
27323
- account: harnessAccountSnapshotSchema.nullable()
27402
+ account: harnessAccountSnapshotSchema.nullable(),
27403
+ /** Every Billing Source from one Harness; `account` remains the first for older clients. */
27404
+ accounts: external_exports.array(harnessAccountSnapshotSchema).max(8).optional()
27324
27405
  }).strict();
27325
27406
  var harnessAccountListParamsSchema = external_exports.object({ refresh: external_exports.boolean().optional() }).strict();
27326
27407
  var harnessAccountListResultSchema = external_exports.object({
27327
- accounts: external_exports.array(harnessAccountSnapshotSchema.extend(harnessAccountIdentityShape)).max(128)
27408
+ accounts: external_exports.array(requireReportedQuota(harnessAccountSnapshotObject.extend(harnessAccountIdentityShape))).max(128)
27328
27409
  }).strict();
27329
27410
 
27330
27411
  // ../../shared-contracts/dist/json-value.js
@@ -27462,6 +27543,8 @@ var harnessModelSchema = external_exports.object({
27462
27543
  ref: harnessModelRefSchema,
27463
27544
  label: nonBlankTextSchema2.max(HARNESS_MODEL_LABEL_MAX_LENGTH),
27464
27545
  resolvedModelLabel: harnessResolvedModelLabelSchema.optional(),
27546
+ /** Optional opaque selection for this same Model with priority processing enabled. */
27547
+ fastModel: harnessModelRefSchema.optional(),
27465
27548
  supportedThinkingOptionIds: external_exports.array(harnessThinkingOptionIdSchema).optional()
27466
27549
  }).strict();
27467
27550
  var harnessThinkingOptionsSchema = external_exports.array(harnessThinkingOptionSchema).superRefine((options, context) => {
@@ -27494,6 +27577,16 @@ var harnessModelCatalogSchema = external_exports.object({
27494
27577
  });
27495
27578
  }
27496
27579
  refs.add(model.ref.id);
27580
+ if (model.fastModel) {
27581
+ if (refs.has(model.fastModel.id) || catalog.models.some((entry) => entry.ref.id === model.fastModel?.id)) {
27582
+ context.addIssue({
27583
+ code: "custom",
27584
+ message: "Fast Model refs must be distinct and unique",
27585
+ path: ["models", index, "fastModel"]
27586
+ });
27587
+ }
27588
+ refs.add(model.fastModel.id);
27589
+ }
27497
27590
  const supportedThinkingIds = /* @__PURE__ */ new Set();
27498
27591
  for (const [optionIndex, optionId] of (model.supportedThinkingOptionIds ?? []).entries()) {
27499
27592
  if (supportedThinkingIds.has(optionId)) {
@@ -27613,11 +27706,13 @@ var threadThinkingSelectParamsSchema = external_exports.object({
27613
27706
  thinkingOptionId: harnessThinkingOptionIdSchema
27614
27707
  }).strict();
27615
27708
  var threadInspectionParamsSchema = external_exports.object({
27616
- threadId: hostThreadIdSchema
27709
+ threadId: hostThreadIdSchema,
27710
+ includeReferenceCapability: external_exports.boolean().optional()
27617
27711
  }).strict();
27618
27712
  var codexThreadInspectionSchema = external_exports.object({
27619
27713
  owner: external_exports.literal("codex"),
27620
- locked: external_exports.literal(true)
27714
+ locked: external_exports.literal(true),
27715
+ supportsThreadReferences: external_exports.literal(true).optional()
27621
27716
  }).strict();
27622
27717
  var externalThreadInspectionSchema = external_exports.object({
27623
27718
  owner: external_exports.literal("external"),
@@ -27743,6 +27838,22 @@ var harnessLaunchSettingsSchema = external_exports.object({
27743
27838
  restartRequired: external_exports.boolean()
27744
27839
  }).strict();
27745
27840
 
27841
+ // ../../shared-contracts/dist/harness-installation.js
27842
+ var harnessInstallationParamsSchema = external_exports.object({
27843
+ harnessId: harnessIdSchema,
27844
+ action: external_exports.enum(["check", "update", "install"])
27845
+ }).strict();
27846
+ var harnessInstallationStateSchema = external_exports.object({
27847
+ currentVersion: external_exports.string().min(1).max(128),
27848
+ latestVersion: external_exports.string().min(1).max(128),
27849
+ updateAvailable: external_exports.boolean(),
27850
+ canUpdate: external_exports.boolean(),
27851
+ // Adapter-owned diagnostic text; UI uses messageCode rather than displaying it verbatim.
27852
+ message: external_exports.string().max(2048).optional(),
27853
+ messageCode: external_exports.string().min(1).max(128).optional(),
27854
+ latestVersionKind: external_exports.enum(["unknown", "tracking-branch"]).optional()
27855
+ }).strict();
27856
+
27746
27857
  // ../../shared-contracts/dist/codex-accounts.js
27747
27858
  var accountIdSchema = external_exports.string().min(1).max(256).regex(/^[A-Za-z0-9._~-]+$/u);
27748
27859
  var nonBlankTextSchema3 = external_exports.string().trim().min(1);
@@ -28042,11 +28153,43 @@ var updateStatusResultSchema = external_exports.strictObject({
28042
28153
  status: updateStatusSchema.nullable()
28043
28154
  });
28044
28155
 
28156
+ // ../../shared-contracts/dist/remote-runtime.js
28157
+ var remoteUpdatePhaseSchema = external_exports.enum([
28158
+ "idle",
28159
+ "installing",
28160
+ "restarting",
28161
+ "succeeded",
28162
+ "failed"
28163
+ ]);
28164
+ var runtimeStatusSchema = external_exports.object({
28165
+ runningVersion: external_exports.string().nullable(),
28166
+ installedVersion: external_exports.string().nullable(),
28167
+ restartRequired: external_exports.boolean(),
28168
+ remote: external_exports.boolean(),
28169
+ updateSupported: external_exports.boolean(),
28170
+ update: external_exports.object({
28171
+ phase: remoteUpdatePhaseSchema,
28172
+ targetVersion: external_exports.string().nullable(),
28173
+ error: external_exports.string().nullable()
28174
+ })
28175
+ });
28176
+ var remoteUpdateParamsSchema = external_exports.object({
28177
+ version: external_exports.string().regex(/^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?$/u)
28178
+ }).strict();
28179
+ var remoteSshSetupParamsSchema = external_exports.object({
28180
+ hostname: external_exports.string().min(1).max(1024).refine((value) => !value.startsWith("-") && !/\s/u.test(value)),
28181
+ port: external_exports.number().int().min(1).max(65535).nullable(),
28182
+ identity: external_exports.string().max(4096).nullable(),
28183
+ action: external_exports.enum(["inspect", "install", "update", "repair"]),
28184
+ version: external_exports.string().regex(/^\d+\.\d+\.\d+$/u).nullable()
28185
+ }).strict();
28186
+ var remoteSshSetupResultSchema = external_exports.object({ state: external_exports.enum(["installed", "not-installed"]) }).strict();
28187
+
28045
28188
  // ../../shared-contracts/dist/index.js
28046
28189
  var workspaceContractVersionSchema = external_exports.literal(WORKSPACE_CONTRACT_VERSION);
28047
28190
 
28048
28191
  // ../qoder/dist/qoder-command.js
28049
- import path2 from "node:path";
28192
+ import path4 from "node:path";
28050
28193
 
28051
28194
  // ../../harness-discovery/dist/environment.js
28052
28195
  import fs from "node:fs";
@@ -28094,6 +28237,36 @@ function newestFirst(names) {
28094
28237
  return [...names].sort((left, right) => right.localeCompare(left, void 0, { numeric: true }));
28095
28238
  }
28096
28239
 
28240
+ // ../../harness-discovery/dist/invocation.js
28241
+ import path2 from "node:path";
28242
+ function commandInvocation(command, arguments_, environment, platform = process.platform) {
28243
+ const extension = path2.win32.extname(command).toLowerCase();
28244
+ if (platform !== "win32" || ![".cmd", ".bat"].includes(extension)) {
28245
+ return { command, arguments: [...arguments_], windowsVerbatimArguments: false };
28246
+ }
28247
+ const quote = (value) => `"${value.replaceAll("%", "%%").replaceAll('"', '""')}"`;
28248
+ const commandLine = [command, ...arguments_].map(quote).join(" ");
28249
+ return {
28250
+ command: environmentValue(environment, "ComSpec") ?? "cmd.exe",
28251
+ arguments: ["/d", "/v:off", "/s", "/c", `"${commandLine}"`],
28252
+ windowsVerbatimArguments: true
28253
+ };
28254
+ }
28255
+
28256
+ // ../../harness-discovery/dist/node-runtime.js
28257
+ import path3 from "node:path";
28258
+ function withNodeRuntimeOnPath(environment, runtimeExecutable = process.execPath, platform = process.platform) {
28259
+ const pathKey = Object.keys(environment).find((name) => name.toLowerCase() === "path") ?? "PATH";
28260
+ const delimiter = platform === "win32" ? ";" : ":";
28261
+ const runtimeDirectory = path3.dirname(runtimeExecutable);
28262
+ const directories = (environment[pathKey] ?? "").split(delimiter).filter(Boolean);
28263
+ const equal = platform === "win32" ? (value) => value.toLowerCase() : (value) => value;
28264
+ if (!directories.some((directory) => equal(directory) === equal(runtimeDirectory))) {
28265
+ directories.push(runtimeDirectory);
28266
+ }
28267
+ return { ...environment, [pathKey]: directories.join(delimiter) };
28268
+ }
28269
+
28097
28270
  // ../../harness-discovery/dist/resolve.js
28098
28271
  import os from "node:os";
28099
28272
 
@@ -28257,6 +28430,170 @@ function resolveHarnessExecutable(spec, input, dependencies = {}) {
28257
28430
  return void 0;
28258
28431
  }
28259
28432
 
28433
+ // ../../harness-discovery/dist/installation.js
28434
+ import { execFile } from "node:child_process";
28435
+ import { homedir } from "node:os";
28436
+ function runInstallationCommand(command, args, environment, timeout = 3e4) {
28437
+ const env = withNodeRuntimeOnPath(environment);
28438
+ const invocation = /\.[cm]?js$/i.test(command) ? commandInvocation(process.execPath, [command, ...args], env) : commandInvocation(command, args, env);
28439
+ return new Promise((resolve, reject) => {
28440
+ const child = execFile(invocation.command, invocation.arguments, {
28441
+ env,
28442
+ cwd: env.HOME ?? env.USERPROFILE ?? homedir(),
28443
+ encoding: "utf8",
28444
+ timeout,
28445
+ killSignal: "SIGKILL",
28446
+ maxBuffer: 1024 * 1024,
28447
+ windowsHide: true,
28448
+ windowsVerbatimArguments: invocation.windowsVerbatimArguments
28449
+ }, (error51, stdout, stderr) => {
28450
+ if (error51)
28451
+ reject(new Error(error51.killed ? "Harness command timed out" : "Harness command failed; check the native installation and retry"));
28452
+ else
28453
+ resolve((stdout || stderr).trim());
28454
+ });
28455
+ child.stdin?.end();
28456
+ });
28457
+ }
28458
+ function installationVersion(value) {
28459
+ if (typeof value !== "string" || !/^v?\d+(?:\.\d+){1,3}(?:-[\w.-]+)?(?:\+[\w.-]+)?$/.test(value.trim()))
28460
+ throw new Error("Harness returned an invalid version");
28461
+ return value.trim().replace(/^v/, "");
28462
+ }
28463
+ function versionFromOutput(output) {
28464
+ return installationVersion(output.match(/\b\d+(?:\.\d+){1,3}(?:-[\w.-]+)?(?:\+[\w.-]+)?\b/)?.[0]);
28465
+ }
28466
+ function newerInstallationVersion(current, latest) {
28467
+ const a = installationVersion(current).replace(/\+.*/, "");
28468
+ const b = installationVersion(latest).replace(/\+.*/, "");
28469
+ const coreA = a.replace(/-.*/, "").split(".").map(BigInt);
28470
+ const coreB = b.replace(/-.*/, "").split(".").map(BigInt);
28471
+ for (let i = 0; i < Math.max(coreA.length, coreB.length); i++) {
28472
+ if ((coreA[i] ?? 0n) !== (coreB[i] ?? 0n))
28473
+ return (coreB[i] ?? 0n) > (coreA[i] ?? 0n);
28474
+ }
28475
+ const preA = a.includes("-") ? a.slice(a.indexOf("-") + 1).split(".") : [];
28476
+ const preB = b.includes("-") ? b.slice(b.indexOf("-") + 1).split(".") : [];
28477
+ if (!preA.length || !preB.length)
28478
+ return !!preA.length && !preB.length;
28479
+ for (let i = 0; i < Math.max(preA.length, preB.length); i++) {
28480
+ const x3 = preA[i];
28481
+ const y = preB[i];
28482
+ if (x3 === y)
28483
+ continue;
28484
+ if (x3 === void 0 || y === void 0)
28485
+ return x3 === void 0;
28486
+ const numericX = /^\d+$/.test(x3);
28487
+ const numericY = /^\d+$/.test(y);
28488
+ if (numericX && numericY) {
28489
+ if (BigInt(x3) === BigInt(y))
28490
+ continue;
28491
+ return BigInt(y) > BigInt(x3);
28492
+ }
28493
+ if (numericX !== numericY)
28494
+ return numericX;
28495
+ return y > x3;
28496
+ }
28497
+ return false;
28498
+ }
28499
+ function createInstallationManager(options) {
28500
+ let checking;
28501
+ let updating;
28502
+ const check2 = () => checking ??= options.check().finally(() => {
28503
+ checking = void 0;
28504
+ });
28505
+ return (action) => {
28506
+ if (updating)
28507
+ return updating;
28508
+ if (action === "check")
28509
+ return check2();
28510
+ updating = (async () => {
28511
+ const before = await check2();
28512
+ if (!before.updateAvailable)
28513
+ return before;
28514
+ if (!before.canUpdate)
28515
+ throw new Error(before.message ?? "This installation cannot be updated automatically");
28516
+ await options.update(before);
28517
+ const after = await check2();
28518
+ if (after.currentVersion === before.currentVersion)
28519
+ throw new Error("The Harness version did not change; check the native updater and retry");
28520
+ return after;
28521
+ })().finally(() => {
28522
+ updating = void 0;
28523
+ });
28524
+ return updating;
28525
+ };
28526
+ }
28527
+ async function fetchInstallationText(url2) {
28528
+ const request = async () => {
28529
+ const response = await fetch(url2, { signal: AbortSignal.timeout(15e3) });
28530
+ if (!response.ok)
28531
+ throw new Error("Could not check the latest Harness version");
28532
+ return response.text();
28533
+ };
28534
+ try {
28535
+ return await request();
28536
+ } catch (error51) {
28537
+ if (error51 instanceof DOMException && (error51.name === "AbortError" || error51.name === "TimeoutError"))
28538
+ throw error51;
28539
+ return request();
28540
+ }
28541
+ }
28542
+
28543
+ // ../../harness-discovery/dist/installer.js
28544
+ import { mkdtemp, rm, writeFile } from "node:fs/promises";
28545
+ import { tmpdir } from "node:os";
28546
+ import { join } from "node:path";
28547
+ function createHarnessInstaller(environment, source) {
28548
+ return async () => {
28549
+ if (!["darwin", "linux", "win32"].includes(process.platform))
28550
+ throw new Error("Unsupported installation platform");
28551
+ const env = withNodeRuntimeOnPath(environment);
28552
+ if ("npm" in source) {
28553
+ const npm = resolveHarnessExecutable({
28554
+ id: "npm",
28555
+ command: "npm",
28556
+ installRoots: {
28557
+ posix: [
28558
+ "~/.npm-global/bin",
28559
+ "~/.local/bin",
28560
+ VERSION_MANAGER_ROOTS,
28561
+ "/opt/homebrew/bin",
28562
+ "/usr/local/bin",
28563
+ "/usr/bin"
28564
+ ],
28565
+ windows: [
28566
+ "${APPDATA}/npm",
28567
+ VERSION_MANAGER_ROOTS,
28568
+ "${ProgramFiles}/nodejs",
28569
+ "${LOCALAPPDATA}/Programs/nodejs"
28570
+ ]
28571
+ }
28572
+ }, { environment: env });
28573
+ if (!npm)
28574
+ throw new Error("Install Node.js and npm first");
28575
+ await runInstallationCommand(npm.executable, ["install", "--global", source.npm], {
28576
+ ...env,
28577
+ ...source.allowScripts ? { npm_config_allow_scripts: source.allowScripts } : {}
28578
+ }, 6e5);
28579
+ return;
28580
+ }
28581
+ const windows = process.platform === "win32";
28582
+ const url2 = windows ? source.windows : source.posix;
28583
+ if (new URL(url2).protocol !== "https:")
28584
+ throw new Error("Installer requires HTTPS");
28585
+ const script = await fetchInstallationText(url2);
28586
+ const directory = await mkdtemp(join(tmpdir(), "codexhost-installer-"));
28587
+ try {
28588
+ const file2 = join(directory, windows ? "install.ps1" : "install.sh");
28589
+ await writeFile(file2, script, { mode: 384 });
28590
+ await runInstallationCommand(windows ? "powershell.exe" : source.shell ?? "bash", windows ? ["-NoProfile", "-NonInteractive", "-ExecutionPolicy", "Bypass", "-File", file2] : [file2], env, 6e5);
28591
+ } finally {
28592
+ await rm(directory, { recursive: true, force: true });
28593
+ }
28594
+ };
28595
+ }
28596
+
28260
28597
  // ../qoder/dist/qoder-command.js
28261
28598
  var QoderExecutableError = class extends Error {
28262
28599
  code = "QODER_NOT_FOUND";
@@ -28320,7 +28657,52 @@ function resolveQoderExecutable(input = {}, dependencies = {}) {
28320
28657
  }, dependencies);
28321
28658
  if (!resolution)
28322
28659
  throw new QoderExecutableError("Qoder CLI is not installed");
28323
- return targetPath(platform).isAbsolute(resolution.executable) ? resolution.executable : path2.resolve(resolution.executable);
28660
+ return targetPath(platform).isAbsolute(resolution.executable) ? resolution.executable : path4.resolve(resolution.executable);
28661
+ }
28662
+
28663
+ // ../qoder/dist/qoder-account.js
28664
+ var record2 = (value) => value && typeof value === "object" && !Array.isArray(value) ? value : {};
28665
+ var nonnegative = (value) => typeof value === "number" && Number.isFinite(value) && value >= 0;
28666
+ function creditAmount(used, limit, unit) {
28667
+ if (!nonnegative(used) || !nonnegative(limit))
28668
+ return void 0;
28669
+ return {
28670
+ used,
28671
+ limit,
28672
+ unit: typeof unit === "string" && unit.trim() ? unit : "credits"
28673
+ };
28674
+ }
28675
+ function projectQoderAccount(usage, identity) {
28676
+ const data = record2(usage);
28677
+ const account = record2(identity);
28678
+ const quota = record2(data.userQuota);
28679
+ const shared = record2(data.orgResourcePackage);
28680
+ const nativePercent = quota.percentage ?? data.totalUsagePercentage;
28681
+ 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;
28682
+ if (usedPercent === void 0)
28683
+ return null;
28684
+ const result = harnessAccountSnapshotSchema.safeParse({
28685
+ ...typeof account.email === "string" && account.email ? { email: account.email } : {},
28686
+ ...typeof account.subscriptionType === "string" && account.subscriptionType ? { plan: account.subscriptionType } : typeof data.userType === "string" ? { plan: data.userType } : {},
28687
+ credits: {
28688
+ usedPercent,
28689
+ periodType: "unknown",
28690
+ label: "Plan credits",
28691
+ ...shared.available === true && nonnegative(shared.percentage) && nonnegative(shared.used) && nonnegative(shared.cap) && shared.cap > 0 ? {
28692
+ productUsage: [
28693
+ {
28694
+ product: "Shared resource credits",
28695
+ usagePercent: Math.min(100, shared.percentage),
28696
+ used: shared.used,
28697
+ limit: shared.cap,
28698
+ unit: typeof shared.unit === "string" ? shared.unit : "credits"
28699
+ }
28700
+ ]
28701
+ } : {},
28702
+ ...creditAmount(quota.used, quota.total, quota.unit)
28703
+ }
28704
+ });
28705
+ return result.success ? result.data : null;
28324
28706
  }
28325
28707
 
28326
28708
  // ../qoder/dist/qoder-errors.js
@@ -28468,6 +28850,26 @@ function mapQoderException(error51) {
28468
28850
  };
28469
28851
  }
28470
28852
 
28853
+ // ../qoder/dist/qoder-login-check.js
28854
+ import { execFile as execFile2 } from "node:child_process";
28855
+ function qoderLoginRequired(text) {
28856
+ return /\bnot logged in\b|\bauthentication (?:required|expired)\b/i.test(text);
28857
+ }
28858
+ function checkQoderLogin(executable, environment, cwd) {
28859
+ return new Promise((resolve) => {
28860
+ execFile2(executable, ["--list-models"], {
28861
+ env: environment,
28862
+ cwd,
28863
+ timeout: 1e4,
28864
+ maxBuffer: 64 * 1024,
28865
+ windowsHide: true
28866
+ }, (error51, stdout, stderr) => {
28867
+ resolve(Boolean(error51 && !error51.killed && qoderLoginRequired(`${stdout}
28868
+ ${stderr}`)));
28869
+ });
28870
+ });
28871
+ }
28872
+
28471
28873
  // ../../harness-adapter/dist/approval.js
28472
28874
  function invalidRequest(message) {
28473
28875
  return { code: "invalidRequest", message, retryable: false };
@@ -29819,8 +30221,8 @@ function getErrorMap2() {
29819
30221
 
29820
30222
  // ../../../node_modules/zod/v3/helpers/parseUtil.js
29821
30223
  var makeIssue = (params) => {
29822
- const { data, path: path4, errorMaps, issueData } = params;
29823
- const fullPath = [...path4, ...issueData.path || []];
30224
+ const { data, path: path7, errorMaps, issueData } = params;
30225
+ const fullPath = [...path7, ...issueData.path || []];
29824
30226
  const fullIssue = {
29825
30227
  ...issueData,
29826
30228
  path: fullPath
@@ -29935,11 +30337,11 @@ var errorUtil;
29935
30337
 
29936
30338
  // ../../../node_modules/zod/v3/types.js
29937
30339
  var ParseInputLazyPath = class {
29938
- constructor(parent, value, path4, key) {
30340
+ constructor(parent, value, path7, key) {
29939
30341
  this._cachedPath = [];
29940
30342
  this.parent = parent;
29941
30343
  this.data = value;
29942
- this._path = path4;
30344
+ this._path = path7;
29943
30345
  this._key = key;
29944
30346
  }
29945
30347
  get path() {
@@ -33466,11 +33868,11 @@ function normalizeObjectSchema(schema) {
33466
33868
  }
33467
33869
  return void 0;
33468
33870
  }
33469
- function getDotPath(path4) {
33470
- if (path4.length === 0) {
33871
+ function getDotPath(path7) {
33872
+ if (path7.length === 0) {
33471
33873
  return "object root";
33472
33874
  }
33473
- return path4.reduce((acc, seg, index) => {
33875
+ return path7.reduce((acc, seg, index) => {
33474
33876
  if (index === 0) {
33475
33877
  return String(seg);
33476
33878
  }
@@ -52041,12 +52443,171 @@ var QoderSession = class {
52041
52443
  }
52042
52444
  };
52043
52445
 
52446
+ // ../qoder/dist/qoder-session-import.js
52447
+ import { stat } from "node:fs/promises";
52448
+ import path5 from "node:path";
52449
+
52450
+ // ../../harness-adapter/dist/session-import.js
52451
+ var STORAGE_ACCESS_ERRORS = /* @__PURE__ */ new Set(["EACCES", "EPERM", "EIO", "EMFILE", "ENFILE"]);
52452
+ function isStorageAccessError(error51) {
52453
+ return typeof error51 === "object" && error51 !== null && "code" in error51 && typeof error51.code === "string" && STORAGE_ACCESS_ERRORS.has(error51.code);
52454
+ }
52455
+ function sessionImportTitle(value, maxLength = HARNESS_SESSION_IMPORT_TITLE_MAX_LENGTH) {
52456
+ if (typeof value !== "string")
52457
+ return null;
52458
+ const normalized = value.replaceAll("\0", "").replaceAll(/\s+/gu, " ").trim();
52459
+ if (!normalized)
52460
+ return null;
52461
+ if (normalized.length <= maxLength)
52462
+ return normalized;
52463
+ const characters = [...normalized];
52464
+ if (characters.length <= maxLength)
52465
+ return normalized;
52466
+ return `${characters.slice(0, maxLength - 1).join("").trimEnd()}…`;
52467
+ }
52468
+ function sessionImportCandidate(input) {
52469
+ const time3 = typeof input.updatedAt === "number" ? input.updatedAt : typeof input.updatedAt === "string" ? Date.parse(input.updatedAt) : Number.NaN;
52470
+ const parsed = harnessSessionImportCandidateSchema.safeParse({
52471
+ nativeSessionId: input.nativeSessionId,
52472
+ cwd: input.cwd,
52473
+ title: typeof input.title === "string" && input.title.trim().length > 0 ? input.title : null,
52474
+ updatedAt: Math.floor(time3),
52475
+ // Unknown must stay unknown; only an explicit boolean is a native statement.
52476
+ running: typeof input.running === "boolean" ? input.running : null
52477
+ });
52478
+ return parsed.success ? parsed.data : null;
52479
+ }
52480
+ var SessionImportScope = class {
52481
+ #abort = new AbortController();
52482
+ #options;
52483
+ #pending = /* @__PURE__ */ new Set();
52484
+ constructor(options) {
52485
+ this.#options = options;
52486
+ }
52487
+ #closed() {
52488
+ return {
52489
+ ok: false,
52490
+ error: { code: "invalidState", message: this.#options.closedMessage, retryable: false }
52491
+ };
52492
+ }
52493
+ read(operation) {
52494
+ const signal = this.#abort.signal;
52495
+ if (signal.aborted)
52496
+ return Promise.resolve(this.#closed());
52497
+ let started;
52498
+ try {
52499
+ started = operation(signal);
52500
+ } catch (error51) {
52501
+ started = Promise.reject(error51 instanceof Error ? error51 : new Error("Session read failed"));
52502
+ }
52503
+ const request = started.then((value) => signal.aborted ? this.#closed() : { ok: true, value }).catch(() => signal.aborted ? this.#closed() : {
52504
+ ok: false,
52505
+ error: {
52506
+ code: "unavailable",
52507
+ message: this.#options.unavailableMessage,
52508
+ retryable: true
52509
+ }
52510
+ }).finally(() => this.#pending.delete(request));
52511
+ this.#pending.add(request);
52512
+ return request;
52513
+ }
52514
+ /** `read` for `resolveCandidate`: a null source is the selected Session having disappeared. */
52515
+ async resolve(operation) {
52516
+ const result = await this.read(operation);
52517
+ if (!result.ok)
52518
+ return result;
52519
+ return result.value ? { ok: true, value: result.value } : {
52520
+ ok: false,
52521
+ error: {
52522
+ code: "sessionNotFound",
52523
+ message: this.#options.notFoundMessage,
52524
+ retryable: false
52525
+ }
52526
+ };
52527
+ }
52528
+ /** Idempotent. Resolves after every started read has settled. */
52529
+ async close() {
52530
+ this.#abort.abort();
52531
+ await Promise.allSettled(this.#pending);
52532
+ }
52533
+ };
52534
+
52535
+ // ../qoder/dist/qoder-session-import.js
52536
+ var QoderSessionImport = class {
52537
+ #dependencies;
52538
+ #scope;
52539
+ constructor(dependencies) {
52540
+ this.#dependencies = dependencies;
52541
+ const name = dependencies.displayName;
52542
+ this.#scope = new SessionImportScope({
52543
+ closedMessage: `${name} Session import is closed`,
52544
+ unavailableMessage: `${name} sessions could not be read; check storage access and retry`,
52545
+ notFoundMessage: `${name} Session is no longer importable`
52546
+ });
52547
+ }
52548
+ listCandidates() {
52549
+ return this.#scope.read(async (signal) => {
52550
+ const candidates = /* @__PURE__ */ new Map();
52551
+ for (const info of await this.#dependencies.listSessions()) {
52552
+ signal.throwIfAborted();
52553
+ const candidate = await this.#candidate(info);
52554
+ if (candidate && !candidates.has(candidate.nativeSessionId))
52555
+ candidates.set(candidate.nativeSessionId, candidate);
52556
+ }
52557
+ return [...candidates.values()];
52558
+ });
52559
+ }
52560
+ resolveCandidate(nativeSessionId) {
52561
+ return this.#scope.resolve(async (signal) => {
52562
+ const info = await this.#dependencies.getSessionInfo(nativeSessionId);
52563
+ signal.throwIfAborted();
52564
+ if (info?.sessionId !== nativeSessionId)
52565
+ return null;
52566
+ const candidate = await this.#candidate(info);
52567
+ if (!candidate)
52568
+ return null;
52569
+ return {
52570
+ candidate,
52571
+ nativeRef: nativeSessionRefSchema.parse({
52572
+ harnessId: this.#dependencies.harnessId,
52573
+ nativeSessionId,
52574
+ formatVersion: 1
52575
+ })
52576
+ };
52577
+ });
52578
+ }
52579
+ close() {
52580
+ return this.#scope.close();
52581
+ }
52582
+ async #candidate(info) {
52583
+ if (typeof info.cwd !== "string" || !path5.isAbsolute(info.cwd))
52584
+ return null;
52585
+ const cwd = path5.resolve(info.cwd);
52586
+ try {
52587
+ if (!(await stat(cwd)).isDirectory())
52588
+ return null;
52589
+ } catch (error51) {
52590
+ if (isStorageAccessError(error51))
52591
+ throw error51;
52592
+ return null;
52593
+ }
52594
+ return sessionImportCandidate({
52595
+ nativeSessionId: info.sessionId,
52596
+ cwd,
52597
+ title: sessionImportTitle(info.customTitle) ?? sessionImportTitle(info.summary) ?? sessionImportTitle(info.firstPrompt),
52598
+ updatedAt: info.lastModified
52599
+ // The SDK exposes no cross-process activity marker: idleness cannot be established.
52600
+ });
52601
+ }
52602
+ };
52603
+
52044
52604
  // ../qoder/dist/qoder-adapter.js
52045
52605
  var QoderAdapter = class {
52046
52606
  harnessId;
52047
52607
  #variant;
52048
52608
  commandCatalog = QODER_FALLBACK_COMMAND_CATALOG;
52049
52609
  liveCommandCatalog = true;
52610
+ sessionImport;
52050
52611
  #commandOverride;
52051
52612
  #environment;
52052
52613
  #platform;
@@ -52070,9 +52631,49 @@ var QoderAdapter = class {
52070
52631
  this.#forkSession = options.forkSession ?? runtime.sdk.forkSession;
52071
52632
  this.#getSessionMessages = options.getSessionMessages ?? runtime.sdk.getSessionMessages;
52072
52633
  this.#getSessionInfo = options.getSessionInfo ?? runtime.sdk.getSessionInfo;
52634
+ this.sessionImport = new QoderSessionImport({
52635
+ harnessId: this.harnessId,
52636
+ displayName: this.#variant === "cn" ? "Qoder CN" : "Qoder",
52637
+ listSessions: options.listSessions ?? (() => runtime.sdk.listSessions()),
52638
+ getSessionInfo: this.#getSessionInfo
52639
+ });
52073
52640
  this.#getAvailableModels = options.getAvailableModels;
52074
52641
  this.#resolveExecutable = options.resolveExecutable ?? ((input, dependencies) => resolveQoderExecutable({ ...input, variant: this.#variant }, dependencies));
52075
52642
  }
52643
+ async inspectAccount() {
52644
+ let probe;
52645
+ let timer;
52646
+ try {
52647
+ const executable = this.#resolveExecutable({
52648
+ ...this.#commandOverride ? { command: this.#commandOverride } : {},
52649
+ environment: this.#environment,
52650
+ platform: this.#platform
52651
+ });
52652
+ probe = this.#queryFactory({
52653
+ prompt: "",
52654
+ options: {
52655
+ cwd: process.cwd(),
52656
+ pathToQoderCLIExecutable: executable,
52657
+ ...this.#environment ? { env: this.#environment } : {},
52658
+ auth: qoderAuthForEnvironment(this.#variant, this.#environment)
52659
+ }
52660
+ });
52661
+ return await Promise.race([
52662
+ Promise.all([probe.getUsageInfo?.(), probe.accountInfo?.().catch(() => void 0)]).then(([usage, identity]) => projectQoderAccount(usage, identity)),
52663
+ new Promise((resolve) => {
52664
+ timer = setTimeout(() => resolve(null), 1e4);
52665
+ })
52666
+ ]);
52667
+ } catch {
52668
+ return null;
52669
+ } finally {
52670
+ clearTimeout(timer);
52671
+ try {
52672
+ await probe?.close();
52673
+ } catch {
52674
+ }
52675
+ }
52676
+ }
52076
52677
  async inspect(input) {
52077
52678
  const cacheKey = input?.cwd ?? "";
52078
52679
  if (input?.refresh) {
@@ -52100,11 +52701,15 @@ var QoderAdapter = class {
52100
52701
  } catch {
52101
52702
  }
52102
52703
  } else {
52704
+ let stderr = "";
52103
52705
  try {
52104
52706
  const probeQuery = this.#queryFactory({
52105
52707
  prompt: "",
52106
52708
  options: {
52107
52709
  cwd: input?.cwd ?? process.cwd(),
52710
+ stderr: (chunk) => {
52711
+ stderr = (stderr + chunk).slice(-8192);
52712
+ },
52108
52713
  pathToQoderCLIExecutable: executable,
52109
52714
  ...this.#environment ? { env: this.#environment } : {},
52110
52715
  auth: qoderAuthForEnvironment(this.#variant, this.#environment)
@@ -52121,9 +52726,14 @@ var QoderAdapter = class {
52121
52726
  }
52122
52727
  }
52123
52728
  } catch (error51) {
52729
+ const needsLogin = qoderLoginRequired(stderr) || error51 instanceof Error && error51.message === "Transport closed" && qoderAuthForEnvironment(this.#variant, this.#environment).type === "qodercli" && await checkQoderLogin(executable, this.#environment, input?.cwd);
52124
52730
  const result2 = {
52125
52731
  status: "unavailable",
52126
- error: mapQoderException(error51)
52732
+ error: needsLogin ? {
52733
+ code: "authenticationRequired",
52734
+ message: `Please run ${this.#variant === "cn" ? "qoderclicn" : "qodercli"} login to authenticate.`,
52735
+ retryable: false
52736
+ } : mapQoderException(error51)
52127
52737
  };
52128
52738
  return result2;
52129
52739
  }
@@ -52245,7 +52855,7 @@ var QoderAdapter = class {
52245
52855
  sourceInfo = await this.#getSessionInfo(sourceRef.data.nativeSessionId, { dir: input.cwd });
52246
52856
  } catch {
52247
52857
  }
52248
- if (sourceInfo?.cwd && path3.resolve(sourceInfo.cwd) !== path3.resolve(input.cwd)) {
52858
+ if (sourceInfo?.cwd && path6.resolve(sourceInfo.cwd) !== path6.resolve(input.cwd)) {
52249
52859
  return {
52250
52860
  ok: false,
52251
52861
  error: {
@@ -52395,18 +53005,71 @@ var QoderAdapter = class {
52395
53005
  this.#sessions.clear();
52396
53006
  this.#inspections.clear();
52397
53007
  this.#inFlightInspections.clear();
52398
- await Promise.all(sessions.map((s) => s.close()));
53008
+ await Promise.all([this.sessionImport.close(), ...sessions.map((s) => s.close())]);
52399
53009
  }
52400
53010
  };
52401
53011
 
52402
- // dist/plugin.js
52403
- function createHarnessAdapter2(context) {
52404
- return new QoderAdapter({
52405
- variant: "cn",
52406
- environment: { ...context.environment },
53012
+ // ../qoder/dist/installation.js
53013
+ function createQoderInstallation(environment, command, variant = "global") {
53014
+ const run = (args, timeout) => runInstallationCommand(resolveQoderExecutable({ environment, variant, ...command ? { command } : {} }), args, environment, timeout);
53015
+ return createInstallationManager({
53016
+ async check() {
53017
+ const currentVersion = versionFromOutput(await run(["--version"]));
53018
+ if (variant === "cn" && !(await run(["update", "--help"]).catch(() => "")).includes("--check"))
53019
+ return {
53020
+ currentVersion,
53021
+ latestVersion: "Unknown",
53022
+ updateAvailable: false,
53023
+ canUpdate: false,
53024
+ messageCode: "qoder-check-unavailable",
53025
+ message: "This Qoder China release does not expose a non-installing update check. Use its original installer."
53026
+ };
53027
+ const output = await run(["update", "--check"]);
53028
+ const available = output.match(/Update available:\s*\S+\s*(?:->|\u2192)\s*(\S+)/i);
53029
+ if (available?.[1])
53030
+ return {
53031
+ currentVersion,
53032
+ latestVersion: installationVersion(available[1]),
53033
+ updateAvailable: newerInstallationVersion(currentVersion, installationVersion(available[1])),
53034
+ canUpdate: true
53035
+ };
53036
+ if (!/already\s+(?:on|at)\s+(?:the\s+)?latest|up.to.date|no updates?\s+available/i.test(output))
53037
+ throw new Error("Qoder update check returned an unknown response");
53038
+ return {
53039
+ currentVersion,
53040
+ latestVersion: currentVersion,
53041
+ updateAvailable: false,
53042
+ canUpdate: true
53043
+ };
53044
+ },
53045
+ async update() {
53046
+ await run(["update"], 3e5);
53047
+ }
53048
+ });
53049
+ }
53050
+
53051
+ // ../qoder/dist/plugin.js
53052
+ function createHarnessAdapter(context, variant = "global") {
53053
+ const environment = { ...context.environment };
53054
+ const command = environment[variant === "cn" ? CODEXHOST_QODERCN_COMMAND : CODEXHOST_QODER_COMMAND];
53055
+ return Object.assign(new QoderAdapter({
53056
+ ...command ? { commandOverride: command } : {},
53057
+ variant,
53058
+ environment,
52407
53059
  platform: context.platform
53060
+ }), {
53061
+ installation: createQoderInstallation(environment, command, variant),
53062
+ install: createHarnessInstaller(environment, variant === "cn" ? {
53063
+ posix: "https://static.qoder.com.cn/qoder-cli-cn/install.sh",
53064
+ windows: "https://static.qoder.com.cn/qoder-cli-cn/install.ps1"
53065
+ } : { posix: "https://qoder.com/install", windows: "https://qoder.com/install.ps1" })
52408
53066
  });
52409
53067
  }
53068
+
53069
+ // dist/plugin.js
53070
+ function createHarnessAdapter2(context) {
53071
+ return createHarnessAdapter(context, "cn");
53072
+ }
52410
53073
  export {
52411
53074
  createHarnessAdapter2 as createHarnessAdapter
52412
53075
  };