@codexhost/cli-linux-arm64 0.24.0 → 0.25.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.
- package/README.md +1 -1
- package/app/codexhost-distribution.json +1 -1
- package/app/console-server.mjs +3166 -3040
- package/app/console-web.js +1156 -585
- package/app/desktop-controller.mjs +645 -264
- package/app/host-runtime.mjs +10906 -10282
- package/app/plugins/antigravity/plugin.mjs +515 -369
- package/app/plugins/claude-code/plugin.mjs +583 -438
- package/app/plugins/codebuddy/plugin.mjs +551 -429
- package/app/plugins/codex-usage/plugin.mjs +344 -224
- package/app/plugins/copilot/plugin.mjs +408 -286
- package/app/plugins/cursor-cli/plugin.mjs +499 -360
- package/app/plugins/deepseek-harness/plugin.mjs +759 -520
- package/app/plugins/devin/plugin.mjs +385 -265
- package/app/plugins/grok/plugin.mjs +638 -516
- package/app/plugins/hermes/plugin.mjs +456 -334
- package/app/plugins/kimi-code/plugin.mjs +454 -332
- package/app/plugins/kiro-cli/plugin.mjs +445 -325
- package/app/plugins/omp/plugin.mjs +707 -339
- package/app/plugins/opencode/plugin.mjs +873 -741
- package/app/plugins/pi/plugin.mjs +481 -359
- package/app/plugins/qoder/plugin.mjs +682 -560
- package/app/plugins/qoder-cn/plugin.mjs +682 -560
- package/app/plugins/qwen-code/plugin.mjs +475 -355
- package/app/plugins/workbuddy/plugin.mjs +549 -429
- package/app/plugins/zcode/plugin.mjs +352 -232
- package/app/renderer-extension.js +1706 -945
- package/app/web/assets/{index-IvFk9KT-.js → index-DUOvhHbV.js} +82 -82
- package/app/web/codexhost-settings.js +416 -51
- package/app/web/index.html +1 -1
- package/app/web/plugins/deepseek-ai__dsh-api-remotes/client.js +64 -64
- package/app/web/plugins/deepseek-ai__dsh-api-session-controller/client.js +8 -8
- package/app/web/plugins/deepseek-ai__dsh-api-workspace-controller/client.js +1 -1
- package/app/web/plugins/deepseek-ai__dsh-client-shortcuts/client.js +1 -1
- package/app/web/plugins/deepseek-ai__dsh-client-ui-brand-official/client.js +1 -1
- package/app/web/plugins/deepseek-ai__dsh-client-ui-chat/client.js +74 -74
- package/app/web/plugins/deepseek-ai__dsh-client-ui-codexhost/client.js +72 -72
- package/app/web/plugins/deepseek-ai__dsh-client-ui-conversation/client.js +97 -97
- package/app/web/plugins/deepseek-ai__dsh-client-ui-layout/client.js +1 -1
- package/app/web/plugins/deepseek-ai__dsh-client-ui-sidebar/client.js +2 -2
- package/app/web/plugins/deepseek-ai__dsh-client-ui-sidebar-files/client.js +1 -1
- package/app/web/plugins/deepseek-ai__dsh-client-ui-tool/client.js +18 -18
- package/app/web/plugins/deepseek-ai__dsh-client-ui-workspace/client.js +8 -8
- package/app/web-modules/server.mjs +2132 -1312
- package/bin/codexhost +0 -0
- package/libexec/codexhost-shim +0 -0
- package/libexec/codexhost-updater +0 -0
- package/package.json +1 -1
|
@@ -147,8 +147,8 @@ var VERSION_MANAGER_ROOTS = "<version-managers>";
|
|
|
147
147
|
function installRootExtensions(platform) {
|
|
148
148
|
return platform === "win32" ? [".exe", ".cmd"] : [""];
|
|
149
149
|
}
|
|
150
|
-
function resolveHomeDirectory(
|
|
151
|
-
return
|
|
150
|
+
function resolveHomeDirectory(input2) {
|
|
151
|
+
return input2.homeDirectory ?? environmentValue(input2.environment, "HOME") ?? environmentValue(input2.environment, "USERPROFILE") ?? os.homedir();
|
|
152
152
|
}
|
|
153
153
|
function templateVariables(environment, platform, home) {
|
|
154
154
|
const pathFlavor = targetPath(platform);
|
|
@@ -181,36 +181,36 @@ function expandInstallRoot(template, environment, platform, home) {
|
|
|
181
181
|
});
|
|
182
182
|
return unresolved ? void 0 : joinTemplate(platform, substituted);
|
|
183
183
|
}
|
|
184
|
-
function installRootDirectories(spec,
|
|
184
|
+
function installRootDirectories(spec, input2, dependencies, platform, home) {
|
|
185
185
|
const templates = (platform === "win32" ? spec.installRoots?.windows : spec.installRoots?.posix) ?? [];
|
|
186
186
|
const directories = [];
|
|
187
187
|
for (const template of templates) {
|
|
188
188
|
if (template === VERSION_MANAGER_ROOTS) {
|
|
189
189
|
directories.push(...versionManagerBinaryDirectories({
|
|
190
190
|
platform,
|
|
191
|
-
environment:
|
|
191
|
+
environment: input2.environment,
|
|
192
192
|
home,
|
|
193
193
|
...dependencies.subdirectories ? { subdirectories: dependencies.subdirectories } : {}
|
|
194
194
|
}));
|
|
195
195
|
continue;
|
|
196
196
|
}
|
|
197
|
-
const directory = expandInstallRoot(template,
|
|
197
|
+
const directory = expandInstallRoot(template, input2.environment, platform, home);
|
|
198
198
|
if (directory !== void 0)
|
|
199
199
|
directories.push(directory);
|
|
200
200
|
}
|
|
201
201
|
return directories;
|
|
202
202
|
}
|
|
203
|
-
function harnessCandidates(spec,
|
|
204
|
-
const platform =
|
|
203
|
+
function harnessCandidates(spec, input2, dependencies = {}) {
|
|
204
|
+
const platform = input2.platform ?? process.platform;
|
|
205
205
|
const pathFlavor = targetPath(platform);
|
|
206
|
-
const configured =
|
|
206
|
+
const configured = input2.command ?? (spec.commandEnvironmentVariable ? environmentValue(input2.environment, spec.commandEnvironmentVariable) : void 0);
|
|
207
207
|
const command = configured ?? spec.command;
|
|
208
208
|
if (pathFlavor.isAbsolute(command) || command.includes("/") || command.includes("\\")) {
|
|
209
209
|
return [{ candidate: command, source: "configured" }];
|
|
210
210
|
}
|
|
211
211
|
const candidates = [];
|
|
212
|
-
const extensions = executableExtensions(command, platform,
|
|
213
|
-
for (const directory of pathDirectories(
|
|
212
|
+
const extensions = executableExtensions(command, platform, input2.environment);
|
|
213
|
+
for (const directory of pathDirectories(input2.environment, platform)) {
|
|
214
214
|
for (const extension of extensions) {
|
|
215
215
|
candidates.push({
|
|
216
216
|
candidate: pathFlavor.join(directory, command + extension),
|
|
@@ -220,8 +220,8 @@ function harnessCandidates(spec, input, dependencies = {}) {
|
|
|
220
220
|
}
|
|
221
221
|
if (configured !== void 0)
|
|
222
222
|
return candidates;
|
|
223
|
-
const home = resolveHomeDirectory(
|
|
224
|
-
for (const directory of installRootDirectories(spec,
|
|
223
|
+
const home = resolveHomeDirectory(input2);
|
|
224
|
+
for (const directory of installRootDirectories(spec, input2, dependencies, platform, home)) {
|
|
225
225
|
for (const extension of installRootExtensions(platform)) {
|
|
226
226
|
candidates.push({
|
|
227
227
|
candidate: pathFlavor.join(directory, spec.command + extension),
|
|
@@ -231,12 +231,12 @@ function harnessCandidates(spec, input, dependencies = {}) {
|
|
|
231
231
|
}
|
|
232
232
|
return candidates;
|
|
233
233
|
}
|
|
234
|
-
function resolveHarnessExecutable(spec,
|
|
235
|
-
const platform =
|
|
234
|
+
function resolveHarnessExecutable(spec, input2, dependencies = {}) {
|
|
235
|
+
const platform = input2.platform ?? process.platform;
|
|
236
236
|
const isExecutable = dependencies.isExecutable ?? ((candidate) => isExecutableFile(candidate, platform));
|
|
237
237
|
const runnable = spec.runnableCandidate ?? ((candidate) => candidate);
|
|
238
238
|
const context = { platform, isExecutable };
|
|
239
|
-
for (const { candidate, source } of harnessCandidates(spec,
|
|
239
|
+
for (const { candidate, source } of harnessCandidates(spec, input2, dependencies)) {
|
|
240
240
|
const executable = runnable(candidate, context);
|
|
241
241
|
if (executable !== void 0 && isExecutable(executable))
|
|
242
242
|
return { executable, source };
|
|
@@ -247,13 +247,13 @@ function resolveHarnessExecutable(spec, input, dependencies = {}) {
|
|
|
247
247
|
// ../../harness-discovery/dist/installation.js
|
|
248
248
|
import { execFile } from "node:child_process";
|
|
249
249
|
import { homedir } from "node:os";
|
|
250
|
-
function runInstallationCommand(command, args, environment, timeout = 3e4) {
|
|
250
|
+
function runInstallationCommand(command, args, environment, timeout = 3e4, cwd) {
|
|
251
251
|
const env = withNodeRuntimeOnPath(environment);
|
|
252
252
|
const invocation = /\.[cm]?js$/i.test(command) ? commandInvocation(process.execPath, [command, ...args], env) : commandInvocation(command, args, env);
|
|
253
253
|
return new Promise((resolve, reject) => {
|
|
254
254
|
const child = execFile(invocation.command, invocation.arguments, {
|
|
255
255
|
env,
|
|
256
|
-
cwd: env.HOME ?? env.USERPROFILE ?? homedir(),
|
|
256
|
+
cwd: cwd ?? env.HOME ?? env.USERPROFILE ?? homedir(),
|
|
257
257
|
encoding: "utf8",
|
|
258
258
|
timeout,
|
|
259
259
|
killSignal: "SIGKILL",
|
|
@@ -280,7 +280,7 @@ function createInstallationManager(options) {
|
|
|
280
280
|
const check2 = () => checking ??= options.check().finally(() => {
|
|
281
281
|
checking = void 0;
|
|
282
282
|
});
|
|
283
|
-
return (action) => {
|
|
283
|
+
return (action, confirmedVersion) => {
|
|
284
284
|
if (updating)
|
|
285
285
|
return updating;
|
|
286
286
|
if (action === "check")
|
|
@@ -291,6 +291,8 @@ function createInstallationManager(options) {
|
|
|
291
291
|
return before;
|
|
292
292
|
if (!before.canUpdate)
|
|
293
293
|
throw new Error(before.message ?? "This installation cannot be updated automatically");
|
|
294
|
+
if ((before.latestVerifiedVersion !== void 0 || confirmedVersion !== void 0) && before.latestVersion !== confirmedVersion)
|
|
295
|
+
return { ...before, confirmationRequired: true };
|
|
294
296
|
await options.update(before);
|
|
295
297
|
const after = await check2();
|
|
296
298
|
if (after.currentVersion === before.currentVersion)
|
|
@@ -1077,8 +1079,8 @@ function cached(getter) {
|
|
|
1077
1079
|
}
|
|
1078
1080
|
};
|
|
1079
1081
|
}
|
|
1080
|
-
function nullish(
|
|
1081
|
-
return
|
|
1082
|
+
function nullish(input2) {
|
|
1083
|
+
return input2 === null || input2 === void 0;
|
|
1082
1084
|
}
|
|
1083
1085
|
function cleanRegex(source) {
|
|
1084
1086
|
const start = source.startsWith("^") ? 1 : 0;
|
|
@@ -1165,8 +1167,8 @@ function randomString(length = 10) {
|
|
|
1165
1167
|
function esc(str) {
|
|
1166
1168
|
return JSON.stringify(str);
|
|
1167
1169
|
}
|
|
1168
|
-
function slugify(
|
|
1169
|
-
return
|
|
1170
|
+
function slugify(input2) {
|
|
1171
|
+
return input2.toLowerCase().trim().replace(/[^\w\s-]/g, "").replace(/[\s_-]+/g, "-").replace(/^-+|-+$/g, "");
|
|
1170
1172
|
}
|
|
1171
1173
|
var captureStackTrace = "captureStackTrace" in Error ? Error.captureStackTrace : (..._args) => {
|
|
1172
1174
|
};
|
|
@@ -1571,19 +1573,19 @@ function finalizeIssue(iss, ctx, config2) {
|
|
|
1571
1573
|
}
|
|
1572
1574
|
return rest;
|
|
1573
1575
|
}
|
|
1574
|
-
function getSizableOrigin(
|
|
1575
|
-
if (
|
|
1576
|
+
function getSizableOrigin(input2) {
|
|
1577
|
+
if (input2 instanceof Set)
|
|
1576
1578
|
return "set";
|
|
1577
|
-
if (
|
|
1579
|
+
if (input2 instanceof Map)
|
|
1578
1580
|
return "map";
|
|
1579
|
-
if (
|
|
1581
|
+
if (input2 instanceof File)
|
|
1580
1582
|
return "file";
|
|
1581
1583
|
return "unknown";
|
|
1582
1584
|
}
|
|
1583
|
-
function getLengthableOrigin(
|
|
1584
|
-
if (Array.isArray(
|
|
1585
|
+
function getLengthableOrigin(input2) {
|
|
1586
|
+
if (Array.isArray(input2))
|
|
1585
1587
|
return "array";
|
|
1586
|
-
if (typeof
|
|
1588
|
+
if (typeof input2 === "string")
|
|
1587
1589
|
return "string";
|
|
1588
1590
|
return "unknown";
|
|
1589
1591
|
}
|
|
@@ -1609,12 +1611,12 @@ function parsedType(data) {
|
|
|
1609
1611
|
return t;
|
|
1610
1612
|
}
|
|
1611
1613
|
function issue(...args) {
|
|
1612
|
-
const [iss,
|
|
1614
|
+
const [iss, input2, inst] = args;
|
|
1613
1615
|
if (typeof iss === "string") {
|
|
1614
1616
|
return {
|
|
1615
1617
|
message: iss,
|
|
1616
1618
|
code: "custom",
|
|
1617
|
-
input,
|
|
1619
|
+
input: input2,
|
|
1618
1620
|
inst
|
|
1619
1621
|
};
|
|
1620
1622
|
}
|
|
@@ -2158,23 +2160,23 @@ var $ZodCheckNumberFormat = /* @__PURE__ */ $constructor("$ZodCheckNumberFormat"
|
|
|
2158
2160
|
bag.pattern = integer;
|
|
2159
2161
|
});
|
|
2160
2162
|
inst._zod.check = (payload) => {
|
|
2161
|
-
const
|
|
2163
|
+
const input2 = payload.value;
|
|
2162
2164
|
if (isInt) {
|
|
2163
|
-
if (!Number.isInteger(
|
|
2165
|
+
if (!Number.isInteger(input2)) {
|
|
2164
2166
|
payload.issues.push({
|
|
2165
2167
|
expected: origin,
|
|
2166
2168
|
format: def.format,
|
|
2167
2169
|
code: "invalid_type",
|
|
2168
2170
|
continue: false,
|
|
2169
|
-
input,
|
|
2171
|
+
input: input2,
|
|
2170
2172
|
inst
|
|
2171
2173
|
});
|
|
2172
2174
|
return;
|
|
2173
2175
|
}
|
|
2174
|
-
if (!Number.isSafeInteger(
|
|
2175
|
-
if (
|
|
2176
|
+
if (!Number.isSafeInteger(input2)) {
|
|
2177
|
+
if (input2 > 0) {
|
|
2176
2178
|
payload.issues.push({
|
|
2177
|
-
input,
|
|
2179
|
+
input: input2,
|
|
2178
2180
|
code: "too_big",
|
|
2179
2181
|
maximum: Number.MAX_SAFE_INTEGER,
|
|
2180
2182
|
note: "Integers must be within the safe integer range.",
|
|
@@ -2185,7 +2187,7 @@ var $ZodCheckNumberFormat = /* @__PURE__ */ $constructor("$ZodCheckNumberFormat"
|
|
|
2185
2187
|
});
|
|
2186
2188
|
} else {
|
|
2187
2189
|
payload.issues.push({
|
|
2188
|
-
input,
|
|
2190
|
+
input: input2,
|
|
2189
2191
|
code: "too_small",
|
|
2190
2192
|
minimum: Number.MIN_SAFE_INTEGER,
|
|
2191
2193
|
note: "Integers must be within the safe integer range.",
|
|
@@ -2198,10 +2200,10 @@ var $ZodCheckNumberFormat = /* @__PURE__ */ $constructor("$ZodCheckNumberFormat"
|
|
|
2198
2200
|
return;
|
|
2199
2201
|
}
|
|
2200
2202
|
}
|
|
2201
|
-
if (
|
|
2203
|
+
if (input2 < minimum) {
|
|
2202
2204
|
payload.issues.push({
|
|
2203
2205
|
origin: "number",
|
|
2204
|
-
input,
|
|
2206
|
+
input: input2,
|
|
2205
2207
|
code: "too_small",
|
|
2206
2208
|
minimum,
|
|
2207
2209
|
inclusive: true,
|
|
@@ -2209,10 +2211,10 @@ var $ZodCheckNumberFormat = /* @__PURE__ */ $constructor("$ZodCheckNumberFormat"
|
|
|
2209
2211
|
continue: !def.abort
|
|
2210
2212
|
});
|
|
2211
2213
|
}
|
|
2212
|
-
if (
|
|
2214
|
+
if (input2 > maximum) {
|
|
2213
2215
|
payload.issues.push({
|
|
2214
2216
|
origin: "number",
|
|
2215
|
-
input,
|
|
2217
|
+
input: input2,
|
|
2216
2218
|
code: "too_big",
|
|
2217
2219
|
maximum,
|
|
2218
2220
|
inclusive: true,
|
|
@@ -2232,11 +2234,11 @@ var $ZodCheckBigIntFormat = /* @__PURE__ */ $constructor("$ZodCheckBigIntFormat"
|
|
|
2232
2234
|
bag.maximum = maximum;
|
|
2233
2235
|
});
|
|
2234
2236
|
inst._zod.check = (payload) => {
|
|
2235
|
-
const
|
|
2236
|
-
if (
|
|
2237
|
+
const input2 = payload.value;
|
|
2238
|
+
if (input2 < minimum) {
|
|
2237
2239
|
payload.issues.push({
|
|
2238
2240
|
origin: "bigint",
|
|
2239
|
-
input,
|
|
2241
|
+
input: input2,
|
|
2240
2242
|
code: "too_small",
|
|
2241
2243
|
minimum,
|
|
2242
2244
|
inclusive: true,
|
|
@@ -2244,10 +2246,10 @@ var $ZodCheckBigIntFormat = /* @__PURE__ */ $constructor("$ZodCheckBigIntFormat"
|
|
|
2244
2246
|
continue: !def.abort
|
|
2245
2247
|
});
|
|
2246
2248
|
}
|
|
2247
|
-
if (
|
|
2249
|
+
if (input2 > maximum) {
|
|
2248
2250
|
payload.issues.push({
|
|
2249
2251
|
origin: "bigint",
|
|
2250
|
-
input,
|
|
2252
|
+
input: input2,
|
|
2251
2253
|
code: "too_big",
|
|
2252
2254
|
maximum,
|
|
2253
2255
|
inclusive: true,
|
|
@@ -2270,16 +2272,16 @@ var $ZodCheckMaxSize = /* @__PURE__ */ $constructor("$ZodCheckMaxSize", (inst, d
|
|
|
2270
2272
|
inst2._zod.bag.maximum = def.maximum;
|
|
2271
2273
|
});
|
|
2272
2274
|
inst._zod.check = (payload) => {
|
|
2273
|
-
const
|
|
2274
|
-
const size =
|
|
2275
|
+
const input2 = payload.value;
|
|
2276
|
+
const size = input2.size;
|
|
2275
2277
|
if (size <= def.maximum)
|
|
2276
2278
|
return;
|
|
2277
2279
|
payload.issues.push({
|
|
2278
|
-
origin: getSizableOrigin(
|
|
2280
|
+
origin: getSizableOrigin(input2),
|
|
2279
2281
|
code: "too_big",
|
|
2280
2282
|
maximum: def.maximum,
|
|
2281
2283
|
inclusive: true,
|
|
2282
|
-
input,
|
|
2284
|
+
input: input2,
|
|
2283
2285
|
inst,
|
|
2284
2286
|
continue: !def.abort
|
|
2285
2287
|
});
|
|
@@ -2298,16 +2300,16 @@ var $ZodCheckMinSize = /* @__PURE__ */ $constructor("$ZodCheckMinSize", (inst, d
|
|
|
2298
2300
|
inst2._zod.bag.minimum = def.minimum;
|
|
2299
2301
|
});
|
|
2300
2302
|
inst._zod.check = (payload) => {
|
|
2301
|
-
const
|
|
2302
|
-
const size =
|
|
2303
|
+
const input2 = payload.value;
|
|
2304
|
+
const size = input2.size;
|
|
2303
2305
|
if (size >= def.minimum)
|
|
2304
2306
|
return;
|
|
2305
2307
|
payload.issues.push({
|
|
2306
|
-
origin: getSizableOrigin(
|
|
2308
|
+
origin: getSizableOrigin(input2),
|
|
2307
2309
|
code: "too_small",
|
|
2308
2310
|
minimum: def.minimum,
|
|
2309
2311
|
inclusive: true,
|
|
2310
|
-
input,
|
|
2312
|
+
input: input2,
|
|
2311
2313
|
inst,
|
|
2312
2314
|
continue: !def.abort
|
|
2313
2315
|
});
|
|
@@ -2327,13 +2329,13 @@ var $ZodCheckSizeEquals = /* @__PURE__ */ $constructor("$ZodCheckSizeEquals", (i
|
|
|
2327
2329
|
bag.size = def.size;
|
|
2328
2330
|
});
|
|
2329
2331
|
inst._zod.check = (payload) => {
|
|
2330
|
-
const
|
|
2331
|
-
const size =
|
|
2332
|
+
const input2 = payload.value;
|
|
2333
|
+
const size = input2.size;
|
|
2332
2334
|
if (size === def.size)
|
|
2333
2335
|
return;
|
|
2334
2336
|
const tooBig = size > def.size;
|
|
2335
2337
|
payload.issues.push({
|
|
2336
|
-
origin: getSizableOrigin(
|
|
2338
|
+
origin: getSizableOrigin(input2),
|
|
2337
2339
|
...tooBig ? { code: "too_big", maximum: def.size } : { code: "too_small", minimum: def.size },
|
|
2338
2340
|
inclusive: true,
|
|
2339
2341
|
exact: true,
|
|
@@ -2356,17 +2358,17 @@ var $ZodCheckMaxLength = /* @__PURE__ */ $constructor("$ZodCheckMaxLength", (ins
|
|
|
2356
2358
|
inst2._zod.bag.maximum = def.maximum;
|
|
2357
2359
|
});
|
|
2358
2360
|
inst._zod.check = (payload) => {
|
|
2359
|
-
const
|
|
2360
|
-
const length =
|
|
2361
|
+
const input2 = payload.value;
|
|
2362
|
+
const length = input2.length;
|
|
2361
2363
|
if (length <= def.maximum)
|
|
2362
2364
|
return;
|
|
2363
|
-
const origin = getLengthableOrigin(
|
|
2365
|
+
const origin = getLengthableOrigin(input2);
|
|
2364
2366
|
payload.issues.push({
|
|
2365
2367
|
origin,
|
|
2366
2368
|
code: "too_big",
|
|
2367
2369
|
maximum: def.maximum,
|
|
2368
2370
|
inclusive: true,
|
|
2369
|
-
input,
|
|
2371
|
+
input: input2,
|
|
2370
2372
|
inst,
|
|
2371
2373
|
continue: !def.abort
|
|
2372
2374
|
});
|
|
@@ -2385,17 +2387,17 @@ var $ZodCheckMinLength = /* @__PURE__ */ $constructor("$ZodCheckMinLength", (ins
|
|
|
2385
2387
|
inst2._zod.bag.minimum = def.minimum;
|
|
2386
2388
|
});
|
|
2387
2389
|
inst._zod.check = (payload) => {
|
|
2388
|
-
const
|
|
2389
|
-
const length =
|
|
2390
|
+
const input2 = payload.value;
|
|
2391
|
+
const length = input2.length;
|
|
2390
2392
|
if (length >= def.minimum)
|
|
2391
2393
|
return;
|
|
2392
|
-
const origin = getLengthableOrigin(
|
|
2394
|
+
const origin = getLengthableOrigin(input2);
|
|
2393
2395
|
payload.issues.push({
|
|
2394
2396
|
origin,
|
|
2395
2397
|
code: "too_small",
|
|
2396
2398
|
minimum: def.minimum,
|
|
2397
2399
|
inclusive: true,
|
|
2398
|
-
input,
|
|
2400
|
+
input: input2,
|
|
2399
2401
|
inst,
|
|
2400
2402
|
continue: !def.abort
|
|
2401
2403
|
});
|
|
@@ -2415,11 +2417,11 @@ var $ZodCheckLengthEquals = /* @__PURE__ */ $constructor("$ZodCheckLengthEquals"
|
|
|
2415
2417
|
bag.length = def.length;
|
|
2416
2418
|
});
|
|
2417
2419
|
inst._zod.check = (payload) => {
|
|
2418
|
-
const
|
|
2419
|
-
const length =
|
|
2420
|
+
const input2 = payload.value;
|
|
2421
|
+
const length = input2.length;
|
|
2420
2422
|
if (length === def.length)
|
|
2421
2423
|
return;
|
|
2422
|
-
const origin = getLengthableOrigin(
|
|
2424
|
+
const origin = getLengthableOrigin(input2);
|
|
2423
2425
|
const tooBig = length > def.length;
|
|
2424
2426
|
payload.issues.push({
|
|
2425
2427
|
origin,
|
|
@@ -3090,15 +3092,15 @@ var $ZodNumber = /* @__PURE__ */ $constructor("$ZodNumber", (inst, def) => {
|
|
|
3090
3092
|
payload.value = Number(payload.value);
|
|
3091
3093
|
} catch (_) {
|
|
3092
3094
|
}
|
|
3093
|
-
const
|
|
3094
|
-
if (typeof
|
|
3095
|
+
const input2 = payload.value;
|
|
3096
|
+
if (typeof input2 === "number" && !Number.isNaN(input2) && Number.isFinite(input2)) {
|
|
3095
3097
|
return payload;
|
|
3096
3098
|
}
|
|
3097
|
-
const received = typeof
|
|
3099
|
+
const received = typeof input2 === "number" ? Number.isNaN(input2) ? "NaN" : !Number.isFinite(input2) ? "Infinity" : void 0 : void 0;
|
|
3098
3100
|
payload.issues.push({
|
|
3099
3101
|
expected: "number",
|
|
3100
3102
|
code: "invalid_type",
|
|
3101
|
-
input,
|
|
3103
|
+
input: input2,
|
|
3102
3104
|
inst,
|
|
3103
3105
|
...received ? { received } : {}
|
|
3104
3106
|
});
|
|
@@ -3118,13 +3120,13 @@ var $ZodBoolean = /* @__PURE__ */ $constructor("$ZodBoolean", (inst, def) => {
|
|
|
3118
3120
|
payload.value = Boolean(payload.value);
|
|
3119
3121
|
} catch (_) {
|
|
3120
3122
|
}
|
|
3121
|
-
const
|
|
3122
|
-
if (typeof
|
|
3123
|
+
const input2 = payload.value;
|
|
3124
|
+
if (typeof input2 === "boolean")
|
|
3123
3125
|
return payload;
|
|
3124
3126
|
payload.issues.push({
|
|
3125
3127
|
expected: "boolean",
|
|
3126
3128
|
code: "invalid_type",
|
|
3127
|
-
input,
|
|
3129
|
+
input: input2,
|
|
3128
3130
|
inst
|
|
3129
3131
|
});
|
|
3130
3132
|
return payload;
|
|
@@ -3157,13 +3159,13 @@ var $ZodBigIntFormat = /* @__PURE__ */ $constructor("$ZodBigIntFormat", (inst, d
|
|
|
3157
3159
|
var $ZodSymbol = /* @__PURE__ */ $constructor("$ZodSymbol", (inst, def) => {
|
|
3158
3160
|
$ZodType.init(inst, def);
|
|
3159
3161
|
inst._zod.parse = (payload, _ctx) => {
|
|
3160
|
-
const
|
|
3161
|
-
if (typeof
|
|
3162
|
+
const input2 = payload.value;
|
|
3163
|
+
if (typeof input2 === "symbol")
|
|
3162
3164
|
return payload;
|
|
3163
3165
|
payload.issues.push({
|
|
3164
3166
|
expected: "symbol",
|
|
3165
3167
|
code: "invalid_type",
|
|
3166
|
-
input,
|
|
3168
|
+
input: input2,
|
|
3167
3169
|
inst
|
|
3168
3170
|
});
|
|
3169
3171
|
return payload;
|
|
@@ -3174,13 +3176,13 @@ var $ZodUndefined = /* @__PURE__ */ $constructor("$ZodUndefined", (inst, def) =>
|
|
|
3174
3176
|
inst._zod.pattern = _undefined;
|
|
3175
3177
|
inst._zod.values = /* @__PURE__ */ new Set([void 0]);
|
|
3176
3178
|
inst._zod.parse = (payload, _ctx) => {
|
|
3177
|
-
const
|
|
3178
|
-
if (typeof
|
|
3179
|
+
const input2 = payload.value;
|
|
3180
|
+
if (typeof input2 === "undefined")
|
|
3179
3181
|
return payload;
|
|
3180
3182
|
payload.issues.push({
|
|
3181
3183
|
expected: "undefined",
|
|
3182
3184
|
code: "invalid_type",
|
|
3183
|
-
input,
|
|
3185
|
+
input: input2,
|
|
3184
3186
|
inst
|
|
3185
3187
|
});
|
|
3186
3188
|
return payload;
|
|
@@ -3191,13 +3193,13 @@ var $ZodNull = /* @__PURE__ */ $constructor("$ZodNull", (inst, def) => {
|
|
|
3191
3193
|
inst._zod.pattern = _null;
|
|
3192
3194
|
inst._zod.values = /* @__PURE__ */ new Set([null]);
|
|
3193
3195
|
inst._zod.parse = (payload, _ctx) => {
|
|
3194
|
-
const
|
|
3195
|
-
if (
|
|
3196
|
+
const input2 = payload.value;
|
|
3197
|
+
if (input2 === null)
|
|
3196
3198
|
return payload;
|
|
3197
3199
|
payload.issues.push({
|
|
3198
3200
|
expected: "null",
|
|
3199
3201
|
code: "invalid_type",
|
|
3200
|
-
input,
|
|
3202
|
+
input: input2,
|
|
3201
3203
|
inst
|
|
3202
3204
|
});
|
|
3203
3205
|
return payload;
|
|
@@ -3226,13 +3228,13 @@ var $ZodNever = /* @__PURE__ */ $constructor("$ZodNever", (inst, def) => {
|
|
|
3226
3228
|
var $ZodVoid = /* @__PURE__ */ $constructor("$ZodVoid", (inst, def) => {
|
|
3227
3229
|
$ZodType.init(inst, def);
|
|
3228
3230
|
inst._zod.parse = (payload, _ctx) => {
|
|
3229
|
-
const
|
|
3230
|
-
if (typeof
|
|
3231
|
+
const input2 = payload.value;
|
|
3232
|
+
if (typeof input2 === "undefined")
|
|
3231
3233
|
return payload;
|
|
3232
3234
|
payload.issues.push({
|
|
3233
3235
|
expected: "void",
|
|
3234
3236
|
code: "invalid_type",
|
|
3235
|
-
input,
|
|
3237
|
+
input: input2,
|
|
3236
3238
|
inst
|
|
3237
3239
|
});
|
|
3238
3240
|
return payload;
|
|
@@ -3247,15 +3249,15 @@ var $ZodDate = /* @__PURE__ */ $constructor("$ZodDate", (inst, def) => {
|
|
|
3247
3249
|
} catch (_err) {
|
|
3248
3250
|
}
|
|
3249
3251
|
}
|
|
3250
|
-
const
|
|
3251
|
-
const isDate =
|
|
3252
|
-
const isValidDate = isDate && !Number.isNaN(
|
|
3252
|
+
const input2 = payload.value;
|
|
3253
|
+
const isDate = input2 instanceof Date;
|
|
3254
|
+
const isValidDate = isDate && !Number.isNaN(input2.getTime());
|
|
3253
3255
|
if (isValidDate)
|
|
3254
3256
|
return payload;
|
|
3255
3257
|
payload.issues.push({
|
|
3256
3258
|
expected: "date",
|
|
3257
3259
|
code: "invalid_type",
|
|
3258
|
-
input,
|
|
3260
|
+
input: input2,
|
|
3259
3261
|
...isDate ? { received: "Invalid Date" } : {},
|
|
3260
3262
|
inst
|
|
3261
3263
|
});
|
|
@@ -3271,20 +3273,20 @@ function handleArrayResult(result, final, index) {
|
|
|
3271
3273
|
var $ZodArray = /* @__PURE__ */ $constructor("$ZodArray", (inst, def) => {
|
|
3272
3274
|
$ZodType.init(inst, def);
|
|
3273
3275
|
inst._zod.parse = (payload, ctx) => {
|
|
3274
|
-
const
|
|
3275
|
-
if (!Array.isArray(
|
|
3276
|
+
const input2 = payload.value;
|
|
3277
|
+
if (!Array.isArray(input2)) {
|
|
3276
3278
|
payload.issues.push({
|
|
3277
3279
|
expected: "array",
|
|
3278
3280
|
code: "invalid_type",
|
|
3279
|
-
input,
|
|
3281
|
+
input: input2,
|
|
3280
3282
|
inst
|
|
3281
3283
|
});
|
|
3282
3284
|
return payload;
|
|
3283
3285
|
}
|
|
3284
|
-
payload.value = Array(
|
|
3286
|
+
payload.value = Array(input2.length);
|
|
3285
3287
|
const proms = [];
|
|
3286
|
-
for (let i = 0; i <
|
|
3287
|
-
const item =
|
|
3288
|
+
for (let i = 0; i < input2.length; i++) {
|
|
3289
|
+
const item = input2[i];
|
|
3288
3290
|
const result = def.element._zod.run({
|
|
3289
3291
|
value: item,
|
|
3290
3292
|
issues: []
|
|
@@ -3301,8 +3303,8 @@ var $ZodArray = /* @__PURE__ */ $constructor("$ZodArray", (inst, def) => {
|
|
|
3301
3303
|
return payload;
|
|
3302
3304
|
};
|
|
3303
3305
|
});
|
|
3304
|
-
function handlePropertyResult(result, final, key,
|
|
3305
|
-
const isPresent = key in
|
|
3306
|
+
function handlePropertyResult(result, final, key, input2, isOptionalIn, isOptionalOut) {
|
|
3307
|
+
const isPresent = key in input2;
|
|
3306
3308
|
if (result.issues.length) {
|
|
3307
3309
|
if (isOptionalIn && isOptionalOut && !isPresent) {
|
|
3308
3310
|
return;
|
|
@@ -3344,14 +3346,14 @@ function normalizeDef(def) {
|
|
|
3344
3346
|
optionalKeys: new Set(okeys)
|
|
3345
3347
|
};
|
|
3346
3348
|
}
|
|
3347
|
-
function handleCatchall(proms,
|
|
3349
|
+
function handleCatchall(proms, input2, payload, ctx, def, inst) {
|
|
3348
3350
|
const unrecognized = [];
|
|
3349
3351
|
const keySet = def.keySet;
|
|
3350
3352
|
const _catchall = def.catchall._zod;
|
|
3351
3353
|
const t = _catchall.def.type;
|
|
3352
3354
|
const isOptionalIn = _catchall.optin === "optional";
|
|
3353
3355
|
const isOptionalOut = _catchall.optout === "optional";
|
|
3354
|
-
for (const key in
|
|
3356
|
+
for (const key in input2) {
|
|
3355
3357
|
if (key === "__proto__")
|
|
3356
3358
|
continue;
|
|
3357
3359
|
if (keySet.has(key))
|
|
@@ -3360,18 +3362,18 @@ function handleCatchall(proms, input, payload, ctx, def, inst) {
|
|
|
3360
3362
|
unrecognized.push(key);
|
|
3361
3363
|
continue;
|
|
3362
3364
|
}
|
|
3363
|
-
const r = _catchall.run({ value:
|
|
3365
|
+
const r = _catchall.run({ value: input2[key], issues: [] }, ctx);
|
|
3364
3366
|
if (r instanceof Promise) {
|
|
3365
|
-
proms.push(r.then((r2) => handlePropertyResult(r2, payload, key,
|
|
3367
|
+
proms.push(r.then((r2) => handlePropertyResult(r2, payload, key, input2, isOptionalIn, isOptionalOut)));
|
|
3366
3368
|
} else {
|
|
3367
|
-
handlePropertyResult(r, payload, key,
|
|
3369
|
+
handlePropertyResult(r, payload, key, input2, isOptionalIn, isOptionalOut);
|
|
3368
3370
|
}
|
|
3369
3371
|
}
|
|
3370
3372
|
if (unrecognized.length) {
|
|
3371
3373
|
payload.issues.push({
|
|
3372
3374
|
code: "unrecognized_keys",
|
|
3373
3375
|
keys: unrecognized,
|
|
3374
|
-
input,
|
|
3376
|
+
input: input2,
|
|
3375
3377
|
inst
|
|
3376
3378
|
});
|
|
3377
3379
|
}
|
|
@@ -3415,12 +3417,12 @@ var $ZodObject = /* @__PURE__ */ $constructor("$ZodObject", (inst, def) => {
|
|
|
3415
3417
|
let value;
|
|
3416
3418
|
inst._zod.parse = (payload, ctx) => {
|
|
3417
3419
|
value ?? (value = _normalized.value);
|
|
3418
|
-
const
|
|
3419
|
-
if (!isObject2(
|
|
3420
|
+
const input2 = payload.value;
|
|
3421
|
+
if (!isObject2(input2)) {
|
|
3420
3422
|
payload.issues.push({
|
|
3421
3423
|
expected: "object",
|
|
3422
3424
|
code: "invalid_type",
|
|
3423
|
-
input,
|
|
3425
|
+
input: input2,
|
|
3424
3426
|
inst
|
|
3425
3427
|
});
|
|
3426
3428
|
return payload;
|
|
@@ -3432,17 +3434,17 @@ var $ZodObject = /* @__PURE__ */ $constructor("$ZodObject", (inst, def) => {
|
|
|
3432
3434
|
const el = shape[key];
|
|
3433
3435
|
const isOptionalIn = el._zod.optin === "optional";
|
|
3434
3436
|
const isOptionalOut = el._zod.optout === "optional";
|
|
3435
|
-
const r = el._zod.run({ value:
|
|
3437
|
+
const r = el._zod.run({ value: input2[key], issues: [] }, ctx);
|
|
3436
3438
|
if (r instanceof Promise) {
|
|
3437
|
-
proms.push(r.then((r2) => handlePropertyResult(r2, payload, key,
|
|
3439
|
+
proms.push(r.then((r2) => handlePropertyResult(r2, payload, key, input2, isOptionalIn, isOptionalOut)));
|
|
3438
3440
|
} else {
|
|
3439
|
-
handlePropertyResult(r, payload, key,
|
|
3441
|
+
handlePropertyResult(r, payload, key, input2, isOptionalIn, isOptionalOut);
|
|
3440
3442
|
}
|
|
3441
3443
|
}
|
|
3442
3444
|
if (!catchall) {
|
|
3443
3445
|
return proms.length ? Promise.all(proms).then(() => payload) : payload;
|
|
3444
3446
|
}
|
|
3445
|
-
return handleCatchall(proms,
|
|
3447
|
+
return handleCatchall(proms, input2, payload, ctx, _normalized.value, inst);
|
|
3446
3448
|
};
|
|
3447
3449
|
});
|
|
3448
3450
|
var $ZodObjectJIT = /* @__PURE__ */ $constructor("$ZodObjectJIT", (inst, def) => {
|
|
@@ -3551,12 +3553,12 @@ var $ZodObjectJIT = /* @__PURE__ */ $constructor("$ZodObjectJIT", (inst, def) =>
|
|
|
3551
3553
|
let value;
|
|
3552
3554
|
inst._zod.parse = (payload, ctx) => {
|
|
3553
3555
|
value ?? (value = _normalized.value);
|
|
3554
|
-
const
|
|
3555
|
-
if (!isObject2(
|
|
3556
|
+
const input2 = payload.value;
|
|
3557
|
+
if (!isObject2(input2)) {
|
|
3556
3558
|
payload.issues.push({
|
|
3557
3559
|
expected: "object",
|
|
3558
3560
|
code: "invalid_type",
|
|
3559
|
-
input,
|
|
3561
|
+
input: input2,
|
|
3560
3562
|
inst
|
|
3561
3563
|
});
|
|
3562
3564
|
return payload;
|
|
@@ -3567,7 +3569,7 @@ var $ZodObjectJIT = /* @__PURE__ */ $constructor("$ZodObjectJIT", (inst, def) =>
|
|
|
3567
3569
|
payload = fastpass(payload, ctx);
|
|
3568
3570
|
if (!catchall)
|
|
3569
3571
|
return payload;
|
|
3570
|
-
return handleCatchall([],
|
|
3572
|
+
return handleCatchall([], input2, payload, ctx, value, inst);
|
|
3571
3573
|
}
|
|
3572
3574
|
return superParse(payload, ctx);
|
|
3573
3575
|
};
|
|
@@ -3727,17 +3729,17 @@ var $ZodDiscriminatedUnion = /* @__PURE__ */ $constructor("$ZodDiscriminatedUnio
|
|
|
3727
3729
|
return map2;
|
|
3728
3730
|
});
|
|
3729
3731
|
inst._zod.parse = (payload, ctx) => {
|
|
3730
|
-
const
|
|
3731
|
-
if (!isObject(
|
|
3732
|
+
const input2 = payload.value;
|
|
3733
|
+
if (!isObject(input2)) {
|
|
3732
3734
|
payload.issues.push({
|
|
3733
3735
|
code: "invalid_type",
|
|
3734
3736
|
expected: "object",
|
|
3735
|
-
input,
|
|
3737
|
+
input: input2,
|
|
3736
3738
|
inst
|
|
3737
3739
|
});
|
|
3738
3740
|
return payload;
|
|
3739
3741
|
}
|
|
3740
|
-
const opt = disc.value.get(
|
|
3742
|
+
const opt = disc.value.get(input2?.[def.discriminator]);
|
|
3741
3743
|
if (opt) {
|
|
3742
3744
|
return opt._zod.run(payload, ctx);
|
|
3743
3745
|
}
|
|
@@ -3750,7 +3752,7 @@ var $ZodDiscriminatedUnion = /* @__PURE__ */ $constructor("$ZodDiscriminatedUnio
|
|
|
3750
3752
|
note: "No matching discriminator",
|
|
3751
3753
|
discriminator: def.discriminator,
|
|
3752
3754
|
options: Array.from(disc.value.keys()),
|
|
3753
|
-
input,
|
|
3755
|
+
input: input2,
|
|
3754
3756
|
path: [def.discriminator],
|
|
3755
3757
|
inst
|
|
3756
3758
|
});
|
|
@@ -3760,9 +3762,9 @@ var $ZodDiscriminatedUnion = /* @__PURE__ */ $constructor("$ZodDiscriminatedUnio
|
|
|
3760
3762
|
var $ZodIntersection = /* @__PURE__ */ $constructor("$ZodIntersection", (inst, def) => {
|
|
3761
3763
|
$ZodType.init(inst, def);
|
|
3762
3764
|
inst._zod.parse = (payload, ctx) => {
|
|
3763
|
-
const
|
|
3764
|
-
const left = def.left._zod.run({ value:
|
|
3765
|
-
const right = def.right._zod.run({ value:
|
|
3765
|
+
const input2 = payload.value;
|
|
3766
|
+
const left = def.left._zod.run({ value: input2, issues: [] }, ctx);
|
|
3767
|
+
const right = def.right._zod.run({ value: input2, issues: [] }, ctx);
|
|
3766
3768
|
const async = left instanceof Promise || right instanceof Promise;
|
|
3767
3769
|
if (async) {
|
|
3768
3770
|
return Promise.all([left, right]).then(([left2, right2]) => {
|
|
@@ -3859,10 +3861,10 @@ var $ZodTuple = /* @__PURE__ */ $constructor("$ZodTuple", (inst, def) => {
|
|
|
3859
3861
|
$ZodType.init(inst, def);
|
|
3860
3862
|
const items = def.items;
|
|
3861
3863
|
inst._zod.parse = (payload, ctx) => {
|
|
3862
|
-
const
|
|
3863
|
-
if (!Array.isArray(
|
|
3864
|
+
const input2 = payload.value;
|
|
3865
|
+
if (!Array.isArray(input2)) {
|
|
3864
3866
|
payload.issues.push({
|
|
3865
|
-
input,
|
|
3867
|
+
input: input2,
|
|
3866
3868
|
inst,
|
|
3867
3869
|
expected: "tuple",
|
|
3868
3870
|
code: "invalid_type"
|
|
@@ -3874,23 +3876,23 @@ var $ZodTuple = /* @__PURE__ */ $constructor("$ZodTuple", (inst, def) => {
|
|
|
3874
3876
|
const optinStart = getTupleOptStart(items, "optin");
|
|
3875
3877
|
const optoutStart = getTupleOptStart(items, "optout");
|
|
3876
3878
|
if (!def.rest) {
|
|
3877
|
-
if (
|
|
3879
|
+
if (input2.length < optinStart) {
|
|
3878
3880
|
payload.issues.push({
|
|
3879
3881
|
code: "too_small",
|
|
3880
3882
|
minimum: optinStart,
|
|
3881
3883
|
inclusive: true,
|
|
3882
|
-
input,
|
|
3884
|
+
input: input2,
|
|
3883
3885
|
inst,
|
|
3884
3886
|
origin: "array"
|
|
3885
3887
|
});
|
|
3886
3888
|
return payload;
|
|
3887
3889
|
}
|
|
3888
|
-
if (
|
|
3890
|
+
if (input2.length > items.length) {
|
|
3889
3891
|
payload.issues.push({
|
|
3890
3892
|
code: "too_big",
|
|
3891
3893
|
maximum: items.length,
|
|
3892
3894
|
inclusive: true,
|
|
3893
|
-
input,
|
|
3895
|
+
input: input2,
|
|
3894
3896
|
inst,
|
|
3895
3897
|
origin: "array"
|
|
3896
3898
|
});
|
|
@@ -3898,7 +3900,7 @@ var $ZodTuple = /* @__PURE__ */ $constructor("$ZodTuple", (inst, def) => {
|
|
|
3898
3900
|
}
|
|
3899
3901
|
const itemResults = new Array(items.length);
|
|
3900
3902
|
for (let i = 0; i < items.length; i++) {
|
|
3901
|
-
const r = items[i]._zod.run({ value:
|
|
3903
|
+
const r = items[i]._zod.run({ value: input2[i], issues: [] }, ctx);
|
|
3902
3904
|
if (r instanceof Promise) {
|
|
3903
3905
|
proms.push(r.then((rr) => {
|
|
3904
3906
|
itemResults[i] = rr;
|
|
@@ -3909,7 +3911,7 @@ var $ZodTuple = /* @__PURE__ */ $constructor("$ZodTuple", (inst, def) => {
|
|
|
3909
3911
|
}
|
|
3910
3912
|
if (def.rest) {
|
|
3911
3913
|
let i = items.length - 1;
|
|
3912
|
-
const rest =
|
|
3914
|
+
const rest = input2.slice(items.length);
|
|
3913
3915
|
for (const el of rest) {
|
|
3914
3916
|
i++;
|
|
3915
3917
|
const result = def.rest._zod.run({ value: el, issues: [] }, ctx);
|
|
@@ -3921,9 +3923,9 @@ var $ZodTuple = /* @__PURE__ */ $constructor("$ZodTuple", (inst, def) => {
|
|
|
3921
3923
|
}
|
|
3922
3924
|
}
|
|
3923
3925
|
if (proms.length) {
|
|
3924
|
-
return Promise.all(proms).then(() => handleTupleResults(itemResults, payload, items,
|
|
3926
|
+
return Promise.all(proms).then(() => handleTupleResults(itemResults, payload, items, input2, optoutStart));
|
|
3925
3927
|
}
|
|
3926
|
-
return handleTupleResults(itemResults, payload, items,
|
|
3928
|
+
return handleTupleResults(itemResults, payload, items, input2, optoutStart);
|
|
3927
3929
|
};
|
|
3928
3930
|
});
|
|
3929
3931
|
function getTupleOptStart(items, key) {
|
|
@@ -3939,10 +3941,10 @@ function handleTupleResult(result, final, index) {
|
|
|
3939
3941
|
}
|
|
3940
3942
|
final.value[index] = result.value;
|
|
3941
3943
|
}
|
|
3942
|
-
function handleTupleResults(itemResults, final, items,
|
|
3944
|
+
function handleTupleResults(itemResults, final, items, input2, optoutStart) {
|
|
3943
3945
|
for (let i = 0; i < items.length; i++) {
|
|
3944
3946
|
const r = itemResults[i];
|
|
3945
|
-
const isPresent = i <
|
|
3947
|
+
const isPresent = i < input2.length;
|
|
3946
3948
|
if (r.issues.length) {
|
|
3947
3949
|
if (!isPresent && i >= optoutStart) {
|
|
3948
3950
|
final.value.length = i;
|
|
@@ -3952,7 +3954,7 @@ function handleTupleResults(itemResults, final, items, input, optoutStart) {
|
|
|
3952
3954
|
}
|
|
3953
3955
|
final.value[i] = r.value;
|
|
3954
3956
|
}
|
|
3955
|
-
for (let i = final.value.length - 1; i >=
|
|
3957
|
+
for (let i = final.value.length - 1; i >= input2.length; i--) {
|
|
3956
3958
|
if (items[i]._zod.optout === "optional" && final.value[i] === void 0) {
|
|
3957
3959
|
final.value.length = i;
|
|
3958
3960
|
} else {
|
|
@@ -3964,12 +3966,12 @@ function handleTupleResults(itemResults, final, items, input, optoutStart) {
|
|
|
3964
3966
|
var $ZodRecord = /* @__PURE__ */ $constructor("$ZodRecord", (inst, def) => {
|
|
3965
3967
|
$ZodType.init(inst, def);
|
|
3966
3968
|
inst._zod.parse = (payload, ctx) => {
|
|
3967
|
-
const
|
|
3968
|
-
if (!isPlainObject(
|
|
3969
|
+
const input2 = payload.value;
|
|
3970
|
+
if (!isPlainObject(input2)) {
|
|
3969
3971
|
payload.issues.push({
|
|
3970
3972
|
expected: "record",
|
|
3971
3973
|
code: "invalid_type",
|
|
3972
|
-
input,
|
|
3974
|
+
input: input2,
|
|
3973
3975
|
inst
|
|
3974
3976
|
});
|
|
3975
3977
|
return payload;
|
|
@@ -3998,7 +4000,7 @@ var $ZodRecord = /* @__PURE__ */ $constructor("$ZodRecord", (inst, def) => {
|
|
|
3998
4000
|
continue;
|
|
3999
4001
|
}
|
|
4000
4002
|
const outKey = keyResult.value;
|
|
4001
|
-
const result = def.valueType._zod.run({ value:
|
|
4003
|
+
const result = def.valueType._zod.run({ value: input2[key], issues: [] }, ctx);
|
|
4002
4004
|
if (result instanceof Promise) {
|
|
4003
4005
|
proms.push(result.then((result2) => {
|
|
4004
4006
|
if (result2.issues.length) {
|
|
@@ -4015,7 +4017,7 @@ var $ZodRecord = /* @__PURE__ */ $constructor("$ZodRecord", (inst, def) => {
|
|
|
4015
4017
|
}
|
|
4016
4018
|
}
|
|
4017
4019
|
let unrecognized;
|
|
4018
|
-
for (const key in
|
|
4020
|
+
for (const key in input2) {
|
|
4019
4021
|
if (!recordKeys.has(key)) {
|
|
4020
4022
|
unrecognized = unrecognized ?? [];
|
|
4021
4023
|
unrecognized.push(key);
|
|
@@ -4024,17 +4026,17 @@ var $ZodRecord = /* @__PURE__ */ $constructor("$ZodRecord", (inst, def) => {
|
|
|
4024
4026
|
if (unrecognized && unrecognized.length > 0) {
|
|
4025
4027
|
payload.issues.push({
|
|
4026
4028
|
code: "unrecognized_keys",
|
|
4027
|
-
input,
|
|
4029
|
+
input: input2,
|
|
4028
4030
|
inst,
|
|
4029
4031
|
keys: unrecognized
|
|
4030
4032
|
});
|
|
4031
4033
|
}
|
|
4032
4034
|
} else {
|
|
4033
4035
|
payload.value = {};
|
|
4034
|
-
for (const key of Reflect.ownKeys(
|
|
4036
|
+
for (const key of Reflect.ownKeys(input2)) {
|
|
4035
4037
|
if (key === "__proto__")
|
|
4036
4038
|
continue;
|
|
4037
|
-
if (!Object.prototype.propertyIsEnumerable.call(
|
|
4039
|
+
if (!Object.prototype.propertyIsEnumerable.call(input2, key))
|
|
4038
4040
|
continue;
|
|
4039
4041
|
let keyResult = def.keyType._zod.run({ value: key, issues: [] }, ctx);
|
|
4040
4042
|
if (keyResult instanceof Promise) {
|
|
@@ -4052,7 +4054,7 @@ var $ZodRecord = /* @__PURE__ */ $constructor("$ZodRecord", (inst, def) => {
|
|
|
4052
4054
|
}
|
|
4053
4055
|
if (keyResult.issues.length) {
|
|
4054
4056
|
if (def.mode === "loose") {
|
|
4055
|
-
payload.value[key] =
|
|
4057
|
+
payload.value[key] = input2[key];
|
|
4056
4058
|
} else {
|
|
4057
4059
|
payload.issues.push({
|
|
4058
4060
|
code: "invalid_key",
|
|
@@ -4065,7 +4067,7 @@ var $ZodRecord = /* @__PURE__ */ $constructor("$ZodRecord", (inst, def) => {
|
|
|
4065
4067
|
}
|
|
4066
4068
|
continue;
|
|
4067
4069
|
}
|
|
4068
|
-
const result = def.valueType._zod.run({ value:
|
|
4070
|
+
const result = def.valueType._zod.run({ value: input2[key], issues: [] }, ctx);
|
|
4069
4071
|
if (result instanceof Promise) {
|
|
4070
4072
|
proms.push(result.then((result2) => {
|
|
4071
4073
|
if (result2.issues.length) {
|
|
@@ -4090,27 +4092,27 @@ var $ZodRecord = /* @__PURE__ */ $constructor("$ZodRecord", (inst, def) => {
|
|
|
4090
4092
|
var $ZodMap = /* @__PURE__ */ $constructor("$ZodMap", (inst, def) => {
|
|
4091
4093
|
$ZodType.init(inst, def);
|
|
4092
4094
|
inst._zod.parse = (payload, ctx) => {
|
|
4093
|
-
const
|
|
4094
|
-
if (!(
|
|
4095
|
+
const input2 = payload.value;
|
|
4096
|
+
if (!(input2 instanceof Map)) {
|
|
4095
4097
|
payload.issues.push({
|
|
4096
4098
|
expected: "map",
|
|
4097
4099
|
code: "invalid_type",
|
|
4098
|
-
input,
|
|
4100
|
+
input: input2,
|
|
4099
4101
|
inst
|
|
4100
4102
|
});
|
|
4101
4103
|
return payload;
|
|
4102
4104
|
}
|
|
4103
4105
|
const proms = [];
|
|
4104
4106
|
payload.value = /* @__PURE__ */ new Map();
|
|
4105
|
-
for (const [key, value] of
|
|
4107
|
+
for (const [key, value] of input2) {
|
|
4106
4108
|
const keyResult = def.keyType._zod.run({ value: key, issues: [] }, ctx);
|
|
4107
4109
|
const valueResult = def.valueType._zod.run({ value, issues: [] }, ctx);
|
|
4108
4110
|
if (keyResult instanceof Promise || valueResult instanceof Promise) {
|
|
4109
4111
|
proms.push(Promise.all([keyResult, valueResult]).then(([keyResult2, valueResult2]) => {
|
|
4110
|
-
handleMapResult(keyResult2, valueResult2, payload, key,
|
|
4112
|
+
handleMapResult(keyResult2, valueResult2, payload, key, input2, inst, ctx);
|
|
4111
4113
|
}));
|
|
4112
4114
|
} else {
|
|
4113
|
-
handleMapResult(keyResult, valueResult, payload, key,
|
|
4115
|
+
handleMapResult(keyResult, valueResult, payload, key, input2, inst, ctx);
|
|
4114
4116
|
}
|
|
4115
4117
|
}
|
|
4116
4118
|
if (proms.length)
|
|
@@ -4118,7 +4120,7 @@ var $ZodMap = /* @__PURE__ */ $constructor("$ZodMap", (inst, def) => {
|
|
|
4118
4120
|
return payload;
|
|
4119
4121
|
};
|
|
4120
4122
|
});
|
|
4121
|
-
function handleMapResult(keyResult, valueResult, final, key,
|
|
4123
|
+
function handleMapResult(keyResult, valueResult, final, key, input2, inst, ctx) {
|
|
4122
4124
|
if (keyResult.issues.length) {
|
|
4123
4125
|
if (propertyKeyTypes.has(typeof key)) {
|
|
4124
4126
|
final.issues.push(...prefixIssues(key, keyResult.issues));
|
|
@@ -4126,7 +4128,7 @@ function handleMapResult(keyResult, valueResult, final, key, input, inst, ctx) {
|
|
|
4126
4128
|
final.issues.push({
|
|
4127
4129
|
code: "invalid_key",
|
|
4128
4130
|
origin: "map",
|
|
4129
|
-
input,
|
|
4131
|
+
input: input2,
|
|
4130
4132
|
inst,
|
|
4131
4133
|
issues: keyResult.issues.map((iss) => finalizeIssue(iss, ctx, config()))
|
|
4132
4134
|
});
|
|
@@ -4139,7 +4141,7 @@ function handleMapResult(keyResult, valueResult, final, key, input, inst, ctx) {
|
|
|
4139
4141
|
final.issues.push({
|
|
4140
4142
|
origin: "map",
|
|
4141
4143
|
code: "invalid_element",
|
|
4142
|
-
input,
|
|
4144
|
+
input: input2,
|
|
4143
4145
|
inst,
|
|
4144
4146
|
key,
|
|
4145
4147
|
issues: valueResult.issues.map((iss) => finalizeIssue(iss, ctx, config()))
|
|
@@ -4151,10 +4153,10 @@ function handleMapResult(keyResult, valueResult, final, key, input, inst, ctx) {
|
|
|
4151
4153
|
var $ZodSet = /* @__PURE__ */ $constructor("$ZodSet", (inst, def) => {
|
|
4152
4154
|
$ZodType.init(inst, def);
|
|
4153
4155
|
inst._zod.parse = (payload, ctx) => {
|
|
4154
|
-
const
|
|
4155
|
-
if (!(
|
|
4156
|
+
const input2 = payload.value;
|
|
4157
|
+
if (!(input2 instanceof Set)) {
|
|
4156
4158
|
payload.issues.push({
|
|
4157
|
-
input,
|
|
4159
|
+
input: input2,
|
|
4158
4160
|
inst,
|
|
4159
4161
|
expected: "set",
|
|
4160
4162
|
code: "invalid_type"
|
|
@@ -4163,7 +4165,7 @@ var $ZodSet = /* @__PURE__ */ $constructor("$ZodSet", (inst, def) => {
|
|
|
4163
4165
|
}
|
|
4164
4166
|
const proms = [];
|
|
4165
4167
|
payload.value = /* @__PURE__ */ new Set();
|
|
4166
|
-
for (const item of
|
|
4168
|
+
for (const item of input2) {
|
|
4167
4169
|
const result = def.valueType._zod.run({ value: item, issues: [] }, ctx);
|
|
4168
4170
|
if (result instanceof Promise) {
|
|
4169
4171
|
proms.push(result.then((result2) => handleSetResult(result2, payload)));
|
|
@@ -4188,14 +4190,14 @@ var $ZodEnum = /* @__PURE__ */ $constructor("$ZodEnum", (inst, def) => {
|
|
|
4188
4190
|
inst._zod.values = valuesSet;
|
|
4189
4191
|
inst._zod.pattern = new RegExp(`^(${values.filter((k) => propertyKeyTypes.has(typeof k)).map((o) => typeof o === "string" ? escapeRegex(o) : o.toString()).join("|")})$`);
|
|
4190
4192
|
inst._zod.parse = (payload, _ctx) => {
|
|
4191
|
-
const
|
|
4192
|
-
if (valuesSet.has(
|
|
4193
|
+
const input2 = payload.value;
|
|
4194
|
+
if (valuesSet.has(input2)) {
|
|
4193
4195
|
return payload;
|
|
4194
4196
|
}
|
|
4195
4197
|
payload.issues.push({
|
|
4196
4198
|
code: "invalid_value",
|
|
4197
4199
|
values,
|
|
4198
|
-
input,
|
|
4200
|
+
input: input2,
|
|
4199
4201
|
inst
|
|
4200
4202
|
});
|
|
4201
4203
|
return payload;
|
|
@@ -4210,14 +4212,14 @@ var $ZodLiteral = /* @__PURE__ */ $constructor("$ZodLiteral", (inst, def) => {
|
|
|
4210
4212
|
inst._zod.values = values;
|
|
4211
4213
|
inst._zod.pattern = new RegExp(`^(${def.values.map((o) => typeof o === "string" ? escapeRegex(o) : o ? escapeRegex(o.toString()) : String(o)).join("|")})$`);
|
|
4212
4214
|
inst._zod.parse = (payload, _ctx) => {
|
|
4213
|
-
const
|
|
4214
|
-
if (values.has(
|
|
4215
|
+
const input2 = payload.value;
|
|
4216
|
+
if (values.has(input2)) {
|
|
4215
4217
|
return payload;
|
|
4216
4218
|
}
|
|
4217
4219
|
payload.issues.push({
|
|
4218
4220
|
code: "invalid_value",
|
|
4219
4221
|
values: def.values,
|
|
4220
|
-
input,
|
|
4222
|
+
input: input2,
|
|
4221
4223
|
inst
|
|
4222
4224
|
});
|
|
4223
4225
|
return payload;
|
|
@@ -4226,13 +4228,13 @@ var $ZodLiteral = /* @__PURE__ */ $constructor("$ZodLiteral", (inst, def) => {
|
|
|
4226
4228
|
var $ZodFile = /* @__PURE__ */ $constructor("$ZodFile", (inst, def) => {
|
|
4227
4229
|
$ZodType.init(inst, def);
|
|
4228
4230
|
inst._zod.parse = (payload, _ctx) => {
|
|
4229
|
-
const
|
|
4230
|
-
if (
|
|
4231
|
+
const input2 = payload.value;
|
|
4232
|
+
if (input2 instanceof File)
|
|
4231
4233
|
return payload;
|
|
4232
4234
|
payload.issues.push({
|
|
4233
4235
|
expected: "file",
|
|
4234
4236
|
code: "invalid_type",
|
|
4235
|
-
input,
|
|
4237
|
+
input: input2,
|
|
4236
4238
|
inst
|
|
4237
4239
|
});
|
|
4238
4240
|
return payload;
|
|
@@ -4262,8 +4264,8 @@ var $ZodTransform = /* @__PURE__ */ $constructor("$ZodTransform", (inst, def) =>
|
|
|
4262
4264
|
return payload;
|
|
4263
4265
|
};
|
|
4264
4266
|
});
|
|
4265
|
-
function handleOptionalResult(result,
|
|
4266
|
-
if (
|
|
4267
|
+
function handleOptionalResult(result, input2) {
|
|
4268
|
+
if (input2 === void 0 && (result.issues.length || result.fallback)) {
|
|
4267
4269
|
return { issues: [], value: void 0 };
|
|
4268
4270
|
}
|
|
4269
4271
|
return result;
|
|
@@ -4281,11 +4283,11 @@ var $ZodOptional = /* @__PURE__ */ $constructor("$ZodOptional", (inst, def) => {
|
|
|
4281
4283
|
});
|
|
4282
4284
|
inst._zod.parse = (payload, ctx) => {
|
|
4283
4285
|
if (def.innerType._zod.optin === "optional") {
|
|
4284
|
-
const
|
|
4286
|
+
const input2 = payload.value;
|
|
4285
4287
|
const result = def.innerType._zod.run(payload, ctx);
|
|
4286
4288
|
if (result instanceof Promise)
|
|
4287
|
-
return result.then((r) => handleOptionalResult(r,
|
|
4288
|
-
return handleOptionalResult(result,
|
|
4289
|
+
return result.then((r) => handleOptionalResult(r, input2));
|
|
4290
|
+
return handleOptionalResult(result, input2);
|
|
4289
4291
|
}
|
|
4290
4292
|
if (payload.value === void 0) {
|
|
4291
4293
|
return payload;
|
|
@@ -4710,20 +4712,20 @@ var $ZodCustom = /* @__PURE__ */ $constructor("$ZodCustom", (inst, def) => {
|
|
|
4710
4712
|
return payload;
|
|
4711
4713
|
};
|
|
4712
4714
|
inst._zod.check = (payload) => {
|
|
4713
|
-
const
|
|
4714
|
-
const r = def.fn(
|
|
4715
|
+
const input2 = payload.value;
|
|
4716
|
+
const r = def.fn(input2);
|
|
4715
4717
|
if (r instanceof Promise) {
|
|
4716
|
-
return r.then((r2) => handleRefineResult(r2, payload,
|
|
4718
|
+
return r.then((r2) => handleRefineResult(r2, payload, input2, inst));
|
|
4717
4719
|
}
|
|
4718
|
-
handleRefineResult(r, payload,
|
|
4720
|
+
handleRefineResult(r, payload, input2, inst);
|
|
4719
4721
|
return;
|
|
4720
4722
|
};
|
|
4721
4723
|
});
|
|
4722
|
-
function handleRefineResult(result, payload,
|
|
4724
|
+
function handleRefineResult(result, payload, input2, inst) {
|
|
4723
4725
|
if (!result) {
|
|
4724
4726
|
const _iss = {
|
|
4725
4727
|
code: "custom",
|
|
4726
|
-
input,
|
|
4728
|
+
input: input2,
|
|
4727
4729
|
inst,
|
|
4728
4730
|
// incorporates params.error into issue reporting
|
|
4729
4731
|
path: [...inst._zod.def.path ?? []],
|
|
@@ -8010,8 +8012,8 @@ function ko_default() {
|
|
|
8010
8012
|
}
|
|
8011
8013
|
|
|
8012
8014
|
// ../../../node_modules/zod/v4/locales/lt.js
|
|
8013
|
-
var capitalizeFirstCharacter = (
|
|
8014
|
-
return
|
|
8015
|
+
var capitalizeFirstCharacter = (text2) => {
|
|
8016
|
+
return text2.charAt(0).toUpperCase() + text2.slice(1);
|
|
8015
8017
|
};
|
|
8016
8018
|
function getUnitTypeFromNumber(number4) {
|
|
8017
8019
|
const abs = Math.abs(number4);
|
|
@@ -11411,23 +11413,23 @@ function _overwrite(tx) {
|
|
|
11411
11413
|
}
|
|
11412
11414
|
// @__NO_SIDE_EFFECTS__
|
|
11413
11415
|
function _normalize(form) {
|
|
11414
|
-
return /* @__PURE__ */ _overwrite((
|
|
11416
|
+
return /* @__PURE__ */ _overwrite((input2) => input2.normalize(form));
|
|
11415
11417
|
}
|
|
11416
11418
|
// @__NO_SIDE_EFFECTS__
|
|
11417
11419
|
function _trim() {
|
|
11418
|
-
return /* @__PURE__ */ _overwrite((
|
|
11420
|
+
return /* @__PURE__ */ _overwrite((input2) => input2.trim());
|
|
11419
11421
|
}
|
|
11420
11422
|
// @__NO_SIDE_EFFECTS__
|
|
11421
11423
|
function _toLowerCase() {
|
|
11422
|
-
return /* @__PURE__ */ _overwrite((
|
|
11424
|
+
return /* @__PURE__ */ _overwrite((input2) => input2.toLowerCase());
|
|
11423
11425
|
}
|
|
11424
11426
|
// @__NO_SIDE_EFFECTS__
|
|
11425
11427
|
function _toUpperCase() {
|
|
11426
|
-
return /* @__PURE__ */ _overwrite((
|
|
11428
|
+
return /* @__PURE__ */ _overwrite((input2) => input2.toUpperCase());
|
|
11427
11429
|
}
|
|
11428
11430
|
// @__NO_SIDE_EFFECTS__
|
|
11429
11431
|
function _slugify() {
|
|
11430
|
-
return /* @__PURE__ */ _overwrite((
|
|
11432
|
+
return /* @__PURE__ */ _overwrite((input2) => slugify(input2));
|
|
11431
11433
|
}
|
|
11432
11434
|
// @__NO_SIDE_EFFECTS__
|
|
11433
11435
|
function _array(Class2, element, params) {
|
|
@@ -11732,8 +11734,8 @@ function _stringbool(Classes, _params) {
|
|
|
11732
11734
|
type: "pipe",
|
|
11733
11735
|
in: stringSchema,
|
|
11734
11736
|
out: booleanSchema,
|
|
11735
|
-
transform: ((
|
|
11736
|
-
let data =
|
|
11737
|
+
transform: ((input2, payload) => {
|
|
11738
|
+
let data = input2;
|
|
11737
11739
|
if (params.case !== "sensitive")
|
|
11738
11740
|
data = data.toLowerCase();
|
|
11739
11741
|
if (truthySet.has(data)) {
|
|
@@ -11752,8 +11754,8 @@ function _stringbool(Classes, _params) {
|
|
|
11752
11754
|
return {};
|
|
11753
11755
|
}
|
|
11754
11756
|
}),
|
|
11755
|
-
reverseTransform: ((
|
|
11756
|
-
if (
|
|
11757
|
+
reverseTransform: ((input2, _payload) => {
|
|
11758
|
+
if (input2 === true) {
|
|
11757
11759
|
return truthyArray[0] || "true";
|
|
11758
11760
|
} else {
|
|
11759
11761
|
return falsyArray[0] || "false";
|
|
@@ -12649,9 +12651,9 @@ var allProcessors = {
|
|
|
12649
12651
|
optional: optionalProcessor,
|
|
12650
12652
|
lazy: lazyProcessor
|
|
12651
12653
|
};
|
|
12652
|
-
function toJSONSchema(
|
|
12653
|
-
if ("_idmap" in
|
|
12654
|
-
const registry2 =
|
|
12654
|
+
function toJSONSchema(input2, params) {
|
|
12655
|
+
if ("_idmap" in input2) {
|
|
12656
|
+
const registry2 = input2;
|
|
12655
12657
|
const ctx2 = initializeContext({ ...params, processors: allProcessors });
|
|
12656
12658
|
const defs = {};
|
|
12657
12659
|
for (const entry of registry2._idmap.entries()) {
|
|
@@ -12679,9 +12681,9 @@ function toJSONSchema(input, params) {
|
|
|
12679
12681
|
return { schemas };
|
|
12680
12682
|
}
|
|
12681
12683
|
const ctx = initializeContext({ ...params, processors: allProcessors });
|
|
12682
|
-
process2(
|
|
12683
|
-
extractDefs(ctx,
|
|
12684
|
-
return finalize(ctx,
|
|
12684
|
+
process2(input2, ctx);
|
|
12685
|
+
extractDefs(ctx, input2);
|
|
12686
|
+
return finalize(ctx, input2);
|
|
12685
12687
|
}
|
|
12686
12688
|
|
|
12687
12689
|
// ../../../node_modules/zod/v4/core/json-schema-generator.js
|
|
@@ -14958,7 +14960,7 @@ var codexhostErrorSchema = external_exports.strictObject({
|
|
|
14958
14960
|
|
|
14959
14961
|
// ../../shared-contracts/dist/harness-presentation.js
|
|
14960
14962
|
var localeSchema = external_exports.string().max(64).regex(/^[a-z]{2,3}(?:-[A-Za-z0-9]{2,8})*$/u);
|
|
14961
|
-
var displayText = (maximum) => external_exports.string().min(1).max(maximum).refine((
|
|
14963
|
+
var displayText = (maximum) => external_exports.string().min(1).max(maximum).refine((text2) => text2.trim().length > 0);
|
|
14962
14964
|
var harnessLocalizationsSchema = external_exports.record(localeSchema, external_exports.object({
|
|
14963
14965
|
label: displayText(256).optional(),
|
|
14964
14966
|
description: displayText(1024).optional()
|
|
@@ -15047,7 +15049,7 @@ var usageMeasurementsSchema = external_exports.object({
|
|
|
15047
15049
|
outputTokensPerSecond: usageMeasurementSchema.refine((value) => value.version === 4).optional().catch(void 0),
|
|
15048
15050
|
timeToFirstOutputMs: usageMeasurementSchema.extend({ value: nonNegativeSafeIntegerSchema }).optional()
|
|
15049
15051
|
}).strict();
|
|
15050
|
-
var indicatorTextSchema = (maximum) => harnessLocalizedTextSchema.refine((entries) => Object.values(entries).every((
|
|
15052
|
+
var indicatorTextSchema = (maximum) => harnessLocalizedTextSchema.refine((entries) => Object.values(entries).every((text2) => text2.length <= maximum));
|
|
15051
15053
|
var composerIndicatorsSchema = external_exports.array(external_exports.object({
|
|
15052
15054
|
kind: external_exports.literal("countdown"),
|
|
15053
15055
|
id: external_exports.string().min(1).max(64),
|
|
@@ -15430,6 +15432,8 @@ var externalThreadInspectionSchema = external_exports.object({
|
|
|
15430
15432
|
effectiveThinkingOptionId: harnessThinkingOptionIdSchema.optional(),
|
|
15431
15433
|
availableThinkingOptions: harnessThinkingOptionsSchema.optional(),
|
|
15432
15434
|
effectivePermissionModeId: harnessPermissionModeIdSchema.optional(),
|
|
15435
|
+
/** Live Session catalog when it, not the Adapter inspection, contains `effectiveModel`. */
|
|
15436
|
+
catalog: harnessModelCatalogSchema.optional(),
|
|
15433
15437
|
history: harnessHistoryCapabilitiesSchema,
|
|
15434
15438
|
usage: threadUsageSnapshotSchema.optional(),
|
|
15435
15439
|
locked: external_exports.literal(true)
|
|
@@ -15488,9 +15492,9 @@ var threadSteeringInspectParamsSchema = external_exports.object({
|
|
|
15488
15492
|
}).strict();
|
|
15489
15493
|
var threadSteeringContextSchema = external_exports.object({
|
|
15490
15494
|
kind: external_exports.literal("application"),
|
|
15491
|
-
value: external_exports.string().transform((
|
|
15495
|
+
value: external_exports.string().transform((text2, context) => {
|
|
15492
15496
|
try {
|
|
15493
|
-
return JSON.parse(
|
|
15497
|
+
return JSON.parse(text2);
|
|
15494
15498
|
} catch {
|
|
15495
15499
|
context.addIssue({ code: "custom", message: "Invalid steering context JSON" });
|
|
15496
15500
|
return external_exports.NEVER;
|
|
@@ -15625,8 +15629,8 @@ var desktopExtensionHttpUrlSchema = external_exports.string().trim().max(2048).r
|
|
|
15625
15629
|
const { username, password } = new URL(value);
|
|
15626
15630
|
return !username && !password && !/[\\\s]/u.test(value);
|
|
15627
15631
|
}, "URL must not contain credentials, backslashes, or whitespace");
|
|
15628
|
-
function localizedText(
|
|
15629
|
-
return external_exports.strictObject({ en:
|
|
15632
|
+
function localizedText(text2) {
|
|
15633
|
+
return external_exports.strictObject({ en: text2, "zh-CN": text2 });
|
|
15630
15634
|
}
|
|
15631
15635
|
var desktopExtensionLocalizedTextSchema = localizedText(external_exports.string().trim().min(1));
|
|
15632
15636
|
var categoriesSchema = external_exports.array(desktopExtensionCategorySchema).max(desktopExtensionCategorySchema.options.length).refine((categories) => new Set(categories).size === categories.length, "Duplicate categories");
|
|
@@ -15743,8 +15747,8 @@ var desktopExtensionTrustTierSchema = external_exports.enum(["official", "commun
|
|
|
15743
15747
|
function isGitHubDesktopExtensionZipballUrl(url2) {
|
|
15744
15748
|
return url2.origin === "https://api.github.com" && /^\/repos\/[\w-]+\/[\w.-]+\/zipball(?:\/[^/]+)?\/?$/u.test(url2.pathname);
|
|
15745
15749
|
}
|
|
15746
|
-
var desktopExtensionZipUrlSchema = desktopExtensionHttpUrlSchema.refine((
|
|
15747
|
-
const url2 = new URL(
|
|
15750
|
+
var desktopExtensionZipUrlSchema = desktopExtensionHttpUrlSchema.refine((input2) => {
|
|
15751
|
+
const url2 = new URL(input2);
|
|
15748
15752
|
return /\.zip$/iu.test(url2.pathname) || isGitHubDesktopExtensionZipballUrl(url2) || url2.origin === "https://github.com" && /^\/[\w-]+\/[\w.-]+\/zipball(?:\/.+)?\/?$/u.test(url2.pathname) || url2.origin === "https://codeload.github.com" && /^\/[\w-]+\/[\w.-]+\/(?:zip|zipball|legacy\.zip)\/.+$/u.test(url2.pathname);
|
|
15749
15753
|
}, "Expected a .zip download URL or a GitHub zipball URL");
|
|
15750
15754
|
var desktopExtensionCatalogEntrySchema = external_exports.strictObject({
|
|
@@ -16095,6 +16099,8 @@ var CLIENT_CHANNEL_METHODS = [
|
|
|
16095
16099
|
"codexhost/workspace/read",
|
|
16096
16100
|
"codexhost/thread/tree/read",
|
|
16097
16101
|
"codexhost/thread/pins/list",
|
|
16102
|
+
"codexhost/thread/sections/list",
|
|
16103
|
+
"codexhost/thread/sections/move",
|
|
16098
16104
|
"codexhost/thread/pins/set",
|
|
16099
16105
|
"codexhost/harness/plugins/list",
|
|
16100
16106
|
"codexhost/harness/inspect",
|
|
@@ -16133,8 +16139,21 @@ var CLIENT_CHANNEL_METHODS = [
|
|
|
16133
16139
|
"codexhost/update/check",
|
|
16134
16140
|
"codexhost/update/start",
|
|
16135
16141
|
"codexhost/update/status",
|
|
16142
|
+
"codexhost/announcement/get",
|
|
16143
|
+
"codexhost/announcement/acknowledge",
|
|
16136
16144
|
"codexhost/sessions/loaded/list"
|
|
16137
16145
|
];
|
|
16146
|
+
var clientThreadSectionsSchema = external_exports.object({
|
|
16147
|
+
sections: external_exports.array(external_exports.object({
|
|
16148
|
+
id: external_exports.string().min(1),
|
|
16149
|
+
name: external_exports.string().min(1),
|
|
16150
|
+
threads: external_exports.array(jsonObjectSchema)
|
|
16151
|
+
}).strict())
|
|
16152
|
+
}).strict();
|
|
16153
|
+
var clientThreadSectionMoveSchema = external_exports.object({
|
|
16154
|
+
threadId: external_exports.string().min(1).max(1024),
|
|
16155
|
+
sectionId: external_exports.string().min(1).max(1024).nullable()
|
|
16156
|
+
}).strict();
|
|
16138
16157
|
var clientThreadPinsSchema = external_exports.object({ threadIds: external_exports.array(external_exports.string().min(1)) }).strict();
|
|
16139
16158
|
var clientThreadPinParamsSchema = external_exports.object({ threadId: external_exports.string().min(1).max(1024), pinned: external_exports.boolean() }).strict();
|
|
16140
16159
|
var clientThreadTreeReadParamsSchema = external_exports.object({}).strict();
|
|
@@ -16676,8 +16695,8 @@ var harnessPreferencePatchSchema = external_exports.strictObject({
|
|
|
16676
16695
|
operations: external_exports.array(harnessPreferenceOperationSchema).min(1).max(256),
|
|
16677
16696
|
initializeOnly: external_exports.boolean().optional(),
|
|
16678
16697
|
expectedRevision: external_exports.number().int().nonnegative().optional()
|
|
16679
|
-
}).superRefine((
|
|
16680
|
-
for (const operation of
|
|
16698
|
+
}).superRefine((input2, ctx) => {
|
|
16699
|
+
for (const operation of input2.operations) {
|
|
16681
16700
|
if (operation.kind === "newThread" && (!operation.lastHarness && !operation.configuration || Boolean(operation.harnessId) !== Boolean(operation.configuration)))
|
|
16682
16701
|
ctx.addIssue({
|
|
16683
16702
|
code: "custom",
|
|
@@ -17079,13 +17098,18 @@ var harnessLaunchSettingsSchema = external_exports.object({
|
|
|
17079
17098
|
// ../../shared-contracts/dist/harness-installation.js
|
|
17080
17099
|
var harnessInstallationParamsSchema = external_exports.object({
|
|
17081
17100
|
harnessId: harnessIdSchema,
|
|
17082
|
-
action: external_exports.enum(["check", "update", "install"])
|
|
17083
|
-
|
|
17101
|
+
action: external_exports.enum(["check", "update", "install"]),
|
|
17102
|
+
confirmedVersion: external_exports.string().min(1).max(128).optional()
|
|
17103
|
+
}).strict().refine(({ action, confirmedVersion }) => action === "update" || confirmedVersion === void 0);
|
|
17084
17104
|
var harnessInstallationStateSchema = external_exports.object({
|
|
17085
17105
|
currentVersion: external_exports.string().min(1).max(128),
|
|
17086
17106
|
latestVersion: external_exports.string().min(1).max(128),
|
|
17087
17107
|
updateAvailable: external_exports.boolean(),
|
|
17088
17108
|
canUpdate: external_exports.boolean(),
|
|
17109
|
+
/** Present when the Adapter has a verified list and the available target is outside it. */
|
|
17110
|
+
latestVerifiedVersion: external_exports.string().min(1).max(128).optional(),
|
|
17111
|
+
/** Update preflight stopped before running the installer; latestVersion needs confirmation. */
|
|
17112
|
+
confirmationRequired: external_exports.literal(true).optional(),
|
|
17089
17113
|
/** Defaults to CLI; some Harnesses ship only inside a desktop application. */
|
|
17090
17114
|
versionKind: external_exports.enum(["cli", "application"]).optional(),
|
|
17091
17115
|
/** Official download opened by the user; does not imply an automatic installation. */
|
|
@@ -17415,6 +17439,38 @@ var updateStatusResultSchema = external_exports.strictObject({
|
|
|
17415
17439
|
status: updateStatusSchema.nullable()
|
|
17416
17440
|
});
|
|
17417
17441
|
|
|
17442
|
+
// ../../shared-contracts/dist/release-announcement.js
|
|
17443
|
+
var RELEASE_ANNOUNCEMENT_MAX_THEMES = 12;
|
|
17444
|
+
var releaseAnnouncementThemeSchema = external_exports.strictObject({
|
|
17445
|
+
icon: external_exports.string().min(1).max(16).optional(),
|
|
17446
|
+
title: external_exports.string().min(1).max(120),
|
|
17447
|
+
body: external_exports.string().min(1).max(1200),
|
|
17448
|
+
contributors: external_exports.array(external_exports.string().min(1).max(39)).max(30)
|
|
17449
|
+
});
|
|
17450
|
+
var releaseAnnouncementContentSchema = external_exports.strictObject({
|
|
17451
|
+
summary: external_exports.string().min(1).max(600).optional(),
|
|
17452
|
+
themes: external_exports.array(releaseAnnouncementThemeSchema).min(1).max(RELEASE_ANNOUNCEMENT_MAX_THEMES)
|
|
17453
|
+
});
|
|
17454
|
+
var releaseAnnouncementSchema = external_exports.strictObject({
|
|
17455
|
+
version: updateSemanticVersionSchema,
|
|
17456
|
+
publishedAt: external_exports.iso.datetime(),
|
|
17457
|
+
url: external_exports.string().max(300).regex(/^https:\/\/github\.com\/BytePioneer-AI\/codex-host\/releases\/tag\/v[0-9A-Za-z.+-]+$/u),
|
|
17458
|
+
zh: releaseAnnouncementContentSchema.nullable(),
|
|
17459
|
+
en: releaseAnnouncementContentSchema.nullable()
|
|
17460
|
+
}).refine((value) => value.zh !== null || value.en !== null, {
|
|
17461
|
+
message: "an announcement needs at least one language"
|
|
17462
|
+
});
|
|
17463
|
+
var releaseAnnouncementGetParamsSchema = external_exports.strictObject({
|
|
17464
|
+
manual: external_exports.boolean().optional()
|
|
17465
|
+
});
|
|
17466
|
+
var releaseAnnouncementGetResultSchema = external_exports.strictObject({
|
|
17467
|
+
announcement: releaseAnnouncementSchema.nullable(),
|
|
17468
|
+
unread: external_exports.boolean()
|
|
17469
|
+
});
|
|
17470
|
+
var releaseAnnouncementAcknowledgeParamsSchema = external_exports.strictObject({
|
|
17471
|
+
version: updateSemanticVersionSchema
|
|
17472
|
+
});
|
|
17473
|
+
|
|
17418
17474
|
// ../../shared-contracts/dist/thread-watch-notice.js
|
|
17419
17475
|
var THREAD_WATCH_NOTICE_OUTCOMES = [
|
|
17420
17476
|
"completed",
|
|
@@ -17462,17 +17518,67 @@ var remoteSshSetupResultSchema = external_exports.object({ state: external_expor
|
|
|
17462
17518
|
|
|
17463
17519
|
// ../../shared-contracts/dist/remote-sessions.js
|
|
17464
17520
|
var REMOTE_CONTROLLER_REQUEST_MAX_BYTES = 16 * 1024;
|
|
17465
|
-
var
|
|
17521
|
+
var REMOTE_IDENTITY_MAX_LENGTH = 1024;
|
|
17522
|
+
var identity = external_exports.string().min(1).max(REMOTE_IDENTITY_MAX_LENGTH);
|
|
17466
17523
|
var target = { hostId: identity.regex(/^remote-(?:ssh(?:-|:)|control:)/u) };
|
|
17467
17524
|
var thread = { ...target, threadId: identity };
|
|
17525
|
+
var text = external_exports.string().min(1).max(8e3);
|
|
17526
|
+
var input = { text, requestId: identity };
|
|
17527
|
+
var remoteDeliveryReplySchema = external_exports.discriminatedUnion("accepted", [
|
|
17528
|
+
external_exports.object({ accepted: external_exports.literal(true), startQueuedItemId: identity.optional() }),
|
|
17529
|
+
external_exports.object({
|
|
17530
|
+
accepted: external_exports.literal(false),
|
|
17531
|
+
code: external_exports.enum([
|
|
17532
|
+
"remote/queue-unavailable",
|
|
17533
|
+
"remote/steer-unavailable",
|
|
17534
|
+
"remote/turn-changed",
|
|
17535
|
+
"remote/send-rejected",
|
|
17536
|
+
"session/queue-item-not-found",
|
|
17537
|
+
"session/queue-item-starting"
|
|
17538
|
+
]),
|
|
17539
|
+
message: external_exports.string()
|
|
17540
|
+
})
|
|
17541
|
+
]);
|
|
17542
|
+
var remoteQueueSnapshotSchema = external_exports.discriminatedUnion("available", [
|
|
17543
|
+
external_exports.object({ available: external_exports.literal(false) }),
|
|
17544
|
+
external_exports.object({
|
|
17545
|
+
available: external_exports.literal(true),
|
|
17546
|
+
items: external_exports.array(external_exports.object({ id: identity, clientUserMessageId: identity, preview: external_exports.string().max(801) })).max(100)
|
|
17547
|
+
})
|
|
17548
|
+
]);
|
|
17468
17549
|
var remoteSessionOperationSchema = external_exports.discriminatedUnion("kind", [
|
|
17469
17550
|
external_exports.strictObject({ kind: external_exports.literal("hosts") }),
|
|
17551
|
+
external_exports.strictObject({
|
|
17552
|
+
kind: external_exports.literal("create"),
|
|
17553
|
+
...target,
|
|
17554
|
+
cwd: external_exports.string().min(1).max(8192),
|
|
17555
|
+
epoch: identity
|
|
17556
|
+
}),
|
|
17557
|
+
external_exports.strictObject({ kind: external_exports.literal("projectHarnesses"), ...target, epoch: identity }),
|
|
17558
|
+
external_exports.strictObject({
|
|
17559
|
+
kind: external_exports.literal("inspectHarness"),
|
|
17560
|
+
...target,
|
|
17561
|
+
epoch: identity,
|
|
17562
|
+
cwd: external_exports.string().min(1).max(8192),
|
|
17563
|
+
harnessId: identity
|
|
17564
|
+
}),
|
|
17565
|
+
external_exports.strictObject({
|
|
17566
|
+
kind: external_exports.literal("startSelected"),
|
|
17567
|
+
...target,
|
|
17568
|
+
epoch: identity,
|
|
17569
|
+
cwd: external_exports.string().min(1).max(8192),
|
|
17570
|
+
harnessId: identity,
|
|
17571
|
+
model: external_exports.string().min(1).max(4096),
|
|
17572
|
+
serviceTier: external_exports.enum(["priority", "ultrafast"]).optional(),
|
|
17573
|
+
reasoningEffort: identity.optional()
|
|
17574
|
+
}),
|
|
17470
17575
|
external_exports.strictObject({ kind: external_exports.literal("status"), ...thread }),
|
|
17471
17576
|
external_exports.strictObject({
|
|
17472
17577
|
kind: external_exports.literal("list"),
|
|
17473
17578
|
...target,
|
|
17474
17579
|
cursor: external_exports.string().nullable(),
|
|
17475
|
-
archived: external_exports.boolean()
|
|
17580
|
+
archived: external_exports.boolean(),
|
|
17581
|
+
includeLoaded: external_exports.literal(true).optional()
|
|
17476
17582
|
}),
|
|
17477
17583
|
external_exports.strictObject({
|
|
17478
17584
|
kind: external_exports.literal("read"),
|
|
@@ -17502,9 +17608,25 @@ var remoteSessionOperationSchema = external_exports.discriminatedUnion("kind", [
|
|
|
17502
17608
|
kind: external_exports.literal("prompt"),
|
|
17503
17609
|
...thread,
|
|
17504
17610
|
epoch: identity,
|
|
17505
|
-
text
|
|
17611
|
+
text,
|
|
17506
17612
|
requestId: identity.optional()
|
|
17507
17613
|
}),
|
|
17614
|
+
external_exports.strictObject({ kind: external_exports.literal("queue"), ...thread, epoch: identity }),
|
|
17615
|
+
external_exports.strictObject({
|
|
17616
|
+
kind: external_exports.literal("delivery"),
|
|
17617
|
+
...thread,
|
|
17618
|
+
epoch: identity,
|
|
17619
|
+
action: external_exports.discriminatedUnion("kind", [
|
|
17620
|
+
external_exports.strictObject({ kind: external_exports.literal("enqueue"), ...input }),
|
|
17621
|
+
external_exports.strictObject({ kind: external_exports.literal("steer"), ...input, turnId: identity }),
|
|
17622
|
+
external_exports.strictObject({ kind: external_exports.literal("remove"), itemId: identity }),
|
|
17623
|
+
external_exports.strictObject({
|
|
17624
|
+
kind: external_exports.literal("start"),
|
|
17625
|
+
itemId: identity,
|
|
17626
|
+
onlyIfHead: external_exports.literal(true).optional()
|
|
17627
|
+
})
|
|
17628
|
+
])
|
|
17629
|
+
}),
|
|
17508
17630
|
external_exports.strictObject({ kind: external_exports.literal("interrupt"), ...thread, epoch: identity, turnId: identity }),
|
|
17509
17631
|
external_exports.strictObject({
|
|
17510
17632
|
kind: external_exports.literal("rename"),
|
|
@@ -17972,8 +18094,8 @@ function liveHarnessCommandPrompt(catalog, idPrefix, commandId, argumentText) {
|
|
|
17972
18094
|
const descriptor = catalog.commands.find(({ id: id2 }) => id2 === commandId);
|
|
17973
18095
|
if (!descriptor)
|
|
17974
18096
|
return null;
|
|
17975
|
-
const
|
|
17976
|
-
return
|
|
18097
|
+
const text2 = typeof argumentText === "string" ? argumentText.trim() : "";
|
|
18098
|
+
return text2 ? `${descriptor.invocation} ${text2}` : descriptor.invocation;
|
|
17977
18099
|
}
|
|
17978
18100
|
function mergeLiveHarnessCommands(builtIns, idPrefix, live, exclusions = {}) {
|
|
17979
18101
|
if (!live)
|
|
@@ -18013,9 +18135,9 @@ function subagentConfiguration(value) {
|
|
|
18013
18135
|
if (typeof value !== "object" || value === null || Array.isArray(value))
|
|
18014
18136
|
return {};
|
|
18015
18137
|
const row = value;
|
|
18016
|
-
const
|
|
18017
|
-
const model2 = row.model === "inherit" ? void 0 :
|
|
18018
|
-
const reasoningEffort =
|
|
18138
|
+
const text2 = (value2) => typeof value2 === "string" && value2.trim() ? value2 : void 0;
|
|
18139
|
+
const model2 = row.model === "inherit" ? void 0 : text2(row.model);
|
|
18140
|
+
const reasoningEffort = text2(row.reasoningEffort) ?? text2(row.reasoning_effort) ?? text2(row.thinking);
|
|
18019
18141
|
return { ...model2 ? { model: model2 } : {}, ...reasoningEffort ? { reasoningEffort } : {} };
|
|
18020
18142
|
}
|
|
18021
18143
|
function inheritSubagentConfiguration(child, parent) {
|
|
@@ -18220,20 +18342,20 @@ async function readGrokUsage(file2, signal) {
|
|
|
18220
18342
|
for (const [model2, value] of Object.entries(isRecord2(usage.modelUsage) ? usage.modelUsage : {})) {
|
|
18221
18343
|
if (!isRecord2(value))
|
|
18222
18344
|
continue;
|
|
18223
|
-
const
|
|
18345
|
+
const input2 = count2(value.inputTokens);
|
|
18224
18346
|
const output = count2(value.outputTokens);
|
|
18225
18347
|
const cached2 = count2(value.cachedReadTokens);
|
|
18226
18348
|
const written = count2(value.cacheCreationTokens ?? 0);
|
|
18227
18349
|
const reasoning = count2(value.reasoningTokens);
|
|
18228
18350
|
const ticks = count2(value.costUsdTicks);
|
|
18229
|
-
if (
|
|
18351
|
+
if (input2 === null || output === null || value.totalTokens !== input2 + output)
|
|
18230
18352
|
continue;
|
|
18231
|
-
const cacheKnown = cached2 !== null && cached2 <=
|
|
18353
|
+
const cacheKnown = cached2 !== null && cached2 <= input2 && written === 0;
|
|
18232
18354
|
entries.push(withUsageSession({
|
|
18233
18355
|
id: `${update.prompt_id}:${model2}`,
|
|
18234
18356
|
occurredAtMs: at,
|
|
18235
18357
|
model: model2,
|
|
18236
|
-
inputTokens:
|
|
18358
|
+
inputTokens: input2,
|
|
18237
18359
|
...cacheKnown ? { cachedInputTokens: cached2, cacheWriteInputTokens: 0 } : {},
|
|
18238
18360
|
outputTokens: output,
|
|
18239
18361
|
...reasoning !== null && reasoning <= output ? { reasoningOutputTokens: reasoning } : {},
|
|
@@ -18316,8 +18438,8 @@ var MEDIA_EXTENSIONS = /* @__PURE__ */ new Set([
|
|
|
18316
18438
|
".webm",
|
|
18317
18439
|
".webp"
|
|
18318
18440
|
]);
|
|
18319
|
-
function rewriteLocalMediaMarkdown(
|
|
18320
|
-
return projectLocalMedia(
|
|
18441
|
+
function rewriteLocalMediaMarkdown(text2, roots, options = {}) {
|
|
18442
|
+
return projectLocalMedia(text2, roots, options.exists ?? mediaFileExists, options.holdIncomplete === true, options.relativeImagesOnly === true).text;
|
|
18321
18443
|
}
|
|
18322
18444
|
var LocalMediaMarkdownStream = class {
|
|
18323
18445
|
#roots;
|
|
@@ -18346,8 +18468,8 @@ var LocalMediaMarkdownStream = class {
|
|
|
18346
18468
|
return this.#text;
|
|
18347
18469
|
}
|
|
18348
18470
|
/** Add native text and return the projected text it makes publishable, possibly empty. */
|
|
18349
|
-
append(
|
|
18350
|
-
this.#native +=
|
|
18471
|
+
append(text2) {
|
|
18472
|
+
this.#native += text2;
|
|
18351
18473
|
return this.#advance(true);
|
|
18352
18474
|
}
|
|
18353
18475
|
/** Return the projected text still held at the end of the stream. */
|
|
@@ -18369,89 +18491,89 @@ var LocalMediaMarkdownStream = class {
|
|
|
18369
18491
|
return delta;
|
|
18370
18492
|
}
|
|
18371
18493
|
};
|
|
18372
|
-
function projectLocalMedia(
|
|
18494
|
+
function projectLocalMedia(text2, roots, exists, holdIncomplete, relativeImagesOnly) {
|
|
18373
18495
|
let output = "";
|
|
18374
18496
|
let index = 0;
|
|
18375
18497
|
let fence = null;
|
|
18376
|
-
while (index <
|
|
18498
|
+
while (index < text2.length) {
|
|
18377
18499
|
if (fence) {
|
|
18378
|
-
const close = closingFenceEnd(
|
|
18500
|
+
const close = closingFenceEnd(text2, index, fence.marker, fence.length);
|
|
18379
18501
|
if (close === -1)
|
|
18380
18502
|
break;
|
|
18381
|
-
output +=
|
|
18503
|
+
output += text2.slice(index, close);
|
|
18382
18504
|
index = close;
|
|
18383
18505
|
fence = null;
|
|
18384
18506
|
continue;
|
|
18385
18507
|
}
|
|
18386
18508
|
const next = earliestIndex([
|
|
18387
|
-
|
|
18388
|
-
|
|
18389
|
-
indexOfLineStartTilde(
|
|
18509
|
+
text2.indexOf("![", index),
|
|
18510
|
+
text2.indexOf("`", index),
|
|
18511
|
+
indexOfLineStartTilde(text2, index)
|
|
18390
18512
|
]);
|
|
18391
18513
|
if (next === -1)
|
|
18392
18514
|
break;
|
|
18393
|
-
output +=
|
|
18515
|
+
output += text2.slice(index, next);
|
|
18394
18516
|
index = next;
|
|
18395
|
-
const marker =
|
|
18517
|
+
const marker = text2[next];
|
|
18396
18518
|
let markerLength = 1;
|
|
18397
18519
|
if (marker === "`" || marker === "~") {
|
|
18398
18520
|
let runEnd = next;
|
|
18399
|
-
while (
|
|
18521
|
+
while (text2[runEnd] === marker)
|
|
18400
18522
|
runEnd += 1;
|
|
18401
18523
|
markerLength = runEnd - next;
|
|
18402
|
-
if (runEnd ===
|
|
18524
|
+
if (runEnd === text2.length && holdIncomplete) {
|
|
18403
18525
|
return { text: output, consumed: next };
|
|
18404
18526
|
}
|
|
18405
18527
|
if (runEnd - next >= 3) {
|
|
18406
|
-
const kind = fenceLineKind(
|
|
18528
|
+
const kind = fenceLineKind(text2, next);
|
|
18407
18529
|
if (kind === "opaque")
|
|
18408
18530
|
break;
|
|
18409
18531
|
if (kind === "flat") {
|
|
18410
18532
|
fence = { marker, length: runEnd - next };
|
|
18411
|
-
output +=
|
|
18533
|
+
output += text2.slice(next, runEnd);
|
|
18412
18534
|
index = runEnd;
|
|
18413
18535
|
continue;
|
|
18414
18536
|
}
|
|
18415
18537
|
}
|
|
18416
18538
|
if (marker === "~") {
|
|
18417
|
-
output +=
|
|
18539
|
+
output += text2.slice(next, runEnd);
|
|
18418
18540
|
index = runEnd;
|
|
18419
18541
|
continue;
|
|
18420
18542
|
}
|
|
18421
18543
|
}
|
|
18422
|
-
if (
|
|
18423
|
-
const image = parseMarkdownImage(
|
|
18544
|
+
if (text2.startsWith("![", next)) {
|
|
18545
|
+
const image = parseMarkdownImage(text2, next);
|
|
18424
18546
|
if (image.kind === "text") {
|
|
18425
|
-
output +=
|
|
18547
|
+
output += text2.slice(next, image.end);
|
|
18426
18548
|
index = image.end;
|
|
18427
18549
|
continue;
|
|
18428
18550
|
}
|
|
18429
18551
|
if (image.kind === "open") {
|
|
18430
18552
|
if (!holdIncomplete)
|
|
18431
18553
|
break;
|
|
18432
|
-
return { text: output +
|
|
18554
|
+
return { text: output + text2.slice(next, image.holdFrom), consumed: image.holdFrom };
|
|
18433
18555
|
}
|
|
18434
18556
|
const resolved2 = relativeImagesOnly && /^(?:[\\/]|[a-z][a-z\d+.-]*:)/i.test(image.destination.trim()) ? null : resolveLocalMediaPath(image.destination, roots, exists);
|
|
18435
|
-
output += resolved2 === null ?
|
|
18557
|
+
output += resolved2 === null ? text2.slice(next, image.end) : text2.slice(next, image.destinationStart) + markdownDestination(resolved2, image.bracketed) + text2.slice(image.destinationEnd, image.end);
|
|
18436
18558
|
index = image.end;
|
|
18437
18559
|
continue;
|
|
18438
18560
|
}
|
|
18439
|
-
const code = parseInlineCode(
|
|
18440
|
-
if (code.kind !== "code" || holdIncomplete && code.end ===
|
|
18561
|
+
const code = parseInlineCode(text2, next, markerLength);
|
|
18562
|
+
if (code.kind !== "code" || holdIncomplete && code.end === text2.length) {
|
|
18441
18563
|
if (holdIncomplete && code.kind !== "text")
|
|
18442
18564
|
return { text: output, consumed: next };
|
|
18443
|
-
output +=
|
|
18565
|
+
output += text2.slice(next, next + markerLength);
|
|
18444
18566
|
index = next + markerLength;
|
|
18445
18567
|
continue;
|
|
18446
18568
|
}
|
|
18447
18569
|
const resolved = relativeImagesOnly || markerLength !== 1 || /[\r\n]/u.test(code.content) ? null : resolveLocalMediaPath(code.content, roots, exists);
|
|
18448
|
-
output += resolved === null ?
|
|
18570
|
+
output += resolved === null ? text2.slice(next, code.end) : mediaMarkdownImage(resolved);
|
|
18449
18571
|
index = code.end;
|
|
18450
18572
|
}
|
|
18451
|
-
return { text: output +
|
|
18573
|
+
return { text: output + text2.slice(index), consumed: text2.length };
|
|
18452
18574
|
}
|
|
18453
|
-
function fenceLineKind(
|
|
18454
|
-
const prefix =
|
|
18575
|
+
function fenceLineKind(text2, index) {
|
|
18576
|
+
const prefix = text2.slice(text2.lastIndexOf("\n", index - 1) + 1, index);
|
|
18455
18577
|
if (prefix === "")
|
|
18456
18578
|
return "flat";
|
|
18457
18579
|
let remaining = prefix.replace(/^[ \t]+/u, "");
|
|
@@ -18463,21 +18585,21 @@ function fenceLineKind(text, index) {
|
|
|
18463
18585
|
}
|
|
18464
18586
|
return "opaque";
|
|
18465
18587
|
}
|
|
18466
|
-
function indexOfLineStartTilde(
|
|
18467
|
-
for (let tilde =
|
|
18468
|
-
if (fenceLineKind(
|
|
18588
|
+
function indexOfLineStartTilde(text2, start) {
|
|
18589
|
+
for (let tilde = text2.indexOf("~", start); tilde !== -1; tilde = text2.indexOf("~", tilde + 1)) {
|
|
18590
|
+
if (fenceLineKind(text2, tilde) !== null)
|
|
18469
18591
|
return tilde;
|
|
18470
18592
|
}
|
|
18471
18593
|
return -1;
|
|
18472
18594
|
}
|
|
18473
|
-
function closingFenceEnd(
|
|
18595
|
+
function closingFenceEnd(text2, start, marker, length) {
|
|
18474
18596
|
const closing = new RegExp(`^ {0,3}${marker === "`" ? "`" : "~"}{${length},}[ \\t]*\\r?$`, "u");
|
|
18475
|
-
let lineStart =
|
|
18597
|
+
let lineStart = text2.indexOf("\n", start);
|
|
18476
18598
|
while (lineStart !== -1) {
|
|
18477
18599
|
lineStart += 1;
|
|
18478
|
-
const newline2 =
|
|
18479
|
-
const lineEnd = newline2 === -1 ?
|
|
18480
|
-
if (closing.test(
|
|
18600
|
+
const newline2 = text2.indexOf("\n", lineStart);
|
|
18601
|
+
const lineEnd = newline2 === -1 ? text2.length : newline2;
|
|
18602
|
+
if (closing.test(text2.slice(lineStart, lineEnd)))
|
|
18481
18603
|
return lineEnd;
|
|
18482
18604
|
lineStart = newline2;
|
|
18483
18605
|
}
|
|
@@ -18493,30 +18615,30 @@ function earliestIndex(candidates) {
|
|
|
18493
18615
|
}
|
|
18494
18616
|
return next;
|
|
18495
18617
|
}
|
|
18496
|
-
function parseInlineCode(
|
|
18618
|
+
function parseInlineCode(text2, start, length) {
|
|
18497
18619
|
let index = start + length;
|
|
18498
|
-
while (index <
|
|
18499
|
-
const tick =
|
|
18500
|
-
if (/\n[^\S\n]*\n/u.test(
|
|
18620
|
+
while (index < text2.length) {
|
|
18621
|
+
const tick = text2.indexOf("`", index);
|
|
18622
|
+
if (/\n[^\S\n]*\n/u.test(text2.slice(index, tick < 0 ? text2.length : tick))) {
|
|
18501
18623
|
return { kind: "text" };
|
|
18502
18624
|
}
|
|
18503
18625
|
if (tick === -1)
|
|
18504
18626
|
break;
|
|
18505
18627
|
let end = tick + 1;
|
|
18506
|
-
while (
|
|
18628
|
+
while (text2[end] === "`")
|
|
18507
18629
|
end += 1;
|
|
18508
18630
|
if (end - tick === length) {
|
|
18509
|
-
return { kind: "code", content:
|
|
18631
|
+
return { kind: "code", content: text2.slice(start + length, tick), end };
|
|
18510
18632
|
}
|
|
18511
18633
|
index = end;
|
|
18512
18634
|
}
|
|
18513
18635
|
return { kind: "open" };
|
|
18514
18636
|
}
|
|
18515
|
-
function parseMarkdownImage(
|
|
18637
|
+
function parseMarkdownImage(text2, start) {
|
|
18516
18638
|
const openLabel = { kind: "open", holdFrom: start + 2 };
|
|
18517
18639
|
let index = start + 2;
|
|
18518
|
-
while (index <
|
|
18519
|
-
const character =
|
|
18640
|
+
while (index < text2.length) {
|
|
18641
|
+
const character = text2[index];
|
|
18520
18642
|
if (character === "\n")
|
|
18521
18643
|
return { kind: "text", end: start + 1 };
|
|
18522
18644
|
if (character === "\\") {
|
|
@@ -18527,62 +18649,62 @@ function parseMarkdownImage(text, start) {
|
|
|
18527
18649
|
break;
|
|
18528
18650
|
index += 1;
|
|
18529
18651
|
}
|
|
18530
|
-
if (index + 1 >=
|
|
18652
|
+
if (index + 1 >= text2.length)
|
|
18531
18653
|
return openLabel;
|
|
18532
|
-
if (
|
|
18654
|
+
if (text2[index + 1] !== "(")
|
|
18533
18655
|
return { kind: "text", end: start + 1 };
|
|
18534
18656
|
const destinationStart = index + 2;
|
|
18535
18657
|
const open = { kind: "open", holdFrom: destinationStart };
|
|
18536
18658
|
const malformed = { kind: "text", end: destinationStart };
|
|
18537
|
-
index = skipBlanks(
|
|
18538
|
-
if (index >=
|
|
18659
|
+
index = skipBlanks(text2, destinationStart);
|
|
18660
|
+
if (index >= text2.length)
|
|
18539
18661
|
return open;
|
|
18540
18662
|
let destination;
|
|
18541
18663
|
let destinationEnd;
|
|
18542
18664
|
let bracketed = false;
|
|
18543
|
-
if (
|
|
18665
|
+
if (text2[index] === "<") {
|
|
18544
18666
|
bracketed = true;
|
|
18545
18667
|
let close = index + 1;
|
|
18546
|
-
while (close <
|
|
18668
|
+
while (close < text2.length && text2[close] !== ">" && text2[close] !== "\n")
|
|
18547
18669
|
close += 1;
|
|
18548
|
-
if (close >=
|
|
18670
|
+
if (close >= text2.length)
|
|
18549
18671
|
return open;
|
|
18550
|
-
if (
|
|
18672
|
+
if (text2[close] === "\n")
|
|
18551
18673
|
return malformed;
|
|
18552
|
-
destination =
|
|
18674
|
+
destination = text2.slice(index + 1, close);
|
|
18553
18675
|
destinationEnd = close + 1;
|
|
18554
18676
|
index = destinationEnd;
|
|
18555
18677
|
} else {
|
|
18556
18678
|
const begin = index;
|
|
18557
|
-
while (index <
|
|
18558
|
-
const character =
|
|
18679
|
+
while (index < text2.length) {
|
|
18680
|
+
const character = text2[index];
|
|
18559
18681
|
if (character === "\n" || character === " " || character === " " || character === ")")
|
|
18560
18682
|
break;
|
|
18561
18683
|
index += character === "\\" ? 2 : 1;
|
|
18562
18684
|
}
|
|
18563
|
-
if (index >=
|
|
18685
|
+
if (index >= text2.length)
|
|
18564
18686
|
return open;
|
|
18565
|
-
destination = unescapeMarkdown(
|
|
18687
|
+
destination = unescapeMarkdown(text2.slice(begin, index));
|
|
18566
18688
|
destinationEnd = index;
|
|
18567
18689
|
}
|
|
18568
|
-
index = skipBlanks(
|
|
18569
|
-
if (index >=
|
|
18690
|
+
index = skipBlanks(text2, index);
|
|
18691
|
+
if (index >= text2.length)
|
|
18570
18692
|
return open;
|
|
18571
|
-
const opener =
|
|
18693
|
+
const opener = text2[index];
|
|
18572
18694
|
if (opener === '"' || opener === "'" || opener === "(") {
|
|
18573
18695
|
const closer = opener === "(" ? ")" : opener;
|
|
18574
18696
|
index += 1;
|
|
18575
|
-
while (index <
|
|
18697
|
+
while (index < text2.length && text2[index] !== closer && text2[index] !== "\n")
|
|
18576
18698
|
index += 1;
|
|
18577
|
-
if (index >=
|
|
18699
|
+
if (index >= text2.length)
|
|
18578
18700
|
return open;
|
|
18579
|
-
if (
|
|
18701
|
+
if (text2[index] === "\n")
|
|
18580
18702
|
return malformed;
|
|
18581
|
-
index = skipBlanks(
|
|
18582
|
-
if (index >=
|
|
18703
|
+
index = skipBlanks(text2, index + 1);
|
|
18704
|
+
if (index >= text2.length)
|
|
18583
18705
|
return open;
|
|
18584
18706
|
}
|
|
18585
|
-
if (
|
|
18707
|
+
if (text2[index] !== ")")
|
|
18586
18708
|
return malformed;
|
|
18587
18709
|
return {
|
|
18588
18710
|
kind: "image",
|
|
@@ -18593,9 +18715,9 @@ function parseMarkdownImage(text, start) {
|
|
|
18593
18715
|
bracketed
|
|
18594
18716
|
};
|
|
18595
18717
|
}
|
|
18596
|
-
function skipBlanks(
|
|
18718
|
+
function skipBlanks(text2, start) {
|
|
18597
18719
|
let index = start;
|
|
18598
|
-
while (
|
|
18720
|
+
while (text2[index] === " " || text2[index] === " ")
|
|
18599
18721
|
index += 1;
|
|
18600
18722
|
return index;
|
|
18601
18723
|
}
|
|
@@ -21349,7 +21471,7 @@ var LineBuffer = class {
|
|
|
21349
21471
|
};
|
|
21350
21472
|
|
|
21351
21473
|
// ../../../node_modules/@agentclientprotocol/sdk/dist/stream.js
|
|
21352
|
-
function ndJsonStream(output,
|
|
21474
|
+
function ndJsonStream(output, input2) {
|
|
21353
21475
|
const textEncoder = new TextEncoder();
|
|
21354
21476
|
const textDecoder = new TextDecoder();
|
|
21355
21477
|
let cancelled = false;
|
|
@@ -21372,7 +21494,7 @@ function ndJsonStream(output, input) {
|
|
|
21372
21494
|
}
|
|
21373
21495
|
}
|
|
21374
21496
|
};
|
|
21375
|
-
const reader =
|
|
21497
|
+
const reader = input2.getReader();
|
|
21376
21498
|
inputReader = reader;
|
|
21377
21499
|
try {
|
|
21378
21500
|
while (true) {
|
|
@@ -21455,8 +21577,8 @@ var zGuardCreateElicitationResponseCancel = object({
|
|
|
21455
21577
|
});
|
|
21456
21578
|
|
|
21457
21579
|
// ../../../node_modules/@agentclientprotocol/sdk/dist/acp.js
|
|
21458
|
-
function ndJsonStream2(output,
|
|
21459
|
-
return ndJsonStream(output,
|
|
21580
|
+
function ndJsonStream2(output, input2) {
|
|
21581
|
+
return ndJsonStream(output, input2);
|
|
21460
21582
|
}
|
|
21461
21583
|
function emptyObjectResponse(response) {
|
|
21462
21584
|
return response ?? {};
|
|
@@ -22986,12 +23108,12 @@ var grokDiscoverySpec = {
|
|
|
22986
23108
|
windows: ["~/.grok/bin", "${APPDATA}/npm", "~/.local/bin", VERSION_MANAGER_ROOTS]
|
|
22987
23109
|
}
|
|
22988
23110
|
};
|
|
22989
|
-
function resolveGrokExecutable(
|
|
22990
|
-
const platform =
|
|
23111
|
+
function resolveGrokExecutable(input2 = {}) {
|
|
23112
|
+
const platform = input2.platform ?? process.platform;
|
|
22991
23113
|
const resolution = resolveHarnessExecutable(grokDiscoverySpec, {
|
|
22992
|
-
...
|
|
22993
|
-
environment:
|
|
22994
|
-
...
|
|
23114
|
+
...input2.command ? { command: input2.command } : {},
|
|
23115
|
+
environment: input2.environment ?? process.env,
|
|
23116
|
+
...input2.homeDirectory ? { homeDirectory: input2.homeDirectory } : {},
|
|
22995
23117
|
platform
|
|
22996
23118
|
});
|
|
22997
23119
|
if (!resolution)
|
|
@@ -23418,9 +23540,9 @@ function createTwoFilesPatch(oldFileName, newFileName, oldStr, newStr, oldHeader
|
|
|
23418
23540
|
} }));
|
|
23419
23541
|
}
|
|
23420
23542
|
}
|
|
23421
|
-
function splitLines(
|
|
23422
|
-
const hasTrailingNl =
|
|
23423
|
-
const result =
|
|
23543
|
+
function splitLines(text2) {
|
|
23544
|
+
const hasTrailingNl = text2.endsWith("\n");
|
|
23545
|
+
const result = text2.split("\n").map((line) => line + "\n");
|
|
23424
23546
|
if (hasTrailingNl) {
|
|
23425
23547
|
result.pop();
|
|
23426
23548
|
} else {
|
|
@@ -23591,22 +23713,22 @@ function grokCommand(name, kind, rawInput) {
|
|
|
23591
23713
|
function grokCommandCwd(rawInput, fallback) {
|
|
23592
23714
|
return stringField(rawInput, "cwd") ?? fallback;
|
|
23593
23715
|
}
|
|
23594
|
-
function startGrokToolItem(
|
|
23595
|
-
const name = grokToolName(
|
|
23596
|
-
const command = grokCommand(name,
|
|
23716
|
+
function startGrokToolItem(input2) {
|
|
23717
|
+
const name = grokToolName(input2.name, input2.title);
|
|
23718
|
+
const command = grokCommand(name, input2.kind ?? void 0, input2.rawInput);
|
|
23597
23719
|
if (command) {
|
|
23598
23720
|
return {
|
|
23599
23721
|
type: "commandExecution",
|
|
23600
|
-
itemId:
|
|
23722
|
+
itemId: input2.itemId,
|
|
23601
23723
|
command,
|
|
23602
|
-
cwd: grokCommandCwd(
|
|
23724
|
+
cwd: grokCommandCwd(input2.rawInput, input2.cwd)
|
|
23603
23725
|
};
|
|
23604
23726
|
}
|
|
23605
23727
|
return {
|
|
23606
23728
|
type: "toolExecution",
|
|
23607
|
-
itemId:
|
|
23729
|
+
itemId: input2.itemId,
|
|
23608
23730
|
toolName: name,
|
|
23609
|
-
arguments: grokToolArguments(
|
|
23731
|
+
arguments: grokToolArguments(input2.rawInput)
|
|
23610
23732
|
};
|
|
23611
23733
|
}
|
|
23612
23734
|
function acpContentText(content) {
|
|
@@ -23644,10 +23766,10 @@ function acpContentImages(content, remainingBytes) {
|
|
|
23644
23766
|
}
|
|
23645
23767
|
function bashOutput(rawOutput) {
|
|
23646
23768
|
const output = rawOutput.output;
|
|
23647
|
-
const
|
|
23769
|
+
const text2 = typeof output === "string" ? output : decodeBytes(output);
|
|
23648
23770
|
const exitCode = numberField(rawOutput, "exit_code") ?? numberField(rawOutput, "exitCode");
|
|
23649
23771
|
return {
|
|
23650
|
-
...
|
|
23772
|
+
...text2 !== void 0 ? { text: text2 } : {},
|
|
23651
23773
|
...exitCode !== void 0 ? { exitCode } : {}
|
|
23652
23774
|
};
|
|
23653
23775
|
}
|
|
@@ -23661,9 +23783,9 @@ function rawOutputProjection(rawOutput) {
|
|
|
23661
23783
|
if (bash.text !== void 0 || bash.exitCode !== void 0)
|
|
23662
23784
|
return bash;
|
|
23663
23785
|
}
|
|
23664
|
-
const
|
|
23665
|
-
if (
|
|
23666
|
-
return { text };
|
|
23786
|
+
const text2 = firstReadableText(rawOutput.content, rawOutput.text, rawOutput.tool_result, rawOutput.raw_output, isRecord7(rawOutput.FileContent) ? rawOutput.FileContent : void 0, isRecord7(rawOutput.Content) ? rawOutput.Content : void 0);
|
|
23787
|
+
if (text2)
|
|
23788
|
+
return { text: text2 };
|
|
23667
23789
|
if (typeof rawOutput.match_count === "number" && Number.isFinite(rawOutput.match_count)) {
|
|
23668
23790
|
return { text: `found ${rawOutput.match_count} matches` };
|
|
23669
23791
|
}
|
|
@@ -23673,33 +23795,33 @@ function projectGrokToolOutput(content, rawOutput, limit = DEFAULT_GROK_TOOL_OUT
|
|
|
23673
23795
|
if (!Number.isSafeInteger(limit) || limit <= 0)
|
|
23674
23796
|
return {};
|
|
23675
23797
|
const fromRaw = rawOutputProjection(rawOutput);
|
|
23676
|
-
const
|
|
23798
|
+
const text2 = acpContentText(content) || fromRaw.text || "";
|
|
23677
23799
|
const parts = [];
|
|
23678
|
-
if (
|
|
23679
|
-
const truncated =
|
|
23680
|
-
parts.push({ type: "text", text: truncated ?
|
|
23800
|
+
if (text2.length > 0) {
|
|
23801
|
+
const truncated = text2.length > limit;
|
|
23802
|
+
parts.push({ type: "text", text: truncated ? text2.slice(0, limit) : text2 });
|
|
23681
23803
|
}
|
|
23682
|
-
parts.push(...acpContentImages(content, Math.max(0, limit -
|
|
23804
|
+
parts.push(...acpContentImages(content, Math.max(0, limit - text2.length)));
|
|
23683
23805
|
return {
|
|
23684
23806
|
...parts.length > 0 ? {
|
|
23685
23807
|
output: {
|
|
23686
23808
|
content: parts,
|
|
23687
|
-
...
|
|
23809
|
+
...text2.length > limit ? { truncated: true } : {}
|
|
23688
23810
|
}
|
|
23689
23811
|
} : {},
|
|
23690
23812
|
...fromRaw.exitCode !== void 0 ? { exitCode: fromRaw.exitCode } : {}
|
|
23691
23813
|
};
|
|
23692
23814
|
}
|
|
23693
23815
|
function grokToolOutputText(output) {
|
|
23694
|
-
return output?.content.filter((entry) => entry.type === "text").map(({ text }) =>
|
|
23816
|
+
return output?.content.filter((entry) => entry.type === "text").map(({ text: text2 }) => text2).join("") ?? "";
|
|
23695
23817
|
}
|
|
23696
23818
|
function applyGrokToolProjection(item, projection) {
|
|
23697
23819
|
if (item.type === "commandExecution") {
|
|
23698
|
-
const
|
|
23820
|
+
const text2 = grokToolOutputText(projection.output);
|
|
23699
23821
|
return {
|
|
23700
23822
|
...item,
|
|
23701
23823
|
...projection.output ? {
|
|
23702
|
-
output:
|
|
23824
|
+
output: text2,
|
|
23703
23825
|
outputTruncated: projection.output.truncated === true
|
|
23704
23826
|
} : {},
|
|
23705
23827
|
...projection.exitCode !== void 0 ? { exitCode: projection.exitCode } : {}
|
|
@@ -23826,8 +23948,8 @@ function grokNativeSubagentId(...candidates) {
|
|
|
23826
23948
|
};
|
|
23827
23949
|
const fromText = (pattern) => {
|
|
23828
23950
|
for (const candidate of candidates) {
|
|
23829
|
-
const
|
|
23830
|
-
const match =
|
|
23951
|
+
const text2 = extractText(candidate);
|
|
23952
|
+
const match = text2?.match(pattern);
|
|
23831
23953
|
if (match?.[1])
|
|
23832
23954
|
return match[1].trim();
|
|
23833
23955
|
}
|
|
@@ -23837,9 +23959,9 @@ function grokNativeSubagentId(...candidates) {
|
|
|
23837
23959
|
}
|
|
23838
23960
|
function grokSubagentResultSummary(...candidates) {
|
|
23839
23961
|
for (const candidate of candidates) {
|
|
23840
|
-
const
|
|
23841
|
-
if (
|
|
23842
|
-
return bounded(
|
|
23962
|
+
const text2 = extractText(candidate);
|
|
23963
|
+
if (text2)
|
|
23964
|
+
return bounded(text2, SUMMARY_LIMIT);
|
|
23843
23965
|
}
|
|
23844
23966
|
return void 0;
|
|
23845
23967
|
}
|
|
@@ -23876,14 +23998,14 @@ function grokSubagentEventFromUpdate(update) {
|
|
|
23876
23998
|
}
|
|
23877
23999
|
return null;
|
|
23878
24000
|
}
|
|
23879
|
-
function grokSubagentWaitSettlements(
|
|
23880
|
-
const ids = grokSubagentWaitIds(
|
|
23881
|
-
if (grokSubagentKill(
|
|
24001
|
+
function grokSubagentWaitSettlements(input2) {
|
|
24002
|
+
const ids = grokSubagentWaitIds(input2.name, input2.title, input2.rawInput);
|
|
24003
|
+
if (grokSubagentKill(input2.name, input2.title)) {
|
|
23882
24004
|
return ids.map((id2) => ({ id: id2, status: "interrupted" }));
|
|
23883
24005
|
}
|
|
23884
24006
|
if (ids.length === 0)
|
|
23885
24007
|
return [];
|
|
23886
|
-
const resultEntries = taskOutputResults(
|
|
24008
|
+
const resultEntries = taskOutputResults(input2.rawOutput);
|
|
23887
24009
|
if (resultEntries.length > 0) {
|
|
23888
24010
|
const settled = [];
|
|
23889
24011
|
for (const result of resultEntries) {
|
|
@@ -23896,10 +24018,10 @@ function grokSubagentWaitSettlements(input) {
|
|
|
23896
24018
|
}
|
|
23897
24019
|
return settled;
|
|
23898
24020
|
}
|
|
23899
|
-
const fromText = taskOutputTextSettlements(
|
|
24021
|
+
const fromText = taskOutputTextSettlements(input2.rawOutput, input2.content, ids);
|
|
23900
24022
|
if (fromText.length > 0)
|
|
23901
24023
|
return fromText;
|
|
23902
|
-
const overall = mapTaskStatus(taskOutputStatus(
|
|
24024
|
+
const overall = mapTaskStatus(taskOutputStatus(input2.rawOutput, input2.content));
|
|
23903
24025
|
if (!overall || overall === "running" || overall === "pending")
|
|
23904
24026
|
return [];
|
|
23905
24027
|
return ids.map((id2) => ({ id: id2, status: overall }));
|
|
@@ -23929,12 +24051,12 @@ function firstRecord(...values) {
|
|
|
23929
24051
|
return void 0;
|
|
23930
24052
|
}
|
|
23931
24053
|
function taskOutputTextSettlements(rawOutput, content, ids) {
|
|
23932
|
-
const
|
|
23933
|
-
if (!
|
|
24054
|
+
const text2 = extractText(content) ?? extractText(rawOutput);
|
|
24055
|
+
if (!text2)
|
|
23934
24056
|
return [];
|
|
23935
24057
|
const settled = [];
|
|
23936
24058
|
const pattern = /---\s*Task\s+(\S+)\s+\[(completed|failed|interrupted|cancelled|canceled)\]\s*---/gi;
|
|
23937
|
-
for (const match of
|
|
24059
|
+
for (const match of text2.matchAll(pattern)) {
|
|
23938
24060
|
const id2 = match[1]?.trim();
|
|
23939
24061
|
const status = mapTaskStatus(match[2]);
|
|
23940
24062
|
if (!id2 || !status || status === "running" || status === "pending")
|
|
@@ -23948,19 +24070,19 @@ function taskOutputTextSettlements(rawOutput, content, ids) {
|
|
|
23948
24070
|
function taskOutputStatus(rawOutput, content) {
|
|
23949
24071
|
if (isRecord8(rawOutput) && typeof rawOutput.status === "string")
|
|
23950
24072
|
return rawOutput.status;
|
|
23951
|
-
const
|
|
23952
|
-
if (!
|
|
24073
|
+
const text2 = extractText(content) ?? extractText(rawOutput);
|
|
24074
|
+
if (!text2)
|
|
23953
24075
|
return void 0;
|
|
23954
|
-
if (/<subagent_meta>|<subagent_result>/i.test(
|
|
24076
|
+
if (/<subagent_meta>|<subagent_result>/i.test(text2))
|
|
23955
24077
|
return "completed";
|
|
23956
|
-
if (/\bstatus["']?\s*[:=]\s*["']?completed/i.test(
|
|
24078
|
+
if (/\bstatus["']?\s*[:=]\s*["']?completed/i.test(text2))
|
|
23957
24079
|
return "completed";
|
|
23958
|
-
if (/\bstatus["']?\s*[:=]\s*["']?failed/i.test(
|
|
24080
|
+
if (/\bstatus["']?\s*[:=]\s*["']?failed/i.test(text2))
|
|
23959
24081
|
return "failed";
|
|
23960
|
-
if (/\bstatus["']?\s*[:=]\s*["']?(cancelled|canceled|interrupted)/i.test(
|
|
24082
|
+
if (/\bstatus["']?\s*[:=]\s*["']?(cancelled|canceled|interrupted)/i.test(text2)) {
|
|
23961
24083
|
return "interrupted";
|
|
23962
24084
|
}
|
|
23963
|
-
if (/\bstill running\b|\bstatus["']?\s*[:=]\s*["']?(running|pending|in_progress)/i.test(
|
|
24085
|
+
if (/\bstill running\b|\bstatus["']?\s*[:=]\s*["']?(running|pending|in_progress)/i.test(text2)) {
|
|
23964
24086
|
return "running";
|
|
23965
24087
|
}
|
|
23966
24088
|
return void 0;
|
|
@@ -23999,8 +24121,8 @@ function extractText(value, depth = 0) {
|
|
|
23999
24121
|
}
|
|
24000
24122
|
if (Array.isArray(value)) {
|
|
24001
24123
|
const parts = value.flatMap((entry) => {
|
|
24002
|
-
const
|
|
24003
|
-
return
|
|
24124
|
+
const text2 = extractText(entry, depth + 1);
|
|
24125
|
+
return text2 ? [text2] : [];
|
|
24004
24126
|
});
|
|
24005
24127
|
const joined = parts.join("\n").trim();
|
|
24006
24128
|
return joined.length > 0 ? joined : void 0;
|
|
@@ -24037,8 +24159,8 @@ function terminalOutcome(stopReason) {
|
|
|
24037
24159
|
}
|
|
24038
24160
|
var systemReminderPattern = /^\s*<system-reminder>[\s\S]*$/u;
|
|
24039
24161
|
var taskCompletedTurnKeyPattern = /^task-completed-/u;
|
|
24040
|
-
function isSyntheticGrokUserText(
|
|
24041
|
-
return systemReminderPattern.test(
|
|
24162
|
+
function isSyntheticGrokUserText(text2) {
|
|
24163
|
+
return systemReminderPattern.test(text2);
|
|
24042
24164
|
}
|
|
24043
24165
|
function isSyntheticGrokTurnKey(nativeTurnKey) {
|
|
24044
24166
|
return taskCompletedTurnKeyPattern.test(nativeTurnKey);
|
|
@@ -24068,7 +24190,7 @@ function parseGrokPromptIndex(checkpointId) {
|
|
|
24068
24190
|
function mapGrokReplay(replay, harnessId, sessionId, cwd, knownTurnRefs = [], toolOutputLimit = DEFAULT_GROK_TOOL_OUTPUT_LIMIT, sessionDirectory) {
|
|
24069
24191
|
const knownByNativeKey = new Map(knownTurnRefs.filter((ref) => ref.harnessId === harnessId && ref.nativeSessionId === sessionId).map((ref) => [ref.nativeTurnKey, ref]));
|
|
24070
24192
|
let turns = [];
|
|
24071
|
-
let
|
|
24193
|
+
let input2 = "";
|
|
24072
24194
|
let items = [];
|
|
24073
24195
|
let turnIndex = 0;
|
|
24074
24196
|
let messageIndex = 0;
|
|
@@ -24229,7 +24351,7 @@ function mapGrokReplay(replay, harnessId, sessionId, cwd, knownTurnRefs = [], to
|
|
|
24229
24351
|
items.push({ item: fileItem, outcome: { status: "succeeded" } });
|
|
24230
24352
|
};
|
|
24231
24353
|
const completeTurn = (outcome, terminalKey) => {
|
|
24232
|
-
if (
|
|
24354
|
+
if (input2.length === 0)
|
|
24233
24355
|
return;
|
|
24234
24356
|
const reconstructedKey = terminalKey ?? nativeTurnKey;
|
|
24235
24357
|
if (!reconstructedKey)
|
|
@@ -24255,7 +24377,7 @@ function mapGrokReplay(replay, harnessId, sessionId, cwd, knownTurnRefs = [], to
|
|
|
24255
24377
|
checkpointId: grokCheckpointId(currentPromptIndex),
|
|
24256
24378
|
formatVersion: 1
|
|
24257
24379
|
}),
|
|
24258
|
-
input: [{ type: "text", text:
|
|
24380
|
+
input: [{ type: "text", text: input2 }],
|
|
24259
24381
|
items,
|
|
24260
24382
|
outcome
|
|
24261
24383
|
});
|
|
@@ -24263,7 +24385,7 @@ function mapGrokReplay(replay, harnessId, sessionId, cwd, knownTurnRefs = [], to
|
|
|
24263
24385
|
messageIndex = 0;
|
|
24264
24386
|
nativeTurnKey = null;
|
|
24265
24387
|
currentPromptIndex = null;
|
|
24266
|
-
|
|
24388
|
+
input2 = "";
|
|
24267
24389
|
items = [];
|
|
24268
24390
|
};
|
|
24269
24391
|
for (const event of replay) {
|
|
@@ -24277,7 +24399,7 @@ function mapGrokReplay(replay, harnessId, sessionId, cwd, knownTurnRefs = [], to
|
|
|
24277
24399
|
nativeTurnKey = null;
|
|
24278
24400
|
nativePromptIndex = event.targetPromptIndex;
|
|
24279
24401
|
currentPromptIndex = null;
|
|
24280
|
-
|
|
24402
|
+
input2 = "";
|
|
24281
24403
|
items = [];
|
|
24282
24404
|
agent = null;
|
|
24283
24405
|
reasoning = null;
|
|
@@ -24290,7 +24412,7 @@ function mapGrokReplay(replay, harnessId, sessionId, cwd, knownTurnRefs = [], to
|
|
|
24290
24412
|
if (isHostTurnEvent(event))
|
|
24291
24413
|
continue;
|
|
24292
24414
|
if (isSyntheticGrokUserText(event.text)) {
|
|
24293
|
-
if (
|
|
24415
|
+
if (input2.length > 0) {
|
|
24294
24416
|
completeTurn({
|
|
24295
24417
|
status: "unknown",
|
|
24296
24418
|
reason: "Grok Native history has no terminal signal"
|
|
@@ -24299,17 +24421,17 @@ function mapGrokReplay(replay, harnessId, sessionId, cwd, knownTurnRefs = [], to
|
|
|
24299
24421
|
nativePromptIndex = (explicitPromptIndex(event) ?? nativePromptIndex) + 1;
|
|
24300
24422
|
continue;
|
|
24301
24423
|
}
|
|
24302
|
-
if (
|
|
24303
|
-
|
|
24424
|
+
if (input2.length > 0) {
|
|
24425
|
+
input2 += event.text;
|
|
24304
24426
|
continue;
|
|
24305
24427
|
}
|
|
24306
24428
|
currentPromptIndex = explicitPromptIndex(event) ?? nativePromptIndex;
|
|
24307
24429
|
nativePromptIndex = currentPromptIndex + 1;
|
|
24308
|
-
|
|
24430
|
+
input2 = event.text;
|
|
24309
24431
|
nativeTurnKey = userEventIdentity(event);
|
|
24310
24432
|
continue;
|
|
24311
24433
|
}
|
|
24312
|
-
if (
|
|
24434
|
+
if (input2.length === 0)
|
|
24313
24435
|
continue;
|
|
24314
24436
|
if (event.type === "turn.completed") {
|
|
24315
24437
|
if (isSyntheticGrokTurnKey(event.nativeTurnKey))
|
|
@@ -24485,16 +24607,16 @@ function isGrokMethodNotFound(error53) {
|
|
|
24485
24607
|
const message = error53 instanceof Error ? error53.message : String(error53);
|
|
24486
24608
|
return /method not found/iu.test(message);
|
|
24487
24609
|
}
|
|
24488
|
-
function buildGrokForkParams(
|
|
24610
|
+
function buildGrokForkParams(input2) {
|
|
24489
24611
|
return {
|
|
24490
|
-
sourceSessionId:
|
|
24491
|
-
sourceCwd:
|
|
24492
|
-
newCwd:
|
|
24493
|
-
targetPromptIndex:
|
|
24494
|
-
...
|
|
24495
|
-
...
|
|
24496
|
-
...
|
|
24497
|
-
...
|
|
24612
|
+
sourceSessionId: input2.sourceSessionId,
|
|
24613
|
+
sourceCwd: input2.sourceCwd,
|
|
24614
|
+
newCwd: input2.newCwd,
|
|
24615
|
+
targetPromptIndex: input2.targetPromptIndex,
|
|
24616
|
+
...input2.newSessionId ? { newSessionId: input2.newSessionId } : {},
|
|
24617
|
+
...input2.newModelId ? { newModelId: input2.newModelId } : {},
|
|
24618
|
+
...input2.sessionKind ? { sessionKind: input2.sessionKind } : {},
|
|
24619
|
+
...input2.sourceWorkspaceDir ? { sourceWorkspaceDir: input2.sourceWorkspaceDir } : {}
|
|
24498
24620
|
};
|
|
24499
24621
|
}
|
|
24500
24622
|
function parseGrokForkResponse(value) {
|
|
@@ -24545,10 +24667,10 @@ function comparableTurn(turn, cwds) {
|
|
|
24545
24667
|
...turn.model ? { model: turn.model } : {}
|
|
24546
24668
|
};
|
|
24547
24669
|
}
|
|
24548
|
-
async function readSnapshot(
|
|
24670
|
+
async function readSnapshot(input2, sessionId) {
|
|
24549
24671
|
let history;
|
|
24550
24672
|
try {
|
|
24551
|
-
history = await
|
|
24673
|
+
history = await input2.readHistory(input2.cwd, sessionId);
|
|
24552
24674
|
} catch {
|
|
24553
24675
|
return {
|
|
24554
24676
|
ok: false,
|
|
@@ -24562,7 +24684,7 @@ async function readSnapshot(input, sessionId) {
|
|
|
24562
24684
|
};
|
|
24563
24685
|
}
|
|
24564
24686
|
try {
|
|
24565
|
-
return { ok: true, value: mapGrokReplay(history,
|
|
24687
|
+
return { ok: true, value: mapGrokReplay(history, input2.harnessId, sessionId, input2.cwd) };
|
|
24566
24688
|
} catch {
|
|
24567
24689
|
return {
|
|
24568
24690
|
ok: false,
|
|
@@ -24570,16 +24692,16 @@ async function readSnapshot(input, sessionId) {
|
|
|
24570
24692
|
};
|
|
24571
24693
|
}
|
|
24572
24694
|
}
|
|
24573
|
-
async function forkGrokSession(
|
|
24574
|
-
const sourceRef = nativeSessionRefSchema.safeParse(
|
|
24575
|
-
const checkpoint = nativeCheckpointRefSchema.safeParse(
|
|
24576
|
-
if (!sourceRef.success || !checkpoint.success || sourceRef.data.harnessId !==
|
|
24695
|
+
async function forkGrokSession(input2) {
|
|
24696
|
+
const sourceRef = nativeSessionRefSchema.safeParse(input2.sourceRef);
|
|
24697
|
+
const checkpoint = nativeCheckpointRefSchema.safeParse(input2.checkpoint);
|
|
24698
|
+
if (!sourceRef.success || !checkpoint.success || sourceRef.data.harnessId !== input2.harnessId || checkpoint.data.harnessId !== input2.harnessId || checkpoint.data.nativeSessionId !== sourceRef.data.nativeSessionId) {
|
|
24577
24699
|
return {
|
|
24578
24700
|
ok: false,
|
|
24579
24701
|
error: error51("invalidRequest", "Grok Fork identity does not belong to the source Session")
|
|
24580
24702
|
};
|
|
24581
24703
|
}
|
|
24582
|
-
const located = await
|
|
24704
|
+
const located = await input2.locateSource(sourceRef.data.nativeSessionId);
|
|
24583
24705
|
if (!located) {
|
|
24584
24706
|
return {
|
|
24585
24707
|
ok: false,
|
|
@@ -24587,8 +24709,8 @@ async function forkGrokSession(input) {
|
|
|
24587
24709
|
};
|
|
24588
24710
|
}
|
|
24589
24711
|
const sourceCwd = path11.resolve(located.cwd);
|
|
24590
|
-
const targetCwd = path11.resolve(
|
|
24591
|
-
const source = await readSnapshot({ ...
|
|
24712
|
+
const targetCwd = path11.resolve(input2.cwd);
|
|
24713
|
+
const source = await readSnapshot({ ...input2, cwd: sourceCwd }, sourceRef.data.nativeSessionId);
|
|
24592
24714
|
if (!source.ok)
|
|
24593
24715
|
return source;
|
|
24594
24716
|
const boundaryIndex = source.value.turns.findIndex((turn) => turn.checkpoint?.checkpointId === checkpoint.data.checkpointId);
|
|
@@ -24602,7 +24724,7 @@ async function forkGrokSession(input) {
|
|
|
24602
24724
|
const sameCwd = sourceCwd === targetCwd;
|
|
24603
24725
|
let derivedSessionId;
|
|
24604
24726
|
try {
|
|
24605
|
-
const forked = await
|
|
24727
|
+
const forked = await input2.forkAndLoad(buildGrokForkParams({
|
|
24606
24728
|
sourceSessionId: sourceRef.data.nativeSessionId,
|
|
24607
24729
|
sourceCwd,
|
|
24608
24730
|
newCwd: targetCwd,
|
|
@@ -24611,7 +24733,7 @@ async function forkGrokSession(input) {
|
|
|
24611
24733
|
...!sameCwd ? { sourceWorkspaceDir: located.sourceWorkspaceDir ?? sourceCwd } : {}
|
|
24612
24734
|
}));
|
|
24613
24735
|
const derivedRef = nativeSessionRefSchema.safeParse({
|
|
24614
|
-
harnessId:
|
|
24736
|
+
harnessId: input2.harnessId,
|
|
24615
24737
|
nativeSessionId: forked.sessionId,
|
|
24616
24738
|
formatVersion: 1
|
|
24617
24739
|
});
|
|
@@ -24633,11 +24755,11 @@ async function forkGrokSession(input) {
|
|
|
24633
24755
|
};
|
|
24634
24756
|
}
|
|
24635
24757
|
const cleanup = async () => {
|
|
24636
|
-
await
|
|
24758
|
+
await input2.deleteSession(targetCwd, derivedSessionId).catch(() => void 0);
|
|
24637
24759
|
};
|
|
24638
24760
|
const [derived, sourceAfter] = await Promise.all([
|
|
24639
|
-
readSnapshot({ ...
|
|
24640
|
-
readSnapshot({ ...
|
|
24761
|
+
readSnapshot({ ...input2, cwd: targetCwd }, derivedSessionId),
|
|
24762
|
+
readSnapshot({ ...input2, cwd: sourceCwd }, sourceRef.data.nativeSessionId)
|
|
24641
24763
|
]);
|
|
24642
24764
|
if (!derived.ok) {
|
|
24643
24765
|
await cleanup();
|
|
@@ -24778,10 +24900,10 @@ function error52(code, message, retryable = false) {
|
|
|
24778
24900
|
function isRecord12(value) {
|
|
24779
24901
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
24780
24902
|
}
|
|
24781
|
-
function buildGrokRewindParams(
|
|
24903
|
+
function buildGrokRewindParams(input2) {
|
|
24782
24904
|
return {
|
|
24783
|
-
sessionId:
|
|
24784
|
-
targetPromptIndex:
|
|
24905
|
+
sessionId: input2.sessionId,
|
|
24906
|
+
targetPromptIndex: input2.targetPromptIndex,
|
|
24785
24907
|
force: true,
|
|
24786
24908
|
mode: "conversation_only"
|
|
24787
24909
|
};
|
|
@@ -24809,10 +24931,10 @@ function rewindPayload(payload) {
|
|
|
24809
24931
|
...rewindError !== void 0 ? { error: rewindError } : {}
|
|
24810
24932
|
};
|
|
24811
24933
|
}
|
|
24812
|
-
async function readSnapshot2(
|
|
24934
|
+
async function readSnapshot2(input2, sessionId) {
|
|
24813
24935
|
let history;
|
|
24814
24936
|
try {
|
|
24815
|
-
history = await
|
|
24937
|
+
history = await input2.readHistory(input2.cwd, sessionId);
|
|
24816
24938
|
} catch {
|
|
24817
24939
|
return {
|
|
24818
24940
|
ok: false,
|
|
@@ -24820,7 +24942,7 @@ async function readSnapshot2(input, sessionId) {
|
|
|
24820
24942
|
};
|
|
24821
24943
|
}
|
|
24822
24944
|
try {
|
|
24823
|
-
return { ok: true, value: mapGrokReplay(history,
|
|
24945
|
+
return { ok: true, value: mapGrokReplay(history, input2.harnessId, sessionId, input2.cwd) };
|
|
24824
24946
|
} catch {
|
|
24825
24947
|
return {
|
|
24826
24948
|
ok: false,
|
|
@@ -24828,15 +24950,15 @@ async function readSnapshot2(input, sessionId) {
|
|
|
24828
24950
|
};
|
|
24829
24951
|
}
|
|
24830
24952
|
}
|
|
24831
|
-
async function rewindGrokLastTurn(
|
|
24832
|
-
const sourceRef = nativeSessionRefSchema.safeParse(
|
|
24833
|
-
if (!sourceRef.success || sourceRef.data.harnessId !==
|
|
24953
|
+
async function rewindGrokLastTurn(input2) {
|
|
24954
|
+
const sourceRef = nativeSessionRefSchema.safeParse(input2.sourceRef);
|
|
24955
|
+
if (!sourceRef.success || sourceRef.data.harnessId !== input2.harnessId) {
|
|
24834
24956
|
return {
|
|
24835
24957
|
ok: false,
|
|
24836
24958
|
error: error52("invalidRequest", "Grok last-Turn Rewind identity does not belong to Grok")
|
|
24837
24959
|
};
|
|
24838
24960
|
}
|
|
24839
|
-
const located = await
|
|
24961
|
+
const located = await input2.locateSource(sourceRef.data.nativeSessionId);
|
|
24840
24962
|
if (!located) {
|
|
24841
24963
|
return {
|
|
24842
24964
|
ok: false,
|
|
@@ -24844,14 +24966,14 @@ async function rewindGrokLastTurn(input) {
|
|
|
24844
24966
|
};
|
|
24845
24967
|
}
|
|
24846
24968
|
const sourceCwd = path12.resolve(located.cwd);
|
|
24847
|
-
const targetCwd = path12.resolve(
|
|
24969
|
+
const targetCwd = path12.resolve(input2.cwd);
|
|
24848
24970
|
if (sourceCwd !== targetCwd) {
|
|
24849
24971
|
return {
|
|
24850
24972
|
ok: false,
|
|
24851
24973
|
error: error52("invalidRequest", "Grok last-Turn Rewind must stay in the source cwd")
|
|
24852
24974
|
};
|
|
24853
24975
|
}
|
|
24854
|
-
const source = await readSnapshot2({ ...
|
|
24976
|
+
const source = await readSnapshot2({ ...input2, cwd: sourceCwd }, sourceRef.data.nativeSessionId);
|
|
24855
24977
|
if (!source.ok)
|
|
24856
24978
|
return source;
|
|
24857
24979
|
const targetPromptIndex = resolveGrokLastTurnPromptIndex(source.value);
|
|
@@ -24863,7 +24985,7 @@ async function rewindGrokLastTurn(input) {
|
|
|
24863
24985
|
}
|
|
24864
24986
|
let sessionId;
|
|
24865
24987
|
try {
|
|
24866
|
-
const rewound = await
|
|
24988
|
+
const rewound = await input2.rewindAndLoad(buildGrokRewindParams({
|
|
24867
24989
|
sessionId: sourceRef.data.nativeSessionId,
|
|
24868
24990
|
targetPromptIndex
|
|
24869
24991
|
}));
|
|
@@ -24884,7 +25006,7 @@ async function rewindGrokLastTurn(input) {
|
|
|
24884
25006
|
error: error52("nativeFailure", message.includes("Rewind") ? message : "Grok Native Rewind failed", true)
|
|
24885
25007
|
};
|
|
24886
25008
|
}
|
|
24887
|
-
const derived = await readSnapshot2({ ...
|
|
25009
|
+
const derived = await readSnapshot2({ ...input2, cwd: targetCwd }, sessionId);
|
|
24888
25010
|
if (!derived.ok)
|
|
24889
25011
|
return derived;
|
|
24890
25012
|
const expectedKeys = source.value.turns.slice(0, -1).map((turn) => turn.nativeTurnRef.nativeTurnKey);
|
|
@@ -25179,8 +25301,8 @@ function classifyStartupError(error53) {
|
|
|
25179
25301
|
if (error53 instanceof GrokExecutableError) {
|
|
25180
25302
|
return new GrokTransportError("notInstalled", error53.message, { cause: error53 });
|
|
25181
25303
|
}
|
|
25182
|
-
const
|
|
25183
|
-
if (
|
|
25304
|
+
const text2 = errorText(error53).toLowerCase();
|
|
25305
|
+
if (text2.includes("auth_required") || text2.includes("authentication") || text2.includes("not logged in") || text2.includes("sign in")) {
|
|
25184
25306
|
return new GrokTransportError("authenticationRequired", "Grok CLI authentication is required", {
|
|
25185
25307
|
cause: error53
|
|
25186
25308
|
});
|
|
@@ -25510,21 +25632,21 @@ var GrokAcpTransport = class {
|
|
|
25510
25632
|
cwd: this.#options.cwd
|
|
25511
25633
|
}), this.#options.commandTimeoutMs, "Grok Session delete");
|
|
25512
25634
|
}
|
|
25513
|
-
async open(
|
|
25635
|
+
async open(input2) {
|
|
25514
25636
|
if (this.#sessionId || this.#closed)
|
|
25515
25637
|
throw new Error("Grok ACP Transport cannot be opened twice");
|
|
25516
25638
|
try {
|
|
25517
|
-
if (
|
|
25518
|
-
this.#startupModelId =
|
|
25639
|
+
if (input2.kind === "create")
|
|
25640
|
+
this.#startupModelId = input2.modelId;
|
|
25519
25641
|
const initialize = await this.#ensureInitialized();
|
|
25520
25642
|
const connection = this.#connection;
|
|
25521
25643
|
if (!connection)
|
|
25522
25644
|
throw new GrokTransportError("unavailable", "Grok ACP is unavailable");
|
|
25523
|
-
this.#replay =
|
|
25645
|
+
this.#replay = input2.kind === "resume" || input2.kind === "fork" || input2.kind === "rewind" ? [] : null;
|
|
25524
25646
|
let session;
|
|
25525
25647
|
let sessionId;
|
|
25526
|
-
if (
|
|
25527
|
-
const permissionMode = decodeGrokPermissionModeId(
|
|
25648
|
+
if (input2.kind === "create") {
|
|
25649
|
+
const permissionMode = decodeGrokPermissionModeId(input2.permissionModeId);
|
|
25528
25650
|
const created = await withTimeout(connection.newSession({
|
|
25529
25651
|
cwd: this.#options.cwd,
|
|
25530
25652
|
mcpServers: [],
|
|
@@ -25532,14 +25654,14 @@ var GrokAcpTransport = class {
|
|
|
25532
25654
|
}), this.#options.commandTimeoutMs, "Grok Session creation");
|
|
25533
25655
|
session = created;
|
|
25534
25656
|
sessionId = created.sessionId;
|
|
25535
|
-
} else if (
|
|
25657
|
+
} else if (input2.kind === "fork") {
|
|
25536
25658
|
const forked = await this.#forkSession({
|
|
25537
|
-
sourceSessionId:
|
|
25538
|
-
sourceCwd:
|
|
25659
|
+
sourceSessionId: input2.sourceSessionId,
|
|
25660
|
+
sourceCwd: input2.sourceCwd,
|
|
25539
25661
|
newCwd: this.#options.cwd,
|
|
25540
|
-
targetPromptIndex:
|
|
25541
|
-
...
|
|
25542
|
-
...
|
|
25662
|
+
targetPromptIndex: input2.targetPromptIndex,
|
|
25663
|
+
...input2.sessionKind ? { sessionKind: input2.sessionKind } : {},
|
|
25664
|
+
...input2.sourceWorkspaceDir ? { sourceWorkspaceDir: input2.sourceWorkspaceDir } : {}
|
|
25543
25665
|
});
|
|
25544
25666
|
try {
|
|
25545
25667
|
session = await withTimeout(connection.loadSession({
|
|
@@ -25552,18 +25674,18 @@ var GrokAcpTransport = class {
|
|
|
25552
25674
|
}
|
|
25553
25675
|
sessionId = forked.newSessionId;
|
|
25554
25676
|
} else {
|
|
25555
|
-
const permissionMode =
|
|
25677
|
+
const permissionMode = input2.kind === "resume" ? decodeGrokPermissionModeId(input2.permissionModeId) : void 0;
|
|
25556
25678
|
session = await withTimeout(connection.loadSession({
|
|
25557
25679
|
cwd: this.#options.cwd,
|
|
25558
25680
|
mcpServers: [],
|
|
25559
|
-
sessionId:
|
|
25681
|
+
sessionId: input2.sessionId,
|
|
25560
25682
|
...permissionMode ? { _meta: grokPermissionModeSessionMeta(permissionMode) } : {}
|
|
25561
25683
|
}), this.#options.commandTimeoutMs, "Grok Session load");
|
|
25562
|
-
sessionId =
|
|
25563
|
-
if (
|
|
25684
|
+
sessionId = input2.sessionId;
|
|
25685
|
+
if (input2.kind === "rewind") {
|
|
25564
25686
|
await this.#rewindSession({
|
|
25565
25687
|
sessionId,
|
|
25566
|
-
targetPromptIndex:
|
|
25688
|
+
targetPromptIndex: input2.targetPromptIndex,
|
|
25567
25689
|
force: true,
|
|
25568
25690
|
mode: "conversation_only"
|
|
25569
25691
|
});
|
|
@@ -25575,7 +25697,7 @@ var GrokAcpTransport = class {
|
|
|
25575
25697
|
this.#sessionId = sessionId;
|
|
25576
25698
|
const replay = this.#replay ?? [];
|
|
25577
25699
|
this.#replay = null;
|
|
25578
|
-
const signals =
|
|
25700
|
+
const signals = input2.kind === "resume" || input2.kind === "fork" || input2.kind === "rewind" ? await readNativeSignals(this.#options, sessionId) : void 0;
|
|
25579
25701
|
return {
|
|
25580
25702
|
initialize,
|
|
25581
25703
|
session,
|
|
@@ -25688,7 +25810,7 @@ var GrokAcpTransport = class {
|
|
|
25688
25810
|
this.#initialize = initialize;
|
|
25689
25811
|
return initialize;
|
|
25690
25812
|
}
|
|
25691
|
-
async runTurn(
|
|
25813
|
+
async runTurn(text2, onEvent, onPermission, onQuestion = async () => ({ outcome: "cancelled" })) {
|
|
25692
25814
|
const connection = this.#connection;
|
|
25693
25815
|
if (!connection || !this.#sessionId || this.#closed || this.#closing) {
|
|
25694
25816
|
throw new GrokTransportError("unavailable", "Grok ACP Session is unavailable");
|
|
@@ -25702,7 +25824,7 @@ var GrokAcpTransport = class {
|
|
|
25702
25824
|
try {
|
|
25703
25825
|
return await connection.prompt({
|
|
25704
25826
|
sessionId: this.#sessionId,
|
|
25705
|
-
prompt: [{ type: "text", text }]
|
|
25827
|
+
prompt: [{ type: "text", text: text2 }]
|
|
25706
25828
|
});
|
|
25707
25829
|
} finally {
|
|
25708
25830
|
await yieldToEventLoop();
|
|
@@ -25952,15 +26074,15 @@ function sessionImportTitle(value, maxLength = HARNESS_SESSION_IMPORT_TITLE_MAX_
|
|
|
25952
26074
|
return normalized;
|
|
25953
26075
|
return `${characters.slice(0, maxLength - 1).join("").trimEnd()}…`;
|
|
25954
26076
|
}
|
|
25955
|
-
function sessionImportCandidate(
|
|
25956
|
-
const time3 = typeof
|
|
26077
|
+
function sessionImportCandidate(input2) {
|
|
26078
|
+
const time3 = typeof input2.updatedAt === "number" ? input2.updatedAt : typeof input2.updatedAt === "string" ? Date.parse(input2.updatedAt) : Number.NaN;
|
|
25957
26079
|
const parsed = harnessSessionImportCandidateSchema.safeParse({
|
|
25958
|
-
nativeSessionId:
|
|
25959
|
-
cwd:
|
|
25960
|
-
title: typeof
|
|
26080
|
+
nativeSessionId: input2.nativeSessionId,
|
|
26081
|
+
cwd: input2.cwd,
|
|
26082
|
+
title: typeof input2.title === "string" && input2.title.trim().length > 0 ? input2.title : null,
|
|
25961
26083
|
updatedAt: Math.floor(time3),
|
|
25962
26084
|
// Unknown must stay unknown; only an explicit boolean is a native statement.
|
|
25963
|
-
running: typeof
|
|
26085
|
+
running: typeof input2.running === "boolean" ? input2.running : null
|
|
25964
26086
|
});
|
|
25965
26087
|
return parsed.success ? parsed.data : null;
|
|
25966
26088
|
}
|
|
@@ -26055,8 +26177,8 @@ async function firstUserText(file2, signal) {
|
|
|
26055
26177
|
const update = isRecord15(entry) && isRecord15(entry.params) ? entry.params.update : null;
|
|
26056
26178
|
if (!isRecord15(update) || update.sessionUpdate !== "user_message_chunk")
|
|
26057
26179
|
continue;
|
|
26058
|
-
const
|
|
26059
|
-
return typeof
|
|
26180
|
+
const text2 = isRecord15(update.content) ? update.content.text : null;
|
|
26181
|
+
return typeof text2 === "string" ? text2 : "";
|
|
26060
26182
|
}
|
|
26061
26183
|
return null;
|
|
26062
26184
|
} finally {
|
|
@@ -26241,50 +26363,50 @@ var GrokSubagentLifecycle = class {
|
|
|
26241
26363
|
nativeSubagentId(callId) {
|
|
26242
26364
|
return this.#delegations.get(callId)?.item.subagents[0]?.nativeSubagentId;
|
|
26243
26365
|
}
|
|
26244
|
-
start(turnId,
|
|
26245
|
-
if (this.#delegations.has(
|
|
26366
|
+
start(turnId, input2) {
|
|
26367
|
+
if (this.#delegations.has(input2.callId)) {
|
|
26246
26368
|
throw new Error("Grok Subagent delegation started more than once");
|
|
26247
26369
|
}
|
|
26248
|
-
this.#callIdByNativeId.set(
|
|
26249
|
-
if (
|
|
26250
|
-
this.#callIdByNativeId.set(
|
|
26370
|
+
this.#callIdByNativeId.set(input2.callId, input2.callId);
|
|
26371
|
+
if (input2.nativeSubagentId)
|
|
26372
|
+
this.#callIdByNativeId.set(input2.nativeSubagentId, input2.callId);
|
|
26251
26373
|
const subagent = {
|
|
26252
|
-
subagentId:
|
|
26253
|
-
...
|
|
26254
|
-
description:
|
|
26255
|
-
...
|
|
26256
|
-
...
|
|
26257
|
-
...
|
|
26258
|
-
background:
|
|
26374
|
+
subagentId: input2.nativeSubagentId ?? input2.callId,
|
|
26375
|
+
...input2.nativeSubagentId ? { nativeSubagentId: input2.nativeSubagentId } : {},
|
|
26376
|
+
description: input2.description,
|
|
26377
|
+
...input2.role ? { role: input2.role } : {},
|
|
26378
|
+
...input2.model ? { model: input2.model } : {},
|
|
26379
|
+
...input2.reasoningEffort ? { reasoningEffort: input2.reasoningEffort } : {},
|
|
26380
|
+
background: input2.background,
|
|
26259
26381
|
status: "running"
|
|
26260
26382
|
};
|
|
26261
26383
|
const item = {
|
|
26262
26384
|
type: "subagentDelegation",
|
|
26263
26385
|
itemId: this.#newItemId(),
|
|
26264
|
-
operation:
|
|
26265
|
-
...
|
|
26386
|
+
operation: input2.operation,
|
|
26387
|
+
...input2.prompt ? { prompt: input2.prompt } : {},
|
|
26266
26388
|
subagents: [subagent]
|
|
26267
26389
|
};
|
|
26268
|
-
this.#delegations.set(
|
|
26390
|
+
this.#delegations.set(input2.callId, { callId: input2.callId, item });
|
|
26269
26391
|
this.#emit({ type: "item.started", turnId, item });
|
|
26270
26392
|
this.#emitState(subagent);
|
|
26271
26393
|
return subagent;
|
|
26272
26394
|
}
|
|
26273
|
-
bindNativeId(turnId,
|
|
26395
|
+
bindNativeId(turnId, input2) {
|
|
26274
26396
|
for (const [callId, active2] of this.#delegations) {
|
|
26275
26397
|
const current = active2.item.subagents[0];
|
|
26276
26398
|
if (!current)
|
|
26277
26399
|
continue;
|
|
26278
|
-
if (current.nativeSubagentId ===
|
|
26279
|
-
return this.update(turnId, callId,
|
|
26400
|
+
if (current.nativeSubagentId === input2.nativeSubagentId) {
|
|
26401
|
+
return this.update(turnId, callId, input2);
|
|
26280
26402
|
}
|
|
26281
26403
|
}
|
|
26282
26404
|
for (const [callId, active2] of this.#delegations) {
|
|
26283
26405
|
const current = active2.item.subagents[0];
|
|
26284
26406
|
if (!current || current.nativeSubagentId)
|
|
26285
26407
|
continue;
|
|
26286
|
-
if (
|
|
26287
|
-
return this.update(turnId, callId,
|
|
26408
|
+
if (input2.description && current.description === input2.description) {
|
|
26409
|
+
return this.update(turnId, callId, input2);
|
|
26288
26410
|
}
|
|
26289
26411
|
}
|
|
26290
26412
|
return void 0;
|
|
@@ -26319,34 +26441,34 @@ var GrokSubagentLifecycle = class {
|
|
|
26319
26441
|
this.#emitState(subagent);
|
|
26320
26442
|
return subagent;
|
|
26321
26443
|
}
|
|
26322
|
-
completeSpawn(turnId, callId,
|
|
26444
|
+
completeSpawn(turnId, callId, input2) {
|
|
26323
26445
|
const active2 = this.#delegations.get(callId);
|
|
26324
|
-
const background =
|
|
26325
|
-
const keepRunning = !
|
|
26446
|
+
const background = input2.background ?? active2?.item.subagents[0]?.background ?? true;
|
|
26447
|
+
const keepRunning = !input2.failed && !input2.cancellationRequested && (background || active2?.item.operation === "send");
|
|
26326
26448
|
if (keepRunning) {
|
|
26327
26449
|
return this.update(turnId, callId, {
|
|
26328
26450
|
status: "running",
|
|
26329
|
-
...
|
|
26330
|
-
...
|
|
26451
|
+
...input2.nativeSubagentId ? { nativeSubagentId: input2.nativeSubagentId } : {},
|
|
26452
|
+
...input2.resultSummary ? { resultSummary: input2.resultSummary } : {}
|
|
26331
26453
|
});
|
|
26332
26454
|
}
|
|
26333
|
-
return this.complete(turnId, callId, { ...
|
|
26455
|
+
return this.complete(turnId, callId, { ...input2, keepRunning: false });
|
|
26334
26456
|
}
|
|
26335
|
-
completeByNativeId(turnId, nativeSubagentId,
|
|
26457
|
+
completeByNativeId(turnId, nativeSubagentId, input2) {
|
|
26336
26458
|
const callId = this.#callIdByNativeId.get(nativeSubagentId) ?? this.#callIdForNative(nativeSubagentId);
|
|
26337
26459
|
if (callId && this.#delegations.has(callId)) {
|
|
26338
|
-
return this.complete(turnId, callId, { ...
|
|
26460
|
+
return this.complete(turnId, callId, { ...input2, nativeSubagentId });
|
|
26339
26461
|
}
|
|
26340
|
-
const status =
|
|
26462
|
+
const status = input2.status ?? (input2.cancellationRequested ? "interrupted" : input2.failed ? "failed" : "completed");
|
|
26341
26463
|
this.#emit({
|
|
26342
26464
|
type: "subagent.state.changed",
|
|
26343
26465
|
nativeSubagentId,
|
|
26344
26466
|
status,
|
|
26345
|
-
...
|
|
26467
|
+
...input2.resultSummary ? { resultSummary: input2.resultSummary } : {}
|
|
26346
26468
|
});
|
|
26347
26469
|
return void 0;
|
|
26348
26470
|
}
|
|
26349
|
-
complete(turnId, callId,
|
|
26471
|
+
complete(turnId, callId, input2) {
|
|
26350
26472
|
const active2 = this.#delegations.get(callId);
|
|
26351
26473
|
if (!active2)
|
|
26352
26474
|
return void 0;
|
|
@@ -26354,15 +26476,15 @@ var GrokSubagentLifecycle = class {
|
|
|
26354
26476
|
const current = active2.item.subagents[0];
|
|
26355
26477
|
if (!current)
|
|
26356
26478
|
throw new Error("Grok Subagent delegation has no Agent state");
|
|
26357
|
-
const status =
|
|
26358
|
-
const nativeSubagentId =
|
|
26479
|
+
const status = input2.status ?? (input2.cancellationRequested ? "interrupted" : input2.failed ? "failed" : input2.keepRunning ? "running" : "completed");
|
|
26480
|
+
const nativeSubagentId = input2.nativeSubagentId ?? current.nativeSubagentId;
|
|
26359
26481
|
if (nativeSubagentId)
|
|
26360
26482
|
this.#callIdByNativeId.set(nativeSubagentId, callId);
|
|
26361
26483
|
const subagent = {
|
|
26362
26484
|
...current,
|
|
26363
26485
|
status,
|
|
26364
26486
|
...nativeSubagentId ? { nativeSubagentId, subagentId: nativeSubagentId } : {},
|
|
26365
|
-
...
|
|
26487
|
+
...input2.resultSummary ? { resultSummary: input2.resultSummary } : {}
|
|
26366
26488
|
};
|
|
26367
26489
|
const item = { ...active2.item, subagents: [subagent] };
|
|
26368
26490
|
this.#emit({
|
|
@@ -26371,7 +26493,7 @@ var GrokSubagentLifecycle = class {
|
|
|
26371
26493
|
itemId: item.itemId,
|
|
26372
26494
|
update: { type: "subagents.replace", subagents: item.subagents }
|
|
26373
26495
|
});
|
|
26374
|
-
const outcome =
|
|
26496
|
+
const outcome = input2.cancellationRequested ? { status: "cancelled", reason: "Cancelled by user" } : input2.failed ? { status: "failed", error: subagentFailure() } : { status: "succeeded" };
|
|
26375
26497
|
this.#emit({ type: "item.completed", turnId, snapshot: { item, outcome } });
|
|
26376
26498
|
this.#emitState(subagent);
|
|
26377
26499
|
return subagent;
|
|
@@ -26524,18 +26646,18 @@ function selectAccessToken(auth, now) {
|
|
|
26524
26646
|
}
|
|
26525
26647
|
return null;
|
|
26526
26648
|
}
|
|
26527
|
-
async function fetchGrokAccount(
|
|
26649
|
+
async function fetchGrokAccount(input2 = {}) {
|
|
26528
26650
|
try {
|
|
26529
|
-
const environment =
|
|
26651
|
+
const environment = input2.environment ?? process.env;
|
|
26530
26652
|
if ([environment.XAI_API_KEY, environment.GROK_API_KEY, environment.GROK_TOKEN].some((value) => value?.trim()))
|
|
26531
26653
|
return null;
|
|
26532
|
-
const now =
|
|
26654
|
+
const now = input2.now ?? /* @__PURE__ */ new Date();
|
|
26533
26655
|
const authPath = path15.join(grokHome2(environment), "auth.json");
|
|
26534
|
-
const raw =
|
|
26656
|
+
const raw = input2.readAuthFile ? await input2.readAuthFile(authPath) : await readFile5(authPath, "utf8");
|
|
26535
26657
|
const token = selectAccessToken(JSON.parse(raw), now);
|
|
26536
26658
|
if (!token)
|
|
26537
26659
|
return null;
|
|
26538
|
-
const fetchImpl =
|
|
26660
|
+
const fetchImpl = input2.fetch ?? fetch;
|
|
26539
26661
|
const request = (url2, timeoutMs) => fetchImpl(url2, {
|
|
26540
26662
|
method: "GET",
|
|
26541
26663
|
headers: {
|
|
@@ -26543,10 +26665,10 @@ async function fetchGrokAccount(input = {}) {
|
|
|
26543
26665
|
"x-xai-token-auth": "xai-grok-cli",
|
|
26544
26666
|
Accept: "application/json"
|
|
26545
26667
|
},
|
|
26546
|
-
signal:
|
|
26668
|
+
signal: input2.signal ? AbortSignal.any([input2.signal, AbortSignal.timeout(timeoutMs)]) : AbortSignal.timeout(timeoutMs)
|
|
26547
26669
|
});
|
|
26548
26670
|
const credits = request(GROK_CREDITS_ENDPOINT, REQUEST_TIMEOUT_MS);
|
|
26549
|
-
const plan =
|
|
26671
|
+
const plan = input2.includePlan === false ? Promise.resolve(void 0) : request(GROK_SETTINGS_ENDPOINT, input2.planTimeoutMs ?? PLAN_TIMEOUT_MS).then(async (response2) => response2.ok ? parseGrokPlan(await response2.json()) : void 0).catch(() => void 0);
|
|
26550
26672
|
const response = await credits;
|
|
26551
26673
|
if (!response.ok)
|
|
26552
26674
|
return null;
|
|
@@ -26569,15 +26691,15 @@ async function fetchGrokAccount(input = {}) {
|
|
|
26569
26691
|
return null;
|
|
26570
26692
|
}
|
|
26571
26693
|
}
|
|
26572
|
-
async function fetchGrokCredits(
|
|
26573
|
-
const account = await fetchGrokAccount({ ...
|
|
26694
|
+
async function fetchGrokCredits(input2 = {}) {
|
|
26695
|
+
const account = await fetchGrokAccount({ ...input2, includePlan: false });
|
|
26574
26696
|
if (!account?.credits)
|
|
26575
26697
|
return null;
|
|
26576
26698
|
const { credits } = account;
|
|
26577
26699
|
return {
|
|
26578
26700
|
usedPercent: credits.usedPercent,
|
|
26579
26701
|
periodType: credits.periodType === "weekly" || credits.periodType === "monthly" ? credits.periodType : "unknown",
|
|
26580
|
-
fetchedAt: (
|
|
26702
|
+
fetchedAt: (input2.now ?? /* @__PURE__ */ new Date()).toISOString(),
|
|
26581
26703
|
...credits.resetsAt ? { resetsAt: credits.resetsAt } : {},
|
|
26582
26704
|
...credits.productUsage ? { productUsage: credits.productUsage } : {}
|
|
26583
26705
|
};
|
|
@@ -27093,8 +27215,8 @@ var GrokHarnessSession = class {
|
|
|
27093
27215
|
}
|
|
27094
27216
|
};
|
|
27095
27217
|
}
|
|
27096
|
-
const
|
|
27097
|
-
if (
|
|
27218
|
+
const text2 = command.input.map(({ text: text3 }) => text3).join("\n");
|
|
27219
|
+
if (text2.length === 0) {
|
|
27098
27220
|
return {
|
|
27099
27221
|
ok: false,
|
|
27100
27222
|
error: {
|
|
@@ -27136,7 +27258,7 @@ var GrokHarnessSession = class {
|
|
|
27136
27258
|
};
|
|
27137
27259
|
this.#active = active2;
|
|
27138
27260
|
this.#event({ type: "turn.started", turnId: command.turnId });
|
|
27139
|
-
void this.#transport.runTurn(
|
|
27261
|
+
void this.#transport.runTurn(text2, (event) => this.#handleEvent(active2, event), (request) => this.#requestPermission(active2, request), (request) => this.#active === active2 && this.#phase === "open" && !active2.cancellationRequested ? active2.questions.ask(request) : Promise.resolve({ outcome: "cancelled" })).finally(() => active2.questions.cancel()).then((response) => this.#settleFromHistory(active2, terminalOutcome2(response, active2.cancellationRequested), response), (error53) => this.#settleFromHistory(active2, {
|
|
27140
27262
|
status: "failed",
|
|
27141
27263
|
error: normalizeError(error53, "nativeFailure")
|
|
27142
27264
|
}));
|
|
@@ -27548,7 +27670,7 @@ var GrokHarnessSession = class {
|
|
|
27548
27670
|
if (usage)
|
|
27549
27671
|
this.#publishUsage(usage, active2.command.turnId);
|
|
27550
27672
|
}
|
|
27551
|
-
#appendAgent(active2,
|
|
27673
|
+
#appendAgent(active2, text2, messageId) {
|
|
27552
27674
|
const identity2 = messageId ?? "agent";
|
|
27553
27675
|
if (active2.agentMessageId !== identity2) {
|
|
27554
27676
|
this.#completeReasoning(active2, { status: "succeeded" });
|
|
@@ -27564,7 +27686,7 @@ var GrokHarnessSession = class {
|
|
|
27564
27686
|
active2.agentMedia = new LocalMediaMarkdownStream(this.#mediaRoots);
|
|
27565
27687
|
this.#event({ type: "item.started", turnId: active2.command.turnId, item: active2.agent });
|
|
27566
27688
|
}
|
|
27567
|
-
const delta = active2.agentMedia?.append(
|
|
27689
|
+
const delta = active2.agentMedia?.append(text2) ?? "";
|
|
27568
27690
|
this.#publishAgent(active2, delta);
|
|
27569
27691
|
}
|
|
27570
27692
|
#publishAgent(active2, delta) {
|
|
@@ -27578,7 +27700,7 @@ var GrokHarnessSession = class {
|
|
|
27578
27700
|
update: { type: "text.append", text: delta }
|
|
27579
27701
|
});
|
|
27580
27702
|
}
|
|
27581
|
-
#appendReasoning(active2,
|
|
27703
|
+
#appendReasoning(active2, text2, messageId) {
|
|
27582
27704
|
const identity2 = messageId ?? "thought";
|
|
27583
27705
|
if (active2.reasoningMessageId !== identity2) {
|
|
27584
27706
|
this.#completeReasoning(active2, { status: "succeeded" });
|
|
@@ -27592,12 +27714,12 @@ var GrokHarnessSession = class {
|
|
|
27592
27714
|
};
|
|
27593
27715
|
this.#event({ type: "item.started", turnId: active2.command.turnId, item: active2.reasoning });
|
|
27594
27716
|
}
|
|
27595
|
-
active2.reasoning = { ...active2.reasoning, text: active2.reasoning.text +
|
|
27717
|
+
active2.reasoning = { ...active2.reasoning, text: active2.reasoning.text + text2 };
|
|
27596
27718
|
this.#event({
|
|
27597
27719
|
type: "item.updated",
|
|
27598
27720
|
turnId: active2.command.turnId,
|
|
27599
27721
|
itemId: active2.reasoning.itemId,
|
|
27600
|
-
update: { type: "text.append", text }
|
|
27722
|
+
update: { type: "text.append", text: text2 }
|
|
27601
27723
|
});
|
|
27602
27724
|
}
|
|
27603
27725
|
#createSubagents() {
|
|
@@ -27955,8 +28077,8 @@ var GrokAdapter = class {
|
|
|
27955
28077
|
sessionImport;
|
|
27956
28078
|
usageStatistics;
|
|
27957
28079
|
subagents = {
|
|
27958
|
-
readSnapshot: async (
|
|
27959
|
-
if (
|
|
28080
|
+
readSnapshot: async (input2) => {
|
|
28081
|
+
if (input2.parent.harnessId !== this.harnessId || input2.nativeSubagentId.trim().length === 0) {
|
|
27960
28082
|
return {
|
|
27961
28083
|
ok: false,
|
|
27962
28084
|
error: {
|
|
@@ -27967,16 +28089,16 @@ var GrokAdapter = class {
|
|
|
27967
28089
|
};
|
|
27968
28090
|
}
|
|
27969
28091
|
try {
|
|
27970
|
-
const location = await locateGrokNativeSession(this.#environment ? { environment: this.#environment } : {},
|
|
27971
|
-
const cwd = location?.cwd ??
|
|
27972
|
-
const history = await readGrokNativeHistory(this.#environment ? { cwd, environment: this.#environment } : { cwd },
|
|
28092
|
+
const location = await locateGrokNativeSession(this.#environment ? { environment: this.#environment } : {}, input2.nativeSubagentId);
|
|
28093
|
+
const cwd = location?.cwd ?? input2.cwd;
|
|
28094
|
+
const history = await readGrokNativeHistory(this.#environment ? { cwd, environment: this.#environment } : { cwd }, input2.nativeSubagentId);
|
|
27973
28095
|
return {
|
|
27974
28096
|
ok: true,
|
|
27975
28097
|
value: mapGrokReplay(
|
|
27976
28098
|
history,
|
|
27977
28099
|
this.harnessId,
|
|
27978
28100
|
// Host Subagent records keep the parent Native Session identity.
|
|
27979
|
-
|
|
28101
|
+
input2.parent.nativeSessionId,
|
|
27980
28102
|
cwd,
|
|
27981
28103
|
[],
|
|
27982
28104
|
this.#toolOutputLimit
|
|
@@ -28008,7 +28130,7 @@ var GrokAdapter = class {
|
|
|
28008
28130
|
randomUUID,
|
|
28009
28131
|
createTransport: (transportOptions) => new GrokAcpTransport({ ...options, ...transportOptions })
|
|
28010
28132
|
};
|
|
28011
|
-
this.#fetchCredits = this.#dependencies.fetchCredits ?? ((
|
|
28133
|
+
this.#fetchCredits = this.#dependencies.fetchCredits ?? ((input2) => fetchGrokCredits(input2.environment ? { environment: input2.environment } : this.#environment ? { environment: this.#environment } : {}));
|
|
28012
28134
|
}
|
|
28013
28135
|
async inspectAccount() {
|
|
28014
28136
|
if (this.#closePromise)
|
|
@@ -28049,11 +28171,11 @@ var GrokAdapter = class {
|
|
|
28049
28171
|
return this.#credits;
|
|
28050
28172
|
}
|
|
28051
28173
|
#inspectionGeneration = 0;
|
|
28052
|
-
async inspect(
|
|
28174
|
+
async inspect(input2 = {}) {
|
|
28053
28175
|
if (this.#closePromise)
|
|
28054
28176
|
return { status: "unavailable", error: invalidState("Grok Adapter is closed") };
|
|
28055
|
-
const cwd = path16.resolve(
|
|
28056
|
-
if (
|
|
28177
|
+
const cwd = path16.resolve(input2.cwd ?? process.cwd());
|
|
28178
|
+
if (input2.refresh) {
|
|
28057
28179
|
this.#inspectionCache.clear();
|
|
28058
28180
|
this.#inspectionGeneration++;
|
|
28059
28181
|
}
|
|
@@ -28101,15 +28223,15 @@ var GrokAdapter = class {
|
|
|
28101
28223
|
};
|
|
28102
28224
|
}
|
|
28103
28225
|
}
|
|
28104
|
-
async open(
|
|
28226
|
+
async open(input2) {
|
|
28105
28227
|
if (this.#closePromise)
|
|
28106
28228
|
return { ok: false, error: invalidState("Grok Adapter is closed") };
|
|
28107
|
-
if (
|
|
28229
|
+
if (input2.cwd.length === 0)
|
|
28108
28230
|
return {
|
|
28109
28231
|
ok: false,
|
|
28110
28232
|
error: { code: "invalidRequest", message: "Grok Adapter requires cwd", retryable: false }
|
|
28111
28233
|
};
|
|
28112
|
-
const requestedPermissionModeId =
|
|
28234
|
+
const requestedPermissionModeId = input2.kind === "create" ? input2.permissionModeId ?? (input2.executionPolicy === "unattended-full-access" ? harnessPermissionModeIdSchema.parse("always-approve") : GROK_DEFAULT_PERMISSION_MODE_ID) : input2.kind === "resume" ? input2.permissionModeId ?? GROK_DEFAULT_PERMISSION_MODE_ID : GROK_DEFAULT_PERMISSION_MODE_ID;
|
|
28113
28235
|
try {
|
|
28114
28236
|
decodeGrokPermissionModeId(requestedPermissionModeId);
|
|
28115
28237
|
} catch {
|
|
@@ -28122,8 +28244,8 @@ var GrokAdapter = class {
|
|
|
28122
28244
|
}
|
|
28123
28245
|
};
|
|
28124
28246
|
}
|
|
28125
|
-
const cwd = path16.resolve(
|
|
28126
|
-
const parsedRef =
|
|
28247
|
+
const cwd = path16.resolve(input2.cwd);
|
|
28248
|
+
const parsedRef = input2.kind === "resume" ? nativeSessionRefSchema.safeParse(input2.nativeRef) : null;
|
|
28127
28249
|
if (parsedRef && (!parsedRef.success || parsedRef.data.harnessId !== this.harnessId)) {
|
|
28128
28250
|
return {
|
|
28129
28251
|
ok: false,
|
|
@@ -28135,13 +28257,13 @@ var GrokAdapter = class {
|
|
|
28135
28257
|
};
|
|
28136
28258
|
}
|
|
28137
28259
|
let session = null;
|
|
28138
|
-
const transport = this.#createTransport(cwd, (error53) => session?.handleTransportFault(error53),
|
|
28260
|
+
const transport = this.#createTransport(cwd, (error53) => session?.handleTransportFault(error53), input2.environment);
|
|
28139
28261
|
let sourceConfiguration;
|
|
28140
28262
|
let initialPermissionModeId = requestedPermissionModeId;
|
|
28141
28263
|
try {
|
|
28142
28264
|
let opened;
|
|
28143
|
-
if (
|
|
28144
|
-
const sourceRef = nativeSessionRefSchema.safeParse(
|
|
28265
|
+
if (input2.kind === "rollbackLastTurn") {
|
|
28266
|
+
const sourceRef = nativeSessionRefSchema.safeParse(input2.sourceRef);
|
|
28145
28267
|
if (!sourceRef.success || sourceRef.data.harnessId !== this.harnessId) {
|
|
28146
28268
|
await transport.close().catch(() => void 0);
|
|
28147
28269
|
return {
|
|
@@ -28174,14 +28296,14 @@ var GrokAdapter = class {
|
|
|
28174
28296
|
await transport.close().catch(() => void 0);
|
|
28175
28297
|
return rewound;
|
|
28176
28298
|
}
|
|
28177
|
-
} else if (
|
|
28178
|
-
const sourceSession = [...this.#sessions].find((entry) =>
|
|
28299
|
+
} else if (input2.kind === "fork") {
|
|
28300
|
+
const sourceSession = [...this.#sessions].find((entry) => input2.sourceRef.harnessId === this.harnessId && entry.initialState.nativeRef?.nativeSessionId === input2.sourceRef.nativeSessionId);
|
|
28179
28301
|
sourceConfiguration = sourceSession?.currentConfiguration();
|
|
28180
28302
|
const forked = await forkGrokSession({
|
|
28181
|
-
checkpoint:
|
|
28303
|
+
checkpoint: input2.checkpoint,
|
|
28182
28304
|
cwd,
|
|
28183
28305
|
harnessId: this.harnessId,
|
|
28184
|
-
sourceRef:
|
|
28306
|
+
sourceRef: input2.sourceRef,
|
|
28185
28307
|
locateSource: (sessionId) => transport.locateSession(sessionId),
|
|
28186
28308
|
readHistory: (historyCwd, sessionId) => transport.readHistory(sessionId, historyCwd),
|
|
28187
28309
|
forkAndLoad: async (params) => {
|
|
@@ -28209,7 +28331,7 @@ var GrokAdapter = class {
|
|
|
28209
28331
|
} : {
|
|
28210
28332
|
kind: "create",
|
|
28211
28333
|
permissionModeId: requestedPermissionModeId,
|
|
28212
|
-
...
|
|
28334
|
+
...input2.kind === "create" && input2.model ? { modelId: input2.model.id } : {}
|
|
28213
28335
|
});
|
|
28214
28336
|
}
|
|
28215
28337
|
if (!opened) {
|
|
@@ -28218,7 +28340,7 @@ var GrokAdapter = class {
|
|
|
28218
28340
|
ok: false,
|
|
28219
28341
|
error: {
|
|
28220
28342
|
code: "nativeFailure",
|
|
28221
|
-
message:
|
|
28343
|
+
message: input2.kind === "rollbackLastTurn" ? "Grok Native Rewind did not open a Session" : "Grok Native Fork did not open a Session",
|
|
28222
28344
|
retryable: true
|
|
28223
28345
|
}
|
|
28224
28346
|
};
|
|
@@ -28230,8 +28352,8 @@ var GrokAdapter = class {
|
|
|
28230
28352
|
const nativeModelId = modelState.currentModel.id;
|
|
28231
28353
|
const nativeThinkingOptionId = modelState.currentThinkingOptionId;
|
|
28232
28354
|
const retainedConfiguration = sourceConfiguration;
|
|
28233
|
-
if ((
|
|
28234
|
-
const operation =
|
|
28355
|
+
if ((input2.kind === "rollbackLastTurn" || input2.kind === "fork") && retainedConfiguration) {
|
|
28356
|
+
const operation = input2.kind === "rollbackLastTurn" ? "Rewind" : "Fork";
|
|
28235
28357
|
initialPermissionModeId = retainedConfiguration.permissionModeId ?? GROK_DEFAULT_PERMISSION_MODE_ID;
|
|
28236
28358
|
const catalogModel = modelState.catalog.models.find(({ ref }) => ref.id === retainedConfiguration.model.id);
|
|
28237
28359
|
if (!catalogModel) {
|
|
@@ -28249,9 +28371,9 @@ var GrokAdapter = class {
|
|
|
28249
28371
|
}
|
|
28250
28372
|
}
|
|
28251
28373
|
}
|
|
28252
|
-
if (
|
|
28253
|
-
const selectedModel =
|
|
28254
|
-
const selectedThinking =
|
|
28374
|
+
if (input2.kind === "create") {
|
|
28375
|
+
const selectedModel = input2.model ?? modelState.currentModel;
|
|
28376
|
+
const selectedThinking = input2.thinkingOptionId ?? modelState.currentThinkingOptionId;
|
|
28255
28377
|
const catalogModel = modelState.catalog.models.find(({ ref }) => ref.id === selectedModel.id);
|
|
28256
28378
|
if (!catalogModel)
|
|
28257
28379
|
throw new GrokTransportError("protocolError", "Requested Grok Model is unavailable");
|
|
@@ -28266,7 +28388,7 @@ var GrokAdapter = class {
|
|
|
28266
28388
|
delete modelState.currentThinkingOptionId;
|
|
28267
28389
|
}
|
|
28268
28390
|
}
|
|
28269
|
-
const savedModel =
|
|
28391
|
+
const savedModel = input2.kind === "resume" && !sessionModelState && input2.model ? modelState.catalog.models.find(({ ref }) => ref.id === input2.model?.id) : void 0;
|
|
28270
28392
|
if (savedModel) {
|
|
28271
28393
|
modelState.currentModel = savedModel.ref;
|
|
28272
28394
|
const thinking = modelState.currentThinkingOptionId;
|
|
@@ -28286,18 +28408,18 @@ var GrokAdapter = class {
|
|
|
28286
28408
|
}
|
|
28287
28409
|
await transport.setPermissionMode(initialPermissionModeId);
|
|
28288
28410
|
const history = await transport.getHistory();
|
|
28289
|
-
let initialUsage =
|
|
28411
|
+
let initialUsage = input2.kind === "resume" || input2.kind === "fork" || input2.kind === "rollbackLastTurn" ? combineUsage(sessionUsageFromHistory(history), usageFromSignals(opened.signals)) : null;
|
|
28290
28412
|
if (contextWindow !== void 0 && initialUsage?.contextUsedTokens !== void 0) {
|
|
28291
28413
|
initialUsage = combineUsage(initialUsage, { contextWindowTokens: contextWindow });
|
|
28292
28414
|
}
|
|
28293
|
-
const environment =
|
|
28415
|
+
const environment = input2.environment ?? this.#environment;
|
|
28294
28416
|
const sessionDirectory = grokNativeSessionDirectory(environment ? { cwd, environment } : { cwd }, opened.sessionId);
|
|
28295
28417
|
const openedSession = new GrokHarnessSession(cwd, transport, opened, modelState, () => this.#sessions.delete(openedSession), {
|
|
28296
28418
|
closeTimeoutMs: this.#closeTimeoutMs,
|
|
28297
28419
|
history,
|
|
28298
28420
|
initialUsage,
|
|
28299
28421
|
initialPermissionModeId,
|
|
28300
|
-
...
|
|
28422
|
+
...input2.kind === "resume" && input2.knownTurnRefs ? { knownTurnRefs: input2.knownTurnRefs } : {},
|
|
28301
28423
|
randomUUID: this.#dependencies.randomUUID,
|
|
28302
28424
|
refreshCredits: () => this.refreshCredits(),
|
|
28303
28425
|
sessionDirectory,
|