@codexhost/cli-linux-arm64 0.23.0 → 0.24.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/app/codexhost-distribution.json +1 -1
- package/app/console-server.mjs +1565 -1805
- package/app/console-web.js +5786 -1600
- package/app/desktop-controller.mjs +13104 -2842
- package/app/host-runtime.mjs +50518 -51753
- package/app/plugins/antigravity/plugin.mjs +1932 -1148
- package/app/plugins/claude-code/plugin.mjs +1676 -1218
- package/app/plugins/codebuddy/plugin.mjs +1266 -850
- package/app/plugins/codex-usage/plugin.mjs +916 -737
- package/app/plugins/copilot/plugin.mjs +838 -640
- package/app/plugins/cursor-cli/plugin.mjs +1058 -747
- package/app/plugins/deepseek-harness/plugin.mjs +1302 -1070
- package/app/plugins/devin/plugin.mjs +949 -752
- package/app/plugins/grok/plugin.mjs +1132 -964
- package/app/plugins/hermes/plugin.mjs +1084 -905
- package/app/plugins/kimi-code/plugin.mjs +977 -804
- package/app/plugins/kiro-cli/plugin.mjs +951 -758
- package/app/plugins/omp/plugin.mjs +1408 -1169
- package/app/plugins/opencode/plugin.mjs +1385 -1142
- package/app/plugins/pi/plugin.mjs +1515 -1287
- package/app/plugins/qoder/plugin.mjs +861 -676
- package/app/plugins/qoder-cn/plugin.mjs +861 -676
- package/app/plugins/qwen-code/plugin.mjs +1060 -888
- package/app/plugins/workbuddy/plugin.mjs +1272 -856
- package/app/plugins/zcode/plugin.mjs +1529 -880
- package/app/renderer-extension.js +11568 -7827
- package/app/web/assets/index-CTCFIQbU.css +1 -0
- package/app/web/assets/index-IvFk9KT-.js +203 -0
- package/app/web/codexhost-settings.js +4472 -36194
- package/app/web/index.html +2 -2
- package/app/web/plugins/deepseek-ai__dsh-api-remotes/client.js +1 -1
- package/app/web/plugins/deepseek-ai__dsh-api-session-controller/client.js +69 -69
- package/app/web/plugins/deepseek-ai__dsh-client-ui-approval/client.js +1 -1
- package/app/web/plugins/deepseek-ai__dsh-client-ui-chat/client.js +74 -74
- package/app/web/plugins/deepseek-ai__dsh-client-ui-codexhost/client.js +75 -64
- package/app/web/plugins/deepseek-ai__dsh-client-ui-conversation/client.js +19 -16
- package/app/web/plugins/deepseek-ai__dsh-client-ui-input-trigger/client.js +1 -1
- package/app/web/plugins/deepseek-ai__dsh-client-ui-layout/client.js +2 -2
- package/app/web/plugins/deepseek-ai__dsh-client-ui-model-selection/client.js +2 -2
- package/app/web/plugins/deepseek-ai__dsh-client-ui-settings-general/client.js +1 -1
- package/app/web/plugins/deepseek-ai__dsh-client-ui-sidebar/client.js +2 -2
- package/app/web/plugins/deepseek-ai__dsh-client-ui-sidebar-documentpreview/client.js +9 -9
- package/app/web/plugins/deepseek-ai__dsh-client-ui-sidebar-right/client.js +1 -1
- package/app/web/plugins/deepseek-ai__dsh-client-ui-theme/client.js +1 -1
- package/app/web/plugins/deepseek-ai__dsh-client-ui-tool/client.js +18 -18
- package/app/web/plugins/deepseek-ai__dsh-client-ui-user-questions/client.js +3 -3
- package/app/web/plugins/deepseek-ai__dsh-client-ui-workspace/client.js +7 -7
- package/app/web/sw.js +8 -1
- package/app/web-modules/server.mjs +2682 -5540
- package/bin/codexhost +0 -0
- package/libexec/codexhost-shim +0 -0
- package/libexec/codexhost-updater +0 -0
- package/package.json +1 -1
- package/app/web/assets/index-DJW4bmyx.css +0 -1
- package/app/web/assets/index-Dyh1KzAB.js +0 -201
|
@@ -32,10 +32,10 @@ function executableExtensions(command, platform, environment) {
|
|
|
32
32
|
return [""];
|
|
33
33
|
return (environmentValue(environment, "PATHEXT") ?? ".COM;.EXE;.BAT;.CMD").split(";").map((extension) => extension.trim()).filter(Boolean);
|
|
34
34
|
}
|
|
35
|
-
function isExecutableFile(
|
|
35
|
+
function isExecutableFile(filePath2, platform) {
|
|
36
36
|
try {
|
|
37
|
-
fs.accessSync(
|
|
38
|
-
return fs.statSync(
|
|
37
|
+
fs.accessSync(filePath2, platform === "win32" ? fs.constants.F_OK : fs.constants.X_OK);
|
|
38
|
+
return fs.statSync(filePath2).isFile();
|
|
39
39
|
} catch {
|
|
40
40
|
return false;
|
|
41
41
|
}
|
|
@@ -412,7 +412,7 @@ function createHarnessInstaller(environment, source) {
|
|
|
412
412
|
import { execFile as execFile2, spawn as spawn2 } from "node:child_process";
|
|
413
413
|
import { randomUUID as randomUUID2 } from "node:crypto";
|
|
414
414
|
import { stat as stat2 } from "node:fs/promises";
|
|
415
|
-
import
|
|
415
|
+
import path13 from "node:path";
|
|
416
416
|
|
|
417
417
|
// ../../../node_modules/zod/v4/classic/external.js
|
|
418
418
|
var external_exports = {};
|
|
@@ -1180,10 +1180,10 @@ function mergeDefs(...defs) {
|
|
|
1180
1180
|
function cloneDef(schema) {
|
|
1181
1181
|
return mergeDefs(schema._zod.def);
|
|
1182
1182
|
}
|
|
1183
|
-
function getElementAtPath(obj,
|
|
1184
|
-
if (!
|
|
1183
|
+
function getElementAtPath(obj, path14) {
|
|
1184
|
+
if (!path14)
|
|
1185
1185
|
return obj;
|
|
1186
|
-
return
|
|
1186
|
+
return path14.reduce((acc, key) => acc?.[key], obj);
|
|
1187
1187
|
}
|
|
1188
1188
|
function promiseAllObject(promisesObj) {
|
|
1189
1189
|
const keys = Object.keys(promisesObj);
|
|
@@ -1592,11 +1592,11 @@ function explicitlyAborted(x, startIndex = 0) {
|
|
|
1592
1592
|
}
|
|
1593
1593
|
return false;
|
|
1594
1594
|
}
|
|
1595
|
-
function prefixIssues(
|
|
1595
|
+
function prefixIssues(path14, issues) {
|
|
1596
1596
|
return issues.map((iss) => {
|
|
1597
1597
|
var _a3;
|
|
1598
1598
|
(_a3 = iss).path ?? (_a3.path = []);
|
|
1599
|
-
iss.path.unshift(
|
|
1599
|
+
iss.path.unshift(path14);
|
|
1600
1600
|
return iss;
|
|
1601
1601
|
});
|
|
1602
1602
|
}
|
|
@@ -1667,8 +1667,8 @@ function cleanEnum(obj) {
|
|
|
1667
1667
|
return Number.isNaN(Number.parseInt(k, 10));
|
|
1668
1668
|
}).map((el) => el[1]);
|
|
1669
1669
|
}
|
|
1670
|
-
function base64ToUint8Array(
|
|
1671
|
-
const binaryString = atob(
|
|
1670
|
+
function base64ToUint8Array(base644) {
|
|
1671
|
+
const binaryString = atob(base644);
|
|
1672
1672
|
const bytes = new Uint8Array(binaryString.length);
|
|
1673
1673
|
for (let i = 0; i < binaryString.length; i++) {
|
|
1674
1674
|
bytes[i] = binaryString.charCodeAt(i);
|
|
@@ -1683,9 +1683,9 @@ function uint8ArrayToBase64(bytes) {
|
|
|
1683
1683
|
return btoa(binaryString);
|
|
1684
1684
|
}
|
|
1685
1685
|
function base64urlToUint8Array(base64url3) {
|
|
1686
|
-
const
|
|
1687
|
-
const padding = "=".repeat((4 -
|
|
1688
|
-
return base64ToUint8Array(
|
|
1686
|
+
const base644 = base64url3.replace(/-/g, "+").replace(/_/g, "/");
|
|
1687
|
+
const padding = "=".repeat((4 - base644.length % 4) % 4);
|
|
1688
|
+
return base64ToUint8Array(base644 + padding);
|
|
1689
1689
|
}
|
|
1690
1690
|
function uint8ArrayToBase64url(bytes) {
|
|
1691
1691
|
return uint8ArrayToBase64(bytes).replace(/\+/g, "-").replace(/\//g, "_").replace(/=/g, "");
|
|
@@ -1743,16 +1743,16 @@ function flattenError(error51, mapper = (issue2) => issue2.message) {
|
|
|
1743
1743
|
}
|
|
1744
1744
|
function formatError(error51, mapper = (issue2) => issue2.message) {
|
|
1745
1745
|
const fieldErrors = { _errors: [] };
|
|
1746
|
-
const processError = (error52,
|
|
1746
|
+
const processError = (error52, path14 = []) => {
|
|
1747
1747
|
for (const issue2 of error52.issues) {
|
|
1748
1748
|
if (issue2.code === "invalid_union" && issue2.errors.length) {
|
|
1749
|
-
issue2.errors.map((issues) => processError({ issues }, [...
|
|
1749
|
+
issue2.errors.map((issues) => processError({ issues }, [...path14, ...issue2.path]));
|
|
1750
1750
|
} else if (issue2.code === "invalid_key") {
|
|
1751
|
-
processError({ issues: issue2.issues }, [...
|
|
1751
|
+
processError({ issues: issue2.issues }, [...path14, ...issue2.path]);
|
|
1752
1752
|
} else if (issue2.code === "invalid_element") {
|
|
1753
|
-
processError({ issues: issue2.issues }, [...
|
|
1753
|
+
processError({ issues: issue2.issues }, [...path14, ...issue2.path]);
|
|
1754
1754
|
} else {
|
|
1755
|
-
const fullpath = [...
|
|
1755
|
+
const fullpath = [...path14, ...issue2.path];
|
|
1756
1756
|
if (fullpath.length === 0) {
|
|
1757
1757
|
fieldErrors._errors.push(mapper(issue2));
|
|
1758
1758
|
} else {
|
|
@@ -1779,17 +1779,17 @@ function formatError(error51, mapper = (issue2) => issue2.message) {
|
|
|
1779
1779
|
}
|
|
1780
1780
|
function treeifyError(error51, mapper = (issue2) => issue2.message) {
|
|
1781
1781
|
const result = { errors: [] };
|
|
1782
|
-
const processError = (error52,
|
|
1782
|
+
const processError = (error52, path14 = []) => {
|
|
1783
1783
|
var _a3, _b;
|
|
1784
1784
|
for (const issue2 of error52.issues) {
|
|
1785
1785
|
if (issue2.code === "invalid_union" && issue2.errors.length) {
|
|
1786
|
-
issue2.errors.map((issues) => processError({ issues }, [...
|
|
1786
|
+
issue2.errors.map((issues) => processError({ issues }, [...path14, ...issue2.path]));
|
|
1787
1787
|
} else if (issue2.code === "invalid_key") {
|
|
1788
|
-
processError({ issues: issue2.issues }, [...
|
|
1788
|
+
processError({ issues: issue2.issues }, [...path14, ...issue2.path]);
|
|
1789
1789
|
} else if (issue2.code === "invalid_element") {
|
|
1790
|
-
processError({ issues: issue2.issues }, [...
|
|
1790
|
+
processError({ issues: issue2.issues }, [...path14, ...issue2.path]);
|
|
1791
1791
|
} else {
|
|
1792
|
-
const fullpath = [...
|
|
1792
|
+
const fullpath = [...path14, ...issue2.path];
|
|
1793
1793
|
if (fullpath.length === 0) {
|
|
1794
1794
|
result.errors.push(mapper(issue2));
|
|
1795
1795
|
continue;
|
|
@@ -1821,8 +1821,8 @@ function treeifyError(error51, mapper = (issue2) => issue2.message) {
|
|
|
1821
1821
|
}
|
|
1822
1822
|
function toDotPath(_path) {
|
|
1823
1823
|
const segs = [];
|
|
1824
|
-
const
|
|
1825
|
-
for (const seg of
|
|
1824
|
+
const path14 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
|
|
1825
|
+
for (const seg of path14) {
|
|
1826
1826
|
if (typeof seg === "number")
|
|
1827
1827
|
segs.push(`[${seg}]`);
|
|
1828
1828
|
else if (typeof seg === "symbol")
|
|
@@ -3051,8 +3051,8 @@ var $ZodBase64 = /* @__PURE__ */ $constructor("$ZodBase64", (inst, def) => {
|
|
|
3051
3051
|
function isValidBase64URL(data) {
|
|
3052
3052
|
if (!base64url.test(data))
|
|
3053
3053
|
return false;
|
|
3054
|
-
const
|
|
3055
|
-
const padded =
|
|
3054
|
+
const base644 = data.replace(/[-_]/g, (c) => c === "-" ? "+" : "/");
|
|
3055
|
+
const padded = base644.padEnd(Math.ceil(base644.length / 4) * 4, "=");
|
|
3056
3056
|
return isValidBase64(padded);
|
|
3057
3057
|
}
|
|
3058
3058
|
var $ZodBase64URL = /* @__PURE__ */ $constructor("$ZodBase64URL", (inst, def) => {
|
|
@@ -3506,42 +3506,42 @@ var $ZodObjectJIT = /* @__PURE__ */ $constructor("$ZodObjectJIT", (inst, def) =>
|
|
|
3506
3506
|
}
|
|
3507
3507
|
doc.write(`const newResult = {};`);
|
|
3508
3508
|
for (const key of normalized.keys) {
|
|
3509
|
-
const
|
|
3509
|
+
const id2 = ids[key];
|
|
3510
3510
|
const k = esc(key);
|
|
3511
3511
|
const schema = shape[key];
|
|
3512
3512
|
const isOptionalIn = schema?._zod?.optin === "optional";
|
|
3513
3513
|
const isOptionalOut = schema?._zod?.optout === "optional";
|
|
3514
|
-
doc.write(`const ${
|
|
3514
|
+
doc.write(`const ${id2} = ${parseStr(key)};`);
|
|
3515
3515
|
if (isOptionalIn && isOptionalOut) {
|
|
3516
3516
|
doc.write(`
|
|
3517
|
-
if (${
|
|
3517
|
+
if (${id2}.issues.length) {
|
|
3518
3518
|
if (${k} in input) {
|
|
3519
|
-
payload.issues = payload.issues.concat(${
|
|
3519
|
+
payload.issues = payload.issues.concat(${id2}.issues.map(iss => ({
|
|
3520
3520
|
...iss,
|
|
3521
3521
|
path: iss.path ? [${k}, ...iss.path] : [${k}]
|
|
3522
3522
|
})));
|
|
3523
3523
|
}
|
|
3524
3524
|
}
|
|
3525
3525
|
|
|
3526
|
-
if (${
|
|
3526
|
+
if (${id2}.value === undefined) {
|
|
3527
3527
|
if (${k} in input) {
|
|
3528
3528
|
newResult[${k}] = undefined;
|
|
3529
3529
|
}
|
|
3530
3530
|
} else {
|
|
3531
|
-
newResult[${k}] = ${
|
|
3531
|
+
newResult[${k}] = ${id2}.value;
|
|
3532
3532
|
}
|
|
3533
3533
|
|
|
3534
3534
|
`);
|
|
3535
3535
|
} else if (!isOptionalIn) {
|
|
3536
3536
|
doc.write(`
|
|
3537
|
-
const ${
|
|
3538
|
-
if (${
|
|
3539
|
-
payload.issues = payload.issues.concat(${
|
|
3537
|
+
const ${id2}_present = ${k} in input;
|
|
3538
|
+
if (${id2}.issues.length) {
|
|
3539
|
+
payload.issues = payload.issues.concat(${id2}.issues.map(iss => ({
|
|
3540
3540
|
...iss,
|
|
3541
3541
|
path: iss.path ? [${k}, ...iss.path] : [${k}]
|
|
3542
3542
|
})));
|
|
3543
3543
|
}
|
|
3544
|
-
if (!${
|
|
3544
|
+
if (!${id2}_present && !${id2}.issues.length) {
|
|
3545
3545
|
payload.issues.push({
|
|
3546
3546
|
code: "invalid_type",
|
|
3547
3547
|
expected: "nonoptional",
|
|
@@ -3550,30 +3550,30 @@ var $ZodObjectJIT = /* @__PURE__ */ $constructor("$ZodObjectJIT", (inst, def) =>
|
|
|
3550
3550
|
});
|
|
3551
3551
|
}
|
|
3552
3552
|
|
|
3553
|
-
if (${
|
|
3554
|
-
if (${
|
|
3553
|
+
if (${id2}_present) {
|
|
3554
|
+
if (${id2}.value === undefined) {
|
|
3555
3555
|
newResult[${k}] = undefined;
|
|
3556
3556
|
} else {
|
|
3557
|
-
newResult[${k}] = ${
|
|
3557
|
+
newResult[${k}] = ${id2}.value;
|
|
3558
3558
|
}
|
|
3559
3559
|
}
|
|
3560
3560
|
|
|
3561
3561
|
`);
|
|
3562
3562
|
} else {
|
|
3563
3563
|
doc.write(`
|
|
3564
|
-
if (${
|
|
3565
|
-
payload.issues = payload.issues.concat(${
|
|
3564
|
+
if (${id2}.issues.length) {
|
|
3565
|
+
payload.issues = payload.issues.concat(${id2}.issues.map(iss => ({
|
|
3566
3566
|
...iss,
|
|
3567
3567
|
path: iss.path ? [${k}, ...iss.path] : [${k}]
|
|
3568
3568
|
})));
|
|
3569
3569
|
}
|
|
3570
3570
|
|
|
3571
|
-
if (${
|
|
3571
|
+
if (${id2}.value === undefined) {
|
|
3572
3572
|
if (${k} in input) {
|
|
3573
3573
|
newResult[${k}] = undefined;
|
|
3574
3574
|
}
|
|
3575
3575
|
} else {
|
|
3576
|
-
newResult[${k}] = ${
|
|
3576
|
+
newResult[${k}] = ${id2}.value;
|
|
3577
3577
|
}
|
|
3578
3578
|
|
|
3579
3579
|
`);
|
|
@@ -11905,26 +11905,26 @@ function extractDefs(ctx, schema) {
|
|
|
11905
11905
|
throw new Error("Unprocessed schema. This is a bug in Zod.");
|
|
11906
11906
|
const idToSchema = /* @__PURE__ */ new Map();
|
|
11907
11907
|
for (const entry of ctx.seen.entries()) {
|
|
11908
|
-
const
|
|
11909
|
-
if (
|
|
11910
|
-
const existing = idToSchema.get(
|
|
11908
|
+
const id2 = ctx.metadataRegistry.get(entry[0])?.id;
|
|
11909
|
+
if (id2) {
|
|
11910
|
+
const existing = idToSchema.get(id2);
|
|
11911
11911
|
if (existing && existing !== entry[0]) {
|
|
11912
|
-
throw new Error(`Duplicate schema id "${
|
|
11912
|
+
throw new Error(`Duplicate schema id "${id2}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);
|
|
11913
11913
|
}
|
|
11914
|
-
idToSchema.set(
|
|
11914
|
+
idToSchema.set(id2, entry[0]);
|
|
11915
11915
|
}
|
|
11916
11916
|
}
|
|
11917
11917
|
const makeURI = (entry) => {
|
|
11918
11918
|
const defsSegment = ctx.target === "draft-2020-12" ? "$defs" : "definitions";
|
|
11919
11919
|
if (ctx.external) {
|
|
11920
11920
|
const externalId = ctx.external.registry.get(entry[0])?.id;
|
|
11921
|
-
const uriGenerator = ctx.external.uri ?? ((
|
|
11921
|
+
const uriGenerator = ctx.external.uri ?? ((id3) => id3);
|
|
11922
11922
|
if (externalId) {
|
|
11923
11923
|
return { ref: uriGenerator(externalId) };
|
|
11924
11924
|
}
|
|
11925
|
-
const
|
|
11926
|
-
entry[1].defId =
|
|
11927
|
-
return { defId:
|
|
11925
|
+
const id2 = entry[1].defId ?? entry[1].schema.id ?? `schema${ctx.counter++}`;
|
|
11926
|
+
entry[1].defId = id2;
|
|
11927
|
+
return { defId: id2, ref: `${uriGenerator("__shared")}#/${defsSegment}/${id2}` };
|
|
11928
11928
|
}
|
|
11929
11929
|
if (entry[1] === root) {
|
|
11930
11930
|
return { ref: "#" };
|
|
@@ -11972,8 +11972,8 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
11972
11972
|
continue;
|
|
11973
11973
|
}
|
|
11974
11974
|
}
|
|
11975
|
-
const
|
|
11976
|
-
if (
|
|
11975
|
+
const id2 = ctx.metadataRegistry.get(entry[0])?.id;
|
|
11976
|
+
if (id2) {
|
|
11977
11977
|
extractToDef(entry);
|
|
11978
11978
|
continue;
|
|
11979
11979
|
}
|
|
@@ -12069,10 +12069,10 @@ function finalize(ctx, schema) {
|
|
|
12069
12069
|
} else {
|
|
12070
12070
|
}
|
|
12071
12071
|
if (ctx.external?.uri) {
|
|
12072
|
-
const
|
|
12073
|
-
if (!
|
|
12072
|
+
const id2 = ctx.external.registry.get(schema)?.id;
|
|
12073
|
+
if (!id2)
|
|
12074
12074
|
throw new Error("Schema is missing an `id` property");
|
|
12075
|
-
result.$id = ctx.external.uri(
|
|
12075
|
+
result.$id = ctx.external.uri(id2);
|
|
12076
12076
|
}
|
|
12077
12077
|
Object.assign(result, root.def ?? root.schema);
|
|
12078
12078
|
const rootMetaId = ctx.metadataRegistry.get(schema)?.id;
|
|
@@ -12232,9 +12232,9 @@ var numberProcessor = (schema, ctx, _json, _params) => {
|
|
|
12232
12232
|
json2.type = "number";
|
|
12233
12233
|
const exMin = typeof exclusiveMinimum === "number" && exclusiveMinimum >= (minimum ?? Number.NEGATIVE_INFINITY);
|
|
12234
12234
|
const exMax = typeof exclusiveMaximum === "number" && exclusiveMaximum <= (maximum ?? Number.POSITIVE_INFINITY);
|
|
12235
|
-
const
|
|
12235
|
+
const legacy2 = ctx.target === "draft-04" || ctx.target === "openapi-3.0";
|
|
12236
12236
|
if (exMin) {
|
|
12237
|
-
if (
|
|
12237
|
+
if (legacy2) {
|
|
12238
12238
|
json2.minimum = exclusiveMinimum;
|
|
12239
12239
|
json2.exclusiveMinimum = true;
|
|
12240
12240
|
} else {
|
|
@@ -12244,7 +12244,7 @@ var numberProcessor = (schema, ctx, _json, _params) => {
|
|
|
12244
12244
|
json2.minimum = minimum;
|
|
12245
12245
|
}
|
|
12246
12246
|
if (exMax) {
|
|
12247
|
-
if (
|
|
12247
|
+
if (legacy2) {
|
|
12248
12248
|
json2.maximum = exclusiveMaximum;
|
|
12249
12249
|
json2.exclusiveMaximum = true;
|
|
12250
12250
|
} else {
|
|
@@ -13106,7 +13106,7 @@ var safeDecodeAsync2 = /* @__PURE__ */ _safeDecodeAsync(ZodRealError);
|
|
|
13106
13106
|
|
|
13107
13107
|
// ../../../node_modules/zod/v4/classic/schemas.js
|
|
13108
13108
|
var _installedGroups = /* @__PURE__ */ new WeakMap();
|
|
13109
|
-
function _installLazyMethods(inst, group,
|
|
13109
|
+
function _installLazyMethods(inst, group, methods3) {
|
|
13110
13110
|
const proto = Object.getPrototypeOf(inst);
|
|
13111
13111
|
let installed = _installedGroups.get(proto);
|
|
13112
13112
|
if (!installed) {
|
|
@@ -13116,8 +13116,8 @@ function _installLazyMethods(inst, group, methods2) {
|
|
|
13116
13116
|
if (installed.has(group))
|
|
13117
13117
|
return;
|
|
13118
13118
|
installed.add(group);
|
|
13119
|
-
for (const key in
|
|
13120
|
-
const fn =
|
|
13119
|
+
for (const key in methods3) {
|
|
13120
|
+
const fn = methods3[key];
|
|
13121
13121
|
Object.defineProperty(proto, key, {
|
|
13122
13122
|
configurable: true,
|
|
13123
13123
|
enumerable: false,
|
|
@@ -14514,13 +14514,13 @@ function resolveRef(ref, ctx) {
|
|
|
14514
14514
|
if (!ref.startsWith("#")) {
|
|
14515
14515
|
throw new Error("External $ref is not supported, only local refs (#/...) are allowed");
|
|
14516
14516
|
}
|
|
14517
|
-
const
|
|
14518
|
-
if (
|
|
14517
|
+
const path14 = ref.slice(1).split("/").filter(Boolean);
|
|
14518
|
+
if (path14.length === 0) {
|
|
14519
14519
|
return ctx.rootSchema;
|
|
14520
14520
|
}
|
|
14521
14521
|
const defsKey = ctx.version === "draft-2020-12" ? "$defs" : "definitions";
|
|
14522
|
-
if (
|
|
14523
|
-
const key =
|
|
14522
|
+
if (path14[0] === defsKey) {
|
|
14523
|
+
const key = path14[1];
|
|
14524
14524
|
if (!key || !ctx.defs[key]) {
|
|
14525
14525
|
throw new Error(`Reference not found: ${ref}`);
|
|
14526
14526
|
}
|
|
@@ -14928,87 +14928,6 @@ function date4(params) {
|
|
|
14928
14928
|
// ../../../node_modules/zod/v4/classic/external.js
|
|
14929
14929
|
config(en_default());
|
|
14930
14930
|
|
|
14931
|
-
// ../../shared-contracts/dist/ids.js
|
|
14932
|
-
var opaqueIdSchema = external_exports.string().refine((value) => value.trim().length > 0, {
|
|
14933
|
-
message: "Identifier must not be empty or whitespace"
|
|
14934
|
-
});
|
|
14935
|
-
var harnessIdSchema = opaqueIdSchema.brand();
|
|
14936
|
-
var hostThreadIdSchema = opaqueIdSchema.brand();
|
|
14937
|
-
var hostTurnIdSchema = opaqueIdSchema.brand();
|
|
14938
|
-
var hostItemIdSchema = opaqueIdSchema.brand();
|
|
14939
|
-
var hostInteractionIdSchema = opaqueIdSchema.brand();
|
|
14940
|
-
|
|
14941
|
-
// ../../shared-contracts/dist/harness-plugins.js
|
|
14942
|
-
var HARNESS_PLUGIN_MANIFEST_MAX_BYTES = 32 * 1024;
|
|
14943
|
-
var HARNESS_PLUGIN_ICON_MAX_BYTES = 128 * 1024;
|
|
14944
|
-
var HARNESS_PLUGIN_LIMIT = 128;
|
|
14945
|
-
var installedPluginIdSchema = external_exports.string().min(1).max(128).regex(/^[a-z][a-z0-9]*(?:[._-][a-z0-9]+)*$/u);
|
|
14946
|
-
var installedHarnessPluginIdSchema = installedPluginIdSchema.pipe(harnessIdSchema);
|
|
14947
|
-
var harnessPluginIdSchema = installedHarnessPluginIdSchema.refine((id) => id !== "codex", "The official Codex identity is reserved");
|
|
14948
|
-
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");
|
|
14949
|
-
var documentationUrlSchema = external_exports.url().refine((value) => /^https:\/\/[^/?#@]+(?:[/?#]|$)/iu.test(value), "Plugin documentation links must be credential-free HTTPS URLs");
|
|
14950
|
-
var localizedTextSchema = external_exports.object({ en: external_exports.string().max(4096), "zh-CN": external_exports.string().max(4096).optional() }).strict();
|
|
14951
|
-
var harnessInstallationGuideSchema = external_exports.object({
|
|
14952
|
-
commands: external_exports.array(external_exports.object({ terminal: external_exports.string().max(256), command: external_exports.string().max(4096) }).strict()).max(8),
|
|
14953
|
-
before: localizedTextSchema.optional(),
|
|
14954
|
-
after: localizedTextSchema.optional(),
|
|
14955
|
-
downloads: external_exports.array(external_exports.object({ label: external_exports.string().max(128), url: documentationUrlSchema }).strict()).max(8).optional()
|
|
14956
|
-
}).strict();
|
|
14957
|
-
var pluginPresentationShape = {
|
|
14958
|
-
id: installedHarnessPluginIdSchema,
|
|
14959
|
-
name: external_exports.string().trim().min(1).max(128),
|
|
14960
|
-
version: external_exports.string().min(1).max(128),
|
|
14961
|
-
/** Capability-only plugin; omitted for existing session-capable plugins. */
|
|
14962
|
-
kind: external_exports.literal("usage").optional(),
|
|
14963
|
-
/** Original image styling or bounded vector paths; never arbitrary CSS/SVG markup. */
|
|
14964
|
-
iconStyle: external_exports.object({
|
|
14965
|
-
vector: external_exports.object({
|
|
14966
|
-
viewBox: external_exports.string().max(128).regex(/^-?\d+(?:\.\d+)?(?: +-?\d+(?:\.\d+)?){3}$/u),
|
|
14967
|
-
color: external_exports.string().regex(/^(?:currentColor|#[a-f0-9]{6})$/iu),
|
|
14968
|
-
paths: external_exports.array(external_exports.object({
|
|
14969
|
-
d: external_exports.string().min(1).max(32768).regex(/^[MmLlHhVvCcSsQqTtAaZz\d.,+eE\s-]+$/u),
|
|
14970
|
-
fillRule: external_exports.enum(["evenodd", "nonzero"]).optional(),
|
|
14971
|
-
fill: external_exports.string().regex(/^(?:currentColor|#[a-f0-9]{6})$/iu).optional()
|
|
14972
|
-
}).strict()).min(1).max(32)
|
|
14973
|
-
}).strict().optional(),
|
|
14974
|
-
background: external_exports.string().regex(/^#[a-f0-9]{6}$/iu).optional(),
|
|
14975
|
-
borderRadius: external_exports.number().min(0).max(50).optional(),
|
|
14976
|
-
paddingRatio: external_exports.number().min(0).max(0.25).optional()
|
|
14977
|
-
}).strict().optional(),
|
|
14978
|
-
installation: harnessInstallationGuideSchema.optional(),
|
|
14979
|
-
notice: localizedTextSchema.optional(),
|
|
14980
|
-
/** The factory accepts a persisted local entrypoint through its construction context. */
|
|
14981
|
-
launchCommand: external_exports.literal(true).optional(),
|
|
14982
|
-
links: external_exports.object({
|
|
14983
|
-
website: documentationUrlSchema.optional(),
|
|
14984
|
-
documentation: documentationUrlSchema.optional(),
|
|
14985
|
-
installation: documentationUrlSchema.optional()
|
|
14986
|
-
}).strict().optional()
|
|
14987
|
-
};
|
|
14988
|
-
var harnessPluginManifestSchema = external_exports.object({
|
|
14989
|
-
manifestVersion: external_exports.literal(1),
|
|
14990
|
-
...pluginPresentationShape,
|
|
14991
|
-
adapterApiVersion: external_exports.number().int().positive(),
|
|
14992
|
-
entry: pluginRelativeResourceSchema,
|
|
14993
|
-
icon: pluginRelativeResourceSchema.optional()
|
|
14994
|
-
}).strict();
|
|
14995
|
-
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);
|
|
14996
|
-
var harnessPluginDescriptorSchema = external_exports.object({
|
|
14997
|
-
...pluginPresentationShape,
|
|
14998
|
-
icon: harnessPluginIconSchema.optional()
|
|
14999
|
-
}).strict();
|
|
15000
|
-
var harnessPluginListParamsSchema = external_exports.object({}).strict();
|
|
15001
|
-
var harnessPluginListResultSchema = external_exports.object({
|
|
15002
|
-
plugins: external_exports.array(harnessPluginDescriptorSchema.extend({ id: harnessPluginIdSchema })).max(HARNESS_PLUGIN_LIMIT)
|
|
15003
|
-
}).strict();
|
|
15004
|
-
var harnessPluginConfigurationSchema = external_exports.object({
|
|
15005
|
-
version: external_exports.literal(1),
|
|
15006
|
-
enabled: external_exports.array(installedHarnessPluginIdSchema).max(HARNESS_PLUGIN_LIMIT)
|
|
15007
|
-
}).strict().refine((value) => new Set(value.enabled).size === value.enabled.length, {
|
|
15008
|
-
message: "Enabled plugin IDs must be unique",
|
|
15009
|
-
path: ["enabled"]
|
|
15010
|
-
});
|
|
15011
|
-
|
|
15012
14931
|
// ../../shared-contracts/dist/json-value.js
|
|
15013
14932
|
function rejectExplicitUndefined(keys) {
|
|
15014
14933
|
return (value, context) => {
|
|
@@ -15068,403 +14987,73 @@ var jsonValueSchema = nonCircularSchema.pipe(recursiveJsonValueSchema);
|
|
|
15068
14987
|
var jsonArraySchema = nonCircularSchema.pipe(external_exports.array(recursiveJsonValueSchema));
|
|
15069
14988
|
var jsonObjectSchema = nonCircularSchema.pipe(external_exports.record(external_exports.string(), recursiveJsonValueSchema));
|
|
15070
14989
|
|
|
15071
|
-
// ../../shared-contracts/dist/
|
|
15072
|
-
var
|
|
15073
|
-
|
|
15074
|
-
|
|
15075
|
-
|
|
15076
|
-
|
|
15077
|
-
|
|
15078
|
-
|
|
15079
|
-
|
|
15080
|
-
|
|
15081
|
-
|
|
15082
|
-
|
|
15083
|
-
var
|
|
15084
|
-
var
|
|
15085
|
-
var
|
|
15086
|
-
|
|
15087
|
-
|
|
15088
|
-
|
|
15089
|
-
|
|
15090
|
-
|
|
15091
|
-
|
|
15092
|
-
var
|
|
15093
|
-
"
|
|
15094
|
-
|
|
15095
|
-
|
|
15096
|
-
|
|
15097
|
-
|
|
15098
|
-
|
|
15099
|
-
|
|
15100
|
-
|
|
15101
|
-
|
|
15102
|
-
|
|
15103
|
-
|
|
15104
|
-
|
|
15105
|
-
|
|
15106
|
-
|
|
15107
|
-
|
|
15108
|
-
|
|
15109
|
-
|
|
15110
|
-
|
|
15111
|
-
|
|
14990
|
+
// ../../shared-contracts/dist/errors.js
|
|
14991
|
+
var codexhostErrorSchema = external_exports.strictObject({
|
|
14992
|
+
code: external_exports.string().min(1),
|
|
14993
|
+
message: external_exports.string().min(1),
|
|
14994
|
+
retryable: external_exports.boolean(),
|
|
14995
|
+
diagnostic: external_exports.string().min(1).optional(),
|
|
14996
|
+
stage: external_exports.string().min(1).optional(),
|
|
14997
|
+
durationMs: external_exports.number().int().nonnegative().optional(),
|
|
14998
|
+
stderrTail: external_exports.string().min(1).optional()
|
|
14999
|
+
}).superRefine(rejectExplicitUndefined(["diagnostic", "stage", "durationMs", "stderrTail"]));
|
|
15000
|
+
|
|
15001
|
+
// ../../shared-contracts/dist/harness-presentation.js
|
|
15002
|
+
var localeSchema = external_exports.string().max(64).regex(/^[a-z]{2,3}(?:-[A-Za-z0-9]{2,8})*$/u);
|
|
15003
|
+
var displayText = (maximum) => external_exports.string().min(1).max(maximum).refine((text2) => text2.trim().length > 0);
|
|
15004
|
+
var harnessLocalizationsSchema = external_exports.record(localeSchema, external_exports.object({
|
|
15005
|
+
label: displayText(256).optional(),
|
|
15006
|
+
description: displayText(1024).optional()
|
|
15007
|
+
}).strict()).refine((entries) => Object.keys(entries).length <= 16, "Too many locales");
|
|
15008
|
+
var harnessLocalizedTextSchema = external_exports.record(localeSchema, displayText(4096)).refine((entries) => typeof entries.en === "string", "English fallback is required").refine((entries) => Object.keys(entries).length <= 16, "Too many locales");
|
|
15009
|
+
|
|
15010
|
+
// ../../shared-contracts/dist/ids.js
|
|
15011
|
+
var opaqueIdSchema = external_exports.string().refine((value) => value.trim().length > 0, {
|
|
15012
|
+
message: "Identifier must not be empty or whitespace"
|
|
15013
|
+
});
|
|
15014
|
+
var harnessIdSchema = opaqueIdSchema.brand();
|
|
15015
|
+
var hostThreadIdSchema = opaqueIdSchema.brand();
|
|
15016
|
+
var hostTurnIdSchema = opaqueIdSchema.brand();
|
|
15017
|
+
var hostItemIdSchema = opaqueIdSchema.brand();
|
|
15018
|
+
var hostInteractionIdSchema = opaqueIdSchema.brand();
|
|
15019
|
+
|
|
15020
|
+
// ../../shared-contracts/dist/harness-permission-modes.js
|
|
15021
|
+
var HARNESS_PERMISSION_MODE_ID_MAX_LENGTH = 128;
|
|
15022
|
+
var HARNESS_PERMISSION_MODE_LABEL_MAX_LENGTH = 256;
|
|
15023
|
+
var HARNESS_PERMISSION_MODE_DESCRIPTION_MAX_LENGTH = 1024;
|
|
15024
|
+
var HARNESS_PERMISSION_MODE_CATALOG_MAX_LENGTH = 32;
|
|
15025
|
+
var nonBlankTextSchema = external_exports.string().refine((value) => value.trim().length > 0, {
|
|
15026
|
+
message: "Value must not be empty or whitespace"
|
|
15027
|
+
});
|
|
15028
|
+
var harnessPermissionModeIdSchema = nonBlankTextSchema.max(HARNESS_PERMISSION_MODE_ID_MAX_LENGTH).regex(/^[A-Za-z0-9._~:-]+$/u, "Permission Mode ID must use transport-safe characters").brand();
|
|
15029
|
+
var harnessPermissionModeSchema = external_exports.object({
|
|
15030
|
+
id: harnessPermissionModeIdSchema,
|
|
15031
|
+
label: nonBlankTextSchema.max(HARNESS_PERMISSION_MODE_LABEL_MAX_LENGTH),
|
|
15032
|
+
description: nonBlankTextSchema.max(HARNESS_PERMISSION_MODE_DESCRIPTION_MAX_LENGTH).optional(),
|
|
15033
|
+
dangerous: external_exports.boolean().optional(),
|
|
15034
|
+
localizations: harnessLocalizationsSchema.optional()
|
|
15035
|
+
}).strict();
|
|
15036
|
+
var harnessPermissionModeCatalogSchema = external_exports.object({
|
|
15037
|
+
modes: external_exports.array(harnessPermissionModeSchema).min(1).max(HARNESS_PERMISSION_MODE_CATALOG_MAX_LENGTH),
|
|
15038
|
+
defaultModeId: harnessPermissionModeIdSchema
|
|
15039
|
+
}).strict().superRefine((catalog, context) => {
|
|
15040
|
+
const ids = /* @__PURE__ */ new Set();
|
|
15041
|
+
for (const [index, mode] of catalog.modes.entries()) {
|
|
15042
|
+
if (ids.has(mode.id)) {
|
|
15043
|
+
context.addIssue({
|
|
15044
|
+
code: "custom",
|
|
15045
|
+
message: "Permission Mode IDs must be unique",
|
|
15046
|
+
path: ["modes", index, "id"]
|
|
15047
|
+
});
|
|
15048
|
+
}
|
|
15049
|
+
ids.add(mode.id);
|
|
15112
15050
|
}
|
|
15113
|
-
|
|
15114
|
-
|
|
15115
|
-
|
|
15116
|
-
|
|
15117
|
-
|
|
15118
|
-
|
|
15119
|
-
return "image/svg+xml";
|
|
15120
|
-
case "woff2":
|
|
15121
|
-
return "font/woff2";
|
|
15122
|
-
case "json":
|
|
15123
|
-
return "application/json";
|
|
15124
|
-
case "css":
|
|
15125
|
-
return "text/css";
|
|
15126
|
-
default:
|
|
15127
|
-
return desktopExtensionScreenshotMimeType(resource);
|
|
15128
|
-
}
|
|
15129
|
-
}
|
|
15130
|
-
var hasPortableSegments = (resource) => resource.split("/").every((segment) => !/[. ]$/u.test(segment));
|
|
15131
|
-
var desktopExtensionAssetPathSchema = pluginRelativeResourceSchema.refine((resource) => hasPortableSegments(resource) && desktopExtensionAssetMimeType(resource) !== void 0, "Expected a relative Desktop extension asset path with a supported suffix");
|
|
15132
|
-
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");
|
|
15133
|
-
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) => {
|
|
15134
|
-
const { username, password } = new URL(value);
|
|
15135
|
-
return !username && !password && !/[\\\s]/u.test(value);
|
|
15136
|
-
}, "URL must not contain credentials, backslashes, or whitespace");
|
|
15137
|
-
function localizedText(text2) {
|
|
15138
|
-
return external_exports.strictObject({ en: text2, "zh-CN": text2 });
|
|
15139
|
-
}
|
|
15140
|
-
var desktopExtensionLocalizedTextSchema = localizedText(external_exports.string().trim().min(1));
|
|
15141
|
-
var categoriesSchema = external_exports.array(desktopExtensionCategorySchema).max(desktopExtensionCategorySchema.options.length).refine((categories) => new Set(categories).size === categories.length, "Duplicate categories");
|
|
15142
|
-
var slotsSchema = external_exports.array(desktopExtensionSlotSchema).max(desktopExtensionSlotSchema.options.length).refine((slots) => new Set(slots).size === slots.length, "Duplicate slots");
|
|
15143
|
-
var settingField = {
|
|
15144
|
-
key: external_exports.string().regex(/^[A-Za-z_][A-Za-z0-9_]*$/u),
|
|
15145
|
-
label: desktopExtensionLocalizedTextSchema,
|
|
15146
|
-
description: desktopExtensionLocalizedTextSchema.optional()
|
|
15147
|
-
};
|
|
15148
|
-
var numericSetting = {
|
|
15149
|
-
...settingField,
|
|
15150
|
-
step: external_exports.number().positive().optional(),
|
|
15151
|
-
default: external_exports.number().optional()
|
|
15152
|
-
};
|
|
15153
|
-
var settingOption = external_exports.strictObject({
|
|
15154
|
-
value: external_exports.string(),
|
|
15155
|
-
label: desktopExtensionLocalizedTextSchema
|
|
15156
|
-
});
|
|
15157
|
-
var desktopExtensionSettingFieldSchema = external_exports.discriminatedUnion("type", [
|
|
15158
|
-
external_exports.strictObject({
|
|
15159
|
-
...settingField,
|
|
15160
|
-
type: external_exports.literal("boolean"),
|
|
15161
|
-
default: external_exports.boolean().optional()
|
|
15162
|
-
}),
|
|
15163
|
-
external_exports.strictObject({
|
|
15164
|
-
...settingField,
|
|
15165
|
-
type: external_exports.literal("string"),
|
|
15166
|
-
placeholder: desktopExtensionLocalizedTextSchema.optional(),
|
|
15167
|
-
default: external_exports.string().optional()
|
|
15168
|
-
}),
|
|
15169
|
-
external_exports.strictObject({
|
|
15170
|
-
...numericSetting,
|
|
15171
|
-
type: external_exports.literal("number"),
|
|
15172
|
-
min: external_exports.number().optional(),
|
|
15173
|
-
max: external_exports.number().optional()
|
|
15174
|
-
}),
|
|
15175
|
-
external_exports.strictObject({
|
|
15176
|
-
...numericSetting,
|
|
15177
|
-
type: external_exports.literal("range"),
|
|
15178
|
-
min: external_exports.number(),
|
|
15179
|
-
max: external_exports.number()
|
|
15180
|
-
}),
|
|
15181
|
-
external_exports.strictObject({
|
|
15182
|
-
...settingField,
|
|
15183
|
-
type: external_exports.literal("select"),
|
|
15184
|
-
options: external_exports.array(settingOption).min(1),
|
|
15185
|
-
default: external_exports.string().optional()
|
|
15186
|
-
})
|
|
15187
|
-
]).superRefine((field3, ctx) => {
|
|
15188
|
-
const issue2 = (path13, message3) => ctx.addIssue({ code: "custom", path: [path13], message: message3 });
|
|
15189
|
-
if (field3.type === "number" || field3.type === "range") {
|
|
15190
|
-
const { min = -Infinity, max = Infinity, default: value } = field3;
|
|
15191
|
-
if (min > max)
|
|
15192
|
-
issue2("max", "Must be at least min");
|
|
15193
|
-
if (value !== void 0 && (value < min || value > max))
|
|
15194
|
-
issue2("default", "Must be within min and max");
|
|
15195
|
-
} else if (field3.type === "select") {
|
|
15196
|
-
const values = new Set(field3.options.map(({ value }) => value));
|
|
15197
|
-
if (values.size !== field3.options.length)
|
|
15198
|
-
issue2("options", "Duplicate option values");
|
|
15199
|
-
if (field3.default !== void 0 && !values.has(field3.default))
|
|
15200
|
-
issue2("default", "Must match an option value");
|
|
15201
|
-
}
|
|
15202
|
-
});
|
|
15203
|
-
var manifestHeader = external_exports.object({
|
|
15204
|
-
manifestVersion: external_exports.int().positive(),
|
|
15205
|
-
id: desktopExtensionIdSchema,
|
|
15206
|
-
name: external_exports.union([extensionName, localizedText(extensionName)]),
|
|
15207
|
-
version: external_exports.string().min(1).max(128),
|
|
15208
|
-
desktopApi: external_exports.int().positive()
|
|
15209
|
-
}).passthrough();
|
|
15210
|
-
var desktopExtensionManifestSchema = manifestHeader.extend({
|
|
15211
|
-
manifestVersion: external_exports.literal(1),
|
|
15212
|
-
desktopApi: external_exports.literal(DESKTOP_EXTENSION_API_VERSION),
|
|
15213
|
-
description: external_exports.strictObject({ en: external_exports.string().max(4096), "zh-CN": external_exports.string().max(4096).optional() }).optional(),
|
|
15214
|
-
author: external_exports.string().trim().min(1).max(128).optional(),
|
|
15215
|
-
repository: desktopExtensionHttpUrlSchema.optional(),
|
|
15216
|
-
details: external_exports.strictObject({ en: external_exports.string().max(16384), "zh-CN": external_exports.string().max(16384).optional() }).optional(),
|
|
15217
|
-
icon: imagePathSchema.optional(),
|
|
15218
|
-
screenshots: external_exports.array(imagePathSchema).max(DESKTOP_EXTENSION_SCREENSHOT_LIMIT).refine((screenshots) => new Set(screenshots).size === screenshots.length, "Duplicate screenshots").optional(),
|
|
15219
|
-
desktop: external_exports.strictObject({
|
|
15220
|
-
script: pluginRelativeResourceSchema,
|
|
15221
|
-
style: pluginRelativeResourceSchema.optional()
|
|
15222
|
-
}).optional(),
|
|
15223
|
-
backend: external_exports.strictObject({ script: pluginRelativeResourceSchema.refine(hasPortableSegments) }).optional(),
|
|
15224
|
-
slots: slotsSchema.default(() => []),
|
|
15225
|
-
settingsSchema: external_exports.array(desktopExtensionSettingFieldSchema).max(32).refine((fields) => new Set(fields.map(({ key }) => key)).size === fields.length, "Duplicate setting keys").optional(),
|
|
15226
|
-
categories: categoriesSchema.optional()
|
|
15227
|
-
}).strict().refine((manifest) => manifest.desktop !== void 0 || manifest.backend !== void 0, "Expected at least one desktop or backend entry");
|
|
15228
|
-
var desktopExtensionConfigurationSchema = external_exports.strictObject({
|
|
15229
|
-
version: external_exports.literal(1),
|
|
15230
|
-
revision: external_exports.int().nonnegative(),
|
|
15231
|
-
enabled: external_exports.array(desktopExtensionIdSchema).max(DESKTOP_EXTENSION_LIMIT).refine((ids) => new Set(ids).size === ids.length, "Duplicate extension IDs"),
|
|
15232
|
-
reloadToken: external_exports.uuid().optional()
|
|
15233
|
-
});
|
|
15234
|
-
var desktopExtensionHashSchema = external_exports.string().regex(/^[a-f0-9]{64}$/u);
|
|
15235
|
-
var desktopExtensionStatusSchema = external_exports.strictObject({
|
|
15236
|
-
state: external_exports.enum([
|
|
15237
|
-
"running",
|
|
15238
|
-
"disabled",
|
|
15239
|
-
"invalid",
|
|
15240
|
-
"incompatible",
|
|
15241
|
-
"conflict",
|
|
15242
|
-
"failed",
|
|
15243
|
-
"waiting"
|
|
15244
|
-
]),
|
|
15245
|
-
hash: desktopExtensionHashSchema.optional(),
|
|
15246
|
-
error: external_exports.string().optional(),
|
|
15247
|
-
conflictWith: desktopExtensionIdSchema.optional()
|
|
15248
|
-
});
|
|
15249
|
-
var desktopExtensionsDiagnosticSchema = external_exports.strictObject({
|
|
15250
|
-
controllerPid: external_exports.int().positive(),
|
|
15251
|
-
targetId: external_exports.string().nullable(),
|
|
15252
|
-
updatedAt: external_exports.iso.datetime(),
|
|
15253
|
-
handledReloadToken: external_exports.uuid().optional(),
|
|
15254
|
-
extensions: external_exports.record(external_exports.string(), desktopExtensionStatusSchema)
|
|
15255
|
-
});
|
|
15256
|
-
var desktopExtensionTrustTierSchema = external_exports.enum(["official", "community"]);
|
|
15257
|
-
function isGitHubDesktopExtensionZipballUrl(url2) {
|
|
15258
|
-
return url2.origin === "https://api.github.com" && /^\/repos\/[\w-]+\/[\w.-]+\/zipball(?:\/[^/]+)?\/?$/u.test(url2.pathname);
|
|
15259
|
-
}
|
|
15260
|
-
var desktopExtensionZipUrlSchema = desktopExtensionHttpUrlSchema.refine((input) => {
|
|
15261
|
-
const url2 = new URL(input);
|
|
15262
|
-
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);
|
|
15263
|
-
}, "Expected a .zip download URL or a GitHub zipball URL");
|
|
15264
|
-
var desktopExtensionCatalogEntrySchema = external_exports.strictObject({
|
|
15265
|
-
id: desktopExtensionIdSchema,
|
|
15266
|
-
version: external_exports.string().trim().min(1).max(128),
|
|
15267
|
-
name: desktopExtensionLocalizedTextSchema.extend({ en: extensionName, "zh-CN": extensionName }),
|
|
15268
|
-
description: localizedText(external_exports.string().trim().min(1).max(4096)),
|
|
15269
|
-
details: localizedText(external_exports.string().trim().min(1).max(16384)).optional(),
|
|
15270
|
-
author: external_exports.string().trim().min(1).max(128),
|
|
15271
|
-
repository: desktopExtensionHttpUrlSchema,
|
|
15272
|
-
stars: external_exports.number().int().min(0).optional(),
|
|
15273
|
-
downloads: external_exports.number().int().min(0).optional(),
|
|
15274
|
-
categories: categoriesSchema.optional(),
|
|
15275
|
-
trustTier: desktopExtensionTrustTierSchema.default("community"),
|
|
15276
|
-
icon: desktopExtensionHttpUrlSchema.optional(),
|
|
15277
|
-
screenshots: external_exports.array(desktopExtensionHttpUrlSchema).max(DESKTOP_EXTENSION_SCREENSHOT_LIMIT).optional(),
|
|
15278
|
-
downloadUrl: desktopExtensionZipUrlSchema,
|
|
15279
|
-
sha256: desktopExtensionHashSchema,
|
|
15280
|
-
slots: slotsSchema.optional(),
|
|
15281
|
-
publishedAt: external_exports.string().optional(),
|
|
15282
|
-
updatedAt: external_exports.string().optional(),
|
|
15283
|
-
minCodexHostVersion: external_exports.string().optional()
|
|
15284
|
-
});
|
|
15285
|
-
var desktopExtensionCatalogSchema = external_exports.strictObject({
|
|
15286
|
-
schemaVersion: external_exports.literal(1),
|
|
15287
|
-
generatedAt: external_exports.string(),
|
|
15288
|
-
extensions: external_exports.array(desktopExtensionCatalogEntrySchema).refine((entries) => new Set(entries.map(({ id }) => id)).size === entries.length, "Duplicate extension IDs")
|
|
15289
|
-
});
|
|
15290
|
-
var DESKTOP_EXTENSIONS_ASSET_METHOD = "codexhost/desktop/extensions/asset";
|
|
15291
|
-
var DESKTOP_EXTENSIONS_SETTINGS_GET_METHOD = "codexhost/desktop/extensions/settings/get";
|
|
15292
|
-
var DESKTOP_EXTENSIONS_SETTINGS_SET_METHOD = "codexhost/desktop/extensions/settings/set";
|
|
15293
|
-
var DESKTOP_EXTENSIONS_BACKEND_INVOKE_METHOD = "codexhost/desktop/extensions/backend/invoke";
|
|
15294
|
-
var extensionIdParams = { id: desktopExtensionIdSchema };
|
|
15295
|
-
var desktopExtensionsAssetParamsSchema = external_exports.strictObject({
|
|
15296
|
-
...extensionIdParams,
|
|
15297
|
-
path: desktopExtensionAssetPathSchema
|
|
15298
|
-
});
|
|
15299
|
-
var desktopExtensionsAssetResultSchema = external_exports.strictObject({
|
|
15300
|
-
mimeType: external_exports.string(),
|
|
15301
|
-
dataUrl: external_exports.string()
|
|
15302
|
-
});
|
|
15303
|
-
var desktopExtensionsSettingsGetParamsSchema = external_exports.strictObject(extensionIdParams);
|
|
15304
|
-
var desktopExtensionsSettingsSetParamsSchema = external_exports.strictObject({
|
|
15305
|
-
...extensionIdParams,
|
|
15306
|
-
values: jsonObjectSchema
|
|
15307
|
-
});
|
|
15308
|
-
var desktopExtensionsSettingsResultSchema = external_exports.strictObject({ values: jsonObjectSchema });
|
|
15309
|
-
var desktopExtensionBackendMethodSchema = external_exports.string().trim().min(1).max(128);
|
|
15310
|
-
var desktopExtensionsBackendInvokeParamsSchema = external_exports.strictObject({
|
|
15311
|
-
...extensionIdParams,
|
|
15312
|
-
method: desktopExtensionBackendMethodSchema,
|
|
15313
|
-
params: jsonValueSchema.optional()
|
|
15314
|
-
});
|
|
15315
|
-
var desktopExtensionsBackendInvokeResultSchema = external_exports.strictObject({
|
|
15316
|
-
result: jsonValueSchema
|
|
15317
|
-
});
|
|
15318
|
-
|
|
15319
|
-
// ../../shared-contracts/dist/desktop-extension-management.js
|
|
15320
|
-
var DESKTOP_EXTENSIONS_LIST_METHOD = "codexhost/desktop/extensions/list";
|
|
15321
|
-
var DESKTOP_EXTENSIONS_ENABLE_METHOD = "codexhost/desktop/extensions/enable";
|
|
15322
|
-
var DESKTOP_EXTENSIONS_DISABLE_METHOD = "codexhost/desktop/extensions/disable";
|
|
15323
|
-
var DESKTOP_EXTENSIONS_CATALOG_METHOD = "codexhost/desktop/extensions/catalog";
|
|
15324
|
-
var DESKTOP_EXTENSIONS_INSTALL_METHOD = "codexhost/desktop/extensions/install";
|
|
15325
|
-
var DESKTOP_EXTENSIONS_UNINSTALL_METHOD = "codexhost/desktop/extensions/uninstall";
|
|
15326
|
-
var DESKTOP_EXTENSIONS_RECOVER_METHOD = "codexhost/desktop/extensions/disable-all-and-reload";
|
|
15327
|
-
var DESKTOP_EXTENSION_MANAGEMENT_METHODS = [
|
|
15328
|
-
DESKTOP_EXTENSIONS_LIST_METHOD,
|
|
15329
|
-
DESKTOP_EXTENSIONS_ENABLE_METHOD,
|
|
15330
|
-
DESKTOP_EXTENSIONS_DISABLE_METHOD,
|
|
15331
|
-
DESKTOP_EXTENSIONS_RECOVER_METHOD,
|
|
15332
|
-
DESKTOP_EXTENSIONS_CATALOG_METHOD,
|
|
15333
|
-
DESKTOP_EXTENSIONS_INSTALL_METHOD,
|
|
15334
|
-
DESKTOP_EXTENSIONS_UNINSTALL_METHOD,
|
|
15335
|
-
DESKTOP_EXTENSIONS_ASSET_METHOD,
|
|
15336
|
-
DESKTOP_EXTENSIONS_SETTINGS_GET_METHOD,
|
|
15337
|
-
DESKTOP_EXTENSIONS_SETTINGS_SET_METHOD,
|
|
15338
|
-
DESKTOP_EXTENSIONS_BACKEND_INVOKE_METHOD
|
|
15339
|
-
];
|
|
15340
|
-
var revisionSchema = external_exports.int().nonnegative();
|
|
15341
|
-
var desktopExtensionsListParamsSchema = external_exports.strictObject({});
|
|
15342
|
-
var desktopExtensionSelectionParamsSchema = external_exports.strictObject({
|
|
15343
|
-
id: desktopExtensionIdSchema,
|
|
15344
|
-
expectedRevision: revisionSchema
|
|
15345
|
-
});
|
|
15346
|
-
var desktopExtensionsRecoveryParamsSchema = external_exports.strictObject({
|
|
15347
|
-
expectedRevision: revisionSchema.optional()
|
|
15348
|
-
});
|
|
15349
|
-
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);
|
|
15350
|
-
var desktopExtensionListItemSchema = external_exports.strictObject({
|
|
15351
|
-
// An invalid discovery can have a directory name that isn't a valid extension ID.
|
|
15352
|
-
id: external_exports.string().min(1),
|
|
15353
|
-
manifest: desktopExtensionManifestSchema.optional(),
|
|
15354
|
-
iconDataUrl: rasterDataUrlSchema(DESKTOP_EXTENSION_ICON_MAX_BYTES).optional(),
|
|
15355
|
-
screenshotDataUrls: external_exports.array(rasterDataUrlSchema(DESKTOP_EXTENSION_SCREENSHOT_MAX_BYTES)).max(DESKTOP_EXTENSION_SCREENSHOT_LIMIT).optional(),
|
|
15356
|
-
enabled: external_exports.boolean(),
|
|
15357
|
-
status: desktopExtensionStatusSchema
|
|
15358
|
-
});
|
|
15359
|
-
var desktopExtensionsListResultSchema = external_exports.strictObject({
|
|
15360
|
-
configuration: desktopExtensionConfigurationSchema,
|
|
15361
|
-
desktopConnected: external_exports.boolean(),
|
|
15362
|
-
diagnostics: external_exports.array(external_exports.string()),
|
|
15363
|
-
extensions: external_exports.array(desktopExtensionListItemSchema)
|
|
15364
|
-
});
|
|
15365
|
-
var desktopExtensionsCatalogParamsSchema = external_exports.strictObject({
|
|
15366
|
-
forceRefresh: external_exports.boolean().optional()
|
|
15367
|
-
});
|
|
15368
|
-
var desktopExtensionsCatalogResultSchema = external_exports.strictObject({
|
|
15369
|
-
catalogUrl: external_exports.string(),
|
|
15370
|
-
source: external_exports.enum(["remote", "fallback"]),
|
|
15371
|
-
fetchedAt: external_exports.string(),
|
|
15372
|
-
cached: external_exports.boolean(),
|
|
15373
|
-
extensions: desktopExtensionCatalogSchema.shape.extensions,
|
|
15374
|
-
error: external_exports.string().optional()
|
|
15375
|
-
});
|
|
15376
|
-
var desktopExtensionsInstallParamsSchema = external_exports.strictObject({
|
|
15377
|
-
source: external_exports.discriminatedUnion("type", [
|
|
15378
|
-
external_exports.strictObject({ type: external_exports.literal("catalog"), id: desktopExtensionIdSchema }),
|
|
15379
|
-
external_exports.strictObject({
|
|
15380
|
-
type: external_exports.literal("url"),
|
|
15381
|
-
url: desktopExtensionHttpUrlSchema,
|
|
15382
|
-
expectedSha256: desktopExtensionHashSchema.optional()
|
|
15383
|
-
}),
|
|
15384
|
-
external_exports.strictObject({
|
|
15385
|
-
type: external_exports.literal("zip-base64"),
|
|
15386
|
-
fileName: external_exports.string().trim().min(1).max(255),
|
|
15387
|
-
contentBase64: external_exports.string().min(4).max(DESKTOP_EXTENSION_ZIP_MAX_BASE64_LENGTH).refine((value) => value.length % 4 === 0 && /^[A-Za-z0-9+/]+={0,2}$/u.test(value), "Expected standard padded base64")
|
|
15388
|
-
})
|
|
15389
|
-
])
|
|
15390
|
-
});
|
|
15391
|
-
var desktopExtensionsInstallResultSchema = external_exports.strictObject({
|
|
15392
|
-
extensionId: desktopExtensionIdSchema,
|
|
15393
|
-
version: external_exports.string().min(1),
|
|
15394
|
-
replaced: external_exports.boolean(),
|
|
15395
|
-
installedPath: external_exports.string(),
|
|
15396
|
-
list: desktopExtensionsListResultSchema
|
|
15397
|
-
});
|
|
15398
|
-
var desktopExtensionsUninstallParamsSchema = external_exports.strictObject({
|
|
15399
|
-
id: desktopExtensionIdSchema
|
|
15400
|
-
});
|
|
15401
|
-
var desktopExtensionsUninstallResultSchema = external_exports.strictObject({
|
|
15402
|
-
removedId: desktopExtensionIdSchema,
|
|
15403
|
-
list: desktopExtensionsListResultSchema
|
|
15404
|
-
});
|
|
15405
|
-
var desktopExtensionMutationResultSchema = external_exports.discriminatedUnion("state", [
|
|
15406
|
-
external_exports.strictObject({ state: external_exports.literal("saved"), configuration: desktopExtensionConfigurationSchema }),
|
|
15407
|
-
external_exports.strictObject({ state: external_exports.literal("slot-conflict"), conflictWith: desktopExtensionIdSchema }),
|
|
15408
|
-
external_exports.strictObject({ state: external_exports.literal("revision-conflict"), revision: revisionSchema })
|
|
15409
|
-
]);
|
|
15410
|
-
|
|
15411
|
-
// ../../shared-contracts/dist/errors.js
|
|
15412
|
-
var codexhostErrorSchema = external_exports.strictObject({
|
|
15413
|
-
code: external_exports.string().min(1),
|
|
15414
|
-
message: external_exports.string().min(1),
|
|
15415
|
-
retryable: external_exports.boolean(),
|
|
15416
|
-
diagnostic: external_exports.string().min(1).optional(),
|
|
15417
|
-
stage: external_exports.string().min(1).optional(),
|
|
15418
|
-
durationMs: external_exports.number().int().nonnegative().optional(),
|
|
15419
|
-
stderrTail: external_exports.string().min(1).optional()
|
|
15420
|
-
}).superRefine(rejectExplicitUndefined(["diagnostic", "stage", "durationMs", "stderrTail"]));
|
|
15421
|
-
|
|
15422
|
-
// ../../shared-contracts/dist/harness-presentation.js
|
|
15423
|
-
var localeSchema = external_exports.string().max(64).regex(/^[a-z]{2,3}(?:-[A-Za-z0-9]{2,8})*$/u);
|
|
15424
|
-
var displayText = (maximum) => external_exports.string().min(1).max(maximum).refine((text2) => text2.trim().length > 0);
|
|
15425
|
-
var harnessLocalizationsSchema = external_exports.record(localeSchema, external_exports.object({
|
|
15426
|
-
label: displayText(256).optional(),
|
|
15427
|
-
description: displayText(1024).optional()
|
|
15428
|
-
}).strict()).refine((entries) => Object.keys(entries).length <= 16, "Too many locales");
|
|
15429
|
-
var harnessLocalizedTextSchema = external_exports.record(localeSchema, displayText(4096)).refine((entries) => typeof entries.en === "string", "English fallback is required").refine((entries) => Object.keys(entries).length <= 16, "Too many locales");
|
|
15430
|
-
|
|
15431
|
-
// ../../shared-contracts/dist/harness-permission-modes.js
|
|
15432
|
-
var HARNESS_PERMISSION_MODE_ID_MAX_LENGTH = 128;
|
|
15433
|
-
var HARNESS_PERMISSION_MODE_LABEL_MAX_LENGTH = 256;
|
|
15434
|
-
var HARNESS_PERMISSION_MODE_DESCRIPTION_MAX_LENGTH = 1024;
|
|
15435
|
-
var HARNESS_PERMISSION_MODE_CATALOG_MAX_LENGTH = 32;
|
|
15436
|
-
var nonBlankTextSchema = external_exports.string().refine((value) => value.trim().length > 0, {
|
|
15437
|
-
message: "Value must not be empty or whitespace"
|
|
15438
|
-
});
|
|
15439
|
-
var harnessPermissionModeIdSchema = nonBlankTextSchema.max(HARNESS_PERMISSION_MODE_ID_MAX_LENGTH).regex(/^[A-Za-z0-9._~:-]+$/u, "Permission Mode ID must use transport-safe characters").brand();
|
|
15440
|
-
var harnessPermissionModeSchema = external_exports.object({
|
|
15441
|
-
id: harnessPermissionModeIdSchema,
|
|
15442
|
-
label: nonBlankTextSchema.max(HARNESS_PERMISSION_MODE_LABEL_MAX_LENGTH),
|
|
15443
|
-
description: nonBlankTextSchema.max(HARNESS_PERMISSION_MODE_DESCRIPTION_MAX_LENGTH).optional(),
|
|
15444
|
-
dangerous: external_exports.boolean().optional(),
|
|
15445
|
-
localizations: harnessLocalizationsSchema.optional()
|
|
15446
|
-
}).strict();
|
|
15447
|
-
var harnessPermissionModeCatalogSchema = external_exports.object({
|
|
15448
|
-
modes: external_exports.array(harnessPermissionModeSchema).min(1).max(HARNESS_PERMISSION_MODE_CATALOG_MAX_LENGTH),
|
|
15449
|
-
defaultModeId: harnessPermissionModeIdSchema
|
|
15450
|
-
}).strict().superRefine((catalog, context) => {
|
|
15451
|
-
const ids = /* @__PURE__ */ new Set();
|
|
15452
|
-
for (const [index, mode] of catalog.modes.entries()) {
|
|
15453
|
-
if (ids.has(mode.id)) {
|
|
15454
|
-
context.addIssue({
|
|
15455
|
-
code: "custom",
|
|
15456
|
-
message: "Permission Mode IDs must be unique",
|
|
15457
|
-
path: ["modes", index, "id"]
|
|
15458
|
-
});
|
|
15459
|
-
}
|
|
15460
|
-
ids.add(mode.id);
|
|
15461
|
-
}
|
|
15462
|
-
if (!ids.has(catalog.defaultModeId)) {
|
|
15463
|
-
context.addIssue({
|
|
15464
|
-
code: "custom",
|
|
15465
|
-
message: "Default Permission Mode must exist in the catalog",
|
|
15466
|
-
path: ["defaultModeId"]
|
|
15467
|
-
});
|
|
15051
|
+
if (!ids.has(catalog.defaultModeId)) {
|
|
15052
|
+
context.addIssue({
|
|
15053
|
+
code: "custom",
|
|
15054
|
+
message: "Default Permission Mode must exist in the catalog",
|
|
15055
|
+
path: ["defaultModeId"]
|
|
15056
|
+
});
|
|
15468
15057
|
}
|
|
15469
15058
|
});
|
|
15470
15059
|
var threadPermissionModeSelectParamsSchema = external_exports.object({
|
|
@@ -15472,6 +15061,9 @@ var threadPermissionModeSelectParamsSchema = external_exports.object({
|
|
|
15472
15061
|
permissionModeId: harnessPermissionModeIdSchema
|
|
15473
15062
|
}).strict();
|
|
15474
15063
|
|
|
15064
|
+
// ../../shared-contracts/dist/harness-route-limit.js
|
|
15065
|
+
var HARNESS_TRANSPORT_MODEL_ID_MAX_LENGTH = 8192;
|
|
15066
|
+
|
|
15475
15067
|
// ../../shared-contracts/dist/thread-usage.js
|
|
15476
15068
|
var nonNegativeSafeIntegerSchema = external_exports.number().int().safe().nonnegative();
|
|
15477
15069
|
var finiteNonNegativeNumberSchema = external_exports.number().finite().nonnegative();
|
|
@@ -15504,7 +15096,7 @@ var composerIndicatorsSchema = external_exports.array(external_exports.object({
|
|
|
15504
15096
|
expiresAtUnix: nonNegativeSafeIntegerSchema,
|
|
15505
15097
|
label: indicatorTextSchema(256).optional(),
|
|
15506
15098
|
tooltip: indicatorTextSchema(1024).optional()
|
|
15507
|
-
}).strict()).max(2).refine((entries) => new Set(entries.map(({ id }) =>
|
|
15099
|
+
}).strict()).max(2).refine((entries) => new Set(entries.map(({ id: id2 }) => id2)).size === entries.length, {
|
|
15508
15100
|
message: "Composer indicator IDs must be unique"
|
|
15509
15101
|
});
|
|
15510
15102
|
var threadUsageSnapshotSchema = external_exports.object({
|
|
@@ -15530,6 +15122,7 @@ var threadUsageSnapshotSchema = external_exports.object({
|
|
|
15530
15122
|
planSevenDayResetsAtUnix: nonNegativeSafeIntegerSchema.optional(),
|
|
15531
15123
|
sessionCacheHitRatePercent: cacheHitRatePercentSchema.optional(),
|
|
15532
15124
|
timeToFirstOutputMs: nonNegativeSafeIntegerSchema.optional(),
|
|
15125
|
+
latestRequestTimeToFirstOutputMs: nonNegativeSafeIntegerSchema.optional(),
|
|
15533
15126
|
costSource: external_exports.enum(["publicPrice", "native"]).optional(),
|
|
15534
15127
|
unpricedModels: external_exports.array(external_exports.string().min(1)).min(1).optional()
|
|
15535
15128
|
}).strict().superRefine((usage, context) => {
|
|
@@ -15657,10 +15250,15 @@ var THREAD_OWNERSHIP_LIST_MAX_LENGTH = 100;
|
|
|
15657
15250
|
var nonBlankTextSchema2 = external_exports.string().refine((value) => value.trim().length > 0, {
|
|
15658
15251
|
message: "Value must not be empty or whitespace"
|
|
15659
15252
|
});
|
|
15660
|
-
var harnessModelRefIdSchema =
|
|
15253
|
+
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();
|
|
15254
|
+
var harnessModelServiceTierSchema = external_exports.enum(["priority", "ultrafast"]);
|
|
15661
15255
|
var harnessModelRefSchema = external_exports.object({
|
|
15662
|
-
id: harnessModelRefIdSchema
|
|
15256
|
+
id: harnessModelRefIdSchema,
|
|
15257
|
+
serviceTier: harnessModelServiceTierSchema.optional()
|
|
15663
15258
|
}).strict();
|
|
15259
|
+
function sameHarnessModelRef(left, right) {
|
|
15260
|
+
return left?.id === right?.id && left?.serviceTier === right?.serviceTier;
|
|
15261
|
+
}
|
|
15664
15262
|
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();
|
|
15665
15263
|
var harnessResolvedModelLabelSchema = nonBlankTextSchema2.max(HARNESS_MODEL_LABEL_MAX_LENGTH);
|
|
15666
15264
|
var harnessThinkingOptionSchema = external_exports.object({
|
|
@@ -15674,7 +15272,15 @@ var harnessModelSchema = external_exports.object({
|
|
|
15674
15272
|
/** Optional opaque selection for this same Model with priority processing enabled. */
|
|
15675
15273
|
fastModel: harnessModelRefSchema.optional(),
|
|
15676
15274
|
supportedThinkingOptionIds: external_exports.array(harnessThinkingOptionIdSchema).optional()
|
|
15677
|
-
}).strict()
|
|
15275
|
+
}).strict().refine((model2) => model2.fastModel?.serviceTier === void 0 || model2.fastModel.id === model2.ref.id, {
|
|
15276
|
+
path: ["fastModel", "id"],
|
|
15277
|
+
message: "A tiered Fast Model must share the base Model ID"
|
|
15278
|
+
});
|
|
15279
|
+
function catalogModelForRef(catalog, ref) {
|
|
15280
|
+
if (!ref)
|
|
15281
|
+
return void 0;
|
|
15282
|
+
return catalog?.models.find((model2) => sameHarnessModelRef(model2.ref, ref) || sameHarnessModelRef(model2.fastModel, ref));
|
|
15283
|
+
}
|
|
15678
15284
|
var harnessThinkingOptionsSchema = external_exports.array(harnessThinkingOptionSchema).superRefine((options, context) => {
|
|
15679
15285
|
const ids = /* @__PURE__ */ new Set();
|
|
15680
15286
|
for (const [index, option] of options.entries()) {
|
|
@@ -15694,26 +15300,26 @@ var harnessModelCatalogSchema = external_exports.object({
|
|
|
15694
15300
|
thinkingOptions: harnessThinkingOptionsSchema,
|
|
15695
15301
|
defaultThinkingOptionId: harnessThinkingOptionIdSchema.optional()
|
|
15696
15302
|
}).strict().superRefine((catalog, context) => {
|
|
15697
|
-
const refs =
|
|
15698
|
-
const thinkingIds = new Set(catalog.thinkingOptions.map(({ id }) =>
|
|
15303
|
+
const refs = [];
|
|
15304
|
+
const thinkingIds = new Set(catalog.thinkingOptions.map(({ id: id2 }) => id2));
|
|
15699
15305
|
for (const [index, model2] of catalog.models.entries()) {
|
|
15700
|
-
if (refs.
|
|
15306
|
+
if (refs.some((ref) => sameHarnessModelRef(ref, model2.ref))) {
|
|
15701
15307
|
context.addIssue({
|
|
15702
15308
|
code: "custom",
|
|
15703
15309
|
message: "Model Catalog refs must be unique",
|
|
15704
15310
|
path: ["models", index, "ref", "id"]
|
|
15705
15311
|
});
|
|
15706
15312
|
}
|
|
15707
|
-
refs.
|
|
15313
|
+
refs.push(model2.ref);
|
|
15708
15314
|
if (model2.fastModel) {
|
|
15709
|
-
if (refs.
|
|
15315
|
+
if (refs.some((ref) => sameHarnessModelRef(ref, model2.fastModel))) {
|
|
15710
15316
|
context.addIssue({
|
|
15711
15317
|
code: "custom",
|
|
15712
15318
|
message: "Fast Model refs must be distinct and unique",
|
|
15713
15319
|
path: ["models", index, "fastModel"]
|
|
15714
15320
|
});
|
|
15715
15321
|
}
|
|
15716
|
-
refs.
|
|
15322
|
+
refs.push(model2.fastModel);
|
|
15717
15323
|
}
|
|
15718
15324
|
const supportedThinkingIds = /* @__PURE__ */ new Set();
|
|
15719
15325
|
for (const [optionIndex, optionId] of (model2.supportedThinkingOptionIds ?? []).entries()) {
|
|
@@ -15734,7 +15340,7 @@ var harnessModelCatalogSchema = external_exports.object({
|
|
|
15734
15340
|
}
|
|
15735
15341
|
}
|
|
15736
15342
|
}
|
|
15737
|
-
if (catalog.defaultModel && !
|
|
15343
|
+
if (catalog.defaultModel && !catalogModelForRef(catalog, catalog.defaultModel)) {
|
|
15738
15344
|
context.addIssue({
|
|
15739
15345
|
code: "custom",
|
|
15740
15346
|
message: "Default Model must exist in the Model Catalog",
|
|
@@ -15774,7 +15380,12 @@ var harnessSessionCapabilitiesSchema = external_exports.object({
|
|
|
15774
15380
|
observe: external_exports.boolean()
|
|
15775
15381
|
}).strict().optional(),
|
|
15776
15382
|
/** True only when `turn.steer` delivers input into the active Turn through a native primitive. */
|
|
15777
|
-
steer: external_exports.boolean().optional()
|
|
15383
|
+
steer: external_exports.boolean().optional(),
|
|
15384
|
+
/**
|
|
15385
|
+
* True when the native plan (task list) outlives the Turn that changed it, so a reopened
|
|
15386
|
+
* Thread gets its latest plan again. Otherwise a plan stays with the Turn that made it.
|
|
15387
|
+
*/
|
|
15388
|
+
persistentPlan: external_exports.boolean().optional()
|
|
15778
15389
|
}).strict();
|
|
15779
15390
|
var harnessConfigurationStateSchema = external_exports.object({
|
|
15780
15391
|
effectiveModel: harnessModelRefSchema.optional(),
|
|
@@ -15783,7 +15394,7 @@ var harnessConfigurationStateSchema = external_exports.object({
|
|
|
15783
15394
|
availableThinkingOptions: harnessThinkingOptionsSchema.optional(),
|
|
15784
15395
|
effectivePermissionModeId: harnessPermissionModeIdSchema.optional()
|
|
15785
15396
|
}).strict().superRefine((state, context) => {
|
|
15786
|
-
if (state.effectiveThinkingOptionId && state.availableThinkingOptions && !state.availableThinkingOptions.some(({ id }) =>
|
|
15397
|
+
if (state.effectiveThinkingOptionId && state.availableThinkingOptions && !state.availableThinkingOptions.some(({ id: id2 }) => id2 === state.effectiveThinkingOptionId)) {
|
|
15787
15398
|
context.addIssue({
|
|
15788
15399
|
code: "custom",
|
|
15789
15400
|
message: "Effective Thinking option must be currently available",
|
|
@@ -15823,7 +15434,8 @@ var harnessInspectParamsSchema = external_exports.object({
|
|
|
15823
15434
|
cwd: nonBlankTextSchema2.max(16384).optional(),
|
|
15824
15435
|
refresh: external_exports.boolean().optional(),
|
|
15825
15436
|
/** `availability` asks only whether the Harness can run; see `InspectHarnessInput.purpose`. */
|
|
15826
|
-
purpose: external_exports.literal("availability").optional()
|
|
15437
|
+
purpose: external_exports.literal("availability").optional(),
|
|
15438
|
+
credentialAccess: external_exports.enum(["allow", "retry"]).optional()
|
|
15827
15439
|
}).strict();
|
|
15828
15440
|
var harnessWebUiOpenParamsSchema = external_exports.object({
|
|
15829
15441
|
harnessId: harnessIdSchema
|
|
@@ -15854,7 +15466,7 @@ var codexThreadInspectionSchema = external_exports.object({
|
|
|
15854
15466
|
var externalThreadInspectionSchema = external_exports.object({
|
|
15855
15467
|
owner: external_exports.literal("external"),
|
|
15856
15468
|
harnessId: nonBlankTextSchema2.max(256),
|
|
15857
|
-
transportModelId: nonBlankTextSchema2.max(
|
|
15469
|
+
transportModelId: nonBlankTextSchema2.max(HARNESS_TRANSPORT_MODEL_ID_MAX_LENGTH),
|
|
15858
15470
|
effectiveModel: harnessModelRefSchema.optional(),
|
|
15859
15471
|
resolvedModelLabel: harnessResolvedModelLabelSchema.optional(),
|
|
15860
15472
|
effectiveThinkingOptionId: harnessThinkingOptionIdSchema.optional(),
|
|
@@ -15910,31 +15522,576 @@ var threadOwnershipListResultSchema = external_exports.object({
|
|
|
15910
15522
|
}
|
|
15911
15523
|
seen.add(thread2.threadId);
|
|
15912
15524
|
}
|
|
15913
|
-
});
|
|
15914
|
-
var threadSteeringInspectParamsSchema = external_exports.object({
|
|
15915
|
-
threadId: hostThreadIdSchema,
|
|
15916
|
-
/** The text about to be steered; a Harness command always stops and restarts. */
|
|
15917
|
-
text: external_exports.string().optional()
|
|
15918
|
-
}).strict();
|
|
15919
|
-
var threadSteeringContextSchema = external_exports.object({
|
|
15920
|
-
kind: external_exports.literal("application"),
|
|
15921
|
-
value: external_exports.string().transform((text2, context) => {
|
|
15922
|
-
try {
|
|
15923
|
-
return JSON.parse(text2);
|
|
15924
|
-
} catch {
|
|
15925
|
-
context.addIssue({ code: "custom", message: "Invalid steering context JSON" });
|
|
15926
|
-
return external_exports.NEVER;
|
|
15927
|
-
}
|
|
15928
|
-
}).pipe(external_exports.object({
|
|
15929
|
-
expectedTurnId: hostTurnIdSchema,
|
|
15930
|
-
clientUserMessageId: external_exports.string().min(1),
|
|
15931
|
-
delivery: external_exports.enum(["newTurn", "activeTurn"])
|
|
15932
|
-
}).strict())
|
|
15933
|
-
}).strict().transform((context) => context.value);
|
|
15934
|
-
var threadSteerDeliverySchema = external_exports.enum(["activeTurn", "newTurn"]);
|
|
15935
|
-
var threadSteeringInspectResultSchema = external_exports.object({
|
|
15936
|
-
delivery: external_exports.enum(["official", "activeTurn", "newTurn"])
|
|
15937
|
-
}).strict();
|
|
15525
|
+
});
|
|
15526
|
+
var threadSteeringInspectParamsSchema = external_exports.object({
|
|
15527
|
+
threadId: hostThreadIdSchema,
|
|
15528
|
+
/** The text about to be steered; a Harness command always stops and restarts. */
|
|
15529
|
+
text: external_exports.string().optional()
|
|
15530
|
+
}).strict();
|
|
15531
|
+
var threadSteeringContextSchema = external_exports.object({
|
|
15532
|
+
kind: external_exports.literal("application"),
|
|
15533
|
+
value: external_exports.string().transform((text2, context) => {
|
|
15534
|
+
try {
|
|
15535
|
+
return JSON.parse(text2);
|
|
15536
|
+
} catch {
|
|
15537
|
+
context.addIssue({ code: "custom", message: "Invalid steering context JSON" });
|
|
15538
|
+
return external_exports.NEVER;
|
|
15539
|
+
}
|
|
15540
|
+
}).pipe(external_exports.object({
|
|
15541
|
+
expectedTurnId: hostTurnIdSchema,
|
|
15542
|
+
clientUserMessageId: external_exports.string().min(1),
|
|
15543
|
+
delivery: external_exports.enum(["newTurn", "activeTurn"])
|
|
15544
|
+
}).strict())
|
|
15545
|
+
}).strict().transform((context) => context.value);
|
|
15546
|
+
var threadSteerDeliverySchema = external_exports.enum(["activeTurn", "newTurn"]);
|
|
15547
|
+
var threadSteeringInspectResultSchema = external_exports.object({
|
|
15548
|
+
delivery: external_exports.enum(["official", "activeTurn", "newTurn"])
|
|
15549
|
+
}).strict();
|
|
15550
|
+
|
|
15551
|
+
// ../../shared-contracts/dist/harness-plugins.js
|
|
15552
|
+
var HARNESS_PLUGIN_MANIFEST_MAX_BYTES = 32 * 1024;
|
|
15553
|
+
var HARNESS_PLUGIN_ICON_MAX_BYTES = 128 * 1024;
|
|
15554
|
+
var HARNESS_PLUGIN_LIMIT = 128;
|
|
15555
|
+
var installedPluginIdSchema = external_exports.string().min(1).max(128).regex(/^[a-z][a-z0-9]*(?:[._-][a-z0-9]+)*$/u);
|
|
15556
|
+
var installedHarnessPluginIdSchema = installedPluginIdSchema.pipe(harnessIdSchema);
|
|
15557
|
+
var harnessPluginIdSchema = installedHarnessPluginIdSchema.refine((id2) => id2 !== "codex", "The official Codex identity is reserved");
|
|
15558
|
+
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");
|
|
15559
|
+
var documentationUrlSchema = external_exports.url().refine((value) => /^https:\/\/[^/?#@]+(?:[/?#]|$)/iu.test(value), "Plugin documentation links must be credential-free HTTPS URLs");
|
|
15560
|
+
var localizedTextSchema = external_exports.object({ en: external_exports.string().max(4096), "zh-CN": external_exports.string().max(4096).optional() }).strict();
|
|
15561
|
+
var harnessInstallationGuideSchema = external_exports.object({
|
|
15562
|
+
commands: external_exports.array(external_exports.object({ terminal: external_exports.string().max(256), command: external_exports.string().max(4096) }).strict()).max(8),
|
|
15563
|
+
before: localizedTextSchema.optional(),
|
|
15564
|
+
after: localizedTextSchema.optional(),
|
|
15565
|
+
downloads: external_exports.array(external_exports.object({ label: external_exports.string().max(128), url: documentationUrlSchema }).strict()).max(8).optional()
|
|
15566
|
+
}).strict();
|
|
15567
|
+
var pluginPresentationShape = {
|
|
15568
|
+
id: installedHarnessPluginIdSchema,
|
|
15569
|
+
name: external_exports.string().trim().min(1).max(128),
|
|
15570
|
+
version: external_exports.string().min(1).max(128),
|
|
15571
|
+
/** Capability-only plugin; omitted for existing session-capable plugins. */
|
|
15572
|
+
kind: external_exports.literal("usage").optional(),
|
|
15573
|
+
/** Original image styling or bounded vector paths; never arbitrary CSS/SVG markup. */
|
|
15574
|
+
iconStyle: external_exports.object({
|
|
15575
|
+
vector: external_exports.object({
|
|
15576
|
+
viewBox: external_exports.string().max(128).regex(/^-?\d+(?:\.\d+)?(?: +-?\d+(?:\.\d+)?){3}$/u),
|
|
15577
|
+
color: external_exports.string().regex(/^(?:currentColor|#[a-f0-9]{6})$/iu),
|
|
15578
|
+
paths: external_exports.array(external_exports.object({
|
|
15579
|
+
d: external_exports.string().min(1).max(32768).regex(/^[MmLlHhVvCcSsQqTtAaZz\d.,+eE\s-]+$/u),
|
|
15580
|
+
fillRule: external_exports.enum(["evenodd", "nonzero"]).optional(),
|
|
15581
|
+
fill: external_exports.string().regex(/^(?:currentColor|#[a-f0-9]{6})$/iu).optional()
|
|
15582
|
+
}).strict()).min(1).max(32)
|
|
15583
|
+
}).strict().optional(),
|
|
15584
|
+
background: external_exports.string().regex(/^#[a-f0-9]{6}$/iu).optional(),
|
|
15585
|
+
borderRadius: external_exports.number().min(0).max(50).optional(),
|
|
15586
|
+
paddingRatio: external_exports.number().min(0).max(0.25).optional()
|
|
15587
|
+
}).strict().optional(),
|
|
15588
|
+
installation: harnessInstallationGuideSchema.optional(),
|
|
15589
|
+
notice: localizedTextSchema.optional(),
|
|
15590
|
+
/** The factory accepts a persisted local entrypoint through its construction context. */
|
|
15591
|
+
launchCommand: external_exports.literal(true).optional(),
|
|
15592
|
+
links: external_exports.object({
|
|
15593
|
+
website: documentationUrlSchema.optional(),
|
|
15594
|
+
documentation: documentationUrlSchema.optional(),
|
|
15595
|
+
installation: documentationUrlSchema.optional()
|
|
15596
|
+
}).strict().optional()
|
|
15597
|
+
};
|
|
15598
|
+
var harnessPluginManifestSchema = external_exports.object({
|
|
15599
|
+
manifestVersion: external_exports.literal(1),
|
|
15600
|
+
...pluginPresentationShape,
|
|
15601
|
+
adapterApiVersion: external_exports.number().int().positive(),
|
|
15602
|
+
entry: pluginRelativeResourceSchema,
|
|
15603
|
+
icon: pluginRelativeResourceSchema.optional()
|
|
15604
|
+
}).strict();
|
|
15605
|
+
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);
|
|
15606
|
+
var harnessPluginDescriptorSchema = external_exports.object({
|
|
15607
|
+
...pluginPresentationShape,
|
|
15608
|
+
icon: harnessPluginIconSchema.optional()
|
|
15609
|
+
}).strict();
|
|
15610
|
+
var harnessPluginListParamsSchema = external_exports.object({}).strict();
|
|
15611
|
+
var harnessPluginListResultSchema = external_exports.object({
|
|
15612
|
+
plugins: external_exports.array(harnessPluginDescriptorSchema.extend({ id: harnessPluginIdSchema })).max(HARNESS_PLUGIN_LIMIT)
|
|
15613
|
+
}).strict();
|
|
15614
|
+
var harnessPluginConfigurationSchema = external_exports.object({
|
|
15615
|
+
version: external_exports.literal(1),
|
|
15616
|
+
enabled: external_exports.array(installedHarnessPluginIdSchema).max(HARNESS_PLUGIN_LIMIT)
|
|
15617
|
+
}).strict().refine((value) => new Set(value.enabled).size === value.enabled.length, {
|
|
15618
|
+
message: "Enabled plugin IDs must be unique",
|
|
15619
|
+
path: ["enabled"]
|
|
15620
|
+
});
|
|
15621
|
+
|
|
15622
|
+
// ../../shared-contracts/dist/desktop-extensions.js
|
|
15623
|
+
var DESKTOP_EXTENSION_API_VERSION = 1;
|
|
15624
|
+
var DESKTOP_EXTENSION_LIMIT = 64;
|
|
15625
|
+
var DESKTOP_EXTENSION_ZIP_MAX_BYTES = 64 * 1024 * 1024;
|
|
15626
|
+
var DESKTOP_EXTENSION_MANIFEST_MAX_BYTES = 128 * 1024;
|
|
15627
|
+
var DESKTOP_EXTENSION_SCRIPT_MAX_BYTES = 2 * 1024 * 1024;
|
|
15628
|
+
var DESKTOP_EXTENSION_STYLE_MAX_BYTES = 256 * 1024;
|
|
15629
|
+
var DESKTOP_EXTENSION_ICON_MAX_BYTES = 128 * 1024;
|
|
15630
|
+
var DESKTOP_EXTENSION_SCREENSHOT_LIMIT = 4;
|
|
15631
|
+
var DESKTOP_EXTENSION_SCREENSHOT_MAX_BYTES = 512 * 1024;
|
|
15632
|
+
var DESKTOP_EXTENSION_LIST_SCREENSHOTS_MAX_BYTES = 8 * 1024 * 1024;
|
|
15633
|
+
var DESKTOP_EXTENSION_SNAPSHOT_MAX_BYTES = 8 * 1024 * 1024;
|
|
15634
|
+
var DESKTOP_EXTENSION_ASSET_MAX_BYTES = 16 * 1024 * 1024;
|
|
15635
|
+
var DESKTOP_EXTENSION_SETTINGS_MAX_BYTES = 1024 * 1024;
|
|
15636
|
+
var desktopExtensionIdSchema = installedPluginIdSchema;
|
|
15637
|
+
var desktopExtensionSlotSchema = external_exports.enum([
|
|
15638
|
+
"sidebar.thread-layout",
|
|
15639
|
+
"sidebar.thread-badge",
|
|
15640
|
+
"appearance.theme"
|
|
15641
|
+
]);
|
|
15642
|
+
var desktopExtensionCategorySchema = external_exports.enum([
|
|
15643
|
+
"appearance",
|
|
15644
|
+
"interface",
|
|
15645
|
+
"workflow",
|
|
15646
|
+
"analytics",
|
|
15647
|
+
"integrations",
|
|
15648
|
+
"tools"
|
|
15649
|
+
]);
|
|
15650
|
+
var extensionName = external_exports.string().trim().min(1).max(128);
|
|
15651
|
+
function desktopExtensionScreenshotMimeType(resource) {
|
|
15652
|
+
switch (resource.match(/\.([^./]+)$/u)?.[1]?.toLowerCase()) {
|
|
15653
|
+
case "png":
|
|
15654
|
+
return "image/png";
|
|
15655
|
+
case "jpg":
|
|
15656
|
+
case "jpeg":
|
|
15657
|
+
return "image/jpeg";
|
|
15658
|
+
case "webp":
|
|
15659
|
+
return "image/webp";
|
|
15660
|
+
default:
|
|
15661
|
+
return void 0;
|
|
15662
|
+
}
|
|
15663
|
+
}
|
|
15664
|
+
var hasPortableSegments = (resource) => resource.split("/").every((segment) => !/[. ]$/u.test(segment));
|
|
15665
|
+
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");
|
|
15666
|
+
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) => {
|
|
15667
|
+
const { username, password } = new URL(value);
|
|
15668
|
+
return !username && !password && !/[\\\s]/u.test(value);
|
|
15669
|
+
}, "URL must not contain credentials, backslashes, or whitespace");
|
|
15670
|
+
function localizedText(text2) {
|
|
15671
|
+
return external_exports.strictObject({ en: text2, "zh-CN": text2 });
|
|
15672
|
+
}
|
|
15673
|
+
var desktopExtensionLocalizedTextSchema = localizedText(external_exports.string().trim().min(1));
|
|
15674
|
+
var categoriesSchema = external_exports.array(desktopExtensionCategorySchema).max(desktopExtensionCategorySchema.options.length).refine((categories) => new Set(categories).size === categories.length, "Duplicate categories");
|
|
15675
|
+
var slotsSchema = external_exports.array(desktopExtensionSlotSchema).max(desktopExtensionSlotSchema.options.length).refine((slots) => new Set(slots).size === slots.length, "Duplicate slots");
|
|
15676
|
+
var settingField = {
|
|
15677
|
+
key: external_exports.string().regex(/^[A-Za-z_][A-Za-z0-9_]*$/u),
|
|
15678
|
+
label: desktopExtensionLocalizedTextSchema,
|
|
15679
|
+
description: desktopExtensionLocalizedTextSchema.optional()
|
|
15680
|
+
};
|
|
15681
|
+
var numericSetting = {
|
|
15682
|
+
...settingField,
|
|
15683
|
+
step: external_exports.number().positive().optional(),
|
|
15684
|
+
default: external_exports.number().optional()
|
|
15685
|
+
};
|
|
15686
|
+
var settingOption = external_exports.strictObject({
|
|
15687
|
+
value: external_exports.string(),
|
|
15688
|
+
label: desktopExtensionLocalizedTextSchema
|
|
15689
|
+
});
|
|
15690
|
+
var desktopExtensionSettingFieldSchema = external_exports.discriminatedUnion("type", [
|
|
15691
|
+
external_exports.strictObject({
|
|
15692
|
+
...settingField,
|
|
15693
|
+
type: external_exports.literal("boolean"),
|
|
15694
|
+
default: external_exports.boolean().optional()
|
|
15695
|
+
}),
|
|
15696
|
+
external_exports.strictObject({
|
|
15697
|
+
...settingField,
|
|
15698
|
+
type: external_exports.literal("string"),
|
|
15699
|
+
placeholder: desktopExtensionLocalizedTextSchema.optional(),
|
|
15700
|
+
default: external_exports.string().optional()
|
|
15701
|
+
}),
|
|
15702
|
+
external_exports.strictObject({
|
|
15703
|
+
...numericSetting,
|
|
15704
|
+
type: external_exports.literal("number"),
|
|
15705
|
+
min: external_exports.number().optional(),
|
|
15706
|
+
max: external_exports.number().optional()
|
|
15707
|
+
}),
|
|
15708
|
+
external_exports.strictObject({
|
|
15709
|
+
...numericSetting,
|
|
15710
|
+
type: external_exports.literal("range"),
|
|
15711
|
+
min: external_exports.number(),
|
|
15712
|
+
max: external_exports.number()
|
|
15713
|
+
}),
|
|
15714
|
+
external_exports.strictObject({
|
|
15715
|
+
...settingField,
|
|
15716
|
+
type: external_exports.literal("select"),
|
|
15717
|
+
options: external_exports.array(settingOption).min(1),
|
|
15718
|
+
default: external_exports.string().optional()
|
|
15719
|
+
})
|
|
15720
|
+
]).superRefine((field3, ctx) => {
|
|
15721
|
+
const issue2 = (path14, message3) => ctx.addIssue({ code: "custom", path: [path14], message: message3 });
|
|
15722
|
+
if (field3.type === "number" || field3.type === "range") {
|
|
15723
|
+
const { min = -Infinity, max = Infinity, default: value } = field3;
|
|
15724
|
+
if (min > max)
|
|
15725
|
+
issue2("max", "Must be at least min");
|
|
15726
|
+
if (value !== void 0 && (value < min || value > max))
|
|
15727
|
+
issue2("default", "Must be within min and max");
|
|
15728
|
+
} else if (field3.type === "select") {
|
|
15729
|
+
const values = new Set(field3.options.map(({ value }) => value));
|
|
15730
|
+
if (values.size !== field3.options.length)
|
|
15731
|
+
issue2("options", "Duplicate option values");
|
|
15732
|
+
if (field3.default !== void 0 && !values.has(field3.default))
|
|
15733
|
+
issue2("default", "Must match an option value");
|
|
15734
|
+
}
|
|
15735
|
+
});
|
|
15736
|
+
var manifestHeader = external_exports.object({
|
|
15737
|
+
manifestVersion: external_exports.int().positive(),
|
|
15738
|
+
id: desktopExtensionIdSchema,
|
|
15739
|
+
name: external_exports.union([extensionName, localizedText(extensionName)]),
|
|
15740
|
+
version: external_exports.string().min(1).max(128),
|
|
15741
|
+
desktopApi: external_exports.int().positive()
|
|
15742
|
+
}).passthrough();
|
|
15743
|
+
var desktopExtensionManifestSchema = manifestHeader.extend({
|
|
15744
|
+
manifestVersion: external_exports.literal(1),
|
|
15745
|
+
desktopApi: external_exports.literal(DESKTOP_EXTENSION_API_VERSION),
|
|
15746
|
+
description: external_exports.strictObject({ en: external_exports.string().max(4096), "zh-CN": external_exports.string().max(4096).optional() }).optional(),
|
|
15747
|
+
author: external_exports.string().trim().min(1).max(128).optional(),
|
|
15748
|
+
repository: desktopExtensionHttpUrlSchema.optional(),
|
|
15749
|
+
details: external_exports.strictObject({ en: external_exports.string().max(16384), "zh-CN": external_exports.string().max(16384).optional() }).optional(),
|
|
15750
|
+
icon: imagePathSchema.optional(),
|
|
15751
|
+
screenshots: external_exports.array(imagePathSchema).max(DESKTOP_EXTENSION_SCREENSHOT_LIMIT).refine((screenshots) => new Set(screenshots).size === screenshots.length, "Duplicate screenshots").optional(),
|
|
15752
|
+
desktop: external_exports.strictObject({
|
|
15753
|
+
script: pluginRelativeResourceSchema,
|
|
15754
|
+
style: pluginRelativeResourceSchema.optional()
|
|
15755
|
+
}).optional(),
|
|
15756
|
+
backend: external_exports.strictObject({ script: pluginRelativeResourceSchema.refine(hasPortableSegments) }).optional(),
|
|
15757
|
+
slots: slotsSchema.default(() => []),
|
|
15758
|
+
settingsSchema: external_exports.array(desktopExtensionSettingFieldSchema).max(32).refine((fields) => new Set(fields.map(({ key }) => key)).size === fields.length, "Duplicate setting keys").optional(),
|
|
15759
|
+
categories: categoriesSchema.optional()
|
|
15760
|
+
}).strict().refine((manifest) => manifest.desktop !== void 0 || manifest.backend !== void 0, "Expected at least one desktop or backend entry");
|
|
15761
|
+
var desktopExtensionHashSchema = external_exports.string().regex(/^[a-f0-9]{64}$/u);
|
|
15762
|
+
var desktopExtensionStatusSchema = external_exports.strictObject({
|
|
15763
|
+
state: external_exports.enum([
|
|
15764
|
+
"running",
|
|
15765
|
+
"disabled",
|
|
15766
|
+
"invalid",
|
|
15767
|
+
"incompatible",
|
|
15768
|
+
"conflict",
|
|
15769
|
+
"failed",
|
|
15770
|
+
"waiting"
|
|
15771
|
+
]),
|
|
15772
|
+
hash: desktopExtensionHashSchema.optional(),
|
|
15773
|
+
error: external_exports.string().optional(),
|
|
15774
|
+
conflictWith: desktopExtensionIdSchema.optional()
|
|
15775
|
+
});
|
|
15776
|
+
var desktopExtensionsDiagnosticSchema = external_exports.strictObject({
|
|
15777
|
+
controllerPid: external_exports.int().positive(),
|
|
15778
|
+
targetId: external_exports.string().nullable(),
|
|
15779
|
+
updatedAt: external_exports.iso.datetime(),
|
|
15780
|
+
handledReloadToken: external_exports.uuid().optional(),
|
|
15781
|
+
extensions: external_exports.record(external_exports.string(), desktopExtensionStatusSchema),
|
|
15782
|
+
surfaces: external_exports.record(external_exports.string(), desktopExtensionStatusSchema).optional()
|
|
15783
|
+
});
|
|
15784
|
+
var desktopExtensionTrustTierSchema = external_exports.enum(["official", "community"]);
|
|
15785
|
+
function isGitHubDesktopExtensionZipballUrl(url2) {
|
|
15786
|
+
return url2.origin === "https://api.github.com" && /^\/repos\/[\w-]+\/[\w.-]+\/zipball(?:\/[^/]+)?\/?$/u.test(url2.pathname);
|
|
15787
|
+
}
|
|
15788
|
+
var desktopExtensionZipUrlSchema = desktopExtensionHttpUrlSchema.refine((input) => {
|
|
15789
|
+
const url2 = new URL(input);
|
|
15790
|
+
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);
|
|
15791
|
+
}, "Expected a .zip download URL or a GitHub zipball URL");
|
|
15792
|
+
var desktopExtensionCatalogEntrySchema = external_exports.strictObject({
|
|
15793
|
+
id: desktopExtensionIdSchema,
|
|
15794
|
+
version: external_exports.string().trim().min(1).max(128),
|
|
15795
|
+
name: desktopExtensionLocalizedTextSchema.extend({ en: extensionName, "zh-CN": extensionName }),
|
|
15796
|
+
description: localizedText(external_exports.string().trim().min(1).max(4096)),
|
|
15797
|
+
details: localizedText(external_exports.string().trim().min(1).max(16384)).optional(),
|
|
15798
|
+
author: external_exports.string().trim().min(1).max(128),
|
|
15799
|
+
repository: desktopExtensionHttpUrlSchema,
|
|
15800
|
+
stars: external_exports.number().int().min(0).optional(),
|
|
15801
|
+
downloads: external_exports.number().int().min(0).optional(),
|
|
15802
|
+
categories: categoriesSchema.optional(),
|
|
15803
|
+
trustTier: desktopExtensionTrustTierSchema.default("community"),
|
|
15804
|
+
icon: desktopExtensionHttpUrlSchema.optional(),
|
|
15805
|
+
screenshots: external_exports.array(desktopExtensionHttpUrlSchema).max(DESKTOP_EXTENSION_SCREENSHOT_LIMIT).optional(),
|
|
15806
|
+
downloadUrl: desktopExtensionZipUrlSchema,
|
|
15807
|
+
sha256: desktopExtensionHashSchema,
|
|
15808
|
+
slots: slotsSchema.optional(),
|
|
15809
|
+
publishedAt: external_exports.string().optional(),
|
|
15810
|
+
updatedAt: external_exports.string().optional(),
|
|
15811
|
+
minCodexHostVersion: external_exports.string().optional()
|
|
15812
|
+
});
|
|
15813
|
+
var desktopExtensionCatalogSchema = external_exports.strictObject({
|
|
15814
|
+
schemaVersion: external_exports.literal(1),
|
|
15815
|
+
generatedAt: external_exports.string(),
|
|
15816
|
+
extensions: external_exports.array(desktopExtensionCatalogEntrySchema).refine((entries) => new Set(entries.map(({ id: id2 }) => id2)).size === entries.length, "Duplicate extension IDs")
|
|
15817
|
+
});
|
|
15818
|
+
var desktopExtensionBackendMethodSchema = external_exports.string().trim().min(1).max(128);
|
|
15819
|
+
|
|
15820
|
+
// ../../shared-contracts/dist/host-extensions.js
|
|
15821
|
+
var reservedName = /^(?:con|prn|aux|nul|com[1-9¹²³]|lpt[1-9¹²³]) *(?:\.|$)/iu;
|
|
15822
|
+
var HOST_EXTENSION_PAGE_API_VERSION = 1;
|
|
15823
|
+
var hostExtensionIdSchema = desktopExtensionIdSchema.refine((id2) => !reservedName.test(id2), "Reserved extension ID");
|
|
15824
|
+
var hostExtensionTargetSchema = external_exports.enum(["desktop", "web"]);
|
|
15825
|
+
var hostExtensionDigestSchema = desktopExtensionHashSchema;
|
|
15826
|
+
var hostExtensionActivationIdSchema = external_exports.uuid();
|
|
15827
|
+
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((path14) => path14.split("/").length <= 32, "Extension resources may be at most 32 segments deep");
|
|
15828
|
+
var legacy = desktopExtensionManifestSchema.shape;
|
|
15829
|
+
var localized = (max, min = 0) => external_exports.strictObject({
|
|
15830
|
+
en: external_exports.string().trim().min(min).max(max),
|
|
15831
|
+
"zh-CN": external_exports.string().trim().min(min).max(max)
|
|
15832
|
+
});
|
|
15833
|
+
var resourceWithSuffix = (suffix) => hostExtensionResourcePathSchema.refine((path14) => path14.endsWith(suffix), `Expected a ${suffix} file`);
|
|
15834
|
+
var moduleEntry = resourceWithSuffix(".mjs");
|
|
15835
|
+
var style = resourceWithSuffix(".css").optional();
|
|
15836
|
+
var hostExtensionCanonicalPath = (path14) => path14.normalize("NFC").toLowerCase();
|
|
15837
|
+
var hostExtensionManifestV2Schema = external_exports.strictObject({
|
|
15838
|
+
manifestVersion: external_exports.literal(2),
|
|
15839
|
+
id: hostExtensionIdSchema,
|
|
15840
|
+
name: localized(128, 1),
|
|
15841
|
+
version: external_exports.string().trim().min(1).max(128),
|
|
15842
|
+
description: localized(4096),
|
|
15843
|
+
details: localized(16384).optional(),
|
|
15844
|
+
author: legacy.author,
|
|
15845
|
+
repository: legacy.repository,
|
|
15846
|
+
icon: legacy.icon.refine((path14) => path14 === void 0 || hostExtensionResourcePathSchema.safeParse(path14).success),
|
|
15847
|
+
screenshots: legacy.screenshots.refine((paths) => paths === void 0 || paths.every((path14) => hostExtensionResourcePathSchema.safeParse(path14).success)),
|
|
15848
|
+
categories: legacy.categories,
|
|
15849
|
+
settingsSchema: legacy.settingsSchema,
|
|
15850
|
+
slots: legacy.slots.removeDefault().optional(),
|
|
15851
|
+
page: external_exports.strictObject({
|
|
15852
|
+
apiVersion: external_exports.literal(HOST_EXTENSION_PAGE_API_VERSION),
|
|
15853
|
+
entry: moduleEntry,
|
|
15854
|
+
style,
|
|
15855
|
+
title: localized(128, 1).optional()
|
|
15856
|
+
}).optional(),
|
|
15857
|
+
widget: external_exports.strictObject({
|
|
15858
|
+
apiVersion: external_exports.literal(HOST_EXTENSION_PAGE_API_VERSION),
|
|
15859
|
+
entry: moduleEntry,
|
|
15860
|
+
style
|
|
15861
|
+
}).optional(),
|
|
15862
|
+
desktop: external_exports.strictObject({ apiVersion: external_exports.literal(1), script: resourceWithSuffix(".js"), style }).optional(),
|
|
15863
|
+
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(),
|
|
15864
|
+
backend: external_exports.strictObject({ apiVersion: external_exports.literal(1), entry: moduleEntry }).optional()
|
|
15865
|
+
}).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" });
|
|
15866
|
+
function targetsForCapabilities({ hasPage, hasWidget, hasDesktop, hasWeb, hasBackend }) {
|
|
15867
|
+
if (hasPage || hasWidget || hasBackend && !hasDesktop && !hasWeb)
|
|
15868
|
+
return ["desktop", "web"];
|
|
15869
|
+
const targets = [];
|
|
15870
|
+
if (hasDesktop)
|
|
15871
|
+
targets.push("desktop");
|
|
15872
|
+
if (hasWeb)
|
|
15873
|
+
targets.push("web");
|
|
15874
|
+
return targets;
|
|
15875
|
+
}
|
|
15876
|
+
var hostExtensionBackendMethodSchema = desktopExtensionBackendMethodSchema;
|
|
15877
|
+
|
|
15878
|
+
// ../../shared-contracts/dist/host-extension-management.js
|
|
15879
|
+
var HOST_EXTENSION_ZIP_MAX_BYTES = DESKTOP_EXTENSION_ZIP_MAX_BYTES;
|
|
15880
|
+
var hostExtensionRevisionSchema = external_exports.int().nonnegative();
|
|
15881
|
+
var hostExtensionConfigurationSchema = external_exports.strictObject({
|
|
15882
|
+
revision: hostExtensionRevisionSchema,
|
|
15883
|
+
enabled: external_exports.array(hostExtensionIdSchema).max(DESKTOP_EXTENSION_LIMIT).refine((ids) => new Set(ids).size === ids.length, "Duplicate extension IDs")
|
|
15884
|
+
});
|
|
15885
|
+
var { downloadUrl, ...catalogMetadata } = desktopExtensionCatalogEntrySchema.shape;
|
|
15886
|
+
var hostExtensionCatalogEntrySchema = external_exports.object({
|
|
15887
|
+
...catalogMetadata,
|
|
15888
|
+
id: hostExtensionIdSchema,
|
|
15889
|
+
format: external_exports.literal("codexhost"),
|
|
15890
|
+
targets: external_exports.array(hostExtensionTargetSchema).min(1).max(2).refine((targets) => new Set(targets).size === targets.length, "Duplicate targets"),
|
|
15891
|
+
apis: external_exports.strictObject({
|
|
15892
|
+
page: external_exports.int().positive().optional(),
|
|
15893
|
+
widget: external_exports.int().positive().optional(),
|
|
15894
|
+
desktop: external_exports.int().positive().optional(),
|
|
15895
|
+
web: external_exports.int().positive().optional(),
|
|
15896
|
+
backend: external_exports.int().positive().optional()
|
|
15897
|
+
}),
|
|
15898
|
+
downloadUrl: downloadUrl.refine((url2) => url2.startsWith("https://"), "Expected HTTPS")
|
|
15899
|
+
}).refine(({ targets, apis }) => {
|
|
15900
|
+
const derived = targetsForCapabilities({
|
|
15901
|
+
hasPage: Boolean(apis.page),
|
|
15902
|
+
hasWidget: Boolean(apis.widget),
|
|
15903
|
+
hasDesktop: Boolean(apis.desktop),
|
|
15904
|
+
hasWeb: Boolean(apis.web),
|
|
15905
|
+
hasBackend: Boolean(apis.backend)
|
|
15906
|
+
});
|
|
15907
|
+
return targets.length === derived.length && derived.every((target2) => targets.includes(target2));
|
|
15908
|
+
}, "Catalog targets must match the declared APIs");
|
|
15909
|
+
var hostExtensionCatalogSchema = external_exports.object({
|
|
15910
|
+
schemaVersion: external_exports.literal(2),
|
|
15911
|
+
generatedAt: external_exports.string().min(1),
|
|
15912
|
+
extensions: external_exports.array(hostExtensionCatalogEntrySchema).max(1e4).refine((entries) => new Set(entries.map(({ id: id2 }) => id2)).size === entries.length, "Duplicate extension IDs")
|
|
15913
|
+
});
|
|
15914
|
+
var hostExtensionsCatalogResultSchema = hostExtensionCatalogSchema.extend({
|
|
15915
|
+
catalogUrl: desktopExtensionHttpUrlSchema,
|
|
15916
|
+
fetchedAt: external_exports.iso.datetime(),
|
|
15917
|
+
cached: external_exports.boolean()
|
|
15918
|
+
});
|
|
15919
|
+
var id = { id: hostExtensionIdSchema };
|
|
15920
|
+
var active = {
|
|
15921
|
+
...id,
|
|
15922
|
+
activationId: hostExtensionActivationIdSchema,
|
|
15923
|
+
digest: hostExtensionDigestSchema
|
|
15924
|
+
};
|
|
15925
|
+
var optionalActivation = { ...id, activationId: active.activationId.optional() };
|
|
15926
|
+
var filePath = external_exports.string().min(1).max(4096).refine((path14) => /^(?:\/|[a-z]:[/\\])/iu.test(path14) && !path14.includes("\0") && !path14.split(/[/\\]/u).some((part) => part === "." || part === ".."), "Expected an absolute local path without dot segments");
|
|
15927
|
+
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");
|
|
15928
|
+
function base643(maxBytes) {
|
|
15929
|
+
return external_exports.string().max(4 * Math.ceil(maxBytes / 3)).refine((value) => {
|
|
15930
|
+
const padding = value.endsWith("==") ? 2 : value.endsWith("=") ? 1 : 0;
|
|
15931
|
+
return value.length % 4 === 0 && value.length * 3 / 4 - padding <= maxBytes && /^[A-Za-z0-9+/]*={0,2}$/u.test(value);
|
|
15932
|
+
}, "Expected bounded standard padded base64");
|
|
15933
|
+
}
|
|
15934
|
+
var hostExtensionGitHubSourceSchema = external_exports.strictObject({
|
|
15935
|
+
type: external_exports.literal("github"),
|
|
15936
|
+
repository: external_exports.string().max(150).regex(/^[a-z0-9-]+\/[a-z0-9_-][a-z0-9_.-]*$/iu),
|
|
15937
|
+
ref: gitRef.optional(),
|
|
15938
|
+
tag: gitRef.optional(),
|
|
15939
|
+
asset: external_exports.string().max(255).regex(/^[a-z0-9_.-]+\.zip$/iu).optional(),
|
|
15940
|
+
subpath: hostExtensionResourcePathSchema.optional()
|
|
15941
|
+
}).refine(({ ref, tag, asset }) => !ref || !tag && !asset, "Use either a zipball ref or a release tag/asset");
|
|
15942
|
+
var hostExtensionInstallSourceSchema = external_exports.union([
|
|
15943
|
+
external_exports.strictObject({ type: external_exports.literal("catalog"), ...id }),
|
|
15944
|
+
hostExtensionGitHubSourceSchema,
|
|
15945
|
+
external_exports.strictObject({ type: external_exports.literal("zip"), base64: base643(HOST_EXTENSION_ZIP_MAX_BYTES).min(4) }),
|
|
15946
|
+
external_exports.strictObject({ type: external_exports.literal("zip"), localZipPath: filePath }),
|
|
15947
|
+
external_exports.strictObject({ type: external_exports.literal("localDir"), localDir: filePath })
|
|
15948
|
+
]);
|
|
15949
|
+
var hostExtensionProvenanceSchema = external_exports.discriminatedUnion("type", [
|
|
15950
|
+
external_exports.strictObject({ type: external_exports.literal("catalog"), ...id }),
|
|
15951
|
+
hostExtensionGitHubSourceSchema,
|
|
15952
|
+
external_exports.strictObject({ type: external_exports.literal("zip") }),
|
|
15953
|
+
external_exports.strictObject({ type: external_exports.literal("localDir") })
|
|
15954
|
+
]);
|
|
15955
|
+
var hostExtensionInstallationSchema = external_exports.strictObject({
|
|
15956
|
+
...active,
|
|
15957
|
+
manifest: hostExtensionManifestV2Schema,
|
|
15958
|
+
installedAt: external_exports.iso.datetime(),
|
|
15959
|
+
source: hostExtensionProvenanceSchema.optional()
|
|
15960
|
+
});
|
|
15961
|
+
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);
|
|
15962
|
+
var desktopConflict = { desktopConflictWith: hostExtensionIdSchema.optional() };
|
|
15963
|
+
var backendState = external_exports.enum(["none", "inactive", "starting", "running", "failed"]);
|
|
15964
|
+
var hostExtensionListItemSchema = external_exports.discriminatedUnion("state", [
|
|
15965
|
+
hostExtensionInstallationSchema.extend({
|
|
15966
|
+
state: external_exports.literal("valid"),
|
|
15967
|
+
enabled: external_exports.boolean(),
|
|
15968
|
+
...desktopConflict,
|
|
15969
|
+
iconDataUrl: rasterDataUrlSchema(DESKTOP_EXTENSION_ICON_MAX_BYTES).optional(),
|
|
15970
|
+
screenshotDataUrls: external_exports.array(rasterDataUrlSchema(DESKTOP_EXTENSION_SCREENSHOT_MAX_BYTES)).max(DESKTOP_EXTENSION_SCREENSHOT_LIMIT).optional(),
|
|
15971
|
+
backendState: backendState.optional(),
|
|
15972
|
+
backendError: external_exports.string().optional()
|
|
15973
|
+
}),
|
|
15974
|
+
external_exports.strictObject({
|
|
15975
|
+
state: external_exports.enum(["invalid", "incompatible"]),
|
|
15976
|
+
id: external_exports.string().min(1),
|
|
15977
|
+
enabled: external_exports.boolean(),
|
|
15978
|
+
error: external_exports.string()
|
|
15979
|
+
})
|
|
15980
|
+
]);
|
|
15981
|
+
var hostExtensionsListResultSchema = external_exports.strictObject({
|
|
15982
|
+
revision: hostExtensionRevisionSchema,
|
|
15983
|
+
configuration: hostExtensionConfigurationSchema,
|
|
15984
|
+
diagnostics: external_exports.array(external_exports.string()),
|
|
15985
|
+
extensions: external_exports.array(hostExtensionListItemSchema)
|
|
15986
|
+
});
|
|
15987
|
+
var hostExtensionRuntimeEntrySchema = hostExtensionInstallationSchema.extend({
|
|
15988
|
+
...desktopConflict,
|
|
15989
|
+
settingsRevision: hostExtensionRevisionSchema
|
|
15990
|
+
});
|
|
15991
|
+
var hostExtensionsSnapshotResultSchema = external_exports.strictObject({
|
|
15992
|
+
/** The Host publishes this revision in extensions-changed, independent of enabled.json's revision. */
|
|
15993
|
+
revision: hostExtensionRevisionSchema,
|
|
15994
|
+
// Enabled, valid activations only. A Desktop conflict does not hide other capabilities.
|
|
15995
|
+
extensions: external_exports.array(hostExtensionRuntimeEntrySchema).max(DESKTOP_EXTENSION_LIMIT)
|
|
15996
|
+
});
|
|
15997
|
+
var HOST_EXTENSIONS_RPC = {
|
|
15998
|
+
list: "codexhost/extensions/list",
|
|
15999
|
+
snapshot: "codexhost/extensions/snapshot",
|
|
16000
|
+
catalog: "codexhost/extensions/catalog",
|
|
16001
|
+
install: "codexhost/extensions/install",
|
|
16002
|
+
update: "codexhost/extensions/update",
|
|
16003
|
+
enable: "codexhost/extensions/enable",
|
|
16004
|
+
disable: "codexhost/extensions/disable",
|
|
16005
|
+
uninstall: "codexhost/extensions/uninstall",
|
|
16006
|
+
recover: "codexhost/extensions/recover",
|
|
16007
|
+
asset: "codexhost/extensions/asset",
|
|
16008
|
+
settingsGet: "codexhost/extensions/settings/get",
|
|
16009
|
+
settingsSet: "codexhost/extensions/settings/set",
|
|
16010
|
+
backendInvoke: "codexhost/extensions/backend/invoke"
|
|
16011
|
+
};
|
|
16012
|
+
var HOST_EXTENSION_MANAGEMENT_METHODS = Object.freeze(Object.values(HOST_EXTENSIONS_RPC));
|
|
16013
|
+
var methods = new Set(HOST_EXTENSION_MANAGEMENT_METHODS);
|
|
16014
|
+
var noParams = external_exports.strictObject({});
|
|
16015
|
+
var expectedRevision = { expectedRevision: hostExtensionRevisionSchema };
|
|
16016
|
+
var selection = external_exports.strictObject({ ...id, ...expectedRevision });
|
|
16017
|
+
var installationResult = hostExtensionInstallationSchema.extend({ replaced: external_exports.boolean() });
|
|
16018
|
+
var mutationResult = external_exports.discriminatedUnion("state", [
|
|
16019
|
+
external_exports.strictObject({ state: external_exports.literal("saved"), configuration: hostExtensionConfigurationSchema }),
|
|
16020
|
+
external_exports.strictObject({ state: external_exports.literal("revision-conflict"), revision: hostExtensionRevisionSchema })
|
|
16021
|
+
]);
|
|
16022
|
+
var hostExtensionsAssetParamsSchema = external_exports.strictObject({
|
|
16023
|
+
...optionalActivation,
|
|
16024
|
+
digest: active.digest.optional(),
|
|
16025
|
+
path: hostExtensionResourcePathSchema
|
|
16026
|
+
});
|
|
16027
|
+
var hostExtensionsAssetResultSchema = external_exports.strictObject({
|
|
16028
|
+
mimeType: external_exports.string().min(1),
|
|
16029
|
+
base64: base643(DESKTOP_EXTENSION_ASSET_MAX_BYTES),
|
|
16030
|
+
digest: active.digest
|
|
16031
|
+
});
|
|
16032
|
+
var hostExtensionSettingsSchema = external_exports.strictObject({
|
|
16033
|
+
settingsRevision: hostExtensionRevisionSchema,
|
|
16034
|
+
values: jsonObjectSchema
|
|
16035
|
+
});
|
|
16036
|
+
var hostExtensionsRpcSchemas = {
|
|
16037
|
+
[HOST_EXTENSIONS_RPC.list]: { params: noParams, result: hostExtensionsListResultSchema },
|
|
16038
|
+
[HOST_EXTENSIONS_RPC.snapshot]: { params: noParams, result: hostExtensionsSnapshotResultSchema },
|
|
16039
|
+
[HOST_EXTENSIONS_RPC.catalog]: {
|
|
16040
|
+
params: external_exports.strictObject({ forceRefresh: external_exports.boolean().optional() }),
|
|
16041
|
+
result: hostExtensionsCatalogResultSchema
|
|
16042
|
+
},
|
|
16043
|
+
[HOST_EXTENSIONS_RPC.install]: {
|
|
16044
|
+
params: external_exports.strictObject({ source: hostExtensionInstallSourceSchema }),
|
|
16045
|
+
result: installationResult
|
|
16046
|
+
},
|
|
16047
|
+
[HOST_EXTENSIONS_RPC.update]: {
|
|
16048
|
+
params: external_exports.strictObject({
|
|
16049
|
+
...id,
|
|
16050
|
+
expectedDigest: active.digest,
|
|
16051
|
+
expectedActivationId: active.activationId.optional(),
|
|
16052
|
+
source: hostExtensionInstallSourceSchema.optional()
|
|
16053
|
+
}),
|
|
16054
|
+
result: installationResult
|
|
16055
|
+
},
|
|
16056
|
+
[HOST_EXTENSIONS_RPC.enable]: { params: selection, result: mutationResult },
|
|
16057
|
+
[HOST_EXTENSIONS_RPC.disable]: { params: selection, result: mutationResult },
|
|
16058
|
+
[HOST_EXTENSIONS_RPC.uninstall]: {
|
|
16059
|
+
params: external_exports.strictObject({
|
|
16060
|
+
...id,
|
|
16061
|
+
removeData: external_exports.boolean().optional(),
|
|
16062
|
+
expectedDigest: active.digest.optional()
|
|
16063
|
+
}),
|
|
16064
|
+
result: external_exports.strictObject({ ...id, removed: external_exports.boolean() })
|
|
16065
|
+
},
|
|
16066
|
+
[HOST_EXTENSIONS_RPC.recover]: {
|
|
16067
|
+
params: external_exports.strictObject({ expectedRevision: expectedRevision.expectedRevision.optional() }),
|
|
16068
|
+
result: mutationResult
|
|
16069
|
+
},
|
|
16070
|
+
[HOST_EXTENSIONS_RPC.asset]: {
|
|
16071
|
+
params: hostExtensionsAssetParamsSchema,
|
|
16072
|
+
result: hostExtensionsAssetResultSchema
|
|
16073
|
+
},
|
|
16074
|
+
[HOST_EXTENSIONS_RPC.settingsGet]: {
|
|
16075
|
+
params: external_exports.strictObject(optionalActivation),
|
|
16076
|
+
result: hostExtensionSettingsSchema
|
|
16077
|
+
},
|
|
16078
|
+
[HOST_EXTENSIONS_RPC.settingsSet]: {
|
|
16079
|
+
params: external_exports.strictObject({
|
|
16080
|
+
...optionalActivation,
|
|
16081
|
+
expectedSettingsRevision: hostExtensionRevisionSchema,
|
|
16082
|
+
values: jsonObjectSchema
|
|
16083
|
+
}),
|
|
16084
|
+
result: hostExtensionSettingsSchema
|
|
16085
|
+
},
|
|
16086
|
+
[HOST_EXTENSIONS_RPC.backendInvoke]: {
|
|
16087
|
+
params: external_exports.strictObject({
|
|
16088
|
+
...optionalActivation,
|
|
16089
|
+
method: hostExtensionBackendMethodSchema,
|
|
16090
|
+
params: jsonValueSchema.optional()
|
|
16091
|
+
}),
|
|
16092
|
+
result: external_exports.strictObject({ result: jsonValueSchema })
|
|
16093
|
+
}
|
|
16094
|
+
};
|
|
15938
16095
|
|
|
15939
16096
|
// ../../shared-contracts/dist/thread-archive-confirm.js
|
|
15940
16097
|
var THREAD_ARCHIVE_CONFIRM_METHOD = "codexhost/thread/archive/confirm";
|
|
@@ -15997,7 +16154,7 @@ var CLIENT_CHANNEL_METHODS = [
|
|
|
15997
16154
|
"codexhost/harness/session-import/list",
|
|
15998
16155
|
"codexhost/harness/session-import/import",
|
|
15999
16156
|
// Host settings shared across Desktop and Web.
|
|
16000
|
-
...
|
|
16157
|
+
...HOST_EXTENSION_MANAGEMENT_METHODS,
|
|
16001
16158
|
"codexhost/harness/installation",
|
|
16002
16159
|
"codexhost/harness/installation/start",
|
|
16003
16160
|
"codexhost/harness/installation/status",
|
|
@@ -16058,6 +16215,11 @@ var clientChannelEventSchema = external_exports.discriminatedUnion("type", [
|
|
|
16058
16215
|
cursor: clientChannelCursorSchema,
|
|
16059
16216
|
revision: external_exports.number().int().nonnegative()
|
|
16060
16217
|
}),
|
|
16218
|
+
external_exports.object({
|
|
16219
|
+
type: external_exports.literal("extensions-changed"),
|
|
16220
|
+
cursor: clientChannelCursorSchema,
|
|
16221
|
+
revision: hostExtensionRevisionSchema
|
|
16222
|
+
}),
|
|
16061
16223
|
external_exports.object({
|
|
16062
16224
|
type: external_exports.literal("hello"),
|
|
16063
16225
|
version: external_exports.literal(1),
|
|
@@ -16494,7 +16656,7 @@ var DEFAULT_IDLE_RELEASE_SETTINGS = Object.freeze({
|
|
|
16494
16656
|
|
|
16495
16657
|
// ../../shared-contracts/dist/harness-preferences.js
|
|
16496
16658
|
var harnessPreferenceScopeSchema = external_exports.string().regex(/^external$/u);
|
|
16497
|
-
var preferenceHarnessKey = harnessIdSchema.transform((
|
|
16659
|
+
var preferenceHarnessKey = harnessIdSchema.transform((id2) => String(id2));
|
|
16498
16660
|
var harnessDefaultConfigurationSchema = external_exports.strictObject({
|
|
16499
16661
|
model: harnessModelRefSchema.optional(),
|
|
16500
16662
|
thinkingOptionId: harnessThinkingOptionIdSchema.optional(),
|
|
@@ -16504,11 +16666,19 @@ var newThreadDefaultsSchema = external_exports.strictObject({
|
|
|
16504
16666
|
lastHarness: harnessIdSchema.optional(),
|
|
16505
16667
|
byHarness: external_exports.record(preferenceHarnessKey, harnessDefaultConfigurationSchema)
|
|
16506
16668
|
});
|
|
16669
|
+
var harnessDelegationDefaultSchema = external_exports.strictObject({
|
|
16670
|
+
model: harnessModelRefSchema.optional(),
|
|
16671
|
+
thinkingOptionId: harnessThinkingOptionIdSchema.optional()
|
|
16672
|
+
}).refine((value) => Boolean(value.model || value.thinkingOptionId), "A delegation default must contain a Model or Thinking option");
|
|
16673
|
+
var delegationDefaultsSchema = external_exports.strictObject({
|
|
16674
|
+
byHarness: external_exports.record(preferenceHarnessKey, harnessDelegationDefaultSchema)
|
|
16675
|
+
});
|
|
16507
16676
|
var modelId = external_exports.string().min(1).max(1024);
|
|
16508
16677
|
var harnessPreferenceValuesSchema = external_exports.strictObject({
|
|
16509
16678
|
idleRelease: idleReleaseSettingsSchema.optional(),
|
|
16510
16679
|
favorites: external_exports.record(preferenceHarnessKey, external_exports.array(modelId).max(2048)).default({}),
|
|
16511
|
-
newThread: newThreadDefaultsSchema.optional()
|
|
16680
|
+
newThread: newThreadDefaultsSchema.optional(),
|
|
16681
|
+
delegation: delegationDefaultsSchema.optional()
|
|
16512
16682
|
});
|
|
16513
16683
|
var harnessPreferenceSnapshotSchema = external_exports.strictObject({
|
|
16514
16684
|
scope: harnessPreferenceScopeSchema,
|
|
@@ -16536,6 +16706,11 @@ var harnessPreferenceOperationSchema = external_exports.discriminatedUnion("kind
|
|
|
16536
16706
|
lastHarness: harnessIdSchema.optional(),
|
|
16537
16707
|
harnessId: harnessIdSchema.optional(),
|
|
16538
16708
|
configuration: harnessDefaultConfigurationSchema.optional()
|
|
16709
|
+
}),
|
|
16710
|
+
external_exports.strictObject({
|
|
16711
|
+
kind: external_exports.literal("delegation"),
|
|
16712
|
+
harnessId: harnessIdSchema,
|
|
16713
|
+
configuration: harnessDelegationDefaultSchema.nullable()
|
|
16539
16714
|
})
|
|
16540
16715
|
]);
|
|
16541
16716
|
var harnessPreferencePatchSchema = external_exports.strictObject({
|
|
@@ -17359,9 +17534,12 @@ var remoteSessionOperationSchema = external_exports.discriminatedUnion("kind", [
|
|
|
17359
17534
|
...thread,
|
|
17360
17535
|
epoch: identity,
|
|
17361
17536
|
modelId: identity.optional(),
|
|
17537
|
+
serviceTier: harnessModelServiceTierSchema.optional(),
|
|
17362
17538
|
thinkingOptionId: identity.optional(),
|
|
17363
17539
|
permissionModeId: identity.optional()
|
|
17364
|
-
}).refine((value) => [value.modelId, value.thinkingOptionId, value.permissionModeId].filter((v) => v !== void 0).length === 1, "Select exactly one remote setting"),
|
|
17540
|
+
}).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, {
|
|
17541
|
+
message: "A service tier requires a Model ID"
|
|
17542
|
+
}),
|
|
17365
17543
|
external_exports.strictObject({
|
|
17366
17544
|
kind: external_exports.literal("prompt"),
|
|
17367
17545
|
...thread,
|
|
@@ -17411,7 +17589,7 @@ var remoteConnectionsRequestSchema = external_exports.discriminatedUnion("action
|
|
|
17411
17589
|
external_exports.strictObject({ action: external_exports.literal("catalog") }),
|
|
17412
17590
|
external_exports.strictObject({
|
|
17413
17591
|
action: external_exports.literal("read-thread"),
|
|
17414
|
-
hostId: hostId.refine((
|
|
17592
|
+
hostId: hostId.refine((id2) => id2 !== "local"),
|
|
17415
17593
|
input: delegationReadParamsSchema
|
|
17416
17594
|
}),
|
|
17417
17595
|
external_exports.strictObject({
|
|
@@ -17425,7 +17603,7 @@ var remoteConnectionsRequestSchema = external_exports.discriminatedUnion("action
|
|
|
17425
17603
|
external_exports.strictObject({ action: external_exports.literal("runtime"), hostId }),
|
|
17426
17604
|
external_exports.strictObject({
|
|
17427
17605
|
action: external_exports.literal("update"),
|
|
17428
|
-
hostId: hostId.refine((
|
|
17606
|
+
hostId: hostId.refine((id2) => id2 !== "local"),
|
|
17429
17607
|
version: remoteUpdateParamsSchema.shape.version
|
|
17430
17608
|
})
|
|
17431
17609
|
]);
|
|
@@ -17489,7 +17667,7 @@ function invalidRequest(message3) {
|
|
|
17489
17667
|
return { code: "invalidRequest", message: message3, retryable: false };
|
|
17490
17668
|
}
|
|
17491
17669
|
function validateHostApprovalResponse(interaction, response) {
|
|
17492
|
-
return interaction.actions.some(({ id }) =>
|
|
17670
|
+
return interaction.actions.some(({ id: id2 }) => id2 === response.actionId) ? null : invalidRequest("Approval Response contains an undeclared action ID");
|
|
17493
17671
|
}
|
|
17494
17672
|
|
|
17495
17673
|
// ../../harness-adapter/dist/question.js
|
|
@@ -17497,7 +17675,7 @@ function invalidRequest2(message3) {
|
|
|
17497
17675
|
return { code: "invalidRequest", message: message3, retryable: false };
|
|
17498
17676
|
}
|
|
17499
17677
|
function validateHostQuestionResponse(interaction, response) {
|
|
17500
|
-
const questionIds = new Set(interaction.questions.map(({ id }) =>
|
|
17678
|
+
const questionIds = new Set(interaction.questions.map(({ id: id2 }) => id2));
|
|
17501
17679
|
if (response.cancelled) {
|
|
17502
17680
|
return Object.keys(response.answers).length === 0 ? null : invalidRequest2("Cancelled Question Response must not contain answers");
|
|
17503
17681
|
}
|
|
@@ -17612,7 +17790,8 @@ var tokenFields = [
|
|
|
17612
17790
|
var safeIntegerFields = [
|
|
17613
17791
|
"planFiveHourResetsAtUnix",
|
|
17614
17792
|
"planSevenDayResetsAtUnix",
|
|
17615
|
-
"timeToFirstOutputMs"
|
|
17793
|
+
"timeToFirstOutputMs",
|
|
17794
|
+
"latestRequestTimeToFirstOutputMs"
|
|
17616
17795
|
];
|
|
17617
17796
|
var percentFields = [
|
|
17618
17797
|
"cacheHitRatePercent",
|
|
@@ -17876,7 +18055,7 @@ function mergeLiveHarnessCommands(builtIns, idPrefix, live, exclusions = {}) {
|
|
|
17876
18055
|
if (!live)
|
|
17877
18056
|
return builtIns;
|
|
17878
18057
|
const invocations = new Set(builtIns.commands.map(({ invocation }) => invocation));
|
|
17879
|
-
const ids = new Set(builtIns.commands.map(({ id }) =>
|
|
18058
|
+
const ids = new Set(builtIns.commands.map(({ id: id2 }) => id2));
|
|
17880
18059
|
const dynamic = [];
|
|
17881
18060
|
for (const command of live) {
|
|
17882
18061
|
const name = command.name.trim().replace(/^\//u, "");
|
|
@@ -17885,12 +18064,12 @@ function mergeLiveHarnessCommands(builtIns, idPrefix, live, exclusions = {}) {
|
|
|
17885
18064
|
if (isExcludedLiveCommand(name, exclusions))
|
|
17886
18065
|
continue;
|
|
17887
18066
|
const invocation = `/${name}`;
|
|
17888
|
-
const
|
|
17889
|
-
if (invocations.has(invocation) || ids.has(
|
|
18067
|
+
const id2 = `${idPrefix}${name.replace(/[^A-Za-z0-9._:-]/gu, "-")}`.slice(0, 128);
|
|
18068
|
+
if (invocations.has(invocation) || ids.has(id2))
|
|
17890
18069
|
continue;
|
|
17891
18070
|
const description = command.description?.trim().slice(0, 512);
|
|
17892
18071
|
const parsed = harnessCommandDescriptorSchema.safeParse({
|
|
17893
|
-
id,
|
|
18072
|
+
id: id2,
|
|
17894
18073
|
invocation,
|
|
17895
18074
|
label: name.slice(0, 128),
|
|
17896
18075
|
...description ? { description } : {},
|
|
@@ -17899,7 +18078,7 @@ function mergeLiveHarnessCommands(builtIns, idPrefix, live, exclusions = {}) {
|
|
|
17899
18078
|
if (!parsed.success)
|
|
17900
18079
|
continue;
|
|
17901
18080
|
invocations.add(invocation);
|
|
17902
|
-
ids.add(
|
|
18081
|
+
ids.add(id2);
|
|
17903
18082
|
dynamic.push(parsed.data);
|
|
17904
18083
|
}
|
|
17905
18084
|
return harnessCommandCatalogSchema.parse({ commands: [...builtIns.commands, ...dynamic] });
|
|
@@ -19772,8 +19951,8 @@ var RequestResponder = class {
|
|
|
19772
19951
|
signal;
|
|
19773
19952
|
finishRequest;
|
|
19774
19953
|
didRespond = false;
|
|
19775
|
-
constructor(
|
|
19776
|
-
this.id =
|
|
19954
|
+
constructor(id2, sendResult, signal = new AbortController().signal, finishRequest) {
|
|
19955
|
+
this.id = id2;
|
|
19777
19956
|
this.sendResult = sendResult;
|
|
19778
19957
|
this.signal = signal;
|
|
19779
19958
|
this.finishRequest = finishRequest;
|
|
@@ -20064,7 +20243,7 @@ var Connection = class {
|
|
|
20064
20243
|
return this.sendWireMessage({ jsonrpc: "2.0", method, params });
|
|
20065
20244
|
}
|
|
20066
20245
|
prepareRequest(method, params, mapResponse, options = {}) {
|
|
20067
|
-
const
|
|
20246
|
+
const id2 = this.nextRequestId++;
|
|
20068
20247
|
let cancel = () => {
|
|
20069
20248
|
};
|
|
20070
20249
|
const response = new Promise((resolve, reject) => {
|
|
@@ -20084,7 +20263,7 @@ var Connection = class {
|
|
|
20084
20263
|
}
|
|
20085
20264
|
pendingResponse.cancellationSent = true;
|
|
20086
20265
|
pendingResponse.cleanup?.();
|
|
20087
|
-
void this.sendCancelRequest(
|
|
20266
|
+
void this.sendCancelRequest(id2).catch(() => {
|
|
20088
20267
|
});
|
|
20089
20268
|
};
|
|
20090
20269
|
options.cancellationSignal?.addEventListener("abort", cancel, {
|
|
@@ -20093,12 +20272,12 @@ var Connection = class {
|
|
|
20093
20272
|
pendingResponse.cleanup = () => {
|
|
20094
20273
|
options.cancellationSignal?.removeEventListener("abort", cancel);
|
|
20095
20274
|
};
|
|
20096
|
-
this.pendingResponses.set(
|
|
20275
|
+
this.pendingResponses.set(id2, pendingResponse);
|
|
20097
20276
|
});
|
|
20098
20277
|
response.catch(() => {
|
|
20099
20278
|
});
|
|
20100
20279
|
return {
|
|
20101
|
-
message: { jsonrpc: "2.0", id, method, params },
|
|
20280
|
+
message: { jsonrpc: "2.0", id: id2, method, params },
|
|
20102
20281
|
response,
|
|
20103
20282
|
cancel: () => cancel()
|
|
20104
20283
|
};
|
|
@@ -20735,7 +20914,7 @@ function memoryStreamPair() {
|
|
|
20735
20914
|
}
|
|
20736
20915
|
];
|
|
20737
20916
|
}
|
|
20738
|
-
var
|
|
20917
|
+
var methods2 = {
|
|
20739
20918
|
agent: {
|
|
20740
20919
|
initialize: AGENT_METHODS.initialize,
|
|
20741
20920
|
authenticate: AGENT_METHODS.authenticate,
|
|
@@ -22183,16 +22362,16 @@ var Diff = class {
|
|
|
22183
22362
|
}
|
|
22184
22363
|
}
|
|
22185
22364
|
}
|
|
22186
|
-
addToPath(
|
|
22187
|
-
const last =
|
|
22365
|
+
addToPath(path14, added, removed, oldPosInc, options) {
|
|
22366
|
+
const last = path14.lastComponent;
|
|
22188
22367
|
if (last && !options.oneChangePerToken && last.added === added && last.removed === removed) {
|
|
22189
22368
|
return {
|
|
22190
|
-
oldPos:
|
|
22369
|
+
oldPos: path14.oldPos + oldPosInc,
|
|
22191
22370
|
lastComponent: { count: last.count + 1, added, removed, previousComponent: last.previousComponent }
|
|
22192
22371
|
};
|
|
22193
22372
|
} else {
|
|
22194
22373
|
return {
|
|
22195
|
-
oldPos:
|
|
22374
|
+
oldPos: path14.oldPos + oldPosInc,
|
|
22196
22375
|
lastComponent: { count: 1, added, removed, previousComponent: last }
|
|
22197
22376
|
};
|
|
22198
22377
|
}
|
|
@@ -23090,16 +23269,16 @@ var AntigravityToolTracker = class {
|
|
|
23090
23269
|
const diff = record3(value);
|
|
23091
23270
|
if (diff.type !== "diff")
|
|
23092
23271
|
return [];
|
|
23093
|
-
const
|
|
23094
|
-
if (!
|
|
23272
|
+
const path14 = displayPath(text(diff.path), this.options.cwd)?.path;
|
|
23273
|
+
if (!path14)
|
|
23095
23274
|
return [];
|
|
23096
23275
|
const oldText = text(diff.oldText);
|
|
23097
23276
|
const newText = text(diff.newText);
|
|
23098
23277
|
const kind = diff.oldText == null ? "add" : diff.newText == null ? "delete" : "update";
|
|
23099
|
-
const patch = createTwoFilesPatch(kind === "add" ? "/dev/null" :
|
|
23278
|
+
const patch = createTwoFilesPatch(kind === "add" ? "/dev/null" : path14, kind === "delete" ? "/dev/null" : path14, oldText, newText, void 0, void 0, { context: 3 });
|
|
23100
23279
|
return [
|
|
23101
23280
|
{
|
|
23102
|
-
path:
|
|
23281
|
+
path: path14,
|
|
23103
23282
|
kind,
|
|
23104
23283
|
unifiedDiff: patch.length > limit ? `${patch.slice(0, limit)}
|
|
23105
23284
|
[diff truncated]
|
|
@@ -23168,41 +23347,46 @@ var AntigravityToolTracker = class {
|
|
|
23168
23347
|
]);
|
|
23169
23348
|
}
|
|
23170
23349
|
};
|
|
23350
|
+
function compactionItemId(stepIndex) {
|
|
23351
|
+
return hostItemIdSchema.parse(`checkpoint-${stepIndex}`);
|
|
23352
|
+
}
|
|
23353
|
+
function compactionOutcome(event) {
|
|
23354
|
+
if (event.status === "succeeded")
|
|
23355
|
+
return succeeded;
|
|
23356
|
+
return {
|
|
23357
|
+
status: "failed",
|
|
23358
|
+
error: {
|
|
23359
|
+
code: "nativeFailure",
|
|
23360
|
+
message: event.error ?? "Antigravity context compaction failed",
|
|
23361
|
+
retryable: false
|
|
23362
|
+
}
|
|
23363
|
+
};
|
|
23364
|
+
}
|
|
23171
23365
|
function projectReplayedEventsToTurns(params) {
|
|
23172
23366
|
const turns = [];
|
|
23173
|
-
const
|
|
23174
|
-
|
|
23367
|
+
const sessionRef = {
|
|
23368
|
+
harnessId: "antigravity",
|
|
23369
|
+
nativeSessionId: params.nativeSessionId,
|
|
23370
|
+
formatVersion: 1
|
|
23371
|
+
};
|
|
23372
|
+
const turnRef = (nativeTurnKey) => nativeTurnRefSchema.parse({ ...sessionRef, nativeTurnKey });
|
|
23373
|
+
const checkpoint = (checkpointId) => nativeCheckpointRefSchema.parse({ ...sessionRef, checkpointId });
|
|
23374
|
+
let active2;
|
|
23175
23375
|
let userRun = false;
|
|
23176
23376
|
let textItem;
|
|
23177
23377
|
let sequence = 0;
|
|
23178
|
-
|
|
23179
|
-
|
|
23378
|
+
let nativeTurnIndex;
|
|
23379
|
+
const begin = (boundary, wakeStep) => {
|
|
23380
|
+
active2?.tracker.finishPending({
|
|
23180
23381
|
status: "cancelled",
|
|
23181
23382
|
reason: "No terminal tool status in native history"
|
|
23182
23383
|
});
|
|
23183
|
-
const
|
|
23184
|
-
const
|
|
23185
|
-
|
|
23186
|
-
if (nativeTurnKey === void 0) {
|
|
23187
|
-
let n = index;
|
|
23188
|
-
nativeTurnKey = `turn-${n}`;
|
|
23189
|
-
while (usedTurnKeys.has(nativeTurnKey))
|
|
23190
|
-
nativeTurnKey = `turn-${++n}`;
|
|
23191
|
-
usedTurnKeys.add(nativeTurnKey);
|
|
23192
|
-
}
|
|
23384
|
+
const checkpointId = wakeStep !== void 0 ? `wake-${wakeStep}` : boundary === void 0 ? void 0 : `turn-${boundary}`;
|
|
23385
|
+
const nativeTurnKey = checkpointId ?? `replay-${turns.length}`;
|
|
23386
|
+
const turnId = hostTurnIdSchema.parse(nativeTurnKey);
|
|
23193
23387
|
const turn = {
|
|
23194
|
-
nativeTurnRef:
|
|
23195
|
-
|
|
23196
|
-
nativeSessionId: params.nativeSessionId,
|
|
23197
|
-
nativeTurnKey,
|
|
23198
|
-
formatVersion: 1
|
|
23199
|
-
}),
|
|
23200
|
-
checkpoint: nativeCheckpointRefSchema.parse({
|
|
23201
|
-
harnessId: "antigravity",
|
|
23202
|
-
nativeSessionId: params.nativeSessionId,
|
|
23203
|
-
checkpointId: `turn-${index}`,
|
|
23204
|
-
formatVersion: 1
|
|
23205
|
-
}),
|
|
23388
|
+
nativeTurnRef: turnRef(nativeTurnKey),
|
|
23389
|
+
...checkpointId !== void 0 ? { checkpoint: checkpoint(checkpointId) } : {},
|
|
23206
23390
|
input: [],
|
|
23207
23391
|
items: [],
|
|
23208
23392
|
outcome: { status: "unknown", reason: "Native history does not include prompt stop reasons" }
|
|
@@ -23226,12 +23410,22 @@ function projectReplayedEventsToTurns(params) {
|
|
|
23226
23410
|
}
|
|
23227
23411
|
});
|
|
23228
23412
|
textItem = void 0;
|
|
23229
|
-
|
|
23230
|
-
|
|
23413
|
+
nativeTurnIndex = boundary;
|
|
23414
|
+
active2 = { turnId, turn, tracker };
|
|
23415
|
+
return active2;
|
|
23231
23416
|
};
|
|
23232
23417
|
for (const event of params.events) {
|
|
23233
|
-
if (event.type === "
|
|
23234
|
-
|
|
23418
|
+
if (event.type === "history.autonomous") {
|
|
23419
|
+
begin(void 0, event.stepIndex);
|
|
23420
|
+
userRun = false;
|
|
23421
|
+
} else if (event.type === "user.text") {
|
|
23422
|
+
const { turn } = !active2 || !userRun ? begin(event.nativeTurnIndex) : active2;
|
|
23423
|
+
if (event.nativeTurnIndex !== void 0 && event.nativeTurnIndex !== nativeTurnIndex) {
|
|
23424
|
+
nativeTurnIndex = event.nativeTurnIndex;
|
|
23425
|
+
const key = `turn-${nativeTurnIndex}`;
|
|
23426
|
+
turn.nativeTurnRef = turnRef(key);
|
|
23427
|
+
turn.checkpoint = checkpoint(key);
|
|
23428
|
+
}
|
|
23235
23429
|
const previous = turn.input[0];
|
|
23236
23430
|
if (previous)
|
|
23237
23431
|
previous.text += event.text;
|
|
@@ -23240,7 +23434,7 @@ function projectReplayedEventsToTurns(params) {
|
|
|
23240
23434
|
userRun = true;
|
|
23241
23435
|
textItem = void 0;
|
|
23242
23436
|
} else if (event.type === "agent.text" || event.type === "agent.thought") {
|
|
23243
|
-
const { turn } =
|
|
23437
|
+
const { turn, turnId } = active2 ?? begin();
|
|
23244
23438
|
userRun = false;
|
|
23245
23439
|
const type = event.type === "agent.text" ? "agentMessage" : "reasoning";
|
|
23246
23440
|
if (textItem?.item.type === type)
|
|
@@ -23249,7 +23443,7 @@ function projectReplayedEventsToTurns(params) {
|
|
|
23249
23443
|
textItem = {
|
|
23250
23444
|
item: {
|
|
23251
23445
|
type,
|
|
23252
|
-
itemId: hostItemIdSchema.parse(
|
|
23446
|
+
itemId: hostItemIdSchema.parse(`${turnId}-item-${sequence++}`),
|
|
23253
23447
|
text: event.text
|
|
23254
23448
|
},
|
|
23255
23449
|
outcome: succeeded
|
|
@@ -23257,13 +23451,21 @@ function projectReplayedEventsToTurns(params) {
|
|
|
23257
23451
|
turn.items.push(textItem);
|
|
23258
23452
|
}
|
|
23259
23453
|
} else if (event.type === "tool.call" || event.type === "tool.update") {
|
|
23260
|
-
const { tracker } =
|
|
23454
|
+
const { tracker } = active2 ?? begin();
|
|
23261
23455
|
userRun = false;
|
|
23262
23456
|
textItem = void 0;
|
|
23263
23457
|
tracker.handleToolEvent(event);
|
|
23458
|
+
} else if (event.type === "history.compaction") {
|
|
23459
|
+
const { turn } = active2 ?? begin();
|
|
23460
|
+
userRun = false;
|
|
23461
|
+
textItem = void 0;
|
|
23462
|
+
turn.items.push({
|
|
23463
|
+
item: { type: "contextCompaction", itemId: compactionItemId(event.stepIndex) },
|
|
23464
|
+
outcome: compactionOutcome(event)
|
|
23465
|
+
});
|
|
23264
23466
|
}
|
|
23265
23467
|
}
|
|
23266
|
-
|
|
23468
|
+
active2?.tracker.finishPending({
|
|
23267
23469
|
status: "cancelled",
|
|
23268
23470
|
reason: "No terminal tool status in native history"
|
|
23269
23471
|
});
|
|
@@ -23545,7 +23747,7 @@ var AntigravityAcpTransport = class {
|
|
|
23545
23747
|
this.#clearCallbacks();
|
|
23546
23748
|
await this.#request(connection.cancel({ sessionId }), "session/cancel");
|
|
23547
23749
|
}
|
|
23548
|
-
|
|
23750
|
+
#clearSessionState() {
|
|
23549
23751
|
const sessionId = this.#sessionId;
|
|
23550
23752
|
this.#sessionId = null;
|
|
23551
23753
|
this.#acceptCallbacks = false;
|
|
@@ -23554,6 +23756,10 @@ var AntigravityAcpTransport = class {
|
|
|
23554
23756
|
this.#promptRequestId = void 0;
|
|
23555
23757
|
this.#pendingEvents = [];
|
|
23556
23758
|
this.#clearCallbacks();
|
|
23759
|
+
return sessionId;
|
|
23760
|
+
}
|
|
23761
|
+
async closeSession() {
|
|
23762
|
+
const sessionId = this.#clearSessionState();
|
|
23557
23763
|
if (sessionId && this.#connection)
|
|
23558
23764
|
await this.#request(this.#connection.closeSession({ sessionId }), "session/close", this.options.closeTimeoutMs ?? 2e3);
|
|
23559
23765
|
}
|
|
@@ -23564,12 +23770,7 @@ var AntigravityAcpTransport = class {
|
|
|
23564
23770
|
return this.#closing = this.#shutdown();
|
|
23565
23771
|
}
|
|
23566
23772
|
async #shutdown() {
|
|
23567
|
-
|
|
23568
|
-
await this.closeSession();
|
|
23569
|
-
} catch (error51) {
|
|
23570
|
-
this.#stderrRaw = `${this.#stderrRaw}
|
|
23571
|
-
${this.#error(error51).message}`.slice(-32e3);
|
|
23572
|
-
}
|
|
23773
|
+
this.#clearSessionState();
|
|
23573
23774
|
this.#faultSignal.abort(new AntigravityTransportError("unavailable", "Antigravity ACP closed"));
|
|
23574
23775
|
this.#opening = null;
|
|
23575
23776
|
this.#sessionHandler = null;
|
|
@@ -23620,8 +23821,8 @@ ${this.#error(error51).message}`.slice(-32e3);
|
|
|
23620
23821
|
this.#active?.onEvent(event);
|
|
23621
23822
|
}
|
|
23622
23823
|
async #callback(request, invoke, cancelled) {
|
|
23623
|
-
const
|
|
23624
|
-
if (!
|
|
23824
|
+
const active2 = this.#active;
|
|
23825
|
+
if (!active2 || !this.#acceptedCallbacks.delete(request) || !("sessionId" in request) || request.sessionId !== this.#sessionId || this.#closed)
|
|
23625
23826
|
return cancelled;
|
|
23626
23827
|
let cancel;
|
|
23627
23828
|
const cancellation = new Promise((resolve) => {
|
|
@@ -23629,7 +23830,7 @@ ${this.#error(error51).message}`.slice(-32e3);
|
|
|
23629
23830
|
});
|
|
23630
23831
|
this.#callbacks.add(cancel);
|
|
23631
23832
|
try {
|
|
23632
|
-
return await Promise.race([invoke(
|
|
23833
|
+
return await Promise.race([invoke(active2), cancellation]);
|
|
23633
23834
|
} finally {
|
|
23634
23835
|
this.#callbacks.delete(cancel);
|
|
23635
23836
|
}
|
|
@@ -23771,7 +23972,12 @@ function nanoseconds(fields) {
|
|
|
23771
23972
|
const result = seconds * 1000000000n + nanos;
|
|
23772
23973
|
return result / NANOSECONDS_PER_MS <= MAX_MS ? result : null;
|
|
23773
23974
|
}
|
|
23774
|
-
function
|
|
23975
|
+
function nativeStepCreatedAtMs(blob) {
|
|
23976
|
+
const fields = blob instanceof Uint8Array && readProtoFields(blob);
|
|
23977
|
+
const timestamp = fields ? nanoseconds(message(fields, 1)) : null;
|
|
23978
|
+
return timestamp === null ? void 0 : Number(timestamp / NANOSECONDS_PER_MS);
|
|
23979
|
+
}
|
|
23980
|
+
function generatorStepIndices(fields) {
|
|
23775
23981
|
const result = [];
|
|
23776
23982
|
for (const item of fields.filter((candidate) => candidate.number === 2)) {
|
|
23777
23983
|
if (item.wire === 0 && typeof item.value === "bigint") {
|
|
@@ -23820,11 +24026,14 @@ function requestMetadata(metadata, generator, request) {
|
|
|
23820
24026
|
const streamed = nanoseconds(message(chat, 12));
|
|
23821
24027
|
if (created === null || started === null || completed === null || ttft === null || streamed === null || started < created || completed <= started || streamed <= 0n || !closeTo(started - created, ttft) || !closeTo(completed - started, streamed))
|
|
23822
24028
|
return facts;
|
|
23823
|
-
const startedAtMs = Number(started / NANOSECONDS_PER_MS);
|
|
23824
|
-
const completedAtMs = Number(completed / NANOSECONDS_PER_MS);
|
|
23825
24029
|
return {
|
|
23826
24030
|
...facts,
|
|
23827
|
-
|
|
24031
|
+
timing: {
|
|
24032
|
+
requestStartedAtMs: Number(created / NANOSECONDS_PER_MS),
|
|
24033
|
+
timeToFirstOutputMs: Number(ttft / NANOSECONDS_PER_MS),
|
|
24034
|
+
startedAtMs: Number(started / NANOSECONDS_PER_MS),
|
|
24035
|
+
completedAtMs: Number(completed / NANOSECONDS_PER_MS)
|
|
24036
|
+
}
|
|
23828
24037
|
};
|
|
23829
24038
|
}
|
|
23830
24039
|
async function readAntigravityRequestMetadata(nativeSessionId, home, requests, neededSteps = new Set(requests.keys())) {
|
|
@@ -23859,7 +24068,7 @@ async function readAntigravityRequestMetadata(nativeSessionId, home, requests, n
|
|
|
23859
24068
|
if (!(generated?.data instanceof Uint8Array))
|
|
23860
24069
|
continue;
|
|
23861
24070
|
const fields = readProtoFields(generated.data);
|
|
23862
|
-
const indices = fields &&
|
|
24071
|
+
const indices = fields && generatorStepIndices(fields);
|
|
23863
24072
|
if (!fields || !indices)
|
|
23864
24073
|
continue;
|
|
23865
24074
|
const plannerSteps = [...new Set(indices.filter((step) => requests.get(step)))];
|
|
@@ -23982,7 +24191,7 @@ var AntigravitySessionUsageTracker = class {
|
|
|
23982
24191
|
#file;
|
|
23983
24192
|
#nativeSessionId;
|
|
23984
24193
|
#home;
|
|
23985
|
-
#
|
|
24194
|
+
#timingTurn = { startedAtMs: 0 };
|
|
23986
24195
|
#consumed = /* @__PURE__ */ new Map();
|
|
23987
24196
|
#requests = /* @__PURE__ */ new Map();
|
|
23988
24197
|
#expectedInitialTurns;
|
|
@@ -23995,6 +24204,7 @@ var AntigravitySessionUsageTracker = class {
|
|
|
23995
24204
|
#outputTokensPerSecond;
|
|
23996
24205
|
#complete = true;
|
|
23997
24206
|
#turnCollectionSteps = /* @__PURE__ */ new Set();
|
|
24207
|
+
#awaitingTiming = /* @__PURE__ */ new Map();
|
|
23998
24208
|
constructor(options) {
|
|
23999
24209
|
this.#nativeSessionId = options.nativeSessionId;
|
|
24000
24210
|
this.#home = options.homedir;
|
|
@@ -24030,8 +24240,8 @@ var AntigravitySessionUsageTracker = class {
|
|
|
24030
24240
|
}
|
|
24031
24241
|
return this.currentUsage();
|
|
24032
24242
|
}
|
|
24033
|
-
beginTurn(startedAtMs = Date.now()) {
|
|
24034
|
-
this.#
|
|
24243
|
+
beginTurn(startedAtMs = Date.now(), turnId) {
|
|
24244
|
+
this.#timingTurn = { startedAtMs, ...turnId && { turnId } };
|
|
24035
24245
|
this.#turnBase = this.#pending ? addUsage(this.#pending.base, this.#pending.usage) : requestUsage([...this.#requests.values()]);
|
|
24036
24246
|
this.#turnCollectionSteps.clear();
|
|
24037
24247
|
this.#turnActive = true;
|
|
@@ -24065,7 +24275,7 @@ var AntigravitySessionUsageTracker = class {
|
|
|
24065
24275
|
}
|
|
24066
24276
|
async replayHistoricalRequests(signal) {
|
|
24067
24277
|
const transcript = await this.#read(signal);
|
|
24068
|
-
const requests = this.#consume(transcript, true);
|
|
24278
|
+
const { requests } = this.#consume(transcript, true);
|
|
24069
24279
|
this.#reconcile();
|
|
24070
24280
|
return { requests, complete: this.#historyComplete(), usage: this.currentUsage() };
|
|
24071
24281
|
}
|
|
@@ -24080,17 +24290,27 @@ var AntigravitySessionUsageTracker = class {
|
|
|
24080
24290
|
const usage = promptUsage(input.promptUsage);
|
|
24081
24291
|
const hadPending = this.#pending !== void 0;
|
|
24082
24292
|
const cacheUsage = usage && this.#pending ? addUsage(this.#pending.usage, usage) : usage ?? this.#pending?.usage;
|
|
24083
|
-
const requests = this.#consume(transcript, false, cacheUsage
|
|
24084
|
-
const
|
|
24085
|
-
|
|
24086
|
-
|
|
24087
|
-
const
|
|
24088
|
-
|
|
24089
|
-
|
|
24293
|
+
const { requests, timings } = this.#consume(transcript, false, cacheUsage);
|
|
24294
|
+
const [step] = this.#turnCollectionSteps;
|
|
24295
|
+
if (step !== void 0 && this.#turnCollectionSteps.size === 1 && !hadPending && !input.hasToolCalls && !transcript.toolCallSteps.has(step) && transcript.metadata === null && transcript.complete && !this.#invalidated && usage?.inputTokens !== void 0 && usage.outputTokens !== void 0) {
|
|
24296
|
+
const single = this.#requests.get(step);
|
|
24297
|
+
const { startedAtMs, completedAtMs } = timing(input);
|
|
24298
|
+
if (single && single.startedAtMs === void 0 && (single.reasoningOutputTokens ?? usage.reasoningOutputTokens) === 0 && (usage.reasoningOutputTokens ?? 0) === 0 && usageMatches(requestUsage([single]), usage, true) && startedAtMs !== void 0 && completedAtMs !== void 0) {
|
|
24299
|
+
const updated = parseHostUsageRequest({ ...single, startedAtMs, completedAtMs });
|
|
24300
|
+
const index = requests.indexOf(single);
|
|
24301
|
+
if (index !== -1)
|
|
24302
|
+
requests[index] = updated;
|
|
24303
|
+
else if (completedAtMs > startedAtMs && single.outputTokens > 0)
|
|
24304
|
+
timings.push({
|
|
24305
|
+
...this.#timingIdentity(single, this.#timingTurn),
|
|
24306
|
+
output: { startedAtMs, completedAtMs, outputTokens: single.outputTokens }
|
|
24307
|
+
});
|
|
24308
|
+
this.#requests.set(step, updated);
|
|
24309
|
+
}
|
|
24090
24310
|
}
|
|
24091
24311
|
this.#recordTurnOutputSpeed();
|
|
24092
24312
|
this.#reconcile();
|
|
24093
|
-
return { requests, complete: this.#historyComplete(), usage: this.currentUsage() };
|
|
24313
|
+
return { requests, timings, complete: this.#historyComplete(), usage: this.currentUsage() };
|
|
24094
24314
|
}
|
|
24095
24315
|
#recordTurnOutputSpeed() {
|
|
24096
24316
|
let tokens = 0;
|
|
@@ -24105,9 +24325,10 @@ var AntigravitySessionUsageTracker = class {
|
|
|
24105
24325
|
if (milliseconds > 0)
|
|
24106
24326
|
this.#outputTokensPerSecond = tokens / (milliseconds / 1e3);
|
|
24107
24327
|
}
|
|
24108
|
-
#consume(transcript, historical, cacheUsage
|
|
24328
|
+
#consume(transcript, historical, cacheUsage) {
|
|
24109
24329
|
this.#complete = transcript.complete;
|
|
24110
24330
|
const requests = [];
|
|
24331
|
+
const timings = [];
|
|
24111
24332
|
const steps = /* @__PURE__ */ new Set([...this.#pending?.steps ?? [], ...this.#turnCollectionSteps]);
|
|
24112
24333
|
for (const [step, request] of transcript.steps) {
|
|
24113
24334
|
if (!request)
|
|
@@ -24122,8 +24343,14 @@ var AntigravitySessionUsageTracker = class {
|
|
|
24122
24343
|
"cachedInputTokens",
|
|
24123
24344
|
"cacheWriteInputTokens",
|
|
24124
24345
|
"reasoningOutputTokens"
|
|
24125
|
-
].some((field3) => previous[field3] !== request[field3]))
|
|
24346
|
+
].some((field3) => previous[field3] !== request[field3])) {
|
|
24126
24347
|
this.#invalidated = true;
|
|
24348
|
+
this.#awaitingTiming.delete(step);
|
|
24349
|
+
}
|
|
24350
|
+
const recorded = this.#requests.get(step);
|
|
24351
|
+
const turn2 = this.#awaitingTiming.get(step);
|
|
24352
|
+
if (!historical && recorded && turn2)
|
|
24353
|
+
this.#requests.set(step, this.#applyTiming(transcript, step, recorded, timings, turn2, true));
|
|
24127
24354
|
continue;
|
|
24128
24355
|
}
|
|
24129
24356
|
const write = cacheUsage?.cacheWriteInputTokens;
|
|
@@ -24146,26 +24373,46 @@ var AntigravitySessionUsageTracker = class {
|
|
|
24146
24373
|
this.#complete = false;
|
|
24147
24374
|
continue;
|
|
24148
24375
|
}
|
|
24149
|
-
const
|
|
24150
|
-
|
|
24151
|
-
|
|
24152
|
-
|
|
24153
|
-
|
|
24154
|
-
|
|
24155
|
-
if (!historical && this.#turnActive && !finalizing && transcript.metadata !== null && !clock && !transcript.toolCallSteps.has(step))
|
|
24156
|
-
continue;
|
|
24157
|
-
parsed = parseHostUsageRequest({
|
|
24158
|
-
...parsed,
|
|
24159
|
-
...historical ? { historical: true } : {},
|
|
24160
|
-
...clock
|
|
24161
|
-
});
|
|
24376
|
+
const turn = historical ? void 0 : this.#timingTurn;
|
|
24377
|
+
if (turn)
|
|
24378
|
+
this.#awaitingTiming.set(step, turn);
|
|
24379
|
+
else
|
|
24380
|
+
parsed.historical = true;
|
|
24381
|
+
const timed = this.#applyTiming(transcript, step, parsed, timings, turn);
|
|
24162
24382
|
this.#consumed.set(step, request);
|
|
24163
|
-
this.#requests.set(step,
|
|
24164
|
-
requests.push(parsed);
|
|
24165
|
-
}
|
|
24166
|
-
return requests;
|
|
24383
|
+
this.#requests.set(step, timed);
|
|
24384
|
+
requests.push(historical || this.#turnActive ? timed : parsed);
|
|
24385
|
+
}
|
|
24386
|
+
return { requests, timings };
|
|
24387
|
+
}
|
|
24388
|
+
#timingIdentity(request, turn) {
|
|
24389
|
+
return { requestId: request.requestId, ...turn.turnId && { turnId: turn.turnId } };
|
|
24390
|
+
}
|
|
24391
|
+
#applyTiming(transcript, step, request, timings, turn, late = false) {
|
|
24392
|
+
const native = transcript.metadata?.get(step);
|
|
24393
|
+
if (!native?.timing || native.timing.completedAtMs > Date.now())
|
|
24394
|
+
return request;
|
|
24395
|
+
this.#awaitingTiming.delete(step);
|
|
24396
|
+
const { requestStartedAtMs, timeToFirstOutputMs, startedAtMs, completedAtMs } = native.timing;
|
|
24397
|
+
const thought = request.reasoningOutputTokens ?? native.reasoningOutputTokens;
|
|
24398
|
+
if (turn && requestStartedAtMs < turn.startedAtMs || thought !== native.reasoningOutputTokens)
|
|
24399
|
+
return request;
|
|
24400
|
+
const interval = request.startedAtMs === void 0 && thought < request.outputTokens && !transcript.toolCallSteps.has(step) && completedAtMs > startedAtMs ? { startedAtMs, completedAtMs, outputTokens: request.outputTokens - thought } : void 0;
|
|
24401
|
+
const separateOutput = late || !this.#turnActive;
|
|
24402
|
+
if (turn)
|
|
24403
|
+
timings.push({
|
|
24404
|
+
...this.#timingIdentity(request, turn),
|
|
24405
|
+
requestStartedAtMs,
|
|
24406
|
+
timeToFirstOutputMs,
|
|
24407
|
+
...separateOutput && interval ? { output: interval } : {}
|
|
24408
|
+
});
|
|
24409
|
+
return parseHostUsageRequest({
|
|
24410
|
+
...request,
|
|
24411
|
+
reasoningOutputTokens: thought,
|
|
24412
|
+
...interval ? { startedAtMs, completedAtMs, timedOutputTokens: interval.outputTokens } : {}
|
|
24413
|
+
});
|
|
24167
24414
|
}
|
|
24168
|
-
async #read(signal
|
|
24415
|
+
async #read(signal) {
|
|
24169
24416
|
signal?.throwIfAborted();
|
|
24170
24417
|
const stream = createReadStream(this.#file, { encoding: "utf8", signal });
|
|
24171
24418
|
const lines = createInterface({ input: stream, crlfDelay: Infinity });
|
|
@@ -24227,9 +24474,12 @@ var AntigravitySessionUsageTracker = class {
|
|
|
24227
24474
|
stream.destroy();
|
|
24228
24475
|
}
|
|
24229
24476
|
result.complete &&= [...result.steps.values()].every((request) => request !== null) && [...this.#consumed.keys()].every((step) => result.steps.has(step));
|
|
24230
|
-
const
|
|
24231
|
-
|
|
24232
|
-
|
|
24477
|
+
const needed = new Set(this.#awaitingTiming.keys());
|
|
24478
|
+
for (const step of result.steps.keys())
|
|
24479
|
+
if (!this.#consumed.has(step))
|
|
24480
|
+
needed.add(step);
|
|
24481
|
+
if (needed.size > 0)
|
|
24482
|
+
result.metadata = await readAntigravityRequestMetadata(this.#nativeSessionId, this.#home, result.steps, needed);
|
|
24233
24483
|
signal?.throwIfAborted();
|
|
24234
24484
|
return result;
|
|
24235
24485
|
}
|
|
@@ -24243,7 +24493,8 @@ var DELEGATION_ENVIRONMENT_KEYS = [
|
|
|
24243
24493
|
"CODEXHOST_THREAD_ID"
|
|
24244
24494
|
];
|
|
24245
24495
|
var ANTIGRAVITY_DELEGATION_INSTRUCTIONS = `This Antigravity Session runs inside codexhost.
|
|
24246
|
-
When the user requests cross-Harness delegation, use the executable specified by the CODEXHOST_CLI_PATH environment variable through your native shell tool.
|
|
24496
|
+
When the user requests cross-Harness delegation, use the executable specified by the CODEXHOST_CLI_PATH environment variable through your native shell tool. Use delegate start and thread send/read/wait/cancel as documented. Use --help or harness list when you need to discover commands or targets. Use --format compact for results. Keep the inherited CODEXHOST_RUNTIME_ENDPOINT, CODEXHOST_RUNTIME_TOKEN and CODEXHOST_THREAD_ID environment variables for every call; they identify this Runtime and parent Thread. Never print their values, substitute another executable, or delegate without user authorization. Native Antigravity subagents are separate from cross-Harness delegation.
|
|
24497
|
+
For an explicit Model, Thinking level, or speed, read harness inspect --help and inspect the target. Pass the exact advertised Model Ref for the requested speed via --model and the Thinking option ID via --thinking. If a requested selection is unavailable, report it and ask before choosing a different one.`;
|
|
24247
24498
|
function antigravityDelegationInstructions(environment) {
|
|
24248
24499
|
return DELEGATION_ENVIRONMENT_KEYS.every((key) => environment[key]) ? ANTIGRAVITY_DELEGATION_INSTRUCTIONS : void 0;
|
|
24249
24500
|
}
|
|
@@ -24251,8 +24502,8 @@ function antigravityDelegationInstructions(environment) {
|
|
|
24251
24502
|
// dist/fork.js
|
|
24252
24503
|
import { randomUUID } from "node:crypto";
|
|
24253
24504
|
import { access as access2, cp, mkdir, open, rm as rm2 } from "node:fs/promises";
|
|
24254
|
-
import
|
|
24255
|
-
import
|
|
24505
|
+
import os4 from "node:os";
|
|
24506
|
+
import path10 from "node:path";
|
|
24256
24507
|
|
|
24257
24508
|
// dist/native-trajectory-metadata.js
|
|
24258
24509
|
var DEFAULT_CLI_PROJECT_ID = "default-cli-project";
|
|
@@ -24351,19 +24602,83 @@ function rewriteTrajectoryMetadataCascadeId(blob, cascadeId) {
|
|
|
24351
24602
|
|
|
24352
24603
|
// dist/native-turn-boundaries.js
|
|
24353
24604
|
import { access } from "node:fs/promises";
|
|
24605
|
+
import os2 from "node:os";
|
|
24606
|
+
import path8 from "node:path";
|
|
24607
|
+
import { setTimeout as delay } from "node:timers/promises";
|
|
24608
|
+
function nativeConversationDbPath(id2, home = os2.homedir()) {
|
|
24609
|
+
return path8.join(home, ".gemini", "antigravity-cli", "conversations", `${id2}.db`);
|
|
24610
|
+
}
|
|
24354
24611
|
async function readNativeTurnCount(dbPath) {
|
|
24612
|
+
return withReadSnapshot(dbPath, countInputs);
|
|
24613
|
+
}
|
|
24614
|
+
function countInputs(db) {
|
|
24615
|
+
return Number(db.prepare("SELECT count(*) AS n FROM steps WHERE step_type = 14").get()?.n ?? 0);
|
|
24616
|
+
}
|
|
24617
|
+
function latestInputCreatedAtMs(db) {
|
|
24618
|
+
const columns = db.prepare("PRAGMA table_info(steps)").all();
|
|
24619
|
+
if (!columns.some((column) => column.name === "metadata"))
|
|
24620
|
+
return void 0;
|
|
24621
|
+
const row = db.prepare("SELECT metadata FROM steps WHERE step_type = 14 ORDER BY idx DESC LIMIT 1").get();
|
|
24622
|
+
return nativeStepCreatedAtMs(row?.metadata);
|
|
24623
|
+
}
|
|
24624
|
+
async function withReadSnapshot(dbPath, read) {
|
|
24355
24625
|
await access(dbPath);
|
|
24356
24626
|
const { DatabaseSync } = await import("node:sqlite");
|
|
24357
24627
|
const db = new DatabaseSync(dbPath, { readOnly: true });
|
|
24358
24628
|
try {
|
|
24359
|
-
|
|
24360
|
-
return
|
|
24629
|
+
db.exec("BEGIN");
|
|
24630
|
+
return read(db);
|
|
24361
24631
|
} finally {
|
|
24362
24632
|
db.close();
|
|
24363
24633
|
}
|
|
24364
24634
|
}
|
|
24635
|
+
var COMMIT_BUDGET_MS = 250;
|
|
24636
|
+
var COMMIT_RECHECK_MS = [0, 25, 75, 175, COMMIT_BUDGET_MS];
|
|
24637
|
+
async function observeNativeTurnCount(dbPath, before, submittedAtMs, completedAtMs, retry, signal) {
|
|
24638
|
+
const started = performance.now();
|
|
24639
|
+
for (const at of retry ? COMMIT_RECHECK_MS : [0]) {
|
|
24640
|
+
if (at > 0) {
|
|
24641
|
+
const elapsed = performance.now() - started;
|
|
24642
|
+
if (elapsed >= COMMIT_BUDGET_MS && at < COMMIT_BUDGET_MS)
|
|
24643
|
+
continue;
|
|
24644
|
+
if (elapsed < at)
|
|
24645
|
+
await delay(Math.ceil(at - elapsed), void 0, { signal }).catch(() => void 0);
|
|
24646
|
+
if (signal.aborted)
|
|
24647
|
+
break;
|
|
24648
|
+
}
|
|
24649
|
+
try {
|
|
24650
|
+
const confirmed = await withReadSnapshot(dbPath, (db) => {
|
|
24651
|
+
const count4 = countInputs(db);
|
|
24652
|
+
if (count4 <= (before ?? 0))
|
|
24653
|
+
return null;
|
|
24654
|
+
const createdAtMs = latestInputCreatedAtMs(db);
|
|
24655
|
+
if (createdAtMs !== void 0) {
|
|
24656
|
+
return createdAtMs > submittedAtMs && createdAtMs <= completedAtMs ? count4 : null;
|
|
24657
|
+
}
|
|
24658
|
+
return before !== null && count4 === before + 1 ? count4 : null;
|
|
24659
|
+
});
|
|
24660
|
+
if (confirmed !== null)
|
|
24661
|
+
return confirmed;
|
|
24662
|
+
} catch (error51) {
|
|
24663
|
+
const { code } = nativeHistoryError(error51);
|
|
24664
|
+
if (code !== "sessionBusy" && code !== "sessionNotFound")
|
|
24665
|
+
break;
|
|
24666
|
+
}
|
|
24667
|
+
}
|
|
24668
|
+
return null;
|
|
24669
|
+
}
|
|
24365
24670
|
function nativeHistoryError(error51) {
|
|
24366
|
-
const
|
|
24671
|
+
const sqlite = error51;
|
|
24672
|
+
if (sqlite?.code === "ERR_SQLITE_ERROR" && sqlite.errcode !== void 0) {
|
|
24673
|
+
const primary = sqlite.errcode & 255;
|
|
24674
|
+
if (primary === 5 || primary === 6)
|
|
24675
|
+
return {
|
|
24676
|
+
code: "sessionBusy",
|
|
24677
|
+
message: "Antigravity native history database is locked; retry shortly",
|
|
24678
|
+
retryable: true
|
|
24679
|
+
};
|
|
24680
|
+
}
|
|
24681
|
+
const missing = sqlite?.code === "ENOENT";
|
|
24367
24682
|
return {
|
|
24368
24683
|
code: missing ? "sessionNotFound" : "nativeFailure",
|
|
24369
24684
|
message: missing ? "Antigravity native conversation database was not found" : "Cannot read or derive Antigravity native history",
|
|
@@ -24371,10 +24686,298 @@ function nativeHistoryError(error51) {
|
|
|
24371
24686
|
};
|
|
24372
24687
|
}
|
|
24373
24688
|
|
|
24689
|
+
// dist/native-replay.js
|
|
24690
|
+
var USER_INPUT = 14;
|
|
24691
|
+
var PLANNER_RESPONSE = 15;
|
|
24692
|
+
var ERROR_MESSAGE = 17;
|
|
24693
|
+
var CHECKPOINT = 23;
|
|
24694
|
+
var SYSTEM_MESSAGE = 101;
|
|
24695
|
+
var GENERIC_TOOL = 132;
|
|
24696
|
+
var DONE = 3;
|
|
24697
|
+
var ERROR = 7;
|
|
24698
|
+
var IN_FLIGHT = /* @__PURE__ */ new Set([1, 2, 8, 9, 11]);
|
|
24699
|
+
function message2(payload) {
|
|
24700
|
+
const fields = payload instanceof Uint8Array ? readProtoFields(payload) : null;
|
|
24701
|
+
if (!fields)
|
|
24702
|
+
throw new Error("Invalid Antigravity history protobuf");
|
|
24703
|
+
return fields;
|
|
24704
|
+
}
|
|
24705
|
+
function messageField(fields, number4) {
|
|
24706
|
+
const field3 = fields.find((entry) => entry.number === number4 && entry.wire === 2);
|
|
24707
|
+
return field3?.value instanceof Uint8Array ? field3.value : void 0;
|
|
24708
|
+
}
|
|
24709
|
+
function nested(fields, number4) {
|
|
24710
|
+
const payload = messageField(fields, number4);
|
|
24711
|
+
return payload ? message2(payload) : [];
|
|
24712
|
+
}
|
|
24713
|
+
function textField(fields, number4) {
|
|
24714
|
+
const bytes = messageField(fields, number4);
|
|
24715
|
+
return bytes ? Buffer.from(bytes).toString("utf8") : "";
|
|
24716
|
+
}
|
|
24717
|
+
function argsValue(raw) {
|
|
24718
|
+
if (!raw)
|
|
24719
|
+
return void 0;
|
|
24720
|
+
try {
|
|
24721
|
+
return JSON.parse(raw);
|
|
24722
|
+
} catch {
|
|
24723
|
+
return raw;
|
|
24724
|
+
}
|
|
24725
|
+
}
|
|
24726
|
+
async function readNativeHistory(sessionId, home) {
|
|
24727
|
+
if (!/^[a-zA-Z0-9][a-zA-Z0-9_-]*$/u.test(sessionId))
|
|
24728
|
+
throw new Error("Invalid native Session ID");
|
|
24729
|
+
const { DatabaseSync } = await import("node:sqlite");
|
|
24730
|
+
const db = new DatabaseSync(nativeConversationDbPath(sessionId, home), { readOnly: true });
|
|
24731
|
+
try {
|
|
24732
|
+
db.exec("BEGIN");
|
|
24733
|
+
return decodeNativeHistory(db);
|
|
24734
|
+
} finally {
|
|
24735
|
+
db.close();
|
|
24736
|
+
}
|
|
24737
|
+
}
|
|
24738
|
+
async function readNativeStepWatermark(dbPath) {
|
|
24739
|
+
const { DatabaseSync } = await import("node:sqlite");
|
|
24740
|
+
let db;
|
|
24741
|
+
try {
|
|
24742
|
+
db = new DatabaseSync(dbPath, { readOnly: true });
|
|
24743
|
+
} catch {
|
|
24744
|
+
return -1;
|
|
24745
|
+
}
|
|
24746
|
+
try {
|
|
24747
|
+
db.exec("BEGIN");
|
|
24748
|
+
const row = db.prepare("SELECT MAX(idx) AS max_idx FROM steps").get();
|
|
24749
|
+
return row?.max_idx === null || row?.max_idx === void 0 ? -1 : Number(row.max_idx);
|
|
24750
|
+
} catch {
|
|
24751
|
+
return -1;
|
|
24752
|
+
} finally {
|
|
24753
|
+
db.close();
|
|
24754
|
+
}
|
|
24755
|
+
}
|
|
24756
|
+
function decodeCheckpointEvent(idx, status, step) {
|
|
24757
|
+
if (status !== DONE && status !== ERROR)
|
|
24758
|
+
return void 0;
|
|
24759
|
+
const error51 = status === ERROR ? nested(step, 31) : [];
|
|
24760
|
+
const errorText = textField(error51, 3) || textField(error51, 2) || textField(error51, 1);
|
|
24761
|
+
return {
|
|
24762
|
+
type: "history.compaction",
|
|
24763
|
+
stepIndex: idx,
|
|
24764
|
+
status: status === DONE ? "succeeded" : "failed",
|
|
24765
|
+
...errorText ? { error: errorText } : {}
|
|
24766
|
+
};
|
|
24767
|
+
}
|
|
24768
|
+
async function readNativeTurnCompactions(dbPath, afterStepIndex) {
|
|
24769
|
+
const { DatabaseSync } = await import("node:sqlite");
|
|
24770
|
+
let db;
|
|
24771
|
+
try {
|
|
24772
|
+
db = new DatabaseSync(dbPath, { readOnly: true });
|
|
24773
|
+
} catch {
|
|
24774
|
+
return [];
|
|
24775
|
+
}
|
|
24776
|
+
try {
|
|
24777
|
+
db.exec("BEGIN");
|
|
24778
|
+
if (db.prepare("PRAGMA user_version").get()?.user_version !== 1)
|
|
24779
|
+
return [];
|
|
24780
|
+
const compactions = [];
|
|
24781
|
+
let turnRun;
|
|
24782
|
+
let seenUserInput = false;
|
|
24783
|
+
const wakeRuns = /* @__PURE__ */ new Set();
|
|
24784
|
+
for (const row of db.prepare(`SELECT idx, step_type, status, step_payload FROM steps
|
|
24785
|
+
WHERE idx > ? AND step_type IN (${USER_INPUT}, ${SYSTEM_MESSAGE}, ${CHECKPOINT})
|
|
24786
|
+
ORDER BY idx`).iterate(afterStepIndex)) {
|
|
24787
|
+
const idx = Number(row.idx);
|
|
24788
|
+
const step = message2(row.step_payload);
|
|
24789
|
+
const stepRun = textField(nested(step, 5), 12);
|
|
24790
|
+
if (row.step_type === USER_INPUT) {
|
|
24791
|
+
seenUserInput = true;
|
|
24792
|
+
turnRun = stepRun;
|
|
24793
|
+
continue;
|
|
24794
|
+
}
|
|
24795
|
+
if (row.step_type === SYSTEM_MESSAGE) {
|
|
24796
|
+
if (stepRun && stepRun !== turnRun)
|
|
24797
|
+
wakeRuns.add(stepRun);
|
|
24798
|
+
continue;
|
|
24799
|
+
}
|
|
24800
|
+
if (!seenUserInput)
|
|
24801
|
+
continue;
|
|
24802
|
+
if (stepRun && wakeRuns.has(stepRun))
|
|
24803
|
+
continue;
|
|
24804
|
+
if (stepRun && turnRun && stepRun !== turnRun)
|
|
24805
|
+
continue;
|
|
24806
|
+
const event = decodeCheckpointEvent(idx, row.status, step);
|
|
24807
|
+
if (event)
|
|
24808
|
+
compactions.push(event);
|
|
24809
|
+
}
|
|
24810
|
+
return compactions;
|
|
24811
|
+
} catch {
|
|
24812
|
+
return [];
|
|
24813
|
+
} finally {
|
|
24814
|
+
db.close();
|
|
24815
|
+
}
|
|
24816
|
+
}
|
|
24817
|
+
function decodeNativeHistory(db) {
|
|
24818
|
+
const events = [];
|
|
24819
|
+
let toolCalls = /* @__PURE__ */ new Map();
|
|
24820
|
+
let turnCount = 0;
|
|
24821
|
+
let run = "";
|
|
24822
|
+
let candidate;
|
|
24823
|
+
let wake;
|
|
24824
|
+
let finalPlanner = false;
|
|
24825
|
+
const endWake = () => {
|
|
24826
|
+
if (wake && !wake.settled)
|
|
24827
|
+
events.length = wake.eventIndex;
|
|
24828
|
+
wake = void 0;
|
|
24829
|
+
candidate = void 0;
|
|
24830
|
+
};
|
|
24831
|
+
const append = (type, text2) => {
|
|
24832
|
+
if (text2)
|
|
24833
|
+
events.push({ type, text: events.at(-1)?.type === type ? `
|
|
24834
|
+
|
|
24835
|
+
${text2}` : text2 });
|
|
24836
|
+
};
|
|
24837
|
+
if (db.prepare("PRAGMA user_version").get()?.user_version !== 1)
|
|
24838
|
+
throw new Error("Unsupported Antigravity history database version");
|
|
24839
|
+
for (const row of db.prepare(`SELECT idx, step_type, status, step_payload FROM steps
|
|
24840
|
+
WHERE step_type IN (${USER_INPUT}, ${PLANNER_RESPONSE}, ${ERROR_MESSAGE}, ${CHECKPOINT}, ${SYSTEM_MESSAGE}, ${GENERIC_TOOL})
|
|
24841
|
+
ORDER BY idx`).iterate()) {
|
|
24842
|
+
const idx = Number(row.idx);
|
|
24843
|
+
const nativeTurnIndex = row.step_type === USER_INPUT ? turnCount++ : void 0;
|
|
24844
|
+
if (nativeTurnIndex !== void 0) {
|
|
24845
|
+
endWake();
|
|
24846
|
+
finalPlanner = false;
|
|
24847
|
+
}
|
|
24848
|
+
if (IN_FLIGHT.has(Number(row.status))) {
|
|
24849
|
+
if (wake && row.step_type === PLANNER_RESPONSE)
|
|
24850
|
+
wake.settled = false;
|
|
24851
|
+
continue;
|
|
24852
|
+
}
|
|
24853
|
+
const step = message2(row.step_payload);
|
|
24854
|
+
const metadata = nested(step, 5);
|
|
24855
|
+
const stepRun = textField(metadata, 12);
|
|
24856
|
+
if (row.step_type === SYSTEM_MESSAGE) {
|
|
24857
|
+
if (row.status === DONE && (stepRun ? stepRun !== run : finalPlanner)) {
|
|
24858
|
+
if (candidate?.run !== stepRun) {
|
|
24859
|
+
endWake();
|
|
24860
|
+
candidate = { stepIndex: idx, run: stepRun, events: [], calls: /* @__PURE__ */ new Map() };
|
|
24861
|
+
}
|
|
24862
|
+
}
|
|
24863
|
+
continue;
|
|
24864
|
+
}
|
|
24865
|
+
if (row.step_type === CHECKPOINT) {
|
|
24866
|
+
const event = decodeCheckpointEvent(idx, row.status, step);
|
|
24867
|
+
if (!event)
|
|
24868
|
+
continue;
|
|
24869
|
+
const pendingWake = candidate?.run === stepRun ? candidate : void 0;
|
|
24870
|
+
if (!pendingWake && (candidate || stepRun && run && stepRun !== run))
|
|
24871
|
+
continue;
|
|
24872
|
+
(pendingWake?.events ?? events).push(event);
|
|
24873
|
+
continue;
|
|
24874
|
+
}
|
|
24875
|
+
if (row.step_type === USER_INPUT)
|
|
24876
|
+
run = stepRun;
|
|
24877
|
+
const number4 = row.step_type === USER_INPUT ? 19 : row.step_type === PLANNER_RESPONSE ? 20 : 24;
|
|
24878
|
+
const body = row.step_type === GENERIC_TOOL ? nested(step, 140) : message2(messageField(step, number4));
|
|
24879
|
+
switch (row.step_type) {
|
|
24880
|
+
case USER_INPUT: {
|
|
24881
|
+
const items = body.flatMap((field3) => field3.number === 3 && field3.wire === 2 ? [textField(message2(field3.value), 1)] : []);
|
|
24882
|
+
const text2 = items.join("") || textField(body, 2) || textField(body, 1);
|
|
24883
|
+
toolCalls.clear();
|
|
24884
|
+
if (text2 && nativeTurnIndex !== void 0)
|
|
24885
|
+
events.push({ type: "user.text", text: text2, nativeTurnIndex });
|
|
24886
|
+
break;
|
|
24887
|
+
}
|
|
24888
|
+
case PLANNER_RESPONSE: {
|
|
24889
|
+
const thought = textField(body, 3);
|
|
24890
|
+
const text2 = textField(body, 1);
|
|
24891
|
+
const calls = body.filter((field3) => field3.number === 7 && field3.wire === 2);
|
|
24892
|
+
if (candidate && candidate.run === stepRun) {
|
|
24893
|
+
const { stepIndex, events: earlierTools, calls: earlierCalls } = candidate;
|
|
24894
|
+
endWake();
|
|
24895
|
+
wake = { eventIndex: events.length, settled: false };
|
|
24896
|
+
events.push({ type: "history.autonomous", stepIndex });
|
|
24897
|
+
for (const event of earlierTools)
|
|
24898
|
+
events.push(event);
|
|
24899
|
+
toolCalls = earlierCalls;
|
|
24900
|
+
}
|
|
24901
|
+
if (stepRun)
|
|
24902
|
+
run = stepRun;
|
|
24903
|
+
finalPlanner = row.status === DONE && !!text2.trim() && calls.length === 0;
|
|
24904
|
+
if (wake)
|
|
24905
|
+
wake.settled = finalPlanner;
|
|
24906
|
+
append("agent.thought", thought);
|
|
24907
|
+
append("agent.text", text2);
|
|
24908
|
+
for (const field3 of body) {
|
|
24909
|
+
if (field3.number !== 7 || field3.wire !== 2)
|
|
24910
|
+
continue;
|
|
24911
|
+
const call = message2(field3.value);
|
|
24912
|
+
const toolCallId = textField(call, 1);
|
|
24913
|
+
const name = textField(call, 2);
|
|
24914
|
+
if (!toolCallId || !name || toolCalls.get(toolCallId) === "settled")
|
|
24915
|
+
continue;
|
|
24916
|
+
toolCalls.set(toolCallId, "pending");
|
|
24917
|
+
events.push({
|
|
24918
|
+
type: "tool.call",
|
|
24919
|
+
toolCallId,
|
|
24920
|
+
name,
|
|
24921
|
+
args: argsValue(textField(call, 3))
|
|
24922
|
+
});
|
|
24923
|
+
}
|
|
24924
|
+
break;
|
|
24925
|
+
}
|
|
24926
|
+
case ERROR_MESSAGE: {
|
|
24927
|
+
if (candidate?.run === stepRun)
|
|
24928
|
+
break;
|
|
24929
|
+
const warning = textField(nested(body, 3), 2);
|
|
24930
|
+
if (warning)
|
|
24931
|
+
append("agent.text", `⚠ ${warning}`);
|
|
24932
|
+
break;
|
|
24933
|
+
}
|
|
24934
|
+
case GENERIC_TOOL: {
|
|
24935
|
+
const call = nested(metadata, 4);
|
|
24936
|
+
const toolCallId = textField(call, 1);
|
|
24937
|
+
if (!toolCallId)
|
|
24938
|
+
break;
|
|
24939
|
+
const pendingWake = candidate?.run === stepRun ? candidate : void 0;
|
|
24940
|
+
const calls = pendingWake?.calls ?? toolCalls;
|
|
24941
|
+
const target2 = pendingWake?.events ?? events;
|
|
24942
|
+
const state = calls.get(toolCallId);
|
|
24943
|
+
if (state === "settled")
|
|
24944
|
+
break;
|
|
24945
|
+
if (state === void 0) {
|
|
24946
|
+
const name = textField(call, 2);
|
|
24947
|
+
if (row.status !== DONE || !name)
|
|
24948
|
+
break;
|
|
24949
|
+
if (!pendingWake && (candidate || stepRun && run && stepRun !== run))
|
|
24950
|
+
break;
|
|
24951
|
+
target2.push({
|
|
24952
|
+
type: "tool.call",
|
|
24953
|
+
toolCallId,
|
|
24954
|
+
name,
|
|
24955
|
+
args: argsValue(textField(call, 3))
|
|
24956
|
+
});
|
|
24957
|
+
}
|
|
24958
|
+
calls.set(toolCallId, "settled");
|
|
24959
|
+
const error51 = nested(step, 31);
|
|
24960
|
+
const output = textField(nested(body, 2), 1) || textField(error51, 3) || textField(error51, 2) || textField(error51, 1);
|
|
24961
|
+
const status = row.status === DONE ? "completed" : row.status === ERROR ? "failed" : "cancelled";
|
|
24962
|
+
target2.push({
|
|
24963
|
+
type: "tool.update",
|
|
24964
|
+
toolCallId,
|
|
24965
|
+
status,
|
|
24966
|
+
...output ? { rawOutput: output } : {}
|
|
24967
|
+
});
|
|
24968
|
+
break;
|
|
24969
|
+
}
|
|
24970
|
+
}
|
|
24971
|
+
}
|
|
24972
|
+
endWake();
|
|
24973
|
+
const wakeWatermark = events.findLast((event) => event.type === "history.autonomous")?.stepIndex ?? -1;
|
|
24974
|
+
return { events, turnCount, wakeWatermark };
|
|
24975
|
+
}
|
|
24976
|
+
|
|
24374
24977
|
// dist/usage-statistics.js
|
|
24375
24978
|
import { lstat, opendir } from "node:fs/promises";
|
|
24376
|
-
import
|
|
24377
|
-
import
|
|
24979
|
+
import os3 from "node:os";
|
|
24980
|
+
import path9 from "node:path";
|
|
24378
24981
|
|
|
24379
24982
|
// ../../harness-adapter/dist/usage-statistics.js
|
|
24380
24983
|
import { createReadStream as createReadStream2 } from "node:fs";
|
|
@@ -24453,10 +25056,10 @@ function count3(value) {
|
|
|
24453
25056
|
return typeof value === "number" && Number.isSafeInteger(value) && value >= 0 ? value : null;
|
|
24454
25057
|
}
|
|
24455
25058
|
function antigravityHome(environment) {
|
|
24456
|
-
return (process.platform === "win32" ? environment.USERPROFILE : environment.HOME) ||
|
|
25059
|
+
return (process.platform === "win32" ? environment.USERPROFILE : environment.HOME) || os3.homedir();
|
|
24457
25060
|
}
|
|
24458
25061
|
function transcriptPath(brainRoot, conversationId) {
|
|
24459
|
-
return
|
|
25062
|
+
return path9.join(brainRoot, conversationId, ".system_generated", "logs", "transcript.jsonl");
|
|
24460
25063
|
}
|
|
24461
25064
|
function isMissing(error51) {
|
|
24462
25065
|
const code = error51?.code;
|
|
@@ -24472,8 +25075,8 @@ async function lstatIfPresent(target2) {
|
|
|
24472
25075
|
}
|
|
24473
25076
|
}
|
|
24474
25077
|
async function transcriptFingerprint(file2) {
|
|
24475
|
-
const logs =
|
|
24476
|
-
for (const directory of [
|
|
25078
|
+
const logs = path9.dirname(file2);
|
|
25079
|
+
for (const directory of [path9.dirname(logs), logs]) {
|
|
24477
25080
|
if (!(await lstatIfPresent(directory))?.isDirectory())
|
|
24478
25081
|
return null;
|
|
24479
25082
|
}
|
|
@@ -24502,7 +25105,7 @@ async function listTranscripts(brainRoot, signal) {
|
|
|
24502
25105
|
return sources;
|
|
24503
25106
|
}
|
|
24504
25107
|
async function readAntigravityUsage(file2, signal) {
|
|
24505
|
-
const sessionId =
|
|
25108
|
+
const sessionId = path9.basename(path9.resolve(file2, "..", "..", ".."));
|
|
24506
25109
|
const requests = /* @__PURE__ */ new Map();
|
|
24507
25110
|
for await (const record4 of jsonlRecords(file2, '"input_tokens"', signal)) {
|
|
24508
25111
|
if (record4.type !== "PLANNER_RESPONSE")
|
|
@@ -24535,21 +25138,21 @@ function createAntigravityUsageStatistics(environment) {
|
|
|
24535
25138
|
return Object.freeze({
|
|
24536
25139
|
async listSources(signal) {
|
|
24537
25140
|
const sources = await listTranscripts(brainRoot, signal);
|
|
24538
|
-
listed = new Map(sources.map(({ id, fingerprint }) => [
|
|
25141
|
+
listed = new Map(sources.map(({ id: id2, fingerprint }) => [id2, fingerprint]));
|
|
24539
25142
|
return sources;
|
|
24540
25143
|
},
|
|
24541
|
-
async readSource(
|
|
24542
|
-
const expected = listed.get(
|
|
25144
|
+
async readSource(id2, signal) {
|
|
25145
|
+
const expected = listed.get(id2);
|
|
24543
25146
|
let entries;
|
|
24544
25147
|
try {
|
|
24545
|
-
entries = await readAntigravityUsage(
|
|
25148
|
+
entries = await readAntigravityUsage(id2, signal);
|
|
24546
25149
|
} catch (error51) {
|
|
24547
25150
|
if (expected !== void 0 && isMissing(error51)) {
|
|
24548
25151
|
throw new HarnessUsageSourceChangedError("Antigravity transcript disappeared before reading; refresh to retry");
|
|
24549
25152
|
}
|
|
24550
25153
|
throw error51;
|
|
24551
25154
|
}
|
|
24552
|
-
if (expected !== void 0 && await transcriptFingerprint(
|
|
25155
|
+
if (expected !== void 0 && await transcriptFingerprint(id2) !== expected) {
|
|
24553
25156
|
throw new HarnessUsageSourceChangedError("Antigravity transcript changed while reading; refresh to retry");
|
|
24554
25157
|
}
|
|
24555
25158
|
return entries;
|
|
@@ -24558,23 +25161,24 @@ function createAntigravityUsageStatistics(environment) {
|
|
|
24558
25161
|
}
|
|
24559
25162
|
|
|
24560
25163
|
// dist/fork.js
|
|
24561
|
-
function
|
|
24562
|
-
return
|
|
25164
|
+
function nativeConversationSummariesDbPath(home = os4.homedir()) {
|
|
25165
|
+
return path10.join(home, ".gemini", "antigravity-cli", "conversation_summaries.db");
|
|
24563
25166
|
}
|
|
24564
|
-
function
|
|
24565
|
-
return
|
|
25167
|
+
function nativeBrainRoot(home = os4.homedir()) {
|
|
25168
|
+
return path10.join(home, ".gemini", "antigravity-cli", "brain");
|
|
24566
25169
|
}
|
|
24567
|
-
function
|
|
24568
|
-
return
|
|
24569
|
-
}
|
|
24570
|
-
function nativeBrainDirPath(id, home = os3.homedir()) {
|
|
24571
|
-
return path9.join(nativeBrainRoot(home), id);
|
|
25170
|
+
function nativeBrainDirPath(id2, home = os4.homedir()) {
|
|
25171
|
+
return path10.join(nativeBrainRoot(home), id2);
|
|
24572
25172
|
}
|
|
24573
25173
|
function validNativeSessionRef(ref, harnessId2) {
|
|
24574
25174
|
return nativeSessionRefSchema.safeParse(ref).success && ref.harnessId === harnessId2 && /^[a-zA-Z0-9][a-zA-Z0-9_-]*$/u.test(ref.nativeSessionId);
|
|
24575
25175
|
}
|
|
24576
|
-
|
|
24577
|
-
|
|
25176
|
+
var ForkBoundaryError = class extends Error {
|
|
25177
|
+
};
|
|
25178
|
+
var ActiveForkUnavailable = class extends Error {
|
|
25179
|
+
};
|
|
25180
|
+
async function cloneNativeConversationDb(sourceId, derivedId, retainedTurnsCountOrHome, homeOption = os4.homedir(), fork) {
|
|
25181
|
+
if (![sourceId, derivedId].every((id2) => /^[a-zA-Z0-9][a-zA-Z0-9_-]*$/u.test(id2)))
|
|
24578
25182
|
throw new Error("Invalid native conversation ID");
|
|
24579
25183
|
const home = typeof retainedTurnsCountOrHome === "string" ? retainedTurnsCountOrHome : homeOption;
|
|
24580
25184
|
const retained = typeof retainedTurnsCountOrHome === "number" ? retainedTurnsCountOrHome : void 0;
|
|
@@ -24582,18 +25186,44 @@ async function cloneNativeConversationDb(sourceId, derivedId, retainedTurnsCount
|
|
|
24582
25186
|
const targetPath2 = nativeConversationDbPath(derivedId, home);
|
|
24583
25187
|
await access2(sourcePath);
|
|
24584
25188
|
const { DatabaseSync, backup } = await import("node:sqlite");
|
|
24585
|
-
const source = new DatabaseSync(sourcePath, { readOnly: true });
|
|
24586
25189
|
let owned = false;
|
|
25190
|
+
let cutoff;
|
|
25191
|
+
const activeTurnIndex = fork?.activeTurnIndex;
|
|
24587
25192
|
try {
|
|
24588
|
-
source
|
|
24589
|
-
|
|
24590
|
-
|
|
24591
|
-
|
|
24592
|
-
|
|
24593
|
-
|
|
24594
|
-
|
|
24595
|
-
|
|
24596
|
-
|
|
25193
|
+
const source = new DatabaseSync(sourcePath, { readOnly: true });
|
|
25194
|
+
try {
|
|
25195
|
+
source.exec("BEGIN");
|
|
25196
|
+
if (activeTurnIndex !== void 0 && source.prepare("PRAGMA journal_mode").get()?.journal_mode !== "wal")
|
|
25197
|
+
throw new ActiveForkUnavailable("Running Antigravity Session has no WAL snapshot; retry when idle");
|
|
25198
|
+
const count4 = Number(source.prepare("SELECT count(*) AS n FROM steps WHERE step_type = 14").get()?.n ?? 0);
|
|
25199
|
+
if (activeTurnIndex !== void 0 && count4 <= activeTurnIndex)
|
|
25200
|
+
throw new ActiveForkUnavailable("The running Antigravity Turn has no committed user input yet; retry shortly");
|
|
25201
|
+
if (retained !== void 0 && (!Number.isSafeInteger(retained) || retained < 0 || retained > count4)) {
|
|
25202
|
+
if (fork)
|
|
25203
|
+
throw new ForkBoundaryError();
|
|
25204
|
+
throw new Error("Invalid retained native Turn count");
|
|
25205
|
+
}
|
|
25206
|
+
if (typeof retainedTurnsCountOrHome === "object") {
|
|
25207
|
+
if ("checkpointId" in retainedTurnsCountOrHome) {
|
|
25208
|
+
const boundaries = derivationBoundaries(source);
|
|
25209
|
+
const index = boundaries.findIndex(({ checkpointId }) => checkpointId === retainedTurnsCountOrHome.checkpointId);
|
|
25210
|
+
if (index < 0)
|
|
25211
|
+
throw new ForkBoundaryError();
|
|
25212
|
+
cutoff = boundaries[index + 1]?.idx;
|
|
25213
|
+
} else
|
|
25214
|
+
cutoff = retainedTurnsCountOrHome.cutoff;
|
|
25215
|
+
} else if (retained !== void 0 && retained < count4) {
|
|
25216
|
+
const boundary = source.prepare("SELECT idx FROM steps WHERE step_type = 14 ORDER BY idx LIMIT 1 OFFSET ?").get(retained);
|
|
25217
|
+
cutoff = retained === 0 ? 0 : Number(boundary?.idx);
|
|
25218
|
+
}
|
|
25219
|
+
await mkdir(path10.dirname(targetPath2), { recursive: true });
|
|
25220
|
+
const reservation = await open(targetPath2, "wx");
|
|
25221
|
+
owned = true;
|
|
25222
|
+
await reservation.close();
|
|
25223
|
+
await backup(source, targetPath2);
|
|
25224
|
+
} finally {
|
|
25225
|
+
source.close();
|
|
25226
|
+
}
|
|
24597
25227
|
const target2 = new DatabaseSync(targetPath2);
|
|
24598
25228
|
try {
|
|
24599
25229
|
target2.exec("BEGIN IMMEDIATE");
|
|
@@ -24603,35 +25233,72 @@ async function cloneNativeConversationDb(sourceId, derivedId, retainedTurnsCount
|
|
|
24603
25233
|
if (!blob)
|
|
24604
25234
|
throw new Error("Invalid native trajectory metadata");
|
|
24605
25235
|
target2.prepare("INSERT OR REPLACE INTO trajectory_metadata_blob (id, data) VALUES ('main', ?)").run(blob);
|
|
24606
|
-
if (
|
|
24607
|
-
const
|
|
24608
|
-
|
|
24609
|
-
|
|
24610
|
-
|
|
24611
|
-
|
|
24612
|
-
|
|
24613
|
-
|
|
24614
|
-
|
|
24615
|
-
|
|
24616
|
-
|
|
24617
|
-
|
|
25236
|
+
if (cutoff !== void 0) {
|
|
25237
|
+
const cutoffIndex = cutoff;
|
|
25238
|
+
target2.prepare("DELETE FROM steps WHERE idx >= ?").run(cutoffIndex);
|
|
25239
|
+
for (const [table, stepFields] of Object.entries({
|
|
25240
|
+
gen_metadata: [],
|
|
25241
|
+
// CortexStepGeneratorMetadata.step_indices (repeated uint32)
|
|
25242
|
+
executor_metadata: [3],
|
|
25243
|
+
// ExecutorMetadata.last_step_idx
|
|
25244
|
+
parent_references: [2],
|
|
25245
|
+
// CortexTrajectoryReference.step_index in the inherited prefix
|
|
25246
|
+
battle_mode_infos: [3, 4]
|
|
25247
|
+
// BattleModeInfo.start_step_index / end_step_index
|
|
25248
|
+
})) {
|
|
25249
|
+
if (!target2.prepare("SELECT name FROM sqlite_master WHERE type = 'table' AND name = ?").get(table))
|
|
25250
|
+
continue;
|
|
25251
|
+
if (cutoffIndex === 0) {
|
|
25252
|
+
target2.exec(`DELETE FROM ${table}`);
|
|
25253
|
+
continue;
|
|
25254
|
+
}
|
|
25255
|
+
const rows = target2.prepare(`SELECT idx, data FROM ${table} ORDER BY idx`);
|
|
25256
|
+
if (table === "gen_metadata") {
|
|
25257
|
+
let last = -1;
|
|
25258
|
+
for (const { idx, data } of rows.iterate()) {
|
|
25259
|
+
const fields = data instanceof Uint8Array && readProtoFields(data);
|
|
25260
|
+
const indices = fields && generatorStepIndices(fields);
|
|
25261
|
+
if (!indices)
|
|
25262
|
+
throw new Error("Invalid native generator metadata");
|
|
25263
|
+
if (indices.some((step) => step >= cutoffIndex))
|
|
25264
|
+
break;
|
|
25265
|
+
if (indices.length > 0)
|
|
25266
|
+
last = Number(idx);
|
|
25267
|
+
}
|
|
25268
|
+
target2.prepare("DELETE FROM gen_metadata WHERE idx > ?").run(last);
|
|
25269
|
+
continue;
|
|
25270
|
+
}
|
|
25271
|
+
const remove = target2.prepare(`DELETE FROM ${table} WHERE idx = ?`);
|
|
25272
|
+
const move = target2.prepare(`UPDATE ${table} SET idx = ? WHERE idx = ?`);
|
|
25273
|
+
let next = 0;
|
|
25274
|
+
for (const { idx, data } of rows.all()) {
|
|
25275
|
+
const fields = data instanceof Uint8Array && readProtoFields(data);
|
|
25276
|
+
if (!fields)
|
|
25277
|
+
throw new Error(`Invalid native ${table}`);
|
|
25278
|
+
const outsidePrefix = fields.some((field3) => stepFields.includes(field3.number) && typeof field3.value === "bigint" && BigInt.asIntN(32, field3.value) >= BigInt(cutoffIndex));
|
|
25279
|
+
if (outsidePrefix)
|
|
25280
|
+
remove.run(Number(idx));
|
|
25281
|
+
else {
|
|
25282
|
+
if (idx !== next)
|
|
25283
|
+
move.run(next, Number(idx));
|
|
25284
|
+
next++;
|
|
25285
|
+
}
|
|
25286
|
+
}
|
|
24618
25287
|
}
|
|
24619
25288
|
}
|
|
24620
25289
|
target2.exec("COMMIT");
|
|
24621
25290
|
} finally {
|
|
24622
25291
|
target2.close();
|
|
24623
25292
|
}
|
|
24624
|
-
await registerDerivedSummary(sourceId, derivedId, home);
|
|
25293
|
+
await registerDerivedSummary(sourceId, derivedId, home, activeTurnIndex !== void 0);
|
|
24625
25294
|
return true;
|
|
24626
25295
|
} catch (error51) {
|
|
24627
25296
|
if (owned)
|
|
24628
25297
|
await removeDerivedDb(derivedId, home);
|
|
24629
25298
|
throw error51;
|
|
24630
|
-
} finally {
|
|
24631
|
-
source.close();
|
|
24632
25299
|
}
|
|
24633
25300
|
}
|
|
24634
|
-
async function registerDerivedSummary(sourceId, derivedId, home) {
|
|
25301
|
+
async function registerDerivedSummary(sourceId, derivedId, home, liveFork) {
|
|
24635
25302
|
const summaryPath = nativeConversationSummariesDbPath(home);
|
|
24636
25303
|
try {
|
|
24637
25304
|
await access2(summaryPath);
|
|
@@ -24646,17 +25313,24 @@ async function registerDerivedSummary(sourceId, derivedId, home) {
|
|
|
24646
25313
|
const template = summaries.prepare("SELECT * FROM conversation_summaries WHERE conversation_id = ?").get(sourceId);
|
|
24647
25314
|
if (!template)
|
|
24648
25315
|
return;
|
|
25316
|
+
if (liveFork && "parent_conversation_id" in template && summaries.prepare(`SELECT 1 FROM conversation_summaries
|
|
25317
|
+
WHERE parent_conversation_id = ? AND status IS NOT 'CASCADE_RUN_STATUS_IDLE' LIMIT 1`).get(sourceId))
|
|
25318
|
+
throw new ActiveForkUnavailable("A native Subagent is not idle; retry after it settles");
|
|
24649
25319
|
const derived = new DatabaseSync(nativeConversationDbPath(derivedId, home), { readOnly: true });
|
|
24650
25320
|
let row;
|
|
24651
25321
|
try {
|
|
24652
25322
|
const metadata = derived.prepare("SELECT data FROM trajectory_metadata_blob WHERE id = 'main'").get()?.data;
|
|
24653
25323
|
const trajectoryId = derived.prepare("SELECT trajectory_id FROM trajectory_meta LIMIT 1").get()?.trajectory_id;
|
|
25324
|
+
const lastInput = derived.prepare(`SELECT idx${"last_user_input_time" in template ? ", metadata" : ""}
|
|
25325
|
+
FROM steps WHERE step_type = 14 ORDER BY idx DESC LIMIT 1`).get();
|
|
25326
|
+
const lastInputMs = nativeStepCreatedAtMs(lastInput?.metadata);
|
|
24654
25327
|
row = {
|
|
24655
25328
|
...template,
|
|
24656
25329
|
conversation_id: derivedId,
|
|
24657
25330
|
status: "CASCADE_RUN_STATUS_IDLE",
|
|
24658
25331
|
step_count: Number(derived.prepare("SELECT count(*) AS n FROM steps").get()?.n),
|
|
24659
|
-
last_user_input_step_index:
|
|
25332
|
+
last_user_input_step_index: lastInput?.idx ?? -1,
|
|
25333
|
+
last_user_input_time: lastInputMs === void 0 ? "0001-01-01T00:00:00Z" : new Date(lastInputMs).toISOString(),
|
|
24660
25334
|
not_fully_idle: 0,
|
|
24661
25335
|
killed: 0,
|
|
24662
25336
|
last_modified_time: (/* @__PURE__ */ new Date()).toISOString(),
|
|
@@ -24671,7 +25345,7 @@ async function registerDerivedSummary(sourceId, derivedId, home) {
|
|
|
24671
25345
|
summaries.close();
|
|
24672
25346
|
}
|
|
24673
25347
|
}
|
|
24674
|
-
async function removeDerivedSummary(
|
|
25348
|
+
async function removeDerivedSummary(id2, home) {
|
|
24675
25349
|
try {
|
|
24676
25350
|
await access2(nativeConversationSummariesDbPath(home));
|
|
24677
25351
|
} catch (error51) {
|
|
@@ -24682,16 +25356,16 @@ async function removeDerivedSummary(id, home) {
|
|
|
24682
25356
|
const { DatabaseSync } = await import("node:sqlite");
|
|
24683
25357
|
const db = new DatabaseSync(nativeConversationSummariesDbPath(home));
|
|
24684
25358
|
try {
|
|
24685
|
-
db.prepare("DELETE FROM conversation_summaries WHERE conversation_id = ?").run(
|
|
25359
|
+
db.prepare("DELETE FROM conversation_summaries WHERE conversation_id = ?").run(id2);
|
|
24686
25360
|
} finally {
|
|
24687
25361
|
db.close();
|
|
24688
25362
|
}
|
|
24689
25363
|
}
|
|
24690
|
-
async function removeDerivedDb(
|
|
24691
|
-
const file2 = nativeConversationDbPath(
|
|
25364
|
+
async function removeDerivedDb(id2, home) {
|
|
25365
|
+
const file2 = nativeConversationDbPath(id2, home);
|
|
24692
25366
|
await Promise.all([file2, `${file2}-wal`, `${file2}-shm`].map((target2) => rm2(target2, { force: true })));
|
|
24693
25367
|
}
|
|
24694
|
-
async function copyNativeBrainDirIfExists(sourceId, derivedId, home =
|
|
25368
|
+
async function copyNativeBrainDirIfExists(sourceId, derivedId, home = os4.homedir()) {
|
|
24695
25369
|
try {
|
|
24696
25370
|
await access2(nativeBrainDirPath(sourceId, home));
|
|
24697
25371
|
} catch (error51) {
|
|
@@ -24703,19 +25377,20 @@ async function copyNativeBrainDirIfExists(sourceId, derivedId, home = os3.homedi
|
|
|
24703
25377
|
recursive: true,
|
|
24704
25378
|
errorOnExist: true,
|
|
24705
25379
|
force: false,
|
|
24706
|
-
filter: (source) =>
|
|
25380
|
+
filter: (source) => path10.basename(source) !== ".system_generated"
|
|
24707
25381
|
});
|
|
24708
25382
|
return true;
|
|
24709
25383
|
}
|
|
24710
|
-
async function openDerivedAntigravitySession(options, input, sourceRef, retained) {
|
|
25384
|
+
async function openDerivedAntigravitySession(options, input, sourceRef, retained, fork) {
|
|
24711
25385
|
const environment = { ...options.adapterEnvironment, ...input.environment };
|
|
24712
25386
|
const home = antigravityHome(environment);
|
|
24713
25387
|
const derivedId = randomUUID();
|
|
24714
25388
|
let cloned = false;
|
|
24715
25389
|
try {
|
|
24716
|
-
await cloneNativeConversationDb(sourceRef.nativeSessionId, derivedId, retained, home);
|
|
25390
|
+
await cloneNativeConversationDb(sourceRef.nativeSessionId, derivedId, retained, home, fork);
|
|
24717
25391
|
cloned = true;
|
|
24718
|
-
|
|
25392
|
+
if (fork?.activeTurnIndex === void 0)
|
|
25393
|
+
await copyNativeBrainDirIfExists(sourceRef.nativeSessionId, derivedId, home);
|
|
24719
25394
|
const result = await options.openSession({
|
|
24720
25395
|
...input,
|
|
24721
25396
|
environment,
|
|
@@ -24726,6 +25401,10 @@ async function openDerivedAntigravitySession(options, input, sourceRef, retained
|
|
|
24726
25401
|
const cleanupFailure = await cleanup().then(() => void 0, () => "Derived native history cleanup failed");
|
|
24727
25402
|
return cleanupFailure ? { ok: false, error: { ...result.error, diagnostic: cleanupFailure } } : result;
|
|
24728
25403
|
} catch (error51) {
|
|
25404
|
+
if (error51 instanceof ForkBoundaryError)
|
|
25405
|
+
return checkpointError();
|
|
25406
|
+
if (error51 instanceof ActiveForkUnavailable)
|
|
25407
|
+
return activeForkError(error51.message);
|
|
24729
25408
|
const cleanupFailure = await cleanup().then(() => void 0, () => "Derived native history cleanup failed");
|
|
24730
25409
|
return {
|
|
24731
25410
|
ok: false,
|
|
@@ -24759,32 +25438,54 @@ async function forkAntigravitySession(options) {
|
|
|
24759
25438
|
const checkpoint = nativeCheckpointRefSchema.safeParse(input.checkpoint);
|
|
24760
25439
|
if (!checkpoint.success || checkpoint.data.harnessId !== harnessId2 || checkpoint.data.nativeSessionId !== input.sourceRef.nativeSessionId)
|
|
24761
25440
|
return checkpointError();
|
|
24762
|
-
|
|
24763
|
-
|
|
24764
|
-
ok: false,
|
|
24765
|
-
error: {
|
|
24766
|
-
code: "sessionBusy",
|
|
24767
|
-
message: "Source Session is busy",
|
|
24768
|
-
retryable: true
|
|
24769
|
-
}
|
|
24770
|
-
};
|
|
24771
|
-
const match = /^turn-(0|[1-9]\d*)$/u.exec(checkpoint.data.checkpointId);
|
|
25441
|
+
const checkpointId = checkpoint.data.checkpointId;
|
|
25442
|
+
const match = /^(turn|wake)-(0|[1-9]\d*)$/u.exec(checkpointId);
|
|
24772
25443
|
if (!match)
|
|
24773
25444
|
return checkpointError();
|
|
25445
|
+
const index = Number(match[2]);
|
|
25446
|
+
if (!Number.isSafeInteger(index + 1))
|
|
25447
|
+
return checkpointError();
|
|
25448
|
+
let activeTurnIndex;
|
|
25449
|
+
if (options.sourceSession?.isActive) {
|
|
25450
|
+
activeTurnIndex = options.sourceSession.activeForkTurnIndex?.(checkpointId, antigravityHome({ ...options.adapterEnvironment, ...input.environment }));
|
|
25451
|
+
if (match[1] !== "turn" || activeTurnIndex === void 0 || index >= activeTurnIndex)
|
|
25452
|
+
return activeForkError("Fork requires a confirmed completed Turn before the running Antigravity Turn and no active Subagents; retry when idle");
|
|
25453
|
+
}
|
|
25454
|
+
return openDerivedAntigravitySession(options, {
|
|
25455
|
+
kind: "resume",
|
|
25456
|
+
nativeRef: input.sourceRef,
|
|
25457
|
+
cwd: input.cwd,
|
|
25458
|
+
...input.environment ? { environment: input.environment } : {}
|
|
25459
|
+
}, input.sourceRef, { checkpointId }, activeTurnIndex === void 0 ? {} : { activeTurnIndex });
|
|
25460
|
+
}
|
|
25461
|
+
function activeForkError(message3) {
|
|
25462
|
+
return { ok: false, error: { code: "sessionBusy", message: message3, retryable: true } };
|
|
25463
|
+
}
|
|
25464
|
+
async function readDerivationBoundaries(dbPath) {
|
|
25465
|
+
await access2(dbPath);
|
|
25466
|
+
const { DatabaseSync } = await import("node:sqlite");
|
|
25467
|
+
const db = new DatabaseSync(dbPath, { readOnly: true });
|
|
24774
25468
|
try {
|
|
24775
|
-
|
|
24776
|
-
|
|
24777
|
-
|
|
24778
|
-
|
|
24779
|
-
|
|
24780
|
-
|
|
24781
|
-
|
|
24782
|
-
|
|
24783
|
-
|
|
24784
|
-
|
|
24785
|
-
|
|
24786
|
-
|
|
25469
|
+
db.exec("BEGIN");
|
|
25470
|
+
return derivationBoundaries(db);
|
|
25471
|
+
} finally {
|
|
25472
|
+
db.close();
|
|
25473
|
+
}
|
|
25474
|
+
}
|
|
25475
|
+
function derivationBoundaries(db) {
|
|
25476
|
+
const users = db.prepare("SELECT idx FROM steps WHERE step_type = 14 ORDER BY idx").all();
|
|
25477
|
+
const boundaries = users.map((row, index) => ({
|
|
25478
|
+
idx: Number(row.idx),
|
|
25479
|
+
checkpointId: `turn-${index}`
|
|
25480
|
+
}));
|
|
25481
|
+
if (db.prepare("SELECT 1 FROM steps WHERE step_type = 101 LIMIT 1").get()) {
|
|
25482
|
+
for (const event of decodeNativeHistory(db).events) {
|
|
25483
|
+
if (event.type === "history.autonomous")
|
|
25484
|
+
boundaries.push({ idx: event.stepIndex, checkpointId: `wake-${event.stepIndex}` });
|
|
25485
|
+
}
|
|
25486
|
+
boundaries.sort((a, b) => a.idx - b.idx);
|
|
24787
25487
|
}
|
|
25488
|
+
return boundaries;
|
|
24788
25489
|
}
|
|
24789
25490
|
function checkpointError() {
|
|
24790
25491
|
return {
|
|
@@ -24810,16 +25511,16 @@ function listedModel(line) {
|
|
|
24810
25511
|
const separator = line.indexOf(" ");
|
|
24811
25512
|
if (separator <= 0)
|
|
24812
25513
|
return null;
|
|
24813
|
-
const
|
|
25514
|
+
const id2 = line.slice(0, separator).trim();
|
|
24814
25515
|
const label = line.slice(separator + 1).trim();
|
|
24815
|
-
if (!
|
|
25516
|
+
if (!id2 || !label)
|
|
24816
25517
|
return null;
|
|
24817
|
-
const match = EFFORT_SUFFIX_PATTERN.exec(
|
|
25518
|
+
const match = EFFORT_SUFFIX_PATTERN.exec(id2);
|
|
24818
25519
|
if (!match?.groups) {
|
|
24819
|
-
return { rawId:
|
|
25520
|
+
return { rawId: id2, rawLabel: label, baseId: id2, baseLabel: label, effort: null };
|
|
24820
25521
|
}
|
|
24821
25522
|
return {
|
|
24822
|
-
rawId:
|
|
25523
|
+
rawId: id2,
|
|
24823
25524
|
rawLabel: label,
|
|
24824
25525
|
baseId: match.groups.base,
|
|
24825
25526
|
baseLabel: label.replace(EFFORT_LABEL_SUFFIX_PATTERN, "").trim() || label,
|
|
@@ -24850,7 +25551,7 @@ function parseAntigravityModels(output) {
|
|
|
24850
25551
|
}
|
|
24851
25552
|
const models = [];
|
|
24852
25553
|
const thinkingOptions = /* @__PURE__ */ new Map();
|
|
24853
|
-
for (const [
|
|
25554
|
+
for (const [id2, { label, efforts, rows }] of grouped) {
|
|
24854
25555
|
const soleRow = rows.length === 1 ? rows[0] : void 0;
|
|
24855
25556
|
if (soleRow?.effort && harnessModelRefSchema.safeParse({ id: soleRow.rawId }).success) {
|
|
24856
25557
|
models.push({
|
|
@@ -24868,7 +25569,7 @@ function parseAntigravityModels(output) {
|
|
|
24868
25569
|
thinkingOptions.set(effort, { id: effort, label: EFFORT_LABELS.get(effort) });
|
|
24869
25570
|
}
|
|
24870
25571
|
models.push({
|
|
24871
|
-
ref: harnessModelRefSchema.parse({ id }),
|
|
25572
|
+
ref: harnessModelRefSchema.parse({ id: id2 }),
|
|
24872
25573
|
label,
|
|
24873
25574
|
resolvedModelLabel: label,
|
|
24874
25575
|
...ordered.length > 0 ? { supportedThinkingOptionIds: ordered } : {}
|
|
@@ -24894,15 +25595,15 @@ function antigravityAvailableThinkingOptions(catalog, model2) {
|
|
|
24894
25595
|
const supported = catalog.models.find(({ ref }) => ref.id === model2.id)?.supportedThinkingOptionIds;
|
|
24895
25596
|
if (!supported)
|
|
24896
25597
|
return void 0;
|
|
24897
|
-
const options = supported.flatMap((
|
|
24898
|
-
const option = catalog.thinkingOptions.find((candidate) => candidate.id ===
|
|
25598
|
+
const options = supported.flatMap((id2) => {
|
|
25599
|
+
const option = catalog.thinkingOptions.find((candidate) => candidate.id === id2);
|
|
24899
25600
|
return option ? [option] : [];
|
|
24900
25601
|
});
|
|
24901
25602
|
return options.length > 0 ? options : void 0;
|
|
24902
25603
|
}
|
|
24903
25604
|
function parseAntigravityAcpModelCatalog(availableModels, configOptions = []) {
|
|
24904
|
-
const modelOption = configOptions.find(({ id }) =>
|
|
24905
|
-
const thoughtOption = configOptions.find(({ id }) =>
|
|
25605
|
+
const modelOption = configOptions.find(({ id: id2 }) => id2 === "model");
|
|
25606
|
+
const thoughtOption = configOptions.find(({ id: id2 }) => id2 === "thought_level");
|
|
24906
25607
|
const thinkingOptions = (thoughtOption?.options ?? []).map(({ value, name }) => ({
|
|
24907
25608
|
id: harnessThinkingOptionIdSchema.parse(value),
|
|
24908
25609
|
label: name
|
|
@@ -24917,23 +25618,23 @@ function parseAntigravityAcpModelCatalog(availableModels, configOptions = []) {
|
|
|
24917
25618
|
ref: { id: modelId2 },
|
|
24918
25619
|
label: name,
|
|
24919
25620
|
resolvedModelLabel: name,
|
|
24920
|
-
...modelId2 === currentModelId && thinkingOptions.length > 0 ? { supportedThinkingOptionIds: thinkingOptions.map(({ id }) =>
|
|
25621
|
+
...modelId2 === currentModelId && thinkingOptions.length > 0 ? { supportedThinkingOptionIds: thinkingOptions.map(({ id: id2 }) => id2) } : {}
|
|
24921
25622
|
})),
|
|
24922
25623
|
defaultModel: { id: currentModelId },
|
|
24923
25624
|
thinkingOptions,
|
|
24924
|
-
...thoughtOption && thinkingOptions.some(({ id }) =>
|
|
25625
|
+
...thoughtOption && thinkingOptions.some(({ id: id2 }) => id2 === thoughtOption.currentValue) ? { defaultThinkingOptionId: thoughtOption.currentValue } : {}
|
|
24925
25626
|
});
|
|
24926
25627
|
}
|
|
24927
25628
|
function readAcpEffectiveModelState(configOptions, catalog) {
|
|
24928
|
-
const model2 = configOptions?.find(({ id }) =>
|
|
24929
|
-
const thought = configOptions?.find(({ id }) =>
|
|
25629
|
+
const model2 = configOptions?.find(({ id: id2 }) => id2 === "model");
|
|
25630
|
+
const thought = configOptions?.find(({ id: id2 }) => id2 === "thought_level");
|
|
24930
25631
|
const effectiveModel = model2 ? harnessModelRefSchema.parse({ id: model2.currentValue }) : void 0;
|
|
24931
25632
|
const resolvedModelLabel = model2?.options.find(({ value }) => value === model2.currentValue)?.name ?? catalog?.models.find(({ ref }) => ref.id === effectiveModel?.id)?.resolvedModelLabel;
|
|
24932
25633
|
const availableThinkingOptions = thought ? thought.options.map(({ value, name }) => ({
|
|
24933
25634
|
id: harnessThinkingOptionIdSchema.parse(value),
|
|
24934
25635
|
label: name
|
|
24935
25636
|
})) : configOptions !== void 0 ? [] : antigravityAvailableThinkingOptions(catalog, effectiveModel);
|
|
24936
|
-
const effectiveThinkingOptionId = thought && availableThinkingOptions?.some(({ id }) =>
|
|
25637
|
+
const effectiveThinkingOptionId = thought && availableThinkingOptions?.some(({ id: id2 }) => id2 === thought.currentValue) ? harnessThinkingOptionIdSchema.parse(thought.currentValue) : void 0;
|
|
24937
25638
|
return {
|
|
24938
25639
|
...effectiveModel ? { effectiveModel } : {},
|
|
24939
25640
|
...resolvedModelLabel ? { resolvedModelLabel } : {},
|
|
@@ -24953,127 +25654,86 @@ function splitAntigravityModelAndEffort(rawModelId) {
|
|
|
24953
25654
|
return { modelRef: harnessModelRefSchema.parse({ id: rawModelId.trim() }) };
|
|
24954
25655
|
}
|
|
24955
25656
|
|
|
24956
|
-
// dist/
|
|
24957
|
-
var
|
|
24958
|
-
var
|
|
24959
|
-
var
|
|
24960
|
-
|
|
24961
|
-
|
|
24962
|
-
|
|
24963
|
-
|
|
24964
|
-
|
|
24965
|
-
|
|
24966
|
-
|
|
24967
|
-
|
|
24968
|
-
|
|
24969
|
-
}
|
|
24970
|
-
function messageField(fields, number4) {
|
|
24971
|
-
const field3 = fields.find((entry) => entry.number === number4 && entry.wire === 2);
|
|
24972
|
-
return field3?.value instanceof Uint8Array ? field3.value : void 0;
|
|
24973
|
-
}
|
|
24974
|
-
function nested(fields, number4) {
|
|
24975
|
-
const payload = messageField(fields, number4);
|
|
24976
|
-
return payload ? message2(payload) : [];
|
|
24977
|
-
}
|
|
24978
|
-
function textField(fields, number4) {
|
|
24979
|
-
const bytes = messageField(fields, number4);
|
|
24980
|
-
return bytes ? Buffer.from(bytes).toString("utf8") : "";
|
|
24981
|
-
}
|
|
24982
|
-
function argsValue(raw) {
|
|
24983
|
-
if (!raw)
|
|
24984
|
-
return void 0;
|
|
24985
|
-
try {
|
|
24986
|
-
return JSON.parse(raw);
|
|
24987
|
-
} catch {
|
|
24988
|
-
return raw;
|
|
25657
|
+
// dist/wake-observer.js
|
|
25658
|
+
var COMMIT_POLL_MS = 100;
|
|
25659
|
+
var COMMIT_WAIT_MS = 1e4;
|
|
25660
|
+
var AntigravityWakeObserver = class {
|
|
25661
|
+
options;
|
|
25662
|
+
#cursor;
|
|
25663
|
+
#deadline = 0;
|
|
25664
|
+
#work;
|
|
25665
|
+
#timer;
|
|
25666
|
+
#closed = false;
|
|
25667
|
+
constructor(options) {
|
|
25668
|
+
this.options = options;
|
|
25669
|
+
this.#cursor = options.cursor;
|
|
24989
25670
|
}
|
|
24990
|
-
|
|
24991
|
-
|
|
24992
|
-
|
|
24993
|
-
|
|
24994
|
-
|
|
24995
|
-
|
|
24996
|
-
|
|
24997
|
-
|
|
24998
|
-
|
|
24999
|
-
|
|
25000
|
-
|
|
25001
|
-
|
|
25002
|
-
|
|
25003
|
-
|
|
25004
|
-
|
|
25005
|
-
|
|
25006
|
-
|
|
25007
|
-
|
|
25008
|
-
|
|
25009
|
-
|
|
25010
|
-
|
|
25011
|
-
|
|
25012
|
-
|
|
25013
|
-
|
|
25014
|
-
|
|
25015
|
-
|
|
25016
|
-
|
|
25017
|
-
const
|
|
25018
|
-
const
|
|
25019
|
-
|
|
25020
|
-
|
|
25021
|
-
|
|
25022
|
-
|
|
25023
|
-
|
|
25024
|
-
|
|
25025
|
-
|
|
25026
|
-
|
|
25027
|
-
}
|
|
25028
|
-
|
|
25029
|
-
|
|
25030
|
-
|
|
25031
|
-
|
|
25032
|
-
|
|
25033
|
-
|
|
25034
|
-
|
|
25035
|
-
|
|
25036
|
-
|
|
25037
|
-
|
|
25038
|
-
|
|
25039
|
-
|
|
25040
|
-
|
|
25041
|
-
|
|
25042
|
-
|
|
25043
|
-
|
|
25044
|
-
|
|
25045
|
-
|
|
25046
|
-
|
|
25047
|
-
break;
|
|
25048
|
-
}
|
|
25049
|
-
case ERROR_MESSAGE: {
|
|
25050
|
-
const warning = textField(nested(body, 3), 2);
|
|
25051
|
-
if (warning)
|
|
25052
|
-
append("agent.text", `⚠ ${warning}`);
|
|
25053
|
-
break;
|
|
25054
|
-
}
|
|
25055
|
-
case GENERIC_TOOL: {
|
|
25056
|
-
const toolCallId = textField(nested(nested(step, 5), 4), 1);
|
|
25057
|
-
if (!pendingCalls.delete(toolCallId))
|
|
25058
|
-
break;
|
|
25059
|
-
const error51 = nested(step, 31);
|
|
25060
|
-
const output = textField(nested(body, 2), 1) || textField(error51, 3) || textField(error51, 2) || textField(error51, 1);
|
|
25061
|
-
const status = row.status === DONE ? "completed" : row.status === ERROR ? "failed" : "cancelled";
|
|
25062
|
-
events.push({
|
|
25063
|
-
type: "tool.update",
|
|
25064
|
-
toolCallId,
|
|
25065
|
-
status,
|
|
25066
|
-
...output ? { rawOutput: output } : {}
|
|
25067
|
-
});
|
|
25068
|
-
break;
|
|
25069
|
-
}
|
|
25671
|
+
get observing() {
|
|
25672
|
+
return this.#work !== void 0 || this.#timer !== void 0;
|
|
25673
|
+
}
|
|
25674
|
+
observe() {
|
|
25675
|
+
if (this.#closed)
|
|
25676
|
+
return;
|
|
25677
|
+
this.#deadline = Date.now() + COMMIT_WAIT_MS;
|
|
25678
|
+
if (!this.observing)
|
|
25679
|
+
void this.#startRead();
|
|
25680
|
+
}
|
|
25681
|
+
/** Probe once before submitting a successor, without waiting on a pending native wake. */
|
|
25682
|
+
async flush() {
|
|
25683
|
+
if (this.#closed || !this.observing)
|
|
25684
|
+
return;
|
|
25685
|
+
if (this.#work)
|
|
25686
|
+
return this.#work;
|
|
25687
|
+
clearTimeout(this.#timer);
|
|
25688
|
+
this.#timer = void 0;
|
|
25689
|
+
return this.#startRead();
|
|
25690
|
+
}
|
|
25691
|
+
#startRead() {
|
|
25692
|
+
return this.#work = this.#read().finally(() => {
|
|
25693
|
+
this.#work = void 0;
|
|
25694
|
+
});
|
|
25695
|
+
}
|
|
25696
|
+
async #read() {
|
|
25697
|
+
try {
|
|
25698
|
+
const { nativeSessionId, home, cwd, outputLimit } = this.options;
|
|
25699
|
+
const { events, wakeWatermark } = await readNativeHistory(nativeSessionId, home);
|
|
25700
|
+
if (this.#closed || !this.options.canPublish())
|
|
25701
|
+
return;
|
|
25702
|
+
if (wakeWatermark <= this.#cursor)
|
|
25703
|
+
return;
|
|
25704
|
+
const turns = projectReplayedEventsToTurns({
|
|
25705
|
+
nativeSessionId,
|
|
25706
|
+
cwd,
|
|
25707
|
+
events,
|
|
25708
|
+
...outputLimit !== void 0 ? { outputLimit } : {}
|
|
25709
|
+
});
|
|
25710
|
+
for (const turn of turns) {
|
|
25711
|
+
const key = turn.nativeTurnRef.nativeTurnKey;
|
|
25712
|
+
if (!key.startsWith("wake-"))
|
|
25713
|
+
continue;
|
|
25714
|
+
const idx = Number(key.slice(5));
|
|
25715
|
+
if (idx <= this.#cursor)
|
|
25716
|
+
continue;
|
|
25717
|
+
this.options.publish(turn);
|
|
25718
|
+
this.#cursor = idx;
|
|
25719
|
+
}
|
|
25720
|
+
} catch {
|
|
25721
|
+
} finally {
|
|
25722
|
+
if (!this.#closed && Date.now() < this.#deadline) {
|
|
25723
|
+
this.#timer = setTimeout(() => {
|
|
25724
|
+
this.#timer = void 0;
|
|
25725
|
+
void this.#startRead();
|
|
25726
|
+
}, COMMIT_POLL_MS);
|
|
25727
|
+
this.#timer.unref();
|
|
25070
25728
|
}
|
|
25071
25729
|
}
|
|
25072
|
-
return { events, turnCount };
|
|
25073
|
-
} finally {
|
|
25074
|
-
db.close();
|
|
25075
25730
|
}
|
|
25076
|
-
|
|
25731
|
+
close() {
|
|
25732
|
+
this.#closed = true;
|
|
25733
|
+
clearTimeout(this.#timer);
|
|
25734
|
+
this.#timer = void 0;
|
|
25735
|
+
}
|
|
25736
|
+
};
|
|
25077
25737
|
|
|
25078
25738
|
// dist/permission-modes.js
|
|
25079
25739
|
var ANTIGRAVITY_ACP_SESSION_MODES = ["default", "accept-edits", "auto", "plan"];
|
|
@@ -25350,8 +26010,9 @@ async function rollbackAntigravityLastTurn(options) {
|
|
|
25350
26010
|
}
|
|
25351
26011
|
};
|
|
25352
26012
|
try {
|
|
25353
|
-
const
|
|
25354
|
-
|
|
26013
|
+
const boundaries = await readDerivationBoundaries(nativeConversationDbPath(input.sourceRef.nativeSessionId, antigravityHome({ ...options.adapterEnvironment, ...input.environment })));
|
|
26014
|
+
const last = boundaries.at(-1);
|
|
26015
|
+
if (!last)
|
|
25355
26016
|
return {
|
|
25356
26017
|
ok: false,
|
|
25357
26018
|
error: {
|
|
@@ -25368,7 +26029,7 @@ async function rollbackAntigravityLastTurn(options) {
|
|
|
25368
26029
|
...input.model ? { model: input.model } : {},
|
|
25369
26030
|
...input.thinkingOptionId ? { thinkingOptionId: input.thinkingOptionId } : {},
|
|
25370
26031
|
...input.permissionModeId ? { permissionModeId: input.permissionModeId } : {}
|
|
25371
|
-
}, input.sourceRef,
|
|
26032
|
+
}, input.sourceRef, { cutoff: boundaries.length === 1 ? 0 : last.idx });
|
|
25372
26033
|
} catch (error51) {
|
|
25373
26034
|
return { ok: false, error: nativeHistoryError(error51) };
|
|
25374
26035
|
}
|
|
@@ -25377,7 +26038,7 @@ async function rollbackAntigravityLastTurn(options) {
|
|
|
25377
26038
|
// dist/session-import.js
|
|
25378
26039
|
import { constants, createReadStream as createReadStream3 } from "node:fs";
|
|
25379
26040
|
import { access as access3, stat } from "node:fs/promises";
|
|
25380
|
-
import
|
|
26041
|
+
import path11 from "node:path";
|
|
25381
26042
|
import { createInterface as createInterface3 } from "node:readline";
|
|
25382
26043
|
import { fileURLToPath } from "node:url";
|
|
25383
26044
|
|
|
@@ -25517,9 +26178,9 @@ function workspacePaths(raw) {
|
|
|
25517
26178
|
continue;
|
|
25518
26179
|
cwd = fileURLToPath(url2);
|
|
25519
26180
|
}
|
|
25520
|
-
if (!
|
|
26181
|
+
if (!path11.isAbsolute(cwd))
|
|
25521
26182
|
continue;
|
|
25522
|
-
cwd =
|
|
26183
|
+
cwd = path11.resolve(cwd);
|
|
25523
26184
|
const normalized = `${cwd.replaceAll("\\", "/")}/`;
|
|
25524
26185
|
if (normalized.includes("/.codexhost/antigravity-history/hooks/"))
|
|
25525
26186
|
continue;
|
|
@@ -25612,11 +26273,11 @@ var AntigravitySessionImport = class {
|
|
|
25612
26273
|
}
|
|
25613
26274
|
async #source(row, signal) {
|
|
25614
26275
|
signal.throwIfAborted();
|
|
25615
|
-
const
|
|
25616
|
-
if (typeof
|
|
26276
|
+
const id2 = row.conversation_id;
|
|
26277
|
+
if (typeof id2 !== "string" || !SESSION_ID.test(id2) || typeof row.parent_conversation_id === "string" && row.parent_conversation_id.length > 0 || typeof row.step_count !== "number" || !Number.isSafeInteger(row.step_count) || row.step_count <= 0 || row.killed !== void 0 && row.killed !== null && row.killed !== 0) {
|
|
25617
26278
|
return null;
|
|
25618
26279
|
}
|
|
25619
|
-
const file2 = nativeConversationDbPath(
|
|
26280
|
+
const file2 = nativeConversationDbPath(id2, this.#home);
|
|
25620
26281
|
try {
|
|
25621
26282
|
return await readStableFiles([file2], async ([info]) => {
|
|
25622
26283
|
if (!info?.isFile())
|
|
@@ -25631,10 +26292,10 @@ var AntigravitySessionImport = class {
|
|
|
25631
26292
|
}
|
|
25632
26293
|
if (!cwd)
|
|
25633
26294
|
return null;
|
|
25634
|
-
const title = sessionImportTitle(row.title) ?? sessionImportTitle(row.preview) ?? await firstUserTitle(
|
|
26295
|
+
const title = sessionImportTitle(row.title) ?? sessionImportTitle(row.preview) ?? await firstUserTitle(path11.join(nativeBrainDirPath(id2, this.#home), ".system_generated", "logs", "transcript.jsonl"), signal);
|
|
25635
26296
|
signal.throwIfAborted();
|
|
25636
26297
|
const candidate = sessionImportCandidate({
|
|
25637
|
-
nativeSessionId:
|
|
26298
|
+
nativeSessionId: id2,
|
|
25638
26299
|
cwd,
|
|
25639
26300
|
title,
|
|
25640
26301
|
updatedAt: row.last_modified_time,
|
|
@@ -25644,7 +26305,7 @@ var AntigravitySessionImport = class {
|
|
|
25644
26305
|
candidate,
|
|
25645
26306
|
nativeRef: nativeSessionRefSchema.parse({
|
|
25646
26307
|
harnessId: "antigravity",
|
|
25647
|
-
nativeSessionId:
|
|
26308
|
+
nativeSessionId: id2,
|
|
25648
26309
|
formatVersion: 1
|
|
25649
26310
|
})
|
|
25650
26311
|
} : null;
|
|
@@ -25660,7 +26321,7 @@ var AntigravitySessionImport = class {
|
|
|
25660
26321
|
|
|
25661
26322
|
// dist/subagent-transcript.js
|
|
25662
26323
|
import { open as open2, realpath } from "node:fs/promises";
|
|
25663
|
-
import
|
|
26324
|
+
import path12 from "node:path";
|
|
25664
26325
|
var nativeSubagentIdSchema = external_exports.uuid();
|
|
25665
26326
|
var MAX_TRANSCRIPT_BYTES = 8 * 1024 * 1024;
|
|
25666
26327
|
var transcriptStepSchema = external_exports.object({
|
|
@@ -25791,10 +26452,10 @@ async function readSubagentTranscript(input) {
|
|
|
25791
26452
|
};
|
|
25792
26453
|
}
|
|
25793
26454
|
try {
|
|
25794
|
-
const file2 =
|
|
25795
|
-
const brainRoot = await realpath(
|
|
26455
|
+
const file2 = path12.join(nativeBrainDirPath(input.childId, input.home), ".system_generated", "logs", "transcript.jsonl");
|
|
26456
|
+
const brainRoot = await realpath(path12.dirname(nativeBrainDirPath(input.childId, input.home)));
|
|
25796
26457
|
const resolved = await realpath(file2);
|
|
25797
|
-
const expected =
|
|
26458
|
+
const expected = path12.join(brainRoot, input.childId, ".system_generated", "logs", "transcript.jsonl");
|
|
25798
26459
|
const normalize = (value) => process.platform === "win32" ? value.toLowerCase() : value;
|
|
25799
26460
|
if (normalize(resolved) !== normalize(expected))
|
|
25800
26461
|
throw new Error("Subagent log redirects outside its native location");
|
|
@@ -25865,24 +26526,24 @@ var AntigravitySubagents = class {
|
|
|
25865
26526
|
get running() {
|
|
25866
26527
|
return [...this.#states.values()].some((state) => state.status === "running" || state.status === "pending");
|
|
25867
26528
|
}
|
|
25868
|
-
state(
|
|
25869
|
-
return this.#states.get(
|
|
26529
|
+
state(id2) {
|
|
26530
|
+
return this.#states.get(id2);
|
|
25870
26531
|
}
|
|
25871
|
-
track(
|
|
25872
|
-
if (this.#stopped || !nativeSubagentIdSchema.safeParse(
|
|
26532
|
+
track(id2, snapshot) {
|
|
26533
|
+
if (this.#stopped || !nativeSubagentIdSchema.safeParse(id2).success)
|
|
25873
26534
|
return;
|
|
25874
26535
|
const item = snapshot.item;
|
|
25875
|
-
const child = item.type === "subagentDelegation" ? item.subagents.find((state) => state.nativeSubagentId ===
|
|
25876
|
-
this.#states.set(
|
|
25877
|
-
subagentId:
|
|
25878
|
-
nativeSubagentId:
|
|
26536
|
+
const child = item.type === "subagentDelegation" ? item.subagents.find((state) => state.nativeSubagentId === id2) : void 0;
|
|
26537
|
+
this.#states.set(id2, {
|
|
26538
|
+
subagentId: id2,
|
|
26539
|
+
nativeSubagentId: id2,
|
|
25879
26540
|
description: "Antigravity Subagent",
|
|
25880
26541
|
background: true,
|
|
25881
|
-
...this.#states.get(
|
|
26542
|
+
...this.#states.get(id2),
|
|
25882
26543
|
...child,
|
|
25883
26544
|
status: "running"
|
|
25884
26545
|
});
|
|
25885
|
-
this.#unavailableSince.delete(
|
|
26546
|
+
this.#unavailableSince.delete(id2);
|
|
25886
26547
|
if (!this.#timer) {
|
|
25887
26548
|
this.#timer = setInterval(() => {
|
|
25888
26549
|
void this.refresh();
|
|
@@ -25902,21 +26563,21 @@ var AntigravitySubagents = class {
|
|
|
25902
26563
|
}
|
|
25903
26564
|
});
|
|
25904
26565
|
}
|
|
25905
|
-
#publish(
|
|
25906
|
-
this.#states.set(
|
|
26566
|
+
#publish(id2, state) {
|
|
26567
|
+
this.#states.set(id2, state);
|
|
25907
26568
|
this.options.emit({
|
|
25908
26569
|
type: "subagent.state.changed",
|
|
25909
|
-
nativeSubagentId:
|
|
26570
|
+
nativeSubagentId: id2,
|
|
25910
26571
|
status: state.status,
|
|
25911
26572
|
...state.resultSummary ? { resultSummary: state.resultSummary } : {}
|
|
25912
26573
|
});
|
|
25913
26574
|
}
|
|
25914
|
-
#expireUnavailable(
|
|
25915
|
-
const since = this.#unavailableSince.get(
|
|
25916
|
-
this.#unavailableSince.set(
|
|
26575
|
+
#expireUnavailable(id2, previous) {
|
|
26576
|
+
const since = this.#unavailableSince.get(id2) ?? Date.now();
|
|
26577
|
+
this.#unavailableSince.set(id2, since);
|
|
25917
26578
|
if (Date.now() - since < (this.options.observationTimeoutMs ?? 3e4))
|
|
25918
26579
|
return false;
|
|
25919
|
-
this.#publish(
|
|
26580
|
+
this.#publish(id2, {
|
|
25920
26581
|
...previous,
|
|
25921
26582
|
status: "interrupted",
|
|
25922
26583
|
resultSummary: "Native Subagent status could not be confirmed"
|
|
@@ -25925,24 +26586,24 @@ var AntigravitySubagents = class {
|
|
|
25925
26586
|
}
|
|
25926
26587
|
async #read() {
|
|
25927
26588
|
const parentId = this.options.parentId();
|
|
25928
|
-
for (const [
|
|
26589
|
+
for (const [id2, previous] of this.#states) {
|
|
25929
26590
|
if (this.#stopped)
|
|
25930
26591
|
return;
|
|
25931
26592
|
if (previous.status !== "running" && previous.status !== "pending")
|
|
25932
26593
|
continue;
|
|
25933
|
-
const observed = parentId ? await readNativeSubagentState(this.options.home, parentId,
|
|
26594
|
+
const observed = parentId ? await readNativeSubagentState(this.options.home, parentId, id2) : { ownership: "unavailable" };
|
|
25934
26595
|
if (this.#stopped)
|
|
25935
26596
|
return;
|
|
25936
|
-
if (this.#states.get(
|
|
26597
|
+
if (this.#states.get(id2) !== previous)
|
|
25937
26598
|
continue;
|
|
25938
26599
|
if (observed.ownership === "foreign") {
|
|
25939
26600
|
const state = { ...previous, status: "interrupted" };
|
|
25940
26601
|
delete state.resultSummary;
|
|
25941
|
-
this.#publish(
|
|
26602
|
+
this.#publish(id2, state);
|
|
25942
26603
|
continue;
|
|
25943
26604
|
}
|
|
25944
26605
|
if (observed.ownership !== "matched" || observed.status === null) {
|
|
25945
|
-
const expired = this.#expireUnavailable(
|
|
26606
|
+
const expired = this.#expireUnavailable(id2, previous);
|
|
25946
26607
|
if (observed.ownership !== "matched" || expired)
|
|
25947
26608
|
continue;
|
|
25948
26609
|
}
|
|
@@ -25950,7 +26611,7 @@ var AntigravitySubagents = class {
|
|
|
25950
26611
|
continue;
|
|
25951
26612
|
const transcript = await readSubagentTranscript({
|
|
25952
26613
|
parentId,
|
|
25953
|
-
childId:
|
|
26614
|
+
childId: id2,
|
|
25954
26615
|
status: observed.status ?? previous.status,
|
|
25955
26616
|
cwd: this.options.cwd,
|
|
25956
26617
|
outputLimit: this.options.outputLimit,
|
|
@@ -25958,26 +26619,26 @@ var AntigravitySubagents = class {
|
|
|
25958
26619
|
});
|
|
25959
26620
|
if (this.#stopped)
|
|
25960
26621
|
return;
|
|
25961
|
-
if (this.#states.get(
|
|
26622
|
+
if (this.#states.get(id2) !== previous)
|
|
25962
26623
|
continue;
|
|
25963
26624
|
if (observed.status === "running")
|
|
25964
|
-
this.#unavailableSince.delete(
|
|
25965
|
-
else if (!transcript.ok && this.#expireUnavailable(
|
|
26625
|
+
this.#unavailableSince.delete(id2);
|
|
26626
|
+
else if (!transcript.ok && this.#expireUnavailable(id2, previous))
|
|
25966
26627
|
continue;
|
|
25967
26628
|
if (transcript.ok && observed.status !== null)
|
|
25968
|
-
this.#unavailableSince.delete(
|
|
26629
|
+
this.#unavailableSince.delete(id2);
|
|
25969
26630
|
let status = transcript.ok ? observed.status ?? previous.status : previous.status;
|
|
25970
26631
|
if (status === "completed" && transcript.ok && transcript.value.turns.at(-1)?.outcome.status === "failed")
|
|
25971
26632
|
status = "failed";
|
|
25972
26633
|
const last = transcript.ok ? transcript.value.turns.at(-1)?.items.findLast(({ item }) => item.type === "agentMessage")?.item : void 0;
|
|
25973
26634
|
const resultSummary = last?.type === "agentMessage" ? last.text.slice(0, 2e3) : previous.resultSummary;
|
|
25974
26635
|
if (status !== previous.status || resultSummary !== previous.resultSummary)
|
|
25975
|
-
this.#publish(
|
|
26636
|
+
this.#publish(id2, { ...previous, status, ...resultSummary ? { resultSummary } : {} });
|
|
25976
26637
|
if (transcript.ok) {
|
|
25977
26638
|
const content = JSON.stringify(transcript.value);
|
|
25978
|
-
if (content !== this.#transcripts.get(
|
|
25979
|
-
this.#transcripts.set(
|
|
25980
|
-
this.options.emit({ type: "subagent.transcript.changed", nativeSubagentId:
|
|
26639
|
+
if (content !== this.#transcripts.get(id2)) {
|
|
26640
|
+
this.#transcripts.set(id2, content);
|
|
26641
|
+
this.options.emit({ type: "subagent.transcript.changed", nativeSubagentId: id2 });
|
|
25981
26642
|
}
|
|
25982
26643
|
}
|
|
25983
26644
|
}
|
|
@@ -26005,7 +26666,7 @@ var antigravitySessionCapabilities = {
|
|
|
26005
26666
|
},
|
|
26006
26667
|
history: { fork: true, forkAcrossCwd: true, rollbackLastTurn: true },
|
|
26007
26668
|
subagents: { observe: true, readTranscript: true },
|
|
26008
|
-
autonomousTurns: { observe:
|
|
26669
|
+
autonomousTurns: { observe: true }
|
|
26009
26670
|
};
|
|
26010
26671
|
function ok(value) {
|
|
26011
26672
|
return { ok: true, value };
|
|
@@ -26127,19 +26788,23 @@ var AntigravitySession = class {
|
|
|
26127
26788
|
#configOptions = [];
|
|
26128
26789
|
#catalog;
|
|
26129
26790
|
#commands = ANTIGRAVITY_COMMAND_CATALOG;
|
|
26130
|
-
|
|
26791
|
+
// Null means a raw count increase alone cannot identify the next prompt.
|
|
26792
|
+
#confirmedCount = null;
|
|
26793
|
+
#confirmedCheckpoints = /* @__PURE__ */ new Set();
|
|
26131
26794
|
#active;
|
|
26132
|
-
#
|
|
26133
|
-
#
|
|
26134
|
-
#postPromptBackground = [];
|
|
26795
|
+
#wakes;
|
|
26796
|
+
#postPromptWake = false;
|
|
26135
26797
|
#pending = /* @__PURE__ */ new Map();
|
|
26136
26798
|
#usage;
|
|
26137
|
-
#usageWork
|
|
26799
|
+
#usageWork;
|
|
26800
|
+
#usageDirty = false;
|
|
26801
|
+
#usageRetry;
|
|
26802
|
+
#usageTurnId;
|
|
26138
26803
|
#abort = new AbortController();
|
|
26139
26804
|
#closed = false;
|
|
26140
26805
|
#faulted = false;
|
|
26141
26806
|
#closing;
|
|
26142
|
-
#
|
|
26807
|
+
#configurationQueue;
|
|
26143
26808
|
#historyOperation = false;
|
|
26144
26809
|
constructor(options) {
|
|
26145
26810
|
this.#options = options;
|
|
@@ -26169,13 +26834,17 @@ var AntigravitySession = class {
|
|
|
26169
26834
|
return this.#state.nativeRef;
|
|
26170
26835
|
}
|
|
26171
26836
|
get isActive() {
|
|
26172
|
-
return !!this.#active || !!this.#opening || this.#
|
|
26837
|
+
return !!this.#active || !!this.#opening || !!this.#configurationQueue || this.#subagents.running;
|
|
26173
26838
|
}
|
|
26174
26839
|
hasBackgroundWork() {
|
|
26175
|
-
return this.#subagents.running;
|
|
26840
|
+
return this.#subagents.running || !!this.#wakes?.observing;
|
|
26841
|
+
}
|
|
26842
|
+
activeForkTurnIndex(checkpointId, home) {
|
|
26843
|
+
if (this.#active?.promptPhase === "submitted" && this.#confirmedCount !== null && !this.#opening && !this.#configurationQueue && !this.#subagents.running && !this.#historyOperation && !this.#closed && !this.#faulted && home === antigravityHome(this.#options.environment) && this.#confirmedCheckpoints.has(checkpointId))
|
|
26844
|
+
return this.#confirmedCount;
|
|
26176
26845
|
}
|
|
26177
26846
|
reserveHistoryOperation() {
|
|
26178
|
-
if (this.isActive || this.#historyOperation || this.#closed || this.#faulted)
|
|
26847
|
+
if (this.isActive || this.#wakes?.observing || this.#historyOperation || this.#closed || this.#faulted)
|
|
26179
26848
|
return null;
|
|
26180
26849
|
this.#historyOperation = true;
|
|
26181
26850
|
return () => {
|
|
@@ -26244,8 +26913,25 @@ var AntigravitySession = class {
|
|
|
26244
26913
|
if (!validNativeSessionRef({ harnessId, nativeSessionId: opened.sessionId, formatVersion: 1 }, harnessId))
|
|
26245
26914
|
throw new AntigravityTransportError("protocolError", "Antigravity returned an invalid native Session ID");
|
|
26246
26915
|
this.#applyOpened(opened, skip);
|
|
26247
|
-
|
|
26916
|
+
if (!this.#wakes) {
|
|
26917
|
+
this.#confirmedCount = await readNativeTurnCount(nativeConversationDbPath(opened.sessionId, antigravityHome(this.#options.environment))).catch((error51) => !ref && error51.code === "ENOENT" ? 0 : null);
|
|
26918
|
+
}
|
|
26248
26919
|
this.#initializeUsage(opened.sessionId);
|
|
26920
|
+
if (!this.#wakes) {
|
|
26921
|
+
const home = antigravityHome(this.#options.environment);
|
|
26922
|
+
const cursor = ref ? await readNativeHistory(opened.sessionId, home).then((value) => value.wakeWatermark, () => -1) : -1;
|
|
26923
|
+
if (this.#closed || this.#faulted)
|
|
26924
|
+
return;
|
|
26925
|
+
this.#wakes = new AntigravityWakeObserver({
|
|
26926
|
+
nativeSessionId: opened.sessionId,
|
|
26927
|
+
cwd: this.#options.cwd,
|
|
26928
|
+
home,
|
|
26929
|
+
cursor,
|
|
26930
|
+
outputLimit: this.#options.adapter.toolOutputLimit,
|
|
26931
|
+
canPublish: () => this.#active?.promptPhase !== "returned",
|
|
26932
|
+
publish: (snapshot) => this.#emit({ type: "turn.autonomous.completed", snapshot })
|
|
26933
|
+
});
|
|
26934
|
+
}
|
|
26249
26935
|
transport.setSessionEventHandler((event) => {
|
|
26250
26936
|
if (this.#transport === transport && !this.#closed && !this.#faulted)
|
|
26251
26937
|
this.#sessionEvent(event);
|
|
@@ -26253,13 +26939,12 @@ var AntigravitySession = class {
|
|
|
26253
26939
|
if (this.#requested.model) {
|
|
26254
26940
|
const applied = await this.#setModelConfig(this.#requested.model.id, this.#requested.thinkingOptionId);
|
|
26255
26941
|
if (!applied.bakedInThinking) {
|
|
26256
|
-
|
|
26257
|
-
|
|
26258
|
-
|
|
26259
|
-
await this.#setConfig("thinking", applied.impliedThinking);
|
|
26942
|
+
const desiredThinking = this.#resolveThinkingChoice(this.#requested.thinkingOptionId ?? applied.impliedThinking);
|
|
26943
|
+
if (desiredThinking) {
|
|
26944
|
+
await this.#setConfig("thinking", desiredThinking);
|
|
26260
26945
|
}
|
|
26261
26946
|
}
|
|
26262
|
-
} else if (this.#requested.thinkingOptionId) {
|
|
26947
|
+
} else if (this.#requested.thinkingOptionId && this.#hasConfigChoice("thinking", this.#requested.thinkingOptionId)) {
|
|
26263
26948
|
await this.#setConfig("thinking", this.#requested.thinkingOptionId);
|
|
26264
26949
|
}
|
|
26265
26950
|
if (!skip && this.#requested.permissionModeId) {
|
|
@@ -26267,7 +26952,8 @@ var AntigravitySession = class {
|
|
|
26267
26952
|
this.#state.effectivePermissionModeId = this.#requested.permissionModeId;
|
|
26268
26953
|
this.#setLocatorPermissionMode(this.#requested.permissionModeId);
|
|
26269
26954
|
}
|
|
26270
|
-
this.#
|
|
26955
|
+
if (!this.#configurationQueue)
|
|
26956
|
+
this.#publishState();
|
|
26271
26957
|
} catch (error51) {
|
|
26272
26958
|
await transport.close().catch(() => void 0);
|
|
26273
26959
|
if (this.#transport === transport)
|
|
@@ -26281,9 +26967,9 @@ var AntigravitySession = class {
|
|
|
26281
26967
|
this.#usage = new AntigravitySessionUsageTracker({
|
|
26282
26968
|
nativeSessionId,
|
|
26283
26969
|
homedir: antigravityHome(this.#options.environment),
|
|
26284
|
-
expectedInitialTurns: this.#
|
|
26970
|
+
expectedInitialTurns: this.#confirmedCount ?? 0
|
|
26285
26971
|
});
|
|
26286
|
-
this.#
|
|
26972
|
+
this.#trackUsageWork(this.#replayUsage());
|
|
26287
26973
|
}
|
|
26288
26974
|
#setLocatorPermissionMode(permissionModeId) {
|
|
26289
26975
|
const ref = this.#state.nativeRef;
|
|
@@ -26332,7 +27018,6 @@ var AntigravitySession = class {
|
|
|
26332
27018
|
...effectivePermissionModeId ? { effectivePermissionModeId } : {},
|
|
26333
27019
|
...readAcpEffectiveModelState(config2, this.#catalog)
|
|
26334
27020
|
};
|
|
26335
|
-
this.#publishState();
|
|
26336
27021
|
}
|
|
26337
27022
|
#findConfigOption(category) {
|
|
26338
27023
|
return this.#configOptions.find((entry) => entry.category === category || entry.id === category || category === "thinking" && entry.id === "thought_level");
|
|
@@ -26341,6 +27026,14 @@ var AntigravitySession = class {
|
|
|
26341
27026
|
const option = this.#findConfigOption(category);
|
|
26342
27027
|
return !!option?.options.some((choice) => choice.value === value);
|
|
26343
27028
|
}
|
|
27029
|
+
#resolveThinkingChoice(preferred) {
|
|
27030
|
+
if (preferred && this.#hasConfigChoice("thinking", preferred))
|
|
27031
|
+
return preferred;
|
|
27032
|
+
if (!this.#state.effectiveThinkingOptionId) {
|
|
27033
|
+
return this.#findConfigOption("thinking")?.options.at(-1)?.value;
|
|
27034
|
+
}
|
|
27035
|
+
return void 0;
|
|
27036
|
+
}
|
|
26344
27037
|
async #setModelConfig(requestedModelId, requestedThinking) {
|
|
26345
27038
|
const option = this.#findConfigOption("model");
|
|
26346
27039
|
if (!option) {
|
|
@@ -26384,19 +27077,28 @@ var AntigravitySession = class {
|
|
|
26384
27077
|
this.#applyConfig(confirmed);
|
|
26385
27078
|
}
|
|
26386
27079
|
#sessionEvent(event) {
|
|
26387
|
-
if (event.type === "agent.text" || event.type === "agent.thought") {
|
|
26388
|
-
this.#
|
|
27080
|
+
if ((event.type === "agent.text" || event.type === "agent.thought") && event.text.trim() || event.type === "tool.call" || event.type === "tool.update") {
|
|
27081
|
+
if (this.#opening || this.#historyOperation || this.#active?.cancelled)
|
|
27082
|
+
return;
|
|
27083
|
+
if (this.#active?.promptPhase === "returned")
|
|
27084
|
+
this.#postPromptWake = true;
|
|
27085
|
+
else if (this.#active?.promptPhase !== "submitted")
|
|
27086
|
+
this.#wakes?.observe();
|
|
26389
27087
|
return;
|
|
26390
27088
|
}
|
|
26391
27089
|
switch (event.type) {
|
|
26392
27090
|
case "config.update":
|
|
26393
|
-
this.#
|
|
27091
|
+
if (!this.#opening && !this.#configurationQueue) {
|
|
27092
|
+
this.#applyConfig(event.configOptions);
|
|
27093
|
+
this.#publishState();
|
|
27094
|
+
}
|
|
26394
27095
|
break;
|
|
26395
27096
|
case "mode.update":
|
|
26396
27097
|
if (!this.#transport?.skipPermissions) {
|
|
26397
27098
|
this.#state.effectivePermissionModeId = harnessPermissionModeIdSchema.parse(event.currentModeId);
|
|
26398
27099
|
this.#setLocatorPermissionMode(event.currentModeId);
|
|
26399
|
-
this.#
|
|
27100
|
+
if (!this.#opening && !this.#configurationQueue)
|
|
27101
|
+
this.#publishState();
|
|
26400
27102
|
}
|
|
26401
27103
|
break;
|
|
26402
27104
|
case "commands.update":
|
|
@@ -26406,8 +27108,11 @@ var AntigravitySession = class {
|
|
|
26406
27108
|
const usage = this.#usage?.recordContextWindow(event.used, event.size);
|
|
26407
27109
|
if (usage)
|
|
26408
27110
|
this.#emit({ type: "session.usage.changed", usage });
|
|
26409
|
-
if (this.#active?.promptPhase === "submitted")
|
|
27111
|
+
if (this.#active?.promptPhase === "submitted") {
|
|
26410
27112
|
void this.refreshUsage();
|
|
27113
|
+
void this.#syncTurnCompactions(this.#active);
|
|
27114
|
+
this.#scheduleUsageRetry();
|
|
27115
|
+
}
|
|
26411
27116
|
break;
|
|
26412
27117
|
}
|
|
26413
27118
|
}
|
|
@@ -26430,24 +27135,75 @@ var AntigravitySession = class {
|
|
|
26430
27135
|
}
|
|
26431
27136
|
}
|
|
26432
27137
|
async refreshUsage() {
|
|
27138
|
+
if (this.#usageWork) {
|
|
27139
|
+
this.#usageDirty = true;
|
|
27140
|
+
await this.#usageWork;
|
|
27141
|
+
} else
|
|
27142
|
+
await this.#trackUsageWork(this.#collectUsage());
|
|
27143
|
+
}
|
|
27144
|
+
#trackUsageWork(work) {
|
|
27145
|
+
const drain = async () => {
|
|
27146
|
+
try {
|
|
27147
|
+
await work;
|
|
27148
|
+
while (this.#usageWork === tracked && this.#usageDirty) {
|
|
27149
|
+
this.#usageDirty = false;
|
|
27150
|
+
await this.#collectUsage();
|
|
27151
|
+
}
|
|
27152
|
+
} finally {
|
|
27153
|
+
if (this.#usageWork === tracked)
|
|
27154
|
+
this.#usageWork = void 0;
|
|
27155
|
+
}
|
|
27156
|
+
};
|
|
27157
|
+
const tracked = drain();
|
|
27158
|
+
this.#usageWork = tracked;
|
|
27159
|
+
return tracked;
|
|
27160
|
+
}
|
|
27161
|
+
#scheduleUsageRetry(remaining = 2) {
|
|
27162
|
+
if (this.#usageRetry || this.#abort.signal.aborted)
|
|
27163
|
+
return;
|
|
27164
|
+
this.#usageRetry = setTimeout(() => {
|
|
27165
|
+
this.#usageRetry = void 0;
|
|
27166
|
+
void this.refreshUsage().then(() => {
|
|
27167
|
+
if (remaining > 1)
|
|
27168
|
+
this.#scheduleUsageRetry(remaining - 1);
|
|
27169
|
+
});
|
|
27170
|
+
}, 150);
|
|
27171
|
+
this.#usageRetry.unref();
|
|
27172
|
+
}
|
|
27173
|
+
async #collectUsage(final) {
|
|
26433
27174
|
const tracker = this.#usage;
|
|
26434
27175
|
if (!tracker || this.#closed || this.#faulted)
|
|
26435
27176
|
return;
|
|
26436
|
-
|
|
27177
|
+
if (final && !this.#isCurrent(final.turn))
|
|
27178
|
+
return;
|
|
27179
|
+
try {
|
|
26437
27180
|
const update = await tracker.collectNewTranscriptRequests({
|
|
26438
|
-
signal: this.#abort.signal
|
|
27181
|
+
signal: this.#abort.signal,
|
|
27182
|
+
...final && {
|
|
27183
|
+
completedAtMs: final.completedAtMs,
|
|
27184
|
+
...final.turn.firstOutputAtMs === void 0 ? {} : { firstOutputAtMs: final.turn.firstOutputAtMs },
|
|
27185
|
+
...final.turn.hasToolCalls && { hasToolCalls: true },
|
|
27186
|
+
...final.usage && { promptUsage: final.usage }
|
|
27187
|
+
}
|
|
26439
27188
|
});
|
|
27189
|
+
const recorded = final ? tracker.recordTurnPromptUsage(final) : update;
|
|
26440
27190
|
if (this.#closed || this.#faulted)
|
|
26441
27191
|
return;
|
|
26442
27192
|
for (const request of update.requests)
|
|
26443
27193
|
this.#emit({ type: "usage.request", request });
|
|
26444
|
-
this.#emit({ type: "usage.history", complete:
|
|
26445
|
-
this.#emit({
|
|
26446
|
-
|
|
27194
|
+
this.#emit({ type: "usage.history", complete: recorded.complete });
|
|
27195
|
+
this.#emit({
|
|
27196
|
+
type: "session.usage.changed",
|
|
27197
|
+
usage: recorded.usage,
|
|
27198
|
+
...this.#usageTurnId && { observedForTurnId: this.#usageTurnId }
|
|
27199
|
+
});
|
|
27200
|
+
for (const { turnId, ...timing2 } of update.timings)
|
|
27201
|
+
if (turnId)
|
|
27202
|
+
this.#emit({ type: "usage.request.timing", turnId, timing: timing2 });
|
|
27203
|
+
} catch {
|
|
26447
27204
|
if (!this.#closed && !this.#faulted)
|
|
26448
27205
|
this.#emit({ type: "usage.history", complete: false });
|
|
26449
|
-
}
|
|
26450
|
-
await this.#usageWork;
|
|
27206
|
+
}
|
|
26451
27207
|
}
|
|
26452
27208
|
get commands() {
|
|
26453
27209
|
return {
|
|
@@ -26489,11 +27245,10 @@ var AntigravitySession = class {
|
|
|
26489
27245
|
nativeSessionId,
|
|
26490
27246
|
cwd: this.#options.cwd,
|
|
26491
27247
|
events,
|
|
26492
|
-
...this.#options.knownTurnRefs ? { knownTurnRefs: this.#options.knownTurnRefs } : {},
|
|
26493
27248
|
...this.#options.adapter.toolOutputLimit !== void 0 ? { outputLimit: this.#options.adapter.toolOutputLimit } : {}
|
|
26494
27249
|
});
|
|
26495
|
-
if (!this.#transport) {
|
|
26496
|
-
this.#
|
|
27250
|
+
if (!this.#transport && !this.#wakes) {
|
|
27251
|
+
this.#confirmedCount = turnCount;
|
|
26497
27252
|
this.#initializeUsage(nativeSessionId);
|
|
26498
27253
|
}
|
|
26499
27254
|
return ok({ turns, ...this.#transport ? { state: { ...this.#state } } : {} });
|
|
@@ -26518,6 +27273,7 @@ var AntigravitySession = class {
|
|
|
26518
27273
|
return err("invalidRequest", "Turn is not active");
|
|
26519
27274
|
if (!turn.cancelled) {
|
|
26520
27275
|
turn.cancelled = true;
|
|
27276
|
+
turn.accounting.abort();
|
|
26521
27277
|
this.#closeInteractions("cancelled");
|
|
26522
27278
|
try {
|
|
26523
27279
|
if (turn.promptPhase === "submitted")
|
|
@@ -26538,24 +27294,46 @@ var AntigravitySession = class {
|
|
|
26538
27294
|
return { ok: false, error: normalizeAntigravityError(error51) };
|
|
26539
27295
|
}
|
|
26540
27296
|
}
|
|
27297
|
+
async #enqueueConfiguration(run) {
|
|
27298
|
+
const previous = this.#configurationQueue;
|
|
27299
|
+
let release;
|
|
27300
|
+
const current = new Promise((resolve) => {
|
|
27301
|
+
release = resolve;
|
|
27302
|
+
});
|
|
27303
|
+
const tail = previous ? previous.then(() => current) : current;
|
|
27304
|
+
this.#configurationQueue = tail;
|
|
27305
|
+
if (previous)
|
|
27306
|
+
await previous;
|
|
27307
|
+
const before = this.#state;
|
|
27308
|
+
try {
|
|
27309
|
+
return await run();
|
|
27310
|
+
} finally {
|
|
27311
|
+
if (this.#transport && !this.#closed && !this.#faulted && this.#state !== before) {
|
|
27312
|
+
this.#publishState();
|
|
27313
|
+
}
|
|
27314
|
+
if (this.#configurationQueue === tail)
|
|
27315
|
+
this.#configurationQueue = void 0;
|
|
27316
|
+
release();
|
|
27317
|
+
}
|
|
27318
|
+
}
|
|
26541
27319
|
#startTurn(command, catalogCommand) {
|
|
26542
27320
|
if (this.#closed || this.#faulted)
|
|
26543
27321
|
return err("invalidState", "Session is closed");
|
|
26544
|
-
if (this.#active || this.#
|
|
27322
|
+
if (this.#active || this.#configurationQueue || this.#historyOperation)
|
|
26545
27323
|
return err("sessionBusy", "Session is busy", true);
|
|
26546
27324
|
if (!command.turnId || !command.input.length || !command.input.some((part) => typeof part.text === "string" && part.text.trim()))
|
|
26547
27325
|
return err("invalidRequest", "Prompt and Turn ID must not be empty");
|
|
26548
27326
|
try {
|
|
26549
|
-
this.#
|
|
27327
|
+
this.#postPromptWake = false;
|
|
26550
27328
|
const turn = {
|
|
26551
27329
|
turnId: command.turnId,
|
|
26552
27330
|
cancelled: false,
|
|
26553
27331
|
ended: false,
|
|
26554
|
-
promptPhase: "notSubmitted"
|
|
27332
|
+
promptPhase: "notSubmitted",
|
|
27333
|
+
accounting: new AbortController(),
|
|
27334
|
+
emittedCompactions: /* @__PURE__ */ new Set()
|
|
26555
27335
|
};
|
|
26556
27336
|
this.#active = turn;
|
|
26557
|
-
this.#settleBackground({ status: "succeeded" });
|
|
26558
|
-
this.#lastCompletedTurnId = void 0;
|
|
26559
27337
|
this.#emit({ type: "turn.started", turnId: turn.turnId });
|
|
26560
27338
|
void this.#runTurn(turn, command, catalogCommand);
|
|
26561
27339
|
return ok({ turnId: command.turnId });
|
|
@@ -26564,7 +27342,7 @@ var AntigravitySession = class {
|
|
|
26564
27342
|
}
|
|
26565
27343
|
}
|
|
26566
27344
|
async #select(command) {
|
|
26567
|
-
if (this.#
|
|
27345
|
+
if (this.#historyOperation)
|
|
26568
27346
|
return err("sessionBusy", "Configuration or history is changing", true);
|
|
26569
27347
|
if (command.type === "permissionMode.select") {
|
|
26570
27348
|
try {
|
|
@@ -26575,17 +27353,44 @@ var AntigravitySession = class {
|
|
|
26575
27353
|
if (this.#options.unattended && command.permissionModeId !== SKIP)
|
|
26576
27354
|
return err("invalidRequest", "Unattended execution requires Skip permissions");
|
|
26577
27355
|
}
|
|
26578
|
-
this.#
|
|
26579
|
-
|
|
27356
|
+
return this.#enqueueConfiguration(async () => {
|
|
27357
|
+
if (this.#closed || this.#faulted)
|
|
27358
|
+
return err("invalidState", "Session is closed");
|
|
27359
|
+
if (this.#historyOperation)
|
|
27360
|
+
return err("sessionBusy", "Configuration or history is changing", true);
|
|
27361
|
+
if (this.#opening) {
|
|
27362
|
+
try {
|
|
27363
|
+
await this.#opening;
|
|
27364
|
+
} catch (error51) {
|
|
27365
|
+
if (!(command.type === "model.select" && error51 instanceof AntigravityTransportError && error51.kind === "unsupported"))
|
|
27366
|
+
throw error51;
|
|
27367
|
+
}
|
|
27368
|
+
if (this.#closed || this.#faulted)
|
|
27369
|
+
return err("invalidState", "Session is closed");
|
|
27370
|
+
}
|
|
26580
27371
|
const openingFromCold = !this.#transport;
|
|
27372
|
+
const previousModel = this.#requested.model;
|
|
27373
|
+
const previousThinkingOptionId = this.#requested.thinkingOptionId;
|
|
26581
27374
|
const previousPermissionMode = this.#requested.permissionModeId;
|
|
26582
|
-
if (openingFromCold && command.type === "
|
|
27375
|
+
if (openingFromCold && command.type === "model.select") {
|
|
27376
|
+
this.#requested.model = command.model;
|
|
27377
|
+
if (command.model.id !== previousModel?.id) {
|
|
27378
|
+
this.#requested.thinkingOptionId = void 0;
|
|
27379
|
+
}
|
|
27380
|
+
} else if (openingFromCold && command.type === "thinking.select") {
|
|
27381
|
+
this.#requested.thinkingOptionId = void 0;
|
|
27382
|
+
} else if (openingFromCold && command.type === "permissionMode.select") {
|
|
26583
27383
|
this.#requested.permissionModeId = command.permissionModeId;
|
|
26584
27384
|
}
|
|
26585
27385
|
try {
|
|
26586
27386
|
await this.initialize();
|
|
26587
27387
|
} catch (error51) {
|
|
26588
|
-
if (openingFromCold && command.type === "
|
|
27388
|
+
if (openingFromCold && command.type === "model.select") {
|
|
27389
|
+
this.#requested.model = previousModel;
|
|
27390
|
+
this.#requested.thinkingOptionId = previousThinkingOptionId;
|
|
27391
|
+
} else if (openingFromCold && command.type === "thinking.select") {
|
|
27392
|
+
this.#requested.thinkingOptionId = previousThinkingOptionId;
|
|
27393
|
+
} else if (openingFromCold && command.type === "permissionMode.select") {
|
|
26589
27394
|
this.#requested.permissionModeId = previousPermissionMode;
|
|
26590
27395
|
}
|
|
26591
27396
|
throw error51;
|
|
@@ -26593,16 +27398,26 @@ var AntigravitySession = class {
|
|
|
26593
27398
|
const transport = this.#transport;
|
|
26594
27399
|
if (!transport || this.#closed || this.#faulted)
|
|
26595
27400
|
return err("invalidState", "Native Session is not connected");
|
|
26596
|
-
if (openingFromCold && command.type === "permissionMode.select") {
|
|
27401
|
+
if (openingFromCold && (command.type === "model.select" || command.type === "permissionMode.select")) {
|
|
27402
|
+
if (command.type === "model.select") {
|
|
27403
|
+
this.#requested.model = this.#state.effectiveModel;
|
|
27404
|
+
this.#requested.thinkingOptionId = this.#state.effectiveThinkingOptionId;
|
|
27405
|
+
}
|
|
26597
27406
|
return ok({ completed: true });
|
|
26598
27407
|
}
|
|
26599
27408
|
if (command.type === "model.select") {
|
|
26600
27409
|
const applied = await this.#setModelConfig(command.model.id);
|
|
26601
|
-
|
|
26602
|
-
|
|
27410
|
+
try {
|
|
27411
|
+
if (!applied.bakedInThinking) {
|
|
27412
|
+
const desiredThinking = this.#resolveThinkingChoice(applied.impliedThinking);
|
|
27413
|
+
if (desiredThinking) {
|
|
27414
|
+
await this.#setConfig("thinking", desiredThinking);
|
|
27415
|
+
}
|
|
27416
|
+
}
|
|
27417
|
+
} finally {
|
|
27418
|
+
this.#requested.model = this.#state.effectiveModel;
|
|
27419
|
+
this.#requested.thinkingOptionId = this.#state.effectiveThinkingOptionId;
|
|
26603
27420
|
}
|
|
26604
|
-
this.#requested.model = this.#state.effectiveModel;
|
|
26605
|
-
this.#requested.thinkingOptionId = this.#state.effectiveThinkingOptionId;
|
|
26606
27421
|
} else if (command.type === "thinking.select") {
|
|
26607
27422
|
await this.#setConfig("thinking", command.thinkingOptionId);
|
|
26608
27423
|
this.#requested.thinkingOptionId = this.#state.effectiveThinkingOptionId;
|
|
@@ -26618,7 +27433,6 @@ var AntigravitySession = class {
|
|
|
26618
27433
|
thinkingOptionId: this.#state.effectiveThinkingOptionId,
|
|
26619
27434
|
permissionModeId: command.permissionModeId
|
|
26620
27435
|
};
|
|
26621
|
-
this.#settleBackground({ status: "succeeded" });
|
|
26622
27436
|
old.setSessionEventHandler(null);
|
|
26623
27437
|
await old.close();
|
|
26624
27438
|
this.#transport = void 0;
|
|
@@ -26638,26 +27452,46 @@ var AntigravitySession = class {
|
|
|
26638
27452
|
this.#state.effectivePermissionModeId = command.permissionModeId;
|
|
26639
27453
|
this.#setLocatorPermissionMode(command.permissionModeId);
|
|
26640
27454
|
this.#requested.permissionModeId = command.permissionModeId;
|
|
26641
|
-
this.#publishState();
|
|
26642
27455
|
}
|
|
26643
27456
|
}
|
|
26644
27457
|
return ok({ completed: true });
|
|
26645
|
-
}
|
|
26646
|
-
this.#configuring = false;
|
|
26647
|
-
}
|
|
27458
|
+
});
|
|
26648
27459
|
}
|
|
26649
27460
|
async #runTurn(turn, command, catalogCommand) {
|
|
26650
27461
|
let outcome;
|
|
26651
27462
|
let nativeTurnRef;
|
|
27463
|
+
let confirmedCheckpoint;
|
|
27464
|
+
let mayWriteInput = true;
|
|
26652
27465
|
try {
|
|
26653
27466
|
await this.initialize();
|
|
26654
27467
|
await this.#usageWork;
|
|
27468
|
+
await this.#wakes?.flush();
|
|
27469
|
+
if (!this.#isCurrent(turn))
|
|
27470
|
+
return;
|
|
27471
|
+
if (turn.cancelled) {
|
|
27472
|
+
this.#finish(turn, { status: "cancelled" });
|
|
27473
|
+
return;
|
|
27474
|
+
}
|
|
27475
|
+
const ref = this.nativeRef;
|
|
27476
|
+
if (!ref)
|
|
27477
|
+
throw new AntigravityTransportError("unavailable", "Native Session is not connected");
|
|
27478
|
+
const home = antigravityHome(this.#options.environment);
|
|
27479
|
+
const file2 = nativeConversationDbPath(ref.nativeSessionId, home);
|
|
27480
|
+
const parts = promptParts(command);
|
|
27481
|
+
const part = parts[0];
|
|
27482
|
+
mayWriteInput = !catalogCommand || part?.type !== "text" || !/^\/(?:compact|help)(?:\s|$)/u.test(part.text);
|
|
27483
|
+
while (this.#configurationQueue && !turn.cancelled && this.#isCurrent(turn)) {
|
|
27484
|
+
await this.#configurationQueue;
|
|
27485
|
+
}
|
|
26655
27486
|
if (!this.#isCurrent(turn))
|
|
26656
27487
|
return;
|
|
26657
27488
|
if (turn.cancelled) {
|
|
26658
27489
|
this.#finish(turn, { status: "cancelled" });
|
|
26659
27490
|
return;
|
|
26660
27491
|
}
|
|
27492
|
+
const transport = this.#transport;
|
|
27493
|
+
if (!transport)
|
|
27494
|
+
throw new AntigravityTransportError("unavailable", "Native Session is not connected");
|
|
26661
27495
|
turn.tracker = new AntigravityToolTracker({
|
|
26662
27496
|
turnId: turn.turnId,
|
|
26663
27497
|
cwd: this.#options.cwd,
|
|
@@ -26670,15 +27504,18 @@ var AntigravitySession = class {
|
|
|
26670
27504
|
if (this.#isCurrent(turn))
|
|
26671
27505
|
this.#emit(event);
|
|
26672
27506
|
},
|
|
26673
|
-
onSubagentSpawned: (
|
|
27507
|
+
onSubagentSpawned: (id2, item) => this.#subagents.track(id2, item)
|
|
26674
27508
|
});
|
|
26675
|
-
const
|
|
26676
|
-
|
|
26677
|
-
|
|
26678
|
-
|
|
26679
|
-
|
|
27509
|
+
const before = this.#confirmedCount;
|
|
27510
|
+
turn.dbPath = file2;
|
|
27511
|
+
turn.compactionAfterStep = await readNativeStepWatermark(file2);
|
|
27512
|
+
if (!this.#isCurrent(turn))
|
|
27513
|
+
return;
|
|
27514
|
+
const submittedAtMs = Date.now();
|
|
27515
|
+
this.#usage?.beginTurn(submittedAtMs, turn.turnId);
|
|
27516
|
+
this.#usageTurnId = turn.turnId;
|
|
26680
27517
|
turn.promptPhase = "submitted";
|
|
26681
|
-
const result = await transport.prompt(
|
|
27518
|
+
const result = await transport.prompt(parts, {
|
|
26682
27519
|
onResponse: () => {
|
|
26683
27520
|
turn.promptPhase = "returned";
|
|
26684
27521
|
},
|
|
@@ -26717,15 +27554,11 @@ var AntigravitySession = class {
|
|
|
26717
27554
|
retryable: false
|
|
26718
27555
|
}
|
|
26719
27556
|
} : { status: "succeeded" };
|
|
26720
|
-
const
|
|
26721
|
-
|
|
26722
|
-
|
|
26723
|
-
|
|
26724
|
-
|
|
26725
|
-
count4 = !catalogCommand && outcome.status === "succeeded" ? before + 1 : before;
|
|
26726
|
-
}
|
|
26727
|
-
if (count4 > before) {
|
|
26728
|
-
const key = `turn-${count4 - 1}`;
|
|
27557
|
+
const confirmedCount = mayWriteInput ? await observeNativeTurnCount(file2, before, submittedAtMs, completedAtMs, outcome.status === "succeeded", AbortSignal.any([turn.accounting.signal, this.#abort.signal])) : null;
|
|
27558
|
+
if (!this.#isCurrent(turn))
|
|
27559
|
+
return;
|
|
27560
|
+
if (confirmedCount !== null) {
|
|
27561
|
+
const key = `turn-${confirmedCount - 1}`;
|
|
26729
27562
|
nativeTurnRef = {
|
|
26730
27563
|
harnessId,
|
|
26731
27564
|
nativeSessionId: ref.nativeSessionId,
|
|
@@ -26733,40 +27566,12 @@ var AntigravitySession = class {
|
|
|
26733
27566
|
nativeTurnKey: key
|
|
26734
27567
|
};
|
|
26735
27568
|
outcome = { ...outcome, checkpoint: { ...ref, checkpointId: key } };
|
|
26736
|
-
this.#
|
|
26737
|
-
|
|
26738
|
-
await this.#usageWork;
|
|
26739
|
-
if (this.#usage && this.#isCurrent(turn)) {
|
|
26740
|
-
try {
|
|
26741
|
-
const timing2 = {
|
|
26742
|
-
...turn.firstOutputAtMs !== void 0 ? { firstOutputAtMs: turn.firstOutputAtMs } : {},
|
|
26743
|
-
completedAtMs
|
|
26744
|
-
};
|
|
26745
|
-
const update = await this.#usage.collectNewTranscriptRequests({
|
|
26746
|
-
...timing2,
|
|
26747
|
-
...turn.hasToolCalls ? { hasToolCalls: true } : {},
|
|
26748
|
-
...result.usage ? { promptUsage: result.usage } : {},
|
|
26749
|
-
signal: this.#abort.signal
|
|
26750
|
-
});
|
|
26751
|
-
const recorded = this.#usage.recordTurnPromptUsage({
|
|
26752
|
-
...result.usage ? { usage: result.usage } : {},
|
|
26753
|
-
...timing2
|
|
26754
|
-
});
|
|
26755
|
-
if (!this.#isCurrent(turn))
|
|
26756
|
-
return;
|
|
26757
|
-
for (const request of update.requests)
|
|
26758
|
-
this.#emit({ type: "usage.request", request });
|
|
26759
|
-
this.#emit({ type: "usage.history", complete: recorded.complete });
|
|
26760
|
-
this.#emit({
|
|
26761
|
-
type: "session.usage.changed",
|
|
26762
|
-
usage: recorded.usage,
|
|
26763
|
-
observedForTurnId: turn.turnId
|
|
26764
|
-
});
|
|
26765
|
-
} catch {
|
|
26766
|
-
if (this.#isCurrent(turn))
|
|
26767
|
-
this.#emit({ type: "usage.history", complete: false });
|
|
26768
|
-
}
|
|
27569
|
+
this.#confirmedCount = confirmedCount;
|
|
27570
|
+
confirmedCheckpoint = key;
|
|
26769
27571
|
}
|
|
27572
|
+
await this.#trackUsageWork(Promise.resolve(this.#usageWork).then(() => this.#collectUsage({ turn, completedAtMs, ...result.usage && { usage: result.usage } })));
|
|
27573
|
+
await this.#syncTurnCompactions(turn);
|
|
27574
|
+
this.#scheduleUsageRetry();
|
|
26770
27575
|
} catch (error51) {
|
|
26771
27576
|
if (error51 instanceof AntigravityTransportError && (error51.kind === "processExited" || error51.kind === "protocolError" || this.#transport?.isClosed)) {
|
|
26772
27577
|
this.handleTransportFault(error51);
|
|
@@ -26775,8 +27580,18 @@ var AntigravitySession = class {
|
|
|
26775
27580
|
} finally {
|
|
26776
27581
|
this.#usage?.endTurn();
|
|
26777
27582
|
}
|
|
26778
|
-
if (this.#isCurrent(turn))
|
|
27583
|
+
if (this.#isCurrent(turn)) {
|
|
27584
|
+
if (mayWriteInput && turn.promptPhase !== "notSubmitted" && !nativeTurnRef)
|
|
27585
|
+
this.#confirmedCount = null;
|
|
27586
|
+
if (turn.cancelled)
|
|
27587
|
+
outcome = {
|
|
27588
|
+
status: "cancelled",
|
|
27589
|
+
...outcome.checkpoint && { checkpoint: outcome.checkpoint }
|
|
27590
|
+
};
|
|
27591
|
+
if (confirmedCheckpoint && outcome.checkpoint)
|
|
27592
|
+
this.#confirmedCheckpoints.add(confirmedCheckpoint);
|
|
26779
27593
|
this.#finish(turn, outcome, nativeTurnRef);
|
|
27594
|
+
}
|
|
26780
27595
|
}
|
|
26781
27596
|
#isCurrent(turn) {
|
|
26782
27597
|
return this.#active === turn && !turn.ended;
|
|
@@ -26808,60 +27623,28 @@ var AntigravitySession = class {
|
|
|
26808
27623
|
});
|
|
26809
27624
|
turn.textItem = void 0;
|
|
26810
27625
|
}
|
|
26811
|
-
|
|
26812
|
-
|
|
26813
|
-
if (!text2)
|
|
26814
|
-
return;
|
|
26815
|
-
if (this.#active) {
|
|
26816
|
-
if (this.#active.promptPhase === "returned") {
|
|
26817
|
-
if (!this.#active.ended && !this.#active.cancelled && !this.#opening && !this.#configuring && !this.#historyOperation)
|
|
26818
|
-
this.#postPromptBackground.push({ type, text: text2 });
|
|
26819
|
-
return;
|
|
26820
|
-
}
|
|
26821
|
-
return;
|
|
26822
|
-
}
|
|
26823
|
-
if (this.#opening || this.#configuring || this.#historyOperation)
|
|
27626
|
+
async #syncTurnCompactions(turn) {
|
|
27627
|
+
if (!this.#isCurrent(turn) || turn.cancelled || turn.dbPath === void 0 || turn.compactionAfterStep === void 0)
|
|
26824
27628
|
return;
|
|
26825
|
-
const
|
|
26826
|
-
if (!
|
|
27629
|
+
const compactions = await readNativeTurnCompactions(turn.dbPath, turn.compactionAfterStep);
|
|
27630
|
+
if (!this.#isCurrent(turn) || turn.cancelled)
|
|
26827
27631
|
return;
|
|
26828
|
-
|
|
26829
|
-
|
|
26830
|
-
|
|
26831
|
-
|
|
26832
|
-
this.#
|
|
26833
|
-
|
|
26834
|
-
|
|
26835
|
-
|
|
26836
|
-
|
|
26837
|
-
|
|
27632
|
+
for (const compaction of compactions) {
|
|
27633
|
+
if (turn.emittedCompactions.has(compaction.stepIndex))
|
|
27634
|
+
continue;
|
|
27635
|
+
turn.emittedCompactions.add(compaction.stepIndex);
|
|
27636
|
+
this.#completeText(turn, { status: "succeeded" });
|
|
27637
|
+
const item = {
|
|
27638
|
+
type: "contextCompaction",
|
|
27639
|
+
itemId: compactionItemId(compaction.stepIndex)
|
|
27640
|
+
};
|
|
27641
|
+
this.#emit({ type: "item.started", turnId: turn.turnId, item });
|
|
26838
27642
|
this.#emit({
|
|
26839
|
-
type: "item.
|
|
26840
|
-
turnId,
|
|
26841
|
-
|
|
27643
|
+
type: "item.completed",
|
|
27644
|
+
turnId: turn.turnId,
|
|
27645
|
+
snapshot: { item, outcome: compactionOutcome(compaction) }
|
|
26842
27646
|
});
|
|
26843
27647
|
}
|
|
26844
|
-
current.textItem.text += text2;
|
|
26845
|
-
this.#emit({
|
|
26846
|
-
type: "item.updated",
|
|
26847
|
-
turnId,
|
|
26848
|
-
itemId: current.textItem.itemId,
|
|
26849
|
-
update: { type: "text.append", text: text2 }
|
|
26850
|
-
});
|
|
26851
|
-
}
|
|
26852
|
-
/** Close the pending idle-output Item; the emitted content stays real output. */
|
|
26853
|
-
#settleBackground(outcome) {
|
|
26854
|
-
const episode = this.#background;
|
|
26855
|
-
if (!episode?.textItem) {
|
|
26856
|
-
this.#background = void 0;
|
|
26857
|
-
return;
|
|
26858
|
-
}
|
|
26859
|
-
this.#emit({
|
|
26860
|
-
type: "item.completed",
|
|
26861
|
-
turnId: episode.turnId,
|
|
26862
|
-
snapshot: { item: { ...episode.textItem }, outcome }
|
|
26863
|
-
});
|
|
26864
|
-
this.#background = void 0;
|
|
26865
27648
|
}
|
|
26866
27649
|
#finish(turn, outcome, nativeTurnRef) {
|
|
26867
27650
|
if (!this.#isCurrent(turn))
|
|
@@ -26871,21 +27654,15 @@ var AntigravitySession = class {
|
|
|
26871
27654
|
turn.tracker?.finishPending(outcome);
|
|
26872
27655
|
turn.ended = true;
|
|
26873
27656
|
this.#active = void 0;
|
|
26874
|
-
if (nativeTurnRef)
|
|
26875
|
-
this.#lastCompletedTurnId = turn.turnId;
|
|
26876
|
-
this.#settleBackground({ status: "succeeded" });
|
|
26877
27657
|
this.#emit({
|
|
26878
27658
|
type: "turn.completed",
|
|
26879
27659
|
turnId: turn.turnId,
|
|
26880
27660
|
...nativeTurnRef ? { nativeTurnRef } : outcome.status === "succeeded" ? { ephemeral: true } : {},
|
|
26881
27661
|
outcome
|
|
26882
27662
|
});
|
|
26883
|
-
if (
|
|
26884
|
-
|
|
26885
|
-
|
|
26886
|
-
} else {
|
|
26887
|
-
this.#postPromptBackground.length = 0;
|
|
26888
|
-
}
|
|
27663
|
+
if (this.#postPromptWake && !this.#closed && !this.#faulted)
|
|
27664
|
+
this.#wakes?.observe();
|
|
27665
|
+
this.#postPromptWake = false;
|
|
26889
27666
|
}
|
|
26890
27667
|
#permission(turn, request) {
|
|
26891
27668
|
const ref = this.nativeRef;
|
|
@@ -26976,11 +27753,11 @@ var AntigravitySession = class {
|
|
|
26976
27753
|
return ok({ accepted: true });
|
|
26977
27754
|
}
|
|
26978
27755
|
#closeInteractions(reason) {
|
|
26979
|
-
for (const [
|
|
27756
|
+
for (const [id2, pending] of this.#pending) {
|
|
26980
27757
|
pending.resolve(pending.cancelValue);
|
|
26981
27758
|
this.#emit({
|
|
26982
27759
|
type: "interaction.closed",
|
|
26983
|
-
interactionId: hostInteractionIdSchema.parse(
|
|
27760
|
+
interactionId: hostInteractionIdSchema.parse(id2),
|
|
26984
27761
|
turnId: pending.interaction.turnId,
|
|
26985
27762
|
reason
|
|
26986
27763
|
});
|
|
@@ -26991,12 +27768,13 @@ var AntigravitySession = class {
|
|
|
26991
27768
|
if (this.#closed || this.#faulted)
|
|
26992
27769
|
return;
|
|
26993
27770
|
this.#faulted = true;
|
|
27771
|
+
clearTimeout(this.#usageRetry);
|
|
26994
27772
|
this.#abort.abort();
|
|
26995
|
-
this.#
|
|
27773
|
+
this.#wakes?.close();
|
|
27774
|
+
this.#postPromptWake = false;
|
|
26996
27775
|
this.#closeInteractions("cancelled");
|
|
26997
27776
|
if (this.#active)
|
|
26998
27777
|
this.#finish(this.#active, { status: "failed", error: normalizeAntigravityError(error51) });
|
|
26999
|
-
this.#settleBackground({ status: "succeeded" });
|
|
27000
27778
|
this.#emit({ type: "session.faulted", error: normalizeAntigravityError(error51) });
|
|
27001
27779
|
this.#channel.end();
|
|
27002
27780
|
this.#subagents.stop();
|
|
@@ -27010,16 +27788,17 @@ var AntigravitySession = class {
|
|
|
27010
27788
|
}
|
|
27011
27789
|
async #close() {
|
|
27012
27790
|
this.#closed = true;
|
|
27791
|
+
clearTimeout(this.#usageRetry);
|
|
27013
27792
|
this.#abort.abort();
|
|
27014
|
-
this.#
|
|
27793
|
+
this.#wakes?.close();
|
|
27794
|
+
this.#postPromptWake = false;
|
|
27015
27795
|
this.#closeInteractions("cancelled");
|
|
27016
|
-
|
|
27017
|
-
|
|
27018
|
-
|
|
27019
|
-
this.#finish(active, { status: "cancelled", reason: "Session closed" });
|
|
27796
|
+
const active2 = this.#active;
|
|
27797
|
+
if (active2)
|
|
27798
|
+
this.#finish(active2, { status: "cancelled", reason: "Session closed" });
|
|
27020
27799
|
this.#channel.end();
|
|
27021
27800
|
this.#transport?.setSessionEventHandler(null);
|
|
27022
|
-
if (
|
|
27801
|
+
if (active2?.promptPhase === "submitted")
|
|
27023
27802
|
await this.#transport?.cancel().catch(() => void 0);
|
|
27024
27803
|
await Promise.all([this.#transport?.close(), this.#subagents.close()]);
|
|
27025
27804
|
this.#options.onClosed(this);
|
|
@@ -27065,7 +27844,7 @@ var AntigravityAdapter = class {
|
|
|
27065
27844
|
status: "unavailable",
|
|
27066
27845
|
error: { code: "invalidState", message: "Adapter is closed", retryable: false }
|
|
27067
27846
|
};
|
|
27068
|
-
const cwd =
|
|
27847
|
+
const cwd = path13.resolve(input.cwd ?? process.cwd());
|
|
27069
27848
|
const key = `${cwd}\0${input.purpose ?? "catalog"}`;
|
|
27070
27849
|
const cached2 = this.#cache.get(key);
|
|
27071
27850
|
const inFlight = this.#inflight.get(key);
|
|
@@ -27074,8 +27853,8 @@ var AntigravityAdapter = class {
|
|
|
27074
27853
|
if (!input.refresh && inFlight)
|
|
27075
27854
|
return inFlight;
|
|
27076
27855
|
if (input.refresh) {
|
|
27077
|
-
this.#cache.
|
|
27078
|
-
this.#
|
|
27856
|
+
this.#cache.clear();
|
|
27857
|
+
this.#inflight.clear();
|
|
27079
27858
|
}
|
|
27080
27859
|
const pending = this.#inspect(cwd, input.purpose).then((result) => {
|
|
27081
27860
|
if (!this.#closed && this.#inflight.get(key) === pending && result.status === "ready")
|
|
@@ -27135,7 +27914,7 @@ var AntigravityAdapter = class {
|
|
|
27135
27914
|
async open(input) {
|
|
27136
27915
|
if (this.#closed)
|
|
27137
27916
|
return err("invalidState", "Adapter is closed");
|
|
27138
|
-
if (!input.cwd || !
|
|
27917
|
+
if (!input.cwd || !path13.isAbsolute(input.cwd))
|
|
27139
27918
|
return err("invalidRequest", "cwd must be an absolute directory");
|
|
27140
27919
|
try {
|
|
27141
27920
|
if (!(await stat2(input.cwd)).isDirectory())
|
|
@@ -27145,9 +27924,10 @@ var AntigravityAdapter = class {
|
|
|
27145
27924
|
}
|
|
27146
27925
|
if (input.kind === "fork" || input.kind === "rollbackLastTurn") {
|
|
27147
27926
|
const source = [...this.#sessions].find((session2) => session2.nativeRef?.nativeSessionId === input.sourceRef.nativeSessionId);
|
|
27148
|
-
const
|
|
27149
|
-
|
|
27150
|
-
|
|
27927
|
+
const liveSource = input.kind === "fork" && source?.isActive ? source : void 0;
|
|
27928
|
+
const release = liveSource ? void 0 : source?.reserveHistoryOperation();
|
|
27929
|
+
if (source && !liveSource && !release)
|
|
27930
|
+
return err("sessionBusy", "Source Session is busy; retry when idle", true);
|
|
27151
27931
|
const common = {
|
|
27152
27932
|
harnessId,
|
|
27153
27933
|
adapterEnvironment: this.#environment,
|
|
@@ -27169,7 +27949,11 @@ var AntigravityAdapter = class {
|
|
|
27169
27949
|
}
|
|
27170
27950
|
};
|
|
27171
27951
|
try {
|
|
27172
|
-
return await (input.kind === "fork" ? forkAntigravitySession({
|
|
27952
|
+
return await (input.kind === "fork" ? forkAntigravitySession({
|
|
27953
|
+
...common,
|
|
27954
|
+
input,
|
|
27955
|
+
...liveSource ? { sourceSession: liveSource } : {}
|
|
27956
|
+
}) : rollbackAntigravityLastTurn({ ...common, input }));
|
|
27173
27957
|
} finally {
|
|
27174
27958
|
release?.();
|
|
27175
27959
|
}
|
|
@@ -27193,7 +27977,7 @@ var AntigravityAdapter = class {
|
|
|
27193
27977
|
model: input.model,
|
|
27194
27978
|
thinkingOptionId: input.thinkingOptionId,
|
|
27195
27979
|
permissionModeId: unattended || !input.permissionModeId && locator && typeof locator === "object" && !Array.isArray(locator) && locator.permissionModeId === SKIP ? harnessPermissionModeIdSchema.parse(SKIP) : input.permissionModeId,
|
|
27196
|
-
...input.kind === "resume" ? { nativeRef: input.nativeRef
|
|
27980
|
+
...input.kind === "resume" ? { nativeRef: input.nativeRef } : {},
|
|
27197
27981
|
unattended,
|
|
27198
27982
|
adapter: this.options,
|
|
27199
27983
|
onClosed: (closed) => this.#sessions.delete(closed)
|