@codexhost/cli-win32-arm64 0.10.0 → 0.10.2
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/host-runtime.mjs +216 -169
- package/app/plugins/deepseek-harness/plugin.mjs +593 -93
- package/app/plugins/omp/plugin.mjs +163 -103
- package/app/plugins/pi/plugin.mjs +4 -1
- package/app/renderer-extension.js +169 -113
- package/bin/codexhost.exe +0 -0
- package/libexec/codexhost-node-repl.exe +0 -0
- package/libexec/codexhost-shim.exe +0 -0
- package/libexec/codexhost-updater.exe +0 -0
- package/package.json +1 -1
|
@@ -527,6 +527,7 @@ function splitLines(text) {
|
|
|
527
527
|
|
|
528
528
|
// dist/omp-adapter.js
|
|
529
529
|
import { randomUUID as randomUUID2 } from "node:crypto";
|
|
530
|
+
import { realpath as realpath2, stat } from "node:fs/promises";
|
|
530
531
|
import path4 from "node:path";
|
|
531
532
|
|
|
532
533
|
// ../../../node_modules/zod/v4/classic/external.js
|
|
@@ -16706,6 +16707,100 @@ function resolveOmpForkBoundary(history, checkpointId) {
|
|
|
16706
16707
|
};
|
|
16707
16708
|
}
|
|
16708
16709
|
|
|
16710
|
+
// dist/omp-session-file.js
|
|
16711
|
+
import { createReadStream } from "node:fs";
|
|
16712
|
+
import { open, realpath } from "node:fs/promises";
|
|
16713
|
+
import readline from "node:readline";
|
|
16714
|
+
var MAX_SESSION_HEADER_BYTES = 64 * 1024;
|
|
16715
|
+
var utf8Decoder = new TextDecoder("utf-8", { fatal: true });
|
|
16716
|
+
function isRecord5(value) {
|
|
16717
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
16718
|
+
}
|
|
16719
|
+
function historyEntry(value) {
|
|
16720
|
+
if (!isRecord5(value) || value.type === "title" || value.type === "session" || typeof value.id !== "string" || value.id.length === 0 || value.parentId !== null && typeof value.parentId !== "string" || typeof value.type !== "string") {
|
|
16721
|
+
return null;
|
|
16722
|
+
}
|
|
16723
|
+
return value;
|
|
16724
|
+
}
|
|
16725
|
+
async function readOmpSessionHistory(sessionFile, maxBytes) {
|
|
16726
|
+
const entries = [];
|
|
16727
|
+
let leafId = null;
|
|
16728
|
+
const lines = readline.createInterface({
|
|
16729
|
+
input: createReadStream(sessionFile, {
|
|
16730
|
+
encoding: "utf8",
|
|
16731
|
+
...maxBytes === void 0 ? {} : { end: maxBytes - 1 }
|
|
16732
|
+
}),
|
|
16733
|
+
crlfDelay: Number.POSITIVE_INFINITY
|
|
16734
|
+
});
|
|
16735
|
+
try {
|
|
16736
|
+
for await (const line of lines) {
|
|
16737
|
+
if (line.length === 0)
|
|
16738
|
+
continue;
|
|
16739
|
+
let parsed;
|
|
16740
|
+
try {
|
|
16741
|
+
parsed = JSON.parse(line);
|
|
16742
|
+
} catch {
|
|
16743
|
+
continue;
|
|
16744
|
+
}
|
|
16745
|
+
const entry = historyEntry(parsed);
|
|
16746
|
+
if (!entry)
|
|
16747
|
+
continue;
|
|
16748
|
+
entries.push(entry);
|
|
16749
|
+
leafId = entry.id;
|
|
16750
|
+
}
|
|
16751
|
+
} finally {
|
|
16752
|
+
lines.close();
|
|
16753
|
+
}
|
|
16754
|
+
return { entries, leafId };
|
|
16755
|
+
}
|
|
16756
|
+
async function readOmpSessionHeader(sessionFile) {
|
|
16757
|
+
const handle = await open(sessionFile, "r");
|
|
16758
|
+
try {
|
|
16759
|
+
const buffer = Buffer.allocUnsafe(MAX_SESSION_HEADER_BYTES);
|
|
16760
|
+
const { bytesRead } = await handle.read(buffer, 0, buffer.length, 0);
|
|
16761
|
+
const contents = buffer.subarray(0, bytesRead);
|
|
16762
|
+
const newline = contents.indexOf(10);
|
|
16763
|
+
if (newline < 0 && bytesRead === buffer.length) {
|
|
16764
|
+
throw new Error("Omp Session header exceeds the supported size");
|
|
16765
|
+
}
|
|
16766
|
+
const contentsText = utf8Decoder.decode(contents);
|
|
16767
|
+
for (const line of contentsText.split("\n")) {
|
|
16768
|
+
if (line.length === 0)
|
|
16769
|
+
continue;
|
|
16770
|
+
let parsed;
|
|
16771
|
+
try {
|
|
16772
|
+
parsed = JSON.parse(line);
|
|
16773
|
+
} catch {
|
|
16774
|
+
continue;
|
|
16775
|
+
}
|
|
16776
|
+
if (!isRecord5(parsed) || parsed.type !== "session")
|
|
16777
|
+
continue;
|
|
16778
|
+
if (typeof parsed.id !== "string" || parsed.id.length === 0 || typeof parsed.cwd !== "string" || parsed.cwd.length === 0) {
|
|
16779
|
+
throw new Error("Omp Session header is invalid");
|
|
16780
|
+
}
|
|
16781
|
+
return { type: "session", id: parsed.id, cwd: parsed.cwd };
|
|
16782
|
+
}
|
|
16783
|
+
throw new Error("Omp Session header is invalid");
|
|
16784
|
+
} finally {
|
|
16785
|
+
await handle.close();
|
|
16786
|
+
}
|
|
16787
|
+
}
|
|
16788
|
+
async function verifyOmpSessionCwd(input) {
|
|
16789
|
+
if (!input.sessionFile)
|
|
16790
|
+
throw new Error("Omp Fork Session has no persisted Session file");
|
|
16791
|
+
const header = await readOmpSessionHeader(input.sessionFile);
|
|
16792
|
+
if (header.id !== input.sessionId) {
|
|
16793
|
+
throw new Error("Omp Fork Session header identity does not match RPC state");
|
|
16794
|
+
}
|
|
16795
|
+
const [actualCwd, expectedCwd] = await Promise.all([
|
|
16796
|
+
realpath(header.cwd),
|
|
16797
|
+
realpath(input.expectedCwd)
|
|
16798
|
+
]);
|
|
16799
|
+
if (actualCwd !== expectedCwd) {
|
|
16800
|
+
throw new Error("Omp Fork Session did not bind the requested cwd");
|
|
16801
|
+
}
|
|
16802
|
+
}
|
|
16803
|
+
|
|
16709
16804
|
// dist/omp-last-turn-rollback.js
|
|
16710
16805
|
function modelFromState(state) {
|
|
16711
16806
|
if (state.provider === null && state.modelId === null)
|
|
@@ -17013,14 +17108,14 @@ function resolveOmpExecutable(input, dependencies = {}) {
|
|
|
17013
17108
|
}
|
|
17014
17109
|
|
|
17015
17110
|
// dist/omp-usage.js
|
|
17016
|
-
function
|
|
17111
|
+
function isRecord6(value) {
|
|
17017
17112
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
17018
17113
|
}
|
|
17019
17114
|
function nonNegativeSafeInteger(value) {
|
|
17020
17115
|
return typeof value === "number" && Number.isSafeInteger(value) && value >= 0 ? value : null;
|
|
17021
17116
|
}
|
|
17022
17117
|
function optionalOmpCacheHitRatePercent(value) {
|
|
17023
|
-
if (!
|
|
17118
|
+
if (!isRecord6(value) || value.role !== "assistant" || !isRecord6(value.usage))
|
|
17024
17119
|
return null;
|
|
17025
17120
|
const input = nonNegativeSafeInteger(value.usage.input);
|
|
17026
17121
|
const cacheRead = nonNegativeSafeInteger(value.usage.cacheRead);
|
|
@@ -17033,20 +17128,20 @@ function optionalOmpCacheHitRatePercent(value) {
|
|
|
17033
17128
|
function latestOmpCacheHitRatePercent(history) {
|
|
17034
17129
|
let latest = null;
|
|
17035
17130
|
for (const entry of activeOmpEntries(history)) {
|
|
17036
|
-
if (entry.type === "message" &&
|
|
17131
|
+
if (entry.type === "message" && isRecord6(entry.message) && entry.message.role === "assistant") {
|
|
17037
17132
|
latest = optionalOmpCacheHitRatePercent(entry.message);
|
|
17038
17133
|
}
|
|
17039
17134
|
}
|
|
17040
17135
|
return latest;
|
|
17041
17136
|
}
|
|
17042
17137
|
function responseData(response, operation) {
|
|
17043
|
-
if (!
|
|
17138
|
+
if (!isRecord6(response.data)) {
|
|
17044
17139
|
throw new Error(`Omp RPC ${operation} response has no data`);
|
|
17045
17140
|
}
|
|
17046
17141
|
return response.data;
|
|
17047
17142
|
}
|
|
17048
17143
|
function contextUsage(value) {
|
|
17049
|
-
if (!
|
|
17144
|
+
if (!isRecord6(value))
|
|
17050
17145
|
throw new Error("Omp RPC context Usage is invalid");
|
|
17051
17146
|
return parseHostUsage({
|
|
17052
17147
|
contextUsedTokens: value.tokens,
|
|
@@ -17056,15 +17151,15 @@ function contextUsage(value) {
|
|
|
17056
17151
|
function parseOmpSessionUsage(response) {
|
|
17057
17152
|
const data = responseData(response, "Session stats");
|
|
17058
17153
|
const tokens = data.tokens;
|
|
17059
|
-
if (tokens !== void 0 && !
|
|
17154
|
+
if (tokens !== void 0 && !isRecord6(tokens)) {
|
|
17060
17155
|
throw new Error("Omp RPC Session stats tokens are invalid");
|
|
17061
17156
|
}
|
|
17062
17157
|
return parseHostUsage({
|
|
17063
|
-
...
|
|
17064
|
-
...
|
|
17065
|
-
...
|
|
17066
|
-
...
|
|
17067
|
-
...
|
|
17158
|
+
...isRecord6(tokens) && tokens.input !== void 0 ? { inputTokens: tokens.input } : {},
|
|
17159
|
+
...isRecord6(tokens) && tokens.cacheRead !== void 0 ? { cachedInputTokens: tokens.cacheRead } : {},
|
|
17160
|
+
...isRecord6(tokens) && tokens.cacheWrite !== void 0 ? { cacheWriteInputTokens: tokens.cacheWrite } : {},
|
|
17161
|
+
...isRecord6(tokens) && tokens.output !== void 0 ? { outputTokens: tokens.output } : {},
|
|
17162
|
+
...isRecord6(tokens) && tokens.total !== void 0 ? { totalTokens: tokens.total } : {},
|
|
17068
17163
|
...data.cost !== void 0 ? { totalCostUsd: data.cost } : {},
|
|
17069
17164
|
...data.contextUsage !== void 0 ? contextUsage(data.contextUsage) : {}
|
|
17070
17165
|
});
|
|
@@ -17083,97 +17178,6 @@ function optionalOmpStateContextUsage(value) {
|
|
|
17083
17178
|
}
|
|
17084
17179
|
}
|
|
17085
17180
|
|
|
17086
|
-
// dist/omp-session-file.js
|
|
17087
|
-
import { createReadStream } from "node:fs";
|
|
17088
|
-
import { open, realpath } from "node:fs/promises";
|
|
17089
|
-
import readline from "node:readline";
|
|
17090
|
-
var MAX_SESSION_HEADER_BYTES = 64 * 1024;
|
|
17091
|
-
var utf8Decoder = new TextDecoder("utf-8", { fatal: true });
|
|
17092
|
-
function isRecord6(value) {
|
|
17093
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
17094
|
-
}
|
|
17095
|
-
function historyEntry(value) {
|
|
17096
|
-
if (!isRecord6(value) || value.type === "title" || value.type === "session" || typeof value.id !== "string" || value.id.length === 0 || value.parentId !== null && typeof value.parentId !== "string" || typeof value.type !== "string") {
|
|
17097
|
-
return null;
|
|
17098
|
-
}
|
|
17099
|
-
return value;
|
|
17100
|
-
}
|
|
17101
|
-
async function readOmpSessionHistory(sessionFile) {
|
|
17102
|
-
const entries = [];
|
|
17103
|
-
let leafId = null;
|
|
17104
|
-
const lines = readline.createInterface({
|
|
17105
|
-
input: createReadStream(sessionFile, { encoding: "utf8" }),
|
|
17106
|
-
crlfDelay: Number.POSITIVE_INFINITY
|
|
17107
|
-
});
|
|
17108
|
-
try {
|
|
17109
|
-
for await (const line of lines) {
|
|
17110
|
-
if (line.length === 0)
|
|
17111
|
-
continue;
|
|
17112
|
-
let parsed;
|
|
17113
|
-
try {
|
|
17114
|
-
parsed = JSON.parse(line);
|
|
17115
|
-
} catch {
|
|
17116
|
-
continue;
|
|
17117
|
-
}
|
|
17118
|
-
const entry = historyEntry(parsed);
|
|
17119
|
-
if (!entry)
|
|
17120
|
-
continue;
|
|
17121
|
-
entries.push(entry);
|
|
17122
|
-
leafId = entry.id;
|
|
17123
|
-
}
|
|
17124
|
-
} finally {
|
|
17125
|
-
lines.close();
|
|
17126
|
-
}
|
|
17127
|
-
return { entries, leafId };
|
|
17128
|
-
}
|
|
17129
|
-
async function readOmpSessionHeader(sessionFile) {
|
|
17130
|
-
const handle = await open(sessionFile, "r");
|
|
17131
|
-
try {
|
|
17132
|
-
const buffer = Buffer.allocUnsafe(MAX_SESSION_HEADER_BYTES);
|
|
17133
|
-
const { bytesRead } = await handle.read(buffer, 0, buffer.length, 0);
|
|
17134
|
-
const contents = buffer.subarray(0, bytesRead);
|
|
17135
|
-
const newline = contents.indexOf(10);
|
|
17136
|
-
if (newline < 0 && bytesRead === buffer.length) {
|
|
17137
|
-
throw new Error("Omp Session header exceeds the supported size");
|
|
17138
|
-
}
|
|
17139
|
-
const contentsText = utf8Decoder.decode(contents);
|
|
17140
|
-
for (const line of contentsText.split("\n")) {
|
|
17141
|
-
if (line.length === 0)
|
|
17142
|
-
continue;
|
|
17143
|
-
let parsed;
|
|
17144
|
-
try {
|
|
17145
|
-
parsed = JSON.parse(line);
|
|
17146
|
-
} catch {
|
|
17147
|
-
continue;
|
|
17148
|
-
}
|
|
17149
|
-
if (!isRecord6(parsed) || parsed.type !== "session")
|
|
17150
|
-
continue;
|
|
17151
|
-
if (typeof parsed.id !== "string" || parsed.id.length === 0 || typeof parsed.cwd !== "string" || parsed.cwd.length === 0) {
|
|
17152
|
-
throw new Error("Omp Session header is invalid");
|
|
17153
|
-
}
|
|
17154
|
-
return { type: "session", id: parsed.id, cwd: parsed.cwd };
|
|
17155
|
-
}
|
|
17156
|
-
throw new Error("Omp Session header is invalid");
|
|
17157
|
-
} finally {
|
|
17158
|
-
await handle.close();
|
|
17159
|
-
}
|
|
17160
|
-
}
|
|
17161
|
-
async function verifyOmpSessionCwd(input) {
|
|
17162
|
-
if (!input.sessionFile)
|
|
17163
|
-
throw new Error("Omp Fork Session has no persisted Session file");
|
|
17164
|
-
const header = await readOmpSessionHeader(input.sessionFile);
|
|
17165
|
-
if (header.id !== input.sessionId) {
|
|
17166
|
-
throw new Error("Omp Fork Session header identity does not match RPC state");
|
|
17167
|
-
}
|
|
17168
|
-
const [actualCwd, expectedCwd] = await Promise.all([
|
|
17169
|
-
realpath(header.cwd),
|
|
17170
|
-
realpath(input.expectedCwd)
|
|
17171
|
-
]);
|
|
17172
|
-
if (actualCwd !== expectedCwd) {
|
|
17173
|
-
throw new Error("Omp Fork Session did not bind the requested cwd");
|
|
17174
|
-
}
|
|
17175
|
-
}
|
|
17176
|
-
|
|
17177
17181
|
// dist/omp-protocol.js
|
|
17178
17182
|
var MAX_FRAME_BYTES = 1024 * 1024;
|
|
17179
17183
|
var MAX_REASSEMBLED_BYTES = 64 * 1024 * 1024;
|
|
@@ -17568,6 +17572,9 @@ var OmpRpcSession = class {
|
|
|
17568
17572
|
new Promise((_resolve, reject) => setTimeout(() => reject(new Error("Omp RPC ready signal timed out")), this.#options.commandTimeoutMs))
|
|
17569
17573
|
]);
|
|
17570
17574
|
await this.#send("negotiate_protocol", { protocolVersion: 2 }).catch(() => void 0);
|
|
17575
|
+
if (this.#options.subscribeSubagentEvents !== false) {
|
|
17576
|
+
await this.#send("set_subagent_subscription", { level: "events" }).catch(() => void 0);
|
|
17577
|
+
}
|
|
17571
17578
|
try {
|
|
17572
17579
|
this.#state = parseSessionState(await this.#send("get_state", {}));
|
|
17573
17580
|
} catch (error51) {
|
|
@@ -18713,6 +18720,46 @@ function sessionFileFromRef(ref) {
|
|
|
18713
18720
|
}
|
|
18714
18721
|
return ref.locator.sessionFile;
|
|
18715
18722
|
}
|
|
18723
|
+
var MAX_SUBAGENT_TRANSCRIPT_BYTES = 8 * 1024 * 1024;
|
|
18724
|
+
function subagentTranscriptPath(parentSessionFile, nativeSubagentId) {
|
|
18725
|
+
if (nativeSubagentId.includes("/") || nativeSubagentId.includes("\\") || nativeSubagentId.includes("\0") || nativeSubagentId === "." || nativeSubagentId === "..") {
|
|
18726
|
+
throw new Error("Omp Subagent ID is not a plain transcript file name");
|
|
18727
|
+
}
|
|
18728
|
+
if (!parentSessionFile.endsWith(".jsonl") || !path4.isAbsolute(parentSessionFile)) {
|
|
18729
|
+
return null;
|
|
18730
|
+
}
|
|
18731
|
+
return `${parentSessionFile.slice(0, -".jsonl".length)}/${nativeSubagentId}.jsonl`;
|
|
18732
|
+
}
|
|
18733
|
+
async function readSubagentTranscriptFile(parentSessionFile, nativeSubagentId) {
|
|
18734
|
+
const transcriptFile = subagentTranscriptPath(parentSessionFile, nativeSubagentId);
|
|
18735
|
+
if (transcriptFile === null)
|
|
18736
|
+
return { status: "missing" };
|
|
18737
|
+
const parentDirectory = path4.dirname(transcriptFile);
|
|
18738
|
+
let metadata;
|
|
18739
|
+
try {
|
|
18740
|
+
metadata = await stat(transcriptFile);
|
|
18741
|
+
} catch (error51) {
|
|
18742
|
+
if (error51.code === "ENOENT")
|
|
18743
|
+
return { status: "missing" };
|
|
18744
|
+
throw error51;
|
|
18745
|
+
}
|
|
18746
|
+
if (!metadata.isFile())
|
|
18747
|
+
return { status: "missing" };
|
|
18748
|
+
if (metadata.size > MAX_SUBAGENT_TRANSCRIPT_BYTES) {
|
|
18749
|
+
throw new Error("Omp Subagent transcript exceeds the supported size");
|
|
18750
|
+
}
|
|
18751
|
+
const [resolvedTranscript, resolvedParentDirectory] = await Promise.all([
|
|
18752
|
+
realpath2(transcriptFile),
|
|
18753
|
+
realpath2(parentDirectory)
|
|
18754
|
+
]);
|
|
18755
|
+
if (path4.dirname(resolvedTranscript) !== resolvedParentDirectory) {
|
|
18756
|
+
throw new Error("Omp Subagent transcript resolves outside its parent Session directory");
|
|
18757
|
+
}
|
|
18758
|
+
return {
|
|
18759
|
+
status: "read",
|
|
18760
|
+
history: await readOmpSessionHistory(transcriptFile, MAX_SUBAGENT_TRANSCRIPT_BYTES)
|
|
18761
|
+
};
|
|
18762
|
+
}
|
|
18716
18763
|
function toolFailure(toolName) {
|
|
18717
18764
|
return {
|
|
18718
18765
|
code: "nativeFailure",
|
|
@@ -20316,9 +20363,18 @@ var OmpAdapter = class {
|
|
|
20316
20363
|
}
|
|
20317
20364
|
let transport;
|
|
20318
20365
|
try {
|
|
20366
|
+
const transcriptFile = await readSubagentTranscriptFile(sessionFileFromRef(input.parent), input.nativeSubagentId);
|
|
20367
|
+
if (transcriptFile.status === "read") {
|
|
20368
|
+
const snapshot2 = mapOmpSnapshot(transcriptFile.history, {
|
|
20369
|
+
sessionId: input.parent.nativeSessionId,
|
|
20370
|
+
model: null
|
|
20371
|
+
});
|
|
20372
|
+
return { ok: true, value: snapshot2 };
|
|
20373
|
+
}
|
|
20319
20374
|
transport = this.#createTransport({
|
|
20320
20375
|
cwd: input.cwd,
|
|
20321
20376
|
sessionFile: sessionFileFromRef(input.parent),
|
|
20377
|
+
subscribeSubagentEvents: false,
|
|
20322
20378
|
onFault: () => void 0
|
|
20323
20379
|
});
|
|
20324
20380
|
await transport.start();
|
|
@@ -20390,7 +20446,11 @@ var OmpAdapter = class {
|
|
|
20390
20446
|
async #inspectCwd(cwd) {
|
|
20391
20447
|
const startedAt = Date.now();
|
|
20392
20448
|
let stage = "spawn";
|
|
20393
|
-
const transport = this.#createTransport({
|
|
20449
|
+
const transport = this.#createTransport({
|
|
20450
|
+
cwd,
|
|
20451
|
+
subscribeSubagentEvents: false,
|
|
20452
|
+
onFault: () => void 0
|
|
20453
|
+
});
|
|
20394
20454
|
this.#inspections.add(transport);
|
|
20395
20455
|
try {
|
|
20396
20456
|
stage = "startup";
|
|
@@ -18700,7 +18700,10 @@ var PiRpcSession = class {
|
|
|
18700
18700
|
}
|
|
18701
18701
|
this.#options = {
|
|
18702
18702
|
commandTimeoutMs: 3e4,
|
|
18703
|
-
|
|
18703
|
+
// Bounds proven stable settlement (Abort acknowledgement plus agent_settled and get_state
|
|
18704
|
+
// confirmation), not the RPC write round trip; must exceed the Host's 20s external steering
|
|
18705
|
+
// bound so a slow cancellation times out gracefully instead of faulting the whole Session.
|
|
18706
|
+
cancelTimeoutMs: 3e4,
|
|
18704
18707
|
closeTimeoutMs: 2e3,
|
|
18705
18708
|
...options
|
|
18706
18709
|
};
|