@liberseek/boft-cli-linux-x64 0.7.7 → 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.
@@ -233,11 +233,11 @@ function harnessCandidates(spec, input, dependencies = {}) {
233
233
  }
234
234
  function resolveHarnessExecutable(spec, input, dependencies = {}) {
235
235
  const platform = input.platform ?? process.platform;
236
- const isExecutable = dependencies.isExecutable ?? ((candidate) => isExecutableFile(candidate, platform));
237
- const runnable = spec.runnableCandidate ?? ((candidate) => candidate);
236
+ const isExecutable = dependencies.isExecutable ?? ((candidate2) => isExecutableFile(candidate2, platform));
237
+ const runnable = spec.runnableCandidate ?? ((candidate2) => candidate2);
238
238
  const context = { platform, isExecutable };
239
- for (const { candidate, source } of harnessCandidates(spec, input, dependencies)) {
240
- const executable = runnable(candidate, context);
239
+ for (const { candidate: candidate2, source } of harnessCandidates(spec, input, dependencies)) {
240
+ const executable = runnable(candidate2, context);
241
241
  if (executable !== void 0 && isExecutable(executable))
242
242
  return { executable, source };
243
243
  }
@@ -1258,10 +1258,10 @@ function mergeDefs(...defs) {
1258
1258
  function cloneDef(schema) {
1259
1259
  return mergeDefs(schema._zod.def);
1260
1260
  }
1261
- function getElementAtPath(obj, path12) {
1262
- if (!path12)
1261
+ function getElementAtPath(obj, path13) {
1262
+ if (!path13)
1263
1263
  return obj;
1264
- return path12.reduce((acc, key) => acc?.[key], obj);
1264
+ return path13.reduce((acc, key) => acc?.[key], obj);
1265
1265
  }
1266
1266
  function promiseAllObject(promisesObj) {
1267
1267
  const keys = Object.keys(promisesObj);
@@ -1670,11 +1670,11 @@ function explicitlyAborted(x, startIndex = 0) {
1670
1670
  }
1671
1671
  return false;
1672
1672
  }
1673
- function prefixIssues(path12, issues) {
1673
+ function prefixIssues(path13, issues) {
1674
1674
  return issues.map((iss) => {
1675
1675
  var _a3;
1676
1676
  (_a3 = iss).path ?? (_a3.path = []);
1677
- iss.path.unshift(path12);
1677
+ iss.path.unshift(path13);
1678
1678
  return iss;
1679
1679
  });
1680
1680
  }
@@ -1821,16 +1821,16 @@ function flattenError(error51, mapper = (issue2) => issue2.message) {
1821
1821
  }
1822
1822
  function formatError(error51, mapper = (issue2) => issue2.message) {
1823
1823
  const fieldErrors = { _errors: [] };
1824
- const processError = (error52, path12 = []) => {
1824
+ const processError = (error52, path13 = []) => {
1825
1825
  for (const issue2 of error52.issues) {
1826
1826
  if (issue2.code === "invalid_union" && issue2.errors.length) {
1827
- issue2.errors.map((issues) => processError({ issues }, [...path12, ...issue2.path]));
1827
+ issue2.errors.map((issues) => processError({ issues }, [...path13, ...issue2.path]));
1828
1828
  } else if (issue2.code === "invalid_key") {
1829
- processError({ issues: issue2.issues }, [...path12, ...issue2.path]);
1829
+ processError({ issues: issue2.issues }, [...path13, ...issue2.path]);
1830
1830
  } else if (issue2.code === "invalid_element") {
1831
- processError({ issues: issue2.issues }, [...path12, ...issue2.path]);
1831
+ processError({ issues: issue2.issues }, [...path13, ...issue2.path]);
1832
1832
  } else {
1833
- const fullpath = [...path12, ...issue2.path];
1833
+ const fullpath = [...path13, ...issue2.path];
1834
1834
  if (fullpath.length === 0) {
1835
1835
  fieldErrors._errors.push(mapper(issue2));
1836
1836
  } else {
@@ -1857,17 +1857,17 @@ function formatError(error51, mapper = (issue2) => issue2.message) {
1857
1857
  }
1858
1858
  function treeifyError(error51, mapper = (issue2) => issue2.message) {
1859
1859
  const result = { errors: [] };
1860
- const processError = (error52, path12 = []) => {
1860
+ const processError = (error52, path13 = []) => {
1861
1861
  var _a3, _b;
1862
1862
  for (const issue2 of error52.issues) {
1863
1863
  if (issue2.code === "invalid_union" && issue2.errors.length) {
1864
- issue2.errors.map((issues) => processError({ issues }, [...path12, ...issue2.path]));
1864
+ issue2.errors.map((issues) => processError({ issues }, [...path13, ...issue2.path]));
1865
1865
  } else if (issue2.code === "invalid_key") {
1866
- processError({ issues: issue2.issues }, [...path12, ...issue2.path]);
1866
+ processError({ issues: issue2.issues }, [...path13, ...issue2.path]);
1867
1867
  } else if (issue2.code === "invalid_element") {
1868
- processError({ issues: issue2.issues }, [...path12, ...issue2.path]);
1868
+ processError({ issues: issue2.issues }, [...path13, ...issue2.path]);
1869
1869
  } else {
1870
- const fullpath = [...path12, ...issue2.path];
1870
+ const fullpath = [...path13, ...issue2.path];
1871
1871
  if (fullpath.length === 0) {
1872
1872
  result.errors.push(mapper(issue2));
1873
1873
  continue;
@@ -1899,8 +1899,8 @@ function treeifyError(error51, mapper = (issue2) => issue2.message) {
1899
1899
  }
1900
1900
  function toDotPath(_path) {
1901
1901
  const segs = [];
1902
- const path12 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
1903
- for (const seg of path12) {
1902
+ const path13 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
1903
+ for (const seg of path13) {
1904
1904
  if (typeof seg === "number")
1905
1905
  segs.push(`[${seg}]`);
1906
1906
  else if (typeof seg === "symbol")
@@ -14592,13 +14592,13 @@ function resolveRef(ref, ctx) {
14592
14592
  if (!ref.startsWith("#")) {
14593
14593
  throw new Error("External $ref is not supported, only local refs (#/...) are allowed");
14594
14594
  }
14595
- const path12 = ref.slice(1).split("/").filter(Boolean);
14596
- if (path12.length === 0) {
14595
+ const path13 = ref.slice(1).split("/").filter(Boolean);
14596
+ if (path13.length === 0) {
14597
14597
  return ctx.rootSchema;
14598
14598
  }
14599
14599
  const defsKey = ctx.version === "draft-2020-12" ? "$defs" : "definitions";
14600
- if (path12[0] === defsKey) {
14601
- const key = path12[1];
14600
+ if (path13[0] === defsKey) {
14601
+ const key = path13[1];
14602
14602
  if (!key || !ctx.defs[key]) {
14603
14603
  throw new Error(`Reference not found: ${ref}`);
14604
14604
  }
@@ -15086,6 +15086,10 @@ var hostTurnIdSchema = opaqueIdSchema.brand();
15086
15086
  var hostItemIdSchema = opaqueIdSchema.brand();
15087
15087
  var hostInteractionIdSchema = opaqueIdSchema.brand();
15088
15088
 
15089
+ // ../../shared-contracts/dist/thread-prewarm.js
15090
+ var threadPrewarmDiscardParamsSchema = external_exports.object({ threadId: hostThreadIdSchema });
15091
+ var threadPrewarmDiscardResultSchema = external_exports.object({ discarded: external_exports.boolean() });
15092
+
15089
15093
  // ../../shared-contracts/dist/harness-plugins.js
15090
15094
  var HARNESS_PLUGIN_MANIFEST_MAX_BYTES = 32 * 1024;
15091
15095
  var HARNESS_PLUGIN_ICON_MAX_BYTES = 128 * 1024;
@@ -15153,6 +15157,9 @@ var consoleOpenResultSchema = external_exports.strictObject({
15153
15157
  url: external_exports.string().max(2048).regex(/^http:\/\/(?:127\.0\.0\.1|localhost):\d{1,5}\/(?:\?.*)?$/u)
15154
15158
  });
15155
15159
  var CONSOLE_HOST_METHODS = Object.freeze([
15160
+ "codexhost/console/remote-connections",
15161
+ "codexhost/runtime/status",
15162
+ "codexhost/remote/ssh-setup",
15156
15163
  "codexhost/harness/plugins/list",
15157
15164
  "codexhost/harness/display-settings/get",
15158
15165
  "codexhost/harness/display-settings/set",
@@ -15781,7 +15788,10 @@ var harnessInstallationStateSchema = external_exports.object({
15781
15788
  latestVersion: external_exports.string().min(1).max(128),
15782
15789
  updateAvailable: external_exports.boolean(),
15783
15790
  canUpdate: external_exports.boolean(),
15784
- message: external_exports.string().max(2048).optional()
15791
+ // Adapter-owned diagnostic text; UI uses messageCode rather than displaying it verbatim.
15792
+ message: external_exports.string().max(2048).optional(),
15793
+ messageCode: external_exports.string().min(1).max(128).optional(),
15794
+ latestVersionKind: external_exports.enum(["unknown", "tracking-branch"]).optional()
15785
15795
  }).strict();
15786
15796
 
15787
15797
  // ../../shared-contracts/dist/codex-accounts.js
@@ -16076,7 +16086,7 @@ var updateStatusSchema = external_exports.strictObject({
16076
16086
  }
16077
16087
  });
16078
16088
  var updateEmptyParamsSchema = external_exports.strictObject({});
16079
- var githubReleaseNotesUrlSchema = external_exports.string().max(300).regex(/^https:\/\/github\.com\/LiberSeek\/BOFT-CLI\/releases\/tag\/v[0-9A-Za-z.+-]+$/u, "release notes URL must identify a codexhost GitHub Release");
16089
+ var githubReleaseNotesUrlSchema = external_exports.string().max(300).regex(/^https:\/\/github\.com\/(LiberSeek|LIBERSEEK)\/BOFT-CLI\/releases\/tag\/v[0-9A-Za-z.+-]+$/u, "release notes URL must identify a codexhost GitHub Release");
16080
16090
  var updateCheckResultSchema = external_exports.strictObject({
16081
16091
  currentVersion: updateSemanticVersionSchema,
16082
16092
  installation: updateInstallationSchema.nullable(),
@@ -16095,6 +16105,80 @@ var updateStatusResultSchema = external_exports.strictObject({
16095
16105
  status: updateStatusSchema.nullable()
16096
16106
  });
16097
16107
 
16108
+ // ../../shared-contracts/dist/remote-runtime.js
16109
+ var remoteUpdatePhaseSchema = external_exports.enum([
16110
+ "idle",
16111
+ "installing",
16112
+ "restarting",
16113
+ "succeeded",
16114
+ "failed"
16115
+ ]);
16116
+ var runtimeStatusSchema = external_exports.object({
16117
+ runningVersion: external_exports.string().nullable(),
16118
+ installedVersion: external_exports.string().nullable(),
16119
+ restartRequired: external_exports.boolean(),
16120
+ remote: external_exports.boolean(),
16121
+ updateSupported: external_exports.boolean(),
16122
+ update: external_exports.object({
16123
+ phase: remoteUpdatePhaseSchema,
16124
+ targetVersion: external_exports.string().nullable(),
16125
+ error: external_exports.string().nullable()
16126
+ })
16127
+ });
16128
+ var remoteUpdateParamsSchema = external_exports.object({
16129
+ version: external_exports.string().regex(/^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?$/u)
16130
+ }).strict();
16131
+ var remoteSshSetupParamsSchema = external_exports.object({
16132
+ hostname: external_exports.string().min(1).max(1024).refine((value) => !value.startsWith("-") && !/\s/u.test(value)),
16133
+ port: external_exports.number().int().min(1).max(65535).nullable(),
16134
+ identity: external_exports.string().max(4096).nullable(),
16135
+ action: external_exports.enum(["inspect", "install", "update", "repair", "uninstall"]),
16136
+ uninstallPackage: external_exports.boolean().optional(),
16137
+ version: external_exports.string().regex(/^\d+\.\d+\.\d+$/u).nullable()
16138
+ }).strict();
16139
+ var remoteSshSetupResultSchema = external_exports.object({ state: external_exports.enum(["installed", "not-installed"]) }).strict();
16140
+
16141
+ // ../../shared-contracts/dist/remote-connections.js
16142
+ var hostId = external_exports.string().min(1).max(1024);
16143
+ var codexSshConnectionSchema = external_exports.object({
16144
+ hostId,
16145
+ displayName: external_exports.string().min(1).max(1024),
16146
+ source: external_exports.enum(["codex-managed", "discovered"]),
16147
+ sshAlias: external_exports.string().max(1024).nullable(),
16148
+ sshHost: external_exports.string().min(1).max(1024),
16149
+ sshPort: external_exports.number().int().min(1).max(65535).nullable(),
16150
+ identity: external_exports.string().max(4096).nullable(),
16151
+ autoConnect: external_exports.boolean(),
16152
+ connectionAnalyticsId: external_exports.string().max(1024).optional()
16153
+ });
16154
+ var codexSshDraftSchema = external_exports.strictObject({
16155
+ displayName: external_exports.string().min(1).max(1024),
16156
+ hostname: external_exports.string().min(1).max(1024),
16157
+ sshPort: external_exports.number().int().min(1).max(65535).nullable(),
16158
+ identity: external_exports.string().max(4096).nullable()
16159
+ });
16160
+ var remoteConnectionsRequestSchema = external_exports.discriminatedUnion("action", [
16161
+ external_exports.strictObject({ action: external_exports.literal("list") }),
16162
+ external_exports.strictObject({
16163
+ action: external_exports.literal("save"),
16164
+ draft: codexSshDraftSchema,
16165
+ previous: codexSshConnectionSchema.nullable()
16166
+ }),
16167
+ external_exports.strictObject({ action: external_exports.literal("remove"), previous: codexSshConnectionSchema }),
16168
+ external_exports.strictObject({ action: external_exports.literal("connect"), hostId, enabled: external_exports.boolean() }),
16169
+ external_exports.strictObject({ action: external_exports.literal("state"), hostId }),
16170
+ external_exports.strictObject({ action: external_exports.literal("runtime"), hostId }),
16171
+ external_exports.strictObject({
16172
+ action: external_exports.literal("update"),
16173
+ hostId: hostId.refine((id) => id !== "local"),
16174
+ version: remoteUpdateParamsSchema.shape.version
16175
+ })
16176
+ ]);
16177
+ var remoteConnectionsReplySchema = external_exports.union([
16178
+ external_exports.strictObject({ result: jsonValueSchema }),
16179
+ external_exports.strictObject({ error: external_exports.strictObject({ code: external_exports.number().int(), message: external_exports.string() }) })
16180
+ ]);
16181
+
16098
16182
  // ../../shared-contracts/dist/index.js
16099
16183
  var workspaceContractVersionSchema = external_exports.literal(WORKSPACE_CONTRACT_VERSION);
16100
16184
 
@@ -16244,20 +16328,20 @@ function parseHostUsage(value) {
16244
16328
  }
16245
16329
  }
16246
16330
  for (const field of ["totalCredits", "contextUsagePercent"]) {
16247
- const candidate = value[field];
16248
- if (candidate !== void 0 && (typeof candidate !== "number" || !Number.isFinite(candidate) || candidate < 0)) {
16331
+ const candidate2 = value[field];
16332
+ if (candidate2 !== void 0 && (typeof candidate2 !== "number" || !Number.isFinite(candidate2) || candidate2 < 0)) {
16249
16333
  throw new Error(`Harness Usage '${field}' must be a finite non-negative number`);
16250
16334
  }
16251
16335
  }
16252
16336
  for (const field of tokenFields) {
16253
- const candidate = value[field];
16254
- if (candidate !== void 0 && (typeof candidate !== "number" || !Number.isSafeInteger(candidate) || candidate < 0)) {
16337
+ const candidate2 = value[field];
16338
+ if (candidate2 !== void 0 && (typeof candidate2 !== "number" || !Number.isSafeInteger(candidate2) || candidate2 < 0)) {
16255
16339
  throw new Error(`Harness Usage '${field}' must be a non-negative safe integer`);
16256
16340
  }
16257
16341
  }
16258
16342
  for (const field of safeIntegerFields) {
16259
- const candidate = value[field];
16260
- if (candidate !== void 0 && (typeof candidate !== "number" || !Number.isSafeInteger(candidate) || candidate < 0)) {
16343
+ const candidate2 = value[field];
16344
+ if (candidate2 !== void 0 && (typeof candidate2 !== "number" || !Number.isSafeInteger(candidate2) || candidate2 < 0)) {
16261
16345
  throw new Error(`Harness Usage '${field}' must be a non-negative safe integer`);
16262
16346
  }
16263
16347
  }
@@ -16268,14 +16352,14 @@ function parseHostUsage(value) {
16268
16352
  throw new Error("Harness Usage 'totalCostUsd' must be a finite non-negative number");
16269
16353
  }
16270
16354
  for (const field of ["totalCredits", "contextUsagePercent"]) {
16271
- const candidate = value[field];
16272
- if (candidate !== void 0 && (typeof candidate !== "number" || !Number.isFinite(candidate) || candidate < 0)) {
16355
+ const candidate2 = value[field];
16356
+ if (candidate2 !== void 0 && (typeof candidate2 !== "number" || !Number.isFinite(candidate2) || candidate2 < 0)) {
16273
16357
  throw new Error(`Harness Usage '${field}' must be a finite non-negative number`);
16274
16358
  }
16275
16359
  }
16276
16360
  for (const field of percentFields) {
16277
- const candidate = value[field];
16278
- if (candidate !== void 0 && (typeof candidate !== "number" || !Number.isFinite(candidate) || candidate < 0 || candidate > 100)) {
16361
+ const candidate2 = value[field];
16362
+ if (candidate2 !== void 0 && (typeof candidate2 !== "number" || !Number.isFinite(candidate2) || candidate2 < 0 || candidate2 > 100)) {
16279
16363
  throw new Error(`Harness Usage '${field}' must be between 0 and 100`);
16280
16364
  }
16281
16365
  }
@@ -16388,7 +16472,7 @@ function normalizeOpenCodeModelCatalog(catalog) {
16388
16472
  ...Object.keys(model.variants ?? {}).sort(compareText).map(encodeOpenCodeVariant)
16389
16473
  ]
16390
16474
  })).sort((left, right) => compareText(left.label, right.label) || compareText(left.ref.id, right.ref.id));
16391
- const defaultNative = catalog.connected.map((providerID) => ({ providerID, modelID: catalog.default[providerID] })).find((candidate) => typeof candidate.modelID === "string" && candidate.modelID.length > 0);
16475
+ const defaultNative = catalog.connected.map((providerID) => ({ providerID, modelID: catalog.default[providerID] })).find((candidate2) => typeof candidate2.modelID === "string" && candidate2.modelID.length > 0);
16392
16476
  const defaultModel = defaultNative ? encodeOpenCodeModelRef(defaultNative) : void 0;
16393
16477
  return harnessModelCatalogSchema.parse({
16394
16478
  models,
@@ -16948,7 +17032,7 @@ var serializeObjectParam = ({ allowReserved, explode, name, style, value, valueO
16948
17032
 
16949
17033
  // ../../../node_modules/@opencode-ai/sdk/dist/v2/gen/core/utils.gen.js
16950
17034
  var PATH_PARAM_RE = /\{[^{}]+\}/g;
16951
- var defaultPathSerializer = ({ path: path12, url: _url2 }) => {
17035
+ var defaultPathSerializer = ({ path: path13, url: _url2 }) => {
16952
17036
  let url2 = _url2;
16953
17037
  const matches = _url2.match(PATH_PARAM_RE);
16954
17038
  if (matches) {
@@ -16967,7 +17051,7 @@ var defaultPathSerializer = ({ path: path12, url: _url2 }) => {
16967
17051
  name = name.substring(1);
16968
17052
  style = "matrix";
16969
17053
  }
16970
- const value = path12[name];
17054
+ const value = path13[name];
16971
17055
  if (value === void 0 || value === null) {
16972
17056
  continue;
16973
17057
  }
@@ -16998,11 +17082,11 @@ var defaultPathSerializer = ({ path: path12, url: _url2 }) => {
16998
17082
  }
16999
17083
  return url2;
17000
17084
  };
17001
- var getUrl = ({ baseUrl, path: path12, query, querySerializer, url: _url2 }) => {
17085
+ var getUrl = ({ baseUrl, path: path13, query, querySerializer, url: _url2 }) => {
17002
17086
  const pathUrl = _url2.startsWith("/") ? _url2 : `/${_url2}`;
17003
17087
  let url2 = (baseUrl ?? "") + pathUrl;
17004
- if (path12) {
17005
- url2 = defaultPathSerializer({ path: path12, url: url2 });
17088
+ if (path13) {
17089
+ url2 = defaultPathSerializer({ path: path13, url: url2 });
17006
17090
  }
17007
17091
  let search = query ? querySerializer(query) : "";
17008
17092
  if (search.startsWith("?")) {
@@ -22255,14 +22339,14 @@ function signalProcessTree(child, signal) {
22255
22339
  }
22256
22340
  function safeOpenCodeServerCwd(environment) {
22257
22341
  const candidates = [environment.USERPROFILE, environment.HOME, homedir2(), tmpdir2()];
22258
- for (const candidate of candidates) {
22259
- if (!candidate || !path6.isAbsolute(candidate))
22342
+ for (const candidate2 of candidates) {
22343
+ if (!candidate2 || !path6.isAbsolute(candidate2))
22260
22344
  continue;
22261
22345
  try {
22262
- if (!fs2.statSync(candidate).isDirectory())
22346
+ if (!fs2.statSync(candidate2).isDirectory())
22263
22347
  continue;
22264
- fs2.accessSync(candidate, fs2.constants.R_OK | fs2.constants.W_OK);
22265
- return candidate;
22348
+ fs2.accessSync(candidate2, fs2.constants.R_OK | fs2.constants.W_OK);
22349
+ return candidate2;
22266
22350
  } catch {
22267
22351
  }
22268
22352
  }
@@ -22717,19 +22801,19 @@ function hasDotPathSegment(value) {
22717
22801
  return segments.some((segment) => segment === "." || segment === "..");
22718
22802
  }
22719
22803
  function canonicalDirectoryPath(value) {
22720
- let candidate = path7.resolve(value);
22804
+ let candidate2 = path7.resolve(value);
22721
22805
  const missingSegments = [];
22722
22806
  for (; ; ) {
22723
22807
  try {
22724
- return path7.join(fs3.realpathSync.native(candidate), ...missingSegments);
22808
+ return path7.join(fs3.realpathSync.native(candidate2), ...missingSegments);
22725
22809
  } catch (error51) {
22726
22810
  if (!missingPath(error51))
22727
22811
  return void 0;
22728
- const parent = path7.dirname(candidate);
22729
- if (parent === candidate)
22812
+ const parent = path7.dirname(candidate2);
22813
+ if (parent === candidate2)
22730
22814
  return void 0;
22731
- missingSegments.unshift(path7.basename(candidate));
22732
- candidate = parent;
22815
+ missingSegments.unshift(path7.basename(candidate2));
22816
+ candidate2 = parent;
22733
22817
  }
22734
22818
  }
22735
22819
  }
@@ -22738,8 +22822,8 @@ function canonicalFilePath(value) {
22738
22822
  const parent = canonicalDirectoryPath(path7.dirname(absolute));
22739
22823
  return parent ? path7.join(parent, path7.basename(absolute)) : void 0;
22740
22824
  }
22741
- function pathIsWithin(root, candidate, allowRoot) {
22742
- const relative = path7.relative(root, candidate);
22825
+ function pathIsWithin(root, candidate2, allowRoot) {
22826
+ const relative = path7.relative(root, candidate2);
22743
22827
  return allowRoot && relative === "" || relative !== "" && relative !== ".." && !relative.startsWith(`..${path7.sep}`) && !path7.isAbsolute(relative);
22744
22828
  }
22745
22829
  function verifiedOpenCodeWorktree(sessionDirectory, paths) {
@@ -22758,8 +22842,8 @@ function openCodeFileIdentity(file2, worktree) {
22758
22842
  if (typeof file2 !== "string" || typeof worktree !== "string" || hasDotPathSegment(file2) || hasDotPathSegment(worktree) || !path7.isAbsolute(worktree) || !file2 || file2.includes("\0") || file2.includes("\n") || file2.includes("\r")) {
22759
22843
  return void 0;
22760
22844
  }
22761
- const candidate = canonicalFilePath(path7.isAbsolute(file2) ? file2 : path7.resolve(worktree, file2));
22762
- return candidate && pathIsWithin(worktree, candidate, false) ? candidate : void 0;
22845
+ const candidate2 = canonicalFilePath(path7.isAbsolute(file2) ? file2 : path7.resolve(worktree, file2));
22846
+ return candidate2 && pathIsWithin(worktree, candidate2, false) ? candidate2 : void 0;
22763
22847
  }
22764
22848
 
22765
22849
  // dist/usage.js
@@ -22987,20 +23071,20 @@ async function deriveOpenCodeHistory(options) {
22987
23071
  retainedCount = boundary.sourceTurnCount - 1;
22988
23072
  }
22989
23073
  const expectedHistory = structuredClone(semanticHistory(before.snapshot).slice(0, retainedCount));
22990
- let candidate = await transport.forkSession(source.id, messageID);
22991
- if (candidate.id === source.id) {
23074
+ let candidate2 = await transport.forkSession(source.id, messageID);
23075
+ if (candidate2.id === source.id) {
22992
23076
  throw new OpenCodeTransportError("protocolError", "OpenCode Fork did not create a distinct Native Session");
22993
23077
  }
22994
- const candidateID = candidate.id;
22995
- options.onCreated(candidate);
22996
- if (candidate.directory !== expectedSource.directory) {
23078
+ const candidateID = candidate2.id;
23079
+ options.onCreated(candidate2);
23080
+ if (candidate2.directory !== expectedSource.directory) {
22997
23081
  throw new OpenCodeTransportError("protocolError", "OpenCode Fork changed working directory");
22998
23082
  }
22999
23083
  if (expectedSource.model) {
23000
- candidate = await transport.updateSessionMetadata(candidateID, selectionMetadata(candidate, expectedSource.model, expectedSource.variant));
23084
+ candidate2 = await transport.updateSessionMetadata(candidateID, selectionMetadata(candidate2, expectedSource.model, expectedSource.variant));
23001
23085
  }
23002
- if (!isDeepStrictEqual(candidate.permission ?? [], expectedSource.permission ?? [])) {
23003
- candidate = await transport.updateSessionPermission(candidateID, expectedSource.permission ?? []);
23086
+ if (!isDeepStrictEqual(candidate2.permission ?? [], expectedSource.permission ?? [])) {
23087
+ candidate2 = await transport.updateSessionPermission(candidateID, expectedSource.permission ?? []);
23004
23088
  }
23005
23089
  const [derived, after, candidateStatus, sourceStatus] = await Promise.all([
23006
23090
  read(candidateID),
@@ -23008,7 +23092,7 @@ async function deriveOpenCodeHistory(options) {
23008
23092
  transport.getStatus(candidateID),
23009
23093
  transport.getStatus(source.id)
23010
23094
  ]);
23011
- if (derived.session.id !== candidateID || candidate.id !== candidateID || derived.session.directory !== before.session.directory || candidateStatus.type !== "idle" || sourceStatus.type !== "idle" || !isDeepStrictEqual(semanticHistory(derived.snapshot), expectedHistory) || !isDeepStrictEqual(sourceState(after), expectedSource) || !isDeepStrictEqual(derived.model, expectedSource.model) || derived.variant !== expectedSource.variant || !isDeepStrictEqual(derived.session.permission ?? [], expectedSource.permission ?? [])) {
23095
+ if (derived.session.id !== candidateID || candidate2.id !== candidateID || derived.session.directory !== before.session.directory || candidateStatus.type !== "idle" || sourceStatus.type !== "idle" || !isDeepStrictEqual(semanticHistory(derived.snapshot), expectedHistory) || !isDeepStrictEqual(sourceState(after), expectedSource) || !isDeepStrictEqual(derived.model, expectedSource.model) || derived.variant !== expectedSource.variant || !isDeepStrictEqual(derived.session.permission ?? [], expectedSource.permission ?? [])) {
23012
23096
  throw new OpenCodeTransportError("protocolError", "OpenCode derived history, source or configuration changed during Fork");
23013
23097
  }
23014
23098
  return derived.session;
@@ -24145,9 +24229,9 @@ var OpenCodeHarnessSession = class {
24145
24229
  if (active.userMessageID)
24146
24230
  return;
24147
24231
  const candidates = messages.filter(({ info }) => info.role === "user" && !active.preexistingUserMessageIds.has(info.id));
24148
- const [candidate] = candidates;
24149
- if (candidates.length === 1 && candidate) {
24150
- this.#bindUserMessage(active, candidate.info.id);
24232
+ const [candidate2] = candidates;
24233
+ if (candidates.length === 1 && candidate2) {
24234
+ this.#bindUserMessage(active, candidate2.info.id);
24151
24235
  return;
24152
24236
  }
24153
24237
  const parents = new Set(messages.filter(({ info }) => info.role === "assistant").map(({ info }) => info.parentID));
@@ -24365,8 +24449,8 @@ var OpenCodeAdapter = class {
24365
24449
  input,
24366
24450
  providers,
24367
24451
  toolOutputLimit: this.#toolOutputLimit,
24368
- onCreated: (candidate) => {
24369
- createdForCleanup = candidate;
24452
+ onCreated: (candidate2) => {
24453
+ createdForCleanup = candidate2;
24370
24454
  }
24371
24455
  });
24372
24456
  }
@@ -24433,7 +24517,7 @@ async function detectOpenCode(options) {
24433
24517
  }
24434
24518
 
24435
24519
  // dist/v2/adapter.js
24436
- import fs6 from "node:fs";
24520
+ import fs7 from "node:fs";
24437
24521
  import { isDeepStrictEqual as isDeepStrictEqual2 } from "node:util";
24438
24522
 
24439
24523
  // dist/v2/state.js
@@ -24508,7 +24592,7 @@ function v2Permissions(current = [], mode) {
24508
24592
  }
24509
24593
  function v2State(session, catalog, policy) {
24510
24594
  const model = session.model ? encodeOpenCodeModelRef({ providerID: session.model.providerID, modelID: session.model.id }) : void 0;
24511
- const entry = catalog.models.find((candidate) => candidate.ref.id === model?.id);
24595
+ const entry = catalog.models.find((candidate2) => candidate2.ref.id === model?.id);
24512
24596
  const mode = session.permissions?.findLast((rule) => rule.action === "*" && rule.resource === "*");
24513
24597
  return {
24514
24598
  nativeRef: v2Ref(session, policy),
@@ -26541,6 +26625,110 @@ function terminalItemOutcome(outcome) {
26541
26625
  return outcome.status === "unknown" ? { status: "failed", error: failure(outcome.reason, "protocolError") } : outcome;
26542
26626
  }
26543
26627
 
26628
+ // dist/v2/session-import.js
26629
+ import fs6 from "node:fs";
26630
+ import path11 from "node:path";
26631
+
26632
+ // ../../harness-adapter/dist/session-import.js
26633
+ function sessionImportTitle(value, maxLength = HARNESS_SESSION_IMPORT_TITLE_MAX_LENGTH) {
26634
+ if (typeof value !== "string")
26635
+ return null;
26636
+ const normalized = value.replaceAll("\0", "").replaceAll(/\s+/gu, " ").trim();
26637
+ if (!normalized)
26638
+ return null;
26639
+ if (normalized.length <= maxLength)
26640
+ return normalized;
26641
+ const characters = [...normalized];
26642
+ if (characters.length <= maxLength)
26643
+ return normalized;
26644
+ return `${characters.slice(0, maxLength - 1).join("").trimEnd()}…`;
26645
+ }
26646
+ function sessionImportCandidate(input) {
26647
+ const time3 = typeof input.updatedAt === "number" ? input.updatedAt : typeof input.updatedAt === "string" ? Date.parse(input.updatedAt) : Number.NaN;
26648
+ const parsed = harnessSessionImportCandidateSchema.safeParse({
26649
+ nativeSessionId: input.nativeSessionId,
26650
+ cwd: input.cwd,
26651
+ title: typeof input.title === "string" && input.title.trim().length > 0 ? input.title : null,
26652
+ updatedAt: Math.floor(time3),
26653
+ // Unknown must stay unknown; only an explicit boolean is a native statement.
26654
+ running: typeof input.running === "boolean" ? input.running : null
26655
+ });
26656
+ return parsed.success ? parsed.data : null;
26657
+ }
26658
+
26659
+ // dist/v2/session-import.js
26660
+ var PAGE_SIZE = 200;
26661
+ var MAX_PAGES = 1e4;
26662
+ function existingDirectory(directory) {
26663
+ if (typeof directory !== "string" || !path11.isAbsolute(directory))
26664
+ return null;
26665
+ try {
26666
+ return fs6.statSync(directory).isDirectory() ? directory : null;
26667
+ } catch {
26668
+ return null;
26669
+ }
26670
+ }
26671
+ function candidate(info, active) {
26672
+ if (info.parentID || info.time.archived !== void 0)
26673
+ return null;
26674
+ const cwd = existingDirectory(info.location.directory);
26675
+ if (!cwd)
26676
+ return null;
26677
+ return sessionImportCandidate({
26678
+ nativeSessionId: info.id,
26679
+ cwd,
26680
+ title: sessionImportTitle(info.title),
26681
+ updatedAt: info.time.updated,
26682
+ // This server only knows its own executions; another process may still hold the Session.
26683
+ running: active[info.id] ? true : null
26684
+ });
26685
+ }
26686
+ async function listV2SessionCandidates(client2) {
26687
+ const active = await client2.session.active();
26688
+ const candidates = /* @__PURE__ */ new Map();
26689
+ const cursors = /* @__PURE__ */ new Set();
26690
+ let cursor;
26691
+ for (let page = 0; page < MAX_PAGES; page += 1) {
26692
+ const response = await client2.session.list({
26693
+ limit: PAGE_SIZE,
26694
+ ...cursor ? { cursor } : {}
26695
+ });
26696
+ for (const info of response.data) {
26697
+ const entry = candidate(info, active);
26698
+ if (entry)
26699
+ candidates.set(entry.nativeSessionId, entry);
26700
+ }
26701
+ const next = response.cursor.next;
26702
+ if (!next || cursors.has(next))
26703
+ break;
26704
+ cursors.add(next);
26705
+ cursor = next;
26706
+ }
26707
+ return [...candidates.values()];
26708
+ }
26709
+ async function resolveV2SessionCandidate(client2, nativeSessionId) {
26710
+ const active = await client2.session.active();
26711
+ const cursors = /* @__PURE__ */ new Set();
26712
+ let cursor;
26713
+ for (let page = 0; page < MAX_PAGES; page += 1) {
26714
+ const response = await client2.session.list({
26715
+ limit: PAGE_SIZE,
26716
+ ...cursor ? { cursor } : {}
26717
+ });
26718
+ const info = response.data.find((entry) => entry.id === nativeSessionId);
26719
+ if (info) {
26720
+ const entry = candidate(info, active);
26721
+ return entry ? { candidate: entry, nativeRef: v2Ref(info, "default") } : null;
26722
+ }
26723
+ const next = response.cursor.next;
26724
+ if (!next || cursors.has(next))
26725
+ break;
26726
+ cursors.add(next);
26727
+ cursor = next;
26728
+ }
26729
+ return null;
26730
+ }
26731
+
26544
26732
  // dist/v2/interactions.js
26545
26733
  function permissionInteraction(request, turnId) {
26546
26734
  return {
@@ -27172,9 +27360,42 @@ var V2Adapter = class {
27172
27360
  this.#connections.delete(connection);
27173
27361
  }
27174
27362
  }
27363
+ sessionImport = {
27364
+ listCandidates: () => this.#discover((client2) => listV2SessionCandidates(client2)),
27365
+ resolveCandidate: async (nativeSessionId) => {
27366
+ const source = await this.#discover((client2) => resolveV2SessionCandidate(client2, nativeSessionId));
27367
+ if (!source.ok)
27368
+ return source;
27369
+ return source.value ? { ok: true, value: source.value } : {
27370
+ ok: false,
27371
+ error: failure("OpenCode Session is no longer importable", "sessionNotFound")
27372
+ };
27373
+ }
27374
+ };
27375
+ /** Read-only discovery on a private server: no Session is created, loaded or prompted. */
27376
+ async #discover(read) {
27377
+ if (this.#closed)
27378
+ return { ok: false, error: failure("OpenCode Adapter is closed", "invalidState") };
27379
+ const connection = new V2Connection(this.options, process.cwd());
27380
+ this.#connections.add(connection);
27381
+ try {
27382
+ const value = await read(await connection.client());
27383
+ if (this.#closed)
27384
+ throw new Error("OpenCode Adapter closed during Session discovery");
27385
+ return { ok: true, value };
27386
+ } catch {
27387
+ return {
27388
+ ok: false,
27389
+ error: this.#closed ? failure("OpenCode Adapter is closed", "invalidState") : failure("OpenCode sessions could not be read; check the installation and retry", "unavailable")
27390
+ };
27391
+ } finally {
27392
+ await connection.close();
27393
+ this.#connections.delete(connection);
27394
+ }
27395
+ }
27175
27396
  async open(input) {
27176
27397
  try {
27177
- input = { ...input, cwd: fs6.realpathSync(input.cwd) };
27398
+ input = { ...input, cwd: fs7.realpathSync(input.cwd) };
27178
27399
  } catch (error51) {
27179
27400
  return errorResult(error51);
27180
27401
  }
@@ -27354,6 +27575,36 @@ var OpenCodeAdapter2 = class {
27354
27575
  this.#adapters.add(adapter);
27355
27576
  return adapter;
27356
27577
  }
27578
+ sessionImport = {
27579
+ listCandidates: () => this.#discover((imports) => imports.listCandidates()),
27580
+ resolveCandidate: (nativeSessionId) => this.#discover((imports) => imports.resolveCandidate(nativeSessionId))
27581
+ };
27582
+ /** Session import follows the selected CLI's protocol, like every other operation. */
27583
+ async #discover(read) {
27584
+ if (this.#closed)
27585
+ return { ok: false, error: failure("OpenCode Adapter is closed", "invalidState") };
27586
+ let adapter;
27587
+ try {
27588
+ adapter = await this.#select();
27589
+ if (!(adapter instanceof V2Adapter))
27590
+ return {
27591
+ ok: false,
27592
+ // v1 answers per project only; there is no native listing across projects to import from.
27593
+ error: failure("OpenCode Session import requires OpenCode v2", "unsupported")
27594
+ };
27595
+ return await read(adapter.sessionImport);
27596
+ } catch (error51) {
27597
+ return {
27598
+ ok: false,
27599
+ error: this.#closed ? failure("OpenCode Adapter is closed", "invalidState") : normalize(error51)
27600
+ };
27601
+ } finally {
27602
+ if (adapter) {
27603
+ await adapter.close();
27604
+ this.#adapters.delete(adapter);
27605
+ }
27606
+ }
27607
+ }
27357
27608
  async inspect(input = {}) {
27358
27609
  let adapter;
27359
27610
  try {
@@ -27410,7 +27661,7 @@ function normalize(error51) {
27410
27661
  // dist/installation.js
27411
27662
  import { realpath as realpath2 } from "node:fs/promises";
27412
27663
  import { homedir as homedir3 } from "node:os";
27413
- import path11 from "node:path";
27664
+ import path12 from "node:path";
27414
27665
  function createOpenCodeInstallation(environment, command) {
27415
27666
  let update;
27416
27667
  return createInstallationManager({
@@ -27431,8 +27682,8 @@ function createOpenCodeInstallation(environment, command) {
27431
27682
  const release = JSON.parse(await fetchInstallationText("https://api.github.com/repos/anomalyco/opencode/releases/latest"));
27432
27683
  latestVersion = installationVersion(release.tag_name);
27433
27684
  const home = environment.HOME ?? environment.USERPROFILE ?? homedir3();
27434
- const standard = path11.join(home, ".opencode", "bin", process.platform === "win32" ? "opencode.exe" : "opencode");
27435
- canUpdate = process.platform !== "win32" && path11.resolve(executable) === standard && await realpath2(executable) === standard;
27685
+ const standard = path12.join(home, ".opencode", "bin", process.platform === "win32" ? "opencode.exe" : "opencode");
27686
+ canUpdate = process.platform !== "win32" && path12.resolve(executable) === standard && await realpath2(executable) === standard;
27436
27687
  update = async (version2) => {
27437
27688
  await runInstallationCommand(executable, ["upgrade", version2, "--method", "curl"], environment, 3e5);
27438
27689
  };
@@ -27442,7 +27693,10 @@ function createOpenCodeInstallation(environment, command) {
27442
27693
  latestVersion,
27443
27694
  updateAvailable: newerInstallationVersion(currentVersion, latestVersion),
27444
27695
  canUpdate,
27445
- ...!canUpdate ? { message: "Use the original package manager to update this OpenCode installation." } : {}
27696
+ ...!canUpdate ? {
27697
+ messageCode: "original-installer",
27698
+ message: "Use the original package manager to update this OpenCode installation."
27699
+ } : {}
27446
27700
  };
27447
27701
  },
27448
27702
  async update(state) {