@eddyskywalker/dsh-chatgpt-subscription 0.32.0 → 0.34.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 +81 -0
- package/README.md +100 -111
- package/lib/client.js +4731 -1239
- package/lib/client.js.map +1 -1
- package/lib/index.js +11514 -3162
- package/lib/types/client/common/format.d.ts +10 -0
- package/lib/types/client/common/format.d.ts.map +1 -1
- package/lib/types/client/hub/brand-icons.d.ts +18 -2
- package/lib/types/client/hub/brand-icons.d.ts.map +1 -1
- package/lib/types/client/hub/hub-styles.d.ts.map +1 -1
- package/lib/types/client/hub/providers.d.ts.map +1 -1
- package/lib/types/client/index.d.ts +4 -0
- package/lib/types/client/index.d.ts.map +1 -1
- package/lib/types/client/minimax-code/VideoFormDialog.d.ts +46 -50
- package/lib/types/client/minimax-code/VideoFormDialog.d.ts.map +1 -1
- package/lib/types/client/minimax-code/locales.d.ts +80 -20
- 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 +17 -11
- package/lib/types/client/minimax-code/video-command-host.d.ts.map +1 -1
- package/lib/types/client/minimax-code/video-command-icon.d.ts +38 -0
- package/lib/types/client/minimax-code/video-command-icon.d.ts.map +1 -0
- package/lib/types/client/minimax-code/video-command.d.ts +53 -59
- package/lib/types/client/minimax-code/video-command.d.ts.map +1 -1
- package/lib/types/client/minimax-code/video-media-dropzone.d.ts +57 -0
- package/lib/types/client/minimax-code/video-media-dropzone.d.ts.map +1 -0
- package/lib/types/client/minimax-code/video-media-input.d.ts +173 -0
- package/lib/types/client/minimax-code/video-media-input.d.ts.map +1 -0
- package/lib/types/client/minimax-code/video-presets.d.ts +67 -0
- package/lib/types/client/minimax-code/video-presets.d.ts.map +1 -0
- package/lib/types/client/minimax-code/video-workspace.d.ts +41 -0
- package/lib/types/client/minimax-code/video-workspace.d.ts.map +1 -0
- package/lib/types/client/opendesign/OpenDesignComposerQuota.d.ts +20 -0
- package/lib/types/client/opendesign/OpenDesignComposerQuota.d.ts.map +1 -0
- package/lib/types/client/opendesign/OpenDesignSection.d.ts +18 -0
- package/lib/types/client/opendesign/OpenDesignSection.d.ts.map +1 -0
- package/lib/types/client/opendesign/api.d.ts +45 -0
- package/lib/types/client/opendesign/api.d.ts.map +1 -0
- package/lib/types/client/opendesign/locales.d.ts +689 -0
- package/lib/types/client/opendesign/locales.d.ts.map +1 -0
- package/lib/types/client/opendesign/styles.d.ts +11 -0
- package/lib/types/client/opendesign/styles.d.ts.map +1 -0
- package/lib/types/client/qoder/QoderComposerQuota.d.ts +41 -0
- package/lib/types/client/qoder/QoderComposerQuota.d.ts.map +1 -0
- package/lib/types/client/qoder/QoderSection.d.ts +36 -0
- package/lib/types/client/qoder/QoderSection.d.ts.map +1 -0
- package/lib/types/client/qoder/api.d.ts +4 -0
- package/lib/types/client/qoder/api.d.ts.map +1 -0
- package/lib/types/client/qoder/locales.d.ts +316 -0
- package/lib/types/client/qoder/locales.d.ts.map +1 -0
- package/lib/types/client/qoder/styles.d.ts +16 -0
- package/lib/types/client/qoder/styles.d.ts.map +1 -0
- package/lib/types/client/qoder/useQoderSection.d.ts +97 -0
- package/lib/types/client/qoder/useQoderSection.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/kimi-code/adapter.d.ts +34 -1
- package/lib/types/host/kimi-code/adapter.d.ts.map +1 -1
- package/lib/types/host/kimi-code/mapper.d.ts +8 -0
- package/lib/types/host/kimi-code/mapper.d.ts.map +1 -1
- package/lib/types/host/kimi-code/types.d.ts +92 -0
- package/lib/types/host/kimi-code/types.d.ts.map +1 -1
- package/lib/types/host/opendesign/account-pool.d.ts +54 -0
- package/lib/types/host/opendesign/account-pool.d.ts.map +1 -0
- package/lib/types/host/opendesign/adapter.d.ts +69 -0
- package/lib/types/host/opendesign/adapter.d.ts.map +1 -0
- package/lib/types/host/opendesign/catalog.d.ts +44 -0
- package/lib/types/host/opendesign/catalog.d.ts.map +1 -0
- package/lib/types/host/opendesign/client.d.ts +148 -0
- package/lib/types/host/opendesign/client.d.ts.map +1 -0
- package/lib/types/host/opendesign/line.d.ts +49 -0
- package/lib/types/host/opendesign/line.d.ts.map +1 -0
- package/lib/types/host/opendesign/mapper.d.ts +128 -0
- package/lib/types/host/opendesign/mapper.d.ts.map +1 -0
- package/lib/types/host/opendesign/oauth.d.ts +105 -0
- package/lib/types/host/opendesign/oauth.d.ts.map +1 -0
- package/lib/types/host/opendesign/routes.d.ts +74 -0
- package/lib/types/host/opendesign/routes.d.ts.map +1 -0
- package/lib/types/host/opendesign/token-store.d.ts +154 -0
- package/lib/types/host/opendesign/token-store.d.ts.map +1 -0
- package/lib/types/host/opendesign/types.d.ts +180 -0
- package/lib/types/host/opendesign/types.d.ts.map +1 -0
- package/lib/types/host/qoder/account-pool.d.ts +137 -0
- package/lib/types/host/qoder/account-pool.d.ts.map +1 -0
- package/lib/types/host/qoder/adapter.d.ts +158 -0
- package/lib/types/host/qoder/adapter.d.ts.map +1 -0
- package/lib/types/host/qoder/adopt.d.ts +146 -0
- package/lib/types/host/qoder/adopt.d.ts.map +1 -0
- package/lib/types/host/qoder/client.d.ts +301 -0
- package/lib/types/host/qoder/client.d.ts.map +1 -0
- package/lib/types/host/qoder/cosy.d.ts +173 -0
- package/lib/types/host/qoder/cosy.d.ts.map +1 -0
- package/lib/types/host/qoder/mapper.d.ts +235 -0
- package/lib/types/host/qoder/mapper.d.ts.map +1 -0
- package/lib/types/host/qoder/model-catalog.d.ts +231 -0
- package/lib/types/host/qoder/model-catalog.d.ts.map +1 -0
- package/lib/types/host/qoder/oauth.d.ts +134 -0
- package/lib/types/host/qoder/oauth.d.ts.map +1 -0
- package/lib/types/host/qoder/routes.d.ts +119 -0
- package/lib/types/host/qoder/routes.d.ts.map +1 -0
- package/lib/types/host/qoder/token-store.d.ts +280 -0
- package/lib/types/host/qoder/token-store.d.ts.map +1 -0
- package/lib/types/host/qoder/types.d.ts +257 -0
- package/lib/types/host/qoder/types.d.ts.map +1 -0
- package/lib/types/host/workbuddy/adapter.d.ts.map +1 -1
- package/lib/types/host/workbuddy/mapper.d.ts +1 -0
- package/lib/types/host/workbuddy/mapper.d.ts.map +1 -1
- package/lib/types/index.d.ts +15 -0
- package/lib/types/index.d.ts.map +1 -1
- package/lib/types/shared/opendesign-contracts.d.ts +159 -0
- package/lib/types/shared/opendesign-contracts.d.ts.map +1 -0
- package/lib/types/shared/qoder-contracts.d.ts +332 -0
- package/lib/types/shared/qoder-contracts.d.ts.map +1 -0
- package/package.json +1 -1
|
@@ -25,7 +25,9 @@ import { KimiCodeAccountPool } from './account-pool.ts';
|
|
|
25
25
|
* - `RATE_LIMIT` — a 429 that is genuine back-pressure ("too many requests"),
|
|
26
26
|
* which the documentation describes as transient and which does belong to the
|
|
27
27
|
* account that hit it, so rotation on it still earns its keep;
|
|
28
|
-
* - `TRANSPORT` — a connection that
|
|
28
|
+
* - `TRANSPORT` — a connection that failed to carry the response: none at all,
|
|
29
|
+
* a body severed mid-stream (`streamFailure`), or a stream that ended without
|
|
30
|
+
* its terminal event (`assertStreamComplete`);
|
|
29
31
|
* - `TIMEOUT` — a stalled stream, handled by the idle watchdog.
|
|
30
32
|
*
|
|
31
33
|
* Deliberately outside the set:
|
|
@@ -102,6 +104,18 @@ export interface KimiFailureClassification {
|
|
|
102
104
|
}
|
|
103
105
|
/** Short, single-line excerpt of one error body, safe to show a user. */
|
|
104
106
|
export declare function summarizeFailureBody(raw: string): string;
|
|
107
|
+
/**
|
|
108
|
+
* Whether one failure detail is the gateway refusing a body for its SIZE.
|
|
109
|
+
*
|
|
110
|
+
* The managed gateway answers an oversized request with
|
|
111
|
+
* `total message size 5943865 exceeds limit 2097152` and no status beyond 400:
|
|
112
|
+
* the figures are bytes, and the wording matches nothing the shared overflow
|
|
113
|
+
* detector looks for. It is recognized HERE rather than in
|
|
114
|
+
* `common/context-overflow.ts` on purpose — that detector is shared by every
|
|
115
|
+
* route in this plugin, so a Kimi-specific sentence added there would
|
|
116
|
+
* reclassify other lines' failures on wording they never send.
|
|
117
|
+
*/
|
|
118
|
+
export declare function isKimiBodySizeRefusal(detail: string): boolean;
|
|
105
119
|
/**
|
|
106
120
|
* Classify one non-2xx response for the retry policy.
|
|
107
121
|
*
|
|
@@ -168,6 +182,25 @@ export declare class KimiCodeAdapter extends LlmAdapter {
|
|
|
168
182
|
* shipped fallback otherwise, narrowed by the user's enabled selection.
|
|
169
183
|
*/
|
|
170
184
|
private catalog;
|
|
185
|
+
/**
|
|
186
|
+
* The single window this line reports AND budgets against.
|
|
187
|
+
*
|
|
188
|
+
* The resolution lives here, in the one place both readers go through, rather
|
|
189
|
+
* than at each call site: `resolveModel` publishes this number to DSH (which
|
|
190
|
+
* computes its compaction threshold from it) and `requestStream` sizes the
|
|
191
|
+
* completion budget with it, so two independent resolutions would let the
|
|
192
|
+
* promise and the budget drift apart.
|
|
193
|
+
*
|
|
194
|
+
* By default the window is published exactly as declared, and a user override
|
|
195
|
+
* is an ordinary declared window: an explicit 1M is the model's advertised
|
|
196
|
+
* capacity as this user chose it, and silently shrinking it would take away
|
|
197
|
+
* the context they asked for. A session that outgrows the byte ceiling is
|
|
198
|
+
* recovered at the wall (CONTEXT_OVERFLOW_CODE), not pre-emptively summarized.
|
|
199
|
+
*
|
|
200
|
+
* A deployment that would rather compact BEFORE the wall sets
|
|
201
|
+
* DSH_KIMI_CODE_BYTES_PER_TOKEN, and then the override is bounded like every
|
|
202
|
+
* other window — see {@link effectiveContextWindow}.
|
|
203
|
+
*/
|
|
171
204
|
private contextWindowFor;
|
|
172
205
|
listModels(provider?: string): Promise<readonly LlmModelInfo[]>;
|
|
173
206
|
resolveModel(provider: string, modelId: string, signal?: AbortSignal): Promise<LlmResolvedModelInfo>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../../../../src/host/kimi-code/adapter.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,UAAU,EAEV,iBAAiB,
|
|
1
|
+
{"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../../../../src/host/kimi-code/adapter.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,UAAU,EAEV,iBAAiB,EAGjB,KAAK,eAAe,EACpB,KAAK,YAAY,EACjB,KAAK,eAAe,EACpB,KAAK,oBAAoB,EACzB,KAAK,mBAAmB,EACxB,KAAK,mBAAmB,EACxB,KAAK,WAAW,EACjB,MAAM,sBAAsB,CAAA;AAC7B,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAA;AACrE,OAAO,EAGL,WAAW,EAUX,mBAAmB,EACpB,MAAM,YAAY,CAAA;AACnB,OAAO,EACL,mBAAmB,EACnB,sBAAsB,EAEtB,KAAK,oBAAoB,EAEzB,KAAK,uBAAuB,EAC7B,MAAM,kBAAkB,CAAA;AAGzB,OAAO,EACL,iBAAiB,EACjB,kBAAkB,EAUnB,MAAM,aAAa,CAAA;AACpB,OAAO,EAcL,KAAK,qBAAqB,EAC1B,KAAK,qBAAqB,EAI3B,MAAM,aAAa,CAAA;AAiFpB,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAA;AAKvD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACH,eAAO,MAAM,6BAA6B,EAAE;IAC1C,IAAI,EAAE,QAAQ,CAAA;IACd,UAAU,EAAE,MAAM,CAAA;IAClB,cAAc,EAAE,MAAM,EAAE,CAAA;IACxB,OAAO,EAAE;QAAE,cAAc,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,MAAM,CAAC;QAAC,WAAW,EAAE,MAAM,CAAA;KAAE,CAAA;CAM7E,CAAA;AAID,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|
|
|
260
260
|
* sent at all. The measured size is the real serialized body, so it accounts
|
|
261
261
|
* for tool schemas and inlined images the caller cannot easily estimate.
|
|
262
262
|
*
|
|
263
|
+
* The error code is CONTEXT_OVERFLOW_CODE, not PROVIDER_ERROR, because naming the
|
|
264
|
+
* remedy in prose is not the same as being able to act on it: DSH forces a
|
|
265
|
+
* compaction and retries the same step only for that one code, and every other
|
|
266
|
+
* 400-shaped failure ends the turn. A byte ceiling is answered by the same
|
|
267
|
+
* compression a token ceiling is — the conversation shrinks either way — so the
|
|
268
|
+
* body of the message stays as specific as it was while the code becomes one the
|
|
269
|
+
* host can recover from.
|
|
270
|
+
*
|
|
263
271
|
* @returns the serialized body, so a caller that is about to send it does not
|
|
264
272
|
* serialize a body of up to tens of megabytes a second time.
|
|
265
273
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mapper.d.ts","sourceRoot":"","sources":["../../../../src/host/kimi-code/mapper.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAGH,OAAO,EAGL,KAAK,oBAAoB,EAEzB,KAAK,eAAe,EACpB,KAAK,OAAO,EACZ,KAAK,WAAW,EAEjB,MAAM,yBAAyB,CAAA;AAKhC,OAAO,EAAE,uBAAuB,EAAmB,MAAM,0BAA0B,CAAA;AACnF,OAAO,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAA;AAEnE,OAAO,EAAE,oBAAoB,EAAE,uBAAuB,EAAE,CAAA;AACxD,OAAO,EACL,sBAAsB,EACtB,uBAAuB,EACvB,uBAAuB,EACvB,4BAA4B,EAC5B,kBAAkB,EAClB,sBAAsB,EAItB,0BAA0B,EAC1B,kBAAkB,EAClB,oBAAoB,EAEpB,KAAK,qBAAqB,EAC1B,KAAK,oBAAoB,EACzB,KAAK,qBAAqB,EAC3B,MAAM,6BAA6B,CAAA;AAGpC,OAAO,EACL,sBAAsB,EACtB,uBAAuB,EACvB,uBAAuB,EACvB,4BA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AAE,MAAM,GAAG,IAAI,CAWzG;AAWD;;;;;;;;;;GAUG;AACH,wBAAgB,aAAa,CAC3B,SAAS,CAAC,EAAE,MAAM,EAClB,SAAS,CAAC,EAAE,MAAM,GACjB,kBAAkB,GAAG;IAAE,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,CAmBlD;AASD,oFAAoF;AACpF,wBAAgB,eAAe,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAUxD;AAmBD,uEAAuE;AACvE,wBAAgB,WAAW,CAAC,KAAK,EAAE,mBAAmB,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,WAAW,EAAE,CAWzF;AAED,kEAAkE;AAClE,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,mBAAmB,GAAG,IAAI,CAUrE"}
|
|
@@ -134,6 +134,98 @@ export declare const ANTHROPIC_MESSAGES_PATH = "/v1/messages?beta=true";
|
|
|
134
134
|
export declare const DEFAULT_MAX_MESSAGE_BODY_BYTES = 2097152;
|
|
135
135
|
/** Ceiling this process enforces, honouring the deployment override. */
|
|
136
136
|
export declare function maxMessageBodyBytes(env?: NodeJS.ProcessEnv): number;
|
|
137
|
+
/**
|
|
138
|
+
* Bytes one METERED token is assumed to occupy when a deployment asks this route
|
|
139
|
+
* to fold its published window against the byte ceiling.
|
|
140
|
+
*
|
|
141
|
+
* The unit is not "bytes per real token" but "bytes per token as the host COUNTS
|
|
142
|
+
* it": DSH prices text at a fixed four characters per token
|
|
143
|
+
* (`@deepseek-ai/dsh-token-meter`'s estimate.ts, CHARS_PER_TOKEN = 4) whatever
|
|
144
|
+
* those characters weigh on the wire. So the figure is four characters per token
|
|
145
|
+
* times the bytes of one character, and each density lands somewhere different:
|
|
146
|
+
*
|
|
147
|
+
* | density | bytes/metered token | 2 MB wall |
|
|
148
|
+
* | ------------------------------------------ | ------------------- | --------- |
|
|
149
|
+
* | ASCII: code, patches, JSON tool results | 4 | 524_288 |
|
|
150
|
+
* | CJK prose mixed with English code and JSON | 8 | 262_144 |
|
|
151
|
+
* | dense CJK | 12 | 174_763 |
|
|
152
|
+
*
|
|
153
|
+
* These are the values DSH_KIMI_CODE_BYTES_PER_TOKEN accepts, and what each buys.
|
|
154
|
+
* Folding is a choice about WHERE compaction fires, never about safety: with a
|
|
155
|
+
* wall at N metered tokens the host's threshold is
|
|
156
|
+
* `floor(min(0.8 x window, window - 65_536))` (this route declares no
|
|
157
|
+
* `defaultMaxTokens`, so nothing is reserved), and the table says which densities
|
|
158
|
+
* sit above it.
|
|
159
|
+
*
|
|
160
|
+
* - unset: no folding at all. The window the model declares — or the one the user
|
|
161
|
+
* explicitly overrode — is published exactly as it is. A long session reaches
|
|
162
|
+
* the 2 MB wall and recovers there, because the refusal carries
|
|
163
|
+
* CONTEXT_OVERFLOW_CODE; nothing is silently given up up front;
|
|
164
|
+
* - 4: publish 524_288, threshold 419_430. Code-dominated sessions compact
|
|
165
|
+
* BEFORE the wall with 104_858 metered tokens of slack, which is the point of
|
|
166
|
+
* the setting; mixed and CJK traffic still meets the wall first;
|
|
167
|
+
* - 5: publish 419_430, threshold 335_544. Same shape, a little less slack;
|
|
168
|
+
* - 8: publish 262_144, threshold 196_608. ASCII and mixed text both compact in
|
|
169
|
+
* time; dense CJK does not;
|
|
170
|
+
* - 12: publish 174_762, threshold 109_226. All three densities compact in time,
|
|
171
|
+
* at the cost of publishing a small window (a CJK-first deployment's choice).
|
|
172
|
+
*
|
|
173
|
+
* Anything smaller than 4 makes the published window larger than the byte ceiling
|
|
174
|
+
* can ever fill (2 -> 1_048_576 against a 524_288-token ASCII wall), so the
|
|
175
|
+
* threshold sits above even the ASCII wall and the setting buys nothing but a
|
|
176
|
+
* window every session is refused before filling.
|
|
177
|
+
*
|
|
178
|
+
* Bytes per metered token in this process, or undefined when folding is off.
|
|
179
|
+
*
|
|
180
|
+
* DSH_KIMI_CODE_BYTES_PER_TOKEN is an OPTIONAL early-compaction switch, not a
|
|
181
|
+
* safety guard, and the distinction decides what a bad value must do. A typo
|
|
182
|
+
* cannot weaken anything here — the recovery code on an oversized refusal is the
|
|
183
|
+
* safety net and it is always armed — so an empty, unparsable, zero or negative
|
|
184
|
+
* value simply means "no folding", the same as leaving the variable out. (The
|
|
185
|
+
* byte CEILING keeps the opposite rule, because THAT is a guard:
|
|
186
|
+
* `maxMessageBodyBytes` falls back to the real limit rather than to no limit.)
|
|
187
|
+
*
|
|
188
|
+
* Undefined rather than a sentinel number on purpose: every caller has to decide
|
|
189
|
+
* what "no ceiling" means for it, and a magic value like Infinity would silently
|
|
190
|
+
* flow into arithmetic instead of forcing that decision.
|
|
191
|
+
*/
|
|
192
|
+
export declare function wireBytesPerToken(env?: NodeJS.ProcessEnv): number | undefined;
|
|
193
|
+
/**
|
|
194
|
+
* Token ceiling the body limit implies at the configured density, or undefined
|
|
195
|
+
* when folding is off.
|
|
196
|
+
*
|
|
197
|
+
* The gateway in front of this route counts BYTES while DSH's compaction
|
|
198
|
+
* thresholds count metered tokens taken from the window an adapter declares, and
|
|
199
|
+
* the two never meet on their own. Expressing the byte ceiling in the unit the
|
|
200
|
+
* host acts on is the same budget-first rule the official kimi-cli applies in
|
|
201
|
+
* `soul/compaction.py::should_auto_compact` — it compacts at 85% of the window or
|
|
202
|
+
* with 50K tokens left and never special-cases 2097152. This route applies that
|
|
203
|
+
* rule only when a deployment asks for it, because "smaller window" is a
|
|
204
|
+
* behaviour change to the model's advertised capacity, not a bug fix.
|
|
205
|
+
*/
|
|
206
|
+
export declare function byteDerivedTokenCap(env?: NodeJS.ProcessEnv): number | undefined;
|
|
207
|
+
/**
|
|
208
|
+
* Context window this route will actually honour for one model.
|
|
209
|
+
*
|
|
210
|
+
* Both what `resolveModel` reports to DSH — which is where the compaction
|
|
211
|
+
* threshold is computed — and what the request builder budgets against, so the
|
|
212
|
+
* promise and the budget cannot drift apart.
|
|
213
|
+
*
|
|
214
|
+
* With folding OFF, which is the default, this is the declared window itself,
|
|
215
|
+
* including a window the user overrode by hand: the vendor's figure and the
|
|
216
|
+
* user's explicit choice are both respected, and a session that outgrows them is
|
|
217
|
+
* recovered at the byte wall rather than pre-emptively summarized.
|
|
218
|
+
*
|
|
219
|
+
* With folding ON it is the smaller of the declared window and
|
|
220
|
+
* {@link byteDerivedTokenCap}: one number for both readers, so what the host
|
|
221
|
+
* believes the model can hold is what the guard lets it send.
|
|
222
|
+
*
|
|
223
|
+
* A window that is missing, zero, negative or not finite is not trusted. It falls
|
|
224
|
+
* back to {@link DEFAULT_CONTEXT_WINDOW} (or to the byte-derived cap when that is
|
|
225
|
+
* smaller), and the result never drops below 1 so no caller ends up with an empty
|
|
226
|
+
* window.
|
|
227
|
+
*/
|
|
228
|
+
export declare function effectiveContextWindow(tokenWindow: number, env?: NodeJS.ProcessEnv): number;
|
|
137
229
|
/**
|
|
138
230
|
* Base64 image payload one request on this route may carry.
|
|
139
231
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/host/kimi-code/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,KAAK,EAAE,uBAAuB,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,qCAAqC,CAAA;AAIhH,eAAO,MAAM,WAAW,cAAc,CAAA;AACtC,eAAO,MAAM,aAAa,cAAc,CAAA;AAExC;;;;;GAKG;AACH,eAAO,MAAM,mBAAmB,yCAAyC,CAAA;AAEzE,+EAA+E;AAC/E,eAAO,MAAM,kBAAkB,0BAA0B,CAAA;AAEzD,4DAA4D;AAC5D,eAAO,MAAM,yBAAyB,oCAAoC,CAAA;AAC1E,wFAAwF;AACxF,eAAO,MAAM,gBAAgB,qBAAqB,CAAA;AAClD,2DAA2D;AAC3D,eAAO,MAAM,sBAAsB,iDAAiD,CAAA;AAEpF,6EAA6E;AAC7E,eAAO,MAAM,YAAY,EAAE,MAAM,CAAC,cAAc,EAAE;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,MA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AY,CAE3D;AAED,sEAAsE;AACtE,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,EAAE,CAE7D;AAED;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,MAAM,GAAG,KAAK,CAAC,MAAM,GAAG,OAAO,GAAG,OAAO,CAAC,CAKrF;AAED;;;;;;;;GAQG;AACH,eAAO,MAAM,uBAAuB,OAAQ,CAAA;AAE5C;;;;;;;;GAQG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,MAAM,EAAE,aAAa,CAAC,EAAE,MAAM,GAAG,MAAM,CAKlF;AAED;;;;;;;;;GASG;AACH,MAAM,MAAM,YAAY,GAAG,IAAI,GAAG,IAAI,CAAA;AAEtC,mEAAmE;AACnE,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,YAAY,CAEpE;AAED;;;;;;;GAOG;AACH,wBAAgB,oBAAoB,CAClC,SAAS,EAAE,MAAM,EACjB,aAAa,EAAE,MAAM,EACrB,oBAAoB,CAAC,EAAE,MAAM,GAC5B,MAAM,CAKR;AAED,gFAAgF;AAChF,wBAAgB,yBAAyB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,uBAAuB,CAE1F;AAED,gEAAgE;AAChE,eAAO,MAAM,eAAe,EAAE,aAAa,CAAC;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,aAAa,EAAE,MAAM,CAAA;CAAE,CACY,CAAA"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { AccountPoolCore, type PoolAccountShape, type PoolData } from '../common/account-pool.ts';
|
|
2
|
+
import type { CredentialStore } from '../token-store.ts';
|
|
3
|
+
import { FileCredentialStore, type OpenDesignCredentials } from './token-store.ts';
|
|
4
|
+
import type { AccountPoolStatusDto, AccountRotationStrategy } from '../../shared/account-pool-contracts.ts';
|
|
5
|
+
import type { OpenDesignAccountSummaryDto } from '../../shared/opendesign-contracts.ts';
|
|
6
|
+
/** One pooled OpenDesign key: the bearer key plus the display facts the card renders. */
|
|
7
|
+
export interface OpenDesignPoolAccount extends PoolAccountShape<OpenDesignCredentials> {
|
|
8
|
+
/** Model id this account last served, for the card's detail line. */
|
|
9
|
+
lastModelId?: string;
|
|
10
|
+
}
|
|
11
|
+
export type OpenDesignPoolStatusDto = AccountPoolStatusDto;
|
|
12
|
+
/** Encrypted pool file this line owns. */
|
|
13
|
+
export declare function opendesignPoolPath(): string;
|
|
14
|
+
/** The credential name a deployment can export instead of pasting a key. */
|
|
15
|
+
export declare const OPENDESIGN_API_KEY_ENV = "OPENDESIGN_API_KEY";
|
|
16
|
+
/** Stable identity of one key; see token-store for why the digest is safe to hold. */
|
|
17
|
+
export declare function opendesignAccountKey(credentials: OpenDesignCredentials): string;
|
|
18
|
+
/** Validate and normalize one whole pool document. */
|
|
19
|
+
export declare function parseOpenDesignPoolData(value: unknown): PoolData<OpenDesignPoolAccount>;
|
|
20
|
+
export interface OpenDesignAccountPoolOptions {
|
|
21
|
+
/** Pre-pool credential file the pool mirrors its primary account into. */
|
|
22
|
+
store?: FileCredentialStore;
|
|
23
|
+
/** Test seam; production builds the platform backend from the pool path. */
|
|
24
|
+
backend?: CredentialStore<PoolData<OpenDesignPoolAccount>>;
|
|
25
|
+
maxAccounts?: number;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* OpenDesign's account pool.
|
|
29
|
+
*
|
|
30
|
+
* One credential kind only: a static API key. None of the kernel's refresh
|
|
31
|
+
* hooks apply, so they are simply not wired — a key has no expiry to refresh
|
|
32
|
+
* against, and a rejected key is replaced, not refreshed.
|
|
33
|
+
*/
|
|
34
|
+
export declare class OpenDesignAccountPool extends AccountPoolCore<OpenDesignCredentials, OpenDesignPoolAccount, OpenDesignAccountSummaryDto> {
|
|
35
|
+
private readonly store;
|
|
36
|
+
constructor(options?: OpenDesignAccountPoolOptions);
|
|
37
|
+
/**
|
|
38
|
+
* Pick the key for the next request, skipping accounts already tried.
|
|
39
|
+
*
|
|
40
|
+
* The credential carries its own base-URL override, so the account and the key
|
|
41
|
+
* are returned together.
|
|
42
|
+
*/
|
|
43
|
+
getEffectiveCredential(excludeIds?: ReadonlySet<string>, fetchFn?: typeof fetch): Promise<{
|
|
44
|
+
account: OpenDesignPoolAccount;
|
|
45
|
+
credentials: OpenDesignCredentials;
|
|
46
|
+
}>;
|
|
47
|
+
/** The pre-pool credential file this pool mirrors its primary account into. */
|
|
48
|
+
mirrorStore(): FileCredentialStore;
|
|
49
|
+
/** The rotation strategy as the settings card renders it. */
|
|
50
|
+
strategy(): Promise<AccountRotationStrategy>;
|
|
51
|
+
/** Remember which model an account last served, best-effort. */
|
|
52
|
+
recordModel(accountId: string, model: string): Promise<void>;
|
|
53
|
+
}
|
|
54
|
+
//# sourceMappingURL=account-pool.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"account-pool.d.ts","sourceRoot":"","sources":["../../../../src/host/opendesign/account-pool.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,eAAe,EAGf,KAAK,gBAAgB,EACrB,KAAK,QAAQ,EACd,MAAM,2BAA2B,CAAA;AAClC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AACxD,OAAO,EACL,mBAAmB,EAKnB,KAAK,qBAAqB,EAC3B,MAAM,kBAAkB,CAAA;AAEzB,OAAO,KAAK,EACV,oBAAoB,EACpB,uBAAuB,EACxB,MAAM,wCAAwC,CAAA;AAC/C,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,sCAAsC,CAAA;AAEvF,yFAAyF;AACzF,MAAM,WAAW,qBAAsB,SAAQ,gBAAgB,CAAC,qBAAqB,CAAC;IACpF,qEAAqE;IACrE,WAAW,CAAC,EAAE,MAAM,CAAA;CACrB;AAED,MAAM,MAAM,uBAAuB,GAAG,oBAAoB,CAAA;AAE1D,0CAA0C;AAC1C,wBAAgB,k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
*
|
|
5
|
+
* Transport and mapping live in `client.ts` / `mapper.ts`. This module owns the
|
|
6
|
+
* request loop: which account, and when an attempt is abandoned. There is no
|
|
7
|
+
* channel layer: the gateway chooses the upstream, and a request proves nothing
|
|
8
|
+
* beyond the account that served it.
|
|
9
|
+
*
|
|
10
|
+
* @module dsh-chatgpt-subscription/opendesign-adapter
|
|
11
|
+
*/
|
|
12
|
+
import { LlmAdapter, type GenerateOptions as HarnessGenerateOptions, type LlmModelInfo, type LlmProviderInfo, type LlmResolvedModelInfo, type PreparedAdapterCall, type ResolvedRetryPolicy, type StreamChunk } from '@deepseek-ai/dsh-llm';
|
|
13
|
+
import type { OpenDesignModelSettingsStore } from './token-store.ts';
|
|
14
|
+
import type { OpenDesignAccountPool } from './account-pool.ts';
|
|
15
|
+
import { type AttachmentImageReader } from '../common/request-images.ts';
|
|
16
|
+
/**
|
|
17
|
+
* Fallback effort ladder for a model no source describes.
|
|
18
|
+
*
|
|
19
|
+
* Per-model ladders come from the shipped table (transcribed from this
|
|
20
|
+
* repository's sibling registries) and from the live catalog; this trio is only
|
|
21
|
+
* what a model with no data at all is offered. The wire carries the id string,
|
|
22
|
+
* so an over-offered level is ignored rather than refused by most gateways —
|
|
23
|
+
* but the ladder still prefers published data for anything the tables know.
|
|
24
|
+
*/
|
|
25
|
+
export declare const REASONING_EFFORT_IDS: readonly string[];
|
|
26
|
+
export interface OpenDesignAdapterOptions {
|
|
27
|
+
/** Proxy-aware fetch for live chat streams. */
|
|
28
|
+
fetchFn: typeof fetch;
|
|
29
|
+
/** Durable attachment service, for request images. */
|
|
30
|
+
attachments?: AttachmentImageReader;
|
|
31
|
+
/** The account pool this adapter rotates over. */
|
|
32
|
+
accountPool: OpenDesignAccountPool;
|
|
33
|
+
}
|
|
34
|
+
export declare class OpenDesignAdapter extends LlmAdapter {
|
|
35
|
+
private readonly modelSettings;
|
|
36
|
+
private readonly options;
|
|
37
|
+
private readonly gate;
|
|
38
|
+
constructor(modelSettings: OpenDesignModelSettingsStore, options: OpenDesignAdapterOptions);
|
|
39
|
+
providerInfo(provider: string): LlmProviderInfo;
|
|
40
|
+
providerRetryPolicy(): ResolvedRetryPolicy;
|
|
41
|
+
imageRequestPricing(): undefined;
|
|
42
|
+
private get accountPool();
|
|
43
|
+
private settings;
|
|
44
|
+
/** Every id the line knows: the shipped table plus the synced live catalog. */
|
|
45
|
+
private knownModelIds;
|
|
46
|
+
/**
|
|
47
|
+
* The ids the route advertises, narrowed by the user's selection and hidden
|
|
48
|
+
* list.
|
|
49
|
+
*
|
|
50
|
+
* The selection is captured against this same id vocabulary (the gateway's
|
|
51
|
+
* own wire ids), so a cold start filters the shipped table through it without
|
|
52
|
+
* the empty-intersection trap a foreign-vocabulary whitelist would spring —
|
|
53
|
+
* and an explicit "everything off" (`[]`) still wins, because that intent
|
|
54
|
+
* does not depend on a vocabulary at all.
|
|
55
|
+
*/
|
|
56
|
+
private visibleModelIds;
|
|
57
|
+
/** One model's resolved descriptor, from the shipped table plus live data. */
|
|
58
|
+
private modelInfo;
|
|
59
|
+
listModels(provider?: string): Promise<readonly LlmModelInfo[]>;
|
|
60
|
+
resolveModel(provider: string, modelId: string, signal?: AbortSignal): Promise<LlmResolvedModelInfo>;
|
|
61
|
+
prepareCall(provider: string, model: string, signal?: AbortSignal): Promise<PreparedAdapterCall>;
|
|
62
|
+
stream(options: HarnessGenerateOptions): AsyncIterable<StreamChunk>;
|
|
63
|
+
/** The message the pool's empty state should raise, in this line's words. */
|
|
64
|
+
private noAccountError;
|
|
65
|
+
private requestStream;
|
|
66
|
+
/** Park an account that refused a request, for the reason it refused. */
|
|
67
|
+
private standDown;
|
|
68
|
+
}
|
|
69
|
+
//# sourceMappingURL=adapter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../../../../src/host/opendesign/adapter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,EACL,UAAU,EAIV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O,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,oBAAoB,CAAC;IAoBpG,WAAW,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAO/F,MAAM,CAAC,OAAO,EAAE,sBAAsB,GAAG,aAAa,CAAC,WAAW,CAAC;IAW1E,6EAA6E;IAC7E,OAAO,CAAC,cAAc;YASP,aAAa;IAoJ5B,yEAAyE;YAC3D,SAAS;CAOxB"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Merge the shipped table, the last gateway listing and the user's per-model
|
|
3
|
+
* override into the descriptor the harness validates.
|
|
4
|
+
*
|
|
5
|
+
* Context window and output cap are provider facts, not preferences: the harness
|
|
6
|
+
* sizes its prompt budget against `context.contextWindow`, so an understated
|
|
7
|
+
* window silently truncates history. This line ships no per-model windows (the
|
|
8
|
+
* gateway publishes none to an API key), so the window is the line default until
|
|
9
|
+
* a live listing or a user override states one.
|
|
10
|
+
*
|
|
11
|
+
* @module dsh-chatgpt-subscription/opendesign-catalog
|
|
12
|
+
*/
|
|
13
|
+
import { type OpenDesignModelInfo } from './types.ts';
|
|
14
|
+
import type { OpenDesignCatalogModel } from './token-store.ts';
|
|
15
|
+
/**
|
|
16
|
+
* The output budget to advertise for one model.
|
|
17
|
+
*
|
|
18
|
+
* `defaultMaxTokens` is what a request asks for, not what the model can emit,
|
|
19
|
+
* and the harness spends it twice: it fills a request's `max_tokens` from it
|
|
20
|
+
* and reserves the same number as completion room before deciding to compact.
|
|
21
|
+
* So a published ceiling clamps the configured budget rather than becoming it,
|
|
22
|
+
* and a budget is never taken past half the window.
|
|
23
|
+
*/
|
|
24
|
+
export declare function resolveOutputBudget(budget: number | undefined, ceiling: number | undefined, contextWindow: number): number | undefined;
|
|
25
|
+
/**
|
|
26
|
+
* Resolve the metadata one model is advertised with.
|
|
27
|
+
*
|
|
28
|
+
* Precedence per field: the user's override, then the last gateway listing,
|
|
29
|
+
* then the shipped table, then the route-wide fallback. The listing sits above
|
|
30
|
+
* the shipped table for the fields the table cannot carry (window, modalities):
|
|
31
|
+
* the table's windows do not exist to be beaten, and its names/prices are
|
|
32
|
+
* curated, so a listing that states no name keeps the table's.
|
|
33
|
+
*/
|
|
34
|
+
export declare function resolveModelInfo(model: string, options: {
|
|
35
|
+
/** Entries persisted by the last catalog sync. */
|
|
36
|
+
synced: readonly OpenDesignCatalogModel[];
|
|
37
|
+
/** Stored context-window override. */
|
|
38
|
+
contextWindowOverride?: number;
|
|
39
|
+
/** Route-wide fallback window. */
|
|
40
|
+
defaultContextWindow?: number;
|
|
41
|
+
/** Route-wide output budget. */
|
|
42
|
+
defaultMaxTokens?: number;
|
|
43
|
+
}): OpenDesignModelInfo;
|
|
44
|
+
//# sourceMappingURL=catalog.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"catalog.d.ts","sourceRoot":"","sources":["../../../../src/host/opendesign/catalog.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,EAML,KAAK,mBAAmB,EACzB,MAAM,YAAY,CAAA;AACnB,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAA;AAc9D;;;;;;;;GAQG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,EAAE,OAAO,EAAE,MAAM,GAAG,SAAS,EAAE,aAAa,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAOtI;AAED;;;;;;;;GAQG;AACH,wBAAgB,gBAAgB,CAC9B,KAAK,EAAE,MAAM,EACb,OAAO,EAAE;IACP,kDAAkD;IAClD,MAAM,EAAE,SAAS,sBAAsB,EAAE,CAAA;IACzC,sCAAsC;IACtC,qBAAqB,CAAC,EAAE,MAAM,CAAA;IAC9B,kCAAkC;IAClC,oBAAoB,CAAC,EAAE,MAAM,CAAA;IAC7B,gCAAgC;IAChC,gBAAgB,CAAC,EAAE,MAAM,CAAA;CAC1B,GACA,mBAAmB,CAoCrB"}
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Transport for the OpenDesign link gateway. Transport only: no account or
|
|
3
|
+
* retry policy lives here (see `adapter.ts`).
|
|
4
|
+
*
|
|
5
|
+
* - `POST {baseURL}/chat/completions` — the chat endpoint this line speaks
|
|
6
|
+
* - `GET {baseURL}/models` — the key's live catalog; also the auth probe,
|
|
7
|
+
* because listing costs no credits while a token of chat does
|
|
8
|
+
*
|
|
9
|
+
* The base URL is the OpenAI spelling and already ends in `/v1`
|
|
10
|
+
* (src/host/opendesign/types.ts records how that was verified), so paths append
|
|
11
|
+
* literally.
|
|
12
|
+
*
|
|
13
|
+
* @module dsh-chatgpt-subscription/opendesign-client
|
|
14
|
+
*/
|
|
15
|
+
import { type OpenDesignDiscoveredModel } from './types.ts';
|
|
16
|
+
export interface OpenDesignHttpResult {
|
|
17
|
+
status: number;
|
|
18
|
+
ok: boolean;
|
|
19
|
+
json: unknown;
|
|
20
|
+
text: string;
|
|
21
|
+
}
|
|
22
|
+
/** Combine a caller signal with a timeout signal. */
|
|
23
|
+
export declare function withTimeout(signal: AbortSignal | undefined, timeoutMs: number | undefined): AbortSignal | undefined;
|
|
24
|
+
/** Strip a trailing slash so paths can be appended literally. */
|
|
25
|
+
export declare function trimBase(baseURL: string): string;
|
|
26
|
+
/** The gateway's chat-completions endpoint for one base URL. */
|
|
27
|
+
export declare function chatURL(baseURL: string): string;
|
|
28
|
+
/** The gateway's catalog endpoint for one base URL. */
|
|
29
|
+
export declare function modelsURL(baseURL: string): string;
|
|
30
|
+
export declare function isRecord(value: unknown): value is Record<string, unknown>;
|
|
31
|
+
/** Send one JSON request and decode whatever comes back; never throws for HTTP errors. */
|
|
32
|
+
export declare function sendJSON(fetchFn: typeof fetch, url: string, { method, apiKey, body, signal, timeoutMs, headers, }?: {
|
|
33
|
+
method?: string;
|
|
34
|
+
apiKey?: string;
|
|
35
|
+
body?: unknown;
|
|
36
|
+
signal?: AbortSignal;
|
|
37
|
+
timeoutMs?: number;
|
|
38
|
+
headers?: Record<string, string>;
|
|
39
|
+
}): Promise<OpenDesignHttpResult>;
|
|
40
|
+
/** Open a streaming chat completion and hand back the live response. */
|
|
41
|
+
export declare function openChatStream({ fetchFn, baseURL, apiKey, body, signal, headers, }: {
|
|
42
|
+
fetchFn: typeof fetch;
|
|
43
|
+
baseURL: string;
|
|
44
|
+
apiKey: string;
|
|
45
|
+
body: unknown;
|
|
46
|
+
signal?: AbortSignal;
|
|
47
|
+
headers?: Record<string, string>;
|
|
48
|
+
}): Promise<Response>;
|
|
49
|
+
/** The gateway's own one-line explanation, when it sent one. */
|
|
50
|
+
export declare function firstMessage(envelope: unknown): string;
|
|
51
|
+
/**
|
|
52
|
+
* The live catalog one key may list.
|
|
53
|
+
*
|
|
54
|
+
* Returns ids plus whatever metadata the listing published, or null on any
|
|
55
|
+
* failure — a refused or unreachable gateway is a fact the caller reports, not
|
|
56
|
+
* an exception the route drops.
|
|
57
|
+
*/
|
|
58
|
+
export declare function fetchGatewayCatalog({ fetchFn, baseURL, apiKey, signal, timeoutMs, }: {
|
|
59
|
+
fetchFn: typeof fetch;
|
|
60
|
+
baseURL: string;
|
|
61
|
+
apiKey: string;
|
|
62
|
+
signal?: AbortSignal;
|
|
63
|
+
timeoutMs?: number;
|
|
64
|
+
}): Promise<{
|
|
65
|
+
ids: string[];
|
|
66
|
+
catalog: Record<string, OpenDesignDiscoveredModel>;
|
|
67
|
+
} | null>;
|
|
68
|
+
/**
|
|
69
|
+
* One id compared without its separators.
|
|
70
|
+
*
|
|
71
|
+
* The AMR control-plane catalog spells ids `public_model_deepseek_v4_1_flash`
|
|
72
|
+
* (the open-source daemon normalizes the same spellings at its boundary), while
|
|
73
|
+
* the link gateway and this line's table use `deepseek-v4.1-flash`. Comparing
|
|
74
|
+
* alphanumerics only maps one onto the other without a per-model translation
|
|
75
|
+
* table that would rot the moment a model is added.
|
|
76
|
+
*/
|
|
77
|
+
export declare function canonicalModelKey(id: string): string;
|
|
78
|
+
/**
|
|
79
|
+
* The control-plane catalog: the AMR-side listing, which DOES carry metadata.
|
|
80
|
+
*
|
|
81
|
+
* `GET {amr}/models` with a control key (the open-source daemon reads the same
|
|
82
|
+
* catalog through `vela model list --all --format json`, whose items carry
|
|
83
|
+
* `metadata.contextWindowTokens`). Ids are normalized onto the known wire ids
|
|
84
|
+
* with {@link canonicalModelKey}; an id the line does not know is kept as the
|
|
85
|
+
* slug it arrived as, never dropped.
|
|
86
|
+
*
|
|
87
|
+
* A runtime key is not accepted here (the console's control-plane surfaces
|
|
88
|
+
* reject it), so this is an OAuth-account capability; the gateway listing stays
|
|
89
|
+
* the path for a pasted key.
|
|
90
|
+
*/
|
|
91
|
+
export declare function fetchControlPlaneCatalog({ fetchFn, controlKey, apiBase, knownIds, signal, timeoutMs, }: {
|
|
92
|
+
fetchFn: typeof fetch;
|
|
93
|
+
controlKey: string;
|
|
94
|
+
apiBase?: string;
|
|
95
|
+
knownIds?: readonly string[];
|
|
96
|
+
signal?: AbortSignal;
|
|
97
|
+
timeoutMs?: number;
|
|
98
|
+
}): Promise<{
|
|
99
|
+
ids: string[];
|
|
100
|
+
catalog: Record<string, OpenDesignDiscoveredModel>;
|
|
101
|
+
} | null>;
|
|
102
|
+
/**
|
|
103
|
+
* Verify one key with the free catalog read.
|
|
104
|
+
*
|
|
105
|
+
* A chat probe would spend credits to learn the same thing, so the probe is the
|
|
106
|
+
* listing: 200 proves the key works (and how many models it sees), 401/403
|
|
107
|
+
* proves it does not, and anything else is reported as the gateway sent it.
|
|
108
|
+
*/
|
|
109
|
+
export declare function testApiKey({ fetchFn, baseURL, apiKey, signal, timeoutMs, }: {
|
|
110
|
+
fetchFn: typeof fetch;
|
|
111
|
+
baseURL: string;
|
|
112
|
+
apiKey: string;
|
|
113
|
+
signal?: AbortSignal;
|
|
114
|
+
timeoutMs?: number;
|
|
115
|
+
}): Promise<{
|
|
116
|
+
authorized: boolean;
|
|
117
|
+
ms: number;
|
|
118
|
+
error: string;
|
|
119
|
+
modelCount: number;
|
|
120
|
+
}>;
|
|
121
|
+
/** One wallet reading: the balance string as served, or the refusal as data. */
|
|
122
|
+
export interface OpenDesignWalletBalance {
|
|
123
|
+
ok: boolean;
|
|
124
|
+
/** USD balance, exactly as the service strings it (e.g. "12.34"). */
|
|
125
|
+
balanceUsd: string | null;
|
|
126
|
+
/** ISO instant the service stamped on the reading, when it sent one. */
|
|
127
|
+
updatedAt: string | null;
|
|
128
|
+
error: string;
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Read one OAuth account's wallet balance with its control key.
|
|
132
|
+
*
|
|
133
|
+
* Wire shape from the open-source daemon's reader
|
|
134
|
+
* (apps/daemon/src/integrations/vela-wallet.ts, nexu-io/open-design): the
|
|
135
|
+
* balance is a STRING matching /^\d+(?:\.\d+)?$/ — a number-shaped field of
|
|
136
|
+
* any other type is not a balance. A refusal is reported as data, never thrown:
|
|
137
|
+
* the card shows it beside controls that keep working without it. Billing reads
|
|
138
|
+
* are display-only upstream too (OPEND-3553 in the same repo): a wallet 401/403
|
|
139
|
+
* says nothing about the chat credential, so it must never mark the account.
|
|
140
|
+
*/
|
|
141
|
+
export declare function fetchWalletBalance({ fetchFn, controlKey, apiBase, signal, timeoutMs, }: {
|
|
142
|
+
fetchFn: typeof fetch;
|
|
143
|
+
controlKey: string;
|
|
144
|
+
apiBase?: string;
|
|
145
|
+
signal?: AbortSignal;
|
|
146
|
+
timeoutMs?: number;
|
|
147
|
+
}): Promise<OpenDesignWalletBalance>;
|
|
148
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../../src/host/opendesign/client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,EAA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
|
2
|
+
import type { AttachmentStore } from '@deepseek-ai/dsh-attachment';
|
|
3
|
+
import { type ProviderRouteClaim } from '../common/provider-route.ts';
|
|
4
|
+
import { OpenDesignAccountPool } from './account-pool.ts';
|
|
5
|
+
import { OpenDesignAdapter } from './adapter.ts';
|
|
6
|
+
import { OpenDesignLoginManager } from './oauth.ts';
|
|
7
|
+
import { OPENDESIGN_ROUTES } from './routes.ts';
|
|
8
|
+
import { OpenDesignModelSettingsStore, type OpenDesignModelSettings } from './token-store.ts';
|
|
9
|
+
import type { HubSummarySource } from '../hub-overview.ts';
|
|
10
|
+
export interface OpenDesignLineOptions {
|
|
11
|
+
/** Proxy-aware fetch that routes and catalog syncs use. */
|
|
12
|
+
fetchFn: typeof fetch;
|
|
13
|
+
/** Controlled/diagnostic fetch that live adapter chat streams use; defaults to fetchFn. */
|
|
14
|
+
modelFetchFn?: typeof fetch;
|
|
15
|
+
/** Durable attachment service, for image input. */
|
|
16
|
+
attachments?: Pick<AttachmentStore, 'readImage' | 'readImageRequest'>;
|
|
17
|
+
}
|
|
18
|
+
export interface OpenDesignLine {
|
|
19
|
+
adapter: OpenDesignAdapter;
|
|
20
|
+
modelSettings: OpenDesignModelSettingsStore;
|
|
21
|
+
accountPool: OpenDesignAccountPool;
|
|
22
|
+
login: OpenDesignLoginManager;
|
|
23
|
+
claim: ProviderRouteClaim;
|
|
24
|
+
disposeRoutes: () => void;
|
|
25
|
+
/** Owner overview card source, read from local snapshots only. */
|
|
26
|
+
hubSource: HubSummarySource;
|
|
27
|
+
/** Release every registration this line made. */
|
|
28
|
+
dispose(): void;
|
|
29
|
+
}
|
|
30
|
+
/** Every id the line knows: the shipped table plus the synced live catalog. */
|
|
31
|
+
export declare function openDesignKnownModelIds(settings: OpenDesignModelSettings): string[];
|
|
32
|
+
/**
|
|
33
|
+
* Every id the line advertises right now.
|
|
34
|
+
*
|
|
35
|
+
* The selection rule is shared by the adapter, the status route and the hub
|
|
36
|
+
* card — they must all read this one function, not three private copies: the
|
|
37
|
+
* user's tick list and the shipped table speak the same id vocabulary here (the
|
|
38
|
+
* gateway's own wire ids), so a cold-start intersection cannot empty the picker,
|
|
39
|
+
* and an explicit "everything off" (`[]`) still wins.
|
|
40
|
+
*/
|
|
41
|
+
export declare function openDesignVisibleModelIds(settings: OpenDesignModelSettings): string[];
|
|
42
|
+
/**
|
|
43
|
+
* Build the line.
|
|
44
|
+
* @param ctx - host plugin context (owns `llm` and `webServer`).
|
|
45
|
+
* @param options - the proxy-aware fetch and the attachment reader.
|
|
46
|
+
*/
|
|
47
|
+
export declare function createOpenDesignLine(ctx: Context, options: OpenDesignLineOptions): OpenDesignLine;
|
|
48
|
+
export { OPENDESIGN_ROUTES };
|
|
49
|
+
//# sourceMappingURL=line.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"line.d.ts","sourceRoot":"","sources":["../../../../src/host/opendesign/line.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAClD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAA;AAClE,OAAO,EAAsB,KAAK,kBAAkB,EAAE,MAAM,6BAA6B,CAAA;AAGzF,OAAO,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAA;AACzD,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAA;AAChD,OAAO,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAA;AACnD,OAAO,EAAoD,iBAAiB,EAAE,MAAM,aAAa,CAAA;AACjG,OAAO,EAAE,4BAA4B,EAAE,KAAK,uBAAuB,EAAE,MAAM,kBAAkB,CAAA;AAE7F,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AAE1D,MAAM,WAAW,qBAAqB;IACpC,2DAA2D;IAC3D,OAAO,EAAE,OAAO,KAAK,CAAA;IACrB,2FAA2F;IAC3F,YAAY,CAAC,EAAE,OAAO,KAAK,C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