@cortexkit/opencode-antigravity-auth 3.0.18 → 3.0.20
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 -1
- package/dist/cli.js +202 -118
- package/dist/cli.js.map +3 -3
- package/dist/cli.meta.json +18 -18
- package/dist/index.js +263 -179
- package/dist/index.js.map +3 -3
- package/dist/index.meta.json +25 -25
- package/dist/server.js +276 -192
- package/dist/server.js.map +3 -3
- package/dist/server.meta.json +1 -1
- package/dist/src/common-auth-embedded/claustrum/consumer.d.ts +10 -0
- package/dist/src/common-auth-embedded/claustrum/consumer.js +25 -0
- package/dist/src/common-auth-embedded/claustrum/custody.d.ts +6 -2
- package/dist/src/common-auth-embedded/claustrum/custody.js +20 -6
- package/dist/src/common-auth-embedded/claustrum/hub.d.ts +3 -1
- package/dist/src/common-auth-embedded/claustrum/hub.js +55 -5
- package/dist/src/common-auth-embedded/claustrum/roster.js +1 -1
- package/dist/src/common-auth-embedded/fs/refresh-file-lock.d.ts +2 -1
- package/dist/src/common-auth-embedded/fs/refresh-file-lock.js +3 -1
- package/dist/src/common-auth-embedded/fs/with-lock.js +1 -1
- package/dist/src/common-auth-embedded/opencode2/index.d.ts +1 -1
- package/dist/src/common-auth-embedded/opencode2/install.d.ts +4 -3
- package/dist/src/common-auth-embedded/opencode2/install.js +144 -17
- package/dist/src/common-auth-embedded/opencode2/types.d.ts +52 -1
- package/dist/src/common-auth-embedded/source-output.json +48 -48
- package/dist/src/ga/tui/host-ga.d.ts.map +1 -1
- package/dist/src/ga/tui/host-ga.js +0 -1
- package/dist/src/ga/tui/host-ga.js.map +1 -1
- package/dist/src/plugin/__fixtures__/verified-store.js +2 -2
- 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/server.d.ts +4 -4
- package/dist/src/server.js +4 -4
- package/dist/src/tui/sidebar-frame.d.ts +3 -4
- package/dist/src/tui/sidebar-frame.d.ts.map +1 -1
- package/dist/src/tui/sidebar-frame.js +4 -8
- package/dist/src/tui/sidebar-frame.js.map +1 -1
- package/dist/src/tui.js +1 -1
- package/dist/tui-build-map.json +9 -9
- package/dist/tui-ga-build-map.json +9 -9
- package/dist/types/src/common-auth-embedded/claustrum/consumer.d.ts +10 -0
- package/dist/types/src/common-auth-embedded/claustrum/custody.d.ts +6 -2
- package/dist/types/src/common-auth-embedded/claustrum/hub.d.ts +3 -1
- package/dist/types/src/common-auth-embedded/fs/refresh-file-lock.d.ts +2 -1
- package/dist/types/src/common-auth-embedded/opencode2/index.d.ts +1 -1
- package/dist/types/src/common-auth-embedded/opencode2/install.d.ts +4 -3
- package/dist/types/src/common-auth-embedded/opencode2/types.d.ts +52 -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/server.d.ts +4 -4
- package/package.json +3 -3
- package/src/common-auth-embedded/claustrum/consumer.d.ts +10 -0
- package/src/common-auth-embedded/claustrum/consumer.js +25 -0
- package/src/common-auth-embedded/claustrum/custody.d.ts +6 -2
- package/src/common-auth-embedded/claustrum/custody.js +20 -6
- package/src/common-auth-embedded/claustrum/hub.d.ts +3 -1
- package/src/common-auth-embedded/claustrum/hub.js +55 -5
- package/src/common-auth-embedded/claustrum/roster.js +1 -1
- package/src/common-auth-embedded/fs/refresh-file-lock.d.ts +2 -1
- package/src/common-auth-embedded/fs/refresh-file-lock.js +3 -1
- package/src/common-auth-embedded/fs/with-lock.js +1 -1
- package/src/common-auth-embedded/opencode2/index.d.ts +1 -1
- package/src/common-auth-embedded/opencode2/install.d.ts +4 -3
- package/src/common-auth-embedded/opencode2/install.js +144 -17
- package/src/common-auth-embedded/opencode2/types.d.ts +52 -1
- package/src/common-auth-embedded/source-output.json +48 -48
- package/src/tui-compiled/tui/sidebar-frame.js +35 -72
- package/src/tui-compiled/tui.js +1 -1
- package/src/tui-ga-compiled/host-ga.js +0 -1
- package/src/tui-ga-compiled/shared/ced204104a639c9c-sidebar-frame.js +35 -72
- package/src/tui-ga-raw/host-ga.tsx +0 -1
- package/src/tui-ga-raw/shared/ced204104a639c9c-sidebar-frame.tsx +7 -29
- package/src/tui-raw/tui/sidebar-frame.tsx +7 -29
- package/src/tui-raw/tui.tsx +1 -1
- package/src/tui.tsx +1 -1
package/dist/tui-build-map.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"schema": 1,
|
|
3
|
-
"compiler": "@cortexkit/common-auth/tui-build@0.
|
|
3
|
+
"compiler": "@cortexkit/common-auth/tui-build@0.31.0",
|
|
4
4
|
"bun": "1.4.2",
|
|
5
5
|
"raw": {
|
|
6
6
|
"selector": "selector.js",
|
|
@@ -201,8 +201,8 @@
|
|
|
201
201
|
{
|
|
202
202
|
"source": "src/tui/sidebar-frame.tsx",
|
|
203
203
|
"output": "src/tui-raw/tui/sidebar-frame.tsx",
|
|
204
|
-
"bytes":
|
|
205
|
-
"sha256": "
|
|
204
|
+
"bytes": 19220,
|
|
205
|
+
"sha256": "1985fc737a027f45564f8801a5e53f93dbf58b07da3471f5bfe147fe7be27633",
|
|
206
206
|
"transform": "public-raw"
|
|
207
207
|
},
|
|
208
208
|
{
|
|
@@ -215,8 +215,8 @@
|
|
|
215
215
|
{
|
|
216
216
|
"source": "src/tui.tsx",
|
|
217
217
|
"output": "src/tui-raw/tui.tsx",
|
|
218
|
-
"bytes":
|
|
219
|
-
"sha256": "
|
|
218
|
+
"bytes": 20201,
|
|
219
|
+
"sha256": "7dd981a905835e552c40d3a47ed1afee0c936c847851285a77d9ed5efb1d237f",
|
|
220
220
|
"transform": "public-raw"
|
|
221
221
|
},
|
|
222
222
|
{
|
|
@@ -423,8 +423,8 @@
|
|
|
423
423
|
{
|
|
424
424
|
"source": "src/tui/sidebar-frame.tsx",
|
|
425
425
|
"output": "src/tui-compiled/tui/sidebar-frame.js",
|
|
426
|
-
"bytes":
|
|
427
|
-
"sha256": "
|
|
426
|
+
"bytes": 22855,
|
|
427
|
+
"sha256": "7227c7699f23fb772c7028760831131b3971445604baa71549b672a007ee40c0",
|
|
428
428
|
"transform": "public-solid-runtime"
|
|
429
429
|
},
|
|
430
430
|
{
|
|
@@ -437,8 +437,8 @@
|
|
|
437
437
|
{
|
|
438
438
|
"source": "src/tui.tsx",
|
|
439
439
|
"output": "src/tui-compiled/tui.js",
|
|
440
|
-
"bytes":
|
|
441
|
-
"sha256": "
|
|
440
|
+
"bytes": 17670,
|
|
441
|
+
"sha256": "20784aac4009207a0b9667c9fa1f96ff3b3fadcf91806c5165410cea7330c1e8",
|
|
442
442
|
"transform": "public-solid-runtime"
|
|
443
443
|
},
|
|
444
444
|
{
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"schema": 1,
|
|
3
|
-
"compiler": "@cortexkit/common-auth/tui-build@0.
|
|
3
|
+
"compiler": "@cortexkit/common-auth/tui-build@0.31.0",
|
|
4
4
|
"bun": "1.4.2",
|
|
5
5
|
"raw": {
|
|
6
6
|
"selector": "selector.js",
|
|
@@ -96,15 +96,15 @@
|
|
|
96
96
|
{
|
|
97
97
|
"source": "src/tui/sidebar-frame.tsx",
|
|
98
98
|
"output": "src/tui-ga-raw/shared/ced204104a639c9c-sidebar-frame.tsx",
|
|
99
|
-
"bytes":
|
|
100
|
-
"sha256": "
|
|
99
|
+
"bytes": 19259,
|
|
100
|
+
"sha256": "303b30775d1f55fd60faf997aedfa275475d8e4c881f1b075d74a434b5cb90b0",
|
|
101
101
|
"transform": "public-raw"
|
|
102
102
|
},
|
|
103
103
|
{
|
|
104
104
|
"source": "src/ga/tui/host-ga.tsx",
|
|
105
105
|
"output": "src/tui-ga-raw/host-ga.tsx",
|
|
106
|
-
"bytes":
|
|
107
|
-
"sha256": "
|
|
106
|
+
"bytes": 59250,
|
|
107
|
+
"sha256": "00bce0f9f657eb1542c3525ba17e31867b6beac8f4046d0c8f078c490309340c",
|
|
108
108
|
"transform": "public-raw"
|
|
109
109
|
},
|
|
110
110
|
{
|
|
@@ -207,15 +207,15 @@
|
|
|
207
207
|
{
|
|
208
208
|
"source": "src/tui/sidebar-frame.tsx",
|
|
209
209
|
"output": "src/tui-ga-compiled/shared/ced204104a639c9c-sidebar-frame.js",
|
|
210
|
-
"bytes":
|
|
211
|
-
"sha256": "
|
|
210
|
+
"bytes": 22894,
|
|
211
|
+
"sha256": "0ebb6b1430c70e20875ba82c373e1140b964a16cf5e83e2a8021a47ee291e45d",
|
|
212
212
|
"transform": "public-solid-runtime"
|
|
213
213
|
},
|
|
214
214
|
{
|
|
215
215
|
"source": "src/ga/tui/host-ga.tsx",
|
|
216
216
|
"output": "src/tui-ga-compiled/host-ga.js",
|
|
217
|
-
"bytes":
|
|
218
|
-
"sha256": "
|
|
217
|
+
"bytes": 47473,
|
|
218
|
+
"sha256": "14721296a80c41444ef9b3746cc13b2fb908a0711afb94ce5bff1ca07caf6cf5",
|
|
219
219
|
"transform": "public-solid-runtime"
|
|
220
220
|
},
|
|
221
221
|
{
|
|
@@ -50,6 +50,12 @@ export interface ClaustrumConsumerOptions<Q = QuotaObservation> {
|
|
|
50
50
|
* routine token refresh, which never moves the view.
|
|
51
51
|
*/
|
|
52
52
|
onRoster?: (roster: VaultRosterFile) => void;
|
|
53
|
+
/**
|
|
54
|
+
* Called once when a coalesced discovery starts, with its completion promise.
|
|
55
|
+
* Covers explicit refresh, poll, watch and send-triggered discovery, even when
|
|
56
|
+
* the view does not change. Observe rejection when attaching async work.
|
|
57
|
+
*/
|
|
58
|
+
onDiscovery?: (promise: Promise<VaultRosterFile | undefined>) => void;
|
|
53
59
|
onError?: (error: unknown) => void;
|
|
54
60
|
/**
|
|
55
61
|
* How often `start()` ticks. A tick lists the vault when no vault watch is
|
|
@@ -104,6 +110,8 @@ export interface HubMemberPort {
|
|
|
104
110
|
keptReceiptState(): KeptReceiptState;
|
|
105
111
|
/** Apply the union of every member's roster in memory to kept receipts. */
|
|
106
112
|
retainUnion(): void;
|
|
113
|
+
/** Share a committed preference change with live members using this roster file. */
|
|
114
|
+
publishRoster(roster: VaultRosterFile): void;
|
|
107
115
|
forget(credentialId: string): void;
|
|
108
116
|
/** The member closed: the hub stops committing and pushing to it. */
|
|
109
117
|
detach(): void;
|
|
@@ -113,6 +121,8 @@ export interface HubRefreshOutcome {
|
|
|
113
121
|
}
|
|
114
122
|
/** What the hub may do to one member's memory. Package-internal. */
|
|
115
123
|
export interface HubMemberHooks {
|
|
124
|
+
/** Observe a hub discovery without relying on member refresh overrides. */
|
|
125
|
+
discovery(promise: Promise<HubRefreshOutcome | undefined>): void;
|
|
116
126
|
/**
|
|
117
127
|
* Set the roster in memory as a consumer's own refresh does (pending quota
|
|
118
128
|
* readings included) and notify `onRoster` when its view changed.
|
|
@@ -25,7 +25,8 @@ export interface ClaustrumFamily {
|
|
|
25
25
|
/** Non-secret classification facts, including rows decoded by older clients. */
|
|
26
26
|
export interface VaultRowFacts {
|
|
27
27
|
readonly credentialId: string;
|
|
28
|
-
|
|
28
|
+
/** Internal serving type derived from `authMethod`, not the id's type hint. */
|
|
29
|
+
readonly credentialType: VaultCredentialType;
|
|
29
30
|
readonly authMethod?: string;
|
|
30
31
|
readonly refreshAdapter?: string;
|
|
31
32
|
readonly providerIds?: readonly string[];
|
|
@@ -108,7 +109,10 @@ export interface VaultInventory {
|
|
|
108
109
|
readonly view: string;
|
|
109
110
|
readonly credentials: readonly VaultCredential[];
|
|
110
111
|
readonly skipped: readonly SkippedVaultRecord[];
|
|
111
|
-
/**
|
|
112
|
+
/**
|
|
113
|
+
* Classifying families only: declared policy codes or the fixed library codes
|
|
114
|
+
* `unknown-auth-method`, `unmapped` and `unclassified`, never classifier errors.
|
|
115
|
+
*/
|
|
112
116
|
readonly refused?: readonly {
|
|
113
117
|
credentialId?: string;
|
|
114
118
|
code: string;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { QuotaObservation } from '../quota/index.js';
|
|
2
|
-
import { type ClaustrumConsumer } from './consumer.js';
|
|
2
|
+
import { type ClaustrumConsumer, type ClaustrumConsumerOptions } from './consumer.js';
|
|
3
3
|
import { type ClassifyingClaustrumFamily, type ClaustrumScopedClient, ClaustrumScopedCustody, type IdentityParser, type KeptReceiptState, type VaultGrantReach } from './custody.js';
|
|
4
4
|
import { type ClaustrumLogger } from './errors.js';
|
|
5
5
|
import { type AccountMapper, type VaultRosterFile } from './roster.js';
|
|
@@ -100,6 +100,8 @@ export interface ClaustrumHubMemberOptions<_Q = QuotaObservation> {
|
|
|
100
100
|
reservedRouteIds?: () => Iterable<string>;
|
|
101
101
|
/** As `ClaustrumConsumerOptions.onRoster`: once per change of view. */
|
|
102
102
|
onRoster?: (roster: VaultRosterFile) => void;
|
|
103
|
+
/** Observe every hub discovery's member result, including background work. */
|
|
104
|
+
onDiscovery?: ClaustrumConsumerOptions<_Q>['onDiscovery'];
|
|
103
105
|
/** This member's own failures, such as a roster commit that failed. */
|
|
104
106
|
onError?: (error: unknown) => void;
|
|
105
107
|
logger?: ClaustrumLogger;
|
|
@@ -21,7 +21,8 @@ export interface LockLoss {
|
|
|
21
21
|
export interface RefreshFileLock {
|
|
22
22
|
readonly ownerId: string;
|
|
23
23
|
assertOwned(): Promise<void>;
|
|
24
|
-
release
|
|
24
|
+
/** Abort stops release retries; the unrenewed lease is left to expire by TTL. */
|
|
25
|
+
release(signal?: AbortSignal): Promise<void>;
|
|
25
26
|
/** Resolves once on detected loss; remains pending after an owner's release. */
|
|
26
27
|
whenLost(): Promise<LockLoss>;
|
|
27
28
|
hasLost(): boolean;
|
|
@@ -5,4 +5,4 @@ export type { FormAnswer, LoginContext, PoolAuthorization, PoolLoginMethod, Regi
|
|
|
5
5
|
export { isPlaceholderCredential, PLACEHOLDER_LIFETIME_MS, PLACEHOLDER_METADATA_KEY, PLACEHOLDER_PREFIX, placeholderCredential, placeholderSecret, registerOpenCode2AuthMethods, VAULT_ACTIVATION_INSTRUCTIONS, } from './integration.js';
|
|
6
6
|
export type { ServerSentEvent } from './sse.js';
|
|
7
7
|
export { watchServerSentEvents } from './sse.js';
|
|
8
|
-
export type { AccountHeadersResult, AccountRequest, Attempt, AttemptEndReason, AttemptOutcome, ChooseAccountInput, ChooseAccountResult, EventVerdict, HeaderEdits, HostError, InstallOpenCode2AuthOptions, LimitSignal, OpenCode2AuthAdapter, OpenCode2AuthEventName, OpenCode2AuthEvents, OpenCode2AuthInstallation, OpenCode2AuthLogger, OpenCode2HookContext, RequestKind, RequestScope, ResponseAccount, RetryHold, RetryReason, SelectingHook, Transport, } from './types.js';
|
|
8
|
+
export type { AccountHeadersResult, AccountRequest, Attempt, AttemptEndReason, AttemptOutcome, ChooseAccountInput, ChooseAccountResult, EventVerdict, HeaderEdits, HostError, InstallOpenCode2AuthOptions, LimitSignal, OpenCode2AuthAdapter, OpenCode2AuthEventName, OpenCode2AuthEvents, OpenCode2AuthInstallation, OpenCode2AuthLogger, OpenCode2HookContext, RequestKind, RequestScope, ResponseAccount, RetryHold, RetryReason, SameAccountRetryInput, SameAccountRetryResult, SelectingHook, Transport, } from './types.js';
|
|
@@ -51,8 +51,9 @@ export declare function applyHeaderEdits(target: Record<string, string>, edits:
|
|
|
51
51
|
* compares the host-prepared secret exactly, then selects a fresh attempt only
|
|
52
52
|
* for an owned send. Request-object attribution therefore needs no attempt
|
|
53
53
|
* header. Frames are owned by the latest handshake of their session and kind;
|
|
54
|
-
* retry runs only when the session's latest transport was owned
|
|
55
|
-
* has
|
|
56
|
-
*
|
|
54
|
+
* retry runs only when the session's latest transport was owned. The host's
|
|
55
|
+
* retry hook has no request identity, so a session that has mixed owned and
|
|
56
|
+
* foreign transports leaves failover and holds to the host. Identity-preserving
|
|
57
|
+
* retries through `retrySameAccount` do not select an account and remain allowed.
|
|
57
58
|
*/
|
|
58
59
|
export declare function installOpenCode2Auth<Q, A = unknown>(ctx: OpenCode2HookContext, adapter: OpenCode2AuthAdapter<Q, A, ChooseAccountResult>, options?: InstallOpenCode2AuthOptions): Promise<OpenCode2AuthInstallation<Q, A>>;
|
|
@@ -173,6 +173,22 @@ export interface HostError {
|
|
|
173
173
|
readonly message: string;
|
|
174
174
|
readonly status?: number;
|
|
175
175
|
}
|
|
176
|
+
/** The known route and host error for an identity-preserving retry. */
|
|
177
|
+
export interface SameAccountRetryInput extends AccountRequest {
|
|
178
|
+
readonly error: HostError;
|
|
179
|
+
/** The host's retry attempt count. */
|
|
180
|
+
readonly attempt: number;
|
|
181
|
+
/**
|
|
182
|
+
* The signal already recorded by a response/frame trigger, if any. Its reason
|
|
183
|
+
* can key prepared credentials, so recovery need not refresh them twice.
|
|
184
|
+
* limitFromError is not called before this callback in a mixed session.
|
|
185
|
+
*/
|
|
186
|
+
readonly limit?: LimitSignal;
|
|
187
|
+
}
|
|
188
|
+
/** Request an immediate retry; a different account ID is ignored. */
|
|
189
|
+
export interface SameAccountRetryResult {
|
|
190
|
+
readonly accountId: string;
|
|
191
|
+
}
|
|
176
192
|
/**
|
|
177
193
|
* Everything provider-specific the installer needs. `Q` is the plugin's own
|
|
178
194
|
* quota reading type; the installer only carries it to the `quota` event.
|
|
@@ -345,6 +361,39 @@ export interface OpenCode2AuthAdapter<Q = unknown, A = unknown, Choice extends C
|
|
|
345
361
|
* the retry hook judged.
|
|
346
362
|
*/
|
|
347
363
|
limitFromError?(error: HostError, attempt: Attempt<A>): LimitSignal | undefined;
|
|
364
|
+
/**
|
|
365
|
+
* Optional recovery on the same route before account failover is considered.
|
|
366
|
+
* May only use a newer record version of the same credentialId and accountIdentity,
|
|
367
|
+
* a different local access token for the same subject, or another path to the
|
|
368
|
+
* same provider with the same credential. The adapter must
|
|
369
|
+
* preserve those identities; opaque credential material is not inspected here.
|
|
370
|
+
* Return {accountId: input.accountId} to retry immediately, or undefined to decline.
|
|
371
|
+
* A different accountId is ignored. Never move a routing pin or select another
|
|
372
|
+
* account here: use chooseAccount for failover and holds.
|
|
373
|
+
*
|
|
374
|
+
* Runs only for an attributable attempt before output, and, when gated, only
|
|
375
|
+
* while the latest transport is owned. Unlike failover and holds, it also runs
|
|
376
|
+
* in mixed-ownership sessions. The next matching owned request skips selection
|
|
377
|
+
* and calls accountHeaders again for this account, so newer credentials or a
|
|
378
|
+
* changed transport path can take effect without changing accounts. Runs at
|
|
379
|
+
* most once per attempt, never on the attempt sent by this recovery, so retries
|
|
380
|
+
* cannot chain. Use input.limit to consume state prepared by a response/frame
|
|
381
|
+
* trigger; without one, the callback may handle input.error itself. Do not
|
|
382
|
+
* refresh again when the trigger has already prepared the new credential.
|
|
383
|
+
* No choice was committed through chooseAccount; unused recovery state is
|
|
384
|
+
* released through dropSameAccountRetry instead of dropChoice.
|
|
385
|
+
* Errors are logged and treated as declining the retry.
|
|
386
|
+
*/
|
|
387
|
+
retrySameAccount?(input: SameAccountRetryInput): Promise<SameAccountRetryResult | undefined> | SameAccountRetryResult | undefined;
|
|
388
|
+
/**
|
|
389
|
+
* Releases a returned same-account recovery that will not be sent: a rejected
|
|
390
|
+
* account ID, selection revocation, changed model/agent, cancellation (session
|
|
391
|
+
* idle), forgetting/deletion, disposal or eviction. Receives the original
|
|
392
|
+
* callback input and returned accountId, once, never for a consumed recovery.
|
|
393
|
+
* Awaited before later selection for the session; errors are logged and swallowed.
|
|
394
|
+
* A callback that declines or throws must clean up its own uncommitted state.
|
|
395
|
+
*/
|
|
396
|
+
dropSameAccountRetry?(input: SameAccountRetryInput & SameAccountRetryResult): Promise<void> | void;
|
|
348
397
|
/**
|
|
349
398
|
* Called once per attempt when it ends: an HTTP response body finished,
|
|
350
399
|
* errored or was cancelled; an HTTP response with an error status or no
|
|
@@ -400,11 +449,13 @@ export interface InstallOpenCode2AuthOptions {
|
|
|
400
449
|
* (its wait, or its refusal to retry) stands and the next attempt may go
|
|
401
450
|
* to the refused account again;
|
|
402
451
|
* - `hold`: an explicit adapter wait on the refused account, before output;
|
|
452
|
+
* - `same-account`: the adapter requested immediate recovery on the same route,
|
|
453
|
+
* without account selection, before output;
|
|
403
454
|
* - `host-decides`: no limit was recognised, or the failing call cannot be
|
|
404
455
|
* attributed safely (ambiguous attempts or mixed ownership in a gated
|
|
405
456
|
* session), so the host's decision stands.
|
|
406
457
|
*/
|
|
407
|
-
export type RetryReason = 'reroute' | 'hold' | 'output-started' | 'no-account' | 'host-decides-last-account' | 'host-decides';
|
|
458
|
+
export type RetryReason = 'reroute' | 'hold' | 'same-account' | 'output-started' | 'no-account' | 'host-decides-last-account' | 'host-decides';
|
|
408
459
|
/**
|
|
409
460
|
* The hook that picked an account. Normally `model.request`; a transport hook
|
|
410
461
|
* picks only when the host skipped `model.request` for that request, which a
|
|
@@ -1,17 +1,16 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Lock-held config writer for operator-controlled settings.
|
|
3
3
|
*
|
|
4
|
-
* The /antigravity
|
|
5
|
-
*
|
|
6
|
-
* slash commands all mutate a small slice of the persisted
|
|
4
|
+
* The /antigravity menu persists operator settings, including the
|
|
5
|
+
* quota floor configured in its Limits section, in a small slice of
|
|
7
6
|
* `antigravity.json`. This writer:
|
|
8
7
|
*
|
|
9
8
|
* 1. Selects the existing project config (if present) — never the
|
|
10
9
|
* user one — so a multi-workspace OpenCode install gets per-project
|
|
11
10
|
* overrides. When no project config exists, the user config is the
|
|
12
11
|
* fallback.
|
|
13
|
-
* 2. Holds the same fenced file lock
|
|
14
|
-
*
|
|
12
|
+
* 2. Holds the same fenced file lock used for the account pool
|
|
13
|
+
* so two menu actions fired in quick succession
|
|
15
14
|
* cannot race.
|
|
16
15
|
* 3. Serializes through `writeJsonAtomic` — staged tmp + rename —
|
|
17
16
|
* so a crash mid-write leaves the previous file intact.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"writer.d.ts","sourceRoot":"","sources":["../../../../../src/plugin/config/writer.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"writer.d.ts","sourceRoot":"","sources":["../../../../../src/plugin/config/writer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAUH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAA;AAGlE,YAAY,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAA;AAElE,MAAM,WAAW,0BAA0B;IACzC,iBAAiB,EAAE,MAAM,CAAA;IACzB,cAAc,EAAE,MAAM,CAAA;IACtB,QAAQ,EAAE,gBAAgB,CAAA;CAC3B;AAED,wBAAsB,mBAAmB,CACvC,OAAO,EAAE,0BAA0B,GAClC,OAAO,CAAC,IAAI,CAAC,CAKf;AAED;;;;;GAKG;AACH,wBAAsB,qBAAqB,CACzC,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,gBAAgB,GACzB,OAAO,CAAC,IAAI,CAAC,CAsBf"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* The package's `./server` entry, loaded by both OpenCode host lines.
|
|
3
3
|
*
|
|
4
|
-
* - OpenCode 1 (1.
|
|
5
|
-
* over `main`.
|
|
6
|
-
* because the object has a `server` function, runs that
|
|
7
|
-
* plugin. It does not go on to call the named exports, so
|
|
4
|
+
* - Supported OpenCode 1 hosts (1.18.4 and later 1.x) prefer a package's
|
|
5
|
+
* `./server` export over `main`. Their loader reads the default export as a
|
|
6
|
+
* plugin object and, because the object has a `server` function, runs that
|
|
7
|
+
* function as the plugin. It does not go on to call the named exports, so
|
|
8
8
|
* `createGaAntigravityPlugin` below is never loaded as a second plugin.
|
|
9
9
|
* - OpenCode 2 (2.0.22 and later) resolves `./server` through its host
|
|
10
10
|
* resolver and accepts a default export with a string `id` and a `setup`
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cortexkit/opencode-antigravity-auth",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.20",
|
|
4
4
|
"description": "Google Antigravity OAuth auth plugin for OpenCode - access Gemini and Claude models using Google credentials",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
],
|
|
29
29
|
"engines": {
|
|
30
30
|
"node": ">=20.0.0",
|
|
31
|
-
"opencode": ">=1.
|
|
31
|
+
"opencode": ">=1.18.4 <2 || >=2.0.22"
|
|
32
32
|
},
|
|
33
33
|
"exports": {
|
|
34
34
|
".": {
|
|
@@ -130,7 +130,7 @@
|
|
|
130
130
|
"dependencies": {
|
|
131
131
|
"@cortexkit/claustrum-client": "0.12.0",
|
|
132
132
|
"@cortexkit/subc-client": "0.22.5",
|
|
133
|
-
"@cortexkit/antigravity-auth-core": "3.0.
|
|
133
|
+
"@cortexkit/antigravity-auth-core": "3.0.20",
|
|
134
134
|
"@cortexkit/private-files": "0.2.2",
|
|
135
135
|
"jsonc-parser": "^3.3.1",
|
|
136
136
|
"xdg-basedir": "^5.1.0",
|
|
@@ -50,6 +50,12 @@ export interface ClaustrumConsumerOptions<Q = QuotaObservation> {
|
|
|
50
50
|
* routine token refresh, which never moves the view.
|
|
51
51
|
*/
|
|
52
52
|
onRoster?: (roster: VaultRosterFile) => void;
|
|
53
|
+
/**
|
|
54
|
+
* Called once when a coalesced discovery starts, with its completion promise.
|
|
55
|
+
* Covers explicit refresh, poll, watch and send-triggered discovery, even when
|
|
56
|
+
* the view does not change. Observe rejection when attaching async work.
|
|
57
|
+
*/
|
|
58
|
+
onDiscovery?: (promise: Promise<VaultRosterFile | undefined>) => void;
|
|
53
59
|
onError?: (error: unknown) => void;
|
|
54
60
|
/**
|
|
55
61
|
* How often `start()` ticks. A tick lists the vault when no vault watch is
|
|
@@ -104,6 +110,8 @@ export interface HubMemberPort {
|
|
|
104
110
|
keptReceiptState(): KeptReceiptState;
|
|
105
111
|
/** Apply the union of every member's roster in memory to kept receipts. */
|
|
106
112
|
retainUnion(): void;
|
|
113
|
+
/** Share a committed preference change with live members using this roster file. */
|
|
114
|
+
publishRoster(roster: VaultRosterFile): void;
|
|
107
115
|
forget(credentialId: string): void;
|
|
108
116
|
/** The member closed: the hub stops committing and pushing to it. */
|
|
109
117
|
detach(): void;
|
|
@@ -113,6 +121,8 @@ export interface HubRefreshOutcome {
|
|
|
113
121
|
}
|
|
114
122
|
/** What the hub may do to one member's memory. Package-internal. */
|
|
115
123
|
export interface HubMemberHooks {
|
|
124
|
+
/** Observe a hub discovery without relying on member refresh overrides. */
|
|
125
|
+
discovery(promise: Promise<HubRefreshOutcome | undefined>): void;
|
|
116
126
|
/**
|
|
117
127
|
* Set the roster in memory as a consumer's own refresh does (pending quota
|
|
118
128
|
* readings included) and notify `onRoster` when its view changed.
|
|
@@ -314,8 +314,17 @@ export class ClaustrumConsumer {
|
|
|
314
314
|
this.#refreshing = undefined;
|
|
315
315
|
});
|
|
316
316
|
this.#track(this.#refreshing);
|
|
317
|
+
this.#notifyDiscovery(this.#refreshing);
|
|
317
318
|
return this.#refreshing;
|
|
318
319
|
}
|
|
320
|
+
#notifyDiscovery(promise) {
|
|
321
|
+
try {
|
|
322
|
+
this.#options.onDiscovery?.(promise);
|
|
323
|
+
}
|
|
324
|
+
catch (error) {
|
|
325
|
+
this.#options.onError?.(error);
|
|
326
|
+
}
|
|
327
|
+
}
|
|
319
328
|
/**
|
|
320
329
|
* Poll in the background and open the vault and insula watches. Until the
|
|
321
330
|
* vault watch is accepted, and whenever it is unavailable, every tick lists
|
|
@@ -571,6 +580,13 @@ export class ClaustrumConsumer {
|
|
|
571
580
|
/** The hub's handle on this member's memory. */
|
|
572
581
|
#hubHooks() {
|
|
573
582
|
return {
|
|
583
|
+
discovery: (promise) => {
|
|
584
|
+
const hub = this.#hub;
|
|
585
|
+
if (!hub || !this.#options.onDiscovery || this.#shutdown.signal.aborted)
|
|
586
|
+
return;
|
|
587
|
+
const discovery = this.#track(promise.then((outcome) => this.#hubOutcome(hub, outcome)));
|
|
588
|
+
this.#notifyDiscovery(discovery);
|
|
589
|
+
},
|
|
574
590
|
install: (roster) => {
|
|
575
591
|
if (this.#shutdown.signal.aborted)
|
|
576
592
|
return;
|
|
@@ -607,6 +623,9 @@ export class ClaustrumConsumer {
|
|
|
607
623
|
*/
|
|
608
624
|
async #hubRefresh(hub) {
|
|
609
625
|
const outcome = await hub.refresh();
|
|
626
|
+
return this.#hubOutcome(hub, outcome);
|
|
627
|
+
}
|
|
628
|
+
#hubOutcome(hub, outcome) {
|
|
610
629
|
this.#assertOpen();
|
|
611
630
|
if (!outcome)
|
|
612
631
|
return undefined;
|
|
@@ -788,6 +807,8 @@ export class ClaustrumConsumer {
|
|
|
788
807
|
this.#assertOpen();
|
|
789
808
|
await declineVaultRoute(this.#options.rosterPath, routeId);
|
|
790
809
|
this.#roster = pendingVaultQuota(this.#options.rosterPath, await readVaultRoster(this.#options.rosterPath));
|
|
810
|
+
if (this.#roster)
|
|
811
|
+
this.#hub?.publishRoster(this.#roster);
|
|
791
812
|
// A hub member shares kept receipts with every other member, so they are
|
|
792
813
|
// retained against all members' rosters, never against this one alone.
|
|
793
814
|
if (this.#hub)
|
|
@@ -799,6 +820,8 @@ export class ClaustrumConsumer {
|
|
|
799
820
|
this.#assertOpen();
|
|
800
821
|
await acceptVaultRoute(this.#options.rosterPath, routeId);
|
|
801
822
|
this.#roster = pendingVaultQuota(this.#options.rosterPath, await readVaultRoster(this.#options.rosterPath));
|
|
823
|
+
if (this.#roster)
|
|
824
|
+
this.#hub?.publishRoster(this.#roster);
|
|
802
825
|
}
|
|
803
826
|
/**
|
|
804
827
|
* Set the order vault accounts are tried in (`reorderVaultRoster`), then
|
|
@@ -809,6 +832,8 @@ export class ClaustrumConsumer {
|
|
|
809
832
|
this.#assertOpen();
|
|
810
833
|
const result = await reorderVaultRoster(this.#options.rosterPath, routeIds);
|
|
811
834
|
this.#roster = pendingVaultQuota(this.#options.rosterPath, await readVaultRoster(this.#options.rosterPath));
|
|
835
|
+
if (this.#roster)
|
|
836
|
+
this.#hub?.publishRoster(this.#roster);
|
|
812
837
|
return result;
|
|
813
838
|
}
|
|
814
839
|
/**
|
|
@@ -25,7 +25,8 @@ export interface ClaustrumFamily {
|
|
|
25
25
|
/** Non-secret classification facts, including rows decoded by older clients. */
|
|
26
26
|
export interface VaultRowFacts {
|
|
27
27
|
readonly credentialId: string;
|
|
28
|
-
|
|
28
|
+
/** Internal serving type derived from `authMethod`, not the id's type hint. */
|
|
29
|
+
readonly credentialType: VaultCredentialType;
|
|
29
30
|
readonly authMethod?: string;
|
|
30
31
|
readonly refreshAdapter?: string;
|
|
31
32
|
readonly providerIds?: readonly string[];
|
|
@@ -108,7 +109,10 @@ export interface VaultInventory {
|
|
|
108
109
|
readonly view: string;
|
|
109
110
|
readonly credentials: readonly VaultCredential[];
|
|
110
111
|
readonly skipped: readonly SkippedVaultRecord[];
|
|
111
|
-
/**
|
|
112
|
+
/**
|
|
113
|
+
* Classifying families only: declared policy codes or the fixed library codes
|
|
114
|
+
* `unknown-auth-method`, `unmapped` and `unclassified`, never classifier errors.
|
|
115
|
+
*/
|
|
112
116
|
readonly refused?: readonly {
|
|
113
117
|
credentialId?: string;
|
|
114
118
|
code: string;
|
|
@@ -85,16 +85,28 @@ function credentialTypeOf(row, family) {
|
|
|
85
85
|
return notMine;
|
|
86
86
|
if (!row.categories.includes(family.category))
|
|
87
87
|
return notMine;
|
|
88
|
-
if (row.credentialType !== 'oauth' && row.credentialType !== 'api_key')
|
|
89
|
-
return notMine;
|
|
90
88
|
if ('classify' in family) {
|
|
91
|
-
|
|
89
|
+
const metadata = rowFactsOf(row);
|
|
90
|
+
let type;
|
|
91
|
+
// The id's type is only a hint; the vault's auth method determines serving.
|
|
92
|
+
switch (metadata.authMethod) {
|
|
93
|
+
case 'apikey':
|
|
94
|
+
type = 'api_key';
|
|
95
|
+
break;
|
|
96
|
+
case 'chatgpt':
|
|
97
|
+
case 'antigravity':
|
|
98
|
+
case 'oauth':
|
|
99
|
+
type = 'oauth';
|
|
100
|
+
break;
|
|
101
|
+
default:
|
|
102
|
+
return { kind: 'refused', code: 'unknown-auth-method' };
|
|
103
|
+
}
|
|
92
104
|
const facts = {
|
|
93
105
|
credentialId: row.id,
|
|
94
|
-
credentialType:
|
|
106
|
+
credentialType: type,
|
|
95
107
|
categories: row.categories,
|
|
96
108
|
refreshAdapter: row.refreshAdapter,
|
|
97
|
-
...
|
|
109
|
+
...metadata,
|
|
98
110
|
};
|
|
99
111
|
if (facts.providerIds === undefined)
|
|
100
112
|
return { kind: 'refused', code: 'unmapped' };
|
|
@@ -103,7 +115,7 @@ function credentialTypeOf(row, family) {
|
|
|
103
115
|
if (result.kind === 'not-mine')
|
|
104
116
|
return notMine;
|
|
105
117
|
if (result.kind === 'mine' && typeof result.member === 'string')
|
|
106
|
-
return { kind: 'mine', type
|
|
118
|
+
return { kind: 'mine', type, member: result.member };
|
|
107
119
|
if (result.kind === 'refused' &&
|
|
108
120
|
typeof result.code === 'string' &&
|
|
109
121
|
/^[a-z][a-z0-9-]{0,31}$/.test(result.code) &&
|
|
@@ -116,6 +128,8 @@ function credentialTypeOf(row, family) {
|
|
|
116
128
|
}
|
|
117
129
|
return { kind: 'refused', code: 'unclassified' };
|
|
118
130
|
}
|
|
131
|
+
if (row.credentialType !== 'oauth' && row.credentialType !== 'api_key')
|
|
132
|
+
return notMine;
|
|
119
133
|
if (row.credentialType === 'oauth')
|
|
120
134
|
return row.refreshAdapter === family.refreshAdapter
|
|
121
135
|
? { kind: 'mine', type: 'oauth' }
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { QuotaObservation } from '../quota/index.js';
|
|
2
|
-
import { type ClaustrumConsumer } from './consumer.js';
|
|
2
|
+
import { type ClaustrumConsumer, type ClaustrumConsumerOptions } from './consumer.js';
|
|
3
3
|
import { type ClassifyingClaustrumFamily, type ClaustrumScopedClient, ClaustrumScopedCustody, type IdentityParser, type KeptReceiptState, type VaultGrantReach } from './custody.js';
|
|
4
4
|
import { type ClaustrumLogger } from './errors.js';
|
|
5
5
|
import { type AccountMapper, type VaultRosterFile } from './roster.js';
|
|
@@ -100,6 +100,8 @@ export interface ClaustrumHubMemberOptions<_Q = QuotaObservation> {
|
|
|
100
100
|
reservedRouteIds?: () => Iterable<string>;
|
|
101
101
|
/** As `ClaustrumConsumerOptions.onRoster`: once per change of view. */
|
|
102
102
|
onRoster?: (roster: VaultRosterFile) => void;
|
|
103
|
+
/** Observe every hub discovery's member result, including background work. */
|
|
104
|
+
onDiscovery?: ClaustrumConsumerOptions<_Q>['onDiscovery'];
|
|
103
105
|
/** This member's own failures, such as a roster commit that failed. */
|
|
104
106
|
onError?: (error: unknown) => void;
|
|
105
107
|
logger?: ClaustrumLogger;
|