@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
@@ -3,7 +3,7 @@ import type { IncomingMessage, ServerResponse } from 'node:http'
3
3
  import type { WebRoute } from '@deepseek-ai/dsh-host-webserver'
4
4
  import type { TaskBoardHostService } from './host-service.ts'
5
5
  import { writeJson } from './http.ts'
6
- import { isLoopbackAddress, isLoopbackRequest } from './loopback.ts'
6
+ import { isForwardedLoopbackRequest, isLoopbackAddress, isLoopbackRequest } from './loopback.ts'
7
7
  import { TaskParseError, TASK_PARSE_MAX_INPUT } from './host-ai.ts'
8
8
  import {
9
9
  parseActionEnvelope,
@@ -20,10 +20,40 @@ const HEARTBEAT_MS = 15_000
20
20
  /** Header replaced by an authenticated same-host reverse proxy. */
21
21
  export const TASK_BOARD_PROXY_TOKEN_HEADER = 'x-dsh-task-board-proxy-token'
22
22
 
23
+ /**
24
+ * The composition's Host connection service, narrowed to the one check the
25
+ * board bridges: `requestRejection` runs the Host/Origin fence and verifies
26
+ * the authority-bound `dsh-auth-*` browser session minted by the Host. It
27
+ * answers `undefined` only for a request it admits and 401/403 otherwise.
28
+ * Declared structurally, like the official open-in-app routes do, because the
29
+ * service's package is a browser-side dependency this Host half does not
30
+ * import.
31
+ */
32
+ export interface TaskBoardConnectionTrust {
33
+ requestRejection(request: { readonly headers: IncomingMessage['headers'] }): 401 | 403 | undefined
34
+ }
35
+
23
36
  /** Optional authenticated reverse-proxy access layered over the loopback default. */
24
37
  export interface TaskBoardRouteAccess {
25
38
  trustedProxyHosts?: readonly string[]
26
39
  proxyToken?: string
40
+ /**
41
+ /**
42
+ * Whether the operator's own reverse proxy or tunnel may speak for the
43
+ * browser: a forwarded request that landed on this machine's loopback
44
+ * upstream then counts as trustable, still behind the browser same-origin
45
+ * marker. Read at each request (hence the function), so the settings switch
46
+ * binds the next request without re-registering the routes. Absent or false
47
+ * keeps the pre-existing fence exactly as it was (issue #1906).
48
+ */
49
+ trustForwardedProxy?: () => boolean
50
+ /**
51
+ * Resolves the Host's `connection` service when a request arrives, so a
52
+ * deployment that mounts it after these routes still gains the bridge and a
53
+ * composition that never mounts it keeps the pre-existing fence. Absent means
54
+ * no bridge (issue #1930).
55
+ */
56
+ connection?: () => TaskBoardConnectionTrust | undefined
27
57
  }
28
58
 
29
59
  /**
@@ -39,6 +69,8 @@ export interface TaskBoardRouteOptions {
39
69
  interface ResolvedRouteAccess {
40
70
  trustedProxyHosts: ReadonlySet<string>
41
71
  proxyToken?: string
72
+ trustForwardedProxy: () => boolean
73
+ connection?: () => TaskBoardConnectionTrust | undefined
42
74
  }
43
75
 
44
76
  function parseAuthority(authority: string): { canonical: string; url: URL } | undefined {
@@ -70,7 +102,12 @@ function resolveAccess(access: TaskBoardRouteAccess): ResolvedRouteAccess {
70
102
  if (trustedProxyHosts.size > 0 && (access.proxyToken === undefined || access.proxyToken === '')) {
71
103
  throw new Error('task-board: authenticated proxy hosts require a non-empty proxy token')
72
104
  }
73
- return { trustedProxyHosts, ...(access.proxyToken === undefined ? {} : { proxyToken: access.proxyToken }) }
105
+ return {
106
+ trustedProxyHosts,
107
+ trustForwardedProxy: access.trustForwardedProxy ?? ((): boolean => false),
108
+ ...(access.proxyToken === undefined ? {} : { proxyToken: access.proxyToken }),
109
+ ...(access.connection === undefined ? {} : { connection: access.connection }),
110
+ }
74
111
  }
75
112
 
76
113
  /**
@@ -146,10 +183,36 @@ function matchesToken(candidate: string | string[] | undefined, expected: string
146
183
  * tripwire, the socket/Host/origin-equality checks carry the authority).
147
184
  * Authenticated proxies must be explicitly allowlisted and replace the
148
185
  * internal token header after their own authentication step.
186
+ *
187
+ * A third party's proxy cannot inject that token, so a deployment whose own
188
+ * tunnel dials the loopback upstream (issue #1918) can instead turn on
189
+ * trustForwardedProxy: a forwarded request that landed on this machine
190
+ * (loopback socket AND loopback Host) is then admitted on the same browser
191
+ * marker alone. The switch defaults off, so an unconfigured board keeps
192
+ * refusing every forwarded request (issue #1906).
193
+ *
194
+ * A deployment behind a reverse proxy or ingress that DSH itself serves
195
+ * (`--trusted-host`, TLS terminated at the edge) is admitted by the Host's
196
+ * `connection` service instead: a request whose Host/Origin fence and signed
197
+ * browser session it accepts needs no board-specific allowlist, which is why
198
+ * the check runs first when the service is mounted (issue #1930). The fence
199
+ * below stays untouched as the fallback, so a deployment without the service,
200
+ * and every direct client the service does not admit, keeps exactly the
201
+ * pre-existing decision.
149
202
  */
150
203
  export function isTrustedTaskBoardRequest(req: IncomingMessage, access: ResolvedRouteAccess): boolean {
204
+ const connection = access.connection?.()
205
+ if (connection !== undefined && connection.requestRejection(req) === undefined) return true
151
206
  if (!browserSameOriginMarker(req)) return false
152
207
  if (isLoopbackRequest(req)) return true
208
+ // The tunnel makes the socket and the Host describe the proxy, so the
209
+ // origin-equality check of the direct fence has nothing to compare on this
210
+ // path; the explicit cross-site marker is then the one signal that separates
211
+ // the operator's own page from a third-party page posting through the tunnel,
212
+ // and it is refused instead of being read as a mere tripwire.
213
+ if (access.trustForwardedProxy()
214
+ && req.headers['sec-fetch-site'] !== 'cross-site'
215
+ && isForwardedLoopbackRequest(req)) return true
153
216
  if (!isLoopbackAddress(req.socket.remoteAddress)) return false
154
217
  const host = req.headers.host
155
218
  if (typeof host !== 'string') return false
@@ -3,8 +3,8 @@ import type { InvokeRemoteRequest, TypertGateway } from '@deepseek-ai/dsh-api-ga
3
3
  import type { SessionAddress, SessionHistoryRecord, SessionListValue, SessionPage, SessionSummary } from '@deepseek-ai/dsh-api-session-controller/types'
4
4
  import type { CommandResult } from '@deepseek-ai/dsh-commands/types'
5
5
  import type { Workspace } from '@deepseek-ai/dsh-workspace/types'
6
- import { teammateName } from './core/subtask.ts'
7
- import { mostRecentWorkspaceId } from './core/workspace-target.ts'
6
+ import { LIANGSHEN_PRESET_ID } from './core/subtask.ts'
7
+ import { MISSING_WORKSPACE_REASON, mostRecentWorkspaceId } from './core/workspace-target.ts'
8
8
  import { declaredRoute, normalizeReasoningEffort, resolveReasoningEffort, type ReasoningRoute } from './core/reasoning-effort.ts'
9
9
  import type { ModelCatalogView } from './core/verification.ts'
10
10
  import type { ExecutionSummary, TaskPermission, TaskRecord } from './core/tasks.ts'
@@ -202,22 +202,24 @@ function escapeProvenanceDelimiter(value: string): string {
202
202
  * first, the provenance wrap then encloses the instruction. Plain tasks (no
203
203
  * freeze) keep the bare handover preamble + prompt.
204
204
  */
205
- /** One other execution member of a run, as named in the launched task's prompt. */
206
- export interface PromptPeer {
207
- /** Task id of the member. */
205
+ /** One unfinished subtask the launched card's own agent has to dispatch. */
206
+ export interface PromptDescendant {
207
+ /** Task id of the subtask card. */
208
208
  id: string
209
- /** Member title. */
209
+ /** Subtask title. */
210
210
  title: string
211
- /** Teammate name when this member runs as a teammate. */
212
- name?: string
211
+ /** Its column, so the run can tell a fresh card from one already failed before. */
212
+ status: string
213
213
  }
214
214
 
215
215
  /** Execution-shape context appended to the launched task's prompt. */
216
216
  export interface PromptContext {
217
- /** The other members this run opens, excluding the launched task itself. */
218
- peers?: readonly PromptPeer[]
219
- /** True when those members run as teammates inside this session (Team Lead). */
220
- team?: boolean
217
+ /**
218
+ * The card's outstanding descendants. Present exactly when this run is an
219
+ * autonomous dispatch: the Host opens no session for them, so this session
220
+ * reads them and dispatches subagents itself.
221
+ */
222
+ descendants?: readonly PromptDescendant[]
221
223
  /**
222
224
  * Scheduled-run provenance: the instant the rule actually fired, its kind,
223
225
  * and the IANA zone its wall clock was read in. Present only for a
@@ -228,19 +230,18 @@ export interface PromptContext {
228
230
  }
229
231
 
230
232
  /**
231
- * The execution-shape section: what else this run opens. A plain cascade opens
232
- * one independent session per member; a team run starts every other member as a
233
- * teammate inside THIS session, so the prompt names the Team tools instead.
233
+ * The dispatch section: this run is the card's own session, and the card still
234
+ * has unfinished subtasks. The Host opens no session for them, so the prompt
235
+ * states what the session must do itself — read each card, dispatch subagents
236
+ * in dependency order, and write the conclusions back before finishing. A card
237
+ * with no outstanding descendant gets no section at all.
234
238
  */
235
- function peerPromptPreamble(context: PromptContext): string | undefined {
236
- const peers = context.peers ?? []
237
- if (peers.length === 0) return undefined
238
- if (context.team === true) {
239
- const lines = peers.map(peer => `- ${escapeProvenanceDelimiter(peer.title)}(teammate: ${peer.name ?? teammateName(peer.title, peer.id, peer.id)})`)
240
- return `本任务是 Agent Team 的 Lead:本次运行不额外开启独立会话,以下 ${peers.length} 个子任务成员已在本会话中作为 teammate 启动。用 list_agents / send_message / wait_agent 协调它们,用任务看板工具读写它们在看板上的卡片:\n${lines.join('\n')}`
241
- }
242
- const lines = peers.map(peer => `- ${escapeProvenanceDelimiter(peer.title)}(任务 ${peer.id})`)
243
- return `本次运行同时并发开启 ${peers.length} 个独立 DSH 会话执行下列子任务成员(可用 task_board_* 工具查看它们的进度):\n${lines.join('\n')}`
239
+ function dispatchPromptPreamble(context: PromptContext): string | undefined {
240
+ const descendants = context.descendants ?? []
241
+ if (descendants.length === 0) return undefined
242
+ const lines = descendants.map(descendant =>
243
+ `- ${escapeProvenanceDelimiter(descendant.title)}(任务 ${descendant.id},状态 ${descendant.status})`)
244
+ return `本卡还有 ${descendants.length} 个未完成的子任务,本次执行不会为它们额外开启会话,由你在本会话内自行派发:\n${lines.join('\n')}\n先用 task_board_get 读取每张子卡的内容与执行目标,再用 subagent 按依赖顺序派发(互不依赖的可以并发),完工前用 task_board_manage({action:'record-external-outcome', result, initiatedBy, summary}) 一次性回填各子卡的结论。`
244
245
  }
245
246
 
246
247
  /**
@@ -279,7 +280,7 @@ export function promptText(task: TaskRecord, context: PromptContext = {}): strin
279
280
  const tagPreamble = tagPromptPreamble(task)
280
281
  const handoverSection = handoverPreamble
281
282
  const schedulePreamble = schedulePromptPreamble(context)
282
- const runPreamble = peerPromptPreamble(context)
283
+ const runPreamble = dispatchPromptPreamble(context)
283
284
  const preambles = [tagPreamble, handoverSection, schedulePreamble, runPreamble]
284
285
  .filter((part): part is string => part !== undefined)
285
286
  const preamble = preambles.length === 0 ? undefined : preambles.join('\n\n')
@@ -435,6 +436,14 @@ export class HostExecutionRunner {
435
436
  async launch(task: TaskRecord, options: {
436
437
  reuseSessionId?: string
437
438
  promptContext?: PromptContext
439
+ /**
440
+ * Agent preset this execution is FORCED under, overriding the card's own
441
+ * `mode` pin (and a handover bundle's): the caller decides it from the run's
442
+ * shape (a card with unfinished subtasks runs as the autonomous dispatcher),
443
+ * and the override is never written into the card. A preset the deployment
444
+ * does not register fails the launch before any session exists.
445
+ */
446
+ agentPreset?: string
438
447
  onSession?: (sessionId: string) => void
439
448
  onGoalArmed?: (armed: boolean) => void
440
449
  /**
@@ -463,9 +472,10 @@ export class HostExecutionRunner {
463
472
  // card that pins nothing is resolved to the deployment's most recently used
464
473
  // workspace instead of being left to `session.create`, whose own fallback is
465
474
  // the Host process working directory (the desktop app's profile directory) —
466
- // never the project the user was in when the card was written.
475
+ // never the project the user was in when the card was written. A deployment
476
+ // with no workspace to offer gets a refusal below, not that fallback.
467
477
  const workspaceId = task.handover?.workspaceId ?? task.workspaceId ?? this.recentWorkspaceId()
468
- const mode = task.handover?.mode ?? task.mode
478
+ const mode = options.agentPreset ?? task.handover?.mode ?? task.mode
469
479
  const permission = task.handover?.permission ?? task.permission
470
480
 
471
481
  if (workspaceId !== undefined && this.workspaceRegistry !== undefined) {
@@ -476,6 +486,14 @@ export class HostExecutionRunner {
476
486
  if (mode !== undefined) {
477
487
  const presets = await this.invoke('agentPresets', 'list', {}) as { presets?: readonly { id: string; broken?: string }[] }
478
488
  const preset = presets.presets?.find(item => item.id === mode)
489
+ // A forced preset is the run's shape, not a stored preference: a
490
+ // deployment that does not serve it (the `liangshen` dispatcher preset is
491
+ // shipped by packages/dsh-liangshen) cannot run this card the way its tree
492
+ // requires, so the run fails closed with the reason readable on the card.
493
+ if (preset === undefined && options.agentPreset !== undefined) {
494
+ throw new Error('agent preset not found: ' + mode + ' (a card with unfinished subtasks runs under the '
495
+ + LIANGSHEN_PRESET_ID + ' preset, which this deployment does not serve)')
496
+ }
479
497
  if (preset === undefined) throw new Error('agent preset not found: ' + mode)
480
498
  if (preset.broken !== undefined) throw new Error('agent preset is unavailable: ' + preset.broken)
481
499
  }
@@ -503,8 +521,15 @@ export class HostExecutionRunner {
503
521
  }
504
522
  return reused
505
523
  }
524
+ // Nothing names a workspace and the deployment has none to resolve to, so
525
+ // there is no place this run may legitimately start: `session.create` would
526
+ // quietly land it in the Host process working directory (the desktop app's
527
+ // profile directory). Refuse before the session exists, with the reason the
528
+ // board settles the card with and the browser renders in the user's
529
+ // language, so the fix (pick a workspace on the card) is what the user reads.
530
+ if (workspaceId === undefined) throw new Error(MISSING_WORKSPACE_REASON)
506
531
  const created = await this.invoke('session', 'create', {
507
- ...(workspaceId === undefined ? {} : { workspaceId }),
532
+ workspaceId,
508
533
  ...(mode === undefined ? {} : { agentPreset: mode }),
509
534
  }) as { sessionId: ExecutionSessionId }
510
535
  const sessionId = created.sessionId
@@ -6,8 +6,8 @@ import { DEFAULT_SESSION_POLL_SECONDS, normalizeSessionPollSeconds, sessionPollM
6
6
  import { reusableSessionId } from './core/session-reuse.ts'
7
7
  import { LaunchAdmissionQueue, type QueuedLaunch } from './host/launch-admission.ts'
8
8
  import { HostTaskLedger, type OpenedRun, type OpenExecutionReference } from './host-ledger.ts'
9
- import { HostExecutionRunner, SessionLaunchError, promptText, type GatewayPeer, type SessionCommandDispatcher, type SessionSummary, type TaskBoardWorkspaceRegistry } from './host-runner.ts'
10
- import { teammateName } from './core/subtask.ts'
9
+ import { HostExecutionRunner, SessionLaunchError, type GatewayPeer, type SessionCommandDispatcher, type SessionSummary, type TaskBoardWorkspaceRegistry } from './host-runner.ts'
10
+ import { LIANGSHEN_PRESET_ID } from './core/subtask.ts'
11
11
  import { workspaceOwningSession } from './core/workspace-target.ts'
12
12
  import { PowerInhibitor } from './power-inhibitor.ts'
13
13
  import { TASK_BOARD_SCHEMA_VERSION, type TaskBoardAction, type TaskBoardEventPayload, type TaskBoardSnapshot } from './protocol.ts'
@@ -18,36 +18,6 @@ import { isTaskPermission, normalizeTargetId, type ExecutionOutcome, type Execut
18
18
  import { passedAttempt, resolveContract, verificationNeverInvoked, verificationOnlyInvalid, verificationRequired, withAcceptanceDetailCleared, type ExecutionVerification, type ModelCatalogView, type VerificationContract, type VerificationSettings } from './core/verification.ts'
19
19
  import type { TaskPermission } from './core/handover.ts'
20
20
 
21
- /** One teammate the Host asks the Agent Teams service to spawn for a team run. */
22
- export interface TeamSpawnInput {
23
- /** Session id of the run's Team Lead (the root task's execution session). */
24
- leadSessionId: string
25
- /** Immutable lower-kebab-case teammate name, unique inside the Team. */
26
- name: string
27
- /** Short description of the delegated responsibility. */
28
- description: string
29
- /** The subtask's execution prompt. */
30
- prompt: string
31
- }
32
-
33
- /** Result of one teammate spawn attempt. */
34
- export interface TeamSpawnResult {
35
- /** The teammate's session id when it reached the active edge. */
36
- sessionId?: string
37
- /** Why the spawn failed: a thrown call, or a member that settled as failed. */
38
- error?: string
39
- }
40
-
41
- /**
42
- * The Agent Teams capability the Host needs for team-mode runs. The plugin
43
- * builds it from the optional `agentTeams` service; it is absent when this
44
- * deployment does not serve that service, in which case a team run is refused
45
- * instead of silently degrading into a plain cascade.
46
- */
47
- export interface TaskBoardTeamDispatcher {
48
- spawn(input: TeamSpawnInput): Promise<TeamSpawnResult>
49
- }
50
-
51
21
  /** Ceiling for the roster-poll failure backoff: a broken session tree is retried at most once a minute. */
52
22
  const POLL_FAILURE_MAX_BACKOFF_MS = 60_000
53
23
  /**
@@ -125,7 +95,7 @@ export const NEVER_INVOKED_VERIFICATION_REASON = 'goal 验收未触发:本次
125
95
  export const INVALID_ONLY_VERIFICATION_REASON = 'goal 验收无效:本次执行只记录了无效验收(裁判未能给出与任务要求对应、且可定位到本次证据的否决依据),看板已停止调用裁判。这**不是**有证据的质量判负:验收本身不可用,本次运行因没有匹配的通过记录而结束。请检查验收环境与证据可见性,或用 task_board_manage(action=reset-verification) 清除记录的无效验收后重新完成目标。'
126
96
 
127
97
  /**
128
- * Provenance of one cron-triggered cascade: when the rule fired and the zone
98
+ * Provenance of one cron-triggered run: when the rule fired and the zone
129
99
  * its wall clock was read in. Passed into every launched prompt of that run so
130
100
  * a scheduled job knows its own clock rather than inferring one.
131
101
  */
@@ -266,7 +236,6 @@ export class TaskBoardHostService {
266
236
  private preventIdleSleep = false
267
237
  private readonly verificationSettings: () => VerificationSettings
268
238
  private readonly verificationCatalog: () => Promise<ModelCatalogView | undefined>
269
- private readonly team: TaskBoardTeamDispatcher | undefined
270
239
  private readonly timers: HostTimerFace
271
240
  /** Live reader of the global native-/goal switch; frozen per execution. */
272
241
  private readonly goalRunEnabled: () => boolean
@@ -322,7 +291,6 @@ export class TaskBoardHostService {
322
291
  * without remounting the row. Absent means the deployment configures none.
323
292
  */
324
293
  cardDefaults?: () => CardDefaults
325
- team?: TaskBoardTeamDispatcher
326
294
  timers?: HostTimerFace
327
295
  /**
328
296
  * Live GLOBAL native /goal switch (a volatile config read). Read ONCE per
@@ -369,7 +337,6 @@ export class TaskBoardHostService {
369
337
  })
370
338
  this.runner = new HostExecutionRunner(gateway, options.commandDispatcher, options.workspaceRegistry, undefined, options.ownerPeer)
371
339
  this.workspaceRegistry = options.workspaceRegistry
372
- this.team = options.team
373
340
  this.timers = options.timers ?? PROCESS_TIMERS
374
341
  this.power = options.power ?? new PowerInhibitor()
375
342
  this.now = options.now ?? Date.now
@@ -478,7 +445,6 @@ export class TaskBoardHostService {
478
445
  power: this.power.snapshot(),
479
446
  sessionDefaultPermission: this.ledger.sessionDefaultPermission,
480
447
  maxSubtaskDepth: this.ledger.maxSubtaskDepth,
481
- teamRunAvailable: this.team !== undefined,
482
448
  // The GLOBAL native-/goal switch is published live for the UI, but the
483
449
  // service freezes its own read at launch: this mirror is for the FORM
484
450
  // (enable/disable + explanation), never for a run already in flight.
@@ -591,13 +557,6 @@ export class TaskBoardHostService {
591
557
  */
592
558
  private applyBoardAction(requestId: string, action: Exclude<TaskBoardAction, { kind: 'extension-action' }>, initiator?: string): TaskBoardSnapshot {
593
559
  const before = this.statusMap()
594
- // Fail closed before the ledger opens anything: a card opted into team
595
- // execution cannot run in a deployment that serves no Agent Teams service,
596
- // and silently degrading it to a plain cascade would misreport the work.
597
- if (this.team === undefined && (action.kind === 'run' || action.kind === 'rerun')) {
598
- const task = this.ledger.state().tasks.find(item => item.id === action.taskId)
599
- if (task?.teamRun === true) throw new Error('Agent Teams is unavailable in this deployment')
600
- }
601
560
  if (action.kind === 'run' || action.kind === 'rerun') this.assertSpendCap()
602
561
  const result = this.ledger.applyRequest(requestId, this.withInheritedWorkspace(action, initiator), initiator)
603
562
  if (result.runs !== undefined) this.dispatchRuns(result.runs)
@@ -687,27 +646,31 @@ export class TaskBoardHostService {
687
646
  this.listeners.clear()
688
647
  }
689
648
 
690
- private async launch(opened: OpenedRun, others: readonly OpenedRun[] = [], schedule?: ScheduledRunContext, freezeContract?: RunContractFreezer): Promise<void> {
649
+ private async launch(opened: OpenedRun, schedule?: ScheduledRunContext, freezeContract?: RunContractFreezer): Promise<void> {
691
650
  /** The session this launch attached to the execution, once it exists. */
692
651
  let attached: string | undefined
693
652
  try {
694
- // A team run always mints a fresh Lead session: teammates are immutable
695
- // children of that session, so reusing an older one would collide on
696
- // their names and orphan the previous team.
697
- const team = opened.task.teamRun === true
698
- const reuseSessionId = team ? undefined : await this.reuseSessionFor(opened.task)
699
- // Both modes tell the launched agent what else this run opens; only a team
700
- // run names teammates, because only then does this session own them.
701
- const peers = others.length === 0 ? undefined : others.map(other => ({
702
- id: other.task.id,
703
- title: other.task.title,
704
- ...(team ? { name: teammateName(other.task.title, other.execution.runGroupId ?? other.task.id, other.task.id) } : {}),
705
- }))
653
+ // One run opens ONE session: the card's own. Its unfinished subtasks are
654
+ // dispatched from inside that session, so a card that carries them is
655
+ // forced under the dispatcher preset and told which cards to pick up. The
656
+ // force is applied here, per execution; the card's stored `mode` is
657
+ // never rewritten by it.
658
+ const forcedPreset = this.ledger.hasOutstandingDescendants(opened.task.id) ? LIANGSHEN_PRESET_ID : undefined
659
+ const descendants = forcedPreset === undefined ? [] : this.ledger.outstandingDescendants(opened.task.id)
660
+ // A forced preset is not the card's own composition, so continuing a
661
+ // session composed from another preset would be refused anyway: mint a
662
+ // fresh one and run the tree the way this execution requires.
663
+ const reuseSessionId = forcedPreset === undefined ? await this.reuseSessionFor(opened.task) : undefined
706
664
  // A cron-triggered run additionally states its own firing instant and
707
665
  // rule zone, so a scheduled job can resolve "today" without guessing.
708
- const promptContext = peers === undefined && schedule === undefined ? undefined : {
709
- ...(peers === undefined ? {} : { peers }),
710
- ...(team ? { team: true } : {}),
666
+ const promptContext = descendants.length === 0 && schedule === undefined ? undefined : {
667
+ ...(descendants.length === 0 ? {} : {
668
+ descendants: descendants.map(descendant => ({
669
+ id: descendant.id,
670
+ title: descendant.title,
671
+ status: descendant.status,
672
+ })),
673
+ }),
711
674
  ...(schedule === undefined ? {} : { schedule }),
712
675
  }
713
676
  // Freeze this execution's acceptance contract BEFORE the session is
@@ -748,11 +711,12 @@ export class TaskBoardHostService {
748
711
  const initial: ExecutionVerification = {
749
712
  contract,
750
713
  attempts: [],
751
- applicability: team ? 'team-member' : !contract.enabled ? skippedBy : notArmed,
714
+ applicability: !contract.enabled ? skippedBy : notArmed,
752
715
  }
753
716
  this.ledger.setVerification(opened.task.id, opened.execution.id, initial)
754
717
  const sessionId = await this.runner.launch(opened.task, {
755
718
  ...(reuseSessionId === undefined ? {} : { reuseSessionId }),
719
+ ...(forcedPreset === undefined ? {} : { agentPreset: forcedPreset }),
756
720
  ...(promptContext === undefined ? {} : { promptContext }),
757
721
  // The frozen global switch travels with the launch, so the runner's
758
722
  // arming decision is exactly the one made above.
@@ -766,13 +730,10 @@ export class TaskBoardHostService {
766
730
  this.ledger.attachSession(opened.task.id, opened.execution.id, id)
767
731
  },
768
732
  onGoalArmed: (armed) => {
769
- this.setApplicability(opened.task.id, opened.execution.id, team
770
- ? 'team-member'
771
- : !contract.enabled ? skippedBy : armed ? 'enforced' : notArmed)
733
+ this.setApplicability(opened.task.id, opened.execution.id, !contract.enabled ? skippedBy : armed ? 'enforced' : notArmed)
772
734
  },
773
735
  })
774
736
  if (attached === undefined) this.ledger.attachSession(opened.task.id, opened.execution.id, sessionId)
775
- if (team) for (const teammate of others) this.scheduleTeammate(teammate, sessionId)
776
737
  } catch (error) {
777
738
  const launchedSession = error instanceof SessionLaunchError ? error.sessionId : undefined
778
739
  if (launchedSession !== undefined) {
@@ -833,42 +794,6 @@ export class TaskBoardHostService {
833
794
  this.refreshSchedule()
834
795
  }
835
796
 
836
- private scheduleTeammate(opened: OpenedRun, leadSessionId: string): void {
837
- this.enqueueLaunch(opened, () => this.spawnTeammate(opened, leadSessionId).catch(error => {
838
- safeConsoleError('[dsh-task-board] teammate spawn settlement failed', error)
839
- }))
840
- }
841
-
842
- /**
843
- * Spawn one teammate inside the Lead session and attach the teammate's
844
- * session to the subtask execution, so the existing session monitor settles
845
- * it from the teammate's own turn like any other execution. A spawn that
846
- * fails settles the subtask as failed immediately, which then folds into the
847
- * Lead's cascade verdict.
848
- */
849
- private async spawnTeammate(opened: OpenedRun, leadSessionId: string): Promise<void> {
850
- const team = this.team
851
- if (team === undefined) {
852
- this.settleAndNotify(opened.task.id, opened.execution.id, 'failed', 'Agent Teams is unavailable in this deployment')
853
- return
854
- }
855
- try {
856
- const member = await team.spawn({
857
- leadSessionId,
858
- name: teammateName(opened.task.title, opened.execution.runGroupId ?? opened.task.id, opened.task.id),
859
- description: opened.task.title,
860
- prompt: promptText(opened.task),
861
- })
862
- if (member.sessionId === undefined || member.sessionId === '') {
863
- this.settleAndNotify(opened.task.id, opened.execution.id, 'failed', member.error ?? 'teammate provisioning failed')
864
- return
865
- }
866
- this.ledger.attachSession(opened.task.id, opened.execution.id, member.sessionId)
867
- } catch (error) {
868
- this.settleAndNotify(opened.task.id, opened.execution.id, 'failed', error instanceof Error ? error.message : String(error))
869
- }
870
- }
871
-
872
797
  /**
873
798
  * One roster pass, and whether it could read the session tree.
874
799
  *
@@ -1035,12 +960,12 @@ export class TaskBoardHostService {
1035
960
  this.ledger.settle(taskId, executionId, outcome, error, summary)
1036
961
  return
1037
962
  }
1038
- const previousStatus = before?.status
963
+ // One settlement can move more than the settled card: a run whose own card
964
+ // is terminal also writes the inherited verdict onto the subtasks it never
965
+ // dispatched. Compare the whole board so the provider events cover those too.
966
+ const statuses = this.statusMap()
1039
967
  this.ledger.settle(taskId, executionId, outcome, error, summary)
1040
- const task = this.ledger.getTask(taskId)
1041
- if (task !== undefined && previousStatus !== undefined && previousStatus !== task.status) {
1042
- this.extensions.emitStatusChanged({ taskId, status: task.status, previous: previousStatus })
1043
- }
968
+ this.emitStatusChanges(statuses)
1044
969
  this.extensions.emitExecutionSettled({
1045
970
  taskId,
1046
971
  executionId,
@@ -1218,28 +1143,18 @@ export class TaskBoardHostService {
1218
1143
  }
1219
1144
 
1220
1145
  /**
1221
- * Launch one run set. The root goes first and receives the run shape in its
1222
- * prompt (which members this run opens, and how they run); every plain-cascade
1223
- * member then launches on its own so one refused participant cannot hold the
1224
- * others back. A team run's members are spawned inside the root's Lead
1225
- * session instead, once that session exists.
1146
+ * Launch the one run a run request opened. A run request names one card and
1147
+ * opens one execution for it; the card's own session dispatches its subtasks
1148
+ * as subagents, so nothing else is enqueued here.
1226
1149
  *
1227
- * Every launch of one run set goes through the admission queue, which admits
1228
- * at most `runLaunchWidth` of them at a time — the whole subtree still opens,
1229
- * members just enter the running column in batches. Order inside the group is
1230
- * the order they are enqueued here, so the root's session always exists before
1231
- * any member's, and one member's launch settling (or failing) is what admits
1232
- * the next. All members share the one contract this group freezes.
1150
+ * The launch still goes through the admission queue, which admits at most
1151
+ * `runLaunchWidth` launches at a time — that bound now applies across
1152
+ * concurrent runs rather than across the members of one run.
1233
1153
  */
1234
1154
  private dispatchRuns(runs: readonly OpenedRun[], schedule?: ScheduledRunContext): void {
1235
- if (runs.length === 0) return
1236
- const root = runs.find(run => run.dispatch !== 'teammate') ?? runs[0]
1237
- const others = runs.filter(run => run !== root)
1238
- const freezeContract = this.contractFreezerForRunGroup()
1239
- this.scheduleLaunch(root, others, schedule, freezeContract)
1240
- for (const run of others) {
1241
- if (run.dispatch !== 'teammate') this.scheduleLaunch(run, [], schedule, freezeContract)
1242
- }
1155
+ const root = runs[0]
1156
+ if (root === undefined) return
1157
+ this.scheduleLaunch(root, schedule, this.contractFreezerForRunGroup())
1243
1158
  }
1244
1159
 
1245
1160
  /**
@@ -1252,8 +1167,8 @@ export class TaskBoardHostService {
1252
1167
  this.ledger.setVerification(taskId, executionId, { ...verification, applicability })
1253
1168
  }
1254
1169
 
1255
- private scheduleLaunch(opened: OpenedRun, others: readonly OpenedRun[] = [], schedule?: ScheduledRunContext, freezeContract?: RunContractFreezer): void {
1256
- this.enqueueLaunch(opened, () => this.launch(opened, others, schedule, freezeContract).catch(error => {
1170
+ private scheduleLaunch(opened: OpenedRun, schedule?: ScheduledRunContext, freezeContract?: RunContractFreezer): void {
1171
+ this.enqueueLaunch(opened, () => this.launch(opened, schedule, freezeContract).catch(error => {
1257
1172
  safeConsoleError('[dsh-task-board] execution launch settlement failed', error)
1258
1173
  }), schedule)
1259
1174
  }