@jiyr0119/dsh-service-console 0.7.2 → 0.9.0

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.
Files changed (40) hide show
  1. package/README.md +7 -5
  2. package/README.zh.md +7 -5
  3. package/docs/local-debugging.md +1 -1
  4. package/docs/rc5-upgrade-review.zh.md +182 -0
  5. package/docs/release-checklist.md +15 -12
  6. package/icon.svg +8 -0
  7. package/lib/client/dictionaries.js +19 -2
  8. package/lib/client/i18n.js +29 -70
  9. package/lib/client/service-list-view.js +186 -0
  10. package/lib/client.js +1284 -685
  11. package/lib/host/config.js +1 -2
  12. package/lib/host/ledger.js +2 -3
  13. package/lib/host/lifecycle.js +2 -3
  14. package/lib/host/ownership.js +8 -4
  15. package/lib/host/process-inspector.js +1 -2
  16. package/lib/host/protection.js +1 -2
  17. package/lib/host/redaction.js +1 -2
  18. package/lib/host/service-registry.js +4 -5
  19. package/lib/host/service-tool.js +42 -4
  20. package/lib/index.js +54 -11
  21. package/lib/types/client/ServiceConsole.d.ts +35 -15
  22. package/lib/types/client/ServiceDockPill.d.ts +29 -0
  23. package/lib/types/client/ServiceListCard.d.ts +17 -0
  24. package/lib/types/client/api.d.ts +19 -0
  25. package/lib/types/client/dictionaries.d.ts +18 -0
  26. package/lib/types/client/i18n.d.ts +33 -40
  27. package/lib/types/client/index.d.ts +21 -10
  28. package/lib/types/client/service-list-view.d.ts +92 -0
  29. package/lib/types/host/ledger.d.ts +7 -0
  30. package/lib/types/host/ownership.d.ts +9 -1
  31. package/lib/types/host/service-registry.d.ts +2 -1
  32. package/lib/types/host/service-tool.d.ts +7 -2
  33. package/lib/types/index.d.ts +18 -2
  34. package/locale/en.json +6 -0
  35. package/locale/zh.json +6 -0
  36. package/package.json +34 -33
  37. package/dsh.plugin.json +0 -16
  38. package/dynamic/client.js +0 -193
  39. package/dynamic/host.js +0 -337
  40. package/manifest.json +0 -24
package/lib/client.js CHANGED
@@ -3,7 +3,7 @@ window.__ModuleLoader__.load({
3
3
  factory: (require) => {
4
4
  var module = { exports: {} };
5
5
  module.exports;
6
- //#region \0rolldown/runtime.js
6
+ // \0rolldown/runtime.js
7
7
  var __create = Object.create;
8
8
  var __defProp = Object.defineProperty;
9
9
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
@@ -24,120 +24,83 @@ window.__ModuleLoader__.load({
24
24
  value: mod,
25
25
  enumerable: true
26
26
  }) : target, mod));
27
- //#endregion
28
27
  let react = require("react");
29
28
  react = __toESM(react, 1);
30
29
  let _deepseek_ai_dsh_client_ui_primitives = require("@deepseek-ai/dsh-client-ui-primitives");
31
30
  let react_jsx_runtime = require("react/jsx-runtime");
32
- //#region \0dsh-css:/home/runner/work/dsh-service-console/dsh-service-console/src/client/service-console.module.css.mjs
33
- const css = ".PuSt5a_layer{z-index:100;pointer-events:none;position:fixed;inset:0}.PuSt5a_popup{background:var(--dsw-alias-bg-layer-2,#262626);border:1px solid var(--dsw-alias-border-inverted,#80808047);width:420px;box-shadow:var(--dsw-shadow-lv3,0 12px 32px #00000059);color:var(--dsw-alias-label-primary,#e8e8e8);--dsh-scrollbar-thumb:var(--dsw-alias-scrollbar-bg-l2,#80808066);--dsh-scrollbar-thumb-hover:var(--dsw-alias-scrollbar-hover-l2,#80808099);pointer-events:auto;opacity:0;transform-origin:100% 0;border-radius:16px;flex-direction:column;font:13px/1.45 -apple-system,BlinkMacSystemFont,Segoe UI,PingFang SC,Microsoft YaHei,sans-serif;transition:opacity .18s,transform .18s;display:flex;position:fixed;right:16px;overflow:hidden;transform:translateY(-8px)scale(.98)}.PuSt5a_popupOn{opacity:1;transform:translateY(0)scale(1)}@media (prefers-reduced-motion:reduce){.PuSt5a_popup{transition:none}}.PuSt5a_head{border-bottom:1px solid var(--dsw-alias-border-l3,#80808033);flex:none;align-items:center;gap:8px;padding:14px 16px 12px 18px;display:flex}.PuSt5a_headIco{color:var(--dsw-alias-state-business-primary,#4176e6);flex:none;display:inline-flex}.PuSt5a_headTitle{text-overflow:ellipsis;white-space:nowrap;flex:1;min-width:0;font-size:15px;font-weight:600;overflow:hidden}.PuSt5a_icoBtn{color:var(--dsw-alias-label-secondary,#9a9a9a);cursor:pointer;background:0 0;border:0;border-radius:8px;flex:none;justify-content:center;align-items:center;width:28px;height:28px;display:inline-flex}.PuSt5a_icoBtn:hover{background:var(--dsw-alias-interactive-bg-hover,#80808024);color:var(--dsw-alias-label-primary,#e8e8e8)}.PuSt5a_tabs{border-bottom:1px solid var(--dsw-alias-border-l3,#80808033);flex:none;gap:2px;padding:0 14px;display:flex}.PuSt5a_tab{height:36px;color:var(--dsw-alias-label-secondary,#9a9a9a);font:inherit;cursor:pointer;background:0 0;border:0;border-radius:10px 10px 0 0;flex:1;justify-content:center;align-items:center;gap:6px;font-size:12.5px;font-weight:500;display:inline-flex;position:relative}.PuSt5a_tab:hover{color:var(--dsw-alias-label-primary,#e8e8e8);background:var(--dsw-alias-interactive-bg-hover,#80808014)}.PuSt5a_tabOn{color:var(--dsw-alias-label-primary,#e8e8e8)}.PuSt5a_tabInd{background:var(--dsw-alias-state-business-primary,#4176e6);opacity:0;border-radius:999px;height:2px;transition:opacity .16s,transform .16s;position:absolute;bottom:-1px;left:24%;right:24%;transform:scaleX(.4)}.PuSt5a_tabOn .PuSt5a_tabInd{opacity:1;transform:scaleX(1)}.PuSt5a_tab:focus-visible{outline:2px solid var(--dsw-alias-state-business-primary,#4176e6);outline-offset:-2px}@media (prefers-reduced-motion:reduce){.PuSt5a_tabInd{transition:none}}.PuSt5a_tabBody{flex-direction:column;flex:1;min-height:0;display:flex;overflow:hidden auto}.PuSt5a_tabBody::-webkit-scrollbar{width:6px}.PuSt5a_tabBody::-webkit-scrollbar-thumb{background:var(--dsh-scrollbar-thumb);border-radius:3px}.PuSt5a_tabBody::-webkit-scrollbar-thumb:hover{background:var(--dsh-scrollbar-thumb-hover)}.PuSt5a_tabBody::-webkit-scrollbar-track{background:0 0}.PuSt5a_filterRow{align-items:center;gap:6px;padding:12px 16px 6px;display:flex}.PuSt5a_filter{min-width:0;height:30px;color:var(--dsw-alias-label-primary,#e8e8e8);border:1px solid var(--dsw-alias-border-l2,#80808059);font:inherit;background:0 0;border-radius:8px;outline:none;flex:1;padding:0 8px;font-size:12.5px}.PuSt5a_filter:focus-visible{border-color:var(--dsw-alias-state-business-primary,#4176e6)}.PuSt5a_filter::placeholder{color:var(--dsw-alias-label-caption,#8a8a8a)}.PuSt5a_filterClear{color:var(--dsw-alias-label-secondary,#9a9a9a);cursor:pointer;background:0 0;border:0;border-radius:6px;flex:none;justify-content:center;align-items:center;width:26px;height:26px;display:inline-flex}.PuSt5a_filterClear:hover{color:var(--dsw-alias-label-primary,#e8e8e8);background:var(--dsw-alias-interactive-bg-hover,#8080801f)}.PuSt5a_segGroup{border:1px solid var(--dsw-alias-border-l2,#80808059);border-radius:8px;flex:none;gap:2px;padding:2px;display:inline-flex}.PuSt5a_segBtn{color:var(--dsw-alias-label-secondary,#9a9a9a);font:inherit;cursor:pointer;background:0 0;border:0;border-radius:6px;padding:6px 7px;font-size:11.5px;line-height:1;transition:color .1s,background .1s}.PuSt5a_segBtn:hover{color:var(--dsw-alias-label-primary,#e8e8e8);background:var(--dsw-alias-interactive-bg-hover,#8080801f)}.PuSt5a_segBtnOn,.PuSt5a_segBtnOn:hover{background:var(--dsw-alias-state-business-primary,#4176e6);color:#fff}@media (prefers-reduced-motion:reduce){.PuSt5a_segBtn{transition:none}}.PuSt5a_hintLine{color:var(--dsw-alias-label-caption,#8a8a8a);align-items:center;gap:6px;padding:4px 18px 8px;font-size:11px;display:flex}.PuSt5a_hintWarn{color:var(--dsw-alias-state-warn-primary,#e7b85d)}.PuSt5a_liveDot{background:var(--dsw-alias-state-success-primary,#55d187);width:7px;height:7px;box-shadow:0 0 0 3px color-mix(in srgb, var(--dsw-alias-state-success-primary,#55d187) 18%, transparent);border-radius:50%;flex:none}.PuSt5a_row{border:1px solid var(--dsw-alias-border-l3,#80808026);background:var(--dsw-alias-bg-layer-1,#ffffff08);border-radius:12px;margin:0 12px 8px;padding:12px 16px;transition:background .12s,border-color .12s}.PuSt5a_row:hover{background:var(--dsw-alias-interactive-bg-hover,#80808014);border-color:var(--dsw-alias-border-l2,#80808040)}.PuSt5a_rowMain{flex-wrap:wrap;align-items:center;gap:8px;min-width:0;display:flex}.PuSt5a_rowDot{flex-shrink:0;font-size:8px;line-height:1}.PuSt5a_rowName{letter-spacing:-.01em;word-break:break-word;font-size:13px;font-weight:600}.PuSt5a_rowMeta{color:var(--dsw-alias-label-secondary,#9a9a9a);font-variant-numeric:tabular-nums;word-break:break-all;font-size:11.5px}.PuSt5a_rowSub{color:var(--dsw-alias-label-secondary,#9a9a9a);word-break:break-all;margin-top:4px;font-size:11.5px;line-height:1.4}.PuSt5a_spacer{flex:1}.PuSt5a_badge{white-space:nowrap;border:1px solid;border-radius:999px;padding:1px 6px;font-size:10px;font-weight:500}.PuSt5a_rowBtn{border:1px solid var(--dsw-alias-border-l2,#8080804d);height:24px;color:var(--dsw-alias-label-secondary,#9a9a9a);font:inherit;cursor:pointer;background:0 0;border-radius:6px;flex:none;justify-content:center;align-items:center;padding:0 7px;font-size:11px;transition:color .1s,background .1s;display:inline-flex}.PuSt5a_rowBtn:hover{color:var(--dsw-alias-label-primary,#e8e8e8);background:var(--dsw-alias-interactive-bg-hover,#8080801f)}.PuSt5a_rowAct{color:var(--dsw-alias-label-secondary,#9a9a9a);border-radius:5px;flex:none;justify-content:center;align-items:center;width:22px;height:22px;text-decoration:none;transition:color .1s,background .1s;display:inline-flex}.PuSt5a_rowAct:hover{color:var(--dsw-alias-state-business-primary,#4176e6);background:var(--dsw-alias-interactive-bg-hover,#8080801f)}.PuSt5a_confirmRow{background:color-mix(in srgb, var(--dsw-alias-state-warn-primary,#e7b85d) 8%, transparent);border:1px solid color-mix(in srgb, var(--dsw-alias-state-warn-primary,#e7b85d) 15%, transparent);border-radius:10px;flex-wrap:wrap;align-items:center;gap:6px;margin-top:10px;padding:10px 12px;display:flex}.PuSt5a_confirmTxt{min-width:0;color:var(--dsw-alias-label-secondary,#b0b3ba);flex:1;font-size:12px}.PuSt5a_confirmOk{background:var(--dsw-alias-state-error-primary,#e5484d);color:#fff;height:26px;font:inherit;cursor:pointer;border:none;border-radius:7px;flex:none;padding:0 10px;font-size:11px;font-weight:500;transition:opacity .1s}.PuSt5a_confirmOk:hover{opacity:.85}.PuSt5a_confirmOk:disabled{opacity:.55;cursor:default}.PuSt5a_confirmCancel{border:1px solid var(--dsw-alias-border-l2,#80808059);height:26px;color:var(--dsw-alias-label-secondary,#9a9a9a);font:inherit;cursor:pointer;background:0 0;border-radius:7px;flex:none;padding:0 10px;font-size:11px;transition:color .1s,background .1s}.PuSt5a_confirmCancel:hover{color:var(--dsw-alias-label-primary,#e8e8e8);background:var(--dsw-alias-interactive-bg-hover,#8080801f)}.PuSt5a_detailBox{border:1px solid var(--dsw-alias-border-l2,#8080804d);background:var(--dsw-alias-bg-layer-1,#00000026);box-shadow:inset 3px 0 0 var(--dsw-alias-state-business-primary,#4176e6);border-radius:10px;margin-top:10px;padding:14px}.PuSt5a_detailHead{justify-content:space-between;align-items:center;margin-bottom:12px;font-size:12px;font-weight:600;display:flex}.PuSt5a_detailAccent{color:var(--dsw-alias-state-business-primary,#4176e6);letter-spacing:.12em;text-transform:uppercase;font-size:9px;font-weight:650}.PuSt5a_detailGrid{grid-template-columns:repeat(2,minmax(0,1fr));gap:12px;display:grid}.PuSt5a_detailGrid>div{flex-direction:column;gap:3px;min-width:0;display:flex}.PuSt5a_detailLabel{color:var(--dsw-alias-label-caption,#7a7d85);letter-spacing:.06em;text-transform:uppercase;font-size:10px;font-weight:600}.PuSt5a_detailGrid code{overflow-wrap:anywhere;word-break:break-all;color:var(--dsw-alias-label-primary,#d8d9dc);font:11px/1.4 ui-monospace,SFMono-Regular,Menlo,Consolas,monospace}.PuSt5a_evidenceBlock{border-top:1px solid var(--dsw-alias-border-l3,#80808026);margin-top:14px;padding-top:12px;overflow:hidden}.PuSt5a_evidenceItem{color:var(--dsw-alias-label-secondary,#8a8d95);gap:6px;margin-top:5px;font-size:11px;line-height:1.4;display:flex}.PuSt5a_evidenceArrow{color:var(--dsw-alias-state-business-primary,#4176e6);flex:none;font-size:10px}.PuSt5a_note{color:var(--dsw-alias-label-caption,#8a8a8a);align-items:center;gap:8px;padding:6px 16px;font-size:12px;display:flex}.PuSt5a_noteErr{color:var(--dsw-alias-state-error-primary,#e5484d);padding:6px 16px;font-size:12px}.PuSt5a_noteWarn{color:var(--dsw-alias-state-warn-primary,#e7b85d);padding:6px 16px;font-size:12px}.PuSt5a_okText{color:var(--dsw-alias-state-success-primary,#55d187);margin-top:4px;font-size:12px}.PuSt5a_errText{color:var(--dsw-alias-state-error-primary,#e5484d);margin-top:4px;font-size:12px}.PuSt5a_empty{color:var(--dsw-alias-label-secondary,#9a9a9a);padding:24px 18px;font-size:12.5px}.PuSt5a_spin{border:2px solid var(--dsw-alias-border-l2,#80808066);border-top-color:var(--dsw-alias-state-business-primary,#4176e6);border-radius:50%;flex:none;width:13px;height:13px;animation:.7s linear infinite PuSt5a_sc-spin}@keyframes PuSt5a_sc-spin{to{transform:rotate(360deg)}}@media (prefers-reduced-motion:reduce){.PuSt5a_spin{animation-duration:1.6s}}.PuSt5a_headerBtn{border:1px solid var(--dsw-alias-border-l2,#80808059);height:32px;color:var(--dsw-alias-label-primary,#e8e8e8);cursor:pointer;background:0 0;border-radius:18px;flex:none;justify-content:center;align-items:center;gap:4px;padding:6px 12px;font-size:13px;font-weight:400;line-height:20px;display:inline-flex}.PuSt5a_headerBtn span,.PuSt5a_headerBtn svg{flex:none}.PuSt5a_headerBtn span{white-space:nowrap}.PuSt5a_headerBtn:hover{background:var(--dsw-alias-interactive-bg-hover,#8080801f)}.PuSt5a_headerBtnOn{color:var(--dsw-alias-state-business-primary,#4176e6);border-color:#4176e680}.PuSt5a_setPage{padding:8px 16px 28px}.PuSt5a_setSection{letter-spacing:.05em;text-transform:uppercase;color:var(--dsw-alias-label-caption,#8a8a8a);padding:10px 4px 6px;font-size:11px;font-weight:600}.PuSt5a_setRow{border-radius:12px;align-items:center;gap:12px;padding:9px 10px;display:flex}.PuSt5a_setRow:hover{background:var(--dsw-alias-interactive-bg-hover,#8080800f)}.PuSt5a_setInfo{flex-direction:column;flex:1;gap:2px;min-width:0;display:flex}.PuSt5a_setLabel{color:var(--dsw-alias-label-primary,#e8e8e8);font-size:12.5px}.PuSt5a_setCap{color:var(--dsw-alias-label-caption,#8a8a8a);font-size:11px}.PuSt5a_setInput{width:80px;min-width:80px;height:28px;color:var(--dsw-alias-label-primary,#e8e8e8);border:1px solid var(--dsw-alias-border-l2,#80808059);font:inherit;background:0 0;border-radius:8px;outline:none;flex:none;padding:0 8px;font-size:12px}.PuSt5a_setInput:focus-visible{border-color:var(--dsw-alias-state-business-primary,#4176e6)}.PuSt5a_setSelect{width:96px}.PuSt5a_switch{border:1px solid var(--dsw-alias-border-l2,#80808066);background:var(--dsw-alias-interactive-bg-hover,#8080802e);cursor:pointer;border-radius:999px;flex:none;width:34px;height:20px;padding:0;transition:background .15s,border-color .15s;position:relative}.PuSt5a_switch:after{content:\"\";background:var(--dsw-alias-label-secondary,#9a9a9a);border-radius:50%;width:14px;height:14px;transition:transform .15s;position:absolute;top:2px;left:2px}.PuSt5a_switch[aria-checked=true]{background:var(--dsw-alias-state-business-primary,#4176e6);border-color:#0000}.PuSt5a_switch[aria-checked=true]:after{background:#fff;transform:translate(14px)}@media (prefers-reduced-motion:reduce){.PuSt5a_switch,.PuSt5a_switch:after{transition:none}}.PuSt5a_prevBtn{border:1px solid var(--dsw-alias-border-l2,#80808059);height:28px;color:var(--dsw-alias-label-secondary,#9a9a9a);font:inherit;cursor:pointer;background:0 0;border-radius:8px;flex:none;justify-content:center;align-items:center;padding:0 10px;font-size:12px;display:inline-flex}.PuSt5a_prevBtn:hover{color:var(--dsw-alias-label-primary,#e8e8e8);background:var(--dsw-alias-interactive-bg-hover,#8080801f)}.PuSt5a_setFooter{justify-content:flex-end;padding:8px 4px 2px;display:flex}.PuSt5a_setNote{color:var(--dsw-alias-label-dimmed,#777);padding:2px 10px 8px;font-size:11px}.PuSt5a_starSection{border:1px solid var(--dsw-alias-border-l3,#80808026);background:var(--dsw-alias-bg-layer-1,#ffffff08);border-radius:12px;margin-top:12px;padding:12px 10px}.PuSt5a_starRow{align-items:center;gap:12px;display:flex}.PuSt5a_starInfo{flex-direction:column;flex:1;gap:2px;min-width:0;display:flex}.PuSt5a_starLabel{color:var(--dsw-alias-label-primary,#e8e8e8);font-size:12.5px}.PuSt5a_starLink{color:var(--dsw-alias-state-business-primary,#4176e6);text-underline-offset:2px;white-space:nowrap;flex:none;font-size:12px;line-height:1.6;text-decoration:underline}.PuSt5a_starLink:hover{opacity:.85}.PuSt5a_rowBtn:focus-visible,.PuSt5a_headerBtn:focus-visible,.PuSt5a_icoBtn:focus-visible,.PuSt5a_prevBtn:focus-visible,.PuSt5a_filter:focus-visible,.PuSt5a_tab:focus-visible,.PuSt5a_segBtn:focus-visible,.PuSt5a_confirmOk:focus-visible,.PuSt5a_confirmCancel:focus-visible{outline:2px solid var(--dsw-alias-state-business-primary,#4176e6);outline-offset:-2px}@media (width<=480px){.PuSt5a_popup{width:calc(100vw - 16px);right:8px}.PuSt5a_detailGrid{grid-template-columns:1fr}}";
34
- const tagId = "@jiyr0119/dsh-service-console/service-console.module.css";
35
- if (typeof document !== "undefined" && document.querySelector("style[data-plugin-css=" + JSON.stringify(tagId) + "]") === null) {
31
+ // \0dsh-css:/home/runner/work/dsh-service-console/dsh-service-console/src/client/service-console.module.css.mjs
32
+ const css$1 = ".PuSt5a_console{height:100%;min-height:0;color:var(--dsw-alias-label-primary,#e8e8e8);--dsh-scrollbar-thumb:var(--dsw-alias-scrollbar-bg-l2,#80808066);--dsh-scrollbar-thumb-hover:var(--dsw-alias-scrollbar-hover-l2,#80808099);flex-direction:column;font:13px/1.45 -apple-system,BlinkMacSystemFont,Segoe UI,PingFang SC,Microsoft YaHei,sans-serif;display:flex;overflow:hidden}.PuSt5a_toolbar{flex:none;align-items:center;gap:8px;padding:10px 12px 6px;display:flex}.PuSt5a_scroll{flex:1;min-height:0;padding-bottom:12px;overflow:hidden auto}.PuSt5a_scroll::-webkit-scrollbar{width:6px}.PuSt5a_scroll::-webkit-scrollbar-thumb{background:var(--dsh-scrollbar-thumb);border-radius:3px}.PuSt5a_scroll::-webkit-scrollbar-thumb:hover{background:var(--dsh-scrollbar-thumb-hover)}.PuSt5a_scroll::-webkit-scrollbar-track{background:0 0}.PuSt5a_headerBtn{border:1px solid var(--dsw-alias-border-l2,#8080804d);height:28px;color:var(--dsw-alias-label-secondary,#9a9a9a);font:inherit;cursor:pointer;background:0 0;border-radius:8px;align-items:center;gap:5px;padding:0 10px;font-size:12px;transition:color .1s,background .1s,border-color .1s;display:inline-flex}.PuSt5a_headerBtn:hover{color:var(--dsw-alias-label-primary,#e8e8e8);background:var(--dsw-alias-interactive-bg-hover,#80808024);border-color:var(--dsw-alias-border-l1,#80808066)}.PuSt5a_headerBtn:focus-visible{outline:2px solid var(--dsw-alias-state-business-primary,#4176e6);outline-offset:1px}.PuSt5a_icoBtn{width:26px;height:26px;color:var(--dsw-alias-label-secondary,#9a9a9a);cursor:pointer;background:0 0;border:0;border-radius:7px;flex:none;justify-content:center;align-items:center;margin-left:auto;display:inline-flex}.PuSt5a_icoBtn:hover{background:var(--dsw-alias-interactive-bg-hover,#80808024);color:var(--dsw-alias-label-primary,#e8e8e8)}.PuSt5a_filterRow{align-items:center;gap:6px;padding:12px 16px 6px;display:flex}.PuSt5a_filter{flex:1;min-width:0}.PuSt5a_filterClear{color:var(--dsw-alias-label-secondary,#9a9a9a);cursor:pointer;background:0 0;border:0;border-radius:6px;flex:none;justify-content:center;align-items:center;width:26px;height:26px;display:inline-flex}.PuSt5a_filterClear:hover{color:var(--dsw-alias-label-primary,#e8e8e8);background:var(--dsw-alias-interactive-bg-hover,#8080801f)}.PuSt5a_hintLine{color:var(--dsw-alias-label-secondary,#9a9a9a);align-items:center;gap:6px;padding:4px 18px 8px;font-size:11.5px;display:flex}.PuSt5a_hintWarn{color:var(--dsw-alias-state-warn-primary,#e7b85d)}.PuSt5a_row{border:1px solid var(--dsw-alias-border-l3,#80808026);background:var(--dsw-alias-bg-layer-1,#ffffff08);border-radius:12px;margin:0 12px 8px;padding:12px 16px;transition:background .12s,border-color .12s}.PuSt5a_row:hover{background:var(--dsw-alias-interactive-bg-hover,#80808014);border-color:var(--dsw-alias-border-l2,#80808040)}.PuSt5a_rowMain{flex-wrap:wrap;align-items:center;gap:8px;min-width:0;display:flex}.PuSt5a_rowDot{flex-shrink:0;font-size:8px;line-height:1}.PuSt5a_rowName{letter-spacing:-.01em;word-break:break-word;font-size:13px;font-weight:600}.PuSt5a_rowMeta{color:var(--dsw-alias-label-secondary,#9a9a9a);font-variant-numeric:tabular-nums;word-break:break-all;font-size:11.5px}.PuSt5a_rowSub{color:var(--dsw-alias-label-secondary,#9a9a9a);word-break:break-all;margin-top:4px;font-size:11.5px;line-height:1.4}.PuSt5a_spacer{flex:1}.PuSt5a_rowBtn{border:1px solid var(--dsw-alias-border-l2,#8080804d);height:24px;color:var(--dsw-alias-label-secondary,#9a9a9a);font:inherit;cursor:pointer;background:0 0;border-radius:6px;flex:none;justify-content:center;align-items:center;padding:0 7px;font-size:11px;transition:color .1s,background .1s;display:inline-flex}.PuSt5a_rowBtn:hover{color:var(--dsw-alias-label-primary,#e8e8e8);background:var(--dsw-alias-interactive-bg-hover,#8080801f)}.PuSt5a_rowAct{color:var(--dsw-alias-label-secondary,#9a9a9a);border-radius:5px;flex:none;justify-content:center;align-items:center;width:22px;height:22px;text-decoration:none;transition:color .1s,background .1s;display:inline-flex}.PuSt5a_rowAct:hover{color:var(--dsw-alias-state-business-primary,#4176e6);background:var(--dsw-alias-interactive-bg-hover,#8080801f)}.PuSt5a_confirmRow{background:color-mix(in srgb, var(--dsw-alias-state-warn-primary,#e7b85d) 8%, transparent);border:1px solid color-mix(in srgb, var(--dsw-alias-state-warn-primary,#e7b85d) 15%, transparent);border-radius:10px;flex-wrap:wrap;align-items:center;gap:6px;margin-top:10px;padding:10px 12px;display:flex}.PuSt5a_confirmTxt{min-width:0;color:var(--dsw-alias-label-secondary,#b0b3ba);flex:1;font-size:12px}.PuSt5a_detailBox{border:1px solid var(--dsw-alias-border-l2,#8080804d);background:var(--dsw-alias-bg-layer-1,#00000026);box-shadow:inset 3px 0 0 var(--dsw-alias-state-business-primary,#4176e6);border-radius:10px;margin-top:10px;padding:14px}.PuSt5a_detailHead{justify-content:space-between;align-items:center;margin-bottom:12px;font-size:12px;font-weight:600;display:flex}.PuSt5a_detailAccent{color:var(--dsw-alias-state-business-primary,#4176e6);letter-spacing:.12em;text-transform:uppercase;font-size:9px;font-weight:650}.PuSt5a_detailGrid{grid-template-columns:repeat(2,minmax(0,1fr));gap:12px;display:grid}.PuSt5a_detailGrid>div{flex-direction:column;gap:3px;min-width:0;display:flex}.PuSt5a_detailLabel{color:var(--dsw-alias-label-secondary,#9a9a9a);letter-spacing:.06em;text-transform:uppercase;font-size:10.5px;font-weight:600}.PuSt5a_detailGrid code{overflow-wrap:anywhere;word-break:break-all;color:var(--dsw-alias-label-primary,#d8d9dc);font:11px/1.4 ui-monospace,SFMono-Regular,Menlo,Consolas,monospace}.PuSt5a_evidenceBlock{border-top:1px solid var(--dsw-alias-border-l3,#80808026);margin-top:14px;padding-top:12px;overflow:hidden}.PuSt5a_evidenceItem{color:var(--dsw-alias-label-secondary,#8a8d95);gap:6px;margin-top:5px;font-size:11px;line-height:1.4;display:flex}.PuSt5a_evidenceArrow{color:var(--dsw-alias-state-business-primary,#4176e6);flex:none;font-size:10px}.PuSt5a_note{color:var(--dsw-alias-label-secondary,#9a9a9a);align-items:center;gap:8px;padding:6px 16px;font-size:12px;display:flex}.PuSt5a_noteErr{color:var(--dsw-alias-label-secondary,#9a9a9a);border-left:2px solid var(--dsw-alias-state-error-primary,#e5484d);padding:6px 16px;font-size:12px}.PuSt5a_noteWarn{color:var(--dsw-alias-label-secondary,#9a9a9a);border-left:2px solid var(--dsw-alias-state-warn-primary,#e7b85d);padding:6px 16px;font-size:12px}.PuSt5a_okText{color:var(--dsw-alias-label-secondary,#9a9a9a);border-left:2px solid var(--dsw-alias-state-success-primary,#55d187);margin-top:4px;padding-left:6px;font-size:12px}.PuSt5a_errText{color:var(--dsw-alias-label-secondary,#9a9a9a);border-left:2px solid var(--dsw-alias-state-error-primary,#e5484d);margin-top:4px;padding-left:6px;font-size:12px}.PuSt5a_empty{color:var(--dsw-alias-label-secondary,#9a9a9a);padding:24px 18px;font-size:12.5px}.PuSt5a_spin{border:2px solid var(--dsw-alias-border-l2,#80808066);border-top-color:var(--dsw-alias-state-business-primary,#4176e6);border-radius:50%;flex:none;width:13px;height:13px;animation:.7s linear infinite PuSt5a_sc-spin}@keyframes PuSt5a_sc-spin{to{transform:rotate(360deg)}}@media (prefers-reduced-motion:reduce){.PuSt5a_spin{animation-duration:1.6s}}.PuSt5a_setPage{padding:8px 16px 28px}.PuSt5a_setSection{letter-spacing:.05em;text-transform:uppercase;color:var(--dsw-alias-label-secondary,#9a9a9a);padding:10px 4px 6px;font-size:11px;font-weight:600}.PuSt5a_setRow{border-radius:12px;align-items:center;gap:12px;padding:9px 10px;display:flex}.PuSt5a_setRow:hover{background:var(--dsw-alias-interactive-bg-hover,#8080800f)}.PuSt5a_setInfo{flex-direction:column;flex:1;gap:2px;min-width:0;display:flex}.PuSt5a_setLabel{color:var(--dsw-alias-label-primary,#e8e8e8);font-size:12.5px}.PuSt5a_setCap{color:var(--dsw-alias-label-secondary,#9a9a9a);font-size:11.5px}.PuSt5a_setInput{width:80px;min-width:80px;height:28px;color:var(--dsw-alias-label-primary,#e8e8e8);border:1px solid var(--dsw-alias-border-l2,#80808059);font:inherit;background:0 0;border-radius:8px;flex:none;padding:0 8px;font-size:12px}.PuSt5a_setInput:focus-visible{border-color:var(--dsw-alias-state-business-primary,#4176e6);outline:2px solid var(--dsw-alias-state-business-primary,#4176e6);outline-offset:1px}.PuSt5a_setSelect{width:96px}.PuSt5a_prevBtn{border:1px solid var(--dsw-alias-border-l2,#80808059);height:28px;color:var(--dsw-alias-label-secondary,#9a9a9a);font:inherit;cursor:pointer;background:0 0;border-radius:8px;flex:none;justify-content:center;align-items:center;padding:0 10px;font-size:12px;display:inline-flex}.PuSt5a_prevBtn:hover{color:var(--dsw-alias-label-primary,#e8e8e8);background:var(--dsw-alias-interactive-bg-hover,#8080801f)}.PuSt5a_setFooter{justify-content:flex-end;padding:8px 4px 2px;display:flex}.PuSt5a_setNote{color:var(--dsw-alias-label-dimmed,#777);padding:2px 10px 8px;font-size:11px}.PuSt5a_starSection{border:1px solid var(--dsw-alias-border-l3,#80808026);background:var(--dsw-alias-bg-layer-1,#ffffff08);border-radius:12px;margin-top:12px;padding:12px 10px}.PuSt5a_starRow{align-items:center;gap:12px;display:flex}.PuSt5a_starInfo{flex-direction:column;flex:1;gap:2px;min-width:0;display:flex}.PuSt5a_starLabel{color:var(--dsw-alias-label-primary,#e8e8e8);font-size:12.5px}.PuSt5a_starLink{color:var(--dsw-alias-state-business-primary,#4176e6);text-underline-offset:2px;white-space:nowrap;flex:none;font-size:12px;line-height:1.6;text-decoration:underline}.PuSt5a_starLink:hover{opacity:.85}.PuSt5a_rowBtn:focus-visible,.PuSt5a_headerBtn:focus-visible,.PuSt5a_icoBtn:focus-visible,.PuSt5a_prevBtn:focus-visible,.PuSt5a_filterClear:focus-visible,.PuSt5a_rowAct:focus-visible,.PuSt5a_setInput:focus-visible{outline:2px solid var(--dsw-alias-state-business-primary,#4176e6);outline-offset:-2px}@media (width<=480px){.PuSt5a_detailGrid{grid-template-columns:1fr}}.PuSt5a_dockPill{border:1px solid var(--dsw-alias-border-l2,#8080804d);height:24px;color:var(--dsw-alias-label-secondary,#9a9a9a);font:inherit;cursor:pointer;pointer-events:auto;background:0 0;border-radius:999px;align-items:center;gap:6px;margin:2px 0 4px;padding:0 10px;font-size:11.5px;transition:color .1s,background .1s,border-color .1s;display:inline-flex}.PuSt5a_dockPill:hover{color:var(--dsw-alias-label-primary,#e8e8e8);background:var(--dsw-alias-interactive-bg-hover,#8080801f);border-color:var(--dsw-alias-border-l1,#80808066)}.PuSt5a_dockPill:focus-visible{outline:2px solid var(--dsw-alias-state-business-primary,#4176e6);outline-offset:1px}.PuSt5a_dockPillPorts{color:var(--dsw-alias-label-secondary,#9a9a9a);font-variant-numeric:tabular-nums}@media (prefers-reduced-motion:reduce){.PuSt5a_dockPill{transition:none}.PuSt5a_console *,.PuSt5a_console :before,.PuSt5a_console :after{transition:none!important;animation:none!important}}";
33
+ const tagId$1 = "@jiyr0119/dsh-service-console/service-console.module.css";
34
+ if (typeof document !== "undefined" && document.querySelector("style[data-plugin-css=" + JSON.stringify(tagId$1) + "]") === null) {
36
35
  const tag = document.createElement("style");
37
36
  tag.dataset.plugin = "@jiyr0119/dsh-service-console";
38
- tag.dataset.pluginCss = tagId;
39
- tag.textContent = css;
37
+ tag.dataset.pluginCss = tagId$1;
38
+ tag.textContent = css$1;
40
39
  document.head.appendChild(tag);
41
40
  }
42
41
  var service_console_module_css_default = {
43
- "icoBtn": "PuSt5a_icoBtn",
44
- "filter": "PuSt5a_filter",
45
- "starLink": "PuSt5a_starLink",
46
- "confirmRow": "PuSt5a_confirmRow",
47
- "evidenceItem": "PuSt5a_evidenceItem",
48
- "okText": "PuSt5a_okText",
49
- "errText": "PuSt5a_errText",
42
+ "evidenceBlock": "PuSt5a_evidenceBlock",
43
+ "rowMain": "PuSt5a_rowMain",
44
+ "setNote": "PuSt5a_setNote",
50
45
  "starInfo": "PuSt5a_starInfo",
51
- "tabBody": "PuSt5a_tabBody",
52
- "evidenceArrow": "PuSt5a_evidenceArrow",
53
- "confirmTxt": "PuSt5a_confirmTxt",
54
- "popupOn": "PuSt5a_popupOn",
55
- "filterRow": "PuSt5a_filterRow",
56
- "head": "PuSt5a_head",
57
- "rowBtn": "PuSt5a_rowBtn",
58
- "rowMeta": "PuSt5a_rowMeta",
59
- "row": "PuSt5a_row",
60
- "tab": "PuSt5a_tab",
61
- "headTitle": "PuSt5a_headTitle",
46
+ "setPage": "PuSt5a_setPage",
47
+ "hintWarn": "PuSt5a_hintWarn",
48
+ "dockPillPorts": "PuSt5a_dockPillPorts",
62
49
  "sc-spin": "PuSt5a_sc-spin",
63
- "rowAct": "PuSt5a_rowAct",
64
- "filterClear": "PuSt5a_filterClear",
65
- "rowSub": "PuSt5a_rowSub",
66
- "hintLine": "PuSt5a_hintLine",
67
- "setInfo": "PuSt5a_setInfo",
68
- "liveDot": "PuSt5a_liveDot",
69
- "noteErr": "PuSt5a_noteErr",
70
- "evidenceBlock": "PuSt5a_evidenceBlock",
71
- "note": "PuSt5a_note",
72
- "detailGrid": "PuSt5a_detailGrid",
73
- "badge": "PuSt5a_badge",
74
- "confirmCancel": "PuSt5a_confirmCancel",
75
- "layer": "PuSt5a_layer",
76
- "setCap": "PuSt5a_setCap",
50
+ "confirmTxt": "PuSt5a_confirmTxt",
77
51
  "detailHead": "PuSt5a_detailHead",
52
+ "hintLine": "PuSt5a_hintLine",
53
+ "rowName": "PuSt5a_rowName",
54
+ "detailLabel": "PuSt5a_detailLabel",
55
+ "okText": "PuSt5a_okText",
56
+ "errText": "PuSt5a_errText",
57
+ "setRow": "PuSt5a_setRow",
78
58
  "setSection": "PuSt5a_setSection",
79
- "rowDot": "PuSt5a_rowDot",
80
- "tabInd": "PuSt5a_tabInd",
81
- "starRow": "PuSt5a_starRow",
82
- "tabs": "PuSt5a_tabs",
83
- "headIco": "PuSt5a_headIco",
84
- "segBtnOn": "PuSt5a_segBtnOn",
85
- "confirmOk": "PuSt5a_confirmOk",
59
+ "setInfo": "PuSt5a_setInfo",
60
+ "setSelect": "PuSt5a_setSelect",
61
+ "prevBtn": "PuSt5a_prevBtn",
86
62
  "detailBox": "PuSt5a_detailBox",
87
- "popup": "PuSt5a_popup",
88
- "headerBtn": "PuSt5a_headerBtn",
63
+ "detailAccent": "PuSt5a_detailAccent",
64
+ "dockPill": "PuSt5a_dockPill",
65
+ "filter": "PuSt5a_filter",
66
+ "console": "PuSt5a_console",
67
+ "evidenceItem": "PuSt5a_evidenceItem",
89
68
  "empty": "PuSt5a_empty",
69
+ "starLabel": "PuSt5a_starLabel",
70
+ "scroll": "PuSt5a_scroll",
71
+ "noteErr": "PuSt5a_noteErr",
90
72
  "setLabel": "PuSt5a_setLabel",
91
- "setFooter": "PuSt5a_setFooter",
92
- "hintWarn": "PuSt5a_hintWarn",
93
- "prevBtn": "PuSt5a_prevBtn",
94
- "starSection": "PuSt5a_starSection",
95
- "detailLabel": "PuSt5a_detailLabel",
73
+ "rowAct": "PuSt5a_rowAct",
74
+ "filterRow": "PuSt5a_filterRow",
75
+ "evidenceArrow": "PuSt5a_evidenceArrow",
96
76
  "setInput": "PuSt5a_setInput",
97
- "segGroup": "PuSt5a_segGroup",
98
- "tabOn": "PuSt5a_tabOn",
99
- "rowName": "PuSt5a_rowName",
100
- "setSelect": "PuSt5a_setSelect",
101
- "headerBtnOn": "PuSt5a_headerBtnOn",
102
- "noteWarn": "PuSt5a_noteWarn",
103
- "segBtn": "PuSt5a_segBtn",
104
- "setPage": "PuSt5a_setPage",
105
- "spin": "PuSt5a_spin",
106
- "setRow": "PuSt5a_setRow",
107
- "switch": "PuSt5a_switch",
108
- "setNote": "PuSt5a_setNote",
109
- "starLabel": "PuSt5a_starLabel",
77
+ "starSection": "PuSt5a_starSection",
78
+ "filterClear": "PuSt5a_filterClear",
110
79
  "spacer": "PuSt5a_spacer",
111
- "rowMain": "PuSt5a_rowMain",
112
- "detailAccent": "PuSt5a_detailAccent"
80
+ "rowDot": "PuSt5a_rowDot",
81
+ "confirmRow": "PuSt5a_confirmRow",
82
+ "noteWarn": "PuSt5a_noteWarn",
83
+ "rowBtn": "PuSt5a_rowBtn",
84
+ "setFooter": "PuSt5a_setFooter",
85
+ "rowMeta": "PuSt5a_rowMeta",
86
+ "starRow": "PuSt5a_starRow",
87
+ "starLink": "PuSt5a_starLink",
88
+ "icoBtn": "PuSt5a_icoBtn",
89
+ "row": "PuSt5a_row",
90
+ "toolbar": "PuSt5a_toolbar",
91
+ "detailGrid": "PuSt5a_detailGrid",
92
+ "note": "PuSt5a_note",
93
+ "setCap": "PuSt5a_setCap",
94
+ "headerBtn": "PuSt5a_headerBtn",
95
+ "rowSub": "PuSt5a_rowSub",
96
+ "spin": "PuSt5a_spin"
113
97
  };
114
- //#endregion
115
- //#region src/client/ServiceConsole.tsx
98
+ // src/client/api.ts
116
99
  /**
117
- * dsh-service-console — 面板组件(原生包 v2)
118
- *
119
- * 架构对齐 dsh-workspace-explorer:
120
- * - i18n: 通过 locale.bind(NS) 获取翻译函数(而非硬编码 TEXTS)
121
- * - API: 通过 fetch 直连 webServer JSON 路由(不走 host.call / LLM)
122
- * - UI: 抽屉式面板 + Tab 栏(服务 / 设置),对标 workspace-explorer 视觉风格
100
+ * 调用一条 `/dsh-sc/api/*` 路由。
101
+ * @param path 路由尾段(例如 `services/scan`)
102
+ * @param payload JSON 请求体
123
103
  */
124
- let timerCtx = null;
125
- let localeSubscribe = null;
126
- let tr = (k) => k;
127
- function bindTimer(t) {
128
- timerCtx = t;
129
- }
130
- function bindLocale(locale) {
131
- tr = locale.t;
132
- localeSubscribe = locale.subscribe;
133
- }
134
- /** 动态错误码 → 词典键(err.<CODE>);未收录的码回退 fallback */
135
- function trError(code, fallback) {
136
- if (!code) return fallback;
137
- const key = "err." + code;
138
- const s = tr(key);
139
- return s === key ? fallback : s;
140
- }
141
104
  async function api(path, payload) {
142
105
  const res = await fetch("/dsh-sc/api/" + path, {
143
106
  method: "POST",
@@ -151,26 +114,15 @@ window.__ModuleLoader__.load({
151
114
  throw new Error("bad JSON HTTP " + res.status);
152
115
  }
153
116
  }
154
- const store = {
155
- open: false,
156
- listeners: /* @__PURE__ */ new Set()
157
- };
158
- function subscribeOpen(fn) {
159
- store.listeners.add(fn);
160
- return () => {
161
- store.listeners.delete(fn);
162
- };
163
- }
164
- function setOpen(v) {
165
- store.open = v;
166
- store.listeners.forEach((l) => l(v));
167
- }
168
- function toggleOpen() {
169
- setOpen(!store.open);
170
- }
171
- function closePanel() {
172
- setOpen(false);
173
- }
117
+ /** 与 host/types.ts 的 Ownership 联合一致(运行时无从推导,靠单测对齐) */
118
+ const OWNERSHIP_LEVELS = [
119
+ "conversation-confirmed",
120
+ "workspace-inferred",
121
+ "other-local",
122
+ "unknown",
123
+ "protected"
124
+ ];
125
+ /** 归属 → 主题色(两处 UI 共用,避免各写一份) */
174
126
  const OWNERSHIP_COLOR = {
175
127
  "conversation-confirmed": "var(--dsw-alias-state-success-primary, #4ade80)",
176
128
  "workspace-inferred": "var(--dsw-alias-state-warn-primary, #fbbf24)",
@@ -178,6 +130,21 @@ window.__ModuleLoader__.load({
178
130
  unknown: "var(--dsw-alias-state-error-primary, #f87171)",
179
131
  protected: "var(--dsw-alias-state-error-primary, #f87171)"
180
132
  };
133
+ /**
134
+ * 归属徽标的 tone:统一 `neutral`。
135
+ *
136
+ * 平台 Tag 的语义色(success/warning/danger)在浅色主题下实测对比度不足
137
+ * (success 2.09:1 / warning 1.96:1 / danger 3.80:1,均低于 AA 4.5:1),
138
+ * 而 `neutral` 为 5.36:1。归属的细粒度语义由前面的彩色圆点承担(装饰性)。
139
+ */
140
+ const OWNERSHIP_TONE = {
141
+ "conversation-confirmed": "neutral",
142
+ "workspace-inferred": "neutral",
143
+ "other-local": "neutral",
144
+ unknown: "neutral",
145
+ protected: "neutral"
146
+ };
147
+ /** 归属 → 词典键 */
181
148
  const OWNERSHIP_KEY = {
182
149
  "conversation-confirmed": "own.conversation",
183
150
  "workspace-inferred": "own.workspace",
@@ -185,10 +152,180 @@ window.__ModuleLoader__.load({
185
152
  unknown: "own.unknown",
186
153
  protected: "own.protected"
187
154
  };
188
- /** API 字符串 → 归属级别(未知值降级为 unknown,不炸 UI) */
189
- function ownershipLevel(v) {
190
- return v === "conversation-confirmed" || v === "workspace-inferred" || v === "other-local" || v === "protected" ? v : "unknown";
155
+ /** API 字符串 → 归属级别(未知值降级 unknown,不炸 UI) */
156
+ function ownershipLevel(value) {
157
+ return OWNERSHIP_LEVELS.includes(value) ? value : "unknown";
158
+ }
159
+ function asRecord(value) {
160
+ return typeof value === "object" && value !== null ? value : null;
191
161
  }
162
+ function finiteNumber(value) {
163
+ return typeof value === "number" && Number.isFinite(value) ? value : null;
164
+ }
165
+ function ownershipOf(value) {
166
+ return typeof value === "string" && OWNERSHIP_LEVELS.includes(value) ? value : "unknown";
167
+ }
168
+ /** 允许打开的主机名:只认本机回环(meta 可被篡改,不能让卡片变成钓鱼链接) */
169
+ const LOOPBACK_HOSTS = /* @__PURE__ */ new Set([
170
+ "localhost",
171
+ "127.0.0.1",
172
+ "::1",
173
+ "[::1]"
174
+ ]);
175
+ /**
176
+ * 只接受 http(s) + 回环主机;其余(含 `javascript:`、`data:`、外部域名)一律 null。
177
+ * @param value meta 里的 url 字段(unknown)
178
+ */
179
+ function safeServiceUrl(value) {
180
+ if (typeof value !== "string" || value === "" || value.length > 2048) return null;
181
+ let parsed;
182
+ try {
183
+ parsed = new URL(value);
184
+ } catch {
185
+ return null;
186
+ }
187
+ if (parsed.protocol !== "http:" && parsed.protocol !== "https:") return null;
188
+ return LOOPBACK_HOSTS.has(parsed.hostname.toLowerCase()) ? value : null;
189
+ }
190
+ /** 单行投影:缺 id 的行直接丢弃(没有稳定 key 无法渲染,也无法操作) */
191
+ function projectRow(value) {
192
+ const raw = asRecord(value);
193
+ if (raw === null) return null;
194
+ const id = typeof raw.id === "string" ? raw.id : "";
195
+ if (id === "") return null;
196
+ const name = typeof raw.name === "string" && raw.name !== "" ? raw.name : id;
197
+ const url = safeServiceUrl(raw.url);
198
+ return {
199
+ id,
200
+ name: name.slice(0, 200),
201
+ ports: typeof raw.ports === "string" ? raw.ports.slice(0, 200) : "",
202
+ ownership: ownershipOf(raw.ownership),
203
+ protected: raw.protected === true,
204
+ restartable: raw.restartable === true,
205
+ url
206
+ };
207
+ }
208
+ /**
209
+ * `presentationMeta` → 卡片视图模型。
210
+ * @param meta 持久化的 meta(`unknown`:旧会话可能没有,或形状已变)
211
+ * @returns 可渲染模型;`null` 表示「没有可用 meta」,调用方应回退到纯文本内容
212
+ */
213
+ function projectServiceListMeta(meta) {
214
+ const raw = asRecord(meta);
215
+ if (raw === null) return null;
216
+ const services = Object.hasOwn(raw, "services") && Array.isArray(raw.services) ? raw.services : null;
217
+ if (services === null) return null;
218
+ const rows = [];
219
+ for (const entry of services) {
220
+ if (rows.length >= 20) break;
221
+ const row = projectRow(entry);
222
+ if (row !== null) rows.push(row);
223
+ }
224
+ const total = finiteNumber(raw.total) ?? rows.length;
225
+ const count = finiteNumber(raw.count) ?? rows.length;
226
+ return {
227
+ scannedAt: finiteNumber(raw.scannedAt),
228
+ total: Math.max(total, rows.length),
229
+ count: Math.max(count, rows.length),
230
+ rows,
231
+ truncated: Math.max(Math.max(count, rows.length) - rows.length, 0)
232
+ };
233
+ }
234
+ /** 端口去重后的一行摘要片段(最多 6 个,避免撑爆行宽);语言无关 */
235
+ function serviceListPorts(model) {
236
+ const ports = [];
237
+ for (const row of model.rows) {
238
+ for (const port of row.ports.split(",")) {
239
+ const p = port.trim();
240
+ if (p !== "" && !ports.includes(p)) ports.push(p);
241
+ if (ports.length >= 6) break;
242
+ }
243
+ if (ports.length >= 6) break;
244
+ }
245
+ return ports.length > 0 ? ":" + ports.join(" :") : "";
246
+ }
247
+ /** 行是否可执行生命周期操作(与面板同一判定:受保护目标只读) */
248
+ function canControlService(row) {
249
+ return !row.protected;
250
+ }
251
+ /**
252
+ * 从一次扫描快照里挑出「属于本会话」的服务。
253
+ * 归属判定在宿主完成(scan 带 sessionId 时按台账 sessionKey 收窄),
254
+ * 这里只做防御式读取:坏行丢弃,未知归属不计数。
255
+ * @param services 扫描接口的 `data.services`(不可信:可能缺失/坏形状)
256
+ */
257
+ function selectSessionServices(services) {
258
+ if (!Array.isArray(services)) return [];
259
+ const rows = [];
260
+ for (const entry of services) {
261
+ const raw = asRecord(entry);
262
+ if (raw === null) continue;
263
+ const id = typeof raw.id === "string" ? raw.id : "";
264
+ if (id === "") continue;
265
+ if (!Object.hasOwn(raw, "ownership") || raw.ownership !== "conversation-confirmed") continue;
266
+ const ports = (Array.isArray(raw.listeners) ? raw.listeners : []).map((l) => {
267
+ const rec = asRecord(l);
268
+ return rec !== null && typeof rec.port === "number" && Number.isFinite(rec.port) ? String(rec.port) : "";
269
+ }).filter((p) => p !== "").join(", ");
270
+ rows.push({
271
+ id,
272
+ name: typeof raw.name === "string" && raw.name !== "" ? raw.name.slice(0, 200) : id,
273
+ ownership: "conversation-confirmed",
274
+ protected: raw.protected === true,
275
+ ports
276
+ });
277
+ }
278
+ return rows;
279
+ }
280
+ /**
281
+ * 本会话服务摘要;`count === 0` 时 pill 不渲染。
282
+ * @param services `selectSessionServices` 的结果
283
+ */
284
+ function summarizeSessionServices(services) {
285
+ const ports = [];
286
+ for (const row of services) {
287
+ for (const port of row.ports.split(",")) {
288
+ const p = port.trim();
289
+ if (p !== "" && !ports.includes(p)) ports.push(p);
290
+ if (ports.length >= 4) break;
291
+ }
292
+ if (ports.length >= 4) break;
293
+ }
294
+ return {
295
+ count: services.length,
296
+ ports: ports.length > 0 ? ":" + ports.join(" :") : ""
297
+ };
298
+ }
299
+ // src/client/ServiceConsole.tsx
300
+ /**
301
+ * dsh-service-console — 控制台内容组件(rc.5 右侧栏 tab 版)
302
+ *
303
+ * 结构(M1 迁移后):
304
+ * - `ServiceConsoleTab`:tab 内容体(工具条 + 服务列表 + 详情 + Toast)。
305
+ * 面板的边框/拖拽/停靠/焦点/关闭由右侧栏拥有,这里只画内容。
306
+ * - `ServiceConsoleEntry`:header 入口按钮,点击由侧栏打开 tab。
307
+ * - `ServiceConsoleSettings` / `ServiceConsoleIcon`:全局设置页与其导航图标。
308
+ *
309
+ * i18n:组件从 slot 注册项的 `locale:` 拿到框架合成的 `t`(按 namespace 类型化),
310
+ * 语言切换由渲染器按 locale revision 重渲染,不需要手动订阅。
311
+ * API:fetch 直连 webServer JSON 路由(不走 host.call / LLM)。
312
+ */
313
+ let timerCtx$1 = null;
314
+ function bindTimer(t) {
315
+ timerCtx$1 = t;
316
+ }
317
+ /** 动态错误码 → 词典键(err.<CODE>);未收录的码回退 fallback */
318
+ function trError(t, code, fallback) {
319
+ if (!code) return fallback;
320
+ const key = "err." + code;
321
+ const s = t(key);
322
+ return s === key ? fallback : s;
323
+ }
324
+ const SCOPE_VALUES = [
325
+ "conversation",
326
+ "workspace",
327
+ "machine"
328
+ ];
192
329
  const SCOPE_KEY = {
193
330
  conversation: "scope.conversation",
194
331
  workspace: "scope.workspace",
@@ -201,27 +338,15 @@ window.__ModuleLoader__.load({
201
338
  showUnknown: true,
202
339
  forceKill: false
203
340
  };
204
- function measurePopup() {
205
- const vh = window.innerHeight;
206
- const header = document.querySelector("[data-slot=\"conversation.session.header\"]");
207
- const composer = document.querySelector("[data-composer-card]");
208
- const top = header ? Math.round(header.getBoundingClientRect().bottom) + 8 : 48;
209
- const bottomLimit = composer ? Math.round(composer.getBoundingClientRect().top) - 8 : vh - 48;
210
- return {
211
- top,
212
- height: Math.max(280, bottomLimit - top)
213
- };
214
- }
215
- function ServiceConsoleEntry() {
216
- const [on, setOn] = react.useState(store.open);
217
- react.useEffect(() => subscribeOpen(setOn), []);
341
+ function ServiceConsoleEntry({ t, openConsole }) {
218
342
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
219
343
  type: "button",
220
- className: service_console_module_css_default.headerBtn + (on ? " " + service_console_module_css_default.headerBtnOn : ""),
221
- onClick: toggleOpen,
222
- title: tr("entry.tip"),
223
- "aria-label": tr("entry.tip"),
224
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: tr("entry.label") }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("svg", {
344
+ className: service_console_module_css_default.headerBtn,
345
+ "data-dsh-sc": "entry",
346
+ onClick: openConsole,
347
+ title: t("entry.tip"),
348
+ "aria-label": t("entry.tip"),
349
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: t("entry.label") }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("svg", {
225
350
  viewBox: "0 0 16 16",
226
351
  width: 13,
227
352
  height: 13,
@@ -244,7 +369,47 @@ window.__ModuleLoader__.load({
244
369
  })]
245
370
  });
246
371
  }
247
- function ServiceConsoleSettings({ onSaved }) {
372
+ function ServiceConsoleIcon({ size }) {
373
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("svg", {
374
+ viewBox: "0 0 16 16",
375
+ width: size,
376
+ height: size,
377
+ "aria-hidden": "true",
378
+ fill: "none",
379
+ children: [
380
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("rect", {
381
+ x: 2.25,
382
+ y: 3.25,
383
+ width: 11.5,
384
+ height: 8.5,
385
+ rx: 2,
386
+ stroke: "currentColor",
387
+ strokeWidth: 1.3
388
+ }),
389
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", {
390
+ d: "M5 6.25 6.9 7.75 5 9.25",
391
+ stroke: "currentColor",
392
+ strokeWidth: 1.3,
393
+ strokeLinecap: "round",
394
+ strokeLinejoin: "round"
395
+ }),
396
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", {
397
+ d: "M8.4 9.25H11",
398
+ stroke: "currentColor",
399
+ strokeWidth: 1.3,
400
+ strokeLinecap: "round"
401
+ }),
402
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", {
403
+ d: "M6 13.4H10",
404
+ stroke: "currentColor",
405
+ strokeWidth: 1.3,
406
+ strokeLinecap: "round"
407
+ })
408
+ ]
409
+ });
410
+ }
411
+ function ServiceConsoleSettings({ t, onSaved }) {
412
+ const tr = t;
248
413
  const [config, setConfig] = react.useState(null);
249
414
  react.useEffect(() => {
250
415
  api("config", {}).then((res) => setConfig(res?.data?.config ?? null)).catch(() => {});
@@ -262,6 +427,7 @@ window.__ModuleLoader__.load({
262
427
  };
263
428
  if (!config) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
264
429
  className: service_console_module_css_default.setPage,
430
+ "data-dsh-sc": "settings",
265
431
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
266
432
  className: service_console_module_css_default.note,
267
433
  children: "Loading…"
@@ -269,6 +435,7 @@ window.__ModuleLoader__.load({
269
435
  });
270
436
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
271
437
  className: service_console_module_css_default.setPage,
438
+ "data-dsh-sc": "settings",
272
439
  children: [
273
440
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
274
441
  className: service_console_module_css_default.setSection,
@@ -351,12 +518,10 @@ window.__ModuleLoader__.load({
351
518
  className: service_console_module_css_default.setCap,
352
519
  children: tr("settings.showUnknown.desc")
353
520
  })]
354
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
355
- type: "button",
356
- role: "switch",
357
- "aria-checked": config.showUnknown,
358
- className: service_console_module_css_default.switch,
359
- onClick: () => updateConfig({ showUnknown: !config.showUnknown })
521
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Switch, {
522
+ checked: config.showUnknown,
523
+ label: tr("settings.showUnknown"),
524
+ onChange: (next) => updateConfig({ showUnknown: next })
360
525
  })]
361
526
  }),
362
527
  /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
@@ -370,12 +535,10 @@ window.__ModuleLoader__.load({
370
535
  className: service_console_module_css_default.setCap,
371
536
  children: tr("settings.forceKill.desc")
372
537
  })]
373
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
374
- type: "button",
375
- role: "switch",
376
- "aria-checked": config.forceKill,
377
- className: service_console_module_css_default.switch,
378
- onClick: () => updateConfig({ forceKill: !config.forceKill })
538
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Switch, {
539
+ checked: config.forceKill,
540
+ label: tr("settings.forceKill"),
541
+ onChange: (next) => updateConfig({ forceKill: next })
379
542
  })]
380
543
  }),
381
544
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
@@ -413,15 +576,9 @@ window.__ModuleLoader__.load({
413
576
  ]
414
577
  });
415
578
  }
416
- function ServiceConsolePanel() {
417
- const [on, setOn] = react.useState(store.open);
418
- const [shown, setShown] = react.useState(false);
419
- const [closing, setClosing] = react.useState(false);
420
- const [rect, setRect] = react.useState({
421
- top: 48,
422
- height: 480
423
- });
424
- const [tab, setTab] = react.useState("services");
579
+ function ServiceConsoleTab({ t, sessionId, visible }) {
580
+ const tr = t;
581
+ const idBase = react.useId();
425
582
  const [query, setQuery] = react.useState("");
426
583
  const [view, setView] = react.useState({
427
584
  phase: "idle",
@@ -443,55 +600,23 @@ window.__ModuleLoader__.load({
443
600
  const [scope, setScope] = react.useState("workspace");
444
601
  const scopeTouched = react.useRef(false);
445
602
  const [pending, setPending] = react.useState(false);
446
- const [, setLangTick] = react.useState(0);
447
603
  const timeoutRef = react.useRef(null);
448
- react.useEffect(() => subscribeOpen(setOn), []);
449
- react.useEffect(() => localeSubscribe?.(() => setLangTick((n) => n + 1)), []);
450
- react.useEffect(() => {
451
- if (on) {
452
- setClosing(false);
453
- setShown(false);
454
- const raf = requestAnimationFrame(() => setShown(true));
455
- return () => cancelAnimationFrame(raf);
456
- }
457
- setShown(false);
458
- setClosing(true);
459
- const t = setTimeout(() => setClosing(false), 200);
460
- return () => clearTimeout(t);
461
- }, [on]);
462
- react.useEffect(() => {
463
- const onKey = (e) => {
464
- if (e.key === "Escape") closePanel();
465
- };
466
- document.addEventListener("keydown", onKey);
467
- return () => document.removeEventListener("keydown", onKey);
468
- }, []);
469
- react.useEffect(() => {
470
- const update = () => setRect(measurePopup());
471
- update();
472
- const ro = new ResizeObserver(update);
473
- const header = document.querySelector("[data-slot=\"conversation.session.header\"]");
474
- const composer = document.querySelector("[data-composer-card]");
475
- if (header) ro.observe(header);
476
- if (composer) ro.observe(composer);
477
- window.addEventListener("resize", update);
478
- return () => {
479
- ro.disconnect();
480
- window.removeEventListener("resize", update);
481
- };
482
- }, []);
604
+ const focusAfter = (rowId) => {
605
+ requestAnimationFrame(() => {
606
+ document.getElementById(`${idBase}-detail-btn-${rowId}`)?.focus();
607
+ });
608
+ };
483
609
  react.useEffect(() => () => {
484
610
  timeoutRef.current?.();
485
611
  }, []);
486
612
  react.useEffect(() => {
487
- if (!on) return;
488
613
  api("config", {}).then((res) => {
489
614
  const c = res?.data?.config ?? null;
490
615
  if (!c) return;
491
616
  setConfig(c);
492
- if (!scopeTouched.current) setScope(c.defaultScope);
617
+ if (!scopeTouched.current) setScope(SCOPE_VALUES.includes(c.defaultScope) ? c.defaultScope : "workspace");
493
618
  }).catch(() => {});
494
- }, [on]);
619
+ }, []);
495
620
  const scan = react.useCallback(() => {
496
621
  const at = (/* @__PURE__ */ new Date()).toLocaleTimeString();
497
622
  setView((v) => ({
@@ -501,7 +626,7 @@ window.__ModuleLoader__.load({
501
626
  err: null
502
627
  }));
503
628
  timeoutRef.current?.();
504
- timeoutRef.current = timerCtx?.timeout(() => {
629
+ timeoutRef.current = timerCtx$1?.timeout(() => {
505
630
  setView((v) => v.phase === "scanning" ? {
506
631
  phase: "timeout",
507
632
  at,
@@ -509,7 +634,7 @@ window.__ModuleLoader__.load({
509
634
  err: "timeout"
510
635
  } : v);
511
636
  }, 8e3) ?? null;
512
- api("services/scan", {}).then((res) => {
637
+ api("services/scan", { sessionId }).then((res) => {
513
638
  timeoutRef.current?.();
514
639
  timeoutRef.current = null;
515
640
  setView({
@@ -528,29 +653,27 @@ window.__ModuleLoader__.load({
528
653
  err: String(e?.message || e)
529
654
  });
530
655
  });
531
- }, []);
656
+ }, [sessionId]);
532
657
  react.useEffect(() => {
533
- if (on && view.phase === "idle") scan();
658
+ if (visible && view.phase === "idle") scan();
534
659
  }, [
535
- on,
660
+ visible,
536
661
  scan,
537
662
  view.phase
538
663
  ]);
539
664
  react.useEffect(() => {
540
- if (!on || tab !== "services" || !config) return;
665
+ if (!config || !visible) return;
541
666
  if (!config.refreshInterval || view.phase === "scanning") return;
542
- const cancel = timerCtx?.timeout(() => scan(), config.refreshInterval);
667
+ const cancel = timerCtx$1?.timeout(() => scan(), config.refreshInterval);
543
668
  return () => {
544
669
  cancel?.();
545
670
  };
546
671
  }, [
547
- on,
548
- tab,
549
672
  config,
673
+ visible,
550
674
  view.phase,
551
675
  scan
552
676
  ]);
553
- if (!on && !closing) return null;
554
677
  const runAction = (svc, action) => {
555
678
  if (pending) return;
556
679
  setConfirming({
@@ -563,6 +686,7 @@ window.__ModuleLoader__.load({
563
686
  if (pending) return;
564
687
  setPending(true);
565
688
  setConfirming(null);
689
+ focusAfter(svc.id);
566
690
  api("services/" + action, { serviceId: svc.id }).then((res) => {
567
691
  let ok;
568
692
  let text;
@@ -571,7 +695,8 @@ window.__ModuleLoader__.load({
571
695
  text = action === "stop" ? tr("result.stopped") : tr("result.restarted");
572
696
  } else {
573
697
  ok = false;
574
- text = trError(res?.error?.code ?? "", res?.error?.message || tr("result.error"));
698
+ const code = res?.error?.code ?? "";
699
+ text = trError(tr, code, res?.error?.message || tr("result.error"));
575
700
  }
576
701
  setOpResult({
577
702
  id: svc.id,
@@ -602,37 +727,46 @@ window.__ModuleLoader__.load({
602
727
  const q = query.toLowerCase();
603
728
  rows = rows.filter((s) => s.name.toLowerCase().includes(q) || String(s.pid).includes(q) || (s.commandSummary ?? "").toLowerCase().includes(q) || (s.cwd ?? "").toLowerCase().includes(q) || s.listeners.some((l) => String(l.port).includes(q)));
604
729
  }
605
- const servicesBody = /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
606
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
607
- className: service_console_module_css_default.filterRow,
608
- children: [
609
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
610
- className: service_console_module_css_default.segGroup,
611
- role: "group",
612
- "aria-label": tr("settings.defaultScope"),
613
- children: [
614
- "conversation",
615
- "workspace",
616
- "machine"
617
- ].map((s) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
618
- type: "button",
619
- className: service_console_module_css_default.segBtn + (scope === s ? " " + service_console_module_css_default.segBtnOn : ""),
620
- "aria-pressed": scope === s,
621
- onClick: () => {
622
- scopeTouched.current = true;
623
- setScope(s);
624
- },
625
- children: tr(SCOPE_KEY[s])
626
- }, s))
627
- }),
628
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
730
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
731
+ className: service_console_module_css_default.console,
732
+ "data-dsh-sc": "panel",
733
+ "data-dsh-sc-phase": view.phase,
734
+ "data-dsh-sc-session": sessionId,
735
+ children: [
736
+ toast ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Toast, {
737
+ text: toast.text,
738
+ tone: toast.tone,
739
+ onDone: () => setToast(null)
740
+ }, toast.seq) : null,
741
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
742
+ className: service_console_module_css_default.toolbar,
743
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.SegmentedControl, {
744
+ id: idBase + "-scope",
745
+ label: tr("scope.filter"),
746
+ value: scope,
747
+ options: SCOPE_VALUES.map((s) => ({
748
+ value: s,
749
+ label: tr(SCOPE_KEY[s])
750
+ })),
751
+ onChange: (next) => {
752
+ scopeTouched.current = true;
753
+ setScope(next);
754
+ }
755
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ButtonRefresh, {
756
+ t: tr,
757
+ onClick: scan
758
+ })]
759
+ }),
760
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
761
+ className: service_console_module_css_default.filterRow,
762
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Input, {
629
763
  className: service_console_module_css_default.filter,
630
764
  type: "text",
631
765
  value: query,
766
+ "aria-label": tr("search.ph"),
632
767
  placeholder: tr("search.ph"),
633
768
  onChange: (e) => setQuery(e.target.value)
634
- }),
635
- query !== "" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
769
+ }), query !== "" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
636
770
  type: "button",
637
771
  className: service_console_module_css_default.filterClear,
638
772
  onClick: () => setQuery(""),
@@ -650,477 +784,750 @@ window.__ModuleLoader__.load({
650
784
  strokeLinecap: "round"
651
785
  })
652
786
  })
653
- }) : null
654
- ]
655
- }),
656
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
657
- className: service_console_module_css_default.hintLine,
658
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { className: service_console_module_css_default.liveDot }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
659
- className: scope === "machine" ? service_console_module_css_default.hintWarn : void 0,
660
- children: scope === "machine" ? "⚠ " + tr("scope.machineWarn") : tr("panel.subtitle")
661
- })]
662
- }),
663
- view.phase === "scanning" ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
664
- className: service_console_module_css_default.note,
665
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { className: service_console_module_css_default.spin }), tr("status.scanning")]
666
- }) : view.phase === "error" || view.phase === "timeout" ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
667
- className: service_console_module_css_default.noteErr,
668
- children: [
669
- tr("status.error"),
670
- ": ",
671
- view.err
672
- ]
673
- }) : null,
674
- (view.data?.partialWarnings ?? []).map((w, i) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
675
- className: service_console_module_css_default.noteWarn,
676
- children: ["⚠ ", w]
677
- }, `w${i}`)),
678
- rows.length === 0 && view.phase === "done" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
679
- className: service_console_module_css_default.empty,
680
- children: tr("svc.noSvc")
681
- }) : rows.map((svc) => {
682
- const level = ownershipLevel(svc.ownership);
683
- const badgeColor = OWNERSHIP_COLOR[level];
684
- const badgeKey = OWNERSHIP_KEY[level];
685
- const ports = svc.listeners.map((l) => String(l.port)).join(", ");
686
- const url = svc.listeners.map((l) => l.url).filter(Boolean)[0] ?? null;
687
- const canControl = !svc.protected;
688
- const isConfirming = confirming?.id === svc.id;
689
- const result = opResult?.id === svc.id ? opResult : null;
690
- return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
691
- className: service_console_module_css_default.row,
787
+ }) : null]
788
+ }),
789
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
790
+ className: service_console_module_css_default.hintLine,
791
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.StateDot, { state: view.phase === "error" || view.phase === "timeout" ? "error" : view.phase === "scanning" ? "ongoing" : "done" }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
792
+ className: scope === "machine" ? service_console_module_css_default.hintWarn : void 0,
793
+ children: scope === "machine" ? "⚠ " + tr("scope.machineWarn") : tr("panel.subtitle")
794
+ })]
795
+ }),
796
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
797
+ id: idBase + "-scope-" + scope + "-panel",
798
+ role: "tabpanel",
799
+ "aria-labelledby": idBase + "-scope-" + scope,
800
+ className: service_console_module_css_default.scroll,
801
+ "aria-busy": view.phase === "scanning",
692
802
  children: [
693
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
694
- className: service_console_module_css_default.rowMain,
695
- children: [
696
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
697
- className: service_console_module_css_default.rowDot,
698
- style: { color: badgeColor },
699
- children: "●"
700
- }),
701
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
702
- className: service_console_module_css_default.rowName,
703
- children: svc.name
704
- }),
705
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
706
- className: service_console_module_css_default.rowMeta,
707
- children: [
708
- ":",
709
- ports,
710
- " · pid ",
711
- svc.pid
712
- ]
713
- }),
714
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
715
- className: service_console_module_css_default.badge,
716
- style: { color: badgeColor },
717
- children: tr(badgeKey)
718
- }),
719
- svc.restartable ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
720
- className: service_console_module_css_default.badge,
721
- style: { color: "var(--dsw-alias-state-success-primary, #4ade80)" },
722
- children: "↻"
723
- }) : null,
724
- url ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("a", {
725
- className: service_console_module_css_default.rowAct,
726
- href: url,
727
- target: "_blank",
728
- rel: "noreferrer",
729
- title: url,
730
- onClick: (e) => e.stopPropagation(),
731
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("svg", {
732
- viewBox: "0 0 16 16",
733
- width: 12,
734
- height: 12,
735
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", {
736
- d: "M6.5 3.5h-3a1 1 0 0 0-1 1v8a1 1 0 0 0 1 1h8a1 1 0 0 0 1-1v-3M9 2.5h4.5V7M13.5 2.5L7.5 8.5",
737
- fill: "none",
738
- stroke: "currentColor",
739
- strokeWidth: 1.3,
740
- strokeLinecap: "round",
741
- strokeLinejoin: "round"
742
- })
743
- })
744
- }) : null,
745
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { className: service_console_module_css_default.spacer }),
746
- canControl ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
747
- type: "button",
748
- className: service_console_module_css_default.rowBtn,
749
- onClick: (e) => {
750
- e.stopPropagation();
751
- runAction(svc, "stop");
752
- },
753
- children: isConfirming && confirming.action === "stop" ? tr("confirm.stop") : tr("action.stop")
754
- }) : null,
755
- svc.restartable && canControl ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
756
- type: "button",
757
- className: service_console_module_css_default.rowBtn,
758
- onClick: (e) => {
759
- e.stopPropagation();
760
- runAction(svc, "restart");
761
- },
762
- children: isConfirming && confirming.action === "restart" ? tr("confirm.restart") : tr("action.restart")
763
- }) : null,
764
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
765
- type: "button",
766
- className: service_console_module_css_default.rowBtn,
767
- onClick: (e) => {
768
- e.stopPropagation();
769
- setExpanded(expanded === svc.id ? null : svc.id);
770
- },
771
- children: expanded === svc.id ? "▾" : tr("action.detail")
772
- })
773
- ]
774
- }),
775
803
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
776
- className: service_console_module_css_default.rowSub,
777
- children: (svc.commandSummary ? svc.commandSummary.slice(0, 100) : "(?)") + (svc.commandSummary && svc.commandSummary.length > 100 ? "…" : "")
804
+ role: "status",
805
+ "aria-live": "polite",
806
+ children: view.phase === "scanning" ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
807
+ className: service_console_module_css_default.note,
808
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { className: service_console_module_css_default.spin }), tr("status.scanning")]
809
+ }) : view.phase === "error" || view.phase === "timeout" ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
810
+ className: service_console_module_css_default.noteErr,
811
+ children: [
812
+ tr("status.error"),
813
+ ": ",
814
+ view.err
815
+ ]
816
+ }) : null
778
817
  }),
779
- svc.cwd ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
780
- className: service_console_module_css_default.rowSub,
781
- children: svc.cwd
782
- }) : null,
783
- result ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
784
- className: result.ok ? service_console_module_css_default.okText : service_console_module_css_default.errText,
785
- children: [result.ok ? "✅ " : "⛔ ", result.text]
786
- }) : null,
787
- isConfirming ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
788
- className: service_console_module_css_default.confirmRow,
789
- children: [
790
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
791
- className: service_console_module_css_default.confirmTxt,
792
- children: tr("confirm.txt", {
793
- name: svc.name,
794
- pid: String(svc.pid),
795
- action: confirming.action === "stop" ? tr("action.stop") : tr("action.restart")
796
- })
797
- }),
798
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
799
- type: "button",
800
- className: service_console_module_css_default.confirmOk,
801
- disabled: pending,
802
- onClick: () => confirmAction(svc, confirming.action),
803
- children: pending ? tr("action.pending") : tr("action.confirm")
804
- }),
805
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
806
- type: "button",
807
- className: service_console_module_css_default.confirmCancel,
808
- onClick: () => setConfirming(null),
809
- children: tr("action.cancel")
810
- })
811
- ]
812
- }) : null,
813
- expanded === svc.id ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
814
- className: service_console_module_css_default.detailBox,
815
- role: "region",
816
- "aria-label": tr("detail.title"),
817
- children: [
818
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
819
- className: service_console_module_css_default.detailHead,
820
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: tr("detail.title") }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
821
- className: service_console_module_css_default.detailAccent,
822
- children: tr("detail.serviceRecord")
823
- })]
824
- }),
825
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
826
- className: service_console_module_css_default.detailGrid,
827
- children: [
828
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
829
- className: service_console_module_css_default.detailLabel,
830
- children: tr("detail.serviceId")
831
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("code", { children: svc.id })] }),
832
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
833
- className: service_console_module_css_default.detailLabel,
834
- children: tr("detail.process")
835
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("code", { children: [
836
- "PID ",
837
- svc.pid,
838
- " · PGID ",
839
- String(svc.processGroupId ?? "-")
840
- ] })] }),
841
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
842
- className: service_console_module_css_default.detailLabel,
843
- children: tr("detail.parent")
844
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("code", { children: ["PPID ", String(svc.parentPid ?? "-")] })] }),
845
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
846
- className: service_console_module_css_default.detailLabel,
847
- children: tr("detail.started")
848
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("code", { children: String(svc.startedAt ?? "-") })] })
849
- ]
850
- }),
851
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
852
- className: service_console_module_css_default.evidenceBlock,
853
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
854
- className: service_console_module_css_default.detailLabel,
855
- children: tr("detail.evidence")
856
- }), svc.ownershipEvidence.length ? svc.ownershipEvidence.map((ev, i) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
857
- className: service_console_module_css_default.evidenceItem,
858
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
859
- className: service_console_module_css_default.evidenceArrow,
860
- children: "↳"
861
- }), ev]
862
- }, i)) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
818
+ (view.data?.partialWarnings ?? []).map((w, i) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
819
+ className: service_console_module_css_default.noteWarn,
820
+ children: ["⚠ ", w]
821
+ }, `w${i}`)),
822
+ rows.length === 0 && view.phase === "done" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
823
+ className: service_console_module_css_default.empty,
824
+ children: tr("svc.noSvc")
825
+ }) : rows.map((svc) => {
826
+ const level = ownershipLevel(svc.ownership);
827
+ const badgeColor = OWNERSHIP_COLOR[level];
828
+ const badgeKey = OWNERSHIP_KEY[level];
829
+ const ports = svc.listeners.map((l) => String(l.port)).join(", ");
830
+ const url = svc.listeners.map((l) => l.url).filter(Boolean)[0] ?? null;
831
+ const canControl = !svc.protected;
832
+ const isConfirming = confirming?.id === svc.id;
833
+ const result = opResult?.id === svc.id ? opResult : null;
834
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
835
+ className: service_console_module_css_default.row,
836
+ "data-dsh-sc": "row",
837
+ "data-dsh-sc-ownership": level,
838
+ "data-dsh-sc-ports": ports,
839
+ children: [
840
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
841
+ className: service_console_module_css_default.rowMain,
842
+ children: [
843
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
844
+ className: service_console_module_css_default.rowDot,
845
+ style: { color: badgeColor },
846
+ "aria-hidden": "true",
847
+ children: "●"
848
+ }),
849
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
850
+ className: service_console_module_css_default.rowName,
851
+ children: svc.name
852
+ }),
853
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
854
+ className: service_console_module_css_default.rowMeta,
855
+ children: [
856
+ ":",
857
+ ports,
858
+ " · pid ",
859
+ svc.pid
860
+ ]
861
+ }),
862
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Tag, {
863
+ tone: OWNERSHIP_TONE[level],
864
+ children: tr(badgeKey)
865
+ }),
866
+ svc.restartable ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Tag, {
867
+ tone: "success",
868
+ children: tr("svc.restartable")
869
+ }) : null,
870
+ url ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("a", {
871
+ className: service_console_module_css_default.rowAct,
872
+ href: url,
873
+ target: "_blank",
874
+ rel: "noreferrer",
875
+ title: url,
876
+ onClick: (e) => e.stopPropagation(),
877
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("svg", {
878
+ viewBox: "0 0 16 16",
879
+ width: 12,
880
+ height: 12,
881
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", {
882
+ d: "M6.5 3.5h-3a1 1 0 0 0-1 1v8a1 1 0 0 0 1 1h8a1 1 0 0 0 1-1v-3M9 2.5h4.5V7M13.5 2.5L7.5 8.5",
883
+ fill: "none",
884
+ stroke: "currentColor",
885
+ strokeWidth: 1.3,
886
+ strokeLinecap: "round",
887
+ strokeLinejoin: "round"
888
+ })
889
+ })
890
+ }) : null,
891
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { className: service_console_module_css_default.spacer }),
892
+ canControl ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
893
+ type: "button",
894
+ className: service_console_module_css_default.rowBtn,
895
+ "aria-label": tr("action.stop") + " " + svc.name,
896
+ onClick: (e) => {
897
+ e.stopPropagation();
898
+ runAction(svc, "stop");
899
+ },
900
+ children: isConfirming && confirming.action === "stop" ? tr("confirm.stop") : tr("action.stop")
901
+ }) : null,
902
+ svc.restartable && canControl ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
903
+ type: "button",
904
+ className: service_console_module_css_default.rowBtn,
905
+ "aria-label": tr("action.restart") + " " + svc.name,
906
+ onClick: (e) => {
907
+ e.stopPropagation();
908
+ runAction(svc, "restart");
909
+ },
910
+ children: isConfirming && confirming.action === "restart" ? tr("confirm.restart") : tr("action.restart")
911
+ }) : null,
912
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
913
+ type: "button",
914
+ className: service_console_module_css_default.rowBtn,
915
+ id: idBase + "-detail-btn-" + svc.id,
916
+ "aria-expanded": expanded === svc.id,
917
+ "aria-controls": idBase + "-detail-" + svc.id,
918
+ "aria-label": tr("action.detail") + " " + svc.name,
919
+ onClick: (e) => {
920
+ e.stopPropagation();
921
+ setExpanded(expanded === svc.id ? null : svc.id);
922
+ },
923
+ children: expanded === svc.id ? "▾" : tr("action.detail")
924
+ })
925
+ ]
926
+ }),
927
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
863
928
  className: service_console_module_css_default.rowSub,
864
- children: "—"
865
- })]
866
- })
867
- ]
868
- }) : null
929
+ children: (svc.commandSummary ? svc.commandSummary.slice(0, 100) : "(?)") + (svc.commandSummary && svc.commandSummary.length > 100 ? "…" : "")
930
+ }),
931
+ svc.cwd ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
932
+ className: service_console_module_css_default.rowSub,
933
+ children: svc.cwd
934
+ }) : null,
935
+ result ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
936
+ className: result.ok ? service_console_module_css_default.okText : service_console_module_css_default.errText,
937
+ children: [result.ok ? "✅ " : "⛔ ", result.text]
938
+ }) : null,
939
+ isConfirming ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
940
+ className: service_console_module_css_default.confirmRow,
941
+ role: "group",
942
+ "aria-label": tr("confirm.txt", {
943
+ name: svc.name,
944
+ pid: String(svc.pid),
945
+ action: confirming.action === "stop" ? tr("action.stop") : tr("action.restart")
946
+ }),
947
+ children: [
948
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
949
+ className: service_console_module_css_default.confirmTxt,
950
+ children: tr("confirm.txt", {
951
+ name: svc.name,
952
+ pid: String(svc.pid),
953
+ action: confirming.action === "stop" ? tr("action.stop") : tr("action.restart")
954
+ })
955
+ }),
956
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
957
+ variant: "primary",
958
+ size: "sm",
959
+ disabled: pending,
960
+ onClick: () => confirmAction(svc, confirming.action),
961
+ children: pending ? tr("action.pending") : tr("action.confirm")
962
+ }),
963
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
964
+ variant: "outline",
965
+ size: "sm",
966
+ onClick: () => {
967
+ setConfirming(null);
968
+ focusAfter(svc.id);
969
+ },
970
+ children: tr("action.cancel")
971
+ })
972
+ ]
973
+ }) : null,
974
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
975
+ className: service_console_module_css_default.detailBox,
976
+ id: idBase + "-detail-" + svc.id,
977
+ role: "region",
978
+ "aria-label": tr("detail.title"),
979
+ hidden: expanded !== svc.id,
980
+ children: [
981
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
982
+ className: service_console_module_css_default.detailHead,
983
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: tr("detail.title") }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
984
+ className: service_console_module_css_default.detailAccent,
985
+ children: tr("detail.serviceRecord")
986
+ })]
987
+ }),
988
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
989
+ className: service_console_module_css_default.detailGrid,
990
+ children: [
991
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
992
+ className: service_console_module_css_default.detailLabel,
993
+ children: tr("detail.serviceId")
994
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("code", { children: svc.id })] }),
995
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
996
+ className: service_console_module_css_default.detailLabel,
997
+ children: tr("detail.process")
998
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("code", { children: [
999
+ "PID ",
1000
+ svc.pid,
1001
+ " · PGID ",
1002
+ String(svc.processGroupId ?? "-")
1003
+ ] })] }),
1004
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1005
+ className: service_console_module_css_default.detailLabel,
1006
+ children: tr("detail.parent")
1007
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("code", { children: ["PPID ", String(svc.parentPid ?? "-")] })] }),
1008
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1009
+ className: service_console_module_css_default.detailLabel,
1010
+ children: tr("detail.started")
1011
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("code", { children: String(svc.startedAt ?? "-") })] })
1012
+ ]
1013
+ }),
1014
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1015
+ className: service_console_module_css_default.evidenceBlock,
1016
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1017
+ className: service_console_module_css_default.detailLabel,
1018
+ children: tr("detail.evidence")
1019
+ }), svc.ownershipEvidence.length ? svc.ownershipEvidence.map((ev, i) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1020
+ className: service_console_module_css_default.evidenceItem,
1021
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1022
+ className: service_console_module_css_default.evidenceArrow,
1023
+ children: "↳"
1024
+ }), ev]
1025
+ }, i)) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
1026
+ className: service_console_module_css_default.rowSub,
1027
+ children: "—"
1028
+ })]
1029
+ })
1030
+ ]
1031
+ })
1032
+ ]
1033
+ }, svc.id);
1034
+ })
869
1035
  ]
870
- }, svc.id);
1036
+ }),
1037
+ SCOPE_VALUES.filter((s) => s !== scope).map((s) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
1038
+ id: idBase + "-scope-" + s + "-panel",
1039
+ role: "tabpanel",
1040
+ "aria-labelledby": idBase + "-scope-" + s,
1041
+ hidden: true
1042
+ }, s))
1043
+ ]
1044
+ });
1045
+ }
1046
+ /** 刷新按钮(小、无文案,供工具条复用) */
1047
+ function ButtonRefresh({ t, onClick }) {
1048
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
1049
+ type: "button",
1050
+ className: service_console_module_css_default.icoBtn,
1051
+ onClick,
1052
+ title: t("status.lastScan"),
1053
+ "aria-label": t("status.lastScan"),
1054
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("svg", {
1055
+ viewBox: "0 0 16 16",
1056
+ width: 14,
1057
+ height: 14,
1058
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", {
1059
+ d: "M13.5 8a5.5 5.5 0 1 1-1.61-3.89M13.5 1.5v3h-3",
1060
+ fill: "none",
1061
+ stroke: "currentColor",
1062
+ strokeWidth: 1.5,
1063
+ strokeLinecap: "round"
1064
+ })
871
1065
  })
872
- ] });
873
- const settingsBody = /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ServiceConsoleSettings, { onSaved: setConfig });
874
- return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
875
- className: service_console_module_css_default.layer,
876
- children: [toast ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Toast, {
877
- text: toast.text,
878
- tone: toast.tone,
879
- onDone: () => setToast(null)
880
- }, toast.seq) : null, /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
881
- className: service_console_module_css_default.popup + (shown ? " " + service_console_module_css_default.popupOn : ""),
882
- style: {
883
- top: rect.top,
884
- height: rect.height
885
- },
1066
+ });
1067
+ }
1068
+ // \0dsh-css:/home/runner/work/dsh-service-console/dsh-service-console/src/client/service-list-card.module.css.mjs
1069
+ const css = "._3hjC-q_card{border:1px solid var(--dsw-alias-border-l3,#80808026);background:var(--dsw-alias-bg-layer-1,#ffffff08);color:var(--dsw-alias-label-primary,#e8e8e8);border-radius:12px;margin:6px 0 10px;padding:10px 12px;font:12.5px/1.45 -apple-system,BlinkMacSystemFont,Segoe UI,PingFang SC,Microsoft YaHei,sans-serif}._3hjC-q_summary{color:var(--dsw-alias-label-secondary,#9a9a9a);font-size:12px}._3hjC-q_spacer{flex:1}._3hjC-q_openConsole{border:1px solid var(--dsw-alias-border-l2,#8080804d);height:24px;color:var(--dsw-alias-label-secondary,#9a9a9a);font:inherit;cursor:pointer;background:0 0;border-radius:6px;flex:none;padding:0 8px;font-size:11px}._3hjC-q_openConsole:hover{color:var(--dsw-alias-label-primary,#e8e8e8);background:var(--dsw-alias-interactive-bg-hover,#8080801f)}._3hjC-q_openConsole:focus-visible,._3hjC-q_action:focus-visible,._3hjC-q_link:focus-visible{outline:2px solid var(--dsw-alias-state-business-primary,#4176e6);outline-offset:1px}._3hjC-q_row{border-top:1px solid var(--dsw-alias-border-l3,#8080801f);padding:6px 0}._3hjC-q_row+._3hjC-q_row{border-top:1px solid var(--dsw-alias-border-l3,#8080801f)}._3hjC-q_rowMain{flex-wrap:wrap;align-items:center;gap:7px;min-width:0;display:flex}._3hjC-q_dot{flex:none;font-size:8px;line-height:1}._3hjC-q_name{word-break:break-word;font-weight:600}._3hjC-q_meta{color:var(--dsw-alias-label-secondary,#9a9a9a);font-variant-numeric:tabular-nums;font-size:11px}._3hjC-q_link{color:var(--dsw-alias-state-business-primary,#4176e6);font-size:11px;text-decoration:none}._3hjC-q_link:hover{text-decoration:underline}._3hjC-q_action{border:1px solid var(--dsw-alias-border-l2,#8080804d);height:22px;color:var(--dsw-alias-label-secondary,#9a9a9a);font:inherit;cursor:pointer;background:0 0;border-radius:6px;flex:none;padding:0 7px;font-size:11px}._3hjC-q_action:hover{color:var(--dsw-alias-label-primary,#e8e8e8);background:var(--dsw-alias-interactive-bg-hover,#8080801f)}._3hjC-q_empty{color:var(--dsw-alias-label-secondary,#9a9a9a);padding:4px 0;font-size:11.5px}._3hjC-q_more{color:var(--dsw-alias-label-secondary,#9a9a9a);padding-top:4px;font-size:11px}._3hjC-q_text{white-space:pre-wrap;word-break:break-word;color:var(--dsw-alias-label-secondary,#9a9a9a);margin:4px 0 0;font-family:ui-monospace,SFMono-Regular,Menlo,monospace;font-size:11px}._3hjC-q_okText{color:var(--dsw-alias-label-secondary,#9a9a9a);border-left:2px solid var(--dsw-alias-state-success-primary,#4ade80);margin-top:4px;padding-left:6px;font-size:11.5px}._3hjC-q_error{color:var(--dsw-alias-label-secondary,#9a9a9a);border-left:2px solid var(--dsw-alias-state-error-primary,#f87171);margin-top:4px;padding-left:6px;font-size:11.5px}@media (prefers-reduced-motion:reduce){._3hjC-q_card{transition:none}}._3hjC-q_accessory{align-items:center;gap:8px;display:inline-flex}._3hjC-q_confirmRow{background:color-mix(in srgb, var(--dsw-alias-state-warn-primary,#e7b85d) 8%, transparent);border:1px solid color-mix(in srgb, var(--dsw-alias-state-warn-primary,#e7b85d) 15%, transparent);border-radius:8px;flex-wrap:wrap;align-items:center;gap:6px;margin-top:6px;padding:6px 8px;display:flex}._3hjC-q_confirmTxt{min-width:0;color:var(--dsw-alias-label-secondary,#b0b3ba);flex:1;font-size:11px}";
1070
+ const tagId = "@jiyr0119/dsh-service-console/service-list-card.module.css";
1071
+ if (typeof document !== "undefined" && document.querySelector("style[data-plugin-css=" + JSON.stringify(tagId) + "]") === null) {
1072
+ const tag = document.createElement("style");
1073
+ tag.dataset.plugin = "@jiyr0119/dsh-service-console";
1074
+ tag.dataset.pluginCss = tagId;
1075
+ tag.textContent = css;
1076
+ document.head.appendChild(tag);
1077
+ }
1078
+ var service_list_card_module_css_default = {
1079
+ "error": "_3hjC-q_error",
1080
+ "openConsole": "_3hjC-q_openConsole",
1081
+ "card": "_3hjC-q_card",
1082
+ "rowMain": "_3hjC-q_rowMain",
1083
+ "link": "_3hjC-q_link",
1084
+ "dot": "_3hjC-q_dot",
1085
+ "spacer": "_3hjC-q_spacer",
1086
+ "empty": "_3hjC-q_empty",
1087
+ "text": "_3hjC-q_text",
1088
+ "okText": "_3hjC-q_okText",
1089
+ "row": "_3hjC-q_row",
1090
+ "summary": "_3hjC-q_summary",
1091
+ "confirmTxt": "_3hjC-q_confirmTxt",
1092
+ "meta": "_3hjC-q_meta",
1093
+ "more": "_3hjC-q_more",
1094
+ "action": "_3hjC-q_action",
1095
+ "confirmRow": "_3hjC-q_confirmRow",
1096
+ "name": "_3hjC-q_name",
1097
+ "accessory": "_3hjC-q_accessory"
1098
+ };
1099
+ // src/client/ServiceListCard.tsx
1100
+ /**
1101
+ * service_list 的聊天卡片(`tool.call.toolview`,keyed by wire tool name)
1102
+ *
1103
+ * 数据来自工具 `output.presentationMeta`(随会话日志持久化 → 视为不可信),
1104
+ * 投影成视图模型由纯函数 `projectServiceListMeta` 完成;任何坏形状都回退成
1105
+ * 纯文本行,**绝不抛错**——toolview 抛错会让该 key 粘性空白。
1106
+ *
1107
+ * 交互约束(与面板同一语义,不新增策略):
1108
+ * - 受保护目标只读;「重启」还要求 meta 里的 `restartable`(无安全启动记录不提供);
1109
+ * - 停止/重启二次确认 + 在途去重;错误码走词典;
1110
+ * - 卡片是一次调用的**快照**,不轮询;折叠状态由平台的 `useDisclosure` 拥有。
1111
+ */
1112
+ /** 结果态的纯文本兜底:把模型面 content 拼成一段(旧会话没有 meta 时走这里) */
1113
+ function contentText(content) {
1114
+ if (!Array.isArray(content)) return "";
1115
+ const parts = [];
1116
+ for (const item of content) if (typeof item === "object" && item !== null && item.type === "text") {
1117
+ const text = item.text;
1118
+ if (typeof text === "string" && text !== "") parts.push(text);
1119
+ }
1120
+ return parts.join("\n");
1121
+ }
1122
+ /** 动态错误码 → 词典键(err.<CODE>),未收录回退 */
1123
+ function errorText(t, code, fallback) {
1124
+ if (code === "") return fallback;
1125
+ const key = "err." + code;
1126
+ const s = t(key);
1127
+ return s === key ? fallback : s;
1128
+ }
1129
+ /** 小监视器图标(DisclosureRow 的 leading 位) */
1130
+ function CardGlyph() {
1131
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("svg", {
1132
+ viewBox: "0 0 16 16",
1133
+ width: 14,
1134
+ height: 14,
1135
+ "aria-hidden": "true",
1136
+ fill: "none",
1137
+ children: [
1138
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("rect", {
1139
+ x: 2.25,
1140
+ y: 3.25,
1141
+ width: 11.5,
1142
+ height: 8.5,
1143
+ rx: 2,
1144
+ stroke: "currentColor",
1145
+ strokeWidth: 1.3
1146
+ }),
1147
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", {
1148
+ d: "M5 6.25 6.9 7.75 5 9.25",
1149
+ stroke: "currentColor",
1150
+ strokeWidth: 1.3,
1151
+ strokeLinecap: "round",
1152
+ strokeLinejoin: "round"
1153
+ }),
1154
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", {
1155
+ d: "M8.4 9.25H11",
1156
+ stroke: "currentColor",
1157
+ strokeWidth: 1.3,
1158
+ strokeLinecap: "round"
1159
+ })
1160
+ ]
1161
+ });
1162
+ }
1163
+ function ServiceListCard(props) {
1164
+ const { t, phase } = props;
1165
+ const disclosure = props.useDisclosure();
1166
+ const [confirming, setConfirming] = react.useState(null);
1167
+ const [opResult, setOpResult] = react.useState(null);
1168
+ const [pending, setPending] = react.useState(false);
1169
+ const [toast, setToast] = react.useState(null);
1170
+ const toastSeq = react.useRef(0);
1171
+ const showToast = (text, tone) => {
1172
+ setToast({
1173
+ seq: ++toastSeq.current,
1174
+ text,
1175
+ tone
1176
+ });
1177
+ };
1178
+ const confirmAction = (row, action) => {
1179
+ if (pending) return;
1180
+ setPending(true);
1181
+ setConfirming(null);
1182
+ api("services/" + action, { serviceId: row.id }).then((res) => {
1183
+ const ok = res?.ok === true;
1184
+ const text = ok ? action === "stop" ? t("result.stopped") : t("result.restarted") : errorText(t, res?.error?.code ?? "", res?.error?.message ?? t("result.error"));
1185
+ setOpResult({
1186
+ id: row.id,
1187
+ ok,
1188
+ text
1189
+ });
1190
+ showToast(text, ok ? "success" : void 0);
1191
+ }).catch((error) => {
1192
+ const text = String(error?.message ?? error);
1193
+ setOpResult({
1194
+ id: row.id,
1195
+ ok: false,
1196
+ text
1197
+ });
1198
+ showToast(text);
1199
+ }).finally(() => setPending(false));
1200
+ };
1201
+ const toastNode = toast === null ? null : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Toast, {
1202
+ text: toast.text,
1203
+ tone: toast.tone,
1204
+ onDone: () => setToast(null)
1205
+ }, toast.seq);
1206
+ if (phase !== "result") return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1207
+ className: service_list_card_module_css_default.card,
1208
+ "data-dsh-sc": "card",
1209
+ "data-dsh-sc-phase": phase,
1210
+ children: [toastNode, /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
1211
+ className: service_list_card_module_css_default.summary,
1212
+ children: t("status.scanning")
1213
+ })]
1214
+ });
1215
+ if (props.block.isError) {
1216
+ const text = contentText(props.block.content);
1217
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1218
+ className: service_list_card_module_css_default.card,
1219
+ "data-dsh-sc": "card",
1220
+ "data-dsh-sc-phase": "result",
1221
+ "data-dsh-sc-error": "true",
886
1222
  children: [
887
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
888
- className: service_console_module_css_default.head,
889
- children: [
890
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
891
- className: service_console_module_css_default.headIco,
892
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("svg", {
893
- viewBox: "0 0 16 16",
894
- width: 17,
895
- height: 17,
896
- "aria-hidden": "true",
897
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("rect", {
898
- x: 2,
899
- y: 3,
900
- width: 12,
901
- height: 10,
902
- rx: 1.5,
903
- fill: "none",
904
- stroke: "currentColor",
905
- strokeWidth: 1.3
906
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", {
907
- d: "M5 7h6M5 10h4",
908
- stroke: "currentColor",
909
- strokeWidth: 1.2,
910
- strokeLinecap: "round"
911
- })]
912
- })
913
- }),
914
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
915
- className: service_console_module_css_default.headTitle,
916
- children: tr("panel.title")
917
- }),
918
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
919
- type: "button",
920
- className: service_console_module_css_default.icoBtn,
921
- onClick: scan,
922
- title: tr("status.lastScan"),
923
- "aria-label": tr("status.lastScan"),
924
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("svg", {
925
- viewBox: "0 0 16 16",
926
- width: 14,
927
- height: 14,
928
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", {
929
- d: "M13.5 8a5.5 5.5 0 1 1-1.61-3.89M13.5 1.5v3h-3",
930
- fill: "none",
931
- stroke: "currentColor",
932
- strokeWidth: 1.5,
933
- strokeLinecap: "round"
934
- })
935
- })
936
- }),
937
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
938
- type: "button",
939
- className: service_console_module_css_default.icoBtn,
940
- onClick: closePanel,
941
- title: tr("action.cancel"),
942
- "aria-label": tr("action.cancel"),
943
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("svg", {
944
- viewBox: "0 0 16 16",
945
- width: 14,
946
- height: 14,
947
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", {
948
- d: "M4 4l8 8M12 4l-8 8",
949
- fill: "none",
950
- stroke: "currentColor",
951
- strokeWidth: 1.5,
952
- strokeLinecap: "round"
953
- })
954
- })
955
- })
956
- ]
1223
+ toastNode,
1224
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
1225
+ className: service_list_card_module_css_default.summary,
1226
+ children: t("status.error")
957
1227
  }),
958
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
959
- className: service_console_module_css_default.tabs,
960
- role: "tablist",
961
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
962
- type: "button",
963
- role: "tab",
964
- "aria-selected": tab === "services",
965
- className: service_console_module_css_default.tab + (tab === "services" ? " " + service_console_module_css_default.tabOn : ""),
966
- onClick: () => setTab("services"),
967
- children: [
968
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("svg", {
969
- viewBox: "0 0 16 16",
970
- width: 13,
971
- height: 13,
972
- "aria-hidden": "true",
973
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("rect", {
974
- x: 2,
975
- y: 3,
976
- width: 12,
977
- height: 10,
978
- rx: 1.5,
979
- fill: "none",
980
- stroke: "currentColor",
981
- strokeWidth: 1.3
982
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", {
983
- d: "M5 7h6M5 10h4",
984
- stroke: "currentColor",
985
- strokeWidth: 1.2,
986
- strokeLinecap: "round"
987
- })]
988
- }),
989
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: tr("tab.services") }),
990
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { className: service_console_module_css_default.tabInd })
991
- ]
992
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
993
- type: "button",
994
- role: "tab",
995
- "aria-selected": tab === "settings",
996
- className: service_console_module_css_default.tab + (tab === "settings" ? " " + service_console_module_css_default.tabOn : ""),
997
- onClick: () => setTab("settings"),
1228
+ text === "" ? null : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("pre", {
1229
+ className: service_list_card_module_css_default.text,
1230
+ children: text
1231
+ })
1232
+ ]
1233
+ });
1234
+ }
1235
+ const model = projectServiceListMeta(props.block.meta);
1236
+ if (model === null) {
1237
+ const text = contentText(props.block.content);
1238
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1239
+ className: service_list_card_module_css_default.card,
1240
+ "data-dsh-sc": "card",
1241
+ "data-dsh-sc-phase": "result",
1242
+ "data-dsh-sc-fallback": "true",
1243
+ children: [toastNode, text === "" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
1244
+ className: service_list_card_module_css_default.summary,
1245
+ children: t("svc.noSvc")
1246
+ }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("pre", {
1247
+ className: service_list_card_module_css_default.text,
1248
+ children: text
1249
+ })]
1250
+ });
1251
+ }
1252
+ const ports = serviceListPorts(model);
1253
+ const protectedCount = model.rows.filter((row) => row.protected).length;
1254
+ const summary = t("card.summary", {
1255
+ count: model.count,
1256
+ total: model.total
1257
+ });
1258
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1259
+ className: service_list_card_module_css_default.card,
1260
+ "data-dsh-sc": "card",
1261
+ "data-dsh-sc-phase": "result",
1262
+ "data-dsh-sc-count": model.rows.length,
1263
+ children: [toastNode, /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_deepseek_ai_dsh_client_ui_primitives.DisclosureRow, {
1264
+ icon: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CardGlyph, {}),
1265
+ title: summary,
1266
+ open: disclosure.expanded,
1267
+ expandable: model.rows.length > 0,
1268
+ onToggle: disclosure.toggle,
1269
+ expandOnRowClick: true,
1270
+ keepContentWhenOpen: true,
1271
+ collapsedContent: ports === "" ? null : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1272
+ className: service_list_card_module_css_default.summary,
1273
+ children: ports
1274
+ }),
1275
+ headerAccessory: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
1276
+ className: service_list_card_module_css_default.accessory,
1277
+ children: [protectedCount > 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Tag, {
1278
+ tone: "danger",
1279
+ children: t("own.protected")
1280
+ }) : null, /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
1281
+ type: "button",
1282
+ className: service_list_card_module_css_default.openConsole,
1283
+ onClick: () => {
1284
+ window.dispatchEvent(new Event("dsh-service-console:open"));
1285
+ },
1286
+ children: t("entry.tip")
1287
+ })]
1288
+ }),
1289
+ children: [
1290
+ model.rows.length === 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
1291
+ className: service_list_card_module_css_default.empty,
1292
+ children: t("svc.noSvc")
1293
+ }) : null,
1294
+ model.rows.map((row) => {
1295
+ const color = OWNERSHIP_COLOR[row.ownership];
1296
+ const isConfirming = confirming?.id === row.id;
1297
+ const result = opResult?.id === row.id ? opResult : null;
1298
+ const controllable = canControlService(row);
1299
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1300
+ className: service_list_card_module_css_default.row,
1301
+ "data-dsh-sc": "card-row",
1302
+ "data-dsh-sc-ownership": row.ownership,
1303
+ "data-dsh-sc-ports": row.ports,
998
1304
  children: [
999
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("svg", {
1000
- viewBox: "0 0 16 16",
1001
- width: 13,
1002
- height: 13,
1003
- "aria-hidden": "true",
1004
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("circle", {
1005
- cx: 8,
1006
- cy: 8,
1007
- r: 2.5,
1008
- fill: "none",
1009
- stroke: "currentColor",
1010
- strokeWidth: 1.3
1011
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", {
1012
- d: "M8 4.3V2.9M8 13.1v-1.4M4.3 8H2.9M13.1 8h-1.4M5.2 5.2L4.1 4.1M11.9 11.9l-1.1-1.1M5.2 10.8L4.1 11.9M11.9 4.1l-1.1 1.1",
1013
- fill: "none",
1014
- stroke: "currentColor",
1015
- strokeWidth: 1.2,
1016
- strokeLinecap: "round"
1017
- })]
1305
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1306
+ className: service_list_card_module_css_default.rowMain,
1307
+ children: [
1308
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1309
+ className: service_list_card_module_css_default.dot,
1310
+ style: { color },
1311
+ "aria-hidden": "true",
1312
+ children: "●"
1313
+ }),
1314
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1315
+ className: service_list_card_module_css_default.name,
1316
+ children: row.name
1317
+ }),
1318
+ row.ports === "" ? null : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
1319
+ className: service_list_card_module_css_default.meta,
1320
+ children: [":", row.ports]
1321
+ }),
1322
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Tag, {
1323
+ tone: OWNERSHIP_TONE[row.ownership],
1324
+ children: t(OWNERSHIP_KEY[row.ownership])
1325
+ }),
1326
+ row.url === null ? null : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("a", {
1327
+ className: service_list_card_module_css_default.link,
1328
+ href: row.url,
1329
+ target: "_blank",
1330
+ rel: "noreferrer",
1331
+ "aria-label": t("action.open") + " " + row.name,
1332
+ title: row.url,
1333
+ children: t("action.open")
1334
+ }),
1335
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { className: service_list_card_module_css_default.spacer }),
1336
+ controllable ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
1337
+ type: "button",
1338
+ className: service_list_card_module_css_default.action,
1339
+ disabled: pending,
1340
+ "aria-label": t("action.stop") + " " + row.name,
1341
+ onClick: () => {
1342
+ setConfirming({
1343
+ id: row.id,
1344
+ action: "stop"
1345
+ });
1346
+ setOpResult(null);
1347
+ },
1348
+ children: isConfirming && confirming.action === "stop" ? t("confirm.stop") : t("action.stop")
1349
+ }) : null,
1350
+ controllable && row.restartable ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
1351
+ type: "button",
1352
+ className: service_list_card_module_css_default.action,
1353
+ disabled: pending,
1354
+ "aria-label": t("action.restart") + " " + row.name,
1355
+ onClick: () => {
1356
+ setConfirming({
1357
+ id: row.id,
1358
+ action: "restart"
1359
+ });
1360
+ setOpResult(null);
1361
+ },
1362
+ children: isConfirming && confirming.action === "restart" ? t("confirm.restart") : t("action.restart")
1363
+ }) : null
1364
+ ]
1018
1365
  }),
1019
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: tr("tab.settings") }),
1020
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { className: service_console_module_css_default.tabInd })
1366
+ controllable && isConfirming ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1367
+ className: service_list_card_module_css_default.confirmRow,
1368
+ children: [
1369
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1370
+ className: service_list_card_module_css_default.confirmTxt,
1371
+ children: t("card.confirm", {
1372
+ name: row.name,
1373
+ action: confirming.action === "stop" ? t("action.stop") : t("action.restart")
1374
+ })
1375
+ }),
1376
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
1377
+ variant: "primary",
1378
+ size: "sm",
1379
+ disabled: pending,
1380
+ onClick: () => confirmAction(row, confirming.action),
1381
+ children: pending ? t("action.pending") : t("action.confirm")
1382
+ }),
1383
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
1384
+ variant: "outline",
1385
+ size: "sm",
1386
+ onClick: () => setConfirming(null),
1387
+ children: t("action.cancel")
1388
+ })
1389
+ ]
1390
+ }) : null,
1391
+ result === null ? null : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
1392
+ className: result.ok ? service_list_card_module_css_default.okText : service_list_card_module_css_default.error,
1393
+ children: (result.ok ? "✅ " : "⛔ ") + result.text
1394
+ })
1021
1395
  ]
1022
- })]
1396
+ }, row.id);
1023
1397
  }),
1024
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
1025
- className: service_console_module_css_default.tabBody,
1026
- children: tab === "services" ? servicesBody : settingsBody
1027
- })
1398
+ model.truncated > 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
1399
+ className: service_list_card_module_css_default.more,
1400
+ children: t("card.more", { n: model.truncated })
1401
+ }) : null
1028
1402
  ]
1029
1403
  })]
1030
1404
  });
1031
1405
  }
1032
- //#endregion
1033
- //#region src/client/i18n.ts
1406
+ // src/client/ServiceDockPill.tsx
1407
+ /**
1408
+ * composer 常驻 pill(`conversation.composer.dock`)
1409
+ *
1410
+ * 只在**本会话**有归属服务(`conversation-confirmed`)时出现:
1411
+ * `2 services · :5173 :3000` → 点击打开控制台 tab。
1412
+ *
1413
+ * 设计取舍:
1414
+ * - 数据来自与面板同一个 `/dsh-sc/api/services/scan`(带 sessionId → 宿主按台账
1415
+ * `sessionKey` 收窄归属),选择/摘要全部走纯函数(`service-list-view.ts`,有单测)。
1416
+ * - 轮询**慢且可停**:20s 一次、页面隐藏时跳过、卸载即清;不为一个环境提示
1417
+ * 引入高频 `lsof`。
1418
+ * - 无归属服务时不渲染任何 DOM(不占位、不抢焦点)。
1419
+ */
1420
+ /** 轮询间隔:环境提示够用,且不让 lsof 跑得太勤 */
1421
+ const POLL_INTERVAL_MS = 3e4;
1422
+ let timerCtx = null;
1423
+ /** 注入平台 timer(与面板共用 `bindTimer` 的同一份服务,但这里需要 interval) */
1424
+ function bindDockTimer(t) {
1425
+ timerCtx = t;
1426
+ }
1427
+ function ServiceDockPill({ t, sessionId }) {
1428
+ const [model, setModel] = react.useState(null);
1429
+ react.useEffect(() => {
1430
+ let cancelled = false;
1431
+ setModel(null);
1432
+ let inFlight = false;
1433
+ const load = () => {
1434
+ if (cancelled) return;
1435
+ if (typeof document !== "undefined" && document.visibilityState === "hidden") return;
1436
+ if (inFlight) return;
1437
+ inFlight = true;
1438
+ api("services/scan", { sessionId }).then((res) => {
1439
+ if (cancelled) return;
1440
+ setModel(summarizeSessionServices(selectSessionServices(res?.data?.services)));
1441
+ }).catch(() => {
1442
+ if (!cancelled) setModel(null);
1443
+ }).finally(() => {
1444
+ inFlight = false;
1445
+ });
1446
+ };
1447
+ const onVisible = () => {
1448
+ if (document.visibilityState === "visible") load();
1449
+ };
1450
+ load();
1451
+ const cancelInterval = timerCtx?.interval(load, POLL_INTERVAL_MS);
1452
+ document.addEventListener("visibilitychange", onVisible);
1453
+ return () => {
1454
+ cancelled = true;
1455
+ cancelInterval?.();
1456
+ document.removeEventListener("visibilitychange", onVisible);
1457
+ };
1458
+ }, [sessionId]);
1459
+ if (model === null || model.count === 0) return null;
1460
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_deepseek_ai_dsh_client_ui_primitives.Pill, {
1461
+ className: service_console_module_css_default.dockPill,
1462
+ "data-dsh-sc": "dock-pill",
1463
+ "data-dsh-sc-count": model.count,
1464
+ title: t("dock.open"),
1465
+ onClick: () => {
1466
+ window.dispatchEvent(new Event("dsh-service-console:open"));
1467
+ },
1468
+ children: [
1469
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.StateDot, {
1470
+ state: "done",
1471
+ size: 8
1472
+ }),
1473
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: t("dock.pill", { n: model.count }) }),
1474
+ model.ports === "" ? null : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1475
+ className: service_console_module_css_default.dockPillPorts,
1476
+ children: model.ports
1477
+ })
1478
+ ]
1479
+ });
1480
+ }
1481
+ // src/client/i18n.ts
1034
1482
  /**
1035
- * 幂等注册词典:逐语种注册;单条失败(如 already has locale)跳过,
1036
- * 不影响其余语种与后续绑定。返回 disposer(整体可安全清理)。
1483
+ * 幂等注册词典:单次对象式注册;已由先前装载注册(`already has locale`)视为
1484
+ * 成功,其余错误留一条告警而不是静默吞成「UI 回显原始键」。
1037
1485
  */
1038
1486
  function registerDictionaries(locale, ns, dicts) {
1039
- const offs = [];
1040
- for (const pair of dicts) {
1041
- const code = pair[0];
1042
- const dict = pair[1];
1043
- try {
1044
- const off = locale.register(ns, code, dict);
1045
- if (typeof off === "function") offs.push(off);
1046
- } catch (error) {
1047
- const message = error instanceof Error ? error.message : String(error);
1048
- if (!/already has locale/.test(message)) console.warn("[dsh-service-console] locale.register(" + ns + ", " + code + ") failed:", message);
1049
- }
1487
+ try {
1488
+ locale.register(ns, dicts);
1489
+ } catch (error) {
1490
+ const message = error instanceof Error ? error.message : String(error);
1491
+ if (!/already has locale/.test(message)) console.warn("[dsh-service-console] locale.register(" + ns + ") failed:", message);
1050
1492
  }
1051
- return () => {
1052
- for (const off of offs) try {
1053
- off();
1054
- } catch {}
1055
- };
1056
1493
  }
1057
1494
  /**
1058
- * 绑定翻译函数:稳定外层 + 每次取最新 bound(旧版 bind 可能缓存语种)。
1059
- * 变量插值手工兜底(旧版 bound 可能不支持 params)。
1495
+ * 绑定翻译函数:rc.5 的 bound 原生支持 `{param}` 插值;这里仍保留兜底替换,
1496
+ * 以便旧版/桩实现忽略 params 时标签不出现裸占位符。
1060
1497
  */
1061
1498
  function bindTranslator(locale, ns) {
1062
- const make = () => {
1063
- let bound;
1499
+ let bound;
1500
+ try {
1501
+ bound = locale.bind(ns);
1502
+ } catch {
1503
+ return ((key) => key);
1504
+ }
1505
+ return ((key, params) => {
1506
+ let s;
1064
1507
  try {
1065
- bound = locale.bind(ns);
1508
+ s = bound(key, params);
1066
1509
  } catch {
1067
- bound = (key) => key;
1068
- }
1069
- return (key, params) => {
1070
- let s;
1071
- try {
1072
- s = bound(key);
1073
- } catch {
1074
- s = key;
1075
- }
1076
- if (typeof s !== "string" || s === "") s = key;
1077
- if (params) for (const k of Object.keys(params)) s = s.split("{" + k + "}").join(String(params[k]));
1078
- return s;
1079
- };
1080
- };
1081
- let t = make();
1082
- return {
1083
- t: (key, params) => t(key, params),
1084
- subscribe: (fn) => {
1085
- const off = locale.subscribe(() => {
1086
- t = make();
1087
- fn();
1088
- });
1089
- return typeof off === "function" ? off : () => {};
1510
+ s = key;
1090
1511
  }
1091
- };
1512
+ if (typeof s !== "string" || s === "") s = key;
1513
+ if (params && s.includes("{")) for (const k of Object.keys(params)) s = s.split("{" + k + "}").join(String(params[k]));
1514
+ return s;
1515
+ });
1092
1516
  }
1093
1517
  /**
1094
- * 反应式 i18n 挂载(0.7.2):等 locale 服务真正可用后再注册/绑定。
1095
- *
1096
- * 0.7.1 在 apply 里一次性 `ctx.get('locale')`,有两个真实事故口,UI 都会
1097
- * 退回 `entry.label` 等原始键:
1098
- *
1099
- * 1. 服务晚到(桌面竞态):桌面客户端 `globalThis.__DSH_LOCALE__` 存在时,
1100
- * dsh-client-locale 的 apply 要先 `await bridge.read()`(Electron IPC)才
1101
- * `ctx.provide('locale')`;本插件 apply 先跑,get 取到 undefined 即整体
1102
- * 跳过 i18n。浏览器开发环境无 bridge、provide 同步完成,所以“本地验证
1103
- * 通过、用户下载后失效”。另外 cordis 的 get(strict) 在 provider fiber
1104
- * 尚未落定(state != 2)时同样返回 undefined。
1105
- * 2. 热更新双装载的 dispose 顺序:dshmarket 更新会把插件装载两次,第二次
1106
- * register 抛 already has locale 被跳过;随后旧实例卸载时若把词典 disposer
1107
- * 掉,词典即被撤走,留下没有词典的新实例回显原始键。
1108
- *
1109
- * 对策:`ctx.inject(['locale'], …)` 按平台注入等待语义在服务真正可用
1110
- * (provider fiber 就绪)后才进入;provider 重启/热更新重载都会重新进入
1111
- * 回调并重绑;词典注册保持幂等,且有意不在实例卸载时撤销(见上第 2 条),
1112
- * 注册本身只增不减,对双装载安全。
1518
+ * 反应式 i18n 挂载:等 locale 服务真正可用(provider fiber 就绪)后注册词典,
1519
+ * 并把绑定好的翻译函数交给调用方(用于 slot 注册项的 `label` thunk——它在每次
1520
+ * 投影时被重新读取,因此语言切换无需重新注册)。
1113
1521
  */
1114
- function attachLocale(ctx, ns, dicts, onBound) {
1522
+ function attachLocale(ctx, ns, dicts, onReady) {
1115
1523
  ctx.inject(["locale"], (sub) => {
1116
1524
  const locale = sub.get("locale");
1117
1525
  if (locale === void 0) return;
1118
1526
  registerDictionaries(locale, ns, dicts);
1119
- onBound(bindTranslator(locale, ns));
1527
+ onReady(bindTranslator(locale, ns));
1120
1528
  });
1121
1529
  }
1122
- //#endregion
1123
- //#region src/client/dictionaries.ts
1530
+ // src/client/dictionaries.ts
1124
1531
  /**
1125
1532
  * dsh-service-console — i18n 词典(对齐 DSH locale.register 机制)
1126
1533
  * 与 dsh-workspace-explorer 共享设计语言:flat key → template string with {vars}
@@ -1140,6 +1547,12 @@ window.__ModuleLoader__.load({
1140
1547
  "status.lastScan": "最近扫描",
1141
1548
  "status.error": "扫描失败",
1142
1549
  "svc.noSvc": "未发现服务",
1550
+ "card.summary": "{count}/{total} 项服务",
1551
+ "card.more": "还有 {n} 项…",
1552
+ "card.confirm": "确认对 {name} 执行{action}?",
1553
+ "svc.restartable": "可重启",
1554
+ "dock.pill": "{n} 个会话服务",
1555
+ "dock.open": "打开服务控制台",
1143
1556
  "svc.ports": "端口",
1144
1557
  "svc.pid": "pid",
1145
1558
  "svc.command": "命令",
@@ -1147,6 +1560,7 @@ window.__ModuleLoader__.load({
1147
1560
  "action.stop": "停止",
1148
1561
  "action.restart": "重启",
1149
1562
  "action.detail": "详情",
1563
+ "action.open": "打开",
1150
1564
  "action.confirm": "确认",
1151
1565
  "action.cancel": "取消",
1152
1566
  "action.pending": "处理中…",
@@ -1161,6 +1575,7 @@ window.__ModuleLoader__.load({
1161
1575
  "own.other": "本机其他",
1162
1576
  "own.unknown": "未知",
1163
1577
  "own.protected": "受保护",
1578
+ "scope.filter": "服务范围",
1164
1579
  "scope.conversation": "本次对话",
1165
1580
  "scope.workspace": "当前工作区",
1166
1581
  "scope.machine": "本机",
@@ -1181,6 +1596,7 @@ window.__ModuleLoader__.load({
1181
1596
  "err.RESTART_UNSAFE": "缺少安全启动信息,不能重启",
1182
1597
  "err.PORT_CONFLICT": "端口仍被占用",
1183
1598
  "err.START_TIMEOUT": "未在预期时间开始监听",
1599
+ "err.FORBIDDEN_REMOTE": "非本机来源:只读(防止远程停本机进程)",
1184
1600
  "tab.services": "服务",
1185
1601
  "tab.settings": "设置",
1186
1602
  "settings.title": "面板设置",
@@ -1214,6 +1630,12 @@ window.__ModuleLoader__.load({
1214
1630
  "status.lastScan": "Last scan",
1215
1631
  "status.error": "Scan failed",
1216
1632
  "svc.noSvc": "no services found",
1633
+ "card.summary": "{count}/{total} services",
1634
+ "card.more": "{n} more…",
1635
+ "card.confirm": "Run {action} on {name}?",
1636
+ "svc.restartable": "restartable",
1637
+ "dock.pill": "{n} dev service(s)",
1638
+ "dock.open": "Open the service console",
1217
1639
  "svc.ports": "Ports",
1218
1640
  "svc.pid": "pid",
1219
1641
  "svc.command": "Command",
@@ -1221,6 +1643,7 @@ window.__ModuleLoader__.load({
1221
1643
  "action.stop": "Stop",
1222
1644
  "action.restart": "Restart",
1223
1645
  "action.detail": "Detail",
1646
+ "action.open": "Open",
1224
1647
  "action.confirm": "OK",
1225
1648
  "action.cancel": "Cancel",
1226
1649
  "action.pending": "Working…",
@@ -1235,6 +1658,7 @@ window.__ModuleLoader__.load({
1235
1658
  "own.other": "Other local",
1236
1659
  "own.unknown": "Unknown",
1237
1660
  "own.protected": "Protected",
1661
+ "scope.filter": "Service scope",
1238
1662
  "scope.conversation": "This chat",
1239
1663
  "scope.workspace": "Workspace",
1240
1664
  "scope.machine": "This machine",
@@ -1255,6 +1679,7 @@ window.__ModuleLoader__.load({
1255
1679
  "err.RESTART_UNSAFE": "Cannot restart safely",
1256
1680
  "err.PORT_CONFLICT": "Port conflict",
1257
1681
  "err.START_TIMEOUT": "Start timeout",
1682
+ "err.FORBIDDEN_REMOTE": "Not a local caller — read-only",
1258
1683
  "tab.services": "Services",
1259
1684
  "tab.settings": "Settings",
1260
1685
  "settings.title": "Panel settings",
@@ -1276,38 +1701,212 @@ window.__ModuleLoader__.load({
1276
1701
  "star.ask": "⭐ Drop a Star if it helped — it makes the author's day",
1277
1702
  "star.cta": "★ Give a Star"
1278
1703
  };
1279
- //#endregion
1280
- //#region src/client/index.tsx
1704
+ // src/client/index.tsx
1705
+ /** 词典命名空间(与 LocaleNamespaceMap 合并、各注册项的 `locale:` 一致) */
1281
1706
  const NS = "dsh-service-console";
1707
+ /** tab 类型的实现身份:全局唯一,同时是 stage-two 三个 seat 的 dispatch key(**不是** kind) */
1708
+ const TAB_ID = "@jiyr0119/dsh-service-console";
1709
+ /** 页面类型判别值:`openTab` 用它,tab 记录里存的也是它 */
1710
+ const TAB_KIND = "service-console";
1282
1711
  let labelT = null;
1283
1712
  function labelFn(key) {
1284
1713
  return labelT ? labelT(key) : key;
1285
1714
  }
1286
- //#endregion
1715
+ /**
1716
+ * 幂等注册:桌面 dshmarket 热更新会把插件装载两次,第二次 `register` 抛
1717
+ * `tab type id … already registered` / `slot … already registered`。
1718
+ * cordis 会 rethrow effect 建立期的异常并中止整个 apply——那会让入口、设置页
1719
+ * 一起消失。这里把重复视为「已由存活实例注册」跳过并留痕(与 i18n 的幂等一致)。
1720
+ */
1721
+ function registerSafely(label, register) {
1722
+ try {
1723
+ const dispose = register();
1724
+ return typeof dispose === "function" ? dispose : () => {};
1725
+ } catch (error) {
1726
+ const message = error instanceof Error ? error.message : String(error);
1727
+ if (!/already registered|already has/i.test(message)) console.warn(`[dsh-service-console] ${label} failed:`, message);
1728
+ return () => {};
1729
+ }
1730
+ }
1731
+ /** 引导页卡片的图标:`ComponentType<IconProps>`(size/className),与 settings 图标不同型 */
1732
+ function ConsoleGlyph({ size = 16, className }) {
1733
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("svg", {
1734
+ viewBox: "0 0 16 16",
1735
+ width: size,
1736
+ height: size,
1737
+ className,
1738
+ "aria-hidden": "true",
1739
+ fill: "none",
1740
+ children: [
1741
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("rect", {
1742
+ x: 2.25,
1743
+ y: 3.25,
1744
+ width: 11.5,
1745
+ height: 8.5,
1746
+ rx: 2,
1747
+ stroke: "currentColor",
1748
+ strokeWidth: 1.3
1749
+ }),
1750
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", {
1751
+ d: "M5 6.25 6.9 7.75 5 9.25",
1752
+ stroke: "currentColor",
1753
+ strokeWidth: 1.3,
1754
+ strokeLinecap: "round",
1755
+ strokeLinejoin: "round"
1756
+ }),
1757
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", {
1758
+ d: "M8.4 9.25H11",
1759
+ stroke: "currentColor",
1760
+ strokeWidth: 1.3,
1761
+ strokeLinecap: "round"
1762
+ })
1763
+ ]
1764
+ });
1765
+ }
1766
+ /**
1767
+ * tab 内容体:会话 id 由框架的 inject face 注入(不读全局 mounted,后台会话也正确)。
1768
+ * `tab.visible` 是平台为「折叠 / 后台会话」提供的信号——不可见时停止扫描与轮询,
1769
+ * 否则隐藏的面板仍每 5s 打一次本机 lsof。
1770
+ */
1771
+ function ServiceConsoleBody({ t, sessionId, useTabInfo }) {
1772
+ const { tab } = useTabInfo();
1773
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ServiceConsoleTab, {
1774
+ t,
1775
+ sessionId,
1776
+ visible: tab.visible
1777
+ });
1778
+ }
1779
+ /** 标签标题:注册后语言切换即时生效(未注册则用开 tab 时捕获的文案) */
1780
+ function ServiceConsoleTitle({ t }) {
1781
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1782
+ "data-dsh-sc-title": true,
1783
+ children: t("panel.title")
1784
+ });
1785
+ }
1287
1786
  module.exports = {
1288
- inject: ["slots", "timer"],
1787
+ inject: [
1788
+ "slots",
1789
+ "timer",
1790
+ "locale",
1791
+ "sidebarRight",
1792
+ "sidebarRightTabs"
1793
+ ],
1289
1794
  apply(ctx) {
1290
1795
  bindTimer(ctx.timer);
1291
- attachLocale(ctx, NS, [["zh", ZH_DICT], ["en", EN_DICT]], (bound) => {
1292
- labelT = bound.t;
1293
- bindLocale(bound);
1796
+ bindDockTimer(ctx.timer);
1797
+ attachLocale(ctx, NS, {
1798
+ zh: ZH_DICT,
1799
+ en: EN_DICT
1800
+ }, (t) => {
1801
+ labelT = t;
1294
1802
  });
1295
- ctx.effect(() => ctx.slots.inject("conversation.session.header.utilities", () => ctx.slots.register({
1803
+ ctx.effect(() => {
1804
+ /** 当前屏幕上的 tab(无会话 / store 未 adopted 时返回 undefined,绝不抛) */
1805
+ const openTab = () => {
1806
+ try {
1807
+ const sessionId = ctx.sidebarRight.mounted.getSnapshot();
1808
+ if (sessionId === void 0) return void 0;
1809
+ const existing = ctx.sidebarRight.tabsIn(sessionId).find((tab) => tab.kind === TAB_KIND);
1810
+ return existing === void 0 ? void 0 : { id: existing.id };
1811
+ } catch {
1812
+ return;
1813
+ }
1814
+ };
1815
+ const open = () => {
1816
+ try {
1817
+ if (ctx.sidebarRight.mounted.getSnapshot() === void 0) return;
1818
+ ctx.sidebarRight.openTab(TAB_KIND);
1819
+ } catch (error) {
1820
+ console.warn("[dsh-service-console] open failed:", String(error));
1821
+ }
1822
+ };
1823
+ const toggle = () => {
1824
+ const existing = openTab();
1825
+ if (existing !== void 0) {
1826
+ try {
1827
+ ctx.sidebarRight.close(existing.id);
1828
+ } catch {}
1829
+ return;
1830
+ }
1831
+ open();
1832
+ };
1833
+ const close = () => {
1834
+ const existing = openTab();
1835
+ if (existing === void 0) return;
1836
+ try {
1837
+ ctx.sidebarRight.close(existing.id);
1838
+ } catch {}
1839
+ };
1840
+ window.addEventListener("dsh-service-console:open", open);
1841
+ window.addEventListener("dsh-service-console:close", close);
1842
+ window.addEventListener("dsh-service-console:toggle", toggle);
1843
+ return () => {
1844
+ window.removeEventListener("dsh-service-console:open", open);
1845
+ window.removeEventListener("dsh-service-console:close", close);
1846
+ window.removeEventListener("dsh-service-console:toggle", toggle);
1847
+ };
1848
+ });
1849
+ ctx.effect(() => registerSafely("tab type", () => ctx.sidebarRightTabs.register({
1850
+ id: TAB_ID,
1851
+ kind: TAB_KIND,
1852
+ priority: "extension",
1853
+ title: () => labelFn("panel.title"),
1854
+ guide: [{
1855
+ id: "open",
1856
+ order: 90,
1857
+ title: () => labelFn("panel.title"),
1858
+ description: () => labelFn("panel.subtitle"),
1859
+ icon: ConsoleGlyph
1860
+ }]
1861
+ })), "service-console: tab type");
1862
+ ctx.effect(() => registerSafely("tab body", () => ctx.slots.inject("sidebar.right.pane.tab", () => ctx.slots.register({
1863
+ name: "sidebar.right.pane.tab",
1864
+ key: TAB_ID,
1865
+ locale: NS,
1866
+ inject: (sessionId) => ({ sessionId: String(sessionId) })
1867
+ }, ServiceConsoleBody))), "service-console: tab body");
1868
+ ctx.effect(() => registerSafely("tab title", () => ctx.slots.inject("sidebar.right.pane.tab.title", () => ctx.slots.register({
1869
+ name: "sidebar.right.pane.tab.title",
1870
+ key: TAB_ID,
1871
+ locale: NS
1872
+ }, ServiceConsoleTitle))), "service-console: tab title");
1873
+ ctx.effect(() => registerSafely("header entry", () => ctx.slots.inject("conversation.session.header.utilities", () => ctx.slots.register({
1296
1874
  name: "conversation.session.header.utilities",
1297
1875
  id: "dsh-service-console",
1298
1876
  order: 25,
1299
- label: () => labelFn("plugin.name")
1300
- }, ServiceConsoleEntry)));
1301
- ctx.effect(() => ctx.slots.inject("shell.overlay", () => ctx.slots.register({
1302
- name: "shell.overlay",
1303
- id: "dsh-service-console-panel"
1304
- }, ServiceConsolePanel)));
1305
- ctx.effect(() => ctx.slots.inject("settings.section", () => ctx.slots.register({
1877
+ locale: NS,
1878
+ label: () => labelFn("plugin.name"),
1879
+ inject: () => ({ openConsole: () => {
1880
+ try {
1881
+ ctx.sidebarRight.openTab(TAB_KIND);
1882
+ } catch (error) {
1883
+ console.warn("[dsh-service-console] openTab failed:", String(error));
1884
+ }
1885
+ } })
1886
+ }, ServiceConsoleEntry))), "service-console: header entry");
1887
+ ctx.effect(() => registerSafely("settings section", () => ctx.slots.inject("settings.section", () => ctx.slots.register({
1306
1888
  name: "settings.section",
1307
1889
  id: "dsh-service-console",
1308
1890
  order: 35,
1891
+ locale: NS,
1309
1892
  label: () => labelFn("plugin.name")
1310
- }, ServiceConsoleSettings)));
1893
+ }, ServiceConsoleSettings))), "service-console: settings section");
1894
+ ctx.effect(() => registerSafely("service_list card", () => ctx.slots.inject("tool.call.toolview", () => ctx.slots.register({
1895
+ name: "tool.call.toolview",
1896
+ key: "service_list",
1897
+ locale: NS
1898
+ }, ServiceListCard))), "service-console: service_list card");
1899
+ ctx.effect(() => registerSafely("dock pill", () => ctx.slots.inject("conversation.composer.dock", () => ctx.slots.register({
1900
+ name: "conversation.composer.dock",
1901
+ id: "dsh-service-console",
1902
+ order: 40,
1903
+ locale: NS,
1904
+ inject: (sessionId) => ({ sessionId: String(sessionId) })
1905
+ }, ServiceDockPill))), "service-console: dock pill");
1906
+ ctx.effect(() => registerSafely("settings icon", () => ctx.slots.inject("settings.section.icon", () => ctx.slots.register({
1907
+ name: "settings.section.icon",
1908
+ id: "dsh-service-console"
1909
+ }, ServiceConsoleIcon))), "service-console: settings icon");
1311
1910
  }
1312
1911
  };
1313
1912
  return module.exports;