@dsh-workbench/shared 1.5.2-rc.1 → 1.5.2

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 (37) hide show
  1. package/dist/api/blocker-table.d.ts +11 -3
  2. package/dist/api/blocker-table.js +88 -49
  3. package/dist/components/card/CardBoundary.d.ts +17 -4
  4. package/dist/components/card/CardBoundary.js +55 -12
  5. package/dist/components/card/CardBoundary.module.css +10 -0
  6. package/dist/contract/blocker.d.ts +4 -0
  7. package/dist/contract/blocker.js +25 -12
  8. package/dist/host/adapters/port-types.d.ts +2 -0
  9. package/dist/host/supply/preflight.d.ts +16 -1
  10. package/dist/i18n/en.js +46 -10
  11. package/dist/i18n/index.d.ts +47 -11
  12. package/dist/i18n/zh.d.ts +46 -10
  13. package/dist/i18n/zh.js +46 -10
  14. package/dist/index.d.ts +2 -0
  15. package/dist/index.js +2 -0
  16. package/dist/lib/blocker-action.d.ts +1 -0
  17. package/dist/lib/copy-flash.d.ts +10 -0
  18. package/dist/lib/copy-flash.js +30 -0
  19. package/dist/lib/fault-prompt.d.ts +40 -0
  20. package/dist/lib/fault-prompt.js +44 -0
  21. package/package.json +1 -1
  22. package/src/api/__tests__/blocker-table.test.ts +112 -3
  23. package/src/api/blocker-table.ts +109 -54
  24. package/src/components/card/CardBoundary.module.css +10 -0
  25. package/src/components/card/CardBoundary.tsx +83 -12
  26. package/src/components/card/__tests__/card-boundary.test.tsx +137 -0
  27. package/src/contract/blocker.ts +31 -12
  28. package/src/host/adapters/port-types.ts +2 -0
  29. package/src/host/runtime/__tests__/dsh-compat.test.ts +1 -1
  30. package/src/host/supply/preflight.ts +18 -2
  31. package/src/i18n/en.ts +46 -10
  32. package/src/i18n/zh.ts +46 -10
  33. package/src/index.ts +2 -0
  34. package/src/lib/__tests__/copy-flash.test.ts +72 -0
  35. package/src/lib/blocker-action.ts +1 -0
  36. package/src/lib/copy-flash.ts +34 -0
  37. package/src/lib/fault-prompt.ts +90 -0
@@ -1,7 +1,13 @@
1
1
  import type { Translate } from '../lib/dsh-client.js';
2
2
  import type { CapabilityPayload } from '../contract/workbench-contract.js';
3
3
  import type { ApiError } from './workbench-client.js';
4
- import type { ModuleBlocker } from '../contract/blocker.js';
4
+ import type { BlockerAction, ModuleBlocker } from '../contract/blocker.js';
5
+ import { type PromptFacts } from '../lib/fault-prompt.js';
6
+ export interface BlockerAsk {
7
+ readonly screen?: string;
8
+ readonly step?: string;
9
+ }
10
+ export declare function askAgentActionOf(t: Translate, facts: PromptFacts): BlockerAction;
5
11
  /**
6
12
  * 把一条诊断码翻成卡住态:标题取该码自己的文案,不认识的码退回兜底那条。
7
13
  * @param code 诊断码(`DIAG_*`);不在注册表里就按兜底码处理。
@@ -9,7 +15,7 @@ import type { ModuleBlocker } from '../contract/blocker.js';
9
15
  * @param detail 可选的技术细节,原样透传;给 null 就不带。
10
16
  * @returns 一定有一张卡,actions 至少一颗「重试」。
11
17
  */
12
- export declare function blockerOfDiag(code: string, t: Translate, detail?: string | null): ModuleBlocker;
18
+ export declare function blockerOfDiag(code: string, t: Translate, detail?: string | null, ask?: BlockerAsk): ModuleBlocker;
13
19
  /**
14
20
  * 把一次读失败翻成一张卡住态,交给卡片直接渲染。
15
21
  * @param error 读口回的错误;undefined 表示连错误都没拿到(多半是网络断,回「原因未知」)。
@@ -21,6 +27,7 @@ export declare function blockerOfError(error: ApiError | undefined, t: Translate
21
27
  path?: string | null;
22
28
  platform?: string;
23
29
  diagnose?: Readonly<Partial<Record<'exec' | 'login' | 'bridge', string>>>;
30
+ ask?: BlockerAsk;
24
31
  }): ModuleBlocker;
25
32
  /**
26
33
  * 把一次读失败与一份能力读数合成一张卡住态:能力闸优先,其次读口错误;两者都干净时返回 `undefined`。
@@ -37,6 +44,7 @@ export declare function blockerOf(parts: {
37
44
  readonly t: Translate;
38
45
  readonly platform?: string | undefined;
39
46
  readonly loginUrl?: string | undefined;
47
+ readonly ask?: BlockerAsk | undefined;
40
48
  }): ModuleBlocker | undefined;
41
49
  /**
42
50
  * 把宿主回的环境读数翻成卡住态:探针没查过(unchecked)只算提示,不挡卡片。
@@ -44,4 +52,4 @@ export declare function blockerOf(parts: {
44
52
  * @param t 文案函数,键都在 env.unit.* / blocker.* 下。
45
53
  * @returns status 为 'ok' 时给 undefined(没有卡住态),其余状态一律给一张。
46
54
  */
47
- export declare function blockerOfCapability(capability: CapabilityPayload, t: Translate): ModuleBlocker | undefined;
55
+ export declare function blockerOfCapability(capability: CapabilityPayload, t: Translate, ask?: BlockerAsk): ModuleBlocker | undefined;
@@ -1,4 +1,5 @@
1
1
  import { DIAG_FALLBACK_CODE, diagSpecOf, isDiagCode } from '../contract/blocker.js';
2
+ import { faultPromptOf, firstLineOf } from '../lib/fault-prompt.js';
2
3
  import { shortenPath } from '../lib/ui.js';
3
4
  function retryAction(t) {
4
5
  return { kind: 'retry', label: t('blocker.retry') };
@@ -6,6 +7,25 @@ function retryAction(t) {
6
7
  function copyAction(t, text) {
7
8
  return { kind: 'copy', label: t('blocker.copy'), text };
8
9
  }
10
+ export function askAgentActionOf(t, facts) {
11
+ return { kind: 'ask-agent', label: t('askAgent.copy'), prompt: faultPromptOf(facts, t) };
12
+ }
13
+ function askOf(t, ask) {
14
+ return {
15
+ screen: ask?.screen ?? t('askAgent.screen.board'),
16
+ ...(ask?.step === undefined ? {} : { step: ask.step }),
17
+ };
18
+ }
19
+ function cardBlocker(parts) {
20
+ const base = {
21
+ id: parts.id,
22
+ severity: parts.severity,
23
+ title: parts.title,
24
+ hint: parts.hint,
25
+ actions: parts.actions,
26
+ };
27
+ return parts.detail === undefined ? base : { ...base, detail: parts.detail };
28
+ }
9
29
  /**
10
30
  * 把一条诊断码翻成卡住态:标题取该码自己的文案,不认识的码退回兜底那条。
11
31
  * @param code 诊断码(`DIAG_*`);不在注册表里就按兜底码处理。
@@ -13,15 +33,26 @@ function copyAction(t, text) {
13
33
  * @param detail 可选的技术细节,原样透传;给 null 就不带。
14
34
  * @returns 一定有一张卡,actions 至少一颗「重试」。
15
35
  */
16
- export function blockerOfDiag(code, t, detail = null) {
17
- const spec = diagSpecOf(isDiagCode(code) ? code : DIAG_FALLBACK_CODE);
36
+ export function blockerOfDiag(code, t, detail = null, ask) {
37
+ const known = isDiagCode(code);
38
+ const spec = diagSpecOf(known ? code : DIAG_FALLBACK_CODE);
39
+ const title = t(spec?.messageKey ?? 'diag.code.unknownCode');
40
+ const actions = known
41
+ ? [retryAction(t)]
42
+ : [
43
+ askAgentActionOf(t, {
44
+ ...askOf(t, ask),
45
+ problem: { why: title, issue: code, ...(detail === null ? {} : { reason: firstLineOf(detail) }) },
46
+ }),
47
+ retryAction(t),
48
+ ];
18
49
  return {
19
50
  id: `diag:${spec?.code ?? DIAG_FALLBACK_CODE}`,
20
51
  severity: 'block',
21
- title: t(spec?.messageKey ?? 'diag.code.unknownCode'),
52
+ title,
22
53
  ...(spec?.hintKey === undefined ? {} : { hint: t(spec.hintKey) }),
23
54
  ...(detail === null ? {} : { detail }),
24
- actions: [retryAction(t)],
55
+ actions,
25
56
  };
26
57
  }
27
58
  /**
@@ -33,11 +64,12 @@ export function blockerOfDiag(code, t, detail = null) {
33
64
  */
34
65
  export function blockerOfError(error, t, context = {}) {
35
66
  if (error === undefined) {
67
+ const title = t('blocker.unknown.title');
36
68
  return {
37
69
  id: 'unknown',
38
70
  severity: 'block',
39
- title: t('blocker.unknown.title'),
40
- actions: [retryAction(t)],
71
+ title,
72
+ actions: [askAgentActionOf(t, { ...askOf(t, context.ask), problem: { why: title } }), retryAction(t)],
41
73
  };
42
74
  }
43
75
  switch (error.code) {
@@ -107,15 +139,29 @@ export function blockerOfError(error, t, context = {}) {
107
139
  ...(error.detail === undefined ? {} : { detail: error.detail }),
108
140
  actions: [retryAction(t)],
109
141
  };
110
- default:
142
+ default: {
143
+ const title = t('blocker.unknown.title');
111
144
  return {
112
145
  id: error.code,
113
146
  severity: 'block',
114
- title: t('blocker.unknown.title'),
147
+ title,
115
148
  ...(error.hint === undefined ? {} : { hint: error.hint }),
116
149
  detail: error.detail ?? error.message,
117
- actions: [retryAction(t)],
150
+ actions: [
151
+ askAgentActionOf(t, {
152
+ ...askOf(t, context.ask),
153
+ problem: {
154
+ why: title,
155
+ issue: error.code,
156
+ ...(firstLineOf(error.detail ?? error.message) === undefined
157
+ ? {}
158
+ : { reason: firstLineOf(error.detail ?? error.message) }),
159
+ },
160
+ }),
161
+ retryAction(t),
162
+ ],
118
163
  };
164
+ }
119
165
  }
120
166
  }
121
167
  /**
@@ -129,7 +175,7 @@ export function blockerOfError(error, t, context = {}) {
129
175
  */
130
176
  export function blockerOf(parts) {
131
177
  if (parts.capability !== undefined) {
132
- const fromCapability = blockerOfCapability(parts.capability, parts.t);
178
+ const fromCapability = blockerOfCapability(parts.capability, parts.t, parts.ask);
133
179
  if (fromCapability !== undefined)
134
180
  return fromCapability;
135
181
  }
@@ -138,7 +184,10 @@ export function blockerOf(parts) {
138
184
  const isLogin = parts.error.code === 'auth-required' || parts.error.code === 'auth';
139
185
  const helpUrl = parts.error.helpUrl !== undefined || !isLogin ? parts.error.helpUrl : parts.loginUrl;
140
186
  const withHelp = helpUrl === undefined ? parts.error : { ...parts.error, helpUrl };
141
- return blockerOfError(withHelp, parts.t, parts.platform === undefined ? {} : { platform: parts.platform });
187
+ return blockerOfError(withHelp, parts.t, {
188
+ ...(parts.platform === undefined ? {} : { platform: parts.platform }),
189
+ ...(parts.ask === undefined ? {} : { ask: parts.ask }),
190
+ });
142
191
  }
143
192
  /**
144
193
  * 把宿主回的环境读数翻成卡住态:探针没查过(unchecked)只算提示,不挡卡片。
@@ -146,7 +195,7 @@ export function blockerOf(parts) {
146
195
  * @param t 文案函数,键都在 env.unit.* / blocker.* 下。
147
196
  * @returns status 为 'ok' 时给 undefined(没有卡住态),其余状态一律给一张。
148
197
  */
149
- export function blockerOfCapability(capability, t) {
198
+ export function blockerOfCapability(capability, t, ask) {
150
199
  if (capability.status === 'ok')
151
200
  return undefined;
152
201
  const problem = capability.needs.find((need) => need.status !== 'ok');
@@ -167,54 +216,44 @@ export function blockerOfCapability(capability, t) {
167
216
  ];
168
217
  const detail = problem?.detail ?? capability.detail;
169
218
  if (capability.status === 'failed') {
170
- return {
219
+ const title = t('env.unit.failed');
220
+ const reason = firstLineOf(capability.detail);
221
+ return cardBlocker({
171
222
  id: 'unit-mount-failed',
172
223
  severity: 'block',
173
- title: t('env.unit.failed'),
224
+ title,
174
225
  hint: t('env.unit.failedHint'),
175
- ...(capability.detail === undefined ? {} : { detail: capability.detail }),
176
- actions: [retryAction(t)],
177
- };
226
+ detail: capability.detail,
227
+ actions: [
228
+ askAgentActionOf(t, {
229
+ ...askOf(t, ask),
230
+ step: ask?.step ?? capability.unit,
231
+ problem: { why: title, ...(reason === undefined ? {} : { reason }) },
232
+ }),
233
+ retryAction(t),
234
+ ],
235
+ });
178
236
  }
179
- if (capability.status === 'unsupported') {
180
- return {
181
- id: 'unit-unsupported',
182
- severity: 'block',
183
- title: t('env.unit.unsupported'),
184
- hint: t('env.unit.unsupportedHint'),
185
- ...(detail === undefined ? {} : { detail }),
237
+ if (capability.status === 'unsupported' || capability.status === 'degraded') {
238
+ const notice = capability.status === 'degraded';
239
+ return cardBlocker({
240
+ id: notice ? 'unit-degraded' : 'unit-unsupported',
241
+ severity: notice ? 'notice' : 'block',
242
+ title: t(notice ? 'env.unit.degraded' : 'env.unit.unsupported'),
243
+ hint: t(notice ? 'env.unit.degradedHint' : 'env.unit.unsupportedHint'),
244
+ detail,
186
245
  actions: [retryAction(t)],
187
- };
246
+ });
188
247
  }
189
- if (capability.status === 'degraded') {
190
- return {
191
- id: 'unit-degraded',
192
- severity: 'notice',
193
- title: t('env.unit.degraded'),
194
- hint: t('env.unit.degradedHint'),
195
- ...(detail === undefined ? {} : { detail }),
196
- actions: [retryAction(t)],
197
- };
198
- }
199
- if (problem === undefined) {
200
- return {
248
+ if (problem === undefined || problem.status === 'unchecked') {
249
+ return cardBlocker({
201
250
  id: 'unit-unchecked',
202
251
  severity: 'notice',
203
252
  title: t('env.unit.unchecked'),
204
253
  hint: t('env.unit.uncheckedHint'),
205
- ...(capability.detail === undefined ? {} : { detail: capability.detail }),
254
+ detail: problem === undefined ? capability.detail : detail,
206
255
  actions: [retryAction(t)],
207
- };
208
- }
209
- if (problem.status === 'unchecked') {
210
- return {
211
- id: 'unit-unchecked',
212
- severity: 'notice',
213
- title: t('env.unit.unchecked'),
214
- hint: t('env.unit.uncheckedHint'),
215
- ...(detail === undefined ? {} : { detail }),
216
- actions: [retryAction(t)],
217
- };
256
+ });
218
257
  }
219
258
  const kindTitle = `env.need.${problem.kind}.${problem.status}`;
220
259
  return {
@@ -13,10 +13,12 @@ export interface CardBoundaryProps {
13
13
  readonly children?: ReactNode | undefined;
14
14
  }
15
15
  /**
16
- * `CardBoundary` 的状态:这次渲染炸出来的那句话,没炸是 `null`。
16
+ * `CardBoundary` 的状态:这次渲染炸出来的那句话、折叠行是否展开、刚复制过没有。
17
17
  */
18
18
  export interface CardBoundaryState {
19
19
  readonly reason: string | null;
20
+ readonly detailsOpen: boolean;
21
+ readonly copied: boolean;
20
22
  }
21
23
  /**
22
24
  * 把抛出来的任何东西收成一句人能看的失败原因,上报与展示都用它。
@@ -24,21 +26,32 @@ export interface CardBoundaryState {
24
26
  * @returns 一句原因文本;`Error('')` 这种没带 message 的会回空串(调用点别把它当"一定有话")。
25
27
  */
26
28
  export declare function errorReasonOf(error: unknown): string;
29
+ /**
30
+ * 卡片渲染崩溃时要交给 agent 的那段提示词:位置 + 哪个模块 + 报错首行。
31
+ * @param unit - 出事的 unit id。
32
+ * @param reason - 拦截到的失败原因。
33
+ * @param t - 文案函数,键在 askAgent.* 与 panels.* 下。
34
+ * @returns 可直接粘贴给 agent 的多行提示词。
35
+ */
36
+ export declare function cardBrokenPromptOf(unit: string, reason: string, t: Translate): string;
27
37
  /**
28
38
  * 卡片级错误边界:一张卡渲染炸了只画一条报错 + 重试,不让整块面板跟着塌。
29
39
  * @param props.unit - 出事的 unit id,写进报错文案并作为上报标识。
30
40
  * @param props.resetKey - 重来键:它一变(如切了工作区)就自动清掉报错,把卡片重新渲染一遍。
31
- * @param props.t - 报错那句与重试钮文案的翻译函数。
41
+ * @param props.t - 报错那句、重试钮与「复制给 agent」的翻译函数。
32
42
  * @param props.onFailure - 失败时把原因报给宿主(面板状态要用);不给就只打一条 console。
33
- * @param props.fallback - 出错时改画这一份;不给就画卡片失败提示与重试。
43
+ * @param props.fallback - 出错时改画这一份;不给就画卡片失败提示、可折叠的原文与两颗按钮。
34
44
  * @param props.children - 正常时要渲染的卡片内容。
35
45
  * @returns 正常时是 `children`,炸过且还没重来之前是一条报错。
36
46
  */
37
47
  export declare class CardBoundary extends Component<CardBoundaryProps, CardBoundaryState> {
38
48
  state: CardBoundaryState;
49
+ private readonly flash;
39
50
  static getDerivedStateFromError(error: unknown): CardBoundaryState;
40
51
  componentDidCatch(error: unknown): void;
41
52
  componentDidUpdate(previous: CardBoundaryProps): void;
42
- private readonly retry;
53
+ componentWillUnmount(): void;
54
+ private readonly reset;
55
+ private readonly copyPrompt;
43
56
  render(): ReactNode;
44
57
  }
@@ -1,7 +1,11 @@
1
1
  import { Component, h } from '../../lib/react.js';
2
+ import { CodeBlock, DisclosureRow, IconInfoOutlineRegular } from '@deepseek-ai/dsh-client-ui-primitives';
3
+ import { createCopyFlash } from '../../lib/copy-flash.js';
4
+ import { faultPromptOf, firstLineOf } from '../../lib/fault-prompt.js';
2
5
  import { Note } from '../feedback/Note.js';
3
6
  import { FormActions } from '../form/FormActions.js';
4
7
  import styles from './CardBoundary.module.css';
8
+ const COPIED_MS = 1500;
5
9
  /**
6
10
  * 把抛出来的任何东西收成一句人能看的失败原因,上报与展示都用它。
7
11
  * @param error - 抛出来的值:`Error` 取 `message`,字符串原样,其余走 JSON。
@@ -12,20 +16,41 @@ export function errorReasonOf(error) {
12
16
  return error.message;
13
17
  return typeof error === 'string' ? error : JSON.stringify(error) ?? String(error);
14
18
  }
19
+ /**
20
+ * 卡片渲染崩溃时要交给 agent 的那段提示词:位置 + 哪个模块 + 报错首行。
21
+ * @param unit - 出事的 unit id。
22
+ * @param reason - 拦截到的失败原因。
23
+ * @param t - 文案函数,键在 askAgent.* 与 panels.* 下。
24
+ * @returns 可直接粘贴给 agent 的多行提示词。
25
+ */
26
+ export function cardBrokenPromptOf(unit, reason, t) {
27
+ const cause = firstLineOf(reason);
28
+ return faultPromptOf({
29
+ screen: t('askAgent.screen.board'),
30
+ problem: {
31
+ why: t('panels.cardBroken', { unit }),
32
+ ...(cause === undefined ? {} : { reason: cause }),
33
+ },
34
+ }, t);
35
+ }
36
+ function stateOf(reason) {
37
+ return { reason, detailsOpen: false, copied: false };
38
+ }
15
39
  /**
16
40
  * 卡片级错误边界:一张卡渲染炸了只画一条报错 + 重试,不让整块面板跟着塌。
17
41
  * @param props.unit - 出事的 unit id,写进报错文案并作为上报标识。
18
42
  * @param props.resetKey - 重来键:它一变(如切了工作区)就自动清掉报错,把卡片重新渲染一遍。
19
- * @param props.t - 报错那句与重试钮文案的翻译函数。
43
+ * @param props.t - 报错那句、重试钮与「复制给 agent」的翻译函数。
20
44
  * @param props.onFailure - 失败时把原因报给宿主(面板状态要用);不给就只打一条 console。
21
- * @param props.fallback - 出错时改画这一份;不给就画卡片失败提示与重试。
45
+ * @param props.fallback - 出错时改画这一份;不给就画卡片失败提示、可折叠的原文与两颗按钮。
22
46
  * @param props.children - 正常时要渲染的卡片内容。
23
47
  * @returns 正常时是 `children`,炸过且还没重来之前是一条报错。
24
48
  */
25
49
  export class CardBoundary extends Component {
26
- state = { reason: null };
50
+ state = stateOf(null);
51
+ flash = createCopyFlash(COPIED_MS);
27
52
  static getDerivedStateFromError(error) {
28
- return { reason: errorReasonOf(error) };
53
+ return stateOf(errorReasonOf(error));
29
54
  }
30
55
  componentDidCatch(error) {
31
56
  const reason = errorReasonOf(error);
@@ -34,28 +59,46 @@ export class CardBoundary extends Component {
34
59
  }
35
60
  componentDidUpdate(previous) {
36
61
  if (previous.resetKey !== this.props.resetKey && this.state.reason !== null) {
37
- this.setState({ reason: null });
62
+ this.reset();
38
63
  }
39
64
  }
40
- retry = () => {
41
- this.setState({ reason: null });
65
+ componentWillUnmount() {
66
+ this.flash.dispose();
67
+ }
68
+ reset = () => {
69
+ this.flash.dispose();
70
+ this.setState(stateOf(null));
71
+ };
72
+ copyPrompt = () => {
73
+ const reason = this.state.reason;
74
+ if (reason === null)
75
+ return;
76
+ this.flash.copy(cardBrokenPromptOf(this.props.unit, reason, this.props.t), (copied) => this.setState({ copied }));
42
77
  };
43
78
  render() {
44
- const { reason } = this.state;
79
+ const { reason, detailsOpen, copied } = this.state;
45
80
  if (reason === null)
46
81
  return this.props.children;
47
82
  if (this.props.fallback !== undefined)
48
83
  return this.props.fallback;
49
84
  return (h(Note, { tone: "problem" },
50
85
  h("div", { className: styles.failure },
51
- h("span", null, this.props.t('panels.cardBroken', { unit: this.props.unit, reason })),
86
+ h("span", null, this.props.t('panels.cardBroken', { unit: this.props.unit })),
87
+ reason === '' ? null : (h(DisclosureRow, { className: styles.raw, icon: h(IconInfoOutlineRegular, { size: 14 }), title: this.props.t('env.fix.details'), open: detailsOpen, expandable: true, expandOnRowClick: true, previewChevron: true, onToggle: () => this.setState({ detailsOpen: !detailsOpen }) },
88
+ h(CodeBlock, { code: reason, copyLabel: this.props.t('blocker.copy'), copiedLabel: this.props.t('env.copied') }))),
52
89
  h(FormActions, { actions: [
53
90
  {
54
91
  key: 'retry',
55
92
  label: this.props.t('panels.cardRetry'),
56
- kind: 'default',
57
- onClick: this.retry,
93
+ onClick: this.reset,
94
+ },
95
+ {
96
+ key: 'ask-agent',
97
+ label: this.props.t('askAgent.copy'),
98
+ kind: 'primary',
99
+ onClick: this.copyPrompt,
58
100
  },
59
- ] }))));
101
+ ] }),
102
+ copied ? h("p", { className: styles.hint }, this.props.t('askAgent.hint')) : null)));
60
103
  }
61
104
  }
@@ -3,3 +3,13 @@
3
3
  flex-direction: column;
4
4
  gap: var(--wb-len-8);
5
5
  }
6
+
7
+ .raw {
8
+ margin-top: var(--wb-len-4);
9
+ }
10
+
11
+ .hint {
12
+ margin-top: var(--wb-len-4);
13
+ font-size: var(--dsw-font-xxs-12-font-size);
14
+ color: var(--dsw-alias-label-secondary);
15
+ }
@@ -10,6 +10,10 @@ export type BlockerAction = {
10
10
  readonly kind: 'copy';
11
11
  readonly label: string;
12
12
  readonly text: string;
13
+ } | {
14
+ readonly kind: 'ask-agent';
15
+ readonly label: string;
16
+ readonly prompt: string;
13
17
  } | {
14
18
  readonly kind: 'retry';
15
19
  readonly label: string;
@@ -18,6 +18,16 @@ export const DIAG_ACTIONS = [
18
18
  'export-diagnostics',
19
19
  ];
20
20
  export const DIAG_LEVELS = ['info', 'warn', 'error'];
21
+ function preflightSpec(code, key) {
22
+ return {
23
+ code,
24
+ class: 'env',
25
+ area: 'preflight',
26
+ action: 'retry',
27
+ messageKey: `diag.code.${key}`,
28
+ hintKey: `diag.hint.${key}`,
29
+ };
30
+ }
21
31
  export const DIAG_CODES = [
22
32
  {
23
33
  code: 'READ_FAILED',
@@ -62,6 +72,11 @@ export const DIAG_CODES = [
62
72
  action: 'retry',
63
73
  messageKey: 'diag.code.supplyInstallFailed',
64
74
  },
75
+ preflightSpec('PREFLIGHT_DIY_ROW_BROKEN', 'preflightDiyRowBroken'),
76
+ preflightSpec('PREFLIGHT_DIY_PRESET_MISSING', 'preflightDiyPresetMissing'),
77
+ preflightSpec('PREFLIGHT_BRIDGE_HOLD', 'preflightBridgeHold'),
78
+ preflightSpec('PREFLIGHT_HOST_OLDER', 'preflightHostOlder'),
79
+ preflightSpec('PREFLIGHT_HOST_NEWER', 'preflightHostNewer'),
65
80
  {
66
81
  code: 'DIAG_BAD_PARAM',
67
82
  class: 'user',
@@ -99,28 +114,26 @@ export function diagSpecOf(code) {
99
114
  export function isDiagCode(code) {
100
115
  return BY_CODE.has(code);
101
116
  }
102
- export const DIAG_DETAIL_KEYS = [
117
+ const DETAIL_KEYS_STEP = [
103
118
  'action',
104
119
  'attempt',
105
120
  'cacheAgeMs',
106
121
  'count',
107
122
  'durationMs',
108
123
  'fromVersion',
109
- 'os',
110
- 'path',
111
124
  'phase',
112
- 'pid',
113
- 'pkg',
114
- 'reason',
115
125
  'requestedCode',
116
126
  'route',
117
- 'since',
118
- 'sink',
119
127
  'stage',
120
128
  'toVersion',
121
129
  'truncated',
122
- 'unit',
123
- 'version',
124
- 'workspace',
125
- 'wroteBytes',
130
+ ];
131
+ const DETAIL_KEYS_SUBJECT = ['os', 'path', 'pid', 'pkg', 'reason', 'unit', 'version', 'workspace'];
132
+ const DETAIL_KEYS_PREFLIGHT = ['issues', 'rows', 'runtime', 'tier', 'verified'];
133
+ const DETAIL_KEYS_SINK = ['since', 'sink', 'wroteBytes'];
134
+ export const DIAG_DETAIL_KEYS = [
135
+ ...DETAIL_KEYS_STEP,
136
+ ...DETAIL_KEYS_SUBJECT,
137
+ ...DETAIL_KEYS_PREFLIGHT,
138
+ ...DETAIL_KEYS_SINK,
126
139
  ];
@@ -1,4 +1,5 @@
1
1
  import type { DshHostContext } from '../../api/dsh.js';
2
+ import type { DiagRecorder } from '../runtime/diag-records.js';
2
3
  import type { Seam } from '../seam/run.js';
3
4
  import type { RuntimeCapabilities, RuntimeProfile } from '../../contract/capabilities.js';
4
5
  import type { BrowserCaptureRow } from '../../contract/data.js';
@@ -158,6 +159,7 @@ export interface ProbePreflightInput {
158
159
  readonly runtimeLabel?: string | undefined;
159
160
  readonly warmReads: () => readonly (readonly string[])[];
160
161
  readonly extensionDir?: string | undefined;
162
+ readonly diag?: DiagRecorder | undefined;
161
163
  }
162
164
  export interface ProbePort {
163
165
  probeUnits(options: ProbeUnitsOptions): Promise<UnitCapability[]>;
@@ -13,14 +13,26 @@ export interface PreflightStep {
13
13
  readonly log?: readonly string[];
14
14
  }
15
15
  export interface PreflightDiyGap {
16
+ readonly kind: 'older-dsh' | 'broken-row' | 'preset-missing';
16
17
  readonly rows: readonly string[];
17
18
  readonly detail: string;
18
- readonly command: string;
19
+ readonly command?: string;
20
+ }
21
+ export interface PreflightPaths {
22
+ readonly workbenchRoot: string;
23
+ readonly dshHome: string;
24
+ }
25
+ export interface PreflightHostFacts {
26
+ readonly version?: string;
27
+ readonly from?: string;
28
+ readonly profileDir?: string;
29
+ readonly verified?: string;
19
30
  }
20
31
  export type PreflightHostTier = 'newer' | 'older';
21
32
  export type PreflightHostStanding = {
22
33
  readonly tier: 'ok';
23
34
  readonly log?: readonly string[];
35
+ readonly facts?: PreflightHostFacts;
24
36
  } | PreflightHostGap;
25
37
  export interface PreflightHostGap {
26
38
  readonly tier: PreflightHostTier;
@@ -28,6 +40,7 @@ export interface PreflightHostGap {
28
40
  readonly verified: string;
29
41
  readonly command?: string;
30
42
  readonly log?: readonly string[];
43
+ readonly facts?: PreflightHostFacts;
31
44
  }
32
45
  export interface PreflightSnapshot {
33
46
  readonly phase: 'idle' | 'checking' | 'installing' | 'ready' | 'failed';
@@ -38,6 +51,8 @@ export interface PreflightSnapshot {
38
51
  readonly guidance?: PreflightGuidance;
39
52
  readonly bridgeIssues?: readonly PreflightBridgeIssue[];
40
53
  readonly hostGap?: PreflightHostGap;
54
+ readonly hostFacts?: PreflightHostFacts;
55
+ readonly paths?: PreflightPaths;
41
56
  readonly diyGap?: PreflightDiyGap;
42
57
  readonly canWakeBrowser?: boolean;
43
58
  readonly extensionDir?: string;