dsh-supermesh 0.0.4 → 0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -19,6 +19,9 @@
|
|
|
19
19
|
|
|
20
20
|
收到触发后按这个顺序走,**每一步都可能提前结束**:
|
|
21
21
|
|
|
22
|
+
0. **这条消息是在叫你吗** —— 看邮件里的 `mentioned`。`mentioned: no` 的消息(别人开的 issue、别人的评论)
|
|
23
|
+
只是时间线记录:可以判一次话题归属,但**不建票、不派工、不叫醒任何人**。
|
|
24
|
+
只有 `mentioned: yes`、这条话题已经挂在票上(订阅跟进),或者人直接对你说「做」,才算开工请求。
|
|
22
25
|
1. **已经是老话题了吗** —— 用 `list_ticket` 看这条话题是否已挂在某张票上。
|
|
23
26
|
挂了就别再判一次,那条触发会自动进对应项目的收件箱。
|
|
24
27
|
2. **需要开新票吗** —— 消息明确指向某张已有票 → `attach_thread_to_ticket`,
|
package/assets/prompts/worker.md
CHANGED
|
@@ -12,6 +12,10 @@ GitHub 用 `gh pr create`,GitLab 用 `glab mr create` 发布。
|
|
|
12
12
|
发布前检查当前分支、origin 和已有 PR/MR。**复用当前票分支的已有结果,避免重复发布。**
|
|
13
13
|
不要自动纳入不明文件;仅提交本任务明确暂存的改动,发布前确认本任务改动已全部提交。
|
|
14
14
|
|
|
15
|
+
**推送前先确认 PR 还开着。** 用 `gh pr view <number> --json state,mergedAt`(GitLab 用 `glab mr view`)确认状态。
|
|
16
|
+
已合并或已关闭说明这张票已经结束、授权已经收回:立刻停手,不要推送、不要改基到新 main、不要另开 PR。
|
|
17
|
+
`report` 报「工单已结束」是同一个信号,收到就停,不要再做任何外部动作。
|
|
18
|
+
|
|
15
19
|
PR 描述里的正式 issue 链接必须从 `read_channel` 的 `ticket/<当前任务号>` 及关联话题上下文取得,不得猜造。
|
|
16
20
|
|
|
17
21
|
## 汇报
|
|
@@ -1588,6 +1588,8 @@ var agent_model_catalog_get_default = defineHandler(async () => {
|
|
|
1588
1588
|
return getServerContext(server).sessionController.modelCatalog();
|
|
1589
1589
|
});
|
|
1590
1590
|
const DSH_PLUGIN_HOME = `${process.env.DSH_HOME ?? join(homedir(), ".dsh")}/.supermesh`;
|
|
1591
|
+
/** 代理工作区:角色会话的 cwd 与官方工作区条目都只指向这里,插件状态留在上一层。 */
|
|
1592
|
+
const DSH_WORKSPACE_HOME = join(DSH_PLUGIN_HOME, "workspace");
|
|
1591
1593
|
// src/storage/index.ts
|
|
1592
1594
|
const storage = createStorage({ driver: fs({
|
|
1593
1595
|
atomic: true,
|
|
@@ -1717,7 +1719,9 @@ var agent_model_get_default = defineHandler(async () => (await setting.load()).m
|
|
|
1717
1719
|
// src/service/role-model.ts
|
|
1718
1720
|
const roleModel = defineService({
|
|
1719
1721
|
async resolve(model) {
|
|
1720
|
-
const
|
|
1722
|
+
const llm = getServerContext(server).get("llm");
|
|
1723
|
+
if (!llm) throw new Error("llm_unavailable");
|
|
1724
|
+
const value = await llm.resolveCallConfig({
|
|
1721
1725
|
provider: model.provider,
|
|
1722
1726
|
model: model.model,
|
|
1723
1727
|
...model.reasoningEffort ? { reasoningEffort: ReasoningEffortId(model.reasoningEffort) } : {}
|
|
@@ -1766,7 +1770,7 @@ const roleModel = defineService({
|
|
|
1766
1770
|
];
|
|
1767
1771
|
return () => disposers.forEach((dispose) => dispose());
|
|
1768
1772
|
});
|
|
1769
|
-
await
|
|
1773
|
+
await getServerContext(server).get("sessionPersistence")?.flush();
|
|
1770
1774
|
}
|
|
1771
1775
|
});
|
|
1772
1776
|
// src/server/routes/agent.model.patch.ts
|
|
@@ -1898,6 +1902,12 @@ const session = defineService({
|
|
|
1898
1902
|
registered.delete(id);
|
|
1899
1903
|
};
|
|
1900
1904
|
},
|
|
1905
|
+
/** 同步判定一个 Agent 是不是插件的四个角色会话:只按预设判断,不读会话历史。 */
|
|
1906
|
+
roleOf(agent) {
|
|
1907
|
+
const preset = getServerContext(server).agentPresets.composedPreset(agent.ctx);
|
|
1908
|
+
if (!preset || !registered.has(preset)) return null;
|
|
1909
|
+
return Object.keys(presets$1).find((role) => presets$1[role] === preset) ?? null;
|
|
1910
|
+
},
|
|
1901
1911
|
async attach(agent) {
|
|
1902
1912
|
const ctx = getServerContext(server);
|
|
1903
1913
|
const preset = ctx.agentPresets.composedPreset(agent.ctx);
|
|
@@ -2079,8 +2089,10 @@ const session = defineService({
|
|
|
2079
2089
|
};
|
|
2080
2090
|
},
|
|
2081
2091
|
workspace: singlet("session:workspace", async () => {
|
|
2082
|
-
|
|
2083
|
-
|
|
2092
|
+
const ctx = getServerContext(server);
|
|
2093
|
+
await mkdir(DSH_WORKSPACE_HOME, { recursive: true });
|
|
2094
|
+
await retireLegacyWorkspace(ctx);
|
|
2095
|
+
return ctx.workspaceRegistry.create(DSH_WORKSPACE_HOME, "代理工作区");
|
|
2084
2096
|
}),
|
|
2085
2097
|
activate: (id) => resolveAgent(id),
|
|
2086
2098
|
async lookup(id) {
|
|
@@ -2144,6 +2156,15 @@ const session = defineService({
|
|
|
2144
2156
|
if ((await session.activity(id)).background) throw new Error("background_stop_pending");
|
|
2145
2157
|
}
|
|
2146
2158
|
});
|
|
2159
|
+
/**
|
|
2160
|
+
* 旧版本把「代理工作区」注册在 `.supermesh` 根本身,那里同时存着插件状态。
|
|
2161
|
+
* 工作区路径不可改,只能删掉这条注册;目录与会话日志都保留,旧会话退化为未分组。
|
|
2162
|
+
*/
|
|
2163
|
+
async function retireLegacyWorkspace(ctx) {
|
|
2164
|
+
const legacy = await realpathNormalize(DSH_PLUGIN_HOME).catch(() => void 0);
|
|
2165
|
+
if (!legacy) return;
|
|
2166
|
+
for (const workspace of ctx.workspaceRegistry.list()) if (workspace.path === legacy) await ctx.workspaceRegistry.delete(workspace.id).catch(() => void 0);
|
|
2167
|
+
}
|
|
2147
2168
|
async function bindWorkspace(id, cwd) {
|
|
2148
2169
|
const ctx = getServerContext(server);
|
|
2149
2170
|
const sid = SessionId(id);
|
|
@@ -2151,6 +2172,7 @@ async function bindWorkspace(id, cwd) {
|
|
|
2151
2172
|
if (!directory) return;
|
|
2152
2173
|
const actual = await realpathNormalize(directory).catch(() => void 0);
|
|
2153
2174
|
if (!actual) return;
|
|
2175
|
+
if (actual === await realpathNormalize(DSH_PLUGIN_HOME).catch(() => void 0)) return;
|
|
2154
2176
|
for (const workspace of [await session.workspace(), ...ctx.workspaceRegistry.list()]) {
|
|
2155
2177
|
if (workspace.sessionIds.includes(sid)) return;
|
|
2156
2178
|
if (workspace.path !== actual) continue;
|
|
@@ -2200,7 +2222,21 @@ const inbox = defineService({
|
|
|
2200
2222
|
if (!identity) return null;
|
|
2201
2223
|
const scope = scopeOf(identity);
|
|
2202
2224
|
if (!scope) return null;
|
|
2203
|
-
const
|
|
2225
|
+
const rows = await db.inbox.listScoped(scope, includeChannel);
|
|
2226
|
+
const triggers = /* @__PURE__ */ new Map();
|
|
2227
|
+
for (const triggerId of new Set(rows.map((message) => message.triggerId).filter(Boolean))) {
|
|
2228
|
+
const trigger = await db.trigger.findById(triggerId);
|
|
2229
|
+
if (trigger) triggers.set(triggerId, {
|
|
2230
|
+
kind: trigger.kind,
|
|
2231
|
+
actorName: trigger.actorName,
|
|
2232
|
+
human: Boolean(trigger.human),
|
|
2233
|
+
mentioned: Boolean(trigger.mentioned)
|
|
2234
|
+
});
|
|
2235
|
+
}
|
|
2236
|
+
const messages = rows.map((message) => ({
|
|
2237
|
+
...message,
|
|
2238
|
+
...message.triggerId && triggers.has(message.triggerId) ? { trigger: triggers.get(message.triggerId) } : {}
|
|
2239
|
+
}));
|
|
2204
2240
|
const projects = (await db.project.listAll()).filter((project) => project.enabled && (identity.role === "main" || project.id === identity.projectId)).map(({ id, name, directory, remoteUrl }) => ({
|
|
2205
2241
|
id,
|
|
2206
2242
|
name,
|
|
@@ -2291,11 +2327,13 @@ const inbox = defineService({
|
|
|
2291
2327
|
continue;
|
|
2292
2328
|
}
|
|
2293
2329
|
if ((await session.activity(id)).running || stopped$2) continue;
|
|
2330
|
+
const trigger = message.triggerId ? await db.trigger.findById(message.triggerId) : void 0;
|
|
2294
2331
|
await session.send(id, [
|
|
2295
2332
|
message.title ?? "",
|
|
2296
2333
|
`[Inbox ${message.id}]`,
|
|
2297
2334
|
message.triggerId ? `triggerId: ${message.triggerId}` : "",
|
|
2298
2335
|
message.threadId ? `threadId: ${message.threadId}` : "",
|
|
2336
|
+
trigger ? `actor: ${trigger.actorName ?? "unknown"} human: ${trigger.human ? "yes" : "no"} mentioned: ${trigger.mentioned ? "yes" : "no"}` : "",
|
|
2299
2337
|
message.message
|
|
2300
2338
|
].filter(Boolean).join(String.fromCharCode(10)), "queue", requestId);
|
|
2301
2339
|
await db.inbox.resetDelivery(message.id);
|
|
@@ -2404,7 +2442,7 @@ var ask__id__answer_post_default = defineHandler(async (event) => {
|
|
|
2404
2442
|
const directory = join(DSH_PLUGIN_HOME, "cli");
|
|
2405
2443
|
const bin = join(directory, "bin");
|
|
2406
2444
|
const gitconfig = join(directory, "gitconfig");
|
|
2407
|
-
const
|
|
2445
|
+
const tokens = [
|
|
2408
2446
|
"GH_TOKEN",
|
|
2409
2447
|
"GITHUB_TOKEN",
|
|
2410
2448
|
"GH_ENTERPRISE_TOKEN",
|
|
@@ -2412,23 +2450,16 @@ const removed = [
|
|
|
2412
2450
|
"GITLAB_TOKEN",
|
|
2413
2451
|
"GLAB_TOKEN",
|
|
2414
2452
|
"OAUTH_TOKEN",
|
|
2415
|
-
"CI_JOB_TOKEN"
|
|
2416
|
-
|
|
2417
|
-
|
|
2418
|
-
"GIT_INDEX_FILE",
|
|
2419
|
-
"GIT_PREFIX",
|
|
2420
|
-
"GIT_COMMON_DIR",
|
|
2421
|
-
"GIT_OBJECT_DIRECTORY",
|
|
2422
|
-
"GIT_ALTERNATE_OBJECT_DIRECTORIES",
|
|
2423
|
-
"GIT_NAMESPACE",
|
|
2424
|
-
"GIT_CONFIG_COUNT",
|
|
2425
|
-
"GIT_CONFIG_PARAMETERS",
|
|
2453
|
+
"CI_JOB_TOKEN"
|
|
2454
|
+
];
|
|
2455
|
+
const identities = [
|
|
2426
2456
|
"GIT_AUTHOR_NAME",
|
|
2427
2457
|
"GIT_AUTHOR_EMAIL",
|
|
2428
2458
|
"GIT_COMMITTER_NAME",
|
|
2429
|
-
"GIT_COMMITTER_EMAIL"
|
|
2430
|
-
"SSH_ASKPASS"
|
|
2459
|
+
"GIT_COMMITTER_EMAIL"
|
|
2431
2460
|
];
|
|
2461
|
+
/** 角色会话标记:由 `ctx.shellEnv` 按调用会话注入,shim 只在这个变量存在时才切到 bot 身份。 */
|
|
2462
|
+
const ROLE_MARKER = "DSH_SUPERMESH_ROLE";
|
|
2432
2463
|
let restore;
|
|
2433
2464
|
let writing$1 = Promise.resolve();
|
|
2434
2465
|
let basePath = "";
|
|
@@ -2437,21 +2468,22 @@ const shell = defineService({
|
|
|
2437
2468
|
if (restore) throw new Error("shell_already_started");
|
|
2438
2469
|
basePath = (process.env.PATH ?? "").split(delimiter).filter((path) => resolve(path).toLowerCase() !== resolve(bin).toLowerCase()).join(delimiter);
|
|
2439
2470
|
await refresh();
|
|
2440
|
-
const
|
|
2441
|
-
|
|
2442
|
-
|
|
2443
|
-
|
|
2444
|
-
|
|
2445
|
-
|
|
2446
|
-
|
|
2447
|
-
|
|
2448
|
-
|
|
2449
|
-
const
|
|
2450
|
-
|
|
2451
|
-
|
|
2471
|
+
const release = getServerContext(server).get("shellEnv")?.register({
|
|
2472
|
+
name: "supermesh-role",
|
|
2473
|
+
variables: { DSH_SUPERMESH_ROLE: { description: "Supermesh 角色会话标记,决定 gh / glab / git 是否使用插件的机器人身份。" } },
|
|
2474
|
+
resolve: (execution) => {
|
|
2475
|
+
const agent = execution.agent;
|
|
2476
|
+
const role = agent ? session.roleOf(agent) : null;
|
|
2477
|
+
return role ? { DSH_SUPERMESH_ROLE: role } : {};
|
|
2478
|
+
}
|
|
2479
|
+
});
|
|
2480
|
+
const previous = process.env.PATH;
|
|
2481
|
+
process.env.PATH = [bin, basePath].join(delimiter);
|
|
2482
|
+
restore = () => {
|
|
2483
|
+
release?.();
|
|
2484
|
+
if (previous === void 0) delete process.env.PATH;
|
|
2485
|
+
else process.env.PATH = previous;
|
|
2452
2486
|
};
|
|
2453
|
-
apply(values);
|
|
2454
|
-
restore = () => apply(previous);
|
|
2455
2487
|
return async () => {
|
|
2456
2488
|
const release = restore;
|
|
2457
2489
|
restore = void 0;
|
|
@@ -2460,10 +2492,7 @@ const shell = defineService({
|
|
|
2460
2492
|
};
|
|
2461
2493
|
},
|
|
2462
2494
|
commandEnvironment() {
|
|
2463
|
-
return {
|
|
2464
|
-
...process.env,
|
|
2465
|
-
...restore ? { PATH: basePath } : {}
|
|
2466
|
-
};
|
|
2495
|
+
return { ...process.env };
|
|
2467
2496
|
},
|
|
2468
2497
|
refresh() {
|
|
2469
2498
|
if (!restore) return Promise.resolve();
|
|
@@ -2503,32 +2532,43 @@ async function refresh() {
|
|
|
2503
2532
|
git_protocol: "https"
|
|
2504
2533
|
} } : {}
|
|
2505
2534
|
}));
|
|
2535
|
+
const shellPath = shellPathOf(basePath);
|
|
2506
2536
|
for (const cli of ["gh", "glab"]) {
|
|
2507
2537
|
const executable = await nativeCli(cli);
|
|
2508
2538
|
const configKey = cli === "gh" ? "GH_CONFIG_DIR" : "GLAB_CONFIG_DIR";
|
|
2509
2539
|
const hostKey = cli === "gh" ? "GH_HOST" : "GITLAB_HOST";
|
|
2510
2540
|
const host = cli === "gh" ? "github.com" : gitlabHost;
|
|
2511
|
-
const shellPath = shellPathOf(basePath);
|
|
2512
2541
|
const keyringKeys = cli === "glab" ? ["GLAB_USE_KEYRING"] : [];
|
|
2513
|
-
|
|
2514
|
-
|
|
2515
|
-
`unset ${removed.filter((key) => /TOKEN/.test(key)).join(" ")}`,
|
|
2542
|
+
const botEnv = [
|
|
2543
|
+
...tokens.map((key) => `unset ${key}`),
|
|
2516
2544
|
`export PATH=${quote(shellPath)}`,
|
|
2517
2545
|
`export ${configKey}=${quote(join(directory, cli).replaceAll("\\", "/"))}`,
|
|
2518
2546
|
`export ${hostKey}=${quote(host)}`,
|
|
2519
|
-
...keyringKeys.map((key) => `export ${key}=false`)
|
|
2547
|
+
...keyringKeys.map((key) => `export ${key}=false`)
|
|
2548
|
+
];
|
|
2549
|
+
await own(join(bin, cli), [
|
|
2550
|
+
"#!/bin/sh",
|
|
2551
|
+
`if [ -z "$${ROLE_MARKER}" ]; then exec ${executable ? quote(executable.replaceAll("\\", "/")) : "exit 127"} "$@"; fi`,
|
|
2552
|
+
...botEnv,
|
|
2520
2553
|
executable ? `exec ${quote(executable.replaceAll("\\", "/"))} "$@"` : `echo '${cli} is not installed' >&2; exit 127`,
|
|
2521
2554
|
""
|
|
2522
2555
|
].join("\n"), 448);
|
|
2523
2556
|
const cmd = (value) => value.replaceAll("%", "%%");
|
|
2524
|
-
|
|
2525
|
-
|
|
2526
|
-
"setlocal",
|
|
2527
|
-
...removed.filter((key) => /TOKEN/.test(key)).map((key) => `set "${key}="`),
|
|
2557
|
+
const botCmd = [
|
|
2558
|
+
...tokens.map((key) => `set "${key}="`),
|
|
2528
2559
|
`set "PATH=${cmd(basePath)}"`,
|
|
2529
2560
|
`set "${configKey}=${cmd(join(directory, cli))}"`,
|
|
2530
2561
|
`set "${hostKey}=${host}"`,
|
|
2531
|
-
...keyringKeys.map((key) => `set "${key}=false"`)
|
|
2562
|
+
...keyringKeys.map((key) => `set "${key}=false"`)
|
|
2563
|
+
];
|
|
2564
|
+
await own(join(bin, `${cli}.cmd`), [
|
|
2565
|
+
"@echo off",
|
|
2566
|
+
"setlocal",
|
|
2567
|
+
`if not defined ${ROLE_MARKER} goto plain`,
|
|
2568
|
+
...botCmd,
|
|
2569
|
+
executable ? `"${cmd(executable)}" %*` : `echo ${cli} is not installed 1>&2 & exit /b 127`,
|
|
2570
|
+
"exit /b %errorlevel%",
|
|
2571
|
+
":plain",
|
|
2532
2572
|
executable ? `"${cmd(executable)}" %*` : `echo ${cli} is not installed 1>&2 & exit /b 127`,
|
|
2533
2573
|
"exit /b %errorlevel%",
|
|
2534
2574
|
""
|
|
@@ -2538,25 +2578,61 @@ async function refresh() {
|
|
|
2538
2578
|
const escaping = [
|
|
2539
2579
|
"GH_CONFIG_DIR",
|
|
2540
2580
|
"GH_HOST",
|
|
2541
|
-
...
|
|
2581
|
+
...tokens
|
|
2542
2582
|
];
|
|
2543
2583
|
await own(join(bin, "gh-default"), [
|
|
2544
2584
|
"#!/bin/sh",
|
|
2545
|
-
`
|
|
2546
|
-
`
|
|
2585
|
+
`if [ -z "$${ROLE_MARKER}" ]; then exec ${nativeGh ? quote(nativeGh.replaceAll("\\", "/")) : "exit 127"} "$@"; fi`,
|
|
2586
|
+
...escaping.map((key) => `unset ${key}`),
|
|
2587
|
+
`export PATH=${quote(shellPath)}`,
|
|
2547
2588
|
nativeGh ? `exec ${quote(nativeGh.replaceAll("\\", "/"))} "$@"` : "echo gh is not installed >&2; exit 127",
|
|
2548
2589
|
""
|
|
2549
2590
|
].join("\n"), 448);
|
|
2550
2591
|
await own(join(bin, "gh-default.cmd"), [
|
|
2551
2592
|
"@echo off",
|
|
2552
2593
|
"setlocal",
|
|
2594
|
+
`if not defined ${ROLE_MARKER} goto plain`,
|
|
2553
2595
|
...escaping.map((key) => `set "${key}="`),
|
|
2554
2596
|
`set "PATH=${basePath.replaceAll("%", "%%")}"`,
|
|
2555
2597
|
nativeGh ? `"${nativeGh.replaceAll("%", "%%")}" %*` : "echo gh is not installed 1>&2 & exit /b 127",
|
|
2556
2598
|
"exit /b %errorlevel%",
|
|
2599
|
+
":plain",
|
|
2600
|
+
nativeGh ? `"${nativeGh.replaceAll("%", "%%")}" %*` : "echo gh is not installed 1>&2 & exit /b 127",
|
|
2601
|
+
"exit /b %errorlevel%",
|
|
2557
2602
|
""
|
|
2558
2603
|
].join("\r\n"), 448);
|
|
2604
|
+
const nativeGit = await nativeCli("git");
|
|
2559
2605
|
const gitQuote = (value) => JSON.stringify(value);
|
|
2606
|
+
const gitEnv = [
|
|
2607
|
+
...identities.map((key) => `unset ${key}`),
|
|
2608
|
+
`export GIT_CONFIG_GLOBAL=${quote(gitconfig.replaceAll("\\", "/"))}`,
|
|
2609
|
+
"export GIT_CONFIG_NOSYSTEM=1",
|
|
2610
|
+
"export GIT_ASKPASS=",
|
|
2611
|
+
"export GIT_TERMINAL_PROMPT=0"
|
|
2612
|
+
];
|
|
2613
|
+
await own(join(bin, "git"), [
|
|
2614
|
+
"#!/bin/sh",
|
|
2615
|
+
`if [ -z "$${ROLE_MARKER}" ]; then exec ${nativeGit ? quote(nativeGit.replaceAll("\\", "/")) : "exit 127"} "$@"; fi`,
|
|
2616
|
+
...gitEnv,
|
|
2617
|
+
nativeGit ? `exec ${quote(nativeGit.replaceAll("\\", "/"))} "$@"` : "echo git is not installed >&2; exit 127",
|
|
2618
|
+
""
|
|
2619
|
+
].join("\n"), 448);
|
|
2620
|
+
await own(join(bin, "git.cmd"), [
|
|
2621
|
+
"@echo off",
|
|
2622
|
+
"setlocal",
|
|
2623
|
+
`if not defined ${ROLE_MARKER} goto plain`,
|
|
2624
|
+
...identities.map((key) => `set "${key}="`),
|
|
2625
|
+
`set "GIT_CONFIG_GLOBAL=${gitconfig.replaceAll("%", "%%")}"`,
|
|
2626
|
+
"set \"GIT_CONFIG_NOSYSTEM=1\"",
|
|
2627
|
+
"set \"GIT_ASKPASS=\"",
|
|
2628
|
+
"set \"GIT_TERMINAL_PROMPT=0\"",
|
|
2629
|
+
nativeGit ? `"${nativeGit.replaceAll("%", "%%")}" %*` : "echo git is not installed 1>&2 & exit /b 127",
|
|
2630
|
+
"exit /b %errorlevel%",
|
|
2631
|
+
":plain",
|
|
2632
|
+
nativeGit ? `"${nativeGit.replaceAll("%", "%%")}" %*` : "echo git is not installed 1>&2 & exit /b 127",
|
|
2633
|
+
"exit /b %errorlevel%",
|
|
2634
|
+
""
|
|
2635
|
+
].join("\r\n"), 448);
|
|
2560
2636
|
const cliPath = (cli) => quote(join(bin, cli).replaceAll("\\", "/"));
|
|
2561
2637
|
const lines = [
|
|
2562
2638
|
"[user]",
|
|
@@ -2682,14 +2758,14 @@ const devops = defineService({
|
|
|
2682
2758
|
},
|
|
2683
2759
|
save(kind, patch) {
|
|
2684
2760
|
return channel.serialize(() => save(kind, patch)).then(async (view) => {
|
|
2685
|
-
const { shell } = await import("./shell-
|
|
2761
|
+
const { shell } = await import("./shell-DqAUjFxq.js");
|
|
2686
2762
|
await shell.refresh();
|
|
2687
2763
|
return view;
|
|
2688
2764
|
});
|
|
2689
2765
|
},
|
|
2690
2766
|
removeCredentials(kind) {
|
|
2691
2767
|
return channel.serialize(() => removeCredentials(kind)).then(async (view) => {
|
|
2692
|
-
const { shell } = await import("./shell-
|
|
2768
|
+
const { shell } = await import("./shell-DqAUjFxq.js");
|
|
2693
2769
|
await shell.refresh();
|
|
2694
2770
|
return view;
|
|
2695
2771
|
});
|
|
@@ -3967,7 +4043,15 @@ const worker = defineService({
|
|
|
3967
4043
|
for (const worker of await db.worker.listRunning()) {
|
|
3968
4044
|
if (stopped) break;
|
|
3969
4045
|
const ticket = await db.ticket.findById(worker.ticketId);
|
|
3970
|
-
if (!ticket
|
|
4046
|
+
if (!ticket) {
|
|
4047
|
+
await db.worker.end(worker.id, "stopped", (/* @__PURE__ */ new Date()).toISOString());
|
|
4048
|
+
continue;
|
|
4049
|
+
}
|
|
4050
|
+
if (ticket.status === "done" || ticket.status === "cancelled") {
|
|
4051
|
+
await session.send(worker.id, `票 ${ticket.id} 已${ticket.status === "done" ? "完成" : "取消"},本次授权已收回:立即停手,不要再提交、推送或开 PR。`, "interrupt").catch(() => void 0);
|
|
4052
|
+
await db.worker.end(worker.id, "stopped", (/* @__PURE__ */ new Date()).toISOString());
|
|
4053
|
+
continue;
|
|
4054
|
+
}
|
|
3971
4055
|
if (ticket.prState === "merged" || ticket.prState === "closed") {
|
|
3972
4056
|
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
3973
4057
|
await db.worker.end(worker.id, "stopped", now);
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as project, c as shell, d as singlet, f as setting, g as db, h as channelProxyEnvironment, i as archive, l as inbox, m as DSH_PLUGIN_HOME, n as server, o as worktree, p as defineService, r as worker$1, s as devops, t as channel, u as session } from "./channel-
|
|
1
|
+
import { a as project, c as shell, d as singlet, f as setting, g as db, h as channelProxyEnvironment, i as archive, l as inbox, m as DSH_PLUGIN_HOME, n as server, o as worktree, p as defineService, r as worker$1, s as devops, t as channel, u as session } from "./channel-ChqKKcYq.js";
|
|
2
2
|
import { existsSync, readFileSync } from "node:fs";
|
|
3
3
|
import { dirname, join, resolve } from "node:path";
|
|
4
4
|
import { fileURLToPath } from "node:url";
|
|
@@ -267,6 +267,18 @@ async function latestVersion(threadId) {
|
|
|
267
267
|
async function markThread(exec, threadId) {
|
|
268
268
|
observe(exec, threadId, await latestVersion(threadId));
|
|
269
269
|
}
|
|
270
|
+
// src/channel/_shared/admission.ts
|
|
271
|
+
function acceptsChannelTrigger(input) {
|
|
272
|
+
if (!input.human || input.historical && !input.subscribed) return false;
|
|
273
|
+
return input.subscribed || input.admin && (input.kind === "open" || input.mentioned) && (!input.ignored || input.mentioned);
|
|
274
|
+
}
|
|
275
|
+
/**
|
|
276
|
+
* 进流程不等于被点名。没 @ bot 的消息只是时间线记录:可以分诊,但不建票、不派工、也不在渠道上发言。
|
|
277
|
+
* 只有明确 @、或者这条话题已经被票订阅(人在跟进已有任务)才算在跟 bot 说话。
|
|
278
|
+
*/
|
|
279
|
+
function addressedToBot(input) {
|
|
280
|
+
return input.mentioned || input.subscribed;
|
|
281
|
+
}
|
|
270
282
|
// src/channel/_shared/error.ts
|
|
271
283
|
var ChannelError = class extends Error {
|
|
272
284
|
code;
|
|
@@ -534,11 +546,6 @@ const resource$1 = defineService({
|
|
|
534
546
|
};
|
|
535
547
|
}
|
|
536
548
|
});
|
|
537
|
-
// src/channel/_shared/admission.ts
|
|
538
|
-
function acceptsChannelTrigger(input) {
|
|
539
|
-
if (!input.human || input.historical && !input.subscribed) return false;
|
|
540
|
-
return input.subscribed || input.admin && (input.kind === "open" || input.mentioned) && (!input.ignored || input.mentioned);
|
|
541
|
-
}
|
|
542
549
|
// src/service/courier.ts
|
|
543
550
|
/** 没有活票的话题,最后一次活动超过这个时长就不再轮询(官方 POLL_HORIZON_MS)。 */
|
|
544
551
|
const POLL_HORIZON_MS = 12096e5;
|
|
@@ -2158,6 +2165,11 @@ const reply_channel = defineTool({
|
|
|
2158
2165
|
status: "suppressed",
|
|
2159
2166
|
reason: "another_role_already_replied"
|
|
2160
2167
|
});
|
|
2168
|
+
const subscribed = (await db.ticketThread.listTicketIds(thread.id)).length > 0;
|
|
2169
|
+
if (!addressedToBot({
|
|
2170
|
+
mentioned: Boolean(trigger.mentioned),
|
|
2171
|
+
subscribed
|
|
2172
|
+
})) throw new Error("这条消息没有 @ bot,也不是已订阅话题上的跟进:只做分诊记录,不对外发言");
|
|
2161
2173
|
const ticketId = identity.ticketId ?? null;
|
|
2162
2174
|
const row = await db.inbox.enqueue({
|
|
2163
2175
|
id: replyKey(trigger.id, args.text),
|
|
@@ -2207,7 +2219,7 @@ const inbox_list = defineTool({
|
|
|
2207
2219
|
});
|
|
2208
2220
|
const read_mailbox = defineTool({
|
|
2209
2221
|
name: "read_mailbox",
|
|
2210
|
-
description: "读取当前角色未处理邮件,以及可用项目的 id、仓库地址和本地路径。可传 ids
|
|
2222
|
+
description: "读取当前角色未处理邮件,以及可用项目的 id、仓库地址和本地路径。可传 ids 一次读取指定多条邮件。渠道邮件带 trigger 事实(actor / human / mentioned):mentioned=no 只是时间线记录,不是开工请求。读取标为已读,处理完用 inbox_kill,ask 必须用 answer。",
|
|
2211
2223
|
parameters: { ids: {
|
|
2212
2224
|
type: "array",
|
|
2213
2225
|
items: { type: "string" },
|
|
@@ -2640,7 +2652,7 @@ const create_worker = defineTool({
|
|
|
2640
2652
|
});
|
|
2641
2653
|
const send = defineTool({
|
|
2642
2654
|
name: "send",
|
|
2643
|
-
description: "直接将完整消息交给活跃 Worker,跳过业务排队;只有需要立刻止损才用 interrupt。Worker
|
|
2655
|
+
description: "直接将完整消息交给活跃 Worker,跳过业务排队;只有需要立刻止损才用 interrupt。Worker 没有收件箱。票已结束不拦,Worker 还活着就能收到。",
|
|
2644
2656
|
parameters: {
|
|
2645
2657
|
workerId: {
|
|
2646
2658
|
type: "string",
|
|
@@ -2681,7 +2693,6 @@ const send = defineTool({
|
|
|
2681
2693
|
const ticket = await db.ticket.findById(worker.ticketId);
|
|
2682
2694
|
if (!ticket || ticket.projectId !== identity.projectId) throw new Error("Worker 不属于当前项目");
|
|
2683
2695
|
if (worker.status === "ended") throw new Error("Worker 已结束");
|
|
2684
|
-
if (ticket.status === "done" || ticket.status === "cancelled") throw new Error("工单已结束");
|
|
2685
2696
|
if (!await session.lookup(worker.id)) throw new Error("Worker 未在运行时加载、已归档或不属于 Supermesh;不能直接发送");
|
|
2686
2697
|
if (args.mode === "reply") {
|
|
2687
2698
|
const asks = (await db.inbox.listByTicket(ticket.id)).filter((row) => row.workerId === worker.id && row.kind === "ask" && row.status === "pending");
|
|
@@ -2736,7 +2747,7 @@ const view = defineTool({
|
|
|
2736
2747
|
});
|
|
2737
2748
|
const cancel = defineTool({
|
|
2738
2749
|
name: "cancel",
|
|
2739
|
-
description: "中止 Worker
|
|
2750
|
+
description: "中止 Worker 当前回合。那一次回合一并作废。票已结束也能停,只看 Worker 是否还活着。",
|
|
2740
2751
|
parameters: {
|
|
2741
2752
|
workerId: {
|
|
2742
2753
|
type: "string",
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { c as shell } from "./channel-ChqKKcYq.js";
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-supermesh",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.5",
|
|
5
5
|
"description": "把 GitHub / GitLab 的 issue、PR 与评论变成任务,交给各自 worktree 里的 Worker 改代码、开 PR,再由上级代理验收收尾。",
|
|
6
6
|
"author": "Hairy <wwu710632@gmail.com>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -120,6 +120,7 @@
|
|
|
120
120
|
"@deepseek-ai/dsh-session-persistence": "0.2.2-rc.2",
|
|
121
121
|
"@deepseek-ai/dsh-session-projection": "0.2.2-rc.2",
|
|
122
122
|
"@deepseek-ai/dsh-session-query": "0.0.1-rc.1",
|
|
123
|
+
"@deepseek-ai/dsh-shell-env": "0.2.2-rc.2",
|
|
123
124
|
"@deepseek-ai/dsh-skill-filesystem": "0.2.2-rc.2",
|
|
124
125
|
"@deepseek-ai/dsh-tools": "0.2.2-rc.2",
|
|
125
126
|
"@deepseek-ai/dsh-user-approval": "0.2.2-rc.2",
|
package/dist/shell-DzrnBk4C.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { c as shell } from "./channel-C1d93AhN.js";
|