@liberseek/boft-cli-win32-arm64 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.
@@ -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) {
@@ -15125,6 +15141,15 @@ var harnessDisplaySetSchema = external_exports.strictObject({
15125
15141
  initializeOnly: external_exports.boolean().optional()
15126
15142
  });
15127
15143
 
15144
+ // ../../shared-contracts/dist/harness-presentation.js
15145
+ var localeSchema = external_exports.string().max(64).regex(/^[a-z]{2,3}(?:-[A-Za-z0-9]{2,8})*$/u);
15146
+ var displayText = (maximum) => external_exports.string().min(1).max(maximum).refine((text2) => text2.trim().length > 0);
15147
+ var harnessLocalizationsSchema = external_exports.record(localeSchema, external_exports.object({
15148
+ label: displayText(256).optional(),
15149
+ description: displayText(1024).optional()
15150
+ }).strict()).refine((entries) => Object.keys(entries).length <= 16, "Too many locales");
15151
+ 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");
15152
+
15128
15153
  // ../../shared-contracts/dist/model-price-overrides.js
15129
15154
  var usdPerMillionTokens = external_exports.number().finite().nonnegative();
15130
15155
  var modelPriceOverrideSchema = external_exports.strictObject({
@@ -15203,6 +15228,8 @@ var usageStatisticsSessionSchema = external_exports.strictObject({
15203
15228
  harness,
15204
15229
  sessionId: external_exports.string().min(1).max(512),
15205
15230
  project: project.nullable(),
15231
+ /** Persisted Desktop title for a mapped Session, otherwise its native name; may be absent. */
15232
+ title: external_exports.string().min(1).max(200).optional(),
15206
15233
  /** Models the session used, most requests first. */
15207
15234
  models: external_exports.array(model).max(16),
15208
15235
  firstAtMs: count,
@@ -15269,7 +15296,12 @@ var usageStatisticsResultSchema = external_exports.strictObject({
15269
15296
  * The sessions that spent the most, by cost and by tokens without cache, all filters applied;
15270
15297
  * requests without a native session are not listed here but count everywhere else.
15271
15298
  */
15272
- sessions: external_exports.array(usageStatisticsSessionSchema).max(100)
15299
+ sessions: external_exports.array(usageStatisticsSessionSchema).max(100),
15300
+ /**
15301
+ * The sessions last active in the range, newest first, all filters applied. Optional for older
15302
+ * Hosts; missing is treated as no list rather than no sessions.
15303
+ */
15304
+ recentSessions: external_exports.array(usageStatisticsSessionSchema).max(100).optional()
15273
15305
  });
15274
15306
 
15275
15307
  // ../../shared-contracts/dist/ids.js
@@ -15538,8 +15570,24 @@ var threadUsageSnapshotSchema = external_exports.object({
15538
15570
  }
15539
15571
  });
15540
15572
  var usagePercentSchema = external_exports.number().finite().min(0).max(100);
15573
+ var accountCreditsPeriodSchema = external_exports.enum([
15574
+ "weekly",
15575
+ "monthly",
15576
+ "five_hour",
15577
+ "seven_day",
15578
+ "unknown"
15579
+ ]);
15580
+ var accountCreditsScopeSchema = external_exports.object({
15581
+ id: external_exports.string().min(1).max(256),
15582
+ label: external_exports.string().min(1).max(256),
15583
+ localizations: harnessLocalizationsSchema.optional()
15584
+ }).strict();
15541
15585
  var accountCreditsProductUsageSchema = external_exports.object({
15542
15586
  product: external_exports.string().min(1),
15587
+ /** Native period and scope, never inferred from the display name. */
15588
+ periodType: accountCreditsPeriodSchema.optional(),
15589
+ scope: accountCreditsScopeSchema.optional(),
15590
+ localizations: harnessLocalizationsSchema.optional(),
15543
15591
  used: external_exports.number().finite().nonnegative().optional(),
15544
15592
  // Zero is a real empty cap, not an absent field.
15545
15593
  limit: external_exports.number().finite().nonnegative().optional(),
@@ -15561,8 +15609,10 @@ var accountCreditsSnapshotSchema = external_exports.object({
15561
15609
  label: external_exports.string().min(1).optional(),
15562
15610
  usedPercent: usagePercentSchema.optional(),
15563
15611
  remaining: external_exports.number().finite().optional(),
15612
+ scope: accountCreditsScopeSchema.optional(),
15613
+ localizations: harnessLocalizationsSchema.optional(),
15564
15614
  resetsAt: external_exports.string().min(1).optional(),
15565
- periodType: external_exports.enum(["weekly", "monthly", "five_hour", "seven_day", "unknown"]),
15615
+ periodType: accountCreditsPeriodSchema,
15566
15616
  productUsage: external_exports.array(accountCreditsProductUsageSchema).min(1).optional(),
15567
15617
  resetCredits: accountResetCreditsSchema.optional()
15568
15618
  }).strict().superRefine((credits, context) => {
@@ -15587,7 +15637,9 @@ var threadUsageInspectionParamsSchema = external_exports.object({
15587
15637
  var threadUsageInspectionSchema = external_exports.object({
15588
15638
  threadId: hostThreadIdSchema,
15589
15639
  usage: threadUsageSnapshotSchema.nullable(),
15590
- accountCredits: accountCreditsSnapshotSchema.optional()
15640
+ accountCredits: accountCreditsSnapshotSchema.optional(),
15641
+ /** Whether this source can provide cached account quota independently of usage. */
15642
+ accountCreditsSupported: external_exports.boolean().optional()
15591
15643
  }).strict();
15592
15644
 
15593
15645
  // ../../shared-contracts/dist/harness-accounts.js
@@ -15714,7 +15766,8 @@ var harnessPermissionModeSchema = external_exports.object({
15714
15766
  id: harnessPermissionModeIdSchema,
15715
15767
  label: nonBlankTextSchema.max(HARNESS_PERMISSION_MODE_LABEL_MAX_LENGTH),
15716
15768
  description: nonBlankTextSchema.max(HARNESS_PERMISSION_MODE_DESCRIPTION_MAX_LENGTH).optional(),
15717
- dangerous: external_exports.boolean().optional()
15769
+ dangerous: external_exports.boolean().optional(),
15770
+ localizations: harnessLocalizationsSchema.optional()
15718
15771
  }).strict();
15719
15772
  var harnessPermissionModeCatalogSchema = external_exports.object({
15720
15773
  modes: external_exports.array(harnessPermissionModeSchema).min(1).max(HARNESS_PERMISSION_MODE_CATALOG_MAX_LENGTH),
@@ -16037,6 +16090,8 @@ var harnessInstallationStateSchema = external_exports.object({
16037
16090
  // Adapter-owned diagnostic text; UI uses messageCode rather than displaying it verbatim.
16038
16091
  message: external_exports.string().max(2048).optional(),
16039
16092
  messageCode: external_exports.string().min(1).max(128).optional(),
16093
+ /** Safe plugin-owned explanation, distinct from raw diagnostic message. */
16094
+ notice: harnessLocalizedTextSchema.optional(),
16040
16095
  latestVersionKind: external_exports.enum(["unknown", "tracking-branch"]).optional()
16041
16096
  }).strict();
16042
16097
 
@@ -16175,6 +16230,7 @@ var harnessCommandDescriptorSchema = external_exports.object({
16175
16230
  invocation: commandInvocationSchema,
16176
16231
  label: commandLabelSchema,
16177
16232
  description: commandDescriptionSchema.optional(),
16233
+ localizations: harnessLocalizationsSchema.optional(),
16178
16234
  argumentMode: external_exports.enum(["none", "text"]),
16179
16235
  /**
16180
16236
  * Native distinction reported by the Harness. Omitted when the Harness does
@@ -18042,20 +18098,38 @@ function piUsageHistory(history) {
18042
18098
  }
18043
18099
 
18044
18100
  // dist/pi-usage-statistics.js
18101
+ function isRecord5(value) {
18102
+ return typeof value === "object" && value !== null && !Array.isArray(value);
18103
+ }
18104
+ function piUserText(content) {
18105
+ if (typeof content === "string")
18106
+ return content;
18107
+ if (!Array.isArray(content))
18108
+ return void 0;
18109
+ return content.filter((block) => isRecord5(block) && block.type === "text" && typeof block.text === "string").map((block) => String(block.text)).join(" ");
18110
+ }
18045
18111
  async function readPiUsage(file2, signal) {
18046
18112
  const entries = [];
18047
18113
  const header = await jsonlHeader(file2, (record7) => record7.type === "session", signal);
18114
+ let name;
18048
18115
  const session = {
18049
18116
  sessionId: typeof header?.id === "string" ? header.id : void 0,
18050
18117
  cwd: typeof header?.cwd === "string" ? header.cwd : void 0
18051
18118
  };
18052
- for await (const line of jsonlRecords(file2, '"assistant"', signal)) {
18119
+ for await (const line of jsonlRecords(file2, '"type"', signal)) {
18120
+ if (line.type === "session_info") {
18121
+ name = usageSessionTitle(line.name) ?? name;
18122
+ continue;
18123
+ }
18053
18124
  if (line.type !== "message")
18054
18125
  continue;
18126
+ const message3 = line.message;
18127
+ if (!name && message3?.role === "user") {
18128
+ name = usageSessionTitle(piUserText(message3.content));
18129
+ }
18055
18130
  const record7 = piUsageRecord(line.message);
18056
18131
  if (record7?.kind !== "request")
18057
18132
  continue;
18058
- const message3 = line.message;
18059
18133
  const at = nativeTimeMs(message3.timestamp) ?? nativeTimeMs(line.timestamp);
18060
18134
  const entry = at !== null && usageEntryFromRequest(record7.request, at);
18061
18135
  if (!entry)
@@ -18067,7 +18141,7 @@ async function readPiUsage(file2, signal) {
18067
18141
  }
18068
18142
  entries.push(withUsageSession(entry, session));
18069
18143
  }
18070
- return entries;
18144
+ return name ? entries.map((entry) => withUsageSession(entry, { ...session, title: name })) : entries;
18071
18145
  }
18072
18146
  function createPiUsageStatistics(environment) {
18073
18147
  return Object.freeze({
@@ -18698,7 +18772,7 @@ import path10 from "node:path";
18698
18772
  import { open, realpath as realpath3 } from "node:fs/promises";
18699
18773
  var MAX_SESSION_HEADER_BYTES = 64 * 1024;
18700
18774
  var utf8Decoder = new TextDecoder("utf-8", { fatal: true });
18701
- function isRecord5(value) {
18775
+ function isRecord6(value) {
18702
18776
  return typeof value === "object" && value !== null && !Array.isArray(value);
18703
18777
  }
18704
18778
  async function readPiSessionHeader(sessionFile) {
@@ -18718,7 +18792,7 @@ async function readPiSessionHeader(sessionFile) {
18718
18792
  } catch {
18719
18793
  throw new Error("Pi Session header is not valid JSON");
18720
18794
  }
18721
- if (!isRecord5(parsed) || parsed.type !== "session" || typeof parsed.id !== "string" || parsed.id.length === 0 || typeof parsed.cwd !== "string" || parsed.cwd.length === 0) {
18795
+ if (!isRecord6(parsed) || parsed.type !== "session" || typeof parsed.id !== "string" || parsed.id.length === 0 || typeof parsed.cwd !== "string" || parsed.cwd.length === 0) {
18722
18796
  throw new Error("Pi Session header is invalid");
18723
18797
  }
18724
18798
  return {
@@ -19767,7 +19841,7 @@ var PiRpcUnsupportedCommandError = class extends Error {
19767
19841
  }
19768
19842
  };
19769
19843
  var textDecoder = new TextDecoder("utf-8", { fatal: true });
19770
- function isRecord6(value) {
19844
+ function isRecord7(value) {
19771
19845
  return typeof value === "object" && value !== null && !Array.isArray(value);
19772
19846
  }
19773
19847
  function message2(value) {
@@ -19779,13 +19853,13 @@ function nonBlankString(value) {
19779
19853
  function parseNativeModel(value, context) {
19780
19854
  if (value === null || value === void 0)
19781
19855
  return null;
19782
- if (!isRecord6(value) || !nonBlankString(value.provider) || !nonBlankString(value.id)) {
19856
+ if (!isRecord7(value) || !nonBlankString(value.provider) || !nonBlankString(value.id)) {
19783
19857
  throw new PiRpcFaultError("protocolError", `Pi RPC returned an invalid ${context} Model`);
19784
19858
  }
19785
19859
  return { provider: value.provider, id: value.id };
19786
19860
  }
19787
19861
  function sessionStateData(response) {
19788
- const data = isRecord6(response.data) ? response.data : null;
19862
+ const data = isRecord7(response.data) ? response.data : null;
19789
19863
  if (!data)
19790
19864
  throw new PiRpcFaultError("protocolError", "Pi RPC state response has no data");
19791
19865
  return data;
@@ -19817,13 +19891,13 @@ function parseSessionStreaming(response) {
19817
19891
  return isStreaming;
19818
19892
  }
19819
19893
  function parseSessionHistory(response) {
19820
- const data = isRecord6(response.data) ? response.data : null;
19894
+ const data = isRecord7(response.data) ? response.data : null;
19821
19895
  if (!data || !Array.isArray(data.entries)) {
19822
19896
  throw new PiRpcFaultError("protocolError", "Pi RPC entries response has no Entries");
19823
19897
  }
19824
19898
  const entries = data.entries.map((entry) => {
19825
19899
  const parsed = jsonValueSchema.safeParse(entry);
19826
- if (!parsed.success || !isRecord6(parsed.data)) {
19900
+ if (!parsed.success || !isRecord7(parsed.data)) {
19827
19901
  throw new PiRpcFaultError("protocolError", "Pi RPC entries response contains an invalid Entry");
19828
19902
  }
19829
19903
  return parsed.data;
@@ -19834,7 +19908,7 @@ function parseSessionHistory(response) {
19834
19908
  return { entries, leafId: data.leafId };
19835
19909
  }
19836
19910
  function parseAvailableThinkingLevels(response) {
19837
- const data = isRecord6(response.data) ? response.data : null;
19911
+ const data = isRecord7(response.data) ? response.data : null;
19838
19912
  if (!data || !Array.isArray(data.levels) || data.levels.length === 0) {
19839
19913
  throw new PiRpcFaultError("protocolError", "Pi RPC Thinking catalog response has no levels");
19840
19914
  }
@@ -19851,13 +19925,13 @@ function parseAvailableThinkingLevels(response) {
19851
19925
  return levels;
19852
19926
  }
19853
19927
  function parseAvailableModels(response) {
19854
- const data = isRecord6(response.data) ? response.data : null;
19928
+ const data = isRecord7(response.data) ? response.data : null;
19855
19929
  if (!data || !Array.isArray(data.models)) {
19856
19930
  throw new PiRpcFaultError("protocolError", "Pi RPC Model catalog response has no models");
19857
19931
  }
19858
19932
  return data.models.map((model2) => {
19859
19933
  const parsed = parseNativeModel(model2, "catalog");
19860
- if (!parsed || !isRecord6(model2) || typeof model2.reasoning !== "boolean") {
19934
+ if (!parsed || !isRecord7(model2) || typeof model2.reasoning !== "boolean") {
19861
19935
  throw new PiRpcFaultError("protocolError", "Pi RPC catalog contains a Model without reasoning capability");
19862
19936
  }
19863
19937
  return {
@@ -19868,17 +19942,17 @@ function parseAvailableModels(response) {
19868
19942
  });
19869
19943
  }
19870
19944
  function assistantText(value) {
19871
- if (!isRecord6(value) || value.role !== "assistant" || !Array.isArray(value.content))
19945
+ if (!isRecord7(value) || value.role !== "assistant" || !Array.isArray(value.content))
19872
19946
  return null;
19873
- return value.content.filter((content) => isRecord6(content) && content.type === "text" && typeof content.text === "string").map((content) => content.text).join("");
19947
+ return value.content.filter((content) => isRecord7(content) && content.type === "text" && typeof content.text === "string").map((content) => content.text).join("");
19874
19948
  }
19875
19949
  function assistantMessageId(value) {
19876
- if (!isRecord6(value) || value.role !== "assistant")
19950
+ if (!isRecord7(value) || value.role !== "assistant")
19877
19951
  return null;
19878
19952
  return nonBlankString(value.responseId) ? value.responseId : null;
19879
19953
  }
19880
19954
  function extractReasoningText(content) {
19881
- if (!isRecord6(content))
19955
+ if (!isRecord7(content))
19882
19956
  return null;
19883
19957
  const type = String(content.type ?? "");
19884
19958
  if (type === "thinking" || type === "reasoning" || type === "thought") {
@@ -19888,12 +19962,12 @@ function extractReasoningText(content) {
19888
19962
  return null;
19889
19963
  }
19890
19964
  function assistantReasoning(value) {
19891
- if (!isRecord6(value) || value.role !== "assistant" || !Array.isArray(value.content))
19965
+ if (!isRecord7(value) || value.role !== "assistant" || !Array.isArray(value.content))
19892
19966
  return null;
19893
19967
  return value.content.map(extractReasoningText).filter((text2) => typeof text2 === "string").join("");
19894
19968
  }
19895
19969
  function assistantFailure(value) {
19896
- if (!isRecord6(value) || value.role !== "assistant")
19970
+ if (!isRecord7(value) || value.role !== "assistant")
19897
19971
  return void 0;
19898
19972
  if (value.stopReason !== "error" && value.stopReason !== "aborted")
19899
19973
  return null;
@@ -19913,7 +19987,7 @@ function signalProcessTree(child, signal) {
19913
19987
  try {
19914
19988
  process.kill(-child.pid, signal);
19915
19989
  } catch (error51) {
19916
- if (!isRecord6(error51) || error51.code !== "ESRCH")
19990
+ if (!isRecord7(error51) || error51.code !== "ESRCH")
19917
19991
  throw error51;
19918
19992
  }
19919
19993
  }
@@ -20049,12 +20123,12 @@ var PiRpcSession = class {
20049
20123
  }
20050
20124
  if (value.type === "message_update") {
20051
20125
  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)) {
20126
+ if (this.#usageRequestStartedAtMs === null && isRecord7(event) && typeof event.type === "string" && /^(text|thinking|reasoning|thought|toolcall)_(start|delta)$/u.test(event.type)) {
20053
20127
  this.#usageRequestStartedAtMs = Date.now();
20054
20128
  }
20055
20129
  return;
20056
20130
  }
20057
- if (value.type === "message_end" && isRecord6(value.message)) {
20131
+ if (value.type === "message_end" && isRecord7(value.message)) {
20058
20132
  if (value.message.role !== "assistant")
20059
20133
  return;
20060
20134
  const startedAtMs = this.#usageRequestStartedAtMs;
@@ -20099,7 +20173,7 @@ var PiRpcSession = class {
20099
20173
  this.#stderrTail = sanitizeDiagnosticTail(`${this.#stderrTail}${chunk.toString()}`);
20100
20174
  });
20101
20175
  child.once("error", (error51) => {
20102
- const kind = isRecord6(error51) && error51.code === "ENOENT" ? "notInstalled" : "unavailable";
20176
+ const kind = isRecord7(error51) && error51.code === "ENOENT" ? "notInstalled" : "unavailable";
20103
20177
  this.#fail(new PiRpcFaultError(kind, `Pi RPC failed to start: ${error51.message}`, this.stderrTail));
20104
20178
  });
20105
20179
  child.once("exit", (code, signal) => {
@@ -20408,7 +20482,7 @@ var PiRpcSession = class {
20408
20482
  this.#buffer = this.#buffer.subarray(newline + 1);
20409
20483
  try {
20410
20484
  const value = JSON.parse(textDecoder.decode(frame));
20411
- if (!isRecord6(value) || typeof value.type !== "string") {
20485
+ if (!isRecord7(value) || typeof value.type !== "string") {
20412
20486
  throw new PiRpcFaultError("protocolError", "Pi RPC returned an invalid envelope");
20413
20487
  }
20414
20488
  this.#handle(value);
@@ -20455,7 +20529,7 @@ var PiRpcSession = class {
20455
20529
  this.#armCommandTimeout(id, pending);
20456
20530
  }
20457
20531
  }
20458
- const outcome = value.aborted === true ? "cancelled" : isRecord6(value.result) ? "succeeded" : "failed";
20532
+ const outcome = value.aborted === true ? "cancelled" : isRecord7(value.result) ? "succeeded" : "failed";
20459
20533
  const event = {
20460
20534
  type: "compaction.completed",
20461
20535
  outcome,
@@ -20493,12 +20567,12 @@ var PiRpcSession = class {
20493
20567
  this.#startAssistantMessage(active, value.message);
20494
20568
  return;
20495
20569
  }
20496
- if (value.type === "message_update" && isRecord6(value.assistantMessageEvent)) {
20570
+ if (value.type === "message_update" && isRecord7(value.assistantMessageEvent)) {
20497
20571
  const event = value.assistantMessageEvent;
20498
20572
  const eventType = String(event.type ?? "");
20499
20573
  const isThinking = eventType === "thinking_delta" || eventType === "reasoning_delta" || eventType === "thought_delta" || eventType === "thinking" || eventType === "reasoning";
20500
20574
  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;
20575
+ 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
20576
  if (isThinking && delta !== null && delta.length > 0) {
20503
20577
  const messageId = this.#ensureAssistantMessage(active, value.message);
20504
20578
  active.reasoningMessageOpen = true;
@@ -20831,7 +20905,7 @@ var PiRpcSession = class {
20831
20905
  return;
20832
20906
  }
20833
20907
  active.failure = failure;
20834
- if (active.origin === "autonomous" && isRecord6(value) && value.stopReason === "aborted") {
20908
+ if (active.origin === "autonomous" && isRecord7(value) && value.stopReason === "aborted") {
20835
20909
  active.nativeCancellationObserved = true;
20836
20910
  }
20837
20911
  this.#latestCacheHitRatePercent = cacheHitRatePercent;
@@ -20985,6 +21059,7 @@ var piCommandCatalog = harnessCommandCatalogSchema.parse({
20985
21059
  {
20986
21060
  id: "pi.compact",
20987
21061
  invocation: "/compact",
21062
+ localizations: { "zh-CN": { label: "压缩上下文", description: "压缩当前对话上下文" } },
20988
21063
  label: "Compact context",
20989
21064
  description: "Compact the current conversation context",
20990
21065
  argumentMode: "text"
@@ -20992,7 +21067,7 @@ var piCommandCatalog = harnessCommandCatalogSchema.parse({
20992
21067
  ]
20993
21068
  });
20994
21069
  var DEFAULT_TOOL_OUTPUT_LIMIT = 64e3;
20995
- function isRecord7(value) {
21070
+ function isRecord8(value) {
20996
21071
  return typeof value === "object" && value !== null && !Array.isArray(value);
20997
21072
  }
20998
21073
  function errorMessage(error51) {
@@ -21007,7 +21082,7 @@ var PiAdapterFaultError = class extends Error {
21007
21082
  }
21008
21083
  };
21009
21084
  function normalizedError(error51, fallbackCode) {
21010
- if (isRecord7(error51) && error51.code === "ENOENT") {
21085
+ if (isRecord8(error51) && error51.code === "ENOENT") {
21011
21086
  return { code: "notInstalled", message: errorMessage(error51), retryable: false };
21012
21087
  }
21013
21088
  if (error51 instanceof PiAdapterFaultError)
@@ -21070,7 +21145,7 @@ function nativeModelForHistory(state2) {
21070
21145
  return nativeModelFromState(state2);
21071
21146
  }
21072
21147
  function sessionFileFromRef(ref) {
21073
- if (ref.harnessId !== piHarnessId2 || !isRecord7(ref.locator) || typeof ref.locator.sessionFile !== "string" || ref.locator.sessionFile.length === 0) {
21148
+ if (ref.harnessId !== piHarnessId2 || !isRecord8(ref.locator) || typeof ref.locator.sessionFile !== "string" || ref.locator.sessionFile.length === 0) {
21074
21149
  throw new Error("Pi Native Session Ref has no resumable Session file");
21075
21150
  }
21076
21151
  return ref.locator.sessionFile;
@@ -21085,9 +21160,9 @@ function toolFailure(toolName) {
21085
21160
  function nativeText(value) {
21086
21161
  if (typeof value === "string")
21087
21162
  return value;
21088
- if (!isRecord7(value) || !Array.isArray(value.content))
21163
+ if (!isRecord8(value) || !Array.isArray(value.content))
21089
21164
  return "";
21090
- return value.content.filter((content) => isRecord7(content) && content.type === "text" && typeof content.text === "string").map(({ text: text2 }) => text2).join("");
21165
+ return value.content.filter((content) => isRecord8(content) && content.type === "text" && typeof content.text === "string").map(({ text: text2 }) => text2).join("");
21091
21166
  }
21092
21167
  function boundedOutput(value, limit) {
21093
21168
  const text2 = nativeText(value);
@@ -21103,17 +21178,17 @@ function outputText(output) {
21103
21178
  return output?.content.filter((content) => content.type === "text").map(({ text: text2 }) => text2).join("") ?? "";
21104
21179
  }
21105
21180
  function stringField(value, key) {
21106
- if (!isRecord7(value))
21181
+ if (!isRecord8(value))
21107
21182
  return void 0;
21108
21183
  const field = value[key];
21109
21184
  if (typeof field === "string" && field.length > 0)
21110
21185
  return field;
21111
- if (isRecord7(value.input)) {
21186
+ if (isRecord8(value.input)) {
21112
21187
  const nested = value.input[key];
21113
21188
  if (typeof nested === "string" && nested.length > 0)
21114
21189
  return nested;
21115
21190
  }
21116
- if (isRecord7(value.arguments)) {
21191
+ if (isRecord8(value.arguments)) {
21117
21192
  const nested = value.arguments[key];
21118
21193
  if (typeof nested === "string" && nested.length > 0)
21119
21194
  return nested;
@@ -21121,7 +21196,7 @@ function stringField(value, key) {
21121
21196
  return void 0;
21122
21197
  }
21123
21198
  function numberField(value, key) {
21124
- if (!isRecord7(value))
21199
+ if (!isRecord8(value))
21125
21200
  return void 0;
21126
21201
  const field = value[key];
21127
21202
  return typeof field === "number" || field === null ? field : void 0;
@@ -21196,7 +21271,7 @@ function fileMutatingKind(toolName) {
21196
21271
  return null;
21197
21272
  }
21198
21273
  function nestedToolString(value, keys) {
21199
- if (!isRecord7(value))
21274
+ if (!isRecord8(value))
21200
21275
  return void 0;
21201
21276
  for (const key of keys) {
21202
21277
  const field = value[key];
@@ -21211,14 +21286,14 @@ function nestedToolString(value, keys) {
21211
21286
  return void 0;
21212
21287
  }
21213
21288
  function patchFromResult(result) {
21214
- if (!isRecord7(result))
21289
+ if (!isRecord8(result))
21215
21290
  return void 0;
21216
21291
  for (const key of ["patch", "diff", "unifiedDiff"]) {
21217
21292
  const field = result[key];
21218
21293
  if (typeof field === "string" && field.length > 0)
21219
21294
  return field;
21220
21295
  }
21221
- if (isRecord7(result.details)) {
21296
+ if (isRecord8(result.details)) {
21222
21297
  for (const key of ["patch", "diff", "unifiedDiff"]) {
21223
21298
  const field = result.details[key];
21224
21299
  if (typeof field === "string" && field.length > 0)
@@ -22236,7 +22311,7 @@ var PiHarnessSession = class {
22236
22311
  type: "question",
22237
22312
  interactionId,
22238
22313
  turnId: active.command.turnId,
22239
- ...associatedTool ? { itemId: associatedTool.item.itemId } : {},
22314
+ ...associatedTool?.item.type === "toolExecution" ? { itemId: associatedTool.item.itemId } : {},
22240
22315
  title: "Pi",
22241
22316
  questions: [question],
22242
22317
  ...request.timeoutMs !== void 0 ? { expiresAt: new Date(Date.now() + request.timeoutMs).toISOString() } : {}