@codexhost/cli-linux-arm64 0.23.0 → 0.24.0
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 +1565 -1805
- package/app/console-web.js +5786 -1600
- package/app/desktop-controller.mjs +13104 -2842
- package/app/host-runtime.mjs +50518 -51753
- package/app/plugins/antigravity/plugin.mjs +1932 -1148
- package/app/plugins/claude-code/plugin.mjs +1676 -1218
- package/app/plugins/codebuddy/plugin.mjs +1266 -850
- package/app/plugins/codex-usage/plugin.mjs +916 -737
- package/app/plugins/copilot/plugin.mjs +838 -640
- package/app/plugins/cursor-cli/plugin.mjs +1058 -747
- package/app/plugins/deepseek-harness/plugin.mjs +1302 -1070
- package/app/plugins/devin/plugin.mjs +949 -752
- package/app/plugins/grok/plugin.mjs +1132 -964
- package/app/plugins/hermes/plugin.mjs +1084 -905
- package/app/plugins/kimi-code/plugin.mjs +977 -804
- package/app/plugins/kiro-cli/plugin.mjs +951 -758
- package/app/plugins/omp/plugin.mjs +1408 -1169
- package/app/plugins/opencode/plugin.mjs +1385 -1142
- package/app/plugins/pi/plugin.mjs +1515 -1287
- package/app/plugins/qoder/plugin.mjs +861 -676
- package/app/plugins/qoder-cn/plugin.mjs +861 -676
- package/app/plugins/qwen-code/plugin.mjs +1060 -888
- package/app/plugins/workbuddy/plugin.mjs +1272 -856
- package/app/plugins/zcode/plugin.mjs +1529 -880
- package/app/renderer-extension.js +11568 -7827
- package/app/web/assets/index-CTCFIQbU.css +1 -0
- package/app/web/assets/index-IvFk9KT-.js +203 -0
- package/app/web/codexhost-settings.js +4472 -36194
- package/app/web/index.html +2 -2
- package/app/web/plugins/deepseek-ai__dsh-api-remotes/client.js +1 -1
- package/app/web/plugins/deepseek-ai__dsh-api-session-controller/client.js +69 -69
- package/app/web/plugins/deepseek-ai__dsh-client-ui-approval/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 +75 -64
- package/app/web/plugins/deepseek-ai__dsh-client-ui-conversation/client.js +19 -16
- package/app/web/plugins/deepseek-ai__dsh-client-ui-input-trigger/client.js +1 -1
- package/app/web/plugins/deepseek-ai__dsh-client-ui-layout/client.js +2 -2
- package/app/web/plugins/deepseek-ai__dsh-client-ui-model-selection/client.js +2 -2
- package/app/web/plugins/deepseek-ai__dsh-client-ui-settings-general/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-documentpreview/client.js +9 -9
- package/app/web/plugins/deepseek-ai__dsh-client-ui-sidebar-right/client.js +1 -1
- package/app/web/plugins/deepseek-ai__dsh-client-ui-theme/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-user-questions/client.js +3 -3
- package/app/web/plugins/deepseek-ai__dsh-client-ui-workspace/client.js +7 -7
- package/app/web/sw.js +8 -1
- package/app/web-modules/server.mjs +2682 -5540
- package/bin/codexhost +0 -0
- package/libexec/codexhost-shim +0 -0
- package/libexec/codexhost-updater +0 -0
- package/package.json +1 -1
- package/app/web/assets/index-DJW4bmyx.css +0 -1
- package/app/web/assets/index-Dyh1KzAB.js +0 -201
|
@@ -32,10 +32,10 @@ function executableExtensions(command, platform, environment) {
|
|
|
32
32
|
return [""];
|
|
33
33
|
return (environmentValue(environment, "PATHEXT") ?? ".COM;.EXE;.BAT;.CMD").split(";").map((extension) => extension.trim()).filter(Boolean);
|
|
34
34
|
}
|
|
35
|
-
function isExecutableFile(
|
|
35
|
+
function isExecutableFile(filePath2, platform) {
|
|
36
36
|
try {
|
|
37
|
-
fs.accessSync(
|
|
38
|
-
return fs.statSync(
|
|
37
|
+
fs.accessSync(filePath2, platform === "win32" ? fs.constants.F_OK : fs.constants.X_OK);
|
|
38
|
+
return fs.statSync(filePath2).isFile();
|
|
39
39
|
} catch {
|
|
40
40
|
return false;
|
|
41
41
|
}
|
|
@@ -1625,8 +1625,8 @@ function cleanEnum(obj) {
|
|
|
1625
1625
|
return Number.isNaN(Number.parseInt(k, 10));
|
|
1626
1626
|
}).map((el) => el[1]);
|
|
1627
1627
|
}
|
|
1628
|
-
function base64ToUint8Array(
|
|
1629
|
-
const binaryString = atob(
|
|
1628
|
+
function base64ToUint8Array(base644) {
|
|
1629
|
+
const binaryString = atob(base644);
|
|
1630
1630
|
const bytes = new Uint8Array(binaryString.length);
|
|
1631
1631
|
for (let i = 0; i < binaryString.length; i++) {
|
|
1632
1632
|
bytes[i] = binaryString.charCodeAt(i);
|
|
@@ -1641,9 +1641,9 @@ function uint8ArrayToBase64(bytes) {
|
|
|
1641
1641
|
return btoa(binaryString);
|
|
1642
1642
|
}
|
|
1643
1643
|
function base64urlToUint8Array(base64url3) {
|
|
1644
|
-
const
|
|
1645
|
-
const padding = "=".repeat((4 -
|
|
1646
|
-
return base64ToUint8Array(
|
|
1644
|
+
const base644 = base64url3.replace(/-/g, "+").replace(/_/g, "/");
|
|
1645
|
+
const padding = "=".repeat((4 - base644.length % 4) % 4);
|
|
1646
|
+
return base64ToUint8Array(base644 + padding);
|
|
1647
1647
|
}
|
|
1648
1648
|
function uint8ArrayToBase64url(bytes) {
|
|
1649
1649
|
return uint8ArrayToBase64(bytes).replace(/\+/g, "-").replace(/\//g, "_").replace(/=/g, "");
|
|
@@ -3009,8 +3009,8 @@ var $ZodBase64 = /* @__PURE__ */ $constructor("$ZodBase64", (inst, def) => {
|
|
|
3009
3009
|
function isValidBase64URL(data) {
|
|
3010
3010
|
if (!base64url.test(data))
|
|
3011
3011
|
return false;
|
|
3012
|
-
const
|
|
3013
|
-
const padded =
|
|
3012
|
+
const base644 = data.replace(/[-_]/g, (c) => c === "-" ? "+" : "/");
|
|
3013
|
+
const padded = base644.padEnd(Math.ceil(base644.length / 4) * 4, "=");
|
|
3014
3014
|
return isValidBase64(padded);
|
|
3015
3015
|
}
|
|
3016
3016
|
var $ZodBase64URL = /* @__PURE__ */ $constructor("$ZodBase64URL", (inst, def) => {
|
|
@@ -3464,42 +3464,42 @@ var $ZodObjectJIT = /* @__PURE__ */ $constructor("$ZodObjectJIT", (inst, def) =>
|
|
|
3464
3464
|
}
|
|
3465
3465
|
doc.write(`const newResult = {};`);
|
|
3466
3466
|
for (const key of normalized.keys) {
|
|
3467
|
-
const
|
|
3467
|
+
const id2 = ids[key];
|
|
3468
3468
|
const k = esc(key);
|
|
3469
3469
|
const schema = shape[key];
|
|
3470
3470
|
const isOptionalIn = schema?._zod?.optin === "optional";
|
|
3471
3471
|
const isOptionalOut = schema?._zod?.optout === "optional";
|
|
3472
|
-
doc.write(`const ${
|
|
3472
|
+
doc.write(`const ${id2} = ${parseStr(key)};`);
|
|
3473
3473
|
if (isOptionalIn && isOptionalOut) {
|
|
3474
3474
|
doc.write(`
|
|
3475
|
-
if (${
|
|
3475
|
+
if (${id2}.issues.length) {
|
|
3476
3476
|
if (${k} in input) {
|
|
3477
|
-
payload.issues = payload.issues.concat(${
|
|
3477
|
+
payload.issues = payload.issues.concat(${id2}.issues.map(iss => ({
|
|
3478
3478
|
...iss,
|
|
3479
3479
|
path: iss.path ? [${k}, ...iss.path] : [${k}]
|
|
3480
3480
|
})));
|
|
3481
3481
|
}
|
|
3482
3482
|
}
|
|
3483
3483
|
|
|
3484
|
-
if (${
|
|
3484
|
+
if (${id2}.value === undefined) {
|
|
3485
3485
|
if (${k} in input) {
|
|
3486
3486
|
newResult[${k}] = undefined;
|
|
3487
3487
|
}
|
|
3488
3488
|
} else {
|
|
3489
|
-
newResult[${k}] = ${
|
|
3489
|
+
newResult[${k}] = ${id2}.value;
|
|
3490
3490
|
}
|
|
3491
3491
|
|
|
3492
3492
|
`);
|
|
3493
3493
|
} else if (!isOptionalIn) {
|
|
3494
3494
|
doc.write(`
|
|
3495
|
-
const ${
|
|
3496
|
-
if (${
|
|
3497
|
-
payload.issues = payload.issues.concat(${
|
|
3495
|
+
const ${id2}_present = ${k} in input;
|
|
3496
|
+
if (${id2}.issues.length) {
|
|
3497
|
+
payload.issues = payload.issues.concat(${id2}.issues.map(iss => ({
|
|
3498
3498
|
...iss,
|
|
3499
3499
|
path: iss.path ? [${k}, ...iss.path] : [${k}]
|
|
3500
3500
|
})));
|
|
3501
3501
|
}
|
|
3502
|
-
if (!${
|
|
3502
|
+
if (!${id2}_present && !${id2}.issues.length) {
|
|
3503
3503
|
payload.issues.push({
|
|
3504
3504
|
code: "invalid_type",
|
|
3505
3505
|
expected: "nonoptional",
|
|
@@ -3508,30 +3508,30 @@ var $ZodObjectJIT = /* @__PURE__ */ $constructor("$ZodObjectJIT", (inst, def) =>
|
|
|
3508
3508
|
});
|
|
3509
3509
|
}
|
|
3510
3510
|
|
|
3511
|
-
if (${
|
|
3512
|
-
if (${
|
|
3511
|
+
if (${id2}_present) {
|
|
3512
|
+
if (${id2}.value === undefined) {
|
|
3513
3513
|
newResult[${k}] = undefined;
|
|
3514
3514
|
} else {
|
|
3515
|
-
newResult[${k}] = ${
|
|
3515
|
+
newResult[${k}] = ${id2}.value;
|
|
3516
3516
|
}
|
|
3517
3517
|
}
|
|
3518
3518
|
|
|
3519
3519
|
`);
|
|
3520
3520
|
} else {
|
|
3521
3521
|
doc.write(`
|
|
3522
|
-
if (${
|
|
3523
|
-
payload.issues = payload.issues.concat(${
|
|
3522
|
+
if (${id2}.issues.length) {
|
|
3523
|
+
payload.issues = payload.issues.concat(${id2}.issues.map(iss => ({
|
|
3524
3524
|
...iss,
|
|
3525
3525
|
path: iss.path ? [${k}, ...iss.path] : [${k}]
|
|
3526
3526
|
})));
|
|
3527
3527
|
}
|
|
3528
3528
|
|
|
3529
|
-
if (${
|
|
3529
|
+
if (${id2}.value === undefined) {
|
|
3530
3530
|
if (${k} in input) {
|
|
3531
3531
|
newResult[${k}] = undefined;
|
|
3532
3532
|
}
|
|
3533
3533
|
} else {
|
|
3534
|
-
newResult[${k}] = ${
|
|
3534
|
+
newResult[${k}] = ${id2}.value;
|
|
3535
3535
|
}
|
|
3536
3536
|
|
|
3537
3537
|
`);
|
|
@@ -11863,26 +11863,26 @@ function extractDefs(ctx, schema) {
|
|
|
11863
11863
|
throw new Error("Unprocessed schema. This is a bug in Zod.");
|
|
11864
11864
|
const idToSchema = /* @__PURE__ */ new Map();
|
|
11865
11865
|
for (const entry of ctx.seen.entries()) {
|
|
11866
|
-
const
|
|
11867
|
-
if (
|
|
11868
|
-
const existing = idToSchema.get(
|
|
11866
|
+
const id2 = ctx.metadataRegistry.get(entry[0])?.id;
|
|
11867
|
+
if (id2) {
|
|
11868
|
+
const existing = idToSchema.get(id2);
|
|
11869
11869
|
if (existing && existing !== entry[0]) {
|
|
11870
|
-
throw new Error(`Duplicate schema id "${
|
|
11870
|
+
throw new Error(`Duplicate schema id "${id2}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);
|
|
11871
11871
|
}
|
|
11872
|
-
idToSchema.set(
|
|
11872
|
+
idToSchema.set(id2, entry[0]);
|
|
11873
11873
|
}
|
|
11874
11874
|
}
|
|
11875
11875
|
const makeURI = (entry) => {
|
|
11876
11876
|
const defsSegment = ctx.target === "draft-2020-12" ? "$defs" : "definitions";
|
|
11877
11877
|
if (ctx.external) {
|
|
11878
11878
|
const externalId = ctx.external.registry.get(entry[0])?.id;
|
|
11879
|
-
const uriGenerator = ctx.external.uri ?? ((
|
|
11879
|
+
const uriGenerator = ctx.external.uri ?? ((id3) => id3);
|
|
11880
11880
|
if (externalId) {
|
|
11881
11881
|
return { ref: uriGenerator(externalId) };
|
|
11882
11882
|
}
|
|
11883
|
-
const
|
|
11884
|
-
entry[1].defId =
|
|
11885
|
-
return { defId:
|
|
11883
|
+
const id2 = entry[1].defId ?? entry[1].schema.id ?? `schema${ctx.counter++}`;
|
|
11884
|
+
entry[1].defId = id2;
|
|
11885
|
+
return { defId: id2, ref: `${uriGenerator("__shared")}#/${defsSegment}/${id2}` };
|
|
11886
11886
|
}
|
|
11887
11887
|
if (entry[1] === root) {
|
|
11888
11888
|
return { ref: "#" };
|
|
@@ -11930,8 +11930,8 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
11930
11930
|
continue;
|
|
11931
11931
|
}
|
|
11932
11932
|
}
|
|
11933
|
-
const
|
|
11934
|
-
if (
|
|
11933
|
+
const id2 = ctx.metadataRegistry.get(entry[0])?.id;
|
|
11934
|
+
if (id2) {
|
|
11935
11935
|
extractToDef(entry);
|
|
11936
11936
|
continue;
|
|
11937
11937
|
}
|
|
@@ -12027,10 +12027,10 @@ function finalize(ctx, schema) {
|
|
|
12027
12027
|
} else {
|
|
12028
12028
|
}
|
|
12029
12029
|
if (ctx.external?.uri) {
|
|
12030
|
-
const
|
|
12031
|
-
if (!
|
|
12030
|
+
const id2 = ctx.external.registry.get(schema)?.id;
|
|
12031
|
+
if (!id2)
|
|
12032
12032
|
throw new Error("Schema is missing an `id` property");
|
|
12033
|
-
result.$id = ctx.external.uri(
|
|
12033
|
+
result.$id = ctx.external.uri(id2);
|
|
12034
12034
|
}
|
|
12035
12035
|
Object.assign(result, root.def ?? root.schema);
|
|
12036
12036
|
const rootMetaId = ctx.metadataRegistry.get(schema)?.id;
|
|
@@ -12190,9 +12190,9 @@ var numberProcessor = (schema, ctx, _json, _params) => {
|
|
|
12190
12190
|
json2.type = "number";
|
|
12191
12191
|
const exMin = typeof exclusiveMinimum === "number" && exclusiveMinimum >= (minimum ?? Number.NEGATIVE_INFINITY);
|
|
12192
12192
|
const exMax = typeof exclusiveMaximum === "number" && exclusiveMaximum <= (maximum ?? Number.POSITIVE_INFINITY);
|
|
12193
|
-
const
|
|
12193
|
+
const legacy2 = ctx.target === "draft-04" || ctx.target === "openapi-3.0";
|
|
12194
12194
|
if (exMin) {
|
|
12195
|
-
if (
|
|
12195
|
+
if (legacy2) {
|
|
12196
12196
|
json2.minimum = exclusiveMinimum;
|
|
12197
12197
|
json2.exclusiveMinimum = true;
|
|
12198
12198
|
} else {
|
|
@@ -12202,7 +12202,7 @@ var numberProcessor = (schema, ctx, _json, _params) => {
|
|
|
12202
12202
|
json2.minimum = minimum;
|
|
12203
12203
|
}
|
|
12204
12204
|
if (exMax) {
|
|
12205
|
-
if (
|
|
12205
|
+
if (legacy2) {
|
|
12206
12206
|
json2.maximum = exclusiveMaximum;
|
|
12207
12207
|
json2.exclusiveMaximum = true;
|
|
12208
12208
|
} else {
|
|
@@ -13064,7 +13064,7 @@ var safeDecodeAsync2 = /* @__PURE__ */ _safeDecodeAsync(ZodRealError);
|
|
|
13064
13064
|
|
|
13065
13065
|
// ../../../node_modules/zod/v4/classic/schemas.js
|
|
13066
13066
|
var _installedGroups = /* @__PURE__ */ new WeakMap();
|
|
13067
|
-
function _installLazyMethods(inst, group,
|
|
13067
|
+
function _installLazyMethods(inst, group, methods3) {
|
|
13068
13068
|
const proto = Object.getPrototypeOf(inst);
|
|
13069
13069
|
let installed = _installedGroups.get(proto);
|
|
13070
13070
|
if (!installed) {
|
|
@@ -13074,8 +13074,8 @@ function _installLazyMethods(inst, group, methods2) {
|
|
|
13074
13074
|
if (installed.has(group))
|
|
13075
13075
|
return;
|
|
13076
13076
|
installed.add(group);
|
|
13077
|
-
for (const key in
|
|
13078
|
-
const fn =
|
|
13077
|
+
for (const key in methods3) {
|
|
13078
|
+
const fn = methods3[key];
|
|
13079
13079
|
Object.defineProperty(proto, key, {
|
|
13080
13080
|
configurable: true,
|
|
13081
13081
|
enumerable: false,
|
|
@@ -14886,87 +14886,6 @@ function date4(params) {
|
|
|
14886
14886
|
// ../../../node_modules/zod/v4/classic/external.js
|
|
14887
14887
|
config(en_default());
|
|
14888
14888
|
|
|
14889
|
-
// ../../shared-contracts/dist/ids.js
|
|
14890
|
-
var opaqueIdSchema = external_exports.string().refine((value) => value.trim().length > 0, {
|
|
14891
|
-
message: "Identifier must not be empty or whitespace"
|
|
14892
|
-
});
|
|
14893
|
-
var harnessIdSchema = opaqueIdSchema.brand();
|
|
14894
|
-
var hostThreadIdSchema = opaqueIdSchema.brand();
|
|
14895
|
-
var hostTurnIdSchema = opaqueIdSchema.brand();
|
|
14896
|
-
var hostItemIdSchema = opaqueIdSchema.brand();
|
|
14897
|
-
var hostInteractionIdSchema = opaqueIdSchema.brand();
|
|
14898
|
-
|
|
14899
|
-
// ../../shared-contracts/dist/harness-plugins.js
|
|
14900
|
-
var HARNESS_PLUGIN_MANIFEST_MAX_BYTES = 32 * 1024;
|
|
14901
|
-
var HARNESS_PLUGIN_ICON_MAX_BYTES = 128 * 1024;
|
|
14902
|
-
var HARNESS_PLUGIN_LIMIT = 128;
|
|
14903
|
-
var installedPluginIdSchema = external_exports.string().min(1).max(128).regex(/^[a-z][a-z0-9]*(?:[._-][a-z0-9]+)*$/u);
|
|
14904
|
-
var installedHarnessPluginIdSchema = installedPluginIdSchema.pipe(harnessIdSchema);
|
|
14905
|
-
var harnessPluginIdSchema = installedHarnessPluginIdSchema.refine((id) => id !== "codex", "The official Codex identity is reserved");
|
|
14906
|
-
var pluginRelativeResourceSchema = external_exports.string().min(1).max(512).refine((value) => !/[\\\u0000:#?]/u.test(value) && !value.startsWith("/") && !value.split("/").some((part) => part === ".." || part === ""), "Plugin resources must be relative paths inside the plugin");
|
|
14907
|
-
var documentationUrlSchema = external_exports.url().refine((value) => /^https:\/\/[^/?#@]+(?:[/?#]|$)/iu.test(value), "Plugin documentation links must be credential-free HTTPS URLs");
|
|
14908
|
-
var localizedTextSchema = external_exports.object({ en: external_exports.string().max(4096), "zh-CN": external_exports.string().max(4096).optional() }).strict();
|
|
14909
|
-
var harnessInstallationGuideSchema = external_exports.object({
|
|
14910
|
-
commands: external_exports.array(external_exports.object({ terminal: external_exports.string().max(256), command: external_exports.string().max(4096) }).strict()).max(8),
|
|
14911
|
-
before: localizedTextSchema.optional(),
|
|
14912
|
-
after: localizedTextSchema.optional(),
|
|
14913
|
-
downloads: external_exports.array(external_exports.object({ label: external_exports.string().max(128), url: documentationUrlSchema }).strict()).max(8).optional()
|
|
14914
|
-
}).strict();
|
|
14915
|
-
var pluginPresentationShape = {
|
|
14916
|
-
id: installedHarnessPluginIdSchema,
|
|
14917
|
-
name: external_exports.string().trim().min(1).max(128),
|
|
14918
|
-
version: external_exports.string().min(1).max(128),
|
|
14919
|
-
/** Capability-only plugin; omitted for existing session-capable plugins. */
|
|
14920
|
-
kind: external_exports.literal("usage").optional(),
|
|
14921
|
-
/** Original image styling or bounded vector paths; never arbitrary CSS/SVG markup. */
|
|
14922
|
-
iconStyle: external_exports.object({
|
|
14923
|
-
vector: external_exports.object({
|
|
14924
|
-
viewBox: external_exports.string().max(128).regex(/^-?\d+(?:\.\d+)?(?: +-?\d+(?:\.\d+)?){3}$/u),
|
|
14925
|
-
color: external_exports.string().regex(/^(?:currentColor|#[a-f0-9]{6})$/iu),
|
|
14926
|
-
paths: external_exports.array(external_exports.object({
|
|
14927
|
-
d: external_exports.string().min(1).max(32768).regex(/^[MmLlHhVvCcSsQqTtAaZz\d.,+eE\s-]+$/u),
|
|
14928
|
-
fillRule: external_exports.enum(["evenodd", "nonzero"]).optional(),
|
|
14929
|
-
fill: external_exports.string().regex(/^(?:currentColor|#[a-f0-9]{6})$/iu).optional()
|
|
14930
|
-
}).strict()).min(1).max(32)
|
|
14931
|
-
}).strict().optional(),
|
|
14932
|
-
background: external_exports.string().regex(/^#[a-f0-9]{6}$/iu).optional(),
|
|
14933
|
-
borderRadius: external_exports.number().min(0).max(50).optional(),
|
|
14934
|
-
paddingRatio: external_exports.number().min(0).max(0.25).optional()
|
|
14935
|
-
}).strict().optional(),
|
|
14936
|
-
installation: harnessInstallationGuideSchema.optional(),
|
|
14937
|
-
notice: localizedTextSchema.optional(),
|
|
14938
|
-
/** The factory accepts a persisted local entrypoint through its construction context. */
|
|
14939
|
-
launchCommand: external_exports.literal(true).optional(),
|
|
14940
|
-
links: external_exports.object({
|
|
14941
|
-
website: documentationUrlSchema.optional(),
|
|
14942
|
-
documentation: documentationUrlSchema.optional(),
|
|
14943
|
-
installation: documentationUrlSchema.optional()
|
|
14944
|
-
}).strict().optional()
|
|
14945
|
-
};
|
|
14946
|
-
var harnessPluginManifestSchema = external_exports.object({
|
|
14947
|
-
manifestVersion: external_exports.literal(1),
|
|
14948
|
-
...pluginPresentationShape,
|
|
14949
|
-
adapterApiVersion: external_exports.number().int().positive(),
|
|
14950
|
-
entry: pluginRelativeResourceSchema,
|
|
14951
|
-
icon: pluginRelativeResourceSchema.optional()
|
|
14952
|
-
}).strict();
|
|
14953
|
-
var harnessPluginIconSchema = external_exports.string().max(Math.ceil(HARNESS_PLUGIN_ICON_MAX_BYTES / 3) * 4 + 64).regex(/^data:image\/(?:png|jpeg|webp|svg\+xml);base64,[A-Za-z0-9+/]+={0,2}$/u);
|
|
14954
|
-
var harnessPluginDescriptorSchema = external_exports.object({
|
|
14955
|
-
...pluginPresentationShape,
|
|
14956
|
-
icon: harnessPluginIconSchema.optional()
|
|
14957
|
-
}).strict();
|
|
14958
|
-
var harnessPluginListParamsSchema = external_exports.object({}).strict();
|
|
14959
|
-
var harnessPluginListResultSchema = external_exports.object({
|
|
14960
|
-
plugins: external_exports.array(harnessPluginDescriptorSchema.extend({ id: harnessPluginIdSchema })).max(HARNESS_PLUGIN_LIMIT)
|
|
14961
|
-
}).strict();
|
|
14962
|
-
var harnessPluginConfigurationSchema = external_exports.object({
|
|
14963
|
-
version: external_exports.literal(1),
|
|
14964
|
-
enabled: external_exports.array(installedHarnessPluginIdSchema).max(HARNESS_PLUGIN_LIMIT)
|
|
14965
|
-
}).strict().refine((value) => new Set(value.enabled).size === value.enabled.length, {
|
|
14966
|
-
message: "Enabled plugin IDs must be unique",
|
|
14967
|
-
path: ["enabled"]
|
|
14968
|
-
});
|
|
14969
|
-
|
|
14970
14889
|
// ../../shared-contracts/dist/json-value.js
|
|
14971
14890
|
function rejectExplicitUndefined(keys) {
|
|
14972
14891
|
return (value, context) => {
|
|
@@ -15026,403 +14945,73 @@ var jsonValueSchema = nonCircularSchema.pipe(recursiveJsonValueSchema);
|
|
|
15026
14945
|
var jsonArraySchema = nonCircularSchema.pipe(external_exports.array(recursiveJsonValueSchema));
|
|
15027
14946
|
var jsonObjectSchema = nonCircularSchema.pipe(external_exports.record(external_exports.string(), recursiveJsonValueSchema));
|
|
15028
14947
|
|
|
15029
|
-
// ../../shared-contracts/dist/
|
|
15030
|
-
var
|
|
15031
|
-
|
|
15032
|
-
|
|
15033
|
-
|
|
15034
|
-
|
|
15035
|
-
|
|
15036
|
-
|
|
15037
|
-
|
|
15038
|
-
|
|
15039
|
-
|
|
15040
|
-
|
|
15041
|
-
var
|
|
15042
|
-
var
|
|
15043
|
-
var
|
|
15044
|
-
|
|
15045
|
-
|
|
15046
|
-
|
|
15047
|
-
|
|
15048
|
-
|
|
15049
|
-
|
|
15050
|
-
var
|
|
15051
|
-
"
|
|
15052
|
-
|
|
15053
|
-
|
|
15054
|
-
|
|
15055
|
-
|
|
15056
|
-
|
|
15057
|
-
|
|
15058
|
-
|
|
15059
|
-
|
|
15060
|
-
|
|
15061
|
-
|
|
15062
|
-
|
|
15063
|
-
|
|
15064
|
-
|
|
15065
|
-
|
|
15066
|
-
|
|
15067
|
-
|
|
15068
|
-
|
|
15069
|
-
|
|
14948
|
+
// ../../shared-contracts/dist/errors.js
|
|
14949
|
+
var codexhostErrorSchema = external_exports.strictObject({
|
|
14950
|
+
code: external_exports.string().min(1),
|
|
14951
|
+
message: external_exports.string().min(1),
|
|
14952
|
+
retryable: external_exports.boolean(),
|
|
14953
|
+
diagnostic: external_exports.string().min(1).optional(),
|
|
14954
|
+
stage: external_exports.string().min(1).optional(),
|
|
14955
|
+
durationMs: external_exports.number().int().nonnegative().optional(),
|
|
14956
|
+
stderrTail: external_exports.string().min(1).optional()
|
|
14957
|
+
}).superRefine(rejectExplicitUndefined(["diagnostic", "stage", "durationMs", "stderrTail"]));
|
|
14958
|
+
|
|
14959
|
+
// ../../shared-contracts/dist/harness-presentation.js
|
|
14960
|
+
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((text) => text.trim().length > 0);
|
|
14962
|
+
var harnessLocalizationsSchema = external_exports.record(localeSchema, external_exports.object({
|
|
14963
|
+
label: displayText(256).optional(),
|
|
14964
|
+
description: displayText(1024).optional()
|
|
14965
|
+
}).strict()).refine((entries) => Object.keys(entries).length <= 16, "Too many locales");
|
|
14966
|
+
var harnessLocalizedTextSchema = external_exports.record(localeSchema, displayText(4096)).refine((entries) => typeof entries.en === "string", "English fallback is required").refine((entries) => Object.keys(entries).length <= 16, "Too many locales");
|
|
14967
|
+
|
|
14968
|
+
// ../../shared-contracts/dist/ids.js
|
|
14969
|
+
var opaqueIdSchema = external_exports.string().refine((value) => value.trim().length > 0, {
|
|
14970
|
+
message: "Identifier must not be empty or whitespace"
|
|
14971
|
+
});
|
|
14972
|
+
var harnessIdSchema = opaqueIdSchema.brand();
|
|
14973
|
+
var hostThreadIdSchema = opaqueIdSchema.brand();
|
|
14974
|
+
var hostTurnIdSchema = opaqueIdSchema.brand();
|
|
14975
|
+
var hostItemIdSchema = opaqueIdSchema.brand();
|
|
14976
|
+
var hostInteractionIdSchema = opaqueIdSchema.brand();
|
|
14977
|
+
|
|
14978
|
+
// ../../shared-contracts/dist/harness-permission-modes.js
|
|
14979
|
+
var HARNESS_PERMISSION_MODE_ID_MAX_LENGTH = 128;
|
|
14980
|
+
var HARNESS_PERMISSION_MODE_LABEL_MAX_LENGTH = 256;
|
|
14981
|
+
var HARNESS_PERMISSION_MODE_DESCRIPTION_MAX_LENGTH = 1024;
|
|
14982
|
+
var HARNESS_PERMISSION_MODE_CATALOG_MAX_LENGTH = 32;
|
|
14983
|
+
var nonBlankTextSchema = external_exports.string().refine((value) => value.trim().length > 0, {
|
|
14984
|
+
message: "Value must not be empty or whitespace"
|
|
14985
|
+
});
|
|
14986
|
+
var harnessPermissionModeIdSchema = nonBlankTextSchema.max(HARNESS_PERMISSION_MODE_ID_MAX_LENGTH).regex(/^[A-Za-z0-9._~:-]+$/u, "Permission Mode ID must use transport-safe characters").brand();
|
|
14987
|
+
var harnessPermissionModeSchema = external_exports.object({
|
|
14988
|
+
id: harnessPermissionModeIdSchema,
|
|
14989
|
+
label: nonBlankTextSchema.max(HARNESS_PERMISSION_MODE_LABEL_MAX_LENGTH),
|
|
14990
|
+
description: nonBlankTextSchema.max(HARNESS_PERMISSION_MODE_DESCRIPTION_MAX_LENGTH).optional(),
|
|
14991
|
+
dangerous: external_exports.boolean().optional(),
|
|
14992
|
+
localizations: harnessLocalizationsSchema.optional()
|
|
14993
|
+
}).strict();
|
|
14994
|
+
var harnessPermissionModeCatalogSchema = external_exports.object({
|
|
14995
|
+
modes: external_exports.array(harnessPermissionModeSchema).min(1).max(HARNESS_PERMISSION_MODE_CATALOG_MAX_LENGTH),
|
|
14996
|
+
defaultModeId: harnessPermissionModeIdSchema
|
|
14997
|
+
}).strict().superRefine((catalog, context) => {
|
|
14998
|
+
const ids = /* @__PURE__ */ new Set();
|
|
14999
|
+
for (const [index, mode] of catalog.modes.entries()) {
|
|
15000
|
+
if (ids.has(mode.id)) {
|
|
15001
|
+
context.addIssue({
|
|
15002
|
+
code: "custom",
|
|
15003
|
+
message: "Permission Mode IDs must be unique",
|
|
15004
|
+
path: ["modes", index, "id"]
|
|
15005
|
+
});
|
|
15006
|
+
}
|
|
15007
|
+
ids.add(mode.id);
|
|
15070
15008
|
}
|
|
15071
|
-
|
|
15072
|
-
|
|
15073
|
-
|
|
15074
|
-
|
|
15075
|
-
|
|
15076
|
-
|
|
15077
|
-
return "image/svg+xml";
|
|
15078
|
-
case "woff2":
|
|
15079
|
-
return "font/woff2";
|
|
15080
|
-
case "json":
|
|
15081
|
-
return "application/json";
|
|
15082
|
-
case "css":
|
|
15083
|
-
return "text/css";
|
|
15084
|
-
default:
|
|
15085
|
-
return desktopExtensionScreenshotMimeType(resource);
|
|
15086
|
-
}
|
|
15087
|
-
}
|
|
15088
|
-
var hasPortableSegments = (resource) => resource.split("/").every((segment) => !/[. ]$/u.test(segment));
|
|
15089
|
-
var desktopExtensionAssetPathSchema = pluginRelativeResourceSchema.refine((resource) => hasPortableSegments(resource) && desktopExtensionAssetMimeType(resource) !== void 0, "Expected a relative Desktop extension asset path with a supported suffix");
|
|
15090
|
-
var imagePathSchema = pluginRelativeResourceSchema.refine((resource) => desktopExtensionScreenshotMimeType(resource) !== void 0 && hasPortableSegments(resource), "Images must be relative .png, .jpg, .jpeg, or .webp paths with no segments ending in a dot or space");
|
|
15091
|
-
var desktopExtensionHttpUrlSchema = external_exports.string().trim().max(2048).regex(/^https?:\/\/[^/?#\\\s]+/iu, "Expected an HTTP(S) URL").pipe(external_exports.url({ protocol: /^https?$/u })).refine((value) => {
|
|
15092
|
-
const { username, password } = new URL(value);
|
|
15093
|
-
return !username && !password && !/[\\\s]/u.test(value);
|
|
15094
|
-
}, "URL must not contain credentials, backslashes, or whitespace");
|
|
15095
|
-
function localizedText(text) {
|
|
15096
|
-
return external_exports.strictObject({ en: text, "zh-CN": text });
|
|
15097
|
-
}
|
|
15098
|
-
var desktopExtensionLocalizedTextSchema = localizedText(external_exports.string().trim().min(1));
|
|
15099
|
-
var categoriesSchema = external_exports.array(desktopExtensionCategorySchema).max(desktopExtensionCategorySchema.options.length).refine((categories) => new Set(categories).size === categories.length, "Duplicate categories");
|
|
15100
|
-
var slotsSchema = external_exports.array(desktopExtensionSlotSchema).max(desktopExtensionSlotSchema.options.length).refine((slots) => new Set(slots).size === slots.length, "Duplicate slots");
|
|
15101
|
-
var settingField = {
|
|
15102
|
-
key: external_exports.string().regex(/^[A-Za-z_][A-Za-z0-9_]*$/u),
|
|
15103
|
-
label: desktopExtensionLocalizedTextSchema,
|
|
15104
|
-
description: desktopExtensionLocalizedTextSchema.optional()
|
|
15105
|
-
};
|
|
15106
|
-
var numericSetting = {
|
|
15107
|
-
...settingField,
|
|
15108
|
-
step: external_exports.number().positive().optional(),
|
|
15109
|
-
default: external_exports.number().optional()
|
|
15110
|
-
};
|
|
15111
|
-
var settingOption = external_exports.strictObject({
|
|
15112
|
-
value: external_exports.string(),
|
|
15113
|
-
label: desktopExtensionLocalizedTextSchema
|
|
15114
|
-
});
|
|
15115
|
-
var desktopExtensionSettingFieldSchema = external_exports.discriminatedUnion("type", [
|
|
15116
|
-
external_exports.strictObject({
|
|
15117
|
-
...settingField,
|
|
15118
|
-
type: external_exports.literal("boolean"),
|
|
15119
|
-
default: external_exports.boolean().optional()
|
|
15120
|
-
}),
|
|
15121
|
-
external_exports.strictObject({
|
|
15122
|
-
...settingField,
|
|
15123
|
-
type: external_exports.literal("string"),
|
|
15124
|
-
placeholder: desktopExtensionLocalizedTextSchema.optional(),
|
|
15125
|
-
default: external_exports.string().optional()
|
|
15126
|
-
}),
|
|
15127
|
-
external_exports.strictObject({
|
|
15128
|
-
...numericSetting,
|
|
15129
|
-
type: external_exports.literal("number"),
|
|
15130
|
-
min: external_exports.number().optional(),
|
|
15131
|
-
max: external_exports.number().optional()
|
|
15132
|
-
}),
|
|
15133
|
-
external_exports.strictObject({
|
|
15134
|
-
...numericSetting,
|
|
15135
|
-
type: external_exports.literal("range"),
|
|
15136
|
-
min: external_exports.number(),
|
|
15137
|
-
max: external_exports.number()
|
|
15138
|
-
}),
|
|
15139
|
-
external_exports.strictObject({
|
|
15140
|
-
...settingField,
|
|
15141
|
-
type: external_exports.literal("select"),
|
|
15142
|
-
options: external_exports.array(settingOption).min(1),
|
|
15143
|
-
default: external_exports.string().optional()
|
|
15144
|
-
})
|
|
15145
|
-
]).superRefine((field2, ctx) => {
|
|
15146
|
-
const issue2 = (path17, message) => ctx.addIssue({ code: "custom", path: [path17], message });
|
|
15147
|
-
if (field2.type === "number" || field2.type === "range") {
|
|
15148
|
-
const { min = -Infinity, max = Infinity, default: value } = field2;
|
|
15149
|
-
if (min > max)
|
|
15150
|
-
issue2("max", "Must be at least min");
|
|
15151
|
-
if (value !== void 0 && (value < min || value > max))
|
|
15152
|
-
issue2("default", "Must be within min and max");
|
|
15153
|
-
} else if (field2.type === "select") {
|
|
15154
|
-
const values = new Set(field2.options.map(({ value }) => value));
|
|
15155
|
-
if (values.size !== field2.options.length)
|
|
15156
|
-
issue2("options", "Duplicate option values");
|
|
15157
|
-
if (field2.default !== void 0 && !values.has(field2.default))
|
|
15158
|
-
issue2("default", "Must match an option value");
|
|
15159
|
-
}
|
|
15160
|
-
});
|
|
15161
|
-
var manifestHeader = external_exports.object({
|
|
15162
|
-
manifestVersion: external_exports.int().positive(),
|
|
15163
|
-
id: desktopExtensionIdSchema,
|
|
15164
|
-
name: external_exports.union([extensionName, localizedText(extensionName)]),
|
|
15165
|
-
version: external_exports.string().min(1).max(128),
|
|
15166
|
-
desktopApi: external_exports.int().positive()
|
|
15167
|
-
}).passthrough();
|
|
15168
|
-
var desktopExtensionManifestSchema = manifestHeader.extend({
|
|
15169
|
-
manifestVersion: external_exports.literal(1),
|
|
15170
|
-
desktopApi: external_exports.literal(DESKTOP_EXTENSION_API_VERSION),
|
|
15171
|
-
description: external_exports.strictObject({ en: external_exports.string().max(4096), "zh-CN": external_exports.string().max(4096).optional() }).optional(),
|
|
15172
|
-
author: external_exports.string().trim().min(1).max(128).optional(),
|
|
15173
|
-
repository: desktopExtensionHttpUrlSchema.optional(),
|
|
15174
|
-
details: external_exports.strictObject({ en: external_exports.string().max(16384), "zh-CN": external_exports.string().max(16384).optional() }).optional(),
|
|
15175
|
-
icon: imagePathSchema.optional(),
|
|
15176
|
-
screenshots: external_exports.array(imagePathSchema).max(DESKTOP_EXTENSION_SCREENSHOT_LIMIT).refine((screenshots) => new Set(screenshots).size === screenshots.length, "Duplicate screenshots").optional(),
|
|
15177
|
-
desktop: external_exports.strictObject({
|
|
15178
|
-
script: pluginRelativeResourceSchema,
|
|
15179
|
-
style: pluginRelativeResourceSchema.optional()
|
|
15180
|
-
}).optional(),
|
|
15181
|
-
backend: external_exports.strictObject({ script: pluginRelativeResourceSchema.refine(hasPortableSegments) }).optional(),
|
|
15182
|
-
slots: slotsSchema.default(() => []),
|
|
15183
|
-
settingsSchema: external_exports.array(desktopExtensionSettingFieldSchema).max(32).refine((fields) => new Set(fields.map(({ key }) => key)).size === fields.length, "Duplicate setting keys").optional(),
|
|
15184
|
-
categories: categoriesSchema.optional()
|
|
15185
|
-
}).strict().refine((manifest) => manifest.desktop !== void 0 || manifest.backend !== void 0, "Expected at least one desktop or backend entry");
|
|
15186
|
-
var desktopExtensionConfigurationSchema = external_exports.strictObject({
|
|
15187
|
-
version: external_exports.literal(1),
|
|
15188
|
-
revision: external_exports.int().nonnegative(),
|
|
15189
|
-
enabled: external_exports.array(desktopExtensionIdSchema).max(DESKTOP_EXTENSION_LIMIT).refine((ids) => new Set(ids).size === ids.length, "Duplicate extension IDs"),
|
|
15190
|
-
reloadToken: external_exports.uuid().optional()
|
|
15191
|
-
});
|
|
15192
|
-
var desktopExtensionHashSchema = external_exports.string().regex(/^[a-f0-9]{64}$/u);
|
|
15193
|
-
var desktopExtensionStatusSchema = external_exports.strictObject({
|
|
15194
|
-
state: external_exports.enum([
|
|
15195
|
-
"running",
|
|
15196
|
-
"disabled",
|
|
15197
|
-
"invalid",
|
|
15198
|
-
"incompatible",
|
|
15199
|
-
"conflict",
|
|
15200
|
-
"failed",
|
|
15201
|
-
"waiting"
|
|
15202
|
-
]),
|
|
15203
|
-
hash: desktopExtensionHashSchema.optional(),
|
|
15204
|
-
error: external_exports.string().optional(),
|
|
15205
|
-
conflictWith: desktopExtensionIdSchema.optional()
|
|
15206
|
-
});
|
|
15207
|
-
var desktopExtensionsDiagnosticSchema = external_exports.strictObject({
|
|
15208
|
-
controllerPid: external_exports.int().positive(),
|
|
15209
|
-
targetId: external_exports.string().nullable(),
|
|
15210
|
-
updatedAt: external_exports.iso.datetime(),
|
|
15211
|
-
handledReloadToken: external_exports.uuid().optional(),
|
|
15212
|
-
extensions: external_exports.record(external_exports.string(), desktopExtensionStatusSchema)
|
|
15213
|
-
});
|
|
15214
|
-
var desktopExtensionTrustTierSchema = external_exports.enum(["official", "community"]);
|
|
15215
|
-
function isGitHubDesktopExtensionZipballUrl(url2) {
|
|
15216
|
-
return url2.origin === "https://api.github.com" && /^\/repos\/[\w-]+\/[\w.-]+\/zipball(?:\/[^/]+)?\/?$/u.test(url2.pathname);
|
|
15217
|
-
}
|
|
15218
|
-
var desktopExtensionZipUrlSchema = desktopExtensionHttpUrlSchema.refine((input) => {
|
|
15219
|
-
const url2 = new URL(input);
|
|
15220
|
-
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);
|
|
15221
|
-
}, "Expected a .zip download URL or a GitHub zipball URL");
|
|
15222
|
-
var desktopExtensionCatalogEntrySchema = external_exports.strictObject({
|
|
15223
|
-
id: desktopExtensionIdSchema,
|
|
15224
|
-
version: external_exports.string().trim().min(1).max(128),
|
|
15225
|
-
name: desktopExtensionLocalizedTextSchema.extend({ en: extensionName, "zh-CN": extensionName }),
|
|
15226
|
-
description: localizedText(external_exports.string().trim().min(1).max(4096)),
|
|
15227
|
-
details: localizedText(external_exports.string().trim().min(1).max(16384)).optional(),
|
|
15228
|
-
author: external_exports.string().trim().min(1).max(128),
|
|
15229
|
-
repository: desktopExtensionHttpUrlSchema,
|
|
15230
|
-
stars: external_exports.number().int().min(0).optional(),
|
|
15231
|
-
downloads: external_exports.number().int().min(0).optional(),
|
|
15232
|
-
categories: categoriesSchema.optional(),
|
|
15233
|
-
trustTier: desktopExtensionTrustTierSchema.default("community"),
|
|
15234
|
-
icon: desktopExtensionHttpUrlSchema.optional(),
|
|
15235
|
-
screenshots: external_exports.array(desktopExtensionHttpUrlSchema).max(DESKTOP_EXTENSION_SCREENSHOT_LIMIT).optional(),
|
|
15236
|
-
downloadUrl: desktopExtensionZipUrlSchema,
|
|
15237
|
-
sha256: desktopExtensionHashSchema,
|
|
15238
|
-
slots: slotsSchema.optional(),
|
|
15239
|
-
publishedAt: external_exports.string().optional(),
|
|
15240
|
-
updatedAt: external_exports.string().optional(),
|
|
15241
|
-
minCodexHostVersion: external_exports.string().optional()
|
|
15242
|
-
});
|
|
15243
|
-
var desktopExtensionCatalogSchema = external_exports.strictObject({
|
|
15244
|
-
schemaVersion: external_exports.literal(1),
|
|
15245
|
-
generatedAt: external_exports.string(),
|
|
15246
|
-
extensions: external_exports.array(desktopExtensionCatalogEntrySchema).refine((entries) => new Set(entries.map(({ id }) => id)).size === entries.length, "Duplicate extension IDs")
|
|
15247
|
-
});
|
|
15248
|
-
var DESKTOP_EXTENSIONS_ASSET_METHOD = "codexhost/desktop/extensions/asset";
|
|
15249
|
-
var DESKTOP_EXTENSIONS_SETTINGS_GET_METHOD = "codexhost/desktop/extensions/settings/get";
|
|
15250
|
-
var DESKTOP_EXTENSIONS_SETTINGS_SET_METHOD = "codexhost/desktop/extensions/settings/set";
|
|
15251
|
-
var DESKTOP_EXTENSIONS_BACKEND_INVOKE_METHOD = "codexhost/desktop/extensions/backend/invoke";
|
|
15252
|
-
var extensionIdParams = { id: desktopExtensionIdSchema };
|
|
15253
|
-
var desktopExtensionsAssetParamsSchema = external_exports.strictObject({
|
|
15254
|
-
...extensionIdParams,
|
|
15255
|
-
path: desktopExtensionAssetPathSchema
|
|
15256
|
-
});
|
|
15257
|
-
var desktopExtensionsAssetResultSchema = external_exports.strictObject({
|
|
15258
|
-
mimeType: external_exports.string(),
|
|
15259
|
-
dataUrl: external_exports.string()
|
|
15260
|
-
});
|
|
15261
|
-
var desktopExtensionsSettingsGetParamsSchema = external_exports.strictObject(extensionIdParams);
|
|
15262
|
-
var desktopExtensionsSettingsSetParamsSchema = external_exports.strictObject({
|
|
15263
|
-
...extensionIdParams,
|
|
15264
|
-
values: jsonObjectSchema
|
|
15265
|
-
});
|
|
15266
|
-
var desktopExtensionsSettingsResultSchema = external_exports.strictObject({ values: jsonObjectSchema });
|
|
15267
|
-
var desktopExtensionBackendMethodSchema = external_exports.string().trim().min(1).max(128);
|
|
15268
|
-
var desktopExtensionsBackendInvokeParamsSchema = external_exports.strictObject({
|
|
15269
|
-
...extensionIdParams,
|
|
15270
|
-
method: desktopExtensionBackendMethodSchema,
|
|
15271
|
-
params: jsonValueSchema.optional()
|
|
15272
|
-
});
|
|
15273
|
-
var desktopExtensionsBackendInvokeResultSchema = external_exports.strictObject({
|
|
15274
|
-
result: jsonValueSchema
|
|
15275
|
-
});
|
|
15276
|
-
|
|
15277
|
-
// ../../shared-contracts/dist/desktop-extension-management.js
|
|
15278
|
-
var DESKTOP_EXTENSIONS_LIST_METHOD = "codexhost/desktop/extensions/list";
|
|
15279
|
-
var DESKTOP_EXTENSIONS_ENABLE_METHOD = "codexhost/desktop/extensions/enable";
|
|
15280
|
-
var DESKTOP_EXTENSIONS_DISABLE_METHOD = "codexhost/desktop/extensions/disable";
|
|
15281
|
-
var DESKTOP_EXTENSIONS_CATALOG_METHOD = "codexhost/desktop/extensions/catalog";
|
|
15282
|
-
var DESKTOP_EXTENSIONS_INSTALL_METHOD = "codexhost/desktop/extensions/install";
|
|
15283
|
-
var DESKTOP_EXTENSIONS_UNINSTALL_METHOD = "codexhost/desktop/extensions/uninstall";
|
|
15284
|
-
var DESKTOP_EXTENSIONS_RECOVER_METHOD = "codexhost/desktop/extensions/disable-all-and-reload";
|
|
15285
|
-
var DESKTOP_EXTENSION_MANAGEMENT_METHODS = [
|
|
15286
|
-
DESKTOP_EXTENSIONS_LIST_METHOD,
|
|
15287
|
-
DESKTOP_EXTENSIONS_ENABLE_METHOD,
|
|
15288
|
-
DESKTOP_EXTENSIONS_DISABLE_METHOD,
|
|
15289
|
-
DESKTOP_EXTENSIONS_RECOVER_METHOD,
|
|
15290
|
-
DESKTOP_EXTENSIONS_CATALOG_METHOD,
|
|
15291
|
-
DESKTOP_EXTENSIONS_INSTALL_METHOD,
|
|
15292
|
-
DESKTOP_EXTENSIONS_UNINSTALL_METHOD,
|
|
15293
|
-
DESKTOP_EXTENSIONS_ASSET_METHOD,
|
|
15294
|
-
DESKTOP_EXTENSIONS_SETTINGS_GET_METHOD,
|
|
15295
|
-
DESKTOP_EXTENSIONS_SETTINGS_SET_METHOD,
|
|
15296
|
-
DESKTOP_EXTENSIONS_BACKEND_INVOKE_METHOD
|
|
15297
|
-
];
|
|
15298
|
-
var revisionSchema = external_exports.int().nonnegative();
|
|
15299
|
-
var desktopExtensionsListParamsSchema = external_exports.strictObject({});
|
|
15300
|
-
var desktopExtensionSelectionParamsSchema = external_exports.strictObject({
|
|
15301
|
-
id: desktopExtensionIdSchema,
|
|
15302
|
-
expectedRevision: revisionSchema
|
|
15303
|
-
});
|
|
15304
|
-
var desktopExtensionsRecoveryParamsSchema = external_exports.strictObject({
|
|
15305
|
-
expectedRevision: revisionSchema.optional()
|
|
15306
|
-
});
|
|
15307
|
-
var rasterDataUrlSchema = (maxBytes) => external_exports.string().max("data:image/jpeg;base64,".length + 4 * Math.ceil(maxBytes / 3)).regex(/^data:image\/(?:png|jpeg|webp);base64,[A-Za-z0-9+/]+={0,2}$/u);
|
|
15308
|
-
var desktopExtensionListItemSchema = external_exports.strictObject({
|
|
15309
|
-
// An invalid discovery can have a directory name that isn't a valid extension ID.
|
|
15310
|
-
id: external_exports.string().min(1),
|
|
15311
|
-
manifest: desktopExtensionManifestSchema.optional(),
|
|
15312
|
-
iconDataUrl: rasterDataUrlSchema(DESKTOP_EXTENSION_ICON_MAX_BYTES).optional(),
|
|
15313
|
-
screenshotDataUrls: external_exports.array(rasterDataUrlSchema(DESKTOP_EXTENSION_SCREENSHOT_MAX_BYTES)).max(DESKTOP_EXTENSION_SCREENSHOT_LIMIT).optional(),
|
|
15314
|
-
enabled: external_exports.boolean(),
|
|
15315
|
-
status: desktopExtensionStatusSchema
|
|
15316
|
-
});
|
|
15317
|
-
var desktopExtensionsListResultSchema = external_exports.strictObject({
|
|
15318
|
-
configuration: desktopExtensionConfigurationSchema,
|
|
15319
|
-
desktopConnected: external_exports.boolean(),
|
|
15320
|
-
diagnostics: external_exports.array(external_exports.string()),
|
|
15321
|
-
extensions: external_exports.array(desktopExtensionListItemSchema)
|
|
15322
|
-
});
|
|
15323
|
-
var desktopExtensionsCatalogParamsSchema = external_exports.strictObject({
|
|
15324
|
-
forceRefresh: external_exports.boolean().optional()
|
|
15325
|
-
});
|
|
15326
|
-
var desktopExtensionsCatalogResultSchema = external_exports.strictObject({
|
|
15327
|
-
catalogUrl: external_exports.string(),
|
|
15328
|
-
source: external_exports.enum(["remote", "fallback"]),
|
|
15329
|
-
fetchedAt: external_exports.string(),
|
|
15330
|
-
cached: external_exports.boolean(),
|
|
15331
|
-
extensions: desktopExtensionCatalogSchema.shape.extensions,
|
|
15332
|
-
error: external_exports.string().optional()
|
|
15333
|
-
});
|
|
15334
|
-
var desktopExtensionsInstallParamsSchema = external_exports.strictObject({
|
|
15335
|
-
source: external_exports.discriminatedUnion("type", [
|
|
15336
|
-
external_exports.strictObject({ type: external_exports.literal("catalog"), id: desktopExtensionIdSchema }),
|
|
15337
|
-
external_exports.strictObject({
|
|
15338
|
-
type: external_exports.literal("url"),
|
|
15339
|
-
url: desktopExtensionHttpUrlSchema,
|
|
15340
|
-
expectedSha256: desktopExtensionHashSchema.optional()
|
|
15341
|
-
}),
|
|
15342
|
-
external_exports.strictObject({
|
|
15343
|
-
type: external_exports.literal("zip-base64"),
|
|
15344
|
-
fileName: external_exports.string().trim().min(1).max(255),
|
|
15345
|
-
contentBase64: external_exports.string().min(4).max(DESKTOP_EXTENSION_ZIP_MAX_BASE64_LENGTH).refine((value) => value.length % 4 === 0 && /^[A-Za-z0-9+/]+={0,2}$/u.test(value), "Expected standard padded base64")
|
|
15346
|
-
})
|
|
15347
|
-
])
|
|
15348
|
-
});
|
|
15349
|
-
var desktopExtensionsInstallResultSchema = external_exports.strictObject({
|
|
15350
|
-
extensionId: desktopExtensionIdSchema,
|
|
15351
|
-
version: external_exports.string().min(1),
|
|
15352
|
-
replaced: external_exports.boolean(),
|
|
15353
|
-
installedPath: external_exports.string(),
|
|
15354
|
-
list: desktopExtensionsListResultSchema
|
|
15355
|
-
});
|
|
15356
|
-
var desktopExtensionsUninstallParamsSchema = external_exports.strictObject({
|
|
15357
|
-
id: desktopExtensionIdSchema
|
|
15358
|
-
});
|
|
15359
|
-
var desktopExtensionsUninstallResultSchema = external_exports.strictObject({
|
|
15360
|
-
removedId: desktopExtensionIdSchema,
|
|
15361
|
-
list: desktopExtensionsListResultSchema
|
|
15362
|
-
});
|
|
15363
|
-
var desktopExtensionMutationResultSchema = external_exports.discriminatedUnion("state", [
|
|
15364
|
-
external_exports.strictObject({ state: external_exports.literal("saved"), configuration: desktopExtensionConfigurationSchema }),
|
|
15365
|
-
external_exports.strictObject({ state: external_exports.literal("slot-conflict"), conflictWith: desktopExtensionIdSchema }),
|
|
15366
|
-
external_exports.strictObject({ state: external_exports.literal("revision-conflict"), revision: revisionSchema })
|
|
15367
|
-
]);
|
|
15368
|
-
|
|
15369
|
-
// ../../shared-contracts/dist/errors.js
|
|
15370
|
-
var codexhostErrorSchema = external_exports.strictObject({
|
|
15371
|
-
code: external_exports.string().min(1),
|
|
15372
|
-
message: external_exports.string().min(1),
|
|
15373
|
-
retryable: external_exports.boolean(),
|
|
15374
|
-
diagnostic: external_exports.string().min(1).optional(),
|
|
15375
|
-
stage: external_exports.string().min(1).optional(),
|
|
15376
|
-
durationMs: external_exports.number().int().nonnegative().optional(),
|
|
15377
|
-
stderrTail: external_exports.string().min(1).optional()
|
|
15378
|
-
}).superRefine(rejectExplicitUndefined(["diagnostic", "stage", "durationMs", "stderrTail"]));
|
|
15379
|
-
|
|
15380
|
-
// ../../shared-contracts/dist/harness-presentation.js
|
|
15381
|
-
var localeSchema = external_exports.string().max(64).regex(/^[a-z]{2,3}(?:-[A-Za-z0-9]{2,8})*$/u);
|
|
15382
|
-
var displayText = (maximum) => external_exports.string().min(1).max(maximum).refine((text) => text.trim().length > 0);
|
|
15383
|
-
var harnessLocalizationsSchema = external_exports.record(localeSchema, external_exports.object({
|
|
15384
|
-
label: displayText(256).optional(),
|
|
15385
|
-
description: displayText(1024).optional()
|
|
15386
|
-
}).strict()).refine((entries) => Object.keys(entries).length <= 16, "Too many locales");
|
|
15387
|
-
var harnessLocalizedTextSchema = external_exports.record(localeSchema, displayText(4096)).refine((entries) => typeof entries.en === "string", "English fallback is required").refine((entries) => Object.keys(entries).length <= 16, "Too many locales");
|
|
15388
|
-
|
|
15389
|
-
// ../../shared-contracts/dist/harness-permission-modes.js
|
|
15390
|
-
var HARNESS_PERMISSION_MODE_ID_MAX_LENGTH = 128;
|
|
15391
|
-
var HARNESS_PERMISSION_MODE_LABEL_MAX_LENGTH = 256;
|
|
15392
|
-
var HARNESS_PERMISSION_MODE_DESCRIPTION_MAX_LENGTH = 1024;
|
|
15393
|
-
var HARNESS_PERMISSION_MODE_CATALOG_MAX_LENGTH = 32;
|
|
15394
|
-
var nonBlankTextSchema = external_exports.string().refine((value) => value.trim().length > 0, {
|
|
15395
|
-
message: "Value must not be empty or whitespace"
|
|
15396
|
-
});
|
|
15397
|
-
var harnessPermissionModeIdSchema = nonBlankTextSchema.max(HARNESS_PERMISSION_MODE_ID_MAX_LENGTH).regex(/^[A-Za-z0-9._~:-]+$/u, "Permission Mode ID must use transport-safe characters").brand();
|
|
15398
|
-
var harnessPermissionModeSchema = external_exports.object({
|
|
15399
|
-
id: harnessPermissionModeIdSchema,
|
|
15400
|
-
label: nonBlankTextSchema.max(HARNESS_PERMISSION_MODE_LABEL_MAX_LENGTH),
|
|
15401
|
-
description: nonBlankTextSchema.max(HARNESS_PERMISSION_MODE_DESCRIPTION_MAX_LENGTH).optional(),
|
|
15402
|
-
dangerous: external_exports.boolean().optional(),
|
|
15403
|
-
localizations: harnessLocalizationsSchema.optional()
|
|
15404
|
-
}).strict();
|
|
15405
|
-
var harnessPermissionModeCatalogSchema = external_exports.object({
|
|
15406
|
-
modes: external_exports.array(harnessPermissionModeSchema).min(1).max(HARNESS_PERMISSION_MODE_CATALOG_MAX_LENGTH),
|
|
15407
|
-
defaultModeId: harnessPermissionModeIdSchema
|
|
15408
|
-
}).strict().superRefine((catalog, context) => {
|
|
15409
|
-
const ids = /* @__PURE__ */ new Set();
|
|
15410
|
-
for (const [index, mode] of catalog.modes.entries()) {
|
|
15411
|
-
if (ids.has(mode.id)) {
|
|
15412
|
-
context.addIssue({
|
|
15413
|
-
code: "custom",
|
|
15414
|
-
message: "Permission Mode IDs must be unique",
|
|
15415
|
-
path: ["modes", index, "id"]
|
|
15416
|
-
});
|
|
15417
|
-
}
|
|
15418
|
-
ids.add(mode.id);
|
|
15419
|
-
}
|
|
15420
|
-
if (!ids.has(catalog.defaultModeId)) {
|
|
15421
|
-
context.addIssue({
|
|
15422
|
-
code: "custom",
|
|
15423
|
-
message: "Default Permission Mode must exist in the catalog",
|
|
15424
|
-
path: ["defaultModeId"]
|
|
15425
|
-
});
|
|
15009
|
+
if (!ids.has(catalog.defaultModeId)) {
|
|
15010
|
+
context.addIssue({
|
|
15011
|
+
code: "custom",
|
|
15012
|
+
message: "Default Permission Mode must exist in the catalog",
|
|
15013
|
+
path: ["defaultModeId"]
|
|
15014
|
+
});
|
|
15426
15015
|
}
|
|
15427
15016
|
});
|
|
15428
15017
|
var threadPermissionModeSelectParamsSchema = external_exports.object({
|
|
@@ -15430,6 +15019,9 @@ var threadPermissionModeSelectParamsSchema = external_exports.object({
|
|
|
15430
15019
|
permissionModeId: harnessPermissionModeIdSchema
|
|
15431
15020
|
}).strict();
|
|
15432
15021
|
|
|
15022
|
+
// ../../shared-contracts/dist/harness-route-limit.js
|
|
15023
|
+
var HARNESS_TRANSPORT_MODEL_ID_MAX_LENGTH = 8192;
|
|
15024
|
+
|
|
15433
15025
|
// ../../shared-contracts/dist/thread-usage.js
|
|
15434
15026
|
var nonNegativeSafeIntegerSchema = external_exports.number().int().safe().nonnegative();
|
|
15435
15027
|
var finiteNonNegativeNumberSchema = external_exports.number().finite().nonnegative();
|
|
@@ -15462,7 +15054,7 @@ var composerIndicatorsSchema = external_exports.array(external_exports.object({
|
|
|
15462
15054
|
expiresAtUnix: nonNegativeSafeIntegerSchema,
|
|
15463
15055
|
label: indicatorTextSchema(256).optional(),
|
|
15464
15056
|
tooltip: indicatorTextSchema(1024).optional()
|
|
15465
|
-
}).strict()).max(2).refine((entries) => new Set(entries.map(({ id }) =>
|
|
15057
|
+
}).strict()).max(2).refine((entries) => new Set(entries.map(({ id: id2 }) => id2)).size === entries.length, {
|
|
15466
15058
|
message: "Composer indicator IDs must be unique"
|
|
15467
15059
|
});
|
|
15468
15060
|
var threadUsageSnapshotSchema = external_exports.object({
|
|
@@ -15488,6 +15080,7 @@ var threadUsageSnapshotSchema = external_exports.object({
|
|
|
15488
15080
|
planSevenDayResetsAtUnix: nonNegativeSafeIntegerSchema.optional(),
|
|
15489
15081
|
sessionCacheHitRatePercent: cacheHitRatePercentSchema.optional(),
|
|
15490
15082
|
timeToFirstOutputMs: nonNegativeSafeIntegerSchema.optional(),
|
|
15083
|
+
latestRequestTimeToFirstOutputMs: nonNegativeSafeIntegerSchema.optional(),
|
|
15491
15084
|
costSource: external_exports.enum(["publicPrice", "native"]).optional(),
|
|
15492
15085
|
unpricedModels: external_exports.array(external_exports.string().min(1)).min(1).optional()
|
|
15493
15086
|
}).strict().superRefine((usage, context) => {
|
|
@@ -15615,10 +15208,15 @@ var THREAD_OWNERSHIP_LIST_MAX_LENGTH = 100;
|
|
|
15615
15208
|
var nonBlankTextSchema2 = external_exports.string().refine((value) => value.trim().length > 0, {
|
|
15616
15209
|
message: "Value must not be empty or whitespace"
|
|
15617
15210
|
});
|
|
15618
|
-
var harnessModelRefIdSchema =
|
|
15211
|
+
var harnessModelRefIdSchema = external_exports.string().min(1).max(HARNESS_MODEL_REF_MAX_LENGTH).refine((id2) => !new RegExp("\\p{Cc}", "u").test(id2), "Model Ref must not contain control characters").brand();
|
|
15212
|
+
var harnessModelServiceTierSchema = external_exports.enum(["priority", "ultrafast"]);
|
|
15619
15213
|
var harnessModelRefSchema = external_exports.object({
|
|
15620
|
-
id: harnessModelRefIdSchema
|
|
15214
|
+
id: harnessModelRefIdSchema,
|
|
15215
|
+
serviceTier: harnessModelServiceTierSchema.optional()
|
|
15621
15216
|
}).strict();
|
|
15217
|
+
function sameHarnessModelRef(left, right) {
|
|
15218
|
+
return left?.id === right?.id && left?.serviceTier === right?.serviceTier;
|
|
15219
|
+
}
|
|
15622
15220
|
var harnessThinkingOptionIdSchema = nonBlankTextSchema2.max(HARNESS_THINKING_OPTION_ID_MAX_LENGTH).regex(/^[A-Za-z0-9._~-]+$/u, "Thinking option ID must use transport-safe characters").brand();
|
|
15623
15221
|
var harnessResolvedModelLabelSchema = nonBlankTextSchema2.max(HARNESS_MODEL_LABEL_MAX_LENGTH);
|
|
15624
15222
|
var harnessThinkingOptionSchema = external_exports.object({
|
|
@@ -15632,7 +15230,15 @@ var harnessModelSchema = external_exports.object({
|
|
|
15632
15230
|
/** Optional opaque selection for this same Model with priority processing enabled. */
|
|
15633
15231
|
fastModel: harnessModelRefSchema.optional(),
|
|
15634
15232
|
supportedThinkingOptionIds: external_exports.array(harnessThinkingOptionIdSchema).optional()
|
|
15635
|
-
}).strict()
|
|
15233
|
+
}).strict().refine((model2) => model2.fastModel?.serviceTier === void 0 || model2.fastModel.id === model2.ref.id, {
|
|
15234
|
+
path: ["fastModel", "id"],
|
|
15235
|
+
message: "A tiered Fast Model must share the base Model ID"
|
|
15236
|
+
});
|
|
15237
|
+
function catalogModelForRef(catalog, ref) {
|
|
15238
|
+
if (!ref)
|
|
15239
|
+
return void 0;
|
|
15240
|
+
return catalog?.models.find((model2) => sameHarnessModelRef(model2.ref, ref) || sameHarnessModelRef(model2.fastModel, ref));
|
|
15241
|
+
}
|
|
15636
15242
|
var harnessThinkingOptionsSchema = external_exports.array(harnessThinkingOptionSchema).superRefine((options, context) => {
|
|
15637
15243
|
const ids = /* @__PURE__ */ new Set();
|
|
15638
15244
|
for (const [index, option] of options.entries()) {
|
|
@@ -15652,26 +15258,26 @@ var harnessModelCatalogSchema = external_exports.object({
|
|
|
15652
15258
|
thinkingOptions: harnessThinkingOptionsSchema,
|
|
15653
15259
|
defaultThinkingOptionId: harnessThinkingOptionIdSchema.optional()
|
|
15654
15260
|
}).strict().superRefine((catalog, context) => {
|
|
15655
|
-
const refs =
|
|
15656
|
-
const thinkingIds = new Set(catalog.thinkingOptions.map(({ id }) =>
|
|
15261
|
+
const refs = [];
|
|
15262
|
+
const thinkingIds = new Set(catalog.thinkingOptions.map(({ id: id2 }) => id2));
|
|
15657
15263
|
for (const [index, model2] of catalog.models.entries()) {
|
|
15658
|
-
if (refs.
|
|
15264
|
+
if (refs.some((ref) => sameHarnessModelRef(ref, model2.ref))) {
|
|
15659
15265
|
context.addIssue({
|
|
15660
15266
|
code: "custom",
|
|
15661
15267
|
message: "Model Catalog refs must be unique",
|
|
15662
15268
|
path: ["models", index, "ref", "id"]
|
|
15663
15269
|
});
|
|
15664
15270
|
}
|
|
15665
|
-
refs.
|
|
15271
|
+
refs.push(model2.ref);
|
|
15666
15272
|
if (model2.fastModel) {
|
|
15667
|
-
if (refs.
|
|
15273
|
+
if (refs.some((ref) => sameHarnessModelRef(ref, model2.fastModel))) {
|
|
15668
15274
|
context.addIssue({
|
|
15669
15275
|
code: "custom",
|
|
15670
15276
|
message: "Fast Model refs must be distinct and unique",
|
|
15671
15277
|
path: ["models", index, "fastModel"]
|
|
15672
15278
|
});
|
|
15673
15279
|
}
|
|
15674
|
-
refs.
|
|
15280
|
+
refs.push(model2.fastModel);
|
|
15675
15281
|
}
|
|
15676
15282
|
const supportedThinkingIds = /* @__PURE__ */ new Set();
|
|
15677
15283
|
for (const [optionIndex, optionId] of (model2.supportedThinkingOptionIds ?? []).entries()) {
|
|
@@ -15692,7 +15298,7 @@ var harnessModelCatalogSchema = external_exports.object({
|
|
|
15692
15298
|
}
|
|
15693
15299
|
}
|
|
15694
15300
|
}
|
|
15695
|
-
if (catalog.defaultModel && !
|
|
15301
|
+
if (catalog.defaultModel && !catalogModelForRef(catalog, catalog.defaultModel)) {
|
|
15696
15302
|
context.addIssue({
|
|
15697
15303
|
code: "custom",
|
|
15698
15304
|
message: "Default Model must exist in the Model Catalog",
|
|
@@ -15732,7 +15338,12 @@ var harnessSessionCapabilitiesSchema = external_exports.object({
|
|
|
15732
15338
|
observe: external_exports.boolean()
|
|
15733
15339
|
}).strict().optional(),
|
|
15734
15340
|
/** True only when `turn.steer` delivers input into the active Turn through a native primitive. */
|
|
15735
|
-
steer: external_exports.boolean().optional()
|
|
15341
|
+
steer: external_exports.boolean().optional(),
|
|
15342
|
+
/**
|
|
15343
|
+
* True when the native plan (task list) outlives the Turn that changed it, so a reopened
|
|
15344
|
+
* Thread gets its latest plan again. Otherwise a plan stays with the Turn that made it.
|
|
15345
|
+
*/
|
|
15346
|
+
persistentPlan: external_exports.boolean().optional()
|
|
15736
15347
|
}).strict();
|
|
15737
15348
|
var harnessConfigurationStateSchema = external_exports.object({
|
|
15738
15349
|
effectiveModel: harnessModelRefSchema.optional(),
|
|
@@ -15741,7 +15352,7 @@ var harnessConfigurationStateSchema = external_exports.object({
|
|
|
15741
15352
|
availableThinkingOptions: harnessThinkingOptionsSchema.optional(),
|
|
15742
15353
|
effectivePermissionModeId: harnessPermissionModeIdSchema.optional()
|
|
15743
15354
|
}).strict().superRefine((state, context) => {
|
|
15744
|
-
if (state.effectiveThinkingOptionId && state.availableThinkingOptions && !state.availableThinkingOptions.some(({ id }) =>
|
|
15355
|
+
if (state.effectiveThinkingOptionId && state.availableThinkingOptions && !state.availableThinkingOptions.some(({ id: id2 }) => id2 === state.effectiveThinkingOptionId)) {
|
|
15745
15356
|
context.addIssue({
|
|
15746
15357
|
code: "custom",
|
|
15747
15358
|
message: "Effective Thinking option must be currently available",
|
|
@@ -15768,131 +15379,677 @@ var readyHarnessInspectionSchema = external_exports.object({
|
|
|
15768
15379
|
});
|
|
15769
15380
|
}
|
|
15770
15381
|
});
|
|
15771
|
-
var failedHarnessInspectionSchema = external_exports.object({
|
|
15772
|
-
status: external_exports.enum(["notInstalled", "unavailable", "error"]),
|
|
15773
|
-
error: codexhostErrorSchema
|
|
15774
|
-
}).strict();
|
|
15775
|
-
var harnessInspectionSchema = external_exports.union([
|
|
15776
|
-
readyHarnessInspectionSchema,
|
|
15777
|
-
failedHarnessInspectionSchema
|
|
15382
|
+
var failedHarnessInspectionSchema = external_exports.object({
|
|
15383
|
+
status: external_exports.enum(["notInstalled", "unavailable", "error"]),
|
|
15384
|
+
error: codexhostErrorSchema
|
|
15385
|
+
}).strict();
|
|
15386
|
+
var harnessInspectionSchema = external_exports.union([
|
|
15387
|
+
readyHarnessInspectionSchema,
|
|
15388
|
+
failedHarnessInspectionSchema
|
|
15389
|
+
]);
|
|
15390
|
+
var harnessInspectParamsSchema = external_exports.object({
|
|
15391
|
+
harnessId: harnessIdSchema,
|
|
15392
|
+
cwd: nonBlankTextSchema2.max(16384).optional(),
|
|
15393
|
+
refresh: external_exports.boolean().optional(),
|
|
15394
|
+
/** `availability` asks only whether the Harness can run; see `InspectHarnessInput.purpose`. */
|
|
15395
|
+
purpose: external_exports.literal("availability").optional(),
|
|
15396
|
+
credentialAccess: external_exports.enum(["allow", "retry"]).optional()
|
|
15397
|
+
}).strict();
|
|
15398
|
+
var harnessWebUiOpenParamsSchema = external_exports.object({
|
|
15399
|
+
harnessId: harnessIdSchema
|
|
15400
|
+
}).strict();
|
|
15401
|
+
var harnessWebUiOpenResultSchema = external_exports.object({}).strict();
|
|
15402
|
+
var threadModelSelectParamsSchema = external_exports.object({
|
|
15403
|
+
threadId: hostThreadIdSchema,
|
|
15404
|
+
model: harnessModelRefSchema
|
|
15405
|
+
}).strict();
|
|
15406
|
+
var threadThinkingSelectParamsSchema = external_exports.object({
|
|
15407
|
+
threadId: hostThreadIdSchema,
|
|
15408
|
+
thinkingOptionId: harnessThinkingOptionIdSchema
|
|
15409
|
+
}).strict();
|
|
15410
|
+
var threadInspectionParamsSchema = external_exports.object({
|
|
15411
|
+
threadId: hostThreadIdSchema,
|
|
15412
|
+
includeReferenceCapability: external_exports.boolean().optional()
|
|
15413
|
+
}).strict();
|
|
15414
|
+
var codexThreadInspectionSchema = external_exports.object({
|
|
15415
|
+
owner: external_exports.literal("codex"),
|
|
15416
|
+
locked: external_exports.boolean(),
|
|
15417
|
+
effectiveModel: harnessModelRefSchema.optional(),
|
|
15418
|
+
resolvedModelLabel: harnessResolvedModelLabelSchema.optional(),
|
|
15419
|
+
effectiveThinkingOptionId: harnessThinkingOptionIdSchema.optional(),
|
|
15420
|
+
effectivePermissionModeId: harnessPermissionModeIdSchema.optional(),
|
|
15421
|
+
history: harnessHistoryCapabilitiesSchema.optional(),
|
|
15422
|
+
supportsThreadReferences: external_exports.literal(true).optional()
|
|
15423
|
+
}).strict();
|
|
15424
|
+
var externalThreadInspectionSchema = external_exports.object({
|
|
15425
|
+
owner: external_exports.literal("external"),
|
|
15426
|
+
harnessId: nonBlankTextSchema2.max(256),
|
|
15427
|
+
transportModelId: nonBlankTextSchema2.max(HARNESS_TRANSPORT_MODEL_ID_MAX_LENGTH),
|
|
15428
|
+
effectiveModel: harnessModelRefSchema.optional(),
|
|
15429
|
+
resolvedModelLabel: harnessResolvedModelLabelSchema.optional(),
|
|
15430
|
+
effectiveThinkingOptionId: harnessThinkingOptionIdSchema.optional(),
|
|
15431
|
+
availableThinkingOptions: harnessThinkingOptionsSchema.optional(),
|
|
15432
|
+
effectivePermissionModeId: harnessPermissionModeIdSchema.optional(),
|
|
15433
|
+
history: harnessHistoryCapabilitiesSchema,
|
|
15434
|
+
usage: threadUsageSnapshotSchema.optional(),
|
|
15435
|
+
locked: external_exports.literal(true)
|
|
15436
|
+
}).strict();
|
|
15437
|
+
var threadInspectionSchema = external_exports.discriminatedUnion("owner", [
|
|
15438
|
+
codexThreadInspectionSchema,
|
|
15439
|
+
externalThreadInspectionSchema
|
|
15440
|
+
]);
|
|
15441
|
+
var threadOwnershipListParamsSchema = external_exports.object({
|
|
15442
|
+
threadIds: external_exports.array(hostThreadIdSchema).min(1).max(THREAD_OWNERSHIP_LIST_MAX_LENGTH)
|
|
15443
|
+
}).strict().superRefine(({ threadIds }, context) => {
|
|
15444
|
+
const seen = /* @__PURE__ */ new Set();
|
|
15445
|
+
for (const [index, threadId] of threadIds.entries()) {
|
|
15446
|
+
if (seen.has(threadId)) {
|
|
15447
|
+
context.addIssue({
|
|
15448
|
+
code: "custom",
|
|
15449
|
+
message: "Thread ownership-list IDs must be unique",
|
|
15450
|
+
path: ["threadIds", index]
|
|
15451
|
+
});
|
|
15452
|
+
}
|
|
15453
|
+
seen.add(threadId);
|
|
15454
|
+
}
|
|
15455
|
+
});
|
|
15456
|
+
var codexThreadOwnershipSchema = external_exports.object({
|
|
15457
|
+
threadId: hostThreadIdSchema,
|
|
15458
|
+
owner: external_exports.literal("codex")
|
|
15459
|
+
}).strict();
|
|
15460
|
+
var externalThreadOwnershipSchema = external_exports.object({
|
|
15461
|
+
threadId: hostThreadIdSchema,
|
|
15462
|
+
owner: external_exports.literal("external"),
|
|
15463
|
+
harnessId: external_exports.string().max(256).pipe(harnessIdSchema)
|
|
15464
|
+
}).strict();
|
|
15465
|
+
var threadOwnershipSchema = external_exports.discriminatedUnion("owner", [
|
|
15466
|
+
codexThreadOwnershipSchema,
|
|
15467
|
+
externalThreadOwnershipSchema
|
|
15468
|
+
]);
|
|
15469
|
+
var threadOwnershipListResultSchema = external_exports.object({
|
|
15470
|
+
threads: external_exports.array(threadOwnershipSchema).min(1).max(THREAD_OWNERSHIP_LIST_MAX_LENGTH)
|
|
15471
|
+
}).strict().superRefine(({ threads }, context) => {
|
|
15472
|
+
const seen = /* @__PURE__ */ new Set();
|
|
15473
|
+
for (const [index, thread2] of threads.entries()) {
|
|
15474
|
+
if (seen.has(thread2.threadId)) {
|
|
15475
|
+
context.addIssue({
|
|
15476
|
+
code: "custom",
|
|
15477
|
+
message: "Thread ownership-list results must be unique",
|
|
15478
|
+
path: ["threads", index, "threadId"]
|
|
15479
|
+
});
|
|
15480
|
+
}
|
|
15481
|
+
seen.add(thread2.threadId);
|
|
15482
|
+
}
|
|
15483
|
+
});
|
|
15484
|
+
var threadSteeringInspectParamsSchema = external_exports.object({
|
|
15485
|
+
threadId: hostThreadIdSchema,
|
|
15486
|
+
/** The text about to be steered; a Harness command always stops and restarts. */
|
|
15487
|
+
text: external_exports.string().optional()
|
|
15488
|
+
}).strict();
|
|
15489
|
+
var threadSteeringContextSchema = external_exports.object({
|
|
15490
|
+
kind: external_exports.literal("application"),
|
|
15491
|
+
value: external_exports.string().transform((text, context) => {
|
|
15492
|
+
try {
|
|
15493
|
+
return JSON.parse(text);
|
|
15494
|
+
} catch {
|
|
15495
|
+
context.addIssue({ code: "custom", message: "Invalid steering context JSON" });
|
|
15496
|
+
return external_exports.NEVER;
|
|
15497
|
+
}
|
|
15498
|
+
}).pipe(external_exports.object({
|
|
15499
|
+
expectedTurnId: hostTurnIdSchema,
|
|
15500
|
+
clientUserMessageId: external_exports.string().min(1),
|
|
15501
|
+
delivery: external_exports.enum(["newTurn", "activeTurn"])
|
|
15502
|
+
}).strict())
|
|
15503
|
+
}).strict().transform((context) => context.value);
|
|
15504
|
+
var threadSteerDeliverySchema = external_exports.enum(["activeTurn", "newTurn"]);
|
|
15505
|
+
var threadSteeringInspectResultSchema = external_exports.object({
|
|
15506
|
+
delivery: external_exports.enum(["official", "activeTurn", "newTurn"])
|
|
15507
|
+
}).strict();
|
|
15508
|
+
|
|
15509
|
+
// ../../shared-contracts/dist/harness-plugins.js
|
|
15510
|
+
var HARNESS_PLUGIN_MANIFEST_MAX_BYTES = 32 * 1024;
|
|
15511
|
+
var HARNESS_PLUGIN_ICON_MAX_BYTES = 128 * 1024;
|
|
15512
|
+
var HARNESS_PLUGIN_LIMIT = 128;
|
|
15513
|
+
var installedPluginIdSchema = external_exports.string().min(1).max(128).regex(/^[a-z][a-z0-9]*(?:[._-][a-z0-9]+)*$/u);
|
|
15514
|
+
var installedHarnessPluginIdSchema = installedPluginIdSchema.pipe(harnessIdSchema);
|
|
15515
|
+
var harnessPluginIdSchema = installedHarnessPluginIdSchema.refine((id2) => id2 !== "codex", "The official Codex identity is reserved");
|
|
15516
|
+
var pluginRelativeResourceSchema = external_exports.string().min(1).max(512).refine((value) => !/[\\\u0000:#?]/u.test(value) && !value.startsWith("/") && !value.split("/").some((part) => part === ".." || part === ""), "Plugin resources must be relative paths inside the plugin");
|
|
15517
|
+
var documentationUrlSchema = external_exports.url().refine((value) => /^https:\/\/[^/?#@]+(?:[/?#]|$)/iu.test(value), "Plugin documentation links must be credential-free HTTPS URLs");
|
|
15518
|
+
var localizedTextSchema = external_exports.object({ en: external_exports.string().max(4096), "zh-CN": external_exports.string().max(4096).optional() }).strict();
|
|
15519
|
+
var harnessInstallationGuideSchema = external_exports.object({
|
|
15520
|
+
commands: external_exports.array(external_exports.object({ terminal: external_exports.string().max(256), command: external_exports.string().max(4096) }).strict()).max(8),
|
|
15521
|
+
before: localizedTextSchema.optional(),
|
|
15522
|
+
after: localizedTextSchema.optional(),
|
|
15523
|
+
downloads: external_exports.array(external_exports.object({ label: external_exports.string().max(128), url: documentationUrlSchema }).strict()).max(8).optional()
|
|
15524
|
+
}).strict();
|
|
15525
|
+
var pluginPresentationShape = {
|
|
15526
|
+
id: installedHarnessPluginIdSchema,
|
|
15527
|
+
name: external_exports.string().trim().min(1).max(128),
|
|
15528
|
+
version: external_exports.string().min(1).max(128),
|
|
15529
|
+
/** Capability-only plugin; omitted for existing session-capable plugins. */
|
|
15530
|
+
kind: external_exports.literal("usage").optional(),
|
|
15531
|
+
/** Original image styling or bounded vector paths; never arbitrary CSS/SVG markup. */
|
|
15532
|
+
iconStyle: external_exports.object({
|
|
15533
|
+
vector: external_exports.object({
|
|
15534
|
+
viewBox: external_exports.string().max(128).regex(/^-?\d+(?:\.\d+)?(?: +-?\d+(?:\.\d+)?){3}$/u),
|
|
15535
|
+
color: external_exports.string().regex(/^(?:currentColor|#[a-f0-9]{6})$/iu),
|
|
15536
|
+
paths: external_exports.array(external_exports.object({
|
|
15537
|
+
d: external_exports.string().min(1).max(32768).regex(/^[MmLlHhVvCcSsQqTtAaZz\d.,+eE\s-]+$/u),
|
|
15538
|
+
fillRule: external_exports.enum(["evenodd", "nonzero"]).optional(),
|
|
15539
|
+
fill: external_exports.string().regex(/^(?:currentColor|#[a-f0-9]{6})$/iu).optional()
|
|
15540
|
+
}).strict()).min(1).max(32)
|
|
15541
|
+
}).strict().optional(),
|
|
15542
|
+
background: external_exports.string().regex(/^#[a-f0-9]{6}$/iu).optional(),
|
|
15543
|
+
borderRadius: external_exports.number().min(0).max(50).optional(),
|
|
15544
|
+
paddingRatio: external_exports.number().min(0).max(0.25).optional()
|
|
15545
|
+
}).strict().optional(),
|
|
15546
|
+
installation: harnessInstallationGuideSchema.optional(),
|
|
15547
|
+
notice: localizedTextSchema.optional(),
|
|
15548
|
+
/** The factory accepts a persisted local entrypoint through its construction context. */
|
|
15549
|
+
launchCommand: external_exports.literal(true).optional(),
|
|
15550
|
+
links: external_exports.object({
|
|
15551
|
+
website: documentationUrlSchema.optional(),
|
|
15552
|
+
documentation: documentationUrlSchema.optional(),
|
|
15553
|
+
installation: documentationUrlSchema.optional()
|
|
15554
|
+
}).strict().optional()
|
|
15555
|
+
};
|
|
15556
|
+
var harnessPluginManifestSchema = external_exports.object({
|
|
15557
|
+
manifestVersion: external_exports.literal(1),
|
|
15558
|
+
...pluginPresentationShape,
|
|
15559
|
+
adapterApiVersion: external_exports.number().int().positive(),
|
|
15560
|
+
entry: pluginRelativeResourceSchema,
|
|
15561
|
+
icon: pluginRelativeResourceSchema.optional()
|
|
15562
|
+
}).strict();
|
|
15563
|
+
var harnessPluginIconSchema = external_exports.string().max(Math.ceil(HARNESS_PLUGIN_ICON_MAX_BYTES / 3) * 4 + 64).regex(/^data:image\/(?:png|jpeg|webp|svg\+xml);base64,[A-Za-z0-9+/]+={0,2}$/u);
|
|
15564
|
+
var harnessPluginDescriptorSchema = external_exports.object({
|
|
15565
|
+
...pluginPresentationShape,
|
|
15566
|
+
icon: harnessPluginIconSchema.optional()
|
|
15567
|
+
}).strict();
|
|
15568
|
+
var harnessPluginListParamsSchema = external_exports.object({}).strict();
|
|
15569
|
+
var harnessPluginListResultSchema = external_exports.object({
|
|
15570
|
+
plugins: external_exports.array(harnessPluginDescriptorSchema.extend({ id: harnessPluginIdSchema })).max(HARNESS_PLUGIN_LIMIT)
|
|
15571
|
+
}).strict();
|
|
15572
|
+
var harnessPluginConfigurationSchema = external_exports.object({
|
|
15573
|
+
version: external_exports.literal(1),
|
|
15574
|
+
enabled: external_exports.array(installedHarnessPluginIdSchema).max(HARNESS_PLUGIN_LIMIT)
|
|
15575
|
+
}).strict().refine((value) => new Set(value.enabled).size === value.enabled.length, {
|
|
15576
|
+
message: "Enabled plugin IDs must be unique",
|
|
15577
|
+
path: ["enabled"]
|
|
15578
|
+
});
|
|
15579
|
+
|
|
15580
|
+
// ../../shared-contracts/dist/desktop-extensions.js
|
|
15581
|
+
var DESKTOP_EXTENSION_API_VERSION = 1;
|
|
15582
|
+
var DESKTOP_EXTENSION_LIMIT = 64;
|
|
15583
|
+
var DESKTOP_EXTENSION_ZIP_MAX_BYTES = 64 * 1024 * 1024;
|
|
15584
|
+
var DESKTOP_EXTENSION_MANIFEST_MAX_BYTES = 128 * 1024;
|
|
15585
|
+
var DESKTOP_EXTENSION_SCRIPT_MAX_BYTES = 2 * 1024 * 1024;
|
|
15586
|
+
var DESKTOP_EXTENSION_STYLE_MAX_BYTES = 256 * 1024;
|
|
15587
|
+
var DESKTOP_EXTENSION_ICON_MAX_BYTES = 128 * 1024;
|
|
15588
|
+
var DESKTOP_EXTENSION_SCREENSHOT_LIMIT = 4;
|
|
15589
|
+
var DESKTOP_EXTENSION_SCREENSHOT_MAX_BYTES = 512 * 1024;
|
|
15590
|
+
var DESKTOP_EXTENSION_LIST_SCREENSHOTS_MAX_BYTES = 8 * 1024 * 1024;
|
|
15591
|
+
var DESKTOP_EXTENSION_SNAPSHOT_MAX_BYTES = 8 * 1024 * 1024;
|
|
15592
|
+
var DESKTOP_EXTENSION_ASSET_MAX_BYTES = 16 * 1024 * 1024;
|
|
15593
|
+
var DESKTOP_EXTENSION_SETTINGS_MAX_BYTES = 1024 * 1024;
|
|
15594
|
+
var desktopExtensionIdSchema = installedPluginIdSchema;
|
|
15595
|
+
var desktopExtensionSlotSchema = external_exports.enum([
|
|
15596
|
+
"sidebar.thread-layout",
|
|
15597
|
+
"sidebar.thread-badge",
|
|
15598
|
+
"appearance.theme"
|
|
15599
|
+
]);
|
|
15600
|
+
var desktopExtensionCategorySchema = external_exports.enum([
|
|
15601
|
+
"appearance",
|
|
15602
|
+
"interface",
|
|
15603
|
+
"workflow",
|
|
15604
|
+
"analytics",
|
|
15605
|
+
"integrations",
|
|
15606
|
+
"tools"
|
|
15607
|
+
]);
|
|
15608
|
+
var extensionName = external_exports.string().trim().min(1).max(128);
|
|
15609
|
+
function desktopExtensionScreenshotMimeType(resource) {
|
|
15610
|
+
switch (resource.match(/\.([^./]+)$/u)?.[1]?.toLowerCase()) {
|
|
15611
|
+
case "png":
|
|
15612
|
+
return "image/png";
|
|
15613
|
+
case "jpg":
|
|
15614
|
+
case "jpeg":
|
|
15615
|
+
return "image/jpeg";
|
|
15616
|
+
case "webp":
|
|
15617
|
+
return "image/webp";
|
|
15618
|
+
default:
|
|
15619
|
+
return void 0;
|
|
15620
|
+
}
|
|
15621
|
+
}
|
|
15622
|
+
var hasPortableSegments = (resource) => resource.split("/").every((segment) => !/[. ]$/u.test(segment));
|
|
15623
|
+
var imagePathSchema = pluginRelativeResourceSchema.refine((resource) => desktopExtensionScreenshotMimeType(resource) !== void 0 && hasPortableSegments(resource), "Images must be relative .png, .jpg, .jpeg, or .webp paths with no segments ending in a dot or space");
|
|
15624
|
+
var desktopExtensionHttpUrlSchema = external_exports.string().trim().max(2048).regex(/^https?:\/\/[^/?#\\\s]+/iu, "Expected an HTTP(S) URL").pipe(external_exports.url({ protocol: /^https?$/u })).refine((value) => {
|
|
15625
|
+
const { username, password } = new URL(value);
|
|
15626
|
+
return !username && !password && !/[\\\s]/u.test(value);
|
|
15627
|
+
}, "URL must not contain credentials, backslashes, or whitespace");
|
|
15628
|
+
function localizedText(text) {
|
|
15629
|
+
return external_exports.strictObject({ en: text, "zh-CN": text });
|
|
15630
|
+
}
|
|
15631
|
+
var desktopExtensionLocalizedTextSchema = localizedText(external_exports.string().trim().min(1));
|
|
15632
|
+
var categoriesSchema = external_exports.array(desktopExtensionCategorySchema).max(desktopExtensionCategorySchema.options.length).refine((categories) => new Set(categories).size === categories.length, "Duplicate categories");
|
|
15633
|
+
var slotsSchema = external_exports.array(desktopExtensionSlotSchema).max(desktopExtensionSlotSchema.options.length).refine((slots) => new Set(slots).size === slots.length, "Duplicate slots");
|
|
15634
|
+
var settingField = {
|
|
15635
|
+
key: external_exports.string().regex(/^[A-Za-z_][A-Za-z0-9_]*$/u),
|
|
15636
|
+
label: desktopExtensionLocalizedTextSchema,
|
|
15637
|
+
description: desktopExtensionLocalizedTextSchema.optional()
|
|
15638
|
+
};
|
|
15639
|
+
var numericSetting = {
|
|
15640
|
+
...settingField,
|
|
15641
|
+
step: external_exports.number().positive().optional(),
|
|
15642
|
+
default: external_exports.number().optional()
|
|
15643
|
+
};
|
|
15644
|
+
var settingOption = external_exports.strictObject({
|
|
15645
|
+
value: external_exports.string(),
|
|
15646
|
+
label: desktopExtensionLocalizedTextSchema
|
|
15647
|
+
});
|
|
15648
|
+
var desktopExtensionSettingFieldSchema = external_exports.discriminatedUnion("type", [
|
|
15649
|
+
external_exports.strictObject({
|
|
15650
|
+
...settingField,
|
|
15651
|
+
type: external_exports.literal("boolean"),
|
|
15652
|
+
default: external_exports.boolean().optional()
|
|
15653
|
+
}),
|
|
15654
|
+
external_exports.strictObject({
|
|
15655
|
+
...settingField,
|
|
15656
|
+
type: external_exports.literal("string"),
|
|
15657
|
+
placeholder: desktopExtensionLocalizedTextSchema.optional(),
|
|
15658
|
+
default: external_exports.string().optional()
|
|
15659
|
+
}),
|
|
15660
|
+
external_exports.strictObject({
|
|
15661
|
+
...numericSetting,
|
|
15662
|
+
type: external_exports.literal("number"),
|
|
15663
|
+
min: external_exports.number().optional(),
|
|
15664
|
+
max: external_exports.number().optional()
|
|
15665
|
+
}),
|
|
15666
|
+
external_exports.strictObject({
|
|
15667
|
+
...numericSetting,
|
|
15668
|
+
type: external_exports.literal("range"),
|
|
15669
|
+
min: external_exports.number(),
|
|
15670
|
+
max: external_exports.number()
|
|
15671
|
+
}),
|
|
15672
|
+
external_exports.strictObject({
|
|
15673
|
+
...settingField,
|
|
15674
|
+
type: external_exports.literal("select"),
|
|
15675
|
+
options: external_exports.array(settingOption).min(1),
|
|
15676
|
+
default: external_exports.string().optional()
|
|
15677
|
+
})
|
|
15678
|
+
]).superRefine((field2, ctx) => {
|
|
15679
|
+
const issue2 = (path17, message) => ctx.addIssue({ code: "custom", path: [path17], message });
|
|
15680
|
+
if (field2.type === "number" || field2.type === "range") {
|
|
15681
|
+
const { min = -Infinity, max = Infinity, default: value } = field2;
|
|
15682
|
+
if (min > max)
|
|
15683
|
+
issue2("max", "Must be at least min");
|
|
15684
|
+
if (value !== void 0 && (value < min || value > max))
|
|
15685
|
+
issue2("default", "Must be within min and max");
|
|
15686
|
+
} else if (field2.type === "select") {
|
|
15687
|
+
const values = new Set(field2.options.map(({ value }) => value));
|
|
15688
|
+
if (values.size !== field2.options.length)
|
|
15689
|
+
issue2("options", "Duplicate option values");
|
|
15690
|
+
if (field2.default !== void 0 && !values.has(field2.default))
|
|
15691
|
+
issue2("default", "Must match an option value");
|
|
15692
|
+
}
|
|
15693
|
+
});
|
|
15694
|
+
var manifestHeader = external_exports.object({
|
|
15695
|
+
manifestVersion: external_exports.int().positive(),
|
|
15696
|
+
id: desktopExtensionIdSchema,
|
|
15697
|
+
name: external_exports.union([extensionName, localizedText(extensionName)]),
|
|
15698
|
+
version: external_exports.string().min(1).max(128),
|
|
15699
|
+
desktopApi: external_exports.int().positive()
|
|
15700
|
+
}).passthrough();
|
|
15701
|
+
var desktopExtensionManifestSchema = manifestHeader.extend({
|
|
15702
|
+
manifestVersion: external_exports.literal(1),
|
|
15703
|
+
desktopApi: external_exports.literal(DESKTOP_EXTENSION_API_VERSION),
|
|
15704
|
+
description: external_exports.strictObject({ en: external_exports.string().max(4096), "zh-CN": external_exports.string().max(4096).optional() }).optional(),
|
|
15705
|
+
author: external_exports.string().trim().min(1).max(128).optional(),
|
|
15706
|
+
repository: desktopExtensionHttpUrlSchema.optional(),
|
|
15707
|
+
details: external_exports.strictObject({ en: external_exports.string().max(16384), "zh-CN": external_exports.string().max(16384).optional() }).optional(),
|
|
15708
|
+
icon: imagePathSchema.optional(),
|
|
15709
|
+
screenshots: external_exports.array(imagePathSchema).max(DESKTOP_EXTENSION_SCREENSHOT_LIMIT).refine((screenshots) => new Set(screenshots).size === screenshots.length, "Duplicate screenshots").optional(),
|
|
15710
|
+
desktop: external_exports.strictObject({
|
|
15711
|
+
script: pluginRelativeResourceSchema,
|
|
15712
|
+
style: pluginRelativeResourceSchema.optional()
|
|
15713
|
+
}).optional(),
|
|
15714
|
+
backend: external_exports.strictObject({ script: pluginRelativeResourceSchema.refine(hasPortableSegments) }).optional(),
|
|
15715
|
+
slots: slotsSchema.default(() => []),
|
|
15716
|
+
settingsSchema: external_exports.array(desktopExtensionSettingFieldSchema).max(32).refine((fields) => new Set(fields.map(({ key }) => key)).size === fields.length, "Duplicate setting keys").optional(),
|
|
15717
|
+
categories: categoriesSchema.optional()
|
|
15718
|
+
}).strict().refine((manifest) => manifest.desktop !== void 0 || manifest.backend !== void 0, "Expected at least one desktop or backend entry");
|
|
15719
|
+
var desktopExtensionHashSchema = external_exports.string().regex(/^[a-f0-9]{64}$/u);
|
|
15720
|
+
var desktopExtensionStatusSchema = external_exports.strictObject({
|
|
15721
|
+
state: external_exports.enum([
|
|
15722
|
+
"running",
|
|
15723
|
+
"disabled",
|
|
15724
|
+
"invalid",
|
|
15725
|
+
"incompatible",
|
|
15726
|
+
"conflict",
|
|
15727
|
+
"failed",
|
|
15728
|
+
"waiting"
|
|
15729
|
+
]),
|
|
15730
|
+
hash: desktopExtensionHashSchema.optional(),
|
|
15731
|
+
error: external_exports.string().optional(),
|
|
15732
|
+
conflictWith: desktopExtensionIdSchema.optional()
|
|
15733
|
+
});
|
|
15734
|
+
var desktopExtensionsDiagnosticSchema = external_exports.strictObject({
|
|
15735
|
+
controllerPid: external_exports.int().positive(),
|
|
15736
|
+
targetId: external_exports.string().nullable(),
|
|
15737
|
+
updatedAt: external_exports.iso.datetime(),
|
|
15738
|
+
handledReloadToken: external_exports.uuid().optional(),
|
|
15739
|
+
extensions: external_exports.record(external_exports.string(), desktopExtensionStatusSchema),
|
|
15740
|
+
surfaces: external_exports.record(external_exports.string(), desktopExtensionStatusSchema).optional()
|
|
15741
|
+
});
|
|
15742
|
+
var desktopExtensionTrustTierSchema = external_exports.enum(["official", "community"]);
|
|
15743
|
+
function isGitHubDesktopExtensionZipballUrl(url2) {
|
|
15744
|
+
return url2.origin === "https://api.github.com" && /^\/repos\/[\w-]+\/[\w.-]+\/zipball(?:\/[^/]+)?\/?$/u.test(url2.pathname);
|
|
15745
|
+
}
|
|
15746
|
+
var desktopExtensionZipUrlSchema = desktopExtensionHttpUrlSchema.refine((input) => {
|
|
15747
|
+
const url2 = new URL(input);
|
|
15748
|
+
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
|
+
}, "Expected a .zip download URL or a GitHub zipball URL");
|
|
15750
|
+
var desktopExtensionCatalogEntrySchema = external_exports.strictObject({
|
|
15751
|
+
id: desktopExtensionIdSchema,
|
|
15752
|
+
version: external_exports.string().trim().min(1).max(128),
|
|
15753
|
+
name: desktopExtensionLocalizedTextSchema.extend({ en: extensionName, "zh-CN": extensionName }),
|
|
15754
|
+
description: localizedText(external_exports.string().trim().min(1).max(4096)),
|
|
15755
|
+
details: localizedText(external_exports.string().trim().min(1).max(16384)).optional(),
|
|
15756
|
+
author: external_exports.string().trim().min(1).max(128),
|
|
15757
|
+
repository: desktopExtensionHttpUrlSchema,
|
|
15758
|
+
stars: external_exports.number().int().min(0).optional(),
|
|
15759
|
+
downloads: external_exports.number().int().min(0).optional(),
|
|
15760
|
+
categories: categoriesSchema.optional(),
|
|
15761
|
+
trustTier: desktopExtensionTrustTierSchema.default("community"),
|
|
15762
|
+
icon: desktopExtensionHttpUrlSchema.optional(),
|
|
15763
|
+
screenshots: external_exports.array(desktopExtensionHttpUrlSchema).max(DESKTOP_EXTENSION_SCREENSHOT_LIMIT).optional(),
|
|
15764
|
+
downloadUrl: desktopExtensionZipUrlSchema,
|
|
15765
|
+
sha256: desktopExtensionHashSchema,
|
|
15766
|
+
slots: slotsSchema.optional(),
|
|
15767
|
+
publishedAt: external_exports.string().optional(),
|
|
15768
|
+
updatedAt: external_exports.string().optional(),
|
|
15769
|
+
minCodexHostVersion: external_exports.string().optional()
|
|
15770
|
+
});
|
|
15771
|
+
var desktopExtensionCatalogSchema = external_exports.strictObject({
|
|
15772
|
+
schemaVersion: external_exports.literal(1),
|
|
15773
|
+
generatedAt: external_exports.string(),
|
|
15774
|
+
extensions: external_exports.array(desktopExtensionCatalogEntrySchema).refine((entries) => new Set(entries.map(({ id: id2 }) => id2)).size === entries.length, "Duplicate extension IDs")
|
|
15775
|
+
});
|
|
15776
|
+
var desktopExtensionBackendMethodSchema = external_exports.string().trim().min(1).max(128);
|
|
15777
|
+
|
|
15778
|
+
// ../../shared-contracts/dist/host-extensions.js
|
|
15779
|
+
var reservedName = /^(?:con|prn|aux|nul|com[1-9¹²³]|lpt[1-9¹²³]) *(?:\.|$)/iu;
|
|
15780
|
+
var HOST_EXTENSION_PAGE_API_VERSION = 1;
|
|
15781
|
+
var hostExtensionIdSchema = desktopExtensionIdSchema.refine((id2) => !reservedName.test(id2), "Reserved extension ID");
|
|
15782
|
+
var hostExtensionTargetSchema = external_exports.enum(["desktop", "web"]);
|
|
15783
|
+
var hostExtensionDigestSchema = desktopExtensionHashSchema;
|
|
15784
|
+
var hostExtensionActivationIdSchema = external_exports.uuid();
|
|
15785
|
+
var hostExtensionResourcePathSchema = pluginRelativeResourceSchema.refine((resource) => !/[\x00-\x1f\x7f<>"|*]/u.test(resource) && resource.split("/").every((part) => !/[. ]$/u.test(part) && !reservedName.test(part)), "Expected a portable relative resource path").refine((path17) => path17.split("/").length <= 32, "Extension resources may be at most 32 segments deep");
|
|
15786
|
+
var legacy = desktopExtensionManifestSchema.shape;
|
|
15787
|
+
var localized = (max, min = 0) => external_exports.strictObject({
|
|
15788
|
+
en: external_exports.string().trim().min(min).max(max),
|
|
15789
|
+
"zh-CN": external_exports.string().trim().min(min).max(max)
|
|
15790
|
+
});
|
|
15791
|
+
var resourceWithSuffix = (suffix) => hostExtensionResourcePathSchema.refine((path17) => path17.endsWith(suffix), `Expected a ${suffix} file`);
|
|
15792
|
+
var moduleEntry = resourceWithSuffix(".mjs");
|
|
15793
|
+
var style = resourceWithSuffix(".css").optional();
|
|
15794
|
+
var hostExtensionCanonicalPath = (path17) => path17.normalize("NFC").toLowerCase();
|
|
15795
|
+
var hostExtensionManifestV2Schema = external_exports.strictObject({
|
|
15796
|
+
manifestVersion: external_exports.literal(2),
|
|
15797
|
+
id: hostExtensionIdSchema,
|
|
15798
|
+
name: localized(128, 1),
|
|
15799
|
+
version: external_exports.string().trim().min(1).max(128),
|
|
15800
|
+
description: localized(4096),
|
|
15801
|
+
details: localized(16384).optional(),
|
|
15802
|
+
author: legacy.author,
|
|
15803
|
+
repository: legacy.repository,
|
|
15804
|
+
icon: legacy.icon.refine((path17) => path17 === void 0 || hostExtensionResourcePathSchema.safeParse(path17).success),
|
|
15805
|
+
screenshots: legacy.screenshots.refine((paths) => paths === void 0 || paths.every((path17) => hostExtensionResourcePathSchema.safeParse(path17).success)),
|
|
15806
|
+
categories: legacy.categories,
|
|
15807
|
+
settingsSchema: legacy.settingsSchema,
|
|
15808
|
+
slots: legacy.slots.removeDefault().optional(),
|
|
15809
|
+
page: external_exports.strictObject({
|
|
15810
|
+
apiVersion: external_exports.literal(HOST_EXTENSION_PAGE_API_VERSION),
|
|
15811
|
+
entry: moduleEntry,
|
|
15812
|
+
style,
|
|
15813
|
+
title: localized(128, 1).optional()
|
|
15814
|
+
}).optional(),
|
|
15815
|
+
widget: external_exports.strictObject({
|
|
15816
|
+
apiVersion: external_exports.literal(HOST_EXTENSION_PAGE_API_VERSION),
|
|
15817
|
+
entry: moduleEntry,
|
|
15818
|
+
style
|
|
15819
|
+
}).optional(),
|
|
15820
|
+
desktop: external_exports.strictObject({ apiVersion: external_exports.literal(1), script: resourceWithSuffix(".js"), style }).optional(),
|
|
15821
|
+
web: external_exports.strictObject({ apiVersion: external_exports.literal(1), entry: moduleEntry.optional(), style }).refine(({ entry, style: style2 }) => entry !== void 0 || style2 !== void 0, "Expected a Web entry or style").optional(),
|
|
15822
|
+
backend: external_exports.strictObject({ apiVersion: external_exports.literal(1), entry: moduleEntry }).optional()
|
|
15823
|
+
}).refine(({ page, widget, desktop, web, backend }) => Boolean(page || widget || desktop || web || backend), "Expected at least one page, widget, desktop, web, or backend entry").refine(({ page, widget, web, backend }) => !backend || [page?.entry, widget?.entry, web?.entry].every((entry) => entry === void 0 || hostExtensionCanonicalPath(entry) !== hostExtensionCanonicalPath(backend.entry)), { path: ["backend", "entry"], message: "A backend entry cannot also be a frontend entry" });
|
|
15824
|
+
function targetsForCapabilities({ hasPage, hasWidget, hasDesktop, hasWeb, hasBackend }) {
|
|
15825
|
+
if (hasPage || hasWidget || hasBackend && !hasDesktop && !hasWeb)
|
|
15826
|
+
return ["desktop", "web"];
|
|
15827
|
+
const targets = [];
|
|
15828
|
+
if (hasDesktop)
|
|
15829
|
+
targets.push("desktop");
|
|
15830
|
+
if (hasWeb)
|
|
15831
|
+
targets.push("web");
|
|
15832
|
+
return targets;
|
|
15833
|
+
}
|
|
15834
|
+
var hostExtensionBackendMethodSchema = desktopExtensionBackendMethodSchema;
|
|
15835
|
+
|
|
15836
|
+
// ../../shared-contracts/dist/host-extension-management.js
|
|
15837
|
+
var HOST_EXTENSION_ZIP_MAX_BYTES = DESKTOP_EXTENSION_ZIP_MAX_BYTES;
|
|
15838
|
+
var hostExtensionRevisionSchema = external_exports.int().nonnegative();
|
|
15839
|
+
var hostExtensionConfigurationSchema = external_exports.strictObject({
|
|
15840
|
+
revision: hostExtensionRevisionSchema,
|
|
15841
|
+
enabled: external_exports.array(hostExtensionIdSchema).max(DESKTOP_EXTENSION_LIMIT).refine((ids) => new Set(ids).size === ids.length, "Duplicate extension IDs")
|
|
15842
|
+
});
|
|
15843
|
+
var { downloadUrl, ...catalogMetadata } = desktopExtensionCatalogEntrySchema.shape;
|
|
15844
|
+
var hostExtensionCatalogEntrySchema = external_exports.object({
|
|
15845
|
+
...catalogMetadata,
|
|
15846
|
+
id: hostExtensionIdSchema,
|
|
15847
|
+
format: external_exports.literal("codexhost"),
|
|
15848
|
+
targets: external_exports.array(hostExtensionTargetSchema).min(1).max(2).refine((targets) => new Set(targets).size === targets.length, "Duplicate targets"),
|
|
15849
|
+
apis: external_exports.strictObject({
|
|
15850
|
+
page: external_exports.int().positive().optional(),
|
|
15851
|
+
widget: external_exports.int().positive().optional(),
|
|
15852
|
+
desktop: external_exports.int().positive().optional(),
|
|
15853
|
+
web: external_exports.int().positive().optional(),
|
|
15854
|
+
backend: external_exports.int().positive().optional()
|
|
15855
|
+
}),
|
|
15856
|
+
downloadUrl: downloadUrl.refine((url2) => url2.startsWith("https://"), "Expected HTTPS")
|
|
15857
|
+
}).refine(({ targets, apis }) => {
|
|
15858
|
+
const derived = targetsForCapabilities({
|
|
15859
|
+
hasPage: Boolean(apis.page),
|
|
15860
|
+
hasWidget: Boolean(apis.widget),
|
|
15861
|
+
hasDesktop: Boolean(apis.desktop),
|
|
15862
|
+
hasWeb: Boolean(apis.web),
|
|
15863
|
+
hasBackend: Boolean(apis.backend)
|
|
15864
|
+
});
|
|
15865
|
+
return targets.length === derived.length && derived.every((target2) => targets.includes(target2));
|
|
15866
|
+
}, "Catalog targets must match the declared APIs");
|
|
15867
|
+
var hostExtensionCatalogSchema = external_exports.object({
|
|
15868
|
+
schemaVersion: external_exports.literal(2),
|
|
15869
|
+
generatedAt: external_exports.string().min(1),
|
|
15870
|
+
extensions: external_exports.array(hostExtensionCatalogEntrySchema).max(1e4).refine((entries) => new Set(entries.map(({ id: id2 }) => id2)).size === entries.length, "Duplicate extension IDs")
|
|
15871
|
+
});
|
|
15872
|
+
var hostExtensionsCatalogResultSchema = hostExtensionCatalogSchema.extend({
|
|
15873
|
+
catalogUrl: desktopExtensionHttpUrlSchema,
|
|
15874
|
+
fetchedAt: external_exports.iso.datetime(),
|
|
15875
|
+
cached: external_exports.boolean()
|
|
15876
|
+
});
|
|
15877
|
+
var id = { id: hostExtensionIdSchema };
|
|
15878
|
+
var active = {
|
|
15879
|
+
...id,
|
|
15880
|
+
activationId: hostExtensionActivationIdSchema,
|
|
15881
|
+
digest: hostExtensionDigestSchema
|
|
15882
|
+
};
|
|
15883
|
+
var optionalActivation = { ...id, activationId: active.activationId.optional() };
|
|
15884
|
+
var filePath = external_exports.string().min(1).max(4096).refine((path17) => /^(?:\/|[a-z]:[/\\])/iu.test(path17) && !path17.includes("\0") && !path17.split(/[/\\]/u).some((part) => part === "." || part === ".."), "Expected an absolute local path without dot segments");
|
|
15885
|
+
var gitRef = external_exports.string().min(1).max(256).refine((ref) => ref.split("/").every((part) => part && /^[a-z0-9_.-]+$/iu.test(part) && part !== "." && part !== ".."), "Invalid GitHub ref");
|
|
15886
|
+
function base643(maxBytes) {
|
|
15887
|
+
return external_exports.string().max(4 * Math.ceil(maxBytes / 3)).refine((value) => {
|
|
15888
|
+
const padding = value.endsWith("==") ? 2 : value.endsWith("=") ? 1 : 0;
|
|
15889
|
+
return value.length % 4 === 0 && value.length * 3 / 4 - padding <= maxBytes && /^[A-Za-z0-9+/]*={0,2}$/u.test(value);
|
|
15890
|
+
}, "Expected bounded standard padded base64");
|
|
15891
|
+
}
|
|
15892
|
+
var hostExtensionGitHubSourceSchema = external_exports.strictObject({
|
|
15893
|
+
type: external_exports.literal("github"),
|
|
15894
|
+
repository: external_exports.string().max(150).regex(/^[a-z0-9-]+\/[a-z0-9_-][a-z0-9_.-]*$/iu),
|
|
15895
|
+
ref: gitRef.optional(),
|
|
15896
|
+
tag: gitRef.optional(),
|
|
15897
|
+
asset: external_exports.string().max(255).regex(/^[a-z0-9_.-]+\.zip$/iu).optional(),
|
|
15898
|
+
subpath: hostExtensionResourcePathSchema.optional()
|
|
15899
|
+
}).refine(({ ref, tag, asset }) => !ref || !tag && !asset, "Use either a zipball ref or a release tag/asset");
|
|
15900
|
+
var hostExtensionInstallSourceSchema = external_exports.union([
|
|
15901
|
+
external_exports.strictObject({ type: external_exports.literal("catalog"), ...id }),
|
|
15902
|
+
hostExtensionGitHubSourceSchema,
|
|
15903
|
+
external_exports.strictObject({ type: external_exports.literal("zip"), base64: base643(HOST_EXTENSION_ZIP_MAX_BYTES).min(4) }),
|
|
15904
|
+
external_exports.strictObject({ type: external_exports.literal("zip"), localZipPath: filePath }),
|
|
15905
|
+
external_exports.strictObject({ type: external_exports.literal("localDir"), localDir: filePath })
|
|
15778
15906
|
]);
|
|
15779
|
-
var
|
|
15780
|
-
|
|
15781
|
-
|
|
15782
|
-
|
|
15783
|
-
|
|
15784
|
-
purpose: external_exports.literal("availability").optional()
|
|
15785
|
-
}).strict();
|
|
15786
|
-
var harnessWebUiOpenParamsSchema = external_exports.object({
|
|
15787
|
-
harnessId: harnessIdSchema
|
|
15788
|
-
}).strict();
|
|
15789
|
-
var harnessWebUiOpenResultSchema = external_exports.object({}).strict();
|
|
15790
|
-
var threadModelSelectParamsSchema = external_exports.object({
|
|
15791
|
-
threadId: hostThreadIdSchema,
|
|
15792
|
-
model: harnessModelRefSchema
|
|
15793
|
-
}).strict();
|
|
15794
|
-
var threadThinkingSelectParamsSchema = external_exports.object({
|
|
15795
|
-
threadId: hostThreadIdSchema,
|
|
15796
|
-
thinkingOptionId: harnessThinkingOptionIdSchema
|
|
15797
|
-
}).strict();
|
|
15798
|
-
var threadInspectionParamsSchema = external_exports.object({
|
|
15799
|
-
threadId: hostThreadIdSchema,
|
|
15800
|
-
includeReferenceCapability: external_exports.boolean().optional()
|
|
15801
|
-
}).strict();
|
|
15802
|
-
var codexThreadInspectionSchema = external_exports.object({
|
|
15803
|
-
owner: external_exports.literal("codex"),
|
|
15804
|
-
locked: external_exports.boolean(),
|
|
15805
|
-
effectiveModel: harnessModelRefSchema.optional(),
|
|
15806
|
-
resolvedModelLabel: harnessResolvedModelLabelSchema.optional(),
|
|
15807
|
-
effectiveThinkingOptionId: harnessThinkingOptionIdSchema.optional(),
|
|
15808
|
-
effectivePermissionModeId: harnessPermissionModeIdSchema.optional(),
|
|
15809
|
-
history: harnessHistoryCapabilitiesSchema.optional(),
|
|
15810
|
-
supportsThreadReferences: external_exports.literal(true).optional()
|
|
15811
|
-
}).strict();
|
|
15812
|
-
var externalThreadInspectionSchema = external_exports.object({
|
|
15813
|
-
owner: external_exports.literal("external"),
|
|
15814
|
-
harnessId: nonBlankTextSchema2.max(256),
|
|
15815
|
-
transportModelId: nonBlankTextSchema2.max(1024),
|
|
15816
|
-
effectiveModel: harnessModelRefSchema.optional(),
|
|
15817
|
-
resolvedModelLabel: harnessResolvedModelLabelSchema.optional(),
|
|
15818
|
-
effectiveThinkingOptionId: harnessThinkingOptionIdSchema.optional(),
|
|
15819
|
-
availableThinkingOptions: harnessThinkingOptionsSchema.optional(),
|
|
15820
|
-
effectivePermissionModeId: harnessPermissionModeIdSchema.optional(),
|
|
15821
|
-
history: harnessHistoryCapabilitiesSchema,
|
|
15822
|
-
usage: threadUsageSnapshotSchema.optional(),
|
|
15823
|
-
locked: external_exports.literal(true)
|
|
15824
|
-
}).strict();
|
|
15825
|
-
var threadInspectionSchema = external_exports.discriminatedUnion("owner", [
|
|
15826
|
-
codexThreadInspectionSchema,
|
|
15827
|
-
externalThreadInspectionSchema
|
|
15907
|
+
var hostExtensionProvenanceSchema = external_exports.discriminatedUnion("type", [
|
|
15908
|
+
external_exports.strictObject({ type: external_exports.literal("catalog"), ...id }),
|
|
15909
|
+
hostExtensionGitHubSourceSchema,
|
|
15910
|
+
external_exports.strictObject({ type: external_exports.literal("zip") }),
|
|
15911
|
+
external_exports.strictObject({ type: external_exports.literal("localDir") })
|
|
15828
15912
|
]);
|
|
15829
|
-
var
|
|
15830
|
-
|
|
15831
|
-
|
|
15832
|
-
|
|
15833
|
-
|
|
15834
|
-
if (seen.has(threadId)) {
|
|
15835
|
-
context.addIssue({
|
|
15836
|
-
code: "custom",
|
|
15837
|
-
message: "Thread ownership-list IDs must be unique",
|
|
15838
|
-
path: ["threadIds", index]
|
|
15839
|
-
});
|
|
15840
|
-
}
|
|
15841
|
-
seen.add(threadId);
|
|
15842
|
-
}
|
|
15913
|
+
var hostExtensionInstallationSchema = external_exports.strictObject({
|
|
15914
|
+
...active,
|
|
15915
|
+
manifest: hostExtensionManifestV2Schema,
|
|
15916
|
+
installedAt: external_exports.iso.datetime(),
|
|
15917
|
+
source: hostExtensionProvenanceSchema.optional()
|
|
15843
15918
|
});
|
|
15844
|
-
var
|
|
15845
|
-
|
|
15846
|
-
|
|
15847
|
-
|
|
15848
|
-
|
|
15849
|
-
|
|
15850
|
-
|
|
15851
|
-
|
|
15852
|
-
|
|
15853
|
-
|
|
15854
|
-
|
|
15855
|
-
|
|
15919
|
+
var rasterDataUrlSchema = (maxBytes) => external_exports.string().max("data:image/jpeg;base64,".length + 4 * Math.ceil(maxBytes / 3)).regex(/^data:image\/(?:png|jpeg|webp);base64,[A-Za-z0-9+/]+={0,2}$/u);
|
|
15920
|
+
var desktopConflict = { desktopConflictWith: hostExtensionIdSchema.optional() };
|
|
15921
|
+
var backendState = external_exports.enum(["none", "inactive", "starting", "running", "failed"]);
|
|
15922
|
+
var hostExtensionListItemSchema = external_exports.discriminatedUnion("state", [
|
|
15923
|
+
hostExtensionInstallationSchema.extend({
|
|
15924
|
+
state: external_exports.literal("valid"),
|
|
15925
|
+
enabled: external_exports.boolean(),
|
|
15926
|
+
...desktopConflict,
|
|
15927
|
+
iconDataUrl: rasterDataUrlSchema(DESKTOP_EXTENSION_ICON_MAX_BYTES).optional(),
|
|
15928
|
+
screenshotDataUrls: external_exports.array(rasterDataUrlSchema(DESKTOP_EXTENSION_SCREENSHOT_MAX_BYTES)).max(DESKTOP_EXTENSION_SCREENSHOT_LIMIT).optional(),
|
|
15929
|
+
backendState: backendState.optional(),
|
|
15930
|
+
backendError: external_exports.string().optional()
|
|
15931
|
+
}),
|
|
15932
|
+
external_exports.strictObject({
|
|
15933
|
+
state: external_exports.enum(["invalid", "incompatible"]),
|
|
15934
|
+
id: external_exports.string().min(1),
|
|
15935
|
+
enabled: external_exports.boolean(),
|
|
15936
|
+
error: external_exports.string()
|
|
15937
|
+
})
|
|
15856
15938
|
]);
|
|
15857
|
-
var
|
|
15858
|
-
|
|
15859
|
-
|
|
15860
|
-
|
|
15861
|
-
|
|
15862
|
-
|
|
15863
|
-
|
|
15864
|
-
|
|
15865
|
-
|
|
15866
|
-
|
|
15867
|
-
|
|
15868
|
-
|
|
15869
|
-
|
|
15870
|
-
|
|
15939
|
+
var hostExtensionsListResultSchema = external_exports.strictObject({
|
|
15940
|
+
revision: hostExtensionRevisionSchema,
|
|
15941
|
+
configuration: hostExtensionConfigurationSchema,
|
|
15942
|
+
diagnostics: external_exports.array(external_exports.string()),
|
|
15943
|
+
extensions: external_exports.array(hostExtensionListItemSchema)
|
|
15944
|
+
});
|
|
15945
|
+
var hostExtensionRuntimeEntrySchema = hostExtensionInstallationSchema.extend({
|
|
15946
|
+
...desktopConflict,
|
|
15947
|
+
settingsRevision: hostExtensionRevisionSchema
|
|
15948
|
+
});
|
|
15949
|
+
var hostExtensionsSnapshotResultSchema = external_exports.strictObject({
|
|
15950
|
+
/** The Host publishes this revision in extensions-changed, independent of enabled.json's revision. */
|
|
15951
|
+
revision: hostExtensionRevisionSchema,
|
|
15952
|
+
// Enabled, valid activations only. A Desktop conflict does not hide other capabilities.
|
|
15953
|
+
extensions: external_exports.array(hostExtensionRuntimeEntrySchema).max(DESKTOP_EXTENSION_LIMIT)
|
|
15954
|
+
});
|
|
15955
|
+
var HOST_EXTENSIONS_RPC = {
|
|
15956
|
+
list: "codexhost/extensions/list",
|
|
15957
|
+
snapshot: "codexhost/extensions/snapshot",
|
|
15958
|
+
catalog: "codexhost/extensions/catalog",
|
|
15959
|
+
install: "codexhost/extensions/install",
|
|
15960
|
+
update: "codexhost/extensions/update",
|
|
15961
|
+
enable: "codexhost/extensions/enable",
|
|
15962
|
+
disable: "codexhost/extensions/disable",
|
|
15963
|
+
uninstall: "codexhost/extensions/uninstall",
|
|
15964
|
+
recover: "codexhost/extensions/recover",
|
|
15965
|
+
asset: "codexhost/extensions/asset",
|
|
15966
|
+
settingsGet: "codexhost/extensions/settings/get",
|
|
15967
|
+
settingsSet: "codexhost/extensions/settings/set",
|
|
15968
|
+
backendInvoke: "codexhost/extensions/backend/invoke"
|
|
15969
|
+
};
|
|
15970
|
+
var HOST_EXTENSION_MANAGEMENT_METHODS = Object.freeze(Object.values(HOST_EXTENSIONS_RPC));
|
|
15971
|
+
var methods = new Set(HOST_EXTENSION_MANAGEMENT_METHODS);
|
|
15972
|
+
var noParams = external_exports.strictObject({});
|
|
15973
|
+
var expectedRevision = { expectedRevision: hostExtensionRevisionSchema };
|
|
15974
|
+
var selection = external_exports.strictObject({ ...id, ...expectedRevision });
|
|
15975
|
+
var installationResult = hostExtensionInstallationSchema.extend({ replaced: external_exports.boolean() });
|
|
15976
|
+
var mutationResult = external_exports.discriminatedUnion("state", [
|
|
15977
|
+
external_exports.strictObject({ state: external_exports.literal("saved"), configuration: hostExtensionConfigurationSchema }),
|
|
15978
|
+
external_exports.strictObject({ state: external_exports.literal("revision-conflict"), revision: hostExtensionRevisionSchema })
|
|
15979
|
+
]);
|
|
15980
|
+
var hostExtensionsAssetParamsSchema = external_exports.strictObject({
|
|
15981
|
+
...optionalActivation,
|
|
15982
|
+
digest: active.digest.optional(),
|
|
15983
|
+
path: hostExtensionResourcePathSchema
|
|
15984
|
+
});
|
|
15985
|
+
var hostExtensionsAssetResultSchema = external_exports.strictObject({
|
|
15986
|
+
mimeType: external_exports.string().min(1),
|
|
15987
|
+
base64: base643(DESKTOP_EXTENSION_ASSET_MAX_BYTES),
|
|
15988
|
+
digest: active.digest
|
|
15989
|
+
});
|
|
15990
|
+
var hostExtensionSettingsSchema = external_exports.strictObject({
|
|
15991
|
+
settingsRevision: hostExtensionRevisionSchema,
|
|
15992
|
+
values: jsonObjectSchema
|
|
15871
15993
|
});
|
|
15872
|
-
var
|
|
15873
|
-
|
|
15874
|
-
|
|
15875
|
-
|
|
15876
|
-
|
|
15877
|
-
|
|
15878
|
-
|
|
15879
|
-
|
|
15880
|
-
|
|
15881
|
-
|
|
15882
|
-
|
|
15883
|
-
|
|
15884
|
-
|
|
15885
|
-
|
|
15886
|
-
|
|
15887
|
-
|
|
15888
|
-
|
|
15889
|
-
|
|
15890
|
-
|
|
15891
|
-
}
|
|
15892
|
-
|
|
15893
|
-
|
|
15894
|
-
|
|
15895
|
-
|
|
15994
|
+
var hostExtensionsRpcSchemas = {
|
|
15995
|
+
[HOST_EXTENSIONS_RPC.list]: { params: noParams, result: hostExtensionsListResultSchema },
|
|
15996
|
+
[HOST_EXTENSIONS_RPC.snapshot]: { params: noParams, result: hostExtensionsSnapshotResultSchema },
|
|
15997
|
+
[HOST_EXTENSIONS_RPC.catalog]: {
|
|
15998
|
+
params: external_exports.strictObject({ forceRefresh: external_exports.boolean().optional() }),
|
|
15999
|
+
result: hostExtensionsCatalogResultSchema
|
|
16000
|
+
},
|
|
16001
|
+
[HOST_EXTENSIONS_RPC.install]: {
|
|
16002
|
+
params: external_exports.strictObject({ source: hostExtensionInstallSourceSchema }),
|
|
16003
|
+
result: installationResult
|
|
16004
|
+
},
|
|
16005
|
+
[HOST_EXTENSIONS_RPC.update]: {
|
|
16006
|
+
params: external_exports.strictObject({
|
|
16007
|
+
...id,
|
|
16008
|
+
expectedDigest: active.digest,
|
|
16009
|
+
expectedActivationId: active.activationId.optional(),
|
|
16010
|
+
source: hostExtensionInstallSourceSchema.optional()
|
|
16011
|
+
}),
|
|
16012
|
+
result: installationResult
|
|
16013
|
+
},
|
|
16014
|
+
[HOST_EXTENSIONS_RPC.enable]: { params: selection, result: mutationResult },
|
|
16015
|
+
[HOST_EXTENSIONS_RPC.disable]: { params: selection, result: mutationResult },
|
|
16016
|
+
[HOST_EXTENSIONS_RPC.uninstall]: {
|
|
16017
|
+
params: external_exports.strictObject({
|
|
16018
|
+
...id,
|
|
16019
|
+
removeData: external_exports.boolean().optional(),
|
|
16020
|
+
expectedDigest: active.digest.optional()
|
|
16021
|
+
}),
|
|
16022
|
+
result: external_exports.strictObject({ ...id, removed: external_exports.boolean() })
|
|
16023
|
+
},
|
|
16024
|
+
[HOST_EXTENSIONS_RPC.recover]: {
|
|
16025
|
+
params: external_exports.strictObject({ expectedRevision: expectedRevision.expectedRevision.optional() }),
|
|
16026
|
+
result: mutationResult
|
|
16027
|
+
},
|
|
16028
|
+
[HOST_EXTENSIONS_RPC.asset]: {
|
|
16029
|
+
params: hostExtensionsAssetParamsSchema,
|
|
16030
|
+
result: hostExtensionsAssetResultSchema
|
|
16031
|
+
},
|
|
16032
|
+
[HOST_EXTENSIONS_RPC.settingsGet]: {
|
|
16033
|
+
params: external_exports.strictObject(optionalActivation),
|
|
16034
|
+
result: hostExtensionSettingsSchema
|
|
16035
|
+
},
|
|
16036
|
+
[HOST_EXTENSIONS_RPC.settingsSet]: {
|
|
16037
|
+
params: external_exports.strictObject({
|
|
16038
|
+
...optionalActivation,
|
|
16039
|
+
expectedSettingsRevision: hostExtensionRevisionSchema,
|
|
16040
|
+
values: jsonObjectSchema
|
|
16041
|
+
}),
|
|
16042
|
+
result: hostExtensionSettingsSchema
|
|
16043
|
+
},
|
|
16044
|
+
[HOST_EXTENSIONS_RPC.backendInvoke]: {
|
|
16045
|
+
params: external_exports.strictObject({
|
|
16046
|
+
...optionalActivation,
|
|
16047
|
+
method: hostExtensionBackendMethodSchema,
|
|
16048
|
+
params: jsonValueSchema.optional()
|
|
16049
|
+
}),
|
|
16050
|
+
result: external_exports.strictObject({ result: jsonValueSchema })
|
|
16051
|
+
}
|
|
16052
|
+
};
|
|
15896
16053
|
|
|
15897
16054
|
// ../../shared-contracts/dist/thread-archive-confirm.js
|
|
15898
16055
|
var THREAD_ARCHIVE_CONFIRM_METHOD = "codexhost/thread/archive/confirm";
|
|
@@ -15955,7 +16112,7 @@ var CLIENT_CHANNEL_METHODS = [
|
|
|
15955
16112
|
"codexhost/harness/session-import/list",
|
|
15956
16113
|
"codexhost/harness/session-import/import",
|
|
15957
16114
|
// Host settings shared across Desktop and Web.
|
|
15958
|
-
...
|
|
16115
|
+
...HOST_EXTENSION_MANAGEMENT_METHODS,
|
|
15959
16116
|
"codexhost/harness/installation",
|
|
15960
16117
|
"codexhost/harness/installation/start",
|
|
15961
16118
|
"codexhost/harness/installation/status",
|
|
@@ -16016,6 +16173,11 @@ var clientChannelEventSchema = external_exports.discriminatedUnion("type", [
|
|
|
16016
16173
|
cursor: clientChannelCursorSchema,
|
|
16017
16174
|
revision: external_exports.number().int().nonnegative()
|
|
16018
16175
|
}),
|
|
16176
|
+
external_exports.object({
|
|
16177
|
+
type: external_exports.literal("extensions-changed"),
|
|
16178
|
+
cursor: clientChannelCursorSchema,
|
|
16179
|
+
revision: hostExtensionRevisionSchema
|
|
16180
|
+
}),
|
|
16019
16181
|
external_exports.object({
|
|
16020
16182
|
type: external_exports.literal("hello"),
|
|
16021
16183
|
version: external_exports.literal(1),
|
|
@@ -16452,7 +16614,7 @@ var DEFAULT_IDLE_RELEASE_SETTINGS = Object.freeze({
|
|
|
16452
16614
|
|
|
16453
16615
|
// ../../shared-contracts/dist/harness-preferences.js
|
|
16454
16616
|
var harnessPreferenceScopeSchema = external_exports.string().regex(/^external$/u);
|
|
16455
|
-
var preferenceHarnessKey = harnessIdSchema.transform((
|
|
16617
|
+
var preferenceHarnessKey = harnessIdSchema.transform((id2) => String(id2));
|
|
16456
16618
|
var harnessDefaultConfigurationSchema = external_exports.strictObject({
|
|
16457
16619
|
model: harnessModelRefSchema.optional(),
|
|
16458
16620
|
thinkingOptionId: harnessThinkingOptionIdSchema.optional(),
|
|
@@ -16462,11 +16624,19 @@ var newThreadDefaultsSchema = external_exports.strictObject({
|
|
|
16462
16624
|
lastHarness: harnessIdSchema.optional(),
|
|
16463
16625
|
byHarness: external_exports.record(preferenceHarnessKey, harnessDefaultConfigurationSchema)
|
|
16464
16626
|
});
|
|
16627
|
+
var harnessDelegationDefaultSchema = external_exports.strictObject({
|
|
16628
|
+
model: harnessModelRefSchema.optional(),
|
|
16629
|
+
thinkingOptionId: harnessThinkingOptionIdSchema.optional()
|
|
16630
|
+
}).refine((value) => Boolean(value.model || value.thinkingOptionId), "A delegation default must contain a Model or Thinking option");
|
|
16631
|
+
var delegationDefaultsSchema = external_exports.strictObject({
|
|
16632
|
+
byHarness: external_exports.record(preferenceHarnessKey, harnessDelegationDefaultSchema)
|
|
16633
|
+
});
|
|
16465
16634
|
var modelId = external_exports.string().min(1).max(1024);
|
|
16466
16635
|
var harnessPreferenceValuesSchema = external_exports.strictObject({
|
|
16467
16636
|
idleRelease: idleReleaseSettingsSchema.optional(),
|
|
16468
16637
|
favorites: external_exports.record(preferenceHarnessKey, external_exports.array(modelId).max(2048)).default({}),
|
|
16469
|
-
newThread: newThreadDefaultsSchema.optional()
|
|
16638
|
+
newThread: newThreadDefaultsSchema.optional(),
|
|
16639
|
+
delegation: delegationDefaultsSchema.optional()
|
|
16470
16640
|
});
|
|
16471
16641
|
var harnessPreferenceSnapshotSchema = external_exports.strictObject({
|
|
16472
16642
|
scope: harnessPreferenceScopeSchema,
|
|
@@ -16494,6 +16664,11 @@ var harnessPreferenceOperationSchema = external_exports.discriminatedUnion("kind
|
|
|
16494
16664
|
lastHarness: harnessIdSchema.optional(),
|
|
16495
16665
|
harnessId: harnessIdSchema.optional(),
|
|
16496
16666
|
configuration: harnessDefaultConfigurationSchema.optional()
|
|
16667
|
+
}),
|
|
16668
|
+
external_exports.strictObject({
|
|
16669
|
+
kind: external_exports.literal("delegation"),
|
|
16670
|
+
harnessId: harnessIdSchema,
|
|
16671
|
+
configuration: harnessDelegationDefaultSchema.nullable()
|
|
16497
16672
|
})
|
|
16498
16673
|
]);
|
|
16499
16674
|
var harnessPreferencePatchSchema = external_exports.strictObject({
|
|
@@ -17317,9 +17492,12 @@ var remoteSessionOperationSchema = external_exports.discriminatedUnion("kind", [
|
|
|
17317
17492
|
...thread,
|
|
17318
17493
|
epoch: identity,
|
|
17319
17494
|
modelId: identity.optional(),
|
|
17495
|
+
serviceTier: harnessModelServiceTierSchema.optional(),
|
|
17320
17496
|
thinkingOptionId: identity.optional(),
|
|
17321
17497
|
permissionModeId: identity.optional()
|
|
17322
|
-
}).refine((value) => [value.modelId, value.thinkingOptionId, value.permissionModeId].filter((v) => v !== void 0).length === 1, "Select exactly one remote setting"),
|
|
17498
|
+
}).refine((value) => [value.modelId, value.thinkingOptionId, value.permissionModeId].filter((v) => v !== void 0).length === 1, "Select exactly one remote setting").refine((value) => value.serviceTier === void 0 || value.modelId !== void 0, {
|
|
17499
|
+
message: "A service tier requires a Model ID"
|
|
17500
|
+
}),
|
|
17323
17501
|
external_exports.strictObject({
|
|
17324
17502
|
kind: external_exports.literal("prompt"),
|
|
17325
17503
|
...thread,
|
|
@@ -17369,7 +17547,7 @@ var remoteConnectionsRequestSchema = external_exports.discriminatedUnion("action
|
|
|
17369
17547
|
external_exports.strictObject({ action: external_exports.literal("catalog") }),
|
|
17370
17548
|
external_exports.strictObject({
|
|
17371
17549
|
action: external_exports.literal("read-thread"),
|
|
17372
|
-
hostId: hostId.refine((
|
|
17550
|
+
hostId: hostId.refine((id2) => id2 !== "local"),
|
|
17373
17551
|
input: delegationReadParamsSchema
|
|
17374
17552
|
}),
|
|
17375
17553
|
external_exports.strictObject({
|
|
@@ -17383,7 +17561,7 @@ var remoteConnectionsRequestSchema = external_exports.discriminatedUnion("action
|
|
|
17383
17561
|
external_exports.strictObject({ action: external_exports.literal("runtime"), hostId }),
|
|
17384
17562
|
external_exports.strictObject({
|
|
17385
17563
|
action: external_exports.literal("update"),
|
|
17386
|
-
hostId: hostId.refine((
|
|
17564
|
+
hostId: hostId.refine((id2) => id2 !== "local"),
|
|
17387
17565
|
version: remoteUpdateParamsSchema.shape.version
|
|
17388
17566
|
})
|
|
17389
17567
|
]);
|
|
@@ -17447,7 +17625,7 @@ function invalidRequest(message) {
|
|
|
17447
17625
|
return { code: "invalidRequest", message, retryable: false };
|
|
17448
17626
|
}
|
|
17449
17627
|
function validateHostApprovalResponse(interaction, response) {
|
|
17450
|
-
return interaction.actions.some(({ id }) =>
|
|
17628
|
+
return interaction.actions.some(({ id: id2 }) => id2 === response.actionId) ? null : invalidRequest("Approval Response contains an undeclared action ID");
|
|
17451
17629
|
}
|
|
17452
17630
|
|
|
17453
17631
|
// ../../harness-adapter/dist/question.js
|
|
@@ -17455,7 +17633,7 @@ function invalidRequest2(message) {
|
|
|
17455
17633
|
return { code: "invalidRequest", message, retryable: false };
|
|
17456
17634
|
}
|
|
17457
17635
|
function validateHostQuestionResponse(interaction, response) {
|
|
17458
|
-
const questionIds = new Set(interaction.questions.map(({ id }) =>
|
|
17636
|
+
const questionIds = new Set(interaction.questions.map(({ id: id2 }) => id2));
|
|
17459
17637
|
if (response.cancelled) {
|
|
17460
17638
|
return Object.keys(response.answers).length === 0 ? null : invalidRequest2("Cancelled Question Response must not contain answers");
|
|
17461
17639
|
}
|
|
@@ -17486,6 +17664,18 @@ function validateHostQuestionResponse(interaction, response) {
|
|
|
17486
17664
|
return null;
|
|
17487
17665
|
}
|
|
17488
17666
|
|
|
17667
|
+
// ../../harness-adapter/dist/legacy-model-ref.js
|
|
17668
|
+
import { Buffer as Buffer2 } from "node:buffer";
|
|
17669
|
+
function normalizeLegacyBase64ModelRef(ref, catalog, prefix) {
|
|
17670
|
+
if (ref.serviceTier || !ref.id.startsWith(prefix))
|
|
17671
|
+
return void 0;
|
|
17672
|
+
const encoded = ref.id.slice(prefix.length);
|
|
17673
|
+
const id2 = Buffer2.from(encoded, "base64url").toString("utf8");
|
|
17674
|
+
if (Buffer2.from(id2).toString("base64url") !== encoded)
|
|
17675
|
+
return void 0;
|
|
17676
|
+
return catalog.models.find(({ ref: ref2 }) => ref2.id === id2 && !ref2.serviceTier)?.ref;
|
|
17677
|
+
}
|
|
17678
|
+
|
|
17489
17679
|
// ../../harness-adapter/dist/output-channel.js
|
|
17490
17680
|
var HarnessOutputChannel = class {
|
|
17491
17681
|
outputs;
|
|
@@ -17570,7 +17760,8 @@ var tokenFields = [
|
|
|
17570
17760
|
var safeIntegerFields = [
|
|
17571
17761
|
"planFiveHourResetsAtUnix",
|
|
17572
17762
|
"planSevenDayResetsAtUnix",
|
|
17573
|
-
"timeToFirstOutputMs"
|
|
17763
|
+
"timeToFirstOutputMs",
|
|
17764
|
+
"latestRequestTimeToFirstOutputMs"
|
|
17574
17765
|
];
|
|
17575
17766
|
var percentFields = [
|
|
17576
17767
|
"cacheHitRatePercent",
|
|
@@ -17778,7 +17969,7 @@ function isExcludedLiveCommand(name, extra = {}) {
|
|
|
17778
17969
|
function liveHarnessCommandPrompt(catalog, idPrefix, commandId, argumentText) {
|
|
17779
17970
|
if (!commandId.startsWith(idPrefix))
|
|
17780
17971
|
return null;
|
|
17781
|
-
const descriptor = catalog.commands.find(({ id }) =>
|
|
17972
|
+
const descriptor = catalog.commands.find(({ id: id2 }) => id2 === commandId);
|
|
17782
17973
|
if (!descriptor)
|
|
17783
17974
|
return null;
|
|
17784
17975
|
const text = typeof argumentText === "string" ? argumentText.trim() : "";
|
|
@@ -17788,7 +17979,7 @@ function mergeLiveHarnessCommands(builtIns, idPrefix, live, exclusions = {}) {
|
|
|
17788
17979
|
if (!live)
|
|
17789
17980
|
return builtIns;
|
|
17790
17981
|
const invocations = new Set(builtIns.commands.map(({ invocation }) => invocation));
|
|
17791
|
-
const ids = new Set(builtIns.commands.map(({ id }) =>
|
|
17982
|
+
const ids = new Set(builtIns.commands.map(({ id: id2 }) => id2));
|
|
17792
17983
|
const dynamic = [];
|
|
17793
17984
|
for (const command of live) {
|
|
17794
17985
|
const name = command.name.trim().replace(/^\//u, "");
|
|
@@ -17797,12 +17988,12 @@ function mergeLiveHarnessCommands(builtIns, idPrefix, live, exclusions = {}) {
|
|
|
17797
17988
|
if (isExcludedLiveCommand(name, exclusions))
|
|
17798
17989
|
continue;
|
|
17799
17990
|
const invocation = `/${name}`;
|
|
17800
|
-
const
|
|
17801
|
-
if (invocations.has(invocation) || ids.has(
|
|
17991
|
+
const id2 = `${idPrefix}${name.replace(/[^A-Za-z0-9._:-]/gu, "-")}`.slice(0, 128);
|
|
17992
|
+
if (invocations.has(invocation) || ids.has(id2))
|
|
17802
17993
|
continue;
|
|
17803
17994
|
const description = command.description?.trim().slice(0, 512);
|
|
17804
17995
|
const parsed = harnessCommandDescriptorSchema.safeParse({
|
|
17805
|
-
id,
|
|
17996
|
+
id: id2,
|
|
17806
17997
|
invocation,
|
|
17807
17998
|
label: name.slice(0, 128),
|
|
17808
17999
|
...description ? { description } : {},
|
|
@@ -17811,7 +18002,7 @@ function mergeLiveHarnessCommands(builtIns, idPrefix, live, exclusions = {}) {
|
|
|
17811
18002
|
if (!parsed.success)
|
|
17812
18003
|
continue;
|
|
17813
18004
|
invocations.add(invocation);
|
|
17814
|
-
ids.add(
|
|
18005
|
+
ids.add(id2);
|
|
17815
18006
|
dynamic.push(parsed.data);
|
|
17816
18007
|
}
|
|
17817
18008
|
return harnessCommandCatalogSchema.parse({ commands: [...builtIns.commands, ...dynamic] });
|
|
@@ -18058,7 +18249,7 @@ function createGrokUsageStatistics(environment) {
|
|
|
18058
18249
|
return Object.freeze({
|
|
18059
18250
|
// sessions/<url-encoded cwd>/<session>/updates.jsonl; subagents are sessions of their own.
|
|
18060
18251
|
listSources: async (signal) => (await jsonlUsageSources(path5.join(grokHome(environment), "sessions"), 2, signal)).filter((source) => path5.basename(source.id) === "updates.jsonl"),
|
|
18061
|
-
readSource: (
|
|
18252
|
+
readSource: (id2, signal) => readGrokUsage(id2, signal)
|
|
18062
18253
|
});
|
|
18063
18254
|
}
|
|
18064
18255
|
|
|
@@ -20324,8 +20515,8 @@ var RequestResponder = class {
|
|
|
20324
20515
|
signal;
|
|
20325
20516
|
finishRequest;
|
|
20326
20517
|
didRespond = false;
|
|
20327
|
-
constructor(
|
|
20328
|
-
this.id =
|
|
20518
|
+
constructor(id2, sendResult, signal = new AbortController().signal, finishRequest) {
|
|
20519
|
+
this.id = id2;
|
|
20329
20520
|
this.sendResult = sendResult;
|
|
20330
20521
|
this.signal = signal;
|
|
20331
20522
|
this.finishRequest = finishRequest;
|
|
@@ -20616,7 +20807,7 @@ var Connection = class {
|
|
|
20616
20807
|
return this.sendWireMessage({ jsonrpc: "2.0", method, params });
|
|
20617
20808
|
}
|
|
20618
20809
|
prepareRequest(method, params, mapResponse, options = {}) {
|
|
20619
|
-
const
|
|
20810
|
+
const id2 = this.nextRequestId++;
|
|
20620
20811
|
let cancel = () => {
|
|
20621
20812
|
};
|
|
20622
20813
|
const response = new Promise((resolve, reject) => {
|
|
@@ -20636,7 +20827,7 @@ var Connection = class {
|
|
|
20636
20827
|
}
|
|
20637
20828
|
pendingResponse.cancellationSent = true;
|
|
20638
20829
|
pendingResponse.cleanup?.();
|
|
20639
|
-
void this.sendCancelRequest(
|
|
20830
|
+
void this.sendCancelRequest(id2).catch(() => {
|
|
20640
20831
|
});
|
|
20641
20832
|
};
|
|
20642
20833
|
options.cancellationSignal?.addEventListener("abort", cancel, {
|
|
@@ -20645,12 +20836,12 @@ var Connection = class {
|
|
|
20645
20836
|
pendingResponse.cleanup = () => {
|
|
20646
20837
|
options.cancellationSignal?.removeEventListener("abort", cancel);
|
|
20647
20838
|
};
|
|
20648
|
-
this.pendingResponses.set(
|
|
20839
|
+
this.pendingResponses.set(id2, pendingResponse);
|
|
20649
20840
|
});
|
|
20650
20841
|
response.catch(() => {
|
|
20651
20842
|
});
|
|
20652
20843
|
return {
|
|
20653
|
-
message: { jsonrpc: "2.0", id, method, params },
|
|
20844
|
+
message: { jsonrpc: "2.0", id: id2, method, params },
|
|
20654
20845
|
response,
|
|
20655
20846
|
cancel: () => cancel()
|
|
20656
20847
|
};
|
|
@@ -21287,7 +21478,7 @@ function memoryStreamPair() {
|
|
|
21287
21478
|
}
|
|
21288
21479
|
];
|
|
21289
21480
|
}
|
|
21290
|
-
var
|
|
21481
|
+
var methods2 = {
|
|
21291
21482
|
agent: {
|
|
21292
21483
|
initialize: AGENT_METHODS.initialize,
|
|
21293
21484
|
authenticate: AGENT_METHODS.authenticate,
|
|
@@ -22666,43 +22857,14 @@ function grokLiveCommands(native) {
|
|
|
22666
22857
|
}
|
|
22667
22858
|
|
|
22668
22859
|
// dist/grok-models.js
|
|
22669
|
-
import { Buffer as Buffer2 } from "node:buffer";
|
|
22670
|
-
var GROK_MODEL_REF_PREFIX = "grok-model-v1.";
|
|
22671
22860
|
function isRecord5(value) {
|
|
22672
22861
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
22673
22862
|
}
|
|
22674
22863
|
function nonBlank(value) {
|
|
22675
22864
|
return typeof value === "string" && value.trim().length > 0;
|
|
22676
22865
|
}
|
|
22677
|
-
function
|
|
22678
|
-
|
|
22679
|
-
throw new Error("Grok Model ID must not be blank");
|
|
22680
|
-
const plain = harnessModelRefSchema.safeParse({ id: value });
|
|
22681
|
-
if (plain.success && !value.startsWith(GROK_MODEL_REF_PREFIX))
|
|
22682
|
-
return plain.data;
|
|
22683
|
-
const id = `${GROK_MODEL_REF_PREFIX}${Buffer2.from(value, "utf8").toString("base64url")}`;
|
|
22684
|
-
if (id.length > HARNESS_MODEL_REF_MAX_LENGTH) {
|
|
22685
|
-
throw new Error("Grok Model ID is too long for a Model Ref");
|
|
22686
|
-
}
|
|
22687
|
-
return harnessModelRefSchema.parse({ id });
|
|
22688
|
-
}
|
|
22689
|
-
function decodeGrokModelRef(ref) {
|
|
22690
|
-
const parsed = harnessModelRefSchema.parse(ref);
|
|
22691
|
-
if (!parsed.id.startsWith(GROK_MODEL_REF_PREFIX))
|
|
22692
|
-
return parsed.id;
|
|
22693
|
-
const encoded = parsed.id.slice(GROK_MODEL_REF_PREFIX.length);
|
|
22694
|
-
if (encoded.length === 0)
|
|
22695
|
-
throw new Error("Grok Model Ref is empty");
|
|
22696
|
-
let value;
|
|
22697
|
-
try {
|
|
22698
|
-
value = Buffer2.from(encoded, "base64url").toString("utf8");
|
|
22699
|
-
} catch {
|
|
22700
|
-
throw new Error("Grok Model Ref is malformed");
|
|
22701
|
-
}
|
|
22702
|
-
if (!nonBlank(value) || encodeGrokModelRef(value).id !== parsed.id) {
|
|
22703
|
-
throw new Error("Grok Model Ref is not canonical");
|
|
22704
|
-
}
|
|
22705
|
-
return value;
|
|
22866
|
+
function normalizeStoredGrokModelRef(ref, catalog) {
|
|
22867
|
+
return normalizeLegacyBase64ModelRef(ref, catalog, "grok-model-v1.");
|
|
22706
22868
|
}
|
|
22707
22869
|
function thinkingOptions(value) {
|
|
22708
22870
|
if (!Array.isArray(value))
|
|
@@ -22712,21 +22874,21 @@ function thinkingOptions(value) {
|
|
|
22712
22874
|
for (const candidate of value) {
|
|
22713
22875
|
if (!isRecord5(candidate) || !nonBlank(candidate.label))
|
|
22714
22876
|
continue;
|
|
22715
|
-
const
|
|
22716
|
-
if (!
|
|
22877
|
+
const id2 = harnessThinkingOptionIdSchema.safeParse(candidate.id ?? candidate.value);
|
|
22878
|
+
if (!id2.success || seen.has(id2.data))
|
|
22717
22879
|
continue;
|
|
22718
|
-
seen.add(
|
|
22719
|
-
options.push({ id:
|
|
22880
|
+
seen.add(id2.data);
|
|
22881
|
+
options.push({ id: id2.data, label: candidate.label });
|
|
22720
22882
|
}
|
|
22721
22883
|
return options;
|
|
22722
22884
|
}
|
|
22723
22885
|
function parseGrokModelState(value) {
|
|
22724
|
-
if (!isRecord5(value) ||
|
|
22886
|
+
if (!isRecord5(value) || typeof value.currentModelId !== "string" || !Array.isArray(value.availableModels)) {
|
|
22725
22887
|
return null;
|
|
22726
22888
|
}
|
|
22727
22889
|
let currentModel;
|
|
22728
22890
|
try {
|
|
22729
|
-
currentModel =
|
|
22891
|
+
currentModel = harnessModelRefSchema.parse({ id: value.currentModelId });
|
|
22730
22892
|
} catch {
|
|
22731
22893
|
return null;
|
|
22732
22894
|
}
|
|
@@ -22736,11 +22898,11 @@ function parseGrokModelState(value) {
|
|
|
22736
22898
|
const models = [];
|
|
22737
22899
|
let currentThinkingOptionId;
|
|
22738
22900
|
for (const candidate of value.availableModels) {
|
|
22739
|
-
if (!isRecord5(candidate) || !nonBlank(candidate.
|
|
22901
|
+
if (!isRecord5(candidate) || !nonBlank(candidate.name))
|
|
22740
22902
|
continue;
|
|
22741
22903
|
let ref;
|
|
22742
22904
|
try {
|
|
22743
|
-
ref =
|
|
22905
|
+
ref = harnessModelRefSchema.parse({ id: candidate.modelId });
|
|
22744
22906
|
} catch {
|
|
22745
22907
|
continue;
|
|
22746
22908
|
}
|
|
@@ -22756,14 +22918,14 @@ function parseGrokModelState(value) {
|
|
|
22756
22918
|
allThinking.set(option.id, option);
|
|
22757
22919
|
if (candidate.modelId === value.currentModelId && nonBlank(metadata.reasoningEffort)) {
|
|
22758
22920
|
const parsed = harnessThinkingOptionIdSchema.safeParse(metadata.reasoningEffort);
|
|
22759
|
-
if (parsed.success && options2.some(({ id }) =>
|
|
22921
|
+
if (parsed.success && options2.some(({ id: id2 }) => id2 === parsed.data)) {
|
|
22760
22922
|
currentThinkingOptionId = parsed.data;
|
|
22761
22923
|
}
|
|
22762
22924
|
}
|
|
22763
22925
|
models.push({
|
|
22764
22926
|
ref,
|
|
22765
22927
|
label: candidate.name,
|
|
22766
|
-
...options2.length > 0 ? { supportedThinkingOptionIds: options2.map(({ id }) =>
|
|
22928
|
+
...options2.length > 0 ? { supportedThinkingOptionIds: options2.map(({ id: id2 }) => id2) } : {}
|
|
22767
22929
|
});
|
|
22768
22930
|
}
|
|
22769
22931
|
if (!models.some(({ ref }) => ref.id === currentModel.id))
|
|
@@ -22790,9 +22952,9 @@ function modelStateFromSessionResponse(response) {
|
|
|
22790
22952
|
}
|
|
22791
22953
|
function stateForGrokModel(modelState, nativeState, model2 = modelState.currentModel, thinkingOptionId = modelState.currentThinkingOptionId, permissionModeId) {
|
|
22792
22954
|
const selectedModel = model2;
|
|
22793
|
-
const catalogModel = modelState.catalog
|
|
22794
|
-
const availableThinkingOptions = catalogModel?.supportedThinkingOptionIds?.flatMap((
|
|
22795
|
-
const option = modelState.catalog.thinkingOptions.find((candidate) => candidate.id ===
|
|
22955
|
+
const catalogModel = catalogModelForRef(modelState.catalog, selectedModel);
|
|
22956
|
+
const availableThinkingOptions = catalogModel?.supportedThinkingOptionIds?.flatMap((id2) => {
|
|
22957
|
+
const option = modelState.catalog.thinkingOptions.find((candidate) => candidate.id === id2);
|
|
22796
22958
|
return option ? [option] : [];
|
|
22797
22959
|
});
|
|
22798
22960
|
return {
|
|
@@ -22838,9 +23000,8 @@ function resolveGrokExecutable(input = {}) {
|
|
|
22838
23000
|
}
|
|
22839
23001
|
function grokInvocation(command, platform = process.platform, modelId2) {
|
|
22840
23002
|
const arguments_ = ["agent", "--no-leader"];
|
|
22841
|
-
|
|
22842
|
-
|
|
22843
|
-
arguments_.push("--model", trimmed);
|
|
23003
|
+
if (modelId2 !== void 0)
|
|
23004
|
+
arguments_.push("--model", modelId2);
|
|
22844
23005
|
arguments_.push("stdio");
|
|
22845
23006
|
return commandInvocation(command, arguments_, process.env, platform);
|
|
22846
23007
|
}
|
|
@@ -23615,12 +23776,12 @@ function collectIds(value) {
|
|
|
23615
23776
|
return [...new Set(ids)];
|
|
23616
23777
|
}
|
|
23617
23778
|
function grokSubagentOperation(name, title, rawInput) {
|
|
23618
|
-
const
|
|
23619
|
-
if (WAIT_TOOL_NAMES.has(
|
|
23779
|
+
const id2 = toolId(name, title);
|
|
23780
|
+
if (WAIT_TOOL_NAMES.has(id2) || KILL_TOOL_NAMES.has(id2))
|
|
23620
23781
|
return null;
|
|
23621
|
-
if (SEND_TOOL_NAMES.has(
|
|
23782
|
+
if (SEND_TOOL_NAMES.has(id2))
|
|
23622
23783
|
return "send";
|
|
23623
|
-
if (SPAWN_TOOL_NAMES.has(
|
|
23784
|
+
if (SPAWN_TOOL_NAMES.has(id2))
|
|
23624
23785
|
return "spawn";
|
|
23625
23786
|
if (isRecord8(rawInput) && rawInput.variant === "Task")
|
|
23626
23787
|
return "spawn";
|
|
@@ -23718,7 +23879,7 @@ function grokSubagentEventFromUpdate(update) {
|
|
|
23718
23879
|
function grokSubagentWaitSettlements(input) {
|
|
23719
23880
|
const ids = grokSubagentWaitIds(input.name, input.title, input.rawInput);
|
|
23720
23881
|
if (grokSubagentKill(input.name, input.title)) {
|
|
23721
|
-
return ids.map((
|
|
23882
|
+
return ids.map((id2) => ({ id: id2, status: "interrupted" }));
|
|
23722
23883
|
}
|
|
23723
23884
|
if (ids.length === 0)
|
|
23724
23885
|
return [];
|
|
@@ -23726,12 +23887,12 @@ function grokSubagentWaitSettlements(input) {
|
|
|
23726
23887
|
if (resultEntries.length > 0) {
|
|
23727
23888
|
const settled = [];
|
|
23728
23889
|
for (const result of resultEntries) {
|
|
23729
|
-
const
|
|
23890
|
+
const id2 = idField(result, "task_id") ?? idField(result, "subagent_id");
|
|
23730
23891
|
const status = mapTaskStatus(typeof result.status === "string" ? result.status : void 0);
|
|
23731
|
-
if (!
|
|
23892
|
+
if (!id2 || !status || status === "running" || status === "pending")
|
|
23732
23893
|
continue;
|
|
23733
23894
|
const resultSummary = bounded(typeof result.output === "string" ? result.output.trim() : void 0, SUMMARY_LIMIT);
|
|
23734
|
-
settled.push({ id, status, ...resultSummary ? { resultSummary } : {} });
|
|
23895
|
+
settled.push({ id: id2, status, ...resultSummary ? { resultSummary } : {} });
|
|
23735
23896
|
}
|
|
23736
23897
|
return settled;
|
|
23737
23898
|
}
|
|
@@ -23741,7 +23902,7 @@ function grokSubagentWaitSettlements(input) {
|
|
|
23741
23902
|
const overall = mapTaskStatus(taskOutputStatus(input.rawOutput, input.content));
|
|
23742
23903
|
if (!overall || overall === "running" || overall === "pending")
|
|
23743
23904
|
return [];
|
|
23744
|
-
return ids.map((
|
|
23905
|
+
return ids.map((id2) => ({ id: id2, status: overall }));
|
|
23745
23906
|
}
|
|
23746
23907
|
function taskOutputResults(rawOutput) {
|
|
23747
23908
|
if (!isRecord8(rawOutput))
|
|
@@ -23774,13 +23935,13 @@ function taskOutputTextSettlements(rawOutput, content, ids) {
|
|
|
23774
23935
|
const settled = [];
|
|
23775
23936
|
const pattern = /---\s*Task\s+(\S+)\s+\[(completed|failed|interrupted|cancelled|canceled)\]\s*---/gi;
|
|
23776
23937
|
for (const match of text.matchAll(pattern)) {
|
|
23777
|
-
const
|
|
23938
|
+
const id2 = match[1]?.trim();
|
|
23778
23939
|
const status = mapTaskStatus(match[2]);
|
|
23779
|
-
if (!
|
|
23940
|
+
if (!id2 || !status || status === "running" || status === "pending")
|
|
23780
23941
|
continue;
|
|
23781
|
-
if (!ids.includes(
|
|
23942
|
+
if (!ids.includes(id2))
|
|
23782
23943
|
continue;
|
|
23783
|
-
settled.push({ id, status });
|
|
23944
|
+
settled.push({ id: id2, status });
|
|
23784
23945
|
}
|
|
23785
23946
|
return settled;
|
|
23786
23947
|
}
|
|
@@ -25536,8 +25697,8 @@ var GrokAcpTransport = class {
|
|
|
25536
25697
|
throw new Error("Grok ACP Session already has an active Prompt");
|
|
25537
25698
|
if (this.#permissionConfirmation)
|
|
25538
25699
|
throw new GrokTransportError("unavailable", "Grok ACP Session has an active operation");
|
|
25539
|
-
const
|
|
25540
|
-
this.#activePrompt =
|
|
25700
|
+
const active2 = { onEvent, onPermission, onQuestion };
|
|
25701
|
+
this.#activePrompt = active2;
|
|
25541
25702
|
try {
|
|
25542
25703
|
return await connection.prompt({
|
|
25543
25704
|
sessionId: this.#sessionId,
|
|
@@ -25545,7 +25706,7 @@ var GrokAcpTransport = class {
|
|
|
25545
25706
|
});
|
|
25546
25707
|
} finally {
|
|
25547
25708
|
await yieldToEventLoop();
|
|
25548
|
-
if (this.#activePrompt ===
|
|
25709
|
+
if (this.#activePrompt === active2)
|
|
25549
25710
|
this.#activePrompt = null;
|
|
25550
25711
|
}
|
|
25551
25712
|
}
|
|
@@ -25557,8 +25718,8 @@ var GrokAcpTransport = class {
|
|
|
25557
25718
|
if (this.#activePrompt || this.#activeCompact || this.#permissionConfirmation) {
|
|
25558
25719
|
throw new GrokTransportError("unavailable", "Grok ACP Session already has an active operation");
|
|
25559
25720
|
}
|
|
25560
|
-
const
|
|
25561
|
-
this.#activeCompact =
|
|
25721
|
+
const active2 = { onEvent, cancellationRequested: false };
|
|
25722
|
+
this.#activeCompact = active2;
|
|
25562
25723
|
try {
|
|
25563
25724
|
const params = {
|
|
25564
25725
|
sessionId: this.#sessionId,
|
|
@@ -25573,13 +25734,13 @@ var GrokAcpTransport = class {
|
|
|
25573
25734
|
raw = await connection.request(GROK_COMPACT_CONVERSATION_FALLBACK_METHOD, params);
|
|
25574
25735
|
}
|
|
25575
25736
|
await yieldToEventLoop();
|
|
25576
|
-
return parseGrokCompactResult(raw,
|
|
25737
|
+
return parseGrokCompactResult(raw, active2.cancellationRequested);
|
|
25577
25738
|
} catch (error53) {
|
|
25578
25739
|
if (error53 instanceof GrokTransportError)
|
|
25579
25740
|
throw error53;
|
|
25580
25741
|
throw new GrokTransportError("unavailable", "Grok Native Compact failed", { cause: error53 });
|
|
25581
25742
|
} finally {
|
|
25582
|
-
if (this.#activeCompact ===
|
|
25743
|
+
if (this.#activeCompact === active2)
|
|
25583
25744
|
this.#activeCompact = null;
|
|
25584
25745
|
}
|
|
25585
25746
|
}
|
|
@@ -25724,10 +25885,10 @@ var GrokAcpTransport = class {
|
|
|
25724
25885
|
} catch (error53) {
|
|
25725
25886
|
throw RequestError.invalidParams(void 0, errorText(error53));
|
|
25726
25887
|
}
|
|
25727
|
-
const
|
|
25728
|
-
if (!
|
|
25888
|
+
const active2 = this.#activePrompt;
|
|
25889
|
+
if (!active2 || this.#closed || this.#closing || this.#replay !== null || this.#activeCompact !== null || request.sessionId !== this.#sessionId)
|
|
25729
25890
|
return { outcome: "cancelled" };
|
|
25730
|
-
return { ...await
|
|
25891
|
+
return { ...await active2.onQuestion(request) };
|
|
25731
25892
|
}
|
|
25732
25893
|
#fault(error53) {
|
|
25733
25894
|
this.#permissionConfirmation?.reject(error53);
|
|
@@ -25915,13 +26076,13 @@ var GrokSessionImport = class {
|
|
|
25915
26076
|
}
|
|
25916
26077
|
listCandidates() {
|
|
25917
26078
|
return this.#scope.read(async (signal) => {
|
|
25918
|
-
const
|
|
26079
|
+
const active2 = await this.#activeSessions(signal);
|
|
25919
26080
|
const candidates = [];
|
|
25920
26081
|
for (const [, directories] of await this.#sessionDirectories(signal)) {
|
|
25921
26082
|
if (directories.length !== 1 || !directories[0])
|
|
25922
26083
|
continue;
|
|
25923
26084
|
try {
|
|
25924
|
-
const candidate = await this.#candidate(directories[0],
|
|
26085
|
+
const candidate = await this.#candidate(directories[0], active2, signal);
|
|
25925
26086
|
if (candidate)
|
|
25926
26087
|
candidates.push(candidate);
|
|
25927
26088
|
} catch (error53) {
|
|
@@ -25958,7 +26119,7 @@ var GrokSessionImport = class {
|
|
|
25958
26119
|
}
|
|
25959
26120
|
/** IDs a live Grok process currently holds open, from Grok's own registry. */
|
|
25960
26121
|
async #activeSessions(signal) {
|
|
25961
|
-
const
|
|
26122
|
+
const active2 = /* @__PURE__ */ new Set();
|
|
25962
26123
|
let entries;
|
|
25963
26124
|
try {
|
|
25964
26125
|
entries = await readJson(path14.join(this.#home(), "active_sessions.json"), signal);
|
|
@@ -25966,15 +26127,15 @@ var GrokSessionImport = class {
|
|
|
25966
26127
|
signal.throwIfAborted();
|
|
25967
26128
|
if (isStorageAccessError(error53))
|
|
25968
26129
|
throw error53;
|
|
25969
|
-
return
|
|
26130
|
+
return active2;
|
|
25970
26131
|
}
|
|
25971
26132
|
if (!Array.isArray(entries))
|
|
25972
|
-
return
|
|
26133
|
+
return active2;
|
|
25973
26134
|
for (const entry of entries) {
|
|
25974
26135
|
if (isRecord15(entry) && typeof entry.session_id === "string" && processAlive(entry.pid))
|
|
25975
|
-
|
|
26136
|
+
active2.add(entry.session_id);
|
|
25976
26137
|
}
|
|
25977
|
-
return
|
|
26138
|
+
return active2;
|
|
25978
26139
|
}
|
|
25979
26140
|
/** Session ID to every directory claiming it. Enumerated links are not followed. */
|
|
25980
26141
|
async #sessionDirectories(signal) {
|
|
@@ -26008,7 +26169,7 @@ var GrokSessionImport = class {
|
|
|
26008
26169
|
}
|
|
26009
26170
|
return found;
|
|
26010
26171
|
}
|
|
26011
|
-
async #candidate(sessionDirectory,
|
|
26172
|
+
async #candidate(sessionDirectory, active2, signal) {
|
|
26012
26173
|
signal.throwIfAborted();
|
|
26013
26174
|
const nativeSessionId = path14.basename(sessionDirectory);
|
|
26014
26175
|
const files = [
|
|
@@ -26042,7 +26203,7 @@ var GrokSessionImport = class {
|
|
|
26042
26203
|
title: sessionImportTitle(summary.generated_title) ?? sessionImportTitle(summary.session_summary) ?? sessionImportTitle(prompt),
|
|
26043
26204
|
updatedAt: updatedAt ?? updates.mtimeMs,
|
|
26044
26205
|
// Grok registers open Sessions with their process. Absence is not proof of idleness.
|
|
26045
|
-
running:
|
|
26206
|
+
running: active2.has(nativeSessionId) ? true : null
|
|
26046
26207
|
});
|
|
26047
26208
|
} catch (error53) {
|
|
26048
26209
|
signal.throwIfAborted();
|
|
@@ -26110,16 +26271,16 @@ var GrokSubagentLifecycle = class {
|
|
|
26110
26271
|
return subagent;
|
|
26111
26272
|
}
|
|
26112
26273
|
bindNativeId(turnId, input) {
|
|
26113
|
-
for (const [callId,
|
|
26114
|
-
const current =
|
|
26274
|
+
for (const [callId, active2] of this.#delegations) {
|
|
26275
|
+
const current = active2.item.subagents[0];
|
|
26115
26276
|
if (!current)
|
|
26116
26277
|
continue;
|
|
26117
26278
|
if (current.nativeSubagentId === input.nativeSubagentId) {
|
|
26118
26279
|
return this.update(turnId, callId, input);
|
|
26119
26280
|
}
|
|
26120
26281
|
}
|
|
26121
|
-
for (const [callId,
|
|
26122
|
-
const current =
|
|
26282
|
+
for (const [callId, active2] of this.#delegations) {
|
|
26283
|
+
const current = active2.item.subagents[0];
|
|
26123
26284
|
if (!current || current.nativeSubagentId)
|
|
26124
26285
|
continue;
|
|
26125
26286
|
if (input.description && current.description === input.description) {
|
|
@@ -26129,10 +26290,10 @@ var GrokSubagentLifecycle = class {
|
|
|
26129
26290
|
return void 0;
|
|
26130
26291
|
}
|
|
26131
26292
|
update(turnId, callId, patch) {
|
|
26132
|
-
const
|
|
26133
|
-
if (!
|
|
26293
|
+
const active2 = this.#delegations.get(callId);
|
|
26294
|
+
if (!active2)
|
|
26134
26295
|
return void 0;
|
|
26135
|
-
const current =
|
|
26296
|
+
const current = active2.item.subagents[0];
|
|
26136
26297
|
if (!current)
|
|
26137
26298
|
throw new Error("Grok Subagent delegation has no Agent state");
|
|
26138
26299
|
if (patch.nativeSubagentId)
|
|
@@ -26148,20 +26309,20 @@ var GrokSubagentLifecycle = class {
|
|
|
26148
26309
|
...patch.resultSummary ? { resultSummary: patch.resultSummary } : {},
|
|
26149
26310
|
...patch.status ? { status: patch.status } : {}
|
|
26150
26311
|
};
|
|
26151
|
-
|
|
26312
|
+
active2.item = { ...active2.item, subagents: [subagent] };
|
|
26152
26313
|
this.#emit({
|
|
26153
26314
|
type: "item.updated",
|
|
26154
26315
|
turnId,
|
|
26155
|
-
itemId:
|
|
26156
|
-
update: { type: "subagents.replace", subagents:
|
|
26316
|
+
itemId: active2.item.itemId,
|
|
26317
|
+
update: { type: "subagents.replace", subagents: active2.item.subagents }
|
|
26157
26318
|
});
|
|
26158
26319
|
this.#emitState(subagent);
|
|
26159
26320
|
return subagent;
|
|
26160
26321
|
}
|
|
26161
26322
|
completeSpawn(turnId, callId, input) {
|
|
26162
|
-
const
|
|
26163
|
-
const background = input.background ??
|
|
26164
|
-
const keepRunning = !input.failed && !input.cancellationRequested && (background ||
|
|
26323
|
+
const active2 = this.#delegations.get(callId);
|
|
26324
|
+
const background = input.background ?? active2?.item.subagents[0]?.background ?? true;
|
|
26325
|
+
const keepRunning = !input.failed && !input.cancellationRequested && (background || active2?.item.operation === "send");
|
|
26165
26326
|
if (keepRunning) {
|
|
26166
26327
|
return this.update(turnId, callId, {
|
|
26167
26328
|
status: "running",
|
|
@@ -26186,11 +26347,11 @@ var GrokSubagentLifecycle = class {
|
|
|
26186
26347
|
return void 0;
|
|
26187
26348
|
}
|
|
26188
26349
|
complete(turnId, callId, input) {
|
|
26189
|
-
const
|
|
26190
|
-
if (!
|
|
26350
|
+
const active2 = this.#delegations.get(callId);
|
|
26351
|
+
if (!active2)
|
|
26191
26352
|
return void 0;
|
|
26192
26353
|
this.#delegations.delete(callId);
|
|
26193
|
-
const current =
|
|
26354
|
+
const current = active2.item.subagents[0];
|
|
26194
26355
|
if (!current)
|
|
26195
26356
|
throw new Error("Grok Subagent delegation has no Agent state");
|
|
26196
26357
|
const status = input.status ?? (input.cancellationRequested ? "interrupted" : input.failed ? "failed" : input.keepRunning ? "running" : "completed");
|
|
@@ -26203,7 +26364,7 @@ var GrokSubagentLifecycle = class {
|
|
|
26203
26364
|
...nativeSubagentId ? { nativeSubagentId, subagentId: nativeSubagentId } : {},
|
|
26204
26365
|
...input.resultSummary ? { resultSummary: input.resultSummary } : {}
|
|
26205
26366
|
};
|
|
26206
|
-
const item = { ...
|
|
26367
|
+
const item = { ...active2.item, subagents: [subagent] };
|
|
26207
26368
|
this.#emit({
|
|
26208
26369
|
type: "item.updated",
|
|
26209
26370
|
turnId,
|
|
@@ -26216,20 +26377,20 @@ var GrokSubagentLifecycle = class {
|
|
|
26216
26377
|
return subagent;
|
|
26217
26378
|
}
|
|
26218
26379
|
finalize(turnId, outcome) {
|
|
26219
|
-
for (const [callId,
|
|
26380
|
+
for (const [callId, active2] of this.#delegations) {
|
|
26220
26381
|
this.#delegations.delete(callId);
|
|
26221
|
-
const current =
|
|
26382
|
+
const current = active2.item.subagents[0];
|
|
26222
26383
|
if (!current)
|
|
26223
26384
|
continue;
|
|
26224
26385
|
const status = outcome.status === "succeeded" ? current.status : outcome.status === "cancelled" ? "interrupted" : "failed";
|
|
26225
|
-
const item = { ...
|
|
26386
|
+
const item = { ...active2.item, subagents: [{ ...current, status }] };
|
|
26226
26387
|
this.#emit({ type: "item.completed", turnId, snapshot: { item, outcome } });
|
|
26227
26388
|
this.#emitState({ ...current, status });
|
|
26228
26389
|
}
|
|
26229
26390
|
}
|
|
26230
26391
|
#callIdForNative(nativeSubagentId) {
|
|
26231
|
-
for (const [callId,
|
|
26232
|
-
if (
|
|
26392
|
+
for (const [callId, active2] of this.#delegations) {
|
|
26393
|
+
if (active2.item.subagents[0]?.nativeSubagentId === nativeSubagentId)
|
|
26233
26394
|
return callId;
|
|
26234
26395
|
}
|
|
26235
26396
|
return void 0;
|
|
@@ -26952,7 +27113,7 @@ var GrokHarnessSession = class {
|
|
|
26952
27113
|
const completion = new Promise((resolve) => {
|
|
26953
27114
|
resolveCompletion = resolve;
|
|
26954
27115
|
});
|
|
26955
|
-
const
|
|
27116
|
+
const active2 = {
|
|
26956
27117
|
command,
|
|
26957
27118
|
questions: new GrokQuestions(command.turnId, this.#randomUUID, (output) => this.#channel.emit(output)),
|
|
26958
27119
|
usage: new GrokTurnUsage(this.#usage, this.#snapshot.turns.length === 0),
|
|
@@ -26973,9 +27134,9 @@ var GrokHarnessSession = class {
|
|
|
26973
27134
|
completion,
|
|
26974
27135
|
resolveCompletion
|
|
26975
27136
|
};
|
|
26976
|
-
this.#active =
|
|
27137
|
+
this.#active = active2;
|
|
26977
27138
|
this.#event({ type: "turn.started", turnId: command.turnId });
|
|
26978
|
-
void this.#transport.runTurn(text, (event) => this.#handleEvent(
|
|
27139
|
+
void this.#transport.runTurn(text, (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, {
|
|
26979
27140
|
status: "failed",
|
|
26980
27141
|
error: normalizeError(error53, "nativeFailure")
|
|
26981
27142
|
}));
|
|
@@ -27042,7 +27203,7 @@ var GrokHarnessSession = class {
|
|
|
27042
27203
|
const completion = new Promise((resolve) => {
|
|
27043
27204
|
resolveCompletion = resolve;
|
|
27044
27205
|
});
|
|
27045
|
-
const
|
|
27206
|
+
const active2 = {
|
|
27046
27207
|
command: { type: "turn.start", turnId: command.turnId, input: [] },
|
|
27047
27208
|
questions: new GrokQuestions(command.turnId, this.#randomUUID, (output) => this.#channel.emit(output)),
|
|
27048
27209
|
agent: null,
|
|
@@ -27062,20 +27223,20 @@ var GrokHarnessSession = class {
|
|
|
27062
27223
|
completion,
|
|
27063
27224
|
resolveCompletion
|
|
27064
27225
|
};
|
|
27065
|
-
this.#active =
|
|
27226
|
+
this.#active = active2;
|
|
27066
27227
|
this.#event({ type: "turn.started", turnId: command.turnId });
|
|
27067
|
-
void this.#transport.compact(userContext, (event) => this.#handleEvent(
|
|
27228
|
+
void this.#transport.compact(userContext, (event) => this.#handleEvent(active2, event)).then((result) => this.#settleManualCompact(active2, result), (error53) => this.#finish(active2, active2.compactionTerminal ? this.#turnOutcomeFromCompaction(active2.compactionTerminal) : {
|
|
27068
27229
|
status: "failed",
|
|
27069
27230
|
error: normalizeError(error53, "nativeFailure")
|
|
27070
27231
|
}));
|
|
27071
27232
|
return { ok: true, value: { turnId: command.turnId } };
|
|
27072
27233
|
}
|
|
27073
|
-
#settleManualCompact(
|
|
27074
|
-
if (this.#active !==
|
|
27234
|
+
#settleManualCompact(active2, result) {
|
|
27235
|
+
if (this.#active !== active2)
|
|
27075
27236
|
return;
|
|
27076
|
-
const terminal =
|
|
27237
|
+
const terminal = active2.compactionTerminal;
|
|
27077
27238
|
if (!terminal) {
|
|
27078
|
-
this.#completeCompaction(
|
|
27239
|
+
this.#completeCompaction(active2, {
|
|
27079
27240
|
type: "compaction.completed",
|
|
27080
27241
|
outcome: result.outcome,
|
|
27081
27242
|
...result.tokensBefore !== void 0 ? { tokensBefore: result.tokensBefore } : {},
|
|
@@ -27084,7 +27245,7 @@ var GrokHarnessSession = class {
|
|
|
27084
27245
|
...result.errorMessage ? { errorMessage: result.errorMessage } : {}
|
|
27085
27246
|
});
|
|
27086
27247
|
}
|
|
27087
|
-
this.#finish(
|
|
27248
|
+
this.#finish(active2, terminal ? this.#turnOutcomeFromCompaction(terminal) : result.outcome === "succeeded" ? { status: "succeeded" } : result.outcome === "cancelled" ? { status: "cancelled", reason: "Context compaction was cancelled" } : {
|
|
27088
27249
|
status: "failed",
|
|
27089
27250
|
error: {
|
|
27090
27251
|
code: "nativeFailure",
|
|
@@ -27158,7 +27319,7 @@ var GrokHarnessSession = class {
|
|
|
27158
27319
|
this.#configuring = true;
|
|
27159
27320
|
try {
|
|
27160
27321
|
const contextWindow = this.#modelState.defaultContextWindowTokensByModel.get(model2.id);
|
|
27161
|
-
await this.#transport.setModel(
|
|
27322
|
+
await this.#transport.setModel(model2.id, thinkingOptionId, contextWindow);
|
|
27162
27323
|
if (contextWindow !== void 0) {
|
|
27163
27324
|
this.#modelState.contextWindowTokensByModel = new Map([
|
|
27164
27325
|
...this.#modelState.contextWindowTokensByModel,
|
|
@@ -27216,15 +27377,15 @@ var GrokHarnessSession = class {
|
|
|
27216
27377
|
}
|
|
27217
27378
|
}
|
|
27218
27379
|
async #cancel(command) {
|
|
27219
|
-
const
|
|
27220
|
-
if (!
|
|
27380
|
+
const active2 = this.#active;
|
|
27381
|
+
if (!active2 || active2.command.turnId !== command.turnId) {
|
|
27221
27382
|
return { ok: false, error: invalidState("Grok Turn Cancel must reference the active Turn") };
|
|
27222
27383
|
}
|
|
27223
|
-
if (
|
|
27384
|
+
if (active2.cancellationRequested)
|
|
27224
27385
|
return { ok: true, value: { cancellationRequested: true } };
|
|
27225
|
-
|
|
27226
|
-
|
|
27227
|
-
for (const approval of
|
|
27386
|
+
active2.cancellationRequested = true;
|
|
27387
|
+
active2.questions.cancel();
|
|
27388
|
+
for (const approval of active2.approvals.values()) {
|
|
27228
27389
|
approval.resolve({ outcome: { outcome: "cancelled" } });
|
|
27229
27390
|
}
|
|
27230
27391
|
try {
|
|
@@ -27235,11 +27396,11 @@ var GrokHarnessSession = class {
|
|
|
27235
27396
|
}
|
|
27236
27397
|
}
|
|
27237
27398
|
async #respond(command) {
|
|
27238
|
-
const
|
|
27239
|
-
if (
|
|
27240
|
-
return
|
|
27241
|
-
const pending =
|
|
27242
|
-
if (!
|
|
27399
|
+
const active2 = this.#active;
|
|
27400
|
+
if (active2?.questions.has(command.interactionId))
|
|
27401
|
+
return active2.questions.respond(command);
|
|
27402
|
+
const pending = active2?.approvals.get(command.interactionId);
|
|
27403
|
+
if (!active2 || !pending)
|
|
27243
27404
|
return { ok: false, error: invalidState("Grok Interaction is not pending") };
|
|
27244
27405
|
if (command.response.type !== "approval") {
|
|
27245
27406
|
return {
|
|
@@ -27264,18 +27425,18 @@ var GrokHarnessSession = class {
|
|
|
27264
27425
|
retryable: false
|
|
27265
27426
|
}
|
|
27266
27427
|
};
|
|
27267
|
-
|
|
27428
|
+
active2.approvals.delete(command.interactionId);
|
|
27268
27429
|
pending.resolve({ outcome: { outcome: "selected", optionId: option.optionId } });
|
|
27269
27430
|
this.#event({
|
|
27270
27431
|
type: "interaction.closed",
|
|
27271
27432
|
interactionId: command.interactionId,
|
|
27272
|
-
turnId:
|
|
27433
|
+
turnId: active2.command.turnId,
|
|
27273
27434
|
reason: "responded"
|
|
27274
27435
|
});
|
|
27275
27436
|
return { ok: true, value: { accepted: true } };
|
|
27276
27437
|
}
|
|
27277
|
-
#requestPermission(
|
|
27278
|
-
if (this.#active !==
|
|
27438
|
+
#requestPermission(active2, request) {
|
|
27439
|
+
if (this.#active !== active2 || active2.cancellationRequested) {
|
|
27279
27440
|
return Promise.resolve({ outcome: { outcome: "cancelled" } });
|
|
27280
27441
|
}
|
|
27281
27442
|
const projectedOptions = projectGrokPermissionOptions(request.options);
|
|
@@ -27283,95 +27444,95 @@ var GrokHarnessSession = class {
|
|
|
27283
27444
|
return Promise.resolve({ outcome: { outcome: "cancelled" } });
|
|
27284
27445
|
}
|
|
27285
27446
|
const interactionId = hostInteractionIdSchema.parse(this.#randomUUID());
|
|
27286
|
-
const options = new Map(projectedOptions.map(({ id, option }) => [
|
|
27287
|
-
const actions = projectedOptions.map(({ id, label, effect }) => ({ id, label, effect }));
|
|
27447
|
+
const options = new Map(projectedOptions.map(({ id: id2, option }) => [id2, option]));
|
|
27448
|
+
const actions = projectedOptions.map(({ id: id2, label, effect }) => ({ id: id2, label, effect }));
|
|
27288
27449
|
const interaction = {
|
|
27289
27450
|
type: "approval",
|
|
27290
27451
|
interactionId,
|
|
27291
|
-
turnId:
|
|
27452
|
+
turnId: active2.command.turnId,
|
|
27292
27453
|
title: request.request.toolCall.title ?? "Grok Tool",
|
|
27293
27454
|
subject: { type: "nativeAction" },
|
|
27294
27455
|
actions
|
|
27295
27456
|
};
|
|
27296
27457
|
return new Promise((resolve) => {
|
|
27297
|
-
|
|
27458
|
+
active2.approvals.set(interactionId, { interaction, options, resolve });
|
|
27298
27459
|
this.#channel.emit({ kind: "interaction", interaction });
|
|
27299
27460
|
});
|
|
27300
27461
|
}
|
|
27301
|
-
#handleEvent(
|
|
27302
|
-
if (this.#active !==
|
|
27462
|
+
#handleEvent(active2, event) {
|
|
27463
|
+
if (this.#active !== active2 || this.#phase !== "open")
|
|
27303
27464
|
return;
|
|
27304
27465
|
if (event.type === "interaction.resolved") {
|
|
27305
|
-
|
|
27466
|
+
active2.questions.withdraw(event.toolCallId);
|
|
27306
27467
|
return;
|
|
27307
27468
|
}
|
|
27308
|
-
const requestUsage =
|
|
27469
|
+
const requestUsage = active2.usage?.observe(event);
|
|
27309
27470
|
if (requestUsage) {
|
|
27310
|
-
this.#publishUsage(requestUsage,
|
|
27311
|
-
void this.#refreshCost(
|
|
27471
|
+
this.#publishUsage(requestUsage, active2.command.turnId, true);
|
|
27472
|
+
void this.#refreshCost(active2);
|
|
27312
27473
|
}
|
|
27313
27474
|
const contextUsage = usageFromUpdate(event.type === "usage" ? event.update : void 0, event.metadata, this.#state.effectiveModel ? this.#modelState.contextWindowTokensByModel.get(this.#state.effectiveModel.id) : void 0);
|
|
27314
27475
|
if (contextUsage)
|
|
27315
|
-
this.#publishUsage(contextUsage,
|
|
27476
|
+
this.#publishUsage(contextUsage, active2.command.turnId);
|
|
27316
27477
|
if (event.type === "agent.text")
|
|
27317
|
-
this.#appendAgent(
|
|
27478
|
+
this.#appendAgent(active2, event.text, event.messageId);
|
|
27318
27479
|
else if (event.type === "agent.thought")
|
|
27319
|
-
this.#appendReasoning(
|
|
27480
|
+
this.#appendReasoning(active2, event.text, event.messageId);
|
|
27320
27481
|
else if (event.type === "tool.call")
|
|
27321
|
-
this.#startTool(
|
|
27482
|
+
this.#startTool(active2, event);
|
|
27322
27483
|
else if (event.type === "tool.update")
|
|
27323
|
-
this.#updateTool(
|
|
27484
|
+
this.#updateTool(active2, event);
|
|
27324
27485
|
else if (event.type === "subagent.spawned")
|
|
27325
|
-
this.#bindSpawnedSubagent(
|
|
27486
|
+
this.#bindSpawnedSubagent(active2, event);
|
|
27326
27487
|
else if (event.type === "subagent.finished")
|
|
27327
|
-
this.#finishNativeSubagent(
|
|
27488
|
+
this.#finishNativeSubagent(active2, event);
|
|
27328
27489
|
else if (event.type === "compaction.started")
|
|
27329
|
-
this.#startCompaction(
|
|
27490
|
+
this.#startCompaction(active2, event);
|
|
27330
27491
|
else if (event.type === "compaction.completed") {
|
|
27331
|
-
|
|
27332
|
-
this.#completeCompaction(
|
|
27492
|
+
active2.compactionTerminal = event;
|
|
27493
|
+
this.#completeCompaction(active2, event);
|
|
27333
27494
|
} else if (event.type === "usage" || event.type === "turn.completed")
|
|
27334
27495
|
return;
|
|
27335
27496
|
}
|
|
27336
|
-
async #refreshCost(
|
|
27497
|
+
async #refreshCost(active2) {
|
|
27337
27498
|
const request = ++this.#costRequest;
|
|
27338
27499
|
try {
|
|
27339
27500
|
const totalCostUsd = sessionCostFromNative(await this.#transport.getUsage(), this.#initialCostUsd);
|
|
27340
|
-
if (this.#active !==
|
|
27501
|
+
if (this.#active !== active2 || this.#phase !== "open" || request !== this.#costRequest)
|
|
27341
27502
|
return;
|
|
27342
27503
|
if (totalCostUsd !== void 0)
|
|
27343
|
-
this.#publishUsage({ totalCostUsd },
|
|
27504
|
+
this.#publishUsage({ totalCostUsd }, active2.command.turnId);
|
|
27344
27505
|
} catch {
|
|
27345
27506
|
}
|
|
27346
27507
|
}
|
|
27347
|
-
#startCompaction(
|
|
27348
|
-
if (
|
|
27508
|
+
#startCompaction(active2, event) {
|
|
27509
|
+
if (active2.compactionItem)
|
|
27349
27510
|
return;
|
|
27350
|
-
this.#completeReasoning(
|
|
27351
|
-
this.#completeAgent(
|
|
27511
|
+
this.#completeReasoning(active2, { status: "succeeded" });
|
|
27512
|
+
this.#completeAgent(active2, { status: "succeeded" });
|
|
27352
27513
|
if (event.contextWindowTokens !== void 0) {
|
|
27353
|
-
|
|
27514
|
+
active2.compactionContextWindow = event.contextWindowTokens;
|
|
27354
27515
|
}
|
|
27355
27516
|
const item = {
|
|
27356
27517
|
type: "contextCompaction",
|
|
27357
27518
|
itemId: hostItemIdSchema.parse(this.#randomUUID())
|
|
27358
27519
|
};
|
|
27359
|
-
|
|
27360
|
-
this.#event({ type: "item.started", turnId:
|
|
27520
|
+
active2.compactionItem = item;
|
|
27521
|
+
this.#event({ type: "item.started", turnId: active2.command.turnId, item });
|
|
27361
27522
|
}
|
|
27362
|
-
#completeCompaction(
|
|
27363
|
-
if (!
|
|
27364
|
-
this.#startCompaction(
|
|
27523
|
+
#completeCompaction(active2, event) {
|
|
27524
|
+
if (!active2.compactionItem) {
|
|
27525
|
+
this.#startCompaction(active2, {
|
|
27365
27526
|
type: "compaction.started",
|
|
27366
27527
|
...event.contextWindowTokens !== void 0 ? { contextWindowTokens: event.contextWindowTokens } : {}
|
|
27367
27528
|
});
|
|
27368
27529
|
}
|
|
27369
|
-
const item =
|
|
27530
|
+
const item = active2.compactionItem;
|
|
27370
27531
|
if (!item)
|
|
27371
27532
|
return;
|
|
27372
|
-
|
|
27373
|
-
const contextWindowTokens = event.contextWindowTokens ??
|
|
27374
|
-
|
|
27533
|
+
active2.compactionItem = null;
|
|
27534
|
+
const contextWindowTokens = event.contextWindowTokens ?? active2.compactionContextWindow ?? (this.#state.effectiveModel ? this.#modelState.contextWindowTokensByModel.get(this.#state.effectiveModel.id) : void 0);
|
|
27535
|
+
active2.compactionContextWindow = void 0;
|
|
27375
27536
|
const outcome = event.outcome === "succeeded" ? { status: "succeeded" } : event.outcome === "cancelled" ? { status: "cancelled", reason: "Context compaction was cancelled" } : {
|
|
27376
27537
|
status: "failed",
|
|
27377
27538
|
error: {
|
|
@@ -27380,62 +27541,62 @@ var GrokHarnessSession = class {
|
|
|
27380
27541
|
retryable: true
|
|
27381
27542
|
}
|
|
27382
27543
|
};
|
|
27383
|
-
this.#completeItem(
|
|
27544
|
+
this.#completeItem(active2, item, outcome);
|
|
27384
27545
|
if (event.outcome !== "succeeded")
|
|
27385
27546
|
return;
|
|
27386
27547
|
const usage = usageFromCompact(event.tokensAfter, contextWindowTokens);
|
|
27387
27548
|
if (usage)
|
|
27388
|
-
this.#publishUsage(usage,
|
|
27549
|
+
this.#publishUsage(usage, active2.command.turnId);
|
|
27389
27550
|
}
|
|
27390
|
-
#appendAgent(
|
|
27551
|
+
#appendAgent(active2, text, messageId) {
|
|
27391
27552
|
const identity2 = messageId ?? "agent";
|
|
27392
|
-
if (
|
|
27393
|
-
this.#completeReasoning(
|
|
27394
|
-
this.#completeAgent(
|
|
27395
|
-
|
|
27553
|
+
if (active2.agentMessageId !== identity2) {
|
|
27554
|
+
this.#completeReasoning(active2, { status: "succeeded" });
|
|
27555
|
+
this.#completeAgent(active2, { status: "succeeded" });
|
|
27556
|
+
active2.agentMessageId = identity2;
|
|
27396
27557
|
}
|
|
27397
|
-
if (!
|
|
27398
|
-
|
|
27558
|
+
if (!active2.agent) {
|
|
27559
|
+
active2.agent = {
|
|
27399
27560
|
type: "agentMessage",
|
|
27400
27561
|
itemId: hostItemIdSchema.parse(this.#randomUUID()),
|
|
27401
27562
|
text: ""
|
|
27402
27563
|
};
|
|
27403
|
-
|
|
27404
|
-
this.#event({ type: "item.started", turnId:
|
|
27564
|
+
active2.agentMedia = new LocalMediaMarkdownStream(this.#mediaRoots);
|
|
27565
|
+
this.#event({ type: "item.started", turnId: active2.command.turnId, item: active2.agent });
|
|
27405
27566
|
}
|
|
27406
|
-
const delta =
|
|
27407
|
-
this.#publishAgent(
|
|
27567
|
+
const delta = active2.agentMedia?.append(text) ?? "";
|
|
27568
|
+
this.#publishAgent(active2, delta);
|
|
27408
27569
|
}
|
|
27409
|
-
#publishAgent(
|
|
27410
|
-
if (!
|
|
27570
|
+
#publishAgent(active2, delta) {
|
|
27571
|
+
if (!active2.agent || !active2.agentMedia || !delta)
|
|
27411
27572
|
return;
|
|
27412
|
-
|
|
27573
|
+
active2.agent = { ...active2.agent, text: active2.agentMedia.text };
|
|
27413
27574
|
this.#event({
|
|
27414
27575
|
type: "item.updated",
|
|
27415
|
-
turnId:
|
|
27416
|
-
itemId:
|
|
27576
|
+
turnId: active2.command.turnId,
|
|
27577
|
+
itemId: active2.agent.itemId,
|
|
27417
27578
|
update: { type: "text.append", text: delta }
|
|
27418
27579
|
});
|
|
27419
27580
|
}
|
|
27420
|
-
#appendReasoning(
|
|
27581
|
+
#appendReasoning(active2, text, messageId) {
|
|
27421
27582
|
const identity2 = messageId ?? "thought";
|
|
27422
|
-
if (
|
|
27423
|
-
this.#completeReasoning(
|
|
27424
|
-
|
|
27583
|
+
if (active2.reasoningMessageId !== identity2) {
|
|
27584
|
+
this.#completeReasoning(active2, { status: "succeeded" });
|
|
27585
|
+
active2.reasoningMessageId = identity2;
|
|
27425
27586
|
}
|
|
27426
|
-
if (!
|
|
27427
|
-
|
|
27587
|
+
if (!active2.reasoning) {
|
|
27588
|
+
active2.reasoning = {
|
|
27428
27589
|
type: "reasoning",
|
|
27429
27590
|
itemId: hostItemIdSchema.parse(this.#randomUUID()),
|
|
27430
27591
|
text: ""
|
|
27431
27592
|
};
|
|
27432
|
-
this.#event({ type: "item.started", turnId:
|
|
27593
|
+
this.#event({ type: "item.started", turnId: active2.command.turnId, item: active2.reasoning });
|
|
27433
27594
|
}
|
|
27434
|
-
|
|
27595
|
+
active2.reasoning = { ...active2.reasoning, text: active2.reasoning.text + text };
|
|
27435
27596
|
this.#event({
|
|
27436
27597
|
type: "item.updated",
|
|
27437
|
-
turnId:
|
|
27438
|
-
itemId:
|
|
27598
|
+
turnId: active2.command.turnId,
|
|
27599
|
+
itemId: active2.reasoning.itemId,
|
|
27439
27600
|
update: { type: "text.append", text }
|
|
27440
27601
|
});
|
|
27441
27602
|
}
|
|
@@ -27445,16 +27606,16 @@ var GrokHarnessSession = class {
|
|
|
27445
27606
|
emit: (event) => this.#event(event)
|
|
27446
27607
|
});
|
|
27447
27608
|
}
|
|
27448
|
-
#startTool(
|
|
27449
|
-
this.#completeReasoning(
|
|
27450
|
-
this.#completeAgent(
|
|
27609
|
+
#startTool(active2, event) {
|
|
27610
|
+
this.#completeReasoning(active2, { status: "succeeded" });
|
|
27611
|
+
this.#completeAgent(active2, { status: "succeeded" });
|
|
27451
27612
|
const operation = grokSubagentOperation(event.name, event.title, event.rawInput);
|
|
27452
27613
|
if (operation) {
|
|
27453
27614
|
const prompt = grokSubagentPrompt(event.rawInput);
|
|
27454
27615
|
const role = grokSubagentRole(event.rawInput);
|
|
27455
27616
|
const nativeSubagentId = grokNativeSubagentId(event.rawInput);
|
|
27456
27617
|
const model2 = grokSubagentModel(event.rawInput);
|
|
27457
|
-
|
|
27618
|
+
active2.subagents.start(active2.command.turnId, {
|
|
27458
27619
|
callId: event.callId,
|
|
27459
27620
|
operation,
|
|
27460
27621
|
description: grokSubagentDescription(event.rawInput, event.title),
|
|
@@ -27466,7 +27627,7 @@ var GrokHarnessSession = class {
|
|
|
27466
27627
|
...nativeSubagentId ? { nativeSubagentId } : {}
|
|
27467
27628
|
});
|
|
27468
27629
|
if (event.status === "completed" || event.status === "failed") {
|
|
27469
|
-
this.#completeSubagentTool(
|
|
27630
|
+
this.#completeSubagentTool(active2, event.callId, event.status, event);
|
|
27470
27631
|
}
|
|
27471
27632
|
return;
|
|
27472
27633
|
}
|
|
@@ -27481,15 +27642,15 @@ var GrokHarnessSession = class {
|
|
|
27481
27642
|
const projection = projectGrokToolOutput(event.content, event.rawOutput, this.#toolOutputLimit);
|
|
27482
27643
|
if (hasGrokToolProjection(projection))
|
|
27483
27644
|
item = applyGrokToolProjection(item, projection);
|
|
27484
|
-
|
|
27485
|
-
this.#event({ type: "item.started", turnId:
|
|
27645
|
+
active2.tools.set(event.callId, { item, ...event.status ? { status: event.status } : {} });
|
|
27646
|
+
this.#event({ type: "item.started", turnId: active2.command.turnId, item });
|
|
27486
27647
|
if (event.status === "completed" || event.status === "failed") {
|
|
27487
|
-
this.#completeTool(
|
|
27648
|
+
this.#completeTool(active2, event.callId, event.status, event.content, event.rawOutput);
|
|
27488
27649
|
}
|
|
27489
27650
|
}
|
|
27490
|
-
#updateTool(
|
|
27491
|
-
if (!
|
|
27492
|
-
this.#startTool(
|
|
27651
|
+
#updateTool(active2, event) {
|
|
27652
|
+
if (!active2.subagents.has(event.callId) && !active2.tools.has(event.callId) && grokSubagentOperation(event.name, event.title, event.rawInput)) {
|
|
27653
|
+
this.#startTool(active2, {
|
|
27493
27654
|
type: "tool.call",
|
|
27494
27655
|
callId: event.callId,
|
|
27495
27656
|
title: event.title ?? "Grok Subagent",
|
|
@@ -27502,14 +27663,14 @@ var GrokHarnessSession = class {
|
|
|
27502
27663
|
});
|
|
27503
27664
|
return;
|
|
27504
27665
|
}
|
|
27505
|
-
if (
|
|
27666
|
+
if (active2.subagents.has(event.callId)) {
|
|
27506
27667
|
if (event.status === "completed" || event.status === "failed") {
|
|
27507
|
-
this.#completeSubagentTool(
|
|
27668
|
+
this.#completeSubagentTool(active2, event.callId, event.status, event);
|
|
27508
27669
|
return;
|
|
27509
27670
|
}
|
|
27510
27671
|
const role = grokSubagentRole(event.rawInput);
|
|
27511
27672
|
const nativeSubagentId = grokNativeSubagentId(event.rawInput, event.rawOutput, event.content);
|
|
27512
|
-
|
|
27673
|
+
active2.subagents.update(active2.command.turnId, event.callId, {
|
|
27513
27674
|
...subagentConfiguration(event.rawInput),
|
|
27514
27675
|
...subagentConfiguration(event.rawOutput),
|
|
27515
27676
|
...event.title ? { description: grokSubagentDescription(event.rawInput, event.title) } : {},
|
|
@@ -27518,7 +27679,7 @@ var GrokHarnessSession = class {
|
|
|
27518
27679
|
});
|
|
27519
27680
|
return;
|
|
27520
27681
|
}
|
|
27521
|
-
const tool =
|
|
27682
|
+
const tool = active2.tools.get(event.callId);
|
|
27522
27683
|
if (!tool)
|
|
27523
27684
|
return;
|
|
27524
27685
|
const projection = projectGrokToolOutput(event.content, event.rawOutput, this.#toolOutputLimit);
|
|
@@ -27532,7 +27693,7 @@ var GrokHarnessSession = class {
|
|
|
27532
27693
|
if (delta.length > 0) {
|
|
27533
27694
|
this.#event({
|
|
27534
27695
|
type: "item.updated",
|
|
27535
|
-
turnId:
|
|
27696
|
+
turnId: active2.command.turnId,
|
|
27536
27697
|
itemId: tool.item.itemId,
|
|
27537
27698
|
update: { type: "output.append", text: delta }
|
|
27538
27699
|
});
|
|
@@ -27541,7 +27702,7 @@ var GrokHarnessSession = class {
|
|
|
27541
27702
|
} else if (tool.item.type === "toolExecution" && projection.output) {
|
|
27542
27703
|
this.#event({
|
|
27543
27704
|
type: "item.updated",
|
|
27544
|
-
turnId:
|
|
27705
|
+
turnId: active2.command.turnId,
|
|
27545
27706
|
itemId: tool.item.itemId,
|
|
27546
27707
|
update: { type: "output.replace", output: projection.output }
|
|
27547
27708
|
});
|
|
@@ -27550,14 +27711,14 @@ var GrokHarnessSession = class {
|
|
|
27550
27711
|
if (event.status)
|
|
27551
27712
|
tool.status = event.status;
|
|
27552
27713
|
if (event.status === "completed" || event.status === "failed") {
|
|
27553
|
-
this.#completeTool(
|
|
27714
|
+
this.#completeTool(active2, event.callId, event.status, event.content, event.rawOutput);
|
|
27554
27715
|
}
|
|
27555
27716
|
}
|
|
27556
|
-
#completeTool(
|
|
27557
|
-
const tool =
|
|
27717
|
+
#completeTool(active2, callId, status, content, rawOutput) {
|
|
27718
|
+
const tool = active2.tools.get(callId);
|
|
27558
27719
|
if (!tool)
|
|
27559
27720
|
return;
|
|
27560
|
-
|
|
27721
|
+
active2.tools.delete(callId);
|
|
27561
27722
|
const projection = projectGrokToolOutput(content, rawOutput, this.#toolOutputLimit);
|
|
27562
27723
|
if (hasGrokToolProjection(projection)) {
|
|
27563
27724
|
tool.item = applyGrokToolProjection(tool.item, projection);
|
|
@@ -27570,10 +27731,10 @@ var GrokHarnessSession = class {
|
|
|
27570
27731
|
retryable: false
|
|
27571
27732
|
}
|
|
27572
27733
|
} : { status: "succeeded" };
|
|
27573
|
-
this.#completeItem(
|
|
27734
|
+
this.#completeItem(active2, tool.item, outcome);
|
|
27574
27735
|
if (status !== "completed")
|
|
27575
27736
|
return;
|
|
27576
|
-
this.#completeWatchedSubagents(
|
|
27737
|
+
this.#completeWatchedSubagents(active2, tool.item, content, rawOutput);
|
|
27577
27738
|
const changes = projectGrokFileChanges(content, this.#cwd);
|
|
27578
27739
|
if (!changes)
|
|
27579
27740
|
return;
|
|
@@ -27583,20 +27744,20 @@ var GrokHarnessSession = class {
|
|
|
27583
27744
|
sourceItemIds: [tool.item.itemId],
|
|
27584
27745
|
changes
|
|
27585
27746
|
};
|
|
27586
|
-
this.#event({ type: "item.started", turnId:
|
|
27587
|
-
this.#completeItem(
|
|
27747
|
+
this.#event({ type: "item.started", turnId: active2.command.turnId, item: fileItem });
|
|
27748
|
+
this.#completeItem(active2, fileItem, { status: "succeeded" });
|
|
27588
27749
|
}
|
|
27589
|
-
#completeSubagentTool(
|
|
27750
|
+
#completeSubagentTool(active2, callId, status, event) {
|
|
27590
27751
|
const nativeSubagentId = grokNativeSubagentId(event.rawInput, event.rawOutput, event.content);
|
|
27591
27752
|
const resultSummary = grokSubagentResultSummary(event.content, event.rawOutput);
|
|
27592
|
-
|
|
27753
|
+
active2.subagents.completeSpawn(active2.command.turnId, callId, {
|
|
27593
27754
|
failed: status === "failed",
|
|
27594
|
-
cancellationRequested:
|
|
27755
|
+
cancellationRequested: active2.cancellationRequested,
|
|
27595
27756
|
...nativeSubagentId ? { nativeSubagentId } : {},
|
|
27596
27757
|
...resultSummary ? { resultSummary } : {}
|
|
27597
27758
|
});
|
|
27598
27759
|
}
|
|
27599
|
-
#completeWatchedSubagents(
|
|
27760
|
+
#completeWatchedSubagents(active2, item, content, rawOutput) {
|
|
27600
27761
|
const name = item.type === "toolExecution" ? item.toolName : item.command;
|
|
27601
27762
|
const rawInput = item.type === "toolExecution" ? item.arguments : void 0;
|
|
27602
27763
|
const resultSummary = grokSubagentResultSummary(content, rawOutput);
|
|
@@ -27607,64 +27768,64 @@ var GrokHarnessSession = class {
|
|
|
27607
27768
|
content,
|
|
27608
27769
|
rawOutput
|
|
27609
27770
|
})) {
|
|
27610
|
-
|
|
27771
|
+
active2.subagents.completeByNativeId(active2.command.turnId, settlement.id, {
|
|
27611
27772
|
failed: settlement.status === "failed",
|
|
27612
|
-
cancellationRequested:
|
|
27773
|
+
cancellationRequested: active2.cancellationRequested || settlement.status === "interrupted",
|
|
27613
27774
|
status: settlement.status,
|
|
27614
27775
|
...settlement.resultSummary ? { resultSummary: settlement.resultSummary } : resultSummary ? { resultSummary } : {}
|
|
27615
27776
|
});
|
|
27616
27777
|
}
|
|
27617
27778
|
}
|
|
27618
|
-
#bindSpawnedSubagent(
|
|
27619
|
-
|
|
27779
|
+
#bindSpawnedSubagent(active2, event) {
|
|
27780
|
+
active2.subagents.bindNativeId(active2.command.turnId, {
|
|
27620
27781
|
nativeSubagentId: event.nativeSubagentId,
|
|
27621
27782
|
...event.description ? { description: event.description } : {},
|
|
27622
27783
|
...event.role ? { role: event.role } : {},
|
|
27623
27784
|
...event.model ? { model: event.model } : {}
|
|
27624
27785
|
});
|
|
27625
27786
|
}
|
|
27626
|
-
#finishNativeSubagent(
|
|
27627
|
-
|
|
27787
|
+
#finishNativeSubagent(active2, event) {
|
|
27788
|
+
active2.subagents.completeByNativeId(active2.command.turnId, event.nativeSubagentId, {
|
|
27628
27789
|
failed: event.status === "failed",
|
|
27629
|
-
cancellationRequested:
|
|
27790
|
+
cancellationRequested: active2.cancellationRequested || event.status === "interrupted",
|
|
27630
27791
|
status: event.status,
|
|
27631
27792
|
...event.resultSummary ? { resultSummary: event.resultSummary } : {}
|
|
27632
27793
|
});
|
|
27633
27794
|
}
|
|
27634
|
-
#completeAgent(
|
|
27635
|
-
const item =
|
|
27636
|
-
if (item &&
|
|
27637
|
-
this.#publishAgent(
|
|
27638
|
-
const completed =
|
|
27639
|
-
|
|
27640
|
-
|
|
27641
|
-
|
|
27795
|
+
#completeAgent(active2, outcome) {
|
|
27796
|
+
const item = active2.agent;
|
|
27797
|
+
if (item && active2.agentMedia)
|
|
27798
|
+
this.#publishAgent(active2, active2.agentMedia.flush());
|
|
27799
|
+
const completed = active2.agent ?? item;
|
|
27800
|
+
active2.agent = null;
|
|
27801
|
+
active2.agentMessageId = null;
|
|
27802
|
+
active2.agentMedia = null;
|
|
27642
27803
|
if (completed)
|
|
27643
|
-
this.#completeItem(
|
|
27804
|
+
this.#completeItem(active2, completed, outcome);
|
|
27644
27805
|
}
|
|
27645
|
-
#completeReasoning(
|
|
27646
|
-
const item =
|
|
27647
|
-
|
|
27648
|
-
|
|
27806
|
+
#completeReasoning(active2, outcome) {
|
|
27807
|
+
const item = active2.reasoning;
|
|
27808
|
+
active2.reasoning = null;
|
|
27809
|
+
active2.reasoningMessageId = null;
|
|
27649
27810
|
if (item)
|
|
27650
|
-
this.#completeItem(
|
|
27811
|
+
this.#completeItem(active2, item, outcome);
|
|
27651
27812
|
}
|
|
27652
|
-
#completeItem(
|
|
27813
|
+
#completeItem(active2, item, outcome) {
|
|
27653
27814
|
const snapshot = { item, outcome };
|
|
27654
|
-
|
|
27815
|
+
active2.completedItems.push(snapshot);
|
|
27655
27816
|
this.#event({
|
|
27656
27817
|
type: "item.completed",
|
|
27657
|
-
turnId:
|
|
27818
|
+
turnId: active2.command.turnId,
|
|
27658
27819
|
snapshot
|
|
27659
27820
|
});
|
|
27660
27821
|
}
|
|
27661
|
-
async #settleFromHistory(
|
|
27822
|
+
async #settleFromHistory(active2, outcome, response) {
|
|
27662
27823
|
let history = [];
|
|
27663
27824
|
let nativeTurnRef;
|
|
27664
27825
|
let checkpoint;
|
|
27665
27826
|
try {
|
|
27666
27827
|
history = await this.#refreshSnapshot();
|
|
27667
|
-
const created = this.#snapshot.turns.filter((turn) => !
|
|
27828
|
+
const created = this.#snapshot.turns.filter((turn) => !active2.beforeNativeTurnKeys.has(turn.nativeTurnRef.nativeTurnKey));
|
|
27668
27829
|
if (created.length !== 1) {
|
|
27669
27830
|
throw new Error(`Grok Turn persisted ${created.length} new Native Turns; exactly one is required`);
|
|
27670
27831
|
}
|
|
@@ -27686,43 +27847,43 @@ var GrokHarnessSession = class {
|
|
|
27686
27847
|
}
|
|
27687
27848
|
const usage = sessionUsageFromHistory(history);
|
|
27688
27849
|
await this.#refreshCredits().catch(() => void 0);
|
|
27689
|
-
this.#finish(
|
|
27850
|
+
this.#finish(active2, checkpoint ? { ...outcome, checkpoint } : outcome, usage, nativeTurnRef);
|
|
27690
27851
|
}
|
|
27691
|
-
#finish(
|
|
27692
|
-
if (this.#active !==
|
|
27852
|
+
#finish(active2, outcome, usage = null, nativeTurnRef) {
|
|
27853
|
+
if (this.#active !== active2)
|
|
27693
27854
|
return;
|
|
27694
|
-
|
|
27855
|
+
active2.questions.cancel();
|
|
27695
27856
|
const itemOutcome = outcome;
|
|
27696
|
-
this.#completeReasoning(
|
|
27697
|
-
this.#completeAgent(
|
|
27698
|
-
|
|
27699
|
-
if (
|
|
27700
|
-
this.#completeItem(
|
|
27701
|
-
|
|
27702
|
-
}
|
|
27703
|
-
for (const tool of
|
|
27704
|
-
this.#completeItem(
|
|
27705
|
-
|
|
27706
|
-
for (const [interactionId, pending] of
|
|
27707
|
-
|
|
27857
|
+
this.#completeReasoning(active2, itemOutcome);
|
|
27858
|
+
this.#completeAgent(active2, itemOutcome);
|
|
27859
|
+
active2.subagents.finalize(active2.command.turnId, itemOutcome);
|
|
27860
|
+
if (active2.compactionItem) {
|
|
27861
|
+
this.#completeItem(active2, active2.compactionItem, itemOutcome);
|
|
27862
|
+
active2.compactionItem = null;
|
|
27863
|
+
}
|
|
27864
|
+
for (const tool of active2.tools.values())
|
|
27865
|
+
this.#completeItem(active2, tool.item, itemOutcome);
|
|
27866
|
+
active2.tools.clear();
|
|
27867
|
+
for (const [interactionId, pending] of active2.approvals) {
|
|
27868
|
+
active2.approvals.delete(interactionId);
|
|
27708
27869
|
pending.resolve({ outcome: { outcome: "cancelled" } });
|
|
27709
27870
|
this.#event({
|
|
27710
27871
|
type: "interaction.closed",
|
|
27711
27872
|
interactionId,
|
|
27712
|
-
turnId:
|
|
27873
|
+
turnId: active2.command.turnId,
|
|
27713
27874
|
reason: "cancelled"
|
|
27714
27875
|
});
|
|
27715
27876
|
}
|
|
27716
27877
|
this.#active = null;
|
|
27717
27878
|
if (usage || this.#usage)
|
|
27718
|
-
this.#publishUsage({ ...usage, ...
|
|
27879
|
+
this.#publishUsage({ ...usage, ...active2.usage?.metrics() }, active2.command.turnId, true);
|
|
27719
27880
|
this.#event({
|
|
27720
27881
|
type: "turn.completed",
|
|
27721
|
-
turnId:
|
|
27882
|
+
turnId: active2.command.turnId,
|
|
27722
27883
|
...nativeTurnRef ? { nativeTurnRef } : {},
|
|
27723
27884
|
outcome
|
|
27724
27885
|
});
|
|
27725
|
-
|
|
27886
|
+
active2.resolveCompletion();
|
|
27726
27887
|
}
|
|
27727
27888
|
#publishUsage(usage, observedForTurnId, replaceMetrics = false) {
|
|
27728
27889
|
const base = this.#usage ? { ...this.#usage } : null;
|
|
@@ -27745,15 +27906,15 @@ var GrokHarnessSession = class {
|
|
|
27745
27906
|
if (this.#phase === "closed")
|
|
27746
27907
|
return;
|
|
27747
27908
|
this.#phase = "closing";
|
|
27748
|
-
const
|
|
27749
|
-
if (
|
|
27750
|
-
|
|
27751
|
-
|
|
27752
|
-
for (const approval of
|
|
27909
|
+
const active2 = this.#active;
|
|
27910
|
+
if (active2) {
|
|
27911
|
+
active2.cancellationRequested = true;
|
|
27912
|
+
active2.questions.cancel();
|
|
27913
|
+
for (const approval of active2.approvals.values())
|
|
27753
27914
|
approval.resolve({ outcome: { outcome: "cancelled" } });
|
|
27754
27915
|
await this.#transport.cancel().catch(() => void 0);
|
|
27755
27916
|
await Promise.race([
|
|
27756
|
-
|
|
27917
|
+
active2.completion,
|
|
27757
27918
|
new Promise((resolve) => setTimeout(resolve, this.#closeTimeoutMs))
|
|
27758
27919
|
]);
|
|
27759
27920
|
}
|
|
@@ -27784,6 +27945,7 @@ var GrokHarnessSession = class {
|
|
|
27784
27945
|
}
|
|
27785
27946
|
};
|
|
27786
27947
|
var GrokAdapter = class {
|
|
27948
|
+
normalizeStoredModelRef = normalizeStoredGrokModelRef;
|
|
27787
27949
|
credentialExport = {
|
|
27788
27950
|
read: () => this.#closePromise ? Promise.resolve([]) : readGrokCredentials(this.#environment ?? process.env)
|
|
27789
27951
|
};
|
|
@@ -27886,15 +28048,19 @@ var GrokAdapter = class {
|
|
|
27886
28048
|
}
|
|
27887
28049
|
return this.#credits;
|
|
27888
28050
|
}
|
|
28051
|
+
#inspectionGeneration = 0;
|
|
27889
28052
|
async inspect(input = {}) {
|
|
27890
28053
|
if (this.#closePromise)
|
|
27891
28054
|
return { status: "unavailable", error: invalidState("Grok Adapter is closed") };
|
|
27892
28055
|
const cwd = path16.resolve(input.cwd ?? process.cwd());
|
|
27893
|
-
if (
|
|
27894
|
-
|
|
27895
|
-
|
|
27896
|
-
return cached2.inspection;
|
|
28056
|
+
if (input.refresh) {
|
|
28057
|
+
this.#inspectionCache.clear();
|
|
28058
|
+
this.#inspectionGeneration++;
|
|
27897
28059
|
}
|
|
28060
|
+
const cached2 = this.#inspectionCache.get(cwd);
|
|
28061
|
+
if (cached2 && Date.now() < cached2.expiresAt)
|
|
28062
|
+
return cached2.inspection;
|
|
28063
|
+
const generation = this.#inspectionGeneration;
|
|
27898
28064
|
let transport = null;
|
|
27899
28065
|
const startedAt = Date.now();
|
|
27900
28066
|
let stage = "spawn";
|
|
@@ -27913,10 +28079,12 @@ var GrokAdapter = class {
|
|
|
27913
28079
|
permissionModes: GROK_PERMISSION_MODE_CATALOG,
|
|
27914
28080
|
capabilities: capabilitiesForModels(modelState)
|
|
27915
28081
|
};
|
|
27916
|
-
this.#
|
|
27917
|
-
|
|
27918
|
-
|
|
27919
|
-
|
|
28082
|
+
if (!this.#closePromise && generation === this.#inspectionGeneration) {
|
|
28083
|
+
this.#inspectionCache.set(cwd, {
|
|
28084
|
+
inspection: ready,
|
|
28085
|
+
expiresAt: Date.now() + INSPECTION_CACHE_TTL_MS
|
|
28086
|
+
});
|
|
28087
|
+
}
|
|
27920
28088
|
this.#scheduleCreditsRefresh();
|
|
27921
28089
|
return ready;
|
|
27922
28090
|
} catch (error53) {
|
|
@@ -28041,7 +28209,7 @@ var GrokAdapter = class {
|
|
|
28041
28209
|
} : {
|
|
28042
28210
|
kind: "create",
|
|
28043
28211
|
permissionModeId: requestedPermissionModeId,
|
|
28044
|
-
...input.kind === "create" && input.model ? { modelId:
|
|
28212
|
+
...input.kind === "create" && input.model ? { modelId: input.model.id } : {}
|
|
28045
28213
|
});
|
|
28046
28214
|
}
|
|
28047
28215
|
if (!opened) {
|
|
@@ -28108,7 +28276,7 @@ var GrokAdapter = class {
|
|
|
28108
28276
|
}
|
|
28109
28277
|
const contextWindow = modelState.defaultContextWindowTokensByModel.get(modelState.currentModel.id);
|
|
28110
28278
|
if (savedModel || modelState.currentModel.id !== nativeModelId || modelState.currentThinkingOptionId !== nativeThinkingOptionId || contextWindow !== void 0 && modelState.contextWindowTokensByModel.get(modelState.currentModel.id) !== contextWindow) {
|
|
28111
|
-
await transport.setModel(
|
|
28279
|
+
await transport.setModel(modelState.currentModel.id, modelState.currentThinkingOptionId, contextWindow);
|
|
28112
28280
|
if (contextWindow !== void 0) {
|
|
28113
28281
|
modelState.contextWindowTokensByModel = new Map([
|
|
28114
28282
|
...modelState.contextWindowTokensByModel,
|