@eddyskywalker/dsh-chatgpt-subscription 0.10.0 → 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 +45 -0
- package/README.md +39 -1
- package/lib/client.js +1569 -205
- package/lib/client.js.map +1 -1
- package/lib/index.js +4775 -1030
- package/lib/types/client/ProviderHubSection.d.ts.map +1 -1
- package/lib/types/client/index.d.ts +2 -0
- package/lib/types/client/index.d.ts.map +1 -1
- package/lib/types/client/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.map +1 -1
- package/lib/types/compat.d.ts +1 -0
- package/lib/types/compat.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/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
|
@@ -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,C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AAK,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,sBAAsB,CAAC;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,SA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AE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAOtG;;;;;;;;;OASG;IACI,MAAM,CAAC,OAAO,EAAE,eAAe,GAAG,aAAa,CAAC,WAAW,CAAC;YAiBpD,aAAa;CAyJ7B;AAED,OAAO,EAAE,WAAW,EAAE,0BAA0B,EAAE,CAAA;AAClD,OAAO,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,CAAA"}
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HTTP surface of the MiniMax Code subscription.
|
|
3
|
+
*
|
|
4
|
+
* ONE header rule governs this whole file, and it is the one the brief calls out as
|
|
5
|
+
* a hard constraint: credentials are sent as `authorization: Bearer <accessToken>`.
|
|
6
|
+
* The endpoint also speaks the Anthropic wire format, whose client normally
|
|
7
|
+
* authenticates with `x-api-key`, and that difference was measured directly — an
|
|
8
|
+
* `x-api-key` request answers 401 `{"code":401,"message":"token is required"}`
|
|
9
|
+
* while the bearer form answers 200. There is deliberately no fallback that tries
|
|
10
|
+
* `x-api-key` after a 401: the measured verdict is that it cannot succeed, and a
|
|
11
|
+
* retry would only add a request to the subscription's bill.
|
|
12
|
+
*
|
|
13
|
+
* The second rule is an absence: this file has no `/v1/models` call and must never
|
|
14
|
+
* grow one. That route is not configured for subscription traffic and answers 503
|
|
15
|
+
* `{"errorCode":50115,"errorReason":"direct_route_not_configured"}`; the model
|
|
16
|
+
* directory is hardcoded in ./model-catalog.ts instead.
|
|
17
|
+
*/
|
|
18
|
+
import { DEFAULT_DEVICE_INTERVAL_SECONDS, MESSAGES_PATH, agentBaseUrl, MINIMAX_CODE_BUILD_ENV, redactToken } from './types.ts';
|
|
19
|
+
import { MinimaxCodeCredentialStore, type MinimaxCodeCredentials } from './token-store.ts';
|
|
20
|
+
import { MinimaxCodeUnauthorizedError } from './oauth.ts';
|
|
21
|
+
import type { MinimaxCodeAccount, MinimaxCodeQuota, MinimaxCodeRegion } from '../../shared/minimax-code-contracts.ts';
|
|
22
|
+
/**
|
|
23
|
+
* Headers for one Messages request.
|
|
24
|
+
*
|
|
25
|
+
* `authorization: Bearer` is REQUIRED and is the only credential field sent —
|
|
26
|
+
* see this file's header comment for the measured reason an `x-api-key` variant
|
|
27
|
+
* must not exist.
|
|
28
|
+
*
|
|
29
|
+
* The token itself never appears in a log line or an error: callers that need to
|
|
30
|
+
* name a credential do so through `redactToken`.
|
|
31
|
+
*/
|
|
32
|
+
export declare function modelRequestHeaders(accessToken: string): Record<string, string>;
|
|
33
|
+
/** Headers for a non-streaming call (the probe). */
|
|
34
|
+
export declare function probeRequestHeaders(accessToken: string): Record<string, string>;
|
|
35
|
+
/** One parsed Anthropic `usage` object. */
|
|
36
|
+
export interface MinimaxUsage {
|
|
37
|
+
inputTokens: number;
|
|
38
|
+
outputTokens: number;
|
|
39
|
+
cacheReadTokens: number;
|
|
40
|
+
cacheWriteTokens: number;
|
|
41
|
+
}
|
|
42
|
+
/** Read the four token counters the Messages response reports. */
|
|
43
|
+
export declare function parseAnthropicUsage(payload: unknown): MinimaxUsage | null;
|
|
44
|
+
/** Short, single-line excerpt of one error body, safe to show a user. */
|
|
45
|
+
export declare function summarizeFailureBody(raw: string): string;
|
|
46
|
+
export interface MinimaxProbeResult {
|
|
47
|
+
ok: boolean;
|
|
48
|
+
/** Model the probe used, when it reached the service. */
|
|
49
|
+
model?: string;
|
|
50
|
+
/** Failure sentence, already safe to render. */
|
|
51
|
+
error?: string;
|
|
52
|
+
latencyMs: number;
|
|
53
|
+
account?: MinimaxCodeAccount | null;
|
|
54
|
+
usage?: MinimaxUsage;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Model the connection probe uses.
|
|
58
|
+
*
|
|
59
|
+
* M3 is the model the measured request used, so a probe against it exercises the
|
|
60
|
+
* exact shape the reconnaissance attested rather than a preview id that may not be
|
|
61
|
+
* entitled on every account.
|
|
62
|
+
*/
|
|
63
|
+
export declare const PROBE_MODEL = "MiniMax-M3";
|
|
64
|
+
/**
|
|
65
|
+
* Prove the stored credential still authenticates.
|
|
66
|
+
*
|
|
67
|
+
* The probe is the real Messages endpoint, because that is the only surface the
|
|
68
|
+
* subscription exposes to a third-party client: there is no account-profile route
|
|
69
|
+
* and `/v1/models` is unavailable, so a 200 from `/messages` is what "signed in"
|
|
70
|
+
* means here. The request is deliberately tiny — one word, 16 output tokens — so a
|
|
71
|
+
* probe the user triggered by pressing a button costs almost nothing.
|
|
72
|
+
*/
|
|
73
|
+
export declare function testConnection(store: MinimaxCodeCredentialStore, options?: {
|
|
74
|
+
fetchFn?: typeof fetch;
|
|
75
|
+
signal?: AbortSignal;
|
|
76
|
+
}): Promise<MinimaxProbeResult>;
|
|
77
|
+
/**
|
|
78
|
+
* Non-streaming Messages call, used by callers that want the body rather than a stream.
|
|
79
|
+
*
|
|
80
|
+
* It exists so the streaming path is not the only implementation of the request
|
|
81
|
+
* shape: the probe and any future test use the same headers and URL builder, which
|
|
82
|
+
* is what keeps the Bearer rule from drifting in a second place.
|
|
83
|
+
*/
|
|
84
|
+
export declare function createMessage(store: MinimaxCodeCredentialStore, request: {
|
|
85
|
+
model: string;
|
|
86
|
+
maxTokens: number;
|
|
87
|
+
prompt: string;
|
|
88
|
+
}, options?: {
|
|
89
|
+
fetchFn?: typeof fetch;
|
|
90
|
+
signal?: AbortSignal;
|
|
91
|
+
}): Promise<{
|
|
92
|
+
ok: boolean;
|
|
93
|
+
status: number;
|
|
94
|
+
payload?: unknown;
|
|
95
|
+
error?: string;
|
|
96
|
+
latencyMs: number;
|
|
97
|
+
}>;
|
|
98
|
+
/**
|
|
99
|
+
* Headers for the Token Plan usage read.
|
|
100
|
+
*
|
|
101
|
+
* NOT {@link modelRequestHeaders}: that set asks for `text/event-stream` because
|
|
102
|
+
* the Messages route streams, and this route answers one JSON document. The
|
|
103
|
+
* credential is still the same bearer token.
|
|
104
|
+
*/
|
|
105
|
+
export declare function quotaRequestHeaders(accessToken: string, pathWithSearch: string, requestTime?: number): Record<string, string>;
|
|
106
|
+
/**
|
|
107
|
+
* The host that last answered.
|
|
108
|
+
*
|
|
109
|
+
* Only a live call can settle which candidate serves this subscription, so the
|
|
110
|
+
* winner is remembered and probed first from then on.
|
|
111
|
+
*/
|
|
112
|
+
/**
|
|
113
|
+
* Why a usage snapshot is absent, when the reason is worth stating on the card.
|
|
114
|
+
*
|
|
115
|
+
* - `credential-not-accepted` — the endpoint answered, and refused THIS line's
|
|
116
|
+
* credential because it needs a platform API key. Measured: every candidate
|
|
117
|
+
* host answers HTTP 200 with `base_resp.status_code: 1004` for an
|
|
118
|
+
* `mcode-public` (MiniMax Code) token, under every auth shape tried.
|
|
119
|
+
* - `unreachable` — no candidate host produced a usable answer at all.
|
|
120
|
+
*/
|
|
121
|
+
export type MinimaxCodeQuotaUnavailable = 'credential-not-accepted' | 'unreachable';
|
|
122
|
+
/** Forget the cached usage snapshot (a sign-out, a sign-in, a test). */
|
|
123
|
+
export declare function clearCachedQuota(): void;
|
|
124
|
+
/** The last usage snapshot without touching the network. */
|
|
125
|
+
export declare function getCachedQuota(): MinimaxCodeQuota | null;
|
|
126
|
+
/** Why the last read produced no snapshot, or null when it produced one. */
|
|
127
|
+
export declare function getQuotaUnavailable(): MinimaxCodeQuotaUnavailable | null;
|
|
128
|
+
/**
|
|
129
|
+
* Resolve the ambiguous `*_usage_count` fields.
|
|
130
|
+
*
|
|
131
|
+
* TRANSCRIBED from the official CLI (`src/utils/quota.ts`), because the ambiguity
|
|
132
|
+
* is real and reading the field naively inverts the bar: older responses report
|
|
133
|
+
* it as a REMAINING count while newer ones report it as a CONSUMED count. When the
|
|
134
|
+
* server also returns an explicit remaining percentage, that percentage selects
|
|
135
|
+
* whichever reading agrees with it; when the counts agree with neither, this
|
|
136
|
+
* returns undefined and the window falls back to the percentage alone rather than
|
|
137
|
+
* inventing a number.
|
|
138
|
+
*/
|
|
139
|
+
export declare function resolveQuotaCounts(reportedCount: number, total: number, remainingPercent: number | undefined): {
|
|
140
|
+
used: number;
|
|
141
|
+
remaining: number;
|
|
142
|
+
total: number;
|
|
143
|
+
} | undefined;
|
|
144
|
+
/**
|
|
145
|
+
* Map one `/v1/token_plan/remains` document onto the card's quota shape.
|
|
146
|
+
*
|
|
147
|
+
* Returns null when nothing usable is present, which the contract defines as the
|
|
148
|
+
* card's graceful degradation.
|
|
149
|
+
*/
|
|
150
|
+
export declare function parseTokenPlanQuota(payload: unknown, now?: number): MinimaxCodeQuota | null;
|
|
151
|
+
/**
|
|
152
|
+
* Read the Token Plan usage snapshot.
|
|
153
|
+
*
|
|
154
|
+
* The endpoint is undocumented (it was found in the official CLI, not in MiniMax's
|
|
155
|
+
* API docs), and which host serves THIS subscription has never been measured, so
|
|
156
|
+
* the candidates are tried in order and the winner is remembered. Any failure
|
|
157
|
+
* yields null: the contract makes `quota` optional precisely so a usage read can
|
|
158
|
+
* never break the connection half of the card.
|
|
159
|
+
*/
|
|
160
|
+
export declare function fetchTokenPlanQuota(credentials: MinimaxCodeCredentials, options?: {
|
|
161
|
+
fetchFn?: typeof fetch;
|
|
162
|
+
signal?: AbortSignal;
|
|
163
|
+
force?: boolean;
|
|
164
|
+
}): Promise<MinimaxCodeQuota | null>;
|
|
165
|
+
/**
|
|
166
|
+
* Every model id the hardcoded directory offers.
|
|
167
|
+
*
|
|
168
|
+
* Exposed as a function rather than re-exported directly so the status route
|
|
169
|
+
* cannot accidentally treat the catalog as live data: it is shipped, not fetched.
|
|
170
|
+
*/
|
|
171
|
+
export declare function listModelIds(): string[];
|
|
172
|
+
/** The catalog entry count, for a status line that reports what is shipped. */
|
|
173
|
+
export declare function catalogSize(): number;
|
|
174
|
+
/**
|
|
175
|
+
* Whether a credential is worth reporting as signed in.
|
|
176
|
+
*
|
|
177
|
+
* A stored-but-expired credential still counts: the card's job is to show who is
|
|
178
|
+
* signed in and let the refresh path repair the token, not to hide an account whose
|
|
179
|
+
* access token happens to have aged out between two calls.
|
|
180
|
+
*/
|
|
181
|
+
export declare function describeCredentials(credentials: MinimaxCodeCredentials | null): MinimaxCodeAccount | null;
|
|
182
|
+
export { MinimaxCodeUnauthorizedError, agentBaseUrl, MESSAGES_PATH, DEFAULT_DEVICE_INTERVAL_SECONDS, MINIMAX_CODE_BUILD_ENV, redactToken };
|
|
183
|
+
export type { MinimaxCodeRegion };
|
|
184
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../../src/host/minimax-code/client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAGH,OAAO,EAEL,+BAA+B,EAC/B,aAAa,EACb,YAAY,EAMZ,sBAAsB,EAEtB,WAAW,EACZ,MAAM,YAAY,CAAA;AACnB,OAAO,EACL,0BAA0B,EAC1B,KAAK,sBAAsB,EAC5B,MAAM,kBAAkB,CAAA;AACzB,OAAO,EAA6C,4BAA4B,EAAE,MAAM,YAAY,CAAA;AAEpG,OAAO,KAAK,EACV,kBAAkB,EAClB,gBAAgB,EAEhB,iBAAiB,EAClB,MAAM,wCAAwC,CAAA;AAU/C;;;;;;;;;GASG;AACH,wBAAgB,mBAAmB,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAS/E;AAED,oDAAoD;AACpD,wBAAgB,mBAAmB,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAE/E;AAED,2CAA2C;AAC3C,MAAM,WAAW,YAAY;IAC3B,WAAW,EAAE,MAAM,CAAA;IACnB,YAAY,EAAE,MAAM,CAAA;IACpB,eAAe,EAAE,MAAM,CAAA;IACvB,gBAAgB,EAAE,MAAM,CAAA;CACzB;AAYD,kEAAkE;AAClE,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,OAAO,GAAG,YAAY,GAAG,IAAI,CASzE;AAED,yEAAyE;AACzE,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,MAAM,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