@cortexkit/opencode-antigravity-auth 3.1.4 → 3.1.7
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 +92 -19
- package/dist/index.js +263 -106
- package/dist/index.js.map +4 -4
- package/dist/index.meta.json +104 -31
- package/dist/server.js +262 -104
- 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/ga/server/index.d.ts +1 -1
- package/dist/src/ga/server/index.d.ts.map +1 -1
- package/dist/src/ga/server/index.js +6 -0
- package/dist/src/ga/server/index.js.map +1 -1
- package/dist/src/plugin/__fixtures__/verified-store.d.ts +1 -1
- package/dist/src/plugin/__fixtures__/verified-store.js +4 -4
- package/dist/src/plugin/request-helpers.js +3 -3
- 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 +5 -2
- package/dist/src/plugin/shared/request-services.js.map +1 -1
- 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/dist/types/src/ga/server/index.d.ts +1 -1
- package/dist/types/src/ga/server/index.d.ts.map +1 -1
- package/dist/types/src/plugin/shared/request-services.d.ts.map +1 -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/index.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)
|
|
@@ -4706,7 +4706,7 @@ var init_rotation = __esm({
|
|
|
4706
4706
|
UNCONFIRMED_RATE_LIMIT_MIN_MS = 5e3;
|
|
4707
4707
|
UNCONFIRMED_RATE_LIMIT_MAX_MS = 3e4;
|
|
4708
4708
|
MAX_UNCONFIRMED_RATE_LIMIT_RETRIES = 2;
|
|
4709
|
-
UNCONFIRMED_RATE_LIMIT_MESSAGE = "Antigravity
|
|
4709
|
+
UNCONFIRMED_RATE_LIMIT_MESSAGE = "Antigravity refused the request without a stated reason. If this keeps happening, change the agent system prompt or wait before sending another request.";
|
|
4710
4710
|
DEFAULT_HEALTH_SCORE_CONFIG = {
|
|
4711
4711
|
initial: 70,
|
|
4712
4712
|
successReward: 1,
|
|
@@ -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((resolve32, 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
|
resolve32();
|
|
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) {
|
|
@@ -27634,6 +27635,12 @@ var init_harness_identity = __esm({
|
|
|
27634
27635
|
"opencode.ai/docs"
|
|
27635
27636
|
];
|
|
27636
27637
|
HARNESS_IDENTITY_REWRITES = [
|
|
27638
|
+
{
|
|
27639
|
+
// Antigravity refuses requests carrying this stock Pi docs bullet with a
|
|
27640
|
+
// false quota error. Remove its codemode clause, retaining other docs pointers.
|
|
27641
|
+
pattern: /^(- When asked about: extensions \(docs\/extensions\.md, examples\/extensions\/\), themes \(docs\/themes\.md\), skills \(docs\/skills\.md\), prompt templates \(docs\/prompt-templates\.md\), TUI components \(docs\/tui\.md\), keybindings \(docs\/keybindings\.md\), SDK integrations \(docs\/sdk\.md\), custom providers \(docs\/custom-provider\.md\), adding models \(docs\/models\.md\), packages \(docs\/packages\.md\), environment variables \(docs\/environment-variables\.md\), MCP servers \(docs\/mcp\.md\)), codemode scripts and non-LLM models such as classifiers and image models \(docs\/codemode\.md\)\n/gm,
|
|
27642
|
+
replacement: "$1\n"
|
|
27643
|
+
},
|
|
27637
27644
|
{
|
|
27638
27645
|
pattern: /\btools\.opencode\b/g,
|
|
27639
27646
|
replacement: "tools['opencode']"
|
|
@@ -27650,6 +27657,10 @@ var init_harness_identity = __esm({
|
|
|
27650
27657
|
pattern: /if OpenCode honestly/g,
|
|
27651
27658
|
replacement: "if the assistant honestly"
|
|
27652
27659
|
},
|
|
27660
|
+
{
|
|
27661
|
+
pattern: /You are a coding assistant running inside (?:pi, a coding agent harness|Pi-Bolt, a build of pi \(a coding agent harness\) compiled ahead of time)\.(?=$|\s)/g,
|
|
27662
|
+
replacement: "You are a coding assistant."
|
|
27663
|
+
},
|
|
27653
27664
|
{
|
|
27654
27665
|
pattern: /running inside Pi-Bolt, a build of pi \(a coding agent harness\) compiled ahead of time/gi,
|
|
27655
27666
|
replacement: "running inside your development environment"
|
|
@@ -27710,7 +27721,7 @@ var init_pre_response_deadline = __esm({
|
|
|
27710
27721
|
"../core/dist/pre-response-deadline.js"() {
|
|
27711
27722
|
"use strict";
|
|
27712
27723
|
PRE_RESPONSE_DEADLINE_MS = 6e5;
|
|
27713
|
-
PRE_RESPONSE_TIMEOUT_MESSAGE = "Antigravity did not begin a response within the pre-response time limit. Check your connection
|
|
27724
|
+
PRE_RESPONSE_TIMEOUT_MESSAGE = "Antigravity did not begin a response within the pre-response time limit. Check your connection before sending another request.";
|
|
27714
27725
|
PreResponseTimeoutError = class extends Error {
|
|
27715
27726
|
code = 412;
|
|
27716
27727
|
status = "FAILED_PRECONDITION";
|
|
@@ -28788,7 +28799,7 @@ function isSchemaObject(value) {
|
|
|
28788
28799
|
function describeValue(value) {
|
|
28789
28800
|
return JSON.stringify(value) ?? String(value);
|
|
28790
28801
|
}
|
|
28791
|
-
function normalizeNullableTypeArray(schema) {
|
|
28802
|
+
function normalizeNullableTypeArray(schema, unionHints) {
|
|
28792
28803
|
if (!Array.isArray(schema.type))
|
|
28793
28804
|
return schema;
|
|
28794
28805
|
if (schema.type.length === 0 || schema.type.some((type) => typeof type !== "string" || !ALLOWED_JSON_SCHEMA_TYPES.has(type.toLowerCase()))) {
|
|
@@ -28799,7 +28810,37 @@ function normalizeNullableTypeArray(schema) {
|
|
|
28799
28810
|
];
|
|
28800
28811
|
const nonNull = types.filter((type) => type !== "null");
|
|
28801
28812
|
if (nonNull.length > 1) {
|
|
28802
|
-
|
|
28813
|
+
if (!unionHints)
|
|
28814
|
+
return schema;
|
|
28815
|
+
const { type: _type, ...base } = schema;
|
|
28816
|
+
if (types.includes("null"))
|
|
28817
|
+
base.nullable = true;
|
|
28818
|
+
const coversEveryType = ["object", "array", "string", "boolean"].every((type) => nonNull.includes(type)) && (nonNull.includes("number") || nonNull.includes("integer"));
|
|
28819
|
+
if (!coversEveryType && (Array.isArray(base.anyOf) || Array.isArray(base.oneOf))) {
|
|
28820
|
+
unionHints.push("type: additional union constraints omitted.");
|
|
28821
|
+
return base;
|
|
28822
|
+
}
|
|
28823
|
+
const branches = nonNull.map((type) => {
|
|
28824
|
+
const branch = { type };
|
|
28825
|
+
for (const key of TYPE_ARRAY_BRANCH_FIELDS[type] ?? []) {
|
|
28826
|
+
if (!Object.hasOwn(base, key))
|
|
28827
|
+
continue;
|
|
28828
|
+
if (key === "enum" && (!Array.isArray(base.enum) || !base.enum.every((value) => typeof value === "string")))
|
|
28829
|
+
continue;
|
|
28830
|
+
branch[key] = base[key];
|
|
28831
|
+
}
|
|
28832
|
+
return branch;
|
|
28833
|
+
});
|
|
28834
|
+
for (const key of /* @__PURE__ */ new Set([
|
|
28835
|
+
...Object.values(TYPE_ARRAY_BRANCH_FIELDS).flat(),
|
|
28836
|
+
"minProperties",
|
|
28837
|
+
"maxProperties"
|
|
28838
|
+
])) {
|
|
28839
|
+
if (key === "enum" && Array.isArray(base.enum) && !base.enum.every((value) => typeof value === "string"))
|
|
28840
|
+
continue;
|
|
28841
|
+
delete base[key];
|
|
28842
|
+
}
|
|
28843
|
+
return coversEveryType ? base : { ...base, anyOf: branches };
|
|
28803
28844
|
}
|
|
28804
28845
|
return {
|
|
28805
28846
|
...schema,
|
|
@@ -28917,7 +28958,7 @@ function toGeminiSchema(schema, options = {}) {
|
|
|
28917
28958
|
return schema;
|
|
28918
28959
|
}
|
|
28919
28960
|
const numericConstraintHints = [];
|
|
28920
|
-
const inputSchema = normalizeNullableTypeArray(mergeSchemaAllOf(schema, numericConstraintHints));
|
|
28961
|
+
const inputSchema = normalizeNullableTypeArray(mergeSchemaAllOf(schema, numericConstraintHints), options.claudeValidated ? void 0 : numericConstraintHints);
|
|
28921
28962
|
const schemaType = typeof inputSchema.type === "string" ? inputSchema.type.toUpperCase() : void 0;
|
|
28922
28963
|
let result = {};
|
|
28923
28964
|
const propertyNames = /* @__PURE__ */ new Set();
|
|
@@ -29268,7 +29309,7 @@ function wrapToolsAsFunctionDeclarations(payload) {
|
|
|
29268
29309
|
passthroughToolCount: passthroughTools.length + (hasWebSearchTool && functionDeclarations.length === 0 ? 1 : 0)
|
|
29269
29310
|
};
|
|
29270
29311
|
}
|
|
29271
|
-
var ALLOWED_SCHEMA_FIELDS, NUMERIC_SCHEMA_CONSTRAINTS, ALLOWED_JSON_SCHEMA_TYPES, CLAUDE_VALIDATED_HINT_FIELDS, VALID_ASPECT_RATIOS;
|
|
29312
|
+
var ALLOWED_SCHEMA_FIELDS, NUMERIC_SCHEMA_CONSTRAINTS, ALLOWED_JSON_SCHEMA_TYPES, TYPE_ARRAY_BRANCH_FIELDS, CLAUDE_VALIDATED_HINT_FIELDS, VALID_ASPECT_RATIOS;
|
|
29272
29313
|
var init_gemini = __esm({
|
|
29273
29314
|
"../core/dist/transform/gemini.js"() {
|
|
29274
29315
|
"use strict";
|
|
@@ -29318,6 +29359,30 @@ var init_gemini = __esm({
|
|
|
29318
29359
|
"object",
|
|
29319
29360
|
"null"
|
|
29320
29361
|
]);
|
|
29362
|
+
TYPE_ARRAY_BRANCH_FIELDS = {
|
|
29363
|
+
object: [
|
|
29364
|
+
"properties",
|
|
29365
|
+
"required",
|
|
29366
|
+
"propertyOrdering",
|
|
29367
|
+
"additionalProperties"
|
|
29368
|
+
],
|
|
29369
|
+
array: ["items", "minItems", "maxItems"],
|
|
29370
|
+
string: ["enum", "format", "minLength", "maxLength", "pattern"],
|
|
29371
|
+
number: [
|
|
29372
|
+
"minimum",
|
|
29373
|
+
"maximum",
|
|
29374
|
+
"exclusiveMinimum",
|
|
29375
|
+
"exclusiveMaximum",
|
|
29376
|
+
"multipleOf"
|
|
29377
|
+
],
|
|
29378
|
+
integer: [
|
|
29379
|
+
"minimum",
|
|
29380
|
+
"maximum",
|
|
29381
|
+
"exclusiveMinimum",
|
|
29382
|
+
"exclusiveMaximum",
|
|
29383
|
+
"multipleOf"
|
|
29384
|
+
]
|
|
29385
|
+
};
|
|
29321
29386
|
CLAUDE_VALIDATED_HINT_FIELDS = /* @__PURE__ */ new Set([
|
|
29322
29387
|
"minLength",
|
|
29323
29388
|
"maxLength",
|
|
@@ -29982,6 +30047,15 @@ function assertRosterBinding(roster, attribution, claustrum) {
|
|
|
29982
30047
|
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
30048
|
throw new VaultProviderStateError("binding-stale", "the vault route no longer serves the attributed credential and account");
|
|
29984
30049
|
}
|
|
30050
|
+
function quotaBoundState(current, attribution) {
|
|
30051
|
+
if (current?.quota === void 0 || current.observed.routeId === attribution.routeId && current.observed.credentialId === attribution.credentialId)
|
|
30052
|
+
return current;
|
|
30053
|
+
return Object.freeze({
|
|
30054
|
+
observed: current.observed,
|
|
30055
|
+
...current.metadata !== void 0 ? { metadata: current.metadata } : {},
|
|
30056
|
+
...current.extensions !== void 0 ? { extensions: current.extensions } : {}
|
|
30057
|
+
});
|
|
30058
|
+
}
|
|
29985
30059
|
async function commitVaultProviderState(input2) {
|
|
29986
30060
|
const { claustrum, fs: fs7, statePath } = input2;
|
|
29987
30061
|
input2.signal?.throwIfAborted();
|
|
@@ -29997,7 +30071,7 @@ async function commitVaultProviderState(input2) {
|
|
|
29997
30071
|
const file = await readVaultProviderState(statePath);
|
|
29998
30072
|
input2.signal?.throwIfAborted();
|
|
29999
30073
|
const current = vaultAccountState(file, identity4);
|
|
30000
|
-
const requested = input2.update(current);
|
|
30074
|
+
const requested = input2.update(quotaBoundState(current, attribution));
|
|
30001
30075
|
if (isRecord9(requested) && typeof requested.then === "function")
|
|
30002
30076
|
throw new VaultProviderStateError("invalid-update", "a state update must be synchronous");
|
|
30003
30077
|
if (requested === void 0)
|
|
@@ -30105,7 +30179,7 @@ async function commitVaultProviderStates(input2) {
|
|
|
30105
30179
|
const identity4 = entry.attribution.accountIdentity;
|
|
30106
30180
|
const current = Object.hasOwn(accounts, identity4) ? accounts[identity4] : void 0;
|
|
30107
30181
|
try {
|
|
30108
|
-
const requested = entry.update(current);
|
|
30182
|
+
const requested = entry.update(quotaBoundState(current, entry.attribution));
|
|
30109
30183
|
if (isRecord9(requested) && typeof requested.then === "function")
|
|
30110
30184
|
throw new VaultProviderStateError("invalid-update", "a state update must be synchronous");
|
|
30111
30185
|
if (requested === void 0 || requested === null && !current) {
|
|
@@ -30534,7 +30608,7 @@ var init_vault_enrollment_authority = __esm({
|
|
|
30534
30608
|
"use strict";
|
|
30535
30609
|
init_common_auth_runtime();
|
|
30536
30610
|
UNSUPPORTED_VAULT_CODE = "unknown_method";
|
|
30537
|
-
VAULT_ACCOUNT_REMEDY = "Vault account access is
|
|
30611
|
+
VAULT_ACCOUNT_REMEDY = "Vault account access is not ready. Connect accounts in the vault, or disconnect the vault to use local accounts.";
|
|
30538
30612
|
}
|
|
30539
30613
|
});
|
|
30540
30614
|
|
|
@@ -30860,12 +30934,12 @@ async function replaceWindowsFile2(from, to, options = {}) {
|
|
|
30860
30934
|
const delays = [0, 10, 20, 40, 80, 100];
|
|
30861
30935
|
let original;
|
|
30862
30936
|
let attempts2 = 0;
|
|
30863
|
-
for (const
|
|
30937
|
+
for (const delay4 of delays) {
|
|
30864
30938
|
const deadline = Math.min(retryDeadline ?? Infinity, leaseDeadline);
|
|
30865
30939
|
if (now() >= deadline)
|
|
30866
30940
|
break;
|
|
30867
|
-
if (
|
|
30868
|
-
await (options.sleep ?? ((ms) => new Promise((r) => setTimeout(r, ms))))(Math.min(
|
|
30941
|
+
if (delay4)
|
|
30942
|
+
await (options.sleep ?? ((ms) => new Promise((r) => setTimeout(r, ms))))(Math.min(delay4, Math.max(0, deadline - now())));
|
|
30869
30943
|
if (now() >= deadline)
|
|
30870
30944
|
break;
|
|
30871
30945
|
const fenceStart = now();
|
|
@@ -34376,8 +34450,8 @@ function isWindowsSharingError(error, platform) {
|
|
|
34376
34450
|
}
|
|
34377
34451
|
async function unlinkIfIdentical(file, stateDir, guard, io = { platform: process.platform, readFile: readFile12, unlink: unlink11 }) {
|
|
34378
34452
|
const started = performance.now();
|
|
34379
|
-
for (const
|
|
34380
|
-
if (
|
|
34453
|
+
for (const delay4 of SHARING_RETRY_DELAYS_MS) {
|
|
34454
|
+
if (delay4 > 0) await new Promise((done) => setTimeout(done, delay4));
|
|
34381
34455
|
let same;
|
|
34382
34456
|
try {
|
|
34383
34457
|
same = (await io.readFile(file.old)).equals(await io.readFile(file.next));
|
|
@@ -40728,12 +40802,12 @@ import { parse } from "jsonc-parser";
|
|
|
40728
40802
|
|
|
40729
40803
|
// src/common-auth-embedded/setup/paths.js
|
|
40730
40804
|
import { homedir as homedir7 } from "node:os";
|
|
40731
|
-
import { posix, win32 } from "node:path";
|
|
40805
|
+
import { posix, win32 as win322 } from "node:path";
|
|
40732
40806
|
import { fileURLToPath } from "node:url";
|
|
40733
40807
|
function setupPaths(io = {}) {
|
|
40734
40808
|
const env3 = io.env ?? process.env;
|
|
40735
40809
|
const platform = io.platform ?? process.platform;
|
|
40736
|
-
const path5 = platform === "win32" ?
|
|
40810
|
+
const path5 = platform === "win32" ? win322 : posix;
|
|
40737
40811
|
const home = io.home ?? (platform === "win32" ? env3.USERPROFILE : env3.HOME) ?? homedir7();
|
|
40738
40812
|
const cwd = io.cwd ?? process.cwd();
|
|
40739
40813
|
const absolute = (value) => path5.resolve(cwd, value);
|
|
@@ -40960,7 +41034,20 @@ import { setTimeout as delay } from "node:timers/promises";
|
|
|
40960
41034
|
import { writeEnrollmentTokenFile as writeEnrollmentTokenFile3 } from "@cortexkit/claustrum-client";
|
|
40961
41035
|
|
|
40962
41036
|
// src/common-auth-embedded/setup/process-fence.js
|
|
41037
|
+
import { statSync as statSync6 } from "node:fs";
|
|
41038
|
+
import { win32 as win323 } from "node:path";
|
|
40963
41039
|
var WINDOWS_CIM_TIMEOUT_MS = 45e3;
|
|
41040
|
+
var WINDOWS_ARM_POWERSHELL_TIMEOUT_MS = 9e4;
|
|
41041
|
+
function isFile(file) {
|
|
41042
|
+
try {
|
|
41043
|
+
return statSync6(file).isFile();
|
|
41044
|
+
} catch {
|
|
41045
|
+
return false;
|
|
41046
|
+
}
|
|
41047
|
+
}
|
|
41048
|
+
function windowsEnv(env3, name) {
|
|
41049
|
+
return Object.entries(env3).find(([key]) => key.toUpperCase() === name.toUpperCase())?.[1];
|
|
41050
|
+
}
|
|
40964
41051
|
var HOSTS = /* @__PURE__ */ new Set(["opencode", "litecode", "opencode2", "pi"]);
|
|
40965
41052
|
var RUNTIMES = /* @__PURE__ */ new Set(["node", "bun"]);
|
|
40966
41053
|
var WINDOWS_FENCE_FILTER = [...HOSTS, ...RUNTIMES].map((name) => `Name LIKE '${name}%'`).join(" OR ");
|
|
@@ -41032,6 +41119,7 @@ function hostName(command) {
|
|
|
41032
41119
|
var ProcessInspectionError = class extends Error {
|
|
41033
41120
|
code = "process-inspection-failed";
|
|
41034
41121
|
step;
|
|
41122
|
+
program;
|
|
41035
41123
|
exitCode;
|
|
41036
41124
|
signal;
|
|
41037
41125
|
timedOut;
|
|
@@ -41040,6 +41128,7 @@ var ProcessInspectionError = class extends Error {
|
|
|
41040
41128
|
super("Process inspection failed; setup cannot prove hosts are stopped.");
|
|
41041
41129
|
this.name = "ProcessInspectionError";
|
|
41042
41130
|
this.step = details.step;
|
|
41131
|
+
this.program = details.program;
|
|
41043
41132
|
this.exitCode = details.exitCode;
|
|
41044
41133
|
this.signal = details.signal;
|
|
41045
41134
|
this.timedOut = details.timedOut;
|
|
@@ -41067,6 +41156,8 @@ Please quit all OpenCode, LiteCode, and Pi processes before running setup.`);
|
|
|
41067
41156
|
};
|
|
41068
41157
|
async function listSetupProcesses(runner = defaultCommandRunner, options = {}) {
|
|
41069
41158
|
const windows2 = (options.platform ?? process.platform) === "win32";
|
|
41159
|
+
const env3 = options.env ?? process.env;
|
|
41160
|
+
const system32 = windows2 ? win323.resolve(windowsEnv(env3, "SystemRoot") ?? windowsEnv(env3, "windir") ?? "C:\\Windows", "System32") : "";
|
|
41070
41161
|
const selfPid = options.selfPid ?? process.pid;
|
|
41071
41162
|
let inspection = {
|
|
41072
41163
|
step: windows2 ? "tasklist" : "ps",
|
|
@@ -41075,10 +41166,11 @@ async function listSetupProcesses(runner = defaultCommandRunner, options = {}) {
|
|
|
41075
41166
|
timedOut: false,
|
|
41076
41167
|
durationMs: 0
|
|
41077
41168
|
};
|
|
41078
|
-
const inspect = async (step, file, args, timeoutMs) => {
|
|
41169
|
+
const inspect = async (step, file, args, timeoutMs, program) => {
|
|
41079
41170
|
const started = performance.now();
|
|
41080
41171
|
inspection = {
|
|
41081
41172
|
step,
|
|
41173
|
+
...program && { program },
|
|
41082
41174
|
exitCode: null,
|
|
41083
41175
|
signal: null,
|
|
41084
41176
|
timedOut: false,
|
|
@@ -41091,6 +41183,7 @@ async function listSetupProcesses(runner = defaultCommandRunner, options = {}) {
|
|
|
41091
41183
|
});
|
|
41092
41184
|
inspection = {
|
|
41093
41185
|
step,
|
|
41186
|
+
...program && { program },
|
|
41094
41187
|
exitCode: result.exitCode,
|
|
41095
41188
|
signal: result.signal ?? null,
|
|
41096
41189
|
timedOut: result.timedOut ?? false,
|
|
@@ -41103,9 +41196,23 @@ async function listSetupProcesses(runner = defaultCommandRunner, options = {}) {
|
|
|
41103
41196
|
options.onStep?.({ ...inspection });
|
|
41104
41197
|
}
|
|
41105
41198
|
};
|
|
41199
|
+
const inspectCim = (args) => {
|
|
41200
|
+
const pwsh = win323.resolve(windowsEnv(env3, "ProgramFiles") ?? "C:\\Program Files", "PowerShell", "7", "pwsh.exe");
|
|
41201
|
+
const program = (options.isFile ?? isFile)(pwsh) ? "pwsh" : "powershell";
|
|
41202
|
+
const arm64 = (windowsEnv(env3, "PROCESSOR_ARCHITEW6432") ?? windowsEnv(env3, "PROCESSOR_ARCHITECTURE"))?.toUpperCase() === "ARM64";
|
|
41203
|
+
const slow = program === "powershell" && arm64;
|
|
41204
|
+
if (slow)
|
|
41205
|
+
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.");
|
|
41206
|
+
return inspect("CIM", program === "pwsh" ? pwsh : win323.resolve(system32, "WindowsPowerShell", "v1.0", "powershell.exe"), args, slow ? WINDOWS_ARM_POWERSHELL_TIMEOUT_MS : WINDOWS_CIM_TIMEOUT_MS, program);
|
|
41207
|
+
};
|
|
41106
41208
|
try {
|
|
41107
41209
|
if (windows2 && options.hostImagesOnly) {
|
|
41108
|
-
const details = await
|
|
41210
|
+
const details = await inspectCim([
|
|
41211
|
+
"-NoProfile",
|
|
41212
|
+
"-NonInteractive",
|
|
41213
|
+
"-Command",
|
|
41214
|
+
WINDOWS_FENCE_QUERY
|
|
41215
|
+
]);
|
|
41109
41216
|
if (details.exitCode !== 0)
|
|
41110
41217
|
throw new ProcessInspectionError(inspection);
|
|
41111
41218
|
const value = JSON.parse(details.stdout);
|
|
@@ -41127,7 +41234,7 @@ async function listSetupProcesses(runner = defaultCommandRunner, options = {}) {
|
|
|
41127
41234
|
}
|
|
41128
41235
|
return processes2;
|
|
41129
41236
|
}
|
|
41130
|
-
const result = await inspect(windows2 ? "tasklist" : "ps", windows2 ? "tasklist.exe" : "ps", windows2 ? ["/fo", "csv", "/nh"] : ["-eo", "pid,command"]);
|
|
41237
|
+
const result = await inspect(windows2 ? "tasklist" : "ps", windows2 ? win323.resolve(system32, "tasklist.exe") : "ps", windows2 ? ["/fo", "csv", "/nh"] : ["-eo", "pid,command"]);
|
|
41131
41238
|
if (result.exitCode !== 0)
|
|
41132
41239
|
throw new ProcessInspectionError(inspection);
|
|
41133
41240
|
const processes = [];
|
|
@@ -41161,12 +41268,12 @@ async function listSetupProcesses(runner = defaultCommandRunner, options = {}) {
|
|
|
41161
41268
|
throw new ProcessInspectionError(inspection);
|
|
41162
41269
|
const runtimes = processes.filter((entry) => entry.pid !== selfPid && /^(?:node|bun)\.exe$/i.test(entry.command));
|
|
41163
41270
|
if (windows2 && runtimes.length && options.inspectRuntimes !== false) {
|
|
41164
|
-
const details = await
|
|
41271
|
+
const details = await inspectCim([
|
|
41165
41272
|
"-NoProfile",
|
|
41166
41273
|
"-NonInteractive",
|
|
41167
41274
|
"-Command",
|
|
41168
41275
|
`$ErrorActionPreference = 'Stop'; Get-CimInstance Win32_Process -Filter "Name = 'node.exe' OR Name = 'bun.exe'" | Select-Object ProcessId,CommandLine | ConvertTo-Json -Compress`
|
|
41169
|
-
]
|
|
41276
|
+
]);
|
|
41170
41277
|
if (details.exitCode !== 0)
|
|
41171
41278
|
throw new ProcessInspectionError(inspection);
|
|
41172
41279
|
const value = JSON.parse(details.stdout || "null");
|
|
@@ -41222,6 +41329,36 @@ async function assertHostsStopped(fence, env3) {
|
|
|
41222
41329
|
throw new ProcessFenceViolationError(active2);
|
|
41223
41330
|
}
|
|
41224
41331
|
|
|
41332
|
+
// src/common-auth-embedded/setup/process-guard.js
|
|
41333
|
+
var SetupProcessGuard = class {
|
|
41334
|
+
inspect;
|
|
41335
|
+
now;
|
|
41336
|
+
#checkedAt;
|
|
41337
|
+
constructor(inspect, now = () => performance.now()) {
|
|
41338
|
+
this.inspect = inspect;
|
|
41339
|
+
this.now = now;
|
|
41340
|
+
}
|
|
41341
|
+
async check(options = {}) {
|
|
41342
|
+
if (options.reuse && this.#checkedAt !== void 0) {
|
|
41343
|
+
const age = this.now() - this.#checkedAt;
|
|
41344
|
+
if (age >= 0 && age < 5e3)
|
|
41345
|
+
return;
|
|
41346
|
+
}
|
|
41347
|
+
this.#checkedAt = void 0;
|
|
41348
|
+
await this.inspect();
|
|
41349
|
+
this.#checkedAt = this.now();
|
|
41350
|
+
}
|
|
41351
|
+
/** Callbacks, writes and waits can all make an earlier inspection stale. */
|
|
41352
|
+
async step(run) {
|
|
41353
|
+
this.#checkedAt = void 0;
|
|
41354
|
+
try {
|
|
41355
|
+
return await run();
|
|
41356
|
+
} finally {
|
|
41357
|
+
this.#checkedAt = void 0;
|
|
41358
|
+
}
|
|
41359
|
+
}
|
|
41360
|
+
};
|
|
41361
|
+
|
|
41225
41362
|
// src/common-auth-embedded/setup/enroll.js
|
|
41226
41363
|
var ENROLLMENT_INCOMPLETE_MESSAGE = "Claustrum enrollment did not complete. Inspect and approve with ck, then rerun setup.";
|
|
41227
41364
|
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.';
|
|
@@ -41250,7 +41387,8 @@ async function connectSetupHost(plugin, host, io, terminal, fence) {
|
|
|
41250
41387
|
throw new Error(VAULT_HOST_CONNECT_REFUSAL2);
|
|
41251
41388
|
const { name, displayName, requestedGrants, grantFallback, paths: input2 } = plugin.vault.hosts[host];
|
|
41252
41389
|
const paths = hostEnrollmentPaths2(input2);
|
|
41253
|
-
|
|
41390
|
+
const guard = typeof fence === "function" ? new SetupProcessGuard(fence, io.now) : fence;
|
|
41391
|
+
await guard.check({ reuse: true });
|
|
41254
41392
|
const client = await (io.connect ?? connectClaustrumEnrollmentClient2)({
|
|
41255
41393
|
connectionFile: plugin.vault.connectionFile,
|
|
41256
41394
|
handshakeTimeoutMs: 2e3
|
|
@@ -41271,11 +41409,10 @@ async function connectSetupHost(plugin, host, io, terminal, fence) {
|
|
|
41271
41409
|
// starts PowerShell.
|
|
41272
41410
|
client,
|
|
41273
41411
|
writeTokenFile: async (path5, file) => {
|
|
41274
|
-
await
|
|
41275
|
-
await writeEnrollmentTokenFile3(path5, file);
|
|
41412
|
+
await guard.check();
|
|
41413
|
+
await guard.step(() => writeEnrollmentTokenFile3(path5, file));
|
|
41276
41414
|
}
|
|
41277
41415
|
});
|
|
41278
|
-
await fence();
|
|
41279
41416
|
const initial = await manager.status();
|
|
41280
41417
|
if (initial.state === "approved") {
|
|
41281
41418
|
printLine2(terminal, `Already connected as ${initial.approvedName ?? initial.proposedName}.`);
|
|
@@ -41292,7 +41429,8 @@ async function connectSetupHost(plugin, host, io, terminal, fence) {
|
|
|
41292
41429
|
let reportedCode;
|
|
41293
41430
|
let failedProposals = 0;
|
|
41294
41431
|
for (; ; ) {
|
|
41295
|
-
|
|
41432
|
+
await guard.check({ reuse: true });
|
|
41433
|
+
const status = await guard.step(() => manager.reconcile());
|
|
41296
41434
|
if (status.state === "approved") {
|
|
41297
41435
|
printLine2(terminal, `Connected ${host} to Claustrum.`);
|
|
41298
41436
|
const access = await confirmEnrollmentAccess(client, status, paths.tokenPath, requestedGrants);
|
|
@@ -41340,8 +41478,8 @@ async function connectSetupHost(plugin, host, io, terminal, fence) {
|
|
|
41340
41478
|
const remaining = deadline - now();
|
|
41341
41479
|
if (remaining <= 0)
|
|
41342
41480
|
break;
|
|
41343
|
-
await wait2(Math.min(pause, remaining));
|
|
41344
|
-
await
|
|
41481
|
+
await guard.step(() => wait2(Math.min(pause, remaining)));
|
|
41482
|
+
await guard.check();
|
|
41345
41483
|
}
|
|
41346
41484
|
if (printedRequest)
|
|
41347
41485
|
throw new HostNotEnrolledError(`Claustrum approval is still pending. In another terminal, run: ${approveCommand(printedRequest, name)} and then rerun setup.`, {
|
|
@@ -41491,6 +41629,8 @@ async function selectSetupHosts(terminal, found) {
|
|
|
41491
41629
|
}
|
|
41492
41630
|
|
|
41493
41631
|
// src/common-auth-embedded/setup/register.js
|
|
41632
|
+
import { rename as rename14 } from "node:fs/promises";
|
|
41633
|
+
import { setTimeout as delay3 } from "node:timers/promises";
|
|
41494
41634
|
import { domainToUnicode } from "node:url";
|
|
41495
41635
|
import { applyEdits, createScanner, findNodeAtLocation, modify, parse as parse2, parseTree } from "jsonc-parser";
|
|
41496
41636
|
|
|
@@ -41700,12 +41840,15 @@ function planOpenCodeRegistration(plugin, generation, io = {}) {
|
|
|
41700
41840
|
});
|
|
41701
41841
|
}
|
|
41702
41842
|
async function registerOpenCode(writes, beforeWrite) {
|
|
41843
|
+
const guard = typeof beforeWrite === "function" ? new SetupProcessGuard(beforeWrite) : beforeWrite;
|
|
41703
41844
|
for (const write of writes) {
|
|
41704
41845
|
if (!write.changed)
|
|
41705
41846
|
continue;
|
|
41706
|
-
await beforeWrite?.();
|
|
41707
41847
|
await writeHostConfigAtomic(write.path, write.content, {
|
|
41708
|
-
|
|
41848
|
+
// Only the rename publishes host-readable config; recheck on every retry.
|
|
41849
|
+
beforeRename: guard ? () => guard.check({ reuse: true }) : void 0,
|
|
41850
|
+
rename: guard ? (from, to) => guard.step(() => rename14(from, to)) : void 0,
|
|
41851
|
+
wait: guard ? (ms) => guard.step(() => delay3(ms)) : void 0
|
|
41709
41852
|
});
|
|
41710
41853
|
}
|
|
41711
41854
|
}
|
|
@@ -41804,7 +41947,11 @@ async function runSetup(plugin, argv = [], io = {}) {
|
|
|
41804
41947
|
return { hosts, dryRun: options.dryRun, mode: "local", detection };
|
|
41805
41948
|
}
|
|
41806
41949
|
const { env: env3, platform } = setupPaths(io);
|
|
41807
|
-
const fence = io.fence ?? createProcessFence(io.runner ?? defaultCommandRunner, {
|
|
41950
|
+
const fence = io.fence ?? createProcessFence(io.runner ?? defaultCommandRunner, {
|
|
41951
|
+
platform,
|
|
41952
|
+
isFile: io.fs?.isFile.bind(io.fs),
|
|
41953
|
+
onProgress: (line) => printLine2(terminal, line)
|
|
41954
|
+
});
|
|
41808
41955
|
const stopped = async () => {
|
|
41809
41956
|
try {
|
|
41810
41957
|
await assertHostsStopped(fence, env3);
|
|
@@ -41814,6 +41961,7 @@ async function runSetup(plugin, argv = [], io = {}) {
|
|
|
41814
41961
|
throw error;
|
|
41815
41962
|
}
|
|
41816
41963
|
};
|
|
41964
|
+
const guard = new SetupProcessGuard(stopped, io.now);
|
|
41817
41965
|
printLine2(terminal, "Checking that OpenCode and Pi are not running\u2026");
|
|
41818
41966
|
if (options.dryRun) {
|
|
41819
41967
|
try {
|
|
@@ -41829,16 +41977,17 @@ async function runSetup(plugin, argv = [], io = {}) {
|
|
|
41829
41977
|
if (error instanceof ProcessInspectionError)
|
|
41830
41978
|
printLine2(terminal, error.refusalText);
|
|
41831
41979
|
}
|
|
41832
|
-
} else
|
|
41833
|
-
await
|
|
41980
|
+
} else {
|
|
41981
|
+
await guard.check();
|
|
41982
|
+
}
|
|
41834
41983
|
if ((options.claustrum || options.enrollOnly) && !detection.claustrum.available)
|
|
41835
41984
|
throw new Error("Claustrum is not available. Start ck, or omit vault-only flags and use --no-claustrum for local sign-in.");
|
|
41836
41985
|
let useVault = options.claustrum || options.enrollOnly;
|
|
41837
41986
|
if (!useVault && !options.login && !options.noClaustrum && !assumeYes && detection.claustrum.available && isInteractive2(terminal)) {
|
|
41838
|
-
const choice = await select2(terminal, [
|
|
41987
|
+
const choice = await guard.step(() => select2(terminal, [
|
|
41839
41988
|
{ label: "No", value: false },
|
|
41840
41989
|
{ label: "Yes", value: true }
|
|
41841
|
-
], { message: "Connect these hosts to the Claustrum vault?" });
|
|
41990
|
+
], { message: "Connect these hosts to the Claustrum vault?" }));
|
|
41842
41991
|
if (choice === null) {
|
|
41843
41992
|
printLine2(terminal, "Setup cancelled. Nothing was changed.");
|
|
41844
41993
|
return { hosts: [], dryRun: options.dryRun, mode: "local", detection };
|
|
@@ -41889,13 +42038,14 @@ ${write.content}`);
|
|
|
41889
42038
|
const enrollmentAccess = /* @__PURE__ */ new Map();
|
|
41890
42039
|
try {
|
|
41891
42040
|
for (const host of hosts) {
|
|
41892
|
-
|
|
41893
|
-
|
|
41894
|
-
|
|
42041
|
+
if (plugin.beforeSignIn) {
|
|
42042
|
+
await guard.check({ reuse: true });
|
|
42043
|
+
await guard.step(() => plugin.beforeSignIn?.(host, context));
|
|
42044
|
+
}
|
|
41895
42045
|
if (useVault) {
|
|
41896
42046
|
enrollment.set(host, "unknown");
|
|
41897
42047
|
try {
|
|
41898
|
-
const access = await connectSetupHost(plugin, host, io, terminal,
|
|
42048
|
+
const access = await connectSetupHost(plugin, host, io, terminal, guard);
|
|
41899
42049
|
if (access)
|
|
41900
42050
|
enrollmentAccess.set(host, access);
|
|
41901
42051
|
} catch (error) {
|
|
@@ -41904,19 +42054,26 @@ ${write.content}`);
|
|
|
41904
42054
|
throw error;
|
|
41905
42055
|
}
|
|
41906
42056
|
enrollment.set(host, "enrolled");
|
|
41907
|
-
} else
|
|
41908
|
-
await
|
|
41909
|
-
|
|
42057
|
+
} else {
|
|
42058
|
+
await guard.check({ reuse: true });
|
|
42059
|
+
await guard.step(() => plugin.signInLocal(host, context));
|
|
42060
|
+
}
|
|
41910
42061
|
if (options.enrollOnly)
|
|
41911
42062
|
continue;
|
|
41912
|
-
|
|
41913
|
-
|
|
42063
|
+
if (plugin.beforeRegister) {
|
|
42064
|
+
await guard.check({ reuse: true });
|
|
42065
|
+
await guard.step(() => plugin.beforeRegister?.(host, mode, context));
|
|
42066
|
+
}
|
|
41914
42067
|
if (host === "opencode")
|
|
41915
|
-
await registerOpenCode(writes,
|
|
41916
|
-
else
|
|
41917
|
-
await
|
|
41918
|
-
|
|
41919
|
-
|
|
42068
|
+
await registerOpenCode(writes, guard);
|
|
42069
|
+
else {
|
|
42070
|
+
await guard.check({ reuse: true });
|
|
42071
|
+
await guard.step(() => registerPi(plugin, detection.pi.executable, io));
|
|
42072
|
+
}
|
|
42073
|
+
if (plugin.migrate) {
|
|
42074
|
+
await guard.check({ reuse: true });
|
|
42075
|
+
await guard.step(() => plugin.migrate?.(host, context));
|
|
42076
|
+
}
|
|
41920
42077
|
}
|
|
41921
42078
|
} catch (error) {
|
|
41922
42079
|
if (enrollment.size === 0)
|
|
@@ -43579,7 +43736,7 @@ function isSessionId(value) {
|
|
|
43579
43736
|
// src/common-auth-embedded/rpc/port-file.js
|
|
43580
43737
|
init_private_files2();
|
|
43581
43738
|
import { createHash as createHash15, randomUUID as randomUUID19 } from "node:crypto";
|
|
43582
|
-
import { chmod as chmod7, mkdir as mkdir17, open as open12, readdir as readdir6, rename as
|
|
43739
|
+
import { chmod as chmod7, mkdir as mkdir17, open as open12, readdir as readdir6, rename as rename15, rmdir as rmdir3, stat as stat17, unlink as unlink15 } from "node:fs/promises";
|
|
43583
43740
|
import { uptime as uptime2 } from "node:os";
|
|
43584
43741
|
import { join as join30, resolve as resolve26 } from "node:path";
|
|
43585
43742
|
function staleBefore(clock2) {
|
|
@@ -43661,7 +43818,7 @@ async function writePortFile(dir, entry, options = {}) {
|
|
|
43661
43818
|
await handle.chmod(384);
|
|
43662
43819
|
await handle.close();
|
|
43663
43820
|
handle = void 0;
|
|
43664
|
-
await
|
|
43821
|
+
await rename15(tmp, target);
|
|
43665
43822
|
created = false;
|
|
43666
43823
|
} finally {
|
|
43667
43824
|
await handle?.close().catch(() => {
|
|
@@ -44936,7 +45093,7 @@ import { join as join33, resolve as resolve28 } from "node:path";
|
|
|
44936
45093
|
// ../core/dist/common-auth-embedded/tui-prefs/watcher.js
|
|
44937
45094
|
init_canonical_file_path();
|
|
44938
45095
|
init_private_files();
|
|
44939
|
-
import { lstatSync, readFileSync as readFileSync8, readlinkSync, realpathSync as realpathSync5, statSync as
|
|
45096
|
+
import { lstatSync, readFileSync as readFileSync8, readlinkSync, realpathSync as realpathSync5, statSync as statSync8, watch } from "node:fs";
|
|
44940
45097
|
import { readFile as readFile17, stat as stat18 } from "node:fs/promises";
|
|
44941
45098
|
import { basename as basename10, dirname as dirname24, join as join32, resolve as resolve27 } from "node:path";
|
|
44942
45099
|
import { clearTimeout as clearTimeout2, setTimeout as setTimeout2 } from "node:timers";
|
|
@@ -44980,7 +45137,7 @@ function watchFile(file, onChange, options, settings) {
|
|
|
44980
45137
|
let lastSeen = null;
|
|
44981
45138
|
if (settings || !windowsPrivateFiles)
|
|
44982
45139
|
try {
|
|
44983
|
-
const metadata = identity3((options.fs?.statSync ??
|
|
45140
|
+
const metadata = identity3((options.fs?.statSync ?? statSync8)(path5), settings);
|
|
44984
45141
|
lastSeen = (options.fs?.readFileSync ?? ((file2) => readFileSync8(file2, "utf8")))(path5);
|
|
44985
45142
|
lastMetadata = metadata;
|
|
44986
45143
|
} catch {
|
|
@@ -46324,7 +46481,7 @@ async function moveSettingsOnce(options) {
|
|
|
46324
46481
|
}
|
|
46325
46482
|
|
|
46326
46483
|
// ../core/dist/common-auth-embedded/settings/paths.js
|
|
46327
|
-
import { posix as posix2, win32 as
|
|
46484
|
+
import { posix as posix2, win32 as win324 } from "node:path";
|
|
46328
46485
|
function isAbsoluteForPlatform(path5, platform) {
|
|
46329
46486
|
if (platform !== "win32")
|
|
46330
46487
|
return path5.startsWith("/");
|
|
@@ -46335,7 +46492,7 @@ function isAbsoluteForPlatform(path5, platform) {
|
|
|
46335
46492
|
return /^[\\/]{2}[^\\/]+[\\/][^\\/]+/.test(path5);
|
|
46336
46493
|
}
|
|
46337
46494
|
function cortexkitConfigDir({ env: env3, platform, homedir: homedir17 }) {
|
|
46338
|
-
const paths = platform === "win32" ?
|
|
46495
|
+
const paths = platform === "win32" ? win324 : posix2;
|
|
46339
46496
|
const absolute = (value) => value !== void 0 && isAbsoluteForPlatform(value, platform);
|
|
46340
46497
|
let base;
|
|
46341
46498
|
if (absolute(env3.XDG_CONFIG_HOME)) {
|
|
@@ -46358,7 +46515,7 @@ function settingsFilePath({ plugin, override, ...options }) {
|
|
|
46358
46515
|
if (override && isAbsoluteForPlatform(override, options.platform)) {
|
|
46359
46516
|
return override;
|
|
46360
46517
|
}
|
|
46361
|
-
const paths = options.platform === "win32" ?
|
|
46518
|
+
const paths = options.platform === "win32" ? win324 : posix2;
|
|
46362
46519
|
return paths.join(cortexkitConfigDir(options), `${plugin}.jsonc`);
|
|
46363
46520
|
}
|
|
46364
46521
|
|
|
@@ -47062,9 +47219,9 @@ init_version_fence();
|
|
|
47062
47219
|
|
|
47063
47220
|
// src/settings/location.ts
|
|
47064
47221
|
import { realpath as realpath6 } from "node:fs/promises";
|
|
47065
|
-
import { posix as posix3, win32 as
|
|
47222
|
+
import { posix as posix3, win32 as win325 } from "node:path";
|
|
47066
47223
|
async function folderIdentity(folder, platform) {
|
|
47067
|
-
const paths = platform === "win32" ?
|
|
47224
|
+
const paths = platform === "win32" ? win325 : posix3;
|
|
47068
47225
|
try {
|
|
47069
47226
|
return await realpath6(folder);
|
|
47070
47227
|
} catch {
|
|
@@ -47073,7 +47230,7 @@ async function folderIdentity(folder, platform) {
|
|
|
47073
47230
|
}
|
|
47074
47231
|
async function resolveSettingsLocation(options) {
|
|
47075
47232
|
const { env: env3, platform, homedir: homedir17 } = options;
|
|
47076
|
-
const paths = platform === "win32" ?
|
|
47233
|
+
const paths = platform === "win32" ? win325 : posix3;
|
|
47077
47234
|
const override = env3.OPENCODE_ANTIGRAVITY_AUTH_SETTINGS_FILE;
|
|
47078
47235
|
const file = settingsFilePath({
|
|
47079
47236
|
plugin: "antigravity-auth",
|
|
@@ -47450,12 +47607,12 @@ function createSettingsRuntime(options) {
|
|
|
47450
47607
|
void enqueue(refreshAll);
|
|
47451
47608
|
});
|
|
47452
47609
|
};
|
|
47453
|
-
const scheduleAttempt = (
|
|
47610
|
+
const scheduleAttempt = (delay4) => {
|
|
47454
47611
|
if (disposed) return;
|
|
47455
47612
|
retryTimer = setTimeout(() => {
|
|
47456
47613
|
retryTimer = void 0;
|
|
47457
47614
|
void enqueue(attemptMove);
|
|
47458
|
-
},
|
|
47615
|
+
}, delay4);
|
|
47459
47616
|
retryTimer.unref?.();
|
|
47460
47617
|
};
|
|
47461
47618
|
const attemptMove = async () => {
|
|
@@ -54865,11 +55022,11 @@ function createSyntheticTextResponse(text2, extraHeaders = {}) {
|
|
|
54865
55022
|
});
|
|
54866
55023
|
}
|
|
54867
55024
|
var NATIVE_GOOGLE_ERROR_MESSAGES = {
|
|
54868
|
-
operator_policy: "Antigravity account pool is
|
|
54869
|
-
soft_quota: 'Antigravity account pool is
|
|
55025
|
+
operator_policy: "Antigravity account pool is blocked by the operator quota policy. Adjust the quota floor in /antigravity \u2192 Limits or refresh quota.",
|
|
55026
|
+
soft_quota: 'Antigravity account pool is blocked by quota protection. Add accounts, wait for quota reset, or turn off soft quota protection with `"soft_quota_threshold_percent": 100` in antigravity-auth.jsonc.',
|
|
54870
55027
|
pool_unavailable: "Antigravity account pool has no account available within the configured wait limit. Add accounts with `opencode auth login` or wait for quota reset.",
|
|
54871
55028
|
model_unavailable: "The requested Antigravity model is not available to the configured accounts. Choose another model.",
|
|
54872
|
-
routing_refused: "Routing has no Antigravity account available for this request right now
|
|
55029
|
+
routing_refused: "Routing has no Antigravity account available for this request right now. Wait before sending another request.",
|
|
54873
55030
|
missing_access_token: "Missing access token. Run `opencode auth login` to reauthenticate.",
|
|
54874
55031
|
empty_response: "Antigravity returned an empty response after the internal retry attempts."
|
|
54875
55032
|
};
|
|
@@ -58449,14 +58606,14 @@ var BackgroundVaultQuotaRefresh = class {
|
|
|
58449
58606
|
this.abortTick();
|
|
58450
58607
|
await this.inFlight;
|
|
58451
58608
|
}
|
|
58452
|
-
schedule(
|
|
58609
|
+
schedule(delay4, intervalWait = null) {
|
|
58453
58610
|
if (this.disposed || !this.started) return;
|
|
58454
58611
|
this.intervalWait = intervalWait;
|
|
58455
58612
|
this.timer = setTimeout(() => {
|
|
58456
58613
|
this.timer = null;
|
|
58457
58614
|
this.intervalWait = null;
|
|
58458
58615
|
void this.tick();
|
|
58459
|
-
},
|
|
58616
|
+
}, delay4);
|
|
58460
58617
|
this.timer.unref?.();
|
|
58461
58618
|
}
|
|
58462
58619
|
/** One serialized tick; also used by deterministic composition tests. */
|
|
@@ -59393,6 +59550,7 @@ function routingHandle(sessionId) {
|
|
|
59393
59550
|
var CACHE_WARM_STOP_REASONS = [
|
|
59394
59551
|
"cost-cap",
|
|
59395
59552
|
"count-cap",
|
|
59553
|
+
"deadline-missed",
|
|
59396
59554
|
"outside-hours",
|
|
59397
59555
|
"session-ended",
|
|
59398
59556
|
"unsupported"
|
|
@@ -60807,7 +60965,7 @@ function createRequestExecutor(deps) {
|
|
|
60807
60965
|
error: {
|
|
60808
60966
|
code: 412,
|
|
60809
60967
|
status: "FAILED_PRECONDITION",
|
|
60810
|
-
message: "This Antigravity thinking level is
|
|
60968
|
+
message: "This Antigravity thinking level is not offered. Choose another thinking level."
|
|
60811
60969
|
}
|
|
60812
60970
|
}),
|
|
60813
60971
|
{ status: 412, headers: { "Content-Type": "application/json" } }
|
|
@@ -62532,9 +62690,8 @@ function createRequestExecutor(deps) {
|
|
|
62532
62690
|
const originalError = recoveryError.originalError || {
|
|
62533
62691
|
error: { message: "Thinking recovery triggered" }
|
|
62534
62692
|
};
|
|
62535
|
-
|
|
62536
|
-
|
|
62537
|
-
[RECOVERY] Thinking block corruption could not be resolved. Try starting a new session.`;
|
|
62693
|
+
log18.debug("thinking-recovery-failed", { error: originalError });
|
|
62694
|
+
const recoveryMessage = "Antigravity could not repair the conversation's thinking blocks. Start a new session.";
|
|
62538
62695
|
return new Response(
|
|
62539
62696
|
JSON.stringify({
|
|
62540
62697
|
type: "error",
|