@liberseek/boft-cli-linux-x64 0.7.6 → 0.7.7

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.
@@ -5,209 +5,576 @@ var __export = (target, all) => {
5
5
  __defProp(target, name, { get: all[name], enumerable: true });
6
6
  };
7
7
 
8
- // dist/grok-adapter.js
9
- import { randomUUID } from "node:crypto";
10
-
11
- // dist/grok-credential-export.js
12
- import { createHash } from "node:crypto";
13
- import { readFile } from "node:fs/promises";
14
- import os from "node:os";
8
+ // ../../harness-discovery/dist/environment.js
9
+ import fs from "node:fs";
15
10
  import path from "node:path";
16
- async function readGrokCredentials(environment) {
17
- if ([environment.XAI_API_KEY, environment.GROK_API_KEY, environment.GROK_TOKEN].some((v) => v?.trim()))
18
- return [];
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;
19
+ }
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) {
19
36
  try {
20
- const home = environment.GROK_HOME ?? path.join(environment.HOME ?? os.homedir(), ".grok");
21
- const auth = JSON.parse(await readFile(path.join(home, "auth.json"), "utf8"));
22
- const client2 = "b1a00492-073a-47ea-816f-4c329264a828";
23
- const entry = auth[`https://auth.x.ai::${client2}`] ?? auth["https://auth.x.ai"];
24
- if (!entry || entry.oidc_issuer !== "https://auth.x.ai" || entry.oidc_client_id !== client2)
25
- return [];
26
- if (![entry.key, entry.refresh_token, entry.user_id].every((v) => typeof v === "string" && v.length))
27
- return [];
28
- const expires = Date.parse(entry.expires_at);
29
- if (!Number.isFinite(expires))
30
- return [];
31
- return [
32
- {
33
- source: {
34
- id: `grok:${createHash("sha256").update(entry.user_id).digest("hex")}`,
35
- harnessId: "grok",
36
- provider: "xai",
37
- label: typeof entry.email === "string" && entry.email ? entry.email : "Grok"
38
- },
39
- oauth: { access: entry.key, refresh: entry.refresh_token, expires: expires - 3e5 }
40
- }
41
- ];
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;
41
+ }
42
+ }
43
+ function subdirectoryNames(directory) {
44
+ try {
45
+ return fs.readdirSync(directory, { withFileTypes: true }).filter((entry) => entry.isDirectory()).map((entry) => entry.name);
42
46
  } catch {
43
47
  return [];
44
48
  }
45
49
  }
50
+ function newestFirst(names) {
51
+ return [...names].sort((left, right) => right.localeCompare(left, void 0, { numeric: true }));
52
+ }
46
53
 
47
- // dist/grok-adapter.js
48
- import path12 from "node:path";
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 };
60
+ }
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
+ }
49
69
 
50
- // ../../../node_modules/@agentclientprotocol/sdk/dist/schema/index.js
51
- var AGENT_METHODS = {
52
- initialize: "initialize",
53
- authenticate: "authenticate",
54
- providers_list: "providers/list",
55
- providers_set: "providers/set",
56
- providers_disable: "providers/disable",
57
- session_new: "session/new",
58
- session_load: "session/load",
59
- session_set_mode: "session/set_mode",
60
- session_set_config_option: "session/set_config_option",
61
- session_prompt: "session/prompt",
62
- session_cancel: "session/cancel",
63
- mcp_message: "mcp/message",
64
- session_list: "session/list",
65
- session_delete: "session/delete",
66
- session_fork: "session/fork",
67
- session_resume: "session/resume",
68
- session_close: "session/close",
69
- logout: "logout",
70
- nes_start: "nes/start",
71
- nes_suggest: "nes/suggest",
72
- nes_accept: "nes/accept",
73
- nes_reject: "nes/reject",
74
- nes_close: "nes/close",
75
- document_did_open: "document/didOpen",
76
- document_did_change: "document/didChange",
77
- document_did_close: "document/didClose",
78
- document_did_save: "document/didSave",
79
- document_did_focus: "document/didFocus"
80
- };
81
- var CLIENT_METHODS = {
82
- session_request_permission: "session/request_permission",
83
- session_update: "session/update",
84
- fs_write_text_file: "fs/write_text_file",
85
- fs_read_text_file: "fs/read_text_file",
86
- terminal_create: "terminal/create",
87
- terminal_output: "terminal/output",
88
- terminal_release: "terminal/release",
89
- terminal_wait_for_exit: "terminal/wait_for_exit",
90
- terminal_kill: "terminal/kill",
91
- mcp_connect: "mcp/connect",
92
- mcp_message: "mcp/message",
93
- mcp_disconnect: "mcp/disconnect",
94
- elicitation_create: "elicitation/create",
95
- elicitation_complete: "elicitation/complete"
96
- };
97
- var PROTOCOL_METHODS = {
98
- cancel_request: "$/cancel_request"
99
- };
100
- var PROTOCOL_VERSION = 1;
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);
80
+ }
81
+ return { ...environment, [pathKey]: directories.join(delimiter) };
82
+ }
101
83
 
102
- // ../../../node_modules/zod/v4/classic/external.js
103
- var external_exports = {};
104
- __export(external_exports, {
105
- $brand: () => $brand,
106
- $input: () => $input,
107
- $output: () => $output,
108
- NEVER: () => NEVER,
109
- TimePrecision: () => TimePrecision,
110
- ZodAny: () => ZodAny,
111
- ZodArray: () => ZodArray,
112
- ZodBase64: () => ZodBase64,
113
- ZodBase64URL: () => ZodBase64URL,
114
- ZodBigInt: () => ZodBigInt,
115
- ZodBigIntFormat: () => ZodBigIntFormat,
116
- ZodBoolean: () => ZodBoolean,
117
- ZodCIDRv4: () => ZodCIDRv4,
118
- ZodCIDRv6: () => ZodCIDRv6,
119
- ZodCUID: () => ZodCUID,
120
- ZodCUID2: () => ZodCUID2,
121
- ZodCatch: () => ZodCatch,
122
- ZodCodec: () => ZodCodec,
123
- ZodCustom: () => ZodCustom,
124
- ZodCustomStringFormat: () => ZodCustomStringFormat,
125
- ZodDate: () => ZodDate,
126
- ZodDefault: () => ZodDefault,
127
- ZodDiscriminatedUnion: () => ZodDiscriminatedUnion,
128
- ZodE164: () => ZodE164,
129
- ZodEmail: () => ZodEmail,
130
- ZodEmoji: () => ZodEmoji,
131
- ZodEnum: () => ZodEnum,
132
- ZodError: () => ZodError,
133
- ZodExactOptional: () => ZodExactOptional,
134
- ZodFile: () => ZodFile,
135
- ZodFirstPartyTypeKind: () => ZodFirstPartyTypeKind,
136
- ZodFunction: () => ZodFunction,
137
- ZodGUID: () => ZodGUID,
138
- ZodIPv4: () => ZodIPv4,
139
- ZodIPv6: () => ZodIPv6,
140
- ZodISODate: () => ZodISODate,
141
- ZodISODateTime: () => ZodISODateTime,
142
- ZodISODuration: () => ZodISODuration,
143
- ZodISOTime: () => ZodISOTime,
144
- ZodIntersection: () => ZodIntersection,
145
- ZodIssueCode: () => ZodIssueCode,
146
- ZodJWT: () => ZodJWT,
147
- ZodKSUID: () => ZodKSUID,
148
- ZodLazy: () => ZodLazy,
149
- ZodLiteral: () => ZodLiteral,
150
- ZodMAC: () => ZodMAC,
151
- ZodMap: () => ZodMap,
152
- ZodNaN: () => ZodNaN,
153
- ZodNanoID: () => ZodNanoID,
154
- ZodNever: () => ZodNever,
155
- ZodNonOptional: () => ZodNonOptional,
156
- ZodNull: () => ZodNull,
157
- ZodNullable: () => ZodNullable,
158
- ZodNumber: () => ZodNumber,
159
- ZodNumberFormat: () => ZodNumberFormat,
160
- ZodObject: () => ZodObject,
161
- ZodOptional: () => ZodOptional,
162
- ZodPipe: () => ZodPipe,
163
- ZodPrefault: () => ZodPrefault,
164
- ZodPreprocess: () => ZodPreprocess,
165
- ZodPromise: () => ZodPromise,
166
- ZodReadonly: () => ZodReadonly,
167
- ZodRealError: () => ZodRealError,
168
- ZodRecord: () => ZodRecord,
169
- ZodSet: () => ZodSet,
170
- ZodString: () => ZodString,
171
- ZodStringFormat: () => ZodStringFormat,
172
- ZodSuccess: () => ZodSuccess,
173
- ZodSymbol: () => ZodSymbol,
174
- ZodTemplateLiteral: () => ZodTemplateLiteral,
175
- ZodTransform: () => ZodTransform,
176
- ZodTuple: () => ZodTuple,
177
- ZodType: () => ZodType,
178
- ZodULID: () => ZodULID,
179
- ZodURL: () => ZodURL,
180
- ZodUUID: () => ZodUUID,
181
- ZodUndefined: () => ZodUndefined,
182
- ZodUnion: () => ZodUnion,
183
- ZodUnknown: () => ZodUnknown,
184
- ZodVoid: () => ZodVoid,
185
- ZodXID: () => ZodXID,
186
- ZodXor: () => ZodXor,
187
- _ZodString: () => _ZodString,
188
- _default: () => _default2,
189
- _function: () => _function,
190
- any: () => any,
191
- array: () => array,
192
- base64: () => base642,
193
- base64url: () => base64url2,
194
- bigint: () => bigint2,
195
- boolean: () => boolean2,
196
- catch: () => _catch2,
197
- check: () => check,
198
- cidrv4: () => cidrv42,
199
- cidrv6: () => cidrv62,
200
- clone: () => clone,
201
- codec: () => codec,
202
- coerce: () => coerce_exports,
203
- config: () => config,
204
- core: () => core_exports2,
205
- cuid: () => cuid3,
206
- cuid2: () => cuid22,
207
- custom: () => custom,
208
- date: () => date3,
209
- decode: () => decode2,
210
- decodeAsync: () => decodeAsync2,
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));
97
+ }
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;
111
+ }
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");
120
+ }
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
+ }
141
+ }
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 "";
179
+ }
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;
196
+ }
197
+ const directory = expandInstallRoot(template, input.environment, platform, home);
198
+ if (directory !== void 0)
199
+ directories.push(directory);
200
+ }
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" }];
210
+ }
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
+ });
219
+ }
220
+ }
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;
233
+ }
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 };
243
+ }
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
+ }, (error53, stdout, stderr) => {
264
+ if (error53)
265
+ reject(new Error(error53.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 createInstallationManager(options) {
278
+ let checking;
279
+ let updating;
280
+ const check2 = () => checking ??= options.check().finally(() => {
281
+ checking = void 0;
282
+ });
283
+ return (action) => {
284
+ if (updating)
285
+ return updating;
286
+ if (action === "check")
287
+ return check2();
288
+ updating = (async () => {
289
+ const before = await check2();
290
+ if (!before.updateAvailable)
291
+ return before;
292
+ if (!before.canUpdate)
293
+ throw new Error(before.message ?? "This installation cannot be updated automatically");
294
+ await options.update(before);
295
+ const after = await check2();
296
+ if (after.currentVersion === before.currentVersion)
297
+ throw new Error("The Harness version did not change; check the native updater and retry");
298
+ return after;
299
+ })().finally(() => {
300
+ updating = void 0;
301
+ });
302
+ return updating;
303
+ };
304
+ }
305
+ async function fetchInstallationText(url2) {
306
+ const request = async () => {
307
+ const response = await fetch(url2, { signal: AbortSignal.timeout(15e3) });
308
+ if (!response.ok)
309
+ throw new Error("Could not check the latest Harness version");
310
+ return response.text();
311
+ };
312
+ try {
313
+ return await request();
314
+ } catch (error53) {
315
+ if (error53 instanceof DOMException && (error53.name === "AbortError" || error53.name === "TimeoutError"))
316
+ throw error53;
317
+ return request();
318
+ }
319
+ }
320
+
321
+ // ../../harness-discovery/dist/installer.js
322
+ import { mkdtemp, rm, writeFile } from "node:fs/promises";
323
+ import { tmpdir } from "node:os";
324
+ import { join } from "node:path";
325
+ function createHarnessInstaller(environment, source) {
326
+ return async () => {
327
+ if (!["darwin", "linux", "win32"].includes(process.platform))
328
+ throw new Error("Unsupported installation platform");
329
+ const env = withNodeRuntimeOnPath(environment);
330
+ if ("npm" in source) {
331
+ const npm = resolveHarnessExecutable({
332
+ id: "npm",
333
+ command: "npm",
334
+ installRoots: {
335
+ posix: [
336
+ "~/.npm-global/bin",
337
+ "~/.local/bin",
338
+ VERSION_MANAGER_ROOTS,
339
+ "/opt/homebrew/bin",
340
+ "/usr/local/bin",
341
+ "/usr/bin"
342
+ ],
343
+ windows: [
344
+ "${APPDATA}/npm",
345
+ VERSION_MANAGER_ROOTS,
346
+ "${ProgramFiles}/nodejs",
347
+ "${LOCALAPPDATA}/Programs/nodejs"
348
+ ]
349
+ }
350
+ }, { environment: env });
351
+ if (!npm)
352
+ throw new Error("Install Node.js and npm first");
353
+ await runInstallationCommand(npm.executable, ["install", "--global", source.npm], {
354
+ ...env,
355
+ ...source.allowScripts ? { npm_config_allow_scripts: source.allowScripts } : {}
356
+ }, 6e5);
357
+ return;
358
+ }
359
+ const windows = process.platform === "win32";
360
+ const url2 = windows ? source.windows : source.posix;
361
+ if (new URL(url2).protocol !== "https:")
362
+ throw new Error("Installer requires HTTPS");
363
+ const script = await fetchInstallationText(url2);
364
+ const directory = await mkdtemp(join(tmpdir(), "codexhost-installer-"));
365
+ try {
366
+ const file2 = join(directory, windows ? "install.ps1" : "install.sh");
367
+ await writeFile(file2, script, { mode: 384 });
368
+ await runInstallationCommand(windows ? "powershell.exe" : source.shell ?? "bash", windows ? ["-NoProfile", "-NonInteractive", "-ExecutionPolicy", "Bypass", "-File", file2] : [file2], env, 6e5);
369
+ } finally {
370
+ await rm(directory, { recursive: true, force: true });
371
+ }
372
+ };
373
+ }
374
+
375
+ // dist/grok-adapter.js
376
+ import { randomUUID } from "node:crypto";
377
+
378
+ // dist/grok-credential-export.js
379
+ import { createHash } from "node:crypto";
380
+ import { readFile } from "node:fs/promises";
381
+ import os2 from "node:os";
382
+ import path4 from "node:path";
383
+ async function readGrokCredentials(environment) {
384
+ if ([environment.XAI_API_KEY, environment.GROK_API_KEY, environment.GROK_TOKEN].some((v) => v?.trim()))
385
+ return [];
386
+ try {
387
+ const home = environment.GROK_HOME ?? path4.join(environment.HOME ?? os2.homedir(), ".grok");
388
+ const auth = JSON.parse(await readFile(path4.join(home, "auth.json"), "utf8"));
389
+ const client2 = "b1a00492-073a-47ea-816f-4c329264a828";
390
+ const entry = auth[`https://auth.x.ai::${client2}`] ?? auth["https://auth.x.ai"];
391
+ if (!entry || entry.oidc_issuer !== "https://auth.x.ai" || entry.oidc_client_id !== client2)
392
+ return [];
393
+ if (![entry.key, entry.refresh_token, entry.user_id].every((v) => typeof v === "string" && v.length))
394
+ return [];
395
+ const expires = Date.parse(entry.expires_at);
396
+ if (!Number.isFinite(expires))
397
+ return [];
398
+ return [
399
+ {
400
+ source: {
401
+ id: `grok:${createHash("sha256").update(entry.user_id).digest("hex")}`,
402
+ harnessId: "grok",
403
+ provider: "xai",
404
+ label: typeof entry.email === "string" && entry.email ? entry.email : "Grok"
405
+ },
406
+ oauth: { access: entry.key, refresh: entry.refresh_token, expires: expires - 3e5 }
407
+ }
408
+ ];
409
+ } catch {
410
+ return [];
411
+ }
412
+ }
413
+
414
+ // dist/grok-adapter.js
415
+ import path12 from "node:path";
416
+
417
+ // ../../../node_modules/@agentclientprotocol/sdk/dist/schema/index.js
418
+ var AGENT_METHODS = {
419
+ initialize: "initialize",
420
+ authenticate: "authenticate",
421
+ providers_list: "providers/list",
422
+ providers_set: "providers/set",
423
+ providers_disable: "providers/disable",
424
+ session_new: "session/new",
425
+ session_load: "session/load",
426
+ session_set_mode: "session/set_mode",
427
+ session_set_config_option: "session/set_config_option",
428
+ session_prompt: "session/prompt",
429
+ session_cancel: "session/cancel",
430
+ mcp_message: "mcp/message",
431
+ session_list: "session/list",
432
+ session_delete: "session/delete",
433
+ session_fork: "session/fork",
434
+ session_resume: "session/resume",
435
+ session_close: "session/close",
436
+ logout: "logout",
437
+ nes_start: "nes/start",
438
+ nes_suggest: "nes/suggest",
439
+ nes_accept: "nes/accept",
440
+ nes_reject: "nes/reject",
441
+ nes_close: "nes/close",
442
+ document_did_open: "document/didOpen",
443
+ document_did_change: "document/didChange",
444
+ document_did_close: "document/didClose",
445
+ document_did_save: "document/didSave",
446
+ document_did_focus: "document/didFocus"
447
+ };
448
+ var CLIENT_METHODS = {
449
+ session_request_permission: "session/request_permission",
450
+ session_update: "session/update",
451
+ fs_write_text_file: "fs/write_text_file",
452
+ fs_read_text_file: "fs/read_text_file",
453
+ terminal_create: "terminal/create",
454
+ terminal_output: "terminal/output",
455
+ terminal_release: "terminal/release",
456
+ terminal_wait_for_exit: "terminal/wait_for_exit",
457
+ terminal_kill: "terminal/kill",
458
+ mcp_connect: "mcp/connect",
459
+ mcp_message: "mcp/message",
460
+ mcp_disconnect: "mcp/disconnect",
461
+ elicitation_create: "elicitation/create",
462
+ elicitation_complete: "elicitation/complete"
463
+ };
464
+ var PROTOCOL_METHODS = {
465
+ cancel_request: "$/cancel_request"
466
+ };
467
+ var PROTOCOL_VERSION = 1;
468
+
469
+ // ../../../node_modules/zod/v4/classic/external.js
470
+ var external_exports = {};
471
+ __export(external_exports, {
472
+ $brand: () => $brand,
473
+ $input: () => $input,
474
+ $output: () => $output,
475
+ NEVER: () => NEVER,
476
+ TimePrecision: () => TimePrecision,
477
+ ZodAny: () => ZodAny,
478
+ ZodArray: () => ZodArray,
479
+ ZodBase64: () => ZodBase64,
480
+ ZodBase64URL: () => ZodBase64URL,
481
+ ZodBigInt: () => ZodBigInt,
482
+ ZodBigIntFormat: () => ZodBigIntFormat,
483
+ ZodBoolean: () => ZodBoolean,
484
+ ZodCIDRv4: () => ZodCIDRv4,
485
+ ZodCIDRv6: () => ZodCIDRv6,
486
+ ZodCUID: () => ZodCUID,
487
+ ZodCUID2: () => ZodCUID2,
488
+ ZodCatch: () => ZodCatch,
489
+ ZodCodec: () => ZodCodec,
490
+ ZodCustom: () => ZodCustom,
491
+ ZodCustomStringFormat: () => ZodCustomStringFormat,
492
+ ZodDate: () => ZodDate,
493
+ ZodDefault: () => ZodDefault,
494
+ ZodDiscriminatedUnion: () => ZodDiscriminatedUnion,
495
+ ZodE164: () => ZodE164,
496
+ ZodEmail: () => ZodEmail,
497
+ ZodEmoji: () => ZodEmoji,
498
+ ZodEnum: () => ZodEnum,
499
+ ZodError: () => ZodError,
500
+ ZodExactOptional: () => ZodExactOptional,
501
+ ZodFile: () => ZodFile,
502
+ ZodFirstPartyTypeKind: () => ZodFirstPartyTypeKind,
503
+ ZodFunction: () => ZodFunction,
504
+ ZodGUID: () => ZodGUID,
505
+ ZodIPv4: () => ZodIPv4,
506
+ ZodIPv6: () => ZodIPv6,
507
+ ZodISODate: () => ZodISODate,
508
+ ZodISODateTime: () => ZodISODateTime,
509
+ ZodISODuration: () => ZodISODuration,
510
+ ZodISOTime: () => ZodISOTime,
511
+ ZodIntersection: () => ZodIntersection,
512
+ ZodIssueCode: () => ZodIssueCode,
513
+ ZodJWT: () => ZodJWT,
514
+ ZodKSUID: () => ZodKSUID,
515
+ ZodLazy: () => ZodLazy,
516
+ ZodLiteral: () => ZodLiteral,
517
+ ZodMAC: () => ZodMAC,
518
+ ZodMap: () => ZodMap,
519
+ ZodNaN: () => ZodNaN,
520
+ ZodNanoID: () => ZodNanoID,
521
+ ZodNever: () => ZodNever,
522
+ ZodNonOptional: () => ZodNonOptional,
523
+ ZodNull: () => ZodNull,
524
+ ZodNullable: () => ZodNullable,
525
+ ZodNumber: () => ZodNumber,
526
+ ZodNumberFormat: () => ZodNumberFormat,
527
+ ZodObject: () => ZodObject,
528
+ ZodOptional: () => ZodOptional,
529
+ ZodPipe: () => ZodPipe,
530
+ ZodPrefault: () => ZodPrefault,
531
+ ZodPreprocess: () => ZodPreprocess,
532
+ ZodPromise: () => ZodPromise,
533
+ ZodReadonly: () => ZodReadonly,
534
+ ZodRealError: () => ZodRealError,
535
+ ZodRecord: () => ZodRecord,
536
+ ZodSet: () => ZodSet,
537
+ ZodString: () => ZodString,
538
+ ZodStringFormat: () => ZodStringFormat,
539
+ ZodSuccess: () => ZodSuccess,
540
+ ZodSymbol: () => ZodSymbol,
541
+ ZodTemplateLiteral: () => ZodTemplateLiteral,
542
+ ZodTransform: () => ZodTransform,
543
+ ZodTuple: () => ZodTuple,
544
+ ZodType: () => ZodType,
545
+ ZodULID: () => ZodULID,
546
+ ZodURL: () => ZodURL,
547
+ ZodUUID: () => ZodUUID,
548
+ ZodUndefined: () => ZodUndefined,
549
+ ZodUnion: () => ZodUnion,
550
+ ZodUnknown: () => ZodUnknown,
551
+ ZodVoid: () => ZodVoid,
552
+ ZodXID: () => ZodXID,
553
+ ZodXor: () => ZodXor,
554
+ _ZodString: () => _ZodString,
555
+ _default: () => _default2,
556
+ _function: () => _function,
557
+ any: () => any,
558
+ array: () => array,
559
+ base64: () => base642,
560
+ base64url: () => base64url2,
561
+ bigint: () => bigint2,
562
+ boolean: () => boolean2,
563
+ catch: () => _catch2,
564
+ check: () => check,
565
+ cidrv4: () => cidrv42,
566
+ cidrv6: () => cidrv62,
567
+ clone: () => clone,
568
+ codec: () => codec,
569
+ coerce: () => coerce_exports,
570
+ config: () => config,
571
+ core: () => core_exports2,
572
+ cuid: () => cuid3,
573
+ cuid2: () => cuid22,
574
+ custom: () => custom,
575
+ date: () => date3,
576
+ decode: () => decode2,
577
+ decodeAsync: () => decodeAsync2,
211
578
  describe: () => describe2,
212
579
  discriminatedUnion: () => discriminatedUnion,
213
580
  e164: () => e1642,
@@ -18792,6 +19159,71 @@ var harnessDisplaySetSchema = external_exports.strictObject({
18792
19159
  initializeOnly: external_exports.boolean().optional()
18793
19160
  });
18794
19161
 
19162
+ // ../../shared-contracts/dist/ids.js
19163
+ var opaqueIdSchema = external_exports.string().refine((value) => value.trim().length > 0, {
19164
+ message: "Identifier must not be empty or whitespace"
19165
+ });
19166
+ var harnessIdSchema = opaqueIdSchema.brand();
19167
+ var hostThreadIdSchema = opaqueIdSchema.brand();
19168
+ var hostTurnIdSchema = opaqueIdSchema.brand();
19169
+ var hostItemIdSchema = opaqueIdSchema.brand();
19170
+ var hostInteractionIdSchema = opaqueIdSchema.brand();
19171
+
19172
+ // ../../shared-contracts/dist/harness-plugins.js
19173
+ var HARNESS_PLUGIN_MANIFEST_MAX_BYTES = 32 * 1024;
19174
+ var HARNESS_PLUGIN_ICON_MAX_BYTES = 128 * 1024;
19175
+ var HARNESS_PLUGIN_LIMIT = 128;
19176
+ 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);
19177
+ 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");
19178
+ var documentationUrlSchema = external_exports.url().refine((value) => /^https:\/\/[^/?#@]+(?:[/?#]|$)/iu.test(value), "Plugin documentation links must be credential-free HTTPS URLs");
19179
+ var pluginPresentationShape = {
19180
+ id: harnessPluginIdSchema,
19181
+ name: external_exports.string().trim().min(1).max(128),
19182
+ version: external_exports.string().min(1).max(128),
19183
+ /** The factory accepts a persisted local entrypoint through its construction context. */
19184
+ launchCommand: external_exports.literal(true).optional(),
19185
+ links: external_exports.object({
19186
+ documentation: documentationUrlSchema.optional(),
19187
+ installation: documentationUrlSchema.optional()
19188
+ }).strict().optional()
19189
+ };
19190
+ var harnessPluginManifestSchema = external_exports.object({
19191
+ manifestVersion: external_exports.literal(1),
19192
+ ...pluginPresentationShape,
19193
+ adapterApiVersion: external_exports.number().int().positive(),
19194
+ entry: relativeResourceSchema,
19195
+ icon: relativeResourceSchema.optional()
19196
+ }).strict();
19197
+ 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);
19198
+ var harnessPluginDescriptorSchema = external_exports.object({
19199
+ ...pluginPresentationShape,
19200
+ icon: harnessPluginIconSchema.optional()
19201
+ }).strict();
19202
+ var harnessPluginListParamsSchema = external_exports.object({}).strict();
19203
+ var harnessPluginListResultSchema = external_exports.object({
19204
+ plugins: external_exports.array(harnessPluginDescriptorSchema).max(HARNESS_PLUGIN_LIMIT)
19205
+ }).strict();
19206
+ var harnessPluginConfigurationSchema = external_exports.object({
19207
+ version: external_exports.literal(1),
19208
+ enabled: external_exports.array(harnessPluginIdSchema).max(HARNESS_PLUGIN_LIMIT)
19209
+ }).strict().refine((value) => new Set(value.enabled).size === value.enabled.length, {
19210
+ message: "Enabled plugin IDs must be unique",
19211
+ path: ["enabled"]
19212
+ });
19213
+
19214
+ // ../../shared-contracts/dist/harness-long-context.js
19215
+ var HARNESS_LONG_CONTEXT_GET_METHOD = "codexhost/harness/long-context/get";
19216
+ var HARNESS_LONG_CONTEXT_SET_METHOD = "codexhost/harness/long-context/set";
19217
+ var harnessLongContextGetSchema = external_exports.object({
19218
+ harnessId: harnessPluginIdSchema
19219
+ }).strict();
19220
+ var harnessLongContextSetSchema = harnessLongContextGetSchema.extend({
19221
+ enabled: external_exports.boolean()
19222
+ });
19223
+ var harnessLongContextSchema = external_exports.object({
19224
+ enabled: external_exports.boolean()
19225
+ }).strict();
19226
+
18795
19227
  // ../../shared-contracts/dist/console.js
18796
19228
  var consoleAnnouncementSchema = external_exports.strictObject({
18797
19229
  title: external_exports.string().trim().min(1).max(200),
@@ -18808,8 +19240,11 @@ var CONSOLE_HOST_METHODS = Object.freeze([
18808
19240
  "codexhost/harness/display-settings/get",
18809
19241
  "codexhost/harness/display-settings/set",
18810
19242
  "codexhost/harness/inspect",
19243
+ "codexhost/harness/installation",
18811
19244
  "codexhost/harness/launch-settings/get",
18812
19245
  "codexhost/harness/launch-settings/set",
19246
+ HARNESS_LONG_CONTEXT_GET_METHOD,
19247
+ HARNESS_LONG_CONTEXT_SET_METHOD,
18813
19248
  "codexhost/harness/web-ui/open",
18814
19249
  "codexhost/harness/accounts/sources",
18815
19250
  "codexhost/harness/accounts/list",
@@ -18869,16 +19304,6 @@ var loadedSessionsSchema = external_exports.array(external_exports.strictObject(
18869
19304
  inactiveMs: external_exports.number().nonnegative()
18870
19305
  }));
18871
19306
 
18872
- // ../../shared-contracts/dist/ids.js
18873
- var opaqueIdSchema = external_exports.string().refine((value) => value.trim().length > 0, {
18874
- message: "Identifier must not be empty or whitespace"
18875
- });
18876
- var harnessIdSchema = opaqueIdSchema.brand();
18877
- var hostThreadIdSchema = opaqueIdSchema.brand();
18878
- var hostTurnIdSchema = opaqueIdSchema.brand();
18879
- var hostItemIdSchema = opaqueIdSchema.brand();
18880
- var hostInteractionIdSchema = opaqueIdSchema.brand();
18881
-
18882
19307
  // ../../shared-contracts/dist/manual-compaction.js
18883
19308
  var threadManualCompactionStartedSchema = external_exports.strictObject({
18884
19309
  threadId: hostThreadIdSchema,
@@ -19274,1190 +19699,848 @@ var harnessSessionCapabilitiesSchema = external_exports.object({
19274
19699
  observe: external_exports.boolean()
19275
19700
  }).strict().optional(),
19276
19701
  input: external_exports.object({
19277
- image: external_exports.boolean()
19278
- }).strict().optional()
19279
- }).strict();
19280
- var harnessConfigurationStateSchema = external_exports.object({
19281
- effectiveModel: harnessModelRefSchema.optional(),
19282
- resolvedModelLabel: harnessResolvedModelLabelSchema.optional(),
19283
- effectiveThinkingOptionId: harnessThinkingOptionIdSchema.optional(),
19284
- availableThinkingOptions: harnessThinkingOptionsSchema.optional(),
19285
- effectivePermissionModeId: harnessPermissionModeIdSchema.optional()
19286
- }).strict().superRefine((state, context) => {
19287
- if (state.effectiveThinkingOptionId && state.availableThinkingOptions && !state.availableThinkingOptions.some(({ id }) => id === state.effectiveThinkingOptionId)) {
19288
- context.addIssue({
19289
- code: "custom",
19290
- message: "Effective Thinking option must be currently available",
19291
- path: ["effectiveThinkingOptionId"]
19292
- });
19293
- }
19294
- });
19295
- var harnessWebUiCapabilitySchema = external_exports.object({
19296
- open: external_exports.literal(true)
19297
- }).strict();
19298
- var readyHarnessInspectionSchema = external_exports.object({
19299
- status: external_exports.literal("ready"),
19300
- catalog: harnessModelCatalogSchema,
19301
- permissionModes: harnessPermissionModeCatalogSchema.optional(),
19302
- capabilities: harnessSessionCapabilitiesSchema,
19303
- webUi: harnessWebUiCapabilitySchema.optional()
19304
- }).strict().superRefine((inspection, context) => {
19305
- const selectable = inspection.capabilities.configuration.selectPermissionMode;
19306
- if (selectable !== Boolean(inspection.permissionModes)) {
19307
- context.addIssue({
19308
- code: "custom",
19309
- message: "Permission Mode catalog and capability must agree",
19310
- path: selectable ? ["permissionModes"] : ["capabilities", "configuration", "selectPermissionMode"]
19311
- });
19312
- }
19313
- });
19314
- var failedHarnessInspectionSchema = external_exports.object({
19315
- status: external_exports.enum(["notInstalled", "unavailable", "error"]),
19316
- error: codexhostErrorSchema
19317
- }).strict();
19318
- var harnessInspectionSchema = external_exports.union([
19319
- readyHarnessInspectionSchema,
19320
- failedHarnessInspectionSchema
19321
- ]);
19322
- var harnessInspectParamsSchema = external_exports.object({
19323
- harnessId: harnessIdSchema,
19324
- cwd: nonBlankTextSchema2.max(16384).optional(),
19325
- refresh: external_exports.boolean().optional()
19326
- }).strict();
19327
- var harnessWebUiOpenParamsSchema = external_exports.object({
19328
- harnessId: harnessIdSchema
19329
- }).strict();
19330
- var harnessWebUiOpenResultSchema = external_exports.object({}).strict();
19331
- var threadModelSelectParamsSchema = external_exports.object({
19332
- threadId: hostThreadIdSchema,
19333
- model: harnessModelRefSchema
19334
- }).strict();
19335
- var threadThinkingSelectParamsSchema = external_exports.object({
19336
- threadId: hostThreadIdSchema,
19337
- thinkingOptionId: harnessThinkingOptionIdSchema
19338
- }).strict();
19339
- var threadInspectionParamsSchema = external_exports.object({
19340
- threadId: hostThreadIdSchema,
19341
- includeReferenceCapability: external_exports.boolean().optional()
19342
- }).strict();
19343
- var codexThreadInspectionSchema = external_exports.object({
19344
- owner: external_exports.literal("codex"),
19345
- locked: external_exports.literal(true),
19346
- supportsThreadReferences: external_exports.literal(true).optional()
19702
+ image: external_exports.boolean()
19703
+ }).strict().optional()
19347
19704
  }).strict();
19348
- var externalThreadInspectionSchema = external_exports.object({
19349
- owner: external_exports.literal("external"),
19350
- harnessId: nonBlankTextSchema2.max(256),
19351
- transportModelId: nonBlankTextSchema2.max(1024),
19705
+ var harnessConfigurationStateSchema = external_exports.object({
19352
19706
  effectiveModel: harnessModelRefSchema.optional(),
19353
19707
  resolvedModelLabel: harnessResolvedModelLabelSchema.optional(),
19354
19708
  effectiveThinkingOptionId: harnessThinkingOptionIdSchema.optional(),
19355
19709
  availableThinkingOptions: harnessThinkingOptionsSchema.optional(),
19356
- effectivePermissionModeId: harnessPermissionModeIdSchema.optional(),
19357
- history: harnessHistoryCapabilitiesSchema,
19358
- usage: threadUsageSnapshotSchema.optional(),
19359
- /** True when the thread is a read-only child thread materialized for a subagent. */
19360
- subagent: external_exports.boolean().optional(),
19361
- locked: external_exports.literal(true)
19362
- }).strict();
19363
- var threadInspectionSchema = external_exports.discriminatedUnion("owner", [
19364
- codexThreadInspectionSchema,
19365
- externalThreadInspectionSchema
19366
- ]);
19367
- var threadOwnershipListParamsSchema = external_exports.object({
19368
- threadIds: external_exports.array(hostThreadIdSchema).min(1).max(THREAD_OWNERSHIP_LIST_MAX_LENGTH)
19369
- }).strict().superRefine(({ threadIds }, context) => {
19370
- const seen = /* @__PURE__ */ new Set();
19371
- for (const [index, threadId] of threadIds.entries()) {
19372
- if (seen.has(threadId)) {
19373
- context.addIssue({
19374
- code: "custom",
19375
- message: "Thread ownership-list IDs must be unique",
19376
- path: ["threadIds", index]
19377
- });
19378
- }
19379
- seen.add(threadId);
19710
+ effectivePermissionModeId: harnessPermissionModeIdSchema.optional()
19711
+ }).strict().superRefine((state, context) => {
19712
+ if (state.effectiveThinkingOptionId && state.availableThinkingOptions && !state.availableThinkingOptions.some(({ id }) => id === state.effectiveThinkingOptionId)) {
19713
+ context.addIssue({
19714
+ code: "custom",
19715
+ message: "Effective Thinking option must be currently available",
19716
+ path: ["effectiveThinkingOptionId"]
19717
+ });
19380
19718
  }
19381
19719
  });
19382
- var codexThreadOwnershipSchema = external_exports.object({
19383
- threadId: hostThreadIdSchema,
19384
- owner: external_exports.literal("codex")
19385
- }).strict();
19386
- var externalThreadOwnershipSchema = external_exports.object({
19387
- threadId: hostThreadIdSchema,
19388
- owner: external_exports.literal("external"),
19389
- harnessId: external_exports.string().max(256).pipe(harnessIdSchema)
19720
+ var harnessWebUiCapabilitySchema = external_exports.object({
19721
+ open: external_exports.literal(true)
19390
19722
  }).strict();
19391
- var threadOwnershipSchema = external_exports.discriminatedUnion("owner", [
19392
- codexThreadOwnershipSchema,
19393
- externalThreadOwnershipSchema
19394
- ]);
19395
- var threadOwnershipListResultSchema = external_exports.object({
19396
- threads: external_exports.array(threadOwnershipSchema).min(1).max(THREAD_OWNERSHIP_LIST_MAX_LENGTH)
19397
- }).strict().superRefine(({ threads }, context) => {
19398
- const seen = /* @__PURE__ */ new Set();
19399
- for (const [index, thread] of threads.entries()) {
19400
- if (seen.has(thread.threadId)) {
19401
- context.addIssue({
19402
- code: "custom",
19403
- message: "Thread ownership-list results must be unique",
19404
- path: ["threads", index, "threadId"]
19405
- });
19406
- }
19407
- seen.add(thread.threadId);
19723
+ var readyHarnessInspectionSchema = external_exports.object({
19724
+ status: external_exports.literal("ready"),
19725
+ catalog: harnessModelCatalogSchema,
19726
+ permissionModes: harnessPermissionModeCatalogSchema.optional(),
19727
+ capabilities: harnessSessionCapabilitiesSchema,
19728
+ webUi: harnessWebUiCapabilitySchema.optional()
19729
+ }).strict().superRefine((inspection, context) => {
19730
+ const selectable = inspection.capabilities.configuration.selectPermissionMode;
19731
+ if (selectable !== Boolean(inspection.permissionModes)) {
19732
+ context.addIssue({
19733
+ code: "custom",
19734
+ message: "Permission Mode catalog and capability must agree",
19735
+ path: selectable ? ["permissionModes"] : ["capabilities", "configuration", "selectPermissionMode"]
19736
+ });
19408
19737
  }
19409
19738
  });
19410
-
19411
- // ../../shared-contracts/dist/harness-plugins.js
19412
- var HARNESS_PLUGIN_MANIFEST_MAX_BYTES = 32 * 1024;
19413
- var HARNESS_PLUGIN_ICON_MAX_BYTES = 128 * 1024;
19414
- var HARNESS_PLUGIN_LIMIT = 128;
19415
- 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);
19416
- 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");
19417
- var documentationUrlSchema = external_exports.url().refine((value) => /^https:\/\/[^/?#@]+(?:[/?#]|$)/iu.test(value), "Plugin documentation links must be credential-free HTTPS URLs");
19418
- var pluginPresentationShape = {
19419
- id: harnessPluginIdSchema,
19420
- name: external_exports.string().trim().min(1).max(128),
19421
- version: external_exports.string().min(1).max(128),
19422
- /** The factory accepts a persisted local entrypoint through its construction context. */
19423
- launchCommand: external_exports.literal(true).optional(),
19424
- links: external_exports.object({
19425
- documentation: documentationUrlSchema.optional(),
19426
- installation: documentationUrlSchema.optional()
19427
- }).strict().optional()
19428
- };
19429
- var harnessPluginManifestSchema = external_exports.object({
19430
- manifestVersion: external_exports.literal(1),
19431
- ...pluginPresentationShape,
19432
- adapterApiVersion: external_exports.number().int().positive(),
19433
- entry: relativeResourceSchema,
19434
- icon: relativeResourceSchema.optional()
19435
- }).strict();
19436
- 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);
19437
- var harnessPluginDescriptorSchema = external_exports.object({
19438
- ...pluginPresentationShape,
19439
- icon: harnessPluginIconSchema.optional()
19440
- }).strict();
19441
- var harnessPluginListParamsSchema = external_exports.object({}).strict();
19442
- var harnessPluginListResultSchema = external_exports.object({
19443
- plugins: external_exports.array(harnessPluginDescriptorSchema).max(HARNESS_PLUGIN_LIMIT)
19444
- }).strict();
19445
- var harnessPluginConfigurationSchema = external_exports.object({
19446
- version: external_exports.literal(1),
19447
- enabled: external_exports.array(harnessPluginIdSchema).max(HARNESS_PLUGIN_LIMIT)
19448
- }).strict().refine((value) => new Set(value.enabled).size === value.enabled.length, {
19449
- message: "Enabled plugin IDs must be unique",
19450
- path: ["enabled"]
19451
- });
19452
-
19453
- // ../../shared-contracts/dist/harness-route.js
19454
- var harnessPluginRouteSchema = external_exports.object({
19455
- harnessId: harnessPluginIdSchema,
19456
- model: harnessModelRefSchema.optional(),
19457
- thinkingOptionId: harnessThinkingOptionIdSchema.optional(),
19458
- permissionModeId: harnessPermissionModeIdSchema.optional()
19459
- }).strict();
19460
-
19461
- // ../../shared-contracts/dist/harness-launch-settings.js
19462
- var harnessLaunchPathSchema = external_exports.string().trim().min(1).max(4096).refine((value) => !/[\u0000\r\n]/u.test(value), "Invalid entrypoint path");
19463
- var harnessLaunchSettingsGetSchema = external_exports.object({
19464
- harnessId: harnessPluginIdSchema
19465
- }).strict();
19466
- var harnessLaunchSettingsSetSchema = harnessLaunchSettingsGetSchema.extend({
19467
- path: harnessLaunchPathSchema.nullable()
19468
- });
19469
- var harnessLaunchSettingsSchema = external_exports.object({
19470
- path: harnessLaunchPathSchema.nullable(),
19471
- restartRequired: external_exports.boolean()
19472
- }).strict();
19473
-
19474
- // ../../shared-contracts/dist/harness-installation.js
19475
- var harnessInstallationParamsSchema = external_exports.object({
19476
- harnessId: harnessIdSchema,
19477
- action: external_exports.enum(["check", "update"])
19478
- }).strict();
19479
- var harnessInstallationStateSchema = external_exports.object({
19480
- currentVersion: external_exports.string().min(1).max(128),
19481
- latestVersion: external_exports.string().min(1).max(128),
19482
- updateAvailable: external_exports.boolean(),
19483
- canUpdate: external_exports.boolean(),
19484
- message: external_exports.string().max(2048).optional()
19485
- }).strict();
19486
-
19487
- // ../../shared-contracts/dist/codex-accounts.js
19488
- var accountIdSchema = external_exports.string().min(1).max(256).regex(/^[A-Za-z0-9._~-]+$/u);
19489
- var nonBlankTextSchema3 = external_exports.string().trim().min(1);
19490
- var codexAccountAuthKindSchema = external_exports.enum(["api", "chatgpt"]);
19491
- var codexAccountSiteUrlPattern = /^https?:\/\/(?:\[[0-9a-fA-F:]+\]|[^/\s:@?#]+)(?::\d{1,5})?(?:[/?#][^\s]*)?$/u;
19492
- function isCodexAccountSiteUrl(value) {
19493
- return value.length > 0 && value.length <= 2048 && codexAccountSiteUrlPattern.test(value);
19494
- }
19495
- var externalUrlOpenParamsSchema = external_exports.object({
19496
- url: external_exports.string().max(2048).refine(isCodexAccountSiteUrl, "External URL must be http(s)")
19497
- }).strict();
19498
- var externalUrlOpenResultSchema = external_exports.object({}).strict();
19499
- var codexAccountPlanTypeSchema = external_exports.enum([
19500
- "free",
19501
- "go",
19502
- "plus",
19503
- "pro",
19504
- "prolite",
19505
- "team",
19506
- "self_serve_business_prolite",
19507
- "self_serve_business_usage_based",
19508
- "business",
19509
- "ent26",
19510
- "enterprise_cbp_automation",
19511
- "enterprise_cbp_usage_based",
19512
- "enterprise",
19513
- "edu",
19514
- "edu_plus",
19515
- "edu_pro",
19516
- "unknown"
19517
- ]);
19518
- var codexAccountSchema = external_exports.object({
19519
- accountId: accountIdSchema,
19520
- label: nonBlankTextSchema3.max(256),
19521
- email: external_exports.string().email().max(320).optional(),
19522
- planType: codexAccountPlanTypeSchema.optional(),
19523
- authKind: codexAccountAuthKindSchema.optional(),
19524
- authIdentity: nonBlankTextSchema3.max(256).optional(),
19525
- siteUrl: external_exports.string().refine(isCodexAccountSiteUrl, "Account site URL must be http(s)").optional()
19526
- }).strict();
19527
- var codexAccountPhaseSchema = external_exports.enum(["ready", "unavailable"]);
19528
- var codexAccountListResultSchema = external_exports.object({
19529
- version: external_exports.literal(2),
19530
- currentAccountId: accountIdSchema.nullable(),
19531
- phase: codexAccountPhaseSchema,
19532
- revision: external_exports.number().int().nonnegative(),
19533
- instanceId: nonBlankTextSchema3.max(1024).optional(),
19534
- accounts: external_exports.array(codexAccountSchema).max(1)
19535
- }).strict();
19536
- var codexAccountUsageParamsSchema = external_exports.object({ accountId: accountIdSchema, refresh: external_exports.boolean().optional() }).strict();
19537
- var codexAccountUsageResultSchema = external_exports.object({
19538
- accountId: accountIdSchema,
19539
- usage: threadUsageSnapshotSchema.nullable(),
19540
- accountCredits: accountCreditsSnapshotSchema.optional(),
19541
- freshness: external_exports.enum(["live", "cached"]),
19542
- observedAt: external_exports.string().datetime().nullable()
19543
- }).strict();
19544
-
19545
- // ../../shared-contracts/dist/harness-session-import.js
19546
- var HARNESS_SESSION_IMPORT_ID_MAX_LENGTH = 1024;
19547
- var HARNESS_SESSION_IMPORT_CWD_MAX_LENGTH = 16384;
19548
- var HARNESS_SESSION_IMPORT_TITLE_MAX_LENGTH = 4096;
19549
- var HARNESS_SESSION_IMPORT_LIST_MAX_LENGTH = 1e3;
19550
- var HARNESS_SESSION_IMPORT_UPDATED_AT_MAX = 864e13;
19551
- var nonBlankTextSchema4 = external_exports.string().refine((value) => value.trim().length > 0, "Value must not be empty or whitespace").refine((value) => !value.includes("\0"), "Value must not contain NUL");
19552
- var harnessSessionImportIdSchema = nonBlankTextSchema4.max(HARNESS_SESSION_IMPORT_ID_MAX_LENGTH);
19553
- var harnessSessionImportCandidateSchema = external_exports.object({
19554
- nativeSessionId: harnessSessionImportIdSchema,
19555
- title: nonBlankTextSchema4.max(HARNESS_SESSION_IMPORT_TITLE_MAX_LENGTH).nullable(),
19556
- updatedAt: external_exports.number().int().nonnegative().max(HARNESS_SESSION_IMPORT_UPDATED_AT_MAX),
19557
- cwd: nonBlankTextSchema4.max(HARNESS_SESSION_IMPORT_CWD_MAX_LENGTH),
19558
- // Native file discovery cannot reliably observe another process's activity.
19559
- running: external_exports.boolean().nullable()
19560
- }).strict();
19561
- var harnessSessionImportSourcesParamsSchema = external_exports.object({}).strict();
19562
- var harnessSessionImportSourcesResultSchema = external_exports.object({
19563
- harnesses: external_exports.array(external_exports.object({
19564
- harnessId: harnessPluginIdSchema,
19565
- name: nonBlankTextSchema4.max(128)
19566
- }).strict()).max(128)
19567
- }).strict();
19568
- var harnessSessionListParamsSchema = external_exports.object({
19569
- harnessId: harnessPluginIdSchema,
19570
- query: external_exports.string().trim().max(4096).refine((value) => !value.includes("\0")).optional(),
19571
- offset: external_exports.number().int().nonnegative().safe().optional(),
19572
- limit: external_exports.number().int().min(1).max(HARNESS_SESSION_IMPORT_LIST_MAX_LENGTH).optional()
19573
- }).strict();
19574
- var harnessSessionListResultSchema = external_exports.object({
19575
- candidates: external_exports.array(harnessSessionImportCandidateSchema).max(HARNESS_SESSION_IMPORT_LIST_MAX_LENGTH),
19576
- total: external_exports.number().int().nonnegative().safe()
19577
- }).strict();
19578
- var harnessSessionImportParamsSchema = external_exports.object({
19579
- harnessId: harnessPluginIdSchema,
19580
- nativeSessionId: harnessSessionImportIdSchema
19739
+ var failedHarnessInspectionSchema = external_exports.object({
19740
+ status: external_exports.enum(["notInstalled", "unavailable", "error"]),
19741
+ error: codexhostErrorSchema
19581
19742
  }).strict();
19582
- var harnessSessionImportResultSchema = external_exports.object({
19583
- threadId: nonBlankTextSchema4.max(1024).pipe(hostThreadIdSchema)
19743
+ var harnessInspectionSchema = external_exports.union([
19744
+ readyHarnessInspectionSchema,
19745
+ failedHarnessInspectionSchema
19746
+ ]);
19747
+ var harnessInspectParamsSchema = external_exports.object({
19748
+ harnessId: harnessIdSchema,
19749
+ cwd: nonBlankTextSchema2.max(16384).optional(),
19750
+ refresh: external_exports.boolean().optional()
19584
19751
  }).strict();
19585
-
19586
- // ../../shared-contracts/dist/deepseek-modern-sessions.js
19587
- var DEEPSEEK_MODERN_SESSION_LIST_MAX_LENGTH = HARNESS_SESSION_IMPORT_LIST_MAX_LENGTH;
19588
- var DEEPSEEK_MODERN_HOST_THREAD_ID_MAX_LENGTH = 1024;
19589
- var nonBlankTextSchema5 = external_exports.string().refine((value) => value.trim().length > 0, "Value must not be empty or whitespace").refine((value) => !value.includes("\0"), "Value must not contain NUL");
19590
- var deepSeekModernSessionIdSchema = harnessSessionImportIdSchema;
19591
- var deepSeekModernSessionCandidateSchema = harnessSessionImportCandidateSchema;
19592
- var deepSeekModernSessionListParamsSchema = external_exports.object({}).strict();
19593
- var deepSeekModernSessionListResultSchema = external_exports.object({
19594
- candidates: external_exports.array(deepSeekModernSessionCandidateSchema).max(DEEPSEEK_MODERN_SESSION_LIST_MAX_LENGTH)
19752
+ var harnessWebUiOpenParamsSchema = external_exports.object({
19753
+ harnessId: harnessIdSchema
19595
19754
  }).strict();
19596
- var deepSeekModernSessionImportParamsSchema = external_exports.object({
19597
- nativeSessionId: deepSeekModernSessionIdSchema
19755
+ var harnessWebUiOpenResultSchema = external_exports.object({}).strict();
19756
+ var threadModelSelectParamsSchema = external_exports.object({
19757
+ threadId: hostThreadIdSchema,
19758
+ model: harnessModelRefSchema
19598
19759
  }).strict();
19599
- var deepSeekModernSessionImportResultSchema = external_exports.object({
19600
- threadId: nonBlankTextSchema5.max(DEEPSEEK_MODERN_HOST_THREAD_ID_MAX_LENGTH).pipe(hostThreadIdSchema)
19760
+ var threadThinkingSelectParamsSchema = external_exports.object({
19761
+ threadId: hostThreadIdSchema,
19762
+ thinkingOptionId: harnessThinkingOptionIdSchema
19601
19763
  }).strict();
19602
-
19603
- // ../../shared-contracts/dist/external-thread-fork.js
19604
- var externalThreadForkParamsSchema = external_exports.object({
19764
+ var threadInspectionParamsSchema = external_exports.object({
19605
19765
  threadId: hostThreadIdSchema,
19606
- lastTurnId: hostTurnIdSchema
19766
+ includeReferenceCapability: external_exports.boolean().optional()
19607
19767
  }).strict();
19608
- var externalThreadForkResultSchema = external_exports.object({
19609
- threadId: hostThreadIdSchema
19768
+ var codexThreadInspectionSchema = external_exports.object({
19769
+ owner: external_exports.literal("codex"),
19770
+ locked: external_exports.literal(true),
19771
+ supportsThreadReferences: external_exports.literal(true).optional()
19610
19772
  }).strict();
19611
-
19612
- // ../../shared-contracts/dist/harness-commands.js
19613
- var commandIdSchema = external_exports.string().trim().min(1).max(128).regex(/^[A-Za-z0-9._:-]+$/u).brand();
19614
- var commandInvocationSchema = external_exports.string().min(1).max(128);
19615
- var commandLabelSchema = external_exports.string().trim().min(1).max(128);
19616
- var commandDescriptionSchema = external_exports.string().trim().min(1).max(512);
19617
- var harnessCommandDescriptorSchema = external_exports.object({
19618
- id: commandIdSchema,
19619
- invocation: commandInvocationSchema,
19620
- label: commandLabelSchema,
19621
- description: commandDescriptionSchema.optional(),
19622
- argumentMode: external_exports.enum(["none", "text"]),
19623
- /**
19624
- * Native distinction reported by the Harness. Omitted when the Harness does
19625
- * not tell skills and commands apart; consumers treat that as "command".
19626
- */
19627
- kind: external_exports.enum(["command", "skill"]).optional()
19773
+ var externalThreadInspectionSchema = external_exports.object({
19774
+ owner: external_exports.literal("external"),
19775
+ harnessId: nonBlankTextSchema2.max(256),
19776
+ transportModelId: nonBlankTextSchema2.max(1024),
19777
+ effectiveModel: harnessModelRefSchema.optional(),
19778
+ resolvedModelLabel: harnessResolvedModelLabelSchema.optional(),
19779
+ effectiveThinkingOptionId: harnessThinkingOptionIdSchema.optional(),
19780
+ availableThinkingOptions: harnessThinkingOptionsSchema.optional(),
19781
+ effectivePermissionModeId: harnessPermissionModeIdSchema.optional(),
19782
+ history: harnessHistoryCapabilitiesSchema,
19783
+ usage: threadUsageSnapshotSchema.optional(),
19784
+ /** True when the thread is a read-only child thread materialized for a subagent. */
19785
+ subagent: external_exports.boolean().optional(),
19786
+ locked: external_exports.literal(true)
19628
19787
  }).strict();
19629
- var harnessCommandCatalogSchema = external_exports.object({
19630
- commands: external_exports.array(harnessCommandDescriptorSchema),
19631
- /**
19632
- * `live` when the catalog includes what a native Session reports for its
19633
- * workspace (custom commands, skills); `static` for Adapter built-ins only.
19634
- * Omitted by Adapters; set by the Host on inspection results.
19635
- */
19636
- source: external_exports.enum(["live", "static"]).optional()
19637
- }).strict().superRefine((catalog, context) => {
19638
- const ids = /* @__PURE__ */ new Set();
19639
- for (const [index, command] of catalog.commands.entries()) {
19640
- if (ids.has(command.id)) {
19788
+ var threadInspectionSchema = external_exports.discriminatedUnion("owner", [
19789
+ codexThreadInspectionSchema,
19790
+ externalThreadInspectionSchema
19791
+ ]);
19792
+ var threadOwnershipListParamsSchema = external_exports.object({
19793
+ threadIds: external_exports.array(hostThreadIdSchema).min(1).max(THREAD_OWNERSHIP_LIST_MAX_LENGTH)
19794
+ }).strict().superRefine(({ threadIds }, context) => {
19795
+ const seen = /* @__PURE__ */ new Set();
19796
+ for (const [index, threadId] of threadIds.entries()) {
19797
+ if (seen.has(threadId)) {
19641
19798
  context.addIssue({
19642
19799
  code: "custom",
19643
- message: "Harness command IDs must be unique",
19644
- path: ["commands", index, "id"]
19800
+ message: "Thread ownership-list IDs must be unique",
19801
+ path: ["threadIds", index]
19645
19802
  });
19646
19803
  }
19647
- ids.add(command.id);
19804
+ seen.add(threadId);
19648
19805
  }
19649
19806
  });
19650
- var harnessCommandsInspectParamsSchema = external_exports.object({
19651
- harnessId: harnessIdSchema,
19652
- /** Workspace of a draft without a Thread, for its live catalog when known. */
19653
- cwd: external_exports.string().min(1).optional()
19654
- }).strict();
19655
- var threadCommandsInspectParamsSchema = external_exports.object({
19656
- threadId: hostThreadIdSchema
19657
- }).strict();
19658
- var threadCommandExecuteParamsSchema = external_exports.object({
19807
+ var codexThreadOwnershipSchema = external_exports.object({
19659
19808
  threadId: hostThreadIdSchema,
19660
- commandId: commandIdSchema,
19661
- turnId: hostTurnIdSchema.optional(),
19662
- arguments: jsonObjectSchema.optional()
19809
+ owner: external_exports.literal("codex")
19663
19810
  }).strict();
19664
- var threadCommandExecuteResultSchema = external_exports.object({
19665
- accepted: external_exports.literal(true),
19666
- turnId: hostTurnIdSchema
19811
+ var externalThreadOwnershipSchema = external_exports.object({
19812
+ threadId: hostThreadIdSchema,
19813
+ owner: external_exports.literal("external"),
19814
+ harnessId: external_exports.string().max(256).pipe(harnessIdSchema)
19667
19815
  }).strict();
19668
-
19669
- // ../../shared-contracts/dist/json-rpc.js
19670
- var jsonRpcVersionSchema = external_exports.literal("2.0").optional();
19671
- var absentSchema = external_exports.never().optional();
19672
- var methodSchema = external_exports.string().min(1);
19673
- var jsonRpcIdSchema = external_exports.union([external_exports.string(), external_exports.number().int()]);
19674
- var jsonRpcErrorSchema = external_exports.object({
19675
- code: external_exports.number().int(),
19676
- message: external_exports.string(),
19677
- data: jsonValueSchema.optional()
19678
- }).catchall(jsonValueSchema).superRefine(rejectExplicitUndefined(["data"]));
19679
- var jsonRpcRequestSchema = external_exports.object({
19680
- jsonrpc: jsonRpcVersionSchema,
19681
- id: jsonRpcIdSchema,
19682
- method: methodSchema,
19683
- params: jsonValueSchema.optional(),
19684
- result: absentSchema,
19685
- error: absentSchema
19686
- }).catchall(jsonValueSchema).superRefine(rejectExplicitUndefined(["jsonrpc", "params", "result", "error"]));
19687
- var jsonRpcNotificationSchema = external_exports.object({
19688
- jsonrpc: jsonRpcVersionSchema,
19689
- id: absentSchema,
19690
- method: methodSchema,
19691
- params: jsonValueSchema.optional(),
19692
- result: absentSchema,
19693
- error: absentSchema
19694
- }).catchall(jsonValueSchema).superRefine(rejectExplicitUndefined(["jsonrpc", "id", "params", "result", "error"]));
19695
- var jsonRpcSuccessResponseSchema = external_exports.object({
19696
- jsonrpc: jsonRpcVersionSchema,
19697
- id: jsonRpcIdSchema,
19698
- method: absentSchema,
19699
- params: absentSchema,
19700
- result: jsonValueSchema,
19701
- error: absentSchema
19702
- }).catchall(jsonValueSchema).superRefine(rejectExplicitUndefined(["jsonrpc", "method", "params", "error"]));
19703
- var jsonRpcErrorResponseSchema = external_exports.object({
19704
- jsonrpc: jsonRpcVersionSchema,
19705
- id: jsonRpcIdSchema,
19706
- method: absentSchema,
19707
- params: absentSchema,
19708
- result: absentSchema,
19709
- error: jsonRpcErrorSchema
19710
- }).catchall(jsonValueSchema).superRefine(rejectExplicitUndefined(["jsonrpc", "method", "params", "result"]));
19711
- var jsonRpcEnvelopeSchema = external_exports.union([
19712
- jsonRpcRequestSchema,
19713
- jsonRpcNotificationSchema,
19714
- jsonRpcSuccessResponseSchema,
19715
- jsonRpcErrorResponseSchema
19716
- ]);
19717
-
19718
- // ../../shared-contracts/dist/native-refs.js
19719
- var nativeIdSchema = external_exports.string().refine((value) => value.trim().length > 0, {
19720
- message: "Native identifier must not be empty or whitespace"
19721
- });
19722
- var nativeSessionRefV1RuntimeSchema = external_exports.strictObject({
19723
- harnessId: harnessIdSchema,
19724
- nativeSessionId: nativeIdSchema,
19725
- locator: jsonValueSchema.optional(),
19726
- formatVersion: external_exports.literal(1)
19727
- }).superRefine(rejectExplicitUndefined(["locator"]));
19728
- var nativeSessionRefV1Schema = nativeSessionRefV1RuntimeSchema;
19729
- var nativeSessionRefSchema = nativeSessionRefV1Schema;
19730
- var nativeTurnRefV1Schema = external_exports.strictObject({
19731
- harnessId: harnessIdSchema,
19732
- nativeSessionId: nativeIdSchema,
19733
- nativeTurnKey: nativeIdSchema,
19734
- formatVersion: external_exports.literal(1)
19735
- });
19736
- var nativeTurnRefSchema = nativeTurnRefV1Schema;
19737
- var nativeCheckpointRefV1RuntimeSchema = external_exports.strictObject({
19738
- harnessId: harnessIdSchema,
19739
- nativeSessionId: nativeIdSchema,
19740
- checkpointId: nativeIdSchema,
19741
- locator: jsonValueSchema.optional(),
19742
- formatVersion: external_exports.literal(1)
19743
- }).superRefine(rejectExplicitUndefined(["locator"]));
19744
- var nativeCheckpointRefV1Schema = nativeCheckpointRefV1RuntimeSchema;
19745
- var nativeCheckpointRefSchema = nativeCheckpointRefV1Schema;
19746
-
19747
- // ../../shared-contracts/dist/updates.js
19748
- var UPDATE_ERROR_MAX_LENGTH = 500;
19749
- var UPDATE_SEMVER_PATTERN = /^\d+\.\d+\.\d+(?:-[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?(?:\+[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?$/u;
19750
- var updateSemanticVersionSchema = external_exports.string().regex(UPDATE_SEMVER_PATTERN);
19751
- var updateInstallationSchema = external_exports.enum(["npm", "windows-installer", "macos-dmg"]);
19752
- var updatePhaseSchema = external_exports.enum([
19753
- "prepared",
19754
- "downloading",
19755
- "waiting-for-exit",
19756
- "installing",
19757
- "restarting",
19758
- "succeeded",
19759
- "failed"
19816
+ var threadOwnershipSchema = external_exports.discriminatedUnion("owner", [
19817
+ codexThreadOwnershipSchema,
19818
+ externalThreadOwnershipSchema
19760
19819
  ]);
19761
- var updateStatusSchema = external_exports.strictObject({
19762
- version: updateSemanticVersionSchema,
19763
- installation: updateInstallationSchema,
19764
- phase: updatePhaseSchema,
19765
- updatedAt: external_exports.number().int().nonnegative(),
19766
- downloadedBytes: external_exports.number().int().nonnegative().optional(),
19767
- totalBytes: external_exports.number().int().positive().optional(),
19768
- error: external_exports.string().min(1).max(UPDATE_ERROR_MAX_LENGTH).nullable()
19769
- }).superRefine((status, context) => {
19770
- if (status.downloadedBytes !== void 0 && status.totalBytes !== void 0 && status.downloadedBytes > status.totalBytes) {
19771
- context.addIssue({
19772
- code: "custom",
19773
- path: ["downloadedBytes"],
19774
- message: "downloadedBytes must not exceed totalBytes"
19775
- });
19776
- }
19777
- });
19778
- var updateEmptyParamsSchema = external_exports.strictObject({});
19779
- 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");
19780
- var updateCheckResultSchema = external_exports.strictObject({
19781
- currentVersion: updateSemanticVersionSchema,
19782
- installation: updateInstallationSchema.nullable(),
19783
- latestVersion: updateSemanticVersionSchema.nullable(),
19784
- updateAvailable: external_exports.boolean(),
19785
- installationAvailable: external_exports.boolean(),
19786
- releaseNotes: external_exports.string().min(1).max(2e4).nullable(),
19787
- releaseNotesUrl: githubReleaseNotesUrlSchema.nullable(),
19788
- status: updateStatusSchema.nullable(),
19789
- error: external_exports.string().min(1).max(UPDATE_ERROR_MAX_LENGTH).nullable()
19790
- });
19791
- var updateStartResultSchema = external_exports.strictObject({
19792
- status: updateStatusSchema
19820
+ var threadOwnershipListResultSchema = external_exports.object({
19821
+ threads: external_exports.array(threadOwnershipSchema).min(1).max(THREAD_OWNERSHIP_LIST_MAX_LENGTH)
19822
+ }).strict().superRefine(({ threads }, context) => {
19823
+ const seen = /* @__PURE__ */ new Set();
19824
+ for (const [index, thread] of threads.entries()) {
19825
+ if (seen.has(thread.threadId)) {
19826
+ context.addIssue({
19827
+ code: "custom",
19828
+ message: "Thread ownership-list results must be unique",
19829
+ path: ["threads", index, "threadId"]
19830
+ });
19831
+ }
19832
+ seen.add(thread.threadId);
19833
+ }
19793
19834
  });
19794
- var updateStatusResultSchema = external_exports.strictObject({
19795
- status: updateStatusSchema.nullable()
19835
+
19836
+ // ../../shared-contracts/dist/harness-route.js
19837
+ var harnessPluginRouteSchema = external_exports.object({
19838
+ harnessId: harnessPluginIdSchema,
19839
+ model: harnessModelRefSchema.optional(),
19840
+ thinkingOptionId: harnessThinkingOptionIdSchema.optional(),
19841
+ permissionModeId: harnessPermissionModeIdSchema.optional()
19842
+ }).strict();
19843
+
19844
+ // ../../shared-contracts/dist/harness-launch-settings.js
19845
+ var harnessLaunchPathSchema = external_exports.string().trim().min(1).max(4096).refine((value) => !/[\u0000\r\n]/u.test(value), "Invalid entrypoint path");
19846
+ var harnessLaunchSettingsGetSchema = external_exports.object({
19847
+ harnessId: harnessPluginIdSchema
19848
+ }).strict();
19849
+ var harnessLaunchSettingsSetSchema = harnessLaunchSettingsGetSchema.extend({
19850
+ path: harnessLaunchPathSchema.nullable()
19796
19851
  });
19852
+ var harnessLaunchSettingsSchema = external_exports.object({
19853
+ path: harnessLaunchPathSchema.nullable(),
19854
+ restartRequired: external_exports.boolean()
19855
+ }).strict();
19797
19856
 
19798
- // ../../shared-contracts/dist/index.js
19799
- var workspaceContractVersionSchema = external_exports.literal(WORKSPACE_CONTRACT_VERSION);
19857
+ // ../../shared-contracts/dist/harness-installation.js
19858
+ var harnessInstallationParamsSchema = external_exports.object({
19859
+ harnessId: harnessIdSchema,
19860
+ action: external_exports.enum(["check", "update", "install"])
19861
+ }).strict();
19862
+ var harnessInstallationStateSchema = external_exports.object({
19863
+ currentVersion: external_exports.string().min(1).max(128),
19864
+ latestVersion: external_exports.string().min(1).max(128),
19865
+ updateAvailable: external_exports.boolean(),
19866
+ canUpdate: external_exports.boolean(),
19867
+ message: external_exports.string().max(2048).optional()
19868
+ }).strict();
19800
19869
 
19801
- // ../../harness-adapter/dist/approval.js
19802
- function invalidRequest(message) {
19803
- return { code: "invalidRequest", message, retryable: false };
19804
- }
19805
- function validateHostApprovalResponse(interaction, response) {
19806
- return interaction.actions.some(({ id }) => id === response.actionId) ? null : invalidRequest("Approval Response contains an undeclared action ID");
19870
+ // ../../shared-contracts/dist/codex-accounts.js
19871
+ var accountIdSchema = external_exports.string().min(1).max(256).regex(/^[A-Za-z0-9._~-]+$/u);
19872
+ var nonBlankTextSchema3 = external_exports.string().trim().min(1);
19873
+ var codexAccountAuthKindSchema = external_exports.enum(["api", "chatgpt"]);
19874
+ var codexAccountSiteUrlPattern = /^https?:\/\/(?:\[[0-9a-fA-F:]+\]|[^/\s:@?#]+)(?::\d{1,5})?(?:[/?#][^\s]*)?$/u;
19875
+ function isCodexAccountSiteUrl(value) {
19876
+ return value.length > 0 && value.length <= 2048 && codexAccountSiteUrlPattern.test(value);
19807
19877
  }
19878
+ var externalUrlOpenParamsSchema = external_exports.object({
19879
+ url: external_exports.string().max(2048).refine(isCodexAccountSiteUrl, "External URL must be http(s)")
19880
+ }).strict();
19881
+ var externalUrlOpenResultSchema = external_exports.object({}).strict();
19882
+ var codexAccountPlanTypeSchema = external_exports.enum([
19883
+ "free",
19884
+ "go",
19885
+ "plus",
19886
+ "pro",
19887
+ "prolite",
19888
+ "team",
19889
+ "self_serve_business_prolite",
19890
+ "self_serve_business_usage_based",
19891
+ "business",
19892
+ "ent26",
19893
+ "enterprise_cbp_automation",
19894
+ "enterprise_cbp_usage_based",
19895
+ "enterprise",
19896
+ "edu",
19897
+ "edu_plus",
19898
+ "edu_pro",
19899
+ "unknown"
19900
+ ]);
19901
+ var codexAccountSchema = external_exports.object({
19902
+ accountId: accountIdSchema,
19903
+ label: nonBlankTextSchema3.max(256),
19904
+ email: external_exports.string().email().max(320).optional(),
19905
+ planType: codexAccountPlanTypeSchema.optional(),
19906
+ authKind: codexAccountAuthKindSchema.optional(),
19907
+ authIdentity: nonBlankTextSchema3.max(256).optional(),
19908
+ siteUrl: external_exports.string().refine(isCodexAccountSiteUrl, "Account site URL must be http(s)").optional()
19909
+ }).strict();
19910
+ var codexAccountPhaseSchema = external_exports.enum(["ready", "unavailable"]);
19911
+ var codexAccountListResultSchema = external_exports.object({
19912
+ version: external_exports.literal(2),
19913
+ currentAccountId: accountIdSchema.nullable(),
19914
+ phase: codexAccountPhaseSchema,
19915
+ revision: external_exports.number().int().nonnegative(),
19916
+ instanceId: nonBlankTextSchema3.max(1024).optional(),
19917
+ accounts: external_exports.array(codexAccountSchema).max(1)
19918
+ }).strict();
19919
+ var codexAccountUsageParamsSchema = external_exports.object({ accountId: accountIdSchema, refresh: external_exports.boolean().optional() }).strict();
19920
+ var codexAccountUsageResultSchema = external_exports.object({
19921
+ accountId: accountIdSchema,
19922
+ usage: threadUsageSnapshotSchema.nullable(),
19923
+ accountCredits: accountCreditsSnapshotSchema.optional(),
19924
+ freshness: external_exports.enum(["live", "cached"]),
19925
+ observedAt: external_exports.string().datetime().nullable()
19926
+ }).strict();
19808
19927
 
19809
- // ../../harness-adapter/dist/question.js
19810
- function invalidRequest2(message) {
19811
- return { code: "invalidRequest", message, retryable: false };
19812
- }
19813
- function validateHostQuestionResponse(interaction, response) {
19814
- const questionIds = new Set(interaction.questions.map(({ id }) => id));
19815
- if (response.cancelled) {
19816
- return Object.keys(response.answers).length === 0 ? null : invalidRequest2("Cancelled Question Response must not contain answers");
19817
- }
19818
- for (const answerId of Object.keys(response.answers)) {
19819
- if (!questionIds.has(answerId)) {
19820
- return invalidRequest2("Question Response contains an unknown Question ID");
19821
- }
19822
- }
19823
- for (const question of interaction.questions) {
19824
- const answers = response.answers[question.id] ?? [];
19825
- if (!question.optional && answers.length === 0) {
19826
- return invalidRequest2("Question Response omits a required answer");
19827
- }
19828
- if (question.type === "text") {
19829
- if (answers.length > 1) {
19830
- return invalidRequest2("Text Question accepts at most one answer");
19831
- }
19832
- continue;
19833
- }
19834
- if (!question.multiple && answers.length > 1) {
19835
- return invalidRequest2("Single-choice Question accepts at most one answer");
19836
- }
19837
- const declared = new Set(question.options.map(({ value }) => value));
19838
- if (!question.allowOther && answers.some((answer) => !declared.has(answer))) {
19839
- return invalidRequest2("Question Response contains an undeclared choice");
19840
- }
19841
- }
19842
- return null;
19843
- }
19928
+ // ../../shared-contracts/dist/harness-session-import.js
19929
+ var HARNESS_SESSION_IMPORT_ID_MAX_LENGTH = 1024;
19930
+ var HARNESS_SESSION_IMPORT_CWD_MAX_LENGTH = 16384;
19931
+ var HARNESS_SESSION_IMPORT_TITLE_MAX_LENGTH = 4096;
19932
+ var HARNESS_SESSION_IMPORT_LIST_MAX_LENGTH = 1e3;
19933
+ var HARNESS_SESSION_IMPORT_UPDATED_AT_MAX = 864e13;
19934
+ var nonBlankTextSchema4 = external_exports.string().refine((value) => value.trim().length > 0, "Value must not be empty or whitespace").refine((value) => !value.includes("\0"), "Value must not contain NUL");
19935
+ var harnessSessionImportIdSchema = nonBlankTextSchema4.max(HARNESS_SESSION_IMPORT_ID_MAX_LENGTH);
19936
+ var harnessSessionImportCandidateSchema = external_exports.object({
19937
+ nativeSessionId: harnessSessionImportIdSchema,
19938
+ title: nonBlankTextSchema4.max(HARNESS_SESSION_IMPORT_TITLE_MAX_LENGTH).nullable(),
19939
+ updatedAt: external_exports.number().int().nonnegative().max(HARNESS_SESSION_IMPORT_UPDATED_AT_MAX),
19940
+ cwd: nonBlankTextSchema4.max(HARNESS_SESSION_IMPORT_CWD_MAX_LENGTH),
19941
+ // Native file discovery cannot reliably observe another process's activity.
19942
+ running: external_exports.boolean().nullable()
19943
+ }).strict();
19944
+ var harnessSessionImportSourcesParamsSchema = external_exports.object({}).strict();
19945
+ var harnessSessionImportSourcesResultSchema = external_exports.object({
19946
+ harnesses: external_exports.array(external_exports.object({
19947
+ harnessId: harnessPluginIdSchema,
19948
+ name: nonBlankTextSchema4.max(128)
19949
+ }).strict()).max(128)
19950
+ }).strict();
19951
+ var harnessSessionListParamsSchema = external_exports.object({
19952
+ harnessId: harnessPluginIdSchema,
19953
+ query: external_exports.string().trim().max(4096).refine((value) => !value.includes("\0")).optional(),
19954
+ offset: external_exports.number().int().nonnegative().safe().optional(),
19955
+ limit: external_exports.number().int().min(1).max(HARNESS_SESSION_IMPORT_LIST_MAX_LENGTH).optional()
19956
+ }).strict();
19957
+ var harnessSessionListResultSchema = external_exports.object({
19958
+ candidates: external_exports.array(harnessSessionImportCandidateSchema).max(HARNESS_SESSION_IMPORT_LIST_MAX_LENGTH),
19959
+ total: external_exports.number().int().nonnegative().safe()
19960
+ }).strict();
19961
+ var harnessSessionImportParamsSchema = external_exports.object({
19962
+ harnessId: harnessPluginIdSchema,
19963
+ nativeSessionId: harnessSessionImportIdSchema
19964
+ }).strict();
19965
+ var harnessSessionImportResultSchema = external_exports.object({
19966
+ threadId: nonBlankTextSchema4.max(1024).pipe(hostThreadIdSchema)
19967
+ }).strict();
19844
19968
 
19845
- // ../../harness-adapter/dist/output-channel.js
19846
- var HarnessOutputChannel = class {
19847
- outputs;
19848
- #consumerCreated = false;
19849
- #ended = false;
19850
- #pending = [];
19851
- #values = [];
19852
- constructor() {
19853
- this.outputs = {
19854
- [Symbol.asyncIterator]: () => {
19855
- if (this.#consumerCreated) {
19856
- throw new Error("Harness outputs allow only one consumer");
19857
- }
19858
- this.#consumerCreated = true;
19859
- return {
19860
- next: () => this.#next()
19861
- };
19862
- }
19863
- };
19864
- }
19865
- emit(value) {
19866
- if (this.#ended)
19867
- return false;
19868
- const resolve = this.#pending.shift();
19869
- if (resolve)
19870
- resolve({ done: false, value });
19871
- else
19872
- this.#values.push(value);
19873
- return true;
19874
- }
19875
- end() {
19876
- if (this.#ended)
19877
- return;
19878
- this.#ended = true;
19879
- if (this.#values.length !== 0)
19880
- return;
19881
- for (const resolve of this.#pending.splice(0))
19882
- resolve({ done: true, value: void 0 });
19883
- }
19884
- #next() {
19885
- const value = this.#values.shift();
19886
- if (value !== void 0)
19887
- return Promise.resolve({ done: false, value });
19888
- if (this.#ended)
19889
- return Promise.resolve({ done: true, value: void 0 });
19890
- return new Promise((resolve) => this.#pending.push(resolve));
19891
- }
19892
- };
19969
+ // ../../shared-contracts/dist/deepseek-modern-sessions.js
19970
+ var DEEPSEEK_MODERN_SESSION_LIST_MAX_LENGTH = HARNESS_SESSION_IMPORT_LIST_MAX_LENGTH;
19971
+ var DEEPSEEK_MODERN_HOST_THREAD_ID_MAX_LENGTH = 1024;
19972
+ var nonBlankTextSchema5 = external_exports.string().refine((value) => value.trim().length > 0, "Value must not be empty or whitespace").refine((value) => !value.includes("\0"), "Value must not contain NUL");
19973
+ var deepSeekModernSessionIdSchema = harnessSessionImportIdSchema;
19974
+ var deepSeekModernSessionCandidateSchema = harnessSessionImportCandidateSchema;
19975
+ var deepSeekModernSessionListParamsSchema = external_exports.object({}).strict();
19976
+ var deepSeekModernSessionListResultSchema = external_exports.object({
19977
+ candidates: external_exports.array(deepSeekModernSessionCandidateSchema).max(DEEPSEEK_MODERN_SESSION_LIST_MAX_LENGTH)
19978
+ }).strict();
19979
+ var deepSeekModernSessionImportParamsSchema = external_exports.object({
19980
+ nativeSessionId: deepSeekModernSessionIdSchema
19981
+ }).strict();
19982
+ var deepSeekModernSessionImportResultSchema = external_exports.object({
19983
+ threadId: nonBlankTextSchema5.max(DEEPSEEK_MODERN_HOST_THREAD_ID_MAX_LENGTH).pipe(hostThreadIdSchema)
19984
+ }).strict();
19893
19985
 
19894
- // ../../harness-adapter/dist/diagnostics.js
19895
- var DIAGNOSTIC_TAIL_MAX_LENGTH = 8e3;
19896
- var SENSITIVE_VALUE_PATTERN = /(api[_-]?key|access[_-]?token|auth(?:orization)?|password|secret)(\s*[:=]\s*)([^\s,;]+)/giu;
19897
- var BEARER_PATTERN = /\bBearer\s+[A-Za-z0-9._~+/=-]+/giu;
19898
- function sanitizeDiagnosticTail(value) {
19899
- const redacted = value.replace(BEARER_PATTERN, "Bearer [redacted]").replace(SENSITIVE_VALUE_PATTERN, "$1$2[redacted]");
19900
- return redacted.length <= DIAGNOSTIC_TAIL_MAX_LENGTH ? redacted : redacted.slice(-DIAGNOSTIC_TAIL_MAX_LENGTH);
19901
- }
19986
+ // ../../shared-contracts/dist/external-thread-fork.js
19987
+ var externalThreadForkParamsSchema = external_exports.object({
19988
+ threadId: hostThreadIdSchema,
19989
+ lastTurnId: hostTurnIdSchema
19990
+ }).strict();
19991
+ var externalThreadForkResultSchema = external_exports.object({
19992
+ threadId: hostThreadIdSchema
19993
+ }).strict();
19902
19994
 
19903
- // ../../harness-adapter/dist/usage.js
19904
- var tokenFields = [
19905
- "inputTokens",
19906
- "cachedInputTokens",
19907
- "cacheWriteInputTokens",
19908
- "outputTokens",
19909
- "outputTokensPerSecond",
19910
- "reasoningOutputTokens",
19911
- "totalTokens",
19912
- "contextWindowTokens",
19913
- "contextUsedTokens"
19914
- ];
19915
- var safeIntegerFields = [
19916
- "planFiveHourResetsAtUnix",
19917
- "planSevenDayResetsAtUnix"
19918
- ];
19919
- var percentFields = [
19920
- "cacheHitRatePercent",
19921
- "planFiveHourUsedPercent",
19922
- "planSevenDayUsedPercent"
19923
- ];
19924
- var usageFields = /* @__PURE__ */ new Set([
19925
- ...tokenFields,
19926
- ...safeIntegerFields,
19927
- ...percentFields,
19928
- "totalCostUsd",
19929
- "totalCredits",
19930
- "contextUsagePercent"
19931
- ]);
19932
- function isRecord2(value) {
19933
- return typeof value === "object" && value !== null && !Array.isArray(value);
19934
- }
19935
- function parseHostUsage(value) {
19936
- if (!isRecord2(value))
19937
- throw new Error("Harness Usage must be an object");
19938
- const keys = Object.keys(value);
19939
- if (keys.length === 0)
19940
- throw new Error("Harness Usage must contain a reliable field");
19941
- for (const key of keys) {
19942
- if (!usageFields.has(key)) {
19943
- throw new Error(`Harness Usage contains unknown field '${key}'`);
19944
- }
19945
- }
19946
- for (const field of ["totalCredits", "contextUsagePercent"]) {
19947
- const candidate = value[field];
19948
- if (candidate !== void 0 && (typeof candidate !== "number" || !Number.isFinite(candidate) || candidate < 0)) {
19949
- throw new Error(`Harness Usage '${field}' must be a finite non-negative number`);
19950
- }
19951
- }
19952
- for (const field of tokenFields) {
19953
- const candidate = value[field];
19954
- if (candidate !== void 0 && (typeof candidate !== "number" || !Number.isSafeInteger(candidate) || candidate < 0)) {
19955
- throw new Error(`Harness Usage '${field}' must be a non-negative safe integer`);
19956
- }
19957
- }
19958
- for (const field of safeIntegerFields) {
19959
- const candidate = value[field];
19960
- if (candidate !== void 0 && (typeof candidate !== "number" || !Number.isSafeInteger(candidate) || candidate < 0)) {
19961
- throw new Error(`Harness Usage '${field}' must be a non-negative safe integer`);
19962
- }
19963
- }
19964
- if (value.outputTokensPerSecond !== void 0 && (typeof value.outputTokensPerSecond !== "number" || !Number.isFinite(value.outputTokensPerSecond) || value.outputTokensPerSecond < 0)) {
19965
- throw new Error("Harness Usage 'outputTokensPerSecond' must be a finite non-negative number");
19966
- }
19967
- if (value.totalCostUsd !== void 0 && (typeof value.totalCostUsd !== "number" || !Number.isFinite(value.totalCostUsd) || value.totalCostUsd < 0)) {
19968
- throw new Error("Harness Usage 'totalCostUsd' must be a finite non-negative number");
19969
- }
19970
- for (const field of ["totalCredits", "contextUsagePercent"]) {
19971
- const candidate = value[field];
19972
- if (candidate !== void 0 && (typeof candidate !== "number" || !Number.isFinite(candidate) || candidate < 0)) {
19973
- throw new Error(`Harness Usage '${field}' must be a finite non-negative number`);
19974
- }
19975
- }
19976
- for (const field of percentFields) {
19977
- const candidate = value[field];
19978
- if (candidate !== void 0 && (typeof candidate !== "number" || !Number.isFinite(candidate) || candidate < 0 || candidate > 100)) {
19979
- throw new Error(`Harness Usage '${field}' must be between 0 and 100`);
19995
+ // ../../shared-contracts/dist/harness-commands.js
19996
+ var commandIdSchema = external_exports.string().trim().min(1).max(128).regex(/^[A-Za-z0-9._:-]+$/u).brand();
19997
+ var commandInvocationSchema = external_exports.string().min(1).max(128);
19998
+ var commandLabelSchema = external_exports.string().trim().min(1).max(128);
19999
+ var commandDescriptionSchema = external_exports.string().trim().min(1).max(512);
20000
+ var harnessCommandDescriptorSchema = external_exports.object({
20001
+ id: commandIdSchema,
20002
+ invocation: commandInvocationSchema,
20003
+ label: commandLabelSchema,
20004
+ description: commandDescriptionSchema.optional(),
20005
+ argumentMode: external_exports.enum(["none", "text"]),
20006
+ /**
20007
+ * Native distinction reported by the Harness. Omitted when the Harness does
20008
+ * not tell skills and commands apart; consumers treat that as "command".
20009
+ */
20010
+ kind: external_exports.enum(["command", "skill"]).optional()
20011
+ }).strict();
20012
+ var harnessCommandCatalogSchema = external_exports.object({
20013
+ commands: external_exports.array(harnessCommandDescriptorSchema),
20014
+ /**
20015
+ * `live` when the catalog includes what a native Session reports for its
20016
+ * workspace (custom commands, skills); `static` for Adapter built-ins only.
20017
+ * Omitted by Adapters; set by the Host on inspection results.
20018
+ */
20019
+ source: external_exports.enum(["live", "static"]).optional()
20020
+ }).strict().superRefine((catalog, context) => {
20021
+ const ids = /* @__PURE__ */ new Set();
20022
+ for (const [index, command] of catalog.commands.entries()) {
20023
+ if (ids.has(command.id)) {
20024
+ context.addIssue({
20025
+ code: "custom",
20026
+ message: "Harness command IDs must be unique",
20027
+ path: ["commands", index, "id"]
20028
+ });
19980
20029
  }
20030
+ ids.add(command.id);
19981
20031
  }
19982
- const hasContextUsed = value.contextUsedTokens !== void 0;
19983
- const hasContextWindow = value.contextWindowTokens !== void 0;
19984
- if (hasContextUsed !== hasContextWindow) {
19985
- throw new Error("Harness Usage context fields must be provided together");
19986
- }
19987
- if (hasContextWindow && value.contextWindowTokens === 0) {
19988
- throw new Error("Harness Usage 'contextWindowTokens' must be greater than zero");
19989
- }
19990
- if (value.planFiveHourResetsAtUnix !== void 0 && value.planFiveHourUsedPercent === void 0) {
19991
- throw new Error("Harness Usage 'planFiveHourResetsAtUnix' must be provided with 'planFiveHourUsedPercent'");
19992
- }
19993
- if (value.planSevenDayResetsAtUnix !== void 0 && value.planSevenDayUsedPercent === void 0) {
19994
- throw new Error("Harness Usage 'planSevenDayResetsAtUnix' must be provided with 'planSevenDayUsedPercent'");
19995
- }
19996
- return { ...value };
19997
- }
20032
+ });
20033
+ var harnessCommandsInspectParamsSchema = external_exports.object({
20034
+ harnessId: harnessIdSchema,
20035
+ /** Workspace of a draft without a Thread, for its live catalog when known. */
20036
+ cwd: external_exports.string().min(1).optional()
20037
+ }).strict();
20038
+ var threadCommandsInspectParamsSchema = external_exports.object({
20039
+ threadId: hostThreadIdSchema
20040
+ }).strict();
20041
+ var threadCommandExecuteParamsSchema = external_exports.object({
20042
+ threadId: hostThreadIdSchema,
20043
+ commandId: commandIdSchema,
20044
+ turnId: hostTurnIdSchema.optional(),
20045
+ arguments: jsonObjectSchema.optional()
20046
+ }).strict();
20047
+ var threadCommandExecuteResultSchema = external_exports.object({
20048
+ accepted: external_exports.literal(true),
20049
+ turnId: hostTurnIdSchema
20050
+ }).strict();
19998
20051
 
19999
- // ../../harness-adapter/dist/live-command-catalog.js
20000
- var COMMON_EXCLUDED_LIVE_COMMANDS = /* @__PURE__ */ new Set([
20001
- // Session lifecycle
20002
- "branch",
20003
- "clear",
20004
- "exit",
20005
- "fork",
20006
- "fresh",
20007
- "new",
20008
- "quit",
20009
- "rename",
20010
- "rename-chat",
20011
- "reset",
20012
- "resume",
20013
- "rewind",
20014
- "session",
20015
- "sessions",
20016
- // Desktop-owned configuration
20017
- "autocompact",
20018
- "color",
20019
- "config",
20020
- "effort",
20021
- "fast",
20022
- "keybindings",
20023
- "model",
20024
- "models",
20025
- "output-style",
20026
- "permissions",
20027
- "settings",
20028
- "statusline",
20029
- "terminal-setup",
20030
- "theme",
20031
- "vim",
20032
- // Trust and approval policy
20033
- "always-approve",
20034
- "auto-mode-setup",
20035
- // Native login
20036
- "login",
20037
- "logout",
20038
- // Work outliving the Turn
20039
- "autopilot",
20040
- "background",
20041
- "bg",
20042
- "goal",
20043
- "jobs",
20044
- "loop",
20045
- "multitask",
20046
- "queue",
20047
- "remote-control",
20048
- "schedule",
20049
- "steer",
20050
- // Native terminal UI
20051
- "copy",
20052
- "debug",
20053
- "feedback",
20054
- "heapdump",
20055
- "share",
20056
- "shell",
20057
- // Plugin and MCP management
20058
- "marketplace",
20059
- "mcp",
20060
- "plugins",
20061
- "reload-plugins"
20052
+ // ../../shared-contracts/dist/json-rpc.js
20053
+ var jsonRpcVersionSchema = external_exports.literal("2.0").optional();
20054
+ var absentSchema = external_exports.never().optional();
20055
+ var methodSchema = external_exports.string().min(1);
20056
+ var jsonRpcIdSchema = external_exports.union([external_exports.string(), external_exports.number().int()]);
20057
+ var jsonRpcErrorSchema = external_exports.object({
20058
+ code: external_exports.number().int(),
20059
+ message: external_exports.string(),
20060
+ data: jsonValueSchema.optional()
20061
+ }).catchall(jsonValueSchema).superRefine(rejectExplicitUndefined(["data"]));
20062
+ var jsonRpcRequestSchema = external_exports.object({
20063
+ jsonrpc: jsonRpcVersionSchema,
20064
+ id: jsonRpcIdSchema,
20065
+ method: methodSchema,
20066
+ params: jsonValueSchema.optional(),
20067
+ result: absentSchema,
20068
+ error: absentSchema
20069
+ }).catchall(jsonValueSchema).superRefine(rejectExplicitUndefined(["jsonrpc", "params", "result", "error"]));
20070
+ var jsonRpcNotificationSchema = external_exports.object({
20071
+ jsonrpc: jsonRpcVersionSchema,
20072
+ id: absentSchema,
20073
+ method: methodSchema,
20074
+ params: jsonValueSchema.optional(),
20075
+ result: absentSchema,
20076
+ error: absentSchema
20077
+ }).catchall(jsonValueSchema).superRefine(rejectExplicitUndefined(["jsonrpc", "id", "params", "result", "error"]));
20078
+ var jsonRpcSuccessResponseSchema = external_exports.object({
20079
+ jsonrpc: jsonRpcVersionSchema,
20080
+ id: jsonRpcIdSchema,
20081
+ method: absentSchema,
20082
+ params: absentSchema,
20083
+ result: jsonValueSchema,
20084
+ error: absentSchema
20085
+ }).catchall(jsonValueSchema).superRefine(rejectExplicitUndefined(["jsonrpc", "method", "params", "error"]));
20086
+ var jsonRpcErrorResponseSchema = external_exports.object({
20087
+ jsonrpc: jsonRpcVersionSchema,
20088
+ id: jsonRpcIdSchema,
20089
+ method: absentSchema,
20090
+ params: absentSchema,
20091
+ result: absentSchema,
20092
+ error: jsonRpcErrorSchema
20093
+ }).catchall(jsonValueSchema).superRefine(rejectExplicitUndefined(["jsonrpc", "method", "params", "result"]));
20094
+ var jsonRpcEnvelopeSchema = external_exports.union([
20095
+ jsonRpcRequestSchema,
20096
+ jsonRpcNotificationSchema,
20097
+ jsonRpcSuccessResponseSchema,
20098
+ jsonRpcErrorResponseSchema
20062
20099
  ]);
20063
- var COMMON_EXCLUDED_LIVE_COMMAND_PREFIXES = ["__", "hooks-"];
20064
- function isExcludedLiveCommand(name, kind, extra = {}) {
20065
- const normalized = name.trim().replace(/^\//u, "");
20066
- if (new Set(extra.names ?? []).has(normalized))
20067
- return true;
20068
- if (extra.prefixes?.some((prefix) => normalized.startsWith(prefix)))
20069
- return true;
20070
- if (kind === "skill")
20071
- return false;
20072
- return COMMON_EXCLUDED_LIVE_COMMANDS.has(normalized) || COMMON_EXCLUDED_LIVE_COMMAND_PREFIXES.some((prefix) => normalized.startsWith(prefix));
20073
- }
20074
- function liveHarnessCommandPrompt(catalog, idPrefix, commandId, argumentText) {
20075
- if (!commandId.startsWith(idPrefix))
20076
- return null;
20077
- const descriptor = catalog.commands.find(({ id }) => id === commandId);
20078
- if (!descriptor)
20079
- return null;
20080
- const text = typeof argumentText === "string" ? argumentText.trim() : "";
20081
- return text ? `${descriptor.invocation} ${text}` : descriptor.invocation;
20082
- }
20083
- function mergeLiveHarnessCommands(builtIns, idPrefix, live, exclusions = {}) {
20084
- if (!live)
20085
- return builtIns;
20086
- const invocations = new Set(builtIns.commands.map(({ invocation }) => invocation));
20087
- const ids = new Set(builtIns.commands.map(({ id }) => id));
20088
- const dynamic = [];
20089
- for (const command of live) {
20090
- const name = command.name.trim().replace(/^\//u, "");
20091
- if (!name || /\s/u.test(name))
20092
- continue;
20093
- if (isExcludedLiveCommand(name, command.kind, exclusions))
20094
- continue;
20095
- const invocation = `/${name}`;
20096
- const id = `${idPrefix}${name.replace(/[^A-Za-z0-9._:-]/gu, "-")}`.slice(0, 128);
20097
- if (invocations.has(invocation) || ids.has(id))
20098
- continue;
20099
- const description = command.description?.trim().slice(0, 512);
20100
- const parsed = harnessCommandDescriptorSchema.safeParse({
20101
- id,
20102
- invocation,
20103
- label: name.slice(0, 128),
20104
- ...description ? { description } : {},
20105
- argumentMode: "text",
20106
- kind: command.kind
20100
+
20101
+ // ../../shared-contracts/dist/native-refs.js
20102
+ var nativeIdSchema = external_exports.string().refine((value) => value.trim().length > 0, {
20103
+ message: "Native identifier must not be empty or whitespace"
20104
+ });
20105
+ var nativeSessionRefV1RuntimeSchema = external_exports.strictObject({
20106
+ harnessId: harnessIdSchema,
20107
+ nativeSessionId: nativeIdSchema,
20108
+ locator: jsonValueSchema.optional(),
20109
+ formatVersion: external_exports.literal(1)
20110
+ }).superRefine(rejectExplicitUndefined(["locator"]));
20111
+ var nativeSessionRefV1Schema = nativeSessionRefV1RuntimeSchema;
20112
+ var nativeSessionRefSchema = nativeSessionRefV1Schema;
20113
+ var nativeTurnRefV1Schema = external_exports.strictObject({
20114
+ harnessId: harnessIdSchema,
20115
+ nativeSessionId: nativeIdSchema,
20116
+ nativeTurnKey: nativeIdSchema,
20117
+ formatVersion: external_exports.literal(1)
20118
+ });
20119
+ var nativeTurnRefSchema = nativeTurnRefV1Schema;
20120
+ var nativeCheckpointRefV1RuntimeSchema = external_exports.strictObject({
20121
+ harnessId: harnessIdSchema,
20122
+ nativeSessionId: nativeIdSchema,
20123
+ checkpointId: nativeIdSchema,
20124
+ locator: jsonValueSchema.optional(),
20125
+ formatVersion: external_exports.literal(1)
20126
+ }).superRefine(rejectExplicitUndefined(["locator"]));
20127
+ var nativeCheckpointRefV1Schema = nativeCheckpointRefV1RuntimeSchema;
20128
+ var nativeCheckpointRefSchema = nativeCheckpointRefV1Schema;
20129
+
20130
+ // ../../shared-contracts/dist/updates.js
20131
+ var UPDATE_ERROR_MAX_LENGTH = 500;
20132
+ var UPDATE_SEMVER_PATTERN = /^\d+\.\d+\.\d+(?:-[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?(?:\+[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?$/u;
20133
+ var updateSemanticVersionSchema = external_exports.string().regex(UPDATE_SEMVER_PATTERN);
20134
+ var updateInstallationSchema = external_exports.enum(["npm", "windows-installer", "macos-dmg"]);
20135
+ var updatePhaseSchema = external_exports.enum([
20136
+ "prepared",
20137
+ "downloading",
20138
+ "waiting-for-exit",
20139
+ "installing",
20140
+ "restarting",
20141
+ "succeeded",
20142
+ "failed"
20143
+ ]);
20144
+ var updateStatusSchema = external_exports.strictObject({
20145
+ version: updateSemanticVersionSchema,
20146
+ installation: updateInstallationSchema,
20147
+ phase: updatePhaseSchema,
20148
+ updatedAt: external_exports.number().int().nonnegative(),
20149
+ downloadedBytes: external_exports.number().int().nonnegative().optional(),
20150
+ totalBytes: external_exports.number().int().positive().optional(),
20151
+ error: external_exports.string().min(1).max(UPDATE_ERROR_MAX_LENGTH).nullable()
20152
+ }).superRefine((status, context) => {
20153
+ if (status.downloadedBytes !== void 0 && status.totalBytes !== void 0 && status.downloadedBytes > status.totalBytes) {
20154
+ context.addIssue({
20155
+ code: "custom",
20156
+ path: ["downloadedBytes"],
20157
+ message: "downloadedBytes must not exceed totalBytes"
20107
20158
  });
20108
- if (!parsed.success)
20109
- continue;
20110
- invocations.add(invocation);
20111
- ids.add(id);
20112
- dynamic.push(parsed.data);
20113
20159
  }
20114
- return harnessCommandCatalogSchema.parse({ commands: [...builtIns.commands, ...dynamic] });
20115
- }
20160
+ });
20161
+ var updateEmptyParamsSchema = external_exports.strictObject({});
20162
+ 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");
20163
+ var updateCheckResultSchema = external_exports.strictObject({
20164
+ currentVersion: updateSemanticVersionSchema,
20165
+ installation: updateInstallationSchema.nullable(),
20166
+ latestVersion: updateSemanticVersionSchema.nullable(),
20167
+ updateAvailable: external_exports.boolean(),
20168
+ installationAvailable: external_exports.boolean(),
20169
+ releaseNotes: external_exports.string().min(1).max(2e4).nullable(),
20170
+ releaseNotesUrl: githubReleaseNotesUrlSchema.nullable(),
20171
+ status: updateStatusSchema.nullable(),
20172
+ error: external_exports.string().min(1).max(UPDATE_ERROR_MAX_LENGTH).nullable()
20173
+ });
20174
+ var updateStartResultSchema = external_exports.strictObject({
20175
+ status: updateStatusSchema
20176
+ });
20177
+ var updateStatusResultSchema = external_exports.strictObject({
20178
+ status: updateStatusSchema.nullable()
20179
+ });
20116
20180
 
20117
- // dist/acp-transport.js
20118
- import { spawn, spawnSync } from "node:child_process";
20119
- import { readdir, readFile as readFile2 } from "node:fs/promises";
20120
- import os4 from "node:os";
20121
- import path10 from "node:path";
20122
- import { Readable, Writable } from "node:stream";
20181
+ // ../../shared-contracts/dist/index.js
20182
+ var workspaceContractVersionSchema = external_exports.literal(WORKSPACE_CONTRACT_VERSION);
20123
20183
 
20124
- // dist/grok-slash-commands.js
20125
- var GROK_LIVE_COMMAND_ID_PREFIX = "grok.slash.";
20126
- function isRecord3(value) {
20127
- return typeof value === "object" && value !== null && !Array.isArray(value);
20128
- }
20129
- function parseGrokAvailableCommands(value) {
20130
- if (!Array.isArray(value))
20131
- return [];
20132
- return value.flatMap((entry) => {
20133
- if (!isRecord3(entry))
20134
- return [];
20135
- const name = typeof entry.name === "string" ? entry.name.trim().replace(/^\//u, "") : "";
20136
- if (!name)
20137
- return [];
20138
- return [
20139
- {
20140
- name,
20141
- description: typeof entry.description === "string" ? entry.description : "",
20142
- meta: isRecord3(entry._meta) ? entry._meta : null
20143
- }
20144
- ];
20145
- });
20146
- }
20147
- function isGrokSkill(command) {
20148
- const path13 = command.meta?.path;
20149
- return typeof path13 === "string" && /(^|[\\/])SKILL\.md$/u.test(path13) || typeof command.meta?.qualifiedName === "string";
20184
+ // ../../harness-adapter/dist/approval.js
20185
+ function invalidRequest(message) {
20186
+ return { code: "invalidRequest", message, retryable: false };
20150
20187
  }
20151
- function grokLiveCommands(native) {
20152
- return native.map((command) => ({
20153
- name: command.name,
20154
- description: command.description,
20155
- kind: isGrokSkill(command) ? "skill" : "command"
20156
- }));
20188
+ function validateHostApprovalResponse(interaction, response) {
20189
+ return interaction.actions.some(({ id }) => id === response.actionId) ? null : invalidRequest("Approval Response contains an undeclared action ID");
20157
20190
  }
20158
20191
 
20159
- // dist/command.js
20160
- import path5 from "node:path";
20161
-
20162
- // ../../harness-discovery/dist/environment.js
20163
- import fs from "node:fs";
20164
- import path2 from "node:path";
20165
- function targetPath(platform) {
20166
- return platform === "win32" ? path2.win32 : path2.posix;
20167
- }
20168
- function environmentValue(environment, name) {
20169
- const lowered = name.toLowerCase();
20170
- for (const [key, value] of Object.entries(environment)) {
20171
- if (key.toLowerCase() === lowered)
20172
- return value;
20173
- }
20174
- return void 0;
20175
- }
20176
- function pathDelimiter(platform) {
20177
- return platform === "win32" ? ";" : ":";
20178
- }
20179
- function pathDirectories(environment, platform) {
20180
- return (environmentValue(environment, "PATH") ?? "").split(pathDelimiter(platform)).map((directory) => directory.trim().replace(/^"|"$/gu, "")).filter(Boolean);
20181
- }
20182
- function executableExtensions(command, platform, environment) {
20183
- if (platform !== "win32")
20184
- return [""];
20185
- if (targetPath(platform).extname(command) !== "")
20186
- return [""];
20187
- return (environmentValue(environment, "PATHEXT") ?? ".COM;.EXE;.BAT;.CMD").split(";").map((extension) => extension.trim()).filter(Boolean);
20192
+ // ../../harness-adapter/dist/question.js
20193
+ function invalidRequest2(message) {
20194
+ return { code: "invalidRequest", message, retryable: false };
20188
20195
  }
20189
- function isExecutableFile(filePath, platform) {
20190
- try {
20191
- fs.accessSync(filePath, platform === "win32" ? fs.constants.F_OK : fs.constants.X_OK);
20192
- return fs.statSync(filePath).isFile();
20193
- } catch {
20194
- return false;
20196
+ function validateHostQuestionResponse(interaction, response) {
20197
+ const questionIds = new Set(interaction.questions.map(({ id }) => id));
20198
+ if (response.cancelled) {
20199
+ return Object.keys(response.answers).length === 0 ? null : invalidRequest2("Cancelled Question Response must not contain answers");
20195
20200
  }
20196
- }
20197
- function subdirectoryNames(directory) {
20198
- try {
20199
- return fs.readdirSync(directory, { withFileTypes: true }).filter((entry) => entry.isDirectory()).map((entry) => entry.name);
20200
- } catch {
20201
- return [];
20201
+ for (const answerId of Object.keys(response.answers)) {
20202
+ if (!questionIds.has(answerId)) {
20203
+ return invalidRequest2("Question Response contains an unknown Question ID");
20204
+ }
20202
20205
  }
20203
- }
20204
- function newestFirst(names) {
20205
- return [...names].sort((left, right) => right.localeCompare(left, void 0, { numeric: true }));
20206
- }
20207
-
20208
- // ../../harness-discovery/dist/invocation.js
20209
- import path3 from "node:path";
20210
- function commandInvocation(command, arguments_, environment, platform = process.platform) {
20211
- const extension = path3.win32.extname(command).toLowerCase();
20212
- if (platform !== "win32" || ![".cmd", ".bat"].includes(extension)) {
20213
- return { command, arguments: [...arguments_], windowsVerbatimArguments: false };
20206
+ for (const question of interaction.questions) {
20207
+ const answers = response.answers[question.id] ?? [];
20208
+ if (!question.optional && answers.length === 0) {
20209
+ return invalidRequest2("Question Response omits a required answer");
20210
+ }
20211
+ if (question.type === "text") {
20212
+ if (answers.length > 1) {
20213
+ return invalidRequest2("Text Question accepts at most one answer");
20214
+ }
20215
+ continue;
20216
+ }
20217
+ if (!question.multiple && answers.length > 1) {
20218
+ return invalidRequest2("Single-choice Question accepts at most one answer");
20219
+ }
20220
+ const declared = new Set(question.options.map(({ value }) => value));
20221
+ if (!question.allowOther && answers.some((answer) => !declared.has(answer))) {
20222
+ return invalidRequest2("Question Response contains an undeclared choice");
20223
+ }
20214
20224
  }
20215
- const quote = (value) => `"${value.replaceAll("%", "%%").replaceAll('"', '""')}"`;
20216
- const commandLine = [command, ...arguments_].map(quote).join(" ");
20217
- return {
20218
- command: environmentValue(environment, "ComSpec") ?? "cmd.exe",
20219
- arguments: ["/d", "/v:off", "/s", "/c", `"${commandLine}"`],
20220
- windowsVerbatimArguments: true
20221
- };
20225
+ return null;
20222
20226
  }
20223
20227
 
20224
- // ../../harness-discovery/dist/node-runtime.js
20225
- import path4 from "node:path";
20226
- function withNodeRuntimeOnPath(environment, runtimeExecutable = process.execPath, platform = process.platform) {
20227
- const pathKey = Object.keys(environment).find((name) => name.toLowerCase() === "path") ?? "PATH";
20228
- const delimiter = platform === "win32" ? ";" : ":";
20229
- const runtimeDirectory = path4.dirname(runtimeExecutable);
20230
- const directories = (environment[pathKey] ?? "").split(delimiter).filter(Boolean);
20231
- const equal = platform === "win32" ? (value) => value.toLowerCase() : (value) => value;
20232
- if (!directories.some((directory) => equal(directory) === equal(runtimeDirectory))) {
20233
- directories.push(runtimeDirectory);
20228
+ // ../../harness-adapter/dist/output-channel.js
20229
+ var HarnessOutputChannel = class {
20230
+ outputs;
20231
+ #consumerCreated = false;
20232
+ #ended = false;
20233
+ #pending = [];
20234
+ #values = [];
20235
+ constructor() {
20236
+ this.outputs = {
20237
+ [Symbol.asyncIterator]: () => {
20238
+ if (this.#consumerCreated) {
20239
+ throw new Error("Harness outputs allow only one consumer");
20240
+ }
20241
+ this.#consumerCreated = true;
20242
+ return {
20243
+ next: () => this.#next()
20244
+ };
20245
+ }
20246
+ };
20234
20247
  }
20235
- return { ...environment, [pathKey]: directories.join(delimiter) };
20236
- }
20237
-
20238
- // ../../harness-discovery/dist/resolve.js
20239
- import os2 from "node:os";
20240
-
20241
- // ../../harness-discovery/dist/version-managers.js
20242
- function versionManagerBinaryDirectories(context) {
20243
- const { platform, environment, home } = context;
20244
- const list = context.subdirectories ?? subdirectoryNames;
20245
- const pathFlavor = targetPath(platform);
20246
- const value = (name) => environmentValue(environment, name);
20247
- const directories = [];
20248
- const versioned = (root, ...tail) => {
20249
- for (const version2 of newestFirst(list(root))) {
20250
- directories.push(pathFlavor.join(root, version2, ...tail));
20251
- }
20252
- };
20253
- if (platform === "win32") {
20254
- const appData = value("APPDATA") ?? pathFlavor.join(home, "AppData", "Roaming");
20255
- const localAppData = value("LOCALAPPDATA") ?? pathFlavor.join(home, "AppData", "Local");
20256
- versioned(pathFlavor.join(appData, "nvm"));
20257
- versioned(value("FNM_DIR") ?? pathFlavor.join(appData, "fnm", "node-versions"), "installation");
20258
- directories.push(pathFlavor.join(localAppData, "Volta", "bin"));
20259
- directories.push(pathFlavor.join(home, ".bun", "bin"));
20260
- const pnpmHome2 = value("PNPM_HOME");
20261
- if (pnpmHome2)
20262
- directories.push(pnpmHome2);
20263
- directories.push(pathFlavor.join(localAppData, "pnpm"));
20264
- return directories;
20248
+ emit(value) {
20249
+ if (this.#ended)
20250
+ return false;
20251
+ const resolve = this.#pending.shift();
20252
+ if (resolve)
20253
+ resolve({ done: false, value });
20254
+ else
20255
+ this.#values.push(value);
20256
+ return true;
20265
20257
  }
20266
- versioned(pathFlavor.join(value("NVM_DIR") ?? pathFlavor.join(home, ".nvm"), "versions", "node"), "bin");
20267
- const fnmRoots = [
20268
- value("FNM_DIR"),
20269
- pathFlavor.join(home, ".local", "share", "fnm"),
20270
- pathFlavor.join(home, "Library", "Application Support", "fnm")
20271
- ].filter((root) => root !== void 0);
20272
- for (const root of fnmRoots) {
20273
- versioned(pathFlavor.join(root, "node-versions"), "installation", "bin");
20258
+ end() {
20259
+ if (this.#ended)
20260
+ return;
20261
+ this.#ended = true;
20262
+ if (this.#values.length !== 0)
20263
+ return;
20264
+ for (const resolve of this.#pending.splice(0))
20265
+ resolve({ done: true, value: void 0 });
20274
20266
  }
20275
- const voltaHome = value("VOLTA_HOME") ?? pathFlavor.join(home, ".volta");
20276
- versioned(pathFlavor.join(voltaHome, "tools", "image", "node"), "bin");
20277
- directories.push(pathFlavor.join(voltaHome, "bin"));
20278
- const asdfHome = value("ASDF_DATA_DIR") ?? pathFlavor.join(home, ".asdf");
20279
- versioned(pathFlavor.join(asdfHome, "installs", "nodejs"), "bin");
20280
- directories.push(pathFlavor.join(asdfHome, "shims"));
20281
- const nodenvHome = value("NODENV_ROOT") ?? pathFlavor.join(home, ".nodenv");
20282
- versioned(pathFlavor.join(nodenvHome, "versions"), "bin");
20283
- directories.push(pathFlavor.join(nodenvHome, "shims"));
20284
- versioned(pathFlavor.join(value("N_PREFIX") ?? "/usr/local", "n", "versions", "node"), "bin");
20285
- directories.push(pathFlavor.join(home, ".bun", "bin"));
20286
- const pnpmHome = value("PNPM_HOME");
20287
- if (pnpmHome)
20288
- directories.push(pnpmHome);
20289
- directories.push(pathFlavor.join(home, "Library", "pnpm"));
20290
- directories.push(pathFlavor.join(home, ".local", "share", "pnpm"));
20291
- for (const prefix of ["/opt/homebrew/opt", "/usr/local/opt"]) {
20292
- for (const formula of newestFirst(list(prefix).filter((name) => name.startsWith("node@")))) {
20293
- directories.push(pathFlavor.join(prefix, formula, "bin"));
20294
- }
20267
+ #next() {
20268
+ const value = this.#values.shift();
20269
+ if (value !== void 0)
20270
+ return Promise.resolve({ done: false, value });
20271
+ if (this.#ended)
20272
+ return Promise.resolve({ done: true, value: void 0 });
20273
+ return new Promise((resolve) => this.#pending.push(resolve));
20295
20274
  }
20296
- return directories;
20297
- }
20275
+ };
20298
20276
 
20299
- // ../../harness-discovery/dist/resolve.js
20300
- var VERSION_MANAGER_ROOTS = "<version-managers>";
20301
- function installRootExtensions(platform) {
20302
- return platform === "win32" ? [".exe", ".cmd"] : [""];
20303
- }
20304
- function resolveHomeDirectory(input) {
20305
- return input.homeDirectory ?? environmentValue(input.environment, "HOME") ?? environmentValue(input.environment, "USERPROFILE") ?? os2.homedir();
20306
- }
20307
- function templateVariables(environment, platform, home) {
20308
- const pathFlavor = targetPath(platform);
20309
- return {
20310
- HOME: home,
20311
- USERPROFILE: home,
20312
- APPDATA: environmentValue(environment, "APPDATA") ?? pathFlavor.join(home, "AppData", "Roaming"),
20313
- LOCALAPPDATA: environmentValue(environment, "LOCALAPPDATA") ?? pathFlavor.join(home, "AppData", "Local")
20314
- };
20277
+ // ../../harness-adapter/dist/diagnostics.js
20278
+ var DIAGNOSTIC_TAIL_MAX_LENGTH = 8e3;
20279
+ var SENSITIVE_VALUE_PATTERN = /(api[_-]?key|access[_-]?token|auth(?:orization)?|password|secret)(\s*[:=]\s*)([^\s,;]+)/giu;
20280
+ var BEARER_PATTERN = /\bBearer\s+[A-Za-z0-9._~+/=-]+/giu;
20281
+ function sanitizeDiagnosticTail(value) {
20282
+ const redacted = value.replace(BEARER_PATTERN, "Bearer [redacted]").replace(SENSITIVE_VALUE_PATTERN, "$1$2[redacted]");
20283
+ return redacted.length <= DIAGNOSTIC_TAIL_MAX_LENGTH ? redacted : redacted.slice(-DIAGNOSTIC_TAIL_MAX_LENGTH);
20315
20284
  }
20316
- function joinTemplate(platform, value) {
20317
- const pathFlavor = targetPath(platform);
20318
- const segments = value.split("/");
20319
- const head = segments[0] ?? "";
20320
- const tail = segments.slice(1);
20321
- if (head === "")
20322
- return pathFlavor.join(pathFlavor.sep, ...tail);
20323
- return tail.length === 0 ? head : pathFlavor.join(head, ...tail);
20285
+
20286
+ // ../../harness-adapter/dist/usage.js
20287
+ var tokenFields = [
20288
+ "inputTokens",
20289
+ "cachedInputTokens",
20290
+ "cacheWriteInputTokens",
20291
+ "outputTokens",
20292
+ "outputTokensPerSecond",
20293
+ "reasoningOutputTokens",
20294
+ "totalTokens",
20295
+ "contextWindowTokens",
20296
+ "contextUsedTokens"
20297
+ ];
20298
+ var safeIntegerFields = [
20299
+ "planFiveHourResetsAtUnix",
20300
+ "planSevenDayResetsAtUnix"
20301
+ ];
20302
+ var percentFields = [
20303
+ "cacheHitRatePercent",
20304
+ "planFiveHourUsedPercent",
20305
+ "planSevenDayUsedPercent"
20306
+ ];
20307
+ var usageFields = /* @__PURE__ */ new Set([
20308
+ ...tokenFields,
20309
+ ...safeIntegerFields,
20310
+ ...percentFields,
20311
+ "totalCostUsd",
20312
+ "totalCredits",
20313
+ "contextUsagePercent"
20314
+ ]);
20315
+ function isRecord2(value) {
20316
+ return typeof value === "object" && value !== null && !Array.isArray(value);
20324
20317
  }
20325
- function expandInstallRoot(template, environment, platform, home) {
20326
- const variables = templateVariables(environment, platform, home);
20327
- let unresolved = false;
20328
- const substituted = template.replace(/^~(?=\/|$)/u, home).replace(/\$\{(\w+)\}/gu, (_match, name) => {
20329
- const value = variables[name] ?? environmentValue(environment, name);
20330
- if (value === void 0 || value === "") {
20331
- unresolved = true;
20332
- return "";
20318
+ function parseHostUsage(value) {
20319
+ if (!isRecord2(value))
20320
+ throw new Error("Harness Usage must be an object");
20321
+ const keys = Object.keys(value);
20322
+ if (keys.length === 0)
20323
+ throw new Error("Harness Usage must contain a reliable field");
20324
+ for (const key of keys) {
20325
+ if (!usageFields.has(key)) {
20326
+ throw new Error(`Harness Usage contains unknown field '${key}'`);
20333
20327
  }
20334
- return value;
20335
- });
20336
- return unresolved ? void 0 : joinTemplate(platform, substituted);
20337
- }
20338
- function installRootDirectories(spec, input, dependencies, platform, home) {
20339
- const templates = (platform === "win32" ? spec.installRoots?.windows : spec.installRoots?.posix) ?? [];
20340
- const directories = [];
20341
- for (const template of templates) {
20342
- if (template === VERSION_MANAGER_ROOTS) {
20343
- directories.push(...versionManagerBinaryDirectories({
20344
- platform,
20345
- environment: input.environment,
20346
- home,
20347
- ...dependencies.subdirectories ? { subdirectories: dependencies.subdirectories } : {}
20348
- }));
20349
- continue;
20328
+ }
20329
+ for (const field of ["totalCredits", "contextUsagePercent"]) {
20330
+ const candidate = value[field];
20331
+ if (candidate !== void 0 && (typeof candidate !== "number" || !Number.isFinite(candidate) || candidate < 0)) {
20332
+ throw new Error(`Harness Usage '${field}' must be a finite non-negative number`);
20350
20333
  }
20351
- const directory = expandInstallRoot(template, input.environment, platform, home);
20352
- if (directory !== void 0)
20353
- directories.push(directory);
20354
20334
  }
20355
- return directories;
20356
- }
20357
- function harnessCandidates(spec, input, dependencies = {}) {
20358
- const platform = input.platform ?? process.platform;
20359
- const pathFlavor = targetPath(platform);
20360
- const configured = input.command ?? (spec.commandEnvironmentVariable ? environmentValue(input.environment, spec.commandEnvironmentVariable) : void 0);
20361
- const command = configured ?? spec.command;
20362
- if (pathFlavor.isAbsolute(command) || command.includes("/") || command.includes("\\")) {
20363
- return [{ candidate: command, source: "configured" }];
20335
+ for (const field of tokenFields) {
20336
+ const candidate = value[field];
20337
+ if (candidate !== void 0 && (typeof candidate !== "number" || !Number.isSafeInteger(candidate) || candidate < 0)) {
20338
+ throw new Error(`Harness Usage '${field}' must be a non-negative safe integer`);
20339
+ }
20364
20340
  }
20365
- const candidates = [];
20366
- const extensions = executableExtensions(command, platform, input.environment);
20367
- for (const directory of pathDirectories(input.environment, platform)) {
20368
- for (const extension of extensions) {
20369
- candidates.push({
20370
- candidate: pathFlavor.join(directory, command + extension),
20371
- source: "path"
20372
- });
20341
+ for (const field of safeIntegerFields) {
20342
+ const candidate = value[field];
20343
+ if (candidate !== void 0 && (typeof candidate !== "number" || !Number.isSafeInteger(candidate) || candidate < 0)) {
20344
+ throw new Error(`Harness Usage '${field}' must be a non-negative safe integer`);
20345
+ }
20346
+ }
20347
+ if (value.outputTokensPerSecond !== void 0 && (typeof value.outputTokensPerSecond !== "number" || !Number.isFinite(value.outputTokensPerSecond) || value.outputTokensPerSecond < 0)) {
20348
+ throw new Error("Harness Usage 'outputTokensPerSecond' must be a finite non-negative number");
20349
+ }
20350
+ if (value.totalCostUsd !== void 0 && (typeof value.totalCostUsd !== "number" || !Number.isFinite(value.totalCostUsd) || value.totalCostUsd < 0)) {
20351
+ throw new Error("Harness Usage 'totalCostUsd' must be a finite non-negative number");
20352
+ }
20353
+ for (const field of ["totalCredits", "contextUsagePercent"]) {
20354
+ const candidate = value[field];
20355
+ if (candidate !== void 0 && (typeof candidate !== "number" || !Number.isFinite(candidate) || candidate < 0)) {
20356
+ throw new Error(`Harness Usage '${field}' must be a finite non-negative number`);
20373
20357
  }
20374
20358
  }
20375
- if (configured !== void 0)
20376
- return candidates;
20377
- const home = resolveHomeDirectory(input);
20378
- for (const directory of installRootDirectories(spec, input, dependencies, platform, home)) {
20379
- for (const extension of installRootExtensions(platform)) {
20380
- candidates.push({
20381
- candidate: pathFlavor.join(directory, spec.command + extension),
20382
- source: "install-root"
20383
- });
20359
+ for (const field of percentFields) {
20360
+ const candidate = value[field];
20361
+ if (candidate !== void 0 && (typeof candidate !== "number" || !Number.isFinite(candidate) || candidate < 0 || candidate > 100)) {
20362
+ throw new Error(`Harness Usage '${field}' must be between 0 and 100`);
20384
20363
  }
20385
20364
  }
20386
- return candidates;
20387
- }
20388
- function resolveHarnessExecutable(spec, input, dependencies = {}) {
20389
- const platform = input.platform ?? process.platform;
20390
- const isExecutable = dependencies.isExecutable ?? ((candidate) => isExecutableFile(candidate, platform));
20391
- const runnable = spec.runnableCandidate ?? ((candidate) => candidate);
20392
- const context = { platform, isExecutable };
20393
- for (const { candidate, source } of harnessCandidates(spec, input, dependencies)) {
20394
- const executable = runnable(candidate, context);
20395
- if (executable !== void 0 && isExecutable(executable))
20396
- return { executable, source };
20365
+ const hasContextUsed = value.contextUsedTokens !== void 0;
20366
+ const hasContextWindow = value.contextWindowTokens !== void 0;
20367
+ if (hasContextUsed !== hasContextWindow) {
20368
+ throw new Error("Harness Usage context fields must be provided together");
20397
20369
  }
20398
- return void 0;
20370
+ if (hasContextWindow && value.contextWindowTokens === 0) {
20371
+ throw new Error("Harness Usage 'contextWindowTokens' must be greater than zero");
20372
+ }
20373
+ if (value.planFiveHourResetsAtUnix !== void 0 && value.planFiveHourUsedPercent === void 0) {
20374
+ throw new Error("Harness Usage 'planFiveHourResetsAtUnix' must be provided with 'planFiveHourUsedPercent'");
20375
+ }
20376
+ if (value.planSevenDayResetsAtUnix !== void 0 && value.planSevenDayUsedPercent === void 0) {
20377
+ throw new Error("Harness Usage 'planSevenDayResetsAtUnix' must be provided with 'planSevenDayUsedPercent'");
20378
+ }
20379
+ return { ...value };
20399
20380
  }
20400
20381
 
20401
- // ../../harness-discovery/dist/installation.js
20402
- import { execFile } from "node:child_process";
20403
- import { homedir } from "node:os";
20404
- function runInstallationCommand(command, args, environment, timeout = 3e4) {
20405
- const env = withNodeRuntimeOnPath(environment);
20406
- const invocation = /\.[cm]?js$/i.test(command) ? commandInvocation(process.execPath, [command, ...args], env) : commandInvocation(command, args, env);
20407
- return new Promise((resolve, reject) => {
20408
- const child = execFile(invocation.command, invocation.arguments, {
20409
- env,
20410
- cwd: env.HOME ?? env.USERPROFILE ?? homedir(),
20411
- encoding: "utf8",
20412
- timeout,
20413
- killSignal: "SIGKILL",
20414
- maxBuffer: 1024 * 1024,
20415
- windowsHide: true,
20416
- windowsVerbatimArguments: invocation.windowsVerbatimArguments
20417
- }, (error53, stdout, stderr) => {
20418
- if (error53)
20419
- reject(new Error(error53.killed ? "Harness command timed out" : "Harness command failed; check the native installation and retry"));
20420
- else
20421
- resolve((stdout || stderr).trim());
20382
+ // ../../harness-adapter/dist/live-command-catalog.js
20383
+ var COMMON_EXCLUDED_LIVE_COMMANDS = /* @__PURE__ */ new Set([
20384
+ // Session lifecycle
20385
+ "branch",
20386
+ "clear",
20387
+ "exit",
20388
+ "fork",
20389
+ "fresh",
20390
+ "new",
20391
+ "quit",
20392
+ "rename",
20393
+ "rename-chat",
20394
+ "reset",
20395
+ "resume",
20396
+ "rewind",
20397
+ "session",
20398
+ "sessions",
20399
+ // Desktop-owned configuration
20400
+ "autocompact",
20401
+ "color",
20402
+ "config",
20403
+ "effort",
20404
+ "fast",
20405
+ "keybindings",
20406
+ "model",
20407
+ "models",
20408
+ "output-style",
20409
+ "permissions",
20410
+ "settings",
20411
+ "statusline",
20412
+ "terminal-setup",
20413
+ "theme",
20414
+ "vim",
20415
+ // Trust and approval policy
20416
+ "always-approve",
20417
+ "auto-mode-setup",
20418
+ // Native login
20419
+ "login",
20420
+ "logout",
20421
+ // Work outliving the Turn
20422
+ "autopilot",
20423
+ "background",
20424
+ "bg",
20425
+ "goal",
20426
+ "jobs",
20427
+ "loop",
20428
+ "multitask",
20429
+ "queue",
20430
+ "remote-control",
20431
+ "schedule",
20432
+ "steer",
20433
+ // Native terminal UI
20434
+ "copy",
20435
+ "debug",
20436
+ "feedback",
20437
+ "heapdump",
20438
+ "share",
20439
+ "shell",
20440
+ // Plugin and MCP management
20441
+ "marketplace",
20442
+ "mcp",
20443
+ "plugins",
20444
+ "reload-plugins"
20445
+ ]);
20446
+ var COMMON_EXCLUDED_LIVE_COMMAND_PREFIXES = ["__", "hooks-"];
20447
+ function isExcludedLiveCommand(name, kind, extra = {}) {
20448
+ const normalized = name.trim().replace(/^\//u, "");
20449
+ if (new Set(extra.names ?? []).has(normalized))
20450
+ return true;
20451
+ if (extra.prefixes?.some((prefix) => normalized.startsWith(prefix)))
20452
+ return true;
20453
+ if (kind === "skill")
20454
+ return false;
20455
+ return COMMON_EXCLUDED_LIVE_COMMANDS.has(normalized) || COMMON_EXCLUDED_LIVE_COMMAND_PREFIXES.some((prefix) => normalized.startsWith(prefix));
20456
+ }
20457
+ function liveHarnessCommandPrompt(catalog, idPrefix, commandId, argumentText) {
20458
+ if (!commandId.startsWith(idPrefix))
20459
+ return null;
20460
+ const descriptor = catalog.commands.find(({ id }) => id === commandId);
20461
+ if (!descriptor)
20462
+ return null;
20463
+ const text = typeof argumentText === "string" ? argumentText.trim() : "";
20464
+ return text ? `${descriptor.invocation} ${text}` : descriptor.invocation;
20465
+ }
20466
+ function mergeLiveHarnessCommands(builtIns, idPrefix, live, exclusions = {}) {
20467
+ if (!live)
20468
+ return builtIns;
20469
+ const invocations = new Set(builtIns.commands.map(({ invocation }) => invocation));
20470
+ const ids = new Set(builtIns.commands.map(({ id }) => id));
20471
+ const dynamic = [];
20472
+ for (const command of live) {
20473
+ const name = command.name.trim().replace(/^\//u, "");
20474
+ if (!name || /\s/u.test(name))
20475
+ continue;
20476
+ if (isExcludedLiveCommand(name, command.kind, exclusions))
20477
+ continue;
20478
+ const invocation = `/${name}`;
20479
+ const id = `${idPrefix}${name.replace(/[^A-Za-z0-9._:-]/gu, "-")}`.slice(0, 128);
20480
+ if (invocations.has(invocation) || ids.has(id))
20481
+ continue;
20482
+ const description = command.description?.trim().slice(0, 512);
20483
+ const parsed = harnessCommandDescriptorSchema.safeParse({
20484
+ id,
20485
+ invocation,
20486
+ label: name.slice(0, 128),
20487
+ ...description ? { description } : {},
20488
+ argumentMode: "text",
20489
+ kind: command.kind
20422
20490
  });
20423
- child.stdin?.end();
20424
- });
20491
+ if (!parsed.success)
20492
+ continue;
20493
+ invocations.add(invocation);
20494
+ ids.add(id);
20495
+ dynamic.push(parsed.data);
20496
+ }
20497
+ return harnessCommandCatalogSchema.parse({ commands: [...builtIns.commands, ...dynamic] });
20425
20498
  }
20426
- function installationVersion(value) {
20427
- if (typeof value !== "string" || !/^v?\d+(?:\.\d+){1,3}(?:-[\w.-]+)?(?:\+[\w.-]+)?$/.test(value.trim()))
20428
- throw new Error("Harness returned an invalid version");
20429
- return value.trim().replace(/^v/, "");
20499
+
20500
+ // dist/acp-transport.js
20501
+ import { spawn, spawnSync } from "node:child_process";
20502
+ import { readdir, readFile as readFile2 } from "node:fs/promises";
20503
+ import os4 from "node:os";
20504
+ import path10 from "node:path";
20505
+ import { Readable, Writable } from "node:stream";
20506
+
20507
+ // dist/grok-slash-commands.js
20508
+ var GROK_LIVE_COMMAND_ID_PREFIX = "grok.slash.";
20509
+ function isRecord3(value) {
20510
+ return typeof value === "object" && value !== null && !Array.isArray(value);
20430
20511
  }
20431
- function createInstallationManager(options) {
20432
- let checking;
20433
- let updating;
20434
- const check2 = () => checking ??= options.check().finally(() => {
20435
- checking = void 0;
20512
+ function parseGrokAvailableCommands(value) {
20513
+ if (!Array.isArray(value))
20514
+ return [];
20515
+ return value.flatMap((entry) => {
20516
+ if (!isRecord3(entry))
20517
+ return [];
20518
+ const name = typeof entry.name === "string" ? entry.name.trim().replace(/^\//u, "") : "";
20519
+ if (!name)
20520
+ return [];
20521
+ return [
20522
+ {
20523
+ name,
20524
+ description: typeof entry.description === "string" ? entry.description : "",
20525
+ meta: isRecord3(entry._meta) ? entry._meta : null
20526
+ }
20527
+ ];
20436
20528
  });
20437
- return (action) => {
20438
- if (updating)
20439
- return updating;
20440
- if (action === "check")
20441
- return check2();
20442
- updating = (async () => {
20443
- const before = await check2();
20444
- if (!before.updateAvailable)
20445
- return before;
20446
- if (!before.canUpdate)
20447
- throw new Error(before.message ?? "This installation cannot be updated automatically");
20448
- await options.update(before);
20449
- const after = await check2();
20450
- if (after.currentVersion === before.currentVersion)
20451
- throw new Error("The Harness version did not change; check the native updater and retry");
20452
- return after;
20453
- })().finally(() => {
20454
- updating = void 0;
20455
- });
20456
- return updating;
20457
- };
20529
+ }
20530
+ function isGrokSkill(command) {
20531
+ const path13 = command.meta?.path;
20532
+ return typeof path13 === "string" && /(^|[\\/])SKILL\.md$/u.test(path13) || typeof command.meta?.qualifiedName === "string";
20533
+ }
20534
+ function grokLiveCommands(native) {
20535
+ return native.map((command) => ({
20536
+ name: command.name,
20537
+ description: command.description,
20538
+ kind: isGrokSkill(command) ? "skill" : "command"
20539
+ }));
20458
20540
  }
20459
20541
 
20460
20542
  // dist/command.js
20543
+ import path5 from "node:path";
20461
20544
  var GrokExecutableError = class extends Error {
20462
20545
  code = "GROK_NOT_FOUND";
20463
20546
  };
@@ -25662,7 +25745,13 @@ function createHarnessAdapter(context) {
25662
25745
  return Object.assign(new GrokAdapter({
25663
25746
  ...environment[GROK_COMMAND_ENV] ? { command: environment[GROK_COMMAND_ENV] } : {},
25664
25747
  environment
25665
- }), { installation: createGrokInstallation(environment, environment[GROK_COMMAND_ENV]) });
25748
+ }), {
25749
+ installation: createGrokInstallation(environment, environment[GROK_COMMAND_ENV]),
25750
+ install: createHarnessInstaller(environment, {
25751
+ npm: "@xai-official/grok",
25752
+ allowScripts: "@xai-official/grok"
25753
+ })
25754
+ });
25666
25755
  }
25667
25756
  export {
25668
25757
  GROK_COMMAND_ENV,