@linxin666/dsh-client-ui-task-board 0.4.8 → 0.4.9

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 (64) hide show
  1. package/README.i18n.yaml +2 -2
  2. package/README.md +28 -22
  3. package/README.zh.md +28 -22
  4. package/lib/client.js +1435 -682
  5. package/lib/client.js.map +1 -1
  6. package/lib/index.js +356 -366
  7. package/lib/types/client/PluginSettingsCard.d.ts +21 -0
  8. package/lib/types/client/TaskBoardSettingsCard.d.ts +7 -0
  9. package/lib/types/client/board/ExecutionLog.d.ts +16 -0
  10. package/lib/types/client/board/TaskForm.d.ts +4 -0
  11. package/lib/types/client/board/VerificationReport.d.ts +2 -15
  12. package/lib/types/client/body-mutations.d.ts +45 -0
  13. package/lib/types/client/locales.d.ts +42 -6
  14. package/lib/types/client/suppress-schedule-row.d.ts +86 -0
  15. package/lib/types/core/controller.d.ts +1 -1
  16. package/lib/types/core/subtask.d.ts +59 -49
  17. package/lib/types/core/tasks.d.ts +5 -8
  18. package/lib/types/core/use-cases/task-update.d.ts +1 -1
  19. package/lib/types/core/workspace-target.d.ts +23 -3
  20. package/lib/types/host/launch-admission.d.ts +8 -9
  21. package/lib/types/host-ledger.d.ts +72 -48
  22. package/lib/types/host-routes.d.ts +49 -0
  23. package/lib/types/host-runner.d.ts +20 -10
  24. package/lib/types/host-service.d.ts +7 -50
  25. package/lib/types/index.d.ts +61 -63
  26. package/lib/types/loopback.d.ts +21 -0
  27. package/lib/types/protocol.d.ts +0 -5
  28. package/lib/types/tool-surface.d.ts +1 -0
  29. package/package.json +25 -25
  30. package/src/client/CardDefaultPresetField.tsx +1 -1
  31. package/src/client/PluginSettingsCard.tsx +78 -18
  32. package/src/client/TaskBoardSettingsCard.tsx +68 -25
  33. package/src/client/board/ExecutionLog.tsx +140 -0
  34. package/src/client/board/LinkSubtaskModal.tsx +1 -9
  35. package/src/client/board/NewTaskModal.tsx +2 -11
  36. package/src/client/board/TaskCard.tsx +45 -23
  37. package/src/client/board/TaskDetail.tsx +407 -261
  38. package/src/client/board/TaskForm.tsx +19 -4
  39. package/src/client/board/VerificationReport.tsx +143 -104
  40. package/src/client/board/task-markdown.module.css +11 -8
  41. package/src/client/board-settings.module.css +35 -7
  42. package/src/client/board.module.css +855 -115
  43. package/src/client/body-mutations.ts +133 -0
  44. package/src/client/index.ts +10 -0
  45. package/src/client/locales.ts +97 -24
  46. package/src/client/settings-card.module.css +71 -10
  47. package/src/client/suppress-schedule-row.ts +198 -0
  48. package/src/core/controller.ts +1 -3
  49. package/src/core/subtask.ts +81 -76
  50. package/src/core/tasks.ts +5 -9
  51. package/src/core/use-cases/task-update.ts +1 -3
  52. package/src/core/workspace-target.ts +27 -3
  53. package/src/host/agent-tools.ts +14 -15
  54. package/src/host/launch-admission.ts +8 -9
  55. package/src/host-ledger.ts +158 -125
  56. package/src/host-routes.ts +65 -2
  57. package/src/host-runner.ts +53 -28
  58. package/src/host-service.ts +42 -127
  59. package/src/index.ts +84 -106
  60. package/src/loopback.ts +32 -0
  61. package/src/protocol.ts +2 -9
  62. package/src/tool-surface.ts +1 -0
  63. package/lib/types/client/board/team-run-promotion.d.ts +0 -26
  64. package/src/client/board/team-run-promotion.ts +0 -39
@@ -5,9 +5,19 @@
5
5
  * as siblings of the built-in Shell / Agent loop / Web search cards. */
6
6
 
7
7
  .card {
8
+ /* The card's local scale: every literal below reads one of these, and the
9
+ nested density overrides the same seven on the same element, so one rule
10
+ set serves both densities. */
11
+ --settings-card-radius: 12px;
12
+ --settings-card-header-pad: 16px;
13
+ --settings-card-header-gap: 13px;
14
+ --settings-card-title-size: 15px;
15
+ --settings-card-description-size: 13px;
16
+ --settings-card-body-inset: 16px;
17
+ --settings-card-motion: 0.18s;
8
18
  border: 1px solid var(--dsw-alias-border-l2);
9
19
  background: var(--dsw-alias-bg-layer-3);
10
- border-radius: 12px;
20
+ border-radius: var(--settings-card-radius);
11
21
  list-style: none;
12
22
  transition: border-color 0.16s, background 0.16s;
13
23
  }
@@ -21,6 +31,24 @@
21
31
  border-color: var(--dsw-alias-label-dimmed);
22
32
  }
23
33
 
34
+ /* Nested density: a topic card inside another card's body. It overrides the
35
+ local scale only, so the first-level card and this one stay one rule set. */
36
+ .cardNested {
37
+ --settings-card-radius: 10px;
38
+ --settings-card-header-pad: 10px 12px;
39
+ --settings-card-header-gap: 10px;
40
+ --settings-card-title-size: 13px;
41
+ --settings-card-description-size: 12px;
42
+ --settings-card-body-inset: 12px;
43
+ }
44
+
45
+ /* One line: the header already carries the full sentence on its title. */
46
+ .cardNested .description {
47
+ white-space: nowrap;
48
+ overflow: hidden;
49
+ text-overflow: ellipsis;
50
+ }
51
+
24
52
  .header {
25
53
  appearance: none;
26
54
  width: 100%;
@@ -34,10 +62,10 @@
34
62
  cursor: pointer;
35
63
  background: transparent;
36
64
  border: 0;
37
- border-radius: 12px;
65
+ border-radius: var(--settings-card-radius);
38
66
  align-items: center;
39
- gap: 13px;
40
- padding: 16px;
67
+ gap: var(--settings-card-header-gap);
68
+ padding: var(--settings-card-header-pad);
41
69
  display: flex;
42
70
  }
43
71
 
@@ -49,10 +77,10 @@
49
77
  .headerStatic {
50
78
  width: 100%;
51
79
  box-sizing: border-box;
52
- border-radius: 12px;
80
+ border-radius: var(--settings-card-radius);
53
81
  align-items: center;
54
- gap: 13px;
55
- padding: 16px;
82
+ gap: var(--settings-card-header-gap);
83
+ padding: var(--settings-card-header-pad);
56
84
  display: flex;
57
85
  }
58
86
 
@@ -85,7 +113,7 @@
85
113
 
86
114
  .name {
87
115
  color: var(--dsw-alias-label-primary);
88
- font-size: 15px;
116
+ font-size: var(--settings-card-title-size);
89
117
  font-weight: 600;
90
118
  line-height: 1.4;
91
119
  }
@@ -95,7 +123,7 @@
95
123
  print leave 12-13px hint text below readable contrast (orca-link #778399
96
124
  on cream measures ~3.4:1). */
97
125
  color: var(--dsw-alias-label-secondary);
98
- font-size: 13px;
126
+ font-size: var(--settings-card-description-size);
99
127
  line-height: 1.5;
100
128
  }
101
129
 
@@ -135,9 +163,36 @@
135
163
  transform: rotate(180deg);
136
164
  }
137
165
 
166
+ /* Body disclosure. One transition pair drives both legs: the wrapper
167
+ animates 0fr -> 1fr and back, the body is its only item and shrinks into the
168
+ collapsed track. Only the moving states clip, so a settled card never cuts
169
+ off a field's popup. */
170
+ .disclosure {
171
+ display: grid;
172
+ grid-template-rows: 0fr;
173
+ opacity: 0;
174
+ transition: grid-template-rows var(--settings-card-motion) ease, opacity var(--settings-card-motion) ease;
175
+ }
176
+
177
+ .disclosure[data-state='collapsed'],
178
+ .disclosure[data-state='entering'],
179
+ .disclosure[data-state='closing'] {
180
+ overflow: hidden;
181
+ }
182
+
183
+ .disclosure[data-state='entering'],
184
+ .disclosure[data-state='shown'] {
185
+ grid-template-rows: 1fr;
186
+ opacity: 1;
187
+ }
188
+
189
+ .disclosure > .body {
190
+ min-height: 0;
191
+ }
192
+
138
193
  .body {
139
194
  border-top: 1px solid var(--dsw-alias-border-l2);
140
- margin: 0 16px;
195
+ margin: 0 var(--settings-card-body-inset);
141
196
  padding-bottom: 8px;
142
197
  }
143
198
 
@@ -510,4 +565,10 @@
510
565
  .toggleThumb {
511
566
  transition: none;
512
567
  }
568
+
569
+ /* Reduced motion drops the height travel but keeps the fade, so a closing
570
+ body still leaves through the leg its own state started. */
571
+ .disclosure {
572
+ transition-property: opacity;
573
+ }
513
574
  }
@@ -0,0 +1,198 @@
1
+ /**
2
+ * Hide the official automation-tasks entry while the board is on.
3
+ *
4
+ * The shell mounts two scheduling surfaces side by side in the sidebar: the
5
+ * official `ui-schedule` client half ("Automation tasks" — the Host Schedule
6
+ * service's own page) and this package's board ("Task board" — a Host ledger
7
+ * that runs real DSH sessions). The board is the family's complete surface, so
8
+ * while it is enabled the official row is hidden and the sidebar offers one
9
+ * scheduling entry instead of two.
10
+ *
11
+ * The shell owns that row: it renders the button, the label, the tooltip, the
12
+ * active highlight and the collapsed rail, and the host's own end-to-end suite
13
+ * addresses the row by its accessible name. The row is therefore located the
14
+ * same way — the shell's global panel list seat (`sidebar.panellist`), whose
15
+ * per-row anchor the slot renderer stamps — and it is identified by the label
16
+ * the shell itself resolves for that entry (`resolveSlotLabel`, exactly the
17
+ * call the shell's panel projection makes), so the match follows the active
18
+ * language instead of a hard-coded translation.
19
+ *
20
+ * The write is one inline `display: none` on the shell's own button: the row
21
+ * stays mounted (React keeps owning it) and the official panel keeps working
22
+ * everywhere else it is reachable — only the duplicate sidebar entry goes
23
+ * away. The board's master switch owns the state, exactly as it owns the
24
+ * board's own row: with the board off, the official row comes back.
25
+ */
26
+
27
+ import { resolveSlotLabel, type StoredEntry } from '@deepseek-ai/dsh-client-ui-slots'
28
+ import { subscribeBodyInvalidations } from './body-mutations.ts'
29
+
30
+ /**
31
+ * The official automation-tasks panel id.
32
+ *
33
+ * The host `ui-schedule` client half registers its sidebar row and its
34
+ * center-column page under this id; the shell's panel projection addresses
35
+ * both by it.
36
+ */
37
+ export const OFFICIAL_SCHEDULE_PANEL_ID = 'schedules'
38
+
39
+ /** The shell's global panel list seat; every rendered panel row carries one anchor. */
40
+ const PANEL_LIST_SLOT = 'sidebar.panellist'
41
+
42
+ /** The anchor the slot renderer stamps for each global panel row. */
43
+ const PANEL_ROW_ANCHOR = `[data-slot="${PANEL_LIST_SLOT}"]`
44
+
45
+ /**
46
+ * The family's own hook on a plugin-owned panel row.
47
+ *
48
+ * A row carrying it belongs to a plugin that owns its entry, never to the
49
+ * official automation-tasks row, so the guard skips those rows: it must not
50
+ * be able to hide the board's own entry.
51
+ */
52
+ const PLUGIN_ROW_HOOK = '[data-dsh-panel-entry]'
53
+
54
+ /** The slot-service slice the guard reads. */
55
+ export interface PanelSlotReader {
56
+ entriesOfSlot?(key: string): readonly StoredEntry[]
57
+ }
58
+
59
+ /** The context slice the guard needs. */
60
+ export interface ScheduleRowGuardContext {
61
+ slots?: PanelSlotReader
62
+ }
63
+
64
+ /**
65
+ * The live panel-list ledger, or an empty one.
66
+ *
67
+ * A context that serves no slot registry (a capture-only test context, or a
68
+ * shell that never declared the seat) has no official row to hide, and the
69
+ * guard must read that as "nothing to do" instead of failing the page.
70
+ * @param ctx - the client context.
71
+ * @returns the panel-list entries the shell currently projects.
72
+ */
73
+ function panelEntries(ctx: ScheduleRowGuardContext): readonly StoredEntry[] {
74
+ const reader = ctx.slots
75
+ if (reader === undefined || typeof reader.entriesOfSlot !== 'function') return []
76
+ try {
77
+ return reader.entriesOfSlot(PANEL_LIST_SLOT) ?? []
78
+ } catch {
79
+ return []
80
+ }
81
+ }
82
+
83
+ /** The guard's controls. */
84
+ export interface ScheduleRowGuard {
85
+ /** Hide the official row, and keep it hidden while the board is on. */
86
+ hide(): void
87
+ /** Restore the official row: the board's master switch is off. */
88
+ show(): void
89
+ /** Release the listeners and restore the row. */
90
+ dispose(): void
91
+ }
92
+
93
+ /**
94
+ * The accessible name the shell renders on the official automation-tasks row.
95
+ *
96
+ * The shell projects its panel list with `resolveSlotLabel(options.label) ??
97
+ * id`, and that value becomes the row's accessible name. Reading the same
98
+ * value out of the same ledger is what keeps the DOM match correct in every
99
+ * language.
100
+ * @param entries - the live panel-list ledger.
101
+ * @returns the row's accessible name, or undefined when the official panel is not mounted.
102
+ */
103
+ export function officialScheduleRowLabel(entries: readonly StoredEntry[]): string | undefined {
104
+ const entry = entries.find(candidate => candidate.options.id === OFFICIAL_SCHEDULE_PANEL_ID)
105
+ if (entry === undefined) return undefined
106
+ try {
107
+ return resolveSlotLabel(entry.options.label) ?? entry.options.id
108
+ } catch {
109
+ // A label thunk that throws must not take the sidebar down with it.
110
+ return undefined
111
+ }
112
+ }
113
+
114
+ /**
115
+ * The shell's button for the panel row carrying this accessible name.
116
+ *
117
+ * Every global panel row renders one slot anchor inside the shell's own
118
+ * button, so the anchor is the row's handle and the button is what the user
119
+ * sees. Rows a plugin owns (they carry the family's own entry hook) are
120
+ * skipped.
121
+ * @param root - the document (or a subtree) to search.
122
+ * @param label - the accessible name to match.
123
+ * @returns the row button, or undefined when no row carries that name.
124
+ */
125
+ export function findPanelRow(root: ParentNode, label: string): HTMLElement | undefined {
126
+ for (const anchor of root.querySelectorAll(PANEL_ROW_ANCHOR)) {
127
+ if (anchor.querySelector(PLUGIN_ROW_HOOK) !== null) continue
128
+ const button = anchor.closest('button') as HTMLElement | null
129
+ if (button !== null && button.getAttribute('aria-label') === label) return button
130
+ }
131
+ return undefined
132
+ }
133
+
134
+ /**
135
+ * Guard the official automation-tasks row against the board's presence.
136
+ *
137
+ * The guard hides the row while the board is enabled and restores it when the
138
+ * board is switched off. It re-applies its write after every DOM change,
139
+ * because the shell owns the row and may mount or replace it at any time (a
140
+ * re-render, a panel-list change, the official plugin arriving late).
141
+ * @param ctx - client context carrying the slot registry.
142
+ * @param root - the document to search; defaults to the ambient one.
143
+ * @returns the guard's controls.
144
+ */
145
+ export function createScheduleRowGuard(ctx: ScheduleRowGuardContext, root?: ParentNode): ScheduleRowGuard {
146
+ const scope = root ?? (typeof document === 'undefined' ? undefined : document)
147
+ let hidden: HTMLElement | undefined
148
+ let previousDisplay: string | null = null
149
+ let stopWatching: (() => void) | undefined
150
+
151
+ const restoreRow = (): void => {
152
+ if (hidden === undefined) return
153
+ const button = hidden
154
+ hidden = undefined
155
+ if (previousDisplay === null) button.style.removeProperty('display')
156
+ else button.style.setProperty('display', previousDisplay)
157
+ previousDisplay = null
158
+ }
159
+
160
+ const hideRow = (): void => {
161
+ if (scope === undefined) return
162
+ const label = officialScheduleRowLabel(panelEntries(ctx))
163
+ if (label === undefined) return
164
+ const button = findPanelRow(scope, label)
165
+ if (button === undefined) return
166
+ if (hidden === button) return
167
+ restoreRow()
168
+ hidden = button
169
+ previousDisplay = button.style.getPropertyValue('display')
170
+ // The shell's own row rule sets a display value, so the write has to beat
171
+ // it: an inline declaration outranks any author rule that is not itself
172
+ // important, and the important flag also survives a skin's own overrides.
173
+ button.style.setProperty('display', 'none', 'important')
174
+ }
175
+
176
+ const sync = (): void => {
177
+ // A replaced row is a new element: the old write died with it.
178
+ if (hidden !== undefined && !hidden.isConnected) restoreRow()
179
+ hideRow()
180
+ }
181
+
182
+ const hide = (): void => {
183
+ hideRow()
184
+ if (stopWatching === undefined) {
185
+ // The page-wide hub: one body observer for every family consumer, and
186
+ // the row is re-hidden after whatever the shell did to the DOM.
187
+ stopWatching = subscribeBodyInvalidations(sync)
188
+ }
189
+ }
190
+
191
+ const show = (): void => {
192
+ stopWatching?.()
193
+ stopWatching = undefined
194
+ restoreRow()
195
+ }
196
+
197
+ return { hide, show, dispose: show }
198
+ }
@@ -152,7 +152,7 @@ export interface ExecutionOptionsSnapshot {
152
152
  * (revision/scheduler/power); a full snapshot also carries the deployment
153
153
  * constants the UI reads (session default permission, subtask depth).
154
154
  */
155
- export type HostMirror = Pick<TaskBoardSnapshot, 'revision' | 'scheduler' | 'power' | 'sessionDefaultPermission' | 'maxSubtaskDepth' | 'teamRunAvailable' | 'goalRunEnabled' | 'cardDefaults' | 'extensions'>
155
+ export type HostMirror = Pick<TaskBoardSnapshot, 'revision' | 'scheduler' | 'power' | 'sessionDefaultPermission' | 'maxSubtaskDepth' | 'goalRunEnabled' | 'cardDefaults' | 'extensions'>
156
156
 
157
157
  /** Immutable controller snapshot for UI subscriptions. */
158
158
  export interface ControllerSnapshot {
@@ -842,7 +842,6 @@ export class BoardController {
842
842
  private mirrorOf(snapshot: TaskBoardSnapshot): HostMirror {
843
843
  const sessionDefaultPermission = snapshot.sessionDefaultPermission ?? this.hostState?.sessionDefaultPermission
844
844
  const maxSubtaskDepth = snapshot.maxSubtaskDepth ?? this.hostState?.maxSubtaskDepth
845
- const teamRunAvailable = snapshot.teamRunAvailable ?? this.hostState?.teamRunAvailable
846
845
  const goalRunEnabled = snapshot.goalRunEnabled ?? this.hostState?.goalRunEnabled
847
846
  // The new-card defaults are NOT carried over: the Host publishes a target
848
847
  // nothing configures by omitting it (protocol.ts states that explicitly), so
@@ -857,7 +856,6 @@ export class BoardController {
857
856
  power: snapshot.power,
858
857
  ...(sessionDefaultPermission === undefined ? {} : { sessionDefaultPermission }),
859
858
  ...(maxSubtaskDepth === undefined ? {} : { maxSubtaskDepth }),
860
- ...(teamRunAvailable === undefined ? {} : { teamRunAvailable }),
861
859
  ...(goalRunEnabled === undefined ? {} : { goalRunEnabled }),
862
860
  ...(cardDefaults === undefined ? {} : { cardDefaults }),
863
861
  ...(extensions === undefined ? {} : { extensions }),
@@ -1,8 +1,8 @@
1
1
  /**
2
2
  * Subtask lineage: the depth gate, the ancestry/descendant queries, the
3
- * cascade participant set one run request opens, the deferred settlement of a
4
- * cascade parent, and the execution-target inheritance a subtask resolves at
5
- * run time.
3
+ * outstanding-descendant decision one run request makes, the deferred
4
+ * settlement of a historical run group, and the execution-target inheritance a
5
+ * subtask resolves at run time.
6
6
  *
7
7
  * Framework-free (no cordis, no runtime imports) so every rule is
8
8
  * unit-testable in isolation. The Host ledger is the only authority; the
@@ -182,46 +182,91 @@ export function checkParentLink(
182
182
  }
183
183
 
184
184
  /**
185
- * The tasks one run request opens executions for: the requested task first,
186
- * then its on-board descendants within the configured depth. This is the
187
- * SHAPE of a cascade — every walk that must see the whole tree (settlement,
188
- * archive/restore, the running lock) reads it. The run path filters it with
189
- * {@link joinsCascadeRun}: archived tasks never run, a participant that already
190
- * has an open execution is skipped by the caller, which cannot start it twice,
191
- * and a finished descendant is left alone.
185
+ * The tasks one run request opens executions for: the requested card ALONE.
186
+ *
187
+ * Running a card never expands into its subtask tree. The card's own session
188
+ * reads its subtasks through the board tools and dispatches subagents itself,
189
+ * so a parent run opens exactly one session. Clicking a subtask runs that
190
+ * subtask as its own root, again without expanding its own descendants. The
191
+ * lineage queries around this one answer questions about the tree the card's
192
+ * agent works with (who is still outstanding, what a historical run group
193
+ * still holds open) — never who gets a session from the Host.
194
+ * @param tasks - the ledger.
195
+ * @param rootId - the task the run request named.
196
+ * @returns the one card this run opens an execution for, or [] when unknown.
197
+ */
198
+ export function cascadeTargets(tasks: readonly TaskRecord[], rootId: string): TaskRecord[] {
199
+ const root = tasks.find(task => task.id === rootId)
200
+ return root === undefined ? [] : [root]
201
+ }
202
+
203
+ /**
204
+ * A task together with every descendant within the configured depth: the
205
+ * subtree a lineage gate (archive, restore, force-close) has to walk.
192
206
  */
193
- export function cascadeTargets(
207
+ export function subtreeTasks(tasks: readonly TaskRecord[], id: string, maxSubtaskDepth: number): TaskRecord[] {
208
+ const root = tasks.find(task => task.id === id)
209
+ return root === undefined ? [] : [root, ...descendantTasks(tasks, id, maxSubtaskDepth)]
210
+ }
211
+
212
+ /**
213
+ * Whether a card still has work outstanding: anything outside the `done`
214
+ * column. It keys on the column alone, so it covers both a subtask that ran
215
+ * and one an operator moved to done by hand.
216
+ */
217
+ export function isOutstanding(task: TaskRecord): boolean {
218
+ return task.status !== 'done'
219
+ }
220
+
221
+ /**
222
+ * The descendants of a card that still have work outstanding, in breadth-first
223
+ * order: the cards its own session is expected to dispatch. An archived
224
+ * descendant is off the board and cannot be dispatched, so it is not listed.
225
+ */
226
+ export function outstandingDescendants(
194
227
  tasks: readonly TaskRecord[],
195
228
  rootId: string,
196
229
  maxSubtaskDepth: number,
197
230
  ): TaskRecord[] {
198
- const root = tasks.find(task => task.id === rootId)
199
- if (root === undefined) return []
200
- return [root, ...descendantTasks(tasks, rootId, maxSubtaskDepth)]
231
+ return descendantTasks(tasks, rootId, maxSubtaskDepth)
232
+ .filter(task => task.archivedAt === undefined && isOutstanding(task))
201
233
  }
202
234
 
203
235
  /**
204
- * Whether a cascade member takes part in a new run.
205
- *
206
- * The task the user ran is always a member: the request names that card, and
207
- * the operator asked for it to run whatever its column says. A descendant does
208
- * not join once it sits in the `done` column — its work is finished, so running
209
- * the parent again is a run of the parent, never a second execution of work
210
- * that is already done. The rule keys on the column alone, so it covers both a
211
- * subtask that ran and one an operator moved to done by hand, and it holds for
212
- * every trigger: a manual run, a re-run, and a due occurrence of a schedule.
213
- * A card whose own schedule is enabled settles back into `todo`, so a scheduled
214
- * subtask stays a participant; to make a finished one run again, move it back
215
- * to `todo` or run it on its own.
216
- * @param task - the candidate member.
236
+ * Whether any descendant of this card still sits outside the `done` column.
237
+ * This is the ONE decision behind both the forced agent preset and the dispatch
238
+ * section of the execution prompt: a card whose tree still holds work runs as
239
+ * the autonomous dispatcher.
240
+ */
241
+ export function hasOutstandingDescendants(
242
+ tasks: readonly TaskRecord[],
243
+ rootId: string,
244
+ maxSubtaskDepth: number,
245
+ ): boolean {
246
+ return outstandingDescendants(tasks, rootId, maxSubtaskDepth).length > 0
247
+ }
248
+
249
+ /**
250
+ * Agent preset a run with unfinished subtasks is forced under. The id comes
251
+ * from packages/dsh-liangshen (its own `LIANGSHEN_PRESET_ID`); the force is
252
+ * applied at launch and never written into a card's `mode` field.
253
+ */
254
+ export const LIANGSHEN_PRESET_ID = 'liangshen'
255
+
256
+ /**
257
+ * Whether a card belongs to a run's dispatch set: the card the request named,
258
+ * or a card whose work is still outstanding. Kept for the browser's subtask
259
+ * preview; the Host run itself opens the clicked card alone
260
+ * ({@link cascadeTargets}).
261
+ * @param task - the candidate card.
217
262
  * @param rootId - the task the run request named.
218
- * @returns false when this member is left alone by the run.
263
+ * @returns false when this card is finished and left alone.
219
264
  */
220
265
  export function joinsCascadeRun(task: TaskRecord, rootId: string): boolean {
221
- return task.id === rootId || task.status !== 'done'
266
+ return task.id === rootId || isOutstanding(task)
222
267
  }
223
268
 
224
- /** One still-open execution belonging to a cascade run group. */
269
+ /** One still-open execution belonging to a stored run group. */
225
270
  export interface OpenCascadeChild {
226
271
  taskId: string
227
272
  execution: ExecutionRecord
@@ -234,8 +279,9 @@ export function openGroupExecution(task: TaskRecord, runGroupId: string): Execut
234
279
 
235
280
  /**
236
281
  * The direct subtasks of parentTaskId whose execution in this run group is
237
- * still open: the parent remaining waiters. The parent may settle once this
238
- * list is empty and its own outcome is known.
282
+ * still open: the parent's remaining waiters. A stored multi-member group (a
283
+ * run the Host opened before it stopped spreading one run across a subtree)
284
+ * folds once this list is empty and the parent's own outcome is known.
239
285
  */
240
286
  export function pendingCascadeChildren(
241
287
  tasks: readonly TaskRecord[],
@@ -252,9 +298,9 @@ export function pendingCascadeChildren(
252
298
  }
253
299
 
254
300
  /**
255
- * Fold a cascade parent own outcome and its children outcomes into one
256
- * verdict: failure dominates, then cancellation, then success. The error text
257
- * is the first failure, falling back to the first cancellation.
301
+ * Fold a stored run-group parent's own outcome and its children's outcomes into
302
+ * one verdict: failure dominates, then cancellation, then success. The error
303
+ * text is the first failure, falling back to the first cancellation.
258
304
  */
259
305
  export function combineCascadeOutcome(
260
306
  entries: readonly { result: ExecutionOutcome; error?: string }[],
@@ -294,47 +340,6 @@ export function effectiveTaskPermission(task: TaskRecord): TaskRecord['permissio
294
340
  * elevated card is runnable while a subtask's own unconfirmed binding stays
295
341
  * gated.
296
342
  */
297
- /**
298
- * The immutable teammate name for one team-mode member. Teammate names are
299
- * lower-kebab-case and must stay unique for the lifetime of the Team: the
300
- * run-group token separates two runs of the same tree, and the member
301
- * discriminator separates two members of one run that reduce to the same slug.
302
- *
303
- * The discriminator is not cosmetic. A title with no ASCII word characters (a
304
- * CJK title, for example) carries no slug at all, so every such title of one
305
- * run group collides on the generic prefix; Agent Teams answers every member
306
- * after the first with `teammate name "..." was already used in this Team`,
307
- * and those subtasks never start. Two ASCII titles that share a slug
308
- * (`AI 强度预测` next to `AI 配比优化`) collide the same way.
309
- * @param title - the member task's title.
310
- * @param token - the run group id (the task id when no group is recorded).
311
- * @param memberId - the member task's id, which makes the name unique in the run.
312
- * @returns the teammate name handed to the Agent Teams service.
313
- */
314
- export function teammateName(title: string, token: string, memberId?: string): string {
315
- const slug = title.toLowerCase().replace(/[^a-z0-9]+/g, '-').replace(/^-+|-+$/g, '').slice(0, 32).replace(/-+$/g, '')
316
- const suffix = token.replace(/[^a-z0-9]/gi, '').slice(0, 8).toLowerCase()
317
- const member = memberId === undefined || memberId === '' ? undefined : stableTag(memberId)
318
- return [slug === '' ? 'subtask' : slug, member, suffix === '' ? 'run' : suffix]
319
- .filter((part): part is string => part !== undefined)
320
- .join('-')
321
- }
322
-
323
- /**
324
- * A stable 4-hex tag for one member id. The name is derived twice for the same
325
- * member — once for the Lead's prompt and once for the spawn request — so the
326
- * tag must be a pure function of the id, never of a clock or a counter. FNV-1a
327
- * keeps it dependency-free in `core/`, which both halves compile.
328
- */
329
- function stableTag(value: string): string {
330
- let hash = 0x811c9dc5
331
- for (let index = 0; index < value.length; index += 1) {
332
- hash ^= value.charCodeAt(index)
333
- hash = Math.imul(hash, 0x01000193) >>> 0
334
- }
335
- return hash.toString(16).padStart(8, '0').slice(0, 4)
336
- }
337
-
338
343
  export function resolveExecutionTargets(
339
344
  task: TaskRecord,
340
345
  tasks: readonly TaskRecord[],
package/src/core/tasks.ts CHANGED
@@ -457,12 +457,11 @@ export interface TaskRecord {
457
457
  */
458
458
  reuseSession?: boolean
459
459
  /**
460
- * Run this task's subtree as an Agent Team instead of one Host-launched
461
- * session per participant: the root becomes the Team Lead session and the
462
- * Host spawns one teammate for each direct subtask inside it. Absent or false
463
- * keeps the plain concurrent cascade. A deployment that does not serve the
464
- * Agent Teams service refuses a team run instead of silently falling back,
465
- * and a subtask's own permission pin cannot be honored in this mode.
460
+ * Historical Agent Team opt-in. New runs never write it and the Host never
461
+ * reads it to decide how to run: a run with unfinished subtasks opens one
462
+ * session whose own agent dispatches subagents. The field is kept so cards
463
+ * already on disk keep their record, and so the ledger can still fold a team
464
+ * run group it opened before this behavior changed.
466
465
  */
467
466
  teamRun?: boolean
468
467
  /**
@@ -589,8 +588,6 @@ export interface NewTaskInput {
589
588
  applyCardDefaults?: boolean
590
589
  /** Reuse the previous execution's session for later runs (issue #1419). */
591
590
  reuseSession?: boolean
592
- /** Run the subtree as an Agent Team (Team Lead session plus one teammate per direct subtask). */
593
- teamRun?: boolean
594
591
  /**
595
592
  * Start the execution with dsh's built-in `/goal`. Absent means the default
596
593
  * (one plain turn); only an explicit true joins the goal run.
@@ -753,7 +750,6 @@ export function createTask(input: NewTaskInput, now: number, id: string): TaskRe
753
750
  model: normalizeTargetId(input.model),
754
751
  reasoningEffort: normalizeTargetId(input.reasoningEffort),
755
752
  reuseSession: input.reuseSession === true ? true : undefined,
756
- teamRun: input.teamRun === true ? true : undefined,
757
753
  // Default OFF: only an explicit true is stored, so a card that never
758
754
  // touched the option (and every card written before the field existed)
759
755
  // keeps running one plain turn.
@@ -16,7 +16,7 @@ import type { TaskHandoverInput } from '../handover.ts'
16
16
  * Editable fields on a task (the update patch surface). `freeze` replaces the
17
17
  * continuation-card snapshot (restamping frozenAt); an explicit null clears it.
18
18
  */
19
- export type TaskUpdatePatch = Partial<Pick<TaskRecord, 'title' | 'description' | 'prompt' | 'workspaceId' | 'mode' | 'permission' | 'model' | 'reasoningEffort' | 'reuseSession' | 'teamRun' | 'goalRun' | 'skipVerification'>> & {
19
+ export type TaskUpdatePatch = Partial<Pick<TaskRecord, 'title' | 'description' | 'prompt' | 'workspaceId' | 'mode' | 'permission' | 'model' | 'reasoningEffort' | 'reuseSession' | 'goalRun' | 'skipVerification'>> & {
20
20
  freeze?: FreezeSnapshot & { redacted?: boolean } | null
21
21
  /** Replaces the handover bundle (restamping bundledAt); an explicit null clears it. */
22
22
  handover?: TaskHandoverInput | null
@@ -109,8 +109,6 @@ export function applyUpdateTask(
109
109
  // Session reuse is a boolean opt-in; false (or an explicit null from a
110
110
  // caller that needs to clear it) returns the task to one session per run.
111
111
  if ('reuseSession' in patch) next.reuseSession = patch.reuseSession === true ? true : undefined
112
- // Team execution is a boolean opt-in with the same clear-by-false rule.
113
- if ('teamRun' in patch) next.teamRun = patch.teamRun === true ? true : undefined
114
112
  // The /goal opt-in is default-OFF: true joins the goal run, while false
115
113
  // (or an explicit null) returns the card to the default and stores nothing.
116
114
  if ('goalRun' in patch) next.goalRun = patch.goalRun === true ? true : undefined
@@ -1,11 +1,12 @@
1
1
  /**
2
2
  * Workspace targeting for cards that pin none.
3
3
  *
4
- * The Host answers two questions here instead of leaving them to
4
+ * The Host answers three questions here instead of leaving them to
5
5
  * `session.create`, whose own fallback is the Host process working directory
6
6
  * (the desktop app's profile directory): which workspace a root card inherits
7
- * from the session that created it, and which workspace an unpinned run lands
8
- * in when nothing could be inherited.
7
+ * from the session that created it, which workspace an unpinned run lands in
8
+ * when nothing could be inherited, and — when neither names one — the refusal
9
+ * that stops the run instead of landing it there.
9
10
  *
10
11
  * Structural types only — the Host's `Workspace` entity satisfies them — so the
11
12
  * browser program compiles this module without importing an SDK value.
@@ -57,3 +58,26 @@ export function mostRecentWorkspaceId(items: readonly WorkspaceCandidate[]): str
57
58
  }
58
59
  return best?.id ?? items[0]?.id
59
60
  }
61
+
62
+ /**
63
+ * The failure text the Host records when a card names no workspace and the
64
+ * deployment has none to resolve it to: the run is refused before any session
65
+ * exists instead of letting `session.create` fall back to the Host process
66
+ * working directory (the desktop app's profile directory), which is never the
67
+ * project the user meant.
68
+ *
69
+ * A finished sentence rather than a code: the ledger stores it as the
70
+ * execution's failure text, which the agent tools serve to a model and which
71
+ * any client prints verbatim. It names the fix, not the mechanism.
72
+ */
73
+ export const MISSING_WORKSPACE_REASON = 'this card pins no workspace; choose a workspace on the card before running'
74
+
75
+ /**
76
+ * Whether a recorded failure text is the missing-workspace refusal, which the
77
+ * browser half renders in the reader's own language.
78
+ * @param reason - the execution's recorded failure text.
79
+ * @returns true when that run was refused for naming no workspace.
80
+ */
81
+ export function isMissingWorkspaceReason(reason: string): boolean {
82
+ return reason === MISSING_WORKSPACE_REASON
83
+ }