@jiyr0119/dsh-service-console 0.8.0 → 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.
package/lib/client.js CHANGED
@@ -29,109 +29,78 @@ window.__ModuleLoader__.load({
29
29
  let _deepseek_ai_dsh_client_ui_primitives = require("@deepseek-ai/dsh-client-ui-primitives");
30
30
  let react_jsx_runtime = require("react/jsx-runtime");
31
31
  // \0dsh-css:/home/runner/work/dsh-service-console/dsh-service-console/src/client/service-console.module.css.mjs
32
- 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}}";
33
- const tagId = "@jiyr0119/dsh-service-console/service-console.module.css";
34
- if (typeof document !== "undefined" && document.querySelector("style[data-plugin-css=" + JSON.stringify(tagId) + "]") === null) {
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) {
35
35
  const tag = document.createElement("style");
36
36
  tag.dataset.plugin = "@jiyr0119/dsh-service-console";
37
- tag.dataset.pluginCss = tagId;
38
- tag.textContent = css;
37
+ tag.dataset.pluginCss = tagId$1;
38
+ tag.textContent = css$1;
39
39
  document.head.appendChild(tag);
40
40
  }
41
41
  var service_console_module_css_default = {
42
- "evidenceItem": "PuSt5a_evidenceItem",
43
- "headerBtnOn": "PuSt5a_headerBtnOn",
44
- "segBtn": "PuSt5a_segBtn",
45
- "setSelect": "PuSt5a_setSelect",
46
- "starLabel": "PuSt5a_starLabel",
47
- "spin": "PuSt5a_spin",
42
+ "evidenceBlock": "PuSt5a_evidenceBlock",
43
+ "rowMain": "PuSt5a_rowMain",
44
+ "setNote": "PuSt5a_setNote",
45
+ "starInfo": "PuSt5a_starInfo",
46
+ "setPage": "PuSt5a_setPage",
47
+ "hintWarn": "PuSt5a_hintWarn",
48
+ "dockPillPorts": "PuSt5a_dockPillPorts",
49
+ "sc-spin": "PuSt5a_sc-spin",
50
+ "confirmTxt": "PuSt5a_confirmTxt",
51
+ "detailHead": "PuSt5a_detailHead",
52
+ "hintLine": "PuSt5a_hintLine",
53
+ "rowName": "PuSt5a_rowName",
54
+ "detailLabel": "PuSt5a_detailLabel",
48
55
  "okText": "PuSt5a_okText",
49
- "setLabel": "PuSt5a_setLabel",
50
- "rowDot": "PuSt5a_rowDot",
51
- "evidenceArrow": "PuSt5a_evidenceArrow",
52
- "confirmCancel": "PuSt5a_confirmCancel",
56
+ "errText": "PuSt5a_errText",
53
57
  "setRow": "PuSt5a_setRow",
54
- "filter": "PuSt5a_filter",
55
- "row": "PuSt5a_row",
56
- "setFooter": "PuSt5a_setFooter",
57
- "segBtnOn": "PuSt5a_segBtnOn",
58
- "noteWarn": "PuSt5a_noteWarn",
59
- "rowMeta": "PuSt5a_rowMeta",
60
- "headIco": "PuSt5a_headIco",
61
- "filterRow": "PuSt5a_filterRow",
62
- "confirmTxt": "PuSt5a_confirmTxt",
63
- "badge": "PuSt5a_badge",
58
+ "setSection": "PuSt5a_setSection",
64
59
  "setInfo": "PuSt5a_setInfo",
65
- "popup": "PuSt5a_popup",
66
- "setInput": "PuSt5a_setInput",
67
- "popupOn": "PuSt5a_popupOn",
68
- "sc-spin": "PuSt5a_sc-spin",
69
- "tabBody": "PuSt5a_tabBody",
70
- "hintLine": "PuSt5a_hintLine",
71
- "icoBtn": "PuSt5a_icoBtn",
72
- "tabOn": "PuSt5a_tabOn",
73
- "evidenceBlock": "PuSt5a_evidenceBlock",
74
- "switch": "PuSt5a_switch",
75
- "headerBtn": "PuSt5a_headerBtn",
76
- "filterClear": "PuSt5a_filterClear",
77
- "layer": "PuSt5a_layer",
78
- "confirmOk": "PuSt5a_confirmOk",
79
- "starInfo": "PuSt5a_starInfo",
80
- "rowSub": "PuSt5a_rowSub",
60
+ "setSelect": "PuSt5a_setSelect",
61
+ "prevBtn": "PuSt5a_prevBtn",
62
+ "detailBox": "PuSt5a_detailBox",
81
63
  "detailAccent": "PuSt5a_detailAccent",
64
+ "dockPill": "PuSt5a_dockPill",
65
+ "filter": "PuSt5a_filter",
66
+ "console": "PuSt5a_console",
67
+ "evidenceItem": "PuSt5a_evidenceItem",
68
+ "empty": "PuSt5a_empty",
69
+ "starLabel": "PuSt5a_starLabel",
70
+ "scroll": "PuSt5a_scroll",
82
71
  "noteErr": "PuSt5a_noteErr",
83
- "liveDot": "PuSt5a_liveDot",
84
- "note": "PuSt5a_note",
72
+ "setLabel": "PuSt5a_setLabel",
85
73
  "rowAct": "PuSt5a_rowAct",
86
- "segGroup": "PuSt5a_segGroup",
87
- "rowMain": "PuSt5a_rowMain",
88
- "rowBtn": "PuSt5a_rowBtn",
89
- "head": "PuSt5a_head",
90
- "empty": "PuSt5a_empty",
91
- "setSection": "PuSt5a_setSection",
92
- "tabInd": "PuSt5a_tabInd",
93
- "detailBox": "PuSt5a_detailBox",
74
+ "filterRow": "PuSt5a_filterRow",
75
+ "evidenceArrow": "PuSt5a_evidenceArrow",
76
+ "setInput": "PuSt5a_setInput",
77
+ "starSection": "PuSt5a_starSection",
78
+ "filterClear": "PuSt5a_filterClear",
94
79
  "spacer": "PuSt5a_spacer",
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",
95
91
  "detailGrid": "PuSt5a_detailGrid",
96
- "detailHead": "PuSt5a_detailHead",
97
- "prevBtn": "PuSt5a_prevBtn",
98
- "tab": "PuSt5a_tab",
99
- "starSection": "PuSt5a_starSection",
100
- "headTitle": "PuSt5a_headTitle",
101
- "setPage": "PuSt5a_setPage",
92
+ "note": "PuSt5a_note",
102
93
  "setCap": "PuSt5a_setCap",
103
- "detailLabel": "PuSt5a_detailLabel",
104
- "starRow": "PuSt5a_starRow",
105
- "errText": "PuSt5a_errText",
106
- "confirmRow": "PuSt5a_confirmRow",
107
- "tabs": "PuSt5a_tabs",
108
- "rowName": "PuSt5a_rowName",
109
- "hintWarn": "PuSt5a_hintWarn",
110
- "setNote": "PuSt5a_setNote",
111
- "starLink": "PuSt5a_starLink"
94
+ "headerBtn": "PuSt5a_headerBtn",
95
+ "rowSub": "PuSt5a_rowSub",
96
+ "spin": "PuSt5a_spin"
112
97
  };
113
- // src/client/ServiceConsole.tsx
98
+ // src/client/api.ts
114
99
  /**
115
- * dsh-service-console — 面板组件(原生包 v2)
116
- *
117
- * 架构对齐 dsh-service-console 的 rc.5 契约:
118
- * - i18n: 组件通过 slot 注册项的 `locale:` 选项拿到框架合成的 `t` seat
119
- * (`PropsLocale`,按 namespace 联合类型化;语言切换由渲染器按 locale revision
120
- * 重渲染 outlet,不再需要模块级 bind + 手动订阅)
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
- function bindTimer(t) {
126
- timerCtx = t;
127
- }
128
- /** 动态错误码 → 词典键(err.<CODE>);未收录的码回退 fallback */
129
- function trError(t, code, fallback) {
130
- if (!code) return fallback;
131
- const key = "err." + code;
132
- const s = t(key);
133
- return s === key ? fallback : s;
134
- }
135
104
  async function api(path, payload) {
136
105
  const res = await fetch("/dsh-sc/api/" + path, {
137
106
  method: "POST",
@@ -145,27 +114,15 @@ window.__ModuleLoader__.load({
145
114
  throw new Error("bad JSON HTTP " + res.status);
146
115
  }
147
116
  }
148
- const store = {
149
- open: false,
150
- sessionId: null,
151
- listeners: /* @__PURE__ */ new Set()
152
- };
153
- function subscribeOpen(fn) {
154
- store.listeners.add(fn);
155
- return () => {
156
- store.listeners.delete(fn);
157
- };
158
- }
159
- function setOpen(v) {
160
- store.open = v;
161
- store.listeners.forEach((l) => l(v));
162
- }
163
- function toggleOpen() {
164
- setOpen(!store.open);
165
- }
166
- function closePanel() {
167
- setOpen(false);
168
- }
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 共用,避免各写一份) */
169
126
  const OWNERSHIP_COLOR = {
170
127
  "conversation-confirmed": "var(--dsw-alias-state-success-primary, #4ade80)",
171
128
  "workspace-inferred": "var(--dsw-alias-state-warn-primary, #fbbf24)",
@@ -173,6 +130,21 @@ window.__ModuleLoader__.load({
173
130
  unknown: "var(--dsw-alias-state-error-primary, #f87171)",
174
131
  protected: "var(--dsw-alias-state-error-primary, #f87171)"
175
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
+ /** 归属 → 词典键 */
176
148
  const OWNERSHIP_KEY = {
177
149
  "conversation-confirmed": "own.conversation",
178
150
  "workspace-inferred": "own.workspace",
@@ -180,10 +152,180 @@ window.__ModuleLoader__.load({
180
152
  unknown: "own.unknown",
181
153
  protected: "own.protected"
182
154
  };
183
- /** API 字符串 → 归属级别(未知值降级为 unknown,不炸 UI) */
184
- function ownershipLevel(v) {
185
- 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;
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;
186
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
+ ];
187
329
  const SCOPE_KEY = {
188
330
  conversation: "scope.conversation",
189
331
  workspace: "scope.workspace",
@@ -196,45 +338,12 @@ window.__ModuleLoader__.load({
196
338
  showUnknown: true,
197
339
  forceKill: false
198
340
  };
199
- /**
200
- * rc.5 起每个 slot 渲染点都是 `[data-slot]` 的 `display: contents` 锚点
201
- * (`dsh-client-ui-renderer` 的 ANCHOR_STYLE)——它没有布局盒,
202
- * `getBoundingClientRect()` 全 0。必须量锚点里真正的元素子节点,
203
- * 否则面板恒落在 `top: 8px` 并压住会话 header。
204
- */
205
- function realBox(anchor) {
206
- if (anchor === null) return null;
207
- const candidate = anchor.firstElementChild ?? anchor;
208
- const rect = candidate.getBoundingClientRect();
209
- return rect.height > 0 || rect.width > 0 ? candidate : null;
210
- }
211
- function popupAnchors() {
212
- return {
213
- header: realBox(document.querySelector("[data-slot=\"conversation.session.header\"]")),
214
- composer: realBox(document.querySelector("[data-composer-card]"))
215
- };
216
- }
217
- function measurePopup() {
218
- const vh = window.innerHeight;
219
- const { header, composer } = popupAnchors();
220
- const top = header ? Math.round(header.getBoundingClientRect().bottom) + 8 : 48;
221
- const composerTop = composer ? Math.round(composer.getBoundingClientRect().top) - 8 : vh - 48;
222
- const bottomLimit = composerTop > top ? composerTop : vh - 48;
223
- return {
224
- top,
225
- height: Math.max(280, bottomLimit - top)
226
- };
227
- }
228
- function ServiceConsoleEntry({ t, sessionId }) {
229
- const [on, setOn] = react.useState(store.open);
230
- react.useEffect(() => subscribeOpen(setOn), []);
231
- react.useEffect(() => {
232
- store.sessionId = sessionId ?? null;
233
- }, [sessionId]);
341
+ function ServiceConsoleEntry({ t, openConsole }) {
234
342
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
235
343
  type: "button",
236
- className: service_console_module_css_default.headerBtn + (on ? " " + service_console_module_css_default.headerBtnOn : ""),
237
- onClick: toggleOpen,
344
+ className: service_console_module_css_default.headerBtn,
345
+ "data-dsh-sc": "entry",
346
+ onClick: openConsole,
238
347
  title: t("entry.tip"),
239
348
  "aria-label": t("entry.tip"),
240
349
  children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: t("entry.label") }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("svg", {
@@ -318,6 +427,7 @@ window.__ModuleLoader__.load({
318
427
  };
319
428
  if (!config) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
320
429
  className: service_console_module_css_default.setPage,
430
+ "data-dsh-sc": "settings",
321
431
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
322
432
  className: service_console_module_css_default.note,
323
433
  children: "Loading…"
@@ -325,6 +435,7 @@ window.__ModuleLoader__.load({
325
435
  });
326
436
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
327
437
  className: service_console_module_css_default.setPage,
438
+ "data-dsh-sc": "settings",
328
439
  children: [
329
440
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
330
441
  className: service_console_module_css_default.setSection,
@@ -407,12 +518,10 @@ window.__ModuleLoader__.load({
407
518
  className: service_console_module_css_default.setCap,
408
519
  children: tr("settings.showUnknown.desc")
409
520
  })]
410
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
411
- type: "button",
412
- role: "switch",
413
- "aria-checked": config.showUnknown,
414
- className: service_console_module_css_default.switch,
415
- 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 })
416
525
  })]
417
526
  }),
418
527
  /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
@@ -426,12 +535,10 @@ window.__ModuleLoader__.load({
426
535
  className: service_console_module_css_default.setCap,
427
536
  children: tr("settings.forceKill.desc")
428
537
  })]
429
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
430
- type: "button",
431
- role: "switch",
432
- "aria-checked": config.forceKill,
433
- className: service_console_module_css_default.switch,
434
- 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 })
435
542
  })]
436
543
  }),
437
544
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
@@ -469,16 +576,9 @@ window.__ModuleLoader__.load({
469
576
  ]
470
577
  });
471
578
  }
472
- function ServiceConsolePanel({ t }) {
579
+ function ServiceConsoleTab({ t, sessionId, visible }) {
473
580
  const tr = t;
474
- const [on, setOn] = react.useState(store.open);
475
- const [shown, setShown] = react.useState(false);
476
- const [closing, setClosing] = react.useState(false);
477
- const [rect, setRect] = react.useState({
478
- top: 48,
479
- height: 480
480
- });
481
- const [tab, setTab] = react.useState("services");
581
+ const idBase = react.useId();
482
582
  const [query, setQuery] = react.useState("");
483
583
  const [view, setView] = react.useState({
484
584
  phase: "idle",
@@ -501,51 +601,22 @@ window.__ModuleLoader__.load({
501
601
  const scopeTouched = react.useRef(false);
502
602
  const [pending, setPending] = react.useState(false);
503
603
  const timeoutRef = react.useRef(null);
504
- react.useEffect(() => subscribeOpen(setOn), []);
505
- react.useEffect(() => {
506
- if (on) {
507
- setClosing(false);
508
- setShown(false);
509
- const raf = requestAnimationFrame(() => setShown(true));
510
- return () => cancelAnimationFrame(raf);
511
- }
512
- setShown(false);
513
- setClosing(true);
514
- const t = setTimeout(() => setClosing(false), 200);
515
- return () => clearTimeout(t);
516
- }, [on]);
517
- react.useEffect(() => {
518
- const onKey = (e) => {
519
- if (e.key === "Escape") closePanel();
520
- };
521
- document.addEventListener("keydown", onKey);
522
- return () => document.removeEventListener("keydown", onKey);
523
- }, []);
524
- react.useEffect(() => {
525
- const update = () => setRect(measurePopup());
526
- update();
527
- const ro = new ResizeObserver(update);
528
- const { header, composer } = popupAnchors();
529
- if (header) ro.observe(header);
530
- if (composer) ro.observe(composer);
531
- window.addEventListener("resize", update);
532
- return () => {
533
- ro.disconnect();
534
- window.removeEventListener("resize", update);
535
- };
536
- }, []);
604
+ const focusAfter = (rowId) => {
605
+ requestAnimationFrame(() => {
606
+ document.getElementById(`${idBase}-detail-btn-${rowId}`)?.focus();
607
+ });
608
+ };
537
609
  react.useEffect(() => () => {
538
610
  timeoutRef.current?.();
539
611
  }, []);
540
612
  react.useEffect(() => {
541
- if (!on) return;
542
613
  api("config", {}).then((res) => {
543
614
  const c = res?.data?.config ?? null;
544
615
  if (!c) return;
545
616
  setConfig(c);
546
- if (!scopeTouched.current) setScope(c.defaultScope);
617
+ if (!scopeTouched.current) setScope(SCOPE_VALUES.includes(c.defaultScope) ? c.defaultScope : "workspace");
547
618
  }).catch(() => {});
548
- }, [on]);
619
+ }, []);
549
620
  const scan = react.useCallback(() => {
550
621
  const at = (/* @__PURE__ */ new Date()).toLocaleTimeString();
551
622
  setView((v) => ({
@@ -555,7 +626,7 @@ window.__ModuleLoader__.load({
555
626
  err: null
556
627
  }));
557
628
  timeoutRef.current?.();
558
- timeoutRef.current = timerCtx?.timeout(() => {
629
+ timeoutRef.current = timerCtx$1?.timeout(() => {
559
630
  setView((v) => v.phase === "scanning" ? {
560
631
  phase: "timeout",
561
632
  at,
@@ -563,7 +634,7 @@ window.__ModuleLoader__.load({
563
634
  err: "timeout"
564
635
  } : v);
565
636
  }, 8e3) ?? null;
566
- api("services/scan", { sessionId: store.sessionId ?? void 0 }).then((res) => {
637
+ api("services/scan", { sessionId }).then((res) => {
567
638
  timeoutRef.current?.();
568
639
  timeoutRef.current = null;
569
640
  setView({
@@ -582,29 +653,27 @@ window.__ModuleLoader__.load({
582
653
  err: String(e?.message || e)
583
654
  });
584
655
  });
585
- }, []);
656
+ }, [sessionId]);
586
657
  react.useEffect(() => {
587
- if (on && view.phase === "idle") scan();
658
+ if (visible && view.phase === "idle") scan();
588
659
  }, [
589
- on,
660
+ visible,
590
661
  scan,
591
662
  view.phase
592
663
  ]);
593
664
  react.useEffect(() => {
594
- if (!on || tab !== "services" || !config) return;
665
+ if (!config || !visible) return;
595
666
  if (!config.refreshInterval || view.phase === "scanning") return;
596
- const cancel = timerCtx?.timeout(() => scan(), config.refreshInterval);
667
+ const cancel = timerCtx$1?.timeout(() => scan(), config.refreshInterval);
597
668
  return () => {
598
669
  cancel?.();
599
670
  };
600
671
  }, [
601
- on,
602
- tab,
603
672
  config,
673
+ visible,
604
674
  view.phase,
605
675
  scan
606
676
  ]);
607
- if (!on && !closing) return null;
608
677
  const runAction = (svc, action) => {
609
678
  if (pending) return;
610
679
  setConfirming({
@@ -617,6 +686,7 @@ window.__ModuleLoader__.load({
617
686
  if (pending) return;
618
687
  setPending(true);
619
688
  setConfirming(null);
689
+ focusAfter(svc.id);
620
690
  api("services/" + action, { serviceId: svc.id }).then((res) => {
621
691
  let ok;
622
692
  let text;
@@ -657,37 +727,46 @@ window.__ModuleLoader__.load({
657
727
  const q = query.toLowerCase();
658
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)));
659
729
  }
660
- const servicesBody = /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
661
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
662
- className: service_console_module_css_default.filterRow,
663
- children: [
664
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
665
- className: service_console_module_css_default.segGroup,
666
- role: "group",
667
- "aria-label": tr("settings.defaultScope"),
668
- children: [
669
- "conversation",
670
- "workspace",
671
- "machine"
672
- ].map((s) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
673
- type: "button",
674
- className: service_console_module_css_default.segBtn + (scope === s ? " " + service_console_module_css_default.segBtnOn : ""),
675
- "aria-pressed": scope === s,
676
- onClick: () => {
677
- scopeTouched.current = true;
678
- setScope(s);
679
- },
680
- children: tr(SCOPE_KEY[s])
681
- }, s))
682
- }),
683
- /* @__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, {
684
763
  className: service_console_module_css_default.filter,
685
764
  type: "text",
686
765
  value: query,
766
+ "aria-label": tr("search.ph"),
687
767
  placeholder: tr("search.ph"),
688
768
  onChange: (e) => setQuery(e.target.value)
689
- }),
690
- query !== "" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
769
+ }), query !== "" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
691
770
  type: "button",
692
771
  className: service_console_module_css_default.filterClear,
693
772
  onClick: () => setQuery(""),
@@ -705,389 +784,700 @@ window.__ModuleLoader__.load({
705
784
  strokeLinecap: "round"
706
785
  })
707
786
  })
708
- }) : null
709
- ]
710
- }),
711
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
712
- className: service_console_module_css_default.hintLine,
713
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { className: service_console_module_css_default.liveDot }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
714
- className: scope === "machine" ? service_console_module_css_default.hintWarn : void 0,
715
- children: scope === "machine" ? "⚠ " + tr("scope.machineWarn") : tr("panel.subtitle")
716
- })]
717
- }),
718
- view.phase === "scanning" ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
719
- className: service_console_module_css_default.note,
720
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { className: service_console_module_css_default.spin }), tr("status.scanning")]
721
- }) : view.phase === "error" || view.phase === "timeout" ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
722
- className: service_console_module_css_default.noteErr,
723
- children: [
724
- tr("status.error"),
725
- ": ",
726
- view.err
727
- ]
728
- }) : null,
729
- (view.data?.partialWarnings ?? []).map((w, i) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
730
- className: service_console_module_css_default.noteWarn,
731
- children: ["⚠ ", w]
732
- }, `w${i}`)),
733
- rows.length === 0 && view.phase === "done" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
734
- className: service_console_module_css_default.empty,
735
- children: tr("svc.noSvc")
736
- }) : rows.map((svc) => {
737
- const level = ownershipLevel(svc.ownership);
738
- const badgeColor = OWNERSHIP_COLOR[level];
739
- const badgeKey = OWNERSHIP_KEY[level];
740
- const ports = svc.listeners.map((l) => String(l.port)).join(", ");
741
- const url = svc.listeners.map((l) => l.url).filter(Boolean)[0] ?? null;
742
- const canControl = !svc.protected;
743
- const isConfirming = confirming?.id === svc.id;
744
- const result = opResult?.id === svc.id ? opResult : null;
745
- return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
746
- 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",
747
802
  children: [
748
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
749
- className: service_console_module_css_default.rowMain,
750
- children: [
751
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
752
- className: service_console_module_css_default.rowDot,
753
- style: { color: badgeColor },
754
- children: "●"
755
- }),
756
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
757
- className: service_console_module_css_default.rowName,
758
- children: svc.name
759
- }),
760
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
761
- className: service_console_module_css_default.rowMeta,
762
- children: [
763
- ":",
764
- ports,
765
- " · pid ",
766
- svc.pid
767
- ]
768
- }),
769
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
770
- className: service_console_module_css_default.badge,
771
- style: { color: badgeColor },
772
- children: tr(badgeKey)
773
- }),
774
- svc.restartable ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
775
- className: service_console_module_css_default.badge,
776
- style: { color: "var(--dsw-alias-state-success-primary, #4ade80)" },
777
- children: "↻"
778
- }) : null,
779
- url ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("a", {
780
- className: service_console_module_css_default.rowAct,
781
- href: url,
782
- target: "_blank",
783
- rel: "noreferrer",
784
- title: url,
785
- onClick: (e) => e.stopPropagation(),
786
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("svg", {
787
- viewBox: "0 0 16 16",
788
- width: 12,
789
- height: 12,
790
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", {
791
- 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",
792
- fill: "none",
793
- stroke: "currentColor",
794
- strokeWidth: 1.3,
795
- strokeLinecap: "round",
796
- strokeLinejoin: "round"
797
- })
798
- })
799
- }) : null,
800
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { className: service_console_module_css_default.spacer }),
801
- canControl ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
802
- type: "button",
803
- className: service_console_module_css_default.rowBtn,
804
- onClick: (e) => {
805
- e.stopPropagation();
806
- runAction(svc, "stop");
807
- },
808
- children: isConfirming && confirming.action === "stop" ? tr("confirm.stop") : tr("action.stop")
809
- }) : null,
810
- svc.restartable && canControl ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
811
- type: "button",
812
- className: service_console_module_css_default.rowBtn,
813
- onClick: (e) => {
814
- e.stopPropagation();
815
- runAction(svc, "restart");
816
- },
817
- children: isConfirming && confirming.action === "restart" ? tr("confirm.restart") : tr("action.restart")
818
- }) : null,
819
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
820
- type: "button",
821
- className: service_console_module_css_default.rowBtn,
822
- onClick: (e) => {
823
- e.stopPropagation();
824
- setExpanded(expanded === svc.id ? null : svc.id);
825
- },
826
- children: expanded === svc.id ? "▾" : tr("action.detail")
827
- })
828
- ]
829
- }),
830
803
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
831
- className: service_console_module_css_default.rowSub,
832
- 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
833
817
  }),
834
- svc.cwd ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
835
- className: service_console_module_css_default.rowSub,
836
- children: svc.cwd
837
- }) : null,
838
- result ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
839
- className: result.ok ? service_console_module_css_default.okText : service_console_module_css_default.errText,
840
- children: [result.ok ? "✅ " : "⛔ ", result.text]
841
- }) : null,
842
- isConfirming ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
843
- className: service_console_module_css_default.confirmRow,
844
- children: [
845
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
846
- className: service_console_module_css_default.confirmTxt,
847
- children: tr("confirm.txt", {
848
- name: svc.name,
849
- pid: String(svc.pid),
850
- action: confirming.action === "stop" ? tr("action.stop") : tr("action.restart")
851
- })
852
- }),
853
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
854
- type: "button",
855
- className: service_console_module_css_default.confirmOk,
856
- disabled: pending,
857
- onClick: () => confirmAction(svc, confirming.action),
858
- children: pending ? tr("action.pending") : tr("action.confirm")
859
- }),
860
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
861
- type: "button",
862
- className: service_console_module_css_default.confirmCancel,
863
- onClick: () => setConfirming(null),
864
- children: tr("action.cancel")
865
- })
866
- ]
867
- }) : null,
868
- expanded === svc.id ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
869
- className: service_console_module_css_default.detailBox,
870
- role: "region",
871
- "aria-label": tr("detail.title"),
872
- children: [
873
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
874
- className: service_console_module_css_default.detailHead,
875
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: tr("detail.title") }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
876
- className: service_console_module_css_default.detailAccent,
877
- children: tr("detail.serviceRecord")
878
- })]
879
- }),
880
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
881
- className: service_console_module_css_default.detailGrid,
882
- children: [
883
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
884
- className: service_console_module_css_default.detailLabel,
885
- children: tr("detail.serviceId")
886
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("code", { children: svc.id })] }),
887
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
888
- className: service_console_module_css_default.detailLabel,
889
- children: tr("detail.process")
890
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("code", { children: [
891
- "PID ",
892
- svc.pid,
893
- " · PGID ",
894
- String(svc.processGroupId ?? "-")
895
- ] })] }),
896
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
897
- className: service_console_module_css_default.detailLabel,
898
- children: tr("detail.parent")
899
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("code", { children: ["PPID ", String(svc.parentPid ?? "-")] })] }),
900
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
901
- className: service_console_module_css_default.detailLabel,
902
- children: tr("detail.started")
903
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("code", { children: String(svc.startedAt ?? "-") })] })
904
- ]
905
- }),
906
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
907
- className: service_console_module_css_default.evidenceBlock,
908
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
909
- className: service_console_module_css_default.detailLabel,
910
- children: tr("detail.evidence")
911
- }), svc.ownershipEvidence.length ? svc.ownershipEvidence.map((ev, i) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
912
- className: service_console_module_css_default.evidenceItem,
913
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
914
- className: service_console_module_css_default.evidenceArrow,
915
- children: "↳"
916
- }), ev]
917
- }, 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", {
918
928
  className: service_console_module_css_default.rowSub,
919
- children: "—"
920
- })]
921
- })
922
- ]
923
- }) : 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
+ })
924
1035
  ]
925
- }, 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
+ })
926
1065
  })
927
- ] });
928
- const settingsBody = /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ServiceConsoleSettings, {
929
- t: tr,
930
- onSaved: setConfig
931
1066
  });
932
- return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
933
- className: service_console_module_css_default.layer,
934
- children: [toast ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Toast, {
935
- text: toast.text,
936
- tone: toast.tone,
937
- onDone: () => setToast(null)
938
- }, toast.seq) : null, /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
939
- className: service_console_module_css_default.popup + (shown ? " " + service_console_module_css_default.popupOn : ""),
940
- "data-window-drag-exclude": true,
941
- style: {
942
- top: rect.top,
943
- height: rect.height
944
- },
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",
945
1222
  children: [
946
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
947
- className: service_console_module_css_default.head,
948
- children: [
949
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
950
- className: service_console_module_css_default.headIco,
951
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("svg", {
952
- viewBox: "0 0 16 16",
953
- width: 17,
954
- height: 17,
955
- "aria-hidden": "true",
956
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("rect", {
957
- x: 2,
958
- y: 3,
959
- width: 12,
960
- height: 10,
961
- rx: 1.5,
962
- fill: "none",
963
- stroke: "currentColor",
964
- strokeWidth: 1.3
965
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", {
966
- d: "M5 7h6M5 10h4",
967
- stroke: "currentColor",
968
- strokeWidth: 1.2,
969
- strokeLinecap: "round"
970
- })]
971
- })
972
- }),
973
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
974
- className: service_console_module_css_default.headTitle,
975
- children: tr("panel.title")
976
- }),
977
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
978
- type: "button",
979
- className: service_console_module_css_default.icoBtn,
980
- onClick: scan,
981
- title: tr("status.lastScan"),
982
- "aria-label": tr("status.lastScan"),
983
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("svg", {
984
- viewBox: "0 0 16 16",
985
- width: 14,
986
- height: 14,
987
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", {
988
- d: "M13.5 8a5.5 5.5 0 1 1-1.61-3.89M13.5 1.5v3h-3",
989
- fill: "none",
990
- stroke: "currentColor",
991
- strokeWidth: 1.5,
992
- strokeLinecap: "round"
993
- })
994
- })
995
- }),
996
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
997
- type: "button",
998
- className: service_console_module_css_default.icoBtn,
999
- onClick: closePanel,
1000
- title: tr("action.cancel"),
1001
- "aria-label": tr("action.cancel"),
1002
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("svg", {
1003
- viewBox: "0 0 16 16",
1004
- width: 14,
1005
- height: 14,
1006
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", {
1007
- d: "M4 4l8 8M12 4l-8 8",
1008
- fill: "none",
1009
- stroke: "currentColor",
1010
- strokeWidth: 1.5,
1011
- strokeLinecap: "round"
1012
- })
1013
- })
1014
- })
1015
- ]
1223
+ toastNode,
1224
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
1225
+ className: service_list_card_module_css_default.summary,
1226
+ children: t("status.error")
1016
1227
  }),
1017
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1018
- className: service_console_module_css_default.tabs,
1019
- role: "tablist",
1020
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
1021
- type: "button",
1022
- role: "tab",
1023
- "aria-selected": tab === "services",
1024
- className: service_console_module_css_default.tab + (tab === "services" ? " " + service_console_module_css_default.tabOn : ""),
1025
- onClick: () => setTab("services"),
1026
- children: [
1027
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("svg", {
1028
- viewBox: "0 0 16 16",
1029
- width: 13,
1030
- height: 13,
1031
- "aria-hidden": "true",
1032
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("rect", {
1033
- x: 2,
1034
- y: 3,
1035
- width: 12,
1036
- height: 10,
1037
- rx: 1.5,
1038
- fill: "none",
1039
- stroke: "currentColor",
1040
- strokeWidth: 1.3
1041
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", {
1042
- d: "M5 7h6M5 10h4",
1043
- stroke: "currentColor",
1044
- strokeWidth: 1.2,
1045
- strokeLinecap: "round"
1046
- })]
1047
- }),
1048
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: tr("tab.services") }),
1049
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { className: service_console_module_css_default.tabInd })
1050
- ]
1051
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
1052
- type: "button",
1053
- role: "tab",
1054
- "aria-selected": tab === "settings",
1055
- className: service_console_module_css_default.tab + (tab === "settings" ? " " + service_console_module_css_default.tabOn : ""),
1056
- 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,
1057
1304
  children: [
1058
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("svg", {
1059
- viewBox: "0 0 16 16",
1060
- width: 13,
1061
- height: 13,
1062
- "aria-hidden": "true",
1063
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("circle", {
1064
- cx: 8,
1065
- cy: 8,
1066
- r: 2.5,
1067
- fill: "none",
1068
- stroke: "currentColor",
1069
- strokeWidth: 1.3
1070
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", {
1071
- 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",
1072
- fill: "none",
1073
- stroke: "currentColor",
1074
- strokeWidth: 1.2,
1075
- strokeLinecap: "round"
1076
- })]
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
+ ]
1077
1365
  }),
1078
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: tr("tab.settings") }),
1079
- /* @__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
+ })
1080
1395
  ]
1081
- })]
1396
+ }, row.id);
1082
1397
  }),
1083
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
1084
- className: service_console_module_css_default.tabBody,
1085
- children: tab === "services" ? servicesBody : settingsBody
1086
- })
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
1087
1402
  ]
1088
1403
  })]
1089
1404
  });
1090
1405
  }
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
+ }
1091
1481
  // src/client/i18n.ts
1092
1482
  /**
1093
1483
  * 幂等注册词典:单次对象式注册;已由先前装载注册(`already has locale`)视为
@@ -1157,6 +1547,12 @@ window.__ModuleLoader__.load({
1157
1547
  "status.lastScan": "最近扫描",
1158
1548
  "status.error": "扫描失败",
1159
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": "打开服务控制台",
1160
1556
  "svc.ports": "端口",
1161
1557
  "svc.pid": "pid",
1162
1558
  "svc.command": "命令",
@@ -1164,6 +1560,7 @@ window.__ModuleLoader__.load({
1164
1560
  "action.stop": "停止",
1165
1561
  "action.restart": "重启",
1166
1562
  "action.detail": "详情",
1563
+ "action.open": "打开",
1167
1564
  "action.confirm": "确认",
1168
1565
  "action.cancel": "取消",
1169
1566
  "action.pending": "处理中…",
@@ -1178,6 +1575,7 @@ window.__ModuleLoader__.load({
1178
1575
  "own.other": "本机其他",
1179
1576
  "own.unknown": "未知",
1180
1577
  "own.protected": "受保护",
1578
+ "scope.filter": "服务范围",
1181
1579
  "scope.conversation": "本次对话",
1182
1580
  "scope.workspace": "当前工作区",
1183
1581
  "scope.machine": "本机",
@@ -1232,6 +1630,12 @@ window.__ModuleLoader__.load({
1232
1630
  "status.lastScan": "Last scan",
1233
1631
  "status.error": "Scan failed",
1234
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",
1235
1639
  "svc.ports": "Ports",
1236
1640
  "svc.pid": "pid",
1237
1641
  "svc.command": "Command",
@@ -1239,6 +1643,7 @@ window.__ModuleLoader__.load({
1239
1643
  "action.stop": "Stop",
1240
1644
  "action.restart": "Restart",
1241
1645
  "action.detail": "Detail",
1646
+ "action.open": "Open",
1242
1647
  "action.confirm": "OK",
1243
1648
  "action.cancel": "Cancel",
1244
1649
  "action.pending": "Working…",
@@ -1253,6 +1658,7 @@ window.__ModuleLoader__.load({
1253
1658
  "own.other": "Other local",
1254
1659
  "own.unknown": "Unknown",
1255
1660
  "own.protected": "Protected",
1661
+ "scope.filter": "Service scope",
1256
1662
  "scope.conversation": "This chat",
1257
1663
  "scope.workspace": "Workspace",
1258
1664
  "scope.machine": "This machine",
@@ -1296,44 +1702,211 @@ window.__ModuleLoader__.load({
1296
1702
  "star.cta": "★ Give a Star"
1297
1703
  };
1298
1704
  // src/client/index.tsx
1705
+ /** 词典命名空间(与 LocaleNamespaceMap 合并、各注册项的 `locale:` 一致) */
1299
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";
1300
1711
  let labelT = null;
1301
1712
  function labelFn(key) {
1302
1713
  return labelT ? labelT(key) : key;
1303
1714
  }
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
+ }
1304
1786
  module.exports = {
1305
- inject: ["slots", "timer"],
1787
+ inject: [
1788
+ "slots",
1789
+ "timer",
1790
+ "locale",
1791
+ "sidebarRight",
1792
+ "sidebarRightTabs"
1793
+ ],
1306
1794
  apply(ctx) {
1307
1795
  bindTimer(ctx.timer);
1796
+ bindDockTimer(ctx.timer);
1308
1797
  attachLocale(ctx, NS, {
1309
1798
  zh: ZH_DICT,
1310
1799
  en: EN_DICT
1311
1800
  }, (t) => {
1312
1801
  labelT = t;
1313
1802
  });
1314
- 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({
1315
1874
  name: "conversation.session.header.utilities",
1316
1875
  id: "dsh-service-console",
1317
1876
  order: 25,
1318
1877
  locale: NS,
1319
- label: () => labelFn("plugin.name")
1320
- }, ServiceConsoleEntry)));
1321
- ctx.effect(() => ctx.slots.inject("shell.overlay", () => ctx.slots.register({
1322
- name: "shell.overlay",
1323
- id: "dsh-service-console-panel",
1324
- locale: NS
1325
- }, ServiceConsolePanel)));
1326
- ctx.effect(() => ctx.slots.inject("settings.section", () => ctx.slots.register({
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({
1327
1888
  name: "settings.section",
1328
1889
  id: "dsh-service-console",
1329
1890
  order: 35,
1330
1891
  locale: NS,
1331
1892
  label: () => labelFn("plugin.name")
1332
- }, ServiceConsoleSettings)));
1333
- ctx.effect(() => ctx.slots.inject("settings.section.icon", () => ctx.slots.register({
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({
1334
1907
  name: "settings.section.icon",
1335
1908
  id: "dsh-service-console"
1336
- }, ServiceConsoleIcon)));
1909
+ }, ServiceConsoleIcon))), "service-console: settings icon");
1337
1910
  }
1338
1911
  };
1339
1912
  return module.exports;