@cortexkit/opencode-antigravity-auth 3.0.17 → 3.0.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +59 -23
- package/dist/cli.js.map +2 -2
- package/dist/cli.meta.json +8 -8
- package/dist/index.js +66 -30
- package/dist/index.js.map +2 -2
- package/dist/index.meta.json +15 -15
- package/dist/server.js +66 -30
- package/dist/server.js.map +2 -2
- package/dist/server.meta.json +1 -1
- package/dist/src/plugin/config/schema.js +4 -4
- package/dist/src/plugin/config/schema.js.map +1 -1
- package/dist/src/plugin/config/writer.d.ts +4 -5
- package/dist/src/plugin/config/writer.d.ts.map +1 -1
- package/dist/src/plugin/config/writer.js +4 -5
- package/dist/src/plugin/config/writer.js.map +1 -1
- package/dist/src/plugin/errors.js +1 -1
- package/dist/src/plugin/request-helpers.js +2 -2
- package/dist/src/plugin/request-helpers.js.map +1 -1
- package/dist/src/process-heartbeat.d.ts +2 -0
- package/dist/src/process-heartbeat.d.ts.map +1 -1
- package/dist/src/process-heartbeat.js +44 -25
- package/dist/src/process-heartbeat.js.map +1 -1
- package/dist/src/runtime-layout.d.ts.map +1 -1
- package/dist/src/runtime-layout.js +8 -1
- package/dist/src/runtime-layout.js.map +1 -1
- package/dist/src/runtime-paths.d.ts.map +1 -1
- package/dist/src/runtime-paths.js +3 -0
- package/dist/src/runtime-paths.js.map +1 -1
- package/dist/types/src/plugin/config/writer.d.ts +4 -5
- package/dist/types/src/plugin/config/writer.d.ts.map +1 -1
- package/dist/types/src/process-heartbeat.d.ts +2 -0
- package/dist/types/src/process-heartbeat.d.ts.map +1 -1
- package/dist/types/src/runtime-layout.d.ts.map +1 -1
- package/dist/types/src/runtime-paths.d.ts.map +1 -1
- package/package.json +2 -2
package/dist/cli.meta.json
CHANGED
|
@@ -2984,7 +2984,7 @@
|
|
|
2984
2984
|
"format": "esm"
|
|
2985
2985
|
},
|
|
2986
2986
|
"src/process-heartbeat.ts": {
|
|
2987
|
-
"bytes":
|
|
2987
|
+
"bytes": 18961,
|
|
2988
2988
|
"imports": [
|
|
2989
2989
|
{
|
|
2990
2990
|
"path": "node:crypto",
|
|
@@ -3046,7 +3046,7 @@
|
|
|
3046
3046
|
"format": "esm"
|
|
3047
3047
|
},
|
|
3048
3048
|
"src/runtime-layout.ts": {
|
|
3049
|
-
"bytes":
|
|
3049
|
+
"bytes": 83839,
|
|
3050
3050
|
"imports": [
|
|
3051
3051
|
{
|
|
3052
3052
|
"path": "node:crypto",
|
|
@@ -3153,7 +3153,7 @@
|
|
|
3153
3153
|
"format": "esm"
|
|
3154
3154
|
},
|
|
3155
3155
|
"src/runtime-paths.ts": {
|
|
3156
|
-
"bytes":
|
|
3156
|
+
"bytes": 17250,
|
|
3157
3157
|
"imports": [
|
|
3158
3158
|
{
|
|
3159
3159
|
"path": "node:crypto",
|
|
@@ -4305,7 +4305,7 @@
|
|
|
4305
4305
|
"imports": [],
|
|
4306
4306
|
"exports": [],
|
|
4307
4307
|
"inputs": {},
|
|
4308
|
-
"bytes":
|
|
4308
|
+
"bytes": 3145986
|
|
4309
4309
|
},
|
|
4310
4310
|
"dist/cli.js": {
|
|
4311
4311
|
"imports": [
|
|
@@ -5460,19 +5460,19 @@
|
|
|
5460
5460
|
"bytesInOutput": 694
|
|
5461
5461
|
},
|
|
5462
5462
|
"src/process-heartbeat.ts": {
|
|
5463
|
-
"bytesInOutput":
|
|
5463
|
+
"bytesInOutput": 8699
|
|
5464
5464
|
},
|
|
5465
5465
|
"src/version-fence.ts": {
|
|
5466
5466
|
"bytesInOutput": 6382
|
|
5467
5467
|
},
|
|
5468
5468
|
"src/runtime-layout.ts": {
|
|
5469
|
-
"bytesInOutput":
|
|
5469
|
+
"bytesInOutput": 46055
|
|
5470
5470
|
},
|
|
5471
5471
|
"src/plugin/storage.ts": {
|
|
5472
5472
|
"bytesInOutput": 11075
|
|
5473
5473
|
},
|
|
5474
5474
|
"src/runtime-paths.ts": {
|
|
5475
|
-
"bytesInOutput":
|
|
5475
|
+
"bytesInOutput": 6278
|
|
5476
5476
|
},
|
|
5477
5477
|
"src/plugin/logging-utils.ts": {
|
|
5478
5478
|
"bytesInOutput": 3617
|
|
@@ -5607,7 +5607,7 @@
|
|
|
5607
5607
|
"bytesInOutput": 1955
|
|
5608
5608
|
}
|
|
5609
5609
|
},
|
|
5610
|
-
"bytes":
|
|
5610
|
+
"bytes": 1179089
|
|
5611
5611
|
}
|
|
5612
5612
|
}
|
|
5613
5613
|
}
|
package/dist/index.js
CHANGED
|
@@ -30494,6 +30494,7 @@ __export(process_heartbeat_exports, {
|
|
|
30494
30494
|
holdCliProcessHeartbeat: () => holdCliProcessHeartbeat,
|
|
30495
30495
|
pluginPackageVersion: () => pluginPackageVersion,
|
|
30496
30496
|
processConfigFolderKey: () => processConfigFolderKey,
|
|
30497
|
+
processHasOlderGeneration: () => processHasOlderGeneration,
|
|
30497
30498
|
processHeartbeatDir: () => processHeartbeatDir,
|
|
30498
30499
|
processHeartbeatPath: () => processHeartbeatPath,
|
|
30499
30500
|
recordProcessAnchor: () => recordProcessAnchor,
|
|
@@ -30522,10 +30523,19 @@ function processConfigFolderKey() {
|
|
|
30522
30523
|
return resolve12(folder);
|
|
30523
30524
|
}
|
|
30524
30525
|
}
|
|
30526
|
+
function processHasOlderGeneration() {
|
|
30527
|
+
return shared.olderGeneration;
|
|
30528
|
+
}
|
|
30525
30529
|
function layoutsRecord() {
|
|
30526
30530
|
return Object.fromEntries(shared.layouts);
|
|
30527
30531
|
}
|
|
30528
30532
|
function storesRecord() {
|
|
30533
|
+
if (shared.olderGeneration)
|
|
30534
|
+
return Object.fromEntries(
|
|
30535
|
+
[.../* @__PURE__ */ new Set([...shared.layouts.keys(), ...shared.stores.keys()])].map(
|
|
30536
|
+
(key) => [key, "config"]
|
|
30537
|
+
)
|
|
30538
|
+
);
|
|
30529
30539
|
return Object.fromEntries(shared.stores);
|
|
30530
30540
|
}
|
|
30531
30541
|
function recordSignature() {
|
|
@@ -30538,6 +30548,7 @@ function holdsLegacyLayout() {
|
|
|
30538
30548
|
}
|
|
30539
30549
|
function holdsFixedOldPaths() {
|
|
30540
30550
|
if (holdsLegacyLayout()) return true;
|
|
30551
|
+
if (shared.olderGeneration) return true;
|
|
30541
30552
|
for (const anchor of shared.stores.values())
|
|
30542
30553
|
if (anchor === "config") return true;
|
|
30543
30554
|
return false;
|
|
@@ -30579,16 +30590,17 @@ function errorText2(error) {
|
|
|
30579
30590
|
return error instanceof Error ? error.message : String(error);
|
|
30580
30591
|
}
|
|
30581
30592
|
async function startProcessHeartbeat(input2) {
|
|
30582
|
-
|
|
30583
|
-
const dir = input2.dir ?? processHeartbeatDir();
|
|
30584
|
-
shared.startedAt ??= (input2.now ?? Date.now)();
|
|
30585
|
-
shared.owners++;
|
|
30586
|
-
for (const [key, layout] of Object.entries(input2.layouts ?? {}))
|
|
30587
|
-
shared.layouts.set(key, layout);
|
|
30588
|
-
for (const [key, anchor] of Object.entries(input2.stores ?? {}))
|
|
30589
|
-
shared.stores.set(key, anchor);
|
|
30593
|
+
let dir;
|
|
30590
30594
|
let path5;
|
|
30591
30595
|
try {
|
|
30596
|
+
const pid = input2.pid ?? process.pid;
|
|
30597
|
+
dir = input2.dir ?? processHeartbeatDir();
|
|
30598
|
+
shared.startedAt ??= (input2.now ?? Date.now)();
|
|
30599
|
+
shared.owners++;
|
|
30600
|
+
for (const [key, layout] of Object.entries(input2.layouts ?? {}))
|
|
30601
|
+
shared.layouts.set(key, layout);
|
|
30602
|
+
for (const [key, anchor] of Object.entries(input2.stores ?? {}))
|
|
30603
|
+
shared.stores.set(key, shared.olderGeneration ? "config" : anchor);
|
|
30592
30604
|
path5 = await writeCurrentRecords(dir, pid, input2.version);
|
|
30593
30605
|
} catch (error) {
|
|
30594
30606
|
input2.logger.warn("process heartbeat not written", {
|
|
@@ -30602,10 +30614,16 @@ async function startProcessHeartbeat(input2) {
|
|
|
30602
30614
|
async release() {
|
|
30603
30615
|
if (released) return;
|
|
30604
30616
|
released = true;
|
|
30605
|
-
|
|
30606
|
-
|
|
30607
|
-
|
|
30608
|
-
|
|
30617
|
+
try {
|
|
30618
|
+
shared.owners = Math.max(0, shared.owners - 1);
|
|
30619
|
+
if (shared.owners > 0) return;
|
|
30620
|
+
if (holdsFixedOldPaths()) return;
|
|
30621
|
+
await removeHeartbeatFile(input2.logger);
|
|
30622
|
+
} catch (error) {
|
|
30623
|
+
input2.logger.warn("process heartbeat not released", {
|
|
30624
|
+
error: errorText2(error)
|
|
30625
|
+
});
|
|
30626
|
+
}
|
|
30609
30627
|
}
|
|
30610
30628
|
};
|
|
30611
30629
|
}
|
|
@@ -30647,7 +30665,7 @@ async function recordProcessLayout(input2) {
|
|
|
30647
30665
|
await writeRecords(markStartedAt(input2));
|
|
30648
30666
|
}
|
|
30649
30667
|
async function recordProcessAnchor(input2) {
|
|
30650
|
-
shared.stores.set(input2.key, input2.anchor);
|
|
30668
|
+
shared.stores.set(input2.key, shared.olderGeneration ? "config" : input2.anchor);
|
|
30651
30669
|
await writeRecords(markStartedAt(input2));
|
|
30652
30670
|
}
|
|
30653
30671
|
function markStartedAt(input2) {
|
|
@@ -30709,7 +30727,7 @@ function __resetProcessHeartbeatForTest() {
|
|
|
30709
30727
|
shared.writtenPath = void 0;
|
|
30710
30728
|
shared.writtenLayouts = void 0;
|
|
30711
30729
|
}
|
|
30712
|
-
var stateKey, globalState, shared, HeartbeatWriteFailure, packageVersion;
|
|
30730
|
+
var stateKey, globalState, olderGeneration, shared, HeartbeatWriteFailure, packageVersion;
|
|
30713
30731
|
var init_process_heartbeat = __esm({
|
|
30714
30732
|
"src/process-heartbeat.ts"() {
|
|
30715
30733
|
"use strict";
|
|
@@ -30717,15 +30735,16 @@ var init_process_heartbeat = __esm({
|
|
|
30717
30735
|
init_runtime_paths();
|
|
30718
30736
|
stateKey = /* @__PURE__ */ Symbol.for("cortexkit.antigravity-auth.process-heartbeat");
|
|
30719
30737
|
globalState = globalThis;
|
|
30720
|
-
|
|
30721
|
-
|
|
30722
|
-
|
|
30723
|
-
|
|
30724
|
-
|
|
30725
|
-
|
|
30726
|
-
|
|
30727
|
-
|
|
30728
|
-
|
|
30738
|
+
olderGeneration = globalState[stateKey] !== void 0 && globalState[stateKey].stores == null;
|
|
30739
|
+
shared = globalState[stateKey] ?? {};
|
|
30740
|
+
shared.owners ??= 0;
|
|
30741
|
+
shared.startedAt ??= void 0;
|
|
30742
|
+
shared.layouts ??= /* @__PURE__ */ new Map();
|
|
30743
|
+
shared.olderGeneration ??= olderGeneration;
|
|
30744
|
+
shared.stores ??= /* @__PURE__ */ new Map();
|
|
30745
|
+
shared.writtenPath ??= void 0;
|
|
30746
|
+
shared.writtenLayouts ??= void 0;
|
|
30747
|
+
shared.exitHookInstalled ??= false;
|
|
30729
30748
|
globalState[stateKey] = shared;
|
|
30730
30749
|
HeartbeatWriteFailure = class extends Error {
|
|
30731
30750
|
constructor(cause) {
|
|
@@ -31239,6 +31258,17 @@ async function settleAccountStore(location, options, log16) {
|
|
|
31239
31258
|
}
|
|
31240
31259
|
async function decideAccountStore(location, options, log16) {
|
|
31241
31260
|
const keepConfig = () => recordAnchor(location, options, "config", log16);
|
|
31261
|
+
if (processHasOlderGeneration()) {
|
|
31262
|
+
logOnce(
|
|
31263
|
+
"older-generation-account-store",
|
|
31264
|
+
() => showLog(
|
|
31265
|
+
log16,
|
|
31266
|
+
"antigravity-auth keeps the account store in OpenCode's config folder until OpenCode restarts, because an older version of the plugin ran in this process.",
|
|
31267
|
+
{ accountStore: "config" }
|
|
31268
|
+
)
|
|
31269
|
+
);
|
|
31270
|
+
return keepConfig();
|
|
31271
|
+
}
|
|
31242
31272
|
const configAnchor = legacyAccountFile(location.configDir);
|
|
31243
31273
|
const stateAnchor = stateHomeAccountFile(location);
|
|
31244
31274
|
const forward = readForwardedAccountStore(configAnchor);
|
|
@@ -32183,6 +32213,9 @@ var init_runtime_layout = __esm({
|
|
|
32183
32213
|
storeRuns: /* @__PURE__ */ new Map(),
|
|
32184
32214
|
logged: /* @__PURE__ */ new Set()
|
|
32185
32215
|
};
|
|
32216
|
+
processState.runs ??= /* @__PURE__ */ new Map();
|
|
32217
|
+
processState.storeRuns ??= /* @__PURE__ */ new Map();
|
|
32218
|
+
processState.logged ??= /* @__PURE__ */ new Set();
|
|
32186
32219
|
globalState2[stateKey2] = processState;
|
|
32187
32220
|
LayoutMoveError = class extends Error {
|
|
32188
32221
|
constructor(code2, message) {
|
|
@@ -32716,6 +32749,9 @@ var init_runtime_paths = __esm({
|
|
|
32716
32749
|
locations: /* @__PURE__ */ new Map(),
|
|
32717
32750
|
storeAnchors: /* @__PURE__ */ new Map()
|
|
32718
32751
|
};
|
|
32752
|
+
shared2.decisions ??= /* @__PURE__ */ new Map();
|
|
32753
|
+
shared2.locations ??= /* @__PURE__ */ new Map();
|
|
32754
|
+
shared2.storeAnchors ??= /* @__PURE__ */ new Map();
|
|
32719
32755
|
decisionState[decisionsKey] = shared2;
|
|
32720
32756
|
SIGNATURE_CACHE_FILE_NAME = "antigravity-signature-cache.json";
|
|
32721
32757
|
}
|
|
@@ -45474,12 +45510,12 @@ var AntigravityConfigSchema = z.object({
|
|
|
45474
45510
|
* When an account's quota usage reaches this percentage, skip it during
|
|
45475
45511
|
* account selection (same as if it were rate-limited).
|
|
45476
45512
|
*
|
|
45513
|
+
* Disabled by default (100). Set a lower threshold to opt in to a reserve.
|
|
45477
45514
|
* Example: 80 means skip account when 80% of quota is used (20% remaining).
|
|
45478
|
-
* Set to 100 to disable soft quota protection.
|
|
45479
45515
|
*
|
|
45480
|
-
* @default
|
|
45516
|
+
* @default 100
|
|
45481
45517
|
*/
|
|
45482
|
-
soft_quota_threshold_percent: z.number().min(1).max(100).default(
|
|
45518
|
+
soft_quota_threshold_percent: z.number().min(1).max(100).default(100),
|
|
45483
45519
|
/**
|
|
45484
45520
|
* How often to refresh quota data in the background (in minutes).
|
|
45485
45521
|
* Quota is refreshed opportunistically after successful API requests.
|
|
@@ -45608,7 +45644,7 @@ var DEFAULT_CONFIG = {
|
|
|
45608
45644
|
max_backoff_seconds: 60,
|
|
45609
45645
|
request_jitter_max_ms: 0,
|
|
45610
45646
|
switch_account_delay_ms: 500,
|
|
45611
|
-
soft_quota_threshold_percent:
|
|
45647
|
+
soft_quota_threshold_percent: 100,
|
|
45612
45648
|
quota_refresh_interval_minutes: 30,
|
|
45613
45649
|
soft_quota_cache_ttl_minutes: "auto",
|
|
45614
45650
|
proactive_rotation_threshold_percent: 20,
|
|
@@ -48642,8 +48678,8 @@ function createSyntheticTextResponse(text2, extraHeaders = {}) {
|
|
|
48642
48678
|
});
|
|
48643
48679
|
}
|
|
48644
48680
|
var NATIVE_GOOGLE_ERROR_MESSAGES = {
|
|
48645
|
-
operator_policy: "Antigravity account pool is unavailable under the operator quota policy. Adjust /antigravity
|
|
48646
|
-
soft_quota:
|
|
48681
|
+
operator_policy: "Antigravity account pool is unavailable under the operator quota policy. Adjust the quota floor in /antigravity \u2192 Limits or refresh quota.",
|
|
48682
|
+
soft_quota: 'Antigravity account pool is unavailable under the quota protection policy. Add accounts, wait for quota reset, or turn off soft quota protection with `"soft_quota_threshold_percent": 100` in antigravity.json.',
|
|
48647
48683
|
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.",
|
|
48648
48684
|
model_unavailable: "The requested Antigravity model is not available to the configured accounts. Choose another model.",
|
|
48649
48685
|
missing_access_token: "Missing access token. Run `opencode auth login` to reauthenticate.",
|
|
@@ -52751,7 +52787,7 @@ var AntigravityKillswitchError = class extends Error {
|
|
|
52751
52787
|
summaries;
|
|
52752
52788
|
constructor(input2) {
|
|
52753
52789
|
super(
|
|
52754
|
-
input2.message ?? `Antigravity killswitch: all ${input2.summaries.length} account(s) under ${input2.thresholdPercent}% quota for ${input2.family}. Refresh quota or
|
|
52790
|
+
input2.message ?? `Antigravity killswitch: all ${input2.summaries.length} account(s) under ${input2.thresholdPercent}% quota for ${input2.family}. Refresh quota or adjust the quota floor in /antigravity \u2192 Limits.`
|
|
52755
52791
|
);
|
|
52756
52792
|
this.name = "AntigravityKillswitchError";
|
|
52757
52793
|
this.family = input2.family;
|