@codexhost/cli-linux-arm64 0.12.2 → 0.13.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.
Files changed (54) hide show
  1. package/README.md +1 -1
  2. package/THIRD_PARTY_NOTICES.txt +9 -1
  3. package/app/codexhost-distribution.json +1 -1
  4. package/app/console-server.mjs +319 -64
  5. package/app/console-web.js +5089 -1367
  6. package/app/desktop-controller.mjs +259 -41
  7. package/app/host-runtime.mjs +5735 -1564
  8. package/app/plugins/antigravity/manifest.json +18 -1
  9. package/app/plugins/antigravity/plugin.mjs +282 -41
  10. package/app/plugins/claude-code/manifest.json +28 -0
  11. package/app/plugins/claude-code/plugin.mjs +35300 -23918
  12. package/app/plugins/codebuddy/manifest.json +17 -0
  13. package/app/plugins/codebuddy/plugin.mjs +5971 -5355
  14. package/app/plugins/codex-usage/manifest.json +9 -0
  15. package/app/plugins/codex-usage/plugin.mjs +17324 -0
  16. package/app/plugins/cursor-cli/manifest.json +17 -0
  17. package/app/plugins/cursor-cli/plugin.mjs +357 -76
  18. package/app/plugins/deepseek-harness/assets/icon.svg +1 -0
  19. package/app/plugins/deepseek-harness/manifest.json +35 -2
  20. package/app/plugins/deepseek-harness/plugin.mjs +822 -241
  21. package/app/plugins/enabled.json +2 -1
  22. package/app/plugins/grok/manifest.json +21 -1
  23. package/app/plugins/grok/plugin.mjs +918 -258
  24. package/app/plugins/hermes/assets/icon.png +0 -0
  25. package/app/plugins/hermes/manifest.json +30 -2
  26. package/app/plugins/hermes/plugin.mjs +284 -32
  27. package/app/plugins/kimi-code/assets/icon.svg +5 -0
  28. package/app/plugins/kimi-code/manifest.json +25 -2
  29. package/app/plugins/kimi-code/plugin.mjs +561 -35
  30. package/app/plugins/kiro-cli/assets/kiro-agent.svg +11 -0
  31. package/app/plugins/kiro-cli/manifest.json +18 -1
  32. package/app/plugins/kiro-cli/plugin.mjs +290 -21
  33. package/app/plugins/omp/manifest.json +21 -1
  34. package/app/plugins/omp/plugin.mjs +2765 -1960
  35. package/app/plugins/opencode/manifest.json +18 -1
  36. package/app/plugins/opencode/plugin.mjs +723 -146
  37. package/app/plugins/pi/manifest.json +32 -0
  38. package/app/plugins/pi/plugin.mjs +2908 -2312
  39. package/app/plugins/qoder/manifest.json +18 -1
  40. package/app/plugins/qoder/plugin.mjs +634 -80
  41. package/app/plugins/qoder-cn/manifest.json +18 -1
  42. package/app/plugins/qoder-cn/plugin.mjs +634 -80
  43. package/app/plugins/workbuddy/manifest.json +18 -0
  44. package/app/plugins/workbuddy/plugin.mjs +6361 -5747
  45. package/app/plugins/zcode/manifest.json +19 -1
  46. package/app/plugins/zcode/plugin.mjs +1098 -259
  47. package/app/renderer-extension.js +13080 -8884
  48. package/bin/codexhost +0 -0
  49. package/libexec/codexhost-shim +0 -0
  50. package/libexec/codexhost-updater +0 -0
  51. package/licenses/Cordis-LICENSE.txt +21 -0
  52. package/licenses/Cosmokit-LICENSE.txt +21 -0
  53. package/package.json +1 -1
  54. package/app/plugins/kiro-cli/assets/icon.svg +0 -5
@@ -2220,20 +2220,20 @@ var require_resolve = __commonJS({
2220
2220
  return false;
2221
2221
  }
2222
2222
  function countKeys(schema) {
2223
- let count = 0;
2223
+ let count3 = 0;
2224
2224
  for (const key in schema) {
2225
2225
  if (key === "$ref")
2226
2226
  return Infinity;
2227
- count++;
2227
+ count3++;
2228
2228
  if (SIMPLE_INLINED.has(key))
2229
2229
  continue;
2230
2230
  if (typeof schema[key] == "object") {
2231
- (0, util_1.eachItem)(schema[key], (sch) => count += countKeys(sch));
2231
+ (0, util_1.eachItem)(schema[key], (sch) => count3 += countKeys(sch));
2232
2232
  }
2233
- if (count === Infinity)
2233
+ if (count3 === Infinity)
2234
2234
  return Infinity;
2235
2235
  }
2236
- return count;
2236
+ return count3;
2237
2237
  }
2238
2238
  function getFullPath(resolver, id = "", normalize) {
2239
2239
  if (normalize !== false)
@@ -3155,7 +3155,7 @@ var require_utils = __commonJS({
3155
3155
  return true;
3156
3156
  }
3157
3157
  function getIPV6(input) {
3158
- let tokenCount = 0;
3158
+ let tokenCount2 = 0;
3159
3159
  const output = { error: false, address: "", zone: "" };
3160
3160
  const address = [];
3161
3161
  const buffer = [];
@@ -3174,7 +3174,7 @@ var require_utils = __commonJS({
3174
3174
  if (!consume(buffer, address, output)) {
3175
3175
  break;
3176
3176
  }
3177
- if (++tokenCount > 7) {
3177
+ if (++tokenCount2 > 7) {
3178
3178
  output.error = true;
3179
3179
  break;
3180
3180
  }
@@ -3229,8 +3229,8 @@ var require_utils = __commonJS({
3229
3229
  }
3230
3230
  return ind;
3231
3231
  }
3232
- function removeDotSegments(path7) {
3233
- let input = path7;
3232
+ function removeDotSegments(path10) {
3233
+ let input = path10;
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 [path7, query] = wsComponent.resourceName.split("?");
3486
- wsComponent.path = path7 && path7 !== "/" ? path7 : void 0;
3485
+ const [path10, query] = wsComponent.resourceName.split("?");
3486
+ wsComponent.path = path10 && path10 !== "/" ? path10 : void 0;
3487
3487
  wsComponent.query = query;
3488
3488
  wsComponent.resourceName = void 0;
3489
3489
  }
@@ -5411,8 +5411,8 @@ var require_contains = __commonJS({
5411
5411
  cxt.result(valid, () => cxt.reset());
5412
5412
  function validateItemsWithCount() {
5413
5413
  const schValid = gen.name("_valid");
5414
- const count = gen.let("count", 0);
5415
- validateItems(schValid, () => gen.if(schValid, () => checkLimits(count)));
5414
+ const count3 = gen.let("count", 0);
5415
+ validateItems(schValid, () => gen.if(schValid, () => checkLimits(count3)));
5416
5416
  }
5417
5417
  function validateItems(_valid, block) {
5418
5418
  gen.forRange("i", 0, len, (i) => {
@@ -5425,16 +5425,16 @@ var require_contains = __commonJS({
5425
5425
  block();
5426
5426
  });
5427
5427
  }
5428
- function checkLimits(count) {
5429
- gen.code((0, codegen_1._)`${count}++`);
5428
+ function checkLimits(count3) {
5429
+ gen.code((0, codegen_1._)`${count3}++`);
5430
5430
  if (max === void 0) {
5431
- gen.if((0, codegen_1._)`${count} >= ${min}`, () => gen.assign(valid, true).break());
5431
+ gen.if((0, codegen_1._)`${count3} >= ${min}`, () => gen.assign(valid, true).break());
5432
5432
  } else {
5433
- gen.if((0, codegen_1._)`${count} > ${max}`, () => gen.assign(valid, false).break());
5433
+ gen.if((0, codegen_1._)`${count3} > ${max}`, () => gen.assign(valid, false).break());
5434
5434
  if (min === 1)
5435
5435
  gen.assign(valid, true);
5436
5436
  else
5437
- gen.if((0, codegen_1._)`${count} >= ${min}`, () => gen.assign(valid, true));
5437
+ gen.if((0, codegen_1._)`${count3} >= ${min}`, () => gen.assign(valid, true));
5438
5438
  }
5439
5439
  }
5440
5440
  }
@@ -8933,20 +8933,20 @@ var require_resolve2 = __commonJS({
8933
8933
  return false;
8934
8934
  }
8935
8935
  function countKeys(schema) {
8936
- let count = 0;
8936
+ let count3 = 0;
8937
8937
  for (const key in schema) {
8938
8938
  if (key === "$ref")
8939
8939
  return Infinity;
8940
- count++;
8940
+ count3++;
8941
8941
  if (SIMPLE_INLINED.has(key))
8942
8942
  continue;
8943
8943
  if (typeof schema[key] == "object") {
8944
- (0, util_1.eachItem)(schema[key], (sch) => count += countKeys(sch));
8944
+ (0, util_1.eachItem)(schema[key], (sch) => count3 += countKeys(sch));
8945
8945
  }
8946
- if (count === Infinity)
8946
+ if (count3 === Infinity)
8947
8947
  return Infinity;
8948
8948
  }
8949
- return count;
8949
+ return count3;
8950
8950
  }
8951
8951
  function getFullPath(resolver, id = "", normalize) {
8952
8952
  if (normalize !== false)
@@ -11309,8 +11309,8 @@ var require_contains2 = __commonJS({
11309
11309
  cxt.result(valid, () => cxt.reset());
11310
11310
  function validateItemsWithCount() {
11311
11311
  const schValid = gen.name("_valid");
11312
- const count = gen.let("count", 0);
11313
- validateItems(schValid, () => gen.if(schValid, () => checkLimits(count)));
11312
+ const count3 = gen.let("count", 0);
11313
+ validateItems(schValid, () => gen.if(schValid, () => checkLimits(count3)));
11314
11314
  }
11315
11315
  function validateItems(_valid, block) {
11316
11316
  gen.forRange("i", 0, len, (i) => {
@@ -11323,16 +11323,16 @@ var require_contains2 = __commonJS({
11323
11323
  block();
11324
11324
  });
11325
11325
  }
11326
- function checkLimits(count) {
11327
- gen.code((0, codegen_1._)`${count}++`);
11326
+ function checkLimits(count3) {
11327
+ gen.code((0, codegen_1._)`${count3}++`);
11328
11328
  if (max === void 0) {
11329
- gen.if((0, codegen_1._)`${count} >= ${min}`, () => gen.assign(valid, true).break());
11329
+ gen.if((0, codegen_1._)`${count3} >= ${min}`, () => gen.assign(valid, true).break());
11330
11330
  } else {
11331
- gen.if((0, codegen_1._)`${count} > ${max}`, () => gen.assign(valid, false).break());
11331
+ gen.if((0, codegen_1._)`${count3} > ${max}`, () => gen.assign(valid, false).break());
11332
11332
  if (min === 1)
11333
11333
  gen.assign(valid, true);
11334
11334
  else
11335
- gen.if((0, codegen_1._)`${count} >= ${min}`, () => gen.assign(valid, true));
11335
+ gen.if((0, codegen_1._)`${count3} >= ${min}`, () => gen.assign(valid, true));
11336
11336
  }
11337
11337
  }
11338
11338
  }
@@ -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 path6 from "node:path";
12595
+ import path9 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, path7) {
13364
- if (!path7)
13363
+ function getElementAtPath(obj, path10) {
13364
+ if (!path10)
13365
13365
  return obj;
13366
- return path7.reduce((acc, key) => acc?.[key], obj);
13366
+ return path10.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(path7, issues) {
13775
+ function prefixIssues(path10, issues) {
13776
13776
  return issues.map((iss) => {
13777
13777
  var _a5;
13778
13778
  (_a5 = iss).path ?? (_a5.path = []);
13779
- iss.path.unshift(path7);
13779
+ iss.path.unshift(path10);
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, path7 = []) => {
13926
+ const processError = (error52, path10 = []) => {
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 }, [...path7, ...issue2.path]));
13929
+ issue2.errors.map((issues) => processError({ issues }, [...path10, ...issue2.path]));
13930
13930
  } else if (issue2.code === "invalid_key") {
13931
- processError({ issues: issue2.issues }, [...path7, ...issue2.path]);
13931
+ processError({ issues: issue2.issues }, [...path10, ...issue2.path]);
13932
13932
  } else if (issue2.code === "invalid_element") {
13933
- processError({ issues: issue2.issues }, [...path7, ...issue2.path]);
13933
+ processError({ issues: issue2.issues }, [...path10, ...issue2.path]);
13934
13934
  } else {
13935
- const fullpath = [...path7, ...issue2.path];
13935
+ const fullpath = [...path10, ...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, path7 = []) => {
13962
+ const processError = (error52, path10 = []) => {
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 }, [...path7, ...issue2.path]));
13966
+ issue2.errors.map((issues) => processError({ issues }, [...path10, ...issue2.path]));
13967
13967
  } else if (issue2.code === "invalid_key") {
13968
- processError({ issues: issue2.issues }, [...path7, ...issue2.path]);
13968
+ processError({ issues: issue2.issues }, [...path10, ...issue2.path]);
13969
13969
  } else if (issue2.code === "invalid_element") {
13970
- processError({ issues: issue2.issues }, [...path7, ...issue2.path]);
13970
+ processError({ issues: issue2.issues }, [...path10, ...issue2.path]);
13971
13971
  } else {
13972
- const fullpath = [...path7, ...issue2.path];
13972
+ const fullpath = [...path10, ...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 path7 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
14005
- for (const seg of path7) {
14004
+ const path10 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
14005
+ for (const seg of path10) {
14006
14006
  if (typeof seg === "number")
14007
14007
  segs.push(`[${seg}]`);
14008
14008
  else if (typeof seg === "symbol")
@@ -17230,8 +17230,8 @@ function az_default() {
17230
17230
  }
17231
17231
 
17232
17232
  // ../../../node_modules/zod/v4/locales/be.js
17233
- function getBelarusianPlural(count, one, few, many) {
17234
- const absCount = Math.abs(count);
17233
+ function getBelarusianPlural(count3, one, few, many) {
17234
+ const absCount = Math.abs(count3);
17235
17235
  const lastDigit = absCount % 10;
17236
17236
  const lastTwoDigits = absCount % 100;
17237
17237
  if (lastTwoDigits >= 11 && lastTwoDigits <= 19) {
@@ -19309,8 +19309,8 @@ function hu_default() {
19309
19309
  }
19310
19310
 
19311
19311
  // ../../../node_modules/zod/v4/locales/hy.js
19312
- function getArmenianPlural(count, one, many) {
19313
- return Math.abs(count) === 1 ? one : many;
19312
+ function getArmenianPlural(count3, one, many) {
19313
+ return Math.abs(count3) === 1 ? one : many;
19314
19314
  }
19315
19315
  function withDefiniteArticle(word) {
19316
19316
  if (!word)
@@ -21438,8 +21438,8 @@ function ro_default() {
21438
21438
  }
21439
21439
 
21440
21440
  // ../../../node_modules/zod/v4/locales/ru.js
21441
- function getRussianPlural(count, one, few, many) {
21442
- const absCount = Math.abs(count);
21441
+ function getRussianPlural(count3, one, few, many) {
21442
+ const absCount = Math.abs(count3);
21443
21443
  const lastDigit = absCount % 10;
21444
21444
  const lastTwoDigits = absCount % 100;
21445
21445
  if (lastTwoDigits >= 11 && lastTwoDigits <= 19) {
@@ -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 path7 = ref.slice(1).split("/").filter(Boolean);
26698
- if (path7.length === 0) {
26697
+ const path10 = ref.slice(1).split("/").filter(Boolean);
26698
+ if (path10.length === 0) {
26699
26699
  return ctx.rootSchema;
26700
26700
  }
26701
26701
  const defsKey = ctx.version === "draft-2020-12" ? "$defs" : "definitions";
26702
- if (path7[0] === defsKey) {
26703
- const key = path7[1];
26702
+ if (path10[0] === defsKey) {
26703
+ const key = path10[1];
26704
26704
  if (!key || !ctx.defs[key]) {
26705
26705
  throw new Error(`Reference not found: ${ref}`);
26706
26706
  }
@@ -27108,6 +27108,15 @@ function date4(params) {
27108
27108
  // ../../../node_modules/zod/v4/classic/external.js
27109
27109
  config(en_default());
27110
27110
 
27111
+ // ../../shared-contracts/dist/delegation-read.js
27112
+ var REMOTE_THREAD_REPLY_MAX_BYTES = 16 * 1024 * 1024;
27113
+ var delegationReadParamsSchema = external_exports.strictObject({
27114
+ threadId: external_exports.string().min(1).max(1024),
27115
+ view: external_exports.enum(["result", "messages"]),
27116
+ cursor: external_exports.string().min(1).max(8192).optional(),
27117
+ limit: external_exports.number().int().min(1).max(100).optional()
27118
+ });
27119
+
27111
27120
  // ../../shared-contracts/dist/credential-imports.js
27112
27121
  var credentialSourceSchema = external_exports.object({
27113
27122
  id: external_exports.string().min(1).max(256),
@@ -27178,6 +27187,160 @@ var harnessDisplaySetSchema = external_exports.strictObject({
27178
27187
  initializeOnly: external_exports.boolean().optional()
27179
27188
  });
27180
27189
 
27190
+ // ../../shared-contracts/dist/model-price-overrides.js
27191
+ var usdPerMillionTokens = external_exports.number().finite().nonnegative();
27192
+ var modelPriceOverrideSchema = external_exports.strictObject({
27193
+ input: usdPerMillionTokens,
27194
+ output: usdPerMillionTokens,
27195
+ cacheRead: usdPerMillionTokens.optional(),
27196
+ cacheWrite: usdPerMillionTokens.optional(),
27197
+ cacheWrite1h: usdPerMillionTokens.optional()
27198
+ });
27199
+ var modelPriceKeySchema = external_exports.string().max(512).refine((key) => key.trim() === key && key.length > 0, "Model ID is required");
27200
+ var modelPriceOverridesSchema = external_exports.strictObject({
27201
+ /** Absolute path of the Host's `pricing.json`. */
27202
+ path: external_exports.string(),
27203
+ entries: external_exports.array(external_exports.strictObject({ key: external_exports.string(), price: modelPriceOverrideSchema })),
27204
+ /** Why the existing file is unusable; the Host then ignores it and refuses to overwrite it. */
27205
+ error: external_exports.string().nullable()
27206
+ });
27207
+ var modelPriceOverridesGetSchema = external_exports.strictObject({});
27208
+ var modelPriceOverridesSetSchema = external_exports.strictObject({
27209
+ key: modelPriceKeySchema,
27210
+ price: modelPriceOverrideSchema.nullable(),
27211
+ previousKey: modelPriceKeySchema.optional()
27212
+ });
27213
+ var modelPriceDefaultParamsSchema = external_exports.strictObject({
27214
+ model: modelPriceKeySchema
27215
+ });
27216
+ var modelPriceSuggestionSchema = external_exports.strictObject({
27217
+ /** Verified from catalog canonical links, not inferred from names or equal prices. */
27218
+ official: external_exports.boolean().optional(),
27219
+ canonicalModelId: external_exports.string().min(1).optional(),
27220
+ provider: external_exports.string().min(1).max(512),
27221
+ model: external_exports.string().min(1).max(512),
27222
+ price: modelPriceOverrideSchema
27223
+ });
27224
+ var modelPriceDefaultResultSchema = external_exports.strictObject({
27225
+ price: modelPriceOverrideSchema.nullable(),
27226
+ /** Local catalog suggestions only; never used automatically for pricing. */
27227
+ suggestions: external_exports.array(modelPriceSuggestionSchema).max(6).optional()
27228
+ });
27229
+
27230
+ // ../../shared-contracts/dist/usage-statistics.js
27231
+ var USAGE_STATISTICS_RANGES = ["today", "7d", "30d", "90d", "all"];
27232
+ var count = external_exports.number().int().min(0).max(Number.MAX_SAFE_INTEGER);
27233
+ var localDate = external_exports.string().regex(/^\d{4}-\d{2}-\d{2}$/u);
27234
+ var harness = external_exports.string().min(1).max(128);
27235
+ var model = external_exports.string().min(1).max(512);
27236
+ var project = external_exports.string().min(1).max(4096);
27237
+ var usageStatisticsParamsSchema = external_exports.strictObject({
27238
+ range: external_exports.enum(USAGE_STATISTICS_RANGES),
27239
+ harness: harness.optional(),
27240
+ model: model.nullable().optional(),
27241
+ project: project.nullable().optional(),
27242
+ /** One local date inside the range. */
27243
+ date: localDate.optional()
27244
+ });
27245
+ var usageStatisticsTotalsSchema = external_exports.strictObject({
27246
+ requests: count,
27247
+ inputTokens: count,
27248
+ cachedInputTokens: count,
27249
+ cacheWriteInputTokens: count,
27250
+ cacheKnownInputTokens: count,
27251
+ outputTokens: count,
27252
+ reasoningOutputTokens: count,
27253
+ /** USD at the public price, summed over the priced requests only. */
27254
+ costUsd: external_exports.number().finite().min(0),
27255
+ /** Requests without a price (or the cache data the price needs); not in `costUsd`. */
27256
+ unpricedRequests: count,
27257
+ /**
27258
+ * Requests whose storage gave no token counts: counted as requests, with neither tokens nor
27259
+ * cost, and not as unpriced.
27260
+ */
27261
+ unmeteredRequests: count
27262
+ });
27263
+ var totals = usageStatisticsTotalsSchema.shape;
27264
+ var usageStatisticsSessionSchema = external_exports.strictObject({
27265
+ harness,
27266
+ sessionId: external_exports.string().min(1).max(512),
27267
+ project: project.nullable(),
27268
+ /** Persisted Desktop title for a mapped Session, otherwise its native name; may be absent. */
27269
+ title: external_exports.string().min(1).max(200).optional(),
27270
+ /** Models the session used, most requests first. */
27271
+ models: external_exports.array(model).max(16),
27272
+ firstAtMs: count,
27273
+ lastAtMs: count,
27274
+ ...totals
27275
+ });
27276
+ var usageStatisticsResultSchema = external_exports.strictObject({
27277
+ range: external_exports.enum(USAGE_STATISTICS_RANGES),
27278
+ /** First local date of the range; null for all time. */
27279
+ from: localDate.nullable(),
27280
+ to: localDate,
27281
+ /** The filters these figures apply, echoed so a late answer to older filters is recognised. */
27282
+ filters: external_exports.strictObject({
27283
+ harness: harness.nullable(),
27284
+ model: model.nullable(),
27285
+ unknownModel: external_exports.boolean(),
27286
+ project: project.nullable(),
27287
+ unknownProject: external_exports.boolean(),
27288
+ date: localDate.nullable()
27289
+ }),
27290
+ /** Reading of native storage: incomplete while the first read, or a refresh, is under way. */
27291
+ reading: external_exports.strictObject({ complete: external_exports.boolean(), sources: count, read: count }),
27292
+ /** Harnesses whose storage could not be read; their part is missing, the rest is complete. */
27293
+ failures: external_exports.array(external_exports.strictObject({ harness, message: external_exports.string().max(2048) })).max(256),
27294
+ /** Every value seen in the range, ignoring the filters, to choose filters from. */
27295
+ options: external_exports.strictObject({
27296
+ harnesses: external_exports.array(harness).max(256),
27297
+ models: external_exports.array(model.nullable()).max(4096),
27298
+ projects: external_exports.array(project.nullable()).max(4096)
27299
+ }),
27300
+ /** Current display metadata, scoped by Harness. Never a pricing or filter identity.
27301
+ * Optional for older Hosts; missing/conflicting labels fall back to the native model ID.
27302
+ */
27303
+ modelLabels: external_exports.array(external_exports.strictObject({ harness, model, label: model })).max(4096).optional(),
27304
+ /** Native credits, all filters applied, never combined across Harnesses or treated as USD.
27305
+ * Only groups with at least one reported value appear; reportedRequests exposes partial data.
27306
+ */
27307
+ credits: external_exports.array(external_exports.strictObject({
27308
+ harness,
27309
+ model: model.nullable(),
27310
+ credits: external_exports.number().finite().min(0),
27311
+ reportedRequests: count,
27312
+ requests: count
27313
+ })).max(4096).optional(),
27314
+ /** All filters applied. */
27315
+ totals: usageStatisticsTotalsSchema,
27316
+ /** Each date and Harness of the range: every filter except the day. */
27317
+ daily: external_exports.array(external_exports.strictObject({ date: localDate, harness, ...totals })).max(2e5),
27318
+ /** Local weekday (0 = Sunday) and hour, all filters applied. */
27319
+ hourly: external_exports.array(external_exports.strictObject({
27320
+ weekday: external_exports.number().int().min(0).max(6),
27321
+ hour: external_exports.number().int().min(0).max(23),
27322
+ ...totals
27323
+ })).max(168),
27324
+ byHarness: external_exports.array(external_exports.strictObject({ harness, ...totals })).max(256),
27325
+ byModel: external_exports.array(external_exports.strictObject({
27326
+ model: model.nullable(),
27327
+ ...totals,
27328
+ /** Requests priced by what the Harness recorded they cost, not by a price list. */
27329
+ harnessPricedRequests: count
27330
+ })).max(4096),
27331
+ byProject: external_exports.array(external_exports.strictObject({ project: project.nullable(), ...totals })).max(4096),
27332
+ /**
27333
+ * The sessions that spent the most, by cost and by tokens without cache, all filters applied;
27334
+ * requests without a native session are not listed here but count everywhere else.
27335
+ */
27336
+ sessions: external_exports.array(usageStatisticsSessionSchema).max(100),
27337
+ /**
27338
+ * The sessions last active in the range, newest first, all filters applied. Optional for older
27339
+ * Hosts; missing is treated as no list rather than no sessions.
27340
+ */
27341
+ recentSessions: external_exports.array(usageStatisticsSessionSchema).max(100).optional()
27342
+ });
27343
+
27181
27344
  // ../../shared-contracts/dist/ids.js
27182
27345
  var opaqueIdSchema = external_exports.string().refine((value) => value.trim().length > 0, {
27183
27346
  message: "Identifier must not be empty or whitespace"
@@ -27225,6 +27388,10 @@ var CONSOLE_HOST_METHODS = Object.freeze([
27225
27388
  "codexhost/account/list",
27226
27389
  "codexhost/account/refresh",
27227
27390
  "codexhost/account/usage/inspect",
27391
+ "codexhost/usage/model-prices/get",
27392
+ "codexhost/usage/model-prices/set",
27393
+ "codexhost/usage/model-prices/default",
27394
+ "codexhost/usage/statistics/get",
27228
27395
  "codexhost/update/check",
27229
27396
  "codexhost/update/start",
27230
27397
  "codexhost/update/status"
@@ -27289,6 +27456,7 @@ var threadUsageSnapshotSchema = external_exports.object({
27289
27456
  cacheWriteInputTokens: nonNegativeSafeIntegerSchema.optional(),
27290
27457
  outputTokens: nonNegativeSafeIntegerSchema.optional(),
27291
27458
  outputTokensPerSecond: finiteNonNegativeNumberSchema.optional(),
27459
+ apiOutputTokensPerSecond: finiteNonNegativeNumberSchema.optional(),
27292
27460
  reasoningOutputTokens: nonNegativeSafeIntegerSchema.optional(),
27293
27461
  totalTokens: nonNegativeSafeIntegerSchema.optional(),
27294
27462
  totalCostUsd: finiteNonNegativeNumberSchema.optional(),
@@ -27300,7 +27468,11 @@ var threadUsageSnapshotSchema = external_exports.object({
27300
27468
  planFiveHourUsedPercent: cacheHitRatePercentSchema.optional(),
27301
27469
  planFiveHourResetsAtUnix: nonNegativeSafeIntegerSchema.optional(),
27302
27470
  planSevenDayUsedPercent: cacheHitRatePercentSchema.optional(),
27303
- planSevenDayResetsAtUnix: nonNegativeSafeIntegerSchema.optional()
27471
+ planSevenDayResetsAtUnix: nonNegativeSafeIntegerSchema.optional(),
27472
+ sessionCacheHitRatePercent: cacheHitRatePercentSchema.optional(),
27473
+ timeToFirstOutputMs: nonNegativeSafeIntegerSchema.optional(),
27474
+ costSource: external_exports.enum(["publicPrice", "native"]).optional(),
27475
+ unpricedModels: external_exports.array(external_exports.string().min(1)).min(1).optional()
27304
27476
  }).strict().superRefine((usage, context) => {
27305
27477
  if (Object.keys(usage).length === 0) {
27306
27478
  context.addIssue({ code: "custom", message: "Thread Usage must contain a reliable field" });
@@ -27321,6 +27493,20 @@ var threadUsageSnapshotSchema = external_exports.object({
27321
27493
  path: ["contextWindowTokens"]
27322
27494
  });
27323
27495
  }
27496
+ if (usage.costSource !== void 0 && usage.totalCostUsd === void 0) {
27497
+ context.addIssue({
27498
+ code: "custom",
27499
+ message: "Thread Usage costSource must be provided with totalCostUsd",
27500
+ path: ["costSource"]
27501
+ });
27502
+ }
27503
+ if (usage.unpricedModels !== void 0 && usage.costSource !== "publicPrice") {
27504
+ context.addIssue({
27505
+ code: "custom",
27506
+ message: "Thread Usage unpricedModels must be provided with a publicPrice cost",
27507
+ path: ["unpricedModels"]
27508
+ });
27509
+ }
27324
27510
  if (usage.planFiveHourResetsAtUnix !== void 0 && usage.planFiveHourUsedPercent === void 0) {
27325
27511
  context.addIssue({
27326
27512
  code: "custom",
@@ -27575,27 +27761,27 @@ var harnessModelCatalogSchema = external_exports.object({
27575
27761
  }).strict().superRefine((catalog, context) => {
27576
27762
  const refs = /* @__PURE__ */ new Set();
27577
27763
  const thinkingIds = new Set(catalog.thinkingOptions.map(({ id }) => id));
27578
- for (const [index, model] of catalog.models.entries()) {
27579
- if (refs.has(model.ref.id)) {
27764
+ for (const [index, model2] of catalog.models.entries()) {
27765
+ if (refs.has(model2.ref.id)) {
27580
27766
  context.addIssue({
27581
27767
  code: "custom",
27582
27768
  message: "Model Catalog refs must be unique",
27583
27769
  path: ["models", index, "ref", "id"]
27584
27770
  });
27585
27771
  }
27586
- refs.add(model.ref.id);
27587
- if (model.fastModel) {
27588
- if (refs.has(model.fastModel.id) || catalog.models.some((entry) => entry.ref.id === model.fastModel?.id)) {
27772
+ refs.add(model2.ref.id);
27773
+ if (model2.fastModel) {
27774
+ if (refs.has(model2.fastModel.id) || catalog.models.some((entry) => entry.ref.id === model2.fastModel?.id)) {
27589
27775
  context.addIssue({
27590
27776
  code: "custom",
27591
27777
  message: "Fast Model refs must be distinct and unique",
27592
27778
  path: ["models", index, "fastModel"]
27593
27779
  });
27594
27780
  }
27595
- refs.add(model.fastModel.id);
27781
+ refs.add(model2.fastModel.id);
27596
27782
  }
27597
27783
  const supportedThinkingIds = /* @__PURE__ */ new Set();
27598
- for (const [optionIndex, optionId] of (model.supportedThinkingOptionIds ?? []).entries()) {
27784
+ for (const [optionIndex, optionId] of (model2.supportedThinkingOptionIds ?? []).entries()) {
27599
27785
  if (supportedThinkingIds.has(optionId)) {
27600
27786
  context.addIssue({
27601
27787
  code: "custom",
@@ -27789,13 +27975,40 @@ var HARNESS_PLUGIN_LIMIT = 128;
27789
27975
  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);
27790
27976
  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");
27791
27977
  var documentationUrlSchema = external_exports.url().refine((value) => /^https:\/\/[^/?#@]+(?:[/?#]|$)/iu.test(value), "Plugin documentation links must be credential-free HTTPS URLs");
27978
+ var localizedTextSchema = external_exports.object({ en: external_exports.string().max(4096), "zh-CN": external_exports.string().max(4096).optional() }).strict();
27979
+ var harnessInstallationGuideSchema = external_exports.object({
27980
+ commands: external_exports.array(external_exports.object({ terminal: external_exports.string().max(256), command: external_exports.string().max(4096) }).strict()).max(8),
27981
+ before: localizedTextSchema.optional(),
27982
+ after: localizedTextSchema.optional(),
27983
+ downloads: external_exports.array(external_exports.object({ label: external_exports.string().max(128), url: documentationUrlSchema }).strict()).max(8).optional()
27984
+ }).strict();
27792
27985
  var pluginPresentationShape = {
27793
27986
  id: harnessPluginIdSchema,
27794
27987
  name: external_exports.string().trim().min(1).max(128),
27795
27988
  version: external_exports.string().min(1).max(128),
27989
+ /** Capability-only plugin; omitted for existing session-capable plugins. */
27990
+ kind: external_exports.literal("usage").optional(),
27991
+ /** Original image styling or bounded vector paths; never arbitrary CSS/SVG markup. */
27992
+ iconStyle: external_exports.object({
27993
+ vector: external_exports.object({
27994
+ viewBox: external_exports.string().max(128).regex(/^-?\d+(?:\.\d+)?(?: +-?\d+(?:\.\d+)?){3}$/u),
27995
+ color: external_exports.string().regex(/^(?:currentColor|#[a-f0-9]{6})$/iu),
27996
+ paths: external_exports.array(external_exports.object({
27997
+ d: external_exports.string().min(1).max(32768).regex(/^[MmLlHhVvCcSsQqTtAaZz\d.,+eE\s-]+$/u),
27998
+ fillRule: external_exports.enum(["evenodd", "nonzero"]).optional(),
27999
+ fill: external_exports.string().regex(/^(?:currentColor|#[a-f0-9]{6})$/iu).optional()
28000
+ }).strict()).min(1).max(32)
28001
+ }).strict().optional(),
28002
+ background: external_exports.string().regex(/^#[a-f0-9]{6}$/iu).optional(),
28003
+ borderRadius: external_exports.number().min(0).max(50).optional(),
28004
+ paddingRatio: external_exports.number().min(0).max(0.25).optional()
28005
+ }).strict().optional(),
28006
+ installation: harnessInstallationGuideSchema.optional(),
28007
+ notice: localizedTextSchema.optional(),
27796
28008
  /** The factory accepts a persisted local entrypoint through its construction context. */
27797
28009
  launchCommand: external_exports.literal(true).optional(),
27798
28010
  links: external_exports.object({
28011
+ website: documentationUrlSchema.optional(),
27799
28012
  documentation: documentationUrlSchema.optional(),
27800
28013
  installation: documentationUrlSchema.optional()
27801
28014
  }).strict().optional()
@@ -28214,6 +28427,11 @@ var codexSshDraftSchema = external_exports.strictObject({
28214
28427
  });
28215
28428
  var remoteConnectionsRequestSchema = external_exports.discriminatedUnion("action", [
28216
28429
  external_exports.strictObject({ action: external_exports.literal("list") }),
28430
+ external_exports.strictObject({
28431
+ action: external_exports.literal("read-thread"),
28432
+ hostId: hostId.refine((id) => id !== "local"),
28433
+ input: delegationReadParamsSchema
28434
+ }),
28217
28435
  external_exports.strictObject({
28218
28436
  action: external_exports.literal("save"),
28219
28437
  draft: codexSshDraftSchema,
@@ -29025,10 +29243,12 @@ var tokenFields = [
29025
29243
  ];
29026
29244
  var safeIntegerFields = [
29027
29245
  "planFiveHourResetsAtUnix",
29028
- "planSevenDayResetsAtUnix"
29246
+ "planSevenDayResetsAtUnix",
29247
+ "timeToFirstOutputMs"
29029
29248
  ];
29030
29249
  var percentFields = [
29031
29250
  "cacheHitRatePercent",
29251
+ "sessionCacheHitRatePercent",
29032
29252
  "planFiveHourUsedPercent",
29033
29253
  "planSevenDayUsedPercent"
29034
29254
  ];
@@ -29036,10 +29256,14 @@ var usageFields = /* @__PURE__ */ new Set([
29036
29256
  ...tokenFields,
29037
29257
  ...safeIntegerFields,
29038
29258
  ...percentFields,
29259
+ "sessionCacheUsage",
29039
29260
  "totalCostUsd",
29040
29261
  "totalCredits",
29041
29262
  "contextUsagePercent",
29042
- "outputTokensPerSecond"
29263
+ "outputTokensPerSecond",
29264
+ "apiOutputTokensPerSecond",
29265
+ "costSource",
29266
+ "unpricedModels"
29043
29267
  ]);
29044
29268
  function isRecord(value) {
29045
29269
  return typeof value === "object" && value !== null && !Array.isArray(value);
@@ -29055,7 +29279,11 @@ function parseHostUsage(value) {
29055
29279
  throw new Error(`Harness Usage contains unknown field '${key}'`);
29056
29280
  }
29057
29281
  }
29058
- for (const field of ["totalCredits", "contextUsagePercent"]) {
29282
+ for (const field of [
29283
+ "totalCredits",
29284
+ "contextUsagePercent",
29285
+ "apiOutputTokensPerSecond"
29286
+ ]) {
29059
29287
  const candidate = value[field];
29060
29288
  if (candidate !== void 0 && (typeof candidate !== "number" || !Number.isFinite(candidate) || candidate < 0)) {
29061
29289
  throw new Error(`Harness Usage '${field}' must be a finite non-negative number`);
@@ -29085,6 +29313,12 @@ function parseHostUsage(value) {
29085
29313
  throw new Error(`Harness Usage '${field}' must be between 0 and 100`);
29086
29314
  }
29087
29315
  }
29316
+ if (value.sessionCacheUsage !== void 0) {
29317
+ const totals2 = value.sessionCacheUsage;
29318
+ if (!isRecord(totals2) || Object.keys(totals2).some((key) => key !== "inputTokens" && key !== "cachedInputTokens") || typeof totals2.inputTokens !== "number" || !Number.isSafeInteger(totals2.inputTokens) || totals2.inputTokens < 0 || typeof totals2.cachedInputTokens !== "number" || !Number.isSafeInteger(totals2.cachedInputTokens) || totals2.cachedInputTokens < 0 || totals2.cachedInputTokens > totals2.inputTokens) {
29319
+ throw new Error("Harness Usage 'sessionCacheUsage' must contain complete bounded token totals");
29320
+ }
29321
+ }
29088
29322
  const hasContextUsed = value.contextUsedTokens !== void 0;
29089
29323
  const hasContextWindow = value.contextWindowTokens !== void 0;
29090
29324
  if (hasContextUsed !== hasContextWindow) {
@@ -29099,8 +29333,43 @@ function parseHostUsage(value) {
29099
29333
  if (value.planSevenDayResetsAtUnix !== void 0 && value.planSevenDayUsedPercent === void 0) {
29100
29334
  throw new Error("Harness Usage 'planSevenDayResetsAtUnix' must be provided with 'planSevenDayUsedPercent'");
29101
29335
  }
29336
+ if (value.costSource !== void 0) {
29337
+ if (value.costSource !== "publicPrice" && value.costSource !== "native") {
29338
+ throw new Error("Harness Usage 'costSource' must be 'publicPrice' or 'native'");
29339
+ }
29340
+ if (value.totalCostUsd === void 0) {
29341
+ throw new Error("Harness Usage 'costSource' must be provided with 'totalCostUsd'");
29342
+ }
29343
+ }
29344
+ if (value.unpricedModels !== void 0) {
29345
+ const models = value.unpricedModels;
29346
+ if (!Array.isArray(models) || models.length === 0 || !models.every((model2) => typeof model2 === "string" && model2.length > 0)) {
29347
+ throw new Error("Harness Usage 'unpricedModels' must be a non-empty list of Model IDs");
29348
+ }
29349
+ if (value.costSource !== "publicPrice") {
29350
+ throw new Error("Harness Usage 'unpricedModels' must be provided with a 'publicPrice' cost");
29351
+ }
29352
+ return { ...value, unpricedModels: [...models] };
29353
+ }
29102
29354
  return { ...value };
29103
29355
  }
29356
+ var requestTokenFields = [
29357
+ "inputTokens",
29358
+ "cachedInputTokens",
29359
+ "cacheWriteInputTokens",
29360
+ "cacheWrite1hInputTokens",
29361
+ "outputTokens",
29362
+ "reasoningOutputTokens",
29363
+ "startedAtMs",
29364
+ "completedAtMs"
29365
+ ];
29366
+ var requestFields = /* @__PURE__ */ new Set([
29367
+ ...requestTokenFields,
29368
+ "requestId",
29369
+ "historical",
29370
+ "model",
29371
+ "provider"
29372
+ ]);
29104
29373
 
29105
29374
  // ../../harness-adapter/dist/live-command-catalog.js
29106
29375
  var COMMON_EXCLUDED_LIVE_COMMANDS = /* @__PURE__ */ new Set([
@@ -29755,10 +30024,10 @@ function parseQoderModelCatalog(rawModels) {
29755
30024
  ...defaultThinkingOptionId ? { defaultThinkingOptionId } : {}
29756
30025
  });
29757
30026
  }
29758
- function qoderAvailableThinkingOptions(catalog, model) {
29759
- if (!catalog || !model)
30027
+ function qoderAvailableThinkingOptions(catalog, model2) {
30028
+ if (!catalog || !model2)
29760
30029
  return void 0;
29761
- const supported = catalog.models.find(({ ref }) => ref.id === model.id)?.supportedThinkingOptionIds;
30030
+ const supported = catalog.models.find(({ ref }) => ref.id === model2.id)?.supportedThinkingOptionIds;
29762
30031
  if (!supported || supported.length === 0)
29763
30032
  return void 0;
29764
30033
  const options = supported.flatMap((id) => {
@@ -30270,8 +30539,8 @@ function getErrorMap2() {
30270
30539
 
30271
30540
  // ../../../node_modules/zod/v3/helpers/parseUtil.js
30272
30541
  var makeIssue = (params) => {
30273
- const { data, path: path7, errorMaps, issueData } = params;
30274
- const fullPath = [...path7, ...issueData.path || []];
30542
+ const { data, path: path10, errorMaps, issueData } = params;
30543
+ const fullPath = [...path10, ...issueData.path || []];
30275
30544
  const fullIssue = {
30276
30545
  ...issueData,
30277
30546
  path: fullPath
@@ -30386,11 +30655,11 @@ var errorUtil;
30386
30655
 
30387
30656
  // ../../../node_modules/zod/v3/types.js
30388
30657
  var ParseInputLazyPath = class {
30389
- constructor(parent, value, path7, key) {
30658
+ constructor(parent, value, path10, key) {
30390
30659
  this._cachedPath = [];
30391
30660
  this.parent = parent;
30392
30661
  this.data = value;
30393
- this._path = path7;
30662
+ this._path = path10;
30394
30663
  this._key = key;
30395
30664
  }
30396
30665
  get path() {
@@ -33917,11 +34186,11 @@ function normalizeObjectSchema(schema) {
33917
34186
  }
33918
34187
  return void 0;
33919
34188
  }
33920
- function getDotPath(path7) {
33921
- if (path7.length === 0) {
34189
+ function getDotPath(path10) {
34190
+ if (path10.length === 0) {
33922
34191
  return "object root";
33923
34192
  }
33924
- return path7.reduce((acc, seg, index) => {
34193
+ return path10.reduce((acc, seg, index) => {
33925
34194
  if (index === 0) {
33926
34195
  return String(seg);
33927
34196
  }
@@ -52650,6 +52919,289 @@ var QoderSessionImport = class {
52650
52919
  }
52651
52920
  };
52652
52921
 
52922
+ // ../qoder/dist/qoder-usage-statistics.js
52923
+ import os4 from "node:os";
52924
+ import path8 from "node:path";
52925
+
52926
+ // ../../harness-adapter/dist/usage-statistics.js
52927
+ import { createReadStream } from "node:fs";
52928
+ import { lstat, opendir } from "node:fs/promises";
52929
+ import path6 from "node:path";
52930
+ import { createInterface } from "node:readline";
52931
+ var MAX_SESSION_ID_LENGTH = 512;
52932
+ var MAX_CWD_LENGTH = 4096;
52933
+ var MAX_SESSION_TITLE_LENGTH = 200;
52934
+ function usageSessionTitle(value) {
52935
+ if (typeof value !== "string")
52936
+ return void 0;
52937
+ const normalized = value.replaceAll("\0", "").replaceAll(/\s+/gu, " ").trim();
52938
+ if (!normalized)
52939
+ return void 0;
52940
+ if (normalized.length <= MAX_SESSION_TITLE_LENGTH)
52941
+ return normalized;
52942
+ const characters = [...normalized];
52943
+ if (characters.length <= MAX_SESSION_TITLE_LENGTH)
52944
+ return normalized;
52945
+ return `${characters.slice(0, MAX_SESSION_TITLE_LENGTH - 1).join("").trimEnd()}…`;
52946
+ }
52947
+ function sessionIdOk(value) {
52948
+ return typeof value === "string" && value.length > 0 && value.length <= MAX_SESSION_ID_LENGTH;
52949
+ }
52950
+ function cwdOk(value) {
52951
+ return typeof value === "string" && value.length > 0 && value.length <= MAX_CWD_LENGTH && !value.includes("\0") && (value.startsWith("/") || /^[A-Za-z]:[\\/]/u.test(value) || value.startsWith("\\\\"));
52952
+ }
52953
+ function withUsageSession(entry, session) {
52954
+ const sessionId = sessionIdOk(session.sessionId) ? session.sessionId : void 0;
52955
+ const cwd = cwdOk(session.cwd) ? session.cwd : void 0;
52956
+ const sessionTitle = sessionId !== void 0 ? usageSessionTitle(session.title) : void 0;
52957
+ if (sessionId === void 0 && cwd === void 0)
52958
+ return entry;
52959
+ return {
52960
+ ...entry,
52961
+ ...sessionId !== void 0 ? { sessionId } : {},
52962
+ ...cwd !== void 0 ? { cwd } : {},
52963
+ ...sessionTitle !== void 0 ? { sessionTitle } : {}
52964
+ };
52965
+ }
52966
+ function tokenCount(value) {
52967
+ return typeof value === "number" && Number.isSafeInteger(value) && value >= 0;
52968
+ }
52969
+ function parseHarnessUsageEntry(value) {
52970
+ if (typeof value !== "object" || value === null || Array.isArray(value))
52971
+ return null;
52972
+ const entry = value;
52973
+ if (typeof entry.id !== "string" || entry.id.length === 0 || entry.id.length > 512)
52974
+ return null;
52975
+ if (!tokenCount(entry.occurredAtMs) || entry.occurredAtMs === 0)
52976
+ return null;
52977
+ if (entry.model !== void 0 && (typeof entry.model !== "string" || entry.model.length === 0)) {
52978
+ return null;
52979
+ }
52980
+ if (!tokenCount(entry.inputTokens) || !tokenCount(entry.outputTokens))
52981
+ return null;
52982
+ for (const field of [
52983
+ "cachedInputTokens",
52984
+ "cacheWriteInputTokens",
52985
+ "cacheWrite1hInputTokens",
52986
+ "reasoningOutputTokens"
52987
+ ]) {
52988
+ if (entry[field] !== void 0 && !tokenCount(entry[field]))
52989
+ return null;
52990
+ }
52991
+ const cached2 = entry.cachedInputTokens ?? 0;
52992
+ const written = entry.cacheWriteInputTokens ?? 0;
52993
+ if (cached2 + written > entry.inputTokens)
52994
+ return null;
52995
+ if ((entry.cacheWrite1hInputTokens ?? 0) > written)
52996
+ return null;
52997
+ if ((entry.reasoningOutputTokens ?? 0) > entry.outputTokens)
52998
+ return null;
52999
+ if (entry.sessionId !== void 0 && !sessionIdOk(entry.sessionId))
53000
+ return null;
53001
+ if (entry.cwd !== void 0 && !cwdOk(entry.cwd))
53002
+ return null;
53003
+ if (entry.sessionTitle !== void 0) {
53004
+ const sessionTitle = usageSessionTitle(entry.sessionTitle);
53005
+ if (sessionTitle === void 0)
53006
+ return null;
53007
+ entry.sessionTitle = sessionTitle;
53008
+ }
53009
+ if (entry.tokensUnknown !== void 0 && entry.tokensUnknown !== true)
53010
+ return null;
53011
+ if (entry.costUsd !== void 0 && (typeof entry.costUsd !== "number" || !Number.isFinite(entry.costUsd) || entry.costUsd < 0)) {
53012
+ return null;
53013
+ }
53014
+ if (entry.credits !== void 0 && (typeof entry.credits !== "number" || !Number.isFinite(entry.credits) || entry.credits < 0)) {
53015
+ return null;
53016
+ }
53017
+ return entry;
53018
+ }
53019
+ async function jsonlUsageSources(root, maxDepth, signal) {
53020
+ const sources = [];
53021
+ const visit = async (directory, depth) => {
53022
+ signal.throwIfAborted();
53023
+ const entries = await opendir(directory).catch((error51) => {
53024
+ if (error51.code === "ENOENT")
53025
+ return null;
53026
+ throw error51;
53027
+ });
53028
+ if (!entries)
53029
+ return;
53030
+ for await (const entry of entries) {
53031
+ signal.throwIfAborted();
53032
+ const file2 = path6.join(directory, entry.name);
53033
+ if (entry.isDirectory()) {
53034
+ if (depth < maxDepth)
53035
+ await visit(file2, depth + 1);
53036
+ } else if (entry.isFile() && entry.name.endsWith(".jsonl")) {
53037
+ const info = await lstat(file2).catch(() => null);
53038
+ if (info?.isFile() && info.size > 0) {
53039
+ sources.push({ id: file2, fingerprint: `${info.ino}:${info.size}:${info.mtimeMs}` });
53040
+ }
53041
+ }
53042
+ }
53043
+ };
53044
+ await visit(root, 0);
53045
+ return sources;
53046
+ }
53047
+ async function* jsonlRecords(file2, marker, signal) {
53048
+ const lines = createInterface({
53049
+ input: createReadStream(file2, { encoding: "utf8", signal }),
53050
+ crlfDelay: Infinity
53051
+ });
53052
+ for await (const line of lines) {
53053
+ if (!line.includes(marker))
53054
+ continue;
53055
+ let value;
53056
+ try {
53057
+ value = JSON.parse(line);
53058
+ } catch {
53059
+ continue;
53060
+ }
53061
+ if (typeof value === "object" && value !== null && !Array.isArray(value)) {
53062
+ yield value;
53063
+ }
53064
+ }
53065
+ }
53066
+ function nativeTimeMs(value) {
53067
+ const time3 = typeof value === "number" ? value : typeof value === "string" ? Date.parse(value) : Number.NaN;
53068
+ return Number.isFinite(time3) && time3 > 0 ? Math.floor(time3) : null;
53069
+ }
53070
+
53071
+ // ../qoder/dist/qoder-model-labels.js
53072
+ import { readFile, stat as stat2 } from "node:fs/promises";
53073
+ import path7 from "node:path";
53074
+ function record3(value) {
53075
+ return typeof value === "object" && value !== null && !Array.isArray(value);
53076
+ }
53077
+ async function readQoderModelLabels(configDirectory, signal) {
53078
+ signal.throwIfAborted();
53079
+ try {
53080
+ const file2 = path7.join(configDirectory, ".auth", "dynamic-texts.json");
53081
+ if ((await stat2(file2)).size > 1024 * 1024)
53082
+ return {};
53083
+ const data = JSON.parse(await readFile(file2, { encoding: "utf8", signal }));
53084
+ if (!record3(data) || !record3(data.locales))
53085
+ return {};
53086
+ const labels = /* @__PURE__ */ new Map();
53087
+ for (const locale of ["zh-CN", "en"]) {
53088
+ const texts = data.locales[locale];
53089
+ if (!record3(texts))
53090
+ continue;
53091
+ for (const [key, value] of Object.entries(texts)) {
53092
+ const prefix = "modelSelector.item.";
53093
+ if (!key.startsWith(prefix))
53094
+ continue;
53095
+ const id = key.slice(prefix.length);
53096
+ if (!id || id.length > 512 || /\.(description|markdownDescription)(\.|$)/u.test(id))
53097
+ continue;
53098
+ if (typeof value !== "string" || !value.trim() || value.trim().length > 512)
53099
+ continue;
53100
+ labels.set(id, value.trim());
53101
+ }
53102
+ }
53103
+ return Object.fromEntries(labels);
53104
+ } catch {
53105
+ signal.throwIfAborted();
53106
+ return {};
53107
+ }
53108
+ }
53109
+
53110
+ // ../qoder/dist/qoder-usage-statistics.js
53111
+ function qoderProjectsDirectory(environment, variant) {
53112
+ const cn3 = variant === "cn";
53113
+ const config2 = environment[cn3 ? "QODERCN_CONFIG_DIR" : "QODER_CONFIG_DIR"];
53114
+ const home = environment[cn3 ? "QODERCN_CLI_HOME" : "QODER_CLI_HOME"] || environment.HOME || environment.USERPROFILE || os4.homedir();
53115
+ return path8.resolve(config2 || path8.join(home, cn3 ? ".qoder-cn" : ".qoder"), "projects");
53116
+ }
53117
+ function isRecord2(value) {
53118
+ return typeof value === "object" && value !== null && !Array.isArray(value);
53119
+ }
53120
+ function qoderUserText(message) {
53121
+ if (!isRecord2(message))
53122
+ return void 0;
53123
+ const { content } = message;
53124
+ if (typeof content === "string")
53125
+ return content;
53126
+ if (!Array.isArray(content))
53127
+ return void 0;
53128
+ return content.filter((block) => isRecord2(block) && block.type === "text" && typeof block.text === "string").map((block) => String(block.text)).join(" ");
53129
+ }
53130
+ function count2(value) {
53131
+ return typeof value === "number" && Number.isSafeInteger(value) && value >= 0;
53132
+ }
53133
+ async function readQoderUsage(file2, signal) {
53134
+ const messages = /* @__PURE__ */ new Map();
53135
+ let sessionId;
53136
+ let cwd;
53137
+ let customTitle;
53138
+ let summary;
53139
+ let firstPrompt;
53140
+ for await (const line of jsonlRecords(file2, '"type"', signal)) {
53141
+ signal.throwIfAborted();
53142
+ if (line.type === "custom-title")
53143
+ customTitle = usageSessionTitle(line.customTitle);
53144
+ else if (!summary && line.type === "summary")
53145
+ summary = usageSessionTitle(line.summary);
53146
+ else if (!firstPrompt && line.type === "user") {
53147
+ firstPrompt = usageSessionTitle(qoderUserText(line.message));
53148
+ }
53149
+ if (line.type !== "assistant" || !isRecord2(line.message))
53150
+ continue;
53151
+ sessionId ??= line.sessionId;
53152
+ cwd ??= line.cwd;
53153
+ if (isRecord2(line.forkedFrom) || line.isApiErrorMessage === true)
53154
+ continue;
53155
+ const { id, model: model2, usage } = line.message;
53156
+ if (typeof id !== "string" || !id || model2 === "<synthetic>")
53157
+ continue;
53158
+ const message = messages.get(id) ?? { at: null };
53159
+ message.at ??= nativeTimeMs(line.timestamp);
53160
+ messages.set(id, message);
53161
+ if (!isRecord2(usage) || message.at === null)
53162
+ continue;
53163
+ const input = usage.input_tokens;
53164
+ const output = usage.output_tokens;
53165
+ const cached2 = usage.cache_read_input_tokens;
53166
+ const written = usage.cache_creation_input_tokens;
53167
+ if (!count2(input) || !count2(output) || !count2(cached2) || !count2(written))
53168
+ continue;
53169
+ const split = isRecord2(usage.cache_creation) ? usage.cache_creation : null;
53170
+ const oneHour = split?.ephemeral_1h_input_tokens;
53171
+ const details = isRecord2(usage.output_tokens_details) ? usage.output_tokens_details : null;
53172
+ const thinking = details?.thinking_tokens;
53173
+ const unreported = input === 0 && output === 0 && cached2 === 0 && written === 0;
53174
+ const entry = parseHarnessUsageEntry({
53175
+ id,
53176
+ occurredAtMs: message.at,
53177
+ ...typeof model2 === "string" && model2 ? { model: model2 } : {},
53178
+ inputTokens: input + cached2 + written,
53179
+ cachedInputTokens: cached2,
53180
+ cacheWriteInputTokens: written,
53181
+ ...count2(oneHour) ? { cacheWrite1hInputTokens: oneHour } : {},
53182
+ outputTokens: output,
53183
+ ...typeof usage.credits === "number" && Number.isFinite(usage.credits) && usage.credits >= 0 ? { credits: usage.credits } : {},
53184
+ ...count2(thinking) ? { reasoningOutputTokens: thinking } : {},
53185
+ ...unreported ? { tokensUnknown: true } : {}
53186
+ });
53187
+ if (entry)
53188
+ message.entry = entry;
53189
+ }
53190
+ const session = {
53191
+ sessionId: typeof sessionId === "string" ? sessionId : void 0,
53192
+ cwd: typeof cwd === "string" ? cwd : void 0,
53193
+ title: customTitle ?? summary ?? firstPrompt
53194
+ };
53195
+ return [...messages.values()].flatMap(({ entry }) => entry ? [withUsageSession(entry, session)] : []);
53196
+ }
53197
+ function createQoderUsageStatistics(environment, variant) {
53198
+ return Object.freeze({
53199
+ readModelLabels: (signal) => readQoderModelLabels(path8.dirname(qoderProjectsDirectory(environment, variant)), signal),
53200
+ listSources: (signal) => jsonlUsageSources(qoderProjectsDirectory(environment, variant), 4, signal),
53201
+ readSource: readQoderUsage
53202
+ });
53203
+ }
53204
+
52653
53205
  // ../qoder/dist/qoder-adapter.js
52654
53206
  var QoderAdapter = class {
52655
53207
  harnessId;
@@ -52657,6 +53209,7 @@ var QoderAdapter = class {
52657
53209
  commandCatalog = QODER_FALLBACK_COMMAND_CATALOG;
52658
53210
  liveCommandCatalog = true;
52659
53211
  sessionImport;
53212
+ usageStatistics;
52660
53213
  #commandOverride;
52661
53214
  #environment;
52662
53215
  #platform;
@@ -52675,6 +53228,7 @@ var QoderAdapter = class {
52675
53228
  this.harnessId = harnessIdSchema.parse(runtime.harnessId);
52676
53229
  this.#commandOverride = options.commandOverride ?? options.environment?.[runtime.commandEnvironmentVariable];
52677
53230
  this.#environment = qoderEnvironment(options.environment);
53231
+ this.usageStatistics = createQoderUsageStatistics({ ...process.env, ...options.environment }, this.#variant);
52678
53232
  this.#platform = options.platform ?? process.platform;
52679
53233
  this.#queryFactory = options.queryFactory ?? ((input) => runtime.sdk.query(input));
52680
53234
  this.#forkSession = options.forkSession ?? runtime.sdk.forkSession;
@@ -52904,7 +53458,7 @@ var QoderAdapter = class {
52904
53458
  sourceInfo = await this.#getSessionInfo(sourceRef.data.nativeSessionId, { dir: input.cwd });
52905
53459
  } catch {
52906
53460
  }
52907
- if (sourceInfo?.cwd && path6.resolve(sourceInfo.cwd) !== path6.resolve(input.cwd)) {
53461
+ if (sourceInfo?.cwd && path9.resolve(sourceInfo.cwd) !== path9.resolve(input.cwd)) {
52908
53462
  return {
52909
53463
  ok: false,
52910
53464
  error: {