@rynfar/meridian 1.72.0 → 1.74.0
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 +119 -107
- package/assets/banner.svg +18 -43
- package/assets/how-it-works.svg +40 -86
- package/assets/providers/README.md +10 -0
- package/assets/providers/antigravity.png +0 -0
- package/assets/providers/claude.png +0 -0
- package/dist/antigravity-clients/opencode.js +173 -0
- package/dist/antigravity-clients/pi.js +21 -0
- package/dist/antigravitySetup-35pd5xqn.js +191 -0
- package/dist/cli-1jstkdj9.js +30 -0
- package/dist/{cli-9e5cxp89.js → cli-2h3w5n6g.js} +163 -65
- package/dist/cli-3zwfvexc.js +56 -0
- package/dist/{cli-hxxy0m1z.js → cli-82e2m44k.js} +2 -1
- package/dist/cli-8sw5wr9j.js +136 -0
- package/dist/{cli-khhjyk04.js → cli-chsp880k.js} +214 -21
- package/dist/cli-dh0a1bw4.js +619 -0
- package/dist/cli-eehk3052.js +57 -0
- package/dist/{cli-ab7zkp1a.js → cli-fveyj34s.js} +32261 -18952
- package/dist/cli-grfp0s1j.js +330 -0
- package/dist/cli-qpfky8wy.js +133 -0
- package/dist/{cli-hj61zpt7.js → cli-wbsmhxcx.js} +26 -2
- package/dist/cli.js +111 -38
- package/dist/cliDashboard-c0dvkj4y.js +325 -0
- package/dist/configDir.d.ts +30 -0
- package/dist/configDir.d.ts.map +1 -0
- package/dist/organizationName-90f0atkn.js +29 -0
- package/dist/{pluginPage-f5gdmbxc.js → pluginPage-pp72d2j8.js} +1 -1
- package/dist/{profileCli-1eecbmgk.js → profileCli-1bfgc05h.js} +13 -3
- package/dist/{profilePage-mamej7kp.js → profilePage-vs319rvf.js} +252 -60
- package/dist/profileRename-4a4km6g8.js +22 -0
- package/dist/{profiles-wch9h234.js → profiles-0mp32ek9.js} +16 -3
- package/dist/proxy/adapterInstances.d.ts +1 -1
- package/dist/proxy/adapterInstances.d.ts.map +1 -1
- package/dist/proxy/adapters/claudecode.d.ts.map +1 -1
- package/dist/proxy/adapters/droid.d.ts.map +1 -1
- package/dist/proxy/auth.d.ts +2 -0
- package/dist/proxy/auth.d.ts.map +1 -1
- package/dist/proxy/authDiscovery.d.ts +52 -0
- package/dist/proxy/authDiscovery.d.ts.map +1 -0
- package/dist/proxy/backends/antigravity.d.ts +8 -0
- package/dist/proxy/backends/antigravity.d.ts.map +1 -0
- package/dist/proxy/backends/antigravityAttachments.d.ts +16 -0
- package/dist/proxy/backends/antigravityAttachments.d.ts.map +1 -0
- package/dist/proxy/backends/antigravityGrammar.d.ts +12 -0
- package/dist/proxy/backends/antigravityGrammar.d.ts.map +1 -0
- package/dist/proxy/backends/antigravityJobs.d.ts +19 -0
- package/dist/proxy/backends/antigravityJobs.d.ts.map +1 -0
- package/dist/proxy/backends/antigravityMedia.d.ts +9 -0
- package/dist/proxy/backends/antigravityMedia.d.ts.map +1 -0
- package/dist/proxy/backends/antigravityNative.d.ts +8 -0
- package/dist/proxy/backends/antigravityNative.d.ts.map +1 -0
- package/dist/proxy/backends/antigravityOpenai.d.ts +9 -0
- package/dist/proxy/backends/antigravityOpenai.d.ts.map +1 -0
- package/dist/proxy/backends/antigravityOpenaiMedia.d.ts +9 -0
- package/dist/proxy/backends/antigravityOpenaiMedia.d.ts.map +1 -0
- package/dist/proxy/backends/antigravityPlugins.d.ts +41 -0
- package/dist/proxy/backends/antigravityPlugins.d.ts.map +1 -0
- package/dist/proxy/backends/antigravityProbe.d.ts +16 -0
- package/dist/proxy/backends/antigravityProbe.d.ts.map +1 -0
- package/dist/proxy/backends/antigravityProcess.d.ts +4 -0
- package/dist/proxy/backends/antigravityProcess.d.ts.map +1 -0
- package/dist/proxy/backends/antigravityProtocol.d.ts +582 -0
- package/dist/proxy/backends/antigravityProtocol.d.ts.map +1 -0
- package/dist/proxy/backends/antigravityReplay.d.ts +41 -0
- package/dist/proxy/backends/antigravityReplay.d.ts.map +1 -0
- package/dist/proxy/backends/antigravityResponses.d.ts +35 -0
- package/dist/proxy/backends/antigravityResponses.d.ts.map +1 -0
- package/dist/proxy/backends/antigravityRuntime.d.ts +189 -0
- package/dist/proxy/backends/antigravityRuntime.d.ts.map +1 -0
- package/dist/proxy/backends/antigravitySchema.d.ts +10 -0
- package/dist/proxy/backends/antigravitySchema.d.ts.map +1 -0
- package/dist/proxy/backends/antigravitySessions.d.ts +28 -0
- package/dist/proxy/backends/antigravitySessions.d.ts.map +1 -0
- package/dist/proxy/backends/antigravityState.d.ts +22 -0
- package/dist/proxy/backends/antigravityState.d.ts.map +1 -0
- package/dist/proxy/backends/antigravityStops.d.ts +10 -0
- package/dist/proxy/backends/antigravityStops.d.ts.map +1 -0
- package/dist/proxy/backends/antigravityTokens.d.ts +14 -0
- package/dist/proxy/backends/antigravityTokens.d.ts.map +1 -0
- package/dist/proxy/backends/antigravityUrl.d.ts +7 -0
- package/dist/proxy/backends/antigravityUrl.d.ts.map +1 -0
- package/dist/proxy/backends/providerStatus.d.ts +15 -0
- package/dist/proxy/backends/providerStatus.d.ts.map +1 -0
- package/dist/proxy/credentialsMode.d.ts +77 -0
- package/dist/proxy/credentialsMode.d.ts.map +1 -0
- package/dist/proxy/design.d.ts.map +1 -1
- package/dist/proxy/followActive.d.ts +262 -0
- package/dist/proxy/followActive.d.ts.map +1 -0
- package/dist/proxy/limitDetection.d.ts +110 -0
- package/dist/proxy/limitDetection.d.ts.map +1 -0
- package/dist/proxy/models.d.ts.map +1 -1
- package/dist/proxy/oauthPlan.d.ts +63 -0
- package/dist/proxy/oauthPlan.d.ts.map +1 -0
- package/dist/proxy/oauthUsage.d.ts +65 -2
- package/dist/proxy/oauthUsage.d.ts.map +1 -1
- package/dist/proxy/openai.d.ts +6 -2
- package/dist/proxy/openai.d.ts.map +1 -1
- package/dist/proxy/organizationName.d.ts +71 -0
- package/dist/proxy/organizationName.d.ts.map +1 -0
- package/dist/proxy/passthroughEarlyStop.d.ts +10 -0
- package/dist/proxy/passthroughEarlyStop.d.ts.map +1 -1
- package/dist/proxy/planAllowance.d.ts +75 -0
- package/dist/proxy/planAllowance.d.ts.map +1 -0
- package/dist/proxy/probes.d.ts +85 -0
- package/dist/proxy/probes.d.ts.map +1 -0
- package/dist/proxy/profileCli.d.ts +53 -1
- package/dist/proxy/profileCli.d.ts.map +1 -1
- package/dist/proxy/profileHealth.d.ts +127 -0
- package/dist/proxy/profileHealth.d.ts.map +1 -0
- package/dist/proxy/profileRename.d.ts +83 -0
- package/dist/proxy/profileRename.d.ts.map +1 -0
- package/dist/proxy/profiles.d.ts +72 -6
- package/dist/proxy/profiles.d.ts.map +1 -1
- package/dist/proxy/query.d.ts +7 -0
- package/dist/proxy/query.d.ts.map +1 -1
- package/dist/proxy/routing.d.ts +59 -1
- package/dist/proxy/routing.d.ts.map +1 -1
- package/dist/proxy/sdkFeatures.d.ts +1 -1
- package/dist/proxy/sdkFeatures.d.ts.map +1 -1
- package/dist/proxy/server.d.ts.map +1 -1
- package/dist/proxy/session/fingerprint.d.ts +5 -0
- package/dist/proxy/session/fingerprint.d.ts.map +1 -1
- package/dist/proxy/session/lineage.d.ts.map +1 -1
- package/dist/proxy/setup.d.ts.map +1 -1
- package/dist/proxy/supervision.d.ts +41 -0
- package/dist/proxy/supervision.d.ts.map +1 -0
- package/dist/proxy/tokenRefresh.d.ts +38 -4
- package/dist/proxy/tokenRefresh.d.ts.map +1 -1
- package/dist/proxy/types.d.ts +32 -0
- package/dist/proxy/types.d.ts.map +1 -1
- package/dist/server.js +11 -7
- package/dist/settings.d.ts +83 -0
- package/dist/settings.d.ts.map +1 -0
- package/dist/{setup-ndmjpy23.js → setup-7fr49z92.js} +1 -1
- package/dist/statusProbe-9x9q261e.js +151 -0
- package/dist/telemetry/dashboard.d.ts.map +1 -1
- package/dist/telemetry/index.d.ts +20 -2
- package/dist/telemetry/index.d.ts.map +1 -1
- package/dist/telemetry/landing.d.ts +1 -1
- package/dist/telemetry/landing.d.ts.map +1 -1
- package/dist/telemetry/logStore.d.ts +11 -0
- package/dist/telemetry/logStore.d.ts.map +1 -1
- package/dist/telemetry/pricingStore.d.ts +2 -2
- package/dist/telemetry/pricingStore.d.ts.map +1 -1
- package/dist/telemetry/profileBar.d.ts +3 -3
- package/dist/telemetry/profileBar.d.ts.map +1 -1
- package/dist/telemetry/profileFacts.d.ts +17 -0
- package/dist/telemetry/profileFacts.d.ts.map +1 -0
- package/dist/telemetry/profileOrder.d.ts +68 -0
- package/dist/telemetry/profileOrder.d.ts.map +1 -0
- package/dist/telemetry/profilePage.d.ts.map +1 -1
- package/dist/telemetry/profileSort.d.ts +35 -0
- package/dist/telemetry/profileSort.d.ts.map +1 -0
- package/dist/telemetry/profileSpent.d.ts +68 -0
- package/dist/telemetry/profileSpent.d.ts.map +1 -0
- package/dist/telemetry/providerPage.d.ts +2 -0
- package/dist/telemetry/providerPage.d.ts.map +1 -0
- package/dist/telemetry/providerSetup.d.ts +5 -0
- package/dist/telemetry/providerSetup.d.ts.map +1 -0
- package/dist/telemetry/providerView.d.ts +45 -0
- package/dist/telemetry/providerView.d.ts.map +1 -0
- package/dist/telemetry/routeChain.d.ts +32 -0
- package/dist/telemetry/routeChain.d.ts.map +1 -0
- package/dist/telemetry/routes.d.ts.map +1 -1
- package/dist/telemetry/settingsPage.d.ts +1 -1
- package/dist/telemetry/settingsPage.d.ts.map +1 -1
- package/dist/telemetry/sqlite.d.ts.map +1 -1
- package/dist/telemetry/store.d.ts +6 -1
- package/dist/telemetry/store.d.ts.map +1 -1
- package/dist/telemetry/types.d.ts +132 -2
- package/dist/telemetry/types.d.ts.map +1 -1
- package/dist/{tokenRefresh-kzz08kea.js → tokenRefresh-eg9h83wd.js} +6 -1
- package/package.json +11 -4
- package/dist/cli-5jxyma6z.js +0 -277
- package/dist/cli-vj9cv18n.js +0 -38
- package/dist/proxy/settings.d.ts +0 -30
- package/dist/proxy/settings.d.ts.map +0 -1
|
@@ -0,0 +1,262 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Follow-the-active-profile mode — `MERIDIAN_FOLLOW_ACTIVE`.
|
|
3
|
+
*
|
|
4
|
+
* Makes a development instance take its active profile from ANOTHER Meridian
|
|
5
|
+
* instance instead of from its own `settings.json`, so the two serve from the
|
|
6
|
+
* same account and a side-by-side comparison is like-for-like.
|
|
7
|
+
*
|
|
8
|
+
* The problem it solves: `MERIDIAN_CONFIG_DIR` relocates `settings.json` and
|
|
9
|
+
* nothing else, so a second instance keeps its own `activeProfile`. Whatever
|
|
10
|
+
* moves the primary's active profile — a UI click, the CLI, an external fleet
|
|
11
|
+
* scheduler — has no effect on the second instance, which quietly serves from
|
|
12
|
+
* a different account. Measured on one box: the primary was on one profile
|
|
13
|
+
* while the dev instance served the same instant from another.
|
|
14
|
+
*
|
|
15
|
+
* What this changes: exactly ONE input to `resolveProfile` — the active
|
|
16
|
+
* profile. The precedence chain around it is untouched, so an explicit
|
|
17
|
+
* `x-meridian-profile` header still wins, and sticky/priority routing behave
|
|
18
|
+
* as they always did (priority mode does not consult the active profile at
|
|
19
|
+
* all for unpinned requests, so follow mode is a no-op there).
|
|
20
|
+
*
|
|
21
|
+
* Degradation is the design constraint, not an afterthought. The followed
|
|
22
|
+
* instance is polled in the background and the last good value is cached; the
|
|
23
|
+
* request path never waits on the network. If the followed instance is down,
|
|
24
|
+
* slow, or answers rubbish, the last known value keeps being served — and if
|
|
25
|
+
* there has never been a good value, the local active profile is used. A dev
|
|
26
|
+
* convenience must not be able to take an instance offline.
|
|
27
|
+
*
|
|
28
|
+
* Leaf module — no imports from server.ts, session/ or profiles.ts.
|
|
29
|
+
*/
|
|
30
|
+
/**
|
|
31
|
+
* Poll cadence. The followed value changes on the order of minutes (a human
|
|
32
|
+
* clicking, or a scheduler rotating accounts), so a fetch per request would be
|
|
33
|
+
* absurd; 10s bounds the divergence window without making the followed
|
|
34
|
+
* instance do meaningful work — `/profiles/list` serves its auth status from a
|
|
35
|
+
* 60s cache that the instance's own 45s keepalive already keeps warm.
|
|
36
|
+
*/
|
|
37
|
+
export declare const FOLLOW_POLL_INTERVAL_MS = 10000;
|
|
38
|
+
/** Per-poll timeout. Short: a slow followed instance must not accumulate polls. */
|
|
39
|
+
export declare const FOLLOW_FETCH_TIMEOUT_MS = 2000;
|
|
40
|
+
/**
|
|
41
|
+
* How long a value may go unconfirmed before it is REPORTED stale.
|
|
42
|
+
*
|
|
43
|
+
* Staleness deliberately does not change routing. Falling back to the local
|
|
44
|
+
* value after a timeout would silently split the comparison exactly when you
|
|
45
|
+
* are least likely to notice, and the local value is not more correct — it is
|
|
46
|
+
* just different. A stale-but-known followed value remains the best available
|
|
47
|
+
* answer to "what is the primary on?"; the dev instance's own `activeProfile`
|
|
48
|
+
* is arbitrary. So a stale value is still followed, and is flagged as stale
|
|
49
|
+
* everywhere the mode is surfaced.
|
|
50
|
+
*/
|
|
51
|
+
export declare const FOLLOW_STALE_AFTER_MS = 120000;
|
|
52
|
+
export type FollowTarget = {
|
|
53
|
+
kind: "off";
|
|
54
|
+
} | {
|
|
55
|
+
kind: "on";
|
|
56
|
+
url: string;
|
|
57
|
+
} | {
|
|
58
|
+
kind: "invalid";
|
|
59
|
+
raw: string;
|
|
60
|
+
message: string;
|
|
61
|
+
};
|
|
62
|
+
/**
|
|
63
|
+
* Parse the env var value into a normalized base URL.
|
|
64
|
+
*
|
|
65
|
+
* A bare `host:port` is accepted and assumed to be http, because that is what
|
|
66
|
+
* anyone types first and `new URL()` would otherwise read `127.0.0.1` as a
|
|
67
|
+
* scheme. Trailing slashes are stripped so callers can concatenate paths.
|
|
68
|
+
*
|
|
69
|
+
* A malformed value yields "invalid" rather than throwing: the caller warns
|
|
70
|
+
* and runs without follow mode. Refusing to start on a typo would take an
|
|
71
|
+
* instance offline, which is the one outcome this feature must never cause.
|
|
72
|
+
*/
|
|
73
|
+
export declare function parseFollowTarget(raw: string | undefined): FollowTarget;
|
|
74
|
+
/**
|
|
75
|
+
* Whether a follow target addresses the instance doing the following.
|
|
76
|
+
*
|
|
77
|
+
* Self-follow is a deadlock, not a harmless no-op: the instance would follow
|
|
78
|
+
* its own active profile (so the value never changes) while refusing local
|
|
79
|
+
* writes (so nothing can change it), leaving the profile frozen forever. It is
|
|
80
|
+
* also the realistic typo — copying the wrong port out of a unit file.
|
|
81
|
+
*/
|
|
82
|
+
export declare function isSelfTarget(url: string, selfHost: string, selfPort: number): boolean;
|
|
83
|
+
/**
|
|
84
|
+
* Extract `activeProfile` from a `/profiles/list` body.
|
|
85
|
+
*
|
|
86
|
+
* Deliberately paranoid about the shape. The followed instance may be a
|
|
87
|
+
* different version, a different program listening on a recycled port, or an
|
|
88
|
+
* error page — "answers rubbish" is one of the failure modes this must
|
|
89
|
+
* survive, and a non-string or absurdly long value must be treated as no
|
|
90
|
+
* value at all rather than routed to.
|
|
91
|
+
*/
|
|
92
|
+
export declare function readActiveProfile(body: unknown): string | undefined;
|
|
93
|
+
/** A profile the followed instance has, and where its credentials live. */
|
|
94
|
+
export interface FollowedProfile {
|
|
95
|
+
id: string;
|
|
96
|
+
/** Absolute CLAUDE_CONFIG_DIR, on a filesystem both instances can read. */
|
|
97
|
+
credentialDir: string;
|
|
98
|
+
}
|
|
99
|
+
export interface FollowedRoster {
|
|
100
|
+
/** Profiles this instance can serve by pointing at the same directory. */
|
|
101
|
+
adoptable: FollowedProfile[];
|
|
102
|
+
/** Profiles it cannot, because their credentials are an inline secret. */
|
|
103
|
+
unadoptable: string[];
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Extract the profile roster from a `/profiles/list` body.
|
|
107
|
+
*
|
|
108
|
+
* Following one scalar is not enough. `MERIDIAN_CONFIG_DIR` gives a second
|
|
109
|
+
* instance its own `profiles.json` — that is the whole point of it — so the
|
|
110
|
+
* two rosters diverge the moment an account is added to either. The followed
|
|
111
|
+
* value then names a profile this instance does not have, `decideFollowedProfile`
|
|
112
|
+
* returns "unknown-profile", and the dev instance serves from an unrelated
|
|
113
|
+
* account: exactly the divergence follow mode exists to prevent. Measured on
|
|
114
|
+
* one box, a profile added to the primary was still absent from the follower
|
|
115
|
+
* minutes later, and its traffic 429'd against the wrong account.
|
|
116
|
+
*
|
|
117
|
+
* Adoptability is decided by the SENDER, which is the only side that can. A
|
|
118
|
+
* profile authenticated by a file both instances can read crosses as a path; a
|
|
119
|
+
* profile authenticated by an inline API key or OAuth token cannot cross at
|
|
120
|
+
* all, because the secret must not leave the process that holds it. The sender
|
|
121
|
+
* reports the second kind by id alone so this instance can say why an account
|
|
122
|
+
* it can see is one it cannot serve.
|
|
123
|
+
*
|
|
124
|
+
* Returns undefined — distinct from an empty roster — when the body carries no
|
|
125
|
+
* roster information at all. `credentialDir` is emitted for EVERY profile, null
|
|
126
|
+
* included, so its total absence means the followed instance predates this and
|
|
127
|
+
* cannot answer the question. Guessing "nothing is adoptable" there would warn
|
|
128
|
+
* about accounts that are merely unreported.
|
|
129
|
+
*/
|
|
130
|
+
export declare function readFollowedRoster(body: unknown): FollowedRoster | undefined;
|
|
131
|
+
export interface FollowState {
|
|
132
|
+
/** Last value successfully read, and when it was last CONFIRMED by a poll. */
|
|
133
|
+
lastGood?: {
|
|
134
|
+
profileId: string;
|
|
135
|
+
at: number;
|
|
136
|
+
};
|
|
137
|
+
/**
|
|
138
|
+
* Last roster successfully read. Kept across a failed poll for the same
|
|
139
|
+
* reason `lastGood` is: a followed instance that has gone quiet has not
|
|
140
|
+
* withdrawn its accounts, and dropping them would strand every session
|
|
141
|
+
* pinned to one.
|
|
142
|
+
*/
|
|
143
|
+
lastRoster?: {
|
|
144
|
+
roster: FollowedRoster;
|
|
145
|
+
at: number;
|
|
146
|
+
};
|
|
147
|
+
/** When the most recent poll completed, successful or not. */
|
|
148
|
+
lastPollAt?: number;
|
|
149
|
+
/** Most recent poll failure. Cleared on the next success. */
|
|
150
|
+
lastError?: {
|
|
151
|
+
message: string;
|
|
152
|
+
at: number;
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
export type FollowOutcome = {
|
|
156
|
+
follow: true;
|
|
157
|
+
profileId: string;
|
|
158
|
+
stale: boolean;
|
|
159
|
+
} | {
|
|
160
|
+
follow: false;
|
|
161
|
+
reason: "no-value" | "unknown-profile";
|
|
162
|
+
followedValue?: string;
|
|
163
|
+
};
|
|
164
|
+
/**
|
|
165
|
+
* Decide whether the followed value should be used, given what this instance
|
|
166
|
+
* actually has. Pure — the whole point is that every branch is testable
|
|
167
|
+
* without a second instance running.
|
|
168
|
+
*
|
|
169
|
+
* `unknown-profile` is a fallback, not a resolution: routing to a profile this
|
|
170
|
+
* instance does not have would resolve to "first configured profile" deeper in
|
|
171
|
+
* `resolveProfile` and silently serve from an unrelated account. Using the
|
|
172
|
+
* local choice and saying so is the smaller surprise.
|
|
173
|
+
*/
|
|
174
|
+
export declare function decideFollowedProfile(state: FollowState, availableIds: readonly string[], now: number, staleAfterMs?: number): FollowOutcome;
|
|
175
|
+
/**
|
|
176
|
+
* The followed instance's base URL, or undefined when not following.
|
|
177
|
+
*
|
|
178
|
+
* Resolved per call rather than frozen at import time, matching `settings.ts`'s
|
|
179
|
+
* treatment of MERIDIAN_CONFIG_DIR — a value captured at import would be fixed
|
|
180
|
+
* before any test (or embedding host) could set it. Parsing is memoized on the
|
|
181
|
+
* raw string so the request path does not build a URL object per call.
|
|
182
|
+
*/
|
|
183
|
+
export declare function followTarget(): {
|
|
184
|
+
url: string;
|
|
185
|
+
} | undefined;
|
|
186
|
+
/** Whether this instance takes its active profile from another one. */
|
|
187
|
+
export declare function isFollowEnabled(): boolean;
|
|
188
|
+
/**
|
|
189
|
+
* The follow decision for a given profile list, or undefined when not
|
|
190
|
+
* following. Called on the request path — synchronous, cache-only, no I/O.
|
|
191
|
+
*/
|
|
192
|
+
export declare function followedActiveProfile(availableIds: readonly string[]): FollowOutcome | undefined;
|
|
193
|
+
/**
|
|
194
|
+
* Profiles contributed by the followed instance. Called on the request path
|
|
195
|
+
* through `getEffectiveProfiles` — synchronous, cache-only, no I/O.
|
|
196
|
+
*
|
|
197
|
+
* Empty until the first successful poll, so an instance whose followed peer is
|
|
198
|
+
* down starts with its own profiles rather than none.
|
|
199
|
+
*/
|
|
200
|
+
export declare function adoptedProfiles(): readonly FollowedProfile[];
|
|
201
|
+
/** Follow state as surfaced by `/profiles/list`. Undefined when not following. */
|
|
202
|
+
export interface FollowStatus {
|
|
203
|
+
/** Base URL of the followed instance. */
|
|
204
|
+
url: string;
|
|
205
|
+
/** Value actually in effect, or null when falling back to the local one. */
|
|
206
|
+
activeProfile: string | null;
|
|
207
|
+
/** Last value read from the followed instance, even if unusable here. */
|
|
208
|
+
followedValue: string | null;
|
|
209
|
+
/** Why the followed value is not in effect, when it isn't. */
|
|
210
|
+
reason: "no-value" | "unknown-profile" | null;
|
|
211
|
+
/** Followed value has not been confirmed recently — still in effect. */
|
|
212
|
+
stale: boolean;
|
|
213
|
+
/** When the followed value was last confirmed. */
|
|
214
|
+
lastSyncedAt: number | null;
|
|
215
|
+
/** Most recent poll failure, if the last poll failed. */
|
|
216
|
+
lastError: string | null;
|
|
217
|
+
/** Profile ids taken from the followed instance and served here. */
|
|
218
|
+
adoptedProfiles: string[];
|
|
219
|
+
/** Profile ids it has that cannot be adopted, so a UI can say why. */
|
|
220
|
+
unadoptableProfiles: string[];
|
|
221
|
+
/** When the roster was last confirmed, or null if never read. */
|
|
222
|
+
rosterSyncedAt: number | null;
|
|
223
|
+
}
|
|
224
|
+
export declare function followStatus(availableIds: readonly string[]): FollowStatus | undefined;
|
|
225
|
+
/**
|
|
226
|
+
* Read the followed instance's active profile once and update the cache.
|
|
227
|
+
*
|
|
228
|
+
* Never throws and never clears a good value on failure: a failed poll leaves
|
|
229
|
+
* the last known value in place, which is what "degrade, never fail" means
|
|
230
|
+
* here. Exported so tests can drive it without a timer.
|
|
231
|
+
*/
|
|
232
|
+
export declare function pollFollowedActiveProfile(): Promise<void>;
|
|
233
|
+
/**
|
|
234
|
+
* Arm the background poll. Idempotent.
|
|
235
|
+
*
|
|
236
|
+
* `self` is the address this instance actually bound (the configured port may
|
|
237
|
+
* be 0), used only for the self-follow guard.
|
|
238
|
+
*/
|
|
239
|
+
export declare function startFollowPolling(self?: {
|
|
240
|
+
host: string;
|
|
241
|
+
port: number;
|
|
242
|
+
}): void;
|
|
243
|
+
/** Stop the background poll. Idempotent. */
|
|
244
|
+
export declare function stopFollowPolling(): void;
|
|
245
|
+
/**
|
|
246
|
+
* Announce the mode once at startup.
|
|
247
|
+
*
|
|
248
|
+
* Not gated on `silent`, matching the treatment of other non-default operating
|
|
249
|
+
* modes: MERIDIAN_SILENT suppresses routine chatter, and this is not routine —
|
|
250
|
+
* it changes where a core piece of this instance's state comes from. An
|
|
251
|
+
* instance silently following another is exactly the hour-long confusion this
|
|
252
|
+
* line exists to prevent.
|
|
253
|
+
*
|
|
254
|
+
* @param routingMode current routing mode, so the one combination where follow
|
|
255
|
+
* mode does nothing useful says so instead of being discovered the hard way.
|
|
256
|
+
*/
|
|
257
|
+
export declare function logFollowBanner(routingMode?: string): void;
|
|
258
|
+
/** Reset all module state — for testing only. */
|
|
259
|
+
export declare function resetFollowActive(): void;
|
|
260
|
+
/** Seed the cache directly — for testing only. */
|
|
261
|
+
export declare function setFollowStateForTesting(next: FollowState): void;
|
|
262
|
+
//# sourceMappingURL=followActive.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"followActive.d.ts","sourceRoot":"","sources":["../../src/proxy/followActive.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAIH;;;;;;GAMG;AACH,eAAO,MAAM,uBAAuB,QAAS,CAAA;AAE7C,mFAAmF;AACnF,eAAO,MAAM,uBAAuB,OAAQ,CAAA;AAE5C;;;;;;;;;;GAUG;AACH,eAAO,MAAM,qBAAqB,SAAU,CAAA;AAO5C,MAAM,MAAM,YAAY,GACpB;IAAE,IAAI,EAAE,KAAK,CAAA;CAAE,GACf;IAAE,IAAI,EAAE,IAAI,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,GAC3B;IAAE,IAAI,E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mBAAmB,EAAE,MAAM,EAAE,CAAA;IAC7B,iEAAiE;IACjE,cAAc,EAAE,MAAM,GAAG,IAAI,CAAA;CAC9B;AAED,wBAAgB,YAAY,CAAC,YAAY,EAAE,SAAS,MAAM,EAAE,GAAG,YAAY,GAAG,SAAS,CAiBtF;AAED;;;;;;GAMG;AACH,wBAAsB,yBAAyB,IAAI,OAAO,CAAC,IAAI,CAAC,CA8C/D;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,CAAC,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAe9E;AAED,4CAA4C;AAC5C,wBAAgB,iBAAiB,IAAI,IAAI,CAIxC;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,eAAe,CAAC,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAgB1D;AAED,iDAAiD;AACjD,wBAAgB,iBAAiB,IAAI,IAAI,CASxC;AAED,kDAAkD;AAClD,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,WAAW,GAAG,IAAI,CAEhE"}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Which allowance did Anthropic just refuse?
|
|
3
|
+
*
|
|
4
|
+
* An account that has run out keeps reporting healthy percentages: measured on
|
|
5
|
+
* the live fleet, `corp4` rendered `5h 67% / 7d 7%` on /profiles at the same
|
|
6
|
+
* minute its requests were being refused. The cached numbers are a snapshot of
|
|
7
|
+
* the last successful read; a refusal is news that arrives later and never
|
|
8
|
+
* overwrites them. So the refusal has to be recorded and reported on its own
|
|
9
|
+
* terms, next to the cached numbers rather than instead of them.
|
|
10
|
+
*
|
|
11
|
+
* This module answers only the "which bucket, and when does it reset" part.
|
|
12
|
+
* It is a leaf module and every function here is pure - the stores that hold
|
|
13
|
+
* the answers live in profileHealth.ts.
|
|
14
|
+
*
|
|
15
|
+
* Evidence ladder, best source first. The distinction that matters to a reader
|
|
16
|
+
* of the UI is `reported` (Anthropic said so) versus inferred (we worked it
|
|
17
|
+
* out from stale numbers), so every diagnosis carries it explicitly:
|
|
18
|
+
*
|
|
19
|
+
* 1. `sdk_event` - the SDK's own `rate_limit_event` said `rejected` and
|
|
20
|
+
* named `rateLimitType`. Unambiguous.
|
|
21
|
+
* 2. `error_message` - the CLI's prose names the window. Measured live:
|
|
22
|
+
* "You've hit your session limit · resets 12:30am
|
|
23
|
+
* (America/Chicago)" - that is both the bucket (Claude
|
|
24
|
+
* Code calls the 5-hour window a "session") and a real
|
|
25
|
+
* reset clock, so it is worth parsing rather than
|
|
26
|
+
* discarding.
|
|
27
|
+
* 3. `cached_usage` - nothing said which, so deduce from the last-read
|
|
28
|
+
* windows: whichever is nearest its limit, or, when the
|
|
29
|
+
* weekly windows are nowhere near theirs, the 5-hour one
|
|
30
|
+
* by elimination.
|
|
31
|
+
* 4. `unknown` - say so rather than guessing a bucket.
|
|
32
|
+
*
|
|
33
|
+
* There are no `anthropic-ratelimit-*` response headers to read here: Meridian
|
|
34
|
+
* reaches Anthropic through the Claude Agent SDK subprocess, never over HTTP it
|
|
35
|
+
* can see, so `rate_limit_event` IS this proxy's structured form of those
|
|
36
|
+
* headers and tier 1 above is the header check.
|
|
37
|
+
*/
|
|
38
|
+
/** How the bucket was determined. See the ladder in the module doc. */
|
|
39
|
+
export type LimitSource = "sdk_event" | "error_message" | "cached_usage" | "unknown";
|
|
40
|
+
export interface LimitDiagnosis {
|
|
41
|
+
/** Anthropic's window key ("five_hour", "seven_day", "seven_day_opus", …),
|
|
42
|
+
* or null when nothing identified it. */
|
|
43
|
+
bucket: string | null;
|
|
44
|
+
/** True when Anthropic named the bucket; false when we deduced it. Drives
|
|
45
|
+
* the "(guess)" marking in the UI. */
|
|
46
|
+
reported: boolean;
|
|
47
|
+
source: LimitSource;
|
|
48
|
+
/** Epoch ms the window reopens, when known. */
|
|
49
|
+
resetsAt: number | null;
|
|
50
|
+
/** One line explaining the verdict, rendered as the badge's tooltip. */
|
|
51
|
+
rationale: string;
|
|
52
|
+
}
|
|
53
|
+
export interface ParsedLimitWording {
|
|
54
|
+
bucket: string | null;
|
|
55
|
+
/** The qualifier as written, kept for the rationale so an unrecognized one
|
|
56
|
+
* ("daily", "monthly") still tells the reader what the CLI said. */
|
|
57
|
+
qualifier: string | null;
|
|
58
|
+
clock: string | null;
|
|
59
|
+
zone: string | null;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Pull the bucket and reset clock out of an SDK error message. Returns nulls
|
|
63
|
+
* for anything it cannot read - this never throws on unfamiliar prose, because
|
|
64
|
+
* the CLI's wording has changed three times already (#764, #787).
|
|
65
|
+
*/
|
|
66
|
+
export declare function parseLimitWording(errMsg: string): ParsedLimitWording;
|
|
67
|
+
/**
|
|
68
|
+
* Resolve "resets 12:30am (America/Chicago)" to an instant: the next time that
|
|
69
|
+
* wall clock occurs in that zone.
|
|
70
|
+
*
|
|
71
|
+
* The offset is read twice - once at `now`, then again at the candidate - so a
|
|
72
|
+
* reset that lands on the far side of a DST boundary resolves to the right
|
|
73
|
+
* instant rather than being an hour out.
|
|
74
|
+
*
|
|
75
|
+
* Returns null for an unparseable clock or unknown zone. Only ever looks one
|
|
76
|
+
* day ahead, so the result is bounded to ~24h from `now`: the CLI prints a
|
|
77
|
+
* clock time with no date, and a value further out than that would be a
|
|
78
|
+
* misreading, not information.
|
|
79
|
+
*/
|
|
80
|
+
export declare function resolveResetClock(clock: string, zone: string | null | undefined, now: number): number | null;
|
|
81
|
+
export interface SdkLimitEvidence {
|
|
82
|
+
rateLimitType?: string;
|
|
83
|
+
status?: string;
|
|
84
|
+
utilization?: number | null;
|
|
85
|
+
resetsAt?: number | null;
|
|
86
|
+
observedAt: number;
|
|
87
|
+
}
|
|
88
|
+
export interface CachedWindow {
|
|
89
|
+
type: string;
|
|
90
|
+
utilization: number | null;
|
|
91
|
+
resetsAt: number | null;
|
|
92
|
+
}
|
|
93
|
+
export interface DiagnoseLimitInput {
|
|
94
|
+
/** Raw SDK error text, before `classifyError` replaces it with proxy prose. */
|
|
95
|
+
message: string;
|
|
96
|
+
now: number;
|
|
97
|
+
/** This profile's SDK rate-limit entries (rateLimitStore.getAll). */
|
|
98
|
+
sdkEntries?: readonly SdkLimitEvidence[];
|
|
99
|
+
/** This profile's last-read OAuth usage windows. */
|
|
100
|
+
windows?: readonly CachedWindow[];
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Decide which allowance was refused, and say how confident that is.
|
|
104
|
+
*
|
|
105
|
+
* Never throws and always returns a diagnosis - an "unknown" verdict is a
|
|
106
|
+
* useful thing to render ("refusing, cause unknown") and far better than
|
|
107
|
+
* silently attributing the refusal to whichever window happened to look busiest.
|
|
108
|
+
*/
|
|
109
|
+
export declare function diagnoseLimit(input: DiagnoseLimitInput): LimitDiagnosis;
|
|
110
|
+
//# sourceMappingURL=limitDetection.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"limitDetection.d.ts","sourceRoot":"","sources":["../../src/proxy/limitDetection.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AAEH,uEAAuE;AACvE,MAAM,MAAM,WAAW,GAAG,WAAW,GAAG,eAAe,GAAG,cAAc,GAAG,SAAS,CAAA;AAEpF,MAAM,WAAW,cAAc;IAC7B;8CAC0C;IAC1C,MAAM,EAAE,MAAM,GAAG,IAAI,CAAA;IACrB;2CACuC;IACvC,QAAQ,EAAE,OAAO,CAAA;IACjB,MAAM,EAAE,WAAW,CAAA;IACnB,+CAA+C;IAC/C,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAA;IACvB,wEAAwE;IACxE,SAAS,EAAE,MAAM,CAAA;CAClB;AAiCD,MAAM,WAAW,kBAAkB;IACjC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAA;IACrB;yEACqE;IACrE,SAAS,EAAE,MAAM,GAAG,IAAI,CAAA;IACxB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAA;IACpB,IAAI,EAAE,MAAM,GAAG,IAAI,CAAA;CACpB;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,MAAM,GAAG,kBAAkB,CAiBpE;AAsDD;;;;;;;;;;;;GAYG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAgB5G;AASD,MAAM,WAAW,gBAAgB;IAC/B,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAC3B,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACxB,UAAU,EAAE,MAAM,CAAA;CACnB;AAED,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAA;IACZ,WAAW,EAAE,MAAM,GAAG,IAAI,CAAA;IAC1B,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAA;CACxB;AAED,MAAM,WAAW,kBAAkB;IACjC,+EAA+E;IAC/E,OAAO,EAAE,MAAM,CAAA;IACf,GAAG,EAAE,MAAM,CAAA;IACX,qEAAqE;IACrE,UAAU,CAAC,EAAE,SAAS,gBAAgB,EAAE,CAAA;IACxC,oDAAoD;IACpD,OAAO,CAAC,EAAE,SAAS,YAAY,EAAE,CAAA;CAClC;AAQD;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,kBAAkB,GAAG,cAAc,CAgEvE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"models.d.ts","sourceRoot":"","sources":["../../src/proxy/models.ts"],"names":[],"mappings":"AAAA;;GAEG;
|
|
1
|
+
{"version":3,"file":"models.d.ts","sourceRoot":"","sources":["../../src/proxy/models.ts"],"names":[],"mappings":"AAAA;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ared by the two moments a plan can be learned: an interactive login, which
|
|
5
|
+
* has just minted a token, and a token refresh, which has just minted another.
|
|
6
|
+
* It lives in its own module rather than in profileCli.ts because profileCli
|
|
7
|
+
* already imports tokenRefresh for the credential store, so the refresh path
|
|
8
|
+
* importing back would close a cycle.
|
|
9
|
+
*
|
|
10
|
+
* This is a leaf module — one authenticated GET, no imports.
|
|
11
|
+
*/
|
|
12
|
+
interface OAuthProfileResponse {
|
|
13
|
+
organization?: {
|
|
14
|
+
organization_type?: string | null;
|
|
15
|
+
rate_limit_tier?: string | null;
|
|
16
|
+
seat_tier?: string | null;
|
|
17
|
+
} | null;
|
|
18
|
+
}
|
|
19
|
+
export interface OAuthPlanFields {
|
|
20
|
+
subscriptionType?: string;
|
|
21
|
+
rateLimitTier?: string;
|
|
22
|
+
/**
|
|
23
|
+
* Which seat a Team member holds, and the ONLY field that separates a
|
|
24
|
+
* Premium seat from a Standard one. Measured across twelve live accounts:
|
|
25
|
+
* every Premium seat reports `rate_limit_tier: "default_claude_max_5x"` —
|
|
26
|
+
* byte-identical to what a personal Max 5x reports — and a Standard seat
|
|
27
|
+
* reports `default_raven`, a codename naming no published allotment. So the
|
|
28
|
+
* rate-limit tier can size neither kind of Team seat: one because it lies
|
|
29
|
+
* and one because it says nothing. Null on every personal account.
|
|
30
|
+
*/
|
|
31
|
+
seatTier?: string;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Translate Anthropic's wire `organization_type` into the vocabulary the Claude
|
|
35
|
+
* CLI writes on disk — the wire value is prefixed (`claude_max`), the stored one
|
|
36
|
+
* is not (`max`). Mirroring the CLI's own mapping is what keeps a credential
|
|
37
|
+
* file Meridian writes indistinguishable from one `claude login` wrote, which
|
|
38
|
+
* matters because `claude auth status` reads it back and is what ultimately
|
|
39
|
+
* feeds `/profiles/list`, `/health` and the `max`-only branch of `/v1/models`.
|
|
40
|
+
*
|
|
41
|
+
* An unrecognized or absent type yields undefined so the caller omits the key,
|
|
42
|
+
* rather than inventing a plan for an account it could not identify.
|
|
43
|
+
*/
|
|
44
|
+
export declare function subscriptionTypeFromOrganizationType(organizationType: string | null | undefined): string | undefined;
|
|
45
|
+
export declare function extractPlanFields(profile: OAuthProfileResponse | null | undefined): OAuthPlanFields;
|
|
46
|
+
/**
|
|
47
|
+
* Whether a stored credential is still missing plan information.
|
|
48
|
+
*
|
|
49
|
+
* Either field being absent counts, because they answer different questions
|
|
50
|
+
* and arrive from different writers: `claude login` records `subscriptionType`
|
|
51
|
+
* but not always `rateLimitTier`, and only `rateLimitTier` distinguishes Max 5x
|
|
52
|
+
* from Max 20x. Requiring both means a file half-filled by the CLI still gets
|
|
53
|
+
* completed.
|
|
54
|
+
*/
|
|
55
|
+
export declare function planFieldsMissing(fields: OAuthPlanFields | null | undefined): boolean;
|
|
56
|
+
/**
|
|
57
|
+
* Best-effort plan lookup for a valid access token. Never throws and never
|
|
58
|
+
* fails its caller: a profile whose plan is unknown is strictly better than no
|
|
59
|
+
* profile at all, and every consumer already treats it as optional.
|
|
60
|
+
*/
|
|
61
|
+
export declare function fetchOAuthPlanFields(accessToken: string): Promise<OAuthPlanFields>;
|
|
62
|
+
export {};
|
|
63
|
+
//# sourceMappingURL=oauthPlan.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"oauthPlan.d.ts","sourceRoot":"","sources":["../../src/proxy/oauthPlan.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAkBH,UAAU,oBAAoB;IAC5B,YAAY,CAAC,EAAE;QACb,iBAAiB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;QACjC,eAAe,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;QAC/B,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;KAC1B,GAAG,IAAI,CAAA;CACT;AAED,MAAM,WAAW,eAAe;IAC9B,gBAAgB,CAAC,EAAE,MAAM,CAAA;IACzB,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB;;;;;;;;OAQG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAA;CAClB;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,oCAAoC,CAClD,gBAAgB,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAC1C,MAAM,GAAG,SAAS,CAQpB;AAED,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,oBAAoB,GAAG,IAAI,GAAG,SAAS,GAAG,eAAe,CASnG;AAED;;;;;;;;GAQG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,eAAe,GAAG,IAAI,GAAG,SAAS,GAAG,OAAO,CAErF;AAED;;;;GAIG;AACH,wBAAsB,oBAAoB,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC,CAuCxF"}
|
|
@@ -56,12 +56,65 @@ export interface OAuthUsageSnapshot {
|
|
|
56
56
|
* plainly rather than as a generic upstream failure.
|
|
57
57
|
*/
|
|
58
58
|
export type OAuthUsageError = "no_token" | "rate_limited" | "upstream_error";
|
|
59
|
-
/**
|
|
60
|
-
|
|
59
|
+
/** What a fetch produced, before provenance is attached. Internal: every
|
|
60
|
+
* public exit goes through `withProvenance`. */
|
|
61
|
+
interface RawUsageResult {
|
|
61
62
|
snapshot: OAuthUsageSnapshot | null;
|
|
62
63
|
/** Set only when `snapshot` is null. */
|
|
63
64
|
error: OAuthUsageError | null;
|
|
64
65
|
}
|
|
66
|
+
/**
|
|
67
|
+
* The run of failed checks since the last successful one.
|
|
68
|
+
*
|
|
69
|
+
* `consecutiveFailures` counts checks that actually reached the credential
|
|
70
|
+
* store or upstream — not polls the 429 cooldown turned away before they got
|
|
71
|
+
* there. The quota page polls every 10s while a backoff runs for a minute or
|
|
72
|
+
* more, so counting suppressed polls would report six failures for one refusal,
|
|
73
|
+
* which says more about the poll interval than about the account.
|
|
74
|
+
*/
|
|
75
|
+
export interface OAuthUsageFailure {
|
|
76
|
+
reason: OAuthUsageError;
|
|
77
|
+
/** Always >= 1 — a success clears the record rather than zeroing it. */
|
|
78
|
+
consecutiveFailures: number;
|
|
79
|
+
lastFailureAt: number;
|
|
80
|
+
}
|
|
81
|
+
/** A usage fetch outcome: the snapshot, or why there isn't one. */
|
|
82
|
+
export interface OAuthUsageResult extends RawUsageResult {
|
|
83
|
+
/** The failing run in progress, or null when the last check succeeded.
|
|
84
|
+
* Independent of `snapshot`/`error`: a stale snapshot served inside the
|
|
85
|
+
* bound reports `error: null`, and a reader still needs to know the figures
|
|
86
|
+
* are standing in for a check that didn't land. */
|
|
87
|
+
failure: OAuthUsageFailure | null;
|
|
88
|
+
/** Last successful reading for this profile at any age — including past the
|
|
89
|
+
* point `staleOr` stops serving it as `snapshot`. Lets a display keep the
|
|
90
|
+
* last known numbers, labelled, instead of blanking. */
|
|
91
|
+
lastGood: OAuthUsageSnapshot | null;
|
|
92
|
+
}
|
|
93
|
+
/** The per-profile usage shape the quota routes serve. */
|
|
94
|
+
export interface UsageEntryFields {
|
|
95
|
+
windows: OAuthUsageWindow[];
|
|
96
|
+
extraUsage: OAuthExtraUsageInfo | null;
|
|
97
|
+
fetchedAt: number | null;
|
|
98
|
+
/** True when the figures are a previous reading rather than one taken by the
|
|
99
|
+
* check that just ran. */
|
|
100
|
+
stale: boolean;
|
|
101
|
+
error: OAuthUsageError | null;
|
|
102
|
+
failure: OAuthUsageFailure | null;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Shape a fetch result for a consumer that renders it to a human.
|
|
106
|
+
*
|
|
107
|
+
* Three states a caller must be able to tell apart, and which bare numbers
|
|
108
|
+
* cannot:
|
|
109
|
+
* never read — no figures at all: `fetchedAt` null, `stale` false.
|
|
110
|
+
* read and fresh — `stale` false, `failure` null.
|
|
111
|
+
* read then stale — figures as of `fetchedAt`, `stale` true, `failure` saying
|
|
112
|
+
* why the newer check didn't land and how many in a row.
|
|
113
|
+
*
|
|
114
|
+
* A window sitting at 0% and a profile that has never been read flatten to the
|
|
115
|
+
* same numbers, so the distinction has to travel as its own field.
|
|
116
|
+
*/
|
|
117
|
+
export declare function toUsageEntry(result: OAuthUsageResult): UsageEntryFields;
|
|
65
118
|
/** Minimal fetch shape used by callAnthropic. Avoids `typeof fetch`'s
|
|
66
119
|
* `preconnect` property, which makes test casts unwieldy. */
|
|
67
120
|
type FetchLike = (input: string, init?: RequestInit) => Promise<Response>;
|
|
@@ -109,6 +162,16 @@ export declare function fetchOAuthUsage(opts?: FetchOAuthUsageOpts): Promise<OAu
|
|
|
109
162
|
* remains for callers that only act on the numbers.
|
|
110
163
|
*/
|
|
111
164
|
export declare function fetchOAuthUsageResult(opts?: FetchOAuthUsageOpts): Promise<OAuthUsageResult>;
|
|
165
|
+
/**
|
|
166
|
+
* Last-read snapshot for a profile, without fetching.
|
|
167
|
+
*
|
|
168
|
+
* For the error path, which needs the cached windows to work out WHICH
|
|
169
|
+
* allowance was just refused and must not add a network round trip to a request
|
|
170
|
+
* that has already failed. Returns undefined when nothing has been read yet;
|
|
171
|
+
* a stale snapshot is deliberately still returned, because "what we last read"
|
|
172
|
+
* is exactly the evidence being reasoned about there.
|
|
173
|
+
*/
|
|
174
|
+
export declare function peekOAuthUsage(profileId?: string | null): OAuthUsageSnapshot | undefined;
|
|
112
175
|
/** Test-only / shutdown helper — clears all cached snapshots and pending fetches. */
|
|
113
176
|
export declare function resetOAuthUsageCache(): void;
|
|
114
177
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"oauthUsage.d.ts","sourceRoot":"","sources":["../../src/proxy/oauthUsage.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAIH,OAAO,EAAoD,KAAK,eAAe,EAAE,MAAM,gBAAgB,CAAA;AA6CvG,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,CAAA;IACZ,WAAW,EAAE,MAAM,GAAG,IAAI,CAAA;IAC1B,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAA;CACxB;AAED,MAAM,WAAW,mBAAm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nB,iEAAiE;IACjE,kBAAkB,CAAC,EAAE,MAAM,CAAA;IAC3B,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,KAAK,CAAC,EAAE,eAAe,CAAA;IACvB,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACzB,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB,SAAS,CAAC,EAAE,SAAS,CAAA;CACtB;AAcD,8CAA8C;AAC9C,wBAAgB,4BAA4B,CAC1C,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,EAAE,mBAAmB,KAAK,OAAO,CAAC,kBAAkB,GAAG,IAAI,CAAC,CAAC,GAAG,IAAI,GAC9E,IAAI,CAEN;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAsB,eAAe,CAAC,IAAI,CAAC,EAAE,mBAAmB,GAAG,OAAO,CAAC,kBAAkB,GAAG,IAAI,CAAC,CAEpG;AASD;;;;GAIG;AACH,wBAAsB,qBAAqB,CAAC,IAAI,CAAC,EAAE,mBAAmB,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAmBjG;AAgHD;;;;;;;;GAQG;AACH,wBAAgB,cAAc,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,kBAAkB,GAAG,SAAS,CAExF;AAED,qFAAqF;AACrF,wBAAgB,oBAAoB,IAAI,IAAI,CAK3C"}
|
package/dist/proxy/openai.d.ts
CHANGED
|
@@ -12,8 +12,10 @@
|
|
|
12
12
|
* 2. Prior turns are packed into a <conversation_history> block in the
|
|
13
13
|
* system prompt so Claude has context
|
|
14
14
|
* 3. Each chat completions request gets a fresh SDK session
|
|
15
|
-
*
|
|
16
|
-
*
|
|
15
|
+
* A request that carries a session key the adapter recognizes (Jcode's
|
|
16
|
+
* x-jcode-session, or the OpenCode-family x-opencode-session /
|
|
17
|
+
* x-session-affinity) is exempt: it keeps its real messages and resumes like
|
|
18
|
+
* any keyed client. An unkeyed request keeps the packing above.
|
|
17
19
|
*/
|
|
18
20
|
export type OpenAiRole = "system" | "user" | "assistant" | "tool";
|
|
19
21
|
export interface OpenAiTextPart {
|
|
@@ -85,6 +87,8 @@ export interface OpenAiChatRequest {
|
|
|
85
87
|
export interface OpenAiTranslationOptions {
|
|
86
88
|
/** Keep append-only turns intact so Meridian can verify and resume lineage. */
|
|
87
89
|
preserveConversationHistory?: boolean;
|
|
90
|
+
/** Providers without native reasoning blocks must retain literal markup. */
|
|
91
|
+
preserveThinkingText?: boolean;
|
|
88
92
|
}
|
|
89
93
|
export interface AnthropicTextBlock {
|
|
90
94
|
type: "text";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"openai.d.ts","sourceRoot":"","sources":["../../src/proxy/openai.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"openai.d.ts","sourceRoot":"","sources":["../../src/proxy/openai.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAQH,MAAM,MAAM,UAAU,GAAG,QAAQ,GAAG,MAAM,GAAG,WAAW,GAAG,MAAM,CAAA;AAEjE,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,CAAC,EAAE,MAAM,CAAA;CACd;AAED,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,WAAW,CAAA;IACjB,SAAS,CAAC,EAAE;QACV,GAAG,CAAC,EAAE,MAAM,CAAA;KACb,CAAA;CACF;AAED,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,SAAS,CAAC,EAAE;QACV,GAAG,CAAC,EAAE,MAAM,CAAA;KACb,CAAA;CACF;AAED,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,UAAU,CAAA;IAChB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,OAAO,EAAE,MAAM,GAAG,iBAAiB,EAAE,CAAA;IACrC,UAAU,CAAC,EAAE,wBAAwB,EAA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