@liberseek/boft-cli-linux-x64 0.7.9 → 0.8.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 (56) hide show
  1. package/README.md +1 -1
  2. package/THIRD_PARTY_NOTICES.txt +8 -0
  3. package/app/codexhost-distribution.json +1 -1
  4. package/app/console-server.mjs +232 -21
  5. package/app/console-web.js +9669 -5390
  6. package/app/desktop-controller.mjs +252 -42
  7. package/app/host-runtime.mjs +5361 -1491
  8. package/app/plugins/antigravity/manifest.json +18 -1
  9. package/app/plugins/antigravity/plugin.mjs +276 -42
  10. package/app/plugins/claude-code/manifest.json +28 -0
  11. package/app/plugins/claude-code/plugin.mjs +1055 -391
  12. package/app/plugins/codebuddy/manifest.json +17 -0
  13. package/app/plugins/codebuddy/plugin.mjs +5931 -5358
  14. package/app/plugins/codex-usage/manifest.json +9 -0
  15. package/app/plugins/codex-usage/plugin.mjs +16750 -0
  16. package/app/plugins/cursor-cli/manifest.json +18 -1
  17. package/app/plugins/cursor-cli/plugin.mjs +351 -77
  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 +798 -242
  21. package/app/plugins/enabled.json +2 -1
  22. package/app/plugins/grok/manifest.json +21 -1
  23. package/app/plugins/grok/plugin.mjs +898 -268
  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 +278 -33
  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 +555 -36
  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 +284 -22
  33. package/app/plugins/muse/manifest.json +18 -1
  34. package/app/plugins/muse/plugin.mjs +251 -17
  35. package/app/plugins/omp/manifest.json +21 -1
  36. package/app/plugins/omp/plugin.mjs +2741 -1960
  37. package/app/plugins/opencode/manifest.json +18 -1
  38. package/app/plugins/opencode/plugin.mjs +694 -147
  39. package/app/plugins/pi/manifest.json +32 -0
  40. package/app/plugins/pi/plugin.mjs +3396 -2841
  41. package/app/plugins/qoder/manifest.json +18 -1
  42. package/app/plugins/qoder/plugin.mjs +585 -81
  43. package/app/plugins/qoder-cn/manifest.json +18 -1
  44. package/app/plugins/qoder-cn/plugin.mjs +585 -81
  45. package/app/plugins/workbuddy/manifest.json +18 -0
  46. package/app/plugins/workbuddy/plugin.mjs +6317 -5746
  47. package/app/plugins/zcode/manifest.json +19 -1
  48. package/app/plugins/zcode/plugin.mjs +1066 -260
  49. package/app/renderer-extension.js +2731 -2427
  50. package/bin/boft +0 -0
  51. package/libexec/boft-shim +0 -0
  52. package/libexec/boft-updater +0 -0
  53. package/licenses/Cordis-LICENSE.txt +21 -0
  54. package/licenses/Cosmokit-LICENSE.txt +21 -0
  55. package/package.json +1 -1
  56. 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
  }
@@ -12995,7 +12995,7 @@ function createHarnessInstaller(environment, source) {
12995
12995
 
12996
12996
  // dist/qoder-adapter.js
12997
12997
  import { randomUUID as randomUUID2 } from "node:crypto";
12998
- import path6 from "node:path";
12998
+ import path9 from "node:path";
12999
12999
 
13000
13000
  // ../../../node_modules/zod/v4/classic/external.js
13001
13001
  var external_exports = {};
@@ -13763,10 +13763,10 @@ function mergeDefs(...defs) {
13763
13763
  function cloneDef(schema) {
13764
13764
  return mergeDefs(schema._zod.def);
13765
13765
  }
13766
- function getElementAtPath(obj, path7) {
13767
- if (!path7)
13766
+ function getElementAtPath(obj, path10) {
13767
+ if (!path10)
13768
13768
  return obj;
13769
- return path7.reduce((acc, key) => acc?.[key], obj);
13769
+ return path10.reduce((acc, key) => acc?.[key], obj);
13770
13770
  }
13771
13771
  function promiseAllObject(promisesObj) {
13772
13772
  const keys = Object.keys(promisesObj);
@@ -14175,11 +14175,11 @@ function explicitlyAborted(x3, startIndex = 0) {
14175
14175
  }
14176
14176
  return false;
14177
14177
  }
14178
- function prefixIssues(path7, issues) {
14178
+ function prefixIssues(path10, issues) {
14179
14179
  return issues.map((iss) => {
14180
14180
  var _a5;
14181
14181
  (_a5 = iss).path ?? (_a5.path = []);
14182
- iss.path.unshift(path7);
14182
+ iss.path.unshift(path10);
14183
14183
  return iss;
14184
14184
  });
14185
14185
  }
@@ -14326,16 +14326,16 @@ function flattenError(error51, mapper = (issue2) => issue2.message) {
14326
14326
  }
14327
14327
  function formatError(error51, mapper = (issue2) => issue2.message) {
14328
14328
  const fieldErrors = { _errors: [] };
14329
- const processError = (error52, path7 = []) => {
14329
+ const processError = (error52, path10 = []) => {
14330
14330
  for (const issue2 of error52.issues) {
14331
14331
  if (issue2.code === "invalid_union" && issue2.errors.length) {
14332
- issue2.errors.map((issues) => processError({ issues }, [...path7, ...issue2.path]));
14332
+ issue2.errors.map((issues) => processError({ issues }, [...path10, ...issue2.path]));
14333
14333
  } else if (issue2.code === "invalid_key") {
14334
- processError({ issues: issue2.issues }, [...path7, ...issue2.path]);
14334
+ processError({ issues: issue2.issues }, [...path10, ...issue2.path]);
14335
14335
  } else if (issue2.code === "invalid_element") {
14336
- processError({ issues: issue2.issues }, [...path7, ...issue2.path]);
14336
+ processError({ issues: issue2.issues }, [...path10, ...issue2.path]);
14337
14337
  } else {
14338
- const fullpath = [...path7, ...issue2.path];
14338
+ const fullpath = [...path10, ...issue2.path];
14339
14339
  if (fullpath.length === 0) {
14340
14340
  fieldErrors._errors.push(mapper(issue2));
14341
14341
  } else {
@@ -14362,17 +14362,17 @@ function formatError(error51, mapper = (issue2) => issue2.message) {
14362
14362
  }
14363
14363
  function treeifyError(error51, mapper = (issue2) => issue2.message) {
14364
14364
  const result = { errors: [] };
14365
- const processError = (error52, path7 = []) => {
14365
+ const processError = (error52, path10 = []) => {
14366
14366
  var _a5, _b;
14367
14367
  for (const issue2 of error52.issues) {
14368
14368
  if (issue2.code === "invalid_union" && issue2.errors.length) {
14369
- issue2.errors.map((issues) => processError({ issues }, [...path7, ...issue2.path]));
14369
+ issue2.errors.map((issues) => processError({ issues }, [...path10, ...issue2.path]));
14370
14370
  } else if (issue2.code === "invalid_key") {
14371
- processError({ issues: issue2.issues }, [...path7, ...issue2.path]);
14371
+ processError({ issues: issue2.issues }, [...path10, ...issue2.path]);
14372
14372
  } else if (issue2.code === "invalid_element") {
14373
- processError({ issues: issue2.issues }, [...path7, ...issue2.path]);
14373
+ processError({ issues: issue2.issues }, [...path10, ...issue2.path]);
14374
14374
  } else {
14375
- const fullpath = [...path7, ...issue2.path];
14375
+ const fullpath = [...path10, ...issue2.path];
14376
14376
  if (fullpath.length === 0) {
14377
14377
  result.errors.push(mapper(issue2));
14378
14378
  continue;
@@ -14404,8 +14404,8 @@ function treeifyError(error51, mapper = (issue2) => issue2.message) {
14404
14404
  }
14405
14405
  function toDotPath(_path) {
14406
14406
  const segs = [];
14407
- const path7 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
14408
- for (const seg of path7) {
14407
+ const path10 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
14408
+ for (const seg of path10) {
14409
14409
  if (typeof seg === "number")
14410
14410
  segs.push(`[${seg}]`);
14411
14411
  else if (typeof seg === "symbol")
@@ -17633,8 +17633,8 @@ function az_default() {
17633
17633
  }
17634
17634
 
17635
17635
  // ../../../node_modules/zod/v4/locales/be.js
17636
- function getBelarusianPlural(count, one, few, many) {
17637
- const absCount = Math.abs(count);
17636
+ function getBelarusianPlural(count3, one, few, many) {
17637
+ const absCount = Math.abs(count3);
17638
17638
  const lastDigit = absCount % 10;
17639
17639
  const lastTwoDigits = absCount % 100;
17640
17640
  if (lastTwoDigits >= 11 && lastTwoDigits <= 19) {
@@ -19712,8 +19712,8 @@ function hu_default() {
19712
19712
  }
19713
19713
 
19714
19714
  // ../../../node_modules/zod/v4/locales/hy.js
19715
- function getArmenianPlural(count, one, many) {
19716
- return Math.abs(count) === 1 ? one : many;
19715
+ function getArmenianPlural(count3, one, many) {
19716
+ return Math.abs(count3) === 1 ? one : many;
19717
19717
  }
19718
19718
  function withDefiniteArticle(word) {
19719
19719
  if (!word)
@@ -21841,8 +21841,8 @@ function ro_default() {
21841
21841
  }
21842
21842
 
21843
21843
  // ../../../node_modules/zod/v4/locales/ru.js
21844
- function getRussianPlural(count, one, few, many) {
21845
- const absCount = Math.abs(count);
21844
+ function getRussianPlural(count3, one, few, many) {
21845
+ const absCount = Math.abs(count3);
21846
21846
  const lastDigit = absCount % 10;
21847
21847
  const lastTwoDigits = absCount % 100;
21848
21848
  if (lastTwoDigits >= 11 && lastTwoDigits <= 19) {
@@ -27097,13 +27097,13 @@ function resolveRef(ref, ctx) {
27097
27097
  if (!ref.startsWith("#")) {
27098
27098
  throw new Error("External $ref is not supported, only local refs (#/...) are allowed");
27099
27099
  }
27100
- const path7 = ref.slice(1).split("/").filter(Boolean);
27101
- if (path7.length === 0) {
27100
+ const path10 = ref.slice(1).split("/").filter(Boolean);
27101
+ if (path10.length === 0) {
27102
27102
  return ctx.rootSchema;
27103
27103
  }
27104
27104
  const defsKey = ctx.version === "draft-2020-12" ? "$defs" : "definitions";
27105
- if (path7[0] === defsKey) {
27106
- const key = path7[1];
27105
+ if (path10[0] === defsKey) {
27106
+ const key = path10[1];
27107
27107
  if (!key || !ctx.defs[key]) {
27108
27108
  throw new Error(`Reference not found: ${ref}`);
27109
27109
  }
@@ -27511,6 +27511,15 @@ function date4(params) {
27511
27511
  // ../../../node_modules/zod/v4/classic/external.js
27512
27512
  config(en_default());
27513
27513
 
27514
+ // ../../shared-contracts/dist/delegation-read.js
27515
+ var REMOTE_THREAD_REPLY_MAX_BYTES = 16 * 1024 * 1024;
27516
+ var delegationReadParamsSchema = external_exports.strictObject({
27517
+ threadId: external_exports.string().min(1).max(1024),
27518
+ view: external_exports.enum(["result", "messages"]),
27519
+ cursor: external_exports.string().min(1).max(8192).optional(),
27520
+ limit: external_exports.number().int().min(1).max(100).optional()
27521
+ });
27522
+
27514
27523
  // ../../shared-contracts/dist/credential-imports.js
27515
27524
  var credentialSourceSchema = external_exports.object({
27516
27525
  id: external_exports.string().min(1).max(256),
@@ -27581,6 +27590,153 @@ var harnessDisplaySetSchema = external_exports.strictObject({
27581
27590
  initializeOnly: external_exports.boolean().optional()
27582
27591
  });
27583
27592
 
27593
+ // ../../shared-contracts/dist/model-price-overrides.js
27594
+ var usdPerMillionTokens = external_exports.number().finite().nonnegative();
27595
+ var modelPriceOverrideSchema = external_exports.strictObject({
27596
+ input: usdPerMillionTokens,
27597
+ output: usdPerMillionTokens,
27598
+ cacheRead: usdPerMillionTokens.optional(),
27599
+ cacheWrite: usdPerMillionTokens.optional(),
27600
+ cacheWrite1h: usdPerMillionTokens.optional()
27601
+ });
27602
+ var modelPriceKeySchema = external_exports.string().max(512).refine((key) => key.trim() === key && key.length > 0, "Model ID is required");
27603
+ var modelPriceOverridesSchema = external_exports.strictObject({
27604
+ /** Absolute path of the Host's `pricing.json`. */
27605
+ path: external_exports.string(),
27606
+ entries: external_exports.array(external_exports.strictObject({ key: external_exports.string(), price: modelPriceOverrideSchema })),
27607
+ /** Why the existing file is unusable; the Host then ignores it and refuses to overwrite it. */
27608
+ error: external_exports.string().nullable()
27609
+ });
27610
+ var modelPriceOverridesGetSchema = external_exports.strictObject({});
27611
+ var modelPriceOverridesSetSchema = external_exports.strictObject({
27612
+ key: modelPriceKeySchema,
27613
+ price: modelPriceOverrideSchema.nullable(),
27614
+ previousKey: modelPriceKeySchema.optional()
27615
+ });
27616
+ var modelPriceDefaultParamsSchema = external_exports.strictObject({
27617
+ model: modelPriceKeySchema
27618
+ });
27619
+ var modelPriceSuggestionSchema = external_exports.strictObject({
27620
+ /** Verified from catalog canonical links, not inferred from names or equal prices. */
27621
+ official: external_exports.boolean().optional(),
27622
+ canonicalModelId: external_exports.string().min(1).optional(),
27623
+ provider: external_exports.string().min(1).max(512),
27624
+ model: external_exports.string().min(1).max(512),
27625
+ price: modelPriceOverrideSchema
27626
+ });
27627
+ var modelPriceDefaultResultSchema = external_exports.strictObject({
27628
+ price: modelPriceOverrideSchema.nullable(),
27629
+ /** Local catalog suggestions only; never used automatically for pricing. */
27630
+ suggestions: external_exports.array(modelPriceSuggestionSchema).max(6).optional()
27631
+ });
27632
+
27633
+ // ../../shared-contracts/dist/usage-statistics.js
27634
+ var USAGE_STATISTICS_RANGES = ["today", "7d", "30d", "90d", "all"];
27635
+ var count = external_exports.number().int().min(0).max(Number.MAX_SAFE_INTEGER);
27636
+ var localDate = external_exports.string().regex(/^\d{4}-\d{2}-\d{2}$/u);
27637
+ var harness = external_exports.string().min(1).max(128);
27638
+ var model = external_exports.string().min(1).max(512);
27639
+ var project = external_exports.string().min(1).max(4096);
27640
+ var usageStatisticsParamsSchema = external_exports.strictObject({
27641
+ range: external_exports.enum(USAGE_STATISTICS_RANGES),
27642
+ harness: harness.optional(),
27643
+ model: model.nullable().optional(),
27644
+ project: project.nullable().optional(),
27645
+ /** One local date inside the range. */
27646
+ date: localDate.optional()
27647
+ });
27648
+ var usageStatisticsTotalsSchema = external_exports.strictObject({
27649
+ requests: count,
27650
+ inputTokens: count,
27651
+ cachedInputTokens: count,
27652
+ cacheWriteInputTokens: count,
27653
+ cacheKnownInputTokens: count,
27654
+ outputTokens: count,
27655
+ reasoningOutputTokens: count,
27656
+ /** USD at the public price, summed over the priced requests only. */
27657
+ costUsd: external_exports.number().finite().min(0),
27658
+ /** Requests without a price (or the cache data the price needs); not in `costUsd`. */
27659
+ unpricedRequests: count,
27660
+ /**
27661
+ * Requests whose storage gave no token counts: counted as requests, with neither tokens nor
27662
+ * cost, and not as unpriced.
27663
+ */
27664
+ unmeteredRequests: count
27665
+ });
27666
+ var totals = usageStatisticsTotalsSchema.shape;
27667
+ var usageStatisticsSessionSchema = external_exports.strictObject({
27668
+ harness,
27669
+ sessionId: external_exports.string().min(1).max(512),
27670
+ project: project.nullable(),
27671
+ /** Models the session used, most requests first. */
27672
+ models: external_exports.array(model).max(16),
27673
+ firstAtMs: count,
27674
+ lastAtMs: count,
27675
+ ...totals
27676
+ });
27677
+ var usageStatisticsResultSchema = external_exports.strictObject({
27678
+ range: external_exports.enum(USAGE_STATISTICS_RANGES),
27679
+ /** First local date of the range; null for all time. */
27680
+ from: localDate.nullable(),
27681
+ to: localDate,
27682
+ /** The filters these figures apply, echoed so a late answer to older filters is recognised. */
27683
+ filters: external_exports.strictObject({
27684
+ harness: harness.nullable(),
27685
+ model: model.nullable(),
27686
+ unknownModel: external_exports.boolean(),
27687
+ project: project.nullable(),
27688
+ unknownProject: external_exports.boolean(),
27689
+ date: localDate.nullable()
27690
+ }),
27691
+ /** Reading of native storage: incomplete while the first read, or a refresh, is under way. */
27692
+ reading: external_exports.strictObject({ complete: external_exports.boolean(), sources: count, read: count }),
27693
+ /** Harnesses whose storage could not be read; their part is missing, the rest is complete. */
27694
+ failures: external_exports.array(external_exports.strictObject({ harness, message: external_exports.string().max(2048) })).max(256),
27695
+ /** Every value seen in the range, ignoring the filters, to choose filters from. */
27696
+ options: external_exports.strictObject({
27697
+ harnesses: external_exports.array(harness).max(256),
27698
+ models: external_exports.array(model.nullable()).max(4096),
27699
+ projects: external_exports.array(project.nullable()).max(4096)
27700
+ }),
27701
+ /** Current display metadata, scoped by Harness. Never a pricing or filter identity.
27702
+ * Optional for older Hosts; missing/conflicting labels fall back to the native model ID.
27703
+ */
27704
+ modelLabels: external_exports.array(external_exports.strictObject({ harness, model, label: model })).max(4096).optional(),
27705
+ /** Native credits, all filters applied, never combined across Harnesses or treated as USD.
27706
+ * Only groups with at least one reported value appear; reportedRequests exposes partial data.
27707
+ */
27708
+ credits: external_exports.array(external_exports.strictObject({
27709
+ harness,
27710
+ model: model.nullable(),
27711
+ credits: external_exports.number().finite().min(0),
27712
+ reportedRequests: count,
27713
+ requests: count
27714
+ })).max(4096).optional(),
27715
+ /** All filters applied. */
27716
+ totals: usageStatisticsTotalsSchema,
27717
+ /** Each date and Harness of the range: every filter except the day. */
27718
+ daily: external_exports.array(external_exports.strictObject({ date: localDate, harness, ...totals })).max(2e5),
27719
+ /** Local weekday (0 = Sunday) and hour, all filters applied. */
27720
+ hourly: external_exports.array(external_exports.strictObject({
27721
+ weekday: external_exports.number().int().min(0).max(6),
27722
+ hour: external_exports.number().int().min(0).max(23),
27723
+ ...totals
27724
+ })).max(168),
27725
+ byHarness: external_exports.array(external_exports.strictObject({ harness, ...totals })).max(256),
27726
+ byModel: external_exports.array(external_exports.strictObject({
27727
+ model: model.nullable(),
27728
+ ...totals,
27729
+ /** Requests priced by what the Harness recorded they cost, not by a price list. */
27730
+ harnessPricedRequests: count
27731
+ })).max(4096),
27732
+ byProject: external_exports.array(external_exports.strictObject({ project: project.nullable(), ...totals })).max(4096),
27733
+ /**
27734
+ * The sessions that spent the most, by cost and by tokens without cache, all filters applied;
27735
+ * requests without a native session are not listed here but count everywhere else.
27736
+ */
27737
+ sessions: external_exports.array(usageStatisticsSessionSchema).max(100)
27738
+ });
27739
+
27584
27740
  // ../../shared-contracts/dist/ids.js
27585
27741
  var opaqueIdSchema = external_exports.string().refine((value) => value.trim().length > 0, {
27586
27742
  message: "Identifier must not be empty or whitespace"
@@ -27602,13 +27758,40 @@ var HARNESS_PLUGIN_LIMIT = 128;
27602
27758
  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);
27603
27759
  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");
27604
27760
  var documentationUrlSchema = external_exports.url().refine((value) => /^https:\/\/[^/?#@]+(?:[/?#]|$)/iu.test(value), "Plugin documentation links must be credential-free HTTPS URLs");
27761
+ var localizedTextSchema = external_exports.object({ en: external_exports.string().max(4096), "zh-CN": external_exports.string().max(4096).optional() }).strict();
27762
+ var harnessInstallationGuideSchema = external_exports.object({
27763
+ commands: external_exports.array(external_exports.object({ terminal: external_exports.string().max(256), command: external_exports.string().max(4096) }).strict()).max(8),
27764
+ before: localizedTextSchema.optional(),
27765
+ after: localizedTextSchema.optional(),
27766
+ downloads: external_exports.array(external_exports.object({ label: external_exports.string().max(128), url: documentationUrlSchema }).strict()).max(8).optional()
27767
+ }).strict();
27605
27768
  var pluginPresentationShape = {
27606
27769
  id: harnessPluginIdSchema,
27607
27770
  name: external_exports.string().trim().min(1).max(128),
27608
27771
  version: external_exports.string().min(1).max(128),
27772
+ /** Capability-only plugin; omitted for existing session-capable plugins. */
27773
+ kind: external_exports.literal("usage").optional(),
27774
+ /** Original image styling or bounded vector paths; never arbitrary CSS/SVG markup. */
27775
+ iconStyle: external_exports.object({
27776
+ vector: external_exports.object({
27777
+ viewBox: external_exports.string().max(128).regex(/^-?\d+(?:\.\d+)?(?: +-?\d+(?:\.\d+)?){3}$/u),
27778
+ color: external_exports.string().regex(/^(?:currentColor|#[a-f0-9]{6})$/iu),
27779
+ paths: external_exports.array(external_exports.object({
27780
+ d: external_exports.string().min(1).max(32768).regex(/^[MmLlHhVvCcSsQqTtAaZz\d.,+eE\s-]+$/u),
27781
+ fillRule: external_exports.enum(["evenodd", "nonzero"]).optional(),
27782
+ fill: external_exports.string().regex(/^(?:currentColor|#[a-f0-9]{6})$/iu).optional()
27783
+ }).strict()).min(1).max(32)
27784
+ }).strict().optional(),
27785
+ background: external_exports.string().regex(/^#[a-f0-9]{6}$/iu).optional(),
27786
+ borderRadius: external_exports.number().min(0).max(50).optional(),
27787
+ paddingRatio: external_exports.number().min(0).max(0.25).optional()
27788
+ }).strict().optional(),
27789
+ installation: harnessInstallationGuideSchema.optional(),
27790
+ notice: localizedTextSchema.optional(),
27609
27791
  /** The factory accepts a persisted local entrypoint through its construction context. */
27610
27792
  launchCommand: external_exports.literal(true).optional(),
27611
27793
  links: external_exports.object({
27794
+ website: documentationUrlSchema.optional(),
27612
27795
  documentation: documentationUrlSchema.optional(),
27613
27796
  installation: documentationUrlSchema.optional()
27614
27797
  }).strict().optional()
@@ -27685,6 +27868,10 @@ var CONSOLE_HOST_METHODS = Object.freeze([
27685
27868
  "codexhost/account/list",
27686
27869
  "codexhost/account/refresh",
27687
27870
  "codexhost/account/usage/inspect",
27871
+ "codexhost/usage/model-prices/get",
27872
+ "codexhost/usage/model-prices/set",
27873
+ "codexhost/usage/model-prices/default",
27874
+ "codexhost/usage/statistics/get",
27688
27875
  "codexhost/update/check",
27689
27876
  "codexhost/update/start",
27690
27877
  "codexhost/update/status"
@@ -27749,6 +27936,7 @@ var threadUsageSnapshotSchema = external_exports.object({
27749
27936
  cacheWriteInputTokens: nonNegativeSafeIntegerSchema.optional(),
27750
27937
  outputTokens: nonNegativeSafeIntegerSchema.optional(),
27751
27938
  outputTokensPerSecond: finiteNonNegativeNumberSchema.optional(),
27939
+ apiOutputTokensPerSecond: finiteNonNegativeNumberSchema.optional(),
27752
27940
  reasoningOutputTokens: nonNegativeSafeIntegerSchema.optional(),
27753
27941
  totalTokens: nonNegativeSafeIntegerSchema.optional(),
27754
27942
  totalCostUsd: finiteNonNegativeNumberSchema.optional(),
@@ -27760,7 +27948,11 @@ var threadUsageSnapshotSchema = external_exports.object({
27760
27948
  planFiveHourUsedPercent: cacheHitRatePercentSchema.optional(),
27761
27949
  planFiveHourResetsAtUnix: nonNegativeSafeIntegerSchema.optional(),
27762
27950
  planSevenDayUsedPercent: cacheHitRatePercentSchema.optional(),
27763
- planSevenDayResetsAtUnix: nonNegativeSafeIntegerSchema.optional()
27951
+ planSevenDayResetsAtUnix: nonNegativeSafeIntegerSchema.optional(),
27952
+ sessionCacheHitRatePercent: cacheHitRatePercentSchema.optional(),
27953
+ timeToFirstOutputMs: nonNegativeSafeIntegerSchema.optional(),
27954
+ costSource: external_exports.enum(["publicPrice", "native"]).optional(),
27955
+ unpricedModels: external_exports.array(external_exports.string().min(1)).min(1).optional()
27764
27956
  }).strict().superRefine((usage, context) => {
27765
27957
  if (Object.keys(usage).length === 0) {
27766
27958
  context.addIssue({ code: "custom", message: "Thread Usage must contain a reliable field" });
@@ -27781,6 +27973,20 @@ var threadUsageSnapshotSchema = external_exports.object({
27781
27973
  path: ["contextWindowTokens"]
27782
27974
  });
27783
27975
  }
27976
+ if (usage.costSource !== void 0 && usage.totalCostUsd === void 0) {
27977
+ context.addIssue({
27978
+ code: "custom",
27979
+ message: "Thread Usage costSource must be provided with totalCostUsd",
27980
+ path: ["costSource"]
27981
+ });
27982
+ }
27983
+ if (usage.unpricedModels !== void 0 && usage.costSource !== "publicPrice") {
27984
+ context.addIssue({
27985
+ code: "custom",
27986
+ message: "Thread Usage unpricedModels must be provided with a publicPrice cost",
27987
+ path: ["unpricedModels"]
27988
+ });
27989
+ }
27784
27990
  if (usage.planFiveHourResetsAtUnix !== void 0 && usage.planFiveHourUsedPercent === void 0) {
27785
27991
  context.addIssue({
27786
27992
  code: "custom",
@@ -28050,27 +28256,27 @@ var harnessModelCatalogSchema = external_exports.object({
28050
28256
  }).strict().superRefine((catalog, context) => {
28051
28257
  const refs = /* @__PURE__ */ new Set();
28052
28258
  const thinkingIds = new Set(catalog.thinkingOptions.map(({ id }) => id));
28053
- for (const [index, model] of catalog.models.entries()) {
28054
- if (refs.has(model.ref.id)) {
28259
+ for (const [index, model2] of catalog.models.entries()) {
28260
+ if (refs.has(model2.ref.id)) {
28055
28261
  context.addIssue({
28056
28262
  code: "custom",
28057
28263
  message: "Model Catalog refs must be unique",
28058
28264
  path: ["models", index, "ref", "id"]
28059
28265
  });
28060
28266
  }
28061
- refs.add(model.ref.id);
28062
- if (model.fastModel) {
28063
- if (refs.has(model.fastModel.id) || catalog.models.some((entry) => entry.ref.id === model.fastModel?.id)) {
28267
+ refs.add(model2.ref.id);
28268
+ if (model2.fastModel) {
28269
+ if (refs.has(model2.fastModel.id) || catalog.models.some((entry) => entry.ref.id === model2.fastModel?.id)) {
28064
28270
  context.addIssue({
28065
28271
  code: "custom",
28066
28272
  message: "Fast Model refs must be distinct and unique",
28067
28273
  path: ["models", index, "fastModel"]
28068
28274
  });
28069
28275
  }
28070
- refs.add(model.fastModel.id);
28276
+ refs.add(model2.fastModel.id);
28071
28277
  }
28072
28278
  const supportedThinkingIds = /* @__PURE__ */ new Set();
28073
- for (const [optionIndex, optionId] of (model.supportedThinkingOptionIds ?? []).entries()) {
28279
+ for (const [optionIndex, optionId] of (model2.supportedThinkingOptionIds ?? []).entries()) {
28074
28280
  if (supportedThinkingIds.has(optionId)) {
28075
28281
  context.addIssue({
28076
28282
  code: "custom",
@@ -28664,6 +28870,11 @@ var codexSshDraftSchema = external_exports.strictObject({
28664
28870
  });
28665
28871
  var remoteConnectionsRequestSchema = external_exports.discriminatedUnion("action", [
28666
28872
  external_exports.strictObject({ action: external_exports.literal("list") }),
28873
+ external_exports.strictObject({
28874
+ action: external_exports.literal("read-thread"),
28875
+ hostId: hostId.refine((id) => id !== "local"),
28876
+ input: delegationReadParamsSchema
28877
+ }),
28667
28878
  external_exports.strictObject({
28668
28879
  action: external_exports.literal("save"),
28669
28880
  draft: codexSshDraftSchema,
@@ -29063,7 +29274,6 @@ var tokenFields = [
29063
29274
  "cachedInputTokens",
29064
29275
  "cacheWriteInputTokens",
29065
29276
  "outputTokens",
29066
- "outputTokensPerSecond",
29067
29277
  "reasoningOutputTokens",
29068
29278
  "totalTokens",
29069
29279
  "contextWindowTokens",
@@ -29071,10 +29281,12 @@ var tokenFields = [
29071
29281
  ];
29072
29282
  var safeIntegerFields = [
29073
29283
  "planFiveHourResetsAtUnix",
29074
- "planSevenDayResetsAtUnix"
29284
+ "planSevenDayResetsAtUnix",
29285
+ "timeToFirstOutputMs"
29075
29286
  ];
29076
29287
  var percentFields = [
29077
29288
  "cacheHitRatePercent",
29289
+ "sessionCacheHitRatePercent",
29078
29290
  "planFiveHourUsedPercent",
29079
29291
  "planSevenDayUsedPercent"
29080
29292
  ];
@@ -29082,9 +29294,14 @@ var usageFields = /* @__PURE__ */ new Set([
29082
29294
  ...tokenFields,
29083
29295
  ...safeIntegerFields,
29084
29296
  ...percentFields,
29297
+ "sessionCacheUsage",
29085
29298
  "totalCostUsd",
29086
29299
  "totalCredits",
29087
- "contextUsagePercent"
29300
+ "contextUsagePercent",
29301
+ "outputTokensPerSecond",
29302
+ "apiOutputTokensPerSecond",
29303
+ "costSource",
29304
+ "unpricedModels"
29088
29305
  ]);
29089
29306
  function isRecord(value) {
29090
29307
  return typeof value === "object" && value !== null && !Array.isArray(value);
@@ -29100,7 +29317,11 @@ function parseHostUsage(value) {
29100
29317
  throw new Error(`Harness Usage contains unknown field '${key}'`);
29101
29318
  }
29102
29319
  }
29103
- for (const field of ["totalCredits", "contextUsagePercent"]) {
29320
+ for (const field of [
29321
+ "totalCredits",
29322
+ "contextUsagePercent",
29323
+ "apiOutputTokensPerSecond"
29324
+ ]) {
29104
29325
  const candidate = value[field];
29105
29326
  if (candidate !== void 0 && (typeof candidate !== "number" || !Number.isFinite(candidate) || candidate < 0)) {
29106
29327
  throw new Error(`Harness Usage '${field}' must be a finite non-negative number`);
@@ -29136,6 +29357,12 @@ function parseHostUsage(value) {
29136
29357
  throw new Error(`Harness Usage '${field}' must be between 0 and 100`);
29137
29358
  }
29138
29359
  }
29360
+ if (value.sessionCacheUsage !== void 0) {
29361
+ const totals2 = value.sessionCacheUsage;
29362
+ 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) {
29363
+ throw new Error("Harness Usage 'sessionCacheUsage' must contain complete bounded token totals");
29364
+ }
29365
+ }
29139
29366
  const hasContextUsed = value.contextUsedTokens !== void 0;
29140
29367
  const hasContextWindow = value.contextWindowTokens !== void 0;
29141
29368
  if (hasContextUsed !== hasContextWindow) {
@@ -29150,8 +29377,43 @@ function parseHostUsage(value) {
29150
29377
  if (value.planSevenDayResetsAtUnix !== void 0 && value.planSevenDayUsedPercent === void 0) {
29151
29378
  throw new Error("Harness Usage 'planSevenDayResetsAtUnix' must be provided with 'planSevenDayUsedPercent'");
29152
29379
  }
29380
+ if (value.costSource !== void 0) {
29381
+ if (value.costSource !== "publicPrice" && value.costSource !== "native") {
29382
+ throw new Error("Harness Usage 'costSource' must be 'publicPrice' or 'native'");
29383
+ }
29384
+ if (value.totalCostUsd === void 0) {
29385
+ throw new Error("Harness Usage 'costSource' must be provided with 'totalCostUsd'");
29386
+ }
29387
+ }
29388
+ if (value.unpricedModels !== void 0) {
29389
+ const models = value.unpricedModels;
29390
+ if (!Array.isArray(models) || models.length === 0 || !models.every((model2) => typeof model2 === "string" && model2.length > 0)) {
29391
+ throw new Error("Harness Usage 'unpricedModels' must be a non-empty list of Model IDs");
29392
+ }
29393
+ if (value.costSource !== "publicPrice") {
29394
+ throw new Error("Harness Usage 'unpricedModels' must be provided with a 'publicPrice' cost");
29395
+ }
29396
+ return { ...value, unpricedModels: [...models] };
29397
+ }
29153
29398
  return { ...value };
29154
29399
  }
29400
+ var requestTokenFields = [
29401
+ "inputTokens",
29402
+ "cachedInputTokens",
29403
+ "cacheWriteInputTokens",
29404
+ "cacheWrite1hInputTokens",
29405
+ "outputTokens",
29406
+ "reasoningOutputTokens",
29407
+ "startedAtMs",
29408
+ "completedAtMs"
29409
+ ];
29410
+ var requestFields = /* @__PURE__ */ new Set([
29411
+ ...requestTokenFields,
29412
+ "requestId",
29413
+ "historical",
29414
+ "model",
29415
+ "provider"
29416
+ ]);
29155
29417
 
29156
29418
  // ../../harness-adapter/dist/live-command-catalog.js
29157
29419
  var COMMON_EXCLUDED_LIVE_COMMANDS = /* @__PURE__ */ new Set([
@@ -29806,10 +30068,10 @@ function parseQoderModelCatalog(rawModels) {
29806
30068
  ...defaultThinkingOptionId ? { defaultThinkingOptionId } : {}
29807
30069
  });
29808
30070
  }
29809
- function qoderAvailableThinkingOptions(catalog, model) {
29810
- if (!catalog || !model)
30071
+ function qoderAvailableThinkingOptions(catalog, model2) {
30072
+ if (!catalog || !model2)
29811
30073
  return void 0;
29812
- const supported = catalog.models.find(({ ref }) => ref.id === model.id)?.supportedThinkingOptionIds;
30074
+ const supported = catalog.models.find(({ ref }) => ref.id === model2.id)?.supportedThinkingOptionIds;
29813
30075
  if (!supported || supported.length === 0)
29814
30076
  return void 0;
29815
30077
  const options = supported.flatMap((id) => {
@@ -30321,8 +30583,8 @@ function getErrorMap2() {
30321
30583
 
30322
30584
  // ../../../node_modules/zod/v3/helpers/parseUtil.js
30323
30585
  var makeIssue = (params) => {
30324
- const { data, path: path7, errorMaps, issueData } = params;
30325
- const fullPath = [...path7, ...issueData.path || []];
30586
+ const { data, path: path10, errorMaps, issueData } = params;
30587
+ const fullPath = [...path10, ...issueData.path || []];
30326
30588
  const fullIssue = {
30327
30589
  ...issueData,
30328
30590
  path: fullPath
@@ -30437,11 +30699,11 @@ var errorUtil;
30437
30699
 
30438
30700
  // ../../../node_modules/zod/v3/types.js
30439
30701
  var ParseInputLazyPath = class {
30440
- constructor(parent, value, path7, key) {
30702
+ constructor(parent, value, path10, key) {
30441
30703
  this._cachedPath = [];
30442
30704
  this.parent = parent;
30443
30705
  this.data = value;
30444
- this._path = path7;
30706
+ this._path = path10;
30445
30707
  this._key = key;
30446
30708
  }
30447
30709
  get path() {
@@ -33968,11 +34230,11 @@ function normalizeObjectSchema(schema) {
33968
34230
  }
33969
34231
  return void 0;
33970
34232
  }
33971
- function getDotPath(path7) {
33972
- if (path7.length === 0) {
34233
+ function getDotPath(path10) {
34234
+ if (path10.length === 0) {
33973
34235
  return "object root";
33974
34236
  }
33975
- return path7.reduce((acc, seg, index) => {
34237
+ return path10.reduce((acc, seg, index) => {
33976
34238
  if (index === 0) {
33977
34239
  return String(seg);
33978
34240
  }
@@ -52701,6 +52963,246 @@ var QoderSessionImport = class {
52701
52963
  }
52702
52964
  };
52703
52965
 
52966
+ // dist/qoder-usage-statistics.js
52967
+ import os4 from "node:os";
52968
+ import path8 from "node:path";
52969
+
52970
+ // ../../harness-adapter/dist/usage-statistics.js
52971
+ import { createReadStream } from "node:fs";
52972
+ import { lstat, opendir } from "node:fs/promises";
52973
+ import path6 from "node:path";
52974
+ import { createInterface } from "node:readline";
52975
+ var MAX_SESSION_ID_LENGTH = 512;
52976
+ var MAX_CWD_LENGTH = 4096;
52977
+ function sessionIdOk(value) {
52978
+ return typeof value === "string" && value.length > 0 && value.length <= MAX_SESSION_ID_LENGTH;
52979
+ }
52980
+ function cwdOk(value) {
52981
+ 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("\\\\"));
52982
+ }
52983
+ function withUsageSession(entry, session) {
52984
+ const sessionId = sessionIdOk(session.sessionId) ? session.sessionId : void 0;
52985
+ const cwd = cwdOk(session.cwd) ? session.cwd : void 0;
52986
+ if (sessionId === void 0 && cwd === void 0)
52987
+ return entry;
52988
+ return {
52989
+ ...entry,
52990
+ ...sessionId !== void 0 ? { sessionId } : {},
52991
+ ...cwd !== void 0 ? { cwd } : {}
52992
+ };
52993
+ }
52994
+ function tokenCount(value) {
52995
+ return typeof value === "number" && Number.isSafeInteger(value) && value >= 0;
52996
+ }
52997
+ function parseHarnessUsageEntry(value) {
52998
+ if (typeof value !== "object" || value === null || Array.isArray(value))
52999
+ return null;
53000
+ const entry = value;
53001
+ if (typeof entry.id !== "string" || entry.id.length === 0 || entry.id.length > 512)
53002
+ return null;
53003
+ if (!tokenCount(entry.occurredAtMs) || entry.occurredAtMs === 0)
53004
+ return null;
53005
+ if (entry.model !== void 0 && (typeof entry.model !== "string" || entry.model.length === 0)) {
53006
+ return null;
53007
+ }
53008
+ if (!tokenCount(entry.inputTokens) || !tokenCount(entry.outputTokens))
53009
+ return null;
53010
+ for (const field of [
53011
+ "cachedInputTokens",
53012
+ "cacheWriteInputTokens",
53013
+ "cacheWrite1hInputTokens",
53014
+ "reasoningOutputTokens"
53015
+ ]) {
53016
+ if (entry[field] !== void 0 && !tokenCount(entry[field]))
53017
+ return null;
53018
+ }
53019
+ const cached2 = entry.cachedInputTokens ?? 0;
53020
+ const written = entry.cacheWriteInputTokens ?? 0;
53021
+ if (cached2 + written > entry.inputTokens)
53022
+ return null;
53023
+ if ((entry.cacheWrite1hInputTokens ?? 0) > written)
53024
+ return null;
53025
+ if ((entry.reasoningOutputTokens ?? 0) > entry.outputTokens)
53026
+ return null;
53027
+ if (entry.sessionId !== void 0 && !sessionIdOk(entry.sessionId))
53028
+ return null;
53029
+ if (entry.cwd !== void 0 && !cwdOk(entry.cwd))
53030
+ return null;
53031
+ if (entry.tokensUnknown !== void 0 && entry.tokensUnknown !== true)
53032
+ return null;
53033
+ if (entry.costUsd !== void 0 && (typeof entry.costUsd !== "number" || !Number.isFinite(entry.costUsd) || entry.costUsd < 0)) {
53034
+ return null;
53035
+ }
53036
+ if (entry.credits !== void 0 && (typeof entry.credits !== "number" || !Number.isFinite(entry.credits) || entry.credits < 0)) {
53037
+ return null;
53038
+ }
53039
+ return entry;
53040
+ }
53041
+ async function jsonlUsageSources(root, maxDepth, signal) {
53042
+ const sources = [];
53043
+ const visit = async (directory, depth) => {
53044
+ signal.throwIfAborted();
53045
+ const entries = await opendir(directory).catch((error51) => {
53046
+ if (error51.code === "ENOENT")
53047
+ return null;
53048
+ throw error51;
53049
+ });
53050
+ if (!entries)
53051
+ return;
53052
+ for await (const entry of entries) {
53053
+ signal.throwIfAborted();
53054
+ const file2 = path6.join(directory, entry.name);
53055
+ if (entry.isDirectory()) {
53056
+ if (depth < maxDepth)
53057
+ await visit(file2, depth + 1);
53058
+ } else if (entry.isFile() && entry.name.endsWith(".jsonl")) {
53059
+ const info = await lstat(file2).catch(() => null);
53060
+ if (info?.isFile() && info.size > 0) {
53061
+ sources.push({ id: file2, fingerprint: `${info.ino}:${info.size}:${info.mtimeMs}` });
53062
+ }
53063
+ }
53064
+ }
53065
+ };
53066
+ await visit(root, 0);
53067
+ return sources;
53068
+ }
53069
+ async function* jsonlRecords(file2, marker, signal) {
53070
+ const lines = createInterface({
53071
+ input: createReadStream(file2, { encoding: "utf8", signal }),
53072
+ crlfDelay: Infinity
53073
+ });
53074
+ for await (const line of lines) {
53075
+ if (!line.includes(marker))
53076
+ continue;
53077
+ let value;
53078
+ try {
53079
+ value = JSON.parse(line);
53080
+ } catch {
53081
+ continue;
53082
+ }
53083
+ if (typeof value === "object" && value !== null && !Array.isArray(value)) {
53084
+ yield value;
53085
+ }
53086
+ }
53087
+ }
53088
+ function nativeTimeMs(value) {
53089
+ const time3 = typeof value === "number" ? value : typeof value === "string" ? Date.parse(value) : Number.NaN;
53090
+ return Number.isFinite(time3) && time3 > 0 ? Math.floor(time3) : null;
53091
+ }
53092
+
53093
+ // dist/qoder-model-labels.js
53094
+ import { readFile, stat as stat2 } from "node:fs/promises";
53095
+ import path7 from "node:path";
53096
+ function record3(value) {
53097
+ return typeof value === "object" && value !== null && !Array.isArray(value);
53098
+ }
53099
+ async function readQoderModelLabels(configDirectory, signal) {
53100
+ signal.throwIfAborted();
53101
+ try {
53102
+ const file2 = path7.join(configDirectory, ".auth", "dynamic-texts.json");
53103
+ if ((await stat2(file2)).size > 1024 * 1024)
53104
+ return {};
53105
+ const data = JSON.parse(await readFile(file2, { encoding: "utf8", signal }));
53106
+ if (!record3(data) || !record3(data.locales))
53107
+ return {};
53108
+ const labels = /* @__PURE__ */ new Map();
53109
+ for (const locale of ["zh-CN", "en"]) {
53110
+ const texts = data.locales[locale];
53111
+ if (!record3(texts))
53112
+ continue;
53113
+ for (const [key, value] of Object.entries(texts)) {
53114
+ const prefix = "modelSelector.item.";
53115
+ if (!key.startsWith(prefix))
53116
+ continue;
53117
+ const id = key.slice(prefix.length);
53118
+ if (!id || id.length > 512 || /\.(description|markdownDescription)(\.|$)/u.test(id))
53119
+ continue;
53120
+ if (typeof value !== "string" || !value.trim() || value.trim().length > 512)
53121
+ continue;
53122
+ labels.set(id, value.trim());
53123
+ }
53124
+ }
53125
+ return Object.fromEntries(labels);
53126
+ } catch {
53127
+ signal.throwIfAborted();
53128
+ return {};
53129
+ }
53130
+ }
53131
+
53132
+ // dist/qoder-usage-statistics.js
53133
+ function qoderProjectsDirectory(environment, variant) {
53134
+ const cn3 = variant === "cn";
53135
+ const config2 = environment[cn3 ? "QODERCN_CONFIG_DIR" : "QODER_CONFIG_DIR"];
53136
+ const home = environment[cn3 ? "QODERCN_CLI_HOME" : "QODER_CLI_HOME"] || environment.HOME || environment.USERPROFILE || os4.homedir();
53137
+ return path8.resolve(config2 || path8.join(home, cn3 ? ".qoder-cn" : ".qoder"), "projects");
53138
+ }
53139
+ function isRecord2(value) {
53140
+ return typeof value === "object" && value !== null && !Array.isArray(value);
53141
+ }
53142
+ function count2(value) {
53143
+ return typeof value === "number" && Number.isSafeInteger(value) && value >= 0;
53144
+ }
53145
+ async function readQoderUsage(file2, signal) {
53146
+ const messages = /* @__PURE__ */ new Map();
53147
+ let sessionId;
53148
+ let cwd;
53149
+ for await (const line of jsonlRecords(file2, '"assistant"', signal)) {
53150
+ signal.throwIfAborted();
53151
+ if (line.type !== "assistant" || !isRecord2(line.message))
53152
+ continue;
53153
+ sessionId ??= line.sessionId;
53154
+ cwd ??= line.cwd;
53155
+ if (isRecord2(line.forkedFrom) || line.isApiErrorMessage === true)
53156
+ continue;
53157
+ const { id, model: model2, usage } = line.message;
53158
+ if (typeof id !== "string" || !id || model2 === "<synthetic>")
53159
+ continue;
53160
+ const message = messages.get(id) ?? { at: null };
53161
+ message.at ??= nativeTimeMs(line.timestamp);
53162
+ messages.set(id, message);
53163
+ if (!isRecord2(usage) || message.at === null)
53164
+ continue;
53165
+ const input = usage.input_tokens;
53166
+ const output = usage.output_tokens;
53167
+ const cached2 = usage.cache_read_input_tokens;
53168
+ const written = usage.cache_creation_input_tokens;
53169
+ if (!count2(input) || !count2(output) || !count2(cached2) || !count2(written))
53170
+ continue;
53171
+ const split = isRecord2(usage.cache_creation) ? usage.cache_creation : null;
53172
+ const oneHour = split?.ephemeral_1h_input_tokens;
53173
+ const details = isRecord2(usage.output_tokens_details) ? usage.output_tokens_details : null;
53174
+ const thinking = details?.thinking_tokens;
53175
+ const unreported = input === 0 && output === 0 && cached2 === 0 && written === 0;
53176
+ const entry = parseHarnessUsageEntry({
53177
+ id,
53178
+ occurredAtMs: message.at,
53179
+ ...typeof model2 === "string" && model2 ? { model: model2 } : {},
53180
+ inputTokens: input + cached2 + written,
53181
+ cachedInputTokens: cached2,
53182
+ cacheWriteInputTokens: written,
53183
+ ...count2(oneHour) ? { cacheWrite1hInputTokens: oneHour } : {},
53184
+ outputTokens: output,
53185
+ ...typeof usage.credits === "number" && Number.isFinite(usage.credits) && usage.credits >= 0 ? { credits: usage.credits } : {},
53186
+ ...count2(thinking) ? { reasoningOutputTokens: thinking } : {},
53187
+ ...unreported ? { tokensUnknown: true } : {}
53188
+ });
53189
+ if (entry)
53190
+ message.entry = entry;
53191
+ }
53192
+ const session = {
53193
+ sessionId: typeof sessionId === "string" ? sessionId : void 0,
53194
+ cwd: typeof cwd === "string" ? cwd : void 0
53195
+ };
53196
+ return [...messages.values()].flatMap(({ entry }) => entry ? [withUsageSession(entry, session)] : []);
53197
+ }
53198
+ function createQoderUsageStatistics(environment, variant) {
53199
+ return Object.freeze({
53200
+ readModelLabels: (signal) => readQoderModelLabels(path8.dirname(qoderProjectsDirectory(environment, variant)), signal),
53201
+ listSources: (signal) => jsonlUsageSources(qoderProjectsDirectory(environment, variant), 4, signal),
53202
+ readSource: readQoderUsage
53203
+ });
53204
+ }
53205
+
52704
53206
  // dist/qoder-adapter.js
52705
53207
  var QoderAdapter = class {
52706
53208
  harnessId;
@@ -52708,6 +53210,7 @@ var QoderAdapter = class {
52708
53210
  commandCatalog = QODER_FALLBACK_COMMAND_CATALOG;
52709
53211
  liveCommandCatalog = true;
52710
53212
  sessionImport;
53213
+ usageStatistics;
52711
53214
  #commandOverride;
52712
53215
  #environment;
52713
53216
  #platform;
@@ -52726,6 +53229,7 @@ var QoderAdapter = class {
52726
53229
  this.harnessId = harnessIdSchema.parse(runtime.harnessId);
52727
53230
  this.#commandOverride = options.commandOverride ?? options.environment?.[runtime.commandEnvironmentVariable];
52728
53231
  this.#environment = qoderEnvironment(options.environment);
53232
+ this.usageStatistics = createQoderUsageStatistics({ ...process.env, ...options.environment }, this.#variant);
52729
53233
  this.#platform = options.platform ?? process.platform;
52730
53234
  this.#queryFactory = options.queryFactory ?? ((input) => runtime.sdk.query(input));
52731
53235
  this.#forkSession = options.forkSession ?? runtime.sdk.forkSession;
@@ -52955,7 +53459,7 @@ var QoderAdapter = class {
52955
53459
  sourceInfo = await this.#getSessionInfo(sourceRef.data.nativeSessionId, { dir: input.cwd });
52956
53460
  } catch {
52957
53461
  }
52958
- if (sourceInfo?.cwd && path6.resolve(sourceInfo.cwd) !== path6.resolve(input.cwd)) {
53462
+ if (sourceInfo?.cwd && path9.resolve(sourceInfo.cwd) !== path9.resolve(input.cwd)) {
52959
53463
  return {
52960
53464
  ok: false,
52961
53465
  error: {