@codexhost/cli-win32-arm64 0.13.0 → 0.13.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.
@@ -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
@@ -17621,9 +17644,11 @@ function ompUsageHistory(history) {
17621
17644
  async function readOmpUsage(file2, signal) {
17622
17645
  const entries = [];
17623
17646
  const header = await jsonlHeader(file2, (record2) => record2.type === "session", signal);
17647
+ const titled = await jsonlHeader(file2, (record2) => record2.type === "title", signal);
17624
17648
  const session = {
17625
17649
  sessionId: typeof header?.id === "string" ? header.id : void 0,
17626
- cwd: typeof header?.cwd === "string" ? header.cwd : void 0
17650
+ cwd: typeof header?.cwd === "string" ? header.cwd : void 0,
17651
+ title: usageSessionTitle(titled?.title)
17627
17652
  };
17628
17653
  for await (const line of jsonlRecords(file2, '"assistant"', signal)) {
17629
17654
  if (line.type !== "message")
@@ -21306,11 +21331,10 @@ var OmpHarnessSession = class {
21306
21331
  state = await transport.selectThinkingOption(this.#requestedThinkingOptionId);
21307
21332
  thinkingLevels = await transport.getAvailableThinkingLevels();
21308
21333
  }
21309
- } else {
21310
- const reconciled = await reconcileThinkingLevel(transport, state, thinkingLevels);
21311
- state = reconciled.state;
21312
- thinkingLevels = reconciled.thinkingLevels;
21313
21334
  }
21335
+ const reconciled = await reconcileThinkingLevel(transport, state, thinkingLevels);
21336
+ state = reconciled.state;
21337
+ thinkingLevels = reconciled.thinkingLevels;
21314
21338
  this.#transport = transport;
21315
21339
  this.#publishTransportState(state, thinkingLevels);
21316
21340
  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
@@ -16732,12 +16755,18 @@ async function readOpenCodeUsage(file2) {
16732
16755
  try {
16733
16756
  const tables = new Set(database.prepare("SELECT name FROM sqlite_master WHERE type = 'table'").all().map((row) => String(row.name)));
16734
16757
  const directories = /* @__PURE__ */ new Map();
16758
+ const titles = /* @__PURE__ */ new Map();
16735
16759
  for (const table of ["session", "session_v2"]) {
16736
16760
  if (!tables.has(table))
16737
16761
  continue;
16738
- for (const row of database.prepare(`SELECT id, directory FROM ${table}`).iterate()) {
16762
+ const columns = new Set(database.prepare(`PRAGMA table_info(${table})`).all().map((row) => String(row.name)));
16763
+ const titleColumn = columns.has("title") ? ", title" : "";
16764
+ for (const row of database.prepare(`SELECT id, directory${titleColumn} FROM ${table}`).iterate()) {
16739
16765
  if (typeof row.directory === "string")
16740
16766
  directories.set(String(row.id), row.directory);
16767
+ const title = usageSessionTitle(row.title);
16768
+ if (title)
16769
+ titles.set(String(row.id), title);
16741
16770
  }
16742
16771
  }
16743
16772
  const entries = /* @__PURE__ */ new Map();
@@ -16754,7 +16783,8 @@ async function readOpenCodeUsage(file2) {
16754
16783
  const sessionId = typeof session === "string" ? session : void 0;
16755
16784
  entries.set(entry.id, withUsageSession(entry, {
16756
16785
  sessionId,
16757
- cwd: sessionId === void 0 ? void 0 : directories.get(sessionId)
16786
+ cwd: sessionId === void 0 ? void 0 : directories.get(sessionId),
16787
+ title: sessionId === void 0 ? void 0 : titles.get(sessionId)
16758
16788
  }));
16759
16789
  }
16760
16790
  };
@@ -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
@@ -17989,20 +18012,38 @@ function piUsageHistory(history) {
17989
18012
  }
17990
18013
 
17991
18014
  // dist/pi-usage-statistics.js
18015
+ function isRecord5(value) {
18016
+ return typeof value === "object" && value !== null && !Array.isArray(value);
18017
+ }
18018
+ function piUserText(content) {
18019
+ if (typeof content === "string")
18020
+ return content;
18021
+ if (!Array.isArray(content))
18022
+ return void 0;
18023
+ return content.filter((block) => isRecord5(block) && block.type === "text" && typeof block.text === "string").map((block) => String(block.text)).join(" ");
18024
+ }
17992
18025
  async function readPiUsage(file2, signal) {
17993
18026
  const entries = [];
17994
18027
  const header = await jsonlHeader(file2, (record7) => record7.type === "session", signal);
18028
+ let name;
17995
18029
  const session = {
17996
18030
  sessionId: typeof header?.id === "string" ? header.id : void 0,
17997
18031
  cwd: typeof header?.cwd === "string" ? header.cwd : void 0
17998
18032
  };
17999
- for await (const line of jsonlRecords(file2, '"assistant"', signal)) {
18033
+ for await (const line of jsonlRecords(file2, '"type"', signal)) {
18034
+ if (line.type === "session_info") {
18035
+ name = usageSessionTitle(line.name) ?? name;
18036
+ continue;
18037
+ }
18000
18038
  if (line.type !== "message")
18001
18039
  continue;
18040
+ const message3 = line.message;
18041
+ if (!name && message3?.role === "user") {
18042
+ name = usageSessionTitle(piUserText(message3.content));
18043
+ }
18002
18044
  const record7 = piUsageRecord(line.message);
18003
18045
  if (record7?.kind !== "request")
18004
18046
  continue;
18005
- const message3 = line.message;
18006
18047
  const at = nativeTimeMs(message3.timestamp) ?? nativeTimeMs(line.timestamp);
18007
18048
  const entry = at !== null && usageEntryFromRequest(record7.request, at);
18008
18049
  if (!entry)
@@ -18014,7 +18055,7 @@ async function readPiUsage(file2, signal) {
18014
18055
  }
18015
18056
  entries.push(withUsageSession(entry, session));
18016
18057
  }
18017
- return entries;
18058
+ return name ? entries.map((entry) => withUsageSession(entry, { ...session, title: name })) : entries;
18018
18059
  }
18019
18060
  function createPiUsageStatistics(environment) {
18020
18061
  return Object.freeze({
@@ -18645,7 +18686,7 @@ import path10 from "node:path";
18645
18686
  import { open, realpath as realpath3 } from "node:fs/promises";
18646
18687
  var MAX_SESSION_HEADER_BYTES = 64 * 1024;
18647
18688
  var utf8Decoder = new TextDecoder("utf-8", { fatal: true });
18648
- function isRecord5(value) {
18689
+ function isRecord6(value) {
18649
18690
  return typeof value === "object" && value !== null && !Array.isArray(value);
18650
18691
  }
18651
18692
  async function readPiSessionHeader(sessionFile) {
@@ -18665,7 +18706,7 @@ async function readPiSessionHeader(sessionFile) {
18665
18706
  } catch {
18666
18707
  throw new Error("Pi Session header is not valid JSON");
18667
18708
  }
18668
- if (!isRecord5(parsed) || parsed.type !== "session" || typeof parsed.id !== "string" || parsed.id.length === 0 || typeof parsed.cwd !== "string" || parsed.cwd.length === 0) {
18709
+ if (!isRecord6(parsed) || parsed.type !== "session" || typeof parsed.id !== "string" || parsed.id.length === 0 || typeof parsed.cwd !== "string" || parsed.cwd.length === 0) {
18669
18710
  throw new Error("Pi Session header is invalid");
18670
18711
  }
18671
18712
  return {
@@ -19714,7 +19755,7 @@ var PiRpcUnsupportedCommandError = class extends Error {
19714
19755
  }
19715
19756
  };
19716
19757
  var textDecoder = new TextDecoder("utf-8", { fatal: true });
19717
- function isRecord6(value) {
19758
+ function isRecord7(value) {
19718
19759
  return typeof value === "object" && value !== null && !Array.isArray(value);
19719
19760
  }
19720
19761
  function message2(value) {
@@ -19726,13 +19767,13 @@ function nonBlankString(value) {
19726
19767
  function parseNativeModel(value, context) {
19727
19768
  if (value === null || value === void 0)
19728
19769
  return null;
19729
- if (!isRecord6(value) || !nonBlankString(value.provider) || !nonBlankString(value.id)) {
19770
+ if (!isRecord7(value) || !nonBlankString(value.provider) || !nonBlankString(value.id)) {
19730
19771
  throw new PiRpcFaultError("protocolError", `Pi RPC returned an invalid ${context} Model`);
19731
19772
  }
19732
19773
  return { provider: value.provider, id: value.id };
19733
19774
  }
19734
19775
  function sessionStateData(response) {
19735
- const data = isRecord6(response.data) ? response.data : null;
19776
+ const data = isRecord7(response.data) ? response.data : null;
19736
19777
  if (!data)
19737
19778
  throw new PiRpcFaultError("protocolError", "Pi RPC state response has no data");
19738
19779
  return data;
@@ -19764,13 +19805,13 @@ function parseSessionStreaming(response) {
19764
19805
  return isStreaming;
19765
19806
  }
19766
19807
  function parseSessionHistory(response) {
19767
- const data = isRecord6(response.data) ? response.data : null;
19808
+ const data = isRecord7(response.data) ? response.data : null;
19768
19809
  if (!data || !Array.isArray(data.entries)) {
19769
19810
  throw new PiRpcFaultError("protocolError", "Pi RPC entries response has no Entries");
19770
19811
  }
19771
19812
  const entries = data.entries.map((entry) => {
19772
19813
  const parsed = jsonValueSchema.safeParse(entry);
19773
- if (!parsed.success || !isRecord6(parsed.data)) {
19814
+ if (!parsed.success || !isRecord7(parsed.data)) {
19774
19815
  throw new PiRpcFaultError("protocolError", "Pi RPC entries response contains an invalid Entry");
19775
19816
  }
19776
19817
  return parsed.data;
@@ -19781,7 +19822,7 @@ function parseSessionHistory(response) {
19781
19822
  return { entries, leafId: data.leafId };
19782
19823
  }
19783
19824
  function parseAvailableThinkingLevels(response) {
19784
- const data = isRecord6(response.data) ? response.data : null;
19825
+ const data = isRecord7(response.data) ? response.data : null;
19785
19826
  if (!data || !Array.isArray(data.levels) || data.levels.length === 0) {
19786
19827
  throw new PiRpcFaultError("protocolError", "Pi RPC Thinking catalog response has no levels");
19787
19828
  }
@@ -19798,13 +19839,13 @@ function parseAvailableThinkingLevels(response) {
19798
19839
  return levels;
19799
19840
  }
19800
19841
  function parseAvailableModels(response) {
19801
- const data = isRecord6(response.data) ? response.data : null;
19842
+ const data = isRecord7(response.data) ? response.data : null;
19802
19843
  if (!data || !Array.isArray(data.models)) {
19803
19844
  throw new PiRpcFaultError("protocolError", "Pi RPC Model catalog response has no models");
19804
19845
  }
19805
19846
  return data.models.map((model2) => {
19806
19847
  const parsed = parseNativeModel(model2, "catalog");
19807
- if (!parsed || !isRecord6(model2) || typeof model2.reasoning !== "boolean") {
19848
+ if (!parsed || !isRecord7(model2) || typeof model2.reasoning !== "boolean") {
19808
19849
  throw new PiRpcFaultError("protocolError", "Pi RPC catalog contains a Model without reasoning capability");
19809
19850
  }
19810
19851
  return {
@@ -19815,17 +19856,17 @@ function parseAvailableModels(response) {
19815
19856
  });
19816
19857
  }
19817
19858
  function assistantText(value) {
19818
- if (!isRecord6(value) || value.role !== "assistant" || !Array.isArray(value.content))
19859
+ if (!isRecord7(value) || value.role !== "assistant" || !Array.isArray(value.content))
19819
19860
  return null;
19820
- return value.content.filter((content) => isRecord6(content) && content.type === "text" && typeof content.text === "string").map((content) => content.text).join("");
19861
+ return value.content.filter((content) => isRecord7(content) && content.type === "text" && typeof content.text === "string").map((content) => content.text).join("");
19821
19862
  }
19822
19863
  function assistantMessageId(value) {
19823
- if (!isRecord6(value) || value.role !== "assistant")
19864
+ if (!isRecord7(value) || value.role !== "assistant")
19824
19865
  return null;
19825
19866
  return nonBlankString(value.responseId) ? value.responseId : null;
19826
19867
  }
19827
19868
  function extractReasoningText(content) {
19828
- if (!isRecord6(content))
19869
+ if (!isRecord7(content))
19829
19870
  return null;
19830
19871
  const type = String(content.type ?? "");
19831
19872
  if (type === "thinking" || type === "reasoning" || type === "thought") {
@@ -19835,12 +19876,12 @@ function extractReasoningText(content) {
19835
19876
  return null;
19836
19877
  }
19837
19878
  function assistantReasoning(value) {
19838
- if (!isRecord6(value) || value.role !== "assistant" || !Array.isArray(value.content))
19879
+ if (!isRecord7(value) || value.role !== "assistant" || !Array.isArray(value.content))
19839
19880
  return null;
19840
19881
  return value.content.map(extractReasoningText).filter((text2) => typeof text2 === "string").join("");
19841
19882
  }
19842
19883
  function assistantFailure(value) {
19843
- if (!isRecord6(value) || value.role !== "assistant")
19884
+ if (!isRecord7(value) || value.role !== "assistant")
19844
19885
  return void 0;
19845
19886
  if (value.stopReason !== "error" && value.stopReason !== "aborted")
19846
19887
  return null;
@@ -19860,7 +19901,7 @@ function signalProcessTree(child, signal) {
19860
19901
  try {
19861
19902
  process.kill(-child.pid, signal);
19862
19903
  } catch (error51) {
19863
- if (!isRecord6(error51) || error51.code !== "ESRCH")
19904
+ if (!isRecord7(error51) || error51.code !== "ESRCH")
19864
19905
  throw error51;
19865
19906
  }
19866
19907
  }
@@ -19996,12 +20037,12 @@ var PiRpcSession = class {
19996
20037
  }
19997
20038
  if (value.type === "message_update") {
19998
20039
  const event = value.assistantMessageEvent;
19999
- if (this.#usageRequestStartedAtMs === null && isRecord6(event) && typeof event.type === "string" && /^(text|thinking|reasoning|thought|toolcall)_(start|delta)$/u.test(event.type)) {
20040
+ if (this.#usageRequestStartedAtMs === null && isRecord7(event) && typeof event.type === "string" && /^(text|thinking|reasoning|thought|toolcall)_(start|delta)$/u.test(event.type)) {
20000
20041
  this.#usageRequestStartedAtMs = Date.now();
20001
20042
  }
20002
20043
  return;
20003
20044
  }
20004
- if (value.type === "message_end" && isRecord6(value.message)) {
20045
+ if (value.type === "message_end" && isRecord7(value.message)) {
20005
20046
  if (value.message.role !== "assistant")
20006
20047
  return;
20007
20048
  const startedAtMs = this.#usageRequestStartedAtMs;
@@ -20046,7 +20087,7 @@ var PiRpcSession = class {
20046
20087
  this.#stderrTail = sanitizeDiagnosticTail(`${this.#stderrTail}${chunk.toString()}`);
20047
20088
  });
20048
20089
  child.once("error", (error51) => {
20049
- const kind = isRecord6(error51) && error51.code === "ENOENT" ? "notInstalled" : "unavailable";
20090
+ const kind = isRecord7(error51) && error51.code === "ENOENT" ? "notInstalled" : "unavailable";
20050
20091
  this.#fail(new PiRpcFaultError(kind, `Pi RPC failed to start: ${error51.message}`, this.stderrTail));
20051
20092
  });
20052
20093
  child.once("exit", (code, signal) => {
@@ -20355,7 +20396,7 @@ var PiRpcSession = class {
20355
20396
  this.#buffer = this.#buffer.subarray(newline + 1);
20356
20397
  try {
20357
20398
  const value = JSON.parse(textDecoder.decode(frame));
20358
- if (!isRecord6(value) || typeof value.type !== "string") {
20399
+ if (!isRecord7(value) || typeof value.type !== "string") {
20359
20400
  throw new PiRpcFaultError("protocolError", "Pi RPC returned an invalid envelope");
20360
20401
  }
20361
20402
  this.#handle(value);
@@ -20402,7 +20443,7 @@ var PiRpcSession = class {
20402
20443
  this.#armCommandTimeout(id, pending);
20403
20444
  }
20404
20445
  }
20405
- const outcome = value.aborted === true ? "cancelled" : isRecord6(value.result) ? "succeeded" : "failed";
20446
+ const outcome = value.aborted === true ? "cancelled" : isRecord7(value.result) ? "succeeded" : "failed";
20406
20447
  const event = {
20407
20448
  type: "compaction.completed",
20408
20449
  outcome,
@@ -20440,12 +20481,12 @@ var PiRpcSession = class {
20440
20481
  this.#startAssistantMessage(active, value.message);
20441
20482
  return;
20442
20483
  }
20443
- if (value.type === "message_update" && isRecord6(value.assistantMessageEvent)) {
20484
+ if (value.type === "message_update" && isRecord7(value.assistantMessageEvent)) {
20444
20485
  const event = value.assistantMessageEvent;
20445
20486
  const eventType = String(event.type ?? "");
20446
20487
  const isThinking = eventType === "thinking_delta" || eventType === "reasoning_delta" || eventType === "thought_delta" || eventType === "thinking" || eventType === "reasoning";
20447
20488
  const isText = eventType === "text_delta" || eventType === "text" || eventType === "content_block_delta";
20448
- 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;
20489
+ 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;
20449
20490
  if (isThinking && delta !== null && delta.length > 0) {
20450
20491
  const messageId = this.#ensureAssistantMessage(active, value.message);
20451
20492
  active.reasoningMessageOpen = true;
@@ -20758,7 +20799,7 @@ var PiRpcSession = class {
20758
20799
  return;
20759
20800
  }
20760
20801
  active.failure = failure;
20761
- if (active.origin === "autonomous" && isRecord6(value) && value.stopReason === "aborted") {
20802
+ if (active.origin === "autonomous" && isRecord7(value) && value.stopReason === "aborted") {
20762
20803
  active.nativeCancellationObserved = true;
20763
20804
  }
20764
20805
  this.#latestCacheHitRatePercent = cacheHitRatePercent;
@@ -20919,7 +20960,7 @@ var piCommandCatalog = harnessCommandCatalogSchema.parse({
20919
20960
  ]
20920
20961
  });
20921
20962
  var DEFAULT_TOOL_OUTPUT_LIMIT = 64e3;
20922
- function isRecord7(value) {
20963
+ function isRecord8(value) {
20923
20964
  return typeof value === "object" && value !== null && !Array.isArray(value);
20924
20965
  }
20925
20966
  function errorMessage(error51) {
@@ -20934,7 +20975,7 @@ var PiAdapterFaultError = class extends Error {
20934
20975
  }
20935
20976
  };
20936
20977
  function normalizedError(error51, fallbackCode) {
20937
- if (isRecord7(error51) && error51.code === "ENOENT") {
20978
+ if (isRecord8(error51) && error51.code === "ENOENT") {
20938
20979
  return { code: "notInstalled", message: errorMessage(error51), retryable: false };
20939
20980
  }
20940
20981
  if (error51 instanceof PiAdapterFaultError)
@@ -20997,7 +21038,7 @@ function nativeModelForHistory(state2) {
20997
21038
  return nativeModelFromState(state2);
20998
21039
  }
20999
21040
  function sessionFileFromRef(ref) {
21000
- if (ref.harnessId !== piHarnessId2 || !isRecord7(ref.locator) || typeof ref.locator.sessionFile !== "string" || ref.locator.sessionFile.length === 0) {
21041
+ if (ref.harnessId !== piHarnessId2 || !isRecord8(ref.locator) || typeof ref.locator.sessionFile !== "string" || ref.locator.sessionFile.length === 0) {
21001
21042
  throw new Error("Pi Native Session Ref has no resumable Session file");
21002
21043
  }
21003
21044
  return ref.locator.sessionFile;
@@ -21012,9 +21053,9 @@ function toolFailure(toolName) {
21012
21053
  function nativeText(value) {
21013
21054
  if (typeof value === "string")
21014
21055
  return value;
21015
- if (!isRecord7(value) || !Array.isArray(value.content))
21056
+ if (!isRecord8(value) || !Array.isArray(value.content))
21016
21057
  return "";
21017
- return value.content.filter((content) => isRecord7(content) && content.type === "text" && typeof content.text === "string").map(({ text: text2 }) => text2).join("");
21058
+ return value.content.filter((content) => isRecord8(content) && content.type === "text" && typeof content.text === "string").map(({ text: text2 }) => text2).join("");
21018
21059
  }
21019
21060
  function boundedOutput(value, limit) {
21020
21061
  const text2 = nativeText(value);
@@ -21030,17 +21071,17 @@ function outputText(output) {
21030
21071
  return output?.content.filter((content) => content.type === "text").map(({ text: text2 }) => text2).join("") ?? "";
21031
21072
  }
21032
21073
  function stringField(value, key) {
21033
- if (!isRecord7(value))
21074
+ if (!isRecord8(value))
21034
21075
  return void 0;
21035
21076
  const field = value[key];
21036
21077
  if (typeof field === "string" && field.length > 0)
21037
21078
  return field;
21038
- if (isRecord7(value.input)) {
21079
+ if (isRecord8(value.input)) {
21039
21080
  const nested = value.input[key];
21040
21081
  if (typeof nested === "string" && nested.length > 0)
21041
21082
  return nested;
21042
21083
  }
21043
- if (isRecord7(value.arguments)) {
21084
+ if (isRecord8(value.arguments)) {
21044
21085
  const nested = value.arguments[key];
21045
21086
  if (typeof nested === "string" && nested.length > 0)
21046
21087
  return nested;
@@ -21048,7 +21089,7 @@ function stringField(value, key) {
21048
21089
  return void 0;
21049
21090
  }
21050
21091
  function numberField(value, key) {
21051
- if (!isRecord7(value))
21092
+ if (!isRecord8(value))
21052
21093
  return void 0;
21053
21094
  const field = value[key];
21054
21095
  return typeof field === "number" || field === null ? field : void 0;
@@ -21123,7 +21164,7 @@ function fileMutatingKind(toolName) {
21123
21164
  return null;
21124
21165
  }
21125
21166
  function nestedToolString(value, keys) {
21126
- if (!isRecord7(value))
21167
+ if (!isRecord8(value))
21127
21168
  return void 0;
21128
21169
  for (const key of keys) {
21129
21170
  const field = value[key];
@@ -21138,14 +21179,14 @@ function nestedToolString(value, keys) {
21138
21179
  return void 0;
21139
21180
  }
21140
21181
  function patchFromResult(result) {
21141
- if (!isRecord7(result))
21182
+ if (!isRecord8(result))
21142
21183
  return void 0;
21143
21184
  for (const key of ["patch", "diff", "unifiedDiff"]) {
21144
21185
  const field = result[key];
21145
21186
  if (typeof field === "string" && field.length > 0)
21146
21187
  return field;
21147
21188
  }
21148
- if (isRecord7(result.details)) {
21189
+ if (isRecord8(result.details)) {
21149
21190
  for (const key of ["patch", "diff", "unifiedDiff"]) {
21150
21191
  const field = result.details[key];
21151
21192
  if (typeof field === "string" && field.length > 0)
@@ -22160,7 +22201,7 @@ var PiHarnessSession = class {
22160
22201
  type: "question",
22161
22202
  interactionId,
22162
22203
  turnId: active.command.turnId,
22163
- ...associatedTool ? { itemId: associatedTool.item.itemId } : {},
22204
+ ...associatedTool?.item.type === "toolExecution" ? { itemId: associatedTool.item.itemId } : {},
22164
22205
  title: "Pi",
22165
22206
  questions: [question],
22166
22207
  ...request.timeoutMs !== void 0 ? { expiresAt: new Date(Date.now() + request.timeoutMs).toISOString() } : {}