@linxin666/dsh-client-ui-task-board-ssh 0.0.0-stage → 0.4.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (126) hide show
  1. package/LICENSE +202 -0
  2. package/README.i18n.yaml +6 -0
  3. package/README.md +85 -2
  4. package/README.zh.md +86 -0
  5. package/cordis.patch.yml +15 -0
  6. package/icon.svg +5 -0
  7. package/lib/client.js +4429 -0
  8. package/lib/index.js +6100 -0
  9. package/lib/types/client/PluginSettingsCard.d.ts +255 -0
  10. package/lib/types/client/RangeBubble.d.ts +46 -0
  11. package/lib/types/client/SegmentGroup.d.ts +28 -0
  12. package/lib/types/client/index.d.ts +100 -0
  13. package/lib/types/client/locales.d.ts +125 -0
  14. package/lib/types/client/seat-props.d.ts +53 -0
  15. package/lib/types/client/settings-entry-form.d.ts +49 -0
  16. package/lib/types/client/settings-form.d.ts +237 -0
  17. package/lib/types/client/ssh/card-decoration.d.ts +23 -0
  18. package/lib/types/client/ssh/compose-section.d.ts +7 -0
  19. package/lib/types/client/ssh/detail-section.d.ts +7 -0
  20. package/lib/types/client/ssh/extension.d.ts +54 -0
  21. package/lib/types/client/ssh/log-buffer.d.ts +128 -0
  22. package/lib/types/client/ssh/log-view.d.ts +37 -0
  23. package/lib/types/client/ssh/model.d.ts +130 -0
  24. package/lib/types/client/ssh/settings-section.d.ts +134 -0
  25. package/lib/types/client/ssh/summary.d.ts +160 -0
  26. package/lib/types/client/ssh/target-form.d.ts +60 -0
  27. package/lib/types/core/action.d.ts +89 -0
  28. package/lib/types/core/adapters/claude.d.ts +15 -0
  29. package/lib/types/core/adapters/codex.d.ts +15 -0
  30. package/lib/types/core/adapters/custom.d.ts +29 -0
  31. package/lib/types/core/adapters/dsh.d.ts +21 -0
  32. package/lib/types/core/adapters/index.d.ts +25 -0
  33. package/lib/types/core/adapters/types.d.ts +76 -0
  34. package/lib/types/core/contract.d.ts +445 -0
  35. package/lib/types/core/launcher-script.d.ts +13 -0
  36. package/lib/types/core/launcher.d.ts +153 -0
  37. package/lib/types/core/ledger.d.ts +123 -0
  38. package/lib/types/core/shell.d.ts +61 -0
  39. package/lib/types/core/target.d.ts +143 -0
  40. package/lib/types/core/task-record.d.ts +63 -0
  41. package/lib/types/core/workspace.d.ts +74 -0
  42. package/lib/types/host/board.d.ts +71 -0
  43. package/lib/types/host/engine.d.ts +418 -0
  44. package/lib/types/host/extension.d.ts +59 -0
  45. package/lib/types/host/logs.d.ts +135 -0
  46. package/lib/types/host/payload.d.ts +75 -0
  47. package/lib/types/host/prompt.d.ts +44 -0
  48. package/lib/types/host/queue.d.ts +53 -0
  49. package/lib/types/host/remote.d.ts +120 -0
  50. package/lib/types/host/settings.d.ts +149 -0
  51. package/lib/types/host/timers.d.ts +20 -0
  52. package/lib/types/host/tools.d.ts +15 -0
  53. package/lib/types/host/workspace/errors.d.ts +29 -0
  54. package/lib/types/host/workspace/git.d.ts +108 -0
  55. package/lib/types/host/workspace/in-place.d.ts +36 -0
  56. package/lib/types/host/workspace/index.d.ts +28 -0
  57. package/lib/types/host/workspace/layout.d.ts +62 -0
  58. package/lib/types/host/workspace/local-git.d.ts +72 -0
  59. package/lib/types/host/workspace/remote-git.d.ts +111 -0
  60. package/lib/types/host/workspace/remote.d.ts +85 -0
  61. package/lib/types/host/workspace/types.d.ts +28 -0
  62. package/lib/types/host/workspace-seam.d.ts +100 -0
  63. package/lib/types/index.d.ts +97 -0
  64. package/lib/types/mount-once.d.ts +55 -0
  65. package/locale/en.json +6 -0
  66. package/locale/zh.json +6 -0
  67. package/package.json +89 -3
  68. package/src/client/PluginSettingsCard.tsx +838 -0
  69. package/src/client/RangeBubble.tsx +164 -0
  70. package/src/client/SegmentGroup.tsx +93 -0
  71. package/src/client/css-modules.d.ts +5 -0
  72. package/src/client/index.ts +195 -0
  73. package/src/client/locales.ts +257 -0
  74. package/src/client/seat-props.ts +58 -0
  75. package/src/client/settings-card.module.css +821 -0
  76. package/src/client/settings-entry-form.ts +141 -0
  77. package/src/client/settings-form.ts +529 -0
  78. package/src/client/ssh/card-decoration.tsx +55 -0
  79. package/src/client/ssh/compose-section.tsx +147 -0
  80. package/src/client/ssh/detail-section.tsx +345 -0
  81. package/src/client/ssh/extension.ts +271 -0
  82. package/src/client/ssh/log-buffer.ts +224 -0
  83. package/src/client/ssh/log-view.tsx +149 -0
  84. package/src/client/ssh/model.ts +299 -0
  85. package/src/client/ssh/settings-section.tsx +401 -0
  86. package/src/client/ssh/summary.ts +388 -0
  87. package/src/client/ssh/target-form.tsx +380 -0
  88. package/src/client/ssh.module.css +617 -0
  89. package/src/core/action.ts +270 -0
  90. package/src/core/adapters/claude.ts +64 -0
  91. package/src/core/adapters/codex.ts +83 -0
  92. package/src/core/adapters/custom.ts +88 -0
  93. package/src/core/adapters/dsh.ts +87 -0
  94. package/src/core/adapters/index.ts +74 -0
  95. package/src/core/adapters/types.ts +95 -0
  96. package/src/core/contract.ts +510 -0
  97. package/src/core/launcher-script.ts +313 -0
  98. package/src/core/launcher.ts +283 -0
  99. package/src/core/ledger.ts +372 -0
  100. package/src/core/shell.ts +77 -0
  101. package/src/core/target.ts +413 -0
  102. package/src/core/task-record.ts +65 -0
  103. package/src/core/workspace.ts +78 -0
  104. package/src/host/board.ts +103 -0
  105. package/src/host/engine.ts +1602 -0
  106. package/src/host/extension.ts +304 -0
  107. package/src/host/logs.ts +297 -0
  108. package/src/host/payload.ts +134 -0
  109. package/src/host/prompt.ts +89 -0
  110. package/src/host/queue.ts +73 -0
  111. package/src/host/remote.ts +328 -0
  112. package/src/host/settings.ts +294 -0
  113. package/src/host/timers.ts +33 -0
  114. package/src/host/tools.ts +259 -0
  115. package/src/host/workspace/errors.ts +43 -0
  116. package/src/host/workspace/git.ts +305 -0
  117. package/src/host/workspace/in-place.ts +58 -0
  118. package/src/host/workspace/index.ts +37 -0
  119. package/src/host/workspace/layout.ts +122 -0
  120. package/src/host/workspace/local-git.ts +164 -0
  121. package/src/host/workspace/remote-git.ts +244 -0
  122. package/src/host/workspace/remote.ts +181 -0
  123. package/src/host/workspace/types.ts +34 -0
  124. package/src/host/workspace-seam.ts +132 -0
  125. package/src/index.ts +243 -0
  126. package/src/mount-once.ts +142 -0
package/lib/client.js ADDED
@@ -0,0 +1,4429 @@
1
+ window.__ModuleLoader__.load({
2
+ id: "@linxin666/dsh-client-ui-task-board-ssh",
3
+ factory: (require) => {
4
+ var module = { exports: {} };
5
+ var exports = module.exports;
6
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
7
+ let react = require("react");
8
+ let react_jsx_runtime = require("react/jsx-runtime");
9
+ let _deepseek_ai_dsh_client_store = require("@deepseek-ai/dsh-client-store");
10
+ //#region \0dsh-css:packages/dsh-task-board-ssh/src/client/settings-card.module.css.mjs
11
+ const css$1 = ".DAVtkG_card{--settings-card-radius:12px;--settings-card-header-pad:16px;--settings-card-header-gap:13px;--settings-card-title-size:15px;--settings-card-description-size:13px;--settings-card-body-inset:16px;--settings-card-motion:.18s;border:1px solid var(--dsw-alias-border-l2);background:var(--dsw-alias-bg-layer-3);border-radius:var(--settings-card-radius);list-style:none;transition:border-color .16s,background .16s}.DAVtkG_card:hover{border-color:var(--dsw-alias-label-dimmed)}.DAVtkG_cardOpen{background:var(--dsw-alias-bg-layer-2);border-color:var(--dsw-alias-label-dimmed)}.DAVtkG_cardNested{--settings-card-radius:10px;--settings-card-header-pad:10px 12px;--settings-card-header-gap:10px;--settings-card-title-size:13px;--settings-card-description-size:12px;--settings-card-body-inset:12px}.DAVtkG_cardNested .DAVtkG_description{white-space:nowrap;text-overflow:ellipsis;overflow:hidden}.DAVtkG_header{appearance:none;box-sizing:border-box;width:100%;font:inherit;color:inherit;text-align:left;cursor:pointer;border-radius:var(--settings-card-radius);align-items:center;gap:var(--settings-card-header-gap);padding:var(--settings-card-header-pad);background:0 0;border:0;display:flex}.DAVtkG_header:focus-visible{outline:2px solid var(--dsw-alias-brand-primary);outline-offset:-2px}.DAVtkG_headerStatic{box-sizing:border-box;border-radius:var(--settings-card-radius);align-items:center;gap:var(--settings-card-header-gap);width:100%;padding:var(--settings-card-header-pad);display:flex}.DAVtkG_headText{flex-direction:column;flex:1;gap:4px;min-width:0;display:flex}.DAVtkG_mark{background:var(--dsw-alias-bg-module-platform);width:34px;height:34px;color:var(--dsw-alias-label-secondary);border-radius:10px;flex:none;place-items:center;transition:color .16s;display:grid}.DAVtkG_header:hover .DAVtkG_mark,.DAVtkG_cardOpen .DAVtkG_mark{color:var(--dsw-alias-label-primary)}.DAVtkG_name{color:var(--dsw-alias-label-primary);font-size:var(--settings-card-title-size);font-weight:600;line-height:1.4}.DAVtkG_description{color:var(--dsw-alias-label-secondary);font-size:12px;line-height:18px}.DAVtkG_headerAction{flex:none;align-items:center;display:inline-flex}.DAVtkG_chevron{color:var(--dsw-alias-label-tertiary);flex:none;width:16px;height:16px;transition:transform .16s,color .16s}.DAVtkG_header:hover .DAVtkG_chevron{color:var(--dsw-alias-label-secondary)}.DAVtkG_chevronOpen{transform:rotate(180deg)}.DAVtkG_disclosure{opacity:0;transition:grid-template-rows var(--settings-card-motion) ease, opacity var(--settings-card-motion) ease;grid-template-rows:0fr;display:grid}.DAVtkG_disclosure[data-state=collapsed],.DAVtkG_disclosure[data-state=entering],.DAVtkG_disclosure[data-state=closing]{overflow:hidden}.DAVtkG_disclosure[data-state=entering],.DAVtkG_disclosure[data-state=shown]{opacity:1;grid-template-rows:1fr}.DAVtkG_disclosure>.DAVtkG_body{min-height:0}.DAVtkG_body{border-top:1px solid var(--dsw-alias-border-l2);margin:0 var(--settings-card-body-inset);padding-bottom:8px;container:DAVtkG_settings-card/inline-size}.DAVtkG_readOnly{color:var(--dsw-alias-label-secondary);margin:12px 0 0;font-size:12px;line-height:1.5}.DAVtkG_notExposed{color:var(--dsw-alias-state-warn-primary);margin:12px 0 0;font-size:12px;line-height:1.5}.DAVtkG_failed{color:var(--dsw-alias-state-error-primary,#b42318);overflow-wrap:anywhere;margin:8px 0 4px;font-size:12px;line-height:18px}.DAVtkG_field{grid-template-columns:minmax(0,1fr) fit-content(50%);grid-template-areas:\"DAVtkG_head DAVtkG_control\"\"DAVtkG_hint DAVtkG_control\";align-items:center;gap:4px 24px;padding:16px 0;display:grid}.DAVtkG_field>.DAVtkG_head{grid-area:DAVtkG_head}.DAVtkG_field>:is(.DAVtkG_hint,.DAVtkG_invalid){grid-area:DAVtkG_hint}.DAVtkG_field>:not(.DAVtkG_head,.DAVtkG_hint,.DAVtkG_invalid){grid-area:DAVtkG_control;justify-self:end;max-width:100%}.DAVtkG_field+.DAVtkG_field{border-top:1px solid var(--dsw-alias-border-l2)}.DAVtkG_head{align-items:center;gap:8px;display:flex}.DAVtkG_label{min-width:0;color:var(--dsw-alias-label-primary);flex:1;font-size:14px;font-weight:400;line-height:22px}.DAVtkG_badges{align-items:center;gap:8px;display:inline-flex}.DAVtkG_badge{white-space:nowrap;background:var(--dsw-alias-bg-module-platform);color:var(--dsw-alias-label-secondary);border-radius:999px;padding:1px 8px;font-size:11px;font-weight:500;line-height:17px}.DAVtkG_reset{font:inherit;color:var(--dsw-alias-label-secondary);cursor:pointer;background:0 0;border:none;padding:0;font-size:12px;line-height:1.5}.DAVtkG_reset:hover:not(:disabled){color:var(--dsw-alias-label-primary)}.DAVtkG_reset:disabled{cursor:default}.DAVtkG_reset:focus-visible{outline:2px solid var(--dsw-alias-brand-primary);outline-offset:2px}.DAVtkG_segmentGroup{background:color-mix(in srgb, var(--dsw-alias-label-primary) 7%, transparent);box-shadow:inset 0 0 0 1px color-mix(in srgb, var(--dsw-alias-label-primary) 5%, transparent);border-radius:8px;flex-wrap:wrap;align-items:center;gap:2px;padding:2px;display:inline-flex;position:relative}.DAVtkG_segment{appearance:none;color:var(--dsw-alias-label-secondary);font:inherit;white-space:nowrap;cursor:pointer;background:0 0;border:0;border-radius:7px;margin:0;padding:3px 12px;font-size:13px;font-weight:500;line-height:18px;transition:background-color .12s,color .12s}.DAVtkG_segment:hover:not(:disabled):not([data-active]){color:var(--dsw-alias-label-primary)}.DAVtkG_segmentGroup:not([data-pill])>.DAVtkG_segment[data-active],.DAVtkG_segmentGroup[data-pill]:before{background:var(--dsw-alias-bg-overlay,var(--dsw-alias-bg-layer-3));box-shadow:0 1px 2px #14141314}body[data-ds-dark-theme] .DAVtkG_segmentGroup:not([data-pill])>.DAVtkG_segment[data-active],body[data-ds-dark-theme] .DAVtkG_segmentGroup[data-pill]:before{box-shadow:none;background:#ffffff24}.DAVtkG_segment[data-active]{color:var(--dsw-alias-label-primary)}.DAVtkG_segmentGroup[data-pill]:before{content:\"\";width:var(--segment-pill-w,0px);height:var(--segment-pill-h,0px);transform:translate(var(--segment-pill-x,0px), var(--segment-pill-y,0px));pointer-events:none;border-radius:7px;transition:transform .24s cubic-bezier(.22,.61,.36,1),width .24s cubic-bezier(.22,.61,.36,1),height .24s cubic-bezier(.22,.61,.36,1);position:absolute;top:0;left:0}.DAVtkG_segmentGroup>*{z-index:1;position:relative}.DAVtkG_segment:focus-visible{outline:2px solid var(--dsw-alias-brand-primary);outline-offset:1px}.DAVtkG_segment:disabled{cursor:not-allowed;opacity:.45}.DAVtkG_segmentGroup[data-pill]:has(>.DAVtkG_segment:disabled):before{opacity:.45}.DAVtkG_input,.DAVtkG_select{border:1px solid var(--dsw-alias-border-l2);background:var(--dsw-alias-bg-layer-3);height:34px;font:inherit;color:var(--dsw-alias-label-primary);border-radius:8px;padding:0 12px;font-size:13px;line-height:1.5}.DAVtkG_input:focus-visible,.DAVtkG_select:focus-visible{border-color:var(--dsw-alias-brand-primary);outline:none}.DAVtkG_input:disabled,.DAVtkG_select:disabled{color:var(--dsw-alias-label-tertiary);cursor:default}.DAVtkG_inputInvalid{border:1px solid var(--dsw-alias-state-error-primary,#b42318);background:var(--dsw-alias-bg-layer-3);height:34px;font:inherit;color:var(--dsw-alias-label-primary);border-radius:8px;padding:0 12px;font-size:13px;line-height:1.5}.DAVtkG_inputInvalid:focus-visible{outline:2px solid var(--dsw-alias-state-error-primary,#b42318);outline-offset:1px;border-color:var(--dsw-alias-state-error-primary,#b42318)}.DAVtkG_field>:is(.DAVtkG_input,.DAVtkG_inputInvalid,.DAVtkG_select,.DAVtkG_selectWrap,.DAVtkG_rangeAnchor){box-sizing:border-box;width:220px}.DAVtkG_rangeAnchor>:is(.DAVtkG_input,.DAVtkG_inputInvalid){box-sizing:border-box;width:100%}@container DAVtkG_settings-card (width<=440px){.DAVtkG_field{grid-template-columns:minmax(0,1fr);grid-template-areas:\"DAVtkG_head\"\"DAVtkG_hint\"\"DAVtkG_control\";row-gap:8px}.DAVtkG_field>:not(.DAVtkG_head,.DAVtkG_hint,.DAVtkG_invalid){justify-self:start}.DAVtkG_field>:is(.DAVtkG_input,.DAVtkG_inputInvalid,.DAVtkG_select,.DAVtkG_selectWrap,.DAVtkG_rangeAnchor){justify-self:stretch;width:auto}}.DAVtkG_selectWrap{position:relative}.DAVtkG_selectButton{appearance:none;text-align:left;cursor:pointer;justify-content:space-between;align-items:center;gap:8px;width:100%;display:flex}.DAVtkG_selectLabel{text-overflow:ellipsis;white-space:nowrap;min-width:0;overflow:hidden}.DAVtkG_selectChevron{color:var(--dsw-alias-label-tertiary);flex:none;transition:transform .16s}.DAVtkG_selectChevronOpen{transform:rotate(180deg)}.DAVtkG_selectPopup{z-index:40;border:1px solid var(--dsw-alias-border-l2);background:var(--dsw-alias-bg-layer-3);max-height:240px;box-shadow:0 8px 24px var(--dsw-alias-bg-mask-2);opacity:0;border-radius:8px;flex-direction:column;padding:4px;transition:opacity .1s,transform .1s;display:flex;position:absolute;top:calc(100% + 4px);left:0;right:0;overflow-y:auto;transform:translateY(-4px)}.DAVtkG_selectPopupOpen{opacity:1;transform:none}.DAVtkG_selectPopupClose{opacity:0;pointer-events:none;transform:translateY(-4px)}.DAVtkG_rangeAnchor{display:inline-flex;position:relative}.DAVtkG_rangeBubble{z-index:40;box-sizing:border-box;border:1px solid var(--dsw-alias-border-l2);background:var(--dsw-alias-bg-layer-3);width:220px;box-shadow:0 8px 24px var(--dsw-alias-bg-mask-2);opacity:0;visibility:hidden;border-radius:10px;padding:10px 12px 6px;transition:opacity .12s,transform .12s,visibility 0s linear .12s;position:absolute;right:0}.DAVtkG_rangeBubble[data-side=above]{bottom:calc(100% + 6px);transform:translateY(4px)}.DAVtkG_rangeBubble[data-side=below]{top:calc(100% + 6px);transform:translateY(-4px)}.DAVtkG_rangeBubble[data-open]{opacity:1;visibility:visible;transition:opacity .12s,transform .12s,visibility;transform:none}.DAVtkG_rangeSlider{appearance:none;cursor:pointer;background:0 0;width:100%;height:18px;margin:0;display:block}.DAVtkG_rangeSlider::-webkit-slider-runnable-track{background:linear-gradient(to right, var(--dsw-alias-brand-primary) var(--range-fill,0%), color-mix(in srgb, var(--dsw-alias-label-primary) 12%, transparent) var(--range-fill,0%));border-radius:999px;height:4px}.DAVtkG_rangeSlider::-moz-range-track{background:color-mix(in srgb, var(--dsw-alias-label-primary) 12%, transparent);border-radius:999px;height:4px}.DAVtkG_rangeSlider::-moz-range-progress{background:var(--dsw-alias-brand-primary);border-radius:999px;height:4px}.DAVtkG_rangeSlider::-webkit-slider-thumb{appearance:none;background:#fff;border:0;border-radius:50%;width:14px;height:14px;margin-top:-5px;transition:transform .12s;box-shadow:0 0 0 1px #0000001f,0 1px 3px #00000040}.DAVtkG_rangeSlider::-moz-range-thumb{background:#fff;border:0;border-radius:50%;width:14px;height:14px;box-shadow:0 0 0 1px #0000001f,0 1px 3px #00000040}.DAVtkG_rangeSlider:active::-webkit-slider-thumb{transform:scale(1.15)}.DAVtkG_rangeSlider:focus-visible{outline:none}.DAVtkG_rangeSlider:focus-visible::-webkit-slider-thumb{box-shadow:0 0 0 2px var(--dsw-alias-brand-primary)}.DAVtkG_rangeSlider:disabled{cursor:not-allowed}.DAVtkG_rangeEnds{color:var(--dsw-alias-label-secondary);font-variant-numeric:tabular-nums;justify-content:space-between;margin-top:2px;font-size:11px;line-height:16px;display:flex}.DAVtkG_selectOption{color:var(--dsw-alias-label-primary);cursor:pointer;white-space:nowrap;text-overflow:ellipsis;border-radius:6px;flex-shrink:0;padding:6px 10px;font-size:13px;line-height:1.5;overflow:hidden}.DAVtkG_selectOption:hover,.DAVtkG_selectOptionActive{background:var(--dsw-alias-interactive-bg-hover)}.DAVtkG_selectOptionSelected{color:var(--dsw-alias-brand-primary);background:color-mix(in srgb, var(--dsw-alias-brand-primary) 10%, transparent);font-weight:500}.DAVtkG_invalid{color:var(--dsw-alias-state-error-primary,#b42318);margin:0;font-size:12px;line-height:18px}.DAVtkG_hint{color:var(--dsw-alias-label-secondary);margin:0;font-size:12px;line-height:18px}.DAVtkG_toggle{appearance:none;cursor:pointer;font:inherit;background:0 0;border:0;border-radius:999px;align-items:center;margin:0;padding:0;display:inline-flex}.DAVtkG_toggleTrack{background:var(--dsw-alias-label-dimmed);border-radius:999px;flex:none;width:36px;height:20px;transition:background-color .18s;position:relative}.DAVtkG_toggleThumb{--toggle-travel:16px;--toggle-overshoot:1px;background:var(--dsw-alias-bg-layer-3);border-radius:50%;width:16px;height:16px;transition:translate .18s;position:absolute;top:2px;left:2px;translate:0;box-shadow:0 1px 2px #1414132e}.DAVtkG_toggle[aria-checked=true] .DAVtkG_toggleTrack{background:var(--dsw-alias-button-primary-fill,var(--dsw-alias-label-primary))}.DAVtkG_toggle[aria-checked=true] .DAVtkG_toggleThumb{translate:var(--toggle-travel) 0;background:var(--dsw-alias-label-primary-foreground,var(--dsw-alias-bg-layer-3))}.DAVtkG_toggle[data-moved][aria-checked=true] .DAVtkG_toggleThumb{animation:.35s cubic-bezier(.34,1.45,.64,1) both DAVtkG_toggle-on}.DAVtkG_toggle[data-moved][aria-checked=false] .DAVtkG_toggleThumb{animation:.35s cubic-bezier(.34,1.45,.64,1) both DAVtkG_toggle-off}@keyframes DAVtkG_toggle-on{0%{translate:0}55%{translate:calc(var(--toggle-travel) + var(--toggle-overshoot)) 0}80%,to{translate:var(--toggle-travel) 0}}@keyframes DAVtkG_toggle-off{0%{translate:var(--toggle-travel) 0}55%{translate:calc(0px - var(--toggle-overshoot)) 0}80%,to{translate:0}}.DAVtkG_toggle:focus-visible{outline:2px solid var(--dsw-alias-brand-primary);outline-offset:2px}.DAVtkG_toggle:disabled{opacity:.45;cursor:not-allowed}@media (prefers-reduced-motion:reduce){.DAVtkG_card,.DAVtkG_header,.DAVtkG_mark,.DAVtkG_chevron,.DAVtkG_chevronOpen,.DAVtkG_rangeBubble,.DAVtkG_selectChevron,.DAVtkG_selectChevronOpen,.DAVtkG_selectPopup,.DAVtkG_toggleTrack,.DAVtkG_toggleThumb{transition:none}.DAVtkG_toggle[data-moved] .DAVtkG_toggleThumb{animation:none}.DAVtkG_disclosure{transition-property:opacity}}";
12
+ const tagId$1 = "@linxin666/dsh-client-ui-task-board-ssh/packages/dsh-task-board-ssh/src/client/settings-card.module.css";
13
+ if (typeof document !== "undefined" && document.querySelector("style[data-plugin-css=" + JSON.stringify(tagId$1) + "]") === null) {
14
+ const tag = document.createElement("style");
15
+ tag.dataset.plugin = "@linxin666/dsh-client-ui-task-board-ssh";
16
+ tag.dataset.pluginCss = tagId$1;
17
+ tag.textContent = css$1;
18
+ document.head.appendChild(tag);
19
+ }
20
+ var settings_card_module_css_default = {
21
+ "badge": "DAVtkG_badge",
22
+ "badges": "DAVtkG_badges",
23
+ "body": "DAVtkG_body",
24
+ "card": "DAVtkG_card",
25
+ "cardNested": "DAVtkG_cardNested",
26
+ "cardOpen": "DAVtkG_cardOpen",
27
+ "chevron": "DAVtkG_chevron",
28
+ "chevronOpen": "DAVtkG_chevronOpen",
29
+ "control": "DAVtkG_control",
30
+ "description": "DAVtkG_description",
31
+ "disclosure": "DAVtkG_disclosure",
32
+ "failed": "DAVtkG_failed",
33
+ "field": "DAVtkG_field",
34
+ "head": "DAVtkG_head",
35
+ "headText": "DAVtkG_headText",
36
+ "header": "DAVtkG_header",
37
+ "headerAction": "DAVtkG_headerAction",
38
+ "headerStatic": "DAVtkG_headerStatic",
39
+ "hint": "DAVtkG_hint",
40
+ "input": "DAVtkG_input",
41
+ "inputInvalid": "DAVtkG_inputInvalid",
42
+ "invalid": "DAVtkG_invalid",
43
+ "label": "DAVtkG_label",
44
+ "mark": "DAVtkG_mark",
45
+ "name": "DAVtkG_name",
46
+ "notExposed": "DAVtkG_notExposed",
47
+ "rangeAnchor": "DAVtkG_rangeAnchor",
48
+ "rangeBubble": "DAVtkG_rangeBubble",
49
+ "rangeEnds": "DAVtkG_rangeEnds",
50
+ "rangeSlider": "DAVtkG_rangeSlider",
51
+ "readOnly": "DAVtkG_readOnly",
52
+ "reset": "DAVtkG_reset",
53
+ "segment": "DAVtkG_segment",
54
+ "segmentGroup": "DAVtkG_segmentGroup",
55
+ "select": "DAVtkG_select",
56
+ "selectButton": "DAVtkG_selectButton",
57
+ "selectChevron": "DAVtkG_selectChevron",
58
+ "selectChevronOpen": "DAVtkG_selectChevronOpen",
59
+ "selectLabel": "DAVtkG_selectLabel",
60
+ "selectOption": "DAVtkG_selectOption",
61
+ "selectOptionActive": "DAVtkG_selectOptionActive",
62
+ "selectOptionSelected": "DAVtkG_selectOptionSelected",
63
+ "selectPopup": "DAVtkG_selectPopup",
64
+ "selectPopupClose": "DAVtkG_selectPopupClose",
65
+ "selectPopupOpen": "DAVtkG_selectPopupOpen",
66
+ "selectWrap": "DAVtkG_selectWrap",
67
+ "settings-card": "DAVtkG_settings-card",
68
+ "toggle": "DAVtkG_toggle",
69
+ "toggle-off": "DAVtkG_toggle-off",
70
+ "toggle-on": "DAVtkG_toggle-on",
71
+ "toggleThumb": "DAVtkG_toggleThumb",
72
+ "toggleTrack": "DAVtkG_toggleTrack"
73
+ };
74
+ //#endregion
75
+ //#region src/client/RangeBubble.tsx
76
+ /**
77
+ * Coarse adjustment for a bounded number: resting the pointer on the control
78
+ * (or moving focus into it) raises a small bubble holding a slider across the
79
+ * field's whole range, so a large change is one drag instead of many presses
80
+ * or a retyped value. The control itself stays the precise entry.
81
+ *
82
+ * The bubble belongs to the anchor's subtree, so moving from the control onto
83
+ * the bubble never counts as leaving. It opens after a short rest and closes a
84
+ * moment after the pointer and focus have both gone, so crossing the control
85
+ * on the way elsewhere does not flash it. While a drag is in progress the
86
+ * bubble stays put even if the pointer strays off it.
87
+ *
88
+ * Dragging reports each value through `onInput`, so the field shows it live;
89
+ * releasing the thumb, or a key press on it, reports `onCommit` once. The
90
+ * bubble opens on the side of the control that has room inside the nearest
91
+ * scrolling ancestor, so a row near the top of a settings page does not hang
92
+ * its bubble under the page edge.
93
+ */
94
+ /** Rest on the control before the bubble opens. */
95
+ const OPEN_DELAY_MS = 220;
96
+ /** Grace after pointer and focus have left before the bubble closes. */
97
+ const CLOSE_DELAY_MS = 200;
98
+ /** Room the bubble needs between the control and the scroller's edge. */
99
+ const BUBBLE_ROOM_PX = 64;
100
+ /** The nearest ancestor that scrolls vertically, or the viewport's root. */
101
+ function scroller(node) {
102
+ for (let parent = node.parentElement; parent !== null; parent = parent.parentElement) {
103
+ const overflow = getComputedStyle(parent).overflowY;
104
+ if (overflow === "auto" || overflow === "scroll") return parent;
105
+ }
106
+ return node.ownerDocument.documentElement;
107
+ }
108
+ /**
109
+ * Render the control with its coarse-adjustment bubble.
110
+ * @param props - the range, the value and the two report callbacks.
111
+ * @returns the anchor holding the control and the bubble.
112
+ */
113
+ function RangeBubble(props) {
114
+ const { min, max, step, disabled = false } = props;
115
+ const [open, setOpen] = (0, react.useState)(false);
116
+ const [side, setSide] = (0, react.useState)("above");
117
+ const [live, setLive] = (0, react.useState)(null);
118
+ const anchorRef = (0, react.useRef)(null);
119
+ const timer = (0, react.useRef)(void 0);
120
+ const hovered = (0, react.useRef)(false);
121
+ const focused = (0, react.useRef)(false);
122
+ const dragging = (0, react.useRef)(false);
123
+ (0, react.useEffect)(() => () => {
124
+ clearTimeout(timer.current);
125
+ }, []);
126
+ (0, react.useEffect)(() => {
127
+ if (disabled) {
128
+ clearTimeout(timer.current);
129
+ setOpen(false);
130
+ }
131
+ }, [disabled]);
132
+ const show = () => {
133
+ const anchor = anchorRef.current;
134
+ if (anchor !== null) {
135
+ const room = anchor.getBoundingClientRect().top - scroller(anchor).getBoundingClientRect().top;
136
+ setSide(room >= BUBBLE_ROOM_PX ? "above" : "below");
137
+ }
138
+ setOpen(true);
139
+ };
140
+ const schedule = () => {
141
+ clearTimeout(timer.current);
142
+ if (disabled) return;
143
+ if (hovered.current || focused.current || dragging.current) {
144
+ if (!open) timer.current = setTimeout(show, focused.current ? 0 : OPEN_DELAY_MS);
145
+ return;
146
+ }
147
+ timer.current = setTimeout(() => {
148
+ setOpen(false);
149
+ }, CLOSE_DELAY_MS);
150
+ };
151
+ const commit = (value) => {
152
+ dragging.current = false;
153
+ setLive(null);
154
+ props.onCommit(value);
155
+ schedule();
156
+ };
157
+ const onChange = (event) => {
158
+ const value = Number(event.target.value);
159
+ setLive(value);
160
+ props.onInput(value);
161
+ };
162
+ const onKeyUp = (event) => {
163
+ if (live !== null) commit(live);
164
+ if (event.key === "Escape") {
165
+ clearTimeout(timer.current);
166
+ setOpen(false);
167
+ }
168
+ };
169
+ const shown = live ?? Math.min(max, Math.max(min, props.value));
170
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
171
+ ref: anchorRef,
172
+ className: settings_card_module_css_default.rangeAnchor,
173
+ onPointerEnter: () => {
174
+ hovered.current = true;
175
+ schedule();
176
+ },
177
+ onPointerLeave: () => {
178
+ hovered.current = false;
179
+ schedule();
180
+ },
181
+ onFocus: () => {
182
+ focused.current = true;
183
+ schedule();
184
+ },
185
+ onBlur: (event) => {
186
+ if (event.currentTarget.contains(event.relatedTarget)) return;
187
+ focused.current = false;
188
+ if (live !== null) commit(live);
189
+ else schedule();
190
+ },
191
+ children: [props.children, /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
192
+ className: settings_card_module_css_default.rangeBubble,
193
+ "data-open": open ? "" : void 0,
194
+ "data-side": side,
195
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
196
+ type: "range",
197
+ className: settings_card_module_css_default.rangeSlider,
198
+ min,
199
+ max,
200
+ step,
201
+ value: shown,
202
+ "aria-label": props.label,
203
+ tabIndex: open ? 0 : -1,
204
+ disabled,
205
+ style: { "--range-fill": `${(shown - min) / (max - min) * 100}%` },
206
+ onPointerDown: () => {
207
+ dragging.current = true;
208
+ },
209
+ onPointerUp: (event) => {
210
+ commit(Number(event.currentTarget.value));
211
+ },
212
+ onPointerCancel: (event) => {
213
+ commit(Number(event.currentTarget.value));
214
+ },
215
+ onChange,
216
+ onKeyUp
217
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
218
+ className: settings_card_module_css_default.rangeEnds,
219
+ "aria-hidden": "true",
220
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: min }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: max })]
221
+ })]
222
+ })]
223
+ });
224
+ }
225
+ //#endregion
226
+ //#region src/client/SegmentGroup.tsx
227
+ /**
228
+ * The family's segmented control: a quiet track whose options share one
229
+ * highlight that slides to the pressed option, instead of each option fading
230
+ * its own background out and the next one in. The settings fields' small
231
+ * choices and the Web Extensions TAB strip both render through it, so the two
232
+ * read as one control.
233
+ *
234
+ * The caller builds the option buttons and marks the pressed one with
235
+ * `data-active`; the group measures that button after every render and writes
236
+ * its box as four custom properties, and the stylesheet draws the highlight
237
+ * there (`.segmentGroup[data-pill]::before`). Attribute and first placement
238
+ * land in the same task, so the highlight appears in place and only later
239
+ * changes slide. A ResizeObserver re-measures when the group or an option
240
+ * changes size: a longer locale, a font arriving, a container growing, a
241
+ * strip wrapping onto a second line.
242
+ */
243
+ /** The attribute marking a group whose highlight has been placed. */
244
+ const PILL_ATTR = "data-pill";
245
+ /** The pressed option, relative to the group. */
246
+ const ACTIVE_SELECTOR = ":scope > [data-active]";
247
+ const PILL_PROPERTIES = [
248
+ "--segment-pill-x",
249
+ "--segment-pill-y",
250
+ "--segment-pill-w",
251
+ "--segment-pill-h"
252
+ ];
253
+ /**
254
+ * Write the highlight's box from the pressed option's box, or take the
255
+ * highlight off when nothing is pressed or the group has no layout yet.
256
+ * The two boxes are read in viewport pixels and turned back into the group's
257
+ * own CSS pixels, so a dialog that opens through a scale transform still
258
+ * lands the highlight on its option.
259
+ */
260
+ function placePill(group) {
261
+ const item = group.querySelector(ACTIVE_SELECTOR);
262
+ const box = group.getBoundingClientRect();
263
+ if (item === null || group.offsetWidth === 0 || box.width === 0) {
264
+ group.removeAttribute(PILL_ATTR);
265
+ for (const property of PILL_PROPERTIES) group.style.removeProperty(property);
266
+ return;
267
+ }
268
+ const scale = box.width / group.offsetWidth;
269
+ const itemBox = item.getBoundingClientRect();
270
+ [
271
+ (itemBox.left - box.left) / scale - group.clientLeft,
272
+ (itemBox.top - box.top) / scale - group.clientTop,
273
+ itemBox.width / scale,
274
+ itemBox.height / scale
275
+ ].forEach((value, index) => {
276
+ group.style.setProperty(PILL_PROPERTIES[index], `${Math.round(value * 100) / 100}px`);
277
+ });
278
+ if (!group.hasAttribute(PILL_ATTR)) group.setAttribute(PILL_ATTR, "");
279
+ }
280
+ /**
281
+ * Render a segmented track around the caller's option buttons.
282
+ * @param props - the track's attributes (role, accessible name, key handler) and its options.
283
+ * @returns the track.
284
+ */
285
+ function SegmentGroup(props) {
286
+ const { children, className, ...rest } = props;
287
+ const group = (0, react.useRef)(null);
288
+ const count = react.Children.count(children);
289
+ (0, react.useLayoutEffect)(() => {
290
+ if (group.current !== null) placePill(group.current);
291
+ });
292
+ (0, react.useLayoutEffect)(() => {
293
+ const element = group.current;
294
+ if (element === null || typeof ResizeObserver === "undefined") return void 0;
295
+ const observer = new ResizeObserver(() => {
296
+ placePill(element);
297
+ });
298
+ observer.observe(element);
299
+ for (const item of Array.from(element.children)) observer.observe(item);
300
+ return () => {
301
+ observer.disconnect();
302
+ };
303
+ }, [count]);
304
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
305
+ ...rest,
306
+ ref: group,
307
+ className: className === void 0 ? settings_card_module_css_default.segmentGroup : `${settings_card_module_css_default.segmentGroup} ${className}`,
308
+ children
309
+ });
310
+ }
311
+ //#endregion
312
+ //#region src/client/PluginSettingsCard.tsx
313
+ /**
314
+ * Family-shared chrome for plugin settings cards: a disclosure header naming
315
+ * the plugin and what its settings govern, the controls inside, and the line
316
+ * that reports a refused write. A pick is written the moment it is made and a
317
+ * typed value after a pause, so the card has no save button and nothing waits
318
+ * on the reader. Renders nothing while the namespace is unavailable — a
319
+ * deployment that does not compose the owning plugin should show no trace of
320
+ * it. Inlined into each consumer's client bundle; mirrors the official
321
+ * ui-plugin-config PluginCard in a self-contained slice.
322
+ *
323
+ * Every field inside the body is one settings row: the label and its hint on
324
+ * the left, the control on the right, a hairline between two rows; a narrow
325
+ * card stacks the control under the text (settings-card.module.css).
326
+ */
327
+ /**
328
+ * What a text field inside a card reaches without its plugin wiring it: write
329
+ * the pending draft now (Enter, leaving the field) or put it back (Escape).
330
+ * Picks need neither; they are written the moment they are made.
331
+ */
332
+ const CardApply = (0, react.createContext)(null);
333
+ /** Length of the body's disclosure motion; it matches `--settings-card-motion` on the card root. */
334
+ const BODY_MOTION_MS = 180;
335
+ /**
336
+ * Render one plugin settings card.
337
+ * @param props - the plugin's copy keys, its form state, and its controls.
338
+ * @returns the card, or nothing while the namespace is still loading.
339
+ */
340
+ function PluginSettingsCard(props) {
341
+ const [open, setOpen] = (0, react.useState)(props.defaultOpen ?? true);
342
+ const { state, alwaysOpen } = props;
343
+ const expanded = alwaysOpen === true || open;
344
+ const [bodyPhase, setBodyPhase] = (0, react.useState)(expanded ? "shown" : "hidden");
345
+ const bodyRef = (0, react.useRef)(null);
346
+ (0, react.useLayoutEffect)(() => {
347
+ if (expanded) {
348
+ if (bodyPhase === "hidden") setBodyPhase("collapsed");
349
+ else if (bodyPhase === "collapsed") {
350
+ const node = bodyRef.current;
351
+ if (node !== null) node.offsetHeight;
352
+ setBodyPhase("entering");
353
+ } else if (bodyPhase === "closing") setBodyPhase("entering");
354
+ return;
355
+ }
356
+ if (bodyPhase === "collapsed") setBodyPhase("hidden");
357
+ else if (bodyPhase === "entering" || bodyPhase === "shown") setBodyPhase("closing");
358
+ }, [expanded, bodyPhase]);
359
+ (0, react.useEffect)(() => {
360
+ if (bodyPhase !== "entering" && bodyPhase !== "closing") return;
361
+ const timer = setTimeout(() => {
362
+ setBodyPhase(bodyPhase === "entering" ? "shown" : "hidden");
363
+ }, BODY_MOTION_MS);
364
+ return () => {
365
+ clearTimeout(timer);
366
+ };
367
+ }, [bodyPhase]);
368
+ if (!state.available) return null;
369
+ const title = props.t(props.titleKey);
370
+ const description = props.t(props.descriptionKey);
371
+ const descriptionTitle = props.descriptionTitleKey === void 0 ? description : props.t(props.descriptionTitleKey);
372
+ const baseClass = expanded ? `${settings_card_module_css_default.cardOpen} ${settings_card_module_css_default.card}` : settings_card_module_css_default.card;
373
+ const cardClass = props.density === "nested" ? `${baseClass} ${settings_card_module_css_default.cardNested}` : baseClass;
374
+ /** The body region both legs share; a hidden phase renders nothing at all. */
375
+ const bodyRegion = (content) => bodyPhase === "hidden" ? null : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
376
+ className: settings_card_module_css_default.disclosure,
377
+ "data-state": bodyPhase,
378
+ ref: bodyRef,
379
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
380
+ className: settings_card_module_css_default.body,
381
+ children: content
382
+ })
383
+ });
384
+ const header = alwaysOpen === true ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
385
+ className: settings_card_module_css_default.headerStatic,
386
+ children: [
387
+ props.icon !== void 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
388
+ className: settings_card_module_css_default.mark,
389
+ "aria-hidden": "true",
390
+ children: props.icon
391
+ }) : null,
392
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
393
+ className: settings_card_module_css_default.headText,
394
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
395
+ className: settings_card_module_css_default.name,
396
+ id: props.titleId,
397
+ title,
398
+ children: title
399
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
400
+ className: settings_card_module_css_default.description,
401
+ title: descriptionTitle,
402
+ children: props.descriptionNode ?? description
403
+ })]
404
+ }),
405
+ props.headerAction !== void 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
406
+ className: settings_card_module_css_default.headerAction,
407
+ children: props.headerAction
408
+ }) : null
409
+ ]
410
+ }) : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
411
+ type: "button",
412
+ className: settings_card_module_css_default.header,
413
+ "aria-expanded": open,
414
+ "aria-label": `${props.t(open ? "settings.collapse" : "settings.expand")}: ${title}`,
415
+ onClick: () => {
416
+ setOpen(!open);
417
+ },
418
+ children: [
419
+ props.icon !== void 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
420
+ className: settings_card_module_css_default.mark,
421
+ "aria-hidden": "true",
422
+ children: props.icon
423
+ }) : null,
424
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
425
+ className: settings_card_module_css_default.headText,
426
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
427
+ className: settings_card_module_css_default.name,
428
+ id: props.titleId,
429
+ title,
430
+ children: title
431
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
432
+ className: settings_card_module_css_default.description,
433
+ title: descriptionTitle,
434
+ children: props.descriptionNode ?? description
435
+ })]
436
+ }),
437
+ props.headerAction !== void 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
438
+ className: settings_card_module_css_default.headerAction,
439
+ children: props.headerAction
440
+ }) : null,
441
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("svg", {
442
+ width: "14",
443
+ height: "14",
444
+ viewBox: "0 0 14 14",
445
+ fill: "none",
446
+ xmlns: "http://www.w3.org/2000/svg",
447
+ className: open ? `${settings_card_module_css_default.chevron} ${settings_card_module_css_default.chevronOpen}` : settings_card_module_css_default.chevron,
448
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", {
449
+ d: "M11.8486 5.5L11.4238 5.92383L8.69727 8.65137C8.44157 8.90706 8.21562 9.13382 8.01172 9.29785C7.79912 9.46883 7.55595 9.61756 7.25 9.66602C7.08435 9.69222 6.91565 9.69222 6.75 9.66602C6.44405 9.61756 6.20088 9.46883 5.98828 9.29785C5.78438 9.13382 5.55843 8.90706 5.30273 8.65137L2.57617 5.92383L2.15137 5.5L3 4.65137L3.42383 5.07617L6.15137 7.80273C6.42595 8.07732 6.59876 8.24849 6.74023 8.3623C6.87291 8.46904 6.92272 8.47813 6.9375 8.48047C6.97895 8.48703 7.02105 8.48703 7.0625 8.48047C7.07728 8.47813 7.12709 8.46904 7.25977 8.3623C7.40124 8.24849 7.57405 8.07732 7.84863 7.80273L10.5762 5.07617L11 4.65137L11.8486 5.5Z",
450
+ fill: "currentColor"
451
+ })
452
+ })
453
+ ]
454
+ });
455
+ const notExposedNotice = state.exposed || props.hideNotExposedNotice === true ? null : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
456
+ className: settings_card_module_css_default.notExposed,
457
+ role: "status",
458
+ children: props.t("settings.notExposed")
459
+ });
460
+ if (!state.exposed && props.renderChildrenWhenNotExposed !== true) return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("li", {
461
+ className: cardClass,
462
+ children: [header, bodyRegion(notExposedNotice)]
463
+ });
464
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("li", {
465
+ className: cardClass,
466
+ children: [header, props.headerOnly !== true ? bodyRegion(/* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
467
+ notExposedNotice,
468
+ !state.writable ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
469
+ className: settings_card_module_css_default.readOnly,
470
+ role: "status",
471
+ children: props.t("settings.readOnly")
472
+ }) : null,
473
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CardApply.Provider, {
474
+ value: {
475
+ commit: props.onSave,
476
+ revert: props.onDiscard
477
+ },
478
+ children: props.children
479
+ }),
480
+ props.hideFooter !== true && state.failed ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("p", {
481
+ className: settings_card_module_css_default.failed,
482
+ role: "status",
483
+ children: [props.t("settings.saveFailed"), state.failedReason ? " - " + state.failedReason : ""]
484
+ }) : null
485
+ ] })) : null]
486
+ });
487
+ }
488
+ /**
489
+ * A typed value field. Its draft is written after a pause in typing, at once on
490
+ * Enter or when focus leaves, and Escape puts the stored value back. `numeric`
491
+ * only hints the keypad: which drafts a field accepts is decided by its spec.
492
+ * A field given a `range` also offers the coarse slider bubble: dragging fills
493
+ * the draft live and releasing writes it.
494
+ */
495
+ function ValueField(props) {
496
+ const apply = (0, react.useContext)(CardApply);
497
+ const settledByKey = (0, react.useRef)(false);
498
+ const onKeyDown = (event) => {
499
+ if (apply === null || event.key !== "Enter" && event.key !== "Escape") return;
500
+ event.preventDefault();
501
+ settledByKey.current = true;
502
+ if (event.key === "Enter") apply.commit();
503
+ else apply.revert();
504
+ event.currentTarget.blur();
505
+ };
506
+ const input = /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
507
+ id: props.id,
508
+ className: props.invalid ? settings_card_module_css_default.inputInvalid : settings_card_module_css_default.input,
509
+ type: "text",
510
+ ...props.numeric === true ? { inputMode: "numeric" } : {},
511
+ ...props.invalid ? { "aria-invalid": true } : {},
512
+ value: props.text,
513
+ placeholder: props.placeholder ?? "",
514
+ disabled: props.disabled,
515
+ onChange: (event) => {
516
+ props.onEdit(event.target.value);
517
+ },
518
+ onKeyDown,
519
+ onFocus: () => {
520
+ settledByKey.current = false;
521
+ },
522
+ onBlur: () => {
523
+ if (settledByKey.current) {
524
+ settledByKey.current = false;
525
+ return;
526
+ }
527
+ apply?.commit();
528
+ }
529
+ });
530
+ const { range } = props;
531
+ const typed = Number(props.text);
532
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
533
+ className: settings_card_module_css_default.field,
534
+ children: [
535
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
536
+ className: settings_card_module_css_default.head,
537
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("label", {
538
+ className: settings_card_module_css_default.label,
539
+ htmlFor: props.id,
540
+ children: props.label
541
+ }), props.overridden ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
542
+ className: settings_card_module_css_default.badges,
543
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
544
+ className: settings_card_module_css_default.badge,
545
+ children: props.overriddenLabel
546
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
547
+ type: "button",
548
+ className: settings_card_module_css_default.reset,
549
+ disabled: props.disabled,
550
+ onClick: props.onReset,
551
+ children: props.resetLabel
552
+ })]
553
+ }) : null]
554
+ }),
555
+ range === void 0 ? input : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(RangeBubble, {
556
+ min: range.min,
557
+ max: range.max,
558
+ step: range.step,
559
+ value: props.text.trim() === "" || Number.isNaN(typed) ? range.min : typed,
560
+ label: `${props.label} ${range.min}–${range.max}`,
561
+ disabled: props.disabled,
562
+ onInput: (value) => {
563
+ props.onEdit(String(value));
564
+ },
565
+ onCommit: (value) => {
566
+ props.onEdit(String(value));
567
+ apply?.commit();
568
+ },
569
+ children: input
570
+ }),
571
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
572
+ className: props.invalid ? settings_card_module_css_default.invalid : settings_card_module_css_default.hint,
573
+ title: props.hintTitle,
574
+ children: props.invalid ? props.invalidLabel : props.hint
575
+ })
576
+ ]
577
+ });
578
+ }
579
+ const NON_SKIN_BODY_MARKERS = /* @__PURE__ */ new Set(["dshSkinCenter", "dshSidebarCollapsed"]);
580
+ function isSkinActive() {
581
+ return Object.keys(document.body.dataset).some((key) => key.startsWith("dsh") && !NON_SKIN_BODY_MARKERS.has(key));
582
+ }
583
+ const SELECT_CLOSE_MS = 100;
584
+ /**
585
+ * The shared dual-mode select control. While an appearance skin is active it
586
+ * renders the legacy native `<select>` untouched, so element-level skin
587
+ * selectors keep working; under the default appearance it renders a
588
+ * self-drawn `role="listbox"` popup whose open/close is transition-animated.
589
+ * Cards reach it through BooleanField/ChoiceField; editors outside a card
590
+ * (the side-card prefs) bind it directly through onEdit.
591
+ * 双模式下拉框:皮肤激活时用原生 select,默认外观用自绘动画弹层。
592
+ */
593
+ function SelectField(props) {
594
+ const { id, options, value } = props;
595
+ const [open, setOpen] = (0, react.useState)(false);
596
+ const [closing, setClosing] = (0, react.useState)(false);
597
+ const [phase, setPhase] = (0, react.useState)("initial");
598
+ const [activeIndex, setActiveIndex] = (0, react.useState)(0);
599
+ const closeTimer = (0, react.useRef)(void 0);
600
+ const wrapRef = (0, react.useRef)(null);
601
+ const popupRef = (0, react.useRef)(null);
602
+ const currentIndex = () => {
603
+ const index = options.findIndex((option) => option.value === value);
604
+ return index >= 0 ? index : 0;
605
+ };
606
+ const close = (0, react.useCallback)(() => {
607
+ if (closeTimer.current !== void 0) clearTimeout(closeTimer.current);
608
+ setClosing(true);
609
+ closeTimer.current = setTimeout(() => {
610
+ setClosing(false);
611
+ setOpen(false);
612
+ }, SELECT_CLOSE_MS);
613
+ }, []);
614
+ const openPopup = () => {
615
+ if (closeTimer.current !== void 0) clearTimeout(closeTimer.current);
616
+ setActiveIndex(currentIndex());
617
+ setPhase("initial");
618
+ setClosing(false);
619
+ setOpen(true);
620
+ };
621
+ const commit = (index) => {
622
+ const option = options[index];
623
+ if (option) props.onEdit(option.value);
624
+ close();
625
+ };
626
+ const onTriggerClick = () => {
627
+ if (props.disabled) return;
628
+ if (open && !closing) close();
629
+ else openPopup();
630
+ };
631
+ const onKeyDown = (event) => {
632
+ if (props.disabled) return;
633
+ const count = options.length;
634
+ switch (event.key) {
635
+ case "ArrowDown":
636
+ case "ArrowUp":
637
+ case "Enter":
638
+ case " ":
639
+ event.preventDefault();
640
+ if (!open) openPopup();
641
+ else if (!closing) if (event.key === "ArrowDown") setActiveIndex((index) => (index + 1) % count);
642
+ else if (event.key === "ArrowUp") setActiveIndex((index) => (index - 1 + count) % count);
643
+ else commit(activeIndex);
644
+ break;
645
+ case "Escape":
646
+ if (open) {
647
+ event.preventDefault();
648
+ event.stopPropagation();
649
+ close();
650
+ }
651
+ break;
652
+ case "Tab":
653
+ if (open) close();
654
+ break;
655
+ }
656
+ };
657
+ (0, react.useEffect)(() => () => {
658
+ if (closeTimer.current !== void 0) clearTimeout(closeTimer.current);
659
+ }, []);
660
+ (0, react.useLayoutEffect)(() => {
661
+ if (open && !closing && phase === "initial") {
662
+ popupRef.current?.offsetHeight;
663
+ setPhase("open");
664
+ }
665
+ }, [
666
+ open,
667
+ closing,
668
+ phase
669
+ ]);
670
+ (0, react.useEffect)(() => {
671
+ if (!open) return;
672
+ const onPointerDown = (event) => {
673
+ const target = event.target;
674
+ if (target instanceof Node && !wrapRef.current?.contains(target)) close();
675
+ };
676
+ document.addEventListener("pointerdown", onPointerDown);
677
+ return () => document.removeEventListener("pointerdown", onPointerDown);
678
+ }, [open, close]);
679
+ (0, react.useEffect)(() => {
680
+ if (props.disabled && open) close();
681
+ }, [
682
+ props.disabled,
683
+ open,
684
+ close
685
+ ]);
686
+ if (isSkinActive()) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("select", {
687
+ id,
688
+ className: settings_card_module_css_default.select,
689
+ value,
690
+ disabled: props.disabled,
691
+ onChange: (event) => {
692
+ props.onEdit(event.target.value);
693
+ },
694
+ children: options.map((option) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("option", {
695
+ value: option.value,
696
+ children: option.label
697
+ }, option.value))
698
+ });
699
+ const label = options.find((option) => option.value === value)?.label ?? "";
700
+ const popupClass = closing ? `${settings_card_module_css_default.selectPopup} ${settings_card_module_css_default.selectPopupClose}` : phase === "open" ? `${settings_card_module_css_default.selectPopup} ${settings_card_module_css_default.selectPopupOpen}` : settings_card_module_css_default.selectPopup;
701
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
702
+ className: settings_card_module_css_default.selectWrap,
703
+ ref: wrapRef,
704
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
705
+ type: "button",
706
+ id,
707
+ className: `${settings_card_module_css_default.select} ${settings_card_module_css_default.selectButton}`,
708
+ disabled: props.disabled,
709
+ "aria-haspopup": "listbox",
710
+ "aria-expanded": open,
711
+ "aria-activedescendant": open ? `${id}-o${activeIndex}` : void 0,
712
+ "aria-invalid": props.invalid || void 0,
713
+ onClick: onTriggerClick,
714
+ onKeyDown,
715
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
716
+ className: settings_card_module_css_default.selectLabel,
717
+ children: label
718
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("svg", {
719
+ width: "14",
720
+ height: "14",
721
+ viewBox: "0 0 14 14",
722
+ fill: "none",
723
+ xmlns: "http://www.w3.org/2000/svg",
724
+ className: open ? `${settings_card_module_css_default.selectChevron} ${settings_card_module_css_default.selectChevronOpen}` : settings_card_module_css_default.selectChevron,
725
+ "aria-hidden": "true",
726
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", {
727
+ d: "M11.8486 5.5L11.4238 5.92383L8.69727 8.65137C8.44157 8.90706 8.21562 9.13382 8.01172 9.29785C7.79912 9.46883 7.55595 9.61756 7.25 9.66602C7.08435 9.69222 6.91565 9.69222 6.75 9.66602C6.44405 9.61756 6.20088 9.46883 5.98828 9.29785C5.78438 9.13382 5.55843 8.90706 5.30273 8.65137L2.57617 5.92383L2.15137 5.5L3 4.65137L3.42383 5.07617L6.15137 7.80273C6.42595 8.07732 6.59876 8.24849 6.74023 8.3623C6.87291 8.46904 6.92272 8.47813 6.9375 8.48047C6.97895 8.48703 7.02105 8.48703 7.0625 8.48047C7.07728 8.47813 7.12709 8.46904 7.25977 8.3623C7.40124 8.24849 7.57405 8.07732 7.84863 7.80273L10.5762 5.07617L11 4.65137L11.8486 5.5Z",
728
+ fill: "currentColor"
729
+ })
730
+ })]
731
+ }), open ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
732
+ className: popupClass,
733
+ role: "listbox",
734
+ ref: popupRef,
735
+ children: options.map((option, index) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
736
+ id: `${id}-o${index}`,
737
+ role: "option",
738
+ "aria-selected": option.value === value,
739
+ className: `${settings_card_module_css_default.selectOption}${option.value === value ? ` ${settings_card_module_css_default.selectOptionSelected}` : ""}${index === activeIndex && !closing ? ` ${settings_card_module_css_default.selectOptionActive}` : ""}`,
740
+ onClick: () => {
741
+ commit(index);
742
+ },
743
+ children: option.label
744
+ }, option.value))
745
+ }) : null]
746
+ });
747
+ }
748
+ /**
749
+ * A visible segmented group for a small set of mutually exclusive values.
750
+ * Every option stays on screen, so inherit/on/off and short enum fields take
751
+ * one click without opening a popup. The pressed option carries the group's
752
+ * sliding highlight and `aria-pressed`; the group takes the field label as its
753
+ * accessible name.
754
+ */
755
+ function SegmentField(props) {
756
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SegmentGroup, {
757
+ id: props.id,
758
+ role: "group",
759
+ "aria-label": props.label,
760
+ "aria-invalid": props.invalid || void 0,
761
+ children: props.options.map((option, index) => {
762
+ const active = option.value === props.value;
763
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
764
+ type: "button",
765
+ className: settings_card_module_css_default.segment,
766
+ "aria-pressed": active,
767
+ disabled: props.disabled,
768
+ "data-active": active ? "" : void 0,
769
+ "data-segment-index": index,
770
+ onClick: () => {
771
+ if (!active) props.onEdit(option.value);
772
+ },
773
+ children: option.label
774
+ }, option.value);
775
+ })
776
+ });
777
+ }
778
+ /** A boolean field: 继承 / 开 / 关. */
779
+ function BooleanField(props) {
780
+ const segmented = props.presentation !== "select";
781
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
782
+ className: settings_card_module_css_default.field,
783
+ children: [
784
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
785
+ className: settings_card_module_css_default.head,
786
+ children: [segmented ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
787
+ className: settings_card_module_css_default.label,
788
+ children: props.label
789
+ }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("label", {
790
+ className: settings_card_module_css_default.label,
791
+ htmlFor: props.id,
792
+ children: props.label
793
+ }), props.overridden ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
794
+ className: settings_card_module_css_default.badges,
795
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
796
+ className: settings_card_module_css_default.badge,
797
+ children: props.overriddenLabel
798
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
799
+ type: "button",
800
+ className: settings_card_module_css_default.reset,
801
+ disabled: props.disabled,
802
+ onClick: props.onReset,
803
+ children: props.resetLabel
804
+ })]
805
+ }) : null]
806
+ }),
807
+ segmented ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SegmentField, {
808
+ id: props.id,
809
+ label: props.label,
810
+ options: [
811
+ {
812
+ value: "",
813
+ label: props.inheritLabel
814
+ },
815
+ {
816
+ value: "true",
817
+ label: props.onLabel
818
+ },
819
+ {
820
+ value: "false",
821
+ label: props.offLabel
822
+ }
823
+ ],
824
+ value: props.text,
825
+ disabled: props.disabled,
826
+ invalid: props.invalid,
827
+ onEdit: props.onEdit
828
+ }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SelectField, {
829
+ id: props.id,
830
+ options: [
831
+ {
832
+ value: "",
833
+ label: props.inheritLabel
834
+ },
835
+ {
836
+ value: "true",
837
+ label: props.onLabel
838
+ },
839
+ {
840
+ value: "false",
841
+ label: props.offLabel
842
+ }
843
+ ],
844
+ value: props.text,
845
+ disabled: props.disabled,
846
+ invalid: props.invalid,
847
+ onEdit: props.onEdit
848
+ }),
849
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
850
+ className: settings_card_module_css_default.hint,
851
+ title: props.hintTitle,
852
+ children: props.hint
853
+ })
854
+ ]
855
+ });
856
+ }
857
+ /** An enumerated field, selecting or segmenting its small choice set. */
858
+ function ChoiceField(props) {
859
+ const segmented = props.presentation === "segment";
860
+ const options = [{
861
+ value: "",
862
+ label: props.inheritLabel
863
+ }, ...props.choices];
864
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
865
+ className: settings_card_module_css_default.field,
866
+ children: [
867
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
868
+ className: settings_card_module_css_default.head,
869
+ children: [segmented ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
870
+ className: settings_card_module_css_default.label,
871
+ children: props.label
872
+ }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("label", {
873
+ className: settings_card_module_css_default.label,
874
+ htmlFor: props.id,
875
+ children: props.label
876
+ }), props.overridden ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
877
+ className: settings_card_module_css_default.badges,
878
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
879
+ className: settings_card_module_css_default.badge,
880
+ children: props.overriddenLabel
881
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
882
+ type: "button",
883
+ className: settings_card_module_css_default.reset,
884
+ disabled: props.disabled,
885
+ onClick: props.onReset,
886
+ children: props.resetLabel
887
+ })]
888
+ }) : null]
889
+ }),
890
+ segmented ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SegmentField, {
891
+ id: props.id,
892
+ label: props.label,
893
+ options,
894
+ value: props.text,
895
+ disabled: props.disabled,
896
+ invalid: props.invalid,
897
+ onEdit: props.onEdit
898
+ }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SelectField, {
899
+ id: props.id,
900
+ options,
901
+ value: props.text,
902
+ disabled: props.disabled,
903
+ invalid: props.invalid,
904
+ onEdit: props.onEdit
905
+ }),
906
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
907
+ className: props.invalid ? settings_card_module_css_default.invalid : settings_card_module_css_default.hint,
908
+ title: props.hintTitle,
909
+ children: props.invalid ? props.invalidLabel : props.hint
910
+ })
911
+ ]
912
+ });
913
+ }
914
+ /** A whole- or decimal-number field. An empty draft clears the field; any other draft that is not a finite number within the constraints stays unwritten. */
915
+ function numberField(field, constraints = {}) {
916
+ const { integer = false, min, max } = constraints;
917
+ return {
918
+ field,
919
+ entry: "type",
920
+ format: (value) => typeof value === "number" ? String(value) : "",
921
+ parse: (text) => {
922
+ const trimmed = text.trim();
923
+ if (trimmed === "") return { kind: "clear" };
924
+ const parsed = Number(trimmed);
925
+ if (!Number.isFinite(parsed)) return void 0;
926
+ if (integer && !Number.isInteger(parsed)) return void 0;
927
+ if (min !== void 0 && parsed < min) return void 0;
928
+ if (max !== void 0 && parsed > max) return void 0;
929
+ return {
930
+ kind: "set",
931
+ value: parsed
932
+ };
933
+ }
934
+ };
935
+ }
936
+ /**
937
+ * A free-text field. An empty draft clears the field. `entry` is `pick` when
938
+ * the text arrives whole from a picker (a preset or a reasoning level).
939
+ */
940
+ function textField(field, entry = "type") {
941
+ return {
942
+ field,
943
+ entry,
944
+ format: (value) => typeof value === "string" ? value : "",
945
+ parse: (text) => {
946
+ const trimmed = text.trim();
947
+ return trimmed === "" ? { kind: "clear" } : {
948
+ kind: "set",
949
+ value: trimmed
950
+ };
951
+ }
952
+ };
953
+ }
954
+ /** A boolean field, edited through true/false draft text. */
955
+ function booleanField(field) {
956
+ return {
957
+ field,
958
+ entry: "pick",
959
+ format: (value) => typeof value === "boolean" ? String(value) : "",
960
+ parse: (text) => {
961
+ const trimmed = text.trim();
962
+ if (trimmed === "") return { kind: "clear" };
963
+ if (trimmed === "true") return {
964
+ kind: "set",
965
+ value: true
966
+ };
967
+ if (trimmed === "false") return {
968
+ kind: "set",
969
+ value: false
970
+ };
971
+ }
972
+ };
973
+ }
974
+ /** An enumerated string field; only the listed choices are accepted. An empty draft clears the field. */
975
+ function choiceField(field, choices) {
976
+ return {
977
+ field,
978
+ entry: "pick",
979
+ format: (value) => typeof value === "string" && choices.includes(value) ? value : "",
980
+ parse: (text) => {
981
+ if (text === "") return { kind: "clear" };
982
+ return choices.includes(text) ? {
983
+ kind: "set",
984
+ value: text
985
+ } : void 0;
986
+ }
987
+ };
988
+ }
989
+ /**
990
+ * Applies one card's edits to one settings namespace as the reader makes them.
991
+ *
992
+ * The Host is the only authority on whether a value was accepted — its
993
+ * validators own the constraints no schema can express — so the outcome is
994
+ * read back from the section rather than predicted here. A write that did not
995
+ * land puts each pick back to the stored value, the way a switch that could not
996
+ * flip springs back, and keeps typed text so the reader can correct it instead
997
+ * of retyping.
998
+ */
999
+ var CardForm = class {
1000
+ scope;
1001
+ specs;
1002
+ staged = /* @__PURE__ */ new Map();
1003
+ listeners = /* @__PURE__ */ new Set();
1004
+ /** The form subscription installed in the constructor; released by dispose(). */
1005
+ disposeForm;
1006
+ disposed = false;
1007
+ /** The pending write of typed text, waiting for typing to pause. */
1008
+ typePause;
1009
+ saving = false;
1010
+ /** A save asked for while one was in flight; it runs once the first settles (#1754). */
1011
+ saveQueued = false;
1012
+ failed = false;
1013
+ failedReason;
1014
+ /** @param scope - the bound configuration form for this card's namespace. */
1015
+ constructor(scope, specs) {
1016
+ this.scope = scope;
1017
+ this.specs = new Map(specs.map((spec) => [spec.field, spec]));
1018
+ this.disposeForm = scope.subscribe(() => {
1019
+ this.publish();
1020
+ });
1021
+ }
1022
+ /**
1023
+ * Release the form subscription and every bound store listener. The card
1024
+ * must call this on teardown; later calls are no-ops.
1025
+ */
1026
+ dispose() {
1027
+ if (this.disposed) return;
1028
+ this.disposed = true;
1029
+ clearTimeout(this.typePause);
1030
+ this.disposeForm();
1031
+ this.listeners.clear();
1032
+ }
1033
+ /** Publish a projection of this form, rebuilt whenever the form or a draft changes. */
1034
+ bind(project) {
1035
+ const store = (0, _deepseek_ai_dsh_client_store.createSnapshotStore)(project());
1036
+ this.listeners.add(() => {
1037
+ store.set(project());
1038
+ });
1039
+ return store;
1040
+ }
1041
+ /** Read the card-level state: what the Host serves, and what is still waiting to be written. */
1042
+ shell() {
1043
+ const snapshot = this.scope.getSnapshot();
1044
+ const plan = this.plan();
1045
+ return {
1046
+ available: snapshot.status !== "loading",
1047
+ exposed: snapshot.status === "ready",
1048
+ writable: snapshot.writable,
1049
+ dirty: plan.length > 0,
1050
+ invalid: plan.some((item) => item.judge === void 0),
1051
+ saving: this.saving,
1052
+ failed: this.failed,
1053
+ ...this.failedReason === void 0 ? {} : { failedReason: this.failedReason }
1054
+ };
1055
+ }
1056
+ /** Read one field's state from the effective section and its staged draft. */
1057
+ field(field) {
1058
+ const spec = this.specOf(field);
1059
+ const staged = this.staged.get(field);
1060
+ if (staged === void 0) return {
1061
+ text: spec.format(this.sectionValue(field)),
1062
+ overridden: this.stored(field),
1063
+ invalid: false
1064
+ };
1065
+ const write = staged.clear ? { kind: "clear" } : spec.parse(staged.text);
1066
+ return {
1067
+ text: staged.text,
1068
+ overridden: write?.kind === "set",
1069
+ invalid: write === void 0
1070
+ };
1071
+ }
1072
+ /** The actions the card's slot registration injects. */
1073
+ actions() {
1074
+ return {
1075
+ edit: (field, text) => {
1076
+ this.stage(field, {
1077
+ text,
1078
+ clear: false
1079
+ });
1080
+ },
1081
+ resetField: (field) => {
1082
+ this.stage(field, {
1083
+ text: this.specOf(field).format(this.baseValue(field)),
1084
+ clear: true
1085
+ });
1086
+ },
1087
+ save: () => {
1088
+ this.applyNow();
1089
+ },
1090
+ discard: () => {
1091
+ clearTimeout(this.typePause);
1092
+ if (this.staged.size === 0 && !this.failed) return;
1093
+ this.staged.clear();
1094
+ this.failed = false;
1095
+ this.failedReason = void 0;
1096
+ this.publish();
1097
+ }
1098
+ };
1099
+ }
1100
+ /**
1101
+ * Run one write, and re-run it once if another was asked for while this one
1102
+ * was still in flight.
1103
+ *
1104
+ * A write is a Host round trip that also drives the profile reconcile, and
1105
+ * the Host runs it inside one exclusive transaction. Answering an edit that
1106
+ * arrives mid-flight by returning immediately dropped it with no explanation
1107
+ * (#1754). Serializing instead means an edit made while another write is
1108
+ * still settling is written against the settled state.
1109
+ * @returns settlement after the mutation and the read-back.
1110
+ */
1111
+ async requestSave() {
1112
+ if (this.saving) {
1113
+ this.saveQueued = true;
1114
+ return;
1115
+ }
1116
+ await this.save();
1117
+ if (!this.saveQueued) return;
1118
+ this.saveQueued = false;
1119
+ await this.requestSave();
1120
+ }
1121
+ /**
1122
+ * Write every valid draft in one atomic form mutation, then re-seed from
1123
+ * what the Host accepted. A draft the field does not accept stays on screen,
1124
+ * unwritten, without holding the others back.
1125
+ *
1126
+ * The batch rides one mutate, so cross-field validate hooks (baseURL+model)
1127
+ * judge it as a unit: the Host either applies every write or refuses the
1128
+ * batch. The form contract answers a refusal or a skipped write with `false`
1129
+ * (it recovers with a fresh Host view instead of throwing), so the outcome is
1130
+ * judged twice: the answer itself, and then the settled snapshot read back
1131
+ * one planned write at a time. One missed write fails the whole batch. A
1132
+ * transport that rejects instead (the dsh-web bridge controller on a dead
1133
+ * connection) reports through the same failure path with its rejection
1134
+ * message. A batch that did not land puts its picks and clears back to the
1135
+ * stored value and keeps its typed text, so the reader can correct it.
1136
+ * @returns settlement after the mutation and the read-back.
1137
+ */
1138
+ async save() {
1139
+ const valid = this.plan().filter((item) => item.judge !== void 0);
1140
+ if (valid.length === 0 || this.saving) return;
1141
+ const pending = /* @__PURE__ */ new Map();
1142
+ for (const item of valid) pending.set(item.field, this.staged.get(item.field));
1143
+ this.saving = true;
1144
+ this.failed = false;
1145
+ this.failedReason = void 0;
1146
+ this.publish();
1147
+ const ops = valid.map((item) => item.op.op === "set" ? {
1148
+ op: "set",
1149
+ path: [item.field],
1150
+ value: item.op.value
1151
+ } : {
1152
+ op: "unset",
1153
+ path: [item.field]
1154
+ });
1155
+ let failedReason;
1156
+ let accepted = false;
1157
+ try {
1158
+ accepted = await this.scope.mutate(ops);
1159
+ } catch (error) {
1160
+ failedReason = error instanceof Error ? error.message : String(error);
1161
+ }
1162
+ const landed = accepted && failedReason === void 0 && valid.every((item) => item.judge());
1163
+ for (const [field, before] of pending) {
1164
+ if (this.staged.get(field) !== before) continue;
1165
+ if (landed || before === void 0 || before.clear || this.specOf(field).entry === "pick") this.staged.delete(field);
1166
+ }
1167
+ this.saving = false;
1168
+ this.failed = !landed;
1169
+ this.failedReason = failedReason;
1170
+ this.publish();
1171
+ }
1172
+ /**
1173
+ * Every staged edit a write would carry. An entry whose draft is not a value
1174
+ * its field accepts carries no write: the form is still dirty, and the draft
1175
+ * stays on screen rather than being dropped. A staged edit that matches the
1176
+ * effective section is not a write at all.
1177
+ * @returns the planned writes, in the order the fields were staged.
1178
+ */
1179
+ plan() {
1180
+ const plan = [];
1181
+ for (const [field, staged] of this.staged) {
1182
+ const spec = this.specOf(field);
1183
+ if (staged.clear) {
1184
+ if (this.stored(field)) plan.push({
1185
+ field,
1186
+ op: {
1187
+ field,
1188
+ op: "unset"
1189
+ },
1190
+ judge: () => this.landedUnset(field)
1191
+ });
1192
+ continue;
1193
+ }
1194
+ if (staged.text === spec.format(this.sectionValue(field))) continue;
1195
+ const write = spec.parse(staged.text);
1196
+ if (write === void 0) plan.push({
1197
+ field,
1198
+ op: {
1199
+ field,
1200
+ op: "unset"
1201
+ },
1202
+ judge: void 0
1203
+ });
1204
+ else if (write.kind === "clear") plan.push({
1205
+ field,
1206
+ op: {
1207
+ field,
1208
+ op: "unset"
1209
+ },
1210
+ judge: () => this.landedUnset(field)
1211
+ });
1212
+ else plan.push({
1213
+ field,
1214
+ op: {
1215
+ field,
1216
+ op: "set",
1217
+ value: write.value
1218
+ },
1219
+ judge: () => this.landedSet(field, write.value)
1220
+ });
1221
+ }
1222
+ return plan;
1223
+ }
1224
+ /**
1225
+ * Read-back judgment for a planned set: the user layer must hold the
1226
+ * intended value once the mutation has settled.
1227
+ */
1228
+ landedSet(field, value) {
1229
+ if (this.specOf(field).secret) return true;
1230
+ return jsonValuesEqual(this.userLayer()?.[field], value);
1231
+ }
1232
+ /**
1233
+ * Read-back judgment for a planned unset: the field must be gone from the
1234
+ * user layer once the mutation has settled.
1235
+ */
1236
+ landedUnset(field) {
1237
+ return !this.stored(field);
1238
+ }
1239
+ /**
1240
+ * Take one edit and schedule its write: a pick or a clear is written now,
1241
+ * typed text once typing has rested for TYPE_PAUSE_MS.
1242
+ */
1243
+ stage(field, edit) {
1244
+ this.staged.set(field, edit);
1245
+ this.failed = false;
1246
+ this.failedReason = void 0;
1247
+ this.publish();
1248
+ if (edit.clear || this.specOf(field).entry === "pick") {
1249
+ this.applyNow();
1250
+ return;
1251
+ }
1252
+ clearTimeout(this.typePause);
1253
+ this.typePause = setTimeout(() => {
1254
+ this.applyNow();
1255
+ }, 600);
1256
+ }
1257
+ /** Write every pending draft now, taking the place of a waiting pause. */
1258
+ applyNow() {
1259
+ clearTimeout(this.typePause);
1260
+ this.typePause = void 0;
1261
+ if (this.disposed) return;
1262
+ this.requestSave();
1263
+ }
1264
+ specOf(field) {
1265
+ const spec = this.specs.get(field);
1266
+ if (spec === void 0) throw new Error(`settings card has no field ${field}`);
1267
+ return spec;
1268
+ }
1269
+ snapshotOf() {
1270
+ return this.scope.getSnapshot();
1271
+ }
1272
+ sectionValue(field) {
1273
+ return this.snapshotOf().value?.[field];
1274
+ }
1275
+ baseValue(field) {
1276
+ return this.snapshotOf().base?.[field];
1277
+ }
1278
+ userLayer() {
1279
+ return this.snapshotOf().user;
1280
+ }
1281
+ stored(field) {
1282
+ const user = this.userLayer();
1283
+ return user !== void 0 && Object.hasOwn(user, field);
1284
+ }
1285
+ publish() {
1286
+ for (const listener of this.listeners) listener();
1287
+ }
1288
+ };
1289
+ /** Structural equality for JSON settings values (primitives, arrays, plain objects). */
1290
+ function jsonValuesEqual(left, right) {
1291
+ if (Object.is(left, right)) return true;
1292
+ if (typeof left !== "object" || left === null || typeof right !== "object" || right === null) return false;
1293
+ if (Array.isArray(left) || Array.isArray(right)) {
1294
+ if (!Array.isArray(left) || !Array.isArray(right) || left.length !== right.length) return false;
1295
+ return left.every((item, index) => jsonValuesEqual(item, right[index]));
1296
+ }
1297
+ const a = left;
1298
+ const b = right;
1299
+ const keysA = Object.keys(a).filter((key) => a[key] !== void 0);
1300
+ const keysB = Object.keys(b).filter((key) => b[key] !== void 0);
1301
+ if (keysA.length !== keysB.length) return false;
1302
+ return keysA.every((key) => Object.hasOwn(b, key) && jsonValuesEqual(a[key], b[key]));
1303
+ }
1304
+ //#endregion
1305
+ //#region src/core/adapters/custom.ts
1306
+ /** Placeholders a template may carry. */
1307
+ const CUSTOM_PLACEHOLDERS = [
1308
+ "prompt_file",
1309
+ "cwd",
1310
+ "session"
1311
+ ];
1312
+ /** Placeholder pattern: a braced lower-case name. */
1313
+ const PLACEHOLDER_RE = /\{([a-z_]+)\}/g;
1314
+ /**
1315
+ * Check one template before a run depends on it.
1316
+ * @param template - the template text.
1317
+ * @returns the reason it cannot be used, or undefined when it can.
1318
+ */
1319
+ function validateCustomTemplate(template) {
1320
+ if (template.trim().length === 0) return "the template must not be empty";
1321
+ if (template.length > 2048) return "the template must be at most 2048 characters";
1322
+ if (template.includes("\0")) return "the template must not contain a NUL byte";
1323
+ for (const match of template.matchAll(PLACEHOLDER_RE)) {
1324
+ const name = match[1];
1325
+ if (!CUSTOM_PLACEHOLDERS.includes(name)) return `unknown placeholder {${name}} (accepted: ${CUSTOM_PLACEHOLDERS.map((p) => `{${p}}`).join(", ")})`;
1326
+ }
1327
+ if (!template.includes("{prompt_file}")) return "the start template must reference {prompt_file}";
1328
+ }
1329
+ //#endregion
1330
+ //#region src/core/target.ts
1331
+ /**
1332
+ * The execution target a card pins, and the run record the ledger carries.
1333
+ *
1334
+ * Both shapes are the wire form: they are what the browser half sends, what the
1335
+ * host half stores under `integrations.ssh`, and what an agent tool returns, so
1336
+ * both are parsed from `unknown` and never trusted. Parsing reports the exact
1337
+ * path of every problem instead of throwing, because a malformed payload
1338
+ * arrives from outside the process and must not become an exception in the
1339
+ * board's action channel.
1340
+ *
1341
+ * @module dsh-task-board-ssh/core/target
1342
+ */
1343
+ /** Which agent CLI the remote run starts. */
1344
+ const SSH_AGENT_KINDS = [
1345
+ "dsh",
1346
+ "claude",
1347
+ "codex",
1348
+ "custom"
1349
+ ];
1350
+ /** Host aliases `dshSsh` accepts: letters, digits, dots, hyphens, underscores. */
1351
+ const HOST_ALIAS_RE = /^[A-Za-z0-9._-]{1,128}$/;
1352
+ /** Longest accepted free text in one target or run field. */
1353
+ const FIELD_MAX = 2048;
1354
+ /** Membership test helper that keeps the union narrow without a cast. */
1355
+ function oneOf(value, allowed) {
1356
+ return typeof value === "string" && allowed.includes(value);
1357
+ }
1358
+ /** Whether a value is a plain object (not an array, not null, no exotic prototype). */
1359
+ function isPlainObject$3(value) {
1360
+ if (typeof value !== "object" || value === null || Array.isArray(value)) return false;
1361
+ const prototype = Object.getPrototypeOf(value);
1362
+ return prototype === Object.prototype || prototype === null;
1363
+ }
1364
+ /** Why a value that git would read as an option is refused. */
1365
+ const OPTION_INJECTION_REASON = "must not start with \"-\": git reads a leading dash as an option, not as a word";
1366
+ /**
1367
+ * Whether git would read a value as an option instead of as a word.
1368
+ * @param value - the candidate argument.
1369
+ * @returns true for a value whose first character is a dash.
1370
+ */
1371
+ function startsWithDash(value) {
1372
+ return value.startsWith("-");
1373
+ }
1374
+ /** Whether a string is a usable absolute POSIX path. */
1375
+ function isAbsolutePath(value) {
1376
+ return value.startsWith("/") && !value.includes("\0") && !value.includes("\n") && !value.includes("\r");
1377
+ }
1378
+ /** Whether a string is safe to compose into a git branch/ref name. */
1379
+ function isSafeGitRefSegment(value) {
1380
+ if (/[\u0000-\u001f\u007f\s~^:?*[\\]/.test(value)) return false;
1381
+ if (value.includes("..") || value.includes("@{") || value.startsWith("/") || value.endsWith("/") || value.endsWith(".") || value.endsWith(".lock") || value.includes("//")) return false;
1382
+ return true;
1383
+ }
1384
+ /** Collects issues while a parser walks one value. */
1385
+ var IssueList = class {
1386
+ errors = [];
1387
+ add(path, message) {
1388
+ this.errors.push({
1389
+ path,
1390
+ message
1391
+ });
1392
+ }
1393
+ /** Join a path segment onto a parent path. */
1394
+ static join(path, key) {
1395
+ return path === "" ? String(key) : `${path}.${String(key)}`;
1396
+ }
1397
+ };
1398
+ /**
1399
+ * Refuse unknown keys so a misspelled field is reported instead of ignored.
1400
+ * @param value - plain object being read.
1401
+ * @param allowed - keys the shape defines.
1402
+ * @param path - path of the object for the diagnostics.
1403
+ * @param issues - collector.
1404
+ */
1405
+ function rejectUnknownKeys(value, allowed, path, issues) {
1406
+ for (const key of Object.keys(value)) if (!allowed.includes(key)) issues.add(IssueList.join(path, key), `unknown field (accepted: ${allowed.join(", ")})`);
1407
+ }
1408
+ /**
1409
+ * Read one required bounded string.
1410
+ * @param value - candidate field.
1411
+ * @param path - path of the field for the diagnostics.
1412
+ * @param issues - collector.
1413
+ * @returns the text, or undefined when it was refused.
1414
+ */
1415
+ function readText$1(value, path, issues) {
1416
+ if (typeof value !== "string") {
1417
+ issues.add(path, "must be a string");
1418
+ return;
1419
+ }
1420
+ if (value.length === 0) {
1421
+ issues.add(path, "must not be empty");
1422
+ return;
1423
+ }
1424
+ if (value.length > FIELD_MAX) {
1425
+ issues.add(path, `must be at most ${FIELD_MAX} characters`);
1426
+ return;
1427
+ }
1428
+ return value;
1429
+ }
1430
+ /** Read the git source of a git workspace. */
1431
+ function parseGitSource(value, path, issues) {
1432
+ if (!isPlainObject$3(value)) {
1433
+ issues.add(path, "must be an object");
1434
+ return;
1435
+ }
1436
+ if (value.kind === "url") {
1437
+ rejectUnknownKeys(value, [
1438
+ "kind",
1439
+ "url",
1440
+ "base"
1441
+ ], path, issues);
1442
+ const urlPath = IssueList.join(path, "url");
1443
+ const basePath = IssueList.join(path, "base");
1444
+ const url = readText$1(value.url, urlPath, issues);
1445
+ const base = value.base === void 0 ? void 0 : readText$1(value.base, basePath, issues);
1446
+ if (url === void 0) return void 0;
1447
+ if (startsWithDash(url)) {
1448
+ issues.add(urlPath, OPTION_INJECTION_REASON);
1449
+ return;
1450
+ }
1451
+ if (url.includes("\0")) {
1452
+ issues.add(urlPath, "must not contain NUL bytes");
1453
+ return;
1454
+ }
1455
+ if (/\s/.test(url)) {
1456
+ issues.add(urlPath, "must not contain whitespace");
1457
+ return;
1458
+ }
1459
+ if (base !== void 0 && startsWithDash(base)) {
1460
+ issues.add(basePath, OPTION_INJECTION_REASON);
1461
+ return;
1462
+ }
1463
+ if (base !== void 0 && !isSafeGitRefSegment(base)) {
1464
+ issues.add(basePath, "must be a valid git branch name without whitespace or control characters");
1465
+ return;
1466
+ }
1467
+ return base === void 0 ? {
1468
+ kind: "url",
1469
+ url
1470
+ } : {
1471
+ kind: "url",
1472
+ url,
1473
+ base
1474
+ };
1475
+ }
1476
+ if (value.kind === "workspace") {
1477
+ rejectUnknownKeys(value, ["kind", "workspaceId"], path, issues);
1478
+ const workspaceIdPath = IssueList.join(path, "workspaceId");
1479
+ const workspaceId = readText$1(value.workspaceId, workspaceIdPath, issues);
1480
+ if (workspaceId === void 0) return void 0;
1481
+ if (workspaceId.includes("\0")) {
1482
+ issues.add(workspaceIdPath, "must not contain NUL bytes");
1483
+ return;
1484
+ }
1485
+ return {
1486
+ kind: "workspace",
1487
+ workspaceId
1488
+ };
1489
+ }
1490
+ issues.add(IssueList.join(path, "kind"), "must be \"url\" or \"workspace\"");
1491
+ }
1492
+ /** Read the filesystem mechanism of one target. */
1493
+ function parseWorkspace(value, path, issues) {
1494
+ if (!isPlainObject$3(value)) {
1495
+ issues.add(path, "must be an object");
1496
+ return;
1497
+ }
1498
+ if (value.kind === "in-place") {
1499
+ rejectUnknownKeys(value, ["kind", "path"], path, issues);
1500
+ const p = readText$1(value.path, IssueList.join(path, "path"), issues);
1501
+ if (p === void 0) return void 0;
1502
+ if (!isAbsolutePath(p)) {
1503
+ issues.add(IssueList.join(path, "path"), "must be an absolute remote path");
1504
+ return;
1505
+ }
1506
+ return {
1507
+ kind: "in-place",
1508
+ path: p
1509
+ };
1510
+ }
1511
+ if (value.kind === "git") {
1512
+ rejectUnknownKeys(value, ["kind", "source"], path, issues);
1513
+ const source = parseGitSource(value.source, IssueList.join(path, "source"), issues);
1514
+ return source === void 0 ? void 0 : {
1515
+ kind: "git",
1516
+ source
1517
+ };
1518
+ }
1519
+ issues.add(IssueList.join(path, "kind"), "must be \"in-place\" or \"git\"");
1520
+ }
1521
+ /** Read which agent CLI a target pins. */
1522
+ function parseAgentTarget(value, path, issues) {
1523
+ if (!isPlainObject$3(value)) {
1524
+ issues.add(path, "must be an object");
1525
+ return;
1526
+ }
1527
+ rejectUnknownKeys(value, [
1528
+ "kind",
1529
+ "command",
1530
+ "resumeCommand"
1531
+ ], path, issues);
1532
+ if (!oneOf(value.kind, SSH_AGENT_KINDS)) {
1533
+ issues.add(IssueList.join(path, "kind"), `must be one of: ${SSH_AGENT_KINDS.join(", ")}`);
1534
+ return;
1535
+ }
1536
+ if (value.kind !== "custom") {
1537
+ if (value.command !== void 0 || value.resumeCommand !== void 0) {
1538
+ issues.add(path, "command templates apply to kind \"custom\" only");
1539
+ return;
1540
+ }
1541
+ return { kind: value.kind };
1542
+ }
1543
+ const commandPath = IssueList.join(path, "command");
1544
+ const resumePath = IssueList.join(path, "resumeCommand");
1545
+ const command = readText$1(value.command, commandPath, issues);
1546
+ const resumeCommand = value.resumeCommand === void 0 ? void 0 : readText$1(value.resumeCommand, resumePath, issues);
1547
+ if (command === void 0) {
1548
+ issues.add(commandPath, "a custom agent needs a start template");
1549
+ return;
1550
+ }
1551
+ const commandProblem = validateCustomTemplate(command);
1552
+ if (commandProblem !== void 0) {
1553
+ issues.add(commandPath, commandProblem);
1554
+ return;
1555
+ }
1556
+ if (resumeCommand !== void 0) {
1557
+ const resumeProblem = validateCustomTemplate(resumeCommand);
1558
+ if (resumeProblem !== void 0) {
1559
+ issues.add(resumePath, resumeProblem);
1560
+ return;
1561
+ }
1562
+ }
1563
+ return resumeCommand === void 0 ? {
1564
+ kind: "custom",
1565
+ command
1566
+ } : {
1567
+ kind: "custom",
1568
+ command,
1569
+ resumeCommand
1570
+ };
1571
+ }
1572
+ /**
1573
+ * Parse one pinned execution target.
1574
+ * @param value - candidate target from the wire, the ledger or a settings form.
1575
+ * @returns the target, or every reason it was refused.
1576
+ */
1577
+ function parseSshTarget(value) {
1578
+ const issues = new IssueList();
1579
+ if (!isPlainObject$3(value)) return {
1580
+ ok: false,
1581
+ errors: [{
1582
+ path: "",
1583
+ message: "must be an object"
1584
+ }]
1585
+ };
1586
+ rejectUnknownKeys(value, [
1587
+ "mode",
1588
+ "host",
1589
+ "agent",
1590
+ "workspace"
1591
+ ], "", issues);
1592
+ if (!oneOf(value.mode, ["direct", "proxy"])) issues.add("mode", "must be \"direct\" or \"proxy\"");
1593
+ const host = typeof value.host === "string" && HOST_ALIAS_RE.test(value.host) ? value.host : void 0;
1594
+ if (host === void 0) issues.add("host", "must be a dshSsh host alias (letters, digits, dots, hyphens, underscores)");
1595
+ const agent = parseAgentTarget(value.agent, "agent", issues);
1596
+ const workspace = parseWorkspace(value.workspace, "workspace", issues);
1597
+ if (issues.errors.length > 0) return {
1598
+ ok: false,
1599
+ errors: issues.errors
1600
+ };
1601
+ return {
1602
+ ok: true,
1603
+ value: {
1604
+ mode: value.mode,
1605
+ host,
1606
+ agent,
1607
+ workspace
1608
+ }
1609
+ };
1610
+ }
1611
+ /**
1612
+ * Parse one run record.
1613
+ * @param value - candidate record from the ledger or an action payload.
1614
+ * @returns the record, or every reason it was refused.
1615
+ */
1616
+ function parseSshRunRecord(value) {
1617
+ const issues = new IssueList();
1618
+ if (!isPlainObject$3(value)) return {
1619
+ ok: false,
1620
+ errors: [{
1621
+ path: "",
1622
+ message: "must be an object"
1623
+ }]
1624
+ };
1625
+ rejectUnknownKeys(value, [
1626
+ "runId",
1627
+ "phase",
1628
+ "startedAt",
1629
+ "finishedAt",
1630
+ "exitCode",
1631
+ "sessionId",
1632
+ "bytes",
1633
+ "branch",
1634
+ "summary",
1635
+ "error",
1636
+ "followUps"
1637
+ ], "", issues);
1638
+ if ((typeof value.runId === "string" && value.runId !== "." && value.runId !== ".." && /^[A-Za-z0-9._-]{1,128}$/.test(value.runId) ? value.runId : void 0) === void 0) issues.add("runId", "must be 1-128 characters of letters, digits, dots, underscores or hyphens");
1639
+ if (!oneOf(value.phase, [
1640
+ "queued",
1641
+ "running",
1642
+ "succeeded",
1643
+ "failed",
1644
+ "cancelled",
1645
+ "lost"
1646
+ ])) issues.add("phase", "must be one of: queued, running, succeeded, failed, cancelled, lost");
1647
+ if (typeof value.startedAt !== "number" || !Number.isFinite(value.startedAt)) issues.add("startedAt", "must be a finite millisecond timestamp");
1648
+ for (const key of [
1649
+ "finishedAt",
1650
+ "exitCode",
1651
+ "bytes",
1652
+ "followUps"
1653
+ ]) {
1654
+ if (value[key] === void 0) continue;
1655
+ if (typeof value[key] !== "number" || !Number.isFinite(value[key])) issues.add(key, "must be a finite number");
1656
+ }
1657
+ for (const key of [
1658
+ "sessionId",
1659
+ "branch",
1660
+ "summary",
1661
+ "error"
1662
+ ]) {
1663
+ if (value[key] === void 0) continue;
1664
+ readText$1(value[key], key, issues);
1665
+ }
1666
+ if (issues.errors.length > 0) return {
1667
+ ok: false,
1668
+ errors: issues.errors
1669
+ };
1670
+ return {
1671
+ ok: true,
1672
+ value: { ...value }
1673
+ };
1674
+ }
1675
+ //#endregion
1676
+ //#region \0dsh-css:packages/dsh-task-board-ssh/src/client/ssh.module.css.mjs
1677
+ const css = ".NsXkLW_section,.NsXkLW_compose,.NsXkLW_badge{--ssh-control-h:var(--dsh-tb-control-h,30px);--ssh-radius:var(--dsh-tb-control-radius,8px);--ssh-ease:var(--dsh-tb-ease,cubic-bezier(.2, 0, 0, 1));--ssh-row:18px}.NsXkLW_section{flex-direction:column;gap:8px;min-width:0;display:flex}.NsXkLW_sectionTitle{color:var(--dsw-alias-label-secondary);margin:0;font-size:12px;font-weight:700;line-height:1.4}.NsXkLW_head{flex-wrap:wrap;align-items:center;gap:8px;display:flex}.NsXkLW_targetLine{color:var(--dsw-alias-label-primary);overflow-wrap:anywhere;margin:0;font-size:13px;line-height:1.55}.NsXkLW_meta{color:var(--dsw-alias-label-secondary);overflow-wrap:anywhere;margin:0;font-size:12px;line-height:1.5}.NsXkLW_summary{color:var(--dsw-alias-label-secondary);background:var(--dsw-alias-bg-layer-2);border-left:2px solid var(--dsw-alias-border-l2);border-radius:0 var(--ssh-radius) var(--ssh-radius) 0;overflow-wrap:anywhere;margin:0;padding:6px 10px;font-size:12px;line-height:1.5}.NsXkLW_formError{color:var(--dsw-alias-state-error-primary);overflow-wrap:anywhere;margin:0;font-size:12px;line-height:1.5}.NsXkLW_statePill,.NsXkLW_badge{box-sizing:border-box;height:var(--ssh-row);white-space:nowrap;border:1px solid var(--dsw-alias-border-l2);color:var(--dsw-alias-label-secondary);border-radius:999px;flex:none;align-items:center;gap:6px;padding:0 8px;font-size:12px;line-height:1;display:inline-flex}.NsXkLW_badge{background:var(--dsw-alias-interactive-bg-hover);border:1px solid #0000}.NsXkLW_badgeDot{border:1.5px solid var(--ssh-run-tone,currentColor);box-sizing:border-box;border-radius:50%;flex:none;width:6px;height:6px}.NsXkLW_badgeHost{text-overflow:ellipsis;white-space:nowrap;min-width:0;max-width:9ch;display:inline-block;overflow:hidden}.NsXkLW_badgeSeparator{white-space:pre;color:var(--dsw-alias-label-secondary)}.NsXkLW_badgeState{flex:none}.NsXkLW_statePill{border-color:var(--ssh-run-tone,var(--dsw-alias-border-l2))}[data-run=idle]{--ssh-run-tone:var(--dsw-alias-label-tertiary)}[data-run=queued],[data-run=running]{--ssh-run-tone:var(--dsw-alias-state-business-primary)}[data-run=succeeded]{--ssh-run-tone:var(--dsw-alias-state-success-primary)}[data-run=failed]{--ssh-run-tone:var(--dsw-alias-state-error-primary)}[data-run=cancelled]{--ssh-run-tone:var(--dsw-alias-state-idle-primary)}[data-run=lost]{--ssh-run-tone:var(--dsw-alias-state-warn-primary)}[data-run=running] .NsXkLW_badgeDot,[data-run=succeeded] .NsXkLW_badgeDot,[data-run=failed] .NsXkLW_badgeDot,[data-run=cancelled] .NsXkLW_badgeDot,[data-run=lost] .NsXkLW_badgeDot{background:var(--ssh-run-tone,currentColor)}[data-run=running] .NsXkLW_badgeDot{animation:NsXkLW_ssh-live 2s var(--ssh-ease,ease-in-out) infinite}@keyframes NsXkLW_ssh-live{0%,to{opacity:1}50%{opacity:.35}}@media (prefers-reduced-motion:reduce){[data-run=running] .NsXkLW_badgeDot{outline:1.5px solid var(--ssh-run-tone,currentColor);outline-offset:1px;animation:none}.NsXkLW_primaryButton,.NsXkLW_ghostButton,.NsXkLW_linkButton,.NsXkLW_input,.NsXkLW_select,.NsXkLW_followUp,.NsXkLW_segment span{transition:none}}.NsXkLW_log{flex-direction:column;gap:6px;min-width:0;display:flex}.NsXkLW_logScroller{box-sizing:content-box;background:var(--dsw-alias-bg-layer-2);border:1px solid var(--dsw-alias-border-l2);border-radius:var(--ssh-radius);font-family:var(--dsw-font-mono,ui-monospace, SFMono-Regular, Menlo, Consolas, monospace);color:var(--dsw-alias-label-primary);padding:0;font-size:12px;line-height:18px;overflow:auto}.NsXkLW_logScroller:focus-visible{outline:2px solid var(--dsw-alias-state-business-primary);outline-offset:2px}.NsXkLW_logSurface{min-width:100%;position:relative}.NsXkLW_logBlock{will-change:transform;position:absolute;top:0;left:0;right:0}.NsXkLW_logRow{white-space:pre;padding:0 10px;overflow:visible}.NsXkLW_logEmpty{color:var(--dsw-alias-label-secondary);margin:0;font-size:12px;line-height:1.5}.NsXkLW_logNotices{flex-wrap:wrap;align-items:center;gap:8px;display:flex}.NsXkLW_logNotice{color:var(--dsw-alias-label-secondary);margin:0;font-size:12px}.NsXkLW_primaryButton,.NsXkLW_ghostButton,.NsXkLW_linkButton{box-sizing:border-box;cursor:pointer;white-space:nowrap;justify-content:center;align-items:center;gap:6px;font-family:inherit;display:inline-flex}.NsXkLW_primaryButton,.NsXkLW_ghostButton{height:var(--ssh-control-h);border-radius:var(--ssh-radius);transition:background-color .12s var(--ssh-ease), border-color .12s var(--ssh-ease);padding:0 12px;font-size:13px}.NsXkLW_primaryButton{color:var(--dsw-alias-label-primary-foreground);background:var(--dsw-alias-button-primary-fill);border:1px solid #0000}.NsXkLW_ghostButton{color:var(--dsw-alias-label-primary);border:1px solid var(--dsw-alias-border-l2);background:0 0}.NsXkLW_primaryButton:hover:not(:disabled){background:var(--dsw-alias-button-primary-hover)}.NsXkLW_ghostButton:hover:not(:disabled){background:var(--dsw-alias-interactive-bg-hover)}.NsXkLW_linkButton{color:var(--dsw-alias-label-secondary);transition:background-color .12s var(--ssh-ease);background:0 0;border:0;border-radius:6px;margin-left:auto;padding:4px 6px;font-size:12px}.NsXkLW_logNotices .NsXkLW_linkButton{margin-left:0}.NsXkLW_linkButton:hover:not(:disabled){background:var(--dsw-alias-interactive-bg-hover)}.NsXkLW_primaryButton:disabled,.NsXkLW_ghostButton:disabled,.NsXkLW_linkButton:disabled{opacity:.5;cursor:not-allowed}.NsXkLW_primaryButton:focus-visible,.NsXkLW_ghostButton:focus-visible,.NsXkLW_linkButton:focus-visible,.NsXkLW_queuedChip:focus-visible,.NsXkLW_input:focus-visible,.NsXkLW_select:focus-visible,.NsXkLW_followUp:focus-visible,.NsXkLW_segment input:focus-visible+span{outline:2px solid var(--dsw-alias-state-business-primary);outline-offset:2px}.NsXkLW_form,.NsXkLW_fields{flex-direction:column;gap:8px;min-width:0;display:flex}.NsXkLW_field{border:0;flex-direction:column;gap:4px;min-width:0;margin:0;padding:0;display:flex}.NsXkLW_fieldLabel{color:var(--dsw-alias-label-secondary);padding:0;font-size:12px;font-weight:500;line-height:1.4}.NsXkLW_fieldHint{color:var(--dsw-alias-label-secondary);margin:0;font-size:12px;line-height:1.45}.NsXkLW_fieldError{color:var(--dsw-alias-state-error-primary);margin:0;font-size:12px;line-height:1.45}.NsXkLW_input,.NsXkLW_select,.NsXkLW_followUp{box-sizing:border-box;width:100%;min-width:0;color:var(--dsw-alias-label-primary);background:var(--dsw-specific-input-major);border:1px solid var(--dsw-alias-border-l2);border-radius:var(--ssh-radius);transition:border-color .12s var(--ssh-ease);outline:none;padding:6px 10px;font-family:inherit;font-size:13px}.NsXkLW_select{height:var(--ssh-control-h);padding:0 10px}.NsXkLW_followUp{min-height:calc(var(--ssh-control-h) + 8px);resize:vertical;line-height:1.5}.NsXkLW_input[aria-invalid=true],.NsXkLW_select[aria-invalid=true],.NsXkLW_followUp[aria-invalid=true]{border-color:var(--dsw-alias-state-error-primary)}.NsXkLW_input:disabled,.NsXkLW_select:disabled,.NsXkLW_followUp:disabled{opacity:.6;cursor:not-allowed}.NsXkLW_input::placeholder,.NsXkLW_followUp::placeholder{color:var(--dsw-alias-label-tertiary)}.NsXkLW_segments{flex-wrap:wrap;gap:6px;display:flex}.NsXkLW_segment{align-items:center;display:inline-flex}.NsXkLW_segment input{clip-path:inset(50%);white-space:nowrap;border:0;width:1px;height:1px;margin:-1px;padding:0;position:absolute;overflow:hidden}.NsXkLW_segment span{box-sizing:border-box;height:var(--ssh-control-h);color:var(--dsw-alias-label-primary);border:1px solid var(--dsw-alias-border-l2);border-radius:var(--ssh-radius);cursor:pointer;transition:background-color .12s var(--ssh-ease), border-color .12s var(--ssh-ease);background:0 0;align-items:center;padding:0 12px;font-size:13px;display:inline-flex}.NsXkLW_segment:not([data-disabled]):hover span{background:var(--dsw-alias-interactive-bg-hover)}.NsXkLW_segment input:checked+span{color:var(--dsw-alias-label-primary);background:var(--dsw-alias-interactive-bg-hover);border-color:var(--dsw-alias-label-secondary);font-weight:600}.NsXkLW_segment input:disabled+span{opacity:.6;cursor:not-allowed}.NsXkLW_field[data-invalid] .NsXkLW_fieldLabel{color:var(--dsw-alias-state-error-primary)}.NsXkLW_actions{flex-direction:column;align-items:stretch;gap:8px;min-width:0;display:flex}.NsXkLW_actionRow{flex-wrap:wrap;align-items:center;gap:8px;display:flex}.NsXkLW_queuedChip{box-sizing:border-box;height:var(--ssh-row);color:var(--dsw-alias-state-business-primary);border:1px dashed var(--dsw-alias-state-business-primary);border-radius:999px;align-items:center;padding:0 8px;font-size:12px;line-height:1;display:inline-flex}.NsXkLW_actionRow .NsXkLW_primaryButton{margin-left:auto}.NsXkLW_compose{flex-direction:column;gap:8px;min-width:0;display:flex}.NsXkLW_composeToggle{color:var(--dsw-alias-label-primary);cursor:pointer;user-select:none;align-items:center;gap:8px;font-size:13px;line-height:1.5;display:flex}.NsXkLW_composeToggle input{accent-color:var(--dsw-alias-state-business-primary);cursor:pointer;flex:none;margin:0}.NsXkLW_composeToggle input:focus-visible{outline:2px solid var(--dsw-alias-state-business-primary);outline-offset:2px}@media (width<=768px){.NsXkLW_section,.NsXkLW_compose{--ssh-control-h:44px}.NsXkLW_composeToggle,.NsXkLW_linkButton{min-height:44px}.NsXkLW_input,.NsXkLW_select,.NsXkLW_followUp{font-size:16px}}.NsXkLW_composeFields{flex-direction:column;gap:8px;min-width:0;display:flex}.NsXkLW_quietField{display:contents}.NsXkLW_quietField p:empty{display:none}.NsXkLW_sectionHint{color:var(--dsw-alias-label-secondary);margin:0;font-size:12px;line-height:1.5}";
1678
+ const tagId = "@linxin666/dsh-client-ui-task-board-ssh/packages/dsh-task-board-ssh/src/client/ssh.module.css";
1679
+ if (typeof document !== "undefined" && document.querySelector("style[data-plugin-css=" + JSON.stringify(tagId) + "]") === null) {
1680
+ const tag = document.createElement("style");
1681
+ tag.dataset.plugin = "@linxin666/dsh-client-ui-task-board-ssh";
1682
+ tag.dataset.pluginCss = tagId;
1683
+ tag.textContent = css;
1684
+ document.head.appendChild(tag);
1685
+ }
1686
+ var ssh_module_css_default = {
1687
+ "actionRow": "NsXkLW_actionRow",
1688
+ "actions": "NsXkLW_actions",
1689
+ "badge": "NsXkLW_badge",
1690
+ "badgeDot": "NsXkLW_badgeDot",
1691
+ "badgeHost": "NsXkLW_badgeHost",
1692
+ "badgeSeparator": "NsXkLW_badgeSeparator",
1693
+ "badgeState": "NsXkLW_badgeState",
1694
+ "compose": "NsXkLW_compose",
1695
+ "composeFields": "NsXkLW_composeFields",
1696
+ "composeToggle": "NsXkLW_composeToggle",
1697
+ "field": "NsXkLW_field",
1698
+ "fieldError": "NsXkLW_fieldError",
1699
+ "fieldHint": "NsXkLW_fieldHint",
1700
+ "fieldLabel": "NsXkLW_fieldLabel",
1701
+ "fields": "NsXkLW_fields",
1702
+ "followUp": "NsXkLW_followUp",
1703
+ "form": "NsXkLW_form",
1704
+ "formError": "NsXkLW_formError",
1705
+ "ghostButton": "NsXkLW_ghostButton",
1706
+ "head": "NsXkLW_head",
1707
+ "input": "NsXkLW_input",
1708
+ "linkButton": "NsXkLW_linkButton",
1709
+ "log": "NsXkLW_log",
1710
+ "logBlock": "NsXkLW_logBlock",
1711
+ "logEmpty": "NsXkLW_logEmpty",
1712
+ "logNotice": "NsXkLW_logNotice",
1713
+ "logNotices": "NsXkLW_logNotices",
1714
+ "logRow": "NsXkLW_logRow",
1715
+ "logScroller": "NsXkLW_logScroller",
1716
+ "logSurface": "NsXkLW_logSurface",
1717
+ "meta": "NsXkLW_meta",
1718
+ "primaryButton": "NsXkLW_primaryButton",
1719
+ "queuedChip": "NsXkLW_queuedChip",
1720
+ "quietField": "NsXkLW_quietField",
1721
+ "section": "NsXkLW_section",
1722
+ "sectionHint": "NsXkLW_sectionHint",
1723
+ "sectionTitle": "NsXkLW_sectionTitle",
1724
+ "segment": "NsXkLW_segment",
1725
+ "segments": "NsXkLW_segments",
1726
+ "select": "NsXkLW_select",
1727
+ "ssh-live": "NsXkLW_ssh-live",
1728
+ "statePill": "NsXkLW_statePill",
1729
+ "summary": "NsXkLW_summary",
1730
+ "targetLine": "NsXkLW_targetLine"
1731
+ };
1732
+ //#endregion
1733
+ //#region src/client/ssh/settings-section.tsx
1734
+ /** One agent whose built-in command line an operator may replace. */
1735
+ const OVERRIDE_AGENTS = [
1736
+ "dsh",
1737
+ "claude",
1738
+ "codex"
1739
+ ];
1740
+ /**
1741
+ * Bounds of the per-host cap, restated from the Host's own normalization
1742
+ * (`src/host/queue.ts`'s `PER_HOST_CAP_MIN`/`PER_HOST_CAP_MAX`, which the Config
1743
+ * schema in `src/index.ts` bounds too). The client may not import the host half,
1744
+ * so `tests/client-limits.spec.ts` pins the two restatements against each other.
1745
+ */
1746
+ const HOST_CAP = {
1747
+ min: 1,
1748
+ max: 16,
1749
+ step: 1,
1750
+ fallback: 2
1751
+ };
1752
+ /** Whether a value is a plain object (not an array, not null). */
1753
+ function isPlainObject$2(value) {
1754
+ return typeof value === "object" && value !== null && !Array.isArray(value);
1755
+ }
1756
+ /**
1757
+ * Read the stored override rows; anything unreadable reads as no override.
1758
+ * @param value - the stored field value.
1759
+ * @returns the rows, one per agent at most.
1760
+ */
1761
+ function readAgentRows(value) {
1762
+ if (!Array.isArray(value)) return [];
1763
+ const rows = [];
1764
+ for (const entry of value) {
1765
+ if (!isPlainObject$2(entry)) continue;
1766
+ const kind = SSH_AGENT_KINDS.find((candidate) => candidate === entry.kind);
1767
+ const command = typeof entry.command === "string" ? entry.command : "";
1768
+ if (kind === void 0 || command.trim() === "") continue;
1769
+ const row = {
1770
+ kind,
1771
+ command
1772
+ };
1773
+ if (typeof entry.resumeCommand === "string" && entry.resumeCommand.trim() !== "") row.resumeCommand = entry.resumeCommand;
1774
+ rows.push(row);
1775
+ }
1776
+ return rows;
1777
+ }
1778
+ /**
1779
+ * Read the override rows out of their JSON draft.
1780
+ * @param text - the field's draft text.
1781
+ * @returns the rows; an unreadable draft reads as no override.
1782
+ */
1783
+ function parseAgentRowsText(text) {
1784
+ if (text.trim() === "") return [];
1785
+ try {
1786
+ return readAgentRows(JSON.parse(text));
1787
+ } catch {
1788
+ return [];
1789
+ }
1790
+ }
1791
+ /**
1792
+ * Replace one agent's start template, keeping everything else the row stores.
1793
+ *
1794
+ * A cleared template removes the row: an override without a command means "use
1795
+ * the built-in command line", and storing an empty one would ask the Host to
1796
+ * start nothing.
1797
+ * @param text - the field's current draft text.
1798
+ * @param kind - agent the edit belongs to.
1799
+ * @param command - the new template.
1800
+ * @returns the new draft text.
1801
+ */
1802
+ function withAgentCommand(text, kind, command) {
1803
+ const existing = parseAgentRowsText(text);
1804
+ const previous = existing.find((row) => row.kind === kind);
1805
+ const rest = existing.filter((row) => row.kind !== kind);
1806
+ if (command.trim() !== "") rest.push({
1807
+ kind,
1808
+ command,
1809
+ ...previous?.resumeCommand === void 0 ? {} : { resumeCommand: previous.resumeCommand }
1810
+ });
1811
+ const knownOrder = OVERRIDE_AGENTS.map((candidate) => rest.find((row) => row.kind === candidate)).filter((row) => row !== void 0);
1812
+ const extra = rest.filter((row) => !OVERRIDE_AGENTS.includes(row.kind));
1813
+ const ordered = [...knownOrder, ...extra];
1814
+ return ordered.length === 0 ? "" : JSON.stringify(ordered);
1815
+ }
1816
+ /** Validate `defaultHost`: empty clears to inherited default, non-empty must be a valid dsh-ssh alias. */
1817
+ function defaultHostField() {
1818
+ return {
1819
+ ...textField("defaultHost"),
1820
+ parse: (text) => {
1821
+ const trimmed = text.trim();
1822
+ if (trimmed === "") return { kind: "clear" };
1823
+ return HOST_ALIAS_RE.test(trimmed) ? {
1824
+ kind: "set",
1825
+ value: trimmed
1826
+ } : void 0;
1827
+ }
1828
+ };
1829
+ }
1830
+ /**
1831
+ * The list field as one JSON draft, so the card's form stays the only writer.
1832
+ *
1833
+ * A draft whose template cannot start anything (it does not reference the
1834
+ * prompt file) stays unwritten and shows as an unacceptable value, which is the
1835
+ * card's own way of refusing a draft.
1836
+ */
1837
+ function agentCommandsField() {
1838
+ return {
1839
+ field: "agentCommands",
1840
+ entry: "type",
1841
+ format: (value) => {
1842
+ const rows = readAgentRows(value);
1843
+ return rows.length === 0 ? "" : JSON.stringify(rows);
1844
+ },
1845
+ parse: (text) => {
1846
+ if (text.trim() === "") return { kind: "clear" };
1847
+ const rows = parseAgentRowsText(text);
1848
+ if (rows.length === 0) return { kind: "clear" };
1849
+ for (const row of rows) {
1850
+ if (validateCustomTemplate(row.command) !== void 0) return void 0;
1851
+ if (row.resumeCommand !== void 0 && validateCustomTemplate(row.resumeCommand) !== void 0) return void 0;
1852
+ }
1853
+ return {
1854
+ kind: "set",
1855
+ value: rows
1856
+ };
1857
+ }
1858
+ };
1859
+ }
1860
+ /** Bridges the extension's settings form onto the card's staged form. */
1861
+ var SshSettingsCardController = class {
1862
+ form;
1863
+ store;
1864
+ /**
1865
+ * @param scope - the bound configuration form of the entry that owns this namespace.
1866
+ */
1867
+ constructor(scope) {
1868
+ this.form = new CardForm(scope, [
1869
+ booleanField("enabled"),
1870
+ defaultHostField(),
1871
+ choiceField("defaultMode", ["direct", "proxy"]),
1872
+ choiceField("defaultAgent", [...SSH_AGENT_KINDS]),
1873
+ numberField("perHostCap", {
1874
+ integer: true,
1875
+ min: HOST_CAP.min,
1876
+ max: HOST_CAP.max
1877
+ }),
1878
+ agentCommandsField()
1879
+ ]);
1880
+ this.store = this.form.bind(() => this.projection());
1881
+ }
1882
+ projection() {
1883
+ return {
1884
+ ...this.form.shell(),
1885
+ enabled: this.form.field("enabled"),
1886
+ defaultHost: this.form.field("defaultHost"),
1887
+ defaultMode: this.form.field("defaultMode"),
1888
+ defaultAgent: this.form.field("defaultAgent"),
1889
+ perHostCap: this.form.field("perHostCap"),
1890
+ agentCommands: this.form.field("agentCommands")
1891
+ };
1892
+ }
1893
+ /**
1894
+ * Build the face the section's slot registration injects.
1895
+ * @returns the section's snapshot store and its form actions.
1896
+ */
1897
+ inject() {
1898
+ return {
1899
+ hooks: { sshSettingsCard: this.store },
1900
+ ...this.form.actions()
1901
+ };
1902
+ }
1903
+ /** Release the card's scope subscription and bound stores. */
1904
+ dispose() {
1905
+ this.form.dispose();
1906
+ }
1907
+ };
1908
+ /** Hint of one agent's command row: what its built-in command line is. */
1909
+ function agentCommandHint(kind) {
1910
+ if (kind === "claude") return "settings.agentCommandHint.claude";
1911
+ if (kind === "codex") return "settings.agentCommandHint.codex";
1912
+ return "settings.agentCommandHint.dsh";
1913
+ }
1914
+ /**
1915
+ * Render the SSH provider's settings section.
1916
+ * @param props - locale copy, the section snapshot, and its form actions.
1917
+ * @returns the section.
1918
+ */
1919
+ function SshSettingsSection(props) {
1920
+ const { t: translate } = props;
1921
+ const label = (key) => translate(key);
1922
+ const agentName = (kind) => label(`detail.agent.${kind}`);
1923
+ const modeName = (mode) => label(mode === "direct" ? "detail.mode.direct" : "detail.mode.proxy");
1924
+ const state = props.useSshSettingsCard((snapshot) => snapshot);
1925
+ const enabled = state.enabled.text !== "false";
1926
+ const fieldCopy = {
1927
+ overriddenLabel: label("settings.overridden"),
1928
+ resetLabel: label("settings.reset"),
1929
+ invalidLabel: label("settings.invalidValue"),
1930
+ disabled: !state.writable
1931
+ };
1932
+ const rows = parseAgentRowsText(state.agentCommands.text);
1933
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(PluginSettingsCard, {
1934
+ t: translate,
1935
+ titleKey: "settings.title",
1936
+ descriptionKey: "settings.description",
1937
+ density: "nested",
1938
+ defaultOpen: false,
1939
+ state,
1940
+ onSave: props.save,
1941
+ onDiscard: props.discard,
1942
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(BooleanField, {
1943
+ id: "settings-task-board-ssh-enabled",
1944
+ label: label("settings.enabled"),
1945
+ hint: label("settings.enabledConsequence"),
1946
+ hintTitle: label("settings.enabledHint"),
1947
+ onLabel: label("settings.on"),
1948
+ offLabel: label("settings.offLabel"),
1949
+ inheritLabel: label("settings.inherit"),
1950
+ ...fieldCopy,
1951
+ ...state.enabled,
1952
+ onEdit: (text) => props.edit("enabled", text),
1953
+ onReset: () => props.resetField("enabled")
1954
+ }), enabled ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
1955
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
1956
+ className: ssh_module_css_default.quietField,
1957
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ChoiceField, {
1958
+ id: "settings-task-board-ssh-mode",
1959
+ label: label("settings.defaultMode"),
1960
+ hint: "",
1961
+ presentation: "segment",
1962
+ inheritLabel: label("settings.inherit"),
1963
+ choices: [{
1964
+ value: "direct",
1965
+ label: modeName("direct")
1966
+ }, {
1967
+ value: "proxy",
1968
+ label: modeName("proxy")
1969
+ }],
1970
+ ...fieldCopy,
1971
+ ...state.defaultMode,
1972
+ onEdit: (text) => props.edit("defaultMode", text),
1973
+ onReset: () => props.resetField("defaultMode")
1974
+ })
1975
+ }),
1976
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
1977
+ className: ssh_module_css_default.quietField,
1978
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ChoiceField, {
1979
+ id: "settings-task-board-ssh-agent",
1980
+ label: label("settings.defaultAgent"),
1981
+ hint: "",
1982
+ inheritLabel: label("settings.inherit"),
1983
+ choices: SSH_AGENT_KINDS.map((kind) => ({
1984
+ value: kind,
1985
+ label: agentName(kind)
1986
+ })),
1987
+ ...fieldCopy,
1988
+ ...state.defaultAgent,
1989
+ onEdit: (text) => props.edit("defaultAgent", text),
1990
+ onReset: () => props.resetField("defaultAgent")
1991
+ })
1992
+ }),
1993
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
1994
+ className: ssh_module_css_default.quietField,
1995
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ValueField, {
1996
+ id: "settings-task-board-ssh-host",
1997
+ label: label("settings.defaultHost"),
1998
+ hint: "",
1999
+ placeholder: label("settings.defaultHostPlaceholder"),
2000
+ ...fieldCopy,
2001
+ ...state.defaultHost,
2002
+ onEdit: (text) => props.edit("defaultHost", text),
2003
+ onReset: () => props.resetField("defaultHost")
2004
+ })
2005
+ }),
2006
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ValueField, {
2007
+ id: "settings-task-board-ssh-cap",
2008
+ label: label("settings.perHostCap"),
2009
+ hint: label("settings.perHostCapHint"),
2010
+ numeric: true,
2011
+ placeholder: String(HOST_CAP.fallback),
2012
+ range: {
2013
+ min: HOST_CAP.min,
2014
+ max: HOST_CAP.max,
2015
+ step: HOST_CAP.step
2016
+ },
2017
+ ...fieldCopy,
2018
+ ...state.perHostCap,
2019
+ onEdit: (text) => props.edit("perHostCap", text),
2020
+ onReset: () => props.resetField("perHostCap")
2021
+ }),
2022
+ OVERRIDE_AGENTS.map((kind) => {
2023
+ const row = rows.find((entry) => entry.kind === kind);
2024
+ const rowInvalid = row !== void 0 && (validateCustomTemplate(row.command) !== void 0 || row.resumeCommand !== void 0 && validateCustomTemplate(row.resumeCommand) !== void 0);
2025
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ValueField, {
2026
+ id: `settings-task-board-ssh-command-${kind}`,
2027
+ label: agentName(kind),
2028
+ hint: label(agentCommandHint(kind)),
2029
+ ...fieldCopy,
2030
+ ...state.agentCommands,
2031
+ text: row?.command ?? "",
2032
+ overridden: row !== void 0,
2033
+ invalid: rowInvalid,
2034
+ onEdit: (text) => props.edit("agentCommands", withAgentCommand(state.agentCommands.text, kind, text)),
2035
+ onReset: () => props.edit("agentCommands", withAgentCommand(state.agentCommands.text, kind, ""))
2036
+ }, kind);
2037
+ })
2038
+ ] }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
2039
+ className: ssh_module_css_default.sectionHint,
2040
+ children: label("settings.disabledNotice")
2041
+ })]
2042
+ });
2043
+ }
2044
+ //#endregion
2045
+ //#region src/core/contract.ts
2046
+ /** Cordis service name the board's host and browser halves each publish. */
2047
+ const TASK_BOARD_SERVICE_NAME = "taskBoard";
2048
+ /** Child seat a provider registers its task-detail section into. */
2049
+ const TASK_BOARD_DETAIL_SECTION = "task-board.detail.section";
2050
+ /** Child seat a provider registers its settings section into. */
2051
+ const TASK_BOARD_SETTINGS_SECTION = "task-board.settings.section";
2052
+ /** Child seat a provider registers its card decoration into. */
2053
+ const TASK_BOARD_CARD_DECORATION = "task-board.card.decoration";
2054
+ /**
2055
+ * Child seat a provider registers its new-card section into: its own
2056
+ * create-time configuration, rendered inside the create dialog's execution
2057
+ * settings, whose draft the board stores on the card it creates.
2058
+ */
2059
+ const TASK_BOARD_COMPOSE_SECTION = "task-board.compose.section";
2060
+ /** Largest accepted free text a provider pushes into an execution, in characters. */
2061
+ const TASK_BOARD_MESSAGE_MAX_LENGTH = 4e3;
2062
+ /**
2063
+ * Resolve the browser half's client capability face by service name. Returns
2064
+ * undefined when the board is not loaded, so a provider's browser half can
2065
+ * degrade instead of throwing.
2066
+ * @param ctx - client context.
2067
+ * @returns the client face, or undefined.
2068
+ */
2069
+ function resolveTaskBoardClientFace(ctx) {
2070
+ try {
2071
+ const face = ctx.get(TASK_BOARD_SERVICE_NAME);
2072
+ return face !== void 0 && typeof face.dispatch === "function" ? face : void 0;
2073
+ } catch {
2074
+ return;
2075
+ }
2076
+ }
2077
+ /** Longest stored instruction text, in characters; the board's own message ceiling. */
2078
+ const SSH_PENDING_TEXT_MAX_LENGTH = TASK_BOARD_MESSAGE_MAX_LENGTH;
2079
+ /**
2080
+ * Read one queued instruction.
2081
+ *
2082
+ * Host-owned bookkeeping that a card may also have carried across builds, so
2083
+ * every field is re-validated and an unknown member makes the instruction
2084
+ * unusable: a message this build cannot interpret is not one it may hand an
2085
+ * agent. Nothing is trimmed here — the parsers report, the trimmer bounds.
2086
+ * @param value - the stored member.
2087
+ * @returns the instruction, or undefined when it is absent or unusable.
2088
+ */
2089
+ function parsePendingInstruction(value) {
2090
+ if (typeof value !== "object" || value === null || Array.isArray(value)) return void 0;
2091
+ const record = value;
2092
+ const known = /* @__PURE__ */ new Set([
2093
+ "kind",
2094
+ "text",
2095
+ "queuedAt",
2096
+ "resumeSessionId"
2097
+ ]);
2098
+ if (Object.keys(record).some((key) => !known.has(key))) return void 0;
2099
+ const kind = record.kind === "follow-up" || record.kind === "rework" ? record.kind : void 0;
2100
+ const text = typeof record.text === "string" && record.text.trim() !== "" && record.text.length <= SSH_PENDING_TEXT_MAX_LENGTH ? record.text : void 0;
2101
+ const queuedAt = typeof record.queuedAt === "number" && Number.isFinite(record.queuedAt) ? record.queuedAt : void 0;
2102
+ if (kind === void 0 || text === void 0 || queuedAt === void 0) return void 0;
2103
+ const pending = {
2104
+ kind,
2105
+ text,
2106
+ queuedAt
2107
+ };
2108
+ if (record.resumeSessionId !== void 0) {
2109
+ const sessionId = typeof record.resumeSessionId === "string" && record.resumeSessionId !== "" && record.resumeSessionId.length <= 200 ? record.resumeSessionId : void 0;
2110
+ if (sessionId === void 0) return void 0;
2111
+ pending.resumeSessionId = sessionId;
2112
+ }
2113
+ return pending;
2114
+ }
2115
+ /**
2116
+ * Parse one stored payload.
2117
+ *
2118
+ * The container is read strictly (version, timestamp, history array) while a
2119
+ * single malformed history entry — or an unusable queued instruction — is
2120
+ * dropped alone, the same rule the board applies to integrations: one bad member
2121
+ * never takes the card's account with it. Nothing here throws, so a corrupted
2122
+ * payload degrades to a readable one.
2123
+ * @param value - candidate payload from the ledger or an action.
2124
+ * @returns the payload, or every reason it was refused.
2125
+ */
2126
+ function parseSshLedgerPayload(value) {
2127
+ const errors = [];
2128
+ if (typeof value !== "object" || value === null || Array.isArray(value)) return {
2129
+ ok: false,
2130
+ errors: [{
2131
+ path: "",
2132
+ message: "must be an object"
2133
+ }]
2134
+ };
2135
+ const record = value;
2136
+ if (record.version !== 1) return {
2137
+ ok: false,
2138
+ errors: [{
2139
+ path: "version",
2140
+ message: `must be 1`
2141
+ }]
2142
+ };
2143
+ if (typeof record.updatedAt !== "number" || !Number.isFinite(record.updatedAt)) errors.push({
2144
+ path: "updatedAt",
2145
+ message: "must be a finite millisecond timestamp"
2146
+ });
2147
+ let target;
2148
+ if (record.target !== void 0) {
2149
+ const parsed = parseSshTarget(record.target);
2150
+ if (parsed.ok) target = parsed.value;
2151
+ else errors.push(...parsed.errors.map((issue) => ({
2152
+ path: issue.path === "" ? "target" : `target.${issue.path}`,
2153
+ message: issue.message
2154
+ })));
2155
+ }
2156
+ let activeRun;
2157
+ if (record.activeRun !== void 0) {
2158
+ const parsed = parseSshRunRecord(record.activeRun);
2159
+ if (parsed.ok) activeRun = parsed.value;
2160
+ else errors.push(...parsed.errors.map((issue) => ({
2161
+ path: issue.path === "" ? "activeRun" : `activeRun.${issue.path}`,
2162
+ message: issue.message
2163
+ })));
2164
+ }
2165
+ const history = [];
2166
+ if (record.history !== void 0) if (!Array.isArray(record.history)) errors.push({
2167
+ path: "history",
2168
+ message: "must be an array"
2169
+ });
2170
+ else for (const entry of record.history) {
2171
+ const parsed = parseSshRunRecord(entry);
2172
+ if (parsed.ok) history.push(parsed.value);
2173
+ }
2174
+ if (errors.length > 0) return {
2175
+ ok: false,
2176
+ errors
2177
+ };
2178
+ const payload = {
2179
+ version: 1,
2180
+ updatedAt: record.updatedAt,
2181
+ history
2182
+ };
2183
+ if (target !== void 0) payload.target = target;
2184
+ if (activeRun !== void 0) payload.activeRun = activeRun;
2185
+ const pending = parsePendingInstruction(record.pending);
2186
+ if (pending !== void 0) payload.pending = pending;
2187
+ return {
2188
+ ok: true,
2189
+ value: payload
2190
+ };
2191
+ }
2192
+ /**
2193
+ * The payload a create dialog reports for a card that does not exist yet: the
2194
+ * target the new card pins, and no run account beside it.
2195
+ *
2196
+ * A card being created has never run, so the document carries an empty history
2197
+ * and no active run or queued instruction — exactly what the host half stores
2198
+ * when it pins a target on an existing card, minus the runs. The result is read
2199
+ * back through {@link parseSshLedgerPayload} before it is returned: a draft this
2200
+ * build could store but not read back is never reported at all, so a card
2201
+ * created through a create dialog always opens on a payload its own detail seat
2202
+ * can account for.
2203
+ * @param target - the target the reader picked, already parsed.
2204
+ * @param updatedAt - instant the draft is reported (ms epoch).
2205
+ * @returns the payload, or undefined when the document does not parse.
2206
+ */
2207
+ function composeDraftPayload(target, updatedAt) {
2208
+ const draft = {
2209
+ version: 1,
2210
+ updatedAt,
2211
+ history: [],
2212
+ target
2213
+ };
2214
+ return parseSshLedgerPayload(draft).ok ? draft : void 0;
2215
+ }
2216
+ //#endregion
2217
+ //#region src/client/ssh/model.ts
2218
+ /**
2219
+ * What a card's SSH payload means, derived as pure functions.
2220
+ *
2221
+ * Every predicate the card badge and the detail section consult lives here, and
2222
+ * none of them reads a clock, issues a request, or allocates more than the
2223
+ * record it was handed: the badge renders on every card of every column on
2224
+ * every mirror frame, so "cheap" is a property the tests pin rather than an
2225
+ * intention. The reader is deliberately lenient — one unreadable field costs
2226
+ * that field, never the card's whole account — because the payload arrives from
2227
+ * a host half that may be a version ahead of this browser bundle.
2228
+ *
2229
+ * @module dsh-task-board-ssh/client/ssh/model
2230
+ */
2231
+ /** Versions of the stored payload this reader understands. */
2232
+ const READABLE_PAYLOAD_VERSIONS = /* @__PURE__ */ new Set([1]);
2233
+ /** Whether a value is a plain object (not an array, not null). */
2234
+ function isPlainObject$1(value) {
2235
+ return typeof value === "object" && value !== null && !Array.isArray(value);
2236
+ }
2237
+ /** One card with nothing pinned. */
2238
+ const NO_VIEW = { phase: "idle" };
2239
+ /**
2240
+ * Read a card's SSH payload leniently.
2241
+ *
2242
+ * The container is accepted at a version this reader knows; a payload stamped
2243
+ * with a version it does not know is refused whole, exactly as the ledger's own
2244
+ * parser refuses it, because guessing at a future shape is worse than showing
2245
+ * an untargeted card. Inside a readable container each record is parsed on its
2246
+ * own, so one corrupt run never hides the target or the other runs.
2247
+ * @param task - card to read.
2248
+ * @returns the parsed pieces, or undefined when the card carries no readable payload.
2249
+ */
2250
+ function readSshLedger(task) {
2251
+ const raw = task.integrations?.["ssh"];
2252
+ if (!isPlainObject$1(raw)) return void 0;
2253
+ if (typeof raw.version === "number" && !READABLE_PAYLOAD_VERSIONS.has(raw.version)) return void 0;
2254
+ const target = parseSshTarget(raw.target);
2255
+ const activeRun = parseSshRunRecord(raw.activeRun);
2256
+ const history = [];
2257
+ if (Array.isArray(raw.history)) for (const entry of raw.history) {
2258
+ const parsed = parseSshRunRecord(entry);
2259
+ if (parsed.ok) history.push(parsed.value);
2260
+ }
2261
+ const pendingKind = isPlainObject$1(raw.pending) && (raw.pending.kind === "follow-up" || raw.pending.kind === "rework") ? raw.pending.kind : void 0;
2262
+ return {
2263
+ ...target.ok ? { target: target.value } : {},
2264
+ ...activeRun.ok ? { activeRun: activeRun.value } : {},
2265
+ ...pendingKind === void 0 ? {} : { pending: pendingKind },
2266
+ history
2267
+ };
2268
+ }
2269
+ /**
2270
+ * Derive everything the card badge and the detail section show.
2271
+ *
2272
+ * Pure and allocation-light by contract: at most one record copy from the
2273
+ * lenient reader, no request, no clock.
2274
+ * @param task - card to derive.
2275
+ * @returns the view; {@link NO_VIEW} when the card pins nothing.
2276
+ */
2277
+ function sshCardView(task) {
2278
+ const ledger = readSshLedger(task);
2279
+ if (ledger === void 0) return NO_VIEW;
2280
+ const lastRun = ledger.history.length > 0 ? ledger.history[ledger.history.length - 1] : void 0;
2281
+ const from = ledger.activeRun ?? lastRun;
2282
+ const view = { phase: from?.phase ?? "idle" };
2283
+ if (ledger.target !== void 0) view.target = ledger.target;
2284
+ if (ledger.activeRun !== void 0) view.activeRun = ledger.activeRun;
2285
+ if (lastRun !== void 0) view.lastRun = lastRun;
2286
+ if (from !== void 0) view.runId = from.runId;
2287
+ if (ledger.pending !== void 0) view.pending = ledger.pending;
2288
+ return view;
2289
+ }
2290
+ /**
2291
+ * Whether a phase means a run is under way.
2292
+ * @param phase - phase to test.
2293
+ * @returns true for queued and running.
2294
+ */
2295
+ function isSshRunActive(phase) {
2296
+ return phase === "queued" || phase === "running";
2297
+ }
2298
+ /**
2299
+ * Map one parser path onto the form field that carries it.
2300
+ * @param path - dotted path the core parser reported.
2301
+ * @returns the field, or undefined for a path the form cannot address.
2302
+ */
2303
+ function fieldOfIssue(path) {
2304
+ if (path === "mode") return "mode";
2305
+ if (path === "host") return "host";
2306
+ if (path === "agent" || path === "agent.kind") return "agent";
2307
+ if (path === "agent.command") return "agentCommand";
2308
+ if (path === "agent.resumeCommand") return "agentResumeCommand";
2309
+ if (path === "workspace" || path === "workspace.kind") return "workspaceKind";
2310
+ if (path === "workspace.path") return "workspacePath";
2311
+ if (path === "workspace.source" || path === "workspace.source.kind") return "gitSource";
2312
+ if (path === "workspace.source.url") return "repositoryUrl";
2313
+ if (path === "workspace.source.base") return "baseBranch";
2314
+ if (path === "workspace.source.workspaceId") return "workspaceId";
2315
+ }
2316
+ /**
2317
+ * Build the wire shape a draft describes, leaving out the fields the chosen
2318
+ * mode and workspace kind do not use.
2319
+ *
2320
+ * Leaving them out is what makes the parser's verdict match what the form
2321
+ * showed: a hidden field can neither pass nor fail.
2322
+ * @param draft - the form's state.
2323
+ * @returns a candidate target for {@link parseSshTarget}.
2324
+ */
2325
+ function draftToTarget(draft) {
2326
+ const agent = draft.mode === "proxy" ? { kind: "dsh" } : { kind: draft.agent };
2327
+ if (draft.mode !== "proxy" && draft.agent === "custom") {
2328
+ agent.command = draft.agentCommand;
2329
+ if (draft.agentResumeCommand.trim() !== "") agent.resumeCommand = draft.agentResumeCommand;
2330
+ }
2331
+ let workspace;
2332
+ if (draft.workspaceKind === "in-place") workspace = {
2333
+ kind: "in-place",
2334
+ path: draft.workspacePath
2335
+ };
2336
+ else if (draft.mode === "proxy" || draft.gitSource === "url") {
2337
+ const source = {
2338
+ kind: "url",
2339
+ url: draft.repositoryUrl
2340
+ };
2341
+ if (draft.baseBranch.trim() !== "") source.base = draft.baseBranch;
2342
+ workspace = {
2343
+ kind: "git",
2344
+ source
2345
+ };
2346
+ } else workspace = {
2347
+ kind: "git",
2348
+ source: {
2349
+ kind: "workspace",
2350
+ workspaceId: draft.workspaceId
2351
+ }
2352
+ };
2353
+ return {
2354
+ mode: draft.mode,
2355
+ host: draft.host,
2356
+ agent,
2357
+ workspace
2358
+ };
2359
+ }
2360
+ /**
2361
+ * Validate a draft through the frozen parser, addressing refusals per field.
2362
+ * @param draft - the form's state.
2363
+ * @param parse - target parser; defaults to the frozen core parser.
2364
+ * @returns the target, or the refusals keyed by field.
2365
+ */
2366
+ function validateDraft(draft, parse = parseSshTarget) {
2367
+ const parsed = parse(draftToTarget(draft));
2368
+ if (parsed.ok) return {
2369
+ target: parsed.value,
2370
+ errors: {},
2371
+ issues: []
2372
+ };
2373
+ const errors = {};
2374
+ for (const issue of parsed.errors) {
2375
+ const field = fieldOfIssue(issue.path);
2376
+ if (field !== void 0 && errors[field] === void 0) errors[field] = issue;
2377
+ }
2378
+ return {
2379
+ errors,
2380
+ issues: parsed.errors
2381
+ };
2382
+ }
2383
+ /**
2384
+ * Read a card's form state out of its target, filling the rest from defaults.
2385
+ * @param target - the pinned target, when the card has one.
2386
+ * @param defaults - the published defaults, when the provider publishes any.
2387
+ * @returns the draft the form opens with.
2388
+ */
2389
+ function draftOf(target, defaults) {
2390
+ const draft = {
2391
+ mode: defaults?.mode ?? "direct",
2392
+ host: defaults?.host ?? "",
2393
+ agent: defaults?.agent ?? "dsh",
2394
+ agentCommand: "",
2395
+ agentResumeCommand: "",
2396
+ workspaceKind: defaults?.workspace ?? "in-place",
2397
+ gitSource: "url",
2398
+ workspacePath: "",
2399
+ repositoryUrl: "",
2400
+ baseBranch: "",
2401
+ workspaceId: ""
2402
+ };
2403
+ if (target === void 0) return draft;
2404
+ draft.mode = target.mode;
2405
+ draft.host = target.host;
2406
+ draft.agent = target.agent.kind;
2407
+ if (target.agent.command !== void 0) draft.agentCommand = target.agent.command;
2408
+ if (target.agent.resumeCommand !== void 0) draft.agentResumeCommand = target.agent.resumeCommand;
2409
+ draft.workspaceKind = target.workspace.kind;
2410
+ if (target.workspace.kind === "in-place") {
2411
+ draft.workspacePath = target.workspace.path;
2412
+ return draft;
2413
+ }
2414
+ if (target.workspace.source.kind === "url") {
2415
+ draft.gitSource = "url";
2416
+ draft.repositoryUrl = target.workspace.source.url;
2417
+ draft.baseBranch = target.workspace.source.base ?? "";
2418
+ return draft;
2419
+ }
2420
+ draft.gitSource = "workspace";
2421
+ draft.workspaceId = target.workspace.source.workspaceId;
2422
+ return draft;
2423
+ }
2424
+ /**
2425
+ * One line describing a pinned target, for the detail summary.
2426
+ *
2427
+ * The host, the agent and the workspace are three facts of one sentence, so
2428
+ * they stay three template values rather than three labelled rows.
2429
+ * @param target - the pinned target.
2430
+ * @returns the pieces the caller interpolates.
2431
+ */
2432
+ function targetSummaryParts(target) {
2433
+ const workspace = target.workspace.kind === "in-place" ? target.workspace.path : target.workspace.source.kind === "url" ? target.workspace.source.url : target.workspace.source.workspaceId;
2434
+ return {
2435
+ host: target.host,
2436
+ agent: target.agent.kind,
2437
+ workspace
2438
+ };
2439
+ }
2440
+ //#endregion
2441
+ //#region src/client/ssh/summary.ts
2442
+ /**
2443
+ * The summary this provider's host half publishes, and the store the browser
2444
+ * half renders it from.
2445
+ *
2446
+ * The host half calls the board capability face's `publish(summary)`; the board
2447
+ * carries that document in its snapshot and hands it to every bookmarking
2448
+ * client inside the mirror's `extensions` map. It is therefore the browser
2449
+ * half's only host-to-client data channel besides the ledger payload on each
2450
+ * card — the action channel returns a boolean, not a reply — so everything the
2451
+ * seats need that is not a card fact travels here: the host list behind the
2452
+ * target form's picker, the provider's defaults, and the byte windows of the
2453
+ * log being read.
2454
+ *
2455
+ * Nothing here is trusted: every field is read defensively and an unknown shape
2456
+ * reads as absent, exactly like the GitHub provider's summary reader.
2457
+ *
2458
+ * @module dsh-task-board-ssh/client/ssh/summary
2459
+ */
2460
+ /** Whether a value is a plain object (not an array, not null). */
2461
+ function isPlainObject(value) {
2462
+ return typeof value === "object" && value !== null && !Array.isArray(value);
2463
+ }
2464
+ /** Read one bounded string field. */
2465
+ function readText(value) {
2466
+ return typeof value === "string" ? value : void 0;
2467
+ }
2468
+ /** Read the host list, dropping entries a picker cannot use. */
2469
+ function decodeHosts(value) {
2470
+ if (!Array.isArray(value)) return void 0;
2471
+ const hosts = [];
2472
+ for (const entry of value) {
2473
+ if (!isPlainObject(entry)) continue;
2474
+ const alias = readText(entry.alias);
2475
+ const host = readText(entry.host);
2476
+ const user = readText(entry.user);
2477
+ if (alias === void 0 || host === void 0 || user === void 0) continue;
2478
+ const decoded = {
2479
+ alias,
2480
+ host,
2481
+ user,
2482
+ port: typeof entry.port === "number" ? entry.port : 22
2483
+ };
2484
+ const environment = readText(entry.environment);
2485
+ const description = readText(entry.description);
2486
+ if (environment !== void 0) decoded.environment = environment;
2487
+ if (description !== void 0) decoded.description = description;
2488
+ hosts.push(decoded);
2489
+ }
2490
+ return hosts;
2491
+ }
2492
+ /** Read the prefill defaults. */
2493
+ function decodeDefaults(value) {
2494
+ if (!isPlainObject(value)) return void 0;
2495
+ const defaults = {};
2496
+ if (typeof value.host === "string" && value.host !== "") defaults.host = value.host;
2497
+ if (value.mode === "direct" || value.mode === "proxy") defaults.mode = value.mode;
2498
+ if (value.agent === "dsh" || value.agent === "claude" || value.agent === "codex" || value.agent === "custom") defaults.agent = value.agent;
2499
+ if (value.workspace === "in-place" || value.workspace === "git") defaults.workspace = value.workspace;
2500
+ return Object.keys(defaults).length === 0 ? void 0 : defaults;
2501
+ }
2502
+ /** Read the per-host caps, keeping only finite positive numbers. */
2503
+ function decodeCaps(value) {
2504
+ if (!isPlainObject(value)) return void 0;
2505
+ const caps = {};
2506
+ for (const [alias, cap] of Object.entries(value)) if (typeof cap === "number" && Number.isFinite(cap) && cap > 0) caps[alias] = Math.floor(cap);
2507
+ return Object.keys(caps).length === 0 ? void 0 : caps;
2508
+ }
2509
+ /** Read the log windows, keyed by card id. */
2510
+ function decodeLogs(value) {
2511
+ if (!isPlainObject(value)) return void 0;
2512
+ const logs = {};
2513
+ for (const [taskId, entry] of Object.entries(value)) {
2514
+ if (!isPlainObject(entry)) continue;
2515
+ const runId = readText(entry.runId);
2516
+ if (runId === void 0 || typeof entry.text !== "string") continue;
2517
+ if (typeof entry.baseOffset !== "number" || typeof entry.endOffset !== "number") continue;
2518
+ const window = {
2519
+ runId,
2520
+ baseOffset: entry.baseOffset,
2521
+ endOffset: entry.endOffset,
2522
+ text: entry.text
2523
+ };
2524
+ if (entry.truncated === true) window.truncated = true;
2525
+ if (entry.hasMore === true) window.hasMore = true;
2526
+ logs[taskId] = window;
2527
+ }
2528
+ return Object.keys(logs).length === 0 ? void 0 : logs;
2529
+ }
2530
+ /** Read the published runs, dropping entries a card cannot address. */
2531
+ function decodeRuns(value) {
2532
+ if (!Array.isArray(value)) return void 0;
2533
+ const runs = [];
2534
+ for (const entry of value) {
2535
+ if (!isPlainObject(entry)) continue;
2536
+ const taskId = readText(entry.taskId);
2537
+ const runId = readText(entry.runId);
2538
+ const host = readText(entry.host);
2539
+ const phase = entry.phase;
2540
+ if (taskId === void 0 || runId === void 0 || host === void 0) continue;
2541
+ if (phase !== "queued" && phase !== "running" && phase !== "succeeded" && phase !== "failed" && phase !== "cancelled" && phase !== "lost") continue;
2542
+ const run = {
2543
+ taskId,
2544
+ runId,
2545
+ phase,
2546
+ host
2547
+ };
2548
+ if (typeof entry.bytes === "number" && Number.isFinite(entry.bytes)) run.bytes = entry.bytes;
2549
+ if (typeof entry.untrackedFiles === "number" && Number.isFinite(entry.untrackedFiles) && entry.untrackedFiles > 0) run.untrackedFiles = entry.untrackedFiles;
2550
+ runs.push(run);
2551
+ }
2552
+ return runs.length === 0 ? void 0 : runs;
2553
+ }
2554
+ /**
2555
+ * Normalize whatever the board hands back; a foreign payload reads as absent.
2556
+ * @param value - the mirror's entry for this extension.
2557
+ * @returns the summary, or undefined when nothing usable is published.
2558
+ */
2559
+ function decodeSummary(value) {
2560
+ if (!isPlainObject(value)) return void 0;
2561
+ const summary = {};
2562
+ if (typeof value.enabled === "boolean") summary.enabled = value.enabled;
2563
+ const hosts = decodeHosts(value.hosts);
2564
+ if (hosts !== void 0) summary.hosts = hosts;
2565
+ const defaults = decodeDefaults(value.defaults);
2566
+ if (defaults !== void 0) summary.defaults = defaults;
2567
+ const caps = decodeCaps(value.caps);
2568
+ if (caps !== void 0) summary.caps = caps;
2569
+ const logs = decodeLogs(value.logs);
2570
+ if (logs !== void 0) summary.logs = logs;
2571
+ const runs = decodeRuns(value.runs);
2572
+ if (runs !== void 0) summary.runs = runs;
2573
+ return summary;
2574
+ }
2575
+ let current;
2576
+ /** How many mirror frames this page has observed. */
2577
+ let framesSeen = 0;
2578
+ /** Whether any observed frame carried this extension's summary. */
2579
+ let publishedEver = false;
2580
+ /** Registered local workspaces published by the board client mirror. */
2581
+ let boardWorkspaces = [];
2582
+ /** Most recent board transport error (e.g. Host refusal on an extension action). */
2583
+ let lastBoardError;
2584
+ const listeners = /* @__PURE__ */ new Set();
2585
+ /** Notify every subscriber, isolating each one. */
2586
+ function notify() {
2587
+ for (const listener of [...listeners]) try {
2588
+ listener();
2589
+ } catch {}
2590
+ }
2591
+ /** Replace the stored summary; an unchanged value notifies nobody. */
2592
+ function setSummary(next) {
2593
+ if (current === next) return;
2594
+ current = next;
2595
+ notify();
2596
+ }
2597
+ /**
2598
+ * Read one client mirror frame: store this extension's summary and record
2599
+ * whether the frame carried it at all.
2600
+ *
2601
+ * The presence of the key is the evidence, not the shape of its value: a
2602
+ * registered provider publishes a summary even before it has anything to report,
2603
+ * and an unregistered one publishes nothing at all.
2604
+ * @param published - the mirror's `extensions` map.
2605
+ */
2606
+ function acceptPublishedSummary(published) {
2607
+ const before = getHostHalfStatus();
2608
+ framesSeen += 1;
2609
+ if (Object.hasOwn(published, "ssh")) publishedEver = true;
2610
+ setSummary(decodeSummary(published["ssh"]));
2611
+ if (getHostHalfStatus() !== before) notify();
2612
+ }
2613
+ /** Drop the summary (the board reports the extension is not running). */
2614
+ function clearSummary() {
2615
+ setSummary(void 0);
2616
+ }
2617
+ /**
2618
+ * Whether the provider's host half is mounted, as far as this page can tell.
2619
+ * @returns the status; `unknown` until the first mirror frame arrives.
2620
+ */
2621
+ function getHostHalfStatus() {
2622
+ if (publishedEver) return "mounted";
2623
+ return framesSeen === 0 ? "unknown" : "unmounted";
2624
+ }
2625
+ /** Update supplemental board mirror context (local workspaces + last Host refusal). */
2626
+ function acceptBoardContext(context) {
2627
+ let changed = false;
2628
+ if (context.workspaces !== void 0) {
2629
+ const prev = boardWorkspaces;
2630
+ const next = context.workspaces;
2631
+ if (prev.length !== next.length || prev.some((item, index) => item.workspaceId !== next[index]?.workspaceId || item.title !== next[index]?.title)) {
2632
+ boardWorkspaces = next;
2633
+ changed = true;
2634
+ }
2635
+ }
2636
+ if (lastBoardError !== context.lastError) lastBoardError = context.lastError;
2637
+ if (changed) notify();
2638
+ }
2639
+ /** Most recent Host transport/action refusal reported by the board mirror. */
2640
+ function getLastBoardError() {
2641
+ return lastBoardError;
2642
+ }
2643
+ /** Registered local workspaces observed from the board mirror. */
2644
+ function getBoardWorkspaces() {
2645
+ return boardWorkspaces;
2646
+ }
2647
+ /** Observe the registered local workspaces from a React component. */
2648
+ function useBoardWorkspaces() {
2649
+ return (0, react.useSyncExternalStore)(subscribe, getBoardWorkspaces, getBoardWorkspaces);
2650
+ }
2651
+ /** The current summary, or undefined while none is published. */
2652
+ function getSummary() {
2653
+ return current;
2654
+ }
2655
+ function subscribe(listener) {
2656
+ listeners.add(listener);
2657
+ return () => {
2658
+ listeners.delete(listener);
2659
+ };
2660
+ }
2661
+ /**
2662
+ * Observe the published summary from a React component.
2663
+ * @returns the current summary, or undefined while none is published.
2664
+ */
2665
+ function usePublishedSummary() {
2666
+ return (0, react.useSyncExternalStore)(subscribe, getSummary, getSummary);
2667
+ }
2668
+ /**
2669
+ * Observe whether the provider's host half is mounted.
2670
+ * @returns the status, re-rendering when the first frame settles it.
2671
+ */
2672
+ function useHostHalfStatus() {
2673
+ return (0, react.useSyncExternalStore)(subscribe, getHostHalfStatus, getHostHalfStatus);
2674
+ }
2675
+ //#endregion
2676
+ //#region src/client/locales.ts
2677
+ /**
2678
+ * Copy for the SSH provider's browser half: a zh dictionary with the English
2679
+ * counterpart beside it. The zh side is the key-set source of truth;
2680
+ * `packages/dsh-i18n` mirrors the keys into the centralized ru dictionary and
2681
+ * `pnpm i18n:check` enforces the parity.
2682
+ *
2683
+ * Prefixes: `settings.*` is the section inside the board's own settings card
2684
+ * (its shared chrome plus this provider's switches), `detail.*` is the
2685
+ * task-detail seat and the field set it shares with the create dialog,
2686
+ * `compose.*` is the create dialog's own row, `run.*` is the run-phase
2687
+ * vocabulary the detail seat and the card badge share, and `card.*` is the
2688
+ * badge itself.
2689
+ *
2690
+ * @module dsh-task-board-ssh/client/locales
2691
+ */
2692
+ /** Extension copy, key source of truth. */
2693
+ const zh = {
2694
+ "settings.title": "SSH 远程执行",
2695
+ "settings.description": "把这张看板的卡片送到经 dsh-ssh 触达的主机上执行。",
2696
+ "settings.enabled": "启用远程执行",
2697
+ "settings.enabledConsequence": "关闭后不再向主机派发运行;已产生的运行记录与远端日志保留。",
2698
+ "settings.enabledHint": "关闭后本扩展不再登记详情区与卡片徽标,也不再向主机派发运行;本区块保留,随时可以重新开启。已经产生的运行记录与远端日志不受影响。",
2699
+ "settings.defaultMode": "默认模式",
2700
+ "settings.defaultAgent": "默认 Agent",
2701
+ "settings.defaultHost": "默认主机",
2702
+ "settings.defaultHostPlaceholder": "dsh-ssh 主机别名",
2703
+ "settings.perHostCap": "每主机并发上限",
2704
+ "settings.perHostCapHint": "同一台主机上同时运行的卡片数,超出的请求按提交顺序排队。",
2705
+ "settings.agentCommandHint.dsh": "留空即用 dsh headless 命令行;模板必须引用 {prompt_file}。",
2706
+ "settings.agentCommandHint.claude": "留空即用 claude -p 命令行;模板必须引用 {prompt_file}。",
2707
+ "settings.agentCommandHint.codex": "留空即用 codex exec 命令行;模板必须引用 {prompt_file}。",
2708
+ "settings.disabledNotice": "关闭中:以下默认值与命令覆写暂不生效,打开上面的开关即可继续配置。",
2709
+ "settings.on": "开",
2710
+ "settings.offLabel": "关",
2711
+ "settings.inherit": "继承默认",
2712
+ "settings.overridden": "已覆盖",
2713
+ "settings.reset": "重置",
2714
+ "settings.invalidValue": "该取值不被接受",
2715
+ "settings.collapse": "收起设置",
2716
+ "settings.expand": "展开设置",
2717
+ "settings.notExposed": "当前 DSH 版本未向设置页暴露本插件的配置命名空间,表单不可用。可编辑 ~/.dsh/settings.yaml 直接配置,或将本命名空间加入 Host 设置白名单后重启。",
2718
+ "settings.readOnly": "当前部署的设置只读。",
2719
+ "settings.saveFailed": "部署未接受这些值,已保留供你修改。",
2720
+ "detail.target": "执行目标",
2721
+ "detail.hostHalfMissing": "需要先在插件管理里启用 SSH 插件",
2722
+ "detail.setTarget": "设置执行目标",
2723
+ "detail.editTarget": "编辑目标",
2724
+ "detail.cancelEdit": "收起目标",
2725
+ "detail.mode": "模式",
2726
+ "detail.mode.direct": "直接执行",
2727
+ "detail.mode.proxy": "本地代理",
2728
+ "detail.modeHintDirect": "在主机上直接起一个 headless agent,本机离线也不影响它。",
2729
+ "detail.modeHintProxy": "本机开一个会话,用 ssh 工具驱动主机;本机离线即中断。",
2730
+ "detail.host": "主机",
2731
+ "detail.hostNone": "没有可用主机",
2732
+ "detail.hostMissing": "在 dsh-ssh 设置里添加主机后,这里才能选择。",
2733
+ "detail.hostUnknown": "已不在 dsh-ssh 的主机列表中:{alias}",
2734
+ "detail.agent": "Agent",
2735
+ "detail.agent.dsh": "dsh",
2736
+ "detail.agent.claude": "Claude Code",
2737
+ "detail.agent.codex": "Codex",
2738
+ "detail.agent.custom": "自定义",
2739
+ "detail.agentCommand": "启动命令",
2740
+ "detail.agentResumeCommand": "续跑命令",
2741
+ "detail.workspace": "工作区",
2742
+ "detail.workspace.in-place": "远端目录",
2743
+ "detail.workspace.git": "Git 分支",
2744
+ "detail.workspace.path": "远端路径",
2745
+ "detail.workspace.source": "仓库来源",
2746
+ "detail.workspace.source.url": "远端仓库",
2747
+ "detail.workspace.source.workspace": "本机仓库",
2748
+ "detail.workspace.url": "仓库地址",
2749
+ "detail.workspace.base": "起始分支",
2750
+ "detail.workspace.workspaceId": "本机工作区",
2751
+ "detail.workspace.workspaceIdPlaceholder": "工作区标识",
2752
+ "detail.save": "保存目标",
2753
+ "detail.saving": "保存中",
2754
+ "detail.targetSummary": "{host} · {agent} · {workspace}",
2755
+ "detail.rejected": "看板没有接受这次操作。",
2756
+ "detail.error.host": "选择一台主机。",
2757
+ "detail.error.path": "填写主机上的绝对路径,需以 / 开头。",
2758
+ "detail.error.agentCommand": "启动命令必须引用 {prompt_file}。",
2759
+ "detail.error.url": "填写主机能访问的仓库地址,不能含空格。",
2760
+ "detail.error.workspaceId": "填写本机工作区的标识。",
2761
+ "detail.error.generic": "该取值不被接受:{error}",
2762
+ "detail.log": "运行日志",
2763
+ "detail.logEmpty": "还没有输出",
2764
+ "detail.logTruncated": "更早的输出已滚出窗口",
2765
+ "detail.logLatest": "跳到最新",
2766
+ "detail.followUp": "追问",
2767
+ "detail.followUpPlaceholder": "写下要它继续做的事",
2768
+ "detail.followUpSend": "发送",
2769
+ "detail.followUpQueued": "本轮结束后发送",
2770
+ "detail.cancel": "取消执行",
2771
+ "detail.cancelling": "取消中",
2772
+ "detail.actionFailed": "操作没有完成:{error}",
2773
+ "detail.untrackedFiles": "{count} 个未跟踪文件未同步",
2774
+ "detail.branch": "分支 {branch}",
2775
+ "run.idle": "待运行",
2776
+ "run.queued": "排队",
2777
+ "run.running": "运行中",
2778
+ "run.succeeded": "已完成",
2779
+ "run.failed": "失败",
2780
+ "run.cancelled": "已取消",
2781
+ "run.lost": "失联",
2782
+ "card.badgeTitle": "{host} · {state}",
2783
+ "compose.remote": "在远程主机上执行"
2784
+ };
2785
+ /** The English counterpart; the same key set, verified by the locale audit. */
2786
+ const en = {
2787
+ "settings.title": "SSH remote execution",
2788
+ "settings.description": "Runs a card of this board on a host reached through dsh-ssh.",
2789
+ "settings.enabled": "Enable remote execution",
2790
+ "settings.enabledConsequence": "No run is dispatched to a host while it is off; recorded runs and their remote logs stay.",
2791
+ "settings.enabledHint": "When off, this extension registers no task-detail section and no card badge, and dispatches no run to a host. This section stays so the switch can be turned back on; recorded runs and remote logs are untouched.",
2792
+ "settings.defaultMode": "Default mode",
2793
+ "settings.defaultAgent": "Default agent",
2794
+ "settings.defaultHost": "Default host",
2795
+ "settings.defaultHostPlaceholder": "dsh-ssh host alias",
2796
+ "settings.perHostCap": "Per-host concurrency",
2797
+ "settings.perHostCapHint": "Cards running at once on one host; anything beyond that waits in submission order.",
2798
+ "settings.agentCommandHint.dsh": "Leave empty for the built-in dsh headless command line; the template must reference {prompt_file}.",
2799
+ "settings.agentCommandHint.claude": "Leave empty for the built-in claude -p command line; the template must reference {prompt_file}.",
2800
+ "settings.agentCommandHint.codex": "Leave empty for the built-in codex exec command line; the template must reference {prompt_file}.",
2801
+ "settings.disabledNotice": "Turned off: the defaults and command overrides below are inactive until the switch above is on.",
2802
+ "settings.on": "On",
2803
+ "settings.offLabel": "Off",
2804
+ "settings.inherit": "Inherit default",
2805
+ "settings.overridden": "Overridden",
2806
+ "settings.reset": "Reset",
2807
+ "settings.invalidValue": "This value is not accepted",
2808
+ "settings.collapse": "Collapse settings",
2809
+ "settings.expand": "Expand settings",
2810
+ "settings.notExposed": "This DSH version does not expose the plugin settings namespace to the settings page, so the form is unavailable. Edit ~/.dsh/settings.yaml directly, or add the namespace to the Host settings allowlist and restart.",
2811
+ "settings.readOnly": "This deployment serves its settings read-only.",
2812
+ "settings.saveFailed": "The deployment did not accept these values; they are kept for you to edit.",
2813
+ "detail.target": "Execution target",
2814
+ "detail.hostHalfMissing": "Enable the SSH plugin in the plugin manager first",
2815
+ "detail.setTarget": "Set an execution target",
2816
+ "detail.editTarget": "Edit target",
2817
+ "detail.cancelEdit": "Collapse target",
2818
+ "detail.mode": "Mode",
2819
+ "detail.mode.direct": "Direct",
2820
+ "detail.mode.proxy": "Local proxy",
2821
+ "detail.modeHintDirect": "Starts a headless agent on the host; it keeps running while this machine is offline.",
2822
+ "detail.modeHintProxy": "Starts a local session that drives the host through the ssh tools; going offline ends it.",
2823
+ "detail.host": "Host",
2824
+ "detail.hostNone": "No host available",
2825
+ "detail.hostMissing": "Add a host in the dsh-ssh settings before choosing one here.",
2826
+ "detail.hostUnknown": "No longer in the dsh-ssh host list: {alias}",
2827
+ "detail.agent": "Agent",
2828
+ "detail.agent.dsh": "dsh",
2829
+ "detail.agent.claude": "Claude Code",
2830
+ "detail.agent.codex": "Codex",
2831
+ "detail.agent.custom": "Custom",
2832
+ "detail.agentCommand": "Start command",
2833
+ "detail.agentResumeCommand": "Resume command",
2834
+ "detail.workspace": "Workspace",
2835
+ "detail.workspace.in-place": "Remote directory",
2836
+ "detail.workspace.git": "Git branch",
2837
+ "detail.workspace.path": "Remote path",
2838
+ "detail.workspace.source": "Repository source",
2839
+ "detail.workspace.source.url": "Remote repository",
2840
+ "detail.workspace.source.workspace": "This workspace",
2841
+ "detail.workspace.url": "Repository URL",
2842
+ "detail.workspace.base": "Starting branch",
2843
+ "detail.workspace.workspaceId": "Workspace",
2844
+ "detail.workspace.workspaceIdPlaceholder": "Workspace id",
2845
+ "detail.save": "Save target",
2846
+ "detail.saving": "Saving",
2847
+ "detail.targetSummary": "{host} · {agent} · {workspace}",
2848
+ "detail.rejected": "The board did not accept that action.",
2849
+ "detail.error.host": "Choose a host.",
2850
+ "detail.error.path": "Enter an absolute path on the host, starting with /.",
2851
+ "detail.error.agentCommand": "The start command must reference {prompt_file}.",
2852
+ "detail.error.url": "Enter a repository URL the host can reach, without spaces.",
2853
+ "detail.error.workspaceId": "Enter the id of a local workspace.",
2854
+ "detail.error.generic": "This value is not accepted: {error}",
2855
+ "detail.log": "Run log",
2856
+ "detail.logEmpty": "No output yet",
2857
+ "detail.logTruncated": "Earlier output left the window",
2858
+ "detail.logLatest": "Jump to latest",
2859
+ "detail.followUp": "Follow-up",
2860
+ "detail.followUpPlaceholder": "What it should do next",
2861
+ "detail.followUpSend": "Send",
2862
+ "detail.followUpQueued": "Sent after this turn ends",
2863
+ "detail.cancel": "Cancel run",
2864
+ "detail.cancelling": "Cancelling",
2865
+ "detail.actionFailed": "The action did not complete: {error}",
2866
+ "detail.untrackedFiles": "{count} untracked files were not sent",
2867
+ "detail.branch": "Branch {branch}",
2868
+ "run.idle": "Ready",
2869
+ "run.queued": "Queued",
2870
+ "run.running": "Running",
2871
+ "run.succeeded": "Done",
2872
+ "run.failed": "Failed",
2873
+ "run.cancelled": "Cancelled",
2874
+ "run.lost": "Lost contact",
2875
+ "card.badgeTitle": "{host} · {state}",
2876
+ "compose.remote": "Run on a remote host"
2877
+ };
2878
+ /** The dictionary this module falls back to when no runtime seat is wired. */
2879
+ function dictionary() {
2880
+ return (typeof document !== "undefined" && document.documentElement.lang !== "" ? document.documentElement.lang : "zh").toLowerCase().startsWith("zh") ? zh : en;
2881
+ }
2882
+ /**
2883
+ * SDK translate seat wired by the browser apply() once ctx.locale is bound.
2884
+ * When present it reads the ACTIVE locale at call time, so the provider's seats
2885
+ * follow a runtime language switch; the document-language pick above stays only
2886
+ * as the unwired fallback.
2887
+ */
2888
+ let runtimeT;
2889
+ /** Wire the SDK translate seat; pass undefined to restore the document-language pick. */
2890
+ function setRuntimeTranslate(t) {
2891
+ runtimeT = t;
2892
+ }
2893
+ /**
2894
+ * Translate one key of this extension's catalog.
2895
+ *
2896
+ * The provider's child seats receive only the contract's owner props, so they
2897
+ * cannot be handed a locale binding the way a plugin card is; this module-level
2898
+ * lookup is what lets them render copy.
2899
+ * @param key - the catalog key.
2900
+ * @param params - optional {name} template values.
2901
+ * @returns the localized text.
2902
+ */
2903
+ function t(key, params) {
2904
+ if (runtimeT !== void 0) return runtimeT(key, params);
2905
+ let text = dictionary()[key];
2906
+ if (params !== void 0) for (const [name, value] of Object.entries(params)) text = text.replaceAll(`{${name}}`, value);
2907
+ return text;
2908
+ }
2909
+ //#endregion
2910
+ //#region src/client/ssh/card-decoration.tsx
2911
+ /** Short plugin name the semantic attributes carry. */
2912
+ const PLUGIN_ATTR$2 = "task-board-ssh";
2913
+ /** Copy key naming one phase; the detail section's pill reads the same table. */
2914
+ function phaseKey$1(phase) {
2915
+ return `run.${phase}`;
2916
+ }
2917
+ /**
2918
+ * Render the card badge.
2919
+ * @param props - the card being decorated.
2920
+ * @returns the chip, or nothing when the card pins no target.
2921
+ */
2922
+ function SshCardDecoration({ task }) {
2923
+ const view = sshCardView(task);
2924
+ const hostHalf = useHostHalfStatus();
2925
+ const target = view.target;
2926
+ if (target === void 0) return null;
2927
+ if (hostHalf === "unmounted") return null;
2928
+ const isProxy = target.mode === "proxy";
2929
+ const state = isProxy ? t("detail.mode.proxy") : t(phaseKey$1(view.phase));
2930
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
2931
+ className: ssh_module_css_default.badge,
2932
+ "data-dsh-plugin": PLUGIN_ATTR$2,
2933
+ "data-dsh-part": "badge",
2934
+ "data-run": isProxy ? "idle" : view.phase,
2935
+ title: t("card.badgeTitle", {
2936
+ host: target.host,
2937
+ state
2938
+ }),
2939
+ children: [
2940
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2941
+ className: ssh_module_css_default.badgeDot,
2942
+ "aria-hidden": "true"
2943
+ }),
2944
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2945
+ className: ssh_module_css_default.badgeHost,
2946
+ children: target.host
2947
+ }),
2948
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2949
+ className: ssh_module_css_default.badgeSeparator,
2950
+ "aria-hidden": "true",
2951
+ children: " · "
2952
+ }),
2953
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2954
+ className: ssh_module_css_default.badgeState,
2955
+ children: state
2956
+ })
2957
+ ]
2958
+ });
2959
+ }
2960
+ //#endregion
2961
+ //#region src/client/ssh/target-form.tsx
2962
+ /**
2963
+ * The target form: everything one card pins about where and how it runs.
2964
+ *
2965
+ * Two frames render these fields — the detail seat's form, which saves one
2966
+ * target onto an existing card, and the create dialog's picker, which reports a
2967
+ * draft the board stores on the card it is about to create. Both frames render
2968
+ * the same {@link SshTargetFields}, so which fields a mode and a workspace kind
2969
+ * actually ask for, and how a refusal is worded, cannot drift between them.
2970
+ *
2971
+ * Only the fields the chosen mode and workspace kind actually use are on
2972
+ * screen, and the value sent is built from exactly those fields — a hidden
2973
+ * field can neither pass nor fail, so what the reader sees is what the parser
2974
+ * judges. Validation runs the frozen core parser before anything leaves the
2975
+ * frame, and its refusals land under the field that carries them, addressed to
2976
+ * the input through `aria-describedby` and `aria-invalid`.
2977
+ *
2978
+ * @module dsh-task-board-ssh/client/ssh/target-form
2979
+ */
2980
+ /** The two execution modes, in the order the form offers them. */
2981
+ const MODES = ["direct", "proxy"];
2982
+ /** The agent CLIs the form offers, in the order the form offers them. */
2983
+ const AGENTS = [
2984
+ "dsh",
2985
+ "claude",
2986
+ "codex",
2987
+ "custom"
2988
+ ];
2989
+ /** The two filesystem mechanisms, in the order the form offers them. */
2990
+ const WORKSPACE_KINDS = ["in-place", "git"];
2991
+ /**
2992
+ * Localized copy for one parser refusal.
2993
+ * @param field - the field the refusal is addressed to.
2994
+ * @param issue - the parser's own sentence, used when the field has no copy of its own.
2995
+ * @returns the sentence to render under the field.
2996
+ */
2997
+ function refusalText(field, issue) {
2998
+ switch (field) {
2999
+ case "host": return t("detail.error.host");
3000
+ case "workspacePath": return t("detail.error.path");
3001
+ case "agentCommand": return t("detail.error.agentCommand");
3002
+ case "repositoryUrl": return t("detail.error.url");
3003
+ case "workspaceId": return t("detail.error.workspaceId");
3004
+ default: return t("detail.error.generic", { error: issue.message });
3005
+ }
3006
+ }
3007
+ /**
3008
+ * Render the fields of one target, in the order a reader walks them.
3009
+ * @param props - the values, the refusals, the hosts to offer and the edit callback.
3010
+ * @returns the field set, in the shape the current draft asks for.
3011
+ */
3012
+ function SshTargetFields({ draft, errors, hosts, workspaces, unknownHost, disabled = false, modeHint, onTouch, onChange }) {
3013
+ const baseId = (0, react.useId)();
3014
+ const mirrorWorkspaces = useBoardWorkspaces();
3015
+ const workspaceOptions = workspaces ?? mirrorWorkspaces;
3016
+ const isProxy = draft.mode === "proxy";
3017
+ const errorFor = (field) => {
3018
+ const issue = errors[field];
3019
+ return issue === void 0 ? void 0 : refusalText(field, issue);
3020
+ };
3021
+ /** Render one labelled text input and its refusal. */
3022
+ const textField = (field, labelKey, value, onChangeText, placeholder) => {
3023
+ const id = `${baseId}-${field}`;
3024
+ const error = errorFor(field);
3025
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
3026
+ className: ssh_module_css_default.field,
3027
+ children: [
3028
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("label", {
3029
+ className: ssh_module_css_default.fieldLabel,
3030
+ htmlFor: id,
3031
+ children: t(labelKey)
3032
+ }),
3033
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
3034
+ id,
3035
+ className: ssh_module_css_default.input,
3036
+ type: "text",
3037
+ value,
3038
+ placeholder,
3039
+ "aria-invalid": error !== void 0,
3040
+ "aria-describedby": error === void 0 ? void 0 : `${id}-error`,
3041
+ onChange: (event) => onChangeText(event.target.value),
3042
+ onBlur: () => onTouch?.(field),
3043
+ disabled
3044
+ }),
3045
+ error !== void 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
3046
+ className: ssh_module_css_default.fieldError,
3047
+ id: `${id}-error`,
3048
+ children: error
3049
+ })
3050
+ ]
3051
+ }, field);
3052
+ };
3053
+ /** Render one labelled choice group whose options are radio inputs. */
3054
+ const choiceGroup = (field, labelKey, options, value, onChangeChoice) => {
3055
+ const error = errorFor(field);
3056
+ const errorId = `${baseId}-${field}-error`;
3057
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("fieldset", {
3058
+ className: ssh_module_css_default.field,
3059
+ "data-invalid": error !== void 0 || void 0,
3060
+ "aria-describedby": error === void 0 ? void 0 : errorId,
3061
+ children: [
3062
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("legend", {
3063
+ className: ssh_module_css_default.fieldLabel,
3064
+ children: t(labelKey)
3065
+ }),
3066
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
3067
+ className: ssh_module_css_default.segments,
3068
+ children: options.map((option) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
3069
+ className: ssh_module_css_default.segment,
3070
+ "data-disabled": disabled || void 0,
3071
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
3072
+ type: "radio",
3073
+ name: `${baseId}-${field}`,
3074
+ value: option.value,
3075
+ checked: value === option.value,
3076
+ onChange: () => onChangeChoice(option.value),
3077
+ disabled
3078
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: t(option.label) })]
3079
+ }, option.value))
3080
+ }),
3081
+ error !== void 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
3082
+ className: ssh_module_css_default.fieldError,
3083
+ id: errorId,
3084
+ children: error
3085
+ })
3086
+ ]
3087
+ }, field);
3088
+ };
3089
+ const hostOptions = hosts.map((host) => ({
3090
+ alias: host.alias,
3091
+ label: `${host.alias} · ${host.user}@${host.host}`
3092
+ }));
3093
+ const hostInList = hostOptions.some((option) => option.alias === draft.host);
3094
+ const hostHint = hostOptions.length === 0 ? t("detail.hostMissing") : void 0;
3095
+ const hostError = hostHint === void 0 ? errorFor("host") : void 0;
3096
+ const hostDescribedBy = [hostHint === void 0 ? void 0 : `${baseId}-host-hint`, hostError === void 0 ? void 0 : `${baseId}-host-error`].filter((part) => part !== void 0).join(" ");
3097
+ const agentError = errorFor("agent");
3098
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
3099
+ className: ssh_module_css_default.fields,
3100
+ "data-dsh-part": "target-fields",
3101
+ children: [
3102
+ choiceGroup("mode", "detail.mode", MODES.map((value) => ({
3103
+ value,
3104
+ label: `detail.mode.${value}`
3105
+ })), draft.mode, (next) => onChange({ mode: next })),
3106
+ modeHint !== void 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
3107
+ className: ssh_module_css_default.fieldHint,
3108
+ children: modeHint
3109
+ }),
3110
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
3111
+ className: ssh_module_css_default.field,
3112
+ children: [
3113
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("label", {
3114
+ className: ssh_module_css_default.fieldLabel,
3115
+ htmlFor: `${baseId}-host`,
3116
+ children: t("detail.host")
3117
+ }),
3118
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("select", {
3119
+ id: `${baseId}-host`,
3120
+ className: ssh_module_css_default.select,
3121
+ value: draft.host,
3122
+ "aria-invalid": hostError !== void 0,
3123
+ "aria-describedby": hostDescribedBy === "" ? void 0 : hostDescribedBy,
3124
+ onChange: (event) => onChange({ host: event.target.value }),
3125
+ onBlur: () => onTouch?.("host"),
3126
+ disabled: disabled || hostOptions.length === 0,
3127
+ children: [
3128
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("option", {
3129
+ value: "",
3130
+ children: t(hostOptions.length === 0 ? "detail.hostNone" : "detail.host")
3131
+ }),
3132
+ !hostInList && unknownHost !== void 0 && unknownHost !== "" && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("option", {
3133
+ value: unknownHost,
3134
+ children: t("detail.hostUnknown", { alias: unknownHost })
3135
+ }),
3136
+ hostOptions.map((option) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("option", {
3137
+ value: option.alias,
3138
+ children: option.label
3139
+ }, option.alias))
3140
+ ]
3141
+ }),
3142
+ hostHint !== void 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
3143
+ className: ssh_module_css_default.fieldHint,
3144
+ id: `${baseId}-host-hint`,
3145
+ children: hostHint
3146
+ }),
3147
+ hostError !== void 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
3148
+ className: ssh_module_css_default.fieldError,
3149
+ id: `${baseId}-host-error`,
3150
+ children: hostError
3151
+ })
3152
+ ]
3153
+ }),
3154
+ !isProxy && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
3155
+ className: ssh_module_css_default.field,
3156
+ children: [
3157
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("label", {
3158
+ className: ssh_module_css_default.fieldLabel,
3159
+ htmlFor: `${baseId}-agent`,
3160
+ children: t("detail.agent")
3161
+ }),
3162
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("select", {
3163
+ id: `${baseId}-agent`,
3164
+ className: ssh_module_css_default.select,
3165
+ value: draft.agent,
3166
+ "aria-invalid": agentError !== void 0,
3167
+ "aria-describedby": agentError === void 0 ? void 0 : `${baseId}-agent-error`,
3168
+ onChange: (event) => onChange({ agent: event.target.value }),
3169
+ disabled,
3170
+ children: AGENTS.map((agent) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("option", {
3171
+ value: agent,
3172
+ children: t(`detail.agent.${agent}`)
3173
+ }, agent))
3174
+ }),
3175
+ agentError !== void 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
3176
+ className: ssh_module_css_default.fieldError,
3177
+ id: `${baseId}-agent-error`,
3178
+ children: agentError
3179
+ })
3180
+ ]
3181
+ }),
3182
+ !isProxy && draft.agent === "custom" && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [textField("agentCommand", "detail.agentCommand", draft.agentCommand, (next) => onChange({ agentCommand: next }), "{prompt_file}"), textField("agentResumeCommand", "detail.agentResumeCommand", draft.agentResumeCommand, (next) => onChange({ agentResumeCommand: next }))] }),
3183
+ choiceGroup("workspaceKind", "detail.workspace", WORKSPACE_KINDS.map((value) => ({
3184
+ value,
3185
+ label: `detail.workspace.${value}`
3186
+ })), draft.workspaceKind, (next) => onChange({ workspaceKind: next })),
3187
+ draft.workspaceKind === "in-place" ? textField("workspacePath", "detail.workspace.path", draft.workspacePath, (next) => onChange({ workspacePath: next }), "/home/me/project") : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [!isProxy && choiceGroup("gitSource", "detail.workspace.source", [{
3188
+ value: "url",
3189
+ label: "detail.workspace.source.url"
3190
+ }, {
3191
+ value: "workspace",
3192
+ label: "detail.workspace.source.workspace"
3193
+ }], draft.gitSource, (next) => onChange({ gitSource: next })), isProxy || draft.gitSource === "url" ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [textField("repositoryUrl", "detail.workspace.url", draft.repositoryUrl, (next) => onChange({ repositoryUrl: next }), "git@example.com:team/repo.git"), textField("baseBranch", "detail.workspace.base", draft.baseBranch, (next) => onChange({ baseBranch: next }), "main")] }) : workspaceOptions.length > 0 ? (() => {
3194
+ const id = `${baseId}-workspaceId`;
3195
+ const wsError = errorFor("workspaceId");
3196
+ const known = workspaceOptions.some((item) => item.workspaceId === draft.workspaceId);
3197
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
3198
+ className: ssh_module_css_default.field,
3199
+ children: [
3200
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("label", {
3201
+ className: ssh_module_css_default.fieldLabel,
3202
+ htmlFor: id,
3203
+ children: t("detail.workspace.workspaceId")
3204
+ }),
3205
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("select", {
3206
+ id,
3207
+ className: ssh_module_css_default.select,
3208
+ value: draft.workspaceId,
3209
+ "aria-invalid": wsError !== void 0,
3210
+ "aria-describedby": wsError === void 0 ? void 0 : `${id}-error`,
3211
+ onChange: (event) => onChange({ workspaceId: event.target.value }),
3212
+ onBlur: () => onTouch?.("workspaceId"),
3213
+ disabled,
3214
+ children: [
3215
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("option", {
3216
+ value: "",
3217
+ children: t("detail.workspace.workspaceIdPlaceholder")
3218
+ }),
3219
+ !known && draft.workspaceId !== "" && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("option", {
3220
+ value: draft.workspaceId,
3221
+ children: draft.workspaceId
3222
+ }),
3223
+ workspaceOptions.map((item) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("option", {
3224
+ value: item.workspaceId,
3225
+ children: item.title
3226
+ }, item.workspaceId))
3227
+ ]
3228
+ }),
3229
+ wsError !== void 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
3230
+ className: ssh_module_css_default.fieldError,
3231
+ id: `${id}-error`,
3232
+ children: wsError
3233
+ })
3234
+ ]
3235
+ }, "workspaceId");
3236
+ })() : textField("workspaceId", "detail.workspace.workspaceId", draft.workspaceId, (next) => onChange({ workspaceId: next }), t("detail.workspace.workspaceIdPlaceholder"))] })
3237
+ ]
3238
+ });
3239
+ }
3240
+ /**
3241
+ * Render the target form: the same fields, framed by one save action.
3242
+ * @param props - the opening state, the hosts to offer and the write callbacks.
3243
+ * @returns the form, in the shape the current draft asks for.
3244
+ */
3245
+ function SshTargetForm({ initial, hosts, unknownHost, saving, submitLabel, onCancel, onSubmit }) {
3246
+ const [draft, setDraft] = (0, react.useState)(initial);
3247
+ const [dirty, setDirty] = (0, react.useState)(false);
3248
+ const [errors, setErrors] = (0, react.useState)({});
3249
+ (0, react.useEffect)(() => {
3250
+ if (!dirty) setDraft(initial);
3251
+ }, [
3252
+ dirty,
3253
+ initial.mode,
3254
+ initial.host,
3255
+ initial.agent,
3256
+ initial.agentCommand,
3257
+ initial.agentResumeCommand,
3258
+ initial.workspaceKind,
3259
+ initial.gitSource,
3260
+ initial.workspacePath,
3261
+ initial.repositoryUrl,
3262
+ initial.baseBranch,
3263
+ initial.workspaceId
3264
+ ]);
3265
+ const edit = (patch) => {
3266
+ setDirty(true);
3267
+ setDraft((current) => ({
3268
+ ...current,
3269
+ ...patch
3270
+ }));
3271
+ setErrors((current) => {
3272
+ const fields = Object.keys(patch);
3273
+ if (!fields.some((field) => current[field] !== void 0)) return current;
3274
+ const kept = { ...current };
3275
+ for (const field of fields) delete kept[field];
3276
+ return kept;
3277
+ });
3278
+ };
3279
+ const submit = (event) => {
3280
+ event.preventDefault();
3281
+ const result = validateDraft(draft);
3282
+ if (result.target === void 0) {
3283
+ setErrors(result.errors);
3284
+ return;
3285
+ }
3286
+ setErrors({});
3287
+ onSubmit(result.target);
3288
+ };
3289
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("form", {
3290
+ className: ssh_module_css_default.form,
3291
+ onSubmit: submit,
3292
+ "data-dsh-part": "target-form",
3293
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(SshTargetFields, {
3294
+ draft,
3295
+ errors,
3296
+ hosts,
3297
+ ...unknownHost === void 0 ? {} : { unknownHost },
3298
+ disabled: saving,
3299
+ modeHint: t(draft.mode === "direct" ? "detail.modeHintDirect" : "detail.modeHintProxy"),
3300
+ onChange: edit
3301
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
3302
+ className: ssh_module_css_default.actions,
3303
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
3304
+ type: "submit",
3305
+ className: ssh_module_css_default.primaryButton,
3306
+ disabled: saving,
3307
+ children: submitLabel
3308
+ }), onCancel !== void 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
3309
+ type: "button",
3310
+ className: ssh_module_css_default.ghostButton,
3311
+ onClick: onCancel,
3312
+ disabled: saving,
3313
+ children: t("detail.cancelEdit")
3314
+ })]
3315
+ })]
3316
+ });
3317
+ }
3318
+ //#endregion
3319
+ //#region src/client/ssh/compose-section.tsx
3320
+ /**
3321
+ * The create dialog's own rows: pin this new card to a remote target before it
3322
+ * exists, instead of creating it untargeted and opening its detail seat.
3323
+ *
3324
+ * The seat renders nothing at all unless the provider can actually run the card:
3325
+ * the extension's own switch is followed by the seat registration itself (the
3326
+ * board drops every seat this provider owns when the switch goes off), and the
3327
+ * host half is proved mounted by a published summary having arrived. A
3328
+ * deployment that ships `dsh-ssh` disabled therefore contributes no rows here —
3329
+ * the same judgement the detail seat makes when it says which plugin to enable,
3330
+ * minus the sentence: creating a card has nothing to do with SSH, and a dialog
3331
+ * about a card is no place to explain a missing host half.
3332
+ *
3333
+ * The default is no target at all: an unchecked switch that expands into the
3334
+ * same field set the detail seat renders, starts from the provider's published
3335
+ * defaults, and reports the draft this card will carry on every change. Invalid
3336
+ * input is never reported — the board would otherwise store a target this build
3337
+ * cannot read back — and its refusal lands under the field that carries it.
3338
+ *
3339
+ * @module dsh-task-board-ssh/client/ssh/compose-section
3340
+ */
3341
+ /** Short plugin name the semantic attributes carry. */
3342
+ const PLUGIN_ATTR$1 = "task-board-ssh";
3343
+ /** Extract a pinned SSH target from a duplicated card's integrations container. */
3344
+ function initialTargetFrom(integrations) {
3345
+ const raw = integrations?.["ssh"];
3346
+ if (raw === void 0) return void 0;
3347
+ const parsed = parseSshLedgerPayload(raw);
3348
+ return parsed.ok ? parsed.value.target : void 0;
3349
+ }
3350
+ /**
3351
+ * Render the SSH provider's new-card seat.
3352
+ * @param props - the board's draft channel, optional duplicate source and submit counter.
3353
+ * @returns the picker while the host half is mounted, nothing otherwise.
3354
+ */
3355
+ function SshComposeSection({ contribute, initialIntegrations, submitAttempt = 0 }) {
3356
+ const summary = usePublishedSummary();
3357
+ const hostHalf = useHostHalfStatus();
3358
+ const [initialTarget] = (0, react.useState)(() => initialTargetFrom(initialIntegrations));
3359
+ const [chosen, setChosen] = (0, react.useState)(() => initialTarget !== void 0);
3360
+ const [edited, setEdited] = (0, react.useState)(() => initialTarget === void 0 ? void 0 : draftOf(initialTarget));
3361
+ const [touched, setTouched] = (0, react.useState)(() => /* @__PURE__ */ new Set());
3362
+ const defaults = summary?.defaults;
3363
+ const draft = (0, react.useMemo)(() => edited ?? draftOf(initialTarget, defaults), [
3364
+ edited,
3365
+ initialTarget,
3366
+ defaults
3367
+ ]);
3368
+ const validation = (0, react.useMemo)(() => validateDraft(draft), [draft]);
3369
+ const fieldsId = `${(0, react.useId)()}-fields`;
3370
+ const mounted = hostHalf === "mounted" && summary !== void 0;
3371
+ const live = chosen && mounted;
3372
+ const visibleErrors = (0, react.useMemo)(() => {
3373
+ if (submitAttempt > 0) return validation.errors;
3374
+ const filtered = {};
3375
+ for (const [field, issue] of Object.entries(validation.errors)) if (issue !== void 0 && touched.has(field)) filtered[field] = issue;
3376
+ return filtered;
3377
+ }, [
3378
+ validation.errors,
3379
+ touched,
3380
+ submitAttempt
3381
+ ]);
3382
+ (0, react.useEffect)(() => {
3383
+ if (!live) {
3384
+ contribute("ssh", void 0);
3385
+ return;
3386
+ }
3387
+ if (validation.target === void 0) {
3388
+ const firstEntry = Object.entries(validation.errors).find(([, issue]) => issue !== void 0);
3389
+ const blocker = firstEntry !== void 0 && firstEntry[1] !== void 0 ? refusalText(firstEntry[0], firstEntry[1]) : t("detail.error.host");
3390
+ contribute("ssh", void 0, {
3391
+ summary: t("compose.remote"),
3392
+ error: blocker
3393
+ });
3394
+ return;
3395
+ }
3396
+ const payload = composeDraftPayload(validation.target, Date.now());
3397
+ if (payload === void 0) {
3398
+ contribute("ssh", void 0, {
3399
+ summary: t("compose.remote"),
3400
+ error: t("detail.rejected")
3401
+ });
3402
+ return;
3403
+ }
3404
+ const parts = targetSummaryParts(validation.target);
3405
+ const label = validation.target.mode === "proxy" ? `${parts.host} · ${t("detail.mode.proxy")}` : `${parts.host} · ${t(`detail.agent.${parts.agent}`)}`;
3406
+ contribute("ssh", { ...payload }, { summary: label });
3407
+ }, [
3408
+ live,
3409
+ validation,
3410
+ contribute
3411
+ ]);
3412
+ if (!mounted) return null;
3413
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
3414
+ className: ssh_module_css_default.compose,
3415
+ "data-dsh-plugin": PLUGIN_ATTR$1,
3416
+ "data-dsh-part": "compose",
3417
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
3418
+ className: ssh_module_css_default.composeToggle,
3419
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
3420
+ type: "checkbox",
3421
+ checked: chosen,
3422
+ "aria-controls": live ? fieldsId : void 0,
3423
+ onChange: (event) => {
3424
+ setChosen(event.target.checked);
3425
+ }
3426
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: t("compose.remote") })]
3427
+ }), live && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
3428
+ className: ssh_module_css_default.composeFields,
3429
+ id: fieldsId,
3430
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SshTargetFields, {
3431
+ draft,
3432
+ errors: visibleErrors,
3433
+ hosts: summary?.hosts ?? [],
3434
+ modeHint: t(draft.mode === "direct" ? "detail.modeHintDirect" : "detail.modeHintProxy"),
3435
+ onTouch: (field) => {
3436
+ setTouched((current) => {
3437
+ if (current.has(field)) return current;
3438
+ const next = new Set(current);
3439
+ next.add(field);
3440
+ return next;
3441
+ });
3442
+ },
3443
+ onChange: (patch) => {
3444
+ setEdited({
3445
+ ...draft,
3446
+ ...patch
3447
+ });
3448
+ setTouched((current) => {
3449
+ const next = new Set(current);
3450
+ for (const key of Object.keys(patch)) next.add(key);
3451
+ return next;
3452
+ });
3453
+ }
3454
+ })
3455
+ })]
3456
+ });
3457
+ }
3458
+ //#endregion
3459
+ //#region src/client/ssh/log-buffer.ts
3460
+ /** Drop the first `from` UTF-8 bytes of `text` without splitting multi-byte code points. */
3461
+ function sliceTextFromByte(text, from) {
3462
+ if (from <= 0) return text;
3463
+ const encoder = new TextEncoder();
3464
+ let bytes = 0;
3465
+ let index = 0;
3466
+ while (index < text.length) {
3467
+ const code = text.codePointAt(index) ?? 0;
3468
+ const character = String.fromCodePoint(code);
3469
+ const size = encoder.encode(character).length;
3470
+ if (bytes + size > from) break;
3471
+ bytes += size;
3472
+ index += character.length;
3473
+ }
3474
+ return text.slice(index);
3475
+ }
3476
+ /**
3477
+ * Accumulates log increments into lines.
3478
+ *
3479
+ * One instance belongs to one open detail panel; closing the panel drops it,
3480
+ * which is what makes reopening replay from the first byte — the buffer asks
3481
+ * the provider for that replay and renders whatever windows arrive.
3482
+ */
3483
+ var SshLogBuffer = class {
3484
+ run;
3485
+ startOffset = 0;
3486
+ endOffset = 0;
3487
+ rows = [];
3488
+ tail;
3489
+ gap = false;
3490
+ /** How many rows the buffer holds, partial trailing line included. */
3491
+ get count() {
3492
+ return this.tail === void 0 ? this.rows.length : this.rows.length + 1;
3493
+ }
3494
+ /**
3495
+ * Apply one published increment.
3496
+ * @param frame - the increment; duplicates and replays are tolerated.
3497
+ * @returns true when the visible content changed.
3498
+ */
3499
+ append(frame) {
3500
+ if (frame.runId !== void 0 && this.run !== void 0 && frame.runId !== this.run) this.reset(frame.runId);
3501
+ else if (frame.runId !== void 0 && this.run === void 0) this.run = frame.runId;
3502
+ if (frame.text.length === 0) return false;
3503
+ if (frame.endOffset <= this.endOffset) return false;
3504
+ let incoming = frame.text;
3505
+ if (this.count === 0 && frame.baseOffset > 0) this.gap = true;
3506
+ else if (this.endOffset > 0 && frame.baseOffset > this.endOffset) this.gap = true;
3507
+ else if (this.endOffset > 0 && frame.baseOffset < this.endOffset) {
3508
+ incoming = sliceTextFromByte(incoming, this.endOffset - frame.baseOffset);
3509
+ if (incoming.length === 0) return false;
3510
+ }
3511
+ if (frame.truncated === true && frame.hasMore !== true) this.gap = true;
3512
+ this.startOffset = this.count === 0 ? frame.baseOffset : Math.min(this.startOffset, frame.baseOffset);
3513
+ this.endOffset = frame.endOffset;
3514
+ const combined = (this.tail ?? "") + incoming;
3515
+ let from = 0;
3516
+ for (;;) {
3517
+ const newline = combined.indexOf("\n", from);
3518
+ if (newline === -1) break;
3519
+ this.rows.push(combined.slice(from, newline));
3520
+ from = newline + 1;
3521
+ }
3522
+ this.tail = from < combined.length ? combined.slice(from) : void 0;
3523
+ return true;
3524
+ }
3525
+ /**
3526
+ * Read one row.
3527
+ * @param index - zero-based row index below {@link count}.
3528
+ * @returns the row text; the empty string outside the buffer.
3529
+ */
3530
+ lineAt(index) {
3531
+ if (index < this.rows.length) return this.rows[index];
3532
+ if (index === this.rows.length && this.tail !== void 0) return this.tail;
3533
+ return "";
3534
+ }
3535
+ /**
3536
+ * Copy every row out; for tests and small surfaces, never for a live render.
3537
+ * @returns the rows, oldest first.
3538
+ */
3539
+ toLines() {
3540
+ return this.tail === void 0 ? [...this.rows] : [...this.rows, this.tail];
3541
+ }
3542
+ /** Drop every line; a later replay starts from the first byte again. */
3543
+ reset(runId) {
3544
+ this.run = runId;
3545
+ this.startOffset = 0;
3546
+ this.endOffset = 0;
3547
+ this.rows = [];
3548
+ this.tail = void 0;
3549
+ this.gap = false;
3550
+ }
3551
+ /** Read the buffer's account of itself. */
3552
+ snapshot() {
3553
+ const snapshot = {
3554
+ count: this.count,
3555
+ truncated: this.gap,
3556
+ start: this.startOffset,
3557
+ end: this.endOffset
3558
+ };
3559
+ if (this.run !== void 0) snapshot.runId = this.run;
3560
+ return snapshot;
3561
+ }
3562
+ };
3563
+ /**
3564
+ * Compute the rows to mount for one scroll position.
3565
+ *
3566
+ * Pure arithmetic over a fixed row height: the tests state the window for a
3567
+ * given geometry exactly, and the component never reads layout to decide what
3568
+ * to render.
3569
+ * @param total - how many rows exist.
3570
+ * @param viewport - scroller geometry and overscan.
3571
+ * @returns the mounted block and the scroll surface it sits in.
3572
+ */
3573
+ function visibleLogWindow(total, viewport) {
3574
+ const rowHeight = viewport.rowHeight > 0 ? viewport.rowHeight : 1;
3575
+ const overscan = viewport.overscan > 0 ? viewport.overscan : 0;
3576
+ const totalHeight = total * rowHeight;
3577
+ if (total <= 0) return {
3578
+ start: 0,
3579
+ end: 0,
3580
+ offsetY: 0,
3581
+ totalHeight,
3582
+ total
3583
+ };
3584
+ const maxScroll = Math.max(0, totalHeight - Math.max(0, viewport.height));
3585
+ const scrollTop = Math.min(Math.max(0, viewport.scrollTop), maxScroll);
3586
+ const first = Math.floor(scrollTop / rowHeight);
3587
+ const visible = Math.max(1, Math.ceil(Math.max(0, viewport.height) / rowHeight));
3588
+ const start = Math.max(0, Math.min(total - 1, first - overscan));
3589
+ return {
3590
+ start,
3591
+ end: Math.min(total, first + visible + overscan),
3592
+ offsetY: start * rowHeight,
3593
+ totalHeight,
3594
+ total
3595
+ };
3596
+ }
3597
+ /** Rows mounted above and below the visible band. */
3598
+ const LOG_OVERSCAN = 8;
3599
+ /**
3600
+ * Render the run log.
3601
+ * @param props - the buffer, its revision, and the copy it reads.
3602
+ * @returns the scroller, its notices and the return-to-tail control.
3603
+ */
3604
+ function SshLogView({ buffer, live, labels, resetKey, version }) {
3605
+ const scroller = (0, react.useRef)(null);
3606
+ const [scrollTop, setScrollTop] = (0, react.useState)(0);
3607
+ const [following, setFollowing] = (0, react.useState)(true);
3608
+ (0, react.useEffect)(() => {
3609
+ setScrollTop(0);
3610
+ setFollowing(true);
3611
+ if (scroller.current !== null) scroller.current.scrollTop = 0;
3612
+ }, [resetKey]);
3613
+ const snapshot = buffer.snapshot();
3614
+ const count = snapshot.count;
3615
+ const maxScroll = Math.max(0, count * 18 - 216);
3616
+ const window = visibleLogWindow(count, {
3617
+ scrollTop: following ? maxScroll : scrollTop,
3618
+ height: 216,
3619
+ rowHeight: 18,
3620
+ overscan: LOG_OVERSCAN
3621
+ });
3622
+ (0, react.useEffect)(() => {
3623
+ if (!following) return;
3624
+ const element = scroller.current;
3625
+ if (element === null) return;
3626
+ element.scrollTop = maxScroll;
3627
+ setScrollTop(maxScroll);
3628
+ }, [
3629
+ version,
3630
+ following,
3631
+ maxScroll
3632
+ ]);
3633
+ const onScroll = (0, react.useCallback)((event) => {
3634
+ const top = event.currentTarget.scrollTop;
3635
+ setScrollTop(top);
3636
+ setFollowing(maxScroll - top <= 18);
3637
+ }, [maxScroll]);
3638
+ const jumpToLatest = (0, react.useCallback)(() => {
3639
+ setFollowing(true);
3640
+ }, []);
3641
+ if (count === 0) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
3642
+ className: ssh_module_css_default.log,
3643
+ "data-dsh-part": "log",
3644
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
3645
+ className: ssh_module_css_default.logEmpty,
3646
+ children: labels.empty
3647
+ })
3648
+ });
3649
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
3650
+ className: ssh_module_css_default.log,
3651
+ "data-dsh-part": "log",
3652
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
3653
+ ref: scroller,
3654
+ className: ssh_module_css_default.logScroller,
3655
+ style: { height: `216px` },
3656
+ tabIndex: 0,
3657
+ role: "group",
3658
+ "aria-label": labels.name,
3659
+ "aria-live": "off",
3660
+ onScroll,
3661
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
3662
+ className: ssh_module_css_default.logSurface,
3663
+ style: { height: `${window.totalHeight}px` },
3664
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
3665
+ className: ssh_module_css_default.logBlock,
3666
+ style: { transform: `translateY(${window.offsetY}px)` },
3667
+ children: Array.from({ length: window.end - window.start }, (_unused, offset) => {
3668
+ const index = window.start + offset;
3669
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
3670
+ className: ssh_module_css_default.logRow,
3671
+ style: { height: `18px` },
3672
+ children: buffer.lineAt(index)
3673
+ }, index);
3674
+ })
3675
+ })
3676
+ })
3677
+ }), (snapshot.truncated || !following && live) && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
3678
+ className: ssh_module_css_default.logNotices,
3679
+ children: [snapshot.truncated && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
3680
+ className: ssh_module_css_default.logNotice,
3681
+ children: labels.truncated
3682
+ }), !following && live && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
3683
+ type: "button",
3684
+ className: ssh_module_css_default.linkButton,
3685
+ onClick: jumpToLatest,
3686
+ children: labels.latest
3687
+ })]
3688
+ })]
3689
+ });
3690
+ }
3691
+ //#endregion
3692
+ //#region src/client/ssh/detail-section.tsx
3693
+ /**
3694
+ * The task-detail seat: what this card runs on, where it is, and what it said.
3695
+ *
3696
+ * The section is built out of three facts the card already holds and one
3697
+ * channel it reads: the ledger payload carries the pinned target and the run
3698
+ * records, the published summary carries the host list and the log increments,
3699
+ * and every write leaves through the board's `dispatch` — the section owns no
3700
+ * HTTP surface and no board internal.
3701
+ *
3702
+ * An untargeted card shows the form and nothing else: there is no run state to
3703
+ * report and no log to read, so showing either would be decoration.
3704
+ *
3705
+ * @module dsh-task-board-ssh/client/ssh/detail-section
3706
+ */
3707
+ /** Short plugin name the semantic attributes carry. */
3708
+ const PLUGIN_ATTR = "task-board-ssh";
3709
+ /** Upper bound for auto-paging settled remote logs into the detail viewer, in bytes. */
3710
+ const AUTO_PAGE_MAX_BYTES = 512 * 1024;
3711
+ /** Copy key naming one run phase; the pill and the badge read the same table. */
3712
+ function phaseKey(phase) {
3713
+ return `run.${phase}`;
3714
+ }
3715
+ /** Display name of one agent CLI. */
3716
+ function agentLabel(kind) {
3717
+ return t(`detail.agent.${kind}`);
3718
+ }
3719
+ /** One sentence from whatever was thrown, for the section's error line. */
3720
+ function messageOf(error) {
3721
+ return error instanceof Error ? error.message : String(error);
3722
+ }
3723
+ /**
3724
+ * Render the SSH provider's task-detail section.
3725
+ * @param props - the card and the board's action channel.
3726
+ * @returns the section in the shape the card's payload asks for.
3727
+ */
3728
+ function SshDetailSection({ task, dispatch }) {
3729
+ const view = sshCardView(task);
3730
+ const summary = usePublishedSummary();
3731
+ const hostHalf = useHostHalfStatus();
3732
+ const [editing, setEditing] = (0, react.useState)(false);
3733
+ const [saving, setSaving] = (0, react.useState)(false);
3734
+ const [cancelling, setCancelling] = (0, react.useState)(false);
3735
+ const [sending, setSending] = (0, react.useState)(false);
3736
+ const [queuedLocal, setQueuedLocal] = (0, react.useState)(false);
3737
+ const [text, setText] = (0, react.useState)("");
3738
+ const [error, setError] = (0, react.useState)();
3739
+ const buffer = (0, react.useRef)(void 0);
3740
+ if (buffer.current === void 0) buffer.current = new SshLogBuffer();
3741
+ const [version, setVersion] = (0, react.useState)(0);
3742
+ const awaitingReplay = (0, react.useRef)(false);
3743
+ const lastRequestedOffset = (0, react.useRef)(0);
3744
+ const targeted = view.target !== void 0;
3745
+ const isProxy = view.target?.mode === "proxy";
3746
+ const archived = task.archivedAt !== void 0;
3747
+ const active = !isProxy && isSshRunActive(view.phase);
3748
+ const pending = summary?.logs?.[task.id];
3749
+ (0, react.useEffect)(() => {
3750
+ setEditing(false);
3751
+ setSaving(false);
3752
+ setCancelling(false);
3753
+ setSending(false);
3754
+ setQueuedLocal(false);
3755
+ setText("");
3756
+ setError(void 0);
3757
+ }, [task.id]);
3758
+ (0, react.useEffect)(() => {
3759
+ if (active || archived) setEditing(false);
3760
+ }, [active, archived]);
3761
+ const send = async (request) => {
3762
+ setError(void 0);
3763
+ try {
3764
+ const accepted = await dispatch(request);
3765
+ if (!accepted) {
3766
+ const hostReason = getLastBoardError();
3767
+ setError(hostReason !== void 0 && hostReason !== "" ? t("detail.actionFailed", { error: hostReason }) : t("detail.rejected"));
3768
+ }
3769
+ return accepted;
3770
+ } catch (cause) {
3771
+ setError(t("detail.actionFailed", { error: messageOf(cause) }));
3772
+ return false;
3773
+ }
3774
+ };
3775
+ (0, react.useEffect)(() => {
3776
+ const current = buffer.current;
3777
+ if (current === void 0) return;
3778
+ current.reset(view.runId);
3779
+ lastRequestedOffset.current = 0;
3780
+ awaitingReplay.current = targeted && !isProxy && view.runId !== void 0;
3781
+ setVersion((previous) => previous + 1);
3782
+ if (!targeted || isProxy) return;
3783
+ dispatch({
3784
+ extensionId: "ssh",
3785
+ action: "refresh",
3786
+ taskId: task.id,
3787
+ ...view.runId === void 0 ? {} : { payload: { runId: view.runId } }
3788
+ }).catch(() => {});
3789
+ }, [
3790
+ task.id,
3791
+ view.runId,
3792
+ targeted,
3793
+ isProxy
3794
+ ]);
3795
+ (0, react.useEffect)(() => {
3796
+ const current = buffer.current;
3797
+ if (current === void 0 || pending === void 0 || isProxy) return;
3798
+ if (view.runId !== void 0 && pending.runId !== view.runId) return;
3799
+ if (awaitingReplay.current) {
3800
+ if (pending.baseOffset > 0) return;
3801
+ awaitingReplay.current = false;
3802
+ }
3803
+ if (current.append(pending)) setVersion((previous) => previous + 1);
3804
+ if (pending.hasMore === true && !active && view.runId !== void 0 && pending.endOffset > lastRequestedOffset.current && pending.endOffset < AUTO_PAGE_MAX_BYTES) {
3805
+ lastRequestedOffset.current = pending.endOffset;
3806
+ dispatch({
3807
+ extensionId: "ssh",
3808
+ action: "refresh",
3809
+ taskId: task.id,
3810
+ payload: {
3811
+ runId: view.runId,
3812
+ offset: pending.endOffset
3813
+ }
3814
+ }).catch(() => {});
3815
+ }
3816
+ }, [
3817
+ pending,
3818
+ isProxy,
3819
+ active,
3820
+ task.id,
3821
+ view.runId,
3822
+ dispatch
3823
+ ]);
3824
+ (0, react.useEffect)(() => {
3825
+ if (!active || view.pending !== void 0) setQueuedLocal(false);
3826
+ }, [active, view.pending]);
3827
+ const hasQueuedFollowUp = view.pending !== void 0 || queuedLocal && active;
3828
+ const saveTarget = async (target) => {
3829
+ setSaving(true);
3830
+ const accepted = await send({
3831
+ extensionId: "ssh",
3832
+ action: "set-target",
3833
+ taskId: task.id,
3834
+ payload: { target }
3835
+ });
3836
+ setSaving(false);
3837
+ if (accepted) setEditing(false);
3838
+ };
3839
+ const cancelRun = async () => {
3840
+ setCancelling(true);
3841
+ await send({
3842
+ extensionId: "ssh",
3843
+ action: "cancel",
3844
+ taskId: task.id
3845
+ });
3846
+ setCancelling(false);
3847
+ };
3848
+ const submitFollowUp = async () => {
3849
+ if (text.trim() === "") return;
3850
+ setSending(true);
3851
+ const accepted = await send({
3852
+ extensionId: "ssh",
3853
+ action: "follow-up",
3854
+ taskId: task.id,
3855
+ payload: { text }
3856
+ });
3857
+ setSending(false);
3858
+ if (!accepted) return;
3859
+ setText("");
3860
+ if (active) setQueuedLocal(true);
3861
+ };
3862
+ if (hostHalf === "unmounted") return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("section", {
3863
+ className: ssh_module_css_default.section,
3864
+ "data-dsh-plugin": PLUGIN_ATTR,
3865
+ "data-dsh-part": "unmounted",
3866
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
3867
+ className: ssh_module_css_default.meta,
3868
+ children: t("detail.hostHalfMissing")
3869
+ })
3870
+ });
3871
+ if (!targeted) {
3872
+ if (archived) return null;
3873
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("section", {
3874
+ className: ssh_module_css_default.section,
3875
+ "data-dsh-plugin": PLUGIN_ATTR,
3876
+ "data-dsh-part": "target",
3877
+ children: [
3878
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("h4", {
3879
+ className: ssh_module_css_default.sectionTitle,
3880
+ children: t("detail.setTarget")
3881
+ }),
3882
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SshTargetForm, {
3883
+ initial: draftOf(void 0, summary?.defaults),
3884
+ hosts: summary?.hosts ?? [],
3885
+ saving,
3886
+ submitLabel: saving ? t("detail.saving") : t("detail.save"),
3887
+ onSubmit: (target) => {
3888
+ saveTarget(target);
3889
+ }
3890
+ }, task.id),
3891
+ error !== void 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
3892
+ className: ssh_module_css_default.formError,
3893
+ role: "alert",
3894
+ children: error
3895
+ })
3896
+ ]
3897
+ });
3898
+ }
3899
+ const target = view.target;
3900
+ const parts = targetSummaryParts(target);
3901
+ const lastRun = view.lastRun;
3902
+ const canEditTarget = !active && !archived;
3903
+ const canFollowUp = !isProxy && !archived && (active || lastRun !== void 0);
3904
+ const untracked = summary?.runs?.find((run) => run.taskId === task.id)?.untrackedFiles ?? 0;
3905
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("section", {
3906
+ className: ssh_module_css_default.section,
3907
+ "data-dsh-plugin": PLUGIN_ATTR,
3908
+ "data-dsh-part": "run",
3909
+ children: [
3910
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
3911
+ className: ssh_module_css_default.head,
3912
+ children: [
3913
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("h4", {
3914
+ className: ssh_module_css_default.sectionTitle,
3915
+ children: t("detail.target")
3916
+ }),
3917
+ !isProxy && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
3918
+ className: ssh_module_css_default.statePill,
3919
+ "data-run": view.phase,
3920
+ children: t(phaseKey(view.phase))
3921
+ }),
3922
+ canEditTarget && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
3923
+ type: "button",
3924
+ className: ssh_module_css_default.linkButton,
3925
+ onClick: () => setEditing((current) => !current),
3926
+ children: t(editing ? "detail.cancelEdit" : "detail.editTarget")
3927
+ })
3928
+ ]
3929
+ }),
3930
+ !editing && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
3931
+ className: ssh_module_css_default.targetLine,
3932
+ title: parts.workspace,
3933
+ children: t("detail.targetSummary", {
3934
+ host: parts.host,
3935
+ agent: isProxy ? t("detail.mode.proxy") : agentLabel(parts.agent),
3936
+ workspace: parts.workspace
3937
+ })
3938
+ }),
3939
+ !editing && isProxy && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
3940
+ className: ssh_module_css_default.meta,
3941
+ children: t("detail.modeHintProxy")
3942
+ }),
3943
+ editing && canEditTarget && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SshTargetForm, {
3944
+ initial: draftOf(target, summary?.defaults),
3945
+ hosts: summary?.hosts ?? [],
3946
+ unknownHost: (summary?.hosts ?? []).some((host) => host.alias === target.host) ? void 0 : target.host,
3947
+ saving,
3948
+ submitLabel: saving ? t("detail.saving") : t("detail.save"),
3949
+ onCancel: () => setEditing(false),
3950
+ onSubmit: (next) => {
3951
+ saveTarget(next);
3952
+ }
3953
+ }, `${task.id}:edit`),
3954
+ !isProxy && !active && lastRun?.error !== void 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
3955
+ className: ssh_module_css_default.formError,
3956
+ children: lastRun.error
3957
+ }),
3958
+ !isProxy && lastRun?.branch !== void 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
3959
+ className: ssh_module_css_default.meta,
3960
+ children: t("detail.branch", { branch: lastRun.branch })
3961
+ }),
3962
+ !isProxy && untracked > 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
3963
+ className: ssh_module_css_default.meta,
3964
+ children: t("detail.untrackedFiles", { count: String(untracked) })
3965
+ }),
3966
+ !isProxy && !active && lastRun?.summary !== void 0 && lastRun.summary !== "" && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
3967
+ className: ssh_module_css_default.summary,
3968
+ title: lastRun.summary,
3969
+ children: lastRun.summary
3970
+ }),
3971
+ !isProxy && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SshLogView, {
3972
+ buffer: buffer.current,
3973
+ version,
3974
+ live: view.phase === "running",
3975
+ resetKey: `${task.id}:${view.runId ?? ""}`,
3976
+ labels: {
3977
+ empty: t("detail.logEmpty"),
3978
+ truncated: t("detail.logTruncated"),
3979
+ latest: t("detail.logLatest"),
3980
+ name: t("detail.log")
3981
+ }
3982
+ }),
3983
+ (canFollowUp || !isProxy && active && !archived) && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
3984
+ className: ssh_module_css_default.actions,
3985
+ children: [
3986
+ canFollowUp && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("textarea", {
3987
+ className: ssh_module_css_default.followUp,
3988
+ "aria-label": t("detail.followUp"),
3989
+ placeholder: t("detail.followUpPlaceholder"),
3990
+ rows: 2,
3991
+ value: text,
3992
+ disabled: sending,
3993
+ onChange: (event) => setText(event.target.value),
3994
+ onKeyDown: (event) => {
3995
+ if (event.key === "Enter" && !event.shiftKey) {
3996
+ event.preventDefault();
3997
+ submitFollowUp();
3998
+ }
3999
+ }
4000
+ }),
4001
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
4002
+ className: ssh_module_css_default.actionRow,
4003
+ children: [
4004
+ hasQueuedFollowUp && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
4005
+ className: ssh_module_css_default.queuedChip,
4006
+ children: t("detail.followUpQueued")
4007
+ }),
4008
+ active && !archived && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
4009
+ type: "button",
4010
+ className: ssh_module_css_default.ghostButton,
4011
+ onClick: () => {
4012
+ cancelRun();
4013
+ },
4014
+ disabled: cancelling,
4015
+ children: t(cancelling ? "detail.cancelling" : "detail.cancel")
4016
+ }),
4017
+ canFollowUp && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
4018
+ type: "button",
4019
+ className: ssh_module_css_default.primaryButton,
4020
+ onClick: () => {
4021
+ submitFollowUp();
4022
+ },
4023
+ disabled: sending || text.trim() === "",
4024
+ children: t("detail.followUpSend")
4025
+ })
4026
+ ]
4027
+ }),
4028
+ error !== void 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
4029
+ className: ssh_module_css_default.formError,
4030
+ role: "alert",
4031
+ children: error
4032
+ })
4033
+ ]
4034
+ }),
4035
+ !canFollowUp && !(active && !archived) && error !== void 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
4036
+ className: ssh_module_css_default.formError,
4037
+ role: "alert",
4038
+ children: error
4039
+ })
4040
+ ]
4041
+ });
4042
+ }
4043
+ //#endregion
4044
+ //#region src/client/ssh/extension.ts
4045
+ /** Locale namespace the seats bind to. */
4046
+ const LOCALE_NS = "task-board-ssh";
4047
+ /**
4048
+ * Install the SSH provider's browser half.
4049
+ * @param ctx - client context (slot registry).
4050
+ * @param source - the extension's live enabled switch.
4051
+ * @param settings - the section to contribute into the board's settings card.
4052
+ * @returns disposer releasing every contribution.
4053
+ */
4054
+ function installSshClientHalf(ctx, source, settings) {
4055
+ /** The dependency-scoped fiber that owns the seats, while both gates are on. */
4056
+ let injection;
4057
+ /** The fiber that owns the board's provider-settings section, independent of the switch. */
4058
+ let settingsInjection;
4059
+ const install = () => {
4060
+ if (injection !== void 0) return;
4061
+ injection = ctx.inject(["taskBoard"], (scope) => {
4062
+ scope.effect(() => installSeats(scope), "task-board-ssh: provider seats");
4063
+ });
4064
+ };
4065
+ const release = () => {
4066
+ const current = injection;
4067
+ injection = void 0;
4068
+ if (current === void 0) return;
4069
+ current.dispose();
4070
+ clearSummary();
4071
+ };
4072
+ const apply = () => {
4073
+ if (source.read()) install();
4074
+ else release();
4075
+ };
4076
+ if (settings !== void 0) settingsInjection = ctx.inject(["taskBoard"], (scope) => {
4077
+ scope.effect(() => registerSettingsSection(scope, settings), "task-board-ssh: provider settings section");
4078
+ });
4079
+ const unsubscribe = source.subscribe(apply);
4080
+ apply();
4081
+ return () => {
4082
+ unsubscribe();
4083
+ release();
4084
+ const currentSettings = settingsInjection;
4085
+ settingsInjection = void 0;
4086
+ if (currentSettings !== void 0) currentSettings.dispose();
4087
+ };
4088
+ }
4089
+ /**
4090
+ * Register the configuration section into the seat the board's settings card
4091
+ * renders.
4092
+ *
4093
+ * The registration follows the seat's OWN declaration lifecycle
4094
+ * (`slots.inject`), not a one-shot `register`: the board's card declares the
4095
+ * seat, and re-declares it whenever it moves between plugin-card seats (the
4096
+ * family group loading after boot is the normal case). Re-declaring RELEASES the
4097
+ * seat's declarations together with every entry registered in it, so a one-shot
4098
+ * registration is silently dropped — the section then never renders while
4099
+ * nothing reports an error.
4100
+ * @param ctx - the dependency-scoped context (slot registry).
4101
+ * @param seat - the contribution to register.
4102
+ * @returns disposer releasing the registration.
4103
+ */
4104
+ function registerSettingsSection(ctx, seat) {
4105
+ const slots = ctx.slots;
4106
+ const register = () => {
4107
+ try {
4108
+ const dispose = slots.register({
4109
+ name: TASK_BOARD_SETTINGS_SECTION,
4110
+ id: "ssh",
4111
+ locale: LOCALE_NS,
4112
+ inject: seat.inject
4113
+ }, seat.component);
4114
+ return () => {
4115
+ try {
4116
+ dispose();
4117
+ } catch {}
4118
+ };
4119
+ } catch (error) {
4120
+ console.error("[dsh-task-board-ssh] provider settings section registration failed", error);
4121
+ return () => {};
4122
+ }
4123
+ };
4124
+ if (typeof slots.inject !== "function") return register();
4125
+ try {
4126
+ return slots.inject(TASK_BOARD_SETTINGS_SECTION, register);
4127
+ } catch (error) {
4128
+ console.error("[dsh-task-board-ssh] provider settings section could not follow its seat", error);
4129
+ return () => {};
4130
+ }
4131
+ }
4132
+ /**
4133
+ * Register the three rendering seats for as long as the board's own master switch
4134
+ * is on, and mirror the published summary into the browser-side store.
4135
+ * @param ctx - client context.
4136
+ * @returns disposer releasing every contribution.
4137
+ */
4138
+ function installSeats(ctx) {
4139
+ const face = resolveTaskBoardClientFace(ctx);
4140
+ if (face === void 0) {
4141
+ console.error("[dsh-task-board-ssh] the taskBoard service does not answer the client contract");
4142
+ return () => {};
4143
+ }
4144
+ const slots = ctx.slots;
4145
+ const seats = [];
4146
+ let registered = false;
4147
+ /** Follow a slot declaration via `slots.inject` when available, falling back to one-shot `register`. */
4148
+ const followSeat = (options, component) => {
4149
+ const seatName = String(options.name);
4150
+ const doRegister = () => {
4151
+ try {
4152
+ const dispose = slots.register(options, component);
4153
+ return () => {
4154
+ try {
4155
+ dispose();
4156
+ } catch {}
4157
+ };
4158
+ } catch (error) {
4159
+ console.error(`[dsh-task-board-ssh] seat registration failed for ${seatName}`, error);
4160
+ return () => {};
4161
+ }
4162
+ };
4163
+ if (typeof slots.inject !== "function") return doRegister();
4164
+ try {
4165
+ return slots.inject(seatName, doRegister);
4166
+ } catch (error) {
4167
+ console.error(`[dsh-task-board-ssh] seat ${seatName} could not follow its declaration`, error);
4168
+ return doRegister();
4169
+ }
4170
+ };
4171
+ const ensure = () => {
4172
+ if (registered) return;
4173
+ const next = [];
4174
+ try {
4175
+ next.push(followSeat({
4176
+ name: TASK_BOARD_DETAIL_SECTION,
4177
+ id: "ssh",
4178
+ locale: LOCALE_NS
4179
+ }, SshDetailSection));
4180
+ next.push(followSeat({
4181
+ name: TASK_BOARD_CARD_DECORATION,
4182
+ id: "ssh"
4183
+ }, SshCardDecoration));
4184
+ next.push(followSeat({
4185
+ name: TASK_BOARD_COMPOSE_SECTION,
4186
+ id: "ssh",
4187
+ locale: LOCALE_NS
4188
+ }, SshComposeSection));
4189
+ seats.push(...next);
4190
+ registered = true;
4191
+ } catch (error) {
4192
+ for (const dispose of next) try {
4193
+ dispose();
4194
+ } catch {}
4195
+ console.error("[dsh-task-board-ssh] seat registration failed", error);
4196
+ }
4197
+ };
4198
+ const release = () => {
4199
+ registered = false;
4200
+ for (const dispose of seats.splice(0)) try {
4201
+ dispose();
4202
+ } catch {}
4203
+ };
4204
+ const applyMirror = (mirror) => {
4205
+ if (mirror.enabled) ensure();
4206
+ else release();
4207
+ acceptBoardContext({
4208
+ ...mirror.workspaces === void 0 ? {} : { workspaces: mirror.workspaces },
4209
+ lastError: mirror.lastError
4210
+ });
4211
+ if (mirror.hydrated !== false) acceptPublishedSummary(mirror.extensions);
4212
+ };
4213
+ const unsubscribe = face.subscribe(applyMirror);
4214
+ applyMirror(face.snapshot());
4215
+ return () => {
4216
+ unsubscribe();
4217
+ release();
4218
+ };
4219
+ }
4220
+ //#endregion
4221
+ //#region src/client/settings-entry-form.ts
4222
+ /** The snapshot a form reports before the Host has answered with this entry. */
4223
+ function pendingSnapshot() {
4224
+ return {
4225
+ status: "loading",
4226
+ value: void 0,
4227
+ base: void 0,
4228
+ user: void 0,
4229
+ revision: void 0,
4230
+ writable: false
4231
+ };
4232
+ }
4233
+ /**
4234
+ * Create a settings form bound to the profile entry id this Host serves, and
4235
+ * rebound whenever the shared describe mirror names a different one of this
4236
+ * package's rows.
4237
+ * @param options - the shared forms service and this package's candidate row ids.
4238
+ * @returns a form delegating to the currently resolved entry's own form.
4239
+ */
4240
+ function createServedEntryForm(options) {
4241
+ const { forms, entryIds } = options;
4242
+ const fallbackId = entryIds[0];
4243
+ const namespaceId = entryIds[entryIds.length - 1];
4244
+ const listeners = /* @__PURE__ */ new Set();
4245
+ let boundId;
4246
+ let bound;
4247
+ let offBound;
4248
+ let snapshot = pendingSnapshot();
4249
+ /** Republish: the delegated snapshot when one is bound, the pending one otherwise. */
4250
+ const publish = () => {
4251
+ if (bound !== void 0) snapshot = bound.getSnapshot();
4252
+ for (const listener of [...listeners]) listener();
4253
+ };
4254
+ /**
4255
+ * The entry id the mirror currently justifies. An unanswered or empty mirror
4256
+ * is not evidence of absence, so it keeps the first candidate; a mirror that
4257
+ * answers without any of this package's rows leaves the namespace itself.
4258
+ * @returns the entry id to bind.
4259
+ */
4260
+ const resolve = () => {
4261
+ let served;
4262
+ try {
4263
+ served = forms.describe().getSnapshot().view?.namespaces.map((row) => row.ns);
4264
+ } catch {
4265
+ served = void 0;
4266
+ }
4267
+ if (served === void 0 || served.length === 0) return fallbackId;
4268
+ return entryIds.find((id) => served.includes(id)) ?? namespaceId;
4269
+ };
4270
+ /** Bind (or rebind) the resolved entry's form; a no-op while it is unchanged. */
4271
+ const bind = () => {
4272
+ const target = resolve();
4273
+ if (target === boundId) return;
4274
+ offBound?.();
4275
+ offBound = void 0;
4276
+ let form;
4277
+ try {
4278
+ form = forms.get(target);
4279
+ } catch {
4280
+ boundId = void 0;
4281
+ return;
4282
+ }
4283
+ boundId = target;
4284
+ bound = form;
4285
+ offBound = form.subscribe(() => {
4286
+ publish();
4287
+ });
4288
+ publish();
4289
+ };
4290
+ try {
4291
+ forms.describe().subscribe(() => {
4292
+ bind();
4293
+ });
4294
+ } catch {}
4295
+ bind();
4296
+ return {
4297
+ getSnapshot: () => snapshot,
4298
+ subscribe: (listener) => {
4299
+ listeners.add(listener);
4300
+ return () => {
4301
+ listeners.delete(listener);
4302
+ };
4303
+ },
4304
+ set: (field, value) => bound?.set(field, value) ?? Promise.resolve(false),
4305
+ unset: (field) => bound?.unset(field) ?? Promise.resolve(false),
4306
+ mutate: (ops, expectedRevision) => bound?.mutate(ops, expectedRevision) ?? Promise.resolve(false)
4307
+ };
4308
+ }
4309
+ //#endregion
4310
+ //#region src/client/index.ts
4311
+ /** Locale namespace this half owns. */
4312
+ const NS = "task-board-ssh";
4313
+ /** Settings namespace the section edits: this extension's family settings identity. */
4314
+ const SETTINGS_NAMESPACE = "task-board-ssh";
4315
+ /** Profile entry ids this package's patch rows carry, most specific first. */
4316
+ const ENTRY_IDS = [
4317
+ "web-ui-task-board-ssh",
4318
+ "ui-task-board-ssh",
4319
+ "dsh-task-board-ssh",
4320
+ SETTINGS_NAMESPACE
4321
+ ];
4322
+ /**
4323
+ * Required client services: the slot registry, the locale catalog, and the
4324
+ * shared configuration forms the section stages over.
4325
+ */
4326
+ const inject = [
4327
+ "slots",
4328
+ "locale",
4329
+ "configForms"
4330
+ ];
4331
+ /**
4332
+ * Bind the settings form the section stages over.
4333
+ *
4334
+ * The family binder comes first: it resolves this package's family namespace
4335
+ * onto the profile entry id the Host serves the form under. A page without that
4336
+ * group binds through the shared forms service on the entry id the describe
4337
+ * mirror justifies, rebound as soon as the mirror answers.
4338
+ * @param ctx - the browser plugin context.
4339
+ * @returns the form the settings section reads and writes.
4340
+ */
4341
+ function bindSettingsForm(ctx) {
4342
+ const binder = ctx.get("webUiSettings");
4343
+ if (binder !== void 0 && typeof binder.bind === "function") return binder.bind({ namespace: SETTINGS_NAMESPACE });
4344
+ return createServedEntryForm({
4345
+ forms: ctx.configForms,
4346
+ entryIds: ENTRY_IDS
4347
+ });
4348
+ }
4349
+ /**
4350
+ * A form for a page that serves this namespace to nobody: it never answers, so
4351
+ * the section explains the missing namespace instead of pretending to be broken,
4352
+ * and the seats still follow the documented default (enabled).
4353
+ * @returns an inert configuration form.
4354
+ */
4355
+ function unavailableForm() {
4356
+ const snapshot = {
4357
+ status: "unavailable",
4358
+ value: void 0,
4359
+ base: void 0,
4360
+ user: void 0,
4361
+ revision: void 0,
4362
+ writable: false
4363
+ };
4364
+ return {
4365
+ getSnapshot: () => snapshot,
4366
+ subscribe: () => () => {},
4367
+ set: async () => false,
4368
+ unset: async () => false,
4369
+ mutate: async () => false
4370
+ };
4371
+ }
4372
+ /**
4373
+ * Mount the extension's browser half: the dictionaries, the settings section,
4374
+ * and the provider's child seats.
4375
+ * @param ctx - the browser plugin context.
4376
+ */
4377
+ function apply(ctx) {
4378
+ ctx.effect(() => {
4379
+ try {
4380
+ return ctx.locale.register(NS, {
4381
+ zh,
4382
+ en
4383
+ });
4384
+ } catch {
4385
+ return () => {};
4386
+ }
4387
+ }, "task-board-ssh: dictionaries");
4388
+ try {
4389
+ setRuntimeTranslate(ctx.locale.bind(NS));
4390
+ } catch {}
4391
+ let scope;
4392
+ try {
4393
+ scope = bindSettingsForm(ctx);
4394
+ } catch {
4395
+ scope = unavailableForm();
4396
+ }
4397
+ const enabledSource = {
4398
+ read: () => scope.getSnapshot().value?.enabled !== false,
4399
+ subscribe: (listener) => scope.subscribe(listener)
4400
+ };
4401
+ let controller;
4402
+ try {
4403
+ controller = new SshSettingsCardController(scope);
4404
+ } catch {
4405
+ controller = void 0;
4406
+ }
4407
+ const settingsSeat = controller === void 0 ? void 0 : {
4408
+ inject: () => controller.inject(),
4409
+ component: SshSettingsSection
4410
+ };
4411
+ ctx.effect(() => installSshClientHalf(ctx, enabledSource, settingsSeat), "task-board-ssh: provider seats");
4412
+ if (controller !== void 0) {
4413
+ const owned = controller;
4414
+ ctx.effect(() => () => {
4415
+ owned.dispose();
4416
+ }, "task-board-ssh: provider settings section");
4417
+ }
4418
+ }
4419
+ //#endregion
4420
+ exports.NS = NS;
4421
+ exports.SETTINGS_NAMESPACE = SETTINGS_NAMESPACE;
4422
+ exports.apply = apply;
4423
+ exports.bindSettingsForm = bindSettingsForm;
4424
+ exports.inject = inject;
4425
+ return module.exports;
4426
+ }
4427
+ });
4428
+
4429
+ //# sourceMappingURL=client.js.map