@liberseek/boft-cli-win32-arm64 0.7.6 → 0.7.8
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 +85 -61
- package/app/console-web.js +678 -182
- package/app/desktop-controller.mjs +84 -22
- package/app/host-runtime.mjs +540 -132
- package/app/plugins/antigravity/plugin.mjs +809 -718
- package/app/plugins/claude-code/plugin.mjs +281 -117
- package/app/plugins/codebuddy/plugin.mjs +739 -664
- package/app/plugins/cursor-cli/plugin.mjs +451 -359
- package/app/plugins/deepseek-harness/plugin.mjs +25477 -26255
- package/app/plugins/grok/plugin.mjs +1405 -1313
- package/app/plugins/hermes/plugin.mjs +621 -472
- package/app/plugins/kimi-code/plugin.mjs +754 -674
- package/app/plugins/kiro-cli/plugin.mjs +15836 -15742
- package/app/plugins/muse/plugin.mjs +74 -55
- package/app/plugins/omp/plugin.mjs +1669 -1551
- package/app/plugins/opencode/plugin.mjs +745 -668
- package/app/plugins/pi/plugin.mjs +15810 -15699
- package/app/plugins/qoder/plugin.mjs +515 -393
- package/app/plugins/qoder-cn/plugin.mjs +181 -57
- package/app/plugins/workbuddy/plugin.mjs +74 -55
- package/app/renderer-extension.js +945 -379
- 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 +1 -1
|
@@ -5,364 +5,767 @@ var __export = (target, all) => {
|
|
|
5
5
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
6
6
|
};
|
|
7
7
|
|
|
8
|
-
//
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
const newString = this.castInput(newStr, options);
|
|
20
|
-
const oldTokens = this.removeEmpty(this.tokenize(oldString, options));
|
|
21
|
-
const newTokens = this.removeEmpty(this.tokenize(newString, options));
|
|
22
|
-
return this.diffWithOptionsObj(oldTokens, newTokens, options, callback);
|
|
8
|
+
// ../../harness-discovery/dist/environment.js
|
|
9
|
+
import fs from "node:fs";
|
|
10
|
+
import path from "node:path";
|
|
11
|
+
function targetPath(platform) {
|
|
12
|
+
return platform === "win32" ? path.win32 : path.posix;
|
|
13
|
+
}
|
|
14
|
+
function environmentValue(environment, name) {
|
|
15
|
+
const lowered = name.toLowerCase();
|
|
16
|
+
for (const [key, value] of Object.entries(environment)) {
|
|
17
|
+
if (key.toLowerCase() === lowered)
|
|
18
|
+
return value;
|
|
23
19
|
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
const bestPath = [{ oldPos: -1, lastComponent: void 0 }];
|
|
46
|
-
let newPos = this.extractCommon(bestPath[0], newTokens, oldTokens, 0, options);
|
|
47
|
-
if (bestPath[0].oldPos + 1 >= oldLen && newPos + 1 >= newLen) {
|
|
48
|
-
return done(this.buildValues(bestPath[0].lastComponent, newTokens, oldTokens));
|
|
49
|
-
}
|
|
50
|
-
let minDiagonalToConsider = -Infinity, maxDiagonalToConsider = Infinity;
|
|
51
|
-
const execEditLength = () => {
|
|
52
|
-
for (let diagonalPath = Math.max(minDiagonalToConsider, -editLength); diagonalPath <= Math.min(maxDiagonalToConsider, editLength); diagonalPath += 2) {
|
|
53
|
-
let basePath;
|
|
54
|
-
const removePath = bestPath[diagonalPath - 1], addPath = bestPath[diagonalPath + 1];
|
|
55
|
-
if (removePath) {
|
|
56
|
-
bestPath[diagonalPath - 1] = void 0;
|
|
57
|
-
}
|
|
58
|
-
let canAdd = false;
|
|
59
|
-
if (addPath) {
|
|
60
|
-
const addPathNewPos = addPath.oldPos - diagonalPath;
|
|
61
|
-
canAdd = addPath && 0 <= addPathNewPos && addPathNewPos < newLen;
|
|
62
|
-
}
|
|
63
|
-
const canRemove = removePath && removePath.oldPos + 1 < oldLen;
|
|
64
|
-
if (!canAdd && !canRemove) {
|
|
65
|
-
bestPath[diagonalPath] = void 0;
|
|
66
|
-
continue;
|
|
67
|
-
}
|
|
68
|
-
if (!canRemove || canAdd && removePath.oldPos < addPath.oldPos) {
|
|
69
|
-
basePath = this.addToPath(addPath, true, false, 0, options);
|
|
70
|
-
} else {
|
|
71
|
-
basePath = this.addToPath(removePath, false, true, 1, options);
|
|
72
|
-
}
|
|
73
|
-
newPos = this.extractCommon(basePath, newTokens, oldTokens, diagonalPath, options);
|
|
74
|
-
if (basePath.oldPos + 1 >= oldLen && newPos + 1 >= newLen) {
|
|
75
|
-
return done(this.buildValues(basePath.lastComponent, newTokens, oldTokens)) || true;
|
|
76
|
-
} else {
|
|
77
|
-
bestPath[diagonalPath] = basePath;
|
|
78
|
-
if (basePath.oldPos + 1 >= oldLen) {
|
|
79
|
-
maxDiagonalToConsider = Math.min(maxDiagonalToConsider, diagonalPath - 1);
|
|
80
|
-
}
|
|
81
|
-
if (newPos + 1 >= newLen) {
|
|
82
|
-
minDiagonalToConsider = Math.max(minDiagonalToConsider, diagonalPath + 1);
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
editLength++;
|
|
87
|
-
};
|
|
88
|
-
if (callback) {
|
|
89
|
-
(function exec() {
|
|
90
|
-
setTimeout(function() {
|
|
91
|
-
if (editLength > maxEditLength || Date.now() > abortAfterTimestamp) {
|
|
92
|
-
return callback(void 0);
|
|
93
|
-
}
|
|
94
|
-
if (!execEditLength()) {
|
|
95
|
-
exec();
|
|
96
|
-
}
|
|
97
|
-
}, 0);
|
|
98
|
-
})();
|
|
99
|
-
} else {
|
|
100
|
-
while (editLength <= maxEditLength && Date.now() <= abortAfterTimestamp) {
|
|
101
|
-
const ret = execEditLength();
|
|
102
|
-
if (ret) {
|
|
103
|
-
return ret;
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
}
|
|
20
|
+
return void 0;
|
|
21
|
+
}
|
|
22
|
+
function pathDelimiter(platform) {
|
|
23
|
+
return platform === "win32" ? ";" : ":";
|
|
24
|
+
}
|
|
25
|
+
function pathDirectories(environment, platform) {
|
|
26
|
+
return (environmentValue(environment, "PATH") ?? "").split(pathDelimiter(platform)).map((directory) => directory.trim().replace(/^"|"$/gu, "")).filter(Boolean);
|
|
27
|
+
}
|
|
28
|
+
function executableExtensions(command, platform, environment) {
|
|
29
|
+
if (platform !== "win32")
|
|
30
|
+
return [""];
|
|
31
|
+
if (targetPath(platform).extname(command) !== "")
|
|
32
|
+
return [""];
|
|
33
|
+
return (environmentValue(environment, "PATHEXT") ?? ".COM;.EXE;.BAT;.CMD").split(";").map((extension) => extension.trim()).filter(Boolean);
|
|
34
|
+
}
|
|
35
|
+
function isExecutableFile(filePath, platform) {
|
|
36
|
+
try {
|
|
37
|
+
fs.accessSync(filePath, platform === "win32" ? fs.constants.F_OK : fs.constants.X_OK);
|
|
38
|
+
return fs.statSync(filePath).isFile();
|
|
39
|
+
} catch {
|
|
40
|
+
return false;
|
|
107
41
|
}
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
};
|
|
115
|
-
} else {
|
|
116
|
-
return {
|
|
117
|
-
oldPos: path7.oldPos + oldPosInc,
|
|
118
|
-
lastComponent: { count: 1, added, removed, previousComponent: last }
|
|
119
|
-
};
|
|
120
|
-
}
|
|
42
|
+
}
|
|
43
|
+
function subdirectoryNames(directory) {
|
|
44
|
+
try {
|
|
45
|
+
return fs.readdirSync(directory, { withFileTypes: true }).filter((entry) => entry.isDirectory()).map((entry) => entry.name);
|
|
46
|
+
} catch {
|
|
47
|
+
return [];
|
|
121
48
|
}
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
}
|
|
133
|
-
if (commonCount && !options.oneChangePerToken) {
|
|
134
|
-
basePath.lastComponent = { count: commonCount, previousComponent: basePath.lastComponent, added: false, removed: false };
|
|
135
|
-
}
|
|
136
|
-
basePath.oldPos = oldPos;
|
|
137
|
-
return newPos;
|
|
49
|
+
}
|
|
50
|
+
function newestFirst(names) {
|
|
51
|
+
return [...names].sort((left, right) => right.localeCompare(left, void 0, { numeric: true }));
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// ../../harness-discovery/dist/invocation.js
|
|
55
|
+
import path2 from "node:path";
|
|
56
|
+
function commandInvocation(command, arguments_, environment, platform = process.platform) {
|
|
57
|
+
const extension = path2.win32.extname(command).toLowerCase();
|
|
58
|
+
if (platform !== "win32" || ![".cmd", ".bat"].includes(extension)) {
|
|
59
|
+
return { command, arguments: [...arguments_], windowsVerbatimArguments: false };
|
|
138
60
|
}
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
61
|
+
const quote = (value) => `"${value.replaceAll("%", "%%").replaceAll('"', '""')}"`;
|
|
62
|
+
const commandLine = [command, ...arguments_].map(quote).join(" ");
|
|
63
|
+
return {
|
|
64
|
+
command: environmentValue(environment, "ComSpec") ?? "cmd.exe",
|
|
65
|
+
arguments: ["/d", "/v:off", "/s", "/c", `"${commandLine}"`],
|
|
66
|
+
windowsVerbatimArguments: true
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// ../../harness-discovery/dist/node-runtime.js
|
|
71
|
+
import path3 from "node:path";
|
|
72
|
+
function withNodeRuntimeOnPath(environment, runtimeExecutable = process.execPath, platform = process.platform) {
|
|
73
|
+
const pathKey = Object.keys(environment).find((name) => name.toLowerCase() === "path") ?? "PATH";
|
|
74
|
+
const delimiter = platform === "win32" ? ";" : ":";
|
|
75
|
+
const runtimeDirectory = path3.dirname(runtimeExecutable);
|
|
76
|
+
const directories = (environment[pathKey] ?? "").split(delimiter).filter(Boolean);
|
|
77
|
+
const equal = platform === "win32" ? (value) => value.toLowerCase() : (value) => value;
|
|
78
|
+
if (!directories.some((directory) => equal(directory) === equal(runtimeDirectory))) {
|
|
79
|
+
directories.push(runtimeDirectory);
|
|
145
80
|
}
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
81
|
+
return { ...environment, [pathKey]: directories.join(delimiter) };
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
// ../../harness-discovery/dist/resolve.js
|
|
85
|
+
import os from "node:os";
|
|
86
|
+
|
|
87
|
+
// ../../harness-discovery/dist/version-managers.js
|
|
88
|
+
function versionManagerBinaryDirectories(context) {
|
|
89
|
+
const { platform, environment, home } = context;
|
|
90
|
+
const list = context.subdirectories ?? subdirectoryNames;
|
|
91
|
+
const pathFlavor = targetPath(platform);
|
|
92
|
+
const value = (name) => environmentValue(environment, name);
|
|
93
|
+
const directories = [];
|
|
94
|
+
const versioned = (root, ...tail) => {
|
|
95
|
+
for (const version2 of newestFirst(list(root))) {
|
|
96
|
+
directories.push(pathFlavor.join(root, version2, ...tail));
|
|
152
97
|
}
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
98
|
+
};
|
|
99
|
+
if (platform === "win32") {
|
|
100
|
+
const appData = value("APPDATA") ?? pathFlavor.join(home, "AppData", "Roaming");
|
|
101
|
+
const localAppData = value("LOCALAPPDATA") ?? pathFlavor.join(home, "AppData", "Local");
|
|
102
|
+
versioned(pathFlavor.join(appData, "nvm"));
|
|
103
|
+
versioned(value("FNM_DIR") ?? pathFlavor.join(appData, "fnm", "node-versions"), "installation");
|
|
104
|
+
directories.push(pathFlavor.join(localAppData, "Volta", "bin"));
|
|
105
|
+
directories.push(pathFlavor.join(home, ".bun", "bin"));
|
|
106
|
+
const pnpmHome2 = value("PNPM_HOME");
|
|
107
|
+
if (pnpmHome2)
|
|
108
|
+
directories.push(pnpmHome2);
|
|
109
|
+
directories.push(pathFlavor.join(localAppData, "pnpm"));
|
|
110
|
+
return directories;
|
|
162
111
|
}
|
|
163
|
-
join(
|
|
164
|
-
|
|
112
|
+
versioned(pathFlavor.join(value("NVM_DIR") ?? pathFlavor.join(home, ".nvm"), "versions", "node"), "bin");
|
|
113
|
+
const fnmRoots = [
|
|
114
|
+
value("FNM_DIR"),
|
|
115
|
+
pathFlavor.join(home, ".local", "share", "fnm"),
|
|
116
|
+
pathFlavor.join(home, "Library", "Application Support", "fnm")
|
|
117
|
+
].filter((root) => root !== void 0);
|
|
118
|
+
for (const root of fnmRoots) {
|
|
119
|
+
versioned(pathFlavor.join(root, "node-versions"), "installation", "bin");
|
|
165
120
|
}
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
121
|
+
const voltaHome = value("VOLTA_HOME") ?? pathFlavor.join(home, ".volta");
|
|
122
|
+
versioned(pathFlavor.join(voltaHome, "tools", "image", "node"), "bin");
|
|
123
|
+
directories.push(pathFlavor.join(voltaHome, "bin"));
|
|
124
|
+
const asdfHome = value("ASDF_DATA_DIR") ?? pathFlavor.join(home, ".asdf");
|
|
125
|
+
versioned(pathFlavor.join(asdfHome, "installs", "nodejs"), "bin");
|
|
126
|
+
directories.push(pathFlavor.join(asdfHome, "shims"));
|
|
127
|
+
const nodenvHome = value("NODENV_ROOT") ?? pathFlavor.join(home, ".nodenv");
|
|
128
|
+
versioned(pathFlavor.join(nodenvHome, "versions"), "bin");
|
|
129
|
+
directories.push(pathFlavor.join(nodenvHome, "shims"));
|
|
130
|
+
versioned(pathFlavor.join(value("N_PREFIX") ?? "/usr/local", "n", "versions", "node"), "bin");
|
|
131
|
+
directories.push(pathFlavor.join(home, ".bun", "bin"));
|
|
132
|
+
const pnpmHome = value("PNPM_HOME");
|
|
133
|
+
if (pnpmHome)
|
|
134
|
+
directories.push(pnpmHome);
|
|
135
|
+
directories.push(pathFlavor.join(home, "Library", "pnpm"));
|
|
136
|
+
directories.push(pathFlavor.join(home, ".local", "share", "pnpm"));
|
|
137
|
+
for (const prefix of ["/opt/homebrew/opt", "/usr/local/opt"]) {
|
|
138
|
+
for (const formula of newestFirst(list(prefix).filter((name) => name.startsWith("node@")))) {
|
|
139
|
+
directories.push(pathFlavor.join(prefix, formula, "bin"));
|
|
140
|
+
}
|
|
171
141
|
}
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
142
|
+
return directories;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
// ../../harness-discovery/dist/resolve.js
|
|
146
|
+
var VERSION_MANAGER_ROOTS = "<version-managers>";
|
|
147
|
+
function installRootExtensions(platform) {
|
|
148
|
+
return platform === "win32" ? [".exe", ".cmd"] : [""];
|
|
149
|
+
}
|
|
150
|
+
function resolveHomeDirectory(input) {
|
|
151
|
+
return input.homeDirectory ?? environmentValue(input.environment, "HOME") ?? environmentValue(input.environment, "USERPROFILE") ?? os.homedir();
|
|
152
|
+
}
|
|
153
|
+
function templateVariables(environment, platform, home) {
|
|
154
|
+
const pathFlavor = targetPath(platform);
|
|
155
|
+
return {
|
|
156
|
+
HOME: home,
|
|
157
|
+
USERPROFILE: home,
|
|
158
|
+
APPDATA: environmentValue(environment, "APPDATA") ?? pathFlavor.join(home, "AppData", "Roaming"),
|
|
159
|
+
LOCALAPPDATA: environmentValue(environment, "LOCALAPPDATA") ?? pathFlavor.join(home, "AppData", "Local")
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
function joinTemplate(platform, value) {
|
|
163
|
+
const pathFlavor = targetPath(platform);
|
|
164
|
+
const segments = value.split("/");
|
|
165
|
+
const head = segments[0] ?? "";
|
|
166
|
+
const tail = segments.slice(1);
|
|
167
|
+
if (head === "")
|
|
168
|
+
return pathFlavor.join(pathFlavor.sep, ...tail);
|
|
169
|
+
return tail.length === 0 ? head : pathFlavor.join(head, ...tail);
|
|
170
|
+
}
|
|
171
|
+
function expandInstallRoot(template, environment, platform, home) {
|
|
172
|
+
const variables = templateVariables(environment, platform, home);
|
|
173
|
+
let unresolved = false;
|
|
174
|
+
const substituted = template.replace(/^~(?=\/|$)/u, home).replace(/\$\{(\w+)\}/gu, (_match, name) => {
|
|
175
|
+
const value = variables[name] ?? environmentValue(environment, name);
|
|
176
|
+
if (value === void 0 || value === "") {
|
|
177
|
+
unresolved = true;
|
|
178
|
+
return "";
|
|
180
179
|
}
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
newPos += component.count;
|
|
198
|
-
if (!component.added) {
|
|
199
|
-
oldPos += component.count;
|
|
200
|
-
}
|
|
201
|
-
} else {
|
|
202
|
-
component.value = this.join(oldTokens.slice(oldPos, oldPos + component.count));
|
|
203
|
-
oldPos += component.count;
|
|
204
|
-
}
|
|
180
|
+
return value;
|
|
181
|
+
});
|
|
182
|
+
return unresolved ? void 0 : joinTemplate(platform, substituted);
|
|
183
|
+
}
|
|
184
|
+
function installRootDirectories(spec, input, dependencies, platform, home) {
|
|
185
|
+
const templates = (platform === "win32" ? spec.installRoots?.windows : spec.installRoots?.posix) ?? [];
|
|
186
|
+
const directories = [];
|
|
187
|
+
for (const template of templates) {
|
|
188
|
+
if (template === VERSION_MANAGER_ROOTS) {
|
|
189
|
+
directories.push(...versionManagerBinaryDirectories({
|
|
190
|
+
platform,
|
|
191
|
+
environment: input.environment,
|
|
192
|
+
home,
|
|
193
|
+
...dependencies.subdirectories ? { subdirectories: dependencies.subdirectories } : {}
|
|
194
|
+
}));
|
|
195
|
+
continue;
|
|
205
196
|
}
|
|
206
|
-
|
|
197
|
+
const directory = expandInstallRoot(template, input.environment, platform, home);
|
|
198
|
+
if (directory !== void 0)
|
|
199
|
+
directories.push(directory);
|
|
207
200
|
}
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
201
|
+
return directories;
|
|
202
|
+
}
|
|
203
|
+
function harnessCandidates(spec, input, dependencies = {}) {
|
|
204
|
+
const platform = input.platform ?? process.platform;
|
|
205
|
+
const pathFlavor = targetPath(platform);
|
|
206
|
+
const configured = input.command ?? (spec.commandEnvironmentVariable ? environmentValue(input.environment, spec.commandEnvironmentVariable) : void 0);
|
|
207
|
+
const command = configured ?? spec.command;
|
|
208
|
+
if (pathFlavor.isAbsolute(command) || command.includes("/") || command.includes("\\")) {
|
|
209
|
+
return [{ candidate: command, source: "configured" }];
|
|
215
210
|
}
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
}
|
|
224
|
-
} else if (options.ignoreNewlineAtEof && !options.newlineIsToken) {
|
|
225
|
-
if (left.endsWith("\n")) {
|
|
226
|
-
left = left.slice(0, -1);
|
|
227
|
-
}
|
|
228
|
-
if (right.endsWith("\n")) {
|
|
229
|
-
right = right.slice(0, -1);
|
|
230
|
-
}
|
|
211
|
+
const candidates = [];
|
|
212
|
+
const extensions = executableExtensions(command, platform, input.environment);
|
|
213
|
+
for (const directory of pathDirectories(input.environment, platform)) {
|
|
214
|
+
for (const extension of extensions) {
|
|
215
|
+
candidates.push({
|
|
216
|
+
candidate: pathFlavor.join(directory, command + extension),
|
|
217
|
+
source: "path"
|
|
218
|
+
});
|
|
231
219
|
}
|
|
232
|
-
return super.equals(left, right, options);
|
|
233
220
|
}
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
221
|
+
if (configured !== void 0)
|
|
222
|
+
return candidates;
|
|
223
|
+
const home = resolveHomeDirectory(input);
|
|
224
|
+
for (const directory of installRootDirectories(spec, input, dependencies, platform, home)) {
|
|
225
|
+
for (const extension of installRootExtensions(platform)) {
|
|
226
|
+
candidates.push({
|
|
227
|
+
candidate: pathFlavor.join(directory, spec.command + extension),
|
|
228
|
+
source: "install-root"
|
|
229
|
+
});
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
return candidates;
|
|
238
233
|
}
|
|
239
|
-
function
|
|
240
|
-
|
|
241
|
-
|
|
234
|
+
function resolveHarnessExecutable(spec, input, dependencies = {}) {
|
|
235
|
+
const platform = input.platform ?? process.platform;
|
|
236
|
+
const isExecutable = dependencies.isExecutable ?? ((candidate) => isExecutableFile(candidate, platform));
|
|
237
|
+
const runnable = spec.runnableCandidate ?? ((candidate) => candidate);
|
|
238
|
+
const context = { platform, isExecutable };
|
|
239
|
+
for (const { candidate, source } of harnessCandidates(spec, input, dependencies)) {
|
|
240
|
+
const executable = runnable(candidate, context);
|
|
241
|
+
if (executable !== void 0 && isExecutable(executable))
|
|
242
|
+
return { executable, source };
|
|
242
243
|
}
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
244
|
+
return void 0;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
// ../../harness-discovery/dist/installation.js
|
|
248
|
+
import { execFile } from "node:child_process";
|
|
249
|
+
import { homedir } from "node:os";
|
|
250
|
+
function runInstallationCommand(command, args, environment, timeout = 3e4) {
|
|
251
|
+
const env = withNodeRuntimeOnPath(environment);
|
|
252
|
+
const invocation = /\.[cm]?js$/i.test(command) ? commandInvocation(process.execPath, [command, ...args], env) : commandInvocation(command, args, env);
|
|
253
|
+
return new Promise((resolve, reject) => {
|
|
254
|
+
const child = execFile(invocation.command, invocation.arguments, {
|
|
255
|
+
env,
|
|
256
|
+
cwd: env.HOME ?? env.USERPROFILE ?? homedir(),
|
|
257
|
+
encoding: "utf8",
|
|
258
|
+
timeout,
|
|
259
|
+
killSignal: "SIGKILL",
|
|
260
|
+
maxBuffer: 1024 * 1024,
|
|
261
|
+
windowsHide: true,
|
|
262
|
+
windowsVerbatimArguments: invocation.windowsVerbatimArguments
|
|
263
|
+
}, (error51, stdout, stderr) => {
|
|
264
|
+
if (error51)
|
|
265
|
+
reject(new Error(error51.killed ? "Harness command timed out" : "Harness command failed; check the native installation and retry"));
|
|
266
|
+
else
|
|
267
|
+
resolve((stdout || stderr).trim());
|
|
268
|
+
});
|
|
269
|
+
child.stdin?.end();
|
|
270
|
+
});
|
|
271
|
+
}
|
|
272
|
+
function installationVersion(value) {
|
|
273
|
+
if (typeof value !== "string" || !/^v?\d+(?:\.\d+){1,3}(?:-[\w.-]+)?(?:\+[\w.-]+)?$/.test(value.trim()))
|
|
274
|
+
throw new Error("Harness returned an invalid version");
|
|
275
|
+
return value.trim().replace(/^v/, "");
|
|
276
|
+
}
|
|
277
|
+
function versionFromOutput(output) {
|
|
278
|
+
return installationVersion(output.match(/\b\d+(?:\.\d+){1,3}(?:-[\w.-]+)?(?:\+[\w.-]+)?\b/)?.[0]);
|
|
279
|
+
}
|
|
280
|
+
function newerInstallationVersion(current, latest) {
|
|
281
|
+
const a = installationVersion(current).replace(/\+.*/, "");
|
|
282
|
+
const b = installationVersion(latest).replace(/\+.*/, "");
|
|
283
|
+
const coreA = a.replace(/-.*/, "").split(".").map(BigInt);
|
|
284
|
+
const coreB = b.replace(/-.*/, "").split(".").map(BigInt);
|
|
285
|
+
for (let i = 0; i < Math.max(coreA.length, coreB.length); i++) {
|
|
286
|
+
if ((coreA[i] ?? 0n) !== (coreB[i] ?? 0n))
|
|
287
|
+
return (coreB[i] ?? 0n) > (coreA[i] ?? 0n);
|
|
246
288
|
}
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
289
|
+
const preA = a.includes("-") ? a.slice(a.indexOf("-") + 1).split(".") : [];
|
|
290
|
+
const preB = b.includes("-") ? b.slice(b.indexOf("-") + 1).split(".") : [];
|
|
291
|
+
if (!preA.length || !preB.length)
|
|
292
|
+
return !!preA.length && !preB.length;
|
|
293
|
+
for (let i = 0; i < Math.max(preA.length, preB.length); i++) {
|
|
294
|
+
const x = preA[i];
|
|
295
|
+
const y = preB[i];
|
|
296
|
+
if (x === y)
|
|
297
|
+
continue;
|
|
298
|
+
if (x === void 0 || y === void 0)
|
|
299
|
+
return x === void 0;
|
|
300
|
+
const numericX = /^\d+$/.test(x);
|
|
301
|
+
const numericY = /^\d+$/.test(y);
|
|
302
|
+
if (numericX && numericY) {
|
|
303
|
+
if (BigInt(x) === BigInt(y))
|
|
304
|
+
continue;
|
|
305
|
+
return BigInt(y) > BigInt(x);
|
|
253
306
|
}
|
|
307
|
+
if (numericX !== numericY)
|
|
308
|
+
return numericX;
|
|
309
|
+
return y > x;
|
|
310
|
+
}
|
|
311
|
+
return false;
|
|
312
|
+
}
|
|
313
|
+
function createInstallationManager(options) {
|
|
314
|
+
let checking;
|
|
315
|
+
let updating;
|
|
316
|
+
const check2 = () => checking ??= options.check().finally(() => {
|
|
317
|
+
checking = void 0;
|
|
318
|
+
});
|
|
319
|
+
return (action) => {
|
|
320
|
+
if (updating)
|
|
321
|
+
return updating;
|
|
322
|
+
if (action === "check")
|
|
323
|
+
return check2();
|
|
324
|
+
updating = (async () => {
|
|
325
|
+
const before = await check2();
|
|
326
|
+
if (!before.updateAvailable)
|
|
327
|
+
return before;
|
|
328
|
+
if (!before.canUpdate)
|
|
329
|
+
throw new Error(before.message ?? "This installation cannot be updated automatically");
|
|
330
|
+
await options.update(before);
|
|
331
|
+
const after = await check2();
|
|
332
|
+
if (after.currentVersion === before.currentVersion)
|
|
333
|
+
throw new Error("The Harness version did not change; check the native updater and retry");
|
|
334
|
+
return after;
|
|
335
|
+
})().finally(() => {
|
|
336
|
+
updating = void 0;
|
|
337
|
+
});
|
|
338
|
+
return updating;
|
|
339
|
+
};
|
|
340
|
+
}
|
|
341
|
+
async function fetchInstallationText(url2) {
|
|
342
|
+
const request = async () => {
|
|
343
|
+
const response = await fetch(url2, { signal: AbortSignal.timeout(15e3) });
|
|
344
|
+
if (!response.ok)
|
|
345
|
+
throw new Error("Could not check the latest Harness version");
|
|
346
|
+
return response.text();
|
|
347
|
+
};
|
|
348
|
+
try {
|
|
349
|
+
return await request();
|
|
350
|
+
} catch (error51) {
|
|
351
|
+
if (error51 instanceof DOMException && (error51.name === "AbortError" || error51.name === "TimeoutError"))
|
|
352
|
+
throw error51;
|
|
353
|
+
return request();
|
|
254
354
|
}
|
|
255
|
-
return retLines;
|
|
256
355
|
}
|
|
257
356
|
|
|
258
|
-
//
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
357
|
+
// ../../harness-discovery/dist/installer.js
|
|
358
|
+
import { mkdtemp, rm, writeFile } from "node:fs/promises";
|
|
359
|
+
import { tmpdir } from "node:os";
|
|
360
|
+
import { join } from "node:path";
|
|
361
|
+
function createHarnessInstaller(environment, source) {
|
|
362
|
+
return async () => {
|
|
363
|
+
if (!["darwin", "linux", "win32"].includes(process.platform))
|
|
364
|
+
throw new Error("Unsupported installation platform");
|
|
365
|
+
const env = withNodeRuntimeOnPath(environment);
|
|
366
|
+
if ("npm" in source) {
|
|
367
|
+
const npm = resolveHarnessExecutable({
|
|
368
|
+
id: "npm",
|
|
369
|
+
command: "npm",
|
|
370
|
+
installRoots: {
|
|
371
|
+
posix: [
|
|
372
|
+
"~/.npm-global/bin",
|
|
373
|
+
"~/.local/bin",
|
|
374
|
+
VERSION_MANAGER_ROOTS,
|
|
375
|
+
"/opt/homebrew/bin",
|
|
376
|
+
"/usr/local/bin",
|
|
377
|
+
"/usr/bin"
|
|
378
|
+
],
|
|
379
|
+
windows: [
|
|
380
|
+
"${APPDATA}/npm",
|
|
381
|
+
VERSION_MANAGER_ROOTS,
|
|
382
|
+
"${ProgramFiles}/nodejs",
|
|
383
|
+
"${LOCALAPPDATA}/Programs/nodejs"
|
|
384
|
+
]
|
|
385
|
+
}
|
|
386
|
+
}, { environment: env });
|
|
387
|
+
if (!npm)
|
|
388
|
+
throw new Error("Install Node.js and npm first");
|
|
389
|
+
await runInstallationCommand(npm.executable, ["install", "--global", source.npm], {
|
|
390
|
+
...env,
|
|
391
|
+
...source.allowScripts ? { npm_config_allow_scripts: source.allowScripts } : {}
|
|
392
|
+
}, 6e5);
|
|
393
|
+
return;
|
|
275
394
|
}
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
i++;
|
|
289
|
-
}
|
|
395
|
+
const windows = process.platform === "win32";
|
|
396
|
+
const url2 = windows ? source.windows : source.posix;
|
|
397
|
+
if (new URL(url2).protocol !== "https:")
|
|
398
|
+
throw new Error("Installer requires HTTPS");
|
|
399
|
+
const script = await fetchInstallationText(url2);
|
|
400
|
+
const directory = await mkdtemp(join(tmpdir(), "codexhost-installer-"));
|
|
401
|
+
try {
|
|
402
|
+
const file2 = join(directory, windows ? "install.ps1" : "install.sh");
|
|
403
|
+
await writeFile(file2, script, { mode: 384 });
|
|
404
|
+
await runInstallationCommand(windows ? "powershell.exe" : source.shell ?? "bash", windows ? ["-NoProfile", "-NonInteractive", "-ExecutionPolicy", "Bypass", "-File", file2] : [file2], env, 6e5);
|
|
405
|
+
} finally {
|
|
406
|
+
await rm(directory, { recursive: true, force: true });
|
|
290
407
|
}
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
} else {
|
|
304
|
-
index.newFileName = fileName;
|
|
305
|
-
index.newHeader = header;
|
|
306
|
-
}
|
|
307
|
-
i++;
|
|
408
|
+
};
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
// ../../../node_modules/diff/libesm/diff/base.js
|
|
412
|
+
var Diff = class {
|
|
413
|
+
diff(oldStr, newStr, options = {}) {
|
|
414
|
+
let callback;
|
|
415
|
+
if (typeof options === "function") {
|
|
416
|
+
callback = options;
|
|
417
|
+
options = {};
|
|
418
|
+
} else if ("callback" in options) {
|
|
419
|
+
callback = options.callback;
|
|
308
420
|
}
|
|
421
|
+
const oldString = this.castInput(oldStr, options);
|
|
422
|
+
const newString = this.castInput(newStr, options);
|
|
423
|
+
const oldTokens = this.removeEmpty(this.tokenize(oldString, options));
|
|
424
|
+
const newTokens = this.removeEmpty(this.tokenize(newString, options));
|
|
425
|
+
return this.diffWithOptionsObj(oldTokens, newTokens, options, callback);
|
|
309
426
|
}
|
|
310
|
-
|
|
427
|
+
diffWithOptionsObj(oldTokens, newTokens, options, callback) {
|
|
311
428
|
var _a3;
|
|
312
|
-
const
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
429
|
+
const done = (value) => {
|
|
430
|
+
value = this.postProcess(value, options);
|
|
431
|
+
if (callback) {
|
|
432
|
+
setTimeout(function() {
|
|
433
|
+
callback(value);
|
|
434
|
+
}, 0);
|
|
435
|
+
return void 0;
|
|
436
|
+
} else {
|
|
437
|
+
return value;
|
|
438
|
+
}
|
|
319
439
|
};
|
|
320
|
-
|
|
321
|
-
|
|
440
|
+
const newLen = newTokens.length, oldLen = oldTokens.length;
|
|
441
|
+
let editLength = 1;
|
|
442
|
+
let maxEditLength = newLen + oldLen;
|
|
443
|
+
if (options.maxEditLength != null) {
|
|
444
|
+
maxEditLength = Math.min(maxEditLength, options.maxEditLength);
|
|
322
445
|
}
|
|
323
|
-
|
|
324
|
-
|
|
446
|
+
const maxExecutionTime = (_a3 = options.timeout) !== null && _a3 !== void 0 ? _a3 : Infinity;
|
|
447
|
+
const abortAfterTimestamp = Date.now() + maxExecutionTime;
|
|
448
|
+
const bestPath = [{ oldPos: -1, lastComponent: void 0 }];
|
|
449
|
+
let newPos = this.extractCommon(bestPath[0], newTokens, oldTokens, 0, options);
|
|
450
|
+
if (bestPath[0].oldPos + 1 >= oldLen && newPos + 1 >= newLen) {
|
|
451
|
+
return done(this.buildValues(bestPath[0].lastComponent, newTokens, oldTokens));
|
|
325
452
|
}
|
|
326
|
-
let
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
if (
|
|
332
|
-
|
|
333
|
-
}
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
453
|
+
let minDiagonalToConsider = -Infinity, maxDiagonalToConsider = Infinity;
|
|
454
|
+
const execEditLength = () => {
|
|
455
|
+
for (let diagonalPath = Math.max(minDiagonalToConsider, -editLength); diagonalPath <= Math.min(maxDiagonalToConsider, editLength); diagonalPath += 2) {
|
|
456
|
+
let basePath;
|
|
457
|
+
const removePath = bestPath[diagonalPath - 1], addPath = bestPath[diagonalPath + 1];
|
|
458
|
+
if (removePath) {
|
|
459
|
+
bestPath[diagonalPath - 1] = void 0;
|
|
460
|
+
}
|
|
461
|
+
let canAdd = false;
|
|
462
|
+
if (addPath) {
|
|
463
|
+
const addPathNewPos = addPath.oldPos - diagonalPath;
|
|
464
|
+
canAdd = addPath && 0 <= addPathNewPos && addPathNewPos < newLen;
|
|
465
|
+
}
|
|
466
|
+
const canRemove = removePath && removePath.oldPos + 1 < oldLen;
|
|
467
|
+
if (!canAdd && !canRemove) {
|
|
468
|
+
bestPath[diagonalPath] = void 0;
|
|
469
|
+
continue;
|
|
470
|
+
}
|
|
471
|
+
if (!canRemove || canAdd && removePath.oldPos < addPath.oldPos) {
|
|
472
|
+
basePath = this.addToPath(addPath, true, false, 0, options);
|
|
473
|
+
} else {
|
|
474
|
+
basePath = this.addToPath(removePath, false, true, 1, options);
|
|
475
|
+
}
|
|
476
|
+
newPos = this.extractCommon(basePath, newTokens, oldTokens, diagonalPath, options);
|
|
477
|
+
if (basePath.oldPos + 1 >= oldLen && newPos + 1 >= newLen) {
|
|
478
|
+
return done(this.buildValues(basePath.lastComponent, newTokens, oldTokens)) || true;
|
|
479
|
+
} else {
|
|
480
|
+
bestPath[diagonalPath] = basePath;
|
|
481
|
+
if (basePath.oldPos + 1 >= oldLen) {
|
|
482
|
+
maxDiagonalToConsider = Math.min(maxDiagonalToConsider, diagonalPath - 1);
|
|
483
|
+
}
|
|
484
|
+
if (newPos + 1 >= newLen) {
|
|
485
|
+
minDiagonalToConsider = Math.max(minDiagonalToConsider, diagonalPath + 1);
|
|
486
|
+
}
|
|
487
|
+
}
|
|
488
|
+
}
|
|
489
|
+
editLength++;
|
|
490
|
+
};
|
|
491
|
+
if (callback) {
|
|
492
|
+
(function exec() {
|
|
493
|
+
setTimeout(function() {
|
|
494
|
+
if (editLength > maxEditLength || Date.now() > abortAfterTimestamp) {
|
|
495
|
+
return callback(void 0);
|
|
496
|
+
}
|
|
497
|
+
if (!execEditLength()) {
|
|
498
|
+
exec();
|
|
499
|
+
}
|
|
500
|
+
}, 0);
|
|
501
|
+
})();
|
|
502
|
+
} else {
|
|
503
|
+
while (editLength <= maxEditLength && Date.now() <= abortAfterTimestamp) {
|
|
504
|
+
const ret = execEditLength();
|
|
505
|
+
if (ret) {
|
|
506
|
+
return ret;
|
|
338
507
|
}
|
|
339
|
-
} else {
|
|
340
|
-
throw new Error(`Hunk at line ${chunkHeaderIndex + 1} contained invalid line ${diffstr[i]}`);
|
|
341
508
|
}
|
|
342
509
|
}
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
if (!
|
|
347
|
-
|
|
510
|
+
}
|
|
511
|
+
addToPath(path7, added, removed, oldPosInc, options) {
|
|
512
|
+
const last = path7.lastComponent;
|
|
513
|
+
if (last && !options.oneChangePerToken && last.added === added && last.removed === removed) {
|
|
514
|
+
return {
|
|
515
|
+
oldPos: path7.oldPos + oldPosInc,
|
|
516
|
+
lastComponent: { count: last.count + 1, added, removed, previousComponent: last.previousComponent }
|
|
517
|
+
};
|
|
518
|
+
} else {
|
|
519
|
+
return {
|
|
520
|
+
oldPos: path7.oldPos + oldPosInc,
|
|
521
|
+
lastComponent: { count: 1, added, removed, previousComponent: last }
|
|
522
|
+
};
|
|
348
523
|
}
|
|
349
|
-
|
|
350
|
-
|
|
524
|
+
}
|
|
525
|
+
extractCommon(basePath, newTokens, oldTokens, diagonalPath, options) {
|
|
526
|
+
const newLen = newTokens.length, oldLen = oldTokens.length;
|
|
527
|
+
let oldPos = basePath.oldPos, newPos = oldPos - diagonalPath, commonCount = 0;
|
|
528
|
+
while (newPos + 1 < newLen && oldPos + 1 < oldLen && this.equals(oldTokens[oldPos + 1], newTokens[newPos + 1], options)) {
|
|
529
|
+
newPos++;
|
|
530
|
+
oldPos++;
|
|
531
|
+
commonCount++;
|
|
532
|
+
if (options.oneChangePerToken) {
|
|
533
|
+
basePath.lastComponent = { count: 1, previousComponent: basePath.lastComponent, added: false, removed: false };
|
|
534
|
+
}
|
|
351
535
|
}
|
|
352
|
-
if (
|
|
353
|
-
|
|
536
|
+
if (commonCount && !options.oneChangePerToken) {
|
|
537
|
+
basePath.lastComponent = { count: commonCount, previousComponent: basePath.lastComponent, added: false, removed: false };
|
|
354
538
|
}
|
|
355
|
-
|
|
539
|
+
basePath.oldPos = oldPos;
|
|
540
|
+
return newPos;
|
|
356
541
|
}
|
|
357
|
-
|
|
358
|
-
|
|
542
|
+
equals(left, right, options) {
|
|
543
|
+
if (options.comparator) {
|
|
544
|
+
return options.comparator(left, right);
|
|
545
|
+
} else {
|
|
546
|
+
return left === right || !!options.ignoreCase && left.toLowerCase() === right.toLowerCase();
|
|
547
|
+
}
|
|
359
548
|
}
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
549
|
+
removeEmpty(array2) {
|
|
550
|
+
const ret = [];
|
|
551
|
+
for (let i = 0; i < array2.length; i++) {
|
|
552
|
+
if (array2[i]) {
|
|
553
|
+
ret.push(array2[i]);
|
|
554
|
+
}
|
|
555
|
+
}
|
|
556
|
+
return ret;
|
|
557
|
+
}
|
|
558
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
559
|
+
castInput(value, options) {
|
|
560
|
+
return value;
|
|
561
|
+
}
|
|
562
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
563
|
+
tokenize(value, options) {
|
|
564
|
+
return Array.from(value);
|
|
565
|
+
}
|
|
566
|
+
join(chars) {
|
|
567
|
+
return chars.join("");
|
|
568
|
+
}
|
|
569
|
+
postProcess(changeObjects, options) {
|
|
570
|
+
return changeObjects;
|
|
571
|
+
}
|
|
572
|
+
get useLongestToken() {
|
|
573
|
+
return false;
|
|
574
|
+
}
|
|
575
|
+
buildValues(lastComponent, newTokens, oldTokens) {
|
|
576
|
+
const components = [];
|
|
577
|
+
let nextComponent;
|
|
578
|
+
while (lastComponent) {
|
|
579
|
+
components.push(lastComponent);
|
|
580
|
+
nextComponent = lastComponent.previousComponent;
|
|
581
|
+
delete lastComponent.previousComponent;
|
|
582
|
+
lastComponent = nextComponent;
|
|
583
|
+
}
|
|
584
|
+
components.reverse();
|
|
585
|
+
const componentLen = components.length;
|
|
586
|
+
let componentPos = 0, newPos = 0, oldPos = 0;
|
|
587
|
+
for (; componentPos < componentLen; componentPos++) {
|
|
588
|
+
const component = components[componentPos];
|
|
589
|
+
if (!component.removed) {
|
|
590
|
+
if (!component.added && this.useLongestToken) {
|
|
591
|
+
let value = newTokens.slice(newPos, newPos + component.count);
|
|
592
|
+
value = value.map(function(value2, i) {
|
|
593
|
+
const oldValue = oldTokens[oldPos + i];
|
|
594
|
+
return oldValue.length > value2.length ? oldValue : value2;
|
|
595
|
+
});
|
|
596
|
+
component.value = this.join(value);
|
|
597
|
+
} else {
|
|
598
|
+
component.value = this.join(newTokens.slice(newPos, newPos + component.count));
|
|
599
|
+
}
|
|
600
|
+
newPos += component.count;
|
|
601
|
+
if (!component.added) {
|
|
602
|
+
oldPos += component.count;
|
|
603
|
+
}
|
|
604
|
+
} else {
|
|
605
|
+
component.value = this.join(oldTokens.slice(oldPos, oldPos + component.count));
|
|
606
|
+
oldPos += component.count;
|
|
607
|
+
}
|
|
608
|
+
}
|
|
609
|
+
return components;
|
|
610
|
+
}
|
|
611
|
+
};
|
|
612
|
+
|
|
613
|
+
// ../../../node_modules/diff/libesm/diff/line.js
|
|
614
|
+
var LineDiff = class extends Diff {
|
|
615
|
+
constructor() {
|
|
616
|
+
super(...arguments);
|
|
617
|
+
this.tokenize = tokenize;
|
|
618
|
+
}
|
|
619
|
+
equals(left, right, options) {
|
|
620
|
+
if (options.ignoreWhitespace) {
|
|
621
|
+
if (!options.newlineIsToken || !left.includes("\n")) {
|
|
622
|
+
left = left.trim();
|
|
623
|
+
}
|
|
624
|
+
if (!options.newlineIsToken || !right.includes("\n")) {
|
|
625
|
+
right = right.trim();
|
|
626
|
+
}
|
|
627
|
+
} else if (options.ignoreNewlineAtEof && !options.newlineIsToken) {
|
|
628
|
+
if (left.endsWith("\n")) {
|
|
629
|
+
left = left.slice(0, -1);
|
|
630
|
+
}
|
|
631
|
+
if (right.endsWith("\n")) {
|
|
632
|
+
right = right.slice(0, -1);
|
|
633
|
+
}
|
|
634
|
+
}
|
|
635
|
+
return super.equals(left, right, options);
|
|
636
|
+
}
|
|
637
|
+
};
|
|
638
|
+
var lineDiff = new LineDiff();
|
|
639
|
+
function diffLines(oldStr, newStr, options) {
|
|
640
|
+
return lineDiff.diff(oldStr, newStr, options);
|
|
641
|
+
}
|
|
642
|
+
function tokenize(value, options) {
|
|
643
|
+
if (options.stripTrailingCr) {
|
|
644
|
+
value = value.replace(/\r\n/g, "\n");
|
|
645
|
+
}
|
|
646
|
+
const retLines = [], linesAndNewlines = value.split(/(\n|\r\n)/);
|
|
647
|
+
if (!linesAndNewlines[linesAndNewlines.length - 1]) {
|
|
648
|
+
linesAndNewlines.pop();
|
|
649
|
+
}
|
|
650
|
+
for (let i = 0; i < linesAndNewlines.length; i++) {
|
|
651
|
+
const line = linesAndNewlines[i];
|
|
652
|
+
if (i % 2 && !options.newlineIsToken) {
|
|
653
|
+
retLines[retLines.length - 1] += line;
|
|
654
|
+
} else {
|
|
655
|
+
retLines.push(line);
|
|
656
|
+
}
|
|
657
|
+
}
|
|
658
|
+
return retLines;
|
|
659
|
+
}
|
|
660
|
+
|
|
661
|
+
// ../../../node_modules/diff/libesm/patch/parse.js
|
|
662
|
+
function parsePatch(uniDiff) {
|
|
663
|
+
const diffstr = uniDiff.split(/\n/), list = [];
|
|
664
|
+
let i = 0;
|
|
665
|
+
function parseIndex() {
|
|
666
|
+
const index = {};
|
|
667
|
+
list.push(index);
|
|
668
|
+
while (i < diffstr.length) {
|
|
669
|
+
const line = diffstr[i];
|
|
670
|
+
if (/^(---|\+\+\+|@@)\s/.test(line)) {
|
|
671
|
+
break;
|
|
672
|
+
}
|
|
673
|
+
const header = /^(?:Index:|diff(?: -r \w+)+)\s+(.+?)\s*$/.exec(line);
|
|
674
|
+
if (header) {
|
|
675
|
+
index.index = header[1];
|
|
676
|
+
}
|
|
677
|
+
i++;
|
|
678
|
+
}
|
|
679
|
+
parseFileHeader(index);
|
|
680
|
+
parseFileHeader(index);
|
|
681
|
+
index.hunks = [];
|
|
682
|
+
while (i < diffstr.length) {
|
|
683
|
+
const line = diffstr[i];
|
|
684
|
+
if (/^(Index:\s|diff\s|---\s|\+\+\+\s|===================================================================)/.test(line)) {
|
|
685
|
+
break;
|
|
686
|
+
} else if (/^@@/.test(line)) {
|
|
687
|
+
index.hunks.push(parseHunk());
|
|
688
|
+
} else if (line) {
|
|
689
|
+
throw new Error("Unknown line " + (i + 1) + " " + JSON.stringify(line));
|
|
690
|
+
} else {
|
|
691
|
+
i++;
|
|
692
|
+
}
|
|
693
|
+
}
|
|
694
|
+
}
|
|
695
|
+
function parseFileHeader(index) {
|
|
696
|
+
const fileHeader = /^(---|\+\+\+)\s+(.*)\r?$/.exec(diffstr[i]);
|
|
697
|
+
if (fileHeader) {
|
|
698
|
+
const data = fileHeader[2].split(" ", 2), header = (data[1] || "").trim();
|
|
699
|
+
let fileName = data[0].replace(/\\\\/g, "\\");
|
|
700
|
+
if (/^".*"$/.test(fileName)) {
|
|
701
|
+
fileName = fileName.substr(1, fileName.length - 2);
|
|
702
|
+
}
|
|
703
|
+
if (fileHeader[1] === "---") {
|
|
704
|
+
index.oldFileName = fileName;
|
|
705
|
+
index.oldHeader = header;
|
|
706
|
+
} else {
|
|
707
|
+
index.newFileName = fileName;
|
|
708
|
+
index.newHeader = header;
|
|
709
|
+
}
|
|
710
|
+
i++;
|
|
711
|
+
}
|
|
712
|
+
}
|
|
713
|
+
function parseHunk() {
|
|
714
|
+
var _a3;
|
|
715
|
+
const chunkHeaderIndex = i, chunkHeaderLine = diffstr[i++], chunkHeader = chunkHeaderLine.split(/@@ -(\d+)(?:,(\d+))? \+(\d+)(?:,(\d+))? @@/);
|
|
716
|
+
const hunk = {
|
|
717
|
+
oldStart: +chunkHeader[1],
|
|
718
|
+
oldLines: typeof chunkHeader[2] === "undefined" ? 1 : +chunkHeader[2],
|
|
719
|
+
newStart: +chunkHeader[3],
|
|
720
|
+
newLines: typeof chunkHeader[4] === "undefined" ? 1 : +chunkHeader[4],
|
|
721
|
+
lines: []
|
|
722
|
+
};
|
|
723
|
+
if (hunk.oldLines === 0) {
|
|
724
|
+
hunk.oldStart += 1;
|
|
725
|
+
}
|
|
726
|
+
if (hunk.newLines === 0) {
|
|
727
|
+
hunk.newStart += 1;
|
|
728
|
+
}
|
|
729
|
+
let addCount = 0, removeCount = 0;
|
|
730
|
+
for (; i < diffstr.length && (removeCount < hunk.oldLines || addCount < hunk.newLines || ((_a3 = diffstr[i]) === null || _a3 === void 0 ? void 0 : _a3.startsWith("\\"))); i++) {
|
|
731
|
+
const operation = diffstr[i].length == 0 && i != diffstr.length - 1 ? " " : diffstr[i][0];
|
|
732
|
+
if (operation === "+" || operation === "-" || operation === " " || operation === "\\") {
|
|
733
|
+
hunk.lines.push(diffstr[i]);
|
|
734
|
+
if (operation === "+") {
|
|
735
|
+
addCount++;
|
|
736
|
+
} else if (operation === "-") {
|
|
737
|
+
removeCount++;
|
|
738
|
+
} else if (operation === " ") {
|
|
739
|
+
addCount++;
|
|
740
|
+
removeCount++;
|
|
741
|
+
}
|
|
742
|
+
} else {
|
|
743
|
+
throw new Error(`Hunk at line ${chunkHeaderIndex + 1} contained invalid line ${diffstr[i]}`);
|
|
744
|
+
}
|
|
745
|
+
}
|
|
746
|
+
if (!addCount && hunk.newLines === 1) {
|
|
747
|
+
hunk.newLines = 0;
|
|
748
|
+
}
|
|
749
|
+
if (!removeCount && hunk.oldLines === 1) {
|
|
750
|
+
hunk.oldLines = 0;
|
|
751
|
+
}
|
|
752
|
+
if (addCount !== hunk.newLines) {
|
|
753
|
+
throw new Error("Added line count did not match for hunk at line " + (chunkHeaderIndex + 1));
|
|
754
|
+
}
|
|
755
|
+
if (removeCount !== hunk.oldLines) {
|
|
756
|
+
throw new Error("Removed line count did not match for hunk at line " + (chunkHeaderIndex + 1));
|
|
757
|
+
}
|
|
758
|
+
return hunk;
|
|
759
|
+
}
|
|
760
|
+
while (i < diffstr.length) {
|
|
761
|
+
parseIndex();
|
|
762
|
+
}
|
|
763
|
+
return list;
|
|
764
|
+
}
|
|
765
|
+
|
|
766
|
+
// ../../../node_modules/diff/libesm/patch/create.js
|
|
767
|
+
function structuredPatch(oldFileName, newFileName, oldStr, newStr, oldHeader, newHeader, options) {
|
|
768
|
+
let optionsObj;
|
|
366
769
|
if (!options) {
|
|
367
770
|
optionsObj = {};
|
|
368
771
|
} else if (typeof options === "function") {
|
|
@@ -15114,40 +15517,108 @@ var harnessDisplaySetSchema = external_exports.strictObject({
|
|
|
15114
15517
|
initializeOnly: external_exports.boolean().optional()
|
|
15115
15518
|
});
|
|
15116
15519
|
|
|
15117
|
-
// ../../shared-contracts/dist/
|
|
15118
|
-
var
|
|
15119
|
-
|
|
15120
|
-
type: external_exports.enum(["info", "warning", "danger"]),
|
|
15121
|
-
body: external_exports.string().trim().min(1).max(16 * 1024)
|
|
15122
|
-
});
|
|
15123
|
-
var consoleOpenParamsSchema = external_exports.strictObject({});
|
|
15124
|
-
var consoleOpenResultSchema = external_exports.strictObject({
|
|
15125
|
-
/** The console address. */
|
|
15126
|
-
url: external_exports.string().max(2048).regex(/^http:\/\/(?:127\.0\.0\.1|localhost):\d{1,5}\/(?:\?.*)?$/u)
|
|
15520
|
+
// ../../shared-contracts/dist/ids.js
|
|
15521
|
+
var opaqueIdSchema = external_exports.string().refine((value) => value.trim().length > 0, {
|
|
15522
|
+
message: "Identifier must not be empty or whitespace"
|
|
15127
15523
|
});
|
|
15128
|
-
var
|
|
15129
|
-
|
|
15130
|
-
|
|
15131
|
-
|
|
15132
|
-
|
|
15133
|
-
|
|
15134
|
-
|
|
15135
|
-
|
|
15136
|
-
|
|
15137
|
-
|
|
15138
|
-
|
|
15139
|
-
|
|
15140
|
-
|
|
15141
|
-
|
|
15142
|
-
|
|
15143
|
-
|
|
15144
|
-
|
|
15145
|
-
|
|
15146
|
-
|
|
15147
|
-
|
|
15148
|
-
|
|
15149
|
-
|
|
15150
|
-
|
|
15524
|
+
var harnessIdSchema = opaqueIdSchema.brand();
|
|
15525
|
+
var hostThreadIdSchema = opaqueIdSchema.brand();
|
|
15526
|
+
var hostTurnIdSchema = opaqueIdSchema.brand();
|
|
15527
|
+
var hostItemIdSchema = opaqueIdSchema.brand();
|
|
15528
|
+
var hostInteractionIdSchema = opaqueIdSchema.brand();
|
|
15529
|
+
|
|
15530
|
+
// ../../shared-contracts/dist/harness-plugins.js
|
|
15531
|
+
var HARNESS_PLUGIN_MANIFEST_MAX_BYTES = 32 * 1024;
|
|
15532
|
+
var HARNESS_PLUGIN_ICON_MAX_BYTES = 128 * 1024;
|
|
15533
|
+
var HARNESS_PLUGIN_LIMIT = 128;
|
|
15534
|
+
var harnessPluginIdSchema = external_exports.string().min(1).max(128).regex(/^[a-z][a-z0-9]*(?:[._-][a-z0-9]+)*$/u).refine((id) => id !== "codex", "The official Codex identity is reserved").pipe(harnessIdSchema);
|
|
15535
|
+
var relativeResourceSchema = external_exports.string().min(1).max(512).refine((value) => !/[\\\u0000:#?]/u.test(value) && !value.startsWith("/") && !value.split("/").some((part) => part === ".." || part === ""), "Plugin resources must be relative paths inside the plugin");
|
|
15536
|
+
var documentationUrlSchema = external_exports.url().refine((value) => /^https:\/\/[^/?#@]+(?:[/?#]|$)/iu.test(value), "Plugin documentation links must be credential-free HTTPS URLs");
|
|
15537
|
+
var pluginPresentationShape = {
|
|
15538
|
+
id: harnessPluginIdSchema,
|
|
15539
|
+
name: external_exports.string().trim().min(1).max(128),
|
|
15540
|
+
version: external_exports.string().min(1).max(128),
|
|
15541
|
+
/** The factory accepts a persisted local entrypoint through its construction context. */
|
|
15542
|
+
launchCommand: external_exports.literal(true).optional(),
|
|
15543
|
+
links: external_exports.object({
|
|
15544
|
+
documentation: documentationUrlSchema.optional(),
|
|
15545
|
+
installation: documentationUrlSchema.optional()
|
|
15546
|
+
}).strict().optional()
|
|
15547
|
+
};
|
|
15548
|
+
var harnessPluginManifestSchema = external_exports.object({
|
|
15549
|
+
manifestVersion: external_exports.literal(1),
|
|
15550
|
+
...pluginPresentationShape,
|
|
15551
|
+
adapterApiVersion: external_exports.number().int().positive(),
|
|
15552
|
+
entry: relativeResourceSchema,
|
|
15553
|
+
icon: relativeResourceSchema.optional()
|
|
15554
|
+
}).strict();
|
|
15555
|
+
var harnessPluginIconSchema = external_exports.string().max(Math.ceil(HARNESS_PLUGIN_ICON_MAX_BYTES / 3) * 4 + 64).regex(/^data:image\/(?:png|jpeg|webp|svg\+xml);base64,[A-Za-z0-9+/]+={0,2}$/u);
|
|
15556
|
+
var harnessPluginDescriptorSchema = external_exports.object({
|
|
15557
|
+
...pluginPresentationShape,
|
|
15558
|
+
icon: harnessPluginIconSchema.optional()
|
|
15559
|
+
}).strict();
|
|
15560
|
+
var harnessPluginListParamsSchema = external_exports.object({}).strict();
|
|
15561
|
+
var harnessPluginListResultSchema = external_exports.object({
|
|
15562
|
+
plugins: external_exports.array(harnessPluginDescriptorSchema).max(HARNESS_PLUGIN_LIMIT)
|
|
15563
|
+
}).strict();
|
|
15564
|
+
var harnessPluginConfigurationSchema = external_exports.object({
|
|
15565
|
+
version: external_exports.literal(1),
|
|
15566
|
+
enabled: external_exports.array(harnessPluginIdSchema).max(HARNESS_PLUGIN_LIMIT)
|
|
15567
|
+
}).strict().refine((value) => new Set(value.enabled).size === value.enabled.length, {
|
|
15568
|
+
message: "Enabled plugin IDs must be unique",
|
|
15569
|
+
path: ["enabled"]
|
|
15570
|
+
});
|
|
15571
|
+
|
|
15572
|
+
// ../../shared-contracts/dist/harness-long-context.js
|
|
15573
|
+
var HARNESS_LONG_CONTEXT_GET_METHOD = "codexhost/harness/long-context/get";
|
|
15574
|
+
var HARNESS_LONG_CONTEXT_SET_METHOD = "codexhost/harness/long-context/set";
|
|
15575
|
+
var harnessLongContextGetSchema = external_exports.object({
|
|
15576
|
+
harnessId: harnessPluginIdSchema
|
|
15577
|
+
}).strict();
|
|
15578
|
+
var harnessLongContextSetSchema = harnessLongContextGetSchema.extend({
|
|
15579
|
+
enabled: external_exports.boolean()
|
|
15580
|
+
});
|
|
15581
|
+
var harnessLongContextSchema = external_exports.object({
|
|
15582
|
+
enabled: external_exports.boolean()
|
|
15583
|
+
}).strict();
|
|
15584
|
+
|
|
15585
|
+
// ../../shared-contracts/dist/console.js
|
|
15586
|
+
var consoleAnnouncementSchema = external_exports.strictObject({
|
|
15587
|
+
title: external_exports.string().trim().min(1).max(200),
|
|
15588
|
+
type: external_exports.enum(["info", "warning", "danger"]),
|
|
15589
|
+
body: external_exports.string().trim().min(1).max(16 * 1024)
|
|
15590
|
+
});
|
|
15591
|
+
var consoleOpenParamsSchema = external_exports.strictObject({});
|
|
15592
|
+
var consoleOpenResultSchema = external_exports.strictObject({
|
|
15593
|
+
/** The console address. */
|
|
15594
|
+
url: external_exports.string().max(2048).regex(/^http:\/\/(?:127\.0\.0\.1|localhost):\d{1,5}\/(?:\?.*)?$/u)
|
|
15595
|
+
});
|
|
15596
|
+
var CONSOLE_HOST_METHODS = Object.freeze([
|
|
15597
|
+
"codexhost/harness/plugins/list",
|
|
15598
|
+
"codexhost/harness/display-settings/get",
|
|
15599
|
+
"codexhost/harness/display-settings/set",
|
|
15600
|
+
"codexhost/harness/inspect",
|
|
15601
|
+
"codexhost/harness/installation",
|
|
15602
|
+
"codexhost/harness/launch-settings/get",
|
|
15603
|
+
"codexhost/harness/launch-settings/set",
|
|
15604
|
+
HARNESS_LONG_CONTEXT_GET_METHOD,
|
|
15605
|
+
HARNESS_LONG_CONTEXT_SET_METHOD,
|
|
15606
|
+
"codexhost/harness/web-ui/open",
|
|
15607
|
+
"codexhost/harness/accounts/sources",
|
|
15608
|
+
"codexhost/harness/accounts/list",
|
|
15609
|
+
"codexhost/harness/accounts/inspect",
|
|
15610
|
+
"codexhost/harness/credential-imports",
|
|
15611
|
+
"codexhost/harness/session-import/sources",
|
|
15612
|
+
"codexhost/harness/session-import/list",
|
|
15613
|
+
"codexhost/harness/session-import/import",
|
|
15614
|
+
"codexhost/account/list",
|
|
15615
|
+
"codexhost/account/refresh",
|
|
15616
|
+
"codexhost/account/usage/inspect",
|
|
15617
|
+
"codexhost/update/check",
|
|
15618
|
+
"codexhost/update/start",
|
|
15619
|
+
"codexhost/update/status"
|
|
15620
|
+
]);
|
|
15621
|
+
|
|
15151
15622
|
// ../../shared-contracts/dist/version.js
|
|
15152
15623
|
var WORKSPACE_CONTRACT_VERSION = 1;
|
|
15153
15624
|
|
|
@@ -15191,16 +15662,6 @@ var loadedSessionsSchema = external_exports.array(external_exports.strictObject(
|
|
|
15191
15662
|
inactiveMs: external_exports.number().nonnegative()
|
|
15192
15663
|
}));
|
|
15193
15664
|
|
|
15194
|
-
// ../../shared-contracts/dist/ids.js
|
|
15195
|
-
var opaqueIdSchema = external_exports.string().refine((value) => value.trim().length > 0, {
|
|
15196
|
-
message: "Identifier must not be empty or whitespace"
|
|
15197
|
-
});
|
|
15198
|
-
var harnessIdSchema = opaqueIdSchema.brand();
|
|
15199
|
-
var hostThreadIdSchema = opaqueIdSchema.brand();
|
|
15200
|
-
var hostTurnIdSchema = opaqueIdSchema.brand();
|
|
15201
|
-
var hostItemIdSchema = opaqueIdSchema.brand();
|
|
15202
|
-
var hostInteractionIdSchema = opaqueIdSchema.brand();
|
|
15203
|
-
|
|
15204
15665
|
// ../../shared-contracts/dist/manual-compaction.js
|
|
15205
15666
|
var threadManualCompactionStartedSchema = external_exports.strictObject({
|
|
15206
15667
|
threadId: hostThreadIdSchema,
|
|
@@ -15730,48 +16191,6 @@ var threadOwnershipListResultSchema = external_exports.object({
|
|
|
15730
16191
|
}
|
|
15731
16192
|
});
|
|
15732
16193
|
|
|
15733
|
-
// ../../shared-contracts/dist/harness-plugins.js
|
|
15734
|
-
var HARNESS_PLUGIN_MANIFEST_MAX_BYTES = 32 * 1024;
|
|
15735
|
-
var HARNESS_PLUGIN_ICON_MAX_BYTES = 128 * 1024;
|
|
15736
|
-
var HARNESS_PLUGIN_LIMIT = 128;
|
|
15737
|
-
var harnessPluginIdSchema = external_exports.string().min(1).max(128).regex(/^[a-z][a-z0-9]*(?:[._-][a-z0-9]+)*$/u).refine((id) => id !== "codex", "The official Codex identity is reserved").pipe(harnessIdSchema);
|
|
15738
|
-
var relativeResourceSchema = external_exports.string().min(1).max(512).refine((value) => !/[\\\u0000:#?]/u.test(value) && !value.startsWith("/") && !value.split("/").some((part) => part === ".." || part === ""), "Plugin resources must be relative paths inside the plugin");
|
|
15739
|
-
var documentationUrlSchema = external_exports.url().refine((value) => /^https:\/\/[^/?#@]+(?:[/?#]|$)/iu.test(value), "Plugin documentation links must be credential-free HTTPS URLs");
|
|
15740
|
-
var pluginPresentationShape = {
|
|
15741
|
-
id: harnessPluginIdSchema,
|
|
15742
|
-
name: external_exports.string().trim().min(1).max(128),
|
|
15743
|
-
version: external_exports.string().min(1).max(128),
|
|
15744
|
-
/** The factory accepts a persisted local entrypoint through its construction context. */
|
|
15745
|
-
launchCommand: external_exports.literal(true).optional(),
|
|
15746
|
-
links: external_exports.object({
|
|
15747
|
-
documentation: documentationUrlSchema.optional(),
|
|
15748
|
-
installation: documentationUrlSchema.optional()
|
|
15749
|
-
}).strict().optional()
|
|
15750
|
-
};
|
|
15751
|
-
var harnessPluginManifestSchema = external_exports.object({
|
|
15752
|
-
manifestVersion: external_exports.literal(1),
|
|
15753
|
-
...pluginPresentationShape,
|
|
15754
|
-
adapterApiVersion: external_exports.number().int().positive(),
|
|
15755
|
-
entry: relativeResourceSchema,
|
|
15756
|
-
icon: relativeResourceSchema.optional()
|
|
15757
|
-
}).strict();
|
|
15758
|
-
var harnessPluginIconSchema = external_exports.string().max(Math.ceil(HARNESS_PLUGIN_ICON_MAX_BYTES / 3) * 4 + 64).regex(/^data:image\/(?:png|jpeg|webp|svg\+xml);base64,[A-Za-z0-9+/]+={0,2}$/u);
|
|
15759
|
-
var harnessPluginDescriptorSchema = external_exports.object({
|
|
15760
|
-
...pluginPresentationShape,
|
|
15761
|
-
icon: harnessPluginIconSchema.optional()
|
|
15762
|
-
}).strict();
|
|
15763
|
-
var harnessPluginListParamsSchema = external_exports.object({}).strict();
|
|
15764
|
-
var harnessPluginListResultSchema = external_exports.object({
|
|
15765
|
-
plugins: external_exports.array(harnessPluginDescriptorSchema).max(HARNESS_PLUGIN_LIMIT)
|
|
15766
|
-
}).strict();
|
|
15767
|
-
var harnessPluginConfigurationSchema = external_exports.object({
|
|
15768
|
-
version: external_exports.literal(1),
|
|
15769
|
-
enabled: external_exports.array(harnessPluginIdSchema).max(HARNESS_PLUGIN_LIMIT)
|
|
15770
|
-
}).strict().refine((value) => new Set(value.enabled).size === value.enabled.length, {
|
|
15771
|
-
message: "Enabled plugin IDs must be unique",
|
|
15772
|
-
path: ["enabled"]
|
|
15773
|
-
});
|
|
15774
|
-
|
|
15775
16194
|
// ../../shared-contracts/dist/harness-route.js
|
|
15776
16195
|
var harnessPluginRouteSchema = external_exports.object({
|
|
15777
16196
|
harnessId: harnessPluginIdSchema,
|
|
@@ -15796,14 +16215,17 @@ var harnessLaunchSettingsSchema = external_exports.object({
|
|
|
15796
16215
|
// ../../shared-contracts/dist/harness-installation.js
|
|
15797
16216
|
var harnessInstallationParamsSchema = external_exports.object({
|
|
15798
16217
|
harnessId: harnessIdSchema,
|
|
15799
|
-
action: external_exports.enum(["check", "update"])
|
|
16218
|
+
action: external_exports.enum(["check", "update", "install"])
|
|
15800
16219
|
}).strict();
|
|
15801
16220
|
var harnessInstallationStateSchema = external_exports.object({
|
|
15802
16221
|
currentVersion: external_exports.string().min(1).max(128),
|
|
15803
16222
|
latestVersion: external_exports.string().min(1).max(128),
|
|
15804
16223
|
updateAvailable: external_exports.boolean(),
|
|
15805
16224
|
canUpdate: external_exports.boolean(),
|
|
15806
|
-
|
|
16225
|
+
// Adapter-owned diagnostic text; UI uses messageCode rather than displaying it verbatim.
|
|
16226
|
+
message: external_exports.string().max(2048).optional(),
|
|
16227
|
+
messageCode: external_exports.string().min(1).max(128).optional(),
|
|
16228
|
+
latestVersionKind: external_exports.enum(["unknown", "tracking-branch"]).optional()
|
|
15807
16229
|
}).strict();
|
|
15808
16230
|
|
|
15809
16231
|
// ../../shared-contracts/dist/codex-accounts.js
|
|
@@ -16098,7 +16520,7 @@ var updateStatusSchema = external_exports.strictObject({
|
|
|
16098
16520
|
}
|
|
16099
16521
|
});
|
|
16100
16522
|
var updateEmptyParamsSchema = external_exports.strictObject({});
|
|
16101
|
-
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");
|
|
16523
|
+
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");
|
|
16102
16524
|
var updateCheckResultSchema = external_exports.strictObject({
|
|
16103
16525
|
currentVersion: updateSemanticVersionSchema,
|
|
16104
16526
|
installation: updateInstallationSchema.nullable(),
|
|
@@ -16112,1231 +16534,897 @@ var updateCheckResultSchema = external_exports.strictObject({
|
|
|
16112
16534
|
});
|
|
16113
16535
|
var updateStartResultSchema = external_exports.strictObject({
|
|
16114
16536
|
status: updateStatusSchema
|
|
16115
|
-
});
|
|
16116
|
-
var updateStatusResultSchema = external_exports.strictObject({
|
|
16117
|
-
status: updateStatusSchema.nullable()
|
|
16118
|
-
});
|
|
16119
|
-
|
|
16120
|
-
// ../../shared-contracts/dist/index.js
|
|
16121
|
-
var workspaceContractVersionSchema = external_exports.literal(WORKSPACE_CONTRACT_VERSION);
|
|
16122
|
-
|
|
16123
|
-
// ../../harness-adapter/dist/approval.js
|
|
16124
|
-
function invalidRequest(message3) {
|
|
16125
|
-
return { code: "invalidRequest", message: message3, retryable: false };
|
|
16126
|
-
}
|
|
16127
|
-
function validateHostApprovalResponse(interaction, response) {
|
|
16128
|
-
return interaction.actions.some(({ id }) => id === response.actionId) ? null : invalidRequest("Approval Response contains an undeclared action ID");
|
|
16129
|
-
}
|
|
16130
|
-
|
|
16131
|
-
// ../../harness-adapter/dist/question.js
|
|
16132
|
-
function invalidRequest2(message3) {
|
|
16133
|
-
return { code: "invalidRequest", message: message3, retryable: false };
|
|
16134
|
-
}
|
|
16135
|
-
function validateHostQuestionResponse(interaction, response) {
|
|
16136
|
-
const questionIds = new Set(interaction.questions.map(({ id }) => id));
|
|
16137
|
-
if (response.cancelled) {
|
|
16138
|
-
return Object.keys(response.answers).length === 0 ? null : invalidRequest2("Cancelled Question Response must not contain answers");
|
|
16139
|
-
}
|
|
16140
|
-
for (const answerId of Object.keys(response.answers)) {
|
|
16141
|
-
if (!questionIds.has(answerId)) {
|
|
16142
|
-
return invalidRequest2("Question Response contains an unknown Question ID");
|
|
16143
|
-
}
|
|
16144
|
-
}
|
|
16145
|
-
for (const question of interaction.questions) {
|
|
16146
|
-
const answers = response.answers[question.id] ?? [];
|
|
16147
|
-
if (!question.optional && answers.length === 0) {
|
|
16148
|
-
return invalidRequest2("Question Response omits a required answer");
|
|
16149
|
-
}
|
|
16150
|
-
if (question.type === "text") {
|
|
16151
|
-
if (answers.length > 1) {
|
|
16152
|
-
return invalidRequest2("Text Question accepts at most one answer");
|
|
16153
|
-
}
|
|
16154
|
-
continue;
|
|
16155
|
-
}
|
|
16156
|
-
if (!question.multiple && answers.length > 1) {
|
|
16157
|
-
return invalidRequest2("Single-choice Question accepts at most one answer");
|
|
16158
|
-
}
|
|
16159
|
-
const declared = new Set(question.options.map(({ value }) => value));
|
|
16160
|
-
if (!question.allowOther && answers.some((answer) => !declared.has(answer))) {
|
|
16161
|
-
return invalidRequest2("Question Response contains an undeclared choice");
|
|
16162
|
-
}
|
|
16163
|
-
}
|
|
16164
|
-
return null;
|
|
16165
|
-
}
|
|
16166
|
-
|
|
16167
|
-
// ../../harness-adapter/dist/output-channel.js
|
|
16168
|
-
var HarnessOutputChannel = class {
|
|
16169
|
-
outputs;
|
|
16170
|
-
#consumerCreated = false;
|
|
16171
|
-
#ended = false;
|
|
16172
|
-
#pending = [];
|
|
16173
|
-
#values = [];
|
|
16174
|
-
constructor() {
|
|
16175
|
-
this.outputs = {
|
|
16176
|
-
[Symbol.asyncIterator]: () => {
|
|
16177
|
-
if (this.#consumerCreated) {
|
|
16178
|
-
throw new Error("Harness outputs allow only one consumer");
|
|
16179
|
-
}
|
|
16180
|
-
this.#consumerCreated = true;
|
|
16181
|
-
return {
|
|
16182
|
-
next: () => this.#next()
|
|
16183
|
-
};
|
|
16184
|
-
}
|
|
16185
|
-
};
|
|
16186
|
-
}
|
|
16187
|
-
emit(value) {
|
|
16188
|
-
if (this.#ended)
|
|
16189
|
-
return false;
|
|
16190
|
-
const resolve = this.#pending.shift();
|
|
16191
|
-
if (resolve)
|
|
16192
|
-
resolve({ done: false, value });
|
|
16193
|
-
else
|
|
16194
|
-
this.#values.push(value);
|
|
16195
|
-
return true;
|
|
16196
|
-
}
|
|
16197
|
-
end() {
|
|
16198
|
-
if (this.#ended)
|
|
16199
|
-
return;
|
|
16200
|
-
this.#ended = true;
|
|
16201
|
-
if (this.#values.length !== 0)
|
|
16202
|
-
return;
|
|
16203
|
-
for (const resolve of this.#pending.splice(0))
|
|
16204
|
-
resolve({ done: true, value: void 0 });
|
|
16205
|
-
}
|
|
16206
|
-
#next() {
|
|
16207
|
-
const value = this.#values.shift();
|
|
16208
|
-
if (value !== void 0)
|
|
16209
|
-
return Promise.resolve({ done: false, value });
|
|
16210
|
-
if (this.#ended)
|
|
16211
|
-
return Promise.resolve({ done: true, value: void 0 });
|
|
16212
|
-
return new Promise((resolve) => this.#pending.push(resolve));
|
|
16213
|
-
}
|
|
16214
|
-
};
|
|
16215
|
-
|
|
16216
|
-
// ../../harness-adapter/dist/diagnostics.js
|
|
16217
|
-
var DIAGNOSTIC_TAIL_MAX_LENGTH = 8e3;
|
|
16218
|
-
var SENSITIVE_VALUE_PATTERN = /(api[_-]?key|access[_-]?token|auth(?:orization)?|password|secret)(\s*[:=]\s*)([^\s,;]+)/giu;
|
|
16219
|
-
var BEARER_PATTERN = /\bBearer\s+[A-Za-z0-9._~+/=-]+/giu;
|
|
16220
|
-
function sanitizeDiagnosticTail(value) {
|
|
16221
|
-
const redacted = value.replace(BEARER_PATTERN, "Bearer [redacted]").replace(SENSITIVE_VALUE_PATTERN, "$1$2[redacted]");
|
|
16222
|
-
return redacted.length <= DIAGNOSTIC_TAIL_MAX_LENGTH ? redacted : redacted.slice(-DIAGNOSTIC_TAIL_MAX_LENGTH);
|
|
16223
|
-
}
|
|
16224
|
-
|
|
16225
|
-
// ../../harness-adapter/dist/usage.js
|
|
16226
|
-
var tokenFields = [
|
|
16227
|
-
"inputTokens",
|
|
16228
|
-
"cachedInputTokens",
|
|
16229
|
-
"cacheWriteInputTokens",
|
|
16230
|
-
"outputTokens",
|
|
16231
|
-
"outputTokensPerSecond",
|
|
16232
|
-
"reasoningOutputTokens",
|
|
16233
|
-
"totalTokens",
|
|
16234
|
-
"contextWindowTokens",
|
|
16235
|
-
"contextUsedTokens"
|
|
16236
|
-
];
|
|
16237
|
-
var safeIntegerFields = [
|
|
16238
|
-
"planFiveHourResetsAtUnix",
|
|
16239
|
-
"planSevenDayResetsAtUnix"
|
|
16240
|
-
];
|
|
16241
|
-
var percentFields = [
|
|
16242
|
-
"cacheHitRatePercent",
|
|
16243
|
-
"planFiveHourUsedPercent",
|
|
16244
|
-
"planSevenDayUsedPercent"
|
|
16245
|
-
];
|
|
16246
|
-
var usageFields = /* @__PURE__ */ new Set([
|
|
16247
|
-
...tokenFields,
|
|
16248
|
-
...safeIntegerFields,
|
|
16249
|
-
...percentFields,
|
|
16250
|
-
"totalCostUsd",
|
|
16251
|
-
"totalCredits",
|
|
16252
|
-
"contextUsagePercent"
|
|
16253
|
-
]);
|
|
16254
|
-
function isRecord(value) {
|
|
16255
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
16256
|
-
}
|
|
16257
|
-
function parseHostUsage(value) {
|
|
16258
|
-
if (!isRecord(value))
|
|
16259
|
-
throw new Error("Harness Usage must be an object");
|
|
16260
|
-
const keys = Object.keys(value);
|
|
16261
|
-
if (keys.length === 0)
|
|
16262
|
-
throw new Error("Harness Usage must contain a reliable field");
|
|
16263
|
-
for (const key of keys) {
|
|
16264
|
-
if (!usageFields.has(key)) {
|
|
16265
|
-
throw new Error(`Harness Usage contains unknown field '${key}'`);
|
|
16266
|
-
}
|
|
16267
|
-
}
|
|
16268
|
-
for (const field of ["totalCredits", "contextUsagePercent"]) {
|
|
16269
|
-
const candidate = value[field];
|
|
16270
|
-
if (candidate !== void 0 && (typeof candidate !== "number" || !Number.isFinite(candidate) || candidate < 0)) {
|
|
16271
|
-
throw new Error(`Harness Usage '${field}' must be a finite non-negative number`);
|
|
16272
|
-
}
|
|
16273
|
-
}
|
|
16274
|
-
for (const field of tokenFields) {
|
|
16275
|
-
const candidate = value[field];
|
|
16276
|
-
if (candidate !== void 0 && (typeof candidate !== "number" || !Number.isSafeInteger(candidate) || candidate < 0)) {
|
|
16277
|
-
throw new Error(`Harness Usage '${field}' must be a non-negative safe integer`);
|
|
16278
|
-
}
|
|
16279
|
-
}
|
|
16280
|
-
for (const field of safeIntegerFields) {
|
|
16281
|
-
const candidate = value[field];
|
|
16282
|
-
if (candidate !== void 0 && (typeof candidate !== "number" || !Number.isSafeInteger(candidate) || candidate < 0)) {
|
|
16283
|
-
throw new Error(`Harness Usage '${field}' must be a non-negative safe integer`);
|
|
16284
|
-
}
|
|
16285
|
-
}
|
|
16286
|
-
if (value.outputTokensPerSecond !== void 0 && (typeof value.outputTokensPerSecond !== "number" || !Number.isFinite(value.outputTokensPerSecond) || value.outputTokensPerSecond < 0)) {
|
|
16287
|
-
throw new Error("Harness Usage 'outputTokensPerSecond' must be a finite non-negative number");
|
|
16288
|
-
}
|
|
16289
|
-
if (value.totalCostUsd !== void 0 && (typeof value.totalCostUsd !== "number" || !Number.isFinite(value.totalCostUsd) || value.totalCostUsd < 0)) {
|
|
16290
|
-
throw new Error("Harness Usage 'totalCostUsd' must be a finite non-negative number");
|
|
16291
|
-
}
|
|
16292
|
-
for (const field of ["totalCredits", "contextUsagePercent"]) {
|
|
16293
|
-
const candidate = value[field];
|
|
16294
|
-
if (candidate !== void 0 && (typeof candidate !== "number" || !Number.isFinite(candidate) || candidate < 0)) {
|
|
16295
|
-
throw new Error(`Harness Usage '${field}' must be a finite non-negative number`);
|
|
16296
|
-
}
|
|
16297
|
-
}
|
|
16298
|
-
for (const field of percentFields) {
|
|
16299
|
-
const candidate = value[field];
|
|
16300
|
-
if (candidate !== void 0 && (typeof candidate !== "number" || !Number.isFinite(candidate) || candidate < 0 || candidate > 100)) {
|
|
16301
|
-
throw new Error(`Harness Usage '${field}' must be between 0 and 100`);
|
|
16302
|
-
}
|
|
16303
|
-
}
|
|
16304
|
-
const hasContextUsed = value.contextUsedTokens !== void 0;
|
|
16305
|
-
const hasContextWindow = value.contextWindowTokens !== void 0;
|
|
16306
|
-
if (hasContextUsed !== hasContextWindow) {
|
|
16307
|
-
throw new Error("Harness Usage context fields must be provided together");
|
|
16308
|
-
}
|
|
16309
|
-
if (hasContextWindow && value.contextWindowTokens === 0) {
|
|
16310
|
-
throw new Error("Harness Usage 'contextWindowTokens' must be greater than zero");
|
|
16311
|
-
}
|
|
16312
|
-
if (value.planFiveHourResetsAtUnix !== void 0 && value.planFiveHourUsedPercent === void 0) {
|
|
16313
|
-
throw new Error("Harness Usage 'planFiveHourResetsAtUnix' must be provided with 'planFiveHourUsedPercent'");
|
|
16314
|
-
}
|
|
16315
|
-
if (value.planSevenDayResetsAtUnix !== void 0 && value.planSevenDayUsedPercent === void 0) {
|
|
16316
|
-
throw new Error("Harness Usage 'planSevenDayResetsAtUnix' must be provided with 'planSevenDayUsedPercent'");
|
|
16317
|
-
}
|
|
16318
|
-
return { ...value };
|
|
16319
|
-
}
|
|
16320
|
-
|
|
16321
|
-
// ../../harness-adapter/dist/live-command-catalog.js
|
|
16322
|
-
var COMMON_EXCLUDED_LIVE_COMMANDS = /* @__PURE__ */ new Set([
|
|
16323
|
-
// Session lifecycle
|
|
16324
|
-
"branch",
|
|
16325
|
-
"clear",
|
|
16326
|
-
"exit",
|
|
16327
|
-
"fork",
|
|
16328
|
-
"fresh",
|
|
16329
|
-
"new",
|
|
16330
|
-
"quit",
|
|
16331
|
-
"rename",
|
|
16332
|
-
"rename-chat",
|
|
16333
|
-
"reset",
|
|
16334
|
-
"resume",
|
|
16335
|
-
"rewind",
|
|
16336
|
-
"session",
|
|
16337
|
-
"sessions",
|
|
16338
|
-
// Desktop-owned configuration
|
|
16339
|
-
"autocompact",
|
|
16340
|
-
"color",
|
|
16341
|
-
"config",
|
|
16342
|
-
"effort",
|
|
16343
|
-
"fast",
|
|
16344
|
-
"keybindings",
|
|
16345
|
-
"model",
|
|
16346
|
-
"models",
|
|
16347
|
-
"output-style",
|
|
16348
|
-
"permissions",
|
|
16349
|
-
"settings",
|
|
16350
|
-
"statusline",
|
|
16351
|
-
"terminal-setup",
|
|
16352
|
-
"theme",
|
|
16353
|
-
"vim",
|
|
16354
|
-
// Trust and approval policy
|
|
16355
|
-
"always-approve",
|
|
16356
|
-
"auto-mode-setup",
|
|
16357
|
-
// Native login
|
|
16358
|
-
"login",
|
|
16359
|
-
"logout",
|
|
16360
|
-
// Work outliving the Turn
|
|
16361
|
-
"autopilot",
|
|
16362
|
-
"background",
|
|
16363
|
-
"bg",
|
|
16364
|
-
"goal",
|
|
16365
|
-
"jobs",
|
|
16366
|
-
"loop",
|
|
16367
|
-
"multitask",
|
|
16368
|
-
"queue",
|
|
16369
|
-
"remote-control",
|
|
16370
|
-
"schedule",
|
|
16371
|
-
"steer",
|
|
16372
|
-
// Native terminal UI
|
|
16373
|
-
"copy",
|
|
16374
|
-
"debug",
|
|
16375
|
-
"feedback",
|
|
16376
|
-
"heapdump",
|
|
16377
|
-
"share",
|
|
16378
|
-
"shell",
|
|
16379
|
-
// Plugin and MCP management
|
|
16380
|
-
"marketplace",
|
|
16381
|
-
"mcp",
|
|
16382
|
-
"plugins",
|
|
16383
|
-
"reload-plugins"
|
|
16384
|
-
]);
|
|
16385
|
-
var COMMON_EXCLUDED_LIVE_COMMAND_PREFIXES = ["__", "hooks-"];
|
|
16386
|
-
function isExcludedLiveCommand(name, kind, extra = {}) {
|
|
16387
|
-
const normalized = name.trim().replace(/^\//u, "");
|
|
16388
|
-
if (new Set(extra.names ?? []).has(normalized))
|
|
16389
|
-
return true;
|
|
16390
|
-
if (extra.prefixes?.some((prefix) => normalized.startsWith(prefix)))
|
|
16391
|
-
return true;
|
|
16392
|
-
if (kind === "skill")
|
|
16393
|
-
return false;
|
|
16394
|
-
return COMMON_EXCLUDED_LIVE_COMMANDS.has(normalized) || COMMON_EXCLUDED_LIVE_COMMAND_PREFIXES.some((prefix) => normalized.startsWith(prefix));
|
|
16395
|
-
}
|
|
16396
|
-
function liveHarnessCommandPrompt(catalog, idPrefix, commandId, argumentText) {
|
|
16397
|
-
if (!commandId.startsWith(idPrefix))
|
|
16398
|
-
return null;
|
|
16399
|
-
const descriptor = catalog.commands.find(({ id }) => id === commandId);
|
|
16400
|
-
if (!descriptor)
|
|
16401
|
-
return null;
|
|
16402
|
-
const text = typeof argumentText === "string" ? argumentText.trim() : "";
|
|
16403
|
-
return text ? `${descriptor.invocation} ${text}` : descriptor.invocation;
|
|
16404
|
-
}
|
|
16405
|
-
function mergeLiveHarnessCommands(builtIns, idPrefix, live, exclusions = {}) {
|
|
16406
|
-
if (!live)
|
|
16407
|
-
return builtIns;
|
|
16408
|
-
const invocations = new Set(builtIns.commands.map(({ invocation }) => invocation));
|
|
16409
|
-
const ids = new Set(builtIns.commands.map(({ id }) => id));
|
|
16410
|
-
const dynamic = [];
|
|
16411
|
-
for (const command of live) {
|
|
16412
|
-
const name = command.name.trim().replace(/^\//u, "");
|
|
16413
|
-
if (!name || /\s/u.test(name))
|
|
16414
|
-
continue;
|
|
16415
|
-
if (isExcludedLiveCommand(name, command.kind, exclusions))
|
|
16416
|
-
continue;
|
|
16417
|
-
const invocation = `/${name}`;
|
|
16418
|
-
const id = `${idPrefix}${name.replace(/[^A-Za-z0-9._:-]/gu, "-")}`.slice(0, 128);
|
|
16419
|
-
if (invocations.has(invocation) || ids.has(id))
|
|
16420
|
-
continue;
|
|
16421
|
-
const description = command.description?.trim().slice(0, 512);
|
|
16422
|
-
const parsed = harnessCommandDescriptorSchema.safeParse({
|
|
16423
|
-
id,
|
|
16424
|
-
invocation,
|
|
16425
|
-
label: name.slice(0, 128),
|
|
16426
|
-
...description ? { description } : {},
|
|
16427
|
-
argumentMode: "text",
|
|
16428
|
-
kind: command.kind
|
|
16429
|
-
});
|
|
16430
|
-
if (!parsed.success)
|
|
16431
|
-
continue;
|
|
16432
|
-
invocations.add(invocation);
|
|
16433
|
-
ids.add(id);
|
|
16434
|
-
dynamic.push(parsed.data);
|
|
16435
|
-
}
|
|
16436
|
-
return harnessCommandCatalogSchema.parse({ commands: [...builtIns.commands, ...dynamic] });
|
|
16437
|
-
}
|
|
16438
|
-
|
|
16439
|
-
// dist/omp-slash-commands.js
|
|
16440
|
-
var OMP_LIVE_COMMAND_ID_PREFIX = "omp.slash.";
|
|
16441
|
-
function isRecord2(value) {
|
|
16442
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
16443
|
-
}
|
|
16444
|
-
function parseOmpAvailableCommands(value) {
|
|
16445
|
-
if (!Array.isArray(value))
|
|
16446
|
-
return [];
|
|
16447
|
-
return value.flatMap((entry) => {
|
|
16448
|
-
if (!isRecord2(entry))
|
|
16449
|
-
return [];
|
|
16450
|
-
const name = typeof entry.name === "string" ? entry.name.trim().replace(/^\//u, "") : "";
|
|
16451
|
-
if (!name)
|
|
16452
|
-
return [];
|
|
16453
|
-
return [
|
|
16454
|
-
{
|
|
16455
|
-
name,
|
|
16456
|
-
description: typeof entry.description === "string" ? entry.description : "",
|
|
16457
|
-
source: typeof entry.source === "string" ? entry.source : null
|
|
16458
|
-
}
|
|
16459
|
-
];
|
|
16460
|
-
});
|
|
16461
|
-
}
|
|
16462
|
-
function ompLiveCommands(native) {
|
|
16463
|
-
return native.filter(({ source }) => source !== "builtin").map((command) => ({
|
|
16464
|
-
name: command.name,
|
|
16465
|
-
description: command.description,
|
|
16466
|
-
kind: command.source === "skill" ? "skill" : "command"
|
|
16467
|
-
}));
|
|
16468
|
-
}
|
|
16469
|
-
|
|
16470
|
-
// dist/omp-model-catalog.js
|
|
16471
|
-
var OMP_MODEL_REF_PREFIX = "omp-model-v1.";
|
|
16472
|
-
var OMP_DRAFT_THINKING_OPTION_IDS = [
|
|
16473
|
-
"off",
|
|
16474
|
-
"minimal",
|
|
16475
|
-
"low",
|
|
16476
|
-
"medium",
|
|
16477
|
-
"high",
|
|
16478
|
-
"xhigh",
|
|
16479
|
-
"max"
|
|
16480
|
-
].map((id) => harnessThinkingOptionIdSchema.parse(id));
|
|
16481
|
-
var OMP_THINKING_LABELS = {
|
|
16482
|
-
off: "Off",
|
|
16483
|
-
minimal: "Minimal",
|
|
16484
|
-
low: "Low",
|
|
16485
|
-
medium: "Medium",
|
|
16486
|
-
high: "High",
|
|
16487
|
-
xhigh: "Extra High",
|
|
16488
|
-
max: "Max"
|
|
16489
|
-
};
|
|
16490
|
-
function compareText(left, right) {
|
|
16491
|
-
return left < right ? -1 : left > right ? 1 : 0;
|
|
16492
|
-
}
|
|
16493
|
-
function assertNativePart(value, name) {
|
|
16494
|
-
if (value.trim().length === 0)
|
|
16495
|
-
throw new Error(`Omp ${name} must not be empty`);
|
|
16496
|
-
}
|
|
16497
|
-
function encodeOmpModelRef(model) {
|
|
16498
|
-
assertNativePart(model.provider, "Model provider");
|
|
16499
|
-
assertNativePart(model.id, "Model id");
|
|
16500
|
-
const encoded = Buffer.from(JSON.stringify([model.provider, model.id]), "utf8").toString("base64url");
|
|
16501
|
-
return harnessModelRefSchema.parse({ id: `${OMP_MODEL_REF_PREFIX}${encoded}` });
|
|
16502
|
-
}
|
|
16503
|
-
function decodeOmpModelRef(ref) {
|
|
16504
|
-
const parsedRef = harnessModelRefSchema.parse(ref);
|
|
16505
|
-
if (!parsedRef.id.startsWith(OMP_MODEL_REF_PREFIX)) {
|
|
16506
|
-
throw new Error("Model Ref does not belong to OmpAdapter");
|
|
16507
|
-
}
|
|
16508
|
-
const encoded = parsedRef.id.slice(OMP_MODEL_REF_PREFIX.length);
|
|
16509
|
-
let decoded;
|
|
16510
|
-
try {
|
|
16511
|
-
decoded = JSON.parse(Buffer.from(encoded, "base64url").toString("utf8"));
|
|
16512
|
-
} catch {
|
|
16513
|
-
throw new Error("Omp Model Ref is malformed");
|
|
16514
|
-
}
|
|
16515
|
-
if (!Array.isArray(decoded) || decoded.length !== 2 || typeof decoded[0] !== "string" || typeof decoded[1] !== "string") {
|
|
16516
|
-
throw new Error("Omp Model Ref has an invalid native identity");
|
|
16517
|
-
}
|
|
16518
|
-
const native = { provider: decoded[0], id: decoded[1] };
|
|
16519
|
-
assertNativePart(native.provider, "Model provider");
|
|
16520
|
-
assertNativePart(native.id, "Model id");
|
|
16521
|
-
if (encodeOmpModelRef(native).id !== parsedRef.id) {
|
|
16522
|
-
throw new Error("Omp Model Ref is not canonical");
|
|
16523
|
-
}
|
|
16524
|
-
return native;
|
|
16525
|
-
}
|
|
16526
|
-
function sameOmpModel(left, right) {
|
|
16527
|
-
return left === null ? right === null : right !== null && left.provider === right.provider && left.id === right.id;
|
|
16537
|
+
});
|
|
16538
|
+
var updateStatusResultSchema = external_exports.strictObject({
|
|
16539
|
+
status: updateStatusSchema.nullable()
|
|
16540
|
+
});
|
|
16541
|
+
|
|
16542
|
+
// ../../shared-contracts/dist/index.js
|
|
16543
|
+
var workspaceContractVersionSchema = external_exports.literal(WORKSPACE_CONTRACT_VERSION);
|
|
16544
|
+
|
|
16545
|
+
// ../../harness-adapter/dist/approval.js
|
|
16546
|
+
function invalidRequest(message3) {
|
|
16547
|
+
return { code: "invalidRequest", message: message3, retryable: false };
|
|
16528
16548
|
}
|
|
16529
|
-
function
|
|
16530
|
-
|
|
16531
|
-
return label || id;
|
|
16549
|
+
function validateHostApprovalResponse(interaction, response) {
|
|
16550
|
+
return interaction.actions.some(({ id }) => id === response.actionId) ? null : invalidRequest("Approval Response contains an undeclared action ID");
|
|
16532
16551
|
}
|
|
16533
|
-
|
|
16534
|
-
|
|
16535
|
-
|
|
16536
|
-
|
|
16537
|
-
}));
|
|
16552
|
+
|
|
16553
|
+
// ../../harness-adapter/dist/question.js
|
|
16554
|
+
function invalidRequest2(message3) {
|
|
16555
|
+
return { code: "invalidRequest", message: message3, retryable: false };
|
|
16538
16556
|
}
|
|
16539
|
-
function
|
|
16540
|
-
const
|
|
16541
|
-
|
|
16542
|
-
|
|
16543
|
-
|
|
16544
|
-
|
|
16545
|
-
|
|
16546
|
-
|
|
16557
|
+
function validateHostQuestionResponse(interaction, response) {
|
|
16558
|
+
const questionIds = new Set(interaction.questions.map(({ id }) => id));
|
|
16559
|
+
if (response.cancelled) {
|
|
16560
|
+
return Object.keys(response.answers).length === 0 ? null : invalidRequest2("Cancelled Question Response must not contain answers");
|
|
16561
|
+
}
|
|
16562
|
+
for (const answerId of Object.keys(response.answers)) {
|
|
16563
|
+
if (!questionIds.has(answerId)) {
|
|
16564
|
+
return invalidRequest2("Question Response contains an unknown Question ID");
|
|
16565
|
+
}
|
|
16566
|
+
}
|
|
16567
|
+
for (const question of interaction.questions) {
|
|
16568
|
+
const answers = response.answers[question.id] ?? [];
|
|
16569
|
+
if (!question.optional && answers.length === 0) {
|
|
16570
|
+
return invalidRequest2("Question Response omits a required answer");
|
|
16571
|
+
}
|
|
16572
|
+
if (question.type === "text") {
|
|
16573
|
+
if (answers.length > 1) {
|
|
16574
|
+
return invalidRequest2("Text Question accepts at most one answer");
|
|
16547
16575
|
}
|
|
16548
16576
|
continue;
|
|
16549
16577
|
}
|
|
16550
|
-
|
|
16551
|
-
|
|
16552
|
-
|
|
16553
|
-
|
|
16554
|
-
|
|
16555
|
-
|
|
16556
|
-
}
|
|
16578
|
+
if (!question.multiple && answers.length > 1) {
|
|
16579
|
+
return invalidRequest2("Single-choice Question accepts at most one answer");
|
|
16580
|
+
}
|
|
16581
|
+
const declared = new Set(question.options.map(({ value }) => value));
|
|
16582
|
+
if (!question.allowOther && answers.some((answer) => !declared.has(answer))) {
|
|
16583
|
+
return invalidRequest2("Question Response contains an undeclared choice");
|
|
16584
|
+
}
|
|
16557
16585
|
}
|
|
16558
|
-
|
|
16559
|
-
|
|
16560
|
-
|
|
16586
|
+
return null;
|
|
16587
|
+
}
|
|
16588
|
+
|
|
16589
|
+
// ../../harness-adapter/dist/output-channel.js
|
|
16590
|
+
var HarnessOutputChannel = class {
|
|
16591
|
+
outputs;
|
|
16592
|
+
#consumerCreated = false;
|
|
16593
|
+
#ended = false;
|
|
16594
|
+
#pending = [];
|
|
16595
|
+
#values = [];
|
|
16596
|
+
constructor() {
|
|
16597
|
+
this.outputs = {
|
|
16598
|
+
[Symbol.asyncIterator]: () => {
|
|
16599
|
+
if (this.#consumerCreated) {
|
|
16600
|
+
throw new Error("Harness outputs allow only one consumer");
|
|
16601
|
+
}
|
|
16602
|
+
this.#consumerCreated = true;
|
|
16603
|
+
return {
|
|
16604
|
+
next: () => this.#next()
|
|
16605
|
+
};
|
|
16606
|
+
}
|
|
16607
|
+
};
|
|
16561
16608
|
}
|
|
16562
|
-
|
|
16563
|
-
|
|
16609
|
+
emit(value) {
|
|
16610
|
+
if (this.#ended)
|
|
16611
|
+
return false;
|
|
16612
|
+
const resolve = this.#pending.shift();
|
|
16613
|
+
if (resolve)
|
|
16614
|
+
resolve({ done: false, value });
|
|
16615
|
+
else
|
|
16616
|
+
this.#values.push(value);
|
|
16617
|
+
return true;
|
|
16564
16618
|
}
|
|
16565
|
-
|
|
16566
|
-
|
|
16619
|
+
end() {
|
|
16620
|
+
if (this.#ended)
|
|
16621
|
+
return;
|
|
16622
|
+
this.#ended = true;
|
|
16623
|
+
if (this.#values.length !== 0)
|
|
16624
|
+
return;
|
|
16625
|
+
for (const resolve of this.#pending.splice(0))
|
|
16626
|
+
resolve({ done: true, value: void 0 });
|
|
16567
16627
|
}
|
|
16568
|
-
|
|
16569
|
-
|
|
16570
|
-
|
|
16571
|
-
|
|
16572
|
-
|
|
16573
|
-
|
|
16574
|
-
|
|
16575
|
-
const defaultThinkingOptionId = thinkingOptions.find(({ id }) => id === effectiveThinkingOptionId)?.id;
|
|
16576
|
-
return harnessModelCatalogSchema.parse({
|
|
16577
|
-
models,
|
|
16578
|
-
...defaultModel ? { defaultModel } : {},
|
|
16579
|
-
thinkingOptions,
|
|
16580
|
-
...defaultThinkingOptionId ? { defaultThinkingOptionId } : {}
|
|
16581
|
-
});
|
|
16582
|
-
}
|
|
16583
|
-
|
|
16584
|
-
// dist/omp-tool-presentation.js
|
|
16585
|
-
function isRecord3(value) {
|
|
16586
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
16587
|
-
}
|
|
16588
|
-
function stringField(value, key) {
|
|
16589
|
-
return isRecord3(value) && typeof value[key] === "string" ? value[key] : void 0;
|
|
16590
|
-
}
|
|
16591
|
-
function toolCommand(toolName, argumentsValue) {
|
|
16592
|
-
if (toolName === "bash") {
|
|
16593
|
-
const command = stringField(argumentsValue, "command");
|
|
16594
|
-
if (command)
|
|
16595
|
-
return command;
|
|
16628
|
+
#next() {
|
|
16629
|
+
const value = this.#values.shift();
|
|
16630
|
+
if (value !== void 0)
|
|
16631
|
+
return Promise.resolve({ done: false, value });
|
|
16632
|
+
if (this.#ended)
|
|
16633
|
+
return Promise.resolve({ done: true, value: void 0 });
|
|
16634
|
+
return new Promise((resolve) => this.#pending.push(resolve));
|
|
16596
16635
|
}
|
|
16597
|
-
|
|
16598
|
-
|
|
16599
|
-
|
|
16600
|
-
|
|
16601
|
-
|
|
16602
|
-
|
|
16603
|
-
|
|
16604
|
-
|
|
16605
|
-
|
|
16606
|
-
};
|
|
16636
|
+
};
|
|
16637
|
+
|
|
16638
|
+
// ../../harness-adapter/dist/diagnostics.js
|
|
16639
|
+
var DIAGNOSTIC_TAIL_MAX_LENGTH = 8e3;
|
|
16640
|
+
var SENSITIVE_VALUE_PATTERN = /(api[_-]?key|access[_-]?token|auth(?:orization)?|password|secret)(\s*[:=]\s*)([^\s,;]+)/giu;
|
|
16641
|
+
var BEARER_PATTERN = /\bBearer\s+[A-Za-z0-9._~+/=-]+/giu;
|
|
16642
|
+
function sanitizeDiagnosticTail(value) {
|
|
16643
|
+
const redacted = value.replace(BEARER_PATTERN, "Bearer [redacted]").replace(SENSITIVE_VALUE_PATTERN, "$1$2[redacted]");
|
|
16644
|
+
return redacted.length <= DIAGNOSTIC_TAIL_MAX_LENGTH ? redacted : redacted.slice(-DIAGNOSTIC_TAIL_MAX_LENGTH);
|
|
16607
16645
|
}
|
|
16608
16646
|
|
|
16609
|
-
// dist/
|
|
16610
|
-
var
|
|
16611
|
-
|
|
16647
|
+
// ../../harness-adapter/dist/usage.js
|
|
16648
|
+
var tokenFields = [
|
|
16649
|
+
"inputTokens",
|
|
16650
|
+
"cachedInputTokens",
|
|
16651
|
+
"cacheWriteInputTokens",
|
|
16652
|
+
"outputTokens",
|
|
16653
|
+
"outputTokensPerSecond",
|
|
16654
|
+
"reasoningOutputTokens",
|
|
16655
|
+
"totalTokens",
|
|
16656
|
+
"contextWindowTokens",
|
|
16657
|
+
"contextUsedTokens"
|
|
16658
|
+
];
|
|
16659
|
+
var safeIntegerFields = [
|
|
16660
|
+
"planFiveHourResetsAtUnix",
|
|
16661
|
+
"planSevenDayResetsAtUnix"
|
|
16662
|
+
];
|
|
16663
|
+
var percentFields = [
|
|
16664
|
+
"cacheHitRatePercent",
|
|
16665
|
+
"planFiveHourUsedPercent",
|
|
16666
|
+
"planSevenDayUsedPercent"
|
|
16667
|
+
];
|
|
16668
|
+
var usageFields = /* @__PURE__ */ new Set([
|
|
16669
|
+
...tokenFields,
|
|
16670
|
+
...safeIntegerFields,
|
|
16671
|
+
...percentFields,
|
|
16672
|
+
"totalCostUsd",
|
|
16673
|
+
"totalCredits",
|
|
16674
|
+
"contextUsagePercent"
|
|
16675
|
+
]);
|
|
16676
|
+
function isRecord(value) {
|
|
16612
16677
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
16613
16678
|
}
|
|
16614
|
-
function
|
|
16615
|
-
if (
|
|
16616
|
-
|
|
16617
|
-
|
|
16618
|
-
|
|
16619
|
-
|
|
16620
|
-
|
|
16621
|
-
|
|
16622
|
-
|
|
16623
|
-
|
|
16624
|
-
return value.filter((part) => isRecord4(part) && part.type === "thinking" && typeof part.thinking === "string").map((part) => part.thinking).join("");
|
|
16625
|
-
}
|
|
16626
|
-
function validatedEntry(value) {
|
|
16627
|
-
if (typeof value.id !== "string" || value.id.length === 0 || value.parentId !== null && typeof value.parentId !== "string" || typeof value.type !== "string") {
|
|
16628
|
-
throw new Error("Omp history contains an invalid Entry identity");
|
|
16629
|
-
}
|
|
16630
|
-
return value;
|
|
16631
|
-
}
|
|
16632
|
-
function activeOmpEntries(history) {
|
|
16633
|
-
if (history.leafId === null)
|
|
16634
|
-
return [];
|
|
16635
|
-
const byId = new Map(history.entries.map((value) => {
|
|
16636
|
-
const entry = validatedEntry(value);
|
|
16637
|
-
return [entry.id, entry];
|
|
16638
|
-
}));
|
|
16639
|
-
const reversed = [];
|
|
16640
|
-
const visited = /* @__PURE__ */ new Set();
|
|
16641
|
-
let current = history.leafId;
|
|
16642
|
-
while (current !== null) {
|
|
16643
|
-
if (visited.has(current))
|
|
16644
|
-
throw new Error("Omp history active branch contains a cycle");
|
|
16645
|
-
visited.add(current);
|
|
16646
|
-
const entry = byId.get(current);
|
|
16647
|
-
if (!entry)
|
|
16648
|
-
throw new Error("Omp history active branch references a missing Entry");
|
|
16649
|
-
reversed.push(entry);
|
|
16650
|
-
current = entry.parentId;
|
|
16651
|
-
}
|
|
16652
|
-
return reversed.reverse();
|
|
16653
|
-
}
|
|
16654
|
-
function message(entry) {
|
|
16655
|
-
return entry.type === "message" && isRecord4(entry.message) ? entry.message : null;
|
|
16656
|
-
}
|
|
16657
|
-
function messageRole(entry) {
|
|
16658
|
-
const value = message(entry)?.role;
|
|
16659
|
-
return typeof value === "string" ? value : null;
|
|
16660
|
-
}
|
|
16661
|
-
function itemId(entryId, kind, ordinal) {
|
|
16662
|
-
return hostItemIdSchema.parse(`omp-item-v1-${entryId}-${kind}-${ordinal}`);
|
|
16663
|
-
}
|
|
16664
|
-
function assistantOutcome(entries) {
|
|
16665
|
-
const assistants = entries.map((entry) => message(entry)).filter((value) => value?.role === "assistant");
|
|
16666
|
-
const final = assistants.at(-1);
|
|
16667
|
-
if (!final)
|
|
16668
|
-
return { status: "unknown", reason: "Omp history has no Assistant terminal" };
|
|
16669
|
-
const stopReason = final.stopReason;
|
|
16670
|
-
if (stopReason === "aborted") {
|
|
16671
|
-
return { status: "cancelled", reason: "Omp Assistant was aborted" };
|
|
16679
|
+
function parseHostUsage(value) {
|
|
16680
|
+
if (!isRecord(value))
|
|
16681
|
+
throw new Error("Harness Usage must be an object");
|
|
16682
|
+
const keys = Object.keys(value);
|
|
16683
|
+
if (keys.length === 0)
|
|
16684
|
+
throw new Error("Harness Usage must contain a reliable field");
|
|
16685
|
+
for (const key of keys) {
|
|
16686
|
+
if (!usageFields.has(key)) {
|
|
16687
|
+
throw new Error(`Harness Usage contains unknown field '${key}'`);
|
|
16688
|
+
}
|
|
16672
16689
|
}
|
|
16673
|
-
|
|
16674
|
-
|
|
16675
|
-
|
|
16676
|
-
|
|
16677
|
-
|
|
16678
|
-
message: typeof final.errorMessage === "string" && final.errorMessage.length > 0 ? final.errorMessage : "Omp Assistant failed",
|
|
16679
|
-
retryable: false
|
|
16680
|
-
}
|
|
16681
|
-
};
|
|
16690
|
+
for (const field of ["totalCredits", "contextUsagePercent"]) {
|
|
16691
|
+
const candidate = value[field];
|
|
16692
|
+
if (candidate !== void 0 && (typeof candidate !== "number" || !Number.isFinite(candidate) || candidate < 0)) {
|
|
16693
|
+
throw new Error(`Harness Usage '${field}' must be a finite non-negative number`);
|
|
16694
|
+
}
|
|
16682
16695
|
}
|
|
16683
|
-
|
|
16684
|
-
|
|
16696
|
+
for (const field of tokenFields) {
|
|
16697
|
+
const candidate = value[field];
|
|
16698
|
+
if (candidate !== void 0 && (typeof candidate !== "number" || !Number.isSafeInteger(candidate) || candidate < 0)) {
|
|
16699
|
+
throw new Error(`Harness Usage '${field}' must be a non-negative safe integer`);
|
|
16700
|
+
}
|
|
16685
16701
|
}
|
|
16686
|
-
|
|
16687
|
-
|
|
16688
|
-
|
|
16689
|
-
|
|
16690
|
-
|
|
16691
|
-
if (outcome.status === "cancelled") {
|
|
16692
|
-
return {
|
|
16693
|
-
status: "cancelled",
|
|
16694
|
-
...outcome.reason ? { reason: outcome.reason } : {}
|
|
16695
|
-
};
|
|
16702
|
+
for (const field of safeIntegerFields) {
|
|
16703
|
+
const candidate = value[field];
|
|
16704
|
+
if (candidate !== void 0 && (typeof candidate !== "number" || !Number.isSafeInteger(candidate) || candidate < 0)) {
|
|
16705
|
+
throw new Error(`Harness Usage '${field}' must be a non-negative safe integer`);
|
|
16706
|
+
}
|
|
16696
16707
|
}
|
|
16697
|
-
|
|
16698
|
-
|
|
16699
|
-
|
|
16700
|
-
|
|
16701
|
-
|
|
16702
|
-
}
|
|
16703
|
-
|
|
16704
|
-
|
|
16705
|
-
|
|
16706
|
-
|
|
16707
|
-
const nativeMessage = message(entry);
|
|
16708
|
-
if (!nativeMessage)
|
|
16709
|
-
continue;
|
|
16710
|
-
const content = Array.isArray(nativeMessage.content) ? nativeMessage.content : [];
|
|
16711
|
-
if (nativeMessage.role === "assistant") {
|
|
16712
|
-
const text = textContent(content);
|
|
16713
|
-
const reasoning = thinkingContent(content);
|
|
16714
|
-
let projectedText = false;
|
|
16715
|
-
let projectedReasoning = false;
|
|
16716
|
-
for (const [ordinal, part] of content.entries()) {
|
|
16717
|
-
if (!isRecord4(part))
|
|
16718
|
-
continue;
|
|
16719
|
-
if (part.type === "thinking" && !projectedReasoning && reasoning.length > 0) {
|
|
16720
|
-
const item2 = {
|
|
16721
|
-
type: "reasoning",
|
|
16722
|
-
itemId: itemId(entry.id, "reasoning", 0),
|
|
16723
|
-
text: reasoning
|
|
16724
|
-
};
|
|
16725
|
-
snapshots.push({ item: item2, outcome: itemOutcome(outcome) });
|
|
16726
|
-
projectedReasoning = true;
|
|
16727
|
-
continue;
|
|
16728
|
-
}
|
|
16729
|
-
if (part.type === "text" && !projectedText && text.length > 0) {
|
|
16730
|
-
const item2 = {
|
|
16731
|
-
type: "agentMessage",
|
|
16732
|
-
itemId: itemId(entry.id, "assistant", 0),
|
|
16733
|
-
text
|
|
16734
|
-
};
|
|
16735
|
-
snapshots.push({ item: item2, outcome: itemOutcome(outcome) });
|
|
16736
|
-
projectedText = true;
|
|
16737
|
-
continue;
|
|
16738
|
-
}
|
|
16739
|
-
if (part.type !== "toolCall" || typeof part.id !== "string" || typeof part.name !== "string") {
|
|
16740
|
-
continue;
|
|
16741
|
-
}
|
|
16742
|
-
const parsedArguments = jsonValueSchema.safeParse(part.arguments);
|
|
16743
|
-
if (!parsedArguments.success)
|
|
16744
|
-
continue;
|
|
16745
|
-
toolCalls.set(part.id, {
|
|
16746
|
-
entryId: entry.id,
|
|
16747
|
-
ordinal,
|
|
16748
|
-
name: part.name,
|
|
16749
|
-
arguments: parsedArguments.data
|
|
16750
|
-
});
|
|
16751
|
-
}
|
|
16752
|
-
continue;
|
|
16708
|
+
if (value.outputTokensPerSecond !== void 0 && (typeof value.outputTokensPerSecond !== "number" || !Number.isFinite(value.outputTokensPerSecond) || value.outputTokensPerSecond < 0)) {
|
|
16709
|
+
throw new Error("Harness Usage 'outputTokensPerSecond' must be a finite non-negative number");
|
|
16710
|
+
}
|
|
16711
|
+
if (value.totalCostUsd !== void 0 && (typeof value.totalCostUsd !== "number" || !Number.isFinite(value.totalCostUsd) || value.totalCostUsd < 0)) {
|
|
16712
|
+
throw new Error("Harness Usage 'totalCostUsd' must be a finite non-negative number");
|
|
16713
|
+
}
|
|
16714
|
+
for (const field of ["totalCredits", "contextUsagePercent"]) {
|
|
16715
|
+
const candidate = value[field];
|
|
16716
|
+
if (candidate !== void 0 && (typeof candidate !== "number" || !Number.isFinite(candidate) || candidate < 0)) {
|
|
16717
|
+
throw new Error(`Harness Usage '${field}' must be a finite non-negative number`);
|
|
16753
16718
|
}
|
|
16754
|
-
|
|
16755
|
-
|
|
16719
|
+
}
|
|
16720
|
+
for (const field of percentFields) {
|
|
16721
|
+
const candidate = value[field];
|
|
16722
|
+
if (candidate !== void 0 && (typeof candidate !== "number" || !Number.isFinite(candidate) || candidate < 0 || candidate > 100)) {
|
|
16723
|
+
throw new Error(`Harness Usage '${field}' must be between 0 and 100`);
|
|
16756
16724
|
}
|
|
16757
|
-
const call = toolCalls.get(nativeMessage.toolCallId);
|
|
16758
|
-
if (!call || call.name !== nativeMessage.toolName)
|
|
16759
|
-
continue;
|
|
16760
|
-
const output = toolOutput(nativeMessage.content);
|
|
16761
|
-
const item = {
|
|
16762
|
-
...projectOmpToolItem({
|
|
16763
|
-
itemId: itemId(call.entryId, "tool", call.ordinal),
|
|
16764
|
-
toolName: call.name,
|
|
16765
|
-
arguments: call.arguments
|
|
16766
|
-
}),
|
|
16767
|
-
...output ? { output: textContent(output.content) } : {}
|
|
16768
|
-
};
|
|
16769
|
-
const toolFailed = nativeMessage.isError === true;
|
|
16770
|
-
snapshots.push({
|
|
16771
|
-
item,
|
|
16772
|
-
outcome: toolFailed ? {
|
|
16773
|
-
status: "failed",
|
|
16774
|
-
error: {
|
|
16775
|
-
code: "nativeFailure",
|
|
16776
|
-
message: `Omp Tool '${call.name}' failed`,
|
|
16777
|
-
retryable: false
|
|
16778
|
-
}
|
|
16779
|
-
} : { status: "succeeded" }
|
|
16780
|
-
});
|
|
16781
16725
|
}
|
|
16782
|
-
|
|
16726
|
+
const hasContextUsed = value.contextUsedTokens !== void 0;
|
|
16727
|
+
const hasContextWindow = value.contextWindowTokens !== void 0;
|
|
16728
|
+
if (hasContextUsed !== hasContextWindow) {
|
|
16729
|
+
throw new Error("Harness Usage context fields must be provided together");
|
|
16730
|
+
}
|
|
16731
|
+
if (hasContextWindow && value.contextWindowTokens === 0) {
|
|
16732
|
+
throw new Error("Harness Usage 'contextWindowTokens' must be greater than zero");
|
|
16733
|
+
}
|
|
16734
|
+
if (value.planFiveHourResetsAtUnix !== void 0 && value.planFiveHourUsedPercent === void 0) {
|
|
16735
|
+
throw new Error("Harness Usage 'planFiveHourResetsAtUnix' must be provided with 'planFiveHourUsedPercent'");
|
|
16736
|
+
}
|
|
16737
|
+
if (value.planSevenDayResetsAtUnix !== void 0 && value.planSevenDayUsedPercent === void 0) {
|
|
16738
|
+
throw new Error("Harness Usage 'planSevenDayResetsAtUnix' must be provided with 'planSevenDayUsedPercent'");
|
|
16739
|
+
}
|
|
16740
|
+
return { ...value };
|
|
16783
16741
|
}
|
|
16784
|
-
|
|
16785
|
-
|
|
16742
|
+
|
|
16743
|
+
// ../../harness-adapter/dist/live-command-catalog.js
|
|
16744
|
+
var COMMON_EXCLUDED_LIVE_COMMANDS = /* @__PURE__ */ new Set([
|
|
16745
|
+
// Session lifecycle
|
|
16746
|
+
"branch",
|
|
16747
|
+
"clear",
|
|
16748
|
+
"exit",
|
|
16749
|
+
"fork",
|
|
16750
|
+
"fresh",
|
|
16751
|
+
"new",
|
|
16752
|
+
"quit",
|
|
16753
|
+
"rename",
|
|
16754
|
+
"rename-chat",
|
|
16755
|
+
"reset",
|
|
16756
|
+
"resume",
|
|
16757
|
+
"rewind",
|
|
16758
|
+
"session",
|
|
16759
|
+
"sessions",
|
|
16760
|
+
// Desktop-owned configuration
|
|
16761
|
+
"autocompact",
|
|
16762
|
+
"color",
|
|
16763
|
+
"config",
|
|
16764
|
+
"effort",
|
|
16765
|
+
"fast",
|
|
16766
|
+
"keybindings",
|
|
16767
|
+
"model",
|
|
16768
|
+
"models",
|
|
16769
|
+
"output-style",
|
|
16770
|
+
"permissions",
|
|
16771
|
+
"settings",
|
|
16772
|
+
"statusline",
|
|
16773
|
+
"terminal-setup",
|
|
16774
|
+
"theme",
|
|
16775
|
+
"vim",
|
|
16776
|
+
// Trust and approval policy
|
|
16777
|
+
"always-approve",
|
|
16778
|
+
"auto-mode-setup",
|
|
16779
|
+
// Native login
|
|
16780
|
+
"login",
|
|
16781
|
+
"logout",
|
|
16782
|
+
// Work outliving the Turn
|
|
16783
|
+
"autopilot",
|
|
16784
|
+
"background",
|
|
16785
|
+
"bg",
|
|
16786
|
+
"goal",
|
|
16787
|
+
"jobs",
|
|
16788
|
+
"loop",
|
|
16789
|
+
"multitask",
|
|
16790
|
+
"queue",
|
|
16791
|
+
"remote-control",
|
|
16792
|
+
"schedule",
|
|
16793
|
+
"steer",
|
|
16794
|
+
// Native terminal UI
|
|
16795
|
+
"copy",
|
|
16796
|
+
"debug",
|
|
16797
|
+
"feedback",
|
|
16798
|
+
"heapdump",
|
|
16799
|
+
"share",
|
|
16800
|
+
"shell",
|
|
16801
|
+
// Plugin and MCP management
|
|
16802
|
+
"marketplace",
|
|
16803
|
+
"mcp",
|
|
16804
|
+
"plugins",
|
|
16805
|
+
"reload-plugins"
|
|
16806
|
+
]);
|
|
16807
|
+
var COMMON_EXCLUDED_LIVE_COMMAND_PREFIXES = ["__", "hooks-"];
|
|
16808
|
+
function isExcludedLiveCommand(name, kind, extra = {}) {
|
|
16809
|
+
const normalized = name.trim().replace(/^\//u, "");
|
|
16810
|
+
if (new Set(extra.names ?? []).has(normalized))
|
|
16811
|
+
return true;
|
|
16812
|
+
if (extra.prefixes?.some((prefix) => normalized.startsWith(prefix)))
|
|
16813
|
+
return true;
|
|
16814
|
+
if (kind === "skill")
|
|
16815
|
+
return false;
|
|
16816
|
+
return COMMON_EXCLUDED_LIVE_COMMANDS.has(normalized) || COMMON_EXCLUDED_LIVE_COMMAND_PREFIXES.some((prefix) => normalized.startsWith(prefix));
|
|
16786
16817
|
}
|
|
16787
|
-
function
|
|
16788
|
-
|
|
16789
|
-
|
|
16790
|
-
|
|
16791
|
-
|
|
16792
|
-
|
|
16793
|
-
|
|
16794
|
-
|
|
16795
|
-
|
|
16818
|
+
function liveHarnessCommandPrompt(catalog, idPrefix, commandId, argumentText) {
|
|
16819
|
+
if (!commandId.startsWith(idPrefix))
|
|
16820
|
+
return null;
|
|
16821
|
+
const descriptor = catalog.commands.find(({ id }) => id === commandId);
|
|
16822
|
+
if (!descriptor)
|
|
16823
|
+
return null;
|
|
16824
|
+
const text = typeof argumentText === "string" ? argumentText.trim() : "";
|
|
16825
|
+
return text ? `${descriptor.invocation} ${text}` : descriptor.invocation;
|
|
16826
|
+
}
|
|
16827
|
+
function mergeLiveHarnessCommands(builtIns, idPrefix, live, exclusions = {}) {
|
|
16828
|
+
if (!live)
|
|
16829
|
+
return builtIns;
|
|
16830
|
+
const invocations = new Set(builtIns.commands.map(({ invocation }) => invocation));
|
|
16831
|
+
const ids = new Set(builtIns.commands.map(({ id }) => id));
|
|
16832
|
+
const dynamic = [];
|
|
16833
|
+
for (const command of live) {
|
|
16834
|
+
const name = command.name.trim().replace(/^\//u, "");
|
|
16835
|
+
if (!name || /\s/u.test(name))
|
|
16796
16836
|
continue;
|
|
16797
|
-
|
|
16798
|
-
const user = active[index];
|
|
16799
|
-
if (messageRole(user) !== "user") {
|
|
16800
|
-
index += 1;
|
|
16837
|
+
if (isExcludedLiveCommand(name, command.kind, exclusions))
|
|
16801
16838
|
continue;
|
|
16802
|
-
}
|
|
16803
|
-
|
|
16804
|
-
|
|
16805
|
-
|
|
16806
|
-
const
|
|
16807
|
-
const
|
|
16808
|
-
|
|
16809
|
-
|
|
16810
|
-
|
|
16811
|
-
|
|
16812
|
-
|
|
16813
|
-
|
|
16814
|
-
});
|
|
16815
|
-
const checkpoint = nativeCheckpointRefSchema.parse({
|
|
16816
|
-
harnessId: ompHarnessId,
|
|
16817
|
-
nativeSessionId: state.sessionId,
|
|
16818
|
-
checkpointId: user.id,
|
|
16819
|
-
formatVersion: 1
|
|
16820
|
-
});
|
|
16821
|
-
turns.push({
|
|
16822
|
-
nativeTurnRef,
|
|
16823
|
-
checkpoint,
|
|
16824
|
-
input: [{ type: "text", text: userText }],
|
|
16825
|
-
items: snapshotItems(entries, outcome),
|
|
16826
|
-
outcome,
|
|
16827
|
-
...effectiveModel ? { model: encodeOmpModelRef(effectiveModel) } : {}
|
|
16839
|
+
const invocation = `/${name}`;
|
|
16840
|
+
const id = `${idPrefix}${name.replace(/[^A-Za-z0-9._:-]/gu, "-")}`.slice(0, 128);
|
|
16841
|
+
if (invocations.has(invocation) || ids.has(id))
|
|
16842
|
+
continue;
|
|
16843
|
+
const description = command.description?.trim().slice(0, 512);
|
|
16844
|
+
const parsed = harnessCommandDescriptorSchema.safeParse({
|
|
16845
|
+
id,
|
|
16846
|
+
invocation,
|
|
16847
|
+
label: name.slice(0, 128),
|
|
16848
|
+
...description ? { description } : {},
|
|
16849
|
+
argumentMode: "text",
|
|
16850
|
+
kind: command.kind
|
|
16828
16851
|
});
|
|
16829
|
-
|
|
16830
|
-
|
|
16831
|
-
|
|
16832
|
-
|
|
16833
|
-
|
|
16834
|
-
index = end;
|
|
16852
|
+
if (!parsed.success)
|
|
16853
|
+
continue;
|
|
16854
|
+
invocations.add(invocation);
|
|
16855
|
+
ids.add(id);
|
|
16856
|
+
dynamic.push(parsed.data);
|
|
16835
16857
|
}
|
|
16836
|
-
return {
|
|
16858
|
+
return harnessCommandCatalogSchema.parse({ commands: [...builtIns.commands, ...dynamic] });
|
|
16837
16859
|
}
|
|
16838
|
-
|
|
16839
|
-
|
|
16840
|
-
|
|
16841
|
-
|
|
16860
|
+
|
|
16861
|
+
// dist/omp-slash-commands.js
|
|
16862
|
+
var OMP_LIVE_COMMAND_ID_PREFIX = "omp.slash.";
|
|
16863
|
+
function isRecord2(value) {
|
|
16864
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
16842
16865
|
}
|
|
16843
|
-
function
|
|
16844
|
-
|
|
16845
|
-
|
|
16846
|
-
|
|
16847
|
-
|
|
16848
|
-
|
|
16849
|
-
|
|
16850
|
-
|
|
16851
|
-
|
|
16852
|
-
|
|
16866
|
+
function parseOmpAvailableCommands(value) {
|
|
16867
|
+
if (!Array.isArray(value))
|
|
16868
|
+
return [];
|
|
16869
|
+
return value.flatMap((entry) => {
|
|
16870
|
+
if (!isRecord2(entry))
|
|
16871
|
+
return [];
|
|
16872
|
+
const name = typeof entry.name === "string" ? entry.name.trim().replace(/^\//u, "") : "";
|
|
16873
|
+
if (!name)
|
|
16874
|
+
return [];
|
|
16875
|
+
return [
|
|
16876
|
+
{
|
|
16877
|
+
name,
|
|
16878
|
+
description: typeof entry.description === "string" ? entry.description : "",
|
|
16879
|
+
source: typeof entry.source === "string" ? entry.source : null
|
|
16880
|
+
}
|
|
16881
|
+
];
|
|
16882
|
+
});
|
|
16883
|
+
}
|
|
16884
|
+
function ompLiveCommands(native) {
|
|
16885
|
+
return native.filter(({ source }) => source !== "builtin").map((command) => ({
|
|
16886
|
+
name: command.name,
|
|
16887
|
+
description: command.description,
|
|
16888
|
+
kind: command.source === "skill" ? "skill" : "command"
|
|
16889
|
+
}));
|
|
16853
16890
|
}
|
|
16854
16891
|
|
|
16855
|
-
// dist/omp-
|
|
16856
|
-
|
|
16857
|
-
|
|
16858
|
-
|
|
16859
|
-
|
|
16860
|
-
|
|
16861
|
-
|
|
16862
|
-
|
|
16892
|
+
// dist/omp-model-catalog.js
|
|
16893
|
+
var OMP_MODEL_REF_PREFIX = "omp-model-v1.";
|
|
16894
|
+
var OMP_DRAFT_THINKING_OPTION_IDS = [
|
|
16895
|
+
"off",
|
|
16896
|
+
"minimal",
|
|
16897
|
+
"low",
|
|
16898
|
+
"medium",
|
|
16899
|
+
"high",
|
|
16900
|
+
"xhigh",
|
|
16901
|
+
"max"
|
|
16902
|
+
].map((id) => harnessThinkingOptionIdSchema.parse(id));
|
|
16903
|
+
var OMP_THINKING_LABELS = {
|
|
16904
|
+
off: "Off",
|
|
16905
|
+
minimal: "Minimal",
|
|
16906
|
+
low: "Low",
|
|
16907
|
+
medium: "Medium",
|
|
16908
|
+
high: "High",
|
|
16909
|
+
xhigh: "Extra High",
|
|
16910
|
+
max: "Max"
|
|
16911
|
+
};
|
|
16912
|
+
function compareText(left, right) {
|
|
16913
|
+
return left < right ? -1 : left > right ? 1 : 0;
|
|
16863
16914
|
}
|
|
16864
|
-
function
|
|
16865
|
-
if (
|
|
16866
|
-
|
|
16867
|
-
}
|
|
16868
|
-
return value;
|
|
16915
|
+
function assertNativePart(value, name) {
|
|
16916
|
+
if (value.trim().length === 0)
|
|
16917
|
+
throw new Error(`Omp ${name} must not be empty`);
|
|
16869
16918
|
}
|
|
16870
|
-
|
|
16871
|
-
|
|
16872
|
-
|
|
16873
|
-
const
|
|
16874
|
-
|
|
16875
|
-
encoding: "utf8",
|
|
16876
|
-
...maxBytes === void 0 ? {} : { end: maxBytes - 1 }
|
|
16877
|
-
}),
|
|
16878
|
-
crlfDelay: Number.POSITIVE_INFINITY
|
|
16879
|
-
});
|
|
16880
|
-
try {
|
|
16881
|
-
for await (const line of lines) {
|
|
16882
|
-
if (line.length === 0)
|
|
16883
|
-
continue;
|
|
16884
|
-
let parsed;
|
|
16885
|
-
try {
|
|
16886
|
-
parsed = JSON.parse(line);
|
|
16887
|
-
} catch {
|
|
16888
|
-
continue;
|
|
16889
|
-
}
|
|
16890
|
-
const entry = historyEntry(parsed);
|
|
16891
|
-
if (!entry)
|
|
16892
|
-
continue;
|
|
16893
|
-
entries.push(entry);
|
|
16894
|
-
leafId = entry.id;
|
|
16895
|
-
}
|
|
16896
|
-
} finally {
|
|
16897
|
-
lines.close();
|
|
16898
|
-
}
|
|
16899
|
-
return { entries, leafId };
|
|
16919
|
+
function encodeOmpModelRef(model) {
|
|
16920
|
+
assertNativePart(model.provider, "Model provider");
|
|
16921
|
+
assertNativePart(model.id, "Model id");
|
|
16922
|
+
const encoded = Buffer.from(JSON.stringify([model.provider, model.id]), "utf8").toString("base64url");
|
|
16923
|
+
return harnessModelRefSchema.parse({ id: `${OMP_MODEL_REF_PREFIX}${encoded}` });
|
|
16900
16924
|
}
|
|
16901
|
-
|
|
16902
|
-
const
|
|
16925
|
+
function decodeOmpModelRef(ref) {
|
|
16926
|
+
const parsedRef = harnessModelRefSchema.parse(ref);
|
|
16927
|
+
if (!parsedRef.id.startsWith(OMP_MODEL_REF_PREFIX)) {
|
|
16928
|
+
throw new Error("Model Ref does not belong to OmpAdapter");
|
|
16929
|
+
}
|
|
16930
|
+
const encoded = parsedRef.id.slice(OMP_MODEL_REF_PREFIX.length);
|
|
16931
|
+
let decoded;
|
|
16903
16932
|
try {
|
|
16904
|
-
|
|
16905
|
-
|
|
16906
|
-
|
|
16907
|
-
const newline = contents.indexOf(10);
|
|
16908
|
-
if (newline < 0 && bytesRead === buffer.length) {
|
|
16909
|
-
throw new Error("Omp Session header exceeds the supported size");
|
|
16910
|
-
}
|
|
16911
|
-
const contentsText = utf8Decoder.decode(contents);
|
|
16912
|
-
for (const line of contentsText.split("\n")) {
|
|
16913
|
-
if (line.length === 0)
|
|
16914
|
-
continue;
|
|
16915
|
-
let parsed;
|
|
16916
|
-
try {
|
|
16917
|
-
parsed = JSON.parse(line);
|
|
16918
|
-
} catch {
|
|
16919
|
-
continue;
|
|
16920
|
-
}
|
|
16921
|
-
if (!isRecord5(parsed) || parsed.type !== "session")
|
|
16922
|
-
continue;
|
|
16923
|
-
if (typeof parsed.id !== "string" || parsed.id.length === 0 || typeof parsed.cwd !== "string" || parsed.cwd.length === 0) {
|
|
16924
|
-
throw new Error("Omp Session header is invalid");
|
|
16925
|
-
}
|
|
16926
|
-
return { type: "session", id: parsed.id, cwd: parsed.cwd };
|
|
16927
|
-
}
|
|
16928
|
-
throw new Error("Omp Session header is invalid");
|
|
16929
|
-
} finally {
|
|
16930
|
-
await handle.close();
|
|
16933
|
+
decoded = JSON.parse(Buffer.from(encoded, "base64url").toString("utf8"));
|
|
16934
|
+
} catch {
|
|
16935
|
+
throw new Error("Omp Model Ref is malformed");
|
|
16931
16936
|
}
|
|
16932
|
-
|
|
16933
|
-
|
|
16934
|
-
if (!input.sessionFile)
|
|
16935
|
-
throw new Error("Omp Fork Session has no persisted Session file");
|
|
16936
|
-
const header = await readOmpSessionHeader(input.sessionFile);
|
|
16937
|
-
if (header.id !== input.sessionId) {
|
|
16938
|
-
throw new Error("Omp Fork Session header identity does not match RPC state");
|
|
16937
|
+
if (!Array.isArray(decoded) || decoded.length !== 2 || typeof decoded[0] !== "string" || typeof decoded[1] !== "string") {
|
|
16938
|
+
throw new Error("Omp Model Ref has an invalid native identity");
|
|
16939
16939
|
}
|
|
16940
|
-
const [
|
|
16941
|
-
|
|
16942
|
-
|
|
16943
|
-
|
|
16944
|
-
|
|
16945
|
-
throw new Error("Omp Fork Session did not bind the requested cwd");
|
|
16940
|
+
const native = { provider: decoded[0], id: decoded[1] };
|
|
16941
|
+
assertNativePart(native.provider, "Model provider");
|
|
16942
|
+
assertNativePart(native.id, "Model id");
|
|
16943
|
+
if (encodeOmpModelRef(native).id !== parsedRef.id) {
|
|
16944
|
+
throw new Error("Omp Model Ref is not canonical");
|
|
16946
16945
|
}
|
|
16946
|
+
return native;
|
|
16947
16947
|
}
|
|
16948
|
-
|
|
16949
|
-
|
|
16950
|
-
|
|
16951
|
-
|
|
16952
|
-
|
|
16953
|
-
|
|
16954
|
-
|
|
16955
|
-
|
|
16956
|
-
return
|
|
16948
|
+
function sameOmpModel(left, right) {
|
|
16949
|
+
return left === null ? right === null : right !== null && left.provider === right.provider && left.id === right.id;
|
|
16950
|
+
}
|
|
16951
|
+
function fallbackThinkingLabel(id) {
|
|
16952
|
+
const label = id.split(/[._~-]+/u).filter((part) => part.length > 0).map((part) => `${part[0]?.toUpperCase() ?? ""}${part.slice(1)}`).join(" ");
|
|
16953
|
+
return label || id;
|
|
16954
|
+
}
|
|
16955
|
+
function normalizeOmpThinkingOptions(levels) {
|
|
16956
|
+
return levels.map((id) => harnessThinkingOptionSchema.parse({
|
|
16957
|
+
id,
|
|
16958
|
+
label: OMP_THINKING_LABELS[id] ?? fallbackThinkingLabel(id)
|
|
16959
|
+
}));
|
|
16957
16960
|
}
|
|
16958
|
-
|
|
16959
|
-
const
|
|
16960
|
-
const
|
|
16961
|
-
|
|
16962
|
-
|
|
16963
|
-
|
|
16964
|
-
|
|
16965
|
-
|
|
16966
|
-
|
|
16967
|
-
|
|
16968
|
-
|
|
16969
|
-
|
|
16970
|
-
|
|
16971
|
-
|
|
16972
|
-
|
|
16973
|
-
|
|
16961
|
+
function normalizeOmpModelCatalog(nativeModels, effectiveModel, thinkingLevels, effectiveThinkingOptionId) {
|
|
16962
|
+
const byRef = /* @__PURE__ */ new Map();
|
|
16963
|
+
for (const native of nativeModels) {
|
|
16964
|
+
const ref = encodeOmpModelRef(native);
|
|
16965
|
+
const existing = byRef.get(ref.id);
|
|
16966
|
+
if (existing) {
|
|
16967
|
+
if (existing.reasoning !== native.reasoning) {
|
|
16968
|
+
throw new Error("Omp duplicate Model entries disagree on reasoning capability");
|
|
16969
|
+
}
|
|
16970
|
+
continue;
|
|
16971
|
+
}
|
|
16972
|
+
byRef.set(ref.id, {
|
|
16973
|
+
model: {
|
|
16974
|
+
ref,
|
|
16975
|
+
label: `${native.provider} / ${native.id}`
|
|
16976
|
+
},
|
|
16977
|
+
reasoning: native.reasoning
|
|
16978
|
+
});
|
|
16974
16979
|
}
|
|
16975
|
-
|
|
16976
|
-
|
|
16977
|
-
|
|
16978
|
-
state = await transport.selectModel(currentModel);
|
|
16980
|
+
const defaultModel = effectiveModel ? encodeOmpModelRef(effectiveModel) : void 0;
|
|
16981
|
+
if (defaultModel && !byRef.has(defaultModel.id)) {
|
|
16982
|
+
throw new Error("Omp effective Model is absent from the available Model catalog");
|
|
16979
16983
|
}
|
|
16980
|
-
if (
|
|
16981
|
-
|
|
16982
|
-
throw new Error("Omp last-Turn rollback changed current Thinking");
|
|
16983
|
-
state = await transport.selectThinkingOption(currentThinking);
|
|
16984
|
+
if (thinkingLevels && effectiveThinkingOptionId && !thinkingLevels.includes(effectiveThinkingOptionId)) {
|
|
16985
|
+
throw new Error("Omp effective Thinking option is absent from the available option catalog");
|
|
16984
16986
|
}
|
|
16985
|
-
if (
|
|
16986
|
-
throw new Error("Omp
|
|
16987
|
+
if (thinkingLevels && !effectiveThinkingOptionId) {
|
|
16988
|
+
throw new Error("Omp did not report an effective Thinking option");
|
|
16987
16989
|
}
|
|
16988
|
-
const
|
|
16989
|
-
|
|
16990
|
-
|
|
16990
|
+
const thinkingOptions = thinkingLevels ? normalizeOmpThinkingOptions(OMP_DRAFT_THINKING_OPTION_IDS) : [];
|
|
16991
|
+
const allThinkingOptionIds = thinkingOptions.map(({ id }) => id);
|
|
16992
|
+
const offThinkingOptionId = thinkingOptions.find(({ id }) => id === "off")?.id;
|
|
16993
|
+
const models = [...byRef.values()].map(({ model, reasoning }) => ({
|
|
16994
|
+
...model,
|
|
16995
|
+
supportedThinkingOptionIds: reasoning ? allThinkingOptionIds : offThinkingOptionId ? [offThinkingOptionId] : []
|
|
16996
|
+
})).sort((left, right) => compareText(left.label, right.label) || compareText(left.ref.id, right.ref.id));
|
|
16997
|
+
const defaultThinkingOptionId = thinkingOptions.find(({ id }) => id === effectiveThinkingOptionId)?.id;
|
|
16998
|
+
return harnessModelCatalogSchema.parse({
|
|
16999
|
+
models,
|
|
17000
|
+
...defaultModel ? { defaultModel } : {},
|
|
17001
|
+
thinkingOptions,
|
|
17002
|
+
...defaultThinkingOptionId ? { defaultThinkingOptionId } : {}
|
|
16991
17003
|
});
|
|
16992
|
-
const expectedTurnKeys = sourceSnapshot.turns.slice(0, -1).map((turn) => turn.nativeTurnRef.nativeTurnKey);
|
|
16993
|
-
const actualTurnKeys = snapshot.turns.map((turn) => turn.nativeTurnRef.nativeTurnKey);
|
|
16994
|
-
if (snapshot.turns.length !== boundary.sourceTurnCount - 1 || actualTurnKeys.some((key, index) => key !== expectedTurnKeys[index])) {
|
|
16995
|
-
throw new Error("Omp last-Turn rollback did not produce the exact retained history prefix");
|
|
16996
|
-
}
|
|
16997
|
-
await transport.verifySessionCwd(cwd);
|
|
16998
|
-
return { ok: true };
|
|
16999
17004
|
}
|
|
17000
17005
|
|
|
17001
|
-
// dist/omp-
|
|
17002
|
-
|
|
17003
|
-
|
|
17004
|
-
import path4 from "node:path";
|
|
17005
|
-
|
|
17006
|
-
// ../../harness-discovery/dist/environment.js
|
|
17007
|
-
import fs from "node:fs";
|
|
17008
|
-
import path from "node:path";
|
|
17009
|
-
function targetPath(platform) {
|
|
17010
|
-
return platform === "win32" ? path.win32 : path.posix;
|
|
17006
|
+
// dist/omp-tool-presentation.js
|
|
17007
|
+
function isRecord3(value) {
|
|
17008
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
17011
17009
|
}
|
|
17012
|
-
function
|
|
17013
|
-
|
|
17014
|
-
|
|
17015
|
-
|
|
17016
|
-
|
|
17010
|
+
function stringField(value, key) {
|
|
17011
|
+
return isRecord3(value) && typeof value[key] === "string" ? value[key] : void 0;
|
|
17012
|
+
}
|
|
17013
|
+
function toolCommand(toolName, argumentsValue) {
|
|
17014
|
+
if (toolName === "bash") {
|
|
17015
|
+
const command = stringField(argumentsValue, "command");
|
|
17016
|
+
if (command)
|
|
17017
|
+
return command;
|
|
17017
17018
|
}
|
|
17018
|
-
|
|
17019
|
+
const serializedArguments = JSON.stringify(argumentsValue);
|
|
17020
|
+
return serializedArguments === "{}" ? toolName : `${toolName} ${serializedArguments}`;
|
|
17019
17021
|
}
|
|
17020
|
-
function
|
|
17021
|
-
return
|
|
17022
|
+
function projectOmpToolItem(input) {
|
|
17023
|
+
return {
|
|
17024
|
+
type: "commandExecution",
|
|
17025
|
+
itemId: input.itemId,
|
|
17026
|
+
command: toolCommand(input.toolName, input.arguments),
|
|
17027
|
+
...input.cwd ? { cwd: input.cwd } : {}
|
|
17028
|
+
};
|
|
17022
17029
|
}
|
|
17023
|
-
|
|
17024
|
-
|
|
17030
|
+
|
|
17031
|
+
// dist/omp-history.js
|
|
17032
|
+
var ompHarnessId = harnessIdSchema.parse("omp");
|
|
17033
|
+
function isRecord4(value) {
|
|
17034
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
17025
17035
|
}
|
|
17026
|
-
function
|
|
17027
|
-
if (
|
|
17028
|
-
return
|
|
17029
|
-
if (
|
|
17030
|
-
return
|
|
17031
|
-
return (
|
|
17036
|
+
function textContent(value) {
|
|
17037
|
+
if (typeof value === "string")
|
|
17038
|
+
return value;
|
|
17039
|
+
if (!Array.isArray(value))
|
|
17040
|
+
return "";
|
|
17041
|
+
return value.filter((part) => isRecord4(part) && part.type === "text" && typeof part.text === "string").map((part) => part.text).join("");
|
|
17032
17042
|
}
|
|
17033
|
-
function
|
|
17034
|
-
|
|
17035
|
-
|
|
17036
|
-
|
|
17037
|
-
|
|
17038
|
-
|
|
17043
|
+
function thinkingContent(value) {
|
|
17044
|
+
if (!Array.isArray(value))
|
|
17045
|
+
return "";
|
|
17046
|
+
return value.filter((part) => isRecord4(part) && part.type === "thinking" && typeof part.thinking === "string").map((part) => part.thinking).join("");
|
|
17047
|
+
}
|
|
17048
|
+
function validatedEntry(value) {
|
|
17049
|
+
if (typeof value.id !== "string" || value.id.length === 0 || value.parentId !== null && typeof value.parentId !== "string" || typeof value.type !== "string") {
|
|
17050
|
+
throw new Error("Omp history contains an invalid Entry identity");
|
|
17039
17051
|
}
|
|
17052
|
+
return value;
|
|
17040
17053
|
}
|
|
17041
|
-
function
|
|
17042
|
-
|
|
17043
|
-
return fs.readdirSync(directory, { withFileTypes: true }).filter((entry) => entry.isDirectory()).map((entry) => entry.name);
|
|
17044
|
-
} catch {
|
|
17054
|
+
function activeOmpEntries(history) {
|
|
17055
|
+
if (history.leafId === null)
|
|
17045
17056
|
return [];
|
|
17057
|
+
const byId = new Map(history.entries.map((value) => {
|
|
17058
|
+
const entry = validatedEntry(value);
|
|
17059
|
+
return [entry.id, entry];
|
|
17060
|
+
}));
|
|
17061
|
+
const reversed = [];
|
|
17062
|
+
const visited = /* @__PURE__ */ new Set();
|
|
17063
|
+
let current = history.leafId;
|
|
17064
|
+
while (current !== null) {
|
|
17065
|
+
if (visited.has(current))
|
|
17066
|
+
throw new Error("Omp history active branch contains a cycle");
|
|
17067
|
+
visited.add(current);
|
|
17068
|
+
const entry = byId.get(current);
|
|
17069
|
+
if (!entry)
|
|
17070
|
+
throw new Error("Omp history active branch references a missing Entry");
|
|
17071
|
+
reversed.push(entry);
|
|
17072
|
+
current = entry.parentId;
|
|
17046
17073
|
}
|
|
17074
|
+
return reversed.reverse();
|
|
17047
17075
|
}
|
|
17048
|
-
function
|
|
17049
|
-
return
|
|
17076
|
+
function message(entry) {
|
|
17077
|
+
return entry.type === "message" && isRecord4(entry.message) ? entry.message : null;
|
|
17050
17078
|
}
|
|
17051
|
-
|
|
17052
|
-
|
|
17053
|
-
|
|
17054
|
-
|
|
17055
|
-
|
|
17056
|
-
|
|
17057
|
-
|
|
17079
|
+
function messageRole(entry) {
|
|
17080
|
+
const value = message(entry)?.role;
|
|
17081
|
+
return typeof value === "string" ? value : null;
|
|
17082
|
+
}
|
|
17083
|
+
function itemId(entryId, kind, ordinal) {
|
|
17084
|
+
return hostItemIdSchema.parse(`omp-item-v1-${entryId}-${kind}-${ordinal}`);
|
|
17085
|
+
}
|
|
17086
|
+
function assistantOutcome(entries) {
|
|
17087
|
+
const assistants = entries.map((entry) => message(entry)).filter((value) => value?.role === "assistant");
|
|
17088
|
+
const final = assistants.at(-1);
|
|
17089
|
+
if (!final)
|
|
17090
|
+
return { status: "unknown", reason: "Omp history has no Assistant terminal" };
|
|
17091
|
+
const stopReason = final.stopReason;
|
|
17092
|
+
if (stopReason === "aborted") {
|
|
17093
|
+
return { status: "cancelled", reason: "Omp Assistant was aborted" };
|
|
17094
|
+
}
|
|
17095
|
+
if (stopReason === "error") {
|
|
17096
|
+
return {
|
|
17097
|
+
status: "failed",
|
|
17098
|
+
error: {
|
|
17099
|
+
code: "nativeFailure",
|
|
17100
|
+
message: typeof final.errorMessage === "string" && final.errorMessage.length > 0 ? final.errorMessage : "Omp Assistant failed",
|
|
17101
|
+
retryable: false
|
|
17102
|
+
}
|
|
17103
|
+
};
|
|
17104
|
+
}
|
|
17105
|
+
if (typeof stopReason === "string" || textContent(final.content).length > 0) {
|
|
17106
|
+
return { status: "succeeded" };
|
|
17107
|
+
}
|
|
17108
|
+
return { status: "unknown", reason: "Omp Assistant terminal is not classifiable" };
|
|
17109
|
+
}
|
|
17110
|
+
function itemOutcome(outcome) {
|
|
17111
|
+
if (outcome.status === "failed")
|
|
17112
|
+
return { status: "failed", error: outcome.error };
|
|
17113
|
+
if (outcome.status === "cancelled") {
|
|
17114
|
+
return {
|
|
17115
|
+
status: "cancelled",
|
|
17116
|
+
...outcome.reason ? { reason: outcome.reason } : {}
|
|
17117
|
+
};
|
|
17118
|
+
}
|
|
17119
|
+
return { status: "succeeded" };
|
|
17120
|
+
}
|
|
17121
|
+
function toolOutput(value) {
|
|
17122
|
+
const text = textContent(value);
|
|
17123
|
+
return text.length > 0 ? { content: [{ type: "text", text }] } : void 0;
|
|
17124
|
+
}
|
|
17125
|
+
function snapshotItems(entries, outcome) {
|
|
17126
|
+
const snapshots = [];
|
|
17127
|
+
const toolCalls = /* @__PURE__ */ new Map();
|
|
17128
|
+
for (const entry of entries) {
|
|
17129
|
+
const nativeMessage = message(entry);
|
|
17130
|
+
if (!nativeMessage)
|
|
17131
|
+
continue;
|
|
17132
|
+
const content = Array.isArray(nativeMessage.content) ? nativeMessage.content : [];
|
|
17133
|
+
if (nativeMessage.role === "assistant") {
|
|
17134
|
+
const text = textContent(content);
|
|
17135
|
+
const reasoning = thinkingContent(content);
|
|
17136
|
+
let projectedText = false;
|
|
17137
|
+
let projectedReasoning = false;
|
|
17138
|
+
for (const [ordinal, part] of content.entries()) {
|
|
17139
|
+
if (!isRecord4(part))
|
|
17140
|
+
continue;
|
|
17141
|
+
if (part.type === "thinking" && !projectedReasoning && reasoning.length > 0) {
|
|
17142
|
+
const item2 = {
|
|
17143
|
+
type: "reasoning",
|
|
17144
|
+
itemId: itemId(entry.id, "reasoning", 0),
|
|
17145
|
+
text: reasoning
|
|
17146
|
+
};
|
|
17147
|
+
snapshots.push({ item: item2, outcome: itemOutcome(outcome) });
|
|
17148
|
+
projectedReasoning = true;
|
|
17149
|
+
continue;
|
|
17150
|
+
}
|
|
17151
|
+
if (part.type === "text" && !projectedText && text.length > 0) {
|
|
17152
|
+
const item2 = {
|
|
17153
|
+
type: "agentMessage",
|
|
17154
|
+
itemId: itemId(entry.id, "assistant", 0),
|
|
17155
|
+
text
|
|
17156
|
+
};
|
|
17157
|
+
snapshots.push({ item: item2, outcome: itemOutcome(outcome) });
|
|
17158
|
+
projectedText = true;
|
|
17159
|
+
continue;
|
|
17160
|
+
}
|
|
17161
|
+
if (part.type !== "toolCall" || typeof part.id !== "string" || typeof part.name !== "string") {
|
|
17162
|
+
continue;
|
|
17163
|
+
}
|
|
17164
|
+
const parsedArguments = jsonValueSchema.safeParse(part.arguments);
|
|
17165
|
+
if (!parsedArguments.success)
|
|
17166
|
+
continue;
|
|
17167
|
+
toolCalls.set(part.id, {
|
|
17168
|
+
entryId: entry.id,
|
|
17169
|
+
ordinal,
|
|
17170
|
+
name: part.name,
|
|
17171
|
+
arguments: parsedArguments.data
|
|
17172
|
+
});
|
|
17173
|
+
}
|
|
17174
|
+
continue;
|
|
17175
|
+
}
|
|
17176
|
+
if (nativeMessage.role !== "toolResult" || typeof nativeMessage.toolCallId !== "string" || typeof nativeMessage.toolName !== "string") {
|
|
17177
|
+
continue;
|
|
17178
|
+
}
|
|
17179
|
+
const call = toolCalls.get(nativeMessage.toolCallId);
|
|
17180
|
+
if (!call || call.name !== nativeMessage.toolName)
|
|
17181
|
+
continue;
|
|
17182
|
+
const output = toolOutput(nativeMessage.content);
|
|
17183
|
+
const item = {
|
|
17184
|
+
...projectOmpToolItem({
|
|
17185
|
+
itemId: itemId(call.entryId, "tool", call.ordinal),
|
|
17186
|
+
toolName: call.name,
|
|
17187
|
+
arguments: call.arguments
|
|
17188
|
+
}),
|
|
17189
|
+
...output ? { output: textContent(output.content) } : {}
|
|
17190
|
+
};
|
|
17191
|
+
const toolFailed = nativeMessage.isError === true;
|
|
17192
|
+
snapshots.push({
|
|
17193
|
+
item,
|
|
17194
|
+
outcome: toolFailed ? {
|
|
17195
|
+
status: "failed",
|
|
17196
|
+
error: {
|
|
17197
|
+
code: "nativeFailure",
|
|
17198
|
+
message: `Omp Tool '${call.name}' failed`,
|
|
17199
|
+
retryable: false
|
|
17200
|
+
}
|
|
17201
|
+
} : { status: "succeeded" }
|
|
17202
|
+
});
|
|
17058
17203
|
}
|
|
17059
|
-
|
|
17060
|
-
const commandLine = [command, ...arguments_].map(quote).join(" ");
|
|
17061
|
-
return {
|
|
17062
|
-
command: environmentValue(environment, "ComSpec") ?? "cmd.exe",
|
|
17063
|
-
arguments: ["/d", "/v:off", "/s", "/c", `"${commandLine}"`],
|
|
17064
|
-
windowsVerbatimArguments: true
|
|
17065
|
-
};
|
|
17204
|
+
return snapshots;
|
|
17066
17205
|
}
|
|
17067
|
-
|
|
17068
|
-
|
|
17069
|
-
import path3 from "node:path";
|
|
17070
|
-
function withNodeRuntimeOnPath(environment, runtimeExecutable = process.execPath, platform = process.platform) {
|
|
17071
|
-
const pathKey = Object.keys(environment).find((name) => name.toLowerCase() === "path") ?? "PATH";
|
|
17072
|
-
const delimiter = platform === "win32" ? ";" : ":";
|
|
17073
|
-
const runtimeDirectory = path3.dirname(runtimeExecutable);
|
|
17074
|
-
const directories = (environment[pathKey] ?? "").split(delimiter).filter(Boolean);
|
|
17075
|
-
const equal = platform === "win32" ? (value) => value.toLowerCase() : (value) => value;
|
|
17076
|
-
if (!directories.some((directory) => equal(directory) === equal(runtimeDirectory))) {
|
|
17077
|
-
directories.push(runtimeDirectory);
|
|
17078
|
-
}
|
|
17079
|
-
return { ...environment, [pathKey]: directories.join(delimiter) };
|
|
17206
|
+
function modelChange(entry) {
|
|
17207
|
+
return entry.type === "model_change" && typeof entry.provider === "string" && typeof entry.modelId === "string" ? { provider: entry.provider, id: entry.modelId } : null;
|
|
17080
17208
|
}
|
|
17081
|
-
|
|
17082
|
-
|
|
17083
|
-
|
|
17084
|
-
|
|
17085
|
-
|
|
17086
|
-
|
|
17087
|
-
|
|
17088
|
-
|
|
17089
|
-
|
|
17090
|
-
|
|
17091
|
-
const directories = [];
|
|
17092
|
-
const versioned = (root, ...tail) => {
|
|
17093
|
-
for (const version2 of newestFirst(list(root))) {
|
|
17094
|
-
directories.push(pathFlavor.join(root, version2, ...tail));
|
|
17209
|
+
function mapOmpSnapshot(history, state) {
|
|
17210
|
+
const active = activeOmpEntries(history);
|
|
17211
|
+
const turns = [];
|
|
17212
|
+
let effectiveModel = state.model;
|
|
17213
|
+
for (let index = 0; index < active.length; ) {
|
|
17214
|
+
const model = modelChange(active[index]);
|
|
17215
|
+
if (model) {
|
|
17216
|
+
effectiveModel = model;
|
|
17217
|
+
index += 1;
|
|
17218
|
+
continue;
|
|
17095
17219
|
}
|
|
17096
|
-
|
|
17097
|
-
|
|
17098
|
-
|
|
17099
|
-
|
|
17100
|
-
|
|
17101
|
-
|
|
17102
|
-
|
|
17103
|
-
|
|
17104
|
-
const
|
|
17105
|
-
|
|
17106
|
-
|
|
17107
|
-
|
|
17108
|
-
|
|
17109
|
-
|
|
17110
|
-
|
|
17111
|
-
|
|
17112
|
-
|
|
17113
|
-
|
|
17114
|
-
|
|
17115
|
-
|
|
17116
|
-
|
|
17117
|
-
|
|
17118
|
-
|
|
17119
|
-
|
|
17120
|
-
|
|
17121
|
-
|
|
17122
|
-
|
|
17123
|
-
|
|
17124
|
-
|
|
17125
|
-
|
|
17126
|
-
|
|
17127
|
-
|
|
17128
|
-
|
|
17129
|
-
|
|
17130
|
-
|
|
17131
|
-
if (pnpmHome)
|
|
17132
|
-
directories.push(pnpmHome);
|
|
17133
|
-
directories.push(pathFlavor.join(home, "Library", "pnpm"));
|
|
17134
|
-
directories.push(pathFlavor.join(home, ".local", "share", "pnpm"));
|
|
17135
|
-
for (const prefix of ["/opt/homebrew/opt", "/usr/local/opt"]) {
|
|
17136
|
-
for (const formula of newestFirst(list(prefix).filter((name) => name.startsWith("node@")))) {
|
|
17137
|
-
directories.push(pathFlavor.join(prefix, formula, "bin"));
|
|
17220
|
+
const user = active[index];
|
|
17221
|
+
if (messageRole(user) !== "user") {
|
|
17222
|
+
index += 1;
|
|
17223
|
+
continue;
|
|
17224
|
+
}
|
|
17225
|
+
let end = index + 1;
|
|
17226
|
+
while (end < active.length && messageRole(active[end]) !== "user")
|
|
17227
|
+
end += 1;
|
|
17228
|
+
const entries = active.slice(index, end);
|
|
17229
|
+
const outcome = assistantOutcome(entries);
|
|
17230
|
+
const userText = textContent(message(user)?.content);
|
|
17231
|
+
const nativeTurnRef = nativeTurnRefSchema.parse({
|
|
17232
|
+
harnessId: ompHarnessId,
|
|
17233
|
+
nativeSessionId: state.sessionId,
|
|
17234
|
+
nativeTurnKey: user.id,
|
|
17235
|
+
formatVersion: 1
|
|
17236
|
+
});
|
|
17237
|
+
const checkpoint = nativeCheckpointRefSchema.parse({
|
|
17238
|
+
harnessId: ompHarnessId,
|
|
17239
|
+
nativeSessionId: state.sessionId,
|
|
17240
|
+
checkpointId: user.id,
|
|
17241
|
+
formatVersion: 1
|
|
17242
|
+
});
|
|
17243
|
+
turns.push({
|
|
17244
|
+
nativeTurnRef,
|
|
17245
|
+
checkpoint,
|
|
17246
|
+
input: [{ type: "text", text: userText }],
|
|
17247
|
+
items: snapshotItems(entries, outcome),
|
|
17248
|
+
outcome,
|
|
17249
|
+
...effectiveModel ? { model: encodeOmpModelRef(effectiveModel) } : {}
|
|
17250
|
+
});
|
|
17251
|
+
for (const entry of entries) {
|
|
17252
|
+
const changed = modelChange(entry);
|
|
17253
|
+
if (changed)
|
|
17254
|
+
effectiveModel = changed;
|
|
17138
17255
|
}
|
|
17256
|
+
index = end;
|
|
17139
17257
|
}
|
|
17140
|
-
return
|
|
17141
|
-
}
|
|
17142
|
-
|
|
17143
|
-
// ../../harness-discovery/dist/resolve.js
|
|
17144
|
-
var VERSION_MANAGER_ROOTS = "<version-managers>";
|
|
17145
|
-
function installRootExtensions(platform) {
|
|
17146
|
-
return platform === "win32" ? [".exe", ".cmd"] : [""];
|
|
17258
|
+
return { turns };
|
|
17147
17259
|
}
|
|
17148
|
-
function
|
|
17149
|
-
|
|
17260
|
+
function resolveOmpLastTurnBoundary(history) {
|
|
17261
|
+
const users = activeOmpEntries(history).filter((entry) => messageRole(entry) === "user");
|
|
17262
|
+
const last = users.at(-1);
|
|
17263
|
+
return last ? { lastUserEntryId: last.id, sourceTurnCount: users.length } : null;
|
|
17150
17264
|
}
|
|
17151
|
-
function
|
|
17152
|
-
const
|
|
17265
|
+
function resolveOmpForkBoundary(history, checkpointId) {
|
|
17266
|
+
const active = activeOmpEntries(history);
|
|
17267
|
+
const users = active.filter((entry) => messageRole(entry) === "user");
|
|
17268
|
+
const targetTurnIndex = users.findIndex((entry) => entry.id === checkpointId);
|
|
17269
|
+
if (targetTurnIndex < 0)
|
|
17270
|
+
throw new Error("Omp Checkpoint is not on the active branch");
|
|
17153
17271
|
return {
|
|
17154
|
-
|
|
17155
|
-
|
|
17156
|
-
APPDATA: environmentValue(environment, "APPDATA") ?? pathFlavor.join(home, "AppData", "Roaming"),
|
|
17157
|
-
LOCALAPPDATA: environmentValue(environment, "LOCALAPPDATA") ?? pathFlavor.join(home, "AppData", "Local")
|
|
17272
|
+
targetTurnIndex,
|
|
17273
|
+
nextUserEntryId: users[targetTurnIndex + 1]?.id ?? null
|
|
17158
17274
|
};
|
|
17159
17275
|
}
|
|
17160
|
-
|
|
17161
|
-
|
|
17162
|
-
|
|
17163
|
-
|
|
17164
|
-
|
|
17165
|
-
|
|
17166
|
-
|
|
17167
|
-
|
|
17276
|
+
|
|
17277
|
+
// dist/omp-session-file.js
|
|
17278
|
+
import { createReadStream } from "node:fs";
|
|
17279
|
+
import { open, realpath } from "node:fs/promises";
|
|
17280
|
+
import readline from "node:readline";
|
|
17281
|
+
var MAX_SESSION_HEADER_BYTES = 64 * 1024;
|
|
17282
|
+
var utf8Decoder = new TextDecoder("utf-8", { fatal: true });
|
|
17283
|
+
function isRecord5(value) {
|
|
17284
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
17168
17285
|
}
|
|
17169
|
-
function
|
|
17170
|
-
|
|
17171
|
-
|
|
17172
|
-
|
|
17173
|
-
|
|
17174
|
-
if (value === void 0 || value === "") {
|
|
17175
|
-
unresolved = true;
|
|
17176
|
-
return "";
|
|
17177
|
-
}
|
|
17178
|
-
return value;
|
|
17179
|
-
});
|
|
17180
|
-
return unresolved ? void 0 : joinTemplate(platform, substituted);
|
|
17286
|
+
function historyEntry(value) {
|
|
17287
|
+
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") {
|
|
17288
|
+
return null;
|
|
17289
|
+
}
|
|
17290
|
+
return value;
|
|
17181
17291
|
}
|
|
17182
|
-
function
|
|
17183
|
-
const
|
|
17184
|
-
|
|
17185
|
-
|
|
17186
|
-
|
|
17187
|
-
|
|
17188
|
-
|
|
17189
|
-
|
|
17190
|
-
|
|
17191
|
-
|
|
17192
|
-
|
|
17193
|
-
|
|
17292
|
+
async function readOmpSessionHistory(sessionFile, maxBytes) {
|
|
17293
|
+
const entries = [];
|
|
17294
|
+
let leafId = null;
|
|
17295
|
+
const lines = readline.createInterface({
|
|
17296
|
+
input: createReadStream(sessionFile, {
|
|
17297
|
+
encoding: "utf8",
|
|
17298
|
+
...maxBytes === void 0 ? {} : { end: maxBytes - 1 }
|
|
17299
|
+
}),
|
|
17300
|
+
crlfDelay: Number.POSITIVE_INFINITY
|
|
17301
|
+
});
|
|
17302
|
+
try {
|
|
17303
|
+
for await (const line of lines) {
|
|
17304
|
+
if (line.length === 0)
|
|
17305
|
+
continue;
|
|
17306
|
+
let parsed;
|
|
17307
|
+
try {
|
|
17308
|
+
parsed = JSON.parse(line);
|
|
17309
|
+
} catch {
|
|
17310
|
+
continue;
|
|
17311
|
+
}
|
|
17312
|
+
const entry = historyEntry(parsed);
|
|
17313
|
+
if (!entry)
|
|
17314
|
+
continue;
|
|
17315
|
+
entries.push(entry);
|
|
17316
|
+
leafId = entry.id;
|
|
17194
17317
|
}
|
|
17195
|
-
|
|
17196
|
-
|
|
17197
|
-
directories.push(directory);
|
|
17318
|
+
} finally {
|
|
17319
|
+
lines.close();
|
|
17198
17320
|
}
|
|
17199
|
-
return
|
|
17321
|
+
return { entries, leafId };
|
|
17200
17322
|
}
|
|
17201
|
-
function
|
|
17202
|
-
const
|
|
17203
|
-
|
|
17204
|
-
|
|
17205
|
-
|
|
17206
|
-
|
|
17207
|
-
|
|
17208
|
-
|
|
17209
|
-
|
|
17210
|
-
const extensions = executableExtensions(command, platform, input.environment);
|
|
17211
|
-
for (const directory of pathDirectories(input.environment, platform)) {
|
|
17212
|
-
for (const extension of extensions) {
|
|
17213
|
-
candidates.push({
|
|
17214
|
-
candidate: pathFlavor.join(directory, command + extension),
|
|
17215
|
-
source: "path"
|
|
17216
|
-
});
|
|
17323
|
+
async function readOmpSessionHeader(sessionFile) {
|
|
17324
|
+
const handle = await open(sessionFile, "r");
|
|
17325
|
+
try {
|
|
17326
|
+
const buffer = Buffer.allocUnsafe(MAX_SESSION_HEADER_BYTES);
|
|
17327
|
+
const { bytesRead } = await handle.read(buffer, 0, buffer.length, 0);
|
|
17328
|
+
const contents = buffer.subarray(0, bytesRead);
|
|
17329
|
+
const newline = contents.indexOf(10);
|
|
17330
|
+
if (newline < 0 && bytesRead === buffer.length) {
|
|
17331
|
+
throw new Error("Omp Session header exceeds the supported size");
|
|
17217
17332
|
}
|
|
17218
|
-
|
|
17219
|
-
|
|
17220
|
-
|
|
17221
|
-
|
|
17222
|
-
|
|
17223
|
-
|
|
17224
|
-
|
|
17225
|
-
|
|
17226
|
-
|
|
17227
|
-
}
|
|
17333
|
+
const contentsText = utf8Decoder.decode(contents);
|
|
17334
|
+
for (const line of contentsText.split("\n")) {
|
|
17335
|
+
if (line.length === 0)
|
|
17336
|
+
continue;
|
|
17337
|
+
let parsed;
|
|
17338
|
+
try {
|
|
17339
|
+
parsed = JSON.parse(line);
|
|
17340
|
+
} catch {
|
|
17341
|
+
continue;
|
|
17342
|
+
}
|
|
17343
|
+
if (!isRecord5(parsed) || parsed.type !== "session")
|
|
17344
|
+
continue;
|
|
17345
|
+
if (typeof parsed.id !== "string" || parsed.id.length === 0 || typeof parsed.cwd !== "string" || parsed.cwd.length === 0) {
|
|
17346
|
+
throw new Error("Omp Session header is invalid");
|
|
17347
|
+
}
|
|
17348
|
+
return { type: "session", id: parsed.id, cwd: parsed.cwd };
|
|
17228
17349
|
}
|
|
17350
|
+
throw new Error("Omp Session header is invalid");
|
|
17351
|
+
} finally {
|
|
17352
|
+
await handle.close();
|
|
17229
17353
|
}
|
|
17230
|
-
return candidates;
|
|
17231
17354
|
}
|
|
17232
|
-
function
|
|
17233
|
-
|
|
17234
|
-
|
|
17235
|
-
const
|
|
17236
|
-
|
|
17237
|
-
|
|
17238
|
-
|
|
17239
|
-
|
|
17240
|
-
|
|
17355
|
+
async function verifyOmpSessionCwd(input) {
|
|
17356
|
+
if (!input.sessionFile)
|
|
17357
|
+
throw new Error("Omp Fork Session has no persisted Session file");
|
|
17358
|
+
const header = await readOmpSessionHeader(input.sessionFile);
|
|
17359
|
+
if (header.id !== input.sessionId) {
|
|
17360
|
+
throw new Error("Omp Fork Session header identity does not match RPC state");
|
|
17361
|
+
}
|
|
17362
|
+
const [actualCwd, expectedCwd] = await Promise.all([
|
|
17363
|
+
realpath(header.cwd),
|
|
17364
|
+
realpath(input.expectedCwd)
|
|
17365
|
+
]);
|
|
17366
|
+
if (actualCwd !== expectedCwd) {
|
|
17367
|
+
throw new Error("Omp Fork Session did not bind the requested cwd");
|
|
17241
17368
|
}
|
|
17242
|
-
return void 0;
|
|
17243
17369
|
}
|
|
17244
17370
|
|
|
17245
|
-
//
|
|
17246
|
-
|
|
17247
|
-
|
|
17248
|
-
|
|
17249
|
-
|
|
17250
|
-
|
|
17251
|
-
|
|
17252
|
-
|
|
17253
|
-
env,
|
|
17254
|
-
cwd: env.HOME ?? env.USERPROFILE ?? homedir(),
|
|
17255
|
-
encoding: "utf8",
|
|
17256
|
-
timeout,
|
|
17257
|
-
killSignal: "SIGKILL",
|
|
17258
|
-
maxBuffer: 1024 * 1024,
|
|
17259
|
-
windowsHide: true,
|
|
17260
|
-
windowsVerbatimArguments: invocation.windowsVerbatimArguments
|
|
17261
|
-
}, (error51, stdout, stderr) => {
|
|
17262
|
-
if (error51)
|
|
17263
|
-
reject(new Error(error51.killed ? "Harness command timed out" : "Harness command failed; check the native installation and retry"));
|
|
17264
|
-
else
|
|
17265
|
-
resolve((stdout || stderr).trim());
|
|
17266
|
-
});
|
|
17267
|
-
child.stdin?.end();
|
|
17268
|
-
});
|
|
17269
|
-
}
|
|
17270
|
-
function installationVersion(value) {
|
|
17271
|
-
if (typeof value !== "string" || !/^v?\d+(?:\.\d+){1,3}(?:-[\w.-]+)?(?:\+[\w.-]+)?$/.test(value.trim()))
|
|
17272
|
-
throw new Error("Harness returned an invalid version");
|
|
17273
|
-
return value.trim().replace(/^v/, "");
|
|
17274
|
-
}
|
|
17275
|
-
function versionFromOutput(output) {
|
|
17276
|
-
return installationVersion(output.match(/\b\d+(?:\.\d+){1,3}(?:-[\w.-]+)?(?:\+[\w.-]+)?\b/)?.[0]);
|
|
17371
|
+
// dist/omp-last-turn-rollback.js
|
|
17372
|
+
function modelFromState(state) {
|
|
17373
|
+
if (state.provider === null && state.modelId === null)
|
|
17374
|
+
return null;
|
|
17375
|
+
if (state.provider === null || state.modelId === null) {
|
|
17376
|
+
throw new Error("Omp state contains a partial Model identity");
|
|
17377
|
+
}
|
|
17378
|
+
return { provider: state.provider, id: state.modelId };
|
|
17277
17379
|
}
|
|
17278
|
-
function
|
|
17279
|
-
const
|
|
17280
|
-
const
|
|
17281
|
-
const
|
|
17282
|
-
const
|
|
17283
|
-
|
|
17284
|
-
|
|
17285
|
-
|
|
17380
|
+
async function rollbackOmpLastTurn(transport, sourceSessionId, cwd) {
|
|
17381
|
+
const startupState = transport.state;
|
|
17382
|
+
const startupSessionId = startupState.sessionId;
|
|
17383
|
+
const currentModel = modelFromState(startupState);
|
|
17384
|
+
const currentThinking = startupState.thinkingLevel;
|
|
17385
|
+
const copiedHistory = await transport.getEntries();
|
|
17386
|
+
const boundary = resolveOmpLastTurnBoundary(copiedHistory);
|
|
17387
|
+
if (!boundary)
|
|
17388
|
+
return { ok: false, reason: "empty" };
|
|
17389
|
+
const sourceSnapshot = mapOmpSnapshot(copiedHistory, {
|
|
17390
|
+
sessionId: startupSessionId,
|
|
17391
|
+
model: currentModel
|
|
17392
|
+
});
|
|
17393
|
+
let state = await transport.fork(boundary.lastUserEntryId);
|
|
17394
|
+
if (state.sessionId === sourceSessionId || state.sessionId === startupSessionId) {
|
|
17395
|
+
throw new Error("Omp last-Turn rollback did not create a distinct Native Session");
|
|
17286
17396
|
}
|
|
17287
|
-
|
|
17288
|
-
|
|
17289
|
-
|
|
17290
|
-
|
|
17291
|
-
for (let i = 0; i < Math.max(preA.length, preB.length); i++) {
|
|
17292
|
-
const x = preA[i];
|
|
17293
|
-
const y = preB[i];
|
|
17294
|
-
if (x === y)
|
|
17295
|
-
continue;
|
|
17296
|
-
if (x === void 0 || y === void 0)
|
|
17297
|
-
return x === void 0;
|
|
17298
|
-
const numericX = /^\d+$/.test(x);
|
|
17299
|
-
const numericY = /^\d+$/.test(y);
|
|
17300
|
-
if (numericX && numericY) {
|
|
17301
|
-
if (BigInt(x) === BigInt(y))
|
|
17302
|
-
continue;
|
|
17303
|
-
return BigInt(y) > BigInt(x);
|
|
17304
|
-
}
|
|
17305
|
-
if (numericX !== numericY)
|
|
17306
|
-
return numericX;
|
|
17307
|
-
return y > x;
|
|
17397
|
+
if (!sameOmpModel(modelFromState(state), currentModel)) {
|
|
17398
|
+
if (!currentModel)
|
|
17399
|
+
throw new Error("Omp last-Turn rollback changed the current Model");
|
|
17400
|
+
state = await transport.selectModel(currentModel);
|
|
17308
17401
|
}
|
|
17309
|
-
|
|
17310
|
-
|
|
17311
|
-
|
|
17312
|
-
|
|
17313
|
-
|
|
17314
|
-
|
|
17315
|
-
|
|
17402
|
+
if (state.thinkingLevel !== currentThinking) {
|
|
17403
|
+
if (!currentThinking)
|
|
17404
|
+
throw new Error("Omp last-Turn rollback changed current Thinking");
|
|
17405
|
+
state = await transport.selectThinkingOption(currentThinking);
|
|
17406
|
+
}
|
|
17407
|
+
if (!sameOmpModel(modelFromState(state), currentModel) || state.thinkingLevel !== currentThinking) {
|
|
17408
|
+
throw new Error("Omp last-Turn rollback could not restore current Model and Thinking");
|
|
17409
|
+
}
|
|
17410
|
+
const snapshot = mapOmpSnapshot(await transport.getEntries(), {
|
|
17411
|
+
sessionId: state.sessionId,
|
|
17412
|
+
model: modelFromState(state)
|
|
17316
17413
|
});
|
|
17317
|
-
|
|
17318
|
-
|
|
17319
|
-
|
|
17320
|
-
|
|
17321
|
-
|
|
17322
|
-
|
|
17323
|
-
|
|
17324
|
-
if (!before.updateAvailable)
|
|
17325
|
-
return before;
|
|
17326
|
-
if (!before.canUpdate)
|
|
17327
|
-
throw new Error(before.message ?? "This installation cannot be updated automatically");
|
|
17328
|
-
await options.update(before);
|
|
17329
|
-
const after = await check2();
|
|
17330
|
-
if (after.currentVersion === before.currentVersion)
|
|
17331
|
-
throw new Error("The Harness version did not change; check the native updater and retry");
|
|
17332
|
-
return after;
|
|
17333
|
-
})().finally(() => {
|
|
17334
|
-
updating = void 0;
|
|
17335
|
-
});
|
|
17336
|
-
return updating;
|
|
17337
|
-
};
|
|
17414
|
+
const expectedTurnKeys = sourceSnapshot.turns.slice(0, -1).map((turn) => turn.nativeTurnRef.nativeTurnKey);
|
|
17415
|
+
const actualTurnKeys = snapshot.turns.map((turn) => turn.nativeTurnRef.nativeTurnKey);
|
|
17416
|
+
if (snapshot.turns.length !== boundary.sourceTurnCount - 1 || actualTurnKeys.some((key, index) => key !== expectedTurnKeys[index])) {
|
|
17417
|
+
throw new Error("Omp last-Turn rollback did not produce the exact retained history prefix");
|
|
17418
|
+
}
|
|
17419
|
+
await transport.verifySessionCwd(cwd);
|
|
17420
|
+
return { ok: true };
|
|
17338
17421
|
}
|
|
17339
17422
|
|
|
17423
|
+
// dist/omp-rpc-session.js
|
|
17424
|
+
import { spawn, spawnSync } from "node:child_process";
|
|
17425
|
+
import { randomUUID } from "node:crypto";
|
|
17426
|
+
import path4 from "node:path";
|
|
17427
|
+
|
|
17340
17428
|
// dist/command.js
|
|
17341
17429
|
var ompDiscoverySpec = {
|
|
17342
17430
|
id: "omp",
|
|
@@ -17752,6 +17840,10 @@ var OmpRpcSession = class {
|
|
|
17752
17840
|
#manualCompaction = null;
|
|
17753
17841
|
#stderrTail = "";
|
|
17754
17842
|
#frameDecoder = new OmpFrameDecoder();
|
|
17843
|
+
#startupFaultResolve = null;
|
|
17844
|
+
#startupFault = new Promise((resolve) => {
|
|
17845
|
+
this.#startupFaultResolve = resolve;
|
|
17846
|
+
});
|
|
17755
17847
|
#readyResolve = null;
|
|
17756
17848
|
#ready = new Promise((resolve) => {
|
|
17757
17849
|
this.#readyResolve = resolve;
|
|
@@ -17823,10 +17915,20 @@ var OmpRpcSession = class {
|
|
|
17823
17915
|
}),
|
|
17824
17916
|
new Promise((_resolve, reject) => setTimeout(() => reject(new Error("Omp RPC start timed out")), this.#options.commandTimeoutMs))
|
|
17825
17917
|
]);
|
|
17826
|
-
|
|
17827
|
-
|
|
17828
|
-
|
|
17829
|
-
|
|
17918
|
+
let readyTimeout;
|
|
17919
|
+
try {
|
|
17920
|
+
await Promise.race([
|
|
17921
|
+
this.#ready,
|
|
17922
|
+
this.#startupFault.then((error51) => {
|
|
17923
|
+
throw error51;
|
|
17924
|
+
}),
|
|
17925
|
+
new Promise((_resolve, reject) => {
|
|
17926
|
+
readyTimeout = setTimeout(() => reject(new Error("Omp RPC ready signal timed out")), this.#options.commandTimeoutMs);
|
|
17927
|
+
})
|
|
17928
|
+
]);
|
|
17929
|
+
} finally {
|
|
17930
|
+
clearTimeout(readyTimeout);
|
|
17931
|
+
}
|
|
17830
17932
|
await this.#send("negotiate_protocol", { protocolVersion: 2 }).catch(() => void 0);
|
|
17831
17933
|
if (this.#options.subscribeSubagentEvents !== false) {
|
|
17832
17934
|
await this.#send("set_subagent_subscription", { level: "events" }).catch(() => void 0);
|
|
@@ -18719,6 +18821,8 @@ var OmpRpcSession = class {
|
|
|
18719
18821
|
if (this.#closed || this.#failed)
|
|
18720
18822
|
return;
|
|
18721
18823
|
this.#failed = true;
|
|
18824
|
+
this.#startupFaultResolve?.(error51);
|
|
18825
|
+
this.#startupFaultResolve = null;
|
|
18722
18826
|
this.#rejectAll(error51);
|
|
18723
18827
|
this.#options.onFault?.(error51);
|
|
18724
18828
|
}
|
|
@@ -20738,7 +20842,11 @@ var OmpAdapter = class {
|
|
|
20738
20842
|
};
|
|
20739
20843
|
} catch (error51) {
|
|
20740
20844
|
await transport.close().catch(() => void 0);
|
|
20741
|
-
const normalized =
|
|
20845
|
+
const normalized = stage === "startup" && /No models available\.\s*Use \/login or set an API key environment variable\./i.test(transport.stderrTail ?? "") ? {
|
|
20846
|
+
code: "configurationRequired",
|
|
20847
|
+
message: "No models are configured for use in Oh My Pi. Configure a Provider and its API key or models.yml, then run `omp` and use `/model` to select a model. For Providers that support it, `/login` configures Provider authentication, not an Oh My Pi account.",
|
|
20848
|
+
retryable: false
|
|
20849
|
+
} : normalizedError(error51, "unavailable");
|
|
20742
20850
|
return {
|
|
20743
20851
|
status: normalized.code === "notInstalled" ? "notInstalled" : "error",
|
|
20744
20852
|
error: {
|
|
@@ -20964,7 +21072,10 @@ function createOmpInstallation(environment, command) {
|
|
|
20964
21072
|
latestVersion,
|
|
20965
21073
|
updateAvailable: newerInstallationVersion(currentVersion, latestVersion),
|
|
20966
21074
|
canUpdate,
|
|
20967
|
-
...!canUpdate ? {
|
|
21075
|
+
...!canUpdate ? {
|
|
21076
|
+
messageCode: "original-installer",
|
|
21077
|
+
message: "Update this installation with its original package manager or launcher."
|
|
21078
|
+
} : {}
|
|
20968
21079
|
};
|
|
20969
21080
|
},
|
|
20970
21081
|
async update() {
|
|
@@ -20980,7 +21091,14 @@ function createHarnessAdapter(context) {
|
|
|
20980
21091
|
return Object.assign(new OmpAdapter({
|
|
20981
21092
|
...environment[OMP_COMMAND_ENV] ? { command: environment[OMP_COMMAND_ENV] } : {},
|
|
20982
21093
|
environment
|
|
20983
|
-
}), {
|
|
21094
|
+
}), {
|
|
21095
|
+
installation: createOmpInstallation(environment, environment[OMP_COMMAND_ENV]),
|
|
21096
|
+
install: createHarnessInstaller(environment, {
|
|
21097
|
+
posix: "https://omp.sh/install",
|
|
21098
|
+
windows: "https://omp.sh/install.ps1",
|
|
21099
|
+
shell: "sh"
|
|
21100
|
+
})
|
|
21101
|
+
});
|
|
20984
21102
|
}
|
|
20985
21103
|
export {
|
|
20986
21104
|
OMP_COMMAND_ENV,
|