@liberseek/boft-cli-linux-x64 0.7.8 → 0.7.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/app/codexhost-distribution.json +1 -1
- package/app/console-server.mjs +16583 -16433
- package/app/console-web.js +3524 -1714
- package/app/desktop-controller.mjs +16241 -350
- package/app/host-runtime.mjs +4343 -954
- package/app/plugins/antigravity/plugin.mjs +81 -0
- package/app/plugins/claude-code/plugin.mjs +393 -100
- package/app/plugins/codebuddy/plugin.mjs +727 -134
- package/app/plugins/cursor-cli/plugin.mjs +431 -120
- package/app/plugins/deepseek-harness/plugin.mjs +81 -0
- package/app/plugins/enabled.json +2 -1
- package/app/plugins/grok/plugin.mjs +459 -56
- package/app/plugins/hermes/plugin.mjs +3301 -7739
- package/app/plugins/kimi-code/plugin.mjs +367 -40
- package/app/plugins/kiro-cli/plugin.mjs +374 -35
- package/app/plugins/muse/plugin.mjs +81 -0
- package/app/plugins/omp/plugin.mjs +505 -97
- package/app/plugins/opencode/plugin.mjs +324 -76
- package/app/plugins/pi/plugin.mjs +195 -55
- package/app/plugins/qoder/plugin.mjs +281 -35
- package/app/plugins/qoder-cn/plugin.mjs +281 -35
- package/app/plugins/workbuddy/plugin.mjs +699 -96
- 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 +2514 -526
- package/bin/boft +0 -0
- package/libexec/boft-shim +0 -0
- package/libexec/boft-updater +0 -0
- package/package.json +1 -1
|
@@ -508,16 +508,16 @@ var Diff = class {
|
|
|
508
508
|
}
|
|
509
509
|
}
|
|
510
510
|
}
|
|
511
|
-
addToPath(
|
|
512
|
-
const last =
|
|
511
|
+
addToPath(path8, added, removed, oldPosInc, options) {
|
|
512
|
+
const last = path8.lastComponent;
|
|
513
513
|
if (last && !options.oneChangePerToken && last.added === added && last.removed === removed) {
|
|
514
514
|
return {
|
|
515
|
-
oldPos:
|
|
515
|
+
oldPos: path8.oldPos + oldPosInc,
|
|
516
516
|
lastComponent: { count: last.count + 1, added, removed, previousComponent: last.previousComponent }
|
|
517
517
|
};
|
|
518
518
|
} else {
|
|
519
519
|
return {
|
|
520
|
-
oldPos:
|
|
520
|
+
oldPos: path8.oldPos + oldPosInc,
|
|
521
521
|
lastComponent: { count: 1, added, removed, previousComponent: last }
|
|
522
522
|
};
|
|
523
523
|
}
|
|
@@ -930,8 +930,8 @@ function splitLines(text) {
|
|
|
930
930
|
|
|
931
931
|
// dist/omp-adapter.js
|
|
932
932
|
import { randomUUID as randomUUID2 } from "node:crypto";
|
|
933
|
-
import { realpath as
|
|
934
|
-
import
|
|
933
|
+
import { realpath as realpath3, stat as stat2 } from "node:fs/promises";
|
|
934
|
+
import path6 from "node:path";
|
|
935
935
|
|
|
936
936
|
// ../../../node_modules/zod/v4/classic/external.js
|
|
937
937
|
var external_exports = {};
|
|
@@ -1699,10 +1699,10 @@ function mergeDefs(...defs) {
|
|
|
1699
1699
|
function cloneDef(schema) {
|
|
1700
1700
|
return mergeDefs(schema._zod.def);
|
|
1701
1701
|
}
|
|
1702
|
-
function getElementAtPath(obj,
|
|
1703
|
-
if (!
|
|
1702
|
+
function getElementAtPath(obj, path8) {
|
|
1703
|
+
if (!path8)
|
|
1704
1704
|
return obj;
|
|
1705
|
-
return
|
|
1705
|
+
return path8.reduce((acc, key) => acc?.[key], obj);
|
|
1706
1706
|
}
|
|
1707
1707
|
function promiseAllObject(promisesObj) {
|
|
1708
1708
|
const keys = Object.keys(promisesObj);
|
|
@@ -2111,11 +2111,11 @@ function explicitlyAborted(x, startIndex = 0) {
|
|
|
2111
2111
|
}
|
|
2112
2112
|
return false;
|
|
2113
2113
|
}
|
|
2114
|
-
function prefixIssues(
|
|
2114
|
+
function prefixIssues(path8, issues) {
|
|
2115
2115
|
return issues.map((iss) => {
|
|
2116
2116
|
var _a3;
|
|
2117
2117
|
(_a3 = iss).path ?? (_a3.path = []);
|
|
2118
|
-
iss.path.unshift(
|
|
2118
|
+
iss.path.unshift(path8);
|
|
2119
2119
|
return iss;
|
|
2120
2120
|
});
|
|
2121
2121
|
}
|
|
@@ -2262,16 +2262,16 @@ function flattenError(error51, mapper = (issue2) => issue2.message) {
|
|
|
2262
2262
|
}
|
|
2263
2263
|
function formatError(error51, mapper = (issue2) => issue2.message) {
|
|
2264
2264
|
const fieldErrors = { _errors: [] };
|
|
2265
|
-
const processError = (error52,
|
|
2265
|
+
const processError = (error52, path8 = []) => {
|
|
2266
2266
|
for (const issue2 of error52.issues) {
|
|
2267
2267
|
if (issue2.code === "invalid_union" && issue2.errors.length) {
|
|
2268
|
-
issue2.errors.map((issues) => processError({ issues }, [...
|
|
2268
|
+
issue2.errors.map((issues) => processError({ issues }, [...path8, ...issue2.path]));
|
|
2269
2269
|
} else if (issue2.code === "invalid_key") {
|
|
2270
|
-
processError({ issues: issue2.issues }, [...
|
|
2270
|
+
processError({ issues: issue2.issues }, [...path8, ...issue2.path]);
|
|
2271
2271
|
} else if (issue2.code === "invalid_element") {
|
|
2272
|
-
processError({ issues: issue2.issues }, [...
|
|
2272
|
+
processError({ issues: issue2.issues }, [...path8, ...issue2.path]);
|
|
2273
2273
|
} else {
|
|
2274
|
-
const fullpath = [...
|
|
2274
|
+
const fullpath = [...path8, ...issue2.path];
|
|
2275
2275
|
if (fullpath.length === 0) {
|
|
2276
2276
|
fieldErrors._errors.push(mapper(issue2));
|
|
2277
2277
|
} else {
|
|
@@ -2298,17 +2298,17 @@ function formatError(error51, mapper = (issue2) => issue2.message) {
|
|
|
2298
2298
|
}
|
|
2299
2299
|
function treeifyError(error51, mapper = (issue2) => issue2.message) {
|
|
2300
2300
|
const result = { errors: [] };
|
|
2301
|
-
const processError = (error52,
|
|
2301
|
+
const processError = (error52, path8 = []) => {
|
|
2302
2302
|
var _a3, _b;
|
|
2303
2303
|
for (const issue2 of error52.issues) {
|
|
2304
2304
|
if (issue2.code === "invalid_union" && issue2.errors.length) {
|
|
2305
|
-
issue2.errors.map((issues) => processError({ issues }, [...
|
|
2305
|
+
issue2.errors.map((issues) => processError({ issues }, [...path8, ...issue2.path]));
|
|
2306
2306
|
} else if (issue2.code === "invalid_key") {
|
|
2307
|
-
processError({ issues: issue2.issues }, [...
|
|
2307
|
+
processError({ issues: issue2.issues }, [...path8, ...issue2.path]);
|
|
2308
2308
|
} else if (issue2.code === "invalid_element") {
|
|
2309
|
-
processError({ issues: issue2.issues }, [...
|
|
2309
|
+
processError({ issues: issue2.issues }, [...path8, ...issue2.path]);
|
|
2310
2310
|
} else {
|
|
2311
|
-
const fullpath = [...
|
|
2311
|
+
const fullpath = [...path8, ...issue2.path];
|
|
2312
2312
|
if (fullpath.length === 0) {
|
|
2313
2313
|
result.errors.push(mapper(issue2));
|
|
2314
2314
|
continue;
|
|
@@ -2340,8 +2340,8 @@ function treeifyError(error51, mapper = (issue2) => issue2.message) {
|
|
|
2340
2340
|
}
|
|
2341
2341
|
function toDotPath(_path) {
|
|
2342
2342
|
const segs = [];
|
|
2343
|
-
const
|
|
2344
|
-
for (const seg of
|
|
2343
|
+
const path8 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
|
|
2344
|
+
for (const seg of path8) {
|
|
2345
2345
|
if (typeof seg === "number")
|
|
2346
2346
|
segs.push(`[${seg}]`);
|
|
2347
2347
|
else if (typeof seg === "symbol")
|
|
@@ -15033,13 +15033,13 @@ function resolveRef(ref, ctx) {
|
|
|
15033
15033
|
if (!ref.startsWith("#")) {
|
|
15034
15034
|
throw new Error("External $ref is not supported, only local refs (#/...) are allowed");
|
|
15035
15035
|
}
|
|
15036
|
-
const
|
|
15037
|
-
if (
|
|
15036
|
+
const path8 = ref.slice(1).split("/").filter(Boolean);
|
|
15037
|
+
if (path8.length === 0) {
|
|
15038
15038
|
return ctx.rootSchema;
|
|
15039
15039
|
}
|
|
15040
15040
|
const defsKey = ctx.version === "draft-2020-12" ? "$defs" : "definitions";
|
|
15041
|
-
if (
|
|
15042
|
-
const key =
|
|
15041
|
+
if (path8[0] === defsKey) {
|
|
15042
|
+
const key = path8[1];
|
|
15043
15043
|
if (!key || !ctx.defs[key]) {
|
|
15044
15044
|
throw new Error(`Reference not found: ${ref}`);
|
|
15045
15045
|
}
|
|
@@ -15527,6 +15527,10 @@ var hostTurnIdSchema = opaqueIdSchema.brand();
|
|
|
15527
15527
|
var hostItemIdSchema = opaqueIdSchema.brand();
|
|
15528
15528
|
var hostInteractionIdSchema = opaqueIdSchema.brand();
|
|
15529
15529
|
|
|
15530
|
+
// ../../shared-contracts/dist/thread-prewarm.js
|
|
15531
|
+
var threadPrewarmDiscardParamsSchema = external_exports.object({ threadId: hostThreadIdSchema });
|
|
15532
|
+
var threadPrewarmDiscardResultSchema = external_exports.object({ discarded: external_exports.boolean() });
|
|
15533
|
+
|
|
15530
15534
|
// ../../shared-contracts/dist/harness-plugins.js
|
|
15531
15535
|
var HARNESS_PLUGIN_MANIFEST_MAX_BYTES = 32 * 1024;
|
|
15532
15536
|
var HARNESS_PLUGIN_ICON_MAX_BYTES = 128 * 1024;
|
|
@@ -15594,6 +15598,9 @@ var consoleOpenResultSchema = external_exports.strictObject({
|
|
|
15594
15598
|
url: external_exports.string().max(2048).regex(/^http:\/\/(?:127\.0\.0\.1|localhost):\d{1,5}\/(?:\?.*)?$/u)
|
|
15595
15599
|
});
|
|
15596
15600
|
var CONSOLE_HOST_METHODS = Object.freeze([
|
|
15601
|
+
"codexhost/console/remote-connections",
|
|
15602
|
+
"codexhost/runtime/status",
|
|
15603
|
+
"codexhost/remote/ssh-setup",
|
|
15597
15604
|
"codexhost/harness/plugins/list",
|
|
15598
15605
|
"codexhost/harness/display-settings/get",
|
|
15599
15606
|
"codexhost/harness/display-settings/set",
|
|
@@ -16539,6 +16546,80 @@ var updateStatusResultSchema = external_exports.strictObject({
|
|
|
16539
16546
|
status: updateStatusSchema.nullable()
|
|
16540
16547
|
});
|
|
16541
16548
|
|
|
16549
|
+
// ../../shared-contracts/dist/remote-runtime.js
|
|
16550
|
+
var remoteUpdatePhaseSchema = external_exports.enum([
|
|
16551
|
+
"idle",
|
|
16552
|
+
"installing",
|
|
16553
|
+
"restarting",
|
|
16554
|
+
"succeeded",
|
|
16555
|
+
"failed"
|
|
16556
|
+
]);
|
|
16557
|
+
var runtimeStatusSchema = external_exports.object({
|
|
16558
|
+
runningVersion: external_exports.string().nullable(),
|
|
16559
|
+
installedVersion: external_exports.string().nullable(),
|
|
16560
|
+
restartRequired: external_exports.boolean(),
|
|
16561
|
+
remote: external_exports.boolean(),
|
|
16562
|
+
updateSupported: external_exports.boolean(),
|
|
16563
|
+
update: external_exports.object({
|
|
16564
|
+
phase: remoteUpdatePhaseSchema,
|
|
16565
|
+
targetVersion: external_exports.string().nullable(),
|
|
16566
|
+
error: external_exports.string().nullable()
|
|
16567
|
+
})
|
|
16568
|
+
});
|
|
16569
|
+
var remoteUpdateParamsSchema = external_exports.object({
|
|
16570
|
+
version: external_exports.string().regex(/^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?$/u)
|
|
16571
|
+
}).strict();
|
|
16572
|
+
var remoteSshSetupParamsSchema = external_exports.object({
|
|
16573
|
+
hostname: external_exports.string().min(1).max(1024).refine((value) => !value.startsWith("-") && !/\s/u.test(value)),
|
|
16574
|
+
port: external_exports.number().int().min(1).max(65535).nullable(),
|
|
16575
|
+
identity: external_exports.string().max(4096).nullable(),
|
|
16576
|
+
action: external_exports.enum(["inspect", "install", "update", "repair", "uninstall"]),
|
|
16577
|
+
uninstallPackage: external_exports.boolean().optional(),
|
|
16578
|
+
version: external_exports.string().regex(/^\d+\.\d+\.\d+$/u).nullable()
|
|
16579
|
+
}).strict();
|
|
16580
|
+
var remoteSshSetupResultSchema = external_exports.object({ state: external_exports.enum(["installed", "not-installed"]) }).strict();
|
|
16581
|
+
|
|
16582
|
+
// ../../shared-contracts/dist/remote-connections.js
|
|
16583
|
+
var hostId = external_exports.string().min(1).max(1024);
|
|
16584
|
+
var codexSshConnectionSchema = external_exports.object({
|
|
16585
|
+
hostId,
|
|
16586
|
+
displayName: external_exports.string().min(1).max(1024),
|
|
16587
|
+
source: external_exports.enum(["codex-managed", "discovered"]),
|
|
16588
|
+
sshAlias: external_exports.string().max(1024).nullable(),
|
|
16589
|
+
sshHost: external_exports.string().min(1).max(1024),
|
|
16590
|
+
sshPort: external_exports.number().int().min(1).max(65535).nullable(),
|
|
16591
|
+
identity: external_exports.string().max(4096).nullable(),
|
|
16592
|
+
autoConnect: external_exports.boolean(),
|
|
16593
|
+
connectionAnalyticsId: external_exports.string().max(1024).optional()
|
|
16594
|
+
});
|
|
16595
|
+
var codexSshDraftSchema = external_exports.strictObject({
|
|
16596
|
+
displayName: external_exports.string().min(1).max(1024),
|
|
16597
|
+
hostname: external_exports.string().min(1).max(1024),
|
|
16598
|
+
sshPort: external_exports.number().int().min(1).max(65535).nullable(),
|
|
16599
|
+
identity: external_exports.string().max(4096).nullable()
|
|
16600
|
+
});
|
|
16601
|
+
var remoteConnectionsRequestSchema = external_exports.discriminatedUnion("action", [
|
|
16602
|
+
external_exports.strictObject({ action: external_exports.literal("list") }),
|
|
16603
|
+
external_exports.strictObject({
|
|
16604
|
+
action: external_exports.literal("save"),
|
|
16605
|
+
draft: codexSshDraftSchema,
|
|
16606
|
+
previous: codexSshConnectionSchema.nullable()
|
|
16607
|
+
}),
|
|
16608
|
+
external_exports.strictObject({ action: external_exports.literal("remove"), previous: codexSshConnectionSchema }),
|
|
16609
|
+
external_exports.strictObject({ action: external_exports.literal("connect"), hostId, enabled: external_exports.boolean() }),
|
|
16610
|
+
external_exports.strictObject({ action: external_exports.literal("state"), hostId }),
|
|
16611
|
+
external_exports.strictObject({ action: external_exports.literal("runtime"), hostId }),
|
|
16612
|
+
external_exports.strictObject({
|
|
16613
|
+
action: external_exports.literal("update"),
|
|
16614
|
+
hostId: hostId.refine((id) => id !== "local"),
|
|
16615
|
+
version: remoteUpdateParamsSchema.shape.version
|
|
16616
|
+
})
|
|
16617
|
+
]);
|
|
16618
|
+
var remoteConnectionsReplySchema = external_exports.union([
|
|
16619
|
+
external_exports.strictObject({ result: jsonValueSchema }),
|
|
16620
|
+
external_exports.strictObject({ error: external_exports.strictObject({ code: external_exports.number().int(), message: external_exports.string() }) })
|
|
16621
|
+
]);
|
|
16622
|
+
|
|
16542
16623
|
// ../../shared-contracts/dist/index.js
|
|
16543
16624
|
var workspaceContractVersionSchema = external_exports.literal(WORKSPACE_CONTRACT_VERSION);
|
|
16544
16625
|
|
|
@@ -17368,6 +17449,330 @@ async function verifyOmpSessionCwd(input) {
|
|
|
17368
17449
|
}
|
|
17369
17450
|
}
|
|
17370
17451
|
|
|
17452
|
+
// dist/session-import.js
|
|
17453
|
+
import { createReadStream as createReadStream2 } from "node:fs";
|
|
17454
|
+
import { opendir, realpath as realpath2, stat } from "node:fs/promises";
|
|
17455
|
+
import os2 from "node:os";
|
|
17456
|
+
import path4 from "node:path";
|
|
17457
|
+
import { createInterface } from "node:readline";
|
|
17458
|
+
|
|
17459
|
+
// ../../harness-adapter/dist/session-import.js
|
|
17460
|
+
import { lstat } from "node:fs/promises";
|
|
17461
|
+
var SessionImportChangedError = class extends Error {
|
|
17462
|
+
constructor(message3 = "Native Session changed during discovery; refresh and retry") {
|
|
17463
|
+
super(message3);
|
|
17464
|
+
this.name = "SessionImportChangedError";
|
|
17465
|
+
}
|
|
17466
|
+
};
|
|
17467
|
+
function isMissingFileError(error51) {
|
|
17468
|
+
return typeof error51 === "object" && error51 !== null && "code" in error51 && error51.code === "ENOENT";
|
|
17469
|
+
}
|
|
17470
|
+
function sameFileFingerprint(left, right) {
|
|
17471
|
+
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;
|
|
17472
|
+
}
|
|
17473
|
+
var STORAGE_ACCESS_ERRORS = /* @__PURE__ */ new Set(["EACCES", "EPERM", "EIO", "EMFILE", "ENFILE"]);
|
|
17474
|
+
function isStorageAccessError(error51) {
|
|
17475
|
+
return typeof error51 === "object" && error51 !== null && "code" in error51 && typeof error51.code === "string" && STORAGE_ACCESS_ERRORS.has(error51.code);
|
|
17476
|
+
}
|
|
17477
|
+
async function optionalLstat(file2) {
|
|
17478
|
+
try {
|
|
17479
|
+
return await lstat(file2);
|
|
17480
|
+
} catch (error51) {
|
|
17481
|
+
if (isMissingFileError(error51))
|
|
17482
|
+
return null;
|
|
17483
|
+
throw error51;
|
|
17484
|
+
}
|
|
17485
|
+
}
|
|
17486
|
+
async function readStableFiles(files, read) {
|
|
17487
|
+
const before = await Promise.all(files.map(optionalLstat));
|
|
17488
|
+
const value = await read(before);
|
|
17489
|
+
const after = await Promise.all(files.map(optionalLstat));
|
|
17490
|
+
if (before.some((info, index) => !sameFileFingerprint(info, after[index] ?? null)))
|
|
17491
|
+
throw new SessionImportChangedError();
|
|
17492
|
+
return value;
|
|
17493
|
+
}
|
|
17494
|
+
function sessionImportTitle(value, maxLength = HARNESS_SESSION_IMPORT_TITLE_MAX_LENGTH) {
|
|
17495
|
+
if (typeof value !== "string")
|
|
17496
|
+
return null;
|
|
17497
|
+
const normalized = value.replaceAll("\0", "").replaceAll(/\s+/gu, " ").trim();
|
|
17498
|
+
if (!normalized)
|
|
17499
|
+
return null;
|
|
17500
|
+
if (normalized.length <= maxLength)
|
|
17501
|
+
return normalized;
|
|
17502
|
+
const characters = [...normalized];
|
|
17503
|
+
if (characters.length <= maxLength)
|
|
17504
|
+
return normalized;
|
|
17505
|
+
return `${characters.slice(0, maxLength - 1).join("").trimEnd()}…`;
|
|
17506
|
+
}
|
|
17507
|
+
function sessionImportCandidate(input) {
|
|
17508
|
+
const time3 = typeof input.updatedAt === "number" ? input.updatedAt : typeof input.updatedAt === "string" ? Date.parse(input.updatedAt) : Number.NaN;
|
|
17509
|
+
const parsed = harnessSessionImportCandidateSchema.safeParse({
|
|
17510
|
+
nativeSessionId: input.nativeSessionId,
|
|
17511
|
+
cwd: input.cwd,
|
|
17512
|
+
title: typeof input.title === "string" && input.title.trim().length > 0 ? input.title : null,
|
|
17513
|
+
updatedAt: Math.floor(time3),
|
|
17514
|
+
// Unknown must stay unknown; only an explicit boolean is a native statement.
|
|
17515
|
+
running: typeof input.running === "boolean" ? input.running : null
|
|
17516
|
+
});
|
|
17517
|
+
return parsed.success ? parsed.data : null;
|
|
17518
|
+
}
|
|
17519
|
+
var SessionImportScope = class {
|
|
17520
|
+
#abort = new AbortController();
|
|
17521
|
+
#options;
|
|
17522
|
+
#pending = /* @__PURE__ */ new Set();
|
|
17523
|
+
constructor(options) {
|
|
17524
|
+
this.#options = options;
|
|
17525
|
+
}
|
|
17526
|
+
#closed() {
|
|
17527
|
+
return {
|
|
17528
|
+
ok: false,
|
|
17529
|
+
error: { code: "invalidState", message: this.#options.closedMessage, retryable: false }
|
|
17530
|
+
};
|
|
17531
|
+
}
|
|
17532
|
+
read(operation) {
|
|
17533
|
+
const signal = this.#abort.signal;
|
|
17534
|
+
if (signal.aborted)
|
|
17535
|
+
return Promise.resolve(this.#closed());
|
|
17536
|
+
let started;
|
|
17537
|
+
try {
|
|
17538
|
+
started = operation(signal);
|
|
17539
|
+
} catch (error51) {
|
|
17540
|
+
started = Promise.reject(error51 instanceof Error ? error51 : new Error("Session read failed"));
|
|
17541
|
+
}
|
|
17542
|
+
const request = started.then((value) => signal.aborted ? this.#closed() : { ok: true, value }).catch(() => signal.aborted ? this.#closed() : {
|
|
17543
|
+
ok: false,
|
|
17544
|
+
error: {
|
|
17545
|
+
code: "unavailable",
|
|
17546
|
+
message: this.#options.unavailableMessage,
|
|
17547
|
+
retryable: true
|
|
17548
|
+
}
|
|
17549
|
+
}).finally(() => this.#pending.delete(request));
|
|
17550
|
+
this.#pending.add(request);
|
|
17551
|
+
return request;
|
|
17552
|
+
}
|
|
17553
|
+
/** `read` for `resolveCandidate`: a null source is the selected Session having disappeared. */
|
|
17554
|
+
async resolve(operation) {
|
|
17555
|
+
const result = await this.read(operation);
|
|
17556
|
+
if (!result.ok)
|
|
17557
|
+
return result;
|
|
17558
|
+
return result.value ? { ok: true, value: result.value } : {
|
|
17559
|
+
ok: false,
|
|
17560
|
+
error: {
|
|
17561
|
+
code: "sessionNotFound",
|
|
17562
|
+
message: this.#options.notFoundMessage,
|
|
17563
|
+
retryable: false
|
|
17564
|
+
}
|
|
17565
|
+
};
|
|
17566
|
+
}
|
|
17567
|
+
/** Idempotent. Resolves after every started read has settled. */
|
|
17568
|
+
async close() {
|
|
17569
|
+
this.#abort.abort();
|
|
17570
|
+
await Promise.allSettled(this.#pending);
|
|
17571
|
+
}
|
|
17572
|
+
};
|
|
17573
|
+
|
|
17574
|
+
// dist/session-import.js
|
|
17575
|
+
function isRecord6(value) {
|
|
17576
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
17577
|
+
}
|
|
17578
|
+
function expandDirectory(value, home) {
|
|
17579
|
+
return path4.resolve(value === "~" ? home : value.startsWith(`~${path4.sep}`) || value.startsWith("~/") ? path4.join(home, value.slice(2)) : value);
|
|
17580
|
+
}
|
|
17581
|
+
function ompSessionImportDirectory(environment) {
|
|
17582
|
+
const home = (process.platform === "win32" ? environment.USERPROFILE : environment.HOME) || os2.homedir();
|
|
17583
|
+
const custom2 = environment.PI_CODING_AGENT_SESSION_DIR;
|
|
17584
|
+
if (custom2)
|
|
17585
|
+
return { directory: expandDirectory(custom2, home), flat: true };
|
|
17586
|
+
const agent = environment.PI_CODING_AGENT_DIR;
|
|
17587
|
+
return {
|
|
17588
|
+
directory: path4.join(agent ? expandDirectory(agent, home) : path4.join(home, ".omp", "agent"), "sessions"),
|
|
17589
|
+
flat: false
|
|
17590
|
+
};
|
|
17591
|
+
}
|
|
17592
|
+
function messageText(content) {
|
|
17593
|
+
if (typeof content === "string")
|
|
17594
|
+
return content;
|
|
17595
|
+
if (!Array.isArray(content))
|
|
17596
|
+
return "";
|
|
17597
|
+
return content.filter((part) => isRecord6(part) && part.type === "text" && typeof part.text === "string").map((part) => String(part.text)).join(" ");
|
|
17598
|
+
}
|
|
17599
|
+
async function readFacts(file2, signal) {
|
|
17600
|
+
const stream = createReadStream2(file2, { encoding: "utf8", signal });
|
|
17601
|
+
const lines = createInterface({ input: stream, crlfDelay: Infinity });
|
|
17602
|
+
let header = null;
|
|
17603
|
+
let nativeTitle = null;
|
|
17604
|
+
let firstPrompt = null;
|
|
17605
|
+
let updatedAt = null;
|
|
17606
|
+
let leafHasUser = false;
|
|
17607
|
+
const hasUserAncestry = /* @__PURE__ */ new Map();
|
|
17608
|
+
try {
|
|
17609
|
+
for await (const line of lines) {
|
|
17610
|
+
signal.throwIfAborted();
|
|
17611
|
+
if (!line.trim())
|
|
17612
|
+
continue;
|
|
17613
|
+
let entry;
|
|
17614
|
+
try {
|
|
17615
|
+
entry = JSON.parse(line);
|
|
17616
|
+
} catch {
|
|
17617
|
+
continue;
|
|
17618
|
+
}
|
|
17619
|
+
if (!isRecord6(entry))
|
|
17620
|
+
continue;
|
|
17621
|
+
if (entry.type === "title") {
|
|
17622
|
+
nativeTitle = sessionImportTitle(entry.title);
|
|
17623
|
+
continue;
|
|
17624
|
+
}
|
|
17625
|
+
if (entry.type === "session") {
|
|
17626
|
+
if (header)
|
|
17627
|
+
return null;
|
|
17628
|
+
if (typeof entry.id !== "string" || entry.id.length === 0 || typeof entry.cwd !== "string" || !path4.isAbsolute(entry.cwd))
|
|
17629
|
+
return null;
|
|
17630
|
+
header = { id: entry.id, cwd: entry.cwd };
|
|
17631
|
+
continue;
|
|
17632
|
+
}
|
|
17633
|
+
if (typeof entry.id !== "string" || entry.id.length === 0)
|
|
17634
|
+
continue;
|
|
17635
|
+
const message3 = isRecord6(entry.message) ? entry.message : null;
|
|
17636
|
+
const isUser = entry.type === "message" && message3?.role === "user";
|
|
17637
|
+
if (isUser)
|
|
17638
|
+
firstPrompt ??= sessionImportTitle(messageText(message3?.content));
|
|
17639
|
+
leafHasUser = isUser || typeof entry.parentId === "string" && hasUserAncestry.get(entry.parentId) === true;
|
|
17640
|
+
hasUserAncestry.set(entry.id, leafHasUser);
|
|
17641
|
+
if (entry.type === "message" && (message3?.role === "user" || message3?.role === "assistant")) {
|
|
17642
|
+
const time3 = typeof message3.timestamp === "number" ? message3.timestamp : typeof entry.timestamp === "string" ? Date.parse(entry.timestamp) : Number.NaN;
|
|
17643
|
+
if (Number.isFinite(time3) && time3 >= 0)
|
|
17644
|
+
updatedAt = time3;
|
|
17645
|
+
}
|
|
17646
|
+
}
|
|
17647
|
+
} finally {
|
|
17648
|
+
lines.close();
|
|
17649
|
+
stream.destroy();
|
|
17650
|
+
}
|
|
17651
|
+
if (!header || !leafHasUser)
|
|
17652
|
+
return null;
|
|
17653
|
+
return {
|
|
17654
|
+
nativeSessionId: header.id,
|
|
17655
|
+
cwd: header.cwd,
|
|
17656
|
+
title: nativeTitle ?? firstPrompt,
|
|
17657
|
+
updatedAt
|
|
17658
|
+
};
|
|
17659
|
+
}
|
|
17660
|
+
var OmpSessionImport = class {
|
|
17661
|
+
#location;
|
|
17662
|
+
#scope = new SessionImportScope({
|
|
17663
|
+
closedMessage: "Omp Session import is closed",
|
|
17664
|
+
unavailableMessage: "Omp sessions could not be read; close native clients, check storage access and retry",
|
|
17665
|
+
notFoundMessage: "Omp Session is no longer importable"
|
|
17666
|
+
});
|
|
17667
|
+
constructor(environment) {
|
|
17668
|
+
this.#location = ompSessionImportDirectory(environment);
|
|
17669
|
+
}
|
|
17670
|
+
listCandidates() {
|
|
17671
|
+
return this.#scope.read(async (signal) => [...(await this.#sources(signal)).values()].flatMap((sources) => (
|
|
17672
|
+
// One identity in two files cannot be resumed unambiguously.
|
|
17673
|
+
sources.length === 1 && sources[0] ? [sources[0].candidate] : []
|
|
17674
|
+
)));
|
|
17675
|
+
}
|
|
17676
|
+
resolveCandidate(nativeSessionId) {
|
|
17677
|
+
return this.#scope.resolve(async (signal) => {
|
|
17678
|
+
const sources = (await this.#sources(signal)).get(nativeSessionId);
|
|
17679
|
+
if (sources?.length !== 1 || !sources[0])
|
|
17680
|
+
return null;
|
|
17681
|
+
const source = await this.#source(sources[0].file, signal);
|
|
17682
|
+
return source?.nativeRef.nativeSessionId === nativeSessionId ? { candidate: source.candidate, nativeRef: source.nativeRef } : null;
|
|
17683
|
+
});
|
|
17684
|
+
}
|
|
17685
|
+
close() {
|
|
17686
|
+
return this.#scope.close();
|
|
17687
|
+
}
|
|
17688
|
+
async #sessionFiles(signal) {
|
|
17689
|
+
const { directory, flat } = this.#location;
|
|
17690
|
+
const info = await optionalLstat(directory);
|
|
17691
|
+
if (!info)
|
|
17692
|
+
return [];
|
|
17693
|
+
if (!info.isDirectory())
|
|
17694
|
+
throw new Error("Omp Session store is not a directory");
|
|
17695
|
+
const files = [];
|
|
17696
|
+
const visit = async (current, projectLevel) => {
|
|
17697
|
+
const entries = await opendir(current).catch((error51) => {
|
|
17698
|
+
if (isMissingFileError(error51))
|
|
17699
|
+
return null;
|
|
17700
|
+
throw error51;
|
|
17701
|
+
});
|
|
17702
|
+
if (!entries)
|
|
17703
|
+
return;
|
|
17704
|
+
for await (const entry of entries) {
|
|
17705
|
+
signal.throwIfAborted();
|
|
17706
|
+
if (projectLevel && entry.isDirectory())
|
|
17707
|
+
await visit(path4.join(current, entry.name), false);
|
|
17708
|
+
else if (!projectLevel && entry.isFile() && entry.name.endsWith(".jsonl"))
|
|
17709
|
+
files.push(path4.join(current, entry.name));
|
|
17710
|
+
}
|
|
17711
|
+
};
|
|
17712
|
+
await visit(directory, !flat);
|
|
17713
|
+
return files;
|
|
17714
|
+
}
|
|
17715
|
+
/** Session ID to every readable file claiming it. Files changing under the read are skipped. */
|
|
17716
|
+
async #sources(signal) {
|
|
17717
|
+
const found = /* @__PURE__ */ new Map();
|
|
17718
|
+
for (const file2 of await this.#sessionFiles(signal)) {
|
|
17719
|
+
signal.throwIfAborted();
|
|
17720
|
+
try {
|
|
17721
|
+
const source = await this.#source(file2, signal);
|
|
17722
|
+
if (!source)
|
|
17723
|
+
continue;
|
|
17724
|
+
const sources = found.get(source.nativeRef.nativeSessionId) ?? [];
|
|
17725
|
+
sources.push(source);
|
|
17726
|
+
found.set(source.nativeRef.nativeSessionId, sources);
|
|
17727
|
+
} catch (error51) {
|
|
17728
|
+
if (!(error51 instanceof SessionImportChangedError))
|
|
17729
|
+
throw error51;
|
|
17730
|
+
}
|
|
17731
|
+
}
|
|
17732
|
+
return found;
|
|
17733
|
+
}
|
|
17734
|
+
async #source(file2, signal) {
|
|
17735
|
+
signal.throwIfAborted();
|
|
17736
|
+
return readStableFiles([file2], async ([info]) => {
|
|
17737
|
+
if (!info?.isFile() || info.size === 0)
|
|
17738
|
+
return null;
|
|
17739
|
+
try {
|
|
17740
|
+
const facts = await readFacts(file2, signal);
|
|
17741
|
+
if (!facts)
|
|
17742
|
+
return null;
|
|
17743
|
+
const cwd = await realpath2(facts.cwd);
|
|
17744
|
+
if (!(await stat(cwd)).isDirectory())
|
|
17745
|
+
return null;
|
|
17746
|
+
const candidate = sessionImportCandidate({
|
|
17747
|
+
nativeSessionId: facts.nativeSessionId,
|
|
17748
|
+
cwd,
|
|
17749
|
+
title: facts.title,
|
|
17750
|
+
updatedAt: facts.updatedAt ?? info.mtimeMs
|
|
17751
|
+
// OMP has no cross-process activity marker: idleness cannot be established.
|
|
17752
|
+
});
|
|
17753
|
+
if (!candidate)
|
|
17754
|
+
return null;
|
|
17755
|
+
return {
|
|
17756
|
+
file: file2,
|
|
17757
|
+
candidate,
|
|
17758
|
+
// Resume needs the file itself: OMP is started with `--session <file>`.
|
|
17759
|
+
nativeRef: nativeSessionRefSchema.parse({
|
|
17760
|
+
harnessId: "omp",
|
|
17761
|
+
nativeSessionId: facts.nativeSessionId,
|
|
17762
|
+
locator: { sessionFile: await realpath2(file2) },
|
|
17763
|
+
formatVersion: 1
|
|
17764
|
+
})
|
|
17765
|
+
};
|
|
17766
|
+
} catch (error51) {
|
|
17767
|
+
signal.throwIfAborted();
|
|
17768
|
+
if (isStorageAccessError(error51))
|
|
17769
|
+
throw error51;
|
|
17770
|
+
return null;
|
|
17771
|
+
}
|
|
17772
|
+
});
|
|
17773
|
+
}
|
|
17774
|
+
};
|
|
17775
|
+
|
|
17371
17776
|
// dist/omp-last-turn-rollback.js
|
|
17372
17777
|
function modelFromState(state) {
|
|
17373
17778
|
if (state.provider === null && state.modelId === null)
|
|
@@ -17423,7 +17828,7 @@ async function rollbackOmpLastTurn(transport, sourceSessionId, cwd) {
|
|
|
17423
17828
|
// dist/omp-rpc-session.js
|
|
17424
17829
|
import { spawn, spawnSync } from "node:child_process";
|
|
17425
17830
|
import { randomUUID } from "node:crypto";
|
|
17426
|
-
import
|
|
17831
|
+
import path5 from "node:path";
|
|
17427
17832
|
|
|
17428
17833
|
// dist/command.js
|
|
17429
17834
|
var ompDiscoverySpec = {
|
|
@@ -17452,14 +17857,14 @@ function resolveOmpExecutable(input, dependencies = {}) {
|
|
|
17452
17857
|
}
|
|
17453
17858
|
|
|
17454
17859
|
// dist/omp-usage.js
|
|
17455
|
-
function
|
|
17860
|
+
function isRecord7(value) {
|
|
17456
17861
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
17457
17862
|
}
|
|
17458
17863
|
function nonNegativeSafeInteger(value) {
|
|
17459
17864
|
return typeof value === "number" && Number.isSafeInteger(value) && value >= 0 ? value : null;
|
|
17460
17865
|
}
|
|
17461
17866
|
function optionalOmpCacheHitRatePercent(value) {
|
|
17462
|
-
if (!
|
|
17867
|
+
if (!isRecord7(value) || value.role !== "assistant" || !isRecord7(value.usage))
|
|
17463
17868
|
return null;
|
|
17464
17869
|
const input = nonNegativeSafeInteger(value.usage.input);
|
|
17465
17870
|
const cacheRead = nonNegativeSafeInteger(value.usage.cacheRead);
|
|
@@ -17472,20 +17877,20 @@ function optionalOmpCacheHitRatePercent(value) {
|
|
|
17472
17877
|
function latestOmpCacheHitRatePercent(history) {
|
|
17473
17878
|
let latest = null;
|
|
17474
17879
|
for (const entry of activeOmpEntries(history)) {
|
|
17475
|
-
if (entry.type === "message" &&
|
|
17880
|
+
if (entry.type === "message" && isRecord7(entry.message) && entry.message.role === "assistant") {
|
|
17476
17881
|
latest = optionalOmpCacheHitRatePercent(entry.message);
|
|
17477
17882
|
}
|
|
17478
17883
|
}
|
|
17479
17884
|
return latest;
|
|
17480
17885
|
}
|
|
17481
17886
|
function responseData(response, operation) {
|
|
17482
|
-
if (!
|
|
17887
|
+
if (!isRecord7(response.data)) {
|
|
17483
17888
|
throw new Error(`Omp RPC ${operation} response has no data`);
|
|
17484
17889
|
}
|
|
17485
17890
|
return response.data;
|
|
17486
17891
|
}
|
|
17487
17892
|
function contextUsage(value) {
|
|
17488
|
-
if (!
|
|
17893
|
+
if (!isRecord7(value))
|
|
17489
17894
|
throw new Error("Omp RPC context Usage is invalid");
|
|
17490
17895
|
return parseHostUsage({
|
|
17491
17896
|
contextUsedTokens: value.tokens,
|
|
@@ -17495,15 +17900,15 @@ function contextUsage(value) {
|
|
|
17495
17900
|
function parseOmpSessionUsage(response) {
|
|
17496
17901
|
const data = responseData(response, "Session stats");
|
|
17497
17902
|
const tokens = data.tokens;
|
|
17498
|
-
if (tokens !== void 0 && !
|
|
17903
|
+
if (tokens !== void 0 && !isRecord7(tokens)) {
|
|
17499
17904
|
throw new Error("Omp RPC Session stats tokens are invalid");
|
|
17500
17905
|
}
|
|
17501
17906
|
return parseHostUsage({
|
|
17502
|
-
...
|
|
17503
|
-
...
|
|
17504
|
-
...
|
|
17505
|
-
...
|
|
17506
|
-
...
|
|
17907
|
+
...isRecord7(tokens) && tokens.input !== void 0 ? { inputTokens: tokens.input } : {},
|
|
17908
|
+
...isRecord7(tokens) && tokens.cacheRead !== void 0 ? { cachedInputTokens: tokens.cacheRead } : {},
|
|
17909
|
+
...isRecord7(tokens) && tokens.cacheWrite !== void 0 ? { cacheWriteInputTokens: tokens.cacheWrite } : {},
|
|
17910
|
+
...isRecord7(tokens) && tokens.output !== void 0 ? { outputTokens: tokens.output } : {},
|
|
17911
|
+
...isRecord7(tokens) && tokens.total !== void 0 ? { totalTokens: tokens.total } : {},
|
|
17507
17912
|
...data.cost !== void 0 ? { totalCostUsd: data.cost } : {},
|
|
17508
17913
|
...data.contextUsage !== void 0 ? contextUsage(data.contextUsage) : {}
|
|
17509
17914
|
});
|
|
@@ -17618,7 +18023,7 @@ var OmpRpcUnsupportedCommandError = class extends Error {
|
|
|
17618
18023
|
}
|
|
17619
18024
|
};
|
|
17620
18025
|
var textDecoder = new TextDecoder("utf-8", { fatal: true });
|
|
17621
|
-
function
|
|
18026
|
+
function isRecord8(value) {
|
|
17622
18027
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
17623
18028
|
}
|
|
17624
18029
|
function message2(value) {
|
|
@@ -17630,13 +18035,13 @@ function nonBlankString(value) {
|
|
|
17630
18035
|
function parseNativeModel(value, context) {
|
|
17631
18036
|
if (value === null || value === void 0)
|
|
17632
18037
|
return null;
|
|
17633
|
-
if (!
|
|
18038
|
+
if (!isRecord8(value) || !nonBlankString(value.provider) || !nonBlankString(value.id)) {
|
|
17634
18039
|
throw new OmpRpcFaultError("protocolError", `Omp RPC returned an invalid ${context} Model`);
|
|
17635
18040
|
}
|
|
17636
18041
|
return { provider: value.provider, id: value.id };
|
|
17637
18042
|
}
|
|
17638
18043
|
function sessionStateData(response) {
|
|
17639
|
-
const data =
|
|
18044
|
+
const data = isRecord8(response.data) ? response.data : null;
|
|
17640
18045
|
if (!data)
|
|
17641
18046
|
throw new OmpRpcFaultError("protocolError", "Omp RPC state response has no data");
|
|
17642
18047
|
return data;
|
|
@@ -17651,7 +18056,7 @@ function parseSessionState(response) {
|
|
|
17651
18056
|
if (thinkingLevel !== null && !thinkingLevel.success) {
|
|
17652
18057
|
throw new OmpRpcFaultError("protocolError", "Omp RPC state has an invalid Thinking level");
|
|
17653
18058
|
}
|
|
17654
|
-
const thinking =
|
|
18059
|
+
const thinking = isRecord8(data.model) && isRecord8(data.model.thinking) ? data.model.thinking : null;
|
|
17655
18060
|
const availableThinkingLevels = thinking && Array.isArray(thinking.efforts) ? thinking.efforts.flatMap((level) => {
|
|
17656
18061
|
const parsed = harnessThinkingOptionIdSchema.safeParse(level);
|
|
17657
18062
|
return parsed.success ? [parsed.data] : [];
|
|
@@ -17674,25 +18079,25 @@ function parseSessionStreaming(response) {
|
|
|
17674
18079
|
return isStreaming;
|
|
17675
18080
|
}
|
|
17676
18081
|
function parseAvailableModels(response) {
|
|
17677
|
-
const data =
|
|
18082
|
+
const data = isRecord8(response.data) ? response.data : null;
|
|
17678
18083
|
if (!data || !Array.isArray(data.models)) {
|
|
17679
18084
|
throw new OmpRpcFaultError("protocolError", "Omp RPC Model catalog response has no models");
|
|
17680
18085
|
}
|
|
17681
18086
|
return data.models.map((model) => {
|
|
17682
18087
|
const parsed = parseNativeModel(model, "catalog");
|
|
17683
|
-
if (!parsed || !
|
|
18088
|
+
if (!parsed || !isRecord8(model) || typeof model.reasoning !== "boolean") {
|
|
17684
18089
|
throw new OmpRpcFaultError("protocolError", "Omp RPC catalog contains a Model without reasoning capability");
|
|
17685
18090
|
}
|
|
17686
18091
|
return { ...parsed, reasoning: model.reasoning };
|
|
17687
18092
|
});
|
|
17688
18093
|
}
|
|
17689
18094
|
function parseSubagentMessages(response) {
|
|
17690
|
-
const data =
|
|
18095
|
+
const data = isRecord8(response.data) ? response.data : null;
|
|
17691
18096
|
if (!data || !nonBlankString(data.sessionFile) || !Number.isSafeInteger(data.fromByte) || !Number.isSafeInteger(data.nextByte) || data.fromByte < 0 || data.nextByte < data.fromByte || typeof data.reset !== "boolean" || !Array.isArray(data.entries) || !Array.isArray(data.messages)) {
|
|
17692
18097
|
throw new OmpRpcFaultError("protocolError", "Omp RPC Subagent transcript response is invalid");
|
|
17693
18098
|
}
|
|
17694
|
-
const entries = data.entries.flatMap((value) =>
|
|
17695
|
-
const messages = data.messages.flatMap((value) =>
|
|
18099
|
+
const entries = data.entries.flatMap((value) => isRecord8(value) ? [value] : []);
|
|
18100
|
+
const messages = data.messages.flatMap((value) => isRecord8(value) ? [value] : []);
|
|
17696
18101
|
if (entries.length !== data.entries.length || messages.length !== data.messages.length) {
|
|
17697
18102
|
throw new OmpRpcFaultError("protocolError", "Omp RPC Subagent transcript contains invalid data");
|
|
17698
18103
|
}
|
|
@@ -17713,17 +18118,17 @@ function subagentStatus(value) {
|
|
|
17713
18118
|
throw new OmpRpcFaultError("protocolError", "Omp RPC Subagent status is invalid");
|
|
17714
18119
|
}
|
|
17715
18120
|
function assistantText(value) {
|
|
17716
|
-
if (!
|
|
18121
|
+
if (!isRecord8(value) || value.role !== "assistant" || !Array.isArray(value.content))
|
|
17717
18122
|
return null;
|
|
17718
|
-
return value.content.filter((content) =>
|
|
18123
|
+
return value.content.filter((content) => isRecord8(content) && content.type === "text" && typeof content.text === "string").map((content) => content.text).join("");
|
|
17719
18124
|
}
|
|
17720
18125
|
function assistantMessageId(value) {
|
|
17721
|
-
if (!
|
|
18126
|
+
if (!isRecord8(value) || value.role !== "assistant")
|
|
17722
18127
|
return null;
|
|
17723
18128
|
return nonBlankString(value.responseId) ? value.responseId : null;
|
|
17724
18129
|
}
|
|
17725
18130
|
function extractReasoningText(content) {
|
|
17726
|
-
if (!
|
|
18131
|
+
if (!isRecord8(content))
|
|
17727
18132
|
return null;
|
|
17728
18133
|
const type = String(content.type ?? "");
|
|
17729
18134
|
if (type === "thinking" || type === "reasoning" || type === "thought") {
|
|
@@ -17733,12 +18138,12 @@ function extractReasoningText(content) {
|
|
|
17733
18138
|
return null;
|
|
17734
18139
|
}
|
|
17735
18140
|
function assistantReasoning(value) {
|
|
17736
|
-
if (!
|
|
18141
|
+
if (!isRecord8(value) || value.role !== "assistant" || !Array.isArray(value.content))
|
|
17737
18142
|
return null;
|
|
17738
18143
|
return value.content.map(extractReasoningText).filter((text) => typeof text === "string").join("");
|
|
17739
18144
|
}
|
|
17740
18145
|
function assistantFailure(value) {
|
|
17741
|
-
if (!
|
|
18146
|
+
if (!isRecord8(value) || value.role !== "assistant")
|
|
17742
18147
|
return void 0;
|
|
17743
18148
|
if (value.stopReason !== "error" && value.stopReason !== "aborted")
|
|
17744
18149
|
return null;
|
|
@@ -17758,7 +18163,7 @@ function signalProcessTree(child, signal) {
|
|
|
17758
18163
|
try {
|
|
17759
18164
|
process.kill(-child.pid, signal);
|
|
17760
18165
|
} catch (error51) {
|
|
17761
|
-
if (!
|
|
18166
|
+
if (!isRecord8(error51) || error51.code !== "ESRCH")
|
|
17762
18167
|
throw error51;
|
|
17763
18168
|
}
|
|
17764
18169
|
}
|
|
@@ -17797,7 +18202,7 @@ function ompRpcProcessCommand(options, dependencies = {}) {
|
|
|
17797
18202
|
...modelArguments,
|
|
17798
18203
|
...sessionArguments
|
|
17799
18204
|
];
|
|
17800
|
-
const extension =
|
|
18205
|
+
const extension = path5.win32.extname(command).toLowerCase();
|
|
17801
18206
|
if (platform !== "win32" || ![".cmd", ".bat"].includes(extension)) {
|
|
17802
18207
|
return { command, arguments: arguments_, windowsVerbatimArguments: false };
|
|
17803
18208
|
}
|
|
@@ -17900,7 +18305,7 @@ var OmpRpcSession = class {
|
|
|
17900
18305
|
this.#stderrTail = sanitizeDiagnosticTail(`${this.#stderrTail}${chunk.toString()}`);
|
|
17901
18306
|
});
|
|
17902
18307
|
child.once("error", (error51) => {
|
|
17903
|
-
const kind =
|
|
18308
|
+
const kind = isRecord8(error51) && error51.code === "ENOENT" ? "notInstalled" : "unavailable";
|
|
17904
18309
|
this.#fail(new OmpRpcFaultError(kind, `Omp RPC failed to start: ${error51.message}`, this.stderrTail));
|
|
17905
18310
|
});
|
|
17906
18311
|
child.once("exit", (code, signal) => {
|
|
@@ -17948,17 +18353,17 @@ var OmpRpcSession = class {
|
|
|
17948
18353
|
return await readOmpSessionHistory(this.state.sessionFile);
|
|
17949
18354
|
}
|
|
17950
18355
|
const response = await this.#send("get_messages", {});
|
|
17951
|
-
const data =
|
|
18356
|
+
const data = isRecord8(response.data) ? response.data : null;
|
|
17952
18357
|
if (!data || !Array.isArray(data.messages)) {
|
|
17953
18358
|
throw new OmpRpcFaultError("protocolError", "Omp RPC messages response has no messages");
|
|
17954
18359
|
}
|
|
17955
18360
|
let branchEntryIds = null;
|
|
17956
18361
|
try {
|
|
17957
18362
|
const branchResponse = await this.#send("get_branch_messages", {});
|
|
17958
|
-
const branchData =
|
|
18363
|
+
const branchData = isRecord8(branchResponse.data) ? branchResponse.data : null;
|
|
17959
18364
|
if (branchData && Array.isArray(branchData.messages)) {
|
|
17960
18365
|
const parsed = branchData.messages.flatMap((entry) => {
|
|
17961
|
-
if (!
|
|
18366
|
+
if (!isRecord8(entry) || !nonBlankString(entry.entryId))
|
|
17962
18367
|
return [];
|
|
17963
18368
|
return [entry.entryId];
|
|
17964
18369
|
});
|
|
@@ -17972,11 +18377,11 @@ var OmpRpcSession = class {
|
|
|
17972
18377
|
let userIndex = 0;
|
|
17973
18378
|
let parentId = null;
|
|
17974
18379
|
const entries = data.messages.map((nativeMessage, index) => {
|
|
17975
|
-
const role =
|
|
18380
|
+
const role = isRecord8(nativeMessage) ? nativeMessage.role : void 0;
|
|
17976
18381
|
const branchId = role === "user" ? branchEntryIds?.[userIndex] : void 0;
|
|
17977
18382
|
if (branchId)
|
|
17978
18383
|
userIndex += 1;
|
|
17979
|
-
const id = branchId ?? (
|
|
18384
|
+
const id = branchId ?? (isRecord8(nativeMessage) && nonBlankString(nativeMessage.id) ? nativeMessage.id : `omp-message-${index}`);
|
|
17980
18385
|
const entry = { id, parentId, type: "message", message: nativeMessage };
|
|
17981
18386
|
parentId = id;
|
|
17982
18387
|
return entry;
|
|
@@ -18056,7 +18461,7 @@ var OmpRpcSession = class {
|
|
|
18056
18461
|
throw new Error("Omp RPC Fork requires an Entry identity");
|
|
18057
18462
|
try {
|
|
18058
18463
|
const response = await this.#send("branch", { entryId });
|
|
18059
|
-
const data =
|
|
18464
|
+
const data = isRecord8(response.data) ? response.data : null;
|
|
18060
18465
|
if (!data || data.cancelled === true) {
|
|
18061
18466
|
throw new OmpRpcFaultError("unavailable", "Omp RPC Fork was cancelled");
|
|
18062
18467
|
}
|
|
@@ -18249,7 +18654,7 @@ var OmpRpcSession = class {
|
|
|
18249
18654
|
continue;
|
|
18250
18655
|
}
|
|
18251
18656
|
const value = decoded;
|
|
18252
|
-
if (!
|
|
18657
|
+
if (!isRecord8(value) || typeof value.type !== "string") {
|
|
18253
18658
|
throw new OmpRpcFaultError("protocolError", "Omp RPC returned an invalid envelope");
|
|
18254
18659
|
}
|
|
18255
18660
|
this.#handle(value);
|
|
@@ -18308,7 +18713,7 @@ var OmpRpcSession = class {
|
|
|
18308
18713
|
this.#armCommandTimeout(id, pending);
|
|
18309
18714
|
}
|
|
18310
18715
|
}
|
|
18311
|
-
const outcome = value.aborted === true ? "cancelled" :
|
|
18716
|
+
const outcome = value.aborted === true ? "cancelled" : isRecord8(value.result) ? "succeeded" : "failed";
|
|
18312
18717
|
const event = {
|
|
18313
18718
|
type: "compaction.completed",
|
|
18314
18719
|
outcome,
|
|
@@ -18341,12 +18746,12 @@ var OmpRpcSession = class {
|
|
|
18341
18746
|
this.#startAssistantMessage(active, value.message);
|
|
18342
18747
|
return;
|
|
18343
18748
|
}
|
|
18344
|
-
if (value.type === "message_update" &&
|
|
18749
|
+
if (value.type === "message_update" && isRecord8(value.assistantMessageEvent)) {
|
|
18345
18750
|
const event = value.assistantMessageEvent;
|
|
18346
18751
|
const eventType = String(event.type ?? "");
|
|
18347
18752
|
const isThinking = eventType === "thinking_delta" || eventType === "reasoning_delta" || eventType === "thought_delta" || eventType === "thinking" || eventType === "reasoning";
|
|
18348
18753
|
const isText = eventType === "text_delta" || eventType === "text" || eventType === "content_block_delta";
|
|
18349
|
-
const delta = typeof event.delta === "string" ? event.delta : typeof event.thinking === "string" ? event.thinking : typeof event.reasoning === "string" ? event.reasoning : typeof event.text === "string" ? event.text :
|
|
18754
|
+
const delta = typeof event.delta === "string" ? event.delta : typeof event.thinking === "string" ? event.thinking : typeof event.reasoning === "string" ? event.reasoning : typeof event.text === "string" ? event.text : isRecord8(event.delta) && typeof event.delta.thinking === "string" ? event.delta.thinking : isRecord8(event.delta) && typeof event.delta.text === "string" ? event.delta.text : null;
|
|
18350
18755
|
if (isThinking && delta !== null && delta.length > 0) {
|
|
18351
18756
|
const messageId = this.#ensureAssistantMessage(active, value.message);
|
|
18352
18757
|
active.reasoningMessageOpen = true;
|
|
@@ -18386,7 +18791,7 @@ var OmpRpcSession = class {
|
|
|
18386
18791
|
if (value.type === "agent_end" && Array.isArray(value.messages)) {
|
|
18387
18792
|
for (let index = value.messages.length - 1; index >= 0; index -= 1) {
|
|
18388
18793
|
const message3 = value.messages[index];
|
|
18389
|
-
if (!
|
|
18794
|
+
if (!isRecord8(message3) || message3.role !== "assistant")
|
|
18390
18795
|
continue;
|
|
18391
18796
|
this.#finalizeAssistantMessage(active, message3);
|
|
18392
18797
|
break;
|
|
@@ -18403,8 +18808,8 @@ var OmpRpcSession = class {
|
|
|
18403
18808
|
if (value.type !== "subagent_lifecycle" && value.type !== "subagent_progress" && value.type !== "subagent_event") {
|
|
18404
18809
|
return false;
|
|
18405
18810
|
}
|
|
18406
|
-
const payload =
|
|
18407
|
-
const progressPayload = value.type === "subagent_progress" && payload &&
|
|
18811
|
+
const payload = isRecord8(value.payload) ? value.payload : null;
|
|
18812
|
+
const progressPayload = value.type === "subagent_progress" && payload && isRecord8(payload.progress) ? payload.progress : null;
|
|
18408
18813
|
const nativeIdValue = progressPayload?.id ?? payload?.id;
|
|
18409
18814
|
if (!payload || !nonBlankString(nativeIdValue)) {
|
|
18410
18815
|
throw new OmpRpcFaultError("protocolError", "Omp RPC Subagent frame has no stable ID");
|
|
@@ -18983,7 +19388,7 @@ var ompCommandCatalog = harnessCommandCatalogSchema.parse({
|
|
|
18983
19388
|
]
|
|
18984
19389
|
});
|
|
18985
19390
|
var DEFAULT_TOOL_OUTPUT_LIMIT = 64e3;
|
|
18986
|
-
function
|
|
19391
|
+
function isRecord9(value) {
|
|
18987
19392
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
18988
19393
|
}
|
|
18989
19394
|
function errorMessage(error51) {
|
|
@@ -18998,7 +19403,7 @@ var OmpAdapterFaultError = class extends Error {
|
|
|
18998
19403
|
}
|
|
18999
19404
|
};
|
|
19000
19405
|
function normalizedError(error51, fallbackCode) {
|
|
19001
|
-
if (
|
|
19406
|
+
if (isRecord9(error51) && error51.code === "ENOENT") {
|
|
19002
19407
|
return { code: "notInstalled", message: errorMessage(error51), retryable: false };
|
|
19003
19408
|
}
|
|
19004
19409
|
if (error51 instanceof OmpAdapterFaultError)
|
|
@@ -19075,7 +19480,7 @@ function nativeModelForHistory(state) {
|
|
|
19075
19480
|
return nativeModelFromState(state);
|
|
19076
19481
|
}
|
|
19077
19482
|
function sessionFileFromRef(ref) {
|
|
19078
|
-
if (ref.harnessId !== ompHarnessId2 || !
|
|
19483
|
+
if (ref.harnessId !== ompHarnessId2 || !isRecord9(ref.locator) || typeof ref.locator.sessionFile !== "string" || ref.locator.sessionFile.length === 0) {
|
|
19079
19484
|
throw new Error("Omp Native Session Ref has no resumable Session file");
|
|
19080
19485
|
}
|
|
19081
19486
|
return ref.locator.sessionFile;
|
|
@@ -19085,7 +19490,7 @@ function subagentTranscriptPath(parentSessionFile, nativeSubagentId) {
|
|
|
19085
19490
|
if (nativeSubagentId.includes("/") || nativeSubagentId.includes("\\") || nativeSubagentId.includes("\0") || nativeSubagentId === "." || nativeSubagentId === "..") {
|
|
19086
19491
|
throw new Error("Omp Subagent ID is not a plain transcript file name");
|
|
19087
19492
|
}
|
|
19088
|
-
if (!parentSessionFile.endsWith(".jsonl") || !
|
|
19493
|
+
if (!parentSessionFile.endsWith(".jsonl") || !path6.isAbsolute(parentSessionFile)) {
|
|
19089
19494
|
return null;
|
|
19090
19495
|
}
|
|
19091
19496
|
return `${parentSessionFile.slice(0, -".jsonl".length)}/${nativeSubagentId}.jsonl`;
|
|
@@ -19094,10 +19499,10 @@ async function readSubagentTranscriptFile(parentSessionFile, nativeSubagentId) {
|
|
|
19094
19499
|
const transcriptFile = subagentTranscriptPath(parentSessionFile, nativeSubagentId);
|
|
19095
19500
|
if (transcriptFile === null)
|
|
19096
19501
|
return { status: "missing" };
|
|
19097
|
-
const parentDirectory =
|
|
19502
|
+
const parentDirectory = path6.dirname(transcriptFile);
|
|
19098
19503
|
let metadata;
|
|
19099
19504
|
try {
|
|
19100
|
-
metadata = await
|
|
19505
|
+
metadata = await stat2(transcriptFile);
|
|
19101
19506
|
} catch (error51) {
|
|
19102
19507
|
if (error51.code === "ENOENT")
|
|
19103
19508
|
return { status: "missing" };
|
|
@@ -19109,10 +19514,10 @@ async function readSubagentTranscriptFile(parentSessionFile, nativeSubagentId) {
|
|
|
19109
19514
|
throw new Error("Omp Subagent transcript exceeds the supported size");
|
|
19110
19515
|
}
|
|
19111
19516
|
const [resolvedTranscript, resolvedParentDirectory] = await Promise.all([
|
|
19112
|
-
|
|
19113
|
-
|
|
19517
|
+
realpath3(transcriptFile),
|
|
19518
|
+
realpath3(parentDirectory)
|
|
19114
19519
|
]);
|
|
19115
|
-
if (
|
|
19520
|
+
if (path6.dirname(resolvedTranscript) !== resolvedParentDirectory) {
|
|
19116
19521
|
throw new Error("Omp Subagent transcript resolves outside its parent Session directory");
|
|
19117
19522
|
}
|
|
19118
19523
|
return {
|
|
@@ -19130,9 +19535,9 @@ function toolFailure(toolName) {
|
|
|
19130
19535
|
function nativeText(value) {
|
|
19131
19536
|
if (typeof value === "string")
|
|
19132
19537
|
return value;
|
|
19133
|
-
if (!
|
|
19538
|
+
if (!isRecord9(value) || !Array.isArray(value.content))
|
|
19134
19539
|
return "";
|
|
19135
|
-
return value.content.filter((content) =>
|
|
19540
|
+
return value.content.filter((content) => isRecord9(content) && content.type === "text" && typeof content.text === "string").map(({ text }) => text).join("");
|
|
19136
19541
|
}
|
|
19137
19542
|
function boundedOutput(value, limit) {
|
|
19138
19543
|
const text = nativeText(value);
|
|
@@ -19148,17 +19553,17 @@ function outputText(output) {
|
|
|
19148
19553
|
return output?.content.filter((content) => content.type === "text").map(({ text }) => text).join("") ?? "";
|
|
19149
19554
|
}
|
|
19150
19555
|
function stringField2(value, key) {
|
|
19151
|
-
if (!
|
|
19556
|
+
if (!isRecord9(value))
|
|
19152
19557
|
return void 0;
|
|
19153
19558
|
const field = value[key];
|
|
19154
19559
|
if (typeof field === "string" && field.length > 0)
|
|
19155
19560
|
return field;
|
|
19156
|
-
if (
|
|
19561
|
+
if (isRecord9(value.input)) {
|
|
19157
19562
|
const nested = value.input[key];
|
|
19158
19563
|
if (typeof nested === "string" && nested.length > 0)
|
|
19159
19564
|
return nested;
|
|
19160
19565
|
}
|
|
19161
|
-
if (
|
|
19566
|
+
if (isRecord9(value.arguments)) {
|
|
19162
19567
|
const nested = value.arguments[key];
|
|
19163
19568
|
if (typeof nested === "string" && nested.length > 0)
|
|
19164
19569
|
return nested;
|
|
@@ -19166,7 +19571,7 @@ function stringField2(value, key) {
|
|
|
19166
19571
|
return void 0;
|
|
19167
19572
|
}
|
|
19168
19573
|
function numberField(value, key) {
|
|
19169
|
-
if (!
|
|
19574
|
+
if (!isRecord9(value))
|
|
19170
19575
|
return void 0;
|
|
19171
19576
|
const field = value[key];
|
|
19172
19577
|
return typeof field === "number" || field === null ? field : void 0;
|
|
@@ -19177,10 +19582,10 @@ function stripDiffPrefix(pathString) {
|
|
|
19177
19582
|
return pathString.startsWith("a/") || pathString.startsWith("b/") ? pathString.slice(2) : pathString;
|
|
19178
19583
|
}
|
|
19179
19584
|
function displayPath(nativePath, cwd) {
|
|
19180
|
-
const resolvedCwd =
|
|
19181
|
-
const resolvedPath =
|
|
19182
|
-
const relative =
|
|
19183
|
-
const inside = relative.length > 0 && relative !== ".." && !relative.startsWith(`..${
|
|
19585
|
+
const resolvedCwd = path6.resolve(cwd);
|
|
19586
|
+
const resolvedPath = path6.isAbsolute(nativePath) ? path6.resolve(nativePath) : path6.resolve(cwd, nativePath);
|
|
19587
|
+
const relative = path6.relative(resolvedCwd, resolvedPath);
|
|
19588
|
+
const inside = relative.length > 0 && relative !== ".." && !relative.startsWith(`..${path6.sep}`);
|
|
19184
19589
|
const selected = inside ? relative : resolvedPath;
|
|
19185
19590
|
const normalized = selected.replaceAll("\\", "/");
|
|
19186
19591
|
if (normalized.length === 0 || normalized === ".")
|
|
@@ -19205,7 +19610,7 @@ function fileMutatingKind(toolName) {
|
|
|
19205
19610
|
return null;
|
|
19206
19611
|
}
|
|
19207
19612
|
function nestedToolString(value, keys) {
|
|
19208
|
-
if (!
|
|
19613
|
+
if (!isRecord9(value))
|
|
19209
19614
|
return void 0;
|
|
19210
19615
|
for (const key of keys) {
|
|
19211
19616
|
const field = value[key];
|
|
@@ -19220,14 +19625,14 @@ function nestedToolString(value, keys) {
|
|
|
19220
19625
|
return void 0;
|
|
19221
19626
|
}
|
|
19222
19627
|
function patchFromResult(result) {
|
|
19223
|
-
if (!
|
|
19628
|
+
if (!isRecord9(result))
|
|
19224
19629
|
return void 0;
|
|
19225
19630
|
for (const key of ["patch", "diff", "unifiedDiff"]) {
|
|
19226
19631
|
const field = result[key];
|
|
19227
19632
|
if (typeof field === "string" && field.length > 0)
|
|
19228
19633
|
return field;
|
|
19229
19634
|
}
|
|
19230
|
-
if (
|
|
19635
|
+
if (isRecord9(result.details)) {
|
|
19231
19636
|
for (const key of ["patch", "diff", "unifiedDiff"]) {
|
|
19232
19637
|
const field = result.details[key];
|
|
19233
19638
|
if (typeof field === "string" && field.length > 0)
|
|
@@ -20712,6 +21117,7 @@ var OmpAdapter = class {
|
|
|
20712
21117
|
commandCatalog = ompCommandCatalog;
|
|
20713
21118
|
liveCommandCatalog = true;
|
|
20714
21119
|
harnessId = ompHarnessId2;
|
|
21120
|
+
sessionImport;
|
|
20715
21121
|
subagents = {
|
|
20716
21122
|
readSnapshot: async (input) => {
|
|
20717
21123
|
if (input.parent.harnessId !== this.harnessId || input.nativeSubagentId.trim().length === 0 || input.cwd.length === 0) {
|
|
@@ -20771,6 +21177,7 @@ var OmpAdapter = class {
|
|
|
20771
21177
|
createTransport: (sessionOptions) => new OmpRpcSession({ ...options, ...sessionOptions })
|
|
20772
21178
|
}) {
|
|
20773
21179
|
this.#createTransport = dependencies.createTransport;
|
|
21180
|
+
this.sessionImport = new OmpSessionImport({ ...process.env, ...options.environment });
|
|
20774
21181
|
this.#closeTimeoutMs = options.closeTimeoutMs ?? 2e3;
|
|
20775
21182
|
this.#toolOutputLimit = options.toolOutputLimit ?? DEFAULT_TOOL_OUTPUT_LIMIT;
|
|
20776
21183
|
}
|
|
@@ -21036,6 +21443,7 @@ var OmpAdapter = class {
|
|
|
21036
21443
|
close() {
|
|
21037
21444
|
if (!this.#closePromise) {
|
|
21038
21445
|
this.#closePromise = Promise.all([
|
|
21446
|
+
this.sessionImport.close(),
|
|
21039
21447
|
...[...this.#inspections].map((transport) => transport.close()),
|
|
21040
21448
|
...[...this.#sessions].map((session) => session.close())
|
|
21041
21449
|
]).then(() => void 0);
|
|
@@ -21045,22 +21453,22 @@ var OmpAdapter = class {
|
|
|
21045
21453
|
};
|
|
21046
21454
|
|
|
21047
21455
|
// dist/installation.js
|
|
21048
|
-
import { realpath as
|
|
21049
|
-
import
|
|
21456
|
+
import { realpath as realpath4 } from "node:fs/promises";
|
|
21457
|
+
import path7 from "node:path";
|
|
21050
21458
|
function createOmpInstallation(environment, command) {
|
|
21051
21459
|
let executable;
|
|
21052
21460
|
let env;
|
|
21053
21461
|
return createInstallationManager({
|
|
21054
21462
|
async check() {
|
|
21055
21463
|
executable = resolveOmpExecutable({ environment, ...command ? { command } : {} });
|
|
21056
|
-
const selected = await
|
|
21464
|
+
const selected = await realpath4(executable);
|
|
21057
21465
|
const pathKey = Object.keys(environment).find((key) => key.toLowerCase() === "path") ?? "PATH";
|
|
21058
21466
|
env = {
|
|
21059
21467
|
...environment,
|
|
21060
|
-
[pathKey]: `${
|
|
21468
|
+
[pathKey]: `${path7.dirname(executable)}${path7.delimiter}${environment[pathKey] ?? ""}`
|
|
21061
21469
|
};
|
|
21062
21470
|
const target = resolveHarnessExecutable({ id: "omp", command: "omp", installRoots: { posix: [], windows: [] } }, { environment: env });
|
|
21063
|
-
const canUpdate = !selected.includes("/nix/store/") && !!target && await
|
|
21471
|
+
const canUpdate = !selected.includes("/nix/store/") && !!target && await realpath4(target.executable) === selected;
|
|
21064
21472
|
const output = await runInstallationCommand(executable, ["update", "--check"], env);
|
|
21065
21473
|
const currentVersion = versionFromOutput(output);
|
|
21066
21474
|
const available = output.match(/New version available:\s*(\S+)/i);
|