@fish-under-sea/dsh-client-ui-task-board-fish 1.0.2 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (125) hide show
  1. package/NOTICE +1 -1
  2. package/README.en.md +6 -4
  3. package/README.md +6 -4
  4. package/README.zh.md +6 -4
  5. package/icon.png +0 -0
  6. package/lib/client.js +4428 -1508
  7. package/lib/client.js.map +1 -1
  8. package/lib/index.js +2670 -496
  9. package/lib/types/client/CardDefaultPresetField.d.ts +35 -0
  10. package/lib/types/client/PluginSettingsCard.d.ts +130 -19
  11. package/lib/types/client/RangeBubble.d.ts +46 -0
  12. package/lib/types/client/SegmentGroup.d.ts +28 -0
  13. package/lib/types/client/TaskBoardSettingsCard.d.ts +63 -0
  14. package/lib/types/client/board/AttachmentField.d.ts +70 -0
  15. package/lib/types/client/board/ExecutionLog.d.ts +24 -0
  16. package/lib/types/client/board/ReasoningEffortField.d.ts +25 -0
  17. package/lib/types/client/board/TaskForm.d.ts +4 -0
  18. package/lib/types/client/board/VerificationReport.d.ts +2 -15
  19. package/lib/types/client/board/model-options.d.ts +87 -0
  20. package/lib/types/client/board/preset-label.d.ts +21 -0
  21. package/lib/types/client/board/preset-roster.d.ts +45 -0
  22. package/lib/types/client/board/source-group.d.ts +27 -0
  23. package/lib/types/client/body-mutations.d.ts +45 -0
  24. package/lib/types/client/host-api.d.ts +25 -0
  25. package/lib/types/client/locales.d.ts +87 -9
  26. package/lib/types/client/pending-verify.d.ts +47 -0
  27. package/lib/types/client/plugin-card-seat.d.ts +3 -1
  28. package/lib/types/client/service.d.ts +4 -1
  29. package/lib/types/client/settings-form.d.ts +73 -51
  30. package/lib/types/core/attachment.d.ts +132 -0
  31. package/lib/types/core/card-defaults.d.ts +78 -0
  32. package/lib/types/core/controller.d.ts +57 -8
  33. package/lib/types/core/execution-summary.d.ts +52 -0
  34. package/lib/types/core/extension.d.ts +116 -0
  35. package/lib/types/core/launch-width.d.ts +31 -0
  36. package/lib/types/core/reasoning-effort.d.ts +57 -0
  37. package/lib/types/core/session-reuse.d.ts +7 -1
  38. package/lib/types/core/spend-budget.d.ts +28 -0
  39. package/lib/types/core/subtask.d.ts +100 -37
  40. package/lib/types/core/tasks.d.ts +94 -10
  41. package/lib/types/core/use-cases/task-create.d.ts +10 -5
  42. package/lib/types/core/use-cases/task-tag.d.ts +36 -0
  43. package/lib/types/core/use-cases/task-update.d.ts +22 -1
  44. package/lib/types/core/wire-projection.d.ts +35 -0
  45. package/lib/types/core/workspace-target.d.ts +23 -3
  46. package/lib/types/host/attachments.d.ts +250 -0
  47. package/lib/types/host/extension-registry.d.ts +40 -0
  48. package/lib/types/host/launch-admission.d.ts +71 -0
  49. package/lib/types/host-ledger.d.ts +114 -47
  50. package/lib/types/host-routes.d.ts +63 -0
  51. package/lib/types/host-runner.d.ts +164 -18
  52. package/lib/types/host-service.d.ts +182 -46
  53. package/lib/types/host-spend.d.ts +52 -0
  54. package/lib/types/index.d.ts +173 -54
  55. package/lib/types/loopback.d.ts +41 -1
  56. package/lib/types/protocol.d.ts +52 -11
  57. package/lib/types/tool-surface.d.ts +1 -0
  58. package/locale/en.json +6 -0
  59. package/locale/zh.json +6 -0
  60. package/package.json +36 -29
  61. package/src/client/CardDefaultPresetField.tsx +101 -0
  62. package/src/client/PluginSettingsCard.tsx +385 -111
  63. package/src/client/RangeBubble.tsx +164 -0
  64. package/src/client/SegmentGroup.tsx +93 -0
  65. package/src/client/TaskBoardSettingsCard.tsx +332 -37
  66. package/src/client/board/AttachmentField.tsx +383 -0
  67. package/src/client/board/EditTaskModal.tsx +63 -0
  68. package/src/client/board/ExecutionLog.tsx +154 -0
  69. package/src/client/board/LinkSubtaskModal.tsx +1 -1
  70. package/src/client/board/NewTaskModal.tsx +154 -45
  71. package/src/client/board/ReasoningEffortField.tsx +50 -0
  72. package/src/client/board/TagManagerModal.tsx +151 -2
  73. package/src/client/board/TaskBoard.tsx +47 -10
  74. package/src/client/board/TaskCard.tsx +45 -23
  75. package/src/client/board/TaskDetail.tsx +468 -258
  76. package/src/client/board/TaskForm.tsx +19 -4
  77. package/src/client/board/VerificationReport.tsx +143 -104
  78. package/src/client/board/model-options.ts +208 -0
  79. package/src/client/board/preset-label.ts +32 -0
  80. package/src/client/board/preset-roster.ts +58 -0
  81. package/src/client/board/source-group.ts +94 -0
  82. package/src/client/board/task-markdown.module.css +11 -8
  83. package/src/client/board-settings.module.css +35 -7
  84. package/src/client/board.module.css +1044 -105
  85. package/src/client/body-mutations.ts +133 -0
  86. package/src/client/host-api.ts +70 -0
  87. package/src/client/index.ts +109 -95
  88. package/src/client/locales.ts +205 -48
  89. package/src/client/pending-verify.ts +90 -0
  90. package/src/client/plugin-card-seat.ts +8 -2
  91. package/src/client/service.ts +24 -0
  92. package/src/client/settings-card.module.css +466 -89
  93. package/src/client/settings-entry-form.ts +0 -1
  94. package/src/client/settings-form.ts +102 -60
  95. package/src/core/attachment.ts +287 -0
  96. package/src/core/card-defaults.ts +132 -0
  97. package/src/core/controller.ts +90 -11
  98. package/src/core/execution-summary.ts +96 -0
  99. package/src/core/extension.ts +120 -0
  100. package/src/core/launch-width.ts +38 -0
  101. package/src/core/reasoning-effort.ts +92 -0
  102. package/src/core/session-reuse.ts +7 -1
  103. package/src/core/spend-budget.ts +35 -0
  104. package/src/core/store.ts +19 -1
  105. package/src/core/subtask.ts +144 -68
  106. package/src/core/tasks.ts +117 -10
  107. package/src/core/use-cases/task-create.ts +27 -16
  108. package/src/core/use-cases/task-tag.ts +56 -0
  109. package/src/core/use-cases/task-update.ts +33 -5
  110. package/src/core/wire-projection.ts +81 -0
  111. package/src/core/workspace-target.ts +27 -3
  112. package/src/host/agent-tools.ts +33 -21
  113. package/src/host/attachments.ts +650 -0
  114. package/src/host/extension-registry.ts +150 -5
  115. package/src/host/launch-admission.ts +139 -0
  116. package/src/host-ledger.ts +248 -117
  117. package/src/host-routes.ts +233 -15
  118. package/src/host-runner.ts +395 -61
  119. package/src/host-service.ts +512 -139
  120. package/src/host-spend.ts +105 -0
  121. package/src/index.ts +312 -92
  122. package/src/loopback.ts +57 -1
  123. package/src/protocol.ts +83 -18
  124. package/src/tool-surface.ts +1 -0
  125. package/icon.svg +0 -3
@@ -4,12 +4,12 @@
4
4
  * NewTaskModal and the EditTaskModal. State stays in the owning modal; these
5
5
  * are controlled components.
6
6
  */
7
- import { useState, type ReactNode } from 'react'
7
+ import { useId, useState, type ReactNode } from 'react'
8
8
  import { TAG_NAME_MAX_LENGTH, TAG_PROMPT_MAX_LENGTH, TASK_TAG_LIMIT, normalizeTags, type TaskTag } from '../../core/tasks.ts'
9
9
  import { t } from '../locales.ts'
10
10
  import css from '../board.module.css'
11
11
  import { IconClose, IconPlus } from './icons.tsx'
12
- import { useDialog, type OverlayPhase } from './overlay.tsx'
12
+ import { useDialog, usePresence, type OverlayPhase } from './overlay.tsx'
13
13
 
14
14
  /** DOM id shared by the tag-name inputs and their datalist (one board at a time). */
15
15
  const TAG_NAME_LIST_ID = 'dsh-task-board-tag-names'
@@ -88,6 +88,10 @@ export function ModalShell({
88
88
  * region keeps a one-line summary of the values it holds, so nothing is hidden
89
89
  * without a trace; a region holding a blocking error is forced open by its
90
90
  * owner (forceOpen) rather than reporting the error out of sight.
91
+ *
92
+ * The body is the panel fold's body under another name: it enters and leaves on
93
+ * the same animation pair, and `usePresence` keeps it mounted through the exit
94
+ * leg so collapsing never snaps.
91
95
  */
92
96
  export function CollapsibleSection({
93
97
  title,
@@ -106,13 +110,20 @@ export function CollapsibleSection({
106
110
  children: ReactNode
107
111
  }) {
108
112
  const [open, setOpen] = useState(defaultOpen)
113
+ const panelId = useId()
109
114
  const expanded = forceOpen || open
115
+ const presence = usePresence(expanded)
116
+ // The one-line preview is also the row's title, so the line that ellipsizes
117
+ // in the header stays readable in full (same rule as the panel's folds).
118
+ const fullLine = summary ?? ''
110
119
  return (
111
120
  <section className={css.formSection} data-dsh-part="form-section" data-open={expanded ? 'true' : undefined}>
112
121
  <button
113
122
  type="button"
114
123
  className={css.formSectionHeader}
115
124
  aria-expanded={expanded}
125
+ aria-controls={panelId}
126
+ title={fullLine === '' ? undefined : fullLine}
116
127
  onClick={() => { setOpen(value => !value) }}
117
128
  >
118
129
  <span className={css.formSectionChevron} aria-hidden="true" />
@@ -121,7 +132,11 @@ export function CollapsibleSection({
121
132
  <span className={css.formSectionSummary}>{summary}</span>
122
133
  )}
123
134
  </button>
124
- {expanded && <div className={css.formSectionBody}>{children}</div>}
135
+ {presence.mounted && (
136
+ <div className={css.formSectionBody} id={panelId} data-state={presence.phase}>
137
+ {children}
138
+ </div>
139
+ )}
125
140
  </section>
126
141
  )
127
142
  }
@@ -231,7 +246,7 @@ export function TaskTagFields({
231
246
  />
232
247
  <button
233
248
  type="button"
234
- className={css.ghostButton}
249
+ className={css.iconButton}
235
250
  aria-label={t('new.tagRemove', { name: tag.name })}
236
251
  onClick={() => { onChange(tags.filter((_, position) => position !== index)) }}
237
252
  >
@@ -3,15 +3,18 @@
3
3
  *
4
4
  * Rendered inside the execution-history row, so a rerun or a scheduled run
5
5
  * keeps its OWN report and a later cycle never overwrites an earlier verdict.
6
- * It shows what the board decided and the evidence it decided on: the verdict,
7
- * the judge route and reasoning level, the acceptance count, the total and
8
- * per-criterion scores against their threshold, the findings the judge located,
9
- * the evidence scope with its truncation, and the token usage.
6
+ * The row itself only carries the verdict: the judge route, the acceptance
7
+ * count, the per-criterion scores and their threshold, the findings, the
8
+ * evidence scope and the token usage sit behind one disclosure, because the
9
+ * same machine explanation repeated on all thirty-four rows of a card was what
10
+ * buried the row a reader needed. Expanding it shows every field the board
11
+ * decided on — nothing is dropped, only folded.
10
12
  *
11
13
  * Deliberately adds no new `data-dsh-part` value: the part enum is owned by the
12
14
  * cross-repository semantic-attribute contract, and this report reuses the
13
15
  * execution row's existing markup instead of extending that enum.
14
16
  */
17
+ import { useId, useState } from 'react'
15
18
  import {
16
19
  MAX_INVALID_ATTEMPTS,
17
20
  MAX_QUALITY_ATTEMPTS,
@@ -29,6 +32,7 @@ import {
29
32
  import { t } from '../locales.ts'
30
33
  import type { TaskBoardKey } from '../locales.ts'
31
34
  import css from '../board.module.css'
35
+ import { usePresence } from './overlay.tsx'
32
36
 
33
37
  /** Render one 0..1 score as a percentage. */
34
38
  function percent(value: number): string {
@@ -54,6 +58,22 @@ const PHASE_STATUS_KEY: Record<ReturnType<typeof verificationPhase>, TaskBoardKe
54
58
  invalid: 'verify.status.invalidHeld',
55
59
  }
56
60
 
61
+ /**
62
+ * Board phase → the badge's colour slot. One slot per meaning instead of one
63
+ * per phase: a phase that is still running reads as a warning, a refused
64
+ * acceptance reads as a failure, and an acceptance that never applied reads as
65
+ * neutral — never as a pass.
66
+ */
67
+ const PHASE_TONE: Record<ReturnType<typeof verificationPhase>, 'success' | 'error' | 'warn' | 'neutral'> = {
68
+ off: 'neutral',
69
+ executing: 'warn',
70
+ verifying: 'warn',
71
+ repairing: 'error',
72
+ passed: 'success',
73
+ failed: 'error',
74
+ invalid: 'error',
75
+ }
76
+
57
77
  /** Evidence location → locale key, for one structured finding's citation. */
58
78
  const LOCATION_KEY: Record<VerificationCriterionFinding['location'], TaskBoardKey> = {
59
79
  task: 'verify.location.task',
@@ -83,6 +103,11 @@ const AUDIT_STAGE_KEY: Record<AcceptanceAuditRecord['stage'], TaskBoardKey> = {
83
103
  budget: 'verify.cleanup.stage.budget',
84
104
  }
85
105
 
106
+ /** Stable key for one finding row. */
107
+ function findingKey(attempt: VerificationAttempt, index: number): string {
108
+ return attempt.at.toString(36) + '-' + String(index)
109
+ }
110
+
86
111
  /** One recorded attempt: a quality verdict, an invalid veto, an anomaly, or a budget stop. */
87
112
  function AttemptRow({ attempt, detailRemoved }: { attempt: VerificationAttempt, detailRemoved: boolean }) {
88
113
  // Everything that is not a quality verdict renders as an anomaly row: a
@@ -94,19 +119,21 @@ function AttemptRow({ attempt, detailRemoved }: { attempt: VerificationAttempt,
94
119
  const exception = attempt.stage !== 'quality' && !invalid
95
120
  const result = exception ? 'failed' : attempt.passed ? 'succeeded' : 'failed'
96
121
  return (
97
- <li className={css.executionRow} data-result={result}>
98
- <span className={css.executionBadge} data-result={result}>
99
- {invalid ? t('verify.status.invalid') : exception ? t('verify.status.exception') : attempt.passed ? t('verify.status.passed') : t('verify.status.failed')}
100
- </span>
101
- <span className={css.executionTimes}>
102
- {invalid
103
- ? t('verify.attemptInvalid', { index: String(attempt.index) })
104
- : exception
105
- ? t('verify.attemptException', { index: String(attempt.index) })
106
- : t('verify.attempt', { index: String(attempt.index) })}
107
- {' · '}{routeLabel(attempt)}
108
- {!exception && !invalid && ' · ' + t('verify.rounds', { rounds: String(attempt.rounds) })}
109
- </span>
122
+ <li className={css.attemptRow} data-result={result}>
123
+ <div className={css.attemptHead}>
124
+ <span className={css.executionBadge} data-result={result}>
125
+ {invalid ? t('verify.status.invalid') : exception ? t('verify.status.exception') : attempt.passed ? t('verify.status.passed') : t('verify.status.failed')}
126
+ </span>
127
+ <span className={css.executionTimes}>
128
+ {invalid
129
+ ? t('verify.attemptInvalid', { index: String(attempt.index) })
130
+ : exception
131
+ ? t('verify.attemptException', { index: String(attempt.index) })
132
+ : t('verify.attempt', { index: String(attempt.index) })}
133
+ {' · '}{routeLabel(attempt)}
134
+ {!exception && !invalid && ' · ' + t('verify.rounds', { rounds: String(attempt.rounds) })}
135
+ </span>
136
+ </div>
110
137
  {invalid && (
111
138
  <span className={css.executionTimes}>
112
139
  {t('verify.invalidDetail', { reason: t(invalidReasonKey(attempt)) })}
@@ -195,93 +222,6 @@ function AttemptRow({ attempt, detailRemoved }: { attempt: VerificationAttempt,
195
222
  )
196
223
  }
197
224
 
198
- /** Stable key for one finding row. */
199
- function findingKey(attempt: VerificationAttempt, index: number): string {
200
- return attempt.at.toString(36) + '-' + String(index)
201
- }
202
-
203
- /**
204
- * Render one execution's acceptance report.
205
- * @param props - the execution's persisted acceptance block.
206
- * @returns the report, or nothing when acceptance never applied.
207
- */
208
- export function VerificationReport({ verification }: { verification: ExecutionVerification }) {
209
- const phase = verificationPhase(verification)
210
- if (phase === 'off' && verification.contract.enabled === false && verification.applicability !== 'skipped') return null
211
- const totals = verificationTotals(verification)
212
- const route = verification.contract.route
213
- const applicabilityKey: TaskBoardKey | undefined = verification.applicability === 'disabled'
214
- ? 'verify.applicability.disabled'
215
- : verification.applicability === 'skipped'
216
- ? 'verify.applicability.skipped'
217
- : verification.applicability === 'goal-unavailable'
218
- ? 'verify.applicability.goalUnavailable'
219
- : verification.applicability === 'goal-disabled'
220
- ? 'verify.applicability.goalDisabled'
221
- : verification.applicability === 'team-member' ? 'verify.applicability.teamMember' : undefined
222
- return (
223
- <div className={css.executionTimes}>
224
- <span className={css.executionBadge} data-result={phase === 'passed' ? 'succeeded' : phase === 'failed' ? 'failed' : undefined}>
225
- {t('verify.title')} · {t(PHASE_STATUS_KEY[phase])}
226
- </span>
227
- <span className={css.executionTimes}>
228
- {t('verify.invalidCounts', {
229
- quality: String(qualityAttempts(verification).length),
230
- max: String(MAX_QUALITY_ATTEMPTS),
231
- invalid: String(invalidAttempts(verification).length),
232
- maxInvalid: String(MAX_INVALID_ATTEMPTS),
233
- exceptions: String(exceptionAttempts(verification).length),
234
- })}
235
- </span>
236
- {route !== undefined && (
237
- <span className={css.executionTimes}>
238
- {verification.contract.modelSource === 'inherit'
239
- ? t('verify.judgeInherited', { model: route.provider + '/' + route.model })
240
- : t(route.reasoningEffort === undefined || route.reasoningEffort === '' ? 'verify.judgeNoEffort' : 'verify.judge', {
241
- model: route.provider + '/' + route.model,
242
- ...(route.reasoningEffort === undefined ? {} : { effort: route.reasoningEffort }),
243
- })}
244
- </span>
245
- )}
246
- {verification.contract.effortFallback !== undefined && (
247
- <span className={css.executionTimes}>
248
- {t('verify.effortFallback', {
249
- requested: verification.contract.effortFallback.requested,
250
- resolved: verification.contract.effortFallback.resolved ?? t('settings.goalVerificationResolvedNoEffort'),
251
- })}
252
- </span>
253
- )}
254
- {applicabilityKey !== undefined && <span className={css.executionTimes}>{t(applicabilityKey)}</span>}
255
- {verification.failedReason !== undefined && (
256
- <span className={css.executionTimes}>{t('verify.finalFailure', { reason: verification.failedReason })}</span>
257
- )}
258
- {totals.calls > 0 && (
259
- <span className={css.executionTimes}>
260
- {t('verify.usage', {
261
- calls: String(totals.calls),
262
- input: String(totals.inputTokens),
263
- output: String(totals.outputTokens),
264
- reasoning: String(totals.reasoningTokens),
265
- })}
266
- {totals.usageIncomplete ? t('verify.usageIncomplete') : ''}
267
- </span>
268
- )}
269
- {verification.attempts.length > 0 && (
270
- <ul className={css.executionList}>
271
- {[...verification.attempts].reverse().map(attempt => (
272
- <AttemptRow
273
- key={attempt.at.toString(36) + '-' + attempt.stage + '-' + String(attempt.index)}
274
- attempt={attempt}
275
- detailRemoved={verification.cleanup?.state === 'cleaned'}
276
- />
277
- ))}
278
- </ul>
279
- )}
280
- {verification.cleanup !== undefined && <CleanupNotice cleanup={verification.cleanup} />}
281
- </div>
282
- )
283
- }
284
-
285
225
  /**
286
226
  * Retention notice of one execution's acceptance detail.
287
227
  *
@@ -320,3 +260,102 @@ function CleanupNotice({ cleanup }: { cleanup: AcceptanceCleanupRecord }) {
320
260
  </>
321
261
  )
322
262
  }
263
+
264
+ /**
265
+ * Render one execution's acceptance report.
266
+ * @param props - the execution's persisted acceptance block.
267
+ * @returns the verdict badge with its fold-out detail, or nothing when
268
+ * acceptance never applied.
269
+ */
270
+ export function VerificationReport({ verification }: { verification: ExecutionVerification }) {
271
+ const [expanded, setExpanded] = useState(false)
272
+ const presence = usePresence(expanded)
273
+ const panelId = useId()
274
+ const phase = verificationPhase(verification)
275
+ if (phase === 'off' && verification.contract.enabled === false && verification.applicability !== 'skipped') return null
276
+ const totals = verificationTotals(verification)
277
+ const route = verification.contract.route
278
+ const applicabilityKey: TaskBoardKey | undefined = verification.applicability === 'disabled'
279
+ ? 'verify.applicability.disabled'
280
+ : verification.applicability === 'skipped'
281
+ ? 'verify.applicability.skipped'
282
+ : verification.applicability === 'goal-unavailable'
283
+ ? 'verify.applicability.goalUnavailable'
284
+ : verification.applicability === 'goal-disabled'
285
+ ? 'verify.applicability.goalDisabled'
286
+ : verification.applicability === 'team-member' ? 'verify.applicability.teamMember' : undefined
287
+ return (
288
+ <div className={css.verifyReport}>
289
+ <button
290
+ type="button"
291
+ className={css.verifyBadge}
292
+ data-tone={PHASE_TONE[phase]}
293
+ aria-expanded={expanded}
294
+ aria-controls={panelId}
295
+ onClick={() => { setExpanded(!expanded) }}
296
+ >
297
+ {t('verify.title')}
298
+ <span className={css.verifyVerdict}>{t(PHASE_STATUS_KEY[phase])}</span>
299
+ <span className={css.disclosureChevron} data-open={expanded} aria-hidden="true" />
300
+ </button>
301
+ {presence.mounted && (
302
+ <div className={css.verifyPanel} id={panelId} data-state={presence.phase}>
303
+ <span className={css.executionTimes}>
304
+ {t('verify.invalidCounts', {
305
+ quality: String(qualityAttempts(verification).length),
306
+ max: String(MAX_QUALITY_ATTEMPTS),
307
+ invalid: String(invalidAttempts(verification).length),
308
+ maxInvalid: String(MAX_INVALID_ATTEMPTS),
309
+ exceptions: String(exceptionAttempts(verification).length),
310
+ })}
311
+ </span>
312
+ {route !== undefined && (
313
+ <span className={css.executionTimes}>
314
+ {verification.contract.modelSource === 'inherit'
315
+ ? t('verify.judgeInherited', { model: route.provider + '/' + route.model })
316
+ : t(route.reasoningEffort === undefined || route.reasoningEffort === '' ? 'verify.judgeNoEffort' : 'verify.judge', {
317
+ model: route.provider + '/' + route.model,
318
+ ...(route.reasoningEffort === undefined ? {} : { effort: route.reasoningEffort }),
319
+ })}
320
+ </span>
321
+ )}
322
+ {verification.contract.effortFallback !== undefined && (
323
+ <span className={css.executionTimes}>
324
+ {t('verify.effortFallback', {
325
+ requested: verification.contract.effortFallback.requested,
326
+ resolved: verification.contract.effortFallback.resolved ?? t('settings.goalVerificationResolvedNoEffort'),
327
+ })}
328
+ </span>
329
+ )}
330
+ {applicabilityKey !== undefined && <span className={css.executionTimes}>{t(applicabilityKey)}</span>}
331
+ {verification.failedReason !== undefined && (
332
+ <span className={css.executionTimes}>{t('verify.finalFailure', { reason: verification.failedReason })}</span>
333
+ )}
334
+ {totals.calls > 0 && (
335
+ <span className={css.executionTimes}>
336
+ {t('verify.usage', {
337
+ calls: String(totals.calls),
338
+ input: String(totals.inputTokens),
339
+ output: String(totals.outputTokens),
340
+ reasoning: String(totals.reasoningTokens),
341
+ })}
342
+ {totals.usageIncomplete ? t('verify.usageIncomplete') : ''}
343
+ </span>
344
+ )}
345
+ {verification.attempts.length > 0 && (
346
+ <ul className={css.executionList}>
347
+ {[...verification.attempts].reverse().map(attempt => (
348
+ <AttemptRow
349
+ key={attempt.at.toString(36) + '-' + attempt.stage + '-' + String(attempt.index)}
350
+ attempt={attempt}
351
+ detailRemoved={verification.cleanup?.state === 'cleaned'}
352
+ />
353
+ ))}
354
+ </ul>
355
+ )}
356
+ {verification.cleanup !== undefined && <CleanupNotice cleanup={verification.cleanup} />}
357
+ </div>
358
+ )}
359
+ </div>
360
+ )
361
+ }
@@ -0,0 +1,208 @@
1
+ /**
2
+ * Execution model options: the picker rows built from the official
3
+ * `session/modelCatalog` reply, and the reasoning-effort derivation both
4
+ * execution-target editors read off them (the create dialog and the detail
5
+ * page share one contract here, so they cannot promise different levels).
6
+ *
7
+ * The pickers must offer each model's real reasoning levels, which only the
8
+ * catalog declares — so the reply is normalized once, here, instead of every
9
+ * picker re-reading the wire shape. The fallback discovery path carries no
10
+ * capability metadata at all; its rows stay silent about reasoning rather than
11
+ * claiming a model supports none.
12
+ *
13
+ * This module also owns the one display form a model row is shown in: the
14
+ * model name, then the provider that publishes it. Two providers may publish
15
+ * one model name, and they are two different routes, so a picker that shows
16
+ * only the name offers two identical rows. Every picker and every collapsed
17
+ * summary reads the label from here, so they cannot drift apart.
18
+ */
19
+ import type { ExecutionModelOption } from '../../core/controller.ts'
20
+ import type { TaskBoardKey } from '../locales.ts'
21
+
22
+ /** One model's declared reasoning capability, as a picker row carries it. */
23
+ type ModelReasoning = NonNullable<ExecutionModelOption['reasoning']>
24
+
25
+ /** A plain JSON object, or undefined for anything else (including arrays). */
26
+ function record(value: unknown): Record<string, unknown> | undefined {
27
+ return typeof value === 'object' && value !== null && !Array.isArray(value) ? value as Record<string, unknown> : undefined
28
+ }
29
+
30
+ /** A non-empty string, or undefined. */
31
+ function text(value: unknown): string | undefined {
32
+ return typeof value === 'string' && value !== '' ? value : undefined
33
+ }
34
+
35
+ /** The effort ids an adapter published for one model, in catalog order. */
36
+ function effortIdsOf(reasoning: Record<string, unknown>): string[] {
37
+ const efforts: string[] = []
38
+ for (const entry of Array.isArray(reasoning.efforts) ? reasoning.efforts : []) {
39
+ const id = text(record(entry)?.id)
40
+ if (id !== undefined && !efforts.includes(id)) efforts.push(id)
41
+ }
42
+ return efforts
43
+ }
44
+
45
+ /**
46
+ * What the catalog declares about one model's reasoning: a published
47
+ * `reasoning` block is what "this route reasons" means, and a model published
48
+ * without one is declared to have none. A model the reply never described at
49
+ * all is a different state, expressed by the row carrying no capability.
50
+ */
51
+ function reasoningOf(model: Record<string, unknown>): ModelReasoning {
52
+ const reasoning = record(model.reasoning)
53
+ if (reasoning === undefined) return { supported: false }
54
+ const efforts = effortIdsOf(reasoning)
55
+ return { supported: true, ...(efforts.length === 0 ? {} : { efforts }) }
56
+ }
57
+
58
+ /**
59
+ * One picker row, or undefined when the entry carries no usable id.
60
+ * @param withCapability - whether this reply declares reasoning metadata at
61
+ * all; the flat discovery list does not, so its rows stay silent about it.
62
+ */
63
+ function rowOf(model: Record<string, unknown>, provider: string | undefined, withCapability: boolean): ExecutionModelOption | undefined {
64
+ const id = text(model.id)
65
+ if (id === undefined) return undefined
66
+ const reasoning = withCapability ? reasoningOf(model) : undefined
67
+ return {
68
+ id: provider === undefined ? id : `${provider}/${id}`,
69
+ name: text(model.name) ?? id,
70
+ ...(provider === undefined ? {} : { provider }),
71
+ ...(reasoning === undefined ? {} : { reasoning }),
72
+ }
73
+ }
74
+
75
+ /**
76
+ * Normalize a `session/modelCatalog` reply into picker rows: one row per model
77
+ * of every provider group, keyed by the qualified route an execution pins.
78
+ * @param value - the raw catalog reply.
79
+ * @returns the rows, empty when the reply is unreadable.
80
+ */
81
+ export function modelOptionsFromCatalog(value: unknown): ExecutionModelOption[] {
82
+ const options: ExecutionModelOption[] = []
83
+ const groups = record(value)?.groups
84
+ for (const entry of Array.isArray(groups) ? groups : []) {
85
+ const group = record(entry)
86
+ if (group === undefined) continue
87
+ const provider = text(group.id) ?? text(group.provider)
88
+ for (const item of Array.isArray(group.models) ? group.models : []) {
89
+ const model = record(item)
90
+ if (model === undefined) continue
91
+ const row = rowOf(model, provider, true)
92
+ if (row !== undefined) options.push(row)
93
+ }
94
+ }
95
+ return options
96
+ }
97
+
98
+ /**
99
+ * Normalize the flat `llm/discoverModels` list into picker rows. That reply
100
+ * names models only, so every row leaves the reasoning capability unknown.
101
+ * @param value - the raw discovery list.
102
+ * @returns the rows, empty when the list is unreadable.
103
+ */
104
+ export function modelOptionsFromDiscoveredModels(value: unknown): ExecutionModelOption[] {
105
+ const options: ExecutionModelOption[] = []
106
+ for (const item of Array.isArray(value) ? value : []) {
107
+ const model = record(item)
108
+ if (model === undefined) continue
109
+ const row = rowOf(model, undefined, false)
110
+ if (row !== undefined) options.push(row)
111
+ }
112
+ return options
113
+ }
114
+
115
+ /**
116
+ * The display form of one model row: the model name first, then the provider
117
+ * that publishes it, joined by " · ".
118
+ *
119
+ * Two providers publishing one model name are two different routes, so the
120
+ * provider belongs in the label — otherwise the picker offers two identical
121
+ * rows and the operator cannot tell which route a card would pin. A row
122
+ * without a provider (the flat discovery fallback names models only) keeps
123
+ * its bare name, and a row that carries no name of its own shows the model
124
+ * part of its own qualified route, so the provider is never printed twice.
125
+ * @param model - the roster row.
126
+ * @returns the label every model picker row and every collapsed summary shows.
127
+ */
128
+ export function modelDisplayLabel(model: ExecutionModelOption): string {
129
+ const provider = model.provider === undefined || model.provider === '' ? undefined : model.provider
130
+ const name = model.name !== undefined && model.name !== ''
131
+ ? model.name
132
+ : provider !== undefined && model.id.startsWith(provider + '/')
133
+ ? model.id.slice(provider.length + 1)
134
+ : model.id
135
+ if (provider === undefined) return name
136
+ return name + ' · ' + provider
137
+ }
138
+
139
+ /**
140
+ * The picker rows of a model roster: the qualified `provider/model` route as
141
+ * the value a pin stores, and the shared display form as the label, so two
142
+ * providers offering one model name stay distinguishable.
143
+ * @param models - the roster rows.
144
+ * @returns the choice rows, in roster order.
145
+ */
146
+ export function modelChoiceRows(models: readonly ExecutionModelOption[]): Array<{ value: string; label: string }> {
147
+ return models.map(model => ({
148
+ value: model.id,
149
+ label: modelDisplayLabel(model),
150
+ }))
151
+ }
152
+
153
+ /**
154
+ * The capability row the roster publishes for one model route.
155
+ * @returns undefined when no model is pinned, or the roster does not describe
156
+ * the pinned one — an unknown model is not the same as a model without
157
+ * reasoning.
158
+ */
159
+ export function reasoningOfModel(
160
+ models: readonly ExecutionModelOption[],
161
+ modelId: string,
162
+ ): ExecutionModelOption['reasoning'] | undefined {
163
+ if (modelId === '') return undefined
164
+ return models.find(item => item.id === modelId)?.reasoning
165
+ }
166
+
167
+ /**
168
+ * The effort ids the picker offers for a model, in catalog order.
169
+ * @returns an empty list when the model is unpinned, unknown, declares no
170
+ * reasoning, or publishes no selectable level.
171
+ */
172
+ export function reasoningEffortsFor(models: readonly ExecutionModelOption[], modelId: string): string[] {
173
+ const reasoning = reasoningOfModel(models, modelId)
174
+ return reasoning?.supported === true ? [...reasoning.efforts ?? []] : []
175
+ }
176
+
177
+ /** Whether the effort picker may be operated: a pinned model with declared, selectable levels. */
178
+ export function reasoningPickerEnabled(models: readonly ExecutionModelOption[], modelId: string): boolean {
179
+ return reasoningEffortsFor(models, modelId).length > 0
180
+ }
181
+
182
+ /**
183
+ * The effort to keep when the picked model changes. Only a model that declares
184
+ * its levels can invalidate one: a model the roster cannot describe keeps the
185
+ * stored value, because the roster has no grounds to call it invalid.
186
+ * @param effort - the effort currently stored/selected ('' = follow the default).
187
+ * @returns the effort to keep.
188
+ */
189
+ export function reconcileReasoningEffort(
190
+ models: readonly ExecutionModelOption[],
191
+ modelId: string,
192
+ effort: string,
193
+ ): string {
194
+ if (effort === '') return ''
195
+ const reasoning = reasoningOfModel(models, modelId)
196
+ if (reasoning === undefined) return modelId === '' ? '' : effort
197
+ return reasoning.efforts?.includes(effort) === true ? effort : ''
198
+ }
199
+
200
+ /**
201
+ * The copy explaining why the picker is in its current state. One lookup for
202
+ * both editors, so the create dialog and the detail page never drift apart.
203
+ */
204
+ export function reasoningHintKey(models: readonly ExecutionModelOption[], modelId: string): TaskBoardKey {
205
+ if (modelId === '') return 'exec.reasoning.hint.pickModel'
206
+ if (reasoningOfModel(models, modelId) === undefined) return 'exec.reasoning.hint.unknownModel'
207
+ return reasoningPickerEnabled(models, modelId) ? 'exec.reasoning.hint.inherit' : 'exec.reasoning.hint.noEfforts'
208
+ }
@@ -42,3 +42,35 @@ export function inheritPresetLabel(presets: readonly ExecutionPresetOption[]): s
42
42
  if (fallback === undefined) return t('exec.mode.inherit')
43
43
  return t('exec.mode.inheritWith', { preset: presetLabel(fallback) })
44
44
  }
45
+
46
+ /** One preset row a picker renders: the stored id, its label, and whether it may be picked. */
47
+ export interface PresetChoiceRow {
48
+ /** The value a pin stores. */
49
+ id: string
50
+ /** Display label, already carrying the default and unavailable suffixes. */
51
+ label: string
52
+ /** True when the preset cannot compose a session: the row is shown but not selectable. */
53
+ disabled: boolean
54
+ }
55
+
56
+ /**
57
+ * The picker rows of one roster, split into the built-in and the user presets.
58
+ * Both pickers render these rows — the create dialog's mode select and the
59
+ * settings card's default-preset field — so their wording and their
60
+ * unavailable rows cannot drift apart.
61
+ * @param presets - the roster options.
62
+ * @returns one row list per group, in roster order.
63
+ */
64
+ export function presetChoiceRows(presets: readonly ExecutionPresetOption[]): { builtin: PresetChoiceRow[]; custom: PresetChoiceRow[] } {
65
+ const row = (preset: ExecutionPresetOption): PresetChoiceRow => ({
66
+ id: preset.id,
67
+ label: presetLabel(preset)
68
+ + (preset.isDefault ? t('exec.mode.defaultSuffix') : '')
69
+ + (preset.broken !== undefined ? t('exec.mode.brokenSuffix') : ''),
70
+ disabled: preset.broken !== undefined,
71
+ })
72
+ return {
73
+ builtin: presets.filter(preset => isBuiltinPreset(preset.id)).map(row),
74
+ custom: presets.filter(preset => !isBuiltinPreset(preset.id)).map(row),
75
+ }
76
+ }
@@ -0,0 +1,58 @@
1
+ /**
2
+ * The agent-preset roster the execution-target pickers read: one read of the
3
+ * generated api-remotes face, and its normalization into the option rows the
4
+ * board controller and the settings card's new-card-defaults topic both
5
+ * consume.
6
+ *
7
+ * The roster is a runtime fact of the deployment, not ledger state. The
8
+ * namespace mounts with the official api-remotes assembly, so the read itself
9
+ * is wired through a scoped inject at the call site (see src/client/index.ts);
10
+ * this module owns only the shape both consumers agree on, so neither has to
11
+ * know how the wire face answers.
12
+ */
13
+ import type { ClientRemote } from '@deepseek-ai/dsh-api-remotes/client'
14
+ import type { ExecutionPresetOption } from '../../core/controller.ts'
15
+
16
+ /** The generated Remote namespace the mode pickers read their roster from. */
17
+ export type PresetRemote = ClientRemote['agentPresets']
18
+
19
+ /** One agent-preset row the wire face answers with. */
20
+ export interface PresetRosterRow {
21
+ id: string
22
+ name?: string
23
+ description?: string
24
+ /** Why this preset cannot compose a session; absent when it can. */
25
+ broken?: string
26
+ isDefault: boolean
27
+ }
28
+
29
+ /**
30
+ * Read the agent-preset roster of one deployment. The caller passes the
31
+ * namespace resolved inside its scoped inject, so a host that serves no such
32
+ * namespace never reaches here; a host that serves it answers `ok: false`
33
+ * instead, which leaves the caller's options untouched.
34
+ * @param remote - the `remote.agentPresets` namespace.
35
+ * @returns the roster, or a failed read the caller ignores.
36
+ */
37
+ export async function readPresetRoster(remote: PresetRemote): Promise<{ ok: boolean; presets: readonly PresetRosterRow[] }> {
38
+ const response = await remote.list()
39
+ if (!response.ok) return { ok: false, presets: [] }
40
+ return { ok: true, presets: response.value.presets }
41
+ }
42
+
43
+ /**
44
+ * Normalize one roster into the picker rows the UI consumes. A preset that
45
+ * cannot compose a session keeps its `broken` reason: the pickers show it and
46
+ * disable it, so a missing preset never looks like a missing roster.
47
+ * @param presets - the roster rows.
48
+ * @returns the picker options.
49
+ */
50
+ export function presetOptionsFromRoster(presets: readonly PresetRosterRow[]): ExecutionPresetOption[] {
51
+ return presets.map(preset => ({
52
+ id: preset.id,
53
+ name: preset.name,
54
+ description: preset.description,
55
+ broken: preset.broken,
56
+ isDefault: preset.isDefault,
57
+ }))
58
+ }