@codexhost/cli-linux-arm64 0.22.0 → 0.24.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/app/codexhost-distribution.json +1 -1
- package/app/console-server.mjs +3117 -274
- package/app/console-web.js +15645 -4413
- package/app/desktop-controller.mjs +14057 -969
- package/app/host-runtime.mjs +11518 -8277
- package/app/plugins/antigravity/plugin.mjs +2030 -678
- package/app/plugins/claude-code/plugin.mjs +2116 -929
- package/app/plugins/codebuddy/plugin.mjs +1247 -353
- package/app/plugins/codex-usage/plugin.mjs +786 -163
- package/app/plugins/copilot/plugin.mjs +938 -296
- package/app/plugins/cursor-cli/plugin.mjs +1021 -232
- package/app/plugins/deepseek-harness/plugin.mjs +1552 -664
- package/app/plugins/devin/plugin.mjs +826 -185
- package/app/plugins/grok/plugin.mjs +1083 -424
- package/app/plugins/hermes/plugin.mjs +961 -338
- package/app/plugins/kimi-code/plugin.mjs +854 -237
- package/app/plugins/kiro-cli/plugin.mjs +821 -184
- package/app/plugins/omp/plugin.mjs +1316 -633
- package/app/plugins/opencode/plugin.mjs +1293 -606
- package/app/plugins/pi/plugin.mjs +1540 -867
- package/app/plugins/qoder/plugin.mjs +961 -332
- package/app/plugins/qoder-cn/plugin.mjs +961 -332
- package/app/plugins/qwen-code/plugin.mjs +937 -321
- package/app/plugins/workbuddy/plugin.mjs +1311 -370
- package/app/plugins/zcode/plugin.mjs +1516 -423
- package/app/renderer-extension.js +21297 -9060
- package/app/web/assets/index-CTCFIQbU.css +1 -0
- package/app/web/assets/index-IvFk9KT-.js +203 -0
- package/app/web/codexhost-settings.js +6753 -31616
- package/app/web/index.html +2 -2
- package/app/web/plugins/deepseek-ai__dsh-api-remotes/client.js +1 -1
- package/app/web/plugins/deepseek-ai__dsh-api-session-controller/client.js +69 -69
- package/app/web/plugins/deepseek-ai__dsh-client-ui-approval/client.js +1 -1
- package/app/web/plugins/deepseek-ai__dsh-client-ui-chat/client.js +14 -14
- package/app/web/plugins/deepseek-ai__dsh-client-ui-codexhost/client.js +75 -64
- package/app/web/plugins/deepseek-ai__dsh-client-ui-conversation/client.js +94 -91
- package/app/web/plugins/deepseek-ai__dsh-client-ui-input-trigger/client.js +1 -1
- package/app/web/plugins/deepseek-ai__dsh-client-ui-layout/client.js +2 -2
- package/app/web/plugins/deepseek-ai__dsh-client-ui-model-selection/client.js +2 -2
- package/app/web/plugins/deepseek-ai__dsh-client-ui-settings-general/client.js +1 -1
- package/app/web/plugins/deepseek-ai__dsh-client-ui-sidebar/client.js +2 -2
- package/app/web/plugins/deepseek-ai__dsh-client-ui-sidebar-browser/client.js +1 -1
- package/app/web/plugins/deepseek-ai__dsh-client-ui-sidebar-documentpreview/client.js +9 -9
- package/app/web/plugins/deepseek-ai__dsh-client-ui-sidebar-right/client.js +1 -1
- package/app/web/plugins/deepseek-ai__dsh-client-ui-theme/client.js +1 -1
- package/app/web/plugins/deepseek-ai__dsh-client-ui-tool/client.js +79 -79
- package/app/web/plugins/deepseek-ai__dsh-client-ui-user-questions/client.js +3 -3
- package/app/web/plugins/deepseek-ai__dsh-client-ui-workspace/client.js +7 -7
- package/app/web/sw.js +8 -1
- package/app/web-modules/licenses/werift-NOTICES.txt +123 -0
- package/app/web-modules/licenses/werift-libwebrtc-NOTICES.txt +58 -0
- package/app/web-modules/server.mjs +40416 -11283
- package/bin/codexhost +0 -0
- package/libexec/codexhost-shim +0 -0
- package/libexec/codexhost-updater +0 -0
- package/package.json +1 -1
- package/app/web/assets/index-CN4a4sj0.js +0 -201
- package/app/web/assets/index-DJW4bmyx.css +0 -1
|
@@ -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
|
}
|
|
@@ -14844,6 +14844,9 @@ var threadPermissionModeSelectParamsSchema = external_exports.object({
|
|
|
14844
14844
|
permissionModeId: harnessPermissionModeIdSchema
|
|
14845
14845
|
}).strict();
|
|
14846
14846
|
|
|
14847
|
+
// ../../shared-contracts/dist/harness-route-limit.js
|
|
14848
|
+
var HARNESS_TRANSPORT_MODEL_ID_MAX_LENGTH = 8192;
|
|
14849
|
+
|
|
14847
14850
|
// ../../shared-contracts/dist/thread-usage.js
|
|
14848
14851
|
var nonNegativeSafeIntegerSchema = external_exports.number().int().safe().nonnegative();
|
|
14849
14852
|
var finiteNonNegativeNumberSchema = external_exports.number().finite().nonnegative();
|
|
@@ -14876,7 +14879,7 @@ var composerIndicatorsSchema = external_exports.array(external_exports.object({
|
|
|
14876
14879
|
expiresAtUnix: nonNegativeSafeIntegerSchema,
|
|
14877
14880
|
label: indicatorTextSchema(256).optional(),
|
|
14878
14881
|
tooltip: indicatorTextSchema(1024).optional()
|
|
14879
|
-
}).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, {
|
|
14880
14883
|
message: "Composer indicator IDs must be unique"
|
|
14881
14884
|
});
|
|
14882
14885
|
var threadUsageSnapshotSchema = external_exports.object({
|
|
@@ -14902,6 +14905,7 @@ var threadUsageSnapshotSchema = external_exports.object({
|
|
|
14902
14905
|
planSevenDayResetsAtUnix: nonNegativeSafeIntegerSchema.optional(),
|
|
14903
14906
|
sessionCacheHitRatePercent: cacheHitRatePercentSchema.optional(),
|
|
14904
14907
|
timeToFirstOutputMs: nonNegativeSafeIntegerSchema.optional(),
|
|
14908
|
+
latestRequestTimeToFirstOutputMs: nonNegativeSafeIntegerSchema.optional(),
|
|
14905
14909
|
costSource: external_exports.enum(["publicPrice", "native"]).optional(),
|
|
14906
14910
|
unpricedModels: external_exports.array(external_exports.string().min(1)).min(1).optional()
|
|
14907
14911
|
}).strict().superRefine((usage, context) => {
|
|
@@ -14999,6 +15003,13 @@ var accountCreditsSnapshotSchema = external_exports.object({
|
|
|
14999
15003
|
productUsage: external_exports.array(accountCreditsProductUsageSchema).min(1).optional(),
|
|
15000
15004
|
resetCredits: accountResetCreditsSchema.optional()
|
|
15001
15005
|
}).strict();
|
|
15006
|
+
var accountBalanceSnapshotSchema = external_exports.object({
|
|
15007
|
+
amount: external_exports.number().finite().nonnegative(),
|
|
15008
|
+
/** ISO 4217 code as reported by the Provider, for example `CNY`. */
|
|
15009
|
+
currency: external_exports.string().trim().min(1).max(8),
|
|
15010
|
+
/** Native label when the Harness exposes several Billing Sources. */
|
|
15011
|
+
label: external_exports.string().trim().min(1).max(128).optional()
|
|
15012
|
+
}).strict();
|
|
15002
15013
|
var threadUsageInspectionParamsSchema = external_exports.object({
|
|
15003
15014
|
threadId: hostThreadIdSchema,
|
|
15004
15015
|
refresh: external_exports.literal("exact").optional()
|
|
@@ -15007,7 +15018,10 @@ var threadUsageInspectionSchema = external_exports.object({
|
|
|
15007
15018
|
threadId: hostThreadIdSchema,
|
|
15008
15019
|
usage: threadUsageSnapshotSchema.nullable(),
|
|
15009
15020
|
accountCredits: accountCreditsSnapshotSchema.optional(),
|
|
15010
|
-
/**
|
|
15021
|
+
/** Prepaid funds for the Thread's Billing Source; shown only when no percentage quota exists. */
|
|
15022
|
+
accountBalance: accountBalanceSnapshotSchema.optional(),
|
|
15023
|
+
/** Whether this source can provide cached account quota (credits or a prepaid balance)
|
|
15024
|
+
* independently of usage. */
|
|
15011
15025
|
accountCreditsSupported: external_exports.boolean().optional()
|
|
15012
15026
|
}).strict();
|
|
15013
15027
|
|
|
@@ -15019,10 +15033,15 @@ var THREAD_OWNERSHIP_LIST_MAX_LENGTH = 100;
|
|
|
15019
15033
|
var nonBlankTextSchema2 = external_exports.string().refine((value) => value.trim().length > 0, {
|
|
15020
15034
|
message: "Value must not be empty or whitespace"
|
|
15021
15035
|
});
|
|
15022
|
-
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"]);
|
|
15023
15038
|
var harnessModelRefSchema = external_exports.object({
|
|
15024
|
-
id: harnessModelRefIdSchema
|
|
15039
|
+
id: harnessModelRefIdSchema,
|
|
15040
|
+
serviceTier: harnessModelServiceTierSchema.optional()
|
|
15025
15041
|
}).strict();
|
|
15042
|
+
function sameHarnessModelRef(left, right) {
|
|
15043
|
+
return left?.id === right?.id && left?.serviceTier === right?.serviceTier;
|
|
15044
|
+
}
|
|
15026
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();
|
|
15027
15046
|
var harnessResolvedModelLabelSchema = nonBlankTextSchema2.max(HARNESS_MODEL_LABEL_MAX_LENGTH);
|
|
15028
15047
|
var harnessThinkingOptionSchema = external_exports.object({
|
|
@@ -15036,7 +15055,15 @@ var harnessModelSchema = external_exports.object({
|
|
|
15036
15055
|
/** Optional opaque selection for this same Model with priority processing enabled. */
|
|
15037
15056
|
fastModel: harnessModelRefSchema.optional(),
|
|
15038
15057
|
supportedThinkingOptionIds: external_exports.array(harnessThinkingOptionIdSchema).optional()
|
|
15039
|
-
}).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
|
+
}
|
|
15040
15067
|
var harnessThinkingOptionsSchema = external_exports.array(harnessThinkingOptionSchema).superRefine((options, context) => {
|
|
15041
15068
|
const ids = /* @__PURE__ */ new Set();
|
|
15042
15069
|
for (const [index, option] of options.entries()) {
|
|
@@ -15056,26 +15083,26 @@ var harnessModelCatalogSchema = external_exports.object({
|
|
|
15056
15083
|
thinkingOptions: harnessThinkingOptionsSchema,
|
|
15057
15084
|
defaultThinkingOptionId: harnessThinkingOptionIdSchema.optional()
|
|
15058
15085
|
}).strict().superRefine((catalog, context) => {
|
|
15059
|
-
const refs =
|
|
15060
|
-
const thinkingIds = new Set(catalog.thinkingOptions.map(({ id }) =>
|
|
15086
|
+
const refs = [];
|
|
15087
|
+
const thinkingIds = new Set(catalog.thinkingOptions.map(({ id: id2 }) => id2));
|
|
15061
15088
|
for (const [index, model2] of catalog.models.entries()) {
|
|
15062
|
-
if (refs.
|
|
15089
|
+
if (refs.some((ref) => sameHarnessModelRef(ref, model2.ref))) {
|
|
15063
15090
|
context.addIssue({
|
|
15064
15091
|
code: "custom",
|
|
15065
15092
|
message: "Model Catalog refs must be unique",
|
|
15066
15093
|
path: ["models", index, "ref", "id"]
|
|
15067
15094
|
});
|
|
15068
15095
|
}
|
|
15069
|
-
refs.
|
|
15096
|
+
refs.push(model2.ref);
|
|
15070
15097
|
if (model2.fastModel) {
|
|
15071
|
-
if (refs.
|
|
15098
|
+
if (refs.some((ref) => sameHarnessModelRef(ref, model2.fastModel))) {
|
|
15072
15099
|
context.addIssue({
|
|
15073
15100
|
code: "custom",
|
|
15074
15101
|
message: "Fast Model refs must be distinct and unique",
|
|
15075
15102
|
path: ["models", index, "fastModel"]
|
|
15076
15103
|
});
|
|
15077
15104
|
}
|
|
15078
|
-
refs.
|
|
15105
|
+
refs.push(model2.fastModel);
|
|
15079
15106
|
}
|
|
15080
15107
|
const supportedThinkingIds = /* @__PURE__ */ new Set();
|
|
15081
15108
|
for (const [optionIndex, optionId] of (model2.supportedThinkingOptionIds ?? []).entries()) {
|
|
@@ -15096,7 +15123,7 @@ var harnessModelCatalogSchema = external_exports.object({
|
|
|
15096
15123
|
}
|
|
15097
15124
|
}
|
|
15098
15125
|
}
|
|
15099
|
-
if (catalog.defaultModel && !
|
|
15126
|
+
if (catalog.defaultModel && !catalogModelForRef(catalog, catalog.defaultModel)) {
|
|
15100
15127
|
context.addIssue({
|
|
15101
15128
|
code: "custom",
|
|
15102
15129
|
message: "Default Model must exist in the Model Catalog",
|
|
@@ -15136,7 +15163,12 @@ var harnessSessionCapabilitiesSchema = external_exports.object({
|
|
|
15136
15163
|
observe: external_exports.boolean()
|
|
15137
15164
|
}).strict().optional(),
|
|
15138
15165
|
/** True only when `turn.steer` delivers input into the active Turn through a native primitive. */
|
|
15139
|
-
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()
|
|
15140
15172
|
}).strict();
|
|
15141
15173
|
var harnessConfigurationStateSchema = external_exports.object({
|
|
15142
15174
|
effectiveModel: harnessModelRefSchema.optional(),
|
|
@@ -15145,7 +15177,7 @@ var harnessConfigurationStateSchema = external_exports.object({
|
|
|
15145
15177
|
availableThinkingOptions: harnessThinkingOptionsSchema.optional(),
|
|
15146
15178
|
effectivePermissionModeId: harnessPermissionModeIdSchema.optional()
|
|
15147
15179
|
}).strict().superRefine((state, context) => {
|
|
15148
|
-
if (state.effectiveThinkingOptionId && state.availableThinkingOptions && !state.availableThinkingOptions.some(({ id }) =>
|
|
15180
|
+
if (state.effectiveThinkingOptionId && state.availableThinkingOptions && !state.availableThinkingOptions.some(({ id: id2 }) => id2 === state.effectiveThinkingOptionId)) {
|
|
15149
15181
|
context.addIssue({
|
|
15150
15182
|
code: "custom",
|
|
15151
15183
|
message: "Effective Thinking option must be currently available",
|
|
@@ -15185,7 +15217,8 @@ var harnessInspectParamsSchema = external_exports.object({
|
|
|
15185
15217
|
cwd: nonBlankTextSchema2.max(16384).optional(),
|
|
15186
15218
|
refresh: external_exports.boolean().optional(),
|
|
15187
15219
|
/** `availability` asks only whether the Harness can run; see `InspectHarnessInput.purpose`. */
|
|
15188
|
-
purpose: external_exports.literal("availability").optional()
|
|
15220
|
+
purpose: external_exports.literal("availability").optional(),
|
|
15221
|
+
credentialAccess: external_exports.enum(["allow", "retry"]).optional()
|
|
15189
15222
|
}).strict();
|
|
15190
15223
|
var harnessWebUiOpenParamsSchema = external_exports.object({
|
|
15191
15224
|
harnessId: harnessIdSchema
|
|
@@ -15216,7 +15249,7 @@ var codexThreadInspectionSchema = external_exports.object({
|
|
|
15216
15249
|
var externalThreadInspectionSchema = external_exports.object({
|
|
15217
15250
|
owner: external_exports.literal("external"),
|
|
15218
15251
|
harnessId: nonBlankTextSchema2.max(256),
|
|
15219
|
-
transportModelId: nonBlankTextSchema2.max(
|
|
15252
|
+
transportModelId: nonBlankTextSchema2.max(HARNESS_TRANSPORT_MODEL_ID_MAX_LENGTH),
|
|
15220
15253
|
effectiveModel: harnessModelRefSchema.optional(),
|
|
15221
15254
|
resolvedModelLabel: harnessResolvedModelLabelSchema.optional(),
|
|
15222
15255
|
effectiveThinkingOptionId: harnessThinkingOptionIdSchema.optional(),
|
|
@@ -15298,13 +15331,635 @@ var threadSteeringInspectResultSchema = external_exports.object({
|
|
|
15298
15331
|
delivery: external_exports.enum(["official", "activeTurn", "newTurn"])
|
|
15299
15332
|
}).strict();
|
|
15300
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()
|
|
15743
|
+
});
|
|
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
|
+
})
|
|
15763
|
+
]);
|
|
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
|
|
15818
|
+
});
|
|
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
|
+
};
|
|
15878
|
+
|
|
15301
15879
|
// ../../shared-contracts/dist/thread-archive-confirm.js
|
|
15880
|
+
var THREAD_ARCHIVE_CONFIRM_METHOD = "codexhost/thread/archive/confirm";
|
|
15302
15881
|
var threadArchiveConfirmParamsSchema = external_exports.object({ threadId: hostThreadIdSchema }).strict();
|
|
15303
15882
|
var threadArchiveConfirmResultSchema = external_exports.object({ confirmed: external_exports.boolean() }).strict();
|
|
15304
15883
|
|
|
15305
15884
|
// ../../shared-contracts/dist/client-channel.js
|
|
15306
15885
|
var CLIENT_CHANNEL_VERSION = 1;
|
|
15307
15886
|
var CLIENT_REQUEST_LIMIT_BYTES = 128 * 1024 * 1024;
|
|
15887
|
+
var CLIENT_CHANNEL_METHODS = [
|
|
15888
|
+
"codexhost/skills/list",
|
|
15889
|
+
"codexhost/voice/status",
|
|
15890
|
+
"codexhost/voice/transcribe",
|
|
15891
|
+
"codexhost/harness/display-settings/get",
|
|
15892
|
+
"codexhost/harness/display-settings/set",
|
|
15893
|
+
"codexhost/harness/display-settings/capabilities",
|
|
15894
|
+
"codexhost/harness/preferences/get",
|
|
15895
|
+
"codexhost/harness/preferences/patch",
|
|
15896
|
+
"thread/list",
|
|
15897
|
+
"codexhost/thread/catalog/read",
|
|
15898
|
+
"thread/read",
|
|
15899
|
+
"thread/resume",
|
|
15900
|
+
"thread/fork",
|
|
15901
|
+
"thread/turns/list",
|
|
15902
|
+
"thread/revert",
|
|
15903
|
+
"thread/items/list",
|
|
15904
|
+
"thread/start",
|
|
15905
|
+
"thread/name/set",
|
|
15906
|
+
"codexhost/thread/title/generate",
|
|
15907
|
+
"thread/archive",
|
|
15908
|
+
THREAD_ARCHIVE_CONFIRM_METHOD,
|
|
15909
|
+
"thread/unarchive",
|
|
15910
|
+
"turn/start",
|
|
15911
|
+
"turn/interrupt",
|
|
15912
|
+
"turn/steer",
|
|
15913
|
+
"thread/queue/list",
|
|
15914
|
+
"thread/queue/add",
|
|
15915
|
+
"thread/queue/update",
|
|
15916
|
+
"thread/queue/delete",
|
|
15917
|
+
"thread/queue/reorder",
|
|
15918
|
+
"thread/queue/start",
|
|
15919
|
+
"codexhost/thread/queue/send-now",
|
|
15920
|
+
"codexhost/workspace/read",
|
|
15921
|
+
"codexhost/thread/tree/read",
|
|
15922
|
+
"codexhost/thread/pins/list",
|
|
15923
|
+
"codexhost/thread/pins/set",
|
|
15924
|
+
"codexhost/harness/plugins/list",
|
|
15925
|
+
"codexhost/harness/inspect",
|
|
15926
|
+
"codexhost/thread/inspect",
|
|
15927
|
+
"codexhost/thread/usage/inspect",
|
|
15928
|
+
"codexhost/thread/ownership/list",
|
|
15929
|
+
"codexhost/thread/model/select",
|
|
15930
|
+
"codexhost/thread/thinking/select",
|
|
15931
|
+
"codexhost/thread/permission-mode/select",
|
|
15932
|
+
"codexhost/thread/commands/inspect",
|
|
15933
|
+
"codexhost/harness/commands/inspect",
|
|
15934
|
+
"codexhost/thread/command/execute",
|
|
15935
|
+
"codexhost/thread/fork",
|
|
15936
|
+
"codexhost/harness/session-import/sources",
|
|
15937
|
+
"codexhost/harness/session-import/list",
|
|
15938
|
+
"codexhost/harness/session-import/import",
|
|
15939
|
+
// Host settings shared across Desktop and Web.
|
|
15940
|
+
...HOST_EXTENSION_MANAGEMENT_METHODS,
|
|
15941
|
+
"codexhost/harness/installation",
|
|
15942
|
+
"codexhost/harness/installation/start",
|
|
15943
|
+
"codexhost/harness/installation/status",
|
|
15944
|
+
"codexhost/harness/launch-settings/get",
|
|
15945
|
+
"codexhost/harness/launch-settings/set",
|
|
15946
|
+
"codexhost/harness/web-ui/open",
|
|
15947
|
+
"codexhost/harness/accounts/sources",
|
|
15948
|
+
"codexhost/harness/accounts/list",
|
|
15949
|
+
"codexhost/harness/accounts/inspect",
|
|
15950
|
+
"codexhost/harness/credential-imports",
|
|
15951
|
+
"codexhost/account/list",
|
|
15952
|
+
"codexhost/account/refresh",
|
|
15953
|
+
"codexhost/account/usage/inspect",
|
|
15954
|
+
"codexhost/usage/model-prices/get",
|
|
15955
|
+
"codexhost/usage/model-prices/set",
|
|
15956
|
+
"codexhost/usage/model-prices/default",
|
|
15957
|
+
"codexhost/usage/statistics/get",
|
|
15958
|
+
"codexhost/update/check",
|
|
15959
|
+
"codexhost/update/start",
|
|
15960
|
+
"codexhost/update/status",
|
|
15961
|
+
"codexhost/sessions/loaded/list"
|
|
15962
|
+
];
|
|
15308
15963
|
var clientThreadPinsSchema = external_exports.object({ threadIds: external_exports.array(external_exports.string().min(1)) }).strict();
|
|
15309
15964
|
var clientThreadPinParamsSchema = external_exports.object({ threadId: external_exports.string().min(1).max(1024), pinned: external_exports.boolean() }).strict();
|
|
15310
15965
|
var clientThreadTreeReadParamsSchema = external_exports.object({}).strict();
|
|
@@ -15343,6 +15998,11 @@ var clientChannelEventSchema = external_exports.discriminatedUnion("type", [
|
|
|
15343
15998
|
cursor: clientChannelCursorSchema,
|
|
15344
15999
|
revision: external_exports.number().int().nonnegative()
|
|
15345
16000
|
}),
|
|
16001
|
+
external_exports.object({
|
|
16002
|
+
type: external_exports.literal("extensions-changed"),
|
|
16003
|
+
cursor: clientChannelCursorSchema,
|
|
16004
|
+
revision: hostExtensionRevisionSchema
|
|
16005
|
+
}),
|
|
15346
16006
|
external_exports.object({
|
|
15347
16007
|
type: external_exports.literal("hello"),
|
|
15348
16008
|
version: external_exports.literal(1),
|
|
@@ -15518,6 +16178,29 @@ var threadCatalogReadResultSchema = external_exports.object({
|
|
|
15518
16178
|
officialCursor: external_exports.object({ live: external_exports.string().nullable(), archived: external_exports.string().nullable().optional() }).strict().optional()
|
|
15519
16179
|
}).strict();
|
|
15520
16180
|
|
|
16181
|
+
// ../../shared-contracts/dist/thread-tree-watch.js
|
|
16182
|
+
var THREAD_TREE_MAX_NODES = 5e3;
|
|
16183
|
+
var threadTreeStatusSchema = external_exports.enum(["running", "waiting", "idle", "unknown"]);
|
|
16184
|
+
var threadTreeNodeSchema = external_exports.strictObject({
|
|
16185
|
+
harnessId: harnessIdSchema,
|
|
16186
|
+
title: external_exports.string().optional(),
|
|
16187
|
+
status: threadTreeStatusSchema,
|
|
16188
|
+
archived: external_exports.boolean()
|
|
16189
|
+
});
|
|
16190
|
+
var threadTreeSnapshotSchema = external_exports.strictObject({
|
|
16191
|
+
revision: external_exports.int().nonnegative(),
|
|
16192
|
+
parents: external_exports.record(hostThreadIdSchema, hostThreadIdSchema),
|
|
16193
|
+
nodes: external_exports.record(hostThreadIdSchema, threadTreeNodeSchema),
|
|
16194
|
+
truncated: external_exports.boolean()
|
|
16195
|
+
}).refine((snapshot) => Object.keys(snapshot.nodes).length <= THREAD_TREE_MAX_NODES, "Too many Thread tree nodes").refine(({ parents, nodes }) => Object.entries(parents).every(([child, parent]) => Object.hasOwn(nodes, child) && Object.hasOwn(nodes, parent)), "Missing Thread tree node");
|
|
16196
|
+
var subscriptionId = external_exports.string().min(1).max(128);
|
|
16197
|
+
var threadTreeWatchParamsSchema = external_exports.strictObject({});
|
|
16198
|
+
var threadTreeUnwatchParamsSchema = external_exports.strictObject({ subscriptionId });
|
|
16199
|
+
var threadTreeUnwatchResultSchema = external_exports.strictObject({});
|
|
16200
|
+
var threadTreeWatchResultSchema = threadTreeUnwatchParamsSchema.extend({
|
|
16201
|
+
snapshot: threadTreeSnapshotSchema
|
|
16202
|
+
});
|
|
16203
|
+
|
|
15521
16204
|
// ../../shared-contracts/dist/voice.js
|
|
15522
16205
|
var VOICE_AUDIO_MAX_BYTES = 10 * 1024 * 1024;
|
|
15523
16206
|
var voiceAudioMimeTypeSchema = external_exports.string().regex(/^audio\/[a-z0-9.+-]+(?:\s*;[^\r\n]*)?$/i);
|
|
@@ -15756,7 +16439,7 @@ var DEFAULT_IDLE_RELEASE_SETTINGS = Object.freeze({
|
|
|
15756
16439
|
|
|
15757
16440
|
// ../../shared-contracts/dist/harness-preferences.js
|
|
15758
16441
|
var harnessPreferenceScopeSchema = external_exports.string().regex(/^external$/u);
|
|
15759
|
-
var preferenceHarnessKey = harnessIdSchema.transform((
|
|
16442
|
+
var preferenceHarnessKey = harnessIdSchema.transform((id2) => String(id2));
|
|
15760
16443
|
var harnessDefaultConfigurationSchema = external_exports.strictObject({
|
|
15761
16444
|
model: harnessModelRefSchema.optional(),
|
|
15762
16445
|
thinkingOptionId: harnessThinkingOptionIdSchema.optional(),
|
|
@@ -15766,11 +16449,19 @@ var newThreadDefaultsSchema = external_exports.strictObject({
|
|
|
15766
16449
|
lastHarness: harnessIdSchema.optional(),
|
|
15767
16450
|
byHarness: external_exports.record(preferenceHarnessKey, harnessDefaultConfigurationSchema)
|
|
15768
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
|
+
});
|
|
15769
16459
|
var modelId = external_exports.string().min(1).max(1024);
|
|
15770
16460
|
var harnessPreferenceValuesSchema = external_exports.strictObject({
|
|
15771
16461
|
idleRelease: idleReleaseSettingsSchema.optional(),
|
|
15772
16462
|
favorites: external_exports.record(preferenceHarnessKey, external_exports.array(modelId).max(2048)).default({}),
|
|
15773
|
-
newThread: newThreadDefaultsSchema.optional()
|
|
16463
|
+
newThread: newThreadDefaultsSchema.optional(),
|
|
16464
|
+
delegation: delegationDefaultsSchema.optional()
|
|
15774
16465
|
});
|
|
15775
16466
|
var harnessPreferenceSnapshotSchema = external_exports.strictObject({
|
|
15776
16467
|
scope: harnessPreferenceScopeSchema,
|
|
@@ -15798,6 +16489,11 @@ var harnessPreferenceOperationSchema = external_exports.discriminatedUnion("kind
|
|
|
15798
16489
|
lastHarness: harnessIdSchema.optional(),
|
|
15799
16490
|
harnessId: harnessIdSchema.optional(),
|
|
15800
16491
|
configuration: harnessDefaultConfigurationSchema.optional()
|
|
16492
|
+
}),
|
|
16493
|
+
external_exports.strictObject({
|
|
16494
|
+
kind: external_exports.literal("delegation"),
|
|
16495
|
+
harnessId: harnessIdSchema,
|
|
16496
|
+
configuration: harnessDelegationDefaultSchema.nullable()
|
|
15801
16497
|
})
|
|
15802
16498
|
]);
|
|
15803
16499
|
var harnessPreferencePatchSchema = external_exports.strictObject({
|
|
@@ -16148,13 +16844,6 @@ var threadManualCompactionStartedSchema = external_exports.strictObject({
|
|
|
16148
16844
|
});
|
|
16149
16845
|
|
|
16150
16846
|
// ../../shared-contracts/dist/harness-accounts.js
|
|
16151
|
-
var accountBalanceSnapshotSchema = external_exports.object({
|
|
16152
|
-
amount: external_exports.number().finite().nonnegative(),
|
|
16153
|
-
/** ISO 4217 code as reported by the Provider, for example `CNY`. */
|
|
16154
|
-
currency: external_exports.string().trim().min(1).max(8),
|
|
16155
|
-
/** Native label when the Harness exposes several Billing Sources. */
|
|
16156
|
-
label: external_exports.string().trim().min(1).max(128).optional()
|
|
16157
|
-
}).strict();
|
|
16158
16847
|
var harnessAccountSnapshotObject = external_exports.object({
|
|
16159
16848
|
email: external_exports.string().trim().min(1).max(320).optional(),
|
|
16160
16849
|
label: external_exports.string().trim().min(1).max(256).optional(),
|
|
@@ -16188,76 +16877,6 @@ var harnessAccountListResultSchema = external_exports.object({
|
|
|
16188
16877
|
accounts: external_exports.array(requireReportedQuota(harnessAccountSnapshotObject.extend(harnessAccountIdentityShape))).max(128)
|
|
16189
16878
|
}).strict();
|
|
16190
16879
|
|
|
16191
|
-
// ../../shared-contracts/dist/harness-plugins.js
|
|
16192
|
-
var HARNESS_PLUGIN_MANIFEST_MAX_BYTES = 32 * 1024;
|
|
16193
|
-
var HARNESS_PLUGIN_ICON_MAX_BYTES = 128 * 1024;
|
|
16194
|
-
var HARNESS_PLUGIN_LIMIT = 128;
|
|
16195
|
-
var installedHarnessPluginIdSchema = external_exports.string().min(1).max(128).regex(/^[a-z][a-z0-9]*(?:[._-][a-z0-9]+)*$/u).pipe(harnessIdSchema);
|
|
16196
|
-
var harnessPluginIdSchema = installedHarnessPluginIdSchema.refine((id) => id !== "codex", "The official Codex identity is reserved");
|
|
16197
|
-
var relativeResourceSchema = external_exports.string().min(1).max(512).refine((value) => !/[\\\u0000:#?]/u.test(value) && !value.startsWith("/") && !value.split("/").some((part) => part === ".." || part === ""), "Plugin resources must be relative paths inside the plugin");
|
|
16198
|
-
var documentationUrlSchema = external_exports.url().refine((value) => /^https:\/\/[^/?#@]+(?:[/?#]|$)/iu.test(value), "Plugin documentation links must be credential-free HTTPS URLs");
|
|
16199
|
-
var localizedTextSchema = external_exports.object({ en: external_exports.string().max(4096), "zh-CN": external_exports.string().max(4096).optional() }).strict();
|
|
16200
|
-
var harnessInstallationGuideSchema = external_exports.object({
|
|
16201
|
-
commands: external_exports.array(external_exports.object({ terminal: external_exports.string().max(256), command: external_exports.string().max(4096) }).strict()).max(8),
|
|
16202
|
-
before: localizedTextSchema.optional(),
|
|
16203
|
-
after: localizedTextSchema.optional(),
|
|
16204
|
-
downloads: external_exports.array(external_exports.object({ label: external_exports.string().max(128), url: documentationUrlSchema }).strict()).max(8).optional()
|
|
16205
|
-
}).strict();
|
|
16206
|
-
var pluginPresentationShape = {
|
|
16207
|
-
id: installedHarnessPluginIdSchema,
|
|
16208
|
-
name: external_exports.string().trim().min(1).max(128),
|
|
16209
|
-
version: external_exports.string().min(1).max(128),
|
|
16210
|
-
/** Capability-only plugin; omitted for existing session-capable plugins. */
|
|
16211
|
-
kind: external_exports.literal("usage").optional(),
|
|
16212
|
-
/** Original image styling or bounded vector paths; never arbitrary CSS/SVG markup. */
|
|
16213
|
-
iconStyle: external_exports.object({
|
|
16214
|
-
vector: external_exports.object({
|
|
16215
|
-
viewBox: external_exports.string().max(128).regex(/^-?\d+(?:\.\d+)?(?: +-?\d+(?:\.\d+)?){3}$/u),
|
|
16216
|
-
color: external_exports.string().regex(/^(?:currentColor|#[a-f0-9]{6})$/iu),
|
|
16217
|
-
paths: external_exports.array(external_exports.object({
|
|
16218
|
-
d: external_exports.string().min(1).max(32768).regex(/^[MmLlHhVvCcSsQqTtAaZz\d.,+eE\s-]+$/u),
|
|
16219
|
-
fillRule: external_exports.enum(["evenodd", "nonzero"]).optional(),
|
|
16220
|
-
fill: external_exports.string().regex(/^(?:currentColor|#[a-f0-9]{6})$/iu).optional()
|
|
16221
|
-
}).strict()).min(1).max(32)
|
|
16222
|
-
}).strict().optional(),
|
|
16223
|
-
background: external_exports.string().regex(/^#[a-f0-9]{6}$/iu).optional(),
|
|
16224
|
-
borderRadius: external_exports.number().min(0).max(50).optional(),
|
|
16225
|
-
paddingRatio: external_exports.number().min(0).max(0.25).optional()
|
|
16226
|
-
}).strict().optional(),
|
|
16227
|
-
installation: harnessInstallationGuideSchema.optional(),
|
|
16228
|
-
notice: localizedTextSchema.optional(),
|
|
16229
|
-
/** The factory accepts a persisted local entrypoint through its construction context. */
|
|
16230
|
-
launchCommand: external_exports.literal(true).optional(),
|
|
16231
|
-
links: external_exports.object({
|
|
16232
|
-
website: documentationUrlSchema.optional(),
|
|
16233
|
-
documentation: documentationUrlSchema.optional(),
|
|
16234
|
-
installation: documentationUrlSchema.optional()
|
|
16235
|
-
}).strict().optional()
|
|
16236
|
-
};
|
|
16237
|
-
var harnessPluginManifestSchema = external_exports.object({
|
|
16238
|
-
manifestVersion: external_exports.literal(1),
|
|
16239
|
-
...pluginPresentationShape,
|
|
16240
|
-
adapterApiVersion: external_exports.number().int().positive(),
|
|
16241
|
-
entry: relativeResourceSchema,
|
|
16242
|
-
icon: relativeResourceSchema.optional()
|
|
16243
|
-
}).strict();
|
|
16244
|
-
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);
|
|
16245
|
-
var harnessPluginDescriptorSchema = external_exports.object({
|
|
16246
|
-
...pluginPresentationShape,
|
|
16247
|
-
icon: harnessPluginIconSchema.optional()
|
|
16248
|
-
}).strict();
|
|
16249
|
-
var harnessPluginListParamsSchema = external_exports.object({}).strict();
|
|
16250
|
-
var harnessPluginListResultSchema = external_exports.object({
|
|
16251
|
-
plugins: external_exports.array(harnessPluginDescriptorSchema.extend({ id: harnessPluginIdSchema })).max(HARNESS_PLUGIN_LIMIT)
|
|
16252
|
-
}).strict();
|
|
16253
|
-
var harnessPluginConfigurationSchema = external_exports.object({
|
|
16254
|
-
version: external_exports.literal(1),
|
|
16255
|
-
enabled: external_exports.array(installedHarnessPluginIdSchema).max(HARNESS_PLUGIN_LIMIT)
|
|
16256
|
-
}).strict().refine((value) => new Set(value.enabled).size === value.enabled.length, {
|
|
16257
|
-
message: "Enabled plugin IDs must be unique",
|
|
16258
|
-
path: ["enabled"]
|
|
16259
|
-
});
|
|
16260
|
-
|
|
16261
16880
|
// ../../shared-contracts/dist/harness-route.js
|
|
16262
16881
|
var harnessPluginRouteSchema = external_exports.object({
|
|
16263
16882
|
harnessId: harnessPluginIdSchema,
|
|
@@ -16698,9 +17317,12 @@ var remoteSessionOperationSchema = external_exports.discriminatedUnion("kind", [
|
|
|
16698
17317
|
...thread,
|
|
16699
17318
|
epoch: identity,
|
|
16700
17319
|
modelId: identity.optional(),
|
|
17320
|
+
serviceTier: harnessModelServiceTierSchema.optional(),
|
|
16701
17321
|
thinkingOptionId: identity.optional(),
|
|
16702
17322
|
permissionModeId: identity.optional()
|
|
16703
|
-
}).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
|
+
}),
|
|
16704
17326
|
external_exports.strictObject({
|
|
16705
17327
|
kind: external_exports.literal("prompt"),
|
|
16706
17328
|
...thread,
|
|
@@ -16750,7 +17372,7 @@ var remoteConnectionsRequestSchema = external_exports.discriminatedUnion("action
|
|
|
16750
17372
|
external_exports.strictObject({ action: external_exports.literal("catalog") }),
|
|
16751
17373
|
external_exports.strictObject({
|
|
16752
17374
|
action: external_exports.literal("read-thread"),
|
|
16753
|
-
hostId: hostId.refine((
|
|
17375
|
+
hostId: hostId.refine((id2) => id2 !== "local"),
|
|
16754
17376
|
input: delegationReadParamsSchema
|
|
16755
17377
|
}),
|
|
16756
17378
|
external_exports.strictObject({
|
|
@@ -16764,7 +17386,7 @@ var remoteConnectionsRequestSchema = external_exports.discriminatedUnion("action
|
|
|
16764
17386
|
external_exports.strictObject({ action: external_exports.literal("runtime"), hostId }),
|
|
16765
17387
|
external_exports.strictObject({
|
|
16766
17388
|
action: external_exports.literal("update"),
|
|
16767
|
-
hostId: hostId.refine((
|
|
17389
|
+
hostId: hostId.refine((id2) => id2 !== "local"),
|
|
16768
17390
|
version: remoteUpdateParamsSchema.shape.version
|
|
16769
17391
|
})
|
|
16770
17392
|
]);
|
|
@@ -16828,7 +17450,7 @@ function invalidRequest(message) {
|
|
|
16828
17450
|
return { code: "invalidRequest", message, retryable: false };
|
|
16829
17451
|
}
|
|
16830
17452
|
function validateHostApprovalResponse(interaction, response) {
|
|
16831
|
-
return interaction.actions.some(({ id }) =>
|
|
17453
|
+
return interaction.actions.some(({ id: id2 }) => id2 === response.actionId) ? null : invalidRequest("Approval Response contains an undeclared action ID");
|
|
16832
17454
|
}
|
|
16833
17455
|
|
|
16834
17456
|
// ../../harness-adapter/dist/question.js
|
|
@@ -16836,7 +17458,7 @@ function invalidRequest2(message) {
|
|
|
16836
17458
|
return { code: "invalidRequest", message, retryable: false };
|
|
16837
17459
|
}
|
|
16838
17460
|
function validateHostQuestionResponse(interaction, response) {
|
|
16839
|
-
const questionIds = new Set(interaction.questions.map(({ id }) =>
|
|
17461
|
+
const questionIds = new Set(interaction.questions.map(({ id: id2 }) => id2));
|
|
16840
17462
|
if (response.cancelled) {
|
|
16841
17463
|
return Object.keys(response.answers).length === 0 ? null : invalidRequest2("Cancelled Question Response must not contain answers");
|
|
16842
17464
|
}
|
|
@@ -16867,6 +17489,21 @@ function validateHostQuestionResponse(interaction, response) {
|
|
|
16867
17489
|
return null;
|
|
16868
17490
|
}
|
|
16869
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
|
+
|
|
16870
17507
|
// ../../harness-adapter/dist/output-channel.js
|
|
16871
17508
|
var HarnessOutputChannel = class {
|
|
16872
17509
|
outputs;
|
|
@@ -16951,7 +17588,8 @@ var tokenFields = [
|
|
|
16951
17588
|
var safeIntegerFields = [
|
|
16952
17589
|
"planFiveHourResetsAtUnix",
|
|
16953
17590
|
"planSevenDayResetsAtUnix",
|
|
16954
|
-
"timeToFirstOutputMs"
|
|
17591
|
+
"timeToFirstOutputMs",
|
|
17592
|
+
"latestRequestTimeToFirstOutputMs"
|
|
16955
17593
|
];
|
|
16956
17594
|
var percentFields = [
|
|
16957
17595
|
"cacheHitRatePercent",
|
|
@@ -17193,10 +17831,10 @@ function configureSubagentSnapshot(snapshot, parent) {
|
|
|
17193
17831
|
}
|
|
17194
17832
|
|
|
17195
17833
|
// dist/usage.js
|
|
17196
|
-
function requestTokens(
|
|
17834
|
+
function requestTokens(id2, model2, value) {
|
|
17197
17835
|
const tokens = record2(value), cache = record2(tokens.cache);
|
|
17198
17836
|
const request = parseHostUsageRequest({
|
|
17199
|
-
requestId:
|
|
17837
|
+
requestId: id2,
|
|
17200
17838
|
...model2 ? { model: model2 } : {},
|
|
17201
17839
|
inputTokens: tokens.input,
|
|
17202
17840
|
outputTokens: tokens.output,
|
|
@@ -17290,12 +17928,12 @@ var ZcodeUsage = class {
|
|
|
17290
17928
|
const pending2 = this.#pending;
|
|
17291
17929
|
if (!pending2 || pending2.turnId !== event.turnId || p.source === "subagent")
|
|
17292
17930
|
return;
|
|
17293
|
-
const
|
|
17294
|
-
if (!
|
|
17931
|
+
const id2 = text(p.assistantMessageId);
|
|
17932
|
+
if (!id2)
|
|
17295
17933
|
return;
|
|
17296
|
-
if (pending2.messageId && pending2.messageId !==
|
|
17934
|
+
if (pending2.messageId && pending2.messageId !== id2)
|
|
17297
17935
|
pending2.ambiguous = true;
|
|
17298
|
-
pending2.messageId =
|
|
17936
|
+
pending2.messageId = id2;
|
|
17299
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"))
|
|
17300
17938
|
pending2.startedAtMs = event.timestamp;
|
|
17301
17939
|
return;
|
|
@@ -17303,11 +17941,11 @@ var ZcodeUsage = class {
|
|
|
17303
17941
|
if (event.type !== "session.updated" || p.querySource !== "main_turn")
|
|
17304
17942
|
return;
|
|
17305
17943
|
if (p.type === "model_request_started") {
|
|
17306
|
-
const
|
|
17307
|
-
if (!
|
|
17944
|
+
const id2 = text(p.requestId), model2 = text(p.modelId);
|
|
17945
|
+
if (!id2 || !model2)
|
|
17308
17946
|
return;
|
|
17309
17947
|
this.#pending = {
|
|
17310
|
-
id,
|
|
17948
|
+
id: id2,
|
|
17311
17949
|
model: model2,
|
|
17312
17950
|
turnId: event.turnId,
|
|
17313
17951
|
ambiguous: this.#pending !== void 0
|
|
@@ -17423,12 +18061,13 @@ function createZcodeUsageStatistics(environment) {
|
|
|
17423
18061
|
}
|
|
17424
18062
|
];
|
|
17425
18063
|
},
|
|
17426
|
-
readSource: (
|
|
18064
|
+
readSource: (id2) => readZcodeUsage(id2)
|
|
17427
18065
|
});
|
|
17428
18066
|
}
|
|
17429
18067
|
|
|
17430
18068
|
// dist/adapter.js
|
|
17431
|
-
import
|
|
18069
|
+
import path7 from "node:path";
|
|
18070
|
+
import { isDeepStrictEqual } from "node:util";
|
|
17432
18071
|
import { stat as stat2 } from "node:fs/promises";
|
|
17433
18072
|
|
|
17434
18073
|
// dist/transport.js
|
|
@@ -17575,57 +18214,374 @@ function createZcodeInstallation(environment, app) {
|
|
|
17575
18214
|
// dist/account.js
|
|
17576
18215
|
import { createHash as createHash4 } from "node:crypto";
|
|
17577
18216
|
import { readFile as readFile3 } from "node:fs/promises";
|
|
17578
|
-
import
|
|
18217
|
+
import path6 from "node:path";
|
|
17579
18218
|
|
|
17580
18219
|
// dist/credentials.js
|
|
17581
18220
|
import { createDecipheriv, createHash } from "node:crypto";
|
|
17582
|
-
import {
|
|
18221
|
+
import { constants } from "node:fs";
|
|
18222
|
+
import { open as open2, readFile } from "node:fs/promises";
|
|
17583
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";
|
|
17584
18228
|
import path3 from "node:path";
|
|
17585
|
-
|
|
17586
|
-
|
|
17587
|
-
|
|
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) {
|
|
17588
18400
|
let username = "unknown";
|
|
17589
18401
|
try {
|
|
17590
18402
|
username = userInfo().username;
|
|
17591
18403
|
} catch {
|
|
17592
18404
|
}
|
|
17593
18405
|
const secret = environment.ZCODE_CREDENTIAL_SECRET || `zcode-credential-fallback:${platform()}:${environment.HOME || homedir2()}:${username}`;
|
|
17594
|
-
const [iv, tag, data, extra] = value.slice(
|
|
18406
|
+
const [iv, tag, data, extra] = value.slice(V1.length).split(".");
|
|
17595
18407
|
try {
|
|
17596
18408
|
if (!iv || !tag || !data || extra !== void 0)
|
|
17597
18409
|
throw new Error();
|
|
17598
|
-
const
|
|
17599
|
-
|
|
17600
|
-
|
|
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();
|
|
17601
18414
|
} catch {
|
|
17602
|
-
throw new
|
|
18415
|
+
throw new ZcodeCredentialError("Cannot decrypt ZCode credentials; ZCODE_CREDENTIAL_SECRET must match ZCode Desktop");
|
|
17603
18416
|
}
|
|
17604
18417
|
}
|
|
17605
|
-
|
|
17606
|
-
|
|
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
|
+
}
|
|
17607
18450
|
try {
|
|
17608
|
-
|
|
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 };
|
|
17609
18510
|
} catch (error51) {
|
|
17610
|
-
if (error51.code === "
|
|
17611
|
-
|
|
17612
|
-
|
|
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();
|
|
17613
18518
|
}
|
|
17614
|
-
|
|
17615
|
-
|
|
17616
|
-
|
|
17617
|
-
|
|
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;
|
|
18528
|
+
try {
|
|
18529
|
+
values = storeSchema.parse(JSON.parse(await readFile(file2, "utf8")));
|
|
18530
|
+
} catch (error51) {
|
|
18531
|
+
if (error51.code === "ENOENT")
|
|
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);
|
|
17618
18548
|
};
|
|
17619
18549
|
}
|
|
17620
|
-
|
|
17621
|
-
|
|
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;
|
|
17622
18578
|
}
|
|
17623
18579
|
|
|
17624
18580
|
// dist/personal-coding-plan.js
|
|
17625
18581
|
import { createHash as createHash3 } from "node:crypto";
|
|
17626
18582
|
import { readFile as readFile2 } from "node:fs/promises";
|
|
17627
18583
|
import { homedir as homedir3 } from "node:os";
|
|
17628
|
-
import
|
|
18584
|
+
import path5 from "node:path";
|
|
17629
18585
|
|
|
17630
18586
|
// dist/project-token.js
|
|
17631
18587
|
import { createHash as createHash2 } from "node:crypto";
|
|
@@ -17634,13 +18590,13 @@ var locationSchema = external_exports.object({
|
|
|
17634
18590
|
projectId: external_exports.string().trim().min(1),
|
|
17635
18591
|
apiKeyId: external_exports.string().trim().min(1)
|
|
17636
18592
|
});
|
|
17637
|
-
function readProjectCredential(credential, family, identity2, origin) {
|
|
18593
|
+
async function readProjectCredential(credential, family, identity2, origin, account) {
|
|
17638
18594
|
const key = `project-key-location:v1:${encodeURIComponent(JSON.stringify([origin, family, identity2, null, 1, "non-team"]))}`;
|
|
17639
|
-
const raw = credential(key);
|
|
18595
|
+
const raw = await credential(key);
|
|
17640
18596
|
if (!raw)
|
|
17641
18597
|
return void 0;
|
|
17642
18598
|
const location = locationSchema.parse(JSON.parse(raw));
|
|
17643
|
-
const login = credential(`oauth:${family}:access_token`).trim();
|
|
18599
|
+
const login = (account.linkedAccessToken ?? await credential(`oauth:${family}:access_token`)).trim();
|
|
17644
18600
|
const loginToken = login.replace(/^Bearer\s+/i, "").trim();
|
|
17645
18601
|
if (!loginToken)
|
|
17646
18602
|
throw projectCredentialError();
|
|
@@ -17649,7 +18605,10 @@ function readProjectCredential(credential, family, identity2, origin) {
|
|
|
17649
18605
|
"individual-coding-plan",
|
|
17650
18606
|
null,
|
|
17651
18607
|
login,
|
|
17652
|
-
credential("zcodejwttoken").trim() || null
|
|
18608
|
+
(await credential("zcodejwttoken")).trim() || null,
|
|
18609
|
+
account.sessionRevision || null,
|
|
18610
|
+
identity2,
|
|
18611
|
+
account.userId
|
|
17653
18612
|
])).digest("hex");
|
|
17654
18613
|
return { origin, loginToken, location, accountScope };
|
|
17655
18614
|
}
|
|
@@ -17693,17 +18652,18 @@ var ProjectToken = class {
|
|
|
17693
18652
|
if (!parsed.success || parsed.data.success === false || parsed.data.data.enable === false)
|
|
17694
18653
|
throw projectCredentialError();
|
|
17695
18654
|
const data = parsed.data.data;
|
|
18655
|
+
const token = plaintextCredential(data.accessToken);
|
|
17696
18656
|
const expiresAt = Math.min(data.expiresAt * 1e3, started + data.expiresIn * 1e3);
|
|
17697
18657
|
signal.throwIfAborted();
|
|
17698
18658
|
if (expiresAt <= Date.now())
|
|
17699
18659
|
throw projectCredentialError();
|
|
17700
18660
|
this.#cached = {
|
|
17701
18661
|
scope,
|
|
17702
|
-
token
|
|
18662
|
+
token,
|
|
17703
18663
|
expiresAt,
|
|
17704
|
-
fingerprint: createHash2("sha256").update(
|
|
18664
|
+
fingerprint: createHash2("sha256").update(token).digest("hex")
|
|
17705
18665
|
};
|
|
17706
|
-
return
|
|
18666
|
+
return token;
|
|
17707
18667
|
} catch (error51) {
|
|
17708
18668
|
signal.throwIfAborted();
|
|
17709
18669
|
if (error51 instanceof ZcodeError)
|
|
@@ -17719,6 +18679,18 @@ var ProjectToken = class {
|
|
|
17719
18679
|
var familySchema = external_exports.enum(["zai", "bigmodel"]);
|
|
17720
18680
|
var recordSchema2 = external_exports.record(external_exports.string(), external_exports.unknown());
|
|
17721
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
|
+
}
|
|
17722
18694
|
function personalCodingPlanOrigin(family, environment) {
|
|
17723
18695
|
const test = environment.ZCODE_ENV?.trim().toLowerCase() === "test";
|
|
17724
18696
|
const prefix = family === "zai" ? "ZAI" : "BIGMODEL";
|
|
@@ -17733,7 +18705,7 @@ async function readSelection(environment, family) {
|
|
|
17733
18705
|
const home = environment.ZCODE_DESKTOP_HOME_DIR?.trim() || environment.HOME?.trim() || environment.USERPROFILE?.trim() || homedir3();
|
|
17734
18706
|
let raw;
|
|
17735
18707
|
try {
|
|
17736
|
-
raw = JSON.parse(await readFile2(
|
|
18708
|
+
raw = JSON.parse(await readFile2(path5.join(home, ".zcode", "v2", "setting.json"), "utf8"));
|
|
17737
18709
|
} catch (error51) {
|
|
17738
18710
|
if (error51.code === "ENOENT")
|
|
17739
18711
|
return false;
|
|
@@ -17769,8 +18741,10 @@ async function queryEntitlement(family, apiKey, environment) {
|
|
|
17769
18741
|
try {
|
|
17770
18742
|
const response = await fetch(`${personalCodingPlanOrigin(family, environment)}/api/biz/subscription/list`, {
|
|
17771
18743
|
method: "GET",
|
|
17772
|
-
//
|
|
17773
|
-
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
|
+
},
|
|
17774
18748
|
redirect: "error",
|
|
17775
18749
|
signal: AbortSignal.timeout(15e3)
|
|
17776
18750
|
});
|
|
@@ -17805,38 +18779,52 @@ var PersonalCodingPlanAccount = class {
|
|
|
17805
18779
|
#authorized = /* @__PURE__ */ new Map();
|
|
17806
18780
|
#projectToken = new ProjectToken();
|
|
17807
18781
|
issue;
|
|
18782
|
+
credentialIssue;
|
|
18783
|
+
credentialAccessRequired = false;
|
|
17808
18784
|
constructor(installation, environment) {
|
|
17809
18785
|
this.installation = installation;
|
|
17810
18786
|
this.environment = environment;
|
|
17811
18787
|
}
|
|
17812
|
-
async #context(providerId, family) {
|
|
18788
|
+
async #context(providerId, family, existingCredential) {
|
|
17813
18789
|
const [credential, current] = await Promise.all([
|
|
17814
|
-
readCredentials(this.installation, this.environment),
|
|
18790
|
+
existingCredential ?? readCredentials(this.installation, this.environment),
|
|
17815
18791
|
readSelection(this.environment, family)
|
|
17816
18792
|
]);
|
|
17817
|
-
|
|
17818
|
-
|
|
17819
|
-
|
|
17820
|
-
|
|
17821
|
-
|
|
17822
|
-
|
|
17823
|
-
|
|
17824
|
-
|
|
17825
|
-
if (
|
|
17826
|
-
|
|
17827
|
-
|
|
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 };
|
|
17828
18814
|
if (project2)
|
|
17829
|
-
return {
|
|
18815
|
+
return { ...base, project: project2 };
|
|
17830
18816
|
const key = `account-provider:coding-plan:${providerId}:account:${encodeURIComponent(identity2)}:api-key`;
|
|
17831
|
-
return {
|
|
18817
|
+
return { ...base, apiKey: (await credential(key)).trim() };
|
|
17832
18818
|
}
|
|
17833
|
-
async inspect(providerId, accountType) {
|
|
18819
|
+
async inspect(providerId, accountType, existingCredential) {
|
|
17834
18820
|
const family = familySchema.parse(accountType);
|
|
17835
18821
|
this.#authorized.delete(providerId);
|
|
17836
18822
|
this.issue = void 0;
|
|
18823
|
+
this.credentialIssue = void 0;
|
|
18824
|
+
this.credentialAccessRequired = false;
|
|
17837
18825
|
let current = false;
|
|
17838
18826
|
try {
|
|
17839
|
-
const context = await this.#context(providerId, family);
|
|
18827
|
+
const context = await this.#context(providerId, family, existingCredential);
|
|
17840
18828
|
if (!context)
|
|
17841
18829
|
return {
|
|
17842
18830
|
availability: "unavailable",
|
|
@@ -17847,7 +18835,7 @@ var PersonalCodingPlanAccount = class {
|
|
|
17847
18835
|
current = context.current;
|
|
17848
18836
|
const connectionKey = createHash3("sha256").update(JSON.stringify([family, context.identity, "individual-coding-plan"])).digest("hex");
|
|
17849
18837
|
const base = { current, connectionKey };
|
|
17850
|
-
if (!context.apiKey) {
|
|
18838
|
+
if (!context.project && !context.apiKey) {
|
|
17851
18839
|
if (current)
|
|
17852
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.";
|
|
17853
18841
|
return {
|
|
@@ -17857,13 +18845,14 @@ var PersonalCodingPlanAccount = class {
|
|
|
17857
18845
|
unavailableReason: "credential-failed"
|
|
17858
18846
|
};
|
|
17859
18847
|
}
|
|
17860
|
-
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);
|
|
17861
18850
|
const after = await this.#context(providerId, family);
|
|
17862
|
-
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))
|
|
17863
18852
|
return { availability: "unknown", entitled: false, current: false };
|
|
17864
18853
|
if (entitlement === "available") {
|
|
17865
18854
|
if (current)
|
|
17866
|
-
this.#authorized.set(providerId, { family,
|
|
18855
|
+
this.#authorized.set(providerId, { family, account: context.account });
|
|
17867
18856
|
return { ...base, availability: "available", entitled: true };
|
|
17868
18857
|
}
|
|
17869
18858
|
if (current)
|
|
@@ -17876,10 +18865,15 @@ var PersonalCodingPlanAccount = class {
|
|
|
17876
18865
|
unavailableReason: entitlement === "unavailable" ? "not-entitled" : "credential-failed"
|
|
17877
18866
|
}
|
|
17878
18867
|
};
|
|
17879
|
-
} catch {
|
|
18868
|
+
} catch (error51) {
|
|
17880
18869
|
current = await readSelection(this.environment, family).catch(() => false);
|
|
17881
|
-
if (current)
|
|
17882
|
-
|
|
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
|
+
}
|
|
17883
18877
|
return { availability: "unknown", entitled: false, current };
|
|
17884
18878
|
}
|
|
17885
18879
|
}
|
|
@@ -17904,7 +18898,7 @@ var PersonalCodingPlanAccount = class {
|
|
|
17904
18898
|
signal.throwIfAborted();
|
|
17905
18899
|
const context = await this.#context(providerId, authorized.family);
|
|
17906
18900
|
signal.throwIfAborted();
|
|
17907
|
-
if (!context?.current || context.
|
|
18901
|
+
if (!context?.current || context.account !== authorized.account)
|
|
17908
18902
|
throw new ZcodeError("authenticationRequired", CONNECT);
|
|
17909
18903
|
if (context.project) {
|
|
17910
18904
|
const { expectedAccountScope, rejectedProjectTokenFingerprint } = parsed.data;
|
|
@@ -17913,7 +18907,7 @@ var PersonalCodingPlanAccount = class {
|
|
|
17913
18907
|
const apiKey = await this.#projectToken.resolve(context.project, this.installation.version, signal, rejectedProjectTokenFingerprint);
|
|
17914
18908
|
const after = await this.#context(providerId, authorized.family);
|
|
17915
18909
|
signal.throwIfAborted();
|
|
17916
|
-
if (!after?.current || after.
|
|
18910
|
+
if (!after?.current || after.account !== context.account || JSON.stringify(after.project) !== JSON.stringify(context.project))
|
|
17917
18911
|
throw new ZcodeError("authenticationRequired", CONNECT);
|
|
17918
18912
|
return {
|
|
17919
18913
|
apiKey,
|
|
@@ -17921,7 +18915,7 @@ var PersonalCodingPlanAccount = class {
|
|
|
17921
18915
|
accountScope: context.project.accountScope
|
|
17922
18916
|
};
|
|
17923
18917
|
}
|
|
17924
|
-
if (parsed.data.expectedAccountScope !== void 0 || parsed.data.rejectedProjectTokenFingerprint)
|
|
18918
|
+
if (!context.apiKey || parsed.data.expectedAccountScope !== void 0 || parsed.data.rejectedProjectTokenFingerprint)
|
|
17925
18919
|
throw new ZcodeError("authenticationRequired", CONNECT);
|
|
17926
18920
|
return { apiKey: context.apiKey };
|
|
17927
18921
|
}
|
|
@@ -17948,7 +18942,7 @@ function resolveEndpointOrigin(environment) {
|
|
|
17948
18942
|
}
|
|
17949
18943
|
async function readDeviceMid(installation) {
|
|
17950
18944
|
try {
|
|
17951
|
-
const file2 =
|
|
18945
|
+
const file2 = path6.join(installation.dataRoot, "telemetry-state.json");
|
|
17952
18946
|
const parsed = JSON.parse(await readFile3(file2, "utf8"));
|
|
17953
18947
|
return typeof parsed?.deviceMid === "string" ? parsed.deviceMid.trim() : "";
|
|
17954
18948
|
} catch {
|
|
@@ -17982,9 +18976,9 @@ function resolveStartPlanModels(data, builtinModelIds) {
|
|
|
17982
18976
|
const validPlans = data.plans.filter((plan) => {
|
|
17983
18977
|
if (plan.status?.trim().toLowerCase() !== "active")
|
|
17984
18978
|
return false;
|
|
17985
|
-
const
|
|
18979
|
+
const id2 = plan.plan_id?.trim().toLowerCase();
|
|
17986
18980
|
const name = plan.name?.trim().toLowerCase();
|
|
17987
|
-
const isStart = !
|
|
18981
|
+
const isStart = !id2 && !name || id2?.includes("start-plan") || id2?.includes("start plan") || name?.includes("start-plan") || name?.includes("start plan");
|
|
17988
18982
|
if (!isStart)
|
|
17989
18983
|
return false;
|
|
17990
18984
|
const ends = Number(plan.ends_at);
|
|
@@ -18009,7 +19003,7 @@ function resolveStartPlanModels(data, builtinModelIds) {
|
|
|
18009
19003
|
for (const raw of candidates) {
|
|
18010
19004
|
if (!raw)
|
|
18011
19005
|
continue;
|
|
18012
|
-
const normalized = builtinModelIds?.find((
|
|
19006
|
+
const normalized = builtinModelIds?.find((id2) => id2.toLowerCase() === raw.toLowerCase()) ?? raw;
|
|
18013
19007
|
const key = normalized.toLowerCase();
|
|
18014
19008
|
if (!seen.has(key)) {
|
|
18015
19009
|
seen.add(key);
|
|
@@ -18019,6 +19013,12 @@ function resolveStartPlanModels(data, builtinModelIds) {
|
|
|
18019
19013
|
}
|
|
18020
19014
|
return models;
|
|
18021
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
|
+
}
|
|
18022
19022
|
async function queryStartPlanBalance(origin, appVersion, jwt2, deviceMid) {
|
|
18023
19023
|
try {
|
|
18024
19024
|
const url2 = new URL(`${origin}/api/v1/zcode-plan/billing/balance`);
|
|
@@ -18045,22 +19045,31 @@ async function queryStartPlanBalance(origin, appVersion, jwt2, deviceMid) {
|
|
|
18045
19045
|
return void 0;
|
|
18046
19046
|
}
|
|
18047
19047
|
}
|
|
18048
|
-
async function accountConfig(installation, environment) {
|
|
19048
|
+
async function accountConfig(installation, environment, readSystemKeyOptions) {
|
|
18049
19049
|
const file2 = installation.builtinProviderConfig;
|
|
18050
19050
|
const builtin = builtinSchema.parse(JSON.parse(await readFile3(file2, "utf8")));
|
|
18051
|
-
const basedOnZCodeBuiltinRevision = `zcode-builtin:${builtin.revision}:${createHash4("sha256").update(
|
|
18052
|
-
|
|
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;
|
|
18053
19055
|
let balanceData;
|
|
18054
|
-
|
|
18055
|
-
|
|
18056
|
-
|
|
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);
|
|
18057
19062
|
const deviceMid = await readDeviceMid(installation);
|
|
18058
19063
|
if (jwt2 && deviceMid) {
|
|
18059
19064
|
const origin = resolveEndpointOrigin(environment);
|
|
18060
19065
|
balanceData = await queryStartPlanBalance(origin, installation.version, jwt2, deviceMid);
|
|
18061
19066
|
}
|
|
18062
|
-
} catch {
|
|
18063
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.`;
|
|
18064
19073
|
}
|
|
18065
19074
|
let startPlan = false;
|
|
18066
19075
|
const codingPlan = new PersonalCodingPlanAccount(installation, environment);
|
|
@@ -18068,10 +19077,10 @@ async function accountConfig(installation, environment) {
|
|
|
18068
19077
|
const states = {};
|
|
18069
19078
|
for (const rule of builtin.config.providerConfigRules.providerRules) {
|
|
18070
19079
|
const access = rule.config.access;
|
|
18071
|
-
if (!
|
|
19080
|
+
if (!channel || access?.accountType !== startFamily(channel))
|
|
18072
19081
|
continue;
|
|
18073
|
-
if (access.mode === "individual-coding-plan"
|
|
18074
|
-
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);
|
|
18075
19084
|
providers[rule.providerId] = {
|
|
18076
19085
|
access: { type: "zhipu-account", entitled: state.entitled }
|
|
18077
19086
|
};
|
|
@@ -18103,19 +19112,22 @@ async function accountConfig(installation, environment) {
|
|
|
18103
19112
|
const overlayDigest = createHash4("sha256").update(JSON.stringify([providers, states])).digest("hex").slice(0, 16);
|
|
18104
19113
|
return {
|
|
18105
19114
|
params: {
|
|
18106
|
-
revision: `codexhost:${
|
|
19115
|
+
revision: `codexhost:${channel ?? (credentialIssue ? "credentials-unavailable" : "signed-out")}:${builtin.revision}:${overlayDigest}`,
|
|
18107
19116
|
basedOnZCodeBuiltinRevision,
|
|
18108
19117
|
providers,
|
|
18109
19118
|
states
|
|
18110
19119
|
},
|
|
18111
19120
|
startPlan,
|
|
18112
|
-
signedIn: Boolean(
|
|
18113
|
-
startPlanChecked: !
|
|
19121
|
+
signedIn: Boolean(channel),
|
|
19122
|
+
startPlanChecked: !credentialIssue && (!channel || balanceData !== void 0),
|
|
19123
|
+
...credentialIssue ? { credentialIssue } : {},
|
|
19124
|
+
credentialAccessRequired,
|
|
18114
19125
|
codingPlan
|
|
18115
19126
|
};
|
|
18116
19127
|
}
|
|
18117
19128
|
async function providerRuntimeHeaders(request, signal, installation, environment, verifier, codingPlan) {
|
|
18118
|
-
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;
|
|
18119
19131
|
try {
|
|
18120
19132
|
signal.throwIfAborted();
|
|
18121
19133
|
if (mode === "individual-coding-plan")
|
|
@@ -18125,7 +19137,11 @@ async function providerRuntimeHeaders(request, signal, installation, environment
|
|
|
18125
19137
|
headersApplied: false,
|
|
18126
19138
|
errorMessage: "codexhost supports ZCode Start Plan and Personal Coding Plan; Team Coding Plan is not supported"
|
|
18127
19139
|
};
|
|
18128
|
-
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);
|
|
18129
19145
|
if (!apiKey)
|
|
18130
19146
|
return { headersApplied: false, errorMessage: SIGN_IN };
|
|
18131
19147
|
const headers = await verifier().verify(signal);
|
|
@@ -18176,11 +19192,11 @@ var calls = {
|
|
|
18176
19192
|
workspace: context.workspace
|
|
18177
19193
|
}
|
|
18178
19194
|
}),
|
|
18179
|
-
unsubscribeConversationV4: ({ sessionId, subscriptionId }, context) => ({
|
|
19195
|
+
unsubscribeConversationV4: ({ sessionId, subscriptionId: subscriptionId2 }, context) => ({
|
|
18180
19196
|
method: "v4/conversation/unsubscribe",
|
|
18181
19197
|
params: {
|
|
18182
19198
|
topic: `conversation/${String(sessionId)}`,
|
|
18183
|
-
subscriptionId,
|
|
19199
|
+
subscriptionId: subscriptionId2,
|
|
18184
19200
|
connectionId: context.connectionId
|
|
18185
19201
|
}
|
|
18186
19202
|
}),
|
|
@@ -18221,6 +19237,8 @@ var CliTransport = class {
|
|
|
18221
19237
|
#startPlan = false;
|
|
18222
19238
|
#signedIn = false;
|
|
18223
19239
|
#startPlanChecked = true;
|
|
19240
|
+
#credentialIssue;
|
|
19241
|
+
#credentialAccessRequired = false;
|
|
18224
19242
|
#codingPlan;
|
|
18225
19243
|
#fault;
|
|
18226
19244
|
#closed = false;
|
|
@@ -18241,6 +19259,12 @@ var CliTransport = class {
|
|
|
18241
19259
|
get startPlanChecked() {
|
|
18242
19260
|
return this.#startPlanChecked;
|
|
18243
19261
|
}
|
|
19262
|
+
get credentialIssue() {
|
|
19263
|
+
return this.#credentialIssue ?? this.#codingPlan?.credentialIssue;
|
|
19264
|
+
}
|
|
19265
|
+
get credentialAccessRequired() {
|
|
19266
|
+
return this.#credentialAccessRequired || this.#codingPlan?.credentialAccessRequired === true;
|
|
19267
|
+
}
|
|
18244
19268
|
get codingPlanIssue() {
|
|
18245
19269
|
return this.#codingPlan?.issue;
|
|
18246
19270
|
}
|
|
@@ -18255,11 +19279,13 @@ var CliTransport = class {
|
|
|
18255
19279
|
if (this.#child || this.#closed)
|
|
18256
19280
|
throw new ZcodeError("invalidState", "ZCode transport already started or closed");
|
|
18257
19281
|
const installation = await resolveInstallation(this.options.environment, this.options.app);
|
|
18258
|
-
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);
|
|
18259
19283
|
this.#installation = installation;
|
|
18260
19284
|
this.#startPlan = startPlan;
|
|
18261
19285
|
this.#signedIn = signedIn;
|
|
18262
19286
|
this.#startPlanChecked = startPlanChecked;
|
|
19287
|
+
this.#credentialIssue = credentialIssue;
|
|
19288
|
+
this.#credentialAccessRequired = credentialAccessRequired;
|
|
18263
19289
|
this.#codingPlan = codingPlan;
|
|
18264
19290
|
const child = spawn(installation.runtime, [installation.cli, "app-server", "--stdio", "--surface", "desktop"], {
|
|
18265
19291
|
cwd: this.options.cwd,
|
|
@@ -18366,12 +19392,12 @@ var CliTransport = class {
|
|
|
18366
19392
|
listener(params);
|
|
18367
19393
|
}
|
|
18368
19394
|
#emitSession(sessionId, value) {
|
|
18369
|
-
for (const [listener,
|
|
18370
|
-
if (
|
|
19395
|
+
for (const [listener, id2] of this.#sessionListeners)
|
|
19396
|
+
if (id2 === sessionId)
|
|
18371
19397
|
listener(value);
|
|
18372
19398
|
}
|
|
18373
|
-
async #answer(
|
|
18374
|
-
const reply = (body) => this.#write({ id, ...body });
|
|
19399
|
+
async #answer(id2, method, params) {
|
|
19400
|
+
const reply = (body) => this.#write({ id: id2, ...body });
|
|
18375
19401
|
if (method === "session/requestRuntimePreferences")
|
|
18376
19402
|
reply({ result: RUNTIME_PREFERENCES });
|
|
18377
19403
|
else if (method === "interaction/requestPermission" || method === "interaction/requestUserInput") {
|
|
@@ -18417,11 +19443,11 @@ var CliTransport = class {
|
|
|
18417
19443
|
#call(method, params, timeoutMs) {
|
|
18418
19444
|
if (!this.#child || this.#closed || this.#fault)
|
|
18419
19445
|
return Promise.reject(this.#fault ?? new ZcodeError("invalidState", "ZCode is closed"));
|
|
18420
|
-
const
|
|
19446
|
+
const id2 = ++this.#nextId;
|
|
18421
19447
|
return new Promise((resolve, reject) => {
|
|
18422
19448
|
const timer = setTimeout(() => this.#fail(new ZcodeError("unavailable", "ZCode request timed out; delivery is unconfirmed")), timeoutMs ?? this.options.timeoutMs ?? DEFAULT_TIMEOUT_MS);
|
|
18423
|
-
this.#pending.set(
|
|
18424
|
-
this.#write({ id, method, params });
|
|
19449
|
+
this.#pending.set(id2, { resolve, reject, timer });
|
|
19450
|
+
this.#write({ id: id2, method, params });
|
|
18425
19451
|
});
|
|
18426
19452
|
}
|
|
18427
19453
|
request(method, params = {}) {
|
|
@@ -19115,34 +20141,56 @@ function createZcodeVerifier(options) {
|
|
|
19115
20141
|
};
|
|
19116
20142
|
}
|
|
19117
20143
|
|
|
20144
|
+
// dist/session.js
|
|
20145
|
+
import { randomUUID as randomUUID2 } from "node:crypto";
|
|
20146
|
+
|
|
19118
20147
|
// dist/models.js
|
|
19119
20148
|
var ZCODE_ID = harnessIdSchema.parse("zcode");
|
|
19120
|
-
function
|
|
19121
|
-
return
|
|
19122
|
-
id: `zcode-local-v1.${Buffer.from(JSON.stringify([model2.providerId, model2.modelId])).toString("base64url")}`
|
|
19123
|
-
});
|
|
20149
|
+
function readableId({ providerId, modelId: modelId2 }) {
|
|
20150
|
+
return `${providerId}/${modelId2}`;
|
|
19124
20151
|
}
|
|
19125
|
-
function
|
|
19126
|
-
|
|
19127
|
-
|
|
19128
|
-
|
|
19129
|
-
|
|
19130
|
-
|
|
19131
|
-
|
|
19132
|
-
|
|
19133
|
-
|
|
19134
|
-
|
|
19135
|
-
|
|
19136
|
-
|
|
19137
|
-
|
|
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) });
|
|
20183
|
+
}
|
|
20184
|
+
function normalizeStoredZcodeModelRef(ref, index) {
|
|
20185
|
+
return ref.serviceTier ? void 0 : index.byLegacy.get(ref.id);
|
|
19138
20186
|
}
|
|
19139
|
-
function selectNativeModel(model2,
|
|
19140
|
-
const
|
|
19141
|
-
const entry = settings.model.available.find((entry2) => encodeModel(entry2.ref).id === model2.id && !entry2.disabledReason);
|
|
20187
|
+
function selectNativeModel(model2, index, current, thinkingOption) {
|
|
20188
|
+
const entry = !model2.serviceTier && index.ids.get(model2.id)?.entry;
|
|
19142
20189
|
if (!entry)
|
|
19143
20190
|
throw new ZcodeError("invalidRequest", "ZCode model is not available");
|
|
19144
|
-
const
|
|
19145
|
-
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;
|
|
19146
20194
|
if (level === void 0)
|
|
19147
20195
|
return native;
|
|
19148
20196
|
if (!entry.reasoning?.levels.some((option) => option.value === level))
|
|
@@ -19155,18 +20203,20 @@ function modelCatalog(settings) {
|
|
|
19155
20203
|
for (const model2 of available)
|
|
19156
20204
|
for (const level of model2.reasoning?.levels ?? [])
|
|
19157
20205
|
levels.set(level.value, level);
|
|
19158
|
-
const
|
|
20206
|
+
const index = modelIndex(available);
|
|
20207
|
+
const current = settings.model.current ? index.encode(settings.model.current) : void 0;
|
|
19159
20208
|
const defaultThinking = settings.thoughtLevel.current ?? settings.thoughtLevel.defaultLevel;
|
|
19160
|
-
|
|
20209
|
+
const catalog = harnessModelCatalogSchema.parse({
|
|
19161
20210
|
models: available.map((model2) => ({
|
|
19162
|
-
ref:
|
|
20211
|
+
ref: index.encode(model2.ref),
|
|
19163
20212
|
label: model2.label,
|
|
19164
20213
|
supportedThinkingOptionIds: model2.reasoning?.enabled ? model2.reasoning.levels.map((level) => level.value) : []
|
|
19165
20214
|
})),
|
|
19166
|
-
...current &&
|
|
20215
|
+
...current && index.ids.has(current.id) ? { defaultModel: current } : {},
|
|
19167
20216
|
thinkingOptions: [...levels.values()].map((level) => ({ id: level.value, label: level.label })),
|
|
19168
20217
|
...defaultThinking && levels.has(defaultThinking) ? { defaultThinkingOptionId: defaultThinking } : {}
|
|
19169
20218
|
});
|
|
20219
|
+
return { catalog, index };
|
|
19170
20220
|
}
|
|
19171
20221
|
var modeLabels = {
|
|
19172
20222
|
build: "Confirm changes",
|
|
@@ -19184,19 +20234,20 @@ var chineseModeLabels = {
|
|
|
19184
20234
|
};
|
|
19185
20235
|
function permissionModes(current = "build") {
|
|
19186
20236
|
return harnessPermissionModeCatalogSchema.parse({
|
|
19187
|
-
modes: Object.entries(modeLabels).map(([
|
|
19188
|
-
id,
|
|
20237
|
+
modes: Object.entries(modeLabels).map(([id2, label]) => ({
|
|
20238
|
+
id: id2,
|
|
19189
20239
|
label,
|
|
19190
|
-
localizations: { "zh-CN": { label: chineseModeLabels[
|
|
19191
|
-
...
|
|
20240
|
+
localizations: { "zh-CN": { label: chineseModeLabels[id2] } },
|
|
20241
|
+
...id2 === "yolo" ? { dangerous: true } : {}
|
|
19192
20242
|
})),
|
|
19193
20243
|
defaultModeId: current
|
|
19194
20244
|
});
|
|
19195
20245
|
}
|
|
19196
|
-
function sessionState(snapshot, locator) {
|
|
20246
|
+
function sessionState(snapshot, locator, index = modelCatalog(snapshot.settings).index) {
|
|
19197
20247
|
const settings = snapshot.settings;
|
|
19198
|
-
const
|
|
19199
|
-
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));
|
|
19200
20251
|
return {
|
|
19201
20252
|
nativeRef: nativeSessionRefSchema.parse({
|
|
19202
20253
|
harnessId: ZCODE_ID,
|
|
@@ -19235,9 +20286,6 @@ function sessionUsage(snapshot, catalog) {
|
|
|
19235
20286
|
return Object.keys(usage).length > 0 ? parseHostUsage(usage) : null;
|
|
19236
20287
|
}
|
|
19237
20288
|
|
|
19238
|
-
// dist/session.js
|
|
19239
|
-
import { randomUUID as randomUUID2 } from "node:crypto";
|
|
19240
|
-
|
|
19241
20289
|
// ../../../node_modules/diff/libesm/diff/base.js
|
|
19242
20290
|
var Diff = class {
|
|
19243
20291
|
diff(oldStr, newStr, options = {}) {
|
|
@@ -19338,16 +20386,16 @@ var Diff = class {
|
|
|
19338
20386
|
}
|
|
19339
20387
|
}
|
|
19340
20388
|
}
|
|
19341
|
-
addToPath(
|
|
19342
|
-
const last =
|
|
20389
|
+
addToPath(path8, added, removed, oldPosInc, options) {
|
|
20390
|
+
const last = path8.lastComponent;
|
|
19343
20391
|
if (last && !options.oneChangePerToken && last.added === added && last.removed === removed) {
|
|
19344
20392
|
return {
|
|
19345
|
-
oldPos:
|
|
20393
|
+
oldPos: path8.oldPos + oldPosInc,
|
|
19346
20394
|
lastComponent: { count: last.count + 1, added, removed, previousComponent: last.previousComponent }
|
|
19347
20395
|
};
|
|
19348
20396
|
} else {
|
|
19349
20397
|
return {
|
|
19350
|
-
oldPos:
|
|
20398
|
+
oldPos: path8.oldPos + oldPosInc,
|
|
19351
20399
|
lastComponent: { count: 1, added, removed, previousComponent: last }
|
|
19352
20400
|
};
|
|
19353
20401
|
}
|
|
@@ -19675,15 +20723,15 @@ function toolOutput(value) {
|
|
|
19675
20723
|
function fileChanges(value) {
|
|
19676
20724
|
const result = record2(value), nested = record2(result.data);
|
|
19677
20725
|
const data = typeof result.filePath === "string" ? result : nested;
|
|
19678
|
-
const
|
|
19679
|
-
if (!
|
|
20726
|
+
const filePath2 = text(data.filePath);
|
|
20727
|
+
if (!filePath2)
|
|
19680
20728
|
return [];
|
|
19681
20729
|
if ((typeof data.originalFile === "string" || data.originalFile === null) && typeof data.content === "string") {
|
|
19682
|
-
const diff = createPatch(
|
|
20730
|
+
const diff = createPatch(filePath2, data.originalFile ?? "", data.content);
|
|
19683
20731
|
if (diff.length > OUTPUT_LIMIT)
|
|
19684
20732
|
return [];
|
|
19685
20733
|
return [
|
|
19686
|
-
{ path:
|
|
20734
|
+
{ path: filePath2, kind: data.originalFile === null ? "add" : "update", unifiedDiff: diff }
|
|
19687
20735
|
];
|
|
19688
20736
|
}
|
|
19689
20737
|
if (Array.isArray(data.structuredPatch)) {
|
|
@@ -19691,26 +20739,26 @@ function fileChanges(value) {
|
|
|
19691
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")))
|
|
19692
20740
|
return [];
|
|
19693
20741
|
const diff = [
|
|
19694
|
-
`--- a/${
|
|
19695
|
-
`+++ b/${
|
|
20742
|
+
`--- a/${filePath2}`,
|
|
20743
|
+
`+++ b/${filePath2}`,
|
|
19696
20744
|
...hunks.flatMap((hunk) => [
|
|
19697
20745
|
`@@ -${hunk.oldStart},${hunk.oldLines} +${hunk.newStart},${hunk.newLines} @@`,
|
|
19698
20746
|
...hunk.lines
|
|
19699
20747
|
])
|
|
19700
20748
|
].join("\n") + "\n";
|
|
19701
|
-
return diff.length <= OUTPUT_LIMIT ? [{ path:
|
|
20749
|
+
return diff.length <= OUTPUT_LIMIT ? [{ path: filePath2, kind: data.originalFile === null ? "add" : "update", unifiedDiff: diff }] : [];
|
|
19702
20750
|
}
|
|
19703
20751
|
return [];
|
|
19704
20752
|
}
|
|
19705
20753
|
function subagent(value, input, fallback) {
|
|
19706
20754
|
const result = record2(value), data = record2(result.data), args = record2(input);
|
|
19707
|
-
const
|
|
19708
|
-
if (!
|
|
20755
|
+
const id2 = text(result.childSessionId) || text(data.childSessionId) || text(result.agentId) || text(data.agentId);
|
|
20756
|
+
if (!id2)
|
|
19709
20757
|
return;
|
|
19710
20758
|
const status = text(result.status) || text(data.status);
|
|
19711
20759
|
return {
|
|
19712
|
-
subagentId:
|
|
19713
|
-
nativeSubagentId:
|
|
20760
|
+
subagentId: id2,
|
|
20761
|
+
nativeSubagentId: id2,
|
|
19714
20762
|
description: text(args.description) || text(args.prompt) || fallback,
|
|
19715
20763
|
...text(args.subagent_type) || text(args.agentType) ? { role: text(args.subagent_type) || text(args.agentType) } : {},
|
|
19716
20764
|
...subagentConfiguration(args),
|
|
@@ -19721,8 +20769,8 @@ function subagent(value, input, fallback) {
|
|
|
19721
20769
|
...text(result.output) ? { resultSummary: text(result.output).slice(0, OUTPUT_LIMIT) } : {}
|
|
19722
20770
|
};
|
|
19723
20771
|
}
|
|
19724
|
-
function makeTool(
|
|
19725
|
-
const itemId = hostItemIdSchema.parse(
|
|
20772
|
+
function makeTool(id2, name, input, cwd) {
|
|
20773
|
+
const itemId = hostItemIdSchema.parse(id2), args = record2(input);
|
|
19726
20774
|
if (name.toLowerCase() === "bash")
|
|
19727
20775
|
return { type: "commandExecution", itemId, command: text(args.command), cwd };
|
|
19728
20776
|
return {
|
|
@@ -19845,21 +20893,21 @@ var TurnProjection = class {
|
|
|
19845
20893
|
}
|
|
19846
20894
|
if (!kind.startsWith("text_") && !reasoning)
|
|
19847
20895
|
return;
|
|
19848
|
-
let
|
|
19849
|
-
if (kind.endsWith("_start") || !
|
|
19850
|
-
|
|
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}`;
|
|
19851
20899
|
if (reasoning)
|
|
19852
|
-
this.#reasoningId =
|
|
20900
|
+
this.#reasoningId = id3;
|
|
19853
20901
|
else
|
|
19854
|
-
this.#textId =
|
|
20902
|
+
this.#textId = id3;
|
|
19855
20903
|
this.start({
|
|
19856
20904
|
type: reasoning ? "reasoning" : "agentMessage",
|
|
19857
|
-
itemId: hostItemIdSchema.parse(
|
|
20905
|
+
itemId: hostItemIdSchema.parse(id3),
|
|
19858
20906
|
text: ""
|
|
19859
20907
|
});
|
|
19860
20908
|
}
|
|
19861
|
-
const item2 = this.items.get(
|
|
19862
|
-
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")
|
|
19863
20911
|
return;
|
|
19864
20912
|
if (typeof p.delta === "string" && p.delta) {
|
|
19865
20913
|
item2.text += p.delta;
|
|
@@ -19880,7 +20928,7 @@ var TurnProjection = class {
|
|
|
19880
20928
|
return;
|
|
19881
20929
|
}
|
|
19882
20930
|
if (event.type === "session.updated" && text(p.childSessionId) && text(p.parentToolCallId)) {
|
|
19883
|
-
const
|
|
20931
|
+
const id3 = `${text(p.parentToolCallId)}:agent`, existing = this.items.get(id3);
|
|
19884
20932
|
const child2 = subagent(p, p, text(p.agentType));
|
|
19885
20933
|
if (!child2)
|
|
19886
20934
|
return;
|
|
@@ -19904,7 +20952,7 @@ var TurnProjection = class {
|
|
|
19904
20952
|
} else
|
|
19905
20953
|
this.start({
|
|
19906
20954
|
type: "subagentDelegation",
|
|
19907
|
-
itemId: hostItemIdSchema.parse(
|
|
20955
|
+
itemId: hostItemIdSchema.parse(id3),
|
|
19908
20956
|
operation: "spawn",
|
|
19909
20957
|
prompt: text(p.prompt),
|
|
19910
20958
|
subagents: [child2]
|
|
@@ -19924,15 +20972,15 @@ var TurnProjection = class {
|
|
|
19924
20972
|
}
|
|
19925
20973
|
if (event.type !== "tool.updated" || p.source === "subagent")
|
|
19926
20974
|
return;
|
|
19927
|
-
const
|
|
19928
|
-
if (!
|
|
20975
|
+
const id2 = text(p.toolCallId);
|
|
20976
|
+
if (!id2)
|
|
19929
20977
|
return;
|
|
19930
20978
|
if (p.kind === "scheduled") {
|
|
19931
|
-
this.start(makeTool(
|
|
20979
|
+
this.start(makeTool(id2, text(p.toolName), p.input, this.cwd));
|
|
19932
20980
|
return;
|
|
19933
20981
|
}
|
|
19934
|
-
const item = this.items.get(
|
|
19935
|
-
if (!item || this.completed.has(
|
|
20982
|
+
const item = this.items.get(id2);
|
|
20983
|
+
if (!item || this.completed.has(id2))
|
|
19936
20984
|
return;
|
|
19937
20985
|
if (p.kind === "progress" && item.type === "commandExecution") {
|
|
19938
20986
|
const next = (text(p.stdoutTail) + text(p.stderrTail)).slice(-OUTPUT_LIMIT);
|
|
@@ -19981,7 +21029,7 @@ var TurnProjection = class {
|
|
|
19981
21029
|
this.complete({
|
|
19982
21030
|
item: {
|
|
19983
21031
|
type: "fileChange",
|
|
19984
|
-
itemId: hostItemIdSchema.parse(`${
|
|
21032
|
+
itemId: hostItemIdSchema.parse(`${id2}:files`),
|
|
19985
21033
|
changes,
|
|
19986
21034
|
sourceItemIds: [item.itemId]
|
|
19987
21035
|
},
|
|
@@ -19992,7 +21040,7 @@ var TurnProjection = class {
|
|
|
19992
21040
|
this.complete({
|
|
19993
21041
|
item: {
|
|
19994
21042
|
type: "subagentDelegation",
|
|
19995
|
-
itemId: hostItemIdSchema.parse(`${
|
|
21043
|
+
itemId: hostItemIdSchema.parse(`${id2}:agent`),
|
|
19996
21044
|
operation: "spawn",
|
|
19997
21045
|
subagents: [child]
|
|
19998
21046
|
},
|
|
@@ -20074,7 +21122,7 @@ function messageOutcome(message) {
|
|
|
20074
21122
|
return { status: "succeeded" };
|
|
20075
21123
|
return { status: "unknown", reason: "The persisted ZCode turn has no terminal result" };
|
|
20076
21124
|
}
|
|
20077
|
-
function history(snapshot, events = [], locator) {
|
|
21125
|
+
function history(snapshot, events = [], locator, index = modelCatalog(snapshot.settings).index) {
|
|
20078
21126
|
const outcomes = /* @__PURE__ */ new Map();
|
|
20079
21127
|
const nativeKeys = /* @__PURE__ */ new Map();
|
|
20080
21128
|
for (const event of events) {
|
|
@@ -20105,7 +21153,7 @@ function history(snapshot, events = [], locator) {
|
|
|
20105
21153
|
items: assistants.flatMap((message) => message.parts.flatMap((part) => projectPart(part, snapshot.session.workspace.workspacePath))),
|
|
20106
21154
|
outcome,
|
|
20107
21155
|
...user.info.model ? {
|
|
20108
|
-
model: encodeModel(user.info.model)
|
|
21156
|
+
model: encodeModel(user.info.model, index)
|
|
20109
21157
|
} : {},
|
|
20110
21158
|
startedAtMs: user.info.time.created,
|
|
20111
21159
|
...completedAtMs !== void 0 ? { completedAtMs } : {}
|
|
@@ -20121,7 +21169,7 @@ function history(snapshot, events = [], locator) {
|
|
|
20121
21169
|
current.assistants.push(message);
|
|
20122
21170
|
}
|
|
20123
21171
|
finish();
|
|
20124
|
-
return { turns, state: sessionState(snapshot, locator) };
|
|
21172
|
+
return { turns, state: sessionState(snapshot, locator, index) };
|
|
20125
21173
|
}
|
|
20126
21174
|
|
|
20127
21175
|
// dist/interactions.js
|
|
@@ -20260,7 +21308,7 @@ function goalArguments(value) {
|
|
|
20260
21308
|
async function withConversation(transport, source, work) {
|
|
20261
21309
|
const sessionId = source.session.sessionId;
|
|
20262
21310
|
const ready = Promise.withResolvers();
|
|
20263
|
-
let
|
|
21311
|
+
let subscriptionId2 = "";
|
|
20264
21312
|
const timer = setTimeout(() => ready.reject(new ZcodeError("protocolError", "ZCode did not provide a conversation revision")), transport.options.timeoutMs ?? 3e4);
|
|
20265
21313
|
void ready.promise.catch(() => void 0);
|
|
20266
21314
|
const dispose = await transport.listen("onDynamicConversationFrame", {}, (value) => {
|
|
@@ -20270,8 +21318,8 @@ async function withConversation(transport, source, work) {
|
|
|
20270
21318
|
});
|
|
20271
21319
|
try {
|
|
20272
21320
|
const result = record2(await transport.request("subscribeConversationV4", { sessionId }));
|
|
20273
|
-
|
|
20274
|
-
if (!
|
|
21321
|
+
subscriptionId2 = text(record2(result.ack).subscriptionId);
|
|
21322
|
+
if (!subscriptionId2)
|
|
20275
21323
|
throw new ZcodeError("protocolError", "ZCode subscription has no identity");
|
|
20276
21324
|
const state = await ready.promise;
|
|
20277
21325
|
const rows = [];
|
|
@@ -20288,7 +21336,7 @@ async function withConversation(transport, source, work) {
|
|
|
20288
21336
|
rows.unshift(...incoming);
|
|
20289
21337
|
if (batch.hasMore !== true)
|
|
20290
21338
|
return await work({ ...state, rows });
|
|
20291
|
-
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];
|
|
20292
21340
|
if (next === void 0 || next === beforeRowId)
|
|
20293
21341
|
break;
|
|
20294
21342
|
beforeRowId = next;
|
|
@@ -20296,15 +21344,15 @@ async function withConversation(transport, source, work) {
|
|
|
20296
21344
|
throw new ZcodeError("protocolError", "ZCode conversation pagination did not finish");
|
|
20297
21345
|
} finally {
|
|
20298
21346
|
clearTimeout(timer);
|
|
20299
|
-
if (
|
|
20300
|
-
await transport.request("unsubscribeConversationV4", { sessionId, subscriptionId }).catch(() => void 0);
|
|
21347
|
+
if (subscriptionId2)
|
|
21348
|
+
await transport.request("unsubscribeConversationV4", { sessionId, subscriptionId: subscriptionId2 }).catch(() => void 0);
|
|
20301
21349
|
await dispose().catch(() => void 0);
|
|
20302
21350
|
}
|
|
20303
21351
|
}
|
|
20304
21352
|
|
|
20305
21353
|
// dist/read-history.js
|
|
20306
|
-
async function readHistory(transport, snapshot, events = []) {
|
|
20307
|
-
const result = history(snapshot, events, transport.locator);
|
|
21354
|
+
async function readHistory(transport, snapshot, index, events = []) {
|
|
21355
|
+
const result = history(snapshot, events, transport.locator, index);
|
|
20308
21356
|
const tools = result.turns.flatMap((turn) => turn.items).filter(({ item }) => item.type === "toolExecution");
|
|
20309
21357
|
if (tools.some(({ item }) => item.type === "toolExecution" && ["Write", "Edit", "MultiEdit"].includes(item.toolName))) {
|
|
20310
21358
|
await withConversation(transport, snapshot, async (view) => {
|
|
@@ -20423,18 +21471,18 @@ var ZcodeSession = class {
|
|
|
20423
21471
|
#lastSeq = 0;
|
|
20424
21472
|
#closePromise;
|
|
20425
21473
|
#terminalTask;
|
|
20426
|
-
|
|
21474
|
+
#models;
|
|
20427
21475
|
constructor(transport, snapshot, onClose, nativeCatalog = snapshot.settings, isLocked = () => false) {
|
|
20428
21476
|
this.transport = transport;
|
|
20429
21477
|
this.onClose = onClose;
|
|
20430
21478
|
this.nativeCatalog = nativeCatalog;
|
|
20431
21479
|
this.isLocked = isLocked;
|
|
20432
21480
|
this.capabilities = ZCODE_CAPABILITIES;
|
|
20433
|
-
this
|
|
21481
|
+
this.#models = modelCatalog(nativeCatalog);
|
|
20434
21482
|
this.#snapshot = snapshot;
|
|
20435
21483
|
this.#usage = new ZcodeUsage(snapshot.session.sessionId, (event) => this.#emit(event));
|
|
20436
21484
|
this.#goalActive = (snapshot.target === void 0 ? snapshot.projection.target : snapshot.target)?.status === "active";
|
|
20437
|
-
this.#state = sessionState(snapshot, transport.locator);
|
|
21485
|
+
this.#state = sessionState(snapshot, transport.locator, this.#models.index);
|
|
20438
21486
|
this.initialState = structuredClone(this.#state);
|
|
20439
21487
|
this.initialUsage = sessionUsage(snapshot, nativeCatalog);
|
|
20440
21488
|
this.#lastSeq = typeof snapshot.runtime.eventSeq === "number" ? snapshot.runtime.eventSeq : 0;
|
|
@@ -20516,7 +21564,7 @@ var ZcodeSession = class {
|
|
|
20516
21564
|
throw new ZcodeError("protocolError", "ZCode changed the native session identity");
|
|
20517
21565
|
this.#snapshot = snapshot;
|
|
20518
21566
|
this.#goalActive = (snapshot.target === void 0 ? snapshot.projection.target : snapshot.target)?.status === "active";
|
|
20519
|
-
this.#state = sessionState(snapshot, this.transport.locator);
|
|
21567
|
+
this.#state = sessionState(snapshot, this.transport.locator, this.#models.index);
|
|
20520
21568
|
this.#emit({ type: "session.state.changed", state: structuredClone(this.#state) });
|
|
20521
21569
|
}
|
|
20522
21570
|
async refreshUsage() {
|
|
@@ -20544,7 +21592,7 @@ var ZcodeSession = class {
|
|
|
20544
21592
|
}
|
|
20545
21593
|
#subagentConfiguration() {
|
|
20546
21594
|
const state = this.#state;
|
|
20547
|
-
const model2 = state.effectiveModel ?
|
|
21595
|
+
const model2 = state.effectiveModel ? this.#snapshot.settings.model.current?.modelId : void 0;
|
|
20548
21596
|
return {
|
|
20549
21597
|
...model2 ? { model: model2 } : {},
|
|
20550
21598
|
...state.effectiveThinkingOptionId ? { reasoningEffort: state.effectiveThinkingOptionId } : {}
|
|
@@ -20562,7 +21610,7 @@ var ZcodeSession = class {
|
|
|
20562
21610
|
try {
|
|
20563
21611
|
const snapshot = await this.#readNative();
|
|
20564
21612
|
this.#apply(snapshot);
|
|
20565
|
-
return { ok: true, value: await readHistory(this.transport, snapshot) };
|
|
21613
|
+
return { ok: true, value: await readHistory(this.transport, snapshot, this.#models.index) };
|
|
20566
21614
|
} catch (error51) {
|
|
20567
21615
|
return { ok: false, error: nativeError(error51) };
|
|
20568
21616
|
}
|
|
@@ -20609,17 +21657,9 @@ var ZcodeSession = class {
|
|
|
20609
21657
|
try {
|
|
20610
21658
|
let method, params;
|
|
20611
21659
|
if (command.type === "model.select") {
|
|
20612
|
-
if (!this.catalog.models.some((model2) => model2.ref.id === command.model.id))
|
|
20613
|
-
return failure("invalidRequest", "ZCode model is not available");
|
|
20614
21660
|
method = "setModel";
|
|
20615
21661
|
params = {
|
|
20616
|
-
model: selectNativeModel(command.model,
|
|
20617
|
-
...this.#snapshot.settings,
|
|
20618
|
-
model: {
|
|
20619
|
-
...this.#snapshot.settings.model,
|
|
20620
|
-
available: this.nativeCatalog.model.available
|
|
20621
|
-
}
|
|
20622
|
-
}),
|
|
21662
|
+
model: selectNativeModel(command.model, this.#models.index, this.#snapshot.settings.model.current),
|
|
20623
21663
|
persistAsWorkspaceLastUsed: false
|
|
20624
21664
|
};
|
|
20625
21665
|
} else if (command.type === "thinking.select") {
|
|
@@ -20659,51 +21699,51 @@ var ZcodeSession = class {
|
|
|
20659
21699
|
return { ok: false, error: nativeError(error51) };
|
|
20660
21700
|
}
|
|
20661
21701
|
}
|
|
20662
|
-
async #start(
|
|
21702
|
+
async #start(id2, method, params) {
|
|
20663
21703
|
if (this.busy)
|
|
20664
21704
|
return failure("sessionBusy", "ZCode already has an active operation", true);
|
|
20665
21705
|
const previousGoalActive = this.#goalActive;
|
|
20666
21706
|
if (method === "goalSession" && ["set", "replace", "resume"].includes(text(params.action)))
|
|
20667
21707
|
this.#goalActive = true;
|
|
20668
|
-
const
|
|
20669
|
-
id,
|
|
21708
|
+
const active2 = {
|
|
21709
|
+
id: id2,
|
|
20670
21710
|
accepted: false,
|
|
20671
21711
|
pending: [],
|
|
20672
21712
|
finishing: false,
|
|
20673
|
-
projection: new TurnProjection(
|
|
21713
|
+
projection: new TurnProjection(id2, this.transport.options.cwd, (event) => this.#emit(event))
|
|
20674
21714
|
};
|
|
20675
|
-
this.#active =
|
|
21715
|
+
this.#active = active2;
|
|
20676
21716
|
let result;
|
|
20677
21717
|
try {
|
|
20678
|
-
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 }));
|
|
20679
21719
|
} catch (error51) {
|
|
20680
|
-
if (this.#active ===
|
|
21720
|
+
if (this.#active === active2)
|
|
20681
21721
|
this.#active = void 0;
|
|
20682
21722
|
this.#goalActive = previousGoalActive;
|
|
20683
21723
|
throw error51;
|
|
20684
21724
|
}
|
|
20685
21725
|
if (this.#closed || this.#faulted)
|
|
20686
21726
|
return failure("invalidState", "ZCode closed before confirming the turn");
|
|
20687
|
-
|
|
20688
|
-
this.#emit({ type: "turn.started", turnId:
|
|
20689
|
-
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))
|
|
20690
21730
|
this.#message(message);
|
|
20691
21731
|
if (method === "goalSession" && result.startedTurn !== true) {
|
|
20692
21732
|
const response = text(result.response);
|
|
20693
21733
|
if (response)
|
|
20694
|
-
|
|
21734
|
+
active2.projection.complete({
|
|
20695
21735
|
item: {
|
|
20696
21736
|
type: "agentMessage",
|
|
20697
|
-
itemId: hostItemIdSchema.parse(`command:${
|
|
21737
|
+
itemId: hostItemIdSchema.parse(`command:${id2}`),
|
|
20698
21738
|
text: response
|
|
20699
21739
|
},
|
|
20700
21740
|
outcome: { status: "succeeded" }
|
|
20701
21741
|
});
|
|
20702
21742
|
if (result.snapshot)
|
|
20703
21743
|
this.#apply(snapshotSchema.parse(result.snapshot));
|
|
20704
|
-
this.#finish(
|
|
21744
|
+
this.#finish(active2, { status: "succeeded" });
|
|
20705
21745
|
}
|
|
20706
|
-
return { ok: true, value: { turnId:
|
|
21746
|
+
return { ok: true, value: { turnId: id2 } };
|
|
20707
21747
|
}
|
|
20708
21748
|
#message(message) {
|
|
20709
21749
|
if (this.#closed || this.#faulted)
|
|
@@ -20755,17 +21795,17 @@ var ZcodeSession = class {
|
|
|
20755
21795
|
if (this.#active?.terminal && this.#active.nativeId !== event.turnId)
|
|
20756
21796
|
this.#finish(this.#active, eventOutcome(this.#active.terminal));
|
|
20757
21797
|
if (!this.#active) {
|
|
20758
|
-
const
|
|
21798
|
+
const id2 = hostTurnIdSchema.parse(`zcode-autonomous-${randomUUID2()}`);
|
|
20759
21799
|
this.#active = {
|
|
20760
|
-
id,
|
|
21800
|
+
id: id2,
|
|
20761
21801
|
accepted: true,
|
|
20762
21802
|
pending: [],
|
|
20763
21803
|
finishing: false,
|
|
20764
|
-
projection: new TurnProjection(
|
|
21804
|
+
projection: new TurnProjection(id2, this.transport.options.cwd, (event2) => this.#emit(event2))
|
|
20765
21805
|
};
|
|
20766
21806
|
this.#emit({
|
|
20767
21807
|
type: "turn.autonomous.started",
|
|
20768
|
-
turnId:
|
|
21808
|
+
turnId: id2,
|
|
20769
21809
|
input: text(event.payload?.input) ? [{ type: "text", text: text(event.payload?.input) }] : []
|
|
20770
21810
|
});
|
|
20771
21811
|
}
|
|
@@ -20785,35 +21825,35 @@ var ZcodeSession = class {
|
|
|
20785
21825
|
nativeSubagentId: p2.childSessionId
|
|
20786
21826
|
});
|
|
20787
21827
|
}
|
|
20788
|
-
const
|
|
20789
|
-
if (!
|
|
21828
|
+
const active2 = this.#active;
|
|
21829
|
+
if (!active2 || event.turnId && active2.nativeId && event.turnId !== active2.nativeId)
|
|
20790
21830
|
return;
|
|
20791
21831
|
if (event.type === "permission.resolved" || event.type === "userInput.resolved") {
|
|
20792
|
-
const
|
|
20793
|
-
this.#closeInteraction(
|
|
21832
|
+
const id2 = `zcode:${text(event.payload?.requestId)}`;
|
|
21833
|
+
this.#closeInteraction(id2, "superseded");
|
|
20794
21834
|
}
|
|
20795
21835
|
if (event.type === "turn.completed" || event.type === "turn.failed") {
|
|
20796
|
-
|
|
21836
|
+
active2.terminal = event;
|
|
20797
21837
|
if (!this.#goalActive)
|
|
20798
|
-
|
|
20799
|
-
} else if (!
|
|
20800
|
-
|
|
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);
|
|
20801
21841
|
}
|
|
20802
|
-
#settle(
|
|
20803
|
-
if (
|
|
21842
|
+
#settle(active2, reason) {
|
|
21843
|
+
if (active2.finishing)
|
|
20804
21844
|
return;
|
|
20805
|
-
|
|
21845
|
+
active2.finishing = true;
|
|
20806
21846
|
this.#terminalTask = (async () => {
|
|
20807
21847
|
const snapshot = await this.#readNative();
|
|
20808
|
-
if (this.#active !==
|
|
21848
|
+
if (this.#active !== active2 || this.#closed || this.#faulted)
|
|
20809
21849
|
return;
|
|
20810
|
-
const turns = (await readHistory(this.transport, snapshot,
|
|
20811
|
-
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);
|
|
20812
21852
|
if (turn)
|
|
20813
|
-
|
|
21853
|
+
active2.projection.reconcile(turn.items);
|
|
20814
21854
|
this.#apply(snapshot);
|
|
20815
|
-
const cancelledBeforeTurnStarted = !
|
|
20816
|
-
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") ? {
|
|
20817
21857
|
status: "failed",
|
|
20818
21858
|
error: {
|
|
20819
21859
|
code: "nativeFailure",
|
|
@@ -20823,21 +21863,21 @@ var ZcodeSession = class {
|
|
|
20823
21863
|
} : turn?.outcome;
|
|
20824
21864
|
if (!outcome || outcome.status === "unknown")
|
|
20825
21865
|
throw new ZcodeError("protocolError", "ZCode completed without a confirmed turn outcome");
|
|
20826
|
-
if (this.#active !==
|
|
21866
|
+
if (this.#active !== active2 || this.#closed || this.#faulted)
|
|
20827
21867
|
return;
|
|
20828
21868
|
this.#usage.replay(snapshot.messages, false);
|
|
20829
|
-
this.#finish(
|
|
21869
|
+
this.#finish(active2, {
|
|
20830
21870
|
...outcome,
|
|
20831
21871
|
...turn?.checkpoint ? { checkpoint: turn.checkpoint } : {}
|
|
20832
21872
|
});
|
|
20833
21873
|
await this.refreshUsage();
|
|
20834
21874
|
})().catch((error51) => this.#fault(error51));
|
|
20835
21875
|
}
|
|
20836
|
-
#closeInteraction(
|
|
20837
|
-
const pending = this.#pendingInteractions.get(
|
|
21876
|
+
#closeInteraction(id2, reason) {
|
|
21877
|
+
const pending = this.#pendingInteractions.get(id2);
|
|
20838
21878
|
if (!pending)
|
|
20839
21879
|
return;
|
|
20840
|
-
this.#pendingInteractions.delete(
|
|
21880
|
+
this.#pendingInteractions.delete(id2);
|
|
20841
21881
|
this.#emit({
|
|
20842
21882
|
type: "interaction.closed",
|
|
20843
21883
|
interactionId: pending.interaction.interactionId,
|
|
@@ -20845,21 +21885,21 @@ var ZcodeSession = class {
|
|
|
20845
21885
|
reason
|
|
20846
21886
|
});
|
|
20847
21887
|
}
|
|
20848
|
-
#finish(
|
|
20849
|
-
if (this.#active !==
|
|
21888
|
+
#finish(active2, outcome) {
|
|
21889
|
+
if (this.#active !== active2)
|
|
20850
21890
|
return;
|
|
20851
|
-
clearTimeout(
|
|
20852
|
-
for (const [
|
|
21891
|
+
clearTimeout(active2.timer);
|
|
21892
|
+
for (const [id2, pending] of this.#pendingInteractions) {
|
|
20853
21893
|
void this.#respond(pending.requestId, pending.interaction.type === "approval" ? { decision: "deny" } : { action: "cancel" }).catch(() => {
|
|
20854
21894
|
});
|
|
20855
|
-
this.#closeInteraction(
|
|
21895
|
+
this.#closeInteraction(id2, "cancelled");
|
|
20856
21896
|
}
|
|
20857
|
-
|
|
21897
|
+
active2.projection.finish(outcome.status === "succeeded" ? { status: "succeeded" } : outcome);
|
|
20858
21898
|
this.#active = void 0;
|
|
20859
21899
|
this.#emit({
|
|
20860
21900
|
type: "turn.completed",
|
|
20861
|
-
turnId:
|
|
20862
|
-
...
|
|
21901
|
+
turnId: active2.id,
|
|
21902
|
+
...active2.messageId ? { nativeTurnRef: nativeTurnRef(this.sessionId, active2.messageId) } : {},
|
|
20863
21903
|
outcome
|
|
20864
21904
|
});
|
|
20865
21905
|
}
|
|
@@ -20933,10 +21973,24 @@ var ZcodeAdapter = class {
|
|
|
20933
21973
|
options;
|
|
20934
21974
|
harnessId = ZCODE_ID;
|
|
20935
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
|
+
};
|
|
20936
21989
|
#closed = false;
|
|
20937
21990
|
#sessions = /* @__PURE__ */ new Set();
|
|
20938
21991
|
#transports = /* @__PURE__ */ new Set();
|
|
20939
21992
|
#opening = /* @__PURE__ */ new Set();
|
|
21993
|
+
#inflightInspect = /* @__PURE__ */ new Map();
|
|
20940
21994
|
// One verification page and SDK instance for the whole Host, as in ZCode Desktop.
|
|
20941
21995
|
#verifier;
|
|
20942
21996
|
#prewarmed = false;
|
|
@@ -20949,7 +22003,7 @@ var ZcodeAdapter = class {
|
|
|
20949
22003
|
appVersion,
|
|
20950
22004
|
...this.options.openLocalPage ? { openLocalPage: this.options.openLocalPage } : {}
|
|
20951
22005
|
});
|
|
20952
|
-
async #transport(cwd, environment) {
|
|
22006
|
+
async #transport(cwd, environment, keyOptions) {
|
|
20953
22007
|
if (this.#closed)
|
|
20954
22008
|
throw new ZcodeError("invalidState", "ZCode Adapter is closed");
|
|
20955
22009
|
if (!(await stat2(cwd)).isDirectory())
|
|
@@ -20959,6 +22013,7 @@ var ZcodeAdapter = class {
|
|
|
20959
22013
|
environment: { ...this.options.environment ?? process.env, ...environment },
|
|
20960
22014
|
...this.options.app ? { app: this.options.app } : {},
|
|
20961
22015
|
...this.options.timeoutMs ? { timeoutMs: this.options.timeoutMs } : {},
|
|
22016
|
+
...keyOptions ? { keyOptions } : {},
|
|
20962
22017
|
verifier: this.#sharedVerifier
|
|
20963
22018
|
};
|
|
20964
22019
|
const transport = this.options.createTransport ? this.options.createTransport(options) : new CliTransport(options);
|
|
@@ -20973,24 +22028,51 @@ var ZcodeAdapter = class {
|
|
|
20973
22028
|
}
|
|
20974
22029
|
}
|
|
20975
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) {
|
|
20976
22055
|
let transport;
|
|
20977
22056
|
try {
|
|
20978
|
-
transport = await this.#transport(
|
|
22057
|
+
transport = await this.#transport(cwd, void 0, keyOptions);
|
|
20979
22058
|
const settings = await readCatalog(transport);
|
|
20980
|
-
const
|
|
20981
|
-
|
|
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;
|
|
20982
22064
|
return {
|
|
20983
22065
|
status: "unavailable",
|
|
20984
22066
|
// A signed-in account without an active plan is not a login problem; only a signed-out
|
|
20985
22067
|
// ZCode Desktop needs the login prompt.
|
|
20986
|
-
error:
|
|
22068
|
+
error: issue2 ? {
|
|
22069
|
+
code: transport.credentialAccessRequired ? "credentialAccessRequired" : "configurationRequired",
|
|
22070
|
+
message: issue2,
|
|
22071
|
+
retryable
|
|
22072
|
+
} : !transport.signedIn ? {
|
|
20987
22073
|
code: "authenticationRequired",
|
|
20988
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.",
|
|
20989
22075
|
retryable: true
|
|
20990
|
-
} : transport.codingPlanIssue ? {
|
|
20991
|
-
code: "configurationRequired",
|
|
20992
|
-
message: transport.codingPlanIssue,
|
|
20993
|
-
retryable: true
|
|
20994
22076
|
} : transport.startPlanChecked ? {
|
|
20995
22077
|
code: "configurationRequired",
|
|
20996
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.",
|
|
@@ -21002,6 +22084,8 @@ var ZcodeAdapter = class {
|
|
|
21002
22084
|
retryable: true
|
|
21003
22085
|
}
|
|
21004
22086
|
};
|
|
22087
|
+
}
|
|
22088
|
+
this.#inspectedModels.set(cwd, models);
|
|
21005
22089
|
return {
|
|
21006
22090
|
status: "ready",
|
|
21007
22091
|
catalog,
|
|
@@ -21036,18 +22120,26 @@ var ZcodeAdapter = class {
|
|
|
21036
22120
|
let transport;
|
|
21037
22121
|
let createdId;
|
|
21038
22122
|
try {
|
|
21039
|
-
|
|
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);
|
|
21040
22128
|
let snapshot, settings;
|
|
22129
|
+
let requestedModel;
|
|
21041
22130
|
if (input.kind === "create") {
|
|
21042
22131
|
settings = await readCatalog(transport);
|
|
22132
|
+
const { catalog, index } = modelCatalog(settings);
|
|
22133
|
+
if (transport.credentialAccessRequired && !catalog.models.length)
|
|
22134
|
+
throw new ZcodeError("credentialAccessRequired", credentialIssue);
|
|
21043
22135
|
if (input.permissionModeId && !permissionModes().modes.some((m) => m.id === input.permissionModeId))
|
|
21044
22136
|
throw new ZcodeError("invalidRequest", "Unknown ZCode permission mode");
|
|
21045
|
-
|
|
22137
|
+
requestedModel = input.model ? selectNativeModel(input.model, index, settings.model.current, input.thinkingOptionId) : void 0;
|
|
21046
22138
|
const mode = input.executionPolicy === "unattended-full-access" ? "yolo" : input.permissionModeId;
|
|
21047
22139
|
const created = await transport.command(null, "createSession", {
|
|
21048
22140
|
workspaceId: input.cwd,
|
|
21049
22141
|
config: {
|
|
21050
|
-
...
|
|
22142
|
+
...requestedModel ? { modelSelection: requestedModel } : {},
|
|
21051
22143
|
...mode ? { mode } : {},
|
|
21052
22144
|
...input.thinkingOptionId ? { thought: input.thinkingOptionId } : {}
|
|
21053
22145
|
}
|
|
@@ -21068,7 +22160,7 @@ var ZcodeAdapter = class {
|
|
|
21068
22160
|
if (snapshot.projection.currentTurnId || snapshot.session.status === "running")
|
|
21069
22161
|
throw new ZcodeError("sessionBusy", "ZCode Session is executing native work", true);
|
|
21070
22162
|
if (input.kind === "create") {
|
|
21071
|
-
if (
|
|
22163
|
+
if (requestedModel && (!snapshot.settings.model.current || !sameNativeModel(snapshot.settings.model.current, requestedModel)))
|
|
21072
22164
|
throw new ZcodeError("nativeFailure", "ZCode did not apply the requested model");
|
|
21073
22165
|
if (input.thinkingOptionId && snapshot.settings.thoughtLevel.current !== input.thinkingOptionId)
|
|
21074
22166
|
throw new ZcodeError("nativeFailure", "ZCode did not apply the requested thinking option");
|
|
@@ -21105,6 +22197,7 @@ var ZcodeAdapter = class {
|
|
|
21105
22197
|
}
|
|
21106
22198
|
async close() {
|
|
21107
22199
|
this.#closed = true;
|
|
22200
|
+
this.#inspectedModels.clear();
|
|
21108
22201
|
await Promise.all([...this.#sessions].map((session) => session.close()));
|
|
21109
22202
|
await Promise.all([...this.#transports].map((transport) => transport.close()));
|
|
21110
22203
|
this.#sessions.clear();
|