@liberseek/boft-cli-win32-arm64 0.8.3 → 0.8.5

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 (34) hide show
  1. package/README.md +1 -1
  2. package/app/codexhost-distribution.json +1 -1
  3. package/app/console-server.mjs +117 -13
  4. package/app/console-web.js +713 -129
  5. package/app/desktop-controller.mjs +713 -42
  6. package/app/host-runtime.mjs +2535 -855
  7. package/app/plugins/antigravity/plugin.mjs +437 -67
  8. package/app/plugins/claude-code/plugin.mjs +758 -248
  9. package/app/plugins/codebuddy/plugin.mjs +348 -156
  10. package/app/plugins/codex-usage/plugin.mjs +258 -106
  11. package/app/plugins/copilot/assets/icon.png +0 -0
  12. package/app/plugins/copilot/manifest.json +26 -0
  13. package/app/plugins/copilot/plugin.mjs +34651 -0
  14. package/app/plugins/cursor-cli/plugin.mjs +20905 -44961
  15. package/app/plugins/deepseek-harness/plugin.mjs +195 -53
  16. package/app/plugins/enabled.json +1 -0
  17. package/app/plugins/grok/plugin.mjs +584 -138
  18. package/app/plugins/hermes/plugin.mjs +134 -13
  19. package/app/plugins/kimi-code/plugin.mjs +145 -26
  20. package/app/plugins/kiro-cli/plugin.mjs +145 -26
  21. package/app/plugins/muse/plugin.mjs +132 -14
  22. package/app/plugins/omp/plugin.mjs +2245 -2040
  23. package/app/plugins/opencode/plugin.mjs +196 -72
  24. package/app/plugins/pi/plugin.mjs +2643 -2309
  25. package/app/plugins/qoder/plugin.mjs +162 -40
  26. package/app/plugins/qoder-cn/plugin.mjs +162 -40
  27. package/app/plugins/workbuddy/plugin.mjs +609 -180
  28. package/app/plugins/zcode/plugin.mjs +192 -44
  29. package/app/renderer-extension.js +3405 -429
  30. package/bin/boft.exe +0 -0
  31. package/libexec/boft-node-repl.exe +0 -0
  32. package/libexec/boft-shim.exe +0 -0
  33. package/libexec/boft-updater.exe +0 -0
  34. package/package.json +1 -1
@@ -3034,10 +3034,10 @@ var $ZodObject = /* @__PURE__ */ $constructor("$ZodObject", (inst, def) => {
3034
3034
  const shape = def.shape;
3035
3035
  const propValues = {};
3036
3036
  for (const key2 in shape) {
3037
- const field = shape[key2]._zod;
3038
- if (field.values) {
3037
+ const field2 = shape[key2]._zod;
3038
+ if (field2.values) {
3039
3039
  propValues[key2] ?? (propValues[key2] = /* @__PURE__ */ new Set());
3040
- for (const v of field.values)
3040
+ for (const v of field2.values)
3041
3041
  propValues[key2].add(v);
3042
3042
  }
3043
3043
  }
@@ -14656,10 +14656,19 @@ var model = external_exports.string().min(1).max(512);
14656
14656
  var project = external_exports.string().min(1).max(4096);
14657
14657
  var usageStatisticsParamsSchema = external_exports.strictObject({
14658
14658
  range: external_exports.enum(USAGE_STATISTICS_RANGES),
14659
+ /** Display timezone for ranges, dates and hourly buckets; omitted means the Host's local zone. */
14660
+ timeZone: external_exports.string().min(1).max(128).refine((value) => {
14661
+ try {
14662
+ new Intl.DateTimeFormat("en", { timeZone: value });
14663
+ return true;
14664
+ } catch {
14665
+ return false;
14666
+ }
14667
+ }, "Unsupported usage statistics timezone").optional(),
14659
14668
  harness: harness.optional(),
14660
14669
  model: model.nullable().optional(),
14661
14670
  project: project.nullable().optional(),
14662
- /** One local date inside the range. */
14671
+ /** One date in the query timezone inside the range. */
14663
14672
  date: localDate.optional()
14664
14673
  });
14665
14674
  var usageStatisticsTotalsSchema = external_exports.strictObject({
@@ -14668,6 +14677,8 @@ var usageStatisticsTotalsSchema = external_exports.strictObject({
14668
14677
  cachedInputTokens: count,
14669
14678
  cacheWriteInputTokens: count,
14670
14679
  cacheKnownInputTokens: count,
14680
+ cacheHitCachedInputTokens: count,
14681
+ cacheHitInputTokens: count,
14671
14682
  outputTokens: count,
14672
14683
  reasoningOutputTokens: count,
14673
14684
  /** USD at the public price, summed over the priced requests only. */
@@ -14695,7 +14706,7 @@ var usageStatisticsSessionSchema = external_exports.strictObject({
14695
14706
  });
14696
14707
  var usageStatisticsResultSchema = external_exports.strictObject({
14697
14708
  range: external_exports.enum(USAGE_STATISTICS_RANGES),
14698
- /** First local date of the range; null for all time. */
14709
+ /** First date in the query timezone (Host local when omitted); null for all time. */
14699
14710
  from: localDate.nullable(),
14700
14711
  to: localDate,
14701
14712
  /** The filters these figures apply, echoed so a late answer to older filters is recognised. */
@@ -14735,7 +14746,7 @@ var usageStatisticsResultSchema = external_exports.strictObject({
14735
14746
  totals: usageStatisticsTotalsSchema,
14736
14747
  /** Each date and Harness of the range: every filter except the day. */
14737
14748
  daily: external_exports.array(external_exports.strictObject({ date: localDate, harness, ...totals })).max(2e5),
14738
- /** Local weekday (0 = Sunday) and hour, all filters applied. */
14749
+ /** Weekday (0 = Sunday) and hour in the query timezone, all filters applied. */
14739
14750
  hourly: external_exports.array(external_exports.strictObject({
14740
14751
  weekday: external_exports.number().int().min(0).max(6),
14741
14752
  hour: external_exports.number().int().min(0).max(23),
@@ -14775,6 +14786,51 @@ var hostInteractionIdSchema = opaqueIdSchema.brand();
14775
14786
  var threadPrewarmDiscardParamsSchema = external_exports.object({ threadId: hostThreadIdSchema });
14776
14787
  var threadPrewarmDiscardResultSchema = external_exports.object({ discarded: external_exports.boolean() });
14777
14788
 
14789
+ // ../../shared-contracts/dist/thread-questions.js
14790
+ var field = external_exports.discriminatedUnion("type", [
14791
+ external_exports.object({
14792
+ id: external_exports.string().min(1),
14793
+ type: external_exports.literal("choice"),
14794
+ prompt: external_exports.string(),
14795
+ options: external_exports.array(external_exports.object({
14796
+ value: external_exports.string().min(1),
14797
+ label: external_exports.string(),
14798
+ description: external_exports.string().optional()
14799
+ })).min(1),
14800
+ multiple: external_exports.boolean(),
14801
+ allowOther: external_exports.boolean(),
14802
+ optional: external_exports.boolean()
14803
+ }),
14804
+ external_exports.object({
14805
+ id: external_exports.string().min(1),
14806
+ type: external_exports.literal("text"),
14807
+ prompt: external_exports.string(),
14808
+ multiline: external_exports.boolean(),
14809
+ secret: external_exports.literal(false),
14810
+ optional: external_exports.boolean(),
14811
+ placeholder: external_exports.string().optional(),
14812
+ prefill: external_exports.string().optional()
14813
+ })
14814
+ ]);
14815
+ var threadQuestionSchema = external_exports.object({
14816
+ interactionId: external_exports.string().min(1),
14817
+ turnId: external_exports.string().min(1),
14818
+ title: external_exports.string().optional(),
14819
+ questions: external_exports.array(field).min(1)
14820
+ }).refine(({ questions }) => questions.some((q) => q.type === "choice" && q.multiple), {
14821
+ message: "Shared cards require at least one multi-select question"
14822
+ });
14823
+ var threadQuestionsListParamsSchema = external_exports.strictObject({ threadId: external_exports.string().min(1) });
14824
+ var threadQuestionsResultSchema = external_exports.object({ questions: external_exports.array(threadQuestionSchema) });
14825
+ var threadQuestionRespondParamsSchema = external_exports.strictObject({
14826
+ threadId: external_exports.string().min(1),
14827
+ turnId: external_exports.string().min(1),
14828
+ interactionId: external_exports.string().min(1),
14829
+ answers: external_exports.record(external_exports.string(), external_exports.array(external_exports.string())),
14830
+ cancelled: external_exports.boolean().default(false)
14831
+ });
14832
+ var threadQuestionRespondResultSchema = external_exports.object({ accepted: external_exports.literal(true) });
14833
+
14778
14834
  // ../../shared-contracts/dist/harness-plugins.js
14779
14835
  var HARNESS_PLUGIN_MANIFEST_MAX_BYTES = 32 * 1024;
14780
14836
  var HARNESS_PLUGIN_ICON_MAX_BYTES = 128 * 1024;
@@ -14877,6 +14933,8 @@ var CONSOLE_HOST_METHODS = Object.freeze([
14877
14933
  "codexhost/harness/display-settings/set",
14878
14934
  "codexhost/harness/inspect",
14879
14935
  "codexhost/harness/installation",
14936
+ "codexhost/harness/installation/start",
14937
+ "codexhost/harness/installation/status",
14880
14938
  "codexhost/harness/launch-settings/get",
14881
14939
  "codexhost/harness/launch-settings/set",
14882
14940
  HARNESS_LONG_CONTEXT_GET_METHOD,
@@ -14954,7 +15012,18 @@ var threadManualCompactionStartedSchema = external_exports.strictObject({
14954
15012
  var nonNegativeSafeIntegerSchema = external_exports.number().int().safe().nonnegative();
14955
15013
  var finiteNonNegativeNumberSchema = external_exports.number().finite().nonnegative();
14956
15014
  var cacheHitRatePercentSchema = external_exports.number().finite().min(0).max(100);
15015
+ var indicatorTextSchema = (maximum) => harnessLocalizedTextSchema.refine((entries) => Object.values(entries).every((text2) => text2.length <= maximum));
15016
+ var composerIndicatorsSchema = external_exports.array(external_exports.object({
15017
+ kind: external_exports.literal("countdown"),
15018
+ id: external_exports.string().min(1).max(64),
15019
+ expiresAtUnix: nonNegativeSafeIntegerSchema,
15020
+ label: indicatorTextSchema(256).optional(),
15021
+ tooltip: indicatorTextSchema(1024).optional()
15022
+ }).strict()).max(2).refine((entries) => new Set(entries.map(({ id }) => id)).size === entries.length, {
15023
+ message: "Composer indicator IDs must be unique"
15024
+ });
14957
15025
  var threadUsageSnapshotSchema = external_exports.object({
15026
+ composerIndicators: composerIndicatorsSchema.optional(),
14958
15027
  inputTokens: nonNegativeSafeIntegerSchema.optional(),
14959
15028
  cachedInputTokens: nonNegativeSafeIntegerSchema.optional(),
14960
15029
  cacheWriteInputTokens: nonNegativeSafeIntegerSchema.optional(),
@@ -15380,7 +15449,9 @@ var harnessSessionCapabilitiesSchema = external_exports.object({
15380
15449
  }).strict().optional(),
15381
15450
  input: external_exports.object({
15382
15451
  image: external_exports.boolean()
15383
- }).strict().optional()
15452
+ }).strict().optional(),
15453
+ /** True only when `turn.steer` delivers input into the active Turn through a native primitive. */
15454
+ steer: external_exports.boolean().optional()
15384
15455
  }).strict();
15385
15456
  var harnessConfigurationStateSchema = external_exports.object({
15386
15457
  effectiveModel: harnessModelRefSchema.optional(),
@@ -15427,7 +15498,9 @@ var harnessInspectionSchema = external_exports.union([
15427
15498
  var harnessInspectParamsSchema = external_exports.object({
15428
15499
  harnessId: harnessIdSchema,
15429
15500
  cwd: nonBlankTextSchema2.max(16384).optional(),
15430
- refresh: external_exports.boolean().optional()
15501
+ refresh: external_exports.boolean().optional(),
15502
+ /** `availability` asks only whether the Harness can run; see `InspectHarnessInput.purpose`. */
15503
+ purpose: external_exports.literal("availability").optional()
15431
15504
  }).strict();
15432
15505
  var harnessWebUiOpenParamsSchema = external_exports.object({
15433
15506
  harnessId: harnessIdSchema
@@ -15512,13 +15585,25 @@ var threadOwnershipListResultSchema = external_exports.object({
15512
15585
  seen.add(thread.threadId);
15513
15586
  }
15514
15587
  });
15588
+ var threadSteeringInspectParamsSchema = external_exports.object({
15589
+ threadId: hostThreadIdSchema,
15590
+ /** The text about to be steered; a Harness command always stops and restarts. */
15591
+ text: external_exports.string().optional()
15592
+ }).strict();
15593
+ var threadSteerDeliverySchema = external_exports.enum(["activeTurn", "newTurn"]);
15594
+ var threadSteeringInspectResultSchema = external_exports.object({
15595
+ delivery: external_exports.enum(["official", "activeTurn", "newTurn"])
15596
+ }).strict();
15515
15597
 
15516
15598
  // ../../shared-contracts/dist/harness-route.js
15517
15599
  var harnessPluginRouteSchema = external_exports.object({
15518
15600
  harnessId: harnessPluginIdSchema,
15519
15601
  model: harnessModelRefSchema.optional(),
15520
15602
  thinkingOptionId: harnessThinkingOptionIdSchema.optional(),
15521
- permissionModeId: harnessPermissionModeIdSchema.optional()
15603
+ permissionModeId: harnessPermissionModeIdSchema.optional(),
15604
+ /** A draft prewarm create: stays unsubmitted until the user's first Turn.
15605
+ * Desktop forwards only the Model of a main-process prewarm to thread/start. */
15606
+ prewarm: external_exports.literal(true).optional()
15522
15607
  }).strict();
15523
15608
 
15524
15609
  // ../../shared-contracts/dist/harness-launch-settings.js
@@ -15544,6 +15629,10 @@ var harnessInstallationStateSchema = external_exports.object({
15544
15629
  latestVersion: external_exports.string().min(1).max(128),
15545
15630
  updateAvailable: external_exports.boolean(),
15546
15631
  canUpdate: external_exports.boolean(),
15632
+ /** Defaults to CLI; some Harnesses ship only inside a desktop application. */
15633
+ versionKind: external_exports.enum(["cli", "application"]).optional(),
15634
+ /** Official download opened by the user; does not imply an automatic installation. */
15635
+ manualUpdateUrl: external_exports.url().max(2048).refine((value) => /^https:\/\/[^/?#@]+(?:[/?#]|$)/iu.test(value), "Manual updates require a credential-free HTTPS URL").optional(),
15547
15636
  // Adapter-owned diagnostic text; UI uses messageCode rather than displaying it verbatim.
15548
15637
  message: external_exports.string().max(2048).optional(),
15549
15638
  messageCode: external_exports.string().min(1).max(128).optional(),
@@ -15551,6 +15640,20 @@ var harnessInstallationStateSchema = external_exports.object({
15551
15640
  notice: harnessLocalizedTextSchema.optional(),
15552
15641
  latestVersionKind: external_exports.enum(["unknown", "tracking-branch"]).optional()
15553
15642
  }).strict();
15643
+ var harnessInstallationTaskParamsSchema = external_exports.object({ taskId: external_exports.string().uuid() }).strict();
15644
+ var harnessInstallationTaskSchema = external_exports.discriminatedUnion("status", [
15645
+ external_exports.object({ taskId: external_exports.string().uuid(), status: external_exports.literal("running") }).strict(),
15646
+ external_exports.object({
15647
+ taskId: external_exports.string().uuid(),
15648
+ status: external_exports.literal("succeeded"),
15649
+ result: harnessInstallationStateSchema
15650
+ }).strict(),
15651
+ external_exports.object({
15652
+ taskId: external_exports.string().uuid(),
15653
+ status: external_exports.literal("failed"),
15654
+ error: external_exports.object({ code: external_exports.number().int(), message: external_exports.string().min(1).max(2048) }).strict()
15655
+ }).strict()
15656
+ ]);
15554
15657
 
15555
15658
  // ../../shared-contracts/dist/codex-accounts.js
15556
15659
  var accountIdSchema = external_exports.string().min(1).max(256).regex(/^[A-Za-z0-9._~-]+$/u);
@@ -15951,6 +16054,13 @@ import { setImmediate as yieldToEventLoop } from "node:timers/promises";
15951
16054
  // ../../harness-adapter/dist/usage-statistics.js
15952
16055
  import { createReadStream } from "node:fs";
15953
16056
  import { createInterface } from "node:readline";
16057
+ var HarnessUsageSourceChangedError = class extends Error {
16058
+ code = "HARNESS_USAGE_SOURCE_CHANGED";
16059
+ /** Plugins may bundle their own copy of this contract, so instanceof is insufficient. */
16060
+ static is(error51) {
16061
+ return typeof error51 === "object" && error51 !== null && "code" in error51 && error51.code === "HARNESS_USAGE_SOURCE_CHANGED";
16062
+ }
16063
+ };
15954
16064
  var MAX_SESSION_ID_LENGTH = 512;
15955
16065
  var MAX_CWD_LENGTH = 4096;
15956
16066
  var MAX_SESSION_TITLE_LENGTH = 200;
@@ -15962,10 +16072,13 @@ function usageSessionTitle(value) {
15962
16072
  return void 0;
15963
16073
  if (normalized.length <= MAX_SESSION_TITLE_LENGTH)
15964
16074
  return normalized;
15965
- const characters = [...normalized];
15966
- if (characters.length <= MAX_SESSION_TITLE_LENGTH)
15967
- return normalized;
15968
- return `${characters.slice(0, MAX_SESSION_TITLE_LENGTH - 1).join("").trimEnd()}…`;
16075
+ let title = "";
16076
+ for (const character of normalized) {
16077
+ if (title.length + character.length >= MAX_SESSION_TITLE_LENGTH)
16078
+ break;
16079
+ title += character;
16080
+ }
16081
+ return `${title.trimEnd()}…`;
15969
16082
  }
15970
16083
  function sessionIdOk(value) {
15971
16084
  return typeof value === "string" && value.length > 0 && value.length <= MAX_SESSION_ID_LENGTH;
@@ -16002,13 +16115,13 @@ function parseHarnessUsageEntry(value) {
16002
16115
  }
16003
16116
  if (!tokenCount(entry.inputTokens) || !tokenCount(entry.outputTokens))
16004
16117
  return null;
16005
- for (const field of [
16118
+ for (const field2 of [
16006
16119
  "cachedInputTokens",
16007
16120
  "cacheWriteInputTokens",
16008
16121
  "cacheWrite1hInputTokens",
16009
16122
  "reasoningOutputTokens"
16010
16123
  ]) {
16011
- if (entry[field] !== void 0 && !tokenCount(entry[field]))
16124
+ if (entry[field2] !== void 0 && !tokenCount(entry[field2]))
16012
16125
  return null;
16013
16126
  }
16014
16127
  const cached2 = entry.cachedInputTokens ?? 0;
@@ -16102,8 +16215,8 @@ function usage(value) {
16102
16215
  if (!row)
16103
16216
  return null;
16104
16217
  const result = { values: [], known: 0 };
16105
- for (const [i, field] of fields.entries()) {
16106
- const n = row[field];
16218
+ for (const [i, field2] of fields.entries()) {
16219
+ const n = row[field2];
16107
16220
  if (n !== void 0 && n !== null) {
16108
16221
  if (typeof n !== "number" || !Number.isSafeInteger(n) || n < 0)
16109
16222
  return null;
@@ -16468,8 +16581,9 @@ var CodexCounters = class {
16468
16581
  // dist/rollout-io.js
16469
16582
  import { createReadStream as createReadStream2 } from "node:fs";
16470
16583
  import { StringDecoder } from "node:string_decoder";
16471
- import { promisify } from "node:util";
16472
- import { zstdDecompress } from "node:zlib";
16584
+ import { pipeline } from "node:stream/promises";
16585
+ import { Readable } from "node:stream";
16586
+ import { constants as zstdConstants, createZstdDecompress } from "node:zlib";
16473
16587
  /*!
16474
16588
  * Rollout reading: zstd frame walking, streaming copy-prefix comparison.
16475
16589
  *
@@ -16492,74 +16606,103 @@ import { zstdDecompress } from "node:zlib";
16492
16606
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
16493
16607
  * SOFTWARE.
16494
16608
  */
16495
- var decompress = promisify(zstdDecompress);
16496
- var MAX_FRAME = 64 * 1024 * 1024;
16497
16609
  var MAX_LINE = 128 * 1024 * 1024;
16498
- function frameSize(data) {
16499
- if (data.length < 8)
16500
- return null;
16501
- const magic = data.readUInt32LE(0);
16502
- if ((magic & 4294967280) === 407710288) {
16503
- const size = 8 + data.readUInt32LE(4);
16504
- if (size > MAX_FRAME)
16505
- throw new Error("Codex zstd frame exceeds the safety limit");
16506
- return data.length >= size ? { size, skip: true } : null;
16507
- }
16508
- if (magic !== 4247762216)
16509
- throw new Error("Invalid Codex zstd frame");
16510
- const descriptor = data.readUInt8(4);
16511
- if (descriptor & 8)
16512
- throw new Error("Reserved Codex zstd frame header");
16513
- const single = descriptor >> 5 & 1;
16514
- let offset = 5 + (single ? 0 : 1) + ([0, 1, 2, 4][descriptor & 3] ?? 0) + ([single, 2, 4, 8][descriptor >> 6] ?? 0);
16515
- for (; ; ) {
16516
- if (offset + 3 > data.length)
16517
- return null;
16518
- const block = data.readUIntLE(offset, 3);
16519
- const type = block >> 1 & 3;
16520
- if (type === 3)
16521
- throw new Error("Reserved Codex zstd block");
16522
- offset += 3 + (type === 1 ? 1 : block >>> 3);
16523
- if (offset > MAX_FRAME)
16524
- throw new Error("Codex zstd frame exceeds the safety limit");
16525
- if (block & 1)
16526
- break;
16527
- }
16528
- if (descriptor & 4)
16529
- offset += 4;
16530
- return data.length >= offset ? { size: offset, skip: false } : null;
16531
- }
16532
16610
  async function* rolloutBytes(file2, signal) {
16533
16611
  signal.throwIfAborted();
16534
16612
  const stream = createReadStream2(file2, { signal });
16535
- let pending = Buffer.alloc(0);
16536
16613
  try {
16537
- for await (const value of stream) {
16538
- signal.throwIfAborted();
16539
- const chunk = value;
16540
- if (!file2.endsWith(".zst")) {
16614
+ if (!file2.endsWith(".zst")) {
16615
+ for await (const chunk of stream) {
16616
+ signal.throwIfAborted();
16541
16617
  yield chunk;
16618
+ }
16619
+ return;
16620
+ }
16621
+ const input = stream[Symbol.asyncIterator]();
16622
+ let pending = Buffer.alloc(0);
16623
+ async function readExact(size, allowEof = false) {
16624
+ const parts = [];
16625
+ let length = 0;
16626
+ while (length < size) {
16627
+ signal.throwIfAborted();
16628
+ if (!pending.length) {
16629
+ const next = await input.next();
16630
+ if (next.done) {
16631
+ if (allowEof && !length)
16632
+ return Buffer.alloc(0);
16633
+ throw new Error("Truncated Codex zstd rollout");
16634
+ }
16635
+ pending = next.value;
16636
+ }
16637
+ const count2 = Math.min(size - length, pending.length);
16638
+ parts.push(pending.subarray(0, count2));
16639
+ pending = pending.subarray(count2);
16640
+ length += count2;
16641
+ }
16642
+ return Buffer.concat(parts, length);
16643
+ }
16644
+ for (; ; ) {
16645
+ const magicBytes = await readExact(4, true);
16646
+ if (!magicBytes.length)
16647
+ break;
16648
+ const magic = magicBytes.readUInt32LE(0);
16649
+ if ((magic & 4294967280) === 407710288) {
16650
+ let size = (await readExact(4)).readUInt32LE(0);
16651
+ while (size) {
16652
+ const count2 = Math.min(size, 64 * 1024);
16653
+ await readExact(count2);
16654
+ size -= count2;
16655
+ }
16542
16656
  continue;
16543
16657
  }
16544
- pending = Buffer.concat([pending, chunk]);
16545
- for (; ; ) {
16546
- const frame = frameSize(pending);
16547
- if (!frame)
16548
- break;
16549
- if (!frame.skip) {
16550
- const decoded = await decompress(pending.subarray(0, frame.size), {
16551
- maxOutputLength: 128 * 1024 * 1024
16552
- });
16658
+ if (magic !== 4247762216)
16659
+ throw new Error("Invalid Codex zstd frame");
16660
+ const descriptorBytes = await readExact(1);
16661
+ const descriptor = descriptorBytes.readUInt8(0);
16662
+ if (descriptor & 8)
16663
+ throw new Error("Reserved Codex zstd frame header");
16664
+ const single = descriptor >> 5 & 1;
16665
+ const headerSize = (single ? 0 : 1) + ([0, 1, 2, 4][descriptor & 3] ?? 0) + ([single, 2, 4, 8][descriptor >> 6] ?? 0);
16666
+ const header = Buffer.concat([magicBytes, descriptorBytes, await readExact(headerSize)]);
16667
+ async function* frameChunks() {
16668
+ yield header;
16669
+ for (; ; ) {
16670
+ const blockBytes = await readExact(3);
16671
+ const block = blockBytes.readUIntLE(0, 3);
16672
+ const type = block >> 1 & 3;
16673
+ if (type === 3)
16674
+ throw new Error("Reserved Codex zstd block");
16675
+ const blockSize = block >>> 3;
16676
+ if (blockSize > 128 * 1024)
16677
+ throw new Error("Invalid Codex zstd block size");
16678
+ yield blockBytes;
16679
+ yield await readExact(type === 1 ? 1 : blockSize);
16680
+ if (block & 1)
16681
+ break;
16682
+ }
16683
+ if (descriptor & 4)
16684
+ yield await readExact(4);
16685
+ }
16686
+ const frame = Readable.from(frameChunks(), { objectMode: false });
16687
+ const decoder = createZstdDecompress({
16688
+ chunkSize: 64 * 1024,
16689
+ params: { [zstdConstants.ZSTD_d_windowLogMax]: 27 }
16690
+ });
16691
+ const completed = pipeline(frame, decoder, { signal }).then(() => null, (error51) => error51);
16692
+ try {
16693
+ for await (const chunk of decoder) {
16553
16694
  signal.throwIfAborted();
16554
- yield decoded;
16695
+ yield chunk;
16555
16696
  }
16556
- pending = pending.subarray(frame.size);
16697
+ const error51 = await completed;
16698
+ if (error51)
16699
+ throw error51;
16700
+ } finally {
16701
+ frame.destroy();
16702
+ decoder.destroy();
16703
+ await completed;
16557
16704
  }
16558
- if (pending.length > MAX_FRAME)
16559
- throw new Error("Codex zstd frame exceeds the safety limit");
16560
16705
  }
16561
- if (pending.length)
16562
- throw new Error("Truncated Codex zstd rollout");
16563
16706
  } finally {
16564
16707
  stream.destroy();
16565
16708
  }
@@ -16633,12 +16776,17 @@ var ROW_KINDS = /* @__PURE__ */ new Set([
16633
16776
  ]);
16634
16777
  var HEAD_TYPE = /"type"\s*:\s*"([^"]+)"/u;
16635
16778
  var TAIL_TYPE = /"type"\s*:\s*"([^"]+)"\s*\}\s*$/u;
16779
+ var USER_ROLE = /"role"\s*:\s*"user"/u;
16780
+ var EVENT_OF_INTEREST = /"type"\s*:\s*"(?:token_count|task_started|thread_settings_applied|user_message)"/u;
16636
16781
  function rowKind(line) {
16637
16782
  const head = HEAD_TYPE.exec(line.slice(0, 1024))?.[1];
16638
16783
  if (head && ROW_KINDS.has(head))
16639
16784
  return head;
16640
16785
  return TAIL_TYPE.exec(line.slice(-1024))?.[1] ?? head;
16641
16786
  }
16787
+ function markerIn(pattern, line) {
16788
+ return pattern.test(line.slice(0, 1024)) || pattern.test(line.slice(-1024));
16789
+ }
16642
16790
  async function stamp(file2) {
16643
16791
  const s = await lstat(file2, { bigint: true });
16644
16792
  if (!s.isFile())
@@ -16702,9 +16850,9 @@ async function readCodexRollouts(files, thread, signal, options = {}) {
16702
16850
  options.onIncomplete?.();
16703
16851
  if (!kind || !ROW_KINDS.has(kind))
16704
16852
  continue;
16705
- if (kind === "response_item" && !/"role"\s*:\s*"user"/u.test(line.slice(0, 1024)))
16853
+ if (kind === "response_item" && !markerIn(USER_ROLE, line))
16706
16854
  continue;
16707
- if (kind === "event_msg" && !/"type"\s*:\s*"(?:token_count|task_started|thread_settings_applied|user_message)"/u.test(line.slice(0, 1024)))
16855
+ if (kind === "event_msg" && !markerIn(EVENT_OF_INTEREST, line))
16708
16856
  continue;
16709
16857
  let row;
16710
16858
  try {
@@ -16755,8 +16903,10 @@ async function readCodexRollouts(files, thread, signal, options = {}) {
16755
16903
  break;
16756
16904
  }
16757
16905
  case "response_item":
16758
- counters.boundary();
16759
- firstPrompt ??= userItemPrompt(p);
16906
+ if (p.type === "message" && p.role === "user") {
16907
+ counters.boundary();
16908
+ firstPrompt ??= userItemPrompt(p);
16909
+ }
16760
16910
  break;
16761
16911
  case "event_msg":
16762
16912
  if (p.type === "task_started") {
@@ -16886,7 +17036,7 @@ function createCodexUsageStatistics(environment, options = {}) {
16886
17036
  const entries = await readCodexRollouts(kept.map(({ file: file2 }) => file2), group.thread, signal, options);
16887
17037
  for (const file2 of group.files)
16888
17038
  if (await stamp(file2.file) !== file2.fingerprint)
16889
- throw new Error("Codex rollout changed while reading; refresh to retry");
17039
+ throw new HarnessUsageSourceChangedError("Codex rollout changed while reading; refresh to retry");
16890
17040
  const named = options.sessionId ? void 0 : (await threadNames(signal)).get(group.thread);
16891
17041
  return named ? entries.map((entry) => withUsageSession(entry, {
16892
17042
  sessionId: entry.sessionId,
@@ -16927,6 +17077,7 @@ var usageFields = /* @__PURE__ */ new Set([
16927
17077
  ...safeIntegerFields,
16928
17078
  ...percentFields,
16929
17079
  "sessionCacheUsage",
17080
+ "composerIndicators",
16930
17081
  "totalCostUsd",
16931
17082
  "totalCredits",
16932
17083
  "contextUsagePercent",
@@ -16949,26 +17100,27 @@ function parseHostUsage(value) {
16949
17100
  throw new Error(`Harness Usage contains unknown field '${key2}'`);
16950
17101
  }
16951
17102
  }
16952
- for (const field of [
17103
+ const indicators = value.composerIndicators === void 0 ? {} : { composerIndicators: composerIndicatorsSchema.parse(value.composerIndicators) };
17104
+ for (const field2 of [
16953
17105
  "totalCredits",
16954
17106
  "contextUsagePercent",
16955
17107
  "apiOutputTokensPerSecond"
16956
17108
  ]) {
16957
- const candidate = value[field];
17109
+ const candidate = value[field2];
16958
17110
  if (candidate !== void 0 && (typeof candidate !== "number" || !Number.isFinite(candidate) || candidate < 0)) {
16959
- throw new Error(`Harness Usage '${field}' must be a finite non-negative number`);
17111
+ throw new Error(`Harness Usage '${field2}' must be a finite non-negative number`);
16960
17112
  }
16961
17113
  }
16962
- for (const field of tokenFields) {
16963
- const candidate = value[field];
17114
+ for (const field2 of tokenFields) {
17115
+ const candidate = value[field2];
16964
17116
  if (candidate !== void 0 && (typeof candidate !== "number" || !Number.isSafeInteger(candidate) || candidate < 0)) {
16965
- throw new Error(`Harness Usage '${field}' must be a non-negative safe integer`);
17117
+ throw new Error(`Harness Usage '${field2}' must be a non-negative safe integer`);
16966
17118
  }
16967
17119
  }
16968
- for (const field of safeIntegerFields) {
16969
- const candidate = value[field];
17120
+ for (const field2 of safeIntegerFields) {
17121
+ const candidate = value[field2];
16970
17122
  if (candidate !== void 0 && (typeof candidate !== "number" || !Number.isSafeInteger(candidate) || candidate < 0)) {
16971
- throw new Error(`Harness Usage '${field}' must be a non-negative safe integer`);
17123
+ throw new Error(`Harness Usage '${field2}' must be a non-negative safe integer`);
16972
17124
  }
16973
17125
  }
16974
17126
  if (value.outputTokensPerSecond !== void 0 && (typeof value.outputTokensPerSecond !== "number" || !Number.isFinite(value.outputTokensPerSecond) || value.outputTokensPerSecond < 0)) {
@@ -16977,16 +17129,16 @@ function parseHostUsage(value) {
16977
17129
  if (value.totalCostUsd !== void 0 && (typeof value.totalCostUsd !== "number" || !Number.isFinite(value.totalCostUsd) || value.totalCostUsd < 0)) {
16978
17130
  throw new Error("Harness Usage 'totalCostUsd' must be a finite non-negative number");
16979
17131
  }
16980
- for (const field of ["totalCredits", "contextUsagePercent"]) {
16981
- const candidate = value[field];
17132
+ for (const field2 of ["totalCredits", "contextUsagePercent"]) {
17133
+ const candidate = value[field2];
16982
17134
  if (candidate !== void 0 && (typeof candidate !== "number" || !Number.isFinite(candidate) || candidate < 0)) {
16983
- throw new Error(`Harness Usage '${field}' must be a finite non-negative number`);
17135
+ throw new Error(`Harness Usage '${field2}' must be a finite non-negative number`);
16984
17136
  }
16985
17137
  }
16986
- for (const field of percentFields) {
16987
- const candidate = value[field];
17138
+ for (const field2 of percentFields) {
17139
+ const candidate = value[field2];
16988
17140
  if (candidate !== void 0 && (typeof candidate !== "number" || !Number.isFinite(candidate) || candidate < 0 || candidate > 100)) {
16989
- throw new Error(`Harness Usage '${field}' must be between 0 and 100`);
17141
+ throw new Error(`Harness Usage '${field2}' must be between 0 and 100`);
16990
17142
  }
16991
17143
  }
16992
17144
  if (value.sessionCacheUsage !== void 0) {
@@ -17025,9 +17177,9 @@ function parseHostUsage(value) {
17025
17177
  if (value.costSource !== "publicPrice") {
17026
17178
  throw new Error("Harness Usage 'unpricedModels' must be provided with a 'publicPrice' cost");
17027
17179
  }
17028
- return { ...value, unpricedModels: [...models] };
17180
+ return { ...value, ...indicators, unpricedModels: [...models] };
17029
17181
  }
17030
- return { ...value };
17182
+ return { ...value, ...indicators };
17031
17183
  }
17032
17184
  var requestTokenFields = [
17033
17185
  "inputTokens",
@@ -17057,19 +17209,19 @@ function parseHostUsageRequest(value) {
17057
17209
  if (typeof value.requestId !== "string" || value.requestId.length === 0) {
17058
17210
  throw new Error("Harness Usage request 'requestId' must be a non-empty string");
17059
17211
  }
17060
- for (const field of ["model", "provider"]) {
17061
- const candidate = value[field];
17212
+ for (const field2 of ["model", "provider"]) {
17213
+ const candidate = value[field2];
17062
17214
  if (candidate !== void 0 && (typeof candidate !== "string" || candidate.length === 0)) {
17063
- throw new Error(`Harness Usage request '${field}' must be a non-empty string`);
17215
+ throw new Error(`Harness Usage request '${field2}' must be a non-empty string`);
17064
17216
  }
17065
17217
  }
17066
17218
  if (value.historical !== void 0 && typeof value.historical !== "boolean") {
17067
17219
  throw new Error("Harness Usage request 'historical' must be a boolean");
17068
17220
  }
17069
- for (const field of requestTokenFields) {
17070
- const candidate = value[field];
17221
+ for (const field2 of requestTokenFields) {
17222
+ const candidate = value[field2];
17071
17223
  if (candidate !== void 0 && (typeof candidate !== "number" || !Number.isSafeInteger(candidate) || candidate < 0)) {
17072
- throw new Error(`Harness Usage request '${field}' must be a non-negative safe integer`);
17224
+ throw new Error(`Harness Usage request '${field2}' must be a non-negative safe integer`);
17073
17225
  }
17074
17226
  }
17075
17227
  if (value.inputTokens === void 0 || value.outputTokens === void 0) {
@@ -17103,7 +17255,7 @@ function tokenSnapshot(value) {
17103
17255
  const total = object2(token.total);
17104
17256
  const last = object2(token.last);
17105
17257
  const result = {};
17106
- for (const field of [
17258
+ for (const field2 of [
17107
17259
  "totalTokens",
17108
17260
  "inputTokens",
17109
17261
  "cachedInputTokens",
@@ -17111,9 +17263,9 @@ function tokenSnapshot(value) {
17111
17263
  "outputTokens",
17112
17264
  "reasoningOutputTokens"
17113
17265
  ]) {
17114
- const n = integer2(total?.[field]);
17266
+ const n = integer2(total?.[field2]);
17115
17267
  if (n !== void 0)
17116
- result[field] = n;
17268
+ result[field2] = n;
17117
17269
  }
17118
17270
  const used = integer2(last?.totalTokens);
17119
17271
  const window = integer2(token.modelContextWindow);
@@ -0,0 +1,26 @@
1
+ {
2
+ "manifestVersion": 1,
3
+ "id": "copilot",
4
+ "name": "GitHub Copilot",
5
+ "version": "0.0.0",
6
+ "installation": {
7
+ "commands": [
8
+ {
9
+ "terminal": "npm · macOS / Linux / Windows",
10
+ "command": "npm install -g @github/copilot"
11
+ }
12
+ ],
13
+ "after": {
14
+ "en": "Run copilot; use /login only if authentication is unavailable. Existing native authentication on the target Host can be reused. CODEXHOST_COPILOT_COMMAND selects an existing CLI installation. Windows npm launchers resolve to that installation's actual JavaScript or executable entrypoint; arbitrary shell wrappers are not supported.",
15
+ "zh-CN": "运行 copilot;若缺少认证,再使用 /login。可复用目标 Host 已有的原生登录;CODEXHOST_COPILOT_COMMAND 可指定已有 CLI 安装。Windows npm 启动器会解析到同一安装的实际 JavaScript 或可执行入口,不支持任意 shell 包装脚本。"
16
+ }
17
+ },
18
+ "links": {
19
+ "website": "https://github.com/features/copilot",
20
+ "documentation": "https://docs.github.com/en/copilot/get-started/cli-quickstart",
21
+ "installation": "https://docs.github.com/en/copilot/how-tos/copilot-cli/set-up-copilot-cli/install-copilot-cli"
22
+ },
23
+ "adapterApiVersion": 1,
24
+ "entry": "plugin.mjs",
25
+ "icon": "./assets/icon.png"
26
+ }