dsh-agent-sdk-bridge 1.0.0 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/DEVELOPMENT.md +62 -3
- package/FAQ.md +58 -0
- package/README.md +53 -24
- package/client.js +2411 -1802
- package/cordis.patch.yml +4 -3
- package/lib/index.js +3151 -250
- package/lib/types/api.d.ts +5 -2
- package/lib/types/brand.d.ts +26 -3
- package/lib/types/codebuddy.d.ts +12 -1
- package/lib/types/config.d.ts +41 -1
- package/lib/types/index.d.ts +21 -0
- package/lib/types/minimax-adapter.d.ts +86 -0
- package/lib/types/minimax-cli.d.ts +69 -0
- package/lib/types/minimax.d.ts +493 -0
- package/package.json +7 -2
- package/src/api.ts +120 -32
- package/src/brand.ts +49 -5
- package/src/codebuddy.ts +55 -4
- package/src/config.ts +53 -1
- package/src/index.ts +50 -4
- package/src/minimax-adapter.ts +370 -0
- package/src/minimax-cli.ts +276 -0
- package/src/minimax.ts +2413 -0
|
@@ -0,0 +1,493 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MiniMax Code over the Agent Client Protocol.
|
|
3
|
+
*
|
|
4
|
+
* `mcode acp` is a stdio ACP server: the plugin starts one process per warm
|
|
5
|
+
* host session, negotiates capabilities, creates one ACP session, and streams
|
|
6
|
+
* `session/update` notifications back to the harness. Host tools are injected
|
|
7
|
+
* as an HTTP MCP server (`mcpServers` in `session/new`), so a tool call the
|
|
8
|
+
* model makes reaches this plugin and then the harness, exactly like the
|
|
9
|
+
* CodeBuddy path.
|
|
10
|
+
*
|
|
11
|
+
* Two MiniMax behaviours shape this module:
|
|
12
|
+
*
|
|
13
|
+
* - ACP has no way to turn off the CLI's built-in tools. The model may call
|
|
14
|
+
* `bash`/`write`/`read` directly, which would bypass the harness. The client
|
|
15
|
+
* watches `tool_call` notifications and cancels the prompt before execution;
|
|
16
|
+
* the turn is then retried with a correction. Host MCP tools are the only
|
|
17
|
+
* calls allowed through.
|
|
18
|
+
* - The CLI stores one auth state per region and selects it with
|
|
19
|
+
* `MAVIS_REGION`; every process is pinned so the mainland and international
|
|
20
|
+
* accounts can coexist.
|
|
21
|
+
*
|
|
22
|
+
* @module dsh-agent-sdk-bridge/minimax
|
|
23
|
+
*/
|
|
24
|
+
import type { GenerateOptions, RequestMessage, StreamChunk, TokenUsage } from '@deepseek-ai/dsh-llm';
|
|
25
|
+
import type { MinimaxRegion } from './brand.ts';
|
|
26
|
+
import type { Live } from './live.ts';
|
|
27
|
+
/** Default context capacity shown for a MiniMax model that declares none. */
|
|
28
|
+
export declare const MINIMAX_DEFAULT_CONTEXT_WINDOW = 512000;
|
|
29
|
+
/** Default output cap; the published MiniMax models allow 128k. */
|
|
30
|
+
export declare const MINIMAX_DEFAULT_MAX_TOKENS = 128000;
|
|
31
|
+
/** How long one model catalog stays fresh. */
|
|
32
|
+
export declare const MINIMAX_CACHE_TTL_MS = 300000;
|
|
33
|
+
/** Bound for one ACP control round trip. */
|
|
34
|
+
export declare const MINIMAX_FETCH_TIMEOUT_MS = 30000;
|
|
35
|
+
/** The MCP server name the model sees; its tools are `mcp__dsh-host__*`. */
|
|
36
|
+
export declare const MINIMAX_MCP_SERVER = "dsh-host";
|
|
37
|
+
/** One model as the settings page and the adapter see it. */
|
|
38
|
+
export interface MinimaxModel {
|
|
39
|
+
id: string;
|
|
40
|
+
name: string;
|
|
41
|
+
description?: string;
|
|
42
|
+
contextWindows: number[];
|
|
43
|
+
defaultContextWindow: number;
|
|
44
|
+
vision: boolean;
|
|
45
|
+
reasoning: boolean;
|
|
46
|
+
reasoningEfforts: string[];
|
|
47
|
+
defaultEffort?: string;
|
|
48
|
+
}
|
|
49
|
+
/** One tool call's result, in the shape the MCP bridge returns. */
|
|
50
|
+
export interface MinimaxMcpToolResult {
|
|
51
|
+
content: {
|
|
52
|
+
type: 'text';
|
|
53
|
+
text: string;
|
|
54
|
+
}[];
|
|
55
|
+
isError?: boolean;
|
|
56
|
+
}
|
|
57
|
+
/** Login progress and state for one region. */
|
|
58
|
+
export interface MinimaxAuthStatus {
|
|
59
|
+
running: boolean;
|
|
60
|
+
region: MinimaxRegion;
|
|
61
|
+
signedIn: boolean;
|
|
62
|
+
startedAt?: number;
|
|
63
|
+
finishedAt?: number;
|
|
64
|
+
/** Authorization URL, once the CLI prints one. */
|
|
65
|
+
url?: string;
|
|
66
|
+
/** Expiry of the stored access token, when reported. */
|
|
67
|
+
expiresAt?: number;
|
|
68
|
+
error?: string;
|
|
69
|
+
}
|
|
70
|
+
/** One rolling quota window reported by the coding-plan endpoint. */
|
|
71
|
+
export interface MinimaxQuotaWindow {
|
|
72
|
+
id: string;
|
|
73
|
+
label: string;
|
|
74
|
+
/** Percent still available; absent when the CLI reports no percentage. */
|
|
75
|
+
remainingPercent?: number;
|
|
76
|
+
/** When this window resets. */
|
|
77
|
+
resetAt?: number;
|
|
78
|
+
/** The plan does not count this window (status 3). */
|
|
79
|
+
unlimited: boolean;
|
|
80
|
+
/** Remaining units, when the endpoint reports a count instead of a ratio. */
|
|
81
|
+
remainingCount?: number;
|
|
82
|
+
totalCount?: number;
|
|
83
|
+
}
|
|
84
|
+
/** Which quota model the account is on. */
|
|
85
|
+
export interface MinimaxPlanInfo {
|
|
86
|
+
kind: 'token-plan' | 'credits' | 'free';
|
|
87
|
+
hasTokenPlan: boolean;
|
|
88
|
+
/** Plan name the account itself reports, when it has one. */
|
|
89
|
+
name?: string;
|
|
90
|
+
tier?: string;
|
|
91
|
+
expiresAt?: number;
|
|
92
|
+
subscriptionType?: string;
|
|
93
|
+
}
|
|
94
|
+
/** Credit balance from the membership record. */
|
|
95
|
+
export interface MinimaxCreditInfo {
|
|
96
|
+
remaining: number;
|
|
97
|
+
purchasedRemaining?: number;
|
|
98
|
+
freeRemaining?: number;
|
|
99
|
+
}
|
|
100
|
+
/** Display identity of the signed-in MiniMax account. */
|
|
101
|
+
export interface MinimaxAccountInfo {
|
|
102
|
+
name?: string;
|
|
103
|
+
email?: string;
|
|
104
|
+
avatar?: string;
|
|
105
|
+
userId?: string;
|
|
106
|
+
}
|
|
107
|
+
/** What the settings page shows for a MiniMax account. */
|
|
108
|
+
export interface MinimaxUsageSnapshot {
|
|
109
|
+
at: number;
|
|
110
|
+
region: MinimaxRegion;
|
|
111
|
+
signedIn: boolean;
|
|
112
|
+
/** Whether the `mcode` executable was found. */
|
|
113
|
+
installed: boolean;
|
|
114
|
+
/** The site refused this machine's network and redirected to the other one. */
|
|
115
|
+
regionBlocked?: boolean;
|
|
116
|
+
error?: string;
|
|
117
|
+
account?: MinimaxAccountInfo;
|
|
118
|
+
plan?: MinimaxPlanInfo;
|
|
119
|
+
credits?: MinimaxCreditInfo;
|
|
120
|
+
/** Coding-plan windows, empty for accounts without a token plan. */
|
|
121
|
+
windows?: MinimaxQuotaWindow[];
|
|
122
|
+
}
|
|
123
|
+
/** The per-user CLI state directory. */
|
|
124
|
+
export declare function minimaxDataDir(): string;
|
|
125
|
+
/** Path of one region's auth-state file. */
|
|
126
|
+
export declare function minimaxAuthStatePath(region: MinimaxRegion): string;
|
|
127
|
+
/** The CLI command name, for error text. */
|
|
128
|
+
export declare function minimaxCliCommand(): string;
|
|
129
|
+
/** Whether a CLI tool name belongs to this plugin's MCP server. */
|
|
130
|
+
export declare function isHostMcpTool(name: string): boolean;
|
|
131
|
+
/** The host-side name of an MCP tool, without the namespace. */
|
|
132
|
+
export declare function hostMcpToolName(name: string): string;
|
|
133
|
+
/** The model config option's values as rows. */
|
|
134
|
+
export declare function minimaxModelsFromConfigOptions(options: readonly any[] | null | undefined): MinimaxModel[];
|
|
135
|
+
/** Whether the region has a stored login. */
|
|
136
|
+
export declare function minimaxSignedIn(region: MinimaxRegion): boolean;
|
|
137
|
+
/** How long one quota reading stays fresh. */
|
|
138
|
+
export declare const MINIMAX_USAGE_CACHE_TTL_MS = 60000;
|
|
139
|
+
/**
|
|
140
|
+
* Whether a URL points at the other site.
|
|
141
|
+
*
|
|
142
|
+
* MiniMax's edge answers a request from the wrong side of the border with a
|
|
143
|
+
* 307 to the other site (`.io` -> `.minimaxi.com` and the reverse). The two
|
|
144
|
+
* are different origins, so a redirect also drops the Authorization header;
|
|
145
|
+
* that is why the CLI reports `401 token is required` instead of an
|
|
146
|
+
* actionable error, and why a stale token is not the real cause.
|
|
147
|
+
*/
|
|
148
|
+
export declare function minimaxHostBelongsToOtherRegion(region: MinimaxRegion, target: string | URL): boolean;
|
|
149
|
+
/** The sentence the card and the chat surface show for a refused region. */
|
|
150
|
+
export declare function minimaxRegionBlockMessage(region: MinimaxRegion): string;
|
|
151
|
+
/** A region whose hosts refused this machine's network. */
|
|
152
|
+
export declare class MinimaxRegionBlockedError extends Error {
|
|
153
|
+
readonly region: MinimaxRegion;
|
|
154
|
+
constructor(region: MinimaxRegion);
|
|
155
|
+
}
|
|
156
|
+
/** Forget a cached reachability verdict. */
|
|
157
|
+
export declare function invalidateMinimaxRegionAccess(region?: MinimaxRegion): void;
|
|
158
|
+
/** The last verdict, for synchronous rendering under the card. */
|
|
159
|
+
export declare function minimaxRegionBlockedCached(region: MinimaxRegion): boolean;
|
|
160
|
+
/**
|
|
161
|
+
* Probe the region's account host for a cross-region redirect.
|
|
162
|
+
*
|
|
163
|
+
* Only a redirect to the other site's domain counts as a block. A timeout or
|
|
164
|
+
* DNS failure leaves the previous verdict alone, so callers report the real
|
|
165
|
+
* network error instead of blaming the IP.
|
|
166
|
+
*/
|
|
167
|
+
export declare function minimaxRegionBlocked(region: MinimaxRegion, options?: {
|
|
168
|
+
fresh?: boolean;
|
|
169
|
+
fetchImpl?: typeof fetch;
|
|
170
|
+
signal?: AbortSignal;
|
|
171
|
+
}): Promise<boolean>;
|
|
172
|
+
/**
|
|
173
|
+
* Build a snapshot from the three account documents.
|
|
174
|
+
*
|
|
175
|
+
* Split out from the network path so the mapping is testable without a live
|
|
176
|
+
* account: the membership record is the source of the plan and credit
|
|
177
|
+
* balance, `remains` only exists for token-plan subscribers.
|
|
178
|
+
*/
|
|
179
|
+
export declare function minimaxUsageFromParts(parts: {
|
|
180
|
+
region: MinimaxRegion;
|
|
181
|
+
at?: number;
|
|
182
|
+
installed?: boolean;
|
|
183
|
+
userInfo?: Record<string, unknown>;
|
|
184
|
+
workspaces?: readonly Record<string, unknown>[];
|
|
185
|
+
membership?: Record<string, unknown>;
|
|
186
|
+
remains?: Record<string, unknown>;
|
|
187
|
+
}): MinimaxUsageSnapshot;
|
|
188
|
+
/** Drop a cached quota reading, so the next request re-reads it. */
|
|
189
|
+
export declare function invalidateMinimaxUsage(region?: MinimaxRegion): void;
|
|
190
|
+
/**
|
|
191
|
+
* Read one region's account, plan and quota.
|
|
192
|
+
*
|
|
193
|
+
* A failed account call keeps the login state and reports the reason in
|
|
194
|
+
* `error`; the settings card shows the account it already knows with that
|
|
195
|
+
* message instead of silently claiming nothing is configured.
|
|
196
|
+
*/
|
|
197
|
+
export declare function minimaxUsage(region: MinimaxRegion, options?: {
|
|
198
|
+
fresh?: boolean;
|
|
199
|
+
token?: string;
|
|
200
|
+
fetchImpl?: typeof fetch;
|
|
201
|
+
signal?: AbortSignal;
|
|
202
|
+
}): Promise<MinimaxUsageSnapshot>;
|
|
203
|
+
/**
|
|
204
|
+
* Browser login/logout, one run per region.
|
|
205
|
+
*
|
|
206
|
+
* The CLI owns the OAuth device flow and the credential file. The plugin only
|
|
207
|
+
* starts the process, surfaces the authorization URL while it waits, and then
|
|
208
|
+
* re-reads the auth-state file to decide whether the region is signed in.
|
|
209
|
+
*/
|
|
210
|
+
export declare class MinimaxAuth {
|
|
211
|
+
private readonly runs;
|
|
212
|
+
status(region: MinimaxRegion): MinimaxAuthStatus;
|
|
213
|
+
/** Start the CLI's browser login. */
|
|
214
|
+
start(region: MinimaxRegion, onFinish?: (ok: boolean) => void): {
|
|
215
|
+
started: true;
|
|
216
|
+
} | {
|
|
217
|
+
started: false;
|
|
218
|
+
error: string;
|
|
219
|
+
};
|
|
220
|
+
/** Sign one region out; the other region is untouched. */
|
|
221
|
+
logout(region: MinimaxRegion): Promise<MinimaxAuthStatus>;
|
|
222
|
+
/** Cancel any login process (plugin disposal). */
|
|
223
|
+
stop(): void;
|
|
224
|
+
}
|
|
225
|
+
/** One event the ACP client or the MCP bridge delivers to a turn. */
|
|
226
|
+
type SessionEvent = {
|
|
227
|
+
kind: 'text';
|
|
228
|
+
text: string;
|
|
229
|
+
} | {
|
|
230
|
+
kind: 'reasoning';
|
|
231
|
+
text: string;
|
|
232
|
+
} | {
|
|
233
|
+
kind: 'usage';
|
|
234
|
+
used: number;
|
|
235
|
+
size: number;
|
|
236
|
+
} | {
|
|
237
|
+
kind: 'host-tool';
|
|
238
|
+
callId: string;
|
|
239
|
+
name: string;
|
|
240
|
+
args: Record<string, unknown>;
|
|
241
|
+
} | {
|
|
242
|
+
kind: 'native-tool';
|
|
243
|
+
name: string;
|
|
244
|
+
} | {
|
|
245
|
+
kind: 'prompt-done';
|
|
246
|
+
stopReason: string;
|
|
247
|
+
} | {
|
|
248
|
+
kind: 'prompt-error';
|
|
249
|
+
error: Error;
|
|
250
|
+
} | {
|
|
251
|
+
kind: 'closed';
|
|
252
|
+
error: Error;
|
|
253
|
+
};
|
|
254
|
+
/** Options for one ACP process. */
|
|
255
|
+
interface MinimaxAcpOptions {
|
|
256
|
+
region: MinimaxRegion;
|
|
257
|
+
cwd: string;
|
|
258
|
+
systemPrompt: string;
|
|
259
|
+
/** HTTP MCP endpoint for host tools; absent for catalog/title calls. */
|
|
260
|
+
mcpUrl?: string;
|
|
261
|
+
mcpToken?: string;
|
|
262
|
+
/** Disable all CLI tools (catalog and title reads need none). */
|
|
263
|
+
disableTools?: boolean;
|
|
264
|
+
timeoutMs?: number;
|
|
265
|
+
onUpdate?: (update: SessionEvent) => void;
|
|
266
|
+
onExit?: (error: Error) => void;
|
|
267
|
+
onPermissionDenied?: (toolName: string) => void;
|
|
268
|
+
}
|
|
269
|
+
/**
|
|
270
|
+
* One `mcode acp` process and its ACP session.
|
|
271
|
+
*
|
|
272
|
+
* The class only speaks protocol: model/effort config, prompts, cancellation,
|
|
273
|
+
* and the translation of `session/update` into {@link SessionEvent}s. Turn
|
|
274
|
+
* policy (tool calls, retries, harness chunks) lives in {@link MinimaxSession}.
|
|
275
|
+
*/
|
|
276
|
+
export declare class MinimaxAcp {
|
|
277
|
+
private child;
|
|
278
|
+
private conn;
|
|
279
|
+
private sessionId;
|
|
280
|
+
private configOptions;
|
|
281
|
+
private systemFile;
|
|
282
|
+
private tempDir;
|
|
283
|
+
private closing;
|
|
284
|
+
private stderr;
|
|
285
|
+
private readonly options;
|
|
286
|
+
constructor(options: MinimaxAcpOptions);
|
|
287
|
+
/** The model/effort options the CLI currently offers. */
|
|
288
|
+
get optionsList(): readonly any[];
|
|
289
|
+
/** The selected model config value. */
|
|
290
|
+
get currentModel(): string | undefined;
|
|
291
|
+
/** Start the process and create one ACP session. */
|
|
292
|
+
start(): Promise<void>;
|
|
293
|
+
/** Run one prompt; resolves when the agent's turn ends. */
|
|
294
|
+
prompt(text: string): Promise<{
|
|
295
|
+
stopReason: string;
|
|
296
|
+
}>;
|
|
297
|
+
/** Ask the agent to stop the active turn. */
|
|
298
|
+
cancel(): Promise<void>;
|
|
299
|
+
/** Set a session config option and remember the updated list. */
|
|
300
|
+
setConfig(id: string, value: string): Promise<void>;
|
|
301
|
+
/**
|
|
302
|
+
* List the models the CLI actually accepts, with each model's own efforts.
|
|
303
|
+
*
|
|
304
|
+
* The advertised option list can contain values the agent rejects (0.6.12
|
|
305
|
+
* lists a `M3.1-Flash` non-thinking value and answers `Invalid model
|
|
306
|
+
* reasoning` when it is selected). Selecting each value once is the only
|
|
307
|
+
* reliable filter, and it also reveals that non-thinking models drop the
|
|
308
|
+
* `thinkingEffort` option entirely, so reasoning has to be reported per
|
|
309
|
+
* model rather than once for the catalog.
|
|
310
|
+
*/
|
|
311
|
+
probeModels(): Promise<MinimaxModel[]>;
|
|
312
|
+
/** Select the model (and, when supported, the thinking effort). */
|
|
313
|
+
selectModel(model: string, effort?: string): Promise<void>;
|
|
314
|
+
/** Exit the session and reap the process. */
|
|
315
|
+
close(): Promise<void>;
|
|
316
|
+
}
|
|
317
|
+
/** Read the model list for one region (cached). */
|
|
318
|
+
export declare class MinimaxCatalog {
|
|
319
|
+
private readonly region;
|
|
320
|
+
private readonly ttlMs;
|
|
321
|
+
private readonly timeoutMs;
|
|
322
|
+
private readonly snapshots;
|
|
323
|
+
private readonly inflight;
|
|
324
|
+
private readonly failures;
|
|
325
|
+
constructor(region: Live<MinimaxRegion>, ttlMs?: Live<number>, timeoutMs?: Live<number>);
|
|
326
|
+
/** Models for one region; a failed refresh keeps the last good list. */
|
|
327
|
+
models(requested?: MinimaxRegion): Promise<readonly MinimaxModel[]>;
|
|
328
|
+
/** Why the last refresh failed, or undefined when it succeeded. */
|
|
329
|
+
error(requested?: MinimaxRegion): string | undefined;
|
|
330
|
+
invalidate(region?: MinimaxRegion): void;
|
|
331
|
+
private fetch;
|
|
332
|
+
}
|
|
333
|
+
/** One shared HTTP MCP server for every warm MiniMax session. */
|
|
334
|
+
export declare class MinimaxMcpServer {
|
|
335
|
+
private server;
|
|
336
|
+
private port;
|
|
337
|
+
private readonly bridges;
|
|
338
|
+
/** The base URL, or undefined before {@link start}. */
|
|
339
|
+
get baseUrl(): string | undefined;
|
|
340
|
+
/** Bind to an ephemeral loopback port. */
|
|
341
|
+
start(): Promise<void>;
|
|
342
|
+
/** Add one session's bridge under a random token. */
|
|
343
|
+
register(bridge: MinimaxMcpBridge): {
|
|
344
|
+
url: string;
|
|
345
|
+
token: string;
|
|
346
|
+
};
|
|
347
|
+
unregister(token: string): void;
|
|
348
|
+
/** Close the server and release every session. */
|
|
349
|
+
close(): void;
|
|
350
|
+
private handle;
|
|
351
|
+
}
|
|
352
|
+
/** One session's view of the MCP server. */
|
|
353
|
+
export declare class MinimaxMcpBridge {
|
|
354
|
+
private readonly callHost;
|
|
355
|
+
private schemas;
|
|
356
|
+
constructor(callHost: (name: string, args: Record<string, unknown>) => Promise<MinimaxMcpToolResult>);
|
|
357
|
+
setTools(tools: readonly {
|
|
358
|
+
name: string;
|
|
359
|
+
description: string;
|
|
360
|
+
parameters?: unknown;
|
|
361
|
+
}[]): void;
|
|
362
|
+
tools(): {
|
|
363
|
+
name: string;
|
|
364
|
+
description: string;
|
|
365
|
+
inputSchema: Record<string, unknown>;
|
|
366
|
+
}[];
|
|
367
|
+
call(name: string, args: Record<string, unknown>): Promise<MinimaxMcpToolResult>;
|
|
368
|
+
}
|
|
369
|
+
/** Build a turn's usage from its character counts and the reported context. */
|
|
370
|
+
export declare function minimaxTurnUsage(counts: {
|
|
371
|
+
contextUsed?: number;
|
|
372
|
+
inputChars: number;
|
|
373
|
+
outputChars: number;
|
|
374
|
+
reasoningChars: number;
|
|
375
|
+
}): TokenUsage;
|
|
376
|
+
/**
|
|
377
|
+
* One warm MiniMax conversation for a harness session id.
|
|
378
|
+
*
|
|
379
|
+
* The ACP agent owns the history. A turn ends either when the prompt finishes
|
|
380
|
+
* or when a host tool call is handed to the harness; in the latter case the
|
|
381
|
+
* ACP prompt stays open until the harness returns the result on its next
|
|
382
|
+
* request, exactly like the CodeBuddy bridge.
|
|
383
|
+
*/
|
|
384
|
+
export declare class MinimaxSession {
|
|
385
|
+
readonly sessionId: string;
|
|
386
|
+
private readonly mcpServer;
|
|
387
|
+
private acp;
|
|
388
|
+
private readonly events;
|
|
389
|
+
private readonly bridge;
|
|
390
|
+
private readonly pending;
|
|
391
|
+
private readonly toolResultTimeoutMs;
|
|
392
|
+
private readonly abortGraceMs;
|
|
393
|
+
private readonly callNonce;
|
|
394
|
+
private toolCounter;
|
|
395
|
+
private promptInFlight;
|
|
396
|
+
private activeTurn;
|
|
397
|
+
private disposed;
|
|
398
|
+
private region;
|
|
399
|
+
private model;
|
|
400
|
+
private effort;
|
|
401
|
+
private systemPrompt;
|
|
402
|
+
private workspace;
|
|
403
|
+
/** The harness workspace; absent means the session owns a temp directory. */
|
|
404
|
+
private requestedCwd;
|
|
405
|
+
private ownsWorkspace;
|
|
406
|
+
private mcpToken;
|
|
407
|
+
private toolSchemas;
|
|
408
|
+
private nativeViolation;
|
|
409
|
+
private cancelSent;
|
|
410
|
+
private correctionCount;
|
|
411
|
+
private observedContextWindow;
|
|
412
|
+
/** Was the last turn closed with tool-calls, leaving the ACP prompt open? */
|
|
413
|
+
private awaitingToolResults;
|
|
414
|
+
/** Host messages already fed to the ACP session, for continuation planning. */
|
|
415
|
+
fedMessages: readonly RequestMessage[] | undefined;
|
|
416
|
+
/** Host system prompt last applied; informational for the adapter. */
|
|
417
|
+
fedSystem: string | undefined;
|
|
418
|
+
constructor(sessionId: string, initialModel: string, mcpServer: MinimaxMcpServer, runtime?: {
|
|
419
|
+
toolResultTimeoutMs?: Live<number>;
|
|
420
|
+
abortGraceMs?: Live<number>;
|
|
421
|
+
});
|
|
422
|
+
/** Model context window observed from a real turn, when one was reported. */
|
|
423
|
+
get contextWindow(): number | undefined;
|
|
424
|
+
/**
|
|
425
|
+
* Whether the ACP session still owns an unfinished turn.
|
|
426
|
+
*
|
|
427
|
+
* A turn closed with `tool-calls` keeps its prompt open while the host runs
|
|
428
|
+
* the tools, so this stays true between the two host requests. A brand-new
|
|
429
|
+
* user message in that state cannot be injected; the adapter rebuilds the
|
|
430
|
+
* session and feeds the whole history instead.
|
|
431
|
+
*/
|
|
432
|
+
get busy(): boolean;
|
|
433
|
+
/**
|
|
434
|
+
* Point the session at a region, model and system prompt.
|
|
435
|
+
*
|
|
436
|
+
* @returns true when the warm ACP process was dropped, which means the
|
|
437
|
+
* conversation state must be rebuilt from the durable history.
|
|
438
|
+
*/
|
|
439
|
+
configure(region: MinimaxRegion, model: string, options?: {
|
|
440
|
+
effort?: string;
|
|
441
|
+
system?: string;
|
|
442
|
+
cwd?: string;
|
|
443
|
+
}): boolean;
|
|
444
|
+
/** Register the host tools this session's MCP server advertises. */
|
|
445
|
+
ensureTools(tools: readonly {
|
|
446
|
+
name: string;
|
|
447
|
+
description: string;
|
|
448
|
+
parameters?: unknown;
|
|
449
|
+
}[]): void;
|
|
450
|
+
/** Hand the host's tool results to parked handlers. */
|
|
451
|
+
deliverToolResults(tail: readonly {
|
|
452
|
+
role: string;
|
|
453
|
+
toolCallId?: unknown;
|
|
454
|
+
content?: unknown;
|
|
455
|
+
isError?: boolean;
|
|
456
|
+
}[]): void;
|
|
457
|
+
/** Run one harness turn. `feed` is new user text, or null for a continuation. */
|
|
458
|
+
stream(options: GenerateOptions, feed: string | null): AsyncGenerator<StreamChunk>;
|
|
459
|
+
/** Tear the ACP process down; parked handlers settle with a cancellation. */
|
|
460
|
+
close(): void;
|
|
461
|
+
private ensureStarted;
|
|
462
|
+
private startPrompt;
|
|
463
|
+
/**
|
|
464
|
+
* Start one ACP prompt and publish its outcome.
|
|
465
|
+
*
|
|
466
|
+
* Cancelling a turn makes the next `session/prompt` fail with "Session
|
|
467
|
+
* already has an active Turn" for a short while even though the cancelled
|
|
468
|
+
* prompt has already resolved. That race is routine here: the native-tool
|
|
469
|
+
* correction is sent immediately after such a cancel, so it is retried with
|
|
470
|
+
* a short backoff instead of being reported as a failed turn.
|
|
471
|
+
*/
|
|
472
|
+
private launchPrompt;
|
|
473
|
+
private dropAcp;
|
|
474
|
+
private handleToolCall;
|
|
475
|
+
private finish;
|
|
476
|
+
}
|
|
477
|
+
/** Warm session pool, keyed by harness session id. */
|
|
478
|
+
export declare class MinimaxSessionManager {
|
|
479
|
+
readonly maxSessions: Live<number>;
|
|
480
|
+
private readonly mcpServer;
|
|
481
|
+
private readonly runtime;
|
|
482
|
+
private readonly sessions;
|
|
483
|
+
constructor(maxSessions: Live<number>, mcpServer: MinimaxMcpServer, runtime?: {
|
|
484
|
+
toolResultTimeoutMs?: Live<number>;
|
|
485
|
+
abortGraceMs?: Live<number>;
|
|
486
|
+
});
|
|
487
|
+
forSession(sessionId: string, region: MinimaxRegion, model: string): MinimaxSession;
|
|
488
|
+
dispose(sessionId: string): void;
|
|
489
|
+
closeAll(): void;
|
|
490
|
+
}
|
|
491
|
+
/** A one-shot turn, used for titles and compaction summaries. */
|
|
492
|
+
export declare function minimaxColdStream(region: MinimaxRegion, prompt: string, model: string | undefined, options: GenerateOptions): Promise<StreamChunk[]>;
|
|
493
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-agent-sdk-bridge",
|
|
3
3
|
"displayName": "Agent SDK Bridge",
|
|
4
|
-
"description": "DeepSeek Harness LLM adapter bridge for Qoder CN, Qoder International
|
|
5
|
-
"version": "1.
|
|
4
|
+
"description": "DeepSeek Harness LLM adapter bridge for Qoder CN, Qoder International, Tencent CodeBuddy and MiniMax Code subscriptions. It reuses each provider's own SDK or official ACP server and CLI login, shows available quota, and exposes per-provider settings pages with independent international and mainland login regions.",
|
|
5
|
+
"version": "1.1.0",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"license": "MIT",
|
|
8
8
|
"author": "k1-h2",
|
|
@@ -17,6 +17,10 @@
|
|
|
17
17
|
"qoder-international",
|
|
18
18
|
"codebuddy",
|
|
19
19
|
"codebuddy-code",
|
|
20
|
+
"minimax",
|
|
21
|
+
"minimax-code",
|
|
22
|
+
"acp",
|
|
23
|
+
"agent-client-protocol",
|
|
20
24
|
"quota",
|
|
21
25
|
"model-provider",
|
|
22
26
|
"agent-sdk"
|
|
@@ -80,6 +84,7 @@
|
|
|
80
84
|
"@deepseek-ai/schemastery": "^3.18.1"
|
|
81
85
|
},
|
|
82
86
|
"dependencies": {
|
|
87
|
+
"@agentclientprotocol/sdk": "^1.9.0",
|
|
83
88
|
"@qoder-ai/qoder-agent-sdk": "^1.0.56",
|
|
84
89
|
"@qodercn-ai/qodercn-agent-sdk": "^1.0.51",
|
|
85
90
|
"@tencent-ai/agent-sdk": "^0.3.289",
|