@cortexkit/opencode-antigravity-auth 3.0.29 → 3.0.31
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 +783 -254
- package/dist/cli.js.map +4 -4
- package/dist/cli.meta.json +145 -77
- package/dist/index.js +842 -297
- package/dist/index.js.map +4 -4
- package/dist/index.meta.json +177 -85
- package/dist/server.js +842 -300
- package/dist/server.js.map +4 -4
- package/dist/server.meta.json +1 -1
- package/dist/src/cli.d.ts +1 -0
- package/dist/src/cli.d.ts.map +1 -1
- package/dist/src/cli.js +22 -2
- package/dist/src/cli.js.map +1 -1
- package/dist/src/common-auth-embedded/claustrum/consumer.d.ts +12 -0
- package/dist/src/common-auth-embedded/claustrum/consumer.js +36 -0
- package/dist/src/common-auth-embedded/claustrum/custody.d.ts +16 -4
- package/dist/src/common-auth-embedded/claustrum/custody.js +74 -9
- package/dist/src/common-auth-embedded/claustrum/hub.d.ts +3 -2
- package/dist/src/common-auth-embedded/claustrum/hub.js +8 -0
- package/dist/src/common-auth-embedded/claustrum/index.d.ts +1 -0
- package/dist/src/common-auth-embedded/claustrum/roster.d.ts +4 -0
- package/dist/src/common-auth-embedded/claustrum/roster.js +34 -8
- package/dist/src/common-auth-embedded/claustrum/usage.d.ts +41 -0
- package/dist/src/common-auth-embedded/claustrum/usage.js +145 -0
- package/dist/src/common-auth-embedded/commands/builtins.d.ts +5 -0
- package/dist/src/common-auth-embedded/commands/builtins.js +38 -0
- package/dist/src/common-auth-embedded/fs/file-read-cache.js +10 -5
- package/dist/src/common-auth-embedded/fs/private-files.d.ts +5 -0
- package/dist/src/common-auth-embedded/fs/private-files.js +7 -0
- package/dist/src/common-auth-embedded/fs/refresh-file-lock.js +142 -47
- package/dist/src/common-auth-embedded/fs/with-lock.js +2 -5
- package/dist/src/common-auth-embedded/limits/activity.d.ts +26 -0
- package/dist/src/common-auth-embedded/limits/axes.d.ts +69 -0
- package/dist/src/common-auth-embedded/limits/decide.d.ts +146 -0
- package/dist/src/common-auth-embedded/limits/duration.d.ts +8 -0
- package/dist/src/common-auth-embedded/limits/families.d.ts +59 -0
- package/dist/src/common-auth-embedded/limits/marker.d.ts +69 -0
- package/dist/src/common-auth-embedded/limits/request-history.d.ts +79 -0
- package/dist/src/common-auth-embedded/limits/scope.d.ts +12 -0
- package/dist/src/common-auth-embedded/limits/signal.d.ts +41 -0
- package/dist/src/common-auth-embedded/limits/terminal.d.ts +52 -0
- package/dist/src/common-auth-embedded/limits/wake.d.ts +21 -0
- package/dist/src/common-auth-embedded/limits/wording.d.ts +25 -0
- 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 +219 -27
- package/dist/src/common-auth-embedded/opencode2/types.d.ts +113 -11
- package/dist/src/common-auth-embedded/routing/admission.d.ts +7 -2
- package/dist/src/common-auth-embedded/routing/admission.js +17 -7
- package/dist/src/common-auth-embedded/routing-accessor/handle.js +10 -0
- package/dist/src/common-auth-embedded/routing-accessor/index.d.ts +13 -3
- package/dist/src/common-auth-embedded/routing-accessor/index.js +11 -10
- package/dist/src/common-auth-embedded/rpc/port-file.d.ts +12 -3
- package/dist/src/common-auth-embedded/rpc/port-file.js +46 -4
- package/dist/src/common-auth-embedded/setup/enroll.js +7 -1
- package/dist/src/common-auth-embedded/source-output.json +260 -124
- package/dist/src/common-auth-embedded/store/attribution.js +3 -2
- package/dist/src/common-auth-embedded/store/errors.d.ts +1 -1
- package/dist/src/common-auth-embedded/store/hooks.d.ts +5 -1
- package/dist/src/common-auth-embedded/store/hooks.js +20 -5
- package/dist/src/common-auth-embedded/store/index.d.ts +1 -0
- package/dist/src/common-auth-embedded/store/limits-namespace.d.ts +13 -0
- package/dist/src/common-auth-embedded/store/limits-namespace.js +46 -0
- package/dist/src/common-auth-embedded/store/pool.d.ts +10 -1
- package/dist/src/common-auth-embedded/store/pool.js +2 -0
- package/dist/src/common-auth-embedded/store/provider-state.js +5 -5
- package/dist/src/common-auth-embedded/store/refresh.js +1 -1
- package/dist/src/common-auth-embedded/store/schema.js +9 -4
- package/dist/src/common-auth-embedded/store/settings.d.ts +2 -0
- package/dist/src/common-auth-embedded/store/settings.js +11 -4
- package/dist/src/plugin/__fixtures__/release-model-ids.d.ts.map +1 -1
- package/dist/src/plugin/__fixtures__/release-model-ids.js +0 -1
- package/dist/src/plugin/__fixtures__/release-model-ids.js.map +1 -1
- package/dist/src/plugin/__fixtures__/verified-store.js +2 -2
- package/dist/src/plugin/account-access.js +1 -1
- package/dist/src/plugin/request.d.ts.map +1 -1
- package/dist/src/plugin/request.js +3 -2
- package/dist/src/plugin/request.js.map +1 -1
- package/dist/src/plugin/shared/request-services.d.ts +1 -1
- package/dist/src/plugin/shared/request-services.js +1 -1
- package/dist/src/runtime-layout.d.ts +9 -2
- package/dist/src/runtime-layout.d.ts.map +1 -1
- package/dist/src/runtime-layout.js +8 -8
- package/dist/src/runtime-layout.js.map +1 -1
- package/dist/src/setup.d.ts.map +1 -1
- package/dist/src/setup.js +29 -40
- package/dist/src/setup.js.map +1 -1
- package/dist/tui-build-map.json +9 -9
- package/dist/tui-ga-build-map.json +1 -1
- package/dist/types/src/cli.d.ts +1 -0
- package/dist/types/src/cli.d.ts.map +1 -1
- package/dist/types/src/common-auth-embedded/claustrum/consumer.d.ts +12 -0
- package/dist/types/src/common-auth-embedded/claustrum/custody.d.ts +16 -4
- package/dist/types/src/common-auth-embedded/claustrum/hub.d.ts +3 -2
- package/dist/types/src/common-auth-embedded/claustrum/index.d.ts +1 -0
- package/dist/types/src/common-auth-embedded/claustrum/roster.d.ts +4 -0
- package/dist/types/src/common-auth-embedded/claustrum/usage.d.ts +41 -0
- package/dist/types/src/common-auth-embedded/commands/builtins.d.ts +5 -0
- package/dist/types/src/common-auth-embedded/limits/activity.d.ts +26 -0
- package/dist/types/src/common-auth-embedded/limits/axes.d.ts +69 -0
- package/dist/types/src/common-auth-embedded/limits/decide.d.ts +146 -0
- package/dist/types/src/common-auth-embedded/limits/duration.d.ts +8 -0
- package/dist/types/src/common-auth-embedded/limits/families.d.ts +59 -0
- package/dist/types/src/common-auth-embedded/limits/marker.d.ts +69 -0
- package/dist/types/src/common-auth-embedded/limits/request-history.d.ts +79 -0
- package/dist/types/src/common-auth-embedded/limits/scope.d.ts +12 -0
- package/dist/types/src/common-auth-embedded/limits/signal.d.ts +41 -0
- package/dist/types/src/common-auth-embedded/limits/terminal.d.ts +52 -0
- package/dist/types/src/common-auth-embedded/limits/wake.d.ts +21 -0
- package/dist/types/src/common-auth-embedded/limits/wording.d.ts +25 -0
- 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 +113 -11
- package/dist/types/src/common-auth-embedded/routing/admission.d.ts +7 -2
- package/dist/types/src/common-auth-embedded/routing-accessor/index.d.ts +13 -3
- package/dist/types/src/common-auth-embedded/store/errors.d.ts +1 -1
- package/dist/types/src/common-auth-embedded/store/hooks.d.ts +5 -1
- package/dist/types/src/common-auth-embedded/store/index.d.ts +1 -0
- package/dist/types/src/common-auth-embedded/store/limits-namespace.d.ts +13 -0
- package/dist/types/src/common-auth-embedded/store/pool.d.ts +10 -1
- package/dist/types/src/common-auth-embedded/store/settings.d.ts +2 -0
- package/dist/types/src/plugin/request.d.ts.map +1 -1
- package/dist/types/src/plugin/shared/request-services.d.ts +1 -1
- package/dist/types/src/runtime-layout.d.ts +9 -2
- package/dist/types/src/runtime-layout.d.ts.map +1 -1
- package/dist/types/src/setup.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/common-auth-embedded/claustrum/consumer.d.ts +12 -0
- package/src/common-auth-embedded/claustrum/consumer.js +36 -0
- package/src/common-auth-embedded/claustrum/custody.d.ts +16 -4
- package/src/common-auth-embedded/claustrum/custody.js +74 -9
- package/src/common-auth-embedded/claustrum/hub.d.ts +3 -2
- package/src/common-auth-embedded/claustrum/hub.js +8 -0
- package/src/common-auth-embedded/claustrum/index.d.ts +1 -0
- package/src/common-auth-embedded/claustrum/roster.d.ts +4 -0
- package/src/common-auth-embedded/claustrum/roster.js +34 -8
- package/src/common-auth-embedded/claustrum/usage.d.ts +41 -0
- package/src/common-auth-embedded/claustrum/usage.js +145 -0
- package/src/common-auth-embedded/commands/builtins.d.ts +5 -0
- package/src/common-auth-embedded/commands/builtins.js +38 -0
- package/src/common-auth-embedded/fs/file-read-cache.js +10 -5
- package/src/common-auth-embedded/fs/private-files.d.ts +5 -0
- package/src/common-auth-embedded/fs/private-files.js +7 -0
- package/src/common-auth-embedded/fs/refresh-file-lock.js +142 -47
- package/src/common-auth-embedded/fs/with-lock.js +2 -5
- package/src/common-auth-embedded/limits/activity.d.ts +26 -0
- package/src/common-auth-embedded/limits/axes.d.ts +69 -0
- package/src/common-auth-embedded/limits/decide.d.ts +146 -0
- package/src/common-auth-embedded/limits/duration.d.ts +8 -0
- package/src/common-auth-embedded/limits/families.d.ts +59 -0
- package/src/common-auth-embedded/limits/marker.d.ts +69 -0
- package/src/common-auth-embedded/limits/request-history.d.ts +79 -0
- package/src/common-auth-embedded/limits/scope.d.ts +12 -0
- package/src/common-auth-embedded/limits/signal.d.ts +41 -0
- package/src/common-auth-embedded/limits/terminal.d.ts +52 -0
- package/src/common-auth-embedded/limits/wake.d.ts +21 -0
- package/src/common-auth-embedded/limits/wording.d.ts +25 -0
- 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 +219 -27
- package/src/common-auth-embedded/opencode2/types.d.ts +113 -11
- package/src/common-auth-embedded/routing/admission.d.ts +7 -2
- package/src/common-auth-embedded/routing/admission.js +17 -7
- package/src/common-auth-embedded/routing-accessor/handle.js +10 -0
- package/src/common-auth-embedded/routing-accessor/index.d.ts +13 -3
- package/src/common-auth-embedded/routing-accessor/index.js +11 -10
- package/src/common-auth-embedded/rpc/port-file.d.ts +12 -3
- package/src/common-auth-embedded/rpc/port-file.js +46 -4
- package/src/common-auth-embedded/setup/enroll.js +7 -1
- package/src/common-auth-embedded/source-output.json +260 -124
- package/src/common-auth-embedded/store/attribution.js +3 -2
- package/src/common-auth-embedded/store/errors.d.ts +1 -1
- package/src/common-auth-embedded/store/hooks.d.ts +5 -1
- package/src/common-auth-embedded/store/hooks.js +20 -5
- package/src/common-auth-embedded/store/index.d.ts +1 -0
- package/src/common-auth-embedded/store/limits-namespace.d.ts +13 -0
- package/src/common-auth-embedded/store/limits-namespace.js +46 -0
- package/src/common-auth-embedded/store/pool.d.ts +10 -1
- package/src/common-auth-embedded/store/pool.js +2 -0
- package/src/common-auth-embedded/store/provider-state.js +5 -5
- package/src/common-auth-embedded/store/refresh.js +1 -1
- package/src/common-auth-embedded/store/schema.js +9 -4
- package/src/common-auth-embedded/store/settings.d.ts +2 -0
- package/src/common-auth-embedded/store/settings.js +11 -4
- package/src/tui-compiled/common-auth-embedded/fs/private-files.js +7 -0
- package/src/tui-compiled/common-auth-embedded/rpc/port-file.js +46 -4
- package/src/tui-raw/common-auth-embedded/fs/private-files.js +7 -0
- package/src/tui-raw/common-auth-embedded/rpc/port-file.js +46 -4
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import type { Scope } from './scope.js';
|
|
2
|
+
import type { AccountKey, LimitKind, LimitSignal } from './signal.js';
|
|
3
|
+
export type MergeLaw = 'latest-evidence' | 'max-until' | 'overwrite';
|
|
4
|
+
export type LimitMarkCause = 'rate-limit' | 'payment-balance';
|
|
5
|
+
export interface LimitMark {
|
|
6
|
+
readonly scope: Scope;
|
|
7
|
+
readonly until: number;
|
|
8
|
+
readonly mergeLaw: MergeLaw;
|
|
9
|
+
readonly cause?: LimitMarkCause;
|
|
10
|
+
}
|
|
11
|
+
export interface FailureLadderAxes {
|
|
12
|
+
readonly kind: 'failure-ladder';
|
|
13
|
+
readonly mergeLaw: MergeLaw;
|
|
14
|
+
readonly hintFloorMs: number;
|
|
15
|
+
readonly quotaSteps: readonly number[];
|
|
16
|
+
readonly byKind: Readonly<Partial<Record<LimitKind, number>>>;
|
|
17
|
+
readonly byReason: Readonly<Record<string, number>>;
|
|
18
|
+
readonly capacity: {
|
|
19
|
+
readonly baseMs: number;
|
|
20
|
+
/** Maximum displacement on either side of baseMs. */
|
|
21
|
+
readonly spreadMs: number;
|
|
22
|
+
};
|
|
23
|
+
readonly defaultMs: number;
|
|
24
|
+
}
|
|
25
|
+
export declare const ANTIGRAVITY_FAILURE_LADDER: FailureLadderAxes;
|
|
26
|
+
export type MarkerAxes = {
|
|
27
|
+
readonly kind: 'off';
|
|
28
|
+
} | {
|
|
29
|
+
readonly kind: 'hint';
|
|
30
|
+
readonly mergeLaw: MergeLaw;
|
|
31
|
+
readonly defaultMs: number;
|
|
32
|
+
readonly defaultMsByKind?: Readonly<Partial<Record<LimitSignal['kind'], number>>>;
|
|
33
|
+
readonly causes?: readonly LimitMarkCause[];
|
|
34
|
+
readonly ignoredKinds?: readonly LimitSignal['kind'][];
|
|
35
|
+
readonly minimumMs: number;
|
|
36
|
+
readonly zero: 'accept' | 'skip';
|
|
37
|
+
/** Core absolute dates and host event-relative hints use different samples. */
|
|
38
|
+
readonly hintClock: 'signal' | 'marker';
|
|
39
|
+
} | {
|
|
40
|
+
readonly kind: 'reset';
|
|
41
|
+
readonly mergeLaw: MergeLaw;
|
|
42
|
+
readonly defaultMs: number;
|
|
43
|
+
} | FailureLadderAxes;
|
|
44
|
+
export interface FailureStreak {
|
|
45
|
+
readonly count: number;
|
|
46
|
+
readonly lastFailureAt: number;
|
|
47
|
+
}
|
|
48
|
+
/** Owned by the process, not a persisted registry snapshot. */
|
|
49
|
+
export type FailureHistory = ReadonlyMap<string, FailureStreak>;
|
|
50
|
+
export type FailureEvent = {
|
|
51
|
+
readonly type: 'failure';
|
|
52
|
+
readonly account: AccountKey;
|
|
53
|
+
readonly at: number;
|
|
54
|
+
} | {
|
|
55
|
+
readonly type: 'success';
|
|
56
|
+
readonly account: AccountKey;
|
|
57
|
+
};
|
|
58
|
+
/** Feed committed marker events, not repeated reducer evaluations, into history. */
|
|
59
|
+
export declare function reduceFailureHistory(history: FailureHistory, event: FailureEvent, ttlMs?: number): FailureHistory;
|
|
60
|
+
export interface MarkerHistory {
|
|
61
|
+
readonly now: number;
|
|
62
|
+
/** Includes the current failure event; success removes only that account's streak. */
|
|
63
|
+
readonly failures?: FailureHistory;
|
|
64
|
+
/** Uniform sample in [0, 1] for the capacity fallback duration; omitted means midpoint. */
|
|
65
|
+
readonly random?: number;
|
|
66
|
+
}
|
|
67
|
+
/** No clocks, random draws, state updates or I/O occur while producing a mark. */
|
|
68
|
+
export declare function markFromSignal(signal: LimitSignal | undefined, axes: MarkerAxes, history: MarkerHistory): LimitMark | undefined;
|
|
69
|
+
export declare function markIsActive(mark: LimitMark, now: number): boolean;
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import type { Scope } from './scope.js';
|
|
2
|
+
import type { AccountKey, LimitKind } from './signal.js';
|
|
3
|
+
export declare function sameAccount(a: AccountKey, b: AccountKey): boolean;
|
|
4
|
+
export interface RequestExclusion {
|
|
5
|
+
readonly account: AccountKey;
|
|
6
|
+
readonly scope: Scope;
|
|
7
|
+
}
|
|
8
|
+
export interface RetainHistory {
|
|
9
|
+
readonly account: AccountKey;
|
|
10
|
+
readonly count: number;
|
|
11
|
+
readonly startedAt: number;
|
|
12
|
+
readonly lastRetainedAt: number;
|
|
13
|
+
}
|
|
14
|
+
export interface RequestHistory {
|
|
15
|
+
/** A request/turn token, not a session id. */
|
|
16
|
+
readonly requestId: string;
|
|
17
|
+
readonly originalUrl: string;
|
|
18
|
+
readonly requestStartedAt: number;
|
|
19
|
+
readonly saw429: boolean;
|
|
20
|
+
readonly sawPaymentBalance?: boolean;
|
|
21
|
+
readonly lastStatus?: number;
|
|
22
|
+
readonly tried: readonly RequestExclusion[];
|
|
23
|
+
readonly excludedForRequest: readonly RequestExclusion[];
|
|
24
|
+
readonly retains: readonly RetainHistory[];
|
|
25
|
+
readonly retainedAttempts: readonly string[];
|
|
26
|
+
readonly excludedAttempts: readonly string[];
|
|
27
|
+
readonly switchedAttempts: readonly string[];
|
|
28
|
+
readonly switches: number;
|
|
29
|
+
readonly blockedSince?: number;
|
|
30
|
+
}
|
|
31
|
+
export declare function createRequestHistory(input: {
|
|
32
|
+
readonly requestId: string;
|
|
33
|
+
readonly originalUrl: string;
|
|
34
|
+
readonly clockNow: number;
|
|
35
|
+
}): RequestHistory;
|
|
36
|
+
export declare function isRequestExcluded(history: RequestHistory, account: AccountKey, scope: Scope): boolean;
|
|
37
|
+
export type RequestHistoryEvent = {
|
|
38
|
+
readonly type: 'response';
|
|
39
|
+
readonly account: AccountKey;
|
|
40
|
+
readonly scope: Scope;
|
|
41
|
+
readonly status?: number;
|
|
42
|
+
readonly kind?: LimitKind;
|
|
43
|
+
} | {
|
|
44
|
+
readonly type: 'retain';
|
|
45
|
+
readonly account: AccountKey;
|
|
46
|
+
readonly attemptId: string;
|
|
47
|
+
readonly clockNow: number;
|
|
48
|
+
readonly cause: 'unconfirmed-limit' | 'credential-recovery';
|
|
49
|
+
} | {
|
|
50
|
+
readonly type: 'exclude';
|
|
51
|
+
readonly account: AccountKey;
|
|
52
|
+
readonly scope: Scope;
|
|
53
|
+
readonly attemptId: string;
|
|
54
|
+
} | {
|
|
55
|
+
readonly type: 'switch';
|
|
56
|
+
readonly attemptId: string;
|
|
57
|
+
} | {
|
|
58
|
+
readonly type: 'blocked';
|
|
59
|
+
readonly clockNow: number;
|
|
60
|
+
} | {
|
|
61
|
+
readonly type: 'selected';
|
|
62
|
+
};
|
|
63
|
+
/** Retain/exclude/switch events are committed by the executor, not by polling. */
|
|
64
|
+
export declare function reduceRequestHistory(history: RequestHistory, event: RequestHistoryEvent): RequestHistory;
|
|
65
|
+
export declare const REQUEST_EXCLUSION_EFFECTS: Readonly<{
|
|
66
|
+
readonly refundHybridToken: true;
|
|
67
|
+
readonly cancelDiscardedBody: true;
|
|
68
|
+
readonly addMark: false;
|
|
69
|
+
readonly addCooldown: false;
|
|
70
|
+
readonly penalizeHealth: false;
|
|
71
|
+
readonly chargeSwitch: false;
|
|
72
|
+
}>;
|
|
73
|
+
/** Run the returned effects once, then reselect with the returned history. */
|
|
74
|
+
export declare function commitRequestExclusion(history: RequestHistory, entry: RequestExclusion & {
|
|
75
|
+
readonly attemptId: string;
|
|
76
|
+
}): {
|
|
77
|
+
readonly history: RequestHistory;
|
|
78
|
+
readonly effects?: typeof REQUEST_EXCLUSION_EFFECTS;
|
|
79
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/** Applicability is a plugin fact, never a substring match on a model id. */
|
|
2
|
+
export type Scope = {
|
|
3
|
+
readonly kind: 'pool';
|
|
4
|
+
} | {
|
|
5
|
+
readonly kind: 'family';
|
|
6
|
+
readonly family: string;
|
|
7
|
+
} | {
|
|
8
|
+
readonly kind: 'model';
|
|
9
|
+
readonly model: string;
|
|
10
|
+
};
|
|
11
|
+
export type FamilyOf = (model: string) => string | undefined;
|
|
12
|
+
export declare function scopeCovers(scope: Scope, model: string, familyOf: FamilyOf): boolean;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { Scope } from './scope.js';
|
|
2
|
+
/** Refreshing credentials preserves this key; replacing an identity does not. */
|
|
3
|
+
export interface AccountKey {
|
|
4
|
+
readonly namespace: string;
|
|
5
|
+
readonly accountId: string;
|
|
6
|
+
readonly incarnation: string;
|
|
7
|
+
}
|
|
8
|
+
export type LimitKind = 'quota-exhausted' | 'rate-limit' | 'capacity' | 'payment-balance' | 'payment-cap' | 'auth' | 'account-access' | 'model-unavailable';
|
|
9
|
+
export interface LimitWindow {
|
|
10
|
+
readonly window: string;
|
|
11
|
+
readonly confirmed: boolean;
|
|
12
|
+
readonly confirmedByReading: boolean;
|
|
13
|
+
readonly resetAt?: number;
|
|
14
|
+
readonly resetSource?: string;
|
|
15
|
+
readonly observedAt: number;
|
|
16
|
+
readonly provenance: string;
|
|
17
|
+
}
|
|
18
|
+
/** A retry hint does not by itself confirm any exhausted window. */
|
|
19
|
+
export interface LimitSignal {
|
|
20
|
+
readonly account: AccountKey;
|
|
21
|
+
readonly kind: LimitKind;
|
|
22
|
+
readonly reason: string;
|
|
23
|
+
readonly status?: number;
|
|
24
|
+
readonly scope: Scope;
|
|
25
|
+
readonly windows: readonly LimitWindow[];
|
|
26
|
+
readonly observedAt: number;
|
|
27
|
+
readonly retryAfterMs?: number;
|
|
28
|
+
readonly retryAfterSource?: string;
|
|
29
|
+
}
|
|
30
|
+
export interface ClassifierInput {
|
|
31
|
+
readonly account: AccountKey;
|
|
32
|
+
readonly status: number;
|
|
33
|
+
readonly headers: Headers;
|
|
34
|
+
readonly body?: unknown;
|
|
35
|
+
readonly firstEvent?: unknown;
|
|
36
|
+
readonly effectiveModel: string;
|
|
37
|
+
readonly readings: readonly LimitWindow[];
|
|
38
|
+
readonly now: number;
|
|
39
|
+
}
|
|
40
|
+
/** Returning nothing must not manufacture an exhaustion mark. */
|
|
41
|
+
export type LimitClassifier = (input: ClassifierInput) => LimitSignal | undefined;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import type { SessionActivity } from './activity.js';
|
|
2
|
+
import type { LimitAxes } from './axes.js';
|
|
3
|
+
import type { LimitDecision, PolicyFacts, TerminalFacts, WaitCheckpoint } from './decide.js';
|
|
4
|
+
import type { RequestHistory } from './request-history.js';
|
|
5
|
+
import type { FamilyOf, Scope } from './scope.js';
|
|
6
|
+
import type { AccountKey } from './signal.js';
|
|
7
|
+
export interface TerminalWindow {
|
|
8
|
+
readonly window: string;
|
|
9
|
+
readonly scope: Scope;
|
|
10
|
+
/** The caller evaluates quota thresholds, not just provider exhaustion. */
|
|
11
|
+
readonly blockedBy?: 'exhausted' | 'floor' | 'killswitch-floor';
|
|
12
|
+
readonly reset?: {
|
|
13
|
+
readonly at: number;
|
|
14
|
+
/** Provenance of this reset field, never the enclosing row's update time. */
|
|
15
|
+
readonly observedAt?: number;
|
|
16
|
+
readonly checkedAt?: number;
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
export interface TerminalCandidate {
|
|
20
|
+
readonly account: AccountKey;
|
|
21
|
+
readonly readingAccount: AccountKey;
|
|
22
|
+
readonly identity?: string;
|
|
23
|
+
readonly readingIdentity?: string;
|
|
24
|
+
readonly windows: readonly TerminalWindow[];
|
|
25
|
+
}
|
|
26
|
+
export interface TerminalScanFacts {
|
|
27
|
+
/** Candidate keys come from the caller's scoped/general terminal scan. */
|
|
28
|
+
readonly candidates: readonly TerminalCandidate[];
|
|
29
|
+
readonly effectiveModel: string;
|
|
30
|
+
readonly familyOf: FamilyOf;
|
|
31
|
+
readonly maxAgeMs: number;
|
|
32
|
+
readonly maxSameAccountWait?: unknown;
|
|
33
|
+
readonly activity?: SessionActivity;
|
|
34
|
+
/** Current session account, used to reject another account's cache record. */
|
|
35
|
+
readonly accountKey?: AccountKey;
|
|
36
|
+
}
|
|
37
|
+
export interface TerminalReset {
|
|
38
|
+
readonly account: AccountKey;
|
|
39
|
+
readonly resetAt: number;
|
|
40
|
+
readonly checkpoint: WaitCheckpoint;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Take each account's latest blocking reset, then the earliest across accounts.
|
|
44
|
+
* A missing identity is compatible, but readings from before re-login are not.
|
|
45
|
+
*/
|
|
46
|
+
export declare function scanTerminalReset(input: TerminalScanFacts, now: number): TerminalReset | undefined;
|
|
47
|
+
export declare function terminalWaitDisabled(metadata: TerminalFacts, axes: LimitAxes): boolean;
|
|
48
|
+
/**
|
|
49
|
+
* When no account is ready, cap the wait by the setting rather than cache expiry.
|
|
50
|
+
* Unlike a same-account hold, this wait may proceed without a cache activity record.
|
|
51
|
+
*/
|
|
52
|
+
export declare function terminalRefusalDecision(facts: PolicyFacts, axes: LimitAxes, history: RequestHistory, metadata: TerminalFacts): LimitDecision | undefined;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { WaitCheckpoint } from './decide.js';
|
|
2
|
+
import type { AccountKey, LimitWindow } from './signal.js';
|
|
3
|
+
export interface WakeFacts {
|
|
4
|
+
readonly checkpoint: WaitCheckpoint;
|
|
5
|
+
readonly target: number;
|
|
6
|
+
/**
|
|
7
|
+
* Ordinary holds require this session/account's provider prompt cache to
|
|
8
|
+
* remain valid; terminal waits instead wait for pool quota, without a cache.
|
|
9
|
+
*/
|
|
10
|
+
readonly kind?: 'hold' | 'terminal';
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Snapshot exhaustion blockers only. A wait caused by a minimum-remaining quota
|
|
14
|
+
* threshold supplies no windows: elapsed time cannot prove renewed headroom.
|
|
15
|
+
*/
|
|
16
|
+
export declare function waitCheckpoint(accountKey: AccountKey, decidedAt: number, windows: readonly LimitWindow[]): WaitCheckpoint;
|
|
17
|
+
/**
|
|
18
|
+
* Match exhaustion evidence for one wake dispatch, without refreshing quota.
|
|
19
|
+
* The caller must still check admission, other blockers and any cache bound.
|
|
20
|
+
*/
|
|
21
|
+
export declare function liftedWindowsForWake(wake: WakeFacts, account: AccountKey, windows: readonly LimitWindow[], now: number): readonly string[];
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { ResetFormatter } from './duration.js';
|
|
2
|
+
export declare function hasUnsafeWording(text: string): boolean;
|
|
3
|
+
export interface MessageParameters {
|
|
4
|
+
readonly labels: readonly string[];
|
|
5
|
+
readonly retryIn?: string;
|
|
6
|
+
readonly reset?: string;
|
|
7
|
+
}
|
|
8
|
+
/** Templates return text only; they cannot replace a family's wire envelope. */
|
|
9
|
+
export type MessageTemplate = (parameters: MessageParameters) => string;
|
|
10
|
+
export declare class UnsafeWordingError extends Error {
|
|
11
|
+
readonly messageKey: string;
|
|
12
|
+
readonly code = "unsafe-wording";
|
|
13
|
+
constructor(messageKey: string);
|
|
14
|
+
}
|
|
15
|
+
export interface LimitMessageOptions {
|
|
16
|
+
readonly refusals?: Readonly<Record<string, MessageTemplate>>;
|
|
17
|
+
readonly retryable?: Readonly<Record<string, MessageTemplate>>;
|
|
18
|
+
readonly formatReset?: ResetFormatter;
|
|
19
|
+
}
|
|
20
|
+
export interface LimitMessages {
|
|
21
|
+
readonly formatReset?: ResetFormatter;
|
|
22
|
+
readonly render: (messageKey: string, parameters: MessageParameters, nonRetryable: boolean) => string | undefined;
|
|
23
|
+
}
|
|
24
|
+
/** Registration rejects unsafe fixed text; actual substitutions are checked again. */
|
|
25
|
+
export declare function registerLimitMessages(options: LimitMessageOptions): LimitMessages;
|
|
@@ -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, SameAccountRetryInput, SameAccountRetryResult, 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, RetryDisposition, RetryHold, RetryReason, RetryWaitThenReselect, RetryWake, SameAccountRetryInput, SameAccountRetryResult, SelectingHook, Transport, } from './types.js';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { ChooseAccountResult, HeaderEdits, InstallOpenCode2AuthOptions, OpenCode2AuthAdapter, OpenCode2AuthInstallation, OpenCode2HookContext } from './types.js';
|
|
2
2
|
export declare const DEFAULT_MAX_RECORDS = 512;
|
|
3
|
-
/**
|
|
4
|
-
export declare const MAX_RETRY_HOLD_MS
|
|
3
|
+
/** Allow a one-hour cache lifetime plus the maximum session jitter. */
|
|
4
|
+
export declare const MAX_RETRY_HOLD_MS = 3621000;
|
|
5
5
|
/**
|
|
6
6
|
* The request header `model.request` sets to the attempt it started. The
|
|
7
7
|
* host builds the HTTP request and the WebSocket handshake from the headers
|
|
@@ -30,7 +30,8 @@ export declare function applyHeaderEdits(target: Record<string, string>, edits:
|
|
|
30
30
|
* - `retry` asks the host to retry at once when an account was refused
|
|
31
31
|
* before any output and `chooseAccount` names another account for the
|
|
32
32
|
* next attempt, keeps the host's decision when the refused account was the
|
|
33
|
-
* last one that can serve
|
|
33
|
+
* last one that can serve. After output, only a witnessed HTTP read failure
|
|
34
|
+
* with adapter-approved same-account continuation can keep the host's retry.
|
|
34
35
|
*
|
|
35
36
|
* Attribution. A send belongs to the attempt named by the mark
|
|
36
37
|
* `model.request` left on it, so several attempts of one session and kind
|