@codexhost/cli-darwin-x64 0.22.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 +3117 -274
- package/app/console-web.js +15645 -4413
- package/app/desktop-controller.mjs +14057 -969
- package/app/host-runtime.mjs +11518 -8277
- package/app/plugins/antigravity/plugin.mjs +2030 -678
- package/app/plugins/claude-code/plugin.mjs +2116 -929
- package/app/plugins/codebuddy/plugin.mjs +1247 -353
- package/app/plugins/codex-usage/plugin.mjs +786 -163
- package/app/plugins/copilot/plugin.mjs +938 -296
- package/app/plugins/cursor-cli/plugin.mjs +1021 -232
- package/app/plugins/deepseek-harness/plugin.mjs +1552 -664
- package/app/plugins/devin/plugin.mjs +826 -185
- package/app/plugins/grok/plugin.mjs +1083 -424
- package/app/plugins/hermes/plugin.mjs +961 -338
- package/app/plugins/kimi-code/plugin.mjs +854 -237
- package/app/plugins/kiro-cli/plugin.mjs +821 -184
- package/app/plugins/omp/plugin.mjs +1316 -633
- package/app/plugins/opencode/plugin.mjs +1293 -606
- package/app/plugins/pi/plugin.mjs +1540 -867
- package/app/plugins/qoder/plugin.mjs +961 -332
- package/app/plugins/qoder-cn/plugin.mjs +961 -332
- package/app/plugins/qwen-code/plugin.mjs +937 -321
- package/app/plugins/workbuddy/plugin.mjs +1311 -370
- package/app/plugins/zcode/plugin.mjs +1516 -423
- package/app/renderer-extension.js +21297 -9060
- package/app/web/assets/index-CTCFIQbU.css +1 -0
- package/app/web/assets/index-IvFk9KT-.js +203 -0
- package/app/web/codexhost-settings.js +6753 -31616
- 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 +14 -14
- 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 +94 -91
- 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-browser/client.js +1 -1
- 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 +79 -79
- 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/licenses/werift-NOTICES.txt +123 -0
- package/app/web-modules/licenses/werift-libwebrtc-NOTICES.txt +58 -0
- package/app/web-modules/server.mjs +40416 -11283
- 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-CN4a4sj0.js +0 -201
- package/app/web/assets/index-DJW4bmyx.css +0 -1
|
@@ -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, methods2) {
|
|
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, methods) {
|
|
|
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 methods2) {
|
|
13078
|
+
const fn = methods2[key];
|
|
13079
13079
|
Object.defineProperty(proto, key, {
|
|
13080
13080
|
configurable: true,
|
|
13081
13081
|
enumerable: false,
|
|
@@ -15019,6 +15019,9 @@ var threadPermissionModeSelectParamsSchema = external_exports.object({
|
|
|
15019
15019
|
permissionModeId: harnessPermissionModeIdSchema
|
|
15020
15020
|
}).strict();
|
|
15021
15021
|
|
|
15022
|
+
// ../../shared-contracts/dist/harness-route-limit.js
|
|
15023
|
+
var HARNESS_TRANSPORT_MODEL_ID_MAX_LENGTH = 8192;
|
|
15024
|
+
|
|
15022
15025
|
// ../../shared-contracts/dist/thread-usage.js
|
|
15023
15026
|
var nonNegativeSafeIntegerSchema = external_exports.number().int().safe().nonnegative();
|
|
15024
15027
|
var finiteNonNegativeNumberSchema = external_exports.number().finite().nonnegative();
|
|
@@ -15051,7 +15054,7 @@ var composerIndicatorsSchema = external_exports.array(external_exports.object({
|
|
|
15051
15054
|
expiresAtUnix: nonNegativeSafeIntegerSchema,
|
|
15052
15055
|
label: indicatorTextSchema(256).optional(),
|
|
15053
15056
|
tooltip: indicatorTextSchema(1024).optional()
|
|
15054
|
-
}).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, {
|
|
15055
15058
|
message: "Composer indicator IDs must be unique"
|
|
15056
15059
|
});
|
|
15057
15060
|
var threadUsageSnapshotSchema = external_exports.object({
|
|
@@ -15077,6 +15080,7 @@ var threadUsageSnapshotSchema = external_exports.object({
|
|
|
15077
15080
|
planSevenDayResetsAtUnix: nonNegativeSafeIntegerSchema.optional(),
|
|
15078
15081
|
sessionCacheHitRatePercent: cacheHitRatePercentSchema.optional(),
|
|
15079
15082
|
timeToFirstOutputMs: nonNegativeSafeIntegerSchema.optional(),
|
|
15083
|
+
latestRequestTimeToFirstOutputMs: nonNegativeSafeIntegerSchema.optional(),
|
|
15080
15084
|
costSource: external_exports.enum(["publicPrice", "native"]).optional(),
|
|
15081
15085
|
unpricedModels: external_exports.array(external_exports.string().min(1)).min(1).optional()
|
|
15082
15086
|
}).strict().superRefine((usage, context) => {
|
|
@@ -15174,6 +15178,13 @@ var accountCreditsSnapshotSchema = external_exports.object({
|
|
|
15174
15178
|
productUsage: external_exports.array(accountCreditsProductUsageSchema).min(1).optional(),
|
|
15175
15179
|
resetCredits: accountResetCreditsSchema.optional()
|
|
15176
15180
|
}).strict();
|
|
15181
|
+
var accountBalanceSnapshotSchema = external_exports.object({
|
|
15182
|
+
amount: external_exports.number().finite().nonnegative(),
|
|
15183
|
+
/** ISO 4217 code as reported by the Provider, for example `CNY`. */
|
|
15184
|
+
currency: external_exports.string().trim().min(1).max(8),
|
|
15185
|
+
/** Native label when the Harness exposes several Billing Sources. */
|
|
15186
|
+
label: external_exports.string().trim().min(1).max(128).optional()
|
|
15187
|
+
}).strict();
|
|
15177
15188
|
var threadUsageInspectionParamsSchema = external_exports.object({
|
|
15178
15189
|
threadId: hostThreadIdSchema,
|
|
15179
15190
|
refresh: external_exports.literal("exact").optional()
|
|
@@ -15182,7 +15193,10 @@ var threadUsageInspectionSchema = external_exports.object({
|
|
|
15182
15193
|
threadId: hostThreadIdSchema,
|
|
15183
15194
|
usage: threadUsageSnapshotSchema.nullable(),
|
|
15184
15195
|
accountCredits: accountCreditsSnapshotSchema.optional(),
|
|
15185
|
-
/**
|
|
15196
|
+
/** Prepaid funds for the Thread's Billing Source; shown only when no percentage quota exists. */
|
|
15197
|
+
accountBalance: accountBalanceSnapshotSchema.optional(),
|
|
15198
|
+
/** Whether this source can provide cached account quota (credits or a prepaid balance)
|
|
15199
|
+
* independently of usage. */
|
|
15186
15200
|
accountCreditsSupported: external_exports.boolean().optional()
|
|
15187
15201
|
}).strict();
|
|
15188
15202
|
|
|
@@ -15194,10 +15208,15 @@ var THREAD_OWNERSHIP_LIST_MAX_LENGTH = 100;
|
|
|
15194
15208
|
var nonBlankTextSchema2 = external_exports.string().refine((value) => value.trim().length > 0, {
|
|
15195
15209
|
message: "Value must not be empty or whitespace"
|
|
15196
15210
|
});
|
|
15197
|
-
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"]);
|
|
15198
15213
|
var harnessModelRefSchema = external_exports.object({
|
|
15199
|
-
id: harnessModelRefIdSchema
|
|
15214
|
+
id: harnessModelRefIdSchema,
|
|
15215
|
+
serviceTier: harnessModelServiceTierSchema.optional()
|
|
15200
15216
|
}).strict();
|
|
15217
|
+
function sameHarnessModelRef(left, right) {
|
|
15218
|
+
return left?.id === right?.id && left?.serviceTier === right?.serviceTier;
|
|
15219
|
+
}
|
|
15201
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();
|
|
15202
15221
|
var harnessResolvedModelLabelSchema = nonBlankTextSchema2.max(HARNESS_MODEL_LABEL_MAX_LENGTH);
|
|
15203
15222
|
var harnessThinkingOptionSchema = external_exports.object({
|
|
@@ -15211,7 +15230,15 @@ var harnessModelSchema = external_exports.object({
|
|
|
15211
15230
|
/** Optional opaque selection for this same Model with priority processing enabled. */
|
|
15212
15231
|
fastModel: harnessModelRefSchema.optional(),
|
|
15213
15232
|
supportedThinkingOptionIds: external_exports.array(harnessThinkingOptionIdSchema).optional()
|
|
15214
|
-
}).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
|
+
}
|
|
15215
15242
|
var harnessThinkingOptionsSchema = external_exports.array(harnessThinkingOptionSchema).superRefine((options, context) => {
|
|
15216
15243
|
const ids = /* @__PURE__ */ new Set();
|
|
15217
15244
|
for (const [index, option] of options.entries()) {
|
|
@@ -15231,26 +15258,26 @@ var harnessModelCatalogSchema = external_exports.object({
|
|
|
15231
15258
|
thinkingOptions: harnessThinkingOptionsSchema,
|
|
15232
15259
|
defaultThinkingOptionId: harnessThinkingOptionIdSchema.optional()
|
|
15233
15260
|
}).strict().superRefine((catalog, context) => {
|
|
15234
|
-
const refs =
|
|
15235
|
-
const thinkingIds = new Set(catalog.thinkingOptions.map(({ id }) =>
|
|
15261
|
+
const refs = [];
|
|
15262
|
+
const thinkingIds = new Set(catalog.thinkingOptions.map(({ id: id2 }) => id2));
|
|
15236
15263
|
for (const [index, model2] of catalog.models.entries()) {
|
|
15237
|
-
if (refs.
|
|
15264
|
+
if (refs.some((ref) => sameHarnessModelRef(ref, model2.ref))) {
|
|
15238
15265
|
context.addIssue({
|
|
15239
15266
|
code: "custom",
|
|
15240
15267
|
message: "Model Catalog refs must be unique",
|
|
15241
15268
|
path: ["models", index, "ref", "id"]
|
|
15242
15269
|
});
|
|
15243
15270
|
}
|
|
15244
|
-
refs.
|
|
15271
|
+
refs.push(model2.ref);
|
|
15245
15272
|
if (model2.fastModel) {
|
|
15246
|
-
if (refs.
|
|
15273
|
+
if (refs.some((ref) => sameHarnessModelRef(ref, model2.fastModel))) {
|
|
15247
15274
|
context.addIssue({
|
|
15248
15275
|
code: "custom",
|
|
15249
15276
|
message: "Fast Model refs must be distinct and unique",
|
|
15250
15277
|
path: ["models", index, "fastModel"]
|
|
15251
15278
|
});
|
|
15252
15279
|
}
|
|
15253
|
-
refs.
|
|
15280
|
+
refs.push(model2.fastModel);
|
|
15254
15281
|
}
|
|
15255
15282
|
const supportedThinkingIds = /* @__PURE__ */ new Set();
|
|
15256
15283
|
for (const [optionIndex, optionId] of (model2.supportedThinkingOptionIds ?? []).entries()) {
|
|
@@ -15271,7 +15298,7 @@ var harnessModelCatalogSchema = external_exports.object({
|
|
|
15271
15298
|
}
|
|
15272
15299
|
}
|
|
15273
15300
|
}
|
|
15274
|
-
if (catalog.defaultModel && !
|
|
15301
|
+
if (catalog.defaultModel && !catalogModelForRef(catalog, catalog.defaultModel)) {
|
|
15275
15302
|
context.addIssue({
|
|
15276
15303
|
code: "custom",
|
|
15277
15304
|
message: "Default Model must exist in the Model Catalog",
|
|
@@ -15311,7 +15338,12 @@ var harnessSessionCapabilitiesSchema = external_exports.object({
|
|
|
15311
15338
|
observe: external_exports.boolean()
|
|
15312
15339
|
}).strict().optional(),
|
|
15313
15340
|
/** True only when `turn.steer` delivers input into the active Turn through a native primitive. */
|
|
15314
|
-
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()
|
|
15315
15347
|
}).strict();
|
|
15316
15348
|
var harnessConfigurationStateSchema = external_exports.object({
|
|
15317
15349
|
effectiveModel: harnessModelRefSchema.optional(),
|
|
@@ -15320,7 +15352,7 @@ var harnessConfigurationStateSchema = external_exports.object({
|
|
|
15320
15352
|
availableThinkingOptions: harnessThinkingOptionsSchema.optional(),
|
|
15321
15353
|
effectivePermissionModeId: harnessPermissionModeIdSchema.optional()
|
|
15322
15354
|
}).strict().superRefine((state, context) => {
|
|
15323
|
-
if (state.effectiveThinkingOptionId && state.availableThinkingOptions && !state.availableThinkingOptions.some(({ id }) =>
|
|
15355
|
+
if (state.effectiveThinkingOptionId && state.availableThinkingOptions && !state.availableThinkingOptions.some(({ id: id2 }) => id2 === state.effectiveThinkingOptionId)) {
|
|
15324
15356
|
context.addIssue({
|
|
15325
15357
|
code: "custom",
|
|
15326
15358
|
message: "Effective Thinking option must be currently available",
|
|
@@ -15360,7 +15392,8 @@ var harnessInspectParamsSchema = external_exports.object({
|
|
|
15360
15392
|
cwd: nonBlankTextSchema2.max(16384).optional(),
|
|
15361
15393
|
refresh: external_exports.boolean().optional(),
|
|
15362
15394
|
/** `availability` asks only whether the Harness can run; see `InspectHarnessInput.purpose`. */
|
|
15363
|
-
purpose: external_exports.literal("availability").optional()
|
|
15395
|
+
purpose: external_exports.literal("availability").optional(),
|
|
15396
|
+
credentialAccess: external_exports.enum(["allow", "retry"]).optional()
|
|
15364
15397
|
}).strict();
|
|
15365
15398
|
var harnessWebUiOpenParamsSchema = external_exports.object({
|
|
15366
15399
|
harnessId: harnessIdSchema
|
|
@@ -15391,7 +15424,7 @@ var codexThreadInspectionSchema = external_exports.object({
|
|
|
15391
15424
|
var externalThreadInspectionSchema = external_exports.object({
|
|
15392
15425
|
owner: external_exports.literal("external"),
|
|
15393
15426
|
harnessId: nonBlankTextSchema2.max(256),
|
|
15394
|
-
transportModelId: nonBlankTextSchema2.max(
|
|
15427
|
+
transportModelId: nonBlankTextSchema2.max(HARNESS_TRANSPORT_MODEL_ID_MAX_LENGTH),
|
|
15395
15428
|
effectiveModel: harnessModelRefSchema.optional(),
|
|
15396
15429
|
resolvedModelLabel: harnessResolvedModelLabelSchema.optional(),
|
|
15397
15430
|
effectiveThinkingOptionId: harnessThinkingOptionIdSchema.optional(),
|
|
@@ -15473,13 +15506,635 @@ var threadSteeringInspectResultSchema = external_exports.object({
|
|
|
15473
15506
|
delivery: external_exports.enum(["official", "activeTurn", "newTurn"])
|
|
15474
15507
|
}).strict();
|
|
15475
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(text2) {
|
|
15629
|
+
return external_exports.strictObject({ en: text2, "zh-CN": text2 });
|
|
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 = (path8, message) => ctx.addIssue({ code: "custom", path: [path8], 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((path8) => path8.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((path8) => path8.endsWith(suffix), `Expected a ${suffix} file`);
|
|
15792
|
+
var moduleEntry = resourceWithSuffix(".mjs");
|
|
15793
|
+
var style = resourceWithSuffix(".css").optional();
|
|
15794
|
+
var hostExtensionCanonicalPath = (path8) => path8.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((path8) => path8 === void 0 || hostExtensionResourcePathSchema.safeParse(path8).success),
|
|
15805
|
+
screenshots: legacy.screenshots.refine((paths) => paths === void 0 || paths.every((path8) => hostExtensionResourcePathSchema.safeParse(path8).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((path8) => /^(?:\/|[a-z]:[/\\])/iu.test(path8) && !path8.includes("\0") && !path8.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 })
|
|
15906
|
+
]);
|
|
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") })
|
|
15912
|
+
]);
|
|
15913
|
+
var hostExtensionInstallationSchema = external_exports.strictObject({
|
|
15914
|
+
...active,
|
|
15915
|
+
manifest: hostExtensionManifestV2Schema,
|
|
15916
|
+
installedAt: external_exports.iso.datetime(),
|
|
15917
|
+
source: hostExtensionProvenanceSchema.optional()
|
|
15918
|
+
});
|
|
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
|
+
})
|
|
15938
|
+
]);
|
|
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
|
|
15993
|
+
});
|
|
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
|
+
};
|
|
16053
|
+
|
|
15476
16054
|
// ../../shared-contracts/dist/thread-archive-confirm.js
|
|
16055
|
+
var THREAD_ARCHIVE_CONFIRM_METHOD = "codexhost/thread/archive/confirm";
|
|
15477
16056
|
var threadArchiveConfirmParamsSchema = external_exports.object({ threadId: hostThreadIdSchema }).strict();
|
|
15478
16057
|
var threadArchiveConfirmResultSchema = external_exports.object({ confirmed: external_exports.boolean() }).strict();
|
|
15479
16058
|
|
|
15480
16059
|
// ../../shared-contracts/dist/client-channel.js
|
|
15481
16060
|
var CLIENT_CHANNEL_VERSION = 1;
|
|
15482
16061
|
var CLIENT_REQUEST_LIMIT_BYTES = 128 * 1024 * 1024;
|
|
16062
|
+
var CLIENT_CHANNEL_METHODS = [
|
|
16063
|
+
"codexhost/skills/list",
|
|
16064
|
+
"codexhost/voice/status",
|
|
16065
|
+
"codexhost/voice/transcribe",
|
|
16066
|
+
"codexhost/harness/display-settings/get",
|
|
16067
|
+
"codexhost/harness/display-settings/set",
|
|
16068
|
+
"codexhost/harness/display-settings/capabilities",
|
|
16069
|
+
"codexhost/harness/preferences/get",
|
|
16070
|
+
"codexhost/harness/preferences/patch",
|
|
16071
|
+
"thread/list",
|
|
16072
|
+
"codexhost/thread/catalog/read",
|
|
16073
|
+
"thread/read",
|
|
16074
|
+
"thread/resume",
|
|
16075
|
+
"thread/fork",
|
|
16076
|
+
"thread/turns/list",
|
|
16077
|
+
"thread/revert",
|
|
16078
|
+
"thread/items/list",
|
|
16079
|
+
"thread/start",
|
|
16080
|
+
"thread/name/set",
|
|
16081
|
+
"codexhost/thread/title/generate",
|
|
16082
|
+
"thread/archive",
|
|
16083
|
+
THREAD_ARCHIVE_CONFIRM_METHOD,
|
|
16084
|
+
"thread/unarchive",
|
|
16085
|
+
"turn/start",
|
|
16086
|
+
"turn/interrupt",
|
|
16087
|
+
"turn/steer",
|
|
16088
|
+
"thread/queue/list",
|
|
16089
|
+
"thread/queue/add",
|
|
16090
|
+
"thread/queue/update",
|
|
16091
|
+
"thread/queue/delete",
|
|
16092
|
+
"thread/queue/reorder",
|
|
16093
|
+
"thread/queue/start",
|
|
16094
|
+
"codexhost/thread/queue/send-now",
|
|
16095
|
+
"codexhost/workspace/read",
|
|
16096
|
+
"codexhost/thread/tree/read",
|
|
16097
|
+
"codexhost/thread/pins/list",
|
|
16098
|
+
"codexhost/thread/pins/set",
|
|
16099
|
+
"codexhost/harness/plugins/list",
|
|
16100
|
+
"codexhost/harness/inspect",
|
|
16101
|
+
"codexhost/thread/inspect",
|
|
16102
|
+
"codexhost/thread/usage/inspect",
|
|
16103
|
+
"codexhost/thread/ownership/list",
|
|
16104
|
+
"codexhost/thread/model/select",
|
|
16105
|
+
"codexhost/thread/thinking/select",
|
|
16106
|
+
"codexhost/thread/permission-mode/select",
|
|
16107
|
+
"codexhost/thread/commands/inspect",
|
|
16108
|
+
"codexhost/harness/commands/inspect",
|
|
16109
|
+
"codexhost/thread/command/execute",
|
|
16110
|
+
"codexhost/thread/fork",
|
|
16111
|
+
"codexhost/harness/session-import/sources",
|
|
16112
|
+
"codexhost/harness/session-import/list",
|
|
16113
|
+
"codexhost/harness/session-import/import",
|
|
16114
|
+
// Host settings shared across Desktop and Web.
|
|
16115
|
+
...HOST_EXTENSION_MANAGEMENT_METHODS,
|
|
16116
|
+
"codexhost/harness/installation",
|
|
16117
|
+
"codexhost/harness/installation/start",
|
|
16118
|
+
"codexhost/harness/installation/status",
|
|
16119
|
+
"codexhost/harness/launch-settings/get",
|
|
16120
|
+
"codexhost/harness/launch-settings/set",
|
|
16121
|
+
"codexhost/harness/web-ui/open",
|
|
16122
|
+
"codexhost/harness/accounts/sources",
|
|
16123
|
+
"codexhost/harness/accounts/list",
|
|
16124
|
+
"codexhost/harness/accounts/inspect",
|
|
16125
|
+
"codexhost/harness/credential-imports",
|
|
16126
|
+
"codexhost/account/list",
|
|
16127
|
+
"codexhost/account/refresh",
|
|
16128
|
+
"codexhost/account/usage/inspect",
|
|
16129
|
+
"codexhost/usage/model-prices/get",
|
|
16130
|
+
"codexhost/usage/model-prices/set",
|
|
16131
|
+
"codexhost/usage/model-prices/default",
|
|
16132
|
+
"codexhost/usage/statistics/get",
|
|
16133
|
+
"codexhost/update/check",
|
|
16134
|
+
"codexhost/update/start",
|
|
16135
|
+
"codexhost/update/status",
|
|
16136
|
+
"codexhost/sessions/loaded/list"
|
|
16137
|
+
];
|
|
15483
16138
|
var clientThreadPinsSchema = external_exports.object({ threadIds: external_exports.array(external_exports.string().min(1)) }).strict();
|
|
15484
16139
|
var clientThreadPinParamsSchema = external_exports.object({ threadId: external_exports.string().min(1).max(1024), pinned: external_exports.boolean() }).strict();
|
|
15485
16140
|
var clientThreadTreeReadParamsSchema = external_exports.object({}).strict();
|
|
@@ -15518,6 +16173,11 @@ var clientChannelEventSchema = external_exports.discriminatedUnion("type", [
|
|
|
15518
16173
|
cursor: clientChannelCursorSchema,
|
|
15519
16174
|
revision: external_exports.number().int().nonnegative()
|
|
15520
16175
|
}),
|
|
16176
|
+
external_exports.object({
|
|
16177
|
+
type: external_exports.literal("extensions-changed"),
|
|
16178
|
+
cursor: clientChannelCursorSchema,
|
|
16179
|
+
revision: hostExtensionRevisionSchema
|
|
16180
|
+
}),
|
|
15521
16181
|
external_exports.object({
|
|
15522
16182
|
type: external_exports.literal("hello"),
|
|
15523
16183
|
version: external_exports.literal(1),
|
|
@@ -15693,6 +16353,29 @@ var threadCatalogReadResultSchema = external_exports.object({
|
|
|
15693
16353
|
officialCursor: external_exports.object({ live: external_exports.string().nullable(), archived: external_exports.string().nullable().optional() }).strict().optional()
|
|
15694
16354
|
}).strict();
|
|
15695
16355
|
|
|
16356
|
+
// ../../shared-contracts/dist/thread-tree-watch.js
|
|
16357
|
+
var THREAD_TREE_MAX_NODES = 5e3;
|
|
16358
|
+
var threadTreeStatusSchema = external_exports.enum(["running", "waiting", "idle", "unknown"]);
|
|
16359
|
+
var threadTreeNodeSchema = external_exports.strictObject({
|
|
16360
|
+
harnessId: harnessIdSchema,
|
|
16361
|
+
title: external_exports.string().optional(),
|
|
16362
|
+
status: threadTreeStatusSchema,
|
|
16363
|
+
archived: external_exports.boolean()
|
|
16364
|
+
});
|
|
16365
|
+
var threadTreeSnapshotSchema = external_exports.strictObject({
|
|
16366
|
+
revision: external_exports.int().nonnegative(),
|
|
16367
|
+
parents: external_exports.record(hostThreadIdSchema, hostThreadIdSchema),
|
|
16368
|
+
nodes: external_exports.record(hostThreadIdSchema, threadTreeNodeSchema),
|
|
16369
|
+
truncated: external_exports.boolean()
|
|
16370
|
+
}).refine((snapshot) => Object.keys(snapshot.nodes).length <= THREAD_TREE_MAX_NODES, "Too many Thread tree nodes").refine(({ parents, nodes }) => Object.entries(parents).every(([child, parent]) => Object.hasOwn(nodes, child) && Object.hasOwn(nodes, parent)), "Missing Thread tree node");
|
|
16371
|
+
var subscriptionId = external_exports.string().min(1).max(128);
|
|
16372
|
+
var threadTreeWatchParamsSchema = external_exports.strictObject({});
|
|
16373
|
+
var threadTreeUnwatchParamsSchema = external_exports.strictObject({ subscriptionId });
|
|
16374
|
+
var threadTreeUnwatchResultSchema = external_exports.strictObject({});
|
|
16375
|
+
var threadTreeWatchResultSchema = threadTreeUnwatchParamsSchema.extend({
|
|
16376
|
+
snapshot: threadTreeSnapshotSchema
|
|
16377
|
+
});
|
|
16378
|
+
|
|
15696
16379
|
// ../../shared-contracts/dist/voice.js
|
|
15697
16380
|
var VOICE_AUDIO_MAX_BYTES = 10 * 1024 * 1024;
|
|
15698
16381
|
var voiceAudioMimeTypeSchema = external_exports.string().regex(/^audio\/[a-z0-9.+-]+(?:\s*;[^\r\n]*)?$/i);
|
|
@@ -15931,7 +16614,7 @@ var DEFAULT_IDLE_RELEASE_SETTINGS = Object.freeze({
|
|
|
15931
16614
|
|
|
15932
16615
|
// ../../shared-contracts/dist/harness-preferences.js
|
|
15933
16616
|
var harnessPreferenceScopeSchema = external_exports.string().regex(/^external$/u);
|
|
15934
|
-
var preferenceHarnessKey = harnessIdSchema.transform((
|
|
16617
|
+
var preferenceHarnessKey = harnessIdSchema.transform((id2) => String(id2));
|
|
15935
16618
|
var harnessDefaultConfigurationSchema = external_exports.strictObject({
|
|
15936
16619
|
model: harnessModelRefSchema.optional(),
|
|
15937
16620
|
thinkingOptionId: harnessThinkingOptionIdSchema.optional(),
|
|
@@ -15941,11 +16624,19 @@ var newThreadDefaultsSchema = external_exports.strictObject({
|
|
|
15941
16624
|
lastHarness: harnessIdSchema.optional(),
|
|
15942
16625
|
byHarness: external_exports.record(preferenceHarnessKey, harnessDefaultConfigurationSchema)
|
|
15943
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
|
+
});
|
|
15944
16634
|
var modelId = external_exports.string().min(1).max(1024);
|
|
15945
16635
|
var harnessPreferenceValuesSchema = external_exports.strictObject({
|
|
15946
16636
|
idleRelease: idleReleaseSettingsSchema.optional(),
|
|
15947
16637
|
favorites: external_exports.record(preferenceHarnessKey, external_exports.array(modelId).max(2048)).default({}),
|
|
15948
|
-
newThread: newThreadDefaultsSchema.optional()
|
|
16638
|
+
newThread: newThreadDefaultsSchema.optional(),
|
|
16639
|
+
delegation: delegationDefaultsSchema.optional()
|
|
15949
16640
|
});
|
|
15950
16641
|
var harnessPreferenceSnapshotSchema = external_exports.strictObject({
|
|
15951
16642
|
scope: harnessPreferenceScopeSchema,
|
|
@@ -15973,6 +16664,11 @@ var harnessPreferenceOperationSchema = external_exports.discriminatedUnion("kind
|
|
|
15973
16664
|
lastHarness: harnessIdSchema.optional(),
|
|
15974
16665
|
harnessId: harnessIdSchema.optional(),
|
|
15975
16666
|
configuration: harnessDefaultConfigurationSchema.optional()
|
|
16667
|
+
}),
|
|
16668
|
+
external_exports.strictObject({
|
|
16669
|
+
kind: external_exports.literal("delegation"),
|
|
16670
|
+
harnessId: harnessIdSchema,
|
|
16671
|
+
configuration: harnessDelegationDefaultSchema.nullable()
|
|
15976
16672
|
})
|
|
15977
16673
|
]);
|
|
15978
16674
|
var harnessPreferencePatchSchema = external_exports.strictObject({
|
|
@@ -16323,13 +17019,6 @@ var threadManualCompactionStartedSchema = external_exports.strictObject({
|
|
|
16323
17019
|
});
|
|
16324
17020
|
|
|
16325
17021
|
// ../../shared-contracts/dist/harness-accounts.js
|
|
16326
|
-
var accountBalanceSnapshotSchema = external_exports.object({
|
|
16327
|
-
amount: external_exports.number().finite().nonnegative(),
|
|
16328
|
-
/** ISO 4217 code as reported by the Provider, for example `CNY`. */
|
|
16329
|
-
currency: external_exports.string().trim().min(1).max(8),
|
|
16330
|
-
/** Native label when the Harness exposes several Billing Sources. */
|
|
16331
|
-
label: external_exports.string().trim().min(1).max(128).optional()
|
|
16332
|
-
}).strict();
|
|
16333
17022
|
var harnessAccountSnapshotObject = external_exports.object({
|
|
16334
17023
|
email: external_exports.string().trim().min(1).max(320).optional(),
|
|
16335
17024
|
label: external_exports.string().trim().min(1).max(256).optional(),
|
|
@@ -16363,76 +17052,6 @@ var harnessAccountListResultSchema = external_exports.object({
|
|
|
16363
17052
|
accounts: external_exports.array(requireReportedQuota(harnessAccountSnapshotObject.extend(harnessAccountIdentityShape))).max(128)
|
|
16364
17053
|
}).strict();
|
|
16365
17054
|
|
|
16366
|
-
// ../../shared-contracts/dist/harness-plugins.js
|
|
16367
|
-
var HARNESS_PLUGIN_MANIFEST_MAX_BYTES = 32 * 1024;
|
|
16368
|
-
var HARNESS_PLUGIN_ICON_MAX_BYTES = 128 * 1024;
|
|
16369
|
-
var HARNESS_PLUGIN_LIMIT = 128;
|
|
16370
|
-
var installedHarnessPluginIdSchema = external_exports.string().min(1).max(128).regex(/^[a-z][a-z0-9]*(?:[._-][a-z0-9]+)*$/u).pipe(harnessIdSchema);
|
|
16371
|
-
var harnessPluginIdSchema = installedHarnessPluginIdSchema.refine((id) => id !== "codex", "The official Codex identity is reserved");
|
|
16372
|
-
var relativeResourceSchema = external_exports.string().min(1).max(512).refine((value) => !/[\\\u0000:#?]/u.test(value) && !value.startsWith("/") && !value.split("/").some((part) => part === ".." || part === ""), "Plugin resources must be relative paths inside the plugin");
|
|
16373
|
-
var documentationUrlSchema = external_exports.url().refine((value) => /^https:\/\/[^/?#@]+(?:[/?#]|$)/iu.test(value), "Plugin documentation links must be credential-free HTTPS URLs");
|
|
16374
|
-
var localizedTextSchema = external_exports.object({ en: external_exports.string().max(4096), "zh-CN": external_exports.string().max(4096).optional() }).strict();
|
|
16375
|
-
var harnessInstallationGuideSchema = external_exports.object({
|
|
16376
|
-
commands: external_exports.array(external_exports.object({ terminal: external_exports.string().max(256), command: external_exports.string().max(4096) }).strict()).max(8),
|
|
16377
|
-
before: localizedTextSchema.optional(),
|
|
16378
|
-
after: localizedTextSchema.optional(),
|
|
16379
|
-
downloads: external_exports.array(external_exports.object({ label: external_exports.string().max(128), url: documentationUrlSchema }).strict()).max(8).optional()
|
|
16380
|
-
}).strict();
|
|
16381
|
-
var pluginPresentationShape = {
|
|
16382
|
-
id: installedHarnessPluginIdSchema,
|
|
16383
|
-
name: external_exports.string().trim().min(1).max(128),
|
|
16384
|
-
version: external_exports.string().min(1).max(128),
|
|
16385
|
-
/** Capability-only plugin; omitted for existing session-capable plugins. */
|
|
16386
|
-
kind: external_exports.literal("usage").optional(),
|
|
16387
|
-
/** Original image styling or bounded vector paths; never arbitrary CSS/SVG markup. */
|
|
16388
|
-
iconStyle: external_exports.object({
|
|
16389
|
-
vector: external_exports.object({
|
|
16390
|
-
viewBox: external_exports.string().max(128).regex(/^-?\d+(?:\.\d+)?(?: +-?\d+(?:\.\d+)?){3}$/u),
|
|
16391
|
-
color: external_exports.string().regex(/^(?:currentColor|#[a-f0-9]{6})$/iu),
|
|
16392
|
-
paths: external_exports.array(external_exports.object({
|
|
16393
|
-
d: external_exports.string().min(1).max(32768).regex(/^[MmLlHhVvCcSsQqTtAaZz\d.,+eE\s-]+$/u),
|
|
16394
|
-
fillRule: external_exports.enum(["evenodd", "nonzero"]).optional(),
|
|
16395
|
-
fill: external_exports.string().regex(/^(?:currentColor|#[a-f0-9]{6})$/iu).optional()
|
|
16396
|
-
}).strict()).min(1).max(32)
|
|
16397
|
-
}).strict().optional(),
|
|
16398
|
-
background: external_exports.string().regex(/^#[a-f0-9]{6}$/iu).optional(),
|
|
16399
|
-
borderRadius: external_exports.number().min(0).max(50).optional(),
|
|
16400
|
-
paddingRatio: external_exports.number().min(0).max(0.25).optional()
|
|
16401
|
-
}).strict().optional(),
|
|
16402
|
-
installation: harnessInstallationGuideSchema.optional(),
|
|
16403
|
-
notice: localizedTextSchema.optional(),
|
|
16404
|
-
/** The factory accepts a persisted local entrypoint through its construction context. */
|
|
16405
|
-
launchCommand: external_exports.literal(true).optional(),
|
|
16406
|
-
links: external_exports.object({
|
|
16407
|
-
website: documentationUrlSchema.optional(),
|
|
16408
|
-
documentation: documentationUrlSchema.optional(),
|
|
16409
|
-
installation: documentationUrlSchema.optional()
|
|
16410
|
-
}).strict().optional()
|
|
16411
|
-
};
|
|
16412
|
-
var harnessPluginManifestSchema = external_exports.object({
|
|
16413
|
-
manifestVersion: external_exports.literal(1),
|
|
16414
|
-
...pluginPresentationShape,
|
|
16415
|
-
adapterApiVersion: external_exports.number().int().positive(),
|
|
16416
|
-
entry: relativeResourceSchema,
|
|
16417
|
-
icon: relativeResourceSchema.optional()
|
|
16418
|
-
}).strict();
|
|
16419
|
-
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);
|
|
16420
|
-
var harnessPluginDescriptorSchema = external_exports.object({
|
|
16421
|
-
...pluginPresentationShape,
|
|
16422
|
-
icon: harnessPluginIconSchema.optional()
|
|
16423
|
-
}).strict();
|
|
16424
|
-
var harnessPluginListParamsSchema = external_exports.object({}).strict();
|
|
16425
|
-
var harnessPluginListResultSchema = external_exports.object({
|
|
16426
|
-
plugins: external_exports.array(harnessPluginDescriptorSchema.extend({ id: harnessPluginIdSchema })).max(HARNESS_PLUGIN_LIMIT)
|
|
16427
|
-
}).strict();
|
|
16428
|
-
var harnessPluginConfigurationSchema = external_exports.object({
|
|
16429
|
-
version: external_exports.literal(1),
|
|
16430
|
-
enabled: external_exports.array(installedHarnessPluginIdSchema).max(HARNESS_PLUGIN_LIMIT)
|
|
16431
|
-
}).strict().refine((value) => new Set(value.enabled).size === value.enabled.length, {
|
|
16432
|
-
message: "Enabled plugin IDs must be unique",
|
|
16433
|
-
path: ["enabled"]
|
|
16434
|
-
});
|
|
16435
|
-
|
|
16436
17055
|
// ../../shared-contracts/dist/harness-route.js
|
|
16437
17056
|
var harnessPluginRouteSchema = external_exports.object({
|
|
16438
17057
|
harnessId: harnessPluginIdSchema,
|
|
@@ -16873,9 +17492,12 @@ var remoteSessionOperationSchema = external_exports.discriminatedUnion("kind", [
|
|
|
16873
17492
|
...thread,
|
|
16874
17493
|
epoch: identity,
|
|
16875
17494
|
modelId: identity.optional(),
|
|
17495
|
+
serviceTier: harnessModelServiceTierSchema.optional(),
|
|
16876
17496
|
thinkingOptionId: identity.optional(),
|
|
16877
17497
|
permissionModeId: identity.optional()
|
|
16878
|
-
}).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
|
+
}),
|
|
16879
17501
|
external_exports.strictObject({
|
|
16880
17502
|
kind: external_exports.literal("prompt"),
|
|
16881
17503
|
...thread,
|
|
@@ -16925,7 +17547,7 @@ var remoteConnectionsRequestSchema = external_exports.discriminatedUnion("action
|
|
|
16925
17547
|
external_exports.strictObject({ action: external_exports.literal("catalog") }),
|
|
16926
17548
|
external_exports.strictObject({
|
|
16927
17549
|
action: external_exports.literal("read-thread"),
|
|
16928
|
-
hostId: hostId.refine((
|
|
17550
|
+
hostId: hostId.refine((id2) => id2 !== "local"),
|
|
16929
17551
|
input: delegationReadParamsSchema
|
|
16930
17552
|
}),
|
|
16931
17553
|
external_exports.strictObject({
|
|
@@ -16939,7 +17561,7 @@ var remoteConnectionsRequestSchema = external_exports.discriminatedUnion("action
|
|
|
16939
17561
|
external_exports.strictObject({ action: external_exports.literal("runtime"), hostId }),
|
|
16940
17562
|
external_exports.strictObject({
|
|
16941
17563
|
action: external_exports.literal("update"),
|
|
16942
|
-
hostId: hostId.refine((
|
|
17564
|
+
hostId: hostId.refine((id2) => id2 !== "local"),
|
|
16943
17565
|
version: remoteUpdateParamsSchema.shape.version
|
|
16944
17566
|
})
|
|
16945
17567
|
]);
|
|
@@ -17003,7 +17625,7 @@ function invalidRequest(message) {
|
|
|
17003
17625
|
return { code: "invalidRequest", message, retryable: false };
|
|
17004
17626
|
}
|
|
17005
17627
|
function validateHostApprovalResponse(interaction, response) {
|
|
17006
|
-
return interaction.actions.some(({ id }) =>
|
|
17628
|
+
return interaction.actions.some(({ id: id2 }) => id2 === response.actionId) ? null : invalidRequest("Approval Response contains an undeclared action ID");
|
|
17007
17629
|
}
|
|
17008
17630
|
|
|
17009
17631
|
// ../../harness-adapter/dist/question.js
|
|
@@ -17011,7 +17633,7 @@ function invalidRequest2(message) {
|
|
|
17011
17633
|
return { code: "invalidRequest", message, retryable: false };
|
|
17012
17634
|
}
|
|
17013
17635
|
function validateHostQuestionResponse(interaction, response) {
|
|
17014
|
-
const questionIds = new Set(interaction.questions.map(({ id }) =>
|
|
17636
|
+
const questionIds = new Set(interaction.questions.map(({ id: id2 }) => id2));
|
|
17015
17637
|
if (response.cancelled) {
|
|
17016
17638
|
return Object.keys(response.answers).length === 0 ? null : invalidRequest2("Cancelled Question Response must not contain answers");
|
|
17017
17639
|
}
|
|
@@ -17042,6 +17664,18 @@ function validateHostQuestionResponse(interaction, response) {
|
|
|
17042
17664
|
return null;
|
|
17043
17665
|
}
|
|
17044
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
|
+
|
|
17045
17679
|
// ../../harness-adapter/dist/output-channel.js
|
|
17046
17680
|
var HarnessOutputChannel = class {
|
|
17047
17681
|
outputs;
|
|
@@ -17126,7 +17760,8 @@ var tokenFields = [
|
|
|
17126
17760
|
var safeIntegerFields = [
|
|
17127
17761
|
"planFiveHourResetsAtUnix",
|
|
17128
17762
|
"planSevenDayResetsAtUnix",
|
|
17129
|
-
"timeToFirstOutputMs"
|
|
17763
|
+
"timeToFirstOutputMs",
|
|
17764
|
+
"latestRequestTimeToFirstOutputMs"
|
|
17130
17765
|
];
|
|
17131
17766
|
var percentFields = [
|
|
17132
17767
|
"cacheHitRatePercent",
|
|
@@ -17336,21 +17971,11 @@ async function hermesPythonCommand(runtime, script, environment, timeoutMs = 2e4
|
|
|
17336
17971
|
function isHermesModeId(value) {
|
|
17337
17972
|
return value === "default" || value === "dont_ask";
|
|
17338
17973
|
}
|
|
17339
|
-
function
|
|
17340
|
-
|
|
17341
|
-
id: Buffer.from(modelId2, "utf8").toString("base64url")
|
|
17342
|
-
});
|
|
17343
|
-
return ref.success ? ref.data : null;
|
|
17974
|
+
function hermesModelRef(id2) {
|
|
17975
|
+
return harnessModelRefSchema.safeParse({ id: id2 }).data ?? null;
|
|
17344
17976
|
}
|
|
17345
|
-
function
|
|
17346
|
-
|
|
17347
|
-
return null;
|
|
17348
|
-
try {
|
|
17349
|
-
const decoded = Buffer.from(modelRefId, "base64url").toString("utf8");
|
|
17350
|
-
return decoded.length > 0 ? decoded : null;
|
|
17351
|
-
} catch {
|
|
17352
|
-
return null;
|
|
17353
|
-
}
|
|
17977
|
+
function normalizeStoredHermesModelRef(ref, catalog) {
|
|
17978
|
+
return normalizeLegacyBase64ModelRef(ref, catalog, "");
|
|
17354
17979
|
}
|
|
17355
17980
|
function catalogAlignedModelLabel(name) {
|
|
17356
17981
|
return name.replace(/\s+·\s+/g, " / ");
|
|
@@ -17363,7 +17988,7 @@ function projectHermesModelState(models) {
|
|
|
17363
17988
|
if (!current)
|
|
17364
17989
|
return { effectiveModel: null, resolvedModelLabel: null };
|
|
17365
17990
|
return {
|
|
17366
|
-
effectiveModel:
|
|
17991
|
+
effectiveModel: hermesModelRef(current.modelId),
|
|
17367
17992
|
resolvedModelLabel: catalogAlignedModelLabel(current.name)
|
|
17368
17993
|
};
|
|
17369
17994
|
}
|
|
@@ -17608,7 +18233,7 @@ function catalogModelsFromInventory(inventory) {
|
|
|
17608
18233
|
if (model2.available === false)
|
|
17609
18234
|
continue;
|
|
17610
18235
|
const nativeModelId = model2.modelId;
|
|
17611
|
-
const ref =
|
|
18236
|
+
const ref = hermesModelRef(nativeModelId);
|
|
17612
18237
|
if (!ref)
|
|
17613
18238
|
continue;
|
|
17614
18239
|
if (inventory.currentModelId && (model2.modelId === inventory.currentModelId || nativeModelId === inventory.currentModelId || model2.modelIdAliases?.includes(inventory.currentModelId))) {
|
|
@@ -17866,7 +18491,7 @@ var HermesGatewayTransport = class _HermesGatewayTransport {
|
|
|
17866
18491
|
environment;
|
|
17867
18492
|
timeoutMs;
|
|
17868
18493
|
onEvent = () => void 0;
|
|
17869
|
-
onRequest = (
|
|
18494
|
+
onRequest = (id2) => this.rejectRequest(id2);
|
|
17870
18495
|
onFault = () => void 0;
|
|
17871
18496
|
#child = null;
|
|
17872
18497
|
#nextId = 0;
|
|
@@ -18013,10 +18638,10 @@ var HermesGatewayTransport = class _HermesGatewayTransport {
|
|
|
18013
18638
|
async request(method, params, timeoutMs = this.timeoutMs, fatalOnTimeout = true) {
|
|
18014
18639
|
if (this.#closed || !this.#child)
|
|
18015
18640
|
throw new Error("Hermes gateway is closed");
|
|
18016
|
-
const
|
|
18641
|
+
const id2 = `codexhost-${++this.#nextId}`;
|
|
18017
18642
|
const response = new Promise((resolve, reject) => {
|
|
18018
|
-
this.#pending.set(
|
|
18019
|
-
this.#send({ jsonrpc: "2.0", id, method, params });
|
|
18643
|
+
this.#pending.set(id2, { resolve, reject });
|
|
18644
|
+
this.#send({ jsonrpc: "2.0", id: id2, method, params });
|
|
18020
18645
|
});
|
|
18021
18646
|
try {
|
|
18022
18647
|
return await withTimeout(response, timeoutMs, `Hermes ${method}`);
|
|
@@ -18025,16 +18650,16 @@ var HermesGatewayTransport = class _HermesGatewayTransport {
|
|
|
18025
18650
|
this.#fault(error51);
|
|
18026
18651
|
throw error51;
|
|
18027
18652
|
} finally {
|
|
18028
|
-
this.#pending.delete(
|
|
18653
|
+
this.#pending.delete(id2);
|
|
18029
18654
|
}
|
|
18030
18655
|
}
|
|
18031
|
-
respond(
|
|
18032
|
-
this.#send({ jsonrpc: "2.0", id, result });
|
|
18656
|
+
respond(id2, result) {
|
|
18657
|
+
this.#send({ jsonrpc: "2.0", id: id2, result });
|
|
18033
18658
|
}
|
|
18034
|
-
rejectRequest(
|
|
18659
|
+
rejectRequest(id2) {
|
|
18035
18660
|
this.#send({
|
|
18036
18661
|
jsonrpc: "2.0",
|
|
18037
|
-
id,
|
|
18662
|
+
id: id2,
|
|
18038
18663
|
error: { code: -32601, message: "Unsupported Host interaction" }
|
|
18039
18664
|
});
|
|
18040
18665
|
}
|
|
@@ -18063,11 +18688,11 @@ var HermesGatewayTransport = class _HermesGatewayTransport {
|
|
|
18063
18688
|
this.onRequest(frame.id, frame.method, gatewayRecord(frame.params));
|
|
18064
18689
|
return;
|
|
18065
18690
|
}
|
|
18066
|
-
const
|
|
18067
|
-
const pending = this.#pending.get(
|
|
18691
|
+
const id2 = gatewayString(frame.id);
|
|
18692
|
+
const pending = this.#pending.get(id2);
|
|
18068
18693
|
if (!pending)
|
|
18069
18694
|
return;
|
|
18070
|
-
this.#pending.delete(
|
|
18695
|
+
this.#pending.delete(id2);
|
|
18071
18696
|
if (frame.error)
|
|
18072
18697
|
pending.reject(new Error(gatewayString(gatewayRecord(frame.error).message) || "Hermes gateway request failed"));
|
|
18073
18698
|
else
|
|
@@ -18701,7 +19326,7 @@ function projectGatewayHistory(sessionId, data) {
|
|
|
18701
19326
|
for (const row of data.rows) {
|
|
18702
19327
|
if (!Number.isSafeInteger(row.id) || !Number.isSafeInteger(row.original_id))
|
|
18703
19328
|
throw new Error("Hermes history has no durable message identity");
|
|
18704
|
-
const
|
|
19329
|
+
const id2 = String(row.original_id);
|
|
18705
19330
|
if (row.role === "user") {
|
|
18706
19331
|
if (typeof row.user_text !== "string")
|
|
18707
19332
|
continue;
|
|
@@ -18711,7 +19336,7 @@ function projectGatewayHistory(sessionId, data) {
|
|
|
18711
19336
|
nativeTurnRef: nativeTurnRefSchema.parse({
|
|
18712
19337
|
harnessId: "hermes",
|
|
18713
19338
|
nativeSessionId: sessionId,
|
|
18714
|
-
nativeTurnKey:
|
|
19339
|
+
nativeTurnKey: id2,
|
|
18715
19340
|
formatVersion: 1
|
|
18716
19341
|
}),
|
|
18717
19342
|
...boundary ? {
|
|
@@ -18736,7 +19361,7 @@ function projectGatewayHistory(sessionId, data) {
|
|
|
18736
19361
|
}
|
|
18737
19362
|
if (!turn)
|
|
18738
19363
|
continue;
|
|
18739
|
-
const itemId = (suffix) => hostItemIdSchema.parse(`hermes:${
|
|
19364
|
+
const itemId = (suffix) => hostItemIdSchema.parse(`hermes:${id2}:${suffix}`);
|
|
18740
19365
|
if (row.role === "assistant") {
|
|
18741
19366
|
const reasoning = row.display_visible === false ? "" : text(row.reasoning_content) || text(row.reasoning);
|
|
18742
19367
|
if (reasoning)
|
|
@@ -18973,22 +19598,22 @@ var hermesGatewayThinkingOptions = [
|
|
|
18973
19598
|
"xhigh",
|
|
18974
19599
|
"max",
|
|
18975
19600
|
"ultra"
|
|
18976
|
-
].map((
|
|
19601
|
+
].map((id2) => ({ id: harnessThinkingOptionIdSchema.parse(id2), label: id2 }));
|
|
18977
19602
|
function question(entry, fallbackId) {
|
|
18978
|
-
const
|
|
19603
|
+
const id2 = gatewayString(entry.qid) || fallbackId;
|
|
18979
19604
|
const prompt = gatewayString(entry.question);
|
|
18980
19605
|
if (!prompt)
|
|
18981
19606
|
throw new Error("Hermes clarify request has no question");
|
|
18982
19607
|
const choices = Array.isArray(entry.choices) ? entry.choices.filter((choice) => typeof choice === "string") : [];
|
|
18983
19608
|
return choices.length ? {
|
|
18984
|
-
id,
|
|
19609
|
+
id: id2,
|
|
18985
19610
|
type: "choice",
|
|
18986
19611
|
prompt,
|
|
18987
19612
|
options: choices.map((value) => ({ value, label: value })),
|
|
18988
19613
|
multiple: entry.multi_select === true,
|
|
18989
19614
|
allowOther: true,
|
|
18990
19615
|
optional: false
|
|
18991
|
-
} : { id, type: "text", prompt, multiline: true, secret: false, optional: false };
|
|
19616
|
+
} : { id: id2, type: "text", prompt, multiline: true, secret: false, optional: false };
|
|
18992
19617
|
}
|
|
18993
19618
|
function gatewayDiff(text2) {
|
|
18994
19619
|
if (!text2 || text2.length > 1024 * 1024)
|
|
@@ -19110,8 +19735,8 @@ var HermesGatewaySessionTransport = class {
|
|
|
19110
19735
|
nativeSessionId
|
|
19111
19736
|
});
|
|
19112
19737
|
transport.onEvent = (event) => this.#event(event);
|
|
19113
|
-
transport.onRequest = (
|
|
19114
|
-
void this.#request(
|
|
19738
|
+
transport.onRequest = (id2, method, params) => {
|
|
19739
|
+
void this.#request(id2, method, params).catch((error51) => this.#fault(error51));
|
|
19115
19740
|
};
|
|
19116
19741
|
transport.onFault = (error51) => this.#fault(error51);
|
|
19117
19742
|
}
|
|
@@ -19142,7 +19767,7 @@ var HermesGatewaySessionTransport = class {
|
|
|
19142
19767
|
]
|
|
19143
19768
|
},
|
|
19144
19769
|
thinkingOptions: hermesGatewayThinkingOptions,
|
|
19145
|
-
...hermesGatewayThinkingOptions.some(({ id }) =>
|
|
19770
|
+
...hermesGatewayThinkingOptions.some(({ id: id2 }) => id2 === currentThinkingOptionId) ? { currentThinkingOptionId } : {}
|
|
19146
19771
|
}
|
|
19147
19772
|
};
|
|
19148
19773
|
}
|
|
@@ -19150,7 +19775,7 @@ var HermesGatewaySessionTransport = class {
|
|
|
19150
19775
|
return this.history.readSnapshot();
|
|
19151
19776
|
}
|
|
19152
19777
|
async setThinking(optionId) {
|
|
19153
|
-
if (!hermesGatewayThinkingOptions.some(({ id }) =>
|
|
19778
|
+
if (!hermesGatewayThinkingOptions.some(({ id: id2 }) => id2 === optionId))
|
|
19154
19779
|
throw new Error("Unsupported Hermes reasoning effort");
|
|
19155
19780
|
const result = await this.transport.request("config.set", {
|
|
19156
19781
|
key: "reasoning",
|
|
@@ -19209,7 +19834,7 @@ var HermesGatewaySessionTransport = class {
|
|
|
19209
19834
|
rejectResult = reject;
|
|
19210
19835
|
});
|
|
19211
19836
|
void result.catch(() => void 0);
|
|
19212
|
-
const
|
|
19837
|
+
const active2 = {
|
|
19213
19838
|
emit,
|
|
19214
19839
|
permission,
|
|
19215
19840
|
...question2 ? { question: question2 } : {},
|
|
@@ -19220,8 +19845,8 @@ var HermesGatewaySessionTransport = class {
|
|
|
19220
19845
|
toolIds: /* @__PURE__ */ new Set(),
|
|
19221
19846
|
admissionId: null
|
|
19222
19847
|
};
|
|
19223
|
-
this.#active =
|
|
19224
|
-
void this.#adoptedPrompts.splice(0).map((prompt) => void this.#respondAdoptedApproval(prompt,
|
|
19848
|
+
this.#active = active2;
|
|
19849
|
+
void this.#adoptedPrompts.splice(0).map((prompt) => void this.#respondAdoptedApproval(prompt, active2).catch(() => void 0));
|
|
19225
19850
|
const commandText = text2.trim();
|
|
19226
19851
|
const nativeCommand = this.nativeCommandName(text2);
|
|
19227
19852
|
try {
|
|
@@ -19239,7 +19864,7 @@ var HermesGatewaySessionTransport = class {
|
|
|
19239
19864
|
throw new Error("Hermes returned an unrecognized compression outcome");
|
|
19240
19865
|
this.#usage(gatewayRecord(compact.usage));
|
|
19241
19866
|
const succeeded = compact.status === "compressed" && summary.noop !== true;
|
|
19242
|
-
|
|
19867
|
+
active2.resolve({
|
|
19243
19868
|
stopReason: "end_turn",
|
|
19244
19869
|
compactionOutcome: compact.status === "aborted" || summary.aborted === true ? {
|
|
19245
19870
|
status: "failed",
|
|
@@ -19258,7 +19883,7 @@ var HermesGatewaySessionTransport = class {
|
|
|
19258
19883
|
if (typeof response.output !== "string")
|
|
19259
19884
|
throw new HermesTransportError("protocolError", "Hermes slash.exec did not return terminal command output");
|
|
19260
19885
|
emit({ type: "agent.text", text: response.output });
|
|
19261
|
-
|
|
19886
|
+
active2.resolve({ stopReason: "end_turn" });
|
|
19262
19887
|
} else {
|
|
19263
19888
|
const guidance = this.#delegationGuidance;
|
|
19264
19889
|
this.#delegationGuidance = null;
|
|
@@ -19273,16 +19898,16 @@ ${text2}` } : {}
|
|
|
19273
19898
|
});
|
|
19274
19899
|
if (submitted.status !== "queued" && submitted.status !== "started")
|
|
19275
19900
|
this.#fault(new Error(`Hermes did not accept the turn (${String(submitted.status)})`));
|
|
19276
|
-
else if (
|
|
19277
|
-
|
|
19901
|
+
else if (active2.admissionId === null && typeof submitted.admission_id === "string")
|
|
19902
|
+
active2.admissionId = submitted.admission_id;
|
|
19278
19903
|
}
|
|
19279
19904
|
} catch (error51) {
|
|
19280
|
-
|
|
19905
|
+
active2.reject(error51 instanceof Error ? error51 : new Error(String(error51)));
|
|
19281
19906
|
}
|
|
19282
19907
|
try {
|
|
19283
19908
|
return await result;
|
|
19284
19909
|
} finally {
|
|
19285
|
-
if (this.#active ===
|
|
19910
|
+
if (this.#active === active2)
|
|
19286
19911
|
this.#active = null;
|
|
19287
19912
|
for (const controller of this.#requests.values())
|
|
19288
19913
|
controller.abort("cancelled");
|
|
@@ -19348,46 +19973,46 @@ ${text2}` } : {}
|
|
|
19348
19973
|
return;
|
|
19349
19974
|
}
|
|
19350
19975
|
if (event.type === "approval.cancelled") {
|
|
19351
|
-
const ids = Array.isArray(payload.request_ids) ? payload.request_ids.filter((
|
|
19352
|
-
for (const
|
|
19353
|
-
this.#approvalRequests.get(
|
|
19354
|
-
this.#approvalRequests.delete(
|
|
19976
|
+
const ids = Array.isArray(payload.request_ids) ? payload.request_ids.filter((id2) => typeof id2 === "string") : [];
|
|
19977
|
+
for (const id2 of ids) {
|
|
19978
|
+
this.#approvalRequests.get(id2)?.abort("cancelled");
|
|
19979
|
+
this.#approvalRequests.delete(id2);
|
|
19355
19980
|
}
|
|
19356
19981
|
return;
|
|
19357
19982
|
}
|
|
19358
|
-
const
|
|
19359
|
-
if (!
|
|
19983
|
+
const active2 = this.#active;
|
|
19984
|
+
if (!active2) {
|
|
19360
19985
|
if (event.type === "error")
|
|
19361
19986
|
this.#fault(new Error(gatewayString(payload.message)));
|
|
19362
19987
|
return;
|
|
19363
19988
|
}
|
|
19364
19989
|
const eventAdmission = gatewayString(event.admission_id);
|
|
19365
19990
|
const eventType = gatewayString(event.type);
|
|
19366
|
-
if (eventAdmission &&
|
|
19991
|
+
if (eventAdmission && active2.admissionId && eventAdmission !== active2.admissionId) {
|
|
19367
19992
|
if (eventType.startsWith("message.") || eventType.startsWith("reasoning."))
|
|
19368
19993
|
return;
|
|
19369
19994
|
}
|
|
19370
19995
|
const text2 = gatewayString(payload.text);
|
|
19371
19996
|
if (event.type === "message.delta") {
|
|
19372
|
-
|
|
19373
|
-
|
|
19997
|
+
active2.streamed += text2;
|
|
19998
|
+
active2.emit({ type: "agent.text", text: text2 });
|
|
19374
19999
|
} else if (event.type === "reasoning.delta" || event.type === "reasoning.available") {
|
|
19375
|
-
if (event.type === "reasoning.delta" || !
|
|
19376
|
-
|
|
19377
|
-
|
|
20000
|
+
if (event.type === "reasoning.delta" || !active2.reasoning) {
|
|
20001
|
+
active2.reasoning += text2;
|
|
20002
|
+
active2.emit({ type: "agent.thought", text: text2 });
|
|
19378
20003
|
}
|
|
19379
20004
|
} else if (event.type === "message.interim") {
|
|
19380
20005
|
if (payload.already_streamed !== true)
|
|
19381
|
-
|
|
19382
|
-
|
|
19383
|
-
|
|
20006
|
+
active2.emit({ type: "agent.text", text: text2 });
|
|
20007
|
+
active2.streamed = "";
|
|
20008
|
+
active2.reasoning = "";
|
|
19384
20009
|
} else if (event.type === "status.update") {
|
|
19385
20010
|
if (payload.kind === "compacting")
|
|
19386
|
-
|
|
20011
|
+
active2.emit({ type: "compaction.started", text: text2 });
|
|
19387
20012
|
else if (payload.kind === "compacted")
|
|
19388
|
-
|
|
20013
|
+
active2.emit({ type: "compaction.finished", text: text2 });
|
|
19389
20014
|
else if (payload.kind === "warning")
|
|
19390
|
-
|
|
20015
|
+
active2.emit({ type: "status.warning", text: text2 });
|
|
19391
20016
|
} else if (event.type === "tool.start" || event.type === "tool.complete") {
|
|
19392
20017
|
const toolCallId = gatewayString(payload.tool_id);
|
|
19393
20018
|
if (!toolCallId)
|
|
@@ -19398,8 +20023,8 @@ ${text2}` } : {}
|
|
|
19398
20023
|
...output ? [{ type: "content", content: { type: "text", text: output } }] : [],
|
|
19399
20024
|
...gatewayDiff(gatewayString(payload.inline_diff))
|
|
19400
20025
|
];
|
|
19401
|
-
if (event.type === "tool.complete" && !
|
|
19402
|
-
|
|
20026
|
+
if (event.type === "tool.complete" && !active2.toolIds.has(toolCallId))
|
|
20027
|
+
active2.emit({
|
|
19403
20028
|
type: "tool.call",
|
|
19404
20029
|
toolCallId,
|
|
19405
20030
|
update: {
|
|
@@ -19409,8 +20034,8 @@ ${text2}` } : {}
|
|
|
19409
20034
|
status: "in_progress"
|
|
19410
20035
|
}
|
|
19411
20036
|
});
|
|
19412
|
-
|
|
19413
|
-
|
|
20037
|
+
active2.toolIds.add(toolCallId);
|
|
20038
|
+
active2.emit(event.type === "tool.start" ? {
|
|
19414
20039
|
type: "tool.call",
|
|
19415
20040
|
toolCallId,
|
|
19416
20041
|
update: {
|
|
@@ -19429,28 +20054,28 @@ ${text2}` } : {}
|
|
|
19429
20054
|
}
|
|
19430
20055
|
});
|
|
19431
20056
|
} else if (event.type === "message.complete") {
|
|
19432
|
-
if (!
|
|
19433
|
-
|
|
19434
|
-
else if (text2.startsWith(
|
|
19435
|
-
|
|
20057
|
+
if (!active2.streamed)
|
|
20058
|
+
active2.emit({ type: "agent.text", text: text2 });
|
|
20059
|
+
else if (text2.startsWith(active2.streamed) && text2.length > active2.streamed.length)
|
|
20060
|
+
active2.emit({ type: "agent.text", text: text2.slice(active2.streamed.length) });
|
|
19436
20061
|
const reasoning = gatewayString(payload.reasoning);
|
|
19437
|
-
if (reasoning && !
|
|
19438
|
-
|
|
19439
|
-
else if (reasoning.startsWith(
|
|
19440
|
-
|
|
20062
|
+
if (reasoning && !active2.reasoning)
|
|
20063
|
+
active2.emit({ type: "agent.thought", text: reasoning });
|
|
20064
|
+
else if (reasoning.startsWith(active2.reasoning) && reasoning.length > active2.reasoning.length)
|
|
20065
|
+
active2.emit({ type: "agent.thought", text: reasoning.slice(active2.reasoning.length) });
|
|
19441
20066
|
const usage = gatewayRecord(payload.usage);
|
|
19442
20067
|
const terminalUsage = projectGatewayUsage(usage);
|
|
19443
20068
|
this.#usage(usage);
|
|
19444
20069
|
if (payload.status === "error")
|
|
19445
|
-
|
|
20070
|
+
active2.reject(new Error(gatewayString(payload.error) || gatewayString(payload.failure_reason) || "Hermes turn failed"));
|
|
19446
20071
|
else
|
|
19447
|
-
|
|
20072
|
+
active2.resolve({
|
|
19448
20073
|
stopReason: payload.status === "interrupted" ? "cancelled" : "end_turn",
|
|
19449
20074
|
...payload.status === "complete" && text2.trim() ? { finalAnswerText: text2 } : {},
|
|
19450
20075
|
...terminalUsage ? { usage: terminalUsage } : {}
|
|
19451
20076
|
});
|
|
19452
20077
|
} else if (event.type === "error")
|
|
19453
|
-
|
|
20078
|
+
active2.reject(new Error(gatewayString(payload.message) || "Hermes gateway failed"));
|
|
19454
20079
|
}
|
|
19455
20080
|
#usage(usage) {
|
|
19456
20081
|
const projected = projectGatewayUsage(usage);
|
|
@@ -19461,19 +20086,19 @@ ${text2}` } : {}
|
|
|
19461
20086
|
else
|
|
19462
20087
|
this.onUsage?.(projected);
|
|
19463
20088
|
}
|
|
19464
|
-
async #request(
|
|
19465
|
-
const
|
|
19466
|
-
if (!
|
|
19467
|
-
this.transport.rejectRequest(
|
|
20089
|
+
async #request(id2, method, params) {
|
|
20090
|
+
const active2 = this.#active;
|
|
20091
|
+
if (!active2 || params.session_id !== this.sessionId || !["clarify", "approval"].includes(method)) {
|
|
20092
|
+
this.transport.rejectRequest(id2);
|
|
19468
20093
|
return;
|
|
19469
20094
|
}
|
|
19470
20095
|
const controller = new AbortController();
|
|
19471
|
-
this.#requests.set(
|
|
20096
|
+
this.#requests.set(id2, controller);
|
|
19472
20097
|
try {
|
|
19473
|
-
if (method === "clarify" &&
|
|
20098
|
+
if (method === "clarify" && active2.question) {
|
|
19474
20099
|
const batch = Array.isArray(params.questions);
|
|
19475
20100
|
const questions = batch ? params.questions.map((value, index) => question(gatewayRecord(value), String(index))) : [question(params, "answer")];
|
|
19476
|
-
const response = await
|
|
20101
|
+
const response = await active2.question({
|
|
19477
20102
|
title: "Hermes",
|
|
19478
20103
|
questions,
|
|
19479
20104
|
signal: controller.signal
|
|
@@ -19486,7 +20111,7 @@ ${text2}` } : {}
|
|
|
19486
20111
|
q?.type === "choice" && q.multiple ? JSON.stringify(values) : values[0] ?? ""
|
|
19487
20112
|
];
|
|
19488
20113
|
}));
|
|
19489
|
-
this.transport.respond(
|
|
20114
|
+
this.transport.respond(id2, response.cancelled ? {} : batch ? { answers } : { answer: answers.answer ?? "" });
|
|
19490
20115
|
}
|
|
19491
20116
|
} else if (method === "approval") {
|
|
19492
20117
|
const choices = Array.isArray(params.choices) ? params.choices : ["once", "deny"];
|
|
@@ -19501,14 +20126,14 @@ ${text2}` } : {}
|
|
|
19501
20126
|
if (payloadRequestId)
|
|
19502
20127
|
this.#approvalRequests.set(payloadRequestId, controller);
|
|
19503
20128
|
try {
|
|
19504
|
-
const response = await
|
|
20129
|
+
const response = await active2.permission({
|
|
19505
20130
|
signal: controller.signal,
|
|
19506
20131
|
title: gatewayString(params.description) || gatewayString(params.command),
|
|
19507
20132
|
description: gatewayString(params.command) || gatewayString(params.description),
|
|
19508
20133
|
options
|
|
19509
20134
|
});
|
|
19510
20135
|
if (!controller.signal.aborted)
|
|
19511
|
-
this.transport.respond(
|
|
20136
|
+
this.transport.respond(id2, {
|
|
19512
20137
|
choice: response ?? "deny"
|
|
19513
20138
|
});
|
|
19514
20139
|
} finally {
|
|
@@ -19516,9 +20141,9 @@ ${text2}` } : {}
|
|
|
19516
20141
|
this.#approvalRequests.delete(payloadRequestId);
|
|
19517
20142
|
}
|
|
19518
20143
|
} else
|
|
19519
|
-
this.transport.rejectRequest(
|
|
20144
|
+
this.transport.rejectRequest(id2);
|
|
19520
20145
|
} finally {
|
|
19521
|
-
this.#requests.delete(
|
|
20146
|
+
this.#requests.delete(id2);
|
|
19522
20147
|
}
|
|
19523
20148
|
}
|
|
19524
20149
|
/** Keep approval prompts from the create/resume snapshot for the next turn. */
|
|
@@ -19537,7 +20162,7 @@ ${text2}` } : {}
|
|
|
19537
20162
|
* question is served by the `clarify` server request (batch mode), and the
|
|
19538
20163
|
* gateway re-issues still-open server requests to an attaching client.
|
|
19539
20164
|
*/
|
|
19540
|
-
async #respondAdoptedApproval(prompt,
|
|
20165
|
+
async #respondAdoptedApproval(prompt, active2) {
|
|
19541
20166
|
if (this.#closed)
|
|
19542
20167
|
return;
|
|
19543
20168
|
const promptId = gatewayString(prompt.prompt_id);
|
|
@@ -19550,7 +20175,7 @@ ${text2}` } : {}
|
|
|
19550
20175
|
label: choice === "session" ? "Allow for this session" : "Always allow"
|
|
19551
20176
|
}
|
|
19552
20177
|
] : choice === "deny" ? [{ id: "deny", effect: "deny", label: "Deny" }] : []);
|
|
19553
|
-
const response = await
|
|
20178
|
+
const response = await active2.permission({
|
|
19554
20179
|
signal: new AbortController().signal,
|
|
19555
20180
|
title: gatewayString(prompt.description) || gatewayString(prompt.command) || "Hermes approval requested before this Session attached",
|
|
19556
20181
|
description: gatewayString(prompt.command) || gatewayString(prompt.description),
|
|
@@ -19654,7 +20279,7 @@ function hermesUsageEntry(row) {
|
|
|
19654
20279
|
if (apiCalls === 0 && input === 0 && output === 0 && cacheRead === 0 && cacheWrite === 0) {
|
|
19655
20280
|
return null;
|
|
19656
20281
|
}
|
|
19657
|
-
const
|
|
20282
|
+
const id2 = typeof row.id === "string" && row.id.length > 0 ? row.id : null;
|
|
19658
20283
|
const epochSeconds = (value) => {
|
|
19659
20284
|
if (typeof value !== "number" || !Number.isFinite(value))
|
|
19660
20285
|
return null;
|
|
@@ -19662,10 +20287,10 @@ function hermesUsageEntry(row) {
|
|
|
19662
20287
|
return Number.isSafeInteger(ms) && !Number.isNaN(new Date(ms).getTime()) ? ms : null;
|
|
19663
20288
|
};
|
|
19664
20289
|
const at = epochSeconds(row.last_activity_at) ?? epochSeconds(row.started_at);
|
|
19665
|
-
if (
|
|
20290
|
+
if (id2 === null || at === null)
|
|
19666
20291
|
return null;
|
|
19667
20292
|
const request = {
|
|
19668
|
-
requestId:
|
|
20293
|
+
requestId: id2,
|
|
19669
20294
|
...typeof row.model === "string" && row.model.length > 0 ? { model: row.model } : {},
|
|
19670
20295
|
inputTokens: input + cacheRead + cacheWrite,
|
|
19671
20296
|
outputTokens: output,
|
|
@@ -19677,7 +20302,7 @@ function hermesUsageEntry(row) {
|
|
|
19677
20302
|
if (!entry)
|
|
19678
20303
|
return null;
|
|
19679
20304
|
return withUsageSession(entry, {
|
|
19680
|
-
sessionId:
|
|
20305
|
+
sessionId: id2,
|
|
19681
20306
|
cwd: typeof row.cwd === "string" ? row.cwd : void 0,
|
|
19682
20307
|
title: usageSessionTitle(row.title ?? row.display_name)
|
|
19683
20308
|
});
|
|
@@ -19709,7 +20334,7 @@ function createHermesUsageStatistics(environment) {
|
|
|
19709
20334
|
const stamp = await fingerprint(file2);
|
|
19710
20335
|
return stamp ? [{ id: file2, fingerprint: stamp }] : [];
|
|
19711
20336
|
},
|
|
19712
|
-
readSource: (
|
|
20337
|
+
readSource: (id2) => readHermesUsage(id2)
|
|
19713
20338
|
});
|
|
19714
20339
|
}
|
|
19715
20340
|
|
|
@@ -19769,15 +20394,15 @@ var HermesQuestions = class {
|
|
|
19769
20394
|
return { ok: true, value: { accepted: true } };
|
|
19770
20395
|
}
|
|
19771
20396
|
cancel(turnId) {
|
|
19772
|
-
for (const [
|
|
20397
|
+
for (const [id2, waiter] of this.#waiters)
|
|
19773
20398
|
if (!turnId || waiter.interaction.turnId === turnId)
|
|
19774
|
-
this.#cancel(
|
|
20399
|
+
this.#cancel(id2, "cancelled");
|
|
19775
20400
|
}
|
|
19776
|
-
#cancel(
|
|
19777
|
-
const waiter = this.#waiters.get(
|
|
20401
|
+
#cancel(id2, reason) {
|
|
20402
|
+
const waiter = this.#waiters.get(id2);
|
|
19778
20403
|
if (!waiter)
|
|
19779
20404
|
return;
|
|
19780
|
-
this.#waiters.delete(
|
|
20405
|
+
this.#waiters.delete(id2);
|
|
19781
20406
|
waiter.resolve({ type: "question", answers: {}, cancelled: true });
|
|
19782
20407
|
this.emit({
|
|
19783
20408
|
kind: "event",
|
|
@@ -20671,27 +21296,27 @@ var HermesSession = class {
|
|
|
20671
21296
|
if (requireNativeCommand && !nativeCommand)
|
|
20672
21297
|
return err("unsupported", "Hermes no longer advertises this command");
|
|
20673
21298
|
const isNativeCommand = nativeCommand != null;
|
|
20674
|
-
const
|
|
20675
|
-
this.#activeTurn =
|
|
20676
|
-
this.#activeTurnId =
|
|
20677
|
-
void this.#runTurn(
|
|
20678
|
-
return ok({ turnId:
|
|
20679
|
-
}
|
|
20680
|
-
async #runTurn(
|
|
20681
|
-
this.#emit({ type: "turn.started", turnId:
|
|
20682
|
-
if (
|
|
20683
|
-
this.#emit({ type: "item.started", turnId:
|
|
21299
|
+
const active2 = new ActiveTurn(command.turnId, turnKey, command.input, !isNativeCommand, isNativeCommand && nativeCommand === "compress");
|
|
21300
|
+
this.#activeTurn = active2;
|
|
21301
|
+
this.#activeTurnId = active2.turnId;
|
|
21302
|
+
void this.#runTurn(active2, text2);
|
|
21303
|
+
return ok({ turnId: active2.turnId });
|
|
21304
|
+
}
|
|
21305
|
+
async #runTurn(active2, text2) {
|
|
21306
|
+
this.#emit({ type: "turn.started", turnId: active2.turnId });
|
|
21307
|
+
if (active2.compactionItem)
|
|
21308
|
+
this.#emit({ type: "item.started", turnId: active2.turnId, item: active2.compactionItem });
|
|
20684
21309
|
let promptResponse = null;
|
|
20685
21310
|
let failure2 = null;
|
|
20686
21311
|
let previousNativeTurnKey;
|
|
20687
21312
|
try {
|
|
20688
|
-
if (
|
|
21313
|
+
if (active2.persistsHistory && this.#transport.readNativeSnapshot)
|
|
20689
21314
|
previousNativeTurnKey = (await this.#transport.readNativeSnapshot()).turns.at(-1)?.nativeTurnRef.nativeTurnKey;
|
|
20690
|
-
promptResponse = await this.#transport.runTurn(text2, (event) => this.#handleTransportEvent(
|
|
21315
|
+
promptResponse = await this.#transport.runTurn(text2, (event) => this.#handleTransportEvent(active2, event), (request) => this.#handlePermissionRequest(active2, request), (request) => this.#handleQuestionRequest(active2, request));
|
|
20691
21316
|
} catch (error51) {
|
|
20692
21317
|
failure2 = error51 instanceof HermesTransportError ? transportErrorToHarness(error51) : harnessError("nativeFailure", error51 instanceof Error ? error51.message : String(error51));
|
|
20693
21318
|
}
|
|
20694
|
-
if (this.#activeTurn !==
|
|
21319
|
+
if (this.#activeTurn !== active2) {
|
|
20695
21320
|
return;
|
|
20696
21321
|
}
|
|
20697
21322
|
let outcome;
|
|
@@ -20707,12 +21332,12 @@ var HermesSession = class {
|
|
|
20707
21332
|
} else {
|
|
20708
21333
|
outcome = { status: "succeeded" };
|
|
20709
21334
|
}
|
|
20710
|
-
|
|
20711
|
-
if (
|
|
21335
|
+
active2.nativeCompactionOutcome = promptResponse?.compactionOutcome;
|
|
21336
|
+
if (active2.persistsHistory && this.#transport.readNativeSnapshot) {
|
|
20712
21337
|
try {
|
|
20713
21338
|
const latest = (await this.#transport.readNativeSnapshot()).turns.at(-1);
|
|
20714
21339
|
if (latest?.nativeTurnRef.nativeTurnKey !== previousNativeTurnKey)
|
|
20715
|
-
|
|
21340
|
+
active2.nativeTurnSnapshot = latest;
|
|
20716
21341
|
} catch (error51) {
|
|
20717
21342
|
outcome = {
|
|
20718
21343
|
status: "failed",
|
|
@@ -20722,72 +21347,72 @@ var HermesSession = class {
|
|
|
20722
21347
|
}
|
|
20723
21348
|
const terminalUsage = promptResponse?.usage ?? null;
|
|
20724
21349
|
const usage = terminalUsage ? this.#usage.merge(terminalUsage) : null;
|
|
20725
|
-
this.#completeActiveTurn(
|
|
21350
|
+
this.#completeActiveTurn(active2, outcome, usage, promptResponse?.finalAnswerText);
|
|
20726
21351
|
}
|
|
20727
|
-
#completeActiveTurn(
|
|
20728
|
-
if (this.#activeTurn !==
|
|
21352
|
+
#completeActiveTurn(active2, outcome, usage = null, finalAnswerText) {
|
|
21353
|
+
if (this.#activeTurn !== active2)
|
|
20729
21354
|
return;
|
|
20730
21355
|
this.#cancelApprovalWaiters();
|
|
20731
21356
|
this.#activeTurn = null;
|
|
20732
21357
|
this.#activeTurnId = null;
|
|
20733
|
-
this.#finishCompactionActivity(
|
|
20734
|
-
|
|
20735
|
-
const compactionOutcome =
|
|
21358
|
+
this.#finishCompactionActivity(active2, "当前 Turn 已结束;原生未确认自动压缩终态,提交结果未知。");
|
|
21359
|
+
active2.finish(outcome.status === "succeeded" ? finalAnswerText : void 0);
|
|
21360
|
+
const compactionOutcome = active2.finishCompaction(outcome);
|
|
20736
21361
|
if (outcome.status === "succeeded" && compactionOutcome?.status === "failed") {
|
|
20737
21362
|
outcome = { status: "failed", error: compactionOutcome.error };
|
|
20738
21363
|
}
|
|
20739
|
-
if (
|
|
20740
|
-
outcome = { ...outcome, checkpoint:
|
|
20741
|
-
const nativeTurnRef =
|
|
21364
|
+
if (active2.nativeTurnSnapshot?.checkpoint)
|
|
21365
|
+
outcome = { ...outcome, checkpoint: active2.nativeTurnSnapshot.checkpoint };
|
|
21366
|
+
const nativeTurnRef = active2.nativeTurnSnapshot?.nativeTurnRef ?? nativeTurnRefSchema.parse({
|
|
20742
21367
|
harnessId: this.#nativeRef.harnessId,
|
|
20743
21368
|
nativeSessionId: this.#nativeRef.nativeSessionId,
|
|
20744
|
-
nativeTurnKey:
|
|
21369
|
+
nativeTurnKey: active2.turnKey,
|
|
20745
21370
|
formatVersion: 1
|
|
20746
21371
|
});
|
|
20747
|
-
const turnSnapshot =
|
|
20748
|
-
for (const pending of
|
|
20749
|
-
this.#emit({ type: "item.completed", turnId:
|
|
21372
|
+
const turnSnapshot = active2.toSnapshot(nativeTurnRef, outcome, true);
|
|
21373
|
+
for (const pending of active2.drainPendingItems()) {
|
|
21374
|
+
this.#emit({ type: "item.completed", turnId: active2.turnId, snapshot: pending });
|
|
20750
21375
|
}
|
|
20751
21376
|
if (usage) {
|
|
20752
|
-
this.#emit({ type: "session.usage.changed", usage, observedForTurnId:
|
|
21377
|
+
this.#emit({ type: "session.usage.changed", usage, observedForTurnId: active2.turnId });
|
|
20753
21378
|
}
|
|
20754
21379
|
this.#emit({
|
|
20755
21380
|
type: "turn.completed",
|
|
20756
|
-
turnId:
|
|
20757
|
-
...
|
|
21381
|
+
turnId: active2.turnId,
|
|
21382
|
+
...active2.persistsHistory && (!this.#transport.readNativeSnapshot || active2.nativeTurnSnapshot) ? { nativeTurnRef } : {},
|
|
20758
21383
|
outcome
|
|
20759
21384
|
});
|
|
20760
|
-
if (
|
|
21385
|
+
if (active2.persistsHistory)
|
|
20761
21386
|
this.#completedTurns.push(turnSnapshot);
|
|
20762
21387
|
void this.#usage.refresh(true);
|
|
20763
21388
|
}
|
|
20764
|
-
#handleTransportEvent(
|
|
20765
|
-
if (this.#activeTurn !==
|
|
21389
|
+
#handleTransportEvent(active2, event) {
|
|
21390
|
+
if (this.#activeTurn !== active2)
|
|
20766
21391
|
return;
|
|
20767
21392
|
switch (event.type) {
|
|
20768
21393
|
case "usage":
|
|
20769
21394
|
this.#usage.observe(event.usage);
|
|
20770
21395
|
return;
|
|
20771
21396
|
case "status.warning": {
|
|
20772
|
-
const notice =
|
|
21397
|
+
const notice = active2.compactionActivity.appendNotice(event.text);
|
|
20773
21398
|
if (notice)
|
|
20774
21399
|
this.#emit({
|
|
20775
21400
|
type: "item.updated",
|
|
20776
|
-
turnId:
|
|
21401
|
+
turnId: active2.turnId,
|
|
20777
21402
|
itemId: notice.itemId,
|
|
20778
21403
|
update: { type: "text.append", text: notice.text }
|
|
20779
21404
|
});
|
|
20780
21405
|
return;
|
|
20781
21406
|
}
|
|
20782
21407
|
case "compaction.started": {
|
|
20783
|
-
if (
|
|
21408
|
+
if (active2.compactionItem)
|
|
20784
21409
|
return;
|
|
20785
|
-
const item =
|
|
21410
|
+
const item = active2.compactionActivity.start(event.text);
|
|
20786
21411
|
if (item) {
|
|
20787
|
-
this.#emit({ type: "item.started", turnId:
|
|
21412
|
+
this.#emit({ type: "item.started", turnId: active2.turnId, item: { ...item, text: "" } });
|
|
20788
21413
|
this.#emit({
|
|
20789
21414
|
type: "item.updated",
|
|
20790
|
-
turnId:
|
|
21415
|
+
turnId: active2.turnId,
|
|
20791
21416
|
itemId: item.itemId,
|
|
20792
21417
|
update: { type: "text.append", text: item.text }
|
|
20793
21418
|
});
|
|
@@ -20795,62 +21420,62 @@ var HermesSession = class {
|
|
|
20795
21420
|
return;
|
|
20796
21421
|
}
|
|
20797
21422
|
case "compaction.finished": {
|
|
20798
|
-
if (this.#finishCompactionActivity(
|
|
21423
|
+
if (this.#finishCompactionActivity(active2, "原生自动压缩阶段已结束;未提供压缩提交结果。"))
|
|
20799
21424
|
void this.#usage.refresh(true);
|
|
20800
21425
|
return;
|
|
20801
21426
|
}
|
|
20802
21427
|
case "agent.thought":
|
|
20803
|
-
this.#appendTextItem(
|
|
21428
|
+
this.#appendTextItem(active2, "reasoning", event.text);
|
|
20804
21429
|
return;
|
|
20805
21430
|
case "agent.text":
|
|
20806
|
-
this.#appendTextItem(
|
|
21431
|
+
this.#appendTextItem(active2, "agentMessage", event.text);
|
|
20807
21432
|
return;
|
|
20808
21433
|
case "tool.call": {
|
|
20809
21434
|
const update = event.update;
|
|
20810
|
-
this.#startToolItem(
|
|
20811
|
-
this.#updateToolItem(
|
|
21435
|
+
this.#startToolItem(active2, event.toolCallId, typeof update.title === "string" ? update.title : null, typeof update.name === "string" ? update.name : null, update.rawInput);
|
|
21436
|
+
this.#updateToolItem(active2, update);
|
|
20812
21437
|
return;
|
|
20813
21438
|
}
|
|
20814
21439
|
case "tool.update":
|
|
20815
|
-
this.#updateToolItem(
|
|
21440
|
+
this.#updateToolItem(active2, event.update);
|
|
20816
21441
|
return;
|
|
20817
21442
|
default:
|
|
20818
21443
|
return;
|
|
20819
21444
|
}
|
|
20820
21445
|
}
|
|
20821
|
-
#finishCompactionActivity(
|
|
20822
|
-
const snapshot =
|
|
21446
|
+
#finishCompactionActivity(active2, reason) {
|
|
21447
|
+
const snapshot = active2.compactionActivity.finish(reason);
|
|
20823
21448
|
if (!snapshot)
|
|
20824
21449
|
return false;
|
|
20825
|
-
|
|
21450
|
+
active2.rememberActivity(snapshot);
|
|
20826
21451
|
this.#emit({
|
|
20827
21452
|
type: "item.updated",
|
|
20828
|
-
turnId:
|
|
21453
|
+
turnId: active2.turnId,
|
|
20829
21454
|
itemId: snapshot.item.itemId,
|
|
20830
21455
|
update: { type: "text.append", text: `
|
|
20831
21456
|
${reason}` }
|
|
20832
21457
|
});
|
|
20833
|
-
this.#emit({ type: "item.completed", turnId:
|
|
21458
|
+
this.#emit({ type: "item.completed", turnId: active2.turnId, snapshot });
|
|
20834
21459
|
return true;
|
|
20835
21460
|
}
|
|
20836
|
-
#appendTextItem(
|
|
20837
|
-
const appended =
|
|
21461
|
+
#appendTextItem(active2, kind, text2) {
|
|
21462
|
+
const appended = active2.appendText(kind, text2);
|
|
20838
21463
|
if (!appended)
|
|
20839
21464
|
return;
|
|
20840
21465
|
if (appended.startedItem) {
|
|
20841
|
-
this.#emit({ type: "item.started", turnId:
|
|
21466
|
+
this.#emit({ type: "item.started", turnId: active2.turnId, item: appended.startedItem });
|
|
20842
21467
|
}
|
|
20843
21468
|
this.#emit({
|
|
20844
21469
|
type: "item.updated",
|
|
20845
|
-
turnId:
|
|
21470
|
+
turnId: active2.turnId,
|
|
20846
21471
|
itemId: appended.item.itemId,
|
|
20847
21472
|
update: { type: "text.append", text: text2 }
|
|
20848
21473
|
});
|
|
20849
21474
|
}
|
|
20850
|
-
#startToolItem(
|
|
20851
|
-
const completedText =
|
|
21475
|
+
#startToolItem(active2, toolCallId, title, name, rawInput) {
|
|
21476
|
+
const completedText = active2.completeCurrentText();
|
|
20852
21477
|
if (completedText) {
|
|
20853
|
-
this.#emit({ type: "item.completed", turnId:
|
|
21478
|
+
this.#emit({ type: "item.completed", turnId: active2.turnId, snapshot: completedText });
|
|
20854
21479
|
}
|
|
20855
21480
|
const item = {
|
|
20856
21481
|
type: "toolExecution",
|
|
@@ -20858,39 +21483,39 @@ ${reason}` }
|
|
|
20858
21483
|
toolName: (name ?? title ?? "").trim() || toolCallId,
|
|
20859
21484
|
arguments: isPlainObjectOrArray(rawInput) ? rawInput : null
|
|
20860
21485
|
};
|
|
20861
|
-
|
|
20862
|
-
this.#emit({ type: "item.started", turnId:
|
|
21486
|
+
active2.addToolItem(toolCallId, { item, startedAt: Date.now() });
|
|
21487
|
+
this.#emit({ type: "item.started", turnId: active2.turnId, item });
|
|
20863
21488
|
}
|
|
20864
|
-
#updateToolItem(
|
|
20865
|
-
const entry =
|
|
21489
|
+
#updateToolItem(active2, update) {
|
|
21490
|
+
const entry = active2.getToolItem(update.toolCallId);
|
|
20866
21491
|
if (!entry)
|
|
20867
21492
|
return;
|
|
20868
|
-
|
|
21493
|
+
active2.rememberFileChanges(update.toolCallId, update);
|
|
20869
21494
|
const output = hermesToolOutput(update);
|
|
20870
21495
|
if (output && output.content.length > 0) {
|
|
20871
|
-
|
|
21496
|
+
active2.updateToolOutput(update.toolCallId, output);
|
|
20872
21497
|
this.#emit({
|
|
20873
21498
|
type: "item.updated",
|
|
20874
|
-
turnId:
|
|
21499
|
+
turnId: active2.turnId,
|
|
20875
21500
|
itemId: entry.item.itemId,
|
|
20876
21501
|
update: { type: "output.replace", output }
|
|
20877
21502
|
});
|
|
20878
21503
|
}
|
|
20879
21504
|
if (update.status === "completed" || update.status === "failed") {
|
|
20880
|
-
const completed =
|
|
21505
|
+
const completed = active2.completeToolItem(update.toolCallId, output, update.status === "failed");
|
|
20881
21506
|
if (completed) {
|
|
20882
|
-
this.#emit({ type: "item.completed", turnId:
|
|
21507
|
+
this.#emit({ type: "item.completed", turnId: active2.turnId, snapshot: completed });
|
|
20883
21508
|
if (update.status === "completed") {
|
|
20884
|
-
const fileChange =
|
|
21509
|
+
const fileChange = active2.completeFileChanges(update.toolCallId, completed.item.itemId);
|
|
20885
21510
|
if (fileChange) {
|
|
20886
|
-
this.#emit({ type: "item.started", turnId:
|
|
20887
|
-
this.#emit({ type: "item.completed", turnId:
|
|
21511
|
+
this.#emit({ type: "item.started", turnId: active2.turnId, item: fileChange.item });
|
|
21512
|
+
this.#emit({ type: "item.completed", turnId: active2.turnId, snapshot: fileChange });
|
|
20888
21513
|
}
|
|
20889
21514
|
}
|
|
20890
21515
|
}
|
|
20891
21516
|
}
|
|
20892
21517
|
}
|
|
20893
|
-
#handlePermissionRequest(
|
|
21518
|
+
#handlePermissionRequest(active2, request) {
|
|
20894
21519
|
if (request.options.length === 0) {
|
|
20895
21520
|
return Promise.resolve(null);
|
|
20896
21521
|
}
|
|
@@ -20898,7 +21523,7 @@ ${reason}` }
|
|
|
20898
21523
|
const interaction = {
|
|
20899
21524
|
type: "approval",
|
|
20900
21525
|
interactionId,
|
|
20901
|
-
turnId:
|
|
21526
|
+
turnId: active2.turnId,
|
|
20902
21527
|
title: request.title?.slice(0, 200) || "Hermes 请求批准",
|
|
20903
21528
|
...request.description ? { description: request.description } : {},
|
|
20904
21529
|
subject: { type: "nativeAction" },
|
|
@@ -20910,7 +21535,7 @@ ${reason}` }
|
|
|
20910
21535
|
const pending = new Promise((resolve) => {
|
|
20911
21536
|
this.#approvalWaiters.set(interactionId, {
|
|
20912
21537
|
interaction,
|
|
20913
|
-
turnId:
|
|
21538
|
+
turnId: active2.turnId,
|
|
20914
21539
|
resolve
|
|
20915
21540
|
});
|
|
20916
21541
|
abort = () => {
|
|
@@ -20920,7 +21545,7 @@ ${reason}` }
|
|
|
20920
21545
|
this.#emit({
|
|
20921
21546
|
type: "interaction.closed",
|
|
20922
21547
|
interactionId,
|
|
20923
|
-
turnId:
|
|
21548
|
+
turnId: active2.turnId,
|
|
20924
21549
|
reason: request.signal?.reason === "expired" ? "expired" : "cancelled"
|
|
20925
21550
|
});
|
|
20926
21551
|
};
|
|
@@ -20983,15 +21608,15 @@ ${reason}` }
|
|
|
20983
21608
|
return { ok: false, error: failure2 };
|
|
20984
21609
|
}
|
|
20985
21610
|
}
|
|
20986
|
-
#handleQuestionRequest(
|
|
20987
|
-
if (this.#activeTurn !==
|
|
21611
|
+
#handleQuestionRequest(active2, request) {
|
|
21612
|
+
if (this.#activeTurn !== active2)
|
|
20988
21613
|
return Promise.resolve({ type: "question", answers: {}, cancelled: true });
|
|
20989
|
-
return this.#questions.open(
|
|
21614
|
+
return this.#questions.open(active2.turnId, request);
|
|
20990
21615
|
}
|
|
20991
21616
|
async #selectThinking(command) {
|
|
20992
21617
|
if (!this.#transport.setThinking)
|
|
20993
21618
|
return err("unsupported", "Hermes does not expose Thinking options");
|
|
20994
|
-
if (!this.#state.availableThinkingOptions?.some(({ id }) =>
|
|
21619
|
+
if (!this.#state.availableThinkingOptions?.some(({ id: id2 }) => id2 === command.thinkingOptionId))
|
|
20995
21620
|
return err("invalidRequest", "Unknown Hermes Thinking option");
|
|
20996
21621
|
try {
|
|
20997
21622
|
const selected = await this.#transport.setThinking(command.thinkingOptionId);
|
|
@@ -21006,10 +21631,7 @@ ${reason}` }
|
|
|
21006
21631
|
}
|
|
21007
21632
|
}
|
|
21008
21633
|
async #selectModel(command) {
|
|
21009
|
-
const native =
|
|
21010
|
-
if (!native) {
|
|
21011
|
-
return err("invalidRequest", "Model Ref does not belong to Hermes");
|
|
21012
|
-
}
|
|
21634
|
+
const native = command.model.id;
|
|
21013
21635
|
try {
|
|
21014
21636
|
await this.#transport.setModel(native);
|
|
21015
21637
|
} catch (error51) {
|
|
@@ -21119,7 +21741,7 @@ async function openGatewaySession(input, transport, onSettle, inheritedPermissio
|
|
|
21119
21741
|
throw new HermesGatewayHistoryError("unsupported", "Hermes gateway supports only native approval policy and session YOLO");
|
|
21120
21742
|
if (input.kind === "create" && input.executionPolicy === "unattended-full-access" && mode && mode !== "dont_ask")
|
|
21121
21743
|
throw new HermesGatewayHistoryError("invalidRequest", "unattended-full-access requires dont_ask");
|
|
21122
|
-
const model2 = input.kind !== "fork"
|
|
21744
|
+
const model2 = input.kind !== "fork" ? input.model?.id : void 0;
|
|
21123
21745
|
if (input.kind !== "fork" && input.model && !model2)
|
|
21124
21746
|
throw new HermesGatewayHistoryError("invalidRequest", "Model Ref does not belong to Hermes");
|
|
21125
21747
|
if (source && gatewayRecord(source.locator).cwd && !await sameDirectory(String(gatewayRecord(source?.locator).cwd), input.cwd))
|
|
@@ -21202,6 +21824,7 @@ async function openGatewaySession(input, transport, onSettle, inheritedPermissio
|
|
|
21202
21824
|
var hermesHarnessId = harnessIdSchema.parse("hermes");
|
|
21203
21825
|
var IMPORT_TIMEOUT_MS = 2e4;
|
|
21204
21826
|
var HermesAdapter = class {
|
|
21827
|
+
normalizeStoredModelRef = normalizeStoredHermesModelRef;
|
|
21205
21828
|
commandCatalog = HERMES_COMMAND_CATALOG;
|
|
21206
21829
|
liveCommandCatalog = true;
|
|
21207
21830
|
harnessId = hermesHarnessId;
|
|
@@ -21329,7 +21952,7 @@ var HermesAdapter = class {
|
|
|
21329
21952
|
if (source?.busy)
|
|
21330
21953
|
return failure("sessionBusy", "Cannot derive a Hermes Session while its source Turn is active", true);
|
|
21331
21954
|
}
|
|
21332
|
-
const owned = (
|
|
21955
|
+
const owned = (id2) => this.#openingNativeIds.has(id2) || [...this.#sessions].some((session) => session.initialState.nativeRef?.nativeSessionId === id2);
|
|
21333
21956
|
if (ref && owned(ref.nativeSessionId))
|
|
21334
21957
|
return failure("sessionBusy", "This Hermes Session already has an owner", true);
|
|
21335
21958
|
if (ref)
|