@ycodium-ai/agent-antigravity 0.2.5029 → 0.2.5093
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/assets/ui.js +2 -20
- package/dist/index.js +805 -615
- package/package.json +7 -4
package/dist/index.js
CHANGED
|
@@ -553,34 +553,34 @@ var require_yauzl = __commonJS({
|
|
|
553
553
|
exports.LocalFileHeader = LocalFileHeader;
|
|
554
554
|
exports.RandomAccessReader = RandomAccessReader;
|
|
555
555
|
function openPromise(path, options2) {
|
|
556
|
-
return new Promise((
|
|
556
|
+
return new Promise((resolve7, reject) => {
|
|
557
557
|
open4(path, { ...options2, lazyEntries: true }, function(err, zipfile) {
|
|
558
558
|
if (err) return reject(err);
|
|
559
|
-
|
|
559
|
+
resolve7(zipfile);
|
|
560
560
|
});
|
|
561
561
|
});
|
|
562
562
|
}
|
|
563
563
|
function fromFdPromise(fd, options2) {
|
|
564
|
-
return new Promise((
|
|
564
|
+
return new Promise((resolve7, reject) => {
|
|
565
565
|
fromFd(fd, { ...options2, lazyEntries: true }, function(err, zipfile) {
|
|
566
566
|
if (err) return reject(err);
|
|
567
|
-
|
|
567
|
+
resolve7(zipfile);
|
|
568
568
|
});
|
|
569
569
|
});
|
|
570
570
|
}
|
|
571
571
|
function fromBufferPromise(buffer, options2) {
|
|
572
|
-
return new Promise((
|
|
572
|
+
return new Promise((resolve7, reject) => {
|
|
573
573
|
fromBuffer(buffer, { ...options2, lazyEntries: true }, function(err, zipfile) {
|
|
574
574
|
if (err) return reject(err);
|
|
575
|
-
|
|
575
|
+
resolve7(zipfile);
|
|
576
576
|
});
|
|
577
577
|
});
|
|
578
578
|
}
|
|
579
579
|
function fromRandomAccessReaderPromise(reader, totalSize, options2) {
|
|
580
|
-
return new Promise((
|
|
580
|
+
return new Promise((resolve7, reject) => {
|
|
581
581
|
fromRandomAccessReader(reader, totalSize, { ...options2, lazyEntries: true }, function(err, zipfile) {
|
|
582
582
|
if (err) return reject(err);
|
|
583
|
-
|
|
583
|
+
resolve7(zipfile);
|
|
584
584
|
});
|
|
585
585
|
});
|
|
586
586
|
}
|
|
@@ -864,15 +864,15 @@ var require_yauzl = __commonJS({
|
|
|
864
864
|
if (self.autoClose) self.close();
|
|
865
865
|
}
|
|
866
866
|
function onEntry(entry) {
|
|
867
|
-
let { resolve:
|
|
867
|
+
let { resolve: resolve7 } = pendingResolveReject;
|
|
868
868
|
pendingResolveReject = null;
|
|
869
|
-
|
|
869
|
+
resolve7({ value: entry });
|
|
870
870
|
}
|
|
871
871
|
function onEnd() {
|
|
872
|
-
let { resolve:
|
|
872
|
+
let { resolve: resolve7 } = pendingResolveReject;
|
|
873
873
|
pendingResolveReject = null;
|
|
874
874
|
cleanup();
|
|
875
|
-
|
|
875
|
+
resolve7({ done: true });
|
|
876
876
|
}
|
|
877
877
|
function onError(err) {
|
|
878
878
|
let { reject } = pendingResolveReject;
|
|
@@ -885,9 +885,9 @@ var require_yauzl = __commonJS({
|
|
|
885
885
|
return this;
|
|
886
886
|
},
|
|
887
887
|
next() {
|
|
888
|
-
const promise2 = new Promise((
|
|
888
|
+
const promise2 = new Promise((resolve7, reject) => {
|
|
889
889
|
if (pendingResolveReject != null) throw new Error("next() called before previous Promise was resolved.");
|
|
890
|
-
pendingResolveReject = { resolve:
|
|
890
|
+
pendingResolveReject = { resolve: resolve7, reject };
|
|
891
891
|
});
|
|
892
892
|
self.readEntry();
|
|
893
893
|
return promise2;
|
|
@@ -1076,26 +1076,26 @@ var require_yauzl = __commonJS({
|
|
|
1076
1076
|
});
|
|
1077
1077
|
};
|
|
1078
1078
|
ZipFile.prototype.openReadStreamPromise = function(entry, options2) {
|
|
1079
|
-
return new Promise((
|
|
1079
|
+
return new Promise((resolve7, reject) => {
|
|
1080
1080
|
this.openReadStream(entry, options2, function(err, readStream) {
|
|
1081
1081
|
if (err) return reject(err);
|
|
1082
|
-
|
|
1082
|
+
resolve7(readStream);
|
|
1083
1083
|
});
|
|
1084
1084
|
});
|
|
1085
1085
|
};
|
|
1086
1086
|
ZipFile.prototype.openReadStreamLowLevelPromise = function(fileDataStart, compressedSize, relativeStart, relativeEnd, decompress, uncompressedSize) {
|
|
1087
|
-
return new Promise((
|
|
1087
|
+
return new Promise((resolve7, reject) => {
|
|
1088
1088
|
this.openReadStream(fileDataStart, compressedSize, relativeStart, relativeEnd, decompress, uncompressedSize, function(err, readStream) {
|
|
1089
1089
|
if (err) return reject(err);
|
|
1090
|
-
|
|
1090
|
+
resolve7(readStream);
|
|
1091
1091
|
});
|
|
1092
1092
|
});
|
|
1093
1093
|
};
|
|
1094
1094
|
ZipFile.prototype.readLocalFileHeaderPromise = function(entry, options2) {
|
|
1095
|
-
return new Promise((
|
|
1095
|
+
return new Promise((resolve7, reject) => {
|
|
1096
1096
|
this.readLocalFileHeader(entry, options2, function(err, localFileHeader) {
|
|
1097
1097
|
if (err) return reject(err);
|
|
1098
|
-
|
|
1098
|
+
resolve7(localFileHeader);
|
|
1099
1099
|
});
|
|
1100
1100
|
});
|
|
1101
1101
|
};
|
|
@@ -1387,7 +1387,7 @@ var require_yauzl = __commonJS({
|
|
|
1387
1387
|
import { definePlugin } from "@ycodium-ai/plugin-api";
|
|
1388
1388
|
|
|
1389
1389
|
// ../../packages/plugin-api/src/version.ts
|
|
1390
|
-
var PLUGIN_API_VERSION =
|
|
1390
|
+
var PLUGIN_API_VERSION = 147;
|
|
1391
1391
|
|
|
1392
1392
|
// src/index.ts
|
|
1393
1393
|
import {
|
|
@@ -1454,17 +1454,17 @@ var waitForLoginController = (instanceId, signal, after) => {
|
|
|
1454
1454
|
const present = controllers.get(instanceId);
|
|
1455
1455
|
if (signal.aborted) return Promise.resolve(void 0);
|
|
1456
1456
|
if (present !== void 0 && present !== after) return Promise.resolve(present);
|
|
1457
|
-
return new Promise((
|
|
1457
|
+
return new Promise((resolve7) => {
|
|
1458
1458
|
const waiters = registrationWaiters.get(instanceId) ?? /* @__PURE__ */ new Set();
|
|
1459
1459
|
registrationWaiters.set(instanceId, waiters);
|
|
1460
1460
|
const wake = () => {
|
|
1461
1461
|
signal.removeEventListener("abort", onAbort);
|
|
1462
|
-
|
|
1462
|
+
resolve7(controllers.get(instanceId));
|
|
1463
1463
|
};
|
|
1464
1464
|
const onAbort = () => {
|
|
1465
1465
|
waiters.delete(wake);
|
|
1466
1466
|
if (waiters.size === 0) registrationWaiters.delete(instanceId);
|
|
1467
|
-
|
|
1467
|
+
resolve7(void 0);
|
|
1468
1468
|
};
|
|
1469
1469
|
waiters.add(wake);
|
|
1470
1470
|
signal.addEventListener("abort", onAbort, { once: true });
|
|
@@ -1614,13 +1614,13 @@ function registerAntigravityAuthCommands(ctx) {
|
|
|
1614
1614
|
emit(controller.state());
|
|
1615
1615
|
const unsubscribe = controller.subscribe(emit);
|
|
1616
1616
|
try {
|
|
1617
|
-
await new Promise((
|
|
1617
|
+
await new Promise((resolve7) => {
|
|
1618
1618
|
if (signal.aborted) {
|
|
1619
|
-
|
|
1619
|
+
resolve7();
|
|
1620
1620
|
return;
|
|
1621
1621
|
}
|
|
1622
|
-
signal.addEventListener("abort", () =>
|
|
1623
|
-
void controller.closed.then(
|
|
1622
|
+
signal.addEventListener("abort", () => resolve7(), { once: true });
|
|
1623
|
+
void controller.closed.then(resolve7);
|
|
1624
1624
|
});
|
|
1625
1625
|
} finally {
|
|
1626
1626
|
unsubscribe();
|
|
@@ -1692,6 +1692,24 @@ function approvalOutcomeForDecision(decision, optionId) {
|
|
|
1692
1692
|
return decision !== "cancel" && optionId !== void 0 ? { outcome: "selected", optionId } : { outcome: "cancelled" };
|
|
1693
1693
|
}
|
|
1694
1694
|
|
|
1695
|
+
// ../../packages/ycodium-executor-common/src/stderrTail.ts
|
|
1696
|
+
var REDACTION_MARKERS = ["[redacted]", "[pairing-url]"];
|
|
1697
|
+
function lastStderrTail(text, maxChars) {
|
|
1698
|
+
if (text.length <= maxChars) return text;
|
|
1699
|
+
let start = text.length - maxChars;
|
|
1700
|
+
if (text[start - 1] !== "\n") {
|
|
1701
|
+
const lineEnd = text.indexOf("\n", start);
|
|
1702
|
+
if (lineEnd !== -1 && lineEnd < text.length - 1) return text.slice(lineEnd + 1);
|
|
1703
|
+
const code = text.charCodeAt(start);
|
|
1704
|
+
if (code >= 56320 && code <= 57343) start += 1;
|
|
1705
|
+
for (const marker of REDACTION_MARKERS) {
|
|
1706
|
+
const at = text.lastIndexOf(marker, start);
|
|
1707
|
+
if (at !== -1 && at < start && start < at + marker.length) start = at + marker.length;
|
|
1708
|
+
}
|
|
1709
|
+
}
|
|
1710
|
+
return text.slice(start);
|
|
1711
|
+
}
|
|
1712
|
+
|
|
1695
1713
|
// ../../packages/ycodium-acp-executor/src/errors.ts
|
|
1696
1714
|
var AcpExecutorError = class extends Error {
|
|
1697
1715
|
code;
|
|
@@ -1796,30 +1814,14 @@ var AcpAgentExitedError = class extends AcpConnectionClosedError {
|
|
|
1796
1814
|
this.exitCode = exitCode;
|
|
1797
1815
|
}
|
|
1798
1816
|
};
|
|
1799
|
-
var REDACTION_MARKERS = ["[redacted]", "[pairing-url]"];
|
|
1800
|
-
var lastLines = (text, maxChars) => {
|
|
1801
|
-
if (text.length <= maxChars) return text;
|
|
1802
|
-
let start = text.length - maxChars;
|
|
1803
|
-
if (text[start - 1] !== "\n") {
|
|
1804
|
-
const lineEnd = text.indexOf("\n", start);
|
|
1805
|
-
if (lineEnd !== -1 && lineEnd < text.length - 1) return text.slice(lineEnd + 1);
|
|
1806
|
-
const code = text.charCodeAt(start);
|
|
1807
|
-
if (code >= 56320 && code <= 57343) start += 1;
|
|
1808
|
-
for (const marker of REDACTION_MARKERS) {
|
|
1809
|
-
const at = text.lastIndexOf(marker, start);
|
|
1810
|
-
if (at !== -1 && at < start && start < at + marker.length) start = at + marker.length;
|
|
1811
|
-
}
|
|
1812
|
-
}
|
|
1813
|
-
return text.slice(start);
|
|
1814
|
-
};
|
|
1815
1817
|
var settledExitCode = async (exited) => {
|
|
1816
1818
|
if (exited === void 0) return void 0;
|
|
1817
1819
|
let timer;
|
|
1818
1820
|
try {
|
|
1819
1821
|
return await Promise.race([
|
|
1820
1822
|
exited.catch(() => void 0),
|
|
1821
|
-
new Promise((
|
|
1822
|
-
timer = setTimeout(() =>
|
|
1823
|
+
new Promise((resolve7) => {
|
|
1824
|
+
timer = setTimeout(() => resolve7(void 0), AGENT_EXIT_SETTLE_MS);
|
|
1823
1825
|
})
|
|
1824
1826
|
]);
|
|
1825
1827
|
} finally {
|
|
@@ -1832,7 +1834,7 @@ async function describeAgentExit(input2) {
|
|
|
1832
1834
|
input2.stderrTail === void 0 ? "" : Promise.resolve().then(input2.stderrTail).catch(() => "")
|
|
1833
1835
|
]);
|
|
1834
1836
|
const head = exitCode === void 0 ? "The agent closed its connection." : exitCode === null ? "The agent process exited without an exit code." : `The agent process exited with code ${exitCode}.`;
|
|
1835
|
-
const excerpt =
|
|
1837
|
+
const excerpt = lastStderrTail(tail.trim(), AGENT_EXIT_STDERR_MAX_CHARS);
|
|
1836
1838
|
return new AcpAgentExitedError(
|
|
1837
1839
|
excerpt.length === 0 ? head : `${head}
|
|
1838
1840
|
Agent stderr (last lines):
|
|
@@ -1897,8 +1899,8 @@ var UnboundedEventStream = class {
|
|
|
1897
1899
|
iterators.subscribers.delete(subscriber);
|
|
1898
1900
|
return { value: void 0, done: true };
|
|
1899
1901
|
}
|
|
1900
|
-
await new Promise((
|
|
1901
|
-
subscriber.wake =
|
|
1902
|
+
await new Promise((resolve7) => {
|
|
1903
|
+
subscriber.wake = resolve7;
|
|
1902
1904
|
});
|
|
1903
1905
|
}
|
|
1904
1906
|
},
|
|
@@ -2049,9 +2051,17 @@ var selectPromptTurnId = (input2, activeTurnId, freshTurnId) => {
|
|
|
2049
2051
|
return target;
|
|
2050
2052
|
};
|
|
2051
2053
|
|
|
2052
|
-
// ../../packages/ycodium-
|
|
2054
|
+
// ../../packages/ycodium-executor-common/src/toolPresentation.ts
|
|
2055
|
+
function isRecord3(value) {
|
|
2056
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
2057
|
+
}
|
|
2058
|
+
function asTrimmedString2(value) {
|
|
2059
|
+
if (typeof value !== "string") return void 0;
|
|
2060
|
+
const trimmed = value.trim();
|
|
2061
|
+
return trimmed.length > 0 ? trimmed : void 0;
|
|
2062
|
+
}
|
|
2053
2063
|
function normalizeCommandValue(value) {
|
|
2054
|
-
const direct =
|
|
2064
|
+
const direct = asTrimmedString2(value);
|
|
2055
2065
|
if (direct) {
|
|
2056
2066
|
return direct;
|
|
2057
2067
|
}
|
|
@@ -2060,7 +2070,7 @@ function normalizeCommandValue(value) {
|
|
|
2060
2070
|
}
|
|
2061
2071
|
const parts = [];
|
|
2062
2072
|
for (const entry of value) {
|
|
2063
|
-
const part =
|
|
2073
|
+
const part = asTrimmedString2(entry);
|
|
2064
2074
|
if (part !== void 0) {
|
|
2065
2075
|
parts.push(part);
|
|
2066
2076
|
}
|
|
@@ -2084,11 +2094,11 @@ function extractCommandFromTitle(title) {
|
|
|
2084
2094
|
return backtickMatch?.[1]?.trim() || void 0;
|
|
2085
2095
|
}
|
|
2086
2096
|
function extractToolCommand(data, title) {
|
|
2087
|
-
const item =
|
|
2088
|
-
const itemInput = item &&
|
|
2089
|
-
const itemResult = item &&
|
|
2090
|
-
const rawInput =
|
|
2091
|
-
const dataInput =
|
|
2097
|
+
const item = isRecord3(data?.["item"]) ? data["item"] : void 0;
|
|
2098
|
+
const itemInput = item && isRecord3(item["input"]) ? item["input"] : void 0;
|
|
2099
|
+
const itemResult = item && isRecord3(item["result"]) ? item["result"] : void 0;
|
|
2100
|
+
const rawInput = isRecord3(data?.["rawInput"]) ? data["rawInput"] : void 0;
|
|
2101
|
+
const dataInput = isRecord3(data?.["input"]) ? data["input"] : void 0;
|
|
2092
2102
|
const candidates = [
|
|
2093
2103
|
normalizeCommandValue(item?.["command"]),
|
|
2094
2104
|
normalizeCommandValue(itemInput?.["command"]),
|
|
@@ -2101,7 +2111,7 @@ function extractToolCommand(data, title) {
|
|
|
2101
2111
|
if (direct) {
|
|
2102
2112
|
return direct;
|
|
2103
2113
|
}
|
|
2104
|
-
const executable =
|
|
2114
|
+
const executable = asTrimmedString2(rawInput?.["executable"]);
|
|
2105
2115
|
const args = normalizeCommandValue(rawInput?.["args"]);
|
|
2106
2116
|
if (executable && args) {
|
|
2107
2117
|
return `${executable} ${args}`;
|
|
@@ -2133,11 +2143,11 @@ function collectPaths(value, paths, seen, depth) {
|
|
|
2133
2143
|
}
|
|
2134
2144
|
return;
|
|
2135
2145
|
}
|
|
2136
|
-
if (!
|
|
2146
|
+
if (!isRecord3(value)) {
|
|
2137
2147
|
return;
|
|
2138
2148
|
}
|
|
2139
2149
|
for (const key of ["path", "filePath", "relativePath", "filename", "newPath", "oldPath"]) {
|
|
2140
|
-
const candidate = maybePathLike(
|
|
2150
|
+
const candidate = maybePathLike(asTrimmedString2(value[key]));
|
|
2141
2151
|
if (!candidate || seen.has(candidate)) {
|
|
2142
2152
|
continue;
|
|
2143
2153
|
}
|
|
@@ -2163,7 +2173,7 @@ function extractPrimaryPath(data) {
|
|
|
2163
2173
|
return paths[0];
|
|
2164
2174
|
}
|
|
2165
2175
|
function normalizeEquivalentValue(value) {
|
|
2166
|
-
const trimmed =
|
|
2176
|
+
const trimmed = asTrimmedString2(value);
|
|
2167
2177
|
if (!trimmed) {
|
|
2168
2178
|
return void 0;
|
|
2169
2179
|
}
|
|
@@ -2176,8 +2186,8 @@ function isEquivalent(left, right) {
|
|
|
2176
2186
|
}
|
|
2177
2187
|
function classifyToolAction(input2) {
|
|
2178
2188
|
const itemType = input2.itemType ?? void 0;
|
|
2179
|
-
const kind =
|
|
2180
|
-
const title =
|
|
2189
|
+
const kind = asTrimmedString2(input2.data?.["kind"])?.toLowerCase();
|
|
2190
|
+
const title = asTrimmedString2(input2.title)?.toLowerCase();
|
|
2181
2191
|
if (itemType === "command_execution" || kind === "execute" || title === "terminal") {
|
|
2182
2192
|
return "command";
|
|
2183
2193
|
}
|
|
@@ -2192,26 +2202,11 @@ function classifyToolAction(input2) {
|
|
|
2192
2202
|
}
|
|
2193
2203
|
return "other";
|
|
2194
2204
|
}
|
|
2195
|
-
function canonicalItemTypeFromAcpToolKind(kind) {
|
|
2196
|
-
switch (kind) {
|
|
2197
|
-
case "execute":
|
|
2198
|
-
return "command_execution";
|
|
2199
|
-
case "edit":
|
|
2200
|
-
case "delete":
|
|
2201
|
-
case "move":
|
|
2202
|
-
return "file_change";
|
|
2203
|
-
case "search":
|
|
2204
|
-
case "fetch":
|
|
2205
|
-
return "web_search";
|
|
2206
|
-
default:
|
|
2207
|
-
return "dynamic_tool_call";
|
|
2208
|
-
}
|
|
2209
|
-
}
|
|
2210
2205
|
function deriveToolActivityPresentation(input2) {
|
|
2211
|
-
const title =
|
|
2212
|
-
const detail = stripTrailingExitCode(
|
|
2213
|
-
const fallbackSummary =
|
|
2214
|
-
const data =
|
|
2206
|
+
const title = asTrimmedString2(input2.title);
|
|
2207
|
+
const detail = stripTrailingExitCode(asTrimmedString2(input2.detail));
|
|
2208
|
+
const fallbackSummary = asTrimmedString2(input2.fallbackSummary) ?? "Tool";
|
|
2209
|
+
const data = isRecord3(input2.data) ? input2.data : void 0;
|
|
2215
2210
|
const command = extractToolCommand(data, title);
|
|
2216
2211
|
const primaryPath = extractPrimaryPath(data);
|
|
2217
2212
|
const action = classifyToolAction({
|
|
@@ -2243,8 +2238,8 @@ function deriveToolActivityPresentation(input2) {
|
|
|
2243
2238
|
};
|
|
2244
2239
|
}
|
|
2245
2240
|
if (action === "search") {
|
|
2246
|
-
const rawInput =
|
|
2247
|
-
const query =
|
|
2241
|
+
const rawInput = isRecord3(data?.["rawInput"]) ? data["rawInput"] : void 0;
|
|
2242
|
+
const query = asTrimmedString2(rawInput?.["query"]) ?? asTrimmedString2(rawInput?.["pattern"]) ?? asTrimmedString2(rawInput?.["searchTerm"]);
|
|
2248
2243
|
return {
|
|
2249
2244
|
summary: "Searched files",
|
|
2250
2245
|
...query ? { detail: query } : {}
|
|
@@ -2261,6 +2256,23 @@ function deriveToolActivityPresentation(input2) {
|
|
|
2261
2256
|
};
|
|
2262
2257
|
}
|
|
2263
2258
|
|
|
2259
|
+
// ../../packages/ycodium-acp-executor/src/tool-presentation.ts
|
|
2260
|
+
function canonicalItemTypeFromAcpToolKind(kind) {
|
|
2261
|
+
switch (kind) {
|
|
2262
|
+
case "execute":
|
|
2263
|
+
return "command_execution";
|
|
2264
|
+
case "edit":
|
|
2265
|
+
case "delete":
|
|
2266
|
+
case "move":
|
|
2267
|
+
return "file_change";
|
|
2268
|
+
case "search":
|
|
2269
|
+
case "fetch":
|
|
2270
|
+
return "web_search";
|
|
2271
|
+
default:
|
|
2272
|
+
return "dynamic_tool_call";
|
|
2273
|
+
}
|
|
2274
|
+
}
|
|
2275
|
+
|
|
2264
2276
|
// ../../packages/ycodium-acp-executor/src/tool-call-state.ts
|
|
2265
2277
|
function normalizeToolCallStatus(raw, fallback) {
|
|
2266
2278
|
switch (raw) {
|
|
@@ -2489,6 +2501,30 @@ function decideToolCallUpdateEmission(input2) {
|
|
|
2489
2501
|
return { emit: false, skippedSinceEmit: skippedSinceEmit + 1 };
|
|
2490
2502
|
}
|
|
2491
2503
|
|
|
2504
|
+
// ../../packages/ycodium-executor-common/src/catalogModel.ts
|
|
2505
|
+
function catalogModelLastSegment(value) {
|
|
2506
|
+
if (value.startsWith("[")) {
|
|
2507
|
+
let parsed;
|
|
2508
|
+
try {
|
|
2509
|
+
parsed = JSON.parse(value);
|
|
2510
|
+
} catch {
|
|
2511
|
+
return void 0;
|
|
2512
|
+
}
|
|
2513
|
+
if (!Array.isArray(parsed) || parsed.length < 2) return void 0;
|
|
2514
|
+
const last = parsed[parsed.length - 1];
|
|
2515
|
+
return typeof last === "string" ? last : void 0;
|
|
2516
|
+
}
|
|
2517
|
+
const separator = value.indexOf("/");
|
|
2518
|
+
return separator > 0 && separator < value.length - 1 ? value.slice(separator + 1) : void 0;
|
|
2519
|
+
}
|
|
2520
|
+
function matchCatalogModel(requested, catalog) {
|
|
2521
|
+
const wanted = requested?.trim();
|
|
2522
|
+
if (!wanted) return void 0;
|
|
2523
|
+
if (catalog.includes(wanted)) return wanted;
|
|
2524
|
+
const byLastSegment = catalog.filter((value) => catalogModelLastSegment(value) === wanted);
|
|
2525
|
+
return byLastSegment.length === 1 ? byLastSegment[0] : void 0;
|
|
2526
|
+
}
|
|
2527
|
+
|
|
2492
2528
|
// ../../packages/ycodium-acp-executor/src/runtime-model.ts
|
|
2493
2529
|
function normalizePlanStepStatus(raw) {
|
|
2494
2530
|
switch (raw) {
|
|
@@ -2530,30 +2566,6 @@ function collectSessionModelIds(models) {
|
|
|
2530
2566
|
(model) => isRecord2(model) && typeof model["modelId"] === "string" ? [model["modelId"]] : []
|
|
2531
2567
|
);
|
|
2532
2568
|
}
|
|
2533
|
-
function catalogModelLastSegment(value) {
|
|
2534
|
-
if (value.startsWith("[")) {
|
|
2535
|
-
let parsed;
|
|
2536
|
-
try {
|
|
2537
|
-
parsed = JSON.parse(value);
|
|
2538
|
-
} catch {
|
|
2539
|
-
return void 0;
|
|
2540
|
-
}
|
|
2541
|
-
if (!Array.isArray(parsed) || parsed.length < 2) return void 0;
|
|
2542
|
-
const last = parsed[parsed.length - 1];
|
|
2543
|
-
return typeof last === "string" ? last : void 0;
|
|
2544
|
-
}
|
|
2545
|
-
const separator = value.indexOf("/");
|
|
2546
|
-
return separator > 0 && separator < value.length - 1 ? value.slice(separator + 1) : void 0;
|
|
2547
|
-
}
|
|
2548
|
-
function matchAdvertisedModelValue(requestedModelId, advertisedValues) {
|
|
2549
|
-
const wanted = requestedModelId.trim();
|
|
2550
|
-
if (!wanted) return void 0;
|
|
2551
|
-
if (advertisedValues.includes(wanted)) return wanted;
|
|
2552
|
-
const byLastSegment = advertisedValues.filter(
|
|
2553
|
-
(value) => catalogModelLastSegment(value) === wanted
|
|
2554
|
-
);
|
|
2555
|
-
return byLastSegment.length === 1 ? byLastSegment[0] : void 0;
|
|
2556
|
-
}
|
|
2557
2569
|
function parseSessionModeState(sessionResponse) {
|
|
2558
2570
|
const modes = sessionResponse.modes;
|
|
2559
2571
|
if (!modes) return void 0;
|
|
@@ -8134,7 +8146,7 @@ var recursive = /* @__PURE__ */ new WeakMap();
|
|
|
8134
8146
|
var NONE = 0;
|
|
8135
8147
|
var ASSUMED = 1;
|
|
8136
8148
|
var PROVEN = 2;
|
|
8137
|
-
function isRecursive(inst, stack,
|
|
8149
|
+
function isRecursive(inst, stack, resolve7) {
|
|
8138
8150
|
const cached2 = recursive.get(inst);
|
|
8139
8151
|
if (cached2 !== void 0)
|
|
8140
8152
|
return cached2 ? PROVEN : NONE;
|
|
@@ -8144,7 +8156,7 @@ function isRecursive(inst, stack, resolve6) {
|
|
|
8144
8156
|
let result = NONE;
|
|
8145
8157
|
const check2 = (child) => {
|
|
8146
8158
|
if (result !== PROVEN && child?._zod) {
|
|
8147
|
-
const answer = isRecursive(child, stack,
|
|
8159
|
+
const answer = isRecursive(child, stack, resolve7);
|
|
8148
8160
|
if (answer > result)
|
|
8149
8161
|
result = answer;
|
|
8150
8162
|
}
|
|
@@ -8155,7 +8167,7 @@ function isRecursive(inst, stack, resolve6) {
|
|
|
8155
8167
|
const desc = Object.getOwnPropertyDescriptor(sh, key);
|
|
8156
8168
|
if (spread && !desc.enumerable)
|
|
8157
8169
|
continue;
|
|
8158
|
-
const child = desc.get ? ASSUMED : desc.value?._zod ? isRecursive(desc.value, stack,
|
|
8170
|
+
const child = desc.get ? ASSUMED : desc.value?._zod ? isRecursive(desc.value, stack, resolve7) : NONE;
|
|
8159
8171
|
if (child > answer)
|
|
8160
8172
|
answer = child;
|
|
8161
8173
|
}
|
|
@@ -8219,7 +8231,7 @@ function isRecursive(inst, stack, resolve6) {
|
|
|
8219
8231
|
break;
|
|
8220
8232
|
// `$ZodLazy` caches its inner on the def, so a resolved edge is followed exactly
|
|
8221
8233
|
case "lazy": {
|
|
8222
|
-
const inner = def._cachedInner ?? (
|
|
8234
|
+
const inner = def._cachedInner ?? (resolve7 ? inst._zod.innerType : void 0);
|
|
8223
8235
|
merge2(inner ? isRecursive(inner, stack, false) : ASSUMED);
|
|
8224
8236
|
break;
|
|
8225
8237
|
}
|
|
@@ -24469,17 +24481,17 @@ function isResponseMessage(value) {
|
|
|
24469
24481
|
function isNotificationMessage(value) {
|
|
24470
24482
|
return isJsonRpcEnvelope(value) && !("id" in value) && typeof value["method"] === "string";
|
|
24471
24483
|
}
|
|
24472
|
-
function
|
|
24484
|
+
function isRecord4(value) {
|
|
24473
24485
|
return typeof value === "object" && value !== null;
|
|
24474
24486
|
}
|
|
24475
24487
|
function isJsonRpcEnvelope(value) {
|
|
24476
|
-
return
|
|
24488
|
+
return isRecord4(value) && value["jsonrpc"] === "2.0";
|
|
24477
24489
|
}
|
|
24478
24490
|
function isJsonRpcId(value) {
|
|
24479
24491
|
return value === null || typeof value === "string" || typeof value === "number" && Number.isFinite(value);
|
|
24480
24492
|
}
|
|
24481
24493
|
function isResponseShapedMessage(value) {
|
|
24482
|
-
return
|
|
24494
|
+
return isRecord4(value) && !("method" in value) && ("id" in value || "result" in value || "error" in value);
|
|
24483
24495
|
}
|
|
24484
24496
|
function isResponseBatch(batch) {
|
|
24485
24497
|
let hasValidCall = false;
|
|
@@ -24489,7 +24501,7 @@ function isResponseBatch(batch) {
|
|
|
24489
24501
|
for (const entry of batch) {
|
|
24490
24502
|
hasValidCall ||= isRequestMessage(entry) || isNotificationMessage(entry);
|
|
24491
24503
|
hasValidResponse ||= isResponseMessage(entry);
|
|
24492
|
-
if (!
|
|
24504
|
+
if (!isRecord4(entry)) {
|
|
24493
24505
|
continue;
|
|
24494
24506
|
}
|
|
24495
24507
|
hasCallShape ||= "method" in entry;
|
|
@@ -24504,13 +24516,13 @@ function isResponseBatch(batch) {
|
|
|
24504
24516
|
return hasResponseShape && !hasCallShape;
|
|
24505
24517
|
}
|
|
24506
24518
|
function cancelRequestId(params) {
|
|
24507
|
-
if (!
|
|
24519
|
+
if (!isRecord4(params) || !isJsonRpcId(params["requestId"])) {
|
|
24508
24520
|
return void 0;
|
|
24509
24521
|
}
|
|
24510
24522
|
return params["requestId"];
|
|
24511
24523
|
}
|
|
24512
24524
|
function isErrorResponse(value) {
|
|
24513
|
-
return
|
|
24525
|
+
return isRecord4(value) && typeof value["code"] === "number" && Number.isInteger(value["code"]) && typeof value["message"] === "string";
|
|
24514
24526
|
}
|
|
24515
24527
|
var Handled = {
|
|
24516
24528
|
/**
|
|
@@ -24883,11 +24895,11 @@ var Connection = class {
|
|
|
24883
24895
|
const id = this.nextRequestId++;
|
|
24884
24896
|
let cancel = () => {
|
|
24885
24897
|
};
|
|
24886
|
-
const response = new Promise((
|
|
24898
|
+
const response = new Promise((resolve7, reject) => {
|
|
24887
24899
|
const pendingResponse = {
|
|
24888
24900
|
resolve: (value) => {
|
|
24889
24901
|
try {
|
|
24890
|
-
|
|
24902
|
+
resolve7(mapResponse ? mapResponse(value) : value);
|
|
24891
24903
|
} catch (error62) {
|
|
24892
24904
|
reject(error62);
|
|
24893
24905
|
}
|
|
@@ -24944,8 +24956,8 @@ var Connection = class {
|
|
|
24944
24956
|
this.stream = stream;
|
|
24945
24957
|
this.staticHandlers = handlers;
|
|
24946
24958
|
this.allowBatches = options2?.allowBatches ?? true;
|
|
24947
|
-
this.closedPromise = new Promise((
|
|
24948
|
-
this.abortController.signal.addEventListener("abort", () =>
|
|
24959
|
+
this.closedPromise = new Promise((resolve7) => {
|
|
24960
|
+
this.abortController.signal.addEventListener("abort", () => resolve7());
|
|
24949
24961
|
});
|
|
24950
24962
|
void this.receive();
|
|
24951
24963
|
}
|
|
@@ -25055,7 +25067,7 @@ var Connection = class {
|
|
|
25055
25067
|
if (this.abortController.signal.aborted) {
|
|
25056
25068
|
return Promise.resolve();
|
|
25057
25069
|
}
|
|
25058
|
-
if (!
|
|
25070
|
+
if (!isRecord4(message)) {
|
|
25059
25071
|
console.error("Invalid message", { message });
|
|
25060
25072
|
return Promise.resolve();
|
|
25061
25073
|
}
|
|
@@ -25458,7 +25470,7 @@ function ndJsonStream(output2, input2) {
|
|
|
25458
25470
|
await writeJson(protocolErrorResponse(RequestError.parseError()));
|
|
25459
25471
|
return;
|
|
25460
25472
|
}
|
|
25461
|
-
if (
|
|
25473
|
+
if (isRecord4(message) || Array.isArray(message)) {
|
|
25462
25474
|
controller.enqueue(message);
|
|
25463
25475
|
} else {
|
|
25464
25476
|
await writeJson(protocolErrorResponse(RequestError.invalidRequest(message)));
|
|
@@ -25839,8 +25851,8 @@ var AsyncQueue = class {
|
|
|
25839
25851
|
if (this.failed) {
|
|
25840
25852
|
return Promise.reject(this.failure);
|
|
25841
25853
|
}
|
|
25842
|
-
return new Promise((
|
|
25843
|
-
this.waiters.push({ resolve:
|
|
25854
|
+
return new Promise((resolve7, reject) => {
|
|
25855
|
+
this.waiters.push({ resolve: resolve7, reject });
|
|
25844
25856
|
});
|
|
25845
25857
|
}
|
|
25846
25858
|
};
|
|
@@ -26445,14 +26457,14 @@ var legacyClientNotificationMethods = /* @__PURE__ */ new Set([
|
|
|
26445
26457
|
import * as NodeStream from "node:stream";
|
|
26446
26458
|
|
|
26447
26459
|
// ../../packages/ycodium-acp-executor/src/jsonrpc.ts
|
|
26448
|
-
function
|
|
26460
|
+
function isRecord5(value) {
|
|
26449
26461
|
return typeof value === "object" && value !== null;
|
|
26450
26462
|
}
|
|
26451
26463
|
function isJsonRpcId2(value) {
|
|
26452
26464
|
return typeof value === "string" || typeof value === "number" && Number.isFinite(value);
|
|
26453
26465
|
}
|
|
26454
26466
|
function isJsonRpcEnvelope2(value) {
|
|
26455
|
-
return
|
|
26467
|
+
return isRecord5(value) && value["jsonrpc"] === "2.0";
|
|
26456
26468
|
}
|
|
26457
26469
|
function isRequestMessage2(value) {
|
|
26458
26470
|
return isJsonRpcEnvelope2(value) && "id" in value && typeof value["method"] === "string" && isJsonRpcId2(value["id"]);
|
|
@@ -26472,7 +26484,7 @@ function isNotificationMessage2(value) {
|
|
|
26472
26484
|
return isJsonRpcEnvelope2(value) && !("id" in value) && typeof value["method"] === "string";
|
|
26473
26485
|
}
|
|
26474
26486
|
function readJsonRpcError(value) {
|
|
26475
|
-
if (!
|
|
26487
|
+
if (!isRecord5(value) || typeof value["code"] !== "number" || typeof value["message"] !== "string") {
|
|
26476
26488
|
return void 0;
|
|
26477
26489
|
}
|
|
26478
26490
|
return {
|
|
@@ -26545,11 +26557,11 @@ var KNOWN_SESSION_UPDATES = /* @__PURE__ */ new Set([
|
|
|
26545
26557
|
"compaction_summary_chunk"
|
|
26546
26558
|
]);
|
|
26547
26559
|
function isSessionUpdateEnvelope(payload) {
|
|
26548
|
-
if (!
|
|
26560
|
+
if (!isRecord5(payload) || typeof payload["sessionId"] !== "string") {
|
|
26549
26561
|
return false;
|
|
26550
26562
|
}
|
|
26551
26563
|
const update = payload["update"];
|
|
26552
|
-
return
|
|
26564
|
+
return isRecord5(update) && typeof update["sessionUpdate"] === "string";
|
|
26553
26565
|
}
|
|
26554
26566
|
function hasKnownVariantShape(update) {
|
|
26555
26567
|
const kind = update["sessionUpdate"];
|
|
@@ -26557,7 +26569,7 @@ function hasKnownVariantShape(update) {
|
|
|
26557
26569
|
return false;
|
|
26558
26570
|
}
|
|
26559
26571
|
if (kind === "user_message_chunk" || kind === "agent_message_chunk" || kind === "agent_thought_chunk") {
|
|
26560
|
-
return
|
|
26572
|
+
return isRecord5(update["content"]);
|
|
26561
26573
|
}
|
|
26562
26574
|
return true;
|
|
26563
26575
|
}
|
|
@@ -26887,12 +26899,12 @@ function createAcpConnection(options2) {
|
|
|
26887
26899
|
failIfClosed();
|
|
26888
26900
|
const id = nextRequestId;
|
|
26889
26901
|
nextRequestId += 1;
|
|
26890
|
-
const { promise: promise2, resolve:
|
|
26902
|
+
const { promise: promise2, resolve: resolve7, reject } = Promise.withResolvers();
|
|
26891
26903
|
pending.set(String(id), {
|
|
26892
26904
|
method,
|
|
26893
26905
|
...promptId === void 0 ? {} : { promptId },
|
|
26894
26906
|
...onArrival === void 0 ? {} : { onArrival },
|
|
26895
|
-
resolve:
|
|
26907
|
+
resolve: resolve7,
|
|
26896
26908
|
reject
|
|
26897
26909
|
});
|
|
26898
26910
|
const message = params === void 0 ? { jsonrpc: "2.0", id, method } : { jsonrpc: "2.0", id, method, params };
|
|
@@ -26921,8 +26933,8 @@ function createAcpConnection(options2) {
|
|
|
26921
26933
|
if (inboundBatches === 0) {
|
|
26922
26934
|
return;
|
|
26923
26935
|
}
|
|
26924
|
-
await new Promise((
|
|
26925
|
-
idleWaiters.push(
|
|
26936
|
+
await new Promise((resolve7) => {
|
|
26937
|
+
idleWaiters.push(resolve7);
|
|
26926
26938
|
if (inboundBatches === 0) {
|
|
26927
26939
|
releaseIdleWaiters();
|
|
26928
26940
|
}
|
|
@@ -27008,8 +27020,8 @@ var Mutex = class {
|
|
|
27008
27020
|
this.locked = true;
|
|
27009
27021
|
return Promise.resolve();
|
|
27010
27022
|
}
|
|
27011
|
-
return new Promise((
|
|
27012
|
-
this.waiters.push(
|
|
27023
|
+
return new Promise((resolve7) => {
|
|
27024
|
+
this.waiters.push(resolve7);
|
|
27013
27025
|
});
|
|
27014
27026
|
}
|
|
27015
27027
|
tryAcquire() {
|
|
@@ -27209,9 +27221,9 @@ function createExecutorLifecycle({
|
|
|
27209
27221
|
let timer;
|
|
27210
27222
|
await Promise.race([
|
|
27211
27223
|
connection.closed.catch(() => void 0),
|
|
27212
|
-
new Promise((
|
|
27224
|
+
new Promise((resolve7) => {
|
|
27213
27225
|
timer = setTimeout(
|
|
27214
|
-
|
|
27226
|
+
resolve7,
|
|
27215
27227
|
options2.resultDrainTimeoutMs ?? DEFAULT_RESULT_DRAIN_TIMEOUT_MS
|
|
27216
27228
|
);
|
|
27217
27229
|
})
|
|
@@ -27325,7 +27337,7 @@ var alignRequestedEffort = async (input2) => {
|
|
|
27325
27337
|
return { configOptions, unsupportedEffort, ...confirmed ? { appliedEffort: fallback } : {} };
|
|
27326
27338
|
};
|
|
27327
27339
|
|
|
27328
|
-
// ../../packages/ycodium-
|
|
27340
|
+
// ../../packages/ycodium-executor-common/src/reasoningLevelFallback.ts
|
|
27329
27341
|
var REASONING_LEVEL_FALLBACK_CODE = "reasoning-level-fallback";
|
|
27330
27342
|
function reasoningLevelFallbackWarning(input2) {
|
|
27331
27343
|
const model = input2.model ?? "This model";
|
|
@@ -28077,12 +28089,12 @@ function createPromptResults({
|
|
|
28077
28089
|
}) {
|
|
28078
28090
|
const prompts = /* @__PURE__ */ new Map();
|
|
28079
28091
|
const add = (identity, finish) => {
|
|
28080
|
-
const { promise: done, resolve:
|
|
28092
|
+
const { promise: done, resolve: resolve7 } = Promise.withResolvers();
|
|
28081
28093
|
const record2 = {
|
|
28082
28094
|
...identity,
|
|
28083
28095
|
finish,
|
|
28084
28096
|
done,
|
|
28085
|
-
resolve:
|
|
28097
|
+
resolve: resolve7,
|
|
28086
28098
|
rejected: false,
|
|
28087
28099
|
interrupted: false,
|
|
28088
28100
|
finished: false
|
|
@@ -28130,9 +28142,9 @@ function createPromptResults({
|
|
|
28130
28142
|
try {
|
|
28131
28143
|
const drained = await Promise.race([
|
|
28132
28144
|
Promise.all(claimed.map((record2) => record2.done)).then(() => true),
|
|
28133
|
-
new Promise((
|
|
28145
|
+
new Promise((resolve7) => {
|
|
28134
28146
|
timer = setTimeout(
|
|
28135
|
-
() =>
|
|
28147
|
+
() => resolve7(false),
|
|
28136
28148
|
options2.resultDrainTimeoutMs ?? DEFAULT_RESULT_DRAIN_TIMEOUT_MS
|
|
28137
28149
|
);
|
|
28138
28150
|
})
|
|
@@ -28331,14 +28343,14 @@ function createExecutorRequests({
|
|
|
28331
28343
|
const statement = hooks.permissionStatement?.(permissionContext) ?? defaultPermissionStatement(permissionRequest);
|
|
28332
28344
|
const fileChanges = hooks.permissionFileChanges?.(permissionContext) ?? fileChangesFromAcpPermission(permissionRequest);
|
|
28333
28345
|
const requestId = randomId();
|
|
28334
|
-
const outcome = await new Promise((
|
|
28346
|
+
const outcome = await new Promise((resolve7) => {
|
|
28335
28347
|
const pending = {
|
|
28336
28348
|
requestId,
|
|
28337
28349
|
request: params,
|
|
28338
28350
|
permissionRequest,
|
|
28339
28351
|
turnId: shared.activeTurnId,
|
|
28340
28352
|
settled: false,
|
|
28341
|
-
resolve:
|
|
28353
|
+
resolve: resolve7
|
|
28342
28354
|
};
|
|
28343
28355
|
approvals.add(pending);
|
|
28344
28356
|
emit(
|
|
@@ -28477,7 +28489,7 @@ function makeArtifactEmitter(input2) {
|
|
|
28477
28489
|
// ../../packages/ycodium-acp-executor/src/executor/runtime.ts
|
|
28478
28490
|
function createExecutorRuntime({
|
|
28479
28491
|
randomId,
|
|
28480
|
-
nowIso:
|
|
28492
|
+
nowIso: nowIso3,
|
|
28481
28493
|
eventStream,
|
|
28482
28494
|
options: options2,
|
|
28483
28495
|
assistantItemRuntimeId,
|
|
@@ -28486,7 +28498,7 @@ function createExecutorRuntime({
|
|
|
28486
28498
|
}) {
|
|
28487
28499
|
const stamp = () => ({
|
|
28488
28500
|
eventId: randomId(),
|
|
28489
|
-
createdAt:
|
|
28501
|
+
createdAt: nowIso3()
|
|
28490
28502
|
});
|
|
28491
28503
|
const isLive = (expectedGeneration) => !shared.disposed && shared.generation === expectedGeneration;
|
|
28492
28504
|
const publish = (event) => {
|
|
@@ -28555,14 +28567,14 @@ function createExecutorRuntime({
|
|
|
28555
28567
|
if (!promptMutex.isLocked) {
|
|
28556
28568
|
return true;
|
|
28557
28569
|
}
|
|
28558
|
-
return await new Promise((
|
|
28570
|
+
return await new Promise((resolve7) => {
|
|
28559
28571
|
const timer = setTimeout(() => {
|
|
28560
28572
|
shared.promptWaiters = shared.promptWaiters.filter((waiter) => waiter !== onSettle);
|
|
28561
|
-
|
|
28573
|
+
resolve7(false);
|
|
28562
28574
|
}, timeoutMs);
|
|
28563
28575
|
const onSettle = () => {
|
|
28564
28576
|
clearTimeout(timer);
|
|
28565
|
-
|
|
28577
|
+
resolve7(true);
|
|
28566
28578
|
};
|
|
28567
28579
|
shared.promptWaiters.push(onSettle);
|
|
28568
28580
|
});
|
|
@@ -28664,7 +28676,7 @@ function judgeRequestedModel(input2) {
|
|
|
28664
28676
|
const hasCurrent = current !== void 0;
|
|
28665
28677
|
if (!hasCatalog && !hasCurrent && input2.state.modelUnconfirmed !== true) return { kind: "keep" };
|
|
28666
28678
|
const canSwitch = canSwitchModel(input2.state);
|
|
28667
|
-
const value = hasCatalog ?
|
|
28679
|
+
const value = hasCatalog ? matchCatalogModel(requested, input2.state.advertisedModelValues) : void 0;
|
|
28668
28680
|
if (value !== void 0 && value === current) return { kind: "keep" };
|
|
28669
28681
|
if (value !== void 0 && canSwitch) return { kind: "switch", value };
|
|
28670
28682
|
return { kind: "refresh" };
|
|
@@ -28704,23 +28716,23 @@ function modelRefreshFailedError(requestedModelId, error62) {
|
|
|
28704
28716
|
}
|
|
28705
28717
|
|
|
28706
28718
|
// ../../packages/ycodium-acp-executor/src/runtime-mode.ts
|
|
28707
|
-
function
|
|
28719
|
+
function isRecord6(value) {
|
|
28708
28720
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
28709
28721
|
}
|
|
28710
28722
|
function asString2(value) {
|
|
28711
28723
|
return typeof value === "string" ? value : void 0;
|
|
28712
28724
|
}
|
|
28713
28725
|
function acpAvailableModes(setup) {
|
|
28714
|
-
if (!
|
|
28726
|
+
if (!isRecord6(setup)) return [];
|
|
28715
28727
|
const out = [];
|
|
28716
28728
|
const seen = /* @__PURE__ */ new Set();
|
|
28717
28729
|
const push = (entry) => {
|
|
28718
|
-
if (!
|
|
28730
|
+
if (!isRecord6(entry)) return;
|
|
28719
28731
|
const id = (asString2(entry["id"]) ?? asString2(entry["value"]))?.trim();
|
|
28720
28732
|
if (!id || seen.has(id)) return;
|
|
28721
28733
|
seen.add(id);
|
|
28722
28734
|
const meta3 = entry["_meta"];
|
|
28723
|
-
const kind =
|
|
28735
|
+
const kind = isRecord6(meta3) ? asString2(meta3["kind"])?.trim().toLowerCase() : void 0;
|
|
28724
28736
|
const name = asString2(entry["name"])?.trim();
|
|
28725
28737
|
const description = asString2(entry["description"])?.trim();
|
|
28726
28738
|
out.push({
|
|
@@ -28731,13 +28743,13 @@ function acpAvailableModes(setup) {
|
|
|
28731
28743
|
});
|
|
28732
28744
|
};
|
|
28733
28745
|
const modes = setup["modes"];
|
|
28734
|
-
if (
|
|
28746
|
+
if (isRecord6(modes) && Array.isArray(modes["availableModes"])) {
|
|
28735
28747
|
for (const entry of modes["availableModes"]) push(entry);
|
|
28736
28748
|
}
|
|
28737
28749
|
const configOptions = setup["configOptions"];
|
|
28738
28750
|
if (Array.isArray(configOptions)) {
|
|
28739
28751
|
for (const option of configOptions) {
|
|
28740
|
-
if (!
|
|
28752
|
+
if (!isRecord6(option)) continue;
|
|
28741
28753
|
if (asString2(option["category"])?.trim().toLowerCase() !== "mode") continue;
|
|
28742
28754
|
if (!Array.isArray(option["options"])) continue;
|
|
28743
28755
|
for (const entry of option["options"]) push(entry);
|
|
@@ -28746,11 +28758,11 @@ function acpAvailableModes(setup) {
|
|
|
28746
28758
|
return out;
|
|
28747
28759
|
}
|
|
28748
28760
|
function acpModeConfigId(setup) {
|
|
28749
|
-
if (!
|
|
28761
|
+
if (!isRecord6(setup)) return void 0;
|
|
28750
28762
|
const configOptions = setup["configOptions"];
|
|
28751
28763
|
if (!Array.isArray(configOptions)) return void 0;
|
|
28752
28764
|
for (const option of configOptions) {
|
|
28753
|
-
if (!
|
|
28765
|
+
if (!isRecord6(option)) continue;
|
|
28754
28766
|
if (asString2(option["category"])?.trim().toLowerCase() !== "mode") continue;
|
|
28755
28767
|
const id = asString2(option["id"])?.trim();
|
|
28756
28768
|
if (id) return id;
|
|
@@ -28758,16 +28770,16 @@ function acpModeConfigId(setup) {
|
|
|
28758
28770
|
return void 0;
|
|
28759
28771
|
}
|
|
28760
28772
|
function acpCurrentModeId(setup) {
|
|
28761
|
-
if (!
|
|
28773
|
+
if (!isRecord6(setup)) return void 0;
|
|
28762
28774
|
const modes = setup["modes"];
|
|
28763
|
-
if (
|
|
28775
|
+
if (isRecord6(modes)) {
|
|
28764
28776
|
const current = asString2(modes["currentModeId"])?.trim();
|
|
28765
28777
|
if (current) return current;
|
|
28766
28778
|
}
|
|
28767
28779
|
const configOptions = setup["configOptions"];
|
|
28768
28780
|
if (Array.isArray(configOptions)) {
|
|
28769
28781
|
for (const option of configOptions) {
|
|
28770
|
-
if (!
|
|
28782
|
+
if (!isRecord6(option)) continue;
|
|
28771
28783
|
if (asString2(option["category"])?.trim().toLowerCase() !== "mode") continue;
|
|
28772
28784
|
const current = asString2(option["currentValue"])?.trim();
|
|
28773
28785
|
if (current) return current;
|
|
@@ -29776,7 +29788,7 @@ function defaultRandomId() {
|
|
|
29776
29788
|
function createAcpExecutor(options2) {
|
|
29777
29789
|
const hooks = { ...defaultVendorHooks, ...options2.hooks };
|
|
29778
29790
|
const cancelGraceMs = options2.cancelGraceMs ?? DEFAULT_CANCEL_GRACE_MS;
|
|
29779
|
-
const
|
|
29791
|
+
const nowIso3 = options2.nowIso ?? defaultNowIso;
|
|
29780
29792
|
const randomId = options2.randomId ?? defaultRandomId;
|
|
29781
29793
|
const eventStream = new UnboundedEventStream();
|
|
29782
29794
|
const threadMutex = new Mutex();
|
|
@@ -29837,7 +29849,7 @@ function createAcpExecutor(options2) {
|
|
|
29837
29849
|
waitForPromptIdle
|
|
29838
29850
|
} = createExecutorRuntime({
|
|
29839
29851
|
randomId,
|
|
29840
|
-
nowIso:
|
|
29852
|
+
nowIso: nowIso3,
|
|
29841
29853
|
eventStream,
|
|
29842
29854
|
options: options2,
|
|
29843
29855
|
assistantItemRuntimeId,
|
|
@@ -30173,22 +30185,103 @@ function createRetryableClose(run) {
|
|
|
30173
30185
|
};
|
|
30174
30186
|
}
|
|
30175
30187
|
|
|
30176
|
-
// ../../packages/ycodium-acp-executor/src/
|
|
30177
|
-
|
|
30178
|
-
|
|
30179
|
-
|
|
30180
|
-
|
|
30181
|
-
|
|
30182
|
-
|
|
30183
|
-
|
|
30184
|
-
|
|
30185
|
-
|
|
30186
|
-
|
|
30187
|
-
|
|
30188
|
-
|
|
30189
|
-
|
|
30190
|
-
|
|
30191
|
-
|
|
30188
|
+
// ../../packages/ycodium-acp-executor/src/prompt-dispatch.ts
|
|
30189
|
+
var dispatchAcpPrompt = (executor, input2) => {
|
|
30190
|
+
const { promise: dispatched, resolve: resolve7 } = Promise.withResolvers();
|
|
30191
|
+
let written = false;
|
|
30192
|
+
const finished = executor.prompt({
|
|
30193
|
+
...input2,
|
|
30194
|
+
onDispatched: (turnId) => {
|
|
30195
|
+
written = true;
|
|
30196
|
+
resolve7(turnId);
|
|
30197
|
+
}
|
|
30198
|
+
});
|
|
30199
|
+
return Promise.race([
|
|
30200
|
+
dispatched.then((turnId) => ({ turnId })),
|
|
30201
|
+
finished.then((result) => {
|
|
30202
|
+
if (!written && input2.expectedActiveTurnId !== void 0 && result.stopReason === "cancelled") {
|
|
30203
|
+
throw new AcpExecutorTurnEndedError();
|
|
30204
|
+
}
|
|
30205
|
+
return { turnId: result.turnId };
|
|
30206
|
+
})
|
|
30207
|
+
]);
|
|
30208
|
+
};
|
|
30209
|
+
|
|
30210
|
+
// ../../packages/ycodium-acp-executor/src/thread-operations.ts
|
|
30211
|
+
var yieldTick = () => new Promise((resolve7) => {
|
|
30212
|
+
setImmediate(resolve7);
|
|
30213
|
+
});
|
|
30214
|
+
var nowIso = () => (/* @__PURE__ */ new Date()).toISOString();
|
|
30215
|
+
function createAcpThreadOperations(options2) {
|
|
30216
|
+
const { threads, requireThread } = options2;
|
|
30217
|
+
return {
|
|
30218
|
+
sendTurn: async (input2, signal) => {
|
|
30219
|
+
if (options2.isDisposed()) throw new Error("instance disposed");
|
|
30220
|
+
const booked = requireThread(input2.threadId);
|
|
30221
|
+
if (signal?.aborted) throw new Error("aborted");
|
|
30222
|
+
options2.beforeSendTurn?.(booked);
|
|
30223
|
+
const onAbort = () => {
|
|
30224
|
+
void booked.executor.cancel(input2.expectedTurnId).catch(() => void 0);
|
|
30225
|
+
};
|
|
30226
|
+
signal?.addEventListener("abort", onAbort);
|
|
30227
|
+
try {
|
|
30228
|
+
const { requestedModelId, requestedEffort } = options2.turnSelection?.(input2.modelSelection) ?? {};
|
|
30229
|
+
const turn = await dispatchAcpPrompt(booked.executor, {
|
|
30230
|
+
text: input2.input ?? "",
|
|
30231
|
+
expectedActiveTurnId: input2.expectedTurnId,
|
|
30232
|
+
...requestedModelId === void 0 ? {} : { requestedModelId },
|
|
30233
|
+
...requestedEffort === void 0 ? {} : { requestedEffort }
|
|
30234
|
+
});
|
|
30235
|
+
booked.turns.push({ id: turn.turnId, items: [] });
|
|
30236
|
+
return {
|
|
30237
|
+
threadId: input2.threadId,
|
|
30238
|
+
turnId: turn.turnId,
|
|
30239
|
+
...booked.session.resumeCursor === void 0 ? {} : { resumeCursor: booked.session.resumeCursor }
|
|
30240
|
+
};
|
|
30241
|
+
} finally {
|
|
30242
|
+
signal?.removeEventListener("abort", onAbort);
|
|
30243
|
+
}
|
|
30244
|
+
},
|
|
30245
|
+
interruptTurn: async (threadId, turnId) => {
|
|
30246
|
+
const booked = threads.get(threadId);
|
|
30247
|
+
if (booked === void 0 || booked.closing) return;
|
|
30248
|
+
options2.log.info("interrupt turn", { threadId, turnId });
|
|
30249
|
+
await booked.executor.cancel(turnId);
|
|
30250
|
+
await yieldTick();
|
|
30251
|
+
},
|
|
30252
|
+
respondToRequest: async (threadId, requestId, decision, reason) => {
|
|
30253
|
+
const booked = requireThread(threadId);
|
|
30254
|
+
await booked.executor.respondToRequest(
|
|
30255
|
+
requestId,
|
|
30256
|
+
decision === "allow" ? "accept" : "decline",
|
|
30257
|
+
reason
|
|
30258
|
+
);
|
|
30259
|
+
},
|
|
30260
|
+
respondToUserInput: async (threadId, requestId, answers) => {
|
|
30261
|
+
const booked = requireThread(threadId);
|
|
30262
|
+
await booked.executor.respondToUserInput(requestId, answers);
|
|
30263
|
+
},
|
|
30264
|
+
/**
|
|
30265
|
+
* 切这只手自报的审批档。`nativeModeId` 是它自己报的 id(探测时原样上报的那些),
|
|
30266
|
+
* 一路不翻译成宿主四档。
|
|
30267
|
+
*
|
|
30268
|
+
* 这是 `setRuntimeMode` 做不到的那一半:那个只改插件自己的会话记录,CLI 收不到
|
|
30269
|
+
* (`runtime-mode-never-reaches-cli` 记的那族缺陷)。
|
|
30270
|
+
*/
|
|
30271
|
+
setNativeMode: async (threadId, nativeModeId) => {
|
|
30272
|
+
const booked = requireThread(threadId);
|
|
30273
|
+
await booked.executor.setNativeMode(nativeModeId);
|
|
30274
|
+
booked.session = { ...booked.session, nativeModeId, updatedAt: nowIso() };
|
|
30275
|
+
},
|
|
30276
|
+
setRuntimeMode: async (threadId, runtimeMode) => {
|
|
30277
|
+
const booked = requireThread(threadId);
|
|
30278
|
+
booked.session = { ...booked.session, runtimeMode, updatedAt: nowIso() };
|
|
30279
|
+
},
|
|
30280
|
+
readThread: async (threadId) => {
|
|
30281
|
+
const booked = requireThread(threadId);
|
|
30282
|
+
return { threadId, turns: booked.turns };
|
|
30283
|
+
}
|
|
30284
|
+
};
|
|
30192
30285
|
}
|
|
30193
30286
|
|
|
30194
30287
|
// ../../packages/ycodium-acp-executor/src/mcp-servers.ts
|
|
@@ -30211,10 +30304,28 @@ function toAcpMcpServers(entries) {
|
|
|
30211
30304
|
);
|
|
30212
30305
|
}
|
|
30213
30306
|
|
|
30307
|
+
// ../../packages/ycodium-acp-executor/src/start-abort.ts
|
|
30308
|
+
function throwIfStartAborted(signal) {
|
|
30309
|
+
if (signal?.aborted) throw new Error("aborted");
|
|
30310
|
+
}
|
|
30311
|
+
async function raceStartAbort(promise2, signal) {
|
|
30312
|
+
void promise2.catch(() => void 0);
|
|
30313
|
+
throwIfStartAborted(signal);
|
|
30314
|
+
if (signal === void 0) return promise2;
|
|
30315
|
+
const aborted2 = Promise.withResolvers();
|
|
30316
|
+
const onAbort = () => aborted2.reject(new Error("aborted"));
|
|
30317
|
+
signal.addEventListener("abort", onAbort, { once: true });
|
|
30318
|
+
try {
|
|
30319
|
+
return await Promise.race([promise2, aborted2.promise]);
|
|
30320
|
+
} finally {
|
|
30321
|
+
signal.removeEventListener("abort", onAbort);
|
|
30322
|
+
}
|
|
30323
|
+
}
|
|
30324
|
+
|
|
30214
30325
|
// ../../packages/ycodium-acp-executor/src/probe.ts
|
|
30215
30326
|
function withProbeTimeout(promise2, timeoutMs, what, signal) {
|
|
30216
30327
|
signal?.throwIfAborted();
|
|
30217
|
-
return new Promise((
|
|
30328
|
+
return new Promise((resolve7, reject) => {
|
|
30218
30329
|
const onAbort = () => {
|
|
30219
30330
|
clearTimeout(timer);
|
|
30220
30331
|
reject(signal?.reason ?? new Error("aborted"));
|
|
@@ -30229,7 +30340,7 @@ function withProbeTimeout(promise2, timeoutMs, what, signal) {
|
|
|
30229
30340
|
(value) => {
|
|
30230
30341
|
clearTimeout(timer);
|
|
30231
30342
|
signal?.removeEventListener("abort", onAbort);
|
|
30232
|
-
|
|
30343
|
+
resolve7(value);
|
|
30233
30344
|
},
|
|
30234
30345
|
(error62) => {
|
|
30235
30346
|
clearTimeout(timer);
|
|
@@ -30281,7 +30392,7 @@ function acpAgentVersion(initializeResult) {
|
|
|
30281
30392
|
var MAX_VERSION_OUTPUT_BYTES = 64 * 1024;
|
|
30282
30393
|
|
|
30283
30394
|
// src/agentProcess.ts
|
|
30284
|
-
import { nodeStreamsFromHandle } from "@ycodium-ai/plugin-api/process-stdin";
|
|
30395
|
+
import { nodeStreamsFromHandle as nodeStreamsFromHandle2 } from "@ycodium-ai/plugin-api/process-stdin";
|
|
30285
30396
|
|
|
30286
30397
|
// src/clock.ts
|
|
30287
30398
|
var realAgentClock = {
|
|
@@ -30298,9 +30409,20 @@ var realAgentClock = {
|
|
|
30298
30409
|
// src/profile.ts
|
|
30299
30410
|
import * as NodeCrypto2 from "node:crypto";
|
|
30300
30411
|
import * as NodeFSP from "node:fs/promises";
|
|
30412
|
+
import * as NodePath4 from "node:path";
|
|
30413
|
+
import { mergeLaunchEnv as mergeLaunchEnv2 } from "@ycodium-ai/plugin-api/executor";
|
|
30414
|
+
|
|
30415
|
+
// ../../packages/ycodium-instance-config/src/homePath.ts
|
|
30301
30416
|
import * as NodeOS2 from "node:os";
|
|
30302
30417
|
import * as NodePath3 from "node:path";
|
|
30303
30418
|
import { mergeLaunchEnv } from "@ycodium-ai/plugin-api/executor";
|
|
30419
|
+
function expandHomePath(value) {
|
|
30420
|
+
if (value === "~") return NodeOS2.homedir();
|
|
30421
|
+
if (value.startsWith("~/") || value.startsWith("~\\")) {
|
|
30422
|
+
return NodePath3.join(NodeOS2.homedir(), value.slice(2));
|
|
30423
|
+
}
|
|
30424
|
+
return value;
|
|
30425
|
+
}
|
|
30304
30426
|
|
|
30305
30427
|
// src/hostPlatform.ts
|
|
30306
30428
|
import * as NodeProcess from "node:process";
|
|
@@ -30312,23 +30434,16 @@ var RUN_DIR_PREFIX = "run-";
|
|
|
30312
30434
|
function sha256Hex(value) {
|
|
30313
30435
|
return NodeCrypto2.createHash("sha256").update(value).digest("hex");
|
|
30314
30436
|
}
|
|
30315
|
-
function expandHomePath(value) {
|
|
30316
|
-
if (value === "~") return NodeOS2.homedir();
|
|
30317
|
-
if (value.startsWith("~/") || value.startsWith("~\\")) {
|
|
30318
|
-
return NodePath3.join(NodeOS2.homedir(), value.slice(2));
|
|
30319
|
-
}
|
|
30320
|
-
return value;
|
|
30321
|
-
}
|
|
30322
30437
|
function resolveAntigravityDirectories(input2) {
|
|
30323
30438
|
const key = sha256Hex(input2.instanceId);
|
|
30324
30439
|
const homePath = input2.homePath.trim();
|
|
30325
30440
|
const custom2 = homePath.length > 0;
|
|
30326
|
-
const profile = custom2 ?
|
|
30441
|
+
const profile = custom2 ? NodePath4.resolve(expandHomePath(homePath)) : NodePath4.join(input2.dataDir, "profiles", key);
|
|
30327
30442
|
const continuationSource = custom2 ? `home\0${(input2.platform ?? HOST_PLATFORM) === "win32" ? profile.toLowerCase() : profile}` : `instance\0${input2.instanceId}`;
|
|
30328
30443
|
return {
|
|
30329
30444
|
profile,
|
|
30330
|
-
runtimeTempRoot:
|
|
30331
|
-
modelCacheFile:
|
|
30445
|
+
runtimeTempRoot: NodePath4.join(input2.dataDir, "tmp", key.slice(0, 12)),
|
|
30446
|
+
modelCacheFile: NodePath4.join(input2.dataDir, "model-cache", `${key}.json`),
|
|
30332
30447
|
continuationKey: `antigravity:profile:${sha256Hex(continuationSource).slice(0, 16)}`
|
|
30333
30448
|
};
|
|
30334
30449
|
}
|
|
@@ -30359,7 +30474,7 @@ function buildAntigravityEnvironment(input2) {
|
|
|
30359
30474
|
for (const [name, value] of Object.entries(input2.instanceEnvironment)) {
|
|
30360
30475
|
if (!isRemovedEnvName(name)) instanceTable[name] = value;
|
|
30361
30476
|
}
|
|
30362
|
-
return
|
|
30477
|
+
return mergeLaunchEnv2({
|
|
30363
30478
|
accountHome: suppressed,
|
|
30364
30479
|
instanceTable,
|
|
30365
30480
|
handOverrides: {
|
|
@@ -30376,10 +30491,10 @@ function antigravityLaunchArgs(platform2 = HOST_PLATFORM) {
|
|
|
30376
30491
|
return platform2 === "linux" ? ["--uid="] : [];
|
|
30377
30492
|
}
|
|
30378
30493
|
async function prepareAntigravityProfile(profile) {
|
|
30379
|
-
const acpDirectory =
|
|
30494
|
+
const acpDirectory = NodePath4.join(profile, "antigravity-acp");
|
|
30380
30495
|
await NodeFSP.mkdir(acpDirectory, { recursive: true, mode: 448 });
|
|
30381
30496
|
await NodeFSP.writeFile(
|
|
30382
|
-
|
|
30497
|
+
NodePath4.join(acpDirectory, "settings.json"),
|
|
30383
30498
|
`${JSON.stringify({ auth: { type: "oauth-personal" } })}
|
|
30384
30499
|
`,
|
|
30385
30500
|
"utf8"
|
|
@@ -30388,13 +30503,13 @@ async function prepareAntigravityProfile(profile) {
|
|
|
30388
30503
|
var liveRuntimeTempDirs = /* @__PURE__ */ new Set();
|
|
30389
30504
|
async function createRuntimeTempDir(root) {
|
|
30390
30505
|
await NodeFSP.mkdir(root, { recursive: true, mode: 448 });
|
|
30391
|
-
const directory = await NodeFSP.mkdtemp(
|
|
30506
|
+
const directory = await NodeFSP.mkdtemp(NodePath4.join(root, RUN_DIR_PREFIX));
|
|
30392
30507
|
liveRuntimeTempDirs.add(directory);
|
|
30393
30508
|
return directory;
|
|
30394
30509
|
}
|
|
30395
30510
|
async function removeRuntimeTempDir(directory) {
|
|
30396
30511
|
liveRuntimeTempDirs.delete(directory);
|
|
30397
|
-
if (!
|
|
30512
|
+
if (!NodePath4.isAbsolute(directory) || !NodePath4.basename(directory).startsWith(RUN_DIR_PREFIX)) {
|
|
30398
30513
|
return false;
|
|
30399
30514
|
}
|
|
30400
30515
|
try {
|
|
@@ -30414,7 +30529,7 @@ async function sweepRuntimeTempDirs(root) {
|
|
|
30414
30529
|
let removed = 0;
|
|
30415
30530
|
for (const name of names) {
|
|
30416
30531
|
if (!name.startsWith(RUN_DIR_PREFIX)) continue;
|
|
30417
|
-
const directory =
|
|
30532
|
+
const directory = NodePath4.join(root, name);
|
|
30418
30533
|
if (liveRuntimeTempDirs.has(directory)) continue;
|
|
30419
30534
|
if (await removeRuntimeTempDir(directory)) removed += 1;
|
|
30420
30535
|
}
|
|
@@ -30452,7 +30567,7 @@ var MAX_LOGIN_DETAIL_CHARS = 16384 + 16;
|
|
|
30452
30567
|
var CONFIG_OPTION_UPDATE_MARKER = Buffer.from("config_option_update");
|
|
30453
30568
|
var ANTIGRAVITY_LOGIN_PROMPT_PREFIX = "Open the following link to authenticate the ACP server: ";
|
|
30454
30569
|
var LOGIN_PROMPT_PREFIX_BYTES = Buffer.from(ANTIGRAVITY_LOGIN_PROMPT_PREFIX);
|
|
30455
|
-
function
|
|
30570
|
+
function isRecord7(value) {
|
|
30456
30571
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
30457
30572
|
}
|
|
30458
30573
|
function firstSignificantByte(line) {
|
|
@@ -30465,10 +30580,10 @@ function sniffConfigOptions(line, hooks) {
|
|
|
30465
30580
|
if (hooks.onConfigOptions === void 0 || !line.includes(CONFIG_OPTION_UPDATE_MARKER)) return;
|
|
30466
30581
|
try {
|
|
30467
30582
|
const frame = JSON.parse(line.toString("utf8"));
|
|
30468
|
-
if (!
|
|
30583
|
+
if (!isRecord7(frame) || frame["method"] !== "session/update") return;
|
|
30469
30584
|
const params = frame["params"];
|
|
30470
|
-
const update =
|
|
30471
|
-
if (!
|
|
30585
|
+
const update = isRecord7(params) ? params["update"] : void 0;
|
|
30586
|
+
if (!isRecord7(update) || update["sessionUpdate"] !== "config_option_update") return;
|
|
30472
30587
|
hooks.onConfigOptions(update["configOptions"]);
|
|
30473
30588
|
} catch {
|
|
30474
30589
|
}
|
|
@@ -30559,8 +30674,8 @@ async function waitForExit(handle, timeoutMs, clock) {
|
|
|
30559
30674
|
try {
|
|
30560
30675
|
return await Promise.race([
|
|
30561
30676
|
handle.exited.then(() => true),
|
|
30562
|
-
new Promise((
|
|
30563
|
-
cancel = clock.delay(timeoutMs, () =>
|
|
30677
|
+
new Promise((resolve7) => {
|
|
30678
|
+
cancel = clock.delay(timeoutMs, () => resolve7(false));
|
|
30564
30679
|
})
|
|
30565
30680
|
]);
|
|
30566
30681
|
} finally {
|
|
@@ -30642,7 +30757,7 @@ async function openAgentProcess(input2) {
|
|
|
30642
30757
|
throw error62;
|
|
30643
30758
|
}
|
|
30644
30759
|
const clock = input2.clock ?? realAgentClock;
|
|
30645
|
-
const { readable, writable } =
|
|
30760
|
+
const { readable, writable } = nodeStreamsFromHandle2({
|
|
30646
30761
|
stdout: filterAgentStdout(handle.stdout, { onLoginPrompt: input2.onLoginPrompt }),
|
|
30647
30762
|
stderr: watchAgentStderr(handle.stderr, input2.onLoginPrompt, input2.onBrowserHelperLine),
|
|
30648
30763
|
writeStdin: handle.writeStdin,
|
|
@@ -30652,7 +30767,7 @@ async function openAgentProcess(input2) {
|
|
|
30652
30767
|
const request2 = (method, params, timeoutMs) => {
|
|
30653
30768
|
const pending = connection.request(method, params);
|
|
30654
30769
|
if (timeoutMs === void 0) return pending;
|
|
30655
|
-
return new Promise((
|
|
30770
|
+
return new Promise((resolve7, reject) => {
|
|
30656
30771
|
const cancel = clock.delay(timeoutMs, () => {
|
|
30657
30772
|
reject(
|
|
30658
30773
|
new AntigravityAuthError(
|
|
@@ -30664,7 +30779,7 @@ async function openAgentProcess(input2) {
|
|
|
30664
30779
|
pending.then(
|
|
30665
30780
|
(value) => {
|
|
30666
30781
|
cancel();
|
|
30667
|
-
|
|
30782
|
+
resolve7(value);
|
|
30668
30783
|
},
|
|
30669
30784
|
(error62) => {
|
|
30670
30785
|
cancel();
|
|
@@ -30692,11 +30807,86 @@ async function openAgentProcess(input2) {
|
|
|
30692
30807
|
}
|
|
30693
30808
|
|
|
30694
30809
|
// src/antigravityInstance/session.ts
|
|
30695
|
-
import { nodeStreamsFromHandle as
|
|
30810
|
+
import { nodeStreamsFromHandle as nodeStreamsFromHandle3 } from "@ycodium-ai/plugin-api/process-stdin";
|
|
30811
|
+
|
|
30812
|
+
// ../../packages/ycodium-instance-config/src/instanceConfig.ts
|
|
30813
|
+
import { modelSelectionStringOption as modelSelectionStringOption2 } from "@ycodium-ai/plugin-api/executor";
|
|
30814
|
+
function isRecord8(value) {
|
|
30815
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
30816
|
+
}
|
|
30817
|
+
function readString(value) {
|
|
30818
|
+
return typeof value === "string" ? value : "";
|
|
30819
|
+
}
|
|
30820
|
+
function readTrimmed(value) {
|
|
30821
|
+
return readString(value).trim();
|
|
30822
|
+
}
|
|
30823
|
+
function modelIdFromSelection(selection) {
|
|
30824
|
+
if (!isRecord8(selection)) return void 0;
|
|
30825
|
+
const model = selection["model"];
|
|
30826
|
+
return typeof model === "string" ? model.trim() || void 0 : void 0;
|
|
30827
|
+
}
|
|
30828
|
+
function readEnvironment(value) {
|
|
30829
|
+
if (!Array.isArray(value)) return {};
|
|
30830
|
+
const env = {};
|
|
30831
|
+
for (const entry of value) {
|
|
30832
|
+
if (!isRecord8(entry)) continue;
|
|
30833
|
+
const name = readTrimmed(entry["name"]);
|
|
30834
|
+
if (name.length === 0) continue;
|
|
30835
|
+
env[name] = readString(entry["value"]);
|
|
30836
|
+
}
|
|
30837
|
+
return env;
|
|
30838
|
+
}
|
|
30839
|
+
function instanceSettings(config2) {
|
|
30840
|
+
if (!isRecord8(config2)) return {};
|
|
30841
|
+
return isRecord8(config2["config"]) ? config2["config"] : config2;
|
|
30842
|
+
}
|
|
30843
|
+
function readInstanceEnvelope(config2) {
|
|
30844
|
+
const envelope = isRecord8(config2) ? config2 : {};
|
|
30845
|
+
const settings = instanceSettings(config2);
|
|
30846
|
+
return {
|
|
30847
|
+
settings,
|
|
30848
|
+
settingOrEnvelope: (key) => readTrimmed(settings[key]) || readTrimmed(envelope[key]),
|
|
30849
|
+
environment: readEnvironment(envelope["environment"]),
|
|
30850
|
+
envelopeDriver: readTrimmed(envelope["driver"]) || void 0
|
|
30851
|
+
};
|
|
30852
|
+
}
|
|
30696
30853
|
|
|
30697
30854
|
// src/backgroundCommands.ts
|
|
30698
30855
|
import * as NodeCrypto3 from "node:crypto";
|
|
30699
30856
|
|
|
30857
|
+
// ../../packages/ycodium-instance-config/src/programHomeSchema.ts
|
|
30858
|
+
function programAndHomeConfigSchema(binaryPath) {
|
|
30859
|
+
const binaryForm = {
|
|
30860
|
+
titleKey: "form.binaryPath.title",
|
|
30861
|
+
descriptionKey: "form.binaryPath.description",
|
|
30862
|
+
placeholderKey: "form.binaryPath.placeholder",
|
|
30863
|
+
control: binaryPath.control
|
|
30864
|
+
};
|
|
30865
|
+
if (binaryPath.machineLocal === true) binaryForm["machineLocal"] = true;
|
|
30866
|
+
return {
|
|
30867
|
+
type: "object",
|
|
30868
|
+
"x-ycodium-form-order": ["binaryPath", "homePath"],
|
|
30869
|
+
properties: {
|
|
30870
|
+
binaryPath: { type: "string", "x-ycodium-form": binaryForm },
|
|
30871
|
+
homePath: {
|
|
30872
|
+
type: "string",
|
|
30873
|
+
"x-ycodium-form": {
|
|
30874
|
+
titleKey: "form.homePath.title",
|
|
30875
|
+
machineLocal: true,
|
|
30876
|
+
descriptionKey: "form.homePath.description",
|
|
30877
|
+
placeholderKey: "form.homePath.placeholder"
|
|
30878
|
+
}
|
|
30879
|
+
},
|
|
30880
|
+
enabled: { type: "boolean" },
|
|
30881
|
+
customModels: { type: "array" },
|
|
30882
|
+
driver: { type: "string" },
|
|
30883
|
+
config: { type: "object" },
|
|
30884
|
+
environment: { type: "array" }
|
|
30885
|
+
},
|
|
30886
|
+
additionalProperties: true
|
|
30887
|
+
};
|
|
30888
|
+
}
|
|
30889
|
+
|
|
30700
30890
|
// src/attachments.ts
|
|
30701
30891
|
var ANTIGRAVITY_IMAGE_MIME_TYPES = [
|
|
30702
30892
|
"image/bmp",
|
|
@@ -30707,7 +30897,7 @@ var ANTIGRAVITY_IMAGE_MIME_TYPES = [
|
|
|
30707
30897
|
var IMAGE_MIME_TYPES = new Set(ANTIGRAVITY_IMAGE_MIME_TYPES);
|
|
30708
30898
|
var ANTIGRAVITY_MAX_IMAGE_BYTES = 10 * 1024 * 1024;
|
|
30709
30899
|
var ANTIGRAVITY_MAX_TOTAL_ATTACHMENT_BYTES = 50 * 1024 * 1024;
|
|
30710
|
-
function
|
|
30900
|
+
function isRecord9(value) {
|
|
30711
30901
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
30712
30902
|
}
|
|
30713
30903
|
var TOO_LARGE_HINT = "Antigravity accepts images up to 10 MiB each and 50 MiB total attachments.";
|
|
@@ -30717,7 +30907,7 @@ async function buildAntigravityPromptBlocks(input2) {
|
|
|
30717
30907
|
if (text) blocks.push({ type: "text", text });
|
|
30718
30908
|
let totalBytes = 0;
|
|
30719
30909
|
for (const attachment of input2.attachments ?? []) {
|
|
30720
|
-
if (!
|
|
30910
|
+
if (!isRecord9(attachment) || attachment["type"] !== "image") continue;
|
|
30721
30911
|
const id = typeof attachment["id"] === "string" ? attachment["id"] : "";
|
|
30722
30912
|
const name = typeof attachment["name"] === "string" ? attachment["name"] : id;
|
|
30723
30913
|
const rawMimeType = typeof attachment["mimeType"] === "string" ? attachment["mimeType"] : "";
|
|
@@ -30794,41 +30984,9 @@ var ANTIGRAVITY_CARD = {
|
|
|
30794
30984
|
},
|
|
30795
30985
|
credentialSources: [],
|
|
30796
30986
|
diagnostics: [],
|
|
30797
|
-
//
|
|
30798
|
-
//
|
|
30799
|
-
configSchema: {
|
|
30800
|
-
type: "object",
|
|
30801
|
-
"x-ycodium-form-order": ["binaryPath", "homePath"],
|
|
30802
|
-
properties: {
|
|
30803
|
-
binaryPath: {
|
|
30804
|
-
type: "string",
|
|
30805
|
-
"x-ycodium-form": {
|
|
30806
|
-
titleKey: "form.binaryPath.title",
|
|
30807
|
-
descriptionKey: "form.binaryPath.description",
|
|
30808
|
-
placeholderKey: "form.binaryPath.placeholder",
|
|
30809
|
-
// 不用 executable-path:那个控件要求绝对路径、空着不让加,可空着正是「用这里下载的运行时」。
|
|
30810
|
-
control: "text",
|
|
30811
|
-
// 也就拿不到 executable-path 自带的本机专属,得自己标。
|
|
30812
|
-
machineLocal: true
|
|
30813
|
-
}
|
|
30814
|
-
},
|
|
30815
|
-
homePath: {
|
|
30816
|
-
type: "string",
|
|
30817
|
-
"x-ycodium-form": {
|
|
30818
|
-
titleKey: "form.homePath.title",
|
|
30819
|
-
machineLocal: true,
|
|
30820
|
-
descriptionKey: "form.homePath.description",
|
|
30821
|
-
placeholderKey: "form.homePath.placeholder"
|
|
30822
|
-
}
|
|
30823
|
-
},
|
|
30824
|
-
enabled: { type: "boolean" },
|
|
30825
|
-
customModels: { type: "array" },
|
|
30826
|
-
driver: { type: "string" },
|
|
30827
|
-
config: { type: "object" },
|
|
30828
|
-
environment: { type: "array" }
|
|
30829
|
-
},
|
|
30830
|
-
additionalProperties: true
|
|
30831
|
-
},
|
|
30987
|
+
// 不用 executable-path:那个控件要求绝对路径、空着不让加,可空着正是「用这里下载的运行时」。
|
|
30988
|
+
// 也就拿不到 executable-path 自带的本机专属,所以 binaryPath 自己标 machineLocal。
|
|
30989
|
+
configSchema: programAndHomeConfigSchema({ control: "text", machineLocal: true }),
|
|
30832
30990
|
modelConnectivity: {
|
|
30833
30991
|
dialects: [],
|
|
30834
30992
|
acceptsExternalEndpoints: false
|
|
@@ -30839,9 +30997,9 @@ var ANTIGRAVITY_CARD = {
|
|
|
30839
30997
|
|
|
30840
30998
|
// src/backgroundCommands.ts
|
|
30841
30999
|
var TASK_TYPE = "local_bash";
|
|
30842
|
-
var
|
|
31000
|
+
var isRecord10 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
30843
31001
|
function describeCommand(rawInput, title) {
|
|
30844
|
-
const command =
|
|
31002
|
+
const command = isRecord10(rawInput) ? rawInput["command"] : void 0;
|
|
30845
31003
|
if (typeof command === "string" && command.trim() !== "") return command.trim();
|
|
30846
31004
|
return title?.trim() || "Antigravity command";
|
|
30847
31005
|
}
|
|
@@ -30905,16 +31063,16 @@ function createBackgroundCommandTracker(input2) {
|
|
|
30905
31063
|
|
|
30906
31064
|
// src/clientFiles.ts
|
|
30907
31065
|
import * as NodeFSP2 from "node:fs/promises";
|
|
30908
|
-
import * as
|
|
31066
|
+
import * as NodePath5 from "node:path";
|
|
30909
31067
|
var CLIENT_FILE_MAX_BYTES = 8 * 1024 * 1024;
|
|
30910
|
-
function
|
|
31068
|
+
function isRecord11(value) {
|
|
30911
31069
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
30912
31070
|
}
|
|
30913
31071
|
function isInside(root, candidate) {
|
|
30914
|
-
const relative2 =
|
|
31072
|
+
const relative2 = NodePath5.relative(root, candidate);
|
|
30915
31073
|
if (relative2 === "") return true;
|
|
30916
|
-
const escapes = relative2 === ".." || relative2.startsWith(`..${
|
|
30917
|
-
return !escapes && !
|
|
31074
|
+
const escapes = relative2 === ".." || relative2.startsWith(`..${NodePath5.sep}`);
|
|
31075
|
+
return !escapes && !NodePath5.isAbsolute(relative2);
|
|
30918
31076
|
}
|
|
30919
31077
|
async function realpathOrSelf(target) {
|
|
30920
31078
|
try {
|
|
@@ -30927,13 +31085,13 @@ async function realTarget(resolved) {
|
|
|
30927
31085
|
try {
|
|
30928
31086
|
return await NodeFSP2.realpath(resolved);
|
|
30929
31087
|
} catch {
|
|
30930
|
-
const parent =
|
|
31088
|
+
const parent = NodePath5.dirname(resolved);
|
|
30931
31089
|
if (parent === resolved) return resolved;
|
|
30932
|
-
return
|
|
31090
|
+
return NodePath5.join(await realTarget(parent), NodePath5.basename(resolved));
|
|
30933
31091
|
}
|
|
30934
31092
|
}
|
|
30935
31093
|
async function resolveInside(requestPath, cwd, roots) {
|
|
30936
|
-
const target = await realTarget(
|
|
31094
|
+
const target = await realTarget(NodePath5.resolve(cwd, requestPath));
|
|
30937
31095
|
const realRoots = await Promise.all(roots.map(realpathOrSelf));
|
|
30938
31096
|
if (!realRoots.some((root) => isInside(root, target))) {
|
|
30939
31097
|
throw RequestError.invalidParams(
|
|
@@ -30995,7 +31153,7 @@ async function writeTextFile(params, roots) {
|
|
|
30995
31153
|
const content = requireString(params, "content");
|
|
30996
31154
|
const filePath = await resolveInside(requestPath, roots.cwd, [roots.cwd]);
|
|
30997
31155
|
try {
|
|
30998
|
-
await NodeFSP2.mkdir(
|
|
31156
|
+
await NodeFSP2.mkdir(NodePath5.dirname(filePath), { recursive: true });
|
|
30999
31157
|
await NodeFSP2.writeFile(filePath, content, "utf8");
|
|
31000
31158
|
} catch {
|
|
31001
31159
|
throw RequestError.internalError(void 0, `Could not write '${requestPath}'.`);
|
|
@@ -31007,7 +31165,7 @@ function createClientFileHandler(roots) {
|
|
|
31007
31165
|
if (method !== CLIENT_METHODS.fs_read_text_file && method !== CLIENT_METHODS.fs_write_text_file) {
|
|
31008
31166
|
return void 0;
|
|
31009
31167
|
}
|
|
31010
|
-
if (!
|
|
31168
|
+
if (!isRecord11(params)) {
|
|
31011
31169
|
throw RequestError.invalidParams(void 0, "Malformed file request.");
|
|
31012
31170
|
}
|
|
31013
31171
|
return method === CLIENT_METHODS.fs_read_text_file ? readTextFile(params, roots) : writeTextFile(params, roots);
|
|
@@ -31016,19 +31174,19 @@ function createClientFileHandler(roots) {
|
|
|
31016
31174
|
|
|
31017
31175
|
// src/modelCache.ts
|
|
31018
31176
|
import * as NodeFSP3 from "node:fs/promises";
|
|
31019
|
-
import * as
|
|
31177
|
+
import * as NodePath6 from "node:path";
|
|
31020
31178
|
var SCHEMA_VERSION = 1;
|
|
31021
|
-
function
|
|
31179
|
+
function isRecord12(value) {
|
|
31022
31180
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
31023
31181
|
}
|
|
31024
31182
|
function antigravityCatalogFromSetup(setup) {
|
|
31025
|
-
if (!
|
|
31183
|
+
if (!isRecord12(setup)) return void 0;
|
|
31026
31184
|
const configOptions = setup["configOptions"];
|
|
31027
31185
|
if (Array.isArray(configOptions)) {
|
|
31028
31186
|
const modelOption = configOptions.find(
|
|
31029
|
-
(option) =>
|
|
31187
|
+
(option) => isRecord12(option) && (option["category"] === "model" || option["id"] === "model")
|
|
31030
31188
|
);
|
|
31031
|
-
if (
|
|
31189
|
+
if (isRecord12(modelOption)) {
|
|
31032
31190
|
const choices2 = acpModelChoicesFromConfigOptions([{ ...modelOption, category: "model" }]);
|
|
31033
31191
|
if (choices2 !== void 0) return catalogFromChoices(choices2);
|
|
31034
31192
|
}
|
|
@@ -31046,12 +31204,12 @@ function catalogFromChoices(choices) {
|
|
|
31046
31204
|
};
|
|
31047
31205
|
}
|
|
31048
31206
|
function parseCache(raw) {
|
|
31049
|
-
if (!
|
|
31207
|
+
if (!isRecord12(raw) || raw["schemaVersion"] !== SCHEMA_VERSION) return void 0;
|
|
31050
31208
|
const rawModels = raw["models"];
|
|
31051
31209
|
if (!Array.isArray(rawModels)) return void 0;
|
|
31052
31210
|
const models = [];
|
|
31053
31211
|
for (const entry of rawModels) {
|
|
31054
|
-
if (!
|
|
31212
|
+
if (!isRecord12(entry) || typeof entry["slug"] !== "string" || entry["slug"].trim() === "") {
|
|
31055
31213
|
continue;
|
|
31056
31214
|
}
|
|
31057
31215
|
const name = entry["name"];
|
|
@@ -31096,7 +31254,7 @@ function updateAntigravityModelCache(file2, patch) {
|
|
|
31096
31254
|
...currentModel === void 0 ? {} : { currentModel },
|
|
31097
31255
|
models: catalog?.models ?? existing?.models ?? []
|
|
31098
31256
|
};
|
|
31099
|
-
await NodeFSP3.mkdir(
|
|
31257
|
+
await NodeFSP3.mkdir(NodePath6.dirname(file2), { recursive: true });
|
|
31100
31258
|
const temporary = `${file2}.${String(process.pid)}.tmp`;
|
|
31101
31259
|
await NodeFSP3.writeFile(temporary, `${JSON.stringify(merged)}
|
|
31102
31260
|
`, "utf8");
|
|
@@ -31142,7 +31300,7 @@ var PAYLOAD_NODES = 512;
|
|
|
31142
31300
|
var PAYLOAD_TEXT = 64e3;
|
|
31143
31301
|
var CONTENT_TEXT = 32e3;
|
|
31144
31302
|
var MAX_DEPTH = 12;
|
|
31145
|
-
var
|
|
31303
|
+
var isRecord13 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
31146
31304
|
var copyText = (text) => Buffer.from(text, "utf16le").toString("utf16le");
|
|
31147
31305
|
function boundText(text, limit = TEXT_LIMIT) {
|
|
31148
31306
|
return text.length <= limit ? text : copyText(`${TRUNCATED_PREFIX}${text.slice(-limit)}`);
|
|
@@ -31164,7 +31322,7 @@ function sanitizeValue(value, budget, depth) {
|
|
|
31164
31322
|
}
|
|
31165
31323
|
return result;
|
|
31166
31324
|
}
|
|
31167
|
-
if (!
|
|
31325
|
+
if (!isRecord13(value)) return value;
|
|
31168
31326
|
const entries = [];
|
|
31169
31327
|
for (const [key, entry] of Object.entries(value)) {
|
|
31170
31328
|
if (budget.nodes <= 0) break;
|
|
@@ -31184,11 +31342,11 @@ function sanitizeToolPayload(payload) {
|
|
|
31184
31342
|
return sanitizeValue(payload, { nodes: PAYLOAD_NODES, text: PAYLOAD_TEXT }, 0);
|
|
31185
31343
|
}
|
|
31186
31344
|
function isUsableContent(entry) {
|
|
31187
|
-
if (!
|
|
31345
|
+
if (!isRecord13(entry)) return false;
|
|
31188
31346
|
switch (entry["type"]) {
|
|
31189
31347
|
case "content": {
|
|
31190
31348
|
const block = entry["content"];
|
|
31191
|
-
if (!
|
|
31349
|
+
if (!isRecord13(block)) return false;
|
|
31192
31350
|
switch (block["type"]) {
|
|
31193
31351
|
case "text":
|
|
31194
31352
|
return typeof block["text"] === "string";
|
|
@@ -31198,7 +31356,7 @@ function isUsableContent(entry) {
|
|
|
31198
31356
|
case "resource_link":
|
|
31199
31357
|
return typeof block["uri"] === "string" && typeof block["name"] === "string";
|
|
31200
31358
|
case "resource":
|
|
31201
|
-
return
|
|
31359
|
+
return isRecord13(block["resource"]);
|
|
31202
31360
|
default:
|
|
31203
31361
|
return false;
|
|
31204
31362
|
}
|
|
@@ -31232,7 +31390,7 @@ function transformAntigravitySessionUpdate(notification) {
|
|
|
31232
31390
|
return isUsableContent(sanitized) ? [sanitized] : [];
|
|
31233
31391
|
})
|
|
31234
31392
|
} : {},
|
|
31235
|
-
...meta3 === void 0 ? {} : { _meta:
|
|
31393
|
+
...meta3 === void 0 ? {} : { _meta: isRecord13(sanitizedMeta) ? sanitizedMeta : null }
|
|
31236
31394
|
};
|
|
31237
31395
|
return { ...notification, update: next };
|
|
31238
31396
|
}
|
|
@@ -31245,7 +31403,7 @@ var SUBAGENT_TITLES = /* @__PURE__ */ new Set([
|
|
|
31245
31403
|
"Running start_subagent",
|
|
31246
31404
|
"Run start_subagent?"
|
|
31247
31405
|
]);
|
|
31248
|
-
var
|
|
31406
|
+
var isRecord14 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
31249
31407
|
function outputText(rawOutput) {
|
|
31250
31408
|
return typeof rawOutput === "string" && rawOutput.trim() !== "" ? boundText(rawOutput.trim()) : void 0;
|
|
31251
31409
|
}
|
|
@@ -31253,7 +31411,7 @@ var antigravityToolSubagents = {
|
|
|
31253
31411
|
recognize: (call) => {
|
|
31254
31412
|
if (call.kind !== void 0 && call.kind !== "other") return void 0;
|
|
31255
31413
|
if (call.title === void 0 || !SUBAGENT_TITLES.has(call.title)) return void 0;
|
|
31256
|
-
return
|
|
31414
|
+
return isRecord14(call.meta) && call.meta["is_mcp_tool_call"] === true ? "exclude" : "subagent";
|
|
31257
31415
|
},
|
|
31258
31416
|
// `start_subagent` 返回的是启动说明,不是子代理的结果:即使工具已 completed,批也还在跑。
|
|
31259
31417
|
facts: (call, _kind, previous) => {
|
|
@@ -31316,7 +31474,7 @@ function antigravityPermissionUserInput(request2) {
|
|
|
31316
31474
|
// src/userSkills.ts
|
|
31317
31475
|
import * as NodeFSP4 from "node:fs/promises";
|
|
31318
31476
|
import * as NodeOS3 from "node:os";
|
|
31319
|
-
import * as
|
|
31477
|
+
import * as NodePath7 from "node:path";
|
|
31320
31478
|
var ANTIGRAVITY_SKILL_SCAN_LIMITS = {
|
|
31321
31479
|
maxSkillBytes: 1e6,
|
|
31322
31480
|
maxScanBytes: 8e6,
|
|
@@ -31334,24 +31492,24 @@ function resolveAntigravityUserHome(platform2, environment) {
|
|
|
31334
31492
|
}
|
|
31335
31493
|
function antigravityUserSkillDirectories(geminiHome) {
|
|
31336
31494
|
return [
|
|
31337
|
-
|
|
31338
|
-
|
|
31495
|
+
NodePath7.join(geminiHome, "config", "skills"),
|
|
31496
|
+
NodePath7.join(geminiHome, "antigravity-cli", "skills")
|
|
31339
31497
|
];
|
|
31340
31498
|
}
|
|
31341
31499
|
var sameFilePath = (platform2, left, right) => platform2 === "win32" ? left.toLowerCase() === right.toLowerCase() : left === right;
|
|
31342
31500
|
async function linkOne(link, target, platform2) {
|
|
31343
|
-
if (sameFilePath(platform2,
|
|
31501
|
+
if (sameFilePath(platform2, NodePath7.resolve(link), target)) return "kept";
|
|
31344
31502
|
const existing = await NodeFSP4.lstat(link).catch((error62) => {
|
|
31345
31503
|
if (error62.code === "ENOENT") return void 0;
|
|
31346
31504
|
throw error62;
|
|
31347
31505
|
});
|
|
31348
31506
|
if (existing !== void 0) {
|
|
31349
31507
|
if (!existing.isSymbolicLink()) return "kept";
|
|
31350
|
-
const current =
|
|
31508
|
+
const current = NodePath7.resolve(NodePath7.dirname(link), await NodeFSP4.readlink(link));
|
|
31351
31509
|
if (sameFilePath(platform2, current, target)) return "already";
|
|
31352
31510
|
await NodeFSP4.unlink(link);
|
|
31353
31511
|
}
|
|
31354
|
-
await NodeFSP4.mkdir(
|
|
31512
|
+
await NodeFSP4.mkdir(NodePath7.dirname(link), { recursive: true });
|
|
31355
31513
|
try {
|
|
31356
31514
|
await NodeFSP4.symlink(target, link, platform2 === "win32" ? "junction" : "dir");
|
|
31357
31515
|
} catch (error62) {
|
|
@@ -31362,7 +31520,7 @@ async function linkOne(link, target, platform2) {
|
|
|
31362
31520
|
async function linkAntigravityUserSkills(input2) {
|
|
31363
31521
|
const links = antigravityUserSkillDirectories(input2.profile);
|
|
31364
31522
|
const targets = antigravityUserSkillDirectories(
|
|
31365
|
-
|
|
31523
|
+
NodePath7.resolve(NodePath7.join(input2.userHome, ".gemini"))
|
|
31366
31524
|
);
|
|
31367
31525
|
const results = [];
|
|
31368
31526
|
for (const [index, link] of links.entries()) {
|
|
@@ -31495,7 +31653,7 @@ async function readSkillFile(skillPath, budget, maxSkillBytes) {
|
|
|
31495
31653
|
}
|
|
31496
31654
|
}
|
|
31497
31655
|
async function discoverAntigravityUserSkills(userHome, limits = ANTIGRAVITY_SKILL_SCAN_LIMITS) {
|
|
31498
|
-
const roots = antigravityUserSkillDirectories(
|
|
31656
|
+
const roots = antigravityUserSkillDirectories(NodePath7.join(userHome, ".gemini"));
|
|
31499
31657
|
const budget = {
|
|
31500
31658
|
remainingBytes: limits.maxScanBytes,
|
|
31501
31659
|
remainingEntries: limits.maxScanEntries
|
|
@@ -31519,7 +31677,7 @@ async function discoverAntigravityUserSkills(userHome, limits = ANTIGRAVITY_SKIL
|
|
|
31519
31677
|
const skillFileName = sorted.find((entry) => entry.toLowerCase() === "skill.md");
|
|
31520
31678
|
if (skillFileName !== void 0) {
|
|
31521
31679
|
if (!skillFileName.endsWith(".md")) return;
|
|
31522
|
-
const skillPath =
|
|
31680
|
+
const skillPath = NodePath7.join(directory, skillFileName);
|
|
31523
31681
|
const contents = await readSkillFile(skillPath, budget, limits.maxSkillBytes);
|
|
31524
31682
|
if (contents === void 0) return;
|
|
31525
31683
|
const skill = parseSkillFile(contents, skillFileName);
|
|
@@ -31535,7 +31693,7 @@ async function discoverAntigravityUserSkills(userHome, limits = ANTIGRAVITY_SKIL
|
|
|
31535
31693
|
}
|
|
31536
31694
|
if (!scanChildren) return;
|
|
31537
31695
|
for (const entry of sorted.toSorted(compareSkillEntries)) {
|
|
31538
|
-
await scanDirectory(
|
|
31696
|
+
await scanDirectory(NodePath7.join(directory, entry), false);
|
|
31539
31697
|
}
|
|
31540
31698
|
};
|
|
31541
31699
|
for (const root of roots) await scanDirectory(root, true);
|
|
@@ -31544,17 +31702,10 @@ async function discoverAntigravityUserSkills(userHome, limits = ANTIGRAVITY_SKIL
|
|
|
31544
31702
|
|
|
31545
31703
|
// src/antigravityInstance/shared.ts
|
|
31546
31704
|
var CLIENT_INFO = { name: "ycodium-agent-antigravity", version: "0.1.0" };
|
|
31547
|
-
var
|
|
31548
|
-
setImmediate(
|
|
31705
|
+
var yieldTick2 = () => new Promise((resolve7) => {
|
|
31706
|
+
setImmediate(resolve7);
|
|
31549
31707
|
});
|
|
31550
|
-
function
|
|
31551
|
-
if (typeof selection !== "object" || selection === null || Array.isArray(selection)) {
|
|
31552
|
-
return void 0;
|
|
31553
|
-
}
|
|
31554
|
-
const model = selection["model"];
|
|
31555
|
-
return typeof model === "string" ? model.trim() || void 0 : void 0;
|
|
31556
|
-
}
|
|
31557
|
-
function nowIso() {
|
|
31708
|
+
function nowIso2() {
|
|
31558
31709
|
return (/* @__PURE__ */ new Date()).toISOString();
|
|
31559
31710
|
}
|
|
31560
31711
|
function modelUnavailableError2(model) {
|
|
@@ -31657,7 +31808,7 @@ function createAntigravitySession({
|
|
|
31657
31808
|
void stopAgentProcess(handle, exitWaitMs, host.log, clock);
|
|
31658
31809
|
}
|
|
31659
31810
|
};
|
|
31660
|
-
const { readable, writable, stderrTail } =
|
|
31811
|
+
const { readable, writable, stderrTail } = nodeStreamsFromHandle3({
|
|
31661
31812
|
stdout: filterAgentStdout(handle.stdout, {
|
|
31662
31813
|
onLoginPrompt,
|
|
31663
31814
|
onConfigOptions: (configOptions) => {
|
|
@@ -31737,7 +31888,7 @@ function createAntigravitySession({
|
|
|
31737
31888
|
throwIfStartAborted(signal);
|
|
31738
31889
|
const catalog = antigravityCatalogFromSetup(started.sessionSetupResult);
|
|
31739
31890
|
recordCatalog(live, catalog, acpAgentVersion(started.initializeResult) ?? void 0);
|
|
31740
|
-
const matchedModel = requestedModelId === void 0 || live.knownModelValues.length === 0 ? void 0 :
|
|
31891
|
+
const matchedModel = requestedModelId === void 0 || live.knownModelValues.length === 0 ? void 0 : matchCatalogModel(requestedModelId, live.knownModelValues);
|
|
31741
31892
|
if (requestedModelId !== void 0 && live.knownModelValues.length > 0 && matchedModel === void 0) {
|
|
31742
31893
|
throw modelUnavailableError2(requestedModelId);
|
|
31743
31894
|
}
|
|
@@ -31751,9 +31902,9 @@ function createAntigravitySession({
|
|
|
31751
31902
|
),
|
|
31752
31903
|
signal
|
|
31753
31904
|
) ?? acpCurrentModeId(started.sessionSetupResult);
|
|
31754
|
-
await
|
|
31905
|
+
await yieldTick2();
|
|
31755
31906
|
throwIfStartAborted(signal);
|
|
31756
|
-
const createdAt =
|
|
31907
|
+
const createdAt = nowIso2();
|
|
31757
31908
|
const resumeCursor = {
|
|
31758
31909
|
schemaVersion: RESUME_SCHEMA_VERSION,
|
|
31759
31910
|
sessionId: started.sessionId
|
|
@@ -31820,9 +31971,9 @@ function createAntigravityTurn({
|
|
|
31820
31971
|
}) {
|
|
31821
31972
|
const runLogoutTurn = async (booked, input2) => {
|
|
31822
31973
|
const turnId = input2.expectedTurnId ?? NodeCrypto4.randomUUID();
|
|
31823
|
-
const stamp = () => ({ eventId: NodeCrypto4.randomUUID(), createdAt:
|
|
31974
|
+
const stamp = () => ({ eventId: NodeCrypto4.randomUUID(), createdAt: nowIso2() });
|
|
31824
31975
|
const base = { provider: ANTIGRAVITY_DRIVER_KIND, threadId: input2.threadId, turnId };
|
|
31825
|
-
booked.session = { ...booked.session, status: "running", updatedAt:
|
|
31976
|
+
booked.session = { ...booked.session, status: "running", updatedAt: nowIso2() };
|
|
31826
31977
|
booked.events.emit({ type: "turn.started", ...stamp(), ...base, payload: {} });
|
|
31827
31978
|
let reply;
|
|
31828
31979
|
try {
|
|
@@ -31871,21 +32022,21 @@ function createAntigravityTurn({
|
|
|
31871
32022
|
readAttachment: attachments === void 0 ? void 0 : (attachmentId) => attachments.read(attachmentId)
|
|
31872
32023
|
});
|
|
31873
32024
|
const requestedModelId = modelIdFromSelection(input2.modelSelection);
|
|
31874
|
-
if (requestedModelId !== void 0 && booked.live.knownModelValues.length > 0 &&
|
|
32025
|
+
if (requestedModelId !== void 0 && booked.live.knownModelValues.length > 0 && matchCatalogModel(requestedModelId, booked.live.knownModelValues) === void 0) {
|
|
31875
32026
|
throw modelUnavailableError2(requestedModelId);
|
|
31876
32027
|
}
|
|
31877
32028
|
const onAbort = () => {
|
|
31878
32029
|
void booked.executor.cancel(input2.expectedTurnId).catch(() => void 0);
|
|
31879
32030
|
};
|
|
31880
32031
|
signal?.addEventListener("abort", onAbort);
|
|
31881
|
-
booked.session = { ...booked.session, status: "running", updatedAt:
|
|
32032
|
+
booked.session = { ...booked.session, status: "running", updatedAt: nowIso2() };
|
|
31882
32033
|
try {
|
|
31883
32034
|
const turn = await booked.executor.prompt({
|
|
31884
32035
|
prompt: blocks,
|
|
31885
32036
|
...input2.expectedTurnId === void 0 ? {} : { turnId: input2.expectedTurnId },
|
|
31886
32037
|
...requestedModelId === void 0 ? {} : { requestedModelId }
|
|
31887
32038
|
});
|
|
31888
|
-
await
|
|
32039
|
+
await yieldTick2();
|
|
31889
32040
|
booked.turns.push({ id: turn.turnId, items: [] });
|
|
31890
32041
|
booked.session = {
|
|
31891
32042
|
...booked.session,
|
|
@@ -31900,44 +32051,20 @@ function createAntigravityTurn({
|
|
|
31900
32051
|
throw booked.live.signInRequired ? new AntigravitySignInRequiredError() : error62;
|
|
31901
32052
|
} finally {
|
|
31902
32053
|
signal?.removeEventListener("abort", onAbort);
|
|
31903
|
-
booked.session = { ...booked.session, status: "idle", updatedAt:
|
|
32054
|
+
booked.session = { ...booked.session, status: "idle", updatedAt: nowIso2() };
|
|
31904
32055
|
}
|
|
31905
32056
|
}
|
|
31906
32057
|
};
|
|
31907
32058
|
}
|
|
31908
32059
|
|
|
31909
32060
|
// src/config.ts
|
|
31910
|
-
function isRecord13(value) {
|
|
31911
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
31912
|
-
}
|
|
31913
|
-
function readString(value) {
|
|
31914
|
-
return typeof value === "string" ? value : "";
|
|
31915
|
-
}
|
|
31916
|
-
function readTrimmed(value) {
|
|
31917
|
-
return readString(value).trim();
|
|
31918
|
-
}
|
|
31919
|
-
function readEnvironment(value) {
|
|
31920
|
-
if (!Array.isArray(value)) return {};
|
|
31921
|
-
const env = {};
|
|
31922
|
-
for (const entry of value) {
|
|
31923
|
-
if (!isRecord13(entry)) continue;
|
|
31924
|
-
const name = readTrimmed(entry["name"]);
|
|
31925
|
-
if (name.length === 0) continue;
|
|
31926
|
-
env[name] = readString(entry["value"]);
|
|
31927
|
-
}
|
|
31928
|
-
return env;
|
|
31929
|
-
}
|
|
31930
32061
|
function parseAntigravityInstanceConfig(config2) {
|
|
31931
|
-
|
|
31932
|
-
return { binaryPath: "", homePath: "", environment: {}, envelopeDriver: void 0 };
|
|
31933
|
-
}
|
|
31934
|
-
const nested = isRecord13(config2["config"]) ? config2["config"] : void 0;
|
|
31935
|
-
const settings = nested ?? config2;
|
|
32062
|
+
const envelope = readInstanceEnvelope(config2);
|
|
31936
32063
|
return {
|
|
31937
|
-
binaryPath: readTrimmed(settings["binaryPath"]),
|
|
31938
|
-
homePath:
|
|
31939
|
-
environment:
|
|
31940
|
-
envelopeDriver:
|
|
32064
|
+
binaryPath: readTrimmed(envelope.settings["binaryPath"]),
|
|
32065
|
+
homePath: envelope.settingOrEnvelope("homePath"),
|
|
32066
|
+
environment: envelope.environment,
|
|
32067
|
+
envelopeDriver: envelope.envelopeDriver
|
|
31941
32068
|
};
|
|
31942
32069
|
}
|
|
31943
32070
|
|
|
@@ -32016,14 +32143,14 @@ function forwardCallback(callback, timeoutMs = FORWARD_TIMEOUT_MS) {
|
|
|
32016
32143
|
"callback-delivery-failed",
|
|
32017
32144
|
"Could not deliver the sign-in response. Start sign-in again."
|
|
32018
32145
|
);
|
|
32019
|
-
return new Promise((
|
|
32146
|
+
return new Promise((resolve7, reject) => {
|
|
32020
32147
|
let settled = false;
|
|
32021
32148
|
const settle2 = (error62) => {
|
|
32022
32149
|
if (settled) return;
|
|
32023
32150
|
settled = true;
|
|
32024
32151
|
clearTimeout(timer);
|
|
32025
32152
|
request2.destroy();
|
|
32026
|
-
if (error62 === void 0)
|
|
32153
|
+
if (error62 === void 0) resolve7();
|
|
32027
32154
|
else reject(error62);
|
|
32028
32155
|
};
|
|
32029
32156
|
const request2 = NodeHttp.request(
|
|
@@ -32053,12 +32180,12 @@ function forwardCallback(callback, timeoutMs = FORWARD_TIMEOUT_MS) {
|
|
|
32053
32180
|
|
|
32054
32181
|
// src/runtime.ts
|
|
32055
32182
|
import * as NodeFSP6 from "node:fs/promises";
|
|
32056
|
-
import * as
|
|
32183
|
+
import * as NodePath9 from "node:path";
|
|
32057
32184
|
|
|
32058
32185
|
// src/managedRuntime.ts
|
|
32059
32186
|
import * as NodeCrypto5 from "node:crypto";
|
|
32060
32187
|
import * as NodeFSP5 from "node:fs/promises";
|
|
32061
|
-
import * as
|
|
32188
|
+
import * as NodePath8 from "node:path";
|
|
32062
32189
|
var RELEASE_RECORD_FILE = ".install-complete.json";
|
|
32063
32190
|
var RELEASE_ID_PATTERN = /^[a-f0-9]{64}$/u;
|
|
32064
32191
|
var RECORD_MAX_BYTES = 8 * 1024;
|
|
@@ -32066,17 +32193,17 @@ var ManagedRuntimeInvalidError = class extends Error {
|
|
|
32066
32193
|
name = "ManagedRuntimeInvalidError";
|
|
32067
32194
|
};
|
|
32068
32195
|
function managedLayout(dataDir, platform2, arch2) {
|
|
32069
|
-
const root =
|
|
32196
|
+
const root = NodePath8.join(dataDir, "runtime", `${platform2}-${arch2}`);
|
|
32070
32197
|
return {
|
|
32071
32198
|
root,
|
|
32072
|
-
versionsDir:
|
|
32073
|
-
activeFile:
|
|
32199
|
+
versionsDir: NodePath8.join(root, "versions"),
|
|
32200
|
+
activeFile: NodePath8.join(root, "active.json")
|
|
32074
32201
|
};
|
|
32075
32202
|
}
|
|
32076
32203
|
function versionDirectoryOf(layout, releaseId) {
|
|
32077
|
-
return
|
|
32204
|
+
return NodePath8.join(layout.versionsDir, releaseId);
|
|
32078
32205
|
}
|
|
32079
|
-
function
|
|
32206
|
+
function isRecord15(value) {
|
|
32080
32207
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
32081
32208
|
}
|
|
32082
32209
|
function isMissing2(error62) {
|
|
@@ -32102,7 +32229,7 @@ async function readActiveReleaseId(layout) {
|
|
|
32102
32229
|
if (isMissing2(error62)) return void 0;
|
|
32103
32230
|
throw error62;
|
|
32104
32231
|
}
|
|
32105
|
-
const releaseId =
|
|
32232
|
+
const releaseId = isRecord15(parsed) ? parsed["releaseId"] : void 0;
|
|
32106
32233
|
if (typeof releaseId !== "string" || !RELEASE_ID_PATTERN.test(releaseId)) {
|
|
32107
32234
|
throw new ManagedRuntimeInvalidError("The managed runtime record is invalid. Reinstall it.");
|
|
32108
32235
|
}
|
|
@@ -32119,7 +32246,7 @@ async function isExecutableFile(candidate, bytes, platform2) {
|
|
|
32119
32246
|
}
|
|
32120
32247
|
}
|
|
32121
32248
|
function readSpec(value) {
|
|
32122
|
-
if (!
|
|
32249
|
+
if (!isRecord15(value)) return void 0;
|
|
32123
32250
|
const { name, bytes } = value;
|
|
32124
32251
|
if (typeof name !== "string" || typeof bytes !== "number") return void 0;
|
|
32125
32252
|
if (!Number.isSafeInteger(bytes) || bytes <= 0) return void 0;
|
|
@@ -32132,20 +32259,20 @@ async function readCompletedRelease(input2) {
|
|
|
32132
32259
|
const directory = versionDirectoryOf(input2.layout, input2.releaseId);
|
|
32133
32260
|
let parsed;
|
|
32134
32261
|
try {
|
|
32135
|
-
parsed = await readSmallJson(
|
|
32262
|
+
parsed = await readSmallJson(NodePath8.join(directory, RELEASE_RECORD_FILE));
|
|
32136
32263
|
} catch (error62) {
|
|
32137
32264
|
if (isMissing2(error62)) throw incomplete;
|
|
32138
32265
|
throw error62;
|
|
32139
32266
|
}
|
|
32140
|
-
if (!
|
|
32267
|
+
if (!isRecord15(parsed)) throw incomplete;
|
|
32141
32268
|
const executable = readSpec(parsed["executable"]);
|
|
32142
32269
|
const harness = readSpec(parsed["harness"]);
|
|
32143
32270
|
const version2 = parsed["version"];
|
|
32144
32271
|
if (parsed["releaseId"] !== input2.releaseId || executable === void 0 || harness === void 0 || typeof version2 !== "string" || version2.trim().length === 0 || executable.name !== input2.names.executable || harness.name !== input2.names.harness) {
|
|
32145
32272
|
throw incomplete;
|
|
32146
32273
|
}
|
|
32147
|
-
const executablePath =
|
|
32148
|
-
const harnessPath =
|
|
32274
|
+
const executablePath = NodePath8.join(directory, executable.name);
|
|
32275
|
+
const harnessPath = NodePath8.join(directory, harness.name);
|
|
32149
32276
|
if (!await isExecutableFile(executablePath, executable.bytes, input2.platform) || !await isExecutableFile(harnessPath, harness.bytes, input2.platform)) {
|
|
32150
32277
|
throw incomplete;
|
|
32151
32278
|
}
|
|
@@ -32164,7 +32291,7 @@ async function readActiveRelease(input2) {
|
|
|
32164
32291
|
}
|
|
32165
32292
|
async function writeReleaseRecord(directory, record2) {
|
|
32166
32293
|
await NodeFSP5.writeFile(
|
|
32167
|
-
|
|
32294
|
+
NodePath8.join(directory, RELEASE_RECORD_FILE),
|
|
32168
32295
|
`${JSON.stringify(record2)}
|
|
32169
32296
|
`,
|
|
32170
32297
|
{ flag: "wx", mode: 384 }
|
|
@@ -32172,7 +32299,7 @@ async function writeReleaseRecord(directory, record2) {
|
|
|
32172
32299
|
}
|
|
32173
32300
|
async function writeActiveRelease(layout, releaseId) {
|
|
32174
32301
|
await NodeFSP5.mkdir(layout.root, { recursive: true });
|
|
32175
|
-
const pending =
|
|
32302
|
+
const pending = NodePath8.join(
|
|
32176
32303
|
layout.root,
|
|
32177
32304
|
`active.json.${NodeCrypto5.randomBytes(6).toString("hex")}.tmp`
|
|
32178
32305
|
);
|
|
@@ -32220,14 +32347,14 @@ function readPathValue(instanceEnvironment, processEnv, platform2) {
|
|
|
32220
32347
|
return lookup(instanceEnvironment) ?? lookup(processEnv) ?? "";
|
|
32221
32348
|
}
|
|
32222
32349
|
function pathCandidates(binary, pathValue) {
|
|
32223
|
-
return pathValue.split(
|
|
32350
|
+
return pathValue.split(NodePath9.delimiter).map((directory) => directory.trim().replace(/^"|"$/gu, "")).filter((directory) => directory.length > 0).map((directory) => NodePath9.resolve(directory, binary));
|
|
32224
32351
|
}
|
|
32225
32352
|
async function managedDirectoryOf(executablePath, managed) {
|
|
32226
32353
|
if (managed === void 0) return null;
|
|
32227
32354
|
try {
|
|
32228
32355
|
const realVersions = await NodeFSP6.realpath(managed.versionsDir);
|
|
32229
|
-
const directory =
|
|
32230
|
-
return
|
|
32356
|
+
const directory = NodePath9.dirname(executablePath);
|
|
32357
|
+
return NodePath9.dirname(directory) === realVersions && RELEASE_ID_PATTERN.test(NodePath9.basename(directory)) ? directory : null;
|
|
32231
32358
|
} catch {
|
|
32232
32359
|
return null;
|
|
32233
32360
|
}
|
|
@@ -32240,7 +32367,7 @@ async function resolveAntigravityExecutable(input2) {
|
|
|
32240
32367
|
const accept = async (candidate, source) => {
|
|
32241
32368
|
if (!await isExecutableFile2(candidate, platform2)) return void 0;
|
|
32242
32369
|
const executablePath = await NodeFSP6.realpath(candidate);
|
|
32243
|
-
const harnessPath =
|
|
32370
|
+
const harnessPath = NodePath9.join(NodePath9.dirname(executablePath), names.harness);
|
|
32244
32371
|
if (!await isExecutableFile2(harnessPath, platform2)) return void 0;
|
|
32245
32372
|
return {
|
|
32246
32373
|
executablePath,
|
|
@@ -32251,7 +32378,7 @@ async function resolveAntigravityExecutable(input2) {
|
|
|
32251
32378
|
};
|
|
32252
32379
|
};
|
|
32253
32380
|
if (configured.length > 0) {
|
|
32254
|
-
const candidates =
|
|
32381
|
+
const candidates = NodePath9.isAbsolute(configured) || configured.includes("/") || configured.includes("\\") ? [NodePath9.resolve(configured)] : pathCandidates(configured, pathValue);
|
|
32255
32382
|
for (const candidate of candidates) {
|
|
32256
32383
|
const found = await accept(candidate, "configured");
|
|
32257
32384
|
if (found !== void 0) return found;
|
|
@@ -32290,10 +32417,10 @@ async function resolveAntigravityExecutable(input2) {
|
|
|
32290
32417
|
|
|
32291
32418
|
// src/signedInMarker.ts
|
|
32292
32419
|
import * as NodeFSP7 from "node:fs/promises";
|
|
32293
|
-
import * as
|
|
32420
|
+
import * as NodePath10 from "node:path";
|
|
32294
32421
|
var SCHEMA_VERSION2 = 1;
|
|
32295
32422
|
function signedInMarkerFile(profile) {
|
|
32296
|
-
return
|
|
32423
|
+
return NodePath10.join(profile, "antigravity-acp", "ycodium-signed-in.json");
|
|
32297
32424
|
}
|
|
32298
32425
|
async function readSignedInMarker(file2) {
|
|
32299
32426
|
try {
|
|
@@ -32304,7 +32431,7 @@ async function readSignedInMarker(file2) {
|
|
|
32304
32431
|
}
|
|
32305
32432
|
}
|
|
32306
32433
|
async function writeSignedInMarker(file2) {
|
|
32307
|
-
await NodeFSP7.mkdir(
|
|
32434
|
+
await NodeFSP7.mkdir(NodePath10.dirname(file2), { recursive: true, mode: 448 });
|
|
32308
32435
|
const temporary = `${file2}.${String(process.pid)}.tmp`;
|
|
32309
32436
|
await NodeFSP7.writeFile(
|
|
32310
32437
|
temporary,
|
|
@@ -32360,20 +32487,20 @@ function describeAuthFailure(error62, fallback) {
|
|
|
32360
32487
|
return fallback;
|
|
32361
32488
|
}
|
|
32362
32489
|
var toAuthError = (value) => new AntigravityAuthError(value.code, value.message);
|
|
32363
|
-
function
|
|
32490
|
+
function isRecord16(value) {
|
|
32364
32491
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
32365
32492
|
}
|
|
32366
32493
|
function advertisesPersonalSignIn(initialized) {
|
|
32367
|
-
if (!
|
|
32494
|
+
if (!isRecord16(initialized) || !Array.isArray(initialized["authMethods"])) return false;
|
|
32368
32495
|
return initialized["authMethods"].some(
|
|
32369
|
-
(method) =>
|
|
32496
|
+
(method) => isRecord16(method) && method["id"] === OAUTH_PERSONAL
|
|
32370
32497
|
);
|
|
32371
32498
|
}
|
|
32372
32499
|
function advertisesLogout(initialized) {
|
|
32373
|
-
if (!
|
|
32500
|
+
if (!isRecord16(initialized)) return false;
|
|
32374
32501
|
const capabilities = initialized["agentCapabilities"];
|
|
32375
|
-
const auth =
|
|
32376
|
-
return
|
|
32502
|
+
const auth = isRecord16(capabilities) ? capabilities["auth"] : void 0;
|
|
32503
|
+
return isRecord16(auth) && Boolean(auth["logout"]);
|
|
32377
32504
|
}
|
|
32378
32505
|
|
|
32379
32506
|
// src/loginController.ts
|
|
@@ -32841,71 +32968,12 @@ import * as NodeFSP10 from "node:fs/promises";
|
|
|
32841
32968
|
import {
|
|
32842
32969
|
ExecutorSpawnRefusedError as ExecutorSpawnRefusedError2
|
|
32843
32970
|
} from "@ycodium-ai/plugin-api/executor";
|
|
32844
|
-
import { nodeStreamsFromHandle as
|
|
32845
|
-
|
|
32846
|
-
// src/sessionFiles.ts
|
|
32847
|
-
import * as NodeFSP8 from "node:fs/promises";
|
|
32848
|
-
import * as NodePath10 from "node:path";
|
|
32849
|
-
var UUID_V4 = /^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/iu;
|
|
32850
|
-
var SESSION_FILE_SUFFIXES = [".db", ".db-wal", ".db-shm", ".db-journal", ".meta"];
|
|
32851
|
-
async function removeTemporarySessionFiles(input2) {
|
|
32852
|
-
const { sessionId } = input2;
|
|
32853
|
-
if (sessionId === void 0 || !UUID_V4.test(sessionId)) return false;
|
|
32854
|
-
const acpDirectory = NodePath10.join(input2.profile, "antigravity-acp");
|
|
32855
|
-
const base = NodePath10.join(acpDirectory, "conversations", sessionId);
|
|
32856
|
-
try {
|
|
32857
|
-
const meta3 = JSON.parse(await NodeFSP8.readFile(`${base}.meta`, "utf8"));
|
|
32858
|
-
const cwd = typeof meta3 === "object" && meta3 !== null ? meta3.cwd : null;
|
|
32859
|
-
if (cwd !== input2.workspace) return false;
|
|
32860
|
-
for (const suffix of SESSION_FILE_SUFFIXES) {
|
|
32861
|
-
await NodeFSP8.rm(`${base}${suffix}`, { force: true });
|
|
32862
|
-
}
|
|
32863
|
-
await NodeFSP8.rm(NodePath10.join(acpDirectory, "brain", sessionId), {
|
|
32864
|
-
recursive: true,
|
|
32865
|
-
force: true
|
|
32866
|
-
});
|
|
32867
|
-
return true;
|
|
32868
|
-
} catch {
|
|
32869
|
-
return false;
|
|
32870
|
-
}
|
|
32871
|
-
}
|
|
32971
|
+
import { nodeStreamsFromHandle as nodeStreamsFromHandle4 } from "@ycodium-ai/plugin-api/process-stdin";
|
|
32872
32972
|
|
|
32873
|
-
// src/
|
|
32874
|
-
import
|
|
32875
|
-
import * as NodePath11 from "node:path";
|
|
32876
|
-
var MAX_CONFIG_BYTES = 64e3;
|
|
32877
|
-
var CONFIG_FILES = [
|
|
32878
|
-
{ name: "hooks.json", key: "hooks" },
|
|
32879
|
-
{ name: "mcp_config.json", key: "mcpServers" }
|
|
32880
|
-
];
|
|
32881
|
-
var isRecord16 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
32882
|
-
async function configIsEmpty(file2, key) {
|
|
32883
|
-
try {
|
|
32884
|
-
const info = await NodeFSP9.stat(file2);
|
|
32885
|
-
if (!info.isFile() || info.size > MAX_CONFIG_BYTES) return false;
|
|
32886
|
-
const parsed = JSON.parse(await NodeFSP9.readFile(file2, "utf8"));
|
|
32887
|
-
if (!isRecord16(parsed)) return false;
|
|
32888
|
-
const table = parsed[key] ?? parsed;
|
|
32889
|
-
return isRecord16(table) && Object.keys(table).length === 0;
|
|
32890
|
-
} catch {
|
|
32891
|
-
return false;
|
|
32892
|
-
}
|
|
32893
|
-
}
|
|
32894
|
-
async function isTextGenerationAvailable(profile) {
|
|
32895
|
-
for (const { name, key } of CONFIG_FILES) {
|
|
32896
|
-
const file2 = NodePath11.join(profile, "config", name);
|
|
32897
|
-
try {
|
|
32898
|
-
await NodeFSP9.lstat(file2);
|
|
32899
|
-
} catch (error62) {
|
|
32900
|
-
if (error62.code === "ENOENT") continue;
|
|
32901
|
-
return false;
|
|
32902
|
-
}
|
|
32903
|
-
if (!await configIsEmpty(file2, key)) return false;
|
|
32904
|
-
}
|
|
32905
|
-
return true;
|
|
32906
|
-
}
|
|
32973
|
+
// ../../packages/ycodium-text-generation/src/structuredTextGeneration.ts
|
|
32974
|
+
import { isOperationCleanupError } from "@ycodium-ai/plugin-api/process-operation";
|
|
32907
32975
|
|
|
32908
|
-
// src/
|
|
32976
|
+
// ../../packages/ycodium-text-generation/src/sanitize.ts
|
|
32909
32977
|
function limitSection(value, maxChars) {
|
|
32910
32978
|
if (value.length <= maxChars) return value;
|
|
32911
32979
|
const truncated = value.slice(0, maxChars);
|
|
@@ -32968,17 +33036,15 @@ function sanitizeThreadTitle(raw) {
|
|
|
32968
33036
|
}
|
|
32969
33037
|
return `${normalized.slice(0, MAX_THREAD_TITLE_CHARS - 3).trimEnd()}...`;
|
|
32970
33038
|
}
|
|
32971
|
-
function
|
|
32972
|
-
|
|
32973
|
-
|
|
32974
|
-
|
|
32975
|
-
}
|
|
32976
|
-
|
|
32977
|
-
|
|
32978
|
-
if (sanitized.includes("/")) {
|
|
32979
|
-
return sanitized.startsWith("feature/") ? sanitized : `feature/${sanitized}`;
|
|
33039
|
+
function normalizeCliError(cliName, error62, fallback) {
|
|
33040
|
+
if (error62 instanceof Error) {
|
|
33041
|
+
const lower = error62.message.toLowerCase();
|
|
33042
|
+
if (error62.message.includes(`Command not found: ${cliName}`) || lower.includes(`spawn ${cliName}`) || lower.includes("enoent")) {
|
|
33043
|
+
return new Error(`${cliName} CLI (\`${cliName}\`) is required but not available on PATH.`);
|
|
33044
|
+
}
|
|
33045
|
+
return new Error(fallback, { cause: error62 });
|
|
32980
33046
|
}
|
|
32981
|
-
return
|
|
33047
|
+
return new Error(fallback);
|
|
32982
33048
|
}
|
|
32983
33049
|
function extractJsonObject(raw) {
|
|
32984
33050
|
const trimmed = raw.trim();
|
|
@@ -33012,7 +33078,7 @@ function extractJsonObject(raw) {
|
|
|
33012
33078
|
return trimmed.slice(start);
|
|
33013
33079
|
}
|
|
33014
33080
|
|
|
33015
|
-
// src/
|
|
33081
|
+
// ../../packages/ycodium-text-generation/src/prompts.ts
|
|
33016
33082
|
var EARLIER_CONTENT_TRUNCATION_MARKER = "[Earlier content truncated]\n\n";
|
|
33017
33083
|
function policyInstruction(instruction) {
|
|
33018
33084
|
const trimmed = instruction?.trim();
|
|
@@ -33286,6 +33352,241 @@ function buildHandoverSummaryPrompt(input2) {
|
|
|
33286
33352
|
return { prompt, outputSchema: HANDOVER_SUMMARY_SCHEMA };
|
|
33287
33353
|
}
|
|
33288
33354
|
|
|
33355
|
+
// ../../packages/ycodium-text-generation/src/branchName.ts
|
|
33356
|
+
function sanitizeBranchFragment(raw) {
|
|
33357
|
+
const normalized = raw.trim().toLowerCase().replace(/['"`]/g, "").replace(/^[./\s_-]+|[./\s_-]+$/g, "");
|
|
33358
|
+
const branchFragment = normalized.replace(/[^a-z0-9/_-]+/g, "-").replace(/\/+/g, "/").replace(/-+/g, "-").replace(/^[./_-]+|[./_-]+$/g, "").slice(0, 64).replace(/[./_-]+$/g, "");
|
|
33359
|
+
return branchFragment.length > 0 ? branchFragment : "update";
|
|
33360
|
+
}
|
|
33361
|
+
function sanitizeFeatureBranchName(raw) {
|
|
33362
|
+
const sanitized = sanitizeBranchFragment(raw);
|
|
33363
|
+
if (sanitized.includes("/")) {
|
|
33364
|
+
return sanitized.startsWith("feature/") ? sanitized : `feature/${sanitized}`;
|
|
33365
|
+
}
|
|
33366
|
+
return `feature/${sanitized}`;
|
|
33367
|
+
}
|
|
33368
|
+
|
|
33369
|
+
// ../../packages/ycodium-text-generation/src/structuredTextGeneration.ts
|
|
33370
|
+
var FAILURE_MESSAGES = {
|
|
33371
|
+
generateCommitMessage: "Failed to generate commit message",
|
|
33372
|
+
generatePrContent: "Failed to generate change request content",
|
|
33373
|
+
generateBranchName: "Failed to generate branch name",
|
|
33374
|
+
generateThreadTitle: "Failed to generate thread title",
|
|
33375
|
+
summarizeHandover: "Failed to summarize handover"
|
|
33376
|
+
};
|
|
33377
|
+
function isRecord17(value) {
|
|
33378
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
33379
|
+
}
|
|
33380
|
+
function readString2(value) {
|
|
33381
|
+
return typeof value === "string" ? value : "";
|
|
33382
|
+
}
|
|
33383
|
+
function optionalString(value) {
|
|
33384
|
+
return typeof value === "string" ? value : void 0;
|
|
33385
|
+
}
|
|
33386
|
+
function readPolicy(value) {
|
|
33387
|
+
if (!isRecord17(value)) return void 0;
|
|
33388
|
+
const commitInstructions = optionalString(value["commitInstructions"]);
|
|
33389
|
+
const changeRequestInstructions = optionalString(value["changeRequestInstructions"]);
|
|
33390
|
+
const branchInstructions = optionalString(value["branchInstructions"]);
|
|
33391
|
+
const threadTitleInstructions = optionalString(value["threadTitleInstructions"]);
|
|
33392
|
+
return {
|
|
33393
|
+
...commitInstructions === void 0 ? {} : { commitInstructions },
|
|
33394
|
+
...changeRequestInstructions === void 0 ? {} : { changeRequestInstructions },
|
|
33395
|
+
...branchInstructions === void 0 ? {} : { branchInstructions },
|
|
33396
|
+
...threadTitleInstructions === void 0 ? {} : { threadTitleInstructions }
|
|
33397
|
+
};
|
|
33398
|
+
}
|
|
33399
|
+
function promptAttachments(attachments) {
|
|
33400
|
+
return attachments.filter(isRecord17).map((attachment) => ({
|
|
33401
|
+
name: optionalString(attachment["name"]) ?? "attachment",
|
|
33402
|
+
mimeType: optionalString(attachment["mimeType"]) ?? "application/octet-stream",
|
|
33403
|
+
sizeBytes: typeof attachment["sizeBytes"] === "number" ? attachment["sizeBytes"] : 0
|
|
33404
|
+
}));
|
|
33405
|
+
}
|
|
33406
|
+
function createStructuredTextGeneration(options2) {
|
|
33407
|
+
const generate = async (operation, raw, signal, produce) => {
|
|
33408
|
+
try {
|
|
33409
|
+
if (!isRecord17(raw) && options2.invalidInput !== void 0) {
|
|
33410
|
+
throw options2.invalidInput(operation);
|
|
33411
|
+
}
|
|
33412
|
+
const input2 = isRecord17(raw) ? raw : {};
|
|
33413
|
+
return await produce(
|
|
33414
|
+
input2,
|
|
33415
|
+
(request2) => options2.run({
|
|
33416
|
+
...request2,
|
|
33417
|
+
operation,
|
|
33418
|
+
cwd: readString2(input2["cwd"]) || ".",
|
|
33419
|
+
modelSelection: input2["modelSelection"],
|
|
33420
|
+
...signal === void 0 ? {} : { signal }
|
|
33421
|
+
})
|
|
33422
|
+
);
|
|
33423
|
+
} catch (error62) {
|
|
33424
|
+
if (options2.cliName === void 0 || isOperationCleanupError(error62)) throw error62;
|
|
33425
|
+
throw normalizeCliError(options2.cliName, error62, FAILURE_MESSAGES[operation]);
|
|
33426
|
+
}
|
|
33427
|
+
};
|
|
33428
|
+
return {
|
|
33429
|
+
generateCommitMessage: (raw, signal) => generate("generateCommitMessage", raw, signal, async (input2, run) => {
|
|
33430
|
+
const includeBranch = input2["includeBranch"] === true;
|
|
33431
|
+
const policy = readPolicy(input2["policy"]);
|
|
33432
|
+
const { prompt, outputSchema } = buildCommitMessagePrompt({
|
|
33433
|
+
branch: optionalString(input2["branch"]) ?? null,
|
|
33434
|
+
stagedSummary: readString2(input2["stagedSummary"]),
|
|
33435
|
+
stagedPatch: readString2(input2["stagedPatch"]),
|
|
33436
|
+
includeBranch,
|
|
33437
|
+
...policy === void 0 ? {} : { policy }
|
|
33438
|
+
});
|
|
33439
|
+
const generated = await run({
|
|
33440
|
+
prompt,
|
|
33441
|
+
outputSchema,
|
|
33442
|
+
schemaKeys: includeBranch ? ["subject", "body", "branch"] : ["subject", "body"],
|
|
33443
|
+
attachments: []
|
|
33444
|
+
});
|
|
33445
|
+
return {
|
|
33446
|
+
subject: sanitizeCommitSubject(readString2(generated["subject"])),
|
|
33447
|
+
body: readString2(generated["body"]).trim(),
|
|
33448
|
+
...typeof generated["branch"] === "string" ? { branch: sanitizeFeatureBranchName(generated["branch"]) } : {}
|
|
33449
|
+
};
|
|
33450
|
+
}),
|
|
33451
|
+
generatePrContent: (raw, signal) => generate("generatePrContent", raw, signal, async (input2, run) => {
|
|
33452
|
+
const changeRequestTemplate = optionalString(input2["changeRequestTemplate"]);
|
|
33453
|
+
const policy = readPolicy(input2["policy"]);
|
|
33454
|
+
const { prompt, outputSchema } = buildPrContentPrompt({
|
|
33455
|
+
baseBranch: readString2(input2["baseBranch"]),
|
|
33456
|
+
headBranch: readString2(input2["headBranch"]),
|
|
33457
|
+
commitSummary: readString2(input2["commitSummary"]),
|
|
33458
|
+
diffSummary: readString2(input2["diffSummary"]),
|
|
33459
|
+
diffPatch: readString2(input2["diffPatch"]),
|
|
33460
|
+
...changeRequestTemplate === void 0 ? {} : { changeRequestTemplate },
|
|
33461
|
+
...policy === void 0 ? {} : { policy }
|
|
33462
|
+
});
|
|
33463
|
+
const generated = await run({
|
|
33464
|
+
prompt,
|
|
33465
|
+
outputSchema,
|
|
33466
|
+
schemaKeys: ["title", "body"],
|
|
33467
|
+
attachments: []
|
|
33468
|
+
});
|
|
33469
|
+
return {
|
|
33470
|
+
title: sanitizePrTitle(readString2(generated["title"])),
|
|
33471
|
+
body: readString2(generated["body"]).trim()
|
|
33472
|
+
};
|
|
33473
|
+
}),
|
|
33474
|
+
generateBranchName: (raw, signal) => generate("generateBranchName", raw, signal, async (input2, run) => {
|
|
33475
|
+
const attachments = Array.isArray(input2["attachments"]) ? input2["attachments"] : [];
|
|
33476
|
+
const policy = readPolicy(input2["policy"]);
|
|
33477
|
+
const { prompt, outputSchema } = buildBranchNamePrompt({
|
|
33478
|
+
message: readString2(input2["message"]),
|
|
33479
|
+
attachments: promptAttachments(attachments),
|
|
33480
|
+
...policy === void 0 ? {} : { policy }
|
|
33481
|
+
});
|
|
33482
|
+
const generated = await run({
|
|
33483
|
+
prompt,
|
|
33484
|
+
outputSchema,
|
|
33485
|
+
schemaKeys: ["branch"],
|
|
33486
|
+
attachments
|
|
33487
|
+
});
|
|
33488
|
+
return { branch: sanitizeBranchFragment(readString2(generated["branch"])) };
|
|
33489
|
+
}),
|
|
33490
|
+
generateThreadTitle: (raw, signal) => generate("generateThreadTitle", raw, signal, async (input2, run) => {
|
|
33491
|
+
const attachments = Array.isArray(input2["attachments"]) ? input2["attachments"] : [];
|
|
33492
|
+
const linkedContext = optionalString(input2["linkedContext"]);
|
|
33493
|
+
const previousTitle = optionalString(input2["previousTitle"]);
|
|
33494
|
+
const policy = readPolicy(input2["policy"]);
|
|
33495
|
+
const { prompt, outputSchema } = buildThreadTitlePrompt({
|
|
33496
|
+
message: readString2(input2["message"]),
|
|
33497
|
+
...linkedContext ? { linkedContext } : {},
|
|
33498
|
+
...previousTitle === void 0 ? {} : { previousTitle },
|
|
33499
|
+
attachments: promptAttachments(attachments),
|
|
33500
|
+
...policy === void 0 ? {} : { policy }
|
|
33501
|
+
});
|
|
33502
|
+
const generated = await run({
|
|
33503
|
+
prompt,
|
|
33504
|
+
outputSchema,
|
|
33505
|
+
schemaKeys: ["title"],
|
|
33506
|
+
attachments
|
|
33507
|
+
});
|
|
33508
|
+
return {
|
|
33509
|
+
title: sanitizeThreadTitle(readString2(generated["title"])),
|
|
33510
|
+
...generated["needsRefinement"] === true ? { needsRefinement: true } : {}
|
|
33511
|
+
};
|
|
33512
|
+
}),
|
|
33513
|
+
summarizeHandover: (raw, signal) => generate("summarizeHandover", raw, signal, async (input2, run) => {
|
|
33514
|
+
const { prompt, outputSchema } = buildHandoverSummaryPrompt({
|
|
33515
|
+
transcript: readString2(input2["transcript"])
|
|
33516
|
+
});
|
|
33517
|
+
const generated = await run({
|
|
33518
|
+
prompt,
|
|
33519
|
+
outputSchema,
|
|
33520
|
+
schemaKeys: ["summary"],
|
|
33521
|
+
attachments: []
|
|
33522
|
+
});
|
|
33523
|
+
return { summary: readString2(generated["summary"]).trim() };
|
|
33524
|
+
})
|
|
33525
|
+
};
|
|
33526
|
+
}
|
|
33527
|
+
|
|
33528
|
+
// src/sessionFiles.ts
|
|
33529
|
+
import * as NodeFSP8 from "node:fs/promises";
|
|
33530
|
+
import * as NodePath11 from "node:path";
|
|
33531
|
+
var UUID_V4 = /^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/iu;
|
|
33532
|
+
var SESSION_FILE_SUFFIXES = [".db", ".db-wal", ".db-shm", ".db-journal", ".meta"];
|
|
33533
|
+
async function removeTemporarySessionFiles(input2) {
|
|
33534
|
+
const { sessionId } = input2;
|
|
33535
|
+
if (sessionId === void 0 || !UUID_V4.test(sessionId)) return false;
|
|
33536
|
+
const acpDirectory = NodePath11.join(input2.profile, "antigravity-acp");
|
|
33537
|
+
const base = NodePath11.join(acpDirectory, "conversations", sessionId);
|
|
33538
|
+
try {
|
|
33539
|
+
const meta3 = JSON.parse(await NodeFSP8.readFile(`${base}.meta`, "utf8"));
|
|
33540
|
+
const cwd = typeof meta3 === "object" && meta3 !== null ? meta3.cwd : null;
|
|
33541
|
+
if (cwd !== input2.workspace) return false;
|
|
33542
|
+
for (const suffix of SESSION_FILE_SUFFIXES) {
|
|
33543
|
+
await NodeFSP8.rm(`${base}${suffix}`, { force: true });
|
|
33544
|
+
}
|
|
33545
|
+
await NodeFSP8.rm(NodePath11.join(acpDirectory, "brain", sessionId), {
|
|
33546
|
+
recursive: true,
|
|
33547
|
+
force: true
|
|
33548
|
+
});
|
|
33549
|
+
return true;
|
|
33550
|
+
} catch {
|
|
33551
|
+
return false;
|
|
33552
|
+
}
|
|
33553
|
+
}
|
|
33554
|
+
|
|
33555
|
+
// src/textGenerationAvailability.ts
|
|
33556
|
+
import * as NodeFSP9 from "node:fs/promises";
|
|
33557
|
+
import * as NodePath12 from "node:path";
|
|
33558
|
+
var MAX_CONFIG_BYTES = 64e3;
|
|
33559
|
+
var CONFIG_FILES = [
|
|
33560
|
+
{ name: "hooks.json", key: "hooks" },
|
|
33561
|
+
{ name: "mcp_config.json", key: "mcpServers" }
|
|
33562
|
+
];
|
|
33563
|
+
var isRecord18 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
33564
|
+
async function configIsEmpty(file2, key) {
|
|
33565
|
+
try {
|
|
33566
|
+
const info = await NodeFSP9.stat(file2);
|
|
33567
|
+
if (!info.isFile() || info.size > MAX_CONFIG_BYTES) return false;
|
|
33568
|
+
const parsed = JSON.parse(await NodeFSP9.readFile(file2, "utf8"));
|
|
33569
|
+
if (!isRecord18(parsed)) return false;
|
|
33570
|
+
const table = parsed[key] ?? parsed;
|
|
33571
|
+
return isRecord18(table) && Object.keys(table).length === 0;
|
|
33572
|
+
} catch {
|
|
33573
|
+
return false;
|
|
33574
|
+
}
|
|
33575
|
+
}
|
|
33576
|
+
async function isTextGenerationAvailable(profile) {
|
|
33577
|
+
for (const { name, key } of CONFIG_FILES) {
|
|
33578
|
+
const file2 = NodePath12.join(profile, "config", name);
|
|
33579
|
+
try {
|
|
33580
|
+
await NodeFSP9.lstat(file2);
|
|
33581
|
+
} catch (error62) {
|
|
33582
|
+
if (error62.code === "ENOENT") continue;
|
|
33583
|
+
return false;
|
|
33584
|
+
}
|
|
33585
|
+
if (!await configIsEmpty(file2, key)) return false;
|
|
33586
|
+
}
|
|
33587
|
+
return true;
|
|
33588
|
+
}
|
|
33589
|
+
|
|
33289
33590
|
// src/textGeneration.ts
|
|
33290
33591
|
var DEFAULT_TIMEOUT_MS = 18e4;
|
|
33291
33592
|
var MAX_OUTPUT_CHARS = 128e3;
|
|
@@ -33296,13 +33597,8 @@ var ANSWER_ONLY_PREFIX = [
|
|
|
33296
33597
|
].join("\n");
|
|
33297
33598
|
var TEXT_GENERATION_UNAVAILABLE_MESSAGE = "Antigravity text generation is unavailable because this account has global hooks or MCP servers configured. Choose another model for generated text.";
|
|
33298
33599
|
var TEXT_GENERATION_BUSY_MESSAGE = "Antigravity is already running as many processes as it allows. Try again when a conversation or another task has finished.";
|
|
33299
|
-
var
|
|
33300
|
-
var
|
|
33301
|
-
function modelIdFromSelection2(selection) {
|
|
33302
|
-
if (!isRecord17(selection)) return void 0;
|
|
33303
|
-
const model = selection["model"];
|
|
33304
|
-
return typeof model === "string" ? model.trim() || void 0 : void 0;
|
|
33305
|
-
}
|
|
33600
|
+
var isRecord19 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
33601
|
+
var readString3 = (value) => typeof value === "string" ? value : "";
|
|
33306
33602
|
function describeFailure(operation, error62) {
|
|
33307
33603
|
if (error62 instanceof ExecutorSpawnRefusedError2) return new Error(TEXT_GENERATION_BUSY_MESSAGE);
|
|
33308
33604
|
if (error62 instanceof TextGenerationRejection) return error62;
|
|
@@ -33334,7 +33630,7 @@ function createAntigravityTextGeneration(deps) {
|
|
|
33334
33630
|
if (!await isTextGenerationAvailable(deps.profile)) {
|
|
33335
33631
|
throw new TextGenerationRejection(TEXT_GENERATION_UNAVAILABLE_MESSAGE);
|
|
33336
33632
|
}
|
|
33337
|
-
const requestedModelId =
|
|
33633
|
+
const requestedModelId = modelIdFromSelection(request2.modelSelection);
|
|
33338
33634
|
const lease = await deps.acquireExecutable();
|
|
33339
33635
|
let runtimeTemp;
|
|
33340
33636
|
let workspace;
|
|
@@ -33390,7 +33686,7 @@ function createAntigravityTextGeneration(deps) {
|
|
|
33390
33686
|
const loginPrompted = Promise.withResolvers();
|
|
33391
33687
|
loginPrompted.promise.catch(() => void 0);
|
|
33392
33688
|
const onLoginPrompt = () => loginPrompted.reject(new AntigravitySignInRequiredError());
|
|
33393
|
-
const { readable, writable, stderrTail } =
|
|
33689
|
+
const { readable, writable, stderrTail } = nodeStreamsFromHandle4({
|
|
33394
33690
|
stdout: filterAgentStdout(handle.stdout, { onLoginPrompt }),
|
|
33395
33691
|
stderr: watchAgentStderr(handle.stderr, onLoginPrompt),
|
|
33396
33692
|
writeStdin: handle.writeStdin,
|
|
@@ -33432,9 +33728,9 @@ function createAntigravityTextGeneration(deps) {
|
|
|
33432
33728
|
);
|
|
33433
33729
|
await activeExecutor.respondToRequest(event.requestId, "cancel").catch(() => void 0);
|
|
33434
33730
|
} else if (event.type === "content.delta") {
|
|
33435
|
-
const payload =
|
|
33731
|
+
const payload = isRecord19(event.payload) ? event.payload : {};
|
|
33436
33732
|
if (payload["streamKind"] !== "assistant_text") continue;
|
|
33437
|
-
output2 +=
|
|
33733
|
+
output2 += readString3(payload["delta"]);
|
|
33438
33734
|
if (output2.length > MAX_OUTPUT_CHARS) fail("Antigravity exceeded the output limit.");
|
|
33439
33735
|
}
|
|
33440
33736
|
}
|
|
@@ -33446,7 +33742,7 @@ function createAntigravityTextGeneration(deps) {
|
|
|
33446
33742
|
sessionId = started.sessionId;
|
|
33447
33743
|
const catalog = antigravityCatalogFromSetup(started.sessionSetupResult);
|
|
33448
33744
|
const known = catalog?.models.map((model) => model.slug) ?? [];
|
|
33449
|
-
if (requestedModelId !== void 0 && known.length > 0 &&
|
|
33745
|
+
if (requestedModelId !== void 0 && known.length > 0 && matchCatalogModel(requestedModelId, known) === void 0) {
|
|
33450
33746
|
throw new TextGenerationRejection(
|
|
33451
33747
|
`${operation}: Antigravity model '${requestedModelId}' is unavailable for this Google account.`
|
|
33452
33748
|
);
|
|
@@ -33482,7 +33778,7 @@ function createAntigravityTextGeneration(deps) {
|
|
|
33482
33778
|
{ cause: error62 }
|
|
33483
33779
|
);
|
|
33484
33780
|
}
|
|
33485
|
-
if (!
|
|
33781
|
+
if (!isRecord19(parsed) || request2.schemaKeys.some((key) => !(key in parsed))) {
|
|
33486
33782
|
throw new TextGenerationRejection(
|
|
33487
33783
|
`${operation}: Antigravity returned output in an unexpected format.`
|
|
33488
33784
|
);
|
|
@@ -33497,109 +33793,10 @@ function createAntigravityTextGeneration(deps) {
|
|
|
33497
33793
|
running.delete(closeAll);
|
|
33498
33794
|
}
|
|
33499
33795
|
};
|
|
33500
|
-
const
|
|
33501
|
-
|
|
33502
|
-
|
|
33503
|
-
};
|
|
33504
|
-
const textGeneration = {
|
|
33505
|
-
generateCommitMessage: async (raw, signal) => {
|
|
33506
|
-
const input2 = asInput(raw, "generateCommitMessage");
|
|
33507
|
-
const includeBranch = input2["includeBranch"] === true;
|
|
33508
|
-
const { prompt } = buildCommitMessagePrompt({
|
|
33509
|
-
branch: typeof input2["branch"] === "string" ? input2["branch"] : null,
|
|
33510
|
-
stagedSummary: readString2(input2["stagedSummary"]),
|
|
33511
|
-
stagedPatch: readString2(input2["stagedPatch"]),
|
|
33512
|
-
includeBranch,
|
|
33513
|
-
...isRecord17(input2["policy"]) ? { policy: input2["policy"] } : {}
|
|
33514
|
-
});
|
|
33515
|
-
const generated = await runJson({
|
|
33516
|
-
operation: "generateCommitMessage",
|
|
33517
|
-
prompt,
|
|
33518
|
-
schemaKeys: includeBranch ? ["subject", "body", "branch"] : ["subject", "body"],
|
|
33519
|
-
modelSelection: input2["modelSelection"],
|
|
33520
|
-
signal
|
|
33521
|
-
});
|
|
33522
|
-
return {
|
|
33523
|
-
subject: sanitizeCommitSubject(readString2(generated["subject"])),
|
|
33524
|
-
body: readString2(generated["body"]).trim(),
|
|
33525
|
-
...typeof generated["branch"] === "string" ? { branch: sanitizeFeatureBranchName(generated["branch"]) } : {}
|
|
33526
|
-
};
|
|
33527
|
-
},
|
|
33528
|
-
generatePrContent: async (raw, signal) => {
|
|
33529
|
-
const input2 = asInput(raw, "generatePrContent");
|
|
33530
|
-
const { prompt } = buildPrContentPrompt({
|
|
33531
|
-
baseBranch: readString2(input2["baseBranch"]),
|
|
33532
|
-
headBranch: readString2(input2["headBranch"]),
|
|
33533
|
-
commitSummary: readString2(input2["commitSummary"]),
|
|
33534
|
-
diffSummary: readString2(input2["diffSummary"]),
|
|
33535
|
-
diffPatch: readString2(input2["diffPatch"]),
|
|
33536
|
-
...typeof input2["changeRequestTemplate"] === "string" ? { changeRequestTemplate: input2["changeRequestTemplate"] } : {},
|
|
33537
|
-
...isRecord17(input2["policy"]) ? { policy: input2["policy"] } : {}
|
|
33538
|
-
});
|
|
33539
|
-
const generated = await runJson({
|
|
33540
|
-
operation: "generatePrContent",
|
|
33541
|
-
prompt,
|
|
33542
|
-
schemaKeys: ["title", "body"],
|
|
33543
|
-
modelSelection: input2["modelSelection"],
|
|
33544
|
-
signal
|
|
33545
|
-
});
|
|
33546
|
-
return {
|
|
33547
|
-
title: sanitizePrTitle(readString2(generated["title"])),
|
|
33548
|
-
body: readString2(generated["body"]).trim()
|
|
33549
|
-
};
|
|
33550
|
-
},
|
|
33551
|
-
generateBranchName: async (raw, signal) => {
|
|
33552
|
-
const input2 = asInput(raw, "generateBranchName");
|
|
33553
|
-
const { prompt } = buildBranchNamePrompt({
|
|
33554
|
-
message: readString2(input2["message"]),
|
|
33555
|
-
...Array.isArray(input2["attachments"]) ? { attachments: input2["attachments"] } : {},
|
|
33556
|
-
...isRecord17(input2["policy"]) ? { policy: input2["policy"] } : {}
|
|
33557
|
-
});
|
|
33558
|
-
const generated = await runJson({
|
|
33559
|
-
operation: "generateBranchName",
|
|
33560
|
-
prompt,
|
|
33561
|
-
schemaKeys: ["branch"],
|
|
33562
|
-
modelSelection: input2["modelSelection"],
|
|
33563
|
-
signal
|
|
33564
|
-
});
|
|
33565
|
-
return { branch: sanitizeBranchFragment(readString2(generated["branch"])) };
|
|
33566
|
-
},
|
|
33567
|
-
generateThreadTitle: async (raw, signal) => {
|
|
33568
|
-
const input2 = asInput(raw, "generateThreadTitle");
|
|
33569
|
-
const { prompt } = buildThreadTitlePrompt({
|
|
33570
|
-
message: readString2(input2["message"]),
|
|
33571
|
-
...typeof input2["linkedContext"] === "string" && input2["linkedContext"].length > 0 ? { linkedContext: input2["linkedContext"] } : {},
|
|
33572
|
-
...typeof input2["previousTitle"] === "string" ? { previousTitle: input2["previousTitle"] } : {},
|
|
33573
|
-
...Array.isArray(input2["attachments"]) ? { attachments: input2["attachments"] } : {},
|
|
33574
|
-
...isRecord17(input2["policy"]) ? { policy: input2["policy"] } : {}
|
|
33575
|
-
});
|
|
33576
|
-
const generated = await runJson({
|
|
33577
|
-
operation: "generateThreadTitle",
|
|
33578
|
-
prompt,
|
|
33579
|
-
schemaKeys: ["title"],
|
|
33580
|
-
modelSelection: input2["modelSelection"],
|
|
33581
|
-
signal
|
|
33582
|
-
});
|
|
33583
|
-
return {
|
|
33584
|
-
title: sanitizeThreadTitle(readString2(generated["title"])),
|
|
33585
|
-
...generated["needsRefinement"] === true ? { needsRefinement: true } : {}
|
|
33586
|
-
};
|
|
33587
|
-
},
|
|
33588
|
-
summarizeHandover: async (raw, signal) => {
|
|
33589
|
-
const input2 = asInput(raw, "summarizeHandover");
|
|
33590
|
-
const { prompt } = buildHandoverSummaryPrompt({
|
|
33591
|
-
transcript: readString2(input2["transcript"])
|
|
33592
|
-
});
|
|
33593
|
-
const generated = await runJson({
|
|
33594
|
-
operation: "summarizeHandover",
|
|
33595
|
-
prompt,
|
|
33596
|
-
schemaKeys: ["summary"],
|
|
33597
|
-
modelSelection: input2["modelSelection"],
|
|
33598
|
-
signal
|
|
33599
|
-
});
|
|
33600
|
-
return { summary: readString2(generated["summary"]).trim() };
|
|
33601
|
-
}
|
|
33602
|
-
};
|
|
33796
|
+
const textGeneration = createStructuredTextGeneration({
|
|
33797
|
+
invalidInput: (operation) => new Error(`${operation}: invalid input.`),
|
|
33798
|
+
run: runJson
|
|
33799
|
+
});
|
|
33603
33800
|
return {
|
|
33604
33801
|
textGeneration,
|
|
33605
33802
|
stopRunning: async () => {
|
|
@@ -33657,6 +33854,12 @@ async function createAntigravityInstance(config2, host, deps) {
|
|
|
33657
33854
|
stopBooked,
|
|
33658
33855
|
host.log
|
|
33659
33856
|
);
|
|
33857
|
+
const threadOps = createAcpThreadOperations({
|
|
33858
|
+
threads,
|
|
33859
|
+
requireThread,
|
|
33860
|
+
isDisposed: () => mutable.disposed,
|
|
33861
|
+
log: host.log
|
|
33862
|
+
});
|
|
33660
33863
|
const helpers = createAntigravityTextGeneration({
|
|
33661
33864
|
host,
|
|
33662
33865
|
profile: dirs.profile,
|
|
@@ -33836,20 +34039,10 @@ async function createAntigravityInstance(config2, host, deps) {
|
|
|
33836
34039
|
return;
|
|
33837
34040
|
}
|
|
33838
34041
|
await booked.executor.cancel(turnId);
|
|
33839
|
-
await
|
|
33840
|
-
},
|
|
33841
|
-
respondToRequest: async (threadId, requestId, decision, reason) => {
|
|
33842
|
-
const booked = requireThread(threadId);
|
|
33843
|
-
await booked.executor.respondToRequest(
|
|
33844
|
-
requestId,
|
|
33845
|
-
decision === "allow" ? "accept" : "decline",
|
|
33846
|
-
reason
|
|
33847
|
-
);
|
|
33848
|
-
},
|
|
33849
|
-
respondToUserInput: async (threadId, requestId, answers) => {
|
|
33850
|
-
const booked = requireThread(threadId);
|
|
33851
|
-
await booked.executor.respondToUserInput(requestId, answers);
|
|
34042
|
+
await yieldTick2();
|
|
33852
34043
|
},
|
|
34044
|
+
respondToRequest: threadOps.respondToRequest,
|
|
34045
|
+
respondToUserInput: threadOps.respondToUserInput,
|
|
33853
34046
|
// 四档由 agent 自己执行(不是宿主替用户答审批),所以切档要真的发给它。
|
|
33854
34047
|
setRuntimeMode: async (threadId, runtimeMode) => {
|
|
33855
34048
|
const booked = requireThread(threadId);
|
|
@@ -33860,15 +34053,12 @@ async function createAntigravityInstance(config2, host, deps) {
|
|
|
33860
34053
|
booked.session = {
|
|
33861
34054
|
...booked.session,
|
|
33862
34055
|
runtimeMode,
|
|
33863
|
-
updatedAt:
|
|
34056
|
+
updatedAt: nowIso2()
|
|
33864
34057
|
};
|
|
33865
34058
|
if (applied !== void 0) booked.appliedModeId = applied;
|
|
33866
34059
|
},
|
|
33867
34060
|
stopSession: (threadId) => stopSession(threadId),
|
|
33868
|
-
readThread:
|
|
33869
|
-
const booked = requireThread(threadId);
|
|
33870
|
-
return { threadId, turns: booked.turns };
|
|
33871
|
-
},
|
|
34061
|
+
readThread: threadOps.readThread,
|
|
33872
34062
|
textGeneration: helpers.textGeneration,
|
|
33873
34063
|
continuationKey: dirs.continuationKey,
|
|
33874
34064
|
dispose: () => {
|
|
@@ -33972,12 +34162,12 @@ function registerRuntimeCommands(ctx, manager) {
|
|
|
33972
34162
|
try {
|
|
33973
34163
|
await manager.reload();
|
|
33974
34164
|
emit(manager.snapshot());
|
|
33975
|
-
await new Promise((
|
|
34165
|
+
await new Promise((resolve7) => {
|
|
33976
34166
|
if (signal.aborted) {
|
|
33977
|
-
|
|
34167
|
+
resolve7();
|
|
33978
34168
|
return;
|
|
33979
34169
|
}
|
|
33980
|
-
signal.addEventListener("abort", () =>
|
|
34170
|
+
signal.addEventListener("abort", () => resolve7(), { once: true });
|
|
33981
34171
|
});
|
|
33982
34172
|
} finally {
|
|
33983
34173
|
unsubscribe();
|
|
@@ -33988,7 +34178,7 @@ function registerRuntimeCommands(ctx, manager) {
|
|
|
33988
34178
|
|
|
33989
34179
|
// src/runtimeManager.ts
|
|
33990
34180
|
import * as NodeFSP12 from "node:fs/promises";
|
|
33991
|
-
import * as
|
|
34181
|
+
import * as NodePath15 from "node:path";
|
|
33992
34182
|
|
|
33993
34183
|
// src/release.ts
|
|
33994
34184
|
var ANTIGRAVITY_RELEASE_VERSION = "agy_acp_server_1.1.1";
|
|
@@ -34058,7 +34248,7 @@ var Yauzl = __toESM(require_yauzl(), 1);
|
|
|
34058
34248
|
import * as NodeCrypto6 from "node:crypto";
|
|
34059
34249
|
import * as NodeFS2 from "node:fs";
|
|
34060
34250
|
import * as NodeFSP11 from "node:fs/promises";
|
|
34061
|
-
import * as
|
|
34251
|
+
import * as NodePath13 from "node:path";
|
|
34062
34252
|
import * as NodeStream2 from "node:stream";
|
|
34063
34253
|
import * as NodeStreamPromises from "node:stream/promises";
|
|
34064
34254
|
var DOWNLOAD_TIMEOUT_MS = 45 * 60 * 1e3;
|
|
@@ -34098,7 +34288,7 @@ async function sweepStaging(versionsDir) {
|
|
|
34098
34288
|
}
|
|
34099
34289
|
for (const name of names) {
|
|
34100
34290
|
if (!name.startsWith(STAGING_PREFIX)) continue;
|
|
34101
|
-
await removeTree(
|
|
34291
|
+
await removeTree(NodePath13.join(versionsDir, name)).catch(() => void 0);
|
|
34102
34292
|
}
|
|
34103
34293
|
}
|
|
34104
34294
|
async function downloadArchive(input2, archivePath) {
|
|
@@ -34178,19 +34368,19 @@ function downloadFailure(input2, error62) {
|
|
|
34178
34368
|
}
|
|
34179
34369
|
var extractFailure = (message, cause) => new RuntimeInstallError("extract-failed", message, cause);
|
|
34180
34370
|
function openZip(archivePath) {
|
|
34181
|
-
return new Promise((
|
|
34371
|
+
return new Promise((resolve7, reject) => {
|
|
34182
34372
|
Yauzl.open(
|
|
34183
34373
|
archivePath,
|
|
34184
34374
|
{ lazyEntries: true, autoClose: false, validateEntrySizes: true, strictFileNames: true },
|
|
34185
34375
|
(error62, zip) => {
|
|
34186
34376
|
if (error62 || !zip) reject(extractFailure("Could not open the verified archive.", error62));
|
|
34187
|
-
else
|
|
34377
|
+
else resolve7(zip);
|
|
34188
34378
|
}
|
|
34189
34379
|
);
|
|
34190
34380
|
});
|
|
34191
34381
|
}
|
|
34192
34382
|
function nextEntry(zip) {
|
|
34193
|
-
return new Promise((
|
|
34383
|
+
return new Promise((resolve7, reject) => {
|
|
34194
34384
|
const cleanup = () => {
|
|
34195
34385
|
zip.removeListener("entry", onEntry);
|
|
34196
34386
|
zip.removeListener("end", onEnd);
|
|
@@ -34198,11 +34388,11 @@ function nextEntry(zip) {
|
|
|
34198
34388
|
};
|
|
34199
34389
|
const onEntry = (entry) => {
|
|
34200
34390
|
cleanup();
|
|
34201
|
-
|
|
34391
|
+
resolve7(entry);
|
|
34202
34392
|
};
|
|
34203
34393
|
const onEnd = () => {
|
|
34204
34394
|
cleanup();
|
|
34205
|
-
|
|
34395
|
+
resolve7(null);
|
|
34206
34396
|
};
|
|
34207
34397
|
const onError = (cause) => {
|
|
34208
34398
|
cleanup();
|
|
@@ -34215,16 +34405,16 @@ function nextEntry(zip) {
|
|
|
34215
34405
|
});
|
|
34216
34406
|
}
|
|
34217
34407
|
function openEntry(zip, entry) {
|
|
34218
|
-
return new Promise((
|
|
34408
|
+
return new Promise((resolve7, reject) => {
|
|
34219
34409
|
zip.openReadStream(entry, (cause, readable) => {
|
|
34220
34410
|
if (cause || !readable) reject(extractFailure("Could not read an archive member.", cause));
|
|
34221
|
-
else
|
|
34411
|
+
else resolve7(readable);
|
|
34222
34412
|
});
|
|
34223
34413
|
});
|
|
34224
34414
|
}
|
|
34225
34415
|
function closeZip(zip) {
|
|
34226
|
-
return new Promise((
|
|
34227
|
-
zip.once("close", () =>
|
|
34416
|
+
return new Promise((resolve7) => {
|
|
34417
|
+
zip.once("close", () => resolve7());
|
|
34228
34418
|
zip.close();
|
|
34229
34419
|
});
|
|
34230
34420
|
}
|
|
@@ -34265,7 +34455,7 @@ async function extractPair(archivePath, outDirectory, asset) {
|
|
|
34265
34455
|
await NodeStreamPromises.pipeline(
|
|
34266
34456
|
await openEntry(zip, entry),
|
|
34267
34457
|
limiter,
|
|
34268
|
-
NodeFS2.createWriteStream(
|
|
34458
|
+
NodeFS2.createWriteStream(NodePath13.join(outDirectory, entry.fileName), {
|
|
34269
34459
|
flags: "wx",
|
|
34270
34460
|
mode: 448
|
|
34271
34461
|
})
|
|
@@ -34307,8 +34497,8 @@ async function validateOrThrow(input2, executable) {
|
|
|
34307
34497
|
}
|
|
34308
34498
|
function executableOf(directory, input2, names) {
|
|
34309
34499
|
return {
|
|
34310
|
-
executablePath:
|
|
34311
|
-
harnessPath:
|
|
34500
|
+
executablePath: NodePath13.join(directory, names.executable),
|
|
34501
|
+
harnessPath: NodePath13.join(directory, names.harness),
|
|
34312
34502
|
source: "managed",
|
|
34313
34503
|
version: input2.asset.version,
|
|
34314
34504
|
managedVersionDirectory: directory
|
|
@@ -34354,10 +34544,10 @@ async function installManagedRelease(input2) {
|
|
|
34354
34544
|
`Antigravity needs at least ${String(Math.ceil(needed / 1024 / 1024))} MiB of free space to install.`
|
|
34355
34545
|
);
|
|
34356
34546
|
}
|
|
34357
|
-
const staging = await NodeFSP11.mkdtemp(
|
|
34547
|
+
const staging = await NodeFSP11.mkdtemp(NodePath13.join(layout.versionsDir, STAGING_PREFIX));
|
|
34358
34548
|
try {
|
|
34359
|
-
const archivePath =
|
|
34360
|
-
const pairDirectory =
|
|
34549
|
+
const archivePath = NodePath13.join(staging, "download.zip");
|
|
34550
|
+
const pairDirectory = NodePath13.join(staging, "runtime");
|
|
34361
34551
|
await NodeFSP11.mkdir(pairDirectory);
|
|
34362
34552
|
const downloaded = await downloadArchive(input2, archivePath);
|
|
34363
34553
|
if (downloaded.bytes !== asset.archiveBytes || downloaded.sha256 !== asset.sha256) {
|
|
@@ -34370,8 +34560,8 @@ async function installManagedRelease(input2) {
|
|
|
34370
34560
|
await extractPair(archivePath, pairDirectory, asset);
|
|
34371
34561
|
await NodeFSP11.rm(archivePath, { force: true });
|
|
34372
34562
|
if (platform2 !== "win32") {
|
|
34373
|
-
await NodeFSP11.chmod(
|
|
34374
|
-
await NodeFSP11.chmod(
|
|
34563
|
+
await NodeFSP11.chmod(NodePath13.join(pairDirectory, asset.executable.name), 493);
|
|
34564
|
+
await NodeFSP11.chmod(NodePath13.join(pairDirectory, asset.harness.name), 493);
|
|
34375
34565
|
}
|
|
34376
34566
|
await validateOrThrow(input2, executableOf(pairDirectory, input2, names));
|
|
34377
34567
|
await writeReleaseRecord(pairDirectory, {
|
|
@@ -34403,31 +34593,31 @@ async function installManagedRelease(input2) {
|
|
|
34403
34593
|
}
|
|
34404
34594
|
|
|
34405
34595
|
// src/runtimeValidate.ts
|
|
34406
|
-
import { nodeStreamsFromHandle as
|
|
34407
|
-
import * as
|
|
34596
|
+
import { nodeStreamsFromHandle as nodeStreamsFromHandle5 } from "@ycodium-ai/plugin-api/process-stdin";
|
|
34597
|
+
import * as NodePath14 from "node:path";
|
|
34408
34598
|
var VALIDATE_REQUEST_TIMEOUT_MS = 9e4;
|
|
34409
34599
|
var EXIT_WAIT_MS = 1e4;
|
|
34410
34600
|
var VALIDATE_CLIENT_INFO = { name: "ycodium-agent-antigravity", version: "0.1.0" };
|
|
34411
34601
|
var EXPECTED_AGENT_NAME = "antigravity-acp";
|
|
34412
|
-
function
|
|
34602
|
+
function isRecord20(value) {
|
|
34413
34603
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
34414
34604
|
}
|
|
34415
34605
|
var RUNTIME_VERSION_PREFIX = "agy_acp_server_";
|
|
34416
34606
|
var runtimeVersionNumber = (version2) => version2.startsWith(RUNTIME_VERSION_PREFIX) ? version2.slice(RUNTIME_VERSION_PREFIX.length) : version2;
|
|
34417
34607
|
function matchesExpectedRuntime(initializeResult, expectedVersion) {
|
|
34418
|
-
if (!
|
|
34608
|
+
if (!isRecord20(initializeResult)) return false;
|
|
34419
34609
|
const agentInfo = initializeResult["agentInfo"];
|
|
34420
34610
|
const capabilities = initializeResult["agentCapabilities"];
|
|
34421
34611
|
const authMethods = initializeResult["authMethods"];
|
|
34422
|
-
if (!
|
|
34612
|
+
if (!isRecord20(agentInfo) || !isRecord20(capabilities) || !Array.isArray(authMethods)) return false;
|
|
34423
34613
|
const sessionCapabilities = capabilities["sessionCapabilities"];
|
|
34424
34614
|
const auth = capabilities["auth"];
|
|
34425
|
-
return agentInfo["name"] === EXPECTED_AGENT_NAME && runtimeVersionNumber(acpAgentVersion(initializeResult) ?? "") === runtimeVersionNumber(expectedVersion) && initializeResult["protocolVersion"] === 1 && capabilities["loadSession"] === true &&
|
|
34615
|
+
return agentInfo["name"] === EXPECTED_AGENT_NAME && runtimeVersionNumber(acpAgentVersion(initializeResult) ?? "") === runtimeVersionNumber(expectedVersion) && initializeResult["protocolVersion"] === 1 && capabilities["loadSession"] === true && isRecord20(sessionCapabilities) && Boolean(sessionCapabilities["resume"]) && isRecord20(auth) && Boolean(auth["logout"]) && authMethods.some((method) => isRecord20(method) && method["id"] === "oauth-personal");
|
|
34426
34616
|
}
|
|
34427
34617
|
async function validateInstalledRuntime(input2) {
|
|
34428
34618
|
const platform2 = input2.platform ?? HOST_PLATFORM;
|
|
34429
|
-
const profileRoot =
|
|
34430
|
-
const tempRoot =
|
|
34619
|
+
const profileRoot = NodePath14.join(input2.dataDir, "tmp", "validate-profile");
|
|
34620
|
+
const tempRoot = NodePath14.join(input2.dataDir, "tmp", "validate");
|
|
34431
34621
|
await sweepRuntimeTempDirs(profileRoot);
|
|
34432
34622
|
await sweepRuntimeTempDirs(tempRoot);
|
|
34433
34623
|
const profile = await createRuntimeTempDir(profileRoot);
|
|
@@ -34450,7 +34640,7 @@ async function validateInstalledRuntime(input2) {
|
|
|
34450
34640
|
...input2.processEnv === void 0 ? {} : { processEnv: input2.processEnv }
|
|
34451
34641
|
})
|
|
34452
34642
|
});
|
|
34453
|
-
const { readable, writable } =
|
|
34643
|
+
const { readable, writable } = nodeStreamsFromHandle5({
|
|
34454
34644
|
stdout: filterAgentStdout(handle.stdout, {}),
|
|
34455
34645
|
stderr: watchAgentStderr(handle.stderr, () => void 0),
|
|
34456
34646
|
writeStdin: handle.writeStdin,
|
|
@@ -34643,8 +34833,8 @@ function createRuntimeManager(deps) {
|
|
|
34643
34833
|
if (!(error62 instanceof AntigravityRuntimeError)) throw error62;
|
|
34644
34834
|
}
|
|
34645
34835
|
if (realRoot !== void 0) {
|
|
34646
|
-
const real = await NodeFSP12.realpath(configured).catch(() =>
|
|
34647
|
-
if (real.startsWith(`${realRoot}${
|
|
34836
|
+
const real = await NodeFSP12.realpath(configured).catch(() => NodePath15.resolve(configured));
|
|
34837
|
+
if (real.startsWith(`${realRoot}${NodePath15.sep}`)) return true;
|
|
34648
34838
|
}
|
|
34649
34839
|
}
|
|
34650
34840
|
return false;
|
|
@@ -34688,8 +34878,8 @@ function createRuntimeManager(deps) {
|
|
|
34688
34878
|
for (const entry of instances) {
|
|
34689
34879
|
const configured = entry.binaryPath.trim();
|
|
34690
34880
|
if (configured.length === 0) continue;
|
|
34691
|
-
const target = await NodeFSP12.realpath(configured).catch(() =>
|
|
34692
|
-
if (target.startsWith(`${real}${
|
|
34881
|
+
const target = await NodeFSP12.realpath(configured).catch(() => NodePath15.resolve(configured));
|
|
34882
|
+
if (target.startsWith(`${real}${NodePath15.sep}`)) return true;
|
|
34693
34883
|
}
|
|
34694
34884
|
return false;
|
|
34695
34885
|
};
|
|
@@ -34704,11 +34894,11 @@ function createRuntimeManager(deps) {
|
|
|
34704
34894
|
try {
|
|
34705
34895
|
await removeDirectory(directory);
|
|
34706
34896
|
deps.log.info("removed an old antigravity runtime version", {
|
|
34707
|
-
releaseId:
|
|
34897
|
+
releaseId: NodePath15.basename(directory)
|
|
34708
34898
|
});
|
|
34709
34899
|
} catch (error62) {
|
|
34710
34900
|
deps.log.warn("could not remove an old antigravity runtime version", {
|
|
34711
|
-
releaseId:
|
|
34901
|
+
releaseId: NodePath15.basename(directory),
|
|
34712
34902
|
error: error62 instanceof Error ? error62.message : String(error62)
|
|
34713
34903
|
});
|
|
34714
34904
|
}
|
|
@@ -34751,7 +34941,7 @@ function createRuntimeManager(deps) {
|
|
|
34751
34941
|
}
|
|
34752
34942
|
await discardVersion(directory);
|
|
34753
34943
|
});
|
|
34754
|
-
const
|
|
34944
|
+
const resolve7 = (input2) => {
|
|
34755
34945
|
const processEnv = input2.processEnv ?? deps.processEnv;
|
|
34756
34946
|
return resolveAntigravityExecutable({
|
|
34757
34947
|
binaryPath: input2.binaryPath,
|
|
@@ -34762,7 +34952,7 @@ function createRuntimeManager(deps) {
|
|
|
34762
34952
|
});
|
|
34763
34953
|
};
|
|
34764
34954
|
const acquire = (input2) => exclusive(async () => {
|
|
34765
|
-
const executable = await
|
|
34955
|
+
const executable = await resolve7(input2);
|
|
34766
34956
|
const directory = executable.managedVersionDirectory;
|
|
34767
34957
|
if (directory !== null) {
|
|
34768
34958
|
leases.set(directory, (leases.get(directory) ?? 0) + 1);
|
|
@@ -34918,7 +35108,7 @@ function createRuntimeManager(deps) {
|
|
|
34918
35108
|
void refreshPathBlocked();
|
|
34919
35109
|
};
|
|
34920
35110
|
},
|
|
34921
|
-
resolve:
|
|
35111
|
+
resolve: resolve7,
|
|
34922
35112
|
acquire,
|
|
34923
35113
|
reload,
|
|
34924
35114
|
snapshot,
|