@liberseek/boft-cli-win32-arm64 0.7.3 → 0.7.5

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.
@@ -527,6 +527,7 @@ function splitLines(text) {
527
527
 
528
528
  // dist/omp-adapter.js
529
529
  import { randomUUID as randomUUID2 } from "node:crypto";
530
+ import { realpath as realpath2, stat } from "node:fs/promises";
530
531
  import path4 from "node:path";
531
532
 
532
533
  // ../../../node_modules/zod/v4/classic/external.js
@@ -16736,6 +16737,100 @@ function resolveOmpForkBoundary(history, checkpointId) {
16736
16737
  };
16737
16738
  }
16738
16739
 
16740
+ // dist/omp-session-file.js
16741
+ import { createReadStream } from "node:fs";
16742
+ import { open, realpath } from "node:fs/promises";
16743
+ import readline from "node:readline";
16744
+ var MAX_SESSION_HEADER_BYTES = 64 * 1024;
16745
+ var utf8Decoder = new TextDecoder("utf-8", { fatal: true });
16746
+ function isRecord5(value) {
16747
+ return typeof value === "object" && value !== null && !Array.isArray(value);
16748
+ }
16749
+ function historyEntry(value) {
16750
+ if (!isRecord5(value) || value.type === "title" || value.type === "session" || typeof value.id !== "string" || value.id.length === 0 || value.parentId !== null && typeof value.parentId !== "string" || typeof value.type !== "string") {
16751
+ return null;
16752
+ }
16753
+ return value;
16754
+ }
16755
+ async function readOmpSessionHistory(sessionFile, maxBytes) {
16756
+ const entries = [];
16757
+ let leafId = null;
16758
+ const lines = readline.createInterface({
16759
+ input: createReadStream(sessionFile, {
16760
+ encoding: "utf8",
16761
+ ...maxBytes === void 0 ? {} : { end: maxBytes - 1 }
16762
+ }),
16763
+ crlfDelay: Number.POSITIVE_INFINITY
16764
+ });
16765
+ try {
16766
+ for await (const line of lines) {
16767
+ if (line.length === 0)
16768
+ continue;
16769
+ let parsed;
16770
+ try {
16771
+ parsed = JSON.parse(line);
16772
+ } catch {
16773
+ continue;
16774
+ }
16775
+ const entry = historyEntry(parsed);
16776
+ if (!entry)
16777
+ continue;
16778
+ entries.push(entry);
16779
+ leafId = entry.id;
16780
+ }
16781
+ } finally {
16782
+ lines.close();
16783
+ }
16784
+ return { entries, leafId };
16785
+ }
16786
+ async function readOmpSessionHeader(sessionFile) {
16787
+ const handle = await open(sessionFile, "r");
16788
+ try {
16789
+ const buffer = Buffer.allocUnsafe(MAX_SESSION_HEADER_BYTES);
16790
+ const { bytesRead } = await handle.read(buffer, 0, buffer.length, 0);
16791
+ const contents = buffer.subarray(0, bytesRead);
16792
+ const newline = contents.indexOf(10);
16793
+ if (newline < 0 && bytesRead === buffer.length) {
16794
+ throw new Error("Omp Session header exceeds the supported size");
16795
+ }
16796
+ const contentsText = utf8Decoder.decode(contents);
16797
+ for (const line of contentsText.split("\n")) {
16798
+ if (line.length === 0)
16799
+ continue;
16800
+ let parsed;
16801
+ try {
16802
+ parsed = JSON.parse(line);
16803
+ } catch {
16804
+ continue;
16805
+ }
16806
+ if (!isRecord5(parsed) || parsed.type !== "session")
16807
+ continue;
16808
+ if (typeof parsed.id !== "string" || parsed.id.length === 0 || typeof parsed.cwd !== "string" || parsed.cwd.length === 0) {
16809
+ throw new Error("Omp Session header is invalid");
16810
+ }
16811
+ return { type: "session", id: parsed.id, cwd: parsed.cwd };
16812
+ }
16813
+ throw new Error("Omp Session header is invalid");
16814
+ } finally {
16815
+ await handle.close();
16816
+ }
16817
+ }
16818
+ async function verifyOmpSessionCwd(input) {
16819
+ if (!input.sessionFile)
16820
+ throw new Error("Omp Fork Session has no persisted Session file");
16821
+ const header = await readOmpSessionHeader(input.sessionFile);
16822
+ if (header.id !== input.sessionId) {
16823
+ throw new Error("Omp Fork Session header identity does not match RPC state");
16824
+ }
16825
+ const [actualCwd, expectedCwd] = await Promise.all([
16826
+ realpath(header.cwd),
16827
+ realpath(input.expectedCwd)
16828
+ ]);
16829
+ if (actualCwd !== expectedCwd) {
16830
+ throw new Error("Omp Fork Session did not bind the requested cwd");
16831
+ }
16832
+ }
16833
+
16739
16834
  // dist/omp-last-turn-rollback.js
16740
16835
  function modelFromState(state) {
16741
16836
  if (state.provider === null && state.modelId === null)
@@ -17043,14 +17138,14 @@ function resolveOmpExecutable(input, dependencies = {}) {
17043
17138
  }
17044
17139
 
17045
17140
  // dist/omp-usage.js
17046
- function isRecord5(value) {
17141
+ function isRecord6(value) {
17047
17142
  return typeof value === "object" && value !== null && !Array.isArray(value);
17048
17143
  }
17049
17144
  function nonNegativeSafeInteger(value) {
17050
17145
  return typeof value === "number" && Number.isSafeInteger(value) && value >= 0 ? value : null;
17051
17146
  }
17052
17147
  function optionalOmpCacheHitRatePercent(value) {
17053
- if (!isRecord5(value) || value.role !== "assistant" || !isRecord5(value.usage))
17148
+ if (!isRecord6(value) || value.role !== "assistant" || !isRecord6(value.usage))
17054
17149
  return null;
17055
17150
  const input = nonNegativeSafeInteger(value.usage.input);
17056
17151
  const cacheRead = nonNegativeSafeInteger(value.usage.cacheRead);
@@ -17063,20 +17158,20 @@ function optionalOmpCacheHitRatePercent(value) {
17063
17158
  function latestOmpCacheHitRatePercent(history) {
17064
17159
  let latest = null;
17065
17160
  for (const entry of activeOmpEntries(history)) {
17066
- if (entry.type === "message" && isRecord5(entry.message) && entry.message.role === "assistant") {
17161
+ if (entry.type === "message" && isRecord6(entry.message) && entry.message.role === "assistant") {
17067
17162
  latest = optionalOmpCacheHitRatePercent(entry.message);
17068
17163
  }
17069
17164
  }
17070
17165
  return latest;
17071
17166
  }
17072
17167
  function responseData(response, operation) {
17073
- if (!isRecord5(response.data)) {
17168
+ if (!isRecord6(response.data)) {
17074
17169
  throw new Error(`Omp RPC ${operation} response has no data`);
17075
17170
  }
17076
17171
  return response.data;
17077
17172
  }
17078
17173
  function contextUsage(value) {
17079
- if (!isRecord5(value))
17174
+ if (!isRecord6(value))
17080
17175
  throw new Error("Omp RPC context Usage is invalid");
17081
17176
  return parseHostUsage({
17082
17177
  contextUsedTokens: value.tokens,
@@ -17086,15 +17181,15 @@ function contextUsage(value) {
17086
17181
  function parseOmpSessionUsage(response) {
17087
17182
  const data = responseData(response, "Session stats");
17088
17183
  const tokens = data.tokens;
17089
- if (tokens !== void 0 && !isRecord5(tokens)) {
17184
+ if (tokens !== void 0 && !isRecord6(tokens)) {
17090
17185
  throw new Error("Omp RPC Session stats tokens are invalid");
17091
17186
  }
17092
17187
  return parseHostUsage({
17093
- ...isRecord5(tokens) && tokens.input !== void 0 ? { inputTokens: tokens.input } : {},
17094
- ...isRecord5(tokens) && tokens.cacheRead !== void 0 ? { cachedInputTokens: tokens.cacheRead } : {},
17095
- ...isRecord5(tokens) && tokens.cacheWrite !== void 0 ? { cacheWriteInputTokens: tokens.cacheWrite } : {},
17096
- ...isRecord5(tokens) && tokens.output !== void 0 ? { outputTokens: tokens.output } : {},
17097
- ...isRecord5(tokens) && tokens.total !== void 0 ? { totalTokens: tokens.total } : {},
17188
+ ...isRecord6(tokens) && tokens.input !== void 0 ? { inputTokens: tokens.input } : {},
17189
+ ...isRecord6(tokens) && tokens.cacheRead !== void 0 ? { cachedInputTokens: tokens.cacheRead } : {},
17190
+ ...isRecord6(tokens) && tokens.cacheWrite !== void 0 ? { cacheWriteInputTokens: tokens.cacheWrite } : {},
17191
+ ...isRecord6(tokens) && tokens.output !== void 0 ? { outputTokens: tokens.output } : {},
17192
+ ...isRecord6(tokens) && tokens.total !== void 0 ? { totalTokens: tokens.total } : {},
17098
17193
  ...data.cost !== void 0 ? { totalCostUsd: data.cost } : {},
17099
17194
  ...data.contextUsage !== void 0 ? contextUsage(data.contextUsage) : {}
17100
17195
  });
@@ -17113,97 +17208,6 @@ function optionalOmpStateContextUsage(value) {
17113
17208
  }
17114
17209
  }
17115
17210
 
17116
- // dist/omp-session-file.js
17117
- import { createReadStream } from "node:fs";
17118
- import { open, realpath } from "node:fs/promises";
17119
- import readline from "node:readline";
17120
- var MAX_SESSION_HEADER_BYTES = 64 * 1024;
17121
- var utf8Decoder = new TextDecoder("utf-8", { fatal: true });
17122
- function isRecord6(value) {
17123
- return typeof value === "object" && value !== null && !Array.isArray(value);
17124
- }
17125
- function historyEntry(value) {
17126
- if (!isRecord6(value) || value.type === "title" || value.type === "session" || typeof value.id !== "string" || value.id.length === 0 || value.parentId !== null && typeof value.parentId !== "string" || typeof value.type !== "string") {
17127
- return null;
17128
- }
17129
- return value;
17130
- }
17131
- async function readOmpSessionHistory(sessionFile) {
17132
- const entries = [];
17133
- let leafId = null;
17134
- const lines = readline.createInterface({
17135
- input: createReadStream(sessionFile, { encoding: "utf8" }),
17136
- crlfDelay: Number.POSITIVE_INFINITY
17137
- });
17138
- try {
17139
- for await (const line of lines) {
17140
- if (line.length === 0)
17141
- continue;
17142
- let parsed;
17143
- try {
17144
- parsed = JSON.parse(line);
17145
- } catch {
17146
- continue;
17147
- }
17148
- const entry = historyEntry(parsed);
17149
- if (!entry)
17150
- continue;
17151
- entries.push(entry);
17152
- leafId = entry.id;
17153
- }
17154
- } finally {
17155
- lines.close();
17156
- }
17157
- return { entries, leafId };
17158
- }
17159
- async function readOmpSessionHeader(sessionFile) {
17160
- const handle = await open(sessionFile, "r");
17161
- try {
17162
- const buffer = Buffer.allocUnsafe(MAX_SESSION_HEADER_BYTES);
17163
- const { bytesRead } = await handle.read(buffer, 0, buffer.length, 0);
17164
- const contents = buffer.subarray(0, bytesRead);
17165
- const newline = contents.indexOf(10);
17166
- if (newline < 0 && bytesRead === buffer.length) {
17167
- throw new Error("Omp Session header exceeds the supported size");
17168
- }
17169
- const contentsText = utf8Decoder.decode(contents);
17170
- for (const line of contentsText.split("\n")) {
17171
- if (line.length === 0)
17172
- continue;
17173
- let parsed;
17174
- try {
17175
- parsed = JSON.parse(line);
17176
- } catch {
17177
- continue;
17178
- }
17179
- if (!isRecord6(parsed) || parsed.type !== "session")
17180
- continue;
17181
- if (typeof parsed.id !== "string" || parsed.id.length === 0 || typeof parsed.cwd !== "string" || parsed.cwd.length === 0) {
17182
- throw new Error("Omp Session header is invalid");
17183
- }
17184
- return { type: "session", id: parsed.id, cwd: parsed.cwd };
17185
- }
17186
- throw new Error("Omp Session header is invalid");
17187
- } finally {
17188
- await handle.close();
17189
- }
17190
- }
17191
- async function verifyOmpSessionCwd(input) {
17192
- if (!input.sessionFile)
17193
- throw new Error("Omp Fork Session has no persisted Session file");
17194
- const header = await readOmpSessionHeader(input.sessionFile);
17195
- if (header.id !== input.sessionId) {
17196
- throw new Error("Omp Fork Session header identity does not match RPC state");
17197
- }
17198
- const [actualCwd, expectedCwd] = await Promise.all([
17199
- realpath(header.cwd),
17200
- realpath(input.expectedCwd)
17201
- ]);
17202
- if (actualCwd !== expectedCwd) {
17203
- throw new Error("Omp Fork Session did not bind the requested cwd");
17204
- }
17205
- }
17206
-
17207
17211
  // dist/omp-protocol.js
17208
17212
  var MAX_FRAME_BYTES = 1024 * 1024;
17209
17213
  var MAX_REASSEMBLED_BYTES = 64 * 1024 * 1024;
@@ -17598,6 +17602,9 @@ var OmpRpcSession = class {
17598
17602
  new Promise((_resolve, reject) => setTimeout(() => reject(new Error("Omp RPC ready signal timed out")), this.#options.commandTimeoutMs))
17599
17603
  ]);
17600
17604
  await this.#send("negotiate_protocol", { protocolVersion: 2 }).catch(() => void 0);
17605
+ if (this.#options.subscribeSubagentEvents !== false) {
17606
+ await this.#send("set_subagent_subscription", { level: "events" }).catch(() => void 0);
17607
+ }
17601
17608
  try {
17602
17609
  this.#state = parseSessionState(await this.#send("get_state", {}));
17603
17610
  } catch (error51) {
@@ -18743,6 +18750,46 @@ function sessionFileFromRef(ref) {
18743
18750
  }
18744
18751
  return ref.locator.sessionFile;
18745
18752
  }
18753
+ var MAX_SUBAGENT_TRANSCRIPT_BYTES = 8 * 1024 * 1024;
18754
+ function subagentTranscriptPath(parentSessionFile, nativeSubagentId) {
18755
+ if (nativeSubagentId.includes("/") || nativeSubagentId.includes("\\") || nativeSubagentId.includes("\0") || nativeSubagentId === "." || nativeSubagentId === "..") {
18756
+ throw new Error("Omp Subagent ID is not a plain transcript file name");
18757
+ }
18758
+ if (!parentSessionFile.endsWith(".jsonl") || !path4.isAbsolute(parentSessionFile)) {
18759
+ return null;
18760
+ }
18761
+ return `${parentSessionFile.slice(0, -".jsonl".length)}/${nativeSubagentId}.jsonl`;
18762
+ }
18763
+ async function readSubagentTranscriptFile(parentSessionFile, nativeSubagentId) {
18764
+ const transcriptFile = subagentTranscriptPath(parentSessionFile, nativeSubagentId);
18765
+ if (transcriptFile === null)
18766
+ return { status: "missing" };
18767
+ const parentDirectory = path4.dirname(transcriptFile);
18768
+ let metadata;
18769
+ try {
18770
+ metadata = await stat(transcriptFile);
18771
+ } catch (error51) {
18772
+ if (error51.code === "ENOENT")
18773
+ return { status: "missing" };
18774
+ throw error51;
18775
+ }
18776
+ if (!metadata.isFile())
18777
+ return { status: "missing" };
18778
+ if (metadata.size > MAX_SUBAGENT_TRANSCRIPT_BYTES) {
18779
+ throw new Error("Omp Subagent transcript exceeds the supported size");
18780
+ }
18781
+ const [resolvedTranscript, resolvedParentDirectory] = await Promise.all([
18782
+ realpath2(transcriptFile),
18783
+ realpath2(parentDirectory)
18784
+ ]);
18785
+ if (path4.dirname(resolvedTranscript) !== resolvedParentDirectory) {
18786
+ throw new Error("Omp Subagent transcript resolves outside its parent Session directory");
18787
+ }
18788
+ return {
18789
+ status: "read",
18790
+ history: await readOmpSessionHistory(transcriptFile, MAX_SUBAGENT_TRANSCRIPT_BYTES)
18791
+ };
18792
+ }
18746
18793
  function toolFailure(toolName) {
18747
18794
  return {
18748
18795
  code: "nativeFailure",
@@ -20349,9 +20396,18 @@ var OmpAdapter = class {
20349
20396
  }
20350
20397
  let transport;
20351
20398
  try {
20399
+ const transcriptFile = await readSubagentTranscriptFile(sessionFileFromRef(input.parent), input.nativeSubagentId);
20400
+ if (transcriptFile.status === "read") {
20401
+ const snapshot2 = mapOmpSnapshot(transcriptFile.history, {
20402
+ sessionId: input.parent.nativeSessionId,
20403
+ model: null
20404
+ });
20405
+ return { ok: true, value: snapshot2 };
20406
+ }
20352
20407
  transport = this.#createTransport({
20353
20408
  cwd: input.cwd,
20354
20409
  sessionFile: sessionFileFromRef(input.parent),
20410
+ subscribeSubagentEvents: false,
20355
20411
  onFault: () => void 0
20356
20412
  });
20357
20413
  await transport.start();
@@ -20423,7 +20479,11 @@ var OmpAdapter = class {
20423
20479
  async #inspectCwd(cwd) {
20424
20480
  const startedAt = Date.now();
20425
20481
  let stage = "spawn";
20426
- const transport = this.#createTransport({ cwd, onFault: () => void 0 });
20482
+ const transport = this.#createTransport({
20483
+ cwd,
20484
+ subscribeSubagentEvents: false,
20485
+ onFault: () => void 0
20486
+ });
20427
20487
  this.#inspections.add(transport);
20428
20488
  try {
20429
20489
  stage = "startup";