@aipanel/provider-deepseek 1.2.13 → 1.2.14
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/es/api.d.ts +7 -0
- package/es/api.js +34 -2
- package/es/profile.d.ts +2 -0
- package/es/profile.js +3 -2
- package/es/provider.js +3 -2
- package/lib/api.cjs +34 -2
- package/lib/api.d.ts +7 -0
- package/lib/profile.cjs +3 -2
- package/lib/profile.d.ts +2 -0
- package/lib/provider.cjs +3 -2
- package/package.json +2 -2
package/es/api.d.ts
CHANGED
|
@@ -11,6 +11,11 @@ export declare class DeepSeekAPI {
|
|
|
11
11
|
private launchToken?;
|
|
12
12
|
/** 启动早期等待 token 就绪的源(dsh 进程 stdout 的 LaunchToken.wait),未就绪时勿立即抛错 */
|
|
13
13
|
private launchTokenSource?;
|
|
14
|
+
/** provider 尚未调用 setLaunchTokenSource 时,等待该源就绪的信号(避免早到请求立即误报) */
|
|
15
|
+
private sourceReadyPromise?;
|
|
16
|
+
private resolveSourceReady?;
|
|
17
|
+
/** 兜底:来源迟迟未绑定时不无限挂起 */
|
|
18
|
+
private static readonly SOURCE_WAIT_TIMEOUT_MS;
|
|
14
19
|
/** browser-session 签名 Cookie(经 launch token 换取),dsh web 所有 /api 请求必须携带 */
|
|
15
20
|
private authCookie?;
|
|
16
21
|
/** 认证引导的幂等 Promise,避免并发多次换取 */
|
|
@@ -25,6 +30,8 @@ export declare class DeepSeekAPI {
|
|
|
25
30
|
* 启动早期 widget 可能在 token 捕获前就发起 /api 请求,此时先等待 token 就绪而非抛错。
|
|
26
31
|
*/
|
|
27
32
|
setLaunchTokenSource(source: () => Promise<string>): void;
|
|
33
|
+
/** 等待 launchTokenSource 就绪(首次调用惰性创建信号);配合 ensureAuthenticated 避免早到请求误报 */
|
|
34
|
+
private waitForSourceReady;
|
|
28
35
|
/** 当前 browser-session Cookie(未认证时 undefined);供代理向转发请求注入同一 Cookie */
|
|
29
36
|
getAuthCookie(): string | undefined;
|
|
30
37
|
/**
|
package/es/api.js
CHANGED
|
@@ -7,7 +7,7 @@ import { DEFAULT_RETRIES, withRetries } from "@aipanel/core";
|
|
|
7
7
|
import { PerformanceTimer, createLogger } from "@aipanel/core/node";
|
|
8
8
|
import { DSH_API_BASE, DSH_REMOTE_MUX_PATH } from "./constants.js";
|
|
9
9
|
const log = createLogger("DeepSeekAPI");
|
|
10
|
-
class
|
|
10
|
+
const _DeepSeekAPI = class _DeepSeekAPI {
|
|
11
11
|
constructor(hostname, getWebPort) {
|
|
12
12
|
__publicField(this, "hostname", hostname);
|
|
13
13
|
__publicField(this, "getWebPort", getWebPort);
|
|
@@ -15,6 +15,9 @@ class DeepSeekAPI {
|
|
|
15
15
|
__publicField(this, "launchToken");
|
|
16
16
|
/** 启动早期等待 token 就绪的源(dsh 进程 stdout 的 LaunchToken.wait),未就绪时勿立即抛错 */
|
|
17
17
|
__publicField(this, "launchTokenSource");
|
|
18
|
+
/** provider 尚未调用 setLaunchTokenSource 时,等待该源就绪的信号(避免早到请求立即误报) */
|
|
19
|
+
__publicField(this, "sourceReadyPromise");
|
|
20
|
+
__publicField(this, "resolveSourceReady");
|
|
18
21
|
/** browser-session 签名 Cookie(经 launch token 换取),dsh web 所有 /api 请求必须携带 */
|
|
19
22
|
__publicField(this, "authCookie");
|
|
20
23
|
/** 认证引导的幂等 Promise,避免并发多次换取 */
|
|
@@ -34,6 +37,16 @@ class DeepSeekAPI {
|
|
|
34
37
|
*/
|
|
35
38
|
setLaunchTokenSource(source) {
|
|
36
39
|
this.launchTokenSource = source;
|
|
40
|
+
this.resolveSourceReady?.();
|
|
41
|
+
}
|
|
42
|
+
/** 等待 launchTokenSource 就绪(首次调用惰性创建信号);配合 ensureAuthenticated 避免早到请求误报 */
|
|
43
|
+
waitForSourceReady() {
|
|
44
|
+
if (!this.sourceReadyPromise) {
|
|
45
|
+
this.sourceReadyPromise = new Promise((resolve) => {
|
|
46
|
+
this.resolveSourceReady = resolve;
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
return this.sourceReadyPromise;
|
|
37
50
|
}
|
|
38
51
|
/** 当前 browser-session Cookie(未认证时 undefined);供代理向转发请求注入同一 Cookie */
|
|
39
52
|
getAuthCookie() {
|
|
@@ -100,6 +113,22 @@ class DeepSeekAPI {
|
|
|
100
113
|
async ensureAuthenticated() {
|
|
101
114
|
if (this.authCookie) return;
|
|
102
115
|
if (!this.launchToken) {
|
|
116
|
+
if (!this.launchTokenSource) {
|
|
117
|
+
let timer;
|
|
118
|
+
try {
|
|
119
|
+
await Promise.race([
|
|
120
|
+
this.waitForSourceReady(),
|
|
121
|
+
new Promise((_, reject) => {
|
|
122
|
+
timer = setTimeout(
|
|
123
|
+
() => reject(new Error("dsh launch token source was not bound in time")),
|
|
124
|
+
_DeepSeekAPI.SOURCE_WAIT_TIMEOUT_MS
|
|
125
|
+
);
|
|
126
|
+
})
|
|
127
|
+
]);
|
|
128
|
+
} finally {
|
|
129
|
+
clearTimeout(timer);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
103
132
|
if (this.launchTokenSource) {
|
|
104
133
|
this.launchToken = await this.launchTokenSource();
|
|
105
134
|
}
|
|
@@ -328,7 +357,10 @@ class DeepSeekAPI {
|
|
|
328
357
|
req.end();
|
|
329
358
|
});
|
|
330
359
|
}
|
|
331
|
-
}
|
|
360
|
+
};
|
|
361
|
+
/** 兜底:来源迟迟未绑定时不无限挂起 */
|
|
362
|
+
__publicField(_DeepSeekAPI, "SOURCE_WAIT_TIMEOUT_MS", 2e4);
|
|
363
|
+
let DeepSeekAPI = _DeepSeekAPI;
|
|
332
364
|
export {
|
|
333
365
|
DeepSeekAPI
|
|
334
366
|
};
|
package/es/profile.d.ts
CHANGED
|
@@ -3,6 +3,8 @@ import type { DeepSeekBusyEnter, DeepSeekPermissionPreset } from "./types";
|
|
|
3
3
|
/** 组装 overlay YAML */
|
|
4
4
|
export declare function buildDshOverlay(options: {
|
|
5
5
|
vitePort: number;
|
|
6
|
+
/** vite 绑定 host(单一来源,核心层归一化):dsh 引擎回连 vite 端点用之;区别于 dsh 自身绑定的 DSH_LOOPBACK_HOST */
|
|
7
|
+
viteHost: string;
|
|
6
8
|
cwd: string;
|
|
7
9
|
/** host 插件(@aipanel/dsh-plugin)是否已同步到 dsh profile;false 时停用该行,避免 fail-loud */
|
|
8
10
|
pluginAvailable?: boolean;
|
package/es/profile.js
CHANGED
|
@@ -7,12 +7,12 @@ import {
|
|
|
7
7
|
HOST_EVENTS_API_PATH,
|
|
8
8
|
createLogger
|
|
9
9
|
} from "@aipanel/core/node";
|
|
10
|
-
import { DSH_LOOPBACK_HOST } from "./constants.js";
|
|
11
10
|
import { DSH_CLIENT_PACKAGE, DSH_PLUGIN_PACKAGE } from "./dsh-install.js";
|
|
12
11
|
const log = createLogger("DeepSeekProfile");
|
|
13
12
|
function buildDshOverlay(options) {
|
|
14
13
|
const {
|
|
15
14
|
vitePort,
|
|
15
|
+
viteHost,
|
|
16
16
|
cwd,
|
|
17
17
|
pluginAvailable = true,
|
|
18
18
|
clientAvailable = true,
|
|
@@ -24,7 +24,7 @@ function buildDshOverlay(options) {
|
|
|
24
24
|
busyEnter,
|
|
25
25
|
theme = "auto"
|
|
26
26
|
} = options;
|
|
27
|
-
const mcpUrl = `http://${
|
|
27
|
+
const mcpUrl = `http://${viteHost}:${vitePort}${MCP_API_PATH}`;
|
|
28
28
|
const rows = [];
|
|
29
29
|
rows.push(
|
|
30
30
|
[
|
|
@@ -46,6 +46,7 @@ function buildDshOverlay(options) {
|
|
|
46
46
|
" config:",
|
|
47
47
|
` cwd: ${JSON.stringify(cwd)}`,
|
|
48
48
|
` vitePort: ${vitePort}`,
|
|
49
|
+
` viteHost: ${JSON.stringify(viteHost)}`,
|
|
49
50
|
` contextApiPath: ${JSON.stringify(CONTEXT_API_PATH)}`,
|
|
50
51
|
` enableDiagnostics: ${enableDiagnostics ? "true" : "false"}`,
|
|
51
52
|
...autoDiagnose !== void 0 ? [` autoDiagnose: ${autoDiagnose ? "true" : "false"}`] : [],
|
package/es/provider.js
CHANGED
|
@@ -83,6 +83,8 @@ Please upgrade:
|
|
|
83
83
|
vitePort: options.vitePort
|
|
84
84
|
});
|
|
85
85
|
const profileDir = dshProfileDir(this.opts.home);
|
|
86
|
+
const launchToken = new LaunchToken();
|
|
87
|
+
this.api.setLaunchTokenSource(() => launchToken.wait());
|
|
86
88
|
const devClientDir = resolveDevDshPackageSource(import.meta.url, "dsh-client", "lib/client.js");
|
|
87
89
|
const clientAvailable = await ensureDshPackage(
|
|
88
90
|
profileDir,
|
|
@@ -109,6 +111,7 @@ Please upgrade:
|
|
|
109
111
|
}
|
|
110
112
|
const overlay = buildDshOverlay({
|
|
111
113
|
vitePort: options.vitePort,
|
|
114
|
+
viteHost: options.viteHost,
|
|
112
115
|
cwd: options.cwd,
|
|
113
116
|
pluginAvailable,
|
|
114
117
|
clientAvailable,
|
|
@@ -122,8 +125,6 @@ Please upgrade:
|
|
|
122
125
|
theme: this.uiTheme
|
|
123
126
|
});
|
|
124
127
|
const patchPath = writeDshOverlay(options.cwd, overlay);
|
|
125
|
-
const launchToken = new LaunchToken();
|
|
126
|
-
this.api.setLaunchTokenSource(() => launchToken.wait());
|
|
127
128
|
const proc = startDeepSeekWeb({
|
|
128
129
|
port: options.port,
|
|
129
130
|
hostname: DSH_LOOPBACK_HOST,
|
package/lib/api.cjs
CHANGED
|
@@ -38,7 +38,7 @@ var import_core = require("@aipanel/core");
|
|
|
38
38
|
var import_node = require("@aipanel/core/node");
|
|
39
39
|
var import_constants = require("./constants.cjs");
|
|
40
40
|
const log = (0, import_node.createLogger)("DeepSeekAPI");
|
|
41
|
-
class
|
|
41
|
+
const _DeepSeekAPI = class _DeepSeekAPI {
|
|
42
42
|
constructor(hostname, getWebPort) {
|
|
43
43
|
__publicField(this, "hostname", hostname);
|
|
44
44
|
__publicField(this, "getWebPort", getWebPort);
|
|
@@ -46,6 +46,9 @@ class DeepSeekAPI {
|
|
|
46
46
|
__publicField(this, "launchToken");
|
|
47
47
|
/** 启动早期等待 token 就绪的源(dsh 进程 stdout 的 LaunchToken.wait),未就绪时勿立即抛错 */
|
|
48
48
|
__publicField(this, "launchTokenSource");
|
|
49
|
+
/** provider 尚未调用 setLaunchTokenSource 时,等待该源就绪的信号(避免早到请求立即误报) */
|
|
50
|
+
__publicField(this, "sourceReadyPromise");
|
|
51
|
+
__publicField(this, "resolveSourceReady");
|
|
49
52
|
/** browser-session 签名 Cookie(经 launch token 换取),dsh web 所有 /api 请求必须携带 */
|
|
50
53
|
__publicField(this, "authCookie");
|
|
51
54
|
/** 认证引导的幂等 Promise,避免并发多次换取 */
|
|
@@ -65,6 +68,16 @@ class DeepSeekAPI {
|
|
|
65
68
|
*/
|
|
66
69
|
setLaunchTokenSource(source) {
|
|
67
70
|
this.launchTokenSource = source;
|
|
71
|
+
this.resolveSourceReady?.();
|
|
72
|
+
}
|
|
73
|
+
/** 等待 launchTokenSource 就绪(首次调用惰性创建信号);配合 ensureAuthenticated 避免早到请求误报 */
|
|
74
|
+
waitForSourceReady() {
|
|
75
|
+
if (!this.sourceReadyPromise) {
|
|
76
|
+
this.sourceReadyPromise = new Promise((resolve) => {
|
|
77
|
+
this.resolveSourceReady = resolve;
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
return this.sourceReadyPromise;
|
|
68
81
|
}
|
|
69
82
|
/** 当前 browser-session Cookie(未认证时 undefined);供代理向转发请求注入同一 Cookie */
|
|
70
83
|
getAuthCookie() {
|
|
@@ -131,6 +144,22 @@ class DeepSeekAPI {
|
|
|
131
144
|
async ensureAuthenticated() {
|
|
132
145
|
if (this.authCookie) return;
|
|
133
146
|
if (!this.launchToken) {
|
|
147
|
+
if (!this.launchTokenSource) {
|
|
148
|
+
let timer;
|
|
149
|
+
try {
|
|
150
|
+
await Promise.race([
|
|
151
|
+
this.waitForSourceReady(),
|
|
152
|
+
new Promise((_, reject) => {
|
|
153
|
+
timer = setTimeout(
|
|
154
|
+
() => reject(new Error("dsh launch token source was not bound in time")),
|
|
155
|
+
_DeepSeekAPI.SOURCE_WAIT_TIMEOUT_MS
|
|
156
|
+
);
|
|
157
|
+
})
|
|
158
|
+
]);
|
|
159
|
+
} finally {
|
|
160
|
+
clearTimeout(timer);
|
|
161
|
+
}
|
|
162
|
+
}
|
|
134
163
|
if (this.launchTokenSource) {
|
|
135
164
|
this.launchToken = await this.launchTokenSource();
|
|
136
165
|
}
|
|
@@ -359,7 +388,10 @@ class DeepSeekAPI {
|
|
|
359
388
|
req.end();
|
|
360
389
|
});
|
|
361
390
|
}
|
|
362
|
-
}
|
|
391
|
+
};
|
|
392
|
+
/** 兜底:来源迟迟未绑定时不无限挂起 */
|
|
393
|
+
__publicField(_DeepSeekAPI, "SOURCE_WAIT_TIMEOUT_MS", 2e4);
|
|
394
|
+
let DeepSeekAPI = _DeepSeekAPI;
|
|
363
395
|
// Annotate the CommonJS export names for ESM import in node:
|
|
364
396
|
0 && (module.exports = {
|
|
365
397
|
DeepSeekAPI
|
package/lib/api.d.ts
CHANGED
|
@@ -11,6 +11,11 @@ export declare class DeepSeekAPI {
|
|
|
11
11
|
private launchToken?;
|
|
12
12
|
/** 启动早期等待 token 就绪的源(dsh 进程 stdout 的 LaunchToken.wait),未就绪时勿立即抛错 */
|
|
13
13
|
private launchTokenSource?;
|
|
14
|
+
/** provider 尚未调用 setLaunchTokenSource 时,等待该源就绪的信号(避免早到请求立即误报) */
|
|
15
|
+
private sourceReadyPromise?;
|
|
16
|
+
private resolveSourceReady?;
|
|
17
|
+
/** 兜底:来源迟迟未绑定时不无限挂起 */
|
|
18
|
+
private static readonly SOURCE_WAIT_TIMEOUT_MS;
|
|
14
19
|
/** browser-session 签名 Cookie(经 launch token 换取),dsh web 所有 /api 请求必须携带 */
|
|
15
20
|
private authCookie?;
|
|
16
21
|
/** 认证引导的幂等 Promise,避免并发多次换取 */
|
|
@@ -25,6 +30,8 @@ export declare class DeepSeekAPI {
|
|
|
25
30
|
* 启动早期 widget 可能在 token 捕获前就发起 /api 请求,此时先等待 token 就绪而非抛错。
|
|
26
31
|
*/
|
|
27
32
|
setLaunchTokenSource(source: () => Promise<string>): void;
|
|
33
|
+
/** 等待 launchTokenSource 就绪(首次调用惰性创建信号);配合 ensureAuthenticated 避免早到请求误报 */
|
|
34
|
+
private waitForSourceReady;
|
|
28
35
|
/** 当前 browser-session Cookie(未认证时 undefined);供代理向转发请求注入同一 Cookie */
|
|
29
36
|
getAuthCookie(): string | undefined;
|
|
30
37
|
/**
|
package/lib/profile.cjs
CHANGED
|
@@ -34,12 +34,12 @@ module.exports = __toCommonJS(profile_exports);
|
|
|
34
34
|
var import_fs = __toESM(require("fs"));
|
|
35
35
|
var import_path = __toESM(require("path"));
|
|
36
36
|
var import_node = require("@aipanel/core/node");
|
|
37
|
-
var import_constants = require("./constants.cjs");
|
|
38
37
|
var import_dsh_install = require("./dsh-install.cjs");
|
|
39
38
|
const log = (0, import_node.createLogger)("DeepSeekProfile");
|
|
40
39
|
function buildDshOverlay(options) {
|
|
41
40
|
const {
|
|
42
41
|
vitePort,
|
|
42
|
+
viteHost,
|
|
43
43
|
cwd,
|
|
44
44
|
pluginAvailable = true,
|
|
45
45
|
clientAvailable = true,
|
|
@@ -51,7 +51,7 @@ function buildDshOverlay(options) {
|
|
|
51
51
|
busyEnter,
|
|
52
52
|
theme = "auto"
|
|
53
53
|
} = options;
|
|
54
|
-
const mcpUrl = `http://${
|
|
54
|
+
const mcpUrl = `http://${viteHost}:${vitePort}${import_node.MCP_API_PATH}`;
|
|
55
55
|
const rows = [];
|
|
56
56
|
rows.push(
|
|
57
57
|
[
|
|
@@ -73,6 +73,7 @@ function buildDshOverlay(options) {
|
|
|
73
73
|
" config:",
|
|
74
74
|
` cwd: ${JSON.stringify(cwd)}`,
|
|
75
75
|
` vitePort: ${vitePort}`,
|
|
76
|
+
` viteHost: ${JSON.stringify(viteHost)}`,
|
|
76
77
|
` contextApiPath: ${JSON.stringify(import_node.CONTEXT_API_PATH)}`,
|
|
77
78
|
` enableDiagnostics: ${enableDiagnostics ? "true" : "false"}`,
|
|
78
79
|
...autoDiagnose !== void 0 ? [` autoDiagnose: ${autoDiagnose ? "true" : "false"}`] : [],
|
package/lib/profile.d.ts
CHANGED
|
@@ -3,6 +3,8 @@ import type { DeepSeekBusyEnter, DeepSeekPermissionPreset } from "./types";
|
|
|
3
3
|
/** 组装 overlay YAML */
|
|
4
4
|
export declare function buildDshOverlay(options: {
|
|
5
5
|
vitePort: number;
|
|
6
|
+
/** vite 绑定 host(单一来源,核心层归一化):dsh 引擎回连 vite 端点用之;区别于 dsh 自身绑定的 DSH_LOOPBACK_HOST */
|
|
7
|
+
viteHost: string;
|
|
6
8
|
cwd: string;
|
|
7
9
|
/** host 插件(@aipanel/dsh-plugin)是否已同步到 dsh profile;false 时停用该行,避免 fail-loud */
|
|
8
10
|
pluginAvailable?: boolean;
|
package/lib/provider.cjs
CHANGED
|
@@ -93,6 +93,8 @@ Please upgrade:
|
|
|
93
93
|
vitePort: options.vitePort
|
|
94
94
|
});
|
|
95
95
|
const profileDir = (0, import_dsh_install.dshProfileDir)(this.opts.home);
|
|
96
|
+
const launchToken = new import_deepseek_web.LaunchToken();
|
|
97
|
+
this.api.setLaunchTokenSource(() => launchToken.wait());
|
|
96
98
|
const devClientDir = (0, import_dsh_install.resolveDevDshPackageSource)(import_meta.url, "dsh-client", "lib/client.js");
|
|
97
99
|
const clientAvailable = await (0, import_dsh_install.ensureDshPackage)(
|
|
98
100
|
profileDir,
|
|
@@ -119,6 +121,7 @@ Please upgrade:
|
|
|
119
121
|
}
|
|
120
122
|
const overlay = (0, import_profile.buildDshOverlay)({
|
|
121
123
|
vitePort: options.vitePort,
|
|
124
|
+
viteHost: options.viteHost,
|
|
122
125
|
cwd: options.cwd,
|
|
123
126
|
pluginAvailable,
|
|
124
127
|
clientAvailable,
|
|
@@ -132,8 +135,6 @@ Please upgrade:
|
|
|
132
135
|
theme: this.uiTheme
|
|
133
136
|
});
|
|
134
137
|
const patchPath = (0, import_profile.writeDshOverlay)(options.cwd, overlay);
|
|
135
|
-
const launchToken = new import_deepseek_web.LaunchToken();
|
|
136
|
-
this.api.setLaunchTokenSource(() => launchToken.wait());
|
|
137
138
|
const proc = (0, import_deepseek_web.startDeepSeekWeb)({
|
|
138
139
|
port: options.port,
|
|
139
140
|
hostname: import_constants2.DSH_LOOPBACK_HOST,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aipanel/provider-deepseek",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.14",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "lib/index.cjs",
|
|
6
6
|
"module": "es/index.js",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
24
|
"execa": "^9.6.1",
|
|
25
|
-
"@aipanel/core": "1.2.
|
|
25
|
+
"@aipanel/core": "1.2.14"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
28
|
"esbuild": "^0.25.0"
|