@cortexkit/opencode-antigravity-auth 3.0.8 → 3.0.10
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/dist/cli.js +584 -189
- package/dist/cli.js.map +4 -4
- package/dist/cli.meta.json +122 -48
- package/dist/index.js +920 -336
- package/dist/index.js.map +4 -4
- package/dist/index.meta.json +141 -64
- package/dist/server.js +954 -368
- package/dist/server.js.map +4 -4
- package/dist/server.meta.json +1 -1
- package/dist/src/common-auth-embedded/auth-menu/login.d.ts +6 -10
- package/dist/src/common-auth-embedded/auth-menu/login.js +14 -11
- package/dist/src/common-auth-embedded/claustrum/consumer.d.ts +8 -2
- package/dist/src/common-auth-embedded/claustrum/consumer.js +64 -21
- package/dist/src/common-auth-embedded/claustrum/index.d.ts +2 -1
- package/dist/src/common-auth-embedded/claustrum/index.js +1 -0
- package/dist/src/common-auth-embedded/claustrum/insula.d.ts +23 -0
- package/dist/src/common-auth-embedded/claustrum/insula.js +64 -2
- package/dist/src/common-auth-embedded/claustrum/quota-writer.d.ts +18 -0
- package/dist/src/common-auth-embedded/claustrum/quota-writer.js +253 -0
- package/dist/src/common-auth-embedded/claustrum/roster.d.ts +18 -2
- package/dist/src/common-auth-embedded/claustrum/roster.js +100 -43
- package/dist/src/common-auth-embedded/fs/with-lock.d.ts +1 -0
- package/dist/src/common-auth-embedded/fs/with-lock.js +2 -0
- package/dist/src/common-auth-embedded/quota/format.d.ts +19 -0
- package/dist/src/common-auth-embedded/quota/format.js +50 -5
- package/dist/src/common-auth-embedded/quota/index.d.ts +3 -3
- package/dist/src/common-auth-embedded/quota/index.js +2 -2
- package/dist/src/common-auth-embedded/quota/map.d.ts +24 -1
- package/dist/src/common-auth-embedded/quota/map.js +31 -6
- package/dist/src/common-auth-embedded/quota/merge.d.ts +6 -1
- package/dist/src/common-auth-embedded/quota/merge.js +17 -3
- package/dist/src/common-auth-embedded/quota/projection.d.ts +3 -1
- package/dist/src/common-auth-embedded/quota/projection.js +3 -1
- package/dist/src/common-auth-embedded/setup/process-fence.d.ts +7 -0
- package/dist/src/common-auth-embedded/setup/process-fence.js +5 -3
- package/dist/src/common-auth-embedded/source-output.json +95 -79
- package/dist/src/plugin/background-vault-quota-refresh.d.ts.map +1 -1
- package/dist/src/plugin/background-vault-quota-refresh.js +8 -1
- package/dist/src/plugin/background-vault-quota-refresh.js.map +1 -1
- package/dist/src/plugin/index.d.ts.map +1 -1
- package/dist/src/plugin/index.js +1 -0
- package/dist/src/plugin/index.js.map +1 -1
- package/dist/src/plugin/quota.d.ts +1 -1
- package/dist/src/plugin/quota.d.ts.map +1 -1
- package/dist/src/plugin/quota.js +17 -5
- package/dist/src/plugin/quota.js.map +1 -1
- package/dist/src/plugin/request-helpers.d.ts +5 -0
- package/dist/src/plugin/request-helpers.d.ts.map +1 -1
- package/dist/src/plugin/request-helpers.js +1 -0
- package/dist/src/plugin/request-helpers.js.map +1 -1
- package/dist/src/plugin/shared/request-services.d.ts.map +1 -1
- package/dist/src/plugin/shared/request-services.js +123 -5
- package/dist/src/plugin/shared/request-services.js.map +1 -1
- package/dist/src/plugin/shared/vault-request-credentials.d.ts +9 -6
- package/dist/src/plugin/shared/vault-request-credentials.d.ts.map +1 -1
- package/dist/src/plugin/shared/vault-request-credentials.js +9 -4
- package/dist/src/plugin/shared/vault-request-credentials.js.map +1 -1
- package/dist/src/plugin/vault-custody.d.ts +2 -0
- package/dist/src/plugin/vault-custody.d.ts.map +1 -1
- package/dist/src/plugin/vault-custody.js +9 -0
- package/dist/src/plugin/vault-custody.js.map +1 -1
- package/dist/src/plugin/vault-insula-quota.d.ts +6 -0
- package/dist/src/plugin/vault-insula-quota.d.ts.map +1 -0
- package/dist/src/plugin/vault-insula-quota.js +50 -0
- package/dist/src/plugin/vault-insula-quota.js.map +1 -0
- package/dist/src/plugin/vault-quota-outcome.d.ts +1 -1
- package/dist/src/plugin/vault-quota-outcome.d.ts.map +1 -1
- package/dist/src/plugin/vault-quota-outcome.js.map +1 -1
- package/dist/tui-build-map.json +21 -21
- package/dist/tui-ga-build-map.json +21 -21
- package/dist/types/src/common-auth-embedded/claustrum/consumer.d.ts +8 -2
- package/dist/types/src/common-auth-embedded/claustrum/index.d.ts +2 -1
- package/dist/types/src/common-auth-embedded/claustrum/insula.d.ts +23 -0
- package/dist/types/src/common-auth-embedded/claustrum/quota-writer.d.ts +18 -0
- package/dist/types/src/common-auth-embedded/claustrum/roster.d.ts +18 -2
- package/dist/types/src/common-auth-embedded/quota/format.d.ts +19 -0
- package/dist/types/src/common-auth-embedded/quota/index.d.ts +3 -3
- package/dist/types/src/common-auth-embedded/quota/map.d.ts +24 -1
- package/dist/types/src/common-auth-embedded/quota/merge.d.ts +6 -1
- package/dist/types/src/common-auth-embedded/quota/projection.d.ts +3 -1
- package/dist/types/src/common-auth-embedded/setup/process-fence.d.ts +7 -0
- package/dist/types/src/plugin/background-vault-quota-refresh.d.ts.map +1 -1
- package/dist/types/src/plugin/config/schema.d.ts +2 -2
- package/dist/types/src/plugin/index.d.ts.map +1 -1
- package/dist/types/src/plugin/quota.d.ts +1 -1
- package/dist/types/src/plugin/quota.d.ts.map +1 -1
- package/dist/types/src/plugin/request-helpers.d.ts +5 -0
- package/dist/types/src/plugin/request-helpers.d.ts.map +1 -1
- package/dist/types/src/plugin/shared/request-services.d.ts.map +1 -1
- package/dist/types/src/plugin/shared/vault-request-credentials.d.ts +9 -6
- package/dist/types/src/plugin/shared/vault-request-credentials.d.ts.map +1 -1
- package/dist/types/src/plugin/vault-custody.d.ts +2 -0
- package/dist/types/src/plugin/vault-custody.d.ts.map +1 -1
- package/dist/types/src/plugin/vault-insula-quota.d.ts +6 -0
- package/dist/types/src/plugin/vault-insula-quota.d.ts.map +1 -0
- package/dist/types/src/plugin/vault-quota-outcome.d.ts +1 -1
- package/dist/types/src/plugin/vault-quota-outcome.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/common-auth-embedded/auth-menu/login.d.ts +6 -10
- package/src/common-auth-embedded/auth-menu/login.js +14 -11
- package/src/common-auth-embedded/claustrum/consumer.d.ts +8 -2
- package/src/common-auth-embedded/claustrum/consumer.js +64 -21
- package/src/common-auth-embedded/claustrum/index.d.ts +2 -1
- package/src/common-auth-embedded/claustrum/index.js +1 -0
- package/src/common-auth-embedded/claustrum/insula.d.ts +23 -0
- package/src/common-auth-embedded/claustrum/insula.js +64 -2
- package/src/common-auth-embedded/claustrum/quota-writer.d.ts +18 -0
- package/src/common-auth-embedded/claustrum/quota-writer.js +253 -0
- package/src/common-auth-embedded/claustrum/roster.d.ts +18 -2
- package/src/common-auth-embedded/claustrum/roster.js +100 -43
- package/src/common-auth-embedded/fs/with-lock.d.ts +1 -0
- package/src/common-auth-embedded/fs/with-lock.js +2 -0
- package/src/common-auth-embedded/quota/format.d.ts +19 -0
- package/src/common-auth-embedded/quota/format.js +50 -5
- package/src/common-auth-embedded/quota/index.d.ts +3 -3
- package/src/common-auth-embedded/quota/index.js +2 -2
- package/src/common-auth-embedded/quota/map.d.ts +24 -1
- package/src/common-auth-embedded/quota/map.js +31 -6
- package/src/common-auth-embedded/quota/merge.d.ts +6 -1
- package/src/common-auth-embedded/quota/merge.js +17 -3
- package/src/common-auth-embedded/quota/projection.d.ts +3 -1
- package/src/common-auth-embedded/quota/projection.js +3 -1
- package/src/common-auth-embedded/setup/process-fence.d.ts +7 -0
- package/src/common-auth-embedded/setup/process-fence.js +5 -3
- package/src/common-auth-embedded/source-output.json +95 -79
- package/src/tui-compiled/common-auth-embedded/quota/format.js +50 -5
- package/src/tui-compiled/common-auth-embedded/quota/index.js +2 -2
- package/src/tui-compiled/common-auth-embedded/quota/map.js +31 -6
- package/src/tui-compiled/common-auth-embedded/quota/merge.js +17 -3
- package/src/tui-compiled/common-auth-embedded/quota/projection.js +3 -1
- package/src/tui-ga-compiled/shared/1ff34afa7c42d196-projection.js +3 -1
- package/src/tui-ga-compiled/shared/77138df80c7ae006-map.js +31 -6
- package/src/tui-ga-compiled/shared/aef2402f8fc342f0-format.js +50 -5
- package/src/tui-ga-compiled/shared/bf17cbee28e58197-index.js +2 -2
- package/src/tui-ga-compiled/shared/ecc214300932dfb6-merge.js +17 -3
- package/src/tui-ga-raw/shared/1ff34afa7c42d196-projection.js +3 -1
- package/src/tui-ga-raw/shared/77138df80c7ae006-map.js +31 -6
- package/src/tui-ga-raw/shared/aef2402f8fc342f0-format.js +50 -5
- package/src/tui-ga-raw/shared/bf17cbee28e58197-index.js +2 -2
- package/src/tui-ga-raw/shared/ecc214300932dfb6-merge.js +17 -3
- package/src/tui-raw/common-auth-embedded/quota/format.js +50 -5
- package/src/tui-raw/common-auth-embedded/quota/index.js +2 -2
- package/src/tui-raw/common-auth-embedded/quota/map.js +31 -6
- package/src/tui-raw/common-auth-embedded/quota/merge.js +17 -3
- package/src/tui-raw/common-auth-embedded/quota/projection.js +3 -1
package/dist/cli.js
CHANGED
|
@@ -65,6 +65,12 @@ function isQuotaCounter(value) {
|
|
|
65
65
|
function isQuotaCounters(value) {
|
|
66
66
|
return isRecord2(value) && Object.values(value).every(isQuotaCounter);
|
|
67
67
|
}
|
|
68
|
+
function isBoolean(value) {
|
|
69
|
+
return typeof value === "boolean";
|
|
70
|
+
}
|
|
71
|
+
function isQuotaCredits(value) {
|
|
72
|
+
return isRecord2(value) && typeof value.hasCredits === "boolean" && typeof value.unlimited === "boolean" && optional2(value, "balance", isFiniteNumber) && optional2(value, "overageLimitReached", isBoolean) && isFiniteNumber(value.checkedAt);
|
|
73
|
+
}
|
|
68
74
|
function readQuotaCounters(value) {
|
|
69
75
|
if (!isRecord2(value))
|
|
70
76
|
return void 0;
|
|
@@ -76,11 +82,16 @@ function decodeQuotaMap(value) {
|
|
|
76
82
|
return value;
|
|
77
83
|
if (!isRecord2(value))
|
|
78
84
|
return void 0;
|
|
79
|
-
const { counters: rawCounters, ...rest } = value;
|
|
85
|
+
const { counters: rawCounters, credits: rawCredits, ...rest } = value;
|
|
80
86
|
if (!isQuotaMap(rest))
|
|
81
87
|
return void 0;
|
|
82
88
|
const counters = readQuotaCounters(rawCounters);
|
|
83
|
-
|
|
89
|
+
const credits = isQuotaCredits(rawCredits) ? rawCredits : void 0;
|
|
90
|
+
return {
|
|
91
|
+
...rest,
|
|
92
|
+
...counters === void 0 ? {} : { counters },
|
|
93
|
+
...credits === void 0 ? {} : { credits }
|
|
94
|
+
};
|
|
84
95
|
}
|
|
85
96
|
function isQuotaMap(value) {
|
|
86
97
|
if (!isRecord2(value) || !Array.isArray(value.limits))
|
|
@@ -94,7 +105,7 @@ function isQuotaMap(value) {
|
|
|
94
105
|
return false;
|
|
95
106
|
seen.add(key);
|
|
96
107
|
}
|
|
97
|
-
return optional2(value, "budget", isCreditBudgetEntry) && optional2(value, "counters", isQuotaCounters);
|
|
108
|
+
return optional2(value, "budget", isCreditBudgetEntry) && optional2(value, "counters", isQuotaCounters) && optional2(value, "credits", isQuotaCredits);
|
|
98
109
|
}
|
|
99
110
|
var ALL_SCOPE, DEFAULT_REQUIRED_LABELS;
|
|
100
111
|
var init_map = __esm({
|
|
@@ -157,7 +168,7 @@ function isQuotaObservation(value) {
|
|
|
157
168
|
}
|
|
158
169
|
if (!coverage.every(isObservedPair))
|
|
159
170
|
return false;
|
|
160
|
-
return (value.budget === void 0 || isObservedBudget(value.budget)) && (value.counters === void 0 || isQuotaCounters(value.counters));
|
|
171
|
+
return (value.budget === void 0 || isObservedBudget(value.budget)) && (value.counters === void 0 || isQuotaCounters(value.counters)) && (value.credits === void 0 || isQuotaCredits(value.credits));
|
|
161
172
|
}
|
|
162
173
|
function compareEntries(left, right) {
|
|
163
174
|
if (left.scope !== right.scope)
|
|
@@ -183,6 +194,14 @@ function mergeCounters(stored, observed) {
|
|
|
183
194
|
}
|
|
184
195
|
return counters.size === 0 ? void 0 : Object.fromEntries(counters);
|
|
185
196
|
}
|
|
197
|
+
function mergeCredits(stored, observed) {
|
|
198
|
+
if (observed === void 0)
|
|
199
|
+
return stored;
|
|
200
|
+
if (stored !== void 0 && observed.checkedAt < stored.checkedAt) {
|
|
201
|
+
return stored;
|
|
202
|
+
}
|
|
203
|
+
return { ...observed };
|
|
204
|
+
}
|
|
186
205
|
function mergeQuotaObservation(stored, observation) {
|
|
187
206
|
const decoded = stored === void 0 ? void 0 : decodeQuotaMap(stored);
|
|
188
207
|
if (stored !== void 0 && decoded === void 0) {
|
|
@@ -226,14 +245,16 @@ function mergeQuotaObservation(stored, observation) {
|
|
|
226
245
|
const existing = entries.get(key);
|
|
227
246
|
entries.set(key, existing === void 0 || existing.kind === "absent" ? { scope, label: pair.label, kind: "absent", checkedAt: at } : { scope, label: pair.label, kind: "retired", retiredAt: at });
|
|
228
247
|
}
|
|
229
|
-
const { limits: _limits, budget: _budget, counters: _counters, ...unknownKeys } = base;
|
|
248
|
+
const { limits: _limits, budget: _budget, counters: _counters, credits: _credits, ...unknownKeys } = base;
|
|
230
249
|
const budget = mergeBudget(base.budget, observation.budget, at);
|
|
231
250
|
const counters = mergeCounters(base.counters, observation.counters);
|
|
251
|
+
const credits = mergeCredits(base.credits, observation.credits);
|
|
232
252
|
return {
|
|
233
253
|
...unknownKeys,
|
|
234
254
|
limits: [...entries.values()].sort(compareEntries),
|
|
235
255
|
...budget === void 0 ? {} : { budget },
|
|
236
|
-
...counters === void 0 ? {} : { counters }
|
|
256
|
+
...counters === void 0 ? {} : { counters },
|
|
257
|
+
...credits === void 0 ? {} : { credits }
|
|
237
258
|
};
|
|
238
259
|
}
|
|
239
260
|
var QuotaCodecError;
|
|
@@ -328,6 +349,13 @@ function quotaWindowParts(quota, options) {
|
|
|
328
349
|
const parts = windows.map(({ part }) => part);
|
|
329
350
|
return age === void 0 ? { windows: parts } : { windows: parts, age };
|
|
330
351
|
}
|
|
352
|
+
function withShortNames(windows) {
|
|
353
|
+
const abbreviations = scopeAbbreviations(windows.filter(({ part, scope }) => part.kind === "window" && scope !== ALL_SCOPE).map(({ scope }) => scope));
|
|
354
|
+
for (const window of windows) {
|
|
355
|
+
window.part.short = window.part.kind === "budget" ? "cr" : window.scope === ALL_SCOPE ? window.part.name : abbreviations.get(window.scope) ?? window.scope;
|
|
356
|
+
}
|
|
357
|
+
return windows;
|
|
358
|
+
}
|
|
331
359
|
function scopedWindowParts(quota, options) {
|
|
332
360
|
if (!quota)
|
|
333
361
|
return { windows: [] };
|
|
@@ -341,6 +369,7 @@ function scopedWindowParts(quota, options) {
|
|
|
341
369
|
part: {
|
|
342
370
|
kind: "window",
|
|
343
371
|
name: quotaWindowName(limit),
|
|
372
|
+
short: "",
|
|
344
373
|
figure: percentLeft(limit.remainingPercent ?? 0),
|
|
345
374
|
remainingPercent,
|
|
346
375
|
checkedAt: limit.checkedAt,
|
|
@@ -358,6 +387,7 @@ function scopedWindowParts(quota, options) {
|
|
|
358
387
|
part: {
|
|
359
388
|
kind: "budget",
|
|
360
389
|
name: "credits",
|
|
390
|
+
short: "",
|
|
361
391
|
figure,
|
|
362
392
|
...remainingPercent === void 0 ? {} : { remainingPercent: clampPercent(remainingPercent) },
|
|
363
393
|
checkedAt: budget.checkedAt,
|
|
@@ -365,6 +395,7 @@ function scopedWindowParts(quota, options) {
|
|
|
365
395
|
}
|
|
366
396
|
});
|
|
367
397
|
}
|
|
398
|
+
withShortNames(windows);
|
|
368
399
|
if (windows.length > 0) {
|
|
369
400
|
const age = now - Math.min(...windows.map(({ part }) => part.checkedAt));
|
|
370
401
|
if (age > (options.staleAfterMs ?? QUOTA_STALE_AFTER_MS)) {
|
|
@@ -444,15 +475,14 @@ function narrowTextParts(quota, options) {
|
|
|
444
475
|
return grouped;
|
|
445
476
|
const general = windows.filter(({ part, scope }) => part.kind === "window" && scope === ALL_SCOPE);
|
|
446
477
|
const scoped = windows.filter(({ part, scope }) => part.kind === "window" && scope !== ALL_SCOPE);
|
|
447
|
-
const abbreviations = scopeAbbreviations(scoped.map(({ scope }) => scope));
|
|
448
478
|
const budget = windows.find(({ part }) => part.kind === "budget");
|
|
449
479
|
const budgetLeft = budget?.spent ? 0 : budget?.part.remainingPercent;
|
|
450
480
|
const extras = [
|
|
451
|
-
...scoped.map(({
|
|
452
|
-
label:
|
|
481
|
+
...scoped.map(({ part }) => ({
|
|
482
|
+
label: part.short,
|
|
453
483
|
remaining: part.remainingPercent ?? 0
|
|
454
484
|
})),
|
|
455
|
-
...budgetLeft === void 0 ? [] : [{ label:
|
|
485
|
+
...budgetLeft === void 0 || budget === void 0 ? [] : [{ label: budget.part.short, remaining: budgetLeft }]
|
|
456
486
|
];
|
|
457
487
|
const tightest = extras.reduce((best, item) => best === void 0 || item.remaining < best.remaining ? item : best, void 0);
|
|
458
488
|
const pieces = general.map(({ part }) => `${part.name} ${wholePercent(part.remainingPercent ?? 0)}%`);
|
|
@@ -480,6 +510,16 @@ function formatQuota(quota, options) {
|
|
|
480
510
|
return parts.join(" \xB7 ");
|
|
481
511
|
return quota && quota.limits.length > 0 ? NO_LIMITS_REPORTED : NO_QUOTA_READING;
|
|
482
512
|
}
|
|
513
|
+
function quotaCreditsText(credits) {
|
|
514
|
+
if (credits === void 0)
|
|
515
|
+
return void 0;
|
|
516
|
+
if (credits.unlimited)
|
|
517
|
+
return "Unlimited";
|
|
518
|
+
if (!credits.hasCredits)
|
|
519
|
+
return void 0;
|
|
520
|
+
const { balance } = credits;
|
|
521
|
+
return typeof balance === "number" && Number.isFinite(balance) && balance > 0 ? `${Math.round(balance)} credits` : "Available";
|
|
522
|
+
}
|
|
483
523
|
var QUOTA_STALE_AFTER_MS, NO_QUOTA_READING, NO_LIMITS_REPORTED, NARROW_GROUP_LIMIT;
|
|
484
524
|
var init_format = __esm({
|
|
485
525
|
"../core/dist/common-auth-embedded/quota/format.js"() {
|
|
@@ -561,12 +601,14 @@ function projectQuota(map, scope = ALL_SCOPE) {
|
|
|
561
601
|
const checkedAt = stamped.length > 0 ? Math.min(...stamped.map((limit) => limit.checkedAt)) : void 0;
|
|
562
602
|
const budget = map?.budget?.kind === "reading" ? projectBudget(map.budget) : void 0;
|
|
563
603
|
const counters = readQuotaCounters(map?.counters);
|
|
604
|
+
const credits = isQuotaCredits(map?.credits) ? map.credits : void 0;
|
|
564
605
|
return {
|
|
565
606
|
scope,
|
|
566
607
|
limits,
|
|
567
608
|
...checkedAt === void 0 ? {} : { checkedAt },
|
|
568
609
|
...budget === void 0 ? {} : { budget },
|
|
569
|
-
...counters === void 0 ? {} : { counters }
|
|
610
|
+
...counters === void 0 ? {} : { counters },
|
|
611
|
+
...credits === void 0 ? {} : { credits }
|
|
570
612
|
};
|
|
571
613
|
}
|
|
572
614
|
function budgetExhaustedResetAt(quota, now) {
|
|
@@ -609,12 +651,14 @@ __export(quota_exports, {
|
|
|
609
651
|
emptyQuotaMap: () => emptyQuotaMap,
|
|
610
652
|
formatQuota: () => formatQuota,
|
|
611
653
|
futureResetAt: () => futureResetAt,
|
|
654
|
+
isQuotaCredits: () => isQuotaCredits,
|
|
612
655
|
isQuotaMap: () => isQuotaMap,
|
|
613
656
|
isQuotaObservation: () => isQuotaObservation,
|
|
614
657
|
isQuotaStale: () => isQuotaStale,
|
|
615
658
|
mergeQuotaObservation: () => mergeQuotaObservation,
|
|
616
659
|
projectQuota: () => projectQuota,
|
|
617
660
|
quotaCodec: () => quotaCodec2,
|
|
661
|
+
quotaCreditsText: () => quotaCreditsText,
|
|
618
662
|
quotaTextParts: () => quotaTextParts,
|
|
619
663
|
quotaWindowName: () => quotaWindowName,
|
|
620
664
|
quotaWindowParts: () => quotaWindowParts,
|
|
@@ -1115,8 +1159,8 @@ async function acquireRefreshFileLockWithClock(options) {
|
|
|
1115
1159
|
let releaseConfirmed = false;
|
|
1116
1160
|
let loss;
|
|
1117
1161
|
let resolveLoss;
|
|
1118
|
-
const lostPromise = new Promise((
|
|
1119
|
-
resolveLoss =
|
|
1162
|
+
const lostPromise = new Promise((resolve15) => {
|
|
1163
|
+
resolveLoss = resolve15;
|
|
1120
1164
|
});
|
|
1121
1165
|
function notifyTimerStep(event) {
|
|
1122
1166
|
try {
|
|
@@ -1273,7 +1317,7 @@ async function acquireRefreshFileLockWithClock(options) {
|
|
|
1273
1317
|
}
|
|
1274
1318
|
}
|
|
1275
1319
|
async function backoff() {
|
|
1276
|
-
await new Promise((
|
|
1320
|
+
await new Promise((resolve15) => setTimeout(resolve15, Math.floor(Math.random() * 4)));
|
|
1277
1321
|
}
|
|
1278
1322
|
async function readLockState(notifyReady = true) {
|
|
1279
1323
|
if (notifyReady && options.onStep)
|
|
@@ -1723,6 +1767,7 @@ function lockPathFor(target, name) {
|
|
|
1723
1767
|
async function withLock(target, options, fn) {
|
|
1724
1768
|
const started = performance.now();
|
|
1725
1769
|
for (; ; ) {
|
|
1770
|
+
options.signal?.throwIfAborted();
|
|
1726
1771
|
const lock = await acquireRefreshFileLock({
|
|
1727
1772
|
path: target,
|
|
1728
1773
|
name: options.name,
|
|
@@ -1733,6 +1778,7 @@ async function withLock(target, options, fn) {
|
|
|
1733
1778
|
});
|
|
1734
1779
|
if (lock) {
|
|
1735
1780
|
try {
|
|
1781
|
+
options.signal?.throwIfAborted();
|
|
1736
1782
|
return await fn(lock);
|
|
1737
1783
|
} finally {
|
|
1738
1784
|
await lock.release();
|
|
@@ -1746,7 +1792,7 @@ async function withLock(target, options, fn) {
|
|
|
1746
1792
|
timeoutMs: options.timeoutMs
|
|
1747
1793
|
});
|
|
1748
1794
|
}
|
|
1749
|
-
await new Promise((
|
|
1795
|
+
await new Promise((resolve15) => setTimeout(resolve15, Math.min(25, Math.ceil(remaining))));
|
|
1750
1796
|
}
|
|
1751
1797
|
}
|
|
1752
1798
|
var LockContentionError, LockOwnershipError;
|
|
@@ -1782,13 +1828,13 @@ function assertNotInsideHook(operation) {
|
|
|
1782
1828
|
function runInsideHook(operation, fn) {
|
|
1783
1829
|
return insideHook.run(operation, async () => await fn());
|
|
1784
1830
|
}
|
|
1785
|
-
async function callFailureHook(operation, hook, rowId2, error,
|
|
1831
|
+
async function callFailureHook(operation, hook, rowId2, error, logger2) {
|
|
1786
1832
|
if (!hook)
|
|
1787
1833
|
return;
|
|
1788
1834
|
try {
|
|
1789
1835
|
await runInsideHook(operation, () => hook(rowId2, error));
|
|
1790
1836
|
} catch (hookError) {
|
|
1791
|
-
|
|
1837
|
+
logger2?.warn("store failure hook threw; the original failure stands", {
|
|
1792
1838
|
operation,
|
|
1793
1839
|
rowId: rowId2,
|
|
1794
1840
|
error: hookError instanceof Error ? hookError.message : String(hookError)
|
|
@@ -1865,7 +1911,7 @@ async function acquirePoolLock(spec, defaults, env3) {
|
|
|
1865
1911
|
});
|
|
1866
1912
|
}
|
|
1867
1913
|
const jitter = Math.floor(Math.random() * (options.retryMs + 1));
|
|
1868
|
-
await new Promise((
|
|
1914
|
+
await new Promise((resolve15) => setTimeout(resolve15, Math.min(options.retryMs + jitter, remaining)));
|
|
1869
1915
|
}
|
|
1870
1916
|
}
|
|
1871
1917
|
function definedOnly(spec) {
|
|
@@ -2943,11 +2989,11 @@ var init_mutate = __esm({
|
|
|
2943
2989
|
if (isRecord4(this.state.accounts) && Object.hasOwn(this.state.accounts, id))
|
|
2944
2990
|
delete this.state.accounts[id];
|
|
2945
2991
|
}
|
|
2946
|
-
setStateAccount(id,
|
|
2992
|
+
setStateAccount(id, fields2) {
|
|
2947
2993
|
if (!isRecord4(this.state.accounts))
|
|
2948
2994
|
this.state.accounts = {};
|
|
2949
2995
|
Object.defineProperty(this.state.accounts, id, {
|
|
2950
|
-
value:
|
|
2996
|
+
value: fields2,
|
|
2951
2997
|
enumerable: true,
|
|
2952
2998
|
writable: true,
|
|
2953
2999
|
configurable: true
|
|
@@ -4496,12 +4542,12 @@ var init_pull = __esm({
|
|
|
4496
4542
|
firedAtLoad;
|
|
4497
4543
|
logger;
|
|
4498
4544
|
inflight = /* @__PURE__ */ new Set();
|
|
4499
|
-
constructor(rt, hook, onFailure, firedAtLoad,
|
|
4545
|
+
constructor(rt, hook, onFailure, firedAtLoad, logger2) {
|
|
4500
4546
|
this.rt = rt;
|
|
4501
4547
|
this.hook = hook;
|
|
4502
4548
|
this.onFailure = onFailure;
|
|
4503
4549
|
this.firedAtLoad = firedAtLoad;
|
|
4504
|
-
this.logger =
|
|
4550
|
+
this.logger = logger2;
|
|
4505
4551
|
}
|
|
4506
4552
|
fire(id, reason) {
|
|
4507
4553
|
if (!this.hook)
|
|
@@ -5583,15 +5629,15 @@ function createRedactor(options = {}) {
|
|
|
5583
5629
|
return SECRET_KEY_EXACT.test(key) || normalized.includes("apikey") || normalized.endsWith("secret") || normalized.endsWith("password") || normalized.endsWith("token") && !normalized.endsWith("tokens") || !!options.extraSecretKeys?.(normalized);
|
|
5584
5630
|
}
|
|
5585
5631
|
function errorEntries(error) {
|
|
5586
|
-
const
|
|
5632
|
+
const fields2 = error;
|
|
5587
5633
|
const entries = [
|
|
5588
5634
|
["name", error.name],
|
|
5589
5635
|
["message", error.message],
|
|
5590
5636
|
["stack", error.stack]
|
|
5591
5637
|
];
|
|
5592
5638
|
for (const key of ["code", "status", "cause"])
|
|
5593
|
-
if (
|
|
5594
|
-
entries.push([key,
|
|
5639
|
+
if (fields2[key] !== void 0)
|
|
5640
|
+
entries.push([key, fields2[key]]);
|
|
5595
5641
|
const listed = new Set(entries.map(([key]) => key));
|
|
5596
5642
|
for (const entry of Object.entries(error))
|
|
5597
5643
|
if (!listed.has(entry[0]))
|
|
@@ -5833,7 +5879,7 @@ function createEngine(options) {
|
|
|
5833
5879
|
} catch {
|
|
5834
5880
|
}
|
|
5835
5881
|
}
|
|
5836
|
-
function
|
|
5882
|
+
function schedule2() {
|
|
5837
5883
|
if (!timer)
|
|
5838
5884
|
timer = setTimeout(() => {
|
|
5839
5885
|
timer = void 0;
|
|
@@ -5875,7 +5921,7 @@ function createEngine(options) {
|
|
|
5875
5921
|
void flushed.catch(() => {
|
|
5876
5922
|
});
|
|
5877
5923
|
} else
|
|
5878
|
-
|
|
5924
|
+
schedule2();
|
|
5879
5925
|
} catch {
|
|
5880
5926
|
}
|
|
5881
5927
|
}
|
|
@@ -6746,9 +6792,9 @@ function findAction(sections, request) {
|
|
|
6746
6792
|
return actions?.find((action) => action.id === request.actionId);
|
|
6747
6793
|
}
|
|
6748
6794
|
function createCommandMenu(options) {
|
|
6749
|
-
const
|
|
6795
|
+
const logger2 = options.logger ?? createLogger2("commands");
|
|
6750
6796
|
const redact3 = createTextRedactor(options.redaction);
|
|
6751
|
-
const seam = { logger, redact: redact3 };
|
|
6797
|
+
const seam = { logger: logger2, redact: redact3 };
|
|
6752
6798
|
const now = options.now ?? Date.now;
|
|
6753
6799
|
const extras = options.extras ?? [];
|
|
6754
6800
|
const replaced = options.replace ?? {};
|
|
@@ -6775,7 +6821,7 @@ function createCommandMenu(options) {
|
|
|
6775
6821
|
content: await section.build(invocation)
|
|
6776
6822
|
};
|
|
6777
6823
|
} catch (error) {
|
|
6778
|
-
|
|
6824
|
+
logger2.warn("command menu section failed to build", {
|
|
6779
6825
|
command: options.command,
|
|
6780
6826
|
section: id,
|
|
6781
6827
|
error: redact3(error instanceof Error ? error.message : String(error))
|
|
@@ -6862,7 +6908,7 @@ function createCommandMenu(options) {
|
|
|
6862
6908
|
};
|
|
6863
6909
|
} catch (error) {
|
|
6864
6910
|
const failure = projectFailure(error);
|
|
6865
|
-
|
|
6911
|
+
logger2.warn("command menu action failed", {
|
|
6866
6912
|
command: options.command,
|
|
6867
6913
|
section: request.sectionId,
|
|
6868
6914
|
action: request.actionId,
|
|
@@ -7228,12 +7274,12 @@ var init_doctor = __esm({
|
|
|
7228
7274
|
});
|
|
7229
7275
|
|
|
7230
7276
|
// ../core/dist/common-auth-embedded/auth-menu/login.js
|
|
7231
|
-
import {
|
|
7232
|
-
function openBrowserForMenu(url, platform = process.platform,
|
|
7277
|
+
import { spawn as defaultSpawn } from "node:child_process";
|
|
7278
|
+
function openBrowserForMenu(url, platform = process.platform, spawn2 = defaultSpawn) {
|
|
7233
7279
|
try {
|
|
7234
7280
|
if (platform === "win32") {
|
|
7235
7281
|
const command = `Start-Process '${url.replaceAll("'", "''")}'`;
|
|
7236
|
-
const
|
|
7282
|
+
const child2 = spawn2("powershell.exe", [
|
|
7237
7283
|
"-NoProfile",
|
|
7238
7284
|
"-NonInteractive",
|
|
7239
7285
|
"-WindowStyle",
|
|
@@ -7241,17 +7287,18 @@ function openBrowserForMenu(url, platform = process.platform, execFileSync = def
|
|
|
7241
7287
|
"-EncodedCommand",
|
|
7242
7288
|
Buffer.from(command, "utf16le").toString("base64")
|
|
7243
7289
|
], { stdio: "ignore", windowsHide: true });
|
|
7244
|
-
|
|
7245
|
-
});
|
|
7246
|
-
child.unref();
|
|
7247
|
-
return child.pid !== void 0;
|
|
7248
|
-
} else {
|
|
7249
|
-
execFileSync(platform === "darwin" ? "open" : "xdg-open", [url], {
|
|
7250
|
-
stdio: "ignore",
|
|
7251
|
-
timeout: 3e3
|
|
7290
|
+
child2.on("error", () => {
|
|
7252
7291
|
});
|
|
7292
|
+
child2.unref();
|
|
7293
|
+
return child2.pid !== void 0;
|
|
7253
7294
|
}
|
|
7254
|
-
|
|
7295
|
+
const child = spawn2(platform === "darwin" ? "open" : "xdg-open", [url], {
|
|
7296
|
+
stdio: "ignore"
|
|
7297
|
+
});
|
|
7298
|
+
child.on("error", () => {
|
|
7299
|
+
});
|
|
7300
|
+
child.unref();
|
|
7301
|
+
return child.pid !== void 0;
|
|
7255
7302
|
} catch {
|
|
7256
7303
|
return false;
|
|
7257
7304
|
}
|
|
@@ -7473,7 +7520,7 @@ async function select(terminal, items, options) {
|
|
|
7473
7520
|
writeLine("");
|
|
7474
7521
|
renderedLines = lines;
|
|
7475
7522
|
};
|
|
7476
|
-
return new Promise((
|
|
7523
|
+
return new Promise((resolve15) => {
|
|
7477
7524
|
const wasRaw = stdin.isRaw ?? false;
|
|
7478
7525
|
const cleanup2 = () => {
|
|
7479
7526
|
if (cleaned)
|
|
@@ -7493,7 +7540,7 @@ async function select(terminal, items, options) {
|
|
|
7493
7540
|
};
|
|
7494
7541
|
const finish = (value) => {
|
|
7495
7542
|
cleanup2();
|
|
7496
|
-
|
|
7543
|
+
resolve15(value);
|
|
7497
7544
|
};
|
|
7498
7545
|
const onSignal = () => finish(null);
|
|
7499
7546
|
const onKey = (data) => {
|
|
@@ -7533,7 +7580,7 @@ async function select(terminal, items, options) {
|
|
|
7533
7580
|
stdin.setRawMode(true);
|
|
7534
7581
|
} catch {
|
|
7535
7582
|
cleanup2();
|
|
7536
|
-
|
|
7583
|
+
resolve15(null);
|
|
7537
7584
|
return;
|
|
7538
7585
|
}
|
|
7539
7586
|
stdin.resume();
|
|
@@ -8524,7 +8571,7 @@ function acquireInsulaQuotaSource(transport, tokenPath) {
|
|
|
8524
8571
|
}
|
|
8525
8572
|
};
|
|
8526
8573
|
}
|
|
8527
|
-
var MINUTE, MAX_AGE, sources, attempts, InsulaQuotaSource;
|
|
8574
|
+
var MINUTE, MAX_AGE, COLD_WAIT, sources, attempts, InsulaQuotaSource;
|
|
8528
8575
|
var init_insula = __esm({
|
|
8529
8576
|
"../core/dist/common-auth-embedded/claustrum/insula.js"() {
|
|
8530
8577
|
"use strict";
|
|
@@ -8532,12 +8579,16 @@ var init_insula = __esm({
|
|
|
8532
8579
|
init_watch();
|
|
8533
8580
|
MINUTE = 6e4;
|
|
8534
8581
|
MAX_AGE = 4 * MINUTE;
|
|
8582
|
+
COLD_WAIT = 2 * MINUTE;
|
|
8535
8583
|
sources = /* @__PURE__ */ new Map();
|
|
8536
8584
|
attempts = /* @__PURE__ */ new Map();
|
|
8537
8585
|
InsulaQuotaSource = class {
|
|
8538
8586
|
transport;
|
|
8539
8587
|
key;
|
|
8540
8588
|
#entries = [];
|
|
8589
|
+
#available = false;
|
|
8590
|
+
#completeProviders = /* @__PURE__ */ new Set();
|
|
8591
|
+
#coldSince = /* @__PURE__ */ new Map();
|
|
8541
8592
|
/** Every usage.get, polled or watch-driven, shares this one slot. */
|
|
8542
8593
|
#reads = new CoalescedRead(async () => {
|
|
8543
8594
|
try {
|
|
@@ -8545,8 +8596,14 @@ var init_insula = __esm({
|
|
|
8545
8596
|
if (!record2(reply) || !Array.isArray(reply.result) || reply.error !== void 0)
|
|
8546
8597
|
throw new Error("unavailable insula usage");
|
|
8547
8598
|
this.#entries = reply.result.filter((entry) => record2(entry) && typeof entry.provider === "string");
|
|
8599
|
+
this.#available = this.#entries.length === reply.result.length && (reply.completeProviders === void 0 || Array.isArray(reply.completeProviders) && reply.completeProviders.every((value) => typeof value === "string"));
|
|
8600
|
+
this.#completeProviders = new Set(this.#available && Array.isArray(reply.completeProviders) ? reply.completeProviders : []);
|
|
8601
|
+
for (const provider2 of this.#completeProviders)
|
|
8602
|
+
this.#coldSince.delete(provider2);
|
|
8548
8603
|
} catch {
|
|
8549
8604
|
this.#entries = [];
|
|
8605
|
+
this.#available = false;
|
|
8606
|
+
this.#completeProviders.clear();
|
|
8550
8607
|
}
|
|
8551
8608
|
}, () => {
|
|
8552
8609
|
});
|
|
@@ -8725,6 +8782,37 @@ var init_insula = __esm({
|
|
|
8725
8782
|
}
|
|
8726
8783
|
return void 0;
|
|
8727
8784
|
}
|
|
8785
|
+
/** Cache-only background lookup; current() retains its original miss behavior. */
|
|
8786
|
+
lookup(provider2, accountId, now) {
|
|
8787
|
+
if (!this.#available)
|
|
8788
|
+
return { miss: "unreachable" };
|
|
8789
|
+
const entry = this.#entries.find((value) => value.provider === provider2 && typeof value.account === "string" && value.account.trim() === accountId);
|
|
8790
|
+
const errorClass = (entry ?? this.#entries.find((value) => value.provider === provider2 && value.account === void 0 && value.errorClass !== void 0))?.errorClass;
|
|
8791
|
+
if (errorClass === "upstream_failed")
|
|
8792
|
+
return { miss: "upstream-failed" };
|
|
8793
|
+
if (errorClass === "credential_absent" || errorClass === "credential_unusable" || errorClass === "credential_rejected")
|
|
8794
|
+
return { miss: "credential" };
|
|
8795
|
+
if (errorClass !== void 0)
|
|
8796
|
+
return { miss: "unreachable" };
|
|
8797
|
+
if (entry) {
|
|
8798
|
+
const fetchedAt = typeof entry.fetchedAt === "string" ? Date.parse(entry.fetchedAt) : Number.NaN;
|
|
8799
|
+
if (!record2(entry.usage) || !Number.isFinite(fetchedAt))
|
|
8800
|
+
return { miss: "unreachable" };
|
|
8801
|
+
const reading = {
|
|
8802
|
+
entry,
|
|
8803
|
+
context: {
|
|
8804
|
+
fetchedAt,
|
|
8805
|
+
...typeof entry.source === "string" && { source: entry.source }
|
|
8806
|
+
}
|
|
8807
|
+
};
|
|
8808
|
+
return now >= fetchedAt + MAX_AGE || entry.stale !== void 0 ? { miss: "stale", reading } : { reading };
|
|
8809
|
+
}
|
|
8810
|
+
if (this.#completeProviders.has(provider2))
|
|
8811
|
+
return { miss: "absent" };
|
|
8812
|
+
const since = this.#coldSince.get(provider2) ?? now;
|
|
8813
|
+
this.#coldSince.set(provider2, since);
|
|
8814
|
+
return { miss: now - since >= COLD_WAIT ? "unreachable" : "cold" };
|
|
8815
|
+
}
|
|
8728
8816
|
};
|
|
8729
8817
|
}
|
|
8730
8818
|
});
|
|
@@ -8938,13 +9026,13 @@ async function readBoundedJson(path2) {
|
|
|
8938
9026
|
await descriptor.close();
|
|
8939
9027
|
}
|
|
8940
9028
|
}
|
|
8941
|
-
function accountRecords(text2,
|
|
9029
|
+
function accountRecords(text2, fields2) {
|
|
8942
9030
|
const records = [];
|
|
8943
9031
|
for (const line of text2.split("\n")) {
|
|
8944
9032
|
if (line.trim() === "" || line.startsWith("#"))
|
|
8945
9033
|
continue;
|
|
8946
9034
|
const parts = line.split(":");
|
|
8947
|
-
if (parts.length !==
|
|
9035
|
+
if (parts.length !== fields2 || !/^[^\s:,]+$/.test(parts[0] ?? "") || !/^\d+$/.test(parts[2] ?? "") || !Number.isSafeInteger(Number(parts[2])) || fields2 === 7 && (!/^\d+$/.test(parts[3] ?? "") || !Number.isSafeInteger(Number(parts[3]))) || fields2 === 4 && parts[3] !== "" && !/^[^\s:,]+(?:,[^\s:,]+)*$/.test(parts[3] ?? ""))
|
|
8948
9036
|
return void 0;
|
|
8949
9037
|
records.push(parts);
|
|
8950
9038
|
}
|
|
@@ -9494,9 +9582,9 @@ function scopedRetryReason(served, current) {
|
|
|
9494
9582
|
return "version-unchanged";
|
|
9495
9583
|
return "rotated";
|
|
9496
9584
|
}
|
|
9497
|
-
function decideScopedRetryAfter401(site, served, current,
|
|
9585
|
+
function decideScopedRetryAfter401(site, served, current, logger2 = defaultLogger) {
|
|
9498
9586
|
const retry = isScopedCredentialRotation(served, current);
|
|
9499
|
-
|
|
9587
|
+
logger2.debug("scoped 401 re-authorized", {
|
|
9500
9588
|
site,
|
|
9501
9589
|
credentialId: served.credentialId,
|
|
9502
9590
|
servedVersion: served.recordVersion,
|
|
@@ -10069,6 +10157,7 @@ var init_interlock = __esm({
|
|
|
10069
10157
|
|
|
10070
10158
|
// ../core/dist/common-auth-embedded/claustrum/roster.js
|
|
10071
10159
|
import { createHash as createHash6 } from "node:crypto";
|
|
10160
|
+
import { resolve as resolve6 } from "node:path";
|
|
10072
10161
|
function hash(value) {
|
|
10073
10162
|
return createHash6("sha256").update(value).digest("hex");
|
|
10074
10163
|
}
|
|
@@ -10289,7 +10378,7 @@ async function readVaultRoster(path2) {
|
|
|
10289
10378
|
return decodeRoster(value);
|
|
10290
10379
|
}
|
|
10291
10380
|
async function mutateVaultRoster(path2, change, options = {}) {
|
|
10292
|
-
return withLock(path2, WRITE_LOCK, async (lock) => {
|
|
10381
|
+
return withLock(path2, { ...WRITE_LOCK, signal: options.signal }, async (lock) => {
|
|
10293
10382
|
const current = await readVaultRoster(path2);
|
|
10294
10383
|
const { next, result } = await change(current, {
|
|
10295
10384
|
assertOwned: () => lock.assertOwned()
|
|
@@ -10299,6 +10388,7 @@ async function mutateVaultRoster(path2, change, options = {}) {
|
|
|
10299
10388
|
await writeJsonAtomic2(path2, next, {
|
|
10300
10389
|
beforeRename: async () => {
|
|
10301
10390
|
await options.beforePublish?.();
|
|
10391
|
+
options.signal?.throwIfAborted();
|
|
10302
10392
|
await lock.assertOwned();
|
|
10303
10393
|
}
|
|
10304
10394
|
});
|
|
@@ -10348,43 +10438,51 @@ function receiptFence(row, receipt2) {
|
|
|
10348
10438
|
return "bind";
|
|
10349
10439
|
return "refuse";
|
|
10350
10440
|
}
|
|
10351
|
-
function recordVaultQuota(path2, input) {
|
|
10352
|
-
|
|
10353
|
-
|
|
10354
|
-
|
|
10355
|
-
|
|
10356
|
-
|
|
10357
|
-
|
|
10358
|
-
const bound = fence === "bind" ? { accountIdentity: input.accountIdentity, unclaimed: true } : {};
|
|
10359
|
-
return {
|
|
10360
|
-
next: {
|
|
10361
|
-
...current,
|
|
10362
|
-
rows: current.rows.map((entry) => entry === row ? { ...entry, ...bound, quota } : entry)
|
|
10363
|
-
},
|
|
10364
|
-
result: true
|
|
10365
|
-
};
|
|
10441
|
+
async function recordVaultQuota(path2, input) {
|
|
10442
|
+
const { routeId, observation, ...receipt2 } = input;
|
|
10443
|
+
return enqueueFencedVaultQuota(path2, {
|
|
10444
|
+
routeId,
|
|
10445
|
+
observation,
|
|
10446
|
+
accountIdentity: receipt2.accountIdentity,
|
|
10447
|
+
receipt: receipt2
|
|
10366
10448
|
});
|
|
10367
10449
|
}
|
|
10450
|
+
async function enqueueFencedVaultQuota(path2, publication2) {
|
|
10451
|
+
if (!isQuotaObservation(publication2.observation))
|
|
10452
|
+
return false;
|
|
10453
|
+
const current = pendingVaultQuota(path2, await readVaultRoster(path2));
|
|
10454
|
+
if (!applyVaultQuota(current, publication2).kept)
|
|
10455
|
+
return false;
|
|
10456
|
+
return enqueueVaultQuota(path2, publication2);
|
|
10457
|
+
}
|
|
10368
10458
|
function recordVaultAccountQuota(path2, input) {
|
|
10369
|
-
return
|
|
10370
|
-
|
|
10371
|
-
|
|
10372
|
-
|
|
10373
|
-
|
|
10374
|
-
|
|
10375
|
-
|
|
10376
|
-
|
|
10377
|
-
|
|
10378
|
-
|
|
10379
|
-
|
|
10380
|
-
|
|
10381
|
-
|
|
10459
|
+
return enqueueFencedVaultQuota(path2, input);
|
|
10460
|
+
}
|
|
10461
|
+
function applyVaultQuota(current, input) {
|
|
10462
|
+
const row = current?.rows.find((entry) => entry.routeId === input.routeId);
|
|
10463
|
+
const fence = !row ? "refuse" : input.receipt ? receiptFence(row, input.receipt) : row.accountIdentity !== void 0 && row.accountIdentity === input.accountIdentity ? "hold" : "refuse";
|
|
10464
|
+
if (!current || !row || fence === "refuse")
|
|
10465
|
+
return { roster: current, kept: false };
|
|
10466
|
+
const quota = mergeQuotaObservation(row.quota, input.observation);
|
|
10467
|
+
const bound = fence === "bind" ? { accountIdentity: input.accountIdentity, unclaimed: true } : {};
|
|
10468
|
+
return {
|
|
10469
|
+
roster: {
|
|
10470
|
+
...current,
|
|
10471
|
+
rows: current.rows.map((entry) => entry === row ? { ...entry, ...bound, quota } : entry)
|
|
10472
|
+
},
|
|
10473
|
+
kept: true
|
|
10474
|
+
};
|
|
10475
|
+
}
|
|
10476
|
+
function forgetPendingVaultDiscovery(path2) {
|
|
10477
|
+
pendingDiscoveries.delete(resolve6(path2));
|
|
10382
10478
|
}
|
|
10383
10479
|
async function refreshVaultRoster(options) {
|
|
10384
10480
|
options.signal?.throwIfAborted();
|
|
10385
10481
|
const active2 = async () => await options.isActive?.() ?? true;
|
|
10386
|
-
if (!await active2())
|
|
10482
|
+
if (!await active2()) {
|
|
10483
|
+
forgetPendingVaultDiscovery(options.path);
|
|
10387
10484
|
return void 0;
|
|
10485
|
+
}
|
|
10388
10486
|
const lease = await acquireRefreshFileLock({
|
|
10389
10487
|
...DISCOVERY_LEASE,
|
|
10390
10488
|
path: options.path,
|
|
@@ -10397,8 +10495,18 @@ async function refreshVaultRoster(options) {
|
|
|
10397
10495
|
throw new ClaustrumConsumerError("roster-busy", "Claustrum account discovery is already in progress");
|
|
10398
10496
|
return persisted;
|
|
10399
10497
|
}
|
|
10498
|
+
const key = resolve6(options.path);
|
|
10499
|
+
let discovered;
|
|
10400
10500
|
try {
|
|
10401
|
-
const
|
|
10501
|
+
const previous = await readVaultRoster(options.path);
|
|
10502
|
+
const pending = pendingDiscoveries.get(key);
|
|
10503
|
+
discovered = pending && (pending.previousView === previous?.view || pending.inventory.view === previous?.view) ? pending : {
|
|
10504
|
+
inventory: await options.custody.discover(options.signal),
|
|
10505
|
+
previousView: previous?.view
|
|
10506
|
+
};
|
|
10507
|
+
pendingDiscoveries.delete(key);
|
|
10508
|
+
const { inventory } = discovered;
|
|
10509
|
+
options.onInventory?.(inventory);
|
|
10402
10510
|
options.signal?.throwIfAborted();
|
|
10403
10511
|
return await mutateVaultRoster(options.path, async (current) => {
|
|
10404
10512
|
if (!await active2())
|
|
@@ -10409,7 +10517,16 @@ async function refreshVaultRoster(options) {
|
|
|
10409
10517
|
const next = projectVaultRoster(current, inventory, projection);
|
|
10410
10518
|
const changed = JSON.stringify(current) !== JSON.stringify(next);
|
|
10411
10519
|
return { ...changed && { next }, result: next };
|
|
10520
|
+
}, {
|
|
10521
|
+
beforePublish: async () => {
|
|
10522
|
+
options.signal?.throwIfAborted();
|
|
10523
|
+
await lease.assertOwned();
|
|
10524
|
+
}
|
|
10412
10525
|
});
|
|
10526
|
+
} catch (error) {
|
|
10527
|
+
if (error instanceof LockContentionError && discovered && !options.signal?.aborted && await active2())
|
|
10528
|
+
pendingDiscoveries.set(key, discovered);
|
|
10529
|
+
throw error;
|
|
10413
10530
|
} finally {
|
|
10414
10531
|
await lease.release();
|
|
10415
10532
|
}
|
|
@@ -10446,7 +10563,7 @@ function resolveVaultPrimary(input) {
|
|
|
10446
10563
|
...previous && previous.accountIdentity !== identity && { replaced: previous }
|
|
10447
10564
|
};
|
|
10448
10565
|
}
|
|
10449
|
-
var DEFAULT_ROUTE_PREFIX, SKIPPED_REASONS, WRITE_LOCK, DISCOVERY_LEASE;
|
|
10566
|
+
var DEFAULT_ROUTE_PREFIX, SKIPPED_REASONS, WRITE_LOCK, DISCOVERY_LEASE, pendingDiscoveries;
|
|
10450
10567
|
var init_roster = __esm({
|
|
10451
10568
|
"../core/dist/common-auth-embedded/claustrum/roster.js"() {
|
|
10452
10569
|
"use strict";
|
|
@@ -10455,6 +10572,8 @@ var init_roster = __esm({
|
|
|
10455
10572
|
init_quota();
|
|
10456
10573
|
init_errors2();
|
|
10457
10574
|
init_interlock();
|
|
10575
|
+
init_quota_writer();
|
|
10576
|
+
init_quota_writer();
|
|
10458
10577
|
DEFAULT_ROUTE_PREFIX = "vault:";
|
|
10459
10578
|
SKIPPED_REASONS = /* @__PURE__ */ new Set([
|
|
10460
10579
|
"empty credential id",
|
|
@@ -10465,9 +10584,238 @@ var init_roster = __esm({
|
|
|
10465
10584
|
WRITE_LOCK = {
|
|
10466
10585
|
name: "claustrum-roster-write",
|
|
10467
10586
|
ttlMs: 1e4,
|
|
10468
|
-
timeoutMs: 5e3
|
|
10587
|
+
timeoutMs: 5e3,
|
|
10588
|
+
renew: true
|
|
10469
10589
|
};
|
|
10470
10590
|
DISCOVERY_LEASE = { name: "claustrum-roster", ttlMs: 3e4 };
|
|
10591
|
+
pendingDiscoveries = /* @__PURE__ */ new Map();
|
|
10592
|
+
}
|
|
10593
|
+
});
|
|
10594
|
+
|
|
10595
|
+
// ../core/dist/common-auth-embedded/claustrum/quota-writer.js
|
|
10596
|
+
import { resolve as resolve7 } from "node:path";
|
|
10597
|
+
function writerFor(path2) {
|
|
10598
|
+
const key = resolve7(path2);
|
|
10599
|
+
let writer = writers.get(key);
|
|
10600
|
+
if (!writer) {
|
|
10601
|
+
writer = {
|
|
10602
|
+
path: key,
|
|
10603
|
+
pending: /* @__PURE__ */ new Map(),
|
|
10604
|
+
listeners: /* @__PURE__ */ new Set(),
|
|
10605
|
+
wake: /* @__PURE__ */ new Set(),
|
|
10606
|
+
abort: new AbortController(),
|
|
10607
|
+
failures: 0,
|
|
10608
|
+
draining: false,
|
|
10609
|
+
order: 0
|
|
10610
|
+
};
|
|
10611
|
+
writers.set(key, writer);
|
|
10612
|
+
}
|
|
10613
|
+
return writer;
|
|
10614
|
+
}
|
|
10615
|
+
function retainVaultQuotaWriter(path2, listener) {
|
|
10616
|
+
const writer = writerFor(path2);
|
|
10617
|
+
writer.listeners.add(listener);
|
|
10618
|
+
let released;
|
|
10619
|
+
return () => released ??= (() => {
|
|
10620
|
+
writer.listeners.delete(listener);
|
|
10621
|
+
return writer.listeners.size ? Promise.resolve() : drainVaultQuota(path2);
|
|
10622
|
+
})();
|
|
10623
|
+
}
|
|
10624
|
+
function fields(publication2) {
|
|
10625
|
+
const result = /* @__PURE__ */ new Map();
|
|
10626
|
+
const { observation } = publication2;
|
|
10627
|
+
const witness = JSON.stringify([
|
|
10628
|
+
publication2.routeId,
|
|
10629
|
+
publication2.receipt?.credentialId,
|
|
10630
|
+
publication2.receipt?.accountIdentitySource,
|
|
10631
|
+
publication2.receipt?.expectedAccountIdentity
|
|
10632
|
+
]);
|
|
10633
|
+
const add = (key, at, part) => result.set(`${witness}:${key}`, {
|
|
10634
|
+
at,
|
|
10635
|
+
order: 0,
|
|
10636
|
+
publication: { ...publication2, observation: part }
|
|
10637
|
+
});
|
|
10638
|
+
const keyFor = (scope, label) => JSON.stringify([scope ?? "all", label]);
|
|
10639
|
+
const read = /* @__PURE__ */ new Set();
|
|
10640
|
+
for (const reading of observation.readings ?? []) {
|
|
10641
|
+
const key = keyFor(reading.scope, reading.label);
|
|
10642
|
+
read.add(key);
|
|
10643
|
+
add(key, observation.checkedAt, {
|
|
10644
|
+
checkedAt: observation.checkedAt,
|
|
10645
|
+
readings: [{ ...reading }]
|
|
10646
|
+
});
|
|
10647
|
+
}
|
|
10648
|
+
for (const pair of observation.coverage ?? []) {
|
|
10649
|
+
const key = keyFor(pair.scope, pair.label);
|
|
10650
|
+
if (!read.has(key))
|
|
10651
|
+
add(key, observation.checkedAt, {
|
|
10652
|
+
checkedAt: observation.checkedAt,
|
|
10653
|
+
coverage: [{ ...pair }]
|
|
10654
|
+
});
|
|
10655
|
+
}
|
|
10656
|
+
if (observation.budget)
|
|
10657
|
+
add("budget", observation.checkedAt, {
|
|
10658
|
+
checkedAt: observation.checkedAt,
|
|
10659
|
+
budget: { ...observation.budget }
|
|
10660
|
+
});
|
|
10661
|
+
for (const [name, counter] of Object.entries(observation.counters ?? {})) {
|
|
10662
|
+
add(`counter:${name}`, counter.checkedAt, {
|
|
10663
|
+
checkedAt: observation.checkedAt,
|
|
10664
|
+
counters: { [name]: { ...counter } }
|
|
10665
|
+
});
|
|
10666
|
+
}
|
|
10667
|
+
if (observation.credits)
|
|
10668
|
+
add("credits", observation.credits.checkedAt, {
|
|
10669
|
+
checkedAt: observation.checkedAt,
|
|
10670
|
+
credits: { ...observation.credits }
|
|
10671
|
+
});
|
|
10672
|
+
if (!result.size)
|
|
10673
|
+
add("empty", observation.checkedAt, { checkedAt: observation.checkedAt });
|
|
10674
|
+
return result;
|
|
10675
|
+
}
|
|
10676
|
+
function enqueueVaultQuota(path2, publication2) {
|
|
10677
|
+
if (!isQuotaObservation(publication2.observation))
|
|
10678
|
+
return Promise.resolve(false);
|
|
10679
|
+
const writer = writerFor(path2);
|
|
10680
|
+
const account = JSON.stringify([
|
|
10681
|
+
publication2.accountIdentity ?? null,
|
|
10682
|
+
publication2.accountIdentity === void 0 ? publication2.routeId : null
|
|
10683
|
+
]);
|
|
10684
|
+
const pending = writer.pending.get(account) ?? /* @__PURE__ */ new Map();
|
|
10685
|
+
for (const [key, field] of fields(publication2)) {
|
|
10686
|
+
const previous = pending.get(key);
|
|
10687
|
+
if (!previous || field.at >= previous.at) {
|
|
10688
|
+
field.order = ++writer.order;
|
|
10689
|
+
if (field.publication.observation.coverage)
|
|
10690
|
+
field.priorReading = previous?.publication.observation.readings ? previous.publication : previous?.priorReading;
|
|
10691
|
+
pending.set(key, field);
|
|
10692
|
+
}
|
|
10693
|
+
}
|
|
10694
|
+
if (pending.size)
|
|
10695
|
+
writer.pending.set(account, pending);
|
|
10696
|
+
for (const listener of writer.listeners)
|
|
10697
|
+
listener(publication2);
|
|
10698
|
+
schedule(writer, COALESCE_MS);
|
|
10699
|
+
return Promise.resolve(true);
|
|
10700
|
+
}
|
|
10701
|
+
function orderedFields(pending) {
|
|
10702
|
+
return [...pending.values()].flatMap((account) => [...account.values()]).sort((a, b) => a.order - b.order);
|
|
10703
|
+
}
|
|
10704
|
+
function pendingVaultQuota(path2, roster) {
|
|
10705
|
+
const writer = writers.get(resolve7(path2));
|
|
10706
|
+
if (writer) {
|
|
10707
|
+
for (const field of orderedFields(writer.pending)) {
|
|
10708
|
+
if (field.priorReading)
|
|
10709
|
+
roster = applyVaultQuota(roster, field.priorReading).roster;
|
|
10710
|
+
roster = applyVaultQuota(roster, field.publication).roster;
|
|
10711
|
+
}
|
|
10712
|
+
}
|
|
10713
|
+
return roster;
|
|
10714
|
+
}
|
|
10715
|
+
function schedule(writer, delay3) {
|
|
10716
|
+
if (writer.running || writer.timer || !writer.pending.size || writer.abort.signal.aborted)
|
|
10717
|
+
return;
|
|
10718
|
+
writer.timer = setTimeout(() => {
|
|
10719
|
+
writer.timer = void 0;
|
|
10720
|
+
flush(writer);
|
|
10721
|
+
}, delay3);
|
|
10722
|
+
if (!writer.draining)
|
|
10723
|
+
writer.timer.unref?.();
|
|
10724
|
+
}
|
|
10725
|
+
function flush(writer) {
|
|
10726
|
+
if (writer.running || writer.abort.signal.aborted)
|
|
10727
|
+
return;
|
|
10728
|
+
const batch = new Map([...writer.pending].map(([account, pending]) => [
|
|
10729
|
+
account,
|
|
10730
|
+
new Map(pending)
|
|
10731
|
+
]));
|
|
10732
|
+
writer.running = (async () => {
|
|
10733
|
+
try {
|
|
10734
|
+
await mutateVaultRoster(writer.path, (current) => {
|
|
10735
|
+
let next = current;
|
|
10736
|
+
for (const field of orderedFields(batch)) {
|
|
10737
|
+
if (field.priorReading)
|
|
10738
|
+
next = applyVaultQuota(next, field.priorReading).roster;
|
|
10739
|
+
next = applyVaultQuota(next, field.publication).roster;
|
|
10740
|
+
}
|
|
10741
|
+
return { ...next !== current && { next }, result: void 0 };
|
|
10742
|
+
}, { signal: writer.abort.signal });
|
|
10743
|
+
for (const [account, fields2] of batch) {
|
|
10744
|
+
const pending = writer.pending.get(account);
|
|
10745
|
+
for (const [key, field] of fields2) {
|
|
10746
|
+
if (pending?.get(key) === field)
|
|
10747
|
+
pending.delete(key);
|
|
10748
|
+
}
|
|
10749
|
+
if (!pending?.size)
|
|
10750
|
+
writer.pending.delete(account);
|
|
10751
|
+
}
|
|
10752
|
+
writer.failures = 0;
|
|
10753
|
+
} catch (error) {
|
|
10754
|
+
if (!writer.abort.signal.aborted && writer.failures++ === 0) {
|
|
10755
|
+
logger.warn("vault quota publication delayed; retrying", {
|
|
10756
|
+
error: error instanceof Error ? error.message : String(error)
|
|
10757
|
+
});
|
|
10758
|
+
}
|
|
10759
|
+
} finally {
|
|
10760
|
+
writer.running = void 0;
|
|
10761
|
+
for (const wake of writer.wake)
|
|
10762
|
+
wake();
|
|
10763
|
+
const backoff = writer.failures ? Math.min(5e3, 100 * 2 ** Math.min(writer.failures, 6)) * (0.5 + Math.random()) : COALESCE_MS;
|
|
10764
|
+
schedule(writer, backoff);
|
|
10765
|
+
}
|
|
10766
|
+
})();
|
|
10767
|
+
}
|
|
10768
|
+
async function drainVaultQuota(path2, timeoutMs = 1e3) {
|
|
10769
|
+
const key = resolve7(path2);
|
|
10770
|
+
const writer = writers.get(key);
|
|
10771
|
+
if (!writer)
|
|
10772
|
+
return;
|
|
10773
|
+
writer.draining = true;
|
|
10774
|
+
clearTimeout(writer.timer);
|
|
10775
|
+
writer.timer = void 0;
|
|
10776
|
+
let deadline;
|
|
10777
|
+
let wake;
|
|
10778
|
+
const drained = new Promise((done) => {
|
|
10779
|
+
wake = () => {
|
|
10780
|
+
if (!writer.pending.size || writer.abort.signal.aborted)
|
|
10781
|
+
done();
|
|
10782
|
+
};
|
|
10783
|
+
writer.wake.add(wake);
|
|
10784
|
+
wake();
|
|
10785
|
+
});
|
|
10786
|
+
try {
|
|
10787
|
+
if (writer.pending.size)
|
|
10788
|
+
flush(writer);
|
|
10789
|
+
await Promise.race([
|
|
10790
|
+
drained,
|
|
10791
|
+
new Promise((done) => {
|
|
10792
|
+
deadline = setTimeout(done, Math.max(0, timeoutMs));
|
|
10793
|
+
})
|
|
10794
|
+
]);
|
|
10795
|
+
} finally {
|
|
10796
|
+
clearTimeout(deadline);
|
|
10797
|
+
if (wake)
|
|
10798
|
+
writer.wake.delete(wake);
|
|
10799
|
+
writer.draining = false;
|
|
10800
|
+
if (!writer.listeners.size) {
|
|
10801
|
+
writer.abort.abort();
|
|
10802
|
+
clearTimeout(writer.timer);
|
|
10803
|
+
writer.pending.clear();
|
|
10804
|
+
if (writers.get(key) === writer)
|
|
10805
|
+
writers.delete(key);
|
|
10806
|
+
}
|
|
10807
|
+
}
|
|
10808
|
+
}
|
|
10809
|
+
var writers, logger, COALESCE_MS;
|
|
10810
|
+
var init_quota_writer = __esm({
|
|
10811
|
+
"../core/dist/common-auth-embedded/claustrum/quota-writer.js"() {
|
|
10812
|
+
"use strict";
|
|
10813
|
+
init_logger();
|
|
10814
|
+
init_quota();
|
|
10815
|
+
init_roster();
|
|
10816
|
+
writers = /* @__PURE__ */ new Map();
|
|
10817
|
+
logger = createLogger2("claustrum");
|
|
10818
|
+
COALESCE_MS = 100;
|
|
10471
10819
|
}
|
|
10472
10820
|
});
|
|
10473
10821
|
|
|
@@ -10482,6 +10830,7 @@ var init_consumer = __esm({
|
|
|
10482
10830
|
init_enrollment();
|
|
10483
10831
|
init_errors2();
|
|
10484
10832
|
init_insula();
|
|
10833
|
+
init_quota_writer();
|
|
10485
10834
|
init_roster();
|
|
10486
10835
|
init_watch();
|
|
10487
10836
|
ClaustrumConsumer = class {
|
|
@@ -10502,11 +10851,16 @@ var init_consumer = __esm({
|
|
|
10502
10851
|
#insula;
|
|
10503
10852
|
#vaultWatch;
|
|
10504
10853
|
#releaseInsulaWatch;
|
|
10854
|
+
#insulaSkips = /* @__PURE__ */ new Map();
|
|
10505
10855
|
/** When this instance last completed a discovery, by `now`. */
|
|
10506
10856
|
#discoveredAt;
|
|
10857
|
+
#releaseQuotaWriter;
|
|
10507
10858
|
constructor(options) {
|
|
10508
10859
|
this.#options = options;
|
|
10509
10860
|
this.#logger = options.logger ?? createLogger2("claustrum");
|
|
10861
|
+
this.#releaseQuotaWriter = retainVaultQuotaWriter(options.rosterPath, (publication2) => {
|
|
10862
|
+
this.#roster = applyVaultQuota(this.#roster, publication2).roster;
|
|
10863
|
+
});
|
|
10510
10864
|
}
|
|
10511
10865
|
#assertOpen(signal) {
|
|
10512
10866
|
this.#shutdown.signal.throwIfAborted();
|
|
@@ -10520,7 +10874,7 @@ var init_consumer = __esm({
|
|
|
10520
10874
|
this.#shutdown.signal,
|
|
10521
10875
|
...signal ? [signal] : []
|
|
10522
10876
|
]);
|
|
10523
|
-
return new Promise((
|
|
10877
|
+
return new Promise((resolve15, reject) => {
|
|
10524
10878
|
const cleanup2 = () => {
|
|
10525
10879
|
combined.signal.removeEventListener("abort", abort);
|
|
10526
10880
|
combined.dispose();
|
|
@@ -10535,7 +10889,7 @@ var init_consumer = __esm({
|
|
|
10535
10889
|
if (combined.signal.aborted)
|
|
10536
10890
|
reject(combined.signal.reason);
|
|
10537
10891
|
else
|
|
10538
|
-
|
|
10892
|
+
resolve15(value);
|
|
10539
10893
|
}, (error) => {
|
|
10540
10894
|
cleanup2();
|
|
10541
10895
|
reject(error);
|
|
@@ -10635,11 +10989,9 @@ var init_consumer = __esm({
|
|
|
10635
10989
|
let discovered;
|
|
10636
10990
|
const roster = await refreshVaultRoster({
|
|
10637
10991
|
path: this.#options.rosterPath,
|
|
10638
|
-
custody
|
|
10639
|
-
|
|
10640
|
-
|
|
10641
|
-
return discovered;
|
|
10642
|
-
}
|
|
10992
|
+
custody,
|
|
10993
|
+
onInventory: (inventory) => {
|
|
10994
|
+
discovered = inventory;
|
|
10643
10995
|
},
|
|
10644
10996
|
isActive: () => this.#active(),
|
|
10645
10997
|
signal: this.#shutdown.signal,
|
|
@@ -10652,7 +11004,7 @@ var init_consumer = __esm({
|
|
|
10652
11004
|
});
|
|
10653
11005
|
this.#assertOpen();
|
|
10654
11006
|
const changed = roster?.view !== this.#roster?.view;
|
|
10655
|
-
this.#roster = roster;
|
|
11007
|
+
this.#roster = pendingVaultQuota(this.#options.rosterPath, roster);
|
|
10656
11008
|
custody.retain(roster?.rows ?? []);
|
|
10657
11009
|
if (discovered && roster?.view !== void 0)
|
|
10658
11010
|
this.#grantReach = discovered.grantReach ? { view: roster.view, reach: discovered.grantReach } : void 0;
|
|
@@ -10788,13 +11140,48 @@ var init_consumer = __esm({
|
|
|
10788
11140
|
return void 0;
|
|
10789
11141
|
try {
|
|
10790
11142
|
await readClaustrumEnrollmentToken(this.#options.tokenPath);
|
|
10791
|
-
const roster = await readVaultRoster(this.#options.rosterPath);
|
|
11143
|
+
const roster = pendingVaultQuota(this.#options.rosterPath, await readVaultRoster(this.#options.rosterPath));
|
|
10792
11144
|
const row = roster?.rows.find((entry) => entry.routeId === routeId);
|
|
10793
11145
|
return this.#normalizeInsulaQuota(row?.accountIdentity);
|
|
10794
11146
|
} catch {
|
|
10795
11147
|
return void 0;
|
|
10796
11148
|
}
|
|
10797
11149
|
}
|
|
11150
|
+
/** Cache-only background lookup, preserving the reason a route has no reading. */
|
|
11151
|
+
async lookupInsulaQuotaForRoute(routeId) {
|
|
11152
|
+
const options = this.#options.insula;
|
|
11153
|
+
if (!options || this.#shutdown.signal.aborted || !await this.#active())
|
|
11154
|
+
return { miss: "unreachable" };
|
|
11155
|
+
try {
|
|
11156
|
+
await readClaustrumEnrollmentToken(this.#options.tokenPath);
|
|
11157
|
+
const roster = pendingVaultQuota(this.#options.rosterPath, await readVaultRoster(this.#options.rosterPath));
|
|
11158
|
+
const account = roster?.rows.find((row) => row.routeId === routeId)?.accountIdentity;
|
|
11159
|
+
if (!account || !this.#insula)
|
|
11160
|
+
return { miss: "unreachable" };
|
|
11161
|
+
const result = this.#insula.source.lookup(options.provider, account, (this.#options.now ?? Date.now)());
|
|
11162
|
+
const reading = result.reading && options.normalize(result.reading.entry, result.reading.context);
|
|
11163
|
+
if (result.miss)
|
|
11164
|
+
return { miss: result.miss, ...reading !== void 0 && { reading } };
|
|
11165
|
+
return reading === void 0 ? { miss: "unreachable" } : { reading };
|
|
11166
|
+
} catch {
|
|
11167
|
+
return { miss: "unreachable" };
|
|
11168
|
+
}
|
|
11169
|
+
}
|
|
11170
|
+
/** Skip the fallback poll while insula is cold or its upstream fetch failed. */
|
|
11171
|
+
async pollInsulaQuotaForRoute(routeId, fallback) {
|
|
11172
|
+
const result = await this.lookupInsulaQuotaForRoute(routeId);
|
|
11173
|
+
if (result.miss === "cold" || result.miss === "upstream-failed") {
|
|
11174
|
+
if (this.#insulaSkips.get(routeId) !== result.miss) {
|
|
11175
|
+
this.#insulaSkips.set(routeId, result.miss);
|
|
11176
|
+
this.#logger.warn("skipped insula provider poll", {
|
|
11177
|
+
reason: result.miss
|
|
11178
|
+
});
|
|
11179
|
+
}
|
|
11180
|
+
return void 0;
|
|
11181
|
+
}
|
|
11182
|
+
this.#insulaSkips.delete(routeId);
|
|
11183
|
+
return result.miss ? fallback() : result.reading;
|
|
11184
|
+
}
|
|
10798
11185
|
#normalizeInsulaQuota(accountIdentity) {
|
|
10799
11186
|
if (!this.#options.insula || !accountIdentity)
|
|
10800
11187
|
return void 0;
|
|
@@ -10817,7 +11204,7 @@ var init_consumer = __esm({
|
|
|
10817
11204
|
this.#insula = void 0;
|
|
10818
11205
|
throw new ClaustrumConsumerError("not-active", "Claustrum scoped custody is not active");
|
|
10819
11206
|
}
|
|
10820
|
-
const current = await readVaultRoster(this.#options.rosterPath);
|
|
11207
|
+
const current = pendingVaultQuota(this.#options.rosterPath, await readVaultRoster(this.#options.rosterPath));
|
|
10821
11208
|
this.#assertOpen(signal);
|
|
10822
11209
|
const observed = roster.rows.find((row) => row.routeId === routeId);
|
|
10823
11210
|
const configured = current?.rows.find((row) => row.routeId === routeId);
|
|
@@ -10896,13 +11283,13 @@ var init_consumer = __esm({
|
|
|
10896
11283
|
async decline(routeId) {
|
|
10897
11284
|
this.#assertOpen();
|
|
10898
11285
|
await declineVaultRoute(this.#options.rosterPath, routeId);
|
|
10899
|
-
this.#roster = await readVaultRoster(this.#options.rosterPath);
|
|
11286
|
+
this.#roster = pendingVaultQuota(this.#options.rosterPath, await readVaultRoster(this.#options.rosterPath));
|
|
10900
11287
|
this.#custody?.retain(this.#roster?.rows ?? []);
|
|
10901
11288
|
}
|
|
10902
11289
|
async accept(routeId) {
|
|
10903
11290
|
this.#assertOpen();
|
|
10904
11291
|
await acceptVaultRoute(this.#options.rosterPath, routeId);
|
|
10905
|
-
this.#roster = await readVaultRoster(this.#options.rosterPath);
|
|
11292
|
+
this.#roster = pendingVaultQuota(this.#options.rosterPath, await readVaultRoster(this.#options.rosterPath));
|
|
10906
11293
|
}
|
|
10907
11294
|
/**
|
|
10908
11295
|
* Store a quota or profile observation for a vault route. The receipt the
|
|
@@ -10912,7 +11299,7 @@ var init_consumer = __esm({
|
|
|
10912
11299
|
*/
|
|
10913
11300
|
async recordQuota(routeId, observation, attempt) {
|
|
10914
11301
|
this.#assertOpen();
|
|
10915
|
-
|
|
11302
|
+
return recordVaultQuota(this.#options.rosterPath, {
|
|
10916
11303
|
routeId,
|
|
10917
11304
|
observation,
|
|
10918
11305
|
credentialId: attempt.credentialId,
|
|
@@ -10924,27 +11311,21 @@ var init_consumer = __esm({
|
|
|
10924
11311
|
expectedAccountIdentity: attempt.expectedAccountIdentity
|
|
10925
11312
|
}
|
|
10926
11313
|
});
|
|
10927
|
-
if (kept)
|
|
10928
|
-
this.#roster = await readVaultRoster(this.#options.rosterPath);
|
|
10929
|
-
return kept;
|
|
10930
11314
|
}
|
|
10931
11315
|
/**
|
|
10932
11316
|
* Store a background observation that belongs to an account rather than to
|
|
10933
11317
|
* a served credential (an insula reading from `cachedInsulaQuotaForRoute`).
|
|
10934
11318
|
* It lands only while the route is still bound to that known account, so no
|
|
10935
11319
|
* credential fetch is needed and a replaced account's reading is dropped.
|
|
10936
|
-
*
|
|
11320
|
+
* Memory updates immediately; durable publication is detached and coalesced.
|
|
10937
11321
|
*/
|
|
10938
11322
|
async recordAccountQuota(routeId, accountIdentity, observation) {
|
|
10939
11323
|
this.#assertOpen();
|
|
10940
|
-
|
|
11324
|
+
return recordVaultAccountQuota(this.#options.rosterPath, {
|
|
10941
11325
|
routeId,
|
|
10942
11326
|
accountIdentity,
|
|
10943
11327
|
observation
|
|
10944
11328
|
});
|
|
10945
|
-
if (kept)
|
|
10946
|
-
this.#roster = await readVaultRoster(this.#options.rosterPath);
|
|
10947
|
-
return kept;
|
|
10948
11329
|
}
|
|
10949
11330
|
close() {
|
|
10950
11331
|
if (this.#shutdown.signal.aborted)
|
|
@@ -10959,6 +11340,13 @@ var init_consumer = __esm({
|
|
|
10959
11340
|
this.#insula = void 0;
|
|
10960
11341
|
this.#roster = void 0;
|
|
10961
11342
|
this.#grantReach = void 0;
|
|
11343
|
+
void this.#releaseQuotaWriter();
|
|
11344
|
+
forgetPendingVaultDiscovery(this.#options.rosterPath);
|
|
11345
|
+
}
|
|
11346
|
+
/** Close immediately; the last consumer also waits for the writer's bounded drain. */
|
|
11347
|
+
async dispose() {
|
|
11348
|
+
this.close();
|
|
11349
|
+
await this.#releaseQuotaWriter();
|
|
10962
11350
|
}
|
|
10963
11351
|
};
|
|
10964
11352
|
}
|
|
@@ -11001,6 +11389,7 @@ __export(claustrum_exports, {
|
|
|
11001
11389
|
declineAccount: () => declineAccount,
|
|
11002
11390
|
declineVaultRoute: () => declineVaultRoute,
|
|
11003
11391
|
disconnectClaustrumEnrollment: () => disconnectClaustrumEnrollment,
|
|
11392
|
+
drainVaultQuota: () => drainVaultQuota,
|
|
11004
11393
|
enrollmentAuthority: () => enrollmentAuthority,
|
|
11005
11394
|
enrollmentName: () => enrollmentName,
|
|
11006
11395
|
getClaustrumEnrollmentPaths: () => getClaustrumEnrollmentPaths,
|
|
@@ -11039,6 +11428,7 @@ var init_claustrum = __esm({
|
|
|
11039
11428
|
init_host_slot();
|
|
11040
11429
|
init_insula();
|
|
11041
11430
|
init_interlock();
|
|
11431
|
+
init_quota_writer();
|
|
11042
11432
|
init_roster();
|
|
11043
11433
|
init_watch();
|
|
11044
11434
|
}
|
|
@@ -11119,7 +11509,7 @@ async function acquirePiLock(authPath, onCompromised, onRenew) {
|
|
|
11119
11509
|
if (!released && lastUpdate + RENEWAL_STALE < Date.now())
|
|
11120
11510
|
compromise();
|
|
11121
11511
|
}
|
|
11122
|
-
function
|
|
11512
|
+
function schedule2(delay3 = UPDATE) {
|
|
11123
11513
|
if (released)
|
|
11124
11514
|
return;
|
|
11125
11515
|
timer = setTimeout(() => {
|
|
@@ -11133,7 +11523,7 @@ async function acquirePiLock(authPath, onCompromised, onRenew) {
|
|
|
11133
11523
|
if (errorCode(error) === "ENOENT" || lastUpdate + RENEWAL_STALE < Date.now())
|
|
11134
11524
|
compromise();
|
|
11135
11525
|
else
|
|
11136
|
-
|
|
11526
|
+
schedule2(1e3);
|
|
11137
11527
|
}
|
|
11138
11528
|
async function update() {
|
|
11139
11529
|
assertFresh();
|
|
@@ -11166,14 +11556,14 @@ async function acquirePiLock(authPath, onCompromised, onRenew) {
|
|
|
11166
11556
|
mtime = next.getTime();
|
|
11167
11557
|
lastUpdate = Date.now();
|
|
11168
11558
|
active.set(path2, { ...identity, mtime, renewedAt: lastUpdate });
|
|
11169
|
-
|
|
11559
|
+
schedule2();
|
|
11170
11560
|
}
|
|
11171
11561
|
onRenew?.(async () => {
|
|
11172
11562
|
if (timer)
|
|
11173
11563
|
clearTimeout(timer);
|
|
11174
11564
|
await update();
|
|
11175
11565
|
});
|
|
11176
|
-
|
|
11566
|
+
schedule2();
|
|
11177
11567
|
return {
|
|
11178
11568
|
assertFresh,
|
|
11179
11569
|
async release() {
|
|
@@ -11232,7 +11622,7 @@ var init_lock = __esm({
|
|
|
11232
11622
|
import { createHash as createHash7 } from "node:crypto";
|
|
11233
11623
|
import { constants as constants2 } from "node:fs";
|
|
11234
11624
|
import { lstat as lstat3, mkdir as mkdir10, open as open7, unlink as unlink7 } from "node:fs/promises";
|
|
11235
|
-
import { dirname as dirname10, resolve as
|
|
11625
|
+
import { dirname as dirname10, resolve as resolve8 } from "node:path";
|
|
11236
11626
|
import { setTimeout as sleep2 } from "node:timers/promises";
|
|
11237
11627
|
function rootSpans(text2) {
|
|
11238
11628
|
let i = text2.indexOf("{") + 1;
|
|
@@ -11433,8 +11823,8 @@ function createPiSlot(options, onStep, hooks) {
|
|
|
11433
11823
|
if (!provider2 || !options.authPath || !options.stashPath || !placeholderKey || placeholderKey.startsWith("!") || placeholderKey.includes("$") || !Number.isFinite(timeout) || timeout < 0) {
|
|
11434
11824
|
throw new PiSlotError("invalid-options");
|
|
11435
11825
|
}
|
|
11436
|
-
const authPath =
|
|
11437
|
-
const stashPath =
|
|
11826
|
+
const authPath = resolve8(options.authPath);
|
|
11827
|
+
const stashPath = resolve8(options.stashPath);
|
|
11438
11828
|
if (authPath === stashPath || stashPath === `${authPath}.lock`) {
|
|
11439
11829
|
throw new PiSlotError("invalid-options");
|
|
11440
11830
|
}
|
|
@@ -11604,7 +11994,7 @@ var init_pi_slot = __esm({
|
|
|
11604
11994
|
// src/cli.ts
|
|
11605
11995
|
import { execFile } from "node:child_process";
|
|
11606
11996
|
import { realpathSync as realpathSync2 } from "node:fs";
|
|
11607
|
-
import { resolve as
|
|
11997
|
+
import { resolve as resolve14 } from "node:path";
|
|
11608
11998
|
import { createInterface } from "node:readline/promises";
|
|
11609
11999
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
11610
12000
|
import { promisify } from "node:util";
|
|
@@ -16446,7 +16836,7 @@ async function rmEvictingDir(evictingPath) {
|
|
|
16446
16836
|
});
|
|
16447
16837
|
}
|
|
16448
16838
|
async function sleep(ms) {
|
|
16449
|
-
await new Promise((
|
|
16839
|
+
await new Promise((resolve15) => setTimeout(resolve15, ms));
|
|
16450
16840
|
}
|
|
16451
16841
|
async function acquireFencedFileLock(options) {
|
|
16452
16842
|
const lockPath = `${options.path}.${options.name}.lock`;
|
|
@@ -16562,8 +16952,8 @@ function buildLock(lockPath, evictingPath, ownerId, options, now) {
|
|
|
16562
16952
|
let released = false;
|
|
16563
16953
|
let lost = false;
|
|
16564
16954
|
let lostResolve = null;
|
|
16565
|
-
let lostPromise = new Promise((
|
|
16566
|
-
lostResolve =
|
|
16955
|
+
let lostPromise = new Promise((resolve15) => {
|
|
16956
|
+
lostResolve = resolve15;
|
|
16567
16957
|
});
|
|
16568
16958
|
const markLost = () => {
|
|
16569
16959
|
if (lost)
|
|
@@ -16573,9 +16963,9 @@ function buildLock(lockPath, evictingPath, ownerId, options, now) {
|
|
|
16573
16963
|
clearInterval(renewTimer);
|
|
16574
16964
|
renewTimer = null;
|
|
16575
16965
|
}
|
|
16576
|
-
const
|
|
16966
|
+
const resolve15 = lostResolve;
|
|
16577
16967
|
lostResolve = null;
|
|
16578
|
-
|
|
16968
|
+
resolve15?.();
|
|
16579
16969
|
};
|
|
16580
16970
|
const setupRenew = () => {
|
|
16581
16971
|
if (options.renew === false)
|
|
@@ -16799,7 +17189,7 @@ var AccountStorageUnreadableError = class extends Error {
|
|
|
16799
17189
|
}
|
|
16800
17190
|
};
|
|
16801
17191
|
var RETRY_DELAYS_MS = [100, 200, 400, 800, 1e3];
|
|
16802
|
-
var DEFAULT_SLEEP = (ms) => new Promise((
|
|
17192
|
+
var DEFAULT_SLEEP = (ms) => new Promise((resolve15) => setTimeout(resolve15, ms));
|
|
16803
17193
|
var DEFAULT_BUILD_BACKUP_PATH = (path2, now) => `${path2}.corrupt-${now.toISOString().replace(/[:.]/g, "-")}`;
|
|
16804
17194
|
async function ensureSecurePermissions(path2) {
|
|
16805
17195
|
try {
|
|
@@ -17310,7 +17700,7 @@ function getHttpsProxy(url) {
|
|
|
17310
17700
|
}
|
|
17311
17701
|
}
|
|
17312
17702
|
function waitForHead(socket, timeoutMs, onTimeout) {
|
|
17313
|
-
return new Promise((
|
|
17703
|
+
return new Promise((resolve15, reject) => {
|
|
17314
17704
|
let buffer = Buffer2.alloc(0);
|
|
17315
17705
|
const timeout = setTimeout(() => {
|
|
17316
17706
|
onTimeout();
|
|
@@ -17333,7 +17723,7 @@ function waitForHead(socket, timeoutMs, onTimeout) {
|
|
|
17333
17723
|
return;
|
|
17334
17724
|
const head = buffer.subarray(0, marker).toString("latin1");
|
|
17335
17725
|
const leftover = buffer.subarray(marker + 4);
|
|
17336
|
-
cleanup2(() =>
|
|
17726
|
+
cleanup2(() => resolve15({ head, leftover }));
|
|
17337
17727
|
};
|
|
17338
17728
|
socket.on("data", onData);
|
|
17339
17729
|
socket.once("error", onError);
|
|
@@ -17347,7 +17737,7 @@ async function connectViaProxy(proxyUrl, targetUrl, timeoutMs, signal, onDebug)
|
|
|
17347
17737
|
port: Number(proxyUrl.port || DEFAULT_PROXY_PORT),
|
|
17348
17738
|
signal: signal ?? void 0
|
|
17349
17739
|
});
|
|
17350
|
-
await new Promise((
|
|
17740
|
+
await new Promise((resolve15, reject) => {
|
|
17351
17741
|
const timeout = setTimeout(() => {
|
|
17352
17742
|
onDebug?.(`agy transport proxy connect timeout after ${timeoutMs}ms`);
|
|
17353
17743
|
proxySocket.destroy();
|
|
@@ -17356,7 +17746,7 @@ async function connectViaProxy(proxyUrl, targetUrl, timeoutMs, signal, onDebug)
|
|
|
17356
17746
|
const cleanup2 = () => clearTimeout(timeout);
|
|
17357
17747
|
proxySocket.once("connect", () => {
|
|
17358
17748
|
cleanup2();
|
|
17359
|
-
|
|
17749
|
+
resolve15();
|
|
17360
17750
|
});
|
|
17361
17751
|
proxySocket.once("error", (error) => {
|
|
17362
17752
|
cleanup2();
|
|
@@ -17381,7 +17771,7 @@ Host: ${targetHost}:${targetPort}\r
|
|
|
17381
17771
|
if (leftover.length > 0) {
|
|
17382
17772
|
proxySocket.unshift(leftover);
|
|
17383
17773
|
}
|
|
17384
|
-
return await new Promise((
|
|
17774
|
+
return await new Promise((resolve15, reject) => {
|
|
17385
17775
|
const tlsOptions = {
|
|
17386
17776
|
socket: proxySocket,
|
|
17387
17777
|
servername: targetHost,
|
|
@@ -17396,7 +17786,7 @@ Host: ${targetHost}:${targetPort}\r
|
|
|
17396
17786
|
const cleanup2 = () => clearTimeout(timeout);
|
|
17397
17787
|
tlsSocket.once("secureConnect", () => {
|
|
17398
17788
|
cleanup2();
|
|
17399
|
-
|
|
17789
|
+
resolve15(tlsSocket);
|
|
17400
17790
|
});
|
|
17401
17791
|
tlsSocket.once("error", (error) => {
|
|
17402
17792
|
cleanup2();
|
|
@@ -17405,7 +17795,7 @@ Host: ${targetHost}:${targetPort}\r
|
|
|
17405
17795
|
});
|
|
17406
17796
|
}
|
|
17407
17797
|
async function connectDirect(targetUrl, timeoutMs, signal, onDebug) {
|
|
17408
|
-
return await new Promise((
|
|
17798
|
+
return await new Promise((resolve15, reject) => {
|
|
17409
17799
|
const tlsOptions = {
|
|
17410
17800
|
host: targetUrl.hostname,
|
|
17411
17801
|
port: Number(targetUrl.port || DEFAULT_HTTPS_PORT),
|
|
@@ -17421,7 +17811,7 @@ async function connectDirect(targetUrl, timeoutMs, signal, onDebug) {
|
|
|
17421
17811
|
const cleanup2 = () => clearTimeout(timeout);
|
|
17422
17812
|
socket.once("secureConnect", () => {
|
|
17423
17813
|
cleanup2();
|
|
17424
|
-
|
|
17814
|
+
resolve15(socket);
|
|
17425
17815
|
});
|
|
17426
17816
|
socket.once("error", (error) => {
|
|
17427
17817
|
cleanup2();
|
|
@@ -17683,6 +18073,7 @@ var ANTIGRAVITY_SCOPES = [
|
|
|
17683
18073
|
var ANTIGRAVITY_REDIRECT_URI = "http://localhost:51121/oauth-callback";
|
|
17684
18074
|
var ANTIGRAVITY_ENDPOINT_DAILY = "https://daily-cloudcode-pa.googleapis.com";
|
|
17685
18075
|
var ANTIGRAVITY_ENDPOINT_PROD = "https://cloudcode-pa.googleapis.com";
|
|
18076
|
+
var ANTIGRAVITY_QUOTA_ENDPOINT = ANTIGRAVITY_ENDPOINT_DAILY;
|
|
17686
18077
|
var ANTIGRAVITY_ENDPOINT_FALLBACKS = [
|
|
17687
18078
|
ANTIGRAVITY_ENDPOINT_DAILY,
|
|
17688
18079
|
ANTIGRAVITY_ENDPOINT_PROD
|
|
@@ -18093,8 +18484,8 @@ function getDefaultTierId(allowedTiers) {
|
|
|
18093
18484
|
return allowedTiers[0]?.id;
|
|
18094
18485
|
}
|
|
18095
18486
|
function wait(ms) {
|
|
18096
|
-
return new Promise((
|
|
18097
|
-
setTimeout(
|
|
18487
|
+
return new Promise((resolve15) => {
|
|
18488
|
+
setTimeout(resolve15, ms);
|
|
18098
18489
|
});
|
|
18099
18490
|
}
|
|
18100
18491
|
function extractManagedProjectId(payload) {
|
|
@@ -18935,17 +19326,17 @@ import {
|
|
|
18935
19326
|
writeFileSync
|
|
18936
19327
|
} from "node:fs";
|
|
18937
19328
|
import { homedir as homedir3 } from "node:os";
|
|
18938
|
-
import { dirname as dirname14, join as join8, resolve as
|
|
19329
|
+
import { dirname as dirname14, join as join8, resolve as resolve11 } from "node:path";
|
|
18939
19330
|
|
|
18940
19331
|
// src/common-auth-embedded/logger/engine.js
|
|
18941
19332
|
import { appendFileSync as appendFileSync2, chmodSync as chmodSync2, existsSync as existsSync2, renameSync as renameSync2, statSync as statSync3 } from "node:fs";
|
|
18942
19333
|
import { open as open8 } from "node:fs/promises";
|
|
18943
|
-
import { dirname as dirname13, resolve as
|
|
19334
|
+
import { dirname as dirname13, resolve as resolve10 } from "node:path";
|
|
18944
19335
|
|
|
18945
19336
|
// src/common-auth-embedded/fs/private-files.js
|
|
18946
19337
|
import { randomUUID as randomUUID11 } from "node:crypto";
|
|
18947
19338
|
import { lstat as lstat4, readFile as readFile7, rename as rename7, unlink as unlink8 } from "node:fs/promises";
|
|
18948
|
-
import { dirname as dirname12, resolve as
|
|
19339
|
+
import { dirname as dirname12, resolve as resolve9 } from "node:path";
|
|
18949
19340
|
var windowsPrivateFiles2 = process.platform === "win32";
|
|
18950
19341
|
var migrationNotices2 = /* @__PURE__ */ new Set();
|
|
18951
19342
|
function ioCode2(detail) {
|
|
@@ -18996,7 +19387,7 @@ async function privateOperation2(path2, stage, operation) {
|
|
|
18996
19387
|
}
|
|
18997
19388
|
var safeParentOptionsForTest2;
|
|
18998
19389
|
async function verifySafeDirectory2(path2, options) {
|
|
18999
|
-
path2 =
|
|
19390
|
+
path2 = resolve9(path2);
|
|
19000
19391
|
options ??= safeParentOptionsForTest2;
|
|
19001
19392
|
await privateOperation2(path2, "safe-parent", async () => {
|
|
19002
19393
|
const result = await (await loadBackend2()).verifySafeParent(path2, options);
|
|
@@ -19011,7 +19402,7 @@ async function verifySafeDirectory2(path2, options) {
|
|
|
19011
19402
|
});
|
|
19012
19403
|
}
|
|
19013
19404
|
async function verifyPrivate2(path2, kind, migrate = false) {
|
|
19014
|
-
path2 =
|
|
19405
|
+
path2 = resolve9(path2);
|
|
19015
19406
|
if (kind === "directory")
|
|
19016
19407
|
return verifySafeDirectory2(path2);
|
|
19017
19408
|
await privateOperation2(path2, "verify", async () => {
|
|
@@ -19046,7 +19437,7 @@ async function verifyPrivate2(path2, kind, migrate = false) {
|
|
|
19046
19437
|
});
|
|
19047
19438
|
}
|
|
19048
19439
|
async function ensurePrivateDirectory3(path2, _migrate = false, options) {
|
|
19049
|
-
path2 =
|
|
19440
|
+
path2 = resolve9(path2);
|
|
19050
19441
|
await privateOperation2(path2, "directory", async () => {
|
|
19051
19442
|
const api = await loadBackend2();
|
|
19052
19443
|
try {
|
|
@@ -19077,7 +19468,7 @@ async function readPrivateText2(path2, migrate = false) {
|
|
|
19077
19468
|
async function readPrivateBuffer2(path2, migrate = false) {
|
|
19078
19469
|
if (!windowsPrivateFiles2)
|
|
19079
19470
|
return readFile7(path2);
|
|
19080
|
-
path2 =
|
|
19471
|
+
path2 = resolve9(path2);
|
|
19081
19472
|
if (migrate) {
|
|
19082
19473
|
await verifySafeDirectory2(dirname12(path2));
|
|
19083
19474
|
await verifyPrivate2(path2, "file", true);
|
|
@@ -19085,20 +19476,20 @@ async function readPrivateBuffer2(path2, migrate = false) {
|
|
|
19085
19476
|
return privateOperation2(path2, "read", async () => (await loadBackend2()).readOwnerOnly(path2));
|
|
19086
19477
|
}
|
|
19087
19478
|
async function createPrivateBytes2(path2, bytes) {
|
|
19088
|
-
await verifySafeDirectory2(dirname12(
|
|
19479
|
+
await verifySafeDirectory2(dirname12(resolve9(path2)));
|
|
19089
19480
|
await privateOperation2(path2, "create", async () => {
|
|
19090
|
-
await (await loadBackend2()).createPrivateFile(
|
|
19481
|
+
await (await loadBackend2()).createPrivateFile(resolve9(path2), bytes);
|
|
19091
19482
|
});
|
|
19092
19483
|
}
|
|
19093
19484
|
async function createPrivateDirectoryExclusive2(path2) {
|
|
19094
|
-
await verifySafeDirectory2(dirname12(
|
|
19485
|
+
await verifySafeDirectory2(dirname12(resolve9(path2)));
|
|
19095
19486
|
await privateOperation2(path2, "directory-create", async () => {
|
|
19096
|
-
await (await loadBackend2()).createOwnerOnly(
|
|
19487
|
+
await (await loadBackend2()).createOwnerOnly(resolve9(path2), { kind: "dir" });
|
|
19097
19488
|
});
|
|
19098
19489
|
}
|
|
19099
19490
|
async function replaceWindowsFile2(from, to, options = {}) {
|
|
19100
|
-
from =
|
|
19101
|
-
to =
|
|
19491
|
+
from = resolve9(from);
|
|
19492
|
+
to = resolve9(to);
|
|
19102
19493
|
const now = options.now ?? (() => performance.now());
|
|
19103
19494
|
const start = now();
|
|
19104
19495
|
const leaseDeadline = options.deadline ?? Infinity;
|
|
@@ -19141,7 +19532,7 @@ async function replaceWindowsFile2(from, to, options = {}) {
|
|
|
19141
19532
|
throw error;
|
|
19142
19533
|
}
|
|
19143
19534
|
async function writePrivateAtomic2(path2, bytes, options = {}) {
|
|
19144
|
-
path2 =
|
|
19535
|
+
path2 = resolve9(path2);
|
|
19145
19536
|
await ensurePrivateDirectory3(dirname12(path2));
|
|
19146
19537
|
try {
|
|
19147
19538
|
await verifyPrivate2(path2, "file", true);
|
|
@@ -19149,7 +19540,7 @@ async function writePrivateAtomic2(path2, bytes, options = {}) {
|
|
|
19149
19540
|
if (error.code !== "ENOENT")
|
|
19150
19541
|
throw error;
|
|
19151
19542
|
}
|
|
19152
|
-
const stage =
|
|
19543
|
+
const stage = resolve9(options.stagePath ?? `${path2}.${randomUUID11()}.tmp`);
|
|
19153
19544
|
if (dirname12(stage) !== dirname12(path2))
|
|
19154
19545
|
throw new PrivateFileError2(path2, "stage-directory", { code: "EXDEV" });
|
|
19155
19546
|
let created = false;
|
|
@@ -19225,15 +19616,15 @@ function createRedactor2(options = {}) {
|
|
|
19225
19616
|
return SECRET_KEY_EXACT2.test(key) || normalized.includes("apikey") || normalized.endsWith("secret") || normalized.endsWith("password") || normalized.endsWith("token") && !normalized.endsWith("tokens") || !!options.extraSecretKeys?.(normalized);
|
|
19226
19617
|
}
|
|
19227
19618
|
function errorEntries(error) {
|
|
19228
|
-
const
|
|
19619
|
+
const fields2 = error;
|
|
19229
19620
|
const entries = [
|
|
19230
19621
|
["name", error.name],
|
|
19231
19622
|
["message", error.message],
|
|
19232
19623
|
["stack", error.stack]
|
|
19233
19624
|
];
|
|
19234
19625
|
for (const key of ["code", "status", "cause"])
|
|
19235
|
-
if (
|
|
19236
|
-
entries.push([key,
|
|
19626
|
+
if (fields2[key] !== void 0)
|
|
19627
|
+
entries.push([key, fields2[key]]);
|
|
19237
19628
|
const listed = new Set(entries.map(([key]) => key));
|
|
19238
19629
|
for (const entry of Object.entries(error))
|
|
19239
19630
|
if (!listed.has(entry[0]))
|
|
@@ -19334,7 +19725,7 @@ async function openWindowsFile2(sink, file) {
|
|
|
19334
19725
|
return sink.handle;
|
|
19335
19726
|
}
|
|
19336
19727
|
async function flushWindowsFile2(sink, file, text2) {
|
|
19337
|
-
file =
|
|
19728
|
+
file = resolve10(file);
|
|
19338
19729
|
try {
|
|
19339
19730
|
if (sink.file !== file)
|
|
19340
19731
|
await closeWindowsFile2(sink);
|
|
@@ -19471,7 +19862,7 @@ function createEngine2(options) {
|
|
|
19471
19862
|
} catch {
|
|
19472
19863
|
}
|
|
19473
19864
|
}
|
|
19474
|
-
function
|
|
19865
|
+
function schedule2() {
|
|
19475
19866
|
if (!timer)
|
|
19476
19867
|
timer = setTimeout(() => {
|
|
19477
19868
|
timer = void 0;
|
|
@@ -19513,7 +19904,7 @@ function createEngine2(options) {
|
|
|
19513
19904
|
void flushed.catch(() => {
|
|
19514
19905
|
});
|
|
19515
19906
|
} else
|
|
19516
|
-
|
|
19907
|
+
schedule2();
|
|
19517
19908
|
} catch {
|
|
19518
19909
|
}
|
|
19519
19910
|
}
|
|
@@ -20072,13 +20463,13 @@ function closeDebugLog() {
|
|
|
20072
20463
|
if (!state || !current) return Promise.resolve();
|
|
20073
20464
|
state.logStream = null;
|
|
20074
20465
|
if (state.logFilePath) liveLogFilePaths.delete(state.logFilePath);
|
|
20075
|
-
return new Promise((
|
|
20076
|
-
current.once("close", () =>
|
|
20077
|
-
current.once("error", () =>
|
|
20466
|
+
return new Promise((resolve15) => {
|
|
20467
|
+
current.once("close", () => resolve15());
|
|
20468
|
+
current.once("error", () => resolve15());
|
|
20078
20469
|
try {
|
|
20079
20470
|
current.end();
|
|
20080
20471
|
} catch {
|
|
20081
|
-
|
|
20472
|
+
resolve15();
|
|
20082
20473
|
}
|
|
20083
20474
|
});
|
|
20084
20475
|
}
|
|
@@ -20376,7 +20767,7 @@ var LegacyAccountPoolRetiredError = class extends Error {
|
|
|
20376
20767
|
};
|
|
20377
20768
|
async function assertLegacyPoolInUse(legacyPath) {
|
|
20378
20769
|
try {
|
|
20379
|
-
await assertLegacyAccountStorageWritable(
|
|
20770
|
+
await assertLegacyAccountStorageWritable(resolve11(legacyPath));
|
|
20380
20771
|
} catch (error) {
|
|
20381
20772
|
throw new LegacyAccountPoolRetiredError(legacyPath, { cause: error });
|
|
20382
20773
|
}
|
|
@@ -20396,7 +20787,7 @@ function refusalMessage(admission) {
|
|
|
20396
20787
|
}
|
|
20397
20788
|
async function bindingOf(options) {
|
|
20398
20789
|
const now = options.now ?? (() => Date.now());
|
|
20399
|
-
const legacyPath =
|
|
20790
|
+
const legacyPath = resolve11(options.legacyPath ?? getStoragePath());
|
|
20400
20791
|
return {
|
|
20401
20792
|
legacyPath,
|
|
20402
20793
|
now,
|
|
@@ -20464,7 +20855,7 @@ async function openAccountStore(options) {
|
|
|
20464
20855
|
}
|
|
20465
20856
|
function initializeFreshAccountStoreFor(modules, options = {}) {
|
|
20466
20857
|
return initializeFreshAccountStore(modules, {
|
|
20467
|
-
legacyPath:
|
|
20858
|
+
legacyPath: resolve11(options.legacyPath ?? getStoragePath()),
|
|
20468
20859
|
now: options.now ?? (() => Date.now())
|
|
20469
20860
|
});
|
|
20470
20861
|
}
|
|
@@ -20738,7 +21129,7 @@ async function fetchLegacyModelsFallback(options) {
|
|
|
20738
21129
|
const modelsResponse = await fetchAvailableModels({
|
|
20739
21130
|
accessToken: options.accessToken,
|
|
20740
21131
|
projectId: options.projectId,
|
|
20741
|
-
endpoints:
|
|
21132
|
+
endpoints: [ANTIGRAVITY_QUOTA_ENDPOINT],
|
|
20742
21133
|
userAgent: buildAntigravityHarnessUserAgent(),
|
|
20743
21134
|
timeoutMs: 1e4,
|
|
20744
21135
|
...options.fetchVia ? { fetchVia: options.fetchVia } : {}
|
|
@@ -20767,7 +21158,7 @@ async function fetchQuotaPayloads(options) {
|
|
|
20767
21158
|
accessToken,
|
|
20768
21159
|
managedProjectId,
|
|
20769
21160
|
projectId,
|
|
20770
|
-
endpoints:
|
|
21161
|
+
endpoints: [ANTIGRAVITY_QUOTA_ENDPOINT],
|
|
20771
21162
|
userAgent: buildAntigravityHarnessUserAgent(),
|
|
20772
21163
|
timeoutMs: 1e4,
|
|
20773
21164
|
...fetchVia ? { fetchVia } : {}
|
|
@@ -20794,14 +21185,14 @@ async function fetchQuotaPayloads(options) {
|
|
|
20794
21185
|
};
|
|
20795
21186
|
}
|
|
20796
21187
|
function untilQuotaAborted(pending, signal) {
|
|
20797
|
-
return new Promise((
|
|
21188
|
+
return new Promise((resolve15, reject) => {
|
|
20798
21189
|
const abort = () => reject(signal.reason);
|
|
20799
21190
|
if (signal.aborted) abort();
|
|
20800
21191
|
else signal.addEventListener("abort", abort, { once: true });
|
|
20801
21192
|
void pending.then(
|
|
20802
21193
|
(value) => {
|
|
20803
21194
|
signal.removeEventListener("abort", abort);
|
|
20804
|
-
|
|
21195
|
+
resolve15(value);
|
|
20805
21196
|
},
|
|
20806
21197
|
(error) => {
|
|
20807
21198
|
signal.removeEventListener("abort", abort);
|
|
@@ -20872,6 +21263,7 @@ function makeFetchAccountQuota(client, providerId, fetchVia) {
|
|
|
20872
21263
|
}),
|
|
20873
21264
|
signal
|
|
20874
21265
|
);
|
|
21266
|
+
if (payloads.quota.error) throw new Error(payloads.quota.error);
|
|
20875
21267
|
return {
|
|
20876
21268
|
index,
|
|
20877
21269
|
email: account.email,
|
|
@@ -20927,6 +21319,7 @@ function makeFetchAccountQuota(client, providerId, fetchVia) {
|
|
|
20927
21319
|
logger: log7
|
|
20928
21320
|
});
|
|
20929
21321
|
quotaResult = payloads.quota;
|
|
21322
|
+
if (quotaResult.error) throw new Error(quotaResult.error);
|
|
20930
21323
|
fellBackToLegacy = payloads.fellBackToLegacy;
|
|
20931
21324
|
for (const [family, groupQuota] of Object.entries(quotaResult.groups)) {
|
|
20932
21325
|
const remainingPercent = (groupQuota.remainingFraction ?? 0) * 100;
|
|
@@ -21081,12 +21474,12 @@ async function startOAuthListener({
|
|
|
21081
21474
|
let resolveCallback;
|
|
21082
21475
|
let rejectCallback;
|
|
21083
21476
|
let timeoutHandle;
|
|
21084
|
-
const callbackPromise = new Promise((
|
|
21477
|
+
const callbackPromise = new Promise((resolve15, reject) => {
|
|
21085
21478
|
resolveCallback = (url) => {
|
|
21086
21479
|
if (settled) return;
|
|
21087
21480
|
settled = true;
|
|
21088
21481
|
if (timeoutHandle) clearTimeout(timeoutHandle);
|
|
21089
|
-
|
|
21482
|
+
resolve15(url);
|
|
21090
21483
|
};
|
|
21091
21484
|
rejectCallback = (error) => {
|
|
21092
21485
|
if (settled) return;
|
|
@@ -21245,7 +21638,7 @@ async function startOAuthListener({
|
|
|
21245
21638
|
});
|
|
21246
21639
|
});
|
|
21247
21640
|
const bindAddress = getBindAddress();
|
|
21248
|
-
await new Promise((
|
|
21641
|
+
await new Promise((resolve15, reject) => {
|
|
21249
21642
|
const handleError = (error) => {
|
|
21250
21643
|
server.off("error", handleError);
|
|
21251
21644
|
if (error.code === "EADDRINUSE") {
|
|
@@ -21261,7 +21654,7 @@ async function startOAuthListener({
|
|
|
21261
21654
|
server.once("error", handleError);
|
|
21262
21655
|
server.listen(port, bindAddress, () => {
|
|
21263
21656
|
server.off("error", handleError);
|
|
21264
|
-
|
|
21657
|
+
resolve15();
|
|
21265
21658
|
});
|
|
21266
21659
|
});
|
|
21267
21660
|
server.on("error", (error) => {
|
|
@@ -21269,7 +21662,7 @@ async function startOAuthListener({
|
|
|
21269
21662
|
});
|
|
21270
21663
|
return {
|
|
21271
21664
|
waitForCallback: () => callbackPromise,
|
|
21272
|
-
close: () => new Promise((
|
|
21665
|
+
close: () => new Promise((resolve15, reject) => {
|
|
21273
21666
|
server.close((error) => {
|
|
21274
21667
|
if (error && error.code !== "ERR_SERVER_NOT_RUNNING") {
|
|
21275
21668
|
reject(error);
|
|
@@ -21278,7 +21671,7 @@ async function startOAuthListener({
|
|
|
21278
21671
|
if (!settled) {
|
|
21279
21672
|
rejectCallback(new Error("OAuth listener closed before callback"));
|
|
21280
21673
|
}
|
|
21281
|
-
|
|
21674
|
+
resolve15();
|
|
21282
21675
|
});
|
|
21283
21676
|
})
|
|
21284
21677
|
};
|
|
@@ -21290,7 +21683,7 @@ async function startOAuthListener({
|
|
|
21290
21683
|
|
|
21291
21684
|
// src/setup.ts
|
|
21292
21685
|
import { lstat as lstat5, readFile as readFile10 } from "node:fs/promises";
|
|
21293
|
-
import { join as join15, resolve as
|
|
21686
|
+
import { join as join15, resolve as resolve13 } from "node:path";
|
|
21294
21687
|
|
|
21295
21688
|
// src/auth-method-labels.ts
|
|
21296
21689
|
var OPENCODE2_POOL_AUTH_LABEL = "Google (antigravity-auth pool, browser)";
|
|
@@ -21462,7 +21855,7 @@ async function select2(terminal, items, options) {
|
|
|
21462
21855
|
writeLine("");
|
|
21463
21856
|
renderedLines = lines;
|
|
21464
21857
|
};
|
|
21465
|
-
return new Promise((
|
|
21858
|
+
return new Promise((resolve15) => {
|
|
21466
21859
|
const wasRaw = stdin.isRaw ?? false;
|
|
21467
21860
|
const cleanup2 = () => {
|
|
21468
21861
|
if (cleaned)
|
|
@@ -21482,7 +21875,7 @@ async function select2(terminal, items, options) {
|
|
|
21482
21875
|
};
|
|
21483
21876
|
const finish = (value) => {
|
|
21484
21877
|
cleanup2();
|
|
21485
|
-
|
|
21878
|
+
resolve15(value);
|
|
21486
21879
|
};
|
|
21487
21880
|
const onSignal = () => finish(null);
|
|
21488
21881
|
const onKey = (data) => {
|
|
@@ -21522,7 +21915,7 @@ async function select2(terminal, items, options) {
|
|
|
21522
21915
|
stdin.setRawMode(true);
|
|
21523
21916
|
} catch {
|
|
21524
21917
|
cleanup2();
|
|
21525
|
-
|
|
21918
|
+
resolve15(null);
|
|
21526
21919
|
return;
|
|
21527
21920
|
}
|
|
21528
21921
|
stdin.resume();
|
|
@@ -21536,7 +21929,7 @@ async function select2(terminal, items, options) {
|
|
|
21536
21929
|
import { createHash as createHash9, randomBytes as randomBytes3, randomUUID as randomUUID14 } from "node:crypto";
|
|
21537
21930
|
import { constants as fsConstants2 } from "node:fs";
|
|
21538
21931
|
import { chmod as chmod3, mkdir as mkdir12, open as open10, readFile as readFile9, realpath as realpath4, rename as rename9, stat as stat7, unlink as unlink9 } from "node:fs/promises";
|
|
21539
|
-
import { basename as basename4, dirname as dirname16, extname as extname2, isAbsolute as isAbsolute3, join as join10, resolve as
|
|
21932
|
+
import { basename as basename4, dirname as dirname16, extname as extname2, isAbsolute as isAbsolute3, join as join10, resolve as resolve12 } from "node:path";
|
|
21540
21933
|
import { ClaustrumCredentialError as ClaustrumCredentialError5, ClaustrumClient as ClaustrumWireClient2, writeEnrollmentTokenFile as writeEnrollmentTokenFile2 } from "@cortexkit/claustrum-client";
|
|
21541
21934
|
|
|
21542
21935
|
// src/common-auth-embedded/fs/lock-constants.js
|
|
@@ -21601,8 +21994,8 @@ async function acquireRefreshFileLockWithClock2(options) {
|
|
|
21601
21994
|
let releaseConfirmed = false;
|
|
21602
21995
|
let loss;
|
|
21603
21996
|
let resolveLoss;
|
|
21604
|
-
const lostPromise = new Promise((
|
|
21605
|
-
resolveLoss =
|
|
21997
|
+
const lostPromise = new Promise((resolve15) => {
|
|
21998
|
+
resolveLoss = resolve15;
|
|
21606
21999
|
});
|
|
21607
22000
|
function notifyTimerStep(event) {
|
|
21608
22001
|
try {
|
|
@@ -21759,7 +22152,7 @@ async function acquireRefreshFileLockWithClock2(options) {
|
|
|
21759
22152
|
}
|
|
21760
22153
|
}
|
|
21761
22154
|
async function backoff() {
|
|
21762
|
-
await new Promise((
|
|
22155
|
+
await new Promise((resolve15) => setTimeout(resolve15, Math.floor(Math.random() * 4)));
|
|
21763
22156
|
}
|
|
21764
22157
|
async function readLockState(notifyReady = true) {
|
|
21765
22158
|
if (notifyReady && options.onStep)
|
|
@@ -22245,7 +22638,7 @@ function hostEnrollmentPaths2(input) {
|
|
|
22245
22638
|
const override = input.override?.trim();
|
|
22246
22639
|
if (override && !isAbsolute3(override) && !input.cwd)
|
|
22247
22640
|
throw new ClaustrumConsumerError2("invalid-state", "A relative Claustrum enrollment override needs a base directory");
|
|
22248
|
-
const tokenPath = override ? isAbsolute3(override) ? override :
|
|
22641
|
+
const tokenPath = override ? isAbsolute3(override) ? override : resolve12(input.cwd, override) : join10(input.stateDir, `${input.host}-enrollment.json`);
|
|
22249
22642
|
return getClaustrumEnrollmentPaths2(tokenPath);
|
|
22250
22643
|
}
|
|
22251
22644
|
function isRecord9(value) {
|
|
@@ -22374,13 +22767,13 @@ async function readBoundedJson2(path2) {
|
|
|
22374
22767
|
await descriptor.close();
|
|
22375
22768
|
}
|
|
22376
22769
|
}
|
|
22377
|
-
function accountRecords2(text2,
|
|
22770
|
+
function accountRecords2(text2, fields2) {
|
|
22378
22771
|
const records = [];
|
|
22379
22772
|
for (const line of text2.split("\n")) {
|
|
22380
22773
|
if (line.trim() === "" || line.startsWith("#"))
|
|
22381
22774
|
continue;
|
|
22382
22775
|
const parts = line.split(":");
|
|
22383
|
-
if (parts.length !==
|
|
22776
|
+
if (parts.length !== fields2 || !/^[^\s:,]+$/.test(parts[0] ?? "") || !/^\d+$/.test(parts[2] ?? "") || !Number.isSafeInteger(Number(parts[2])) || fields2 === 7 && (!/^\d+$/.test(parts[3] ?? "") || !Number.isSafeInteger(Number(parts[3]))) || fields2 === 4 && parts[3] !== "" && !/^[^\s:,]+(?:,[^\s:,]+)*$/.test(parts[3] ?? ""))
|
|
22384
22777
|
return void 0;
|
|
22385
22778
|
records.push(parts);
|
|
22386
22779
|
}
|
|
@@ -22840,7 +23233,7 @@ var ByteTail = class {
|
|
|
22840
23233
|
};
|
|
22841
23234
|
var defaultCommandRunner = {
|
|
22842
23235
|
run(file, args, options = {}) {
|
|
22843
|
-
return new Promise((
|
|
23236
|
+
return new Promise((resolve15) => {
|
|
22844
23237
|
const started = performance.now();
|
|
22845
23238
|
const timeoutMs = options.timeoutMs ?? 15e3;
|
|
22846
23239
|
const stderr = new ByteTail();
|
|
@@ -22858,7 +23251,7 @@ var defaultCommandRunner = {
|
|
|
22858
23251
|
stdio: ["ignore", "pipe", "pipe"]
|
|
22859
23252
|
});
|
|
22860
23253
|
} catch {
|
|
22861
|
-
|
|
23254
|
+
resolve15({
|
|
22862
23255
|
exitCode: 1,
|
|
22863
23256
|
stdout: "",
|
|
22864
23257
|
stderr: "",
|
|
@@ -22893,7 +23286,7 @@ var defaultCommandRunner = {
|
|
|
22893
23286
|
settled = true;
|
|
22894
23287
|
if (timer)
|
|
22895
23288
|
clearTimeout(timer);
|
|
22896
|
-
|
|
23289
|
+
resolve15({
|
|
22897
23290
|
exitCode: spawnError ? 1 : outputExceeded ? 1 : code2 ?? 1,
|
|
22898
23291
|
stdout: Buffer.concat(stdout, stdoutLength).toString("utf8"),
|
|
22899
23292
|
stderr: stderr.toString(),
|
|
@@ -23322,6 +23715,7 @@ Please quit all OpenCode, LiteCode, and Pi processes before running setup.`);
|
|
|
23322
23715
|
};
|
|
23323
23716
|
async function listSetupProcesses(runner = defaultCommandRunner, options = {}) {
|
|
23324
23717
|
const windows = (options.platform ?? process.platform) === "win32";
|
|
23718
|
+
const selfPid = options.selfPid ?? process.pid;
|
|
23325
23719
|
let inspection = {
|
|
23326
23720
|
step: windows ? "tasklist" : "ps",
|
|
23327
23721
|
exitCode: null,
|
|
@@ -23390,7 +23784,7 @@ async function listSetupProcesses(runner = defaultCommandRunner, options = {}) {
|
|
|
23390
23784
|
}
|
|
23391
23785
|
if (!processes.length)
|
|
23392
23786
|
throw new ProcessInspectionError(inspection);
|
|
23393
|
-
const runtimes = processes.filter((entry) => entry.pid !==
|
|
23787
|
+
const runtimes = processes.filter((entry) => entry.pid !== selfPid && /^(?:node|bun)\.exe$/i.test(entry.command));
|
|
23394
23788
|
if (windows && runtimes.length && options.inspectRuntimes !== false) {
|
|
23395
23789
|
const details = await inspect("CIM", "powershell.exe", [
|
|
23396
23790
|
"-NoProfile",
|
|
@@ -23423,7 +23817,8 @@ async function listSetupProcesses(runner = defaultCommandRunner, options = {}) {
|
|
|
23423
23817
|
}
|
|
23424
23818
|
}
|
|
23425
23819
|
function createProcessFence(runner = defaultCommandRunner, options = {}) {
|
|
23426
|
-
const
|
|
23820
|
+
const selfPid = options.selfPid ?? process.pid;
|
|
23821
|
+
const isHost = (entry) => entry.pid !== selfPid && hostName(entry.command) !== null;
|
|
23427
23822
|
return {
|
|
23428
23823
|
async listRunningHosts(env3) {
|
|
23429
23824
|
return (await listSetupProcesses(runner, { ...options, env: env3 })).filter(isHost);
|
|
@@ -23437,7 +23832,7 @@ function createProcessFence(runner = defaultCommandRunner, options = {}) {
|
|
|
23437
23832
|
const windows = (options.platform ?? process.platform) === "win32";
|
|
23438
23833
|
return {
|
|
23439
23834
|
hosts: processes.filter(isHost),
|
|
23440
|
-
uncheckedRuntimes: windows ? processes.filter((entry) => entry.pid !==
|
|
23835
|
+
uncheckedRuntimes: windows ? processes.filter((entry) => entry.pid !== selfPid && /^(?:node|bun)\.exe$/i.test(entry.command)).length : 0
|
|
23441
23836
|
};
|
|
23442
23837
|
}
|
|
23443
23838
|
};
|
|
@@ -24019,7 +24414,7 @@ async function writeNativeSlot(host, slot, context, expectedAuthority = "local")
|
|
|
24019
24414
|
beforeRename: async () => {
|
|
24020
24415
|
await assertSetupHostsStopped();
|
|
24021
24416
|
const claustrum = await loadCommonAuthClaustrum();
|
|
24022
|
-
const stateDir = host === "opencode" ? openCodeVaultPaths(
|
|
24417
|
+
const stateDir = host === "opencode" ? openCodeVaultPaths(resolve13(getStoragePath())).dir : getPiAntigravityVaultDir();
|
|
24023
24418
|
if (await claustrum.enrollmentAuthority(
|
|
24024
24419
|
claustrum.hostEnrollmentPaths({ stateDir, host }),
|
|
24025
24420
|
`antigravity-auth-${host}`
|
|
@@ -24049,7 +24444,7 @@ async function persistPiSetupLogin(result, context) {
|
|
|
24049
24444
|
}
|
|
24050
24445
|
async function createSetupPlugin(deps, migrateOpenCode, forceLogin = false) {
|
|
24051
24446
|
const claustrum = await loadCommonAuthClaustrum();
|
|
24052
|
-
const opencode = openCodeVaultPaths(
|
|
24447
|
+
const opencode = openCodeVaultPaths(resolve13(getStoragePath()));
|
|
24053
24448
|
const piDir = getPiAntigravityVaultDir();
|
|
24054
24449
|
const hosts = {
|
|
24055
24450
|
opencode: {
|
|
@@ -24068,7 +24463,7 @@ async function createSetupPlugin(deps, migrateOpenCode, forceLogin = false) {
|
|
|
24068
24463
|
const assertLocal = async (host, context) => {
|
|
24069
24464
|
if (host === "opencode")
|
|
24070
24465
|
return assertLocalOpenCodeLogin(
|
|
24071
|
-
|
|
24466
|
+
resolve13(getStoragePath()),
|
|
24072
24467
|
context.opencodeGeneration
|
|
24073
24468
|
);
|
|
24074
24469
|
if (await authority(host) !== "local")
|
|
@@ -24600,7 +24995,7 @@ function createDefaultCliDependencies() {
|
|
|
24600
24995
|
throw new Error(
|
|
24601
24996
|
"Pi setup requires its detected native agent directory."
|
|
24602
24997
|
);
|
|
24603
|
-
const legacyPath =
|
|
24998
|
+
const legacyPath = resolve14(getStoragePath());
|
|
24604
24999
|
const repository = host === "pi" ? void 0 : await prepareCliLoginStore(legacyPath, context?.opencodeGeneration);
|
|
24605
25000
|
try {
|
|
24606
25001
|
return await performOAuthLogin(request, {
|
|
@@ -24760,7 +25155,7 @@ async function readAccountStore(legacyPath) {
|
|
|
24760
25155
|
function createDefaultAccountStoreOperations() {
|
|
24761
25156
|
const offline = { processesStopped: true };
|
|
24762
25157
|
return {
|
|
24763
|
-
legacyPath: () =>
|
|
25158
|
+
legacyPath: () => resolve14(getStoragePath()),
|
|
24764
25159
|
migrate: async (legacyPath) => createAccountMigrationFactory(await loadCommonAuthStoreModules())({
|
|
24765
25160
|
legacyPath,
|
|
24766
25161
|
offline,
|