@liberseek/boft-cli-win32-arm64 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.
@@ -349,7 +349,7 @@ function createHarnessInstaller(environment, source) {
349
349
 
350
350
  // dist/kiro-adapter.js
351
351
  import { randomUUID } from "node:crypto";
352
- import path7 from "node:path";
352
+ import path8 from "node:path";
353
353
 
354
354
  // ../../../node_modules/zod/v4/classic/external.js
355
355
  var external_exports = {};
@@ -1117,10 +1117,10 @@ function mergeDefs(...defs) {
1117
1117
  function cloneDef(schema) {
1118
1118
  return mergeDefs(schema._zod.def);
1119
1119
  }
1120
- function getElementAtPath(obj, path8) {
1121
- if (!path8)
1120
+ function getElementAtPath(obj, path9) {
1121
+ if (!path9)
1122
1122
  return obj;
1123
- return path8.reduce((acc, key) => acc?.[key], obj);
1123
+ return path9.reduce((acc, key) => acc?.[key], obj);
1124
1124
  }
1125
1125
  function promiseAllObject(promisesObj) {
1126
1126
  const keys = Object.keys(promisesObj);
@@ -1529,11 +1529,11 @@ function explicitlyAborted(x, startIndex = 0) {
1529
1529
  }
1530
1530
  return false;
1531
1531
  }
1532
- function prefixIssues(path8, issues) {
1532
+ function prefixIssues(path9, issues) {
1533
1533
  return issues.map((iss) => {
1534
1534
  var _a3;
1535
1535
  (_a3 = iss).path ?? (_a3.path = []);
1536
- iss.path.unshift(path8);
1536
+ iss.path.unshift(path9);
1537
1537
  return iss;
1538
1538
  });
1539
1539
  }
@@ -1680,16 +1680,16 @@ function flattenError(error51, mapper = (issue2) => issue2.message) {
1680
1680
  }
1681
1681
  function formatError(error51, mapper = (issue2) => issue2.message) {
1682
1682
  const fieldErrors = { _errors: [] };
1683
- const processError = (error52, path8 = []) => {
1683
+ const processError = (error52, path9 = []) => {
1684
1684
  for (const issue2 of error52.issues) {
1685
1685
  if (issue2.code === "invalid_union" && issue2.errors.length) {
1686
- issue2.errors.map((issues) => processError({ issues }, [...path8, ...issue2.path]));
1686
+ issue2.errors.map((issues) => processError({ issues }, [...path9, ...issue2.path]));
1687
1687
  } else if (issue2.code === "invalid_key") {
1688
- processError({ issues: issue2.issues }, [...path8, ...issue2.path]);
1688
+ processError({ issues: issue2.issues }, [...path9, ...issue2.path]);
1689
1689
  } else if (issue2.code === "invalid_element") {
1690
- processError({ issues: issue2.issues }, [...path8, ...issue2.path]);
1690
+ processError({ issues: issue2.issues }, [...path9, ...issue2.path]);
1691
1691
  } else {
1692
- const fullpath = [...path8, ...issue2.path];
1692
+ const fullpath = [...path9, ...issue2.path];
1693
1693
  if (fullpath.length === 0) {
1694
1694
  fieldErrors._errors.push(mapper(issue2));
1695
1695
  } else {
@@ -1716,17 +1716,17 @@ function formatError(error51, mapper = (issue2) => issue2.message) {
1716
1716
  }
1717
1717
  function treeifyError(error51, mapper = (issue2) => issue2.message) {
1718
1718
  const result = { errors: [] };
1719
- const processError = (error52, path8 = []) => {
1719
+ const processError = (error52, path9 = []) => {
1720
1720
  var _a3, _b;
1721
1721
  for (const issue2 of error52.issues) {
1722
1722
  if (issue2.code === "invalid_union" && issue2.errors.length) {
1723
- issue2.errors.map((issues) => processError({ issues }, [...path8, ...issue2.path]));
1723
+ issue2.errors.map((issues) => processError({ issues }, [...path9, ...issue2.path]));
1724
1724
  } else if (issue2.code === "invalid_key") {
1725
- processError({ issues: issue2.issues }, [...path8, ...issue2.path]);
1725
+ processError({ issues: issue2.issues }, [...path9, ...issue2.path]);
1726
1726
  } else if (issue2.code === "invalid_element") {
1727
- processError({ issues: issue2.issues }, [...path8, ...issue2.path]);
1727
+ processError({ issues: issue2.issues }, [...path9, ...issue2.path]);
1728
1728
  } else {
1729
- const fullpath = [...path8, ...issue2.path];
1729
+ const fullpath = [...path9, ...issue2.path];
1730
1730
  if (fullpath.length === 0) {
1731
1731
  result.errors.push(mapper(issue2));
1732
1732
  continue;
@@ -1758,8 +1758,8 @@ function treeifyError(error51, mapper = (issue2) => issue2.message) {
1758
1758
  }
1759
1759
  function toDotPath(_path) {
1760
1760
  const segs = [];
1761
- const path8 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
1762
- for (const seg of path8) {
1761
+ const path9 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
1762
+ for (const seg of path9) {
1763
1763
  if (typeof seg === "number")
1764
1764
  segs.push(`[${seg}]`);
1765
1765
  else if (typeof seg === "symbol")
@@ -14451,13 +14451,13 @@ function resolveRef(ref, ctx) {
14451
14451
  if (!ref.startsWith("#")) {
14452
14452
  throw new Error("External $ref is not supported, only local refs (#/...) are allowed");
14453
14453
  }
14454
- const path8 = ref.slice(1).split("/").filter(Boolean);
14455
- if (path8.length === 0) {
14454
+ const path9 = ref.slice(1).split("/").filter(Boolean);
14455
+ if (path9.length === 0) {
14456
14456
  return ctx.rootSchema;
14457
14457
  }
14458
14458
  const defsKey = ctx.version === "draft-2020-12" ? "$defs" : "definitions";
14459
- if (path8[0] === defsKey) {
14460
- const key = path8[1];
14459
+ if (path9[0] === defsKey) {
14460
+ const key = path9[1];
14461
14461
  if (!key || !ctx.defs[key]) {
14462
14462
  throw new Error(`Reference not found: ${ref}`);
14463
14463
  }
@@ -14945,6 +14945,10 @@ var hostTurnIdSchema = opaqueIdSchema.brand();
14945
14945
  var hostItemIdSchema = opaqueIdSchema.brand();
14946
14946
  var hostInteractionIdSchema = opaqueIdSchema.brand();
14947
14947
 
14948
+ // ../../shared-contracts/dist/thread-prewarm.js
14949
+ var threadPrewarmDiscardParamsSchema = external_exports.object({ threadId: hostThreadIdSchema });
14950
+ var threadPrewarmDiscardResultSchema = external_exports.object({ discarded: external_exports.boolean() });
14951
+
14948
14952
  // ../../shared-contracts/dist/harness-plugins.js
14949
14953
  var HARNESS_PLUGIN_MANIFEST_MAX_BYTES = 32 * 1024;
14950
14954
  var HARNESS_PLUGIN_ICON_MAX_BYTES = 128 * 1024;
@@ -15012,6 +15016,9 @@ var consoleOpenResultSchema = external_exports.strictObject({
15012
15016
  url: external_exports.string().max(2048).regex(/^http:\/\/(?:127\.0\.0\.1|localhost):\d{1,5}\/(?:\?.*)?$/u)
15013
15017
  });
15014
15018
  var CONSOLE_HOST_METHODS = Object.freeze([
15019
+ "codexhost/console/remote-connections",
15020
+ "codexhost/runtime/status",
15021
+ "codexhost/remote/ssh-setup",
15015
15022
  "codexhost/harness/plugins/list",
15016
15023
  "codexhost/harness/display-settings/get",
15017
15024
  "codexhost/harness/display-settings/set",
@@ -15957,6 +15964,80 @@ var updateStatusResultSchema = external_exports.strictObject({
15957
15964
  status: updateStatusSchema.nullable()
15958
15965
  });
15959
15966
 
15967
+ // ../../shared-contracts/dist/remote-runtime.js
15968
+ var remoteUpdatePhaseSchema = external_exports.enum([
15969
+ "idle",
15970
+ "installing",
15971
+ "restarting",
15972
+ "succeeded",
15973
+ "failed"
15974
+ ]);
15975
+ var runtimeStatusSchema = external_exports.object({
15976
+ runningVersion: external_exports.string().nullable(),
15977
+ installedVersion: external_exports.string().nullable(),
15978
+ restartRequired: external_exports.boolean(),
15979
+ remote: external_exports.boolean(),
15980
+ updateSupported: external_exports.boolean(),
15981
+ update: external_exports.object({
15982
+ phase: remoteUpdatePhaseSchema,
15983
+ targetVersion: external_exports.string().nullable(),
15984
+ error: external_exports.string().nullable()
15985
+ })
15986
+ });
15987
+ var remoteUpdateParamsSchema = external_exports.object({
15988
+ version: external_exports.string().regex(/^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?$/u)
15989
+ }).strict();
15990
+ var remoteSshSetupParamsSchema = external_exports.object({
15991
+ hostname: external_exports.string().min(1).max(1024).refine((value) => !value.startsWith("-") && !/\s/u.test(value)),
15992
+ port: external_exports.number().int().min(1).max(65535).nullable(),
15993
+ identity: external_exports.string().max(4096).nullable(),
15994
+ action: external_exports.enum(["inspect", "install", "update", "repair", "uninstall"]),
15995
+ uninstallPackage: external_exports.boolean().optional(),
15996
+ version: external_exports.string().regex(/^\d+\.\d+\.\d+$/u).nullable()
15997
+ }).strict();
15998
+ var remoteSshSetupResultSchema = external_exports.object({ state: external_exports.enum(["installed", "not-installed"]) }).strict();
15999
+
16000
+ // ../../shared-contracts/dist/remote-connections.js
16001
+ var hostId = external_exports.string().min(1).max(1024);
16002
+ var codexSshConnectionSchema = external_exports.object({
16003
+ hostId,
16004
+ displayName: external_exports.string().min(1).max(1024),
16005
+ source: external_exports.enum(["codex-managed", "discovered"]),
16006
+ sshAlias: external_exports.string().max(1024).nullable(),
16007
+ sshHost: external_exports.string().min(1).max(1024),
16008
+ sshPort: external_exports.number().int().min(1).max(65535).nullable(),
16009
+ identity: external_exports.string().max(4096).nullable(),
16010
+ autoConnect: external_exports.boolean(),
16011
+ connectionAnalyticsId: external_exports.string().max(1024).optional()
16012
+ });
16013
+ var codexSshDraftSchema = external_exports.strictObject({
16014
+ displayName: external_exports.string().min(1).max(1024),
16015
+ hostname: external_exports.string().min(1).max(1024),
16016
+ sshPort: external_exports.number().int().min(1).max(65535).nullable(),
16017
+ identity: external_exports.string().max(4096).nullable()
16018
+ });
16019
+ var remoteConnectionsRequestSchema = external_exports.discriminatedUnion("action", [
16020
+ external_exports.strictObject({ action: external_exports.literal("list") }),
16021
+ external_exports.strictObject({
16022
+ action: external_exports.literal("save"),
16023
+ draft: codexSshDraftSchema,
16024
+ previous: codexSshConnectionSchema.nullable()
16025
+ }),
16026
+ external_exports.strictObject({ action: external_exports.literal("remove"), previous: codexSshConnectionSchema }),
16027
+ external_exports.strictObject({ action: external_exports.literal("connect"), hostId, enabled: external_exports.boolean() }),
16028
+ external_exports.strictObject({ action: external_exports.literal("state"), hostId }),
16029
+ external_exports.strictObject({ action: external_exports.literal("runtime"), hostId }),
16030
+ external_exports.strictObject({
16031
+ action: external_exports.literal("update"),
16032
+ hostId: hostId.refine((id) => id !== "local"),
16033
+ version: remoteUpdateParamsSchema.shape.version
16034
+ })
16035
+ ]);
16036
+ var remoteConnectionsReplySchema = external_exports.union([
16037
+ external_exports.strictObject({ result: jsonValueSchema }),
16038
+ external_exports.strictObject({ error: external_exports.strictObject({ code: external_exports.number().int(), message: external_exports.string() }) })
16039
+ ]);
16040
+
15960
16041
  // ../../shared-contracts/dist/index.js
15961
16042
  var workspaceContractVersionSchema = external_exports.literal(WORKSPACE_CONTRACT_VERSION);
15962
16043
 
@@ -21454,16 +21535,16 @@ var Diff = class {
21454
21535
  }
21455
21536
  }
21456
21537
  }
21457
- addToPath(path8, added, removed, oldPosInc, options) {
21458
- const last = path8.lastComponent;
21538
+ addToPath(path9, added, removed, oldPosInc, options) {
21539
+ const last = path9.lastComponent;
21459
21540
  if (last && !options.oneChangePerToken && last.added === added && last.removed === removed) {
21460
21541
  return {
21461
- oldPos: path8.oldPos + oldPosInc,
21542
+ oldPos: path9.oldPos + oldPosInc,
21462
21543
  lastComponent: { count: last.count + 1, added, removed, previousComponent: last.previousComponent }
21463
21544
  };
21464
21545
  } else {
21465
21546
  return {
21466
- oldPos: path8.oldPos + oldPosInc,
21547
+ oldPos: path9.oldPos + oldPosInc,
21467
21548
  lastComponent: { count: 1, added, removed, previousComponent: last }
21468
21549
  };
21469
21550
  }
@@ -22743,10 +22824,265 @@ async function readKiroSnapshot(location) {
22743
22824
  };
22744
22825
  }
22745
22826
 
22746
- // dist/kiro-adapter.js
22827
+ // dist/session-import.js
22828
+ import { opendir, readFile as readFile2, stat } from "node:fs/promises";
22829
+ import path7 from "node:path";
22830
+
22831
+ // ../../harness-adapter/dist/session-import.js
22832
+ import { lstat } from "node:fs/promises";
22833
+ var SessionImportChangedError = class extends Error {
22834
+ constructor(message = "Native Session changed during discovery; refresh and retry") {
22835
+ super(message);
22836
+ this.name = "SessionImportChangedError";
22837
+ }
22838
+ };
22839
+ function isMissingFileError(error51) {
22840
+ return typeof error51 === "object" && error51 !== null && "code" in error51 && error51.code === "ENOENT";
22841
+ }
22842
+ function sameFileFingerprint(left, right) {
22843
+ 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;
22844
+ }
22845
+ var STORAGE_ACCESS_ERRORS = /* @__PURE__ */ new Set(["EACCES", "EPERM", "EIO", "EMFILE", "ENFILE"]);
22846
+ function isStorageAccessError(error51) {
22847
+ return typeof error51 === "object" && error51 !== null && "code" in error51 && typeof error51.code === "string" && STORAGE_ACCESS_ERRORS.has(error51.code);
22848
+ }
22849
+ async function optionalLstat(file2) {
22850
+ try {
22851
+ return await lstat(file2);
22852
+ } catch (error51) {
22853
+ if (isMissingFileError(error51))
22854
+ return null;
22855
+ throw error51;
22856
+ }
22857
+ }
22858
+ async function readStableFiles(files, read) {
22859
+ const before = await Promise.all(files.map(optionalLstat));
22860
+ const value = await read(before);
22861
+ const after = await Promise.all(files.map(optionalLstat));
22862
+ if (before.some((info, index) => !sameFileFingerprint(info, after[index] ?? null)))
22863
+ throw new SessionImportChangedError();
22864
+ return value;
22865
+ }
22866
+ function sessionImportTitle(value, maxLength = HARNESS_SESSION_IMPORT_TITLE_MAX_LENGTH) {
22867
+ if (typeof value !== "string")
22868
+ return null;
22869
+ const normalized = value.replaceAll("\0", "").replaceAll(/\s+/gu, " ").trim();
22870
+ if (!normalized)
22871
+ return null;
22872
+ if (normalized.length <= maxLength)
22873
+ return normalized;
22874
+ const characters = [...normalized];
22875
+ if (characters.length <= maxLength)
22876
+ return normalized;
22877
+ return `${characters.slice(0, maxLength - 1).join("").trimEnd()}…`;
22878
+ }
22879
+ function sessionImportCandidate(input) {
22880
+ const time3 = typeof input.updatedAt === "number" ? input.updatedAt : typeof input.updatedAt === "string" ? Date.parse(input.updatedAt) : Number.NaN;
22881
+ const parsed = harnessSessionImportCandidateSchema.safeParse({
22882
+ nativeSessionId: input.nativeSessionId,
22883
+ cwd: input.cwd,
22884
+ title: typeof input.title === "string" && input.title.trim().length > 0 ? input.title : null,
22885
+ updatedAt: Math.floor(time3),
22886
+ // Unknown must stay unknown; only an explicit boolean is a native statement.
22887
+ running: typeof input.running === "boolean" ? input.running : null
22888
+ });
22889
+ return parsed.success ? parsed.data : null;
22890
+ }
22891
+ var SessionImportScope = class {
22892
+ #abort = new AbortController();
22893
+ #options;
22894
+ #pending = /* @__PURE__ */ new Set();
22895
+ constructor(options) {
22896
+ this.#options = options;
22897
+ }
22898
+ #closed() {
22899
+ return {
22900
+ ok: false,
22901
+ error: { code: "invalidState", message: this.#options.closedMessage, retryable: false }
22902
+ };
22903
+ }
22904
+ read(operation) {
22905
+ const signal = this.#abort.signal;
22906
+ if (signal.aborted)
22907
+ return Promise.resolve(this.#closed());
22908
+ let started;
22909
+ try {
22910
+ started = operation(signal);
22911
+ } catch (error51) {
22912
+ started = Promise.reject(error51 instanceof Error ? error51 : new Error("Session read failed"));
22913
+ }
22914
+ const request = started.then((value) => signal.aborted ? this.#closed() : { ok: true, value }).catch(() => signal.aborted ? this.#closed() : {
22915
+ ok: false,
22916
+ error: {
22917
+ code: "unavailable",
22918
+ message: this.#options.unavailableMessage,
22919
+ retryable: true
22920
+ }
22921
+ }).finally(() => this.#pending.delete(request));
22922
+ this.#pending.add(request);
22923
+ return request;
22924
+ }
22925
+ /** `read` for `resolveCandidate`: a null source is the selected Session having disappeared. */
22926
+ async resolve(operation) {
22927
+ const result = await this.read(operation);
22928
+ if (!result.ok)
22929
+ return result;
22930
+ return result.value ? { ok: true, value: result.value } : {
22931
+ ok: false,
22932
+ error: {
22933
+ code: "sessionNotFound",
22934
+ message: this.#options.notFoundMessage,
22935
+ retryable: false
22936
+ }
22937
+ };
22938
+ }
22939
+ /** Idempotent. Resolves after every started read has settled. */
22940
+ async close() {
22941
+ this.#abort.abort();
22942
+ await Promise.allSettled(this.#pending);
22943
+ }
22944
+ };
22945
+
22946
+ // dist/session-import.js
22947
+ var MAX_METADATA_BYTES = 1024 * 1024;
22948
+ var NON_WORKSPACE_DIRECTORIES = /* @__PURE__ */ new Set(["cli"]);
22747
22949
  function isRecord11(value) {
22748
22950
  return typeof value === "object" && value !== null && !Array.isArray(value);
22749
22951
  }
22952
+ function userText(row) {
22953
+ const { content, text } = row.payload;
22954
+ return kiroVisibleText(typeof content === "string" ? content : text ?? "");
22955
+ }
22956
+ var KiroSessionImport = class {
22957
+ #environment;
22958
+ #scope = new SessionImportScope({
22959
+ closedMessage: "Kiro Session import is closed",
22960
+ unavailableMessage: "Kiro sessions could not be read; close native clients, check storage access and retry",
22961
+ notFoundMessage: "Kiro Session is no longer importable"
22962
+ });
22963
+ constructor(environment) {
22964
+ this.#environment = { ...environment };
22965
+ }
22966
+ listCandidates() {
22967
+ return this.#scope.read(async (signal) => {
22968
+ const candidates = [];
22969
+ for (const [, directories] of await this.#sessionDirectories(signal)) {
22970
+ if (directories.length !== 1 || !directories[0])
22971
+ continue;
22972
+ try {
22973
+ const candidate = await this.#candidate(directories[0], signal);
22974
+ if (candidate)
22975
+ candidates.push(candidate);
22976
+ } catch (error51) {
22977
+ if (!(error51 instanceof SessionImportChangedError))
22978
+ throw error51;
22979
+ }
22980
+ }
22981
+ return candidates;
22982
+ });
22983
+ }
22984
+ resolveCandidate(nativeSessionId) {
22985
+ return this.#scope.resolve(async (signal) => {
22986
+ const directories = (await this.#sessionDirectories(signal)).get(nativeSessionId);
22987
+ if (directories?.length !== 1 || !directories[0])
22988
+ return null;
22989
+ const candidate = await this.#candidate(directories[0], signal);
22990
+ if (!candidate)
22991
+ return null;
22992
+ return {
22993
+ candidate,
22994
+ nativeRef: nativeSessionRefSchema.parse({
22995
+ harnessId: "kiro-cli",
22996
+ nativeSessionId,
22997
+ formatVersion: 1
22998
+ })
22999
+ };
23000
+ });
23001
+ }
23002
+ close() {
23003
+ return this.#scope.close();
23004
+ }
23005
+ /** Session ID to every directory claiming it. Enumerated links are not followed. */
23006
+ async #sessionDirectories(signal) {
23007
+ const root = path7.join(kiroHomeDir(this.#environment), "sessions");
23008
+ const found = /* @__PURE__ */ new Map();
23009
+ const info = await optionalLstat(root);
23010
+ if (!info)
23011
+ return found;
23012
+ if (!info.isDirectory())
23013
+ throw new Error("Kiro Session store is not a directory");
23014
+ for await (const workspace of await opendir(root)) {
23015
+ signal.throwIfAborted();
23016
+ if (!workspace.isDirectory() || NON_WORKSPACE_DIRECTORIES.has(workspace.name))
23017
+ continue;
23018
+ const workspaceDirectory = path7.join(root, workspace.name);
23019
+ const sessions = await opendir(workspaceDirectory).catch((error51) => {
23020
+ if (isMissingFileError(error51))
23021
+ return null;
23022
+ throw error51;
23023
+ });
23024
+ if (!sessions)
23025
+ continue;
23026
+ for await (const session of sessions) {
23027
+ signal.throwIfAborted();
23028
+ if (!session.isDirectory())
23029
+ continue;
23030
+ const directories = found.get(session.name) ?? [];
23031
+ directories.push(path7.join(workspaceDirectory, session.name));
23032
+ found.set(session.name, directories);
23033
+ }
23034
+ }
23035
+ return found;
23036
+ }
23037
+ async #candidate(sessionDirectory, signal) {
23038
+ signal.throwIfAborted();
23039
+ const files = [
23040
+ path7.join(sessionDirectory, "session.json"),
23041
+ path7.join(sessionDirectory, "messages.jsonl")
23042
+ ];
23043
+ return readStableFiles(files, async ([metadata, messages]) => {
23044
+ if (!metadata?.isFile() || !messages?.isFile() || metadata.size > MAX_METADATA_BYTES)
23045
+ return null;
23046
+ try {
23047
+ const meta3 = JSON.parse(await readFile2(files[0], { encoding: "utf8", signal }));
23048
+ if (!isRecord11(meta3) || meta3.id !== path7.basename(sessionDirectory))
23049
+ return null;
23050
+ const workspacePath = Array.isArray(meta3.workspacePaths) ? meta3.workspacePaths[0] : void 0;
23051
+ if (typeof workspacePath !== "string" || !path7.isAbsolute(workspacePath) || workspacePath.includes("\0"))
23052
+ return null;
23053
+ const cwd = path7.resolve(workspacePath);
23054
+ if (!(await stat(cwd)).isDirectory())
23055
+ return null;
23056
+ signal.throwIfAborted();
23057
+ const rows = await readKiroSessionMessages({
23058
+ sessionDirectory,
23059
+ sessionMeta: meta3,
23060
+ cwd
23061
+ });
23062
+ const firstUser = rows.find((row) => row.payload.type === "user");
23063
+ if (!firstUser)
23064
+ return null;
23065
+ const modified = typeof meta3.lastModifiedAt === "string" ? Date.parse(meta3.lastModifiedAt) : Number.NaN;
23066
+ return sessionImportCandidate({
23067
+ nativeSessionId: meta3.id,
23068
+ cwd,
23069
+ title: sessionImportTitle(meta3.title) ?? sessionImportTitle(userText(firstUser)),
23070
+ updatedAt: Number.isFinite(modified) && modified >= 0 ? modified : messages.mtimeMs
23071
+ });
23072
+ } catch (error51) {
23073
+ signal.throwIfAborted();
23074
+ if (isStorageAccessError(error51))
23075
+ throw error51;
23076
+ return null;
23077
+ }
23078
+ });
23079
+ }
23080
+ };
23081
+
23082
+ // dist/kiro-adapter.js
23083
+ function isRecord12(value) {
23084
+ return typeof value === "object" && value !== null && !Array.isArray(value);
23085
+ }
22750
23086
  var KIRO_SESSION_CAPABILITIES = {
22751
23087
  configuration: {
22752
23088
  selectModel: true,
@@ -22771,6 +23107,7 @@ var KiroAdapter = class {
22771
23107
  harnessId = harnessIdSchema.parse("kiro-cli");
22772
23108
  commandCatalog = KIRO_COMMAND_CATALOG;
22773
23109
  liveCommandCatalog = true;
23110
+ sessionImport;
22774
23111
  #options;
22775
23112
  #deps;
22776
23113
  #sessions = /* @__PURE__ */ new Set();
@@ -22779,9 +23116,10 @@ var KiroAdapter = class {
22779
23116
  constructor(options = {}, deps = {}) {
22780
23117
  this.#options = options;
22781
23118
  this.#deps = deps;
23119
+ this.sessionImport = new KiroSessionImport({ ...process.env, ...options.environment });
22782
23120
  }
22783
23121
  async inspect(input = {}) {
22784
- const cwd = path7.resolve(input.cwd ?? process.cwd());
23122
+ const cwd = path8.resolve(input.cwd ?? process.cwd());
22785
23123
  const cached2 = this.#inspectionCache.get(cwd);
22786
23124
  if (!input.refresh && cached2) {
22787
23125
  if (cached2.refreshAfter <= Date.now()) {
@@ -22842,7 +23180,7 @@ var KiroAdapter = class {
22842
23180
  const transport = this.#createTransport(cwd);
22843
23181
  try {
22844
23182
  const initialize = await transport.inspect();
22845
- const modelCatalog = isRecord11(initialize) && isRecord11(initialize.catalog) ? initialize.catalog : parseKiroModelCatalog(isRecord11(initialize) ? initialize.configOptions : void 0);
23183
+ const modelCatalog = isRecord12(initialize) && isRecord12(initialize.catalog) ? initialize.catalog : parseKiroModelCatalog(isRecord12(initialize) ? initialize.configOptions : void 0);
22846
23184
  if (modelCatalog.models.length === 0)
22847
23185
  throw new Error("Kiro returned no native model catalog");
22848
23186
  return {
@@ -23096,6 +23434,7 @@ var KiroAdapter = class {
23096
23434
  async close() {
23097
23435
  try {
23098
23436
  await Promise.all([
23437
+ this.sessionImport.close(),
23099
23438
  ...this.#inspectionInFlight.values(),
23100
23439
  ...[...this.#sessions].map((session) => session.close())
23101
23440
  ]);
@@ -23263,7 +23602,7 @@ var KiroSession = class {
23263
23602
  }
23264
23603
  };
23265
23604
  } catch (error51) {
23266
- if (this.#newSessionWithoutTurn && isRecord11(error51) && error51.code === "ENOENT") {
23605
+ if (this.#newSessionWithoutTurn && isRecord12(error51) && error51.code === "ENOENT") {
23267
23606
  return { ok: true, value: { turns: [], state: this.#state() } };
23268
23607
  }
23269
23608
  return {
@@ -23324,7 +23663,7 @@ var KiroSession = class {
23324
23663
  kind: "event",
23325
23664
  event: { type: "turn.started", turnId }
23326
23665
  });
23327
- const userText = command.input.filter((part) => part.type === "text").map((part) => part.text).join("\n");
23666
+ const userText2 = command.input.filter((part) => part.type === "text").map((part) => part.text).join("\n");
23328
23667
  const output = new KiroTurnOutput(turnId, this.#cwd, (event) => this.#channel.emit(event));
23329
23668
  let assignedUserMessageId;
23330
23669
  const stopped = new Promise((_resolve, reject) => {
@@ -23335,14 +23674,14 @@ var KiroSession = class {
23335
23674
  try {
23336
23675
  const promptResult = await Promise.race([
23337
23676
  stopped,
23338
- this.#transport.runTurn(userText, (event) => {
23677
+ this.#transport.runTurn(userText2, (event) => {
23339
23678
  if (this.#closed || this.#activeTurnId !== turnId)
23340
23679
  return;
23341
23680
  output.accept(event);
23342
23681
  if (event.type === "usage") {
23343
23682
  this.observeUsage(event);
23344
23683
  const meta3 = event.metadata?.kiro;
23345
- if (isRecord11(meta3) && meta3.kind === "user_message_id_assigned" && typeof meta3.userMessageId === "string") {
23684
+ if (isRecord12(meta3) && meta3.kind === "user_message_id_assigned" && typeof meta3.userMessageId === "string") {
23346
23685
  assignedUserMessageId = meta3.userMessageId;
23347
23686
  }
23348
23687
  } else if (event.type === "compaction.completed") {
@@ -23424,7 +23763,7 @@ var KiroSession = class {
23424
23763
  });
23425
23764
  })
23426
23765
  ]);
23427
- if (isRecord11(promptResult) && promptResult.stopReason === "cancelled") {
23766
+ if (isRecord12(promptResult) && promptResult.stopReason === "cancelled") {
23428
23767
  turnOutcome = { status: "cancelled", reason: "User cancelled" };
23429
23768
  } else {
23430
23769
  turnOutcome = { status: "succeeded" };
@@ -23753,7 +24092,7 @@ var KiroSession = class {
23753
24092
  }
23754
24093
  });
23755
24094
  const result2 = await Promise.race([stopped, this.#transport.compact()]);
23756
- if (isRecord11(result2) && result2.success === false) {
24095
+ if (isRecord12(result2) && result2.success === false) {
23757
24096
  throw new Error("Kiro context compaction did not complete");
23758
24097
  }
23759
24098
  this.#channel.emit({