@jiyr0119/dsh-service-console 0.8.0 → 0.10.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",
48
- "okText": "PuSt5a_okText",
49
- "setLabel": "PuSt5a_setLabel",
42
+ "setNote": "PuSt5a_setNote",
43
+ "toolbar": "PuSt5a_toolbar",
44
+ "errText": "PuSt5a_errText",
45
+ "dockPillPorts": "PuSt5a_dockPillPorts",
50
46
  "rowDot": "PuSt5a_rowDot",
47
+ "rowName": "PuSt5a_rowName",
48
+ "detailBox": "PuSt5a_detailBox",
49
+ "detailGrid": "PuSt5a_detailGrid",
51
50
  "evidenceArrow": "PuSt5a_evidenceArrow",
52
- "confirmCancel": "PuSt5a_confirmCancel",
53
- "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",
64
- "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",
51
+ "console": "PuSt5a_console",
52
+ "okText": "PuSt5a_okText",
53
+ "setPage": "PuSt5a_setPage",
70
54
  "hintLine": "PuSt5a_hintLine",
71
- "icoBtn": "PuSt5a_icoBtn",
72
- "tabOn": "PuSt5a_tabOn",
73
- "evidenceBlock": "PuSt5a_evidenceBlock",
74
- "switch": "PuSt5a_switch",
75
- "headerBtn": "PuSt5a_headerBtn",
55
+ "sc-spin": "PuSt5a_sc-spin",
76
56
  "filterClear": "PuSt5a_filterClear",
77
- "layer": "PuSt5a_layer",
78
- "confirmOk": "PuSt5a_confirmOk",
79
- "starInfo": "PuSt5a_starInfo",
80
57
  "rowSub": "PuSt5a_rowSub",
81
- "detailAccent": "PuSt5a_detailAccent",
82
- "noteErr": "PuSt5a_noteErr",
83
- "liveDot": "PuSt5a_liveDot",
84
- "note": "PuSt5a_note",
58
+ "hintWarn": "PuSt5a_hintWarn",
59
+ "icoBtn": "PuSt5a_icoBtn",
85
60
  "rowAct": "PuSt5a_rowAct",
86
- "segGroup": "PuSt5a_segGroup",
87
- "rowMain": "PuSt5a_rowMain",
88
- "rowBtn": "PuSt5a_rowBtn",
89
- "head": "PuSt5a_head",
90
- "empty": "PuSt5a_empty",
61
+ "confirmTxt": "PuSt5a_confirmTxt",
62
+ "detailAccent": "PuSt5a_detailAccent",
63
+ "evidenceItem": "PuSt5a_evidenceItem",
91
64
  "setSection": "PuSt5a_setSection",
92
- "tabInd": "PuSt5a_tabInd",
93
- "detailBox": "PuSt5a_detailBox",
65
+ "setRow": "PuSt5a_setRow",
66
+ "noteWarn": "PuSt5a_noteWarn",
67
+ "setSelect": "PuSt5a_setSelect",
68
+ "setFooter": "PuSt5a_setFooter",
69
+ "starSection": "PuSt5a_starSection",
70
+ "starLabel": "PuSt5a_starLabel",
71
+ "scroll": "PuSt5a_scroll",
72
+ "rowBtn": "PuSt5a_rowBtn",
73
+ "spin": "PuSt5a_spin",
94
74
  "spacer": "PuSt5a_spacer",
95
- "detailGrid": "PuSt5a_detailGrid",
75
+ "filterRow": "PuSt5a_filterRow",
76
+ "setInfo": "PuSt5a_setInfo",
77
+ "filter": "PuSt5a_filter",
78
+ "starLink": "PuSt5a_starLink",
96
79
  "detailHead": "PuSt5a_detailHead",
80
+ "rowMain": "PuSt5a_rowMain",
81
+ "empty": "PuSt5a_empty",
82
+ "confirmRow": "PuSt5a_confirmRow",
83
+ "dockPill": "PuSt5a_dockPill",
84
+ "rowMeta": "PuSt5a_rowMeta",
85
+ "note": "PuSt5a_note",
86
+ "row": "PuSt5a_row",
87
+ "headerBtn": "PuSt5a_headerBtn",
88
+ "detailLabel": "PuSt5a_detailLabel",
89
+ "evidenceBlock": "PuSt5a_evidenceBlock",
97
90
  "prevBtn": "PuSt5a_prevBtn",
98
- "tab": "PuSt5a_tab",
99
- "starSection": "PuSt5a_starSection",
100
- "headTitle": "PuSt5a_headTitle",
101
- "setPage": "PuSt5a_setPage",
91
+ "setInput": "PuSt5a_setInput",
102
92
  "setCap": "PuSt5a_setCap",
103
- "detailLabel": "PuSt5a_detailLabel",
104
93
  "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
+ "starInfo": "PuSt5a_starInfo",
95
+ "setLabel": "PuSt5a_setLabel",
96
+ "noteErr": "PuSt5a_noteErr"
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;
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;
186
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,9 +634,19 @@ 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;
640
+ if (res?.ok === false) {
641
+ const code = res.error?.code ?? "";
642
+ setView({
643
+ phase: "error",
644
+ at,
645
+ data: null,
646
+ err: trError(tr, code, res.error?.message ?? tr("status.error"))
647
+ });
648
+ return;
649
+ }
569
650
  setView({
570
651
  phase: "done",
571
652
  at,
@@ -582,29 +663,27 @@ window.__ModuleLoader__.load({
582
663
  err: String(e?.message || e)
583
664
  });
584
665
  });
585
- }, []);
666
+ }, [sessionId]);
586
667
  react.useEffect(() => {
587
- if (on && view.phase === "idle") scan();
668
+ if (visible && view.phase === "idle") scan();
588
669
  }, [
589
- on,
670
+ visible,
590
671
  scan,
591
672
  view.phase
592
673
  ]);
593
674
  react.useEffect(() => {
594
- if (!on || tab !== "services" || !config) return;
675
+ if (!config || !visible) return;
595
676
  if (!config.refreshInterval || view.phase === "scanning") return;
596
- const cancel = timerCtx?.timeout(() => scan(), config.refreshInterval);
677
+ const cancel = timerCtx$1?.timeout(() => scan(), config.refreshInterval);
597
678
  return () => {
598
679
  cancel?.();
599
680
  };
600
681
  }, [
601
- on,
602
- tab,
603
682
  config,
683
+ visible,
604
684
  view.phase,
605
685
  scan
606
686
  ]);
607
- if (!on && !closing) return null;
608
687
  const runAction = (svc, action) => {
609
688
  if (pending) return;
610
689
  setConfirming({
@@ -617,6 +696,7 @@ window.__ModuleLoader__.load({
617
696
  if (pending) return;
618
697
  setPending(true);
619
698
  setConfirming(null);
699
+ focusAfter(svc.id);
620
700
  api("services/" + action, { serviceId: svc.id }).then((res) => {
621
701
  let ok;
622
702
  let text;
@@ -657,37 +737,46 @@ window.__ModuleLoader__.load({
657
737
  const q = query.toLowerCase();
658
738
  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
739
  }
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", {
740
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
741
+ className: service_console_module_css_default.console,
742
+ "data-dsh-sc": "panel",
743
+ "data-dsh-sc-phase": view.phase,
744
+ "data-dsh-sc-session": sessionId,
745
+ children: [
746
+ toast ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Toast, {
747
+ text: toast.text,
748
+ tone: toast.tone,
749
+ onDone: () => setToast(null)
750
+ }, toast.seq) : null,
751
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
752
+ className: service_console_module_css_default.toolbar,
753
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.SegmentedControl, {
754
+ id: idBase + "-scope",
755
+ label: tr("scope.filter"),
756
+ value: scope,
757
+ options: SCOPE_VALUES.map((s) => ({
758
+ value: s,
759
+ label: tr(SCOPE_KEY[s])
760
+ })),
761
+ onChange: (next) => {
762
+ scopeTouched.current = true;
763
+ setScope(next);
764
+ }
765
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ButtonRefresh, {
766
+ t: tr,
767
+ onClick: scan
768
+ })]
769
+ }),
770
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
771
+ className: service_console_module_css_default.filterRow,
772
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Input, {
684
773
  className: service_console_module_css_default.filter,
685
774
  type: "text",
686
775
  value: query,
776
+ "aria-label": tr("search.ph"),
687
777
  placeholder: tr("search.ph"),
688
778
  onChange: (e) => setQuery(e.target.value)
689
- }),
690
- query !== "" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
779
+ }), query !== "" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
691
780
  type: "button",
692
781
  className: service_console_module_css_default.filterClear,
693
782
  onClick: () => setQuery(""),
@@ -705,389 +794,704 @@ window.__ModuleLoader__.load({
705
794
  strokeLinecap: "round"
706
795
  })
707
796
  })
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,
797
+ }) : null]
798
+ }),
799
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
800
+ className: service_console_module_css_default.hintLine,
801
+ 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", {
802
+ className: scope === "machine" ? service_console_module_css_default.hintWarn : void 0,
803
+ children: scope === "machine" ? "⚠ " + tr("scope.machineWarn") : tr("panel.subtitle")
804
+ })]
805
+ }),
806
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
807
+ id: idBase + "-scope-" + scope + "-panel",
808
+ role: "tabpanel",
809
+ "aria-labelledby": idBase + "-scope-" + scope,
810
+ className: service_console_module_css_default.scroll,
811
+ "aria-busy": view.phase === "scanning",
747
812
  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
813
  /* @__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 ? "…" : "")
814
+ role: "status",
815
+ "aria-live": "polite",
816
+ children: view.phase === "scanning" ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
817
+ className: service_console_module_css_default.note,
818
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { className: service_console_module_css_default.spin }), tr("status.scanning")]
819
+ }) : view.phase === "error" || view.phase === "timeout" ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
820
+ className: service_console_module_css_default.noteErr,
821
+ children: [
822
+ tr("status.error"),
823
+ ": ",
824
+ view.err
825
+ ]
826
+ }) : null
833
827
  }),
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", {
828
+ (view.data?.partialWarnings ?? []).map((w, i) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
829
+ className: service_console_module_css_default.noteWarn,
830
+ children: ["⚠ ", w]
831
+ }, `w${i}`)),
832
+ rows.length === 0 && view.phase === "done" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
833
+ className: service_console_module_css_default.empty,
834
+ children: tr("svc.noSvc")
835
+ }) : rows.map((svc) => {
836
+ const level = ownershipLevel(svc.ownership);
837
+ const badgeColor = OWNERSHIP_COLOR[level];
838
+ const badgeKey = OWNERSHIP_KEY[level];
839
+ const ports = svc.listeners.map((l) => String(l.port)).join(", ");
840
+ const url = svc.listeners.map((l) => l.url).filter(Boolean)[0] ?? null;
841
+ const canControl = !svc.protected;
842
+ const isConfirming = confirming?.id === svc.id;
843
+ const result = opResult?.id === svc.id ? opResult : null;
844
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
845
+ className: service_console_module_css_default.row,
846
+ "data-dsh-sc": "row",
847
+ "data-dsh-sc-ownership": level,
848
+ "data-dsh-sc-ports": ports,
849
+ children: [
850
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
851
+ className: service_console_module_css_default.rowMain,
852
+ children: [
853
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
854
+ className: service_console_module_css_default.rowDot,
855
+ style: { color: badgeColor },
856
+ "aria-hidden": "true",
857
+ children: "●"
858
+ }),
859
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
860
+ className: service_console_module_css_default.rowName,
861
+ children: svc.name
862
+ }),
863
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
864
+ className: service_console_module_css_default.rowMeta,
865
+ children: [
866
+ ":",
867
+ ports,
868
+ " · pid ",
869
+ svc.pid
870
+ ]
871
+ }),
872
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Tag, {
873
+ tone: OWNERSHIP_TONE[level],
874
+ children: tr(badgeKey)
875
+ }),
876
+ svc.restartable ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Tag, {
877
+ tone: "success",
878
+ children: tr("svc.restartable")
879
+ }) : null,
880
+ url ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("a", {
881
+ className: service_console_module_css_default.rowAct,
882
+ href: url,
883
+ target: "_blank",
884
+ rel: "noreferrer",
885
+ title: url,
886
+ onClick: (e) => e.stopPropagation(),
887
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("svg", {
888
+ viewBox: "0 0 16 16",
889
+ width: 12,
890
+ height: 12,
891
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", {
892
+ 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",
893
+ fill: "none",
894
+ stroke: "currentColor",
895
+ strokeWidth: 1.3,
896
+ strokeLinecap: "round",
897
+ strokeLinejoin: "round"
898
+ })
899
+ })
900
+ }) : null,
901
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { className: service_console_module_css_default.spacer }),
902
+ canControl ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
903
+ type: "button",
904
+ className: service_console_module_css_default.rowBtn,
905
+ "aria-label": tr("action.stop") + " " + svc.name,
906
+ onClick: (e) => {
907
+ e.stopPropagation();
908
+ runAction(svc, "stop");
909
+ },
910
+ children: isConfirming && confirming.action === "stop" ? tr("confirm.stop") : tr("action.stop")
911
+ }) : null,
912
+ svc.restartable && canControl ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
913
+ type: "button",
914
+ className: service_console_module_css_default.rowBtn,
915
+ "aria-label": tr("action.restart") + " " + svc.name,
916
+ onClick: (e) => {
917
+ e.stopPropagation();
918
+ runAction(svc, "restart");
919
+ },
920
+ children: isConfirming && confirming.action === "restart" ? tr("confirm.restart") : tr("action.restart")
921
+ }) : null,
922
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
923
+ type: "button",
924
+ className: service_console_module_css_default.rowBtn,
925
+ id: idBase + "-detail-btn-" + svc.id,
926
+ "aria-expanded": expanded === svc.id,
927
+ "aria-controls": idBase + "-detail-" + svc.id,
928
+ "aria-label": tr("action.detail") + " " + svc.name,
929
+ onClick: (e) => {
930
+ e.stopPropagation();
931
+ setExpanded(expanded === svc.id ? null : svc.id);
932
+ },
933
+ children: expanded === svc.id ? "▾" : tr("action.detail")
934
+ })
935
+ ]
936
+ }),
937
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
918
938
  className: service_console_module_css_default.rowSub,
919
- children: "—"
920
- })]
921
- })
922
- ]
923
- }) : null
939
+ children: (svc.commandSummary ? svc.commandSummary.slice(0, 100) : "(?)") + (svc.commandSummary && svc.commandSummary.length > 100 ? "…" : "")
940
+ }),
941
+ svc.cwd ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
942
+ className: service_console_module_css_default.rowSub,
943
+ children: svc.cwd
944
+ }) : null,
945
+ result ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
946
+ className: result.ok ? service_console_module_css_default.okText : service_console_module_css_default.errText,
947
+ children: [result.ok ? "✅ " : "⛔ ", result.text]
948
+ }) : null,
949
+ isConfirming ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
950
+ className: service_console_module_css_default.confirmRow,
951
+ role: "group",
952
+ "aria-label": tr("confirm.txt", {
953
+ name: svc.name,
954
+ pid: String(svc.pid),
955
+ action: confirming.action === "stop" ? tr("action.stop") : tr("action.restart")
956
+ }),
957
+ children: [
958
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
959
+ className: service_console_module_css_default.confirmTxt,
960
+ children: tr("confirm.txt", {
961
+ name: svc.name,
962
+ pid: String(svc.pid),
963
+ action: confirming.action === "stop" ? tr("action.stop") : tr("action.restart")
964
+ })
965
+ }),
966
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
967
+ variant: "primary",
968
+ size: "sm",
969
+ disabled: pending,
970
+ onClick: () => confirmAction(svc, confirming.action),
971
+ children: pending ? tr("action.pending") : tr("action.confirm")
972
+ }),
973
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
974
+ variant: "outline",
975
+ size: "sm",
976
+ onClick: () => {
977
+ setConfirming(null);
978
+ focusAfter(svc.id);
979
+ },
980
+ children: tr("action.cancel")
981
+ })
982
+ ]
983
+ }) : null,
984
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
985
+ className: service_console_module_css_default.detailBox,
986
+ id: idBase + "-detail-" + svc.id,
987
+ role: "region",
988
+ "aria-label": tr("detail.title"),
989
+ hidden: expanded !== svc.id,
990
+ children: [
991
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
992
+ className: service_console_module_css_default.detailHead,
993
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: tr("detail.title") }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
994
+ className: service_console_module_css_default.detailAccent,
995
+ children: tr("detail.serviceRecord")
996
+ })]
997
+ }),
998
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
999
+ className: service_console_module_css_default.detailGrid,
1000
+ children: [
1001
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1002
+ className: service_console_module_css_default.detailLabel,
1003
+ children: tr("detail.serviceId")
1004
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("code", { children: svc.id })] }),
1005
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1006
+ className: service_console_module_css_default.detailLabel,
1007
+ children: tr("detail.process")
1008
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("code", { children: [
1009
+ "PID ",
1010
+ svc.pid,
1011
+ " · PGID ",
1012
+ String(svc.processGroupId ?? "-")
1013
+ ] })] }),
1014
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1015
+ className: service_console_module_css_default.detailLabel,
1016
+ children: tr("detail.parent")
1017
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("code", { children: ["PPID ", String(svc.parentPid ?? "-")] })] }),
1018
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1019
+ className: service_console_module_css_default.detailLabel,
1020
+ children: tr("detail.started")
1021
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("code", { children: String(svc.startedAt ?? "-") })] })
1022
+ ]
1023
+ }),
1024
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1025
+ className: service_console_module_css_default.evidenceBlock,
1026
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1027
+ className: service_console_module_css_default.detailLabel,
1028
+ children: tr("detail.evidence")
1029
+ }), svc.ownershipEvidence.length ? svc.ownershipEvidence.map((ev, i) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1030
+ className: service_console_module_css_default.evidenceItem,
1031
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1032
+ className: service_console_module_css_default.evidenceArrow,
1033
+ children: "↳"
1034
+ }), ev]
1035
+ }, i)) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
1036
+ className: service_console_module_css_default.rowSub,
1037
+ children: "—"
1038
+ })]
1039
+ })
1040
+ ]
1041
+ })
1042
+ ]
1043
+ }, svc.id);
1044
+ })
924
1045
  ]
925
- }, svc.id);
1046
+ }),
1047
+ SCOPE_VALUES.filter((s) => s !== scope).map((s) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
1048
+ id: idBase + "-scope-" + s + "-panel",
1049
+ role: "tabpanel",
1050
+ "aria-labelledby": idBase + "-scope-" + s,
1051
+ hidden: true
1052
+ }, s))
1053
+ ]
1054
+ });
1055
+ }
1056
+ /** 刷新按钮(小、无文案,供工具条复用) */
1057
+ function ButtonRefresh({ t, onClick }) {
1058
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
1059
+ type: "button",
1060
+ className: service_console_module_css_default.icoBtn,
1061
+ onClick,
1062
+ title: t("status.lastScan"),
1063
+ "aria-label": t("status.lastScan"),
1064
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("svg", {
1065
+ viewBox: "0 0 16 16",
1066
+ width: 14,
1067
+ height: 14,
1068
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", {
1069
+ d: "M13.5 8a5.5 5.5 0 1 1-1.61-3.89M13.5 1.5v3h-3",
1070
+ fill: "none",
1071
+ stroke: "currentColor",
1072
+ strokeWidth: 1.5,
1073
+ strokeLinecap: "round"
1074
+ })
926
1075
  })
927
- ] });
928
- const settingsBody = /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ServiceConsoleSettings, {
929
- t: tr,
930
- onSaved: setConfig
931
1076
  });
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
- },
1077
+ }
1078
+ // \0dsh-css:/home/runner/work/dsh-service-console/dsh-service-console/src/client/service-list-card.module.css.mjs
1079
+ 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}";
1080
+ const tagId = "@jiyr0119/dsh-service-console/service-list-card.module.css";
1081
+ if (typeof document !== "undefined" && document.querySelector("style[data-plugin-css=" + JSON.stringify(tagId) + "]") === null) {
1082
+ const tag = document.createElement("style");
1083
+ tag.dataset.plugin = "@jiyr0119/dsh-service-console";
1084
+ tag.dataset.pluginCss = tagId;
1085
+ tag.textContent = css;
1086
+ document.head.appendChild(tag);
1087
+ }
1088
+ var service_list_card_module_css_default = {
1089
+ "action": "_3hjC-q_action",
1090
+ "link": "_3hjC-q_link",
1091
+ "confirmRow": "_3hjC-q_confirmRow",
1092
+ "dot": "_3hjC-q_dot",
1093
+ "row": "_3hjC-q_row",
1094
+ "card": "_3hjC-q_card",
1095
+ "accessory": "_3hjC-q_accessory",
1096
+ "meta": "_3hjC-q_meta",
1097
+ "okText": "_3hjC-q_okText",
1098
+ "confirmTxt": "_3hjC-q_confirmTxt",
1099
+ "empty": "_3hjC-q_empty",
1100
+ "spacer": "_3hjC-q_spacer",
1101
+ "rowMain": "_3hjC-q_rowMain",
1102
+ "error": "_3hjC-q_error",
1103
+ "summary": "_3hjC-q_summary",
1104
+ "more": "_3hjC-q_more",
1105
+ "name": "_3hjC-q_name",
1106
+ "text": "_3hjC-q_text",
1107
+ "openConsole": "_3hjC-q_openConsole"
1108
+ };
1109
+ // src/client/ServiceListCard.tsx
1110
+ /**
1111
+ * service_list 的聊天卡片(`tool.call.toolview`,keyed by wire tool name)
1112
+ *
1113
+ * 数据来自工具 `output.presentationMeta`(随会话日志持久化 → 视为不可信),
1114
+ * 投影成视图模型由纯函数 `projectServiceListMeta` 完成;任何坏形状都回退成
1115
+ * 纯文本行,**绝不抛错**——toolview 抛错会让该 key 粘性空白。
1116
+ *
1117
+ * 交互约束(与面板同一语义,不新增策略):
1118
+ * - 受保护目标只读;「重启」还要求 meta 里的 `restartable`(无安全启动记录不提供);
1119
+ * - 停止/重启二次确认 + 在途去重;错误码走词典;
1120
+ * - 卡片是一次调用的**快照**,不轮询;折叠状态由平台的 `useDisclosure` 拥有。
1121
+ */
1122
+ /** 结果态的纯文本兜底:把模型面 content 拼成一段(旧会话没有 meta 时走这里) */
1123
+ function contentText(content) {
1124
+ if (!Array.isArray(content)) return "";
1125
+ const parts = [];
1126
+ for (const item of content) if (typeof item === "object" && item !== null && item.type === "text") {
1127
+ const text = item.text;
1128
+ if (typeof text === "string" && text !== "") parts.push(text);
1129
+ }
1130
+ return parts.join("\n");
1131
+ }
1132
+ /** 动态错误码 → 词典键(err.<CODE>),未收录回退 */
1133
+ function errorText(t, code, fallback) {
1134
+ if (code === "") return fallback;
1135
+ const key = "err." + code;
1136
+ const s = t(key);
1137
+ return s === key ? fallback : s;
1138
+ }
1139
+ /** 小监视器图标(DisclosureRow 的 leading 位) */
1140
+ function CardGlyph() {
1141
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("svg", {
1142
+ viewBox: "0 0 16 16",
1143
+ width: 14,
1144
+ height: 14,
1145
+ "aria-hidden": "true",
1146
+ fill: "none",
1147
+ children: [
1148
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("rect", {
1149
+ x: 2.25,
1150
+ y: 3.25,
1151
+ width: 11.5,
1152
+ height: 8.5,
1153
+ rx: 2,
1154
+ stroke: "currentColor",
1155
+ strokeWidth: 1.3
1156
+ }),
1157
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", {
1158
+ d: "M5 6.25 6.9 7.75 5 9.25",
1159
+ stroke: "currentColor",
1160
+ strokeWidth: 1.3,
1161
+ strokeLinecap: "round",
1162
+ strokeLinejoin: "round"
1163
+ }),
1164
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", {
1165
+ d: "M8.4 9.25H11",
1166
+ stroke: "currentColor",
1167
+ strokeWidth: 1.3,
1168
+ strokeLinecap: "round"
1169
+ })
1170
+ ]
1171
+ });
1172
+ }
1173
+ function ServiceListCard(props) {
1174
+ const { t, phase } = props;
1175
+ const disclosure = props.useDisclosure();
1176
+ const [confirming, setConfirming] = react.useState(null);
1177
+ const [opResult, setOpResult] = react.useState(null);
1178
+ const [pending, setPending] = react.useState(false);
1179
+ const [toast, setToast] = react.useState(null);
1180
+ const toastSeq = react.useRef(0);
1181
+ const showToast = (text, tone) => {
1182
+ setToast({
1183
+ seq: ++toastSeq.current,
1184
+ text,
1185
+ tone
1186
+ });
1187
+ };
1188
+ const confirmAction = (row, action) => {
1189
+ if (pending) return;
1190
+ setPending(true);
1191
+ setConfirming(null);
1192
+ api("services/" + action, { serviceId: row.id }).then((res) => {
1193
+ const ok = res?.ok === true;
1194
+ const text = ok ? action === "stop" ? t("result.stopped") : t("result.restarted") : errorText(t, res?.error?.code ?? "", res?.error?.message ?? t("result.error"));
1195
+ setOpResult({
1196
+ id: row.id,
1197
+ ok,
1198
+ text
1199
+ });
1200
+ showToast(text, ok ? "success" : void 0);
1201
+ }).catch((error) => {
1202
+ const text = String(error?.message ?? error);
1203
+ setOpResult({
1204
+ id: row.id,
1205
+ ok: false,
1206
+ text
1207
+ });
1208
+ showToast(text);
1209
+ }).finally(() => setPending(false));
1210
+ };
1211
+ const toastNode = toast === null ? null : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Toast, {
1212
+ text: toast.text,
1213
+ tone: toast.tone,
1214
+ onDone: () => setToast(null)
1215
+ }, toast.seq);
1216
+ if (phase !== "result") return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1217
+ className: service_list_card_module_css_default.card,
1218
+ "data-dsh-sc": "card",
1219
+ "data-dsh-sc-phase": phase,
1220
+ children: [toastNode, /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
1221
+ className: service_list_card_module_css_default.summary,
1222
+ children: t("status.scanning")
1223
+ })]
1224
+ });
1225
+ if (props.block.isError) {
1226
+ const text = contentText(props.block.content);
1227
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1228
+ className: service_list_card_module_css_default.card,
1229
+ "data-dsh-sc": "card",
1230
+ "data-dsh-sc-phase": "result",
1231
+ "data-dsh-sc-error": "true",
945
1232
  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
- ]
1233
+ toastNode,
1234
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
1235
+ className: service_list_card_module_css_default.summary,
1236
+ children: t("status.error")
1016
1237
  }),
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"),
1238
+ text === "" ? null : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("pre", {
1239
+ className: service_list_card_module_css_default.text,
1240
+ children: text
1241
+ })
1242
+ ]
1243
+ });
1244
+ }
1245
+ const model = projectServiceListMeta(props.block.meta);
1246
+ if (model === null) {
1247
+ const text = contentText(props.block.content);
1248
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1249
+ className: service_list_card_module_css_default.card,
1250
+ "data-dsh-sc": "card",
1251
+ "data-dsh-sc-phase": "result",
1252
+ "data-dsh-sc-fallback": "true",
1253
+ children: [toastNode, text === "" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
1254
+ className: service_list_card_module_css_default.summary,
1255
+ children: t("svc.noSvc")
1256
+ }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("pre", {
1257
+ className: service_list_card_module_css_default.text,
1258
+ children: text
1259
+ })]
1260
+ });
1261
+ }
1262
+ const ports = serviceListPorts(model);
1263
+ const protectedCount = model.rows.filter((row) => row.protected).length;
1264
+ const summary = t("card.summary", {
1265
+ count: model.count,
1266
+ total: model.total
1267
+ });
1268
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1269
+ className: service_list_card_module_css_default.card,
1270
+ "data-dsh-sc": "card",
1271
+ "data-dsh-sc-phase": "result",
1272
+ "data-dsh-sc-count": model.rows.length,
1273
+ children: [toastNode, /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_deepseek_ai_dsh_client_ui_primitives.DisclosureRow, {
1274
+ icon: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CardGlyph, {}),
1275
+ title: summary,
1276
+ open: disclosure.expanded,
1277
+ expandable: model.rows.length > 0,
1278
+ onToggle: disclosure.toggle,
1279
+ expandOnRowClick: true,
1280
+ keepContentWhenOpen: true,
1281
+ collapsedContent: ports === "" ? null : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1282
+ className: service_list_card_module_css_default.summary,
1283
+ children: ports
1284
+ }),
1285
+ headerAccessory: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
1286
+ className: service_list_card_module_css_default.accessory,
1287
+ children: [protectedCount > 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Tag, {
1288
+ tone: "danger",
1289
+ children: t("own.protected")
1290
+ }) : null, /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
1291
+ type: "button",
1292
+ className: service_list_card_module_css_default.openConsole,
1293
+ onClick: () => {
1294
+ window.dispatchEvent(new Event("dsh-service-console:open"));
1295
+ },
1296
+ children: t("entry.tip")
1297
+ })]
1298
+ }),
1299
+ children: [
1300
+ model.rows.length === 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
1301
+ className: service_list_card_module_css_default.empty,
1302
+ children: t("svc.noSvc")
1303
+ }) : null,
1304
+ model.rows.map((row) => {
1305
+ const color = OWNERSHIP_COLOR[row.ownership];
1306
+ const isConfirming = confirming?.id === row.id;
1307
+ const result = opResult?.id === row.id ? opResult : null;
1308
+ const controllable = canControlService(row);
1309
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1310
+ className: service_list_card_module_css_default.row,
1311
+ "data-dsh-sc": "card-row",
1312
+ "data-dsh-sc-ownership": row.ownership,
1313
+ "data-dsh-sc-ports": row.ports,
1057
1314
  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
- })]
1315
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1316
+ className: service_list_card_module_css_default.rowMain,
1317
+ children: [
1318
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1319
+ className: service_list_card_module_css_default.dot,
1320
+ style: { color },
1321
+ "aria-hidden": "true",
1322
+ children: "●"
1323
+ }),
1324
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1325
+ className: service_list_card_module_css_default.name,
1326
+ children: row.name
1327
+ }),
1328
+ row.ports === "" ? null : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
1329
+ className: service_list_card_module_css_default.meta,
1330
+ children: [":", row.ports]
1331
+ }),
1332
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Tag, {
1333
+ tone: OWNERSHIP_TONE[row.ownership],
1334
+ children: t(OWNERSHIP_KEY[row.ownership])
1335
+ }),
1336
+ row.url === null ? null : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("a", {
1337
+ className: service_list_card_module_css_default.link,
1338
+ href: row.url,
1339
+ target: "_blank",
1340
+ rel: "noreferrer",
1341
+ "aria-label": t("action.open") + " " + row.name,
1342
+ title: row.url,
1343
+ children: t("action.open")
1344
+ }),
1345
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { className: service_list_card_module_css_default.spacer }),
1346
+ controllable ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
1347
+ type: "button",
1348
+ className: service_list_card_module_css_default.action,
1349
+ disabled: pending,
1350
+ "aria-label": t("action.stop") + " " + row.name,
1351
+ onClick: () => {
1352
+ setConfirming({
1353
+ id: row.id,
1354
+ action: "stop"
1355
+ });
1356
+ setOpResult(null);
1357
+ },
1358
+ children: isConfirming && confirming.action === "stop" ? t("confirm.stop") : t("action.stop")
1359
+ }) : null,
1360
+ controllable && row.restartable ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
1361
+ type: "button",
1362
+ className: service_list_card_module_css_default.action,
1363
+ disabled: pending,
1364
+ "aria-label": t("action.restart") + " " + row.name,
1365
+ onClick: () => {
1366
+ setConfirming({
1367
+ id: row.id,
1368
+ action: "restart"
1369
+ });
1370
+ setOpResult(null);
1371
+ },
1372
+ children: isConfirming && confirming.action === "restart" ? t("confirm.restart") : t("action.restart")
1373
+ }) : null
1374
+ ]
1077
1375
  }),
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 })
1376
+ controllable && isConfirming ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1377
+ className: service_list_card_module_css_default.confirmRow,
1378
+ children: [
1379
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1380
+ className: service_list_card_module_css_default.confirmTxt,
1381
+ children: t("card.confirm", {
1382
+ name: row.name,
1383
+ action: confirming.action === "stop" ? t("action.stop") : t("action.restart")
1384
+ })
1385
+ }),
1386
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
1387
+ variant: "primary",
1388
+ size: "sm",
1389
+ disabled: pending,
1390
+ onClick: () => confirmAction(row, confirming.action),
1391
+ children: pending ? t("action.pending") : t("action.confirm")
1392
+ }),
1393
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
1394
+ variant: "outline",
1395
+ size: "sm",
1396
+ onClick: () => setConfirming(null),
1397
+ children: t("action.cancel")
1398
+ })
1399
+ ]
1400
+ }) : null,
1401
+ result === null ? null : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
1402
+ className: result.ok ? service_list_card_module_css_default.okText : service_list_card_module_css_default.error,
1403
+ children: (result.ok ? "✅ " : "⛔ ") + result.text
1404
+ })
1080
1405
  ]
1081
- })]
1406
+ }, row.id);
1082
1407
  }),
1083
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
1084
- className: service_console_module_css_default.tabBody,
1085
- children: tab === "services" ? servicesBody : settingsBody
1086
- })
1408
+ model.truncated > 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
1409
+ className: service_list_card_module_css_default.more,
1410
+ children: t("card.more", { n: model.truncated })
1411
+ }) : null
1087
1412
  ]
1088
1413
  })]
1089
1414
  });
1090
1415
  }
1416
+ // src/client/ServiceDockPill.tsx
1417
+ /**
1418
+ * composer 常驻 pill(`conversation.composer.dock`)
1419
+ *
1420
+ * 只在**本会话**有归属服务(`conversation-confirmed`)时出现:
1421
+ * `2 services · :5173 :3000` → 点击打开控制台 tab。
1422
+ *
1423
+ * 设计取舍:
1424
+ * - 数据来自与面板同一个 `/dsh-sc/api/services/scan`(带 sessionId → 宿主按台账
1425
+ * `sessionKey` 收窄归属),选择/摘要全部走纯函数(`service-list-view.ts`,有单测)。
1426
+ * - 轮询**慢且可停**:20s 一次、页面隐藏时跳过、卸载即清;不为一个环境提示
1427
+ * 引入高频 `lsof`。
1428
+ * - 无归属服务时不渲染任何 DOM(不占位、不抢焦点)。
1429
+ */
1430
+ /** 轮询间隔:环境提示够用,且不让 lsof 跑得太勤 */
1431
+ const POLL_INTERVAL_MS = 3e4;
1432
+ let timerCtx = null;
1433
+ /** 注入平台 timer(与面板共用 `bindTimer` 的同一份服务,但这里需要 interval) */
1434
+ function bindDockTimer(t) {
1435
+ timerCtx = t;
1436
+ }
1437
+ function ServiceDockPill({ t, sessionId }) {
1438
+ const [model, setModel] = react.useState(null);
1439
+ react.useEffect(() => {
1440
+ let cancelled = false;
1441
+ setModel(null);
1442
+ let inFlight = false;
1443
+ const load = () => {
1444
+ if (cancelled) return;
1445
+ if (typeof document !== "undefined" && document.visibilityState === "hidden") return;
1446
+ if (inFlight) return;
1447
+ inFlight = true;
1448
+ api("services/scan", { sessionId }).then((res) => {
1449
+ if (cancelled) return;
1450
+ if (res?.ok === false) {
1451
+ setModel(null);
1452
+ return;
1453
+ }
1454
+ setModel(summarizeSessionServices(selectSessionServices(res?.data?.services)));
1455
+ }).catch(() => {
1456
+ if (!cancelled) setModel(null);
1457
+ }).finally(() => {
1458
+ inFlight = false;
1459
+ });
1460
+ };
1461
+ const onVisible = () => {
1462
+ if (document.visibilityState === "visible") load();
1463
+ };
1464
+ load();
1465
+ const cancelInterval = timerCtx?.interval(load, POLL_INTERVAL_MS);
1466
+ document.addEventListener("visibilitychange", onVisible);
1467
+ return () => {
1468
+ cancelled = true;
1469
+ cancelInterval?.();
1470
+ document.removeEventListener("visibilitychange", onVisible);
1471
+ };
1472
+ }, [sessionId]);
1473
+ if (model === null || model.count === 0) return null;
1474
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_deepseek_ai_dsh_client_ui_primitives.Pill, {
1475
+ className: service_console_module_css_default.dockPill,
1476
+ "data-dsh-sc": "dock-pill",
1477
+ "data-dsh-sc-count": model.count,
1478
+ title: t("dock.open"),
1479
+ onClick: () => {
1480
+ window.dispatchEvent(new Event("dsh-service-console:open"));
1481
+ },
1482
+ children: [
1483
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.StateDot, {
1484
+ state: "done",
1485
+ size: 8
1486
+ }),
1487
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: t("dock.pill", { n: model.count }) }),
1488
+ model.ports === "" ? null : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1489
+ className: service_console_module_css_default.dockPillPorts,
1490
+ children: model.ports
1491
+ })
1492
+ ]
1493
+ });
1494
+ }
1091
1495
  // src/client/i18n.ts
1092
1496
  /**
1093
1497
  * 幂等注册词典:单次对象式注册;已由先前装载注册(`already has locale`)视为
@@ -1157,6 +1561,12 @@ window.__ModuleLoader__.load({
1157
1561
  "status.lastScan": "最近扫描",
1158
1562
  "status.error": "扫描失败",
1159
1563
  "svc.noSvc": "未发现服务",
1564
+ "card.summary": "{count}/{total} 项服务",
1565
+ "card.more": "还有 {n} 项…",
1566
+ "card.confirm": "确认对 {name} 执行{action}?",
1567
+ "svc.restartable": "可重启",
1568
+ "dock.pill": "{n} 个会话服务",
1569
+ "dock.open": "打开服务控制台",
1160
1570
  "svc.ports": "端口",
1161
1571
  "svc.pid": "pid",
1162
1572
  "svc.command": "命令",
@@ -1164,6 +1574,7 @@ window.__ModuleLoader__.load({
1164
1574
  "action.stop": "停止",
1165
1575
  "action.restart": "重启",
1166
1576
  "action.detail": "详情",
1577
+ "action.open": "打开",
1167
1578
  "action.confirm": "确认",
1168
1579
  "action.cancel": "取消",
1169
1580
  "action.pending": "处理中…",
@@ -1178,6 +1589,7 @@ window.__ModuleLoader__.load({
1178
1589
  "own.other": "本机其他",
1179
1590
  "own.unknown": "未知",
1180
1591
  "own.protected": "受保护",
1592
+ "scope.filter": "服务范围",
1181
1593
  "scope.conversation": "本次对话",
1182
1594
  "scope.workspace": "当前工作区",
1183
1595
  "scope.machine": "本机",
@@ -1199,6 +1611,10 @@ window.__ModuleLoader__.load({
1199
1611
  "err.PORT_CONFLICT": "端口仍被占用",
1200
1612
  "err.START_TIMEOUT": "未在预期时间开始监听",
1201
1613
  "err.FORBIDDEN_REMOTE": "非本机来源:只读(防止远程停本机进程)",
1614
+ "err.SCAN_FAILED": "扫描失败:无法读取本机监听端口",
1615
+ "err.BAD_REQUEST": "请求参数不合法",
1616
+ "err.INTERNAL": "内部错误",
1617
+ "err.SCAN_TIMEOUT": "扫描超时:系统命令未在时限内返回",
1202
1618
  "tab.services": "服务",
1203
1619
  "tab.settings": "设置",
1204
1620
  "settings.title": "面板设置",
@@ -1232,6 +1648,12 @@ window.__ModuleLoader__.load({
1232
1648
  "status.lastScan": "Last scan",
1233
1649
  "status.error": "Scan failed",
1234
1650
  "svc.noSvc": "no services found",
1651
+ "card.summary": "{count}/{total} services",
1652
+ "card.more": "{n} more…",
1653
+ "card.confirm": "Run {action} on {name}?",
1654
+ "svc.restartable": "restartable",
1655
+ "dock.pill": "{n} dev service(s)",
1656
+ "dock.open": "Open the service console",
1235
1657
  "svc.ports": "Ports",
1236
1658
  "svc.pid": "pid",
1237
1659
  "svc.command": "Command",
@@ -1239,6 +1661,7 @@ window.__ModuleLoader__.load({
1239
1661
  "action.stop": "Stop",
1240
1662
  "action.restart": "Restart",
1241
1663
  "action.detail": "Detail",
1664
+ "action.open": "Open",
1242
1665
  "action.confirm": "OK",
1243
1666
  "action.cancel": "Cancel",
1244
1667
  "action.pending": "Working…",
@@ -1253,6 +1676,7 @@ window.__ModuleLoader__.load({
1253
1676
  "own.other": "Other local",
1254
1677
  "own.unknown": "Unknown",
1255
1678
  "own.protected": "Protected",
1679
+ "scope.filter": "Service scope",
1256
1680
  "scope.conversation": "This chat",
1257
1681
  "scope.workspace": "Workspace",
1258
1682
  "scope.machine": "This machine",
@@ -1274,6 +1698,10 @@ window.__ModuleLoader__.load({
1274
1698
  "err.PORT_CONFLICT": "Port conflict",
1275
1699
  "err.START_TIMEOUT": "Start timeout",
1276
1700
  "err.FORBIDDEN_REMOTE": "Not a local caller — read-only",
1701
+ "err.SCAN_FAILED": "Scan failed: cannot read local listeners",
1702
+ "err.BAD_REQUEST": "Invalid request",
1703
+ "err.INTERNAL": "Internal error",
1704
+ "err.SCAN_TIMEOUT": "Scan timed out",
1277
1705
  "tab.services": "Services",
1278
1706
  "tab.settings": "Settings",
1279
1707
  "settings.title": "Panel settings",
@@ -1296,44 +1724,211 @@ window.__ModuleLoader__.load({
1296
1724
  "star.cta": "★ Give a Star"
1297
1725
  };
1298
1726
  // src/client/index.tsx
1727
+ /** 词典命名空间(与 LocaleNamespaceMap 合并、各注册项的 `locale:` 一致) */
1299
1728
  const NS = "dsh-service-console";
1729
+ /** tab 类型的实现身份:全局唯一,同时是 stage-two 三个 seat 的 dispatch key(**不是** kind) */
1730
+ const TAB_ID = "@jiyr0119/dsh-service-console";
1731
+ /** 页面类型判别值:`openTab` 用它,tab 记录里存的也是它 */
1732
+ const TAB_KIND = "service-console";
1300
1733
  let labelT = null;
1301
1734
  function labelFn(key) {
1302
1735
  return labelT ? labelT(key) : key;
1303
1736
  }
1737
+ /**
1738
+ * 幂等注册:桌面 dshmarket 热更新会把插件装载两次,第二次 `register` 抛
1739
+ * `tab type id … already registered` / `slot … already registered`。
1740
+ * cordis 会 rethrow effect 建立期的异常并中止整个 apply——那会让入口、设置页
1741
+ * 一起消失。这里把重复视为「已由存活实例注册」跳过并留痕(与 i18n 的幂等一致)。
1742
+ */
1743
+ function registerSafely(label, register) {
1744
+ try {
1745
+ const dispose = register();
1746
+ return typeof dispose === "function" ? dispose : () => {};
1747
+ } catch (error) {
1748
+ const message = error instanceof Error ? error.message : String(error);
1749
+ if (!/already registered|already has/i.test(message)) console.warn(`[dsh-service-console] ${label} failed:`, message);
1750
+ return () => {};
1751
+ }
1752
+ }
1753
+ /** 引导页卡片的图标:`ComponentType<IconProps>`(size/className),与 settings 图标不同型 */
1754
+ function ConsoleGlyph({ size = 16, className }) {
1755
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("svg", {
1756
+ viewBox: "0 0 16 16",
1757
+ width: size,
1758
+ height: size,
1759
+ className,
1760
+ "aria-hidden": "true",
1761
+ fill: "none",
1762
+ children: [
1763
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("rect", {
1764
+ x: 2.25,
1765
+ y: 3.25,
1766
+ width: 11.5,
1767
+ height: 8.5,
1768
+ rx: 2,
1769
+ stroke: "currentColor",
1770
+ strokeWidth: 1.3
1771
+ }),
1772
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", {
1773
+ d: "M5 6.25 6.9 7.75 5 9.25",
1774
+ stroke: "currentColor",
1775
+ strokeWidth: 1.3,
1776
+ strokeLinecap: "round",
1777
+ strokeLinejoin: "round"
1778
+ }),
1779
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", {
1780
+ d: "M8.4 9.25H11",
1781
+ stroke: "currentColor",
1782
+ strokeWidth: 1.3,
1783
+ strokeLinecap: "round"
1784
+ })
1785
+ ]
1786
+ });
1787
+ }
1788
+ /**
1789
+ * tab 内容体:会话 id 由框架的 inject face 注入(不读全局 mounted,后台会话也正确)。
1790
+ * `tab.visible` 是平台为「折叠 / 后台会话」提供的信号——不可见时停止扫描与轮询,
1791
+ * 否则隐藏的面板仍每 5s 打一次本机 lsof。
1792
+ */
1793
+ function ServiceConsoleBody({ t, sessionId, useTabInfo }) {
1794
+ const { tab } = useTabInfo();
1795
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ServiceConsoleTab, {
1796
+ t,
1797
+ sessionId,
1798
+ visible: tab.visible
1799
+ });
1800
+ }
1801
+ /** 标签标题:注册后语言切换即时生效(未注册则用开 tab 时捕获的文案) */
1802
+ function ServiceConsoleTitle({ t }) {
1803
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1804
+ "data-dsh-sc-title": true,
1805
+ children: t("panel.title")
1806
+ });
1807
+ }
1304
1808
  module.exports = {
1305
- inject: ["slots", "timer"],
1809
+ inject: [
1810
+ "slots",
1811
+ "timer",
1812
+ "locale",
1813
+ "sidebarRight",
1814
+ "sidebarRightTabs"
1815
+ ],
1306
1816
  apply(ctx) {
1307
1817
  bindTimer(ctx.timer);
1818
+ bindDockTimer(ctx.timer);
1308
1819
  attachLocale(ctx, NS, {
1309
1820
  zh: ZH_DICT,
1310
1821
  en: EN_DICT
1311
1822
  }, (t) => {
1312
1823
  labelT = t;
1313
1824
  });
1314
- ctx.effect(() => ctx.slots.inject("conversation.session.header.utilities", () => ctx.slots.register({
1825
+ ctx.effect(() => {
1826
+ /** 当前屏幕上的 tab(无会话 / store 未 adopted 时返回 undefined,绝不抛) */
1827
+ const openTab = () => {
1828
+ try {
1829
+ const sessionId = ctx.sidebarRight.mounted.getSnapshot();
1830
+ if (sessionId === void 0) return void 0;
1831
+ const existing = ctx.sidebarRight.tabsIn(sessionId).find((tab) => tab.kind === TAB_KIND);
1832
+ return existing === void 0 ? void 0 : { id: existing.id };
1833
+ } catch {
1834
+ return;
1835
+ }
1836
+ };
1837
+ const open = () => {
1838
+ try {
1839
+ if (ctx.sidebarRight.mounted.getSnapshot() === void 0) return;
1840
+ ctx.sidebarRight.openTab(TAB_KIND);
1841
+ } catch (error) {
1842
+ console.warn("[dsh-service-console] open failed:", String(error));
1843
+ }
1844
+ };
1845
+ const toggle = () => {
1846
+ const existing = openTab();
1847
+ if (existing !== void 0) {
1848
+ try {
1849
+ ctx.sidebarRight.close(existing.id);
1850
+ } catch {}
1851
+ return;
1852
+ }
1853
+ open();
1854
+ };
1855
+ const close = () => {
1856
+ const existing = openTab();
1857
+ if (existing === void 0) return;
1858
+ try {
1859
+ ctx.sidebarRight.close(existing.id);
1860
+ } catch {}
1861
+ };
1862
+ window.addEventListener("dsh-service-console:open", open);
1863
+ window.addEventListener("dsh-service-console:close", close);
1864
+ window.addEventListener("dsh-service-console:toggle", toggle);
1865
+ return () => {
1866
+ window.removeEventListener("dsh-service-console:open", open);
1867
+ window.removeEventListener("dsh-service-console:close", close);
1868
+ window.removeEventListener("dsh-service-console:toggle", toggle);
1869
+ };
1870
+ });
1871
+ ctx.effect(() => registerSafely("tab type", () => ctx.sidebarRightTabs.register({
1872
+ id: TAB_ID,
1873
+ kind: TAB_KIND,
1874
+ priority: "extension",
1875
+ title: () => labelFn("panel.title"),
1876
+ guide: [{
1877
+ id: "open",
1878
+ order: 90,
1879
+ title: () => labelFn("panel.title"),
1880
+ description: () => labelFn("panel.subtitle"),
1881
+ icon: ConsoleGlyph
1882
+ }]
1883
+ })), "service-console: tab type");
1884
+ ctx.effect(() => registerSafely("tab body", () => ctx.slots.inject("sidebar.right.pane.tab", () => ctx.slots.register({
1885
+ name: "sidebar.right.pane.tab",
1886
+ key: TAB_ID,
1887
+ locale: NS,
1888
+ inject: (sessionId) => ({ sessionId: String(sessionId) })
1889
+ }, ServiceConsoleBody))), "service-console: tab body");
1890
+ ctx.effect(() => registerSafely("tab title", () => ctx.slots.inject("sidebar.right.pane.tab.title", () => ctx.slots.register({
1891
+ name: "sidebar.right.pane.tab.title",
1892
+ key: TAB_ID,
1893
+ locale: NS
1894
+ }, ServiceConsoleTitle))), "service-console: tab title");
1895
+ ctx.effect(() => registerSafely("header entry", () => ctx.slots.inject("conversation.session.header.utilities", () => ctx.slots.register({
1315
1896
  name: "conversation.session.header.utilities",
1316
1897
  id: "dsh-service-console",
1317
1898
  order: 25,
1318
1899
  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({
1900
+ label: () => labelFn("plugin.name"),
1901
+ inject: () => ({ openConsole: () => {
1902
+ try {
1903
+ ctx.sidebarRight.openTab(TAB_KIND);
1904
+ } catch (error) {
1905
+ console.warn("[dsh-service-console] openTab failed:", String(error));
1906
+ }
1907
+ } })
1908
+ }, ServiceConsoleEntry))), "service-console: header entry");
1909
+ ctx.effect(() => registerSafely("settings section", () => ctx.slots.inject("settings.section", () => ctx.slots.register({
1327
1910
  name: "settings.section",
1328
1911
  id: "dsh-service-console",
1329
1912
  order: 35,
1330
1913
  locale: NS,
1331
1914
  label: () => labelFn("plugin.name")
1332
- }, ServiceConsoleSettings)));
1333
- ctx.effect(() => ctx.slots.inject("settings.section.icon", () => ctx.slots.register({
1915
+ }, ServiceConsoleSettings))), "service-console: settings section");
1916
+ ctx.effect(() => registerSafely("service_list card", () => ctx.slots.inject("tool.call.toolview", () => ctx.slots.register({
1917
+ name: "tool.call.toolview",
1918
+ key: "service_list",
1919
+ locale: NS
1920
+ }, ServiceListCard))), "service-console: service_list card");
1921
+ ctx.effect(() => registerSafely("dock pill", () => ctx.slots.inject("conversation.composer.dock", () => ctx.slots.register({
1922
+ name: "conversation.composer.dock",
1923
+ id: "dsh-service-console",
1924
+ order: 40,
1925
+ locale: NS,
1926
+ inject: (sessionId) => ({ sessionId: String(sessionId) })
1927
+ }, ServiceDockPill))), "service-console: dock pill");
1928
+ ctx.effect(() => registerSafely("settings icon", () => ctx.slots.inject("settings.section.icon", () => ctx.slots.register({
1334
1929
  name: "settings.section.icon",
1335
1930
  id: "dsh-service-console"
1336
- }, ServiceConsoleIcon)));
1931
+ }, ServiceConsoleIcon))), "service-console: settings icon");
1337
1932
  }
1338
1933
  };
1339
1934
  return module.exports;