@codexhost/cli-darwin-x64 0.13.0 → 0.13.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.
@@ -14682,6 +14682,8 @@ var usageStatisticsSessionSchema = external_exports.strictObject({
14682
14682
  harness,
14683
14683
  sessionId: external_exports.string().min(1).max(512),
14684
14684
  project: project.nullable(),
14685
+ /** Persisted Desktop title for a mapped Session, otherwise its native name; may be absent. */
14686
+ title: external_exports.string().min(1).max(200).optional(),
14685
14687
  /** Models the session used, most requests first. */
14686
14688
  models: external_exports.array(model).max(16),
14687
14689
  firstAtMs: count,
@@ -14748,7 +14750,12 @@ var usageStatisticsResultSchema = external_exports.strictObject({
14748
14750
  * The sessions that spent the most, by cost and by tokens without cache, all filters applied;
14749
14751
  * requests without a native session are not listed here but count everywhere else.
14750
14752
  */
14751
- sessions: external_exports.array(usageStatisticsSessionSchema).max(100)
14753
+ sessions: external_exports.array(usageStatisticsSessionSchema).max(100),
14754
+ /**
14755
+ * The sessions last active in the range, newest first, all filters applied. Optional for older
14756
+ * Hosts; missing is treated as no list rather than no sessions.
14757
+ */
14758
+ recentSessions: external_exports.array(usageStatisticsSessionSchema).max(100).optional()
14752
14759
  });
14753
14760
 
14754
14761
  // ../../shared-contracts/dist/ids.js
@@ -17339,6 +17346,20 @@ import path2 from "node:path";
17339
17346
  import { createInterface } from "node:readline";
17340
17347
  var MAX_SESSION_ID_LENGTH = 512;
17341
17348
  var MAX_CWD_LENGTH = 4096;
17349
+ var MAX_SESSION_TITLE_LENGTH = 200;
17350
+ function usageSessionTitle(value) {
17351
+ if (typeof value !== "string")
17352
+ return void 0;
17353
+ const normalized = value.replaceAll("\0", "").replaceAll(/\s+/gu, " ").trim();
17354
+ if (!normalized)
17355
+ return void 0;
17356
+ if (normalized.length <= MAX_SESSION_TITLE_LENGTH)
17357
+ return normalized;
17358
+ const characters = [...normalized];
17359
+ if (characters.length <= MAX_SESSION_TITLE_LENGTH)
17360
+ return normalized;
17361
+ return `${characters.slice(0, MAX_SESSION_TITLE_LENGTH - 1).join("").trimEnd()}…`;
17362
+ }
17342
17363
  function sessionIdOk(value) {
17343
17364
  return typeof value === "string" && value.length > 0 && value.length <= MAX_SESSION_ID_LENGTH;
17344
17365
  }
@@ -17348,12 +17369,14 @@ function cwdOk(value) {
17348
17369
  function withUsageSession(entry, session) {
17349
17370
  const sessionId = sessionIdOk(session.sessionId) ? session.sessionId : void 0;
17350
17371
  const cwd = cwdOk(session.cwd) ? session.cwd : void 0;
17372
+ const sessionTitle = sessionId !== void 0 ? usageSessionTitle(session.title) : void 0;
17351
17373
  if (sessionId === void 0 && cwd === void 0)
17352
17374
  return entry;
17353
17375
  return {
17354
17376
  ...entry,
17355
17377
  ...sessionId !== void 0 ? { sessionId } : {},
17356
- ...cwd !== void 0 ? { cwd } : {}
17378
+ ...cwd !== void 0 ? { cwd } : {},
17379
+ ...sessionTitle !== void 0 ? { sessionTitle } : {}
17357
17380
  };
17358
17381
  }
17359
17382
  function usageEntryFromRequest(request, occurredAtMs) {
@@ -18852,11 +18875,30 @@ function historyUsage(contents) {
18852
18875
  function record3(value) {
18853
18876
  return typeof value === "object" && value !== null && !Array.isArray(value) ? value : {};
18854
18877
  }
18878
+ function codeBuddyUserText(row) {
18879
+ if (row.type !== "message" || row.role !== "user")
18880
+ return void 0;
18881
+ const { content } = row;
18882
+ if (typeof content === "string")
18883
+ return content;
18884
+ if (!Array.isArray(content))
18885
+ return void 0;
18886
+ return content.map((part) => record3(part)).filter((part) => typeof part.text === "string").map((part) => String(part.text)).join(" ");
18887
+ }
18855
18888
  async function readCodeBuddyUsage(file2, signal) {
18856
18889
  const messages = /* @__PURE__ */ new Map();
18857
18890
  let sessionId;
18858
18891
  let cwd;
18859
- for await (const row of jsonlRecords(file2, '"rawUsage"', signal)) {
18892
+ let customTitle;
18893
+ let generatedTitle;
18894
+ let firstPrompt;
18895
+ for await (const row of jsonlRecords(file2, '"type"', signal)) {
18896
+ if (row.type === "custom-title")
18897
+ customTitle = usageSessionTitle(row.customTitle);
18898
+ else if (row.type === "ai-title")
18899
+ generatedTitle = usageSessionTitle(row.aiTitle);
18900
+ else if (!firstPrompt)
18901
+ firstPrompt = usageSessionTitle(codeBuddyUserText(row));
18860
18902
  if (typeof row.type !== "string" || !NATIVE_MESSAGE_TYPES.has(row.type))
18861
18903
  continue;
18862
18904
  sessionId ??= row.sessionId;
@@ -18878,7 +18920,8 @@ async function readCodeBuddyUsage(file2, signal) {
18878
18920
  }
18879
18921
  entries.push(withUsageSession(entry, {
18880
18922
  sessionId: typeof sessionId === "string" ? sessionId : void 0,
18881
- cwd: typeof cwd === "string" ? cwd : void 0
18923
+ cwd: typeof cwd === "string" ? cwd : void 0,
18924
+ title: customTitle ?? generatedTitle ?? firstPrompt
18882
18925
  }));
18883
18926
  }
18884
18927
  }
@@ -13,6 +13,20 @@ import { lstat } from "node:fs/promises";
13
13
  // ../../harness-adapter/dist/usage-statistics.js
14
14
  var MAX_SESSION_ID_LENGTH = 512;
15
15
  var MAX_CWD_LENGTH = 4096;
16
+ var MAX_SESSION_TITLE_LENGTH = 200;
17
+ function usageSessionTitle(value) {
18
+ if (typeof value !== "string")
19
+ return void 0;
20
+ const normalized = value.replaceAll("\0", "").replaceAll(/\s+/gu, " ").trim();
21
+ if (!normalized)
22
+ return void 0;
23
+ if (normalized.length <= MAX_SESSION_TITLE_LENGTH)
24
+ return normalized;
25
+ const characters = [...normalized];
26
+ if (characters.length <= MAX_SESSION_TITLE_LENGTH)
27
+ return normalized;
28
+ return `${characters.slice(0, MAX_SESSION_TITLE_LENGTH - 1).join("").trimEnd()}…`;
29
+ }
16
30
  function sessionIdOk(value) {
17
31
  return typeof value === "string" && value.length > 0 && value.length <= MAX_SESSION_ID_LENGTH;
18
32
  }
@@ -22,12 +36,14 @@ function cwdOk(value) {
22
36
  function withUsageSession(entry, session) {
23
37
  const sessionId = sessionIdOk(session.sessionId) ? session.sessionId : void 0;
24
38
  const cwd = cwdOk(session.cwd) ? session.cwd : void 0;
39
+ const sessionTitle = sessionId !== void 0 ? usageSessionTitle(session.title) : void 0;
25
40
  if (sessionId === void 0 && cwd === void 0)
26
41
  return entry;
27
42
  return {
28
43
  ...entry,
29
44
  ...sessionId !== void 0 ? { sessionId } : {},
30
- ...cwd !== void 0 ? { cwd } : {}
45
+ ...cwd !== void 0 ? { cwd } : {},
46
+ ...sessionTitle !== void 0 ? { sessionTitle } : {}
31
47
  };
32
48
  }
33
49
  function usageEntryFromRequest(request, occurredAtMs) {
@@ -14849,6 +14865,8 @@ var usageStatisticsSessionSchema = external_exports.strictObject({
14849
14865
  harness,
14850
14866
  sessionId: external_exports.string().min(1).max(512),
14851
14867
  project: project.nullable(),
14868
+ /** Persisted Desktop title for a mapped Session, otherwise its native name; may be absent. */
14869
+ title: external_exports.string().min(1).max(200).optional(),
14852
14870
  /** Models the session used, most requests first. */
14853
14871
  models: external_exports.array(model).max(16),
14854
14872
  firstAtMs: count,
@@ -14915,7 +14933,12 @@ var usageStatisticsResultSchema = external_exports.strictObject({
14915
14933
  * The sessions that spent the most, by cost and by tokens without cache, all filters applied;
14916
14934
  * requests without a native session are not listed here but count everywhere else.
14917
14935
  */
14918
- sessions: external_exports.array(usageStatisticsSessionSchema).max(100)
14936
+ sessions: external_exports.array(usageStatisticsSessionSchema).max(100),
14937
+ /**
14938
+ * The sessions last active in the range, newest first, all filters applied. Optional for older
14939
+ * Hosts; missing is treated as no list rather than no sessions.
14940
+ */
14941
+ recentSessions: external_exports.array(usageStatisticsSessionSchema).max(100).optional()
14919
14942
  });
14920
14943
 
14921
14944
  // ../../shared-contracts/dist/ids.js
@@ -16486,11 +16509,17 @@ async function readZcodeUsage(file2) {
16486
16509
  try {
16487
16510
  const entries = [];
16488
16511
  const directories = /* @__PURE__ */ new Map();
16512
+ const titles = /* @__PURE__ */ new Map();
16489
16513
  const hasSessions = database.prepare("SELECT 1 FROM sqlite_master WHERE type = 'table' AND name = 'session'").get();
16490
16514
  if (hasSessions) {
16491
- for (const row of database.prepare("SELECT id, directory FROM session").iterate()) {
16515
+ const columns = new Set(database.prepare("PRAGMA table_info(session)").all().map((row) => String(row.name)));
16516
+ const titleColumn = columns.has("title") ? ", title" : "";
16517
+ for (const row of database.prepare(`SELECT id, directory${titleColumn} FROM session`).iterate()) {
16492
16518
  if (typeof row.directory === "string")
16493
16519
  directories.set(String(row.id), row.directory);
16520
+ const title = usageSessionTitle(row.title);
16521
+ if (title)
16522
+ titles.set(String(row.id), title);
16494
16523
  }
16495
16524
  }
16496
16525
  for (const row of database.prepare("SELECT id, session_id, data FROM message").iterate()) {
@@ -16520,7 +16549,11 @@ async function readZcodeUsage(file2) {
16520
16549
  const entry = usage.kind === "request" && at !== null && usageEntryFromRequest(usage.request, at);
16521
16550
  if (entry) {
16522
16551
  const sessionId = String(row.session_id);
16523
- entries.push(withUsageSession(entry, { sessionId, cwd: directories.get(sessionId) }));
16552
+ entries.push(withUsageSession(entry, {
16553
+ sessionId,
16554
+ cwd: directories.get(sessionId),
16555
+ title: titles.get(sessionId)
16556
+ }));
16524
16557
  }
16525
16558
  }
16526
16559
  return entries;