@cortexkit/opencode-antigravity-auth 3.1.4 → 3.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -2
- package/dist/cli.js +158 -74
- package/dist/cli.js.map +4 -4
- package/dist/cli.meta.json +88 -15
- package/dist/index.js +244 -96
- package/dist/index.js.map +4 -4
- package/dist/index.meta.json +92 -19
- package/dist/server.js +242 -94
- package/dist/server.js.map +4 -4
- package/dist/server.meta.json +1 -1
- package/dist/src/common-auth-embedded/auth-menu/login.js +4 -1
- package/dist/src/common-auth-embedded/routing-accessor/cache-policy.d.ts +2 -2
- package/dist/src/common-auth-embedded/routing-accessor/cache-policy.js +1 -0
- package/dist/src/common-auth-embedded/setup/command.js +40 -19
- package/dist/src/common-auth-embedded/setup/enroll.d.ts +2 -1
- package/dist/src/common-auth-embedded/setup/enroll.js +12 -7
- package/dist/src/common-auth-embedded/setup/process-fence.d.ts +9 -0
- package/dist/src/common-auth-embedded/setup/process-fence.js +52 -8
- package/dist/src/common-auth-embedded/setup/process-guard.d.ts +12 -0
- package/dist/src/common-auth-embedded/setup/process-guard.js +32 -0
- package/dist/src/common-auth-embedded/setup/register.d.ts +2 -1
- package/dist/src/common-auth-embedded/setup/register.js +12 -2
- package/dist/src/common-auth-embedded/source-output.json +54 -38
- package/dist/src/plugin/__fixtures__/verified-store.d.ts +1 -1
- package/dist/src/plugin/__fixtures__/verified-store.js +4 -4
- package/dist/tui-build-map.json +1 -1
- package/dist/tui-ga-build-map.json +1 -1
- package/dist/types/src/common-auth-embedded/routing-accessor/cache-policy.d.ts +2 -2
- package/dist/types/src/common-auth-embedded/setup/enroll.d.ts +2 -1
- package/dist/types/src/common-auth-embedded/setup/process-fence.d.ts +9 -0
- package/dist/types/src/common-auth-embedded/setup/process-guard.d.ts +12 -0
- package/dist/types/src/common-auth-embedded/setup/register.d.ts +2 -1
- package/package.json +2 -2
- package/src/common-auth-embedded/auth-menu/login.js +4 -1
- package/src/common-auth-embedded/routing-accessor/cache-policy.d.ts +2 -2
- package/src/common-auth-embedded/routing-accessor/cache-policy.js +1 -0
- package/src/common-auth-embedded/setup/command.js +40 -19
- package/src/common-auth-embedded/setup/enroll.d.ts +2 -1
- package/src/common-auth-embedded/setup/enroll.js +12 -7
- package/src/common-auth-embedded/setup/process-fence.d.ts +9 -0
- package/src/common-auth-embedded/setup/process-fence.js +52 -8
- package/src/common-auth-embedded/setup/process-guard.d.ts +12 -0
- package/src/common-auth-embedded/setup/process-guard.js +32 -0
- package/src/common-auth-embedded/setup/register.d.ts +2 -1
- package/src/common-auth-embedded/setup/register.js +12 -2
- package/src/common-auth-embedded/source-output.json +54 -38
package/dist/server.js
CHANGED
|
@@ -761,12 +761,12 @@ async function replaceWindowsFile(from, to, options = {}) {
|
|
|
761
761
|
const delays = [0, 10, 20, 40, 80, 100];
|
|
762
762
|
let original;
|
|
763
763
|
let attempts2 = 0;
|
|
764
|
-
for (const
|
|
764
|
+
for (const delay4 of delays) {
|
|
765
765
|
const deadline = Math.min(retryDeadline ?? Infinity, leaseDeadline);
|
|
766
766
|
if (now() >= deadline)
|
|
767
767
|
break;
|
|
768
|
-
if (
|
|
769
|
-
await (options.sleep ?? ((ms) => new Promise((r) => setTimeout(r, ms))))(Math.min(
|
|
768
|
+
if (delay4)
|
|
769
|
+
await (options.sleep ?? ((ms) => new Promise((r) => setTimeout(r, ms))))(Math.min(delay4, Math.max(0, deadline - now())));
|
|
770
770
|
if (now() >= deadline)
|
|
771
771
|
break;
|
|
772
772
|
const fenceStart = now();
|
|
@@ -4563,8 +4563,8 @@ var init_model_registry = __esm({
|
|
|
4563
4563
|
// ../core/dist/rotation.js
|
|
4564
4564
|
function unconfirmedRateLimitDelayMs(retryAfter, now = Date.now()) {
|
|
4565
4565
|
const value = retryAfter?.trim();
|
|
4566
|
-
const
|
|
4567
|
-
return Number.isFinite(
|
|
4566
|
+
const delay4 = value ? /^\d+(?:\.\d+)?$/.test(value) ? Number(value) * 1e3 : Date.parse(value) - now : Number.NaN;
|
|
4567
|
+
return Number.isFinite(delay4) ? Math.min(UNCONFIRMED_RATE_LIMIT_MAX_MS, Math.max(UNCONFIRMED_RATE_LIMIT_MIN_MS, delay4)) : UNCONFIRMED_RATE_LIMIT_MIN_MS;
|
|
4568
4568
|
}
|
|
4569
4569
|
function parseRateLimitReason(reason, message, status) {
|
|
4570
4570
|
if (status === 529 || status === 503)
|
|
@@ -8911,9 +8911,9 @@ async function acquireWithRetry(path5, sleep5) {
|
|
|
8911
8911
|
return lock;
|
|
8912
8912
|
}
|
|
8913
8913
|
if (attempt < RETRY_DELAYS_MS.length) {
|
|
8914
|
-
const
|
|
8915
|
-
if (
|
|
8916
|
-
await sleep5(
|
|
8914
|
+
const delay4 = RETRY_DELAYS_MS[attempt];
|
|
8915
|
+
if (delay4 !== void 0) {
|
|
8916
|
+
await sleep5(delay4);
|
|
8917
8917
|
}
|
|
8918
8918
|
}
|
|
8919
8919
|
}
|
|
@@ -17625,11 +17625,11 @@ var init_quota_writer = __esm({
|
|
|
17625
17625
|
overlay(rows) {
|
|
17626
17626
|
return rows.map((row) => this.overlayRow(row));
|
|
17627
17627
|
}
|
|
17628
|
-
schedule(
|
|
17628
|
+
schedule(delay4) {
|
|
17629
17629
|
if (this.running || this.timer || !this.pending.size || this.stopped)
|
|
17630
17630
|
return;
|
|
17631
17631
|
const remaining = this.closed ? 0 : (this.committedAt ?? -Infinity) + QUOTA_COMMIT_INTERVAL_MS - this.clock.now();
|
|
17632
|
-
this.timer = this.clock.schedule(Math.max(
|
|
17632
|
+
this.timer = this.clock.schedule(Math.max(delay4, remaining), () => {
|
|
17633
17633
|
this.timer = void 0;
|
|
17634
17634
|
return this.flush();
|
|
17635
17635
|
});
|
|
@@ -17729,8 +17729,8 @@ var init_quota_writer = __esm({
|
|
|
17729
17729
|
this.running = void 0;
|
|
17730
17730
|
for (const wake of this.wake)
|
|
17731
17731
|
wake();
|
|
17732
|
-
const
|
|
17733
|
-
this.schedule(
|
|
17732
|
+
const delay4 = this.failures ? Math.min(5e3, 100 * 2 ** Math.min(this.failures, 6)) * (0.5 + Math.random()) : COALESCE_MS;
|
|
17733
|
+
this.schedule(delay4);
|
|
17734
17734
|
}
|
|
17735
17735
|
})();
|
|
17736
17736
|
return this.running;
|
|
@@ -20470,11 +20470,12 @@ var init_doctor = __esm({
|
|
|
20470
20470
|
|
|
20471
20471
|
// ../core/dist/common-auth-embedded/auth-menu/login.js
|
|
20472
20472
|
import { spawn as defaultSpawn } from "node:child_process";
|
|
20473
|
+
import { win32 } from "node:path";
|
|
20473
20474
|
function openBrowserForMenu(url, platform = process.platform, spawn2 = defaultSpawn) {
|
|
20474
20475
|
try {
|
|
20475
20476
|
if (platform === "win32") {
|
|
20476
20477
|
const command = `Start-Process '${url.replaceAll("'", "''")}'`;
|
|
20477
|
-
const child2 = spawn2("powershell.exe", [
|
|
20478
|
+
const child2 = spawn2(win32.resolve(process.env.SystemRoot ?? process.env.windir ?? "C:\\Windows", "System32", "WindowsPowerShell", "v1.0", "powershell.exe"), [
|
|
20478
20479
|
"-NoProfile",
|
|
20479
20480
|
"-NonInteractive",
|
|
20480
20481
|
"-WindowStyle",
|
|
@@ -21417,12 +21418,12 @@ var init_watch = __esm({
|
|
|
21417
21418
|
this.#options.logger?.debug("claustrum vault watch", { mode, reason });
|
|
21418
21419
|
this.#options.onMode?.(mode);
|
|
21419
21420
|
}
|
|
21420
|
-
#later(
|
|
21421
|
+
#later(delay4, run) {
|
|
21421
21422
|
this.#timer = (this.#options.setTimeoutImpl ?? setTimeout)(() => {
|
|
21422
21423
|
this.#timer = void 0;
|
|
21423
21424
|
if (!this.#stopped)
|
|
21424
21425
|
run();
|
|
21425
|
-
},
|
|
21426
|
+
}, delay4);
|
|
21426
21427
|
this.#timer.unref?.();
|
|
21427
21428
|
}
|
|
21428
21429
|
async #open(resubscribed) {
|
|
@@ -21494,10 +21495,10 @@ var init_watch = __esm({
|
|
|
21494
21495
|
const now = (this.#options.now ?? Date.now)();
|
|
21495
21496
|
if (watch2.acceptedAt !== void 0 && now - watch2.acceptedAt >= SAFETY_POLL_MS)
|
|
21496
21497
|
this.#closes = 0;
|
|
21497
|
-
const
|
|
21498
|
+
const delay4 = Math.min(RESUBSCRIBE_BACKOFF_MS * 2 ** Math.min(this.#closes, 16), WATCH_RETRY_MS);
|
|
21498
21499
|
this.#closes++;
|
|
21499
21500
|
this.#setMode("polling", "resubscribing");
|
|
21500
|
-
this.#later(
|
|
21501
|
+
this.#later(delay4, () => void this.#open(true));
|
|
21501
21502
|
return;
|
|
21502
21503
|
}
|
|
21503
21504
|
this.#fallback(end.kind);
|
|
@@ -21788,12 +21789,12 @@ var init_insula = __esm({
|
|
|
21788
21789
|
watch2?.handle?.stop();
|
|
21789
21790
|
this.#mode = "polling";
|
|
21790
21791
|
}
|
|
21791
|
-
#later(
|
|
21792
|
+
#later(delay4) {
|
|
21792
21793
|
this.#timer = (this.#timers.setTimeoutImpl ?? setTimeout)(() => {
|
|
21793
21794
|
this.#timer = void 0;
|
|
21794
21795
|
if (this.#watchers > 0 && !this.#watch)
|
|
21795
21796
|
this.#open();
|
|
21796
|
-
},
|
|
21797
|
+
}, delay4);
|
|
21797
21798
|
this.#timer.unref?.();
|
|
21798
21799
|
}
|
|
21799
21800
|
#open() {
|
|
@@ -21841,10 +21842,10 @@ var init_insula = __esm({
|
|
|
21841
21842
|
return;
|
|
21842
21843
|
}
|
|
21843
21844
|
if (watch2.notices > 0) {
|
|
21844
|
-
const
|
|
21845
|
+
const delay4 = Math.min(RESUBSCRIBE_BACKOFF_MS * 2 ** Math.min(this.#closes, 16), WATCH_RETRY_MS);
|
|
21845
21846
|
this.#closes++;
|
|
21846
21847
|
this.#mode = "polling";
|
|
21847
|
-
this.#later(
|
|
21848
|
+
this.#later(delay4);
|
|
21848
21849
|
return;
|
|
21849
21850
|
}
|
|
21850
21851
|
this.#mode = "fallback";
|
|
@@ -23533,9 +23534,9 @@ var init_custody = __esm({
|
|
|
23533
23534
|
users: 0,
|
|
23534
23535
|
error,
|
|
23535
23536
|
pending: Promise.resolve().then(async () => {
|
|
23536
|
-
let
|
|
23537
|
+
let delay4 = 250;
|
|
23537
23538
|
for (; ; ) {
|
|
23538
|
-
await this.#receiptBackoff(
|
|
23539
|
+
await this.#receiptBackoff(delay4, controller.signal);
|
|
23539
23540
|
try {
|
|
23540
23541
|
return await this.#authorizeFresh(identity4, token, controller.signal);
|
|
23541
23542
|
} catch (failure2) {
|
|
@@ -23543,7 +23544,7 @@ var init_custody = __esm({
|
|
|
23543
23544
|
if (classifyVaultFailure(failure2) !== "unreachable")
|
|
23544
23545
|
throw failure2;
|
|
23545
23546
|
created.error = failure2;
|
|
23546
|
-
|
|
23547
|
+
delay4 = Math.min(delay4 * 2, 1e3);
|
|
23547
23548
|
}
|
|
23548
23549
|
}
|
|
23549
23550
|
})
|
|
@@ -23597,7 +23598,7 @@ var init_custody = __esm({
|
|
|
23597
23598
|
}
|
|
23598
23599
|
}
|
|
23599
23600
|
}
|
|
23600
|
-
#receiptBackoff(
|
|
23601
|
+
#receiptBackoff(delay4, signal) {
|
|
23601
23602
|
this.#check(signal);
|
|
23602
23603
|
return new Promise((resolve33, reject) => {
|
|
23603
23604
|
const abort = () => {
|
|
@@ -23608,7 +23609,7 @@ var init_custody = __esm({
|
|
|
23608
23609
|
const timer = this.#setTimeout(() => {
|
|
23609
23610
|
signal.removeEventListener("abort", abort);
|
|
23610
23611
|
resolve33();
|
|
23611
|
-
},
|
|
23612
|
+
}, delay4);
|
|
23612
23613
|
timer.unref?.();
|
|
23613
23614
|
signal.addEventListener("abort", abort, { once: true });
|
|
23614
23615
|
if (signal.aborted)
|
|
@@ -24632,11 +24633,11 @@ function pendingVaultQuota(path5, roster) {
|
|
|
24632
24633
|
function hasPendingVaultQuota(path5) {
|
|
24633
24634
|
return !!writers.get(resolve11(path5))?.pending.size;
|
|
24634
24635
|
}
|
|
24635
|
-
function schedule(writer,
|
|
24636
|
+
function schedule(writer, delay4) {
|
|
24636
24637
|
if (writer.running || writer.timer || !writer.pending.size || writer.abort.signal.aborted)
|
|
24637
24638
|
return;
|
|
24638
24639
|
const remaining = writer.draining ? 0 : (writer.committedAt ?? -Infinity) + QUOTA_COMMIT_INTERVAL_MS - writer.clock.now();
|
|
24639
|
-
writer.timer = writer.clock.schedule(Math.max(
|
|
24640
|
+
writer.timer = writer.clock.schedule(Math.max(delay4, remaining), () => {
|
|
24640
24641
|
writer.timer = void 0;
|
|
24641
24642
|
return flush(writer);
|
|
24642
24643
|
});
|
|
@@ -25073,13 +25074,13 @@ var init_consumer = __esm({
|
|
|
25073
25074
|
}
|
|
25074
25075
|
if (this.#shutdown.signal.aborted)
|
|
25075
25076
|
return;
|
|
25076
|
-
const
|
|
25077
|
-
if (
|
|
25077
|
+
const delay4 = this.#options.pollIntervalMs ?? 5e3;
|
|
25078
|
+
if (delay4 <= 0)
|
|
25078
25079
|
return;
|
|
25079
25080
|
this.#timer = (this.#options.setTimeoutImpl ?? setTimeout)(() => {
|
|
25080
25081
|
this.#timer = void 0;
|
|
25081
25082
|
void this.#track(tick());
|
|
25082
|
-
},
|
|
25083
|
+
}, delay4);
|
|
25083
25084
|
this.#timer.unref?.();
|
|
25084
25085
|
};
|
|
25085
25086
|
void this.#track(tick());
|
|
@@ -26549,13 +26550,13 @@ var init_hub = __esm({
|
|
|
26549
26550
|
}
|
|
26550
26551
|
if (this.#shutdown.signal.aborted)
|
|
26551
26552
|
return;
|
|
26552
|
-
const
|
|
26553
|
-
if (
|
|
26553
|
+
const delay4 = this.#options.pollIntervalMs ?? 5e3;
|
|
26554
|
+
if (delay4 <= 0)
|
|
26554
26555
|
return;
|
|
26555
26556
|
this.#timer = (this.#options.setTimeoutImpl ?? setTimeout)(() => {
|
|
26556
26557
|
this.#timer = void 0;
|
|
26557
26558
|
void this.#track(this.#tick());
|
|
26558
|
-
},
|
|
26559
|
+
}, delay4);
|
|
26559
26560
|
this.#timer.unref?.();
|
|
26560
26561
|
}
|
|
26561
26562
|
/**
|
|
@@ -26846,12 +26847,12 @@ async function acquirePiLock(authPath, onCompromised, onRenew) {
|
|
|
26846
26847
|
if (!released && lastUpdate + RENEWAL_STALE < Date.now())
|
|
26847
26848
|
compromise();
|
|
26848
26849
|
}
|
|
26849
|
-
function schedule2(
|
|
26850
|
+
function schedule2(delay4 = UPDATE) {
|
|
26850
26851
|
if (released)
|
|
26851
26852
|
return;
|
|
26852
26853
|
timer = setTimeout(() => {
|
|
26853
26854
|
void update();
|
|
26854
|
-
},
|
|
26855
|
+
}, delay4);
|
|
26855
26856
|
timer.unref();
|
|
26856
26857
|
}
|
|
26857
26858
|
function retry(error) {
|
|
@@ -28788,7 +28789,7 @@ function isSchemaObject(value) {
|
|
|
28788
28789
|
function describeValue(value) {
|
|
28789
28790
|
return JSON.stringify(value) ?? String(value);
|
|
28790
28791
|
}
|
|
28791
|
-
function normalizeNullableTypeArray(schema) {
|
|
28792
|
+
function normalizeNullableTypeArray(schema, unionHints) {
|
|
28792
28793
|
if (!Array.isArray(schema.type))
|
|
28793
28794
|
return schema;
|
|
28794
28795
|
if (schema.type.length === 0 || schema.type.some((type) => typeof type !== "string" || !ALLOWED_JSON_SCHEMA_TYPES.has(type.toLowerCase()))) {
|
|
@@ -28799,7 +28800,37 @@ function normalizeNullableTypeArray(schema) {
|
|
|
28799
28800
|
];
|
|
28800
28801
|
const nonNull = types.filter((type) => type !== "null");
|
|
28801
28802
|
if (nonNull.length > 1) {
|
|
28802
|
-
|
|
28803
|
+
if (!unionHints)
|
|
28804
|
+
return schema;
|
|
28805
|
+
const { type: _type, ...base } = schema;
|
|
28806
|
+
if (types.includes("null"))
|
|
28807
|
+
base.nullable = true;
|
|
28808
|
+
const coversEveryType = ["object", "array", "string", "boolean"].every((type) => nonNull.includes(type)) && (nonNull.includes("number") || nonNull.includes("integer"));
|
|
28809
|
+
if (!coversEveryType && (Array.isArray(base.anyOf) || Array.isArray(base.oneOf))) {
|
|
28810
|
+
unionHints.push("type: additional union constraints omitted.");
|
|
28811
|
+
return base;
|
|
28812
|
+
}
|
|
28813
|
+
const branches = nonNull.map((type) => {
|
|
28814
|
+
const branch = { type };
|
|
28815
|
+
for (const key of TYPE_ARRAY_BRANCH_FIELDS[type] ?? []) {
|
|
28816
|
+
if (!Object.hasOwn(base, key))
|
|
28817
|
+
continue;
|
|
28818
|
+
if (key === "enum" && (!Array.isArray(base.enum) || !base.enum.every((value) => typeof value === "string")))
|
|
28819
|
+
continue;
|
|
28820
|
+
branch[key] = base[key];
|
|
28821
|
+
}
|
|
28822
|
+
return branch;
|
|
28823
|
+
});
|
|
28824
|
+
for (const key of /* @__PURE__ */ new Set([
|
|
28825
|
+
...Object.values(TYPE_ARRAY_BRANCH_FIELDS).flat(),
|
|
28826
|
+
"minProperties",
|
|
28827
|
+
"maxProperties"
|
|
28828
|
+
])) {
|
|
28829
|
+
if (key === "enum" && Array.isArray(base.enum) && !base.enum.every((value) => typeof value === "string"))
|
|
28830
|
+
continue;
|
|
28831
|
+
delete base[key];
|
|
28832
|
+
}
|
|
28833
|
+
return coversEveryType ? base : { ...base, anyOf: branches };
|
|
28803
28834
|
}
|
|
28804
28835
|
return {
|
|
28805
28836
|
...schema,
|
|
@@ -28917,7 +28948,7 @@ function toGeminiSchema(schema, options = {}) {
|
|
|
28917
28948
|
return schema;
|
|
28918
28949
|
}
|
|
28919
28950
|
const numericConstraintHints = [];
|
|
28920
|
-
const inputSchema = normalizeNullableTypeArray(mergeSchemaAllOf(schema, numericConstraintHints));
|
|
28951
|
+
const inputSchema = normalizeNullableTypeArray(mergeSchemaAllOf(schema, numericConstraintHints), options.claudeValidated ? void 0 : numericConstraintHints);
|
|
28921
28952
|
const schemaType = typeof inputSchema.type === "string" ? inputSchema.type.toUpperCase() : void 0;
|
|
28922
28953
|
let result = {};
|
|
28923
28954
|
const propertyNames = /* @__PURE__ */ new Set();
|
|
@@ -29268,7 +29299,7 @@ function wrapToolsAsFunctionDeclarations(payload) {
|
|
|
29268
29299
|
passthroughToolCount: passthroughTools.length + (hasWebSearchTool && functionDeclarations.length === 0 ? 1 : 0)
|
|
29269
29300
|
};
|
|
29270
29301
|
}
|
|
29271
|
-
var ALLOWED_SCHEMA_FIELDS, NUMERIC_SCHEMA_CONSTRAINTS, ALLOWED_JSON_SCHEMA_TYPES, CLAUDE_VALIDATED_HINT_FIELDS, VALID_ASPECT_RATIOS;
|
|
29302
|
+
var ALLOWED_SCHEMA_FIELDS, NUMERIC_SCHEMA_CONSTRAINTS, ALLOWED_JSON_SCHEMA_TYPES, TYPE_ARRAY_BRANCH_FIELDS, CLAUDE_VALIDATED_HINT_FIELDS, VALID_ASPECT_RATIOS;
|
|
29272
29303
|
var init_gemini = __esm({
|
|
29273
29304
|
"../core/dist/transform/gemini.js"() {
|
|
29274
29305
|
"use strict";
|
|
@@ -29318,6 +29349,30 @@ var init_gemini = __esm({
|
|
|
29318
29349
|
"object",
|
|
29319
29350
|
"null"
|
|
29320
29351
|
]);
|
|
29352
|
+
TYPE_ARRAY_BRANCH_FIELDS = {
|
|
29353
|
+
object: [
|
|
29354
|
+
"properties",
|
|
29355
|
+
"required",
|
|
29356
|
+
"propertyOrdering",
|
|
29357
|
+
"additionalProperties"
|
|
29358
|
+
],
|
|
29359
|
+
array: ["items", "minItems", "maxItems"],
|
|
29360
|
+
string: ["enum", "format", "minLength", "maxLength", "pattern"],
|
|
29361
|
+
number: [
|
|
29362
|
+
"minimum",
|
|
29363
|
+
"maximum",
|
|
29364
|
+
"exclusiveMinimum",
|
|
29365
|
+
"exclusiveMaximum",
|
|
29366
|
+
"multipleOf"
|
|
29367
|
+
],
|
|
29368
|
+
integer: [
|
|
29369
|
+
"minimum",
|
|
29370
|
+
"maximum",
|
|
29371
|
+
"exclusiveMinimum",
|
|
29372
|
+
"exclusiveMaximum",
|
|
29373
|
+
"multipleOf"
|
|
29374
|
+
]
|
|
29375
|
+
};
|
|
29321
29376
|
CLAUDE_VALIDATED_HINT_FIELDS = /* @__PURE__ */ new Set([
|
|
29322
29377
|
"minLength",
|
|
29323
29378
|
"maxLength",
|
|
@@ -29982,6 +30037,15 @@ function assertRosterBinding(roster, attribution, claustrum) {
|
|
|
29982
30037
|
if (!roster || !row?.enabled || row.state !== "active" || row.stale === true || row.unclaimed === true || row.credentialId !== attribution.credentialId || row.accountIdentity !== attribution.accountIdentity || claustrum.isDeclined(roster.declined, attribution.credentialId, attribution.accountIdentity))
|
|
29983
30038
|
throw new VaultProviderStateError("binding-stale", "the vault route no longer serves the attributed credential and account");
|
|
29984
30039
|
}
|
|
30040
|
+
function quotaBoundState(current, attribution) {
|
|
30041
|
+
if (current?.quota === void 0 || current.observed.routeId === attribution.routeId && current.observed.credentialId === attribution.credentialId)
|
|
30042
|
+
return current;
|
|
30043
|
+
return Object.freeze({
|
|
30044
|
+
observed: current.observed,
|
|
30045
|
+
...current.metadata !== void 0 ? { metadata: current.metadata } : {},
|
|
30046
|
+
...current.extensions !== void 0 ? { extensions: current.extensions } : {}
|
|
30047
|
+
});
|
|
30048
|
+
}
|
|
29985
30049
|
async function commitVaultProviderState(input2) {
|
|
29986
30050
|
const { claustrum, fs: fs7, statePath } = input2;
|
|
29987
30051
|
input2.signal?.throwIfAborted();
|
|
@@ -29997,7 +30061,7 @@ async function commitVaultProviderState(input2) {
|
|
|
29997
30061
|
const file = await readVaultProviderState(statePath);
|
|
29998
30062
|
input2.signal?.throwIfAborted();
|
|
29999
30063
|
const current = vaultAccountState(file, identity4);
|
|
30000
|
-
const requested = input2.update(current);
|
|
30064
|
+
const requested = input2.update(quotaBoundState(current, attribution));
|
|
30001
30065
|
if (isRecord9(requested) && typeof requested.then === "function")
|
|
30002
30066
|
throw new VaultProviderStateError("invalid-update", "a state update must be synchronous");
|
|
30003
30067
|
if (requested === void 0)
|
|
@@ -30105,7 +30169,7 @@ async function commitVaultProviderStates(input2) {
|
|
|
30105
30169
|
const identity4 = entry.attribution.accountIdentity;
|
|
30106
30170
|
const current = Object.hasOwn(accounts, identity4) ? accounts[identity4] : void 0;
|
|
30107
30171
|
try {
|
|
30108
|
-
const requested = entry.update(current);
|
|
30172
|
+
const requested = entry.update(quotaBoundState(current, entry.attribution));
|
|
30109
30173
|
if (isRecord9(requested) && typeof requested.then === "function")
|
|
30110
30174
|
throw new VaultProviderStateError("invalid-update", "a state update must be synchronous");
|
|
30111
30175
|
if (requested === void 0 || requested === null && !current) {
|
|
@@ -30853,12 +30917,12 @@ async function replaceWindowsFile2(from, to, options = {}) {
|
|
|
30853
30917
|
const delays = [0, 10, 20, 40, 80, 100];
|
|
30854
30918
|
let original;
|
|
30855
30919
|
let attempts2 = 0;
|
|
30856
|
-
for (const
|
|
30920
|
+
for (const delay4 of delays) {
|
|
30857
30921
|
const deadline = Math.min(retryDeadline ?? Infinity, leaseDeadline);
|
|
30858
30922
|
if (now() >= deadline)
|
|
30859
30923
|
break;
|
|
30860
|
-
if (
|
|
30861
|
-
await (options.sleep ?? ((ms) => new Promise((r) => setTimeout(r, ms))))(Math.min(
|
|
30924
|
+
if (delay4)
|
|
30925
|
+
await (options.sleep ?? ((ms) => new Promise((r) => setTimeout(r, ms))))(Math.min(delay4, Math.max(0, deadline - now())));
|
|
30862
30926
|
if (now() >= deadline)
|
|
30863
30927
|
break;
|
|
30864
30928
|
const fenceStart = now();
|
|
@@ -34280,8 +34344,8 @@ function isWindowsSharingError(error, platform) {
|
|
|
34280
34344
|
}
|
|
34281
34345
|
async function unlinkIfIdentical(file, stateDir, guard, io = { platform: process.platform, readFile: readFile15, unlink: unlink12 }) {
|
|
34282
34346
|
const started = performance.now();
|
|
34283
|
-
for (const
|
|
34284
|
-
if (
|
|
34347
|
+
for (const delay4 of SHARING_RETRY_DELAYS_MS) {
|
|
34348
|
+
if (delay4 > 0) await new Promise((done) => setTimeout(done, delay4));
|
|
34285
34349
|
let same;
|
|
34286
34350
|
try {
|
|
34287
34351
|
same = (await io.readFile(file.old)).equals(await io.readFile(file.next));
|
|
@@ -38855,7 +38919,7 @@ async function moveSettingsOnce(options) {
|
|
|
38855
38919
|
}
|
|
38856
38920
|
|
|
38857
38921
|
// ../core/dist/common-auth-embedded/settings/paths.js
|
|
38858
|
-
import { posix, win32 } from "node:path";
|
|
38922
|
+
import { posix, win32 as win322 } from "node:path";
|
|
38859
38923
|
function isAbsoluteForPlatform(path5, platform) {
|
|
38860
38924
|
if (platform !== "win32")
|
|
38861
38925
|
return path5.startsWith("/");
|
|
@@ -38866,7 +38930,7 @@ function isAbsoluteForPlatform(path5, platform) {
|
|
|
38866
38930
|
return /^[\\/]{2}[^\\/]+[\\/][^\\/]+/.test(path5);
|
|
38867
38931
|
}
|
|
38868
38932
|
function cortexkitConfigDir({ env: env3, platform, homedir: homedir17 }) {
|
|
38869
|
-
const paths = platform === "win32" ?
|
|
38933
|
+
const paths = platform === "win32" ? win322 : posix;
|
|
38870
38934
|
const absolute = (value) => value !== void 0 && isAbsoluteForPlatform(value, platform);
|
|
38871
38935
|
let base;
|
|
38872
38936
|
if (absolute(env3.XDG_CONFIG_HOME)) {
|
|
@@ -38889,7 +38953,7 @@ function settingsFilePath({ plugin: plugin2, override, ...options }) {
|
|
|
38889
38953
|
if (override && isAbsoluteForPlatform(override, options.platform)) {
|
|
38890
38954
|
return override;
|
|
38891
38955
|
}
|
|
38892
|
-
const paths = options.platform === "win32" ?
|
|
38956
|
+
const paths = options.platform === "win32" ? win322 : posix;
|
|
38893
38957
|
return paths.join(cortexkitConfigDir(options), `${plugin2}.jsonc`);
|
|
38894
38958
|
}
|
|
38895
38959
|
|
|
@@ -42525,14 +42589,14 @@ var BackgroundVaultQuotaRefresh = class {
|
|
|
42525
42589
|
this.abortTick();
|
|
42526
42590
|
await this.inFlight;
|
|
42527
42591
|
}
|
|
42528
|
-
schedule(
|
|
42592
|
+
schedule(delay4, intervalWait = null) {
|
|
42529
42593
|
if (this.disposed || !this.started) return;
|
|
42530
42594
|
this.intervalWait = intervalWait;
|
|
42531
42595
|
this.timer = setTimeout(() => {
|
|
42532
42596
|
this.timer = null;
|
|
42533
42597
|
this.intervalWait = null;
|
|
42534
42598
|
void this.tick();
|
|
42535
|
-
},
|
|
42599
|
+
}, delay4);
|
|
42536
42600
|
this.timer.unref?.();
|
|
42537
42601
|
}
|
|
42538
42602
|
/** One serialized tick; also used by deterministic composition tests. */
|
|
@@ -49241,6 +49305,7 @@ function routingHandle(sessionId) {
|
|
|
49241
49305
|
var CACHE_WARM_STOP_REASONS = [
|
|
49242
49306
|
"cost-cap",
|
|
49243
49307
|
"count-cap",
|
|
49308
|
+
"deadline-missed",
|
|
49244
49309
|
"outside-hours",
|
|
49245
49310
|
"session-ended",
|
|
49246
49311
|
"unsupported"
|
|
@@ -52672,9 +52737,9 @@ init_version_fence();
|
|
|
52672
52737
|
|
|
52673
52738
|
// src/settings/location.ts
|
|
52674
52739
|
import { realpath as realpath5 } from "node:fs/promises";
|
|
52675
|
-
import { posix as posix2, win32 as
|
|
52740
|
+
import { posix as posix2, win32 as win323 } from "node:path";
|
|
52676
52741
|
async function folderIdentity(folder, platform) {
|
|
52677
|
-
const paths = platform === "win32" ?
|
|
52742
|
+
const paths = platform === "win32" ? win323 : posix2;
|
|
52678
52743
|
try {
|
|
52679
52744
|
return await realpath5(folder);
|
|
52680
52745
|
} catch {
|
|
@@ -52683,7 +52748,7 @@ async function folderIdentity(folder, platform) {
|
|
|
52683
52748
|
}
|
|
52684
52749
|
async function resolveSettingsLocation(options) {
|
|
52685
52750
|
const { env: env3, platform, homedir: homedir17 } = options;
|
|
52686
|
-
const paths = platform === "win32" ?
|
|
52751
|
+
const paths = platform === "win32" ? win323 : posix2;
|
|
52687
52752
|
const override = env3.OPENCODE_ANTIGRAVITY_AUTH_SETTINGS_FILE;
|
|
52688
52753
|
const file = settingsFilePath({
|
|
52689
52754
|
plugin: "antigravity-auth",
|
|
@@ -53060,12 +53125,12 @@ function createSettingsRuntime(options) {
|
|
|
53060
53125
|
void enqueue(refreshAll);
|
|
53061
53126
|
});
|
|
53062
53127
|
};
|
|
53063
|
-
const scheduleAttempt = (
|
|
53128
|
+
const scheduleAttempt = (delay4) => {
|
|
53064
53129
|
if (disposed) return;
|
|
53065
53130
|
retryTimer = setTimeout(() => {
|
|
53066
53131
|
retryTimer = void 0;
|
|
53067
53132
|
void enqueue(attemptMove);
|
|
53068
|
-
},
|
|
53133
|
+
}, delay4);
|
|
53069
53134
|
retryTimer.unref?.();
|
|
53070
53135
|
};
|
|
53071
53136
|
const attemptMove = async () => {
|
|
@@ -61102,12 +61167,12 @@ import { parse } from "jsonc-parser";
|
|
|
61102
61167
|
|
|
61103
61168
|
// src/common-auth-embedded/setup/paths.js
|
|
61104
61169
|
import { homedir as homedir11 } from "node:os";
|
|
61105
|
-
import { posix as posix3, win32 as
|
|
61170
|
+
import { posix as posix3, win32 as win324 } from "node:path";
|
|
61106
61171
|
import { fileURLToPath } from "node:url";
|
|
61107
61172
|
function setupPaths(io = {}) {
|
|
61108
61173
|
const env3 = io.env ?? process.env;
|
|
61109
61174
|
const platform = io.platform ?? process.platform;
|
|
61110
|
-
const path5 = platform === "win32" ?
|
|
61175
|
+
const path5 = platform === "win32" ? win324 : posix3;
|
|
61111
61176
|
const home = io.home ?? (platform === "win32" ? env3.USERPROFILE : env3.HOME) ?? homedir11();
|
|
61112
61177
|
const cwd = io.cwd ?? process.cwd();
|
|
61113
61178
|
const absolute = (value) => path5.resolve(cwd, value);
|
|
@@ -61334,7 +61399,20 @@ import { setTimeout as delay } from "node:timers/promises";
|
|
|
61334
61399
|
import { writeEnrollmentTokenFile as writeEnrollmentTokenFile3 } from "@cortexkit/claustrum-client";
|
|
61335
61400
|
|
|
61336
61401
|
// src/common-auth-embedded/setup/process-fence.js
|
|
61402
|
+
import { statSync as statSync7 } from "node:fs";
|
|
61403
|
+
import { win32 as win325 } from "node:path";
|
|
61337
61404
|
var WINDOWS_CIM_TIMEOUT_MS = 45e3;
|
|
61405
|
+
var WINDOWS_ARM_POWERSHELL_TIMEOUT_MS = 9e4;
|
|
61406
|
+
function isFile(file) {
|
|
61407
|
+
try {
|
|
61408
|
+
return statSync7(file).isFile();
|
|
61409
|
+
} catch {
|
|
61410
|
+
return false;
|
|
61411
|
+
}
|
|
61412
|
+
}
|
|
61413
|
+
function windowsEnv(env3, name) {
|
|
61414
|
+
return Object.entries(env3).find(([key]) => key.toUpperCase() === name.toUpperCase())?.[1];
|
|
61415
|
+
}
|
|
61338
61416
|
var HOSTS = /* @__PURE__ */ new Set(["opencode", "litecode", "opencode2", "pi"]);
|
|
61339
61417
|
var RUNTIMES = /* @__PURE__ */ new Set(["node", "bun"]);
|
|
61340
61418
|
var WINDOWS_FENCE_FILTER = [...HOSTS, ...RUNTIMES].map((name) => `Name LIKE '${name}%'`).join(" OR ");
|
|
@@ -61406,6 +61484,7 @@ function hostName(command) {
|
|
|
61406
61484
|
var ProcessInspectionError = class extends Error {
|
|
61407
61485
|
code = "process-inspection-failed";
|
|
61408
61486
|
step;
|
|
61487
|
+
program;
|
|
61409
61488
|
exitCode;
|
|
61410
61489
|
signal;
|
|
61411
61490
|
timedOut;
|
|
@@ -61414,6 +61493,7 @@ var ProcessInspectionError = class extends Error {
|
|
|
61414
61493
|
super("Process inspection failed; setup cannot prove hosts are stopped.");
|
|
61415
61494
|
this.name = "ProcessInspectionError";
|
|
61416
61495
|
this.step = details.step;
|
|
61496
|
+
this.program = details.program;
|
|
61417
61497
|
this.exitCode = details.exitCode;
|
|
61418
61498
|
this.signal = details.signal;
|
|
61419
61499
|
this.timedOut = details.timedOut;
|
|
@@ -61441,6 +61521,8 @@ Please quit all OpenCode, LiteCode, and Pi processes before running setup.`);
|
|
|
61441
61521
|
};
|
|
61442
61522
|
async function listSetupProcesses(runner = defaultCommandRunner, options = {}) {
|
|
61443
61523
|
const windows2 = (options.platform ?? process.platform) === "win32";
|
|
61524
|
+
const env3 = options.env ?? process.env;
|
|
61525
|
+
const system32 = windows2 ? win325.resolve(windowsEnv(env3, "SystemRoot") ?? windowsEnv(env3, "windir") ?? "C:\\Windows", "System32") : "";
|
|
61444
61526
|
const selfPid = options.selfPid ?? process.pid;
|
|
61445
61527
|
let inspection = {
|
|
61446
61528
|
step: windows2 ? "tasklist" : "ps",
|
|
@@ -61449,10 +61531,11 @@ async function listSetupProcesses(runner = defaultCommandRunner, options = {}) {
|
|
|
61449
61531
|
timedOut: false,
|
|
61450
61532
|
durationMs: 0
|
|
61451
61533
|
};
|
|
61452
|
-
const inspect = async (step, file, args, timeoutMs) => {
|
|
61534
|
+
const inspect = async (step, file, args, timeoutMs, program) => {
|
|
61453
61535
|
const started = performance.now();
|
|
61454
61536
|
inspection = {
|
|
61455
61537
|
step,
|
|
61538
|
+
...program && { program },
|
|
61456
61539
|
exitCode: null,
|
|
61457
61540
|
signal: null,
|
|
61458
61541
|
timedOut: false,
|
|
@@ -61465,6 +61548,7 @@ async function listSetupProcesses(runner = defaultCommandRunner, options = {}) {
|
|
|
61465
61548
|
});
|
|
61466
61549
|
inspection = {
|
|
61467
61550
|
step,
|
|
61551
|
+
...program && { program },
|
|
61468
61552
|
exitCode: result.exitCode,
|
|
61469
61553
|
signal: result.signal ?? null,
|
|
61470
61554
|
timedOut: result.timedOut ?? false,
|
|
@@ -61477,9 +61561,23 @@ async function listSetupProcesses(runner = defaultCommandRunner, options = {}) {
|
|
|
61477
61561
|
options.onStep?.({ ...inspection });
|
|
61478
61562
|
}
|
|
61479
61563
|
};
|
|
61564
|
+
const inspectCim = (args) => {
|
|
61565
|
+
const pwsh = win325.resolve(windowsEnv(env3, "ProgramFiles") ?? "C:\\Program Files", "PowerShell", "7", "pwsh.exe");
|
|
61566
|
+
const program = (options.isFile ?? isFile)(pwsh) ? "pwsh" : "powershell";
|
|
61567
|
+
const arm64 = (windowsEnv(env3, "PROCESSOR_ARCHITEW6432") ?? windowsEnv(env3, "PROCESSOR_ARCHITECTURE"))?.toUpperCase() === "ARM64";
|
|
61568
|
+
const slow = program === "powershell" && arm64;
|
|
61569
|
+
if (slow)
|
|
61570
|
+
options.onProgress?.("Checking that OpenCode and Pi are not running. Without PowerShell 7 this can take up to a minute on Windows ARM; installing PowerShell 7 makes it fast.");
|
|
61571
|
+
return inspect("CIM", program === "pwsh" ? pwsh : win325.resolve(system32, "WindowsPowerShell", "v1.0", "powershell.exe"), args, slow ? WINDOWS_ARM_POWERSHELL_TIMEOUT_MS : WINDOWS_CIM_TIMEOUT_MS, program);
|
|
61572
|
+
};
|
|
61480
61573
|
try {
|
|
61481
61574
|
if (windows2 && options.hostImagesOnly) {
|
|
61482
|
-
const details = await
|
|
61575
|
+
const details = await inspectCim([
|
|
61576
|
+
"-NoProfile",
|
|
61577
|
+
"-NonInteractive",
|
|
61578
|
+
"-Command",
|
|
61579
|
+
WINDOWS_FENCE_QUERY
|
|
61580
|
+
]);
|
|
61483
61581
|
if (details.exitCode !== 0)
|
|
61484
61582
|
throw new ProcessInspectionError(inspection);
|
|
61485
61583
|
const value = JSON.parse(details.stdout);
|
|
@@ -61501,7 +61599,7 @@ async function listSetupProcesses(runner = defaultCommandRunner, options = {}) {
|
|
|
61501
61599
|
}
|
|
61502
61600
|
return processes2;
|
|
61503
61601
|
}
|
|
61504
|
-
const result = await inspect(windows2 ? "tasklist" : "ps", windows2 ? "tasklist.exe" : "ps", windows2 ? ["/fo", "csv", "/nh"] : ["-eo", "pid,command"]);
|
|
61602
|
+
const result = await inspect(windows2 ? "tasklist" : "ps", windows2 ? win325.resolve(system32, "tasklist.exe") : "ps", windows2 ? ["/fo", "csv", "/nh"] : ["-eo", "pid,command"]);
|
|
61505
61603
|
if (result.exitCode !== 0)
|
|
61506
61604
|
throw new ProcessInspectionError(inspection);
|
|
61507
61605
|
const processes = [];
|
|
@@ -61535,12 +61633,12 @@ async function listSetupProcesses(runner = defaultCommandRunner, options = {}) {
|
|
|
61535
61633
|
throw new ProcessInspectionError(inspection);
|
|
61536
61634
|
const runtimes = processes.filter((entry) => entry.pid !== selfPid && /^(?:node|bun)\.exe$/i.test(entry.command));
|
|
61537
61635
|
if (windows2 && runtimes.length && options.inspectRuntimes !== false) {
|
|
61538
|
-
const details = await
|
|
61636
|
+
const details = await inspectCim([
|
|
61539
61637
|
"-NoProfile",
|
|
61540
61638
|
"-NonInteractive",
|
|
61541
61639
|
"-Command",
|
|
61542
61640
|
`$ErrorActionPreference = 'Stop'; Get-CimInstance Win32_Process -Filter "Name = 'node.exe' OR Name = 'bun.exe'" | Select-Object ProcessId,CommandLine | ConvertTo-Json -Compress`
|
|
61543
|
-
]
|
|
61641
|
+
]);
|
|
61544
61642
|
if (details.exitCode !== 0)
|
|
61545
61643
|
throw new ProcessInspectionError(inspection);
|
|
61546
61644
|
const value = JSON.parse(details.stdout || "null");
|
|
@@ -61596,6 +61694,36 @@ async function assertHostsStopped(fence, env3) {
|
|
|
61596
61694
|
throw new ProcessFenceViolationError(active2);
|
|
61597
61695
|
}
|
|
61598
61696
|
|
|
61697
|
+
// src/common-auth-embedded/setup/process-guard.js
|
|
61698
|
+
var SetupProcessGuard = class {
|
|
61699
|
+
inspect;
|
|
61700
|
+
now;
|
|
61701
|
+
#checkedAt;
|
|
61702
|
+
constructor(inspect, now = () => performance.now()) {
|
|
61703
|
+
this.inspect = inspect;
|
|
61704
|
+
this.now = now;
|
|
61705
|
+
}
|
|
61706
|
+
async check(options = {}) {
|
|
61707
|
+
if (options.reuse && this.#checkedAt !== void 0) {
|
|
61708
|
+
const age = this.now() - this.#checkedAt;
|
|
61709
|
+
if (age >= 0 && age < 5e3)
|
|
61710
|
+
return;
|
|
61711
|
+
}
|
|
61712
|
+
this.#checkedAt = void 0;
|
|
61713
|
+
await this.inspect();
|
|
61714
|
+
this.#checkedAt = this.now();
|
|
61715
|
+
}
|
|
61716
|
+
/** Callbacks, writes and waits can all make an earlier inspection stale. */
|
|
61717
|
+
async step(run) {
|
|
61718
|
+
this.#checkedAt = void 0;
|
|
61719
|
+
try {
|
|
61720
|
+
return await run();
|
|
61721
|
+
} finally {
|
|
61722
|
+
this.#checkedAt = void 0;
|
|
61723
|
+
}
|
|
61724
|
+
}
|
|
61725
|
+
};
|
|
61726
|
+
|
|
61599
61727
|
// src/common-auth-embedded/setup/enroll.js
|
|
61600
61728
|
var ENROLLMENT_INCOMPLETE_MESSAGE = "Claustrum enrollment did not complete. Inspect and approve with ck, then rerun setup.";
|
|
61601
61729
|
var UNSUPPORTED_VAULT_MESSAGE = 'This Claustrum vault is too old to connect plugins. Run ck upgrade to move to Claustrum v0.2.0 or newer (read "Upgrading from v0.1.3" in its release notes first), or run setup without --claustrum to use local accounts.';
|
|
@@ -61624,7 +61752,8 @@ async function connectSetupHost(plugin2, host, io, terminal, fence) {
|
|
|
61624
61752
|
throw new Error(VAULT_HOST_CONNECT_REFUSAL2);
|
|
61625
61753
|
const { name, displayName, requestedGrants, grantFallback, paths: input2 } = plugin2.vault.hosts[host];
|
|
61626
61754
|
const paths = hostEnrollmentPaths2(input2);
|
|
61627
|
-
|
|
61755
|
+
const guard = typeof fence === "function" ? new SetupProcessGuard(fence, io.now) : fence;
|
|
61756
|
+
await guard.check({ reuse: true });
|
|
61628
61757
|
const client = await (io.connect ?? connectClaustrumEnrollmentClient2)({
|
|
61629
61758
|
connectionFile: plugin2.vault.connectionFile,
|
|
61630
61759
|
handshakeTimeoutMs: 2e3
|
|
@@ -61645,11 +61774,10 @@ async function connectSetupHost(plugin2, host, io, terminal, fence) {
|
|
|
61645
61774
|
// starts PowerShell.
|
|
61646
61775
|
client,
|
|
61647
61776
|
writeTokenFile: async (path5, file) => {
|
|
61648
|
-
await
|
|
61649
|
-
await writeEnrollmentTokenFile3(path5, file);
|
|
61777
|
+
await guard.check();
|
|
61778
|
+
await guard.step(() => writeEnrollmentTokenFile3(path5, file));
|
|
61650
61779
|
}
|
|
61651
61780
|
});
|
|
61652
|
-
await fence();
|
|
61653
61781
|
const initial = await manager.status();
|
|
61654
61782
|
if (initial.state === "approved") {
|
|
61655
61783
|
printLine2(terminal, `Already connected as ${initial.approvedName ?? initial.proposedName}.`);
|
|
@@ -61666,7 +61794,8 @@ async function connectSetupHost(plugin2, host, io, terminal, fence) {
|
|
|
61666
61794
|
let reportedCode;
|
|
61667
61795
|
let failedProposals = 0;
|
|
61668
61796
|
for (; ; ) {
|
|
61669
|
-
|
|
61797
|
+
await guard.check({ reuse: true });
|
|
61798
|
+
const status = await guard.step(() => manager.reconcile());
|
|
61670
61799
|
if (status.state === "approved") {
|
|
61671
61800
|
printLine2(terminal, `Connected ${host} to Claustrum.`);
|
|
61672
61801
|
const access = await confirmEnrollmentAccess(client, status, paths.tokenPath, requestedGrants);
|
|
@@ -61714,8 +61843,8 @@ async function connectSetupHost(plugin2, host, io, terminal, fence) {
|
|
|
61714
61843
|
const remaining = deadline - now();
|
|
61715
61844
|
if (remaining <= 0)
|
|
61716
61845
|
break;
|
|
61717
|
-
await wait2(Math.min(pause, remaining));
|
|
61718
|
-
await
|
|
61846
|
+
await guard.step(() => wait2(Math.min(pause, remaining)));
|
|
61847
|
+
await guard.check();
|
|
61719
61848
|
}
|
|
61720
61849
|
if (printedRequest)
|
|
61721
61850
|
throw new HostNotEnrolledError(`Claustrum approval is still pending. In another terminal, run: ${approveCommand(printedRequest, name)} and then rerun setup.`, {
|
|
@@ -61865,6 +61994,8 @@ async function selectSetupHosts(terminal, found) {
|
|
|
61865
61994
|
}
|
|
61866
61995
|
|
|
61867
61996
|
// src/common-auth-embedded/setup/register.js
|
|
61997
|
+
import { rename as rename15 } from "node:fs/promises";
|
|
61998
|
+
import { setTimeout as delay3 } from "node:timers/promises";
|
|
61868
61999
|
import { domainToUnicode } from "node:url";
|
|
61869
62000
|
import { applyEdits as applyEdits2, createScanner as createScanner2, findNodeAtLocation as findNodeAtLocation2, modify as modify2, parse as parse2, parseTree as parseTree2 } from "jsonc-parser";
|
|
61870
62001
|
|
|
@@ -62074,12 +62205,15 @@ function planOpenCodeRegistration(plugin2, generation, io = {}) {
|
|
|
62074
62205
|
});
|
|
62075
62206
|
}
|
|
62076
62207
|
async function registerOpenCode(writes, beforeWrite) {
|
|
62208
|
+
const guard = typeof beforeWrite === "function" ? new SetupProcessGuard(beforeWrite) : beforeWrite;
|
|
62077
62209
|
for (const write of writes) {
|
|
62078
62210
|
if (!write.changed)
|
|
62079
62211
|
continue;
|
|
62080
|
-
await beforeWrite?.();
|
|
62081
62212
|
await writeHostConfigAtomic(write.path, write.content, {
|
|
62082
|
-
|
|
62213
|
+
// Only the rename publishes host-readable config; recheck on every retry.
|
|
62214
|
+
beforeRename: guard ? () => guard.check({ reuse: true }) : void 0,
|
|
62215
|
+
rename: guard ? (from, to) => guard.step(() => rename15(from, to)) : void 0,
|
|
62216
|
+
wait: guard ? (ms) => guard.step(() => delay3(ms)) : void 0
|
|
62083
62217
|
});
|
|
62084
62218
|
}
|
|
62085
62219
|
}
|
|
@@ -62178,7 +62312,11 @@ async function runSetup(plugin2, argv = [], io = {}) {
|
|
|
62178
62312
|
return { hosts, dryRun: options.dryRun, mode: "local", detection };
|
|
62179
62313
|
}
|
|
62180
62314
|
const { env: env3, platform } = setupPaths(io);
|
|
62181
|
-
const fence = io.fence ?? createProcessFence(io.runner ?? defaultCommandRunner, {
|
|
62315
|
+
const fence = io.fence ?? createProcessFence(io.runner ?? defaultCommandRunner, {
|
|
62316
|
+
platform,
|
|
62317
|
+
isFile: io.fs?.isFile.bind(io.fs),
|
|
62318
|
+
onProgress: (line) => printLine2(terminal, line)
|
|
62319
|
+
});
|
|
62182
62320
|
const stopped = async () => {
|
|
62183
62321
|
try {
|
|
62184
62322
|
await assertHostsStopped(fence, env3);
|
|
@@ -62188,6 +62326,7 @@ async function runSetup(plugin2, argv = [], io = {}) {
|
|
|
62188
62326
|
throw error;
|
|
62189
62327
|
}
|
|
62190
62328
|
};
|
|
62329
|
+
const guard = new SetupProcessGuard(stopped, io.now);
|
|
62191
62330
|
printLine2(terminal, "Checking that OpenCode and Pi are not running\u2026");
|
|
62192
62331
|
if (options.dryRun) {
|
|
62193
62332
|
try {
|
|
@@ -62203,16 +62342,17 @@ async function runSetup(plugin2, argv = [], io = {}) {
|
|
|
62203
62342
|
if (error instanceof ProcessInspectionError)
|
|
62204
62343
|
printLine2(terminal, error.refusalText);
|
|
62205
62344
|
}
|
|
62206
|
-
} else
|
|
62207
|
-
await
|
|
62345
|
+
} else {
|
|
62346
|
+
await guard.check();
|
|
62347
|
+
}
|
|
62208
62348
|
if ((options.claustrum || options.enrollOnly) && !detection.claustrum.available)
|
|
62209
62349
|
throw new Error("Claustrum is not available. Start ck, or omit vault-only flags and use --no-claustrum for local sign-in.");
|
|
62210
62350
|
let useVault = options.claustrum || options.enrollOnly;
|
|
62211
62351
|
if (!useVault && !options.login && !options.noClaustrum && !assumeYes && detection.claustrum.available && isInteractive2(terminal)) {
|
|
62212
|
-
const choice = await select2(terminal, [
|
|
62352
|
+
const choice = await guard.step(() => select2(terminal, [
|
|
62213
62353
|
{ label: "No", value: false },
|
|
62214
62354
|
{ label: "Yes", value: true }
|
|
62215
|
-
], { message: "Connect these hosts to the Claustrum vault?" });
|
|
62355
|
+
], { message: "Connect these hosts to the Claustrum vault?" }));
|
|
62216
62356
|
if (choice === null) {
|
|
62217
62357
|
printLine2(terminal, "Setup cancelled. Nothing was changed.");
|
|
62218
62358
|
return { hosts: [], dryRun: options.dryRun, mode: "local", detection };
|
|
@@ -62263,13 +62403,14 @@ ${write.content}`);
|
|
|
62263
62403
|
const enrollmentAccess = /* @__PURE__ */ new Map();
|
|
62264
62404
|
try {
|
|
62265
62405
|
for (const host of hosts) {
|
|
62266
|
-
|
|
62267
|
-
|
|
62268
|
-
|
|
62406
|
+
if (plugin2.beforeSignIn) {
|
|
62407
|
+
await guard.check({ reuse: true });
|
|
62408
|
+
await guard.step(() => plugin2.beforeSignIn?.(host, context));
|
|
62409
|
+
}
|
|
62269
62410
|
if (useVault) {
|
|
62270
62411
|
enrollment.set(host, "unknown");
|
|
62271
62412
|
try {
|
|
62272
|
-
const access = await connectSetupHost(plugin2, host, io, terminal,
|
|
62413
|
+
const access = await connectSetupHost(plugin2, host, io, terminal, guard);
|
|
62273
62414
|
if (access)
|
|
62274
62415
|
enrollmentAccess.set(host, access);
|
|
62275
62416
|
} catch (error) {
|
|
@@ -62278,19 +62419,26 @@ ${write.content}`);
|
|
|
62278
62419
|
throw error;
|
|
62279
62420
|
}
|
|
62280
62421
|
enrollment.set(host, "enrolled");
|
|
62281
|
-
} else
|
|
62282
|
-
await
|
|
62283
|
-
|
|
62422
|
+
} else {
|
|
62423
|
+
await guard.check({ reuse: true });
|
|
62424
|
+
await guard.step(() => plugin2.signInLocal(host, context));
|
|
62425
|
+
}
|
|
62284
62426
|
if (options.enrollOnly)
|
|
62285
62427
|
continue;
|
|
62286
|
-
|
|
62287
|
-
|
|
62428
|
+
if (plugin2.beforeRegister) {
|
|
62429
|
+
await guard.check({ reuse: true });
|
|
62430
|
+
await guard.step(() => plugin2.beforeRegister?.(host, mode, context));
|
|
62431
|
+
}
|
|
62288
62432
|
if (host === "opencode")
|
|
62289
|
-
await registerOpenCode(writes,
|
|
62290
|
-
else
|
|
62291
|
-
await
|
|
62292
|
-
|
|
62293
|
-
|
|
62433
|
+
await registerOpenCode(writes, guard);
|
|
62434
|
+
else {
|
|
62435
|
+
await guard.check({ reuse: true });
|
|
62436
|
+
await guard.step(() => registerPi(plugin2, detection.pi.executable, io));
|
|
62437
|
+
}
|
|
62438
|
+
if (plugin2.migrate) {
|
|
62439
|
+
await guard.check({ reuse: true });
|
|
62440
|
+
await guard.step(() => plugin2.migrate?.(host, context));
|
|
62441
|
+
}
|
|
62294
62442
|
}
|
|
62295
62443
|
} catch (error) {
|
|
62296
62444
|
if (enrollment.size === 0)
|
|
@@ -63953,7 +64101,7 @@ function isSessionId(value) {
|
|
|
63953
64101
|
// src/common-auth-embedded/rpc/port-file.js
|
|
63954
64102
|
init_private_files2();
|
|
63955
64103
|
import { createHash as createHash21, randomUUID as randomUUID25 } from "node:crypto";
|
|
63956
|
-
import { chmod as chmod7, mkdir as mkdir20, open as open13, readdir as readdir7, rename as
|
|
64104
|
+
import { chmod as chmod7, mkdir as mkdir20, open as open13, readdir as readdir7, rename as rename16, rmdir as rmdir3, stat as stat20, unlink as unlink16 } from "node:fs/promises";
|
|
63957
64105
|
import { uptime as uptime2 } from "node:os";
|
|
63958
64106
|
import { join as join43, resolve as resolve31 } from "node:path";
|
|
63959
64107
|
function staleBefore(clock2) {
|
|
@@ -64035,7 +64183,7 @@ async function writePortFile(dir, entry, options = {}) {
|
|
|
64035
64183
|
await handle.chmod(384);
|
|
64036
64184
|
await handle.close();
|
|
64037
64185
|
handle = void 0;
|
|
64038
|
-
await
|
|
64186
|
+
await rename16(tmp, target);
|
|
64039
64187
|
created = false;
|
|
64040
64188
|
} finally {
|
|
64041
64189
|
await handle?.close().catch(() => {
|