@lynn123411/dsh-notify-user 0.5.2 → 0.5.4

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/lib/client.js CHANGED
@@ -448,6 +448,7 @@ function RootEnabledToggle({ sessionId, form, locked, reportFailure, t }) {
448
448
  var NS = "notifyUser";
449
449
  var en = {
450
450
  "row.preparing": "Sending update\u2026",
451
+ "row.failed": "Could not send update",
451
452
  "row.fallbackTitle": "Update",
452
453
  "markdown.copy": "Copy",
453
454
  "markdown.copied": "Copied",
@@ -459,10 +460,10 @@ var en = {
459
460
  "config.defaultEnabled.label": "On by default",
460
461
  "config.defaultEnabled.hint": "New sessions start with proactive updates on; change a single session in the model and reasoning menu.",
461
462
  "config.threshold.label": "Nudge after",
462
- "config.threshold.hint": "Tool calls without an update before the model is nudged; 0 turns nudging off.",
463
+ "config.threshold.hint": "Tool calls without an update before the model is nudged; 0 turns nudging off and leaves the update tool available.",
463
464
  "config.threshold.unit": "calls",
464
465
  "config.resetOnProse.label": "Reset on prose",
465
- "config.resetOnProse.hint": "Any assistant reply with text counts as an update and resets the count; turn it off to reset only on notify_user, a new turn, or a user message.",
466
+ "config.resetOnProse.hint": "Any assistant reply with text counts as an update and resets the count; turn it off to reset only on a successful update, a new turn, or a user message.",
466
467
  "config.reportMode.label": "Update format",
467
468
  "config.reportMode.hint": "Summary only: the model writes one line and the card shows just the title; structured body: the model writes a title and a body.",
468
469
  "config.reportMode.structured": "Structured body",
@@ -487,6 +488,7 @@ var en = {
487
488
  };
488
489
  var zh = {
489
490
  "row.preparing": "\u6B63\u5728\u6C47\u62A5\u2026",
491
+ "row.failed": "\u6C47\u62A5\u5931\u8D25",
490
492
  "row.fallbackTitle": "\u66F4\u65B0",
491
493
  "markdown.copy": "\u590D\u5236",
492
494
  "markdown.copied": "\u5DF2\u590D\u5236",
@@ -498,10 +500,10 @@ var zh = {
498
500
  "config.defaultEnabled.label": "\u9ED8\u8BA4\u5F00\u542F",
499
501
  "config.defaultEnabled.hint": "\u65B0\u4F1A\u8BDD\u9ED8\u8BA4\u6253\u5F00\u4E3B\u52A8\u6C47\u62A5\uFF1B\u5355\u4E2A\u4F1A\u8BDD\u7684\u5F00\u5173\u5728\u6A21\u578B\u4E0E\u63A8\u7406\u7B49\u7EA7\u83DC\u5355\u91CC\u3002",
500
502
  "config.threshold.label": "\u50AC\u529E\u9608\u503C",
501
- "config.threshold.hint": "\u8FDE\u7EED\u591A\u5C11\u6B21\u5DE5\u5177\u8C03\u7528\u6CA1\u6709\u6C47\u62A5\u65F6\u50AC\u4E00\u6B21\uFF1B0 \u5173\u95ED\u50AC\u529E\u3002",
503
+ "config.threshold.hint": "\u8FDE\u7EED\u591A\u5C11\u6B21\u5DE5\u5177\u8C03\u7528\u6CA1\u6709\u6C47\u62A5\u65F6\u50AC\u4E00\u6B21\uFF1B0 \u5173\u95ED\u50AC\u529E\uFF0C\u4ECD\u53EF\u4E3B\u52A8\u6C47\u62A5\u3002",
502
504
  "config.threshold.unit": "\u6B21",
503
505
  "config.resetOnProse.label": "\u6563\u6587\u56DE\u590D\u6E05\u96F6",
504
- "config.resetOnProse.hint": "\u6A21\u578B\u5728\u52A9\u624B\u6D88\u606F\u91CC\u5199\u4E86\u6B63\u6587\u5C31\u7B97\u6C47\u62A5\u8FC7\uFF0C\u8BA1\u6570\u6E05\u96F6\uFF1B\u5173\u6389\u540E\u53EA\u5728 notify_user\u3001\u65B0\u56DE\u5408\u6216\u7528\u6237\u63D2\u8BDD\u65F6\u6E05\u96F6\u3002",
506
+ "config.resetOnProse.hint": "\u6A21\u578B\u5728\u52A9\u624B\u6D88\u606F\u91CC\u5199\u4E86\u6B63\u6587\u5C31\u7B97\u6C47\u62A5\u8FC7\uFF0C\u8BA1\u6570\u6E05\u96F6\uFF1B\u5173\u6389\u540E\u53EA\u5728\u6C47\u62A5\u6210\u529F\u3001\u65B0\u56DE\u5408\u6216\u7528\u6237\u63D2\u8BDD\u65F6\u6E05\u96F6\u3002",
505
507
  "config.reportMode.label": "\u6C47\u62A5\u5F62\u6001",
506
508
  "config.reportMode.hint": "\u53EA\u62A5\u6458\u8981\u65F6\u6A21\u578B\u53EA\u5199\u4E00\u884C\u6807\u9898\uFF0C\u5361\u7247\u53EA\u663E\u793A\u6807\u9898\u884C\uFF1B\u7ED3\u6784\u5316\u6B63\u6587\u65F6\u6A21\u578B\u5199\u6807\u9898\u4E0E\u6B63\u6587\u3002",
507
509
  "config.reportMode.structured": "\u7ED3\u6784\u5316\u6B63\u6587",
@@ -526,6 +528,11 @@ var zh = {
526
528
  };
527
529
 
528
530
  // src/client/row-model.ts
531
+ function failureOf(content, error) {
532
+ const text = content.flatMap((block) => block.type === "text" && block.text?.trim() ? [block.text] : []).join("\n");
533
+ const detail = text || (error === void 0 ? "" : error.reason || `${error.name}: ${error.code}`);
534
+ return { detail };
535
+ }
529
536
  function parseUpdate(value) {
530
537
  if (typeof value !== "object" || value === null) return null;
531
538
  const record = value;
@@ -586,13 +593,22 @@ function settledState(current, update) {
586
593
  ...current.anchorSeq === void 0 ? {} : { anchorSeq: current.anchorSeq }
587
594
  };
588
595
  }
596
+ function rootResultState(event, current) {
597
+ if (event.data.message.isError) {
598
+ return {
599
+ ...stateOf(null, current?.time ?? event.time, true, current?.anchorSeq ?? event.seq),
600
+ failure: failureOf(event.data.message.content, event.data.error)
601
+ };
602
+ }
603
+ const update = parseUpdate(event.data.meta);
604
+ return current === void 0 ? stateOf(update, event.time, true, event.seq) : settledState(current, update);
605
+ }
589
606
  function fallbackState(context) {
590
607
  for (let index = context.matches.length - 1; index >= 0; index -= 1) {
591
608
  const event = context.matches[index].event;
592
- if (event.type === "tool/result") {
593
- return { ...parseUpdate(event.data.meta) ?? { message: "" }, time: event.time, settled: true, anchorSeq: event.seq };
594
- }
609
+ if (event.type === "tool/result") return rootResultState(event);
595
610
  if (event.type === "tool/ptc-dispatch") {
611
+ if (event.data.isError) return void 0;
596
612
  return {
597
613
  ...parseUpdate(event.data.meta) ?? parseUpdate(event.data.arguments) ?? { message: "" },
598
614
  time: event.time,
@@ -638,6 +654,9 @@ function createNotifyDefinition() {
638
654
  case "tool/ptc-dispatch-start":
639
655
  case "tool/ptc-dispatch": {
640
656
  if (event.data.name !== NOTIFY_TOOL_NAME) return null;
657
+ if (event.type === "tool/ptc-dispatch" && event.data.isError) {
658
+ return { id: String(event.data.subCallId), role: "update" };
659
+ }
641
660
  return {
642
661
  id: String(event.data.subCallId),
643
662
  role: event.type === "tool/ptc-dispatch-start" ? "start" : "update",
@@ -662,8 +681,9 @@ function createNotifyDefinition() {
662
681
  if (event.type === "tool/call") {
663
682
  return stateOf(parseArgs(event.data.arguments) ?? { message: current.message }, event.time, current.settled, event.seq);
664
683
  }
665
- if (event.type === "tool/result") return settledState(current, parseUpdate(event.data.meta));
684
+ if (event.type === "tool/result") return rootResultState(event, current);
666
685
  if (event.type === "tool/ptc-dispatch") {
686
+ if (event.data.isError) return { ...current, useNativeError: true };
667
687
  return settledState(current, parseUpdate(event.data.meta) ?? parseUpdate(event.data.arguments));
668
688
  }
669
689
  return current;
@@ -678,13 +698,14 @@ function createNotifyDefinition() {
678
698
  target: "chat",
679
699
  anchorSeq: state.anchorSeq,
680
700
  location: context.start?.location ?? context.matches[0]?.location ?? { kind: "unresolved" },
681
- groupTree: "process",
682
- visibility: "visible",
701
+ groupTree: state.failure === void 0 ? "process" : void 0,
702
+ visibility: state.useNativeError ? "hidden" : "visible",
683
703
  data: {
684
704
  ...state.title === void 0 ? {} : { title: state.title },
685
705
  message: state.message,
686
706
  time: state.time,
687
- settled: state.settled
707
+ settled: state.settled,
708
+ ...state.failure === void 0 ? {} : { failure: state.failure }
688
709
  }
689
710
  };
690
711
  return node;
@@ -696,34 +717,39 @@ function createNotifyDefinition() {
696
717
  var import_react3 = require("react");
697
718
  var import_dsh_client_ui_primitives3 = require("@deepseek-ai/dsh-client-ui-primitives");
698
719
  var import_jsx_runtime3 = require("react/jsx-runtime");
699
- function useClientConfig(form) {
700
- const [config, setConfig] = (0, import_react3.useState)(() => readConfig(form) ?? DEFAULT_CLIENT_CONFIG);
701
- (0, import_react3.useEffect)(() => {
702
- const sync = () => {
703
- setConfig(readConfig(form) ?? DEFAULT_CLIENT_CONFIG);
704
- };
705
- sync();
706
- return form.subscribe(sync);
707
- }, [form]);
708
- return config;
709
- }
710
720
  function markdownLabels(t) {
711
721
  return {
712
722
  code: { copyLabel: t("markdown.copy"), copiedLabel: t("markdown.copied") },
713
723
  footnotes: t("markdown.footnotes")
714
724
  };
715
725
  }
716
- function NotifyCard({ data, form, openFile, t, seat }) {
717
- const config = useClientConfig(form);
726
+ function NotifyCard({
727
+ data,
728
+ openFile,
729
+ t,
730
+ seat,
731
+ config: { useCollapsible, useSummaryOnly, useSummaryRender, useBodyExpandedByDefault, useShowTime }
732
+ }) {
733
+ const collapsibleByConfig = useCollapsible((value) => value ?? DEFAULT_CLIENT_CONFIG.collapsible);
734
+ const summaryOnly = useSummaryOnly((value) => value ?? DEFAULT_CLIENT_CONFIG.summaryOnly);
735
+ const summaryRender = useSummaryRender((value) => value ?? DEFAULT_CLIENT_CONFIG.summaryRender);
736
+ const bodyExpandedByDefault = useBodyExpandedByDefault((value) => value ?? DEFAULT_CLIENT_CONFIG.bodyExpandedByDefault);
737
+ const showTime = useShowTime((value) => value ?? DEFAULT_CLIENT_CONFIG.showTime);
718
738
  const [open, setOpen] = (0, import_react3.useState)(null);
739
+ if (data.failure !== void 0) {
740
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "dsh-notify-failure", "data-tool": NOTIFY_TOOL_NAME, "data-state": "error", children: [
741
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("strong", { children: t("row.failed") }),
742
+ data.failure.detail.length === 0 ? null : /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { children: data.failure.detail })
743
+ ] });
744
+ }
719
745
  const title = titleOf({ title: data.title, message: data.message }, t("row.fallbackTitle"));
720
- if (config.summaryOnly && config.summaryRender === "prose") {
746
+ if (summaryOnly && summaryRender === "prose") {
721
747
  return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "dsh-notify-prose", "data-tool": NOTIFY_TOOL_NAME, "data-state": data.settled ? "settled" : "running", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_dsh_client_ui_primitives3.MarkdownDelegateProvider, { openFile, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_dsh_client_ui_primitives3.MarkdownText, { text: title, labels: markdownLabels(t) }) }) });
722
748
  }
723
- const hasBody = !config.summaryOnly && data.message.trim().length > 0;
724
- const collapsible = config.collapsible && hasBody;
725
- const expanded = collapsible ? open ?? config.bodyExpandedByDefault : true;
726
- const time = config.showTime ? formatClock(data.time) : null;
749
+ const hasBody = !summaryOnly && data.message.trim().length > 0;
750
+ const collapsible = collapsibleByConfig && hasBody;
751
+ const expanded = collapsible ? open ?? bodyExpandedByDefault : true;
752
+ const time = showTime ? formatClock(data.time) : null;
727
753
  const titleNode = data.settled ? title : /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_dsh_client_ui_primitives3.TextShimmer, { active: true, children: title });
728
754
  return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
729
755
  "div",
@@ -766,30 +792,33 @@ function NotifyCard({ data, form, openFile, t, seat }) {
766
792
 
767
793
  // src/client/NotifyNodeView.tsx
768
794
  var import_jsx_runtime4 = require("react/jsx-runtime");
769
- function NotifyNodeView({ node, openFile, t, form }) {
770
- return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(NotifyCard, { data: node.data, form, openFile, t, seat: "node" });
795
+ function NotifyNodeView(props) {
796
+ const { node, openFile, t } = props;
797
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(NotifyCard, { data: node.data, config: props, openFile, t, seat: "node" });
771
798
  }
772
799
 
773
800
  // src/client/NotifyRow.tsx
774
801
  var import_jsx_runtime5 = require("react/jsx-runtime");
775
802
  function NotifyRow(props) {
776
- const { t, form } = props;
803
+ const { t } = props;
804
+ const failure = props.phase === "result" && props.block.isError ? failureOf(props.block.content, props.block.error) : void 0;
777
805
  const preparing = props.phase === "preparing";
778
- const update = preparing ? { message: "" } : readUpdate(props.block);
806
+ const update = preparing || failure !== void 0 ? { message: "" } : readUpdate(props.block);
779
807
  const data = {
780
808
  ...preparing ? { title: t("row.preparing") } : update.title === void 0 ? {} : { title: update.title },
781
809
  message: update.message,
782
810
  time: props.block.time,
783
- settled: props.phase === "result"
811
+ settled: props.phase === "result",
812
+ ...failure === void 0 ? {} : { failure }
784
813
  };
785
- return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(NotifyCard, { data, form, openFile: props.openFile, t, seat: "row" });
814
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(NotifyCard, { data, config: props, openFile: props.openFile, t, seat: "row" });
786
815
  }
787
816
 
788
817
  // src/client/ConfigCard.css
789
818
  var ConfigCard_default = "/* \u63D2\u4EF6\u9875\u4E0A\u7684\u50AC\u529E\u914D\u7F6E\u5361\u3002 */\n\n.dsh-notify-config {\n display: flex;\n flex-direction: column;\n gap: 10px;\n}\n\n.dsh-notify-config-row {\n display: flex;\n align-items: flex-start;\n justify-content: space-between;\n gap: 16px;\n}\n\n.dsh-notify-config-info {\n display: flex;\n flex-direction: column;\n gap: 2px;\n min-width: 0;\n}\n\n.dsh-notify-config-label {\n color: var(--dsw-alias-label-primary);\n font-size: 13px;\n line-height: 20px;\n}\n\n.dsh-notify-config-hint {\n color: var(--dsw-alias-label-secondary);\n font-size: 12px;\n line-height: 18px;\n}\n\n.dsh-notify-config-field {\n display: flex;\n flex: none;\n align-items: center;\n gap: 6px;\n}\n\n.dsh-notify-config-input {\n width: 88px;\n}\n\n.dsh-notify-config-unit {\n color: var(--dsw-alias-label-secondary);\n font-size: 12px;\n}\n\n.dsh-notify-config-error {\n color: var(--dsw-alias-state-error-primary);\n font-size: 12px;\n line-height: 18px;\n}\n\n.dsh-notify-config-note {\n color: var(--dsw-alias-label-secondary);\n font-size: 12px;\n line-height: 18px;\n}\n";
790
819
 
791
820
  // src/client/NotifyCard.css
792
- var NotifyCard_default = '/* `notify_user` \u7684\u8FDB\u5EA6\u5361\uFF1A\u5706\u70B9 + \u6807\u9898 + \u65F6\u95F4\uFF0C\u6B63\u6587\u9ED8\u8BA4\u6536\u8D77\uFF1B\u60AC\u505C\u65F6\u5706\u70B9\u53D8\u6210\u6298\u53E0\u952E\u3002\n *\n * \u884C\u9996\u53D6\u5BBF\u4E3B `DisclosureRow` \u7684\u540C\u4E00\u5957\u51E0\u4F55\uFF1A16px \u56FE\u6807\u6846 + 6px \u95F4\u8DDD\uFF0C\u6807\u9898\u6587\u5B57\u56E0\u6B64\u843D\u5728\n * \u884C\u5DE6\u8FB9\u7F18 +22px\uFF0C\u4E0E\u8FC7\u7A0B\u884C\u3001\u5DE5\u5177\u884C\u7684\u6587\u5B57\u5217\u5BF9\u9F50\uFF1B\u6846\u5BBD\u8DDF\u968F\u5BBF\u4E3B\u7684\u5B57\u53F7\u8F74\uFF0C\u6539\u5B57\u53F7\u540E\u4ECD\u5BF9\u9F50\u3002 */\n\n.dsh-notify-card {\n padding: 2px 0 8px;\n}\n\n/* \u5BF9\u8BDD\u8282\u70B9\u5EA7\u4F4D\uFF1A\u4E0A\u4E0B\u95F4\u8DDD\u4EA4\u7ED9\u5BBF\u4E3B\u7684\u6D41\u95F4\u8DDD\uFF08\u89C1\u6587\u4EF6\u672B\u5C3E\u7684 --dsh-chat-flow-gap\uFF09\uFF0C\u5361\u7247\u672C\u8EAB\u4E0D\u52A0\u5185\u8FB9\u8DDD\u3002 */\n.dsh-notify-card[data-seat="node"] {\n padding: 0;\n}\n\n.dsh-notify-head {\n display: flex;\n align-items: center;\n gap: 6px;\n min-height: 24px;\n}\n\n.dsh-notify-dot {\n position: relative;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n flex: none;\n width: calc(16px + var(--dsh-content-font-delta, 0px));\n height: calc(16px + var(--dsh-content-font-delta, 0px));\n}\n\n/* \u5706\u70B9\u662F\u5E73\u65F6\u7684\u6837\u5B50\uFF1B\u60AC\u505C\u6807\u9898\u884C\u65F6\u8BA9\u4F4D\u7ED9\u6298\u53E0\u952E\uFF0C\u4E0E\u5BBF\u4E3B DisclosureRow \u7684 leading \u540C\u6784\u3002 */\n.dsh-notify-dot-idle {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n opacity: 1;\n transition: opacity 100ms ease;\n}\n\n.dsh-notify-dot-idle::before {\n content: \'\';\n width: 7px;\n height: 7px;\n border-radius: 50%;\n corner-shape: round;\n background: var(--dsw-alias-state-business-primary);\n}\n\n.dsh-notify-toggle {\n display: inline-flex;\n align-items: center;\n gap: 6px;\n min-width: 0;\n padding: 0;\n border: 0;\n background: none;\n color: inherit;\n font: inherit;\n text-align: left;\n cursor: pointer;\n}\n\n.dsh-notify-title {\n color: var(--dsw-alias-state-business-primary);\n font-size: 14px;\n font-weight: 600;\n line-height: 22px;\n}\n\n.dsh-notify-chevron {\n position: absolute;\n inset: 0;\n margin: auto;\n color: var(--dsw-alias-state-business-primary);\n opacity: 0;\n transition: transform 0.15s ease, opacity 100ms ease;\n}\n\n/* \u60AC\u505C\u65F6\u6309\u5C55\u5F00\u72B6\u6001\u7ED9\u65B9\u5411\uFF1A\u6536\u8D77\u671D\u4E0B\uFF0C\u5C55\u5F00\u671D\u4E0A\u3002 */\n.dsh-notify-dot[data-open] .dsh-notify-chevron {\n transform: rotate(180deg);\n}\n\n/* \u5C55\u5F00\u4E0E\u6536\u8D77\u90FD\u663E\u793A\u5706\u70B9\uFF1B\u6298\u53E0\u952E\u53EA\u5728\u60AC\u505C\u6807\u9898\u884C\u65F6\u51FA\u73B0\uFF0C\u4E0D\u968F\u5C55\u5F00\u72B6\u6001\u5E38\u9A7B\u3002 */\n@media (hover: hover) {\n /* \u53EA\u6709\u5E26\u6298\u53E0\u952E\u7684\u5361\u7247\u624D\u5728\u60AC\u505C\u65F6\u8BA9\u5706\u70B9\u8BA9\u4F4D\uFF1B\u6458\u8981\u6A21\u5F0F\u6CA1\u6709\u6298\u53E0\u952E\uFF0C\u5706\u70B9\u4FDD\u6301\u4E0D\u52A8\u3002 */\n .dsh-notify-card[data-collapsible] .dsh-notify-head:hover .dsh-notify-dot-idle {\n opacity: 0;\n }\n\n .dsh-notify-card[data-collapsible] .dsh-notify-head:hover .dsh-notify-chevron {\n opacity: 1;\n }\n}\n\n@media (prefers-reduced-motion: reduce) {\n .dsh-notify-dot-idle,\n .dsh-notify-chevron {\n transition: none;\n }\n}\n\n.dsh-notify-time {\n flex: none;\n margin-left: auto;\n color: var(--dsw-alias-label-tertiary);\n font-size: 12px;\n line-height: 18px;\n}\n\n/* \u6458\u8981\u6309\u6563\u6587\u6E32\u67D3\uFF1A\u4E0D\u52A0\u5361\u7247\u5185\u8FB9\u8DDD\uFF0C\u6392\u7248\u4EA4\u7ED9\u5BBF\u4E3B\u7684\u6B63\u6587\u6837\u5F0F\u3002 */\n.dsh-notify-prose {\n padding: 0;\n}\n\n/* \u7AD6\u7EBF\u843D\u5728\u5706\u70B9\u7684\u5706\u5FC3\u4E0A\uFF08\u884C\u5DE6\u8FB9\u7F18 +8px\uFF09\uFF0C\u6B63\u6587\u6587\u5B57\u4E0E\u6807\u9898\u540C\u5217\uFF08+22px\uFF09\u3002 */\n.dsh-notify-body {\n margin: 2px 0 0 calc(8px + var(--dsh-content-font-delta, 0px) * 0.5);\n padding-left: calc(13px + var(--dsh-content-font-delta, 0px) * 0.5);\n border-left: 1px solid var(--dsw-alias-border-l1);\n color: var(--dsw-alias-label-primary);\n}\n\n/* \u5BBF\u4E3B\u7684 compact markdown \u81EA\u5E26\u7070\u5B57\uFF0C\u8FD9\u91CC\u6309\u6563\u6587\u9ED1\u8986\u76D6\u5230\u5B83\u7684\u6839\u8282\u70B9\u3002 */\n.dsh-notify-body > div {\n color: var(--dsw-alias-label-primary);\n}\n\n/* \u6298\u53E0\u6001\u7684\u6C47\u62A5\u884C\u4E0E\u6563\u6587\u5757\u540C\u8DDD\uFF1A\u5BBF\u4E3B\u6309 --dsh-chat-flow-gap \u7ED9\u6D41\u8282\u70B9\u7559\u767D\uFF0C\u9ED8\u8BA4 4px\uFF1B\n \u8FD9\u91CC\u628A\u6C47\u62A5\u884C\u81EA\u5DF1\u4E0E\u5B83\u540E\u9762\u90A3\u4E00\u884C\u90FD\u63D0\u5230\u6563\u6587\u7684 12px\u3002 */\n[data-chat-flow-kind="notify-user"] {\n --dsh-chat-flow-gap: 12px;\n}\n\n[data-chat-flow-kind="notify-user"] + * {\n --dsh-chat-flow-gap: 12px;\n}\n';
821
+ var NotifyCard_default = '/* `notify_user` \u7684\u8FDB\u5EA6\u5361\uFF1A\u5706\u70B9 + \u6807\u9898 + \u65F6\u95F4\uFF0C\u6B63\u6587\u9ED8\u8BA4\u6536\u8D77\uFF1B\u60AC\u505C\u65F6\u5706\u70B9\u53D8\u6210\u6298\u53E0\u952E\u3002\n *\n * \u884C\u9996\u53D6\u5BBF\u4E3B `DisclosureRow` \u7684\u540C\u4E00\u5957\u51E0\u4F55\uFF1A16px \u56FE\u6807\u6846 + 6px \u95F4\u8DDD\uFF0C\u6807\u9898\u6587\u5B57\u56E0\u6B64\u843D\u5728\n * \u884C\u5DE6\u8FB9\u7F18 +22px\uFF0C\u4E0E\u8FC7\u7A0B\u884C\u3001\u5DE5\u5177\u884C\u7684\u6587\u5B57\u5217\u5BF9\u9F50\uFF1B\u6846\u5BBD\u8DDF\u968F\u5BBF\u4E3B\u7684\u5B57\u53F7\u8F74\uFF0C\u6539\u5B57\u53F7\u540E\u4ECD\u5BF9\u9F50\u3002 */\n\n.dsh-notify-card {\n padding: 2px 0 8px;\n}\n\n/* \u5BF9\u8BDD\u8282\u70B9\u5EA7\u4F4D\uFF1A\u4E0A\u4E0B\u95F4\u8DDD\u4EA4\u7ED9\u5BBF\u4E3B\u7684\u6D41\u95F4\u8DDD\uFF08\u89C1\u6587\u4EF6\u672B\u5C3E\u7684 --dsh-chat-flow-gap\uFF09\uFF0C\u5361\u7247\u672C\u8EAB\u4E0D\u52A0\u5185\u8FB9\u8DDD\u3002 */\n.dsh-notify-card[data-seat="node"] {\n padding: 0;\n}\n\n.dsh-notify-head {\n display: flex;\n align-items: center;\n gap: 6px;\n min-height: 24px;\n}\n\n.dsh-notify-dot {\n position: relative;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n flex: none;\n width: calc(16px + var(--dsh-content-font-delta, 0px));\n height: calc(16px + var(--dsh-content-font-delta, 0px));\n}\n\n/* \u5706\u70B9\u662F\u5E73\u65F6\u7684\u6837\u5B50\uFF1B\u60AC\u505C\u6807\u9898\u884C\u65F6\u8BA9\u4F4D\u7ED9\u6298\u53E0\u952E\uFF0C\u4E0E\u5BBF\u4E3B DisclosureRow \u7684 leading \u540C\u6784\u3002 */\n.dsh-notify-dot-idle {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n opacity: 1;\n transition: opacity 100ms ease;\n}\n\n.dsh-notify-dot-idle::before {\n content: \'\';\n width: 7px;\n height: 7px;\n border-radius: 50%;\n corner-shape: round;\n background: var(--dsw-alias-state-business-primary);\n}\n\n.dsh-notify-toggle {\n display: inline-flex;\n align-items: center;\n gap: 6px;\n min-width: 0;\n padding: 0;\n border: 0;\n background: none;\n color: inherit;\n font: inherit;\n text-align: left;\n cursor: pointer;\n}\n\n.dsh-notify-title {\n color: var(--dsw-alias-state-business-primary);\n font-size: 14px;\n font-weight: 600;\n line-height: 22px;\n}\n\n.dsh-notify-chevron {\n position: absolute;\n inset: 0;\n margin: auto;\n color: var(--dsw-alias-state-business-primary);\n opacity: 0;\n transition: transform 0.15s ease, opacity 100ms ease;\n}\n\n/* \u60AC\u505C\u65F6\u6309\u5C55\u5F00\u72B6\u6001\u7ED9\u65B9\u5411\uFF1A\u6536\u8D77\u671D\u4E0B\uFF0C\u5C55\u5F00\u671D\u4E0A\u3002 */\n.dsh-notify-dot[data-open] .dsh-notify-chevron {\n transform: rotate(180deg);\n}\n\n/* \u5C55\u5F00\u4E0E\u6536\u8D77\u90FD\u663E\u793A\u5706\u70B9\uFF1B\u6298\u53E0\u952E\u53EA\u5728\u60AC\u505C\u6807\u9898\u884C\u65F6\u51FA\u73B0\uFF0C\u4E0D\u968F\u5C55\u5F00\u72B6\u6001\u5E38\u9A7B\u3002 */\n@media (hover: hover) {\n /* \u53EA\u6709\u5E26\u6298\u53E0\u952E\u7684\u5361\u7247\u624D\u5728\u60AC\u505C\u65F6\u8BA9\u5706\u70B9\u8BA9\u4F4D\uFF1B\u6458\u8981\u6A21\u5F0F\u6CA1\u6709\u6298\u53E0\u952E\uFF0C\u5706\u70B9\u4FDD\u6301\u4E0D\u52A8\u3002 */\n .dsh-notify-card[data-collapsible] .dsh-notify-head:hover .dsh-notify-dot-idle {\n opacity: 0;\n }\n\n .dsh-notify-card[data-collapsible] .dsh-notify-head:hover .dsh-notify-chevron {\n opacity: 1;\n }\n}\n\n@media (prefers-reduced-motion: reduce) {\n .dsh-notify-dot-idle,\n .dsh-notify-chevron {\n transition: none;\n }\n}\n\n.dsh-notify-time {\n flex: none;\n margin-left: auto;\n color: var(--dsw-alias-label-tertiary);\n font-size: 12px;\n line-height: 18px;\n}\n\n/* \u6458\u8981\u6309\u6563\u6587\u6E32\u67D3\uFF1A\u4E0D\u52A0\u5361\u7247\u5185\u8FB9\u8DDD\uFF0C\u6392\u7248\u4EA4\u7ED9\u5BBF\u4E3B\u7684\u6B63\u6587\u6837\u5F0F\u3002 */\n.dsh-notify-prose {\n padding: 0;\n}\n\n/* \u7AD6\u7EBF\u843D\u5728\u5706\u70B9\u7684\u5706\u5FC3\u4E0A\uFF08\u884C\u5DE6\u8FB9\u7F18 +8px\uFF09\uFF0C\u6B63\u6587\u6587\u5B57\u4E0E\u6807\u9898\u540C\u5217\uFF08+22px\uFF09\u3002 */\n.dsh-notify-body {\n margin: 2px 0 0 calc(8px + var(--dsh-content-font-delta, 0px) * 0.5);\n padding-left: calc(13px + var(--dsh-content-font-delta, 0px) * 0.5);\n border-left: 1px solid var(--dsw-alias-border-l1);\n color: var(--dsw-alias-label-primary);\n}\n\n/* \u5BBF\u4E3B\u7684 compact markdown \u81EA\u5E26\u7070\u5B57\uFF0C\u8FD9\u91CC\u6309\u6563\u6587\u9ED1\u8986\u76D6\u5230\u5B83\u7684\u6839\u8282\u70B9\u3002 */\n.dsh-notify-body > div {\n color: var(--dsw-alias-label-primary);\n}\n\n/* \u6298\u53E0\u6001\u7684\u6C47\u62A5\u884C\u4E0E\u6563\u6587\u5757\u540C\u8DDD\uFF1A\u5BBF\u4E3B\u6309 --dsh-chat-flow-gap \u7ED9\u6D41\u8282\u70B9\u7559\u767D\uFF0C\u9ED8\u8BA4 4px\uFF1B\n \u8FD9\u91CC\u628A\u6C47\u62A5\u884C\u81EA\u5DF1\u4E0E\u5B83\u540E\u9762\u90A3\u4E00\u884C\u90FD\u63D0\u5230\u6563\u6587\u7684 12px\u3002 */\n[data-chat-flow-kind="notify-user"] {\n --dsh-chat-flow-gap: 12px;\n}\n\n[data-chat-flow-kind="notify-user"] + * {\n --dsh-chat-flow-gap: 12px;\n}\n\n.dsh-notify-failure {\n color: var(--dsw-alias-state-error-primary);\n overflow-wrap: anywhere;\n white-space: pre-wrap;\n}\n';
793
822
 
794
823
  // src/client/EnabledToggle.css
795
824
  var EnabledToggle_default = "/* \u6A21\u578B\u4E0E\u63A8\u7406\u7B49\u7EA7\u83DC\u5355\u91CC\u7684\u300C\u4E3B\u52A8\u6C47\u62A5\u300D\u5F00\u5173\u3002 */\n\n.dsh-notify-toggle-row {\n position: relative;\n display: flex;\n align-items: center;\n justify-content: space-between;\n gap: 16px;\n min-height: 34px;\n padding: 0 8px;\n border-radius: var(--dsw-radius-md);\n color: var(--dsw-alias-label-primary);\n font-size: 13px;\n line-height: 20px;\n}\n\n.dsh-notify-toggle-label {\n display: inline-flex;\n align-items: center;\n gap: 4px;\n min-width: 0;\n}\n\n.dsh-notify-toggle-info {\n position: relative;\n z-index: 1;\n flex: none;\n width: 20px;\n height: 20px;\n padding: 0;\n color: var(--dsw-alias-label-caption);\n}\n\n/* \u5F00\u5173\u7684\u70B9\u51FB\u533A\u94FA\u6EE1\u6574\u884C\uFF0C\u4F46\u4E0D\u5305\u4F4F\u4FE1\u606F\u6309\u94AE\u3002 */\n.dsh-notify-toggle-row .dsh-notify-toggle-switch {\n position: static;\n}\n\n.dsh-notify-toggle-switch::after {\n content: '';\n position: absolute;\n inset: 0;\n border-radius: var(--dsw-radius-md);\n}\n\n.dsh-notify-toggle-row:has(.dsh-notify-toggle-switch:focus-visible) {\n background: var(--dsw-alias-interactive-bg-hover);\n}\n\n@media (hover: hover) {\n .dsh-notify-toggle-row:has(.dsh-notify-toggle-switch:not(:disabled)):hover {\n background: var(--dsw-alias-interactive-bg-hover);\n }\n}\n";
@@ -818,7 +847,14 @@ function removeStyles() {
818
847
  if (typeof document === "undefined") return;
819
848
  for (const tag of document.head.querySelectorAll(`style[data-plugin="${BUNDLE_NAME}"]`)) tag.remove();
820
849
  }
821
- function apply(ctx) {
850
+ function apply(ctx, config) {
851
+ const cardHooks = {
852
+ collapsible: config.collapsible,
853
+ summaryOnly: config.summaryOnly,
854
+ summaryRender: config.summaryRender,
855
+ bodyExpandedByDefault: config.bodyExpandedByDefault,
856
+ showTime: config.showTime
857
+ };
822
858
  ctx.effect(() => {
823
859
  injectStyles();
824
860
  return () => {
@@ -827,36 +863,33 @@ function apply(ctx) {
827
863
  }, "dsh-notify-user: stylesheets");
828
864
  ctx.effect(() => ctx.locale.register(NS, { zh, en }), "dsh-notify-user: dictionaries");
829
865
  ctx.effect(() => {
830
- const form = ctx.configForms.get(SETTINGS_NAMESPACE);
866
+ let placement;
831
867
  let dispose;
832
868
  const sync = () => {
833
- const placement = readConfig(form)?.cardPlacement ?? DEFAULT_CARD_PLACEMENT;
834
- if (placement === "boundary") {
835
- dispose ??= ctx.uiConversation.events.register(createNotifyDefinition());
836
- return;
837
- }
869
+ const next = config.cardPlacement.get() === "inline" ? "inline" : DEFAULT_CARD_PLACEMENT;
870
+ if (next === placement) return;
838
871
  dispose?.();
839
- dispose = void 0;
872
+ placement = next;
873
+ dispose = next === "boundary" ? ctx.uiConversation.events.register(createNotifyDefinition()) : ctx.slots.inject("tool.call.toolview", () => ctx.slots.register({
874
+ name: "tool.call.toolview",
875
+ key: NOTIFY_TOOL_NAME,
876
+ locale: NS,
877
+ inject: () => ({ hooks: cardHooks })
878
+ }, NotifyRow));
840
879
  };
841
880
  sync();
842
- const unsubscribe = form.subscribe(sync);
881
+ const unsubscribe = config.cardPlacement.subscribe(sync);
843
882
  return () => {
844
883
  unsubscribe();
845
884
  dispose?.();
846
885
  };
847
- }, "dsh-notify-user: notify node definition");
886
+ }, "dsh-notify-user: card placement");
848
887
  ctx.slots.inject("conversation.chat.node", () => ctx.slots.register({
849
888
  name: "conversation.chat.node",
850
889
  key: NOTIFY_NODE_KIND,
851
890
  locale: NS,
852
- inject: () => ({ form: ctx.configForms.get(SETTINGS_NAMESPACE) })
891
+ inject: () => ({ hooks: cardHooks })
853
892
  }, NotifyNodeView));
854
- ctx.slots.inject("tool.call.toolview", () => ctx.slots.register({
855
- name: "tool.call.toolview",
856
- key: NOTIFY_TOOL_NAME,
857
- locale: NS,
858
- inject: () => ({ form: ctx.configForms.get(SETTINGS_NAMESPACE) })
859
- }, NotifyRow));
860
893
  ctx.slots.inject(MODEL_OPTIONS_SLOT, () => ctx.slots.register({
861
894
  name: MODEL_OPTIONS_SLOT,
862
895
  id: "notify-user-enabled",