@liberseek/boft-cli-win32-arm64 0.7.9 → 0.8.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 (57) 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 +322 -67
  5. package/app/console-web.js +9202 -5218
  6. package/app/desktop-controller.mjs +259 -42
  7. package/app/host-runtime.mjs +6250 -1689
  8. package/app/plugins/antigravity/manifest.json +18 -1
  9. package/app/plugins/antigravity/plugin.mjs +283 -42
  10. package/app/plugins/claude-code/manifest.json +28 -0
  11. package/app/plugins/claude-code/plugin.mjs +35676 -24151
  12. package/app/plugins/codebuddy/manifest.json +17 -0
  13. package/app/plugins/codebuddy/plugin.mjs +5972 -5356
  14. package/app/plugins/codex-usage/manifest.json +9 -0
  15. package/app/plugins/codex-usage/plugin.mjs +17386 -0
  16. package/app/plugins/cursor-cli/manifest.json +18 -1
  17. package/app/plugins/cursor-cli/plugin.mjs +358 -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 +823 -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 +933 -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 +469 -73
  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 +562 -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 +291 -22
  33. package/app/plugins/muse/manifest.json +18 -1
  34. package/app/plugins/muse/plugin.mjs +258 -17
  35. package/app/plugins/omp/manifest.json +21 -1
  36. package/app/plugins/omp/plugin.mjs +2763 -1958
  37. package/app/plugins/opencode/manifest.json +18 -1
  38. package/app/plugins/opencode/plugin.mjs +724 -147
  39. package/app/plugins/pi/manifest.json +32 -0
  40. package/app/plugins/pi/plugin.mjs +2908 -2312
  41. package/app/plugins/qoder/manifest.json +18 -1
  42. package/app/plugins/qoder/plugin.mjs +635 -81
  43. package/app/plugins/qoder-cn/manifest.json +18 -1
  44. package/app/plugins/qoder-cn/plugin.mjs +635 -81
  45. package/app/plugins/workbuddy/manifest.json +18 -0
  46. package/app/plugins/workbuddy/plugin.mjs +6362 -5748
  47. package/app/plugins/zcode/manifest.json +19 -1
  48. package/app/plugins/zcode/plugin.mjs +1117 -278
  49. package/app/renderer-extension.js +14675 -10087
  50. package/bin/boft.exe +0 -0
  51. package/libexec/boft-node-repl.exe +0 -0
  52. package/libexec/boft-shim.exe +0 -0
  53. package/libexec/boft-updater.exe +0 -0
  54. package/licenses/Cordis-LICENSE.txt +21 -0
  55. package/licenses/Cosmokit-LICENSE.txt +21 -0
  56. package/package.json +4 -4
  57. 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,160 @@ 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
+ /** Persisted Desktop title for a mapped Session, otherwise its native name; may be absent. */
27672
+ title: external_exports.string().min(1).max(200).optional(),
27673
+ /** Models the session used, most requests first. */
27674
+ models: external_exports.array(model).max(16),
27675
+ firstAtMs: count,
27676
+ lastAtMs: count,
27677
+ ...totals
27678
+ });
27679
+ var usageStatisticsResultSchema = external_exports.strictObject({
27680
+ range: external_exports.enum(USAGE_STATISTICS_RANGES),
27681
+ /** First local date of the range; null for all time. */
27682
+ from: localDate.nullable(),
27683
+ to: localDate,
27684
+ /** The filters these figures apply, echoed so a late answer to older filters is recognised. */
27685
+ filters: external_exports.strictObject({
27686
+ harness: harness.nullable(),
27687
+ model: model.nullable(),
27688
+ unknownModel: external_exports.boolean(),
27689
+ project: project.nullable(),
27690
+ unknownProject: external_exports.boolean(),
27691
+ date: localDate.nullable()
27692
+ }),
27693
+ /** Reading of native storage: incomplete while the first read, or a refresh, is under way. */
27694
+ reading: external_exports.strictObject({ complete: external_exports.boolean(), sources: count, read: count }),
27695
+ /** Harnesses whose storage could not be read; their part is missing, the rest is complete. */
27696
+ failures: external_exports.array(external_exports.strictObject({ harness, message: external_exports.string().max(2048) })).max(256),
27697
+ /** Every value seen in the range, ignoring the filters, to choose filters from. */
27698
+ options: external_exports.strictObject({
27699
+ harnesses: external_exports.array(harness).max(256),
27700
+ models: external_exports.array(model.nullable()).max(4096),
27701
+ projects: external_exports.array(project.nullable()).max(4096)
27702
+ }),
27703
+ /** Current display metadata, scoped by Harness. Never a pricing or filter identity.
27704
+ * Optional for older Hosts; missing/conflicting labels fall back to the native model ID.
27705
+ */
27706
+ modelLabels: external_exports.array(external_exports.strictObject({ harness, model, label: model })).max(4096).optional(),
27707
+ /** Native credits, all filters applied, never combined across Harnesses or treated as USD.
27708
+ * Only groups with at least one reported value appear; reportedRequests exposes partial data.
27709
+ */
27710
+ credits: external_exports.array(external_exports.strictObject({
27711
+ harness,
27712
+ model: model.nullable(),
27713
+ credits: external_exports.number().finite().min(0),
27714
+ reportedRequests: count,
27715
+ requests: count
27716
+ })).max(4096).optional(),
27717
+ /** All filters applied. */
27718
+ totals: usageStatisticsTotalsSchema,
27719
+ /** Each date and Harness of the range: every filter except the day. */
27720
+ daily: external_exports.array(external_exports.strictObject({ date: localDate, harness, ...totals })).max(2e5),
27721
+ /** Local weekday (0 = Sunday) and hour, all filters applied. */
27722
+ hourly: external_exports.array(external_exports.strictObject({
27723
+ weekday: external_exports.number().int().min(0).max(6),
27724
+ hour: external_exports.number().int().min(0).max(23),
27725
+ ...totals
27726
+ })).max(168),
27727
+ byHarness: external_exports.array(external_exports.strictObject({ harness, ...totals })).max(256),
27728
+ byModel: external_exports.array(external_exports.strictObject({
27729
+ model: model.nullable(),
27730
+ ...totals,
27731
+ /** Requests priced by what the Harness recorded they cost, not by a price list. */
27732
+ harnessPricedRequests: count
27733
+ })).max(4096),
27734
+ byProject: external_exports.array(external_exports.strictObject({ project: project.nullable(), ...totals })).max(4096),
27735
+ /**
27736
+ * The sessions that spent the most, by cost and by tokens without cache, all filters applied;
27737
+ * requests without a native session are not listed here but count everywhere else.
27738
+ */
27739
+ sessions: external_exports.array(usageStatisticsSessionSchema).max(100),
27740
+ /**
27741
+ * The sessions last active in the range, newest first, all filters applied. Optional for older
27742
+ * Hosts; missing is treated as no list rather than no sessions.
27743
+ */
27744
+ recentSessions: external_exports.array(usageStatisticsSessionSchema).max(100).optional()
27745
+ });
27746
+
27584
27747
  // ../../shared-contracts/dist/ids.js
27585
27748
  var opaqueIdSchema = external_exports.string().refine((value) => value.trim().length > 0, {
27586
27749
  message: "Identifier must not be empty or whitespace"
@@ -27602,13 +27765,40 @@ var HARNESS_PLUGIN_LIMIT = 128;
27602
27765
  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
27766
  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
27767
  var documentationUrlSchema = external_exports.url().refine((value) => /^https:\/\/[^/?#@]+(?:[/?#]|$)/iu.test(value), "Plugin documentation links must be credential-free HTTPS URLs");
27768
+ var localizedTextSchema = external_exports.object({ en: external_exports.string().max(4096), "zh-CN": external_exports.string().max(4096).optional() }).strict();
27769
+ var harnessInstallationGuideSchema = external_exports.object({
27770
+ commands: external_exports.array(external_exports.object({ terminal: external_exports.string().max(256), command: external_exports.string().max(4096) }).strict()).max(8),
27771
+ before: localizedTextSchema.optional(),
27772
+ after: localizedTextSchema.optional(),
27773
+ downloads: external_exports.array(external_exports.object({ label: external_exports.string().max(128), url: documentationUrlSchema }).strict()).max(8).optional()
27774
+ }).strict();
27605
27775
  var pluginPresentationShape = {
27606
27776
  id: harnessPluginIdSchema,
27607
27777
  name: external_exports.string().trim().min(1).max(128),
27608
27778
  version: external_exports.string().min(1).max(128),
27779
+ /** Capability-only plugin; omitted for existing session-capable plugins. */
27780
+ kind: external_exports.literal("usage").optional(),
27781
+ /** Original image styling or bounded vector paths; never arbitrary CSS/SVG markup. */
27782
+ iconStyle: external_exports.object({
27783
+ vector: external_exports.object({
27784
+ viewBox: external_exports.string().max(128).regex(/^-?\d+(?:\.\d+)?(?: +-?\d+(?:\.\d+)?){3}$/u),
27785
+ color: external_exports.string().regex(/^(?:currentColor|#[a-f0-9]{6})$/iu),
27786
+ paths: external_exports.array(external_exports.object({
27787
+ d: external_exports.string().min(1).max(32768).regex(/^[MmLlHhVvCcSsQqTtAaZz\d.,+eE\s-]+$/u),
27788
+ fillRule: external_exports.enum(["evenodd", "nonzero"]).optional(),
27789
+ fill: external_exports.string().regex(/^(?:currentColor|#[a-f0-9]{6})$/iu).optional()
27790
+ }).strict()).min(1).max(32)
27791
+ }).strict().optional(),
27792
+ background: external_exports.string().regex(/^#[a-f0-9]{6}$/iu).optional(),
27793
+ borderRadius: external_exports.number().min(0).max(50).optional(),
27794
+ paddingRatio: external_exports.number().min(0).max(0.25).optional()
27795
+ }).strict().optional(),
27796
+ installation: harnessInstallationGuideSchema.optional(),
27797
+ notice: localizedTextSchema.optional(),
27609
27798
  /** The factory accepts a persisted local entrypoint through its construction context. */
27610
27799
  launchCommand: external_exports.literal(true).optional(),
27611
27800
  links: external_exports.object({
27801
+ website: documentationUrlSchema.optional(),
27612
27802
  documentation: documentationUrlSchema.optional(),
27613
27803
  installation: documentationUrlSchema.optional()
27614
27804
  }).strict().optional()
@@ -27685,6 +27875,10 @@ var CONSOLE_HOST_METHODS = Object.freeze([
27685
27875
  "codexhost/account/list",
27686
27876
  "codexhost/account/refresh",
27687
27877
  "codexhost/account/usage/inspect",
27878
+ "codexhost/usage/model-prices/get",
27879
+ "codexhost/usage/model-prices/set",
27880
+ "codexhost/usage/model-prices/default",
27881
+ "codexhost/usage/statistics/get",
27688
27882
  "codexhost/update/check",
27689
27883
  "codexhost/update/start",
27690
27884
  "codexhost/update/status"
@@ -27749,6 +27943,7 @@ var threadUsageSnapshotSchema = external_exports.object({
27749
27943
  cacheWriteInputTokens: nonNegativeSafeIntegerSchema.optional(),
27750
27944
  outputTokens: nonNegativeSafeIntegerSchema.optional(),
27751
27945
  outputTokensPerSecond: finiteNonNegativeNumberSchema.optional(),
27946
+ apiOutputTokensPerSecond: finiteNonNegativeNumberSchema.optional(),
27752
27947
  reasoningOutputTokens: nonNegativeSafeIntegerSchema.optional(),
27753
27948
  totalTokens: nonNegativeSafeIntegerSchema.optional(),
27754
27949
  totalCostUsd: finiteNonNegativeNumberSchema.optional(),
@@ -27760,7 +27955,11 @@ var threadUsageSnapshotSchema = external_exports.object({
27760
27955
  planFiveHourUsedPercent: cacheHitRatePercentSchema.optional(),
27761
27956
  planFiveHourResetsAtUnix: nonNegativeSafeIntegerSchema.optional(),
27762
27957
  planSevenDayUsedPercent: cacheHitRatePercentSchema.optional(),
27763
- planSevenDayResetsAtUnix: nonNegativeSafeIntegerSchema.optional()
27958
+ planSevenDayResetsAtUnix: nonNegativeSafeIntegerSchema.optional(),
27959
+ sessionCacheHitRatePercent: cacheHitRatePercentSchema.optional(),
27960
+ timeToFirstOutputMs: nonNegativeSafeIntegerSchema.optional(),
27961
+ costSource: external_exports.enum(["publicPrice", "native"]).optional(),
27962
+ unpricedModels: external_exports.array(external_exports.string().min(1)).min(1).optional()
27764
27963
  }).strict().superRefine((usage, context) => {
27765
27964
  if (Object.keys(usage).length === 0) {
27766
27965
  context.addIssue({ code: "custom", message: "Thread Usage must contain a reliable field" });
@@ -27781,6 +27980,20 @@ var threadUsageSnapshotSchema = external_exports.object({
27781
27980
  path: ["contextWindowTokens"]
27782
27981
  });
27783
27982
  }
27983
+ if (usage.costSource !== void 0 && usage.totalCostUsd === void 0) {
27984
+ context.addIssue({
27985
+ code: "custom",
27986
+ message: "Thread Usage costSource must be provided with totalCostUsd",
27987
+ path: ["costSource"]
27988
+ });
27989
+ }
27990
+ if (usage.unpricedModels !== void 0 && usage.costSource !== "publicPrice") {
27991
+ context.addIssue({
27992
+ code: "custom",
27993
+ message: "Thread Usage unpricedModels must be provided with a publicPrice cost",
27994
+ path: ["unpricedModels"]
27995
+ });
27996
+ }
27784
27997
  if (usage.planFiveHourResetsAtUnix !== void 0 && usage.planFiveHourUsedPercent === void 0) {
27785
27998
  context.addIssue({
27786
27999
  code: "custom",
@@ -28050,27 +28263,27 @@ var harnessModelCatalogSchema = external_exports.object({
28050
28263
  }).strict().superRefine((catalog, context) => {
28051
28264
  const refs = /* @__PURE__ */ new Set();
28052
28265
  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)) {
28266
+ for (const [index, model2] of catalog.models.entries()) {
28267
+ if (refs.has(model2.ref.id)) {
28055
28268
  context.addIssue({
28056
28269
  code: "custom",
28057
28270
  message: "Model Catalog refs must be unique",
28058
28271
  path: ["models", index, "ref", "id"]
28059
28272
  });
28060
28273
  }
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)) {
28274
+ refs.add(model2.ref.id);
28275
+ if (model2.fastModel) {
28276
+ if (refs.has(model2.fastModel.id) || catalog.models.some((entry) => entry.ref.id === model2.fastModel?.id)) {
28064
28277
  context.addIssue({
28065
28278
  code: "custom",
28066
28279
  message: "Fast Model refs must be distinct and unique",
28067
28280
  path: ["models", index, "fastModel"]
28068
28281
  });
28069
28282
  }
28070
- refs.add(model.fastModel.id);
28283
+ refs.add(model2.fastModel.id);
28071
28284
  }
28072
28285
  const supportedThinkingIds = /* @__PURE__ */ new Set();
28073
- for (const [optionIndex, optionId] of (model.supportedThinkingOptionIds ?? []).entries()) {
28286
+ for (const [optionIndex, optionId] of (model2.supportedThinkingOptionIds ?? []).entries()) {
28074
28287
  if (supportedThinkingIds.has(optionId)) {
28075
28288
  context.addIssue({
28076
28289
  code: "custom",
@@ -28664,6 +28877,11 @@ var codexSshDraftSchema = external_exports.strictObject({
28664
28877
  });
28665
28878
  var remoteConnectionsRequestSchema = external_exports.discriminatedUnion("action", [
28666
28879
  external_exports.strictObject({ action: external_exports.literal("list") }),
28880
+ external_exports.strictObject({
28881
+ action: external_exports.literal("read-thread"),
28882
+ hostId: hostId.refine((id) => id !== "local"),
28883
+ input: delegationReadParamsSchema
28884
+ }),
28667
28885
  external_exports.strictObject({
28668
28886
  action: external_exports.literal("save"),
28669
28887
  draft: codexSshDraftSchema,
@@ -29063,7 +29281,6 @@ var tokenFields = [
29063
29281
  "cachedInputTokens",
29064
29282
  "cacheWriteInputTokens",
29065
29283
  "outputTokens",
29066
- "outputTokensPerSecond",
29067
29284
  "reasoningOutputTokens",
29068
29285
  "totalTokens",
29069
29286
  "contextWindowTokens",
@@ -29071,10 +29288,12 @@ var tokenFields = [
29071
29288
  ];
29072
29289
  var safeIntegerFields = [
29073
29290
  "planFiveHourResetsAtUnix",
29074
- "planSevenDayResetsAtUnix"
29291
+ "planSevenDayResetsAtUnix",
29292
+ "timeToFirstOutputMs"
29075
29293
  ];
29076
29294
  var percentFields = [
29077
29295
  "cacheHitRatePercent",
29296
+ "sessionCacheHitRatePercent",
29078
29297
  "planFiveHourUsedPercent",
29079
29298
  "planSevenDayUsedPercent"
29080
29299
  ];
@@ -29082,9 +29301,14 @@ var usageFields = /* @__PURE__ */ new Set([
29082
29301
  ...tokenFields,
29083
29302
  ...safeIntegerFields,
29084
29303
  ...percentFields,
29304
+ "sessionCacheUsage",
29085
29305
  "totalCostUsd",
29086
29306
  "totalCredits",
29087
- "contextUsagePercent"
29307
+ "contextUsagePercent",
29308
+ "outputTokensPerSecond",
29309
+ "apiOutputTokensPerSecond",
29310
+ "costSource",
29311
+ "unpricedModels"
29088
29312
  ]);
29089
29313
  function isRecord(value) {
29090
29314
  return typeof value === "object" && value !== null && !Array.isArray(value);
@@ -29100,7 +29324,11 @@ function parseHostUsage(value) {
29100
29324
  throw new Error(`Harness Usage contains unknown field '${key}'`);
29101
29325
  }
29102
29326
  }
29103
- for (const field of ["totalCredits", "contextUsagePercent"]) {
29327
+ for (const field of [
29328
+ "totalCredits",
29329
+ "contextUsagePercent",
29330
+ "apiOutputTokensPerSecond"
29331
+ ]) {
29104
29332
  const candidate = value[field];
29105
29333
  if (candidate !== void 0 && (typeof candidate !== "number" || !Number.isFinite(candidate) || candidate < 0)) {
29106
29334
  throw new Error(`Harness Usage '${field}' must be a finite non-negative number`);
@@ -29136,6 +29364,12 @@ function parseHostUsage(value) {
29136
29364
  throw new Error(`Harness Usage '${field}' must be between 0 and 100`);
29137
29365
  }
29138
29366
  }
29367
+ if (value.sessionCacheUsage !== void 0) {
29368
+ const totals2 = value.sessionCacheUsage;
29369
+ 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) {
29370
+ throw new Error("Harness Usage 'sessionCacheUsage' must contain complete bounded token totals");
29371
+ }
29372
+ }
29139
29373
  const hasContextUsed = value.contextUsedTokens !== void 0;
29140
29374
  const hasContextWindow = value.contextWindowTokens !== void 0;
29141
29375
  if (hasContextUsed !== hasContextWindow) {
@@ -29150,8 +29384,43 @@ function parseHostUsage(value) {
29150
29384
  if (value.planSevenDayResetsAtUnix !== void 0 && value.planSevenDayUsedPercent === void 0) {
29151
29385
  throw new Error("Harness Usage 'planSevenDayResetsAtUnix' must be provided with 'planSevenDayUsedPercent'");
29152
29386
  }
29387
+ if (value.costSource !== void 0) {
29388
+ if (value.costSource !== "publicPrice" && value.costSource !== "native") {
29389
+ throw new Error("Harness Usage 'costSource' must be 'publicPrice' or 'native'");
29390
+ }
29391
+ if (value.totalCostUsd === void 0) {
29392
+ throw new Error("Harness Usage 'costSource' must be provided with 'totalCostUsd'");
29393
+ }
29394
+ }
29395
+ if (value.unpricedModels !== void 0) {
29396
+ const models = value.unpricedModels;
29397
+ if (!Array.isArray(models) || models.length === 0 || !models.every((model2) => typeof model2 === "string" && model2.length > 0)) {
29398
+ throw new Error("Harness Usage 'unpricedModels' must be a non-empty list of Model IDs");
29399
+ }
29400
+ if (value.costSource !== "publicPrice") {
29401
+ throw new Error("Harness Usage 'unpricedModels' must be provided with a 'publicPrice' cost");
29402
+ }
29403
+ return { ...value, unpricedModels: [...models] };
29404
+ }
29153
29405
  return { ...value };
29154
29406
  }
29407
+ var requestTokenFields = [
29408
+ "inputTokens",
29409
+ "cachedInputTokens",
29410
+ "cacheWriteInputTokens",
29411
+ "cacheWrite1hInputTokens",
29412
+ "outputTokens",
29413
+ "reasoningOutputTokens",
29414
+ "startedAtMs",
29415
+ "completedAtMs"
29416
+ ];
29417
+ var requestFields = /* @__PURE__ */ new Set([
29418
+ ...requestTokenFields,
29419
+ "requestId",
29420
+ "historical",
29421
+ "model",
29422
+ "provider"
29423
+ ]);
29155
29424
 
29156
29425
  // ../../harness-adapter/dist/live-command-catalog.js
29157
29426
  var COMMON_EXCLUDED_LIVE_COMMANDS = /* @__PURE__ */ new Set([
@@ -29806,10 +30075,10 @@ function parseQoderModelCatalog(rawModels) {
29806
30075
  ...defaultThinkingOptionId ? { defaultThinkingOptionId } : {}
29807
30076
  });
29808
30077
  }
29809
- function qoderAvailableThinkingOptions(catalog, model) {
29810
- if (!catalog || !model)
30078
+ function qoderAvailableThinkingOptions(catalog, model2) {
30079
+ if (!catalog || !model2)
29811
30080
  return void 0;
29812
- const supported = catalog.models.find(({ ref }) => ref.id === model.id)?.supportedThinkingOptionIds;
30081
+ const supported = catalog.models.find(({ ref }) => ref.id === model2.id)?.supportedThinkingOptionIds;
29813
30082
  if (!supported || supported.length === 0)
29814
30083
  return void 0;
29815
30084
  const options = supported.flatMap((id) => {
@@ -30321,8 +30590,8 @@ function getErrorMap2() {
30321
30590
 
30322
30591
  // ../../../node_modules/zod/v3/helpers/parseUtil.js
30323
30592
  var makeIssue = (params) => {
30324
- const { data, path: path7, errorMaps, issueData } = params;
30325
- const fullPath = [...path7, ...issueData.path || []];
30593
+ const { data, path: path10, errorMaps, issueData } = params;
30594
+ const fullPath = [...path10, ...issueData.path || []];
30326
30595
  const fullIssue = {
30327
30596
  ...issueData,
30328
30597
  path: fullPath
@@ -30437,11 +30706,11 @@ var errorUtil;
30437
30706
 
30438
30707
  // ../../../node_modules/zod/v3/types.js
30439
30708
  var ParseInputLazyPath = class {
30440
- constructor(parent, value, path7, key) {
30709
+ constructor(parent, value, path10, key) {
30441
30710
  this._cachedPath = [];
30442
30711
  this.parent = parent;
30443
30712
  this.data = value;
30444
- this._path = path7;
30713
+ this._path = path10;
30445
30714
  this._key = key;
30446
30715
  }
30447
30716
  get path() {
@@ -33968,11 +34237,11 @@ function normalizeObjectSchema(schema) {
33968
34237
  }
33969
34238
  return void 0;
33970
34239
  }
33971
- function getDotPath(path7) {
33972
- if (path7.length === 0) {
34240
+ function getDotPath(path10) {
34241
+ if (path10.length === 0) {
33973
34242
  return "object root";
33974
34243
  }
33975
- return path7.reduce((acc, seg, index) => {
34244
+ return path10.reduce((acc, seg, index) => {
33976
34245
  if (index === 0) {
33977
34246
  return String(seg);
33978
34247
  }
@@ -52701,6 +52970,289 @@ var QoderSessionImport = class {
52701
52970
  }
52702
52971
  };
52703
52972
 
52973
+ // dist/qoder-usage-statistics.js
52974
+ import os4 from "node:os";
52975
+ import path8 from "node:path";
52976
+
52977
+ // ../../harness-adapter/dist/usage-statistics.js
52978
+ import { createReadStream } from "node:fs";
52979
+ import { lstat, opendir } from "node:fs/promises";
52980
+ import path6 from "node:path";
52981
+ import { createInterface } from "node:readline";
52982
+ var MAX_SESSION_ID_LENGTH = 512;
52983
+ var MAX_CWD_LENGTH = 4096;
52984
+ var MAX_SESSION_TITLE_LENGTH = 200;
52985
+ function usageSessionTitle(value) {
52986
+ if (typeof value !== "string")
52987
+ return void 0;
52988
+ const normalized = value.replaceAll("\0", "").replaceAll(/\s+/gu, " ").trim();
52989
+ if (!normalized)
52990
+ return void 0;
52991
+ if (normalized.length <= MAX_SESSION_TITLE_LENGTH)
52992
+ return normalized;
52993
+ const characters = [...normalized];
52994
+ if (characters.length <= MAX_SESSION_TITLE_LENGTH)
52995
+ return normalized;
52996
+ return `${characters.slice(0, MAX_SESSION_TITLE_LENGTH - 1).join("").trimEnd()}…`;
52997
+ }
52998
+ function sessionIdOk(value) {
52999
+ return typeof value === "string" && value.length > 0 && value.length <= MAX_SESSION_ID_LENGTH;
53000
+ }
53001
+ function cwdOk(value) {
53002
+ 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("\\\\"));
53003
+ }
53004
+ function withUsageSession(entry, session) {
53005
+ const sessionId = sessionIdOk(session.sessionId) ? session.sessionId : void 0;
53006
+ const cwd = cwdOk(session.cwd) ? session.cwd : void 0;
53007
+ const sessionTitle = sessionId !== void 0 ? usageSessionTitle(session.title) : void 0;
53008
+ if (sessionId === void 0 && cwd === void 0)
53009
+ return entry;
53010
+ return {
53011
+ ...entry,
53012
+ ...sessionId !== void 0 ? { sessionId } : {},
53013
+ ...cwd !== void 0 ? { cwd } : {},
53014
+ ...sessionTitle !== void 0 ? { sessionTitle } : {}
53015
+ };
53016
+ }
53017
+ function tokenCount(value) {
53018
+ return typeof value === "number" && Number.isSafeInteger(value) && value >= 0;
53019
+ }
53020
+ function parseHarnessUsageEntry(value) {
53021
+ if (typeof value !== "object" || value === null || Array.isArray(value))
53022
+ return null;
53023
+ const entry = value;
53024
+ if (typeof entry.id !== "string" || entry.id.length === 0 || entry.id.length > 512)
53025
+ return null;
53026
+ if (!tokenCount(entry.occurredAtMs) || entry.occurredAtMs === 0)
53027
+ return null;
53028
+ if (entry.model !== void 0 && (typeof entry.model !== "string" || entry.model.length === 0)) {
53029
+ return null;
53030
+ }
53031
+ if (!tokenCount(entry.inputTokens) || !tokenCount(entry.outputTokens))
53032
+ return null;
53033
+ for (const field of [
53034
+ "cachedInputTokens",
53035
+ "cacheWriteInputTokens",
53036
+ "cacheWrite1hInputTokens",
53037
+ "reasoningOutputTokens"
53038
+ ]) {
53039
+ if (entry[field] !== void 0 && !tokenCount(entry[field]))
53040
+ return null;
53041
+ }
53042
+ const cached2 = entry.cachedInputTokens ?? 0;
53043
+ const written = entry.cacheWriteInputTokens ?? 0;
53044
+ if (cached2 + written > entry.inputTokens)
53045
+ return null;
53046
+ if ((entry.cacheWrite1hInputTokens ?? 0) > written)
53047
+ return null;
53048
+ if ((entry.reasoningOutputTokens ?? 0) > entry.outputTokens)
53049
+ return null;
53050
+ if (entry.sessionId !== void 0 && !sessionIdOk(entry.sessionId))
53051
+ return null;
53052
+ if (entry.cwd !== void 0 && !cwdOk(entry.cwd))
53053
+ return null;
53054
+ if (entry.sessionTitle !== void 0) {
53055
+ const sessionTitle = usageSessionTitle(entry.sessionTitle);
53056
+ if (sessionTitle === void 0)
53057
+ return null;
53058
+ entry.sessionTitle = sessionTitle;
53059
+ }
53060
+ if (entry.tokensUnknown !== void 0 && entry.tokensUnknown !== true)
53061
+ return null;
53062
+ if (entry.costUsd !== void 0 && (typeof entry.costUsd !== "number" || !Number.isFinite(entry.costUsd) || entry.costUsd < 0)) {
53063
+ return null;
53064
+ }
53065
+ if (entry.credits !== void 0 && (typeof entry.credits !== "number" || !Number.isFinite(entry.credits) || entry.credits < 0)) {
53066
+ return null;
53067
+ }
53068
+ return entry;
53069
+ }
53070
+ async function jsonlUsageSources(root, maxDepth, signal) {
53071
+ const sources = [];
53072
+ const visit = async (directory, depth) => {
53073
+ signal.throwIfAborted();
53074
+ const entries = await opendir(directory).catch((error51) => {
53075
+ if (error51.code === "ENOENT")
53076
+ return null;
53077
+ throw error51;
53078
+ });
53079
+ if (!entries)
53080
+ return;
53081
+ for await (const entry of entries) {
53082
+ signal.throwIfAborted();
53083
+ const file2 = path6.join(directory, entry.name);
53084
+ if (entry.isDirectory()) {
53085
+ if (depth < maxDepth)
53086
+ await visit(file2, depth + 1);
53087
+ } else if (entry.isFile() && entry.name.endsWith(".jsonl")) {
53088
+ const info = await lstat(file2).catch(() => null);
53089
+ if (info?.isFile() && info.size > 0) {
53090
+ sources.push({ id: file2, fingerprint: `${info.ino}:${info.size}:${info.mtimeMs}` });
53091
+ }
53092
+ }
53093
+ }
53094
+ };
53095
+ await visit(root, 0);
53096
+ return sources;
53097
+ }
53098
+ async function* jsonlRecords(file2, marker, signal) {
53099
+ const lines = createInterface({
53100
+ input: createReadStream(file2, { encoding: "utf8", signal }),
53101
+ crlfDelay: Infinity
53102
+ });
53103
+ for await (const line of lines) {
53104
+ if (!line.includes(marker))
53105
+ continue;
53106
+ let value;
53107
+ try {
53108
+ value = JSON.parse(line);
53109
+ } catch {
53110
+ continue;
53111
+ }
53112
+ if (typeof value === "object" && value !== null && !Array.isArray(value)) {
53113
+ yield value;
53114
+ }
53115
+ }
53116
+ }
53117
+ function nativeTimeMs(value) {
53118
+ const time3 = typeof value === "number" ? value : typeof value === "string" ? Date.parse(value) : Number.NaN;
53119
+ return Number.isFinite(time3) && time3 > 0 ? Math.floor(time3) : null;
53120
+ }
53121
+
53122
+ // dist/qoder-model-labels.js
53123
+ import { readFile, stat as stat2 } from "node:fs/promises";
53124
+ import path7 from "node:path";
53125
+ function record3(value) {
53126
+ return typeof value === "object" && value !== null && !Array.isArray(value);
53127
+ }
53128
+ async function readQoderModelLabels(configDirectory, signal) {
53129
+ signal.throwIfAborted();
53130
+ try {
53131
+ const file2 = path7.join(configDirectory, ".auth", "dynamic-texts.json");
53132
+ if ((await stat2(file2)).size > 1024 * 1024)
53133
+ return {};
53134
+ const data = JSON.parse(await readFile(file2, { encoding: "utf8", signal }));
53135
+ if (!record3(data) || !record3(data.locales))
53136
+ return {};
53137
+ const labels = /* @__PURE__ */ new Map();
53138
+ for (const locale of ["zh-CN", "en"]) {
53139
+ const texts = data.locales[locale];
53140
+ if (!record3(texts))
53141
+ continue;
53142
+ for (const [key, value] of Object.entries(texts)) {
53143
+ const prefix = "modelSelector.item.";
53144
+ if (!key.startsWith(prefix))
53145
+ continue;
53146
+ const id = key.slice(prefix.length);
53147
+ if (!id || id.length > 512 || /\.(description|markdownDescription)(\.|$)/u.test(id))
53148
+ continue;
53149
+ if (typeof value !== "string" || !value.trim() || value.trim().length > 512)
53150
+ continue;
53151
+ labels.set(id, value.trim());
53152
+ }
53153
+ }
53154
+ return Object.fromEntries(labels);
53155
+ } catch {
53156
+ signal.throwIfAborted();
53157
+ return {};
53158
+ }
53159
+ }
53160
+
53161
+ // dist/qoder-usage-statistics.js
53162
+ function qoderProjectsDirectory(environment, variant) {
53163
+ const cn3 = variant === "cn";
53164
+ const config2 = environment[cn3 ? "QODERCN_CONFIG_DIR" : "QODER_CONFIG_DIR"];
53165
+ const home = environment[cn3 ? "QODERCN_CLI_HOME" : "QODER_CLI_HOME"] || environment.HOME || environment.USERPROFILE || os4.homedir();
53166
+ return path8.resolve(config2 || path8.join(home, cn3 ? ".qoder-cn" : ".qoder"), "projects");
53167
+ }
53168
+ function isRecord2(value) {
53169
+ return typeof value === "object" && value !== null && !Array.isArray(value);
53170
+ }
53171
+ function qoderUserText(message) {
53172
+ if (!isRecord2(message))
53173
+ return void 0;
53174
+ const { content } = message;
53175
+ if (typeof content === "string")
53176
+ return content;
53177
+ if (!Array.isArray(content))
53178
+ return void 0;
53179
+ return content.filter((block) => isRecord2(block) && block.type === "text" && typeof block.text === "string").map((block) => String(block.text)).join(" ");
53180
+ }
53181
+ function count2(value) {
53182
+ return typeof value === "number" && Number.isSafeInteger(value) && value >= 0;
53183
+ }
53184
+ async function readQoderUsage(file2, signal) {
53185
+ const messages = /* @__PURE__ */ new Map();
53186
+ let sessionId;
53187
+ let cwd;
53188
+ let customTitle;
53189
+ let summary;
53190
+ let firstPrompt;
53191
+ for await (const line of jsonlRecords(file2, '"type"', signal)) {
53192
+ signal.throwIfAborted();
53193
+ if (line.type === "custom-title")
53194
+ customTitle = usageSessionTitle(line.customTitle);
53195
+ else if (!summary && line.type === "summary")
53196
+ summary = usageSessionTitle(line.summary);
53197
+ else if (!firstPrompt && line.type === "user") {
53198
+ firstPrompt = usageSessionTitle(qoderUserText(line.message));
53199
+ }
53200
+ if (line.type !== "assistant" || !isRecord2(line.message))
53201
+ continue;
53202
+ sessionId ??= line.sessionId;
53203
+ cwd ??= line.cwd;
53204
+ if (isRecord2(line.forkedFrom) || line.isApiErrorMessage === true)
53205
+ continue;
53206
+ const { id, model: model2, usage } = line.message;
53207
+ if (typeof id !== "string" || !id || model2 === "<synthetic>")
53208
+ continue;
53209
+ const message = messages.get(id) ?? { at: null };
53210
+ message.at ??= nativeTimeMs(line.timestamp);
53211
+ messages.set(id, message);
53212
+ if (!isRecord2(usage) || message.at === null)
53213
+ continue;
53214
+ const input = usage.input_tokens;
53215
+ const output = usage.output_tokens;
53216
+ const cached2 = usage.cache_read_input_tokens;
53217
+ const written = usage.cache_creation_input_tokens;
53218
+ if (!count2(input) || !count2(output) || !count2(cached2) || !count2(written))
53219
+ continue;
53220
+ const split = isRecord2(usage.cache_creation) ? usage.cache_creation : null;
53221
+ const oneHour = split?.ephemeral_1h_input_tokens;
53222
+ const details = isRecord2(usage.output_tokens_details) ? usage.output_tokens_details : null;
53223
+ const thinking = details?.thinking_tokens;
53224
+ const unreported = input === 0 && output === 0 && cached2 === 0 && written === 0;
53225
+ const entry = parseHarnessUsageEntry({
53226
+ id,
53227
+ occurredAtMs: message.at,
53228
+ ...typeof model2 === "string" && model2 ? { model: model2 } : {},
53229
+ inputTokens: input + cached2 + written,
53230
+ cachedInputTokens: cached2,
53231
+ cacheWriteInputTokens: written,
53232
+ ...count2(oneHour) ? { cacheWrite1hInputTokens: oneHour } : {},
53233
+ outputTokens: output,
53234
+ ...typeof usage.credits === "number" && Number.isFinite(usage.credits) && usage.credits >= 0 ? { credits: usage.credits } : {},
53235
+ ...count2(thinking) ? { reasoningOutputTokens: thinking } : {},
53236
+ ...unreported ? { tokensUnknown: true } : {}
53237
+ });
53238
+ if (entry)
53239
+ message.entry = entry;
53240
+ }
53241
+ const session = {
53242
+ sessionId: typeof sessionId === "string" ? sessionId : void 0,
53243
+ cwd: typeof cwd === "string" ? cwd : void 0,
53244
+ title: customTitle ?? summary ?? firstPrompt
53245
+ };
53246
+ return [...messages.values()].flatMap(({ entry }) => entry ? [withUsageSession(entry, session)] : []);
53247
+ }
53248
+ function createQoderUsageStatistics(environment, variant) {
53249
+ return Object.freeze({
53250
+ readModelLabels: (signal) => readQoderModelLabels(path8.dirname(qoderProjectsDirectory(environment, variant)), signal),
53251
+ listSources: (signal) => jsonlUsageSources(qoderProjectsDirectory(environment, variant), 4, signal),
53252
+ readSource: readQoderUsage
53253
+ });
53254
+ }
53255
+
52704
53256
  // dist/qoder-adapter.js
52705
53257
  var QoderAdapter = class {
52706
53258
  harnessId;
@@ -52708,6 +53260,7 @@ var QoderAdapter = class {
52708
53260
  commandCatalog = QODER_FALLBACK_COMMAND_CATALOG;
52709
53261
  liveCommandCatalog = true;
52710
53262
  sessionImport;
53263
+ usageStatistics;
52711
53264
  #commandOverride;
52712
53265
  #environment;
52713
53266
  #platform;
@@ -52726,6 +53279,7 @@ var QoderAdapter = class {
52726
53279
  this.harnessId = harnessIdSchema.parse(runtime.harnessId);
52727
53280
  this.#commandOverride = options.commandOverride ?? options.environment?.[runtime.commandEnvironmentVariable];
52728
53281
  this.#environment = qoderEnvironment(options.environment);
53282
+ this.usageStatistics = createQoderUsageStatistics({ ...process.env, ...options.environment }, this.#variant);
52729
53283
  this.#platform = options.platform ?? process.platform;
52730
53284
  this.#queryFactory = options.queryFactory ?? ((input) => runtime.sdk.query(input));
52731
53285
  this.#forkSession = options.forkSession ?? runtime.sdk.forkSession;
@@ -52955,7 +53509,7 @@ var QoderAdapter = class {
52955
53509
  sourceInfo = await this.#getSessionInfo(sourceRef.data.nativeSessionId, { dir: input.cwd });
52956
53510
  } catch {
52957
53511
  }
52958
- if (sourceInfo?.cwd && path6.resolve(sourceInfo.cwd) !== path6.resolve(input.cwd)) {
53512
+ if (sourceInfo?.cwd && path9.resolve(sourceInfo.cwd) !== path9.resolve(input.cwd)) {
52959
53513
  return {
52960
53514
  ok: false,
52961
53515
  error: {