@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
@@ -0,0 +1,132 @@
1
+ /**
2
+ * New-card defaults: the execution targets a freshly created card starts from,
3
+ * and how they combine with what the caller picked and with the card a subtask
4
+ * or a duplicate is created from.
5
+ *
6
+ * Framework-free (no cordis, no runtime imports) because BOTH halves compile
7
+ * it: the Host resolves the seed when it writes the card, and the browser
8
+ * resolves the same seed to open the new-task dialog on it. One pure function
9
+ * is the only place the rules live, so the dialog and the ledger cannot drift.
10
+ *
11
+ * Every target is resolved in ONE order: what the caller picked wins over the
12
+ * value carried over from the card this one is created from, which wins over
13
+ * the board's new-card defaults, and a target nothing supplies stays blank
14
+ * ("no pin, resolved at run time"). A duplicate is a copy of its source and a
15
+ * subtask is derived from its parent, so both keep the source's own pins and
16
+ * fill only the fields that source left unset.
17
+ *
18
+ * The permission of a PARENT is the one exception: it never participates. The
19
+ * permission is not copied onto a card at creation — doing so would also have
20
+ * to copy the parent's human confirmation to stay runnable, and a detached
21
+ * child would keep both, so one confirmed parent would mint unbounded confirmed
22
+ * elevated roots. It is resolved along the ancestor chain at launch instead
23
+ * (core/subtask.ts), which is what makes detaching remove the inheritance by
24
+ * construction. A duplicate is not a hierarchy link, so it copies the
25
+ * permission like every other target. The board's own default permission is not
26
+ * a parent binding either and does apply to a subtask; it only pre-fills the
27
+ * card, and a value above the session baseline still needs a human
28
+ * confirmation before the card may run.
29
+ *
30
+ * The reasoning level is bound to the model route it was chosen for and never
31
+ * crosses to another one:
32
+ *
33
+ * - a level the caller picked is used as it stands;
34
+ * - a caller that pinned a model of its own inherits no level at all, not
35
+ * even one the same model happens to carry on the source card;
36
+ * - otherwise the source card's level travels with the source value it was
37
+ * stored on, exactly as the card's own model/level pair does, and wins over
38
+ * the board default level, so a board that configures none behaves exactly
39
+ * as the create path always has;
40
+ * - a board default level applies only while the card's final model IS the
41
+ * configured default model, and a blank default model makes it inert —
42
+ * a level the resolved model does not declare could only be refused by
43
+ * model selection at run time.
44
+ */
45
+ import type { TaskRecord } from './tasks.ts'
46
+
47
+ /** The board's configured new-card defaults; a blank target means "not set". */
48
+ export interface CardDefaults {
49
+ /** Agent preset a new card starts from. */
50
+ mode?: string
51
+ /** Permission a new card starts from. */
52
+ permission?: string
53
+ /** Model a new card starts from. */
54
+ model?: string
55
+ /** Reasoning level a new card starts from, for the model above. */
56
+ reasoningEffort?: string
57
+ }
58
+
59
+ /** The card a new one is created from, and how it is derived from it. */
60
+ export interface CardTargetSource {
61
+ /** A copy of the source card, or a subtask of it. */
62
+ kind: 'duplicate' | 'parent'
63
+ /** The source card's execution targets. */
64
+ task: Pick<TaskRecord, 'mode' | 'permission' | 'model' | 'reasoningEffort'>
65
+ }
66
+
67
+ /** The resolved targets of the card about to be created; blank means "unset". */
68
+ export interface CardTargetSeed {
69
+ mode: string
70
+ permission: string
71
+ model: string
72
+ reasoningEffort: string
73
+ }
74
+
75
+ /** Trim one optional target: blank text means "not set", like every stored pin. */
76
+ function textOf(value: string | undefined): string {
77
+ return value?.trim() ?? ''
78
+ }
79
+
80
+ /**
81
+ * Resolve the execution targets a new card starts from.
82
+ * @param defaults - the board's configured new-card defaults, if any.
83
+ * @param source - the card this one is created from (a duplicate or a parent), if any.
84
+ * @param picked - what the caller chose explicitly; a non-blank value wins.
85
+ * @returns the four targets, blank where nothing supplies a value.
86
+ */
87
+ export function resolveCardTargets(
88
+ defaults: CardDefaults | undefined,
89
+ source: CardTargetSource | undefined,
90
+ picked?: Partial<CardTargetSeed>,
91
+ ): CardTargetSeed {
92
+ const defaultMode = textOf(defaults?.mode)
93
+ const defaultPermission = textOf(defaults?.permission)
94
+ const defaultModel = textOf(defaults?.model)
95
+ // A default level with no default model of its own names no route to bind to
96
+ // (only a hand-edited settings document can express that), so it is inert.
97
+ const defaultEffort = defaultModel === '' ? '' : textOf(defaults?.reasoningEffort)
98
+ const chosen = {
99
+ mode: textOf(picked?.mode),
100
+ permission: textOf(picked?.permission),
101
+ model: textOf(picked?.model),
102
+ reasoningEffort: textOf(picked?.reasoningEffort),
103
+ }
104
+ const copied = source === undefined ? undefined : {
105
+ mode: textOf(source.task.mode),
106
+ permission: textOf(source.task.permission),
107
+ model: textOf(source.task.model),
108
+ reasoningEffort: textOf(source.task.reasoningEffort),
109
+ }
110
+
111
+ /** The value carried over from the source card, or the board default. */
112
+ const inherited = (key: 'mode' | 'permission' | 'model'): string => {
113
+ const fallback = key === 'mode' ? defaultMode : key === 'model' ? defaultModel : defaultPermission
114
+ // A parent's binding never travels; a duplicate's does (it is not a link).
115
+ if (copied === undefined || (key === 'permission' && source?.kind === 'parent')) return fallback
116
+ return copied[key] === '' ? fallback : copied[key]
117
+ }
118
+
119
+ const mode = chosen.mode === '' ? inherited('mode') : chosen.mode
120
+ const permission = chosen.permission === '' ? inherited('permission') : chosen.permission
121
+ const model = chosen.model === '' ? inherited('model') : chosen.model
122
+
123
+ let reasoningEffort = chosen.reasoningEffort
124
+ if (reasoningEffort === '' && chosen.model === '') {
125
+ // The caller pinned no model of its own, so the level follows the source
126
+ // pair first and the board default second.
127
+ const sourced = copied === undefined ? '' : copied.reasoningEffort
128
+ reasoningEffort = sourced !== '' ? sourced : (model !== '' && model === defaultModel ? defaultEffort : '')
129
+ }
130
+
131
+ return { mode, permission, model, reasoningEffort }
132
+ }
@@ -13,6 +13,7 @@
13
13
  */
14
14
  import type { TaskStore } from './store.ts'
15
15
  import { hasOpenExecution, withStatus, type NewTaskInput, type TaskRecord, type TaskStatus } from './tasks.ts'
16
+ import type { TaskAttachment, TaskAttachmentKind } from './attachment.ts'
16
17
  import { applyArchiveTask, applyRestoreTask } from './use-cases/task-archive.ts'
17
18
  import { applyCreateTask } from './use-cases/task-create.ts'
18
19
  import { applyDeleteTask } from './use-cases/task-delete.ts'
@@ -31,6 +32,7 @@ import type {
31
32
  } from '../protocol.ts'
32
33
  import type {
33
34
  TaskBoardExtensionActionRequest,
35
+ TaskBoardGroupingSelector,
34
36
  TaskBoardVisibilityPredicate,
35
37
  } from './extension.ts'
36
38
 
@@ -48,6 +50,12 @@ export interface TaskBoardTransport {
48
50
  * that cannot parse simply omits it, and the form hides the section.
49
51
  */
50
52
  parseDraft?(request: TaskBoardParseRequest, signal?: AbortSignal): Promise<TaskBoardParseDraft>
53
+ /**
54
+ * Upload one file or image into the Host's attachment storage. Optional: a
55
+ * deployment that serves no attachment storage omits it, and the form then
56
+ * refuses to stage an attachment.
57
+ */
58
+ uploadAttachment?(file: File, kind: TaskAttachmentKind): Promise<TaskAttachment>
51
59
  }
52
60
 
53
61
  /**
@@ -127,6 +135,17 @@ export interface ExecutionModelOption {
127
135
  name?: string
128
136
  label?: string
129
137
  provider?: string
138
+ /**
139
+ * Reasoning metadata the adapter declares for this exact route. An effort
140
+ * picker is offered only while `supported`, and its choices are `efforts` —
141
+ * the ids the target model really accepts, so the UI never offers (or keeps)
142
+ * a level the model would reject. Absent means the deployment published no
143
+ * capability for this model; the card value is then left untouched.
144
+ */
145
+ reasoning?: {
146
+ supported: boolean
147
+ efforts?: readonly string[]
148
+ }
130
149
  }
131
150
 
132
151
  /** The execution-target option sets the UI feeds into the controller. */
@@ -141,7 +160,7 @@ export interface ExecutionOptionsSnapshot {
141
160
  * (revision/scheduler/power); a full snapshot also carries the deployment
142
161
  * constants the UI reads (session default permission, subtask depth).
143
162
  */
144
- export type HostMirror = Pick<TaskBoardSnapshot, 'revision' | 'scheduler' | 'power' | 'sessionDefaultPermission' | 'maxSubtaskDepth' | 'teamRunAvailable' | 'goalRunEnabled' | 'extensions'>
163
+ export type HostMirror = Pick<TaskBoardSnapshot, 'revision' | 'scheduler' | 'power' | 'sessionDefaultPermission' | 'maxSubtaskDepth' | 'goalRunEnabled' | 'cardDefaults' | 'extensions' | 'attachmentLimits'>
145
164
 
146
165
  /** Immutable controller snapshot for UI subscriptions. */
147
166
  export interface ControllerSnapshot {
@@ -166,6 +185,8 @@ export interface ControllerSnapshot {
166
185
  * hand-built snapshot (tests, a shell-less composition) defaults to visible.
167
186
  */
168
187
  visibility?: readonly TaskBoardVisibilityPredicate[]
188
+ /** Provider source-group selectors, in registration order; browser-only functions. */
189
+ grouping?: readonly TaskBoardGroupingSelector[]
169
190
  /** Read-only summaries published by running extensions, keyed by extension id. */
170
191
  extensions?: Readonly<Record<string, unknown>>
171
192
  }
@@ -217,6 +238,8 @@ export class BoardController {
217
238
  private hostState: HostMirror | undefined
218
239
  /** Provider visibility predicates (immutable array; replaced on change). */
219
240
  private visibility: readonly TaskBoardVisibilityPredicate[] = []
241
+ /** Provider source-group selectors (immutable array; replaced on change). */
242
+ private grouping: readonly TaskBoardGroupingSelector[] = []
220
243
  private remoteSubscribed = false
221
244
  private remoteInitialization: Promise<boolean> | undefined
222
245
 
@@ -268,6 +291,7 @@ export class BoardController {
268
291
  ...(this.transportError === undefined ? {} : { transportError: this.transportError }),
269
292
  ...(this.hostState === undefined ? {} : { host: this.hostState }),
270
293
  visibility: this.visibility,
294
+ grouping: this.grouping,
271
295
  ...(this.hostState?.extensions === undefined ? {} : { extensions: this.hostState.extensions }),
272
296
  }
273
297
  }
@@ -287,6 +311,18 @@ export class BoardController {
287
311
  }
288
312
  }
289
313
 
314
+ /** Register one source-group selector; registration order breaks ownership ties. */
315
+ registerGrouping(selector: TaskBoardGroupingSelector): () => void {
316
+ this.grouping = [...this.grouping, selector]
317
+ this.notify()
318
+ return () => {
319
+ const next = this.grouping.filter(candidate => candidate !== selector)
320
+ if (next.length === this.grouping.length) return
321
+ this.grouping = next
322
+ this.notify()
323
+ }
324
+ }
325
+
290
326
  /**
291
327
  * Deliver one provider action through the board's same-origin channel. A
292
328
  * board without a Host transport (the legacy in-memory path) refuses it.
@@ -318,6 +354,22 @@ export class BoardController {
318
354
  return await this.initializeRemote()
319
355
  }
320
356
 
357
+ /**
358
+ * Re-read the authoritative Host snapshot.
359
+ *
360
+ * The board's volatile deployment configuration — the new-card defaults among
361
+ * it — is republished the moment the settings document is written, but the SSE
362
+ * frame that republish emits carries the value as of BEFORE the write (the
363
+ * loader hands the update to the fiber while the new document is not yet
364
+ * visible to it), so a mirror that followed frames alone would stay one edit
365
+ * behind and the create dialog would prefill from the previous defaults for
366
+ * the rest of the session. The surface that owns the write asks for the
367
+ * snapshot again instead of trusting the frame.
368
+ */
369
+ refreshHostState(): void {
370
+ void this.refreshRemote()
371
+ }
372
+
321
373
  // --- view state -------------------------------------------------------------
322
374
 
323
375
  /**
@@ -407,7 +459,7 @@ export class BoardController {
407
459
 
408
460
  createTask(input: NewTaskInput): TaskRecord | undefined {
409
461
  const id = this.uuid()
410
- const { task, tasks } = applyCreateTask(this.tasks, input, this.now(), id, this.mirrorDepth())
462
+ const { task, tasks } = applyCreateTask(this.tasks, input, this.now(), id, this.mirrorDepth(), undefined, this.hostState?.cardDefaults)
411
463
  if (task === undefined) return undefined
412
464
  this.tasks = [...tasks]
413
465
  this.persistAndNotify()
@@ -421,7 +473,7 @@ export class BoardController {
421
473
  // The preview must obey the SAME lineage gate the Host will: a browser-side
422
474
  // default of one level would reject a legal subtask-of-subtask before the
423
475
  // request is ever sent.
424
- const preview = applyCreateTask(this.tasks, input, this.now(), id, this.mirrorDepth()).task
476
+ const preview = applyCreateTask(this.tasks, input, this.now(), id, this.mirrorDepth(), undefined, this.hostState?.cardDefaults).task
425
477
  if (preview === undefined) return undefined
426
478
  return await this.commitRemote({ kind: 'create', id, input }, id)
427
479
  ? this.tasks.find(task => task.id === id)
@@ -485,6 +537,23 @@ export class BoardController {
485
537
  return await parse.call(transport, request, signal)
486
538
  }
487
539
 
540
+ /**
541
+ * Upload one attachment into the Host's attachment storage.
542
+ *
543
+ * The form calls this when the card is SAVED, never when a file is picked:
544
+ * a staged file is a local preview until the card is really saved.
545
+ * @param file - the picked file.
546
+ * @param kind - whether the file is stored as an image or verbatim.
547
+ * @returns the metadata the Host computed, or undefined when this
548
+ * deployment serves no attachment storage.
549
+ */
550
+ async uploadAttachment(file: File, kind: TaskAttachmentKind): Promise<TaskAttachment | undefined> {
551
+ const transport = this.deps.transport
552
+ const upload = transport?.uploadAttachment
553
+ if (transport === undefined || upload === undefined) return undefined
554
+ return await upload.call(transport, file, kind)
555
+ }
556
+
488
557
  moveTask(id: string, status: TaskStatus): void {
489
558
  if (this.deps.transport !== undefined) {
490
559
  void this.commitRemote({ kind: 'move', taskId: id, status }, id)
@@ -804,28 +873,38 @@ export class BoardController {
804
873
  }
805
874
 
806
875
  /**
807
- * Project a Host snapshot onto the browser's mirror. SSE frames and partial
808
- * snapshots carry only the volatile subset (revision/scheduler/power), so the
809
- * deployment constants the UI reads — the session-default permission the
810
- * confirmation banner compares against and the subtask depth limit — are
811
- * carried over from the last full snapshot instead of being dropped by a
812
- * heartbeat frame.
876
+ * Project a Host snapshot onto the browser's mirror. Every snapshot the
877
+ * transport serves is a full document (bootstrap/state/action all answer
878
+ * `TaskBoardHostService.snapshot()`), so the deployment constants the UI reads
879
+ * — the session-default permission the confirmation banner compares against,
880
+ * the subtask depth limit, the platform switches and the extensions a provider
881
+ * published — are taken as published, carried over only where the snapshot
882
+ * itself omits the key.
813
883
  */
814
884
  private mirrorOf(snapshot: TaskBoardSnapshot): HostMirror {
815
885
  const sessionDefaultPermission = snapshot.sessionDefaultPermission ?? this.hostState?.sessionDefaultPermission
816
886
  const maxSubtaskDepth = snapshot.maxSubtaskDepth ?? this.hostState?.maxSubtaskDepth
817
- const teamRunAvailable = snapshot.teamRunAvailable ?? this.hostState?.teamRunAvailable
818
887
  const goalRunEnabled = snapshot.goalRunEnabled ?? this.hostState?.goalRunEnabled
888
+ // The new-card defaults are NOT carried over: the Host publishes a target
889
+ // nothing configures by omitting it (protocol.ts states that explicitly), so
890
+ // an absent key means "this deployment configures none". Carrying the last
891
+ // value over would keep a CLEARED default alive in the create dialog, which
892
+ // is the mirror image of the staleness this key is re-read for.
893
+ const cardDefaults = snapshot.cardDefaults
819
894
  const extensions = snapshot.extensions ?? this.hostState?.extensions
895
+ // The attachment limits are carried over: a deployment that lowers them
896
+ // must keep the browser's refusal in step until the next snapshot.
897
+ const attachmentLimits = snapshot.attachmentLimits ?? this.hostState?.attachmentLimits
820
898
  return {
821
899
  revision: snapshot.revision,
822
900
  scheduler: snapshot.scheduler,
823
901
  power: snapshot.power,
824
902
  ...(sessionDefaultPermission === undefined ? {} : { sessionDefaultPermission }),
825
903
  ...(maxSubtaskDepth === undefined ? {} : { maxSubtaskDepth }),
826
- ...(teamRunAvailable === undefined ? {} : { teamRunAvailable }),
827
904
  ...(goalRunEnabled === undefined ? {} : { goalRunEnabled }),
905
+ ...(cardDefaults === undefined ? {} : { cardDefaults }),
828
906
  ...(extensions === undefined ? {} : { extensions }),
907
+ ...(attachmentLimits === undefined ? {} : { attachmentLimits }),
829
908
  }
830
909
  }
831
910
 
@@ -0,0 +1,96 @@
1
+ /**
2
+ * What one execution left behind: the text of its last assistant message,
3
+ * recorded on the execution record next to the verdict it belongs to.
4
+ *
5
+ * A settled execution used to carry only a verdict, so a parent card could see
6
+ * that a subtask succeeded without ever seeing what it produced, and had to
7
+ * guess or redo the work. The card's own content cannot answer that: card
8
+ * content is the plan and freezes at the first execution
9
+ * (`canEditTaskContent`), so the closing words of a run are recorded on the
10
+ * execution record instead.
11
+ *
12
+ * Pure (no cordis, no runtime imports) so the settlement path is unit-testable
13
+ * without a session, and so a text-less run degrades to "no field" rather than
14
+ * to an empty string.
15
+ */
16
+ import { EXECUTION_SUMMARY_LIMIT, type ExecutionSummary } from './tasks.ts'
17
+
18
+ /** Structural view of one session event, as both readers expose it. */
19
+ export interface SummaryEvent {
20
+ type?: unknown
21
+ seq?: unknown
22
+ time?: unknown
23
+ data?: unknown
24
+ }
25
+
26
+ /** One rendered content block of an assistant message, or '' when it has no prose. */
27
+ function blockProse(block: unknown): string {
28
+ if (typeof block !== 'object' || block === null) return ''
29
+ const row = block as Record<string, unknown>
30
+ // Only prose: reasoning and tool traffic are the acceptance evidence's job,
31
+ // and a summary that opened with a tool call would bury the conclusion.
32
+ return row.type === 'text' && typeof row.text === 'string' ? row.text : ''
33
+ }
34
+
35
+ /** The assistant's own prose of one message: its text blocks joined and trimmed. */
36
+ function messageProse(content: unknown): string {
37
+ if (!Array.isArray(content)) return ''
38
+ return content.map(blockProse).filter(part => part !== '').join('\n').trim()
39
+ }
40
+
41
+ /**
42
+ * Bound one summary, keeping its tail: the closing paragraphs carry the
43
+ * conclusion a reader is after, and the omitted opening is announced instead of
44
+ * silently dropped. Mirrors the evidence reader's tail bound.
45
+ */
46
+ export function truncateExecutionSummary(text: string, limit = EXECUTION_SUMMARY_LIMIT): string {
47
+ if (text.length <= limit) return text
48
+ const notice = '[truncated ' + String(text.length - limit) + ' chars] '
49
+ return notice.length >= limit ? text.slice(-limit) : notice + text.slice(-(limit - notice.length))
50
+ }
51
+
52
+ /**
53
+ * The summary one execution's own events support.
54
+ *
55
+ * Only events at or after `startedAt` belong to this run: a reused session
56
+ * carries the history of earlier executions, which must not be reported as this
57
+ * one's output. The last assistant message WITH prose wins — a trailing
58
+ * tool-call or reasoning-only message has nothing to leave behind, so the reader
59
+ * walks back to the last one that speaks.
60
+ * @param events - the session events the inspection already read.
61
+ * @param startedAt - the execution's start instant (ms epoch); 0 means "all".
62
+ * @returns the bounded summary with the seq it came from, or undefined when the
63
+ * run left no usable text.
64
+ */
65
+ export function executionSummaryOf(events: readonly SummaryEvent[], startedAt: number): ExecutionSummary | undefined {
66
+ const own = events
67
+ .filter(event => typeof event.time !== 'number' || startedAt <= 0 || event.time >= startedAt)
68
+ .filter(event => event.type === 'assistant/message' && typeof event.seq === 'number')
69
+ .sort((a, b) => (a.seq as number) - (b.seq as number))
70
+ for (let index = own.length - 1; index >= 0; index -= 1) {
71
+ const event = own[index]
72
+ const data = typeof event.data === 'object' && event.data !== null ? event.data as Record<string, unknown> : {}
73
+ const message = typeof data.message === 'object' && data.message !== null ? data.message as Record<string, unknown> : {}
74
+ const text = messageProse(message.content)
75
+ if (text === '') continue
76
+ return { text: truncateExecutionSummary(text), seq: event.seq as number }
77
+ }
78
+ return undefined
79
+ }
80
+
81
+ /**
82
+ * Repair one persisted or reported summary.
83
+ *
84
+ * A summary is informational, so an unreadable one is dropped on its own rather
85
+ * than costing the execution (or the task row) it hangs on. A hand-edited
86
+ * overlong text is bounded on the way in, so no reader ever holds more than the
87
+ * limit.
88
+ */
89
+ export function normalizeExecutionSummary(value: unknown): ExecutionSummary | undefined {
90
+ if (typeof value !== 'object' || value === null) return undefined
91
+ const row = value as Record<string, unknown>
92
+ if (typeof row.text !== 'string' || typeof row.seq !== 'number' || !Number.isFinite(row.seq)) return undefined
93
+ const text = row.text.trim()
94
+ if (text === '') return undefined
95
+ return { text: truncateExecutionSummary(text), seq: row.seq }
96
+ }
@@ -12,6 +12,7 @@
12
12
  * @module dsh-task-board/core/extension
13
13
  */
14
14
  import type { ToolDefinition } from '@deepseek-ai/dsh-tools'
15
+ import type { TaskBoardAction, TaskBoardSnapshot, TaskBoardVerificationOptions } from '../protocol.ts'
15
16
  import type { ExecutionOutcome, TaskRecord, TaskStatus } from './tasks.ts'
16
17
 
17
18
  /** Cordis service name the host and browser halves each publish. */
@@ -46,6 +47,14 @@ export const TASK_BOARD_EXTENSION_SEATS: readonly string[] = [
46
47
  */
47
48
  export const TASK_BOARD_PAYLOAD_LIMIT_BYTES = 64 * 1024
48
49
 
50
+ /**
51
+ * Largest accepted free text a provider pushes into an execution, in
52
+ * characters: one follow-up message, or one set of rework instructions. Both
53
+ * reach a model as user input, so the bound keeps a single provider call from
54
+ * becoming an unbounded context injection.
55
+ */
56
+ export const TASK_BOARD_MESSAGE_MAX_LENGTH = 4_000
57
+
49
58
  /** Depth beyond which a payload is refused instead of walked. */
50
59
  const PAYLOAD_DEPTH_LIMIT = 64
51
60
 
@@ -160,6 +169,26 @@ export interface TaskBoardTaskDraft {
160
169
  * no reason to know better pins nothing.
161
170
  */
162
171
  workspaceId?: string
172
+ /**
173
+ * Agent preset the created card pins as its execution composition. Absent
174
+ * pins nothing and leaves the board's own resolution in charge. The value is
175
+ * forwarded to the board's creation path unchanged, so a preset this
176
+ * deployment does not register fails the RUN closed, exactly as it does for a
177
+ * card created anywhere else.
178
+ */
179
+ mode?: string
180
+ /**
181
+ * Model the created card pins, in `provider/model` form — the same field
182
+ * `task_board_create` takes. Resolved against the host catalog at launch, so
183
+ * an unknown route is a run-time answer, not a creation-time one.
184
+ */
185
+ model?: string
186
+ /**
187
+ * Reasoning level for the pinned {@link model}. It travels with the model it
188
+ * was chosen for: the board never applies a level to a route that does not
189
+ * declare it.
190
+ */
191
+ reasoningEffort?: string
163
192
  }
164
193
 
165
194
  /** Options of {@link TaskBoardTasksFace.create}. */
@@ -200,6 +229,42 @@ export interface TaskBoardTasksFace {
200
229
  setStatus(taskId: string, status: TaskStatus, initiator?: string): void
201
230
  /** Every task carrying this extension's payload. */
202
231
  linked(): readonly TaskBoardLinkedTask[]
232
+ /**
233
+ * Run a card that already executed again — in its ORIGINAL session — with
234
+ * `instructions` carried as this run's additional input, which is how a
235
+ * reviewer sends work back rather than asking for a fresh attempt. The
236
+ * instructions are recorded on the execution the request opens, so the run
237
+ * history says why that run exists.
238
+ *
239
+ * The request passes through every run gate the board already has — the
240
+ * running lock, the permission confirmation, the acceptance contract and the
241
+ * spend cap — and it never rewrites the card: an executed card's frozen
242
+ * title, description and prompt stay exactly what ran (see
243
+ * {@link TaskBoardTasksFace.patchContent}). A card that never executed, or
244
+ * whose session cannot be continued, is refused instead of quietly starting a
245
+ * conversation the caller never saw.
246
+ *
247
+ * Optional, like {@link TaskBoardExtensionHost.sessions}: the contract
248
+ * version stays 1, so a provider checks the face before using it.
249
+ */
250
+ rework?(taskId: string, instructions: string, initiator?: string): void
251
+ }
252
+
253
+ /**
254
+ * Execution-session face: what a provider delivers INTO a run the board
255
+ * already executed or is executing now.
256
+ */
257
+ export interface TaskBoardSessionsFace {
258
+ /**
259
+ * Queue one follow-up user message into the session of the card's current
260
+ * execution, or of its most recent one when no execution is open.
261
+ *
262
+ * The message is an ordinary user turn queued behind whatever that session is
263
+ * doing; it re-asserts nothing, so the execution's permission, model and
264
+ * preset stay the ones the run froze. A card that never executed, an archived
265
+ * card, and a session the host no longer reaches are refused.
266
+ */
267
+ followUp(taskId: string, text: string): Promise<void>
203
268
  }
204
269
 
205
270
  /** Storage face for one extension's own payload on a task. */
@@ -253,6 +318,12 @@ export interface TaskBoardEventFace {
253
318
  */
254
319
  export interface TaskBoardExtensionHost {
255
320
  tasks: TaskBoardTasksFace
321
+ /**
322
+ * Delivery into a card's execution session. Optional in the contract on
323
+ * purpose: the API version stays 1, so a provider built against this revision
324
+ * probes the face and keeps working against a board that serves none.
325
+ */
326
+ sessions?: TaskBoardSessionsFace
256
327
  integration: TaskBoardIntegrationFace
257
328
  events: TaskBoardEventFace
258
329
  /**
@@ -293,6 +364,17 @@ export interface TaskBoardClientMirror {
293
364
  /** Whether a task should be shown on the board; false hides it. */
294
365
  export type TaskBoardVisibilityPredicate = (task: TaskRecord) => boolean
295
366
 
367
+ /** Generic source bucket a provider assigns to one card. */
368
+ export interface TaskBoardSourceGroup {
369
+ /** Stable, provider-namespaced identity used for ordering and fold persistence. */
370
+ id: string
371
+ /** Full human-readable source label, such as an owner/repository pair. */
372
+ label: string
373
+ }
374
+
375
+ /** Return a card's source group, or undefined when this provider does not own it. */
376
+ export type TaskBoardGroupingSelector = (task: TaskRecord) => TaskBoardSourceGroup | undefined
377
+
296
378
  /**
297
379
  * Client capability face the board's browser half provides. A provider's
298
380
  * browser half resolves it from the shared cordis service name; it never
@@ -303,6 +385,11 @@ export interface TaskBoardClientFace {
303
385
  dispatch(request: TaskBoardExtensionActionRequest): Promise<boolean>
304
386
  /** Register one card visibility predicate; the returned disposer removes it. */
305
387
  registerVisibility(predicate: TaskBoardVisibilityPredicate): () => void
388
+ /**
389
+ * Register one source-group selector; the first selector returning a group
390
+ * wins. Optional so an older board can serve the same API version.
391
+ */
392
+ registerGrouping?(selector: TaskBoardGroupingSelector): () => void
306
393
  /** Subscribe to the board mirror. */
307
394
  subscribe(callback: (mirror: TaskBoardClientMirror) => void): () => void
308
395
  /** Read the current board mirror. */
@@ -338,6 +425,39 @@ export interface TaskBoardHostFace {
338
425
  registerExtension(extension: TaskBoardExtension): () => void
339
426
  /** Whether the board currently runs a given extension (board x extension). */
340
427
  isExtensionEnabled(extensionId: string): boolean
428
+ /**
429
+ * The whole ledger as the board builds it, tasks included.
430
+ *
431
+ * Part of the read/write face an IN-PROCESS consumer drives the board through
432
+ * (the remote bridge plugin forwarding it to a paired phone); a browser half
433
+ * reads the same document over the board's own HTTP surface. Forwards
434
+ * {@link ../host-service.ts | TaskBoardHostService.snapshot}, so nothing is
435
+ * interpreted between the ledger and the caller.
436
+ */
437
+ snapshot(): TaskBoardSnapshot
438
+ /**
439
+ * Apply one action through every gate the board already has — the running
440
+ * lock, the permission confirmation, the subtask depth, the schedule budget —
441
+ * and answer the resulting snapshot.
442
+ *
443
+ * The `requestId` is the ledger's own idempotency key, so a caller that
444
+ * retries one envelope does not apply it twice. Refusals are the ledger's:
445
+ * they throw with the Host's own text, which is why this face adds no code
446
+ * table of its own.
447
+ */
448
+ apply(requestId: string, action: TaskBoardAction, initiator?: string): TaskBoardSnapshot | Promise<TaskBoardSnapshot>
449
+ /**
450
+ * Follow the board's change notifications. The listener receives no payload —
451
+ * a consumer that needs the state reads {@link snapshot} — and the returned
452
+ * disposer unsubscribes.
453
+ */
454
+ subscribe(listener: () => void): () => void
455
+ /**
456
+ * The acceptance settings, the contract they resolve to right now, and the
457
+ * model catalog the choices come from. The same document the board's own
458
+ * `/verification` route serves.
459
+ */
460
+ verificationOptions(): Promise<TaskBoardVerificationOptions>
341
461
  }
342
462
 
343
463
  declare module '@deepseek-ai/cordis' {
@@ -0,0 +1,38 @@
1
+ /**
2
+ * Run-launch admission width: the one bound on how many sessions this board
3
+ * starts at the same time.
4
+ *
5
+ * One board action opens a whole subtree, and a team run hands every member of
6
+ * it to the Lead at once, so without a bound the Host asks DSH for dozens of
7
+ * sessions in a single tick. The repository's own measured guidance caps heavy
8
+ * implementation subagents at three (docs/multi-agent-resources.md) and no
9
+ * runtime mechanism enforced it; this setting is that mechanism.
10
+ *
11
+ * The bounds and the default live here rather than in either half, exactly like
12
+ * the roster cadence: the settings card validates a draft against the same
13
+ * range the Host clamps a hand-edited configuration to, and a programmatic
14
+ * mount that names no width gets the default.
15
+ *
16
+ * @module dsh-task-board/core/launch-width
17
+ */
18
+
19
+ /** Width used when neither the settings document nor the mount names one. */
20
+ export const DEFAULT_RUN_LAUNCH_WIDTH = 3
21
+
22
+ /** Narrowest accepted width: one launch at a time. */
23
+ export const RUN_LAUNCH_WIDTH_MIN = 1
24
+
25
+ /** Widest accepted width. */
26
+ export const RUN_LAUNCH_WIDTH_MAX = 16
27
+
28
+ /**
29
+ * Clamp a configured width into the supported range. A value the schema would
30
+ * refuse (non-finite, below the floor, above the ceiling) still leaves the
31
+ * board launching: an out-of-range setting never stalls a run.
32
+ * @param width - configured width, or undefined for the default.
33
+ * @returns the effective width.
34
+ */
35
+ export function normalizeRunLaunchWidth(width: number | undefined): number {
36
+ if (width === undefined || !Number.isFinite(width)) return DEFAULT_RUN_LAUNCH_WIDTH
37
+ return Math.min(Math.max(Math.trunc(width), RUN_LAUNCH_WIDTH_MIN), RUN_LAUNCH_WIDTH_MAX)
38
+ }