@eddyskywalker/dsh-chatgpt-subscription 0.30.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 +61 -0
- package/README.md +64 -1
- package/lib/client.js +34034 -2768
- package/lib/client.js.map +1 -1
- package/lib/index.js +33214 -24259
- 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/MinimaxCodeSection.d.ts.map +1 -1
- package/lib/types/client/minimax-code/MinimaxVideoDocumentBody.d.ts +86 -0
- package/lib/types/client/minimax-code/MinimaxVideoDocumentBody.d.ts.map +1 -0
- package/lib/types/client/minimax-code/MinimaxVideoToolView.d.ts +83 -0
- package/lib/types/client/minimax-code/MinimaxVideoToolView.d.ts.map +1 -0
- package/lib/types/client/minimax-code/VideoFormDialog.d.ts +90 -0
- package/lib/types/client/minimax-code/VideoFormDialog.d.ts.map +1 -0
- package/lib/types/client/minimax-code/VideoSettingsSections.d.ts +73 -0
- package/lib/types/client/minimax-code/VideoSettingsSections.d.ts.map +1 -0
- package/lib/types/client/minimax-code/commands-contract.d.ts +35 -0
- package/lib/types/client/minimax-code/commands-contract.d.ts.map +1 -0
- package/lib/types/client/minimax-code/document-preview.d.ts +45 -0
- package/lib/types/client/minimax-code/document-preview.d.ts.map +1 -0
- package/lib/types/client/minimax-code/locales.d.ts +206 -2
- package/lib/types/client/minimax-code/locales.d.ts.map +1 -1
- package/lib/types/client/minimax-code/styles.d.ts.map +1 -1
- package/lib/types/client/minimax-code/video-command-host.d.ts +61 -0
- package/lib/types/client/minimax-code/video-command-host.d.ts.map +1 -0
- package/lib/types/client/minimax-code/video-command.d.ts +126 -0
- package/lib/types/client/minimax-code/video-command.d.ts.map +1 -0
- package/lib/types/client/minimax-code/video-contract.d.ts +208 -0
- package/lib/types/client/minimax-code/video-contract.d.ts.map +1 -0
- package/lib/types/client/minimax-code/video-defaults-store.d.ts +61 -0
- package/lib/types/client/minimax-code/video-defaults-store.d.ts.map +1 -0
- package/lib/types/client/minimax-code/video-form-rules.d.ts +288 -0
- package/lib/types/client/minimax-code/video-form-rules.d.ts.map +1 -0
- package/lib/types/client/minimax-code/video-media.d.ts +61 -0
- package/lib/types/client/minimax-code/video-media.d.ts.map +1 -0
- package/lib/types/client/minimax-code/video-slots.d.ts +140 -0
- package/lib/types/client/minimax-code/video-slots.d.ts.map +1 -0
- 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/host/minimax-code/client.d.ts.map +1 -1
- package/lib/types/host/minimax-code/iso-bmff-duration.d.ts +84 -0
- package/lib/types/host/minimax-code/iso-bmff-duration.d.ts.map +1 -0
- package/lib/types/host/minimax-code/matrix-client.d.ts +168 -0
- package/lib/types/host/minimax-code/matrix-client.d.ts.map +1 -0
- package/lib/types/host/minimax-code/media-store.d.ts +153 -0
- package/lib/types/host/minimax-code/media-store.d.ts.map +1 -0
- package/lib/types/host/minimax-code/routes.d.ts.map +1 -1
- package/lib/types/host/minimax-code/video-history.d.ts +240 -0
- package/lib/types/host/minimax-code/video-history.d.ts.map +1 -0
- package/lib/types/host/minimax-code/video-submit-rules.d.ts +40 -0
- package/lib/types/host/minimax-code/video-submit-rules.d.ts.map +1 -0
- package/lib/types/host/minimax-code/video-tool.d.ts +757 -0
- package/lib/types/host/minimax-code/video-tool.d.ts.map +1 -0
- package/lib/types/host/progress-updates/index.d.ts +6 -0
- package/lib/types/host/progress-updates/index.d.ts.map +1 -1
- package/lib/types/host/progress-updates/projection.d.ts +214 -0
- package/lib/types/host/progress-updates/projection.d.ts.map +1 -0
- 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 +14 -4
|
@@ -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,MAAM,CAAA;IACb,QAAQ,CAAC,EAAE,MAAM,CAAA;CAClB;AAED,8DAA8D;AAC9D,MAAM,WAAW,YAAY;IAC3B,OAAO,EAAE,MAAM,GAAG,IAAI,CAAA;IACtB,SAAS,EAAE,OAAO,EAAE,CAAA;IACpB,KAAK,EAAE,OAAO,CAAA;IACd,QAAQ,EAAE,aAAa,GAAG,IAAI,CAAA;IAC9B,aAAa,EAAE,MAA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,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;IAC7B,cAAc,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAC9B,SAAS,CAAC,EAAE,MAAM,EAAE,CAAA;IACpB,QAAQ,CAAC,EAAE,OAAO,CAAC,MAAM,CAAC,aAAa,EAAE,MAAM,EAAE,CAAC,CAAC,CAAA;IACnD,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,wBAAwB,CAAC,CAAA;IACzD,cAAc,CAAC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AM,GAAG,yBAAyB;IAGhD,4CAA4C;eACjC,KAAK,CAAC,yBAAyB,GAAG;QAAE,EAAE,EAAE,MAAM,CAAA;KAAE,CAAC;IAG5D,0DAA0D;iBAC7C,MAAM,SAAS,OAAO,CAAC,yBAAyB,CAAC,GAAG,yBAAyB;IAc1F,sFAAsF;yBAE7E,MAAM,YACH,MAAM,GAAG,IAAI,GAAG,SAAS,UAC3B,sBAAsB,QACxB,OAAO,MACT,OAAO,uBACiB;QAAE,cAAc,CAAC,EAAE,OAAO,CAAA;KAAE,GACvD,IAAI;IASP,8DAA8D;kBAChD,qBAAqB,GAAG,IAAI;IA2B1C,+DAA+D;0BACzC,MAAM,GAAG,IAAI;IAKnC,0CAA0C;sDACG,qBAAqB,EAAE;IAMpE,8CAA8C;mBAC/B,MAAM;IAGrB,6EAA6E;uBAC1D,MAAM;IAGzB,6CAA6C;eAClC,qBAAqB;IAGhC,gDAAgD;qBAC/B,IAAI,CAAC,qBAAqB,EAAE,WAAW,CAAC,GAAG;QAAE,SAAS,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,qBAAqB;IAI1G,gDAAgD;aACvC,iBAAiB;IAG1B,wCAAwC;mBACzB,IAAI,CAAC,iBAAiB,EAAE,UAAU,CAAC,GAAG,iBAAiB;EAKzE;AAED,MAAM,MAAM,cAAc,GAAG,UAAU,CAAC,OAAO,oBAAoB,CAAC,CAAA"}
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
import type { CredentialStore } from '../token-store.ts';
|
|
2
|
+
import { type ClinePassPinSettings } from './types.ts';
|
|
3
|
+
/**
|
|
4
|
+
* One stored Cline Pass API key.
|
|
5
|
+
*
|
|
6
|
+
* The gateway authenticates with a static key rather than the rotating OAuth
|
|
7
|
+
* pair most lines in this plugin store, so there is no refresh token and nothing
|
|
8
|
+
* expires. The key is host-only and never crosses to a browser; the settings
|
|
9
|
+
* card renders the alias and the account row, never this value.
|
|
10
|
+
*/
|
|
11
|
+
interface ClinePassCredentialBase {
|
|
12
|
+
/** User-chosen label so several accounts are distinguishable. */
|
|
13
|
+
alias?: string;
|
|
14
|
+
/** Unix milliseconds the credential was added to the pool. */
|
|
15
|
+
addedAt?: number;
|
|
16
|
+
/** Per-account gateway override; empty means the line's own base URL. */
|
|
17
|
+
baseURL?: string;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* A static API key, the shape the standalone `dsh-cline-pass` plugin used.
|
|
21
|
+
*
|
|
22
|
+
* Kept as a fallback: the official clients now sign in with WorkOS OAuth, but
|
|
23
|
+
* existing users may still hold a key, and a key has no refresh lifecycle.
|
|
24
|
+
*/
|
|
25
|
+
export interface ClinePassApiKeyCredentials extends ClinePassCredentialBase {
|
|
26
|
+
/** Absent on records written before the OAuth path existed. */
|
|
27
|
+
kind?: 'api-key';
|
|
28
|
+
/** Host-only bearer key. */
|
|
29
|
+
apiKey: string;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* One Cline account signed in through WorkOS device authorization.
|
|
33
|
+
*
|
|
34
|
+
* `access` is the raw WorkOS access token; the wire bearer is
|
|
35
|
+
* `workos:<access>` (Cline's own clients add that prefix). `refresh` rotates on
|
|
36
|
+
* every refresh, so it is persisted before the new access token is used.
|
|
37
|
+
*/
|
|
38
|
+
export interface ClinePassOAuthCredentials extends ClinePassCredentialBase {
|
|
39
|
+
kind: 'oauth';
|
|
40
|
+
access: string;
|
|
41
|
+
refresh: string;
|
|
42
|
+
/** Unix milliseconds the access token expires. */
|
|
43
|
+
expires: number;
|
|
44
|
+
/** Cline's stable user id, when the token registration returned one. */
|
|
45
|
+
accountId?: string;
|
|
46
|
+
email?: string;
|
|
47
|
+
name?: string;
|
|
48
|
+
metadata?: Record<string, unknown>;
|
|
49
|
+
}
|
|
50
|
+
export type ClinePassCredentials = ClinePassOAuthCredentials | ClinePassApiKeyCredentials;
|
|
51
|
+
/** Cline's own clients send OAuth access tokens with this prefix. */
|
|
52
|
+
export declare const CLINE_WORKOS_TOKEN_PREFIX = "workos:";
|
|
53
|
+
/** Whether one credential is an OAuth session rather than a static key. */
|
|
54
|
+
export declare function isOAuthCredentials(credentials: ClinePassCredentials): credentials is ClinePassOAuthCredentials;
|
|
55
|
+
/** The `Authorization: Bearer` value for one credential. */
|
|
56
|
+
export declare function bearerFor(credentials: ClinePassCredentials): string;
|
|
57
|
+
/** Stable identity two credentials share when they are the same Cline account. */
|
|
58
|
+
export declare function credentialsIdentity(credentials: ClinePassCredentials): string;
|
|
59
|
+
/** Unix milliseconds the credential expires, when it has an expiry. */
|
|
60
|
+
export declare function credentialsExpiresAt(credentials: ClinePassCredentials): number | undefined;
|
|
61
|
+
/** The user-facing label for one credential, when it states one. */
|
|
62
|
+
export declare function credentialsLabel(credentials: ClinePassCredentials): string | undefined;
|
|
63
|
+
/** Decode a JWT's `exp` claim, without trusting anything else in it. */
|
|
64
|
+
export declare function jwtExpiryMs(token: string): number | undefined;
|
|
65
|
+
/** One catalog entry, as the last successful scan published it. */
|
|
66
|
+
export interface ClinePassCatalogModel {
|
|
67
|
+
id: string;
|
|
68
|
+
name?: string;
|
|
69
|
+
contextWindow?: number;
|
|
70
|
+
maxTokens?: number;
|
|
71
|
+
reasoning?: boolean;
|
|
72
|
+
input?: string[];
|
|
73
|
+
efforts?: string[];
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Everything this line stores besides credentials.
|
|
77
|
+
*
|
|
78
|
+
* `enabledModelIds === null` is "no filter": every catalogued model, including
|
|
79
|
+
* ones a later scan adds. An array is an explicit selection, and an empty one
|
|
80
|
+
* switches every model off. Modelling "all" as null rather than as an explicit
|
|
81
|
+
* all-ids list means a model the service adds later is not silently hidden by a
|
|
82
|
+
* selection made before it existed.
|
|
83
|
+
*/
|
|
84
|
+
export interface ClinePassModelSettings {
|
|
85
|
+
enabled: boolean;
|
|
86
|
+
baseURL: string;
|
|
87
|
+
enabledModelIds: string[] | null;
|
|
88
|
+
catalogModels: ClinePassCatalogModel[];
|
|
89
|
+
/** Per-model upstream pin, keyed by model id. */
|
|
90
|
+
pins: Record<string, ClinePassPinSettings>;
|
|
91
|
+
/** Models the route must not advertise even though it still knows them. */
|
|
92
|
+
hiddenModels: string[];
|
|
93
|
+
/** Per-model context-window override; absent uses the published window. */
|
|
94
|
+
contextWindowOverrides: Record<string, number>;
|
|
95
|
+
defaultContextWindow: number;
|
|
96
|
+
defaultMaxTokens: number;
|
|
97
|
+
maxConcurrentRequests: number;
|
|
98
|
+
streamIdleTimeoutMs: number;
|
|
99
|
+
historyLimit: number;
|
|
100
|
+
exposeCatalog: boolean;
|
|
101
|
+
/** Which pin spellings a request carries: `both` (default) or `detected`. */
|
|
102
|
+
pinSpelling: string;
|
|
103
|
+
/** Whether the `cline_pass_*` tools are registered on the next start. */
|
|
104
|
+
exposeTools: boolean;
|
|
105
|
+
}
|
|
106
|
+
export interface ClinePassPreferenceStore {
|
|
107
|
+
status(): ClinePassModelSettings;
|
|
108
|
+
read(): Promise<ClinePassModelSettings>;
|
|
109
|
+
update(patch: Partial<ClinePassModelSettings>): Promise<ClinePassModelSettings>;
|
|
110
|
+
}
|
|
111
|
+
export declare function credentialPath(): string;
|
|
112
|
+
export declare function modelSettingsPath(): string;
|
|
113
|
+
/** Validate one stored credential: an OAuth session or a static API key. */
|
|
114
|
+
export declare function parseClinePassCredentials(value: unknown): ClinePassCredentials;
|
|
115
|
+
/** Encrypted credential store for the single-key (pre-pool) configuration. */
|
|
116
|
+
export declare class FileCredentialStore {
|
|
117
|
+
private readonly filePath;
|
|
118
|
+
private readonly backend;
|
|
119
|
+
constructor(filePath?: string, backend?: CredentialStore<ClinePassCredentials>);
|
|
120
|
+
path(): string;
|
|
121
|
+
read(): Promise<ClinePassCredentials | null>;
|
|
122
|
+
write(credentials: ClinePassCredentials): Promise<void>;
|
|
123
|
+
clear(): Promise<void>;
|
|
124
|
+
}
|
|
125
|
+
/** Parse one whole settings document. */
|
|
126
|
+
export declare function parseClinePassModelSettings(value: unknown): ClinePassModelSettings;
|
|
127
|
+
/** The document a fresh install starts from. */
|
|
128
|
+
export declare function defaultClinePassModelSettings(): ClinePassModelSettings;
|
|
129
|
+
/**
|
|
130
|
+
* Model and routing settings, bound to a JSON file beside the encrypted
|
|
131
|
+
* credential store.
|
|
132
|
+
*
|
|
133
|
+
* The file is written atomically (temp + rename) so a crash mid-write leaves the
|
|
134
|
+
* previous document intact rather than a truncated one that reads as "reset all
|
|
135
|
+
* settings".
|
|
136
|
+
*/
|
|
137
|
+
export declare class ClinePassModelSettingsStore implements ClinePassPreferenceStore {
|
|
138
|
+
private readonly filePath;
|
|
139
|
+
private cached;
|
|
140
|
+
private loadPromise;
|
|
141
|
+
constructor(filePath?: string);
|
|
142
|
+
path(): string;
|
|
143
|
+
status(): ClinePassModelSettings;
|
|
144
|
+
/**
|
|
145
|
+
* Read the document at activation time, synchronously.
|
|
146
|
+
*
|
|
147
|
+
* The line has to decide whether to register its management tools before
|
|
148
|
+
* `apply()` returns: a tool list snapshotted by a running Session would not
|
|
149
|
+
* see a registration that landed a tick later. The file is small and plain
|
|
150
|
+
* JSON (only credentials are encrypted), so one sync read is the honest
|
|
151
|
+
* trade.
|
|
152
|
+
*/
|
|
153
|
+
readSync(): ClinePassModelSettings;
|
|
154
|
+
read(): Promise<ClinePassModelSettings>;
|
|
155
|
+
private load;
|
|
156
|
+
write(settings: ClinePassModelSettings): Promise<ClinePassModelSettings>;
|
|
157
|
+
update(patch: Partial<ClinePassModelSettings>): Promise<ClinePassModelSettings>;
|
|
158
|
+
/** Record a catalog sync without touching the user's selection or pins. */
|
|
159
|
+
storeCatalog(models: ClinePassCatalogModel[]): Promise<ClinePassModelSettings>;
|
|
160
|
+
/** Store one model's pin; an empty pin list returns it to automatic routing. */
|
|
161
|
+
setPin(model: string, pin: ClinePassPinSettings): Promise<ClinePassModelSettings>;
|
|
162
|
+
/** Drop one model's pin entirely. */
|
|
163
|
+
clearPin(model: string): Promise<ClinePassModelSettings>;
|
|
164
|
+
/** Store or clear (null) one model's context-window override. */
|
|
165
|
+
setContextWindowOverride(model: string, contextWindow: number | null): Promise<ClinePassModelSettings>;
|
|
166
|
+
}
|
|
167
|
+
export {};
|
|
168
|
+
//# sourceMappingURL=token-store.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"token-store.d.ts","sourceRoot":"","sources":["../../../../src/host/cline-pass/token-store.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AAMxD,OAAO,EASL,KAAK,oBAAoB,EAC1B,MAAM,YAAY,CAAA;AAEnB;;;;;;;GAOG;AACH,UAAU,uBAAuB;IAC/B,iEAAiE;IACjE,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,8DAA8D;IAC9D,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,yEAAyE;IACzE,OAAO,CAAC,EAAE,MAAM,CAAA;CACjB;AAED;;;;;GAKG;AACH,MAAM,WAAW,0BAA2B,SAAQ,uBAAuB;IACzE,+DAA+D;IAC/D,IAAI,CAAC,EAAE,SAAS,CAAA;IAChB,4BAA4B;IAC5B,MAAM,EAAE,MAAM,CAAA;CACf;AAED;;;;;;GAMG;AACH,MAAM,WAAW,yBAA0B,SAAQ,uBAAuB;IACxE,IAAI,EAAE,OAAO,CAAA;IACb,MAAM,EAAE,MAAM,CAAA;IACd,OAAO,EAAE,MAAM,CAAA;IACf,kDAAkD;IAClD,OAAO,EAAE,MAAM,CAAA;IACf,wEAAwE;IACxE,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CACnC;AAED,MAAM,MAAM,oBAAoB,GAAG,yBAAyB,GAAG,0BAA0B,CAAA;AAEzF,qEAAqE;AACrE,eAAO,MAAM,yBAAyB,YAAY,CAAA;AAElD,2EAA2E;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AAwB;IAI9D,OAAO,CAAC,QAAQ,CAAC,QAAQ;IAHrC,OAAO,CAAC,MAAM,CAAsC;IACpD,OAAO,CAAC,WAAW,CAA+C;gBAErC,QAAQ,SAAsB;IAE3D,IAAI,IAAI,MAAM;IAId,MAAM,IAAI,sBAAsB;IAIhC;;;;;;;;OAQG;IACH,QAAQ,IAAI,sBAAsB;IAY5B,IAAI,IAAI,OAAO,CAAC,sBAAsB,CAAC;YAS/B,IAAI;IAcZ,KAAK,CAAC,QAAQ,EAAE,sBAAsB,GAAG,OAAO,CAAC,sBAAsB,CAAC;IASxE,MAAM,CAAC,KAAK,EAAE,OAAO,CAAC,sBAAsB,CAAC,GAAG,OAAO,CAAC,sBAAsB,CAAC;IAgBrF,2EAA2E;IACrE,YAAY,CAAC,MAAM,EAAE,qBAAqB,EAAE,GAAG,OAAO,CAAC,sBAAsB,CAAC;IAKpF,gFAAgF;IAC1E,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,oBAAoB,GAAG,OAAO,CAAC,sBAAsB,CAAC;IAKvF,qCAAqC;IAC/B,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,sBAAsB,CAAC;IAO9D,iEAAiE;IAC3D,wBAAwB,CAAC,KAAK,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO,CAAC,sBAAsB,CAAC;CAO7G"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { Context } from '@deepseek-ai/cordis';
|
|
2
|
+
import type { ClinePassAccountPool } from './account-pool.ts';
|
|
3
|
+
import type { ClinePassEngine } from './engine.ts';
|
|
4
|
+
import type { ClinePassStore } from './store.ts';
|
|
5
|
+
import type { ClinePassModelSettingsStore } from './token-store.ts';
|
|
6
|
+
import type { ClinePassWebStatus } from '../../shared/cline-pass-contracts.ts';
|
|
7
|
+
export interface ClinePassToolsOptions {
|
|
8
|
+
settings: ClinePassModelSettingsStore;
|
|
9
|
+
accountPool: ClinePassAccountPool;
|
|
10
|
+
store: ClinePassStore;
|
|
11
|
+
engine: ClinePassEngine;
|
|
12
|
+
status(): Promise<ClinePassWebStatus>;
|
|
13
|
+
/** Whether the route is currently served by this plugin. */
|
|
14
|
+
serving(): boolean;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Register every `cline_pass_*` tool.
|
|
18
|
+
* @returns one disposer bundle, or an empty list when no tools service exists.
|
|
19
|
+
*/
|
|
20
|
+
export declare function registerClinePassTools(ctx: Context, options: ClinePassToolsOptions): Array<() => void>;
|
|
21
|
+
//# sourceMappingURL=tools.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../../../../src/host/cline-pass/tools.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAGlD,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,2BAA2B,EAAE,MAAM,kBAAkB,CAAA;AAGnE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,sCAAsC,CAAA;AA0H9E,MAAM,WAAW,qBAAqB;IACpC,QAAQ,EAAE,2BAA2B,CAAA;IACrC,WAAW,EAAE,oBAAoB,CAAA;IACjC,KAAK,EAAE,cAAc,CAAA;IACrB,MAAM,EAAE,eAAe,CAAA;IACvB,MAAM,IAAI,OAAO,CAAC,kBAAkB,CAAC,CAAA;IACrC,4DAA4D;IAC5D,OAAO,IAAI,OAAO,CAAA;CACnB;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,GAAG,EAAE,OAAO,EAAE,OAAO,EAAE,qBAAqB,GAAG,KAAK,CAAC,MAAM,IAAI,CAAC,CA8jBtG"}
|