@linxin666/dsh-client-ui-task-board 0.4.1 → 0.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. package/README.i18n.yaml +2 -2
  2. package/README.md +24 -0
  3. package/README.zh.md +24 -0
  4. package/lib/client.js +917 -81
  5. package/lib/client.js.map +1 -1
  6. package/lib/index.js +1774 -1420
  7. package/lib/types/client/TaskBoardSettingsCard.d.ts +4 -0
  8. package/lib/types/client/board/LinkSubtaskModal.d.ts +11 -0
  9. package/lib/types/client/board/NewTaskModal.d.ts +7 -1
  10. package/lib/types/client/board/TaskCard.d.ts +11 -1
  11. package/lib/types/client/locales.d.ts +33 -0
  12. package/lib/types/core/controller.d.ts +30 -1
  13. package/lib/types/core/subtask.d.ts +122 -0
  14. package/lib/types/core/tasks.d.ts +46 -3
  15. package/lib/types/core/use-cases/task-archive.d.ts +10 -13
  16. package/lib/types/core/use-cases/task-create.d.ts +13 -4
  17. package/lib/types/core/use-cases/task-delete.d.ts +7 -1
  18. package/lib/types/core/use-cases/task-parent.d.ts +21 -0
  19. package/lib/types/core/use-cases/task-update.d.ts +1 -1
  20. package/lib/types/host/agent-tools.d.ts +27 -0
  21. package/lib/types/host-ledger.d.ts +88 -4
  22. package/lib/types/host-runner.d.ts +39 -1
  23. package/lib/types/host-service.d.ts +47 -0
  24. package/lib/types/index.d.ts +83 -5
  25. package/lib/types/protocol.d.ts +14 -0
  26. package/package.json +23 -21
  27. package/src/client/TaskBoardSettingsCard.tsx +48 -3
  28. package/src/client/board/LinkSubtaskModal.tsx +82 -0
  29. package/src/client/board/NewTaskModal.tsx +40 -6
  30. package/src/client/board/TaskBoard.tsx +88 -8
  31. package/src/client/board/TaskCard.tsx +52 -2
  32. package/src/client/board/TaskDetail.tsx +124 -1
  33. package/src/client/board.module.css +96 -0
  34. package/src/client/host-api.ts +14 -4
  35. package/src/client/index.ts +11 -1
  36. package/src/client/locales.ts +70 -2
  37. package/src/core/controller.ts +69 -8
  38. package/src/core/store.ts +15 -0
  39. package/src/core/subtask.ts +286 -0
  40. package/src/core/tasks.ts +50 -2
  41. package/src/core/use-cases/task-archive.ts +46 -12
  42. package/src/core/use-cases/task-create.ts +42 -7
  43. package/src/core/use-cases/task-delete.ts +11 -1
  44. package/src/core/use-cases/task-parent.ts +64 -0
  45. package/src/core/use-cases/task-update.ts +3 -1
  46. package/src/host/agent-tools.ts +643 -0
  47. package/src/host-ledger.ts +323 -45
  48. package/src/host-runner.ts +141 -12
  49. package/src/host-service.ts +127 -10
  50. package/src/index.ts +181 -9
  51. package/src/protocol.ts +26 -2
@@ -15,6 +15,8 @@ export interface TaskBoardSettings {
15
15
  announceToAgent?: boolean;
16
16
  /** Prevent host idle sleep while sessions run or schedules are armed. */
17
17
  preventIdleSleep?: boolean;
18
+ /** Subtask depth limit (1..3); 1 means a single level of subtasks. */
19
+ maxSubtaskDepth?: number;
18
20
  }
19
21
  /** What the task-board card renders. */
20
22
  export interface TaskBoardSettingsCardState extends CardShell {
@@ -24,6 +26,8 @@ export interface TaskBoardSettingsCardState extends CardShell {
24
26
  announceToAgent: CardFieldState;
25
27
  /** Idle-system-sleep protection flag. */
26
28
  preventIdleSleep: CardFieldState;
29
+ /** Subtask depth limit field. */
30
+ maxSubtaskDepth: CardFieldState;
27
31
  }
28
32
  /** The registration-side face the card's slot entry injects. */
29
33
  export interface TaskBoardSettingsCardFace extends CardActions {
@@ -0,0 +1,11 @@
1
+ import type { BoardController } from '../../core/controller.ts';
2
+ import type { TaskRecord } from '../../core/tasks.ts';
3
+ /** Link-subtask overlay props. */
4
+ export interface LinkSubtaskModalProps {
5
+ controller: BoardController;
6
+ /** The task the picked card becomes a subtask of. */
7
+ parent: TaskRecord;
8
+ onClose: () => void;
9
+ }
10
+ /** Link-subtask overlay. */
11
+ export declare function LinkSubtaskModal({ controller, parent, onClose }: LinkSubtaskModalProps): import("react").JSX.Element;
@@ -12,6 +12,12 @@ export interface NewTaskModalProps {
12
12
  defaultWorkspaceId?: string;
13
13
  /** Optional callback after successful duplication (e.g. to archive source). */
14
14
  onDuplicateSuccess?: (sourceTaskId: string) => Promise<void>;
15
+ /**
16
+ * Task the new card becomes a subtask of ("add subtask" from its detail
17
+ * view). The execution targets start from the parent's and the create action
18
+ * carries the parent link; unset targets inherit again at run time.
19
+ */
20
+ parentTask?: TaskRecord;
15
21
  }
16
22
  /** New-task form overlay. */
17
- export declare function NewTaskModal({ controller, onClose, initialTask, defaultWorkspaceId, onDuplicateSuccess }: NewTaskModalProps): import("react").JSX.Element;
23
+ export declare function NewTaskModal({ controller, onClose, initialTask, defaultWorkspaceId, onDuplicateSuccess, parentTask }: NewTaskModalProps): import("react").JSX.Element;
@@ -2,11 +2,21 @@ import type { TaskRecord } from '../../core/tasks.ts';
2
2
  /** Compact relative/absolute time label. */
3
3
  export declare function formatHostTimestamp(ms: number, timeZone?: string): string;
4
4
  export declare function formatTime(ms: number, timeZone?: string): string;
5
- declare function TaskCardInner({ task, pending, timeZone, onClick }: {
5
+ declare function TaskCardInner({ task, pending, timeZone, onClick, subtaskCount, isSubtask, subtasksDone, subtasksRunning, subtasksFailed, }: {
6
6
  task: TaskRecord;
7
7
  pending: boolean;
8
8
  timeZone?: string;
9
9
  onClick: () => void;
10
+ /** Direct subtasks of this card, shown as a badge (0 hides it). */
11
+ subtaskCount?: number;
12
+ /** Whether this card is itself a subtask. */
13
+ isSubtask?: boolean;
14
+ /** Direct subtasks already settled as done, for the roll-up badge. */
15
+ subtasksDone?: number;
16
+ /** Direct subtasks currently running, for the roll-up badge. */
17
+ subtasksRunning?: number;
18
+ /** Direct subtasks that failed, for the roll-up badge. */
19
+ subtasksFailed?: number;
10
20
  }): import("react").JSX.Element;
11
21
  /** Memoized card: re-renders only when the card's own task record changes. */
12
22
  export declare const TaskCard: import("react").MemoExoticComponent<typeof TaskCardInner>;
@@ -156,12 +156,16 @@ export declare const zh: {
156
156
  'exec.mode.brokenSuffix': string;
157
157
  'exec.mode.removed': string;
158
158
  'exec.permission.default': string;
159
+ 'exec.permission.inheritParent': string;
159
160
  'exec.permission.read-only': string;
160
161
  'exec.permission.workspace-write': string;
161
162
  'exec.permission.danger-full-access': string;
162
163
  'exec.model.default': string;
163
164
  'exec.model.unknown': string;
164
165
  'exec.reuseSession': string;
166
+ 'exec.teamRun': string;
167
+ 'exec.teamRunHint': string;
168
+ 'exec.teamRunUnavailable': string;
165
169
  'exec.reuseSessionHint': string;
166
170
  'detail.executionSettings': string;
167
171
  'exec.hint': string;
@@ -192,6 +196,35 @@ export declare const zh: {
192
196
  'settings.unsaved': string;
193
197
  'settings.saveFailed': string;
194
198
  'settings.invalidNumber': string;
199
+ 'settings.maxSubtaskDepth': string;
200
+ 'settings.maxSubtaskDepthHint': string;
201
+ 'settings.maxSubtaskDepthOption': string;
202
+ 'detail.parent': string;
203
+ 'detail.parent.open': string;
204
+ 'detail.subtasks': string;
205
+ 'detail.subtasks.empty': string;
206
+ 'detail.subtasks.add': string;
207
+ 'detail.subtasks.link': string;
208
+ 'detail.subtasks.detach': string;
209
+ 'detail.subtasks.runningLock': string;
210
+ 'detail.subtasks.runHint': string;
211
+ 'detail.subtasks.waiting': string;
212
+ 'detail.subtasks.depthLimit': string;
213
+ 'detail.subtasks.hostOnly': string;
214
+ 'new.subtaskTitle': string;
215
+ 'new.subtaskInherit': string;
216
+ 'link.subtask.title': string;
217
+ 'link.subtask.hint': string;
218
+ 'link.subtask.empty': string;
219
+ 'link.subtask.confirm': string;
220
+ 'card.subtask': string;
221
+ 'card.subtasks': string;
222
+ 'card.subtasksFailed': string;
223
+ 'card.subtasksRunning': string;
224
+ 'card.subtasksBreakdown': string;
225
+ 'board.hideSubtasks': string;
226
+ 'board.showSubtasks': string;
227
+ 'board.subtaskFilterHint': string;
195
228
  };
196
229
  /** en dictionary, complete against the zh key set. */
197
230
  export declare const en: Record<keyof typeof zh, string>;
@@ -90,6 +90,12 @@ export interface ExecutionOptionsSnapshot {
90
90
  presets: readonly ExecutionPresetOption[];
91
91
  models?: readonly ExecutionModelOption[];
92
92
  }
93
+ /**
94
+ * Host-owned state the browser mirrors. SSE frames carry the volatile subset
95
+ * (revision/scheduler/power); a full snapshot also carries the deployment
96
+ * constants the UI reads (session default permission, subtask depth).
97
+ */
98
+ export type HostMirror = Pick<TaskBoardSnapshot, 'revision' | 'scheduler' | 'power' | 'sessionDefaultPermission' | 'maxSubtaskDepth' | 'teamRunAvailable'>;
93
99
  /** Immutable controller snapshot for UI subscriptions. */
94
100
  export interface ControllerSnapshot {
95
101
  tasks: readonly TaskRecord[];
@@ -105,7 +111,7 @@ export interface ControllerSnapshot {
105
111
  /** Whether this deployment can parse pasted text into task fields (issue #1540). */
106
112
  canParseTask?: boolean;
107
113
  transportError?: string;
108
- host?: Pick<TaskBoardSnapshot, 'revision' | 'scheduler' | 'power' | 'sessionDefaultPermission'>;
114
+ host?: HostMirror;
109
115
  }
110
116
  /** The selected task (resolved from the ledger), or undefined. */
111
117
  export declare function selectedTaskOf(snapshot: ControllerSnapshot): TaskRecord | undefined;
@@ -195,6 +201,14 @@ export declare class BoardController {
195
201
  * @returns true when applied.
196
202
  */
197
203
  archiveTask(id: string): boolean;
204
+ /**
205
+ * Attach an existing task under a parent (or detach it with a null parent)
206
+ * through the Host. The lineage gate — parent exists and is on-board, no
207
+ * cycle, depth within the deployment limit — belongs to the Host; a refusal
208
+ * surfaces through the transport error like every other rejected action.
209
+ * @returns true when the link was accepted by the authority.
210
+ */
211
+ setParent(id: string, parentId: string | null): Promise<boolean>;
198
212
  /** Restore an archived task back onto the board (same status column). */
199
213
  restoreTask(id: string): boolean;
200
214
  /**
@@ -263,6 +277,21 @@ export declare class BoardController {
263
277
  * re-serialize the whole ledger per tab even while nothing changes.
264
278
  */
265
279
  private onRemoteEvent;
280
+ /**
281
+ * Deployment subtask depth limit the browser mirrors from the last Host
282
+ * snapshot; the fallback is the deployment default for the legacy path (no
283
+ * transport) and for the window before the first snapshot arrives.
284
+ */
285
+ private mirrorDepth;
286
+ /**
287
+ * Project a Host snapshot onto the browser's mirror. SSE frames and partial
288
+ * snapshots carry only the volatile subset (revision/scheduler/power), so the
289
+ * deployment constants the UI reads — the session-default permission the
290
+ * confirmation banner compares against and the subtask depth limit — are
291
+ * carried over from the last full snapshot instead of being dropped by a
292
+ * heartbeat frame.
293
+ */
294
+ private mirrorOf;
266
295
  private refreshRemote;
267
296
  private acceptRemote;
268
297
  private notify;
@@ -0,0 +1,122 @@
1
+ /**
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.
6
+ *
7
+ * Framework-free (no cordis, no runtime imports) so every rule is
8
+ * unit-testable in isolation. The Host ledger is the only authority; the
9
+ * browser mirrors these predicates to enable or disable controls, never to
10
+ * decide them.
11
+ */
12
+ import type { ExecutionOutcome, ExecutionRecord, TaskRecord } from './tasks.ts';
13
+ /** Lowest configurable subtask depth. */
14
+ export declare const SUBTASK_DEPTH_MIN = 1;
15
+ /** Highest configurable subtask depth. */
16
+ export declare const SUBTASK_DEPTH_MAX = 3;
17
+ /** Deployment default: one level of subtasks, and no subtask of a subtask. */
18
+ export declare const DEFAULT_SUBTASK_DEPTH = 1;
19
+ /**
20
+ * Clamp a configured depth into the supported range. Anything unusable
21
+ * (absent, non-numeric, not finite) falls back to the default, so a bad
22
+ * configuration narrows the tree instead of lifting the guard.
23
+ */
24
+ export declare function normalizeSubtaskDepth(value: unknown): number;
25
+ /** Whether an unknown value is a settled execution outcome. */
26
+ export declare function isExecutionOutcome(value: unknown): value is ExecutionOutcome;
27
+ /**
28
+ * Nearest-first ancestor chain of a task. The walk is cycle-safe and bounded
29
+ * by the ledger size rather than by the deployment maximum: a chain stored
30
+ * under a larger limit survives that limit being lowered, and restore and
31
+ * inheritance must still see all of it.
32
+ */
33
+ export declare function ancestorChain(tasks: readonly TaskRecord[], task: TaskRecord): TaskRecord[];
34
+ /** Root-to-task depth: a root task is 0, its subtask 1, and so on. */
35
+ export declare function taskDepth(tasks: readonly TaskRecord[], id: string): number;
36
+ /** Direct subtasks of a task, in ledger order. */
37
+ export declare function directSubtasks(tasks: readonly TaskRecord[], id: string): TaskRecord[];
38
+ /**
39
+ * Descendants of a task in breadth-first order, bounded by maxSubtaskDepth
40
+ * total depth. The visited set keeps a malformed ledger from looping.
41
+ */
42
+ export declare function descendantTasks(tasks: readonly TaskRecord[], id: string, maxSubtaskDepth: number): TaskRecord[];
43
+ /**
44
+ * Height of a task's own subtree (0 for a leaf), bounded by the hard maximum.
45
+ * The visited set makes the walk terminate on a cyclic hand-edited ledger
46
+ * instead of recursing until the stack overflows.
47
+ */
48
+ export declare function subtreeHeight(tasks: readonly TaskRecord[], id: string, visited?: ReadonlySet<string>): number;
49
+ /** Why a parent link was refused; also the source of the Host error text. */
50
+ export type ParentLinkRejection = 'unknown-task' | 'unknown-parent' | 'archived-parent' | 'self-parent' | 'cycle' | 'depth-exceeded';
51
+ export interface ParentLinkCheck {
52
+ /** True when the link (or the detachment) may be stored. */
53
+ ok: boolean;
54
+ /** Why it was refused; absent when ok. */
55
+ reason?: ParentLinkRejection;
56
+ }
57
+ /**
58
+ * Whether childId may be attached under parentId. A null parent detaches and
59
+ * is always allowed for a known task. Otherwise the link must name an
60
+ * on-board task that is neither the child itself nor one of its descendants,
61
+ * and the resulting depth (parent depth + 1 + the child own subtree height)
62
+ * must stay within maxSubtaskDepth.
63
+ */
64
+ export declare function checkParentLink(tasks: readonly TaskRecord[], childId: string, parentId: string | null, maxSubtaskDepth: number): ParentLinkCheck;
65
+ /**
66
+ * The tasks one run request opens executions for: the requested task first,
67
+ * then its on-board descendants within the configured depth. Archived tasks
68
+ * never run; a participant that already has an open execution is skipped by
69
+ * the caller, which cannot start it twice.
70
+ */
71
+ export declare function cascadeTargets(tasks: readonly TaskRecord[], rootId: string, maxSubtaskDepth: number): TaskRecord[];
72
+ /** One still-open execution belonging to a cascade run group. */
73
+ export interface OpenCascadeChild {
74
+ taskId: string;
75
+ execution: ExecutionRecord;
76
+ }
77
+ /** The open execution of a task inside a run group, if it still exists. */
78
+ export declare function openGroupExecution(task: TaskRecord, runGroupId: string): ExecutionRecord | undefined;
79
+ /**
80
+ * The direct subtasks of parentTaskId whose execution in this run group is
81
+ * still open: the parent remaining waiters. The parent may settle once this
82
+ * list is empty and its own outcome is known.
83
+ */
84
+ export declare function pendingCascadeChildren(tasks: readonly TaskRecord[], parentTaskId: string, runGroupId: string): OpenCascadeChild[];
85
+ /**
86
+ * Fold a cascade parent own outcome and its children outcomes into one
87
+ * verdict: failure dominates, then cancellation, then success. The error text
88
+ * is the first failure, falling back to the first cancellation.
89
+ */
90
+ export declare function combineCascadeOutcome(entries: readonly {
91
+ result: ExecutionOutcome;
92
+ error?: string;
93
+ }[]): {
94
+ result: ExecutionOutcome;
95
+ error: string | undefined;
96
+ };
97
+ /**
98
+ * The permission a task would actually run under: its handover bundle's pin
99
+ * wins over the plain pin field, exactly as the runner resolves it.
100
+ */
101
+ export declare function effectiveTaskPermission(task: TaskRecord): TaskRecord['permission'];
102
+ /**
103
+ * Resolve the execution targets a (sub)task actually runs with: its own value
104
+ * wins, and an unset target inherits the nearest ancestor up to the root.
105
+ * Workspace, agent preset and model inherit the ancestor's PIN only — a
106
+ * handover bundle is a per-card continuation artefact and is never inherited.
107
+ * The permission inherits the ancestor's EFFECTIVE binding, and its human
108
+ * confirmation travels with it, so a subtask of an already-confirmed elevated
109
+ * card is runnable while a subtask's own unconfirmed binding stays gated.
110
+ */
111
+ /**
112
+ * The immutable teammate name for one team-mode member. Teammate names are
113
+ * lower-kebab-case and must stay unique for the lifetime of the Team, so the
114
+ * run-group token is appended: two runs of the same tree never collide. A title
115
+ * with no ASCII word characters (a CJK title, for example) keeps a stable
116
+ * generic prefix and is still distinguished by the token.
117
+ * @param title - the member task's title.
118
+ * @param token - the run group id (the task id when no group is recorded).
119
+ * @returns the teammate name handed to the Agent Teams service.
120
+ */
121
+ export declare function teammateName(title: string, token: string): string;
122
+ export declare function resolveExecutionTargets(task: TaskRecord, tasks: readonly TaskRecord[], maxSubtaskDepth?: number): TaskRecord;
@@ -8,6 +8,8 @@ import type { FreezeSnapshot } from './freeze-snapshot.ts';
8
8
  import type { TaskHandover, TaskHandoverInput } from './handover.ts';
9
9
  /** Task lifecycle status, one per kanban column. */
10
10
  export type TaskStatus = 'backlog' | 'todo' | 'running' | 'done' | 'failed';
11
+ /** Settled outcome of one execution attempt. */
12
+ export type ExecutionOutcome = 'succeeded' | 'failed' | 'cancelled';
11
13
  /**
12
14
  * One real execution attempt: the run's own id, the dsh session that ran it
13
15
  * (filled once the session is created), and the settled outcome once the
@@ -23,7 +25,7 @@ export interface ExecutionRecord {
23
25
  /** When the run settled; absent while still running. */
24
26
  endedAt: number | undefined;
25
27
  /** Outcome once settled. */
26
- result: 'succeeded' | 'failed' | 'cancelled' | undefined;
28
+ result: ExecutionOutcome | undefined;
27
29
  /** Human failure text when the run failed (prompt rejection or agent error). */
28
30
  error: string | undefined;
29
31
  /**
@@ -36,6 +38,20 @@ export interface ExecutionRecord {
36
38
  frozenAt?: number;
37
39
  /** Freeze source session captured from the card snapshot when the run opened. */
38
40
  frozenBy?: string;
41
+ /**
42
+ * Cascade run group shared by the parent execution and every descendant
43
+ * execution one run request opened. Absent on a plain single-task run.
44
+ */
45
+ runGroupId?: string;
46
+ /**
47
+ * A cascade parent's own session outcome, recorded as soon as its own turn
48
+ * settles and held while its subtask executions finish. The execution stays
49
+ * open (no `endedAt`) until the last child settles; the Host monitor skips
50
+ * an execution whose own outcome is already recorded.
51
+ */
52
+ ownResult?: ExecutionOutcome;
53
+ /** Human failure text that arrived with {@link ownResult}. */
54
+ ownError?: string;
39
55
  }
40
56
  /**
41
57
  * Maximum number of execution records retained per task. Older settled runs
@@ -140,6 +156,14 @@ export interface TaskRecord {
140
156
  description: string;
141
157
  /** The prompt sent to dsh when this task is executed. */
142
158
  prompt: string;
159
+ /**
160
+ * Parent task id: present only on a subtask. The Host owns the lineage gate
161
+ * (see `core/subtask.ts`), which refuses a cycle, an archived parent, and
162
+ * any link that would exceed `maxSubtaskDepth` — so every chain the Host
163
+ * wrote under the current setting is at most that many links long. Lowering
164
+ * the limit later neither rewrites nor deletes an already stored link.
165
+ */
166
+ parentId?: string;
143
167
  /** Current column. */
144
168
  status: TaskStatus;
145
169
  /** Creation instant (ms epoch). */
@@ -181,6 +205,15 @@ export interface TaskRecord {
181
205
  * {@link reusableSessionId}).
182
206
  */
183
207
  reuseSession?: boolean;
208
+ /**
209
+ * Run this task's subtree as an Agent Team instead of one Host-launched
210
+ * session per participant: the root becomes the Team Lead session and the
211
+ * Host spawns one teammate for each direct subtask inside it. Absent or false
212
+ * keeps the plain concurrent cascade. A deployment that does not serve the
213
+ * Agent Teams service refuses a team run instead of silently falling back,
214
+ * and a subtask's own permission pin cannot be honored in this mode.
215
+ */
216
+ teamRun?: boolean;
184
217
  /**
185
218
  * Frozen context snapshot for a continuation card; absent on plain tasks.
186
219
  * Sanitized before it enters the ledger (redaction, slash-command taint,
@@ -231,6 +264,12 @@ export interface NewTaskInput {
231
264
  title: string;
232
265
  description: string;
233
266
  prompt: string;
267
+ /**
268
+ * Parent task id, turning this creation into a subtask. Absent keeps a root
269
+ * task; the create use case validates the link (existence, depth) and
270
+ * inherits the parent's unset execution targets.
271
+ */
272
+ parentId?: string;
234
273
  /** Workspace the execution must run in; empty/absent = the recent workspace. */
235
274
  workspaceId?: string;
236
275
  /** Agent preset the execution session must be composed from; empty/absent = deployment default. */
@@ -241,6 +280,8 @@ export interface NewTaskInput {
241
280
  model?: string;
242
281
  /** Reuse the previous execution's session for later runs (issue #1419). */
243
282
  reuseSession?: boolean;
283
+ /** Run the subtree as an Agent Team (Team Lead session plus one teammate per direct subtask). */
284
+ teamRun?: boolean;
244
285
  /**
245
286
  * Optional scheduled-run rule requested at creation time (the new-task
246
287
  * dialog): an enable flag plus a 5-field cron expression. The create use
@@ -308,8 +349,10 @@ export declare function withSchedule(task: TaskRecord, patch: Partial<ScheduleRu
308
349
  /**
309
350
  * Open a fresh execution on a task: move it to 'running' and append a
310
351
  * running execution record. Returns the new task and the new execution.
352
+ * @param runGroupId - cascade run group, when this run also opened executions
353
+ * for the task's subtasks (see `core/subtask.ts`).
311
354
  */
312
- export declare function startExecution(task: TaskRecord, now: number, executionId: string, initiatedBy?: string): {
355
+ export declare function startExecution(task: TaskRecord, now: number, executionId: string, initiatedBy?: string, runGroupId?: string): {
313
356
  task: TaskRecord;
314
357
  execution: ExecutionRecord;
315
358
  };
@@ -318,6 +361,6 @@ export declare function startExecution(task: TaskRecord, now: number, executionI
318
361
  * matching column. No-op (returns the input task) when the execution is not
319
362
  * the task's latest or is already settled.
320
363
  */
321
- export declare function settleExecution(task: TaskRecord, executionId: string, outcome: 'succeeded' | 'failed' | 'cancelled', now: number, error: string | undefined): TaskRecord;
364
+ export declare function settleExecution(task: TaskRecord, executionId: string, outcome: ExecutionOutcome, now: number, error: string | undefined): TaskRecord;
322
365
  /** A settled-execution summary string for the detail view. */
323
366
  export declare function executionLabel(execution: ExecutionRecord): string;
@@ -1,9 +1,3 @@
1
- /**
2
- * Archive/restore task use case: move a task off the main board and back,
3
- * whatever its status but `running`. The task keeps its status, execution history, and
4
- * transcript references, while archiving disarms any schedule so it cannot
5
- * create more execution records until the user restores and re-enables it.
6
- */
7
1
  import type { TaskRecord } from '../tasks.ts';
8
2
  /** Result of an archive transition. */
9
3
  export interface ArchiveTaskResult {
@@ -13,11 +7,14 @@ export interface ArchiveTaskResult {
13
7
  archived: boolean;
14
8
  }
15
9
  /**
16
- * Archive one task: only a `running` task stays on the board (its runner
17
- * still owns its lifecycle until the execution settles); every other status
18
- * can be archived. Archiving disarms a schedule; already-archived tasks are
19
- * a no-op.
10
+ * Archive one task and its subtasks: only a running member keeps the group on
11
+ * the board (its runner still owns its lifecycle until the execution settles);
12
+ * any other status can be archived. Archiving disarms schedules; an
13
+ * already-archived task is a no-op.
14
+ */
15
+ export declare function applyArchiveTask(tasks: readonly TaskRecord[], id: string, now: number, maxSubtaskDepth?: number): ArchiveTaskResult;
16
+ /**
17
+ * Restore one task back onto the main board, together with its ancestors (an
18
+ * on-board subtask must not point at an archived parent) and its subtasks.
20
19
  */
21
- export declare function applyArchiveTask(tasks: readonly TaskRecord[], id: string, now: number): ArchiveTaskResult;
22
- /** Restore one task back onto the main board (clears the archive marker). */
23
- export declare function applyRestoreTask(tasks: readonly TaskRecord[], id: string, now: number): ArchiveTaskResult;
20
+ export declare function applyRestoreTask(tasks: readonly TaskRecord[], id: string, now: number, maxSubtaskDepth?: number): ArchiveTaskResult;
@@ -1,17 +1,26 @@
1
1
  import { type NewTaskInput, type TaskRecord } from '../tasks.ts';
2
2
  /** Result of a create transition: the new task (when accepted) + the next ledger. */
3
3
  export interface CreateTaskResult {
4
- /** The minted task, or undefined when the input was rejected (blank title). */
4
+ /** The minted task, or undefined when the input was rejected. */
5
5
  task: TaskRecord | undefined;
6
6
  /** The next ledger; identical reference when rejected. */
7
7
  tasks: readonly TaskRecord[];
8
+ /** Why the input was rejected; absent when a task was minted. */
9
+ error?: string;
8
10
  }
9
11
  /**
10
12
  * Apply a create against the current ledger. Returns the new task and the
11
- * appended ledger, or the unchanged ledger when the title is blank.
13
+ * appended ledger, or the unchanged ledger when the title is blank or the
14
+ * requested parent link is refused.
15
+ *
16
+ * A subtask inherits the execution targets its parent already pins (workspace,
17
+ * agent preset, permission, model) unless the form supplied its own; the
18
+ * parent human permission confirmation travels with an inherited permission,
19
+ * so a subtask of an already-confirmed elevated card is runnable at once.
12
20
  * @param tasks - current ledger.
13
- * @param input - raw user input (title/description/prompt + optional schedule).
21
+ * @param input - raw user input (title/description/prompt + optional schedule/parent).
14
22
  * @param now - clock instant (ms epoch).
15
23
  * @param id - minted task id.
24
+ * @param maxSubtaskDepth - deployment subtask depth limit.
16
25
  */
17
- export declare function applyCreateTask(tasks: readonly TaskRecord[], input: NewTaskInput, now: number, id: string): CreateTaskResult;
26
+ export declare function applyCreateTask(tasks: readonly TaskRecord[], input: NewTaskInput, now: number, id: string, maxSubtaskDepth?: number): CreateTaskResult;
@@ -1,7 +1,11 @@
1
1
  /**
2
2
  * Delete-task use case: drop a task from the ledger and clear the selection
3
3
  * when it pointed at the removed task. Pure ledger transition (no persistence
4
- * or notify — the controller orchestrates those).
4
+ * or notify - the controller orchestrates those).
5
+ *
6
+ * A task that still has subtasks is refused: deleting the parent would leave
7
+ * dangling child links, and silently detaching (or cascading) the children is
8
+ * a data-loss decision the user must make explicitly.
5
9
  */
6
10
  import type { TaskRecord } from '../tasks.ts';
7
11
  /** Result of a delete transition. */
@@ -10,6 +14,8 @@ export interface DeleteTaskResult {
10
14
  tasks: readonly TaskRecord[];
11
15
  /** Whether the previous selection referenced the removed task. */
12
16
  selectionCleared: boolean;
17
+ /** True when the task still carries subtasks, so nothing was removed. */
18
+ blocked: boolean;
13
19
  }
14
20
  /**
15
21
  * Apply a delete across the ledger. The selection (a task id) is cleared when
@@ -0,0 +1,21 @@
1
+ import type { TaskRecord } from '../tasks.ts';
2
+ /** Result of a parent-link transition. */
3
+ export interface SetParentResult {
4
+ /** The next ledger; the input reference when refused. */
5
+ tasks: readonly TaskRecord[];
6
+ /** Whether the link (or the detachment) was stored. */
7
+ applied: boolean;
8
+ /** User-facing refusal reason; absent when applied. */
9
+ error?: string;
10
+ }
11
+ /**
12
+ * Attach or detach one task. A null (or blank) parent detaches, which is always
13
+ * allowed for a known on-board task; attaching validates the whole chain so a
14
+ * cyclic or too-deep ledger can never be stored.
15
+ * @param tasks - current ledger.
16
+ * @param id - the task being moved.
17
+ * @param parentId - the new parent, or null to detach.
18
+ * @param now - clock instant (ms epoch).
19
+ * @param maxSubtaskDepth - deployment subtask depth limit.
20
+ */
21
+ export declare function applySetParent(tasks: readonly TaskRecord[], id: string, parentId: string | null, now: number, maxSubtaskDepth?: number): SetParentResult;
@@ -15,7 +15,7 @@ import type { TaskHandoverInput } from '../handover.ts';
15
15
  * Editable fields on a task (the update patch surface). `freeze` replaces the
16
16
  * continuation-card snapshot (restamping frozenAt); an explicit null clears it.
17
17
  */
18
- export type TaskUpdatePatch = Partial<Pick<TaskRecord, 'title' | 'description' | 'prompt' | 'workspaceId' | 'mode' | 'permission' | 'model' | 'reuseSession'>> & {
18
+ export type TaskUpdatePatch = Partial<Pick<TaskRecord, 'title' | 'description' | 'prompt' | 'workspaceId' | 'mode' | 'permission' | 'model' | 'reuseSession' | 'teamRun'>> & {
19
19
  freeze?: FreezeSnapshot & {
20
20
  redacted?: boolean;
21
21
  } | null;
@@ -0,0 +1,27 @@
1
+ import { type ToolDefinition } from '@deepseek-ai/dsh-tools';
2
+ import type { TaskBoardAction, TaskBoardSnapshot } from '../protocol.ts';
3
+ /**
4
+ * The narrow Host face the tools need. TaskBoardHostService satisfies it
5
+ * structurally, so tests and a future host can drive the same surface.
6
+ */
7
+ export interface TaskBoardToolHost {
8
+ /** Current board snapshot (tasks + scheduler + power + deployment constants). */
9
+ snapshot(): TaskBoardSnapshot;
10
+ /** Submit one confirmed Host action; returns the resulting snapshot. */
11
+ apply(requestId: string, action: TaskBoardAction, initiator?: string): TaskBoardSnapshot;
12
+ }
13
+ /** Registered tool names, in registration order. */
14
+ export declare const TASK_BOARD_TOOL_NAMES: readonly ["task_board_list", "task_board_get", "task_board_create", "task_board_update", "task_board_set_parent", "task_board_run", "task_board_manage", "task_board_schedule"];
15
+ /**
16
+ * The calling session id, for the execution audit trail (the same stamp the
17
+ * browser asserts). Absent when a call has no agent behind it.
18
+ */
19
+ export declare function callingSessionId(exec: {
20
+ agent?: unknown;
21
+ }): string | undefined;
22
+ /**
23
+ * Build every task-board tool bound to one Host service.
24
+ * @param host - the Host ledger/service face (TaskBoardHostService).
25
+ * @returns the tool definitions, in TASK_BOARD_TOOL_NAMES order.
26
+ */
27
+ export declare function buildTaskBoardTools(host: TaskBoardToolHost): ToolDefinition[];