@codexhost/cli-darwin-x64 0.23.0 → 0.24.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/app/codexhost-distribution.json +1 -1
- package/app/console-server.mjs +1565 -1805
- package/app/console-web.js +5786 -1600
- package/app/desktop-controller.mjs +13104 -2842
- package/app/host-runtime.mjs +50518 -51753
- package/app/plugins/antigravity/plugin.mjs +1932 -1148
- package/app/plugins/claude-code/plugin.mjs +1676 -1218
- package/app/plugins/codebuddy/plugin.mjs +1266 -850
- package/app/plugins/codex-usage/plugin.mjs +916 -737
- package/app/plugins/copilot/plugin.mjs +838 -640
- package/app/plugins/cursor-cli/plugin.mjs +1058 -747
- package/app/plugins/deepseek-harness/plugin.mjs +1302 -1070
- package/app/plugins/devin/plugin.mjs +949 -752
- package/app/plugins/grok/plugin.mjs +1132 -964
- package/app/plugins/hermes/plugin.mjs +1084 -905
- package/app/plugins/kimi-code/plugin.mjs +977 -804
- package/app/plugins/kiro-cli/plugin.mjs +951 -758
- package/app/plugins/omp/plugin.mjs +1408 -1169
- package/app/plugins/opencode/plugin.mjs +1385 -1142
- package/app/plugins/pi/plugin.mjs +1515 -1287
- package/app/plugins/qoder/plugin.mjs +861 -676
- package/app/plugins/qoder-cn/plugin.mjs +861 -676
- package/app/plugins/qwen-code/plugin.mjs +1060 -888
- package/app/plugins/workbuddy/plugin.mjs +1272 -856
- package/app/plugins/zcode/plugin.mjs +1529 -880
- package/app/renderer-extension.js +11568 -7827
- package/app/web/assets/index-CTCFIQbU.css +1 -0
- package/app/web/assets/index-IvFk9KT-.js +203 -0
- package/app/web/codexhost-settings.js +4472 -36194
- package/app/web/index.html +2 -2
- package/app/web/plugins/deepseek-ai__dsh-api-remotes/client.js +1 -1
- package/app/web/plugins/deepseek-ai__dsh-api-session-controller/client.js +69 -69
- package/app/web/plugins/deepseek-ai__dsh-client-ui-approval/client.js +1 -1
- package/app/web/plugins/deepseek-ai__dsh-client-ui-chat/client.js +74 -74
- package/app/web/plugins/deepseek-ai__dsh-client-ui-codexhost/client.js +75 -64
- package/app/web/plugins/deepseek-ai__dsh-client-ui-conversation/client.js +19 -16
- package/app/web/plugins/deepseek-ai__dsh-client-ui-input-trigger/client.js +1 -1
- package/app/web/plugins/deepseek-ai__dsh-client-ui-layout/client.js +2 -2
- package/app/web/plugins/deepseek-ai__dsh-client-ui-model-selection/client.js +2 -2
- package/app/web/plugins/deepseek-ai__dsh-client-ui-settings-general/client.js +1 -1
- package/app/web/plugins/deepseek-ai__dsh-client-ui-sidebar/client.js +2 -2
- package/app/web/plugins/deepseek-ai__dsh-client-ui-sidebar-documentpreview/client.js +9 -9
- package/app/web/plugins/deepseek-ai__dsh-client-ui-sidebar-right/client.js +1 -1
- package/app/web/plugins/deepseek-ai__dsh-client-ui-theme/client.js +1 -1
- package/app/web/plugins/deepseek-ai__dsh-client-ui-tool/client.js +18 -18
- package/app/web/plugins/deepseek-ai__dsh-client-ui-user-questions/client.js +3 -3
- package/app/web/plugins/deepseek-ai__dsh-client-ui-workspace/client.js +7 -7
- package/app/web/sw.js +8 -1
- package/app/web-modules/server.mjs +2682 -5540
- package/bin/codexhost +0 -0
- package/libexec/codexhost-shim +0 -0
- package/libexec/codexhost-updater +0 -0
- package/package.json +1 -1
- package/app/web/assets/index-DJW4bmyx.css +0 -1
- package/app/web/assets/index-Dyh1KzAB.js +0 -201
|
@@ -835,10 +835,10 @@ function mergeDefs(...defs) {
|
|
|
835
835
|
function cloneDef(schema) {
|
|
836
836
|
return mergeDefs(schema._zod.def);
|
|
837
837
|
}
|
|
838
|
-
function getElementAtPath(obj,
|
|
839
|
-
if (!
|
|
838
|
+
function getElementAtPath(obj, path8) {
|
|
839
|
+
if (!path8)
|
|
840
840
|
return obj;
|
|
841
|
-
return
|
|
841
|
+
return path8.reduce((acc, key) => acc?.[key], obj);
|
|
842
842
|
}
|
|
843
843
|
function promiseAllObject(promisesObj) {
|
|
844
844
|
const keys = Object.keys(promisesObj);
|
|
@@ -1247,11 +1247,11 @@ function explicitlyAborted(x, startIndex = 0) {
|
|
|
1247
1247
|
}
|
|
1248
1248
|
return false;
|
|
1249
1249
|
}
|
|
1250
|
-
function prefixIssues(
|
|
1250
|
+
function prefixIssues(path8, issues) {
|
|
1251
1251
|
return issues.map((iss) => {
|
|
1252
1252
|
var _a3;
|
|
1253
1253
|
(_a3 = iss).path ?? (_a3.path = []);
|
|
1254
|
-
iss.path.unshift(
|
|
1254
|
+
iss.path.unshift(path8);
|
|
1255
1255
|
return iss;
|
|
1256
1256
|
});
|
|
1257
1257
|
}
|
|
@@ -1322,8 +1322,8 @@ function cleanEnum(obj) {
|
|
|
1322
1322
|
return Number.isNaN(Number.parseInt(k, 10));
|
|
1323
1323
|
}).map((el) => el[1]);
|
|
1324
1324
|
}
|
|
1325
|
-
function base64ToUint8Array(
|
|
1326
|
-
const binaryString = atob(
|
|
1325
|
+
function base64ToUint8Array(base644) {
|
|
1326
|
+
const binaryString = atob(base644);
|
|
1327
1327
|
const bytes = new Uint8Array(binaryString.length);
|
|
1328
1328
|
for (let i = 0; i < binaryString.length; i++) {
|
|
1329
1329
|
bytes[i] = binaryString.charCodeAt(i);
|
|
@@ -1338,9 +1338,9 @@ function uint8ArrayToBase64(bytes) {
|
|
|
1338
1338
|
return btoa(binaryString);
|
|
1339
1339
|
}
|
|
1340
1340
|
function base64urlToUint8Array(base64url3) {
|
|
1341
|
-
const
|
|
1342
|
-
const padding = "=".repeat((4 -
|
|
1343
|
-
return base64ToUint8Array(
|
|
1341
|
+
const base644 = base64url3.replace(/-/g, "+").replace(/_/g, "/");
|
|
1342
|
+
const padding = "=".repeat((4 - base644.length % 4) % 4);
|
|
1343
|
+
return base64ToUint8Array(base644 + padding);
|
|
1344
1344
|
}
|
|
1345
1345
|
function uint8ArrayToBase64url(bytes) {
|
|
1346
1346
|
return uint8ArrayToBase64(bytes).replace(/\+/g, "-").replace(/\//g, "_").replace(/=/g, "");
|
|
@@ -1398,16 +1398,16 @@ function flattenError(error51, mapper = (issue2) => issue2.message) {
|
|
|
1398
1398
|
}
|
|
1399
1399
|
function formatError(error51, mapper = (issue2) => issue2.message) {
|
|
1400
1400
|
const fieldErrors = { _errors: [] };
|
|
1401
|
-
const processError = (error52,
|
|
1401
|
+
const processError = (error52, path8 = []) => {
|
|
1402
1402
|
for (const issue2 of error52.issues) {
|
|
1403
1403
|
if (issue2.code === "invalid_union" && issue2.errors.length) {
|
|
1404
|
-
issue2.errors.map((issues) => processError({ issues }, [...
|
|
1404
|
+
issue2.errors.map((issues) => processError({ issues }, [...path8, ...issue2.path]));
|
|
1405
1405
|
} else if (issue2.code === "invalid_key") {
|
|
1406
|
-
processError({ issues: issue2.issues }, [...
|
|
1406
|
+
processError({ issues: issue2.issues }, [...path8, ...issue2.path]);
|
|
1407
1407
|
} else if (issue2.code === "invalid_element") {
|
|
1408
|
-
processError({ issues: issue2.issues }, [...
|
|
1408
|
+
processError({ issues: issue2.issues }, [...path8, ...issue2.path]);
|
|
1409
1409
|
} else {
|
|
1410
|
-
const fullpath = [...
|
|
1410
|
+
const fullpath = [...path8, ...issue2.path];
|
|
1411
1411
|
if (fullpath.length === 0) {
|
|
1412
1412
|
fieldErrors._errors.push(mapper(issue2));
|
|
1413
1413
|
} else {
|
|
@@ -1434,17 +1434,17 @@ function formatError(error51, mapper = (issue2) => issue2.message) {
|
|
|
1434
1434
|
}
|
|
1435
1435
|
function treeifyError(error51, mapper = (issue2) => issue2.message) {
|
|
1436
1436
|
const result = { errors: [] };
|
|
1437
|
-
const processError = (error52,
|
|
1437
|
+
const processError = (error52, path8 = []) => {
|
|
1438
1438
|
var _a3, _b;
|
|
1439
1439
|
for (const issue2 of error52.issues) {
|
|
1440
1440
|
if (issue2.code === "invalid_union" && issue2.errors.length) {
|
|
1441
|
-
issue2.errors.map((issues) => processError({ issues }, [...
|
|
1441
|
+
issue2.errors.map((issues) => processError({ issues }, [...path8, ...issue2.path]));
|
|
1442
1442
|
} else if (issue2.code === "invalid_key") {
|
|
1443
|
-
processError({ issues: issue2.issues }, [...
|
|
1443
|
+
processError({ issues: issue2.issues }, [...path8, ...issue2.path]);
|
|
1444
1444
|
} else if (issue2.code === "invalid_element") {
|
|
1445
|
-
processError({ issues: issue2.issues }, [...
|
|
1445
|
+
processError({ issues: issue2.issues }, [...path8, ...issue2.path]);
|
|
1446
1446
|
} else {
|
|
1447
|
-
const fullpath = [...
|
|
1447
|
+
const fullpath = [...path8, ...issue2.path];
|
|
1448
1448
|
if (fullpath.length === 0) {
|
|
1449
1449
|
result.errors.push(mapper(issue2));
|
|
1450
1450
|
continue;
|
|
@@ -1476,8 +1476,8 @@ function treeifyError(error51, mapper = (issue2) => issue2.message) {
|
|
|
1476
1476
|
}
|
|
1477
1477
|
function toDotPath(_path) {
|
|
1478
1478
|
const segs = [];
|
|
1479
|
-
const
|
|
1480
|
-
for (const seg of
|
|
1479
|
+
const path8 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
|
|
1480
|
+
for (const seg of path8) {
|
|
1481
1481
|
if (typeof seg === "number")
|
|
1482
1482
|
segs.push(`[${seg}]`);
|
|
1483
1483
|
else if (typeof seg === "symbol")
|
|
@@ -2706,8 +2706,8 @@ var $ZodBase64 = /* @__PURE__ */ $constructor("$ZodBase64", (inst, def) => {
|
|
|
2706
2706
|
function isValidBase64URL(data) {
|
|
2707
2707
|
if (!base64url.test(data))
|
|
2708
2708
|
return false;
|
|
2709
|
-
const
|
|
2710
|
-
const padded =
|
|
2709
|
+
const base644 = data.replace(/[-_]/g, (c) => c === "-" ? "+" : "/");
|
|
2710
|
+
const padded = base644.padEnd(Math.ceil(base644.length / 4) * 4, "=");
|
|
2711
2711
|
return isValidBase64(padded);
|
|
2712
2712
|
}
|
|
2713
2713
|
var $ZodBase64URL = /* @__PURE__ */ $constructor("$ZodBase64URL", (inst, def) => {
|
|
@@ -3161,42 +3161,42 @@ var $ZodObjectJIT = /* @__PURE__ */ $constructor("$ZodObjectJIT", (inst, def) =>
|
|
|
3161
3161
|
}
|
|
3162
3162
|
doc.write(`const newResult = {};`);
|
|
3163
3163
|
for (const key of normalized.keys) {
|
|
3164
|
-
const
|
|
3164
|
+
const id2 = ids[key];
|
|
3165
3165
|
const k = esc(key);
|
|
3166
3166
|
const schema = shape[key];
|
|
3167
3167
|
const isOptionalIn = schema?._zod?.optin === "optional";
|
|
3168
3168
|
const isOptionalOut = schema?._zod?.optout === "optional";
|
|
3169
|
-
doc.write(`const ${
|
|
3169
|
+
doc.write(`const ${id2} = ${parseStr(key)};`);
|
|
3170
3170
|
if (isOptionalIn && isOptionalOut) {
|
|
3171
3171
|
doc.write(`
|
|
3172
|
-
if (${
|
|
3172
|
+
if (${id2}.issues.length) {
|
|
3173
3173
|
if (${k} in input) {
|
|
3174
|
-
payload.issues = payload.issues.concat(${
|
|
3174
|
+
payload.issues = payload.issues.concat(${id2}.issues.map(iss => ({
|
|
3175
3175
|
...iss,
|
|
3176
3176
|
path: iss.path ? [${k}, ...iss.path] : [${k}]
|
|
3177
3177
|
})));
|
|
3178
3178
|
}
|
|
3179
3179
|
}
|
|
3180
3180
|
|
|
3181
|
-
if (${
|
|
3181
|
+
if (${id2}.value === undefined) {
|
|
3182
3182
|
if (${k} in input) {
|
|
3183
3183
|
newResult[${k}] = undefined;
|
|
3184
3184
|
}
|
|
3185
3185
|
} else {
|
|
3186
|
-
newResult[${k}] = ${
|
|
3186
|
+
newResult[${k}] = ${id2}.value;
|
|
3187
3187
|
}
|
|
3188
3188
|
|
|
3189
3189
|
`);
|
|
3190
3190
|
} else if (!isOptionalIn) {
|
|
3191
3191
|
doc.write(`
|
|
3192
|
-
const ${
|
|
3193
|
-
if (${
|
|
3194
|
-
payload.issues = payload.issues.concat(${
|
|
3192
|
+
const ${id2}_present = ${k} in input;
|
|
3193
|
+
if (${id2}.issues.length) {
|
|
3194
|
+
payload.issues = payload.issues.concat(${id2}.issues.map(iss => ({
|
|
3195
3195
|
...iss,
|
|
3196
3196
|
path: iss.path ? [${k}, ...iss.path] : [${k}]
|
|
3197
3197
|
})));
|
|
3198
3198
|
}
|
|
3199
|
-
if (!${
|
|
3199
|
+
if (!${id2}_present && !${id2}.issues.length) {
|
|
3200
3200
|
payload.issues.push({
|
|
3201
3201
|
code: "invalid_type",
|
|
3202
3202
|
expected: "nonoptional",
|
|
@@ -3205,30 +3205,30 @@ var $ZodObjectJIT = /* @__PURE__ */ $constructor("$ZodObjectJIT", (inst, def) =>
|
|
|
3205
3205
|
});
|
|
3206
3206
|
}
|
|
3207
3207
|
|
|
3208
|
-
if (${
|
|
3209
|
-
if (${
|
|
3208
|
+
if (${id2}_present) {
|
|
3209
|
+
if (${id2}.value === undefined) {
|
|
3210
3210
|
newResult[${k}] = undefined;
|
|
3211
3211
|
} else {
|
|
3212
|
-
newResult[${k}] = ${
|
|
3212
|
+
newResult[${k}] = ${id2}.value;
|
|
3213
3213
|
}
|
|
3214
3214
|
}
|
|
3215
3215
|
|
|
3216
3216
|
`);
|
|
3217
3217
|
} else {
|
|
3218
3218
|
doc.write(`
|
|
3219
|
-
if (${
|
|
3220
|
-
payload.issues = payload.issues.concat(${
|
|
3219
|
+
if (${id2}.issues.length) {
|
|
3220
|
+
payload.issues = payload.issues.concat(${id2}.issues.map(iss => ({
|
|
3221
3221
|
...iss,
|
|
3222
3222
|
path: iss.path ? [${k}, ...iss.path] : [${k}]
|
|
3223
3223
|
})));
|
|
3224
3224
|
}
|
|
3225
3225
|
|
|
3226
|
-
if (${
|
|
3226
|
+
if (${id2}.value === undefined) {
|
|
3227
3227
|
if (${k} in input) {
|
|
3228
3228
|
newResult[${k}] = undefined;
|
|
3229
3229
|
}
|
|
3230
3230
|
} else {
|
|
3231
|
-
newResult[${k}] = ${
|
|
3231
|
+
newResult[${k}] = ${id2}.value;
|
|
3232
3232
|
}
|
|
3233
3233
|
|
|
3234
3234
|
`);
|
|
@@ -11560,26 +11560,26 @@ function extractDefs(ctx, schema) {
|
|
|
11560
11560
|
throw new Error("Unprocessed schema. This is a bug in Zod.");
|
|
11561
11561
|
const idToSchema = /* @__PURE__ */ new Map();
|
|
11562
11562
|
for (const entry of ctx.seen.entries()) {
|
|
11563
|
-
const
|
|
11564
|
-
if (
|
|
11565
|
-
const existing = idToSchema.get(
|
|
11563
|
+
const id2 = ctx.metadataRegistry.get(entry[0])?.id;
|
|
11564
|
+
if (id2) {
|
|
11565
|
+
const existing = idToSchema.get(id2);
|
|
11566
11566
|
if (existing && existing !== entry[0]) {
|
|
11567
|
-
throw new Error(`Duplicate schema id "${
|
|
11567
|
+
throw new Error(`Duplicate schema id "${id2}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);
|
|
11568
11568
|
}
|
|
11569
|
-
idToSchema.set(
|
|
11569
|
+
idToSchema.set(id2, entry[0]);
|
|
11570
11570
|
}
|
|
11571
11571
|
}
|
|
11572
11572
|
const makeURI = (entry) => {
|
|
11573
11573
|
const defsSegment = ctx.target === "draft-2020-12" ? "$defs" : "definitions";
|
|
11574
11574
|
if (ctx.external) {
|
|
11575
11575
|
const externalId = ctx.external.registry.get(entry[0])?.id;
|
|
11576
|
-
const uriGenerator = ctx.external.uri ?? ((
|
|
11576
|
+
const uriGenerator = ctx.external.uri ?? ((id3) => id3);
|
|
11577
11577
|
if (externalId) {
|
|
11578
11578
|
return { ref: uriGenerator(externalId) };
|
|
11579
11579
|
}
|
|
11580
|
-
const
|
|
11581
|
-
entry[1].defId =
|
|
11582
|
-
return { defId:
|
|
11580
|
+
const id2 = entry[1].defId ?? entry[1].schema.id ?? `schema${ctx.counter++}`;
|
|
11581
|
+
entry[1].defId = id2;
|
|
11582
|
+
return { defId: id2, ref: `${uriGenerator("__shared")}#/${defsSegment}/${id2}` };
|
|
11583
11583
|
}
|
|
11584
11584
|
if (entry[1] === root) {
|
|
11585
11585
|
return { ref: "#" };
|
|
@@ -11627,8 +11627,8 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
11627
11627
|
continue;
|
|
11628
11628
|
}
|
|
11629
11629
|
}
|
|
11630
|
-
const
|
|
11631
|
-
if (
|
|
11630
|
+
const id2 = ctx.metadataRegistry.get(entry[0])?.id;
|
|
11631
|
+
if (id2) {
|
|
11632
11632
|
extractToDef(entry);
|
|
11633
11633
|
continue;
|
|
11634
11634
|
}
|
|
@@ -11724,10 +11724,10 @@ function finalize(ctx, schema) {
|
|
|
11724
11724
|
} else {
|
|
11725
11725
|
}
|
|
11726
11726
|
if (ctx.external?.uri) {
|
|
11727
|
-
const
|
|
11728
|
-
if (!
|
|
11727
|
+
const id2 = ctx.external.registry.get(schema)?.id;
|
|
11728
|
+
if (!id2)
|
|
11729
11729
|
throw new Error("Schema is missing an `id` property");
|
|
11730
|
-
result.$id = ctx.external.uri(
|
|
11730
|
+
result.$id = ctx.external.uri(id2);
|
|
11731
11731
|
}
|
|
11732
11732
|
Object.assign(result, root.def ?? root.schema);
|
|
11733
11733
|
const rootMetaId = ctx.metadataRegistry.get(schema)?.id;
|
|
@@ -11887,9 +11887,9 @@ var numberProcessor = (schema, ctx, _json, _params) => {
|
|
|
11887
11887
|
json2.type = "number";
|
|
11888
11888
|
const exMin = typeof exclusiveMinimum === "number" && exclusiveMinimum >= (minimum ?? Number.NEGATIVE_INFINITY);
|
|
11889
11889
|
const exMax = typeof exclusiveMaximum === "number" && exclusiveMaximum <= (maximum ?? Number.POSITIVE_INFINITY);
|
|
11890
|
-
const
|
|
11890
|
+
const legacy2 = ctx.target === "draft-04" || ctx.target === "openapi-3.0";
|
|
11891
11891
|
if (exMin) {
|
|
11892
|
-
if (
|
|
11892
|
+
if (legacy2) {
|
|
11893
11893
|
json2.minimum = exclusiveMinimum;
|
|
11894
11894
|
json2.exclusiveMinimum = true;
|
|
11895
11895
|
} else {
|
|
@@ -11899,7 +11899,7 @@ var numberProcessor = (schema, ctx, _json, _params) => {
|
|
|
11899
11899
|
json2.minimum = minimum;
|
|
11900
11900
|
}
|
|
11901
11901
|
if (exMax) {
|
|
11902
|
-
if (
|
|
11902
|
+
if (legacy2) {
|
|
11903
11903
|
json2.maximum = exclusiveMaximum;
|
|
11904
11904
|
json2.exclusiveMaximum = true;
|
|
11905
11905
|
} else {
|
|
@@ -12761,7 +12761,7 @@ var safeDecodeAsync2 = /* @__PURE__ */ _safeDecodeAsync(ZodRealError);
|
|
|
12761
12761
|
|
|
12762
12762
|
// ../../../node_modules/zod/v4/classic/schemas.js
|
|
12763
12763
|
var _installedGroups = /* @__PURE__ */ new WeakMap();
|
|
12764
|
-
function _installLazyMethods(inst, group,
|
|
12764
|
+
function _installLazyMethods(inst, group, methods2) {
|
|
12765
12765
|
const proto = Object.getPrototypeOf(inst);
|
|
12766
12766
|
let installed = _installedGroups.get(proto);
|
|
12767
12767
|
if (!installed) {
|
|
@@ -12771,8 +12771,8 @@ function _installLazyMethods(inst, group, methods) {
|
|
|
12771
12771
|
if (installed.has(group))
|
|
12772
12772
|
return;
|
|
12773
12773
|
installed.add(group);
|
|
12774
|
-
for (const key in
|
|
12775
|
-
const fn =
|
|
12774
|
+
for (const key in methods2) {
|
|
12775
|
+
const fn = methods2[key];
|
|
12776
12776
|
Object.defineProperty(proto, key, {
|
|
12777
12777
|
configurable: true,
|
|
12778
12778
|
enumerable: false,
|
|
@@ -14169,13 +14169,13 @@ function resolveRef(ref, ctx) {
|
|
|
14169
14169
|
if (!ref.startsWith("#")) {
|
|
14170
14170
|
throw new Error("External $ref is not supported, only local refs (#/...) are allowed");
|
|
14171
14171
|
}
|
|
14172
|
-
const
|
|
14173
|
-
if (
|
|
14172
|
+
const path8 = ref.slice(1).split("/").filter(Boolean);
|
|
14173
|
+
if (path8.length === 0) {
|
|
14174
14174
|
return ctx.rootSchema;
|
|
14175
14175
|
}
|
|
14176
14176
|
const defsKey = ctx.version === "draft-2020-12" ? "$defs" : "definitions";
|
|
14177
|
-
if (
|
|
14178
|
-
const key =
|
|
14177
|
+
if (path8[0] === defsKey) {
|
|
14178
|
+
const key = path8[1];
|
|
14179
14179
|
if (!key || !ctx.defs[key]) {
|
|
14180
14180
|
throw new Error(`Reference not found: ${ref}`);
|
|
14181
14181
|
}
|
|
@@ -14711,87 +14711,6 @@ function text(value) {
|
|
|
14711
14711
|
return typeof value === "string" ? value : "";
|
|
14712
14712
|
}
|
|
14713
14713
|
|
|
14714
|
-
// ../../shared-contracts/dist/ids.js
|
|
14715
|
-
var opaqueIdSchema = external_exports.string().refine((value) => value.trim().length > 0, {
|
|
14716
|
-
message: "Identifier must not be empty or whitespace"
|
|
14717
|
-
});
|
|
14718
|
-
var harnessIdSchema = opaqueIdSchema.brand();
|
|
14719
|
-
var hostThreadIdSchema = opaqueIdSchema.brand();
|
|
14720
|
-
var hostTurnIdSchema = opaqueIdSchema.brand();
|
|
14721
|
-
var hostItemIdSchema = opaqueIdSchema.brand();
|
|
14722
|
-
var hostInteractionIdSchema = opaqueIdSchema.brand();
|
|
14723
|
-
|
|
14724
|
-
// ../../shared-contracts/dist/harness-plugins.js
|
|
14725
|
-
var HARNESS_PLUGIN_MANIFEST_MAX_BYTES = 32 * 1024;
|
|
14726
|
-
var HARNESS_PLUGIN_ICON_MAX_BYTES = 128 * 1024;
|
|
14727
|
-
var HARNESS_PLUGIN_LIMIT = 128;
|
|
14728
|
-
var installedPluginIdSchema = external_exports.string().min(1).max(128).regex(/^[a-z][a-z0-9]*(?:[._-][a-z0-9]+)*$/u);
|
|
14729
|
-
var installedHarnessPluginIdSchema = installedPluginIdSchema.pipe(harnessIdSchema);
|
|
14730
|
-
var harnessPluginIdSchema = installedHarnessPluginIdSchema.refine((id) => id !== "codex", "The official Codex identity is reserved");
|
|
14731
|
-
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");
|
|
14732
|
-
var documentationUrlSchema = external_exports.url().refine((value) => /^https:\/\/[^/?#@]+(?:[/?#]|$)/iu.test(value), "Plugin documentation links must be credential-free HTTPS URLs");
|
|
14733
|
-
var localizedTextSchema = external_exports.object({ en: external_exports.string().max(4096), "zh-CN": external_exports.string().max(4096).optional() }).strict();
|
|
14734
|
-
var harnessInstallationGuideSchema = external_exports.object({
|
|
14735
|
-
commands: external_exports.array(external_exports.object({ terminal: external_exports.string().max(256), command: external_exports.string().max(4096) }).strict()).max(8),
|
|
14736
|
-
before: localizedTextSchema.optional(),
|
|
14737
|
-
after: localizedTextSchema.optional(),
|
|
14738
|
-
downloads: external_exports.array(external_exports.object({ label: external_exports.string().max(128), url: documentationUrlSchema }).strict()).max(8).optional()
|
|
14739
|
-
}).strict();
|
|
14740
|
-
var pluginPresentationShape = {
|
|
14741
|
-
id: installedHarnessPluginIdSchema,
|
|
14742
|
-
name: external_exports.string().trim().min(1).max(128),
|
|
14743
|
-
version: external_exports.string().min(1).max(128),
|
|
14744
|
-
/** Capability-only plugin; omitted for existing session-capable plugins. */
|
|
14745
|
-
kind: external_exports.literal("usage").optional(),
|
|
14746
|
-
/** Original image styling or bounded vector paths; never arbitrary CSS/SVG markup. */
|
|
14747
|
-
iconStyle: external_exports.object({
|
|
14748
|
-
vector: external_exports.object({
|
|
14749
|
-
viewBox: external_exports.string().max(128).regex(/^-?\d+(?:\.\d+)?(?: +-?\d+(?:\.\d+)?){3}$/u),
|
|
14750
|
-
color: external_exports.string().regex(/^(?:currentColor|#[a-f0-9]{6})$/iu),
|
|
14751
|
-
paths: external_exports.array(external_exports.object({
|
|
14752
|
-
d: external_exports.string().min(1).max(32768).regex(/^[MmLlHhVvCcSsQqTtAaZz\d.,+eE\s-]+$/u),
|
|
14753
|
-
fillRule: external_exports.enum(["evenodd", "nonzero"]).optional(),
|
|
14754
|
-
fill: external_exports.string().regex(/^(?:currentColor|#[a-f0-9]{6})$/iu).optional()
|
|
14755
|
-
}).strict()).min(1).max(32)
|
|
14756
|
-
}).strict().optional(),
|
|
14757
|
-
background: external_exports.string().regex(/^#[a-f0-9]{6}$/iu).optional(),
|
|
14758
|
-
borderRadius: external_exports.number().min(0).max(50).optional(),
|
|
14759
|
-
paddingRatio: external_exports.number().min(0).max(0.25).optional()
|
|
14760
|
-
}).strict().optional(),
|
|
14761
|
-
installation: harnessInstallationGuideSchema.optional(),
|
|
14762
|
-
notice: localizedTextSchema.optional(),
|
|
14763
|
-
/** The factory accepts a persisted local entrypoint through its construction context. */
|
|
14764
|
-
launchCommand: external_exports.literal(true).optional(),
|
|
14765
|
-
links: external_exports.object({
|
|
14766
|
-
website: documentationUrlSchema.optional(),
|
|
14767
|
-
documentation: documentationUrlSchema.optional(),
|
|
14768
|
-
installation: documentationUrlSchema.optional()
|
|
14769
|
-
}).strict().optional()
|
|
14770
|
-
};
|
|
14771
|
-
var harnessPluginManifestSchema = external_exports.object({
|
|
14772
|
-
manifestVersion: external_exports.literal(1),
|
|
14773
|
-
...pluginPresentationShape,
|
|
14774
|
-
adapterApiVersion: external_exports.number().int().positive(),
|
|
14775
|
-
entry: pluginRelativeResourceSchema,
|
|
14776
|
-
icon: pluginRelativeResourceSchema.optional()
|
|
14777
|
-
}).strict();
|
|
14778
|
-
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);
|
|
14779
|
-
var harnessPluginDescriptorSchema = external_exports.object({
|
|
14780
|
-
...pluginPresentationShape,
|
|
14781
|
-
icon: harnessPluginIconSchema.optional()
|
|
14782
|
-
}).strict();
|
|
14783
|
-
var harnessPluginListParamsSchema = external_exports.object({}).strict();
|
|
14784
|
-
var harnessPluginListResultSchema = external_exports.object({
|
|
14785
|
-
plugins: external_exports.array(harnessPluginDescriptorSchema.extend({ id: harnessPluginIdSchema })).max(HARNESS_PLUGIN_LIMIT)
|
|
14786
|
-
}).strict();
|
|
14787
|
-
var harnessPluginConfigurationSchema = external_exports.object({
|
|
14788
|
-
version: external_exports.literal(1),
|
|
14789
|
-
enabled: external_exports.array(installedHarnessPluginIdSchema).max(HARNESS_PLUGIN_LIMIT)
|
|
14790
|
-
}).strict().refine((value) => new Set(value.enabled).size === value.enabled.length, {
|
|
14791
|
-
message: "Enabled plugin IDs must be unique",
|
|
14792
|
-
path: ["enabled"]
|
|
14793
|
-
});
|
|
14794
|
-
|
|
14795
14714
|
// ../../shared-contracts/dist/json-value.js
|
|
14796
14715
|
function rejectExplicitUndefined(keys) {
|
|
14797
14716
|
return (value, context) => {
|
|
@@ -14851,403 +14770,73 @@ var jsonValueSchema = nonCircularSchema.pipe(recursiveJsonValueSchema);
|
|
|
14851
14770
|
var jsonArraySchema = nonCircularSchema.pipe(external_exports.array(recursiveJsonValueSchema));
|
|
14852
14771
|
var jsonObjectSchema = nonCircularSchema.pipe(external_exports.record(external_exports.string(), recursiveJsonValueSchema));
|
|
14853
14772
|
|
|
14854
|
-
// ../../shared-contracts/dist/
|
|
14855
|
-
var
|
|
14856
|
-
|
|
14857
|
-
|
|
14858
|
-
|
|
14859
|
-
|
|
14860
|
-
|
|
14861
|
-
|
|
14862
|
-
|
|
14863
|
-
|
|
14864
|
-
|
|
14865
|
-
|
|
14866
|
-
var
|
|
14867
|
-
var
|
|
14868
|
-
var
|
|
14869
|
-
|
|
14870
|
-
|
|
14871
|
-
|
|
14872
|
-
|
|
14873
|
-
|
|
14874
|
-
|
|
14875
|
-
var
|
|
14876
|
-
"
|
|
14877
|
-
|
|
14878
|
-
|
|
14879
|
-
|
|
14880
|
-
|
|
14881
|
-
|
|
14882
|
-
|
|
14883
|
-
|
|
14884
|
-
|
|
14885
|
-
|
|
14886
|
-
|
|
14887
|
-
|
|
14888
|
-
|
|
14889
|
-
|
|
14890
|
-
|
|
14891
|
-
|
|
14892
|
-
|
|
14893
|
-
|
|
14894
|
-
|
|
14773
|
+
// ../../shared-contracts/dist/errors.js
|
|
14774
|
+
var codexhostErrorSchema = external_exports.strictObject({
|
|
14775
|
+
code: external_exports.string().min(1),
|
|
14776
|
+
message: external_exports.string().min(1),
|
|
14777
|
+
retryable: external_exports.boolean(),
|
|
14778
|
+
diagnostic: external_exports.string().min(1).optional(),
|
|
14779
|
+
stage: external_exports.string().min(1).optional(),
|
|
14780
|
+
durationMs: external_exports.number().int().nonnegative().optional(),
|
|
14781
|
+
stderrTail: external_exports.string().min(1).optional()
|
|
14782
|
+
}).superRefine(rejectExplicitUndefined(["diagnostic", "stage", "durationMs", "stderrTail"]));
|
|
14783
|
+
|
|
14784
|
+
// ../../shared-contracts/dist/harness-presentation.js
|
|
14785
|
+
var localeSchema = external_exports.string().max(64).regex(/^[a-z]{2,3}(?:-[A-Za-z0-9]{2,8})*$/u);
|
|
14786
|
+
var displayText = (maximum) => external_exports.string().min(1).max(maximum).refine((text2) => text2.trim().length > 0);
|
|
14787
|
+
var harnessLocalizationsSchema = external_exports.record(localeSchema, external_exports.object({
|
|
14788
|
+
label: displayText(256).optional(),
|
|
14789
|
+
description: displayText(1024).optional()
|
|
14790
|
+
}).strict()).refine((entries) => Object.keys(entries).length <= 16, "Too many locales");
|
|
14791
|
+
var harnessLocalizedTextSchema = external_exports.record(localeSchema, displayText(4096)).refine((entries) => typeof entries.en === "string", "English fallback is required").refine((entries) => Object.keys(entries).length <= 16, "Too many locales");
|
|
14792
|
+
|
|
14793
|
+
// ../../shared-contracts/dist/ids.js
|
|
14794
|
+
var opaqueIdSchema = external_exports.string().refine((value) => value.trim().length > 0, {
|
|
14795
|
+
message: "Identifier must not be empty or whitespace"
|
|
14796
|
+
});
|
|
14797
|
+
var harnessIdSchema = opaqueIdSchema.brand();
|
|
14798
|
+
var hostThreadIdSchema = opaqueIdSchema.brand();
|
|
14799
|
+
var hostTurnIdSchema = opaqueIdSchema.brand();
|
|
14800
|
+
var hostItemIdSchema = opaqueIdSchema.brand();
|
|
14801
|
+
var hostInteractionIdSchema = opaqueIdSchema.brand();
|
|
14802
|
+
|
|
14803
|
+
// ../../shared-contracts/dist/harness-permission-modes.js
|
|
14804
|
+
var HARNESS_PERMISSION_MODE_ID_MAX_LENGTH = 128;
|
|
14805
|
+
var HARNESS_PERMISSION_MODE_LABEL_MAX_LENGTH = 256;
|
|
14806
|
+
var HARNESS_PERMISSION_MODE_DESCRIPTION_MAX_LENGTH = 1024;
|
|
14807
|
+
var HARNESS_PERMISSION_MODE_CATALOG_MAX_LENGTH = 32;
|
|
14808
|
+
var nonBlankTextSchema = external_exports.string().refine((value) => value.trim().length > 0, {
|
|
14809
|
+
message: "Value must not be empty or whitespace"
|
|
14810
|
+
});
|
|
14811
|
+
var harnessPermissionModeIdSchema = nonBlankTextSchema.max(HARNESS_PERMISSION_MODE_ID_MAX_LENGTH).regex(/^[A-Za-z0-9._~:-]+$/u, "Permission Mode ID must use transport-safe characters").brand();
|
|
14812
|
+
var harnessPermissionModeSchema = external_exports.object({
|
|
14813
|
+
id: harnessPermissionModeIdSchema,
|
|
14814
|
+
label: nonBlankTextSchema.max(HARNESS_PERMISSION_MODE_LABEL_MAX_LENGTH),
|
|
14815
|
+
description: nonBlankTextSchema.max(HARNESS_PERMISSION_MODE_DESCRIPTION_MAX_LENGTH).optional(),
|
|
14816
|
+
dangerous: external_exports.boolean().optional(),
|
|
14817
|
+
localizations: harnessLocalizationsSchema.optional()
|
|
14818
|
+
}).strict();
|
|
14819
|
+
var harnessPermissionModeCatalogSchema = external_exports.object({
|
|
14820
|
+
modes: external_exports.array(harnessPermissionModeSchema).min(1).max(HARNESS_PERMISSION_MODE_CATALOG_MAX_LENGTH),
|
|
14821
|
+
defaultModeId: harnessPermissionModeIdSchema
|
|
14822
|
+
}).strict().superRefine((catalog, context) => {
|
|
14823
|
+
const ids = /* @__PURE__ */ new Set();
|
|
14824
|
+
for (const [index, mode] of catalog.modes.entries()) {
|
|
14825
|
+
if (ids.has(mode.id)) {
|
|
14826
|
+
context.addIssue({
|
|
14827
|
+
code: "custom",
|
|
14828
|
+
message: "Permission Mode IDs must be unique",
|
|
14829
|
+
path: ["modes", index, "id"]
|
|
14830
|
+
});
|
|
14831
|
+
}
|
|
14832
|
+
ids.add(mode.id);
|
|
14895
14833
|
}
|
|
14896
|
-
|
|
14897
|
-
|
|
14898
|
-
|
|
14899
|
-
|
|
14900
|
-
|
|
14901
|
-
|
|
14902
|
-
return "image/svg+xml";
|
|
14903
|
-
case "woff2":
|
|
14904
|
-
return "font/woff2";
|
|
14905
|
-
case "json":
|
|
14906
|
-
return "application/json";
|
|
14907
|
-
case "css":
|
|
14908
|
-
return "text/css";
|
|
14909
|
-
default:
|
|
14910
|
-
return desktopExtensionScreenshotMimeType(resource);
|
|
14911
|
-
}
|
|
14912
|
-
}
|
|
14913
|
-
var hasPortableSegments = (resource) => resource.split("/").every((segment) => !/[. ]$/u.test(segment));
|
|
14914
|
-
var desktopExtensionAssetPathSchema = pluginRelativeResourceSchema.refine((resource) => hasPortableSegments(resource) && desktopExtensionAssetMimeType(resource) !== void 0, "Expected a relative Desktop extension asset path with a supported suffix");
|
|
14915
|
-
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");
|
|
14916
|
-
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) => {
|
|
14917
|
-
const { username, password } = new URL(value);
|
|
14918
|
-
return !username && !password && !/[\\\s]/u.test(value);
|
|
14919
|
-
}, "URL must not contain credentials, backslashes, or whitespace");
|
|
14920
|
-
function localizedText(text2) {
|
|
14921
|
-
return external_exports.strictObject({ en: text2, "zh-CN": text2 });
|
|
14922
|
-
}
|
|
14923
|
-
var desktopExtensionLocalizedTextSchema = localizedText(external_exports.string().trim().min(1));
|
|
14924
|
-
var categoriesSchema = external_exports.array(desktopExtensionCategorySchema).max(desktopExtensionCategorySchema.options.length).refine((categories) => new Set(categories).size === categories.length, "Duplicate categories");
|
|
14925
|
-
var slotsSchema = external_exports.array(desktopExtensionSlotSchema).max(desktopExtensionSlotSchema.options.length).refine((slots) => new Set(slots).size === slots.length, "Duplicate slots");
|
|
14926
|
-
var settingField = {
|
|
14927
|
-
key: external_exports.string().regex(/^[A-Za-z_][A-Za-z0-9_]*$/u),
|
|
14928
|
-
label: desktopExtensionLocalizedTextSchema,
|
|
14929
|
-
description: desktopExtensionLocalizedTextSchema.optional()
|
|
14930
|
-
};
|
|
14931
|
-
var numericSetting = {
|
|
14932
|
-
...settingField,
|
|
14933
|
-
step: external_exports.number().positive().optional(),
|
|
14934
|
-
default: external_exports.number().optional()
|
|
14935
|
-
};
|
|
14936
|
-
var settingOption = external_exports.strictObject({
|
|
14937
|
-
value: external_exports.string(),
|
|
14938
|
-
label: desktopExtensionLocalizedTextSchema
|
|
14939
|
-
});
|
|
14940
|
-
var desktopExtensionSettingFieldSchema = external_exports.discriminatedUnion("type", [
|
|
14941
|
-
external_exports.strictObject({
|
|
14942
|
-
...settingField,
|
|
14943
|
-
type: external_exports.literal("boolean"),
|
|
14944
|
-
default: external_exports.boolean().optional()
|
|
14945
|
-
}),
|
|
14946
|
-
external_exports.strictObject({
|
|
14947
|
-
...settingField,
|
|
14948
|
-
type: external_exports.literal("string"),
|
|
14949
|
-
placeholder: desktopExtensionLocalizedTextSchema.optional(),
|
|
14950
|
-
default: external_exports.string().optional()
|
|
14951
|
-
}),
|
|
14952
|
-
external_exports.strictObject({
|
|
14953
|
-
...numericSetting,
|
|
14954
|
-
type: external_exports.literal("number"),
|
|
14955
|
-
min: external_exports.number().optional(),
|
|
14956
|
-
max: external_exports.number().optional()
|
|
14957
|
-
}),
|
|
14958
|
-
external_exports.strictObject({
|
|
14959
|
-
...numericSetting,
|
|
14960
|
-
type: external_exports.literal("range"),
|
|
14961
|
-
min: external_exports.number(),
|
|
14962
|
-
max: external_exports.number()
|
|
14963
|
-
}),
|
|
14964
|
-
external_exports.strictObject({
|
|
14965
|
-
...settingField,
|
|
14966
|
-
type: external_exports.literal("select"),
|
|
14967
|
-
options: external_exports.array(settingOption).min(1),
|
|
14968
|
-
default: external_exports.string().optional()
|
|
14969
|
-
})
|
|
14970
|
-
]).superRefine((field3, ctx) => {
|
|
14971
|
-
const issue2 = (path7, message) => ctx.addIssue({ code: "custom", path: [path7], message });
|
|
14972
|
-
if (field3.type === "number" || field3.type === "range") {
|
|
14973
|
-
const { min = -Infinity, max = Infinity, default: value } = field3;
|
|
14974
|
-
if (min > max)
|
|
14975
|
-
issue2("max", "Must be at least min");
|
|
14976
|
-
if (value !== void 0 && (value < min || value > max))
|
|
14977
|
-
issue2("default", "Must be within min and max");
|
|
14978
|
-
} else if (field3.type === "select") {
|
|
14979
|
-
const values = new Set(field3.options.map(({ value }) => value));
|
|
14980
|
-
if (values.size !== field3.options.length)
|
|
14981
|
-
issue2("options", "Duplicate option values");
|
|
14982
|
-
if (field3.default !== void 0 && !values.has(field3.default))
|
|
14983
|
-
issue2("default", "Must match an option value");
|
|
14984
|
-
}
|
|
14985
|
-
});
|
|
14986
|
-
var manifestHeader = external_exports.object({
|
|
14987
|
-
manifestVersion: external_exports.int().positive(),
|
|
14988
|
-
id: desktopExtensionIdSchema,
|
|
14989
|
-
name: external_exports.union([extensionName, localizedText(extensionName)]),
|
|
14990
|
-
version: external_exports.string().min(1).max(128),
|
|
14991
|
-
desktopApi: external_exports.int().positive()
|
|
14992
|
-
}).passthrough();
|
|
14993
|
-
var desktopExtensionManifestSchema = manifestHeader.extend({
|
|
14994
|
-
manifestVersion: external_exports.literal(1),
|
|
14995
|
-
desktopApi: external_exports.literal(DESKTOP_EXTENSION_API_VERSION),
|
|
14996
|
-
description: external_exports.strictObject({ en: external_exports.string().max(4096), "zh-CN": external_exports.string().max(4096).optional() }).optional(),
|
|
14997
|
-
author: external_exports.string().trim().min(1).max(128).optional(),
|
|
14998
|
-
repository: desktopExtensionHttpUrlSchema.optional(),
|
|
14999
|
-
details: external_exports.strictObject({ en: external_exports.string().max(16384), "zh-CN": external_exports.string().max(16384).optional() }).optional(),
|
|
15000
|
-
icon: imagePathSchema.optional(),
|
|
15001
|
-
screenshots: external_exports.array(imagePathSchema).max(DESKTOP_EXTENSION_SCREENSHOT_LIMIT).refine((screenshots) => new Set(screenshots).size === screenshots.length, "Duplicate screenshots").optional(),
|
|
15002
|
-
desktop: external_exports.strictObject({
|
|
15003
|
-
script: pluginRelativeResourceSchema,
|
|
15004
|
-
style: pluginRelativeResourceSchema.optional()
|
|
15005
|
-
}).optional(),
|
|
15006
|
-
backend: external_exports.strictObject({ script: pluginRelativeResourceSchema.refine(hasPortableSegments) }).optional(),
|
|
15007
|
-
slots: slotsSchema.default(() => []),
|
|
15008
|
-
settingsSchema: external_exports.array(desktopExtensionSettingFieldSchema).max(32).refine((fields) => new Set(fields.map(({ key }) => key)).size === fields.length, "Duplicate setting keys").optional(),
|
|
15009
|
-
categories: categoriesSchema.optional()
|
|
15010
|
-
}).strict().refine((manifest) => manifest.desktop !== void 0 || manifest.backend !== void 0, "Expected at least one desktop or backend entry");
|
|
15011
|
-
var desktopExtensionConfigurationSchema = external_exports.strictObject({
|
|
15012
|
-
version: external_exports.literal(1),
|
|
15013
|
-
revision: external_exports.int().nonnegative(),
|
|
15014
|
-
enabled: external_exports.array(desktopExtensionIdSchema).max(DESKTOP_EXTENSION_LIMIT).refine((ids) => new Set(ids).size === ids.length, "Duplicate extension IDs"),
|
|
15015
|
-
reloadToken: external_exports.uuid().optional()
|
|
15016
|
-
});
|
|
15017
|
-
var desktopExtensionHashSchema = external_exports.string().regex(/^[a-f0-9]{64}$/u);
|
|
15018
|
-
var desktopExtensionStatusSchema = external_exports.strictObject({
|
|
15019
|
-
state: external_exports.enum([
|
|
15020
|
-
"running",
|
|
15021
|
-
"disabled",
|
|
15022
|
-
"invalid",
|
|
15023
|
-
"incompatible",
|
|
15024
|
-
"conflict",
|
|
15025
|
-
"failed",
|
|
15026
|
-
"waiting"
|
|
15027
|
-
]),
|
|
15028
|
-
hash: desktopExtensionHashSchema.optional(),
|
|
15029
|
-
error: external_exports.string().optional(),
|
|
15030
|
-
conflictWith: desktopExtensionIdSchema.optional()
|
|
15031
|
-
});
|
|
15032
|
-
var desktopExtensionsDiagnosticSchema = external_exports.strictObject({
|
|
15033
|
-
controllerPid: external_exports.int().positive(),
|
|
15034
|
-
targetId: external_exports.string().nullable(),
|
|
15035
|
-
updatedAt: external_exports.iso.datetime(),
|
|
15036
|
-
handledReloadToken: external_exports.uuid().optional(),
|
|
15037
|
-
extensions: external_exports.record(external_exports.string(), desktopExtensionStatusSchema)
|
|
15038
|
-
});
|
|
15039
|
-
var desktopExtensionTrustTierSchema = external_exports.enum(["official", "community"]);
|
|
15040
|
-
function isGitHubDesktopExtensionZipballUrl(url2) {
|
|
15041
|
-
return url2.origin === "https://api.github.com" && /^\/repos\/[\w-]+\/[\w.-]+\/zipball(?:\/[^/]+)?\/?$/u.test(url2.pathname);
|
|
15042
|
-
}
|
|
15043
|
-
var desktopExtensionZipUrlSchema = desktopExtensionHttpUrlSchema.refine((input) => {
|
|
15044
|
-
const url2 = new URL(input);
|
|
15045
|
-
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);
|
|
15046
|
-
}, "Expected a .zip download URL or a GitHub zipball URL");
|
|
15047
|
-
var desktopExtensionCatalogEntrySchema = external_exports.strictObject({
|
|
15048
|
-
id: desktopExtensionIdSchema,
|
|
15049
|
-
version: external_exports.string().trim().min(1).max(128),
|
|
15050
|
-
name: desktopExtensionLocalizedTextSchema.extend({ en: extensionName, "zh-CN": extensionName }),
|
|
15051
|
-
description: localizedText(external_exports.string().trim().min(1).max(4096)),
|
|
15052
|
-
details: localizedText(external_exports.string().trim().min(1).max(16384)).optional(),
|
|
15053
|
-
author: external_exports.string().trim().min(1).max(128),
|
|
15054
|
-
repository: desktopExtensionHttpUrlSchema,
|
|
15055
|
-
stars: external_exports.number().int().min(0).optional(),
|
|
15056
|
-
downloads: external_exports.number().int().min(0).optional(),
|
|
15057
|
-
categories: categoriesSchema.optional(),
|
|
15058
|
-
trustTier: desktopExtensionTrustTierSchema.default("community"),
|
|
15059
|
-
icon: desktopExtensionHttpUrlSchema.optional(),
|
|
15060
|
-
screenshots: external_exports.array(desktopExtensionHttpUrlSchema).max(DESKTOP_EXTENSION_SCREENSHOT_LIMIT).optional(),
|
|
15061
|
-
downloadUrl: desktopExtensionZipUrlSchema,
|
|
15062
|
-
sha256: desktopExtensionHashSchema,
|
|
15063
|
-
slots: slotsSchema.optional(),
|
|
15064
|
-
publishedAt: external_exports.string().optional(),
|
|
15065
|
-
updatedAt: external_exports.string().optional(),
|
|
15066
|
-
minCodexHostVersion: external_exports.string().optional()
|
|
15067
|
-
});
|
|
15068
|
-
var desktopExtensionCatalogSchema = external_exports.strictObject({
|
|
15069
|
-
schemaVersion: external_exports.literal(1),
|
|
15070
|
-
generatedAt: external_exports.string(),
|
|
15071
|
-
extensions: external_exports.array(desktopExtensionCatalogEntrySchema).refine((entries) => new Set(entries.map(({ id }) => id)).size === entries.length, "Duplicate extension IDs")
|
|
15072
|
-
});
|
|
15073
|
-
var DESKTOP_EXTENSIONS_ASSET_METHOD = "codexhost/desktop/extensions/asset";
|
|
15074
|
-
var DESKTOP_EXTENSIONS_SETTINGS_GET_METHOD = "codexhost/desktop/extensions/settings/get";
|
|
15075
|
-
var DESKTOP_EXTENSIONS_SETTINGS_SET_METHOD = "codexhost/desktop/extensions/settings/set";
|
|
15076
|
-
var DESKTOP_EXTENSIONS_BACKEND_INVOKE_METHOD = "codexhost/desktop/extensions/backend/invoke";
|
|
15077
|
-
var extensionIdParams = { id: desktopExtensionIdSchema };
|
|
15078
|
-
var desktopExtensionsAssetParamsSchema = external_exports.strictObject({
|
|
15079
|
-
...extensionIdParams,
|
|
15080
|
-
path: desktopExtensionAssetPathSchema
|
|
15081
|
-
});
|
|
15082
|
-
var desktopExtensionsAssetResultSchema = external_exports.strictObject({
|
|
15083
|
-
mimeType: external_exports.string(),
|
|
15084
|
-
dataUrl: external_exports.string()
|
|
15085
|
-
});
|
|
15086
|
-
var desktopExtensionsSettingsGetParamsSchema = external_exports.strictObject(extensionIdParams);
|
|
15087
|
-
var desktopExtensionsSettingsSetParamsSchema = external_exports.strictObject({
|
|
15088
|
-
...extensionIdParams,
|
|
15089
|
-
values: jsonObjectSchema
|
|
15090
|
-
});
|
|
15091
|
-
var desktopExtensionsSettingsResultSchema = external_exports.strictObject({ values: jsonObjectSchema });
|
|
15092
|
-
var desktopExtensionBackendMethodSchema = external_exports.string().trim().min(1).max(128);
|
|
15093
|
-
var desktopExtensionsBackendInvokeParamsSchema = external_exports.strictObject({
|
|
15094
|
-
...extensionIdParams,
|
|
15095
|
-
method: desktopExtensionBackendMethodSchema,
|
|
15096
|
-
params: jsonValueSchema.optional()
|
|
15097
|
-
});
|
|
15098
|
-
var desktopExtensionsBackendInvokeResultSchema = external_exports.strictObject({
|
|
15099
|
-
result: jsonValueSchema
|
|
15100
|
-
});
|
|
15101
|
-
|
|
15102
|
-
// ../../shared-contracts/dist/desktop-extension-management.js
|
|
15103
|
-
var DESKTOP_EXTENSIONS_LIST_METHOD = "codexhost/desktop/extensions/list";
|
|
15104
|
-
var DESKTOP_EXTENSIONS_ENABLE_METHOD = "codexhost/desktop/extensions/enable";
|
|
15105
|
-
var DESKTOP_EXTENSIONS_DISABLE_METHOD = "codexhost/desktop/extensions/disable";
|
|
15106
|
-
var DESKTOP_EXTENSIONS_CATALOG_METHOD = "codexhost/desktop/extensions/catalog";
|
|
15107
|
-
var DESKTOP_EXTENSIONS_INSTALL_METHOD = "codexhost/desktop/extensions/install";
|
|
15108
|
-
var DESKTOP_EXTENSIONS_UNINSTALL_METHOD = "codexhost/desktop/extensions/uninstall";
|
|
15109
|
-
var DESKTOP_EXTENSIONS_RECOVER_METHOD = "codexhost/desktop/extensions/disable-all-and-reload";
|
|
15110
|
-
var DESKTOP_EXTENSION_MANAGEMENT_METHODS = [
|
|
15111
|
-
DESKTOP_EXTENSIONS_LIST_METHOD,
|
|
15112
|
-
DESKTOP_EXTENSIONS_ENABLE_METHOD,
|
|
15113
|
-
DESKTOP_EXTENSIONS_DISABLE_METHOD,
|
|
15114
|
-
DESKTOP_EXTENSIONS_RECOVER_METHOD,
|
|
15115
|
-
DESKTOP_EXTENSIONS_CATALOG_METHOD,
|
|
15116
|
-
DESKTOP_EXTENSIONS_INSTALL_METHOD,
|
|
15117
|
-
DESKTOP_EXTENSIONS_UNINSTALL_METHOD,
|
|
15118
|
-
DESKTOP_EXTENSIONS_ASSET_METHOD,
|
|
15119
|
-
DESKTOP_EXTENSIONS_SETTINGS_GET_METHOD,
|
|
15120
|
-
DESKTOP_EXTENSIONS_SETTINGS_SET_METHOD,
|
|
15121
|
-
DESKTOP_EXTENSIONS_BACKEND_INVOKE_METHOD
|
|
15122
|
-
];
|
|
15123
|
-
var revisionSchema = external_exports.int().nonnegative();
|
|
15124
|
-
var desktopExtensionsListParamsSchema = external_exports.strictObject({});
|
|
15125
|
-
var desktopExtensionSelectionParamsSchema = external_exports.strictObject({
|
|
15126
|
-
id: desktopExtensionIdSchema,
|
|
15127
|
-
expectedRevision: revisionSchema
|
|
15128
|
-
});
|
|
15129
|
-
var desktopExtensionsRecoveryParamsSchema = external_exports.strictObject({
|
|
15130
|
-
expectedRevision: revisionSchema.optional()
|
|
15131
|
-
});
|
|
15132
|
-
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);
|
|
15133
|
-
var desktopExtensionListItemSchema = external_exports.strictObject({
|
|
15134
|
-
// An invalid discovery can have a directory name that isn't a valid extension ID.
|
|
15135
|
-
id: external_exports.string().min(1),
|
|
15136
|
-
manifest: desktopExtensionManifestSchema.optional(),
|
|
15137
|
-
iconDataUrl: rasterDataUrlSchema(DESKTOP_EXTENSION_ICON_MAX_BYTES).optional(),
|
|
15138
|
-
screenshotDataUrls: external_exports.array(rasterDataUrlSchema(DESKTOP_EXTENSION_SCREENSHOT_MAX_BYTES)).max(DESKTOP_EXTENSION_SCREENSHOT_LIMIT).optional(),
|
|
15139
|
-
enabled: external_exports.boolean(),
|
|
15140
|
-
status: desktopExtensionStatusSchema
|
|
15141
|
-
});
|
|
15142
|
-
var desktopExtensionsListResultSchema = external_exports.strictObject({
|
|
15143
|
-
configuration: desktopExtensionConfigurationSchema,
|
|
15144
|
-
desktopConnected: external_exports.boolean(),
|
|
15145
|
-
diagnostics: external_exports.array(external_exports.string()),
|
|
15146
|
-
extensions: external_exports.array(desktopExtensionListItemSchema)
|
|
15147
|
-
});
|
|
15148
|
-
var desktopExtensionsCatalogParamsSchema = external_exports.strictObject({
|
|
15149
|
-
forceRefresh: external_exports.boolean().optional()
|
|
15150
|
-
});
|
|
15151
|
-
var desktopExtensionsCatalogResultSchema = external_exports.strictObject({
|
|
15152
|
-
catalogUrl: external_exports.string(),
|
|
15153
|
-
source: external_exports.enum(["remote", "fallback"]),
|
|
15154
|
-
fetchedAt: external_exports.string(),
|
|
15155
|
-
cached: external_exports.boolean(),
|
|
15156
|
-
extensions: desktopExtensionCatalogSchema.shape.extensions,
|
|
15157
|
-
error: external_exports.string().optional()
|
|
15158
|
-
});
|
|
15159
|
-
var desktopExtensionsInstallParamsSchema = external_exports.strictObject({
|
|
15160
|
-
source: external_exports.discriminatedUnion("type", [
|
|
15161
|
-
external_exports.strictObject({ type: external_exports.literal("catalog"), id: desktopExtensionIdSchema }),
|
|
15162
|
-
external_exports.strictObject({
|
|
15163
|
-
type: external_exports.literal("url"),
|
|
15164
|
-
url: desktopExtensionHttpUrlSchema,
|
|
15165
|
-
expectedSha256: desktopExtensionHashSchema.optional()
|
|
15166
|
-
}),
|
|
15167
|
-
external_exports.strictObject({
|
|
15168
|
-
type: external_exports.literal("zip-base64"),
|
|
15169
|
-
fileName: external_exports.string().trim().min(1).max(255),
|
|
15170
|
-
contentBase64: external_exports.string().min(4).max(DESKTOP_EXTENSION_ZIP_MAX_BASE64_LENGTH).refine((value) => value.length % 4 === 0 && /^[A-Za-z0-9+/]+={0,2}$/u.test(value), "Expected standard padded base64")
|
|
15171
|
-
})
|
|
15172
|
-
])
|
|
15173
|
-
});
|
|
15174
|
-
var desktopExtensionsInstallResultSchema = external_exports.strictObject({
|
|
15175
|
-
extensionId: desktopExtensionIdSchema,
|
|
15176
|
-
version: external_exports.string().min(1),
|
|
15177
|
-
replaced: external_exports.boolean(),
|
|
15178
|
-
installedPath: external_exports.string(),
|
|
15179
|
-
list: desktopExtensionsListResultSchema
|
|
15180
|
-
});
|
|
15181
|
-
var desktopExtensionsUninstallParamsSchema = external_exports.strictObject({
|
|
15182
|
-
id: desktopExtensionIdSchema
|
|
15183
|
-
});
|
|
15184
|
-
var desktopExtensionsUninstallResultSchema = external_exports.strictObject({
|
|
15185
|
-
removedId: desktopExtensionIdSchema,
|
|
15186
|
-
list: desktopExtensionsListResultSchema
|
|
15187
|
-
});
|
|
15188
|
-
var desktopExtensionMutationResultSchema = external_exports.discriminatedUnion("state", [
|
|
15189
|
-
external_exports.strictObject({ state: external_exports.literal("saved"), configuration: desktopExtensionConfigurationSchema }),
|
|
15190
|
-
external_exports.strictObject({ state: external_exports.literal("slot-conflict"), conflictWith: desktopExtensionIdSchema }),
|
|
15191
|
-
external_exports.strictObject({ state: external_exports.literal("revision-conflict"), revision: revisionSchema })
|
|
15192
|
-
]);
|
|
15193
|
-
|
|
15194
|
-
// ../../shared-contracts/dist/errors.js
|
|
15195
|
-
var codexhostErrorSchema = external_exports.strictObject({
|
|
15196
|
-
code: external_exports.string().min(1),
|
|
15197
|
-
message: external_exports.string().min(1),
|
|
15198
|
-
retryable: external_exports.boolean(),
|
|
15199
|
-
diagnostic: external_exports.string().min(1).optional(),
|
|
15200
|
-
stage: external_exports.string().min(1).optional(),
|
|
15201
|
-
durationMs: external_exports.number().int().nonnegative().optional(),
|
|
15202
|
-
stderrTail: external_exports.string().min(1).optional()
|
|
15203
|
-
}).superRefine(rejectExplicitUndefined(["diagnostic", "stage", "durationMs", "stderrTail"]));
|
|
15204
|
-
|
|
15205
|
-
// ../../shared-contracts/dist/harness-presentation.js
|
|
15206
|
-
var localeSchema = external_exports.string().max(64).regex(/^[a-z]{2,3}(?:-[A-Za-z0-9]{2,8})*$/u);
|
|
15207
|
-
var displayText = (maximum) => external_exports.string().min(1).max(maximum).refine((text2) => text2.trim().length > 0);
|
|
15208
|
-
var harnessLocalizationsSchema = external_exports.record(localeSchema, external_exports.object({
|
|
15209
|
-
label: displayText(256).optional(),
|
|
15210
|
-
description: displayText(1024).optional()
|
|
15211
|
-
}).strict()).refine((entries) => Object.keys(entries).length <= 16, "Too many locales");
|
|
15212
|
-
var harnessLocalizedTextSchema = external_exports.record(localeSchema, displayText(4096)).refine((entries) => typeof entries.en === "string", "English fallback is required").refine((entries) => Object.keys(entries).length <= 16, "Too many locales");
|
|
15213
|
-
|
|
15214
|
-
// ../../shared-contracts/dist/harness-permission-modes.js
|
|
15215
|
-
var HARNESS_PERMISSION_MODE_ID_MAX_LENGTH = 128;
|
|
15216
|
-
var HARNESS_PERMISSION_MODE_LABEL_MAX_LENGTH = 256;
|
|
15217
|
-
var HARNESS_PERMISSION_MODE_DESCRIPTION_MAX_LENGTH = 1024;
|
|
15218
|
-
var HARNESS_PERMISSION_MODE_CATALOG_MAX_LENGTH = 32;
|
|
15219
|
-
var nonBlankTextSchema = external_exports.string().refine((value) => value.trim().length > 0, {
|
|
15220
|
-
message: "Value must not be empty or whitespace"
|
|
15221
|
-
});
|
|
15222
|
-
var harnessPermissionModeIdSchema = nonBlankTextSchema.max(HARNESS_PERMISSION_MODE_ID_MAX_LENGTH).regex(/^[A-Za-z0-9._~:-]+$/u, "Permission Mode ID must use transport-safe characters").brand();
|
|
15223
|
-
var harnessPermissionModeSchema = external_exports.object({
|
|
15224
|
-
id: harnessPermissionModeIdSchema,
|
|
15225
|
-
label: nonBlankTextSchema.max(HARNESS_PERMISSION_MODE_LABEL_MAX_LENGTH),
|
|
15226
|
-
description: nonBlankTextSchema.max(HARNESS_PERMISSION_MODE_DESCRIPTION_MAX_LENGTH).optional(),
|
|
15227
|
-
dangerous: external_exports.boolean().optional(),
|
|
15228
|
-
localizations: harnessLocalizationsSchema.optional()
|
|
15229
|
-
}).strict();
|
|
15230
|
-
var harnessPermissionModeCatalogSchema = external_exports.object({
|
|
15231
|
-
modes: external_exports.array(harnessPermissionModeSchema).min(1).max(HARNESS_PERMISSION_MODE_CATALOG_MAX_LENGTH),
|
|
15232
|
-
defaultModeId: harnessPermissionModeIdSchema
|
|
15233
|
-
}).strict().superRefine((catalog, context) => {
|
|
15234
|
-
const ids = /* @__PURE__ */ new Set();
|
|
15235
|
-
for (const [index, mode] of catalog.modes.entries()) {
|
|
15236
|
-
if (ids.has(mode.id)) {
|
|
15237
|
-
context.addIssue({
|
|
15238
|
-
code: "custom",
|
|
15239
|
-
message: "Permission Mode IDs must be unique",
|
|
15240
|
-
path: ["modes", index, "id"]
|
|
15241
|
-
});
|
|
15242
|
-
}
|
|
15243
|
-
ids.add(mode.id);
|
|
15244
|
-
}
|
|
15245
|
-
if (!ids.has(catalog.defaultModeId)) {
|
|
15246
|
-
context.addIssue({
|
|
15247
|
-
code: "custom",
|
|
15248
|
-
message: "Default Permission Mode must exist in the catalog",
|
|
15249
|
-
path: ["defaultModeId"]
|
|
15250
|
-
});
|
|
14834
|
+
if (!ids.has(catalog.defaultModeId)) {
|
|
14835
|
+
context.addIssue({
|
|
14836
|
+
code: "custom",
|
|
14837
|
+
message: "Default Permission Mode must exist in the catalog",
|
|
14838
|
+
path: ["defaultModeId"]
|
|
14839
|
+
});
|
|
15251
14840
|
}
|
|
15252
14841
|
});
|
|
15253
14842
|
var threadPermissionModeSelectParamsSchema = external_exports.object({
|
|
@@ -15255,6 +14844,9 @@ var threadPermissionModeSelectParamsSchema = external_exports.object({
|
|
|
15255
14844
|
permissionModeId: harnessPermissionModeIdSchema
|
|
15256
14845
|
}).strict();
|
|
15257
14846
|
|
|
14847
|
+
// ../../shared-contracts/dist/harness-route-limit.js
|
|
14848
|
+
var HARNESS_TRANSPORT_MODEL_ID_MAX_LENGTH = 8192;
|
|
14849
|
+
|
|
15258
14850
|
// ../../shared-contracts/dist/thread-usage.js
|
|
15259
14851
|
var nonNegativeSafeIntegerSchema = external_exports.number().int().safe().nonnegative();
|
|
15260
14852
|
var finiteNonNegativeNumberSchema = external_exports.number().finite().nonnegative();
|
|
@@ -15287,7 +14879,7 @@ var composerIndicatorsSchema = external_exports.array(external_exports.object({
|
|
|
15287
14879
|
expiresAtUnix: nonNegativeSafeIntegerSchema,
|
|
15288
14880
|
label: indicatorTextSchema(256).optional(),
|
|
15289
14881
|
tooltip: indicatorTextSchema(1024).optional()
|
|
15290
|
-
}).strict()).max(2).refine((entries) => new Set(entries.map(({ id }) =>
|
|
14882
|
+
}).strict()).max(2).refine((entries) => new Set(entries.map(({ id: id2 }) => id2)).size === entries.length, {
|
|
15291
14883
|
message: "Composer indicator IDs must be unique"
|
|
15292
14884
|
});
|
|
15293
14885
|
var threadUsageSnapshotSchema = external_exports.object({
|
|
@@ -15313,6 +14905,7 @@ var threadUsageSnapshotSchema = external_exports.object({
|
|
|
15313
14905
|
planSevenDayResetsAtUnix: nonNegativeSafeIntegerSchema.optional(),
|
|
15314
14906
|
sessionCacheHitRatePercent: cacheHitRatePercentSchema.optional(),
|
|
15315
14907
|
timeToFirstOutputMs: nonNegativeSafeIntegerSchema.optional(),
|
|
14908
|
+
latestRequestTimeToFirstOutputMs: nonNegativeSafeIntegerSchema.optional(),
|
|
15316
14909
|
costSource: external_exports.enum(["publicPrice", "native"]).optional(),
|
|
15317
14910
|
unpricedModels: external_exports.array(external_exports.string().min(1)).min(1).optional()
|
|
15318
14911
|
}).strict().superRefine((usage, context) => {
|
|
@@ -15440,10 +15033,15 @@ var THREAD_OWNERSHIP_LIST_MAX_LENGTH = 100;
|
|
|
15440
15033
|
var nonBlankTextSchema2 = external_exports.string().refine((value) => value.trim().length > 0, {
|
|
15441
15034
|
message: "Value must not be empty or whitespace"
|
|
15442
15035
|
});
|
|
15443
|
-
var harnessModelRefIdSchema =
|
|
15036
|
+
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();
|
|
15037
|
+
var harnessModelServiceTierSchema = external_exports.enum(["priority", "ultrafast"]);
|
|
15444
15038
|
var harnessModelRefSchema = external_exports.object({
|
|
15445
|
-
id: harnessModelRefIdSchema
|
|
15039
|
+
id: harnessModelRefIdSchema,
|
|
15040
|
+
serviceTier: harnessModelServiceTierSchema.optional()
|
|
15446
15041
|
}).strict();
|
|
15042
|
+
function sameHarnessModelRef(left, right) {
|
|
15043
|
+
return left?.id === right?.id && left?.serviceTier === right?.serviceTier;
|
|
15044
|
+
}
|
|
15447
15045
|
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();
|
|
15448
15046
|
var harnessResolvedModelLabelSchema = nonBlankTextSchema2.max(HARNESS_MODEL_LABEL_MAX_LENGTH);
|
|
15449
15047
|
var harnessThinkingOptionSchema = external_exports.object({
|
|
@@ -15457,7 +15055,15 @@ var harnessModelSchema = external_exports.object({
|
|
|
15457
15055
|
/** Optional opaque selection for this same Model with priority processing enabled. */
|
|
15458
15056
|
fastModel: harnessModelRefSchema.optional(),
|
|
15459
15057
|
supportedThinkingOptionIds: external_exports.array(harnessThinkingOptionIdSchema).optional()
|
|
15460
|
-
}).strict()
|
|
15058
|
+
}).strict().refine((model2) => model2.fastModel?.serviceTier === void 0 || model2.fastModel.id === model2.ref.id, {
|
|
15059
|
+
path: ["fastModel", "id"],
|
|
15060
|
+
message: "A tiered Fast Model must share the base Model ID"
|
|
15061
|
+
});
|
|
15062
|
+
function catalogModelForRef(catalog, ref) {
|
|
15063
|
+
if (!ref)
|
|
15064
|
+
return void 0;
|
|
15065
|
+
return catalog?.models.find((model2) => sameHarnessModelRef(model2.ref, ref) || sameHarnessModelRef(model2.fastModel, ref));
|
|
15066
|
+
}
|
|
15461
15067
|
var harnessThinkingOptionsSchema = external_exports.array(harnessThinkingOptionSchema).superRefine((options, context) => {
|
|
15462
15068
|
const ids = /* @__PURE__ */ new Set();
|
|
15463
15069
|
for (const [index, option] of options.entries()) {
|
|
@@ -15477,26 +15083,26 @@ var harnessModelCatalogSchema = external_exports.object({
|
|
|
15477
15083
|
thinkingOptions: harnessThinkingOptionsSchema,
|
|
15478
15084
|
defaultThinkingOptionId: harnessThinkingOptionIdSchema.optional()
|
|
15479
15085
|
}).strict().superRefine((catalog, context) => {
|
|
15480
|
-
const refs =
|
|
15481
|
-
const thinkingIds = new Set(catalog.thinkingOptions.map(({ id }) =>
|
|
15086
|
+
const refs = [];
|
|
15087
|
+
const thinkingIds = new Set(catalog.thinkingOptions.map(({ id: id2 }) => id2));
|
|
15482
15088
|
for (const [index, model2] of catalog.models.entries()) {
|
|
15483
|
-
if (refs.
|
|
15089
|
+
if (refs.some((ref) => sameHarnessModelRef(ref, model2.ref))) {
|
|
15484
15090
|
context.addIssue({
|
|
15485
15091
|
code: "custom",
|
|
15486
15092
|
message: "Model Catalog refs must be unique",
|
|
15487
15093
|
path: ["models", index, "ref", "id"]
|
|
15488
15094
|
});
|
|
15489
15095
|
}
|
|
15490
|
-
refs.
|
|
15096
|
+
refs.push(model2.ref);
|
|
15491
15097
|
if (model2.fastModel) {
|
|
15492
|
-
if (refs.
|
|
15098
|
+
if (refs.some((ref) => sameHarnessModelRef(ref, model2.fastModel))) {
|
|
15493
15099
|
context.addIssue({
|
|
15494
15100
|
code: "custom",
|
|
15495
15101
|
message: "Fast Model refs must be distinct and unique",
|
|
15496
15102
|
path: ["models", index, "fastModel"]
|
|
15497
15103
|
});
|
|
15498
15104
|
}
|
|
15499
|
-
refs.
|
|
15105
|
+
refs.push(model2.fastModel);
|
|
15500
15106
|
}
|
|
15501
15107
|
const supportedThinkingIds = /* @__PURE__ */ new Set();
|
|
15502
15108
|
for (const [optionIndex, optionId] of (model2.supportedThinkingOptionIds ?? []).entries()) {
|
|
@@ -15517,7 +15123,7 @@ var harnessModelCatalogSchema = external_exports.object({
|
|
|
15517
15123
|
}
|
|
15518
15124
|
}
|
|
15519
15125
|
}
|
|
15520
|
-
if (catalog.defaultModel && !
|
|
15126
|
+
if (catalog.defaultModel && !catalogModelForRef(catalog, catalog.defaultModel)) {
|
|
15521
15127
|
context.addIssue({
|
|
15522
15128
|
code: "custom",
|
|
15523
15129
|
message: "Default Model must exist in the Model Catalog",
|
|
@@ -15557,7 +15163,12 @@ var harnessSessionCapabilitiesSchema = external_exports.object({
|
|
|
15557
15163
|
observe: external_exports.boolean()
|
|
15558
15164
|
}).strict().optional(),
|
|
15559
15165
|
/** True only when `turn.steer` delivers input into the active Turn through a native primitive. */
|
|
15560
|
-
steer: external_exports.boolean().optional()
|
|
15166
|
+
steer: external_exports.boolean().optional(),
|
|
15167
|
+
/**
|
|
15168
|
+
* True when the native plan (task list) outlives the Turn that changed it, so a reopened
|
|
15169
|
+
* Thread gets its latest plan again. Otherwise a plan stays with the Turn that made it.
|
|
15170
|
+
*/
|
|
15171
|
+
persistentPlan: external_exports.boolean().optional()
|
|
15561
15172
|
}).strict();
|
|
15562
15173
|
var harnessConfigurationStateSchema = external_exports.object({
|
|
15563
15174
|
effectiveModel: harnessModelRefSchema.optional(),
|
|
@@ -15566,7 +15177,7 @@ var harnessConfigurationStateSchema = external_exports.object({
|
|
|
15566
15177
|
availableThinkingOptions: harnessThinkingOptionsSchema.optional(),
|
|
15567
15178
|
effectivePermissionModeId: harnessPermissionModeIdSchema.optional()
|
|
15568
15179
|
}).strict().superRefine((state, context) => {
|
|
15569
|
-
if (state.effectiveThinkingOptionId && state.availableThinkingOptions && !state.availableThinkingOptions.some(({ id }) =>
|
|
15180
|
+
if (state.effectiveThinkingOptionId && state.availableThinkingOptions && !state.availableThinkingOptions.some(({ id: id2 }) => id2 === state.effectiveThinkingOptionId)) {
|
|
15570
15181
|
context.addIssue({
|
|
15571
15182
|
code: "custom",
|
|
15572
15183
|
message: "Effective Thinking option must be currently available",
|
|
@@ -15606,7 +15217,8 @@ var harnessInspectParamsSchema = external_exports.object({
|
|
|
15606
15217
|
cwd: nonBlankTextSchema2.max(16384).optional(),
|
|
15607
15218
|
refresh: external_exports.boolean().optional(),
|
|
15608
15219
|
/** `availability` asks only whether the Harness can run; see `InspectHarnessInput.purpose`. */
|
|
15609
|
-
purpose: external_exports.literal("availability").optional()
|
|
15220
|
+
purpose: external_exports.literal("availability").optional(),
|
|
15221
|
+
credentialAccess: external_exports.enum(["allow", "retry"]).optional()
|
|
15610
15222
|
}).strict();
|
|
15611
15223
|
var harnessWebUiOpenParamsSchema = external_exports.object({
|
|
15612
15224
|
harnessId: harnessIdSchema
|
|
@@ -15637,7 +15249,7 @@ var codexThreadInspectionSchema = external_exports.object({
|
|
|
15637
15249
|
var externalThreadInspectionSchema = external_exports.object({
|
|
15638
15250
|
owner: external_exports.literal("external"),
|
|
15639
15251
|
harnessId: nonBlankTextSchema2.max(256),
|
|
15640
|
-
transportModelId: nonBlankTextSchema2.max(
|
|
15252
|
+
transportModelId: nonBlankTextSchema2.max(HARNESS_TRANSPORT_MODEL_ID_MAX_LENGTH),
|
|
15641
15253
|
effectiveModel: harnessModelRefSchema.optional(),
|
|
15642
15254
|
resolvedModelLabel: harnessResolvedModelLabelSchema.optional(),
|
|
15643
15255
|
effectiveThinkingOptionId: harnessThinkingOptionIdSchema.optional(),
|
|
@@ -15651,73 +15263,618 @@ var threadInspectionSchema = external_exports.discriminatedUnion("owner", [
|
|
|
15651
15263
|
codexThreadInspectionSchema,
|
|
15652
15264
|
externalThreadInspectionSchema
|
|
15653
15265
|
]);
|
|
15654
|
-
var threadOwnershipListParamsSchema = external_exports.object({
|
|
15655
|
-
threadIds: external_exports.array(hostThreadIdSchema).min(1).max(THREAD_OWNERSHIP_LIST_MAX_LENGTH)
|
|
15656
|
-
}).strict().superRefine(({ threadIds }, context) => {
|
|
15657
|
-
const seen = /* @__PURE__ */ new Set();
|
|
15658
|
-
for (const [index, threadId] of threadIds.entries()) {
|
|
15659
|
-
if (seen.has(threadId)) {
|
|
15660
|
-
context.addIssue({
|
|
15661
|
-
code: "custom",
|
|
15662
|
-
message: "Thread ownership-list IDs must be unique",
|
|
15663
|
-
path: ["threadIds", index]
|
|
15664
|
-
});
|
|
15665
|
-
}
|
|
15666
|
-
seen.add(threadId);
|
|
15667
|
-
}
|
|
15266
|
+
var threadOwnershipListParamsSchema = external_exports.object({
|
|
15267
|
+
threadIds: external_exports.array(hostThreadIdSchema).min(1).max(THREAD_OWNERSHIP_LIST_MAX_LENGTH)
|
|
15268
|
+
}).strict().superRefine(({ threadIds }, context) => {
|
|
15269
|
+
const seen = /* @__PURE__ */ new Set();
|
|
15270
|
+
for (const [index, threadId] of threadIds.entries()) {
|
|
15271
|
+
if (seen.has(threadId)) {
|
|
15272
|
+
context.addIssue({
|
|
15273
|
+
code: "custom",
|
|
15274
|
+
message: "Thread ownership-list IDs must be unique",
|
|
15275
|
+
path: ["threadIds", index]
|
|
15276
|
+
});
|
|
15277
|
+
}
|
|
15278
|
+
seen.add(threadId);
|
|
15279
|
+
}
|
|
15280
|
+
});
|
|
15281
|
+
var codexThreadOwnershipSchema = external_exports.object({
|
|
15282
|
+
threadId: hostThreadIdSchema,
|
|
15283
|
+
owner: external_exports.literal("codex")
|
|
15284
|
+
}).strict();
|
|
15285
|
+
var externalThreadOwnershipSchema = external_exports.object({
|
|
15286
|
+
threadId: hostThreadIdSchema,
|
|
15287
|
+
owner: external_exports.literal("external"),
|
|
15288
|
+
harnessId: external_exports.string().max(256).pipe(harnessIdSchema)
|
|
15289
|
+
}).strict();
|
|
15290
|
+
var threadOwnershipSchema = external_exports.discriminatedUnion("owner", [
|
|
15291
|
+
codexThreadOwnershipSchema,
|
|
15292
|
+
externalThreadOwnershipSchema
|
|
15293
|
+
]);
|
|
15294
|
+
var threadOwnershipListResultSchema = external_exports.object({
|
|
15295
|
+
threads: external_exports.array(threadOwnershipSchema).min(1).max(THREAD_OWNERSHIP_LIST_MAX_LENGTH)
|
|
15296
|
+
}).strict().superRefine(({ threads }, context) => {
|
|
15297
|
+
const seen = /* @__PURE__ */ new Set();
|
|
15298
|
+
for (const [index, thread2] of threads.entries()) {
|
|
15299
|
+
if (seen.has(thread2.threadId)) {
|
|
15300
|
+
context.addIssue({
|
|
15301
|
+
code: "custom",
|
|
15302
|
+
message: "Thread ownership-list results must be unique",
|
|
15303
|
+
path: ["threads", index, "threadId"]
|
|
15304
|
+
});
|
|
15305
|
+
}
|
|
15306
|
+
seen.add(thread2.threadId);
|
|
15307
|
+
}
|
|
15308
|
+
});
|
|
15309
|
+
var threadSteeringInspectParamsSchema = external_exports.object({
|
|
15310
|
+
threadId: hostThreadIdSchema,
|
|
15311
|
+
/** The text about to be steered; a Harness command always stops and restarts. */
|
|
15312
|
+
text: external_exports.string().optional()
|
|
15313
|
+
}).strict();
|
|
15314
|
+
var threadSteeringContextSchema = external_exports.object({
|
|
15315
|
+
kind: external_exports.literal("application"),
|
|
15316
|
+
value: external_exports.string().transform((text2, context) => {
|
|
15317
|
+
try {
|
|
15318
|
+
return JSON.parse(text2);
|
|
15319
|
+
} catch {
|
|
15320
|
+
context.addIssue({ code: "custom", message: "Invalid steering context JSON" });
|
|
15321
|
+
return external_exports.NEVER;
|
|
15322
|
+
}
|
|
15323
|
+
}).pipe(external_exports.object({
|
|
15324
|
+
expectedTurnId: hostTurnIdSchema,
|
|
15325
|
+
clientUserMessageId: external_exports.string().min(1),
|
|
15326
|
+
delivery: external_exports.enum(["newTurn", "activeTurn"])
|
|
15327
|
+
}).strict())
|
|
15328
|
+
}).strict().transform((context) => context.value);
|
|
15329
|
+
var threadSteerDeliverySchema = external_exports.enum(["activeTurn", "newTurn"]);
|
|
15330
|
+
var threadSteeringInspectResultSchema = external_exports.object({
|
|
15331
|
+
delivery: external_exports.enum(["official", "activeTurn", "newTurn"])
|
|
15332
|
+
}).strict();
|
|
15333
|
+
|
|
15334
|
+
// ../../shared-contracts/dist/harness-plugins.js
|
|
15335
|
+
var HARNESS_PLUGIN_MANIFEST_MAX_BYTES = 32 * 1024;
|
|
15336
|
+
var HARNESS_PLUGIN_ICON_MAX_BYTES = 128 * 1024;
|
|
15337
|
+
var HARNESS_PLUGIN_LIMIT = 128;
|
|
15338
|
+
var installedPluginIdSchema = external_exports.string().min(1).max(128).regex(/^[a-z][a-z0-9]*(?:[._-][a-z0-9]+)*$/u);
|
|
15339
|
+
var installedHarnessPluginIdSchema = installedPluginIdSchema.pipe(harnessIdSchema);
|
|
15340
|
+
var harnessPluginIdSchema = installedHarnessPluginIdSchema.refine((id2) => id2 !== "codex", "The official Codex identity is reserved");
|
|
15341
|
+
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");
|
|
15342
|
+
var documentationUrlSchema = external_exports.url().refine((value) => /^https:\/\/[^/?#@]+(?:[/?#]|$)/iu.test(value), "Plugin documentation links must be credential-free HTTPS URLs");
|
|
15343
|
+
var localizedTextSchema = external_exports.object({ en: external_exports.string().max(4096), "zh-CN": external_exports.string().max(4096).optional() }).strict();
|
|
15344
|
+
var harnessInstallationGuideSchema = external_exports.object({
|
|
15345
|
+
commands: external_exports.array(external_exports.object({ terminal: external_exports.string().max(256), command: external_exports.string().max(4096) }).strict()).max(8),
|
|
15346
|
+
before: localizedTextSchema.optional(),
|
|
15347
|
+
after: localizedTextSchema.optional(),
|
|
15348
|
+
downloads: external_exports.array(external_exports.object({ label: external_exports.string().max(128), url: documentationUrlSchema }).strict()).max(8).optional()
|
|
15349
|
+
}).strict();
|
|
15350
|
+
var pluginPresentationShape = {
|
|
15351
|
+
id: installedHarnessPluginIdSchema,
|
|
15352
|
+
name: external_exports.string().trim().min(1).max(128),
|
|
15353
|
+
version: external_exports.string().min(1).max(128),
|
|
15354
|
+
/** Capability-only plugin; omitted for existing session-capable plugins. */
|
|
15355
|
+
kind: external_exports.literal("usage").optional(),
|
|
15356
|
+
/** Original image styling or bounded vector paths; never arbitrary CSS/SVG markup. */
|
|
15357
|
+
iconStyle: external_exports.object({
|
|
15358
|
+
vector: external_exports.object({
|
|
15359
|
+
viewBox: external_exports.string().max(128).regex(/^-?\d+(?:\.\d+)?(?: +-?\d+(?:\.\d+)?){3}$/u),
|
|
15360
|
+
color: external_exports.string().regex(/^(?:currentColor|#[a-f0-9]{6})$/iu),
|
|
15361
|
+
paths: external_exports.array(external_exports.object({
|
|
15362
|
+
d: external_exports.string().min(1).max(32768).regex(/^[MmLlHhVvCcSsQqTtAaZz\d.,+eE\s-]+$/u),
|
|
15363
|
+
fillRule: external_exports.enum(["evenodd", "nonzero"]).optional(),
|
|
15364
|
+
fill: external_exports.string().regex(/^(?:currentColor|#[a-f0-9]{6})$/iu).optional()
|
|
15365
|
+
}).strict()).min(1).max(32)
|
|
15366
|
+
}).strict().optional(),
|
|
15367
|
+
background: external_exports.string().regex(/^#[a-f0-9]{6}$/iu).optional(),
|
|
15368
|
+
borderRadius: external_exports.number().min(0).max(50).optional(),
|
|
15369
|
+
paddingRatio: external_exports.number().min(0).max(0.25).optional()
|
|
15370
|
+
}).strict().optional(),
|
|
15371
|
+
installation: harnessInstallationGuideSchema.optional(),
|
|
15372
|
+
notice: localizedTextSchema.optional(),
|
|
15373
|
+
/** The factory accepts a persisted local entrypoint through its construction context. */
|
|
15374
|
+
launchCommand: external_exports.literal(true).optional(),
|
|
15375
|
+
links: external_exports.object({
|
|
15376
|
+
website: documentationUrlSchema.optional(),
|
|
15377
|
+
documentation: documentationUrlSchema.optional(),
|
|
15378
|
+
installation: documentationUrlSchema.optional()
|
|
15379
|
+
}).strict().optional()
|
|
15380
|
+
};
|
|
15381
|
+
var harnessPluginManifestSchema = external_exports.object({
|
|
15382
|
+
manifestVersion: external_exports.literal(1),
|
|
15383
|
+
...pluginPresentationShape,
|
|
15384
|
+
adapterApiVersion: external_exports.number().int().positive(),
|
|
15385
|
+
entry: pluginRelativeResourceSchema,
|
|
15386
|
+
icon: pluginRelativeResourceSchema.optional()
|
|
15387
|
+
}).strict();
|
|
15388
|
+
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);
|
|
15389
|
+
var harnessPluginDescriptorSchema = external_exports.object({
|
|
15390
|
+
...pluginPresentationShape,
|
|
15391
|
+
icon: harnessPluginIconSchema.optional()
|
|
15392
|
+
}).strict();
|
|
15393
|
+
var harnessPluginListParamsSchema = external_exports.object({}).strict();
|
|
15394
|
+
var harnessPluginListResultSchema = external_exports.object({
|
|
15395
|
+
plugins: external_exports.array(harnessPluginDescriptorSchema.extend({ id: harnessPluginIdSchema })).max(HARNESS_PLUGIN_LIMIT)
|
|
15396
|
+
}).strict();
|
|
15397
|
+
var harnessPluginConfigurationSchema = external_exports.object({
|
|
15398
|
+
version: external_exports.literal(1),
|
|
15399
|
+
enabled: external_exports.array(installedHarnessPluginIdSchema).max(HARNESS_PLUGIN_LIMIT)
|
|
15400
|
+
}).strict().refine((value) => new Set(value.enabled).size === value.enabled.length, {
|
|
15401
|
+
message: "Enabled plugin IDs must be unique",
|
|
15402
|
+
path: ["enabled"]
|
|
15403
|
+
});
|
|
15404
|
+
|
|
15405
|
+
// ../../shared-contracts/dist/desktop-extensions.js
|
|
15406
|
+
var DESKTOP_EXTENSION_API_VERSION = 1;
|
|
15407
|
+
var DESKTOP_EXTENSION_LIMIT = 64;
|
|
15408
|
+
var DESKTOP_EXTENSION_ZIP_MAX_BYTES = 64 * 1024 * 1024;
|
|
15409
|
+
var DESKTOP_EXTENSION_MANIFEST_MAX_BYTES = 128 * 1024;
|
|
15410
|
+
var DESKTOP_EXTENSION_SCRIPT_MAX_BYTES = 2 * 1024 * 1024;
|
|
15411
|
+
var DESKTOP_EXTENSION_STYLE_MAX_BYTES = 256 * 1024;
|
|
15412
|
+
var DESKTOP_EXTENSION_ICON_MAX_BYTES = 128 * 1024;
|
|
15413
|
+
var DESKTOP_EXTENSION_SCREENSHOT_LIMIT = 4;
|
|
15414
|
+
var DESKTOP_EXTENSION_SCREENSHOT_MAX_BYTES = 512 * 1024;
|
|
15415
|
+
var DESKTOP_EXTENSION_LIST_SCREENSHOTS_MAX_BYTES = 8 * 1024 * 1024;
|
|
15416
|
+
var DESKTOP_EXTENSION_SNAPSHOT_MAX_BYTES = 8 * 1024 * 1024;
|
|
15417
|
+
var DESKTOP_EXTENSION_ASSET_MAX_BYTES = 16 * 1024 * 1024;
|
|
15418
|
+
var DESKTOP_EXTENSION_SETTINGS_MAX_BYTES = 1024 * 1024;
|
|
15419
|
+
var desktopExtensionIdSchema = installedPluginIdSchema;
|
|
15420
|
+
var desktopExtensionSlotSchema = external_exports.enum([
|
|
15421
|
+
"sidebar.thread-layout",
|
|
15422
|
+
"sidebar.thread-badge",
|
|
15423
|
+
"appearance.theme"
|
|
15424
|
+
]);
|
|
15425
|
+
var desktopExtensionCategorySchema = external_exports.enum([
|
|
15426
|
+
"appearance",
|
|
15427
|
+
"interface",
|
|
15428
|
+
"workflow",
|
|
15429
|
+
"analytics",
|
|
15430
|
+
"integrations",
|
|
15431
|
+
"tools"
|
|
15432
|
+
]);
|
|
15433
|
+
var extensionName = external_exports.string().trim().min(1).max(128);
|
|
15434
|
+
function desktopExtensionScreenshotMimeType(resource) {
|
|
15435
|
+
switch (resource.match(/\.([^./]+)$/u)?.[1]?.toLowerCase()) {
|
|
15436
|
+
case "png":
|
|
15437
|
+
return "image/png";
|
|
15438
|
+
case "jpg":
|
|
15439
|
+
case "jpeg":
|
|
15440
|
+
return "image/jpeg";
|
|
15441
|
+
case "webp":
|
|
15442
|
+
return "image/webp";
|
|
15443
|
+
default:
|
|
15444
|
+
return void 0;
|
|
15445
|
+
}
|
|
15446
|
+
}
|
|
15447
|
+
var hasPortableSegments = (resource) => resource.split("/").every((segment) => !/[. ]$/u.test(segment));
|
|
15448
|
+
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");
|
|
15449
|
+
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) => {
|
|
15450
|
+
const { username, password } = new URL(value);
|
|
15451
|
+
return !username && !password && !/[\\\s]/u.test(value);
|
|
15452
|
+
}, "URL must not contain credentials, backslashes, or whitespace");
|
|
15453
|
+
function localizedText(text2) {
|
|
15454
|
+
return external_exports.strictObject({ en: text2, "zh-CN": text2 });
|
|
15455
|
+
}
|
|
15456
|
+
var desktopExtensionLocalizedTextSchema = localizedText(external_exports.string().trim().min(1));
|
|
15457
|
+
var categoriesSchema = external_exports.array(desktopExtensionCategorySchema).max(desktopExtensionCategorySchema.options.length).refine((categories) => new Set(categories).size === categories.length, "Duplicate categories");
|
|
15458
|
+
var slotsSchema = external_exports.array(desktopExtensionSlotSchema).max(desktopExtensionSlotSchema.options.length).refine((slots) => new Set(slots).size === slots.length, "Duplicate slots");
|
|
15459
|
+
var settingField = {
|
|
15460
|
+
key: external_exports.string().regex(/^[A-Za-z_][A-Za-z0-9_]*$/u),
|
|
15461
|
+
label: desktopExtensionLocalizedTextSchema,
|
|
15462
|
+
description: desktopExtensionLocalizedTextSchema.optional()
|
|
15463
|
+
};
|
|
15464
|
+
var numericSetting = {
|
|
15465
|
+
...settingField,
|
|
15466
|
+
step: external_exports.number().positive().optional(),
|
|
15467
|
+
default: external_exports.number().optional()
|
|
15468
|
+
};
|
|
15469
|
+
var settingOption = external_exports.strictObject({
|
|
15470
|
+
value: external_exports.string(),
|
|
15471
|
+
label: desktopExtensionLocalizedTextSchema
|
|
15472
|
+
});
|
|
15473
|
+
var desktopExtensionSettingFieldSchema = external_exports.discriminatedUnion("type", [
|
|
15474
|
+
external_exports.strictObject({
|
|
15475
|
+
...settingField,
|
|
15476
|
+
type: external_exports.literal("boolean"),
|
|
15477
|
+
default: external_exports.boolean().optional()
|
|
15478
|
+
}),
|
|
15479
|
+
external_exports.strictObject({
|
|
15480
|
+
...settingField,
|
|
15481
|
+
type: external_exports.literal("string"),
|
|
15482
|
+
placeholder: desktopExtensionLocalizedTextSchema.optional(),
|
|
15483
|
+
default: external_exports.string().optional()
|
|
15484
|
+
}),
|
|
15485
|
+
external_exports.strictObject({
|
|
15486
|
+
...numericSetting,
|
|
15487
|
+
type: external_exports.literal("number"),
|
|
15488
|
+
min: external_exports.number().optional(),
|
|
15489
|
+
max: external_exports.number().optional()
|
|
15490
|
+
}),
|
|
15491
|
+
external_exports.strictObject({
|
|
15492
|
+
...numericSetting,
|
|
15493
|
+
type: external_exports.literal("range"),
|
|
15494
|
+
min: external_exports.number(),
|
|
15495
|
+
max: external_exports.number()
|
|
15496
|
+
}),
|
|
15497
|
+
external_exports.strictObject({
|
|
15498
|
+
...settingField,
|
|
15499
|
+
type: external_exports.literal("select"),
|
|
15500
|
+
options: external_exports.array(settingOption).min(1),
|
|
15501
|
+
default: external_exports.string().optional()
|
|
15502
|
+
})
|
|
15503
|
+
]).superRefine((field3, ctx) => {
|
|
15504
|
+
const issue2 = (path8, message) => ctx.addIssue({ code: "custom", path: [path8], message });
|
|
15505
|
+
if (field3.type === "number" || field3.type === "range") {
|
|
15506
|
+
const { min = -Infinity, max = Infinity, default: value } = field3;
|
|
15507
|
+
if (min > max)
|
|
15508
|
+
issue2("max", "Must be at least min");
|
|
15509
|
+
if (value !== void 0 && (value < min || value > max))
|
|
15510
|
+
issue2("default", "Must be within min and max");
|
|
15511
|
+
} else if (field3.type === "select") {
|
|
15512
|
+
const values = new Set(field3.options.map(({ value }) => value));
|
|
15513
|
+
if (values.size !== field3.options.length)
|
|
15514
|
+
issue2("options", "Duplicate option values");
|
|
15515
|
+
if (field3.default !== void 0 && !values.has(field3.default))
|
|
15516
|
+
issue2("default", "Must match an option value");
|
|
15517
|
+
}
|
|
15518
|
+
});
|
|
15519
|
+
var manifestHeader = external_exports.object({
|
|
15520
|
+
manifestVersion: external_exports.int().positive(),
|
|
15521
|
+
id: desktopExtensionIdSchema,
|
|
15522
|
+
name: external_exports.union([extensionName, localizedText(extensionName)]),
|
|
15523
|
+
version: external_exports.string().min(1).max(128),
|
|
15524
|
+
desktopApi: external_exports.int().positive()
|
|
15525
|
+
}).passthrough();
|
|
15526
|
+
var desktopExtensionManifestSchema = manifestHeader.extend({
|
|
15527
|
+
manifestVersion: external_exports.literal(1),
|
|
15528
|
+
desktopApi: external_exports.literal(DESKTOP_EXTENSION_API_VERSION),
|
|
15529
|
+
description: external_exports.strictObject({ en: external_exports.string().max(4096), "zh-CN": external_exports.string().max(4096).optional() }).optional(),
|
|
15530
|
+
author: external_exports.string().trim().min(1).max(128).optional(),
|
|
15531
|
+
repository: desktopExtensionHttpUrlSchema.optional(),
|
|
15532
|
+
details: external_exports.strictObject({ en: external_exports.string().max(16384), "zh-CN": external_exports.string().max(16384).optional() }).optional(),
|
|
15533
|
+
icon: imagePathSchema.optional(),
|
|
15534
|
+
screenshots: external_exports.array(imagePathSchema).max(DESKTOP_EXTENSION_SCREENSHOT_LIMIT).refine((screenshots) => new Set(screenshots).size === screenshots.length, "Duplicate screenshots").optional(),
|
|
15535
|
+
desktop: external_exports.strictObject({
|
|
15536
|
+
script: pluginRelativeResourceSchema,
|
|
15537
|
+
style: pluginRelativeResourceSchema.optional()
|
|
15538
|
+
}).optional(),
|
|
15539
|
+
backend: external_exports.strictObject({ script: pluginRelativeResourceSchema.refine(hasPortableSegments) }).optional(),
|
|
15540
|
+
slots: slotsSchema.default(() => []),
|
|
15541
|
+
settingsSchema: external_exports.array(desktopExtensionSettingFieldSchema).max(32).refine((fields) => new Set(fields.map(({ key }) => key)).size === fields.length, "Duplicate setting keys").optional(),
|
|
15542
|
+
categories: categoriesSchema.optional()
|
|
15543
|
+
}).strict().refine((manifest) => manifest.desktop !== void 0 || manifest.backend !== void 0, "Expected at least one desktop or backend entry");
|
|
15544
|
+
var desktopExtensionHashSchema = external_exports.string().regex(/^[a-f0-9]{64}$/u);
|
|
15545
|
+
var desktopExtensionStatusSchema = external_exports.strictObject({
|
|
15546
|
+
state: external_exports.enum([
|
|
15547
|
+
"running",
|
|
15548
|
+
"disabled",
|
|
15549
|
+
"invalid",
|
|
15550
|
+
"incompatible",
|
|
15551
|
+
"conflict",
|
|
15552
|
+
"failed",
|
|
15553
|
+
"waiting"
|
|
15554
|
+
]),
|
|
15555
|
+
hash: desktopExtensionHashSchema.optional(),
|
|
15556
|
+
error: external_exports.string().optional(),
|
|
15557
|
+
conflictWith: desktopExtensionIdSchema.optional()
|
|
15558
|
+
});
|
|
15559
|
+
var desktopExtensionsDiagnosticSchema = external_exports.strictObject({
|
|
15560
|
+
controllerPid: external_exports.int().positive(),
|
|
15561
|
+
targetId: external_exports.string().nullable(),
|
|
15562
|
+
updatedAt: external_exports.iso.datetime(),
|
|
15563
|
+
handledReloadToken: external_exports.uuid().optional(),
|
|
15564
|
+
extensions: external_exports.record(external_exports.string(), desktopExtensionStatusSchema),
|
|
15565
|
+
surfaces: external_exports.record(external_exports.string(), desktopExtensionStatusSchema).optional()
|
|
15566
|
+
});
|
|
15567
|
+
var desktopExtensionTrustTierSchema = external_exports.enum(["official", "community"]);
|
|
15568
|
+
function isGitHubDesktopExtensionZipballUrl(url2) {
|
|
15569
|
+
return url2.origin === "https://api.github.com" && /^\/repos\/[\w-]+\/[\w.-]+\/zipball(?:\/[^/]+)?\/?$/u.test(url2.pathname);
|
|
15570
|
+
}
|
|
15571
|
+
var desktopExtensionZipUrlSchema = desktopExtensionHttpUrlSchema.refine((input) => {
|
|
15572
|
+
const url2 = new URL(input);
|
|
15573
|
+
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);
|
|
15574
|
+
}, "Expected a .zip download URL or a GitHub zipball URL");
|
|
15575
|
+
var desktopExtensionCatalogEntrySchema = external_exports.strictObject({
|
|
15576
|
+
id: desktopExtensionIdSchema,
|
|
15577
|
+
version: external_exports.string().trim().min(1).max(128),
|
|
15578
|
+
name: desktopExtensionLocalizedTextSchema.extend({ en: extensionName, "zh-CN": extensionName }),
|
|
15579
|
+
description: localizedText(external_exports.string().trim().min(1).max(4096)),
|
|
15580
|
+
details: localizedText(external_exports.string().trim().min(1).max(16384)).optional(),
|
|
15581
|
+
author: external_exports.string().trim().min(1).max(128),
|
|
15582
|
+
repository: desktopExtensionHttpUrlSchema,
|
|
15583
|
+
stars: external_exports.number().int().min(0).optional(),
|
|
15584
|
+
downloads: external_exports.number().int().min(0).optional(),
|
|
15585
|
+
categories: categoriesSchema.optional(),
|
|
15586
|
+
trustTier: desktopExtensionTrustTierSchema.default("community"),
|
|
15587
|
+
icon: desktopExtensionHttpUrlSchema.optional(),
|
|
15588
|
+
screenshots: external_exports.array(desktopExtensionHttpUrlSchema).max(DESKTOP_EXTENSION_SCREENSHOT_LIMIT).optional(),
|
|
15589
|
+
downloadUrl: desktopExtensionZipUrlSchema,
|
|
15590
|
+
sha256: desktopExtensionHashSchema,
|
|
15591
|
+
slots: slotsSchema.optional(),
|
|
15592
|
+
publishedAt: external_exports.string().optional(),
|
|
15593
|
+
updatedAt: external_exports.string().optional(),
|
|
15594
|
+
minCodexHostVersion: external_exports.string().optional()
|
|
15595
|
+
});
|
|
15596
|
+
var desktopExtensionCatalogSchema = external_exports.strictObject({
|
|
15597
|
+
schemaVersion: external_exports.literal(1),
|
|
15598
|
+
generatedAt: external_exports.string(),
|
|
15599
|
+
extensions: external_exports.array(desktopExtensionCatalogEntrySchema).refine((entries) => new Set(entries.map(({ id: id2 }) => id2)).size === entries.length, "Duplicate extension IDs")
|
|
15600
|
+
});
|
|
15601
|
+
var desktopExtensionBackendMethodSchema = external_exports.string().trim().min(1).max(128);
|
|
15602
|
+
|
|
15603
|
+
// ../../shared-contracts/dist/host-extensions.js
|
|
15604
|
+
var reservedName = /^(?:con|prn|aux|nul|com[1-9¹²³]|lpt[1-9¹²³]) *(?:\.|$)/iu;
|
|
15605
|
+
var HOST_EXTENSION_PAGE_API_VERSION = 1;
|
|
15606
|
+
var hostExtensionIdSchema = desktopExtensionIdSchema.refine((id2) => !reservedName.test(id2), "Reserved extension ID");
|
|
15607
|
+
var hostExtensionTargetSchema = external_exports.enum(["desktop", "web"]);
|
|
15608
|
+
var hostExtensionDigestSchema = desktopExtensionHashSchema;
|
|
15609
|
+
var hostExtensionActivationIdSchema = external_exports.uuid();
|
|
15610
|
+
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");
|
|
15611
|
+
var legacy = desktopExtensionManifestSchema.shape;
|
|
15612
|
+
var localized = (max, min = 0) => external_exports.strictObject({
|
|
15613
|
+
en: external_exports.string().trim().min(min).max(max),
|
|
15614
|
+
"zh-CN": external_exports.string().trim().min(min).max(max)
|
|
15615
|
+
});
|
|
15616
|
+
var resourceWithSuffix = (suffix) => hostExtensionResourcePathSchema.refine((path8) => path8.endsWith(suffix), `Expected a ${suffix} file`);
|
|
15617
|
+
var moduleEntry = resourceWithSuffix(".mjs");
|
|
15618
|
+
var style = resourceWithSuffix(".css").optional();
|
|
15619
|
+
var hostExtensionCanonicalPath = (path8) => path8.normalize("NFC").toLowerCase();
|
|
15620
|
+
var hostExtensionManifestV2Schema = external_exports.strictObject({
|
|
15621
|
+
manifestVersion: external_exports.literal(2),
|
|
15622
|
+
id: hostExtensionIdSchema,
|
|
15623
|
+
name: localized(128, 1),
|
|
15624
|
+
version: external_exports.string().trim().min(1).max(128),
|
|
15625
|
+
description: localized(4096),
|
|
15626
|
+
details: localized(16384).optional(),
|
|
15627
|
+
author: legacy.author,
|
|
15628
|
+
repository: legacy.repository,
|
|
15629
|
+
icon: legacy.icon.refine((path8) => path8 === void 0 || hostExtensionResourcePathSchema.safeParse(path8).success),
|
|
15630
|
+
screenshots: legacy.screenshots.refine((paths) => paths === void 0 || paths.every((path8) => hostExtensionResourcePathSchema.safeParse(path8).success)),
|
|
15631
|
+
categories: legacy.categories,
|
|
15632
|
+
settingsSchema: legacy.settingsSchema,
|
|
15633
|
+
slots: legacy.slots.removeDefault().optional(),
|
|
15634
|
+
page: external_exports.strictObject({
|
|
15635
|
+
apiVersion: external_exports.literal(HOST_EXTENSION_PAGE_API_VERSION),
|
|
15636
|
+
entry: moduleEntry,
|
|
15637
|
+
style,
|
|
15638
|
+
title: localized(128, 1).optional()
|
|
15639
|
+
}).optional(),
|
|
15640
|
+
widget: external_exports.strictObject({
|
|
15641
|
+
apiVersion: external_exports.literal(HOST_EXTENSION_PAGE_API_VERSION),
|
|
15642
|
+
entry: moduleEntry,
|
|
15643
|
+
style
|
|
15644
|
+
}).optional(),
|
|
15645
|
+
desktop: external_exports.strictObject({ apiVersion: external_exports.literal(1), script: resourceWithSuffix(".js"), style }).optional(),
|
|
15646
|
+
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(),
|
|
15647
|
+
backend: external_exports.strictObject({ apiVersion: external_exports.literal(1), entry: moduleEntry }).optional()
|
|
15648
|
+
}).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" });
|
|
15649
|
+
function targetsForCapabilities({ hasPage, hasWidget, hasDesktop, hasWeb, hasBackend }) {
|
|
15650
|
+
if (hasPage || hasWidget || hasBackend && !hasDesktop && !hasWeb)
|
|
15651
|
+
return ["desktop", "web"];
|
|
15652
|
+
const targets = [];
|
|
15653
|
+
if (hasDesktop)
|
|
15654
|
+
targets.push("desktop");
|
|
15655
|
+
if (hasWeb)
|
|
15656
|
+
targets.push("web");
|
|
15657
|
+
return targets;
|
|
15658
|
+
}
|
|
15659
|
+
var hostExtensionBackendMethodSchema = desktopExtensionBackendMethodSchema;
|
|
15660
|
+
|
|
15661
|
+
// ../../shared-contracts/dist/host-extension-management.js
|
|
15662
|
+
var HOST_EXTENSION_ZIP_MAX_BYTES = DESKTOP_EXTENSION_ZIP_MAX_BYTES;
|
|
15663
|
+
var hostExtensionRevisionSchema = external_exports.int().nonnegative();
|
|
15664
|
+
var hostExtensionConfigurationSchema = external_exports.strictObject({
|
|
15665
|
+
revision: hostExtensionRevisionSchema,
|
|
15666
|
+
enabled: external_exports.array(hostExtensionIdSchema).max(DESKTOP_EXTENSION_LIMIT).refine((ids) => new Set(ids).size === ids.length, "Duplicate extension IDs")
|
|
15667
|
+
});
|
|
15668
|
+
var { downloadUrl, ...catalogMetadata } = desktopExtensionCatalogEntrySchema.shape;
|
|
15669
|
+
var hostExtensionCatalogEntrySchema = external_exports.object({
|
|
15670
|
+
...catalogMetadata,
|
|
15671
|
+
id: hostExtensionIdSchema,
|
|
15672
|
+
format: external_exports.literal("codexhost"),
|
|
15673
|
+
targets: external_exports.array(hostExtensionTargetSchema).min(1).max(2).refine((targets) => new Set(targets).size === targets.length, "Duplicate targets"),
|
|
15674
|
+
apis: external_exports.strictObject({
|
|
15675
|
+
page: external_exports.int().positive().optional(),
|
|
15676
|
+
widget: external_exports.int().positive().optional(),
|
|
15677
|
+
desktop: external_exports.int().positive().optional(),
|
|
15678
|
+
web: external_exports.int().positive().optional(),
|
|
15679
|
+
backend: external_exports.int().positive().optional()
|
|
15680
|
+
}),
|
|
15681
|
+
downloadUrl: downloadUrl.refine((url2) => url2.startsWith("https://"), "Expected HTTPS")
|
|
15682
|
+
}).refine(({ targets, apis }) => {
|
|
15683
|
+
const derived = targetsForCapabilities({
|
|
15684
|
+
hasPage: Boolean(apis.page),
|
|
15685
|
+
hasWidget: Boolean(apis.widget),
|
|
15686
|
+
hasDesktop: Boolean(apis.desktop),
|
|
15687
|
+
hasWeb: Boolean(apis.web),
|
|
15688
|
+
hasBackend: Boolean(apis.backend)
|
|
15689
|
+
});
|
|
15690
|
+
return targets.length === derived.length && derived.every((target2) => targets.includes(target2));
|
|
15691
|
+
}, "Catalog targets must match the declared APIs");
|
|
15692
|
+
var hostExtensionCatalogSchema = external_exports.object({
|
|
15693
|
+
schemaVersion: external_exports.literal(2),
|
|
15694
|
+
generatedAt: external_exports.string().min(1),
|
|
15695
|
+
extensions: external_exports.array(hostExtensionCatalogEntrySchema).max(1e4).refine((entries) => new Set(entries.map(({ id: id2 }) => id2)).size === entries.length, "Duplicate extension IDs")
|
|
15696
|
+
});
|
|
15697
|
+
var hostExtensionsCatalogResultSchema = hostExtensionCatalogSchema.extend({
|
|
15698
|
+
catalogUrl: desktopExtensionHttpUrlSchema,
|
|
15699
|
+
fetchedAt: external_exports.iso.datetime(),
|
|
15700
|
+
cached: external_exports.boolean()
|
|
15701
|
+
});
|
|
15702
|
+
var id = { id: hostExtensionIdSchema };
|
|
15703
|
+
var active = {
|
|
15704
|
+
...id,
|
|
15705
|
+
activationId: hostExtensionActivationIdSchema,
|
|
15706
|
+
digest: hostExtensionDigestSchema
|
|
15707
|
+
};
|
|
15708
|
+
var optionalActivation = { ...id, activationId: active.activationId.optional() };
|
|
15709
|
+
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");
|
|
15710
|
+
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");
|
|
15711
|
+
function base643(maxBytes) {
|
|
15712
|
+
return external_exports.string().max(4 * Math.ceil(maxBytes / 3)).refine((value) => {
|
|
15713
|
+
const padding = value.endsWith("==") ? 2 : value.endsWith("=") ? 1 : 0;
|
|
15714
|
+
return value.length % 4 === 0 && value.length * 3 / 4 - padding <= maxBytes && /^[A-Za-z0-9+/]*={0,2}$/u.test(value);
|
|
15715
|
+
}, "Expected bounded standard padded base64");
|
|
15716
|
+
}
|
|
15717
|
+
var hostExtensionGitHubSourceSchema = external_exports.strictObject({
|
|
15718
|
+
type: external_exports.literal("github"),
|
|
15719
|
+
repository: external_exports.string().max(150).regex(/^[a-z0-9-]+\/[a-z0-9_-][a-z0-9_.-]*$/iu),
|
|
15720
|
+
ref: gitRef.optional(),
|
|
15721
|
+
tag: gitRef.optional(),
|
|
15722
|
+
asset: external_exports.string().max(255).regex(/^[a-z0-9_.-]+\.zip$/iu).optional(),
|
|
15723
|
+
subpath: hostExtensionResourcePathSchema.optional()
|
|
15724
|
+
}).refine(({ ref, tag, asset }) => !ref || !tag && !asset, "Use either a zipball ref or a release tag/asset");
|
|
15725
|
+
var hostExtensionInstallSourceSchema = external_exports.union([
|
|
15726
|
+
external_exports.strictObject({ type: external_exports.literal("catalog"), ...id }),
|
|
15727
|
+
hostExtensionGitHubSourceSchema,
|
|
15728
|
+
external_exports.strictObject({ type: external_exports.literal("zip"), base64: base643(HOST_EXTENSION_ZIP_MAX_BYTES).min(4) }),
|
|
15729
|
+
external_exports.strictObject({ type: external_exports.literal("zip"), localZipPath: filePath }),
|
|
15730
|
+
external_exports.strictObject({ type: external_exports.literal("localDir"), localDir: filePath })
|
|
15731
|
+
]);
|
|
15732
|
+
var hostExtensionProvenanceSchema = external_exports.discriminatedUnion("type", [
|
|
15733
|
+
external_exports.strictObject({ type: external_exports.literal("catalog"), ...id }),
|
|
15734
|
+
hostExtensionGitHubSourceSchema,
|
|
15735
|
+
external_exports.strictObject({ type: external_exports.literal("zip") }),
|
|
15736
|
+
external_exports.strictObject({ type: external_exports.literal("localDir") })
|
|
15737
|
+
]);
|
|
15738
|
+
var hostExtensionInstallationSchema = external_exports.strictObject({
|
|
15739
|
+
...active,
|
|
15740
|
+
manifest: hostExtensionManifestV2Schema,
|
|
15741
|
+
installedAt: external_exports.iso.datetime(),
|
|
15742
|
+
source: hostExtensionProvenanceSchema.optional()
|
|
15668
15743
|
});
|
|
15669
|
-
var
|
|
15670
|
-
|
|
15671
|
-
|
|
15672
|
-
|
|
15673
|
-
|
|
15674
|
-
|
|
15675
|
-
|
|
15676
|
-
|
|
15677
|
-
|
|
15678
|
-
|
|
15679
|
-
|
|
15680
|
-
|
|
15744
|
+
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);
|
|
15745
|
+
var desktopConflict = { desktopConflictWith: hostExtensionIdSchema.optional() };
|
|
15746
|
+
var backendState = external_exports.enum(["none", "inactive", "starting", "running", "failed"]);
|
|
15747
|
+
var hostExtensionListItemSchema = external_exports.discriminatedUnion("state", [
|
|
15748
|
+
hostExtensionInstallationSchema.extend({
|
|
15749
|
+
state: external_exports.literal("valid"),
|
|
15750
|
+
enabled: external_exports.boolean(),
|
|
15751
|
+
...desktopConflict,
|
|
15752
|
+
iconDataUrl: rasterDataUrlSchema(DESKTOP_EXTENSION_ICON_MAX_BYTES).optional(),
|
|
15753
|
+
screenshotDataUrls: external_exports.array(rasterDataUrlSchema(DESKTOP_EXTENSION_SCREENSHOT_MAX_BYTES)).max(DESKTOP_EXTENSION_SCREENSHOT_LIMIT).optional(),
|
|
15754
|
+
backendState: backendState.optional(),
|
|
15755
|
+
backendError: external_exports.string().optional()
|
|
15756
|
+
}),
|
|
15757
|
+
external_exports.strictObject({
|
|
15758
|
+
state: external_exports.enum(["invalid", "incompatible"]),
|
|
15759
|
+
id: external_exports.string().min(1),
|
|
15760
|
+
enabled: external_exports.boolean(),
|
|
15761
|
+
error: external_exports.string()
|
|
15762
|
+
})
|
|
15681
15763
|
]);
|
|
15682
|
-
var
|
|
15683
|
-
|
|
15684
|
-
|
|
15685
|
-
|
|
15686
|
-
|
|
15687
|
-
|
|
15688
|
-
|
|
15689
|
-
|
|
15690
|
-
|
|
15691
|
-
|
|
15692
|
-
|
|
15693
|
-
|
|
15694
|
-
|
|
15695
|
-
|
|
15764
|
+
var hostExtensionsListResultSchema = external_exports.strictObject({
|
|
15765
|
+
revision: hostExtensionRevisionSchema,
|
|
15766
|
+
configuration: hostExtensionConfigurationSchema,
|
|
15767
|
+
diagnostics: external_exports.array(external_exports.string()),
|
|
15768
|
+
extensions: external_exports.array(hostExtensionListItemSchema)
|
|
15769
|
+
});
|
|
15770
|
+
var hostExtensionRuntimeEntrySchema = hostExtensionInstallationSchema.extend({
|
|
15771
|
+
...desktopConflict,
|
|
15772
|
+
settingsRevision: hostExtensionRevisionSchema
|
|
15773
|
+
});
|
|
15774
|
+
var hostExtensionsSnapshotResultSchema = external_exports.strictObject({
|
|
15775
|
+
/** The Host publishes this revision in extensions-changed, independent of enabled.json's revision. */
|
|
15776
|
+
revision: hostExtensionRevisionSchema,
|
|
15777
|
+
// Enabled, valid activations only. A Desktop conflict does not hide other capabilities.
|
|
15778
|
+
extensions: external_exports.array(hostExtensionRuntimeEntrySchema).max(DESKTOP_EXTENSION_LIMIT)
|
|
15779
|
+
});
|
|
15780
|
+
var HOST_EXTENSIONS_RPC = {
|
|
15781
|
+
list: "codexhost/extensions/list",
|
|
15782
|
+
snapshot: "codexhost/extensions/snapshot",
|
|
15783
|
+
catalog: "codexhost/extensions/catalog",
|
|
15784
|
+
install: "codexhost/extensions/install",
|
|
15785
|
+
update: "codexhost/extensions/update",
|
|
15786
|
+
enable: "codexhost/extensions/enable",
|
|
15787
|
+
disable: "codexhost/extensions/disable",
|
|
15788
|
+
uninstall: "codexhost/extensions/uninstall",
|
|
15789
|
+
recover: "codexhost/extensions/recover",
|
|
15790
|
+
asset: "codexhost/extensions/asset",
|
|
15791
|
+
settingsGet: "codexhost/extensions/settings/get",
|
|
15792
|
+
settingsSet: "codexhost/extensions/settings/set",
|
|
15793
|
+
backendInvoke: "codexhost/extensions/backend/invoke"
|
|
15794
|
+
};
|
|
15795
|
+
var HOST_EXTENSION_MANAGEMENT_METHODS = Object.freeze(Object.values(HOST_EXTENSIONS_RPC));
|
|
15796
|
+
var methods = new Set(HOST_EXTENSION_MANAGEMENT_METHODS);
|
|
15797
|
+
var noParams = external_exports.strictObject({});
|
|
15798
|
+
var expectedRevision = { expectedRevision: hostExtensionRevisionSchema };
|
|
15799
|
+
var selection = external_exports.strictObject({ ...id, ...expectedRevision });
|
|
15800
|
+
var installationResult = hostExtensionInstallationSchema.extend({ replaced: external_exports.boolean() });
|
|
15801
|
+
var mutationResult = external_exports.discriminatedUnion("state", [
|
|
15802
|
+
external_exports.strictObject({ state: external_exports.literal("saved"), configuration: hostExtensionConfigurationSchema }),
|
|
15803
|
+
external_exports.strictObject({ state: external_exports.literal("revision-conflict"), revision: hostExtensionRevisionSchema })
|
|
15804
|
+
]);
|
|
15805
|
+
var hostExtensionsAssetParamsSchema = external_exports.strictObject({
|
|
15806
|
+
...optionalActivation,
|
|
15807
|
+
digest: active.digest.optional(),
|
|
15808
|
+
path: hostExtensionResourcePathSchema
|
|
15809
|
+
});
|
|
15810
|
+
var hostExtensionsAssetResultSchema = external_exports.strictObject({
|
|
15811
|
+
mimeType: external_exports.string().min(1),
|
|
15812
|
+
base64: base643(DESKTOP_EXTENSION_ASSET_MAX_BYTES),
|
|
15813
|
+
digest: active.digest
|
|
15814
|
+
});
|
|
15815
|
+
var hostExtensionSettingsSchema = external_exports.strictObject({
|
|
15816
|
+
settingsRevision: hostExtensionRevisionSchema,
|
|
15817
|
+
values: jsonObjectSchema
|
|
15696
15818
|
});
|
|
15697
|
-
var
|
|
15698
|
-
|
|
15699
|
-
|
|
15700
|
-
|
|
15701
|
-
|
|
15702
|
-
|
|
15703
|
-
|
|
15704
|
-
|
|
15705
|
-
|
|
15706
|
-
|
|
15707
|
-
|
|
15708
|
-
|
|
15709
|
-
|
|
15710
|
-
|
|
15711
|
-
|
|
15712
|
-
|
|
15713
|
-
|
|
15714
|
-
|
|
15715
|
-
|
|
15716
|
-
}
|
|
15717
|
-
|
|
15718
|
-
|
|
15719
|
-
|
|
15720
|
-
|
|
15819
|
+
var hostExtensionsRpcSchemas = {
|
|
15820
|
+
[HOST_EXTENSIONS_RPC.list]: { params: noParams, result: hostExtensionsListResultSchema },
|
|
15821
|
+
[HOST_EXTENSIONS_RPC.snapshot]: { params: noParams, result: hostExtensionsSnapshotResultSchema },
|
|
15822
|
+
[HOST_EXTENSIONS_RPC.catalog]: {
|
|
15823
|
+
params: external_exports.strictObject({ forceRefresh: external_exports.boolean().optional() }),
|
|
15824
|
+
result: hostExtensionsCatalogResultSchema
|
|
15825
|
+
},
|
|
15826
|
+
[HOST_EXTENSIONS_RPC.install]: {
|
|
15827
|
+
params: external_exports.strictObject({ source: hostExtensionInstallSourceSchema }),
|
|
15828
|
+
result: installationResult
|
|
15829
|
+
},
|
|
15830
|
+
[HOST_EXTENSIONS_RPC.update]: {
|
|
15831
|
+
params: external_exports.strictObject({
|
|
15832
|
+
...id,
|
|
15833
|
+
expectedDigest: active.digest,
|
|
15834
|
+
expectedActivationId: active.activationId.optional(),
|
|
15835
|
+
source: hostExtensionInstallSourceSchema.optional()
|
|
15836
|
+
}),
|
|
15837
|
+
result: installationResult
|
|
15838
|
+
},
|
|
15839
|
+
[HOST_EXTENSIONS_RPC.enable]: { params: selection, result: mutationResult },
|
|
15840
|
+
[HOST_EXTENSIONS_RPC.disable]: { params: selection, result: mutationResult },
|
|
15841
|
+
[HOST_EXTENSIONS_RPC.uninstall]: {
|
|
15842
|
+
params: external_exports.strictObject({
|
|
15843
|
+
...id,
|
|
15844
|
+
removeData: external_exports.boolean().optional(),
|
|
15845
|
+
expectedDigest: active.digest.optional()
|
|
15846
|
+
}),
|
|
15847
|
+
result: external_exports.strictObject({ ...id, removed: external_exports.boolean() })
|
|
15848
|
+
},
|
|
15849
|
+
[HOST_EXTENSIONS_RPC.recover]: {
|
|
15850
|
+
params: external_exports.strictObject({ expectedRevision: expectedRevision.expectedRevision.optional() }),
|
|
15851
|
+
result: mutationResult
|
|
15852
|
+
},
|
|
15853
|
+
[HOST_EXTENSIONS_RPC.asset]: {
|
|
15854
|
+
params: hostExtensionsAssetParamsSchema,
|
|
15855
|
+
result: hostExtensionsAssetResultSchema
|
|
15856
|
+
},
|
|
15857
|
+
[HOST_EXTENSIONS_RPC.settingsGet]: {
|
|
15858
|
+
params: external_exports.strictObject(optionalActivation),
|
|
15859
|
+
result: hostExtensionSettingsSchema
|
|
15860
|
+
},
|
|
15861
|
+
[HOST_EXTENSIONS_RPC.settingsSet]: {
|
|
15862
|
+
params: external_exports.strictObject({
|
|
15863
|
+
...optionalActivation,
|
|
15864
|
+
expectedSettingsRevision: hostExtensionRevisionSchema,
|
|
15865
|
+
values: jsonObjectSchema
|
|
15866
|
+
}),
|
|
15867
|
+
result: hostExtensionSettingsSchema
|
|
15868
|
+
},
|
|
15869
|
+
[HOST_EXTENSIONS_RPC.backendInvoke]: {
|
|
15870
|
+
params: external_exports.strictObject({
|
|
15871
|
+
...optionalActivation,
|
|
15872
|
+
method: hostExtensionBackendMethodSchema,
|
|
15873
|
+
params: jsonValueSchema.optional()
|
|
15874
|
+
}),
|
|
15875
|
+
result: external_exports.strictObject({ result: jsonValueSchema })
|
|
15876
|
+
}
|
|
15877
|
+
};
|
|
15721
15878
|
|
|
15722
15879
|
// ../../shared-contracts/dist/thread-archive-confirm.js
|
|
15723
15880
|
var THREAD_ARCHIVE_CONFIRM_METHOD = "codexhost/thread/archive/confirm";
|
|
@@ -15780,7 +15937,7 @@ var CLIENT_CHANNEL_METHODS = [
|
|
|
15780
15937
|
"codexhost/harness/session-import/list",
|
|
15781
15938
|
"codexhost/harness/session-import/import",
|
|
15782
15939
|
// Host settings shared across Desktop and Web.
|
|
15783
|
-
...
|
|
15940
|
+
...HOST_EXTENSION_MANAGEMENT_METHODS,
|
|
15784
15941
|
"codexhost/harness/installation",
|
|
15785
15942
|
"codexhost/harness/installation/start",
|
|
15786
15943
|
"codexhost/harness/installation/status",
|
|
@@ -15841,6 +15998,11 @@ var clientChannelEventSchema = external_exports.discriminatedUnion("type", [
|
|
|
15841
15998
|
cursor: clientChannelCursorSchema,
|
|
15842
15999
|
revision: external_exports.number().int().nonnegative()
|
|
15843
16000
|
}),
|
|
16001
|
+
external_exports.object({
|
|
16002
|
+
type: external_exports.literal("extensions-changed"),
|
|
16003
|
+
cursor: clientChannelCursorSchema,
|
|
16004
|
+
revision: hostExtensionRevisionSchema
|
|
16005
|
+
}),
|
|
15844
16006
|
external_exports.object({
|
|
15845
16007
|
type: external_exports.literal("hello"),
|
|
15846
16008
|
version: external_exports.literal(1),
|
|
@@ -16277,7 +16439,7 @@ var DEFAULT_IDLE_RELEASE_SETTINGS = Object.freeze({
|
|
|
16277
16439
|
|
|
16278
16440
|
// ../../shared-contracts/dist/harness-preferences.js
|
|
16279
16441
|
var harnessPreferenceScopeSchema = external_exports.string().regex(/^external$/u);
|
|
16280
|
-
var preferenceHarnessKey = harnessIdSchema.transform((
|
|
16442
|
+
var preferenceHarnessKey = harnessIdSchema.transform((id2) => String(id2));
|
|
16281
16443
|
var harnessDefaultConfigurationSchema = external_exports.strictObject({
|
|
16282
16444
|
model: harnessModelRefSchema.optional(),
|
|
16283
16445
|
thinkingOptionId: harnessThinkingOptionIdSchema.optional(),
|
|
@@ -16287,11 +16449,19 @@ var newThreadDefaultsSchema = external_exports.strictObject({
|
|
|
16287
16449
|
lastHarness: harnessIdSchema.optional(),
|
|
16288
16450
|
byHarness: external_exports.record(preferenceHarnessKey, harnessDefaultConfigurationSchema)
|
|
16289
16451
|
});
|
|
16452
|
+
var harnessDelegationDefaultSchema = external_exports.strictObject({
|
|
16453
|
+
model: harnessModelRefSchema.optional(),
|
|
16454
|
+
thinkingOptionId: harnessThinkingOptionIdSchema.optional()
|
|
16455
|
+
}).refine((value) => Boolean(value.model || value.thinkingOptionId), "A delegation default must contain a Model or Thinking option");
|
|
16456
|
+
var delegationDefaultsSchema = external_exports.strictObject({
|
|
16457
|
+
byHarness: external_exports.record(preferenceHarnessKey, harnessDelegationDefaultSchema)
|
|
16458
|
+
});
|
|
16290
16459
|
var modelId = external_exports.string().min(1).max(1024);
|
|
16291
16460
|
var harnessPreferenceValuesSchema = external_exports.strictObject({
|
|
16292
16461
|
idleRelease: idleReleaseSettingsSchema.optional(),
|
|
16293
16462
|
favorites: external_exports.record(preferenceHarnessKey, external_exports.array(modelId).max(2048)).default({}),
|
|
16294
|
-
newThread: newThreadDefaultsSchema.optional()
|
|
16463
|
+
newThread: newThreadDefaultsSchema.optional(),
|
|
16464
|
+
delegation: delegationDefaultsSchema.optional()
|
|
16295
16465
|
});
|
|
16296
16466
|
var harnessPreferenceSnapshotSchema = external_exports.strictObject({
|
|
16297
16467
|
scope: harnessPreferenceScopeSchema,
|
|
@@ -16319,6 +16489,11 @@ var harnessPreferenceOperationSchema = external_exports.discriminatedUnion("kind
|
|
|
16319
16489
|
lastHarness: harnessIdSchema.optional(),
|
|
16320
16490
|
harnessId: harnessIdSchema.optional(),
|
|
16321
16491
|
configuration: harnessDefaultConfigurationSchema.optional()
|
|
16492
|
+
}),
|
|
16493
|
+
external_exports.strictObject({
|
|
16494
|
+
kind: external_exports.literal("delegation"),
|
|
16495
|
+
harnessId: harnessIdSchema,
|
|
16496
|
+
configuration: harnessDelegationDefaultSchema.nullable()
|
|
16322
16497
|
})
|
|
16323
16498
|
]);
|
|
16324
16499
|
var harnessPreferencePatchSchema = external_exports.strictObject({
|
|
@@ -17142,9 +17317,12 @@ var remoteSessionOperationSchema = external_exports.discriminatedUnion("kind", [
|
|
|
17142
17317
|
...thread,
|
|
17143
17318
|
epoch: identity,
|
|
17144
17319
|
modelId: identity.optional(),
|
|
17320
|
+
serviceTier: harnessModelServiceTierSchema.optional(),
|
|
17145
17321
|
thinkingOptionId: identity.optional(),
|
|
17146
17322
|
permissionModeId: identity.optional()
|
|
17147
|
-
}).refine((value) => [value.modelId, value.thinkingOptionId, value.permissionModeId].filter((v) => v !== void 0).length === 1, "Select exactly one remote setting"),
|
|
17323
|
+
}).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, {
|
|
17324
|
+
message: "A service tier requires a Model ID"
|
|
17325
|
+
}),
|
|
17148
17326
|
external_exports.strictObject({
|
|
17149
17327
|
kind: external_exports.literal("prompt"),
|
|
17150
17328
|
...thread,
|
|
@@ -17194,7 +17372,7 @@ var remoteConnectionsRequestSchema = external_exports.discriminatedUnion("action
|
|
|
17194
17372
|
external_exports.strictObject({ action: external_exports.literal("catalog") }),
|
|
17195
17373
|
external_exports.strictObject({
|
|
17196
17374
|
action: external_exports.literal("read-thread"),
|
|
17197
|
-
hostId: hostId.refine((
|
|
17375
|
+
hostId: hostId.refine((id2) => id2 !== "local"),
|
|
17198
17376
|
input: delegationReadParamsSchema
|
|
17199
17377
|
}),
|
|
17200
17378
|
external_exports.strictObject({
|
|
@@ -17208,7 +17386,7 @@ var remoteConnectionsRequestSchema = external_exports.discriminatedUnion("action
|
|
|
17208
17386
|
external_exports.strictObject({ action: external_exports.literal("runtime"), hostId }),
|
|
17209
17387
|
external_exports.strictObject({
|
|
17210
17388
|
action: external_exports.literal("update"),
|
|
17211
|
-
hostId: hostId.refine((
|
|
17389
|
+
hostId: hostId.refine((id2) => id2 !== "local"),
|
|
17212
17390
|
version: remoteUpdateParamsSchema.shape.version
|
|
17213
17391
|
})
|
|
17214
17392
|
]);
|
|
@@ -17272,7 +17450,7 @@ function invalidRequest(message) {
|
|
|
17272
17450
|
return { code: "invalidRequest", message, retryable: false };
|
|
17273
17451
|
}
|
|
17274
17452
|
function validateHostApprovalResponse(interaction, response) {
|
|
17275
|
-
return interaction.actions.some(({ id }) =>
|
|
17453
|
+
return interaction.actions.some(({ id: id2 }) => id2 === response.actionId) ? null : invalidRequest("Approval Response contains an undeclared action ID");
|
|
17276
17454
|
}
|
|
17277
17455
|
|
|
17278
17456
|
// ../../harness-adapter/dist/question.js
|
|
@@ -17280,7 +17458,7 @@ function invalidRequest2(message) {
|
|
|
17280
17458
|
return { code: "invalidRequest", message, retryable: false };
|
|
17281
17459
|
}
|
|
17282
17460
|
function validateHostQuestionResponse(interaction, response) {
|
|
17283
|
-
const questionIds = new Set(interaction.questions.map(({ id }) =>
|
|
17461
|
+
const questionIds = new Set(interaction.questions.map(({ id: id2 }) => id2));
|
|
17284
17462
|
if (response.cancelled) {
|
|
17285
17463
|
return Object.keys(response.answers).length === 0 ? null : invalidRequest2("Cancelled Question Response must not contain answers");
|
|
17286
17464
|
}
|
|
@@ -17311,6 +17489,21 @@ function validateHostQuestionResponse(interaction, response) {
|
|
|
17311
17489
|
return null;
|
|
17312
17490
|
}
|
|
17313
17491
|
|
|
17492
|
+
// ../../harness-adapter/dist/composite-model-ref.js
|
|
17493
|
+
function compositeModelRefIds(entries, fallbackId) {
|
|
17494
|
+
const counts = /* @__PURE__ */ new Map();
|
|
17495
|
+
for (const entry of entries) {
|
|
17496
|
+
const id2 = `${entry.provider}/${entry.model}`;
|
|
17497
|
+
counts.set(id2, (counts.get(id2) ?? 0) + 1);
|
|
17498
|
+
}
|
|
17499
|
+
const ids = /* @__PURE__ */ new Map();
|
|
17500
|
+
for (const entry of entries) {
|
|
17501
|
+
const id2 = `${entry.provider}/${entry.model}`;
|
|
17502
|
+
ids.set(counts.get(id2) === 1 ? id2 : fallbackId(entry), entry);
|
|
17503
|
+
}
|
|
17504
|
+
return ids;
|
|
17505
|
+
}
|
|
17506
|
+
|
|
17314
17507
|
// ../../harness-adapter/dist/output-channel.js
|
|
17315
17508
|
var HarnessOutputChannel = class {
|
|
17316
17509
|
outputs;
|
|
@@ -17395,7 +17588,8 @@ var tokenFields = [
|
|
|
17395
17588
|
var safeIntegerFields = [
|
|
17396
17589
|
"planFiveHourResetsAtUnix",
|
|
17397
17590
|
"planSevenDayResetsAtUnix",
|
|
17398
|
-
"timeToFirstOutputMs"
|
|
17591
|
+
"timeToFirstOutputMs",
|
|
17592
|
+
"latestRequestTimeToFirstOutputMs"
|
|
17399
17593
|
];
|
|
17400
17594
|
var percentFields = [
|
|
17401
17595
|
"cacheHitRatePercent",
|
|
@@ -17637,10 +17831,10 @@ function configureSubagentSnapshot(snapshot, parent) {
|
|
|
17637
17831
|
}
|
|
17638
17832
|
|
|
17639
17833
|
// dist/usage.js
|
|
17640
|
-
function requestTokens(
|
|
17834
|
+
function requestTokens(id2, model2, value) {
|
|
17641
17835
|
const tokens = record2(value), cache = record2(tokens.cache);
|
|
17642
17836
|
const request = parseHostUsageRequest({
|
|
17643
|
-
requestId:
|
|
17837
|
+
requestId: id2,
|
|
17644
17838
|
...model2 ? { model: model2 } : {},
|
|
17645
17839
|
inputTokens: tokens.input,
|
|
17646
17840
|
outputTokens: tokens.output,
|
|
@@ -17734,12 +17928,12 @@ var ZcodeUsage = class {
|
|
|
17734
17928
|
const pending2 = this.#pending;
|
|
17735
17929
|
if (!pending2 || pending2.turnId !== event.turnId || p.source === "subagent")
|
|
17736
17930
|
return;
|
|
17737
|
-
const
|
|
17738
|
-
if (!
|
|
17931
|
+
const id2 = text(p.assistantMessageId);
|
|
17932
|
+
if (!id2)
|
|
17739
17933
|
return;
|
|
17740
|
-
if (pending2.messageId && pending2.messageId !==
|
|
17934
|
+
if (pending2.messageId && pending2.messageId !== id2)
|
|
17741
17935
|
pending2.ambiguous = true;
|
|
17742
|
-
pending2.messageId =
|
|
17936
|
+
pending2.messageId = id2;
|
|
17743
17937
|
if (pending2.startedAtMs === void 0 && ((p.kind === "text_delta" || p.kind === "reasoning_delta") && text(p.delta) || p.kind === "tool_input_start" || p.kind === "tool_input_delta" && text(p.delta) || p.kind === "tool_call"))
|
|
17744
17938
|
pending2.startedAtMs = event.timestamp;
|
|
17745
17939
|
return;
|
|
@@ -17747,11 +17941,11 @@ var ZcodeUsage = class {
|
|
|
17747
17941
|
if (event.type !== "session.updated" || p.querySource !== "main_turn")
|
|
17748
17942
|
return;
|
|
17749
17943
|
if (p.type === "model_request_started") {
|
|
17750
|
-
const
|
|
17751
|
-
if (!
|
|
17944
|
+
const id2 = text(p.requestId), model2 = text(p.modelId);
|
|
17945
|
+
if (!id2 || !model2)
|
|
17752
17946
|
return;
|
|
17753
17947
|
this.#pending = {
|
|
17754
|
-
id,
|
|
17948
|
+
id: id2,
|
|
17755
17949
|
model: model2,
|
|
17756
17950
|
turnId: event.turnId,
|
|
17757
17951
|
ambiguous: this.#pending !== void 0
|
|
@@ -17867,12 +18061,13 @@ function createZcodeUsageStatistics(environment) {
|
|
|
17867
18061
|
}
|
|
17868
18062
|
];
|
|
17869
18063
|
},
|
|
17870
|
-
readSource: (
|
|
18064
|
+
readSource: (id2) => readZcodeUsage(id2)
|
|
17871
18065
|
});
|
|
17872
18066
|
}
|
|
17873
18067
|
|
|
17874
18068
|
// dist/adapter.js
|
|
17875
|
-
import
|
|
18069
|
+
import path7 from "node:path";
|
|
18070
|
+
import { isDeepStrictEqual } from "node:util";
|
|
17876
18071
|
import { stat as stat2 } from "node:fs/promises";
|
|
17877
18072
|
|
|
17878
18073
|
// dist/transport.js
|
|
@@ -18019,57 +18214,374 @@ function createZcodeInstallation(environment, app) {
|
|
|
18019
18214
|
// dist/account.js
|
|
18020
18215
|
import { createHash as createHash4 } from "node:crypto";
|
|
18021
18216
|
import { readFile as readFile3 } from "node:fs/promises";
|
|
18022
|
-
import
|
|
18217
|
+
import path6 from "node:path";
|
|
18023
18218
|
|
|
18024
18219
|
// dist/credentials.js
|
|
18025
18220
|
import { createDecipheriv, createHash } from "node:crypto";
|
|
18026
|
-
import {
|
|
18221
|
+
import { constants } from "node:fs";
|
|
18222
|
+
import { open as open2, readFile } from "node:fs/promises";
|
|
18027
18223
|
import { homedir as homedir2, platform, userInfo } from "node:os";
|
|
18224
|
+
import path4 from "node:path";
|
|
18225
|
+
|
|
18226
|
+
// dist/credential-keyring.js
|
|
18227
|
+
import { execFile } from "node:child_process";
|
|
18028
18228
|
import path3 from "node:path";
|
|
18029
|
-
|
|
18030
|
-
|
|
18031
|
-
|
|
18229
|
+
import { promisify } from "node:util";
|
|
18230
|
+
var execute = promisify(execFile);
|
|
18231
|
+
var SERVICE = "ZCode Credential Encryption";
|
|
18232
|
+
var KEYCHAIN_PASSWORD_TIMEOUT_MS = 3e4;
|
|
18233
|
+
var KeychainReadTimeout = class extends Error {
|
|
18234
|
+
};
|
|
18235
|
+
var KeychainAccessDeferred = class extends Error {
|
|
18236
|
+
};
|
|
18237
|
+
var cachedKeys = /* @__PURE__ */ new Map();
|
|
18238
|
+
var deniedReads = /* @__PURE__ */ new Map();
|
|
18239
|
+
var inFlightReads = /* @__PURE__ */ new Map();
|
|
18240
|
+
function invalidateSystemCredentialKey(account, value) {
|
|
18241
|
+
const key = `${process.platform}:${account}`;
|
|
18242
|
+
const cached2 = cachedKeys.get(key);
|
|
18243
|
+
if (cached2?.value !== value)
|
|
18244
|
+
return;
|
|
18245
|
+
if (process.platform === "darwin")
|
|
18246
|
+
cached2.mismatched = true;
|
|
18247
|
+
else
|
|
18248
|
+
cachedKeys.delete(key);
|
|
18249
|
+
}
|
|
18250
|
+
var WIN32_READER = String.raw`
|
|
18251
|
+
$ErrorActionPreference = 'Stop'
|
|
18252
|
+
Add-Type -TypeDefinition @'
|
|
18253
|
+
using System;
|
|
18254
|
+
using System.Runtime.InteropServices;
|
|
18255
|
+
|
|
18256
|
+
public static class ZCodeKeyReader {
|
|
18257
|
+
[StructLayout(LayoutKind.Sequential)]
|
|
18258
|
+
private struct Credential {
|
|
18259
|
+
public uint Flags, Type;
|
|
18260
|
+
public IntPtr TargetName, Comment;
|
|
18261
|
+
public System.Runtime.InteropServices.ComTypes.FILETIME LastWritten;
|
|
18262
|
+
public uint BlobSize;
|
|
18263
|
+
public IntPtr Blob;
|
|
18264
|
+
}
|
|
18265
|
+
|
|
18266
|
+
[DllImport("advapi32.dll", ExactSpelling = true, CharSet = CharSet.Unicode)]
|
|
18267
|
+
[return: MarshalAs(UnmanagedType.Bool)]
|
|
18268
|
+
private static extern bool CredReadW(string target, uint type, uint flags, out IntPtr result);
|
|
18269
|
+
|
|
18270
|
+
[DllImport("advapi32.dll", ExactSpelling = true)]
|
|
18271
|
+
private static extern void CredFree(IntPtr credential);
|
|
18272
|
+
|
|
18273
|
+
public static string Read(string target) {
|
|
18274
|
+
IntPtr result;
|
|
18275
|
+
if (!CredReadW(target, 1, 0, out result)) return null; // CRED_TYPE_GENERIC
|
|
18276
|
+
try {
|
|
18277
|
+
var credential = (Credential)Marshal.PtrToStructure(result, typeof(Credential));
|
|
18278
|
+
if (credential.Blob == IntPtr.Zero || credential.BlobSize != 86) return null;
|
|
18279
|
+
return Marshal.PtrToStringUni(credential.Blob, 43);
|
|
18280
|
+
} finally { CredFree(result); }
|
|
18281
|
+
}
|
|
18282
|
+
}
|
|
18283
|
+
'@
|
|
18284
|
+
`;
|
|
18285
|
+
var readSystemCredentialKey = async (account, options = {}) => {
|
|
18286
|
+
if (!/^[a-f0-9]{64}$/.test(account))
|
|
18287
|
+
return;
|
|
18288
|
+
const cacheKey = `${process.platform}:${account}`;
|
|
18289
|
+
const existing = inFlightReads.get(cacheKey);
|
|
18290
|
+
if (existing)
|
|
18291
|
+
return existing;
|
|
18292
|
+
const mayRetry = (readAt) => options.access === "retry" && (options.requestedAt ?? Infinity) >= readAt;
|
|
18293
|
+
const cached2 = cachedKeys.get(cacheKey);
|
|
18294
|
+
if (cached2 && (!cached2.mismatched || !mayRetry(cached2.readAt))) {
|
|
18295
|
+
if (cached2.mismatched && options.access !== "retry")
|
|
18296
|
+
options.skipped = "retry";
|
|
18297
|
+
return cached2.value;
|
|
18298
|
+
}
|
|
18299
|
+
const denied = deniedReads.get(cacheKey);
|
|
18300
|
+
if (denied && !mayRetry(denied.readAt)) {
|
|
18301
|
+
if (options.access !== "retry")
|
|
18302
|
+
options.skipped = "retry";
|
|
18303
|
+
if (denied.reason === "timeout")
|
|
18304
|
+
throw new KeychainReadTimeout();
|
|
18305
|
+
return void 0;
|
|
18306
|
+
}
|
|
18307
|
+
if (process.platform === "darwin" && !options.access) {
|
|
18308
|
+
options.skipped = "allow";
|
|
18309
|
+
throw new KeychainAccessDeferred();
|
|
18310
|
+
}
|
|
18311
|
+
cachedKeys.delete(cacheKey);
|
|
18312
|
+
deniedReads.delete(cacheKey);
|
|
18313
|
+
const read = (async () => {
|
|
18314
|
+
const env = {
|
|
18315
|
+
...process.env,
|
|
18316
|
+
ZCODE_CREDENTIAL_SECRET: void 0,
|
|
18317
|
+
ZCODE_CREDENTIAL_SECRET_FILE: void 0
|
|
18318
|
+
};
|
|
18319
|
+
const run = async (file2, args, timeout = 5e3) => (await execute(file2, args, { env, timeout, maxBuffer: 4096, windowsHide: true })).stdout;
|
|
18320
|
+
try {
|
|
18321
|
+
let value;
|
|
18322
|
+
if (process.platform === "win32") {
|
|
18323
|
+
const root = process.env.SystemRoot;
|
|
18324
|
+
if (!root || !path3.isAbsolute(root))
|
|
18325
|
+
return;
|
|
18326
|
+
const powershell = path3.join(root, "System32", "WindowsPowerShell", "v1.0", "powershell.exe");
|
|
18327
|
+
const command = `${WIN32_READER}
|
|
18328
|
+
[Console]::Write([ZCodeKeyReader]::Read('${account}.${SERVICE}'))`;
|
|
18329
|
+
value = (await run(powershell, [
|
|
18330
|
+
"-NoLogo",
|
|
18331
|
+
"-NoProfile",
|
|
18332
|
+
"-NonInteractive",
|
|
18333
|
+
"-EncodedCommand",
|
|
18334
|
+
Buffer.from(command, "utf16le").toString("base64")
|
|
18335
|
+
])).replace(/\r?\n$/, "");
|
|
18336
|
+
} else if (process.platform === "darwin") {
|
|
18337
|
+
const security = "/usr/bin/security";
|
|
18338
|
+
const keychain = /^\s*"([^"\r\n]+)"\s*$/.exec(await run(security, ["default-keychain", "-d", "user"]))?.[1];
|
|
18339
|
+
if (!keychain || !path3.isAbsolute(keychain)) {
|
|
18340
|
+
deniedReads.set(cacheKey, { reason: "denied", readAt: performance.now() });
|
|
18341
|
+
return;
|
|
18342
|
+
}
|
|
18343
|
+
const raw = await run(security, ["find-generic-password", "-s", SERVICE, "-a", account, "-w", keychain], KEYCHAIN_PASSWORD_TIMEOUT_MS).catch((error51) => {
|
|
18344
|
+
const failure2 = error51;
|
|
18345
|
+
if (failure2?.killed && failure2.code === null && failure2.signal === "SIGTERM")
|
|
18346
|
+
throw new KeychainReadTimeout();
|
|
18347
|
+
return void 0;
|
|
18348
|
+
});
|
|
18349
|
+
value = raw?.replace(/\r?\n$/, "");
|
|
18350
|
+
} else if (process.platform === "linux") {
|
|
18351
|
+
value = await run("/usr/bin/secret-tool", [
|
|
18352
|
+
"lookup",
|
|
18353
|
+
"service",
|
|
18354
|
+
SERVICE,
|
|
18355
|
+
"username",
|
|
18356
|
+
account
|
|
18357
|
+
]);
|
|
18358
|
+
}
|
|
18359
|
+
if (value) {
|
|
18360
|
+
cachedKeys.set(cacheKey, { value, readAt: performance.now() });
|
|
18361
|
+
deniedReads.delete(cacheKey);
|
|
18362
|
+
return value;
|
|
18363
|
+
}
|
|
18364
|
+
deniedReads.set(cacheKey, { reason: "denied", readAt: performance.now() });
|
|
18365
|
+
return value;
|
|
18366
|
+
} catch (error51) {
|
|
18367
|
+
if (error51 instanceof KeychainReadTimeout) {
|
|
18368
|
+
deniedReads.set(cacheKey, { reason: "timeout", readAt: performance.now() });
|
|
18369
|
+
throw error51;
|
|
18370
|
+
}
|
|
18371
|
+
deniedReads.set(cacheKey, { reason: "denied", readAt: performance.now() });
|
|
18372
|
+
}
|
|
18373
|
+
})();
|
|
18374
|
+
inFlightReads.set(cacheKey, read);
|
|
18375
|
+
try {
|
|
18376
|
+
return await read;
|
|
18377
|
+
} finally {
|
|
18378
|
+
inFlightReads.delete(cacheKey);
|
|
18379
|
+
}
|
|
18380
|
+
};
|
|
18381
|
+
|
|
18382
|
+
// dist/credentials.js
|
|
18383
|
+
var V1 = "enc:v1:";
|
|
18384
|
+
var V2 = "enc:v2:";
|
|
18385
|
+
var digest = (value) => createHash("sha256").update(value).digest();
|
|
18386
|
+
var storeSchema = external_exports.record(external_exports.string(), external_exports.string());
|
|
18387
|
+
var ZcodeCredentialError = class extends ZcodeError {
|
|
18388
|
+
constructor(message, code = "authenticationRequired") {
|
|
18389
|
+
super(code, message, code !== "credentialAccessRequired");
|
|
18390
|
+
}
|
|
18391
|
+
};
|
|
18392
|
+
var invalidV2 = () => new ZcodeCredentialError("Cannot decrypt ZCode enc:v2: credentials: invalid or damaged encrypted record.");
|
|
18393
|
+
var unavailableV2 = () => new ZcodeCredentialError("Cannot read ZCode enc:v2: credentials: the original key is unavailable or does not match. Check the ZCode credential storage in the Host user's session.");
|
|
18394
|
+
function decryptGcm(iv, tag, data, key) {
|
|
18395
|
+
const decipher = createDecipheriv("aes-256-gcm", key, iv, { authTagLength: tag.length });
|
|
18396
|
+
decipher.setAuthTag(tag);
|
|
18397
|
+
return Buffer.concat([decipher.update(data), decipher.final()]).toString("utf8");
|
|
18398
|
+
}
|
|
18399
|
+
function decryptV1(value, environment) {
|
|
18032
18400
|
let username = "unknown";
|
|
18033
18401
|
try {
|
|
18034
18402
|
username = userInfo().username;
|
|
18035
18403
|
} catch {
|
|
18036
18404
|
}
|
|
18037
18405
|
const secret = environment.ZCODE_CREDENTIAL_SECRET || `zcode-credential-fallback:${platform()}:${environment.HOME || homedir2()}:${username}`;
|
|
18038
|
-
const [iv, tag, data, extra] = value.slice(
|
|
18406
|
+
const [iv, tag, data, extra] = value.slice(V1.length).split(".");
|
|
18039
18407
|
try {
|
|
18040
18408
|
if (!iv || !tag || !data || extra !== void 0)
|
|
18041
18409
|
throw new Error();
|
|
18042
|
-
const
|
|
18043
|
-
|
|
18044
|
-
|
|
18410
|
+
const authTag = Buffer.from(tag, "base64url");
|
|
18411
|
+
if (authTag.length !== 16)
|
|
18412
|
+
throw new Error();
|
|
18413
|
+
return decryptGcm(Buffer.from(iv, "base64url"), authTag, Buffer.from(data, "base64url"), digest(secret)).trim();
|
|
18045
18414
|
} catch {
|
|
18046
|
-
throw new
|
|
18415
|
+
throw new ZcodeCredentialError("Cannot decrypt ZCode credentials; ZCODE_CREDENTIAL_SECRET must match ZCode Desktop");
|
|
18047
18416
|
}
|
|
18048
18417
|
}
|
|
18049
|
-
|
|
18050
|
-
|
|
18418
|
+
function decodeSegment(value) {
|
|
18419
|
+
if (!/^[A-Za-z0-9_-]*$/.test(value))
|
|
18420
|
+
throw invalidV2();
|
|
18421
|
+
const bytes = Buffer.from(value, "base64url");
|
|
18422
|
+
if (bytes.toString("base64url") !== value)
|
|
18423
|
+
throw invalidV2();
|
|
18424
|
+
return bytes;
|
|
18425
|
+
}
|
|
18426
|
+
async function decryptV2(value, getKey) {
|
|
18427
|
+
const [source, fingerprint, payload, extra] = value.slice(V2.length).split(":");
|
|
18428
|
+
if (source !== "os" && source !== "env" || !fingerprint || !/^[a-f0-9]{24}$/.test(fingerprint) || !payload || extra !== void 0)
|
|
18429
|
+
throw invalidV2();
|
|
18430
|
+
const [encodedIv, encodedTag, encodedData, extraSegment] = payload.split(".");
|
|
18431
|
+
if (!encodedIv || !encodedTag || encodedData === void 0 || extraSegment !== void 0)
|
|
18432
|
+
throw invalidV2();
|
|
18433
|
+
const iv = decodeSegment(encodedIv);
|
|
18434
|
+
const tag = decodeSegment(encodedTag);
|
|
18435
|
+
const data = decodeSegment(encodedData);
|
|
18436
|
+
if (iv.length !== 12 || tag.length !== 16)
|
|
18437
|
+
throw invalidV2();
|
|
18438
|
+
const material = await getKey(source);
|
|
18439
|
+
const { key } = material;
|
|
18440
|
+
if (source !== material.source)
|
|
18441
|
+
throw unavailableV2();
|
|
18442
|
+
if (digest(key).toString("hex").slice(0, 24) !== fingerprint) {
|
|
18443
|
+
if (material.account) {
|
|
18444
|
+
invalidateSystemCredentialKey(material.account, key.toString("base64url"));
|
|
18445
|
+
if (process.platform === "darwin")
|
|
18446
|
+
throw new ZcodeCredentialError(`${unavailableV2().message} Re-detect ZCode in Connections to authorize the macOS Keychain read again.`, "credentialAccessRequired");
|
|
18447
|
+
}
|
|
18448
|
+
throw unavailableV2();
|
|
18449
|
+
}
|
|
18450
|
+
try {
|
|
18451
|
+
return decryptGcm(iv, tag, data, key);
|
|
18452
|
+
} catch {
|
|
18453
|
+
throw invalidV2();
|
|
18454
|
+
}
|
|
18455
|
+
}
|
|
18456
|
+
async function readSecretFile(file2, implicit) {
|
|
18457
|
+
const handle = await open2(file2, constants.O_RDONLY | (constants.O_NONBLOCK ?? 0));
|
|
18458
|
+
try {
|
|
18459
|
+
const stat3 = await handle.stat();
|
|
18460
|
+
if (!stat3.isFile() || stat3.size < 32 || stat3.size > 4096 || implicit && process.platform !== "win32" && (stat3.mode & 63) !== 0)
|
|
18461
|
+
throw unavailableV2();
|
|
18462
|
+
const secret = await handle.readFile("utf8");
|
|
18463
|
+
const length = Buffer.byteLength(secret, "utf8");
|
|
18464
|
+
if (length < 32 || length > 4096)
|
|
18465
|
+
throw unavailableV2();
|
|
18466
|
+
return secret;
|
|
18467
|
+
} finally {
|
|
18468
|
+
await handle.close();
|
|
18469
|
+
}
|
|
18470
|
+
}
|
|
18471
|
+
async function loadV2Key(file2, values, environment, readSystemKey, source, readSystemKeyOptions) {
|
|
18472
|
+
try {
|
|
18473
|
+
const secret = environment.ZCODE_CREDENTIAL_SECRET;
|
|
18474
|
+
const explicitFile = environment.ZCODE_CREDENTIAL_SECRET_FILE;
|
|
18475
|
+
if (secret && explicitFile)
|
|
18476
|
+
throw unavailableV2();
|
|
18477
|
+
if (secret)
|
|
18478
|
+
return { source: "env", key: digest(secret) };
|
|
18479
|
+
if (explicitFile)
|
|
18480
|
+
return { source: "env", key: digest(await readSecretFile(explicitFile, false)) };
|
|
18481
|
+
const directory = path4.dirname(file2);
|
|
18482
|
+
const marker = await readFile(path4.join(directory, "credential-source"), "utf8").catch((error51) => {
|
|
18483
|
+
if (error51.code === "ENOENT")
|
|
18484
|
+
return void 0;
|
|
18485
|
+
throw error51;
|
|
18486
|
+
});
|
|
18487
|
+
if (marker !== void 0 && marker !== "os\n")
|
|
18488
|
+
throw unavailableV2();
|
|
18489
|
+
const hasOsEnvelope = Object.values(values).some((value) => value.startsWith(`${V2}os:`));
|
|
18490
|
+
if (!hasOsEnvelope) {
|
|
18491
|
+
if (marker)
|
|
18492
|
+
throw unavailableV2();
|
|
18493
|
+
return {
|
|
18494
|
+
source: "env",
|
|
18495
|
+
key: digest(await readSecretFile(path4.join(directory, "credential-secret"), true))
|
|
18496
|
+
};
|
|
18497
|
+
}
|
|
18498
|
+
if (source !== "os")
|
|
18499
|
+
throw unavailableV2();
|
|
18500
|
+
const account = digest(file2).toString("hex");
|
|
18501
|
+
const encoded = readSystemKeyOptions ? await readSystemKey(account, readSystemKeyOptions) : await readSystemKey(account);
|
|
18502
|
+
if (!encoded && process.platform === "darwin")
|
|
18503
|
+
throw new ZcodeCredentialError(`${unavailableV2().message} Re-detect ZCode in Connections to authorize the macOS Keychain read again.`, "credentialAccessRequired");
|
|
18504
|
+
if (!encoded || encoded.length !== 43)
|
|
18505
|
+
throw unavailableV2();
|
|
18506
|
+
const key = decodeSegment(encoded);
|
|
18507
|
+
if (key.length !== 32)
|
|
18508
|
+
throw unavailableV2();
|
|
18509
|
+
return { source: "os", key, account };
|
|
18510
|
+
} catch (error51) {
|
|
18511
|
+
if (error51 instanceof ZcodeCredentialError && error51.code === "credentialAccessRequired")
|
|
18512
|
+
throw error51;
|
|
18513
|
+
if (error51 instanceof KeychainAccessDeferred)
|
|
18514
|
+
throw new ZcodeCredentialError("ZCode account models require macOS Keychain access. Select ZCode or re-detect it in Connections to authorize access.", "credentialAccessRequired");
|
|
18515
|
+
if (error51 instanceof KeychainReadTimeout)
|
|
18516
|
+
throw new ZcodeCredentialError("ZCode could not read credentials: macOS Keychain read timed out. Re-detect ZCode in Connections and allow access to ZCode Credential Encryption.", "credentialAccessRequired");
|
|
18517
|
+
throw unavailableV2();
|
|
18518
|
+
}
|
|
18519
|
+
}
|
|
18520
|
+
function plaintextCredential(value) {
|
|
18521
|
+
if (/^\s*(?:Bearer\s+)*enc:/i.test(value))
|
|
18522
|
+
throw new ZcodeCredentialError("Cannot read ZCode credentials: unsupported encrypted credential format (enc:).");
|
|
18523
|
+
return value;
|
|
18524
|
+
}
|
|
18525
|
+
async function readCredentials(installation, environment, readSystemKey = readSystemCredentialKey, readSystemKeyOptions) {
|
|
18526
|
+
const file2 = path4.resolve(installation.dataRoot, "credentials.json");
|
|
18527
|
+
let values;
|
|
18051
18528
|
try {
|
|
18052
|
-
|
|
18529
|
+
values = storeSchema.parse(JSON.parse(await readFile(file2, "utf8")));
|
|
18053
18530
|
} catch (error51) {
|
|
18054
18531
|
if (error51.code === "ENOENT")
|
|
18055
|
-
return () => "";
|
|
18056
|
-
throw new
|
|
18057
|
-
}
|
|
18058
|
-
const
|
|
18059
|
-
return (key) => {
|
|
18060
|
-
const value = values
|
|
18061
|
-
|
|
18532
|
+
return async () => "";
|
|
18533
|
+
throw new ZcodeCredentialError("Cannot read ZCode credentials.");
|
|
18534
|
+
}
|
|
18535
|
+
const keys = /* @__PURE__ */ new Map();
|
|
18536
|
+
return async (key) => {
|
|
18537
|
+
const value = Object.hasOwn(values, key) ? values[key] : void 0;
|
|
18538
|
+
if (value === void 0)
|
|
18539
|
+
return "";
|
|
18540
|
+
return plaintextCredential(value.startsWith(V1) ? decryptV1(value, environment) : value.startsWith(V2) ? await decryptV2(value, (source) => {
|
|
18541
|
+
const existing = keys.get(source);
|
|
18542
|
+
if (existing)
|
|
18543
|
+
return existing;
|
|
18544
|
+
const key2 = loadV2Key(file2, values, environment, readSystemKey, source, readSystemKeyOptions);
|
|
18545
|
+
keys.set(source, key2);
|
|
18546
|
+
return key2;
|
|
18547
|
+
}) : value);
|
|
18062
18548
|
};
|
|
18063
18549
|
}
|
|
18064
|
-
|
|
18065
|
-
|
|
18550
|
+
|
|
18551
|
+
// dist/oauth-account.js
|
|
18552
|
+
async function readLoginChannel(credential) {
|
|
18553
|
+
const active2 = await credential("oauth:active_provider");
|
|
18554
|
+
if (active2 === "zai" || active2 === "zai_cn" || active2 === "bigmodel")
|
|
18555
|
+
return active2;
|
|
18556
|
+
if (active2)
|
|
18557
|
+
throw new ZcodeCredentialError("The active ZCode login channel is not supported by CodexHost.");
|
|
18558
|
+
}
|
|
18559
|
+
var normalizedProfile = external_exports.object({
|
|
18560
|
+
id: external_exports.string(),
|
|
18561
|
+
username: external_exports.string(),
|
|
18562
|
+
displayName: external_exports.string()
|
|
18563
|
+
});
|
|
18564
|
+
var rawZaiProfile = external_exports.object({ user_id: external_exports.string() });
|
|
18565
|
+
async function readOAuthUserId(credential, channel) {
|
|
18566
|
+
const raw = await credential(`oauth:${channel}:user_info`);
|
|
18567
|
+
if (!raw)
|
|
18568
|
+
return;
|
|
18569
|
+
let profile;
|
|
18570
|
+
try {
|
|
18571
|
+
profile = JSON.parse(raw);
|
|
18572
|
+
} catch {
|
|
18573
|
+
throw new ZcodeCredentialError("Cannot read the ZCode login profile.");
|
|
18574
|
+
}
|
|
18575
|
+
const id2 = normalizedProfile.safeParse(profile).data?.id ?? (channel === "bigmodel" ? void 0 : rawZaiProfile.safeParse(profile).data?.user_id);
|
|
18576
|
+
if (id2?.trim() && id2.trim() !== "unknown")
|
|
18577
|
+
return id2;
|
|
18066
18578
|
}
|
|
18067
18579
|
|
|
18068
18580
|
// dist/personal-coding-plan.js
|
|
18069
18581
|
import { createHash as createHash3 } from "node:crypto";
|
|
18070
18582
|
import { readFile as readFile2 } from "node:fs/promises";
|
|
18071
18583
|
import { homedir as homedir3 } from "node:os";
|
|
18072
|
-
import
|
|
18584
|
+
import path5 from "node:path";
|
|
18073
18585
|
|
|
18074
18586
|
// dist/project-token.js
|
|
18075
18587
|
import { createHash as createHash2 } from "node:crypto";
|
|
@@ -18078,13 +18590,13 @@ var locationSchema = external_exports.object({
|
|
|
18078
18590
|
projectId: external_exports.string().trim().min(1),
|
|
18079
18591
|
apiKeyId: external_exports.string().trim().min(1)
|
|
18080
18592
|
});
|
|
18081
|
-
function readProjectCredential(credential, family, identity2, origin) {
|
|
18593
|
+
async function readProjectCredential(credential, family, identity2, origin, account) {
|
|
18082
18594
|
const key = `project-key-location:v1:${encodeURIComponent(JSON.stringify([origin, family, identity2, null, 1, "non-team"]))}`;
|
|
18083
|
-
const raw = credential(key);
|
|
18595
|
+
const raw = await credential(key);
|
|
18084
18596
|
if (!raw)
|
|
18085
18597
|
return void 0;
|
|
18086
18598
|
const location = locationSchema.parse(JSON.parse(raw));
|
|
18087
|
-
const login = credential(`oauth:${family}:access_token`).trim();
|
|
18599
|
+
const login = (account.linkedAccessToken ?? await credential(`oauth:${family}:access_token`)).trim();
|
|
18088
18600
|
const loginToken = login.replace(/^Bearer\s+/i, "").trim();
|
|
18089
18601
|
if (!loginToken)
|
|
18090
18602
|
throw projectCredentialError();
|
|
@@ -18093,7 +18605,10 @@ function readProjectCredential(credential, family, identity2, origin) {
|
|
|
18093
18605
|
"individual-coding-plan",
|
|
18094
18606
|
null,
|
|
18095
18607
|
login,
|
|
18096
|
-
credential("zcodejwttoken").trim() || null
|
|
18608
|
+
(await credential("zcodejwttoken")).trim() || null,
|
|
18609
|
+
account.sessionRevision || null,
|
|
18610
|
+
identity2,
|
|
18611
|
+
account.userId
|
|
18097
18612
|
])).digest("hex");
|
|
18098
18613
|
return { origin, loginToken, location, accountScope };
|
|
18099
18614
|
}
|
|
@@ -18137,17 +18652,18 @@ var ProjectToken = class {
|
|
|
18137
18652
|
if (!parsed.success || parsed.data.success === false || parsed.data.data.enable === false)
|
|
18138
18653
|
throw projectCredentialError();
|
|
18139
18654
|
const data = parsed.data.data;
|
|
18655
|
+
const token = plaintextCredential(data.accessToken);
|
|
18140
18656
|
const expiresAt = Math.min(data.expiresAt * 1e3, started + data.expiresIn * 1e3);
|
|
18141
18657
|
signal.throwIfAborted();
|
|
18142
18658
|
if (expiresAt <= Date.now())
|
|
18143
18659
|
throw projectCredentialError();
|
|
18144
18660
|
this.#cached = {
|
|
18145
18661
|
scope,
|
|
18146
|
-
token
|
|
18662
|
+
token,
|
|
18147
18663
|
expiresAt,
|
|
18148
|
-
fingerprint: createHash2("sha256").update(
|
|
18664
|
+
fingerprint: createHash2("sha256").update(token).digest("hex")
|
|
18149
18665
|
};
|
|
18150
|
-
return
|
|
18666
|
+
return token;
|
|
18151
18667
|
} catch (error51) {
|
|
18152
18668
|
signal.throwIfAborted();
|
|
18153
18669
|
if (error51 instanceof ZcodeError)
|
|
@@ -18163,6 +18679,18 @@ var ProjectToken = class {
|
|
|
18163
18679
|
var familySchema = external_exports.enum(["zai", "bigmodel"]);
|
|
18164
18680
|
var recordSchema2 = external_exports.record(external_exports.string(), external_exports.unknown());
|
|
18165
18681
|
var CONNECT = "Connect Personal Coding Plan in ZCode Desktop, then re-detect ZCode and reopen the Thread";
|
|
18682
|
+
var linkedBigModelSchema = external_exports.object({
|
|
18683
|
+
userId: external_exports.string(),
|
|
18684
|
+
customerId: external_exports.string().trim().min(1),
|
|
18685
|
+
accessToken: external_exports.string().trim().min(1)
|
|
18686
|
+
});
|
|
18687
|
+
function parseBigModelLink(raw) {
|
|
18688
|
+
try {
|
|
18689
|
+
return linkedBigModelSchema.safeParse(JSON.parse(raw)).data;
|
|
18690
|
+
} catch {
|
|
18691
|
+
return void 0;
|
|
18692
|
+
}
|
|
18693
|
+
}
|
|
18166
18694
|
function personalCodingPlanOrigin(family, environment) {
|
|
18167
18695
|
const test = environment.ZCODE_ENV?.trim().toLowerCase() === "test";
|
|
18168
18696
|
const prefix = family === "zai" ? "ZAI" : "BIGMODEL";
|
|
@@ -18177,7 +18705,7 @@ async function readSelection(environment, family) {
|
|
|
18177
18705
|
const home = environment.ZCODE_DESKTOP_HOME_DIR?.trim() || environment.HOME?.trim() || environment.USERPROFILE?.trim() || homedir3();
|
|
18178
18706
|
let raw;
|
|
18179
18707
|
try {
|
|
18180
|
-
raw = JSON.parse(await readFile2(
|
|
18708
|
+
raw = JSON.parse(await readFile2(path5.join(home, ".zcode", "v2", "setting.json"), "utf8"));
|
|
18181
18709
|
} catch (error51) {
|
|
18182
18710
|
if (error51.code === "ENOENT")
|
|
18183
18711
|
return false;
|
|
@@ -18213,8 +18741,10 @@ async function queryEntitlement(family, apiKey, environment) {
|
|
|
18213
18741
|
try {
|
|
18214
18742
|
const response = await fetch(`${personalCodingPlanOrigin(family, environment)}/api/biz/subscription/list`, {
|
|
18215
18743
|
method: "GET",
|
|
18216
|
-
//
|
|
18217
|
-
headers: {
|
|
18744
|
+
// Desktop checks the model credential: a personal API Key or a project token.
|
|
18745
|
+
headers: {
|
|
18746
|
+
Authorization: apiKey.trim().replace(/^Bearer\s+/i, "").trim()
|
|
18747
|
+
},
|
|
18218
18748
|
redirect: "error",
|
|
18219
18749
|
signal: AbortSignal.timeout(15e3)
|
|
18220
18750
|
});
|
|
@@ -18249,38 +18779,52 @@ var PersonalCodingPlanAccount = class {
|
|
|
18249
18779
|
#authorized = /* @__PURE__ */ new Map();
|
|
18250
18780
|
#projectToken = new ProjectToken();
|
|
18251
18781
|
issue;
|
|
18782
|
+
credentialIssue;
|
|
18783
|
+
credentialAccessRequired = false;
|
|
18252
18784
|
constructor(installation, environment) {
|
|
18253
18785
|
this.installation = installation;
|
|
18254
18786
|
this.environment = environment;
|
|
18255
18787
|
}
|
|
18256
|
-
async #context(providerId, family) {
|
|
18788
|
+
async #context(providerId, family, existingCredential) {
|
|
18257
18789
|
const [credential, current] = await Promise.all([
|
|
18258
|
-
readCredentials(this.installation, this.environment),
|
|
18790
|
+
existingCredential ?? readCredentials(this.installation, this.environment),
|
|
18259
18791
|
readSelection(this.environment, family)
|
|
18260
18792
|
]);
|
|
18261
|
-
|
|
18262
|
-
|
|
18263
|
-
|
|
18264
|
-
|
|
18265
|
-
|
|
18266
|
-
|
|
18267
|
-
|
|
18268
|
-
|
|
18269
|
-
if (
|
|
18270
|
-
|
|
18271
|
-
|
|
18793
|
+
const channel = await readLoginChannel(credential);
|
|
18794
|
+
if (!channel || channel !== family && !(channel === "zai_cn" && family === "bigmodel"))
|
|
18795
|
+
return;
|
|
18796
|
+
const userId = await readOAuthUserId(credential, channel);
|
|
18797
|
+
if (!userId)
|
|
18798
|
+
return;
|
|
18799
|
+
let identity2 = userId.trim();
|
|
18800
|
+
let linkedAccessToken;
|
|
18801
|
+
if (channel === "zai_cn") {
|
|
18802
|
+
if (!await credential("oauth:zai_cn:access_token"))
|
|
18803
|
+
return;
|
|
18804
|
+
const link = parseBigModelLink(await credential("oauth:linked_bigmodel"));
|
|
18805
|
+
if (link?.userId !== userId)
|
|
18806
|
+
return;
|
|
18807
|
+
identity2 = link.customerId;
|
|
18808
|
+
linkedAccessToken = plaintextCredential(link.accessToken);
|
|
18809
|
+
}
|
|
18810
|
+
const sessionRevision = await credential("oauth:session_revision");
|
|
18811
|
+
const account = JSON.stringify([channel, userId, identity2, sessionRevision]);
|
|
18812
|
+
const project2 = await readProjectCredential(credential, family, identity2, personalCodingPlanOrigin(family, this.environment), { userId, sessionRevision, linkedAccessToken });
|
|
18813
|
+
const base = { identity: identity2, account, current };
|
|
18272
18814
|
if (project2)
|
|
18273
|
-
return {
|
|
18815
|
+
return { ...base, project: project2 };
|
|
18274
18816
|
const key = `account-provider:coding-plan:${providerId}:account:${encodeURIComponent(identity2)}:api-key`;
|
|
18275
|
-
return {
|
|
18817
|
+
return { ...base, apiKey: (await credential(key)).trim() };
|
|
18276
18818
|
}
|
|
18277
|
-
async inspect(providerId, accountType) {
|
|
18819
|
+
async inspect(providerId, accountType, existingCredential) {
|
|
18278
18820
|
const family = familySchema.parse(accountType);
|
|
18279
18821
|
this.#authorized.delete(providerId);
|
|
18280
18822
|
this.issue = void 0;
|
|
18823
|
+
this.credentialIssue = void 0;
|
|
18824
|
+
this.credentialAccessRequired = false;
|
|
18281
18825
|
let current = false;
|
|
18282
18826
|
try {
|
|
18283
|
-
const context = await this.#context(providerId, family);
|
|
18827
|
+
const context = await this.#context(providerId, family, existingCredential);
|
|
18284
18828
|
if (!context)
|
|
18285
18829
|
return {
|
|
18286
18830
|
availability: "unavailable",
|
|
@@ -18291,7 +18835,7 @@ var PersonalCodingPlanAccount = class {
|
|
|
18291
18835
|
current = context.current;
|
|
18292
18836
|
const connectionKey = createHash3("sha256").update(JSON.stringify([family, context.identity, "individual-coding-plan"])).digest("hex");
|
|
18293
18837
|
const base = { current, connectionKey };
|
|
18294
|
-
if (!context.apiKey) {
|
|
18838
|
+
if (!context.project && !context.apiKey) {
|
|
18295
18839
|
if (current)
|
|
18296
18840
|
this.issue = "ZCode is signed in, but its Personal Coding Plan credentials are not initialized. Open the personal plan in ZCode Desktop, then re-detect ZCode. This does not mean the subscription is inactive.";
|
|
18297
18841
|
return {
|
|
@@ -18301,13 +18845,14 @@ var PersonalCodingPlanAccount = class {
|
|
|
18301
18845
|
unavailableReason: "credential-failed"
|
|
18302
18846
|
};
|
|
18303
18847
|
}
|
|
18304
|
-
const
|
|
18848
|
+
const apiKey = context.project ? await this.#projectToken.resolve(context.project, this.installation.version, new AbortController().signal) : context.apiKey;
|
|
18849
|
+
const entitlement = await queryEntitlement(family, apiKey, this.environment);
|
|
18305
18850
|
const after = await this.#context(providerId, family);
|
|
18306
|
-
if (!after || after.
|
|
18851
|
+
if (!after || after.account !== context.account || after.current !== current || after.apiKey !== context.apiKey || JSON.stringify(after.project) !== JSON.stringify(context.project))
|
|
18307
18852
|
return { availability: "unknown", entitled: false, current: false };
|
|
18308
18853
|
if (entitlement === "available") {
|
|
18309
18854
|
if (current)
|
|
18310
|
-
this.#authorized.set(providerId, { family,
|
|
18855
|
+
this.#authorized.set(providerId, { family, account: context.account });
|
|
18311
18856
|
return { ...base, availability: "available", entitled: true };
|
|
18312
18857
|
}
|
|
18313
18858
|
if (current)
|
|
@@ -18320,10 +18865,15 @@ var PersonalCodingPlanAccount = class {
|
|
|
18320
18865
|
unavailableReason: entitlement === "unavailable" ? "not-entitled" : "credential-failed"
|
|
18321
18866
|
}
|
|
18322
18867
|
};
|
|
18323
|
-
} catch {
|
|
18868
|
+
} catch (error51) {
|
|
18324
18869
|
current = await readSelection(this.environment, family).catch(() => false);
|
|
18325
|
-
if (current)
|
|
18326
|
-
|
|
18870
|
+
if (current) {
|
|
18871
|
+
if (error51 instanceof ZcodeCredentialError) {
|
|
18872
|
+
this.credentialIssue = `${error51.message} Personal Coding Plan subscription status is unknown.`;
|
|
18873
|
+
this.credentialAccessRequired = error51.code === "credentialAccessRequired";
|
|
18874
|
+
}
|
|
18875
|
+
this.issue = this.credentialIssue ?? "ZCode Personal Coding Plan credentials could not be read or verified. Open the personal plan in ZCode Desktop, then re-detect ZCode; subscription status is unknown.";
|
|
18876
|
+
}
|
|
18327
18877
|
return { availability: "unknown", entitled: false, current };
|
|
18328
18878
|
}
|
|
18329
18879
|
}
|
|
@@ -18348,7 +18898,7 @@ var PersonalCodingPlanAccount = class {
|
|
|
18348
18898
|
signal.throwIfAborted();
|
|
18349
18899
|
const context = await this.#context(providerId, authorized.family);
|
|
18350
18900
|
signal.throwIfAborted();
|
|
18351
|
-
if (!context?.current || context.
|
|
18901
|
+
if (!context?.current || context.account !== authorized.account)
|
|
18352
18902
|
throw new ZcodeError("authenticationRequired", CONNECT);
|
|
18353
18903
|
if (context.project) {
|
|
18354
18904
|
const { expectedAccountScope, rejectedProjectTokenFingerprint } = parsed.data;
|
|
@@ -18357,7 +18907,7 @@ var PersonalCodingPlanAccount = class {
|
|
|
18357
18907
|
const apiKey = await this.#projectToken.resolve(context.project, this.installation.version, signal, rejectedProjectTokenFingerprint);
|
|
18358
18908
|
const after = await this.#context(providerId, authorized.family);
|
|
18359
18909
|
signal.throwIfAborted();
|
|
18360
|
-
if (!after?.current || after.
|
|
18910
|
+
if (!after?.current || after.account !== context.account || JSON.stringify(after.project) !== JSON.stringify(context.project))
|
|
18361
18911
|
throw new ZcodeError("authenticationRequired", CONNECT);
|
|
18362
18912
|
return {
|
|
18363
18913
|
apiKey,
|
|
@@ -18365,7 +18915,7 @@ var PersonalCodingPlanAccount = class {
|
|
|
18365
18915
|
accountScope: context.project.accountScope
|
|
18366
18916
|
};
|
|
18367
18917
|
}
|
|
18368
|
-
if (parsed.data.expectedAccountScope !== void 0 || parsed.data.rejectedProjectTokenFingerprint)
|
|
18918
|
+
if (!context.apiKey || parsed.data.expectedAccountScope !== void 0 || parsed.data.rejectedProjectTokenFingerprint)
|
|
18369
18919
|
throw new ZcodeError("authenticationRequired", CONNECT);
|
|
18370
18920
|
return { apiKey: context.apiKey };
|
|
18371
18921
|
}
|
|
@@ -18392,7 +18942,7 @@ function resolveEndpointOrigin(environment) {
|
|
|
18392
18942
|
}
|
|
18393
18943
|
async function readDeviceMid(installation) {
|
|
18394
18944
|
try {
|
|
18395
|
-
const file2 =
|
|
18945
|
+
const file2 = path6.join(installation.dataRoot, "telemetry-state.json");
|
|
18396
18946
|
const parsed = JSON.parse(await readFile3(file2, "utf8"));
|
|
18397
18947
|
return typeof parsed?.deviceMid === "string" ? parsed.deviceMid.trim() : "";
|
|
18398
18948
|
} catch {
|
|
@@ -18426,9 +18976,9 @@ function resolveStartPlanModels(data, builtinModelIds) {
|
|
|
18426
18976
|
const validPlans = data.plans.filter((plan) => {
|
|
18427
18977
|
if (plan.status?.trim().toLowerCase() !== "active")
|
|
18428
18978
|
return false;
|
|
18429
|
-
const
|
|
18979
|
+
const id2 = plan.plan_id?.trim().toLowerCase();
|
|
18430
18980
|
const name = plan.name?.trim().toLowerCase();
|
|
18431
|
-
const isStart = !
|
|
18981
|
+
const isStart = !id2 && !name || id2?.includes("start-plan") || id2?.includes("start plan") || name?.includes("start-plan") || name?.includes("start plan");
|
|
18432
18982
|
if (!isStart)
|
|
18433
18983
|
return false;
|
|
18434
18984
|
const ends = Number(plan.ends_at);
|
|
@@ -18453,7 +19003,7 @@ function resolveStartPlanModels(data, builtinModelIds) {
|
|
|
18453
19003
|
for (const raw of candidates) {
|
|
18454
19004
|
if (!raw)
|
|
18455
19005
|
continue;
|
|
18456
|
-
const normalized = builtinModelIds?.find((
|
|
19006
|
+
const normalized = builtinModelIds?.find((id2) => id2.toLowerCase() === raw.toLowerCase()) ?? raw;
|
|
18457
19007
|
const key = normalized.toLowerCase();
|
|
18458
19008
|
if (!seen.has(key)) {
|
|
18459
19009
|
seen.add(key);
|
|
@@ -18463,6 +19013,12 @@ function resolveStartPlanModels(data, builtinModelIds) {
|
|
|
18463
19013
|
}
|
|
18464
19014
|
return models;
|
|
18465
19015
|
}
|
|
19016
|
+
var startFamily = (channel) => channel === "zai_cn" ? "bigmodel" : channel;
|
|
19017
|
+
async function readStartJwt(credential, channel) {
|
|
19018
|
+
if (channel === "zai_cn" && !(await readOAuthUserId(credential, channel) && await credential("oauth:zai_cn:access_token")))
|
|
19019
|
+
return "";
|
|
19020
|
+
return credential("zcodejwttoken");
|
|
19021
|
+
}
|
|
18466
19022
|
async function queryStartPlanBalance(origin, appVersion, jwt2, deviceMid) {
|
|
18467
19023
|
try {
|
|
18468
19024
|
const url2 = new URL(`${origin}/api/v1/zcode-plan/billing/balance`);
|
|
@@ -18489,22 +19045,31 @@ async function queryStartPlanBalance(origin, appVersion, jwt2, deviceMid) {
|
|
|
18489
19045
|
return void 0;
|
|
18490
19046
|
}
|
|
18491
19047
|
}
|
|
18492
|
-
async function accountConfig(installation, environment) {
|
|
19048
|
+
async function accountConfig(installation, environment, readSystemKeyOptions) {
|
|
18493
19049
|
const file2 = installation.builtinProviderConfig;
|
|
18494
19050
|
const builtin = builtinSchema.parse(JSON.parse(await readFile3(file2, "utf8")));
|
|
18495
|
-
const basedOnZCodeBuiltinRevision = `zcode-builtin:${builtin.revision}:${createHash4("sha256").update(
|
|
18496
|
-
|
|
19051
|
+
const basedOnZCodeBuiltinRevision = `zcode-builtin:${builtin.revision}:${createHash4("sha256").update(path6.resolve(file2)).digest("hex")}`;
|
|
19052
|
+
let channel;
|
|
19053
|
+
let credentialIssue;
|
|
19054
|
+
let credentialAccessRequired = false;
|
|
18497
19055
|
let balanceData;
|
|
18498
|
-
|
|
18499
|
-
|
|
18500
|
-
|
|
19056
|
+
let credential;
|
|
19057
|
+
try {
|
|
19058
|
+
credential = await readCredentials(installation, environment, void 0, readSystemKeyOptions);
|
|
19059
|
+
channel = await readLoginChannel(credential);
|
|
19060
|
+
if (channel) {
|
|
19061
|
+
const jwt2 = await readStartJwt(credential, channel);
|
|
18501
19062
|
const deviceMid = await readDeviceMid(installation);
|
|
18502
19063
|
if (jwt2 && deviceMid) {
|
|
18503
19064
|
const origin = resolveEndpointOrigin(environment);
|
|
18504
19065
|
balanceData = await queryStartPlanBalance(origin, installation.version, jwt2, deviceMid);
|
|
18505
19066
|
}
|
|
18506
|
-
} catch {
|
|
18507
19067
|
}
|
|
19068
|
+
} catch (error51) {
|
|
19069
|
+
if (!(error51 instanceof ZcodeCredentialError))
|
|
19070
|
+
throw error51;
|
|
19071
|
+
credentialAccessRequired = error51.code === "credentialAccessRequired";
|
|
19072
|
+
credentialIssue = channel ? error51.message : `${error51.message} Personal Coding Plan subscription status is unknown.`;
|
|
18508
19073
|
}
|
|
18509
19074
|
let startPlan = false;
|
|
18510
19075
|
const codingPlan = new PersonalCodingPlanAccount(installation, environment);
|
|
@@ -18512,10 +19077,10 @@ async function accountConfig(installation, environment) {
|
|
|
18512
19077
|
const states = {};
|
|
18513
19078
|
for (const rule of builtin.config.providerConfigRules.providerRules) {
|
|
18514
19079
|
const access = rule.config.access;
|
|
18515
|
-
if (!
|
|
19080
|
+
if (!channel || access?.accountType !== startFamily(channel))
|
|
18516
19081
|
continue;
|
|
18517
|
-
if (access.mode === "individual-coding-plan"
|
|
18518
|
-
const state = await codingPlan.inspect(rule.providerId,
|
|
19082
|
+
if (access.mode === "individual-coding-plan") {
|
|
19083
|
+
const state = await codingPlan.inspect(rule.providerId, access.accountType, credential);
|
|
18519
19084
|
providers[rule.providerId] = {
|
|
18520
19085
|
access: { type: "zhipu-account", entitled: state.entitled }
|
|
18521
19086
|
};
|
|
@@ -18547,19 +19112,22 @@ async function accountConfig(installation, environment) {
|
|
|
18547
19112
|
const overlayDigest = createHash4("sha256").update(JSON.stringify([providers, states])).digest("hex").slice(0, 16);
|
|
18548
19113
|
return {
|
|
18549
19114
|
params: {
|
|
18550
|
-
revision: `codexhost:${
|
|
19115
|
+
revision: `codexhost:${channel ?? (credentialIssue ? "credentials-unavailable" : "signed-out")}:${builtin.revision}:${overlayDigest}`,
|
|
18551
19116
|
basedOnZCodeBuiltinRevision,
|
|
18552
19117
|
providers,
|
|
18553
19118
|
states
|
|
18554
19119
|
},
|
|
18555
19120
|
startPlan,
|
|
18556
|
-
signedIn: Boolean(
|
|
18557
|
-
startPlanChecked: !
|
|
19121
|
+
signedIn: Boolean(channel),
|
|
19122
|
+
startPlanChecked: !credentialIssue && (!channel || balanceData !== void 0),
|
|
19123
|
+
...credentialIssue ? { credentialIssue } : {},
|
|
19124
|
+
credentialAccessRequired,
|
|
18558
19125
|
codingPlan
|
|
18559
19126
|
};
|
|
18560
19127
|
}
|
|
18561
19128
|
async function providerRuntimeHeaders(request, signal, installation, environment, verifier, codingPlan) {
|
|
18562
|
-
const
|
|
19129
|
+
const access = external_exports.object({ mode: external_exports.string(), accountType: external_exports.string().optional() }).safeParse(request.accountAccess).data;
|
|
19130
|
+
const mode = access?.mode;
|
|
18563
19131
|
try {
|
|
18564
19132
|
signal.throwIfAborted();
|
|
18565
19133
|
if (mode === "individual-coding-plan")
|
|
@@ -18569,7 +19137,11 @@ async function providerRuntimeHeaders(request, signal, installation, environment
|
|
|
18569
19137
|
headersApplied: false,
|
|
18570
19138
|
errorMessage: "codexhost supports ZCode Start Plan and Personal Coding Plan; Team Coding Plan is not supported"
|
|
18571
19139
|
};
|
|
18572
|
-
const
|
|
19140
|
+
const credential = await readCredentials(installation, environment);
|
|
19141
|
+
const channel = await readLoginChannel(credential);
|
|
19142
|
+
if (!channel || access?.accountType !== void 0 && access.accountType !== startFamily(channel))
|
|
19143
|
+
return { headersApplied: false, errorMessage: SIGN_IN };
|
|
19144
|
+
const apiKey = await readStartJwt(credential, channel);
|
|
18573
19145
|
if (!apiKey)
|
|
18574
19146
|
return { headersApplied: false, errorMessage: SIGN_IN };
|
|
18575
19147
|
const headers = await verifier().verify(signal);
|
|
@@ -18665,6 +19237,8 @@ var CliTransport = class {
|
|
|
18665
19237
|
#startPlan = false;
|
|
18666
19238
|
#signedIn = false;
|
|
18667
19239
|
#startPlanChecked = true;
|
|
19240
|
+
#credentialIssue;
|
|
19241
|
+
#credentialAccessRequired = false;
|
|
18668
19242
|
#codingPlan;
|
|
18669
19243
|
#fault;
|
|
18670
19244
|
#closed = false;
|
|
@@ -18685,6 +19259,12 @@ var CliTransport = class {
|
|
|
18685
19259
|
get startPlanChecked() {
|
|
18686
19260
|
return this.#startPlanChecked;
|
|
18687
19261
|
}
|
|
19262
|
+
get credentialIssue() {
|
|
19263
|
+
return this.#credentialIssue ?? this.#codingPlan?.credentialIssue;
|
|
19264
|
+
}
|
|
19265
|
+
get credentialAccessRequired() {
|
|
19266
|
+
return this.#credentialAccessRequired || this.#codingPlan?.credentialAccessRequired === true;
|
|
19267
|
+
}
|
|
18688
19268
|
get codingPlanIssue() {
|
|
18689
19269
|
return this.#codingPlan?.issue;
|
|
18690
19270
|
}
|
|
@@ -18699,11 +19279,13 @@ var CliTransport = class {
|
|
|
18699
19279
|
if (this.#child || this.#closed)
|
|
18700
19280
|
throw new ZcodeError("invalidState", "ZCode transport already started or closed");
|
|
18701
19281
|
const installation = await resolveInstallation(this.options.environment, this.options.app);
|
|
18702
|
-
const { params: accountParams, startPlan, signedIn, startPlanChecked, codingPlan } = await accountConfig(installation, this.options.environment);
|
|
19282
|
+
const { params: accountParams, startPlan, signedIn, startPlanChecked, credentialIssue, credentialAccessRequired, codingPlan } = await accountConfig(installation, this.options.environment, this.options.keyOptions);
|
|
18703
19283
|
this.#installation = installation;
|
|
18704
19284
|
this.#startPlan = startPlan;
|
|
18705
19285
|
this.#signedIn = signedIn;
|
|
18706
19286
|
this.#startPlanChecked = startPlanChecked;
|
|
19287
|
+
this.#credentialIssue = credentialIssue;
|
|
19288
|
+
this.#credentialAccessRequired = credentialAccessRequired;
|
|
18707
19289
|
this.#codingPlan = codingPlan;
|
|
18708
19290
|
const child = spawn(installation.runtime, [installation.cli, "app-server", "--stdio", "--surface", "desktop"], {
|
|
18709
19291
|
cwd: this.options.cwd,
|
|
@@ -18810,12 +19392,12 @@ var CliTransport = class {
|
|
|
18810
19392
|
listener(params);
|
|
18811
19393
|
}
|
|
18812
19394
|
#emitSession(sessionId, value) {
|
|
18813
|
-
for (const [listener,
|
|
18814
|
-
if (
|
|
19395
|
+
for (const [listener, id2] of this.#sessionListeners)
|
|
19396
|
+
if (id2 === sessionId)
|
|
18815
19397
|
listener(value);
|
|
18816
19398
|
}
|
|
18817
|
-
async #answer(
|
|
18818
|
-
const reply = (body) => this.#write({ id, ...body });
|
|
19399
|
+
async #answer(id2, method, params) {
|
|
19400
|
+
const reply = (body) => this.#write({ id: id2, ...body });
|
|
18819
19401
|
if (method === "session/requestRuntimePreferences")
|
|
18820
19402
|
reply({ result: RUNTIME_PREFERENCES });
|
|
18821
19403
|
else if (method === "interaction/requestPermission" || method === "interaction/requestUserInput") {
|
|
@@ -18861,11 +19443,11 @@ var CliTransport = class {
|
|
|
18861
19443
|
#call(method, params, timeoutMs) {
|
|
18862
19444
|
if (!this.#child || this.#closed || this.#fault)
|
|
18863
19445
|
return Promise.reject(this.#fault ?? new ZcodeError("invalidState", "ZCode is closed"));
|
|
18864
|
-
const
|
|
19446
|
+
const id2 = ++this.#nextId;
|
|
18865
19447
|
return new Promise((resolve, reject) => {
|
|
18866
19448
|
const timer = setTimeout(() => this.#fail(new ZcodeError("unavailable", "ZCode request timed out; delivery is unconfirmed")), timeoutMs ?? this.options.timeoutMs ?? DEFAULT_TIMEOUT_MS);
|
|
18867
|
-
this.#pending.set(
|
|
18868
|
-
this.#write({ id, method, params });
|
|
19449
|
+
this.#pending.set(id2, { resolve, reject, timer });
|
|
19450
|
+
this.#write({ id: id2, method, params });
|
|
18869
19451
|
});
|
|
18870
19452
|
}
|
|
18871
19453
|
request(method, params = {}) {
|
|
@@ -19559,34 +20141,56 @@ function createZcodeVerifier(options) {
|
|
|
19559
20141
|
};
|
|
19560
20142
|
}
|
|
19561
20143
|
|
|
20144
|
+
// dist/session.js
|
|
20145
|
+
import { randomUUID as randomUUID2 } from "node:crypto";
|
|
20146
|
+
|
|
19562
20147
|
// dist/models.js
|
|
19563
20148
|
var ZCODE_ID = harnessIdSchema.parse("zcode");
|
|
19564
|
-
function
|
|
19565
|
-
return
|
|
19566
|
-
id: `zcode-local-v1.${Buffer.from(JSON.stringify([model2.providerId, model2.modelId])).toString("base64url")}`
|
|
19567
|
-
});
|
|
20149
|
+
function readableId({ providerId, modelId: modelId2 }) {
|
|
20150
|
+
return `${providerId}/${modelId2}`;
|
|
19568
20151
|
}
|
|
19569
|
-
function
|
|
19570
|
-
|
|
19571
|
-
|
|
19572
|
-
|
|
19573
|
-
|
|
19574
|
-
|
|
19575
|
-
|
|
19576
|
-
|
|
19577
|
-
|
|
19578
|
-
|
|
19579
|
-
|
|
19580
|
-
|
|
19581
|
-
|
|
20152
|
+
function legacyId({ providerId, modelId: modelId2 }) {
|
|
20153
|
+
return `zcode-local-v1.${Buffer.from(JSON.stringify([providerId, modelId2])).toString("base64url")}`;
|
|
20154
|
+
}
|
|
20155
|
+
function sameNativeModel(a, b) {
|
|
20156
|
+
return a.providerId === b.providerId && a.modelId === b.modelId;
|
|
20157
|
+
}
|
|
20158
|
+
function modelIndex(models) {
|
|
20159
|
+
const entries = new Map(models.map((entry) => [
|
|
20160
|
+
legacyId(entry.ref),
|
|
20161
|
+
{
|
|
20162
|
+
provider: entry.ref.providerId,
|
|
20163
|
+
model: entry.ref.modelId,
|
|
20164
|
+
entry
|
|
20165
|
+
}
|
|
20166
|
+
]));
|
|
20167
|
+
const ids = compositeModelRefIds([...entries.values()], ({ entry }) => legacyId(entry.ref));
|
|
20168
|
+
const readable = new Set(models.map(({ ref }) => readableId(ref)));
|
|
20169
|
+
const byLegacy = /* @__PURE__ */ new Map();
|
|
20170
|
+
for (const [id2, { entry }] of ids) {
|
|
20171
|
+
byLegacy.set(legacyId(entry.ref), harnessModelRefSchema.parse({ id: id2 }));
|
|
20172
|
+
}
|
|
20173
|
+
const encode3 = (model2) => {
|
|
20174
|
+
const id2 = readableId(model2);
|
|
20175
|
+
return byLegacy.get(legacyId(model2)) ?? harnessModelRefSchema.parse({
|
|
20176
|
+
id: readable.has(id2) ? legacyId(model2) : id2
|
|
20177
|
+
});
|
|
20178
|
+
};
|
|
20179
|
+
return { encode: encode3, ids, byLegacy };
|
|
20180
|
+
}
|
|
20181
|
+
function encodeModel(model2, index) {
|
|
20182
|
+
return index?.encode(model2) ?? harnessModelRefSchema.parse({ id: readableId(model2) });
|
|
19582
20183
|
}
|
|
19583
|
-
function
|
|
19584
|
-
|
|
19585
|
-
|
|
20184
|
+
function normalizeStoredZcodeModelRef(ref, index) {
|
|
20185
|
+
return ref.serviceTier ? void 0 : index.byLegacy.get(ref.id);
|
|
20186
|
+
}
|
|
20187
|
+
function selectNativeModel(model2, index, current, thinkingOption) {
|
|
20188
|
+
const entry = !model2.serviceTier && index.ids.get(model2.id)?.entry;
|
|
19586
20189
|
if (!entry)
|
|
19587
20190
|
throw new ZcodeError("invalidRequest", "ZCode model is not available");
|
|
19588
|
-
const
|
|
19589
|
-
const
|
|
20191
|
+
const { providerId, modelId: modelId2 } = entry.ref;
|
|
20192
|
+
const native = { providerId, modelId: modelId2 };
|
|
20193
|
+
const level = thinkingOption ?? (current && sameNativeModel(current, native) ? current.options?.reasoningLevel : void 0) ?? entry.reasoning?.defaultLevel;
|
|
19590
20194
|
if (level === void 0)
|
|
19591
20195
|
return native;
|
|
19592
20196
|
if (!entry.reasoning?.levels.some((option) => option.value === level))
|
|
@@ -19599,18 +20203,20 @@ function modelCatalog(settings) {
|
|
|
19599
20203
|
for (const model2 of available)
|
|
19600
20204
|
for (const level of model2.reasoning?.levels ?? [])
|
|
19601
20205
|
levels.set(level.value, level);
|
|
19602
|
-
const
|
|
20206
|
+
const index = modelIndex(available);
|
|
20207
|
+
const current = settings.model.current ? index.encode(settings.model.current) : void 0;
|
|
19603
20208
|
const defaultThinking = settings.thoughtLevel.current ?? settings.thoughtLevel.defaultLevel;
|
|
19604
|
-
|
|
20209
|
+
const catalog = harnessModelCatalogSchema.parse({
|
|
19605
20210
|
models: available.map((model2) => ({
|
|
19606
|
-
ref:
|
|
20211
|
+
ref: index.encode(model2.ref),
|
|
19607
20212
|
label: model2.label,
|
|
19608
20213
|
supportedThinkingOptionIds: model2.reasoning?.enabled ? model2.reasoning.levels.map((level) => level.value) : []
|
|
19609
20214
|
})),
|
|
19610
|
-
...current &&
|
|
20215
|
+
...current && index.ids.has(current.id) ? { defaultModel: current } : {},
|
|
19611
20216
|
thinkingOptions: [...levels.values()].map((level) => ({ id: level.value, label: level.label })),
|
|
19612
20217
|
...defaultThinking && levels.has(defaultThinking) ? { defaultThinkingOptionId: defaultThinking } : {}
|
|
19613
20218
|
});
|
|
20219
|
+
return { catalog, index };
|
|
19614
20220
|
}
|
|
19615
20221
|
var modeLabels = {
|
|
19616
20222
|
build: "Confirm changes",
|
|
@@ -19628,19 +20234,20 @@ var chineseModeLabels = {
|
|
|
19628
20234
|
};
|
|
19629
20235
|
function permissionModes(current = "build") {
|
|
19630
20236
|
return harnessPermissionModeCatalogSchema.parse({
|
|
19631
|
-
modes: Object.entries(modeLabels).map(([
|
|
19632
|
-
id,
|
|
20237
|
+
modes: Object.entries(modeLabels).map(([id2, label]) => ({
|
|
20238
|
+
id: id2,
|
|
19633
20239
|
label,
|
|
19634
|
-
localizations: { "zh-CN": { label: chineseModeLabels[
|
|
19635
|
-
...
|
|
20240
|
+
localizations: { "zh-CN": { label: chineseModeLabels[id2] } },
|
|
20241
|
+
...id2 === "yolo" ? { dangerous: true } : {}
|
|
19636
20242
|
})),
|
|
19637
20243
|
defaultModeId: current
|
|
19638
20244
|
});
|
|
19639
20245
|
}
|
|
19640
|
-
function sessionState(snapshot, locator) {
|
|
20246
|
+
function sessionState(snapshot, locator, index = modelCatalog(snapshot.settings).index) {
|
|
19641
20247
|
const settings = snapshot.settings;
|
|
19642
|
-
const
|
|
19643
|
-
const
|
|
20248
|
+
const native = settings.model.current;
|
|
20249
|
+
const current = native ? encodeModel(native, index) : void 0;
|
|
20250
|
+
const model2 = native && settings.model.available.find((candidate) => sameNativeModel(candidate.ref, native));
|
|
19644
20251
|
return {
|
|
19645
20252
|
nativeRef: nativeSessionRefSchema.parse({
|
|
19646
20253
|
harnessId: ZCODE_ID,
|
|
@@ -19679,9 +20286,6 @@ function sessionUsage(snapshot, catalog) {
|
|
|
19679
20286
|
return Object.keys(usage).length > 0 ? parseHostUsage(usage) : null;
|
|
19680
20287
|
}
|
|
19681
20288
|
|
|
19682
|
-
// dist/session.js
|
|
19683
|
-
import { randomUUID as randomUUID2 } from "node:crypto";
|
|
19684
|
-
|
|
19685
20289
|
// ../../../node_modules/diff/libesm/diff/base.js
|
|
19686
20290
|
var Diff = class {
|
|
19687
20291
|
diff(oldStr, newStr, options = {}) {
|
|
@@ -19782,16 +20386,16 @@ var Diff = class {
|
|
|
19782
20386
|
}
|
|
19783
20387
|
}
|
|
19784
20388
|
}
|
|
19785
|
-
addToPath(
|
|
19786
|
-
const last =
|
|
20389
|
+
addToPath(path8, added, removed, oldPosInc, options) {
|
|
20390
|
+
const last = path8.lastComponent;
|
|
19787
20391
|
if (last && !options.oneChangePerToken && last.added === added && last.removed === removed) {
|
|
19788
20392
|
return {
|
|
19789
|
-
oldPos:
|
|
20393
|
+
oldPos: path8.oldPos + oldPosInc,
|
|
19790
20394
|
lastComponent: { count: last.count + 1, added, removed, previousComponent: last.previousComponent }
|
|
19791
20395
|
};
|
|
19792
20396
|
} else {
|
|
19793
20397
|
return {
|
|
19794
|
-
oldPos:
|
|
20398
|
+
oldPos: path8.oldPos + oldPosInc,
|
|
19795
20399
|
lastComponent: { count: 1, added, removed, previousComponent: last }
|
|
19796
20400
|
};
|
|
19797
20401
|
}
|
|
@@ -20119,15 +20723,15 @@ function toolOutput(value) {
|
|
|
20119
20723
|
function fileChanges(value) {
|
|
20120
20724
|
const result = record2(value), nested = record2(result.data);
|
|
20121
20725
|
const data = typeof result.filePath === "string" ? result : nested;
|
|
20122
|
-
const
|
|
20123
|
-
if (!
|
|
20726
|
+
const filePath2 = text(data.filePath);
|
|
20727
|
+
if (!filePath2)
|
|
20124
20728
|
return [];
|
|
20125
20729
|
if ((typeof data.originalFile === "string" || data.originalFile === null) && typeof data.content === "string") {
|
|
20126
|
-
const diff = createPatch(
|
|
20730
|
+
const diff = createPatch(filePath2, data.originalFile ?? "", data.content);
|
|
20127
20731
|
if (diff.length > OUTPUT_LIMIT)
|
|
20128
20732
|
return [];
|
|
20129
20733
|
return [
|
|
20130
|
-
{ path:
|
|
20734
|
+
{ path: filePath2, kind: data.originalFile === null ? "add" : "update", unifiedDiff: diff }
|
|
20131
20735
|
];
|
|
20132
20736
|
}
|
|
20133
20737
|
if (Array.isArray(data.structuredPatch)) {
|
|
@@ -20135,26 +20739,26 @@ function fileChanges(value) {
|
|
|
20135
20739
|
if (!hunks.every((hunk) => typeof hunk.oldStart === "number" && typeof hunk.oldLines === "number" && typeof hunk.newStart === "number" && typeof hunk.newLines === "number" && Array.isArray(hunk.lines) && hunk.lines.every((line) => typeof line === "string")))
|
|
20136
20740
|
return [];
|
|
20137
20741
|
const diff = [
|
|
20138
|
-
`--- a/${
|
|
20139
|
-
`+++ b/${
|
|
20742
|
+
`--- a/${filePath2}`,
|
|
20743
|
+
`+++ b/${filePath2}`,
|
|
20140
20744
|
...hunks.flatMap((hunk) => [
|
|
20141
20745
|
`@@ -${hunk.oldStart},${hunk.oldLines} +${hunk.newStart},${hunk.newLines} @@`,
|
|
20142
20746
|
...hunk.lines
|
|
20143
20747
|
])
|
|
20144
20748
|
].join("\n") + "\n";
|
|
20145
|
-
return diff.length <= OUTPUT_LIMIT ? [{ path:
|
|
20749
|
+
return diff.length <= OUTPUT_LIMIT ? [{ path: filePath2, kind: data.originalFile === null ? "add" : "update", unifiedDiff: diff }] : [];
|
|
20146
20750
|
}
|
|
20147
20751
|
return [];
|
|
20148
20752
|
}
|
|
20149
20753
|
function subagent(value, input, fallback) {
|
|
20150
20754
|
const result = record2(value), data = record2(result.data), args = record2(input);
|
|
20151
|
-
const
|
|
20152
|
-
if (!
|
|
20755
|
+
const id2 = text(result.childSessionId) || text(data.childSessionId) || text(result.agentId) || text(data.agentId);
|
|
20756
|
+
if (!id2)
|
|
20153
20757
|
return;
|
|
20154
20758
|
const status = text(result.status) || text(data.status);
|
|
20155
20759
|
return {
|
|
20156
|
-
subagentId:
|
|
20157
|
-
nativeSubagentId:
|
|
20760
|
+
subagentId: id2,
|
|
20761
|
+
nativeSubagentId: id2,
|
|
20158
20762
|
description: text(args.description) || text(args.prompt) || fallback,
|
|
20159
20763
|
...text(args.subagent_type) || text(args.agentType) ? { role: text(args.subagent_type) || text(args.agentType) } : {},
|
|
20160
20764
|
...subagentConfiguration(args),
|
|
@@ -20165,8 +20769,8 @@ function subagent(value, input, fallback) {
|
|
|
20165
20769
|
...text(result.output) ? { resultSummary: text(result.output).slice(0, OUTPUT_LIMIT) } : {}
|
|
20166
20770
|
};
|
|
20167
20771
|
}
|
|
20168
|
-
function makeTool(
|
|
20169
|
-
const itemId = hostItemIdSchema.parse(
|
|
20772
|
+
function makeTool(id2, name, input, cwd) {
|
|
20773
|
+
const itemId = hostItemIdSchema.parse(id2), args = record2(input);
|
|
20170
20774
|
if (name.toLowerCase() === "bash")
|
|
20171
20775
|
return { type: "commandExecution", itemId, command: text(args.command), cwd };
|
|
20172
20776
|
return {
|
|
@@ -20289,21 +20893,21 @@ var TurnProjection = class {
|
|
|
20289
20893
|
}
|
|
20290
20894
|
if (!kind.startsWith("text_") && !reasoning)
|
|
20291
20895
|
return;
|
|
20292
|
-
let
|
|
20293
|
-
if (kind.endsWith("_start") || !
|
|
20294
|
-
|
|
20896
|
+
let id3 = text(p.partId) || (text(p.assistantMessageId) ? `stream:${text(p.assistantMessageId)}:${reasoning ? "reasoning" : "text"}` : reasoning ? this.#reasoningId : this.#textId);
|
|
20897
|
+
if (kind.endsWith("_start") || !id3 || !this.items.has(id3)) {
|
|
20898
|
+
id3 ||= `stream:${this.turnId}:${++this.#streamNumber}`;
|
|
20295
20899
|
if (reasoning)
|
|
20296
|
-
this.#reasoningId =
|
|
20900
|
+
this.#reasoningId = id3;
|
|
20297
20901
|
else
|
|
20298
|
-
this.#textId =
|
|
20902
|
+
this.#textId = id3;
|
|
20299
20903
|
this.start({
|
|
20300
20904
|
type: reasoning ? "reasoning" : "agentMessage",
|
|
20301
|
-
itemId: hostItemIdSchema.parse(
|
|
20905
|
+
itemId: hostItemIdSchema.parse(id3),
|
|
20302
20906
|
text: ""
|
|
20303
20907
|
});
|
|
20304
20908
|
}
|
|
20305
|
-
const item2 = this.items.get(
|
|
20306
|
-
if (!item2 || this.completed.has(
|
|
20909
|
+
const item2 = this.items.get(id3);
|
|
20910
|
+
if (!item2 || this.completed.has(id3) || item2.type !== "agentMessage" && item2.type !== "reasoning")
|
|
20307
20911
|
return;
|
|
20308
20912
|
if (typeof p.delta === "string" && p.delta) {
|
|
20309
20913
|
item2.text += p.delta;
|
|
@@ -20324,7 +20928,7 @@ var TurnProjection = class {
|
|
|
20324
20928
|
return;
|
|
20325
20929
|
}
|
|
20326
20930
|
if (event.type === "session.updated" && text(p.childSessionId) && text(p.parentToolCallId)) {
|
|
20327
|
-
const
|
|
20931
|
+
const id3 = `${text(p.parentToolCallId)}:agent`, existing = this.items.get(id3);
|
|
20328
20932
|
const child2 = subagent(p, p, text(p.agentType));
|
|
20329
20933
|
if (!child2)
|
|
20330
20934
|
return;
|
|
@@ -20348,7 +20952,7 @@ var TurnProjection = class {
|
|
|
20348
20952
|
} else
|
|
20349
20953
|
this.start({
|
|
20350
20954
|
type: "subagentDelegation",
|
|
20351
|
-
itemId: hostItemIdSchema.parse(
|
|
20955
|
+
itemId: hostItemIdSchema.parse(id3),
|
|
20352
20956
|
operation: "spawn",
|
|
20353
20957
|
prompt: text(p.prompt),
|
|
20354
20958
|
subagents: [child2]
|
|
@@ -20368,15 +20972,15 @@ var TurnProjection = class {
|
|
|
20368
20972
|
}
|
|
20369
20973
|
if (event.type !== "tool.updated" || p.source === "subagent")
|
|
20370
20974
|
return;
|
|
20371
|
-
const
|
|
20372
|
-
if (!
|
|
20975
|
+
const id2 = text(p.toolCallId);
|
|
20976
|
+
if (!id2)
|
|
20373
20977
|
return;
|
|
20374
20978
|
if (p.kind === "scheduled") {
|
|
20375
|
-
this.start(makeTool(
|
|
20979
|
+
this.start(makeTool(id2, text(p.toolName), p.input, this.cwd));
|
|
20376
20980
|
return;
|
|
20377
20981
|
}
|
|
20378
|
-
const item = this.items.get(
|
|
20379
|
-
if (!item || this.completed.has(
|
|
20982
|
+
const item = this.items.get(id2);
|
|
20983
|
+
if (!item || this.completed.has(id2))
|
|
20380
20984
|
return;
|
|
20381
20985
|
if (p.kind === "progress" && item.type === "commandExecution") {
|
|
20382
20986
|
const next = (text(p.stdoutTail) + text(p.stderrTail)).slice(-OUTPUT_LIMIT);
|
|
@@ -20425,7 +21029,7 @@ var TurnProjection = class {
|
|
|
20425
21029
|
this.complete({
|
|
20426
21030
|
item: {
|
|
20427
21031
|
type: "fileChange",
|
|
20428
|
-
itemId: hostItemIdSchema.parse(`${
|
|
21032
|
+
itemId: hostItemIdSchema.parse(`${id2}:files`),
|
|
20429
21033
|
changes,
|
|
20430
21034
|
sourceItemIds: [item.itemId]
|
|
20431
21035
|
},
|
|
@@ -20436,7 +21040,7 @@ var TurnProjection = class {
|
|
|
20436
21040
|
this.complete({
|
|
20437
21041
|
item: {
|
|
20438
21042
|
type: "subagentDelegation",
|
|
20439
|
-
itemId: hostItemIdSchema.parse(`${
|
|
21043
|
+
itemId: hostItemIdSchema.parse(`${id2}:agent`),
|
|
20440
21044
|
operation: "spawn",
|
|
20441
21045
|
subagents: [child]
|
|
20442
21046
|
},
|
|
@@ -20518,7 +21122,7 @@ function messageOutcome(message) {
|
|
|
20518
21122
|
return { status: "succeeded" };
|
|
20519
21123
|
return { status: "unknown", reason: "The persisted ZCode turn has no terminal result" };
|
|
20520
21124
|
}
|
|
20521
|
-
function history(snapshot, events = [], locator) {
|
|
21125
|
+
function history(snapshot, events = [], locator, index = modelCatalog(snapshot.settings).index) {
|
|
20522
21126
|
const outcomes = /* @__PURE__ */ new Map();
|
|
20523
21127
|
const nativeKeys = /* @__PURE__ */ new Map();
|
|
20524
21128
|
for (const event of events) {
|
|
@@ -20549,7 +21153,7 @@ function history(snapshot, events = [], locator) {
|
|
|
20549
21153
|
items: assistants.flatMap((message) => message.parts.flatMap((part) => projectPart(part, snapshot.session.workspace.workspacePath))),
|
|
20550
21154
|
outcome,
|
|
20551
21155
|
...user.info.model ? {
|
|
20552
|
-
model: encodeModel(user.info.model)
|
|
21156
|
+
model: encodeModel(user.info.model, index)
|
|
20553
21157
|
} : {},
|
|
20554
21158
|
startedAtMs: user.info.time.created,
|
|
20555
21159
|
...completedAtMs !== void 0 ? { completedAtMs } : {}
|
|
@@ -20565,7 +21169,7 @@ function history(snapshot, events = [], locator) {
|
|
|
20565
21169
|
current.assistants.push(message);
|
|
20566
21170
|
}
|
|
20567
21171
|
finish();
|
|
20568
|
-
return { turns, state: sessionState(snapshot, locator) };
|
|
21172
|
+
return { turns, state: sessionState(snapshot, locator, index) };
|
|
20569
21173
|
}
|
|
20570
21174
|
|
|
20571
21175
|
// dist/interactions.js
|
|
@@ -20732,7 +21336,7 @@ async function withConversation(transport, source, work) {
|
|
|
20732
21336
|
rows.unshift(...incoming);
|
|
20733
21337
|
if (batch.hasMore !== true)
|
|
20734
21338
|
return await work({ ...state, rows });
|
|
20735
|
-
const next = incoming.map((row) => row.rowId).filter((
|
|
21339
|
+
const next = incoming.map((row) => row.rowId).filter((id2) => typeof id2 === "number").sort((a, b) => a - b)[0];
|
|
20736
21340
|
if (next === void 0 || next === beforeRowId)
|
|
20737
21341
|
break;
|
|
20738
21342
|
beforeRowId = next;
|
|
@@ -20747,8 +21351,8 @@ async function withConversation(transport, source, work) {
|
|
|
20747
21351
|
}
|
|
20748
21352
|
|
|
20749
21353
|
// dist/read-history.js
|
|
20750
|
-
async function readHistory(transport, snapshot, events = []) {
|
|
20751
|
-
const result = history(snapshot, events, transport.locator);
|
|
21354
|
+
async function readHistory(transport, snapshot, index, events = []) {
|
|
21355
|
+
const result = history(snapshot, events, transport.locator, index);
|
|
20752
21356
|
const tools = result.turns.flatMap((turn) => turn.items).filter(({ item }) => item.type === "toolExecution");
|
|
20753
21357
|
if (tools.some(({ item }) => item.type === "toolExecution" && ["Write", "Edit", "MultiEdit"].includes(item.toolName))) {
|
|
20754
21358
|
await withConversation(transport, snapshot, async (view) => {
|
|
@@ -20867,18 +21471,18 @@ var ZcodeSession = class {
|
|
|
20867
21471
|
#lastSeq = 0;
|
|
20868
21472
|
#closePromise;
|
|
20869
21473
|
#terminalTask;
|
|
20870
|
-
|
|
21474
|
+
#models;
|
|
20871
21475
|
constructor(transport, snapshot, onClose, nativeCatalog = snapshot.settings, isLocked = () => false) {
|
|
20872
21476
|
this.transport = transport;
|
|
20873
21477
|
this.onClose = onClose;
|
|
20874
21478
|
this.nativeCatalog = nativeCatalog;
|
|
20875
21479
|
this.isLocked = isLocked;
|
|
20876
21480
|
this.capabilities = ZCODE_CAPABILITIES;
|
|
20877
|
-
this
|
|
21481
|
+
this.#models = modelCatalog(nativeCatalog);
|
|
20878
21482
|
this.#snapshot = snapshot;
|
|
20879
21483
|
this.#usage = new ZcodeUsage(snapshot.session.sessionId, (event) => this.#emit(event));
|
|
20880
21484
|
this.#goalActive = (snapshot.target === void 0 ? snapshot.projection.target : snapshot.target)?.status === "active";
|
|
20881
|
-
this.#state = sessionState(snapshot, transport.locator);
|
|
21485
|
+
this.#state = sessionState(snapshot, transport.locator, this.#models.index);
|
|
20882
21486
|
this.initialState = structuredClone(this.#state);
|
|
20883
21487
|
this.initialUsage = sessionUsage(snapshot, nativeCatalog);
|
|
20884
21488
|
this.#lastSeq = typeof snapshot.runtime.eventSeq === "number" ? snapshot.runtime.eventSeq : 0;
|
|
@@ -20960,7 +21564,7 @@ var ZcodeSession = class {
|
|
|
20960
21564
|
throw new ZcodeError("protocolError", "ZCode changed the native session identity");
|
|
20961
21565
|
this.#snapshot = snapshot;
|
|
20962
21566
|
this.#goalActive = (snapshot.target === void 0 ? snapshot.projection.target : snapshot.target)?.status === "active";
|
|
20963
|
-
this.#state = sessionState(snapshot, this.transport.locator);
|
|
21567
|
+
this.#state = sessionState(snapshot, this.transport.locator, this.#models.index);
|
|
20964
21568
|
this.#emit({ type: "session.state.changed", state: structuredClone(this.#state) });
|
|
20965
21569
|
}
|
|
20966
21570
|
async refreshUsage() {
|
|
@@ -20988,7 +21592,7 @@ var ZcodeSession = class {
|
|
|
20988
21592
|
}
|
|
20989
21593
|
#subagentConfiguration() {
|
|
20990
21594
|
const state = this.#state;
|
|
20991
|
-
const model2 = state.effectiveModel ?
|
|
21595
|
+
const model2 = state.effectiveModel ? this.#snapshot.settings.model.current?.modelId : void 0;
|
|
20992
21596
|
return {
|
|
20993
21597
|
...model2 ? { model: model2 } : {},
|
|
20994
21598
|
...state.effectiveThinkingOptionId ? { reasoningEffort: state.effectiveThinkingOptionId } : {}
|
|
@@ -21006,7 +21610,7 @@ var ZcodeSession = class {
|
|
|
21006
21610
|
try {
|
|
21007
21611
|
const snapshot = await this.#readNative();
|
|
21008
21612
|
this.#apply(snapshot);
|
|
21009
|
-
return { ok: true, value: await readHistory(this.transport, snapshot) };
|
|
21613
|
+
return { ok: true, value: await readHistory(this.transport, snapshot, this.#models.index) };
|
|
21010
21614
|
} catch (error51) {
|
|
21011
21615
|
return { ok: false, error: nativeError(error51) };
|
|
21012
21616
|
}
|
|
@@ -21053,17 +21657,9 @@ var ZcodeSession = class {
|
|
|
21053
21657
|
try {
|
|
21054
21658
|
let method, params;
|
|
21055
21659
|
if (command.type === "model.select") {
|
|
21056
|
-
if (!this.catalog.models.some((model2) => model2.ref.id === command.model.id))
|
|
21057
|
-
return failure("invalidRequest", "ZCode model is not available");
|
|
21058
21660
|
method = "setModel";
|
|
21059
21661
|
params = {
|
|
21060
|
-
model: selectNativeModel(command.model,
|
|
21061
|
-
...this.#snapshot.settings,
|
|
21062
|
-
model: {
|
|
21063
|
-
...this.#snapshot.settings.model,
|
|
21064
|
-
available: this.nativeCatalog.model.available
|
|
21065
|
-
}
|
|
21066
|
-
}),
|
|
21662
|
+
model: selectNativeModel(command.model, this.#models.index, this.#snapshot.settings.model.current),
|
|
21067
21663
|
persistAsWorkspaceLastUsed: false
|
|
21068
21664
|
};
|
|
21069
21665
|
} else if (command.type === "thinking.select") {
|
|
@@ -21103,51 +21699,51 @@ var ZcodeSession = class {
|
|
|
21103
21699
|
return { ok: false, error: nativeError(error51) };
|
|
21104
21700
|
}
|
|
21105
21701
|
}
|
|
21106
|
-
async #start(
|
|
21702
|
+
async #start(id2, method, params) {
|
|
21107
21703
|
if (this.busy)
|
|
21108
21704
|
return failure("sessionBusy", "ZCode already has an active operation", true);
|
|
21109
21705
|
const previousGoalActive = this.#goalActive;
|
|
21110
21706
|
if (method === "goalSession" && ["set", "replace", "resume"].includes(text(params.action)))
|
|
21111
21707
|
this.#goalActive = true;
|
|
21112
|
-
const
|
|
21113
|
-
id,
|
|
21708
|
+
const active2 = {
|
|
21709
|
+
id: id2,
|
|
21114
21710
|
accepted: false,
|
|
21115
21711
|
pending: [],
|
|
21116
21712
|
finishing: false,
|
|
21117
|
-
projection: new TurnProjection(
|
|
21713
|
+
projection: new TurnProjection(id2, this.transport.options.cwd, (event) => this.#emit(event))
|
|
21118
21714
|
};
|
|
21119
|
-
this.#active =
|
|
21715
|
+
this.#active = active2;
|
|
21120
21716
|
let result;
|
|
21121
21717
|
try {
|
|
21122
|
-
result = record2(method === "sendText" ? await this.transport.command(this.sessionId, "sendText", params,
|
|
21718
|
+
result = record2(method === "sendText" ? await this.transport.command(this.sessionId, "sendText", params, id2) : await this.transport.request(method, { sessionId: this.sessionId, ...params }));
|
|
21123
21719
|
} catch (error51) {
|
|
21124
|
-
if (this.#active ===
|
|
21720
|
+
if (this.#active === active2)
|
|
21125
21721
|
this.#active = void 0;
|
|
21126
21722
|
this.#goalActive = previousGoalActive;
|
|
21127
21723
|
throw error51;
|
|
21128
21724
|
}
|
|
21129
21725
|
if (this.#closed || this.#faulted)
|
|
21130
21726
|
return failure("invalidState", "ZCode closed before confirming the turn");
|
|
21131
|
-
|
|
21132
|
-
this.#emit({ type: "turn.started", turnId:
|
|
21133
|
-
for (const message of
|
|
21727
|
+
active2.accepted = true;
|
|
21728
|
+
this.#emit({ type: "turn.started", turnId: id2 });
|
|
21729
|
+
for (const message of active2.pending.splice(0))
|
|
21134
21730
|
this.#message(message);
|
|
21135
21731
|
if (method === "goalSession" && result.startedTurn !== true) {
|
|
21136
21732
|
const response = text(result.response);
|
|
21137
21733
|
if (response)
|
|
21138
|
-
|
|
21734
|
+
active2.projection.complete({
|
|
21139
21735
|
item: {
|
|
21140
21736
|
type: "agentMessage",
|
|
21141
|
-
itemId: hostItemIdSchema.parse(`command:${
|
|
21737
|
+
itemId: hostItemIdSchema.parse(`command:${id2}`),
|
|
21142
21738
|
text: response
|
|
21143
21739
|
},
|
|
21144
21740
|
outcome: { status: "succeeded" }
|
|
21145
21741
|
});
|
|
21146
21742
|
if (result.snapshot)
|
|
21147
21743
|
this.#apply(snapshotSchema.parse(result.snapshot));
|
|
21148
|
-
this.#finish(
|
|
21744
|
+
this.#finish(active2, { status: "succeeded" });
|
|
21149
21745
|
}
|
|
21150
|
-
return { ok: true, value: { turnId:
|
|
21746
|
+
return { ok: true, value: { turnId: id2 } };
|
|
21151
21747
|
}
|
|
21152
21748
|
#message(message) {
|
|
21153
21749
|
if (this.#closed || this.#faulted)
|
|
@@ -21199,17 +21795,17 @@ var ZcodeSession = class {
|
|
|
21199
21795
|
if (this.#active?.terminal && this.#active.nativeId !== event.turnId)
|
|
21200
21796
|
this.#finish(this.#active, eventOutcome(this.#active.terminal));
|
|
21201
21797
|
if (!this.#active) {
|
|
21202
|
-
const
|
|
21798
|
+
const id2 = hostTurnIdSchema.parse(`zcode-autonomous-${randomUUID2()}`);
|
|
21203
21799
|
this.#active = {
|
|
21204
|
-
id,
|
|
21800
|
+
id: id2,
|
|
21205
21801
|
accepted: true,
|
|
21206
21802
|
pending: [],
|
|
21207
21803
|
finishing: false,
|
|
21208
|
-
projection: new TurnProjection(
|
|
21804
|
+
projection: new TurnProjection(id2, this.transport.options.cwd, (event2) => this.#emit(event2))
|
|
21209
21805
|
};
|
|
21210
21806
|
this.#emit({
|
|
21211
21807
|
type: "turn.autonomous.started",
|
|
21212
|
-
turnId:
|
|
21808
|
+
turnId: id2,
|
|
21213
21809
|
input: text(event.payload?.input) ? [{ type: "text", text: text(event.payload?.input) }] : []
|
|
21214
21810
|
});
|
|
21215
21811
|
}
|
|
@@ -21229,35 +21825,35 @@ var ZcodeSession = class {
|
|
|
21229
21825
|
nativeSubagentId: p2.childSessionId
|
|
21230
21826
|
});
|
|
21231
21827
|
}
|
|
21232
|
-
const
|
|
21233
|
-
if (!
|
|
21828
|
+
const active2 = this.#active;
|
|
21829
|
+
if (!active2 || event.turnId && active2.nativeId && event.turnId !== active2.nativeId)
|
|
21234
21830
|
return;
|
|
21235
21831
|
if (event.type === "permission.resolved" || event.type === "userInput.resolved") {
|
|
21236
|
-
const
|
|
21237
|
-
this.#closeInteraction(
|
|
21832
|
+
const id2 = `zcode:${text(event.payload?.requestId)}`;
|
|
21833
|
+
this.#closeInteraction(id2, "superseded");
|
|
21238
21834
|
}
|
|
21239
21835
|
if (event.type === "turn.completed" || event.type === "turn.failed") {
|
|
21240
|
-
|
|
21836
|
+
active2.terminal = event;
|
|
21241
21837
|
if (!this.#goalActive)
|
|
21242
|
-
|
|
21243
|
-
} else if (!
|
|
21244
|
-
|
|
21838
|
+
active2.timer = setTimeout(() => this.#fault(new ZcodeError("unavailable", "ZCode did not confirm that the turn stopped")), this.transport.options.timeoutMs ?? 3e4);
|
|
21839
|
+
} else if (!active2.terminal)
|
|
21840
|
+
active2.projection.event(event);
|
|
21245
21841
|
}
|
|
21246
|
-
#settle(
|
|
21247
|
-
if (
|
|
21842
|
+
#settle(active2, reason) {
|
|
21843
|
+
if (active2.finishing)
|
|
21248
21844
|
return;
|
|
21249
|
-
|
|
21845
|
+
active2.finishing = true;
|
|
21250
21846
|
this.#terminalTask = (async () => {
|
|
21251
21847
|
const snapshot = await this.#readNative();
|
|
21252
|
-
if (this.#active !==
|
|
21848
|
+
if (this.#active !== active2 || this.#closed || this.#faulted)
|
|
21253
21849
|
return;
|
|
21254
|
-
const turns = (await readHistory(this.transport, snapshot,
|
|
21255
|
-
const turn = turns.find((turn2) => turn2.nativeTurnRef.nativeTurnKey ===
|
|
21850
|
+
const turns = (await readHistory(this.transport, snapshot, this.#models.index, active2.terminal ? [active2.terminal] : [])).turns;
|
|
21851
|
+
const turn = turns.find((turn2) => turn2.nativeTurnRef.nativeTurnKey === active2.messageId);
|
|
21256
21852
|
if (turn)
|
|
21257
|
-
|
|
21853
|
+
active2.projection.reconcile(turn.items);
|
|
21258
21854
|
this.#apply(snapshot);
|
|
21259
|
-
const cancelledBeforeTurnStarted = !
|
|
21260
|
-
const outcome =
|
|
21855
|
+
const cancelledBeforeTurnStarted = !active2.nativeId && await active2.cancellation;
|
|
21856
|
+
const outcome = active2.terminal ? eventOutcome(active2.terminal) : turn?.outcome.status === "cancelled" ? turn.outcome : cancelledBeforeTurnStarted ? { status: "cancelled" } : reason === "session_compacted" ? { status: "succeeded" } : reason === "session_compact_cancelled" ? { status: "cancelled" } : reason.endsWith("failed") ? {
|
|
21261
21857
|
status: "failed",
|
|
21262
21858
|
error: {
|
|
21263
21859
|
code: "nativeFailure",
|
|
@@ -21267,21 +21863,21 @@ var ZcodeSession = class {
|
|
|
21267
21863
|
} : turn?.outcome;
|
|
21268
21864
|
if (!outcome || outcome.status === "unknown")
|
|
21269
21865
|
throw new ZcodeError("protocolError", "ZCode completed without a confirmed turn outcome");
|
|
21270
|
-
if (this.#active !==
|
|
21866
|
+
if (this.#active !== active2 || this.#closed || this.#faulted)
|
|
21271
21867
|
return;
|
|
21272
21868
|
this.#usage.replay(snapshot.messages, false);
|
|
21273
|
-
this.#finish(
|
|
21869
|
+
this.#finish(active2, {
|
|
21274
21870
|
...outcome,
|
|
21275
21871
|
...turn?.checkpoint ? { checkpoint: turn.checkpoint } : {}
|
|
21276
21872
|
});
|
|
21277
21873
|
await this.refreshUsage();
|
|
21278
21874
|
})().catch((error51) => this.#fault(error51));
|
|
21279
21875
|
}
|
|
21280
|
-
#closeInteraction(
|
|
21281
|
-
const pending = this.#pendingInteractions.get(
|
|
21876
|
+
#closeInteraction(id2, reason) {
|
|
21877
|
+
const pending = this.#pendingInteractions.get(id2);
|
|
21282
21878
|
if (!pending)
|
|
21283
21879
|
return;
|
|
21284
|
-
this.#pendingInteractions.delete(
|
|
21880
|
+
this.#pendingInteractions.delete(id2);
|
|
21285
21881
|
this.#emit({
|
|
21286
21882
|
type: "interaction.closed",
|
|
21287
21883
|
interactionId: pending.interaction.interactionId,
|
|
@@ -21289,21 +21885,21 @@ var ZcodeSession = class {
|
|
|
21289
21885
|
reason
|
|
21290
21886
|
});
|
|
21291
21887
|
}
|
|
21292
|
-
#finish(
|
|
21293
|
-
if (this.#active !==
|
|
21888
|
+
#finish(active2, outcome) {
|
|
21889
|
+
if (this.#active !== active2)
|
|
21294
21890
|
return;
|
|
21295
|
-
clearTimeout(
|
|
21296
|
-
for (const [
|
|
21891
|
+
clearTimeout(active2.timer);
|
|
21892
|
+
for (const [id2, pending] of this.#pendingInteractions) {
|
|
21297
21893
|
void this.#respond(pending.requestId, pending.interaction.type === "approval" ? { decision: "deny" } : { action: "cancel" }).catch(() => {
|
|
21298
21894
|
});
|
|
21299
|
-
this.#closeInteraction(
|
|
21895
|
+
this.#closeInteraction(id2, "cancelled");
|
|
21300
21896
|
}
|
|
21301
|
-
|
|
21897
|
+
active2.projection.finish(outcome.status === "succeeded" ? { status: "succeeded" } : outcome);
|
|
21302
21898
|
this.#active = void 0;
|
|
21303
21899
|
this.#emit({
|
|
21304
21900
|
type: "turn.completed",
|
|
21305
|
-
turnId:
|
|
21306
|
-
...
|
|
21901
|
+
turnId: active2.id,
|
|
21902
|
+
...active2.messageId ? { nativeTurnRef: nativeTurnRef(this.sessionId, active2.messageId) } : {},
|
|
21307
21903
|
outcome
|
|
21308
21904
|
});
|
|
21309
21905
|
}
|
|
@@ -21377,10 +21973,24 @@ var ZcodeAdapter = class {
|
|
|
21377
21973
|
options;
|
|
21378
21974
|
harnessId = ZCODE_ID;
|
|
21379
21975
|
commandCatalog = COMMAND_CATALOG;
|
|
21976
|
+
#inspectedModels = /* @__PURE__ */ new Map();
|
|
21977
|
+
normalizeStoredModelRef = (ref, catalog) => {
|
|
21978
|
+
let match;
|
|
21979
|
+
for (const models of this.#inspectedModels.values()) {
|
|
21980
|
+
if (!isDeepStrictEqual(models.catalog, catalog))
|
|
21981
|
+
continue;
|
|
21982
|
+
const candidate = normalizeStoredZcodeModelRef(ref, models.index);
|
|
21983
|
+
if (!candidate || match && match.id !== candidate.id)
|
|
21984
|
+
return void 0;
|
|
21985
|
+
match = candidate;
|
|
21986
|
+
}
|
|
21987
|
+
return match;
|
|
21988
|
+
};
|
|
21380
21989
|
#closed = false;
|
|
21381
21990
|
#sessions = /* @__PURE__ */ new Set();
|
|
21382
21991
|
#transports = /* @__PURE__ */ new Set();
|
|
21383
21992
|
#opening = /* @__PURE__ */ new Set();
|
|
21993
|
+
#inflightInspect = /* @__PURE__ */ new Map();
|
|
21384
21994
|
// One verification page and SDK instance for the whole Host, as in ZCode Desktop.
|
|
21385
21995
|
#verifier;
|
|
21386
21996
|
#prewarmed = false;
|
|
@@ -21393,7 +22003,7 @@ var ZcodeAdapter = class {
|
|
|
21393
22003
|
appVersion,
|
|
21394
22004
|
...this.options.openLocalPage ? { openLocalPage: this.options.openLocalPage } : {}
|
|
21395
22005
|
});
|
|
21396
|
-
async #transport(cwd, environment) {
|
|
22006
|
+
async #transport(cwd, environment, keyOptions) {
|
|
21397
22007
|
if (this.#closed)
|
|
21398
22008
|
throw new ZcodeError("invalidState", "ZCode Adapter is closed");
|
|
21399
22009
|
if (!(await stat2(cwd)).isDirectory())
|
|
@@ -21403,6 +22013,7 @@ var ZcodeAdapter = class {
|
|
|
21403
22013
|
environment: { ...this.options.environment ?? process.env, ...environment },
|
|
21404
22014
|
...this.options.app ? { app: this.options.app } : {},
|
|
21405
22015
|
...this.options.timeoutMs ? { timeoutMs: this.options.timeoutMs } : {},
|
|
22016
|
+
...keyOptions ? { keyOptions } : {},
|
|
21406
22017
|
verifier: this.#sharedVerifier
|
|
21407
22018
|
};
|
|
21408
22019
|
const transport = this.options.createTransport ? this.options.createTransport(options) : new CliTransport(options);
|
|
@@ -21417,24 +22028,51 @@ var ZcodeAdapter = class {
|
|
|
21417
22028
|
}
|
|
21418
22029
|
}
|
|
21419
22030
|
async inspect(input = {}) {
|
|
22031
|
+
const cwd = path7.resolve(input.cwd ?? process.cwd());
|
|
22032
|
+
const access = input.credentialAccess;
|
|
22033
|
+
return this.#inspect(cwd, access ? { access, requestedAt: performance.now() } : {});
|
|
22034
|
+
}
|
|
22035
|
+
async #inspect(cwd, keyOptions) {
|
|
22036
|
+
const { access } = keyOptions;
|
|
22037
|
+
const existing = this.#inflightInspect.get(cwd);
|
|
22038
|
+
if (existing) {
|
|
22039
|
+
if (access) {
|
|
22040
|
+
const { skipped } = existing.keyOptions;
|
|
22041
|
+
if (skipped && (skipped === "allow" || access === "retry")) {
|
|
22042
|
+
await existing.task;
|
|
22043
|
+
return this.#inspect(cwd, keyOptions);
|
|
22044
|
+
}
|
|
22045
|
+
if (!existing.keyOptions.access || access === "retry" && existing.keyOptions.access !== "retry")
|
|
22046
|
+
Object.assign(existing.keyOptions, keyOptions);
|
|
22047
|
+
}
|
|
22048
|
+
return existing.task;
|
|
22049
|
+
}
|
|
22050
|
+
const task = this.#runInspect(cwd, keyOptions).finally(() => this.#inflightInspect.delete(cwd));
|
|
22051
|
+
this.#inflightInspect.set(cwd, { keyOptions, task });
|
|
22052
|
+
return task;
|
|
22053
|
+
}
|
|
22054
|
+
async #runInspect(cwd, keyOptions) {
|
|
21420
22055
|
let transport;
|
|
21421
22056
|
try {
|
|
21422
|
-
transport = await this.#transport(
|
|
22057
|
+
transport = await this.#transport(cwd, void 0, keyOptions);
|
|
21423
22058
|
const settings = await readCatalog(transport);
|
|
21424
|
-
const
|
|
21425
|
-
|
|
22059
|
+
const models = modelCatalog(settings);
|
|
22060
|
+
const { catalog } = models;
|
|
22061
|
+
if (!catalog.models.length) {
|
|
22062
|
+
const issue2 = transport.codingPlanIssue ?? transport.credentialIssue;
|
|
22063
|
+
const retryable = !transport.credentialIssue;
|
|
21426
22064
|
return {
|
|
21427
22065
|
status: "unavailable",
|
|
21428
22066
|
// A signed-in account without an active plan is not a login problem; only a signed-out
|
|
21429
22067
|
// ZCode Desktop needs the login prompt.
|
|
21430
|
-
error:
|
|
22068
|
+
error: issue2 ? {
|
|
22069
|
+
code: transport.credentialAccessRequired ? "credentialAccessRequired" : "configurationRequired",
|
|
22070
|
+
message: issue2,
|
|
22071
|
+
retryable
|
|
22072
|
+
} : !transport.signedIn ? {
|
|
21431
22073
|
code: "authenticationRequired",
|
|
21432
22074
|
message: "ZCode has no available models. Sign in to ZCode Desktop with a Start Plan or Personal Coding Plan account, or add a personal provider, then re-detect ZCode. Team Coding Plan is not supported.",
|
|
21433
22075
|
retryable: true
|
|
21434
|
-
} : transport.codingPlanIssue ? {
|
|
21435
|
-
code: "configurationRequired",
|
|
21436
|
-
message: transport.codingPlanIssue,
|
|
21437
|
-
retryable: true
|
|
21438
22076
|
} : transport.startPlanChecked ? {
|
|
21439
22077
|
code: "configurationRequired",
|
|
21440
22078
|
message: "ZCode is signed in, but the account has no available models: no active Start Plan or event quota, no Personal Coding Plan, and no personal provider. Free trial and event quotas expire; subscribe to GLM Coding Plan or add a personal provider (API Key) in ZCode Desktop, then re-detect ZCode. Team Coding Plan is not supported.",
|
|
@@ -21446,6 +22084,8 @@ var ZcodeAdapter = class {
|
|
|
21446
22084
|
retryable: true
|
|
21447
22085
|
}
|
|
21448
22086
|
};
|
|
22087
|
+
}
|
|
22088
|
+
this.#inspectedModels.set(cwd, models);
|
|
21449
22089
|
return {
|
|
21450
22090
|
status: "ready",
|
|
21451
22091
|
catalog,
|
|
@@ -21480,18 +22120,26 @@ var ZcodeAdapter = class {
|
|
|
21480
22120
|
let transport;
|
|
21481
22121
|
let createdId;
|
|
21482
22122
|
try {
|
|
21483
|
-
|
|
22123
|
+
const prewarm = input.kind === "create" && input.prewarm === true;
|
|
22124
|
+
transport = await this.#transport(path7.resolve(input.cwd), input.environment, prewarm ? void 0 : { access: "allow" });
|
|
22125
|
+
const credentialIssue = transport.credentialIssue ?? "ZCode credential access is required";
|
|
22126
|
+
if (prewarm && transport.credentialAccessRequired)
|
|
22127
|
+
throw new ZcodeError("credentialAccessRequired", credentialIssue);
|
|
21484
22128
|
let snapshot, settings;
|
|
22129
|
+
let requestedModel;
|
|
21485
22130
|
if (input.kind === "create") {
|
|
21486
22131
|
settings = await readCatalog(transport);
|
|
22132
|
+
const { catalog, index } = modelCatalog(settings);
|
|
22133
|
+
if (transport.credentialAccessRequired && !catalog.models.length)
|
|
22134
|
+
throw new ZcodeError("credentialAccessRequired", credentialIssue);
|
|
21487
22135
|
if (input.permissionModeId && !permissionModes().modes.some((m) => m.id === input.permissionModeId))
|
|
21488
22136
|
throw new ZcodeError("invalidRequest", "Unknown ZCode permission mode");
|
|
21489
|
-
|
|
22137
|
+
requestedModel = input.model ? selectNativeModel(input.model, index, settings.model.current, input.thinkingOptionId) : void 0;
|
|
21490
22138
|
const mode = input.executionPolicy === "unattended-full-access" ? "yolo" : input.permissionModeId;
|
|
21491
22139
|
const created = await transport.command(null, "createSession", {
|
|
21492
22140
|
workspaceId: input.cwd,
|
|
21493
22141
|
config: {
|
|
21494
|
-
...
|
|
22142
|
+
...requestedModel ? { modelSelection: requestedModel } : {},
|
|
21495
22143
|
...mode ? { mode } : {},
|
|
21496
22144
|
...input.thinkingOptionId ? { thought: input.thinkingOptionId } : {}
|
|
21497
22145
|
}
|
|
@@ -21512,7 +22160,7 @@ var ZcodeAdapter = class {
|
|
|
21512
22160
|
if (snapshot.projection.currentTurnId || snapshot.session.status === "running")
|
|
21513
22161
|
throw new ZcodeError("sessionBusy", "ZCode Session is executing native work", true);
|
|
21514
22162
|
if (input.kind === "create") {
|
|
21515
|
-
if (
|
|
22163
|
+
if (requestedModel && (!snapshot.settings.model.current || !sameNativeModel(snapshot.settings.model.current, requestedModel)))
|
|
21516
22164
|
throw new ZcodeError("nativeFailure", "ZCode did not apply the requested model");
|
|
21517
22165
|
if (input.thinkingOptionId && snapshot.settings.thoughtLevel.current !== input.thinkingOptionId)
|
|
21518
22166
|
throw new ZcodeError("nativeFailure", "ZCode did not apply the requested thinking option");
|
|
@@ -21549,6 +22197,7 @@ var ZcodeAdapter = class {
|
|
|
21549
22197
|
}
|
|
21550
22198
|
async close() {
|
|
21551
22199
|
this.#closed = true;
|
|
22200
|
+
this.#inspectedModels.clear();
|
|
21552
22201
|
await Promise.all([...this.#sessions].map((session) => session.close()));
|
|
21553
22202
|
await Promise.all([...this.#transports].map((transport) => transport.close()));
|
|
21554
22203
|
this.#sessions.clear();
|