heybash-xdpool 1.0.6 → 1.0.8
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 +12 -0
- package/README.md +3 -1
- package/assets/licenses/dsh-connect-doubao-MIT.txt +21 -0
- package/lib/bin.js +396 -48
- package/lib/client.js +523 -26
- package/lib/index.d.ts +25 -2
- package/lib/index.js +4868 -1914
- package/package.json +1 -1
- package/vendor/channel-pack/pack.js +17 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# Heybash
|
|
2
2
|
|
|
3
|
+
## 1.0.8 — 桌面启动修复
|
|
4
|
+
|
|
5
|
+
- 修复 1.0.7 前端包误引入 Node 模块,导致 DeepSeek Harness 桌面端启动失败。
|
|
6
|
+
- 增加实际执行浏览器模块工厂的回归测试,防止类似错误再次发布。
|
|
7
|
+
|
|
8
|
+
## 1.0.7 — 豆包直连与积分自动化
|
|
9
|
+
|
|
10
|
+
- 接入豆包浏览器登录、直接对话模型及工具调用,账号池显示连接和可用额度;首次登录需要浏览器。
|
|
11
|
+
- 支持国际版 WorkBuddy 每日活跃上报,并在签到活动关闭时正确显示跳过;每日积分由服务端发放。
|
|
12
|
+
- 支持 `skill_share` 生成公开技能分享链接并完成任务,无需发送给联系人;新增 `first_buddy` 首次领取流程(首次领取场景待真实账号验证)。
|
|
13
|
+
- 修复已领取任务状态显示,以及 CodeArts 请求头、工具参数递归和部分页面重挂载问题。
|
|
14
|
+
|
|
3
15
|
## 1.0.6 — 并行工具调用修复
|
|
4
16
|
|
|
5
17
|
- 修复聚合路由在同时调用多个工具时混合参数,避免出现 MALFORMED_RESPONSE 并中断会话。
|
package/README.md
CHANGED
|
@@ -247,8 +247,10 @@ xdpool:
|
|
|
247
247
|
- [corrinehu/dsh-workbuddy-connect](https://github.com/corrinehu/dsh-workbuddy-connect)(MIT)—— 设置节注册(`settings.installSection`)与 DSH 插件结构、客户端卡片加载机制、桌面端凭据刷新与 loopback shim 加固的核心参照;本项目沿用其「宿主通过 installSection 挂卡片」的打通路径。
|
|
248
248
|
- [dingminhua/dsh-connect-workbuddy](https://github.com/dingminhua/dsh-connect-workbuddy)(MIT,Copyright (c) 2026 LaoDing)—— `dsm-plugin-card*` 卡片样式语言与 `--dsw-alias-*` 主题变量的参照实现;**每日签到**(`/v2/billing/meter/checkin-activity-status` 与 `/v2/billing/meter/daily-checkin`)、积分包聚合口径(月度周期套餐 / 一次性礼包区分)与国内 / 国际版按 `domain` 选择上游域名的做法,参考了该项目已验证的接口形态。
|
|
249
249
|
- [Sliverkiss/workbuddy2api](https://github.com/Sliverkiss/workbuddy2api)(MIT)—— WorkBuddy 上游协议(`copilot.tencent.com` 的 wire behavior)与积分接口的参照实现;**积分自动化**(成长中心签到 / 活跃上报 / 连登兑换 / 猫猫旅行状态机 / 13 条任务事件链 / 专家召唤链)整体照该项目的 Go 版逆向实现移植,每条事件链的判据与实测结论都来自它。
|
|
250
|
+
- [Wahwayhale/dsh-connect-doubao](https://github.com/Wahwayhale/dsh-connect-doubao)(MIT,Copyright (c) 2026 Wahwayhale)—— 豆包直连协议和模型目录的上游来源;随包保留 [许可证](./assets/licenses/dsh-connect-doubao-MIT.txt)。
|
|
251
|
+
- [L0NE-6/WorkBuddy-Daily](https://github.com/L0NE-6/WorkBuddy-Daily)(MIT,Copyright (c) 2026 L0NE-6)—— 参考技能分享链接接口、分享事件以及首只 Buddy 领取流程;仅生成公开技能分享链接,不向任何人发送。
|
|
250
252
|
|
|
251
|
-
|
|
253
|
+
以上项目的版权归各自作者所有。引用及移植的代码遵循各项目许可证,随包保留相应版权和许可证。若标注有遗漏或不当之处,欢迎提交 issue 指正。
|
|
252
254
|
|
|
253
255
|
## 许可证
|
|
254
256
|
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Wahwayhale
|
|
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/lib/bin.js
CHANGED
|
@@ -4,11 +4,12 @@ import { chmod, copyFile, mkdir, readFile, readdir, rename, rm, unlink, writeFil
|
|
|
4
4
|
import { homedir, platform } from "node:os";
|
|
5
5
|
import { basename, dirname, join, resolve } from "node:path";
|
|
6
6
|
import { execFile, execFileSync } from "node:child_process";
|
|
7
|
+
import "@deepseek-ai/dsh-llm";
|
|
8
|
+
import "@deepseek-ai/dsh-llm/brand";
|
|
7
9
|
import z from "@deepseek-ai/schemastery";
|
|
8
10
|
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
9
11
|
import "@earendil-works/pi-ai";
|
|
10
12
|
import "@earendil-works/pi-ai/api/openai-completions.lazy";
|
|
11
|
-
import "@deepseek-ai/dsh-llm";
|
|
12
13
|
import "@deepseek-ai/dsh-llm-pi-ai";
|
|
13
14
|
// src/badges.ts
|
|
14
15
|
/**
|
|
@@ -189,6 +190,38 @@ const SESSION_DEAD_MARKERS = [
|
|
|
189
190
|
*/
|
|
190
191
|
const ALREADY_CHECKIN_MARKERS = ["已签到", "already"];
|
|
191
192
|
/**
|
|
193
|
+
* Markers for "the check-in activity is not running on this gateway".
|
|
194
|
+
*
|
|
195
|
+
* Distinct from {@link ALREADY_CHECKIN_MARKERS}: "already collected" means the
|
|
196
|
+
* account got its reward, while this means there is nothing to collect on that
|
|
197
|
+
* gateway at all. Both are no-ops rather than failures, but only the first is
|
|
198
|
+
* evidence the account is working.
|
|
199
|
+
*
|
|
200
|
+
* Measured on the international gateway (`www.workbuddy.ai`, 2026-11-10):
|
|
201
|
+
* `checkin-activity-status` answers 200 with `active: false`, and claiming
|
|
202
|
+
* answers HTTP 400 `{"code":10001,"msg":"签到活动未开启或已过期"}`. Neither `已签到`
|
|
203
|
+
* nor `already` matches that wording, so the scheduler used to record a healthy
|
|
204
|
+
* global account as a failed job — a per-account `failed: +1` on every run, for
|
|
205
|
+
* an activity the gateway simply does not run.
|
|
206
|
+
*/
|
|
207
|
+
const CHECKIN_UNAVAILABLE_MARKERS = [
|
|
208
|
+
"签到活动未开启",
|
|
209
|
+
"活动未开启",
|
|
210
|
+
"活动已过期",
|
|
211
|
+
"not active",
|
|
212
|
+
"activity is not open"
|
|
213
|
+
];
|
|
214
|
+
/**
|
|
215
|
+
* Whether a claim failure means "this gateway runs no check-in activity".
|
|
216
|
+
*
|
|
217
|
+
* Callers treat this as a skipped no-op: the job reached the upstream and
|
|
218
|
+
* correctly found nothing to collect, which is not an account fault.
|
|
219
|
+
*/
|
|
220
|
+
function isCheckinUnavailable(error) {
|
|
221
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
222
|
+
return CHECKIN_UNAVAILABLE_MARKERS.some((marker) => message.includes(marker));
|
|
223
|
+
}
|
|
224
|
+
/**
|
|
192
225
|
* Markers for "there is no compensation offer to collect".
|
|
193
226
|
*
|
|
194
227
|
* The offer is seasonal — an outage announcement opens one, and it closes on a
|
|
@@ -545,6 +578,7 @@ const SSE_SCAN_LIMIT = 1 << 20;
|
|
|
545
578
|
/** Server request ids look like `cmb-<32 hex>` or a bare 32 hex string. */
|
|
546
579
|
const SERVER_ID_PATTERN = /"id"\s*:\s*"((?:cmb-)?[0-9a-f]{32})"/;
|
|
547
580
|
const DESKTOP_TASK_UA = "WorkBuddy/5.5.6 WorkBuddy/5.5.6 CLI/2.137.1";
|
|
581
|
+
const SKILL_SHARE_UA = "WorkBuddy/5.9.3 WorkBuddy/5.9.3 CLI/2.165.0";
|
|
548
582
|
/**
|
|
549
583
|
* Derive a stable 36-hex device id from the account uid.
|
|
550
584
|
*
|
|
@@ -1568,9 +1602,20 @@ var WorkBuddyUpstreamClient = class {
|
|
|
1568
1602
|
* Business fields win over the fingerprint, so a caller can override a device
|
|
1569
1603
|
* id to align with a real install.
|
|
1570
1604
|
*/
|
|
1571
|
-
async reportDesktopEvents(credential, events) {
|
|
1605
|
+
async reportDesktopEvents(credential, events, identity) {
|
|
1572
1606
|
if (events.length === 0) return;
|
|
1573
1607
|
const fingerprint = this.desktopFingerprint(credential);
|
|
1608
|
+
if (identity === "skill-share") Object.assign(fingerprint, {
|
|
1609
|
+
ideVersion: "5.9.3",
|
|
1610
|
+
extVersion: "5.9.3",
|
|
1611
|
+
releaseDate: 1793093056315,
|
|
1612
|
+
commit: "d46924219e79332f49c37ccebf27292f87001b19",
|
|
1613
|
+
qimei36: deriveDeviceId(credential, "qimei"),
|
|
1614
|
+
osVersion: "10.0.28000",
|
|
1615
|
+
cpuModel: "11th Gen Intel(R) Core(TM) i5-11320H @ 3.20GHz",
|
|
1616
|
+
cpuCores: 8,
|
|
1617
|
+
memorySize: 16
|
|
1618
|
+
});
|
|
1574
1619
|
const body = events.map((event) => ({
|
|
1575
1620
|
...fingerprint,
|
|
1576
1621
|
...event
|
|
@@ -1581,7 +1626,7 @@ var WorkBuddyUpstreamClient = class {
|
|
|
1581
1626
|
"Authorization": `Bearer ${credential.accessToken}`,
|
|
1582
1627
|
"Accept": "application/json, text/plain, */*",
|
|
1583
1628
|
"Content-Type": "application/json;charset=UTF-8",
|
|
1584
|
-
"User-Agent": DESKTOP_TASK_UA,
|
|
1629
|
+
"User-Agent": identity === "skill-share" ? SKILL_SHARE_UA : DESKTOP_TASK_UA,
|
|
1585
1630
|
"X-Product": "SaaS",
|
|
1586
1631
|
"X-Request-ID": deriveDeviceId(credential, "req") + String(Date.now() % 1e6),
|
|
1587
1632
|
...credential.uid === void 0 || credential.uid === "" ? {} : { "X-User-Id": credential.uid },
|
|
@@ -1723,6 +1768,80 @@ var WorkBuddyUpstreamClient = class {
|
|
|
1723
1768
|
}
|
|
1724
1769
|
return out;
|
|
1725
1770
|
}
|
|
1771
|
+
/** Read public marketplace skills for the share-link task. */
|
|
1772
|
+
async shareableSkills(credential) {
|
|
1773
|
+
if (regionOf(credential.domain) !== "cn") throw new Error("skill sharing is only available for domestic accounts");
|
|
1774
|
+
const response = await this.fetchImpl("https://www.codebuddy.cn/v2/operation-platform/market/skill/list", {
|
|
1775
|
+
method: "POST",
|
|
1776
|
+
headers: {
|
|
1777
|
+
...chatHeaders(credential),
|
|
1778
|
+
"User-Agent": DESKTOP_TASK_UA
|
|
1779
|
+
},
|
|
1780
|
+
body: JSON.stringify({
|
|
1781
|
+
page: 1,
|
|
1782
|
+
page_size: 20
|
|
1783
|
+
}),
|
|
1784
|
+
signal: AbortSignal.timeout(JSON_TIMEOUT_MS)
|
|
1785
|
+
});
|
|
1786
|
+
const envelope = await readEnvelope(response);
|
|
1787
|
+
if (!response.ok || envelope.code !== 0) throw envelopeError(response.status, envelope);
|
|
1788
|
+
const rows = asRecord(envelope.data)["skills"];
|
|
1789
|
+
if (!Array.isArray(rows)) return [];
|
|
1790
|
+
return rows.flatMap((value) => {
|
|
1791
|
+
const row = asRecord(value);
|
|
1792
|
+
const id = typeof row["skill_id"] === "string" ? row["skill_id"] : typeof row["id"] === "string" ? row["id"] : "";
|
|
1793
|
+
const name = [
|
|
1794
|
+
row["display_name_zh"],
|
|
1795
|
+
row["name"],
|
|
1796
|
+
row["display_name_en"]
|
|
1797
|
+
].find((v) => typeof v === "string" && v.trim() !== "");
|
|
1798
|
+
const description = [
|
|
1799
|
+
row["description_zh"],
|
|
1800
|
+
row["description"],
|
|
1801
|
+
row["description_en"]
|
|
1802
|
+
].find((v) => typeof v === "string" && v.trim() !== "");
|
|
1803
|
+
return id.trim() === "" || typeof name !== "string" ? [] : [{
|
|
1804
|
+
id: id.trim(),
|
|
1805
|
+
name: name.trim(),
|
|
1806
|
+
description: typeof description === "string" ? description.trim().slice(0, 60) : ""
|
|
1807
|
+
}];
|
|
1808
|
+
});
|
|
1809
|
+
}
|
|
1810
|
+
/** Create a real link for a public marketplace skill. Never sends it to a person. */
|
|
1811
|
+
async createSkillShareLink(credential, skill) {
|
|
1812
|
+
if (regionOf(credential.domain) !== "cn" || !credential.uid || !skill.id || !skill.name) throw new Error("skill share requires a domestic account and a marketplace skill");
|
|
1813
|
+
const response = await this.fetchImpl("https://open.workbuddy.cn/api/v2/open-platform/asset-shares/c2c/channels", {
|
|
1814
|
+
method: "POST",
|
|
1815
|
+
headers: {
|
|
1816
|
+
"Authorization": `Bearer ${credential.accessToken}`,
|
|
1817
|
+
"X-User-Id": credential.uid,
|
|
1818
|
+
"X-Domain": "copilot.tencent.com",
|
|
1819
|
+
"Content-Type": "application/json",
|
|
1820
|
+
"Accept": "application/json, text/plain, */*",
|
|
1821
|
+
"User-Agent": SKILL_SHARE_UA
|
|
1822
|
+
},
|
|
1823
|
+
body: JSON.stringify({
|
|
1824
|
+
asset_kind: "skill",
|
|
1825
|
+
asset_source: "market",
|
|
1826
|
+
asset_ref: JSON.stringify({ asset_id: skill.id }),
|
|
1827
|
+
ways: ["link"],
|
|
1828
|
+
extra: {
|
|
1829
|
+
name: skill.name,
|
|
1830
|
+
description: skill.description,
|
|
1831
|
+
shareKey: skill.id,
|
|
1832
|
+
marketplaceSource: "builtin-market"
|
|
1833
|
+
}
|
|
1834
|
+
}),
|
|
1835
|
+
signal: AbortSignal.timeout(JSON_TIMEOUT_MS)
|
|
1836
|
+
});
|
|
1837
|
+
const envelope = await readEnvelope(response);
|
|
1838
|
+
if (!response.ok || envelope.code !== 0) throw envelopeError(response.status, envelope);
|
|
1839
|
+
const data = asRecord(envelope.data);
|
|
1840
|
+
const shareCode = typeof data["share_code"] === "string" ? data["share_code"].trim() : "";
|
|
1841
|
+
const link = (Array.isArray(data["ways"]) ? data["ways"] : []).map(asRecord).find((way) => way["share_way"] === "link")?.["resource_ref"];
|
|
1842
|
+
if (shareCode === "" || typeof link !== "string" || link.trim() === "") throw new Error("skill share response has no share code or link");
|
|
1843
|
+
return { shareCode };
|
|
1844
|
+
}
|
|
1726
1845
|
/**
|
|
1727
1846
|
* Open a REAL desktop conversation and return the ids the server assigned.
|
|
1728
1847
|
*
|
|
@@ -1978,7 +2097,11 @@ var WorkBuddyUpstreamClient = class {
|
|
|
1978
2097
|
* rather than an error, which is why it is thrown as-is for them to classify.
|
|
1979
2098
|
*/
|
|
1980
2099
|
async buddyAdoptFirst(credential) {
|
|
1981
|
-
await this.growthJson(credential, "POST", "/activity/growth/buddy/first", {});
|
|
2100
|
+
const data = await this.growthJson(credential, "POST", "/activity/growth/buddy/first", {});
|
|
2101
|
+
return {
|
|
2102
|
+
credit: numOf(data["credit"]),
|
|
2103
|
+
energy: numOf(data["energy"])
|
|
2104
|
+
};
|
|
1982
2105
|
}
|
|
1983
2106
|
/** Current travel state for the account's buddy. */
|
|
1984
2107
|
async buddyTravelStatus(credential) {
|
|
@@ -4947,6 +5070,123 @@ ${new Date(until).toISOString()}
|
|
|
4947
5070
|
};
|
|
4948
5071
|
}
|
|
4949
5072
|
};
|
|
5073
|
+
// src/doubao-catalog.ts
|
|
5074
|
+
/**
|
|
5075
|
+
* DSH-side alias for "generate an image".
|
|
5076
|
+
*
|
|
5077
|
+
* NOT a Doubao `model_item_key` — Doubao has no model by this name. Selecting it
|
|
5078
|
+
* makes the shim send an ordinary chat turn with `input_skill: imageGen`, and
|
|
5079
|
+
* Doubao answers with Seedream. Keeping it in the catalog is what puts 生图 in
|
|
5080
|
+
* DSH's model picker without inventing a second UI.
|
|
5081
|
+
*/
|
|
5082
|
+
const DOUBAO_IMAGE_MODEL_ID = "image-gen";
|
|
5083
|
+
/**
|
|
5084
|
+
* IMAGEGEN_LABEL_OVERLAY: 生图版本名以插件根目录的 image-models.json 为准,
|
|
5085
|
+
* 该文件由 doubao_imagemodels.py --sync 从服务端 get_item_conf 生成。
|
|
5086
|
+
*/
|
|
5087
|
+
function imageModelLabelFromOverlay() {
|
|
5088
|
+
try {
|
|
5089
|
+
const url = new URL("../image-models.json", import.meta.url);
|
|
5090
|
+
const parsed = JSON.parse(readFileSync(url, "utf8"));
|
|
5091
|
+
return typeof parsed.label === "string" && parsed.label !== "" ? parsed.label : void 0;
|
|
5092
|
+
} catch {
|
|
5093
|
+
return;
|
|
5094
|
+
}
|
|
5095
|
+
}
|
|
5096
|
+
/**
|
|
5097
|
+
* The entries DSH may offer.
|
|
5098
|
+
*
|
|
5099
|
+
* WHY THESE ENTRIES. Doubao groups models by MODE, and the model list is per-mode:
|
|
5100
|
+
*
|
|
5101
|
+
* 对话 → 豆包 快速 (0), 豆包 2.1 Turbo·专家 (3)
|
|
5102
|
+
* 工作任务 → 自动 (9), 2.1 Lite (seed-lite-7b), 2.1 Pro (5), Turbo (3)
|
|
5103
|
+
*
|
|
5104
|
+
* The 「工作任务」 group (`seed-lite-7b`, `5`, `9`) runs through `Agent-GeneralTask`
|
|
5105
|
+
* (`mode_id: "3"`, `agent_mode: 1`) and is accompanied by an HTTP `tool_local`
|
|
5106
|
+
* workspace responder (`msg/ack` -> `upload_command_result` -> `msg/complete`)
|
|
5107
|
+
* so external turns complete without `710010702`.
|
|
5108
|
+
*
|
|
5109
|
+
* MEASURED, 2026-10-22: `model_item_key` is forwarded verbatim (the server stores
|
|
5110
|
+
* it on the message), but in 对话 mode it does NOT change what answers —
|
|
5111
|
+
* 0 / 3 / 5 / seed-lite-7b AND a deliberately bogus key all returned answers of
|
|
5112
|
+
* indistinguishable length and latency (12.3–14.0 s). So this list is honest
|
|
5113
|
+
* about what the PICKER can offer; it does not claim per-key routing.
|
|
5114
|
+
*
|
|
5115
|
+
* 「豆包 快速」 leads because it is the app's own chat-mode default, so an
|
|
5116
|
+
* unconfigured install reproduces the app rather than something that merely
|
|
5117
|
+
* happens to work.
|
|
5118
|
+
*/
|
|
5119
|
+
const DOUBAO_MODELS = [
|
|
5120
|
+
{
|
|
5121
|
+
id: "0",
|
|
5122
|
+
name: "豆包 快速",
|
|
5123
|
+
reasoning: false
|
|
5124
|
+
},
|
|
5125
|
+
{
|
|
5126
|
+
id: "3",
|
|
5127
|
+
name: "豆包 2.1 Turbo",
|
|
5128
|
+
badge: "专家",
|
|
5129
|
+
reasoning: true
|
|
5130
|
+
},
|
|
5131
|
+
{
|
|
5132
|
+
id: "seed-lite-7b",
|
|
5133
|
+
name: "豆包 2.1 Lite",
|
|
5134
|
+
badge: "工作任务",
|
|
5135
|
+
reasoning: true,
|
|
5136
|
+
taskMode: true
|
|
5137
|
+
},
|
|
5138
|
+
{
|
|
5139
|
+
id: "5",
|
|
5140
|
+
name: "豆包 2.1 Pro",
|
|
5141
|
+
badge: "工作任务",
|
|
5142
|
+
reasoning: true,
|
|
5143
|
+
taskMode: true
|
|
5144
|
+
},
|
|
5145
|
+
{
|
|
5146
|
+
id: "9",
|
|
5147
|
+
name: "自动",
|
|
5148
|
+
badge: "工作任务",
|
|
5149
|
+
reasoning: true,
|
|
5150
|
+
taskMode: true
|
|
5151
|
+
},
|
|
5152
|
+
{
|
|
5153
|
+
id: DOUBAO_IMAGE_MODEL_ID,
|
|
5154
|
+
name: imageModelLabelFromOverlay() ?? "豆包 生图(Seedream 5.5)",
|
|
5155
|
+
reasoning: true
|
|
5156
|
+
}
|
|
5157
|
+
];
|
|
5158
|
+
randomUUID();
|
|
5159
|
+
DOUBAO_MODELS.filter((model) => model.id === "0" || model.id === "3");
|
|
5160
|
+
Object.freeze([
|
|
5161
|
+
"priority",
|
|
5162
|
+
"round-robin",
|
|
5163
|
+
"balanced",
|
|
5164
|
+
"sticky",
|
|
5165
|
+
"expiry"
|
|
5166
|
+
]);
|
|
5167
|
+
/**
|
|
5168
|
+
* The schedule every automation job falls back to.
|
|
5169
|
+
*
|
|
5170
|
+
* Shared by both halves on purpose. The host uses it when a configured hour
|
|
5171
|
+
* list arrives empty (the settings schema materializes "never configured" into
|
|
5172
|
+
* `[]`), and the card uses it when it writes the `automation` block back, so a
|
|
5173
|
+
* document that already holds an empty list is healed instead of being saved
|
|
5174
|
+
* back as an unrunnable schedule.
|
|
5175
|
+
*
|
|
5176
|
+
* This lives here rather than in `scheduler.ts` because the browser half cannot
|
|
5177
|
+
* import the host module: `scheduler.ts` pulls in `node:crypto` and the whole
|
|
5178
|
+
* upstream client, none of which exists in the browser bundle. Two hand-written
|
|
5179
|
+
* copies would drift, and the drift is invisible — the card would write a
|
|
5180
|
+
* schedule the scheduler does not run.
|
|
5181
|
+
*/
|
|
5182
|
+
const DEFAULT_AUTOMATION_HOURS = {
|
|
5183
|
+
checkin: [9],
|
|
5184
|
+
report: [10],
|
|
5185
|
+
tasks: [11],
|
|
5186
|
+
streak: [12],
|
|
5187
|
+
travel: [9, 21],
|
|
5188
|
+
compensation: [13]
|
|
5189
|
+
};
|
|
4950
5190
|
// src/catalog.ts
|
|
4951
5191
|
/**
|
|
4952
5192
|
* Model catalog with per-model credit multipliers.
|
|
@@ -5339,36 +5579,6 @@ function catalogFromUpstream(models, region = "cn") {
|
|
|
5339
5579
|
if (models.length === 0) return fallbackModelsFor(region);
|
|
5340
5580
|
return models.map(toModelInfo);
|
|
5341
5581
|
}
|
|
5342
|
-
Object.freeze([
|
|
5343
|
-
"priority",
|
|
5344
|
-
"round-robin",
|
|
5345
|
-
"balanced",
|
|
5346
|
-
"sticky",
|
|
5347
|
-
"expiry"
|
|
5348
|
-
]);
|
|
5349
|
-
/**
|
|
5350
|
-
* The schedule every automation job falls back to.
|
|
5351
|
-
*
|
|
5352
|
-
* Shared by both halves on purpose. The host uses it when a configured hour
|
|
5353
|
-
* list arrives empty (the settings schema materializes "never configured" into
|
|
5354
|
-
* `[]`), and the card uses it when it writes the `automation` block back, so a
|
|
5355
|
-
* document that already holds an empty list is healed instead of being saved
|
|
5356
|
-
* back as an unrunnable schedule.
|
|
5357
|
-
*
|
|
5358
|
-
* This lives here rather than in `scheduler.ts` because the browser half cannot
|
|
5359
|
-
* import the host module: `scheduler.ts` pulls in `node:crypto` and the whole
|
|
5360
|
-
* upstream client, none of which exists in the browser bundle. Two hand-written
|
|
5361
|
-
* copies would drift, and the drift is invisible — the card would write a
|
|
5362
|
-
* schedule the scheduler does not run.
|
|
5363
|
-
*/
|
|
5364
|
-
const DEFAULT_AUTOMATION_HOURS = {
|
|
5365
|
-
checkin: [9],
|
|
5366
|
-
report: [10],
|
|
5367
|
-
tasks: [11],
|
|
5368
|
-
streak: [12],
|
|
5369
|
-
travel: [9, 21],
|
|
5370
|
-
compensation: [13]
|
|
5371
|
-
};
|
|
5372
5582
|
// src/channels.ts
|
|
5373
5583
|
/**
|
|
5374
5584
|
* Mount the vendored free-channel pack.
|
|
@@ -10662,6 +10872,33 @@ function skillChain(conversationId, requestId) {
|
|
|
10662
10872
|
}]
|
|
10663
10873
|
};
|
|
10664
10874
|
}
|
|
10875
|
+
/** Link-share events, sent only after the server created a real marketplace link. */
|
|
10876
|
+
function skillShareLinkChain(skill, shareCode, now = Date.now()) {
|
|
10877
|
+
if (!skill.id || !skill.name || !shareCode) throw new Error("skill share event requires a real skill and share code");
|
|
10878
|
+
const common = {
|
|
10879
|
+
eventCode: "skill_share_channel_action",
|
|
10880
|
+
skillId: skill.id,
|
|
10881
|
+
skillName: skill.name,
|
|
10882
|
+
skillType: "market",
|
|
10883
|
+
action: "link",
|
|
10884
|
+
panelType: "clipboard",
|
|
10885
|
+
isSuccessful: true,
|
|
10886
|
+
cost: 0,
|
|
10887
|
+
id: shareCode,
|
|
10888
|
+
actionAt: now
|
|
10889
|
+
};
|
|
10890
|
+
return {
|
|
10891
|
+
transport: "desktop",
|
|
10892
|
+
identity: "skill-share",
|
|
10893
|
+
events: [{
|
|
10894
|
+
...common,
|
|
10895
|
+
panelAction: "click"
|
|
10896
|
+
}, {
|
|
10897
|
+
...common,
|
|
10898
|
+
panelAction: "success"
|
|
10899
|
+
}]
|
|
10900
|
+
};
|
|
10901
|
+
}
|
|
10665
10902
|
/** The theme-apply event `Hp_Appearance` is scored on. */
|
|
10666
10903
|
function appearanceChain(themeKey = APPEARANCE_THEME_KEY) {
|
|
10667
10904
|
return {
|
|
@@ -10854,6 +11091,8 @@ const EVENT_CHAIN_BUILDERS = {
|
|
|
10854
11091
|
Hp_Appearance: true,
|
|
10855
11092
|
Library_read: true,
|
|
10856
11093
|
skill_1: true,
|
|
11094
|
+
skill_share: true,
|
|
11095
|
+
first_buddy: true,
|
|
10857
11096
|
expert_5: true,
|
|
10858
11097
|
Expert_team_use_3: true,
|
|
10859
11098
|
Expert_lighthouse: true,
|
|
@@ -11004,11 +11243,34 @@ function slotKey(date, timeZone = AUTOMATION_TIME_ZONE) {
|
|
|
11004
11243
|
*
|
|
11005
11244
|
* So the scope is per job, and the default for a job that is not named is `cn`:
|
|
11006
11245
|
* a new job must opt in explicitly rather than inherit an accident.
|
|
11246
|
+
*
|
|
11247
|
+
* Measured against the live international gateway (`www.workbuddy.ai`,
|
|
11248
|
+
* 2026-11-10) rather than assumed — three of the six jobs do work there, and the
|
|
11249
|
+
* old comment's claim that the gateway "has no activity report and no streak
|
|
11250
|
+
* ladder" was simply wrong:
|
|
11251
|
+
*
|
|
11252
|
+
* - `POST /v2/report` answers 200 `{code:0}` and moves the very next
|
|
11253
|
+
* `GET /activity/growth/streak` read from `days: 0` to `days: 1` on an account
|
|
11254
|
+
* with no prior history. That is the whole daily-active credit mechanism: each
|
|
11255
|
+
* recorded active day grants a 30-credit `Bonus Pack` (31-day expiry, granted
|
|
11256
|
+
* server-side the following morning — there is no claim endpoint).
|
|
11257
|
+
* - `GET /activity/growth/streak` returns the same shape as CN (`streak.days`,
|
|
11258
|
+
* `next_tier`, and `redemption_status.tiers[].{tier,days,credit,energy,cards,
|
|
11259
|
+
* chances}`), so the streak ladder and its `7d/14d/28d` redemption work too.
|
|
11260
|
+
* - Check-in is the one thing that genuinely does not: the activity is closed
|
|
11261
|
+
* (`active: false`) and `daily-checkin` answers `签到活动未开启或已过期`, which
|
|
11262
|
+
* `isAlreadyCheckin` does not recognise — hence the misleading `failed: +1`.
|
|
11263
|
+
*
|
|
11264
|
+
* The task centre also exists (`GET /v2/activity/growth/tasks` returns five
|
|
11265
|
+
* tasks) but is NOT safe to enable: its entries key on numeric `task_id` + `code`
|
|
11266
|
+
* with no `task_code`, no `reward_credit`/`reward_energy` and no `current`/
|
|
11267
|
+
* `target`, so `parseTask` drops them and `tasks/accept` answers `task not found`.
|
|
11268
|
+
* Making that work is a parsing job with no measurable payout, so it stays off.
|
|
11007
11269
|
*/
|
|
11008
11270
|
const JOB_REGION_SCOPE = {
|
|
11009
|
-
report: ["cn"],
|
|
11271
|
+
report: ["cn", "global"],
|
|
11272
|
+
streak: ["cn", "global"],
|
|
11010
11273
|
tasks: ["cn"],
|
|
11011
|
-
streak: ["cn"],
|
|
11012
11274
|
travel: ["cn"],
|
|
11013
11275
|
compensation: ["cn"],
|
|
11014
11276
|
checkin: ["cn", "global"]
|
|
@@ -11090,6 +11352,10 @@ var WorkBuddyScheduler = class {
|
|
|
11090
11352
|
compensation: { ...EMPTY_JOB_STATE }
|
|
11091
11353
|
};
|
|
11092
11354
|
claimableSeen = 0;
|
|
11355
|
+
/** Completion failures for the latest pass, keyed by account and task. */
|
|
11356
|
+
eventFailures = /* @__PURE__ */ new Map();
|
|
11357
|
+
/** Direct rewards from first-Buddy adoption, awaiting the task summary. */
|
|
11358
|
+
buddyAdoptionReceipts = /* @__PURE__ */ new Map();
|
|
11093
11359
|
/**
|
|
11094
11360
|
* Credits/energy/tasks earned per account TODAY, keyed by account id.
|
|
11095
11361
|
*
|
|
@@ -11567,8 +11833,11 @@ var WorkBuddyScheduler = class {
|
|
|
11567
11833
|
switch (kind) {
|
|
11568
11834
|
case "checkin": {
|
|
11569
11835
|
let alreadyDone = false;
|
|
11836
|
+
let activityClosed = false;
|
|
11570
11837
|
try {
|
|
11571
|
-
|
|
11838
|
+
const status = await this.client.fetchCheckinStatus(account.credential);
|
|
11839
|
+
alreadyDone = status.todayCheckedIn === true;
|
|
11840
|
+
activityClosed = status.active === false;
|
|
11572
11841
|
} catch (error) {
|
|
11573
11842
|
this.logger.warn?.(`automation checkin ${account.label}: status read failed, claiming anyway:`, error);
|
|
11574
11843
|
}
|
|
@@ -11576,6 +11845,15 @@ var WorkBuddyScheduler = class {
|
|
|
11576
11845
|
this.logger.info?.(`automation checkin ${account.label}: already done today (read, not claimed)`);
|
|
11577
11846
|
break;
|
|
11578
11847
|
}
|
|
11848
|
+
if (activityClosed) {
|
|
11849
|
+
this.logger.info?.(`automation checkin ${account.label}: no check-in activity on this gateway, skipped`);
|
|
11850
|
+
items.push({
|
|
11851
|
+
title: "每日签到",
|
|
11852
|
+
status: "skipped",
|
|
11853
|
+
note: "this gateway runs no check-in activity"
|
|
11854
|
+
});
|
|
11855
|
+
break;
|
|
11856
|
+
}
|
|
11579
11857
|
try {
|
|
11580
11858
|
const claim = await this.client.claimDailyCheckin(account.credential);
|
|
11581
11859
|
this.recordEarnings(account.id, today, { checkinCredit: claim.credit });
|
|
@@ -11584,6 +11862,15 @@ var WorkBuddyScheduler = class {
|
|
|
11584
11862
|
this.logger.info?.(`automation checkin ${account.label}: +${claim.credit} credit`);
|
|
11585
11863
|
}
|
|
11586
11864
|
} catch (error) {
|
|
11865
|
+
if (isCheckinUnavailable(error)) {
|
|
11866
|
+
this.logger.info?.(`automation checkin ${account.label}: no check-in activity on this gateway, skipped`);
|
|
11867
|
+
items.push({
|
|
11868
|
+
title: "每日签到",
|
|
11869
|
+
status: "skipped",
|
|
11870
|
+
note: "this gateway runs no check-in activity"
|
|
11871
|
+
});
|
|
11872
|
+
break;
|
|
11873
|
+
}
|
|
11587
11874
|
if (!isAlreadyCheckin(error)) throw error;
|
|
11588
11875
|
this.logger.info?.(`automation checkin ${account.label}: already done today`);
|
|
11589
11876
|
}
|
|
@@ -11701,6 +11988,7 @@ var WorkBuddyScheduler = class {
|
|
|
11701
11988
|
let sentAnything = false;
|
|
11702
11989
|
for (const account of accounts) {
|
|
11703
11990
|
if (this.stopped) return;
|
|
11991
|
+
this.eventFailures.delete(account.id);
|
|
11704
11992
|
let tasks;
|
|
11705
11993
|
try {
|
|
11706
11994
|
tasks = await this.client.listTasks(account.credential);
|
|
@@ -11708,14 +11996,28 @@ var WorkBuddyScheduler = class {
|
|
|
11708
11996
|
this.logger.warn?.(`automation events ${account.label}: list failed:`, error);
|
|
11709
11997
|
continue;
|
|
11710
11998
|
}
|
|
11711
|
-
const pending = tasks.filter((task) => task.taskCode
|
|
11999
|
+
const pending = tasks.filter((task) => Object.hasOwn(EVENT_CHAIN_BUILDERS, task.taskCode) && !task.claimed && !task.claimable && !task.locked);
|
|
11712
12000
|
for (const task of pending) {
|
|
11713
12001
|
if (this.stopped) return;
|
|
11714
12002
|
let chains;
|
|
11715
12003
|
try {
|
|
12004
|
+
if (task.taskCode === "first_buddy") {
|
|
12005
|
+
if (await this.completeFirstBuddy(account)) sentAnything = true;
|
|
12006
|
+
continue;
|
|
12007
|
+
}
|
|
12008
|
+
if (task.taskCode === "skill_share" && task.acceptStatus === "not_accepted") {
|
|
12009
|
+
await this.client.acceptTasks(account.credential, [task.taskCode]);
|
|
12010
|
+
const updated = (await this.client.listTasks(account.credential)).find((row) => row.taskCode === task.taskCode);
|
|
12011
|
+
if (updated === void 0 || updated.acceptStatus === "not_accepted" || updated.acceptStatus === "" || updated.locked) throw new Error("skill_share task was not accepted");
|
|
12012
|
+
if (updated.claimed || updated.claimable) continue;
|
|
12013
|
+
}
|
|
11716
12014
|
chains = await this.chainsFor(task, account.credential);
|
|
11717
12015
|
} catch (error) {
|
|
11718
|
-
this.
|
|
12016
|
+
const failed = this.eventFailures.get(account.id) ?? /* @__PURE__ */ new Set();
|
|
12017
|
+
failed.add(task.taskCode);
|
|
12018
|
+
this.eventFailures.set(account.id, failed);
|
|
12019
|
+
if (task.taskCode === "skill_share") this.logger.warn?.(`automation events ${account.label}: skill_share failed`);
|
|
12020
|
+
else this.logger.warn?.(`automation events ${account.label}: ${task.taskCode} could not be built:`, error);
|
|
11719
12021
|
continue;
|
|
11720
12022
|
}
|
|
11721
12023
|
for (const chain of chains) {
|
|
@@ -11725,7 +12027,11 @@ var WorkBuddyScheduler = class {
|
|
|
11725
12027
|
this.logger.info?.(`automation events ${account.label}: ${task.taskCode} chain sent`);
|
|
11726
12028
|
sentAnything = true;
|
|
11727
12029
|
} catch (error) {
|
|
11728
|
-
this.
|
|
12030
|
+
const failed = this.eventFailures.get(account.id) ?? /* @__PURE__ */ new Set();
|
|
12031
|
+
failed.add(task.taskCode);
|
|
12032
|
+
this.eventFailures.set(account.id, failed);
|
|
12033
|
+
if (task.taskCode === "skill_share") this.logger.warn?.(`automation events ${account.label}: skill_share report failed`);
|
|
12034
|
+
else this.logger.warn?.(`automation events ${account.label}: ${task.taskCode} failed:`, error);
|
|
11729
12035
|
break;
|
|
11730
12036
|
}
|
|
11731
12037
|
if (this.delayMs > 0 && !this.stopped) await sleep(this.delayMs);
|
|
@@ -11734,6 +12040,20 @@ var WorkBuddyScheduler = class {
|
|
|
11734
12040
|
}
|
|
11735
12041
|
if (sentAnything && this.eventScoreWaitMs > 0 && !this.stopped) await sleep(this.eventScoreWaitMs);
|
|
11736
12042
|
}
|
|
12043
|
+
/** Adopt only when the account truly lacks a Buddy; verify after the write. */
|
|
12044
|
+
async completeFirstBuddy(account) {
|
|
12045
|
+
const credential = account.credential;
|
|
12046
|
+
if (await this.client.buddyInfo(credential) !== void 0) return false;
|
|
12047
|
+
await this.client.reportDesktopEvents(credential, [{
|
|
12048
|
+
eventCode: "buddy_agreement_view",
|
|
12049
|
+
timestamp: Date.now()
|
|
12050
|
+
}]);
|
|
12051
|
+
await this.client.buddyAgree(credential);
|
|
12052
|
+
const receipt = await this.client.buddyAdoptFirst(credential);
|
|
12053
|
+
if (receipt && (receipt.credit > 0 || receipt.energy > 0)) this.buddyAdoptionReceipts.set(account.id, receipt);
|
|
12054
|
+
if (await this.client.buddyInfo(credential) === void 0) throw new Error("first_buddy adoption was not confirmed");
|
|
12055
|
+
return true;
|
|
12056
|
+
}
|
|
11737
12057
|
/**
|
|
11738
12058
|
* Send one chain on the channel it was built for.
|
|
11739
12059
|
*
|
|
@@ -11748,7 +12068,7 @@ var WorkBuddyScheduler = class {
|
|
|
11748
12068
|
await this.client.reportWebEvent(credential, web.eventCode, web.pageUrl, web.elementId, web.elementName);
|
|
11749
12069
|
return;
|
|
11750
12070
|
}
|
|
11751
|
-
await this.client.reportDesktopEvents(credential, chain.events ?? []);
|
|
12071
|
+
await this.client.reportDesktopEvents(credential, chain.events ?? [], chain.identity);
|
|
11752
12072
|
}
|
|
11753
12073
|
/**
|
|
11754
12074
|
* Build every chain that scores one task.
|
|
@@ -11772,6 +12092,11 @@ var WorkBuddyScheduler = class {
|
|
|
11772
12092
|
if (this.delayMs > 0 && !this.stopped) await sleep(2e3);
|
|
11773
12093
|
return [appearanceChain()];
|
|
11774
12094
|
case "Library_read": return [libraryReadChain()];
|
|
12095
|
+
case "skill_share": {
|
|
12096
|
+
const skill = (await this.client.shareableSkills(credential))[0];
|
|
12097
|
+
if (skill === void 0) throw new Error("skill_share: no public marketplace skill available");
|
|
12098
|
+
return [skillShareLinkChain(skill, (await this.client.createSkillShareLink(credential, skill)).shareCode)];
|
|
12099
|
+
}
|
|
11775
12100
|
case "skill_1": {
|
|
11776
12101
|
const chat = await this.client.openConversation(credential);
|
|
11777
12102
|
if (chat === void 0) throw new Error("skill_1: no server conversation");
|
|
@@ -11935,16 +12260,38 @@ var WorkBuddyScheduler = class {
|
|
|
11935
12260
|
if (open.length > 0) await this.client.acceptTasks(credential, open);
|
|
11936
12261
|
const refreshed = await this.client.listTasks(credential);
|
|
11937
12262
|
const claimable = refreshed.filter((task) => task.claimable && !task.locked);
|
|
11938
|
-
|
|
11939
|
-
let
|
|
11940
|
-
let
|
|
12263
|
+
const adoption = this.buddyAdoptionReceipts.get(account.id);
|
|
12264
|
+
let credit = adoption?.credit ?? 0;
|
|
12265
|
+
let energy = adoption?.energy ?? 0;
|
|
12266
|
+
let claimed = adoption === void 0 ? 0 : 1;
|
|
11941
12267
|
const titles = [];
|
|
11942
12268
|
const items = [];
|
|
11943
|
-
|
|
11944
|
-
title:
|
|
11945
|
-
status: "
|
|
11946
|
-
|
|
12269
|
+
if (adoption !== void 0) items.push({
|
|
12270
|
+
title: "Buddy 领养奖励",
|
|
12271
|
+
status: "claimed",
|
|
12272
|
+
...adoption.credit > 0 ? { credit: adoption.credit } : {},
|
|
12273
|
+
...adoption.energy > 0 ? { energy: adoption.energy } : {}
|
|
11947
12274
|
});
|
|
12275
|
+
for (const task of refreshed) {
|
|
12276
|
+
const title = task.title === "" ? task.taskCode : task.title;
|
|
12277
|
+
if (task.claimed) items.push({
|
|
12278
|
+
title,
|
|
12279
|
+
status: "already"
|
|
12280
|
+
});
|
|
12281
|
+
else if (!task.claimable && this.eventFailures.get(account.id)?.has(task.taskCode)) items.push({
|
|
12282
|
+
title,
|
|
12283
|
+
status: "failed",
|
|
12284
|
+
note: "automatic completion failed"
|
|
12285
|
+
});
|
|
12286
|
+
else if (task.locked || !task.claimable) {
|
|
12287
|
+
const note = task.locked ? "locked" : task.acceptStatus === "not_accepted" ? "not accepted" : Object.hasOwn(EVENT_CHAIN_BUILDERS, task.taskCode) ? "not scored yet" : "not covered by automation";
|
|
12288
|
+
items.push({
|
|
12289
|
+
title,
|
|
12290
|
+
status: "skipped",
|
|
12291
|
+
note
|
|
12292
|
+
});
|
|
12293
|
+
}
|
|
12294
|
+
}
|
|
11948
12295
|
for (const task of claimable) {
|
|
11949
12296
|
if (this.stopped) break;
|
|
11950
12297
|
const reward = await this.client.claimTaskReward(credential, task.taskCode);
|
|
@@ -11970,6 +12317,7 @@ var WorkBuddyScheduler = class {
|
|
|
11970
12317
|
}
|
|
11971
12318
|
if (this.delayMs > 0 && !this.stopped) await sleep(this.delayMs);
|
|
11972
12319
|
}
|
|
12320
|
+
this.buddyAdoptionReceipts.delete(account.id);
|
|
11973
12321
|
return {
|
|
11974
12322
|
claimed,
|
|
11975
12323
|
credit,
|