@karlorz/codexhost-cli-win32-x64 0.14.0-5 → 0.15.0-1
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-web.js +133 -30
- package/app/cpa-live-voice-hook.js +36 -7
- package/app/desktop-controller.mjs +79 -39
- package/app/host-runtime.mjs +3234 -3054
- package/app/plugins/antigravity/plugin.mjs +292 -50
- package/app/plugins/claude-code/plugin.mjs +304 -108
- package/app/plugins/codebuddy/plugin.mjs +139 -25
- package/app/plugins/cursor-cli/plugin.mjs +139 -25
- package/app/plugins/grok/plugin.mjs +31 -18
- package/app/plugins/pi/plugin.mjs +31 -6
- package/app/plugins/workbuddy/plugin.mjs +139 -25
- package/app/plugins/zcode/plugin.mjs +28 -3
- package/app/renderer-extension.js +1265 -1041
- package/bin/codexhost.exe +0 -0
- package/libexec/codexhost-node-repl.exe +0 -0
- package/libexec/codexhost-shim.exe +0 -0
- package/libexec/codexhost-updater.exe +0 -0
- package/package.json +1 -1
|
@@ -413,8 +413,8 @@ import { spawn } from "node:child_process";
|
|
|
413
413
|
import { randomUUID as randomUUID6 } from "node:crypto";
|
|
414
414
|
import { readFile as readFile2, unlink } from "node:fs/promises";
|
|
415
415
|
import https3 from "node:https";
|
|
416
|
-
import
|
|
417
|
-
import
|
|
416
|
+
import os6 from "node:os";
|
|
417
|
+
import path11 from "node:path";
|
|
418
418
|
import readline from "node:readline";
|
|
419
419
|
|
|
420
420
|
// ../../../node_modules/zod/v4/classic/external.js
|
|
@@ -1183,10 +1183,10 @@ function mergeDefs(...defs) {
|
|
|
1183
1183
|
function cloneDef(schema) {
|
|
1184
1184
|
return mergeDefs(schema._zod.def);
|
|
1185
1185
|
}
|
|
1186
|
-
function getElementAtPath(obj,
|
|
1187
|
-
if (!
|
|
1186
|
+
function getElementAtPath(obj, path12) {
|
|
1187
|
+
if (!path12)
|
|
1188
1188
|
return obj;
|
|
1189
|
-
return
|
|
1189
|
+
return path12.reduce((acc, key) => acc?.[key], obj);
|
|
1190
1190
|
}
|
|
1191
1191
|
function promiseAllObject(promisesObj) {
|
|
1192
1192
|
const keys = Object.keys(promisesObj);
|
|
@@ -1595,11 +1595,11 @@ function explicitlyAborted(x, startIndex = 0) {
|
|
|
1595
1595
|
}
|
|
1596
1596
|
return false;
|
|
1597
1597
|
}
|
|
1598
|
-
function prefixIssues(
|
|
1598
|
+
function prefixIssues(path12, issues) {
|
|
1599
1599
|
return issues.map((iss) => {
|
|
1600
1600
|
var _a3;
|
|
1601
1601
|
(_a3 = iss).path ?? (_a3.path = []);
|
|
1602
|
-
iss.path.unshift(
|
|
1602
|
+
iss.path.unshift(path12);
|
|
1603
1603
|
return iss;
|
|
1604
1604
|
});
|
|
1605
1605
|
}
|
|
@@ -1746,16 +1746,16 @@ function flattenError(error51, mapper = (issue2) => issue2.message) {
|
|
|
1746
1746
|
}
|
|
1747
1747
|
function formatError(error51, mapper = (issue2) => issue2.message) {
|
|
1748
1748
|
const fieldErrors = { _errors: [] };
|
|
1749
|
-
const processError = (error52,
|
|
1749
|
+
const processError = (error52, path12 = []) => {
|
|
1750
1750
|
for (const issue2 of error52.issues) {
|
|
1751
1751
|
if (issue2.code === "invalid_union" && issue2.errors.length) {
|
|
1752
|
-
issue2.errors.map((issues) => processError({ issues }, [...
|
|
1752
|
+
issue2.errors.map((issues) => processError({ issues }, [...path12, ...issue2.path]));
|
|
1753
1753
|
} else if (issue2.code === "invalid_key") {
|
|
1754
|
-
processError({ issues: issue2.issues }, [...
|
|
1754
|
+
processError({ issues: issue2.issues }, [...path12, ...issue2.path]);
|
|
1755
1755
|
} else if (issue2.code === "invalid_element") {
|
|
1756
|
-
processError({ issues: issue2.issues }, [...
|
|
1756
|
+
processError({ issues: issue2.issues }, [...path12, ...issue2.path]);
|
|
1757
1757
|
} else {
|
|
1758
|
-
const fullpath = [...
|
|
1758
|
+
const fullpath = [...path12, ...issue2.path];
|
|
1759
1759
|
if (fullpath.length === 0) {
|
|
1760
1760
|
fieldErrors._errors.push(mapper(issue2));
|
|
1761
1761
|
} else {
|
|
@@ -1782,17 +1782,17 @@ function formatError(error51, mapper = (issue2) => issue2.message) {
|
|
|
1782
1782
|
}
|
|
1783
1783
|
function treeifyError(error51, mapper = (issue2) => issue2.message) {
|
|
1784
1784
|
const result = { errors: [] };
|
|
1785
|
-
const processError = (error52,
|
|
1785
|
+
const processError = (error52, path12 = []) => {
|
|
1786
1786
|
var _a3, _b;
|
|
1787
1787
|
for (const issue2 of error52.issues) {
|
|
1788
1788
|
if (issue2.code === "invalid_union" && issue2.errors.length) {
|
|
1789
|
-
issue2.errors.map((issues) => processError({ issues }, [...
|
|
1789
|
+
issue2.errors.map((issues) => processError({ issues }, [...path12, ...issue2.path]));
|
|
1790
1790
|
} else if (issue2.code === "invalid_key") {
|
|
1791
|
-
processError({ issues: issue2.issues }, [...
|
|
1791
|
+
processError({ issues: issue2.issues }, [...path12, ...issue2.path]);
|
|
1792
1792
|
} else if (issue2.code === "invalid_element") {
|
|
1793
|
-
processError({ issues: issue2.issues }, [...
|
|
1793
|
+
processError({ issues: issue2.issues }, [...path12, ...issue2.path]);
|
|
1794
1794
|
} else {
|
|
1795
|
-
const fullpath = [...
|
|
1795
|
+
const fullpath = [...path12, ...issue2.path];
|
|
1796
1796
|
if (fullpath.length === 0) {
|
|
1797
1797
|
result.errors.push(mapper(issue2));
|
|
1798
1798
|
continue;
|
|
@@ -1824,8 +1824,8 @@ function treeifyError(error51, mapper = (issue2) => issue2.message) {
|
|
|
1824
1824
|
}
|
|
1825
1825
|
function toDotPath(_path) {
|
|
1826
1826
|
const segs = [];
|
|
1827
|
-
const
|
|
1828
|
-
for (const seg of
|
|
1827
|
+
const path12 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
|
|
1828
|
+
for (const seg of path12) {
|
|
1829
1829
|
if (typeof seg === "number")
|
|
1830
1830
|
segs.push(`[${seg}]`);
|
|
1831
1831
|
else if (typeof seg === "symbol")
|
|
@@ -5053,8 +5053,8 @@ function az_default() {
|
|
|
5053
5053
|
}
|
|
5054
5054
|
|
|
5055
5055
|
// ../../../node_modules/zod/v4/locales/be.js
|
|
5056
|
-
function getBelarusianPlural(
|
|
5057
|
-
const absCount = Math.abs(
|
|
5056
|
+
function getBelarusianPlural(count3, one, few, many) {
|
|
5057
|
+
const absCount = Math.abs(count3);
|
|
5058
5058
|
const lastDigit = absCount % 10;
|
|
5059
5059
|
const lastTwoDigits = absCount % 100;
|
|
5060
5060
|
if (lastTwoDigits >= 11 && lastTwoDigits <= 19) {
|
|
@@ -7132,8 +7132,8 @@ function hu_default() {
|
|
|
7132
7132
|
}
|
|
7133
7133
|
|
|
7134
7134
|
// ../../../node_modules/zod/v4/locales/hy.js
|
|
7135
|
-
function getArmenianPlural(
|
|
7136
|
-
return Math.abs(
|
|
7135
|
+
function getArmenianPlural(count3, one, many) {
|
|
7136
|
+
return Math.abs(count3) === 1 ? one : many;
|
|
7137
7137
|
}
|
|
7138
7138
|
function withDefiniteArticle(word) {
|
|
7139
7139
|
if (!word)
|
|
@@ -9261,8 +9261,8 @@ function ro_default() {
|
|
|
9261
9261
|
}
|
|
9262
9262
|
|
|
9263
9263
|
// ../../../node_modules/zod/v4/locales/ru.js
|
|
9264
|
-
function getRussianPlural(
|
|
9265
|
-
const absCount = Math.abs(
|
|
9264
|
+
function getRussianPlural(count3, one, few, many) {
|
|
9265
|
+
const absCount = Math.abs(count3);
|
|
9266
9266
|
const lastDigit = absCount % 10;
|
|
9267
9267
|
const lastTwoDigits = absCount % 100;
|
|
9268
9268
|
if (lastTwoDigits >= 11 && lastTwoDigits <= 19) {
|
|
@@ -14517,13 +14517,13 @@ function resolveRef(ref, ctx) {
|
|
|
14517
14517
|
if (!ref.startsWith("#")) {
|
|
14518
14518
|
throw new Error("External $ref is not supported, only local refs (#/...) are allowed");
|
|
14519
14519
|
}
|
|
14520
|
-
const
|
|
14521
|
-
if (
|
|
14520
|
+
const path12 = ref.slice(1).split("/").filter(Boolean);
|
|
14521
|
+
if (path12.length === 0) {
|
|
14522
14522
|
return ctx.rootSchema;
|
|
14523
14523
|
}
|
|
14524
14524
|
const defsKey = ctx.version === "draft-2020-12" ? "$defs" : "definitions";
|
|
14525
|
-
if (
|
|
14526
|
-
const key =
|
|
14525
|
+
if (path12[0] === defsKey) {
|
|
14526
|
+
const key = path12[1];
|
|
14527
14527
|
if (!key || !ctx.defs[key]) {
|
|
14528
14528
|
throw new Error(`Reference not found: ${ref}`);
|
|
14529
14529
|
}
|
|
@@ -16823,6 +16823,12 @@ function historyPath(environment) {
|
|
|
16823
16823
|
const threadId = safeThreadId(environment);
|
|
16824
16824
|
return threadId ? path5.join(historyRoot(environment), `${threadId}.json`) : null;
|
|
16825
16825
|
}
|
|
16826
|
+
function antigravityHookDirectory(environment) {
|
|
16827
|
+
const threadId = safeThreadId(environment);
|
|
16828
|
+
if (!threadId || threadId === "." || threadId === "..")
|
|
16829
|
+
return null;
|
|
16830
|
+
return path5.join(historyRoot(environment), "hooks", threadId);
|
|
16831
|
+
}
|
|
16826
16832
|
function jsonTurn(turn) {
|
|
16827
16833
|
return JSON.parse(JSON.stringify(turn));
|
|
16828
16834
|
}
|
|
@@ -17011,8 +17017,11 @@ var AntigravityHistory = class _AntigravityHistory {
|
|
|
17011
17017
|
function nativeConversationDbPath(nativeSessionId, homedir2 = os3.homedir()) {
|
|
17012
17018
|
return path6.join(homedir2, ".gemini", "antigravity-cli", "conversations", `${nativeSessionId}.db`);
|
|
17013
17019
|
}
|
|
17020
|
+
function nativeBrainRoot(homedir2 = os3.homedir()) {
|
|
17021
|
+
return path6.join(homedir2, ".gemini", "antigravity-cli", "brain");
|
|
17022
|
+
}
|
|
17014
17023
|
function nativeBrainDirPath(nativeSessionId, homedir2 = os3.homedir()) {
|
|
17015
|
-
return path6.join(homedir2,
|
|
17024
|
+
return path6.join(nativeBrainRoot(homedir2), nativeSessionId);
|
|
17016
17025
|
}
|
|
17017
17026
|
async function cloneNativeConversationDb(sourceSessionId, derivedSessionId, retainedTurnsCountOrHomedir, homedirOption = os3.homedir()) {
|
|
17018
17027
|
let retainedTurnsCount;
|
|
@@ -18265,7 +18274,7 @@ var AntigravityQuestionBridge = class _AntigravityQuestionBridge {
|
|
|
18265
18274
|
this.#server.on("request", (request, response) => this.#receive(request, response));
|
|
18266
18275
|
}
|
|
18267
18276
|
static async create(options) {
|
|
18268
|
-
const directory = await mkdtemp2(path8.join(os4.tmpdir(), "codexhost-agy-question-"));
|
|
18277
|
+
const directory = options.directory ?? await mkdtemp2(path8.join(os4.tmpdir(), "codexhost-agy-question-"));
|
|
18269
18278
|
const bridge = new _AntigravityQuestionBridge(directory, options);
|
|
18270
18279
|
try {
|
|
18271
18280
|
await new Promise((resolve, reject) => {
|
|
@@ -18281,7 +18290,7 @@ var AntigravityQuestionBridge = class _AntigravityQuestionBridge {
|
|
|
18281
18290
|
throw new Error("Question bridge did not bind");
|
|
18282
18291
|
bridge.environment.CODEXHOST_AGY_QUESTION_URL = `http://127.0.0.1:${address.port}/question`;
|
|
18283
18292
|
const client = path8.join(directory, "question-hook.cjs");
|
|
18284
|
-
await mkdir3(path8.join(directory, ".agents"));
|
|
18293
|
+
await mkdir3(path8.join(directory, ".agents"), { recursive: true, mode: 448 });
|
|
18285
18294
|
await writeFile3(client, ANTIGRAVITY_QUESTION_HOOK_CLIENT, "utf8");
|
|
18286
18295
|
const quote = (value) => `'${value.replaceAll("'", "'\\''")}'`;
|
|
18287
18296
|
bridge.environment.CODEXHOST_AGY_QUESTION_NODE = `"${process.execPath.replaceAll("\\", "/")}"`;
|
|
@@ -18510,7 +18519,9 @@ var AntigravityQuestionBridge = class _AntigravityQuestionBridge {
|
|
|
18510
18519
|
this.#server.close(() => resolve());
|
|
18511
18520
|
this.#server.closeAllConnections();
|
|
18512
18521
|
});
|
|
18513
|
-
|
|
18522
|
+
if (this.#options.directory === void 0) {
|
|
18523
|
+
await rm3(this.directory, { recursive: true, force: true, maxRetries: 5, retryDelay: 50 });
|
|
18524
|
+
}
|
|
18514
18525
|
})();
|
|
18515
18526
|
return this.#disposal;
|
|
18516
18527
|
}
|
|
@@ -19004,12 +19015,195 @@ var AntigravitySubagents = class {
|
|
|
19004
19015
|
}
|
|
19005
19016
|
};
|
|
19006
19017
|
|
|
19018
|
+
// dist/usage-statistics.js
|
|
19019
|
+
import { lstat, opendir } from "node:fs/promises";
|
|
19020
|
+
import os5 from "node:os";
|
|
19021
|
+
import path10 from "node:path";
|
|
19022
|
+
|
|
19023
|
+
// ../../harness-adapter/dist/usage-statistics.js
|
|
19024
|
+
import { createReadStream } from "node:fs";
|
|
19025
|
+
import { createInterface } from "node:readline";
|
|
19026
|
+
var HarnessUsageSourceChangedError = class extends Error {
|
|
19027
|
+
code = "HARNESS_USAGE_SOURCE_CHANGED";
|
|
19028
|
+
/** Plugins may bundle their own copy of this contract, so instanceof is insufficient. */
|
|
19029
|
+
static is(error51) {
|
|
19030
|
+
return typeof error51 === "object" && error51 !== null && "code" in error51 && error51.code === "HARNESS_USAGE_SOURCE_CHANGED";
|
|
19031
|
+
}
|
|
19032
|
+
};
|
|
19033
|
+
var MAX_SESSION_ID_LENGTH = 512;
|
|
19034
|
+
var MAX_CWD_LENGTH = 4096;
|
|
19035
|
+
var MAX_SESSION_TITLE_LENGTH = 200;
|
|
19036
|
+
function usageSessionTitle(value) {
|
|
19037
|
+
if (typeof value !== "string")
|
|
19038
|
+
return void 0;
|
|
19039
|
+
const normalized = value.replaceAll("\0", "").replaceAll(/\s+/gu, " ").trim();
|
|
19040
|
+
if (!normalized)
|
|
19041
|
+
return void 0;
|
|
19042
|
+
if (normalized.length <= MAX_SESSION_TITLE_LENGTH)
|
|
19043
|
+
return normalized;
|
|
19044
|
+
let title = "";
|
|
19045
|
+
for (const character of normalized) {
|
|
19046
|
+
if (title.length + character.length >= MAX_SESSION_TITLE_LENGTH)
|
|
19047
|
+
break;
|
|
19048
|
+
title += character;
|
|
19049
|
+
}
|
|
19050
|
+
return `${title.trimEnd()}…`;
|
|
19051
|
+
}
|
|
19052
|
+
function sessionIdOk(value) {
|
|
19053
|
+
return typeof value === "string" && value.length > 0 && value.length <= MAX_SESSION_ID_LENGTH;
|
|
19054
|
+
}
|
|
19055
|
+
function cwdOk(value) {
|
|
19056
|
+
return typeof value === "string" && value.length > 0 && value.length <= MAX_CWD_LENGTH && !value.includes("\0") && (value.startsWith("/") || /^[A-Za-z]:[\\/]/u.test(value) || value.startsWith("\\\\"));
|
|
19057
|
+
}
|
|
19058
|
+
function withUsageSession(entry, session) {
|
|
19059
|
+
const sessionId = sessionIdOk(session.sessionId) ? session.sessionId : void 0;
|
|
19060
|
+
const cwd = cwdOk(session.cwd) ? session.cwd : void 0;
|
|
19061
|
+
const sessionTitle = sessionId !== void 0 ? usageSessionTitle(session.title) : void 0;
|
|
19062
|
+
if (sessionId === void 0 && cwd === void 0)
|
|
19063
|
+
return entry;
|
|
19064
|
+
return {
|
|
19065
|
+
...entry,
|
|
19066
|
+
...sessionId !== void 0 ? { sessionId } : {},
|
|
19067
|
+
...cwd !== void 0 ? { cwd } : {},
|
|
19068
|
+
...sessionTitle !== void 0 ? { sessionTitle } : {}
|
|
19069
|
+
};
|
|
19070
|
+
}
|
|
19071
|
+
async function* jsonlRecords(file2, marker, signal) {
|
|
19072
|
+
const lines = createInterface({
|
|
19073
|
+
input: createReadStream(file2, { encoding: "utf8", signal }),
|
|
19074
|
+
crlfDelay: Infinity
|
|
19075
|
+
});
|
|
19076
|
+
for await (const line of lines) {
|
|
19077
|
+
if (!line.includes(marker))
|
|
19078
|
+
continue;
|
|
19079
|
+
let value;
|
|
19080
|
+
try {
|
|
19081
|
+
value = JSON.parse(line);
|
|
19082
|
+
} catch {
|
|
19083
|
+
continue;
|
|
19084
|
+
}
|
|
19085
|
+
if (typeof value === "object" && value !== null && !Array.isArray(value)) {
|
|
19086
|
+
yield value;
|
|
19087
|
+
}
|
|
19088
|
+
}
|
|
19089
|
+
}
|
|
19090
|
+
function nativeTimeMs(value) {
|
|
19091
|
+
const time3 = typeof value === "number" ? value : typeof value === "string" ? Date.parse(value) : Number.NaN;
|
|
19092
|
+
return Number.isFinite(time3) && time3 > 0 ? Math.floor(time3) : null;
|
|
19093
|
+
}
|
|
19094
|
+
|
|
19095
|
+
// dist/usage-statistics.js
|
|
19096
|
+
function count2(value) {
|
|
19097
|
+
return typeof value === "number" && Number.isSafeInteger(value) && value >= 0 ? value : null;
|
|
19098
|
+
}
|
|
19099
|
+
function antigravityHome(environment) {
|
|
19100
|
+
return (process.platform === "win32" ? environment.USERPROFILE : environment.HOME) || os5.homedir();
|
|
19101
|
+
}
|
|
19102
|
+
function transcriptPath(brainRoot, conversationId) {
|
|
19103
|
+
return path10.join(brainRoot, conversationId, ".system_generated", "logs", "transcript.jsonl");
|
|
19104
|
+
}
|
|
19105
|
+
function isMissing(error51) {
|
|
19106
|
+
const code = error51?.code;
|
|
19107
|
+
return code === "ENOENT" || code === "ENOTDIR";
|
|
19108
|
+
}
|
|
19109
|
+
async function lstatIfPresent(target) {
|
|
19110
|
+
try {
|
|
19111
|
+
return await lstat(target);
|
|
19112
|
+
} catch (error51) {
|
|
19113
|
+
if (isMissing(error51))
|
|
19114
|
+
return null;
|
|
19115
|
+
throw error51;
|
|
19116
|
+
}
|
|
19117
|
+
}
|
|
19118
|
+
async function transcriptFingerprint(file2) {
|
|
19119
|
+
const logs = path10.dirname(file2);
|
|
19120
|
+
for (const directory of [path10.dirname(logs), logs]) {
|
|
19121
|
+
if (!(await lstatIfPresent(directory))?.isDirectory())
|
|
19122
|
+
return null;
|
|
19123
|
+
}
|
|
19124
|
+
const info = await lstatIfPresent(file2);
|
|
19125
|
+
return info?.isFile() && info.size > 0 ? `${info.ino}:${info.size}:${info.mtimeMs}` : null;
|
|
19126
|
+
}
|
|
19127
|
+
async function listTranscripts(brainRoot, signal) {
|
|
19128
|
+
signal.throwIfAborted();
|
|
19129
|
+
const conversations = await opendir(brainRoot).catch((error51) => {
|
|
19130
|
+
if (error51.code === "ENOENT")
|
|
19131
|
+
return null;
|
|
19132
|
+
throw error51;
|
|
19133
|
+
});
|
|
19134
|
+
if (!conversations)
|
|
19135
|
+
return [];
|
|
19136
|
+
const sources = [];
|
|
19137
|
+
for await (const entry of conversations) {
|
|
19138
|
+
signal.throwIfAborted();
|
|
19139
|
+
if (!entry.isDirectory())
|
|
19140
|
+
continue;
|
|
19141
|
+
const file2 = transcriptPath(brainRoot, entry.name);
|
|
19142
|
+
const fingerprint = await transcriptFingerprint(file2);
|
|
19143
|
+
if (fingerprint)
|
|
19144
|
+
sources.push({ id: file2, fingerprint });
|
|
19145
|
+
}
|
|
19146
|
+
return sources;
|
|
19147
|
+
}
|
|
19148
|
+
async function readAntigravityUsage(file2, signal) {
|
|
19149
|
+
const sessionId = path10.basename(path10.resolve(file2, "..", "..", ".."));
|
|
19150
|
+
const requests = /* @__PURE__ */ new Map();
|
|
19151
|
+
for await (const record2 of jsonlRecords(file2, '"input_tokens"', signal)) {
|
|
19152
|
+
if (record2.type !== "PLANNER_RESPONSE")
|
|
19153
|
+
continue;
|
|
19154
|
+
const step = count2(record2.step_index);
|
|
19155
|
+
const input = count2(record2.input_tokens);
|
|
19156
|
+
const output = count2(record2.output_tokens);
|
|
19157
|
+
const cached2 = count2(record2.cache_read_tokens);
|
|
19158
|
+
const at = nativeTimeMs(record2.created_at);
|
|
19159
|
+
if (step === null || input === null || output === null || at === null)
|
|
19160
|
+
continue;
|
|
19161
|
+
requests.set(step, withUsageSession({
|
|
19162
|
+
id: `${String(record2.created_at)}:${step}:${input}:${cached2 ?? "-"}:${output}`,
|
|
19163
|
+
occurredAtMs: at,
|
|
19164
|
+
inputTokens: input + (cached2 ?? 0),
|
|
19165
|
+
...cached2 !== null ? { cachedInputTokens: cached2 } : {},
|
|
19166
|
+
outputTokens: output
|
|
19167
|
+
}, { sessionId }));
|
|
19168
|
+
}
|
|
19169
|
+
return [...requests.values()];
|
|
19170
|
+
}
|
|
19171
|
+
function createAntigravityUsageStatistics(environment) {
|
|
19172
|
+
const brainRoot = nativeBrainRoot(antigravityHome(environment));
|
|
19173
|
+
let listed = /* @__PURE__ */ new Map();
|
|
19174
|
+
return Object.freeze({
|
|
19175
|
+
async listSources(signal) {
|
|
19176
|
+
const sources = await listTranscripts(brainRoot, signal);
|
|
19177
|
+
listed = new Map(sources.map(({ id, fingerprint }) => [id, fingerprint]));
|
|
19178
|
+
return sources;
|
|
19179
|
+
},
|
|
19180
|
+
async readSource(id, signal) {
|
|
19181
|
+
const expected = listed.get(id);
|
|
19182
|
+
let entries;
|
|
19183
|
+
try {
|
|
19184
|
+
entries = await readAntigravityUsage(id, signal);
|
|
19185
|
+
} catch (error51) {
|
|
19186
|
+
if (expected !== void 0 && isMissing(error51)) {
|
|
19187
|
+
throw new HarnessUsageSourceChangedError("Antigravity transcript disappeared before reading; refresh to retry");
|
|
19188
|
+
}
|
|
19189
|
+
throw error51;
|
|
19190
|
+
}
|
|
19191
|
+
if (expected !== void 0 && await transcriptFingerprint(id) !== expected) {
|
|
19192
|
+
throw new HarnessUsageSourceChangedError("Antigravity transcript changed while reading; refresh to retry");
|
|
19193
|
+
}
|
|
19194
|
+
return entries;
|
|
19195
|
+
}
|
|
19196
|
+
});
|
|
19197
|
+
}
|
|
19198
|
+
|
|
19007
19199
|
// dist/antigravity-adapter.js
|
|
19008
19200
|
var antigravityHarnessId = harnessIdSchema.parse("antigravity");
|
|
19009
19201
|
var DEFAULT_INSPECT_TIMEOUT_MS = 2e4;
|
|
19010
19202
|
var DEFAULT_PRINT_TIMEOUT = "30m";
|
|
19011
19203
|
var DEFAULT_TOOL_OUTPUT_LIMIT = 64e3;
|
|
19012
19204
|
var DEFAULT_SUBAGENT_OBSERVATION_TIMEOUT_MS = 3e4;
|
|
19205
|
+
var NATIVE_EXIT_GRACE_MS = 2e3;
|
|
19206
|
+
var DEFAULT_TURN_CLEANUP_WAIT_MS = 5e3;
|
|
19013
19207
|
var CONTEXT_USAGE_TIMEOUT_MS = 8e3;
|
|
19014
19208
|
var CONTEXT_USAGE_RETRY_MS = 100;
|
|
19015
19209
|
var TRAJECTORY_TIMEOUT_MS = 2e3;
|
|
@@ -19038,8 +19232,8 @@ function mergePendingStep(pending, step) {
|
|
|
19038
19232
|
};
|
|
19039
19233
|
}
|
|
19040
19234
|
function sameFile(left, right) {
|
|
19041
|
-
const a =
|
|
19042
|
-
const b =
|
|
19235
|
+
const a = path11.resolve(left);
|
|
19236
|
+
const b = path11.resolve(right);
|
|
19043
19237
|
return process.platform === "win32" ? a.toLowerCase() === b.toLowerCase() : a === b;
|
|
19044
19238
|
}
|
|
19045
19239
|
function resolveAntigravityContextWindow(modelId, reportedWindow) {
|
|
@@ -19067,12 +19261,28 @@ function errorMessage(error51) {
|
|
|
19067
19261
|
function invalidState(message) {
|
|
19068
19262
|
return { code: "invalidState", message, retryable: false };
|
|
19069
19263
|
}
|
|
19264
|
+
function settledWithin(promise2, timeoutMs) {
|
|
19265
|
+
return new Promise((resolve) => {
|
|
19266
|
+
const timer = setTimeout(resolve, timeoutMs);
|
|
19267
|
+
const settle = () => {
|
|
19268
|
+
clearTimeout(timer);
|
|
19269
|
+
resolve();
|
|
19270
|
+
};
|
|
19271
|
+
void promise2.then(settle, settle);
|
|
19272
|
+
});
|
|
19273
|
+
}
|
|
19070
19274
|
var ANTIGRAVITY_WORKSPACE_FILE_INSTRUCTION = "[System Instruction: When creating new files in the workspace, you MUST use the write_to_file tool. When modifying existing files, use the replace_file_content tool. CRITICAL: NEVER include ArtifactMetadata when calling write_to_file for workspace files (ArtifactMetadata is strictly reserved for artifacts in the brain directory, and providing it for workspace files causes a path validation rejection). Do NOT use terminal commands (such as Set-Content, Out-File, echo, or cat) to create or write code files. For clarification, ask_question is connected to the codexhost Desktop through a Hook. Use single-choice or text questions. The Hook returns the actual user response in its reason while blocking the native auto-skip behavior; do not retry merely because the native tool reports it was blocked.]\n\n";
|
|
19071
|
-
function
|
|
19275
|
+
function antigravityWorkingDirectoryInstruction(cwd) {
|
|
19276
|
+
return `[System Instruction: The project working directory is ${JSON.stringify(cwd)}. Run terminal commands and resolve relative file paths in this directory unless the task requires another one.]
|
|
19277
|
+
|
|
19278
|
+
`;
|
|
19279
|
+
}
|
|
19280
|
+
function formatAntigravityTurnPrompt(text, cwd) {
|
|
19072
19281
|
if (text.startsWith("/") || text.includes("ArtifactMetadata")) {
|
|
19073
19282
|
return text;
|
|
19074
19283
|
}
|
|
19075
|
-
|
|
19284
|
+
const workingDirectory = cwd ? antigravityWorkingDirectoryInstruction(cwd) : "";
|
|
19285
|
+
return `${ANTIGRAVITY_WORKSPACE_FILE_INSTRUCTION}${workingDirectory}${text}`;
|
|
19076
19286
|
}
|
|
19077
19287
|
function permissionDeniedTurnError(nativeMode, denial) {
|
|
19078
19288
|
const mode = nativeMode ? ` '${nativeMode}'` : "";
|
|
@@ -19174,14 +19384,15 @@ async function pollAntigravityContextUsage(logPath, conversationId, modelId, isD
|
|
|
19174
19384
|
}
|
|
19175
19385
|
return null;
|
|
19176
19386
|
}
|
|
19177
|
-
function hostUsage(value, modelId) {
|
|
19387
|
+
function hostUsage(value, modelId, scope) {
|
|
19178
19388
|
if (!value)
|
|
19179
19389
|
return null;
|
|
19180
19390
|
const inputTokens = safeToken(value.input_tokens);
|
|
19181
19391
|
const outputTokens = safeToken(value.output_tokens);
|
|
19182
19392
|
const reasoningOutputTokens = safeToken(value.thinking_tokens);
|
|
19183
19393
|
const totalTokens = safeToken(value.total_tokens);
|
|
19184
|
-
const
|
|
19394
|
+
const requestPromptTokens = scope === "request" && inputTokens !== void 0 ? inputTokens + (safeToken(value.cache_read_tokens) ?? 0) : void 0;
|
|
19395
|
+
const contextUsedTokens = safeToken(value.context_used_tokens ?? value.estimated_tokens_used) ?? requestPromptTokens;
|
|
19185
19396
|
const rawWindow = safeToken(value.context_window_tokens ?? value.max_context_tokens);
|
|
19186
19397
|
const contextWindowTokens = contextUsedTokens !== void 0 || rawWindow !== void 0 ? resolveAntigravityContextWindow(modelId, rawWindow) : void 0;
|
|
19187
19398
|
const usage = {
|
|
@@ -19258,6 +19469,7 @@ var AntigravitySession = class {
|
|
|
19258
19469
|
#printTimeout;
|
|
19259
19470
|
#toolOutputLimit;
|
|
19260
19471
|
#subagentObservationTimeoutMs;
|
|
19472
|
+
#turnCleanupWaitMs;
|
|
19261
19473
|
#history;
|
|
19262
19474
|
#subagentObservers = /* @__PURE__ */ new Set();
|
|
19263
19475
|
#active = null;
|
|
@@ -19284,6 +19496,7 @@ var AntigravitySession = class {
|
|
|
19284
19496
|
this.#thinkingOptionId = input.thinkingOptionId ?? input.history.thinkingOptionId;
|
|
19285
19497
|
this.#toolOutputLimit = input.toolOutputLimit;
|
|
19286
19498
|
this.#subagentObservationTimeoutMs = input.subagentObservationTimeoutMs;
|
|
19499
|
+
this.#turnCleanupWaitMs = input.turnCleanupWaitMs;
|
|
19287
19500
|
this.#onClosed = input.onClosed;
|
|
19288
19501
|
this.initialState = this.#state();
|
|
19289
19502
|
this.outputs = this.#channel.outputs;
|
|
@@ -19361,7 +19574,10 @@ var AntigravitySession = class {
|
|
|
19361
19574
|
};
|
|
19362
19575
|
}
|
|
19363
19576
|
let questions;
|
|
19364
|
-
|
|
19577
|
+
const hookDirectory = antigravityHookDirectory(this.#environment);
|
|
19578
|
+
const previousTurn = hookDirectory ? this.#questionCleanup : Promise.resolve();
|
|
19579
|
+
this.#preparingQuestions = previousTurn.then(() => AntigravityQuestionBridge.create({
|
|
19580
|
+
...hookDirectory ? { directory: hookDirectory } : {},
|
|
19365
19581
|
turnId: command.turnId,
|
|
19366
19582
|
nativeSessionId: () => this.#active?.command === command && !this.#active.cancellationRequested ? this.#nativeRef?.nativeSessionId : void 0,
|
|
19367
19583
|
schedule: (action) => {
|
|
@@ -19384,7 +19600,7 @@ var AntigravitySession = class {
|
|
|
19384
19600
|
}
|
|
19385
19601
|
this.#channel.emit(output);
|
|
19386
19602
|
}
|
|
19387
|
-
});
|
|
19603
|
+
}));
|
|
19388
19604
|
try {
|
|
19389
19605
|
questions = await this.#preparingQuestions;
|
|
19390
19606
|
} catch (error51) {
|
|
@@ -19404,7 +19620,7 @@ var AntigravitySession = class {
|
|
|
19404
19620
|
return { ok: false, error: invalidState("Antigravity Session is closed") };
|
|
19405
19621
|
}
|
|
19406
19622
|
const environment = { ...this.#environment, ...questions.environment };
|
|
19407
|
-
const logPath =
|
|
19623
|
+
const logPath = path11.join(os6.tmpdir(), `codexhost-antigravity-${randomUUID6()}.log`);
|
|
19408
19624
|
const arguments_ = [
|
|
19409
19625
|
"--input-format",
|
|
19410
19626
|
"stream-json",
|
|
@@ -19525,7 +19741,7 @@ ${line}`).slice(-8e3);
|
|
|
19525
19741
|
});
|
|
19526
19742
|
});
|
|
19527
19743
|
try {
|
|
19528
|
-
const turnPrompt = formatAntigravityTurnPrompt(text);
|
|
19744
|
+
const turnPrompt = formatAntigravityTurnPrompt(text, this.#cwd);
|
|
19529
19745
|
if (child.stdin.writable) {
|
|
19530
19746
|
child.stdin.write(`${JSON.stringify({ event: "user", message: { content: turnPrompt } })}
|
|
19531
19747
|
`, () => void 0);
|
|
@@ -19609,7 +19825,7 @@ ${line}`).slice(-8e3);
|
|
|
19609
19825
|
if (event.step_update.conversation_id !== this.#nativeRef?.nativeSessionId)
|
|
19610
19826
|
return;
|
|
19611
19827
|
await this.#handleStep(active, event.step_update);
|
|
19612
|
-
const usage = hostUsage(event.step_update.usage, active.model?.id);
|
|
19828
|
+
const usage = hostUsage(event.step_update.usage, active.model?.id, "request");
|
|
19613
19829
|
if (usage)
|
|
19614
19830
|
this.#publishUsage(active, usage);
|
|
19615
19831
|
this.#ensureContextUsage(active, event.step_update.conversation_id);
|
|
@@ -19635,7 +19851,7 @@ ${line}`).slice(-8e3);
|
|
|
19635
19851
|
});
|
|
19636
19852
|
return;
|
|
19637
19853
|
}
|
|
19638
|
-
const usage = hostUsage(event.result.usage, active.model?.id);
|
|
19854
|
+
const usage = hostUsage(event.result.usage, active.model?.id, "conversation");
|
|
19639
19855
|
if (usage)
|
|
19640
19856
|
this.#publishUsage(active, usage);
|
|
19641
19857
|
this.#ensureContextUsage(active, event.result.conversation_id);
|
|
@@ -19872,8 +20088,9 @@ ${line}`).slice(-8e3);
|
|
|
19872
20088
|
await active.subagents.settled;
|
|
19873
20089
|
if (active.process.stdin.writable)
|
|
19874
20090
|
active.process.stdin.end();
|
|
19875
|
-
const timer = setTimeout(() => active.process.kill(),
|
|
19876
|
-
await active.exited
|
|
20091
|
+
const timer = setTimeout(() => active.process.kill(), NATIVE_EXIT_GRACE_MS);
|
|
20092
|
+
await settledWithin(active.exited, NATIVE_EXIT_GRACE_MS + this.#turnCleanupWaitMs);
|
|
20093
|
+
clearTimeout(timer);
|
|
19877
20094
|
await active.questions.dispose();
|
|
19878
20095
|
this.#subagentObservers.delete(active.subagents);
|
|
19879
20096
|
}).catch(() => void 0);
|
|
@@ -20050,6 +20267,7 @@ function historySubagentState(history, id) {
|
|
|
20050
20267
|
var AntigravityAdapter = class {
|
|
20051
20268
|
commandCatalog = ANTIGRAVITY_COMMAND_CATALOG;
|
|
20052
20269
|
harnessId = antigravityHarnessId;
|
|
20270
|
+
usageStatistics;
|
|
20053
20271
|
subagents = {
|
|
20054
20272
|
readSnapshot: async (input) => {
|
|
20055
20273
|
if (this.#closed || input.parent.harnessId !== this.harnessId || !nativeSubagentIdSchema.safeParse(input.nativeSubagentId).success) {
|
|
@@ -20082,6 +20300,7 @@ var AntigravityAdapter = class {
|
|
|
20082
20300
|
#sessions = /* @__PURE__ */ new Set();
|
|
20083
20301
|
#toolOutputLimit;
|
|
20084
20302
|
#subagentObservationTimeoutMs;
|
|
20303
|
+
#turnCleanupWaitMs;
|
|
20085
20304
|
#closed = false;
|
|
20086
20305
|
#quota = null;
|
|
20087
20306
|
#quotaCwd = null;
|
|
@@ -20090,6 +20309,7 @@ var AntigravityAdapter = class {
|
|
|
20090
20309
|
constructor(options = {}) {
|
|
20091
20310
|
this.#command = options.command;
|
|
20092
20311
|
this.#environment = options.environment ?? process.env;
|
|
20312
|
+
this.usageStatistics = createAntigravityUsageStatistics(this.#environment);
|
|
20093
20313
|
this.#inspectTimeoutMs = options.inspectTimeoutMs ?? DEFAULT_INSPECT_TIMEOUT_MS;
|
|
20094
20314
|
this.#printTimeout = options.printTimeout ?? DEFAULT_PRINT_TIMEOUT;
|
|
20095
20315
|
this.#toolOutputLimit = options.toolOutputLimit ?? DEFAULT_TOOL_OUTPUT_LIMIT;
|
|
@@ -20098,12 +20318,17 @@ var AntigravityAdapter = class {
|
|
|
20098
20318
|
throw new RangeError("subagentObservationTimeoutMs must be a finite positive number");
|
|
20099
20319
|
}
|
|
20100
20320
|
this.#subagentObservationTimeoutMs = subagentObservationTimeoutMs;
|
|
20321
|
+
const turnCleanupWaitMs = options.turnCleanupWaitMs ?? DEFAULT_TURN_CLEANUP_WAIT_MS;
|
|
20322
|
+
if (!Number.isFinite(turnCleanupWaitMs) || turnCleanupWaitMs < 0) {
|
|
20323
|
+
throw new RangeError("turnCleanupWaitMs must be a finite non-negative number");
|
|
20324
|
+
}
|
|
20325
|
+
this.#turnCleanupWaitMs = turnCleanupWaitMs;
|
|
20101
20326
|
}
|
|
20102
20327
|
async inspect(input = {}) {
|
|
20103
20328
|
if (this.#closed) {
|
|
20104
20329
|
return { status: "unavailable", error: invalidState("Antigravity Adapter is closed") };
|
|
20105
20330
|
}
|
|
20106
|
-
const cwd =
|
|
20331
|
+
const cwd = path11.resolve(input.cwd ?? process.cwd());
|
|
20107
20332
|
const inFlight = this.#inspectionInFlight.get(cwd);
|
|
20108
20333
|
if (inFlight)
|
|
20109
20334
|
return inFlight;
|
|
@@ -20246,7 +20471,7 @@ var AntigravityAdapter = class {
|
|
|
20246
20471
|
}
|
|
20247
20472
|
};
|
|
20248
20473
|
}
|
|
20249
|
-
const cwd =
|
|
20474
|
+
const cwd = path11.resolve(input.cwd);
|
|
20250
20475
|
let catalog = this.#inspectionCache.get(cwd)?.catalog;
|
|
20251
20476
|
if (!catalog) {
|
|
20252
20477
|
const inspection = await this.inspect({ cwd: input.cwd });
|
|
@@ -20282,6 +20507,7 @@ var AntigravityAdapter = class {
|
|
|
20282
20507
|
...params.thinkingOptionId ? { thinkingOptionId: params.thinkingOptionId } : {},
|
|
20283
20508
|
toolOutputLimit: this.#toolOutputLimit,
|
|
20284
20509
|
subagentObservationTimeoutMs: this.#subagentObservationTimeoutMs,
|
|
20510
|
+
turnCleanupWaitMs: this.#turnCleanupWaitMs,
|
|
20285
20511
|
onClosed: () => this.#sessions.delete(session2)
|
|
20286
20512
|
});
|
|
20287
20513
|
this.#sessions.add(session2);
|
|
@@ -20318,6 +20544,7 @@ var AntigravityAdapter = class {
|
|
|
20318
20544
|
...params.thinkingOptionId ? { thinkingOptionId: params.thinkingOptionId } : {},
|
|
20319
20545
|
toolOutputLimit: this.#toolOutputLimit,
|
|
20320
20546
|
subagentObservationTimeoutMs: this.#subagentObservationTimeoutMs,
|
|
20547
|
+
turnCleanupWaitMs: this.#turnCleanupWaitMs,
|
|
20321
20548
|
onClosed: () => this.#sessions.delete(session2)
|
|
20322
20549
|
});
|
|
20323
20550
|
this.#sessions.add(session2);
|
|
@@ -20375,6 +20602,7 @@ var AntigravityAdapter = class {
|
|
|
20375
20602
|
...thinkingOptionId ? { thinkingOptionId } : {},
|
|
20376
20603
|
toolOutputLimit: this.#toolOutputLimit,
|
|
20377
20604
|
subagentObservationTimeoutMs: this.#subagentObservationTimeoutMs,
|
|
20605
|
+
turnCleanupWaitMs: this.#turnCleanupWaitMs,
|
|
20378
20606
|
onClosed: () => this.#sessions.delete(session)
|
|
20379
20607
|
});
|
|
20380
20608
|
this.#sessions.add(session);
|
|
@@ -20434,11 +20662,23 @@ function createAntigravityInstallation(environment, command, dependencies = {})
|
|
|
20434
20662
|
|
|
20435
20663
|
// dist/plugin.js
|
|
20436
20664
|
var ANTIGRAVITY_COMMAND_ENV = "CODEXHOST_ANTIGRAVITY_COMMAND";
|
|
20665
|
+
var ANTIGRAVITY_DISABLE_AUTO_UPDATE_ENV = "AGY_CLI_DISABLE_AUTO_UPDATE";
|
|
20666
|
+
function antigravityProcessEnvironment(environment, platform) {
|
|
20667
|
+
if (platform !== "win32" && platform !== "darwin")
|
|
20668
|
+
return environment;
|
|
20669
|
+
const isWindows = platform === "win32";
|
|
20670
|
+
const matchesSwitch = (name) => isWindows ? name.toUpperCase() === ANTIGRAVITY_DISABLE_AUTO_UPDATE_ENV : name === ANTIGRAVITY_DISABLE_AUTO_UPDATE_ENV;
|
|
20671
|
+
const entries = Object.entries(environment);
|
|
20672
|
+
const configured = entries.some(([name, value]) => matchesSwitch(name) && value !== void 0);
|
|
20673
|
+
const hasUndefinedSwitch = entries.some(([name, value]) => matchesSwitch(name) && value === void 0);
|
|
20674
|
+
const cleanEnvironment = hasUndefinedSwitch ? Object.fromEntries(entries.filter(([name, value]) => !matchesSwitch(name) || value !== void 0)) : environment;
|
|
20675
|
+
return configured ? cleanEnvironment : { ...cleanEnvironment, [ANTIGRAVITY_DISABLE_AUTO_UPDATE_ENV]: "true" };
|
|
20676
|
+
}
|
|
20437
20677
|
function createHarnessAdapter(context) {
|
|
20438
20678
|
const environment = { ...context.environment };
|
|
20439
20679
|
return Object.assign(new AntigravityAdapter({
|
|
20440
20680
|
...environment[ANTIGRAVITY_COMMAND_ENV] ? { command: environment[ANTIGRAVITY_COMMAND_ENV] } : {},
|
|
20441
|
-
environment
|
|
20681
|
+
environment: antigravityProcessEnvironment(environment, context.platform)
|
|
20442
20682
|
}), {
|
|
20443
20683
|
install: createHarnessInstaller(environment, {
|
|
20444
20684
|
posix: "https://antigravity.google/cli/install.sh",
|
|
@@ -20455,6 +20695,8 @@ async function warmup(adapter) {
|
|
|
20455
20695
|
}
|
|
20456
20696
|
export {
|
|
20457
20697
|
ANTIGRAVITY_COMMAND_ENV,
|
|
20698
|
+
ANTIGRAVITY_DISABLE_AUTO_UPDATE_ENV,
|
|
20699
|
+
antigravityProcessEnvironment,
|
|
20458
20700
|
createHarnessAdapter,
|
|
20459
20701
|
warmup
|
|
20460
20702
|
};
|