@liberseek/boft-cli-linux-x64 0.7.8 → 0.7.9

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.
@@ -15007,6 +15007,10 @@ var hostTurnIdSchema = opaqueIdSchema.brand();
15007
15007
  var hostItemIdSchema = opaqueIdSchema.brand();
15008
15008
  var hostInteractionIdSchema = opaqueIdSchema.brand();
15009
15009
 
15010
+ // ../../shared-contracts/dist/thread-prewarm.js
15011
+ var threadPrewarmDiscardParamsSchema = external_exports.object({ threadId: hostThreadIdSchema });
15012
+ var threadPrewarmDiscardResultSchema = external_exports.object({ discarded: external_exports.boolean() });
15013
+
15010
15014
  // ../../shared-contracts/dist/harness-plugins.js
15011
15015
  var HARNESS_PLUGIN_MANIFEST_MAX_BYTES = 32 * 1024;
15012
15016
  var HARNESS_PLUGIN_ICON_MAX_BYTES = 128 * 1024;
@@ -15074,6 +15078,9 @@ var consoleOpenResultSchema = external_exports.strictObject({
15074
15078
  url: external_exports.string().max(2048).regex(/^http:\/\/(?:127\.0\.0\.1|localhost):\d{1,5}\/(?:\?.*)?$/u)
15075
15079
  });
15076
15080
  var CONSOLE_HOST_METHODS = Object.freeze([
15081
+ "codexhost/console/remote-connections",
15082
+ "codexhost/runtime/status",
15083
+ "codexhost/remote/ssh-setup",
15077
15084
  "codexhost/harness/plugins/list",
15078
15085
  "codexhost/harness/display-settings/get",
15079
15086
  "codexhost/harness/display-settings/set",
@@ -16019,6 +16026,80 @@ var updateStatusResultSchema = external_exports.strictObject({
16019
16026
  status: updateStatusSchema.nullable()
16020
16027
  });
16021
16028
 
16029
+ // ../../shared-contracts/dist/remote-runtime.js
16030
+ var remoteUpdatePhaseSchema = external_exports.enum([
16031
+ "idle",
16032
+ "installing",
16033
+ "restarting",
16034
+ "succeeded",
16035
+ "failed"
16036
+ ]);
16037
+ var runtimeStatusSchema = external_exports.object({
16038
+ runningVersion: external_exports.string().nullable(),
16039
+ installedVersion: external_exports.string().nullable(),
16040
+ restartRequired: external_exports.boolean(),
16041
+ remote: external_exports.boolean(),
16042
+ updateSupported: external_exports.boolean(),
16043
+ update: external_exports.object({
16044
+ phase: remoteUpdatePhaseSchema,
16045
+ targetVersion: external_exports.string().nullable(),
16046
+ error: external_exports.string().nullable()
16047
+ })
16048
+ });
16049
+ var remoteUpdateParamsSchema = external_exports.object({
16050
+ version: external_exports.string().regex(/^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?$/u)
16051
+ }).strict();
16052
+ var remoteSshSetupParamsSchema = external_exports.object({
16053
+ hostname: external_exports.string().min(1).max(1024).refine((value) => !value.startsWith("-") && !/\s/u.test(value)),
16054
+ port: external_exports.number().int().min(1).max(65535).nullable(),
16055
+ identity: external_exports.string().max(4096).nullable(),
16056
+ action: external_exports.enum(["inspect", "install", "update", "repair", "uninstall"]),
16057
+ uninstallPackage: external_exports.boolean().optional(),
16058
+ version: external_exports.string().regex(/^\d+\.\d+\.\d+$/u).nullable()
16059
+ }).strict();
16060
+ var remoteSshSetupResultSchema = external_exports.object({ state: external_exports.enum(["installed", "not-installed"]) }).strict();
16061
+
16062
+ // ../../shared-contracts/dist/remote-connections.js
16063
+ var hostId = external_exports.string().min(1).max(1024);
16064
+ var codexSshConnectionSchema = external_exports.object({
16065
+ hostId,
16066
+ displayName: external_exports.string().min(1).max(1024),
16067
+ source: external_exports.enum(["codex-managed", "discovered"]),
16068
+ sshAlias: external_exports.string().max(1024).nullable(),
16069
+ sshHost: external_exports.string().min(1).max(1024),
16070
+ sshPort: external_exports.number().int().min(1).max(65535).nullable(),
16071
+ identity: external_exports.string().max(4096).nullable(),
16072
+ autoConnect: external_exports.boolean(),
16073
+ connectionAnalyticsId: external_exports.string().max(1024).optional()
16074
+ });
16075
+ var codexSshDraftSchema = external_exports.strictObject({
16076
+ displayName: external_exports.string().min(1).max(1024),
16077
+ hostname: external_exports.string().min(1).max(1024),
16078
+ sshPort: external_exports.number().int().min(1).max(65535).nullable(),
16079
+ identity: external_exports.string().max(4096).nullable()
16080
+ });
16081
+ var remoteConnectionsRequestSchema = external_exports.discriminatedUnion("action", [
16082
+ external_exports.strictObject({ action: external_exports.literal("list") }),
16083
+ external_exports.strictObject({
16084
+ action: external_exports.literal("save"),
16085
+ draft: codexSshDraftSchema,
16086
+ previous: codexSshConnectionSchema.nullable()
16087
+ }),
16088
+ external_exports.strictObject({ action: external_exports.literal("remove"), previous: codexSshConnectionSchema }),
16089
+ external_exports.strictObject({ action: external_exports.literal("connect"), hostId, enabled: external_exports.boolean() }),
16090
+ external_exports.strictObject({ action: external_exports.literal("state"), hostId }),
16091
+ external_exports.strictObject({ action: external_exports.literal("runtime"), hostId }),
16092
+ external_exports.strictObject({
16093
+ action: external_exports.literal("update"),
16094
+ hostId: hostId.refine((id) => id !== "local"),
16095
+ version: remoteUpdateParamsSchema.shape.version
16096
+ })
16097
+ ]);
16098
+ var remoteConnectionsReplySchema = external_exports.union([
16099
+ external_exports.strictObject({ result: jsonValueSchema }),
16100
+ external_exports.strictObject({ error: external_exports.strictObject({ code: external_exports.number().int(), message: external_exports.string() }) })
16101
+ ]);
16102
+
16022
16103
  // ../../shared-contracts/dist/index.js
16023
16104
  var workspaceContractVersionSchema = external_exports.literal(WORKSPACE_CONTRACT_VERSION);
16024
16105
 
@@ -18655,20 +18736,105 @@ import { opendir, realpath as realpath3, stat } from "node:fs/promises";
18655
18736
  import os3 from "node:os";
18656
18737
  import path11 from "node:path";
18657
18738
  import { createInterface as createInterface2 } from "node:readline";
18658
- var PiSessionChangedError = class extends Error {
18659
- constructor() {
18660
- super("Pi Session changed during discovery; refresh and retry");
18739
+
18740
+ // ../../harness-adapter/dist/session-import.js
18741
+ var SessionImportChangedError = class extends Error {
18742
+ constructor(message3 = "Native Session changed during discovery; refresh and retry") {
18743
+ super(message3);
18744
+ this.name = "SessionImportChangedError";
18661
18745
  }
18662
18746
  };
18663
- function sameFile(left, right) {
18664
- return left.size === right.size && left.mtimeMs === right.mtimeMs && left.ctimeMs === right.ctimeMs && left.ino === right.ino && left.dev === right.dev;
18747
+ function isMissingFileError(error51) {
18748
+ return typeof error51 === "object" && error51 !== null && "code" in error51 && error51.code === "ENOENT";
18749
+ }
18750
+ function sameFileFingerprint(left, right) {
18751
+ return left === null || right === null ? left === right : left.dev === right.dev && left.ino === right.ino && left.size === right.size && left.mtimeMs === right.mtimeMs && left.ctimeMs === right.ctimeMs;
18665
18752
  }
18753
+ function sessionImportTitle(value, maxLength = HARNESS_SESSION_IMPORT_TITLE_MAX_LENGTH) {
18754
+ if (typeof value !== "string")
18755
+ return null;
18756
+ const normalized = value.replaceAll("\0", "").replaceAll(/\s+/gu, " ").trim();
18757
+ if (!normalized)
18758
+ return null;
18759
+ if (normalized.length <= maxLength)
18760
+ return normalized;
18761
+ const characters = [...normalized];
18762
+ if (characters.length <= maxLength)
18763
+ return normalized;
18764
+ return `${characters.slice(0, maxLength - 1).join("").trimEnd()}…`;
18765
+ }
18766
+ function sessionImportCandidate(input) {
18767
+ const time3 = typeof input.updatedAt === "number" ? input.updatedAt : typeof input.updatedAt === "string" ? Date.parse(input.updatedAt) : Number.NaN;
18768
+ const parsed = harnessSessionImportCandidateSchema.safeParse({
18769
+ nativeSessionId: input.nativeSessionId,
18770
+ cwd: input.cwd,
18771
+ title: typeof input.title === "string" && input.title.trim().length > 0 ? input.title : null,
18772
+ updatedAt: Math.floor(time3),
18773
+ // Unknown must stay unknown; only an explicit boolean is a native statement.
18774
+ running: typeof input.running === "boolean" ? input.running : null
18775
+ });
18776
+ return parsed.success ? parsed.data : null;
18777
+ }
18778
+ var SessionImportScope = class {
18779
+ #abort = new AbortController();
18780
+ #options;
18781
+ #pending = /* @__PURE__ */ new Set();
18782
+ constructor(options) {
18783
+ this.#options = options;
18784
+ }
18785
+ #closed() {
18786
+ return {
18787
+ ok: false,
18788
+ error: { code: "invalidState", message: this.#options.closedMessage, retryable: false }
18789
+ };
18790
+ }
18791
+ read(operation) {
18792
+ const signal = this.#abort.signal;
18793
+ if (signal.aborted)
18794
+ return Promise.resolve(this.#closed());
18795
+ let started;
18796
+ try {
18797
+ started = operation(signal);
18798
+ } catch (error51) {
18799
+ started = Promise.reject(error51 instanceof Error ? error51 : new Error("Session read failed"));
18800
+ }
18801
+ const request = started.then((value) => signal.aborted ? this.#closed() : { ok: true, value }).catch(() => signal.aborted ? this.#closed() : {
18802
+ ok: false,
18803
+ error: {
18804
+ code: "unavailable",
18805
+ message: this.#options.unavailableMessage,
18806
+ retryable: true
18807
+ }
18808
+ }).finally(() => this.#pending.delete(request));
18809
+ this.#pending.add(request);
18810
+ return request;
18811
+ }
18812
+ /** `read` for `resolveCandidate`: a null source is the selected Session having disappeared. */
18813
+ async resolve(operation) {
18814
+ const result = await this.read(operation);
18815
+ if (!result.ok)
18816
+ return result;
18817
+ return result.value ? { ok: true, value: result.value } : {
18818
+ ok: false,
18819
+ error: {
18820
+ code: "sessionNotFound",
18821
+ message: this.#options.notFoundMessage,
18822
+ retryable: false
18823
+ }
18824
+ };
18825
+ }
18826
+ /** Idempotent. Resolves after every started read has settled. */
18827
+ async close() {
18828
+ this.#abort.abort();
18829
+ await Promise.allSettled(this.#pending);
18830
+ }
18831
+ };
18832
+
18833
+ // dist/pi-session-import.js
18834
+ var PI_SESSION_CHANGED = "Pi Session changed during discovery; refresh and retry";
18666
18835
  function isRecord4(value) {
18667
18836
  return typeof value === "object" && value !== null && !Array.isArray(value);
18668
18837
  }
18669
- function missing(error51) {
18670
- return isRecord4(error51) && error51.code === "ENOENT";
18671
- }
18672
18838
  function expandDirectory(value, home) {
18673
18839
  return path11.resolve(value === "~" ? home : value.startsWith(`~${path11.sep}`) || value.startsWith("~/") ? path11.join(home, value.slice(2)) : value);
18674
18840
  }
@@ -18688,7 +18854,7 @@ async function sessionFiles(directory, flat, signal) {
18688
18854
  const visit = async (dir, projectLevel) => {
18689
18855
  signal.throwIfAborted();
18690
18856
  const entries = await opendir(dir).catch((error51) => {
18691
- if (missing(error51))
18857
+ if (isMissingFileError(error51))
18692
18858
  return null;
18693
18859
  throw error51;
18694
18860
  });
@@ -18743,12 +18909,12 @@ async function readCandidate(file2, signal) {
18743
18909
  if (!firstMessage && entry.type === "message" && message3?.role === "user") {
18744
18910
  const content = message3.content;
18745
18911
  const text2 = typeof content === "string" ? content : Array.isArray(content) ? content.filter((block) => isRecord4(block) && block.type === "text" && typeof block.text === "string").map((block) => block.text).join(" ") : "";
18746
- firstMessage = text2.replaceAll("\0", "").trim().slice(0, HARNESS_SESSION_IMPORT_TITLE_MAX_LENGTH) || null;
18912
+ firstMessage = sessionImportTitle(text2);
18747
18913
  }
18748
18914
  hasUser = entry.type === "message" && message3?.role === "user" || typeof entry.parentId === "string" && entries.get(entry.parentId) === true;
18749
18915
  entries.set(entry.id, hasUser);
18750
18916
  if (entry.type === "session_info")
18751
- name = typeof entry.name === "string" ? entry.name.trim() || null : null;
18917
+ name = sessionImportTitle(entry.name);
18752
18918
  if (entry.type === "message" && (message3?.role === "user" || message3?.role === "assistant")) {
18753
18919
  const time3 = typeof message3.timestamp === "number" ? message3.timestamp : typeof entry.timestamp === "string" ? Date.parse(entry.timestamp) : NaN;
18754
18920
  if (Number.isFinite(time3))
@@ -18764,8 +18930,8 @@ async function readCandidate(file2, signal) {
18764
18930
  if (!hasUser)
18765
18931
  return null;
18766
18932
  const after = await stat(file2);
18767
- if (!sameFile(before, after))
18768
- throw new PiSessionChangedError();
18933
+ if (!sameFileFingerprint(before, after))
18934
+ throw new SessionImportChangedError(PI_SESSION_CHANGED);
18769
18935
  const cwd = await realpath3(String(header.cwd));
18770
18936
  if (!(await stat(cwd)).isDirectory())
18771
18937
  return null;
@@ -18775,14 +18941,13 @@ async function readCandidate(file2, signal) {
18775
18941
  locator: { sessionFile: await realpath3(file2) },
18776
18942
  formatVersion: 1
18777
18943
  });
18778
- const candidate = harnessSessionImportCandidateSchema.safeParse({
18944
+ const candidate = sessionImportCandidate({
18779
18945
  nativeSessionId: header.id,
18780
18946
  cwd,
18781
18947
  title: name ?? firstMessage,
18782
- updatedAt: Math.floor(updatedAt),
18783
- running: null
18948
+ updatedAt
18784
18949
  });
18785
- return candidate.success && nativeRef.success ? { candidate: candidate.data, nativeRef: nativeRef.data } : null;
18950
+ return candidate && nativeRef.success ? { candidate, nativeRef: nativeRef.data } : null;
18786
18951
  }
18787
18952
  async function readIdentity(file2, signal) {
18788
18953
  const stream = createReadStream2(file2, { encoding: "utf8", signal });
@@ -18830,7 +18995,7 @@ var PiSessionImportIndex = class {
18830
18995
  try {
18831
18996
  const fingerprint = await stat(file2);
18832
18997
  const cached2 = this.#cache.get(file2);
18833
- const source = cached2 && sameFile(cached2.fingerprint, fingerprint) ? cached2.source : await readCandidate(file2, signal);
18998
+ const source = cached2 && sameFileFingerprint(cached2.fingerprint, fingerprint) ? cached2.source : await readCandidate(file2, signal);
18834
18999
  if (!source)
18835
19000
  continue;
18836
19001
  if (!(await stat(source.candidate.cwd)).isDirectory())
@@ -18841,7 +19006,7 @@ var PiSessionImportIndex = class {
18841
19006
  next.set(file2, { fingerprint, source });
18842
19007
  sources.push(source);
18843
19008
  } catch (error51) {
18844
- if (!missing(error51) && !(error51 instanceof PiSessionChangedError))
19009
+ if (!isMissingFileError(error51) && !(error51 instanceof SessionImportChangedError))
18845
19010
  throw error51;
18846
19011
  }
18847
19012
  }
@@ -18856,14 +19021,14 @@ var PiSessionImportIndex = class {
18856
19021
  try {
18857
19022
  const fingerprint = await stat(file2);
18858
19023
  const cached2 = this.#cache.get(file2);
18859
- const id = cached2 && sameFile(cached2.fingerprint, fingerprint) ? cached2.source.nativeRef.nativeSessionId : await readIdentity(file2, signal);
19024
+ const id = cached2 && sameFileFingerprint(cached2.fingerprint, fingerprint) ? cached2.source.nativeRef.nativeSessionId : await readIdentity(file2, signal);
18860
19025
  if (id !== nativeSessionId)
18861
19026
  continue;
18862
19027
  if (selected)
18863
19028
  throw new Error("Pi Session identity is ambiguous across files");
18864
19029
  selected = file2;
18865
19030
  } catch (error51) {
18866
- if (!missing(error51))
19031
+ if (!isMissingFileError(error51))
18867
19032
  throw error51;
18868
19033
  }
18869
19034
  }
@@ -18873,7 +19038,7 @@ var PiSessionImportIndex = class {
18873
19038
  const source = await readCandidate(selected, signal);
18874
19039
  return source?.nativeRef.nativeSessionId === nativeSessionId ? source : null;
18875
19040
  } catch (error51) {
18876
- if (missing(error51))
19041
+ if (isMissingFileError(error51))
18877
19042
  return null;
18878
19043
  throw error51;
18879
19044
  }
@@ -21896,27 +22061,17 @@ var PiAdapter = class {
21896
22061
  };
21897
22062
  sessionImport = Object.freeze({
21898
22063
  listCandidates: async () => {
21899
- const result = await this.#readImport((signal) => this.#importIndex.list(signal));
22064
+ const result = await this.#importScope.read((signal) => this.#importIndex.list(signal));
21900
22065
  return result.ok ? { ok: true, value: result.value.map(({ candidate }) => candidate) } : result;
21901
22066
  },
21902
- resolveCandidate: async (nativeSessionId) => {
21903
- const result = await this.#readImport((signal) => this.#importIndex.resolve(nativeSessionId, signal));
21904
- if (!result.ok)
21905
- return result;
21906
- const source = result.value;
21907
- return source ? { ok: true, value: source } : {
21908
- ok: false,
21909
- error: {
21910
- code: "sessionNotFound",
21911
- message: "Pi Session is no longer importable",
21912
- retryable: false
21913
- }
21914
- };
21915
- }
22067
+ resolveCandidate: (nativeSessionId) => this.#importScope.resolve((signal) => this.#importIndex.resolve(nativeSessionId, signal))
21916
22068
  });
21917
22069
  #importIndex;
21918
- #importAbort = new AbortController();
21919
- #importRequests = /* @__PURE__ */ new Set();
22070
+ #importScope = new SessionImportScope({
22071
+ closedMessage: "Pi Adapter is closed",
22072
+ unavailableMessage: "Pi Session discovery failed; check storage access and duplicate Session identities, then retry after closing native clients",
22073
+ notFoundMessage: "Pi Session is no longer importable"
22074
+ });
21920
22075
  #closeTimeoutMs;
21921
22076
  #createTransport;
21922
22077
  #inspectionCache = /* @__PURE__ */ new Map();
@@ -21959,20 +22114,6 @@ var PiAdapter = class {
21959
22114
  const accounts = await this.inspectAccounts();
21960
22115
  return accounts[0] ?? null;
21961
22116
  }
21962
- #readImport(operation) {
21963
- if (this.#importAbort.signal.aborted)
21964
- return Promise.resolve({ ok: false, error: invalidState("Pi Adapter is closed") });
21965
- const request = operation(this.#importAbort.signal).then((value) => ({ ok: true, value })).catch(() => ({
21966
- ok: false,
21967
- error: {
21968
- code: "unavailable",
21969
- message: "Pi Session discovery failed; check storage access and duplicate Session identities, then retry after closing native clients",
21970
- retryable: true
21971
- }
21972
- })).finally(() => this.#importRequests.delete(request));
21973
- this.#importRequests.add(request);
21974
- return request;
21975
- }
21976
22117
  async inspect(input = {}) {
21977
22118
  if (this.#closePromise) {
21978
22119
  return {
@@ -22300,9 +22441,8 @@ var PiAdapter = class {
22300
22441
  }
22301
22442
  close() {
22302
22443
  if (!this.#closePromise) {
22303
- this.#importAbort.abort();
22304
22444
  this.#closePromise = Promise.all([
22305
- ...this.#importRequests,
22445
+ this.#importScope.close(),
22306
22446
  ...[...this.#inspections].map((transport) => transport.close()),
22307
22447
  ...[...this.#sessions].map((session) => session.close())
22308
22448
  ]).then(() => void 0);