@linxin666/dsh-client-ui-task-board 0.4.7 → 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 (75) hide show
  1. package/README.i18n.yaml +2 -2
  2. package/README.md +29 -22
  3. package/README.zh.md +29 -22
  4. package/lib/client.js +1553 -670
  5. package/lib/client.js.map +1 -1
  6. package/lib/index.js +757 -419
  7. package/lib/types/client/PluginSettingsCard.d.ts +60 -0
  8. package/lib/types/client/TaskBoardSettingsCard.d.ts +14 -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 +44 -6
  14. package/lib/types/client/suppress-schedule-row.d.ts +86 -0
  15. package/lib/types/client/telemetry.d.ts +14 -2
  16. package/lib/types/core/controller.d.ts +1 -1
  17. package/lib/types/core/execution-summary.d.ts +52 -0
  18. package/lib/types/core/extension.d.ts +34 -0
  19. package/lib/types/core/spend-budget.d.ts +28 -0
  20. package/lib/types/core/subtask.d.ts +59 -49
  21. package/lib/types/core/tasks.d.ts +37 -9
  22. package/lib/types/core/use-cases/task-update.d.ts +1 -1
  23. package/lib/types/core/workspace-target.d.ts +23 -3
  24. package/lib/types/host/launch-admission.d.ts +8 -9
  25. package/lib/types/host-ledger.d.ts +96 -50
  26. package/lib/types/host-routes.d.ts +49 -0
  27. package/lib/types/host-runner.d.ts +24 -11
  28. package/lib/types/host-service.d.ts +38 -50
  29. package/lib/types/host-spend.d.ts +52 -0
  30. package/lib/types/index.d.ts +70 -61
  31. package/lib/types/loopback.d.ts +41 -1
  32. package/lib/types/protocol.d.ts +0 -5
  33. package/lib/types/tool-surface.d.ts +1 -0
  34. package/package.json +25 -25
  35. package/src/client/CardDefaultPresetField.tsx +1 -1
  36. package/src/client/PluginSettingsCard.tsx +140 -20
  37. package/src/client/TaskBoardSettingsCard.tsx +104 -24
  38. package/src/client/board/ExecutionLog.tsx +140 -0
  39. package/src/client/board/LinkSubtaskModal.tsx +1 -9
  40. package/src/client/board/NewTaskModal.tsx +2 -11
  41. package/src/client/board/TaskCard.tsx +45 -23
  42. package/src/client/board/TaskDetail.tsx +407 -261
  43. package/src/client/board/TaskForm.tsx +19 -4
  44. package/src/client/board/VerificationReport.tsx +143 -104
  45. package/src/client/board/task-markdown.module.css +11 -8
  46. package/src/client/board-settings.module.css +35 -7
  47. package/src/client/board.module.css +855 -115
  48. package/src/client/body-mutations.ts +133 -0
  49. package/src/client/index.ts +10 -0
  50. package/src/client/locales.ts +101 -24
  51. package/src/client/settings-card.module.css +141 -11
  52. package/src/client/suppress-schedule-row.ts +198 -0
  53. package/src/client/telemetry.ts +47 -2
  54. package/src/core/controller.ts +1 -3
  55. package/src/core/execution-summary.ts +96 -0
  56. package/src/core/extension.ts +34 -0
  57. package/src/core/spend-budget.ts +35 -0
  58. package/src/core/store.ts +4 -0
  59. package/src/core/subtask.ts +81 -76
  60. package/src/core/tasks.ts +48 -10
  61. package/src/core/use-cases/task-update.ts +1 -3
  62. package/src/core/workspace-target.ts +27 -3
  63. package/src/host/agent-tools.ts +14 -15
  64. package/src/host/launch-admission.ts +8 -9
  65. package/src/host-ledger.ts +218 -127
  66. package/src/host-routes.ts +65 -2
  67. package/src/host-runner.ts +68 -35
  68. package/src/host-service.ts +136 -132
  69. package/src/host-spend.ts +105 -0
  70. package/src/index.ts +115 -104
  71. package/src/loopback.ts +57 -1
  72. package/src/protocol.ts +2 -9
  73. package/src/tool-surface.ts +1 -0
  74. package/lib/types/client/board/team-run-promotion.d.ts +0 -26
  75. package/src/client/board/team-run-promotion.ts +0 -39
@@ -0,0 +1,35 @@
1
+ /**
2
+ * The daily token ceiling both spend gates share, as pure rules: the cap
3
+ * comparison and the one refusal wording.
4
+ *
5
+ * The unit is tokens, not money. The usage ledger the board reads prices only
6
+ * DeepSeek's own routes, so a cost cap would read 0 on every other route and
7
+ * refuse nothing on exactly the deployments that need it. A cap of 0 is the
8
+ * shipped default and means "no gate": both gates answer before they read a
9
+ * file, subscribe to an event, or compute anything.
10
+ * @module @linxin666/dsh-task-board/core/spend-budget
11
+ */
12
+
13
+ /** Token cap one board day may spend; 0 disables the gate. */
14
+ export const DEFAULT_SPEND_BUDGET_TOKENS = 0
15
+
16
+ /**
17
+ * Whether a day's measured spend already reached the cap.
18
+ * @param usedTokens - tokens the day's spend measurement reported.
19
+ * @param cap - the configured cap, 0 for "no gate".
20
+ * @returns true when a run must be refused.
21
+ */
22
+ export function spendCapReached(usedTokens: number, cap: number): boolean {
23
+ return cap > 0 && usedTokens >= cap
24
+ }
25
+
26
+ /**
27
+ * The refusal text both gates report: the thrown message a client sees as
28
+ * board-refused, and the scheduler error a due occurrence records.
29
+ * @param usedTokens - tokens the day's spend measurement reported.
30
+ * @param cap - the configured cap.
31
+ * @returns the refusal message.
32
+ */
33
+ export function spendCapMessage(usedTokens: number, cap: number): string {
34
+ return `spend cap reached: ${usedTokens} tokens of ${cap} today; raise the cap in the task board settings`
35
+ }
package/src/core/store.ts CHANGED
@@ -12,6 +12,7 @@
12
12
  import { isValidCron, isValidTimeZone } from './schedule.ts'
13
13
  import { SCHEDULE_STOP_REASONS, isTaskPermission, isTaskStatus, normalizeTags, normalizeTargetId, type ScheduleRule, type ScheduleStopReason, type TaskFreeze, type TaskRecord, type TaskPermission, type TaskStatus } from './tasks.ts'
14
14
  import { isExecutionOutcome } from './subtask.ts'
15
+ import { normalizeExecutionSummary } from './execution-summary.ts'
15
16
  import type { TaskHandover } from './handover.ts'
16
17
  import { sanitizeFreezeSnapshot } from './freeze-snapshot.ts'
17
18
  import { sanitizeHandover } from './handover.ts'
@@ -256,6 +257,9 @@ export function parseLedger(raw: string | null): TaskRecord[] {
256
257
  runGroupId: normalizeTargetId(execution.runGroupId),
257
258
  ownResult: isExecutionOutcome(execution.ownResult) ? execution.ownResult : undefined,
258
259
  ownError: typeof execution.ownError === 'string' ? execution.ownError : undefined,
260
+ // A summary a reader does not recognize (an older document has none) is
261
+ // simply absent; a malformed one is dropped without costing the run.
262
+ summary: normalizeExecutionSummary(execution.summary),
259
263
  // A malformed acceptance block is dropped rather than dropping the
260
264
  // execution record: the board then treats that run as unverified.
261
265
  verification: normalizeVerification(execution.verification),
@@ -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
@@ -15,6 +15,29 @@ export type TaskStatus = 'backlog' | 'todo' | 'running' | 'done' | 'failed'
15
15
  /** Settled outcome of one execution attempt. */
16
16
  export type ExecutionOutcome = 'succeeded' | 'failed' | 'cancelled'
17
17
 
18
+ /**
19
+ * What one execution left behind: the text of the run's last assistant message
20
+ * and the session event it was read from.
21
+ *
22
+ * The board records a verdict per execution but no output, so a parent card
23
+ * could see that a subtask succeeded without seeing what it produced. Card
24
+ * content cannot answer that (it is the plan and freezes at the first
25
+ * execution), so the closing text rides the execution record instead.
26
+ */
27
+ export interface ExecutionSummary {
28
+ /** Last assistant message text of the run, bounded by {@link EXECUTION_SUMMARY_LIMIT}. */
29
+ text: string
30
+ /** Seq of the session event that text came from; absent text has no seq either. */
31
+ seq: number
32
+ }
33
+
34
+ /**
35
+ * Upper bound of one recorded summary, in characters. The ledger stores a
36
+ * conclusion, not a transcript: a reader that needs the whole message follows
37
+ * {@link ExecutionSummary.seq} into the session history.
38
+ */
39
+ export const EXECUTION_SUMMARY_LIMIT = 4000
40
+
18
41
  /**
19
42
  * One real execution attempt: the run's own id, the dsh session that ran it
20
43
  * (filled once the session is created), and the settled outcome once the
@@ -72,6 +95,16 @@ export interface ExecutionRecord {
72
95
  ownResult?: ExecutionOutcome
73
96
  /** Human failure text that arrived with {@link ownResult}. */
74
97
  ownError?: string
98
+ /**
99
+ * What this run left behind: the text of its last assistant message, taken
100
+ * when the settlement read the session and recorded with the verdict.
101
+ *
102
+ * Absent — never an empty string — when the session could not be read or
103
+ * carried no assistant prose, so "recorded nothing" stays distinguishable
104
+ * from "produced nothing". Settling never fails over it: a summary is
105
+ * informational, and every field above is what the board decides with.
106
+ */
107
+ summary?: ExecutionSummary
75
108
  /**
76
109
  * Goal acceptance state of this execution (task-board goal verification).
77
110
  * Fixed when the execution starts and never rewritten from later settings:
@@ -424,12 +457,11 @@ export interface TaskRecord {
424
457
  */
425
458
  reuseSession?: boolean
426
459
  /**
427
- * Run this task's subtree as an Agent Team instead of one Host-launched
428
- * session per participant: the root becomes the Team Lead session and the
429
- * Host spawns one teammate for each direct subtask inside it. Absent or false
430
- * keeps the plain concurrent cascade. A deployment that does not serve the
431
- * Agent Teams service refuses a team run instead of silently falling back,
432
- * 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.
433
465
  */
434
466
  teamRun?: boolean
435
467
  /**
@@ -556,8 +588,6 @@ export interface NewTaskInput {
556
588
  applyCardDefaults?: boolean
557
589
  /** Reuse the previous execution's session for later runs (issue #1419). */
558
590
  reuseSession?: boolean
559
- /** Run the subtree as an Agent Team (Team Lead session plus one teammate per direct subtask). */
560
- teamRun?: boolean
561
591
  /**
562
592
  * Start the execution with dsh's built-in `/goal`. Absent means the default
563
593
  * (one plain turn); only an explicit true joins the goal run.
@@ -720,7 +750,6 @@ export function createTask(input: NewTaskInput, now: number, id: string): TaskRe
720
750
  model: normalizeTargetId(input.model),
721
751
  reasoningEffort: normalizeTargetId(input.reasoningEffort),
722
752
  reuseSession: input.reuseSession === true ? true : undefined,
723
- teamRun: input.teamRun === true ? true : undefined,
724
753
  // Default OFF: only an explicit true is stored, so a card that never
725
754
  // touched the option (and every card written before the field existed)
726
755
  // keeps running one plain turn.
@@ -843,12 +872,21 @@ export function settleExecution(
843
872
  outcome: ExecutionOutcome,
844
873
  now: number,
845
874
  error: string | undefined,
875
+ summary?: ExecutionSummary,
846
876
  ): TaskRecord {
847
877
  const index = task.executions.findIndex(execution => execution.id === executionId)
848
878
  if (index === -1) return task
849
879
  const execution = task.executions[index]
850
880
  if (execution.endedAt !== undefined) return task
851
- const settled: ExecutionRecord = { ...execution, endedAt: now, result: outcome, error }
881
+ // A settle without one keeps whatever an earlier settle already recorded: a
882
+ // cascade parent's final fold has no session of its own to read.
883
+ const settled: ExecutionRecord = {
884
+ ...execution,
885
+ endedAt: now,
886
+ result: outcome,
887
+ error,
888
+ ...(summary === undefined ? {} : { summary }),
889
+ }
852
890
  const executions = [...task.executions]
853
891
  executions[index] = settled
854
892
  return { ...task, status: settledStatus(task, outcome), updatedAt: now, executions }
@@ -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
+ }
@@ -132,9 +132,12 @@ function executionView(execution: ExecutionRecord): Record<string, unknown> {
132
132
  ...(execution.initiatedBy === undefined ? {} : { initiatedBy: execution.initiatedBy }),
133
133
  // Set only by record-external-outcome: the Host observed no session for it.
134
134
  ...(execution.external === true ? { external: true } : {}),
135
+ // Every Host run joins a run group (single-member for a new run, and
136
+ // multi-member for a group the ledger stored before it stopped spreading one
137
+ // run across a subtree); the field keeps its historical name.
135
138
  ...(execution.runGroupId === undefined ? {} : { cascade: true }),
136
- // A deferred cascade parent has settled its own turn but still waits for
137
- // its subtasks; that is not a stuck card and the model must not retry it.
139
+ // A parent of a stored group has settled its own turn but still waits for
140
+ // its members; that is not a stuck card and the model must not retry it.
138
141
  ...(execution.ownResult === undefined
139
142
  ? {}
140
143
  : { ownResult: execution.ownResult, awaitingSubtasks: execution.endedAt === undefined }),
@@ -277,7 +280,7 @@ function buildSetParentTool(host: TaskBoardToolHost): ToolDefinition {
277
280
  description: [
278
281
  'Attach an existing task under a parent (making it a subtask) or detach it back to the root board by setting its parentId.',
279
282
  'Pass an empty parentId to detach.',
280
- 'The Host refuses the link when the parent is unknown or archived, when the moved task is one of its own descendants, when the resulting depth exceeds the deployment subtask limit (default one level, maximum three), or while the task has an unsettled execution (its link may still be a running cascade parent pointer).',
283
+ 'The Host refuses the link when the parent is unknown or archived, when the moved task is one of its own descendants, when the resulting depth exceeds the deployment subtask limit (default one level, maximum three), or while the task has an unsettled execution (its link may still be a stored run group parent pointer).',
281
284
  'Running a task opens one run group over its subtree concurrently and leaves a subtask that already sits in the done column alone; a parent card settles only after its own turn and every direct subtask it opened have settled.',
282
285
  ].join(' '),
283
286
  parameters: {
@@ -307,14 +310,13 @@ function buildRunTool(host: TaskBoardToolHost): ToolDefinition {
307
310
  name: 'task_board_run',
308
311
  description: [
309
312
  'Run a task on the board now, or re-run a settled one.',
310
- 'Running a task also runs its whole subtask tree CONCURRENTLY: the Host opens one real DSH session per member under one run group, each replaying its card pinned workspace, agent preset, permission and model; a subtask that does not pin them inherits its nearest ancestor.',
311
- 'The parent card stays in the running column until its own turn and every direct subtask have settled, and it fails when any member failed; one failing subtask never stops the others.',
313
+ 'Running a card opens ONE session for that card: no session is opened for its subtasks, and the card agent dispatches them itself with subagent. A card whose subtasks are still unfinished runs under the liangshen agent preset and is told which cards to pick up.',
314
+ 'Clicking a subtask runs that subtask as its own root, again without opening anything for its descendants.',
312
315
  'A card whose effective permission is above the deployment session default is refused with confirmation-required until a HUMAN confirms the binding in the board UI; this tool cannot confirm it.',
313
- 'A card whose task carries teamRun instead starts ONE Team Lead session and the Host spawns a teammate per subtask inside it, so those cards run as an Agent Team rather than as independent sessions; that mode needs the deployment Agent Teams service and is refused when it is missing.',
314
316
  'Executions consume real API quota. Sessions are created asynchronously, so read their ids and outcomes back with task_board_get.',
315
317
  ].join(' '),
316
318
  parameters: {
317
- taskId: { type: 'string', required: true, description: 'The task to run; running a root task runs its whole subtree, minus the subtasks that are already in the done column.' },
319
+ taskId: { type: 'string', required: true, description: 'The task to run; only this card gets a session, its unfinished subtasks are dispatched by that session own agent.' },
318
320
  rerun: { type: 'boolean', description: 'Re-run a settled task: reset its column to todo before starting (default false).' },
319
321
  },
320
322
  output: { schema: { type: 'json' }, render: renderJson },
@@ -341,7 +343,7 @@ function buildRunTool(host: TaskBoardToolHost): ToolDefinition {
341
343
  ok: true,
342
344
  started,
343
345
  ...(root === undefined ? {} : { task: taskSummary(root, snapshot.tasks, snapshot.sessionDefaultPermission) }),
344
- note: 'Executions run asynchronously; call task_board_get to read session ids and the settled outcome. The parent settles only after its own turn and every direct subtask settle.',
346
+ note: 'Executions run asynchronously; call task_board_get to read session ids and the settled outcome.',
345
347
  })
346
348
  } catch (error) {
347
349
  const message = messageOf(error)
@@ -358,7 +360,7 @@ function buildManageTool(host: TaskBoardToolHost): ToolDefinition {
358
360
  'Move, archive, restore, delete, or settle one task board card.',
359
361
  'move-backlog, move-todo, move-running, move-done and move-failed are the manual column moves and cover every column; a card the runner is executing (one with an open execution) cannot be moved.',
360
362
  'A manual move writes the card column only and never fabricates an execution record, so the card reports a declaration rather than evidence of a run: done/failed declare work finished (or failed) outside a Host-run execution — human work, an external system, a decision made elsewhere — and running says the work is under way without a tracked session. Use task_board_run when the work should actually run in a session here.',
361
- 'record-external-outcome is the record-backed version of move-done and move-failed: use it when YOU, or another agent outside this Host, actually finished or failed the card with your own model, so the terminal column and the run history both derive from one execution record. It takes result (succeeded or failed) and initiatedBy (who completed it, for example your own agent name) plus an optional summary, and it is refused while the card still has an open execution: the Host stays the only authority over a run it is executing. It cannot record running or cancelled — those remain Host-only.',
363
+ 'record-external-outcome is the record-backed version of move-done and move-failed: use it when YOU, or another agent outside this Host, actually finished or failed the card with your own model, so the terminal column and the run history both derive from one execution record. It takes result (succeeded or failed) and initiatedBy (who completed it, for example your own agent name) plus an optional summary, and it is refused while the card still has an open execution: the Host stays the only authority over a run it is executing. It cannot record running or cancelled — those remain Host-only. A parent card that dispatched its subtasks uses it once, at the end, to backfill every subtask card with the conclusion it reached; the Host records an inherited verdict on a subtask the parent never wrote back, so the write-back is what keeps each subtask conclusion its own.',
362
364
  'settle force-closes the open execution of a card the board can no longer observe (a stuck running card) and records it cancelled with the caller as the reason, so the card returns to the todo column and can be run again.',
363
365
  'reset-verification clears the acceptance anomalies (timeouts, authentication failures, an unresolvable judge route, or an attempt the time budget ended) recorded on a card open execution, so the next update_goal(action: complete) runs a fresh acceptance. It is refused unless that execution really carries such anomalies, it never clears a quality verdict, and a spent anomaly budget otherwise HOLDS the card open instead of failing it: tell the user the acceptance environment is unusable and that this action is how they clear it once they have fixed it.',
364
366
  'archive takes the whole subtask tree off the board and is refused while any member has an unsettled execution; restore brings the task, its ancestors and its subtree back; delete removes one card and is refused while it still has subtasks (detach or delete them first) or while it runs.',
@@ -459,7 +461,7 @@ function buildScheduleTool(host: TaskBoardToolHost): ToolDefinition {
459
461
  'Arm, change, or disarm a task scheduled runs. Two kinds of plan exist: a recurring 5-field cron rule (day-of-month and day-of-week follow Vixie semantics: both restricted means OR, otherwise AND), and a one-shot that runs once at a future instant.',
460
462
  'For a one-shot pass mode "once" with at (the planned instant, ms since epoch UTC). For a recurring rule pass mode "cron" (or omit mode) with a cron expression, optionally capped by maxRuns (a positive whole number of scheduled executions; omit for unlimited, pass 0 to clear a cap).',
461
463
  'The wall clock is read in the rule stored IANA time zone; omit timeZone to use the Host zone reported by task_board_list/task_board_get. DST gaps are skipped and an ambiguous fall-back time fires once, at the earlier instant.',
462
- 'A due scheduled task runs the same cascade a manual run does, so a root task runs its whole subtask tree minus the subtasks already in the done column.',
464
+ 'A due scheduled task runs exactly what a manual run of that card does: one session for the card, never one per subtask.',
463
465
  'The scheduler counts executions it actually starts; once a rule reaches its run budget it stops itself in the ledger, and a manual run never consumes the budget. A schedule whose tree contains an unconfirmed above-default permission is refused and does not consume the budget; the reason is reported in the list board summary as schedulerError.',
464
466
  'Missed occurrences during Host downtime are skipped, never queued (a one-shot whose instant passed while the Host was down is stopped as missed); a task that is already running skips its occurrence without consuming the budget.',
465
467
  ].join(' '),
@@ -566,7 +568,8 @@ function buildGetTool(host: TaskBoardToolHost): ToolDefinition {
566
568
  name: 'task_board_get',
567
569
  description: [
568
570
  'Read one task board card in full: prompt, description, labels, column, parent link, direct subtasks, execution targets, schedule, permission gate state, and the last ten execution attempts with their session ids and outcomes.',
569
- 'Use it before running or editing a card, and after a run to read the settled outcome.',
571
+ 'Use it before running or editing a card, after a run to read the settled outcome, and to read each subtask card before dispatching it with subagent.',
572
+ 'A card written before team runs were retired may still report teamRun: true; the field is history and never changes how the Host runs the card.',
570
573
  ].join(' '),
571
574
  parameters: {
572
575
  taskId: { type: 'string', required: true, description: 'Task id, as reported by task_board_list or task_board_create.' },
@@ -602,7 +605,6 @@ function buildCreateTool(host: TaskBoardToolHost): ToolDefinition {
602
605
  model: { type: 'string', description: 'Pinned model as provider/model (or a model id); omit to adopt the board new-card default, and the host default when none is configured.' },
603
606
  reasoningEffort: { type: 'string', description: 'Reasoning effort id for that model (an adapter-owned level such as "high"); omit to adopt the board new-card default for that model, and the model own default when none applies. Only an effort the target model declares is sent; an empty string clears it back to the default.' },
604
607
  reuseSession: { type: 'boolean', description: 'Continue later runs in the previous execution session instead of a fresh conversation.' },
605
- teamRun: { type: 'boolean', description: 'Run this task as an Agent Team: running it starts one Team Lead session and the Host spawns a teammate per subtask inside it. Omit or false for one independent session per member. Refused when the deployment serves no Agent Teams service.' },
606
608
  goalRun: { type: 'boolean', description: 'Start each run with dsh built-in /goal so the session keeps working continuation rounds until the goal completes. Off by default: omit (or pass false) for a single plain turn, and pass true to opt this card in. It only takes effect while the deployment global native /goal switch is on.' },
607
609
  skipVerification: { type: 'boolean', description: 'Run this task without the board acceptance gate: update_goal may mark the goal complete without a passing acceptance, and the execution record is marked skipped. Default false (omit to inherit the board-wide acceptance switch). Only affects executions started afterwards.' },
608
610
  tags: {
@@ -654,7 +656,6 @@ function buildCreateTool(host: TaskBoardToolHost): ToolDefinition {
654
656
  // targets the caller omitted are filled.
655
657
  applyCardDefaults: true,
656
658
  ...(args.reuseSession === true ? { reuseSession: true } : {}),
657
- ...(args.teamRun === true ? { teamRun: true } : {}),
658
659
  ...(args.goalRun === true ? { goalRun: true } : {}),
659
660
  ...(args.skipVerification === true ? { skipVerification: true } : {}),
660
661
  ...(tags.length === 0 ? {} : { tags }),
@@ -714,7 +715,6 @@ function buildUpdateTool(host: TaskBoardToolHost): ToolDefinition {
714
715
  model: { type: 'string', description: 'New pinned model; an empty string clears it.' },
715
716
  reasoningEffort: { type: 'string', description: 'New reasoning effort id for the pinned model; an empty string clears it back to the model own default. Only an effort the target model declares is sent at run time.' },
716
717
  reuseSession: { type: 'boolean', description: 'Continue later runs in the previous execution session.' },
717
- teamRun: { type: 'boolean', description: 'Switches this task between a plain cascade (one session per member) and an Agent Team run (Lead session plus a teammate per subtask).' },
718
718
  goalRun: { type: 'boolean', description: 'Whether each run starts with dsh built-in /goal (default false, one plain turn). Pass true to opt this card in, or false to return it to the default.' },
719
719
  skipVerification: { type: 'boolean', description: 'Whether this task runs without the board acceptance gate (default false, inherit the board-wide switch). Pass true to opt out; pass false to opt back in. Only affects executions started afterwards.' },
720
720
  tags: {
@@ -748,7 +748,6 @@ function buildUpdateTool(host: TaskBoardToolHost): ToolDefinition {
748
748
  patch.permission = args.permission === '' ? undefined : args.permission
749
749
  }
750
750
  if (has(args, 'reuseSession')) patch.reuseSession = args.reuseSession === true
751
- if (has(args, 'teamRun')) patch.teamRun = args.teamRun === true
752
751
  if (has(args, 'goalRun')) patch.goalRun = args.goalRun === true ? true : false
753
752
  if (has(args, 'skipVerification')) patch.skipVerification = args.skipVerification === true ? true : false
754
753
  if (has(args, 'tags')) {
@@ -1,19 +1,18 @@
1
1
  /**
2
2
  * Admission control for the session-creating half of a run.
3
3
  *
4
- * One board action can open a whole subtree, and a team run hands every member
5
- * of it to the Lead at once. Both paths used to fire every launch in the same
6
- * tick, so the Host asked DSH for N sessions at once — the burst the repository's
7
- * measured guidance caps at three heavy implementation subagents
8
- * (docs/multi-agent-resources.md), with no mechanism enforcing it.
4
+ * A run opens one session, so the burst this bounds is several runs starting at
5
+ * once — several cards run from different tabs, or a due schedule firing while
6
+ * a manual run is still launching. Unbounded, the Host asks DSH for N sessions
7
+ * in the same tick: the burst the repository's measured guidance caps at three
8
+ * heavy implementation subagents (docs/multi-agent-resources.md), with no
9
+ * mechanism enforcing it.
9
10
  *
10
11
  * The queue is SERVICE-wide, not per run group: the pressure it bounds is the
11
12
  * machine's (the Host process's memory and the swap it drives), and two run
12
13
  * groups opened from two tabs share one Host. Admission is round-robin across
13
- * run groups — FIFO inside a group, so a group's first run (the Lead, which
14
- * carries the run shape and the teammate namespace) always starts before its
15
- * members — so a large subtree cannot starve a run opened after it, and no
16
- * entry can be starved.
14
+ * run groups — FIFO inside a group — so one run cannot starve another opened
15
+ * after it, and no entry can be starved.
17
16
  *
18
17
  * The width is read through a live callback, so a settings edit takes effect on
19
18
  * the next admission without remounting anything.