@michengai/dsh-btw 0.1.8 → 0.1.10

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 CHANGED
@@ -1,5 +1,15 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.1.10] - 2026-09-18
4
+
5
+ - List `/btw` in the official command catalog with a label, description, and icon.
6
+ - Keep independent bubbles when submitting from the official catalog; side questions still do not run tools.
7
+
8
+ ## [0.1.9] - 2026-09-18
9
+
10
+ - Support DSH `0.1.6-alpha.2` while retaining compatibility with the six previously supported host versions.
11
+ - Use the official composer focus action when adding a quote to the conversation.
12
+
3
13
  ## [0.1.8] - 2026-09-16
4
14
 
5
15
  - Support DSH `0.1.6-alpha.1` while retaining compatibility with the five previously supported host versions.
@@ -1,5 +1,15 @@
1
1
  # 更新日志
2
2
 
3
+ ## [0.1.10] - 2026-09-18
4
+
5
+ - 将 `/btw` 列入官方「指令」目录,并补上名称、说明和图标。
6
+ - 从官方目录提交时仍走独立气泡,不执行工具。
7
+
8
+ ## [0.1.9] - 2026-09-18
9
+
10
+ - 支持 DSH `0.1.6-alpha.2`,同时保留此前六个宿主版本的兼容支持。
11
+ - 添加引用到对话时改用宿主输入框的官方聚焦接口。
12
+
3
13
  ## [0.1.8] - 2026-09-16
4
14
 
5
15
  - 支持 DSH `0.1.6-alpha.1`,同时保留此前五个宿主版本的兼容支持。
package/README.md CHANGED
@@ -37,9 +37,9 @@ The main conversation stays in place, with the side answer above the composer.
37
37
 
38
38
  ### Command menu
39
39
 
40
- Type `/` and select `btw` under the side-question category, or enter `/btw your question` directly.
40
+ Type `/` and select `btw` under Commands, or enter `/btw your question` directly.
41
41
 
42
- ![The side-question category and btw command](https://raw.githubusercontent.com/MichengAI/dsh-btw/2d8dd7752cec1b29dd705969eaa932635ba0bf4f/assets/screenshots/btw-command-menu.png)
42
+ ![The official command menu with btw](https://raw.githubusercontent.com/MichengAI/dsh-btw/2d8dd7752cec1b29dd705969eaa932635ba0bf4f/assets/screenshots/btw-command-menu.png)
43
43
 
44
44
  ### Independent answer bubbles
45
45
 
@@ -68,7 +68,7 @@ For a desktop workbench, download [DSH Codex Desktop](https://github.com/Micheng
68
68
  ## Prerequisites
69
69
 
70
70
  - An installed copy of DeepSeek Harness.
71
- - Host peers accept exactly `0.1.0-rc.8 || 0.1.1-rc.2 || 0.1.2-rc.1 || 0.1.5-rc.1 || 0.1.5-rc.2 || 0.1.6-alpha.1`.
71
+ - Host peers accept exactly `0.1.0-rc.8 || 0.1.1-rc.2 || 0.1.2-rc.1 || 0.1.5-rc.1 || 0.1.5-rc.2 || 0.1.6-alpha.1 || 0.1.6-alpha.2`.
72
72
  - Node.js 22+ and `dsh` available in your terminal.
73
73
 
74
74
  ## Installation
@@ -160,7 +160,7 @@ npm run check
160
160
 
161
161
  `npm run check` runs type checking, tests, and a build.
162
162
 
163
- Development and builds target `0.1.6-alpha.1`. `npm run test:compat` builds with that baseline and runs the test suite on each of the six isolated host versions, using a test model adapter. DOM component tests do not replace live-browser acceptance.
163
+ Development and builds target `0.1.6-alpha.2`. `npm run test:compat` builds with that baseline and runs the test suite on each of the seven isolated host versions, using a test model adapter. DOM component tests do not replace live-browser acceptance.
164
164
 
165
165
  Previous manual end-to-end acceptance with Edge and a live DeepSeek model passed on `0.1.5-rc.1`: side questions, attachment rejection, copying, collapse/expand, cancellation, and continued parent-session operation. This is not part of `npm run test:compat`. The selection toolbar, draft insertion, sidebar coexistence, and real-model side answers were subsequently checked on `0.1.5-rc.2`; the full end-to-end suite remains pending on that version and the older three versions.
166
166
 
package/README.zh-CN.md CHANGED
@@ -37,9 +37,9 @@
37
37
 
38
38
  ### 命令入口
39
39
 
40
- 输入 `/` 后,可在「旁问」分类中选择 `btw`,也可以直接输入 `/btw 问题`。
40
+ 输入 `/` 后,可在「指令」中选择 `btw`,也可以直接输入 `/btw 问题`。
41
41
 
42
- ![命令菜单中的旁问分类和 btw 入口](https://raw.githubusercontent.com/MichengAI/dsh-btw/2d8dd7752cec1b29dd705969eaa932635ba0bf4f/assets/screenshots/btw-command-menu.png)
42
+ ![官方指令菜单中的 btw 入口](https://raw.githubusercontent.com/MichengAI/dsh-btw/2d8dd7752cec1b29dd705969eaa932635ba0bf4f/assets/screenshots/btw-command-menu.png)
43
43
 
44
44
  ### 独立答案气泡
45
45
 
@@ -68,7 +68,7 @@
68
68
  ## 前置条件
69
69
 
70
70
  - 已安装 DeepSeek Harness。
71
- - 宿主 peer 依赖精确声明为 `0.1.0-rc.8 || 0.1.1-rc.2 || 0.1.2-rc.1 || 0.1.5-rc.1 || 0.1.5-rc.2 || 0.1.6-alpha.1`。
71
+ - 宿主 peer 依赖精确声明为 `0.1.0-rc.8 || 0.1.1-rc.2 || 0.1.2-rc.1 || 0.1.5-rc.1 || 0.1.5-rc.2 || 0.1.6-alpha.1 || 0.1.6-alpha.2`。
72
72
  - Node.js 22+,可在终端执行 `dsh`。
73
73
 
74
74
  ## 安装
@@ -159,7 +159,7 @@ npm run check
159
159
 
160
160
  `npm run check` 执行类型检查、测试和构建。
161
161
 
162
- 开发与构建基线为 `0.1.6-alpha.1`。`npm run test:compat` 用该基线编译,再在六个隔离宿主版本中分别运行测试集,模型使用测试适配器。DOM 组件测试不替代真实浏览器验收。
162
+ 开发与构建基线为 `0.1.6-alpha.2`。`npm run test:compat` 用该基线编译,再在七个隔离宿主版本中分别运行测试集,模型使用测试适配器。DOM 组件测试不替代真实浏览器验收。
163
163
 
164
164
  此前在 `0.1.5-rc.1` 上完成真实 Edge 与 DeepSeek 模型的手工端到端验收,旁问、附件拒绝、复制、折叠/展开、取消和父会话继续均通过。这不属于 `npm run test:compat`;随后在 `0.1.5-rc.2` 验证了划词横条、添加引用、侧边栏共存及真实模型旁问回答;该版本与旧三版的完整端到端用例仍未全部验收。
165
165
 
package/lib/client.js CHANGED
@@ -369,6 +369,110 @@ __export(index_exports, {
369
369
  module.exports = __toCommonJS(index_exports);
370
370
  var import_react6 = __toESM(require("react"), 1);
371
371
 
372
+ // node_modules/lucide-react/dist/esm/createLucideIcon.js
373
+ var import_react2 = require("react");
374
+
375
+ // node_modules/lucide-react/dist/esm/shared/src/utils.js
376
+ var toKebabCase = (string3) => string3.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase();
377
+ var mergeClasses = (...classes) => classes.filter((className, index2, array) => {
378
+ return Boolean(className) && className.trim() !== "" && array.indexOf(className) === index2;
379
+ }).join(" ").trim();
380
+
381
+ // node_modules/lucide-react/dist/esm/Icon.js
382
+ var import_react = require("react");
383
+
384
+ // node_modules/lucide-react/dist/esm/defaultAttributes.js
385
+ var defaultAttributes = {
386
+ xmlns: "http://www.w3.org/2000/svg",
387
+ width: 24,
388
+ height: 24,
389
+ viewBox: "0 0 24 24",
390
+ fill: "none",
391
+ stroke: "currentColor",
392
+ strokeWidth: 2,
393
+ strokeLinecap: "round",
394
+ strokeLinejoin: "round"
395
+ };
396
+
397
+ // node_modules/lucide-react/dist/esm/Icon.js
398
+ var Icon = (0, import_react.forwardRef)(
399
+ ({
400
+ color: color2 = "currentColor",
401
+ size = 24,
402
+ strokeWidth = 2,
403
+ absoluteStrokeWidth,
404
+ className = "",
405
+ children,
406
+ iconNode,
407
+ ...rest
408
+ }, ref) => {
409
+ return (0, import_react.createElement)(
410
+ "svg",
411
+ {
412
+ ref,
413
+ ...defaultAttributes,
414
+ width: size,
415
+ height: size,
416
+ stroke: color2,
417
+ strokeWidth: absoluteStrokeWidth ? Number(strokeWidth) * 24 / Number(size) : strokeWidth,
418
+ className: mergeClasses("lucide", className),
419
+ ...rest
420
+ },
421
+ [
422
+ ...iconNode.map(([tag, attrs]) => (0, import_react.createElement)(tag, attrs)),
423
+ ...Array.isArray(children) ? children : [children]
424
+ ]
425
+ );
426
+ }
427
+ );
428
+
429
+ // node_modules/lucide-react/dist/esm/createLucideIcon.js
430
+ var createLucideIcon = (iconName, iconNode) => {
431
+ const Component = (0, import_react2.forwardRef)(
432
+ ({ className, ...props }, ref) => (0, import_react2.createElement)(Icon, {
433
+ ref,
434
+ iconNode,
435
+ className: mergeClasses(`lucide-${toKebabCase(iconName)}`, className),
436
+ ...props
437
+ })
438
+ );
439
+ Component.displayName = `${iconName}`;
440
+ return Component;
441
+ };
442
+
443
+ // node_modules/lucide-react/dist/esm/icons/check.js
444
+ var Check = createLucideIcon("Check", [["path", { d: "M20 6 9 17l-5-5", key: "1gmf2c" }]]);
445
+
446
+ // node_modules/lucide-react/dist/esm/icons/chevron-down.js
447
+ var ChevronDown = createLucideIcon("ChevronDown", [
448
+ ["path", { d: "m6 9 6 6 6-6", key: "qrunsl" }]
449
+ ]);
450
+
451
+ // node_modules/lucide-react/dist/esm/icons/chevron-up.js
452
+ var ChevronUp = createLucideIcon("ChevronUp", [["path", { d: "m18 15-6-6-6 6", key: "153udz" }]]);
453
+
454
+ // node_modules/lucide-react/dist/esm/icons/copy.js
455
+ var Copy = createLucideIcon("Copy", [
456
+ ["rect", { width: "14", height: "14", x: "8", y: "8", rx: "2", ry: "2", key: "17jyea" }],
457
+ ["path", { d: "M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2", key: "zix9uf" }]
458
+ ]);
459
+
460
+ // node_modules/lucide-react/dist/esm/icons/loader-circle.js
461
+ var LoaderCircle = createLucideIcon("LoaderCircle", [
462
+ ["path", { d: "M21 12a9 9 0 1 1-6.219-8.56", key: "13zald" }]
463
+ ]);
464
+
465
+ // node_modules/lucide-react/dist/esm/icons/message-circle.js
466
+ var MessageCircle = createLucideIcon("MessageCircle", [
467
+ ["path", { d: "M7.9 20A9 9 0 1 0 4 16.1L2 22Z", key: "vv11sd" }]
468
+ ]);
469
+
470
+ // node_modules/lucide-react/dist/esm/icons/x.js
471
+ var X = createLucideIcon("X", [
472
+ ["path", { d: "M18 6 6 18", key: "1bl5f8" }],
473
+ ["path", { d: "m6 6 12 12", key: "d8bk6v" }]
474
+ ]);
475
+
372
476
  // src/limits.ts
373
477
  var MAX_QUESTION_LENGTH = 8e3;
374
478
  var MAX_REFERENCE_LENGTH = 8e3;
@@ -400,7 +504,8 @@ var zh = {
400
504
  "status.closing": "\u6B63\u5728\u5173\u95ED\u2026",
401
505
  "command.hint": "\u65C1\u95EE\u5185\u5BB9",
402
506
  "menu.group": "\u65C1\u95EE",
403
- "command.description": "\u6839\u636E\u5F53\u524D\u4E0A\u4E0B\u6587\u56DE\u7B54\u65C1\u95EE",
507
+ "command.label": "\u65C1\u95EE",
508
+ "command.description": "\u6839\u636E\u5F53\u524D\u4E0A\u4E0B\u6587\u56DE\u7B54\uFF0C\u4E0D\u6267\u884C\u5DE5\u5177",
404
509
  "error.copy": "\u590D\u5236\u5931\u8D25\uFF0C\u8BF7\u9009\u62E9\u56DE\u7B54\u6587\u5B57\u590D\u5236\u3002",
405
510
  "error.attachments": "\u65C1\u95EE\u53EA\u63A5\u53D7\u6587\u5B57\uFF0C\u56FE\u7247\u548C\u6587\u4EF6\u4ECD\u4FDD\u7559\u5728\u8F93\u5165\u6846\u4E2D\u3002",
406
511
  "error.removeAttachments": "\u65C1\u95EE\u53EA\u63A5\u53D7\u6587\u5B57\uFF0C\u8BF7\u5148\u79FB\u9664\u56FE\u7247\u548C\u6587\u4EF6\u3002",
@@ -448,7 +553,8 @@ var en = {
448
553
  "status.closing": "Closing\u2026",
449
554
  "command.hint": "Side question",
450
555
  "menu.group": "Side Questions",
451
- "command.description": "Ask a side question using the current context",
556
+ "command.label": "Side question",
557
+ "command.description": "Answer from current context without running tools",
452
558
  "error.copy": "Copy failed. Select the answer text to copy it.",
453
559
  "error.attachments": "Side questions accept text only. Your images and files remain in the input.",
454
560
  "error.removeAttachments": "Side questions accept text only. Remove the images and files first.",
@@ -576,110 +682,6 @@ var BubbleStore = class {
576
682
  // src/client/BubbleView.tsx
577
683
  var import_react4 = __toESM(require("react"), 1);
578
684
 
579
- // node_modules/lucide-react/dist/esm/createLucideIcon.js
580
- var import_react2 = require("react");
581
-
582
- // node_modules/lucide-react/dist/esm/shared/src/utils.js
583
- var toKebabCase = (string3) => string3.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase();
584
- var mergeClasses = (...classes) => classes.filter((className, index2, array) => {
585
- return Boolean(className) && className.trim() !== "" && array.indexOf(className) === index2;
586
- }).join(" ").trim();
587
-
588
- // node_modules/lucide-react/dist/esm/Icon.js
589
- var import_react = require("react");
590
-
591
- // node_modules/lucide-react/dist/esm/defaultAttributes.js
592
- var defaultAttributes = {
593
- xmlns: "http://www.w3.org/2000/svg",
594
- width: 24,
595
- height: 24,
596
- viewBox: "0 0 24 24",
597
- fill: "none",
598
- stroke: "currentColor",
599
- strokeWidth: 2,
600
- strokeLinecap: "round",
601
- strokeLinejoin: "round"
602
- };
603
-
604
- // node_modules/lucide-react/dist/esm/Icon.js
605
- var Icon = (0, import_react.forwardRef)(
606
- ({
607
- color: color2 = "currentColor",
608
- size = 24,
609
- strokeWidth = 2,
610
- absoluteStrokeWidth,
611
- className = "",
612
- children,
613
- iconNode,
614
- ...rest
615
- }, ref) => {
616
- return (0, import_react.createElement)(
617
- "svg",
618
- {
619
- ref,
620
- ...defaultAttributes,
621
- width: size,
622
- height: size,
623
- stroke: color2,
624
- strokeWidth: absoluteStrokeWidth ? Number(strokeWidth) * 24 / Number(size) : strokeWidth,
625
- className: mergeClasses("lucide", className),
626
- ...rest
627
- },
628
- [
629
- ...iconNode.map(([tag, attrs]) => (0, import_react.createElement)(tag, attrs)),
630
- ...Array.isArray(children) ? children : [children]
631
- ]
632
- );
633
- }
634
- );
635
-
636
- // node_modules/lucide-react/dist/esm/createLucideIcon.js
637
- var createLucideIcon = (iconName, iconNode) => {
638
- const Component = (0, import_react2.forwardRef)(
639
- ({ className, ...props }, ref) => (0, import_react2.createElement)(Icon, {
640
- ref,
641
- iconNode,
642
- className: mergeClasses(`lucide-${toKebabCase(iconName)}`, className),
643
- ...props
644
- })
645
- );
646
- Component.displayName = `${iconName}`;
647
- return Component;
648
- };
649
-
650
- // node_modules/lucide-react/dist/esm/icons/check.js
651
- var Check = createLucideIcon("Check", [["path", { d: "M20 6 9 17l-5-5", key: "1gmf2c" }]]);
652
-
653
- // node_modules/lucide-react/dist/esm/icons/chevron-down.js
654
- var ChevronDown = createLucideIcon("ChevronDown", [
655
- ["path", { d: "m6 9 6 6 6-6", key: "qrunsl" }]
656
- ]);
657
-
658
- // node_modules/lucide-react/dist/esm/icons/chevron-up.js
659
- var ChevronUp = createLucideIcon("ChevronUp", [["path", { d: "m18 15-6-6-6 6", key: "153udz" }]]);
660
-
661
- // node_modules/lucide-react/dist/esm/icons/copy.js
662
- var Copy = createLucideIcon("Copy", [
663
- ["rect", { width: "14", height: "14", x: "8", y: "8", rx: "2", ry: "2", key: "17jyea" }],
664
- ["path", { d: "M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2", key: "zix9uf" }]
665
- ]);
666
-
667
- // node_modules/lucide-react/dist/esm/icons/loader-circle.js
668
- var LoaderCircle = createLucideIcon("LoaderCircle", [
669
- ["path", { d: "M21 12a9 9 0 1 1-6.219-8.56", key: "13zald" }]
670
- ]);
671
-
672
- // node_modules/lucide-react/dist/esm/icons/message-circle.js
673
- var MessageCircle = createLucideIcon("MessageCircle", [
674
- ["path", { d: "M7.9 20A9 9 0 1 0 4 16.1L2 22Z", key: "vv11sd" }]
675
- ]);
676
-
677
- // node_modules/lucide-react/dist/esm/icons/x.js
678
- var X = createLucideIcon("X", [
679
- ["path", { d: "M18 6 6 18", key: "1bl5f8" }],
680
- ["path", { d: "m6 6 12 12", key: "d8bk6v" }]
681
- ]);
682
-
683
685
  // node_modules/devlop/lib/default.js
684
686
  function ok() {
685
687
  }
@@ -13404,11 +13406,11 @@ function appendQuote(draft, reference) {
13404
13406
 
13405
13407
  `;
13406
13408
  }
13407
- function addQuoteToComposer(input, reference, t, focus) {
13409
+ function addQuoteToComposer(input, reference, t) {
13408
13410
  const snapshot = input.state.getSnapshot();
13409
13411
  if (snapshot.phase === "adjudicating" || snapshot.phase === "submitting") throw new Error(t("error.composerBusy"));
13410
13412
  input.setDraft(appendQuote(snapshot.draft, reference));
13411
- focus();
13413
+ input.focus?.();
13412
13414
  }
13413
13415
 
13414
13416
  // src/client/SelectionAsk.tsx
@@ -13569,9 +13571,7 @@ function SelectionAsk({ store, sessionId, t, addToConversation }) {
13569
13571
  const add = () => {
13570
13572
  if (!draft) return;
13571
13573
  try {
13572
- addToConversation(draft.reference, () => {
13573
- anchor.current?.closest("[data-composer-seat]")?.querySelector('[contenteditable="true"]:not([aria-disabled="true"]), textarea:not(:disabled):not([readonly])')?.focus({ preventScroll: true });
13574
- });
13574
+ addToConversation(draft.reference);
13575
13575
  setDraft(void 0);
13576
13576
  } catch (issue) {
13577
13577
  setError(issue instanceof Error ? issue.message : String(issue));
@@ -13660,7 +13660,85 @@ var CSS = `
13660
13660
  `;
13661
13661
 
13662
13662
  // src/client/index.tsx
13663
- var inject = ["slots", "inputTriggers", "remote", "remote.commands", "locale", "conversation", "sessions"];
13663
+ var inject = ["slots", "remote", "remote.commands", "locale", "conversation", "sessions"];
13664
+ function BtwCommandIcon({ size = 16, className }) {
13665
+ return /* @__PURE__ */ import_react6.default.createElement(MessageCircle, { size, className });
13666
+ }
13667
+ function sessionIdOf(session) {
13668
+ if (typeof session === "string") return session;
13669
+ if (session && typeof session === "object" && "sessionId" in session) return String(session.sessionId);
13670
+ return String(session);
13671
+ }
13672
+ function attachOfficialBtw(commandUi, claim, t) {
13673
+ const live = commandUi;
13674
+ if (!live) return () => {
13675
+ };
13676
+ const restore = [];
13677
+ if (typeof live.candidates === "function") {
13678
+ const original = live.candidates;
13679
+ live.candidates = async (...args) => {
13680
+ const rows = await original.apply(live, args);
13681
+ if (!Array.isArray(rows)) return rows;
13682
+ return rows.map((row) => {
13683
+ if (!row || typeof row !== "object" || !("name" in row) || row.name !== "btw") return row;
13684
+ const item = row;
13685
+ return {
13686
+ ...item,
13687
+ label: t("command.label"),
13688
+ description: t("command.description"),
13689
+ hint: t("command.hint"),
13690
+ icon: item.icon ?? BtwCommandIcon
13691
+ };
13692
+ });
13693
+ };
13694
+ restore.push(() => {
13695
+ live.candidates = original;
13696
+ });
13697
+ }
13698
+ if (typeof live.dispatch === "function") {
13699
+ const original = live.dispatch.bind(live);
13700
+ live.dispatch = (pick) => pick.candidate?.name === "btw" ? claim(sessionIdOf(pick.session)) : original(pick);
13701
+ restore.push(() => {
13702
+ live.dispatch = original;
13703
+ });
13704
+ }
13705
+ if (typeof live.matchSpace === "function") {
13706
+ const original = live.matchSpace.bind(live);
13707
+ live.matchSpace = (session, token) => token === "/btw" ? claim(sessionIdOf(session)) : original(session, token);
13708
+ restore.push(() => {
13709
+ live.matchSpace = original;
13710
+ });
13711
+ }
13712
+ if (typeof live.matchEnter === "function") {
13713
+ const original = live.matchEnter.bind(live);
13714
+ live.matchEnter = async (session, line, signal, envelope) => {
13715
+ if (!/^\/btw(?:\s|$)/.test(line.trim())) return original(session, line, signal, envelope);
13716
+ if (envelope?.attachments || envelope?.images) throw new Error(t("error.removeAttachments"));
13717
+ return claim(sessionIdOf(session));
13718
+ };
13719
+ restore.push(() => {
13720
+ live.matchEnter = original;
13721
+ });
13722
+ }
13723
+ if (typeof live.execute === "function") {
13724
+ const original = live.execute.bind(live);
13725
+ live.execute = async (session, line, attachments) => {
13726
+ if (!/^\/btw(?:\s|$)/.test(line)) return original(session, line, attachments);
13727
+ if (Array.isArray(attachments) && attachments.length) return { kind: "error", text: t("error.attachments") };
13728
+ const outcome = claim(sessionIdOf(session));
13729
+ if (!outcome || typeof outcome !== "object" || !("claim" in outcome)) return { kind: "error", text: t("error.backend") };
13730
+ try {
13731
+ return await outcome.claim.submit(line.replace(/^\/btw\s*/, "").trim(), void 0, []);
13732
+ } catch (error) {
13733
+ return { kind: "error", text: error instanceof Error ? error.message : String(error) };
13734
+ }
13735
+ };
13736
+ restore.push(() => {
13737
+ live.execute = original;
13738
+ });
13739
+ }
13740
+ return () => restore.forEach((dispose) => dispose());
13741
+ }
13664
13742
  function apply(ctx) {
13665
13743
  ctx.effect(() => ctx.locale.register(NS, { zh, en }));
13666
13744
  const t = ctx.locale.bind(NS);
@@ -13692,38 +13770,8 @@ function apply(ctx) {
13692
13770
  }
13693
13771
  }
13694
13772
  } });
13695
- const source = {
13696
- name: "btw",
13697
- trigger: "/",
13698
- order: -100,
13699
- candidates: async (_session, request) => !request.signal.aborted && "btw".startsWith(request.query.toLowerCase()) ? [{ name: "btw", description: t("command.description"), hint: t("command.hint") }] : [],
13700
- onPick: (pick) => pick.candidate.name === "btw" ? claim(pick.session.sessionId) : void 0,
13701
- matchSpace: (session, token) => token === "/btw" ? claim(session.sessionId) : void 0,
13702
- matchEnter: async (session, line, signal, envelope) => {
13703
- if (signal.aborted || !/^\/btw(?:\s|$)/.test(line)) return void 0;
13704
- const input = envelope;
13705
- if (input.attachments || input.images) throw new Error(t("error.removeAttachments"));
13706
- return claim(session.sessionId);
13707
- }
13708
- };
13709
- ctx.effect(() => {
13710
- let registeredName;
13711
- let unregister = () => {
13712
- };
13713
- const register = () => {
13714
- const name2 = t("menu.group");
13715
- if (name2 === registeredName) return;
13716
- unregister();
13717
- unregister = ctx.inputTriggers.registerSource({ ...source, name: name2 });
13718
- registeredName = name2;
13719
- };
13720
- register();
13721
- const unsubscribe = ctx.locale.subscribe(register);
13722
- return () => {
13723
- unsubscribe();
13724
- unregister();
13725
- };
13726
- });
13773
+ if (typeof ctx.inject === "function") ctx.inject(["commandUi"], (scope) => attachOfficialBtw(scope.get("commandUi"), (sessionId) => claim(sessionId), t));
13774
+ else ctx.effect(() => attachOfficialBtw(ctx.get("commandUi"), (sessionId) => claim(sessionId), t));
13727
13775
  ctx.effect(() => {
13728
13776
  const style = document.createElement("style");
13729
13777
  style.dataset.michengaiBtw = "";
@@ -13733,13 +13781,10 @@ function apply(ctx) {
13733
13781
  });
13734
13782
  ctx.effect(() => () => store.dispose());
13735
13783
  function Dock(props) {
13736
- return /* @__PURE__ */ import_react6.default.createElement(import_react6.default.Fragment, null, /* @__PURE__ */ import_react6.default.createElement(SelectionAsk, { key: props.session.sessionId, store, sessionId: props.session.sessionId, t: props.t, addToConversation: (reference, focusComposer) => {
13784
+ return /* @__PURE__ */ import_react6.default.createElement(import_react6.default.Fragment, null, /* @__PURE__ */ import_react6.default.createElement(SelectionAsk, { key: props.session.sessionId, store, sessionId: props.session.sessionId, t: props.t, addToConversation: (reference) => {
13737
13785
  const session = ctx.get("sessions").scope(props.session.sessionId);
13738
13786
  if (!session) throw new Error(props.t("error.backend"));
13739
- const input = ctx.conversation.input.for(session);
13740
- addQuoteToComposer(input, reference, props.t, () => {
13741
- focusComposer?.();
13742
- });
13787
+ addQuoteToComposer(ctx.conversation.input.for(session), reference, props.t);
13743
13788
  } }), /* @__PURE__ */ import_react6.default.createElement(BubbleDock, { store, sessionId: props.session.sessionId, t: props.t }));
13744
13789
  }
13745
13790
  slots.inject("conversation.input.dock", () => slots.register({ name: "conversation.input.dock", id: "michengai-btw", order: -50, locale: NS }, Dock));
package/lib/index.js CHANGED
@@ -28,7 +28,8 @@ var zh = {
28
28
  "status.closing": "\u6B63\u5728\u5173\u95ED\u2026",
29
29
  "command.hint": "\u65C1\u95EE\u5185\u5BB9",
30
30
  "menu.group": "\u65C1\u95EE",
31
- "command.description": "\u6839\u636E\u5F53\u524D\u4E0A\u4E0B\u6587\u56DE\u7B54\u65C1\u95EE",
31
+ "command.label": "\u65C1\u95EE",
32
+ "command.description": "\u6839\u636E\u5F53\u524D\u4E0A\u4E0B\u6587\u56DE\u7B54\uFF0C\u4E0D\u6267\u884C\u5DE5\u5177",
32
33
  "error.copy": "\u590D\u5236\u5931\u8D25\uFF0C\u8BF7\u9009\u62E9\u56DE\u7B54\u6587\u5B57\u590D\u5236\u3002",
33
34
  "error.attachments": "\u65C1\u95EE\u53EA\u63A5\u53D7\u6587\u5B57\uFF0C\u56FE\u7247\u548C\u6587\u4EF6\u4ECD\u4FDD\u7559\u5728\u8F93\u5165\u6846\u4E2D\u3002",
34
35
  "error.removeAttachments": "\u65C1\u95EE\u53EA\u63A5\u53D7\u6587\u5B57\uFF0C\u8BF7\u5148\u79FB\u9664\u56FE\u7247\u548C\u6587\u4EF6\u3002",
@@ -76,7 +77,8 @@ var en = {
76
77
  "status.closing": "Closing\u2026",
77
78
  "command.hint": "Side question",
78
79
  "menu.group": "Side Questions",
79
- "command.description": "Ask a side question using the current context",
80
+ "command.label": "Side question",
81
+ "command.description": "Answer from current context without running tools",
80
82
  "error.copy": "Copy failed. Select the answer text to copy it.",
81
83
  "error.attachments": "Side questions accept text only. Your images and files remain in the input.",
82
84
  "error.removeAttachments": "Side questions accept text only. Remove the images and files first.",
@@ -336,12 +338,33 @@ function descriptorLabel(data) {
336
338
  if (typeof data !== "object" || data === null || !("label" in data) || typeof data.label !== "string") return void 0;
337
339
  return data.label;
338
340
  }
339
- function lastDescriptorLabel(session) {
340
- if (typeof session?.snapshotEvents !== "function") return void 0;
341
- const event = session.snapshotEvents().findLast((item) => item.type === "subagent/descriptor");
342
- return descriptorLabel(event?.data);
341
+ function lastDescriptorLabel(session, identityOf) {
342
+ if (!session) return void 0;
343
+ if (identityOf) {
344
+ const identity = identityOf(session);
345
+ return typeof identity?.label === "string" ? identity.label : void 0;
346
+ }
347
+ const events = session.snapshotEvents;
348
+ if (typeof events !== "function") return void 0;
349
+ return descriptorLabel(events().findLast((item) => item.type === "subagent/descriptor")?.data);
343
350
  }
344
- function createAnswerOnlyGuard(labels) {
351
+ function identityOfFromContext(ctx) {
352
+ try {
353
+ const projections = ctx.get("sessionProjections");
354
+ const snapshot = projections?.snapshot;
355
+ if (typeof snapshot !== "function") return void 0;
356
+ return (session) => {
357
+ try {
358
+ return snapshot(session, ["subagent"]).values?.subagent ?? null;
359
+ } catch {
360
+ return null;
361
+ }
362
+ };
363
+ } catch {
364
+ return void 0;
365
+ }
366
+ }
367
+ function createAnswerOnlyGuard(labels, identityOf) {
345
368
  const owned = /* @__PURE__ */ new WeakSet();
346
369
  const claim = (value) => {
347
370
  if (value) owned.add(value);
@@ -349,7 +372,7 @@ function createAnswerOnlyGuard(labels) {
349
372
  const guard = ({ agent }) => {
350
373
  if (!agent) return void 0;
351
374
  if (owned.has(agent) || agent.session !== void 0 && owned.has(agent.session)) return DENY;
352
- const label = lastDescriptorLabel(agent.session);
375
+ const label = lastDescriptorLabel(agent.session, identityOf);
353
376
  if (!label || !labels.has(label)) return void 0;
354
377
  claim(agent);
355
378
  claim(agent.session);
@@ -394,8 +417,8 @@ var PERSONA = `\u4F60\u662F\u5F53\u524D\u4E3B\u4EFB\u52A1\u4E4B\u5916\u7684\u4E0
394
417
  function apply(ctx) {
395
418
  ctx.effect(() => hideInternalCommands(ctx.commands));
396
419
  const labels = /* @__PURE__ */ new Set();
397
- const protection = createAnswerOnlyGuard(labels);
398
420
  const host = ctx.extend({ fiber: ctx.root.fiber });
421
+ const protection = createAnswerOnlyGuard(labels, identityOfFromContext(host));
399
422
  const releaseGuard = host.tools.guard(protection);
400
423
  const stopWatch = host.on("session/event", (session, event) => protection.recognize(session, event));
401
424
  const jobs = new SideJobs(async (request) => {
@@ -436,6 +459,18 @@ ${request.question}` }]
436
459
  }
437
460
  });
438
461
  ctx.effect(() => () => jobs.dispose());
462
+ ctx.effect(() => ctx.commands.register({
463
+ name: "btw",
464
+ description: translate()("command.description"),
465
+ input: { hint: translate()("command.hint") },
466
+ recordInput: false,
467
+ handler: (invocation) => {
468
+ const question = invocation.rawInput.trim();
469
+ if (!question) return { kind: "error", text: translate()("error.empty") };
470
+ if (question.length > MAX_QUESTION_LENGTH) return { kind: "error", text: translate()("error.length") };
471
+ return jobs.ask(invocation.agent.session.header.id, globalThis.crypto.randomUUID(), question, invocation.signal, invocation.agent);
472
+ }
473
+ }));
439
474
  ctx.effect(() => ctx.commands.register({
440
475
  name: RUN_COMMAND,
441
476
  description: "BTW \u6C14\u6CE1\u5185\u90E8\u8BF7\u6C42",
@@ -6,5 +6,5 @@ export declare function SelectionAsk({ store, sessionId, t, addToConversation }:
6
6
  store: BubbleStore;
7
7
  sessionId: string;
8
8
  t: BtwTranslate;
9
- addToConversation: (reference: string, focusComposer: () => void) => void;
9
+ addToConversation: (reference: string) => void;
10
10
  }): React.JSX.Element;
@@ -7,9 +7,10 @@ interface DraftInput {
7
7
  };
8
8
  };
9
9
  setDraft(text: string): void;
10
+ focus?(): void;
10
11
  }
11
12
  /** 固定追加引用,保留原草稿;统一引用内部换行,正文空白不裁剪。 */
12
13
  export declare function appendQuote(draft: string, reference: string): string;
13
- /** 提交事务期间不改写草稿;成功写入后由调用方聚焦所属会话输入框。 */
14
- export declare function addQuoteToComposer(input: DraftInput, reference: string, t: BtwTranslate, focus: () => void): void;
14
+ /** 提交事务期间不改写草稿;成功写入后把键盘交回宿主输入框。 */
15
+ export declare function addQuoteToComposer(input: DraftInput, reference: string, t: BtwTranslate): void;
15
16
  export {};
@@ -25,6 +25,7 @@ export declare const zh: {
25
25
  'status.closing': string;
26
26
  'command.hint': string;
27
27
  'menu.group': string;
28
+ 'command.label': string;
28
29
  'command.description': string;
29
30
  'error.copy': string;
30
31
  'error.attachments': string;
@@ -6,8 +6,12 @@ export interface SessionIdentityHint {
6
6
  snapshotEvents?(): readonly SessionEventLike[];
7
7
  }
8
8
  export interface AgentIdentity {
9
- session?: SessionIdentityHint;
9
+ session?: object;
10
10
  }
11
+ export interface SubagentIdentityHint {
12
+ readonly label?: string;
13
+ }
14
+ export type IdentityOf = (session: object) => SubagentIdentityHint | null | undefined;
11
15
  export interface AnswerOnlyGuard {
12
16
  (execution: {
13
17
  agent?: AgentIdentity;
@@ -15,5 +19,9 @@ export interface AnswerOnlyGuard {
15
19
  own(agent: object): void;
16
20
  recognize(session: object, event: SessionEventLike): void;
17
21
  }
22
+ /** 官方替换同步事件扫描:ctx.sessionProjections.snapshot(session, ['subagent']).values.subagent */
23
+ export declare function identityOfFromContext(ctx: {
24
+ get(name: string): unknown;
25
+ }): IdentityOf | undefined;
18
26
  /** 空白名单过滤继承工具;本保护额外拒绝 PTC 及子作用域自注册工具。 */
19
- export declare function createAnswerOnlyGuard(labels: ReadonlySet<string>): AnswerOnlyGuard;
27
+ export declare function createAnswerOnlyGuard(labels: ReadonlySet<string>, identityOf?: IdentityOf): AnswerOnlyGuard;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@michengai/dsh-btw",
3
- "version": "0.1.8",
4
- "description": "DSH 一次性只读旁问气泡",
3
+ "version": "0.1.10",
4
+ "description": "DSH 一次性只读旁问插件:基于当前上下文回答,独立气泡,不执行工具 · One-shot read-only side-ask plugin: answers from current context in an independent bubble, no tool execution",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "git+https://github.com/MichengAI/dsh-btw.git"
@@ -42,7 +42,6 @@
42
42
  "platform": "web",
43
43
  "inject": [
44
44
  "@deepseek-ai/dsh-client-ui-conversation",
45
- "@deepseek-ai/dsh-client-ui-input-trigger",
46
45
  "@deepseek-ai/dsh-api-remotes",
47
46
  "@deepseek-ai/dsh-client-locale"
48
47
  ]
@@ -63,44 +62,44 @@
63
62
  "license": "Apache-2.0",
64
63
  "peerDependencies": {
65
64
  "@deepseek-ai/cordis": "^4.0.2",
66
- "@deepseek-ai/dsh-commands": "0.1.0-rc.8 || 0.1.1-rc.2 || 0.1.2-rc.1 || 0.1.5-rc.1 || 0.1.5-rc.2 || 0.1.6-alpha.1",
67
- "@deepseek-ai/dsh-subagent": "0.1.0-rc.8 || 0.1.1-rc.2 || 0.1.2-rc.1 || 0.1.5-rc.1 || 0.1.5-rc.2 || 0.1.6-alpha.1",
68
- "@deepseek-ai/dsh-tools": "0.1.0-rc.8 || 0.1.1-rc.2 || 0.1.2-rc.1 || 0.1.5-rc.1 || 0.1.5-rc.2 || 0.1.6-alpha.1",
65
+ "@deepseek-ai/dsh-commands": "0.1.0-rc.8 || 0.1.1-rc.2 || 0.1.2-rc.1 || 0.1.5-rc.1 || 0.1.5-rc.2 || 0.1.6-alpha.1 || 0.1.6-alpha.2",
66
+ "@deepseek-ai/dsh-subagent": "0.1.0-rc.8 || 0.1.1-rc.2 || 0.1.2-rc.1 || 0.1.5-rc.1 || 0.1.5-rc.2 || 0.1.6-alpha.1 || 0.1.6-alpha.2",
67
+ "@deepseek-ai/dsh-tools": "0.1.0-rc.8 || 0.1.1-rc.2 || 0.1.2-rc.1 || 0.1.5-rc.1 || 0.1.5-rc.2 || 0.1.6-alpha.1 || 0.1.6-alpha.2",
69
68
  "react": "^18.3.1"
70
69
  },
71
70
  "devDependencies": {
72
71
  "@deepseek-ai/cordis": "4.0.2",
73
- "@deepseek-ai/dsh-agent": "0.1.6-alpha.1",
74
- "@deepseek-ai/dsh-agent-loop": "0.1.6-alpha.1",
75
- "@deepseek-ai/dsh-api-gateway": "0.1.6-alpha.1",
76
- "@deepseek-ai/dsh-api-session-controller": "0.1.6-alpha.1",
77
- "@deepseek-ai/dsh-attachment": "0.1.6-alpha.1",
78
- "@deepseek-ai/dsh-client-locale": "0.1.6-alpha.1",
79
- "@deepseek-ai/dsh-client-ui-chat": "0.1.6-alpha.1",
80
- "@deepseek-ai/dsh-client-ui-conversation": "0.1.6-alpha.1",
81
- "@deepseek-ai/dsh-client-ui-input-trigger": "0.1.6-alpha.1",
82
- "@deepseek-ai/dsh-client-ui-renderer": "0.1.6-alpha.1",
83
- "@deepseek-ai/dsh-client-ui-slots": "0.1.6-alpha.1",
84
- "@deepseek-ai/dsh-client-ui-theme": "0.1.6-alpha.1",
85
- "@deepseek-ai/dsh-commands": "0.1.6-alpha.1",
86
- "@deepseek-ai/dsh-invariants": "0.1.6-alpha.1",
87
- "@deepseek-ai/dsh-llm": "0.1.6-alpha.1",
88
- "@deepseek-ai/dsh-ptc-runtime": "0.1.6-alpha.1",
89
- "@deepseek-ai/dsh-sandbox": "0.1.6-alpha.1",
90
- "@deepseek-ai/dsh-sandbox-policy": "0.1.6-alpha.1",
91
- "@deepseek-ai/dsh-scope": "0.1.6-alpha.1",
92
- "@deepseek-ai/dsh-session": "0.1.6-alpha.1",
93
- "@deepseek-ai/dsh-session-persistence": "0.1.6-alpha.1",
94
- "@deepseek-ai/dsh-session-projection": "0.1.6-alpha.1",
95
- "@deepseek-ai/dsh-subagent": "0.1.6-alpha.1",
96
- "@deepseek-ai/dsh-subagent-fork-in-process": "0.1.6-alpha.1",
97
- "@deepseek-ai/dsh-subagent-in-process-driver": "0.1.6-alpha.1",
98
- "@deepseek-ai/dsh-system-prompt": "0.1.6-alpha.1",
99
- "@deepseek-ai/dsh-tools": "0.1.6-alpha.1",
100
- "@deepseek-ai/dsh-user-approval": "0.1.6-alpha.1",
101
- "@deepseek-ai/dsh-typert-protocol": "0.1.6-alpha.1",
102
- "@deepseek-ai/dsh-typert-registry": "0.1.6-alpha.1",
103
- "@deepseek-ai/dsh-util-time": "0.1.6-alpha.1",
72
+ "@deepseek-ai/dsh-agent": "0.1.6-alpha.2",
73
+ "@deepseek-ai/dsh-agent-loop": "0.1.6-alpha.2",
74
+ "@deepseek-ai/dsh-api-gateway": "0.1.6-alpha.2",
75
+ "@deepseek-ai/dsh-api-session-controller": "0.1.6-alpha.2",
76
+ "@deepseek-ai/dsh-attachment": "0.1.6-alpha.2",
77
+ "@deepseek-ai/dsh-client-locale": "0.1.6-alpha.2",
78
+ "@deepseek-ai/dsh-client-ui-chat": "0.1.6-alpha.2",
79
+ "@deepseek-ai/dsh-client-ui-conversation": "0.1.6-alpha.2",
80
+ "@deepseek-ai/dsh-client-ui-input-trigger": "0.1.6-alpha.2",
81
+ "@deepseek-ai/dsh-client-ui-renderer": "0.1.6-alpha.2",
82
+ "@deepseek-ai/dsh-client-ui-slots": "0.1.6-alpha.2",
83
+ "@deepseek-ai/dsh-client-ui-theme": "0.1.6-alpha.2",
84
+ "@deepseek-ai/dsh-commands": "0.1.6-alpha.2",
85
+ "@deepseek-ai/dsh-invariants": "0.1.6-alpha.2",
86
+ "@deepseek-ai/dsh-llm": "0.1.6-alpha.2",
87
+ "@deepseek-ai/dsh-ptc-runtime": "0.1.6-alpha.2",
88
+ "@deepseek-ai/dsh-sandbox": "0.1.6-alpha.2",
89
+ "@deepseek-ai/dsh-sandbox-policy": "0.1.6-alpha.2",
90
+ "@deepseek-ai/dsh-scope": "0.1.6-alpha.2",
91
+ "@deepseek-ai/dsh-session": "0.1.6-alpha.2",
92
+ "@deepseek-ai/dsh-session-persistence": "0.1.6-alpha.2",
93
+ "@deepseek-ai/dsh-session-projection": "0.1.6-alpha.2",
94
+ "@deepseek-ai/dsh-subagent": "0.1.6-alpha.2",
95
+ "@deepseek-ai/dsh-subagent-fork-in-process": "0.1.6-alpha.2",
96
+ "@deepseek-ai/dsh-subagent-in-process-driver": "0.1.6-alpha.2",
97
+ "@deepseek-ai/dsh-system-prompt": "0.1.6-alpha.2",
98
+ "@deepseek-ai/dsh-tools": "0.1.6-alpha.2",
99
+ "@deepseek-ai/dsh-user-approval": "0.1.6-alpha.2",
100
+ "@deepseek-ai/dsh-typert-protocol": "0.1.6-alpha.2",
101
+ "@deepseek-ai/dsh-typert-registry": "0.1.6-alpha.2",
102
+ "@deepseek-ai/dsh-util-time": "0.1.6-alpha.2",
104
103
  "@types/node": "^22.0.0",
105
104
  "@types/react": "^18.3.1",
106
105
  "@types/react-dom": "^18.3.7",