@liberseek/boft-cli-linux-x64 0.8.0 → 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.
@@ -415,6 +415,20 @@ import path4 from "node:path";
415
415
  import { createInterface } from "node:readline";
416
416
  var MAX_SESSION_ID_LENGTH = 512;
417
417
  var MAX_CWD_LENGTH = 4096;
418
+ var MAX_SESSION_TITLE_LENGTH = 200;
419
+ function usageSessionTitle(value) {
420
+ if (typeof value !== "string")
421
+ return void 0;
422
+ const normalized = value.replaceAll("\0", "").replaceAll(/\s+/gu, " ").trim();
423
+ if (!normalized)
424
+ return void 0;
425
+ if (normalized.length <= MAX_SESSION_TITLE_LENGTH)
426
+ return normalized;
427
+ const characters = [...normalized];
428
+ if (characters.length <= MAX_SESSION_TITLE_LENGTH)
429
+ return normalized;
430
+ return `${characters.slice(0, MAX_SESSION_TITLE_LENGTH - 1).join("").trimEnd()}…`;
431
+ }
418
432
  function sessionIdOk(value) {
419
433
  return typeof value === "string" && value.length > 0 && value.length <= MAX_SESSION_ID_LENGTH;
420
434
  }
@@ -424,12 +438,14 @@ function cwdOk(value) {
424
438
  function withUsageSession(entry, session) {
425
439
  const sessionId = sessionIdOk(session.sessionId) ? session.sessionId : void 0;
426
440
  const cwd = cwdOk(session.cwd) ? session.cwd : void 0;
441
+ const sessionTitle = sessionId !== void 0 ? usageSessionTitle(session.title) : void 0;
427
442
  if (sessionId === void 0 && cwd === void 0)
428
443
  return entry;
429
444
  return {
430
445
  ...entry,
431
446
  ...sessionId !== void 0 ? { sessionId } : {},
432
- ...cwd !== void 0 ? { cwd } : {}
447
+ ...cwd !== void 0 ? { cwd } : {},
448
+ ...sessionTitle !== void 0 ? { sessionTitle } : {}
433
449
  };
434
450
  }
435
451
  function usageEntryFromRequest(request, occurredAtMs) {
@@ -15206,6 +15222,8 @@ var usageStatisticsSessionSchema = external_exports.strictObject({
15206
15222
  harness,
15207
15223
  sessionId: external_exports.string().min(1).max(512),
15208
15224
  project: project.nullable(),
15225
+ /** Persisted Desktop title for a mapped Session, otherwise its native name; may be absent. */
15226
+ title: external_exports.string().min(1).max(200).optional(),
15209
15227
  /** Models the session used, most requests first. */
15210
15228
  models: external_exports.array(model).max(16),
15211
15229
  firstAtMs: count,
@@ -15272,7 +15290,12 @@ var usageStatisticsResultSchema = external_exports.strictObject({
15272
15290
  * The sessions that spent the most, by cost and by tokens without cache, all filters applied;
15273
15291
  * requests without a native session are not listed here but count everywhere else.
15274
15292
  */
15275
- sessions: external_exports.array(usageStatisticsSessionSchema).max(100)
15293
+ sessions: external_exports.array(usageStatisticsSessionSchema).max(100),
15294
+ /**
15295
+ * The sessions last active in the range, newest first, all filters applied. Optional for older
15296
+ * Hosts; missing is treated as no list rather than no sessions.
15297
+ */
15298
+ recentSessions: external_exports.array(usageStatisticsSessionSchema).max(100).optional()
15276
15299
  });
15277
15300
 
15278
15301
  // ../../shared-contracts/dist/ids.js
@@ -17674,9 +17697,11 @@ function ompUsageHistory(history) {
17674
17697
  async function readOmpUsage(file2, signal) {
17675
17698
  const entries = [];
17676
17699
  const header = await jsonlHeader(file2, (record2) => record2.type === "session", signal);
17700
+ const titled = await jsonlHeader(file2, (record2) => record2.type === "title", signal);
17677
17701
  const session = {
17678
17702
  sessionId: typeof header?.id === "string" ? header.id : void 0,
17679
- cwd: typeof header?.cwd === "string" ? header.cwd : void 0
17703
+ cwd: typeof header?.cwd === "string" ? header.cwd : void 0,
17704
+ title: usageSessionTitle(titled?.title)
17680
17705
  };
17681
17706
  for await (const line of jsonlRecords(file2, '"assistant"', signal)) {
17682
17707
  if (line.type !== "message")
@@ -21362,11 +21387,10 @@ var OmpHarnessSession = class {
21362
21387
  state = await transport.selectThinkingOption(this.#requestedThinkingOptionId);
21363
21388
  thinkingLevels = await transport.getAvailableThinkingLevels();
21364
21389
  }
21365
- } else {
21366
- const reconciled = await reconcileThinkingLevel(transport, state, thinkingLevels);
21367
- state = reconciled.state;
21368
- thinkingLevels = reconciled.thinkingLevels;
21369
21390
  }
21391
+ const reconciled = await reconcileThinkingLevel(transport, state, thinkingLevels);
21392
+ state = reconciled.state;
21393
+ thinkingLevels = reconciled.thinkingLevels;
21370
21394
  this.#transport = transport;
21371
21395
  this.#publishTransportState(state, thinkingLevels);
21372
21396
  return transport;
@@ -495,6 +495,20 @@ import { lstat } from "node:fs/promises";
495
495
  // ../../harness-adapter/dist/usage-statistics.js
496
496
  var MAX_SESSION_ID_LENGTH = 512;
497
497
  var MAX_CWD_LENGTH = 4096;
498
+ var MAX_SESSION_TITLE_LENGTH = 200;
499
+ function usageSessionTitle(value) {
500
+ if (typeof value !== "string")
501
+ return void 0;
502
+ const normalized = value.replaceAll("\0", "").replaceAll(/\s+/gu, " ").trim();
503
+ if (!normalized)
504
+ return void 0;
505
+ if (normalized.length <= MAX_SESSION_TITLE_LENGTH)
506
+ return normalized;
507
+ const characters = [...normalized];
508
+ if (characters.length <= MAX_SESSION_TITLE_LENGTH)
509
+ return normalized;
510
+ return `${characters.slice(0, MAX_SESSION_TITLE_LENGTH - 1).join("").trimEnd()}…`;
511
+ }
498
512
  function sessionIdOk(value) {
499
513
  return typeof value === "string" && value.length > 0 && value.length <= MAX_SESSION_ID_LENGTH;
500
514
  }
@@ -504,12 +518,14 @@ function cwdOk(value) {
504
518
  function withUsageSession(entry, session) {
505
519
  const sessionId = sessionIdOk(session.sessionId) ? session.sessionId : void 0;
506
520
  const cwd = cwdOk(session.cwd) ? session.cwd : void 0;
521
+ const sessionTitle = sessionId !== void 0 ? usageSessionTitle(session.title) : void 0;
507
522
  if (sessionId === void 0 && cwd === void 0)
508
523
  return entry;
509
524
  return {
510
525
  ...entry,
511
526
  ...sessionId !== void 0 ? { sessionId } : {},
512
- ...cwd !== void 0 ? { cwd } : {}
527
+ ...cwd !== void 0 ? { cwd } : {},
528
+ ...sessionTitle !== void 0 ? { sessionTitle } : {}
513
529
  };
514
530
  }
515
531
  function usageEntryFromRequest(request, occurredAtMs) {
@@ -15203,6 +15219,8 @@ var usageStatisticsSessionSchema = external_exports.strictObject({
15203
15219
  harness,
15204
15220
  sessionId: external_exports.string().min(1).max(512),
15205
15221
  project: project.nullable(),
15222
+ /** Persisted Desktop title for a mapped Session, otherwise its native name; may be absent. */
15223
+ title: external_exports.string().min(1).max(200).optional(),
15206
15224
  /** Models the session used, most requests first. */
15207
15225
  models: external_exports.array(model).max(16),
15208
15226
  firstAtMs: count,
@@ -15269,7 +15287,12 @@ var usageStatisticsResultSchema = external_exports.strictObject({
15269
15287
  * The sessions that spent the most, by cost and by tokens without cache, all filters applied;
15270
15288
  * requests without a native session are not listed here but count everywhere else.
15271
15289
  */
15272
- sessions: external_exports.array(usageStatisticsSessionSchema).max(100)
15290
+ sessions: external_exports.array(usageStatisticsSessionSchema).max(100),
15291
+ /**
15292
+ * The sessions last active in the range, newest first, all filters applied. Optional for older
15293
+ * Hosts; missing is treated as no list rather than no sessions.
15294
+ */
15295
+ recentSessions: external_exports.array(usageStatisticsSessionSchema).max(100).optional()
15273
15296
  });
15274
15297
 
15275
15298
  // ../../shared-contracts/dist/ids.js
@@ -16785,12 +16808,18 @@ async function readOpenCodeUsage(file2) {
16785
16808
  try {
16786
16809
  const tables = new Set(database.prepare("SELECT name FROM sqlite_master WHERE type = 'table'").all().map((row) => String(row.name)));
16787
16810
  const directories = /* @__PURE__ */ new Map();
16811
+ const titles = /* @__PURE__ */ new Map();
16788
16812
  for (const table of ["session", "session_v2"]) {
16789
16813
  if (!tables.has(table))
16790
16814
  continue;
16791
- for (const row of database.prepare(`SELECT id, directory FROM ${table}`).iterate()) {
16815
+ const columns = new Set(database.prepare(`PRAGMA table_info(${table})`).all().map((row) => String(row.name)));
16816
+ const titleColumn = columns.has("title") ? ", title" : "";
16817
+ for (const row of database.prepare(`SELECT id, directory${titleColumn} FROM ${table}`).iterate()) {
16792
16818
  if (typeof row.directory === "string")
16793
16819
  directories.set(String(row.id), row.directory);
16820
+ const title = usageSessionTitle(row.title);
16821
+ if (title)
16822
+ titles.set(String(row.id), title);
16794
16823
  }
16795
16824
  }
16796
16825
  const entries = /* @__PURE__ */ new Map();
@@ -16807,7 +16836,8 @@ async function readOpenCodeUsage(file2) {
16807
16836
  const sessionId = typeof session === "string" ? session : void 0;
16808
16837
  entries.set(entry.id, withUsageSession(entry, {
16809
16838
  sessionId,
16810
- cwd: sessionId === void 0 ? void 0 : directories.get(sessionId)
16839
+ cwd: sessionId === void 0 ? void 0 : directories.get(sessionId),
16840
+ title: sessionId === void 0 ? void 0 : titles.get(sessionId)
16811
16841
  }));
16812
16842
  }
16813
16843
  };
@@ -415,6 +415,20 @@ import path4 from "node:path";
415
415
  import { createInterface } from "node:readline";
416
416
  var MAX_SESSION_ID_LENGTH = 512;
417
417
  var MAX_CWD_LENGTH = 4096;
418
+ var MAX_SESSION_TITLE_LENGTH = 200;
419
+ function usageSessionTitle(value) {
420
+ if (typeof value !== "string")
421
+ return void 0;
422
+ const normalized = value.replaceAll("\0", "").replaceAll(/\s+/gu, " ").trim();
423
+ if (!normalized)
424
+ return void 0;
425
+ if (normalized.length <= MAX_SESSION_TITLE_LENGTH)
426
+ return normalized;
427
+ const characters = [...normalized];
428
+ if (characters.length <= MAX_SESSION_TITLE_LENGTH)
429
+ return normalized;
430
+ return `${characters.slice(0, MAX_SESSION_TITLE_LENGTH - 1).join("").trimEnd()}…`;
431
+ }
418
432
  function sessionIdOk(value) {
419
433
  return typeof value === "string" && value.length > 0 && value.length <= MAX_SESSION_ID_LENGTH;
420
434
  }
@@ -424,12 +438,14 @@ function cwdOk(value) {
424
438
  function withUsageSession(entry, session) {
425
439
  const sessionId = sessionIdOk(session.sessionId) ? session.sessionId : void 0;
426
440
  const cwd = cwdOk(session.cwd) ? session.cwd : void 0;
441
+ const sessionTitle = sessionId !== void 0 ? usageSessionTitle(session.title) : void 0;
427
442
  if (sessionId === void 0 && cwd === void 0)
428
443
  return entry;
429
444
  return {
430
445
  ...entry,
431
446
  ...sessionId !== void 0 ? { sessionId } : {},
432
- ...cwd !== void 0 ? { cwd } : {}
447
+ ...cwd !== void 0 ? { cwd } : {},
448
+ ...sessionTitle !== void 0 ? { sessionTitle } : {}
433
449
  };
434
450
  }
435
451
  function usageEntryFromRequest(request, occurredAtMs) {
@@ -15203,6 +15219,8 @@ var usageStatisticsSessionSchema = external_exports.strictObject({
15203
15219
  harness,
15204
15220
  sessionId: external_exports.string().min(1).max(512),
15205
15221
  project: project.nullable(),
15222
+ /** Persisted Desktop title for a mapped Session, otherwise its native name; may be absent. */
15223
+ title: external_exports.string().min(1).max(200).optional(),
15206
15224
  /** Models the session used, most requests first. */
15207
15225
  models: external_exports.array(model).max(16),
15208
15226
  firstAtMs: count,
@@ -15269,7 +15287,12 @@ var usageStatisticsResultSchema = external_exports.strictObject({
15269
15287
  * The sessions that spent the most, by cost and by tokens without cache, all filters applied;
15270
15288
  * requests without a native session are not listed here but count everywhere else.
15271
15289
  */
15272
- sessions: external_exports.array(usageStatisticsSessionSchema).max(100)
15290
+ sessions: external_exports.array(usageStatisticsSessionSchema).max(100),
15291
+ /**
15292
+ * The sessions last active in the range, newest first, all filters applied. Optional for older
15293
+ * Hosts; missing is treated as no list rather than no sessions.
15294
+ */
15295
+ recentSessions: external_exports.array(usageStatisticsSessionSchema).max(100).optional()
15273
15296
  });
15274
15297
 
15275
15298
  // ../../shared-contracts/dist/ids.js
@@ -18042,20 +18065,38 @@ function piUsageHistory(history) {
18042
18065
  }
18043
18066
 
18044
18067
  // dist/pi-usage-statistics.js
18068
+ function isRecord5(value) {
18069
+ return typeof value === "object" && value !== null && !Array.isArray(value);
18070
+ }
18071
+ function piUserText(content) {
18072
+ if (typeof content === "string")
18073
+ return content;
18074
+ if (!Array.isArray(content))
18075
+ return void 0;
18076
+ return content.filter((block) => isRecord5(block) && block.type === "text" && typeof block.text === "string").map((block) => String(block.text)).join(" ");
18077
+ }
18045
18078
  async function readPiUsage(file2, signal) {
18046
18079
  const entries = [];
18047
18080
  const header = await jsonlHeader(file2, (record7) => record7.type === "session", signal);
18081
+ let name;
18048
18082
  const session = {
18049
18083
  sessionId: typeof header?.id === "string" ? header.id : void 0,
18050
18084
  cwd: typeof header?.cwd === "string" ? header.cwd : void 0
18051
18085
  };
18052
- for await (const line of jsonlRecords(file2, '"assistant"', signal)) {
18086
+ for await (const line of jsonlRecords(file2, '"type"', signal)) {
18087
+ if (line.type === "session_info") {
18088
+ name = usageSessionTitle(line.name) ?? name;
18089
+ continue;
18090
+ }
18053
18091
  if (line.type !== "message")
18054
18092
  continue;
18093
+ const message3 = line.message;
18094
+ if (!name && message3?.role === "user") {
18095
+ name = usageSessionTitle(piUserText(message3.content));
18096
+ }
18055
18097
  const record7 = piUsageRecord(line.message);
18056
18098
  if (record7?.kind !== "request")
18057
18099
  continue;
18058
- const message3 = line.message;
18059
18100
  const at = nativeTimeMs(message3.timestamp) ?? nativeTimeMs(line.timestamp);
18060
18101
  const entry = at !== null && usageEntryFromRequest(record7.request, at);
18061
18102
  if (!entry)
@@ -18067,7 +18108,7 @@ async function readPiUsage(file2, signal) {
18067
18108
  }
18068
18109
  entries.push(withUsageSession(entry, session));
18069
18110
  }
18070
- return entries;
18111
+ return name ? entries.map((entry) => withUsageSession(entry, { ...session, title: name })) : entries;
18071
18112
  }
18072
18113
  function createPiUsageStatistics(environment) {
18073
18114
  return Object.freeze({
@@ -18698,7 +18739,7 @@ import path10 from "node:path";
18698
18739
  import { open, realpath as realpath3 } from "node:fs/promises";
18699
18740
  var MAX_SESSION_HEADER_BYTES = 64 * 1024;
18700
18741
  var utf8Decoder = new TextDecoder("utf-8", { fatal: true });
18701
- function isRecord5(value) {
18742
+ function isRecord6(value) {
18702
18743
  return typeof value === "object" && value !== null && !Array.isArray(value);
18703
18744
  }
18704
18745
  async function readPiSessionHeader(sessionFile) {
@@ -18718,7 +18759,7 @@ async function readPiSessionHeader(sessionFile) {
18718
18759
  } catch {
18719
18760
  throw new Error("Pi Session header is not valid JSON");
18720
18761
  }
18721
- if (!isRecord5(parsed) || parsed.type !== "session" || typeof parsed.id !== "string" || parsed.id.length === 0 || typeof parsed.cwd !== "string" || parsed.cwd.length === 0) {
18762
+ if (!isRecord6(parsed) || parsed.type !== "session" || typeof parsed.id !== "string" || parsed.id.length === 0 || typeof parsed.cwd !== "string" || parsed.cwd.length === 0) {
18722
18763
  throw new Error("Pi Session header is invalid");
18723
18764
  }
18724
18765
  return {
@@ -19767,7 +19808,7 @@ var PiRpcUnsupportedCommandError = class extends Error {
19767
19808
  }
19768
19809
  };
19769
19810
  var textDecoder = new TextDecoder("utf-8", { fatal: true });
19770
- function isRecord6(value) {
19811
+ function isRecord7(value) {
19771
19812
  return typeof value === "object" && value !== null && !Array.isArray(value);
19772
19813
  }
19773
19814
  function message2(value) {
@@ -19779,13 +19820,13 @@ function nonBlankString(value) {
19779
19820
  function parseNativeModel(value, context) {
19780
19821
  if (value === null || value === void 0)
19781
19822
  return null;
19782
- if (!isRecord6(value) || !nonBlankString(value.provider) || !nonBlankString(value.id)) {
19823
+ if (!isRecord7(value) || !nonBlankString(value.provider) || !nonBlankString(value.id)) {
19783
19824
  throw new PiRpcFaultError("protocolError", `Pi RPC returned an invalid ${context} Model`);
19784
19825
  }
19785
19826
  return { provider: value.provider, id: value.id };
19786
19827
  }
19787
19828
  function sessionStateData(response) {
19788
- const data = isRecord6(response.data) ? response.data : null;
19829
+ const data = isRecord7(response.data) ? response.data : null;
19789
19830
  if (!data)
19790
19831
  throw new PiRpcFaultError("protocolError", "Pi RPC state response has no data");
19791
19832
  return data;
@@ -19817,13 +19858,13 @@ function parseSessionStreaming(response) {
19817
19858
  return isStreaming;
19818
19859
  }
19819
19860
  function parseSessionHistory(response) {
19820
- const data = isRecord6(response.data) ? response.data : null;
19861
+ const data = isRecord7(response.data) ? response.data : null;
19821
19862
  if (!data || !Array.isArray(data.entries)) {
19822
19863
  throw new PiRpcFaultError("protocolError", "Pi RPC entries response has no Entries");
19823
19864
  }
19824
19865
  const entries = data.entries.map((entry) => {
19825
19866
  const parsed = jsonValueSchema.safeParse(entry);
19826
- if (!parsed.success || !isRecord6(parsed.data)) {
19867
+ if (!parsed.success || !isRecord7(parsed.data)) {
19827
19868
  throw new PiRpcFaultError("protocolError", "Pi RPC entries response contains an invalid Entry");
19828
19869
  }
19829
19870
  return parsed.data;
@@ -19834,7 +19875,7 @@ function parseSessionHistory(response) {
19834
19875
  return { entries, leafId: data.leafId };
19835
19876
  }
19836
19877
  function parseAvailableThinkingLevels(response) {
19837
- const data = isRecord6(response.data) ? response.data : null;
19878
+ const data = isRecord7(response.data) ? response.data : null;
19838
19879
  if (!data || !Array.isArray(data.levels) || data.levels.length === 0) {
19839
19880
  throw new PiRpcFaultError("protocolError", "Pi RPC Thinking catalog response has no levels");
19840
19881
  }
@@ -19851,13 +19892,13 @@ function parseAvailableThinkingLevels(response) {
19851
19892
  return levels;
19852
19893
  }
19853
19894
  function parseAvailableModels(response) {
19854
- const data = isRecord6(response.data) ? response.data : null;
19895
+ const data = isRecord7(response.data) ? response.data : null;
19855
19896
  if (!data || !Array.isArray(data.models)) {
19856
19897
  throw new PiRpcFaultError("protocolError", "Pi RPC Model catalog response has no models");
19857
19898
  }
19858
19899
  return data.models.map((model2) => {
19859
19900
  const parsed = parseNativeModel(model2, "catalog");
19860
- if (!parsed || !isRecord6(model2) || typeof model2.reasoning !== "boolean") {
19901
+ if (!parsed || !isRecord7(model2) || typeof model2.reasoning !== "boolean") {
19861
19902
  throw new PiRpcFaultError("protocolError", "Pi RPC catalog contains a Model without reasoning capability");
19862
19903
  }
19863
19904
  return {
@@ -19868,17 +19909,17 @@ function parseAvailableModels(response) {
19868
19909
  });
19869
19910
  }
19870
19911
  function assistantText(value) {
19871
- if (!isRecord6(value) || value.role !== "assistant" || !Array.isArray(value.content))
19912
+ if (!isRecord7(value) || value.role !== "assistant" || !Array.isArray(value.content))
19872
19913
  return null;
19873
- return value.content.filter((content) => isRecord6(content) && content.type === "text" && typeof content.text === "string").map((content) => content.text).join("");
19914
+ return value.content.filter((content) => isRecord7(content) && content.type === "text" && typeof content.text === "string").map((content) => content.text).join("");
19874
19915
  }
19875
19916
  function assistantMessageId(value) {
19876
- if (!isRecord6(value) || value.role !== "assistant")
19917
+ if (!isRecord7(value) || value.role !== "assistant")
19877
19918
  return null;
19878
19919
  return nonBlankString(value.responseId) ? value.responseId : null;
19879
19920
  }
19880
19921
  function extractReasoningText(content) {
19881
- if (!isRecord6(content))
19922
+ if (!isRecord7(content))
19882
19923
  return null;
19883
19924
  const type = String(content.type ?? "");
19884
19925
  if (type === "thinking" || type === "reasoning" || type === "thought") {
@@ -19888,12 +19929,12 @@ function extractReasoningText(content) {
19888
19929
  return null;
19889
19930
  }
19890
19931
  function assistantReasoning(value) {
19891
- if (!isRecord6(value) || value.role !== "assistant" || !Array.isArray(value.content))
19932
+ if (!isRecord7(value) || value.role !== "assistant" || !Array.isArray(value.content))
19892
19933
  return null;
19893
19934
  return value.content.map(extractReasoningText).filter((text2) => typeof text2 === "string").join("");
19894
19935
  }
19895
19936
  function assistantFailure(value) {
19896
- if (!isRecord6(value) || value.role !== "assistant")
19937
+ if (!isRecord7(value) || value.role !== "assistant")
19897
19938
  return void 0;
19898
19939
  if (value.stopReason !== "error" && value.stopReason !== "aborted")
19899
19940
  return null;
@@ -19913,7 +19954,7 @@ function signalProcessTree(child, signal) {
19913
19954
  try {
19914
19955
  process.kill(-child.pid, signal);
19915
19956
  } catch (error51) {
19916
- if (!isRecord6(error51) || error51.code !== "ESRCH")
19957
+ if (!isRecord7(error51) || error51.code !== "ESRCH")
19917
19958
  throw error51;
19918
19959
  }
19919
19960
  }
@@ -20049,12 +20090,12 @@ var PiRpcSession = class {
20049
20090
  }
20050
20091
  if (value.type === "message_update") {
20051
20092
  const event = value.assistantMessageEvent;
20052
- if (this.#usageRequestStartedAtMs === null && isRecord6(event) && typeof event.type === "string" && /^(text|thinking|reasoning|thought|toolcall)_(start|delta)$/u.test(event.type)) {
20093
+ if (this.#usageRequestStartedAtMs === null && isRecord7(event) && typeof event.type === "string" && /^(text|thinking|reasoning|thought|toolcall)_(start|delta)$/u.test(event.type)) {
20053
20094
  this.#usageRequestStartedAtMs = Date.now();
20054
20095
  }
20055
20096
  return;
20056
20097
  }
20057
- if (value.type === "message_end" && isRecord6(value.message)) {
20098
+ if (value.type === "message_end" && isRecord7(value.message)) {
20058
20099
  if (value.message.role !== "assistant")
20059
20100
  return;
20060
20101
  const startedAtMs = this.#usageRequestStartedAtMs;
@@ -20099,7 +20140,7 @@ var PiRpcSession = class {
20099
20140
  this.#stderrTail = sanitizeDiagnosticTail(`${this.#stderrTail}${chunk.toString()}`);
20100
20141
  });
20101
20142
  child.once("error", (error51) => {
20102
- const kind = isRecord6(error51) && error51.code === "ENOENT" ? "notInstalled" : "unavailable";
20143
+ const kind = isRecord7(error51) && error51.code === "ENOENT" ? "notInstalled" : "unavailable";
20103
20144
  this.#fail(new PiRpcFaultError(kind, `Pi RPC failed to start: ${error51.message}`, this.stderrTail));
20104
20145
  });
20105
20146
  child.once("exit", (code, signal) => {
@@ -20408,7 +20449,7 @@ var PiRpcSession = class {
20408
20449
  this.#buffer = this.#buffer.subarray(newline + 1);
20409
20450
  try {
20410
20451
  const value = JSON.parse(textDecoder.decode(frame));
20411
- if (!isRecord6(value) || typeof value.type !== "string") {
20452
+ if (!isRecord7(value) || typeof value.type !== "string") {
20412
20453
  throw new PiRpcFaultError("protocolError", "Pi RPC returned an invalid envelope");
20413
20454
  }
20414
20455
  this.#handle(value);
@@ -20455,7 +20496,7 @@ var PiRpcSession = class {
20455
20496
  this.#armCommandTimeout(id, pending);
20456
20497
  }
20457
20498
  }
20458
- const outcome = value.aborted === true ? "cancelled" : isRecord6(value.result) ? "succeeded" : "failed";
20499
+ const outcome = value.aborted === true ? "cancelled" : isRecord7(value.result) ? "succeeded" : "failed";
20459
20500
  const event = {
20460
20501
  type: "compaction.completed",
20461
20502
  outcome,
@@ -20493,12 +20534,12 @@ var PiRpcSession = class {
20493
20534
  this.#startAssistantMessage(active, value.message);
20494
20535
  return;
20495
20536
  }
20496
- if (value.type === "message_update" && isRecord6(value.assistantMessageEvent)) {
20537
+ if (value.type === "message_update" && isRecord7(value.assistantMessageEvent)) {
20497
20538
  const event = value.assistantMessageEvent;
20498
20539
  const eventType = String(event.type ?? "");
20499
20540
  const isThinking = eventType === "thinking_delta" || eventType === "reasoning_delta" || eventType === "thought_delta" || eventType === "thinking" || eventType === "reasoning";
20500
20541
  const isText = eventType === "text_delta" || eventType === "text" || eventType === "content_block_delta";
20501
- const delta = typeof event.delta === "string" ? event.delta : typeof event.thinking === "string" ? event.thinking : typeof event.reasoning === "string" ? event.reasoning : typeof event.text === "string" ? event.text : isRecord6(event.delta) && typeof event.delta.thinking === "string" ? event.delta.thinking : isRecord6(event.delta) && typeof event.delta.text === "string" ? event.delta.text : null;
20542
+ const delta = typeof event.delta === "string" ? event.delta : typeof event.thinking === "string" ? event.thinking : typeof event.reasoning === "string" ? event.reasoning : typeof event.text === "string" ? event.text : isRecord7(event.delta) && typeof event.delta.thinking === "string" ? event.delta.thinking : isRecord7(event.delta) && typeof event.delta.text === "string" ? event.delta.text : null;
20502
20543
  if (isThinking && delta !== null && delta.length > 0) {
20503
20544
  const messageId = this.#ensureAssistantMessage(active, value.message);
20504
20545
  active.reasoningMessageOpen = true;
@@ -20831,7 +20872,7 @@ var PiRpcSession = class {
20831
20872
  return;
20832
20873
  }
20833
20874
  active.failure = failure;
20834
- if (active.origin === "autonomous" && isRecord6(value) && value.stopReason === "aborted") {
20875
+ if (active.origin === "autonomous" && isRecord7(value) && value.stopReason === "aborted") {
20835
20876
  active.nativeCancellationObserved = true;
20836
20877
  }
20837
20878
  this.#latestCacheHitRatePercent = cacheHitRatePercent;
@@ -20992,7 +21033,7 @@ var piCommandCatalog = harnessCommandCatalogSchema.parse({
20992
21033
  ]
20993
21034
  });
20994
21035
  var DEFAULT_TOOL_OUTPUT_LIMIT = 64e3;
20995
- function isRecord7(value) {
21036
+ function isRecord8(value) {
20996
21037
  return typeof value === "object" && value !== null && !Array.isArray(value);
20997
21038
  }
20998
21039
  function errorMessage(error51) {
@@ -21007,7 +21048,7 @@ var PiAdapterFaultError = class extends Error {
21007
21048
  }
21008
21049
  };
21009
21050
  function normalizedError(error51, fallbackCode) {
21010
- if (isRecord7(error51) && error51.code === "ENOENT") {
21051
+ if (isRecord8(error51) && error51.code === "ENOENT") {
21011
21052
  return { code: "notInstalled", message: errorMessage(error51), retryable: false };
21012
21053
  }
21013
21054
  if (error51 instanceof PiAdapterFaultError)
@@ -21070,7 +21111,7 @@ function nativeModelForHistory(state2) {
21070
21111
  return nativeModelFromState(state2);
21071
21112
  }
21072
21113
  function sessionFileFromRef(ref) {
21073
- if (ref.harnessId !== piHarnessId2 || !isRecord7(ref.locator) || typeof ref.locator.sessionFile !== "string" || ref.locator.sessionFile.length === 0) {
21114
+ if (ref.harnessId !== piHarnessId2 || !isRecord8(ref.locator) || typeof ref.locator.sessionFile !== "string" || ref.locator.sessionFile.length === 0) {
21074
21115
  throw new Error("Pi Native Session Ref has no resumable Session file");
21075
21116
  }
21076
21117
  return ref.locator.sessionFile;
@@ -21085,9 +21126,9 @@ function toolFailure(toolName) {
21085
21126
  function nativeText(value) {
21086
21127
  if (typeof value === "string")
21087
21128
  return value;
21088
- if (!isRecord7(value) || !Array.isArray(value.content))
21129
+ if (!isRecord8(value) || !Array.isArray(value.content))
21089
21130
  return "";
21090
- return value.content.filter((content) => isRecord7(content) && content.type === "text" && typeof content.text === "string").map(({ text: text2 }) => text2).join("");
21131
+ return value.content.filter((content) => isRecord8(content) && content.type === "text" && typeof content.text === "string").map(({ text: text2 }) => text2).join("");
21091
21132
  }
21092
21133
  function boundedOutput(value, limit) {
21093
21134
  const text2 = nativeText(value);
@@ -21103,17 +21144,17 @@ function outputText(output) {
21103
21144
  return output?.content.filter((content) => content.type === "text").map(({ text: text2 }) => text2).join("") ?? "";
21104
21145
  }
21105
21146
  function stringField(value, key) {
21106
- if (!isRecord7(value))
21147
+ if (!isRecord8(value))
21107
21148
  return void 0;
21108
21149
  const field = value[key];
21109
21150
  if (typeof field === "string" && field.length > 0)
21110
21151
  return field;
21111
- if (isRecord7(value.input)) {
21152
+ if (isRecord8(value.input)) {
21112
21153
  const nested = value.input[key];
21113
21154
  if (typeof nested === "string" && nested.length > 0)
21114
21155
  return nested;
21115
21156
  }
21116
- if (isRecord7(value.arguments)) {
21157
+ if (isRecord8(value.arguments)) {
21117
21158
  const nested = value.arguments[key];
21118
21159
  if (typeof nested === "string" && nested.length > 0)
21119
21160
  return nested;
@@ -21121,7 +21162,7 @@ function stringField(value, key) {
21121
21162
  return void 0;
21122
21163
  }
21123
21164
  function numberField(value, key) {
21124
- if (!isRecord7(value))
21165
+ if (!isRecord8(value))
21125
21166
  return void 0;
21126
21167
  const field = value[key];
21127
21168
  return typeof field === "number" || field === null ? field : void 0;
@@ -21196,7 +21237,7 @@ function fileMutatingKind(toolName) {
21196
21237
  return null;
21197
21238
  }
21198
21239
  function nestedToolString(value, keys) {
21199
- if (!isRecord7(value))
21240
+ if (!isRecord8(value))
21200
21241
  return void 0;
21201
21242
  for (const key of keys) {
21202
21243
  const field = value[key];
@@ -21211,14 +21252,14 @@ function nestedToolString(value, keys) {
21211
21252
  return void 0;
21212
21253
  }
21213
21254
  function patchFromResult(result) {
21214
- if (!isRecord7(result))
21255
+ if (!isRecord8(result))
21215
21256
  return void 0;
21216
21257
  for (const key of ["patch", "diff", "unifiedDiff"]) {
21217
21258
  const field = result[key];
21218
21259
  if (typeof field === "string" && field.length > 0)
21219
21260
  return field;
21220
21261
  }
21221
- if (isRecord7(result.details)) {
21262
+ if (isRecord8(result.details)) {
21222
21263
  for (const key of ["patch", "diff", "unifiedDiff"]) {
21223
21264
  const field = result.details[key];
21224
21265
  if (typeof field === "string" && field.length > 0)
@@ -22236,7 +22277,7 @@ var PiHarnessSession = class {
22236
22277
  type: "question",
22237
22278
  interactionId,
22238
22279
  turnId: active.command.turnId,
22239
- ...associatedTool ? { itemId: associatedTool.item.itemId } : {},
22280
+ ...associatedTool?.item.type === "toolExecution" ? { itemId: associatedTool.item.itemId } : {},
22240
22281
  title: "Pi",
22241
22282
  questions: [question],
22242
22283
  ...request.timeoutMs !== void 0 ? { expiresAt: new Date(Date.now() + request.timeoutMs).toISOString() } : {}