dsh-nova-lewis 0.2.1 → 0.2.2

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/README.cn.md CHANGED
@@ -1,6 +1,6 @@
1
- `dsh-nova-lewis` · v0.2.1 · [npm](https://www.npmjs.com/package/dsh-nova-lewis)
1
+ `dsh-nova-lewis` · v0.2.2 · [npm](https://www.npmjs.com/package/dsh-nova-lewis)
2
2
 
3
- [English](https://www.npmjs.com/package/dsh-nova-lewis/v/0.2.1) | 简体中文
3
+ [English](https://www.npmjs.com/package/dsh-nova-lewis/v/0.2.2) | 简体中文
4
4
 
5
5
  # ds-nova · 附魔台多模型协作
6
6
 
@@ -16,7 +16,7 @@
16
16
  2. 在各个 API 连接下勾选具体型号。同一连接下可以勾选多个型号。只有一个型号时,它也可以分步完成能力范围内的工作。
17
17
  3. 选择 **确认后执行** 或 **直接执行**,然后照常发送任务。前一种方式会先生成计划,你可以查看分工、改派负责人,再点 **确认并开始**。
18
18
 
19
- ![在原聊天输入框开启协作,选择开工方式和具体型号](https://cdn.jsdelivr.net/npm/dsh-nova-lewis@0.2.1/docs/images/collaboration-menu.png)
19
+ ![在原聊天输入框开启协作,选择开工方式和具体型号](https://cdn.jsdelivr.net/npm/dsh-nova-lewis@0.2.2/docs/images/collaboration-menu.png)
20
20
 
21
21
  可以直接把这个订单迁移任务发到聊天框。
22
22
 
@@ -28,7 +28,7 @@
28
28
 
29
29
  下面的本机演示使用同一个 API 连接。A 整理字段映射,B 据此分析兼容读取,C 需要 A 和 B 的成果才能评估回滚。
30
30
 
31
- ![同一 API 中的三个型号分别统筹、整理字段和评估兼容与回滚](https://cdn.jsdelivr.net/npm/dsh-nova-lewis@0.2.1/docs/images/task-graph.png)
31
+ ![同一 API 中的三个型号分别统筹、整理字段和评估兼容与回滚](https://cdn.jsdelivr.net/npm/dsh-nova-lewis@0.2.2/docs/images/task-graph.png)
32
32
 
33
33
  - **任务资料** 在协作设置中添加验收条款等原文,发送时在 **本次资料** 中勾选。复核模型可以按行引用这些条款。
34
34
  - **分工建议** 在 **模型与分工** 中查看哪些已选型号适合统筹、起草工作提示词或执行复核,以及这些建议的依据。
@@ -36,7 +36,7 @@
36
36
  - **两种更新** 在 **更新与作者** 检查插件软件版本。在线模型推荐资料有独立版本,在 **模型预设 → 检查开发者更新** 查看哪些型号的分工建议有变化,选择 **应用更新** 即可使用新资料。
37
37
  - **作者与数据共享** 在 **更新与作者** 查看作者信息。数据共享默认关闭,只有阅读说明并明确同意后才会开启,共享记录只归在 DS Nova 名下。你可以随时在同一窗口停止共享并请求删除记录。
38
38
 
39
- ![本机演示中两个型号的四次调用及各自的 Token 用量](https://cdn.jsdelivr.net/npm/dsh-nova-lewis@0.2.1/docs/images/model-usage.png)
39
+ ![本机演示中两个型号的四次调用及各自的 Token 用量](https://cdn.jsdelivr.net/npm/dsh-nova-lewis@0.2.2/docs/images/model-usage.png)
40
40
 
41
41
  ## 作者
42
42
 
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
- `dsh-nova-lewis` · v0.2.1 · [npm](https://www.npmjs.com/package/dsh-nova-lewis)
1
+ `dsh-nova-lewis` · v0.2.2 · [npm](https://www.npmjs.com/package/dsh-nova-lewis)
2
2
 
3
- [English](#english) | [简体中文](#简体中文) · [中文版 Markdown 文件](https://cdn.jsdelivr.net/npm/dsh-nova-lewis@0.2.1/README.cn.md)
3
+ [English](#english) | [简体中文](#简体中文) · [中文版 Markdown 文件](https://cdn.jsdelivr.net/npm/dsh-nova-lewis@0.2.2/README.cn.md)
4
4
 
5
5
  # ds-nova · Multi-model collaboration for DeepSeek Harness
6
6
 
@@ -18,7 +18,7 @@ In DeepSeek Harness 0.2.2-rc.5, open **Plugins → Add Plugin**, enter `dsh-nova
18
18
  2. Select individual models under their API connections. You can select several models from one connection. If you have one model, it can handle successive steps within its capabilities.
19
19
  3. Choose **确认后执行** (Review the plan first) or **直接执行** (Start directly), then send your task. With the first option, you can inspect the plan and reassign a step before clicking **确认并开始** (Confirm and start).
20
20
 
21
- ![The collaboration menu next to the chat box, with execution mode and model selection](https://cdn.jsdelivr.net/npm/dsh-nova-lewis@0.2.1/docs/images/collaboration-menu.png)
21
+ ![The collaboration menu next to the chat box, with execution mode and model selection](https://cdn.jsdelivr.net/npm/dsh-nova-lewis@0.2.2/docs/images/collaboration-menu.png)
22
22
 
23
23
  Try this order migration task in chat.
24
24
 
@@ -30,7 +30,7 @@ Open **协作导图** (Task graph) from the collaboration menu. The canvas conne
30
30
 
31
31
  In this local demonstration, all three models use one API connection. Step A maps the fields. Step B uses that mapping to assess read compatibility. Step C needs both results to evaluate rollback.
32
32
 
33
- ![Three models on one API connection coordinating the field mapping, compatibility assessment, and rollback review](https://cdn.jsdelivr.net/npm/dsh-nova-lewis@0.2.1/docs/images/task-graph.png)
33
+ ![Three models on one API connection coordinating the field mapping, compatibility assessment, and rollback review](https://cdn.jsdelivr.net/npm/dsh-nova-lewis@0.2.2/docs/images/task-graph.png)
34
34
 
35
35
  - **Task materials.** Add a source such as acceptance criteria in collaboration settings. Select it under **本次资料** when sending the task so the reviewer can cite the original lines.
36
36
  - **Assignment guidance.** Under **模型与分工**, see which selected models are suited to coordination, drafting work instructions, or reviewing a result, along with the evidence for those suggestions.
@@ -38,7 +38,7 @@ In this local demonstration, all three models use one API connection. Step A map
38
38
  - **Software and model updates.** Check the software version under **更新与作者**. Model recommendations have their own version. Open **模型预设 → 检查开发者更新** to see which model profiles have changed, then choose **应用更新** to apply the new guidance to your installed plugin.
39
39
  - **Author and data sharing.** Open **更新与作者** to view author information. Data sharing is off by default and requires your explicit consent. Shared records are attributed only to DS Nova. You can stop sharing and request deletion in the same window at any time.
40
40
 
41
- ![Four local demo calls grouped by model, with a separate token total for each](https://cdn.jsdelivr.net/npm/dsh-nova-lewis@0.2.1/docs/images/model-usage.png)
41
+ ![Four local demo calls grouped by model, with a separate token total for each](https://cdn.jsdelivr.net/npm/dsh-nova-lewis@0.2.2/docs/images/model-usage.png)
42
42
 
43
43
  ### Author
44
44
 
@@ -58,7 +58,7 @@ Zhou Yichen (FerrariLewis) created the DSH LEWIS ENCHANTMENT series. Its startup
58
58
  2. 在各个 API 连接下勾选具体型号。同一连接下可以勾选多个型号。只有一个型号时,它也可以分步完成能力范围内的工作。
59
59
  3. 选择 **确认后执行** 或 **直接执行**,然后照常发送任务。前一种方式会先生成计划,你可以查看分工、改派负责人,再点 **确认并开始**。
60
60
 
61
- ![在原聊天输入框开启协作,选择开工方式和具体型号](https://cdn.jsdelivr.net/npm/dsh-nova-lewis@0.2.1/docs/images/collaboration-menu.png)
61
+ ![在原聊天输入框开启协作,选择开工方式和具体型号](https://cdn.jsdelivr.net/npm/dsh-nova-lewis@0.2.2/docs/images/collaboration-menu.png)
62
62
 
63
63
  可以直接把这个订单迁移任务发到聊天框。
64
64
 
@@ -70,7 +70,7 @@ Zhou Yichen (FerrariLewis) created the DSH LEWIS ENCHANTMENT series. Its startup
70
70
 
71
71
  下面的本机演示使用同一个 API 连接。A 整理字段映射,B 据此分析兼容读取,C 需要 A 和 B 的成果才能评估回滚。
72
72
 
73
- ![同一 API 中的三个型号分别统筹、整理字段和评估兼容与回滚](https://cdn.jsdelivr.net/npm/dsh-nova-lewis@0.2.1/docs/images/task-graph.png)
73
+ ![同一 API 中的三个型号分别统筹、整理字段和评估兼容与回滚](https://cdn.jsdelivr.net/npm/dsh-nova-lewis@0.2.2/docs/images/task-graph.png)
74
74
 
75
75
  - **任务资料** 在协作设置中添加验收条款等原文,发送时在 **本次资料** 中勾选。复核模型可以按行引用这些条款。
76
76
  - **分工建议** 在 **模型与分工** 中查看哪些已选型号适合统筹、起草工作提示词或执行复核,以及这些建议的依据。
@@ -78,7 +78,7 @@ Zhou Yichen (FerrariLewis) created the DSH LEWIS ENCHANTMENT series. Its startup
78
78
  - **两种更新** 在 **更新与作者** 检查插件软件版本。在线模型推荐资料有独立版本,在 **模型预设 → 检查开发者更新** 查看哪些型号的分工建议有变化,选择 **应用更新** 即可使用新资料。
79
79
  - **作者与数据共享** 在 **更新与作者** 查看作者信息。数据共享默认关闭,只有阅读说明并明确同意后才会开启,共享记录只归在 DS Nova 名下。你可以随时在同一窗口停止共享并请求删除记录。
80
80
 
81
- ![本机演示中两个型号的四次调用及各自的 Token 用量](https://cdn.jsdelivr.net/npm/dsh-nova-lewis@0.2.1/docs/images/model-usage.png)
81
+ ![本机演示中两个型号的四次调用及各自的 Token 用量](https://cdn.jsdelivr.net/npm/dsh-nova-lewis@0.2.2/docs/images/model-usage.png)
82
82
 
83
83
  ### 作者
84
84
 
package/dist/client.js CHANGED
@@ -2127,7 +2127,7 @@ function updateView(update, { locale = "zh-CN", nativeManager = false } = {}) {
2127
2127
  const available = update.kind === "available";
2128
2128
  const published = available && (update.channel === "npm" || update.channel === "official");
2129
2129
  const actions = available ? button2("close", "稍后再说") + (published ? button2("release", nativeManager ? "打开插件管理" : "查看 npm 包", { css: primary }) : button2("install", "更新到 " + esc(update.latestVersion), { css: primary, disabled: true, extra: ' title="当前本地示例仅支持检查更新"' })) : button2("close", preview ? "关闭预览" : "知道了", { css: primary });
2130
- return '<div class="bs-startup-update-card">' + closeButton("关闭更新提示") + '<div class="bs-startup-update-glyph" aria-hidden="true">' + (current ? "✓" : failed ? "!" : "✧") + '</div><p class="bs-startup-update-brand">' + brand + (preview ? "<span> · 更新提醒外观预览</span>" : "") + '</p><h2 id="bs-startup-update-title">' + title + '</h2><p id="bs-startup-update-description" class="bs-startup-update-copy">' + esc(description) + "</p>" + (failed || unpublished ? "" : versions(update, current)) + (failed || unpublished || current ? "" : '<div class="bs-release-notes" aria-label="本次更新"><h3>本次更新</h3>' + (notes.trim() ? "<p>" + esc(notes) + "</p>" : '<p class="bs-release-notes-empty">' + (preview ? "更新说明待作者填写(仅本地预览)" : "此版本未提供更新说明。") + "</p>") + "</div>") + (published ? '<p class="bs-startup-update-copy">在 DSH 插件管理的「版本」中选择 v' + esc(update.latestVersion) + " 并确认更新。首次按包名安装时,可在「添加插件」输入 <code>dsh-nova-lewis@" + esc(update.latestVersion) + "</code>。</p>" : "") + (failed || unpublished || current ? "" : '<p class="bs-startup-update-restart">更新完成后,请完全退出并重新打开 Harness,以应用新版本。</p><p class="bs-startup-update-retain">你的协作设置、任务资料和运行记录都会保留</p>') + '<div class="bs-startup-update-actions">' + actions + "</div></div>";
2130
+ return '<div class="bs-startup-update-card">' + closeButton("关闭更新提示") + '<div class="bs-startup-update-glyph" aria-hidden="true">' + (current ? "✓" : failed ? "!" : "✧") + '</div><p class="bs-startup-update-brand">' + brand + (preview ? "<span> · 更新提醒外观预览</span>" : "") + '</p><h2 id="bs-startup-update-title">' + title + '</h2><p id="bs-startup-update-description" class="bs-startup-update-copy">' + esc(description) + "</p>" + (failed || unpublished ? "" : versions(update, current)) + (failed || unpublished || current || !notes && !preview ? "" : '<div class="bs-release-notes" aria-label="本次更新"><h3>本次更新</h3>' + (notes ? "<p>" + esc(notes) + "</p>" : '<p class="bs-release-notes-empty">更新说明待作者填写(仅本地预览)</p>') + "</div>") + (published ? '<p class="bs-startup-update-copy">在 DSH 插件管理的「版本」中选择 v' + esc(update.latestVersion) + " 并确认更新。首次按包名安装时,可在「添加插件」输入 <code>dsh-nova-lewis@" + esc(update.latestVersion) + "</code>。</p>" : "") + (failed || unpublished || current ? "" : '<p class="bs-startup-update-restart">更新完成后,请完全退出并重新打开 Harness,以应用新版本。</p><p class="bs-startup-update-retain">你的协作设置、任务资料和运行记录都会保留</p>') + '<div class="bs-startup-update-actions">' + actions + "</div></div>";
2131
2131
  }
2132
2132
  function sharingNotice(local) {
2133
2133
  const account = local ? "" : "<li>已登录 DeepSeek 的昵称与账户标识。账户标识传至接收服务后用服务端密钥 HMAC 去重,原始标识不落盘。</li>";
@@ -2619,9 +2619,11 @@ function notices(s) {
2619
2619
  const unknown = [...run.operations || [], ...run.attempts || []].filter(
2620
2620
  (a) => a.status === "unknown" && !a.parentId
2621
2621
  );
2622
+ const unavailable = run.settings?.unavailableRouteIds;
2623
+ const skipped = unavailable?.length ? "<p>" + esc("本次跳过暂不可用的已选型号:" + unavailable.join("、")) + "。</p>" : "";
2622
2624
  if (!unknown.length && !tickets.length && !run.error && !run.reason)
2623
- return "";
2624
- return '<details class="tickets" open><summary>' + icon("alert", 15) + "待我处理 <b>" + num(tickets.length || 1) + "</b></summary>" + (run.error || run.reason ? txt(run.error || run.reason) : "") + unknown.map(
2625
+ return skipped;
2626
+ return skipped + '<details class="tickets" open><summary>' + icon("alert", 15) + "待我处理 <b>" + num(tickets.length || 1) + "</b></summary>" + (run.error || run.reason ? txt(run.error || run.reason) : "") + unknown.map(
2625
2627
  (a) => button(
2626
2628
  "reconcile",
2627
2629
  "核对未确认请求 · " + (run.nodes?.find((n) => n.id === a.nodeId)?.title || "统筹规划"),
@@ -3387,6 +3389,11 @@ function mountWorkbench(container, bridge, options = {}) {
3387
3389
  const run = s.run;
3388
3390
  if (!run)
3389
3391
  return '<div data-graph class="bs-preferences bs-ending-settings">' + renderGraph(s, v) + "</div>";
3392
+ const switchRun = s.runs?.length > 1 ? '<div class="bs-author-entry">' + button("runs", "切换运行(" + num(s.runs.length) + ")", null, "") + "</div>" : "";
3393
+ if (run.settings?.easterEgg) {
3394
+ const answered = run.nodes.filter((n) => n.status === "done").length;
3395
+ return '<div data-graph class="bs-preferences bs-ending-settings"><div class="bs-field bs-ending-header"><h2>型号点名</h2>' + badge(run.status) + "</div><p>" + num(answered) + " / " + num(run.nodes.length) + " 个型号已回应</p>" + (run.status === "running" ? iconButton("cancelDialog", "取消本次点名", "stop") : "") + (run.status === "paused" ? button("resume", "继续点名", "play", "btn primary") : "") + (run.status === "blocked" ? notices(s) : "") + "</div>" + usageSummary(s) + switchRun;
3396
+ }
3390
3397
  const active = run.nodes?.filter((n) => n.status === "running") || [];
3391
3398
  const activities = active.length ? '<div class="activities">' + active.map(
3392
3399
  (n) => button(
@@ -3400,7 +3407,7 @@ function mountWorkbench(container, bridge, options = {}) {
3400
3407
  const planning = !run.planVersion || run.status === "awaiting_confirmation";
3401
3408
  const diagram = renderGraph(s, v);
3402
3409
  const progress = runSummary(s);
3403
- return '<div data-graph class="bs-preferences bs-ending-settings"><div class="bs-field bs-ending-header"><h2>协作导图</h2><span>' + (planning ? "统筹规划" : "执行进度") + '</span></div><div class="bs-animation-content"><div class="bs-section-title"><h2>' + esc(run.task) + "</h2><span>" + esc(s.mode === "demo" ? "离线演示 · " : "") + "计划 v" + esc(run.planVersion) + " · " + badge(run.status) + '</span></div><div class="run-controls bs-update-actions">' + controls(run) + "</div>" + notices(s) + (planning ? diagram + progress : progress + activities + diagram) + "</div></div>" + inspector(s, v) + usageSummary(s) + history(s) + (s.runs?.length > 1 ? '<div class="bs-author-entry">' + button("runs", "切换运行(" + num(s.runs.length) + ")", null, "") + "</div>" : "");
3410
+ return '<div data-graph class="bs-preferences bs-ending-settings"><div class="bs-field bs-ending-header"><h2>协作导图</h2><span>' + (planning ? "统筹规划" : "执行进度") + '</span></div><div class="bs-animation-content"><div class="bs-section-title"><h2>' + esc(run.task) + "</h2><span>" + esc(s.mode === "demo" ? "离线演示 · " : "") + "计划 v" + esc(run.planVersion) + " · " + badge(run.status) + '</span></div><div class="run-controls bs-update-actions">' + controls(run) + "</div>" + notices(s) + (planning ? diagram + progress : progress + activities + diagram) + "</div></div>" + inspector(s, v) + usageSummary(s) + history(s) + switchRun;
3404
3411
  }
3405
3412
  function workspace() {
3406
3413
  if (v.view === "graph") return runPanel();
@@ -4786,6 +4793,35 @@ function composerPlacement(anchor, viewport, frameTop = 0) {
4786
4793
  return { width, left, maxHeight: Math.min(540, openAbove ? above : below), ...openAbove ? { bottom: viewport.layoutHeight - aboveEdge } : { top: belowEdge } };
4787
4794
  }
4788
4795
 
4796
+ // host/exact-composer-text.mjs
4797
+ var PRESENCE_TRIGGER = "在嘛?";
4798
+ function preserveExactComposerText(conversation, sessions, collaborationEnabled) {
4799
+ const send = conversation.sendSession;
4800
+ if (typeof send !== "function") return;
4801
+ const previous = Object.getOwnPropertyDescriptor(conversation, "sendSession");
4802
+ let active = true;
4803
+ function sendWithOriginalText(session, text, attachments, ...rest) {
4804
+ if (active && text === PRESENCE_TRIGGER && attachments.length === 0) {
4805
+ const binding = sessions.binding(session.sessionId);
4806
+ if (binding?.session === session) {
4807
+ const draft = conversation.input.for(binding.ctx).state.getSnapshot();
4808
+ const original = draft.draft;
4809
+ if (!draft.occurrences.length && original !== text && original.trim() === text) {
4810
+ return collaborationEnabled(session.sessionId).then((enabled) => send.call(this, session, active && enabled ? original : text, attachments, ...rest));
4811
+ }
4812
+ }
4813
+ }
4814
+ return send.call(this, session, text, attachments, ...rest);
4815
+ }
4816
+ conversation.sendSession = sendWithOriginalText;
4817
+ return () => {
4818
+ active = false;
4819
+ if (conversation.sendSession !== sendWithOriginalText) return;
4820
+ if (previous) Object.defineProperty(conversation, "sendSession", previous);
4821
+ else delete conversation.sendSession;
4822
+ };
4823
+ }
4824
+
4789
4825
  // host/composer.css
4790
4826
  var composer_default = ".bs-studio.composer-menu {\n width:100%;\n max-width:none;\n container-type:inline-size;\n display:flex;\n flex-direction:column;\n max-height:var(--composer-max-height);\n padding:0;\n margin:0;\n box-sizing:border-box;\n}\n.composer-main {\n min-height:0;\n padding:12px min(5%,18px) 4px;\n overflow-y:auto;\n overflow-x:hidden;\n overscroll-behavior:contain;\n}\n.composer-menu fieldset { min-width:0; margin:0; padding:10px 0 6px; border:0; }\n.composer-menu legend {\n float:left;\n width:100%;\n padding:4px 4px 6px;\n color:var(--bs-muted);\n font-size:.88em;\n font-weight:600;\n overflow-wrap:anywhere;\n}\n.composer-menu .composer-model:first-of-type { clear:both; }\n.composer-menu .bs-field {\n display:grid;\n grid-template-columns:minmax(0,1fr) auto;\n gap:10px;\n align-items:center;\n padding:10px 4px;\n}\n.composer-menu .bs-field strong,.composer-menu .bs-field small,.composer-menu .bs-field > span:first-child {\n min-width:0;\n line-height:1.4;\n white-space:normal;\n overflow-wrap:anywhere;\n}\n.composer-menu .bs-toggle-row input { right:4px; }\n.composer-menu .bs-field .model-id { font-family:var(--dsw-font-mono,monospace); }\n.composer-menu .composer-reasoning { padding:0 4px 10px 12px; }\n.composer-menu .composer-reasoning > span:first-child { color:var(--bs-muted); }\n.composer-menu .composer-materials { border-top:1px solid var(--bs-border); margin-top:6px; padding:7px 0; }\n.composer-menu .composer-materials summary { cursor:pointer; display:list-item; list-style-position:inside; padding:8px 4px; }\n.composer-menu .composer-materials .bs-clip-actions { padding:4px 4px 7px; }\n.composer-menu .composer-actions {\n display:grid;\n flex:none;\n grid-template-columns:repeat(auto-fit,minmax(min(76px,100%),1fr));\n gap:6px;\n margin:0 min(5%,18px);\n padding:9px 0 12px;\n border-top:1px solid var(--bs-border);\n}\n.composer-menu .composer-actions button { min-width:0; padding:7px 5px; white-space:normal; overflow-wrap:anywhere; }\n.composer-menu p { margin:6px 4px; overflow-wrap:anywhere; }\n";
4791
4827
 
@@ -5264,6 +5300,16 @@ function Composer({ ctx, sessionId }) {
5264
5300
  ), pop);
5265
5301
  }
5266
5302
  function apply(ctx) {
5303
+ ctx.inject?.(["conversation", "sessions"], (ready) => ready.effect(() => preserveExactComposerText(ready.conversation, ready.sessions, async (sessionId) => {
5304
+ const bridge = hostBridge(ctx, sessionId, true);
5305
+ try {
5306
+ return (await bridge.getState()).composer?.enabled === true;
5307
+ } catch {
5308
+ return true;
5309
+ } finally {
5310
+ bridge.dispose();
5311
+ }
5312
+ }), "collaboration exact composer text"));
5267
5313
  ctx.inject?.(["pluginNavigation"], (ready) => ready.effect(() => {
5268
5314
  const manager = ready.pluginNavigation;
5269
5315
  pluginManagers.set(ctx, manager);
package/host/client.mjs CHANGED
@@ -13,6 +13,7 @@ import {toggleParticipant} from './selection.mjs'
13
13
  import {isNewVisiblePlan} from './plan-view.mjs'
14
14
  import {mountChoice,POLICY_OPTIONS} from '../ui/choices.mjs'
15
15
  import {composerPlacement} from './composer-layout.mjs'
16
+ import {preserveExactComposerText} from './exact-composer-text.mjs'
16
17
  import composerCSS from './composer.css'
17
18
 
18
19
  // Keep DSH's persisted sidebar tabs, series shortcuts and settings target valid across the package rename.
@@ -291,6 +292,12 @@ function Composer({ctx,sessionId}){
291
292
  title:reason || '本会话的协作开关、模型与进度','aria-expanded':opened,'aria-haspopup':'dialog',onClick:()=>setOpened(!opened)},'协作'+(hint?' · '+hint:''))),pop)
292
293
  }
293
294
  export function apply(ctx){
295
+ ctx.inject?.(['conversation','sessions'],ready=>ready.effect(()=>preserveExactComposerText(ready.conversation,ready.sessions,async sessionId=>{
296
+ const bridge=hostBridge(ctx,sessionId,true)
297
+ try{return (await bridge.getState()).composer?.enabled===true}
298
+ // A transient settings error must not turn a padded ordinary message into a roll call.
299
+ catch{return true}finally{bridge.dispose()}
300
+ }),'collaboration exact composer text'))
294
301
  ctx.inject?.(['pluginNavigation'],ready=>ready.effect(()=>{
295
302
  const manager=ready.pluginNavigation
296
303
  pluginManagers.set(ctx,manager)
@@ -0,0 +1,31 @@
1
+ export const PRESENCE_TRIGGER = '在嘛?'
2
+
3
+ // DSH rc.5 trims both ends of ordinary drafts before handing them to the send
4
+ // service. At that handoff the session's input store still contains the draft.
5
+ export function preserveExactComposerText(conversation, sessions, collaborationEnabled) {
6
+ const send = conversation.sendSession
7
+ if (typeof send !== 'function') return
8
+ const previous = Object.getOwnPropertyDescriptor(conversation, 'sendSession')
9
+ let active = true
10
+ function sendWithOriginalText(session, text, attachments, ...rest) {
11
+ if (active && text === PRESENCE_TRIGGER && attachments.length === 0) {
12
+ const binding = sessions.binding(session.sessionId)
13
+ if (binding?.session === session) {
14
+ const draft = conversation.input.for(binding.ctx).state.getSnapshot()
15
+ const original = draft.draft
16
+ if (!draft.occurrences.length && original !== text && original.trim() === text) {
17
+ return collaborationEnabled(session.sessionId).then(enabled =>
18
+ send.call(this, session, active && enabled ? original : text, attachments, ...rest))
19
+ }
20
+ }
21
+ }
22
+ return send.call(this, session, text, attachments, ...rest)
23
+ }
24
+ conversation.sendSession = sendWithOriginalText
25
+ return () => {
26
+ active = false
27
+ if (conversation.sendSession !== sendWithOriginalText) return
28
+ if (previous) Object.defineProperty(conversation, 'sendSession', previous)
29
+ else delete conversation.sendSession
30
+ }
31
+ }
package/host/index.mjs CHANGED
@@ -11,7 +11,7 @@ import { discoverRoutes, executorFor, plannerFor } from './models.mjs'
11
11
  import {choosePlanner} from '../src/role-routing.mjs'
12
12
  import { createChildren } from './children.mjs'
13
13
  import {sessionSelection} from './selection.mjs'
14
- import {formatConversationPlan} from './plan-view.mjs'
14
+ import {isRollCall,prepareRollCall,executeRollCall,renderRollCall} from './roll-call.mjs'
15
15
 
16
16
  export const name = 'dsh-nova-lewis'
17
17
  export const inject = ['commands','llm','agents','sessions','sessionProjections','connection','storageDomain','webServer']
@@ -63,9 +63,14 @@ function delta(previous, snapshot) {
63
63
  return {runId:snapshot.runId,fields,rows,order}
64
64
  }
65
65
  function delivered(snapshot) {
66
- const outputs = snapshot.nodes.filter(n=>n.artifactId && !snapshot.nodes.some(next=>next.deps.includes(n.id)))
66
+ const finals = snapshot.nodes.filter(n=>n.final && n.artifactId)
67
+ const outputs = finals.length ? finals : snapshot.nodes.filter(n=>n.artifactId && !snapshot.nodes.some(next=>next.deps.includes(n.id)))
67
68
  return outputs.map(n=>snapshot.artifacts.find(a=>a.id===n.artifactId)).filter(Boolean)
68
69
  }
70
+ function answerText(outputs) {
71
+ return outputs.map(a=>a.text+(a.unresolved?.length ? '\n未决项:'+a.unresolved.join('、') : '')).join('\n\n') || '本次协作没有可交付的答复。'
72
+ }
73
+ const completedText = snapshot => snapshot.settings?.easterEgg ? renderRollCall(snapshot) : answerText(delivered(snapshot))
69
74
  const settled = run=>['completed','cancelled','blocked'].includes(run.status)
70
75
  function waitForRun(engine,ready,signal) {
71
76
  return new Promise((resolve,reject)=>{
@@ -99,7 +104,8 @@ export async function installHost(ctx,config,api) {
99
104
  ctx.effect(()=>()=>author.dispose(),'collaboration author settings')
100
105
  const spawn = createChildren(ctx,config), execute = executorFor(ctx,spawn)
101
106
  const engines = new Map(), active = new WeakMap(), observers = new Map()
102
- const nativeDeliveries = new Set()
107
+ const nativeDeliveries = new Map()
108
+ const pendingRollCalls = new WeakMap()
103
109
  const composerSettings=(room,sessionId)=>{
104
110
  const saved=room.composer?.sessionId===sessionId && room.composer
105
111
  const materialIds=room.materialSelection?.sessionId===sessionId ? room.materialSelection.ids : []
@@ -131,16 +137,14 @@ export async function installHost(ctx,config,api) {
131
137
  ctx.on('llm/adapters-updated',refresh)
132
138
  function bind(session,runId) {
133
139
  let last = view.stateOf(session).runs[runId]
134
- return {execute,persist:async (snapshot,event)=>{
140
+ return {execute:args=>args.settings?.easterEgg ? executeRollCall(ctx,args) : execute(args),persist:async (snapshot,event)=>{
135
141
  const data = clean(snapshot)
136
142
  api.appendPluginRecord(session,RECORD,delta(last,data))
137
143
  if (data.status==='completed' && last?.status!=='completed' && !nativeDeliveries.has(runId)) {
138
144
  const outputs = delivered(data)
139
- const text = ['协作交付 · '+data.task,'运行 '+runId,...outputs.map(a=>a.title+'\n'+a.text+
140
- (a.unresolved.length ? '\n未决项:'+a.unresolved.join(';') : '')),
141
- '步骤索引\n'+data.nodes.map((n,i)=>'第 '+(i+1)+' 步 '+n.title+' ['+n.id+']\n'+(data.artifacts.find(a=>a.id===n.artifactId)?.summary || n.status)).join('\n')
142
- ].join('\n\n')
143
- const final = outputs.at(-1), route = data.attempts.find(a=>a.id===final?.attemptId)?.route
145
+ const text = completedText(data)
146
+ const final = outputs.at(-1), route = [...(data.operations || []),...data.attempts].find(a=>a.id===final?.attemptId)?.route ||
147
+ data.routes.find(r=>r.id===(final?.routeId || data.plannerRouteId))
144
148
  if (route) session.append('assistant/message',{turn:0,step:0,stream:[],message:{
145
149
  role:'assistant',id:randomUUID(),content:[{type:'text',text}],source:{kind:'model',provider:route.providerId,model:route.modelId}
146
150
  }},{surfaceOp:'append'})
@@ -170,7 +174,7 @@ export async function installHost(ctx,config,api) {
170
174
  if (compact) {
171
175
  const snapshot=room.runs[selectedId]
172
176
  const run=snapshot && snapshot.sessionId===sessionId?{runId:snapshot.runId,status:snapshot.status,planVersion:snapshot.planVersion,
173
- createdAt:snapshot.createdAt,native:!!snapshot.settings?.nativePromptId,
177
+ createdAt:snapshot.createdAt,native:!!snapshot.settings?.nativePromptId && !snapshot.settings.easterEgg,
174
178
  assignmentsHash:snapshot.assignmentsHash,total:snapshot.nodes.length,done:snapshot.nodes.filter(n=>n.status==='done').length}:null
175
179
  const {routes,connections,warnings}=await catalog()
176
180
  return {mode:'host',sessionId,composer:composerSettings(room,sessionId),run,revision:epoch,
@@ -196,7 +200,7 @@ export async function installHost(ctx,config,api) {
196
200
  const launch = ()=>engine.plan(planner).catch(()=>updated())
197
201
  const jobs=ctx.get ? ctx.get('jobs') : ctx.jobs
198
202
  if (!jobs) { void launch(); return }
199
- const {runId,task} = engine.snapshot()
203
+ const {task} = engine.snapshot()
200
204
  try {
201
205
  jobs.start({owner:session.id,kind:'collab',label:task.replace(/\s+/g,' ').slice(0,100),
202
206
  run:job=>{
@@ -205,7 +209,8 @@ export async function installHost(ctx,config,api) {
205
209
  job.updateProgress?.(snapshot.nodes.filter(n=>n.status==='done').length+'/'+snapshot.nodes.length+' · '+snapshot.status)
206
210
  if (['completed','cancelled','blocked'].includes(snapshot.status)) {
207
211
  off()
208
- resolve({status:snapshot.status==='completed'?'completed':snapshot.status==='cancelled'?'killed':'failed',result:'协作运行 '+runId+' · '+snapshot.status})
212
+ resolve({status:snapshot.status==='completed'?'completed':snapshot.status==='cancelled'?'killed':'failed',
213
+ result:snapshot.status==='completed'?'协作已完成。':snapshot.status==='cancelled'?'协作已取消。':'请在右侧协作导图查看需要处理的步骤。'})
209
214
  }
210
215
  })
211
216
  void launch()
@@ -218,6 +223,41 @@ export async function installHost(ctx,config,api) {
218
223
  }
219
224
  }
220
225
  const create=(session,p,native)=>presets.run(()=>createRun(session,p,native))
226
+ function rollCall(session,pref,promptId,signal) {
227
+ let pending=pendingRollCalls.get(session)
228
+ if (!pending) { pending=new Map(); pendingRollCalls.set(session,pending) }
229
+ if (pending.has(promptId)) return pending.get(promptId)
230
+ const stored=Object.values(view.stateOf(session).runs).find(run=>run.sessionId===session.id && run.settings?.nativePromptId===promptId)
231
+ if (stored) return Promise.resolve(stored.runId)
232
+ const start=createRollCall(session,pref,promptId,signal).finally(()=>pending.delete(promptId))
233
+ pending.set(promptId,start)
234
+ return start
235
+ }
236
+ async function createRollCall(session,pref,promptId,signal) {
237
+ const {routes}=await catalog()
238
+ await profileQueue
239
+ signal?.throwIfAborted()
240
+ const {participants,replies,closing}=prepareRollCall(pref,routes)
241
+ const {settings,settingsOverrides}=readProfile()
242
+ const runId=randomUUID(), allowedRouteIds=participants.map(r=>r.id)
243
+ const nodes=participants.map((route,i)=>({id:'roll-call-'+(i+1),routeId:route.id,title:route.label || route.modelId || route.id,
244
+ deliverable:'点名回应 '+(i+1),acceptance:'从该型号的彩蛋选项中选一句。',outputReserve:1024,final:true,optional:true}))
245
+ const engine=new RunEngine({runId,sessionId:session.id,task:'在嘛?',mode:'auto',routes:participants,allowedRouteIds,
246
+ settings:{...settings,...(!Object.hasOwn(settingsOverrides,'maxRequests') && {maxRequests:Math.max(settings.maxRequests,nodes.length)}),
247
+ nativePromptId:promptId,easterEgg:{replies,closing},reasoningLevels:pref.reasoningLevels},
248
+ ...bind(session,runId)})
249
+ engines.set(runId,{session,engine}); active.set(session,runId)
250
+ nativeDeliveries.set(runId,0)
251
+ const abort=()=>{void engine.cancel().catch(()=>{})}
252
+ signal?.addEventListener('abort',abort,{once:true})
253
+ try {
254
+ await engine.publish({nodes,rationale:'每个勾选的型号独立回应本次点名。'})
255
+ return runId
256
+ } catch(error) {
257
+ nativeDeliveries.delete(runId)
258
+ throw error
259
+ } finally { signal?.removeEventListener('abort',abort) }
260
+ }
221
261
  async function createRun(session,p,native) {
222
262
  void author.launch().catch(()=>{})
223
263
  const task = String(p.task || '').trim()
@@ -252,12 +292,12 @@ export async function installHost(ctx,config,api) {
252
292
  ...(native?{nativePromptId:native.promptId}:{}),
253
293
  ...(native?.materialSelectionId?{nativeMaterialSelectionId:native.materialSelectionId}:{})}
254
294
  const engine = new RunEngine({runId,sessionId:session.id,task,routes,settings:runSettings,sources,plannerAssignment,
255
- allowedRouteIds:allowed.map(r=>r.id),mode:p.policy ?? settings.policy,beforeAutoStart:native?.beforeAutoStart,...bind(session,runId)})
295
+ allowedRouteIds:allowed.map(r=>r.id),mode:p.policy ?? settings.policy,...bind(session,runId)})
256
296
  engines.set(runId,{session,engine});active.set(session,runId)
257
297
  const planModel=plannerFor(ctx,{allowedTools,workMode:p.mode,history:native?.history,materials:selectedMaterials})
258
298
  const planner=args=>presets.run(()=>planModel(args))
259
299
  if (native) {
260
- nativeDeliveries.add(runId)
300
+ nativeDeliveries.set(runId,0)
261
301
  void engine.plan(planner).catch(()=>updated())
262
302
  } else startJob(session,engine,planner)
263
303
  updated()
@@ -301,6 +341,7 @@ export async function installHost(ctx,config,api) {
301
341
  const runId = p.runId || active.get(session) || Object.keys(view.stateOf(session).runs).at(-1)
302
342
  const e = obtain(session,runId)
303
343
  if (!e) throw Error('请先在当前会话创建协作运行。')
344
+ if (['assign','editPlan','revise'].includes(type) && view.stateOf(session).runs[runId]?.settings?.easterEgg) throw Error('点名回应由本次勾选的每个型号分别完成,无法改派。')
304
345
  switch(type) {
305
346
  case 'selectRun': return // Selection belongs to this view. The composer follows the current run.
306
347
  case 'confirm': await e.confirm(p.planVersion,p.assignmentsHash);return
@@ -356,18 +397,19 @@ export async function installHost(ctx,config,api) {
356
397
  return collaborate({options,session,room,pref,current,next})
357
398
  })
358
399
  async function* collaborate({options,session,room,pref,current,next}){
400
+ const egg=isRollCall(current)
359
401
  // DSH already admitted the draft, attachment receipts and prior history. Preserve the host's multimodal path.
360
- if (options.messages.some(m=>m.role==='user' && m.content.some(b=>b.type==='file' || b.type==='image')) ||
361
- current.some(m=>m.content.some(b=>b.type!=='text'))) { yield* next();return }
402
+ if (!egg && (options.messages.some(m=>m.role==='user' && m.content.some(b=>b.type==='file' || b.type==='image')) ||
403
+ current.some(m=>m.content.some(b=>b.type!=='text')))) { yield* next();return }
362
404
  const task=current.flatMap(m=>m.content.map(b=>b.text)).join('\n\n').trim()
363
405
  if (!task || task.startsWith('/')) { yield* next();return }
364
406
  const selected=pref.routeIds
365
407
  const snapshotList=Object.values(room.runs).filter(r=>r.sessionId===session.id)
366
408
  const promptId=current.map(m=>m.id).join(',')
367
409
  let runId=snapshotList.find(r=>r.settings?.nativePromptId===promptId)?.runId, engine
368
- let releaseGraph,graphDelivered=false,blockStarted=false
369
- const graphRead=new Promise(resolve=>{releaseGraph=resolve})
410
+ let blockStarted=false
370
411
  try{
412
+ if (!runId && egg) runId=await rollCall(session,pref,promptId,options.signal)
371
413
  if (!runId) {
372
414
  const currentIds=new Set(current.map(m=>m.id))
373
415
  const historyText=options.messages.filter(m=>!currentIds.has(m.id) && (m.role==='assistant'||m.role==='user'&&m.source?.kind==='user'))
@@ -381,23 +423,17 @@ export async function installHost(ctx,config,api) {
381
423
  const provider=(await catalog()).routes.find(r=>r.providerId===options.provider && r.modelId===options.model && selected.includes(r.id))
382
424
  const materialIds=pref.materialIds
383
425
  const created=await create(session,{task,routeIds:selected,preferredPlannerId:provider?.id,materialIds},
384
- {history,promptId,materialSelectionId:materialIds.length?room.materialSelection.id:null,
385
- beforeAutoStart:()=>graphRead})
426
+ {history,promptId,materialSelectionId:materialIds.length?room.materialSelection.id:null})
386
427
  runId=created.runId
387
428
  }
388
429
  engine=obtain(session,runId)
430
+ nativeDeliveries.set(runId,(nativeDeliveries.get(runId) || 0)+1)
389
431
  blockStarted=true
390
432
  yield {type:'block-start',index:0,blockType:'text'}
391
- const plan=await waitForRun(engine,s=>s.planVersion>0 || settled(s),options.signal)
392
- if(plan.planVersion>0)yield {type:'text-delta',index:0,text:formatConversationPlan(plan)}
393
- graphDelivered=true
394
- releaseGraph()
395
- const done=settled(plan)?plan:await waitForRun(engine,settled,options.signal)
396
- const outputs=delivered(done)
397
- const body=done.status==='completed' ? outputs.map(a=>a.text+(a.unresolved.length?'\n未决项:'+a.unresolved.join('、'):'')).join('\n\n') :
433
+ const done=await waitForRun(engine,settled,options.signal)
434
+ const body=done.status==='completed' ? completedText(done) :
398
435
  done.status==='cancelled'?'协作已取消。':'协作需要处理。'+(done.error || done.nodes.find(n=>n.reason)?.reason || '请打开任务图查看阻塞原因。')
399
- const footer='\n\n协作运行 '+runId+(outputs.length?' · '+outputs.map(a=>done.routes.find(r=>r.id===a.routeId)?.label || a.routeId).join('、'):'')
400
- yield {type:'text-delta',index:0,text:(done.status==='completed'?'**执行结果**\n\n':'')+body+footer}
436
+ yield {type:'text-delta',index:0,text:body}
401
437
  yield {type:'finish',reason:{kind:'stop'}}
402
438
  }catch(error){
403
439
  if (options.signal?.aborted) throw error
@@ -405,9 +441,12 @@ export async function installHost(ctx,config,api) {
405
441
  yield {type:'text-delta',index:0,text:'协作未完成:'+error.message}
406
442
  yield {type:'finish',reason:{kind:'stop'}}
407
443
  }finally{
408
- if(engine && (!graphDelivered || options.signal?.aborted) && !settled(engine.snapshot()))await engine.cancel().catch(()=>{})
409
- releaseGraph()
410
- if(runId)nativeDeliveries.delete(runId)
444
+ if(engine && (!engine.snapshot().planVersion || options.signal?.aborted) && !settled(engine.snapshot()))await engine.cancel().catch(()=>{})
445
+ if (engine) {
446
+ const remaining=(nativeDeliveries.get(runId) || 1)-1
447
+ if (remaining) nativeDeliveries.set(runId,remaining)
448
+ else nativeDeliveries.delete(runId)
449
+ }
411
450
  }
412
451
  }
413
452
  ctx.commands.register({definitionId:name,name:'collab',description:'在当前会话规划并执行多模型协作任务',input:{hint:'<任务>'},
@@ -420,8 +459,8 @@ export async function installHost(ctx,config,api) {
420
459
  const pref=composerSettings(room,inv.agent.session.id)
421
460
  const allowed=pref.routeIds.length?pref.routeIds:planner?[planner.id]:[]
422
461
  if (!allowed.length) throw Error('请先在会话中选择参与模型。')
423
- const {runId}=await create(inv.agent.session,{task:inv.rawInput,routeIds:allowed,preferredPlannerId:planner?.id})
424
- return {kind:'success',text:'协作规划已开始。打开输入框的「协作」查看分工和用量。\n运行 '+runId}
462
+ await create(inv.agent.session,{task:inv.rawInput,routeIds:allowed,preferredPlannerId:planner?.id})
463
+ return {kind:'success',text:'协作已开始,可在右侧协作导图查看进度。'}
425
464
  } catch(error) {return {kind:'error',text:error.message}}
426
465
  }})
427
466
  ctx.on('session/disposed',session=>{
@@ -1,20 +1,3 @@
1
- function inline(value) {
2
- return String(value ?? '').replace(/[\r\n\t]+/g,' ').replace(/([\\`*_\[\]<>])/g,'\\$1')
3
- }
4
- export function formatConversationPlan(run) {
5
- const labels=new Map(run.routes.map(r=>[r.id,inline(r.label || r.modelId || r.id)]))
6
- const indices=new Map(run.nodes.map((node,i)=>[node.id,i+1]))
7
- const rows=run.nodes.slice(0,16).map(node=>{
8
- const predecessors=node.deps.length?node.deps.map(id=>'第 '+indices.get(id)+' 步').join('、'):'统筹计划'
9
- return indices.get(node.id)+'. **'+inline(node.title)+'** · '+(labels.get(node.routeId) || inline(node.routeId))+' · 承接'+predecessors
10
- })
11
- if (run.nodes.length>rows.length) rows.push('其余 '+(run.nodes.length-rows.length)+' 步见右栏完整任务图。')
12
- return '**协作分工图 · 版本 '+run.planVersion+'**\n\n统筹模型 '+(labels.get(run.plannerRouteId) || inline(run.plannerRouteId))+
13
- ' 已发布计划。开工方式为'+(run.mode==='manual'?'确认后执行。':'直接执行。')+
14
- (run.settings?.unavailableRouteIds?.length?'\n本次跳过暂不可用的已选型号:'+run.settings.unavailableRouteIds.map(inline).join('、')+'。':'')+
15
- '\n\n'+rows.join('\n')+'\n\n'
16
- }
17
-
18
1
  export function isNewVisiblePlan(run,mountedAt,currentSessionId,sessionId,lastShown) {
19
2
  return !!(run && run.native && run.planVersion>0 && run.runId!==lastShown && currentSessionId===sessionId &&
20
3
  Number.isFinite(Date.parse(run.createdAt)) && Date.parse(run.createdAt)>=mountedAt)
@@ -0,0 +1,78 @@
1
+ import {allocateEggReplies, chooseNovaClosing, formatEggMessage, formatEggReply} from '../src/easter-egg.mjs'
2
+ import {PRESENCE_TRIGGER} from './exact-composer-text.mjs'
3
+ import {streamText} from './models.mjs'
4
+
5
+ export function isRollCall(current) {
6
+ if (current.length !== 1) return false
7
+ const message = current[0]
8
+ return message.source?.kind === 'user' && message.content?.length === 1 &&
9
+ message.content[0].type === 'text' && message.content[0].text === PRESENCE_TRIGGER
10
+ }
11
+
12
+ function unavailableRoute(id) {
13
+ const split = id.indexOf('/')
14
+ if (split !== -1) {
15
+ try {
16
+ return {id, providerId:decodeURIComponent(id.slice(0, split)), modelId:decodeURIComponent(id.slice(split + 1)),
17
+ enabled:false, capabilities:[]}
18
+ } catch { /* A previously stored route may use a different key format. */ }
19
+ }
20
+ return {id, modelId:id, enabled:false, capabilities:[]}
21
+ }
22
+
23
+ export function prepareRollCall(pref, routes) {
24
+ const directory = new Map(routes.map(route => [route.id, route]))
25
+ const participants = [...new Set(pref.routeIds)].map(id => directory.get(id) || unavailableRoute(id))
26
+ // Deal to reachable text models first so an old checkbox cannot use up a category.
27
+ const available = [], unavailable = []
28
+ for (const route of participants) {
29
+ if (route.enabled !== false && (route.capabilities ?? ['text']).includes('text')) available.push(route)
30
+ else unavailable.push(route)
31
+ }
32
+ const assigned = new Map(allocateEggReplies([...available, ...unavailable]).map(reply => [reply.routeId, reply]))
33
+ const replies = participants.map(route => assigned.get(route.id))
34
+ return {participants, replies, closing:chooseNovaClosing()}
35
+ }
36
+
37
+ export async function executeRollCall(ctx, args) {
38
+ const reply = args.settings.easterEgg.replies.find(item => item.routeId === args.route.id)
39
+ if (!reply || args.route.id !== args.node.routeId) throw Object.assign(Error('未找到该型号的彩蛋候选。'), {dispatched:false})
40
+ const messages = [
41
+ {role:'system', content:'NOVA 彩蛋点名。用户问“在嘛?”。请从用户消息的 JSON 数组中任选一句作答。只返回从 1 开始的选项编号,或逐字返回所选原句。'},
42
+ {role:'user', content:JSON.stringify(reply.choices)},
43
+ ]
44
+ // A stalled provider must release its slot so the other selected models can answer.
45
+ const signal = AbortSignal.any([args.signal, AbortSignal.timeout(90_000)])
46
+ signal.throwIfAborted()
47
+ let onAbort
48
+ const aborted = new Promise((_, reject) => {
49
+ onAbort = () => reject(signal.reason)
50
+ signal.addEventListener('abort', onAbort, {once:true})
51
+ })
52
+ let result
53
+ try {
54
+ result = await Promise.race([streamText(ctx, {...args, signal}, messages, args.node.outputReserve), aborted])
55
+ } finally {
56
+ signal.removeEventListener('abort', onAbort)
57
+ }
58
+ const answer = result.text
59
+ const chosen = /^[1-9]\d*$/.test(answer) ? reply.choices[Number(answer) - 1] : reply.choices.find(text => text === answer)
60
+ if (chosen === undefined) throw Object.assign(Error('该型号未返回有效的彩蛋选项。'), {usage:result.usage})
61
+ return {...result, text:chosen}
62
+ }
63
+
64
+ export function renderRollCall(snapshot) {
65
+ const {replies, closing} = snapshot.settings.easterEgg
66
+ const directory = new Map(snapshot.routes.map(route => [route.id, route]))
67
+ const nodes = new Map(snapshot.nodes.map(node => [node.routeId, node]))
68
+ const artifacts = new Map(snapshot.artifacts.map(artifact => [artifact.id, artifact]))
69
+ const lines = replies.map(({routeId, choices}) => {
70
+ const route = directory.get(routeId) || unavailableRoute(routeId)
71
+ const node = nodes.get(routeId)
72
+ const artifact = artifacts.get(node?.artifactId)
73
+ const text = artifact?.routeId === routeId && choices.includes(artifact.text) ? artifact.text :
74
+ route.enabled === false ? '(型号当前不可用)' : '(本次未回应)'
75
+ return formatEggReply(route, text)
76
+ })
77
+ return formatEggMessage(lines, closing)
78
+ }
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "dsh-nova-lewis",
3
- "version": "0.2.1",
3
+ "version": "0.2.2",
4
4
  "lewisEnchantRelease": {
5
- "version": "0.2.1",
6
- "notes": "修复勾选多个型号时统筹计划因输出额度不足而被截断的问题。已选型号暂不可用时,协作可使用符合本次分工和权限的候补型号。在输入框的「协作」中可以为每个型号选择 DSH 已配置的推理等级。"
5
+ "version": "0.2.2",
6
+ "notes": ""
7
7
  },
8
8
  "lewisEnchantReleaseEn": {
9
- "version": "0.2.1",
10
- "notes": "Fixed truncated plans when multiple models are selected. Eligible selected models can take over when a coordinator or text worker is unavailable. In the chat collaboration menu, choose from the reasoning levels configured in DSH for each model."
9
+ "version": "0.2.2",
10
+ "notes": ""
11
11
  },
12
12
  "type": "module",
13
13
  "publishConfig": {
@@ -0,0 +1,86 @@
1
+ // 彩蛋.xlsx, Sheet1!B2:I8. Column C labels the languages of the replies in D.
2
+ export const eggPhrases = Object.freeze({
3
+ 古怪: Object.freeze(['にゃ〜 ฅ^•ﻌ•^ฅ', 'Ciallo~(∠・ω< )⌒★']),
4
+ 各国语言: Object.freeze(['Coucou!', 'Holaaa~', 'Hallöchen!', 'Привет!', '안뇽!', 'はーい!( ´ ▽ ` )ノ', 'やっほー!(≧▽≦)']),
5
+ 正常人类: Object.freeze(['怎么啦?', '嗨', '一直在啊']),
6
+ 不正常: Object.freeze(['你猜?', '可以不在吗?', '阿巴阿巴', '又有活了']),
7
+ 程序员: Object.freeze(['Let me cook', 'Noodling…']),
8
+ 颜文字: Object.freeze(['👀', '( ̄▽ ̄)', '(・∀・)', '(`・ω・´)', '(=^・ω・^=)']),
9
+ nova系列: Object.freeze(['Still shining ✩', 'Ad astra ✧', '(∩^o^)⊃━☆゚.*', '星星收到啦 ✦']),
10
+ })
11
+
12
+ const closings = [
13
+ "**NOVA:See? We're all here. ✦**",
14
+ '**NOVA:Here we are, together. ♡**',
15
+ '**NOVA:Present and shining! ✧**',
16
+ ]
17
+
18
+ // Draw every item once before refilling. At a cycle boundary avoid repeating the last draw.
19
+ function drawFrom(items, random) {
20
+ let pool = [], previous
21
+ return () => {
22
+ let available = pool.length
23
+ if (!available) {
24
+ pool = items.filter(item=>item!==previous)
25
+ available = pool.length
26
+ if (previous!==undefined) pool.push(previous)
27
+ }
28
+ const index = Math.floor(random() * (available || pool.length))
29
+ previous = pool.splice(index,1)[0]
30
+ return previous
31
+ }
32
+ }
33
+
34
+ const modelName = route => route.modelId || route.label || route.id
35
+ const oneLine = text => String(text).replace(/[\u0000-\u001f\u007f-\u009f\u2028\u2029]+/gu,' ')
36
+ .replace(/[\u061c\u200e\u200f\u202a-\u202e\u2066-\u2069]/gu,'').trim()
37
+ const renderPhrase = (phrase, route) => phrase.replaceAll('【模型】',()=>oneLine(modelName(route)))
38
+
39
+ export function allocateEggReplies(routes, random = Math.random) {
40
+ const categories = Object.keys(eggPhrases)
41
+ const nextCategory = drawFrom(categories, random)
42
+ const members = new Map(categories.map(category=>[category,[]]))
43
+ const replies = routes.map(route=>{
44
+ const category = nextCategory()
45
+ const reply = {routeId:route.id, category, text:'', choices:[]}
46
+ members.get(category).push({route, reply})
47
+ return reply
48
+ })
49
+ for (const [category, team] of members) {
50
+ if (!team.length) continue
51
+ const phrases = eggPhrases[category]
52
+ const nextPhrase = drawFrom(phrases,random), unused = new Set(phrases)
53
+ for (const {route, reply} of team) {
54
+ const phrase = nextPhrase()
55
+ unused.delete(phrase)
56
+ reply.text = renderPhrase(phrase,route)
57
+ reply.choices.push(reply.text)
58
+ }
59
+ // Disjoint menus let each live model choose freely without duplicating another model's choices.
60
+ const extraPhrase = drawFrom([...unused],random), recipient = drawFrom(team,random)
61
+ for (let i = 0; i < unused.size; i++) {
62
+ const {route, reply} = recipient()
63
+ reply.choices.push(renderPhrase(extraPhrase(),route))
64
+ }
65
+ }
66
+ return replies
67
+ }
68
+
69
+ function markdownText(value) {
70
+ return oneLine(value).replace(/[\\`*_\[\]<>~&|]/g,'\\$&')
71
+ }
72
+
73
+ export function formatEggReply(route, text) {
74
+ const provider = route.providerId || route.apiId
75
+ const name = provider ? provider+' / '+modelName(route) : modelName(route)
76
+ return '**'+markdownText(name)+'**:'+markdownText(text)
77
+ }
78
+
79
+ export function chooseNovaClosing(random = Math.random) {
80
+ return closings[Math.floor(random() * closings.length)]
81
+ }
82
+
83
+ export function formatEggMessage(lines, closing = chooseNovaClosing()) {
84
+ if (!closings.includes(closing)) throw Error('未知的 NOVA 彩蛋结语。')
85
+ return lines.length ? lines.join(' \n')+'\n\n'+closing : closing
86
+ }
@@ -17,9 +17,9 @@ export function routeCatalog(routes) {
17
17
  return copy(routes)
18
18
  }
19
19
 
20
- export function normalizeNodes(plan) {
21
- if (!Array.isArray(plan?.nodes) || !plan.nodes.length || plan.nodes.length > 100) {
22
- throw Error('计划需包含 1 至 100 个节点')
20
+ export function normalizeNodes(plan, maxNodes = 100) {
21
+ if (!Array.isArray(plan?.nodes) || !plan.nodes.length || plan.nodes.length > maxNodes) {
22
+ throw Error('计划需包含 1 至 '+maxNodes+' 个节点')
23
23
  }
24
24
  const ids = new Set()
25
25
  const deliverables = new Set()
package/src/engine.mjs CHANGED
@@ -87,7 +87,7 @@ function beginAttempt(state, node, route, kind, reserved) {
87
87
 
88
88
  function publish(state, plan, fromPlanner = false) {
89
89
  if (plan?.validationError) throw Error(String(plan.validationError))
90
- const nodes = normalizeNodes(plan)
90
+ const nodes = normalizeNodes(plan, !fromPlanner && state.settings.easterEgg ? state.allowedRouteIds.length : undefined)
91
91
  if (fromPlanner && nodes.length > 1) {
92
92
  const byId = new Map(nodes.map(n => [n.id, n])), prerequisites = new Set()
93
93
  const include = id => {
@@ -267,8 +267,9 @@ export class RunEngine {
267
267
  this.#beforeAutoStart = options.beforeAutoStart
268
268
  const settings = copy(options.settings || {})
269
269
  const allowedRouteIds = strings(options.allowedRouteIds ?? routes.filter(route => route.enabled !== false).map(route => route.id), '允许的路由')
270
- const plannerAssignment = options.plannerAssignment || choosePlanner(routes.filter(r=>allowedRouteIds.includes(r.id)), options.task || '',
271
- {lockedId:options.plannerRouteId,preferredId:options.preferredPlannerId})
270
+ const plannerAssignment = settings.easterEgg || !allowedRouteIds.length ? null : options.plannerAssignment ||
271
+ choosePlanner(routes.filter(r=>allowedRouteIds.includes(r.id)), options.task || '',
272
+ {lockedId:options.plannerRouteId,preferredId:options.preferredPlannerId})
272
273
  const configured = key => options[key] ?? settings[key]
273
274
  const maxTokens = safeLimit(configured('maxTokens'), 'Token 预算')
274
275
  const defaultFinalTokens = maxTokens == null ? 0 : Math.min(2048, Math.floor(maxTokens / 8))