dsh-supermesh 0.0.5 → 0.0.6
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/assets/prompts/manager.md +3 -2
- package/assets/prompts/orchestrator.md +5 -3
- package/dist/{channel-ChqKKcYq.js → channel-AKRPqFjp.js} +172 -58
- package/dist/client.cjs +317 -204
- package/dist/client.cjs.map +1 -1
- package/dist/index.js +51 -61
- package/dist/shell-BZBvr4aJ.js +1 -0
- package/package.json +1 -1
- package/dist/shell-DqAUjFxq.js +0 -1
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as project, c as shell, d as
|
|
1
|
+
import { _ as addressedToBot, a as project, b as db, c as shell, d as latestTriggerStrength, f as singlet, g as channelProxyEnvironment, h as DSH_PLUGIN_HOME, i as archive, l as inbox, m as defineService, n as server, o as worktree, p as setting, r as worker$1, s as devops, t as channel, u as session, v as channelTriggerStrength, y as ticketAllowed } from "./channel-AKRPqFjp.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";
|
|
@@ -7,7 +7,7 @@ import { defineTool } from "@deepseek-ai/dsh-tools";
|
|
|
7
7
|
import { createHash, randomUUID } from "node:crypto";
|
|
8
8
|
import { execFile } from "node:child_process";
|
|
9
9
|
import { createRouteDispatcher } from "@deepseek-ai/dsh-http-proxy";
|
|
10
|
-
import { mkdir, readFile, rename
|
|
10
|
+
import { mkdir, readFile, rename, writeFile } from "node:fs/promises";
|
|
11
11
|
import { fetch } from "undici";
|
|
12
12
|
import { Cron } from "croner";
|
|
13
13
|
// src/ai/_shared/prompt-file.ts
|
|
@@ -267,18 +267,6 @@ 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
|
-
}
|
|
282
270
|
// src/channel/_shared/error.ts
|
|
283
271
|
var ChannelError = class extends Error {
|
|
284
272
|
code;
|
|
@@ -637,15 +625,17 @@ const courier = defineService({
|
|
|
637
625
|
});
|
|
638
626
|
const subscriptions = await db.ticketThread.listTicketIds(thread.id);
|
|
639
627
|
const historical = port.createdAt(row) < baseline;
|
|
640
|
-
const
|
|
641
|
-
|
|
628
|
+
const { administrators, inferred } = await setting.load();
|
|
629
|
+
const admin = administrators.some((name) => name.toLowerCase() === actorName.toLowerCase());
|
|
630
|
+
if (!channelTriggerStrength({
|
|
642
631
|
human,
|
|
643
632
|
historical,
|
|
644
633
|
subscribed: subscriptions.length > 0,
|
|
645
634
|
admin,
|
|
646
635
|
mentioned,
|
|
647
636
|
kind,
|
|
648
|
-
ignored: thread.triage === "ignored"
|
|
637
|
+
ignored: thread.triage === "ignored",
|
|
638
|
+
inferred
|
|
649
639
|
})) return;
|
|
650
640
|
const targets = /* @__PURE__ */ new Map();
|
|
651
641
|
for (const ticketId of subscriptions) {
|
|
@@ -2219,7 +2209,7 @@ const inbox_list = defineTool({
|
|
|
2219
2209
|
});
|
|
2220
2210
|
const read_mailbox = defineTool({
|
|
2221
2211
|
name: "read_mailbox",
|
|
2222
|
-
description: "读取当前角色未处理邮件,以及可用项目的 id、仓库地址和本地路径。可传 ids 一次读取指定多条邮件。渠道邮件带 trigger 事实(actor / human / mentioned):
|
|
2212
|
+
description: "读取当前角色未处理邮件,以及可用项目的 id、仓库地址和本地路径。可传 ids 一次读取指定多条邮件。渠道邮件带 trigger 事实(actor / human / mentioned / strength):strength=inferred 只是候选,只能分诊记录,不能建票。读取标为已读,处理完用 inbox_kill,ask 必须用 answer。",
|
|
2223
2213
|
parameters: { ids: {
|
|
2224
2214
|
type: "array",
|
|
2225
2215
|
items: { type: "string" },
|
|
@@ -2672,7 +2662,7 @@ const send = defineTool({
|
|
|
2672
2662
|
"reply"
|
|
2673
2663
|
],
|
|
2674
2664
|
required: true,
|
|
2675
|
-
description: "queue
|
|
2665
|
+
description: "queue 在 Worker 运行中 steer 到最近一步,空闲时开新回合;interrupt 中止当前回合再 steer;reply 回答它的 ask,投递规则同 queue。"
|
|
2676
2666
|
}
|
|
2677
2667
|
},
|
|
2678
2668
|
output: {
|
|
@@ -2694,6 +2684,7 @@ const send = defineTool({
|
|
|
2694
2684
|
if (!ticket || ticket.projectId !== identity.projectId) throw new Error("Worker 不属于当前项目");
|
|
2695
2685
|
if (worker.status === "ended") throw new Error("Worker 已结束");
|
|
2696
2686
|
if (!await session.lookup(worker.id)) throw new Error("Worker 未在运行时加载、已归档或不属于 Supermesh;不能直接发送");
|
|
2687
|
+
let messageId;
|
|
2697
2688
|
if (args.mode === "reply") {
|
|
2698
2689
|
const asks = (await db.inbox.listByTicket(ticket.id)).filter((row) => row.workerId === worker.id && row.kind === "ask" && row.status === "pending");
|
|
2699
2690
|
if (asks.length !== 1 || !db.inbox.owns(asks[0], {
|
|
@@ -2704,12 +2695,9 @@ const send = defineTool({
|
|
|
2704
2695
|
type: "project",
|
|
2705
2696
|
projectId: identity.projectId
|
|
2706
2697
|
}, (/* @__PURE__ */ new Date()).toISOString());
|
|
2707
|
-
await session.send(worker.id, `[Answer ${asks[0].id}] ${args.text}`, "reply", `supermesh:answer:${asks[0].id}`);
|
|
2708
|
-
} else await session.send(worker.id, args.text, args.mode);
|
|
2709
|
-
return JSON.stringify({
|
|
2710
|
-
sent: true,
|
|
2711
|
-
mode: args.mode
|
|
2712
|
-
});
|
|
2698
|
+
messageId = await session.send(worker.id, `[Answer ${asks[0].id}] ${args.text}`, "reply", `supermesh:answer:${asks[0].id}`);
|
|
2699
|
+
} else messageId = await session.send(worker.id, args.text, args.mode === "interrupt" ? "interrupt" : "wake");
|
|
2700
|
+
return JSON.stringify({ messageId });
|
|
2713
2701
|
}
|
|
2714
2702
|
});
|
|
2715
2703
|
const view = defineTool({
|
|
@@ -2747,7 +2735,7 @@ const view = defineTool({
|
|
|
2747
2735
|
});
|
|
2748
2736
|
const cancel = defineTool({
|
|
2749
2737
|
name: "cancel",
|
|
2750
|
-
description: "
|
|
2738
|
+
description: "中断 Worker 当前回合:那一次回合作废,会话不结束,之后还能用 send 继续。票已结束也能停,只看 Worker 是否还活着。",
|
|
2751
2739
|
parameters: {
|
|
2752
2740
|
workerId: {
|
|
2753
2741
|
type: "string",
|
|
@@ -2762,7 +2750,7 @@ const cancel = defineTool({
|
|
|
2762
2750
|
output: {
|
|
2763
2751
|
schema: {
|
|
2764
2752
|
type: "string",
|
|
2765
|
-
description: "
|
|
2753
|
+
description: "是否已受理。"
|
|
2766
2754
|
},
|
|
2767
2755
|
render: (_args, value) => [{
|
|
2768
2756
|
type: "text",
|
|
@@ -2778,48 +2766,41 @@ const cancel = defineTool({
|
|
|
2778
2766
|
if (!ticket || ticket.projectId !== identity.projectId) throw new Error("Worker 不属于当前项目");
|
|
2779
2767
|
if (worker.status === "ended") throw new Error("Worker 已结束");
|
|
2780
2768
|
await session.cancel(worker.id, args.keepInbox);
|
|
2781
|
-
return JSON.stringify({
|
|
2769
|
+
return JSON.stringify({ accepted: true });
|
|
2782
2770
|
}
|
|
2783
2771
|
});
|
|
2784
|
-
const
|
|
2785
|
-
name: "
|
|
2786
|
-
description: "
|
|
2787
|
-
parameters: {
|
|
2788
|
-
workerId: {
|
|
2789
|
-
type: "string",
|
|
2790
|
-
required: true,
|
|
2791
|
-
description: "要改名的 Worker。"
|
|
2792
|
-
},
|
|
2793
|
-
title: {
|
|
2794
|
-
type: "string",
|
|
2795
|
-
required: true,
|
|
2796
|
-
description: "新标题。"
|
|
2797
|
-
}
|
|
2798
|
-
},
|
|
2772
|
+
const list_worker = defineTool({
|
|
2773
|
+
name: "list_worker",
|
|
2774
|
+
description: "列出本项目还没结束的 Worker 和当前回合状态。running 表示正在跑;inactive 表示没有回合在跑,可以 send 继续。",
|
|
2775
|
+
parameters: {},
|
|
2799
2776
|
output: {
|
|
2800
2777
|
schema: {
|
|
2801
2778
|
type: "string",
|
|
2802
|
-
description: "
|
|
2779
|
+
description: "Worker 列表:id、票号、标题、状态。"
|
|
2803
2780
|
},
|
|
2804
2781
|
render: (_args, value) => [{
|
|
2805
2782
|
type: "text",
|
|
2806
2783
|
text: value
|
|
2807
2784
|
}]
|
|
2808
2785
|
},
|
|
2809
|
-
execute: async (
|
|
2786
|
+
execute: async (_args, exec) => {
|
|
2810
2787
|
const identity = await session.resolve(exec.agent?.session.id ?? "");
|
|
2811
2788
|
if (identity?.role !== "project" || !identity.projectId) throw new Error("仅项目编排可调用");
|
|
2812
|
-
const
|
|
2813
|
-
|
|
2814
|
-
|
|
2815
|
-
|
|
2816
|
-
|
|
2817
|
-
|
|
2818
|
-
|
|
2819
|
-
|
|
2820
|
-
|
|
2821
|
-
|
|
2822
|
-
|
|
2789
|
+
const rows = [];
|
|
2790
|
+
for (const ticket of await db.ticket.listByProject(identity.projectId)) {
|
|
2791
|
+
if (ticket.status === "done" || ticket.status === "cancelled") continue;
|
|
2792
|
+
for (const worker of await db.worker.listByTicket(ticket.id)) {
|
|
2793
|
+
if (worker.status === "ended") continue;
|
|
2794
|
+
const agent = await session.lookup(worker.id);
|
|
2795
|
+
rows.push({
|
|
2796
|
+
id: worker.id,
|
|
2797
|
+
ticketId: ticket.id,
|
|
2798
|
+
title: ticket.title,
|
|
2799
|
+
status: agent?.status === "running" ? "running" : "inactive"
|
|
2800
|
+
});
|
|
2801
|
+
}
|
|
2802
|
+
}
|
|
2803
|
+
return JSON.stringify(rows);
|
|
2823
2804
|
}
|
|
2824
2805
|
});
|
|
2825
2806
|
// src/ai/preset.ts
|
|
@@ -2862,7 +2843,7 @@ const manager = definePreset({
|
|
|
2862
2843
|
send,
|
|
2863
2844
|
view,
|
|
2864
2845
|
cancel,
|
|
2865
|
-
|
|
2846
|
+
list_worker
|
|
2866
2847
|
],
|
|
2867
2848
|
plugins: [
|
|
2868
2849
|
agentInstructions,
|
|
@@ -3487,7 +3468,7 @@ const unlink_thread = defineTool({
|
|
|
3487
3468
|
// src/ai/orchestrator/tools/ticket.ts
|
|
3488
3469
|
const create_ticket$1 = defineTool({
|
|
3489
3470
|
name: "create_ticket",
|
|
3490
|
-
description: "开一张票。任务一旦存在,projectId
|
|
3471
|
+
description: "开一张票。任务一旦存在,projectId 就必须确定。没 @ bot 的触发只是 inferred 候选,inferred 模式不是 auto 时会被拒绝。",
|
|
3491
3472
|
parameters: {
|
|
3492
3473
|
title: {
|
|
3493
3474
|
type: "string",
|
|
@@ -3508,6 +3489,10 @@ const create_ticket$1 = defineTool({
|
|
|
3508
3489
|
description: {
|
|
3509
3490
|
type: "string",
|
|
3510
3491
|
description: "需求正文,没有就省略。"
|
|
3492
|
+
},
|
|
3493
|
+
triggerId: {
|
|
3494
|
+
type: "string",
|
|
3495
|
+
description: "引起这张票的触发,取邮件里的 triggerId。省略时按 threadIds 里最新的一条触发判准入强度。"
|
|
3511
3496
|
}
|
|
3512
3497
|
},
|
|
3513
3498
|
output: {
|
|
@@ -3524,6 +3509,7 @@ const create_ticket$1 = defineTool({
|
|
|
3524
3509
|
const identity = await session.resolve(exec.agent?.session.id ?? "");
|
|
3525
3510
|
if (!identity) throw new Error("当前会话没有 Supermesh 身份");
|
|
3526
3511
|
if (identity.role !== "main") throw new Error("仅主编排可调用");
|
|
3512
|
+
if (!ticketAllowed(await latestTriggerStrength(args.threadIds, args.triggerId), (await setting.load()).inferred)) throw new Error("这条触发没有 @ bot,只是 inferred 候选,当前 inferred 模式不是 auto:只能做分诊记录,不能建票。要开工请让人 @ bot 一次,或在设置里把 inferred 改成 auto。");
|
|
3527
3513
|
return JSON.stringify(await db.ticket.createWithThreads(args.projectId, args.title, args.threadIds, args.description));
|
|
3528
3514
|
}
|
|
3529
3515
|
});
|
|
@@ -3921,7 +3907,7 @@ const report = defineTool({
|
|
|
3921
3907
|
output: {
|
|
3922
3908
|
schema: {
|
|
3923
3909
|
type: "string",
|
|
3924
|
-
description: "
|
|
3910
|
+
description: "是否已记录。"
|
|
3925
3911
|
},
|
|
3926
3912
|
render: (_args, value) => [{
|
|
3927
3913
|
type: "text",
|
|
@@ -3934,7 +3920,11 @@ const report = defineTool({
|
|
|
3934
3920
|
if (identity.role !== "worker" || !identity.workerId || !identity.ticketId) throw new Error("仅 Worker 可调用");
|
|
3935
3921
|
const worker = await db.worker.findById(identity.workerId);
|
|
3936
3922
|
if (!worker || worker.status === "ended") throw new Error("Worker 已结束");
|
|
3937
|
-
|
|
3923
|
+
await db.worker.reportProgress(worker.id, args.state, args.summary);
|
|
3924
|
+
return JSON.stringify({
|
|
3925
|
+
recorded: true,
|
|
3926
|
+
state: args.state
|
|
3927
|
+
});
|
|
3938
3928
|
}
|
|
3939
3929
|
});
|
|
3940
3930
|
const ask = defineTool({
|
|
@@ -4278,7 +4268,7 @@ var JsonSchedulerImpl = class {
|
|
|
4278
4268
|
await mkdir(dirname(this.filePath), { recursive: true });
|
|
4279
4269
|
const tmp = `${this.filePath}.${process.pid}.tmp`;
|
|
4280
4270
|
await writeFile(tmp, `${JSON.stringify(payload, null, 2)}\n`, "utf8");
|
|
4281
|
-
await rename
|
|
4271
|
+
await rename(tmp, this.filePath);
|
|
4282
4272
|
}
|
|
4283
4273
|
async load() {
|
|
4284
4274
|
let raw;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { c as shell } from "./channel-AKRPqFjp.js";
|
package/package.json
CHANGED
package/dist/shell-DqAUjFxq.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { c as shell } from "./channel-ChqKKcYq.js";
|