@eddyskywalker/dsh-chatgpt-subscription 0.9.9 → 0.10.1
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 +72 -0
- package/README.md +80 -2
- package/lib/client.js +1596 -207
- package/lib/client.js.map +1 -1
- package/lib/index.js +4834 -1019
- package/lib/types/client/ProviderHubSection.d.ts.map +1 -1
- package/lib/types/client/claude/locales.d.ts +2 -2
- package/lib/types/client/command-code/locales.d.ts +2 -2
- package/lib/types/client/index.d.ts +2 -0
- package/lib/types/client/index.d.ts.map +1 -1
- package/lib/types/client/kimi-code/locales.d.ts +2 -2
- package/lib/types/client/minimax-code/MinimaxCodeComposerQuota.d.ts +27 -0
- package/lib/types/client/minimax-code/MinimaxCodeComposerQuota.d.ts.map +1 -0
- package/lib/types/client/minimax-code/MinimaxCodeSection.d.ts +49 -0
- package/lib/types/client/minimax-code/MinimaxCodeSection.d.ts.map +1 -0
- package/lib/types/client/minimax-code/api.d.ts +5 -0
- package/lib/types/client/minimax-code/api.d.ts.map +1 -0
- package/lib/types/client/minimax-code/locales.d.ts +341 -0
- package/lib/types/client/minimax-code/locales.d.ts.map +1 -0
- package/lib/types/client/minimax-code/styles.d.ts +12 -0
- package/lib/types/client/minimax-code/styles.d.ts.map +1 -0
- package/lib/types/client/styles.d.ts +19 -0
- package/lib/types/client/styles.d.ts.map +1 -1
- package/lib/types/compat.d.ts +1 -0
- package/lib/types/compat.d.ts.map +1 -1
- package/lib/types/host/agent-preset.d.ts.map +1 -1
- package/lib/types/host/claude/mapper.d.ts +11 -2
- package/lib/types/host/claude/mapper.d.ts.map +1 -1
- package/lib/types/host/minimax-code/account-pool.d.ts +219 -0
- package/lib/types/host/minimax-code/account-pool.d.ts.map +1 -0
- package/lib/types/host/minimax-code/adapter.d.ts +168 -0
- package/lib/types/host/minimax-code/adapter.d.ts.map +1 -0
- package/lib/types/host/minimax-code/client.d.ts +184 -0
- package/lib/types/host/minimax-code/client.d.ts.map +1 -0
- package/lib/types/host/minimax-code/mapper.d.ts +143 -0
- package/lib/types/host/minimax-code/mapper.d.ts.map +1 -0
- package/lib/types/host/minimax-code/model-catalog.d.ts +146 -0
- package/lib/types/host/minimax-code/model-catalog.d.ts.map +1 -0
- package/lib/types/host/minimax-code/oauth.d.ts +204 -0
- package/lib/types/host/minimax-code/oauth.d.ts.map +1 -0
- package/lib/types/host/minimax-code/routes.d.ts +79 -0
- package/lib/types/host/minimax-code/routes.d.ts.map +1 -0
- package/lib/types/host/minimax-code/token-store.d.ts +238 -0
- package/lib/types/host/minimax-code/token-store.d.ts.map +1 -0
- package/lib/types/host/minimax-code/types.d.ts +206 -0
- package/lib/types/host/minimax-code/types.d.ts.map +1 -0
- package/lib/types/host/subagent-model-authorization.d.ts +7 -0
- package/lib/types/host/subagent-model-authorization.d.ts.map +1 -1
- package/lib/types/index.d.ts +10 -0
- package/lib/types/index.d.ts.map +1 -1
- package/lib/types/shared/minimax-code-contracts.d.ts +166 -0
- package/lib/types/shared/minimax-code-contracts.d.ts.map +1 -0
- package/package.json +1 -1
- package/presets/dispatch/agent.cordis.yml +13 -1
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export declare const STYLE_ID = "dsh-minimax-code-settings-style";
|
|
2
|
+
/**
|
|
3
|
+
* MiniMax Code-only additions to the shared settings design system.
|
|
4
|
+
*
|
|
5
|
+
* The base control styles (.dsha-page, .dsha-group, .dsha-row, .dsha-models,
|
|
6
|
+
* the device-code box, the meter, the composer badge, ...) come from the
|
|
7
|
+
* stylesheet the sibling routes install, in the same order the client installs
|
|
8
|
+
* them, so this file declares only what stays unique to this card: the mono
|
|
9
|
+
* credential path and the model-name list.
|
|
10
|
+
*/
|
|
11
|
+
export declare function installMinimaxCodeStyles(): void;
|
|
12
|
+
//# sourceMappingURL=styles.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"styles.d.ts","sourceRoot":"","sources":["../../../../src/client/minimax-code/styles.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,QAAQ,oCAAoC,CAAA;AAEzD;;;;;;;;GAQG;AACH,wBAAgB,wBAAwB,IAAI,IAAI,CAW/C"}
|
|
@@ -1,2 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Install the ChatGPT tab's stylesheet as a document-owned, never-removed
|
|
3
|
+
* `<style>` element.
|
|
4
|
+
*
|
|
5
|
+
* The other client stylesheets this plugin installs are additive: their
|
|
6
|
+
* installers no-op when the element already exists and their disposers do
|
|
7
|
+
* nothing, so a restart can never take the styles away. This one used to
|
|
8
|
+
* create *and remove* its element, and the dedupe handoff was racy: on a
|
|
9
|
+
* plugin fiber restart (config change, dependency reload, HMR) the new fiber
|
|
10
|
+
* ran `apply()` before the old fiber's async unload removed the element —
|
|
11
|
+
* dedupe saw the old tag, returned a no-op disposer, and the old unload then
|
|
12
|
+
* deleted the only copy. Every later restart kept returning the no-op, so the
|
|
13
|
+
* stylesheet never came back and the settings page rendered unstyled.
|
|
14
|
+
*
|
|
15
|
+
* Fix: treat the tag as owned by the document rather than by one fiber —
|
|
16
|
+
* create it when missing, refresh `textContent` when a rebuilt bundle ships
|
|
17
|
+
* different CSS (HMR), and return a no-op disposer unconditionally, matching
|
|
18
|
+
* the additive installers.
|
|
19
|
+
*/
|
|
1
20
|
export declare function installStyles(): () => void;
|
|
2
21
|
//# sourceMappingURL=styles.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"styles.d.ts","sourceRoot":"","sources":["../../../src/client/styles.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"styles.d.ts","sourceRoot":"","sources":["../../../src/client/styles.ts"],"names":[],"mappings":"AAqIA;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,aAAa,IAAI,MAAM,IAAI,CAa1C"}
|
package/lib/types/compat.d.ts
CHANGED
|
@@ -16,6 +16,7 @@ export declare const TOKEN_REFRESH_MARGIN_MS = 60000;
|
|
|
16
16
|
export declare const ROUTE_PREFIX: "/api/dsh-chatgpt-subscription";
|
|
17
17
|
export declare const PLUGIN_VERSION: "0.1.0-alpha.0";
|
|
18
18
|
export declare const CODEX_CHATGPT_PROVIDER_ID: "codex-chatgpt";
|
|
19
|
+
export { MINIMAX_CODE_PROVIDER_ID, MINIMAX_CODE_ROUTE_PREFIX } from './shared/minimax-code-contracts.ts';
|
|
19
20
|
export declare const CODEX_API_BASE: "https://chatgpt.com/backend-api/codex";
|
|
20
21
|
export declare const CODEX_RESPONSES_URL: "https://chatgpt.com/backend-api/codex/responses";
|
|
21
22
|
export declare const CODEX_IMAGE_GENERATION_URL: "https://chatgpt.com/backend-api/codex/images/generations";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compat.d.ts","sourceRoot":"","sources":["../../src/compat.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,eAAO,MAAM,oBAAoB,EAAG,yBAAkC,CAAA;AACtE,eAAO,MAAM,uBAAuB,EAAG,8BAAuC,CAAA;AAC9E,eAAO,MAAM,mBAAmB,EAAG,WAAoB,CAAA;AACvD,eAAO,MAAM,mBAAmB,EAAG,IAAa,CAAA;AAChD,eAAO,MAAM,mBAAmB,EAAG,gBAAyB,CAAA;AAC5D,eAAO,MAAM,kBAAkB,uCAAwF,CAAA;AACvH,eAAO,MAAM,WAAW,EAAG,qCAA8C,CAAA;AACzE,eAAO,MAAM,gBAAgB,EAAG,UAAmB,CAAA;AACnD,eAAO,MAAM,sBAAsB,QAAa,CAAA;AAChD,eAAO,MAAM,uBAAuB,QAAS,CAAA;AAC7C,eAAO,MAAM,YAAY,EAAG,+BAAwC,CAAA;AACpE,eAAO,MAAM,cAAc,EAAG,eAAwB,CAAA;AACtD,eAAO,MAAM,yBAAyB,EAAG,eAAwB,CAAA;
|
|
1
|
+
{"version":3,"file":"compat.d.ts","sourceRoot":"","sources":["../../src/compat.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,eAAO,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@@ -506,8 +506,17 @@ export interface ClaudeStreamState {
|
|
|
506
506
|
toolCalls: Map<number, PendingToolCall>;
|
|
507
507
|
/** Anthropic content index -> a buffered thinking block. */
|
|
508
508
|
pending: Map<number, PendingThinking>;
|
|
509
|
-
/**
|
|
510
|
-
|
|
509
|
+
/**
|
|
510
|
+
* Anthropic content index -> the wire block that produced the emitted block.
|
|
511
|
+
*
|
|
512
|
+
* A slot is `null` - never `undefined` - when a block has no verbatim wire
|
|
513
|
+
* form to replay. That is not cosmetic: this array goes into the finish
|
|
514
|
+
* chunk's replayState, DSH validates every stream chunk as lossless JSON, and
|
|
515
|
+
* `undefined` is not a JSON value, so a hole here costs the caller the WHOLE
|
|
516
|
+
* turn ("Assistant stream chunk must be losslessly JSON-serializable") rather
|
|
517
|
+
* than one replay entry. See {@link jsonSafeValue}.
|
|
518
|
+
*/
|
|
519
|
+
replayBlocks: (Record<string, unknown> | null)[];
|
|
511
520
|
/** Tool-name translation the response side maps back through. */
|
|
512
521
|
toolNames: ClaudeToolNames | undefined;
|
|
513
522
|
sawMessageStart: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mapper.d.ts","sourceRoot":"","sources":["../../../../src/host/claude/mapper.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgLG;AAEH,OAAO,EAEL,KAAK,YAAY,EAEjB,KAAK,eAAe,EAEpB,KAAK,WAAW,EAEjB,MAAM,yBAAyB,CAAA;AAChC,OAAO,KAAK,EAAE,eAAe,EAAsB,MAAM,6BAA6B,CAAA;
|
|
1
|
+
{"version":3,"file":"mapper.d.ts","sourceRoot":"","sources":["../../../../src/host/claude/mapper.ts"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,GAAG,iBAAiB,CAqBhF;AA0KD;;;;;;;;GAQG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,iBAAiB,GAAG,WAAW,EAAE,CAyBnE;AAED;;;;;;;GAOG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,iBAAiB,GAAG,IAAI,CAInE;AAqBD;;;;;;;;GAQG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,iBAAiB,GAAG,WAAW,EAAE,CAqKvF"}
|
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MiniMax Code 号池:the account pool for the MiniMax Code (编程订阅) line.
|
|
3
|
+
*
|
|
4
|
+
* This is the second line in this package that pools a credential it does not
|
|
5
|
+
* own (WorkBuddy was the first), and that one fact decides every shape below:
|
|
6
|
+
*
|
|
7
|
+
* 1. MiniMax Code's normal credential is the desktop application's own
|
|
8
|
+
* \`~/.minimax/auth/<buildEnv>/<region>/mcode-public/auth.json\`. The plugin
|
|
9
|
+
* reads it so a user already signed in to the app never signs in twice, which
|
|
10
|
+
* is exactly the WorkBuddy precedent for the CodeBuddy client's \`*.info\`
|
|
11
|
+
* files.
|
|
12
|
+
* 2. ADOPTED MEANS NEVER DESTROYED. That file belongs to an application the
|
|
13
|
+
* user is running. The pool may read it, may adopt it into its own account
|
|
14
|
+
* list, and may write a rotated token back through the store's atomic
|
|
15
|
+
* replacement — but no path in this file may revoke it or delete it. A
|
|
16
|
+
* deleted \`auth.json\` signs the user out of MiniMax Code itself, so such an
|
|
17
|
+
* account is reported as \`removable: false\` and deletion is refused
|
|
18
|
+
* ({@link MinimaxCodeAccountPool.deleteAccount}), mirroring WorkBuddy's
|
|
19
|
+
* desktop accounts.
|
|
20
|
+
* 3. What the pool adds on top of the single-credential line is rotation: more
|
|
21
|
+
* than one sign-in can serve requests, a 429 cools one account down instead
|
|
22
|
+
* of taking the line offline, and the settings card can list, alias, promote
|
|
23
|
+
* and switch between them.
|
|
24
|
+
*
|
|
25
|
+
* The credential format stays the store's: this file never invents a field of
|
|
26
|
+
* its own inside a token record, so a write back into the app's document keeps
|
|
27
|
+
* the exact shape the app expects.
|
|
28
|
+
*/
|
|
29
|
+
import type { IncomingMessage, ServerResponse } from 'node:http';
|
|
30
|
+
import { AccountPoolCore, type PoolAccountShape, type PoolData } from '../common/account-pool.ts';
|
|
31
|
+
import type { CredentialStore } from '../token-store.ts';
|
|
32
|
+
import { MinimaxCodeCredentialStore, type MinimaxCodeCredentialSource, type MinimaxCodeCredentials } from './token-store.ts';
|
|
33
|
+
import type { MinimaxCodeRegion } from '../../shared/minimax-code-contracts.ts';
|
|
34
|
+
import type { AccountRotationStrategy, PoolAccountSummaryDto } from '../../shared/account-pool-contracts.ts';
|
|
35
|
+
/**
|
|
36
|
+
* One pooled MiniMax Code account.
|
|
37
|
+
*
|
|
38
|
+
* The credential travels whole (the pool persists it, and the store knows how to
|
|
39
|
+
* write it back to the file it came from); everything else here is a non-secret
|
|
40
|
+
* fact the settings card renders without a second round trip.
|
|
41
|
+
*/
|
|
42
|
+
export interface MinimaxCodePoolAccount extends PoolAccountShape<MinimaxCodeCredentials> {
|
|
43
|
+
/** Region the credential was issued in; decides every host this account uses. */
|
|
44
|
+
region: MinimaxCodeRegion;
|
|
45
|
+
/**
|
|
46
|
+
* Which store owns the credential.
|
|
47
|
+
*
|
|
48
|
+
* \`minimax-native\` is MiniMax Code's own \`auth.json\`: adopted and renewed,
|
|
49
|
+
* never deletable from here. \`file\` is the plugin's own store, written by a
|
|
50
|
+
* device-code sign-in started in this plugin.
|
|
51
|
+
*/
|
|
52
|
+
source: MinimaxCodeCredentialSource;
|
|
53
|
+
/** Display facts, when the credential's token claims carry them. */
|
|
54
|
+
email?: string;
|
|
55
|
+
planName?: string;
|
|
56
|
+
}
|
|
57
|
+
/** The pool slice the settings card renders, mirroring {@link AccountPoolStatusDto}. */
|
|
58
|
+
export interface MinimaxCodeAccountSummaryDto extends PoolAccountSummaryDto {
|
|
59
|
+
region?: MinimaxCodeRegion;
|
|
60
|
+
source?: MinimaxCodeCredentialSource;
|
|
61
|
+
/** Credential generation; diagnostics for two-sided refresh contention with the app. */
|
|
62
|
+
generation?: number;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Encrypted pool file this line owns.
|
|
66
|
+
*
|
|
67
|
+
* Separate from the credential file on purpose: the pool may hold several
|
|
68
|
+
* accounts, while \`~/.minimax/auth\` holds exactly one session per region and is
|
|
69
|
+
* the desktop app's to write.
|
|
70
|
+
*/
|
|
71
|
+
export declare function minimaxCodePoolPath(): string;
|
|
72
|
+
/**
|
|
73
|
+
* Identity two credentials share when they are the same account.
|
|
74
|
+
*
|
|
75
|
+
* Neither token can be used for this: the access token is replaced on every
|
|
76
|
+
* refresh and the refresh token rotates, so keying on either would make one
|
|
77
|
+
* account look new after every rotation. A hash of the refresh token would have
|
|
78
|
+
* the same defect and no compensating benefit, so it is not done.
|
|
79
|
+
*
|
|
80
|
+
* Two different identities are available, one per provenance:
|
|
81
|
+
*
|
|
82
|
+
* - A native credential names the desktop app's own record slot through
|
|
83
|
+
* \`recordKey\`. That key is a non-secret digest of the app's auth-home path, so
|
|
84
|
+
* it is stable across every rotation, and the app keeps exactly one session per
|
|
85
|
+
* slot: re-signing in there replaces the session, which for routing purposes is
|
|
86
|
+
* the same account, so updating the row in place is the correct outcome.
|
|
87
|
+
* - A plugin-owned credential has no record slot (the app's key is a hash this
|
|
88
|
+
* plugin cannot reproduce) and no account profile, so the sign-in that produced
|
|
89
|
+
* it — its \`loginEpoch\`, which survives every rotation — is the identity. A
|
|
90
|
+
* second device-code sign-in is genuinely a second session with its own refresh
|
|
91
|
+
* token chain, so it is its own account.
|
|
92
|
+
*
|
|
93
|
+
* When neither is present there is nothing stable to key on: the function returns
|
|
94
|
+
* undefined, the core mints \`acc_<random>\`, and the row is added rather than
|
|
95
|
+
* silently merged with an unrelated credential.
|
|
96
|
+
*/
|
|
97
|
+
export declare function minimaxCodePoolIdentity(credentials: MinimaxCodeCredentials): string | undefined;
|
|
98
|
+
/**
|
|
99
|
+
* Validate and normalize one whole pool document.
|
|
100
|
+
*
|
|
101
|
+
* The credential is re-parsed through the store's own validator, so a row can
|
|
102
|
+
* never hold a token shape the store would refuse to write back. \`source\`,
|
|
103
|
+
* \`recordKey\` and \`buildEnv\` have to be restored explicitly: the validator
|
|
104
|
+
* takes them from its fallback rather than from the payload, and a native account
|
|
105
|
+
* that lost them would be re-labelled as plugin-owned (so the card would offer a
|
|
106
|
+
* delete that must never happen, and a rotation would land in the plugin's file
|
|
107
|
+
* instead of the app's).
|
|
108
|
+
*/
|
|
109
|
+
export declare function parseMinimaxCodePoolData(value: unknown): PoolData<MinimaxCodePoolAccount>;
|
|
110
|
+
export interface MinimaxCodeAccountPoolOptions {
|
|
111
|
+
/**
|
|
112
|
+
* Credential store the pool reads the desktop app's sign-in through and mirrors
|
|
113
|
+
* its primary account into.
|
|
114
|
+
*/
|
|
115
|
+
store?: MinimaxCodeCredentialStore;
|
|
116
|
+
/** Test seam; production builds the platform backend from the pool path. */
|
|
117
|
+
backend?: CredentialStore<PoolData<MinimaxCodePoolAccount>>;
|
|
118
|
+
/** Accounts this pool accepts; defaults to the core's limit. */
|
|
119
|
+
maxAccounts?: number;
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* MiniMax Code's account pool.
|
|
123
|
+
*
|
|
124
|
+
* It owns rotation and the write-back, exactly like the sibling lines, with one
|
|
125
|
+
* asymmetry the hooks below enforce: an account whose credential lives in the
|
|
126
|
+
* desktop app's file is adopted, never owned.
|
|
127
|
+
*/
|
|
128
|
+
export declare class MinimaxCodeAccountPool extends AccountPoolCore<MinimaxCodeCredentials, MinimaxCodePoolAccount, MinimaxCodeAccountSummaryDto> {
|
|
129
|
+
private readonly store;
|
|
130
|
+
constructor(options?: MinimaxCodeAccountPoolOptions);
|
|
131
|
+
/**
|
|
132
|
+
* Pick the account for the next request.
|
|
133
|
+
*
|
|
134
|
+
* The returned credential carries its own region and record key, so a caller
|
|
135
|
+
* must use those rather than any process-wide default. This is the method the
|
|
136
|
+
* adapter uses; {@link getEffectiveAccount} beneath it already refreshes a
|
|
137
|
+
* credential that is about to expire and writes the rotation back.
|
|
138
|
+
*/
|
|
139
|
+
getEffectiveCredential(excludeIds?: ReadonlySet<string>, fetchFn?: typeof fetch): Promise<{
|
|
140
|
+
account: MinimaxCodePoolAccount;
|
|
141
|
+
credentials: MinimaxCodeCredentials;
|
|
142
|
+
}>;
|
|
143
|
+
/**
|
|
144
|
+
* The desktop app's own current copy of one native account's credential.
|
|
145
|
+
*
|
|
146
|
+
* The app rotates its token on its own schedule, so the copy the pool adopted
|
|
147
|
+
* can be older than what is on disk. Only the same record slot counts: a
|
|
148
|
+
* different record key or region is a different account, and substituting it
|
|
149
|
+
* would present one account's token as another's. A file whose token is already
|
|
150
|
+
* stale is not newer authority either — the refresh path has just written the
|
|
151
|
+
* pair back, and reading the pre-refresh file would undo it.
|
|
152
|
+
*/
|
|
153
|
+
private liveNativeCredential;
|
|
154
|
+
/**
|
|
155
|
+
* Adopt the sign-in the desktop app currently holds into the pool.
|
|
156
|
+
*
|
|
157
|
+
* The pre-pool projection ({@link legacyAccount}) only surfaces when the pool is
|
|
158
|
+
* empty, so a user who already has a plugin-owned account needs an explicit way
|
|
159
|
+
* to bring the app's session in as well. Nothing is ever removed from the app;
|
|
160
|
+
* the account is added under its own record-slot identity, so adopting twice
|
|
161
|
+
* updates the same row.
|
|
162
|
+
*/
|
|
163
|
+
adoptNativeAccount(alias?: string): Promise<MinimaxCodePoolAccount>;
|
|
164
|
+
/**
|
|
165
|
+
* Delete one account.
|
|
166
|
+
*
|
|
167
|
+
* An account whose credential is the desktop app's own \`auth.json\` is refused:
|
|
168
|
+
* this plugin does not own that file, and removing the account would either
|
|
169
|
+
* strand the app's session or — if the deletion were ever allowed to reach the
|
|
170
|
+
* file — sign the user out of MiniMax Code itself. Signing out there is the
|
|
171
|
+
* supported way to end it, and the card is told so by \`removable: false\`.
|
|
172
|
+
*/
|
|
173
|
+
deleteAccount(accountId: string): Promise<void>;
|
|
174
|
+
/** The credential store this pool mirrors its primary account into. */
|
|
175
|
+
mirrorStore(): MinimaxCodeCredentialStore;
|
|
176
|
+
}
|
|
177
|
+
/** The pool slice of a status response; exactly the fields the card renders. */
|
|
178
|
+
export interface MinimaxCodePoolStatus {
|
|
179
|
+
accounts: MinimaxCodeAccountSummaryDto[];
|
|
180
|
+
activeAccountId?: string;
|
|
181
|
+
rotationStrategy: AccountRotationStrategy;
|
|
182
|
+
/** Whether this process installed a pool at all. */
|
|
183
|
+
poolInstalled: boolean;
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* Read the pool slice of the status DTO.
|
|
187
|
+
*
|
|
188
|
+
* A pool that cannot be read must not fail the whole card: the connection
|
|
189
|
+
* section is still worth rendering, just with an empty account list.
|
|
190
|
+
*/
|
|
191
|
+
export declare function minimaxCodePoolStatus(pool: MinimaxCodeAccountPool | undefined): Promise<MinimaxCodePoolStatus>;
|
|
192
|
+
export interface MinimaxCodeAccountsRouteOptions {
|
|
193
|
+
/**
|
|
194
|
+
* Status the route answers a mutation with, so the card re-renders in one round
|
|
195
|
+
* trip. Defaults to the pool slice alone.
|
|
196
|
+
*/
|
|
197
|
+
readStatus?: () => Promise<unknown>;
|
|
198
|
+
/**
|
|
199
|
+
* Called after a mutation that can move which account serves a request, so the
|
|
200
|
+
* caller can drop per-account caches (quota, catalog) that belong to the account
|
|
201
|
+
* that just changed.
|
|
202
|
+
*/
|
|
203
|
+
onAccountsChanged?: () => void;
|
|
204
|
+
}
|
|
205
|
+
/**
|
|
206
|
+
* The \`/accounts\` route for this line, as a self-contained handler.
|
|
207
|
+
*
|
|
208
|
+
* It is a handler rather than a second \`webServer.register\` call because the
|
|
209
|
+
* parent route already owns the \`/minimax-code/api\` prefix: registering a nested
|
|
210
|
+
* prefix beside it would make which handler sees \`/accounts\` depend on the
|
|
211
|
+
* server's prefix-matching order. The parent dispatches on \`path === 'accounts'\`
|
|
212
|
+
* and calls this.
|
|
213
|
+
*
|
|
214
|
+
* Every POST goes through {@link isSameOriginMutation}, exactly like the sibling
|
|
215
|
+
* lines' account routes, and no response ever carries a credential: what leaves
|
|
216
|
+
* here is the summary DTO the card renders.
|
|
217
|
+
*/
|
|
218
|
+
export declare function createMinimaxCodeAccountsHandler(pool: MinimaxCodeAccountPool | undefined, options?: MinimaxCodeAccountsRouteOptions): (request: IncomingMessage, response: ServerResponse) => Promise<void>;
|
|
219
|
+
//# sourceMappingURL=account-pool.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"account-pool.d.ts","sourceRoot":"","sources":["../../../../src/host/minimax-code/account-pool.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAGH,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,WAAW,CAAA;AAEhE,OAAO,EACL,eAAe,EAGf,KAAK,gBAAgB,EACrB,KAAK,QAAQ,EACd,MAAM,2BAA2B,CAAA;AAElC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AACxD,OAAO,EACL,0BAA0B,EAG1B,KAAK,2BAA2B,EAChC,KAAK,sBAAsB,EAC5B,MAAM,kBAAkB,CAAA;AAOzB,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wCAAwC,CAAA;AAC/E,OAAO,KAAK,EACV,uBAAuB,EACvB,qBAAqB,EACtB,MAAM,wCAAwC,CAAA;AAE/C;;;;;;GAMG;AACH,MAAM,WAAW,sBAAuB,SAAQ,gBAAgB,CAAC,sBAAsB,CAAC;IACtF,iFAAiF;IACjF,MAAM,EAAE,iBAAiB,CAAA;IACzB;;;;;;OAMG;IACH,MAAM,EAAE,2BAA2B,CAAA;IACnC,oEAAoE;IACpE,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,QAAQ,CAAC,EAAE,MAAM,CA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IAQzE;;;;;;;;OAQG;IACY,aAAa,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAS9D,uEAAuE;IACvE,WAAW,IAAI,0BAA0B;CAG1C;AAED,gFAAgF;AAChF,MAAM,WAAW,qBAAqB;IACpC,QAAQ,EAAE,4BAA4B,EAAE,CAAA;IACxC,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB,gBAAgB,EAAE,uBAAuB,CAAA;IACzC,oDAAoD;IACpD,aAAa,EAAE,OAAO,CAAA;CACvB;AAED;;;;;GAKG;AACH,wBAAsB,qBAAqB,CACzC,IAAI,EAAE,sBAAsB,GAAG,SAAS,GACvC,OAAO,CAAC,qBAAqB,CAAC,CAYhC;AA2CD,MAAM,WAAW,+BAA+B;IAC9C;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,OAAO,CAAC,OAAO,CAAC,CAAA;IACnC;;;;OAIG;IACH,iBAAiB,CAAC,EAAE,MAAM,IAAI,CAAA;CAC/B;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,gCAAgC,CAC9C,IAAI,EAAE,sBAAsB,GAAG,SAAS,EACxC,OAAO,GAAE,+BAAoC,GAC5C,CAAC,OAAO,EAAE,eAAe,EAAE,QAAQ,EAAE,cAAc,KAAK,OAAO,CAAC,IAAI,CAAC,CAwDvE"}
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The DSH adapter for the MiniMax Code subscription.
|
|
3
|
+
*
|
|
4
|
+
* It follows the shape every other line in this package uses — claim the provider
|
|
5
|
+
* id, list the hardcoded directory, resolve one model, stream one request — with
|
|
6
|
+
* two differences that belong to this line alone:
|
|
7
|
+
*
|
|
8
|
+
* 1. the credential is the desktop app's own \`auth.json\`, read and renewed through
|
|
9
|
+
* ./oauth.ts under the read-only-first discipline; and
|
|
10
|
+
* 2. there is no account pool. Pooling exists to rotate several signed-in accounts
|
|
11
|
+
* against one subscription; here there is exactly one credential, shared with an
|
|
12
|
+
* application the user is also running, and inventing a second one would mean
|
|
13
|
+
* racing that application for a rotation neither of them needs.
|
|
14
|
+
*/
|
|
15
|
+
import { LlmAdapter, type GenerateOptions, type LlmModelInfo, type LlmProviderInfo, type LlmResolvedModelInfo, type PreparedAdapterCall, type ResolvedRetryPolicy, type StreamChunk } from '@deepseek-ai/dsh-llm';
|
|
16
|
+
import { PROVIDER_ID } from './types.ts';
|
|
17
|
+
import { MinimaxCodeCredentialStore, MinimaxCodeModelSettingsStore, type MinimaxCodePreferenceStore } from './token-store.ts';
|
|
18
|
+
import { clampOutputToContext, maxOutputTokensFor, type AttachmentImageReader } from './mapper.ts';
|
|
19
|
+
import type { MinimaxCodeAccountPool } from './account-pool.ts';
|
|
20
|
+
/**
|
|
21
|
+
* Transient-failure retry policy for the minimax-code route.
|
|
22
|
+
*
|
|
23
|
+
* The subscription fronts the model providers, so a call can fail with a 502/503
|
|
24
|
+
* while the subscription and the credential stay perfectly usable. The retryable
|
|
25
|
+
* set is therefore SERVER (any 5xx), RATE_LIMIT (genuine back-pressure), TRANSPORT
|
|
26
|
+
* (a connection that produced no response) and TIMEOUT (a stalled stream, handled
|
|
27
|
+
* by the idle watchdog).
|
|
28
|
+
*
|
|
29
|
+
* Deliberately outside the set: INVALID_CREDENTIAL (a rejected token fails
|
|
30
|
+
* identically every time), PROVIDER_ERROR (a 400 or a plan refusal), and ABORTED
|
|
31
|
+
* (the caller already cancelled).
|
|
32
|
+
*/
|
|
33
|
+
export declare const MINIMAX_CODE_RETRY_POLICY_CONFIG: {
|
|
34
|
+
mode: 'normal';
|
|
35
|
+
maxRetries: number;
|
|
36
|
+
retryableCodes: string[];
|
|
37
|
+
backoff: {
|
|
38
|
+
initialDelayMs: number;
|
|
39
|
+
maxDelayMs: number;
|
|
40
|
+
jitterRatio: number;
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
/** What one failed response means for the retry policy. */
|
|
44
|
+
export interface MinimaxFailureClassification {
|
|
45
|
+
/** DSH error code; decides whether the route retries. */
|
|
46
|
+
code: string;
|
|
47
|
+
/** Message shown to the user, with the service's own text appended. */
|
|
48
|
+
message: string;
|
|
49
|
+
/** True only when the failure is worth retrying. */
|
|
50
|
+
retryable: boolean;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Classify one non-2xx response for the retry policy.
|
|
54
|
+
*
|
|
55
|
+
* A 401 on this route is the one failure with an unambiguous remedy, and it is the
|
|
56
|
+
* one the credentials rule exists for: the service answers
|
|
57
|
+
* \`{"code":401,"message":"token is required"}\` both when no credential was sent
|
|
58
|
+
* and when the one that was sent is no longer accepted, so the message names the
|
|
59
|
+
* sign-in path instead of asking the user to guess.
|
|
60
|
+
*/
|
|
61
|
+
export declare function classifyMinimaxFailure(status: number, bodyText: string): MinimaxFailureClassification;
|
|
62
|
+
export interface MinimaxCodeAdapterOptions {
|
|
63
|
+
fetchFn?: typeof fetch;
|
|
64
|
+
/** Attachment seam: verified bytes for one durable image. */
|
|
65
|
+
attachments?: AttachmentImageReader;
|
|
66
|
+
/**
|
|
67
|
+
* The account pool, when this process installed one.
|
|
68
|
+
*
|
|
69
|
+
* With a pool the adapter rotates between accounts and lets a 429 cool one
|
|
70
|
+
* account down instead of taking the whole line offline; without one it keeps
|
|
71
|
+
* the single-credential behaviour it had before, reading and renewing the one
|
|
72
|
+
* stored credential. Both postures are supported because the pool is optional
|
|
73
|
+
* in a composition (a headless host, a test), and a missing pool must not make
|
|
74
|
+
* the route unusable.
|
|
75
|
+
*/
|
|
76
|
+
accountPool?: MinimaxCodeAccountPool;
|
|
77
|
+
}
|
|
78
|
+
export declare class MinimaxCodeAdapter extends LlmAdapter {
|
|
79
|
+
private readonly store;
|
|
80
|
+
/**
|
|
81
|
+
* The JSON file fallback for the model selection.
|
|
82
|
+
*
|
|
83
|
+
* Every sibling line has one, and it is not dead weight even where a settings
|
|
84
|
+
* service exists: it is what a later run on a harness that dropped the register
|
|
85
|
+
* seam reads back.
|
|
86
|
+
*/
|
|
87
|
+
private readonly modelSettings;
|
|
88
|
+
/**
|
|
89
|
+
* Registered model settings, when the harness still offers the register seam.
|
|
90
|
+
*
|
|
91
|
+
* Optional because the adapter is also constructed by tooling and tests that
|
|
92
|
+
* have no settings service; {@link settings} then reads the file directly, so
|
|
93
|
+
* both shapes answer the same three questions.
|
|
94
|
+
*/
|
|
95
|
+
private readonly preferences;
|
|
96
|
+
private readonly options;
|
|
97
|
+
constructor(store?: MinimaxCodeCredentialStore, options?: MinimaxCodeAdapterOptions, modelSettings?: MinimaxCodeModelSettingsStore, preferences?: MinimaxCodePreferenceStore);
|
|
98
|
+
/**
|
|
99
|
+
* The current model selection.
|
|
100
|
+
*
|
|
101
|
+
* Synchronous on the register seam (the scope reads from memory) and a single
|
|
102
|
+
* file read otherwise. The loop over models that consults it runs on every
|
|
103
|
+
* model-picker query, so this is deliberately not memoized: a cached snapshot
|
|
104
|
+
* would keep serving a model the user disabled in the card until the process
|
|
105
|
+
* restarted, which is the complaint this whole settings surface exists to fix.
|
|
106
|
+
*/
|
|
107
|
+
private settings;
|
|
108
|
+
/**
|
|
109
|
+
* The credential one request should present, and the pool account behind it.
|
|
110
|
+
*
|
|
111
|
+
* With a pool, the pool picks the account (rotation, cooldown, stickiness) and
|
|
112
|
+
* owns the refresh, so this must not read the single-credential file: that file
|
|
113
|
+
* mirrors one pooled account, and presenting it would silently pin every request
|
|
114
|
+
* to whichever account was mirrored last.
|
|
115
|
+
*
|
|
116
|
+
* Without a pool the previous behaviour is kept exactly, including the
|
|
117
|
+
* read-only-first refresh policy.
|
|
118
|
+
*/
|
|
119
|
+
private acquireCredential;
|
|
120
|
+
/**
|
|
121
|
+
* Renew the credential the service just refused.
|
|
122
|
+
*
|
|
123
|
+
* With a pool, the account that failed is the one renewed, so the rotation lands
|
|
124
|
+
* on that account's own record instead of the single-credential file; without a
|
|
125
|
+
* pool the store's own forced refresh is what ran before the pool existed.
|
|
126
|
+
*/
|
|
127
|
+
private renewCredential;
|
|
128
|
+
providerInfo(provider: string): LlmProviderInfo;
|
|
129
|
+
providerRetryPolicy(): ResolvedRetryPolicy;
|
|
130
|
+
imageRequestPricing(): undefined;
|
|
131
|
+
/**
|
|
132
|
+
* The hardcoded directory, narrowed to what the user enabled it to serve.
|
|
133
|
+
*
|
|
134
|
+
* Nothing is fetched: the listing route is unavailable on this endpoint, so a
|
|
135
|
+
* "live catalog" would be a request that can only ever fail.
|
|
136
|
+
*
|
|
137
|
+
* The line-wide switch is honoured before the selection is even resolved, so
|
|
138
|
+
* turning the card's switch off exposes no model at all — including the ones
|
|
139
|
+
* the user left ticked, which is what "off" has to mean if it is to mean
|
|
140
|
+
* anything.
|
|
141
|
+
*/
|
|
142
|
+
listModels(provider?: string): Promise<readonly LlmModelInfo[]>;
|
|
143
|
+
/**
|
|
144
|
+
* One model's resolved metadata, read through the current selection.
|
|
145
|
+
*
|
|
146
|
+
* The effective context window is the override when one is saved, and the
|
|
147
|
+
* output cap is sized against that same number — a window the card shows and a
|
|
148
|
+
* cap the request path computes from a different one is precisely the drift
|
|
149
|
+
* this single resolver exists to prevent.
|
|
150
|
+
*/
|
|
151
|
+
resolveModel(provider: string, modelId: string, signal?: AbortSignal): Promise<LlmResolvedModelInfo>;
|
|
152
|
+
prepareCall(provider: string, model: string, signal?: AbortSignal): Promise<PreparedAdapterCall>;
|
|
153
|
+
/**
|
|
154
|
+
* One request, with the line's default reasoning effort materialized.
|
|
155
|
+
*
|
|
156
|
+
* A caller that states an effort is passed through untouched: DSH materializes
|
|
157
|
+
* {@link resolveModel}'s default into the options for a picker-driven turn, so
|
|
158
|
+
* a value arriving here is a deliberate choice and must not be replaced. Only
|
|
159
|
+
* an unstated one is filled in, and only when the user actually configured a
|
|
160
|
+
* global level — the shipped default is "say nothing", because the model has
|
|
161
|
+
* its own and restating it in every body is a chance to disagree with it.
|
|
162
|
+
*/
|
|
163
|
+
stream(options: GenerateOptions): AsyncIterable<StreamChunk>;
|
|
164
|
+
private requestStream;
|
|
165
|
+
}
|
|
166
|
+
export { PROVIDER_ID, MinimaxCodeCredentialStore };
|
|
167
|
+
export { maxOutputTokensFor, clampOutputToContext };
|
|
168
|
+
//# sourceMappingURL=adapter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../../../../src/host/minimax-code/adapter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EACL,UAAU,EAIV,KAAK,eAAe,EACpB,KAAK,YAAY,EACjB,KAAK,eAAe,EACpB,KAAK,oBAAoB,EACzB,KAAK,mBAAmB,EACxB,KAAK,mBAAmB,EACxB,KAAK,WAAW,EACjB,MAAM,sBAAsB,CAAA;AAE7B,OAAO,EAEL,WAAW,EAMZ,MAAM,YAAY,CAAA;AASnB,OAAO,EACL,0BAA0B,EAC1B,6BAA6B,EAG7B,KAAK,0BAA0B,EAChC,MAAM,kBAAkB,CAAA;AAMzB,OAAO,EAIL,oBAAoB,EAIpB,kBAAkB,EAIlB,KAAK,qBAAqB,EAC3B,MAAM,aAAa,CAAA;AACpB,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAA;AAK/D;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,gCAAgC,EAAE;IAC7C,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;AAOD,2DAA2D;AAC3D,MAAM,WAAW,4BAA4B;IAC3C,yDAAyD;IACzD,IAAI,EAAE,MAAM,CAAA;IACZ,uEAAuE;IACvE,OAAO,EAAE,MAAM,CAAA;IACf,oDAAoD;IACpD,SAAS,EAAE,OAAO,CAAA;CACnB;AAsBD;;;;;;;;GAQG;AACH,w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