@rynfar/meridian 1.71.1 → 1.73.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 +115 -162
- package/assets/desktop-dashboard.jpg +0 -0
- package/assets/trayTemplate.png +0 -0
- package/assets/trayTemplate@2x.png +0 -0
- package/assets/trayTemplate@3x.png +0 -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-grfp0s1j.js +330 -0
- package/dist/{cli-ryt69ryf.js → cli-p5zbk952.js} +2185 -358
- package/dist/{cli-8yp89fan.js → cli-p9ca4p13.js} +17 -2
- package/dist/cli-qpfky8wy.js +133 -0
- package/dist/cli.js +47 -12
- 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-n3gdtbmj.js → pluginPage-3kxsrdpj.js} +1 -1
- package/dist/{profileCli-1eecbmgk.js → profileCli-1bfgc05h.js} +13 -3
- package/dist/{profilePage-vfj2dbhn.js → profilePage-etxqg3vn.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/authDiscovery.d.ts +52 -0
- package/dist/proxy/authDiscovery.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/errors.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 +4 -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/session/processIncarnation.d.ts +7 -0
- package/dist/proxy/session/processIncarnation.d.ts.map +1 -1
- package/dist/proxy/sessionLifecycle.d.ts +8 -1
- package/dist/proxy/sessionLifecycle.d.ts.map +1 -1
- package/dist/proxy/sessionStore.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/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 +10 -2
- 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/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 +2 -1
- 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
|
@@ -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 {
|
|
@@ -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,EAAE,CAAA;CACxC;AAED,MAAM,WAAW,sBAAsB;IACrC,IAAI,EAAE,UAAU,CAAA;IAChB,QAAQ,EAAE;QACR,IAAI,EAAE,MAAM,CAAA;QACZ,WAAW,CAAC,EAAE,MAAM,CAAA;QACpB,UAAU,EAAE,OAAO,CAAA;QACnB,MAAM,CAAC,EAAE,OAAO,CAAA;KACjB,CAAA;CACF;AAED,MAAM,WAAW,oBAAoB;IACnC,IAAI,EAAE,QAAQ,CA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,CAAA;KAAE,GAC/B;QAAE,IAAI,EAAE,UAAU,CAAC;QAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;KAAE,GACvC,qBAAqB,CAAA;IACzB,OAAO,CAAC,EAAE;QAAE,EAAE,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,cAAc,CAAA;KAAE,CAAA;IACjD,KAAK,CAAC,EAAE,cAAc,CAAA;CACvB;AAED,MAAM,WAAW,aAAa;IAC5B,CAAC,KAAK,EAAE,iBAAiB,GAAG,iBAAiB,GAAG,IAAI,CAAA;IACpD,eAAe,IAAI,iBAAiB,GAAG,IAAI,CAAA;CAC5C;AAED,MAAM,WAAW,oBAAoB;IACnC,YAAY,EAAE,MAAM,CAAA;IACpB,KAAK,EAAE,MAAM,CAAA;IACb,OAAO,EAAE,MAAM,CAAA;IACf,iEAAiE;IACjE,mBAAmB,CAAC,EAAE,OAAO,CAAA;IAC7B,YAAY,CAAC,EAAE,OAAO,CAAA;CACvB;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,oBAAoB,GAAG,aAAa,CAyD5E;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,0BAA0B,CACxC,KAAK,EAAE,iBAAiB,EACxB,YAAY,EAAE,MAAM,EACpB,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,MAAM,EACf,WAAW,EAAE,MAAM,EACnB,mBAAmB,CAAC,EAAE,OAAO,GAC5B,iBAAiB,GAAG,IAAI,CA2H1B;AAgCD;;;;;;;;;GASG;AACH,wBAAgB,cAAc,CAAC,uBAAuB,EAAE,OAAO,EAAE,GAAG,SAAgC,GAAG,WAAW,EAAE,CAoFnH"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The organization an account belongs to, as Anthropic names it.
|
|
3
|
+
*
|
|
4
|
+
* `GET /api/oauth/profile` answers `organization.name` — the human label for
|
|
5
|
+
* the account behind a profile. A fleet whose profiles are called `work2` and
|
|
6
|
+
* `corp3` is told apart by that label and by nothing else on the card.
|
|
7
|
+
*
|
|
8
|
+
* WHERE IT IS KEPT. `.credentials.json` already holds `subscriptionType` and
|
|
9
|
+
* `rateLimitTier`, so it looks like the natural home — but those are Claude
|
|
10
|
+
* Code's OWN keys. Meridian writes that file to be indistinguishable from one
|
|
11
|
+
* `claude login` wrote, and a Meridian-invented key breaks that deliberately;
|
|
12
|
+
* worse, Claude Code rewrites the file on its next refresh and would drop the
|
|
13
|
+
* key, so it would not even survive. This is Meridian's own file, beside
|
|
14
|
+
* settings.json, and neither objection applies to it.
|
|
15
|
+
*
|
|
16
|
+
* WHY IT IS CACHED. The render path must not make an authenticated round trip
|
|
17
|
+
* per profile: two pages poll `/profiles/list` every 10s and a fleet is a dozen
|
|
18
|
+
* accounts, which is a dozen requests to Anthropic every ten seconds for a
|
|
19
|
+
* string that changes approximately never. So reads are synchronous and
|
|
20
|
+
* cache-only, and a stale entry is refreshed in the background — the response
|
|
21
|
+
* never waits on the network.
|
|
22
|
+
*
|
|
23
|
+
* Leaf module — no imports from server.ts or session/.
|
|
24
|
+
*/
|
|
25
|
+
import { type CredentialStore } from "./tokenRefresh";
|
|
26
|
+
/** How old an entry may get before a background refresh is worth making. */
|
|
27
|
+
export declare const ORGANIZATION_REFRESH_AFTER_MS: number;
|
|
28
|
+
/** Floor between two lookups for one profile, successful or not, so an
|
|
29
|
+
* unreachable Anthropic cannot be retried once per 10s poll forever. */
|
|
30
|
+
export declare const ORGANIZATION_RETRY_AFTER_MS: number;
|
|
31
|
+
export interface OrganizationRecord {
|
|
32
|
+
name: string;
|
|
33
|
+
fetchedAt: number;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Read a record map out of whatever the file actually holds. Hand-editable and
|
|
37
|
+
* written by other versions, so an entry that is not a usable name is dropped
|
|
38
|
+
* rather than served.
|
|
39
|
+
*/
|
|
40
|
+
export declare function readOrganizations(raw: unknown): Record<string, OrganizationRecord>;
|
|
41
|
+
/**
|
|
42
|
+
* Pull the name out of an `/api/oauth/profile` body.
|
|
43
|
+
*
|
|
44
|
+
* Nullable in principle even though every account measured has one, so an
|
|
45
|
+
* absent name yields null and the caller renders nothing rather than "unknown".
|
|
46
|
+
*/
|
|
47
|
+
export declare function extractOrganizationName(body: unknown): string | null;
|
|
48
|
+
export declare function organizationNeedsRefresh(record: OrganizationRecord | undefined, now: number, refreshAfterMs?: number): boolean;
|
|
49
|
+
/** Every organization on record, keyed by profile id. */
|
|
50
|
+
export declare function organizationNames(): Record<string, OrganizationRecord>;
|
|
51
|
+
export declare function rememberOrganizationName(profileId: string, name: string): void;
|
|
52
|
+
type FetchLike = (input: string, init?: RequestInit) => Promise<Response>;
|
|
53
|
+
/**
|
|
54
|
+
* Best-effort lookup for one account. Never throws and never fails its caller:
|
|
55
|
+
* a profile whose organization is unknown is strictly better than a page that
|
|
56
|
+
* will not render.
|
|
57
|
+
*/
|
|
58
|
+
export declare function fetchOrganizationName(store: CredentialStore, fetchImpl?: FetchLike): Promise<string | null>;
|
|
59
|
+
export declare function enableOrganizationLookup(): void;
|
|
60
|
+
export interface RefreshOrganizationOpts {
|
|
61
|
+
claudeConfigDir?: string;
|
|
62
|
+
store?: CredentialStore;
|
|
63
|
+
fetchImpl?: FetchLike;
|
|
64
|
+
retryAfterMs?: number;
|
|
65
|
+
}
|
|
66
|
+
/** Learn one profile's organization in the background. Returns immediately. */
|
|
67
|
+
export declare function refreshOrganizationNameSoon(profileId: string, opts?: RefreshOrganizationOpts): void;
|
|
68
|
+
/** Reset module state — for testing only. */
|
|
69
|
+
export declare function resetOrganizationLookupForTesting(): void;
|
|
70
|
+
export {};
|
|
71
|
+
//# sourceMappingURL=organizationName.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"organizationName.d.ts","sourceRoot":"","sources":["../../src/proxy/organizationName.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAMH,OAA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ED,+EAA+E;AAC/E,wBAAgB,2BAA2B,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,GAAE,uBAA4B,GAAG,IAAI,CAsBvG;AAED,6CAA6C;AAC7C,wBAAgB,iCAAiC,IAAI,IAAI,CAIxD"}
|
|
@@ -113,6 +113,16 @@ export interface CompleteToolResultContinuationOptions {
|
|
|
113
113
|
*/
|
|
114
114
|
allowTrailingSystemReminder?: boolean;
|
|
115
115
|
}
|
|
116
|
+
/**
|
|
117
|
+
* Detect mid-conversation effort metadata system messages (e.g. pi >= 0.85.0
|
|
118
|
+
* Persistent Claude thinking effort). These carry effort metadata in
|
|
119
|
+
* `output_config` with empty content and no tool ids or text instructions.
|
|
120
|
+
*/
|
|
121
|
+
export declare function isMidConvoEffortSystemMessage(message: {
|
|
122
|
+
role?: unknown;
|
|
123
|
+
content?: unknown;
|
|
124
|
+
output_config?: unknown;
|
|
125
|
+
} | null | undefined): boolean;
|
|
116
126
|
/**
|
|
117
127
|
* Verify that a resumed tool-result delta settles exactly the tool calls at the
|
|
118
128
|
* stored assistant checkpoint, then coalesce queued user turns into one SDK
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"passthroughEarlyStop.d.ts","sourceRoot":"","sources":["../../src/proxy/passthroughEarlyStop.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AAYH,MAAM,WAAW,gBAAgB;IAC/B,gFAAgF;IAChF,QAAQ,EAAE,GAAG,CAAC,MAAM,CAAC,CAAA;IACrB,6EAA6E;IAC7E,QAAQ,EAAE,GAAG,CAAC,MAAM,CAAC,CAAA;IACrB;yEACqE;IACrE,qBAAqB,CAAC,EAAE,MAAM,CAAA;IAC9B,0EAA0E;IAC1E,KAAK,EAAE,OAAO,CAAA;CACf;AAED,wBAAgB,sBAAsB,IAAI,gBAAgB,CAEzD;AAED;;;;;;;GAOG;AACH,MAAM,WAAW,sBAAsB;IACrC,IAAI,EA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ACH,wBAAgB,sBAAsB,CAAC,KAAK,EAAE;IAC5C,oBAAoB,EAAE,OAAO,CAAA;IAC7B,gBAAgB,CAAC,EAAE,MAAM,CAAA;IACzB,gBAAgB,CAAC,EAAE,MAAM,CAAA;IACzB,mBAAmB,EAAE,OAAO,CAAA;IAC5B,qBAAqB,CAAC,EAAE,MAAM,CAAA;IAC9B,oEAAoE;IACpE,WAAW,EAAE,OAAO,CAAA;CACrB,GAAG,sBAAsB,CAMzB"}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Plan → coding-allotment multiplier.
|
|
3
|
+
*
|
|
4
|
+
* Anthropic sizes a plan's Claude Code allotment as a multiple of the Pro
|
|
5
|
+
* baseline — 5x, 20x, 6.25x — and that number, not the plan name, is what says
|
|
6
|
+
* how much work an account can actually do. Two accounts both reporting
|
|
7
|
+
* `Plan: max` can differ by 4x in capacity, so a page that shows only the plan
|
|
8
|
+
* cannot tell the user which account has room left.
|
|
9
|
+
*
|
|
10
|
+
* The multiplier is derived from the raw strings the profile endpoint returns
|
|
11
|
+
* — `seatTier` for a Team account, `rateLimitTier` otherwise — rather than
|
|
12
|
+
* from `subscriptionType`, because that field is too coarse: it collapses Max
|
|
13
|
+
* 5x and Max 20x into the single word `max`, and Team Standard and Team
|
|
14
|
+
* Premium into `team`. `subscriptionType` names the family and is used for the
|
|
15
|
+
* size only as a fallback for the one tier it pins unambiguously.
|
|
16
|
+
*
|
|
17
|
+
* An unrecognized tier yields null rather than a default, which is the whole
|
|
18
|
+
* point of the field: rendering `1x` for an account that is really 20x is
|
|
19
|
+
* worse than rendering nothing, because a reader acts on it.
|
|
20
|
+
*
|
|
21
|
+
* This is a leaf module — pure, no I/O, no imports.
|
|
22
|
+
*/
|
|
23
|
+
export interface PlanAllowance {
|
|
24
|
+
/** Multiplier as displayed, e.g. `"20x"`. Null when the tier is unknown. */
|
|
25
|
+
multiplier: string | null;
|
|
26
|
+
/**
|
|
27
|
+
* The same value as a number, so callers can weight or rank accounts without
|
|
28
|
+
* re-parsing the label. Null whenever `multiplier` is.
|
|
29
|
+
*/
|
|
30
|
+
weight: number | null;
|
|
31
|
+
/** Tier label, e.g. `"Personal Max"`. Null when the tier is unknown. */
|
|
32
|
+
label: string | null;
|
|
33
|
+
/**
|
|
34
|
+
* Which side of Anthropic's pricing the account sits on — `"Personal"`,
|
|
35
|
+
* `"Team"` or `"Enterprise"`. Separate from `planName` because the two are
|
|
36
|
+
* answered by different fields and either can be known without the other: an
|
|
37
|
+
* account whose family is declared but whose tier is unrecognized still has
|
|
38
|
+
* a trustworthy family.
|
|
39
|
+
*/
|
|
40
|
+
accountType: string | null;
|
|
41
|
+
/**
|
|
42
|
+
* The plan WITHIN that family, in the vocabulary of Anthropic's own pricing
|
|
43
|
+
* page: `"Max 20x"`, `"Max 5x"`, `"Pro"`, `"Free"` for personal accounts and
|
|
44
|
+
* `"Premium seat"` / `"Standard seat"` for Team ones.
|
|
45
|
+
*
|
|
46
|
+
* Null when the family is known but the plan is not — which is the common
|
|
47
|
+
* case for a Team seat with no `seat_tier`, since its `rate_limit_tier`
|
|
48
|
+
* reports the underlying bucket rather than the seat.
|
|
49
|
+
*/
|
|
50
|
+
planName: string | null;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Reduce a raw tier string to the form the table below is keyed by.
|
|
54
|
+
*
|
|
55
|
+
* Anthropic prefixes the wire value (`default_claude_max_20x`) and separates
|
|
56
|
+
* words with underscores; the same tier also appears bare (`max_20x`) in
|
|
57
|
+
* places, and `team_tier_1` is the wire spelling of what the pricing page
|
|
58
|
+
* calls Team Premium. Normalizing first means one entry per tier instead of
|
|
59
|
+
* one per spelling.
|
|
60
|
+
*/
|
|
61
|
+
export declare function normalizeRateLimitTier(raw: string | null | undefined): string | null;
|
|
62
|
+
/**
|
|
63
|
+
* Derive the allowance from whatever plan fields a credential file carries.
|
|
64
|
+
*
|
|
65
|
+
* Both arguments are optional because both are optional on disk: a profile
|
|
66
|
+
* written before the plan was persisted has neither, and one written by an
|
|
67
|
+
* older Meridian has only `subscriptionType`. Every unknown case returns the
|
|
68
|
+
* same all-null shape, so callers can render conditionally on one field.
|
|
69
|
+
*/
|
|
70
|
+
export declare function planAllowance(fields: {
|
|
71
|
+
rateLimitTier?: string | null;
|
|
72
|
+
seatTier?: string | null;
|
|
73
|
+
subscriptionType?: string | null;
|
|
74
|
+
} | null | undefined): PlanAllowance;
|
|
75
|
+
//# sourceMappingURL=planAllowance.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"planAllowance.d.ts","sourceRoot":"","sources":["../../src/proxy/planAllowance.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,MAAM,WAAW,aAAa;IAC5B,4EAA4E;IAC5E,UAAU,EAAE,MAAM,GAAG,IAAI,CAAA;IACzB;;;OAGG;IACH,MAAM,EAAE,MAAM,GAAG,IAAI,CAAA;IACrB,wEAAwE;IACxE,KAAK,EAAE,MAAM,GAAG,IAAI,CAAA;IACpB;;;;;;OAMG;IACH,WAAW,EAAE,MAAM,GAAG,IAAI,CAAA;IAC1B;;;;;;;;OAQG;IACH,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAA;CACxB;AA4BD;;;;;;;;GAQG;AACH,wBAAgB,sBAAsB,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,MAAM,GAAG,IAAI,CASpF;AAwED;;;;;;;GAOG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE;IACpC,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAC7B,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACxB,gBAAgB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CACjC,GAAG,IAAI,GAAG,SAAS,GAAG,aAAa,CAkBnC"}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Liveness and readiness as two DIFFERENT questions, because the existing
|
|
3
|
+
* `/health` answers a third one and is wrong when used as either.
|
|
4
|
+
*
|
|
5
|
+
* `/health` verifies the ACTIVE profile's auth: it spawns `claude auth status`
|
|
6
|
+
* and returns 503 when that profile is logged out. As a liveness probe that is
|
|
7
|
+
* a restart loop waiting to happen - a logged-out account is not fixed by
|
|
8
|
+
* killing the process, and a supervisor pointed at it will keep killing a
|
|
9
|
+
* perfectly healthy proxy until somebody re-authenticates. As a readiness probe
|
|
10
|
+
* it is wrong in the other direction: it inspects one profile out of however
|
|
11
|
+
* many are configured, and its own catch-all answers `degraded` with status
|
|
12
|
+
* **200**, so an instance that cannot verify auth at all reads as ready.
|
|
13
|
+
*
|
|
14
|
+
* So:
|
|
15
|
+
*
|
|
16
|
+
* /livez is this PROCESS still turning - would a restart help?
|
|
17
|
+
* /readyz should traffic be sent to THIS instance rather than another?
|
|
18
|
+
*
|
|
19
|
+
* Named after kube-apiserver's own endpoints, and shaped like them - plain
|
|
20
|
+
* text `ok`, with `?verbose` listing every check - so a Kubernetes probe, a
|
|
21
|
+
* Caddy `health_uri` and a person with curl all read the same thing.
|
|
22
|
+
*/
|
|
23
|
+
export type ProbeKind = "livez" | "readyz";
|
|
24
|
+
export interface ProbeCheck {
|
|
25
|
+
readonly name: string;
|
|
26
|
+
readonly ok: boolean;
|
|
27
|
+
/** Why it failed. Absent when it passed. */
|
|
28
|
+
readonly detail?: string;
|
|
29
|
+
}
|
|
30
|
+
export interface ProbeReport {
|
|
31
|
+
readonly ok: boolean;
|
|
32
|
+
readonly checks: readonly ProbeCheck[];
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Liveness passes unconditionally, and that is the design rather than a stub.
|
|
36
|
+
*
|
|
37
|
+
* Reaching this function at all means the event loop is turning and the HTTP
|
|
38
|
+
* server is answering, which is the entire question. Every dependency added
|
|
39
|
+
* here - a subprocess, a credential file, a reachable upstream - is another
|
|
40
|
+
* way for this process to be killed over somebody else's outage, and a
|
|
41
|
+
* liveness probe that restarts a working process is strictly worse than no
|
|
42
|
+
* liveness probe at all.
|
|
43
|
+
*/
|
|
44
|
+
export declare function livenessReport(): ProbeReport;
|
|
45
|
+
export interface ReadinessInput {
|
|
46
|
+
/** Profiles this instance would actually serve from. */
|
|
47
|
+
readonly profileCount: number;
|
|
48
|
+
/** Whether a Claude executable resolves for this instance. */
|
|
49
|
+
readonly claudeExecutableResolved: boolean;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Readiness admits only checks that are PER-INSTANCE.
|
|
53
|
+
*
|
|
54
|
+
* The point of readiness is to move traffic somewhere better, so a check that
|
|
55
|
+
* two instances fail together cannot move it anywhere - it can only take every
|
|
56
|
+
* instance out at once and turn a clear error into a 502. That is why the
|
|
57
|
+
* credentials are deliberately not checked here even though a proxy with no
|
|
58
|
+
* usable token serves nothing: instances share those files, so an outage of
|
|
59
|
+
* them is not a reason to prefer one instance over another, and the honest
|
|
60
|
+
* answer to the caller is the provider's own 401 rather than a gateway error.
|
|
61
|
+
*
|
|
62
|
+
* What remains is genuinely local to one process:
|
|
63
|
+
*
|
|
64
|
+
* profiles an instance whose configuration and whose
|
|
65
|
+
* `profiles.json` are both empty has no account to serve
|
|
66
|
+
* from, while a neighbour reading a populated one is
|
|
67
|
+
* fine. In a container that is entirely per-instance: the
|
|
68
|
+
* file lives under that container's own HOME, so a
|
|
69
|
+
* missing mount takes exactly one replica out.
|
|
70
|
+
* claude-executable resolved from `MERIDIAN_CLAUDE_PATH`, this install's
|
|
71
|
+
* own `node_modules`, or its platform package - all
|
|
72
|
+
* per-instance, and without one no request can be served
|
|
73
|
+
* (#478).
|
|
74
|
+
*/
|
|
75
|
+
export declare function readinessReport(input: ReadinessInput): ProbeReport;
|
|
76
|
+
/**
|
|
77
|
+
* kube-apiserver's own output shape: `[+]name ok` per check, a verdict line,
|
|
78
|
+
* and a bare `ok` when everything passed and nobody asked for detail.
|
|
79
|
+
*
|
|
80
|
+
* The terse form is the one a load balancer polls every few seconds, so it
|
|
81
|
+
* stays two bytes; the failing form names the checks that failed even without
|
|
82
|
+
* `?verbose`, because a 503 nobody can explain is a 503 somebody disables.
|
|
83
|
+
*/
|
|
84
|
+
export declare function renderProbe(kind: ProbeKind, report: ProbeReport, verbose: boolean): string;
|
|
85
|
+
//# sourceMappingURL=probes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"probes.d.ts","sourceRoot":"","sources":["../../src/proxy/probes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,MAAM,MAAM,SAAS,GAAG,OAAO,GAAG,QAAQ,CAAA;AAE1C,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,EAAE,EAAE,OAAO,CAAA;IACpB,4CAA4C;IAC5C,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CACzB;AAED,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,EAAE,EAAE,OAAO,CAAA;IACpB,QAAQ,CAAC,MAAM,EAAE,SAAS,UAAU,EAAE,CAAA;CACvC;AAED;;;;;;;;;GASG;AACH,wBAAgB,cAAc,IAAI,WAAW,CAE5C;AAED,MAAM,WAAW,cAAc;IAC7B,wDAAwD;IACxD,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAA;IAC7B,8DAA8D;IAC9D,QAAQ,CAAC,wBAAwB,EAAE,OAAO,CAAA;CAC3C;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,cAAc,GAAG,WAAW,CAgBlE;AAED;;;;;;;GAOG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,SAAS,EAAE,MAAM,EAAE,WAAW,EAAE,OAAO,EAAE,OAAO,GAAG,MAAM,CAS1F"}
|
|
@@ -1,17 +1,27 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* CLI commands for profile management.
|
|
3
3
|
*
|
|
4
|
-
* Browser-login profiles are stored under
|
|
4
|
+
* Browser-login profiles are stored under <config dir>/profiles/{id}/
|
|
5
5
|
* — each directory is a standalone CLAUDE_CONFIG_DIR with its own OAuth
|
|
6
6
|
* tokens. OAuth-token profiles (added via `--oauth-token`) live entirely in
|
|
7
7
|
* profiles.json — no per-profile config dir.
|
|
8
8
|
*
|
|
9
9
|
* This is a leaf module — no imports from server.ts or session/.
|
|
10
10
|
*/
|
|
11
|
+
import { type OAuthPlanFields } from "./oauthPlan";
|
|
11
12
|
import type { ProfileConfig } from "./profiles";
|
|
13
|
+
import { type CredentialsFile } from "./tokenRefresh";
|
|
12
14
|
export declare const OAUTH_TOKEN_URL = "https://platform.claude.com/v1/oauth/token";
|
|
13
15
|
export declare const OAUTH_CLIENT_ID = "9d1c250a-e61b-44d9-88ed-5944d1962f5e";
|
|
14
16
|
export declare const OAUTH_REDIRECT_URI = "https://platform.claude.com/oauth/code/callback";
|
|
17
|
+
/**
|
|
18
|
+
* Pure: is this ID safe to use as a profile name?
|
|
19
|
+
*
|
|
20
|
+
* A profile ID becomes a directory name under PROFILES_DIR, so anything
|
|
21
|
+
* carrying a path separator or a `..` segment would escape that directory.
|
|
22
|
+
* Restricting to plain identifiers keeps IDs both safe and shell-friendly.
|
|
23
|
+
*/
|
|
24
|
+
export declare function isValidProfileId(id: string): boolean;
|
|
15
25
|
interface AuthLoginOptions {
|
|
16
26
|
headless?: boolean;
|
|
17
27
|
}
|
|
@@ -24,9 +34,29 @@ interface ParsedAuthorizationCode {
|
|
|
24
34
|
code: string;
|
|
25
35
|
state?: string;
|
|
26
36
|
}
|
|
37
|
+
interface OAuthTokenResponse {
|
|
38
|
+
access_token: string;
|
|
39
|
+
refresh_token?: string;
|
|
40
|
+
expires_in?: number;
|
|
41
|
+
expires_at?: number;
|
|
42
|
+
scope?: string;
|
|
43
|
+
}
|
|
27
44
|
export declare function buildAuthLoginEnv(configDir: string | undefined, _options?: AuthLoginOptions, baseEnv?: NodeJS.ProcessEnv): NodeJS.ProcessEnv;
|
|
28
45
|
export declare function createManualOAuthSession(scopes?: string[]): ManualOAuthSession;
|
|
29
46
|
export declare function parseAuthorizationCodeInput(input: string): ParsedAuthorizationCode | null;
|
|
47
|
+
type CompleteOAuthTokenResponse = OAuthTokenResponse & {
|
|
48
|
+
refresh_token: string;
|
|
49
|
+
};
|
|
50
|
+
/**
|
|
51
|
+
* Build the record a login writes to disk.
|
|
52
|
+
*
|
|
53
|
+
* Split out so the on-disk shape is directly assertable: the defect this closes
|
|
54
|
+
* was a field missing from this object literal, which no test of the
|
|
55
|
+
* surrounding prompt/fetch I/O would have caught. Plan fields spread in only
|
|
56
|
+
* when known — `subscriptionType: undefined` would write a null-ish key into a
|
|
57
|
+
* file the real CLI also parses.
|
|
58
|
+
*/
|
|
59
|
+
export declare function buildLoginCredentials(tokenData: CompleteOAuthTokenResponse, plan: OAuthPlanFields, now?: number): CredentialsFile;
|
|
30
60
|
export declare function profileAdd(id: string, options?: AuthLoginOptions): Promise<void>;
|
|
31
61
|
export declare function profileAddOauthToken(id: string, tokenArg: string | undefined): Promise<void>;
|
|
32
62
|
export declare function profileList(): void;
|
|
@@ -41,7 +71,29 @@ export declare function profileList(): void;
|
|
|
41
71
|
*/
|
|
42
72
|
export declare function dirsToRemoveOnProfileRemove(profile: ProfileConfig, profilesDir: string): string[];
|
|
43
73
|
export declare function profileRemove(id: string): void;
|
|
74
|
+
export declare function profileRename(from: string, to: string): void;
|
|
44
75
|
export declare function profileSwitch(id: string): Promise<void>;
|
|
76
|
+
export type ProfileLoginPlan = {
|
|
77
|
+
action: "create";
|
|
78
|
+
} | {
|
|
79
|
+
action: "reject-invalid-id";
|
|
80
|
+
} | {
|
|
81
|
+
action: "reject-oauth-token";
|
|
82
|
+
} | {
|
|
83
|
+
action: "login";
|
|
84
|
+
profile: ProfileConfig;
|
|
85
|
+
};
|
|
86
|
+
/**
|
|
87
|
+
* Pure: decide what `meridian profile login <id>` should do.
|
|
88
|
+
*
|
|
89
|
+
* An unknown ID is a request to create that profile, not an error — the ID is
|
|
90
|
+
* validated first because only this branch turns it into a directory. A profile
|
|
91
|
+
* that already exists is never re-validated: it was written by an earlier `add`
|
|
92
|
+
* (or by hand), and login must keep working on it either way.
|
|
93
|
+
*
|
|
94
|
+
* Caller performs the login itself — this returns the decision only.
|
|
95
|
+
*/
|
|
96
|
+
export declare function planProfileLogin(id: string, profiles: ProfileConfig[]): ProfileLoginPlan;
|
|
45
97
|
export declare function profileLogin(id: string, options?: AuthLoginOptions): Promise<void>;
|
|
46
98
|
export declare function profileHelp(): void;
|
|
47
99
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"profileCli.d.ts","sourceRoot":"","sources":["../../src/proxy/profileCli.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;
|
|
1
|
+
{"version":3,"file":"profileCli.d.ts","sourceRoot":"","sources":["../../src/proxy/profileCli.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAWH,OAAO,EAAwB,KAAK,eAAe,EAAE,MAAM,aAAa,CAAA;AACxE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AAY/C,OAAO,EAAiC,KAAK,eAAe,EAAE,MAAM,gBAAgB,CAAA;AAGpF,eAAO,MAAM,eAAe,+CAA+C,CAAA;AAC3E,eAAO,MAAM,eAAe,yCAAyC,CAAA;AACrE,eAAO,MAAM,kBAAkB,oDAAoD,CAAA;AAsBnF;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAEpD;AAOD,UAAU,gBAAgB;IACxB,QAAQ,CAAC,EAAE,OAAO,CAAA;CACnB;AAED,UAAU,kBAAkB;IAC1B,YAAY,EAAE,MAAM,CAAA;IACpB,YAAY,EAAE,MAAM,CAAA;IACpB,KAAK,EAAE,MAAM,CAAA;CACd;AAED,UAAU,uBAAuB;IAC/B,IAAI,EAAE,MAAM,C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