@eddyskywalker/dsh-chatgpt-subscription 0.10.0 → 0.10.5
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 +58 -0
- package/README.md +39 -1
- package/lib/client.js +1675 -208
- package/lib/client.js.map +1 -1
- package/lib/index.js +5891 -1342
- 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 +377 -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/checkin-gateway.d.ts +109 -0
- package/lib/types/host/minimax-code/checkin-gateway.d.ts.map +1 -0
- package/lib/types/host/minimax-code/checkin.d.ts +150 -0
- package/lib/types/host/minimax-code/checkin.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 +172 -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 +82 -0
- package/lib/types/host/minimax-code/routes.d.ts.map +1 -0
- package/lib/types/host/minimax-code/token-store.d.ts +253 -0
- package/lib/types/host/minimax-code/token-store.d.ts.map +1 -0
- package/lib/types/host/minimax-code/types.d.ts +222 -0
- package/lib/types/host/minimax-code/types.d.ts.map +1 -0
- package/lib/types/index.d.ts +11 -0
- package/lib/types/index.d.ts.map +1 -1
- package/lib/types/shared/minimax-code-contracts.d.ts +202 -0
- package/lib/types/shared/minimax-code-contracts.d.ts.map +1 -0
- package/package.json +31 -31
- package/lib/types/host/claude/__probe-assert.d.ts +0 -2
- package/lib/types/host/claude/__probe-assert.d.ts.map +0 -1
- package/lib/types/shared/__probe-claude-import.d.ts +0 -2
- package/lib/types/shared/__probe-claude-import.d.ts.map +0 -1
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OAuth for the MiniMax Code subscription.
|
|
3
|
+
*
|
|
4
|
+
* The flow is RFC 8628 device authorization with PKCE(S256) against a public
|
|
5
|
+
* client (`mcode-public`, no secret) — the shape the desktop app uses, and the
|
|
6
|
+
* only one that fits a plugin with no browser callback to receive.
|
|
7
|
+
*
|
|
8
|
+
* Measured facts that shape this file (brief section 2.5):
|
|
9
|
+
*
|
|
10
|
+
* - device authorization: POST `account.minimax.cn/oauth2/device/code`
|
|
11
|
+
* - token (device grant AND refresh): POST `account.minimax.cn/oauth2/token`
|
|
12
|
+
* - revocation: POST `account.minimax.cn/oauth2/revoke`
|
|
13
|
+
* - every call is `application/x-www-form-urlencoded` with `Accept: application/json`
|
|
14
|
+
* - the device grant carries `code_challenge`/`code_challenge_method=S256` and the
|
|
15
|
+
* poll carries the matching `code_verifier`
|
|
16
|
+
* - the refresh carries `grant_type=refresh_token`, `refresh_token`, `client_id`,
|
|
17
|
+
* `scope` and `audience`
|
|
18
|
+
*
|
|
19
|
+
* The refresh policy is the one the brief fixes at section 2.6: read the stored
|
|
20
|
+
* credential first and use it while it is valid, refresh only when it is not (or
|
|
21
|
+
* when the service has just rejected it), write the rotation back atomically, and
|
|
22
|
+
* never let a failed refresh damage the file MiniMax Code itself depends on.
|
|
23
|
+
*/
|
|
24
|
+
import type { MinimaxCodeAccount, MinimaxCodeRegion, MinimaxCodeWebLogin } from '../../shared/minimax-code-contracts.ts';
|
|
25
|
+
import { accountHost } from './types.ts';
|
|
26
|
+
import { type MinimaxCodeCredentialStore, type MinimaxCodeCredentials } from './token-store.ts';
|
|
27
|
+
/** Raised when the stored credential was rejected and a new sign-in is required. */
|
|
28
|
+
export declare class MinimaxCodeUnauthorizedError extends Error {
|
|
29
|
+
constructor(message: string);
|
|
30
|
+
}
|
|
31
|
+
/** Raised when a transient failure outlived its retry budget. */
|
|
32
|
+
export declare class MinimaxCodeRetryableError extends Error {
|
|
33
|
+
constructor(message: string, cause?: unknown);
|
|
34
|
+
}
|
|
35
|
+
/** Raised when the user denied the device authorization request. */
|
|
36
|
+
export declare class MinimaxCodeAccessDeniedError extends Error {
|
|
37
|
+
constructor(message: string);
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* One PKCE pair (RFC 7636).
|
|
41
|
+
*
|
|
42
|
+
* The verifier is a fresh random string per authorization; the challenge is its
|
|
43
|
+
* SHA-256 digest, both base64url encoded with no padding, which is what S256
|
|
44
|
+
* means on the wire.
|
|
45
|
+
*/
|
|
46
|
+
export declare function createPkcePair(): {
|
|
47
|
+
verifier: string;
|
|
48
|
+
challenge: string;
|
|
49
|
+
};
|
|
50
|
+
/** Parsed device authorization response. */
|
|
51
|
+
export interface DeviceAuthorization {
|
|
52
|
+
userCode: string;
|
|
53
|
+
deviceCode: string;
|
|
54
|
+
verificationUri: string;
|
|
55
|
+
verificationUriComplete: string;
|
|
56
|
+
expiresIn: number;
|
|
57
|
+
interval: number;
|
|
58
|
+
/** PKCE verifier the matching poll must present. */
|
|
59
|
+
codeVerifier: string;
|
|
60
|
+
/** Region the authorization was requested in; decides every later host. */
|
|
61
|
+
region: MinimaxCodeRegion;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Start a device authorization (RFC 8628 section 3.1).
|
|
65
|
+
*
|
|
66
|
+
* A public client sends its `client_id`, the scope and audience it wants, and the
|
|
67
|
+
* PKCE challenge — no secret, which is the whole point of the device profile.
|
|
68
|
+
*/
|
|
69
|
+
export declare function requestDeviceAuthorization(options?: {
|
|
70
|
+
fetchFn?: typeof fetch;
|
|
71
|
+
signal?: AbortSignal;
|
|
72
|
+
region?: MinimaxCodeRegion;
|
|
73
|
+
}): Promise<DeviceAuthorization>;
|
|
74
|
+
/** One token response, in the shape the store persists. */
|
|
75
|
+
export interface MinimaxToken {
|
|
76
|
+
accessToken: string;
|
|
77
|
+
refreshToken: string;
|
|
78
|
+
tokenType: string;
|
|
79
|
+
expiresInSec: number;
|
|
80
|
+
expiresAtMs: number;
|
|
81
|
+
scope: string;
|
|
82
|
+
}
|
|
83
|
+
/** Outcome of one device-token poll. */
|
|
84
|
+
export type DevicePollOutcome = {
|
|
85
|
+
kind: 'success';
|
|
86
|
+
token: MinimaxToken;
|
|
87
|
+
} | {
|
|
88
|
+
kind: 'pending';
|
|
89
|
+
slowDown: boolean;
|
|
90
|
+
} | {
|
|
91
|
+
kind: 'expired';
|
|
92
|
+
};
|
|
93
|
+
/**
|
|
94
|
+
* Poll the token endpoint once for one device code (RFC 8628 section 3.4).
|
|
95
|
+
*
|
|
96
|
+
* A 5xx is a transport-class failure rather than a verdict on the device code, so
|
|
97
|
+
* it is raised for the caller's retry loop instead of being read as "still
|
|
98
|
+
* pending" — treating it as pending would spin against a broken endpoint until the
|
|
99
|
+
* device code expired.
|
|
100
|
+
*/
|
|
101
|
+
export declare function pollDeviceToken(authorization: Pick<DeviceAuthorization, 'deviceCode' | 'codeVerifier' | 'region'>, options?: {
|
|
102
|
+
fetchFn?: typeof fetch;
|
|
103
|
+
signal?: AbortSignal;
|
|
104
|
+
}): Promise<DevicePollOutcome>;
|
|
105
|
+
/**
|
|
106
|
+
* Refresh an access token, with a bounded retry.
|
|
107
|
+
*
|
|
108
|
+
* Only a transient status or a transport failure is retried. A 400/401/403, or an
|
|
109
|
+
* `invalid_grant` body, is a verdict that the refresh token is dead and stops
|
|
110
|
+
* immediately: retrying it can never succeed, and every attempt is a request the
|
|
111
|
+
* subscription pays for.
|
|
112
|
+
*/
|
|
113
|
+
export declare function refreshAccessToken(refreshToken: string, options: {
|
|
114
|
+
fetchFn?: typeof fetch;
|
|
115
|
+
signal?: AbortSignal;
|
|
116
|
+
region: MinimaxCodeRegion;
|
|
117
|
+
}): Promise<MinimaxToken>;
|
|
118
|
+
/**
|
|
119
|
+
* Revoke one token at the service.
|
|
120
|
+
*
|
|
121
|
+
* Best effort by design: a revocation that cannot reach the service must not stop
|
|
122
|
+
* a local sign-out, because the credential is already gone from this machine.
|
|
123
|
+
*/
|
|
124
|
+
export declare function revokeToken(token: string, options: {
|
|
125
|
+
fetchFn?: typeof fetch;
|
|
126
|
+
signal?: AbortSignal;
|
|
127
|
+
region: MinimaxCodeRegion;
|
|
128
|
+
}): Promise<boolean>;
|
|
129
|
+
/** Start a device-code sign-in and hand the card what it must display. */
|
|
130
|
+
export declare function beginWebLogin(options?: {
|
|
131
|
+
fetchFn?: typeof fetch;
|
|
132
|
+
region?: MinimaxCodeRegion;
|
|
133
|
+
signal?: AbortSignal;
|
|
134
|
+
}): Promise<MinimaxCodeWebLogin>;
|
|
135
|
+
/** The public projection of one live sign-in, for the status route. */
|
|
136
|
+
export declare function getWebLogin(loginId: string): MinimaxCodeWebLogin | null;
|
|
137
|
+
/** Cancel one sign-in, dropping the session so a later poll cannot resume it. */
|
|
138
|
+
export declare function cancelWebLogin(loginId: string): boolean;
|
|
139
|
+
/** Forget every session; used by the test seam and by a full sign-out. */
|
|
140
|
+
export declare function resetWebLogins(): void;
|
|
141
|
+
/** Build the account projection one credential yields. */
|
|
142
|
+
export declare function accountFromCredentials(credentials: {
|
|
143
|
+
loginEpoch: string;
|
|
144
|
+
generation: number;
|
|
145
|
+
expiresAtMs: number;
|
|
146
|
+
region: MinimaxCodeRegion;
|
|
147
|
+
}): MinimaxCodeAccount;
|
|
148
|
+
export { accountHost };
|
|
149
|
+
/** Whether the given refresh token was rejected recently. */
|
|
150
|
+
export declare function isRefreshTokenRejected(refreshToken: string): boolean;
|
|
151
|
+
/** Test seam: forget every remembered rejection. */
|
|
152
|
+
export declare function resetRefreshRejections(): void;
|
|
153
|
+
export interface EnsureTokenOptions {
|
|
154
|
+
fetchFn?: typeof fetch;
|
|
155
|
+
signal?: AbortSignal;
|
|
156
|
+
/** Refresh even when the stored token is not near expiry (used after a 401). */
|
|
157
|
+
force?: boolean;
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* Return a usable access token, refreshing and writing back only when needed.
|
|
161
|
+
*
|
|
162
|
+
* This is the whole of the contention discipline in one function:
|
|
163
|
+
*
|
|
164
|
+
* 1. read the stored credential and use it as-is while it is valid — the
|
|
165
|
+
* common case, and the one that never touches the file or the network;
|
|
166
|
+
* 2. refresh only when it is not (or when `force` reports a 401 the service has
|
|
167
|
+
* already issued);
|
|
168
|
+
* 3. share one rotation between concurrent callers, so a burst of tool calls at
|
|
169
|
+
* expiry cannot each try to rotate the same refresh token;
|
|
170
|
+
* 4. write the result back through the store's atomic replacement, and remember a
|
|
171
|
+
* rejected token so the next caller is told to sign in instead of retrying.
|
|
172
|
+
*/
|
|
173
|
+
export declare function ensureAccessToken(store: MinimaxCodeCredentialStore, options?: EnsureTokenOptions): Promise<MinimaxCodeCredentials>;
|
|
174
|
+
/**
|
|
175
|
+
* Poll one live sign-in once and, on success, persist what it produced.
|
|
176
|
+
*
|
|
177
|
+
* The persisted credential is plugin-owned: a device-code sign-in started here
|
|
178
|
+
* has no record in the desktop app's `auth.json` (its record key embeds a hash
|
|
179
|
+
* this plugin cannot reproduce), so writing a fabricated entry there would leave
|
|
180
|
+
* the app with an entry it never reads.
|
|
181
|
+
*/
|
|
182
|
+
export declare function pollWebLogin(store: MinimaxCodeCredentialStore, loginId: string, options?: {
|
|
183
|
+
fetchFn?: typeof fetch;
|
|
184
|
+
signal?: AbortSignal;
|
|
185
|
+
/**
|
|
186
|
+
* Called with the credential a completed sign-in produced, after it has been
|
|
187
|
+
* persisted.
|
|
188
|
+
*
|
|
189
|
+
* The single-credential store cannot express a second account, so without this
|
|
190
|
+
* a sign-in started from the card would never join the pool: the pool would
|
|
191
|
+
* keep serving its existing accounts, and the user's new sign-in would exist
|
|
192
|
+
* only as the mirror file. The pool installs this hook and adds the credential
|
|
193
|
+
* as its own account.
|
|
194
|
+
*
|
|
195
|
+
* A failure here must not fail the sign-in: the credential is already durable,
|
|
196
|
+
* and the pool is a routing convenience on top of it. The caller receives the
|
|
197
|
+
* authenticated verdict either way.
|
|
198
|
+
*/
|
|
199
|
+
onSave?: (credentials: MinimaxCodeCredentials) => Promise<void>;
|
|
200
|
+
}): Promise<{
|
|
201
|
+
status: 'pending' | 'authenticated' | 'expired' | 'denied';
|
|
202
|
+
account?: MinimaxCodeAccount;
|
|
203
|
+
}>;
|
|
204
|
+
//# sourceMappingURL=oauth.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"oauth.d.ts","sourceRoot":"","sources":["../../../../src/host/minimax-code/oauth.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAIH,OAAO,KAAK,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,MAAM,wCAAwC,CAAA;AACxH,OAAO,EAgBL,WAAW,EAIZ,MAAM,YAAY,CAAA;AACnB,OAAO,EAEL,KAAK,0BAA0B,EAC/B,KAAK,sBAAs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CAAC,EAAE,kBAAkB,CAAA;CAAE,CAAC,CA6DvG"}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Web routes for the MiniMax Code line.
|
|
3
|
+
*
|
|
4
|
+
* The six routes below are the frozen contract the client half consumes (brief
|
|
5
|
+
* section 3). Their paths, request bodies and verdicts are therefore not free:
|
|
6
|
+
* this file implements them as specified rather than as this line might prefer.
|
|
7
|
+
*
|
|
8
|
+
* Response envelope: every route answers \`{ ok: true, value: <payload> }\`, which is
|
|
9
|
+
* what the sibling lines in this package use. The three routes whose contract names
|
|
10
|
+
* a top-level key as well (\`/login/start\` -> \`login\`, \`/login/poll\` -> \`status\` and
|
|
11
|
+
* \`account\`, \`/test\` -> \`ok\`/\`model\`/\`error\`) carry that key at the top level too,
|
|
12
|
+
* so a client written against either reading resolves. \`/test\` is the one route
|
|
13
|
+
* where the envelope's \`ok\` cannot double as the payload's: its contract defines
|
|
14
|
+
* \`ok\` as the probe verdict, so the envelope there is the verdict itself and the
|
|
15
|
+
* duplicate lives under \`value\`.
|
|
16
|
+
*
|
|
17
|
+
* Mounting: the routes are registered under BOTH the contract prefix and the
|
|
18
|
+
* sibling-line convention, because the two disagree in this repository and the
|
|
19
|
+
* client half must not be able to miss them for that reason alone.
|
|
20
|
+
*
|
|
21
|
+
* \`/models\` and \`/settings\` are the model-settings half every sibling line has and
|
|
22
|
+
* this one shipped without. They are two names for one route because the sibling
|
|
23
|
+
* cards disagree about which to call: kimi-code and claude call it \`/models\`,
|
|
24
|
+
* workbuddy and command-code call it \`/settings\`. Serving both costs one string
|
|
25
|
+
* comparison and removes a client-side special case.
|
|
26
|
+
*/
|
|
27
|
+
import type { Context } from '@deepseek-ai/cordis';
|
|
28
|
+
import { MINIMAX_CODE_PROVIDER_ID, type MinimaxCodeWebStatus } from '../../shared/minimax-code-contracts.ts';
|
|
29
|
+
import { type MinimaxCodeAccountPool } from './account-pool.ts';
|
|
30
|
+
import { MinimaxCodeCredentialStore, MinimaxCodeModelSettingsStore, type MinimaxCodeModelSettings, type MinimaxCodePreferenceStore, type MinimaxCodeSettingsPatch } from './token-store.ts';
|
|
31
|
+
import { ensureAccessToken, getWebLogin } from './oauth.ts';
|
|
32
|
+
import type { MinimaxCodeCheckinService } from './checkin.ts';
|
|
33
|
+
/** The sub-path one request addresses, whichever prefix it arrived under. */
|
|
34
|
+
export declare function subPathOf(requestUrl: string): string;
|
|
35
|
+
/**
|
|
36
|
+
* The stored selection, however this deployment persists it.
|
|
37
|
+
*
|
|
38
|
+
* The routes accept either shape so a composition that still has the register
|
|
39
|
+
* settings seam and one that only has the file both work: the caller passes
|
|
40
|
+
* whichever it wired, and nothing in this file needs to know which it got. The
|
|
41
|
+
* patch type is the store's own, deliberately, so a field added to the settings
|
|
42
|
+
* document cannot become one this route accepts but the stores silently drop.
|
|
43
|
+
*/
|
|
44
|
+
export interface MinimaxCodeSettingsSource {
|
|
45
|
+
/** Current selection: a value on the register seam, a read on the file store. */
|
|
46
|
+
status(): Promise<MinimaxCodeModelSettings> | MinimaxCodeModelSettings;
|
|
47
|
+
update(patch: MinimaxCodeSettingsPatch): Promise<MinimaxCodeModelSettings>;
|
|
48
|
+
}
|
|
49
|
+
export interface MinimaxCodeStatusOptions {
|
|
50
|
+
fetchFn?: typeof fetch;
|
|
51
|
+
/** Whether this plugin currently owns the provider route; re-read on every status. */
|
|
52
|
+
serving?: boolean | (() => boolean);
|
|
53
|
+
/** Diagnostic when another plugin owns the provider route; re-read on every status. */
|
|
54
|
+
conflict?: string | null | (() => string | null);
|
|
55
|
+
/**
|
|
56
|
+
* Where the model selection lives.
|
|
57
|
+
*
|
|
58
|
+
* Omitted, the routes read the default settings file, which is what a caller
|
|
59
|
+
* that only wants the connection half of the card gets. The plugin entry
|
|
60
|
+
* supplies the same store the adapter was built with, so the card and the
|
|
61
|
+
* request path can never read two different selections.
|
|
62
|
+
*/
|
|
63
|
+
settings?: MinimaxCodeSettingsSource;
|
|
64
|
+
/**
|
|
65
|
+
* The account pool, when this process installed one.
|
|
66
|
+
*
|
|
67
|
+
* Omitting it is a supported posture: the line then behaves as the
|
|
68
|
+
* single-credential route it was before the pool existed, and the status
|
|
69
|
+
* reports `poolInstalled: false` so the card can say so rather than render an
|
|
70
|
+
* empty account list that looks like a bug.
|
|
71
|
+
*/
|
|
72
|
+
accountPool?: MinimaxCodeAccountPool;
|
|
73
|
+
/** Daily check-in scheduler; absent leaves the card's check-in row empty. */
|
|
74
|
+
checkin?: Pick<MinimaxCodeCheckinService, 'tick' | 'summary'>;
|
|
75
|
+
}
|
|
76
|
+
/** Everything the settings card renders. */
|
|
77
|
+
export declare function getMinimaxCodeWebStatus(store: MinimaxCodeCredentialStore, options?: MinimaxCodeStatusOptions, settingsSource?: MinimaxCodeSettingsSource): Promise<MinimaxCodeWebStatus>;
|
|
78
|
+
export declare function registerMinimaxCodeRoutes(ctx: Context, store?: MinimaxCodeCredentialStore, options?: MinimaxCodeStatusOptions, modelSettings?: MinimaxCodeModelSettingsStore, preferences?: MinimaxCodePreferenceStore): () => void;
|
|
79
|
+
/** Test seam: forget which sign-in the status route reports. */
|
|
80
|
+
export declare function resetLatestLogin(): void;
|
|
81
|
+
export { MINIMAX_CODE_PROVIDER_ID, getWebLogin, ensureAccessToken };
|
|
82
|
+
//# sourceMappingURL=routes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"routes.d.ts","sourceRoot":"","sources":["../../../../src/host/minimax-code/routes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAGlD,OAAO,EACL,wBAAwB,EAMxB,KAAK,oBAAoB,EAC1B,MAAM,wCAAwC,CAAA;AAG/C,OAAO,EAGL,KAAK,sBAAsB,EAC5B,MAAM,mBAAmB,CAAA;AAE1B,OAAO,EACL,0BAA0B,EAC1B,6BAA6B,EAE7B,KAAK,wB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,aAAa,GAAE,6BAAmE,EAClF,WAAW,CAAC,EAAE,0BAA0B,GACvC,MAAM,IAAI,CAyPZ;AAED,gEAAgE;AAChE,wBAAgB,gBAAgB,IAAI,IAAI,CAEvC;AAED,OAAO,EAAE,wBAAwB,EAAE,WAAW,EAAE,iBAAiB,EAAE,CAAA"}
|
|
@@ -0,0 +1,253 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Credential storage for the MiniMax Code line.
|
|
3
|
+
*
|
|
4
|
+
* Unlike every other line in this package, this one does not own its credential
|
|
5
|
+
* format: MiniMax Code itself keeps the signed-in session in
|
|
6
|
+
* `~/.minimax/auth/<buildEnv>/<region>/mcode-public/auth.json`, and the whole
|
|
7
|
+
* point of reusing it is that a user who is already signed in to the desktop app
|
|
8
|
+
* does not sign in again here.
|
|
9
|
+
*
|
|
10
|
+
* That sharing is the design constraint:
|
|
11
|
+
*
|
|
12
|
+
* 1. READ-ONLY FIRST. Every call reads the file and uses the stored token when it
|
|
13
|
+
* is still valid; the plugin never rotates a credential it does not have to.
|
|
14
|
+
* 2. WRITE-BACK IS ATOMIC. A rotated token replaces the file through a temporary
|
|
15
|
+
* file plus `rename`, so a failed or interrupted refresh leaves the previous
|
|
16
|
+
* `auth.json` byte-for-byte intact — the requirement the brief states at
|
|
17
|
+
* section 2.6.4.
|
|
18
|
+
* 3. NO LOCK IS TAKEN. MiniMax Code holds `auth.lock` while it refreshes, and a
|
|
19
|
+
* second process must not create, delete or wait on that file: doing so could
|
|
20
|
+
* break the app's own refresh. Atomic replacement is what makes lock-free
|
|
21
|
+
* sharing safe instead — a reader sees either the whole old file or the whole
|
|
22
|
+
* new one, never a half-written one, and the record's key is preserved so the
|
|
23
|
+
* app finds its own entry where it left it.
|
|
24
|
+
* 4. THE SHAPE IS PRESERVED. `schemaVersion` and every other record in
|
|
25
|
+
* `records` survive a write untouched; only the `mcode-public` record and the
|
|
26
|
+
* matching `auth-state.json` fields change.
|
|
27
|
+
*
|
|
28
|
+
* A credential this plugin obtained itself (device-code login with no native file
|
|
29
|
+
* present) is kept in the plugin's own store under `$DSH_HOME/storages`, so the
|
|
30
|
+
* two provenances never overwrite each other.
|
|
31
|
+
*/
|
|
32
|
+
import { type ContextWindowOverridePatch } from '../common/context-window-overrides.ts';
|
|
33
|
+
import type { MinimaxCodeReasoningEffort, MinimaxCodeRegion } from '../../shared/minimax-code-contracts.ts';
|
|
34
|
+
/** Where the credential and the token came from. */
|
|
35
|
+
export type MinimaxCodeCredentialSource = 'minimax-native' | 'file';
|
|
36
|
+
/**
|
|
37
|
+
* One MiniMax Code subscription credential.
|
|
38
|
+
*
|
|
39
|
+
* Field names follow `auth.json` exactly; nothing is renamed on the way in or
|
|
40
|
+
* out, so a round trip cannot lose a field the desktop app depends on.
|
|
41
|
+
*/
|
|
42
|
+
export interface MinimaxCodeCredentials {
|
|
43
|
+
/** Bearer access token for the agent API. Host-only; never sent to a browser. */
|
|
44
|
+
accessToken: string;
|
|
45
|
+
/** Rotating refresh token. Host-only. */
|
|
46
|
+
refreshToken: string;
|
|
47
|
+
/** Always "Bearer" in the measured file; kept verbatim. */
|
|
48
|
+
tokenType: string;
|
|
49
|
+
/** Public client the record belongs to. */
|
|
50
|
+
clientId: string;
|
|
51
|
+
/** Scopes the token was issued for. */
|
|
52
|
+
scopes: string[];
|
|
53
|
+
/** Audience the token was issued for. */
|
|
54
|
+
audience: string;
|
|
55
|
+
/** Unix milliseconds the access token stops being valid. */
|
|
56
|
+
expiresAtMs: number;
|
|
57
|
+
/** Rotations the credential has been through; incremented on every refresh. */
|
|
58
|
+
generation: number;
|
|
59
|
+
/** Identity of the sign-in that produced the credential. */
|
|
60
|
+
loginEpoch: string;
|
|
61
|
+
/** Build environment segment of the path the credential lives under. */
|
|
62
|
+
buildEnv: string;
|
|
63
|
+
/** Region the credential was issued in. */
|
|
64
|
+
region: MinimaxCodeRegion;
|
|
65
|
+
/** Record key inside `auth.json`, preserved verbatim so a write lands in place. */
|
|
66
|
+
recordKey: string | null;
|
|
67
|
+
/** Whether this credential is the desktop app's file or the plugin's own. */
|
|
68
|
+
source: MinimaxCodeCredentialSource;
|
|
69
|
+
/** Unix milliseconds this plugin read or wrote the credential. */
|
|
70
|
+
seenAt?: number;
|
|
71
|
+
}
|
|
72
|
+
/** The MiniMax home directory: the desktop app's data root. */
|
|
73
|
+
export declare function minimaxHomeDir(env?: NodeJS.ProcessEnv): string;
|
|
74
|
+
/** Directory holding one region's auth files. */
|
|
75
|
+
export declare function authDirFor(region: MinimaxCodeRegion, buildEnv?: string): string;
|
|
76
|
+
/** Path of the desktop app's credential file for one region. */
|
|
77
|
+
export declare function authJsonPath(region: MinimaxCodeRegion, buildEnv?: string): string;
|
|
78
|
+
/** Path of the desktop app's non-secret state file for one region. */
|
|
79
|
+
export declare function authStateJsonPath(region: MinimaxCodeRegion, buildEnv?: string): string;
|
|
80
|
+
/** Path of the plugin's own credential file, used when no native file exists. */
|
|
81
|
+
export declare function pluginCredentialPath(): string;
|
|
82
|
+
/**
|
|
83
|
+
* Validate and normalize one stored credential.
|
|
84
|
+
*
|
|
85
|
+
* A payload that is missing a token or an expiry is rejected rather than
|
|
86
|
+
* defaulted: a credential with an invented expiry would be presented to the
|
|
87
|
+
* service as valid when it is not, which is exactly the failure the refresh path
|
|
88
|
+
* exists to prevent.
|
|
89
|
+
*/
|
|
90
|
+
export declare function parseMinimaxCodeCredentials(value: unknown, fallback: {
|
|
91
|
+
region: MinimaxCodeRegion;
|
|
92
|
+
buildEnv?: string;
|
|
93
|
+
recordKey?: string | null;
|
|
94
|
+
source?: MinimaxCodeCredentialSource;
|
|
95
|
+
}): MinimaxCodeCredentials;
|
|
96
|
+
/** Whether a credential is valid for long enough to use as-is. */
|
|
97
|
+
export declare function credentialIsFresh(credentials: MinimaxCodeCredentials, now?: number): boolean;
|
|
98
|
+
/**
|
|
99
|
+
* The credential store for this line.
|
|
100
|
+
*
|
|
101
|
+
* `read()` prefers the desktop app's file and falls back to the plugin's own, so
|
|
102
|
+
* a user who signed in through either path is served. `write()` returns the
|
|
103
|
+
* credential to the file it came from, which is what keeps the two provenances
|
|
104
|
+
* from clobbering each other.
|
|
105
|
+
*/
|
|
106
|
+
export declare class MinimaxCodeCredentialStore {
|
|
107
|
+
private readonly region;
|
|
108
|
+
constructor(region?: MinimaxCodeRegion);
|
|
109
|
+
/** Path of the file the next read or write targets. */
|
|
110
|
+
path(): string;
|
|
111
|
+
private readNative;
|
|
112
|
+
private readPluginFile;
|
|
113
|
+
read(): Promise<MinimaxCodeCredentials | null>;
|
|
114
|
+
/**
|
|
115
|
+
* The credential in force plus where it came from, in one pass.
|
|
116
|
+
*
|
|
117
|
+
* A status response needs all three facts, and each of the targeted accessors
|
|
118
|
+
* re-reads and re-parses the native document (a file read plus a JSON parse per
|
|
119
|
+
* region probed). Reading once here keeps one /status call from doing that work
|
|
120
|
+
* three times, which matters because the settings card polls this route.
|
|
121
|
+
*/
|
|
122
|
+
readWithProvenance(): Promise<{
|
|
123
|
+
credentials: MinimaxCodeCredentials | null;
|
|
124
|
+
source: MinimaxCodeCredentialSource;
|
|
125
|
+
path: string;
|
|
126
|
+
}>;
|
|
127
|
+
/** Which file the credential currently in force lives in. */
|
|
128
|
+
activeSource(): Promise<MinimaxCodeCredentialSource>;
|
|
129
|
+
/**
|
|
130
|
+
* Persist a credential back where it came from.
|
|
131
|
+
*
|
|
132
|
+
* A native credential is written into the existing record, preserving the
|
|
133
|
+
* document's `schemaVersion` and every other record; a plugin credential is
|
|
134
|
+
* written to the plugin's own file. Either way the write is atomic.
|
|
135
|
+
*/
|
|
136
|
+
write(credentials: MinimaxCodeCredentials): Promise<void>;
|
|
137
|
+
/**
|
|
138
|
+
* Forget the credential this plugin owns.
|
|
139
|
+
*
|
|
140
|
+
* The desktop app's `auth.json` is deliberately left alone: it is not this
|
|
141
|
+
* plugin's to delete, and removing it would sign the user out of MiniMax Code
|
|
142
|
+
* itself. A credential this store is only *reading* from the app therefore
|
|
143
|
+
* remains in force after a sign-out, which the status route reports so the
|
|
144
|
+
* user is not told a session ended when it did not.
|
|
145
|
+
*/
|
|
146
|
+
delete(): Promise<void>;
|
|
147
|
+
}
|
|
148
|
+
/** Namespace the model selection is registered under on a register-capable harness. */
|
|
149
|
+
export declare const MINIMAX_CODE_PREFERENCES_NAMESPACE = "dsh-minimax-code";
|
|
150
|
+
/**
|
|
151
|
+
* The model-selection half of this line's settings.
|
|
152
|
+
*
|
|
153
|
+
* The catalog (`MINIMAX_CODE_MODELS`) is deliberately not stored here. A shipped
|
|
154
|
+
* catalog changes with the code, so persisting a copy of it would leave a user
|
|
155
|
+
* whose file is a release behind reading a model list the build no longer serves;
|
|
156
|
+
* only the user's own choices live in this document.
|
|
157
|
+
*/
|
|
158
|
+
export interface MinimaxCodeModelSettings {
|
|
159
|
+
/** Line-wide switch. Absent means enabled: this line shipped enabled. */
|
|
160
|
+
enabled?: boolean;
|
|
161
|
+
/** Catalog ids DSH offers in the conversation model picker. */
|
|
162
|
+
enabledModelIds: string[];
|
|
163
|
+
/** Per-model context window, replacing the catalog's own number. */
|
|
164
|
+
contextWindowOverrides: Record<string, number>;
|
|
165
|
+
/** Level used when a conversation picks none; null means the model's own. */
|
|
166
|
+
defaultReasoningEffort: MinimaxCodeReasoningEffort | null;
|
|
167
|
+
/** Daily check-in scheduler switch. Absent means enabled. */
|
|
168
|
+
checkin?: {
|
|
169
|
+
enabled: boolean;
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* One settings patch.
|
|
174
|
+
*
|
|
175
|
+
* `contextWindowOverrides` is a patch rather than the whole map because `null`
|
|
176
|
+
* has to survive as a value: it is the settings card's "restore the catalog
|
|
177
|
+
* default" and deletes exactly one key. A full replacement could not express
|
|
178
|
+
* that without the caller first reading the document it wants to edit.
|
|
179
|
+
*/
|
|
180
|
+
export interface MinimaxCodeSettingsPatch {
|
|
181
|
+
enabled?: boolean;
|
|
182
|
+
enabledModelIds?: string[];
|
|
183
|
+
contextWindowOverrides?: ContextWindowOverridePatch;
|
|
184
|
+
defaultReasoningEffort?: MinimaxCodeReasoningEffort | null;
|
|
185
|
+
checkin?: {
|
|
186
|
+
enabled: boolean;
|
|
187
|
+
};
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* The seam the routes and the adapter share.
|
|
191
|
+
*
|
|
192
|
+
* `status()` is synchronous on purpose: it is read on every model-picker query
|
|
193
|
+
* and on every settings-card poll, and both callers only need a snapshot. A
|
|
194
|
+
* promise-shaped reader here would make each of them await a file read on a hot
|
|
195
|
+
* path for a value that changes at human speed.
|
|
196
|
+
*/
|
|
197
|
+
export interface MinimaxCodePreferenceStore {
|
|
198
|
+
/**
|
|
199
|
+
* The file-backed store warms up asynchronously, so `status()` answers from
|
|
200
|
+
* shipped defaults until that read settles. A caller that acts on a
|
|
201
|
+
* preference at startup — the check-in scheduler signing in on boot — must
|
|
202
|
+
* await this first, or it acts on the default instead of the user's choice.
|
|
203
|
+
* A register-backed store reads synchronously and resolves immediately.
|
|
204
|
+
*/
|
|
205
|
+
ready(): Promise<void>;
|
|
206
|
+
status(): MinimaxCodeModelSettings;
|
|
207
|
+
update(patch: MinimaxCodeSettingsPatch): Promise<MinimaxCodeModelSettings>;
|
|
208
|
+
}
|
|
209
|
+
/** Path of the settings file used when no settings service is present. */
|
|
210
|
+
export declare function modelSettingsPath(): string;
|
|
211
|
+
/**
|
|
212
|
+
* Apply one patch to one settings document.
|
|
213
|
+
*
|
|
214
|
+
* The merge lives outside both stores because the register-backed store has to
|
|
215
|
+
* normalize the scope's value through the same rules the file store applies; two
|
|
216
|
+
* copies of this logic is how the two storage paths drift apart the first time
|
|
217
|
+
* one of them learns a new field.
|
|
218
|
+
*/
|
|
219
|
+
export declare function mergeMinimaxCodeSettings(current: MinimaxCodeModelSettings, patch: MinimaxCodeSettingsPatch): MinimaxCodeModelSettings;
|
|
220
|
+
/**
|
|
221
|
+
* The settings file beside the credentials.
|
|
222
|
+
*
|
|
223
|
+
* This is what a harness without the register seam (0.1.7, and a headless host)
|
|
224
|
+
* reads back on boot, so it is the store that has to survive a crash: the write
|
|
225
|
+
* is a temporary sibling plus `rename`, and the document just written is read
|
|
226
|
+
* back and compared before the write is reported as done. Without the read-back
|
|
227
|
+
* a partial write, or a filesystem that dropped the rename, would report a
|
|
228
|
+
* selection the next boot does not agree with — the card would show a model
|
|
229
|
+
* grid the adapter never applies.
|
|
230
|
+
*/
|
|
231
|
+
export declare class MinimaxCodeModelSettingsStore {
|
|
232
|
+
private readonly filePath;
|
|
233
|
+
constructor(filePath?: string);
|
|
234
|
+
path(): string;
|
|
235
|
+
read(): Promise<MinimaxCodeModelSettings>;
|
|
236
|
+
write(settings: MinimaxCodeModelSettings): Promise<void>;
|
|
237
|
+
/**
|
|
238
|
+
* Read-modify-write under the same per-path lock the credential writes use.
|
|
239
|
+
*
|
|
240
|
+
* Without it two patches landing together each read the same document and the
|
|
241
|
+
* second write silently discards the first — a lost model selection, with no
|
|
242
|
+
* error anywhere. The lock is shared with the credential paths because it is
|
|
243
|
+
* keyed by resolved path, and the two never name the same file.
|
|
244
|
+
*/
|
|
245
|
+
updateSettings(patch: MinimaxCodeSettingsPatch): Promise<MinimaxCodeModelSettings>;
|
|
246
|
+
}
|
|
247
|
+
/**
|
|
248
|
+
* Bind the model selection to the DSH settings document when the harness still
|
|
249
|
+
* offers one, and to the JSON file beside it otherwise: a harness without the
|
|
250
|
+
* register seam (0.1.7, and a headless host) reads that file back on boot.
|
|
251
|
+
*/
|
|
252
|
+
export declare function registerMinimaxCodePreferenceStore(settings?: unknown, fallbackStore?: MinimaxCodeModelSettingsStore): MinimaxCodePreferenceStore;
|
|
253
|
+
//# sourceMappingURL=token-store.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"token-store.d.ts","sourceRoot":"","sources":["../../../../src/host/minimax-code/token-store.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAUH,OAAO,EAA+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