@eddyskywalker/dsh-chatgpt-subscription 0.8.4 → 0.9.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 +45 -0
- package/README.md +93 -38
- package/lib/client.js +2126 -1693
- package/lib/client.js.map +1 -1
- package/lib/index.js +7597 -2781
- package/lib/types/client/claude/ClaudeComposerQuota.d.ts +33 -0
- package/lib/types/client/claude/ClaudeComposerQuota.d.ts.map +1 -0
- package/lib/types/client/{zhipu/ZhipuSection.d.ts → claude/ClaudeSection.d.ts} +2 -2
- package/lib/types/client/claude/ClaudeSection.d.ts.map +1 -0
- package/lib/types/client/claude/locales.d.ts +444 -0
- package/lib/types/client/claude/locales.d.ts.map +1 -0
- package/lib/types/client/claude/styles.d.ts +15 -0
- package/lib/types/client/claude/styles.d.ts.map +1 -0
- package/lib/types/client/index.d.ts +1 -1
- package/lib/types/client/index.d.ts.map +1 -1
- package/lib/types/host/claude/__probe-assert.d.ts +2 -0
- package/lib/types/host/claude/__probe-assert.d.ts.map +1 -0
- package/lib/types/host/claude/account-pool.d.ts +580 -0
- package/lib/types/host/claude/account-pool.d.ts.map +1 -0
- package/lib/types/host/claude/adapter.d.ts +267 -0
- package/lib/types/host/claude/adapter.d.ts.map +1 -0
- package/lib/types/host/claude/adopt.d.ts +292 -0
- package/lib/types/host/claude/adopt.d.ts.map +1 -0
- package/lib/types/host/claude/client.d.ts +513 -0
- package/lib/types/host/claude/client.d.ts.map +1 -0
- package/lib/types/host/claude/mapper.d.ts +510 -0
- package/lib/types/host/claude/mapper.d.ts.map +1 -0
- package/lib/types/host/claude/model-catalog.d.ts +365 -0
- package/lib/types/host/claude/model-catalog.d.ts.map +1 -0
- package/lib/types/host/claude/oauth.d.ts +393 -0
- package/lib/types/host/claude/oauth.d.ts.map +1 -0
- package/lib/types/host/claude/routes.d.ts +128 -0
- package/lib/types/host/claude/routes.d.ts.map +1 -0
- package/lib/types/host/claude/token-store.d.ts +312 -0
- package/lib/types/host/claude/token-store.d.ts.map +1 -0
- package/lib/types/host/claude/types.d.ts +237 -0
- package/lib/types/host/claude/types.d.ts.map +1 -0
- package/lib/types/index.d.ts +10 -7
- package/lib/types/index.d.ts.map +1 -1
- package/lib/types/shared/__probe-claude-import.d.ts +2 -0
- package/lib/types/shared/__probe-claude-import.d.ts.map +1 -0
- package/lib/types/shared/claude-contracts.d.ts +337 -0
- package/lib/types/shared/claude-contracts.d.ts.map +1 -0
- package/package.json +1 -1
- package/lib/types/client/zhipu/ZhipuComposerQuota.d.ts +0 -26
- package/lib/types/client/zhipu/ZhipuComposerQuota.d.ts.map +0 -1
- package/lib/types/client/zhipu/ZhipuSection.d.ts.map +0 -1
- package/lib/types/client/zhipu/locales.d.ts +0 -275
- package/lib/types/client/zhipu/locales.d.ts.map +0 -1
- package/lib/types/client/zhipu/styles.d.ts +0 -12
- package/lib/types/client/zhipu/styles.d.ts.map +0 -1
- package/lib/types/host/zhipu/account-pool.d.ts +0 -43
- package/lib/types/host/zhipu/account-pool.d.ts.map +0 -1
- package/lib/types/host/zhipu/adapter.d.ts +0 -93
- package/lib/types/host/zhipu/adapter.d.ts.map +0 -1
- package/lib/types/host/zhipu/client.d.ts +0 -153
- package/lib/types/host/zhipu/client.d.ts.map +0 -1
- package/lib/types/host/zhipu/mapper.d.ts +0 -111
- package/lib/types/host/zhipu/mapper.d.ts.map +0 -1
- package/lib/types/host/zhipu/model-catalog.d.ts +0 -73
- package/lib/types/host/zhipu/model-catalog.d.ts.map +0 -1
- package/lib/types/host/zhipu/routes.d.ts +0 -33
- package/lib/types/host/zhipu/routes.d.ts.map +0 -1
- package/lib/types/host/zhipu/token-store.d.ts +0 -112
- package/lib/types/host/zhipu/token-store.d.ts.map +0 -1
- package/lib/types/host/zhipu/types.d.ts +0 -125
- package/lib/types/host/zhipu/types.d.ts.map +0 -1
- package/lib/types/shared/zhipu-contracts.d.ts +0 -164
- package/lib/types/shared/zhipu-contracts.d.ts.map +0 -1
|
@@ -1,111 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Wire mapping for the GLM Coding Plan chat endpoint.
|
|
3
|
-
*
|
|
4
|
-
* The endpoint is OpenAI Chat Completions shaped. This module absorbs the
|
|
5
|
-
* differences this route actually has, each one drawn from the provider's own
|
|
6
|
-
* documentation rather than assumed from the OpenAI default:
|
|
7
|
-
*
|
|
8
|
-
* 1. **Reasoning rides `delta.reasoning_content`,** not OpenAI's
|
|
9
|
-
* `reasoning_summary`, and is emitted as its own DSH reasoning block.
|
|
10
|
-
* 2. **`reasoning_effort` accepts only the model's own ladder.** The GLM-5.x
|
|
11
|
-
* family takes `low`/`high`/`max` (GLM-5.2 takes two of them), and any other
|
|
12
|
-
* value is an error rather than a hint. DSH's vocabulary is wider, so every
|
|
13
|
-
* value is converged onto the model's ladder before it is sent.
|
|
14
|
-
* 3. **`thinking` is left untouched.** Its default is `enabled`, and
|
|
15
|
-
* GLM-5.3 / GLM-5.3-FLASH / GLM-4.7 reject `thinking.type: "disabled"` as an
|
|
16
|
-
* error — so this route never sends a disabling value for any model and
|
|
17
|
-
* simply omits the field, which is the enabled default for all of them.
|
|
18
|
-
* 4. **No `stream_options`.** The provider's streaming documentation shows the
|
|
19
|
-
* usage object arriving on the final chunk without it, and the field is
|
|
20
|
-
* absent from the documented request schema; sending an undocumented field
|
|
21
|
-
* to this API risks a 400 for no gain.
|
|
22
|
-
*/
|
|
23
|
-
import { type OutboundContentBlock, type GenerateOptions, type StreamChunk } from '../common/llm-compat.ts';
|
|
24
|
-
import type { AttachmentStore } from '@deepseek-ai/dsh-attachment';
|
|
25
|
-
/** Attachment seam this route needs: verified bytes for one durable image. */
|
|
26
|
-
export type AttachmentImageReader = Pick<AttachmentStore, 'readImage'>;
|
|
27
|
-
/** One durable user image resolved for an in-flight request, or proven unreadable. */
|
|
28
|
-
export type ResolvedRequestImage = {
|
|
29
|
-
readonly kind: 'inline';
|
|
30
|
-
readonly mediaType: string;
|
|
31
|
-
readonly data: string;
|
|
32
|
-
} | {
|
|
33
|
-
readonly kind: 'unavailable';
|
|
34
|
-
};
|
|
35
|
-
/** Resolved images keyed by durable attachment id; consumed by one request build. */
|
|
36
|
-
export type ResolvedRequestImages = ReadonlyMap<string, ResolvedRequestImage>;
|
|
37
|
-
/**
|
|
38
|
-
* Base64 image payload one request may carry.
|
|
39
|
-
*
|
|
40
|
-
* 12 MB matches what this plugin's other routes allow and keeps the
|
|
41
|
-
* conversation text and tool schemas in the same body.
|
|
42
|
-
*/
|
|
43
|
-
export declare const MAX_REQUEST_IMAGE_BYTES: number;
|
|
44
|
-
/**
|
|
45
|
-
* Replace the oldest inline images with a text placeholder once one request
|
|
46
|
-
* would carry more than {@link MAX_REQUEST_IMAGE_BYTES} of base64 image data.
|
|
47
|
-
* Durable history is untouched; only the request about to be sent changes.
|
|
48
|
-
*/
|
|
49
|
-
export declare function offloadOldestRequestImages(options: GenerateOptions): GenerateOptions;
|
|
50
|
-
/**
|
|
51
|
-
* Read every durable `{ type: 'image', attachment }` block one request carries.
|
|
52
|
-
* An unreadable image resolves to `unavailable` rather than disappearing, so
|
|
53
|
-
* the model is told the picture is missing instead of answering about a blank.
|
|
54
|
-
*/
|
|
55
|
-
export declare function resolveRequestImages(options: GenerateOptions, attachments: AttachmentImageReader | undefined, signal?: AbortSignal): Promise<ResolvedRequestImages>;
|
|
56
|
-
/** Drop the JSON-Schema keywords provider gateways reject or ignore. */
|
|
57
|
-
export declare function stripMetaSchema(schema: unknown): Record<string, unknown>;
|
|
58
|
-
/**
|
|
59
|
-
* Build one `/api/coding/paas/v4/chat/completions` body.
|
|
60
|
-
*
|
|
61
|
-
* `reasoning_effort` is only included when the caller's level is already one
|
|
62
|
-
* the model declares. A level outside that ladder is dropped rather than
|
|
63
|
-
* snapped here: the adapter converges it against the model's own declaration
|
|
64
|
-
* before calling in, so a value reaching this builder is either valid or was
|
|
65
|
-
* deliberately withheld, and guessing here would hide a bug in that step.
|
|
66
|
-
*/
|
|
67
|
-
export declare function buildChatRequest(options: GenerateOptions, images?: ResolvedRequestImages, declaredEfforts?: readonly string[]): Record<string, unknown>;
|
|
68
|
-
interface PendingToolCall {
|
|
69
|
-
blockIndex: number;
|
|
70
|
-
id: string;
|
|
71
|
-
name: string;
|
|
72
|
-
arguments: string;
|
|
73
|
-
started: boolean;
|
|
74
|
-
}
|
|
75
|
-
export interface ZhipuStreamState {
|
|
76
|
-
blocks: OutboundContentBlock[];
|
|
77
|
-
current: {
|
|
78
|
-
index: number;
|
|
79
|
-
type: 'text' | 'reasoning';
|
|
80
|
-
text: string;
|
|
81
|
-
} | null;
|
|
82
|
-
/** wire tool index -> accumulating call. */
|
|
83
|
-
toolCalls: Map<number, PendingToolCall>;
|
|
84
|
-
hasContent: boolean;
|
|
85
|
-
hasToolCall: boolean;
|
|
86
|
-
finishReason: string | null;
|
|
87
|
-
/** The `[DONE]` sentinel arrived. */
|
|
88
|
-
done: boolean;
|
|
89
|
-
/** Terminal chunks were already emitted. */
|
|
90
|
-
finished: boolean;
|
|
91
|
-
inputTokens: number;
|
|
92
|
-
outputTokens: number;
|
|
93
|
-
cacheReadTokens: number;
|
|
94
|
-
reasoningTokens: number;
|
|
95
|
-
sawUsage: boolean;
|
|
96
|
-
}
|
|
97
|
-
export declare function createStreamState(): ZhipuStreamState;
|
|
98
|
-
/** Feed one SSE line from the Coding Plan chat endpoint. */
|
|
99
|
-
export declare function processStreamLine(line: string, state: ZhipuStreamState): StreamChunk[];
|
|
100
|
-
/** Flush every open block, then emit usage and the terminal finish. */
|
|
101
|
-
export declare function closeStream(state: ZhipuStreamState): StreamChunk[];
|
|
102
|
-
/**
|
|
103
|
-
* A stream that ends without a terminal event is truncated, not complete.
|
|
104
|
-
*
|
|
105
|
-
* The endpoint always terminates with either `finish_reason` or `[DONE]`, so
|
|
106
|
-
* their absence means the connection dropped mid-answer and the partial text
|
|
107
|
-
* must not be presented as a finished reply.
|
|
108
|
-
*/
|
|
109
|
-
export declare function assertStreamComplete(state: ZhipuStreamState): void;
|
|
110
|
-
export {};
|
|
111
|
-
//# sourceMappingURL=mapper.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"mapper.d.ts","sourceRoot":"","sources":["../../../../src/host/zhipu/mapper.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,EAGL,KAAK,oBAAoB,EAEzB,KAAK,eAAe,EAEpB,KAAK,WAAW,EAEjB,MAAM,yBAAyB,CAAA;AAChC,OAAO,KAAK,EAAE,eAAe,EAAsB,MAAM,6BAA6B,CAAA;AA4BtF,8EAA8E;AAC9E,MAAM,MAAM,qBAAqB,GAAG,IAAI,CAAC,eAAe,EAAE,WAAW,CAAC,CAAA;AAEtE,sFAAsF;AACtF,MAAM,MAAM,oBAAoB,GAC5B;IAAE,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;IAAC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAC9E;IAAE,QAAQ,CAAC,IAAI,EAAE,aAAa,CAAA;CAAE,CAAA;AAEpC,qFAAqF;AACrF,MAAM,MAAM,qBAAqB,GAAG,WAAW,CAAC,MAAM,EAAE,oBAAoB,CAAC,CAAA;AAI7E;;;;;GAKG;AACH,eAAO,MAAM,uBAAuB,QAAmB,CAAA;AAuDvD;;;;GAIG;AACH,wBAAgB,0BAA0B,CAAC,OAAO,EAAE,eAAe,GAAG,eAAe,CA4BpF;AAED;;;;GAIG;AACH,wBAAsB,oBAAoB,CACxC,OAAO,EAAE,eAAe,EACxB,WAAW,EAAE,qBAAqB,GAAG,SAAS,EAC9C,MAAM,CAAC,EAAE,WAAW,GACnB,OAAO,CAAC,qBAAqB,CAAC,CAwBhC;AAyHD,wEAAwE;AACxE,wBAAgB,eAAe,CAAC,MAAM,EAAE,OAAO,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,C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W,EAAE,CAOlE;AAED;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,gBAAgB,GAAG,IAAI,CAIlE"}
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Model capabilities for the GLM Coding Plan, transcribed per model.
|
|
3
|
-
*
|
|
4
|
-
* The runtime authority is the plan's own `/api/coding/paas/v4/models` listing,
|
|
5
|
-
* which reports each model's real context window; this table stands in before
|
|
6
|
-
* the first successful fetch and for a machine that cannot reach it yet.
|
|
7
|
-
*
|
|
8
|
-
* Nothing here is inferred from a model's name. Image support and the accepted
|
|
9
|
-
* reasoning ladder are per-model facts that the family name does not decide:
|
|
10
|
-
* `glm-5.3-flash` takes images while `glm-5.3` does not, and `glm-5.2` accepts
|
|
11
|
-
* two effort levels where `glm-5.3` accepts three.
|
|
12
|
-
*
|
|
13
|
-
* Sources, checked 2026-09 against the provider's published specification:
|
|
14
|
-
* - the Coding Plan model registry (`zai-coding-plan` on models.dev), which
|
|
15
|
-
* lists exactly the models the plan's own base URL serves;
|
|
16
|
-
* - the model pages and core-parameter table on docs.z.ai, which give the
|
|
17
|
-
* 1M-token window and 128K output cap of the GLM-5.x family;
|
|
18
|
-
* - the deep-thinking guide, which states that GLM-5.3 / GLM-5.3-FLASH / GLM-4.7
|
|
19
|
-
* no longer accept `thinking.type: "disabled"`.
|
|
20
|
-
*/
|
|
21
|
-
import type { ZhipuRegion } from '../../shared/zhipu-contracts.ts';
|
|
22
|
-
/** One model's shipped capability entry. */
|
|
23
|
-
export interface ZhipuModelEntry {
|
|
24
|
-
id: string;
|
|
25
|
-
name: string;
|
|
26
|
-
/** Context window DSH assumes before an override is saved. */
|
|
27
|
-
contextWindow: number;
|
|
28
|
-
/** Maximum output tokens this route requests when a caller omits one. */
|
|
29
|
-
maxTokens: number;
|
|
30
|
-
/**
|
|
31
|
-
* Reasoning levels this model accepts, in escalating order.
|
|
32
|
-
*
|
|
33
|
-
* Empty means the model takes no `reasoning_effort` at all: it reasons (or
|
|
34
|
-
* does not) by its own default and the field is never sent, because upstream
|
|
35
|
-
* rejects an unsupported level outright.
|
|
36
|
-
*/
|
|
37
|
-
reasoningEfforts: readonly string[];
|
|
38
|
-
/** Whether the model accepts image input on this route. */
|
|
39
|
-
supportsImage: boolean;
|
|
40
|
-
/**
|
|
41
|
-
* Whether the model can be told to skip thinking.
|
|
42
|
-
*
|
|
43
|
-
* GLM-5.3 / GLM-5.3-FLASH / GLM-4.7 cannot: the provider documents that
|
|
44
|
-
* sending `thinking.type: "disabled"` to them is an error, so this route never
|
|
45
|
-
* sends a disabling value for them.
|
|
46
|
-
*/
|
|
47
|
-
canDisableThinking: boolean;
|
|
48
|
-
/** Deployments that serve this model. */
|
|
49
|
-
regions: readonly ZhipuRegion[];
|
|
50
|
-
description?: string;
|
|
51
|
-
}
|
|
52
|
-
export declare const ZHIPU_MODELS: readonly ZhipuModelEntry[];
|
|
53
|
-
/**
|
|
54
|
-
* Which models the shipped table resolves to when the live listing is
|
|
55
|
-
* unreachable. All of them: the table is already the Coding Plan's own model
|
|
56
|
-
* set, and hiding an entry would give the user no way to enable it.
|
|
57
|
-
*/
|
|
58
|
-
export declare const DEFAULT_VISIBLE_MODEL_IDS: readonly string[];
|
|
59
|
-
/** The shipped table in the shape the routes and the picker read. */
|
|
60
|
-
export declare const FALLBACK_MODELS: readonly ZhipuModelEntry[];
|
|
61
|
-
/** Look one model up, or receive an unknown-model stub that claims nothing. */
|
|
62
|
-
export declare function resolveZhipuModel(modelId: string, catalog?: readonly ZhipuModelEntry[]): ZhipuModelEntry;
|
|
63
|
-
/** Models one deployment serves. */
|
|
64
|
-
export declare function modelsForRegion(region: ZhipuRegion, catalog?: readonly ZhipuModelEntry[]): ZhipuModelEntry[];
|
|
65
|
-
/** Context window this route assumes for one model, before any override. */
|
|
66
|
-
export declare function defaultContextWindowFor(modelId: string, catalog?: readonly ZhipuModelEntry[]): number;
|
|
67
|
-
/** Output cap one request asks for when the caller omits one. */
|
|
68
|
-
export declare function maxOutputTokensFor(modelId: string, catalog?: readonly ZhipuModelEntry[]): number;
|
|
69
|
-
/** Reasoning levels one model accepts; empty when it takes no effort field. */
|
|
70
|
-
export declare function zhipuReasoningEfforts(modelId: string, catalog?: readonly ZhipuModelEntry[]): string[];
|
|
71
|
-
/** Whether one model accepts image input on this route. */
|
|
72
|
-
export declare function zhipuModelSupportsImage(modelId: string, catalog?: readonly ZhipuModelEntry[]): boolean;
|
|
73
|
-
//# sourceMappingURL=model-catalog.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"model-catalog.d.ts","sourceRoot":"","sources":["../../../../src/host/zhipu/model-catalog.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAA;AAGlE,4CAA4C;AAC5C,MAAM,WAAW,eAAe;IAC9B,EAAE,EAAE,MAAM,CAAA;IACV,IAAI,EAAE,MAAM,CAAA;IACZ,8DAA8D;IAC9D,aAAa,EAAE,MAAM,CAAA;IACrB,yEAAyE;IACzE,SAAS,EAAE,MAAM,CAAA;IACjB;;;;;;OAMG;IACH,gBAAgB,EAAE,SAAS,MAAM,EAAE,CAAA;IACnC,2DAA2D;IAC3D,aAAa,EAAE,OAAO,CAAA;IACtB;;;;;;OAMG;IACH,kBAAkB,EAAE,OAAO,CAAA;IAC3B,yCAAyC;IACzC,OAAO,EAAE,SAAS,WAAW,EAAE,CAAA;IAC/B,WAAW,CAAC,EAAE,MAAM,CAAA;CACrB;AA+BD,eAAO,MAAM,YAAY,EAAE,SAAS,eAAe,EA6FlD,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,yBAAyB,EAAE,SAAS,MAAM,EAA0C,CAAA;AAEjG,qEAAqE;AACrE,eAAO,MAAM,eAAe,EAAE,SAAS,eAAe,EAAiB,CAAA;AAEvE,+EAA+E;AAC/E,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,GAAE,SAAS,eAAe,EAAiB,GAAG,eAAe,CAgBtH;AAED,oCAAoC;AACpC,wBAAgB,eAAe,CAC7B,MAAM,EAAE,WAAW,EACnB,OAAO,GAAE,SAAS,eAAe,EAAiB,GACjD,eAAe,EAAE,CAEnB;AAED,4EAA4E;AAC5E,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,SAAS,eAAe,EAAE,GAAG,MAAM,CAErG;AAED,iEAAiE;AACjE,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,SAAS,eAAe,EAAE,GAAG,MAAM,CAEhG;AAED,+EAA+E;AAC/E,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,SAAS,eAAe,EAAE,GAAG,MAAM,EAAE,CAErG;AAED,2DAA2D;AAC3D,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,SAAS,eAAe,EAAE,GAAG,OAAO,CAEtG"}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import type { Context } from '@deepseek-ai/cordis';
|
|
2
|
-
import { DEFAULT_CONTEXT_WINDOW, PROVIDER_ID, PROVIDER_NAME } from './types.ts';
|
|
3
|
-
import { FileCredentialStore, FileModelSettingsStore, zhipuKeyHint, type ZhipuCredentials, type ZhipuPreferenceStore } from './token-store.ts';
|
|
4
|
-
import { type ZhipuModelEntry } from './model-catalog.ts';
|
|
5
|
-
import { getCachedQuota, parseCatalogModels } from './client.ts';
|
|
6
|
-
import type { ZhipuModelOption, ZhipuWebStatus } from '../../shared/zhipu-contracts.ts';
|
|
7
|
-
import type { ZhipuAccountPool } from './account-pool.ts';
|
|
8
|
-
/**
|
|
9
|
-
* The selection the card should show.
|
|
10
|
-
*
|
|
11
|
-
* A stored list that still equals the shipped default has never been edited, so
|
|
12
|
-
* it cannot know about models the catalog has since added; treating it as
|
|
13
|
-
* "everything this account can call" keeps a first run from hiding models
|
|
14
|
-
* behind an unedited default. Any explicit edit is honoured exactly.
|
|
15
|
-
*/
|
|
16
|
-
export declare function resolveEnabledModelIds(stored: readonly string[], available: readonly string[], enabled?: boolean): string[];
|
|
17
|
-
/** Build the model options the settings card renders, in catalog order. */
|
|
18
|
-
export declare function buildModelOptions(catalog: readonly ZhipuModelEntry[], available: readonly string[], enabledModelIds: readonly string[], overrides: Record<string, number>): ZhipuModelOption[];
|
|
19
|
-
export interface ZhipuStatusOptions {
|
|
20
|
-
fetchFn?: typeof fetch;
|
|
21
|
-
/** Whether this plugin currently owns the provider route; re-read on every status. */
|
|
22
|
-
serving?: boolean | (() => boolean);
|
|
23
|
-
/** Diagnostic when another plugin owns the provider route; re-read on every status. */
|
|
24
|
-
conflict?: string | null | (() => string | null);
|
|
25
|
-
/** Multi-account pool this line schedules through; absent keeps the single-account card. */
|
|
26
|
-
accountPool?: ZhipuAccountPool;
|
|
27
|
-
}
|
|
28
|
-
/** Everything the settings card renders: account, quota, and the model catalog. */
|
|
29
|
-
export declare function getZhipuWebStatus(store: FileCredentialStore, modelSettings: FileModelSettingsStore, preferences?: ZhipuPreferenceStore, options?: ZhipuStatusOptions, quotaError?: string | null): Promise<ZhipuWebStatus>;
|
|
30
|
-
/** Register the GLM Coding Plan settings routes under `/zhipu/api`. */
|
|
31
|
-
export declare function registerZhipuRoutes(ctx: Context, store: FileCredentialStore, modelSettings: FileModelSettingsStore, preferences?: ZhipuPreferenceStore, options?: ZhipuStatusOptions): () => void;
|
|
32
|
-
export { PROVIDER_ID, PROVIDER_NAME, DEFAULT_CONTEXT_WINDOW, getCachedQuota, zhipuKeyHint, parseCatalogModels, type ZhipuCredentials, type ZhipuModelEntry, type ZhipuModelOption, type ZhipuWebStatus, };
|
|
33
|
-
//# sourceMappingURL=routes.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"routes.d.ts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AE,gBAAgB,CAAA;CAC/B;AAMD,mFAAmF;AACnF,wBAAsB,iBAAiB,CACrC,KAAK,EAAE,mBAAmB,EAC1B,aAAa,EAAE,sBAAsB,EACrC,WAAW,CAAC,EAAE,oBAAoB,EAClC,OAAO,GAAE,kBAAuB,EAChC,UAAU,GAAE,MAAM,GAAG,IAAW,GAC/B,OAAO,CAAC,cAAc,CAAC,CAmDzB;AAED,uEAAuE;AACvE,wBAAgB,mBAAmB,CACjC,GAAG,EAAE,OAAO,EACZ,KAAK,EAAE,mBAAmB,EAC1B,aAAa,EAAE,sBAAsB,EACrC,WAAW,CAAC,EAAE,oBAAoB,EAClC,OAAO,GAAE,kBAAuB,GAC/B,MAAM,IAAI,CAuSZ;AAED,OAAO,EACL,WAAW,EACX,aAAa,EACb,sBAAsB,EACtB,cAAc,EACd,YAAY,EACZ,kBAAkB,EAClB,KAAK,gBAAgB,EACrB,KAAK,eAAe,EACpB,KAAK,gBAAgB,EACrB,KAAK,cAAc,GACpB,CAAA"}
|
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
import type { ZhipuReasoningEffort, ZhipuRegion } from '../../shared/zhipu-contracts.ts';
|
|
2
|
-
import type { CredentialStore } from '../token-store.ts';
|
|
3
|
-
import { type ContextWindowOverridePatch } from '../common/context-window-overrides.ts';
|
|
4
|
-
export declare const ZHIPU_PREFERENCES_NAMESPACE = "dsh-zhipu";
|
|
5
|
-
export type { ZhipuReasoningEffort, ZhipuRegion };
|
|
6
|
-
/**
|
|
7
|
-
* One stored GLM Coding Plan credential.
|
|
8
|
-
*
|
|
9
|
-
* A Coding Plan credential is a long-lived console API key with nothing to
|
|
10
|
-
* refresh and nothing to expire, so there is no token pair here. The key is
|
|
11
|
-
* bound to one deployment: the same key is rejected by the other host, so the
|
|
12
|
-
* region travels with the credential rather than with the process.
|
|
13
|
-
*/
|
|
14
|
-
export interface ZhipuCredentials {
|
|
15
|
-
/** Console API key. Host-only; never sent to a browser. */
|
|
16
|
-
apiKey: string;
|
|
17
|
-
/** Deployment the key was issued by. */
|
|
18
|
-
region: ZhipuRegion;
|
|
19
|
-
/** Chat base URL this credential's region resolves to. */
|
|
20
|
-
apiBase: string;
|
|
21
|
-
/** Display name the provider reports for the key, when it reports one. */
|
|
22
|
-
keyName?: string;
|
|
23
|
-
/** Plan name/level the subscription service reports, when it reports one. */
|
|
24
|
-
planLabel?: string;
|
|
25
|
-
planLevel?: string;
|
|
26
|
-
/** Unix milliseconds the key was saved. */
|
|
27
|
-
authenticatedAt?: number;
|
|
28
|
-
}
|
|
29
|
-
export interface ZhipuCatalogModel {
|
|
30
|
-
id: string;
|
|
31
|
-
name?: string;
|
|
32
|
-
contextWindow?: number;
|
|
33
|
-
maxTokens?: number;
|
|
34
|
-
reasoningEfforts?: string[];
|
|
35
|
-
supportsImage?: boolean;
|
|
36
|
-
canDisableThinking?: boolean;
|
|
37
|
-
regions?: ZhipuRegion[];
|
|
38
|
-
description?: string;
|
|
39
|
-
}
|
|
40
|
-
export interface ZhipuModelSettings {
|
|
41
|
-
enabled?: boolean;
|
|
42
|
-
enabledModelIds: string[];
|
|
43
|
-
catalogModels: ZhipuCatalogModel[];
|
|
44
|
-
contextWindowOverrides: Record<string, number>;
|
|
45
|
-
defaultReasoningEffort: ZhipuReasoningEffort | null;
|
|
46
|
-
/** Account pinned in the card; null means the pool's own strategy decides. */
|
|
47
|
-
selectedAccountId: string | null;
|
|
48
|
-
}
|
|
49
|
-
export interface ZhipuPreferenceStore {
|
|
50
|
-
status(): ZhipuModelSettings;
|
|
51
|
-
update(patch: {
|
|
52
|
-
enabled?: boolean;
|
|
53
|
-
enabledModelIds?: string[];
|
|
54
|
-
/** `null` deletes one override and falls back to the catalog default. */
|
|
55
|
-
contextWindowOverrides?: ContextWindowOverridePatch;
|
|
56
|
-
defaultReasoningEffort?: ZhipuReasoningEffort | null;
|
|
57
|
-
selectedAccountId?: string | null;
|
|
58
|
-
}): Promise<ZhipuModelSettings>;
|
|
59
|
-
}
|
|
60
|
-
/**
|
|
61
|
-
* Bind the model selection to the DSH settings document when the harness still
|
|
62
|
-
* offers one, and to the JSON file beside it otherwise: a harness without the
|
|
63
|
-
* register seam (0.1.7, and a headless test) reads that file back on boot.
|
|
64
|
-
*/
|
|
65
|
-
export declare function registerZhipuPreferenceStore(settings?: unknown, fallbackStore?: FileModelSettingsStore): ZhipuPreferenceStore;
|
|
66
|
-
export declare function credentialPath(): string;
|
|
67
|
-
export declare function modelSettingsPath(): string;
|
|
68
|
-
/**
|
|
69
|
-
* Stable, non-secret identity of one key.
|
|
70
|
-
*
|
|
71
|
-
* The key itself is never written into a file name or an alias; a digest of it
|
|
72
|
-
* plus the region is what distinguishes two keys of the same account, and the
|
|
73
|
-
* region is part of the identity because the same key text cannot be valid on
|
|
74
|
-
* both deployments at once.
|
|
75
|
-
*/
|
|
76
|
-
export declare function zhipuAccountKey(credentials: Pick<ZhipuCredentials, 'apiKey' | 'region'>): string;
|
|
77
|
-
/** Last four characters of a key, the most a card may show. */
|
|
78
|
-
export declare function zhipuKeyHint(apiKey: string): string;
|
|
79
|
-
export declare function parseZhipuCredentials(value: unknown): ZhipuCredentials;
|
|
80
|
-
/** Encrypted credential store; the plaintext JSON is only a migration source. */
|
|
81
|
-
export declare class FileCredentialStore {
|
|
82
|
-
private readonly filePath;
|
|
83
|
-
private readonly backend;
|
|
84
|
-
constructor(filePath?: string, backend?: CredentialStore<ZhipuCredentials>);
|
|
85
|
-
path(): string;
|
|
86
|
-
private serialize;
|
|
87
|
-
private removeLegacy;
|
|
88
|
-
private saveVerified;
|
|
89
|
-
read(): Promise<ZhipuCredentials | null>;
|
|
90
|
-
write(credentials: ZhipuCredentials): Promise<void>;
|
|
91
|
-
delete(): Promise<void>;
|
|
92
|
-
}
|
|
93
|
-
/** Plain-JSON model settings used when the settings service is unavailable. */
|
|
94
|
-
export declare class FileModelSettingsStore {
|
|
95
|
-
private readonly filePath;
|
|
96
|
-
constructor(filePath?: string);
|
|
97
|
-
path(): string;
|
|
98
|
-
read(): Promise<ZhipuModelSettings>;
|
|
99
|
-
write(settings: ZhipuModelSettings): Promise<void>;
|
|
100
|
-
updateSettings(patch: {
|
|
101
|
-
enabled?: boolean;
|
|
102
|
-
enabledModelIds?: string[];
|
|
103
|
-
/** `null` deletes one override and falls back to the catalog default. */
|
|
104
|
-
contextWindowOverrides?: ContextWindowOverridePatch;
|
|
105
|
-
defaultReasoningEffort?: ZhipuReasoningEffort | null;
|
|
106
|
-
selectedAccountId?: string | null;
|
|
107
|
-
}): Promise<ZhipuModelSettings>;
|
|
108
|
-
setCatalogModels(catalogModels: ZhipuCatalogModel[], options?: {
|
|
109
|
-
enabledModelIds?: string[];
|
|
110
|
-
}): Promise<ZhipuModelSettings>;
|
|
111
|
-
}
|
|
112
|
-
//# sourceMappingURL=token-store.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"token-store.d.ts","sourceRoot":"","sources":["../../../../src/host/zhipu/token-store.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,oBAAoB,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAA;AAIxF,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AAExD,OAAO,EAA+B,KAAK,0BAA0B,EAAE,MAAM,uCAAuC,CAAA;AAMpH,eAAO,MAAM,2BAA2B,cAAc,CAAA;AAEtD,YAAY,EAAE,oBAAoB,EAAE,WAAW,EAAE,CAAA;AAOjD;;;;;;;GAOG;AACH,MAAM,WAAW,gBAAgB;IAC/B,2DAA2D;IAC3D,MAAM,EAAE,MAAM,CAAA;IACd,wCAAwC;IACxC,MAAM,EAAE,WAAW,CAAA;IACnB,0DAA0D;IAC1D,OAAO,EAAE,MAAM,CAAA;IACf,0EAA0E;IAC1E,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,6EAA6E;IAC7E,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,2CAA2C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ACpD,iBAAiB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;KAClC,GAAG,OAAO,CAAC,kBAAkB,CAAC;IAkBzB,gBAAgB,CACpB,aAAa,EAAE,iBAAiB,EAAE,EAClC,OAAO,CAAC,EAAE;QAAE,eAAe,CAAC,EAAE,MAAM,EAAE,CAAA;KAAE,GACvC,OAAO,CAAC,kBAAkB,CAAC;CAU/B"}
|
|
@@ -1,125 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Static facts about the Zhipu / Z.ai GLM Coding Plan.
|
|
3
|
-
*
|
|
4
|
-
* The GLM Coding Plan is a subscription (智谱 GLM Coding Plan / Z.ai GLM Coding
|
|
5
|
-
* Plan) whose coding models are served by a **separate** OpenAI-compatible
|
|
6
|
-
* surface from the pay-as-you-go open platform. The plan's chat base URL is
|
|
7
|
-
* `/api/coding/paas/v4`, and a general-API key or the general base URL
|
|
8
|
-
* (`/api/paas/v4`) fails here — the two are distinct products that bill
|
|
9
|
-
* different balances.
|
|
10
|
-
*
|
|
11
|
-
* Two deployments exist and are independent: the international one (`api.z.ai`)
|
|
12
|
-
* and the China one (`open.bigmodel.cn`). A key minted in one console is
|
|
13
|
-
* rejected by the other, so the region belongs to the credential.
|
|
14
|
-
*
|
|
15
|
-
* Everything asserted here was checked against Z.ai's published documentation
|
|
16
|
-
* and against the live hosts (see the notes on each constant).
|
|
17
|
-
*
|
|
18
|
-
* @see https://docs.z.ai/devpack/overview
|
|
19
|
-
* @see https://docs.z.ai/guides/llm/glm-5.3
|
|
20
|
-
* @see https://docs.z.ai/api-reference/llm/chat-completion
|
|
21
|
-
*/
|
|
22
|
-
import type { ZhipuRegion } from '../../shared/zhipu-contracts.ts';
|
|
23
|
-
export declare const PROVIDER_ID = "zhipu-coding-plan";
|
|
24
|
-
export declare const PROVIDER_NAME = "GLM\uFF08\u667A\u8C31 Coding Plan\uFF09";
|
|
25
|
-
/** International deployment: Z.ai. */
|
|
26
|
-
export declare const INTL_BASE_URL = "https://api.z.ai";
|
|
27
|
-
/** China deployment: 智谱开放平台 (BigModel). */
|
|
28
|
-
export declare const CN_BASE_URL = "https://open.bigmodel.cn";
|
|
29
|
-
/**
|
|
30
|
-
* Hosts that identify the deployment a key belongs to.
|
|
31
|
-
*
|
|
32
|
-
* A pasted key states no region, so it is detected from the console the user
|
|
33
|
-
* names, and an unknown value falls back to the international deployment.
|
|
34
|
-
*/
|
|
35
|
-
export declare const REGION_BASE_URLS: Record<ZhipuRegion, string>;
|
|
36
|
-
/** Chat surface of the Coding Plan, appended to a region base URL. */
|
|
37
|
-
export declare const CHAT_PATH = "/api/coding/paas/v4/chat/completions";
|
|
38
|
-
/** Model listing on the same Coding Plan surface. */
|
|
39
|
-
export declare const MODELS_PATH = "/api/coding/paas/v4/models";
|
|
40
|
-
/**
|
|
41
|
-
* Undocumented monitor endpoints the plan's own usage page reads.
|
|
42
|
-
*
|
|
43
|
-
* They are the only source of the plan's credit windows, and both deployments
|
|
44
|
-
* expose them on the same path. Measured live on both hosts: a request with no
|
|
45
|
-
* credential answers the platform's envelope (`code 1001`, "Authentication
|
|
46
|
-
* parameter not received in Header") and one with a wrong credential answers
|
|
47
|
-
* `code 401`, so the routes exist and are authenticated.
|
|
48
|
-
*
|
|
49
|
-
* The `Authorization` header carries the raw key with **no `Bearer` prefix** on
|
|
50
|
-
* these two — that is the scheme the plan's own page uses, and the documented
|
|
51
|
-
* `Bearer` form belongs to the model API instead.
|
|
52
|
-
*/
|
|
53
|
-
export declare const QUOTA_PATH = "/api/monitor/usage/quota/limit";
|
|
54
|
-
export declare const SUBSCRIPTION_PATH = "/api/biz/subscription/list";
|
|
55
|
-
/** Timeouts and cache lifetimes. */
|
|
56
|
-
export declare const DISCOVERY_TIMEOUT_MS = 20000;
|
|
57
|
-
export declare const CHAT_TIMEOUT_MS = 300000;
|
|
58
|
-
export declare const QUOTA_CACHE_TTL_MS: number;
|
|
59
|
-
export declare const CATALOG_CACHE_TTL_MS: number;
|
|
60
|
-
export declare const STREAM_IDLE_TIMEOUT_MS = 300000;
|
|
61
|
-
export declare const STREAM_IDLE_TIMEOUT_CODE = "LLM_STREAM_IDLE_TIMEOUT";
|
|
62
|
-
export declare const DEFAULT_MAX_TOKENS = 32768;
|
|
63
|
-
export declare const DEFAULT_CONTEXT_WINDOW = 128000;
|
|
64
|
-
/**
|
|
65
|
-
* Product identity for the `User-Agent`.
|
|
66
|
-
*
|
|
67
|
-
* The base URL and the header vocabulary are the provider's own public
|
|
68
|
-
* contract, so this route identifies itself honestly as this plugin rather than
|
|
69
|
-
* impersonating a client it is not.
|
|
70
|
-
*/
|
|
71
|
-
export declare const PLUGIN_USER_AGENT = "dsh-chatgpt-subscription (+https://github.com/Aa728848/dsh-chatgpt-subscription)";
|
|
72
|
-
/** Reasoning levels the Coding Plan accepts for its GLM-5.x models. */
|
|
73
|
-
export declare const CODING_EFFORTS: readonly ["low", "high", "max"];
|
|
74
|
-
/**
|
|
75
|
-
* Platform-level business codes this route classifies.
|
|
76
|
-
*
|
|
77
|
-
* Documented in the provider's own error table; the HTTP status stays generic
|
|
78
|
-
* while the body names the real condition, so the body is what the adapter
|
|
79
|
-
* reads. Several entries share a status with an unrelated condition, which is
|
|
80
|
-
* exactly why classification cannot stop at the status line.
|
|
81
|
-
*
|
|
82
|
-
* @see https://docs.z.ai/api-reference/api-code
|
|
83
|
-
*/
|
|
84
|
-
export declare const ERROR_CODE: {
|
|
85
|
-
/** 401 — the credential is absent from the header. */
|
|
86
|
-
readonly AUTH_MISSING: 1001;
|
|
87
|
-
/** 401 — token expired or wrong; signing in again is what fixes it. */
|
|
88
|
-
readonly AUTH_INVALID: 1000;
|
|
89
|
-
readonly AUTH_EXPIRED: 1003;
|
|
90
|
-
/** 429 — no balance and no usable resource package. */
|
|
91
|
-
readonly NO_BALANCE: 1113;
|
|
92
|
-
/** 400 — unknown model id. */
|
|
93
|
-
readonly UNKNOWN_MODEL: 1211;
|
|
94
|
-
/** 400 — the model does not serve this call method. */
|
|
95
|
-
readonly WRONG_METHOD: 1212;
|
|
96
|
-
/** 400 — a required parameter was missing. */
|
|
97
|
-
readonly MISSING_PARAM: 1213;
|
|
98
|
-
/** 400 — a parameter value was rejected, e.g. an unsupported reasoning level. */
|
|
99
|
-
readonly INVALID_PARAM: 1214;
|
|
100
|
-
/** 403 — the account's plan does not grant this API. */
|
|
101
|
-
readonly NO_PERMISSION: 1220;
|
|
102
|
-
/** 400 — prompt exceeds the model's window. */
|
|
103
|
-
readonly PROMPT_TOO_LONG: 1261;
|
|
104
|
-
/** 400 — the provider's own content filter refused the input. */
|
|
105
|
-
readonly CONTENT_FILTERED: 1301;
|
|
106
|
-
/** 429 — request-rate limit. */
|
|
107
|
-
readonly RATE_LIMITED: 1302;
|
|
108
|
-
/** 429 — transient service overload. */
|
|
109
|
-
readonly OVERLOADED: 1305;
|
|
110
|
-
/** 429 — a named usage window is spent; the body carries the reset instant. */
|
|
111
|
-
readonly USAGE_LIMIT: 1308;
|
|
112
|
-
/** 429 — the Coding Plan package has lapsed. */
|
|
113
|
-
readonly PLAN_EXPIRED: 1309;
|
|
114
|
-
/** 429 — weekly/monthly allowance spent; the body carries the reset instant. */
|
|
115
|
-
readonly PLAN_LIMIT: 1310;
|
|
116
|
-
/** 429 — the current plan does not include this model. */
|
|
117
|
-
readonly MODEL_NOT_IN_PLAN: 1311;
|
|
118
|
-
};
|
|
119
|
-
/** Whether a free-form region belongs to the China deployment. */
|
|
120
|
-
export declare function regionForBaseUrl(baseUrl: string | undefined): ZhipuRegion;
|
|
121
|
-
/** Chat base URL one region resolves to. */
|
|
122
|
-
export declare function apiBaseForRegion(region: ZhipuRegion): string;
|
|
123
|
-
/** Normalize a free-form region name onto a supported deployment. */
|
|
124
|
-
export declare function normalizeRegion(value: unknown): ZhipuRegion | undefined;
|
|
125
|
-
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/host/zhipu/types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+CAA+C;;IAE/C,iEAAiE;;IAEjE,gCAAgC;;IAEhC,wCAAwC;;IAExC,+EAA+E;;IAE/E,gDAAgD;;IAEhD,gFAAgF;;IAEhF,0DAA0D;;CAElD,CAAA;AAEV,kEAAkE;AAClE,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS,GAAG,WAAW,CAGzE;AAED,4CAA4C;AAC5C,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,WAAW,GAAG,MAAM,CAE5D;AAED,qEAAqE;AACrE,wBAAgB,eAAe,CAAC,KAAK,EAAE,OAAO,GAAG,WAAW,GAAG,SAAS,CAQvE"}
|
|
@@ -1,164 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Wire contracts between the Zhipu (GLM Coding Plan) host routes and the
|
|
3
|
-
* browser settings card. Everything here is public: no credential ever crosses
|
|
4
|
-
* this boundary, only the non-secret facts the card renders.
|
|
5
|
-
*/
|
|
6
|
-
import type { AccountPoolStatusDto, PoolAccountSummaryDto } from './account-pool-contracts.ts';
|
|
7
|
-
/**
|
|
8
|
-
* Which deployment an account belongs to.
|
|
9
|
-
*
|
|
10
|
-
* The two deployments are separate hosts with separate console-issued keys, and
|
|
11
|
-
* a key minted on one is rejected by the other. The region is therefore a
|
|
12
|
-
* property of the credential, not of the request.
|
|
13
|
-
*/
|
|
14
|
-
export type ZhipuRegion = 'cn' | 'intl';
|
|
15
|
-
/**
|
|
16
|
-
* Reasoning levels this route can put on the wire.
|
|
17
|
-
*
|
|
18
|
-
* Deliberately the narrow set the Coding Plan accepts. Upstream documents
|
|
19
|
-
* exactly these three for the GLM-5.x family and answers an error for anything
|
|
20
|
-
* else, so the card offers only them and any other value a caller names is
|
|
21
|
-
* converged onto the nearest rung before the request is built.
|
|
22
|
-
*/
|
|
23
|
-
export type ZhipuReasoningEffort = 'low' | 'high' | 'max';
|
|
24
|
-
/** Every level this route can name, in escalating order (the card's sort key). */
|
|
25
|
-
export declare const ZHIPU_REASONING_EFFORTS: readonly ZhipuReasoningEffort[];
|
|
26
|
-
export declare function convergeZhipuEffort(effort: string, ladder: readonly string[]): ZhipuReasoningEffort | null;
|
|
27
|
-
/** One model offered by the GLM Coding Plan. */
|
|
28
|
-
export interface ZhipuModelOption {
|
|
29
|
-
id: string;
|
|
30
|
-
name: string;
|
|
31
|
-
/** Enabled models are the ones DSH offers in the conversation model picker. */
|
|
32
|
-
enabled: boolean;
|
|
33
|
-
/** Context window this route assumes when the caller saves no override. */
|
|
34
|
-
defaultContextWindow: number;
|
|
35
|
-
/** Effective context window: the override when one is saved, else the default. */
|
|
36
|
-
contextWindow: number;
|
|
37
|
-
/** Maximum output tokens this route requests when a caller omits one. */
|
|
38
|
-
defaultMaxTokens: number;
|
|
39
|
-
/** Reasoning levels this model exposes; empty for a model that takes none. */
|
|
40
|
-
reasoningEfforts: string[];
|
|
41
|
-
/** Whether the model accepts image input on this route. */
|
|
42
|
-
supportsImage: boolean;
|
|
43
|
-
/** Deployments that serve this model; the account's own region must be listed. */
|
|
44
|
-
regions: ZhipuRegion[];
|
|
45
|
-
/** One-line description shown beside the model in the settings card. */
|
|
46
|
-
description?: string;
|
|
47
|
-
}
|
|
48
|
-
/** One allowance window the monitor service reports. */
|
|
49
|
-
export interface ZhipuQuotaWindow {
|
|
50
|
-
id: string;
|
|
51
|
-
label: string;
|
|
52
|
-
/** Used fraction in [0, 1] when the service reports a bounded allowance. */
|
|
53
|
-
usedFraction: number | null;
|
|
54
|
-
/** Remaining fraction in [0, 1], when the service reports one. */
|
|
55
|
-
remainingFraction: number | null;
|
|
56
|
-
/** Consumed amount as the service reports it, e.g. `12,500,000`. */
|
|
57
|
-
used: string | null;
|
|
58
|
-
/** Window allowance as the service reports it. */
|
|
59
|
-
limit: string | null;
|
|
60
|
-
/** Unix milliseconds the window resets, when reported. */
|
|
61
|
-
resetsAt: number | null;
|
|
62
|
-
/** Length of the window in minutes, when the service names one. */
|
|
63
|
-
windowMinutes: number | null;
|
|
64
|
-
description: string | null;
|
|
65
|
-
}
|
|
66
|
-
/** One credit / token / tool-call meter the monitor service reports. */
|
|
67
|
-
export interface ZhipuMeter {
|
|
68
|
-
id: string;
|
|
69
|
-
label: string;
|
|
70
|
-
usedFraction: number | null;
|
|
71
|
-
remainingFraction: number | null;
|
|
72
|
-
used: string | null;
|
|
73
|
-
limit: string | null;
|
|
74
|
-
resetsAt: number | null;
|
|
75
|
-
description: string | null;
|
|
76
|
-
}
|
|
77
|
-
/** Account identity as the settings card renders it. Never carries the key. */
|
|
78
|
-
export interface ZhipuAccount {
|
|
79
|
-
/** Stable, non-secret selection key derived from region + key digest. */
|
|
80
|
-
id: string;
|
|
81
|
-
/** Last four characters of the key, so a user can tell two keys apart. */
|
|
82
|
-
keyHint: string;
|
|
83
|
-
email: string | null;
|
|
84
|
-
planLabel: string | null;
|
|
85
|
-
region: ZhipuRegion;
|
|
86
|
-
/** Chat base URL this account's region resolves to. */
|
|
87
|
-
apiBase: string;
|
|
88
|
-
/** Unix milliseconds the key was saved. */
|
|
89
|
-
authenticatedAt: number | null;
|
|
90
|
-
}
|
|
91
|
-
/** One Zhipu account as the shared pool card renders it. Never carries a key. */
|
|
92
|
-
export interface ZhipuAccountSummaryDto extends PoolAccountSummaryDto {
|
|
93
|
-
region: ZhipuRegion;
|
|
94
|
-
/** Last four characters of the key. */
|
|
95
|
-
keyHint?: string;
|
|
96
|
-
/** Chat base URL the account's region resolves to. */
|
|
97
|
-
apiBase?: string;
|
|
98
|
-
}
|
|
99
|
-
/** One point-in-time quota snapshot for the selected account. */
|
|
100
|
-
export interface ZhipuAccountQuota {
|
|
101
|
-
account: ZhipuAccount;
|
|
102
|
-
/** Plan name the subscription service reports, e.g. `GLM Coding Pro`. */
|
|
103
|
-
planName: string | null;
|
|
104
|
-
/** Machine plan level, e.g. `pro` / `lite` / `max`. */
|
|
105
|
-
planLevel: string | null;
|
|
106
|
-
/** Unix milliseconds the plan renews, when reported. */
|
|
107
|
-
renewsAt: number | null;
|
|
108
|
-
meters: ZhipuMeter[];
|
|
109
|
-
windows: ZhipuQuotaWindow[];
|
|
110
|
-
/** When this snapshot was read. */
|
|
111
|
-
fetchedAt: number;
|
|
112
|
-
/** Monitor routes that answered, for diagnostics in the settings card. */
|
|
113
|
-
sources: string[];
|
|
114
|
-
}
|
|
115
|
-
/** Everything the settings card and the composer badge render. */
|
|
116
|
-
export interface ZhipuWebStatus extends Partial<AccountPoolStatusDto> {
|
|
117
|
-
enabled?: boolean;
|
|
118
|
-
authenticated: boolean;
|
|
119
|
-
hasCredentials: boolean;
|
|
120
|
-
/** Storage description for the plugin's encrypted credential store. */
|
|
121
|
-
storagePath: string;
|
|
122
|
-
account: ZhipuAccount | null;
|
|
123
|
-
quota: ZhipuAccountQuota | null;
|
|
124
|
-
lastFetchedAt: number | null;
|
|
125
|
-
/**
|
|
126
|
-
* Whether a quota refresh is running behind this answer.
|
|
127
|
-
*
|
|
128
|
-
* The card renders the snapshot it already had instead of waiting on the
|
|
129
|
-
* upstream request; when this is true the client asks again shortly so the
|
|
130
|
-
* refreshed snapshot reaches the UI.
|
|
131
|
-
*/
|
|
132
|
-
quotaRefreshing?: boolean;
|
|
133
|
-
models: ZhipuModelOption[];
|
|
134
|
-
contextWindowOverrides: Record<string, number>;
|
|
135
|
-
defaultReasoningEffort: ZhipuReasoningEffort | null;
|
|
136
|
-
/** Account selected for model discovery and all requests; null means automatic. */
|
|
137
|
-
selectedAccountId: string | null;
|
|
138
|
-
/** Route the plugin currently serves; false when another plugin owns it. */
|
|
139
|
-
serving: boolean;
|
|
140
|
-
/** Diagnostic when the route is owned by a different adapter family. */
|
|
141
|
-
conflict: string | null;
|
|
142
|
-
/** Diagnostic when the monitor endpoints refused the last read. */
|
|
143
|
-
quotaError: string | null;
|
|
144
|
-
}
|
|
145
|
-
/** Patch accepted by the models/settings route. */
|
|
146
|
-
export interface ZhipuSettingsUpdateDto {
|
|
147
|
-
enabled?: boolean;
|
|
148
|
-
enabledModelIds?: string[];
|
|
149
|
-
/** A number sets an override for that model; `null` restores the catalog default. */
|
|
150
|
-
contextWindowOverrides?: Record<string, number | null>;
|
|
151
|
-
defaultReasoningEffort?: ZhipuReasoningEffort | null;
|
|
152
|
-
selectedAccountId?: string | null;
|
|
153
|
-
}
|
|
154
|
-
/** Result of a connection test against the upstream chat endpoint. */
|
|
155
|
-
export interface ZhipuConnectionDto {
|
|
156
|
-
connected: boolean;
|
|
157
|
-
account: ZhipuAccount | null;
|
|
158
|
-
/** Round-trip time of the probe request. */
|
|
159
|
-
latencyMs: number;
|
|
160
|
-
/** Model the probe asked for. */
|
|
161
|
-
model: string;
|
|
162
|
-
checkedAt: number;
|
|
163
|
-
}
|
|
164
|
-
//# sourceMappingURL=zhipu-contracts.d.ts.map
|