dsh-workbuddy-connect 0.2.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/LICENSE +21 -0
- package/README.en.md +58 -0
- package/README.md +64 -0
- package/cordis.patch.yml +6 -0
- package/lib/bin.d.ts +6 -0
- package/lib/bin.js +167 -0
- package/lib/client.js +439 -0
- package/lib/host-heartbeat-DehQgrb9.js +830 -0
- package/lib/index.d.ts +332 -0
- package/lib/index.js +556 -0
- package/package.json +102 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Corrine Hu
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.en.md
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
# DSH WorkBuddy Connect
|
|
2
|
+
|
|
3
|
+
English | [中文](./README.md)
|
|
4
|
+
|
|
5
|
+
Brings every model in the WorkBuddy desktop app (GLM-5.3, GLM-5.2, DeepSeek-V4-Pro, DeepSeek-V4-Flash, Kimi-K3, MiniMax-M3, Hy3, and more) straight into [DeepSeek Harness](https://github.com/deepseek-ai/deepseek-harness) — zero configuration in the DSH chat.
|
|
6
|
+
|
|
7
|
+
## Features
|
|
8
|
+
|
|
9
|
+
- **Works out of the box**: install and enable the plugin, then use it directly in DSH — no extra configuration.
|
|
10
|
+
|
|
11
|
+

|
|
12
|
+
|
|
13
|
+
- **Info at a glance**: Settings → Plugins → DSH WorkBuddy Connect card
|
|
14
|
+
|
|
15
|
+

|
|
16
|
+
|
|
17
|
+
Expand the card to see the account, token validity, and remaining credit.
|
|
18
|
+
|
|
19
|
+

|
|
20
|
+
|
|
21
|
+
## Install
|
|
22
|
+
|
|
23
|
+
Prerequisite: the WorkBuddy desktop app is installed and signed in (the plugin reuses the app's sign-in state and follows account switches automatically).
|
|
24
|
+
|
|
25
|
+
```sh
|
|
26
|
+
# npm (recommended; ships prebuilt artifacts)
|
|
27
|
+
dsh plugin --profile web add dsh-workbuddy-connect
|
|
28
|
+
|
|
29
|
+
# or install from the GitHub source
|
|
30
|
+
dsh plugin --profile web add github:corrinehu/dsh-workbuddy-connect
|
|
31
|
+
|
|
32
|
+
dsh web
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## CLI
|
|
36
|
+
|
|
37
|
+
`dsh plugin --profile web exec dsh-workbuddy-connect status`: sign-in state and remaining credit (`--json` for machine-readable output; `doctor` for diagnostics and `logout` for credential cleanup are also available).
|
|
38
|
+
|
|
39
|
+
## Known limitations
|
|
40
|
+
|
|
41
|
+
- Verified on macOS with the DSH Web profile (`0.1.1-rc.2`+, Node 22+). The default credential paths on Windows / Linux are unverified — point the `WORKBUDDY_AUTH_FILE` environment variable at the actual location if needed.
|
|
42
|
+
- Relies on WorkBuddy client interfaces (not a public API); the plugin may need updates as WorkBuddy changes.
|
|
43
|
+
|
|
44
|
+
## Disclaimer
|
|
45
|
+
|
|
46
|
+
- This project is for **personal learning and research only**, driving your own WorkBuddy account on your own machine. Do not use it commercially or beyond reasonable personal use.
|
|
47
|
+
- Users must comply with the WorkBuddy terms of service. Any consequence of using this project (including but not limited to account restrictions, depleted credit, or service interruption) is borne by the user.
|
|
48
|
+
- The author is not liable for any direct or indirect loss arising from the use or misuse of this project.
|
|
49
|
+
- This project is not affiliated with, endorsed by, or sponsored by Tencent, WorkBuddy, or DeepSeek. Product names are used for compatibility description only; trademarks belong to their respective owners.
|
|
50
|
+
|
|
51
|
+
## Acknowledgements
|
|
52
|
+
|
|
53
|
+
- [Sliverkiss/workbuddy2api](https://github.com/Sliverkiss/workbuddy2api) (MIT) — reference implementation of the WorkBuddy upstream protocol.
|
|
54
|
+
- [franksong2702/dsh-codex-connect](https://github.com/franksong2702/dsh-codex-connect) (Apache-2.0) — reference for the DSH plugin structure and provider registration.
|
|
55
|
+
|
|
56
|
+
## License
|
|
57
|
+
|
|
58
|
+
[MIT](./LICENSE)
|
package/README.md
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
# DSH WorkBuddy Connect
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
[English](./README.en.md) | 中文
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
将 WorkBuddy 桌面 App 中包含的各种模型(GLM-5.3、GLM-5.2、DeepSeek-V4-Pro、DeepSeek-V4-Flash、Kimi-K3、MiniMax-M3 、Hy3等)自动接入 DeepSeek Harness,实现在 DSH 对话窗口里零配置使用。
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
## 功能
|
|
11
|
+
|
|
12
|
+
- **开箱即用**:安装和启用插件后,在 DSH 中直接使用,无需额外配置。
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+

|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
- **信息查看**:设置 → 插件 → DSH WorkBuddy Connect 卡片
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+

|
|
22
|
+
|
|
23
|
+
卡片展开后,可查看账号信息、令牌有效期与剩余积分。
|
|
24
|
+
|
|
25
|
+

|
|
26
|
+
|
|
27
|
+
## 安装
|
|
28
|
+
|
|
29
|
+
前置:已安装并登录 WorkBuddy 桌面 App(插件复用 App 的登录状态,账号切换自动跟随)。
|
|
30
|
+
|
|
31
|
+
```sh
|
|
32
|
+
# npm(推荐,自带预构建产物)
|
|
33
|
+
dsh plugin --profile web add dsh-workbuddy-connect
|
|
34
|
+
|
|
35
|
+
# 或从 GitHub 源码安装
|
|
36
|
+
dsh plugin --profile web add github:corrinehu/dsh-workbuddy-connect
|
|
37
|
+
|
|
38
|
+
dsh web
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## 命令行
|
|
42
|
+
|
|
43
|
+
`dsh plugin --profile web exec dsh-workbuddy-connect status`:登录状态与剩余积分(`--json` 输出机器可读格式;另有 `doctor` 诊断、`logout` 清理凭据)。
|
|
44
|
+
|
|
45
|
+
## 已知限制
|
|
46
|
+
|
|
47
|
+
- 在 macOS 与 DSH Web profile(`0.1.1-rc.2`+、Node 22+)下验证通过;Windows / Linux 的凭据默认路径未经验证,必要时可通过环境变量 `WORKBUDDY_AUTH_FILE` 指定实际位置。
|
|
48
|
+
- 依赖 WorkBuddy 客户端接口(非官方开放 API),WorkBuddy 更新后插件可能需要随之调整。
|
|
49
|
+
|
|
50
|
+
## 免责声明
|
|
51
|
+
|
|
52
|
+
- 本项目**仅供个人学习和研究使用**,仅驱动使用者自己的 WorkBuddy 账号在本机调用,请勿用于商业用途或超出个人合理使用的场景。
|
|
53
|
+
- 使用者需遵守 WorkBuddy 的服务条款;因使用本项目产生的任何后果(包括但不限于账号被限制、额度被清空、服务中断),由使用者自行承担。
|
|
54
|
+
- 本项目作者不对任何因使用或滥用本项目产生的直接或间接损失负责。
|
|
55
|
+
- 本项目与腾讯、WorkBuddy、DeepSeek 均无关联,未获其授权或认可;文中出现的名称仅用于描述兼容关系,其商标权利归各自所有。
|
|
56
|
+
|
|
57
|
+
## 致谢
|
|
58
|
+
|
|
59
|
+
- [Sliverkiss/workbuddy2api](https://github.com/Sliverkiss/workbuddy2api)(MIT)— WorkBuddy 上游协议的参照实现。
|
|
60
|
+
- [franksong2702/dsh-codex-connect](https://github.com/franksong2702/dsh-codex-connect)(Apache-2.0)— DSH 插件结构与 provider 注册的参照。
|
|
61
|
+
|
|
62
|
+
## 许可证
|
|
63
|
+
|
|
64
|
+
[MIT](./LICENSE)
|
package/cordis.patch.yml
ADDED
package/lib/bin.d.ts
ADDED
package/lib/bin.js
ADDED
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { _ as WorkBuddyCredentialStore, a as readHostHeartbeat, b as workbuddyOwnAuthPath, c as WORKBUDDY_CONNECT_VERSION, l as WorkBuddyUpstreamClient, o as workbuddyHostHeartbeatPath, p as FALLBACK_WORKBUDDY_MODELS, r as isHeartbeatProcessAlive } from "./host-heartbeat-DehQgrb9.js";
|
|
3
|
+
import { realpathSync } from "node:fs";
|
|
4
|
+
import { fileURLToPath } from "node:url";
|
|
5
|
+
//#region src/bin.ts
|
|
6
|
+
/** Standalone status/diagnostics CLI for the dsh-workbuddy-connect bundle. */
|
|
7
|
+
const JSON_SCHEMA_VERSION = 1;
|
|
8
|
+
/** Remove token-like strings from an unexpected diagnostic message. */
|
|
9
|
+
function safeMessage(error) {
|
|
10
|
+
return (error instanceof Error ? error.message : String(error)).replace(/\beyJ[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+\b/gu, "[redacted token]").replace(/(\b(?:code|token|refresh_token|access_token)=)[^&\s]+/giu, "$1[redacted]");
|
|
11
|
+
}
|
|
12
|
+
function printHelp() {
|
|
13
|
+
process.stdout.write([
|
|
14
|
+
"Usage: dsh-workbuddy-connect <doctor|status|logout> [--json]",
|
|
15
|
+
"",
|
|
16
|
+
" doctor secret-free sign-in and environment diagnostics",
|
|
17
|
+
" status sign-in state, remaining WorkBuddy credit, and host-bundle health",
|
|
18
|
+
" logout remove the plugin-owned credential copy (the desktop app keeps its sign-in)",
|
|
19
|
+
" --json emit one secret-free JSON document (doctor/status only)",
|
|
20
|
+
""
|
|
21
|
+
].join("\n"));
|
|
22
|
+
}
|
|
23
|
+
function printJson(value) {
|
|
24
|
+
process.stdout.write(`${JSON.stringify(value)}\n`);
|
|
25
|
+
}
|
|
26
|
+
function makeStore() {
|
|
27
|
+
const client = new WorkBuddyUpstreamClient();
|
|
28
|
+
return new WorkBuddyCredentialStore({ refresh: (credential) => client.refreshToken(credential) });
|
|
29
|
+
}
|
|
30
|
+
async function doctor(jsonOutput) {
|
|
31
|
+
const store = makeStore();
|
|
32
|
+
const status = await store.status();
|
|
33
|
+
const desktopPresent = await store.desktopFilePresent();
|
|
34
|
+
const heartbeat = await readHostHeartbeat();
|
|
35
|
+
const hostAlive = heartbeat !== void 0 && isHeartbeatProcessAlive(heartbeat);
|
|
36
|
+
const report = {
|
|
37
|
+
schemaVersion: JSON_SCHEMA_VERSION,
|
|
38
|
+
package: "dsh-workbuddy-connect",
|
|
39
|
+
version: WORKBUDDY_CONNECT_VERSION,
|
|
40
|
+
node: process.version,
|
|
41
|
+
desktopAuthFile: {
|
|
42
|
+
path: store.desktopAuthPath() ?? "(no platform default; set WORKBUDDY_AUTH_FILE)",
|
|
43
|
+
present: desktopPresent
|
|
44
|
+
},
|
|
45
|
+
ownAuthFile: workbuddyOwnAuthPath(),
|
|
46
|
+
hostHeartbeat: {
|
|
47
|
+
path: workbuddyHostHeartbeatPath(),
|
|
48
|
+
present: heartbeat !== void 0,
|
|
49
|
+
...heartbeat === void 0 ? {} : {
|
|
50
|
+
registeredAt: heartbeat.registeredAt,
|
|
51
|
+
pid: heartbeat.pid
|
|
52
|
+
},
|
|
53
|
+
processAlive: hostAlive
|
|
54
|
+
},
|
|
55
|
+
signIn: status.state,
|
|
56
|
+
fallbackModels: FALLBACK_WORKBUDDY_MODELS.length,
|
|
57
|
+
hints: [
|
|
58
|
+
...status.state === "signed-in" ? [] : ["Sign in once in the WorkBuddy desktop app, then run status again."],
|
|
59
|
+
...desktopPresent ? [] : [`No WorkBuddy desktop auth file at the expected path; set WORKBUDDY_AUTH_FILE if it lives elsewhere.`],
|
|
60
|
+
...hostAlive ? [] : ["Host bundle not running in this DSH profile (or the process exited). The browser card and provider are unavailable until DSH starts the plugin."]
|
|
61
|
+
]
|
|
62
|
+
};
|
|
63
|
+
if (jsonOutput) printJson(report);
|
|
64
|
+
else process.stdout.write([
|
|
65
|
+
`WorkBuddy Connect ${WORKBUDDY_CONNECT_VERSION} on ${process.version}`,
|
|
66
|
+
`Desktop auth file: ${report.desktopAuthFile.present ? "present" : "missing"} (${report.desktopAuthFile.path})`,
|
|
67
|
+
`Host bundle: ${hostAlive ? `running (pid ${heartbeat.pid})` : heartbeat !== void 0 ? "stale heartbeat (process exited)" : "not started"}`,
|
|
68
|
+
`Sign-in state: ${report.signIn}`,
|
|
69
|
+
`Static fallback models: ${report.fallbackModels}`,
|
|
70
|
+
...report.hints.map((hint) => `Hint: ${hint}`),
|
|
71
|
+
""
|
|
72
|
+
].join("\n"));
|
|
73
|
+
return status.state === "signed-in" && desktopPresent ? 0 : 1;
|
|
74
|
+
}
|
|
75
|
+
async function status(jsonOutput) {
|
|
76
|
+
const store = makeStore();
|
|
77
|
+
const client = new WorkBuddyUpstreamClient();
|
|
78
|
+
const authStatus = await store.status();
|
|
79
|
+
const heartbeat = await readHostHeartbeat();
|
|
80
|
+
const hostAlive = heartbeat !== void 0 && isHeartbeatProcessAlive(heartbeat);
|
|
81
|
+
const hostState = hostAlive ? "running" : heartbeat !== void 0 ? "stale" : "not-started";
|
|
82
|
+
if (authStatus.state !== "signed-in") {
|
|
83
|
+
if (jsonOutput) printJson({
|
|
84
|
+
schemaVersion: JSON_SCHEMA_VERSION,
|
|
85
|
+
package: "dsh-workbuddy-connect",
|
|
86
|
+
version: WORKBUDDY_CONNECT_VERSION,
|
|
87
|
+
status: "signed-out",
|
|
88
|
+
hostBundle: hostState
|
|
89
|
+
});
|
|
90
|
+
else process.stdout.write(`WorkBuddy Connect: signed out\nHost bundle: ${hostState}\n`);
|
|
91
|
+
return 1;
|
|
92
|
+
}
|
|
93
|
+
let credits;
|
|
94
|
+
try {
|
|
95
|
+
const credential = await store.current();
|
|
96
|
+
if (credential !== void 0) credits = { total: (await client.fetchCredits(credential)).total };
|
|
97
|
+
} catch (error) {
|
|
98
|
+
credits = {
|
|
99
|
+
total: 0,
|
|
100
|
+
error: safeMessage(error)
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
const expiresAt = authStatus.expiresAtMs !== void 0 ? new Date(authStatus.expiresAtMs).toISOString() : void 0;
|
|
104
|
+
if (jsonOutput) {
|
|
105
|
+
printJson({
|
|
106
|
+
schemaVersion: JSON_SCHEMA_VERSION,
|
|
107
|
+
package: "dsh-workbuddy-connect",
|
|
108
|
+
version: WORKBUDDY_CONNECT_VERSION,
|
|
109
|
+
status: "signed-in",
|
|
110
|
+
...expiresAt === void 0 ? {} : { accessTokenExpires: expiresAt },
|
|
111
|
+
...authStatus.nickname === void 0 ? {} : { nickname: authStatus.nickname },
|
|
112
|
+
...authStatus.domain === void 0 || authStatus.domain === "" ? {} : { domain: authStatus.domain },
|
|
113
|
+
source: authStatus.source,
|
|
114
|
+
credits: credits?.total,
|
|
115
|
+
...credits?.error === void 0 ? {} : { creditsError: credits.error },
|
|
116
|
+
hostBundle: hostState
|
|
117
|
+
});
|
|
118
|
+
return 0;
|
|
119
|
+
}
|
|
120
|
+
process.stdout.write([
|
|
121
|
+
`WorkBuddy Connect: signed in${authStatus.nickname === void 0 ? "" : ` as ${authStatus.nickname}`}`,
|
|
122
|
+
...expiresAt === void 0 ? [] : [`Access token expires ${expiresAt} (refresh is automatic)`],
|
|
123
|
+
credits?.error === void 0 ? `Remaining credit: ${credits?.total ?? "unknown"}` : `Remaining credit: unavailable (${credits.error})`,
|
|
124
|
+
`Host bundle: ${hostAlive ? `running (pid ${heartbeat.pid})` : hostState === "stale" ? "stale heartbeat (DSH process exited)" : "not started in this profile"}`,
|
|
125
|
+
"Client card: load failures are logged to the browser console only; the host provider is unaffected.",
|
|
126
|
+
""
|
|
127
|
+
].join("\n"));
|
|
128
|
+
return 0;
|
|
129
|
+
}
|
|
130
|
+
/** Execute one boot-free command. */
|
|
131
|
+
async function run(argv) {
|
|
132
|
+
if (argv.length === 0 || argv[0] === "--help" || argv[0] === "-h") {
|
|
133
|
+
printHelp();
|
|
134
|
+
return 0;
|
|
135
|
+
}
|
|
136
|
+
const [rawAction, ...flags] = argv;
|
|
137
|
+
if (![
|
|
138
|
+
"doctor",
|
|
139
|
+
"logout",
|
|
140
|
+
"status"
|
|
141
|
+
].includes(rawAction)) {
|
|
142
|
+
process.stderr.write(`dsh-workbuddy-connect: expected doctor, logout, or status; got ${JSON.stringify(rawAction)}\n`);
|
|
143
|
+
return 1;
|
|
144
|
+
}
|
|
145
|
+
const action = rawAction;
|
|
146
|
+
const jsonOutput = flags.includes("--json");
|
|
147
|
+
if (flags.filter((flag) => flag !== "--json").length > 0 || jsonOutput && action === "logout") {
|
|
148
|
+
process.stderr.write(`dsh-workbuddy-connect: invalid options for ${action}: ${flags.join(" ")}\n`);
|
|
149
|
+
return 1;
|
|
150
|
+
}
|
|
151
|
+
try {
|
|
152
|
+
switch (action) {
|
|
153
|
+
case "doctor": return await doctor(jsonOutput);
|
|
154
|
+
case "status": return await status(jsonOutput);
|
|
155
|
+
case "logout":
|
|
156
|
+
await makeStore().logout();
|
|
157
|
+
process.stdout.write(`WorkBuddy Connect: removed ${workbuddyOwnAuthPath()}; the desktop app's sign-in is untouched\n`);
|
|
158
|
+
return 0;
|
|
159
|
+
}
|
|
160
|
+
} catch (error) {
|
|
161
|
+
process.stderr.write(`dsh-workbuddy-connect: ${action} failed: ${safeMessage(error)}\n`);
|
|
162
|
+
return 1;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
if (process.argv[1] !== void 0 && fileURLToPath(import.meta.url) === realpathSync(process.argv[1])) process.exitCode = await run(process.argv.slice(2));
|
|
166
|
+
//#endregion
|
|
167
|
+
export { run };
|