@liberseek/boft-cli-linux-x64 0.8.0 → 0.8.2

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.
@@ -384,6 +384,20 @@ import path4 from "node:path";
384
384
  import { createInterface } from "node:readline";
385
385
  var MAX_SESSION_ID_LENGTH = 512;
386
386
  var MAX_CWD_LENGTH = 4096;
387
+ var MAX_SESSION_TITLE_LENGTH = 200;
388
+ function usageSessionTitle(value) {
389
+ if (typeof value !== "string")
390
+ return void 0;
391
+ const normalized = value.replaceAll("\0", "").replaceAll(/\s+/gu, " ").trim();
392
+ if (!normalized)
393
+ return void 0;
394
+ if (normalized.length <= MAX_SESSION_TITLE_LENGTH)
395
+ return normalized;
396
+ const characters = [...normalized];
397
+ if (characters.length <= MAX_SESSION_TITLE_LENGTH)
398
+ return normalized;
399
+ return `${characters.slice(0, MAX_SESSION_TITLE_LENGTH - 1).join("").trimEnd()}…`;
400
+ }
387
401
  function sessionIdOk(value) {
388
402
  return typeof value === "string" && value.length > 0 && value.length <= MAX_SESSION_ID_LENGTH;
389
403
  }
@@ -393,12 +407,14 @@ function cwdOk(value) {
393
407
  function withUsageSession(entry, session) {
394
408
  const sessionId = sessionIdOk(session.sessionId) ? session.sessionId : void 0;
395
409
  const cwd = cwdOk(session.cwd) ? session.cwd : void 0;
410
+ const sessionTitle = sessionId !== void 0 ? usageSessionTitle(session.title) : void 0;
396
411
  if (sessionId === void 0 && cwd === void 0)
397
412
  return entry;
398
413
  return {
399
414
  ...entry,
400
415
  ...sessionId !== void 0 ? { sessionId } : {},
401
- ...cwd !== void 0 ? { cwd } : {}
416
+ ...cwd !== void 0 ? { cwd } : {},
417
+ ...sessionTitle !== void 0 ? { sessionTitle } : {}
402
418
  };
403
419
  }
404
420
  async function jsonlUsageSources(root, maxDepth, signal) {
@@ -464,12 +480,18 @@ function count(value) {
464
480
  function grokHome(environment) {
465
481
  return environment.GROK_HOME || path5.join(environment.HOME || os2.homedir(), ".grok");
466
482
  }
467
- async function forkedAtMs(directory) {
483
+ async function grokSummary(directory) {
468
484
  try {
469
485
  const summary = JSON.parse(await readFile(path5.join(directory, "summary.json"), "utf8"));
470
- return isRecord(summary) && typeof summary.parent_session_id === "string" ? nativeTimeMs(summary.created_at) : null;
486
+ if (!isRecord(summary))
487
+ return { forkedAt: null };
488
+ const title = usageSessionTitle(summary.generated_title) ?? usageSessionTitle(summary.session_summary);
489
+ return {
490
+ forkedAt: typeof summary.parent_session_id === "string" ? nativeTimeMs(summary.created_at) : null,
491
+ ...title ? { title } : {}
492
+ };
471
493
  } catch {
472
- return null;
494
+ return { forkedAt: null };
473
495
  }
474
496
  }
475
497
  function grokSession(file2) {
@@ -483,12 +505,18 @@ function grokSession(file2) {
483
505
  return { sessionId: path5.basename(directory), cwd };
484
506
  }
485
507
  async function readGrokUsage(file2, signal) {
486
- const forkedAt = await forkedAtMs(path5.dirname(file2));
508
+ const summary = await grokSummary(path5.dirname(file2));
509
+ const forkedAt = summary.forkedAt;
510
+ let title = summary.title;
487
511
  const session = grokSession(file2);
488
512
  const entries = [];
489
- for await (const line of jsonlRecords(file2, '"turn_completed"', signal)) {
513
+ for await (const line of jsonlRecords(file2, '"sessionUpdate"', signal)) {
490
514
  const params = isRecord(line.params) ? line.params : {};
491
515
  const update = isRecord(params.update) ? params.update : {};
516
+ if (!title && update.sessionUpdate === "user_message_chunk") {
517
+ title = usageSessionTitle(isRecord(update.content) ? update.content.text : void 0);
518
+ continue;
519
+ }
492
520
  const usage = isRecord(update.usage) ? update.usage : {};
493
521
  if (update.sessionUpdate !== "turn_completed" || typeof update.prompt_id !== "string")
494
522
  continue;
@@ -519,7 +547,7 @@ async function readGrokUsage(file2, signal) {
519
547
  // A turn Grok marks incomplete has no cost of its own; it counts as free rather
520
548
  // than as a model without a price.
521
549
  ...ticks !== null ? { costUsd: ticks / USD_TICKS } : usage.usageIsIncomplete === true ? { costUsd: 0 } : {}
522
- }, session));
550
+ }, { ...session, ...title ? { title } : {} }));
523
551
  }
524
552
  }
525
553
  return entries;
@@ -19328,6 +19356,15 @@ var harnessDisplaySetSchema = external_exports.strictObject({
19328
19356
  initializeOnly: external_exports.boolean().optional()
19329
19357
  });
19330
19358
 
19359
+ // ../../shared-contracts/dist/harness-presentation.js
19360
+ var localeSchema = external_exports.string().max(64).regex(/^[a-z]{2,3}(?:-[A-Za-z0-9]{2,8})*$/u);
19361
+ var displayText = (maximum) => external_exports.string().min(1).max(maximum).refine((text) => text.trim().length > 0);
19362
+ var harnessLocalizationsSchema = external_exports.record(localeSchema, external_exports.object({
19363
+ label: displayText(256).optional(),
19364
+ description: displayText(1024).optional()
19365
+ }).strict()).refine((entries) => Object.keys(entries).length <= 16, "Too many locales");
19366
+ var harnessLocalizedTextSchema = external_exports.record(localeSchema, displayText(4096)).refine((entries) => typeof entries.en === "string", "English fallback is required").refine((entries) => Object.keys(entries).length <= 16, "Too many locales");
19367
+
19331
19368
  // ../../shared-contracts/dist/model-price-overrides.js
19332
19369
  var usdPerMillionTokens = external_exports.number().finite().nonnegative();
19333
19370
  var modelPriceOverrideSchema = external_exports.strictObject({
@@ -19406,6 +19443,8 @@ var usageStatisticsSessionSchema = external_exports.strictObject({
19406
19443
  harness,
19407
19444
  sessionId: external_exports.string().min(1).max(512),
19408
19445
  project: project.nullable(),
19446
+ /** Persisted Desktop title for a mapped Session, otherwise its native name; may be absent. */
19447
+ title: external_exports.string().min(1).max(200).optional(),
19409
19448
  /** Models the session used, most requests first. */
19410
19449
  models: external_exports.array(model).max(16),
19411
19450
  firstAtMs: count2,
@@ -19472,7 +19511,12 @@ var usageStatisticsResultSchema = external_exports.strictObject({
19472
19511
  * The sessions that spent the most, by cost and by tokens without cache, all filters applied;
19473
19512
  * requests without a native session are not listed here but count everywhere else.
19474
19513
  */
19475
- sessions: external_exports.array(usageStatisticsSessionSchema).max(100)
19514
+ sessions: external_exports.array(usageStatisticsSessionSchema).max(100),
19515
+ /**
19516
+ * The sessions last active in the range, newest first, all filters applied. Optional for older
19517
+ * Hosts; missing is treated as no list rather than no sessions.
19518
+ */
19519
+ recentSessions: external_exports.array(usageStatisticsSessionSchema).max(100).optional()
19476
19520
  });
19477
19521
 
19478
19522
  // ../../shared-contracts/dist/ids.js
@@ -19741,8 +19785,24 @@ var threadUsageSnapshotSchema = external_exports.object({
19741
19785
  }
19742
19786
  });
19743
19787
  var usagePercentSchema = external_exports.number().finite().min(0).max(100);
19788
+ var accountCreditsPeriodSchema = external_exports.enum([
19789
+ "weekly",
19790
+ "monthly",
19791
+ "five_hour",
19792
+ "seven_day",
19793
+ "unknown"
19794
+ ]);
19795
+ var accountCreditsScopeSchema = external_exports.object({
19796
+ id: external_exports.string().min(1).max(256),
19797
+ label: external_exports.string().min(1).max(256),
19798
+ localizations: harnessLocalizationsSchema.optional()
19799
+ }).strict();
19744
19800
  var accountCreditsProductUsageSchema = external_exports.object({
19745
19801
  product: external_exports.string().min(1),
19802
+ /** Native period and scope, never inferred from the display name. */
19803
+ periodType: accountCreditsPeriodSchema.optional(),
19804
+ scope: accountCreditsScopeSchema.optional(),
19805
+ localizations: harnessLocalizationsSchema.optional(),
19746
19806
  used: external_exports.number().finite().nonnegative().optional(),
19747
19807
  // Zero is a real empty cap, not an absent field.
19748
19808
  limit: external_exports.number().finite().nonnegative().optional(),
@@ -19764,8 +19824,10 @@ var accountCreditsSnapshotSchema = external_exports.object({
19764
19824
  label: external_exports.string().min(1).optional(),
19765
19825
  usedPercent: usagePercentSchema.optional(),
19766
19826
  remaining: external_exports.number().finite().optional(),
19827
+ scope: accountCreditsScopeSchema.optional(),
19828
+ localizations: harnessLocalizationsSchema.optional(),
19767
19829
  resetsAt: external_exports.string().min(1).optional(),
19768
- periodType: external_exports.enum(["weekly", "monthly", "five_hour", "seven_day", "unknown"]),
19830
+ periodType: accountCreditsPeriodSchema,
19769
19831
  productUsage: external_exports.array(accountCreditsProductUsageSchema).min(1).optional(),
19770
19832
  resetCredits: accountResetCreditsSchema.optional()
19771
19833
  }).strict().superRefine((credits, context) => {
@@ -19790,7 +19852,9 @@ var threadUsageInspectionParamsSchema = external_exports.object({
19790
19852
  var threadUsageInspectionSchema = external_exports.object({
19791
19853
  threadId: hostThreadIdSchema,
19792
19854
  usage: threadUsageSnapshotSchema.nullable(),
19793
- accountCredits: accountCreditsSnapshotSchema.optional()
19855
+ accountCredits: accountCreditsSnapshotSchema.optional(),
19856
+ /** Whether this source can provide cached account quota independently of usage. */
19857
+ accountCreditsSupported: external_exports.boolean().optional()
19794
19858
  }).strict();
19795
19859
 
19796
19860
  // ../../shared-contracts/dist/harness-accounts.js
@@ -19917,7 +19981,8 @@ var harnessPermissionModeSchema = external_exports.object({
19917
19981
  id: harnessPermissionModeIdSchema,
19918
19982
  label: nonBlankTextSchema.max(HARNESS_PERMISSION_MODE_LABEL_MAX_LENGTH),
19919
19983
  description: nonBlankTextSchema.max(HARNESS_PERMISSION_MODE_DESCRIPTION_MAX_LENGTH).optional(),
19920
- dangerous: external_exports.boolean().optional()
19984
+ dangerous: external_exports.boolean().optional(),
19985
+ localizations: harnessLocalizationsSchema.optional()
19921
19986
  }).strict();
19922
19987
  var harnessPermissionModeCatalogSchema = external_exports.object({
19923
19988
  modes: external_exports.array(harnessPermissionModeSchema).min(1).max(HARNESS_PERMISSION_MODE_CATALOG_MAX_LENGTH),
@@ -20240,6 +20305,8 @@ var harnessInstallationStateSchema = external_exports.object({
20240
20305
  // Adapter-owned diagnostic text; UI uses messageCode rather than displaying it verbatim.
20241
20306
  message: external_exports.string().max(2048).optional(),
20242
20307
  messageCode: external_exports.string().min(1).max(128).optional(),
20308
+ /** Safe plugin-owned explanation, distinct from raw diagnostic message. */
20309
+ notice: harnessLocalizedTextSchema.optional(),
20243
20310
  latestVersionKind: external_exports.enum(["unknown", "tracking-branch"]).optional()
20244
20311
  }).strict();
20245
20312
 
@@ -20378,6 +20445,7 @@ var harnessCommandDescriptorSchema = external_exports.object({
20378
20445
  invocation: commandInvocationSchema,
20379
20446
  label: commandLabelSchema,
20380
20447
  description: commandDescriptionSchema.optional(),
20448
+ localizations: harnessLocalizationsSchema.optional(),
20381
20449
  argumentMode: external_exports.enum(["none", "text"]),
20382
20450
  /**
20383
20451
  * Native distinction reported by the Harness. Omitted when the Harness does
@@ -23502,16 +23570,23 @@ var GROK_PERMISSION_MODE_CATALOG = harnessPermissionModeCatalogSchema.parse({
23502
23570
  {
23503
23571
  id: "ask",
23504
23572
  label: "Ask",
23573
+ localizations: { "zh-CN": { label: "询问", description: "执行受保护的工具操作前询问。" } },
23505
23574
  description: "Ask before protected tool actions."
23506
23575
  },
23507
23576
  {
23508
23577
  id: "auto",
23509
23578
  label: "Auto",
23579
+ localizations: {
23580
+ "zh-CN": { label: "自动", description: "由 Grok Build 决定哪些工具操作可自动运行。" }
23581
+ },
23510
23582
  description: "Let Grok Build decide which tool actions may run automatically."
23511
23583
  },
23512
23584
  {
23513
23585
  id: "always-approve",
23514
23586
  label: "Always approve",
23587
+ localizations: {
23588
+ "zh-CN": { label: "始终批准", description: "无需提示即可批准所有工具操作。" }
23589
+ },
23515
23590
  description: "Approve all tool actions without prompting.",
23516
23591
  dangerous: true
23517
23592
  }
@@ -24856,7 +24931,20 @@ function productUsageFrom(value) {
24856
24931
  if (!isRecord17(entry) || typeof entry.product !== "string")
24857
24932
  return [];
24858
24933
  const usagePercent = finitePercent(entry.usagePercent);
24859
- return usagePercent === void 0 ? [] : [{ product: entry.product, usagePercent }];
24934
+ const labels = {
24935
+ GrokBuild: "Build",
24936
+ GrokChat: "Chat",
24937
+ GrokImagine: "Imagine",
24938
+ GrokVoice: "Voice"
24939
+ };
24940
+ const label = Object.hasOwn(labels, entry.product) ? labels[entry.product] : void 0;
24941
+ return usagePercent === void 0 ? [] : [
24942
+ {
24943
+ product: entry.product,
24944
+ ...label ? { localizations: { en: { label }, "zh-CN": { label } } } : {},
24945
+ usagePercent
24946
+ }
24947
+ ];
24860
24948
  });
24861
24949
  return products.length > 0 ? products : void 0;
24862
24950
  }
@@ -25253,6 +25341,7 @@ var grokCommandCatalog = harnessCommandCatalogSchema.parse({
25253
25341
  {
25254
25342
  id: "grok.compact",
25255
25343
  invocation: "/compact",
25344
+ localizations: { "zh-CN": { label: "压缩上下文", description: "压缩当前对话上下文" } },
25256
25345
  label: "Compact context",
25257
25346
  description: "Compact the current conversation context",
25258
25347
  argumentMode: "text"
@@ -26442,10 +26531,15 @@ var GrokAdapter = class {
26442
26531
  async inspectAccount() {
26443
26532
  if (this.#closePromise)
26444
26533
  return null;
26445
- return (this.#dependencies.fetchAccount ?? fetchGrokAccount)({
26534
+ const account = await (this.#dependencies.fetchAccount ?? fetchGrokAccount)({
26446
26535
  ...this.#environment ? { environment: this.#environment } : {},
26447
26536
  signal: this.#accountAbort.signal
26448
26537
  });
26538
+ if (!account?.credits)
26539
+ return account;
26540
+ const credits = { ...account.credits };
26541
+ delete credits.productUsage;
26542
+ return { ...account, credits };
26449
26543
  }
26450
26544
  credits() {
26451
26545
  return this.#credits;