@eddyskywalker/dsh-chatgpt-subscription 0.31.0 → 0.32.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/CHANGELOG.md +34 -0
- package/README.md +64 -1
- package/lib/client.js +29654 -1099
- package/lib/client.js.map +1 -1
- package/lib/index.js +7163 -1484
- package/lib/types/client/cline-pass/ClinePassComposerQuota.d.ts +20 -0
- package/lib/types/client/cline-pass/ClinePassComposerQuota.d.ts.map +1 -0
- package/lib/types/client/cline-pass/ClinePassSection.d.ts +17 -0
- package/lib/types/client/cline-pass/ClinePassSection.d.ts.map +1 -0
- package/lib/types/client/cline-pass/api.d.ts +84 -0
- package/lib/types/client/cline-pass/api.d.ts.map +1 -0
- package/lib/types/client/cline-pass/locales.d.ts +1025 -0
- package/lib/types/client/cline-pass/locales.d.ts.map +1 -0
- package/lib/types/client/cline-pass/styles.d.ts +7 -0
- package/lib/types/client/cline-pass/styles.d.ts.map +1 -0
- package/lib/types/client/hub/brand-icons.d.ts +2 -2
- package/lib/types/client/hub/brand-icons.d.ts.map +1 -1
- package/lib/types/client/hub/providers.d.ts.map +1 -1
- package/lib/types/client/index.d.ts +2 -0
- package/lib/types/client/index.d.ts.map +1 -1
- package/lib/types/client/mermaid/renderer.d.ts +23 -0
- package/lib/types/client/mermaid/renderer.d.ts.map +1 -1
- package/lib/types/client/minimax-code/MinimaxVideoDocumentBody.d.ts +31 -14
- package/lib/types/client/minimax-code/MinimaxVideoDocumentBody.d.ts.map +1 -1
- package/lib/types/client/minimax-code/MinimaxVideoToolView.d.ts.map +1 -1
- package/lib/types/client/minimax-code/video-contract.d.ts +36 -0
- package/lib/types/client/minimax-code/video-contract.d.ts.map +1 -1
- package/lib/types/client/minimax-code/video-slots.d.ts +58 -5
- package/lib/types/client/minimax-code/video-slots.d.ts.map +1 -1
- package/lib/types/client/progress-updates/markdown-lite.d.ts +19 -6
- package/lib/types/client/progress-updates/markdown-lite.d.ts.map +1 -1
- package/lib/types/host/antigravity/adapter.d.ts.map +1 -1
- package/lib/types/host/cline-pass/account-pool.d.ts +63 -0
- package/lib/types/host/cline-pass/account-pool.d.ts.map +1 -0
- package/lib/types/host/cline-pass/adapter.d.ts +49 -0
- package/lib/types/host/cline-pass/adapter.d.ts.map +1 -0
- package/lib/types/host/cline-pass/catalog.d.ts +49 -0
- package/lib/types/host/cline-pass/catalog.d.ts.map +1 -0
- package/lib/types/host/cline-pass/client.d.ts +118 -0
- package/lib/types/host/cline-pass/client.d.ts.map +1 -0
- package/lib/types/host/cline-pass/engine.d.ts +223 -0
- package/lib/types/host/cline-pass/engine.d.ts.map +1 -0
- package/lib/types/host/cline-pass/line.d.ts +55 -0
- package/lib/types/host/cline-pass/line.d.ts.map +1 -0
- package/lib/types/host/cline-pass/mapper.d.ts +112 -0
- package/lib/types/host/cline-pass/mapper.d.ts.map +1 -0
- package/lib/types/host/cline-pass/oauth.d.ts +134 -0
- package/lib/types/host/cline-pass/oauth.d.ts.map +1 -0
- package/lib/types/host/cline-pass/protocol.d.ts +186 -0
- package/lib/types/host/cline-pass/protocol.d.ts.map +1 -0
- package/lib/types/host/cline-pass/routes.d.ts +71 -0
- package/lib/types/host/cline-pass/routes.d.ts.map +1 -0
- package/lib/types/host/cline-pass/store.d.ts +97 -0
- package/lib/types/host/cline-pass/store.d.ts.map +1 -0
- package/lib/types/host/cline-pass/token-store.d.ts +168 -0
- package/lib/types/host/cline-pass/token-store.d.ts.map +1 -0
- package/lib/types/host/cline-pass/tools.d.ts +21 -0
- package/lib/types/host/cline-pass/tools.d.ts.map +1 -0
- package/lib/types/host/cline-pass/types.d.ts +168 -0
- package/lib/types/host/cline-pass/types.d.ts.map +1 -0
- package/lib/types/host/common/model-request-control.d.ts +1 -1
- package/lib/types/host/common/model-request-control.d.ts.map +1 -1
- package/lib/types/host/common/request-diagnostics.d.ts +1 -1
- package/lib/types/host/common/request-diagnostics.d.ts.map +1 -1
- package/lib/types/index.d.ts +12 -0
- package/lib/types/index.d.ts.map +1 -1
- package/lib/types/shared/cline-pass-contracts.d.ts +267 -0
- package/lib/types/shared/cline-pass-contracts.d.ts.map +1 -0
- package/package.json +2 -1
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cline account sign-in: WorkOS device authorization followed by Cline's token
|
|
3
|
+
* registration, plus the refresh chain.
|
|
4
|
+
*
|
|
5
|
+
* The official clients implement exactly this sequence (Cline repo
|
|
6
|
+
* `sdk/packages/core/src/auth/cline.ts` + `auth/provider-auth-registry.ts`):
|
|
7
|
+
*
|
|
8
|
+
* 1. `POST https://api.workos.com/user_management/authorize/device` with the
|
|
9
|
+
* public client id → `device_code`, `user_code`, `verification_uri_complete`;
|
|
10
|
+
* 2. the user confirms the code in a browser;
|
|
11
|
+
* 3. `POST https://api.workos.com/user_management/authenticate` polls the device
|
|
12
|
+
* grant → WorkOS `access_token` / `refresh_token`;
|
|
13
|
+
* 4. `POST {cline}/api/v1/auth/register` exchanges those for Cline's own session
|
|
14
|
+
* (access, rotating refresh, expiry, user info);
|
|
15
|
+
* 5. later, `POST {cline}/api/v1/auth/refresh` renews it.
|
|
16
|
+
*
|
|
17
|
+
* The chat bearer is `workos:<access>` — the prefix is part of the token the
|
|
18
|
+
* official clients send, not a display detail. See `formatClineApiKey` in the
|
|
19
|
+
* same repo.
|
|
20
|
+
*
|
|
21
|
+
* The constants below are transcribed from
|
|
22
|
+
* `sdk/packages/shared/src/runtime/cline-environment.ts` (production entry).
|
|
23
|
+
*
|
|
24
|
+
* @module dsh-chatgpt-subscription/cline-pass-oauth
|
|
25
|
+
*/
|
|
26
|
+
import { type ClinePassOAuthCredentials } from './token-store.ts';
|
|
27
|
+
export declare const CLINE_WORKOS_CLIENT_ID = "client_01K3A541FN8TA3EPPHTD2325AR";
|
|
28
|
+
export declare const CLINE_WORKOS_API_BASE = "https://api.workos.com";
|
|
29
|
+
export declare const CLINE_WORKOS_DEVICE_PATH = "/user_management/authorize/device";
|
|
30
|
+
export declare const CLINE_WORKOS_AUTHENTICATE_PATH = "/user_management/authenticate";
|
|
31
|
+
/** One WorkOS device authorization, as the card renders it. */
|
|
32
|
+
export interface ClinePassDeviceAuthorization {
|
|
33
|
+
deviceCode: string;
|
|
34
|
+
userCode: string;
|
|
35
|
+
verificationUri: string;
|
|
36
|
+
verificationUriComplete?: string;
|
|
37
|
+
expiresInSeconds: number;
|
|
38
|
+
pollIntervalSeconds: number;
|
|
39
|
+
}
|
|
40
|
+
/** A token/refresh failure with the HTTP facts a caller can judge. */
|
|
41
|
+
export declare class ClinePassOAuthError extends Error {
|
|
42
|
+
readonly status?: number;
|
|
43
|
+
readonly code?: string;
|
|
44
|
+
constructor(message: string, options?: {
|
|
45
|
+
status?: number;
|
|
46
|
+
code?: string;
|
|
47
|
+
cause?: unknown;
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
/** Whether a refresh failure means the session is gone and a sign-in is needed. */
|
|
51
|
+
export declare function isClinePassInvalidGrant(error: unknown): boolean;
|
|
52
|
+
/** The auth root for one chat base URL. */
|
|
53
|
+
export declare function clineAuthBaseURL(chatBaseURL: string): string;
|
|
54
|
+
/** One auth sub-path under the chat base. */
|
|
55
|
+
export declare function clineAuthURL(chatBaseURL: string, path: string): string;
|
|
56
|
+
/** Step 1: ask WorkOS for a device code. */
|
|
57
|
+
export declare function startClinePassDeviceAuth(fetchFn: typeof fetch, { signal, timeoutMs }?: {
|
|
58
|
+
signal?: AbortSignal;
|
|
59
|
+
timeoutMs?: number;
|
|
60
|
+
}): Promise<ClinePassDeviceAuthorization>;
|
|
61
|
+
/** Step 4: exchange WorkOS tokens for a Cline session. */
|
|
62
|
+
export declare function registerClinePassTokens(fetchFn: typeof fetch, { baseURL, accessToken, refreshToken, signal, timeoutMs, base, }: {
|
|
63
|
+
baseURL: string;
|
|
64
|
+
accessToken: string;
|
|
65
|
+
refreshToken: string;
|
|
66
|
+
signal?: AbortSignal;
|
|
67
|
+
timeoutMs?: number;
|
|
68
|
+
base?: Partial<ClinePassOAuthCredentials>;
|
|
69
|
+
}): Promise<ClinePassOAuthCredentials>;
|
|
70
|
+
/** Renew one Cline session. The refresh token rotates, so persist the result. */
|
|
71
|
+
export declare function refreshClinePassCredentials(fetchFn: typeof fetch, credentials: ClinePassOAuthCredentials, { baseURL, signal, timeoutMs, }: {
|
|
72
|
+
baseURL: string;
|
|
73
|
+
signal?: AbortSignal;
|
|
74
|
+
timeoutMs?: number;
|
|
75
|
+
}): Promise<ClinePassOAuthCredentials>;
|
|
76
|
+
/** Whether one session should be refreshed before its next use. */
|
|
77
|
+
export declare function clinePassNeedsRefresh(credentials: ClinePassOAuthCredentials, now: number): boolean;
|
|
78
|
+
/** One login flow, as the settings card renders it. */
|
|
79
|
+
export type ClinePassLoginStatus = 'idle' | 'pending' | 'complete' | 'failed' | 'cancelled';
|
|
80
|
+
export interface ClinePassLoginFlow {
|
|
81
|
+
id: string;
|
|
82
|
+
status: ClinePassLoginStatus;
|
|
83
|
+
userCode: string;
|
|
84
|
+
verificationUri: string;
|
|
85
|
+
expiresAt: number;
|
|
86
|
+
intervalSeconds: number;
|
|
87
|
+
error: string;
|
|
88
|
+
accountAlias: string;
|
|
89
|
+
}
|
|
90
|
+
export interface ClinePassLoginOptions {
|
|
91
|
+
fetchFn: typeof fetch;
|
|
92
|
+
/** The line's current chat base URL. */
|
|
93
|
+
baseURL(): string;
|
|
94
|
+
/** Persist a newly signed-in account; throws make the flow fail. */
|
|
95
|
+
onLogin(credentials: ClinePassOAuthCredentials): Promise<void>;
|
|
96
|
+
logger?: {
|
|
97
|
+
warn(message: string, ...args: unknown[]): void;
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* One device-code sign-in at a time.
|
|
102
|
+
*
|
|
103
|
+
* Polling is driven by the card (`GET /login/status`): each request makes at
|
|
104
|
+
* most one WorkOS call, and only after the advertised interval has elapsed. A
|
|
105
|
+
* host restart therefore loses the pending flow rather than keeping a poll loop
|
|
106
|
+
* alive with no reader — the same contract the Step Code line uses.
|
|
107
|
+
*/
|
|
108
|
+
export declare class ClinePassLoginManager {
|
|
109
|
+
private readonly options;
|
|
110
|
+
private flow;
|
|
111
|
+
private sequence;
|
|
112
|
+
constructor(options: ClinePassLoginOptions);
|
|
113
|
+
/** Start a new flow, cancelling any previous one. */
|
|
114
|
+
begin({ signal }?: {
|
|
115
|
+
signal?: AbortSignal;
|
|
116
|
+
}): Promise<ClinePassLoginFlow>;
|
|
117
|
+
/** The latest flow, or null when this process never started one. */
|
|
118
|
+
current(): ClinePassLoginFlow | null;
|
|
119
|
+
/**
|
|
120
|
+
* Advance one flow and return its state.
|
|
121
|
+
*
|
|
122
|
+
* A flow the caller does not name is not advanced: two cards (or a stale one)
|
|
123
|
+
* cannot spend each other's polls.
|
|
124
|
+
*/
|
|
125
|
+
status(id: string, { signal, timeoutMs }?: {
|
|
126
|
+
signal?: AbortSignal;
|
|
127
|
+
timeoutMs?: number;
|
|
128
|
+
}): Promise<ClinePassLoginFlow>;
|
|
129
|
+
/** Abandon one flow; a late browser confirmation is then ignored. */
|
|
130
|
+
cancel(id: string): boolean;
|
|
131
|
+
/** Mark every flow cancelled for teardown. */
|
|
132
|
+
dispose(): void;
|
|
133
|
+
}
|
|
134
|
+
//# sourceMappingURL=oauth.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"oauth.d.ts","sourceRoot":"","sources":["../../../../src/host/cline-pass/oauth.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,OAAO,EACL,KAAK,yBAAyB,EAE/B,MAAM,kBAAkB,CAAA;AAGzB,eAAO,MAAM,sBAAsB,sCAAsC,CAAA;AACzE,eAAO,MAAM,qBAAqB,2BAA2B,CAAA;AAC7D,eAAO,MAAM,wBAAwB,sCAAsC,CAAA;AAC3E,eAAO,MAAM,8BAA8B,kCAAkC,CAAA;AAO7E,+DAA+D;AAC/D,MAAM,WA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AC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI,CAAA;KAAE,CAAA;CAC7D;AAED;;;;;;;GAOG;AACH,qBAAa,qBAAqB;IAIpB,OAAO,CAAC,QAAQ,CAAC,OAAO;IAHpC,OAAO,CAAC,IAAI,CAA4B;IACxC,OAAO,CAAC,QAAQ,CAAI;gBAES,OAAO,EAAE,qBAAqB;IAE3D,qDAAqD;IAC/C,KAAK,CAAC,EAAE,MAAM,EAAE,GAAE;QAAE,MAAM,CAAC,EAAE,WAAW,CAAA;KAAO,GAAG,OAAO,CAAC,kBAAkB,CAAC;IA2BnF,oEAAoE;IACpE,OAAO,IAAI,kBAAkB,GAAG,IAAI;IAIpC;;;;;OAKG;IACG,MAAM,CAAC,EAAE,EAAE,MAAM,EAAE,EAAE,MAAM,EAAE,SAAS,EAAE,GAAE;QAAE,MAAM,CAAC,EAAE,WAAW,CAAC;QAAC,SAAS,CAAC,EAAE,MAAM,CAAA;KAAO,GAAG,OAAO,CAAC,kBAAkB,CAAC;IA2D/H,qEAAqE;IACrE,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO;IAQ3B,8CAA8C;IAC9C,OAAO,IAAI,IAAI;CAKhB"}
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
/** Which pipeline the gateway routed one request through. */
|
|
2
|
+
export type ClinePipeline = 'direct' | 'planner';
|
|
3
|
+
/** One candidate request, after a pin has been expanded into try order. */
|
|
4
|
+
export interface PinAttempt {
|
|
5
|
+
/** The channel to pin, or null for automatic routing. */
|
|
6
|
+
upstream: string | null;
|
|
7
|
+
/** The remaining ordered candidates; used in `preferred` mode. */
|
|
8
|
+
orderRest: string[];
|
|
9
|
+
/** Channels that must never serve this request. */
|
|
10
|
+
excludeList: string[];
|
|
11
|
+
/** Strict writes `only`; preferred writes `order` as well. */
|
|
12
|
+
strict: boolean;
|
|
13
|
+
/** Normalized sort metric, or null for none. */
|
|
14
|
+
sort: string | null;
|
|
15
|
+
/** `detected` restores the old single-spelling behavior. */
|
|
16
|
+
spelling?: string;
|
|
17
|
+
}
|
|
18
|
+
/** One model's stored pin configuration. */
|
|
19
|
+
export interface PinConfig {
|
|
20
|
+
upstreams?: readonly string[];
|
|
21
|
+
exclude?: readonly string[];
|
|
22
|
+
pinMode?: string;
|
|
23
|
+
sort?: string;
|
|
24
|
+
spelling?: string;
|
|
25
|
+
}
|
|
26
|
+
/** What one response says about how the gateway routed it. */
|
|
27
|
+
export interface RoutingFacts {
|
|
28
|
+
content: string | null;
|
|
29
|
+
toolCalls: unknown[];
|
|
30
|
+
usage: unknown;
|
|
31
|
+
pipeline: ClinePipeline | null;
|
|
32
|
+
canonicalSlug: string | null;
|
|
33
|
+
finalProvider: string | null;
|
|
34
|
+
finalProviderName: string | null;
|
|
35
|
+
fallbacks: string[];
|
|
36
|
+
plan: string;
|
|
37
|
+
}
|
|
38
|
+
/** Written into the model observation store, so probe results are kept apart by pipeline. */
|
|
39
|
+
export interface PinModelMeta {
|
|
40
|
+
upstreams?: string[];
|
|
41
|
+
channels?: Partial<Record<ClinePipeline, string[]>>;
|
|
42
|
+
pipeline?: ClinePipeline | null;
|
|
43
|
+
}
|
|
44
|
+
/** One attempt's replayed identity. */
|
|
45
|
+
export interface PinAttemptOutcome {
|
|
46
|
+
attempt: PinAttempt;
|
|
47
|
+
routing: {
|
|
48
|
+
finalProvider: string | null;
|
|
49
|
+
} | null;
|
|
50
|
+
}
|
|
51
|
+
/** Whether a pin was honored, or could not be judged. */
|
|
52
|
+
export type PinAdherence = 'adopted' | 'fallback' | 'not-adopted' | 'violated' | 'unresolved';
|
|
53
|
+
/**
|
|
54
|
+
* The gateway wraps some answers in a `{ data: … }` envelope; unwrap it.
|
|
55
|
+
* @param json - raw decoded response body.
|
|
56
|
+
* @returns the OpenAI-shaped payload.
|
|
57
|
+
*/
|
|
58
|
+
export declare function unwrapEnvelope(json: unknown): Record<string, unknown>;
|
|
59
|
+
/** Turn any error-shaped value into display text. */
|
|
60
|
+
export declare function errorText(value: unknown): string;
|
|
61
|
+
/** Account authentication refusals, including responses with no useful body. */
|
|
62
|
+
export declare function isAuthenticationError(message: unknown, status?: number): boolean;
|
|
63
|
+
/**
|
|
64
|
+
* Read the routing facts out of one completed gateway response.
|
|
65
|
+
* @param json - raw decoded response body (enveloped or not).
|
|
66
|
+
* @returns pipeline, canonical slug, chosen upstream and fallback list.
|
|
67
|
+
*/
|
|
68
|
+
export declare function parseRouting(json: unknown): RoutingFacts;
|
|
69
|
+
/** Lowercase a display name into an upstream slug. */
|
|
70
|
+
export declare function slugify(value: unknown): string;
|
|
71
|
+
/** OpenRouter's names for the three sort metrics. */
|
|
72
|
+
export declare const OPENROUTER_SORT: Readonly<Record<string, string>>;
|
|
73
|
+
/**
|
|
74
|
+
* Channels the two routers spell differently, as `[planner, direct]` pairs.
|
|
75
|
+
*
|
|
76
|
+
* Z.AI is `zai` to the Vercel gateway and `z-ai` to OpenRouter. Writing one name
|
|
77
|
+
* into both spellings matters: a request that lands on the direct pipeline
|
|
78
|
+
* carries `provider.only` to OpenRouter, where an unknown provider is refused
|
|
79
|
+
* rather than ignored.
|
|
80
|
+
*/
|
|
81
|
+
export declare const CHANNEL_ALIASES: ReadonlyArray<readonly [string, string]>;
|
|
82
|
+
/**
|
|
83
|
+
* Translate a channel name into the spelling one pipeline uses.
|
|
84
|
+
* @param name - the configured channel name, in either spelling.
|
|
85
|
+
* @param pipeline - `'planner'` or `'direct'`.
|
|
86
|
+
* @returns the name that pipeline expects; unknown names pass through.
|
|
87
|
+
*/
|
|
88
|
+
export declare function channelNameFor(name: string, pipeline: ClinePipeline): string;
|
|
89
|
+
/**
|
|
90
|
+
* Normalize a configured sort into a wire value or null.
|
|
91
|
+
*
|
|
92
|
+
* Two spellings mean "no sort" and both must be dropped before the request is
|
|
93
|
+
* built: the settings schema stores an empty string, and `none` is the
|
|
94
|
+
* documented "clear it" value. Neither is a metric, and the gateway rejects them
|
|
95
|
+
* with HTTP 400.
|
|
96
|
+
*/
|
|
97
|
+
export declare function normalizeSort(value: unknown): string | null;
|
|
98
|
+
/**
|
|
99
|
+
* Normalize a configured pin mode to the one value the router compares against.
|
|
100
|
+
* @param value - the configured pin mode, as stored.
|
|
101
|
+
* @returns `'strict'` or `'preferred'`.
|
|
102
|
+
*/
|
|
103
|
+
export declare function normalizePinMode(value: unknown): 'strict' | 'preferred';
|
|
104
|
+
/** A request body, before and after pin injection. */
|
|
105
|
+
type WireBody = Record<string, unknown>;
|
|
106
|
+
/**
|
|
107
|
+
* Write one attempt's upstream preference into a request body.
|
|
108
|
+
*
|
|
109
|
+
* Excludes are compiled into an `only` allow-list because the gateway ignores
|
|
110
|
+
* the exclude/ignore fields.
|
|
111
|
+
*
|
|
112
|
+
* Both spellings are written by default. A pin is honored only by the pipeline
|
|
113
|
+
* that owns the spelling, and the pipeline a model runs on is decided by the
|
|
114
|
+
* gateway and can differ between calls, so writing just the spelling the last
|
|
115
|
+
* probe observed means the pin silently evaporates the moment that changes. Each
|
|
116
|
+
* pipeline ignores the other's field, which is what makes writing both safe.
|
|
117
|
+
* `spelling: 'detected'` restores the old single-spelling behavior.
|
|
118
|
+
*
|
|
119
|
+
* @returns a new body with the pin applied.
|
|
120
|
+
*/
|
|
121
|
+
export declare function injectPrefs(body: WireBody, meta: PinModelMeta | undefined, attempt: PinAttempt | undefined): WireBody;
|
|
122
|
+
/**
|
|
123
|
+
* Read back whether the router honored one attempt's pin.
|
|
124
|
+
*
|
|
125
|
+
* A 200 is not evidence that the pin was applied: an unknown or unavailable
|
|
126
|
+
* `only` value is dropped by the router, which then serves the request from
|
|
127
|
+
* another channel. The only honest test is the channel the response reports.
|
|
128
|
+
*/
|
|
129
|
+
export declare function pinAdherence(attempt: PinAttempt, routing: {
|
|
130
|
+
finalProvider: string | null;
|
|
131
|
+
} | null | undefined): PinAdherence;
|
|
132
|
+
/** Whether an adherence reading means the pin was honored, or cannot be judged. */
|
|
133
|
+
export declare function isAdherenceOk(adherence: PinAdherence): boolean;
|
|
134
|
+
/**
|
|
135
|
+
* Name the configuration problems that make a pin impossible to honor.
|
|
136
|
+
*
|
|
137
|
+
* Both cases used to produce a request with no pin fields at all — that is,
|
|
138
|
+
* "excluded" channels still in play, silently.
|
|
139
|
+
*
|
|
140
|
+
* @returns human-readable warnings, empty when the pin is expressible.
|
|
141
|
+
*/
|
|
142
|
+
export declare function pinWarnings(attempt: Pick<PinAttempt, 'upstream'> & {
|
|
143
|
+
excludeList?: string[];
|
|
144
|
+
}, meta: PinModelMeta | undefined): string[];
|
|
145
|
+
/**
|
|
146
|
+
* Expand one model's pin configuration into the ordered failover candidates.
|
|
147
|
+
*
|
|
148
|
+
* A model with a non-empty (post-exclusion) pin list is tried upstream by
|
|
149
|
+
* upstream; a model without one is a single automatic candidate whose excludes
|
|
150
|
+
* become an allow-list.
|
|
151
|
+
*/
|
|
152
|
+
export declare function buildAttempts(config: PinConfig): PinAttempt[];
|
|
153
|
+
/**
|
|
154
|
+
* Classify a pinned-request failure into one upstream availability verdict.
|
|
155
|
+
* @returns `ok` (the channel answered), `limited`, `bad`, `auth`, or `unknown`.
|
|
156
|
+
*/
|
|
157
|
+
export declare function classifyUpstreamError(message: unknown): 'ok' | 'limited' | 'bad' | 'auth' | 'unknown';
|
|
158
|
+
/**
|
|
159
|
+
* Recover the gateway's own upstream list from a routing-layer error.
|
|
160
|
+
*
|
|
161
|
+
* The probe channels an impossible `only` value, so the router fails before
|
|
162
|
+
* spending a token and names every provider it could have used.
|
|
163
|
+
*/
|
|
164
|
+
export declare function extractAvailableProviders(message: unknown, pipeline: ClinePipeline | null): string[] | null;
|
|
165
|
+
/**
|
|
166
|
+
* Read the tier-0 channel hint out of a planner's reasoning sentence.
|
|
167
|
+
* @param plan - `provider_metadata.gateway.routing.planningReasoning`.
|
|
168
|
+
*/
|
|
169
|
+
export declare function parseTier0(plan: unknown): string[];
|
|
170
|
+
/**
|
|
171
|
+
* Merge the upstream channels discovered by several means, keeping order and
|
|
172
|
+
* dropping duplicates.
|
|
173
|
+
* @param lists - candidate lists, highest confidence first.
|
|
174
|
+
* @returns the merged, de-duplicated upstream slugs (capped at MAX_UPSTREAMS).
|
|
175
|
+
*/
|
|
176
|
+
export declare function mergeUpstreams(...lists: ReadonlyArray<readonly string[] | null | undefined>): string[];
|
|
177
|
+
/**
|
|
178
|
+
* Normalize a model id for fuzzy OpenRouter catalog matching.
|
|
179
|
+
* @param value - either id.
|
|
180
|
+
* @returns the comparable form.
|
|
181
|
+
*/
|
|
182
|
+
export declare function normalizeSlug(value: unknown): string;
|
|
183
|
+
/** Whether a value is a non-null object. */
|
|
184
|
+
export declare function isRecord(value: unknown): value is Record<string, unknown>;
|
|
185
|
+
export {};
|
|
186
|
+
//# sourceMappingURL=protocol.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"protocol.d.ts","sourceRoot":"","sources":["../../../../src/host/cline-pass/protocol.ts"],"names":[],"mappings":"AAeA,6DAA6D;AAC7D,MAAM,MAAM,aAAa,GAAG,QAAQ,GAAG,SAAS,CAAA;AAEhD,2EAA2E;AAC3E,MAAM,WAAW,UAAU;IACzB,yDAAyD;IACzD,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAA;IACvB,kEAAkE;IAClE,SAAS,EAAE,MAAM,EAAE,CAAA;IACnB,mDAAmD;IACnD,WAAW,EAAE,MAAM,EAAE,CAAA;IACrB,8DAA8D;IAC9D,MAAM,EAAE,OAAO,CAAA;IACf,gDAAgD;IAChD,IAAI,EAAE,MAAM,GAAG,IAAI,CAAA;IACnB,4DAA4D;IAC5D,QAAQ,CAAC,EAAE,MAAM,CAAA;CAClB;AAED,4CAA4C;AAC5C,MAAM,WAAW,SAAS;IACxB,SAAS,CAAC,EAAE,SAAS,MAAM,EAAE,CAAA;IAC7B,OAAO,CAAC,EAAE,SAAS,MAAM,EAAE,CAAA;IAC3B,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,IAAI,CAAC,EAAE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U,EAAE,UAAU,CAAC,GAAG;IAAE,WAAW,CAAC,EAAE,MAAM,EAAE,CAAA;CAAE,EAAE,IAAI,EAAE,YAAY,GAAG,SAAS,GAAG,MAAM,EAAE,CAcxI;AAED;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,SAAS,GAAG,UAAU,EAAE,CAiB7D;AAED;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,GAAG,SAAS,GAAG,KAAK,GAAG,MAAM,GAAG,SAAS,CAOrG;AAED;;;;;GAKG;AACH,wBAAgB,yBAAyB,CAAC,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,aAAa,GAAG,IAAI,GAAG,MAAM,EAAE,GAAG,IAAI,CAoB3G;AAED;;;GAGG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,OAAO,GAAG,MAAM,EAAE,CAIlD;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,GAAG,KAAK,EAAE,aAAa,CAAC,SAAS,MAAM,EAAE,GAAG,IAAI,GAAG,SAAS,CAAC,GAAG,MAAM,EAAE,CAStG;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAEpD;AAED,4CAA4C;AAC5C,wBAAgB,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAEzE"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The Cline Pass settings API.
|
|
3
|
+
*
|
|
4
|
+
* The surface is the same one every sibling line exposes — status, accounts,
|
|
5
|
+
* models — plus the controls this line genuinely has: per-model upstream pins,
|
|
6
|
+
* a channel probe/validate/test pair, the official quota reading and the
|
|
7
|
+
* in-process request history.
|
|
8
|
+
*
|
|
9
|
+
* Reads never trigger an upstream call; quota is refreshed by its own action.
|
|
10
|
+
*
|
|
11
|
+
* @module dsh-chatgpt-subscription/cline-pass-routes
|
|
12
|
+
*/
|
|
13
|
+
import type { Context } from '@deepseek-ai/cordis';
|
|
14
|
+
import type { ClinePassAccountPool } from './account-pool.ts';
|
|
15
|
+
import type { ClinePassEngine } from './engine.ts';
|
|
16
|
+
import type { ClinePassStore } from './store.ts';
|
|
17
|
+
import type { ClinePassLoginManager } from './oauth.ts';
|
|
18
|
+
import { type ClinePassModelSettingsStore } from './token-store.ts';
|
|
19
|
+
import { openPlatformBrowser } from '../step-code/routes.ts';
|
|
20
|
+
import { type ClinePassWebStatus } from '../../shared/cline-pass-contracts.ts';
|
|
21
|
+
export interface ClinePassRouteOptions {
|
|
22
|
+
settings: ClinePassModelSettingsStore;
|
|
23
|
+
accountPool: ClinePassAccountPool;
|
|
24
|
+
store: ClinePassStore;
|
|
25
|
+
engine: ClinePassEngine;
|
|
26
|
+
/** Proxy-aware fetch for account verification and quota reads. */
|
|
27
|
+
fetchFn: typeof fetch;
|
|
28
|
+
/** Device-code sign-in state, when the composition installed one. */
|
|
29
|
+
login?: ClinePassLoginManager;
|
|
30
|
+
/**
|
|
31
|
+
* Browser opener for `/login/start`; defaults to a no-op because the settings
|
|
32
|
+
* card opens the verification URL itself via `window.open`.
|
|
33
|
+
*/
|
|
34
|
+
openBrowser?: (url: string) => void;
|
|
35
|
+
serving(): boolean;
|
|
36
|
+
conflict(): string | null;
|
|
37
|
+
}
|
|
38
|
+
/** Named browser opener for deployments that want the host to launch the verification URL. */
|
|
39
|
+
export declare const openClinePassBrowser: typeof openPlatformBrowser;
|
|
40
|
+
/** Assemble the whole status payload the Cline Pass tab renders. */
|
|
41
|
+
export declare function getClinePassWebStatus(options: ClinePassRouteOptions): Promise<ClinePassWebStatus>;
|
|
42
|
+
/** The route table, exported so the client and this file can be checked against each other. */
|
|
43
|
+
export declare const CLINE_PASS_ROUTES: {
|
|
44
|
+
readonly status: "GET";
|
|
45
|
+
readonly settings: "POST";
|
|
46
|
+
readonly accounts: "GET|POST";
|
|
47
|
+
readonly 'login/start': "POST";
|
|
48
|
+
readonly 'login/status': "GET";
|
|
49
|
+
readonly 'login/cancel': "POST";
|
|
50
|
+
readonly models: "GET|POST";
|
|
51
|
+
readonly 'models/pin': "POST";
|
|
52
|
+
readonly 'models/reset': "POST";
|
|
53
|
+
readonly 'models/probe': "POST";
|
|
54
|
+
readonly 'models/validate': "POST";
|
|
55
|
+
readonly 'models/test': "POST";
|
|
56
|
+
readonly 'models/visibility': "POST";
|
|
57
|
+
readonly 'models/visibility-all': "POST";
|
|
58
|
+
readonly 'models/context-window': "POST";
|
|
59
|
+
readonly 'catalog/refresh': "POST";
|
|
60
|
+
readonly usage: "GET|POST";
|
|
61
|
+
readonly history: "GET";
|
|
62
|
+
};
|
|
63
|
+
/**
|
|
64
|
+
* Register the Cline Pass settings API under `/cline-pass/api`.
|
|
65
|
+
*
|
|
66
|
+
* Registered unconditionally: the card is how a user adds their first key, so
|
|
67
|
+
* gating it on winning the route would leave a contested id with no way to
|
|
68
|
+
* configure it at all.
|
|
69
|
+
*/
|
|
70
|
+
export declare function registerClinePassRoutes(ctx: Context, options: ClinePassRouteOptions): () => void;
|
|
71
|
+
//# sourceMappingURL=routes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"routes.d.ts","sourceRoot":"","sources":["../../../../src/host/cline-pass/routes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAMlD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAA;AAC7D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAClD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AAChD,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAA;AACvD,OAAO,EAA0C,KAAK,2BAA2B,EAAE,MAAM,kBAAkB,CAAA;AAE3G,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAA;AAC5D,OAAO,EAiBL,KAAK,kBAAkB,EACxB,MAAM,sCAAsC,CAAA;AAkH7C,MAAM,WAAW,qBAAqB;IACpC,QAAQ,EAAE,2BAA2B,CAAA;IACrC,WAAW,EAAE,oBAAoB,CAAA;IACjC,KAAK,EAAE,cAAc,CAAA;IACrB,MAAM,EAAE,eAAe,CAAA;IACvB,kEAAkE;IAClE,OAAO,EAAE,OAAO,KAAK,CAAA;IACrB,qEAAqE;IACrE,KAAK,CAAC,EAAE,qBAAqB,CAAA;IAC7B;;;OAGG;IACH,WAAW,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAA;IACnC,OAAO,IAAI,OAAO,CAAA;IAClB,QAAQ,IAAI,MAAM,GAAG,IAAI,CAAA;CAC1B;AAED,8FAA8F;AAC9F,eAAO,MAAM,oBAAoB,4BAAsB,CAAA;AAEvD,oEAAoE;AACpE,wBAAsB,qBAAqB,CAAC,OAAO,EAAE,qBAAqB,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAgDvG;AAwBD,+FAA+F;AAC/F,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;CAAS,CAAA;AAEvC;;;;;;GAMG;AACH,wBAAgB,uBAAuB,CAAC,GAAG,EAAE,OAAO,EAAE,OAAO,EAAE,qBAAqB,GAAG,MAAM,IAAI,CAqdhG"}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import type { ClinePipeline } from './protocol.ts';
|
|
2
|
+
import type { ClinePassHistoryRowDto, ClinePassUsageDto } from '../../shared/cline-pass-contracts.ts';
|
|
3
|
+
export type ClinePassVerdictStatus = 'ok' | 'limited' | 'bad' | 'auth' | 'not-adopted' | 'unknown';
|
|
4
|
+
/** One upstream availability verdict. */
|
|
5
|
+
export interface ClinePassUpstreamVerdict {
|
|
6
|
+
status: ClinePassVerdictStatus;
|
|
7
|
+
note: string;
|
|
8
|
+
ms: number;
|
|
9
|
+
checkedAt: number;
|
|
10
|
+
}
|
|
11
|
+
/** Per-upstream endpoint detail harvested from OpenRouter's public catalog. */
|
|
12
|
+
export interface ClinePassUpstreamDetail {
|
|
13
|
+
slug: string;
|
|
14
|
+
name: string;
|
|
15
|
+
endpoints: number;
|
|
16
|
+
context: number;
|
|
17
|
+
uptime: number;
|
|
18
|
+
}
|
|
19
|
+
/** Discovered metadata for one model. */
|
|
20
|
+
export interface ClinePassModelObservation {
|
|
21
|
+
ok?: boolean;
|
|
22
|
+
pipeline?: ClinePipeline | null;
|
|
23
|
+
pinnable?: boolean;
|
|
24
|
+
canonicalSlug?: string | null;
|
|
25
|
+
openrouterSlug?: string | null;
|
|
26
|
+
upstreams?: string[];
|
|
27
|
+
channels?: Partial<Record<ClinePipeline, string[]>>;
|
|
28
|
+
upstreamStatus?: Record<string, ClinePassUpstreamVerdict>;
|
|
29
|
+
upstreamDetail?: Record<string, ClinePassUpstreamDetail>;
|
|
30
|
+
availableProviders?: string[];
|
|
31
|
+
tier0?: string[];
|
|
32
|
+
lastProvider?: string | null;
|
|
33
|
+
lastMs?: number;
|
|
34
|
+
probedAt?: number;
|
|
35
|
+
validatedAt?: number;
|
|
36
|
+
staleAt?: number;
|
|
37
|
+
lastError?: string;
|
|
38
|
+
}
|
|
39
|
+
/** One recorded model call. */
|
|
40
|
+
export interface ClinePassHistoryEntry extends Omit<ClinePassHistoryRowDto, 'usageReported' | 'usage'> {
|
|
41
|
+
/** Null means the gateway sent no usage frame, which is not a zero-cost call. */
|
|
42
|
+
usage?: {
|
|
43
|
+
inputTokens?: number;
|
|
44
|
+
outputTokens?: number;
|
|
45
|
+
cacheReadTokens?: number;
|
|
46
|
+
reasoningTokens?: number;
|
|
47
|
+
} | null;
|
|
48
|
+
code?: string;
|
|
49
|
+
}
|
|
50
|
+
/** What a caller supplies when recording a call; the store stamps the time. */
|
|
51
|
+
export type ClinePassHistoryInput = Pick<ClinePassHistoryEntry, 'model'> & Partial<Omit<ClinePassHistoryEntry, 'model' | 'ts'>>;
|
|
52
|
+
/** The last cached catalog scan. */
|
|
53
|
+
export interface ClinePassCatalogState {
|
|
54
|
+
ids: string[];
|
|
55
|
+
sources: string[];
|
|
56
|
+
models: Record<string, unknown>;
|
|
57
|
+
fetchedAt: number;
|
|
58
|
+
}
|
|
59
|
+
/** Create the observation store. */
|
|
60
|
+
export declare function createClinePassStore({ historyLimit }?: {
|
|
61
|
+
historyLimit?: number;
|
|
62
|
+
}): {
|
|
63
|
+
/** Discovered metadata for one model (never undefined). */
|
|
64
|
+
metaOf(model: string): ClinePassModelObservation;
|
|
65
|
+
/** Every model with discovered metadata. */
|
|
66
|
+
allMeta(): Array<ClinePassModelObservation & {
|
|
67
|
+
id: string;
|
|
68
|
+
}>;
|
|
69
|
+
/** Merge one discovery result into a model's metadata. */
|
|
70
|
+
learn(model: string, patch: Partial<ClinePassModelObservation>): ClinePassModelObservation;
|
|
71
|
+
/** Record a verdict; explicit validation also replaces stale results with unknown. */
|
|
72
|
+
learnUpstream(model: string, upstream: string | null | undefined, status: ClinePassVerdictStatus, note: unknown, ms: unknown, { includeUnknown }?: {
|
|
73
|
+
includeUnknown?: boolean;
|
|
74
|
+
}): void;
|
|
75
|
+
/** Append one request-history row (newest first, bounded). */
|
|
76
|
+
record(entry: ClinePassHistoryInput): void;
|
|
77
|
+
/** Adopt a changed retention budget from the settings file. */
|
|
78
|
+
setHistoryLimit(next: number): void;
|
|
79
|
+
/** Read request history, newest first. */
|
|
80
|
+
readHistory(limitParam?: number, model?: string): ClinePassHistoryEntry[];
|
|
81
|
+
/** Total rows retained, before any filter. */
|
|
82
|
+
historySize(): number;
|
|
83
|
+
/** Monotonic change counter, including replacements at the retention cap. */
|
|
84
|
+
historyRevision(): number;
|
|
85
|
+
/** The last cached official-catalog scan. */
|
|
86
|
+
catalog(): ClinePassCatalogState;
|
|
87
|
+
/** Replace the cached official-catalog scan. */
|
|
88
|
+
setCatalog(next: Omit<ClinePassCatalogState, "fetchedAt"> & {
|
|
89
|
+
fetchedAt?: number;
|
|
90
|
+
}): ClinePassCatalogState;
|
|
91
|
+
/** The last quota reading (never undefined). */
|
|
92
|
+
usage(): ClinePassUsageDto;
|
|
93
|
+
/** Replace the cached quota reading. */
|
|
94
|
+
setUsage(next: Pick<ClinePassUsageDto, "accounts">): ClinePassUsageDto;
|
|
95
|
+
};
|
|
96
|
+
export type ClinePassStore = ReturnType<typeof createClinePassStore>;
|
|
97
|
+
//# sourceMappingURL=store.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../../../../src/host/cline-pass/store.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAA;AAClD,OAAO,KAAK,EACV,sBAAsB,EACtB,iBAAiB,EAClB,MAAM,sCAAsC,CAAA;AAG7C,MAAM,MAAM,sBAAsB,GAAG,IAAI,GAAG,SAAS,GAAG,KAAK,GAAG,MAAM,GAAG,aAAa,GAAG,SAAS,CAAA;AAElG,yCAAyC;AACzC,MAAM,WAAW,wBAAwB;IACvC,MAAM,EAAE,sBAAsB,CAAA;IAC9B,IAAI,EAAE,MAAM,CAAA;IACZ,EAAE,EAAE,MAAM,CAAA;IACV,SAAS,EAAE,MAAM,CAAA;CAClB;AAED,+EAA+E;AAC/E,MAAM,WAAW,uBAAuB;IACtC,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,CAAA;IACZ,SAAS,EAAE,MAAM,CAAA;IACjB,OAAO,EAAE,MAAM,CAAA;IACf,MAAM,EAAE,MAAM,CAAA;CACf;AAED,yCAAyC;AACzC,MAAM,WAAW,yBAAyB;IACxC,EAAE,CAAC,EAAE,OAAO,CAAA;IACZ,QAAQ,CAAC,EAAE,aAAa,GAAG,IAAI,CAAA;IAC/B,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;I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