@liberseek/boft-cli-win32-arm64 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.
- package/README.md +1 -1
- package/app/codexhost-distribution.json +1 -1
- package/app/console-server.mjs +16598 -16440
- package/app/console-web.js +3628 -1789
- package/app/desktop-controller.mjs +16256 -351
- package/app/host-runtime.mjs +4360 -962
- package/app/plugins/antigravity/plugin.mjs +86 -2
- package/app/plugins/claude-code/plugin.mjs +399 -102
- package/app/plugins/codebuddy/plugin.mjs +733 -136
- package/app/plugins/cursor-cli/plugin.mjs +436 -122
- package/app/plugins/deepseek-harness/plugin.mjs +87 -2
- package/app/plugins/enabled.json +2 -1
- package/app/plugins/grok/plugin.mjs +464 -58
- package/app/plugins/hermes/plugin.mjs +3307 -7685
- package/app/plugins/kimi-code/plugin.mjs +376 -43
- package/app/plugins/kiro-cli/plugin.mjs +390 -48
- package/app/plugins/muse/plugin.mjs +86 -2
- package/app/plugins/omp/plugin.mjs +539 -105
- package/app/plugins/opencode/plugin.mjs +333 -79
- package/app/plugins/pi/plugin.mjs +200 -57
- package/app/plugins/qoder/plugin.mjs +317 -38
- package/app/plugins/qoder-cn/plugin.mjs +317 -38
- package/app/plugins/workbuddy/plugin.mjs +704 -98
- package/app/plugins/zcode/assets/icon.svg +8 -0
- package/app/plugins/zcode/manifest.json +14 -0
- package/app/plugins/zcode/plugin.mjs +19304 -0
- package/app/renderer-extension.js +2766 -695
- package/bin/boft.exe +0 -0
- package/libexec/boft-node-repl.exe +0 -0
- package/libexec/boft-shim.exe +0 -0
- package/libexec/boft-updater.exe +0 -0
- package/package.json +2 -2
|
@@ -488,8 +488,8 @@ function createHarnessInstaller(environment, source) {
|
|
|
488
488
|
}
|
|
489
489
|
|
|
490
490
|
// dist/kimi-adapter.js
|
|
491
|
-
import { readFile as
|
|
492
|
-
import
|
|
491
|
+
import { readFile as readFile6 } from "node:fs/promises";
|
|
492
|
+
import path9 from "node:path";
|
|
493
493
|
import { isDeepStrictEqual } from "node:util";
|
|
494
494
|
|
|
495
495
|
// ../../../node_modules/zod/v4/classic/external.js
|
|
@@ -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,
|
|
1262
|
-
if (!
|
|
1261
|
+
function getElementAtPath(obj, path10) {
|
|
1262
|
+
if (!path10)
|
|
1263
1263
|
return obj;
|
|
1264
|
-
return
|
|
1264
|
+
return path10.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(
|
|
1673
|
+
function prefixIssues(path10, issues) {
|
|
1674
1674
|
return issues.map((iss) => {
|
|
1675
1675
|
var _a3;
|
|
1676
1676
|
(_a3 = iss).path ?? (_a3.path = []);
|
|
1677
|
-
iss.path.unshift(
|
|
1677
|
+
iss.path.unshift(path10);
|
|
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,
|
|
1824
|
+
const processError = (error52, path10 = []) => {
|
|
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 }, [...
|
|
1827
|
+
issue2.errors.map((issues) => processError({ issues }, [...path10, ...issue2.path]));
|
|
1828
1828
|
} else if (issue2.code === "invalid_key") {
|
|
1829
|
-
processError({ issues: issue2.issues }, [...
|
|
1829
|
+
processError({ issues: issue2.issues }, [...path10, ...issue2.path]);
|
|
1830
1830
|
} else if (issue2.code === "invalid_element") {
|
|
1831
|
-
processError({ issues: issue2.issues }, [...
|
|
1831
|
+
processError({ issues: issue2.issues }, [...path10, ...issue2.path]);
|
|
1832
1832
|
} else {
|
|
1833
|
-
const fullpath = [...
|
|
1833
|
+
const fullpath = [...path10, ...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,
|
|
1860
|
+
const processError = (error52, path10 = []) => {
|
|
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 }, [...
|
|
1864
|
+
issue2.errors.map((issues) => processError({ issues }, [...path10, ...issue2.path]));
|
|
1865
1865
|
} else if (issue2.code === "invalid_key") {
|
|
1866
|
-
processError({ issues: issue2.issues }, [...
|
|
1866
|
+
processError({ issues: issue2.issues }, [...path10, ...issue2.path]);
|
|
1867
1867
|
} else if (issue2.code === "invalid_element") {
|
|
1868
|
-
processError({ issues: issue2.issues }, [...
|
|
1868
|
+
processError({ issues: issue2.issues }, [...path10, ...issue2.path]);
|
|
1869
1869
|
} else {
|
|
1870
|
-
const fullpath = [...
|
|
1870
|
+
const fullpath = [...path10, ...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
|
|
1903
|
-
for (const seg of
|
|
1902
|
+
const path10 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
|
|
1903
|
+
for (const seg of path10) {
|
|
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
|
|
14596
|
-
if (
|
|
14595
|
+
const path10 = ref.slice(1).split("/").filter(Boolean);
|
|
14596
|
+
if (path10.length === 0) {
|
|
14597
14597
|
return ctx.rootSchema;
|
|
14598
14598
|
}
|
|
14599
14599
|
const defsKey = ctx.version === "draft-2020-12" ? "$defs" : "definitions";
|
|
14600
|
-
if (
|
|
14601
|
-
const key =
|
|
14600
|
+
if (path10[0] === defsKey) {
|
|
14601
|
+
const key = path10[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
|
-
|
|
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
|
|
|
@@ -21253,16 +21337,16 @@ var Diff = class {
|
|
|
21253
21337
|
}
|
|
21254
21338
|
}
|
|
21255
21339
|
}
|
|
21256
|
-
addToPath(
|
|
21257
|
-
const last =
|
|
21340
|
+
addToPath(path10, added, removed, oldPosInc, options) {
|
|
21341
|
+
const last = path10.lastComponent;
|
|
21258
21342
|
if (last && !options.oneChangePerToken && last.added === added && last.removed === removed) {
|
|
21259
21343
|
return {
|
|
21260
|
-
oldPos:
|
|
21344
|
+
oldPos: path10.oldPos + oldPosInc,
|
|
21261
21345
|
lastComponent: { count: last.count + 1, added, removed, previousComponent: last.previousComponent }
|
|
21262
21346
|
};
|
|
21263
21347
|
} else {
|
|
21264
21348
|
return {
|
|
21265
|
-
oldPos:
|
|
21349
|
+
oldPos: path10.oldPos + oldPosInc,
|
|
21266
21350
|
lastComponent: { count: 1, added, removed, previousComponent: last }
|
|
21267
21351
|
};
|
|
21268
21352
|
}
|
|
@@ -23216,19 +23300,259 @@ async function readKimiSessionUsage(sessionId, options = {}) {
|
|
|
23216
23300
|
}
|
|
23217
23301
|
}
|
|
23218
23302
|
|
|
23303
|
+
// dist/session-import.js
|
|
23304
|
+
import { readFile as readFile4, stat } from "node:fs/promises";
|
|
23305
|
+
import path7 from "node:path";
|
|
23306
|
+
|
|
23307
|
+
// ../../harness-adapter/dist/session-import.js
|
|
23308
|
+
import { lstat } from "node:fs/promises";
|
|
23309
|
+
var SessionImportChangedError = class extends Error {
|
|
23310
|
+
constructor(message = "Native Session changed during discovery; refresh and retry") {
|
|
23311
|
+
super(message);
|
|
23312
|
+
this.name = "SessionImportChangedError";
|
|
23313
|
+
}
|
|
23314
|
+
};
|
|
23315
|
+
function isMissingFileError(error51) {
|
|
23316
|
+
return typeof error51 === "object" && error51 !== null && "code" in error51 && error51.code === "ENOENT";
|
|
23317
|
+
}
|
|
23318
|
+
function sameFileFingerprint(left, right) {
|
|
23319
|
+
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;
|
|
23320
|
+
}
|
|
23321
|
+
var STORAGE_ACCESS_ERRORS = /* @__PURE__ */ new Set(["EACCES", "EPERM", "EIO", "EMFILE", "ENFILE"]);
|
|
23322
|
+
function isStorageAccessError(error51) {
|
|
23323
|
+
return typeof error51 === "object" && error51 !== null && "code" in error51 && typeof error51.code === "string" && STORAGE_ACCESS_ERRORS.has(error51.code);
|
|
23324
|
+
}
|
|
23325
|
+
async function optionalLstat(file2) {
|
|
23326
|
+
try {
|
|
23327
|
+
return await lstat(file2);
|
|
23328
|
+
} catch (error51) {
|
|
23329
|
+
if (isMissingFileError(error51))
|
|
23330
|
+
return null;
|
|
23331
|
+
throw error51;
|
|
23332
|
+
}
|
|
23333
|
+
}
|
|
23334
|
+
async function readStableFiles(files, read) {
|
|
23335
|
+
const before = await Promise.all(files.map(optionalLstat));
|
|
23336
|
+
const value = await read(before);
|
|
23337
|
+
const after = await Promise.all(files.map(optionalLstat));
|
|
23338
|
+
if (before.some((info, index) => !sameFileFingerprint(info, after[index] ?? null)))
|
|
23339
|
+
throw new SessionImportChangedError();
|
|
23340
|
+
return value;
|
|
23341
|
+
}
|
|
23342
|
+
function sessionImportTitle(value, maxLength = HARNESS_SESSION_IMPORT_TITLE_MAX_LENGTH) {
|
|
23343
|
+
if (typeof value !== "string")
|
|
23344
|
+
return null;
|
|
23345
|
+
const normalized = value.replaceAll("\0", "").replaceAll(/\s+/gu, " ").trim();
|
|
23346
|
+
if (!normalized)
|
|
23347
|
+
return null;
|
|
23348
|
+
if (normalized.length <= maxLength)
|
|
23349
|
+
return normalized;
|
|
23350
|
+
const characters = [...normalized];
|
|
23351
|
+
if (characters.length <= maxLength)
|
|
23352
|
+
return normalized;
|
|
23353
|
+
return `${characters.slice(0, maxLength - 1).join("").trimEnd()}…`;
|
|
23354
|
+
}
|
|
23355
|
+
function sessionImportCandidate(input) {
|
|
23356
|
+
const time3 = typeof input.updatedAt === "number" ? input.updatedAt : typeof input.updatedAt === "string" ? Date.parse(input.updatedAt) : Number.NaN;
|
|
23357
|
+
const parsed = harnessSessionImportCandidateSchema.safeParse({
|
|
23358
|
+
nativeSessionId: input.nativeSessionId,
|
|
23359
|
+
cwd: input.cwd,
|
|
23360
|
+
title: typeof input.title === "string" && input.title.trim().length > 0 ? input.title : null,
|
|
23361
|
+
updatedAt: Math.floor(time3),
|
|
23362
|
+
// Unknown must stay unknown; only an explicit boolean is a native statement.
|
|
23363
|
+
running: typeof input.running === "boolean" ? input.running : null
|
|
23364
|
+
});
|
|
23365
|
+
return parsed.success ? parsed.data : null;
|
|
23366
|
+
}
|
|
23367
|
+
var SessionImportScope = class {
|
|
23368
|
+
#abort = new AbortController();
|
|
23369
|
+
#options;
|
|
23370
|
+
#pending = /* @__PURE__ */ new Set();
|
|
23371
|
+
constructor(options) {
|
|
23372
|
+
this.#options = options;
|
|
23373
|
+
}
|
|
23374
|
+
#closed() {
|
|
23375
|
+
return {
|
|
23376
|
+
ok: false,
|
|
23377
|
+
error: { code: "invalidState", message: this.#options.closedMessage, retryable: false }
|
|
23378
|
+
};
|
|
23379
|
+
}
|
|
23380
|
+
read(operation) {
|
|
23381
|
+
const signal = this.#abort.signal;
|
|
23382
|
+
if (signal.aborted)
|
|
23383
|
+
return Promise.resolve(this.#closed());
|
|
23384
|
+
let started;
|
|
23385
|
+
try {
|
|
23386
|
+
started = operation(signal);
|
|
23387
|
+
} catch (error51) {
|
|
23388
|
+
started = Promise.reject(error51 instanceof Error ? error51 : new Error("Session read failed"));
|
|
23389
|
+
}
|
|
23390
|
+
const request = started.then((value) => signal.aborted ? this.#closed() : { ok: true, value }).catch(() => signal.aborted ? this.#closed() : {
|
|
23391
|
+
ok: false,
|
|
23392
|
+
error: {
|
|
23393
|
+
code: "unavailable",
|
|
23394
|
+
message: this.#options.unavailableMessage,
|
|
23395
|
+
retryable: true
|
|
23396
|
+
}
|
|
23397
|
+
}).finally(() => this.#pending.delete(request));
|
|
23398
|
+
this.#pending.add(request);
|
|
23399
|
+
return request;
|
|
23400
|
+
}
|
|
23401
|
+
/** `read` for `resolveCandidate`: a null source is the selected Session having disappeared. */
|
|
23402
|
+
async resolve(operation) {
|
|
23403
|
+
const result = await this.read(operation);
|
|
23404
|
+
if (!result.ok)
|
|
23405
|
+
return result;
|
|
23406
|
+
return result.value ? { ok: true, value: result.value } : {
|
|
23407
|
+
ok: false,
|
|
23408
|
+
error: {
|
|
23409
|
+
code: "sessionNotFound",
|
|
23410
|
+
message: this.#options.notFoundMessage,
|
|
23411
|
+
retryable: false
|
|
23412
|
+
}
|
|
23413
|
+
};
|
|
23414
|
+
}
|
|
23415
|
+
/** Idempotent. Resolves after every started read has settled. */
|
|
23416
|
+
async close() {
|
|
23417
|
+
this.#abort.abort();
|
|
23418
|
+
await Promise.allSettled(this.#pending);
|
|
23419
|
+
}
|
|
23420
|
+
};
|
|
23421
|
+
|
|
23422
|
+
// dist/session-import.js
|
|
23423
|
+
function isRecord5(value) {
|
|
23424
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
23425
|
+
}
|
|
23426
|
+
var KimiSessionImport = class {
|
|
23427
|
+
#home;
|
|
23428
|
+
#scope = new SessionImportScope({
|
|
23429
|
+
closedMessage: "Kimi Session import is closed",
|
|
23430
|
+
unavailableMessage: "Kimi sessions could not be read; close native clients, check storage access and retry",
|
|
23431
|
+
notFoundMessage: "Kimi Session is no longer importable"
|
|
23432
|
+
});
|
|
23433
|
+
constructor(options) {
|
|
23434
|
+
this.#home = getKimiCodeHome(options.homeDirectory, options.environment);
|
|
23435
|
+
}
|
|
23436
|
+
listCandidates() {
|
|
23437
|
+
return this.#scope.read(async (signal) => {
|
|
23438
|
+
const candidates = [];
|
|
23439
|
+
for (const nativeSessionId of await this.#indexedSessions(signal)) {
|
|
23440
|
+
try {
|
|
23441
|
+
const source = await this.#source(nativeSessionId, signal);
|
|
23442
|
+
if (source)
|
|
23443
|
+
candidates.push(source.candidate);
|
|
23444
|
+
} catch (error51) {
|
|
23445
|
+
if (!(error51 instanceof SessionImportChangedError))
|
|
23446
|
+
throw error51;
|
|
23447
|
+
}
|
|
23448
|
+
}
|
|
23449
|
+
return candidates;
|
|
23450
|
+
});
|
|
23451
|
+
}
|
|
23452
|
+
resolveCandidate(nativeSessionId) {
|
|
23453
|
+
return this.#scope.resolve(async (signal) => (await this.#indexedSessions(signal)).has(nativeSessionId) ? this.#source(nativeSessionId, signal) : null);
|
|
23454
|
+
}
|
|
23455
|
+
close() {
|
|
23456
|
+
return this.#scope.close();
|
|
23457
|
+
}
|
|
23458
|
+
/** Live identities in Kimi's index. The last record of an identity decides, as in resume. */
|
|
23459
|
+
async #indexedSessions(signal) {
|
|
23460
|
+
const live = /* @__PURE__ */ new Set();
|
|
23461
|
+
let content;
|
|
23462
|
+
try {
|
|
23463
|
+
content = await readFile4(path7.join(this.#home, "session_index.jsonl"), {
|
|
23464
|
+
encoding: "utf8",
|
|
23465
|
+
signal
|
|
23466
|
+
});
|
|
23467
|
+
} catch (error51) {
|
|
23468
|
+
signal.throwIfAborted();
|
|
23469
|
+
if (isMissingFileError(error51))
|
|
23470
|
+
return live;
|
|
23471
|
+
throw error51;
|
|
23472
|
+
}
|
|
23473
|
+
for (const line of content.split("\n")) {
|
|
23474
|
+
if (!line.trim())
|
|
23475
|
+
continue;
|
|
23476
|
+
let entry;
|
|
23477
|
+
try {
|
|
23478
|
+
entry = JSON.parse(line);
|
|
23479
|
+
} catch {
|
|
23480
|
+
continue;
|
|
23481
|
+
}
|
|
23482
|
+
if (!isRecord5(entry) || typeof entry.sessionId !== "string" || !entry.sessionId)
|
|
23483
|
+
continue;
|
|
23484
|
+
if (entry.deleted || typeof entry.sessionDir !== "string")
|
|
23485
|
+
live.delete(entry.sessionId);
|
|
23486
|
+
else
|
|
23487
|
+
live.add(entry.sessionId);
|
|
23488
|
+
}
|
|
23489
|
+
return live;
|
|
23490
|
+
}
|
|
23491
|
+
async #source(nativeSessionId, signal) {
|
|
23492
|
+
signal.throwIfAborted();
|
|
23493
|
+
const options = { kimiCodeHome: this.#home };
|
|
23494
|
+
let located;
|
|
23495
|
+
try {
|
|
23496
|
+
located = await locateKimiSession(nativeSessionId, options);
|
|
23497
|
+
} catch (error51) {
|
|
23498
|
+
if (isStorageAccessError(error51))
|
|
23499
|
+
throw error51;
|
|
23500
|
+
return null;
|
|
23501
|
+
}
|
|
23502
|
+
if (!located)
|
|
23503
|
+
return null;
|
|
23504
|
+
const { state } = located;
|
|
23505
|
+
const files = [
|
|
23506
|
+
path7.join(located.sessionDir, "state.json"),
|
|
23507
|
+
path7.join(located.mainHomeDir, "wire.jsonl")
|
|
23508
|
+
];
|
|
23509
|
+
return readStableFiles(files, async ([stateInfo, wire]) => {
|
|
23510
|
+
if (!stateInfo?.isFile() || !wire?.isFile())
|
|
23511
|
+
return null;
|
|
23512
|
+
try {
|
|
23513
|
+
if (typeof state.cwd !== "string" || !path7.isAbsolute(state.cwd))
|
|
23514
|
+
return null;
|
|
23515
|
+
const cwd = path7.resolve(state.cwd);
|
|
23516
|
+
if (!(await stat(cwd)).isDirectory())
|
|
23517
|
+
return null;
|
|
23518
|
+
signal.throwIfAborted();
|
|
23519
|
+
const { turns } = await readKimiSessionSnapshot(nativeSessionId, options);
|
|
23520
|
+
const prompt = turns.flatMap((turn) => turn.input).find((input) => input.type === "text" && input.text.trim().length > 0);
|
|
23521
|
+
if (!prompt || prompt.type !== "text")
|
|
23522
|
+
return null;
|
|
23523
|
+
const activity = turns.flatMap((turn) => [turn.completedAtMs, turn.startedAtMs]).filter((time3) => typeof time3 === "number" && Number.isFinite(time3));
|
|
23524
|
+
const candidate = sessionImportCandidate({
|
|
23525
|
+
nativeSessionId,
|
|
23526
|
+
cwd,
|
|
23527
|
+
title: sessionImportTitle(state.title) ?? sessionImportTitle(prompt.text),
|
|
23528
|
+
// Wire record times are milliseconds; the state file's unit is not documented.
|
|
23529
|
+
updatedAt: activity.length > 0 ? Math.max(...activity) : wire.mtimeMs
|
|
23530
|
+
// Kimi has no cross-process activity marker: idleness cannot be established.
|
|
23531
|
+
});
|
|
23532
|
+
return candidate ? { candidate, nativeRef: createKimiNativeSessionRef(nativeSessionId, cwd) } : null;
|
|
23533
|
+
} catch (error51) {
|
|
23534
|
+
signal.throwIfAborted();
|
|
23535
|
+
if (isStorageAccessError(error51))
|
|
23536
|
+
throw error51;
|
|
23537
|
+
return null;
|
|
23538
|
+
}
|
|
23539
|
+
});
|
|
23540
|
+
}
|
|
23541
|
+
};
|
|
23542
|
+
|
|
23219
23543
|
// dist/kimi-session.js
|
|
23220
23544
|
import { setTimeout as delay } from "node:timers/promises";
|
|
23221
23545
|
|
|
23222
23546
|
// dist/command-history.js
|
|
23223
|
-
import { appendFile, readFile as
|
|
23224
|
-
import
|
|
23547
|
+
import { appendFile, readFile as readFile5, writeFile as writeFile3 } from "node:fs/promises";
|
|
23548
|
+
import path8 from "node:path";
|
|
23225
23549
|
async function readKimiCommandHistory(sessionId, options) {
|
|
23226
23550
|
const located = await locateKimiSession(sessionId, options);
|
|
23227
23551
|
if (!located)
|
|
23228
23552
|
return [];
|
|
23229
23553
|
let content;
|
|
23230
23554
|
try {
|
|
23231
|
-
content = await
|
|
23555
|
+
content = await readFile5(path8.join(located.sessionDir, "codexhost-commands.jsonl"), "utf8");
|
|
23232
23556
|
} catch (error51) {
|
|
23233
23557
|
if (error51.code === "ENOENT")
|
|
23234
23558
|
return [];
|
|
@@ -23258,7 +23582,7 @@ async function appendKimiCommandHistory(turn, options) {
|
|
|
23258
23582
|
const located = await locateKimiSession(turn.nativeTurnRef.nativeSessionId, options);
|
|
23259
23583
|
if (!located)
|
|
23260
23584
|
throw new Error("Cannot persist Kimi command: native session is missing");
|
|
23261
|
-
await appendFile(
|
|
23585
|
+
await appendFile(path8.join(located.sessionDir, "codexhost-commands.jsonl"), `${JSON.stringify(turn)}
|
|
23262
23586
|
`, "utf8");
|
|
23263
23587
|
}
|
|
23264
23588
|
async function copyKimiCommandHistory(turns, sessionId, options) {
|
|
@@ -23272,7 +23596,7 @@ async function copyKimiCommandHistory(turns, sessionId, options) {
|
|
|
23272
23596
|
nativeTurnRef: { ...turn.nativeTurnRef, nativeSessionId: sessionId },
|
|
23273
23597
|
...turn.checkpoint ? { checkpoint: { ...turn.checkpoint, nativeSessionId: sessionId } } : {}
|
|
23274
23598
|
}));
|
|
23275
|
-
await writeFile3(
|
|
23599
|
+
await writeFile3(path8.join(located.sessionDir, "codexhost-commands.jsonl"), copied.map((turn) => `${JSON.stringify(turn)}
|
|
23276
23600
|
`).join(""), "utf8");
|
|
23277
23601
|
}
|
|
23278
23602
|
|
|
@@ -24444,6 +24768,7 @@ function stateFromConfig(sessionId, cwd, configOptions) {
|
|
|
24444
24768
|
}
|
|
24445
24769
|
var KimiAdapter = class {
|
|
24446
24770
|
harnessId = kimiHarnessId3;
|
|
24771
|
+
sessionImport;
|
|
24447
24772
|
#options;
|
|
24448
24773
|
#deps;
|
|
24449
24774
|
#sessions = /* @__PURE__ */ new Set();
|
|
@@ -24456,6 +24781,10 @@ var KimiAdapter = class {
|
|
|
24456
24781
|
constructor(options = {}, dependencies = {}) {
|
|
24457
24782
|
this.#options = options;
|
|
24458
24783
|
this.#deps = dependencies;
|
|
24784
|
+
this.sessionImport = new KimiSessionImport({
|
|
24785
|
+
environment: { ...process.env, ...options.environment },
|
|
24786
|
+
homeDirectory: options.homeDirectory
|
|
24787
|
+
});
|
|
24459
24788
|
}
|
|
24460
24789
|
async inspectAccount() {
|
|
24461
24790
|
if (this.#closed)
|
|
@@ -24494,10 +24823,10 @@ var KimiAdapter = class {
|
|
|
24494
24823
|
return result;
|
|
24495
24824
|
}
|
|
24496
24825
|
const kimiHome2 = getKimiCodeHome(this.#options.homeDirectory, environment);
|
|
24497
|
-
const configPath =
|
|
24826
|
+
const configPath = path9.join(kimiHome2, "config.toml");
|
|
24498
24827
|
let nativeConfig = null;
|
|
24499
24828
|
try {
|
|
24500
|
-
const configContent = await
|
|
24829
|
+
const configContent = await readFile6(configPath, "utf8");
|
|
24501
24830
|
nativeConfig = parseKimiConfigToml(configContent);
|
|
24502
24831
|
} catch {
|
|
24503
24832
|
nativeConfig = null;
|
|
@@ -24608,10 +24937,10 @@ var KimiAdapter = class {
|
|
|
24608
24937
|
onFault: (error51) => session?.handleTransportFault(error51)
|
|
24609
24938
|
});
|
|
24610
24939
|
const kimiHome2 = getKimiCodeHome(this.#options.homeDirectory, environment);
|
|
24611
|
-
const configPath =
|
|
24940
|
+
const configPath = path9.join(kimiHome2, "config.toml");
|
|
24612
24941
|
let nativeConfig = null;
|
|
24613
24942
|
try {
|
|
24614
|
-
const configContent = await
|
|
24943
|
+
const configContent = await readFile6(configPath, "utf8");
|
|
24615
24944
|
nativeConfig = parseKimiConfigToml(configContent);
|
|
24616
24945
|
} catch {
|
|
24617
24946
|
nativeConfig = null;
|
|
@@ -24668,7 +24997,7 @@ var KimiAdapter = class {
|
|
|
24668
24997
|
await transport.close().catch(() => void 0);
|
|
24669
24998
|
return err2("checkpointNotFound", "Kimi Checkpoint does not belong to the source Native Session");
|
|
24670
24999
|
}
|
|
24671
|
-
if (
|
|
25000
|
+
if (path9.resolve(cwd) !== path9.resolve(located.state.cwd)) {
|
|
24672
25001
|
await transport.close().catch(() => void 0);
|
|
24673
25002
|
return err2("unsupported", "Kimi Code cannot fork across different working directories");
|
|
24674
25003
|
}
|
|
@@ -24791,7 +25120,7 @@ var KimiAdapter = class {
|
|
|
24791
25120
|
const located = await locateKimiSession(sourceId, historyOptions);
|
|
24792
25121
|
if (!located)
|
|
24793
25122
|
return err2("sessionNotFound", "Kimi source session was not found");
|
|
24794
|
-
if (
|
|
25123
|
+
if (path9.resolve(input.cwd) !== path9.resolve(located.state.cwd))
|
|
24795
25124
|
return err2("unsupported", "Kimi cannot roll back into another working directory");
|
|
24796
25125
|
const source = [...this.#sessions].find((candidate) => candidate.initialState.nativeRef?.nativeSessionId === sourceId);
|
|
24797
25126
|
if (source) {
|
|
@@ -24849,6 +25178,7 @@ var KimiAdapter = class {
|
|
|
24849
25178
|
return;
|
|
24850
25179
|
this.#closed = true;
|
|
24851
25180
|
this.#commandCatalog = KIMI_DEFAULT_COMMAND_CATALOG;
|
|
25181
|
+
await this.sessionImport.close();
|
|
24852
25182
|
for (const session of this.#sessions) {
|
|
24853
25183
|
await session.close().catch(() => void 0);
|
|
24854
25184
|
}
|
|
@@ -24857,7 +25187,7 @@ var KimiAdapter = class {
|
|
|
24857
25187
|
};
|
|
24858
25188
|
|
|
24859
25189
|
// dist/installation.js
|
|
24860
|
-
import { open, readFile as
|
|
25190
|
+
import { open, readFile as readFile7 } from "node:fs/promises";
|
|
24861
25191
|
import { homedir as homedir3 } from "node:os";
|
|
24862
25192
|
import { join as join3 } from "node:path";
|
|
24863
25193
|
function createKimiInstallation(environment) {
|
|
@@ -24880,7 +25210,7 @@ function createKimiInstallation(environment) {
|
|
|
24880
25210
|
async check() {
|
|
24881
25211
|
const currentVersion = versionFromOutput(await run(["--version"]));
|
|
24882
25212
|
const home = environment.KIMI_CODE_HOME ?? join3(environment.HOME ?? homedir3(), ".kimi-code");
|
|
24883
|
-
const region = await
|
|
25213
|
+
const region = await readFile7(join3(home, "region"), "utf8").catch(() => "");
|
|
24884
25214
|
const base = region.trim() === "global" ? "https://code.kimi.ai/kimi-code" : "https://code.kimi.com/kimi-code";
|
|
24885
25215
|
const latestVersion = installationVersion(await fetchInstallationText(`${base}/latest`));
|
|
24886
25216
|
const npm = await npmInstallation(executable(), ["@moonshot-ai/kimi-code"], environment);
|
|
@@ -24890,7 +25220,10 @@ function createKimiInstallation(environment) {
|
|
|
24890
25220
|
latestVersion,
|
|
24891
25221
|
updateAvailable: newerInstallationVersion(currentVersion, latestVersion),
|
|
24892
25222
|
canUpdate,
|
|
24893
|
-
...!canUpdate ? {
|
|
25223
|
+
...!canUpdate ? {
|
|
25224
|
+
messageCode: "original-installer",
|
|
25225
|
+
message: "Use the original installer to update this Kimi installation"
|
|
25226
|
+
} : {}
|
|
24894
25227
|
};
|
|
24895
25228
|
},
|
|
24896
25229
|
async update(state) {
|