omp-antigravity-acp-provider 0.1.19 → 0.1.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +47 -17
- package/extension/assets/runtime-manifest.json +205 -0
- package/extension/assets/src/acp/supervisor.mjs +101 -0
- package/extension/auth-sync.ts +1 -0
- package/extension/catalog-store.ts +21 -3
- package/extension/commands.ts +16 -2
- package/extension/context-transfer.ts +25 -0
- package/extension/continuation-claim.ts +20 -0
- package/extension/diagnostics.ts +40 -0
- package/extension/history-fingerprint.ts +80 -0
- package/extension/index.ts +30 -12
- package/extension/omp-session-source.ts +60 -0
- package/extension/runtime-pool.ts +24 -2
- package/extension/runtime.mjs +1289 -757
- package/extension/session-cleanup.ts +171 -176
- package/extension/session-store.ts +98 -0
- package/extension/structured-fingerprint.ts +63 -0
- package/extension/tier-connection.ts +53 -20
- package/package.json +5 -5
- package/scripts/build.mjs +171 -10
package/extension/runtime.mjs
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { createRequire as __ompCreateRequire } from "node:module";
|
|
2
|
-
import { pathToFileURL as __ompPathToFileURL } from "node:url";
|
|
3
2
|
const require = __ompCreateRequire(import.meta.url);
|
|
4
|
-
const __ompAssetURL = (specifier) =>
|
|
3
|
+
const __ompAssetURL = (specifier) => new URL(specifier.replace("pi-antigravity-acp-provider/", "./assets/"), import.meta.url).href;
|
|
5
4
|
var __create = Object.create;
|
|
6
5
|
var __defProp = Object.defineProperty;
|
|
7
6
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
@@ -1350,68 +1349,68 @@ var require_lockfile = __commonJS({
|
|
|
1350
1349
|
});
|
|
1351
1350
|
}
|
|
1352
1351
|
function updateLock(file2, options) {
|
|
1353
|
-
const
|
|
1354
|
-
if (
|
|
1352
|
+
const lock4 = locks[file2];
|
|
1353
|
+
if (lock4.updateTimeout) {
|
|
1355
1354
|
return;
|
|
1356
1355
|
}
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
options.fs.stat(
|
|
1361
|
-
const isOverThreshold =
|
|
1356
|
+
lock4.updateDelay = lock4.updateDelay || options.update;
|
|
1357
|
+
lock4.updateTimeout = setTimeout(() => {
|
|
1358
|
+
lock4.updateTimeout = null;
|
|
1359
|
+
options.fs.stat(lock4.lockfilePath, (err, stat) => {
|
|
1360
|
+
const isOverThreshold = lock4.lastUpdate + options.stale < Date.now();
|
|
1362
1361
|
if (err) {
|
|
1363
1362
|
if (err.code === "ENOENT" || isOverThreshold) {
|
|
1364
|
-
return setLockAsCompromised(file2,
|
|
1363
|
+
return setLockAsCompromised(file2, lock4, Object.assign(err, { code: "ECOMPROMISED" }));
|
|
1365
1364
|
}
|
|
1366
|
-
|
|
1365
|
+
lock4.updateDelay = 1e3;
|
|
1367
1366
|
return updateLock(file2, options);
|
|
1368
1367
|
}
|
|
1369
|
-
const isMtimeOurs =
|
|
1368
|
+
const isMtimeOurs = lock4.mtime.getTime() === stat.mtime.getTime();
|
|
1370
1369
|
if (!isMtimeOurs) {
|
|
1371
1370
|
return setLockAsCompromised(
|
|
1372
1371
|
file2,
|
|
1373
|
-
|
|
1372
|
+
lock4,
|
|
1374
1373
|
Object.assign(
|
|
1375
1374
|
new Error("Unable to update lock within the stale threshold"),
|
|
1376
1375
|
{ code: "ECOMPROMISED" }
|
|
1377
1376
|
)
|
|
1378
1377
|
);
|
|
1379
1378
|
}
|
|
1380
|
-
const mtime = mtimePrecision.getMtime(
|
|
1381
|
-
options.fs.utimes(
|
|
1382
|
-
const isOverThreshold2 =
|
|
1383
|
-
if (
|
|
1379
|
+
const mtime = mtimePrecision.getMtime(lock4.mtimePrecision);
|
|
1380
|
+
options.fs.utimes(lock4.lockfilePath, mtime, mtime, (err2) => {
|
|
1381
|
+
const isOverThreshold2 = lock4.lastUpdate + options.stale < Date.now();
|
|
1382
|
+
if (lock4.released) {
|
|
1384
1383
|
return;
|
|
1385
1384
|
}
|
|
1386
1385
|
if (err2) {
|
|
1387
1386
|
if (err2.code === "ENOENT" || isOverThreshold2) {
|
|
1388
|
-
return setLockAsCompromised(file2,
|
|
1387
|
+
return setLockAsCompromised(file2, lock4, Object.assign(err2, { code: "ECOMPROMISED" }));
|
|
1389
1388
|
}
|
|
1390
|
-
|
|
1389
|
+
lock4.updateDelay = 1e3;
|
|
1391
1390
|
return updateLock(file2, options);
|
|
1392
1391
|
}
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1392
|
+
lock4.mtime = mtime;
|
|
1393
|
+
lock4.lastUpdate = Date.now();
|
|
1394
|
+
lock4.updateDelay = null;
|
|
1396
1395
|
updateLock(file2, options);
|
|
1397
1396
|
});
|
|
1398
1397
|
});
|
|
1399
|
-
},
|
|
1400
|
-
if (
|
|
1401
|
-
|
|
1398
|
+
}, lock4.updateDelay);
|
|
1399
|
+
if (lock4.updateTimeout.unref) {
|
|
1400
|
+
lock4.updateTimeout.unref();
|
|
1402
1401
|
}
|
|
1403
1402
|
}
|
|
1404
|
-
function setLockAsCompromised(file2,
|
|
1405
|
-
|
|
1406
|
-
if (
|
|
1407
|
-
clearTimeout(
|
|
1403
|
+
function setLockAsCompromised(file2, lock4, err) {
|
|
1404
|
+
lock4.released = true;
|
|
1405
|
+
if (lock4.updateTimeout) {
|
|
1406
|
+
clearTimeout(lock4.updateTimeout);
|
|
1408
1407
|
}
|
|
1409
|
-
if (locks[file2] ===
|
|
1408
|
+
if (locks[file2] === lock4) {
|
|
1410
1409
|
delete locks[file2];
|
|
1411
1410
|
}
|
|
1412
|
-
|
|
1411
|
+
lock4.options.onCompromised(err);
|
|
1413
1412
|
}
|
|
1414
|
-
function
|
|
1413
|
+
function lock3(file2, options, callback) {
|
|
1415
1414
|
options = {
|
|
1416
1415
|
stale: 1e4,
|
|
1417
1416
|
update: null,
|
|
@@ -1441,7 +1440,7 @@ var require_lockfile = __commonJS({
|
|
|
1441
1440
|
if (err2) {
|
|
1442
1441
|
return callback(operation.mainError());
|
|
1443
1442
|
}
|
|
1444
|
-
const
|
|
1443
|
+
const lock4 = locks[file3] = {
|
|
1445
1444
|
lockfilePath: getLockFile(file3, options),
|
|
1446
1445
|
mtime,
|
|
1447
1446
|
mtimePrecision: mtimePrecision2,
|
|
@@ -1450,7 +1449,7 @@ var require_lockfile = __commonJS({
|
|
|
1450
1449
|
};
|
|
1451
1450
|
updateLock(file3, options);
|
|
1452
1451
|
callback(null, (releasedCallback) => {
|
|
1453
|
-
if (
|
|
1452
|
+
if (lock4.released) {
|
|
1454
1453
|
return releasedCallback && releasedCallback(Object.assign(new Error("Lock is already released"), { code: "ERELEASED" }));
|
|
1455
1454
|
}
|
|
1456
1455
|
unlock(file3, { ...options, realpath: false }, releasedCallback);
|
|
@@ -1469,12 +1468,12 @@ var require_lockfile = __commonJS({
|
|
|
1469
1468
|
if (err) {
|
|
1470
1469
|
return callback(err);
|
|
1471
1470
|
}
|
|
1472
|
-
const
|
|
1473
|
-
if (!
|
|
1471
|
+
const lock4 = locks[file3];
|
|
1472
|
+
if (!lock4) {
|
|
1474
1473
|
return callback(Object.assign(new Error("Lock is not acquired/owned by you"), { code: "ENOTACQUIRED" }));
|
|
1475
1474
|
}
|
|
1476
|
-
|
|
1477
|
-
|
|
1475
|
+
lock4.updateTimeout && clearTimeout(lock4.updateTimeout);
|
|
1476
|
+
lock4.released = true;
|
|
1478
1477
|
delete locks[file3];
|
|
1479
1478
|
removeLock(file3, options, callback);
|
|
1480
1479
|
});
|
|
@@ -1511,7 +1510,7 @@ var require_lockfile = __commonJS({
|
|
|
1511
1510
|
}
|
|
1512
1511
|
}
|
|
1513
1512
|
});
|
|
1514
|
-
module2.exports.lock =
|
|
1513
|
+
module2.exports.lock = lock3;
|
|
1515
1514
|
module2.exports.unlock = unlock;
|
|
1516
1515
|
module2.exports.check = check2;
|
|
1517
1516
|
module2.exports.getLocks = getLocks;
|
|
@@ -1589,11 +1588,11 @@ var require_proper_lockfile = __commonJS({
|
|
|
1589
1588
|
"use strict";
|
|
1590
1589
|
var lockfile = require_lockfile();
|
|
1591
1590
|
var { toPromise, toSync, toSyncOptions } = require_adapter();
|
|
1592
|
-
async function
|
|
1591
|
+
async function lock3(file2, options) {
|
|
1593
1592
|
const release = await toPromise(lockfile.lock)(file2, options);
|
|
1594
1593
|
return toPromise(release);
|
|
1595
1594
|
}
|
|
1596
|
-
function
|
|
1595
|
+
function lockSync(file2, options) {
|
|
1597
1596
|
const release = toSync(lockfile.lock)(file2, toSyncOptions(options));
|
|
1598
1597
|
return toSync(release);
|
|
1599
1598
|
}
|
|
@@ -1609,10 +1608,10 @@ var require_proper_lockfile = __commonJS({
|
|
|
1609
1608
|
function checkSync(file2, options) {
|
|
1610
1609
|
return toSync(lockfile.check)(file2, toSyncOptions(options));
|
|
1611
1610
|
}
|
|
1612
|
-
module2.exports =
|
|
1613
|
-
module2.exports.lock =
|
|
1611
|
+
module2.exports = lock3;
|
|
1612
|
+
module2.exports.lock = lock3;
|
|
1614
1613
|
module2.exports.unlock = unlock;
|
|
1615
|
-
module2.exports.lockSync =
|
|
1614
|
+
module2.exports.lockSync = lockSync;
|
|
1616
1615
|
module2.exports.unlockSync = unlockSync;
|
|
1617
1616
|
module2.exports.check = check2;
|
|
1618
1617
|
module2.exports.checkSync = checkSync;
|
|
@@ -7861,11 +7860,11 @@ var require_debuggability = __commonJS({
|
|
|
7861
7860
|
};
|
|
7862
7861
|
var parseLineInfoRegex = /[\/<\(]([^:\/]+):(\d+):(?:\d+)\)?\s*$/;
|
|
7863
7862
|
function parseLineInfo(line) {
|
|
7864
|
-
var
|
|
7865
|
-
if (
|
|
7863
|
+
var matches2 = line.match(parseLineInfoRegex);
|
|
7864
|
+
if (matches2) {
|
|
7866
7865
|
return {
|
|
7867
|
-
fileName:
|
|
7868
|
-
line: parseInt(
|
|
7866
|
+
fileName: matches2[1],
|
|
7867
|
+
line: parseInt(matches2[2], 10)
|
|
7869
7868
|
};
|
|
7870
7869
|
}
|
|
7871
7870
|
}
|
|
@@ -10193,9 +10192,9 @@ var require_timers = __commonJS({
|
|
|
10193
10192
|
clearTimeout(this.handle);
|
|
10194
10193
|
};
|
|
10195
10194
|
var afterValue = function(value) {
|
|
10196
|
-
return
|
|
10195
|
+
return delay5(+this).thenReturn(value);
|
|
10197
10196
|
};
|
|
10198
|
-
var
|
|
10197
|
+
var delay5 = Promise2.delay = function(ms, value) {
|
|
10199
10198
|
var ret2;
|
|
10200
10199
|
var handle;
|
|
10201
10200
|
if (value !== void 0) {
|
|
@@ -10217,7 +10216,7 @@ var require_timers = __commonJS({
|
|
|
10217
10216
|
return ret2;
|
|
10218
10217
|
};
|
|
10219
10218
|
Promise2.prototype.delay = function(ms) {
|
|
10220
|
-
return
|
|
10219
|
+
return delay5(ms, this);
|
|
10221
10220
|
};
|
|
10222
10221
|
var afterTimeout = function(promise2, message, parent) {
|
|
10223
10222
|
var err;
|
|
@@ -13106,37 +13105,37 @@ var require_dataType = __commonJS({
|
|
|
13106
13105
|
DataType2[DataType2["Wrong"] = 1] = "Wrong";
|
|
13107
13106
|
})(DataType || (exports2.DataType = DataType = {}));
|
|
13108
13107
|
function getSchemaTypes(schema) {
|
|
13109
|
-
const
|
|
13110
|
-
const hasNull =
|
|
13108
|
+
const types4 = getJSONTypes(schema.type);
|
|
13109
|
+
const hasNull = types4.includes("null");
|
|
13111
13110
|
if (hasNull) {
|
|
13112
13111
|
if (schema.nullable === false)
|
|
13113
13112
|
throw new Error("type: null contradicts nullable: false");
|
|
13114
13113
|
} else {
|
|
13115
|
-
if (!
|
|
13114
|
+
if (!types4.length && schema.nullable !== void 0) {
|
|
13116
13115
|
throw new Error('"nullable" cannot be used without "type"');
|
|
13117
13116
|
}
|
|
13118
13117
|
if (schema.nullable === true)
|
|
13119
|
-
|
|
13118
|
+
types4.push("null");
|
|
13120
13119
|
}
|
|
13121
|
-
return
|
|
13120
|
+
return types4;
|
|
13122
13121
|
}
|
|
13123
13122
|
exports2.getSchemaTypes = getSchemaTypes;
|
|
13124
13123
|
function getJSONTypes(ts) {
|
|
13125
|
-
const
|
|
13126
|
-
if (
|
|
13127
|
-
return
|
|
13128
|
-
throw new Error("type must be JSONType or JSONType[]: " +
|
|
13124
|
+
const types4 = Array.isArray(ts) ? ts : ts ? [ts] : [];
|
|
13125
|
+
if (types4.every(rules_1.isJSONType))
|
|
13126
|
+
return types4;
|
|
13127
|
+
throw new Error("type must be JSONType or JSONType[]: " + types4.join(","));
|
|
13129
13128
|
}
|
|
13130
13129
|
exports2.getJSONTypes = getJSONTypes;
|
|
13131
|
-
function coerceAndCheckDataType(it,
|
|
13130
|
+
function coerceAndCheckDataType(it, types4) {
|
|
13132
13131
|
const { gen, data, opts } = it;
|
|
13133
|
-
const coerceTo = coerceToTypes(
|
|
13134
|
-
const checkTypes =
|
|
13132
|
+
const coerceTo = coerceToTypes(types4, opts.coerceTypes);
|
|
13133
|
+
const checkTypes = types4.length > 0 && !(coerceTo.length === 0 && types4.length === 1 && (0, applicability_1.schemaHasRulesForType)(it, types4[0]));
|
|
13135
13134
|
if (checkTypes) {
|
|
13136
|
-
const wrongType = checkDataTypes(
|
|
13135
|
+
const wrongType = checkDataTypes(types4, data, opts.strictNumbers, DataType.Wrong);
|
|
13137
13136
|
gen.if(wrongType, () => {
|
|
13138
13137
|
if (coerceTo.length)
|
|
13139
|
-
coerceData(it,
|
|
13138
|
+
coerceData(it, types4, coerceTo);
|
|
13140
13139
|
else
|
|
13141
13140
|
reportTypeError(it);
|
|
13142
13141
|
});
|
|
@@ -13145,15 +13144,15 @@ var require_dataType = __commonJS({
|
|
|
13145
13144
|
}
|
|
13146
13145
|
exports2.coerceAndCheckDataType = coerceAndCheckDataType;
|
|
13147
13146
|
var COERCIBLE = /* @__PURE__ */ new Set(["string", "number", "integer", "boolean", "null"]);
|
|
13148
|
-
function coerceToTypes(
|
|
13149
|
-
return coerceTypes ?
|
|
13147
|
+
function coerceToTypes(types4, coerceTypes) {
|
|
13148
|
+
return coerceTypes ? types4.filter((t) => COERCIBLE.has(t) || coerceTypes === "array" && t === "array") : [];
|
|
13150
13149
|
}
|
|
13151
|
-
function coerceData(it,
|
|
13150
|
+
function coerceData(it, types4, coerceTo) {
|
|
13152
13151
|
const { gen, data, opts } = it;
|
|
13153
13152
|
const dataType = gen.let("dataType", (0, codegen_1._)`typeof ${data}`);
|
|
13154
13153
|
const coerced = gen.let("coerced", (0, codegen_1._)`undefined`);
|
|
13155
13154
|
if (opts.coerceTypes === "array") {
|
|
13156
|
-
gen.if((0, codegen_1._)`${dataType} == 'object' && Array.isArray(${data}) && ${data}.length == 1`, () => gen.assign(data, (0, codegen_1._)`${data}[0]`).assign(dataType, (0, codegen_1._)`typeof ${data}`).if(checkDataTypes(
|
|
13155
|
+
gen.if((0, codegen_1._)`${dataType} == 'object' && Array.isArray(${data}) && ${data}.length == 1`, () => gen.assign(data, (0, codegen_1._)`${data}[0]`).assign(dataType, (0, codegen_1._)`typeof ${data}`).if(checkDataTypes(types4, data, opts.strictNumbers), () => gen.assign(coerced, data)));
|
|
13157
13156
|
}
|
|
13158
13157
|
gen.if((0, codegen_1._)`${coerced} !== undefined`);
|
|
13159
13158
|
for (const t of coerceTo) {
|
|
@@ -13229,19 +13228,19 @@ var require_dataType = __commonJS({
|
|
|
13229
13228
|
return checkDataType(dataTypes[0], data, strictNums, correct);
|
|
13230
13229
|
}
|
|
13231
13230
|
let cond;
|
|
13232
|
-
const
|
|
13233
|
-
if (
|
|
13231
|
+
const types4 = (0, util_1.toHash)(dataTypes);
|
|
13232
|
+
if (types4.array && types4.object) {
|
|
13234
13233
|
const notObj = (0, codegen_1._)`typeof ${data} != "object"`;
|
|
13235
|
-
cond =
|
|
13236
|
-
delete
|
|
13237
|
-
delete
|
|
13238
|
-
delete
|
|
13234
|
+
cond = types4.null ? notObj : (0, codegen_1._)`!${data} || ${notObj}`;
|
|
13235
|
+
delete types4.null;
|
|
13236
|
+
delete types4.array;
|
|
13237
|
+
delete types4.object;
|
|
13239
13238
|
} else {
|
|
13240
13239
|
cond = codegen_1.nil;
|
|
13241
13240
|
}
|
|
13242
|
-
if (
|
|
13243
|
-
delete
|
|
13244
|
-
for (const t in
|
|
13241
|
+
if (types4.number)
|
|
13242
|
+
delete types4.integer;
|
|
13243
|
+
for (const t in types4)
|
|
13245
13244
|
cond = (0, codegen_1.and)(cond, checkDataType(t, data, strictNums, correct));
|
|
13246
13245
|
return cond;
|
|
13247
13246
|
}
|
|
@@ -14046,9 +14045,9 @@ var require_validate = __commonJS({
|
|
|
14046
14045
|
function typeAndKeywords(it, errsCount) {
|
|
14047
14046
|
if (it.opts.jtd)
|
|
14048
14047
|
return schemaKeywords(it, [], false, errsCount);
|
|
14049
|
-
const
|
|
14050
|
-
const checkedTypes = (0, dataType_1.coerceAndCheckDataType)(it,
|
|
14051
|
-
schemaKeywords(it,
|
|
14048
|
+
const types4 = (0, dataType_1.getSchemaTypes)(it.schema);
|
|
14049
|
+
const checkedTypes = (0, dataType_1.coerceAndCheckDataType)(it, types4);
|
|
14050
|
+
schemaKeywords(it, types4, !checkedTypes, errsCount);
|
|
14052
14051
|
}
|
|
14053
14052
|
function checkRefsAndKeywords(it) {
|
|
14054
14053
|
const { schema, errSchemaPath, opts, self: self2 } = it;
|
|
@@ -14098,7 +14097,7 @@ var require_validate = __commonJS({
|
|
|
14098
14097
|
if (items instanceof codegen_1.Name)
|
|
14099
14098
|
gen.assign((0, codegen_1._)`${evaluated}.items`, items);
|
|
14100
14099
|
}
|
|
14101
|
-
function schemaKeywords(it,
|
|
14100
|
+
function schemaKeywords(it, types4, typeErrors, errsCount) {
|
|
14102
14101
|
const { gen, schema, data, allErrors, opts, self: self2 } = it;
|
|
14103
14102
|
const { RULES } = self2;
|
|
14104
14103
|
if (schema.$ref && (opts.ignoreKeywordsWithRef || !(0, util_1.schemaHasRulesButRef)(schema, RULES))) {
|
|
@@ -14106,7 +14105,7 @@ var require_validate = __commonJS({
|
|
|
14106
14105
|
return;
|
|
14107
14106
|
}
|
|
14108
14107
|
if (!opts.jtd)
|
|
14109
|
-
checkStrictTypes(it,
|
|
14108
|
+
checkStrictTypes(it, types4);
|
|
14110
14109
|
gen.block(() => {
|
|
14111
14110
|
for (const group2 of RULES.rules)
|
|
14112
14111
|
groupKeywords(group2);
|
|
@@ -14118,7 +14117,7 @@ var require_validate = __commonJS({
|
|
|
14118
14117
|
if (group2.type) {
|
|
14119
14118
|
gen.if((0, dataType_2.checkDataType)(group2.type, data, opts.strictNumbers));
|
|
14120
14119
|
iterateKeywords(it, group2);
|
|
14121
|
-
if (
|
|
14120
|
+
if (types4.length === 1 && types4[0] === group2.type && typeErrors) {
|
|
14122
14121
|
gen.else();
|
|
14123
14122
|
(0, dataType_2.reportTypeError)(it);
|
|
14124
14123
|
}
|
|
@@ -14142,27 +14141,27 @@ var require_validate = __commonJS({
|
|
|
14142
14141
|
}
|
|
14143
14142
|
});
|
|
14144
14143
|
}
|
|
14145
|
-
function checkStrictTypes(it,
|
|
14144
|
+
function checkStrictTypes(it, types4) {
|
|
14146
14145
|
if (it.schemaEnv.meta || !it.opts.strictTypes)
|
|
14147
14146
|
return;
|
|
14148
|
-
checkContextTypes(it,
|
|
14147
|
+
checkContextTypes(it, types4);
|
|
14149
14148
|
if (!it.opts.allowUnionTypes)
|
|
14150
|
-
checkMultipleTypes(it,
|
|
14149
|
+
checkMultipleTypes(it, types4);
|
|
14151
14150
|
checkKeywordTypes(it, it.dataTypes);
|
|
14152
14151
|
}
|
|
14153
|
-
function checkContextTypes(it,
|
|
14154
|
-
if (!
|
|
14152
|
+
function checkContextTypes(it, types4) {
|
|
14153
|
+
if (!types4.length)
|
|
14155
14154
|
return;
|
|
14156
14155
|
if (!it.dataTypes.length) {
|
|
14157
|
-
it.dataTypes =
|
|
14156
|
+
it.dataTypes = types4;
|
|
14158
14157
|
return;
|
|
14159
14158
|
}
|
|
14160
|
-
|
|
14159
|
+
types4.forEach((t) => {
|
|
14161
14160
|
if (!includesType(it.dataTypes, t)) {
|
|
14162
14161
|
strictTypesError(it, `type "${t}" not allowed by context "${it.dataTypes.join(",")}"`);
|
|
14163
14162
|
}
|
|
14164
14163
|
});
|
|
14165
|
-
narrowSchemaTypes(it,
|
|
14164
|
+
narrowSchemaTypes(it, types4);
|
|
14166
14165
|
}
|
|
14167
14166
|
function checkMultipleTypes(it, ts) {
|
|
14168
14167
|
if (ts.length > 1 && !(ts.length === 2 && ts.includes("null"))) {
|
|
@@ -14398,11 +14397,11 @@ var require_validate = __commonJS({
|
|
|
14398
14397
|
jsonPointer = $data;
|
|
14399
14398
|
data = names_1.default.rootData;
|
|
14400
14399
|
} else {
|
|
14401
|
-
const
|
|
14402
|
-
if (!
|
|
14400
|
+
const matches2 = RELATIVE_JSON_POINTER.exec($data);
|
|
14401
|
+
if (!matches2)
|
|
14403
14402
|
throw new Error(`Invalid JSON-pointer: ${$data}`);
|
|
14404
|
-
const up = +
|
|
14405
|
-
jsonPointer =
|
|
14403
|
+
const up = +matches2[1];
|
|
14404
|
+
jsonPointer = matches2[2];
|
|
14406
14405
|
if (jsonPointer === "#") {
|
|
14407
14406
|
if (up >= dataLevel)
|
|
14408
14407
|
throw new Error(errorMsg("property/index", up));
|
|
@@ -15289,11 +15288,11 @@ var require_schemes = __commonJS({
|
|
|
15289
15288
|
urnComponent.error = "URN can not be parsed";
|
|
15290
15289
|
return urnComponent;
|
|
15291
15290
|
}
|
|
15292
|
-
const
|
|
15293
|
-
if (
|
|
15291
|
+
const matches2 = urnComponent.path.match(URN_REG);
|
|
15292
|
+
if (matches2 && matches2[0] === urnComponent.path) {
|
|
15294
15293
|
const scheme = options.scheme || urnComponent.scheme || "urn";
|
|
15295
|
-
urnComponent.nid =
|
|
15296
|
-
urnComponent.nss =
|
|
15294
|
+
urnComponent.nid = matches2[1].toLowerCase();
|
|
15295
|
+
urnComponent.nss = matches2[2];
|
|
15297
15296
|
const urnScheme = `${scheme}:${options.nid || urnComponent.nid}`;
|
|
15298
15297
|
const schemeHandler = getSchemeHandler(urnScheme);
|
|
15299
15298
|
urnComponent.path = void 0;
|
|
@@ -15607,8 +15606,8 @@ var require_fast_uri = __commonJS({
|
|
|
15607
15606
|
var URI_PARSE = /^(?:([^#/:?]+):)?(?:\/\/((?:([^#/?@]*)@)?(\[[^#/?\]]+\]|[^#/:?]*)(?::(\d*))?))?([^#?]*)(?:\?([^#]*))?(?:#((?:.|[\n\r])*))?/u;
|
|
15608
15607
|
var AUTHORITY_PREFIX = /^(?:[^#/:?]+:)?\/\/([^/?#]*)/;
|
|
15609
15608
|
var AUTHORITY_INTRODUCER_REGION = /^(?:[^#/:?]+:)?([/\\\t\n\r]*)/;
|
|
15610
|
-
function getParseError(parsed,
|
|
15611
|
-
if (
|
|
15609
|
+
function getParseError(parsed, matches2) {
|
|
15610
|
+
if (matches2[2] !== void 0 && parsed.path && parsed.path[0] !== "/") {
|
|
15612
15611
|
return 'URI path must start with "/" when authority is present.';
|
|
15613
15612
|
}
|
|
15614
15613
|
if (typeof parsed.port === "number" && (parsed.port < 0 || parsed.port > 65535)) {
|
|
@@ -15630,9 +15629,9 @@ var require_fast_uri = __commonJS({
|
|
|
15630
15629
|
function isIPLiteral(host) {
|
|
15631
15630
|
return host[0] === "[" && host[host.length - 1] === "]";
|
|
15632
15631
|
}
|
|
15633
|
-
function hasMalformedComponentPercentEncoding(
|
|
15634
|
-
const host =
|
|
15635
|
-
return hasMalformedPercentEncoding(
|
|
15632
|
+
function hasMalformedComponentPercentEncoding(matches2) {
|
|
15633
|
+
const host = matches2[4];
|
|
15634
|
+
return hasMalformedPercentEncoding(matches2[3]) || host !== void 0 && !isIPLiteral(host) && hasMalformedPercentEncoding(host) || hasMalformedPercentEncoding(matches2[6]) || hasMalformedPercentEncoding(matches2[7]) || hasMalformedPercentEncoding(matches2[8]);
|
|
15636
15635
|
}
|
|
15637
15636
|
function canonicalizeHost(parsed, options, schemeHandler, isIP) {
|
|
15638
15637
|
if (!options.unicodeSupport && (!schemeHandler || !schemeHandler.unicodeSupport) && parsed.host && !isIPLiteral(parsed.host) && (options.domainHost || schemeHandler && schemeHandler.domainHost) && isIP === false && nonSimpleDomain(parsed.host)) {
|
|
@@ -15689,15 +15688,15 @@ var require_fast_uri = __commonJS({
|
|
|
15689
15688
|
}
|
|
15690
15689
|
}
|
|
15691
15690
|
}
|
|
15692
|
-
const
|
|
15693
|
-
if (
|
|
15694
|
-
parsed.scheme =
|
|
15695
|
-
parsed.userinfo =
|
|
15696
|
-
parsed.host =
|
|
15697
|
-
parsed.port = parseInt(
|
|
15698
|
-
parsed.path =
|
|
15699
|
-
parsed.query =
|
|
15700
|
-
parsed.fragment =
|
|
15691
|
+
const matches2 = uri.match(URI_PARSE);
|
|
15692
|
+
if (matches2) {
|
|
15693
|
+
parsed.scheme = matches2[1];
|
|
15694
|
+
parsed.userinfo = matches2[3];
|
|
15695
|
+
parsed.host = matches2[4];
|
|
15696
|
+
parsed.port = parseInt(matches2[5], 10);
|
|
15697
|
+
parsed.path = matches2[6] || "";
|
|
15698
|
+
parsed.query = matches2[7];
|
|
15699
|
+
parsed.fragment = matches2[8];
|
|
15701
15700
|
if (parsed.scheme !== void 0) {
|
|
15702
15701
|
const decodedScheme = unescape(parsed.scheme);
|
|
15703
15702
|
if (VALID_SCHEME.test(decodedScheme)) {
|
|
@@ -15707,14 +15706,14 @@ var require_fast_uri = __commonJS({
|
|
|
15707
15706
|
malformedScheme = true;
|
|
15708
15707
|
}
|
|
15709
15708
|
}
|
|
15710
|
-
malformedPercentEncoding = hasMalformedComponentPercentEncoding(
|
|
15709
|
+
malformedPercentEncoding = hasMalformedComponentPercentEncoding(matches2);
|
|
15711
15710
|
if (malformedPercentEncoding) {
|
|
15712
15711
|
parsed.error = parsed.error || "URI contains malformed percent-encoding.";
|
|
15713
15712
|
}
|
|
15714
15713
|
if (isNaN(parsed.port)) {
|
|
15715
|
-
parsed.port =
|
|
15714
|
+
parsed.port = matches2[5];
|
|
15716
15715
|
}
|
|
15717
|
-
const parseError = getParseError(parsed,
|
|
15716
|
+
const parseError = getParseError(parsed, matches2);
|
|
15718
15717
|
if (parseError !== void 0) {
|
|
15719
15718
|
parsed.error = parsed.error || parseError;
|
|
15720
15719
|
malformedAuthorityOrPort = true;
|
|
@@ -18564,12 +18563,12 @@ var require_formats = __commonJS({
|
|
|
18564
18563
|
var DATE2 = /^(\d\d\d\d)-(\d\d)-(\d\d)$/;
|
|
18565
18564
|
var DAYS2 = [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
|
|
18566
18565
|
function date5(str) {
|
|
18567
|
-
const
|
|
18568
|
-
if (!
|
|
18566
|
+
const matches2 = DATE2.exec(str);
|
|
18567
|
+
if (!matches2)
|
|
18569
18568
|
return false;
|
|
18570
|
-
const year = +
|
|
18571
|
-
const month = +
|
|
18572
|
-
const day = +
|
|
18569
|
+
const year = +matches2[1];
|
|
18570
|
+
const month = +matches2[2];
|
|
18571
|
+
const day = +matches2[3];
|
|
18573
18572
|
return month >= 1 && month <= 12 && day >= 1 && day <= (month === 2 && isLeapYear(year) ? 29 : DAYS2[month]);
|
|
18574
18573
|
}
|
|
18575
18574
|
function compareDate(d1, d2) {
|
|
@@ -18584,16 +18583,16 @@ var require_formats = __commonJS({
|
|
|
18584
18583
|
var TIME2 = /^(\d\d):(\d\d):(\d\d(?:\.\d+)?)(z|([+-])(\d\d)(?::?(\d\d))?)?$/i;
|
|
18585
18584
|
function getTime(strictTimeZone) {
|
|
18586
18585
|
return function time3(str) {
|
|
18587
|
-
const
|
|
18588
|
-
if (!
|
|
18586
|
+
const matches2 = TIME2.exec(str);
|
|
18587
|
+
if (!matches2)
|
|
18589
18588
|
return false;
|
|
18590
|
-
const hr = +
|
|
18591
|
-
const min = +
|
|
18592
|
-
const sec = +
|
|
18593
|
-
const tz =
|
|
18594
|
-
const tzSign =
|
|
18595
|
-
const tzH = +(
|
|
18596
|
-
const tzM = +(
|
|
18589
|
+
const hr = +matches2[1];
|
|
18590
|
+
const min = +matches2[2];
|
|
18591
|
+
const sec = +matches2[3];
|
|
18592
|
+
const tz = matches2[4];
|
|
18593
|
+
const tzSign = matches2[5] === "-" ? -1 : 1;
|
|
18594
|
+
const tzH = +(matches2[6] || 0);
|
|
18595
|
+
const tzM = +(matches2[7] || 0);
|
|
18597
18596
|
if (tzH > 23 || tzM > 59 || strictTimeZone && !tz)
|
|
18598
18597
|
return false;
|
|
18599
18598
|
if (hr <= 23 && min <= 59 && sec < 60)
|
|
@@ -19174,6 +19173,91 @@ function validModelId(id) {
|
|
|
19174
19173
|
return id.length > 0 && id.length <= 128 && !/[\u0000-\u001f\u007f]/u.test(id);
|
|
19175
19174
|
}
|
|
19176
19175
|
|
|
19176
|
+
// extension/history-fingerprint.ts
|
|
19177
|
+
import { types } from "node:util";
|
|
19178
|
+
var UNSUPPORTED = /* @__PURE__ */ Symbol("unsupported snapshot");
|
|
19179
|
+
var MIN_STRING = 2048;
|
|
19180
|
+
var MAX_NODES = 128;
|
|
19181
|
+
function worthCaching(content) {
|
|
19182
|
+
if (typeof content === "string") return content.length >= MIN_STRING;
|
|
19183
|
+
if (!Array.isArray(content) || types.isProxy(content)) return false;
|
|
19184
|
+
for (let i = 0; i < Math.min(content.length, 32); i++) {
|
|
19185
|
+
const block = Object.getOwnPropertyDescriptor(content, String(i))?.value;
|
|
19186
|
+
if (!block || typeof block !== "object" || types.isProxy(block)) continue;
|
|
19187
|
+
for (const key of ["text", "data", "thinking"]) {
|
|
19188
|
+
const value = Object.getOwnPropertyDescriptor(block, key)?.value;
|
|
19189
|
+
if (typeof value === "string" && value.length >= MIN_STRING) return true;
|
|
19190
|
+
}
|
|
19191
|
+
}
|
|
19192
|
+
return false;
|
|
19193
|
+
}
|
|
19194
|
+
function snapshot(value, budget = { nodes: 0 }, seen = /* @__PURE__ */ new Set()) {
|
|
19195
|
+
if (++budget.nodes > MAX_NODES) return UNSUPPORTED;
|
|
19196
|
+
if (value === null || typeof value !== "object") {
|
|
19197
|
+
return ["function", "symbol", "bigint"].includes(typeof value) ? UNSUPPORTED : value;
|
|
19198
|
+
}
|
|
19199
|
+
const array2 = Array.isArray(value);
|
|
19200
|
+
if (types.isProxy(value) || seen.has(value) || Object.getPrototypeOf(value) !== (array2 ? Array.prototype : Object.prototype)) return UNSUPPORTED;
|
|
19201
|
+
seen.add(value);
|
|
19202
|
+
const keys = Object.keys(value);
|
|
19203
|
+
if (keys.length > MAX_NODES || array2 && (keys.length !== value.length || Object.getOwnPropertyNames(value).length !== keys.length + 1)) return UNSUPPORTED;
|
|
19204
|
+
const result = array2 ? [] : /* @__PURE__ */ Object.create(null);
|
|
19205
|
+
for (let i = 0; i < keys.length; i++) {
|
|
19206
|
+
const key = keys[i];
|
|
19207
|
+
if (array2 && key !== String(i)) return UNSUPPORTED;
|
|
19208
|
+
const descriptor = Object.getOwnPropertyDescriptor(value, key);
|
|
19209
|
+
if (!Object.hasOwn(descriptor, "value")) return UNSUPPORTED;
|
|
19210
|
+
const child = snapshot(descriptor.value, budget, seen);
|
|
19211
|
+
if (child === UNSUPPORTED) return UNSUPPORTED;
|
|
19212
|
+
result[key] = child;
|
|
19213
|
+
}
|
|
19214
|
+
return result;
|
|
19215
|
+
}
|
|
19216
|
+
function matches(value, saved, budget = { nodes: 0 }) {
|
|
19217
|
+
if (++budget.nodes > MAX_NODES) return false;
|
|
19218
|
+
if (value === null || typeof value !== "object") return Object.is(value, saved);
|
|
19219
|
+
const array2 = Array.isArray(value);
|
|
19220
|
+
if (types.isProxy(value) || !saved || typeof saved !== "object" || array2 !== Array.isArray(saved) || Object.getPrototypeOf(value) !== (array2 ? Array.prototype : Object.prototype)) return false;
|
|
19221
|
+
const keys = Object.keys(value);
|
|
19222
|
+
if (keys.length > MAX_NODES || keys.length !== Object.keys(saved).length || array2 && (value.length !== saved.length || Object.getOwnPropertyNames(value).length !== keys.length + 1)) return false;
|
|
19223
|
+
for (const key of keys) {
|
|
19224
|
+
const descriptor = Object.getOwnPropertyDescriptor(value, key);
|
|
19225
|
+
if (!Object.hasOwn(descriptor, "value") || !Object.hasOwn(saved, key) || !matches(descriptor.value, saved[key], budget)) return false;
|
|
19226
|
+
}
|
|
19227
|
+
return true;
|
|
19228
|
+
}
|
|
19229
|
+
function createHistoryFingerprintMemo() {
|
|
19230
|
+
const entries = /* @__PURE__ */ new WeakMap();
|
|
19231
|
+
return (message, value, compute) => {
|
|
19232
|
+
const previous = entries.get(message);
|
|
19233
|
+
if (previous && matches(value, previous.value)) return previous.digest;
|
|
19234
|
+
if (previous) entries.delete(message);
|
|
19235
|
+
if (!worthCaching(value.content)) return compute();
|
|
19236
|
+
const saved = snapshot(value);
|
|
19237
|
+
const digest = compute();
|
|
19238
|
+
if (saved !== UNSUPPORTED) entries.set(message, { value: saved, digest });
|
|
19239
|
+
return digest;
|
|
19240
|
+
};
|
|
19241
|
+
}
|
|
19242
|
+
|
|
19243
|
+
// extension/continuation-claim.ts
|
|
19244
|
+
var owners = /* @__PURE__ */ new WeakSet();
|
|
19245
|
+
async function claimContinuation(binding, work, invalidate) {
|
|
19246
|
+
if (owners.has(binding)) throw new Error("ACP continuation is already in progress for this session");
|
|
19247
|
+
owners.add(binding);
|
|
19248
|
+
try {
|
|
19249
|
+
await work();
|
|
19250
|
+
} catch (error62) {
|
|
19251
|
+
try {
|
|
19252
|
+
await invalidate();
|
|
19253
|
+
} catch {
|
|
19254
|
+
}
|
|
19255
|
+
throw error62;
|
|
19256
|
+
} finally {
|
|
19257
|
+
owners.delete(binding);
|
|
19258
|
+
}
|
|
19259
|
+
}
|
|
19260
|
+
|
|
19177
19261
|
// extension/turn-cancellation.ts
|
|
19178
19262
|
async function drainCancelledTurn(binding, abort, signal, timeoutMs = 1500) {
|
|
19179
19263
|
const completion = binding.turnCompletion;
|
|
@@ -19196,6 +19280,97 @@ async function drainCancelledTurn(binding, abort, signal, timeoutMs = 1500) {
|
|
|
19196
19280
|
}
|
|
19197
19281
|
}
|
|
19198
19282
|
|
|
19283
|
+
// extension/structured-fingerprint.ts
|
|
19284
|
+
import { types as types2 } from "node:util";
|
|
19285
|
+
var OBJECT = /* @__PURE__ */ Symbol("object");
|
|
19286
|
+
var NULL_OBJECT = /* @__PURE__ */ Symbol("null object");
|
|
19287
|
+
var ARRAY = /* @__PURE__ */ Symbol("array");
|
|
19288
|
+
var FUNCTION = /* @__PURE__ */ Symbol("function");
|
|
19289
|
+
var MAX_NODES2 = 32768;
|
|
19290
|
+
var MAX_TOKENS = 131072;
|
|
19291
|
+
var MAX_CHARS = 2 * 1024 * 1024;
|
|
19292
|
+
var FUNCTION_PROTOTYPES = /* @__PURE__ */ new Set([
|
|
19293
|
+
Function.prototype,
|
|
19294
|
+
Object.getPrototypeOf(async () => {
|
|
19295
|
+
}),
|
|
19296
|
+
Object.getPrototypeOf(function* () {
|
|
19297
|
+
}),
|
|
19298
|
+
Object.getPrototypeOf(async function* () {
|
|
19299
|
+
})
|
|
19300
|
+
]);
|
|
19301
|
+
function createStructuredFingerprintMemo() {
|
|
19302
|
+
let tokens, digest;
|
|
19303
|
+
function visit2(value, put, budget, seen) {
|
|
19304
|
+
if (++budget.nodes > MAX_NODES2) throw new Error("snapshot node budget");
|
|
19305
|
+
if (typeof value === "function") {
|
|
19306
|
+
if (types2.isProxy(value) || !FUNCTION_PROTOTYPES.has(Object.getPrototypeOf(value)) || "toJSON" in value) throw new Error("exotic function");
|
|
19307
|
+
put(FUNCTION);
|
|
19308
|
+
return;
|
|
19309
|
+
}
|
|
19310
|
+
if (value === null || typeof value !== "object") {
|
|
19311
|
+
if (typeof value === "symbol" || typeof value === "bigint") throw new Error("unsupported primitive");
|
|
19312
|
+
if (typeof value === "string" && (budget.chars += value.length) > MAX_CHARS) throw new Error("snapshot string budget");
|
|
19313
|
+
put(value);
|
|
19314
|
+
return;
|
|
19315
|
+
}
|
|
19316
|
+
if (types2.isProxy(value)) throw new Error("proxy");
|
|
19317
|
+
const array2 = Array.isArray(value), prototype = Object.getPrototypeOf(value);
|
|
19318
|
+
if (seen.has(value) || (array2 ? prototype !== Array.prototype : prototype !== Object.prototype && prototype !== null) || Object.getOwnPropertySymbols(value).length) throw new Error("unsupported container");
|
|
19319
|
+
seen.add(value);
|
|
19320
|
+
const keys = Object.getOwnPropertyNames(value);
|
|
19321
|
+
if (keys.length > MAX_NODES2) throw new Error("snapshot key budget");
|
|
19322
|
+
if (array2 && (keys.length !== value.length + 1 || keys.at(-1) !== "length")) throw new Error("custom/sparse array");
|
|
19323
|
+
put(array2 ? ARRAY : prototype === null ? NULL_OBJECT : OBJECT);
|
|
19324
|
+
put(keys.length);
|
|
19325
|
+
for (let i = 0; i < keys.length; i++) {
|
|
19326
|
+
const key = keys[i];
|
|
19327
|
+
if (array2 && i < keys.length - 1 && key !== String(i)) throw new Error("sparse array");
|
|
19328
|
+
const descriptor = Object.getOwnPropertyDescriptor(value, key);
|
|
19329
|
+
if (!("value" in descriptor)) throw new Error("accessor");
|
|
19330
|
+
if ((budget.chars += key.length) > MAX_CHARS) throw new Error("snapshot string budget");
|
|
19331
|
+
put(key);
|
|
19332
|
+
put(descriptor.enumerable);
|
|
19333
|
+
visit2(descriptor.value, put, budget, seen);
|
|
19334
|
+
}
|
|
19335
|
+
}
|
|
19336
|
+
const clear = () => {
|
|
19337
|
+
tokens = void 0;
|
|
19338
|
+
digest = void 0;
|
|
19339
|
+
};
|
|
19340
|
+
const memo2 = (value, compute) => {
|
|
19341
|
+
if (tokens) {
|
|
19342
|
+
let index = 0;
|
|
19343
|
+
try {
|
|
19344
|
+
visit2(value, (token2) => {
|
|
19345
|
+
if (!Object.is(token2, tokens[index++])) throw new Error("changed");
|
|
19346
|
+
}, { nodes: 0, chars: 0 }, /* @__PURE__ */ new Set());
|
|
19347
|
+
if (index === tokens.length) return digest;
|
|
19348
|
+
} catch {
|
|
19349
|
+
}
|
|
19350
|
+
}
|
|
19351
|
+
clear();
|
|
19352
|
+
let next = [];
|
|
19353
|
+
try {
|
|
19354
|
+
visit2(
|
|
19355
|
+
value,
|
|
19356
|
+
(token2) => {
|
|
19357
|
+
if (next.length >= MAX_TOKENS) throw new Error("snapshot token budget");
|
|
19358
|
+
next.push(token2);
|
|
19359
|
+
},
|
|
19360
|
+
{ nodes: 0, chars: 0 },
|
|
19361
|
+
/* @__PURE__ */ new Set()
|
|
19362
|
+
);
|
|
19363
|
+
} catch {
|
|
19364
|
+
next = void 0;
|
|
19365
|
+
}
|
|
19366
|
+
const result = compute();
|
|
19367
|
+
tokens = next;
|
|
19368
|
+
digest = next ? result : void 0;
|
|
19369
|
+
return result;
|
|
19370
|
+
};
|
|
19371
|
+
return Object.assign(memo2, { clear });
|
|
19372
|
+
}
|
|
19373
|
+
|
|
19199
19374
|
// node_modules/@earendil-works/pi-ai/dist/utils/event-stream.js
|
|
19200
19375
|
var FifoQueue = class {
|
|
19201
19376
|
incoming = [];
|
|
@@ -23209,16 +23384,16 @@ var $ZodUnion = /* @__PURE__ */ $constructor("$ZodUnion", (inst, def) => {
|
|
|
23209
23384
|
};
|
|
23210
23385
|
});
|
|
23211
23386
|
function handleExclusiveUnionResults(results, final, inst, ctx) {
|
|
23212
|
-
const
|
|
23387
|
+
const matches2 = [];
|
|
23213
23388
|
for (let i = 0; i < results.length; i++) {
|
|
23214
23389
|
if (results[i].issues.length === 0)
|
|
23215
|
-
|
|
23390
|
+
matches2.push(i);
|
|
23216
23391
|
}
|
|
23217
|
-
if (
|
|
23218
|
-
final.value = results[
|
|
23392
|
+
if (matches2.length === 1) {
|
|
23393
|
+
final.value = results[matches2[0]].value;
|
|
23219
23394
|
return final;
|
|
23220
23395
|
}
|
|
23221
|
-
if (
|
|
23396
|
+
if (matches2.length === 0) {
|
|
23222
23397
|
final.issues.push({
|
|
23223
23398
|
code: "invalid_union",
|
|
23224
23399
|
input: final.value,
|
|
@@ -23232,7 +23407,7 @@ function handleExclusiveUnionResults(results, final, inst, ctx) {
|
|
|
23232
23407
|
inst,
|
|
23233
23408
|
errors: [],
|
|
23234
23409
|
inclusive: false,
|
|
23235
|
-
matches
|
|
23410
|
+
matches: matches2
|
|
23236
23411
|
});
|
|
23237
23412
|
}
|
|
23238
23413
|
return final;
|
|
@@ -34620,10 +34795,10 @@ function _properties(shape, params) {
|
|
|
34620
34795
|
});
|
|
34621
34796
|
}
|
|
34622
34797
|
// @__NO_SIDE_EFFECTS__
|
|
34623
|
-
function _mime(
|
|
34798
|
+
function _mime(types4, params) {
|
|
34624
34799
|
return new $ZodCheckMimeType({
|
|
34625
34800
|
check: "mime_type",
|
|
34626
|
-
mime:
|
|
34801
|
+
mime: types4,
|
|
34627
34802
|
...normalizeParams(params)
|
|
34628
34803
|
});
|
|
34629
34804
|
}
|
|
@@ -35210,7 +35385,7 @@ function compactTypeUnion(schema) {
|
|
|
35210
35385
|
const options = schema.anyOf;
|
|
35211
35386
|
if (!Array.isArray(options) || options.length === 0 || schema.type !== void 0)
|
|
35212
35387
|
return;
|
|
35213
|
-
const
|
|
35388
|
+
const types4 = [];
|
|
35214
35389
|
for (const option of options) {
|
|
35215
35390
|
if (!option || typeof option !== "object")
|
|
35216
35391
|
return;
|
|
@@ -35222,12 +35397,12 @@ function compactTypeUnion(schema) {
|
|
|
35222
35397
|
for (const member of Array.isArray(type) ? type : [type]) {
|
|
35223
35398
|
if (typeof member !== "string")
|
|
35224
35399
|
return;
|
|
35225
|
-
if (!
|
|
35226
|
-
|
|
35400
|
+
if (!types4.includes(member))
|
|
35401
|
+
types4.push(member);
|
|
35227
35402
|
}
|
|
35228
35403
|
}
|
|
35229
35404
|
delete schema.anyOf;
|
|
35230
|
-
schema.type =
|
|
35405
|
+
schema.type = types4.length === 1 ? types4[0] : types4;
|
|
35231
35406
|
}
|
|
35232
35407
|
var FOLDABLE_KEYS = /* @__PURE__ */ new Set(["type", "properties", "required", "additionalProperties"]);
|
|
35233
35408
|
var UNION_KEYS = ["oneOf", "anyOf"];
|
|
@@ -36026,8 +36201,8 @@ function stringifyKeyNames(bySchema, json3, visited2) {
|
|
|
36026
36201
|
if (mapped.some((branch, i) => branch !== branches[i]))
|
|
36027
36202
|
json3 = { ...json3, [keyword]: mapped };
|
|
36028
36203
|
}
|
|
36029
|
-
const
|
|
36030
|
-
const numericType = !
|
|
36204
|
+
const types4 = Array.isArray(json3.type) ? json3.type : [json3.type];
|
|
36205
|
+
const numericType = !types4.includes("string") && types4.some((t) => t === "number" || t === "integer");
|
|
36031
36206
|
const values = json3.enum ?? (json3.const !== void 0 ? [json3.const] : void 0);
|
|
36032
36207
|
if (!numericType && !values?.some((v) => typeof v === "number"))
|
|
36033
36208
|
return json3;
|
|
@@ -36040,7 +36215,7 @@ function stringifyKeyNames(bySchema, json3, visited2) {
|
|
|
36040
36215
|
return rest;
|
|
36041
36216
|
rest.type = "string";
|
|
36042
36217
|
if (!values)
|
|
36043
|
-
rest.pattern = (
|
|
36218
|
+
rest.pattern = (types4.includes("number") ? number : integer).source;
|
|
36044
36219
|
return rest;
|
|
36045
36220
|
}
|
|
36046
36221
|
var pendingRecords = /* @__PURE__ */ new WeakMap();
|
|
@@ -37773,7 +37948,7 @@ var ZodFile = /* @__PURE__ */ $constructor("ZodFile", (inst, def) => {
|
|
|
37773
37948
|
inst._zod.processJSONSchema = (ctx, json3, params) => fileProcessor(inst, ctx, json3, params);
|
|
37774
37949
|
inst.min = (size, params) => inst.check(_minSize(size, params));
|
|
37775
37950
|
inst.max = (size, params) => inst.check(_maxSize(size, params));
|
|
37776
|
-
inst.mime = (
|
|
37951
|
+
inst.mime = (types4, params) => inst.check(_mime(Array.isArray(types4) ? types4 : [types4], params));
|
|
37777
37952
|
});
|
|
37778
37953
|
function file(params) {
|
|
37779
37954
|
return _file(ZodFile, params);
|
|
@@ -38431,20 +38606,20 @@ function checkArrayGuards(arraySchema, guards) {
|
|
|
38431
38606
|
if (guards.containsSchema) {
|
|
38432
38607
|
const minContains = guards.minContains ?? 1;
|
|
38433
38608
|
const ceiling = guards.maxContains !== void 0 ? guards.maxContains + 1 : Number.POSITIVE_INFINITY;
|
|
38434
|
-
let
|
|
38609
|
+
let matches2 = 0;
|
|
38435
38610
|
for (const item of items) {
|
|
38436
|
-
if (guards.containsSchema.safeParse(item).success && ++
|
|
38611
|
+
if (guards.containsSchema.safeParse(item).success && ++matches2 >= ceiling)
|
|
38437
38612
|
break;
|
|
38438
38613
|
}
|
|
38439
|
-
if (
|
|
38614
|
+
if (matches2 < minContains) {
|
|
38440
38615
|
payload.issues.push({
|
|
38441
38616
|
code: "custom",
|
|
38442
|
-
message: `Array must contain at least ${minContains} matching ${plural(minContains)}; found ${
|
|
38617
|
+
message: `Array must contain at least ${minContains} matching ${plural(minContains)}; found ${matches2}`,
|
|
38443
38618
|
input: items,
|
|
38444
38619
|
continue: true
|
|
38445
38620
|
});
|
|
38446
38621
|
}
|
|
38447
|
-
if (guards.maxContains !== void 0 &&
|
|
38622
|
+
if (guards.maxContains !== void 0 && matches2 > guards.maxContains) {
|
|
38448
38623
|
payload.issues.push({
|
|
38449
38624
|
code: "custom",
|
|
38450
38625
|
message: `Array must contain at most ${guards.maxContains} matching ${plural(guards.maxContains)}`,
|
|
@@ -44225,9 +44400,12 @@ function structuredErrorDetail(data) {
|
|
|
44225
44400
|
return typeof detail === "string" && detail.trim() ? redact(detail.trim()) : void 0;
|
|
44226
44401
|
}
|
|
44227
44402
|
|
|
44228
|
-
//
|
|
44229
|
-
|
|
44230
|
-
import
|
|
44403
|
+
// extension/session-store.ts
|
|
44404
|
+
var import_proper_lockfile = __toESM(require_proper_lockfile(), 1);
|
|
44405
|
+
import fs4 from "node:fs/promises";
|
|
44406
|
+
import path5 from "node:path";
|
|
44407
|
+
import { randomUUID } from "node:crypto";
|
|
44408
|
+
import { setTimeout as delay2 } from "node:timers/promises";
|
|
44231
44409
|
|
|
44232
44410
|
// node_modules/pi-antigravity-acp-provider/src/config.ts
|
|
44233
44411
|
import fs3 from "node:fs";
|
|
@@ -44306,85 +44484,109 @@ function isRuntimeUpdateMode(value) {
|
|
|
44306
44484
|
return value === "automatic" || value === "notify" || value === "manual";
|
|
44307
44485
|
}
|
|
44308
44486
|
|
|
44309
|
-
//
|
|
44310
|
-
var
|
|
44311
|
-
import fs4 from "node:fs";
|
|
44312
|
-
import path5 from "node:path";
|
|
44313
|
-
function withStoreLock(file2, update) {
|
|
44314
|
-
fs4.mkdirSync(path5.dirname(file2), { recursive: true, mode: 448 });
|
|
44315
|
-
const deadline = Date.now() + 5e3;
|
|
44316
|
-
const sleeper = new Int32Array(new SharedArrayBuffer(4));
|
|
44317
|
-
let release;
|
|
44318
|
-
for (; ; ) {
|
|
44319
|
-
try {
|
|
44320
|
-
release = (0, import_proper_lockfile.lockSync)(file2, { realpath: false, stale: 3e4 });
|
|
44321
|
-
break;
|
|
44322
|
-
} catch (error62) {
|
|
44323
|
-
if (error62.code !== "ELOCKED" || Date.now() >= deadline) throw error62;
|
|
44324
|
-
Atomics.wait(sleeper, 0, 0, 10);
|
|
44325
|
-
}
|
|
44326
|
-
}
|
|
44327
|
-
try {
|
|
44328
|
-
update();
|
|
44329
|
-
} finally {
|
|
44330
|
-
release();
|
|
44331
|
-
}
|
|
44332
|
-
}
|
|
44333
|
-
|
|
44334
|
-
// node_modules/pi-antigravity-acp-provider/src/acp/session-store.ts
|
|
44335
|
-
function resolveSessionStorePath() {
|
|
44336
|
-
return path6.join(resolvePiAgentDir(), "antigravity-acp-provider", "sessions.json");
|
|
44337
|
-
}
|
|
44338
|
-
var MAX_RECORDS = 256;
|
|
44339
|
-
var MAX_AGE_MS = 30 * 24 * 60 * 6e4;
|
|
44487
|
+
// extension/session-store.ts
|
|
44488
|
+
var tails = /* @__PURE__ */ new Map();
|
|
44340
44489
|
var AcpSessionStore = class {
|
|
44341
|
-
constructor(file2 = resolveSessionStorePath()) {
|
|
44342
|
-
this.file = file2;
|
|
44343
|
-
}
|
|
44344
44490
|
file;
|
|
44345
|
-
|
|
44346
|
-
|
|
44491
|
+
constructor(file2 = path5.join(resolvePiAgentDir(), "antigravity-acp-provider", "sessions.json")) {
|
|
44492
|
+
this.file = path5.resolve(file2);
|
|
44493
|
+
}
|
|
44494
|
+
enqueue(work) {
|
|
44495
|
+
const result = (tails.get(this.file) ?? Promise.resolve()).catch(() => {
|
|
44496
|
+
}).then(work);
|
|
44497
|
+
tails.set(this.file, result);
|
|
44498
|
+
void result.finally(() => {
|
|
44499
|
+
if (tails.get(this.file) === result) tails.delete(this.file);
|
|
44500
|
+
}).catch(() => {
|
|
44501
|
+
});
|
|
44502
|
+
return result;
|
|
44503
|
+
}
|
|
44504
|
+
async flush() {
|
|
44505
|
+
await tails.get(this.file);
|
|
44506
|
+
}
|
|
44507
|
+
get(id) {
|
|
44508
|
+
return this.enqueue(async () => (await this.read()).find((record3) => record3.piSessionId === id && Date.now() - record3.lastActive <= 30 * 24 * 60 * 6e4));
|
|
44347
44509
|
}
|
|
44348
44510
|
save(record3) {
|
|
44349
|
-
|
|
44350
|
-
|
|
44351
|
-
records.
|
|
44352
|
-
records.
|
|
44353
|
-
|
|
44511
|
+
const captured = { ...record3 };
|
|
44512
|
+
return this.update(async () => {
|
|
44513
|
+
const records = (await this.read()).filter((value) => value.piSessionId !== captured.piSessionId);
|
|
44514
|
+
records.push(captured);
|
|
44515
|
+
records.sort((a, b) => b.lastActive - a.lastActive);
|
|
44516
|
+
await this.write(records.slice(0, 256));
|
|
44354
44517
|
});
|
|
44355
44518
|
}
|
|
44356
|
-
remove(
|
|
44357
|
-
|
|
44519
|
+
remove(id) {
|
|
44520
|
+
return this.update(async () => this.write((await this.read()).filter((record3) => record3.piSessionId !== id)));
|
|
44521
|
+
}
|
|
44522
|
+
removeIfMatches(id, acpSessionId) {
|
|
44523
|
+
let removed = false;
|
|
44524
|
+
return this.update(async () => {
|
|
44525
|
+
const records = await this.read();
|
|
44526
|
+
removed = records.some((record3) => record3.piSessionId === id && record3.acpSessionId === acpSessionId);
|
|
44527
|
+
if (removed) await this.write(records.filter((record3) => record3.piSessionId !== id || record3.acpSessionId !== acpSessionId));
|
|
44528
|
+
}).then(() => removed);
|
|
44358
44529
|
}
|
|
44359
44530
|
clear() {
|
|
44360
|
-
|
|
44531
|
+
return this.update(() => fs4.rm(this.file, { force: true }));
|
|
44532
|
+
}
|
|
44533
|
+
update(work) {
|
|
44534
|
+
return this.enqueue(async () => {
|
|
44535
|
+
await fs4.mkdir(path5.dirname(this.file), { recursive: true, mode: 448 });
|
|
44536
|
+
const deadline = Date.now() + 5e3;
|
|
44537
|
+
let compromised;
|
|
44538
|
+
let release;
|
|
44539
|
+
for (; ; ) {
|
|
44540
|
+
try {
|
|
44541
|
+
release = await (0, import_proper_lockfile.lock)(this.file, {
|
|
44542
|
+
realpath: false,
|
|
44543
|
+
stale: 3e4,
|
|
44544
|
+
retries: 0,
|
|
44545
|
+
onCompromised: (error62) => {
|
|
44546
|
+
compromised = error62;
|
|
44547
|
+
}
|
|
44548
|
+
});
|
|
44549
|
+
break;
|
|
44550
|
+
} catch (error62) {
|
|
44551
|
+
if (error62.code !== "ELOCKED" || Date.now() >= deadline) throw error62;
|
|
44552
|
+
await delay2(10);
|
|
44553
|
+
}
|
|
44554
|
+
}
|
|
44555
|
+
try {
|
|
44556
|
+
if (compromised) throw compromised;
|
|
44557
|
+
await work();
|
|
44558
|
+
if (compromised) throw compromised;
|
|
44559
|
+
} finally {
|
|
44560
|
+
await release();
|
|
44561
|
+
}
|
|
44562
|
+
});
|
|
44361
44563
|
}
|
|
44362
|
-
read() {
|
|
44564
|
+
async read() {
|
|
44565
|
+
let raw;
|
|
44363
44566
|
try {
|
|
44364
|
-
|
|
44365
|
-
|
|
44366
|
-
|
|
44367
|
-
|
|
44368
|
-
return [];
|
|
44567
|
+
raw = await fs4.readFile(this.file, "utf8");
|
|
44568
|
+
} catch (error62) {
|
|
44569
|
+
if (error62.code === "ENOENT") return [];
|
|
44570
|
+
throw error62;
|
|
44369
44571
|
}
|
|
44572
|
+
const parsed = JSON.parse(raw);
|
|
44573
|
+
if (!Array.isArray(parsed)) throw new Error("Invalid ACP session registry; refusing to overwrite it");
|
|
44574
|
+
return parsed.filter((record3) => Boolean(record3) && typeof record3 === "object" && ["piSessionId", "acpSessionId", "acpModelId", "cwd", "historyFingerprint"].every((key) => typeof record3[key] === "string") && Number.isSafeInteger(record3.messageCount) && record3.messageCount >= 0 && Number.isFinite(record3.lastActive) && (record3.expectedAssistantFingerprint === void 0 || typeof record3.expectedAssistantFingerprint === "string") && (record3.ompCheckpointVersion === void 0 || record3.ompCheckpointVersion === 1) && ["ompInFlight", "ompExpectedAssistantHasOutput", "ompCancelledCheckpoint", "ompCancelledHadOutput"].every((key) => record3[key] === void 0 || typeof record3[key] === "boolean"));
|
|
44370
44575
|
}
|
|
44371
|
-
write(records) {
|
|
44372
|
-
if (records.length
|
|
44373
|
-
|
|
44576
|
+
async write(records) {
|
|
44577
|
+
if (!records.length) {
|
|
44578
|
+
await fs4.rm(this.file, { force: true });
|
|
44374
44579
|
return;
|
|
44375
44580
|
}
|
|
44376
|
-
|
|
44377
|
-
|
|
44378
|
-
|
|
44379
|
-
|
|
44380
|
-
|
|
44581
|
+
const temporary = `${this.file}.${randomUUID()}.tmp`;
|
|
44582
|
+
try {
|
|
44583
|
+
await fs4.writeFile(temporary, JSON.stringify(records) + "\n", { mode: 384, flag: "wx" });
|
|
44584
|
+
await fs4.rename(temporary, this.file);
|
|
44585
|
+
} finally {
|
|
44586
|
+
await fs4.rm(temporary, { force: true });
|
|
44587
|
+
}
|
|
44381
44588
|
}
|
|
44382
44589
|
};
|
|
44383
|
-
function validRecord(value) {
|
|
44384
|
-
if (!value || typeof value !== "object") return false;
|
|
44385
|
-
const record3 = value;
|
|
44386
|
-
return typeof record3.piSessionId === "string" && typeof record3.acpSessionId === "string" && typeof record3.acpModelId === "string" && typeof record3.cwd === "string" && Number.isSafeInteger(record3.messageCount) && (record3.messageCount ?? -1) >= 0 && typeof record3.historyFingerprint === "string" && (record3.expectedAssistantFingerprint === void 0 || typeof record3.expectedAssistantFingerprint === "string") && typeof record3.lastActive === "number" && Number.isFinite(record3.lastActive);
|
|
44387
|
-
}
|
|
44388
44590
|
|
|
44389
44591
|
// node_modules/pi-antigravity-acp-provider/src/acp/events.ts
|
|
44390
44592
|
function mapSessionUpdate(notification) {
|
|
@@ -44451,22 +44653,22 @@ function clean(value) {
|
|
|
44451
44653
|
var import_unzipper = __toESM(require_unzip2(), 1);
|
|
44452
44654
|
import { execFile } from "node:child_process";
|
|
44453
44655
|
import { createHash } from "node:crypto";
|
|
44454
|
-
import
|
|
44656
|
+
import fs6 from "node:fs";
|
|
44455
44657
|
import os3 from "node:os";
|
|
44456
|
-
import
|
|
44658
|
+
import path6 from "node:path";
|
|
44457
44659
|
import { pipeline } from "node:stream/promises";
|
|
44458
44660
|
import { promisify } from "node:util";
|
|
44459
44661
|
|
|
44460
44662
|
// node_modules/pi-antigravity-acp-provider/src/acp/runtime-manifest.ts
|
|
44461
44663
|
import { verify } from "node:crypto";
|
|
44462
|
-
import
|
|
44664
|
+
import fs5 from "node:fs";
|
|
44463
44665
|
var MANIFEST_PUBLIC_KEY = `-----BEGIN PUBLIC KEY-----
|
|
44464
44666
|
MCowBQYDK2VwAyEAxmka3YjT7PpPic+rroqg9bhFbSmh79ZtMwlpGlwCDLA=
|
|
44465
44667
|
-----END PUBLIC KEY-----`;
|
|
44466
44668
|
var RUNTIME_MANIFEST_URL = "https://raw.githubusercontent.com/zacbemis/pi-antigravity-acp-provider/main/runtime-manifest.json";
|
|
44467
44669
|
var BUNDLED_RUNTIME_MANIFEST = new URL("../../runtime-manifest.json", __ompAssetURL("pi-antigravity-acp-provider/src/acp/runtime-manifest.ts"));
|
|
44468
44670
|
function readBundledRuntimeManifest() {
|
|
44469
|
-
return parseTrustedRuntimeManifest(
|
|
44671
|
+
return parseTrustedRuntimeManifest(fs5.readFileSync(BUNDLED_RUNTIME_MANIFEST, "utf8"));
|
|
44470
44672
|
}
|
|
44471
44673
|
function parseTrustedRuntimeManifest(text) {
|
|
44472
44674
|
let value;
|
|
@@ -44602,7 +44804,7 @@ async function ensureOnce(onProgress) {
|
|
|
44602
44804
|
} catch {
|
|
44603
44805
|
}
|
|
44604
44806
|
if (launch && launch.source !== "managed") return;
|
|
44605
|
-
if (launch) repairRuntimeExecutablePermissions(
|
|
44807
|
+
if (launch) repairRuntimeExecutablePermissions(path6.dirname(launch.command));
|
|
44606
44808
|
if (launch && loadConfig().runtimeUpdates !== "automatic") return;
|
|
44607
44809
|
let resolved;
|
|
44608
44810
|
try {
|
|
@@ -44612,7 +44814,7 @@ async function ensureOnce(onProgress) {
|
|
|
44612
44814
|
throw error62;
|
|
44613
44815
|
}
|
|
44614
44816
|
const { release } = resolved;
|
|
44615
|
-
const installedVersion = launch ? readInstallRecord(
|
|
44817
|
+
const installedVersion = launch ? readInstallRecord(path6.dirname(launch.command))?.version : void 0;
|
|
44616
44818
|
if (installedVersion && compareRuntimeVersions(installedVersion, release.version) >= 0) return;
|
|
44617
44819
|
await installRuntime(release, onProgress);
|
|
44618
44820
|
}
|
|
@@ -44687,14 +44889,14 @@ async function installRuntime(release, onProgress) {
|
|
|
44687
44889
|
return await withInstallLock(root, async () => {
|
|
44688
44890
|
adoptLegacyCurrentRelease(root, release);
|
|
44689
44891
|
const current = currentManagedRecord(root);
|
|
44690
|
-
if (current?.record.archiveSha256 === release.archiveSha256 && isInstalledRelease(
|
|
44892
|
+
if (current?.record.archiveSha256 === release.archiveSha256 && isInstalledRelease(path6.dirname(current.binary), release)) {
|
|
44691
44893
|
return { version: current.record.version, changed: false, binary: current.binary };
|
|
44692
44894
|
}
|
|
44693
44895
|
if (current && compareRuntimeVersions(current.record.version, release.version) > 0) {
|
|
44694
44896
|
return { version: current.record.version, changed: false, binary: current.binary };
|
|
44695
44897
|
}
|
|
44696
|
-
const destination =
|
|
44697
|
-
const binary =
|
|
44898
|
+
const destination = path6.join(root, "versions", release.archiveSha256);
|
|
44899
|
+
const binary = path6.join(destination, release.binaryName);
|
|
44698
44900
|
const destinationValid = isInstalledRelease(destination, release);
|
|
44699
44901
|
const changed = current?.record.archiveSha256 !== release.archiveSha256 || !destinationValid;
|
|
44700
44902
|
if (!destinationValid) await installRelease(destination, release, onProgress);
|
|
@@ -44711,27 +44913,27 @@ async function installRuntime(release, onProgress) {
|
|
|
44711
44913
|
}
|
|
44712
44914
|
}
|
|
44713
44915
|
async function installRelease(destination, release, onProgress) {
|
|
44714
|
-
const versions =
|
|
44715
|
-
|
|
44716
|
-
const staging =
|
|
44717
|
-
const archive =
|
|
44718
|
-
const runtime =
|
|
44719
|
-
|
|
44916
|
+
const versions = path6.dirname(destination);
|
|
44917
|
+
fs6.mkdirSync(versions, { recursive: true, mode: 448 });
|
|
44918
|
+
const staging = fs6.mkdtempSync(path6.join(versions, ".install-"));
|
|
44919
|
+
const archive = path6.join(staging, "download.zip");
|
|
44920
|
+
const runtime = path6.join(staging, "runtime");
|
|
44921
|
+
fs6.mkdirSync(runtime, { mode: 448 });
|
|
44720
44922
|
try {
|
|
44721
44923
|
onProgress?.("Downloading the Antigravity ACP server (this is a large download)\u2026");
|
|
44722
44924
|
const archiveSha256 = await download(release, archive, onProgress);
|
|
44723
44925
|
if (archiveSha256 !== release.archiveSha256) throw new Error("Antigravity ACP archive SHA-256 mismatch");
|
|
44724
44926
|
onProgress?.("Extracting the verified Antigravity ACP runtime\u2026");
|
|
44725
44927
|
await extractRuntimeArchive(archive, runtime, release);
|
|
44726
|
-
|
|
44928
|
+
fs6.rmSync(archive, { force: true });
|
|
44727
44929
|
if (process.platform !== "win32") {
|
|
44728
|
-
|
|
44729
|
-
|
|
44930
|
+
fs6.chmodSync(path6.join(runtime, release.binaryName), 493);
|
|
44931
|
+
fs6.chmodSync(path6.join(runtime, release.harnessName), 493);
|
|
44730
44932
|
}
|
|
44731
44933
|
if (process.platform === "darwin") {
|
|
44732
44934
|
await Promise.all(
|
|
44733
44935
|
[release.binaryName, release.harnessName].map(
|
|
44734
|
-
(name) => execFileAsync("xattr", ["-d", "com.apple.quarantine",
|
|
44936
|
+
(name) => execFileAsync("xattr", ["-d", "com.apple.quarantine", path6.join(runtime, name)]).catch(() => void 0)
|
|
44735
44937
|
)
|
|
44736
44938
|
);
|
|
44737
44939
|
}
|
|
@@ -44749,17 +44951,17 @@ async function installRelease(destination, release, onProgress) {
|
|
|
44749
44951
|
harnessBytes: release.harnessBytes,
|
|
44750
44952
|
installedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
44751
44953
|
};
|
|
44752
|
-
|
|
44954
|
+
fs6.writeFileSync(path6.join(runtime, "install-integrity.json"), `${JSON.stringify(record3, null, 2)}
|
|
44753
44955
|
`, {
|
|
44754
44956
|
mode: 384
|
|
44755
44957
|
});
|
|
44756
44958
|
try {
|
|
44757
|
-
|
|
44959
|
+
fs6.renameSync(runtime, destination);
|
|
44758
44960
|
} catch (error62) {
|
|
44759
44961
|
if (!isInstalledRelease(destination, release)) throw error62;
|
|
44760
44962
|
}
|
|
44761
44963
|
} finally {
|
|
44762
|
-
|
|
44964
|
+
fs6.rmSync(staging, { recursive: true, force: true });
|
|
44763
44965
|
}
|
|
44764
44966
|
}
|
|
44765
44967
|
async function extractRuntimeArchive(archivePath, destination, release) {
|
|
@@ -44771,8 +44973,8 @@ async function extractRuntimeArchive(archivePath, destination, release) {
|
|
|
44771
44973
|
]);
|
|
44772
44974
|
for (const entry of archive.files) {
|
|
44773
44975
|
const size = expected.get(entry.path);
|
|
44774
|
-
await pipeline(entry.stream(),
|
|
44775
|
-
if (
|
|
44976
|
+
await pipeline(entry.stream(), fs6.createWriteStream(path6.join(destination, entry.path), { flags: "wx", mode: 384 }));
|
|
44977
|
+
if (fs6.statSync(path6.join(destination, entry.path)).size !== size) {
|
|
44776
44978
|
throw new Error(`ACP archive file was truncated: ${entry.path}`);
|
|
44777
44979
|
}
|
|
44778
44980
|
}
|
|
@@ -44799,7 +45001,7 @@ function isExpectedRuntimeIdentity(initialized, releaseVersion) {
|
|
|
44799
45001
|
async function validateRuntime(directory, release) {
|
|
44800
45002
|
const connection = new AntigravityAcpConnection({
|
|
44801
45003
|
cwd: directory,
|
|
44802
|
-
command:
|
|
45004
|
+
command: path6.join(directory, release.binaryName),
|
|
44803
45005
|
args: release.args,
|
|
44804
45006
|
initializeTimeoutMs: VALIDATION_TIMEOUT_MS,
|
|
44805
45007
|
operationTimeoutMs: VALIDATION_TIMEOUT_MS
|
|
@@ -44832,19 +45034,19 @@ async function download(release, destination, onProgress) {
|
|
|
44832
45034
|
controller.enqueue(chunk);
|
|
44833
45035
|
}
|
|
44834
45036
|
});
|
|
44835
|
-
await pipeline(response.body.pipeThrough(progress),
|
|
45037
|
+
await pipeline(response.body.pipeThrough(progress), fs6.createWriteStream(destination, { mode: 384 }));
|
|
44836
45038
|
if (received !== release.archiveBytes) throw new Error("ACP server download size did not match its signed manifest");
|
|
44837
45039
|
return hash2.digest("hex");
|
|
44838
45040
|
}
|
|
44839
45041
|
function isInstalledRelease(directory, release) {
|
|
44840
45042
|
const record3 = readInstallRecord(directory);
|
|
44841
|
-
return record3?.version === release.version && record3.platform === release.platform && record3.archive === release.archive && record3.archiveSha256 === release.archiveSha256 && record3.archiveBytes === release.archiveBytes && record3.binaryName === release.binaryName && record3.binaryBytes === release.binaryBytes && record3.harnessName === release.harnessName && record3.harnessBytes === release.harnessBytes && validRuntimeFile(
|
|
45043
|
+
return record3?.version === release.version && record3.platform === release.platform && record3.archive === release.archive && record3.archiveSha256 === release.archiveSha256 && record3.archiveBytes === release.archiveBytes && record3.binaryName === release.binaryName && record3.binaryBytes === release.binaryBytes && record3.harnessName === release.harnessName && record3.harnessBytes === release.harnessBytes && validRuntimeFile(path6.join(directory, release.binaryName), release.binaryBytes) && validRuntimeFile(path6.join(directory, release.harnessName), release.harnessBytes);
|
|
44842
45044
|
}
|
|
44843
45045
|
function readInstallRecord(directory) {
|
|
44844
45046
|
try {
|
|
44845
|
-
const file2 =
|
|
44846
|
-
if (
|
|
44847
|
-
const value = JSON.parse(
|
|
45047
|
+
const file2 = path6.join(directory, "install-integrity.json");
|
|
45048
|
+
if (fs6.statSync(file2).size > 8 * 1024) return void 0;
|
|
45049
|
+
const value = JSON.parse(fs6.readFileSync(file2, "utf8"));
|
|
44848
45050
|
if (typeof value.version !== "string" || typeof value.platform !== "string" || typeof value.archiveSha256 !== "string" || typeof value.binaryName !== "string" || typeof value.harnessName !== "string") {
|
|
44849
45051
|
return void 0;
|
|
44850
45052
|
}
|
|
@@ -44855,11 +45057,11 @@ function readInstallRecord(directory) {
|
|
|
44855
45057
|
}
|
|
44856
45058
|
}
|
|
44857
45059
|
function adoptLegacyCurrentRelease(root, release) {
|
|
44858
|
-
const directory =
|
|
44859
|
-
const file2 =
|
|
45060
|
+
const directory = path6.join(root, "current");
|
|
45061
|
+
const file2 = path6.join(directory, "install-integrity.json");
|
|
44860
45062
|
try {
|
|
44861
|
-
const legacy = JSON.parse(
|
|
44862
|
-
if (legacy.version !== release.version || legacy.platform !== release.platform || legacy.archiveSha256 !== release.archiveSha256 || !validRuntimeFile(
|
|
45063
|
+
const legacy = JSON.parse(fs6.readFileSync(file2, "utf8"));
|
|
45064
|
+
if (legacy.version !== release.version || legacy.platform !== release.platform || legacy.archiveSha256 !== release.archiveSha256 || !validRuntimeFile(path6.join(directory, release.binaryName), release.binaryBytes) || !validRuntimeFile(path6.join(directory, release.harnessName), release.harnessBytes)) {
|
|
44863
45065
|
return;
|
|
44864
45066
|
}
|
|
44865
45067
|
const record3 = {
|
|
@@ -44875,24 +45077,24 @@ function adoptLegacyCurrentRelease(root, release) {
|
|
|
44875
45077
|
installedAt: typeof legacy.installedAt === "string" ? legacy.installedAt : (/* @__PURE__ */ new Date()).toISOString()
|
|
44876
45078
|
};
|
|
44877
45079
|
const temporary = `${file2}.${process.pid}.tmp`;
|
|
44878
|
-
|
|
45080
|
+
fs6.writeFileSync(temporary, `${JSON.stringify(record3, null, 2)}
|
|
44879
45081
|
`, { mode: 384 });
|
|
44880
|
-
|
|
45082
|
+
fs6.renameSync(temporary, file2);
|
|
44881
45083
|
} catch {
|
|
44882
45084
|
}
|
|
44883
45085
|
}
|
|
44884
45086
|
function currentManagedRecord(root) {
|
|
44885
|
-
const current =
|
|
45087
|
+
const current = path6.join(root, "current");
|
|
44886
45088
|
const record3 = readInstallRecord(current);
|
|
44887
45089
|
if (!record3) return void 0;
|
|
44888
|
-
const binary =
|
|
45090
|
+
const binary = path6.join(current, record3.binaryName);
|
|
44889
45091
|
return validRuntimeFile(binary, record3.binaryBytes) ? { record: record3, binary } : void 0;
|
|
44890
45092
|
}
|
|
44891
45093
|
function readCachedManifest() {
|
|
44892
45094
|
try {
|
|
44893
45095
|
const file2 = manifestCachePath();
|
|
44894
|
-
if (
|
|
44895
|
-
const value = JSON.parse(
|
|
45096
|
+
if (fs6.statSync(file2).size > 512 * 1024) return void 0;
|
|
45097
|
+
const value = JSON.parse(fs6.readFileSync(file2, "utf8"));
|
|
44896
45098
|
if (typeof value.checkedAt !== "number" || typeof value.manifest !== "string") return void 0;
|
|
44897
45099
|
return { checkedAt: value.checkedAt, manifest: parseTrustedRuntimeManifest(value.manifest) };
|
|
44898
45100
|
} catch {
|
|
@@ -44901,24 +45103,24 @@ function readCachedManifest() {
|
|
|
44901
45103
|
}
|
|
44902
45104
|
function writeCachedManifest(manifest) {
|
|
44903
45105
|
const file2 = manifestCachePath();
|
|
44904
|
-
|
|
45106
|
+
fs6.mkdirSync(path6.dirname(file2), { recursive: true, mode: 448 });
|
|
44905
45107
|
const temporary = `${file2}.${process.pid}.tmp`;
|
|
44906
|
-
|
|
45108
|
+
fs6.writeFileSync(
|
|
44907
45109
|
temporary,
|
|
44908
45110
|
`${JSON.stringify({ checkedAt: Date.now(), manifest: JSON.stringify(manifest) }, null, 2)}
|
|
44909
45111
|
`,
|
|
44910
45112
|
{ mode: 384 }
|
|
44911
45113
|
);
|
|
44912
|
-
|
|
45114
|
+
fs6.renameSync(temporary, file2);
|
|
44913
45115
|
}
|
|
44914
45116
|
function manifestCachePath() {
|
|
44915
|
-
return
|
|
45117
|
+
return path6.join(runtimeRoot(), "runtime-manifest-cache.json");
|
|
44916
45118
|
}
|
|
44917
45119
|
function readCachedOfficialRelease(key) {
|
|
44918
45120
|
try {
|
|
44919
45121
|
const file2 = officialCachePath(key);
|
|
44920
|
-
if (
|
|
44921
|
-
const value = JSON.parse(
|
|
45122
|
+
if (fs6.statSync(file2).size > 256 * 1024) return void 0;
|
|
45123
|
+
const value = JSON.parse(fs6.readFileSync(file2, "utf8"));
|
|
44922
45124
|
if (typeof value.checkedAt !== "number" || typeof value.release?.version !== "string" || typeof value.release.entry?.archive !== "string") {
|
|
44923
45125
|
return void 0;
|
|
44924
45126
|
}
|
|
@@ -44930,48 +45132,48 @@ function readCachedOfficialRelease(key) {
|
|
|
44930
45132
|
}
|
|
44931
45133
|
function writeCachedOfficialRelease(key, release) {
|
|
44932
45134
|
const file2 = officialCachePath(key);
|
|
44933
|
-
|
|
45135
|
+
fs6.mkdirSync(path6.dirname(file2), { recursive: true, mode: 448 });
|
|
44934
45136
|
const temporary = `${file2}.${process.pid}.tmp`;
|
|
44935
|
-
|
|
45137
|
+
fs6.writeFileSync(temporary, `${JSON.stringify({ checkedAt: Date.now(), release }, null, 2)}
|
|
44936
45138
|
`, { mode: 384 });
|
|
44937
|
-
|
|
45139
|
+
fs6.renameSync(temporary, file2);
|
|
44938
45140
|
}
|
|
44939
45141
|
function officialCachePath(key) {
|
|
44940
|
-
return
|
|
45142
|
+
return path6.join(runtimeRoot(), `official-registry-${key}.json`);
|
|
44941
45143
|
}
|
|
44942
45144
|
function runtimeRoot() {
|
|
44943
|
-
return
|
|
45145
|
+
return path6.join(os3.homedir(), ".local", "opt", "agy-acp");
|
|
44944
45146
|
}
|
|
44945
45147
|
async function withInstallLock(root, operation) {
|
|
44946
|
-
|
|
44947
|
-
const
|
|
45148
|
+
fs6.mkdirSync(root, { recursive: true, mode: 448 });
|
|
45149
|
+
const lock3 = path6.join(root, ".update-lock");
|
|
44948
45150
|
const deadline = Date.now() + INSTALL_TIMEOUT_MS;
|
|
44949
45151
|
for (; ; ) {
|
|
44950
45152
|
try {
|
|
44951
|
-
|
|
44952
|
-
|
|
45153
|
+
fs6.mkdirSync(lock3, { mode: 448 });
|
|
45154
|
+
fs6.writeFileSync(path6.join(lock3, "owner.json"), JSON.stringify({ pid: process.pid, createdAt: Date.now() }), {
|
|
44953
45155
|
mode: 384
|
|
44954
45156
|
});
|
|
44955
45157
|
break;
|
|
44956
45158
|
} catch (error62) {
|
|
44957
45159
|
if (error62.code !== "EEXIST") throw error62;
|
|
44958
|
-
if (isStaleLock(
|
|
44959
|
-
|
|
45160
|
+
if (isStaleLock(lock3)) {
|
|
45161
|
+
fs6.rmSync(lock3, { recursive: true, force: true });
|
|
44960
45162
|
continue;
|
|
44961
45163
|
}
|
|
44962
45164
|
if (Date.now() >= deadline) throw new Error("Timed out waiting for another ACP runtime update");
|
|
44963
|
-
await
|
|
45165
|
+
await delay3(LOCK_POLL_MS);
|
|
44964
45166
|
}
|
|
44965
45167
|
}
|
|
44966
45168
|
try {
|
|
44967
45169
|
return await operation();
|
|
44968
45170
|
} finally {
|
|
44969
|
-
|
|
45171
|
+
fs6.rmSync(lock3, { recursive: true, force: true });
|
|
44970
45172
|
}
|
|
44971
45173
|
}
|
|
44972
|
-
function isStaleLock(
|
|
45174
|
+
function isStaleLock(lock3) {
|
|
44973
45175
|
try {
|
|
44974
|
-
const value = JSON.parse(
|
|
45176
|
+
const value = JSON.parse(fs6.readFileSync(path6.join(lock3, "owner.json"), "utf8"));
|
|
44975
45177
|
if (typeof value.createdAt !== "number" || Date.now() - value.createdAt > LOCK_STALE_MS) return true;
|
|
44976
45178
|
if (typeof value.pid !== "number") return true;
|
|
44977
45179
|
try {
|
|
@@ -44982,7 +45184,7 @@ function isStaleLock(lock) {
|
|
|
44982
45184
|
}
|
|
44983
45185
|
} catch {
|
|
44984
45186
|
try {
|
|
44985
|
-
return Date.now() -
|
|
45187
|
+
return Date.now() - fs6.statSync(lock3).mtimeMs > LOCK_STALE_MS;
|
|
44986
45188
|
} catch {
|
|
44987
45189
|
return true;
|
|
44988
45190
|
}
|
|
@@ -44992,10 +45194,10 @@ function repairRuntimeExecutablePermissions(directory, platform = process.platfo
|
|
|
44992
45194
|
if (platform === "win32") return [];
|
|
44993
45195
|
const repaired = [];
|
|
44994
45196
|
for (const name of ["agy_acp_server.par", "localharness_external"]) {
|
|
44995
|
-
const file2 =
|
|
45197
|
+
const file2 = path6.join(directory, name);
|
|
44996
45198
|
let stat;
|
|
44997
45199
|
try {
|
|
44998
|
-
stat =
|
|
45200
|
+
stat = fs6.lstatSync(file2);
|
|
44999
45201
|
} catch (error62) {
|
|
45000
45202
|
if (error62.code === "ENOENT") {
|
|
45001
45203
|
throw new Error(`Managed ACP runtime payload is missing: ${name}`);
|
|
@@ -45006,38 +45208,38 @@ function repairRuntimeExecutablePermissions(directory, platform = process.platfo
|
|
|
45006
45208
|
const permissions = stat.mode & 511;
|
|
45007
45209
|
const executablePermissions = permissions | (permissions & 292) >> 2;
|
|
45008
45210
|
if (permissions !== executablePermissions) {
|
|
45009
|
-
|
|
45211
|
+
fs6.chmodSync(file2, executablePermissions);
|
|
45010
45212
|
repaired.push(name);
|
|
45011
45213
|
}
|
|
45012
45214
|
}
|
|
45013
45215
|
return repaired;
|
|
45014
45216
|
}
|
|
45015
45217
|
function pointCurrentAt(root, destination) {
|
|
45016
|
-
const current =
|
|
45017
|
-
const temporary =
|
|
45018
|
-
|
|
45019
|
-
|
|
45020
|
-
process.platform === "win32" ? destination :
|
|
45218
|
+
const current = path6.join(root, "current");
|
|
45219
|
+
const temporary = path6.join(root, `.current-${process.pid}`);
|
|
45220
|
+
fs6.rmSync(temporary, { recursive: true, force: true });
|
|
45221
|
+
fs6.symlinkSync(
|
|
45222
|
+
process.platform === "win32" ? destination : path6.relative(root, destination),
|
|
45021
45223
|
temporary,
|
|
45022
45224
|
process.platform === "win32" ? "junction" : "dir"
|
|
45023
45225
|
);
|
|
45024
|
-
|
|
45025
|
-
|
|
45226
|
+
fs6.rmSync(current, { recursive: true, force: true });
|
|
45227
|
+
fs6.renameSync(temporary, current);
|
|
45026
45228
|
}
|
|
45027
45229
|
function configureDefaultAuth() {
|
|
45028
45230
|
const directory = resolveAntigravityAcpDirectory();
|
|
45029
|
-
const settingsFile =
|
|
45030
|
-
const tokenFile =
|
|
45031
|
-
if (
|
|
45231
|
+
const settingsFile = path6.join(directory, "settings.json");
|
|
45232
|
+
const tokenFile = path6.join(directory, "acp_token.json");
|
|
45233
|
+
if (fs6.existsSync(tokenFile)) return;
|
|
45032
45234
|
let settings2 = {};
|
|
45033
45235
|
try {
|
|
45034
|
-
settings2 = JSON.parse(
|
|
45236
|
+
settings2 = JSON.parse(fs6.readFileSync(settingsFile, "utf8"));
|
|
45035
45237
|
if (settings2.auth && typeof settings2.auth === "object") return;
|
|
45036
45238
|
} catch {
|
|
45037
45239
|
}
|
|
45038
|
-
|
|
45240
|
+
fs6.mkdirSync(directory, { recursive: true, mode: 448 });
|
|
45039
45241
|
const type = process.env.GEMINI_API_KEY ? "gemini-api-key" : "oauth-personal";
|
|
45040
|
-
|
|
45242
|
+
fs6.writeFileSync(settingsFile, `${JSON.stringify({ ...settings2, auth: { type } }, null, 2)}
|
|
45041
45243
|
`, { mode: 384 });
|
|
45042
45244
|
}
|
|
45043
45245
|
function platformKey() {
|
|
@@ -45053,13 +45255,13 @@ function platformKey() {
|
|
|
45053
45255
|
}
|
|
45054
45256
|
function isMuslLinux() {
|
|
45055
45257
|
if (process.platform !== "linux") return false;
|
|
45056
|
-
if (
|
|
45258
|
+
if (fs6.existsSync("/etc/alpine-release")) return true;
|
|
45057
45259
|
const report = process.report?.getReport();
|
|
45058
45260
|
return !report?.header?.glibcVersionRuntime;
|
|
45059
45261
|
}
|
|
45060
45262
|
function validRuntimeFile(file2, bytes) {
|
|
45061
45263
|
try {
|
|
45062
|
-
const stat =
|
|
45264
|
+
const stat = fs6.statSync(file2);
|
|
45063
45265
|
return stat.isFile() && stat.size === bytes && (process.platform === "win32" || (stat.mode & 73) !== 0);
|
|
45064
45266
|
} catch {
|
|
45065
45267
|
return false;
|
|
@@ -45086,7 +45288,7 @@ async function readBoundedText(response, maxBytes) {
|
|
|
45086
45288
|
reader.releaseLock();
|
|
45087
45289
|
}
|
|
45088
45290
|
}
|
|
45089
|
-
function
|
|
45291
|
+
function delay3(ms) {
|
|
45090
45292
|
return new Promise((resolve) => {
|
|
45091
45293
|
const timer = setTimeout(resolve, ms);
|
|
45092
45294
|
timer.unref?.();
|
|
@@ -45094,9 +45296,9 @@ function delay2(ms) {
|
|
|
45094
45296
|
}
|
|
45095
45297
|
|
|
45096
45298
|
// node_modules/pi-antigravity-acp-provider/src/acp/headless-oauth.ts
|
|
45097
|
-
import
|
|
45299
|
+
import fs7 from "node:fs";
|
|
45098
45300
|
import os4 from "node:os";
|
|
45099
|
-
import
|
|
45301
|
+
import path7 from "node:path";
|
|
45100
45302
|
var CAPTURE_ENV = "PI_ANTIGRAVITY_OAUTH_CAPTURE_FILE";
|
|
45101
45303
|
var CAPTURE_TIMEOUT_MS = 3e4;
|
|
45102
45304
|
var MAX_CAPTURE_BYTES = 64 * 1024;
|
|
@@ -45109,11 +45311,11 @@ var HeadlessOAuthRelay = class {
|
|
|
45109
45311
|
if (process.platform === "win32") {
|
|
45110
45312
|
throw new Error("Manual Antigravity OAuth capture is not yet supported on Windows hosts");
|
|
45111
45313
|
}
|
|
45112
|
-
this.directory =
|
|
45113
|
-
|
|
45114
|
-
this.captureFile =
|
|
45115
|
-
const browser =
|
|
45116
|
-
|
|
45314
|
+
this.directory = fs7.mkdtempSync(path7.join(os4.tmpdir(), "pi-antigravity-oauth-"));
|
|
45315
|
+
fs7.chmodSync(this.directory, 448);
|
|
45316
|
+
this.captureFile = path7.join(this.directory, "authorization-url");
|
|
45317
|
+
const browser = path7.join(this.directory, "capture-browser");
|
|
45318
|
+
fs7.writeFileSync(
|
|
45117
45319
|
browser,
|
|
45118
45320
|
`#!/bin/sh
|
|
45119
45321
|
umask 077
|
|
@@ -45121,14 +45323,14 @@ printf '%s\\n' "$1" > "$${CAPTURE_ENV}"
|
|
|
45121
45323
|
`,
|
|
45122
45324
|
{ mode: 448 }
|
|
45123
45325
|
);
|
|
45124
|
-
const executable2 =
|
|
45125
|
-
|
|
45126
|
-
|
|
45326
|
+
const executable2 = path7.join(this.directory, "xdg-open");
|
|
45327
|
+
fs7.copyFileSync(browser, executable2);
|
|
45328
|
+
fs7.chmodSync(executable2, 448);
|
|
45127
45329
|
this.env = {
|
|
45128
45330
|
...baseEnv,
|
|
45129
45331
|
BROWSER: browser,
|
|
45130
45332
|
[CAPTURE_ENV]: this.captureFile,
|
|
45131
|
-
PATH: `${this.directory}${
|
|
45333
|
+
PATH: `${this.directory}${path7.delimiter}${baseEnv.PATH ?? ""}`
|
|
45132
45334
|
};
|
|
45133
45335
|
}
|
|
45134
45336
|
async waitForAuthorization(signal) {
|
|
@@ -45137,11 +45339,11 @@ printf '%s\\n' "$1" > "$${CAPTURE_ENV}"
|
|
|
45137
45339
|
if (this.disposed) throw new Error("Antigravity OAuth relay was closed");
|
|
45138
45340
|
if (signal?.aborted) throw abortReason(signal);
|
|
45139
45341
|
try {
|
|
45140
|
-
const stat =
|
|
45342
|
+
const stat = fs7.lstatSync(this.captureFile);
|
|
45141
45343
|
if (!stat.isFile() || stat.size > MAX_CAPTURE_BYTES) {
|
|
45142
45344
|
throw new Error("Antigravity OAuth browser capture produced an invalid file");
|
|
45143
45345
|
}
|
|
45144
|
-
const text =
|
|
45346
|
+
const text = fs7.readFileSync(this.captureFile, "utf8").trim();
|
|
45145
45347
|
if (text) return parseAuthorization(text);
|
|
45146
45348
|
} catch (error62) {
|
|
45147
45349
|
if (error62.code !== "ENOENT") throw error62;
|
|
@@ -45149,7 +45351,7 @@ printf '%s\\n' "$1" > "$${CAPTURE_ENV}"
|
|
|
45149
45351
|
if (Date.now() >= deadline) {
|
|
45150
45352
|
throw new Error("Antigravity did not provide an OAuth URL within 30 seconds");
|
|
45151
45353
|
}
|
|
45152
|
-
await
|
|
45354
|
+
await delay4(100, signal);
|
|
45153
45355
|
}
|
|
45154
45356
|
}
|
|
45155
45357
|
async forwardCallback(input2, authorization, signal) {
|
|
@@ -45174,7 +45376,7 @@ printf '%s\\n' "$1" > "$${CAPTURE_ENV}"
|
|
|
45174
45376
|
dispose() {
|
|
45175
45377
|
if (this.disposed) return;
|
|
45176
45378
|
this.disposed = true;
|
|
45177
|
-
|
|
45379
|
+
fs7.rmSync(this.directory, { recursive: true, force: true });
|
|
45178
45380
|
}
|
|
45179
45381
|
};
|
|
45180
45382
|
function shouldUseHeadlessOAuth(environment = process.env, platform = process.platform) {
|
|
@@ -45230,7 +45432,7 @@ function validateLoopback(url2) {
|
|
|
45230
45432
|
throw new Error("Antigravity OAuth redirect is not a valid loopback URL");
|
|
45231
45433
|
}
|
|
45232
45434
|
}
|
|
45233
|
-
function
|
|
45435
|
+
function delay4(ms, signal) {
|
|
45234
45436
|
return new Promise((resolve, reject) => {
|
|
45235
45437
|
if (signal?.aborted) {
|
|
45236
45438
|
reject(abortReason(signal));
|
|
@@ -52105,39 +52307,39 @@ function IsLeapYear(year) {
|
|
|
52105
52307
|
return year % 4 === 0 && (year % 100 !== 0 || year % 400 === 0);
|
|
52106
52308
|
}
|
|
52107
52309
|
function IsDate2(value) {
|
|
52108
|
-
const
|
|
52109
|
-
if (!
|
|
52310
|
+
const matches2 = DATE.exec(value);
|
|
52311
|
+
if (!matches2)
|
|
52110
52312
|
return false;
|
|
52111
|
-
const year = +
|
|
52112
|
-
const month = +
|
|
52113
|
-
const day = +
|
|
52313
|
+
const year = +matches2[1];
|
|
52314
|
+
const month = +matches2[2];
|
|
52315
|
+
const day = +matches2[3];
|
|
52114
52316
|
return month >= 1 && month <= 12 && day >= 1 && day <= (month === 2 && IsLeapYear(year) ? 29 : DAYS[month]);
|
|
52115
52317
|
}
|
|
52116
52318
|
|
|
52117
52319
|
// node_modules/typebox/build/format/time.mjs
|
|
52118
52320
|
var TIME = /^(\d\d):(\d\d):(\d\d)(?:\.\d+)?(?:([Zz])|([+-])(\d\d):(\d\d))?$/;
|
|
52119
52321
|
function IsTime(value, strictTimeZone = true) {
|
|
52120
|
-
const
|
|
52121
|
-
if (!
|
|
52322
|
+
const matches2 = TIME.exec(value);
|
|
52323
|
+
if (!matches2)
|
|
52122
52324
|
return false;
|
|
52123
|
-
if (strictTimeZone && !
|
|
52325
|
+
if (strictTimeZone && !matches2[4] && !matches2[5])
|
|
52124
52326
|
return false;
|
|
52125
|
-
const hr = +
|
|
52126
|
-
const min = +
|
|
52127
|
-
const sec = +
|
|
52327
|
+
const hr = +matches2[1];
|
|
52328
|
+
const min = +matches2[2];
|
|
52329
|
+
const sec = +matches2[3];
|
|
52128
52330
|
if (hr > 23 || min > 59 || sec > 60)
|
|
52129
52331
|
return false;
|
|
52130
|
-
if (
|
|
52131
|
-
const tzH2 = +
|
|
52132
|
-
const tzM2 = +
|
|
52332
|
+
if (matches2[5]) {
|
|
52333
|
+
const tzH2 = +matches2[6];
|
|
52334
|
+
const tzM2 = +matches2[7];
|
|
52133
52335
|
if (tzH2 > 23 || tzM2 > 59)
|
|
52134
52336
|
return false;
|
|
52135
52337
|
}
|
|
52136
52338
|
if (sec < 60)
|
|
52137
52339
|
return true;
|
|
52138
|
-
const tzSign =
|
|
52139
|
-
const tzH = +(
|
|
52140
|
-
const tzM = +(
|
|
52340
|
+
const tzSign = matches2[5] === "-" ? -1 : 1;
|
|
52341
|
+
const tzH = +(matches2[6] || 0);
|
|
52342
|
+
const tzM = +(matches2[7] || 0);
|
|
52141
52343
|
const totalUtcMin = hr * 60 + min - tzSign * (tzH * 60 + tzM);
|
|
52142
52344
|
return (totalUtcMin % 1440 + 1440) % 1440 === 1439;
|
|
52143
52345
|
}
|
|
@@ -52989,8 +53191,8 @@ function CheckTypeName(_stack, _context, type, _schema, value) {
|
|
|
52989
53191
|
)
|
|
52990
53192
|
);
|
|
52991
53193
|
}
|
|
52992
|
-
function CheckTypeNames(stack, context,
|
|
52993
|
-
return guard_exports.Some(
|
|
53194
|
+
function CheckTypeNames(stack, context, types4, schema, value) {
|
|
53195
|
+
return guard_exports.Some(types4, (type) => CheckTypeName(stack, context, type, schema, value));
|
|
52994
53196
|
}
|
|
52995
53197
|
function CheckType(stack, context, schema, value) {
|
|
52996
53198
|
return guard_exports.IsArray(schema.type) ? CheckTypeNames(stack, context, schema.type, schema, value) : CheckTypeName(stack, context, schema.type, schema, value);
|
|
@@ -53759,8 +53961,8 @@ function IsEnum2(value) {
|
|
|
53759
53961
|
}
|
|
53760
53962
|
|
|
53761
53963
|
// node_modules/typebox/build/type/types/intersect.mjs
|
|
53762
|
-
function Intersect(
|
|
53763
|
-
return memory_exports.Create({ "~kind": "Intersect" }, { allOf:
|
|
53964
|
+
function Intersect(types4, options = {}) {
|
|
53965
|
+
return memory_exports.Create({ "~kind": "Intersect" }, { allOf: types4 }, options);
|
|
53764
53966
|
}
|
|
53765
53967
|
function IsIntersect(value) {
|
|
53766
53968
|
return IsKind(value, "Intersect");
|
|
@@ -53993,18 +54195,18 @@ function ParsePatternIntoTypes(pattern) {
|
|
|
53993
54195
|
function FromLiteral(_value) {
|
|
53994
54196
|
return true;
|
|
53995
54197
|
}
|
|
53996
|
-
function FromTypesReduce(
|
|
53997
|
-
return guard_exports.ShiftLeft(
|
|
54198
|
+
function FromTypesReduce(types4) {
|
|
54199
|
+
return guard_exports.ShiftLeft(types4, (left, right) => FromType(left) ? FromTypesReduce(right) : false, () => true);
|
|
53998
54200
|
}
|
|
53999
|
-
function FromTypes(
|
|
54000
|
-
const result = guard_exports.IsEqual(
|
|
54201
|
+
function FromTypes(types4) {
|
|
54202
|
+
const result = guard_exports.IsEqual(types4.length, 0) ? false : FromTypesReduce(types4);
|
|
54001
54203
|
return result;
|
|
54002
54204
|
}
|
|
54003
54205
|
function FromType(type) {
|
|
54004
54206
|
return IsUnion(type) ? FromTypes(type.anyOf) : IsLiteral(type) ? FromLiteral(type.const) : false;
|
|
54005
54207
|
}
|
|
54006
|
-
function IsTemplateLiteralFinite(
|
|
54007
|
-
const result = FromTypes(
|
|
54208
|
+
function IsTemplateLiteralFinite(types4) {
|
|
54209
|
+
const result = FromTypes(types4);
|
|
54008
54210
|
return result;
|
|
54009
54211
|
}
|
|
54010
54212
|
|
|
@@ -54020,34 +54222,34 @@ function FromLiteralPush(variants, value, result = []) {
|
|
|
54020
54222
|
function FromLiteral2(variants, value) {
|
|
54021
54223
|
return guard_exports.IsEqual(variants.length, 0) ? [`${value}`] : FromLiteralPush(variants, value);
|
|
54022
54224
|
}
|
|
54023
|
-
function FromUnion(variants,
|
|
54024
|
-
return guard_exports.ShiftLeft(
|
|
54225
|
+
function FromUnion(variants, types4, result = []) {
|
|
54226
|
+
return guard_exports.ShiftLeft(types4, (left, right) => FromUnion(variants, right, [...result, ...FromType2(variants, left)]), () => result);
|
|
54025
54227
|
}
|
|
54026
54228
|
function FromType2(variants, type) {
|
|
54027
54229
|
const result = IsUnion(type) ? FromUnion(variants, type.anyOf) : IsLiteral(type) ? FromLiteral2(variants, type.const) : Unreachable();
|
|
54028
54230
|
return result;
|
|
54029
54231
|
}
|
|
54030
|
-
function DecodeFromSpan(variants,
|
|
54031
|
-
return guard_exports.ShiftLeft(
|
|
54232
|
+
function DecodeFromSpan(variants, types4) {
|
|
54233
|
+
return guard_exports.ShiftLeft(types4, (left, right) => DecodeFromSpan(FromType2(variants, left), right), () => variants);
|
|
54032
54234
|
}
|
|
54033
54235
|
function VariantsToLiterals(variants) {
|
|
54034
54236
|
return variants.map((variant) => Literal(variant));
|
|
54035
54237
|
}
|
|
54036
|
-
function DecodeTypesAsUnion(
|
|
54037
|
-
const variants = DecodeFromSpan([],
|
|
54238
|
+
function DecodeTypesAsUnion(types4) {
|
|
54239
|
+
const variants = DecodeFromSpan([], types4);
|
|
54038
54240
|
const literals = VariantsToLiterals(variants);
|
|
54039
54241
|
const result = Union(literals);
|
|
54040
54242
|
return result;
|
|
54041
54243
|
}
|
|
54042
|
-
function DecodeTypes(
|
|
54043
|
-
return guard_exports.IsEqual(
|
|
54244
|
+
function DecodeTypes(types4) {
|
|
54245
|
+
return guard_exports.IsEqual(types4.length, 0) ? Unreachable() : (
|
|
54044
54246
|
// Literal('') :
|
|
54045
|
-
guard_exports.IsEqual(
|
|
54247
|
+
guard_exports.IsEqual(types4.length, 1) && IsLiteral(types4[0]) ? types4[0] : DecodeTypesAsUnion(types4)
|
|
54046
54248
|
);
|
|
54047
54249
|
}
|
|
54048
54250
|
function TemplateLiteralDecodeUnsafe(pattern) {
|
|
54049
|
-
const
|
|
54050
|
-
const result = guard_exports.IsEqual(
|
|
54251
|
+
const types4 = ParsePatternIntoTypes(pattern);
|
|
54252
|
+
const result = guard_exports.IsEqual(types4.length, 0) ? String2() : IsTemplateLiteralFinite(types4) ? DecodeTypes(types4) : TemplateLiteralCreate(pattern);
|
|
54051
54253
|
return result;
|
|
54052
54254
|
}
|
|
54053
54255
|
function TemplateLiteralDecode(pattern) {
|
|
@@ -54074,8 +54276,8 @@ function FromBooleanKey(value) {
|
|
|
54074
54276
|
}
|
|
54075
54277
|
|
|
54076
54278
|
// node_modules/typebox/build/type/types/tuple.mjs
|
|
54077
|
-
function Tuple(
|
|
54078
|
-
const [items, minItems, additionalItems] = [
|
|
54279
|
+
function Tuple(types4, options = {}) {
|
|
54280
|
+
const [items, minItems, additionalItems] = [types4, types4.length, false];
|
|
54079
54281
|
return memory_exports.Create({ ["~kind"]: "Tuple" }, { type: "array", additionalItems, items, minItems }, options);
|
|
54080
54282
|
}
|
|
54081
54283
|
function IsTuple(value) {
|
|
@@ -54128,8 +54330,8 @@ function RemoveOptional(type, options = {}) {
|
|
|
54128
54330
|
}
|
|
54129
54331
|
|
|
54130
54332
|
// node_modules/typebox/build/type/engine/tuple/to_object.mjs
|
|
54131
|
-
function TupleElementsToProperties(
|
|
54132
|
-
const result =
|
|
54333
|
+
function TupleElementsToProperties(types4) {
|
|
54334
|
+
const result = types4.reduceRight((result2, right, index) => {
|
|
54133
54335
|
return { [index]: right, ...result2 };
|
|
54134
54336
|
}, {});
|
|
54135
54337
|
return result;
|
|
@@ -54205,14 +54407,14 @@ function DistributeOperation(left, right) {
|
|
|
54205
54407
|
const result = shouldEvaluate ? EvaluateIntersect([evaluatedLeft, evaluatedRight]) : Narrow(evaluatedLeft, evaluatedRight);
|
|
54206
54408
|
return result;
|
|
54207
54409
|
}
|
|
54208
|
-
function DistributeType(type,
|
|
54209
|
-
return guard_exports.ShiftLeft(
|
|
54410
|
+
function DistributeType(type, types4, result = []) {
|
|
54411
|
+
return guard_exports.ShiftLeft(types4, (left, right) => DistributeType(type, right, [...result, DistributeOperation(left, type)]), () => guard_exports.IsEqual(result.length, 0) ? [type] : result);
|
|
54210
54412
|
}
|
|
54211
|
-
function DistributeUnion(
|
|
54212
|
-
return guard_exports.ShiftLeft(
|
|
54413
|
+
function DistributeUnion(types4, distribution, result = []) {
|
|
54414
|
+
return guard_exports.ShiftLeft(types4, (left, right) => DistributeUnion(right, distribution, [...result, ...Distribute([left], distribution)]), () => result);
|
|
54213
54415
|
}
|
|
54214
|
-
function Distribute(
|
|
54215
|
-
return guard_exports.ShiftLeft(
|
|
54416
|
+
function Distribute(types4, result = []) {
|
|
54417
|
+
return guard_exports.ShiftLeft(types4, (left, right) => IsUnion(left) ? Distribute(right, DistributeUnion(left.anyOf, result)) : Distribute(right, DistributeType(left, result)), () => result);
|
|
54216
54418
|
}
|
|
54217
54419
|
|
|
54218
54420
|
// node_modules/typebox/build/type/engine/exclude/operation.mjs
|
|
@@ -54242,8 +54444,8 @@ function EvaluateDependent(if_, then_, else_) {
|
|
|
54242
54444
|
function EvaluateEnum(values, result = []) {
|
|
54243
54445
|
return guard_exports.ShiftLeft(values, (left, right) => EvaluateEnum(right, [...result, Literal(left)]), () => EvaluateUnion(result));
|
|
54244
54446
|
}
|
|
54245
|
-
function EvaluateIntersect(
|
|
54246
|
-
const distribution = Distribute(
|
|
54447
|
+
function EvaluateIntersect(types4) {
|
|
54448
|
+
const distribution = Distribute(types4);
|
|
54247
54449
|
const broadend = Broaden(distribution);
|
|
54248
54450
|
const result = EvaluateUnion(broadend);
|
|
54249
54451
|
return result;
|
|
@@ -54253,8 +54455,8 @@ function EvaluateTemplateLiteral(pattern) {
|
|
|
54253
54455
|
const result = EvaluateType(evaluated);
|
|
54254
54456
|
return result;
|
|
54255
54457
|
}
|
|
54256
|
-
function EvaluateUnion(
|
|
54257
|
-
const broadend = Broaden(
|
|
54458
|
+
function EvaluateUnion(types4) {
|
|
54459
|
+
const broadend = Broaden(types4);
|
|
54258
54460
|
const result = EvaluateUnionFast(broadend);
|
|
54259
54461
|
return result;
|
|
54260
54462
|
}
|
|
@@ -54262,8 +54464,8 @@ function EvaluateType(type) {
|
|
|
54262
54464
|
const result = IsDependent(type) ? EvaluateDependent(type.if, type.then, type.else) : IsEnum2(type) ? EvaluateEnum(type.enum) : IsIntersect(type) ? EvaluateIntersect(type.allOf) : IsTemplateLiteral(type) ? EvaluateTemplateLiteral(type.pattern) : IsUnion(type) ? EvaluateUnion(type.anyOf) : type;
|
|
54263
54465
|
return result;
|
|
54264
54466
|
}
|
|
54265
|
-
function EvaluateUnionFast(
|
|
54266
|
-
const result = guard_exports.IsEqual(
|
|
54467
|
+
function EvaluateUnionFast(types4) {
|
|
54468
|
+
const result = guard_exports.IsEqual(types4.length, 1) ? types4[0] : guard_exports.IsEqual(types4.length, 0) ? Never() : Union(types4);
|
|
54267
54469
|
return result;
|
|
54268
54470
|
}
|
|
54269
54471
|
|
|
@@ -54281,8 +54483,8 @@ function FromIntegerKey(_key, value) {
|
|
|
54281
54483
|
}
|
|
54282
54484
|
|
|
54283
54485
|
// node_modules/typebox/build/type/engine/record/from_key_intersect.mjs
|
|
54284
|
-
function FromIntersectKey(
|
|
54285
|
-
const evaluatedKey = EvaluateIntersect(
|
|
54486
|
+
function FromIntersectKey(types4, value) {
|
|
54487
|
+
const evaluatedKey = EvaluateIntersect(types4);
|
|
54286
54488
|
const result = FromKey(evaluatedKey, value);
|
|
54287
54489
|
return result;
|
|
54288
54490
|
}
|
|
@@ -54305,8 +54507,8 @@ function FromStringKey(key, value) {
|
|
|
54305
54507
|
|
|
54306
54508
|
// node_modules/typebox/build/type/engine/record/from_key_template_literal.mjs
|
|
54307
54509
|
function FromTemplateKey(pattern, value) {
|
|
54308
|
-
const
|
|
54309
|
-
const finite = IsTemplateLiteralFinite(
|
|
54510
|
+
const types4 = ParsePatternIntoTypes(pattern);
|
|
54511
|
+
const finite = IsTemplateLiteralFinite(types4);
|
|
54310
54512
|
const result = finite ? FromKey(EvaluateTemplateLiteral(pattern), value) : CreateRecord(pattern, value);
|
|
54311
54513
|
return result;
|
|
54312
54514
|
}
|
|
@@ -54316,29 +54518,29 @@ function FlattenType(type) {
|
|
|
54316
54518
|
const result = IsUnion(type) ? Flatten(type.anyOf) : [type];
|
|
54317
54519
|
return result;
|
|
54318
54520
|
}
|
|
54319
|
-
function Flatten(
|
|
54320
|
-
return guard_exports.ShiftLeft(
|
|
54521
|
+
function Flatten(types4, result = []) {
|
|
54522
|
+
return guard_exports.ShiftLeft(types4, (left, right) => Flatten(right, [...result, ...FlattenType(left)]), () => result);
|
|
54321
54523
|
}
|
|
54322
54524
|
|
|
54323
54525
|
// node_modules/typebox/build/type/engine/record/from_key_union.mjs
|
|
54324
|
-
function StringOrNumberCheck(
|
|
54325
|
-
return
|
|
54526
|
+
function StringOrNumberCheck(types4) {
|
|
54527
|
+
return types4.some((type) => IsString3(type) || IsNumber3(type) || IsInteger2(type));
|
|
54326
54528
|
}
|
|
54327
|
-
function TryBuildRecord(
|
|
54328
|
-
return guard_exports.IsEqual(StringOrNumberCheck(
|
|
54529
|
+
function TryBuildRecord(types4, value) {
|
|
54530
|
+
return guard_exports.IsEqual(StringOrNumberCheck(types4), true) ? CreateRecord(StringKey, value) : void 0;
|
|
54329
54531
|
}
|
|
54330
|
-
function CreateProperties(
|
|
54331
|
-
return
|
|
54532
|
+
function CreateProperties(types4, value) {
|
|
54533
|
+
return types4.reduce((result, left) => {
|
|
54332
54534
|
return IsLiteral(left) && (guard_exports.IsString(left.const) || guard_exports.IsNumber(left.const)) ? { ...result, [left.const]: value } : result;
|
|
54333
54535
|
}, {});
|
|
54334
54536
|
}
|
|
54335
|
-
function CreateObject(
|
|
54336
|
-
const properties = CreateProperties(
|
|
54537
|
+
function CreateObject(types4, value) {
|
|
54538
|
+
const properties = CreateProperties(types4, value);
|
|
54337
54539
|
const result = _Object_(properties);
|
|
54338
54540
|
return result;
|
|
54339
54541
|
}
|
|
54340
|
-
function FromUnionKey(
|
|
54341
|
-
const flattened = Flatten(
|
|
54542
|
+
function FromUnionKey(types4, value) {
|
|
54543
|
+
const flattened = Flatten(types4);
|
|
54342
54544
|
const record3 = TryBuildRecord(flattened, value);
|
|
54343
54545
|
return IsSchema2(record3) ? record3 : CreateObject(flattened, value);
|
|
54344
54546
|
}
|
|
@@ -55293,8 +55495,8 @@ function EncodeString(right, pattern) {
|
|
|
55293
55495
|
function EncodeTemplateLiteral(templatePattern, right, pattern) {
|
|
55294
55496
|
return EncodeTypes(right, `${pattern}${UnwrapTemplateLiteralPattern(templatePattern)}`);
|
|
55295
55497
|
}
|
|
55296
|
-
function EncodeTemplateLiteralDeferred(
|
|
55297
|
-
const templateLiteral2 = TemplateLiteralAction(
|
|
55498
|
+
function EncodeTemplateLiteralDeferred(types4, right, pattern) {
|
|
55499
|
+
const templateLiteral2 = TemplateLiteralAction(types4, {});
|
|
55298
55500
|
const result = EncodeType(templateLiteral2, right, pattern);
|
|
55299
55501
|
return result;
|
|
55300
55502
|
}
|
|
@@ -55302,49 +55504,49 @@ function EncodeEnum(values, right, pattern) {
|
|
|
55302
55504
|
const evaluated = EvaluateEnum(values);
|
|
55303
55505
|
return EncodeType(evaluated, right, pattern);
|
|
55304
55506
|
}
|
|
55305
|
-
function EncodeUnion(
|
|
55306
|
-
return guard_exports.ShiftLeft(
|
|
55507
|
+
function EncodeUnion(types4, right, pattern, result = []) {
|
|
55508
|
+
return guard_exports.ShiftLeft(types4, (head, tail) => EncodeUnion(tail, right, pattern, [...result, EncodeType(head, [], "")]), () => EncodeTypes(right, `${pattern}(${JoinString(result)})`));
|
|
55307
55509
|
}
|
|
55308
55510
|
function EncodeType(type, right, pattern) {
|
|
55309
55511
|
return IsEnum2(type) ? EncodeEnum(type.enum, right, pattern) : IsInteger2(type) ? EncodeInteger(right, pattern) : IsLiteral(type) ? EncodeLiteral(type.const, right, pattern) : IsBigInt2(type) ? EncodeBigInt(right, pattern) : IsBoolean3(type) ? EncodeBoolean(right, pattern) : IsNumber3(type) ? EncodeNumber(right, pattern) : IsString3(type) ? EncodeString(right, pattern) : IsTemplateLiteral(type) ? EncodeTemplateLiteral(type.pattern, right, pattern) : IsTemplateLiteralDeferred(type) ? EncodeTemplateLiteralDeferred(type.parameters[0], right, pattern) : IsUnion(type) ? EncodeUnion(type.anyOf, right, pattern) : NeverPattern;
|
|
55310
55512
|
}
|
|
55311
|
-
function EncodeTypes(
|
|
55312
|
-
return guard_exports.ShiftLeft(
|
|
55513
|
+
function EncodeTypes(types4, pattern) {
|
|
55514
|
+
return guard_exports.ShiftLeft(types4, (left, right) => EncodeType(left, right, pattern), () => pattern);
|
|
55313
55515
|
}
|
|
55314
|
-
function EncodePattern(
|
|
55315
|
-
const encoded = EncodeTypes(
|
|
55516
|
+
function EncodePattern(types4) {
|
|
55517
|
+
const encoded = EncodeTypes(types4, "");
|
|
55316
55518
|
const result = `^${encoded}$`;
|
|
55317
55519
|
return result;
|
|
55318
55520
|
}
|
|
55319
|
-
function TemplateLiteralEncode(
|
|
55320
|
-
const pattern = EncodePattern(
|
|
55521
|
+
function TemplateLiteralEncode(types4) {
|
|
55522
|
+
const pattern = EncodePattern(types4);
|
|
55321
55523
|
const result = TemplateLiteralCreate(pattern);
|
|
55322
55524
|
return result;
|
|
55323
55525
|
}
|
|
55324
55526
|
|
|
55325
55527
|
// node_modules/typebox/build/type/engine/template_literal/instantiate.mjs
|
|
55326
|
-
function TemplateLiteralAction(
|
|
55327
|
-
const result = CanInstantiate(
|
|
55528
|
+
function TemplateLiteralAction(types4, options) {
|
|
55529
|
+
const result = CanInstantiate(types4) ? memory_exports.Update(TemplateLiteralEncode(types4), {}, options) : TemplateLiteralDeferred(types4, options);
|
|
55328
55530
|
return result;
|
|
55329
55531
|
}
|
|
55330
|
-
function TemplateLiteralInstantiate(context, state,
|
|
55331
|
-
const instantiatedTypes = InstantiateTypes(context, state,
|
|
55532
|
+
function TemplateLiteralInstantiate(context, state, types4, options) {
|
|
55533
|
+
const instantiatedTypes = InstantiateTypes(context, state, types4);
|
|
55332
55534
|
return TemplateLiteralAction(instantiatedTypes, options);
|
|
55333
55535
|
}
|
|
55334
55536
|
|
|
55335
55537
|
// node_modules/typebox/build/type/types/template_literal.mjs
|
|
55336
|
-
function TemplateLiteralDeferred(
|
|
55337
|
-
return Deferred("TemplateLiteral", [
|
|
55538
|
+
function TemplateLiteralDeferred(types4, options = {}) {
|
|
55539
|
+
return Deferred("TemplateLiteral", [types4], options);
|
|
55338
55540
|
}
|
|
55339
55541
|
function IsTemplateLiteralDeferred(value) {
|
|
55340
55542
|
return IsSchema2(value) && guard_exports.HasPropertyKey(value, "action") && guard_exports.IsEqual(value.action, "TemplateLiteral");
|
|
55341
55543
|
}
|
|
55342
|
-
function TemplateLiteralFromTypes(
|
|
55343
|
-
return TemplateLiteralAction(
|
|
55544
|
+
function TemplateLiteralFromTypes(types4) {
|
|
55545
|
+
return TemplateLiteralAction(types4, {});
|
|
55344
55546
|
}
|
|
55345
55547
|
function TemplateLiteralFromString(template) {
|
|
55346
|
-
const
|
|
55347
|
-
return TemplateLiteralFromTypes(
|
|
55548
|
+
const types4 = ParseTemplateIntoTypes(template);
|
|
55549
|
+
return TemplateLiteralFromTypes(types4);
|
|
55348
55550
|
}
|
|
55349
55551
|
function TemplateLiteral2(input2, options = {}) {
|
|
55350
55552
|
const type = guard_exports.IsString(input2) ? TemplateLiteralFromString(input2) : TemplateLiteralFromTypes(input2);
|
|
@@ -55644,14 +55846,14 @@ function InferUnionResult(inferred, name, left, right) {
|
|
|
55644
55846
|
}
|
|
55645
55847
|
|
|
55646
55848
|
// node_modules/typebox/build/type/extends/tuple.mjs
|
|
55647
|
-
function Reverse(
|
|
55648
|
-
return [...
|
|
55849
|
+
function Reverse(types4) {
|
|
55850
|
+
return [...types4].reverse();
|
|
55649
55851
|
}
|
|
55650
|
-
function ApplyReverse(
|
|
55651
|
-
return reversed ? Reverse(
|
|
55852
|
+
function ApplyReverse(types4, reversed) {
|
|
55853
|
+
return reversed ? Reverse(types4) : types4;
|
|
55652
55854
|
}
|
|
55653
|
-
function Reversed(
|
|
55654
|
-
const first =
|
|
55855
|
+
function Reversed(types4) {
|
|
55856
|
+
const first = types4.length > 0 ? types4[0] : void 0;
|
|
55655
55857
|
const inferrable = IsSchema2(first) ? TryRestInferable(first) : void 0;
|
|
55656
55858
|
return IsSchema2(inferrable);
|
|
55657
55859
|
}
|
|
@@ -55757,11 +55959,11 @@ function FromRef(stack, context, ref) {
|
|
|
55757
55959
|
return stack.includes(ref) ? true : FromType3([...stack, ref], context, context[ref]);
|
|
55758
55960
|
}
|
|
55759
55961
|
function FromProperties(stack, context, properties) {
|
|
55760
|
-
const
|
|
55761
|
-
return FromTypes2(stack, context,
|
|
55962
|
+
const types4 = PropertyValues(properties);
|
|
55963
|
+
return FromTypes2(stack, context, types4);
|
|
55762
55964
|
}
|
|
55763
|
-
function FromTypes2(stack, context,
|
|
55764
|
-
return guard_exports.ShiftLeft(
|
|
55965
|
+
function FromTypes2(stack, context, types4) {
|
|
55966
|
+
return guard_exports.ShiftLeft(types4, (left, right) => FromType3(stack, context, left) ? true : FromTypes2(stack, context, right), () => false);
|
|
55765
55967
|
}
|
|
55766
55968
|
function FromType3(stack, context, type) {
|
|
55767
55969
|
return IsRef2(type) ? FromRef(stack, context, type.$ref) : IsArray2(type) ? FromType3(stack, context, type.items) : IsConstructor2(type) ? FromTypes2(stack, context, [...type.parameters, type.instanceType]) : IsFunction2(type) ? FromTypes2(stack, context, [...type.parameters, type.returnType]) : IsInterfaceDeferred(type) ? FromProperties(stack, context, type.parameters[1]) : IsIntersect(type) ? FromTypes2(stack, context, type.allOf) : IsObject2(type) ? FromProperties(stack, context, type.properties) : IsUnion(type) ? FromTypes2(stack, context, type.anyOf) : IsTuple(type) ? FromTypes2(stack, context, type.items) : IsRecord(type) ? FromType3(stack, context, RecordValue(type)) : false;
|
|
@@ -55788,11 +55990,11 @@ function FromRef2(context, ref, result) {
|
|
|
55788
55990
|
return result.includes(ref) ? result : ref in context ? FromType4(context, context[ref], [...result, ref]) : Unreachable();
|
|
55789
55991
|
}
|
|
55790
55992
|
function FromProperties2(context, properties, result) {
|
|
55791
|
-
const
|
|
55792
|
-
return FromTypes3(context,
|
|
55993
|
+
const types4 = PropertyValues(properties);
|
|
55994
|
+
return FromTypes3(context, types4, result);
|
|
55793
55995
|
}
|
|
55794
|
-
function FromTypes3(context,
|
|
55795
|
-
return
|
|
55996
|
+
function FromTypes3(context, types4, result) {
|
|
55997
|
+
return types4.reduce((result2, left) => {
|
|
55796
55998
|
return FromType4(context, left, result2);
|
|
55797
55999
|
}, result);
|
|
55798
56000
|
}
|
|
@@ -55813,8 +56015,8 @@ function FromProperties3(properties) {
|
|
|
55813
56015
|
return { ...result, [key]: FromType5(properties[key]) };
|
|
55814
56016
|
}, {});
|
|
55815
56017
|
}
|
|
55816
|
-
function FromTypes4(
|
|
55817
|
-
return
|
|
56018
|
+
function FromTypes4(types4) {
|
|
56019
|
+
return types4.reduce((result, left) => {
|
|
55818
56020
|
return [...result, FromType5(left)];
|
|
55819
56021
|
}, []);
|
|
55820
56022
|
}
|
|
@@ -55880,33 +56082,33 @@ function Compare(left, right) {
|
|
|
55880
56082
|
}
|
|
55881
56083
|
|
|
55882
56084
|
// node_modules/typebox/build/type/engine/evaluate/broaden.mjs
|
|
55883
|
-
function BroadenFilter(type,
|
|
55884
|
-
return guard_exports.ShiftLeft(
|
|
56085
|
+
function BroadenFilter(type, types4, result = [], all = types4) {
|
|
56086
|
+
return guard_exports.ShiftLeft(types4, (left, right) => {
|
|
55885
56087
|
const compare = Compare(type, left);
|
|
55886
56088
|
return guard_exports.IsEqual(compare, CompareResultLeftInside) || guard_exports.IsEqual(compare, CompareResultEqual) ? all : guard_exports.IsEqual(compare, CompareResultDisjoint) ? BroadenFilter(type, right, [...result, left], all) : BroadenFilter(type, right, result, all);
|
|
55887
56089
|
}, () => [...result, type]);
|
|
55888
56090
|
}
|
|
55889
|
-
function BroadenType(type,
|
|
56091
|
+
function BroadenType(type, types4, result) {
|
|
55890
56092
|
const evaluated = EvaluateType(type);
|
|
55891
56093
|
return IsAny(evaluated) ? [evaluated] : (
|
|
55892
56094
|
// terminate (always the most broad)
|
|
55893
56095
|
IsUnknown(evaluated) ? [evaluated] : (
|
|
55894
56096
|
// terminate (always the most broad)
|
|
55895
|
-
IsNever(evaluated) ? BroadenTypes(
|
|
56097
|
+
IsNever(evaluated) ? BroadenTypes(types4, result) : (
|
|
55896
56098
|
// ignored: never is dropped
|
|
55897
|
-
IsObject2(evaluated) ? BroadenTypes(
|
|
56099
|
+
IsObject2(evaluated) ? BroadenTypes(types4, [...result, evaluated]) : (
|
|
55898
56100
|
// objects are always considered (too expensive to compare)
|
|
55899
|
-
BroadenTypes(
|
|
56101
|
+
BroadenTypes(types4, BroadenFilter(evaluated, result))
|
|
55900
56102
|
)
|
|
55901
56103
|
)
|
|
55902
56104
|
)
|
|
55903
56105
|
);
|
|
55904
56106
|
}
|
|
55905
|
-
function BroadenTypes(
|
|
55906
|
-
return guard_exports.ShiftLeft(
|
|
56107
|
+
function BroadenTypes(types4, result = []) {
|
|
56108
|
+
return guard_exports.ShiftLeft(types4, (left, right) => BroadenType(left, right, result), () => result);
|
|
55907
56109
|
}
|
|
55908
|
-
function Broaden(
|
|
55909
|
-
const broadened = BroadenTypes(
|
|
56110
|
+
function Broaden(types4) {
|
|
56111
|
+
const broadened = BroadenTypes(types4);
|
|
55910
56112
|
const flattened = Flatten(broadened);
|
|
55911
56113
|
return flattened;
|
|
55912
56114
|
}
|
|
@@ -56104,8 +56306,8 @@ function FromTemplateLiteral(mapping, pattern) {
|
|
|
56104
56306
|
}
|
|
56105
56307
|
|
|
56106
56308
|
// node_modules/typebox/build/type/engine/intrinsics/from_union.mjs
|
|
56107
|
-
function FromUnion2(mapping,
|
|
56108
|
-
const result =
|
|
56309
|
+
function FromUnion2(mapping, types4) {
|
|
56310
|
+
const result = types4.map((type) => FromType7(mapping, type));
|
|
56109
56311
|
return Union(result);
|
|
56110
56312
|
}
|
|
56111
56313
|
|
|
@@ -56333,8 +56535,8 @@ function CollapseIntersectProperties(left, right) {
|
|
|
56333
56535
|
const shared = memory_exports.Assign(unique, sharedProperties);
|
|
56334
56536
|
return shared;
|
|
56335
56537
|
}
|
|
56336
|
-
function FromIntersect(
|
|
56337
|
-
return
|
|
56538
|
+
function FromIntersect(types4) {
|
|
56539
|
+
return types4.reduce((result, left) => {
|
|
56338
56540
|
return CollapseIntersectProperties(result, FromType8(left));
|
|
56339
56541
|
}, {});
|
|
56340
56542
|
}
|
|
@@ -56345,8 +56547,8 @@ function FromObject4(properties) {
|
|
|
56345
56547
|
}
|
|
56346
56548
|
|
|
56347
56549
|
// node_modules/typebox/build/type/engine/object/from_tuple.mjs
|
|
56348
|
-
function FromTuple(
|
|
56349
|
-
const object3 = TupleToObject(Tuple(
|
|
56550
|
+
function FromTuple(types4) {
|
|
56551
|
+
const object3 = TupleToObject(Tuple(types4));
|
|
56350
56552
|
const result = FromType8(object3);
|
|
56351
56553
|
return result;
|
|
56352
56554
|
}
|
|
@@ -56359,11 +56561,11 @@ function CollapseUnionProperties(left, right) {
|
|
|
56359
56561
|
}, {});
|
|
56360
56562
|
return result;
|
|
56361
56563
|
}
|
|
56362
|
-
function ReduceVariants(
|
|
56363
|
-
return guard_exports.ShiftLeft(
|
|
56564
|
+
function ReduceVariants(types4, result) {
|
|
56565
|
+
return guard_exports.ShiftLeft(types4, (left, right) => ReduceVariants(right, CollapseUnionProperties(result, FromType8(left))), () => result);
|
|
56364
56566
|
}
|
|
56365
|
-
function FromUnion3(
|
|
56366
|
-
return guard_exports.ShiftLeft(
|
|
56567
|
+
function FromUnion3(types4) {
|
|
56568
|
+
return guard_exports.ShiftLeft(types4, (left, right) => ReduceVariants(right, FromType8(left)), () => Unreachable());
|
|
56367
56569
|
}
|
|
56368
56570
|
|
|
56369
56571
|
// node_modules/typebox/build/type/engine/object/from_type.mjs
|
|
@@ -56389,8 +56591,8 @@ function ConvertToIntegerKey(value) {
|
|
|
56389
56591
|
function NormalizeLiteral(value) {
|
|
56390
56592
|
return Literal(ConvertToIntegerKey(value));
|
|
56391
56593
|
}
|
|
56392
|
-
function NormalizeIndexerTypes(
|
|
56393
|
-
return
|
|
56594
|
+
function NormalizeIndexerTypes(types4) {
|
|
56595
|
+
return types4.map((type) => NormalizeIndexer(type));
|
|
56394
56596
|
}
|
|
56395
56597
|
function NormalizeIndexer(type) {
|
|
56396
56598
|
return IsIntersect(type) ? Intersect(NormalizeIndexerTypes(type.allOf)) : IsUnion(type) ? Union(NormalizeIndexerTypes(type.anyOf)) : IsLiteral(type) ? NormalizeLiteral(type.const) : type;
|
|
@@ -56427,8 +56629,8 @@ function FromEnum(values) {
|
|
|
56427
56629
|
}
|
|
56428
56630
|
|
|
56429
56631
|
// node_modules/typebox/build/type/engine/indexable/from_intersect.mjs
|
|
56430
|
-
function FromIntersect2(
|
|
56431
|
-
const evaluated = EvaluateIntersect(
|
|
56632
|
+
function FromIntersect2(types4) {
|
|
56633
|
+
const evaluated = EvaluateIntersect(types4);
|
|
56432
56634
|
const result = FromType9(evaluated);
|
|
56433
56635
|
return result;
|
|
56434
56636
|
}
|
|
@@ -56447,8 +56649,8 @@ function FromTemplateLiteral2(pattern) {
|
|
|
56447
56649
|
}
|
|
56448
56650
|
|
|
56449
56651
|
// node_modules/typebox/build/type/engine/indexable/from_union.mjs
|
|
56450
|
-
function FromUnion4(
|
|
56451
|
-
return
|
|
56652
|
+
function FromUnion4(types4) {
|
|
56653
|
+
return types4.reduce((result, left) => {
|
|
56452
56654
|
return [...result, ...FromType9(left)];
|
|
56453
56655
|
}, []);
|
|
56454
56656
|
}
|
|
@@ -56465,8 +56667,8 @@ function ToIndexableKeys(type) {
|
|
|
56465
56667
|
}
|
|
56466
56668
|
|
|
56467
56669
|
// node_modules/typebox/build/type/engine/this/expand_this.mjs
|
|
56468
|
-
function FromTypes5(properties,
|
|
56469
|
-
return
|
|
56670
|
+
function FromTypes5(properties, types4) {
|
|
56671
|
+
return types4.map((type) => FromType10(properties, type));
|
|
56470
56672
|
}
|
|
56471
56673
|
function FromType10(properties, type) {
|
|
56472
56674
|
return IsArray2(type) ? _Array_(FromType10(properties, type.items)) : IsConstructor2(type) ? Constructor(FromTypes5(properties, type.parameters), FromType10(properties, type.instanceType)) : IsFunction2(type) ? _Function_(FromTypes5(properties, type.parameters), FromType10(properties, type.returnType)) : IsTuple(type) ? Tuple(FromTypes5(properties, type.items)) : IsUnion(type) ? Union(FromTypes5(properties, type.anyOf)) : IsIntersect(type) ? Intersect(FromTypes5(properties, type.allOf)) : IsThis(type) ? _Object_(properties) : type;
|
|
@@ -56514,32 +56716,32 @@ function FromObject5(properties, indexer) {
|
|
|
56514
56716
|
function ConvertLiteral(value) {
|
|
56515
56717
|
return Literal(ConvertToIntegerKey(value));
|
|
56516
56718
|
}
|
|
56517
|
-
function ArrayIndexerTypes(
|
|
56518
|
-
return
|
|
56719
|
+
function ArrayIndexerTypes(types4) {
|
|
56720
|
+
return types4.map((type) => FormatArrayIndexer(type));
|
|
56519
56721
|
}
|
|
56520
56722
|
function FormatArrayIndexer(type) {
|
|
56521
56723
|
return IsIntersect(type) ? Intersect(ArrayIndexerTypes(type.allOf)) : IsUnion(type) ? Union(ArrayIndexerTypes(type.anyOf)) : IsLiteral(type) ? ConvertLiteral(type.const) : type;
|
|
56522
56724
|
}
|
|
56523
56725
|
|
|
56524
56726
|
// node_modules/typebox/build/type/engine/indexed/from_tuple.mjs
|
|
56525
|
-
function IndexElementsWithIndexer(
|
|
56526
|
-
return
|
|
56727
|
+
function IndexElementsWithIndexer(types4, indexer) {
|
|
56728
|
+
return types4.reduceRight((result, right, index) => {
|
|
56527
56729
|
const check2 = Extends({}, Literal(index), indexer);
|
|
56528
56730
|
return result_exports.IsExtendsTrueLike(check2) ? [right, ...result] : result;
|
|
56529
56731
|
}, []);
|
|
56530
56732
|
}
|
|
56531
|
-
function FromTupleWithIndexer(
|
|
56733
|
+
function FromTupleWithIndexer(types4, indexer) {
|
|
56532
56734
|
const formattedArrayIndexer = FormatArrayIndexer(indexer);
|
|
56533
|
-
const elements = IndexElementsWithIndexer(
|
|
56735
|
+
const elements = IndexElementsWithIndexer(types4, formattedArrayIndexer);
|
|
56534
56736
|
return EvaluateUnionFast(elements);
|
|
56535
56737
|
}
|
|
56536
|
-
function FromTupleWithoutIndexer(
|
|
56537
|
-
return EvaluateUnionFast(
|
|
56738
|
+
function FromTupleWithoutIndexer(types4) {
|
|
56739
|
+
return EvaluateUnionFast(types4);
|
|
56538
56740
|
}
|
|
56539
|
-
function FromTuple2(
|
|
56741
|
+
function FromTuple2(types4, indexer) {
|
|
56540
56742
|
return (
|
|
56541
56743
|
// length (intrinsic)
|
|
56542
|
-
IsLiteral(indexer) && guard_exports.IsEqual(indexer.const, "length") ? Literal(
|
|
56744
|
+
IsLiteral(indexer) && guard_exports.IsEqual(indexer.const, "length") ? Literal(types4.length) : IsNumber3(indexer) || IsInteger2(indexer) ? FromTupleWithoutIndexer(types4) : FromTupleWithIndexer(types4, indexer)
|
|
56543
56745
|
);
|
|
56544
56746
|
}
|
|
56545
56747
|
|
|
@@ -56622,8 +56824,8 @@ function FromRecord2(type) {
|
|
|
56622
56824
|
}
|
|
56623
56825
|
|
|
56624
56826
|
// node_modules/typebox/build/type/engine/keyof/from_tuple.mjs
|
|
56625
|
-
function FromTuple3(
|
|
56626
|
-
const result =
|
|
56827
|
+
function FromTuple3(types4) {
|
|
56828
|
+
const result = types4.map((_, index) => Literal(index));
|
|
56627
56829
|
return EvaluateUnionFast(result);
|
|
56628
56830
|
}
|
|
56629
56831
|
|
|
@@ -56659,8 +56861,8 @@ function FromTemplateLiteral3(pattern) {
|
|
|
56659
56861
|
const result = FromType13(evaluated);
|
|
56660
56862
|
return result;
|
|
56661
56863
|
}
|
|
56662
|
-
function FromUnion5(
|
|
56663
|
-
return
|
|
56864
|
+
function FromUnion5(types4) {
|
|
56865
|
+
return types4.reduce((result, left) => {
|
|
56664
56866
|
return [...result, ...FromType13(left)];
|
|
56665
56867
|
}, []);
|
|
56666
56868
|
}
|
|
@@ -56861,15 +57063,15 @@ function FromDependent3(if_, then_, else_) {
|
|
|
56861
57063
|
}
|
|
56862
57064
|
|
|
56863
57065
|
// node_modules/typebox/build/type/engine/partial/from_intersect.mjs
|
|
56864
|
-
function FromIntersect3(
|
|
56865
|
-
const evaluated = EvaluateIntersect(
|
|
57066
|
+
function FromIntersect3(types4) {
|
|
57067
|
+
const evaluated = EvaluateIntersect(types4);
|
|
56866
57068
|
const result = FromType15(evaluated);
|
|
56867
57069
|
return result;
|
|
56868
57070
|
}
|
|
56869
57071
|
|
|
56870
57072
|
// node_modules/typebox/build/type/engine/partial/from_union.mjs
|
|
56871
|
-
function FromUnion6(
|
|
56872
|
-
const result =
|
|
57073
|
+
function FromUnion6(types4) {
|
|
57074
|
+
const result = types4.map((type) => FromType15(type));
|
|
56873
57075
|
return Union(result);
|
|
56874
57076
|
}
|
|
56875
57077
|
|
|
@@ -56963,8 +57165,8 @@ function FromDependent4(if_, then_, else_) {
|
|
|
56963
57165
|
}
|
|
56964
57166
|
|
|
56965
57167
|
// node_modules/typebox/build/type/engine/readonly_object/from_intersect.mjs
|
|
56966
|
-
function FromIntersect4(
|
|
56967
|
-
const evaluated = EvaluateIntersect(
|
|
57168
|
+
function FromIntersect4(types4) {
|
|
57169
|
+
const evaluated = EvaluateIntersect(types4);
|
|
56968
57170
|
const result = FromType17(evaluated);
|
|
56969
57171
|
return result;
|
|
56970
57172
|
}
|
|
@@ -56979,14 +57181,14 @@ function FromObject8(properties) {
|
|
|
56979
57181
|
}
|
|
56980
57182
|
|
|
56981
57183
|
// node_modules/typebox/build/type/engine/readonly_object/from_tuple.mjs
|
|
56982
|
-
function FromTuple4(
|
|
56983
|
-
const result = AddImmutable(Tuple(
|
|
57184
|
+
function FromTuple4(types4) {
|
|
57185
|
+
const result = AddImmutable(Tuple(types4));
|
|
56984
57186
|
return result;
|
|
56985
57187
|
}
|
|
56986
57188
|
|
|
56987
57189
|
// node_modules/typebox/build/type/engine/readonly_object/from_union.mjs
|
|
56988
|
-
function FromUnion7(
|
|
56989
|
-
const result =
|
|
57190
|
+
function FromUnion7(types4) {
|
|
57191
|
+
const result = types4.map((type) => FromType17(type));
|
|
56990
57192
|
return Union(result);
|
|
56991
57193
|
}
|
|
56992
57194
|
|
|
@@ -57026,15 +57228,15 @@ function FromDependent5(if_, then_, else_) {
|
|
|
57026
57228
|
}
|
|
57027
57229
|
|
|
57028
57230
|
// node_modules/typebox/build/type/engine/required/from_intersect.mjs
|
|
57029
|
-
function FromIntersect5(
|
|
57030
|
-
const evaluated = EvaluateIntersect(
|
|
57231
|
+
function FromIntersect5(types4) {
|
|
57232
|
+
const evaluated = EvaluateIntersect(types4);
|
|
57031
57233
|
const result = FromType18(evaluated);
|
|
57032
57234
|
return result;
|
|
57033
57235
|
}
|
|
57034
57236
|
|
|
57035
57237
|
// node_modules/typebox/build/type/engine/required/from_union.mjs
|
|
57036
|
-
function FromUnion8(
|
|
57037
|
-
const result =
|
|
57238
|
+
function FromUnion8(types4) {
|
|
57239
|
+
const result = types4.map((type) => FromType18(type));
|
|
57038
57240
|
return Union(result);
|
|
57039
57241
|
}
|
|
57040
57242
|
|
|
@@ -57114,8 +57316,8 @@ function SpreadElement(type) {
|
|
|
57114
57316
|
const result = IsRest(type) ? IsTuple(type.items) ? RestSpread(type.items.items) : IsInfer(type.items) ? [type] : IsRef2(type.items) ? [type] : [Never()] : [type];
|
|
57115
57317
|
return result;
|
|
57116
57318
|
}
|
|
57117
|
-
function RestSpread(
|
|
57118
|
-
const result =
|
|
57319
|
+
function RestSpread(types4) {
|
|
57320
|
+
const result = types4.reduce((result2, left) => {
|
|
57119
57321
|
return [...result2, ...SpreadElement(left)];
|
|
57120
57322
|
}, []);
|
|
57121
57323
|
return result;
|
|
@@ -57125,21 +57327,21 @@ function RestSpread(types2) {
|
|
|
57125
57327
|
function State(callstack, visited2) {
|
|
57126
57328
|
return { callstack, visited: visited2 };
|
|
57127
57329
|
}
|
|
57128
|
-
function CanInstantiate(
|
|
57129
|
-
return guard_exports.ShiftLeft(
|
|
57330
|
+
function CanInstantiate(types4) {
|
|
57331
|
+
return guard_exports.ShiftLeft(types4, (left, right) => IsRef2(left) ? false : CanInstantiate(right), () => true);
|
|
57130
57332
|
}
|
|
57131
57333
|
function InstantiateProperties(context, state, properties) {
|
|
57132
57334
|
return guard_exports.Keys(properties).reduce((result, key) => {
|
|
57133
57335
|
return { ...result, [key]: InstantiateType(context, state, properties[key]) };
|
|
57134
57336
|
}, {});
|
|
57135
57337
|
}
|
|
57136
|
-
function InstantiateElements(context, state,
|
|
57137
|
-
const elements = InstantiateTypes(context, state,
|
|
57338
|
+
function InstantiateElements(context, state, types4) {
|
|
57339
|
+
const elements = InstantiateTypes(context, state, types4);
|
|
57138
57340
|
const result = RestSpread(elements);
|
|
57139
57341
|
return result;
|
|
57140
57342
|
}
|
|
57141
|
-
function InstantiateTypes(context, state,
|
|
57142
|
-
return
|
|
57343
|
+
function InstantiateTypes(context, state, types4) {
|
|
57344
|
+
return types4.map((type) => InstantiateType(context, state, type));
|
|
57143
57345
|
}
|
|
57144
57346
|
function WithModifiers(type, instantiatedType) {
|
|
57145
57347
|
const withOptional = IsOptional(type) ? AddOptionalAction(instantiatedType, {}) : instantiatedType;
|
|
@@ -57211,14 +57413,14 @@ function Comparer(left, right) {
|
|
|
57211
57413
|
const compareResult = Compare(left, right);
|
|
57212
57414
|
return guard_exports.IsEqual(compareResult, CompareResultRightInside) ? 1 : guard_exports.IsEqual(compareResult, CompareResultDisjoint) ? 1 : 0;
|
|
57213
57415
|
}
|
|
57214
|
-
function Insert(type,
|
|
57215
|
-
return guard_exports.ShiftLeft(
|
|
57416
|
+
function Insert(type, types4, result = []) {
|
|
57417
|
+
return guard_exports.ShiftLeft(types4, (left, right) => guard_exports.IsEqual(Comparer(type, left), 1) ? Insert(type, right, [...result, left]) : [...result, type, ...types4], () => [...result, type]);
|
|
57216
57418
|
}
|
|
57217
|
-
function Sort(
|
|
57218
|
-
return guard_exports.ShiftLeft(
|
|
57419
|
+
function Sort(types4, result = []) {
|
|
57420
|
+
return guard_exports.ShiftLeft(types4, (left, right) => Sort(right, Insert(left, result)), () => result);
|
|
57219
57421
|
}
|
|
57220
|
-
function Priority(
|
|
57221
|
-
const result = Sort(
|
|
57422
|
+
function Priority(types4) {
|
|
57423
|
+
const result = Sort(types4);
|
|
57222
57424
|
return result;
|
|
57223
57425
|
}
|
|
57224
57426
|
|
|
@@ -57365,11 +57567,11 @@ function FromProperties4(properties) {
|
|
|
57365
57567
|
function FromRecordKey(type) {
|
|
57366
57568
|
return String2({ pattern: RecordPattern(type) });
|
|
57367
57569
|
}
|
|
57368
|
-
function FromPriorityTypes(
|
|
57369
|
-
return FromTypes6(Priority(
|
|
57570
|
+
function FromPriorityTypes(types4) {
|
|
57571
|
+
return FromTypes6(Priority(types4));
|
|
57370
57572
|
}
|
|
57371
|
-
function FromTypes6(
|
|
57372
|
-
return
|
|
57573
|
+
function FromTypes6(types4) {
|
|
57574
|
+
return types4.map((type) => FromType20(type));
|
|
57373
57575
|
}
|
|
57374
57576
|
function FromType20(type) {
|
|
57375
57577
|
const next = IsArray2(type) ? _Array_(FromType20(type.items), ArrayOptions(type)) : IsIntersect(type) ? Intersect(FromTypes6(type.allOf)) : IsUnion(type) ? Union(FromPriorityTypes(type.anyOf)) : IsObject2(type) ? _Object_(FromProperties4(type.properties)) : IsRecord(type) ? Record(FromRecordKey(type), FromType20(RecordValue(type))) : IsTuple(type) ? Tuple(FromTypes6(type.items)) : type;
|
|
@@ -58736,7 +58938,7 @@ __export(value_exports, {
|
|
|
58736
58938
|
});
|
|
58737
58939
|
|
|
58738
58940
|
// node_modules/pi-antigravity-acp-provider/src/mcp/schema.ts
|
|
58739
|
-
import { types } from "node:util";
|
|
58941
|
+
import { types as types3 } from "node:util";
|
|
58740
58942
|
var SCHEMA_LIMIT = 64 * 1024;
|
|
58741
58943
|
var MAX_SCHEMA_WORK = 1e5;
|
|
58742
58944
|
var MAX_SCHEMA_DEPTH = 16;
|
|
@@ -58766,7 +58968,7 @@ function scalarChars(value) {
|
|
|
58766
58968
|
return typeof value === "string" ? value.length + 2 : String(value).length;
|
|
58767
58969
|
}
|
|
58768
58970
|
function snapshotArray(value, budget) {
|
|
58769
|
-
if (
|
|
58971
|
+
if (types3.isProxy(value)) return "unsupported_keyword";
|
|
58770
58972
|
if (!Array.isArray(value)) return "invalid_keyword_value";
|
|
58771
58973
|
if (Object.getPrototypeOf(value) !== Array.prototype) return "unsupported_keyword";
|
|
58772
58974
|
if (Object.getOwnPropertySymbols(value).length > 0) return "unsupported_keyword";
|
|
@@ -58821,7 +59023,7 @@ function plainEntries(value, budget) {
|
|
|
58821
59023
|
function sanitizeSchema(value, depth, budget) {
|
|
58822
59024
|
if (depth > MAX_SCHEMA_DEPTH) return { reason: "too_deep" };
|
|
58823
59025
|
if (!value || typeof value !== "object") return { reason: "invalid_keyword_value" };
|
|
58824
|
-
if (
|
|
59026
|
+
if (types3.isProxy(value)) return { reason: "unsupported_keyword" };
|
|
58825
59027
|
if (Array.isArray(value)) return { reason: "invalid_keyword_value" };
|
|
58826
59028
|
if (budget.ancestors.has(value)) return { reason: "cyclic_schema" };
|
|
58827
59029
|
spend(budget, 1, 2);
|
|
@@ -58854,7 +59056,7 @@ function sanitizeNode(value, depth, budget) {
|
|
|
58854
59056
|
continue;
|
|
58855
59057
|
}
|
|
58856
59058
|
if (key === "properties") {
|
|
58857
|
-
if (
|
|
59059
|
+
if (types3.isProxy(candidate)) return { reason: "unsupported_keyword" };
|
|
58858
59060
|
if (!candidate || typeof candidate !== "object" || Array.isArray(candidate)) {
|
|
58859
59061
|
return { reason: "invalid_keyword_value" };
|
|
58860
59062
|
}
|
|
@@ -58895,9 +59097,9 @@ function sanitizeNode(value, depth, budget) {
|
|
|
58895
59097
|
}
|
|
58896
59098
|
let list;
|
|
58897
59099
|
if (key === "enum" || key === "required" || key === "type" && typeof candidate === "object" && candidate !== null) {
|
|
58898
|
-
const
|
|
58899
|
-
if (typeof
|
|
58900
|
-
list =
|
|
59100
|
+
const snapshot2 = snapshotArray(candidate, budget);
|
|
59101
|
+
if (typeof snapshot2 === "string") return { reason: snapshot2 };
|
|
59102
|
+
list = snapshot2;
|
|
58901
59103
|
}
|
|
58902
59104
|
let valid;
|
|
58903
59105
|
if (STRING_KEYS.has(key)) valid = typeof candidate === "string";
|
|
@@ -59094,23 +59296,23 @@ function toolError(text) {
|
|
|
59094
59296
|
}
|
|
59095
59297
|
|
|
59096
59298
|
// extension/fs-atomic.ts
|
|
59097
|
-
import
|
|
59098
|
-
import
|
|
59099
|
-
import { randomUUID } from "node:crypto";
|
|
59299
|
+
import fs8 from "node:fs";
|
|
59300
|
+
import path8 from "node:path";
|
|
59301
|
+
import { randomUUID as randomUUID2 } from "node:crypto";
|
|
59100
59302
|
function isMissingFileError(error62) {
|
|
59101
59303
|
return Boolean(error62 && typeof error62 === "object" && "code" in error62 && error62.code === "ENOENT");
|
|
59102
59304
|
}
|
|
59103
59305
|
function writeJsonAtomic(file2, value, pretty = true) {
|
|
59104
|
-
|
|
59105
|
-
const temporary = `${file2}.${
|
|
59306
|
+
fs8.mkdirSync(path8.dirname(file2), { recursive: true, mode: 448 });
|
|
59307
|
+
const temporary = `${file2}.${randomUUID2()}.tmp`;
|
|
59106
59308
|
try {
|
|
59107
59309
|
const serialized = pretty ? `${JSON.stringify(value, null, 2)}
|
|
59108
59310
|
` : `${JSON.stringify(value)}
|
|
59109
59311
|
`;
|
|
59110
|
-
|
|
59111
|
-
|
|
59312
|
+
fs8.writeFileSync(temporary, serialized, { mode: 384 });
|
|
59313
|
+
fs8.renameSync(temporary, file2);
|
|
59112
59314
|
} finally {
|
|
59113
|
-
|
|
59315
|
+
fs8.rmSync(temporary, { force: true });
|
|
59114
59316
|
}
|
|
59115
59317
|
}
|
|
59116
59318
|
|
|
@@ -59138,6 +59340,18 @@ function estimateTransferTokens(text, images = 0, utf8Bytes = Buffer.byteLength(
|
|
|
59138
59340
|
}
|
|
59139
59341
|
|
|
59140
59342
|
// extension/context-transfer.ts
|
|
59343
|
+
var ACP_STEP_TEXT_BYTES = 188e3;
|
|
59344
|
+
function promptTextBytes(prompt) {
|
|
59345
|
+
let bytes = 0;
|
|
59346
|
+
for (const block of prompt) {
|
|
59347
|
+
if (block.type === "text") bytes += Buffer.byteLength(block.text ?? "", "utf8") + 2;
|
|
59348
|
+
else if (block.type === "resource" && block.resource) {
|
|
59349
|
+
bytes += Buffer.byteLength(`Embedded resource (${block.resource.uri}):
|
|
59350
|
+
${block.resource.text}`, "utf8") + 2;
|
|
59351
|
+
}
|
|
59352
|
+
}
|
|
59353
|
+
return bytes;
|
|
59354
|
+
}
|
|
59141
59355
|
function currentSystemInstructions(context) {
|
|
59142
59356
|
const prompt = getCurrentSystemPrompt(context.messages) || context.systemPrompt || "";
|
|
59143
59357
|
if (Buffer.byteLength(prompt, "utf8") > 134217728) throw new Error("OMP system instructions exceed the 128 MiB hard transfer ceiling; reduce them rather than truncating instructions");
|
|
@@ -59237,6 +59451,10 @@ ${instructions}` : "";
|
|
|
59237
59451
|
const bytes = instructionsBytes + historyBytes + tailBytes + imageWireChars + imageCount * 10;
|
|
59238
59452
|
const budget = historyBudget(void 0, process.env, options.maxTransferBytes);
|
|
59239
59453
|
if (bytes > budget) throw new Error(`Request payload too large (413): local ACP transfer needs ${bytes} bytes; budget is ${budget}. Use OMP /compact or raise maxTransferBytes. No history was silently truncated.`);
|
|
59454
|
+
const textBytes = promptTextBytes(prompt);
|
|
59455
|
+
if (textBytes > ACP_STEP_TEXT_BYTES) {
|
|
59456
|
+
throw new Error(`Maximum context length exceeded: official Antigravity ACP single-step text needs ${textBytes} bytes; safe budget is ${ACP_STEP_TEXT_BYTES} bytes. Compact the conversation with OMP /compact and retry. A larger contextWindow or maxTransferBytes does not raise this server limit. No history or current request was sent or silently truncated.`);
|
|
59457
|
+
}
|
|
59240
59458
|
const estimatedTokens = (instructionsText ? estimateTransferTokens(instructionsText, 0, instructionsBytes - 108) : 0) + (historyText ? estimateTransferTokens(historyText, 0, historyBytes - 100) : 0) + estimateTransferTokens(tailSerialized, imageCount, tailBytes);
|
|
59241
59459
|
if (estimatedTokens > options.inputTokenBudget) throw new Error(`Maximum context length exceeded: local ACP estimate is ${estimatedTokens} tokens; input budget is ${options.inputTokenBudget}. Use OMP /compact. This is a heuristic estimate, not a server token count. No history was silently truncated.`);
|
|
59242
59460
|
return { prompt, messageCount: messages.length };
|
|
@@ -59453,14 +59671,14 @@ function quotaFromPrompt(response) {
|
|
|
59453
59671
|
const reset = quota.resetTimestamp ?? quota.resetAt ?? quota.reset_time;
|
|
59454
59672
|
const tier = quota.tier ?? quota.plan;
|
|
59455
59673
|
const model = quota.model ?? quota.modelId;
|
|
59456
|
-
const
|
|
59674
|
+
const snapshot2 = {
|
|
59457
59675
|
...remaining !== void 0 ? { remaining } : {},
|
|
59458
59676
|
...limit !== void 0 ? { limit } : {},
|
|
59459
59677
|
...typeof reset === "string" || typeof reset === "number" ? { resetAt: typeof reset === "number" ? new Date(reset > 1e12 ? reset : reset * 1e3).toISOString() : reset } : {},
|
|
59460
59678
|
...typeof tier === "string" ? { tier } : {},
|
|
59461
59679
|
...typeof model === "string" ? { model } : {}
|
|
59462
59680
|
};
|
|
59463
|
-
return Object.keys(
|
|
59681
|
+
return Object.keys(snapshot2).length > 0 ? snapshot2 : void 0;
|
|
59464
59682
|
}
|
|
59465
59683
|
function record2(value) {
|
|
59466
59684
|
return value && typeof value === "object" ? value : void 0;
|
|
@@ -59470,9 +59688,21 @@ function number4(value) {
|
|
|
59470
59688
|
}
|
|
59471
59689
|
|
|
59472
59690
|
// node_modules/pi-antigravity-acp-provider/src/runtime.ts
|
|
59691
|
+
var ompMessageFingerprintMemo = createHistoryFingerprintMemo();
|
|
59473
59692
|
var PERMISSION_TIMEOUT_MS = 12e4;
|
|
59474
59693
|
var TOOL_BATCH_MS = 100;
|
|
59475
59694
|
var AntigravityRuntime = class {
|
|
59695
|
+
ompSystemMemo = createStructuredFingerprintMemo();
|
|
59696
|
+
ompToolsMemo = createStructuredFingerprintMemo();
|
|
59697
|
+
ompMessagesFingerprint(messages) {
|
|
59698
|
+
return messagesFingerprint(messages, this.ompSystemMemo);
|
|
59699
|
+
}
|
|
59700
|
+
ompMessageFingerprint(message) {
|
|
59701
|
+
return messageFingerprint(message, this.ompSystemMemo);
|
|
59702
|
+
}
|
|
59703
|
+
ompToolsFingerprint(tools) {
|
|
59704
|
+
return this.ompToolsMemo(tools, () => piToolFingerprint(tools));
|
|
59705
|
+
}
|
|
59476
59706
|
bindings = /* @__PURE__ */ new Map();
|
|
59477
59707
|
resolvedBindings = /* @__PURE__ */ new Set();
|
|
59478
59708
|
disposed = false;
|
|
@@ -59618,7 +59848,7 @@ var AntigravityRuntime = class {
|
|
|
59618
59848
|
}
|
|
59619
59849
|
async logout() {
|
|
59620
59850
|
await this.closeBindings();
|
|
59621
|
-
this.sessionStore?.clear();
|
|
59851
|
+
await this.sessionStore?.clear();
|
|
59622
59852
|
clearAntigravityCredentials();
|
|
59623
59853
|
}
|
|
59624
59854
|
setPermissionMode(mode) {
|
|
@@ -59686,6 +59916,7 @@ var AntigravityRuntime = class {
|
|
|
59686
59916
|
return this.closePromise ??= this.closeBindings();
|
|
59687
59917
|
}
|
|
59688
59918
|
async closeBindings() {
|
|
59919
|
+
const closingTurns = [...this.resolvedBindings].flatMap((binding) => binding.turnCompletion ? [binding.turnCompletion] : []);
|
|
59689
59920
|
this.bindingEpoch += 1;
|
|
59690
59921
|
const pending = [...this.bindings.values()];
|
|
59691
59922
|
this.bindings.clear();
|
|
@@ -59704,6 +59935,13 @@ var AntigravityRuntime = class {
|
|
|
59704
59935
|
]);
|
|
59705
59936
|
})
|
|
59706
59937
|
);
|
|
59938
|
+
await Promise.allSettled(closingTurns);
|
|
59939
|
+
try {
|
|
59940
|
+
await this.sessionStore?.flush?.();
|
|
59941
|
+
} finally {
|
|
59942
|
+
this.ompSystemMemo.clear();
|
|
59943
|
+
this.ompToolsMemo.clear();
|
|
59944
|
+
}
|
|
59707
59945
|
}
|
|
59708
59946
|
async runQueued(model, context, options, writer) {
|
|
59709
59947
|
this.assertActive();
|
|
@@ -59718,12 +59956,12 @@ var AntigravityRuntime = class {
|
|
|
59718
59956
|
let binding = await this.getBinding(key, model, acpModelId, options.apiKey, writer, tools, options.signal);
|
|
59719
59957
|
await this.modeChanges;
|
|
59720
59958
|
this.assertEpoch(epoch);
|
|
59721
|
-
if (binding.mode !== this.permissionMode || this.confirmedMode(binding) !== this.permissionMode || binding.toolFingerprint !==
|
|
59959
|
+
if (binding.mode !== this.permissionMode || this.confirmedMode(binding) !== this.permissionMode || binding.toolFingerprint !== this.ompToolsFingerprint(tools)) {
|
|
59722
59960
|
await this.invalidateBinding(binding);
|
|
59723
59961
|
binding = await this.getBinding(key, model, acpModelId, options.apiKey, writer, tools, options.signal);
|
|
59724
59962
|
}
|
|
59725
|
-
if ((binding.turnCompletion || binding.permission || binding.pendingTools.size > 0) && (context.messages.findLastIndex((message) => message.role === "user") >= binding.pendingContextCount ||
|
|
59726
|
-
const prefixMatches = context.messages.length >= binding.pendingContextCount &&
|
|
59963
|
+
if ((binding.turnCompletion || binding.permission || binding.pendingTools.size > 0) && (context.messages.findLastIndex((message) => message.role === "user") >= binding.pendingContextCount || this.ompMessagesFingerprint(context.messages.slice(0, binding.pendingContextCount)) !== binding.pendingContextFingerprint)) {
|
|
59964
|
+
const prefixMatches = context.messages.length >= binding.pendingContextCount && this.ompMessagesFingerprint(context.messages.slice(0, binding.pendingContextCount)) === binding.pendingContextFingerprint;
|
|
59727
59965
|
const drained = prefixMatches && await drainCancelledTurn(binding, () => abortTurn(binding), options.signal);
|
|
59728
59966
|
if (!drained || !binding.connection.process.alive || binding.needsReconstruction || !["cancelled", "end_turn"].includes(binding.ompTerminalStopReason)) {
|
|
59729
59967
|
await this.invalidateBinding(binding);
|
|
@@ -59735,22 +59973,25 @@ var AntigravityRuntime = class {
|
|
|
59735
59973
|
const result = findPermissionResult(context, pending.id);
|
|
59736
59974
|
if (!result) {
|
|
59737
59975
|
cancelPermission(binding);
|
|
59738
|
-
await this.
|
|
59976
|
+
await this.invalidateBinding(binding);
|
|
59739
59977
|
binding = await this.getBinding(key, model, acpModelId, options.apiKey, writer, tools, options.signal);
|
|
59740
59978
|
} else {
|
|
59741
|
-
binding
|
|
59742
|
-
|
|
59743
|
-
|
|
59744
|
-
|
|
59745
|
-
|
|
59746
|
-
|
|
59747
|
-
|
|
59748
|
-
|
|
59749
|
-
|
|
59750
|
-
pending.
|
|
59751
|
-
|
|
59752
|
-
|
|
59753
|
-
|
|
59979
|
+
return await claimContinuation(binding, async () => {
|
|
59980
|
+
binding.writer = writer;
|
|
59981
|
+
const continuationTurn = binding.turnCompletion;
|
|
59982
|
+
await this.noteContinuationInstructions(binding, context);
|
|
59983
|
+
if (!continuationTurn || binding.turnCompletion !== continuationTurn || binding.abortRequested || options.signal?.aborted || !binding.connection.process.alive) throw abortError();
|
|
59984
|
+
binding.pendingContextCount = context.messages.length;
|
|
59985
|
+
binding.pendingContextFingerprint = this.ompMessagesFingerprint(context.messages);
|
|
59986
|
+
binding.permission = void 0;
|
|
59987
|
+
clearTimeout(pending.timer);
|
|
59988
|
+
if (!result.cancelled && result.optionId && pending.request.options.some((option) => option.optionId === result.optionId)) {
|
|
59989
|
+
pending.resolve({ outcome: { outcome: "selected", optionId: result.optionId } });
|
|
59990
|
+
} else {
|
|
59991
|
+
pending.resolve({ outcome: { outcome: "cancelled" } });
|
|
59992
|
+
}
|
|
59993
|
+
await this.awaitContinuation(binding, options.signal);
|
|
59994
|
+
}, () => this.invalidateBinding(binding));
|
|
59754
59995
|
}
|
|
59755
59996
|
}
|
|
59756
59997
|
if (binding.pendingTools.size > 0) {
|
|
@@ -59760,19 +60001,22 @@ var AntigravityRuntime = class {
|
|
|
59760
60001
|
}));
|
|
59761
60002
|
if (results.some((result) => result.message === void 0)) {
|
|
59762
60003
|
cancelPiTools(binding, "Pi continued without returning every requested tool result");
|
|
59763
|
-
await this.
|
|
60004
|
+
await this.invalidateBinding(binding);
|
|
59764
60005
|
binding = await this.getBinding(key, model, acpModelId, options.apiKey, writer, tools, options.signal);
|
|
59765
60006
|
} else {
|
|
59766
|
-
binding
|
|
59767
|
-
|
|
59768
|
-
|
|
59769
|
-
|
|
59770
|
-
|
|
59771
|
-
binding.
|
|
59772
|
-
|
|
59773
|
-
|
|
59774
|
-
|
|
59775
|
-
|
|
60007
|
+
return await claimContinuation(binding, async () => {
|
|
60008
|
+
binding.writer = writer;
|
|
60009
|
+
const continuationTurn = binding.turnCompletion;
|
|
60010
|
+
await this.noteContinuationInstructions(binding, context);
|
|
60011
|
+
if (!continuationTurn || binding.turnCompletion !== continuationTurn || binding.abortRequested || options.signal?.aborted || !binding.connection.process.alive) throw abortError();
|
|
60012
|
+
binding.pendingContextCount = context.messages.length;
|
|
60013
|
+
binding.pendingContextFingerprint = this.ompMessagesFingerprint(context.messages);
|
|
60014
|
+
for (const { pending, message } of results) {
|
|
60015
|
+
binding.pendingTools.delete(pending.invocation.id);
|
|
60016
|
+
pending.resolve(toMcpToolResult(message));
|
|
60017
|
+
}
|
|
60018
|
+
await this.awaitContinuation(binding, options.signal);
|
|
60019
|
+
}, () => this.invalidateBinding(binding));
|
|
59776
60020
|
}
|
|
59777
60021
|
}
|
|
59778
60022
|
const previous = this.queues.get(key) ?? Promise.resolve();
|
|
@@ -59782,13 +60026,14 @@ var AntigravityRuntime = class {
|
|
|
59782
60026
|
});
|
|
59783
60027
|
this.queues.set(key, queue);
|
|
59784
60028
|
await previous;
|
|
60029
|
+
let ompDispatched = false;
|
|
59785
60030
|
let completeTurn;
|
|
59786
60031
|
let onTurnAbort;
|
|
59787
60032
|
try {
|
|
59788
60033
|
await this.modeChanges;
|
|
59789
60034
|
this.assertEpoch(epoch);
|
|
59790
60035
|
binding = await this.getBinding(key, model, acpModelId, options.apiKey, writer, tools, options.signal);
|
|
59791
|
-
if (binding.needsReconstruction || binding.
|
|
60036
|
+
if (binding.needsReconstruction || binding.expectedAssistantFingerprint && context.messages[binding.messageCount]?.role === "assistant" && this.ompMessageFingerprint(context.messages[binding.messageCount]) !== binding.expectedAssistantFingerprint || (binding.ompExpectedAssistantHasOutput || binding.ompCancelledCheckpoint && binding.ompCancelledHadOutput) && context.messages[binding.messageCount]?.role !== "assistant" || binding.mode !== this.permissionMode || this.confirmedMode(binding) !== this.permissionMode || binding.toolFingerprint !== this.ompToolsFingerprint(tools) || context.messages.length < binding.messageCount || this.ompMessagesFingerprint(context.messages.slice(0, binding.messageCount)) !== binding.historyFingerprint) {
|
|
59792
60037
|
await this.dropBinding(key, binding, true);
|
|
59793
60038
|
binding = await this.getBinding(key, model, acpModelId, options.apiKey, writer, tools, options.signal);
|
|
59794
60039
|
}
|
|
@@ -59800,7 +60045,7 @@ var AntigravityRuntime = class {
|
|
|
59800
60045
|
const fresh = binding.messageCount === 0;
|
|
59801
60046
|
let unseenStart = binding.messageCount;
|
|
59802
60047
|
const expected = context.messages[unseenStart];
|
|
59803
|
-
if (!fresh && expected?.role === "assistant" && binding.expectedAssistantFingerprint ===
|
|
60048
|
+
if (!fresh && expected?.role === "assistant" && binding.expectedAssistantFingerprint === this.ompMessageFingerprint(expected)) {
|
|
59804
60049
|
unseenStart += 1;
|
|
59805
60050
|
}
|
|
59806
60051
|
const parts = adaptPromptToCapabilities(
|
|
@@ -59817,7 +60062,7 @@ var AntigravityRuntime = class {
|
|
|
59817
60062
|
binding.instructionsFingerprint = instructionFingerprint(context);
|
|
59818
60063
|
binding.needsReconstruction = false;
|
|
59819
60064
|
binding.pendingContextCount = context.messages.length;
|
|
59820
|
-
binding.pendingContextFingerprint =
|
|
60065
|
+
binding.pendingContextFingerprint = this.ompMessagesFingerprint(context.messages);
|
|
59821
60066
|
binding.turnCompletion = new Promise((resolve) => {
|
|
59822
60067
|
completeTurn = resolve;
|
|
59823
60068
|
});
|
|
@@ -59827,6 +60072,13 @@ var AntigravityRuntime = class {
|
|
|
59827
60072
|
options.signal.addEventListener("abort", onTurnAbort, { once: true });
|
|
59828
60073
|
if (options.signal.aborted) onTurnAbort();
|
|
59829
60074
|
}
|
|
60075
|
+
if (options.signal?.aborted) throw abortError();
|
|
60076
|
+
binding.ompInFlight = true;
|
|
60077
|
+
await this.persistBinding(binding);
|
|
60078
|
+
this.assertEpoch(epoch);
|
|
60079
|
+
if (binding.ompInvalidated || !binding.connection.process.alive) throw new AntigravityAcpError("protocol", "ACP session closed before prompt dispatch");
|
|
60080
|
+
if (options.signal?.aborted) throw abortError();
|
|
60081
|
+
ompDispatched = true;
|
|
59830
60082
|
const response = await binding.connection.prompt(
|
|
59831
60083
|
{ sessionId: binding.session.sessionId, prompt: parts.prompt },
|
|
59832
60084
|
options.signal
|
|
@@ -59841,12 +60093,14 @@ var AntigravityRuntime = class {
|
|
|
59841
60093
|
activeWriter.message.rawStopReason = response.stopReason;
|
|
59842
60094
|
binding.messageCount = binding.pendingContextCount || parts.messageCount;
|
|
59843
60095
|
binding.historyFingerprint = binding.pendingContextFingerprint;
|
|
59844
|
-
binding.expectedAssistantFingerprint =
|
|
60096
|
+
binding.expectedAssistantFingerprint = this.ompMessageFingerprint(activeWriter.message.content.length ? activeWriter.message : { ...activeWriter.message, content: [{ type: "text", text: "" }] });
|
|
60097
|
+
binding.ompExpectedAssistantHasOutput = activeWriter.message.content.some((block) => block.type !== "text" || block.text.length > 0);
|
|
60098
|
+
binding.ompInFlight = false;
|
|
59845
60099
|
if (response.stopReason !== "cancelled") binding.ompCancelledCheckpoint = false;
|
|
59846
|
-
this.persistBinding(binding);
|
|
60100
|
+
await this.persistBinding(binding);
|
|
59847
60101
|
if (response.stopReason === "end_turn") {
|
|
59848
|
-
binding.connection.confirmReplacement?.(key, binding.session.sessionId);
|
|
59849
|
-
if (!persistent) binding.connection.discardSession?.(binding.session.sessionId);
|
|
60102
|
+
await binding.connection.confirmReplacement?.(key, binding.session.sessionId);
|
|
60103
|
+
if (!persistent) await binding.connection.discardSession?.(binding.session.sessionId);
|
|
59850
60104
|
}
|
|
59851
60105
|
switch (response.stopReason) {
|
|
59852
60106
|
case "cancelled":
|
|
@@ -59862,15 +60116,23 @@ var AntigravityRuntime = class {
|
|
|
59862
60116
|
binding.writer?.fail(error62, isAbort(error62));
|
|
59863
60117
|
if (isAbort(error62) || binding.abortRequested) {
|
|
59864
60118
|
abortTurn(binding);
|
|
59865
|
-
if (binding.connection.process.alive && !binding.needsReconstruction && ["cancelled", "end_turn"].includes(binding.ompTerminalStopReason)) {
|
|
60119
|
+
if (binding.connection.process.alive && !binding.ompInvalidated && !binding.needsReconstruction && ["cancelled", "end_turn"].includes(binding.ompTerminalStopReason)) {
|
|
59866
60120
|
binding.messageCount = binding.pendingContextCount;
|
|
59867
60121
|
binding.historyFingerprint = binding.pendingContextFingerprint;
|
|
59868
|
-
binding.expectedAssistantFingerprint =
|
|
60122
|
+
binding.expectedAssistantFingerprint = this.ompMessageFingerprint((binding.writer ?? writer).message);
|
|
59869
60123
|
binding.ompCancelledCheckpoint = true;
|
|
59870
60124
|
binding.ompCancelledHadOutput = (binding.writer ?? writer).message.content.length > 0;
|
|
59871
|
-
|
|
60125
|
+
binding.ompExpectedAssistantHasOutput = binding.ompCancelledHadOutput;
|
|
60126
|
+
binding.ompInFlight = false;
|
|
60127
|
+
try {
|
|
60128
|
+
await this.persistBinding(binding);
|
|
60129
|
+
} catch (checkpointError) {
|
|
60130
|
+
await this.invalidateBinding(binding);
|
|
60131
|
+
throw checkpointError;
|
|
60132
|
+
}
|
|
59872
60133
|
} else await this.invalidateBinding(binding);
|
|
59873
|
-
}
|
|
60134
|
+
} else if (ompDispatched) await this.invalidateBinding(binding);
|
|
60135
|
+
else binding.ompInFlight = false;
|
|
59874
60136
|
if (!binding.connection.process.alive) await this.dropBinding(key, binding);
|
|
59875
60137
|
throw error62;
|
|
59876
60138
|
} finally {
|
|
@@ -59923,7 +60185,13 @@ var AntigravityRuntime = class {
|
|
|
59923
60185
|
async getBinding(key, model, acpModelId, apiKey, writer, tools, signal) {
|
|
59924
60186
|
this.assertActive();
|
|
59925
60187
|
const existing = this.bindings.get(key);
|
|
59926
|
-
if (existing)
|
|
60188
|
+
if (existing) {
|
|
60189
|
+
const value = await existing;
|
|
60190
|
+
if (!value.ompInvalidated) return value;
|
|
60191
|
+
await value.ompDropPromise;
|
|
60192
|
+
if (this.bindings.get(key) === existing) this.bindings.delete(key);
|
|
60193
|
+
return this.getBinding(key, model, acpModelId, apiKey, writer, tools, signal);
|
|
60194
|
+
}
|
|
59927
60195
|
const created = this.createBinding(key, model, acpModelId, apiKey, writer, tools ?? [], signal).catch((error62) => {
|
|
59928
60196
|
if (this.bindings.get(key) === created) this.bindings.delete(key);
|
|
59929
60197
|
throw error62;
|
|
@@ -59959,7 +60227,12 @@ var AntigravityRuntime = class {
|
|
|
59959
60227
|
}
|
|
59960
60228
|
const mcpServers = mcpServer ? [mcpServer] : [];
|
|
59961
60229
|
const piSessionId = key.startsWith("sid:") ? key.slice(4) : void 0;
|
|
59962
|
-
|
|
60230
|
+
let saved = piSessionId ? await this.sessionStore?.get(piSessionId) : void 0;
|
|
60231
|
+
if (saved && (saved.ompCheckpointVersion !== 1 || saved.ompInFlight !== false)) {
|
|
60232
|
+
await connection.retireForReplacement?.(key, saved.acpSessionId);
|
|
60233
|
+
await this.ompRemoveSaved(saved.piSessionId, saved.acpSessionId);
|
|
60234
|
+
saved = void 0;
|
|
60235
|
+
}
|
|
59963
60236
|
let session;
|
|
59964
60237
|
let restored = false;
|
|
59965
60238
|
if (saved?.cwd === cwd) {
|
|
@@ -59977,7 +60250,7 @@ var AntigravityRuntime = class {
|
|
|
59977
60250
|
session = { sessionId: saved.acpSessionId, ...loaded };
|
|
59978
60251
|
restored = true;
|
|
59979
60252
|
} catch {
|
|
59980
|
-
this.sessionStore?.remove(saved.piSessionId);
|
|
60253
|
+
await this.sessionStore?.remove(saved.piSessionId);
|
|
59981
60254
|
}
|
|
59982
60255
|
}
|
|
59983
60256
|
}
|
|
@@ -59985,7 +60258,7 @@ var AntigravityRuntime = class {
|
|
|
59985
60258
|
this.assertEpoch(epoch);
|
|
59986
60259
|
const mode = this.permissionMode;
|
|
59987
60260
|
if (!supportsMode(session, mode)) {
|
|
59988
|
-
if (piSessionId) this.sessionStore?.remove(piSessionId);
|
|
60261
|
+
if (piSessionId) await this.sessionStore?.remove(piSessionId);
|
|
59989
60262
|
throw new AntigravityAcpError("protocol", `Antigravity ${restored ? "restored" : "new"} session did not advertise permission mode '${mode}'; refusing to prompt`);
|
|
59990
60263
|
}
|
|
59991
60264
|
if (sessionModes(session)?.currentModeId !== mode) await connection.setMode(session.sessionId, mode, signal);
|
|
@@ -59997,6 +60270,9 @@ var AntigravityRuntime = class {
|
|
|
59997
60270
|
this.assertEpoch(epoch);
|
|
59998
60271
|
if (mode !== this.permissionMode) throw new AntigravityAcpError("protocol", "Permission mode changed during session setup; retry the turn");
|
|
59999
60272
|
const createdBinding = {
|
|
60273
|
+
ompInFlight: false,
|
|
60274
|
+
ompInvalidated: false,
|
|
60275
|
+
ompExpectedAssistantHasOutput: restored && saved?.ompExpectedAssistantHasOutput === true,
|
|
60000
60276
|
key,
|
|
60001
60277
|
cwd,
|
|
60002
60278
|
connection,
|
|
@@ -60009,16 +60285,16 @@ var AntigravityRuntime = class {
|
|
|
60009
60285
|
messageCount: restored && saved ? saved.messageCount : 0,
|
|
60010
60286
|
ompCancelledCheckpoint: restored && saved?.ompCancelledCheckpoint === true,
|
|
60011
60287
|
ompCancelledHadOutput: restored && saved?.ompCancelledHadOutput === true,
|
|
60012
|
-
historyFingerprint: restored && saved ? saved.historyFingerprint :
|
|
60288
|
+
historyFingerprint: restored && saved ? saved.historyFingerprint : this.ompMessagesFingerprint([]),
|
|
60013
60289
|
expectedAssistantFingerprint: restored ? saved?.expectedAssistantFingerprint : void 0,
|
|
60014
60290
|
pendingContextCount: 0,
|
|
60015
|
-
pendingContextFingerprint:
|
|
60291
|
+
pendingContextFingerprint: this.ompMessagesFingerprint([]),
|
|
60016
60292
|
writer,
|
|
60017
60293
|
permission: void 0,
|
|
60018
60294
|
pendingTools: /* @__PURE__ */ new Map(),
|
|
60019
60295
|
toolBatchTimer: void 0,
|
|
60020
60296
|
bridge,
|
|
60021
|
-
toolFingerprint:
|
|
60297
|
+
toolFingerprint: this.ompToolsFingerprint(tools),
|
|
60022
60298
|
omittedTools,
|
|
60023
60299
|
turnCompletion: void 0,
|
|
60024
60300
|
abortRequested: false,
|
|
@@ -60026,7 +60302,8 @@ var AntigravityRuntime = class {
|
|
|
60026
60302
|
restored
|
|
60027
60303
|
};
|
|
60028
60304
|
binding = createdBinding;
|
|
60029
|
-
this.persistBinding(createdBinding);
|
|
60305
|
+
await this.persistBinding(createdBinding);
|
|
60306
|
+
this.assertEpoch(epoch);
|
|
60030
60307
|
this.resolvedBindings.add(createdBinding);
|
|
60031
60308
|
void connection.process.exited.then(() => {
|
|
60032
60309
|
cancelPermission(createdBinding);
|
|
@@ -60035,7 +60312,7 @@ var AntigravityRuntime = class {
|
|
|
60035
60312
|
void bridge?.close().catch(() => void 0);
|
|
60036
60313
|
const current = this.bindings.get(key);
|
|
60037
60314
|
if (current) void current.then((value) => {
|
|
60038
|
-
if (value === createdBinding && this.bindings.get(key) === current) this.bindings.delete(key);
|
|
60315
|
+
if (value === createdBinding && this.bindings.get(key) === current && !createdBinding.ompInvalidated) this.bindings.delete(key);
|
|
60039
60316
|
}).catch(() => void 0);
|
|
60040
60317
|
}).catch(() => void 0);
|
|
60041
60318
|
return createdBinding;
|
|
@@ -60044,16 +60321,19 @@ var AntigravityRuntime = class {
|
|
|
60044
60321
|
throw error62;
|
|
60045
60322
|
}
|
|
60046
60323
|
}
|
|
60047
|
-
persistBinding(binding) {
|
|
60048
|
-
if (!binding.piSessionId) return;
|
|
60324
|
+
async persistBinding(binding) {
|
|
60325
|
+
if (!binding.piSessionId || binding.ompInvalidated) return;
|
|
60049
60326
|
if (binding.needsReconstruction) {
|
|
60050
|
-
this.
|
|
60327
|
+
await this.ompRemoveSaved(binding.piSessionId, binding.session.sessionId);
|
|
60051
60328
|
return;
|
|
60052
60329
|
}
|
|
60053
|
-
this.sessionStore?.save({
|
|
60330
|
+
await this.sessionStore?.save({
|
|
60054
60331
|
piSessionId: binding.piSessionId,
|
|
60055
60332
|
acpSessionId: binding.session.sessionId,
|
|
60056
60333
|
acpModelId: binding.modelId,
|
|
60334
|
+
ompCheckpointVersion: 1,
|
|
60335
|
+
ompInFlight: binding.ompInFlight === true,
|
|
60336
|
+
ompExpectedAssistantHasOutput: binding.ompExpectedAssistantHasOutput === true,
|
|
60057
60337
|
ompCancelledCheckpoint: binding.ompCancelledCheckpoint === true,
|
|
60058
60338
|
ompCancelledHadOutput: binding.ompCancelledHadOutput === true,
|
|
60059
60339
|
cwd: binding.cwd,
|
|
@@ -60130,25 +60410,43 @@ var AntigravityRuntime = class {
|
|
|
60130
60410
|
else if (activity.type === "tool" || activity.type === "plan") binding.writer.thinking(activity.text);
|
|
60131
60411
|
}
|
|
60132
60412
|
}
|
|
60413
|
+
async ompRemoveSaved(piSessionId, acpSessionId) {
|
|
60414
|
+
if (typeof this.sessionStore?.removeIfMatches === "function") await this.sessionStore.removeIfMatches(piSessionId, acpSessionId);
|
|
60415
|
+
else await this.sessionStore?.remove(piSessionId);
|
|
60416
|
+
}
|
|
60133
60417
|
async dropBinding(key, binding, removeSaved = false) {
|
|
60134
|
-
if (removeSaved) binding.
|
|
60135
|
-
|
|
60136
|
-
|
|
60137
|
-
if (removeSaved && binding.piSessionId) this.
|
|
60138
|
-
|
|
60418
|
+
if (removeSaved) binding.ompInvalidated = true;
|
|
60419
|
+
if (binding.ompDropPromise) {
|
|
60420
|
+
await binding.ompDropPromise;
|
|
60421
|
+
if (removeSaved && binding.piSessionId) await this.ompRemoveSaved(binding.piSessionId, binding.session.sessionId);
|
|
60422
|
+
return;
|
|
60139
60423
|
}
|
|
60140
|
-
|
|
60141
|
-
|
|
60142
|
-
|
|
60143
|
-
|
|
60424
|
+
const dropping = (async () => {
|
|
60425
|
+
const current = this.bindings.get(key);
|
|
60426
|
+
this.resolvedBindings.delete(binding);
|
|
60427
|
+
cancelPermission(binding);
|
|
60428
|
+
cancelPiTools(binding, "Antigravity session closed before Pi returned the tool result");
|
|
60429
|
+
const closing = Promise.allSettled([binding.connection.close(), binding.bridge?.close() ?? Promise.resolve()]);
|
|
60430
|
+
try {
|
|
60431
|
+
if (removeSaved) {
|
|
60432
|
+
await binding.connection.retireForReplacement?.(key, binding.session.sessionId);
|
|
60433
|
+
if (binding.piSessionId) await this.ompRemoveSaved(binding.piSessionId, binding.session.sessionId);
|
|
60434
|
+
}
|
|
60435
|
+
} finally {
|
|
60436
|
+
await closing;
|
|
60437
|
+
if (current && await current === binding && this.bindings.get(key) === current) this.bindings.delete(key);
|
|
60438
|
+
}
|
|
60439
|
+
})();
|
|
60440
|
+
binding.ompDropPromise = dropping;
|
|
60441
|
+
await dropping;
|
|
60144
60442
|
}
|
|
60145
60443
|
confirmedMode(binding) {
|
|
60146
60444
|
return sessionModes(binding.connection.getSessionState(binding.session.sessionId))?.currentModeId;
|
|
60147
60445
|
}
|
|
60148
|
-
noteContinuationInstructions(binding, context) {
|
|
60446
|
+
async noteContinuationInstructions(binding, context) {
|
|
60149
60447
|
if (binding.instructionsFingerprint !== instructionFingerprint(context)) {
|
|
60150
60448
|
binding.needsReconstruction = true;
|
|
60151
|
-
if (binding.piSessionId) this.sessionStore?.remove(binding.piSessionId);
|
|
60449
|
+
if (binding.piSessionId) await this.sessionStore?.remove(binding.piSessionId);
|
|
60152
60450
|
}
|
|
60153
60451
|
}
|
|
60154
60452
|
async invalidateBinding(binding) {
|
|
@@ -60240,11 +60538,11 @@ function findPermissionResult(context, requestId) {
|
|
|
60240
60538
|
}
|
|
60241
60539
|
return void 0;
|
|
60242
60540
|
}
|
|
60243
|
-
function messagesFingerprint(messages) {
|
|
60244
|
-
const fingerprints = messages.map(messageFingerprint);
|
|
60541
|
+
function messagesFingerprint(messages, systemMemo) {
|
|
60542
|
+
const fingerprints = messages.map((message) => messageFingerprint(message, systemMemo));
|
|
60245
60543
|
return createHash2("sha256").update(fingerprints.join("\n")).digest("hex");
|
|
60246
60544
|
}
|
|
60247
|
-
function messageFingerprint(message) {
|
|
60545
|
+
function messageFingerprint(message, systemMemo) {
|
|
60248
60546
|
let value;
|
|
60249
60547
|
if (message.role === "user") {
|
|
60250
60548
|
value = { role: message.role, content: message.content };
|
|
@@ -60272,7 +60570,8 @@ function messageFingerprint(message) {
|
|
|
60272
60570
|
isError: message.isError
|
|
60273
60571
|
};
|
|
60274
60572
|
}
|
|
60275
|
-
|
|
60573
|
+
const compute = () => createHash2("sha256").update(canonicalJson2(value)).digest("hex");
|
|
60574
|
+
return message.role === "system" && systemMemo ? systemMemo(value, compute) : ompMessageFingerprintMemo(message, value, compute);
|
|
60276
60575
|
}
|
|
60277
60576
|
function canonicalJson2(value) {
|
|
60278
60577
|
if (Array.isArray(value)) return `[${value.map(canonicalJson2).join(",")}]`;
|
|
@@ -60590,13 +60889,19 @@ var TierConnection = class extends AntigravityAcpConnection {
|
|
|
60590
60889
|
usageCaptures = /* @__PURE__ */ new Map();
|
|
60591
60890
|
usageCommands = /* @__PURE__ */ new Set();
|
|
60592
60891
|
cleanup;
|
|
60892
|
+
diagnostics;
|
|
60893
|
+
firstOutput = /* @__PURE__ */ new Map();
|
|
60894
|
+
pendingOwned = /* @__PURE__ */ new Set();
|
|
60895
|
+
ownershipRetry;
|
|
60593
60896
|
cleanupLeases = /* @__PURE__ */ new Map();
|
|
60594
60897
|
toolRouting;
|
|
60595
60898
|
constructor(options) {
|
|
60596
60899
|
super(options);
|
|
60597
60900
|
this.cleanup = options.ompCleanup;
|
|
60901
|
+
this.diagnostics = options.ompDiagnostics;
|
|
60598
60902
|
this.cleanup?.start();
|
|
60599
|
-
void this.process.exited.then(() => this.releaseCleanupLeases())
|
|
60903
|
+
void this.process.exited.then(() => this.releaseCleanupLeases()).catch(() => {
|
|
60904
|
+
});
|
|
60600
60905
|
this.debugToolUpdates = options.ompDebugToolUpdates ?? false;
|
|
60601
60906
|
this.usageMode = options.ompUsageMode ?? "auto";
|
|
60602
60907
|
this.setHandlers({ ...options.handlers, onUpdate: async (notification) => {
|
|
@@ -60615,6 +60920,10 @@ var TierConnection = class extends AntigravityAcpConnection {
|
|
|
60615
60920
|
}
|
|
60616
60921
|
return;
|
|
60617
60922
|
}
|
|
60923
|
+
if (update.sessionUpdate === "agent_message_chunk" && this.firstOutput.has(notification.sessionId)) {
|
|
60924
|
+
this.diagnostics?.record("acp.first-output", performance.now() - this.firstOutput.get(notification.sessionId));
|
|
60925
|
+
this.firstOutput.delete(notification.sessionId);
|
|
60926
|
+
}
|
|
60618
60927
|
if (showAcpUpdate(notification, this.debugToolUpdates)) await options.handlers?.onUpdate?.(notification);
|
|
60619
60928
|
} });
|
|
60620
60929
|
if (options.ompNativeTools) {
|
|
@@ -60632,25 +60941,26 @@ var TierConnection = class extends AntigravityAcpConnection {
|
|
|
60632
60941
|
const session = await super.newSession(...args);
|
|
60633
60942
|
if (this.cleanup) {
|
|
60634
60943
|
try {
|
|
60635
|
-
this.cleanupLeases.set(session.sessionId, this.cleanup.acquire(session.sessionId, true, this.process.pid));
|
|
60944
|
+
this.cleanupLeases.set(session.sessionId, await this.cleanup.acquire(session.sessionId, true, this.process.pid));
|
|
60636
60945
|
} catch {
|
|
60637
|
-
|
|
60946
|
+
this.pendingOwned.add(session.sessionId);
|
|
60947
|
+
console.warn("[ACP cleanup] Registration deferred; preserving session files and retrying.");
|
|
60638
60948
|
}
|
|
60639
60949
|
}
|
|
60640
60950
|
this.usageBaselines.set(session.sessionId, { input: 0, completion: 0, thinking: 0, cached: 0, total: 0 });
|
|
60641
60951
|
return session;
|
|
60642
60952
|
}
|
|
60643
|
-
protectSession(id) {
|
|
60953
|
+
async protectSession(id) {
|
|
60644
60954
|
if (this.cleanup && !this.cleanupLeases.has(id)) {
|
|
60645
|
-
this.cleanupLeases.set(id, this.cleanup.acquire(id, false, this.process.pid));
|
|
60955
|
+
this.cleanupLeases.set(id, await this.cleanup.acquire(id, false, this.process.pid));
|
|
60646
60956
|
}
|
|
60647
60957
|
}
|
|
60648
60958
|
async resumeSession(...args) {
|
|
60649
|
-
this.protectSession(args[0]);
|
|
60959
|
+
await this.protectSession(args[0]);
|
|
60650
60960
|
return super.resumeSession(...args);
|
|
60651
60961
|
}
|
|
60652
60962
|
async loadSession(...args) {
|
|
60653
|
-
this.protectSession(args[0]);
|
|
60963
|
+
await this.protectSession(args[0]);
|
|
60654
60964
|
return super.loadSession(...args);
|
|
60655
60965
|
}
|
|
60656
60966
|
dropSessionState(id) {
|
|
@@ -60659,28 +60969,29 @@ var TierConnection = class extends AntigravityAcpConnection {
|
|
|
60659
60969
|
this.usageBaselines?.delete(id);
|
|
60660
60970
|
this.usageCommands?.delete(id);
|
|
60661
60971
|
}
|
|
60662
|
-
retireForReplacement(key, id) {
|
|
60972
|
+
async retireForReplacement(key, id) {
|
|
60663
60973
|
this.dropSessionState(id);
|
|
60664
60974
|
try {
|
|
60665
|
-
this.cleanup?.retire(key, id);
|
|
60975
|
+
await this.cleanup?.retire(key, id);
|
|
60666
60976
|
} catch {
|
|
60667
60977
|
}
|
|
60668
60978
|
}
|
|
60669
|
-
confirmReplacement(key, id) {
|
|
60979
|
+
async confirmReplacement(key, id) {
|
|
60670
60980
|
try {
|
|
60671
|
-
this.cleanup?.confirm(key, id);
|
|
60981
|
+
await this.cleanup?.confirm(key, id, true);
|
|
60672
60982
|
} catch {
|
|
60673
60983
|
}
|
|
60674
60984
|
}
|
|
60675
|
-
discardSession(id) {
|
|
60676
|
-
this.retireForReplacement(`discovery:${id}`, id);
|
|
60677
|
-
this.confirmReplacement(`discovery:${id}`, "discovery-complete");
|
|
60985
|
+
async discardSession(id) {
|
|
60986
|
+
await this.retireForReplacement(`discovery:${id}`, id);
|
|
60987
|
+
await this.confirmReplacement(`discovery:${id}`, "discovery-complete");
|
|
60678
60988
|
}
|
|
60679
|
-
releaseCleanupLeases() {
|
|
60989
|
+
async releaseCleanupLeases() {
|
|
60680
60990
|
if (this.process.alive) return;
|
|
60991
|
+
await this.retryOwnership();
|
|
60681
60992
|
for (const [id, token2] of this.cleanupLeases ?? []) {
|
|
60682
60993
|
try {
|
|
60683
|
-
this.cleanup?.release(token2);
|
|
60994
|
+
await this.cleanup?.release(token2, true);
|
|
60684
60995
|
this.cleanupLeases.delete(id);
|
|
60685
60996
|
} catch {
|
|
60686
60997
|
}
|
|
@@ -60688,12 +60999,32 @@ var TierConnection = class extends AntigravityAcpConnection {
|
|
|
60688
60999
|
}
|
|
60689
61000
|
async close() {
|
|
60690
61001
|
await super.close();
|
|
60691
|
-
this.releaseCleanupLeases();
|
|
61002
|
+
await this.releaseCleanupLeases();
|
|
60692
61003
|
this.contextUsage?.clear();
|
|
60693
61004
|
this.usageStatus?.clear();
|
|
60694
61005
|
this.usageBaselines?.clear();
|
|
60695
61006
|
this.usageCommands?.clear();
|
|
60696
61007
|
this.usageCaptures?.clear();
|
|
61008
|
+
this.firstOutput?.clear();
|
|
61009
|
+
}
|
|
61010
|
+
async retryOwnership() {
|
|
61011
|
+
if (this.ownershipRetry) return this.ownershipRetry;
|
|
61012
|
+
const pending = this.retryOwnershipOnce();
|
|
61013
|
+
this.ownershipRetry = pending;
|
|
61014
|
+
try {
|
|
61015
|
+
await pending;
|
|
61016
|
+
} finally {
|
|
61017
|
+
if (this.ownershipRetry === pending) this.ownershipRetry = void 0;
|
|
61018
|
+
}
|
|
61019
|
+
}
|
|
61020
|
+
async retryOwnershipOnce() {
|
|
61021
|
+
for (const id of this.pendingOwned ?? []) {
|
|
61022
|
+
try {
|
|
61023
|
+
this.cleanupLeases.set(id, await this.cleanup.acquire(id, true, this.process.pid));
|
|
61024
|
+
this.pendingOwned.delete(id);
|
|
61025
|
+
} catch {
|
|
61026
|
+
}
|
|
61027
|
+
}
|
|
60697
61028
|
}
|
|
60698
61029
|
async readUsage(sessionId, signal) {
|
|
60699
61030
|
const started = performance.now();
|
|
@@ -60715,8 +61046,14 @@ var TierConnection = class extends AntigravityAcpConnection {
|
|
|
60715
61046
|
async prompt(request, signal) {
|
|
60716
61047
|
this.activePrompts++;
|
|
60717
61048
|
const id = request.sessionId;
|
|
61049
|
+
await this.retryOwnership();
|
|
61050
|
+
let abortedAt;
|
|
61051
|
+
const aborted2 = () => {
|
|
61052
|
+
abortedAt = performance.now();
|
|
61053
|
+
};
|
|
61054
|
+
signal?.addEventListener("abort", aborted2, { once: true });
|
|
60718
61055
|
try {
|
|
60719
|
-
this.cleanup?.touch(id);
|
|
61056
|
+
await this.cleanup?.touch(id);
|
|
60720
61057
|
} catch {
|
|
60721
61058
|
}
|
|
60722
61059
|
try {
|
|
@@ -60728,7 +61065,11 @@ var TierConnection = class extends AntigravityAcpConnection {
|
|
|
60728
61065
|
} catch {
|
|
60729
61066
|
}
|
|
60730
61067
|
}
|
|
61068
|
+
const started = performance.now();
|
|
61069
|
+
this.firstOutput?.set(id, started);
|
|
60731
61070
|
const response = await super.prompt(request, signal);
|
|
61071
|
+
this.diagnostics?.record("acp.prompt", performance.now() - started);
|
|
61072
|
+
if (abortedAt !== void 0 && ["cancelled", "end_turn"].includes(response.stopReason)) this.diagnostics?.record("acp.cancel-confirmation", performance.now() - abortedAt);
|
|
60732
61073
|
const withContext = (value) => {
|
|
60733
61074
|
const context = this.contextUsage.get(id);
|
|
60734
61075
|
return context ? { ...value, _meta: { ...value._meta, ompContextTokens: context.used } } : value;
|
|
@@ -60752,9 +61093,11 @@ var TierConnection = class extends AntigravityAcpConnection {
|
|
|
60752
61093
|
return withContext(response);
|
|
60753
61094
|
}
|
|
60754
61095
|
} finally {
|
|
61096
|
+
signal?.removeEventListener("abort", aborted2);
|
|
61097
|
+
this.firstOutput?.delete(id);
|
|
60755
61098
|
this.activePrompts--;
|
|
60756
61099
|
try {
|
|
60757
|
-
this.cleanup?.touch(id);
|
|
61100
|
+
await this.cleanup?.touch(id);
|
|
60758
61101
|
} catch {
|
|
60759
61102
|
}
|
|
60760
61103
|
}
|
|
@@ -60786,227 +61129,416 @@ var TierConnection = class extends AntigravityAcpConnection {
|
|
|
60786
61129
|
// extension/session-cleanup.ts
|
|
60787
61130
|
var import_proper_lockfile2 = __toESM(require_proper_lockfile(), 1);
|
|
60788
61131
|
import fs10 from "node:fs";
|
|
61132
|
+
import afs from "node:fs/promises";
|
|
60789
61133
|
import path10 from "node:path";
|
|
60790
|
-
import { createHash as createHash3, randomUUID as
|
|
61134
|
+
import { createHash as createHash3, randomUUID as randomUUID3 } from "node:crypto";
|
|
61135
|
+
|
|
61136
|
+
// extension/omp-session-source.ts
|
|
61137
|
+
import fs9 from "node:fs/promises";
|
|
61138
|
+
import path9 from "node:path";
|
|
61139
|
+
async function sourceRoot(root) {
|
|
61140
|
+
if (await fs9.realpath(root) !== path9.resolve(root)) throw new Error("Unsafe OMP session root");
|
|
61141
|
+
const stat = await fs9.stat(root);
|
|
61142
|
+
if (!stat.isDirectory()) throw new Error("Invalid OMP session root");
|
|
61143
|
+
return stat;
|
|
61144
|
+
}
|
|
61145
|
+
async function sourceId(file2) {
|
|
61146
|
+
if (await fs9.realpath(file2) !== path9.resolve(file2)) throw new Error("Symlinked OMP session");
|
|
61147
|
+
const handle = await fs9.open(file2, "r");
|
|
61148
|
+
try {
|
|
61149
|
+
if (!(await handle.stat()).isFile()) throw new Error("Invalid OMP session file");
|
|
61150
|
+
const buffer = Buffer.alloc(65536);
|
|
61151
|
+
const { bytesRead } = await handle.read(buffer, 0, buffer.length, 0);
|
|
61152
|
+
for (const line of buffer.toString("utf8", 0, bytesRead).split("\n").slice(0, 4)) {
|
|
61153
|
+
try {
|
|
61154
|
+
const header = JSON.parse(line);
|
|
61155
|
+
if (header.type === "session" && typeof header.id === "string") return header.id;
|
|
61156
|
+
} catch {
|
|
61157
|
+
}
|
|
61158
|
+
}
|
|
61159
|
+
throw new Error("OMP session header unavailable");
|
|
61160
|
+
} finally {
|
|
61161
|
+
await handle.close();
|
|
61162
|
+
}
|
|
61163
|
+
}
|
|
61164
|
+
async function findSources(root) {
|
|
61165
|
+
let entries = 0;
|
|
61166
|
+
const sources = /* @__PURE__ */ new Map();
|
|
61167
|
+
async function visit2(dir, depth) {
|
|
61168
|
+
if (depth > 4) throw new Error("OMP source scan depth exceeded");
|
|
61169
|
+
for (const item of await fs9.readdir(dir, { withFileTypes: true })) {
|
|
61170
|
+
if (++entries > 2e4) throw new Error("OMP source scan limit exceeded");
|
|
61171
|
+
if (item.isSymbolicLink()) throw new Error("Ambiguous symlink in OMP session root");
|
|
61172
|
+
const file2 = path9.join(dir, item.name);
|
|
61173
|
+
if (item.isDirectory()) {
|
|
61174
|
+
if (/^\d{4}-\d\d-\d\d.*_[\da-f-]+$/i.test(item.name)) continue;
|
|
61175
|
+
await visit2(file2, depth + 1);
|
|
61176
|
+
} else if (item.isFile() && item.name.endsWith(".jsonl")) sources.set(await sourceId(file2), file2);
|
|
61177
|
+
}
|
|
61178
|
+
}
|
|
61179
|
+
await visit2(root, 0);
|
|
61180
|
+
return sources;
|
|
61181
|
+
}
|
|
61182
|
+
|
|
61183
|
+
// extension/session-cleanup.ts
|
|
60791
61184
|
var DEFAULT = { mode: "conservative", idleDays: 7 };
|
|
60792
61185
|
var UUID = /^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/i;
|
|
60793
|
-
var
|
|
60794
|
-
function validate2(
|
|
60795
|
-
|
|
60796
|
-
|
|
60797
|
-
|
|
61186
|
+
var tails2 = /* @__PURE__ */ new Map();
|
|
61187
|
+
function validate2(p) {
|
|
61188
|
+
if (!p || !["off", "conservative", "timeout"].includes(p.mode) || !Number.isFinite(p.idleDays) || p.idleDays < 1 / 24 || p.idleDays > 3650) throw new Error("Cleanup requires off|conservative|timeout and idleDays between 1/24 and 3650");
|
|
61189
|
+
for (const k of ["maxSessions", "maxBytes", "batchSize"]) if (p[k] !== void 0 && (!Number.isSafeInteger(p[k]) || p[k] < (k === "batchSize" ? 1 : 0) || k === "batchSize" && p[k] > 100)) throw new Error(`Invalid cleanup ${k}`);
|
|
61190
|
+
if (p.orphanGraceDays !== void 0 && (!Number.isFinite(p.orphanGraceDays) || p.orphanGraceDays < 1 / 24 || p.orphanGraceDays > 3650)) throw new Error("Invalid orphanGraceDays");
|
|
61191
|
+
return { mode: p.mode, idleDays: p.idleDays, ...Object.fromEntries(["maxSessions", "maxBytes", "orphanGraceDays", "batchSize"].filter((k) => p[k] !== void 0).map((k) => [k, p[k]])) };
|
|
61192
|
+
}
|
|
61193
|
+
function loadCleanupPolicy(file2) {
|
|
61194
|
+
try {
|
|
61195
|
+
return validate2(JSON.parse(fs10.readFileSync(file2, "utf8")));
|
|
61196
|
+
} catch (e) {
|
|
61197
|
+
if (isMissingFileError(e)) return { ...DEFAULT };
|
|
61198
|
+
throw e;
|
|
60798
61199
|
}
|
|
60799
|
-
return { mode: candidate.mode, idleDays: candidate.idleDays };
|
|
60800
61200
|
}
|
|
60801
|
-
function saveCleanupPolicy(file2,
|
|
60802
|
-
writeJsonAtomic(file2, validate2(
|
|
61201
|
+
function saveCleanupPolicy(file2, p) {
|
|
61202
|
+
writeJsonAtomic(file2, validate2(p), false);
|
|
60803
61203
|
}
|
|
60804
61204
|
function live(pid) {
|
|
60805
61205
|
try {
|
|
60806
61206
|
process.kill(pid, 0);
|
|
60807
61207
|
return true;
|
|
60808
|
-
} catch (
|
|
60809
|
-
return
|
|
61208
|
+
} catch (e) {
|
|
61209
|
+
return e.code !== "ESRCH";
|
|
60810
61210
|
}
|
|
60811
61211
|
}
|
|
60812
|
-
|
|
60813
|
-
return createHash3("sha256").update(key).digest("hex");
|
|
60814
|
-
}
|
|
61212
|
+
var group = (key) => createHash3("sha256").update(key).digest("hex");
|
|
60815
61213
|
var SessionCleanup = class {
|
|
60816
61214
|
constructor(stateDir, acpDir = resolveAntigravityAcpDirectory(), now = Date.now, isLive = live) {
|
|
61215
|
+
this.stateDir = stateDir;
|
|
60817
61216
|
this.acpDir = acpDir;
|
|
60818
61217
|
this.now = now;
|
|
60819
61218
|
this.isLive = isLive;
|
|
60820
61219
|
this.policyPath = path10.join(stateDir, "cleanup.json");
|
|
60821
|
-
|
|
60822
|
-
this.registryPath = path10.join(stateDir, `cleanup-sessions-${root}.json`);
|
|
61220
|
+
this.registryPath = path10.join(stateDir, `cleanup-sessions-${createHash3("sha256").update(path10.resolve(acpDir)).digest("hex").slice(0, 16)}.json`);
|
|
60823
61221
|
}
|
|
61222
|
+
stateDir;
|
|
60824
61223
|
acpDir;
|
|
60825
61224
|
now;
|
|
60826
61225
|
isLive;
|
|
60827
61226
|
policyPath;
|
|
60828
61227
|
registryPath;
|
|
60829
61228
|
timer;
|
|
60830
|
-
|
|
60831
|
-
|
|
60832
|
-
|
|
60833
|
-
|
|
60834
|
-
|
|
60835
|
-
|
|
60836
|
-
|
|
60837
|
-
|
|
60838
|
-
|
|
60839
|
-
|
|
61229
|
+
nextBatch;
|
|
61230
|
+
collecting;
|
|
61231
|
+
touched = /* @__PURE__ */ new Map();
|
|
61232
|
+
intents = [];
|
|
61233
|
+
report = { owned: 0, active: 0, mapped: 0, unmapped: 0, ownedBytes: 0, overBudget: false, removed: 0, failures: 0, deferred: 0 };
|
|
61234
|
+
configure(mode, idleDays = loadCleanupPolicy(this.policyPath).idleDays) {
|
|
61235
|
+
saveCleanupPolicy(this.policyPath, { ...loadCleanupPolicy(this.policyPath), mode, idleDays });
|
|
61236
|
+
}
|
|
61237
|
+
budget(maxSessions, maxBytes) {
|
|
61238
|
+
saveCleanupPolicy(this.policyPath, { ...loadCleanupPolicy(this.policyPath), maxSessions, maxBytes });
|
|
61239
|
+
}
|
|
61240
|
+
async trackSource(id, file2) {
|
|
61241
|
+
const root = path10.resolve(this.stateDir, "..", "sessions");
|
|
61242
|
+
const relative = path10.relative(root, file2);
|
|
61243
|
+
if (!relative || relative.startsWith("..") || path10.isAbsolute(relative) || !file2.endsWith(".jsonl")) return;
|
|
61244
|
+
const stat = await sourceRoot(root);
|
|
61245
|
+
if (await sourceId(file2) !== id) return;
|
|
61246
|
+
await this.transaction(async (registry2) => {
|
|
61247
|
+
const mappings = JSON.parse(await afs.readFile(path10.join(this.stateDir, "sessions.json"), "utf8"));
|
|
61248
|
+
if (!Array.isArray(mappings)) throw new Error("Invalid mappings");
|
|
61249
|
+
for (const record3 of registry2.sessions) if (record3.owned && mappings.some((m) => m.piSessionId === id && m.acpSessionId === record3.id)) {
|
|
61250
|
+
record3.ompSource = { id, file: path10.resolve(file2), root, device: stat.dev, inode: stat.ino };
|
|
61251
|
+
delete record3.sourceDeleted;
|
|
60840
61252
|
}
|
|
60841
|
-
|
|
60842
|
-
this.cachedPolicy = { mtimeMs: stat.mtimeMs, size: stat.size, policy };
|
|
60843
|
-
return policy;
|
|
60844
|
-
} catch (error62) {
|
|
60845
|
-
if (isMissingFileError(error62)) return { ...DEFAULT };
|
|
60846
|
-
throw error62;
|
|
60847
|
-
}
|
|
60848
|
-
}
|
|
60849
|
-
configure(mode, idleDays = this.getPolicy().idleDays) {
|
|
60850
|
-
saveCleanupPolicy(this.policyPath, { mode, idleDays });
|
|
60851
|
-
this.cachedPolicy = void 0;
|
|
61253
|
+
});
|
|
60852
61254
|
}
|
|
60853
61255
|
status() {
|
|
60854
|
-
return { ...this.
|
|
61256
|
+
return { ...loadCleanupPolicy(this.policyPath), ...this.report, warning: this.report.overBudget ? "Soft budget exceeded; mapped and active sessions remain protected" : void 0, pendingLifecycleUpdates: this.intents.length, file: this.policyPath, scope: "adapter-owned local ACP data" };
|
|
60855
61257
|
}
|
|
60856
61258
|
start() {
|
|
60857
61259
|
if (this.timer) return;
|
|
60858
|
-
this.collect();
|
|
60859
|
-
this.timer = setInterval(() =>
|
|
61260
|
+
void this.collect();
|
|
61261
|
+
this.timer = setInterval(() => {
|
|
61262
|
+
void this.collect();
|
|
61263
|
+
}, 15 * 6e4);
|
|
60860
61264
|
this.timer.unref();
|
|
60861
61265
|
}
|
|
60862
|
-
stop() {
|
|
61266
|
+
async stop() {
|
|
60863
61267
|
clearInterval(this.timer);
|
|
61268
|
+
clearTimeout(this.nextBatch);
|
|
60864
61269
|
this.timer = void 0;
|
|
61270
|
+
this.nextBatch = void 0;
|
|
61271
|
+
await this.collecting;
|
|
61272
|
+
await tails2.get(this.registryPath)?.catch(() => {
|
|
61273
|
+
});
|
|
60865
61274
|
}
|
|
60866
61275
|
transaction(action) {
|
|
60867
|
-
|
|
60868
|
-
|
|
60869
|
-
|
|
60870
|
-
|
|
61276
|
+
const pending = (tails2.get(this.registryPath) ?? Promise.resolve()).catch(() => {
|
|
61277
|
+
}).then(async () => {
|
|
61278
|
+
await afs.mkdir(path10.dirname(this.registryPath), { recursive: true, mode: 448 });
|
|
61279
|
+
const release = await (0, import_proper_lockfile2.lock)(this.registryPath, { realpath: false, stale: 6e5, retries: 0 });
|
|
60871
61280
|
try {
|
|
60872
|
-
|
|
60873
|
-
|
|
60874
|
-
|
|
60875
|
-
|
|
60876
|
-
|
|
60877
|
-
throw new Error("Invalid ACP cleanup registry; refusing deletion");
|
|
60878
|
-
}
|
|
60879
|
-
if (this.pendingTouches.size > 0) {
|
|
60880
|
-
for (const r of registry2.sessions) {
|
|
60881
|
-
const touched = this.pendingTouches.get(r.id);
|
|
60882
|
-
if (touched !== void 0 && touched > r.lastUsed) r.lastUsed = touched;
|
|
61281
|
+
let r = { version: 1, sessions: [] };
|
|
61282
|
+
try {
|
|
61283
|
+
r = JSON.parse(await afs.readFile(this.registryPath, "utf8"));
|
|
61284
|
+
} catch (e) {
|
|
61285
|
+
if (!isMissingFileError(e)) throw e;
|
|
60883
61286
|
}
|
|
60884
|
-
|
|
61287
|
+
if (r.version !== 1 || !Array.isArray(r.sessions) || !r.sessions.every((v) => UUID.test(v.id) && typeof v.owned === "boolean" && Number.isFinite(v.lastUsed) && Array.isArray(v.leases) && (v.replaced === void 0 || typeof v.replaced === "boolean") && (v.orphanedAt === void 0 || Number.isFinite(v.orphanedAt)) && (v.retiredFor === void 0 || /^[a-f0-9]{64}$/.test(v.retiredFor)) && (v.sourceDeleted === void 0 || typeof v.sourceDeleted === "boolean") && (v.ompSource === void 0 || typeof v.ompSource.id === "string" && typeof v.ompSource.file === "string" && typeof v.ompSource.root === "string" && Number.isFinite(v.ompSource.device) && Number.isFinite(v.ompSource.inode) && (v.ompSource.missingSince === void 0 || Number.isFinite(v.ompSource.missingSince))) && v.leases.every((l) => typeof l.token === "string" && Number.isSafeInteger(l.pid) && l.pid > 0 && Number.isSafeInteger(l.serverPid) && l.serverPid > 0))) throw new Error("Invalid ACP cleanup registry; refusing deletion");
|
|
61288
|
+
const actions = this.intents.slice();
|
|
61289
|
+
for (const apply of actions) apply(r);
|
|
61290
|
+
for (const v of r.sessions) if (this.touched.has(v.id)) v.lastUsed = Math.max(v.lastUsed, this.touched.get(v.id));
|
|
61291
|
+
const result = await action(r), tmp = this.registryPath + "." + randomUUID3() + ".tmp";
|
|
61292
|
+
try {
|
|
61293
|
+
await afs.writeFile(tmp, JSON.stringify(r), { mode: 384, flag: "wx" });
|
|
61294
|
+
await afs.rename(tmp, this.registryPath);
|
|
61295
|
+
} finally {
|
|
61296
|
+
await afs.rm(tmp, { force: true });
|
|
61297
|
+
}
|
|
61298
|
+
this.intents.splice(0, actions.length);
|
|
61299
|
+
return result;
|
|
61300
|
+
} finally {
|
|
61301
|
+
await release();
|
|
60885
61302
|
}
|
|
60886
|
-
|
|
60887
|
-
|
|
60888
|
-
|
|
60889
|
-
|
|
60890
|
-
|
|
60891
|
-
}
|
|
61303
|
+
});
|
|
61304
|
+
tails2.set(this.registryPath, pending);
|
|
61305
|
+
void pending.finally(() => {
|
|
61306
|
+
if (tails2.get(this.registryPath) === pending) tails2.delete(this.registryPath);
|
|
61307
|
+
}).catch(() => {
|
|
61308
|
+
});
|
|
61309
|
+
return pending;
|
|
60892
61310
|
}
|
|
60893
|
-
acquire(id, owned, serverPid) {
|
|
61311
|
+
async acquire(id, owned, serverPid) {
|
|
60894
61312
|
if (!UUID.test(id) || !Number.isSafeInteger(serverPid) || serverPid <= 0) throw new Error("Invalid ACP cleanup lease");
|
|
60895
|
-
return this.transaction((
|
|
60896
|
-
|
|
60897
|
-
|
|
60898
|
-
|
|
60899
|
-
|
|
60900
|
-
|
|
60901
|
-
|
|
60902
|
-
|
|
60903
|
-
|
|
60904
|
-
|
|
60905
|
-
this.
|
|
61313
|
+
return this.transaction((r) => {
|
|
61314
|
+
let v = r.sessions.find((v2) => v2.id === id);
|
|
61315
|
+
if (!v) {
|
|
61316
|
+
v = { id, owned, lastUsed: this.now(), leases: [] };
|
|
61317
|
+
r.sessions.push(v);
|
|
61318
|
+
}
|
|
61319
|
+
const token2 = randomUUID3();
|
|
61320
|
+
v.leases.push({ token: token2, pid: process.pid, serverPid });
|
|
61321
|
+
v.lastUsed = this.now();
|
|
61322
|
+
delete v.orphanedAt;
|
|
61323
|
+
this.touched.set(id, v.lastUsed);
|
|
60906
61324
|
return token2;
|
|
60907
61325
|
});
|
|
60908
61326
|
}
|
|
60909
|
-
|
|
60910
|
-
this.
|
|
60911
|
-
|
|
60912
|
-
|
|
60913
|
-
|
|
61327
|
+
async intent(action) {
|
|
61328
|
+
if (this.intents.length >= 1024) throw new Error("Lifecycle retry queue full; preserving files");
|
|
61329
|
+
this.intents.push(action);
|
|
61330
|
+
try {
|
|
61331
|
+
await this.transaction(() => {
|
|
61332
|
+
});
|
|
61333
|
+
} catch (e) {
|
|
61334
|
+
this.report.failures++;
|
|
61335
|
+
throw e;
|
|
61336
|
+
}
|
|
60914
61337
|
}
|
|
60915
|
-
|
|
60916
|
-
|
|
60917
|
-
|
|
60918
|
-
|
|
60919
|
-
|
|
60920
|
-
|
|
61338
|
+
async release(token2, background = false) {
|
|
61339
|
+
await this.intent((r) => {
|
|
61340
|
+
for (const v of r.sessions) v.leases = v.leases.filter((l) => l.token !== token2);
|
|
61341
|
+
});
|
|
61342
|
+
if (background) {
|
|
61343
|
+
void this.collect();
|
|
61344
|
+
return 0;
|
|
60921
61345
|
}
|
|
60922
|
-
this.
|
|
60923
|
-
|
|
60924
|
-
|
|
60925
|
-
|
|
60926
|
-
|
|
60927
|
-
|
|
61346
|
+
return this.collect();
|
|
61347
|
+
}
|
|
61348
|
+
async touch(id) {
|
|
61349
|
+
const last = this.touched.get(id);
|
|
61350
|
+
this.touched.set(id, this.now());
|
|
61351
|
+
if (last !== void 0 && this.now() - last < 6e4) return;
|
|
61352
|
+
await this.transaction(() => {
|
|
60928
61353
|
});
|
|
60929
61354
|
}
|
|
60930
61355
|
retire(key, id) {
|
|
60931
|
-
this.
|
|
60932
|
-
const
|
|
60933
|
-
if (
|
|
60934
|
-
|
|
60935
|
-
|
|
61356
|
+
return this.intent((r) => {
|
|
61357
|
+
const v = r.sessions.find((v2) => v2.id === id);
|
|
61358
|
+
if (v?.owned) {
|
|
61359
|
+
v.retiredFor = group(key);
|
|
61360
|
+
v.replaced = false;
|
|
60936
61361
|
}
|
|
60937
61362
|
});
|
|
60938
61363
|
}
|
|
60939
|
-
confirm(key, replacement) {
|
|
60940
|
-
this.
|
|
60941
|
-
for (const
|
|
61364
|
+
async confirm(key, replacement, background = false) {
|
|
61365
|
+
await this.intent((r) => {
|
|
61366
|
+
for (const v of r.sessions) if (v.id !== replacement && v.retiredFor === group(key)) v.replaced = true;
|
|
60942
61367
|
});
|
|
60943
|
-
|
|
61368
|
+
if (background) {
|
|
61369
|
+
void this.collect();
|
|
61370
|
+
return 0;
|
|
61371
|
+
}
|
|
61372
|
+
return this.collect();
|
|
60944
61373
|
}
|
|
60945
61374
|
collect() {
|
|
60946
|
-
|
|
60947
|
-
|
|
60948
|
-
|
|
60949
|
-
return
|
|
60950
|
-
|
|
60951
|
-
|
|
60952
|
-
|
|
60953
|
-
|
|
60954
|
-
|
|
60955
|
-
|
|
60956
|
-
|
|
61375
|
+
if (this.collecting) return this.collecting;
|
|
61376
|
+
const pending = this.collectOnce().catch(() => {
|
|
61377
|
+
this.report.failures++;
|
|
61378
|
+
return 0;
|
|
61379
|
+
});
|
|
61380
|
+
this.collecting = pending;
|
|
61381
|
+
void pending.finally(() => {
|
|
61382
|
+
if (this.collecting === pending) this.collecting = void 0;
|
|
61383
|
+
if (this.timer && this.report.deferred > 0 && !this.nextBatch) {
|
|
61384
|
+
this.nextBatch = setTimeout(() => {
|
|
61385
|
+
this.nextBatch = void 0;
|
|
61386
|
+
void this.collect();
|
|
61387
|
+
}, 1e3);
|
|
61388
|
+
this.nextBatch.unref();
|
|
61389
|
+
}
|
|
61390
|
+
});
|
|
61391
|
+
return pending;
|
|
61392
|
+
}
|
|
61393
|
+
async collectOnce() {
|
|
61394
|
+
const policy = loadCleanupPolicy(this.policyPath);
|
|
61395
|
+
return this.transaction(async (registry2) => {
|
|
61396
|
+
let mappings = [];
|
|
61397
|
+
try {
|
|
61398
|
+
const p = JSON.parse(await afs.readFile(path10.join(this.stateDir, "sessions.json"), "utf8"));
|
|
61399
|
+
if (!Array.isArray(p)) throw new Error("Invalid mappings");
|
|
61400
|
+
mappings = p;
|
|
61401
|
+
} catch (e) {
|
|
61402
|
+
if (!isMissingFileError(e)) throw e;
|
|
61403
|
+
}
|
|
61404
|
+
const mapped = new Set(mappings.map((v) => v.acpSessionId));
|
|
61405
|
+
const report = { owned: 0, active: 0, mapped: 0, unmapped: 0, ownedBytes: 0, overBudget: false, removed: 0, failures: this.report.failures, deferred: 0 };
|
|
61406
|
+
let dirs;
|
|
61407
|
+
const owned = [];
|
|
61408
|
+
const sourceScans = /* @__PURE__ */ new Map();
|
|
61409
|
+
for (const v of registry2.sessions) {
|
|
61410
|
+
v.leases = v.leases.filter((l) => this.isLive(l.pid) || this.isLive(l.serverPid));
|
|
61411
|
+
if (!v.owned) continue;
|
|
61412
|
+
if (policy.mode !== "off" && v.ompSource && !v.leases.length) {
|
|
61413
|
+
delete v.sourceDeleted;
|
|
60957
61414
|
try {
|
|
60958
|
-
|
|
60959
|
-
|
|
60960
|
-
|
|
60961
|
-
|
|
60962
|
-
|
|
60963
|
-
|
|
61415
|
+
const source = v.ompSource, root = path10.resolve(this.stateDir, "..", "sessions");
|
|
61416
|
+
const relative = path10.relative(root, source.file);
|
|
61417
|
+
if (source.root !== root || !relative || relative.startsWith("..") || path10.isAbsolute(relative)) throw new Error("Invalid source scope");
|
|
61418
|
+
const stat = await sourceRoot(root);
|
|
61419
|
+
if (stat.dev !== source.device || stat.ino !== source.inode) throw new Error("OMP storage changed; preserving session");
|
|
61420
|
+
let missing = false;
|
|
61421
|
+
try {
|
|
61422
|
+
await afs.lstat(source.file);
|
|
61423
|
+
} catch (e) {
|
|
61424
|
+
if (!isMissingFileError(e)) throw e;
|
|
61425
|
+
missing = true;
|
|
61426
|
+
}
|
|
61427
|
+
if (!missing) {
|
|
61428
|
+
delete source.missingSince;
|
|
61429
|
+
} else {
|
|
61430
|
+
if (!sourceScans.has(root)) sourceScans.set(root, findSources(root));
|
|
61431
|
+
const moved = (await sourceScans.get(root)).get(source.id);
|
|
61432
|
+
if (moved) {
|
|
61433
|
+
source.file = moved;
|
|
61434
|
+
delete source.missingSince;
|
|
61435
|
+
} else if (source.missingSince === void 0) source.missingSince = this.now();
|
|
61436
|
+
else if (this.now() - source.missingSince >= 6e4) {
|
|
61437
|
+
const finalRoot = await sourceRoot(root);
|
|
61438
|
+
if (finalRoot.dev !== source.device || finalRoot.ino !== source.inode) throw new Error("OMP storage changed during scan");
|
|
61439
|
+
let restored = false;
|
|
61440
|
+
try {
|
|
61441
|
+
await afs.lstat(source.file);
|
|
61442
|
+
restored = true;
|
|
61443
|
+
delete source.missingSince;
|
|
61444
|
+
} catch (e) {
|
|
61445
|
+
if (!isMissingFileError(e)) throw e;
|
|
61446
|
+
}
|
|
61447
|
+
if (!restored) {
|
|
61448
|
+
await new AcpSessionStore(path10.join(this.stateDir, "sessions.json")).removeIfMatches(source.id, v.id);
|
|
61449
|
+
const latest = JSON.parse(await afs.readFile(path10.join(this.stateDir, "sessions.json"), "utf8").catch((e) => {
|
|
61450
|
+
if (isMissingFileError(e)) return "[]";
|
|
61451
|
+
throw e;
|
|
61452
|
+
}));
|
|
61453
|
+
if (!Array.isArray(latest)) throw new Error("Invalid mappings");
|
|
61454
|
+
if (!latest.some((m) => m.acpSessionId === v.id)) {
|
|
61455
|
+
mapped.delete(v.id);
|
|
61456
|
+
v.sourceDeleted = true;
|
|
61457
|
+
}
|
|
61458
|
+
}
|
|
61459
|
+
}
|
|
61460
|
+
}
|
|
60964
61461
|
} catch {
|
|
60965
|
-
|
|
61462
|
+
report.failures++;
|
|
60966
61463
|
}
|
|
60967
|
-
}
|
|
60968
|
-
|
|
60969
|
-
|
|
60970
|
-
|
|
60971
|
-
|
|
60972
|
-
|
|
61464
|
+
}
|
|
61465
|
+
report.owned++;
|
|
61466
|
+
if (v.leases.length) report.active++;
|
|
61467
|
+
if (mapped.has(v.id)) {
|
|
61468
|
+
report.mapped++;
|
|
61469
|
+
delete v.orphanedAt;
|
|
61470
|
+
} else {
|
|
61471
|
+
report.unmapped++;
|
|
61472
|
+
v.orphanedAt ??= this.now();
|
|
61473
|
+
}
|
|
61474
|
+
let size = 0;
|
|
61475
|
+
try {
|
|
61476
|
+
dirs ??= await this.verifyRoot();
|
|
61477
|
+
for (const target of this.targets(v.id, dirs)) size += await this.inspect(target);
|
|
61478
|
+
} catch {
|
|
61479
|
+
report.failures++;
|
|
61480
|
+
}
|
|
61481
|
+
report.ownedBytes += size;
|
|
61482
|
+
owned.push({ v, size });
|
|
61483
|
+
}
|
|
61484
|
+
const over = () => Boolean(policy.maxSessions && report.owned > policy.maxSessions || policy.maxBytes && report.ownedBytes > policy.maxBytes);
|
|
61485
|
+
report.overBudget = over();
|
|
61486
|
+
if (policy.mode !== "off") for (const { v, size } of owned.sort((a, b) => a.v.lastUsed - b.v.lastUsed)) {
|
|
61487
|
+
if (mapped.has(v.id) || v.leases.length) continue;
|
|
61488
|
+
const expired = policy.mode === "timeout" && (this.now() - v.lastUsed >= policy.idleDays * 864e5 || over() && this.now() - v.orphanedAt >= (policy.orphanGraceDays ?? 1) * 864e5);
|
|
61489
|
+
if (!v.replaced && !v.sourceDeleted && !expired) continue;
|
|
61490
|
+
if (report.removed >= (policy.batchSize ?? 8)) {
|
|
61491
|
+
report.deferred++;
|
|
61492
|
+
continue;
|
|
61493
|
+
}
|
|
61494
|
+
try {
|
|
61495
|
+
dirs ??= await this.verifyRoot();
|
|
61496
|
+
const targets = this.targets(v.id, dirs);
|
|
61497
|
+
for (const target of targets) await this.inspect(target);
|
|
61498
|
+
for (const target of targets) await afs.rm(target, { recursive: true, force: true });
|
|
61499
|
+
registry2.sessions = registry2.sessions.filter((r) => r !== v);
|
|
61500
|
+
this.touched.delete(v.id);
|
|
61501
|
+
report.removed++;
|
|
61502
|
+
report.owned--;
|
|
61503
|
+
report.unmapped--;
|
|
61504
|
+
report.ownedBytes -= size;
|
|
61505
|
+
} catch {
|
|
61506
|
+
report.failures++;
|
|
61507
|
+
}
|
|
61508
|
+
}
|
|
61509
|
+
registry2.sessions = registry2.sessions.filter((v) => v.owned || v.leases.length);
|
|
61510
|
+
report.overBudget = over();
|
|
61511
|
+
this.report = report;
|
|
61512
|
+
return report.removed;
|
|
61513
|
+
});
|
|
61514
|
+
}
|
|
61515
|
+
targets(id, d) {
|
|
61516
|
+
return [".db", ".db-wal", ".db-shm", ".db-journal", ".meta"].map((s) => path10.join(d.conversations, id + s)).concat(path10.join(d.brain, id));
|
|
60973
61517
|
}
|
|
60974
|
-
|
|
61518
|
+
async verifyRoot() {
|
|
60975
61519
|
const root = path10.resolve(this.acpDir);
|
|
60976
|
-
if (
|
|
60977
|
-
const
|
|
60978
|
-
const
|
|
60979
|
-
|
|
60980
|
-
|
|
60981
|
-
|
|
60982
|
-
} catch (error62) {
|
|
60983
|
-
if (!isMissingFileError(error62)) throw error62;
|
|
60984
|
-
}
|
|
61520
|
+
if (await afs.realpath(root) !== root) throw new Error("Symlinked ACP root");
|
|
61521
|
+
const dirs = { conversations: path10.join(root, "conversations"), brain: path10.join(root, "brain") };
|
|
61522
|
+
for (const d of Object.values(dirs)) try {
|
|
61523
|
+
if (await afs.realpath(d) !== d) throw new Error("Symlinked cleanup directory");
|
|
61524
|
+
} catch (e) {
|
|
61525
|
+
if (!isMissingFileError(e)) throw e;
|
|
60985
61526
|
}
|
|
60986
|
-
return
|
|
61527
|
+
return dirs;
|
|
60987
61528
|
}
|
|
60988
|
-
|
|
60989
|
-
|
|
60990
|
-
|
|
60991
|
-
|
|
60992
|
-
|
|
60993
|
-
|
|
60994
|
-
|
|
60995
|
-
|
|
60996
|
-
|
|
60997
|
-
|
|
60998
|
-
|
|
60999
|
-
|
|
61000
|
-
|
|
61001
|
-
} catch (error62) {
|
|
61002
|
-
if (isMissingFileError(error62)) return;
|
|
61003
|
-
throw error62;
|
|
61004
|
-
}
|
|
61005
|
-
if (stat.isSymbolicLink() || !stat.isDirectory() && !stat.isFile()) throw new Error("Unsafe cleanup target");
|
|
61006
|
-
if (stat.isDirectory()) for (const child of fs10.readdirSync(file2)) inspect(path10.join(file2, child));
|
|
61007
|
-
};
|
|
61008
|
-
for (const target of targets) inspect(target);
|
|
61009
|
-
for (const target of targets) fs10.rmSync(target, { recursive: true, force: true });
|
|
61529
|
+
async inspect(file2) {
|
|
61530
|
+
let s;
|
|
61531
|
+
try {
|
|
61532
|
+
s = await afs.lstat(file2);
|
|
61533
|
+
} catch (e) {
|
|
61534
|
+
if (isMissingFileError(e)) return 0;
|
|
61535
|
+
throw e;
|
|
61536
|
+
}
|
|
61537
|
+
if (s.isSymbolicLink() || !s.isDirectory() && !s.isFile()) throw new Error("Unsafe cleanup target");
|
|
61538
|
+
if (!s.isDirectory()) return s.size;
|
|
61539
|
+
let size = 0;
|
|
61540
|
+
for (const f of await afs.readdir(file2)) size += await this.inspect(path10.join(file2, f));
|
|
61541
|
+
return size;
|
|
61010
61542
|
}
|
|
61011
61543
|
};
|
|
61012
61544
|
|