@codexhost/cli-linux-arm64 0.11.0 → 0.12.1

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,6 +5,409 @@ var __export = (target, all) => {
5
5
  __defProp(target, name, { get: all[name], enumerable: true });
6
6
  };
7
7
 
8
+ // ../../harness-discovery/dist/environment.js
9
+ import fs from "node:fs";
10
+ import path from "node:path";
11
+ function targetPath(platform) {
12
+ return platform === "win32" ? path.win32 : path.posix;
13
+ }
14
+ function environmentValue(environment, name) {
15
+ const lowered = name.toLowerCase();
16
+ for (const [key, value] of Object.entries(environment)) {
17
+ if (key.toLowerCase() === lowered)
18
+ return value;
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) {
36
+ try {
37
+ fs.accessSync(filePath, platform === "win32" ? fs.constants.F_OK : fs.constants.X_OK);
38
+ return fs.statSync(filePath).isFile();
39
+ } catch {
40
+ return false;
41
+ }
42
+ }
43
+ function subdirectoryNames(directory) {
44
+ try {
45
+ return fs.readdirSync(directory, { withFileTypes: true }).filter((entry) => entry.isDirectory()).map((entry) => entry.name);
46
+ } catch {
47
+ return [];
48
+ }
49
+ }
50
+ function newestFirst(names) {
51
+ return [...names].sort((left, right) => right.localeCompare(left, void 0, { numeric: true }));
52
+ }
53
+
54
+ // ../../harness-discovery/dist/invocation.js
55
+ import path2 from "node:path";
56
+ function commandInvocation(command, arguments_, environment, platform = process.platform) {
57
+ const extension = path2.win32.extname(command).toLowerCase();
58
+ if (platform !== "win32" || ![".cmd", ".bat"].includes(extension)) {
59
+ return { command, arguments: [...arguments_], windowsVerbatimArguments: false };
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
+ }
69
+
70
+ // ../../harness-discovery/dist/node-runtime.js
71
+ import path3 from "node:path";
72
+ function withNodeRuntimeOnPath(environment, runtimeExecutable = process.execPath, platform = process.platform) {
73
+ const pathKey = Object.keys(environment).find((name) => name.toLowerCase() === "path") ?? "PATH";
74
+ const delimiter = platform === "win32" ? ";" : ":";
75
+ const runtimeDirectory = path3.dirname(runtimeExecutable);
76
+ const directories = (environment[pathKey] ?? "").split(delimiter).filter(Boolean);
77
+ const equal = platform === "win32" ? (value) => value.toLowerCase() : (value) => value;
78
+ if (!directories.some((directory) => equal(directory) === equal(runtimeDirectory))) {
79
+ directories.push(runtimeDirectory);
80
+ }
81
+ return { ...environment, [pathKey]: directories.join(delimiter) };
82
+ }
83
+
84
+ // ../../harness-discovery/dist/resolve.js
85
+ import os from "node:os";
86
+
87
+ // ../../harness-discovery/dist/version-managers.js
88
+ function versionManagerBinaryDirectories(context) {
89
+ const { platform, environment, home } = context;
90
+ const list = context.subdirectories ?? subdirectoryNames;
91
+ const pathFlavor = targetPath(platform);
92
+ const value = (name) => environmentValue(environment, name);
93
+ const directories = [];
94
+ const versioned = (root, ...tail) => {
95
+ for (const version2 of newestFirst(list(root))) {
96
+ directories.push(pathFlavor.join(root, version2, ...tail));
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
+ }, (error51, stdout, stderr) => {
264
+ if (error51)
265
+ reject(new Error(error51.killed ? "Harness command timed out" : "Harness command failed; check the native installation and retry"));
266
+ else
267
+ resolve((stdout || stderr).trim());
268
+ });
269
+ child.stdin?.end();
270
+ });
271
+ }
272
+ function installationVersion(value) {
273
+ if (typeof value !== "string" || !/^v?\d+(?:\.\d+){1,3}(?:-[\w.-]+)?(?:\+[\w.-]+)?$/.test(value.trim()))
274
+ throw new Error("Harness returned an invalid version");
275
+ return value.trim().replace(/^v/, "");
276
+ }
277
+ function versionFromOutput(output) {
278
+ return installationVersion(output.match(/\b\d+(?:\.\d+){1,3}(?:-[\w.-]+)?(?:\+[\w.-]+)?\b/)?.[0]);
279
+ }
280
+ function newerInstallationVersion(current, latest) {
281
+ const a = installationVersion(current).replace(/\+.*/, "");
282
+ const b = installationVersion(latest).replace(/\+.*/, "");
283
+ const coreA = a.replace(/-.*/, "").split(".").map(BigInt);
284
+ const coreB = b.replace(/-.*/, "").split(".").map(BigInt);
285
+ for (let i = 0; i < Math.max(coreA.length, coreB.length); i++) {
286
+ if ((coreA[i] ?? 0n) !== (coreB[i] ?? 0n))
287
+ return (coreB[i] ?? 0n) > (coreA[i] ?? 0n);
288
+ }
289
+ const preA = a.includes("-") ? a.slice(a.indexOf("-") + 1).split(".") : [];
290
+ const preB = b.includes("-") ? b.slice(b.indexOf("-") + 1).split(".") : [];
291
+ if (!preA.length || !preB.length)
292
+ return !!preA.length && !preB.length;
293
+ for (let i = 0; i < Math.max(preA.length, preB.length); i++) {
294
+ const x = preA[i];
295
+ const y = preB[i];
296
+ if (x === y)
297
+ continue;
298
+ if (x === void 0 || y === void 0)
299
+ return x === void 0;
300
+ const numericX = /^\d+$/.test(x);
301
+ const numericY = /^\d+$/.test(y);
302
+ if (numericX && numericY) {
303
+ if (BigInt(x) === BigInt(y))
304
+ continue;
305
+ return BigInt(y) > BigInt(x);
306
+ }
307
+ if (numericX !== numericY)
308
+ return numericX;
309
+ return y > x;
310
+ }
311
+ return false;
312
+ }
313
+ function createInstallationManager(options) {
314
+ let checking;
315
+ let updating;
316
+ const check2 = () => checking ??= options.check().finally(() => {
317
+ checking = void 0;
318
+ });
319
+ return (action) => {
320
+ if (updating)
321
+ return updating;
322
+ if (action === "check")
323
+ return check2();
324
+ updating = (async () => {
325
+ const before = await check2();
326
+ if (!before.updateAvailable)
327
+ return before;
328
+ if (!before.canUpdate)
329
+ throw new Error(before.message ?? "This installation cannot be updated automatically");
330
+ await options.update(before);
331
+ const after = await check2();
332
+ if (after.currentVersion === before.currentVersion)
333
+ throw new Error("The Harness version did not change; check the native updater and retry");
334
+ return after;
335
+ })().finally(() => {
336
+ updating = void 0;
337
+ });
338
+ return updating;
339
+ };
340
+ }
341
+ async function fetchInstallationText(url2) {
342
+ const request = async () => {
343
+ const response = await fetch(url2, { signal: AbortSignal.timeout(15e3) });
344
+ if (!response.ok)
345
+ throw new Error("Could not check the latest Harness version");
346
+ return response.text();
347
+ };
348
+ try {
349
+ return await request();
350
+ } catch (error51) {
351
+ if (error51 instanceof DOMException && (error51.name === "AbortError" || error51.name === "TimeoutError"))
352
+ throw error51;
353
+ return request();
354
+ }
355
+ }
356
+
357
+ // ../../harness-discovery/dist/installer.js
358
+ import { mkdtemp, rm, writeFile } from "node:fs/promises";
359
+ import { tmpdir } from "node:os";
360
+ import { join } from "node:path";
361
+ function createHarnessInstaller(environment, source) {
362
+ return async () => {
363
+ if (!["darwin", "linux", "win32"].includes(process.platform))
364
+ throw new Error("Unsupported installation platform");
365
+ const env = withNodeRuntimeOnPath(environment);
366
+ if ("npm" in source) {
367
+ const npm = resolveHarnessExecutable({
368
+ id: "npm",
369
+ command: "npm",
370
+ installRoots: {
371
+ posix: [
372
+ "~/.npm-global/bin",
373
+ "~/.local/bin",
374
+ VERSION_MANAGER_ROOTS,
375
+ "/opt/homebrew/bin",
376
+ "/usr/local/bin",
377
+ "/usr/bin"
378
+ ],
379
+ windows: [
380
+ "${APPDATA}/npm",
381
+ VERSION_MANAGER_ROOTS,
382
+ "${ProgramFiles}/nodejs",
383
+ "${LOCALAPPDATA}/Programs/nodejs"
384
+ ]
385
+ }
386
+ }, { environment: env });
387
+ if (!npm)
388
+ throw new Error("Install Node.js and npm first");
389
+ await runInstallationCommand(npm.executable, ["install", "--global", source.npm], {
390
+ ...env,
391
+ ...source.allowScripts ? { npm_config_allow_scripts: source.allowScripts } : {}
392
+ }, 6e5);
393
+ return;
394
+ }
395
+ const windows = process.platform === "win32";
396
+ const url2 = windows ? source.windows : source.posix;
397
+ if (new URL(url2).protocol !== "https:")
398
+ throw new Error("Installer requires HTTPS");
399
+ const script = await fetchInstallationText(url2);
400
+ const directory = await mkdtemp(join(tmpdir(), "codexhost-installer-"));
401
+ try {
402
+ const file2 = join(directory, windows ? "install.ps1" : "install.sh");
403
+ await writeFile(file2, script, { mode: 384 });
404
+ await runInstallationCommand(windows ? "powershell.exe" : source.shell ?? "bash", windows ? ["-NoProfile", "-NonInteractive", "-ExecutionPolicy", "Bypass", "-File", file2] : [file2], env, 6e5);
405
+ } finally {
406
+ await rm(directory, { recursive: true, force: true });
407
+ }
408
+ };
409
+ }
410
+
8
411
  // dist/antigravity-adapter.js
9
412
  import { spawn } from "node:child_process";
10
413
  import { randomUUID as randomUUID6 } from "node:crypto";
@@ -14598,6 +15001,20 @@ var harnessDisplaySetSchema = external_exports.strictObject({
14598
15001
  initializeOnly: external_exports.boolean().optional()
14599
15002
  });
14600
15003
 
15004
+ // ../../shared-contracts/dist/ids.js
15005
+ var opaqueIdSchema = external_exports.string().refine((value) => value.trim().length > 0, {
15006
+ message: "Identifier must not be empty or whitespace"
15007
+ });
15008
+ var harnessIdSchema = opaqueIdSchema.brand();
15009
+ var hostThreadIdSchema = opaqueIdSchema.brand();
15010
+ var hostTurnIdSchema = opaqueIdSchema.brand();
15011
+ var hostItemIdSchema = opaqueIdSchema.brand();
15012
+ var hostInteractionIdSchema = opaqueIdSchema.brand();
15013
+
15014
+ // ../../shared-contracts/dist/thread-prewarm.js
15015
+ var threadPrewarmDiscardParamsSchema = external_exports.object({ threadId: hostThreadIdSchema });
15016
+ var threadPrewarmDiscardResultSchema = external_exports.object({ discarded: external_exports.boolean() });
15017
+
14601
15018
  // ../../shared-contracts/dist/console.js
14602
15019
  var consoleAnnouncementSchema = external_exports.strictObject({
14603
15020
  title: external_exports.string().trim().min(1).max(200),
@@ -14610,10 +15027,14 @@ var consoleOpenResultSchema = external_exports.strictObject({
14610
15027
  url: external_exports.string().max(2048).regex(/^http:\/\/(?:127\.0\.0\.1|localhost):\d{1,5}\/(?:\?.*)?$/u)
14611
15028
  });
14612
15029
  var CONSOLE_HOST_METHODS = Object.freeze([
15030
+ "codexhost/console/remote-connections",
15031
+ "codexhost/runtime/status",
15032
+ "codexhost/remote/ssh-setup",
14613
15033
  "codexhost/harness/plugins/list",
14614
15034
  "codexhost/harness/display-settings/get",
14615
15035
  "codexhost/harness/display-settings/set",
14616
15036
  "codexhost/harness/inspect",
15037
+ "codexhost/harness/installation",
14617
15038
  "codexhost/harness/launch-settings/get",
14618
15039
  "codexhost/harness/launch-settings/set",
14619
15040
  "codexhost/harness/web-ui/open",
@@ -14675,16 +15096,6 @@ var loadedSessionsSchema = external_exports.array(external_exports.strictObject(
14675
15096
  inactiveMs: external_exports.number().nonnegative()
14676
15097
  }));
14677
15098
 
14678
- // ../../shared-contracts/dist/ids.js
14679
- var opaqueIdSchema = external_exports.string().refine((value) => value.trim().length > 0, {
14680
- message: "Identifier must not be empty or whitespace"
14681
- });
14682
- var harnessIdSchema = opaqueIdSchema.brand();
14683
- var hostThreadIdSchema = opaqueIdSchema.brand();
14684
- var hostTurnIdSchema = opaqueIdSchema.brand();
14685
- var hostItemIdSchema = opaqueIdSchema.brand();
14686
- var hostInteractionIdSchema = opaqueIdSchema.brand();
14687
-
14688
15099
  // ../../shared-contracts/dist/manual-compaction.js
14689
15100
  var threadManualCompactionStartedSchema = external_exports.strictObject({
14690
15101
  threadId: hostThreadIdSchema,
@@ -14968,1083 +15379,811 @@ var harnessModelSchema = external_exports.object({
14968
15379
  }).strict();
14969
15380
  var harnessThinkingOptionsSchema = external_exports.array(harnessThinkingOptionSchema).superRefine((options, context) => {
14970
15381
  const ids = /* @__PURE__ */ new Set();
14971
- for (const [index, option] of options.entries()) {
14972
- if (ids.has(option.id)) {
14973
- context.addIssue({
14974
- code: "custom",
14975
- message: "Thinking option IDs must be unique",
14976
- path: [index, "id"]
14977
- });
14978
- }
14979
- ids.add(option.id);
14980
- }
14981
- });
14982
- var harnessModelCatalogSchema = external_exports.object({
14983
- models: external_exports.array(harnessModelSchema),
14984
- defaultModel: harnessModelRefSchema.optional(),
14985
- thinkingOptions: harnessThinkingOptionsSchema,
14986
- defaultThinkingOptionId: harnessThinkingOptionIdSchema.optional()
14987
- }).strict().superRefine((catalog, context) => {
14988
- const refs = /* @__PURE__ */ new Set();
14989
- const thinkingIds = new Set(catalog.thinkingOptions.map(({ id }) => id));
14990
- for (const [index, model] of catalog.models.entries()) {
14991
- if (refs.has(model.ref.id)) {
14992
- context.addIssue({
14993
- code: "custom",
14994
- message: "Model Catalog refs must be unique",
14995
- path: ["models", index, "ref", "id"]
14996
- });
14997
- }
14998
- refs.add(model.ref.id);
14999
- if (model.fastModel) {
15000
- if (refs.has(model.fastModel.id) || catalog.models.some((entry) => entry.ref.id === model.fastModel?.id)) {
15001
- context.addIssue({
15002
- code: "custom",
15003
- message: "Fast Model refs must be distinct and unique",
15004
- path: ["models", index, "fastModel"]
15005
- });
15006
- }
15007
- refs.add(model.fastModel.id);
15008
- }
15009
- const supportedThinkingIds = /* @__PURE__ */ new Set();
15010
- for (const [optionIndex, optionId] of (model.supportedThinkingOptionIds ?? []).entries()) {
15011
- if (supportedThinkingIds.has(optionId)) {
15012
- context.addIssue({
15013
- code: "custom",
15014
- message: "Supported Thinking option IDs must be unique per Model",
15015
- path: ["models", index, "supportedThinkingOptionIds", optionIndex]
15016
- });
15017
- }
15018
- supportedThinkingIds.add(optionId);
15019
- if (!thinkingIds.has(optionId)) {
15020
- context.addIssue({
15021
- code: "custom",
15022
- message: "Supported Thinking option must exist in the catalog",
15023
- path: ["models", index, "supportedThinkingOptionIds", optionIndex]
15024
- });
15025
- }
15026
- }
15027
- }
15028
- if (catalog.defaultModel && !refs.has(catalog.defaultModel.id)) {
15029
- context.addIssue({
15030
- code: "custom",
15031
- message: "Default Model must exist in the Model Catalog",
15032
- path: ["defaultModel", "id"]
15033
- });
15034
- }
15035
- if (catalog.defaultThinkingOptionId && !thinkingIds.has(catalog.defaultThinkingOptionId)) {
15036
- context.addIssue({
15037
- code: "custom",
15038
- message: "Default Thinking option must exist in the catalog",
15039
- path: ["defaultThinkingOptionId"]
15040
- });
15041
- }
15042
- });
15043
- var harnessHistoryCapabilitiesSchema = external_exports.object({
15044
- fork: external_exports.boolean(),
15045
- forkAcrossCwd: external_exports.boolean(),
15046
- rollbackLastTurn: external_exports.boolean()
15047
- }).strict().refine((history) => history.fork || !history.forkAcrossCwd, {
15048
- path: ["forkAcrossCwd"],
15049
- message: "Cross-cwd Fork requires exact history Fork support"
15050
- });
15051
- var harnessPermissionModeScopeSchema = external_exports.enum(["live", "atCreate"]);
15052
- var harnessSessionCapabilitiesSchema = external_exports.object({
15053
- configuration: external_exports.object({
15054
- selectModel: external_exports.boolean(),
15055
- selectThinkingOption: external_exports.boolean(),
15056
- selectPermissionMode: external_exports.boolean(),
15057
- permissionModeScope: harnessPermissionModeScopeSchema.default("live")
15058
- }).strict(),
15059
- history: harnessHistoryCapabilitiesSchema,
15060
- subagents: external_exports.object({
15061
- observe: external_exports.boolean(),
15062
- readTranscript: external_exports.boolean()
15063
- }).strict().optional(),
15064
- autonomousTurns: external_exports.object({
15065
- observe: external_exports.boolean()
15066
- }).strict().optional()
15067
- }).strict();
15068
- var harnessConfigurationStateSchema = external_exports.object({
15069
- effectiveModel: harnessModelRefSchema.optional(),
15070
- resolvedModelLabel: harnessResolvedModelLabelSchema.optional(),
15071
- effectiveThinkingOptionId: harnessThinkingOptionIdSchema.optional(),
15072
- availableThinkingOptions: harnessThinkingOptionsSchema.optional(),
15073
- effectivePermissionModeId: harnessPermissionModeIdSchema.optional()
15074
- }).strict().superRefine((state, context) => {
15075
- if (state.effectiveThinkingOptionId && state.availableThinkingOptions && !state.availableThinkingOptions.some(({ id }) => id === state.effectiveThinkingOptionId)) {
15076
- context.addIssue({
15077
- code: "custom",
15078
- message: "Effective Thinking option must be currently available",
15079
- path: ["effectiveThinkingOptionId"]
15080
- });
15081
- }
15082
- });
15083
- var harnessWebUiCapabilitySchema = external_exports.object({
15084
- open: external_exports.literal(true)
15085
- }).strict();
15086
- var readyHarnessInspectionSchema = external_exports.object({
15087
- status: external_exports.literal("ready"),
15088
- catalog: harnessModelCatalogSchema,
15089
- permissionModes: harnessPermissionModeCatalogSchema.optional(),
15090
- capabilities: harnessSessionCapabilitiesSchema,
15091
- webUi: harnessWebUiCapabilitySchema.optional()
15092
- }).strict().superRefine((inspection, context) => {
15093
- const selectable = inspection.capabilities.configuration.selectPermissionMode;
15094
- if (selectable !== Boolean(inspection.permissionModes)) {
15095
- context.addIssue({
15096
- code: "custom",
15097
- message: "Permission Mode catalog and capability must agree",
15098
- path: selectable ? ["permissionModes"] : ["capabilities", "configuration", "selectPermissionMode"]
15099
- });
15100
- }
15101
- });
15102
- var failedHarnessInspectionSchema = external_exports.object({
15103
- status: external_exports.enum(["notInstalled", "unavailable", "error"]),
15104
- error: codexhostErrorSchema
15105
- }).strict();
15106
- var harnessInspectionSchema = external_exports.union([
15107
- readyHarnessInspectionSchema,
15108
- failedHarnessInspectionSchema
15109
- ]);
15110
- var harnessInspectParamsSchema = external_exports.object({
15111
- harnessId: harnessIdSchema,
15112
- cwd: nonBlankTextSchema2.max(16384).optional(),
15113
- refresh: external_exports.boolean().optional()
15114
- }).strict();
15115
- var harnessWebUiOpenParamsSchema = external_exports.object({
15116
- harnessId: harnessIdSchema
15117
- }).strict();
15118
- var harnessWebUiOpenResultSchema = external_exports.object({}).strict();
15119
- var threadModelSelectParamsSchema = external_exports.object({
15120
- threadId: hostThreadIdSchema,
15121
- model: harnessModelRefSchema
15122
- }).strict();
15123
- var threadThinkingSelectParamsSchema = external_exports.object({
15124
- threadId: hostThreadIdSchema,
15125
- thinkingOptionId: harnessThinkingOptionIdSchema
15126
- }).strict();
15127
- var threadInspectionParamsSchema = external_exports.object({
15128
- threadId: hostThreadIdSchema,
15129
- includeReferenceCapability: external_exports.boolean().optional()
15130
- }).strict();
15131
- var codexThreadInspectionSchema = external_exports.object({
15132
- owner: external_exports.literal("codex"),
15133
- locked: external_exports.literal(true),
15134
- supportsThreadReferences: external_exports.literal(true).optional()
15135
- }).strict();
15136
- var externalThreadInspectionSchema = external_exports.object({
15137
- owner: external_exports.literal("external"),
15138
- harnessId: nonBlankTextSchema2.max(256),
15139
- transportModelId: nonBlankTextSchema2.max(1024),
15140
- effectiveModel: harnessModelRefSchema.optional(),
15141
- resolvedModelLabel: harnessResolvedModelLabelSchema.optional(),
15142
- effectiveThinkingOptionId: harnessThinkingOptionIdSchema.optional(),
15143
- availableThinkingOptions: harnessThinkingOptionsSchema.optional(),
15144
- effectivePermissionModeId: harnessPermissionModeIdSchema.optional(),
15145
- history: harnessHistoryCapabilitiesSchema,
15146
- usage: threadUsageSnapshotSchema.optional(),
15147
- locked: external_exports.literal(true)
15148
- }).strict();
15149
- var threadInspectionSchema = external_exports.discriminatedUnion("owner", [
15150
- codexThreadInspectionSchema,
15151
- externalThreadInspectionSchema
15152
- ]);
15153
- var threadOwnershipListParamsSchema = external_exports.object({
15154
- threadIds: external_exports.array(hostThreadIdSchema).min(1).max(THREAD_OWNERSHIP_LIST_MAX_LENGTH)
15155
- }).strict().superRefine(({ threadIds }, context) => {
15156
- const seen = /* @__PURE__ */ new Set();
15157
- for (const [index, threadId] of threadIds.entries()) {
15158
- if (seen.has(threadId)) {
15382
+ for (const [index, option] of options.entries()) {
15383
+ if (ids.has(option.id)) {
15159
15384
  context.addIssue({
15160
15385
  code: "custom",
15161
- message: "Thread ownership-list IDs must be unique",
15162
- path: ["threadIds", index]
15386
+ message: "Thinking option IDs must be unique",
15387
+ path: [index, "id"]
15163
15388
  });
15164
15389
  }
15165
- seen.add(threadId);
15390
+ ids.add(option.id);
15166
15391
  }
15167
15392
  });
15168
- var codexThreadOwnershipSchema = external_exports.object({
15169
- threadId: hostThreadIdSchema,
15170
- owner: external_exports.literal("codex")
15171
- }).strict();
15172
- var externalThreadOwnershipSchema = external_exports.object({
15173
- threadId: hostThreadIdSchema,
15174
- owner: external_exports.literal("external"),
15175
- harnessId: external_exports.string().max(256).pipe(harnessIdSchema)
15176
- }).strict();
15177
- var threadOwnershipSchema = external_exports.discriminatedUnion("owner", [
15178
- codexThreadOwnershipSchema,
15179
- externalThreadOwnershipSchema
15180
- ]);
15181
- var threadOwnershipListResultSchema = external_exports.object({
15182
- threads: external_exports.array(threadOwnershipSchema).min(1).max(THREAD_OWNERSHIP_LIST_MAX_LENGTH)
15183
- }).strict().superRefine(({ threads }, context) => {
15184
- const seen = /* @__PURE__ */ new Set();
15185
- for (const [index, thread] of threads.entries()) {
15186
- if (seen.has(thread.threadId)) {
15393
+ var harnessModelCatalogSchema = external_exports.object({
15394
+ models: external_exports.array(harnessModelSchema),
15395
+ defaultModel: harnessModelRefSchema.optional(),
15396
+ thinkingOptions: harnessThinkingOptionsSchema,
15397
+ defaultThinkingOptionId: harnessThinkingOptionIdSchema.optional()
15398
+ }).strict().superRefine((catalog, context) => {
15399
+ const refs = /* @__PURE__ */ new Set();
15400
+ const thinkingIds = new Set(catalog.thinkingOptions.map(({ id }) => id));
15401
+ for (const [index, model] of catalog.models.entries()) {
15402
+ if (refs.has(model.ref.id)) {
15187
15403
  context.addIssue({
15188
15404
  code: "custom",
15189
- message: "Thread ownership-list results must be unique",
15190
- path: ["threads", index, "threadId"]
15405
+ message: "Model Catalog refs must be unique",
15406
+ path: ["models", index, "ref", "id"]
15191
15407
  });
15192
15408
  }
15193
- seen.add(thread.threadId);
15409
+ refs.add(model.ref.id);
15410
+ if (model.fastModel) {
15411
+ if (refs.has(model.fastModel.id) || catalog.models.some((entry) => entry.ref.id === model.fastModel?.id)) {
15412
+ context.addIssue({
15413
+ code: "custom",
15414
+ message: "Fast Model refs must be distinct and unique",
15415
+ path: ["models", index, "fastModel"]
15416
+ });
15417
+ }
15418
+ refs.add(model.fastModel.id);
15419
+ }
15420
+ const supportedThinkingIds = /* @__PURE__ */ new Set();
15421
+ for (const [optionIndex, optionId] of (model.supportedThinkingOptionIds ?? []).entries()) {
15422
+ if (supportedThinkingIds.has(optionId)) {
15423
+ context.addIssue({
15424
+ code: "custom",
15425
+ message: "Supported Thinking option IDs must be unique per Model",
15426
+ path: ["models", index, "supportedThinkingOptionIds", optionIndex]
15427
+ });
15428
+ }
15429
+ supportedThinkingIds.add(optionId);
15430
+ if (!thinkingIds.has(optionId)) {
15431
+ context.addIssue({
15432
+ code: "custom",
15433
+ message: "Supported Thinking option must exist in the catalog",
15434
+ path: ["models", index, "supportedThinkingOptionIds", optionIndex]
15435
+ });
15436
+ }
15437
+ }
15438
+ }
15439
+ if (catalog.defaultModel && !refs.has(catalog.defaultModel.id)) {
15440
+ context.addIssue({
15441
+ code: "custom",
15442
+ message: "Default Model must exist in the Model Catalog",
15443
+ path: ["defaultModel", "id"]
15444
+ });
15445
+ }
15446
+ if (catalog.defaultThinkingOptionId && !thinkingIds.has(catalog.defaultThinkingOptionId)) {
15447
+ context.addIssue({
15448
+ code: "custom",
15449
+ message: "Default Thinking option must exist in the catalog",
15450
+ path: ["defaultThinkingOptionId"]
15451
+ });
15194
15452
  }
15195
15453
  });
15196
-
15197
- // ../../shared-contracts/dist/harness-plugins.js
15198
- var HARNESS_PLUGIN_MANIFEST_MAX_BYTES = 32 * 1024;
15199
- var HARNESS_PLUGIN_ICON_MAX_BYTES = 128 * 1024;
15200
- var HARNESS_PLUGIN_LIMIT = 128;
15201
- 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);
15202
- 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");
15203
- var documentationUrlSchema = external_exports.url().refine((value) => /^https:\/\/[^/?#@]+(?:[/?#]|$)/iu.test(value), "Plugin documentation links must be credential-free HTTPS URLs");
15204
- var pluginPresentationShape = {
15205
- id: harnessPluginIdSchema,
15206
- name: external_exports.string().trim().min(1).max(128),
15207
- version: external_exports.string().min(1).max(128),
15208
- /** The factory accepts a persisted local entrypoint through its construction context. */
15209
- launchCommand: external_exports.literal(true).optional(),
15210
- links: external_exports.object({
15211
- documentation: documentationUrlSchema.optional(),
15212
- installation: documentationUrlSchema.optional()
15213
- }).strict().optional()
15214
- };
15215
- var harnessPluginManifestSchema = external_exports.object({
15216
- manifestVersion: external_exports.literal(1),
15217
- ...pluginPresentationShape,
15218
- adapterApiVersion: external_exports.number().int().positive(),
15219
- entry: relativeResourceSchema,
15220
- icon: relativeResourceSchema.optional()
15221
- }).strict();
15222
- 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);
15223
- var harnessPluginDescriptorSchema = external_exports.object({
15224
- ...pluginPresentationShape,
15225
- icon: harnessPluginIconSchema.optional()
15226
- }).strict();
15227
- var harnessPluginListParamsSchema = external_exports.object({}).strict();
15228
- var harnessPluginListResultSchema = external_exports.object({
15229
- plugins: external_exports.array(harnessPluginDescriptorSchema).max(HARNESS_PLUGIN_LIMIT)
15230
- }).strict();
15231
- var harnessPluginConfigurationSchema = external_exports.object({
15232
- version: external_exports.literal(1),
15233
- enabled: external_exports.array(harnessPluginIdSchema).max(HARNESS_PLUGIN_LIMIT)
15234
- }).strict().refine((value) => new Set(value.enabled).size === value.enabled.length, {
15235
- message: "Enabled plugin IDs must be unique",
15236
- path: ["enabled"]
15237
- });
15238
-
15239
- // ../../shared-contracts/dist/harness-route.js
15240
- var harnessPluginRouteSchema = external_exports.object({
15241
- harnessId: harnessPluginIdSchema,
15242
- model: harnessModelRefSchema.optional(),
15243
- thinkingOptionId: harnessThinkingOptionIdSchema.optional(),
15244
- permissionModeId: harnessPermissionModeIdSchema.optional()
15245
- }).strict();
15246
-
15247
- // ../../shared-contracts/dist/harness-launch-settings.js
15248
- var harnessLaunchPathSchema = external_exports.string().trim().min(1).max(4096).refine((value) => !/[\u0000\r\n]/u.test(value), "Invalid entrypoint path");
15249
- var harnessLaunchSettingsGetSchema = external_exports.object({
15250
- harnessId: harnessPluginIdSchema
15251
- }).strict();
15252
- var harnessLaunchSettingsSetSchema = harnessLaunchSettingsGetSchema.extend({
15253
- path: harnessLaunchPathSchema.nullable()
15454
+ var harnessHistoryCapabilitiesSchema = external_exports.object({
15455
+ fork: external_exports.boolean(),
15456
+ forkAcrossCwd: external_exports.boolean(),
15457
+ rollbackLastTurn: external_exports.boolean()
15458
+ }).strict().refine((history) => history.fork || !history.forkAcrossCwd, {
15459
+ path: ["forkAcrossCwd"],
15460
+ message: "Cross-cwd Fork requires exact history Fork support"
15254
15461
  });
15255
- var harnessLaunchSettingsSchema = external_exports.object({
15256
- path: harnessLaunchPathSchema.nullable(),
15257
- restartRequired: external_exports.boolean()
15258
- }).strict();
15259
-
15260
- // ../../shared-contracts/dist/harness-installation.js
15261
- var harnessInstallationParamsSchema = external_exports.object({
15262
- harnessId: harnessIdSchema,
15263
- action: external_exports.enum(["check", "update"])
15264
- }).strict();
15265
- var harnessInstallationStateSchema = external_exports.object({
15266
- currentVersion: external_exports.string().min(1).max(128),
15267
- latestVersion: external_exports.string().min(1).max(128),
15268
- updateAvailable: external_exports.boolean(),
15269
- canUpdate: external_exports.boolean(),
15270
- message: external_exports.string().max(2048).optional()
15271
- }).strict();
15272
-
15273
- // ../../shared-contracts/dist/codex-accounts.js
15274
- var accountIdSchema = external_exports.string().min(1).max(256).regex(/^[A-Za-z0-9._~-]+$/u);
15275
- var nonBlankTextSchema3 = external_exports.string().trim().min(1);
15276
- var codexAccountPlanTypeSchema = external_exports.enum([
15277
- "free",
15278
- "go",
15279
- "plus",
15280
- "pro",
15281
- "prolite",
15282
- "team",
15283
- "self_serve_business_prolite",
15284
- "self_serve_business_usage_based",
15285
- "business",
15286
- "ent26",
15287
- "enterprise_cbp_automation",
15288
- "enterprise_cbp_usage_based",
15289
- "enterprise",
15290
- "edu",
15291
- "edu_plus",
15292
- "edu_pro",
15293
- "unknown"
15294
- ]);
15295
- var codexAccountSchema = external_exports.object({
15296
- accountId: accountIdSchema,
15297
- label: nonBlankTextSchema3.max(256),
15298
- email: external_exports.string().email().max(320).optional(),
15299
- planType: codexAccountPlanTypeSchema.optional()
15300
- }).strict();
15301
- var codexAccountPhaseSchema = external_exports.enum(["ready", "unavailable"]);
15302
- var codexAccountListResultSchema = external_exports.object({
15303
- version: external_exports.literal(2),
15304
- currentAccountId: accountIdSchema.nullable(),
15305
- phase: codexAccountPhaseSchema,
15306
- revision: external_exports.number().int().nonnegative(),
15307
- instanceId: nonBlankTextSchema3.max(1024).optional(),
15308
- accounts: external_exports.array(codexAccountSchema).max(1)
15309
- }).strict();
15310
- var codexAccountUsageParamsSchema = external_exports.object({ accountId: accountIdSchema, refresh: external_exports.boolean().optional() }).strict();
15311
- var codexAccountUsageResultSchema = external_exports.object({
15312
- accountId: accountIdSchema,
15313
- usage: threadUsageSnapshotSchema.nullable(),
15314
- accountCredits: accountCreditsSnapshotSchema.optional(),
15315
- freshness: external_exports.enum(["live", "cached"]),
15316
- observedAt: external_exports.string().datetime().nullable()
15317
- }).strict();
15318
-
15319
- // ../../shared-contracts/dist/harness-session-import.js
15320
- var HARNESS_SESSION_IMPORT_ID_MAX_LENGTH = 1024;
15321
- var HARNESS_SESSION_IMPORT_CWD_MAX_LENGTH = 16384;
15322
- var HARNESS_SESSION_IMPORT_TITLE_MAX_LENGTH = 4096;
15323
- var HARNESS_SESSION_IMPORT_LIST_MAX_LENGTH = 1e3;
15324
- var HARNESS_SESSION_IMPORT_UPDATED_AT_MAX = 864e13;
15325
- 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");
15326
- var harnessSessionImportIdSchema = nonBlankTextSchema4.max(HARNESS_SESSION_IMPORT_ID_MAX_LENGTH);
15327
- var harnessSessionImportCandidateSchema = external_exports.object({
15328
- nativeSessionId: harnessSessionImportIdSchema,
15329
- title: nonBlankTextSchema4.max(HARNESS_SESSION_IMPORT_TITLE_MAX_LENGTH).nullable(),
15330
- updatedAt: external_exports.number().int().nonnegative().max(HARNESS_SESSION_IMPORT_UPDATED_AT_MAX),
15331
- cwd: nonBlankTextSchema4.max(HARNESS_SESSION_IMPORT_CWD_MAX_LENGTH),
15332
- // Native file discovery cannot reliably observe another process's activity.
15333
- running: external_exports.boolean().nullable()
15334
- }).strict();
15335
- var harnessSessionImportSourcesParamsSchema = external_exports.object({}).strict();
15336
- var harnessSessionImportSourcesResultSchema = external_exports.object({
15337
- harnesses: external_exports.array(external_exports.object({
15338
- harnessId: harnessPluginIdSchema,
15339
- name: nonBlankTextSchema4.max(128)
15340
- }).strict()).max(128)
15341
- }).strict();
15342
- var harnessSessionListParamsSchema = external_exports.object({
15343
- harnessId: harnessPluginIdSchema,
15344
- query: external_exports.string().trim().max(4096).refine((value) => !value.includes("\0")).optional(),
15345
- offset: external_exports.number().int().nonnegative().safe().optional(),
15346
- limit: external_exports.number().int().min(1).max(HARNESS_SESSION_IMPORT_LIST_MAX_LENGTH).optional()
15347
- }).strict();
15348
- var harnessSessionListResultSchema = external_exports.object({
15349
- candidates: external_exports.array(harnessSessionImportCandidateSchema).max(HARNESS_SESSION_IMPORT_LIST_MAX_LENGTH),
15350
- total: external_exports.number().int().nonnegative().safe()
15351
- }).strict();
15352
- var harnessSessionImportParamsSchema = external_exports.object({
15353
- harnessId: harnessPluginIdSchema,
15354
- nativeSessionId: harnessSessionImportIdSchema
15462
+ var harnessPermissionModeScopeSchema = external_exports.enum(["live", "atCreate"]);
15463
+ var harnessSessionCapabilitiesSchema = external_exports.object({
15464
+ configuration: external_exports.object({
15465
+ selectModel: external_exports.boolean(),
15466
+ selectThinkingOption: external_exports.boolean(),
15467
+ selectPermissionMode: external_exports.boolean(),
15468
+ permissionModeScope: harnessPermissionModeScopeSchema.default("live")
15469
+ }).strict(),
15470
+ history: harnessHistoryCapabilitiesSchema,
15471
+ subagents: external_exports.object({
15472
+ observe: external_exports.boolean(),
15473
+ readTranscript: external_exports.boolean()
15474
+ }).strict().optional(),
15475
+ autonomousTurns: external_exports.object({
15476
+ observe: external_exports.boolean()
15477
+ }).strict().optional()
15355
15478
  }).strict();
15356
- var harnessSessionImportResultSchema = external_exports.object({
15357
- threadId: nonBlankTextSchema4.max(1024).pipe(hostThreadIdSchema)
15479
+ var harnessConfigurationStateSchema = external_exports.object({
15480
+ effectiveModel: harnessModelRefSchema.optional(),
15481
+ resolvedModelLabel: harnessResolvedModelLabelSchema.optional(),
15482
+ effectiveThinkingOptionId: harnessThinkingOptionIdSchema.optional(),
15483
+ availableThinkingOptions: harnessThinkingOptionsSchema.optional(),
15484
+ effectivePermissionModeId: harnessPermissionModeIdSchema.optional()
15485
+ }).strict().superRefine((state, context) => {
15486
+ if (state.effectiveThinkingOptionId && state.availableThinkingOptions && !state.availableThinkingOptions.some(({ id }) => id === state.effectiveThinkingOptionId)) {
15487
+ context.addIssue({
15488
+ code: "custom",
15489
+ message: "Effective Thinking option must be currently available",
15490
+ path: ["effectiveThinkingOptionId"]
15491
+ });
15492
+ }
15493
+ });
15494
+ var harnessWebUiCapabilitySchema = external_exports.object({
15495
+ open: external_exports.literal(true)
15358
15496
  }).strict();
15359
-
15360
- // ../../shared-contracts/dist/deepseek-modern-sessions.js
15361
- var DEEPSEEK_MODERN_SESSION_LIST_MAX_LENGTH = HARNESS_SESSION_IMPORT_LIST_MAX_LENGTH;
15362
- var DEEPSEEK_MODERN_HOST_THREAD_ID_MAX_LENGTH = 1024;
15363
- 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");
15364
- var deepSeekModernSessionIdSchema = harnessSessionImportIdSchema;
15365
- var deepSeekModernSessionCandidateSchema = harnessSessionImportCandidateSchema;
15366
- var deepSeekModernSessionListParamsSchema = external_exports.object({}).strict();
15367
- var deepSeekModernSessionListResultSchema = external_exports.object({
15368
- candidates: external_exports.array(deepSeekModernSessionCandidateSchema).max(DEEPSEEK_MODERN_SESSION_LIST_MAX_LENGTH)
15497
+ var readyHarnessInspectionSchema = external_exports.object({
15498
+ status: external_exports.literal("ready"),
15499
+ catalog: harnessModelCatalogSchema,
15500
+ permissionModes: harnessPermissionModeCatalogSchema.optional(),
15501
+ capabilities: harnessSessionCapabilitiesSchema,
15502
+ webUi: harnessWebUiCapabilitySchema.optional()
15503
+ }).strict().superRefine((inspection, context) => {
15504
+ const selectable = inspection.capabilities.configuration.selectPermissionMode;
15505
+ if (selectable !== Boolean(inspection.permissionModes)) {
15506
+ context.addIssue({
15507
+ code: "custom",
15508
+ message: "Permission Mode catalog and capability must agree",
15509
+ path: selectable ? ["permissionModes"] : ["capabilities", "configuration", "selectPermissionMode"]
15510
+ });
15511
+ }
15512
+ });
15513
+ var failedHarnessInspectionSchema = external_exports.object({
15514
+ status: external_exports.enum(["notInstalled", "unavailable", "error"]),
15515
+ error: codexhostErrorSchema
15369
15516
  }).strict();
15370
- var deepSeekModernSessionImportParamsSchema = external_exports.object({
15371
- nativeSessionId: deepSeekModernSessionIdSchema
15517
+ var harnessInspectionSchema = external_exports.union([
15518
+ readyHarnessInspectionSchema,
15519
+ failedHarnessInspectionSchema
15520
+ ]);
15521
+ var harnessInspectParamsSchema = external_exports.object({
15522
+ harnessId: harnessIdSchema,
15523
+ cwd: nonBlankTextSchema2.max(16384).optional(),
15524
+ refresh: external_exports.boolean().optional()
15372
15525
  }).strict();
15373
- var deepSeekModernSessionImportResultSchema = external_exports.object({
15374
- threadId: nonBlankTextSchema5.max(DEEPSEEK_MODERN_HOST_THREAD_ID_MAX_LENGTH).pipe(hostThreadIdSchema)
15526
+ var harnessWebUiOpenParamsSchema = external_exports.object({
15527
+ harnessId: harnessIdSchema
15375
15528
  }).strict();
15376
-
15377
- // ../../shared-contracts/dist/external-thread-fork.js
15378
- var externalThreadForkParamsSchema = external_exports.object({
15529
+ var harnessWebUiOpenResultSchema = external_exports.object({}).strict();
15530
+ var threadModelSelectParamsSchema = external_exports.object({
15379
15531
  threadId: hostThreadIdSchema,
15380
- lastTurnId: hostTurnIdSchema
15381
- }).strict();
15382
- var externalThreadForkResultSchema = external_exports.object({
15383
- threadId: hostThreadIdSchema
15384
- }).strict();
15385
-
15386
- // ../../shared-contracts/dist/harness-commands.js
15387
- var commandIdSchema = external_exports.string().trim().min(1).max(128).regex(/^[A-Za-z0-9._:-]+$/u).brand();
15388
- var commandInvocationSchema = external_exports.string().min(1).max(128);
15389
- var commandLabelSchema = external_exports.string().trim().min(1).max(128);
15390
- var commandDescriptionSchema = external_exports.string().trim().min(1).max(512);
15391
- var harnessCommandDescriptorSchema = external_exports.object({
15392
- id: commandIdSchema,
15393
- invocation: commandInvocationSchema,
15394
- label: commandLabelSchema,
15395
- description: commandDescriptionSchema.optional(),
15396
- argumentMode: external_exports.enum(["none", "text"]),
15397
- /**
15398
- * Native distinction reported by the Harness. Omitted when the Harness does
15399
- * not tell skills and commands apart; consumers treat that as "command".
15400
- */
15401
- kind: external_exports.enum(["command", "skill"]).optional()
15402
- }).strict();
15403
- var harnessCommandCatalogSchema = external_exports.object({
15404
- commands: external_exports.array(harnessCommandDescriptorSchema),
15405
- /**
15406
- * `live` when the catalog includes what a native Session reports for its
15407
- * workspace (custom commands, skills); `static` for Adapter built-ins only.
15408
- * Omitted by Adapters; set by the Host on inspection results.
15409
- */
15410
- source: external_exports.enum(["live", "static"]).optional()
15411
- }).strict().superRefine((catalog, context) => {
15412
- const ids = /* @__PURE__ */ new Set();
15413
- for (const [index, command] of catalog.commands.entries()) {
15414
- if (ids.has(command.id)) {
15415
- context.addIssue({
15416
- code: "custom",
15417
- message: "Harness command IDs must be unique",
15418
- path: ["commands", index, "id"]
15419
- });
15420
- }
15421
- ids.add(command.id);
15422
- }
15423
- });
15424
- var harnessCommandsInspectParamsSchema = external_exports.object({
15425
- harnessId: harnessIdSchema,
15426
- /** Workspace of a draft without a Thread, for its live catalog when known. */
15427
- cwd: external_exports.string().min(1).optional()
15532
+ model: harnessModelRefSchema
15428
15533
  }).strict();
15429
- var threadCommandsInspectParamsSchema = external_exports.object({
15430
- threadId: hostThreadIdSchema
15534
+ var threadThinkingSelectParamsSchema = external_exports.object({
15535
+ threadId: hostThreadIdSchema,
15536
+ thinkingOptionId: harnessThinkingOptionIdSchema
15431
15537
  }).strict();
15432
- var threadCommandExecuteParamsSchema = external_exports.object({
15538
+ var threadInspectionParamsSchema = external_exports.object({
15433
15539
  threadId: hostThreadIdSchema,
15434
- commandId: commandIdSchema,
15435
- turnId: hostTurnIdSchema.optional(),
15436
- arguments: jsonObjectSchema.optional()
15540
+ includeReferenceCapability: external_exports.boolean().optional()
15437
15541
  }).strict();
15438
- var threadCommandExecuteResultSchema = external_exports.object({
15439
- accepted: external_exports.literal(true),
15440
- turnId: hostTurnIdSchema
15542
+ var codexThreadInspectionSchema = external_exports.object({
15543
+ owner: external_exports.literal("codex"),
15544
+ locked: external_exports.literal(true),
15545
+ supportsThreadReferences: external_exports.literal(true).optional()
15441
15546
  }).strict();
15442
-
15443
- // ../../shared-contracts/dist/json-rpc.js
15444
- var jsonRpcVersionSchema = external_exports.literal("2.0").optional();
15445
- var absentSchema = external_exports.never().optional();
15446
- var methodSchema = external_exports.string().min(1);
15447
- var jsonRpcIdSchema = external_exports.union([external_exports.string(), external_exports.number().int()]);
15448
- var jsonRpcErrorSchema = external_exports.object({
15449
- code: external_exports.number().int(),
15450
- message: external_exports.string(),
15451
- data: jsonValueSchema.optional()
15452
- }).catchall(jsonValueSchema).superRefine(rejectExplicitUndefined(["data"]));
15453
- var jsonRpcRequestSchema = external_exports.object({
15454
- jsonrpc: jsonRpcVersionSchema,
15455
- id: jsonRpcIdSchema,
15456
- method: methodSchema,
15457
- params: jsonValueSchema.optional(),
15458
- result: absentSchema,
15459
- error: absentSchema
15460
- }).catchall(jsonValueSchema).superRefine(rejectExplicitUndefined(["jsonrpc", "params", "result", "error"]));
15461
- var jsonRpcNotificationSchema = external_exports.object({
15462
- jsonrpc: jsonRpcVersionSchema,
15463
- id: absentSchema,
15464
- method: methodSchema,
15465
- params: jsonValueSchema.optional(),
15466
- result: absentSchema,
15467
- error: absentSchema
15468
- }).catchall(jsonValueSchema).superRefine(rejectExplicitUndefined(["jsonrpc", "id", "params", "result", "error"]));
15469
- var jsonRpcSuccessResponseSchema = external_exports.object({
15470
- jsonrpc: jsonRpcVersionSchema,
15471
- id: jsonRpcIdSchema,
15472
- method: absentSchema,
15473
- params: absentSchema,
15474
- result: jsonValueSchema,
15475
- error: absentSchema
15476
- }).catchall(jsonValueSchema).superRefine(rejectExplicitUndefined(["jsonrpc", "method", "params", "error"]));
15477
- var jsonRpcErrorResponseSchema = external_exports.object({
15478
- jsonrpc: jsonRpcVersionSchema,
15479
- id: jsonRpcIdSchema,
15480
- method: absentSchema,
15481
- params: absentSchema,
15482
- result: absentSchema,
15483
- error: jsonRpcErrorSchema
15484
- }).catchall(jsonValueSchema).superRefine(rejectExplicitUndefined(["jsonrpc", "method", "params", "result"]));
15485
- var jsonRpcEnvelopeSchema = external_exports.union([
15486
- jsonRpcRequestSchema,
15487
- jsonRpcNotificationSchema,
15488
- jsonRpcSuccessResponseSchema,
15489
- jsonRpcErrorResponseSchema
15490
- ]);
15491
-
15492
- // ../../shared-contracts/dist/native-refs.js
15493
- var nativeIdSchema = external_exports.string().refine((value) => value.trim().length > 0, {
15494
- message: "Native identifier must not be empty or whitespace"
15495
- });
15496
- var nativeSessionRefV1RuntimeSchema = external_exports.strictObject({
15497
- harnessId: harnessIdSchema,
15498
- nativeSessionId: nativeIdSchema,
15499
- locator: jsonValueSchema.optional(),
15500
- formatVersion: external_exports.literal(1)
15501
- }).superRefine(rejectExplicitUndefined(["locator"]));
15502
- var nativeSessionRefV1Schema = nativeSessionRefV1RuntimeSchema;
15503
- var nativeSessionRefSchema = nativeSessionRefV1Schema;
15504
- var nativeTurnRefV1Schema = external_exports.strictObject({
15505
- harnessId: harnessIdSchema,
15506
- nativeSessionId: nativeIdSchema,
15507
- nativeTurnKey: nativeIdSchema,
15508
- formatVersion: external_exports.literal(1)
15509
- });
15510
- var nativeTurnRefSchema = nativeTurnRefV1Schema;
15511
- var nativeCheckpointRefV1RuntimeSchema = external_exports.strictObject({
15512
- harnessId: harnessIdSchema,
15513
- nativeSessionId: nativeIdSchema,
15514
- checkpointId: nativeIdSchema,
15515
- locator: jsonValueSchema.optional(),
15516
- formatVersion: external_exports.literal(1)
15517
- }).superRefine(rejectExplicitUndefined(["locator"]));
15518
- var nativeCheckpointRefV1Schema = nativeCheckpointRefV1RuntimeSchema;
15519
- var nativeCheckpointRefSchema = nativeCheckpointRefV1Schema;
15520
-
15521
- // ../../shared-contracts/dist/updates.js
15522
- var UPDATE_ERROR_MAX_LENGTH = 500;
15523
- var UPDATE_SEMVER_PATTERN = /^\d+\.\d+\.\d+(?:-[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?(?:\+[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?$/u;
15524
- var updateSemanticVersionSchema = external_exports.string().regex(UPDATE_SEMVER_PATTERN);
15525
- var updateInstallationSchema = external_exports.enum(["npm", "windows-installer", "macos-dmg"]);
15526
- var updatePhaseSchema = external_exports.enum([
15527
- "prepared",
15528
- "downloading",
15529
- "waiting-for-exit",
15530
- "installing",
15531
- "restarting",
15532
- "succeeded",
15533
- "failed"
15534
- ]);
15535
- var updateStatusSchema = external_exports.strictObject({
15536
- version: updateSemanticVersionSchema,
15537
- installation: updateInstallationSchema,
15538
- phase: updatePhaseSchema,
15539
- updatedAt: external_exports.number().int().nonnegative(),
15540
- downloadedBytes: external_exports.number().int().nonnegative().optional(),
15541
- totalBytes: external_exports.number().int().positive().optional(),
15542
- error: external_exports.string().min(1).max(UPDATE_ERROR_MAX_LENGTH).nullable()
15543
- }).superRefine((status, context) => {
15544
- if (status.downloadedBytes !== void 0 && status.totalBytes !== void 0 && status.downloadedBytes > status.totalBytes) {
15545
- context.addIssue({
15546
- code: "custom",
15547
- path: ["downloadedBytes"],
15548
- message: "downloadedBytes must not exceed totalBytes"
15549
- });
15547
+ var externalThreadInspectionSchema = external_exports.object({
15548
+ owner: external_exports.literal("external"),
15549
+ harnessId: nonBlankTextSchema2.max(256),
15550
+ transportModelId: nonBlankTextSchema2.max(1024),
15551
+ effectiveModel: harnessModelRefSchema.optional(),
15552
+ resolvedModelLabel: harnessResolvedModelLabelSchema.optional(),
15553
+ effectiveThinkingOptionId: harnessThinkingOptionIdSchema.optional(),
15554
+ availableThinkingOptions: harnessThinkingOptionsSchema.optional(),
15555
+ effectivePermissionModeId: harnessPermissionModeIdSchema.optional(),
15556
+ history: harnessHistoryCapabilitiesSchema,
15557
+ usage: threadUsageSnapshotSchema.optional(),
15558
+ locked: external_exports.literal(true)
15559
+ }).strict();
15560
+ var threadInspectionSchema = external_exports.discriminatedUnion("owner", [
15561
+ codexThreadInspectionSchema,
15562
+ externalThreadInspectionSchema
15563
+ ]);
15564
+ var threadOwnershipListParamsSchema = external_exports.object({
15565
+ threadIds: external_exports.array(hostThreadIdSchema).min(1).max(THREAD_OWNERSHIP_LIST_MAX_LENGTH)
15566
+ }).strict().superRefine(({ threadIds }, context) => {
15567
+ const seen = /* @__PURE__ */ new Set();
15568
+ for (const [index, threadId] of threadIds.entries()) {
15569
+ if (seen.has(threadId)) {
15570
+ context.addIssue({
15571
+ code: "custom",
15572
+ message: "Thread ownership-list IDs must be unique",
15573
+ path: ["threadIds", index]
15574
+ });
15575
+ }
15576
+ seen.add(threadId);
15550
15577
  }
15551
15578
  });
15552
- var updateEmptyParamsSchema = external_exports.strictObject({});
15553
- var githubReleaseNotesUrlSchema = external_exports.string().max(300).regex(/^https:\/\/github\.com\/BytePioneer-AI\/codex-host\/releases\/tag\/v[0-9A-Za-z.+-]+$/u, "release notes URL must identify a codexhost GitHub Release");
15554
- var updateCheckResultSchema = external_exports.strictObject({
15555
- currentVersion: updateSemanticVersionSchema,
15556
- installation: updateInstallationSchema.nullable(),
15557
- latestVersion: updateSemanticVersionSchema.nullable(),
15558
- updateAvailable: external_exports.boolean(),
15559
- installationAvailable: external_exports.boolean(),
15560
- releaseNotes: external_exports.string().min(1).max(2e4).nullable(),
15561
- releaseNotesUrl: githubReleaseNotesUrlSchema.nullable(),
15562
- status: updateStatusSchema.nullable(),
15563
- error: external_exports.string().min(1).max(UPDATE_ERROR_MAX_LENGTH).nullable()
15564
- });
15565
- var updateStartResultSchema = external_exports.strictObject({
15566
- status: updateStatusSchema
15579
+ var codexThreadOwnershipSchema = external_exports.object({
15580
+ threadId: hostThreadIdSchema,
15581
+ owner: external_exports.literal("codex")
15582
+ }).strict();
15583
+ var externalThreadOwnershipSchema = external_exports.object({
15584
+ threadId: hostThreadIdSchema,
15585
+ owner: external_exports.literal("external"),
15586
+ harnessId: external_exports.string().max(256).pipe(harnessIdSchema)
15587
+ }).strict();
15588
+ var threadOwnershipSchema = external_exports.discriminatedUnion("owner", [
15589
+ codexThreadOwnershipSchema,
15590
+ externalThreadOwnershipSchema
15591
+ ]);
15592
+ var threadOwnershipListResultSchema = external_exports.object({
15593
+ threads: external_exports.array(threadOwnershipSchema).min(1).max(THREAD_OWNERSHIP_LIST_MAX_LENGTH)
15594
+ }).strict().superRefine(({ threads }, context) => {
15595
+ const seen = /* @__PURE__ */ new Set();
15596
+ for (const [index, thread] of threads.entries()) {
15597
+ if (seen.has(thread.threadId)) {
15598
+ context.addIssue({
15599
+ code: "custom",
15600
+ message: "Thread ownership-list results must be unique",
15601
+ path: ["threads", index, "threadId"]
15602
+ });
15603
+ }
15604
+ seen.add(thread.threadId);
15605
+ }
15567
15606
  });
15568
- var updateStatusResultSchema = external_exports.strictObject({
15569
- status: updateStatusSchema.nullable()
15607
+
15608
+ // ../../shared-contracts/dist/harness-plugins.js
15609
+ var HARNESS_PLUGIN_MANIFEST_MAX_BYTES = 32 * 1024;
15610
+ var HARNESS_PLUGIN_ICON_MAX_BYTES = 128 * 1024;
15611
+ var HARNESS_PLUGIN_LIMIT = 128;
15612
+ 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);
15613
+ 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");
15614
+ var documentationUrlSchema = external_exports.url().refine((value) => /^https:\/\/[^/?#@]+(?:[/?#]|$)/iu.test(value), "Plugin documentation links must be credential-free HTTPS URLs");
15615
+ var pluginPresentationShape = {
15616
+ id: harnessPluginIdSchema,
15617
+ name: external_exports.string().trim().min(1).max(128),
15618
+ version: external_exports.string().min(1).max(128),
15619
+ /** The factory accepts a persisted local entrypoint through its construction context. */
15620
+ launchCommand: external_exports.literal(true).optional(),
15621
+ links: external_exports.object({
15622
+ documentation: documentationUrlSchema.optional(),
15623
+ installation: documentationUrlSchema.optional()
15624
+ }).strict().optional()
15625
+ };
15626
+ var harnessPluginManifestSchema = external_exports.object({
15627
+ manifestVersion: external_exports.literal(1),
15628
+ ...pluginPresentationShape,
15629
+ adapterApiVersion: external_exports.number().int().positive(),
15630
+ entry: relativeResourceSchema,
15631
+ icon: relativeResourceSchema.optional()
15632
+ }).strict();
15633
+ 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);
15634
+ var harnessPluginDescriptorSchema = external_exports.object({
15635
+ ...pluginPresentationShape,
15636
+ icon: harnessPluginIconSchema.optional()
15637
+ }).strict();
15638
+ var harnessPluginListParamsSchema = external_exports.object({}).strict();
15639
+ var harnessPluginListResultSchema = external_exports.object({
15640
+ plugins: external_exports.array(harnessPluginDescriptorSchema).max(HARNESS_PLUGIN_LIMIT)
15641
+ }).strict();
15642
+ var harnessPluginConfigurationSchema = external_exports.object({
15643
+ version: external_exports.literal(1),
15644
+ enabled: external_exports.array(harnessPluginIdSchema).max(HARNESS_PLUGIN_LIMIT)
15645
+ }).strict().refine((value) => new Set(value.enabled).size === value.enabled.length, {
15646
+ message: "Enabled plugin IDs must be unique",
15647
+ path: ["enabled"]
15570
15648
  });
15571
15649
 
15572
- // ../../shared-contracts/dist/index.js
15573
- var workspaceContractVersionSchema = external_exports.literal(WORKSPACE_CONTRACT_VERSION);
15650
+ // ../../shared-contracts/dist/harness-route.js
15651
+ var harnessPluginRouteSchema = external_exports.object({
15652
+ harnessId: harnessPluginIdSchema,
15653
+ model: harnessModelRefSchema.optional(),
15654
+ thinkingOptionId: harnessThinkingOptionIdSchema.optional(),
15655
+ permissionModeId: harnessPermissionModeIdSchema.optional()
15656
+ }).strict();
15574
15657
 
15575
- // ../../harness-adapter/dist/question.js
15576
- function invalidRequest(message) {
15577
- return { code: "invalidRequest", message, retryable: false };
15578
- }
15579
- function validateHostQuestionResponse(interaction, response) {
15580
- const questionIds = new Set(interaction.questions.map(({ id }) => id));
15581
- if (response.cancelled) {
15582
- return Object.keys(response.answers).length === 0 ? null : invalidRequest("Cancelled Question Response must not contain answers");
15583
- }
15584
- for (const answerId of Object.keys(response.answers)) {
15585
- if (!questionIds.has(answerId)) {
15586
- return invalidRequest("Question Response contains an unknown Question ID");
15587
- }
15588
- }
15589
- for (const question of interaction.questions) {
15590
- const answers = response.answers[question.id] ?? [];
15591
- if (!question.optional && answers.length === 0) {
15592
- return invalidRequest("Question Response omits a required answer");
15593
- }
15594
- if (question.type === "text") {
15595
- if (answers.length > 1) {
15596
- return invalidRequest("Text Question accepts at most one answer");
15597
- }
15598
- continue;
15599
- }
15600
- if (!question.multiple && answers.length > 1) {
15601
- return invalidRequest("Single-choice Question accepts at most one answer");
15602
- }
15603
- const declared = new Set(question.options.map(({ value }) => value));
15604
- if (!question.allowOther && answers.some((answer) => !declared.has(answer))) {
15605
- return invalidRequest("Question Response contains an undeclared choice");
15606
- }
15607
- }
15608
- return null;
15609
- }
15658
+ // ../../shared-contracts/dist/harness-launch-settings.js
15659
+ var harnessLaunchPathSchema = external_exports.string().trim().min(1).max(4096).refine((value) => !/[\u0000\r\n]/u.test(value), "Invalid entrypoint path");
15660
+ var harnessLaunchSettingsGetSchema = external_exports.object({
15661
+ harnessId: harnessPluginIdSchema
15662
+ }).strict();
15663
+ var harnessLaunchSettingsSetSchema = harnessLaunchSettingsGetSchema.extend({
15664
+ path: harnessLaunchPathSchema.nullable()
15665
+ });
15666
+ var harnessLaunchSettingsSchema = external_exports.object({
15667
+ path: harnessLaunchPathSchema.nullable(),
15668
+ restartRequired: external_exports.boolean()
15669
+ }).strict();
15610
15670
 
15611
- // ../../harness-adapter/dist/output-channel.js
15612
- var HarnessOutputChannel = class {
15613
- outputs;
15614
- #consumerCreated = false;
15615
- #ended = false;
15616
- #pending = [];
15617
- #values = [];
15618
- constructor() {
15619
- this.outputs = {
15620
- [Symbol.asyncIterator]: () => {
15621
- if (this.#consumerCreated) {
15622
- throw new Error("Harness outputs allow only one consumer");
15623
- }
15624
- this.#consumerCreated = true;
15625
- return {
15626
- next: () => this.#next()
15627
- };
15628
- }
15629
- };
15630
- }
15631
- emit(value) {
15632
- if (this.#ended)
15633
- return false;
15634
- const resolve = this.#pending.shift();
15635
- if (resolve)
15636
- resolve({ done: false, value });
15637
- else
15638
- this.#values.push(value);
15639
- return true;
15640
- }
15641
- end() {
15642
- if (this.#ended)
15643
- return;
15644
- this.#ended = true;
15645
- if (this.#values.length !== 0)
15646
- return;
15647
- for (const resolve of this.#pending.splice(0))
15648
- resolve({ done: true, value: void 0 });
15649
- }
15650
- #next() {
15651
- const value = this.#values.shift();
15652
- if (value !== void 0)
15653
- return Promise.resolve({ done: false, value });
15654
- if (this.#ended)
15655
- return Promise.resolve({ done: true, value: void 0 });
15656
- return new Promise((resolve) => this.#pending.push(resolve));
15657
- }
15658
- };
15671
+ // ../../shared-contracts/dist/harness-installation.js
15672
+ var harnessInstallationParamsSchema = external_exports.object({
15673
+ harnessId: harnessIdSchema,
15674
+ action: external_exports.enum(["check", "update", "install"])
15675
+ }).strict();
15676
+ var harnessInstallationStateSchema = external_exports.object({
15677
+ currentVersion: external_exports.string().min(1).max(128),
15678
+ latestVersion: external_exports.string().min(1).max(128),
15679
+ updateAvailable: external_exports.boolean(),
15680
+ canUpdate: external_exports.boolean(),
15681
+ // Adapter-owned diagnostic text; UI uses messageCode rather than displaying it verbatim.
15682
+ message: external_exports.string().max(2048).optional(),
15683
+ messageCode: external_exports.string().min(1).max(128).optional(),
15684
+ latestVersionKind: external_exports.enum(["unknown", "tracking-branch"]).optional()
15685
+ }).strict();
15686
+
15687
+ // ../../shared-contracts/dist/codex-accounts.js
15688
+ var accountIdSchema = external_exports.string().min(1).max(256).regex(/^[A-Za-z0-9._~-]+$/u);
15689
+ var nonBlankTextSchema3 = external_exports.string().trim().min(1);
15690
+ var codexAccountPlanTypeSchema = external_exports.enum([
15691
+ "free",
15692
+ "go",
15693
+ "plus",
15694
+ "pro",
15695
+ "prolite",
15696
+ "team",
15697
+ "self_serve_business_prolite",
15698
+ "self_serve_business_usage_based",
15699
+ "business",
15700
+ "ent26",
15701
+ "enterprise_cbp_automation",
15702
+ "enterprise_cbp_usage_based",
15703
+ "enterprise",
15704
+ "edu",
15705
+ "edu_plus",
15706
+ "edu_pro",
15707
+ "unknown"
15708
+ ]);
15709
+ var codexAccountSchema = external_exports.object({
15710
+ accountId: accountIdSchema,
15711
+ label: nonBlankTextSchema3.max(256),
15712
+ email: external_exports.string().email().max(320).optional(),
15713
+ planType: codexAccountPlanTypeSchema.optional()
15714
+ }).strict();
15715
+ var codexAccountPhaseSchema = external_exports.enum(["ready", "unavailable"]);
15716
+ var codexAccountListResultSchema = external_exports.object({
15717
+ version: external_exports.literal(2),
15718
+ currentAccountId: accountIdSchema.nullable(),
15719
+ phase: codexAccountPhaseSchema,
15720
+ revision: external_exports.number().int().nonnegative(),
15721
+ instanceId: nonBlankTextSchema3.max(1024).optional(),
15722
+ accounts: external_exports.array(codexAccountSchema).max(1)
15723
+ }).strict();
15724
+ var codexAccountUsageParamsSchema = external_exports.object({ accountId: accountIdSchema, refresh: external_exports.boolean().optional() }).strict();
15725
+ var codexAccountUsageResultSchema = external_exports.object({
15726
+ accountId: accountIdSchema,
15727
+ usage: threadUsageSnapshotSchema.nullable(),
15728
+ accountCredits: accountCreditsSnapshotSchema.optional(),
15729
+ freshness: external_exports.enum(["live", "cached"]),
15730
+ observedAt: external_exports.string().datetime().nullable()
15731
+ }).strict();
15659
15732
 
15660
- // ../../harness-adapter/dist/diagnostics.js
15661
- var DIAGNOSTIC_TAIL_MAX_LENGTH = 8e3;
15662
- var SENSITIVE_VALUE_PATTERN = /(api[_-]?key|access[_-]?token|auth(?:orization)?|password|secret)(\s*[:=]\s*)([^\s,;]+)/giu;
15663
- var BEARER_PATTERN = /\bBearer\s+[A-Za-z0-9._~+/=-]+/giu;
15664
- function sanitizeDiagnosticTail(value) {
15665
- const redacted = value.replace(BEARER_PATTERN, "Bearer [redacted]").replace(SENSITIVE_VALUE_PATTERN, "$1$2[redacted]");
15666
- return redacted.length <= DIAGNOSTIC_TAIL_MAX_LENGTH ? redacted : redacted.slice(-DIAGNOSTIC_TAIL_MAX_LENGTH);
15667
- }
15733
+ // ../../shared-contracts/dist/harness-session-import.js
15734
+ var HARNESS_SESSION_IMPORT_ID_MAX_LENGTH = 1024;
15735
+ var HARNESS_SESSION_IMPORT_CWD_MAX_LENGTH = 16384;
15736
+ var HARNESS_SESSION_IMPORT_TITLE_MAX_LENGTH = 4096;
15737
+ var HARNESS_SESSION_IMPORT_LIST_MAX_LENGTH = 1e3;
15738
+ var HARNESS_SESSION_IMPORT_UPDATED_AT_MAX = 864e13;
15739
+ 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");
15740
+ var harnessSessionImportIdSchema = nonBlankTextSchema4.max(HARNESS_SESSION_IMPORT_ID_MAX_LENGTH);
15741
+ var harnessSessionImportCandidateSchema = external_exports.object({
15742
+ nativeSessionId: harnessSessionImportIdSchema,
15743
+ title: nonBlankTextSchema4.max(HARNESS_SESSION_IMPORT_TITLE_MAX_LENGTH).nullable(),
15744
+ updatedAt: external_exports.number().int().nonnegative().max(HARNESS_SESSION_IMPORT_UPDATED_AT_MAX),
15745
+ cwd: nonBlankTextSchema4.max(HARNESS_SESSION_IMPORT_CWD_MAX_LENGTH),
15746
+ // Native file discovery cannot reliably observe another process's activity.
15747
+ running: external_exports.boolean().nullable()
15748
+ }).strict();
15749
+ var harnessSessionImportSourcesParamsSchema = external_exports.object({}).strict();
15750
+ var harnessSessionImportSourcesResultSchema = external_exports.object({
15751
+ harnesses: external_exports.array(external_exports.object({
15752
+ harnessId: harnessPluginIdSchema,
15753
+ name: nonBlankTextSchema4.max(128)
15754
+ }).strict()).max(128)
15755
+ }).strict();
15756
+ var harnessSessionListParamsSchema = external_exports.object({
15757
+ harnessId: harnessPluginIdSchema,
15758
+ query: external_exports.string().trim().max(4096).refine((value) => !value.includes("\0")).optional(),
15759
+ offset: external_exports.number().int().nonnegative().safe().optional(),
15760
+ limit: external_exports.number().int().min(1).max(HARNESS_SESSION_IMPORT_LIST_MAX_LENGTH).optional()
15761
+ }).strict();
15762
+ var harnessSessionListResultSchema = external_exports.object({
15763
+ candidates: external_exports.array(harnessSessionImportCandidateSchema).max(HARNESS_SESSION_IMPORT_LIST_MAX_LENGTH),
15764
+ total: external_exports.number().int().nonnegative().safe()
15765
+ }).strict();
15766
+ var harnessSessionImportParamsSchema = external_exports.object({
15767
+ harnessId: harnessPluginIdSchema,
15768
+ nativeSessionId: harnessSessionImportIdSchema
15769
+ }).strict();
15770
+ var harnessSessionImportResultSchema = external_exports.object({
15771
+ threadId: nonBlankTextSchema4.max(1024).pipe(hostThreadIdSchema)
15772
+ }).strict();
15668
15773
 
15669
- // ../../harness-adapter/dist/usage.js
15670
- var tokenFields = [
15671
- "inputTokens",
15672
- "cachedInputTokens",
15673
- "cacheWriteInputTokens",
15674
- "outputTokens",
15675
- "outputTokensPerSecond",
15676
- "reasoningOutputTokens",
15677
- "totalTokens",
15678
- "contextWindowTokens",
15679
- "contextUsedTokens"
15680
- ];
15681
- var safeIntegerFields = [
15682
- "planFiveHourResetsAtUnix",
15683
- "planSevenDayResetsAtUnix"
15684
- ];
15685
- var percentFields = [
15686
- "cacheHitRatePercent",
15687
- "planFiveHourUsedPercent",
15688
- "planSevenDayUsedPercent"
15689
- ];
15690
- var usageFields = /* @__PURE__ */ new Set([
15691
- ...tokenFields,
15692
- ...safeIntegerFields,
15693
- ...percentFields,
15694
- "totalCostUsd",
15695
- "totalCredits",
15696
- "contextUsagePercent"
15697
- ]);
15774
+ // ../../shared-contracts/dist/deepseek-modern-sessions.js
15775
+ var DEEPSEEK_MODERN_SESSION_LIST_MAX_LENGTH = HARNESS_SESSION_IMPORT_LIST_MAX_LENGTH;
15776
+ var DEEPSEEK_MODERN_HOST_THREAD_ID_MAX_LENGTH = 1024;
15777
+ 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");
15778
+ var deepSeekModernSessionIdSchema = harnessSessionImportIdSchema;
15779
+ var deepSeekModernSessionCandidateSchema = harnessSessionImportCandidateSchema;
15780
+ var deepSeekModernSessionListParamsSchema = external_exports.object({}).strict();
15781
+ var deepSeekModernSessionListResultSchema = external_exports.object({
15782
+ candidates: external_exports.array(deepSeekModernSessionCandidateSchema).max(DEEPSEEK_MODERN_SESSION_LIST_MAX_LENGTH)
15783
+ }).strict();
15784
+ var deepSeekModernSessionImportParamsSchema = external_exports.object({
15785
+ nativeSessionId: deepSeekModernSessionIdSchema
15786
+ }).strict();
15787
+ var deepSeekModernSessionImportResultSchema = external_exports.object({
15788
+ threadId: nonBlankTextSchema5.max(DEEPSEEK_MODERN_HOST_THREAD_ID_MAX_LENGTH).pipe(hostThreadIdSchema)
15789
+ }).strict();
15698
15790
 
15699
- // ../../harness-discovery/dist/environment.js
15700
- import fs from "node:fs";
15701
- import path from "node:path";
15702
- function targetPath(platform) {
15703
- return platform === "win32" ? path.win32 : path.posix;
15704
- }
15705
- function environmentValue(environment, name) {
15706
- const lowered = name.toLowerCase();
15707
- for (const [key, value] of Object.entries(environment)) {
15708
- if (key.toLowerCase() === lowered)
15709
- return value;
15710
- }
15711
- return void 0;
15712
- }
15713
- function pathDelimiter(platform) {
15714
- return platform === "win32" ? ";" : ":";
15715
- }
15716
- function pathDirectories(environment, platform) {
15717
- return (environmentValue(environment, "PATH") ?? "").split(pathDelimiter(platform)).map((directory) => directory.trim().replace(/^"|"$/gu, "")).filter(Boolean);
15718
- }
15719
- function executableExtensions(command, platform, environment) {
15720
- if (platform !== "win32")
15721
- return [""];
15722
- if (targetPath(platform).extname(command) !== "")
15723
- return [""];
15724
- return (environmentValue(environment, "PATHEXT") ?? ".COM;.EXE;.BAT;.CMD").split(";").map((extension) => extension.trim()).filter(Boolean);
15725
- }
15726
- function isExecutableFile(filePath, platform) {
15727
- try {
15728
- fs.accessSync(filePath, platform === "win32" ? fs.constants.F_OK : fs.constants.X_OK);
15729
- return fs.statSync(filePath).isFile();
15730
- } catch {
15731
- return false;
15732
- }
15733
- }
15734
- function subdirectoryNames(directory) {
15735
- try {
15736
- return fs.readdirSync(directory, { withFileTypes: true }).filter((entry) => entry.isDirectory()).map((entry) => entry.name);
15737
- } catch {
15738
- return [];
15791
+ // ../../shared-contracts/dist/external-thread-fork.js
15792
+ var externalThreadForkParamsSchema = external_exports.object({
15793
+ threadId: hostThreadIdSchema,
15794
+ lastTurnId: hostTurnIdSchema
15795
+ }).strict();
15796
+ var externalThreadForkResultSchema = external_exports.object({
15797
+ threadId: hostThreadIdSchema
15798
+ }).strict();
15799
+
15800
+ // ../../shared-contracts/dist/harness-commands.js
15801
+ var commandIdSchema = external_exports.string().trim().min(1).max(128).regex(/^[A-Za-z0-9._:-]+$/u).brand();
15802
+ var commandInvocationSchema = external_exports.string().min(1).max(128);
15803
+ var commandLabelSchema = external_exports.string().trim().min(1).max(128);
15804
+ var commandDescriptionSchema = external_exports.string().trim().min(1).max(512);
15805
+ var harnessCommandDescriptorSchema = external_exports.object({
15806
+ id: commandIdSchema,
15807
+ invocation: commandInvocationSchema,
15808
+ label: commandLabelSchema,
15809
+ description: commandDescriptionSchema.optional(),
15810
+ argumentMode: external_exports.enum(["none", "text"]),
15811
+ /**
15812
+ * Native distinction reported by the Harness. Omitted when the Harness does
15813
+ * not tell skills and commands apart; consumers treat that as "command".
15814
+ */
15815
+ kind: external_exports.enum(["command", "skill"]).optional()
15816
+ }).strict();
15817
+ var harnessCommandCatalogSchema = external_exports.object({
15818
+ commands: external_exports.array(harnessCommandDescriptorSchema),
15819
+ /**
15820
+ * `live` when the catalog includes what a native Session reports for its
15821
+ * workspace (custom commands, skills); `static` for Adapter built-ins only.
15822
+ * Omitted by Adapters; set by the Host on inspection results.
15823
+ */
15824
+ source: external_exports.enum(["live", "static"]).optional()
15825
+ }).strict().superRefine((catalog, context) => {
15826
+ const ids = /* @__PURE__ */ new Set();
15827
+ for (const [index, command] of catalog.commands.entries()) {
15828
+ if (ids.has(command.id)) {
15829
+ context.addIssue({
15830
+ code: "custom",
15831
+ message: "Harness command IDs must be unique",
15832
+ path: ["commands", index, "id"]
15833
+ });
15834
+ }
15835
+ ids.add(command.id);
15739
15836
  }
15740
- }
15741
- function newestFirst(names) {
15742
- return [...names].sort((left, right) => right.localeCompare(left, void 0, { numeric: true }));
15743
- }
15837
+ });
15838
+ var harnessCommandsInspectParamsSchema = external_exports.object({
15839
+ harnessId: harnessIdSchema,
15840
+ /** Workspace of a draft without a Thread, for its live catalog when known. */
15841
+ cwd: external_exports.string().min(1).optional()
15842
+ }).strict();
15843
+ var threadCommandsInspectParamsSchema = external_exports.object({
15844
+ threadId: hostThreadIdSchema
15845
+ }).strict();
15846
+ var threadCommandExecuteParamsSchema = external_exports.object({
15847
+ threadId: hostThreadIdSchema,
15848
+ commandId: commandIdSchema,
15849
+ turnId: hostTurnIdSchema.optional(),
15850
+ arguments: jsonObjectSchema.optional()
15851
+ }).strict();
15852
+ var threadCommandExecuteResultSchema = external_exports.object({
15853
+ accepted: external_exports.literal(true),
15854
+ turnId: hostTurnIdSchema
15855
+ }).strict();
15856
+
15857
+ // ../../shared-contracts/dist/json-rpc.js
15858
+ var jsonRpcVersionSchema = external_exports.literal("2.0").optional();
15859
+ var absentSchema = external_exports.never().optional();
15860
+ var methodSchema = external_exports.string().min(1);
15861
+ var jsonRpcIdSchema = external_exports.union([external_exports.string(), external_exports.number().int()]);
15862
+ var jsonRpcErrorSchema = external_exports.object({
15863
+ code: external_exports.number().int(),
15864
+ message: external_exports.string(),
15865
+ data: jsonValueSchema.optional()
15866
+ }).catchall(jsonValueSchema).superRefine(rejectExplicitUndefined(["data"]));
15867
+ var jsonRpcRequestSchema = external_exports.object({
15868
+ jsonrpc: jsonRpcVersionSchema,
15869
+ id: jsonRpcIdSchema,
15870
+ method: methodSchema,
15871
+ params: jsonValueSchema.optional(),
15872
+ result: absentSchema,
15873
+ error: absentSchema
15874
+ }).catchall(jsonValueSchema).superRefine(rejectExplicitUndefined(["jsonrpc", "params", "result", "error"]));
15875
+ var jsonRpcNotificationSchema = external_exports.object({
15876
+ jsonrpc: jsonRpcVersionSchema,
15877
+ id: absentSchema,
15878
+ method: methodSchema,
15879
+ params: jsonValueSchema.optional(),
15880
+ result: absentSchema,
15881
+ error: absentSchema
15882
+ }).catchall(jsonValueSchema).superRefine(rejectExplicitUndefined(["jsonrpc", "id", "params", "result", "error"]));
15883
+ var jsonRpcSuccessResponseSchema = external_exports.object({
15884
+ jsonrpc: jsonRpcVersionSchema,
15885
+ id: jsonRpcIdSchema,
15886
+ method: absentSchema,
15887
+ params: absentSchema,
15888
+ result: jsonValueSchema,
15889
+ error: absentSchema
15890
+ }).catchall(jsonValueSchema).superRefine(rejectExplicitUndefined(["jsonrpc", "method", "params", "error"]));
15891
+ var jsonRpcErrorResponseSchema = external_exports.object({
15892
+ jsonrpc: jsonRpcVersionSchema,
15893
+ id: jsonRpcIdSchema,
15894
+ method: absentSchema,
15895
+ params: absentSchema,
15896
+ result: absentSchema,
15897
+ error: jsonRpcErrorSchema
15898
+ }).catchall(jsonValueSchema).superRefine(rejectExplicitUndefined(["jsonrpc", "method", "params", "result"]));
15899
+ var jsonRpcEnvelopeSchema = external_exports.union([
15900
+ jsonRpcRequestSchema,
15901
+ jsonRpcNotificationSchema,
15902
+ jsonRpcSuccessResponseSchema,
15903
+ jsonRpcErrorResponseSchema
15904
+ ]);
15744
15905
 
15745
- // ../../harness-discovery/dist/invocation.js
15746
- import path2 from "node:path";
15747
- function commandInvocation(command, arguments_, environment, platform = process.platform) {
15748
- const extension = path2.win32.extname(command).toLowerCase();
15749
- if (platform !== "win32" || ![".cmd", ".bat"].includes(extension)) {
15750
- return { command, arguments: [...arguments_], windowsVerbatimArguments: false };
15751
- }
15752
- const quote = (value) => `"${value.replaceAll("%", "%%").replaceAll('"', '""')}"`;
15753
- const commandLine = [command, ...arguments_].map(quote).join(" ");
15754
- return {
15755
- command: environmentValue(environment, "ComSpec") ?? "cmd.exe",
15756
- arguments: ["/d", "/v:off", "/s", "/c", `"${commandLine}"`],
15757
- windowsVerbatimArguments: true
15758
- };
15759
- }
15906
+ // ../../shared-contracts/dist/native-refs.js
15907
+ var nativeIdSchema = external_exports.string().refine((value) => value.trim().length > 0, {
15908
+ message: "Native identifier must not be empty or whitespace"
15909
+ });
15910
+ var nativeSessionRefV1RuntimeSchema = external_exports.strictObject({
15911
+ harnessId: harnessIdSchema,
15912
+ nativeSessionId: nativeIdSchema,
15913
+ locator: jsonValueSchema.optional(),
15914
+ formatVersion: external_exports.literal(1)
15915
+ }).superRefine(rejectExplicitUndefined(["locator"]));
15916
+ var nativeSessionRefV1Schema = nativeSessionRefV1RuntimeSchema;
15917
+ var nativeSessionRefSchema = nativeSessionRefV1Schema;
15918
+ var nativeTurnRefV1Schema = external_exports.strictObject({
15919
+ harnessId: harnessIdSchema,
15920
+ nativeSessionId: nativeIdSchema,
15921
+ nativeTurnKey: nativeIdSchema,
15922
+ formatVersion: external_exports.literal(1)
15923
+ });
15924
+ var nativeTurnRefSchema = nativeTurnRefV1Schema;
15925
+ var nativeCheckpointRefV1RuntimeSchema = external_exports.strictObject({
15926
+ harnessId: harnessIdSchema,
15927
+ nativeSessionId: nativeIdSchema,
15928
+ checkpointId: nativeIdSchema,
15929
+ locator: jsonValueSchema.optional(),
15930
+ formatVersion: external_exports.literal(1)
15931
+ }).superRefine(rejectExplicitUndefined(["locator"]));
15932
+ var nativeCheckpointRefV1Schema = nativeCheckpointRefV1RuntimeSchema;
15933
+ var nativeCheckpointRefSchema = nativeCheckpointRefV1Schema;
15760
15934
 
15761
- // ../../harness-discovery/dist/node-runtime.js
15762
- import path3 from "node:path";
15763
- function withNodeRuntimeOnPath(environment, runtimeExecutable = process.execPath, platform = process.platform) {
15764
- const pathKey = Object.keys(environment).find((name) => name.toLowerCase() === "path") ?? "PATH";
15765
- const delimiter = platform === "win32" ? ";" : ":";
15766
- const runtimeDirectory = path3.dirname(runtimeExecutable);
15767
- const directories = (environment[pathKey] ?? "").split(delimiter).filter(Boolean);
15768
- const equal = platform === "win32" ? (value) => value.toLowerCase() : (value) => value;
15769
- if (!directories.some((directory) => equal(directory) === equal(runtimeDirectory))) {
15770
- directories.push(runtimeDirectory);
15935
+ // ../../shared-contracts/dist/updates.js
15936
+ var UPDATE_ERROR_MAX_LENGTH = 500;
15937
+ var UPDATE_SEMVER_PATTERN = /^\d+\.\d+\.\d+(?:-[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?(?:\+[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?$/u;
15938
+ var updateSemanticVersionSchema = external_exports.string().regex(UPDATE_SEMVER_PATTERN);
15939
+ var updateInstallationSchema = external_exports.enum(["npm", "windows-installer", "macos-dmg"]);
15940
+ var updatePhaseSchema = external_exports.enum([
15941
+ "prepared",
15942
+ "downloading",
15943
+ "waiting-for-exit",
15944
+ "installing",
15945
+ "restarting",
15946
+ "succeeded",
15947
+ "failed"
15948
+ ]);
15949
+ var updateStatusSchema = external_exports.strictObject({
15950
+ version: updateSemanticVersionSchema,
15951
+ installation: updateInstallationSchema,
15952
+ phase: updatePhaseSchema,
15953
+ updatedAt: external_exports.number().int().nonnegative(),
15954
+ downloadedBytes: external_exports.number().int().nonnegative().optional(),
15955
+ totalBytes: external_exports.number().int().positive().optional(),
15956
+ error: external_exports.string().min(1).max(UPDATE_ERROR_MAX_LENGTH).nullable()
15957
+ }).superRefine((status, context) => {
15958
+ if (status.downloadedBytes !== void 0 && status.totalBytes !== void 0 && status.downloadedBytes > status.totalBytes) {
15959
+ context.addIssue({
15960
+ code: "custom",
15961
+ path: ["downloadedBytes"],
15962
+ message: "downloadedBytes must not exceed totalBytes"
15963
+ });
15771
15964
  }
15772
- return { ...environment, [pathKey]: directories.join(delimiter) };
15773
- }
15965
+ });
15966
+ var updateEmptyParamsSchema = external_exports.strictObject({});
15967
+ var githubReleaseNotesUrlSchema = external_exports.string().max(300).regex(/^https:\/\/github\.com\/BytePioneer-AI\/codex-host\/releases\/tag\/v[0-9A-Za-z.+-]+$/u, "release notes URL must identify a codexhost GitHub Release");
15968
+ var updateCheckResultSchema = external_exports.strictObject({
15969
+ currentVersion: updateSemanticVersionSchema,
15970
+ installation: updateInstallationSchema.nullable(),
15971
+ latestVersion: updateSemanticVersionSchema.nullable(),
15972
+ updateAvailable: external_exports.boolean(),
15973
+ installationAvailable: external_exports.boolean(),
15974
+ releaseNotes: external_exports.string().min(1).max(2e4).nullable(),
15975
+ releaseNotesUrl: githubReleaseNotesUrlSchema.nullable(),
15976
+ status: updateStatusSchema.nullable(),
15977
+ error: external_exports.string().min(1).max(UPDATE_ERROR_MAX_LENGTH).nullable()
15978
+ });
15979
+ var updateStartResultSchema = external_exports.strictObject({
15980
+ status: updateStatusSchema
15981
+ });
15982
+ var updateStatusResultSchema = external_exports.strictObject({
15983
+ status: updateStatusSchema.nullable()
15984
+ });
15774
15985
 
15775
- // ../../harness-discovery/dist/resolve.js
15776
- import os from "node:os";
15986
+ // ../../shared-contracts/dist/remote-runtime.js
15987
+ var remoteUpdatePhaseSchema = external_exports.enum([
15988
+ "idle",
15989
+ "installing",
15990
+ "restarting",
15991
+ "succeeded",
15992
+ "failed"
15993
+ ]);
15994
+ var runtimeStatusSchema = external_exports.object({
15995
+ runningVersion: external_exports.string().nullable(),
15996
+ installedVersion: external_exports.string().nullable(),
15997
+ restartRequired: external_exports.boolean(),
15998
+ remote: external_exports.boolean(),
15999
+ updateSupported: external_exports.boolean(),
16000
+ update: external_exports.object({
16001
+ phase: remoteUpdatePhaseSchema,
16002
+ targetVersion: external_exports.string().nullable(),
16003
+ error: external_exports.string().nullable()
16004
+ })
16005
+ });
16006
+ var remoteUpdateParamsSchema = external_exports.object({
16007
+ version: external_exports.string().regex(/^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?$/u)
16008
+ }).strict();
16009
+ var remoteSshSetupParamsSchema = external_exports.object({
16010
+ hostname: external_exports.string().min(1).max(1024).refine((value) => !value.startsWith("-") && !/\s/u.test(value)),
16011
+ port: external_exports.number().int().min(1).max(65535).nullable(),
16012
+ identity: external_exports.string().max(4096).nullable(),
16013
+ action: external_exports.enum(["inspect", "install", "update", "repair", "uninstall"]),
16014
+ uninstallPackage: external_exports.boolean().optional(),
16015
+ version: external_exports.string().regex(/^\d+\.\d+\.\d+$/u).nullable()
16016
+ }).strict();
16017
+ var remoteSshSetupResultSchema = external_exports.object({ state: external_exports.enum(["installed", "not-installed"]) }).strict();
15777
16018
 
15778
- // ../../harness-discovery/dist/version-managers.js
15779
- function versionManagerBinaryDirectories(context) {
15780
- const { platform, environment, home } = context;
15781
- const list = context.subdirectories ?? subdirectoryNames;
15782
- const pathFlavor = targetPath(platform);
15783
- const value = (name) => environmentValue(environment, name);
15784
- const directories = [];
15785
- const versioned = (root, ...tail) => {
15786
- for (const version2 of newestFirst(list(root))) {
15787
- directories.push(pathFlavor.join(root, version2, ...tail));
15788
- }
15789
- };
15790
- if (platform === "win32") {
15791
- const appData = value("APPDATA") ?? pathFlavor.join(home, "AppData", "Roaming");
15792
- const localAppData = value("LOCALAPPDATA") ?? pathFlavor.join(home, "AppData", "Local");
15793
- versioned(pathFlavor.join(appData, "nvm"));
15794
- versioned(value("FNM_DIR") ?? pathFlavor.join(appData, "fnm", "node-versions"), "installation");
15795
- directories.push(pathFlavor.join(localAppData, "Volta", "bin"));
15796
- directories.push(pathFlavor.join(home, ".bun", "bin"));
15797
- const pnpmHome2 = value("PNPM_HOME");
15798
- if (pnpmHome2)
15799
- directories.push(pnpmHome2);
15800
- directories.push(pathFlavor.join(localAppData, "pnpm"));
15801
- return directories;
15802
- }
15803
- versioned(pathFlavor.join(value("NVM_DIR") ?? pathFlavor.join(home, ".nvm"), "versions", "node"), "bin");
15804
- const fnmRoots = [
15805
- value("FNM_DIR"),
15806
- pathFlavor.join(home, ".local", "share", "fnm"),
15807
- pathFlavor.join(home, "Library", "Application Support", "fnm")
15808
- ].filter((root) => root !== void 0);
15809
- for (const root of fnmRoots) {
15810
- versioned(pathFlavor.join(root, "node-versions"), "installation", "bin");
15811
- }
15812
- const voltaHome = value("VOLTA_HOME") ?? pathFlavor.join(home, ".volta");
15813
- versioned(pathFlavor.join(voltaHome, "tools", "image", "node"), "bin");
15814
- directories.push(pathFlavor.join(voltaHome, "bin"));
15815
- const asdfHome = value("ASDF_DATA_DIR") ?? pathFlavor.join(home, ".asdf");
15816
- versioned(pathFlavor.join(asdfHome, "installs", "nodejs"), "bin");
15817
- directories.push(pathFlavor.join(asdfHome, "shims"));
15818
- const nodenvHome = value("NODENV_ROOT") ?? pathFlavor.join(home, ".nodenv");
15819
- versioned(pathFlavor.join(nodenvHome, "versions"), "bin");
15820
- directories.push(pathFlavor.join(nodenvHome, "shims"));
15821
- versioned(pathFlavor.join(value("N_PREFIX") ?? "/usr/local", "n", "versions", "node"), "bin");
15822
- directories.push(pathFlavor.join(home, ".bun", "bin"));
15823
- const pnpmHome = value("PNPM_HOME");
15824
- if (pnpmHome)
15825
- directories.push(pnpmHome);
15826
- directories.push(pathFlavor.join(home, "Library", "pnpm"));
15827
- directories.push(pathFlavor.join(home, ".local", "share", "pnpm"));
15828
- for (const prefix of ["/opt/homebrew/opt", "/usr/local/opt"]) {
15829
- for (const formula of newestFirst(list(prefix).filter((name) => name.startsWith("node@")))) {
15830
- directories.push(pathFlavor.join(prefix, formula, "bin"));
15831
- }
15832
- }
15833
- return directories;
15834
- }
16019
+ // ../../shared-contracts/dist/remote-connections.js
16020
+ var hostId = external_exports.string().min(1).max(1024);
16021
+ var codexSshConnectionSchema = external_exports.object({
16022
+ hostId,
16023
+ displayName: external_exports.string().min(1).max(1024),
16024
+ source: external_exports.enum(["codex-managed", "discovered"]),
16025
+ sshAlias: external_exports.string().max(1024).nullable(),
16026
+ sshHost: external_exports.string().min(1).max(1024),
16027
+ sshPort: external_exports.number().int().min(1).max(65535).nullable(),
16028
+ identity: external_exports.string().max(4096).nullable(),
16029
+ autoConnect: external_exports.boolean(),
16030
+ connectionAnalyticsId: external_exports.string().max(1024).optional()
16031
+ });
16032
+ var codexSshDraftSchema = external_exports.strictObject({
16033
+ displayName: external_exports.string().min(1).max(1024),
16034
+ hostname: external_exports.string().min(1).max(1024),
16035
+ sshPort: external_exports.number().int().min(1).max(65535).nullable(),
16036
+ identity: external_exports.string().max(4096).nullable()
16037
+ });
16038
+ var remoteConnectionsRequestSchema = external_exports.discriminatedUnion("action", [
16039
+ external_exports.strictObject({ action: external_exports.literal("list") }),
16040
+ external_exports.strictObject({
16041
+ action: external_exports.literal("save"),
16042
+ draft: codexSshDraftSchema,
16043
+ previous: codexSshConnectionSchema.nullable()
16044
+ }),
16045
+ external_exports.strictObject({ action: external_exports.literal("remove"), previous: codexSshConnectionSchema }),
16046
+ external_exports.strictObject({ action: external_exports.literal("connect"), hostId, enabled: external_exports.boolean() }),
16047
+ external_exports.strictObject({ action: external_exports.literal("state"), hostId }),
16048
+ external_exports.strictObject({ action: external_exports.literal("runtime"), hostId }),
16049
+ external_exports.strictObject({
16050
+ action: external_exports.literal("update"),
16051
+ hostId: hostId.refine((id) => id !== "local"),
16052
+ version: remoteUpdateParamsSchema.shape.version
16053
+ })
16054
+ ]);
16055
+ var remoteConnectionsReplySchema = external_exports.union([
16056
+ external_exports.strictObject({ result: jsonValueSchema }),
16057
+ external_exports.strictObject({ error: external_exports.strictObject({ code: external_exports.number().int(), message: external_exports.string() }) })
16058
+ ]);
15835
16059
 
15836
- // ../../harness-discovery/dist/resolve.js
15837
- var VERSION_MANAGER_ROOTS = "<version-managers>";
15838
- function installRootExtensions(platform) {
15839
- return platform === "win32" ? [".exe", ".cmd"] : [""];
15840
- }
15841
- function resolveHomeDirectory(input) {
15842
- return input.homeDirectory ?? environmentValue(input.environment, "HOME") ?? environmentValue(input.environment, "USERPROFILE") ?? os.homedir();
15843
- }
15844
- function templateVariables(environment, platform, home) {
15845
- const pathFlavor = targetPath(platform);
15846
- return {
15847
- HOME: home,
15848
- USERPROFILE: home,
15849
- APPDATA: environmentValue(environment, "APPDATA") ?? pathFlavor.join(home, "AppData", "Roaming"),
15850
- LOCALAPPDATA: environmentValue(environment, "LOCALAPPDATA") ?? pathFlavor.join(home, "AppData", "Local")
15851
- };
15852
- }
15853
- function joinTemplate(platform, value) {
15854
- const pathFlavor = targetPath(platform);
15855
- const segments = value.split("/");
15856
- const head = segments[0] ?? "";
15857
- const tail = segments.slice(1);
15858
- if (head === "")
15859
- return pathFlavor.join(pathFlavor.sep, ...tail);
15860
- return tail.length === 0 ? head : pathFlavor.join(head, ...tail);
15861
- }
15862
- function expandInstallRoot(template, environment, platform, home) {
15863
- const variables = templateVariables(environment, platform, home);
15864
- let unresolved = false;
15865
- const substituted = template.replace(/^~(?=\/|$)/u, home).replace(/\$\{(\w+)\}/gu, (_match, name) => {
15866
- const value = variables[name] ?? environmentValue(environment, name);
15867
- if (value === void 0 || value === "") {
15868
- unresolved = true;
15869
- return "";
15870
- }
15871
- return value;
15872
- });
15873
- return unresolved ? void 0 : joinTemplate(platform, substituted);
15874
- }
15875
- function installRootDirectories(spec, input, dependencies, platform, home) {
15876
- const templates = (platform === "win32" ? spec.installRoots?.windows : spec.installRoots?.posix) ?? [];
15877
- const directories = [];
15878
- for (const template of templates) {
15879
- if (template === VERSION_MANAGER_ROOTS) {
15880
- directories.push(...versionManagerBinaryDirectories({
15881
- platform,
15882
- environment: input.environment,
15883
- home,
15884
- ...dependencies.subdirectories ? { subdirectories: dependencies.subdirectories } : {}
15885
- }));
15886
- continue;
15887
- }
15888
- const directory = expandInstallRoot(template, input.environment, platform, home);
15889
- if (directory !== void 0)
15890
- directories.push(directory);
15891
- }
15892
- return directories;
15893
- }
15894
- function harnessCandidates(spec, input, dependencies = {}) {
15895
- const platform = input.platform ?? process.platform;
15896
- const pathFlavor = targetPath(platform);
15897
- const configured = input.command ?? (spec.commandEnvironmentVariable ? environmentValue(input.environment, spec.commandEnvironmentVariable) : void 0);
15898
- const command = configured ?? spec.command;
15899
- if (pathFlavor.isAbsolute(command) || command.includes("/") || command.includes("\\")) {
15900
- return [{ candidate: command, source: "configured" }];
16060
+ // ../../shared-contracts/dist/index.js
16061
+ var workspaceContractVersionSchema = external_exports.literal(WORKSPACE_CONTRACT_VERSION);
16062
+
16063
+ // ../../harness-adapter/dist/question.js
16064
+ function invalidRequest(message) {
16065
+ return { code: "invalidRequest", message, retryable: false };
16066
+ }
16067
+ function validateHostQuestionResponse(interaction, response) {
16068
+ const questionIds = new Set(interaction.questions.map(({ id }) => id));
16069
+ if (response.cancelled) {
16070
+ return Object.keys(response.answers).length === 0 ? null : invalidRequest("Cancelled Question Response must not contain answers");
15901
16071
  }
15902
- const candidates = [];
15903
- const extensions = executableExtensions(command, platform, input.environment);
15904
- for (const directory of pathDirectories(input.environment, platform)) {
15905
- for (const extension of extensions) {
15906
- candidates.push({
15907
- candidate: pathFlavor.join(directory, command + extension),
15908
- source: "path"
15909
- });
16072
+ for (const answerId of Object.keys(response.answers)) {
16073
+ if (!questionIds.has(answerId)) {
16074
+ return invalidRequest("Question Response contains an unknown Question ID");
15910
16075
  }
15911
16076
  }
15912
- if (configured !== void 0)
15913
- return candidates;
15914
- const home = resolveHomeDirectory(input);
15915
- for (const directory of installRootDirectories(spec, input, dependencies, platform, home)) {
15916
- for (const extension of installRootExtensions(platform)) {
15917
- candidates.push({
15918
- candidate: pathFlavor.join(directory, spec.command + extension),
15919
- source: "install-root"
15920
- });
16077
+ for (const question of interaction.questions) {
16078
+ const answers = response.answers[question.id] ?? [];
16079
+ if (!question.optional && answers.length === 0) {
16080
+ return invalidRequest("Question Response omits a required answer");
16081
+ }
16082
+ if (question.type === "text") {
16083
+ if (answers.length > 1) {
16084
+ return invalidRequest("Text Question accepts at most one answer");
16085
+ }
16086
+ continue;
16087
+ }
16088
+ if (!question.multiple && answers.length > 1) {
16089
+ return invalidRequest("Single-choice Question accepts at most one answer");
16090
+ }
16091
+ const declared = new Set(question.options.map(({ value }) => value));
16092
+ if (!question.allowOther && answers.some((answer) => !declared.has(answer))) {
16093
+ return invalidRequest("Question Response contains an undeclared choice");
15921
16094
  }
15922
16095
  }
15923
- return candidates;
15924
- }
15925
- function resolveHarnessExecutable(spec, input, dependencies = {}) {
15926
- const platform = input.platform ?? process.platform;
15927
- const isExecutable = dependencies.isExecutable ?? ((candidate) => isExecutableFile(candidate, platform));
15928
- const runnable = spec.runnableCandidate ?? ((candidate) => candidate);
15929
- const context = { platform, isExecutable };
15930
- for (const { candidate, source } of harnessCandidates(spec, input, dependencies)) {
15931
- const executable = runnable(candidate, context);
15932
- if (executable !== void 0 && isExecutable(executable))
15933
- return { executable, source };
15934
- }
15935
- return void 0;
16096
+ return null;
15936
16097
  }
15937
16098
 
15938
- // ../../harness-discovery/dist/installation.js
15939
- import { execFile } from "node:child_process";
15940
- import { homedir } from "node:os";
15941
- function runInstallationCommand(command, args, environment, timeout = 3e4) {
15942
- const env = withNodeRuntimeOnPath(environment);
15943
- const invocation = /\.[cm]?js$/i.test(command) ? commandInvocation(process.execPath, [command, ...args], env) : commandInvocation(command, args, env);
15944
- return new Promise((resolve, reject) => {
15945
- const child = execFile(invocation.command, invocation.arguments, {
15946
- env,
15947
- cwd: env.HOME ?? env.USERPROFILE ?? homedir(),
15948
- encoding: "utf8",
15949
- timeout,
15950
- killSignal: "SIGKILL",
15951
- maxBuffer: 1024 * 1024,
15952
- windowsHide: true,
15953
- windowsVerbatimArguments: invocation.windowsVerbatimArguments
15954
- }, (error51, stdout, stderr) => {
15955
- if (error51)
15956
- reject(new Error(error51.killed ? "Harness command timed out" : "Harness command failed; check the native installation and retry"));
15957
- else
15958
- resolve((stdout || stderr).trim());
15959
- });
15960
- child.stdin?.end();
15961
- });
15962
- }
15963
- function installationVersion(value) {
15964
- if (typeof value !== "string" || !/^v?\d+(?:\.\d+){1,3}(?:-[\w.-]+)?(?:\+[\w.-]+)?$/.test(value.trim()))
15965
- throw new Error("Harness returned an invalid version");
15966
- return value.trim().replace(/^v/, "");
15967
- }
15968
- function versionFromOutput(output) {
15969
- return installationVersion(output.match(/\b\d+(?:\.\d+){1,3}(?:-[\w.-]+)?(?:\+[\w.-]+)?\b/)?.[0]);
15970
- }
15971
- function newerInstallationVersion(current, latest) {
15972
- const a = installationVersion(current).replace(/\+.*/, "");
15973
- const b = installationVersion(latest).replace(/\+.*/, "");
15974
- const coreA = a.replace(/-.*/, "").split(".").map(BigInt);
15975
- const coreB = b.replace(/-.*/, "").split(".").map(BigInt);
15976
- for (let i = 0; i < Math.max(coreA.length, coreB.length); i++) {
15977
- if ((coreA[i] ?? 0n) !== (coreB[i] ?? 0n))
15978
- return (coreB[i] ?? 0n) > (coreA[i] ?? 0n);
16099
+ // ../../harness-adapter/dist/output-channel.js
16100
+ var HarnessOutputChannel = class {
16101
+ outputs;
16102
+ #consumerCreated = false;
16103
+ #ended = false;
16104
+ #pending = [];
16105
+ #values = [];
16106
+ constructor() {
16107
+ this.outputs = {
16108
+ [Symbol.asyncIterator]: () => {
16109
+ if (this.#consumerCreated) {
16110
+ throw new Error("Harness outputs allow only one consumer");
16111
+ }
16112
+ this.#consumerCreated = true;
16113
+ return {
16114
+ next: () => this.#next()
16115
+ };
16116
+ }
16117
+ };
15979
16118
  }
15980
- const preA = a.includes("-") ? a.slice(a.indexOf("-") + 1).split(".") : [];
15981
- const preB = b.includes("-") ? b.slice(b.indexOf("-") + 1).split(".") : [];
15982
- if (!preA.length || !preB.length)
15983
- return !!preA.length && !preB.length;
15984
- for (let i = 0; i < Math.max(preA.length, preB.length); i++) {
15985
- const x = preA[i];
15986
- const y = preB[i];
15987
- if (x === y)
15988
- continue;
15989
- if (x === void 0 || y === void 0)
15990
- return x === void 0;
15991
- const numericX = /^\d+$/.test(x);
15992
- const numericY = /^\d+$/.test(y);
15993
- if (numericX && numericY) {
15994
- if (BigInt(x) === BigInt(y))
15995
- continue;
15996
- return BigInt(y) > BigInt(x);
15997
- }
15998
- if (numericX !== numericY)
15999
- return numericX;
16000
- return y > x;
16119
+ emit(value) {
16120
+ if (this.#ended)
16121
+ return false;
16122
+ const resolve = this.#pending.shift();
16123
+ if (resolve)
16124
+ resolve({ done: false, value });
16125
+ else
16126
+ this.#values.push(value);
16127
+ return true;
16001
16128
  }
16002
- return false;
16003
- }
16004
- function createInstallationManager(options) {
16005
- let checking;
16006
- let updating;
16007
- const check2 = () => checking ??= options.check().finally(() => {
16008
- checking = void 0;
16009
- });
16010
- return (action) => {
16011
- if (updating)
16012
- return updating;
16013
- if (action === "check")
16014
- return check2();
16015
- updating = (async () => {
16016
- const before = await check2();
16017
- if (!before.updateAvailable)
16018
- return before;
16019
- if (!before.canUpdate)
16020
- throw new Error(before.message ?? "This installation cannot be updated automatically");
16021
- await options.update(before);
16022
- const after = await check2();
16023
- if (after.currentVersion === before.currentVersion)
16024
- throw new Error("The Harness version did not change; check the native updater and retry");
16025
- return after;
16026
- })().finally(() => {
16027
- updating = void 0;
16028
- });
16029
- return updating;
16030
- };
16031
- }
16032
- async function fetchInstallationText(url2) {
16033
- const request = async () => {
16034
- const response = await fetch(url2, { signal: AbortSignal.timeout(15e3) });
16035
- if (!response.ok)
16036
- throw new Error("Could not check the latest Harness version");
16037
- return response.text();
16038
- };
16039
- try {
16040
- return await request();
16041
- } catch (error51) {
16042
- if (error51 instanceof DOMException && (error51.name === "AbortError" || error51.name === "TimeoutError"))
16043
- throw error51;
16044
- return request();
16129
+ end() {
16130
+ if (this.#ended)
16131
+ return;
16132
+ this.#ended = true;
16133
+ if (this.#values.length !== 0)
16134
+ return;
16135
+ for (const resolve of this.#pending.splice(0))
16136
+ resolve({ done: true, value: void 0 });
16137
+ }
16138
+ #next() {
16139
+ const value = this.#values.shift();
16140
+ if (value !== void 0)
16141
+ return Promise.resolve({ done: false, value });
16142
+ if (this.#ended)
16143
+ return Promise.resolve({ done: true, value: void 0 });
16144
+ return new Promise((resolve) => this.#pending.push(resolve));
16045
16145
  }
16146
+ };
16147
+
16148
+ // ../../harness-adapter/dist/diagnostics.js
16149
+ var DIAGNOSTIC_TAIL_MAX_LENGTH = 8e3;
16150
+ var SENSITIVE_VALUE_PATTERN = /(api[_-]?key|access[_-]?token|auth(?:orization)?|password|secret)(\s*[:=]\s*)([^\s,;]+)/giu;
16151
+ var BEARER_PATTERN = /\bBearer\s+[A-Za-z0-9._~+/=-]+/giu;
16152
+ function sanitizeDiagnosticTail(value) {
16153
+ const redacted = value.replace(BEARER_PATTERN, "Bearer [redacted]").replace(SENSITIVE_VALUE_PATTERN, "$1$2[redacted]");
16154
+ return redacted.length <= DIAGNOSTIC_TAIL_MAX_LENGTH ? redacted : redacted.slice(-DIAGNOSTIC_TAIL_MAX_LENGTH);
16046
16155
  }
16047
16156
 
16157
+ // ../../harness-adapter/dist/usage.js
16158
+ var tokenFields = [
16159
+ "inputTokens",
16160
+ "cachedInputTokens",
16161
+ "cacheWriteInputTokens",
16162
+ "outputTokens",
16163
+ "outputTokensPerSecond",
16164
+ "reasoningOutputTokens",
16165
+ "totalTokens",
16166
+ "contextWindowTokens",
16167
+ "contextUsedTokens"
16168
+ ];
16169
+ var safeIntegerFields = [
16170
+ "planFiveHourResetsAtUnix",
16171
+ "planSevenDayResetsAtUnix"
16172
+ ];
16173
+ var percentFields = [
16174
+ "cacheHitRatePercent",
16175
+ "planFiveHourUsedPercent",
16176
+ "planSevenDayUsedPercent"
16177
+ ];
16178
+ var usageFields = /* @__PURE__ */ new Set([
16179
+ ...tokenFields,
16180
+ ...safeIntegerFields,
16181
+ ...percentFields,
16182
+ "totalCostUsd",
16183
+ "totalCredits",
16184
+ "contextUsagePercent"
16185
+ ]);
16186
+
16048
16187
  // dist/command.js
16049
16188
  import path4 from "node:path";
16050
16189
  var antigravityDiscoverySpec = {
@@ -16077,7 +16216,7 @@ import path6 from "node:path";
16077
16216
 
16078
16217
  // dist/history.js
16079
16218
  import { randomUUID } from "node:crypto";
16080
- import { mkdir, readFile, readdir, rename, rm, writeFile } from "node:fs/promises";
16219
+ import { mkdir, readFile, readdir, rename, rm as rm2, writeFile as writeFile2 } from "node:fs/promises";
16081
16220
  import os2 from "node:os";
16082
16221
  import path5 from "node:path";
16083
16222
  var HISTORY_VERSION = 1;
@@ -16354,7 +16493,7 @@ var AntigravityHistory = class _AntigravityHistory {
16354
16493
  await mkdir(directory, { recursive: true, mode: 448 });
16355
16494
  const temporary = path5.join(directory, `.${path5.basename(file2)}.${randomUUID()}.tmp`);
16356
16495
  try {
16357
- await writeFile(temporary, `${JSON.stringify({
16496
+ await writeFile2(temporary, `${JSON.stringify({
16358
16497
  formatVersion: HISTORY_VERSION,
16359
16498
  nativeSessionId,
16360
16499
  turns,
@@ -16364,7 +16503,7 @@ var AntigravityHistory = class _AntigravityHistory {
16364
16503
  `, { mode: 384 });
16365
16504
  await rename(temporary, file2);
16366
16505
  } finally {
16367
- await rm(temporary, { force: true }).catch(() => void 0);
16506
+ await rm2(temporary, { force: true }).catch(() => void 0);
16368
16507
  }
16369
16508
  });
16370
16509
  }
@@ -17489,7 +17628,7 @@ async function fetchAntigravityQuota(run, now = /* @__PURE__ */ new Date()) {
17489
17628
 
17490
17629
  // dist/question-bridge.js
17491
17630
  import { randomBytes, randomUUID as randomUUID4, timingSafeEqual } from "node:crypto";
17492
- import { mkdir as mkdir3, mkdtemp, rm as rm2, writeFile as writeFile2 } from "node:fs/promises";
17631
+ import { mkdir as mkdir3, mkdtemp as mkdtemp2, rm as rm3, writeFile as writeFile3 } from "node:fs/promises";
17493
17632
  import { createServer } from "node:http";
17494
17633
  import os4 from "node:os";
17495
17634
  import path8 from "node:path";
@@ -17617,7 +17756,7 @@ var AntigravityQuestionBridge = class _AntigravityQuestionBridge {
17617
17756
  this.#server.on("request", (request, response) => this.#receive(request, response));
17618
17757
  }
17619
17758
  static async create(options) {
17620
- const directory = await mkdtemp(path8.join(os4.tmpdir(), "codexhost-agy-question-"));
17759
+ const directory = await mkdtemp2(path8.join(os4.tmpdir(), "codexhost-agy-question-"));
17621
17760
  const bridge = new _AntigravityQuestionBridge(directory, options);
17622
17761
  try {
17623
17762
  await new Promise((resolve, reject) => {
@@ -17634,12 +17773,12 @@ var AntigravityQuestionBridge = class _AntigravityQuestionBridge {
17634
17773
  bridge.environment.CODEXHOST_AGY_QUESTION_URL = `http://127.0.0.1:${address.port}/question`;
17635
17774
  const client = path8.join(directory, "question-hook.cjs");
17636
17775
  await mkdir3(path8.join(directory, ".agents"));
17637
- await writeFile2(client, ANTIGRAVITY_QUESTION_HOOK_CLIENT, "utf8");
17776
+ await writeFile3(client, ANTIGRAVITY_QUESTION_HOOK_CLIENT, "utf8");
17638
17777
  const quote = (value) => `'${value.replaceAll("'", "'\\''")}'`;
17639
17778
  bridge.environment.CODEXHOST_AGY_QUESTION_NODE = `"${process.execPath.replaceAll("\\", "/")}"`;
17640
17779
  bridge.environment.CODEXHOST_AGY_QUESTION_CLIENT = `"${client.replaceAll("\\", "/")}"`;
17641
17780
  const command = process.platform === "win32" ? "%CODEXHOST_AGY_QUESTION_NODE% %CODEXHOST_AGY_QUESTION_CLIENT%" : `${quote(process.execPath)} ${quote(client)}`;
17642
- await writeFile2(path8.join(directory, ".agents", "hooks.json"), JSON.stringify({
17781
+ await writeFile3(path8.join(directory, ".agents", "hooks.json"), JSON.stringify({
17643
17782
  "codexhost-question-bridge": {
17644
17783
  PreToolUse: [
17645
17784
  {
@@ -17862,7 +18001,7 @@ var AntigravityQuestionBridge = class _AntigravityQuestionBridge {
17862
18001
  this.#server.close(() => resolve());
17863
18002
  this.#server.closeAllConnections();
17864
18003
  });
17865
- await rm2(this.directory, { recursive: true, force: true, maxRetries: 5, retryDelay: 50 });
18004
+ await rm3(this.directory, { recursive: true, force: true, maxRetries: 5, retryDelay: 50 });
17866
18005
  })();
17867
18006
  return this.#disposal;
17868
18007
  }
@@ -18558,7 +18697,9 @@ function normalizedProcessError(detail, fallback, exposeDetail = false) {
18558
18697
  return {
18559
18698
  code: "nativeFailure",
18560
18699
  message: exposeDetail && nativeDetail ? `${fallback}: ${nativeDetail}` : fallback,
18561
- retryable: true,
18700
+ // These native rejections need a changed precondition or a quota reset;
18701
+ // immediately replaying a Turn (and its tools) cannot resolve them.
18702
+ retryable: !/User location is not supported for the API use|Individual quota reached/iu.test(nativeDetail),
18562
18703
  ...diagnostic ? { stderrTail: diagnostic.slice(-4e3) } : {}
18563
18704
  };
18564
18705
  }
@@ -18969,6 +19110,18 @@ ${line}`).slice(-8e3);
18969
19110
  async #handleResult(active, event) {
18970
19111
  if (this.#active !== active)
18971
19112
  return;
19113
+ const resultConversationId = event.result.conversation_id.trim();
19114
+ if (resultConversationId && this.#nativeRef && resultConversationId !== this.#nativeRef.nativeSessionId) {
19115
+ this.#completeTurn(active, {
19116
+ status: "failed",
19117
+ error: {
19118
+ code: "protocolError",
19119
+ message: "Antigravity returned a result for a different Conversation",
19120
+ retryable: false
19121
+ }
19122
+ });
19123
+ return;
19124
+ }
18972
19125
  const usage = hostUsage(event.result.usage, active.model?.id);
18973
19126
  if (usage)
18974
19127
  this.#publishUsage(active, usage);
@@ -18981,7 +19134,7 @@ ${line}`).slice(-8e3);
18981
19134
  await active.subagents.refresh();
18982
19135
  if (this.#active !== active)
18983
19136
  return;
18984
- const convId = event.result.conversation_id && event.result.conversation_id.trim().length > 0 ? event.result.conversation_id.trim() : this.#nativeRef?.nativeSessionId ?? "";
19137
+ const convId = resultConversationId || this.#nativeRef?.nativeSessionId || "";
18985
19138
  if (!this.#nativeRef && convId) {
18986
19139
  this.#nativeRef = nativeSessionRefSchema.parse({
18987
19140
  harnessId: this.harnessId,
@@ -19765,6 +19918,10 @@ function createHarnessAdapter(context) {
19765
19918
  ...environment[ANTIGRAVITY_COMMAND_ENV] ? { command: environment[ANTIGRAVITY_COMMAND_ENV] } : {},
19766
19919
  environment
19767
19920
  }), {
19921
+ install: createHarnessInstaller(environment, {
19922
+ posix: "https://antigravity.google/cli/install.sh",
19923
+ windows: "https://antigravity.google/cli/install.ps1"
19924
+ }),
19768
19925
  installation: createAntigravityInstallation(environment, environment[ANTIGRAVITY_COMMAND_ENV])
19769
19926
  });
19770
19927
  }