dsh-plugin-inspiration-workbench 0.10.0 → 0.13.3

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.
@@ -49,7 +49,7 @@
49
49
  font-family: var(--dsw-font-family); font-size: 10px; padding: 1px 4px; border-radius: 4px;
50
50
  border: .5px solid var(--dsw-alias-border-l2); background: var(--dsw-alias-bg-layer-2); color: var(--dsw-alias-label-tertiary);
51
51
  }
52
- @media (max-width: 1180px) { .iwb-hint { display: none; } }
52
+ @media (max-width: 1500px) { .iwb-hint { display: none; } }
53
53
 
54
54
  /* ── canvas ──────────────────────────────────────────────────────── */
55
55
  .iwb-canvas {
@@ -225,6 +225,7 @@
225
225
  .iwb-body {
226
226
  flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden; padding: 12px 12px 4px;
227
227
  display: flex; flex-direction: column; gap: 9px; scrollbar-gutter: stable;
228
+ overscroll-behavior: contain;
228
229
  mask-image: linear-gradient(to bottom, #000 calc(100% - 11px), transparent);
229
230
  }
230
231
  .iwb-foot { flex: 0 0 auto; padding: 7px 8px 8px; border-top: .5px solid var(--dsw-alias-border-l1); }
@@ -662,6 +663,7 @@ mark.iwb-hit.current { outline: 1px solid var(--dsw-alias-state-warn-primary); }
662
663
  flex: 1; width: 100%; resize: none; border: 0; outline: none; background: none;
663
664
  font-family: inherit; font-size: 12.5px; line-height: 20px;
664
665
  color: var(--dsw-alias-label-primary); padding: 0;
666
+ overscroll-behavior: contain;
665
667
  }
666
668
  .iwb-note-input::placeholder { color: var(--dsw-alias-label-caption); }
667
669
  .iwb-card-note { background: color-mix(in srgb, var(--dsw-alias-state-warn-primary) 6%, var(--dsw-alias-bg-layer-1)); }
@@ -807,5 +809,117 @@ mark.iwb-hit.current { outline: 1px solid var(--dsw-alias-state-warn-primary); }
807
809
  opacity: 0; pointer-events: none; transition: opacity .16s, transform .16s; max-width: 70%; text-align: center; z-index: 40;
808
810
  }
809
811
  .iwb-toast.show { opacity: 1; transform: translate(-50%, 0); }
810
- /* The batch bar owns the bottom edge; lift toasts above it while it is visible. */
812
+
811
813
  .iwb-batch:not([hidden]) ~ .iwb-toast { bottom: 62px; }
814
+
815
+ /* ── real pipeline delivery states ───────────────────────────────── */
816
+ .iwb-links path.iwb-link-delivered { stroke: var(--dsw-alias-state-success-primary); opacity: .82; }
817
+ .iwb-links path.iwb-link-failed { stroke: var(--dsw-alias-state-error-primary); opacity: .9; }
818
+ .iwb-links path.iwb-link-drafted { stroke: var(--dsw-alias-state-warn-primary); opacity: .85; }
819
+ .iwb-links path.iwb-link-delivering {
820
+ stroke: var(--dsw-alias-label-deep-diving); opacity: .95;
821
+ stroke-dasharray: 5 5; animation: iwb-flow-dash .7s linear infinite;
822
+ }
823
+ .iwb-links path.iwb-link-waiting { opacity: .46; }
824
+ @keyframes iwb-flow-dash { to { stroke-dashoffset: -10; } }
825
+ .iwb-btn-icon { width: 28px; padding-inline: 0; justify-content: center; flex: 0 0 auto; }
826
+
827
+ /* ── accessible native confirmation dialog ───────────────────────── */
828
+ .iwb-confirm-dialog {
829
+ width: min(440px, calc(100vw - 32px)); padding: 0; border: .5px solid var(--dsw-alias-border-l2);
830
+ border-radius: 16px; background: var(--dsw-alias-bg-base); color: var(--dsw-alias-label-primary);
831
+ box-shadow: var(--dsw-shadow-lv4);
832
+ }
833
+ .iwb-confirm-dialog::backdrop { background: rgba(15, 17, 21, .28); backdrop-filter: blur(2px); }
834
+ .iwb-confirm-form { padding: 22px; display: flex; flex-direction: column; gap: 14px; }
835
+ .iwb-confirm-form h2 { margin: 0; font-size: 18px; line-height: 26px; font-weight: 600; }
836
+ .iwb-confirm-form p { margin: 0; font-size: 13px; line-height: 21px; color: var(--dsw-alias-label-secondary); }
837
+ .iwb-confirm-form label { display: flex; flex-direction: column; gap: 6px; font-size: 12px; color: var(--dsw-alias-label-tertiary); }
838
+ .iwb-confirm-form input {
839
+ height: 36px; padding: 0 10px; border: .5px solid var(--dsw-alias-border-l4); border-radius: 8px;
840
+ background: var(--dsw-alias-bg-layer-1); color: var(--dsw-alias-label-primary); font: inherit; font-size: 13px;
841
+ }
842
+ .iwb-confirm-form input:focus { outline: 2px solid color-mix(in srgb, var(--dsw-alias-label-deep-diving) 28%, transparent); border-color: var(--dsw-alias-label-deep-diving); }
843
+ .iwb-confirm-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }
844
+ .iwb-confirm-actions button {
845
+ min-height: 32px; padding: 0 12px; border: .5px solid var(--dsw-alias-border-l2); border-radius: 8px;
846
+ background: var(--dsw-alias-bg-layer-1); color: var(--dsw-alias-label-secondary); font: inherit; font-size: 12px; cursor: pointer;
847
+ }
848
+ .iwb-confirm-actions button:hover { background: var(--dsw-alias-interactive-bg-hover); color: var(--dsw-alias-label-primary); }
849
+ .iwb-confirm-actions button.primary { background: var(--dsw-alias-label-deep-diving); color: #fff; border-color: transparent; }
850
+ .iwb-confirm-actions button:focus-visible { outline: 2px solid var(--dsw-alias-label-deep-diving); outline-offset: 2px; }
851
+
852
+ /* ── dual view: canvas / task ────────────────────────────────────── */
853
+ .iwb-titles { margin-right: 12px; }
854
+ .iwb-mode-switch {
855
+ display: inline-flex; align-items: center; gap: 2px; margin-right: auto; padding: 2px;
856
+ border: .5px solid var(--dsw-alias-border-l2); border-radius: 9px; background: var(--dsw-alias-bg-layer-2);
857
+ }
858
+ .iwb-mode-tab {
859
+ height: 24px; min-width: 46px; padding: 0 10px; border: 0; border-radius: 6px;
860
+ background: transparent; color: var(--dsw-alias-label-tertiary); font: inherit; font-size: 11.5px; cursor: pointer;
861
+ }
862
+ .iwb-mode-tab:hover { color: var(--dsw-alias-label-primary); }
863
+ .iwb-mode-tab.active { background: var(--dsw-alias-bg-layer-1); color: var(--dsw-alias-label-primary); box-shadow: var(--dsw-shadow-lv1); }
864
+ .iwb-mode-tab:focus-visible { outline: 2px solid var(--dsw-alias-label-deep-diving); outline-offset: 1px; }
865
+ .iwb-canvas[hidden], .iwb-task-view[hidden], .iwb-toolbar [hidden] { display: none !important; }
866
+ @media (max-width: 760px) {
867
+ .iwb-mode-tab { min-width: 38px; padding-inline: 7px; }
868
+ }
869
+
870
+
871
+
872
+ /* ── Markdown notes and file cards ───────────────────────────────── */
873
+ .iwb-note-toggle { display: flex; justify-content: flex-end; gap: 4px; margin-bottom: 8px; }
874
+ .iwb-note-toggle-button {
875
+ min-height: 24px; padding: 0 8px; border: .5px solid var(--dsw-alias-border-l2); border-radius: 6px;
876
+ background: transparent; color: var(--dsw-alias-label-tertiary); font: inherit; font-size: 10.5px; cursor: pointer;
877
+ }
878
+ .iwb-note-toggle-button.active { background: var(--dsw-alias-bg-layer-2); color: var(--dsw-alias-label-primary); }
879
+ .iwb-note-toggle-button:focus-visible { outline: 2px solid var(--dsw-alias-label-deep-diving); }
880
+ .iwb-note-preview { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; font-size: 12.5px; line-height: 1.7; }
881
+ .iwb-note-preview h1, .iwb-note-preview h2, .iwb-note-preview h3, .iwb-note-preview h4 { margin: 0 0 10px; line-height: 1.35; }
882
+ .iwb-note-preview h1 { font-size: 18px; }
883
+ .iwb-note-preview h2 { font-size: 16px; }
884
+ .iwb-note-preview h3 { font-size: 14px; }
885
+ .iwb-note-preview h4 { font-size: 12.5px; }
886
+ .iwb-note-preview p, .iwb-note-preview .iwb-md-p { margin: 0 0 10px; }
887
+ .iwb-note-preview ul, .iwb-note-preview ol { margin: 6px 0 12px 20px; padding: 0; }
888
+ .iwb-note-preview li { margin: 4px 0; }
889
+ .iwb-note-preview .iwb-codeblock { margin: 8px 0 12px; }
890
+ .iwb-note-preview .iwb-md-code { padding: 1px 4px; border-radius: 4px; background: var(--dsw-alias-bg-layer-2); }
891
+ .iwb-note-preview .iwb-md-link { color: var(--dsw-alias-label-deep-diving); text-decoration: underline; }
892
+ .iwb-note-preview .iwb-md-quote { margin: 8px 0; padding-left: 10px; border-left: 2px solid var(--dsw-alias-border-l3); color: var(--dsw-alias-label-secondary); }
893
+ .iwb-note-input[hidden], .iwb-note-preview[hidden] { display: none !important; }
894
+ .iwb-file-body { height: 100%; display: flex; flex-direction: column; gap: 10px; align-items: stretch; }
895
+ .iwb-file-thumb { width: 100%; height: 220px; object-fit: contain; border-radius: 9px; background: var(--dsw-alias-bg-layer-2); }
896
+ .iwb-file-icon {
897
+ height: 120px; display: grid; place-items: center; border-radius: 10px;
898
+ background: var(--dsw-alias-bg-layer-2); color: var(--dsw-alias-label-tertiary);
899
+ font-size: 22px; font-weight: 650; letter-spacing: .08em;
900
+ }
901
+ .iwb-file-name { font-size: 13px; font-weight: 600; line-height: 1.45; word-break: break-word; }
902
+ .iwb-file-meta { font-size: 11px; line-height: 1.5; color: var(--dsw-alias-label-tertiary); word-break: break-all; }
903
+ .iwb-file-open { align-self: flex-start; margin-top: auto; }
904
+ .iwb-file-preview-button { width: 22px; height: 22px; display: grid; place-items: center; }
905
+ .iwb-file-dialog {
906
+ width: min(980px, calc(100vw - 40px)); height: min(780px, calc(100vh - 40px)); padding: 0;
907
+ border: .5px solid var(--dsw-alias-border-l2); border-radius: 16px;
908
+ background: var(--dsw-alias-bg-base); color: var(--dsw-alias-label-primary); box-shadow: var(--dsw-shadow-lv4);
909
+ }
910
+ .iwb-file-dialog::backdrop { background: rgba(15,17,21,.35); backdrop-filter: blur(3px); }
911
+ .iwb-file-dialog-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; padding: 18px 20px 12px; border-bottom: .5px solid var(--dsw-alias-border-l1); }
912
+ .iwb-file-dialog-head h2 { margin: 0 0 5px; font-size: 17px; line-height: 1.4; word-break: break-word; }
913
+ .iwb-file-dialog-head p { margin: 0; font-size: 11px; color: var(--dsw-alias-label-tertiary); }
914
+ .iwb-file-dialog-close { width: 28px; height: 28px; border: 0; border-radius: 7px; background: transparent; color: var(--dsw-alias-label-secondary); font-size: 22px; cursor: pointer; }
915
+ .iwb-file-dialog-close:hover { background: var(--dsw-alias-interactive-bg-hover); }
916
+ .iwb-file-dialog-body { height: calc(100% - 126px); overflow: auto; padding: 16px 20px; overscroll-behavior: contain; }
917
+ .iwb-file-preview-image { display: block; max-width: 100%; max-height: 100%; margin: auto; object-fit: contain; border-radius: 10px; }
918
+ .iwb-file-preview-frame { width: 100%; height: 100%; min-height: 520px; border: .5px solid var(--dsw-alias-border-l2); border-radius: 10px; background: white; }
919
+ .iwb-file-preview-text { margin: 0; white-space: pre-wrap; word-break: break-word; font: 12px/1.65 var(--dsw-font-mono, monospace); color: var(--dsw-alias-label-primary); }
920
+ .iwb-file-dialog-foot { display: flex; justify-content: flex-end; padding: 10px 20px 14px; border-top: .5px solid var(--dsw-alias-border-l1); }
921
+ .iwb-file-dialog-foot a { text-decoration: none; }
922
+
923
+ @media (prefers-reduced-motion: reduce) {
924
+ .iwb-links path.iwb-link-delivering { animation: none; }
925
+ }
@@ -0,0 +1,83 @@
1
+ /**
2
+ * Run task-analysis prompts through a real, inspectable DSH session.
3
+ * The session remains in the native sidebar so users can audit the full answer.
4
+ */
5
+
6
+ export function assistantTextFromView(view) {
7
+ const items = Array.isArray(view?.items) ? view.items : [];
8
+ for (let index = items.length - 1; index >= 0; index -= 1) {
9
+ const item = items[index];
10
+ if (item?.k === 'assistant' && typeof item.text === 'string' && item.text.trim()) {
11
+ return item.text.trim();
12
+ }
13
+ }
14
+ return '';
15
+ }
16
+
17
+ const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
18
+
19
+ export async function runTaskAnalysis({
20
+ adapter,
21
+ prompt,
22
+ workspaceId,
23
+ timeoutMs = 120000,
24
+ selection,
25
+ signal,
26
+ pollMs = 450,
27
+ title = '灵感工作台 · 任务规划',
28
+ }) {
29
+ if (!adapter?.createSession || !adapter?.prompt) {
30
+ throw new Error('当前环境没有提供可用的 AI 会话接口');
31
+ }
32
+ if (!String(prompt || '').trim()) throw new Error('规划内容不能为空');
33
+
34
+ const sessionId = await adapter.createSession({ workspaceId, title });
35
+ const stop = adapter.open(sessionId, () => {});
36
+ let timedOut = false;
37
+ const startedAt = Date.now();
38
+ let sawRunning = false;
39
+
40
+ const abort = async () => {
41
+ try { await adapter.cancel(sessionId); } catch { /* best effort */ }
42
+ };
43
+ signal?.addEventListener?.('abort', abort, { once: true });
44
+
45
+ try {
46
+ if (adapter.waitForReady) await adapter.waitForReady(sessionId, { timeoutMs: 15000 });
47
+ if (selection && adapter.selectModel) {
48
+ await adapter.selectModel(sessionId, {
49
+ provider: selection.provider,
50
+ model: selection.model || selection.id,
51
+ reasoningEffort: selection.reasoningEffort,
52
+ });
53
+ }
54
+ await adapter.prompt(sessionId, prompt, 'queue');
55
+
56
+ while (Date.now() - startedAt < timeoutMs) {
57
+ if (signal?.aborted) throw new Error('已取消本次规划');
58
+ const view = adapter.read(sessionId);
59
+ sawRunning = sawRunning || Boolean(view?.running);
60
+ if (view?.lastError) throw new Error(String(view.lastError));
61
+ const text = assistantTextFromView(view);
62
+ // Some adapters publish the final text just before flipping running=false.
63
+ // Requiring either an observed run or a short settle window avoids returning
64
+ // an empty intermediate frame on very fast responses.
65
+ if (text && !view?.running && (sawRunning || Date.now() - startedAt > 1800)) {
66
+ return { sessionId, text, title };
67
+ }
68
+ await sleep(pollMs);
69
+ }
70
+ timedOut = true;
71
+ await abort();
72
+ const error = new Error('本次规划超时,已停止等待;可在原生会话中查看或重试');
73
+ error.sessionId = sessionId;
74
+ throw error;
75
+ } catch (error) {
76
+ if (!error.sessionId) error.sessionId = sessionId;
77
+ if (!timedOut && signal?.aborted) await abort();
78
+ throw error;
79
+ } finally {
80
+ signal?.removeEventListener?.('abort', abort);
81
+ stop?.();
82
+ }
83
+ }