@liberseek/boft-cli-linux-x64 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 (56) 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 +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 +4 -4
  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
  }
@@ -12592,7 +12592,7 @@ var require_dist = __commonJS({
12592
12592
 
12593
12593
  // ../qoder/dist/qoder-adapter.js
12594
12594
  import { randomUUID as randomUUID2 } from "node:crypto";
12595
- import path6 from "node:path";
12595
+ import path9 from "node:path";
12596
12596
 
12597
12597
  // ../../../node_modules/zod/v4/classic/external.js
12598
12598
  var external_exports = {};
@@ -13360,10 +13360,10 @@ function mergeDefs(...defs) {
13360
13360
  function cloneDef(schema) {
13361
13361
  return mergeDefs(schema._zod.def);
13362
13362
  }
13363
- function getElementAtPath(obj, path7) {
13364
- if (!path7)
13363
+ function getElementAtPath(obj, path10) {
13364
+ if (!path10)
13365
13365
  return obj;
13366
- return path7.reduce((acc, key) => acc?.[key], obj);
13366
+ return path10.reduce((acc, key) => acc?.[key], obj);
13367
13367
  }
13368
13368
  function promiseAllObject(promisesObj) {
13369
13369
  const keys = Object.keys(promisesObj);
@@ -13772,11 +13772,11 @@ function explicitlyAborted(x3, startIndex = 0) {
13772
13772
  }
13773
13773
  return false;
13774
13774
  }
13775
- function prefixIssues(path7, issues) {
13775
+ function prefixIssues(path10, issues) {
13776
13776
  return issues.map((iss) => {
13777
13777
  var _a5;
13778
13778
  (_a5 = iss).path ?? (_a5.path = []);
13779
- iss.path.unshift(path7);
13779
+ iss.path.unshift(path10);
13780
13780
  return iss;
13781
13781
  });
13782
13782
  }
@@ -13923,16 +13923,16 @@ function flattenError(error51, mapper = (issue2) => issue2.message) {
13923
13923
  }
13924
13924
  function formatError(error51, mapper = (issue2) => issue2.message) {
13925
13925
  const fieldErrors = { _errors: [] };
13926
- const processError = (error52, path7 = []) => {
13926
+ const processError = (error52, path10 = []) => {
13927
13927
  for (const issue2 of error52.issues) {
13928
13928
  if (issue2.code === "invalid_union" && issue2.errors.length) {
13929
- issue2.errors.map((issues) => processError({ issues }, [...path7, ...issue2.path]));
13929
+ issue2.errors.map((issues) => processError({ issues }, [...path10, ...issue2.path]));
13930
13930
  } else if (issue2.code === "invalid_key") {
13931
- processError({ issues: issue2.issues }, [...path7, ...issue2.path]);
13931
+ processError({ issues: issue2.issues }, [...path10, ...issue2.path]);
13932
13932
  } else if (issue2.code === "invalid_element") {
13933
- processError({ issues: issue2.issues }, [...path7, ...issue2.path]);
13933
+ processError({ issues: issue2.issues }, [...path10, ...issue2.path]);
13934
13934
  } else {
13935
- const fullpath = [...path7, ...issue2.path];
13935
+ const fullpath = [...path10, ...issue2.path];
13936
13936
  if (fullpath.length === 0) {
13937
13937
  fieldErrors._errors.push(mapper(issue2));
13938
13938
  } else {
@@ -13959,17 +13959,17 @@ function formatError(error51, mapper = (issue2) => issue2.message) {
13959
13959
  }
13960
13960
  function treeifyError(error51, mapper = (issue2) => issue2.message) {
13961
13961
  const result = { errors: [] };
13962
- const processError = (error52, path7 = []) => {
13962
+ const processError = (error52, path10 = []) => {
13963
13963
  var _a5, _b;
13964
13964
  for (const issue2 of error52.issues) {
13965
13965
  if (issue2.code === "invalid_union" && issue2.errors.length) {
13966
- issue2.errors.map((issues) => processError({ issues }, [...path7, ...issue2.path]));
13966
+ issue2.errors.map((issues) => processError({ issues }, [...path10, ...issue2.path]));
13967
13967
  } else if (issue2.code === "invalid_key") {
13968
- processError({ issues: issue2.issues }, [...path7, ...issue2.path]);
13968
+ processError({ issues: issue2.issues }, [...path10, ...issue2.path]);
13969
13969
  } else if (issue2.code === "invalid_element") {
13970
- processError({ issues: issue2.issues }, [...path7, ...issue2.path]);
13970
+ processError({ issues: issue2.issues }, [...path10, ...issue2.path]);
13971
13971
  } else {
13972
- const fullpath = [...path7, ...issue2.path];
13972
+ const fullpath = [...path10, ...issue2.path];
13973
13973
  if (fullpath.length === 0) {
13974
13974
  result.errors.push(mapper(issue2));
13975
13975
  continue;
@@ -14001,8 +14001,8 @@ function treeifyError(error51, mapper = (issue2) => issue2.message) {
14001
14001
  }
14002
14002
  function toDotPath(_path) {
14003
14003
  const segs = [];
14004
- const path7 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
14005
- for (const seg of path7) {
14004
+ const path10 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
14005
+ for (const seg of path10) {
14006
14006
  if (typeof seg === "number")
14007
14007
  segs.push(`[${seg}]`);
14008
14008
  else if (typeof seg === "symbol")
@@ -17230,8 +17230,8 @@ function az_default() {
17230
17230
  }
17231
17231
 
17232
17232
  // ../../../node_modules/zod/v4/locales/be.js
17233
- function getBelarusianPlural(count, one, few, many) {
17234
- const absCount = Math.abs(count);
17233
+ function getBelarusianPlural(count3, one, few, many) {
17234
+ const absCount = Math.abs(count3);
17235
17235
  const lastDigit = absCount % 10;
17236
17236
  const lastTwoDigits = absCount % 100;
17237
17237
  if (lastTwoDigits >= 11 && lastTwoDigits <= 19) {
@@ -19309,8 +19309,8 @@ function hu_default() {
19309
19309
  }
19310
19310
 
19311
19311
  // ../../../node_modules/zod/v4/locales/hy.js
19312
- function getArmenianPlural(count, one, many) {
19313
- return Math.abs(count) === 1 ? one : many;
19312
+ function getArmenianPlural(count3, one, many) {
19313
+ return Math.abs(count3) === 1 ? one : many;
19314
19314
  }
19315
19315
  function withDefiniteArticle(word) {
19316
19316
  if (!word)
@@ -21438,8 +21438,8 @@ function ro_default() {
21438
21438
  }
21439
21439
 
21440
21440
  // ../../../node_modules/zod/v4/locales/ru.js
21441
- function getRussianPlural(count, one, few, many) {
21442
- const absCount = Math.abs(count);
21441
+ function getRussianPlural(count3, one, few, many) {
21442
+ const absCount = Math.abs(count3);
21443
21443
  const lastDigit = absCount % 10;
21444
21444
  const lastTwoDigits = absCount % 100;
21445
21445
  if (lastTwoDigits >= 11 && lastTwoDigits <= 19) {
@@ -26694,13 +26694,13 @@ function resolveRef(ref, ctx) {
26694
26694
  if (!ref.startsWith("#")) {
26695
26695
  throw new Error("External $ref is not supported, only local refs (#/...) are allowed");
26696
26696
  }
26697
- const path7 = ref.slice(1).split("/").filter(Boolean);
26698
- if (path7.length === 0) {
26697
+ const path10 = ref.slice(1).split("/").filter(Boolean);
26698
+ if (path10.length === 0) {
26699
26699
  return ctx.rootSchema;
26700
26700
  }
26701
26701
  const defsKey = ctx.version === "draft-2020-12" ? "$defs" : "definitions";
26702
- if (path7[0] === defsKey) {
26703
- const key = path7[1];
26702
+ if (path10[0] === defsKey) {
26703
+ const key = path10[1];
26704
26704
  if (!key || !ctx.defs[key]) {
26705
26705
  throw new Error(`Reference not found: ${ref}`);
26706
26706
  }
@@ -27108,6 +27108,15 @@ function date4(params) {
27108
27108
  // ../../../node_modules/zod/v4/classic/external.js
27109
27109
  config(en_default());
27110
27110
 
27111
+ // ../../shared-contracts/dist/delegation-read.js
27112
+ var REMOTE_THREAD_REPLY_MAX_BYTES = 16 * 1024 * 1024;
27113
+ var delegationReadParamsSchema = external_exports.strictObject({
27114
+ threadId: external_exports.string().min(1).max(1024),
27115
+ view: external_exports.enum(["result", "messages"]),
27116
+ cursor: external_exports.string().min(1).max(8192).optional(),
27117
+ limit: external_exports.number().int().min(1).max(100).optional()
27118
+ });
27119
+
27111
27120
  // ../../shared-contracts/dist/credential-imports.js
27112
27121
  var credentialSourceSchema = external_exports.object({
27113
27122
  id: external_exports.string().min(1).max(256),
@@ -27178,6 +27187,160 @@ var harnessDisplaySetSchema = external_exports.strictObject({
27178
27187
  initializeOnly: external_exports.boolean().optional()
27179
27188
  });
27180
27189
 
27190
+ // ../../shared-contracts/dist/model-price-overrides.js
27191
+ var usdPerMillionTokens = external_exports.number().finite().nonnegative();
27192
+ var modelPriceOverrideSchema = external_exports.strictObject({
27193
+ input: usdPerMillionTokens,
27194
+ output: usdPerMillionTokens,
27195
+ cacheRead: usdPerMillionTokens.optional(),
27196
+ cacheWrite: usdPerMillionTokens.optional(),
27197
+ cacheWrite1h: usdPerMillionTokens.optional()
27198
+ });
27199
+ var modelPriceKeySchema = external_exports.string().max(512).refine((key) => key.trim() === key && key.length > 0, "Model ID is required");
27200
+ var modelPriceOverridesSchema = external_exports.strictObject({
27201
+ /** Absolute path of the Host's `pricing.json`. */
27202
+ path: external_exports.string(),
27203
+ entries: external_exports.array(external_exports.strictObject({ key: external_exports.string(), price: modelPriceOverrideSchema })),
27204
+ /** Why the existing file is unusable; the Host then ignores it and refuses to overwrite it. */
27205
+ error: external_exports.string().nullable()
27206
+ });
27207
+ var modelPriceOverridesGetSchema = external_exports.strictObject({});
27208
+ var modelPriceOverridesSetSchema = external_exports.strictObject({
27209
+ key: modelPriceKeySchema,
27210
+ price: modelPriceOverrideSchema.nullable(),
27211
+ previousKey: modelPriceKeySchema.optional()
27212
+ });
27213
+ var modelPriceDefaultParamsSchema = external_exports.strictObject({
27214
+ model: modelPriceKeySchema
27215
+ });
27216
+ var modelPriceSuggestionSchema = external_exports.strictObject({
27217
+ /** Verified from catalog canonical links, not inferred from names or equal prices. */
27218
+ official: external_exports.boolean().optional(),
27219
+ canonicalModelId: external_exports.string().min(1).optional(),
27220
+ provider: external_exports.string().min(1).max(512),
27221
+ model: external_exports.string().min(1).max(512),
27222
+ price: modelPriceOverrideSchema
27223
+ });
27224
+ var modelPriceDefaultResultSchema = external_exports.strictObject({
27225
+ price: modelPriceOverrideSchema.nullable(),
27226
+ /** Local catalog suggestions only; never used automatically for pricing. */
27227
+ suggestions: external_exports.array(modelPriceSuggestionSchema).max(6).optional()
27228
+ });
27229
+
27230
+ // ../../shared-contracts/dist/usage-statistics.js
27231
+ var USAGE_STATISTICS_RANGES = ["today", "7d", "30d", "90d", "all"];
27232
+ var count = external_exports.number().int().min(0).max(Number.MAX_SAFE_INTEGER);
27233
+ var localDate = external_exports.string().regex(/^\d{4}-\d{2}-\d{2}$/u);
27234
+ var harness = external_exports.string().min(1).max(128);
27235
+ var model = external_exports.string().min(1).max(512);
27236
+ var project = external_exports.string().min(1).max(4096);
27237
+ var usageStatisticsParamsSchema = external_exports.strictObject({
27238
+ range: external_exports.enum(USAGE_STATISTICS_RANGES),
27239
+ harness: harness.optional(),
27240
+ model: model.nullable().optional(),
27241
+ project: project.nullable().optional(),
27242
+ /** One local date inside the range. */
27243
+ date: localDate.optional()
27244
+ });
27245
+ var usageStatisticsTotalsSchema = external_exports.strictObject({
27246
+ requests: count,
27247
+ inputTokens: count,
27248
+ cachedInputTokens: count,
27249
+ cacheWriteInputTokens: count,
27250
+ cacheKnownInputTokens: count,
27251
+ outputTokens: count,
27252
+ reasoningOutputTokens: count,
27253
+ /** USD at the public price, summed over the priced requests only. */
27254
+ costUsd: external_exports.number().finite().min(0),
27255
+ /** Requests without a price (or the cache data the price needs); not in `costUsd`. */
27256
+ unpricedRequests: count,
27257
+ /**
27258
+ * Requests whose storage gave no token counts: counted as requests, with neither tokens nor
27259
+ * cost, and not as unpriced.
27260
+ */
27261
+ unmeteredRequests: count
27262
+ });
27263
+ var totals = usageStatisticsTotalsSchema.shape;
27264
+ var usageStatisticsSessionSchema = external_exports.strictObject({
27265
+ harness,
27266
+ sessionId: external_exports.string().min(1).max(512),
27267
+ project: project.nullable(),
27268
+ /** Persisted Desktop title for a mapped Session, otherwise its native name; may be absent. */
27269
+ title: external_exports.string().min(1).max(200).optional(),
27270
+ /** Models the session used, most requests first. */
27271
+ models: external_exports.array(model).max(16),
27272
+ firstAtMs: count,
27273
+ lastAtMs: count,
27274
+ ...totals
27275
+ });
27276
+ var usageStatisticsResultSchema = external_exports.strictObject({
27277
+ range: external_exports.enum(USAGE_STATISTICS_RANGES),
27278
+ /** First local date of the range; null for all time. */
27279
+ from: localDate.nullable(),
27280
+ to: localDate,
27281
+ /** The filters these figures apply, echoed so a late answer to older filters is recognised. */
27282
+ filters: external_exports.strictObject({
27283
+ harness: harness.nullable(),
27284
+ model: model.nullable(),
27285
+ unknownModel: external_exports.boolean(),
27286
+ project: project.nullable(),
27287
+ unknownProject: external_exports.boolean(),
27288
+ date: localDate.nullable()
27289
+ }),
27290
+ /** Reading of native storage: incomplete while the first read, or a refresh, is under way. */
27291
+ reading: external_exports.strictObject({ complete: external_exports.boolean(), sources: count, read: count }),
27292
+ /** Harnesses whose storage could not be read; their part is missing, the rest is complete. */
27293
+ failures: external_exports.array(external_exports.strictObject({ harness, message: external_exports.string().max(2048) })).max(256),
27294
+ /** Every value seen in the range, ignoring the filters, to choose filters from. */
27295
+ options: external_exports.strictObject({
27296
+ harnesses: external_exports.array(harness).max(256),
27297
+ models: external_exports.array(model.nullable()).max(4096),
27298
+ projects: external_exports.array(project.nullable()).max(4096)
27299
+ }),
27300
+ /** Current display metadata, scoped by Harness. Never a pricing or filter identity.
27301
+ * Optional for older Hosts; missing/conflicting labels fall back to the native model ID.
27302
+ */
27303
+ modelLabels: external_exports.array(external_exports.strictObject({ harness, model, label: model })).max(4096).optional(),
27304
+ /** Native credits, all filters applied, never combined across Harnesses or treated as USD.
27305
+ * Only groups with at least one reported value appear; reportedRequests exposes partial data.
27306
+ */
27307
+ credits: external_exports.array(external_exports.strictObject({
27308
+ harness,
27309
+ model: model.nullable(),
27310
+ credits: external_exports.number().finite().min(0),
27311
+ reportedRequests: count,
27312
+ requests: count
27313
+ })).max(4096).optional(),
27314
+ /** All filters applied. */
27315
+ totals: usageStatisticsTotalsSchema,
27316
+ /** Each date and Harness of the range: every filter except the day. */
27317
+ daily: external_exports.array(external_exports.strictObject({ date: localDate, harness, ...totals })).max(2e5),
27318
+ /** Local weekday (0 = Sunday) and hour, all filters applied. */
27319
+ hourly: external_exports.array(external_exports.strictObject({
27320
+ weekday: external_exports.number().int().min(0).max(6),
27321
+ hour: external_exports.number().int().min(0).max(23),
27322
+ ...totals
27323
+ })).max(168),
27324
+ byHarness: external_exports.array(external_exports.strictObject({ harness, ...totals })).max(256),
27325
+ byModel: external_exports.array(external_exports.strictObject({
27326
+ model: model.nullable(),
27327
+ ...totals,
27328
+ /** Requests priced by what the Harness recorded they cost, not by a price list. */
27329
+ harnessPricedRequests: count
27330
+ })).max(4096),
27331
+ byProject: external_exports.array(external_exports.strictObject({ project: project.nullable(), ...totals })).max(4096),
27332
+ /**
27333
+ * The sessions that spent the most, by cost and by tokens without cache, all filters applied;
27334
+ * requests without a native session are not listed here but count everywhere else.
27335
+ */
27336
+ sessions: external_exports.array(usageStatisticsSessionSchema).max(100),
27337
+ /**
27338
+ * The sessions last active in the range, newest first, all filters applied. Optional for older
27339
+ * Hosts; missing is treated as no list rather than no sessions.
27340
+ */
27341
+ recentSessions: external_exports.array(usageStatisticsSessionSchema).max(100).optional()
27342
+ });
27343
+
27181
27344
  // ../../shared-contracts/dist/ids.js
27182
27345
  var opaqueIdSchema = external_exports.string().refine((value) => value.trim().length > 0, {
27183
27346
  message: "Identifier must not be empty or whitespace"
@@ -27199,13 +27362,40 @@ var HARNESS_PLUGIN_LIMIT = 128;
27199
27362
  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);
27200
27363
  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");
27201
27364
  var documentationUrlSchema = external_exports.url().refine((value) => /^https:\/\/[^/?#@]+(?:[/?#]|$)/iu.test(value), "Plugin documentation links must be credential-free HTTPS URLs");
27365
+ var localizedTextSchema = external_exports.object({ en: external_exports.string().max(4096), "zh-CN": external_exports.string().max(4096).optional() }).strict();
27366
+ var harnessInstallationGuideSchema = external_exports.object({
27367
+ commands: external_exports.array(external_exports.object({ terminal: external_exports.string().max(256), command: external_exports.string().max(4096) }).strict()).max(8),
27368
+ before: localizedTextSchema.optional(),
27369
+ after: localizedTextSchema.optional(),
27370
+ downloads: external_exports.array(external_exports.object({ label: external_exports.string().max(128), url: documentationUrlSchema }).strict()).max(8).optional()
27371
+ }).strict();
27202
27372
  var pluginPresentationShape = {
27203
27373
  id: harnessPluginIdSchema,
27204
27374
  name: external_exports.string().trim().min(1).max(128),
27205
27375
  version: external_exports.string().min(1).max(128),
27376
+ /** Capability-only plugin; omitted for existing session-capable plugins. */
27377
+ kind: external_exports.literal("usage").optional(),
27378
+ /** Original image styling or bounded vector paths; never arbitrary CSS/SVG markup. */
27379
+ iconStyle: external_exports.object({
27380
+ vector: external_exports.object({
27381
+ viewBox: external_exports.string().max(128).regex(/^-?\d+(?:\.\d+)?(?: +-?\d+(?:\.\d+)?){3}$/u),
27382
+ color: external_exports.string().regex(/^(?:currentColor|#[a-f0-9]{6})$/iu),
27383
+ paths: external_exports.array(external_exports.object({
27384
+ d: external_exports.string().min(1).max(32768).regex(/^[MmLlHhVvCcSsQqTtAaZz\d.,+eE\s-]+$/u),
27385
+ fillRule: external_exports.enum(["evenodd", "nonzero"]).optional(),
27386
+ fill: external_exports.string().regex(/^(?:currentColor|#[a-f0-9]{6})$/iu).optional()
27387
+ }).strict()).min(1).max(32)
27388
+ }).strict().optional(),
27389
+ background: external_exports.string().regex(/^#[a-f0-9]{6}$/iu).optional(),
27390
+ borderRadius: external_exports.number().min(0).max(50).optional(),
27391
+ paddingRatio: external_exports.number().min(0).max(0.25).optional()
27392
+ }).strict().optional(),
27393
+ installation: harnessInstallationGuideSchema.optional(),
27394
+ notice: localizedTextSchema.optional(),
27206
27395
  /** The factory accepts a persisted local entrypoint through its construction context. */
27207
27396
  launchCommand: external_exports.literal(true).optional(),
27208
27397
  links: external_exports.object({
27398
+ website: documentationUrlSchema.optional(),
27209
27399
  documentation: documentationUrlSchema.optional(),
27210
27400
  installation: documentationUrlSchema.optional()
27211
27401
  }).strict().optional()
@@ -27282,6 +27472,10 @@ var CONSOLE_HOST_METHODS = Object.freeze([
27282
27472
  "codexhost/account/list",
27283
27473
  "codexhost/account/refresh",
27284
27474
  "codexhost/account/usage/inspect",
27475
+ "codexhost/usage/model-prices/get",
27476
+ "codexhost/usage/model-prices/set",
27477
+ "codexhost/usage/model-prices/default",
27478
+ "codexhost/usage/statistics/get",
27285
27479
  "codexhost/update/check",
27286
27480
  "codexhost/update/start",
27287
27481
  "codexhost/update/status"
@@ -27346,6 +27540,7 @@ var threadUsageSnapshotSchema = external_exports.object({
27346
27540
  cacheWriteInputTokens: nonNegativeSafeIntegerSchema.optional(),
27347
27541
  outputTokens: nonNegativeSafeIntegerSchema.optional(),
27348
27542
  outputTokensPerSecond: finiteNonNegativeNumberSchema.optional(),
27543
+ apiOutputTokensPerSecond: finiteNonNegativeNumberSchema.optional(),
27349
27544
  reasoningOutputTokens: nonNegativeSafeIntegerSchema.optional(),
27350
27545
  totalTokens: nonNegativeSafeIntegerSchema.optional(),
27351
27546
  totalCostUsd: finiteNonNegativeNumberSchema.optional(),
@@ -27357,7 +27552,11 @@ var threadUsageSnapshotSchema = external_exports.object({
27357
27552
  planFiveHourUsedPercent: cacheHitRatePercentSchema.optional(),
27358
27553
  planFiveHourResetsAtUnix: nonNegativeSafeIntegerSchema.optional(),
27359
27554
  planSevenDayUsedPercent: cacheHitRatePercentSchema.optional(),
27360
- planSevenDayResetsAtUnix: nonNegativeSafeIntegerSchema.optional()
27555
+ planSevenDayResetsAtUnix: nonNegativeSafeIntegerSchema.optional(),
27556
+ sessionCacheHitRatePercent: cacheHitRatePercentSchema.optional(),
27557
+ timeToFirstOutputMs: nonNegativeSafeIntegerSchema.optional(),
27558
+ costSource: external_exports.enum(["publicPrice", "native"]).optional(),
27559
+ unpricedModels: external_exports.array(external_exports.string().min(1)).min(1).optional()
27361
27560
  }).strict().superRefine((usage, context) => {
27362
27561
  if (Object.keys(usage).length === 0) {
27363
27562
  context.addIssue({ code: "custom", message: "Thread Usage must contain a reliable field" });
@@ -27378,6 +27577,20 @@ var threadUsageSnapshotSchema = external_exports.object({
27378
27577
  path: ["contextWindowTokens"]
27379
27578
  });
27380
27579
  }
27580
+ if (usage.costSource !== void 0 && usage.totalCostUsd === void 0) {
27581
+ context.addIssue({
27582
+ code: "custom",
27583
+ message: "Thread Usage costSource must be provided with totalCostUsd",
27584
+ path: ["costSource"]
27585
+ });
27586
+ }
27587
+ if (usage.unpricedModels !== void 0 && usage.costSource !== "publicPrice") {
27588
+ context.addIssue({
27589
+ code: "custom",
27590
+ message: "Thread Usage unpricedModels must be provided with a publicPrice cost",
27591
+ path: ["unpricedModels"]
27592
+ });
27593
+ }
27381
27594
  if (usage.planFiveHourResetsAtUnix !== void 0 && usage.planFiveHourUsedPercent === void 0) {
27382
27595
  context.addIssue({
27383
27596
  code: "custom",
@@ -27647,27 +27860,27 @@ var harnessModelCatalogSchema = external_exports.object({
27647
27860
  }).strict().superRefine((catalog, context) => {
27648
27861
  const refs = /* @__PURE__ */ new Set();
27649
27862
  const thinkingIds = new Set(catalog.thinkingOptions.map(({ id }) => id));
27650
- for (const [index, model] of catalog.models.entries()) {
27651
- if (refs.has(model.ref.id)) {
27863
+ for (const [index, model2] of catalog.models.entries()) {
27864
+ if (refs.has(model2.ref.id)) {
27652
27865
  context.addIssue({
27653
27866
  code: "custom",
27654
27867
  message: "Model Catalog refs must be unique",
27655
27868
  path: ["models", index, "ref", "id"]
27656
27869
  });
27657
27870
  }
27658
- refs.add(model.ref.id);
27659
- if (model.fastModel) {
27660
- if (refs.has(model.fastModel.id) || catalog.models.some((entry) => entry.ref.id === model.fastModel?.id)) {
27871
+ refs.add(model2.ref.id);
27872
+ if (model2.fastModel) {
27873
+ if (refs.has(model2.fastModel.id) || catalog.models.some((entry) => entry.ref.id === model2.fastModel?.id)) {
27661
27874
  context.addIssue({
27662
27875
  code: "custom",
27663
27876
  message: "Fast Model refs must be distinct and unique",
27664
27877
  path: ["models", index, "fastModel"]
27665
27878
  });
27666
27879
  }
27667
- refs.add(model.fastModel.id);
27880
+ refs.add(model2.fastModel.id);
27668
27881
  }
27669
27882
  const supportedThinkingIds = /* @__PURE__ */ new Set();
27670
- for (const [optionIndex, optionId] of (model.supportedThinkingOptionIds ?? []).entries()) {
27883
+ for (const [optionIndex, optionId] of (model2.supportedThinkingOptionIds ?? []).entries()) {
27671
27884
  if (supportedThinkingIds.has(optionId)) {
27672
27885
  context.addIssue({
27673
27886
  code: "custom",
@@ -28261,6 +28474,11 @@ var codexSshDraftSchema = external_exports.strictObject({
28261
28474
  });
28262
28475
  var remoteConnectionsRequestSchema = external_exports.discriminatedUnion("action", [
28263
28476
  external_exports.strictObject({ action: external_exports.literal("list") }),
28477
+ external_exports.strictObject({
28478
+ action: external_exports.literal("read-thread"),
28479
+ hostId: hostId.refine((id) => id !== "local"),
28480
+ input: delegationReadParamsSchema
28481
+ }),
28264
28482
  external_exports.strictObject({
28265
28483
  action: external_exports.literal("save"),
28266
28484
  draft: codexSshDraftSchema,
@@ -29065,7 +29283,6 @@ var tokenFields = [
29065
29283
  "cachedInputTokens",
29066
29284
  "cacheWriteInputTokens",
29067
29285
  "outputTokens",
29068
- "outputTokensPerSecond",
29069
29286
  "reasoningOutputTokens",
29070
29287
  "totalTokens",
29071
29288
  "contextWindowTokens",
@@ -29073,10 +29290,12 @@ var tokenFields = [
29073
29290
  ];
29074
29291
  var safeIntegerFields = [
29075
29292
  "planFiveHourResetsAtUnix",
29076
- "planSevenDayResetsAtUnix"
29293
+ "planSevenDayResetsAtUnix",
29294
+ "timeToFirstOutputMs"
29077
29295
  ];
29078
29296
  var percentFields = [
29079
29297
  "cacheHitRatePercent",
29298
+ "sessionCacheHitRatePercent",
29080
29299
  "planFiveHourUsedPercent",
29081
29300
  "planSevenDayUsedPercent"
29082
29301
  ];
@@ -29084,9 +29303,14 @@ var usageFields = /* @__PURE__ */ new Set([
29084
29303
  ...tokenFields,
29085
29304
  ...safeIntegerFields,
29086
29305
  ...percentFields,
29306
+ "sessionCacheUsage",
29087
29307
  "totalCostUsd",
29088
29308
  "totalCredits",
29089
- "contextUsagePercent"
29309
+ "contextUsagePercent",
29310
+ "outputTokensPerSecond",
29311
+ "apiOutputTokensPerSecond",
29312
+ "costSource",
29313
+ "unpricedModels"
29090
29314
  ]);
29091
29315
  function isRecord(value) {
29092
29316
  return typeof value === "object" && value !== null && !Array.isArray(value);
@@ -29102,7 +29326,11 @@ function parseHostUsage(value) {
29102
29326
  throw new Error(`Harness Usage contains unknown field '${key}'`);
29103
29327
  }
29104
29328
  }
29105
- for (const field of ["totalCredits", "contextUsagePercent"]) {
29329
+ for (const field of [
29330
+ "totalCredits",
29331
+ "contextUsagePercent",
29332
+ "apiOutputTokensPerSecond"
29333
+ ]) {
29106
29334
  const candidate = value[field];
29107
29335
  if (candidate !== void 0 && (typeof candidate !== "number" || !Number.isFinite(candidate) || candidate < 0)) {
29108
29336
  throw new Error(`Harness Usage '${field}' must be a finite non-negative number`);
@@ -29138,6 +29366,12 @@ function parseHostUsage(value) {
29138
29366
  throw new Error(`Harness Usage '${field}' must be between 0 and 100`);
29139
29367
  }
29140
29368
  }
29369
+ if (value.sessionCacheUsage !== void 0) {
29370
+ const totals2 = value.sessionCacheUsage;
29371
+ 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) {
29372
+ throw new Error("Harness Usage 'sessionCacheUsage' must contain complete bounded token totals");
29373
+ }
29374
+ }
29141
29375
  const hasContextUsed = value.contextUsedTokens !== void 0;
29142
29376
  const hasContextWindow = value.contextWindowTokens !== void 0;
29143
29377
  if (hasContextUsed !== hasContextWindow) {
@@ -29152,8 +29386,43 @@ function parseHostUsage(value) {
29152
29386
  if (value.planSevenDayResetsAtUnix !== void 0 && value.planSevenDayUsedPercent === void 0) {
29153
29387
  throw new Error("Harness Usage 'planSevenDayResetsAtUnix' must be provided with 'planSevenDayUsedPercent'");
29154
29388
  }
29389
+ if (value.costSource !== void 0) {
29390
+ if (value.costSource !== "publicPrice" && value.costSource !== "native") {
29391
+ throw new Error("Harness Usage 'costSource' must be 'publicPrice' or 'native'");
29392
+ }
29393
+ if (value.totalCostUsd === void 0) {
29394
+ throw new Error("Harness Usage 'costSource' must be provided with 'totalCostUsd'");
29395
+ }
29396
+ }
29397
+ if (value.unpricedModels !== void 0) {
29398
+ const models = value.unpricedModels;
29399
+ if (!Array.isArray(models) || models.length === 0 || !models.every((model2) => typeof model2 === "string" && model2.length > 0)) {
29400
+ throw new Error("Harness Usage 'unpricedModels' must be a non-empty list of Model IDs");
29401
+ }
29402
+ if (value.costSource !== "publicPrice") {
29403
+ throw new Error("Harness Usage 'unpricedModels' must be provided with a 'publicPrice' cost");
29404
+ }
29405
+ return { ...value, unpricedModels: [...models] };
29406
+ }
29155
29407
  return { ...value };
29156
29408
  }
29409
+ var requestTokenFields = [
29410
+ "inputTokens",
29411
+ "cachedInputTokens",
29412
+ "cacheWriteInputTokens",
29413
+ "cacheWrite1hInputTokens",
29414
+ "outputTokens",
29415
+ "reasoningOutputTokens",
29416
+ "startedAtMs",
29417
+ "completedAtMs"
29418
+ ];
29419
+ var requestFields = /* @__PURE__ */ new Set([
29420
+ ...requestTokenFields,
29421
+ "requestId",
29422
+ "historical",
29423
+ "model",
29424
+ "provider"
29425
+ ]);
29157
29426
 
29158
29427
  // ../../harness-adapter/dist/live-command-catalog.js
29159
29428
  var COMMON_EXCLUDED_LIVE_COMMANDS = /* @__PURE__ */ new Set([
@@ -29808,10 +30077,10 @@ function parseQoderModelCatalog(rawModels) {
29808
30077
  ...defaultThinkingOptionId ? { defaultThinkingOptionId } : {}
29809
30078
  });
29810
30079
  }
29811
- function qoderAvailableThinkingOptions(catalog, model) {
29812
- if (!catalog || !model)
30080
+ function qoderAvailableThinkingOptions(catalog, model2) {
30081
+ if (!catalog || !model2)
29813
30082
  return void 0;
29814
- const supported = catalog.models.find(({ ref }) => ref.id === model.id)?.supportedThinkingOptionIds;
30083
+ const supported = catalog.models.find(({ ref }) => ref.id === model2.id)?.supportedThinkingOptionIds;
29815
30084
  if (!supported || supported.length === 0)
29816
30085
  return void 0;
29817
30086
  const options = supported.flatMap((id) => {
@@ -30323,8 +30592,8 @@ function getErrorMap2() {
30323
30592
 
30324
30593
  // ../../../node_modules/zod/v3/helpers/parseUtil.js
30325
30594
  var makeIssue = (params) => {
30326
- const { data, path: path7, errorMaps, issueData } = params;
30327
- const fullPath = [...path7, ...issueData.path || []];
30595
+ const { data, path: path10, errorMaps, issueData } = params;
30596
+ const fullPath = [...path10, ...issueData.path || []];
30328
30597
  const fullIssue = {
30329
30598
  ...issueData,
30330
30599
  path: fullPath
@@ -30439,11 +30708,11 @@ var errorUtil;
30439
30708
 
30440
30709
  // ../../../node_modules/zod/v3/types.js
30441
30710
  var ParseInputLazyPath = class {
30442
- constructor(parent, value, path7, key) {
30711
+ constructor(parent, value, path10, key) {
30443
30712
  this._cachedPath = [];
30444
30713
  this.parent = parent;
30445
30714
  this.data = value;
30446
- this._path = path7;
30715
+ this._path = path10;
30447
30716
  this._key = key;
30448
30717
  }
30449
30718
  get path() {
@@ -33970,11 +34239,11 @@ function normalizeObjectSchema(schema) {
33970
34239
  }
33971
34240
  return void 0;
33972
34241
  }
33973
- function getDotPath(path7) {
33974
- if (path7.length === 0) {
34242
+ function getDotPath(path10) {
34243
+ if (path10.length === 0) {
33975
34244
  return "object root";
33976
34245
  }
33977
- return path7.reduce((acc, seg, index) => {
34246
+ return path10.reduce((acc, seg, index) => {
33978
34247
  if (index === 0) {
33979
34248
  return String(seg);
33980
34249
  }
@@ -52703,6 +52972,289 @@ var QoderSessionImport = class {
52703
52972
  }
52704
52973
  };
52705
52974
 
52975
+ // ../qoder/dist/qoder-usage-statistics.js
52976
+ import os4 from "node:os";
52977
+ import path8 from "node:path";
52978
+
52979
+ // ../../harness-adapter/dist/usage-statistics.js
52980
+ import { createReadStream } from "node:fs";
52981
+ import { lstat, opendir } from "node:fs/promises";
52982
+ import path6 from "node:path";
52983
+ import { createInterface } from "node:readline";
52984
+ var MAX_SESSION_ID_LENGTH = 512;
52985
+ var MAX_CWD_LENGTH = 4096;
52986
+ var MAX_SESSION_TITLE_LENGTH = 200;
52987
+ function usageSessionTitle(value) {
52988
+ if (typeof value !== "string")
52989
+ return void 0;
52990
+ const normalized = value.replaceAll("\0", "").replaceAll(/\s+/gu, " ").trim();
52991
+ if (!normalized)
52992
+ return void 0;
52993
+ if (normalized.length <= MAX_SESSION_TITLE_LENGTH)
52994
+ return normalized;
52995
+ const characters = [...normalized];
52996
+ if (characters.length <= MAX_SESSION_TITLE_LENGTH)
52997
+ return normalized;
52998
+ return `${characters.slice(0, MAX_SESSION_TITLE_LENGTH - 1).join("").trimEnd()}…`;
52999
+ }
53000
+ function sessionIdOk(value) {
53001
+ return typeof value === "string" && value.length > 0 && value.length <= MAX_SESSION_ID_LENGTH;
53002
+ }
53003
+ function cwdOk(value) {
53004
+ 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("\\\\"));
53005
+ }
53006
+ function withUsageSession(entry, session) {
53007
+ const sessionId = sessionIdOk(session.sessionId) ? session.sessionId : void 0;
53008
+ const cwd = cwdOk(session.cwd) ? session.cwd : void 0;
53009
+ const sessionTitle = sessionId !== void 0 ? usageSessionTitle(session.title) : void 0;
53010
+ if (sessionId === void 0 && cwd === void 0)
53011
+ return entry;
53012
+ return {
53013
+ ...entry,
53014
+ ...sessionId !== void 0 ? { sessionId } : {},
53015
+ ...cwd !== void 0 ? { cwd } : {},
53016
+ ...sessionTitle !== void 0 ? { sessionTitle } : {}
53017
+ };
53018
+ }
53019
+ function tokenCount(value) {
53020
+ return typeof value === "number" && Number.isSafeInteger(value) && value >= 0;
53021
+ }
53022
+ function parseHarnessUsageEntry(value) {
53023
+ if (typeof value !== "object" || value === null || Array.isArray(value))
53024
+ return null;
53025
+ const entry = value;
53026
+ if (typeof entry.id !== "string" || entry.id.length === 0 || entry.id.length > 512)
53027
+ return null;
53028
+ if (!tokenCount(entry.occurredAtMs) || entry.occurredAtMs === 0)
53029
+ return null;
53030
+ if (entry.model !== void 0 && (typeof entry.model !== "string" || entry.model.length === 0)) {
53031
+ return null;
53032
+ }
53033
+ if (!tokenCount(entry.inputTokens) || !tokenCount(entry.outputTokens))
53034
+ return null;
53035
+ for (const field of [
53036
+ "cachedInputTokens",
53037
+ "cacheWriteInputTokens",
53038
+ "cacheWrite1hInputTokens",
53039
+ "reasoningOutputTokens"
53040
+ ]) {
53041
+ if (entry[field] !== void 0 && !tokenCount(entry[field]))
53042
+ return null;
53043
+ }
53044
+ const cached2 = entry.cachedInputTokens ?? 0;
53045
+ const written = entry.cacheWriteInputTokens ?? 0;
53046
+ if (cached2 + written > entry.inputTokens)
53047
+ return null;
53048
+ if ((entry.cacheWrite1hInputTokens ?? 0) > written)
53049
+ return null;
53050
+ if ((entry.reasoningOutputTokens ?? 0) > entry.outputTokens)
53051
+ return null;
53052
+ if (entry.sessionId !== void 0 && !sessionIdOk(entry.sessionId))
53053
+ return null;
53054
+ if (entry.cwd !== void 0 && !cwdOk(entry.cwd))
53055
+ return null;
53056
+ if (entry.sessionTitle !== void 0) {
53057
+ const sessionTitle = usageSessionTitle(entry.sessionTitle);
53058
+ if (sessionTitle === void 0)
53059
+ return null;
53060
+ entry.sessionTitle = sessionTitle;
53061
+ }
53062
+ if (entry.tokensUnknown !== void 0 && entry.tokensUnknown !== true)
53063
+ return null;
53064
+ if (entry.costUsd !== void 0 && (typeof entry.costUsd !== "number" || !Number.isFinite(entry.costUsd) || entry.costUsd < 0)) {
53065
+ return null;
53066
+ }
53067
+ if (entry.credits !== void 0 && (typeof entry.credits !== "number" || !Number.isFinite(entry.credits) || entry.credits < 0)) {
53068
+ return null;
53069
+ }
53070
+ return entry;
53071
+ }
53072
+ async function jsonlUsageSources(root, maxDepth, signal) {
53073
+ const sources = [];
53074
+ const visit = async (directory, depth) => {
53075
+ signal.throwIfAborted();
53076
+ const entries = await opendir(directory).catch((error51) => {
53077
+ if (error51.code === "ENOENT")
53078
+ return null;
53079
+ throw error51;
53080
+ });
53081
+ if (!entries)
53082
+ return;
53083
+ for await (const entry of entries) {
53084
+ signal.throwIfAborted();
53085
+ const file2 = path6.join(directory, entry.name);
53086
+ if (entry.isDirectory()) {
53087
+ if (depth < maxDepth)
53088
+ await visit(file2, depth + 1);
53089
+ } else if (entry.isFile() && entry.name.endsWith(".jsonl")) {
53090
+ const info = await lstat(file2).catch(() => null);
53091
+ if (info?.isFile() && info.size > 0) {
53092
+ sources.push({ id: file2, fingerprint: `${info.ino}:${info.size}:${info.mtimeMs}` });
53093
+ }
53094
+ }
53095
+ }
53096
+ };
53097
+ await visit(root, 0);
53098
+ return sources;
53099
+ }
53100
+ async function* jsonlRecords(file2, marker, signal) {
53101
+ const lines = createInterface({
53102
+ input: createReadStream(file2, { encoding: "utf8", signal }),
53103
+ crlfDelay: Infinity
53104
+ });
53105
+ for await (const line of lines) {
53106
+ if (!line.includes(marker))
53107
+ continue;
53108
+ let value;
53109
+ try {
53110
+ value = JSON.parse(line);
53111
+ } catch {
53112
+ continue;
53113
+ }
53114
+ if (typeof value === "object" && value !== null && !Array.isArray(value)) {
53115
+ yield value;
53116
+ }
53117
+ }
53118
+ }
53119
+ function nativeTimeMs(value) {
53120
+ const time3 = typeof value === "number" ? value : typeof value === "string" ? Date.parse(value) : Number.NaN;
53121
+ return Number.isFinite(time3) && time3 > 0 ? Math.floor(time3) : null;
53122
+ }
53123
+
53124
+ // ../qoder/dist/qoder-model-labels.js
53125
+ import { readFile, stat as stat2 } from "node:fs/promises";
53126
+ import path7 from "node:path";
53127
+ function record3(value) {
53128
+ return typeof value === "object" && value !== null && !Array.isArray(value);
53129
+ }
53130
+ async function readQoderModelLabels(configDirectory, signal) {
53131
+ signal.throwIfAborted();
53132
+ try {
53133
+ const file2 = path7.join(configDirectory, ".auth", "dynamic-texts.json");
53134
+ if ((await stat2(file2)).size > 1024 * 1024)
53135
+ return {};
53136
+ const data = JSON.parse(await readFile(file2, { encoding: "utf8", signal }));
53137
+ if (!record3(data) || !record3(data.locales))
53138
+ return {};
53139
+ const labels = /* @__PURE__ */ new Map();
53140
+ for (const locale of ["zh-CN", "en"]) {
53141
+ const texts = data.locales[locale];
53142
+ if (!record3(texts))
53143
+ continue;
53144
+ for (const [key, value] of Object.entries(texts)) {
53145
+ const prefix = "modelSelector.item.";
53146
+ if (!key.startsWith(prefix))
53147
+ continue;
53148
+ const id = key.slice(prefix.length);
53149
+ if (!id || id.length > 512 || /\.(description|markdownDescription)(\.|$)/u.test(id))
53150
+ continue;
53151
+ if (typeof value !== "string" || !value.trim() || value.trim().length > 512)
53152
+ continue;
53153
+ labels.set(id, value.trim());
53154
+ }
53155
+ }
53156
+ return Object.fromEntries(labels);
53157
+ } catch {
53158
+ signal.throwIfAborted();
53159
+ return {};
53160
+ }
53161
+ }
53162
+
53163
+ // ../qoder/dist/qoder-usage-statistics.js
53164
+ function qoderProjectsDirectory(environment, variant) {
53165
+ const cn3 = variant === "cn";
53166
+ const config2 = environment[cn3 ? "QODERCN_CONFIG_DIR" : "QODER_CONFIG_DIR"];
53167
+ const home = environment[cn3 ? "QODERCN_CLI_HOME" : "QODER_CLI_HOME"] || environment.HOME || environment.USERPROFILE || os4.homedir();
53168
+ return path8.resolve(config2 || path8.join(home, cn3 ? ".qoder-cn" : ".qoder"), "projects");
53169
+ }
53170
+ function isRecord2(value) {
53171
+ return typeof value === "object" && value !== null && !Array.isArray(value);
53172
+ }
53173
+ function qoderUserText(message) {
53174
+ if (!isRecord2(message))
53175
+ return void 0;
53176
+ const { content } = message;
53177
+ if (typeof content === "string")
53178
+ return content;
53179
+ if (!Array.isArray(content))
53180
+ return void 0;
53181
+ return content.filter((block) => isRecord2(block) && block.type === "text" && typeof block.text === "string").map((block) => String(block.text)).join(" ");
53182
+ }
53183
+ function count2(value) {
53184
+ return typeof value === "number" && Number.isSafeInteger(value) && value >= 0;
53185
+ }
53186
+ async function readQoderUsage(file2, signal) {
53187
+ const messages = /* @__PURE__ */ new Map();
53188
+ let sessionId;
53189
+ let cwd;
53190
+ let customTitle;
53191
+ let summary;
53192
+ let firstPrompt;
53193
+ for await (const line of jsonlRecords(file2, '"type"', signal)) {
53194
+ signal.throwIfAborted();
53195
+ if (line.type === "custom-title")
53196
+ customTitle = usageSessionTitle(line.customTitle);
53197
+ else if (!summary && line.type === "summary")
53198
+ summary = usageSessionTitle(line.summary);
53199
+ else if (!firstPrompt && line.type === "user") {
53200
+ firstPrompt = usageSessionTitle(qoderUserText(line.message));
53201
+ }
53202
+ if (line.type !== "assistant" || !isRecord2(line.message))
53203
+ continue;
53204
+ sessionId ??= line.sessionId;
53205
+ cwd ??= line.cwd;
53206
+ if (isRecord2(line.forkedFrom) || line.isApiErrorMessage === true)
53207
+ continue;
53208
+ const { id, model: model2, usage } = line.message;
53209
+ if (typeof id !== "string" || !id || model2 === "<synthetic>")
53210
+ continue;
53211
+ const message = messages.get(id) ?? { at: null };
53212
+ message.at ??= nativeTimeMs(line.timestamp);
53213
+ messages.set(id, message);
53214
+ if (!isRecord2(usage) || message.at === null)
53215
+ continue;
53216
+ const input = usage.input_tokens;
53217
+ const output = usage.output_tokens;
53218
+ const cached2 = usage.cache_read_input_tokens;
53219
+ const written = usage.cache_creation_input_tokens;
53220
+ if (!count2(input) || !count2(output) || !count2(cached2) || !count2(written))
53221
+ continue;
53222
+ const split = isRecord2(usage.cache_creation) ? usage.cache_creation : null;
53223
+ const oneHour = split?.ephemeral_1h_input_tokens;
53224
+ const details = isRecord2(usage.output_tokens_details) ? usage.output_tokens_details : null;
53225
+ const thinking = details?.thinking_tokens;
53226
+ const unreported = input === 0 && output === 0 && cached2 === 0 && written === 0;
53227
+ const entry = parseHarnessUsageEntry({
53228
+ id,
53229
+ occurredAtMs: message.at,
53230
+ ...typeof model2 === "string" && model2 ? { model: model2 } : {},
53231
+ inputTokens: input + cached2 + written,
53232
+ cachedInputTokens: cached2,
53233
+ cacheWriteInputTokens: written,
53234
+ ...count2(oneHour) ? { cacheWrite1hInputTokens: oneHour } : {},
53235
+ outputTokens: output,
53236
+ ...typeof usage.credits === "number" && Number.isFinite(usage.credits) && usage.credits >= 0 ? { credits: usage.credits } : {},
53237
+ ...count2(thinking) ? { reasoningOutputTokens: thinking } : {},
53238
+ ...unreported ? { tokensUnknown: true } : {}
53239
+ });
53240
+ if (entry)
53241
+ message.entry = entry;
53242
+ }
53243
+ const session = {
53244
+ sessionId: typeof sessionId === "string" ? sessionId : void 0,
53245
+ cwd: typeof cwd === "string" ? cwd : void 0,
53246
+ title: customTitle ?? summary ?? firstPrompt
53247
+ };
53248
+ return [...messages.values()].flatMap(({ entry }) => entry ? [withUsageSession(entry, session)] : []);
53249
+ }
53250
+ function createQoderUsageStatistics(environment, variant) {
53251
+ return Object.freeze({
53252
+ readModelLabels: (signal) => readQoderModelLabels(path8.dirname(qoderProjectsDirectory(environment, variant)), signal),
53253
+ listSources: (signal) => jsonlUsageSources(qoderProjectsDirectory(environment, variant), 4, signal),
53254
+ readSource: readQoderUsage
53255
+ });
53256
+ }
53257
+
52706
53258
  // ../qoder/dist/qoder-adapter.js
52707
53259
  var QoderAdapter = class {
52708
53260
  harnessId;
@@ -52710,6 +53262,7 @@ var QoderAdapter = class {
52710
53262
  commandCatalog = QODER_FALLBACK_COMMAND_CATALOG;
52711
53263
  liveCommandCatalog = true;
52712
53264
  sessionImport;
53265
+ usageStatistics;
52713
53266
  #commandOverride;
52714
53267
  #environment;
52715
53268
  #platform;
@@ -52728,6 +53281,7 @@ var QoderAdapter = class {
52728
53281
  this.harnessId = harnessIdSchema.parse(runtime.harnessId);
52729
53282
  this.#commandOverride = options.commandOverride ?? options.environment?.[runtime.commandEnvironmentVariable];
52730
53283
  this.#environment = qoderEnvironment(options.environment);
53284
+ this.usageStatistics = createQoderUsageStatistics({ ...process.env, ...options.environment }, this.#variant);
52731
53285
  this.#platform = options.platform ?? process.platform;
52732
53286
  this.#queryFactory = options.queryFactory ?? ((input) => runtime.sdk.query(input));
52733
53287
  this.#forkSession = options.forkSession ?? runtime.sdk.forkSession;
@@ -52957,7 +53511,7 @@ var QoderAdapter = class {
52957
53511
  sourceInfo = await this.#getSessionInfo(sourceRef.data.nativeSessionId, { dir: input.cwd });
52958
53512
  } catch {
52959
53513
  }
52960
- if (sourceInfo?.cwd && path6.resolve(sourceInfo.cwd) !== path6.resolve(input.cwd)) {
53514
+ if (sourceInfo?.cwd && path9.resolve(sourceInfo.cwd) !== path9.resolve(input.cwd)) {
52961
53515
  return {
52962
53516
  ok: false,
52963
53517
  error: {