@fish-under-sea/dsh-client-ui-task-board-fish 1.0.2 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (125) hide show
  1. package/NOTICE +1 -1
  2. package/README.en.md +6 -4
  3. package/README.md +6 -4
  4. package/README.zh.md +6 -4
  5. package/icon.png +0 -0
  6. package/lib/client.js +4428 -1508
  7. package/lib/client.js.map +1 -1
  8. package/lib/index.js +2670 -496
  9. package/lib/types/client/CardDefaultPresetField.d.ts +35 -0
  10. package/lib/types/client/PluginSettingsCard.d.ts +130 -19
  11. package/lib/types/client/RangeBubble.d.ts +46 -0
  12. package/lib/types/client/SegmentGroup.d.ts +28 -0
  13. package/lib/types/client/TaskBoardSettingsCard.d.ts +63 -0
  14. package/lib/types/client/board/AttachmentField.d.ts +70 -0
  15. package/lib/types/client/board/ExecutionLog.d.ts +24 -0
  16. package/lib/types/client/board/ReasoningEffortField.d.ts +25 -0
  17. package/lib/types/client/board/TaskForm.d.ts +4 -0
  18. package/lib/types/client/board/VerificationReport.d.ts +2 -15
  19. package/lib/types/client/board/model-options.d.ts +87 -0
  20. package/lib/types/client/board/preset-label.d.ts +21 -0
  21. package/lib/types/client/board/preset-roster.d.ts +45 -0
  22. package/lib/types/client/board/source-group.d.ts +27 -0
  23. package/lib/types/client/body-mutations.d.ts +45 -0
  24. package/lib/types/client/host-api.d.ts +25 -0
  25. package/lib/types/client/locales.d.ts +87 -9
  26. package/lib/types/client/pending-verify.d.ts +47 -0
  27. package/lib/types/client/plugin-card-seat.d.ts +3 -1
  28. package/lib/types/client/service.d.ts +4 -1
  29. package/lib/types/client/settings-form.d.ts +73 -51
  30. package/lib/types/core/attachment.d.ts +132 -0
  31. package/lib/types/core/card-defaults.d.ts +78 -0
  32. package/lib/types/core/controller.d.ts +57 -8
  33. package/lib/types/core/execution-summary.d.ts +52 -0
  34. package/lib/types/core/extension.d.ts +116 -0
  35. package/lib/types/core/launch-width.d.ts +31 -0
  36. package/lib/types/core/reasoning-effort.d.ts +57 -0
  37. package/lib/types/core/session-reuse.d.ts +7 -1
  38. package/lib/types/core/spend-budget.d.ts +28 -0
  39. package/lib/types/core/subtask.d.ts +100 -37
  40. package/lib/types/core/tasks.d.ts +94 -10
  41. package/lib/types/core/use-cases/task-create.d.ts +10 -5
  42. package/lib/types/core/use-cases/task-tag.d.ts +36 -0
  43. package/lib/types/core/use-cases/task-update.d.ts +22 -1
  44. package/lib/types/core/wire-projection.d.ts +35 -0
  45. package/lib/types/core/workspace-target.d.ts +23 -3
  46. package/lib/types/host/attachments.d.ts +250 -0
  47. package/lib/types/host/extension-registry.d.ts +40 -0
  48. package/lib/types/host/launch-admission.d.ts +71 -0
  49. package/lib/types/host-ledger.d.ts +114 -47
  50. package/lib/types/host-routes.d.ts +63 -0
  51. package/lib/types/host-runner.d.ts +164 -18
  52. package/lib/types/host-service.d.ts +182 -46
  53. package/lib/types/host-spend.d.ts +52 -0
  54. package/lib/types/index.d.ts +173 -54
  55. package/lib/types/loopback.d.ts +41 -1
  56. package/lib/types/protocol.d.ts +52 -11
  57. package/lib/types/tool-surface.d.ts +1 -0
  58. package/locale/en.json +6 -0
  59. package/locale/zh.json +6 -0
  60. package/package.json +36 -29
  61. package/src/client/CardDefaultPresetField.tsx +101 -0
  62. package/src/client/PluginSettingsCard.tsx +385 -111
  63. package/src/client/RangeBubble.tsx +164 -0
  64. package/src/client/SegmentGroup.tsx +93 -0
  65. package/src/client/TaskBoardSettingsCard.tsx +332 -37
  66. package/src/client/board/AttachmentField.tsx +383 -0
  67. package/src/client/board/EditTaskModal.tsx +63 -0
  68. package/src/client/board/ExecutionLog.tsx +154 -0
  69. package/src/client/board/LinkSubtaskModal.tsx +1 -1
  70. package/src/client/board/NewTaskModal.tsx +154 -45
  71. package/src/client/board/ReasoningEffortField.tsx +50 -0
  72. package/src/client/board/TagManagerModal.tsx +151 -2
  73. package/src/client/board/TaskBoard.tsx +47 -10
  74. package/src/client/board/TaskCard.tsx +45 -23
  75. package/src/client/board/TaskDetail.tsx +468 -258
  76. package/src/client/board/TaskForm.tsx +19 -4
  77. package/src/client/board/VerificationReport.tsx +143 -104
  78. package/src/client/board/model-options.ts +208 -0
  79. package/src/client/board/preset-label.ts +32 -0
  80. package/src/client/board/preset-roster.ts +58 -0
  81. package/src/client/board/source-group.ts +94 -0
  82. package/src/client/board/task-markdown.module.css +11 -8
  83. package/src/client/board-settings.module.css +35 -7
  84. package/src/client/board.module.css +1044 -105
  85. package/src/client/body-mutations.ts +133 -0
  86. package/src/client/host-api.ts +70 -0
  87. package/src/client/index.ts +109 -95
  88. package/src/client/locales.ts +205 -48
  89. package/src/client/pending-verify.ts +90 -0
  90. package/src/client/plugin-card-seat.ts +8 -2
  91. package/src/client/service.ts +24 -0
  92. package/src/client/settings-card.module.css +466 -89
  93. package/src/client/settings-entry-form.ts +0 -1
  94. package/src/client/settings-form.ts +102 -60
  95. package/src/core/attachment.ts +287 -0
  96. package/src/core/card-defaults.ts +132 -0
  97. package/src/core/controller.ts +90 -11
  98. package/src/core/execution-summary.ts +96 -0
  99. package/src/core/extension.ts +120 -0
  100. package/src/core/launch-width.ts +38 -0
  101. package/src/core/reasoning-effort.ts +92 -0
  102. package/src/core/session-reuse.ts +7 -1
  103. package/src/core/spend-budget.ts +35 -0
  104. package/src/core/store.ts +19 -1
  105. package/src/core/subtask.ts +144 -68
  106. package/src/core/tasks.ts +117 -10
  107. package/src/core/use-cases/task-create.ts +27 -16
  108. package/src/core/use-cases/task-tag.ts +56 -0
  109. package/src/core/use-cases/task-update.ts +33 -5
  110. package/src/core/wire-projection.ts +81 -0
  111. package/src/core/workspace-target.ts +27 -3
  112. package/src/host/agent-tools.ts +33 -21
  113. package/src/host/attachments.ts +650 -0
  114. package/src/host/extension-registry.ts +150 -5
  115. package/src/host/launch-admission.ts +139 -0
  116. package/src/host-ledger.ts +248 -117
  117. package/src/host-routes.ts +233 -15
  118. package/src/host-runner.ts +395 -61
  119. package/src/host-service.ts +512 -139
  120. package/src/host-spend.ts +105 -0
  121. package/src/index.ts +312 -92
  122. package/src/loopback.ts +57 -1
  123. package/src/protocol.ts +83 -18
  124. package/src/tool-surface.ts +1 -0
  125. package/icon.svg +0 -3
package/src/index.ts CHANGED
@@ -12,17 +12,19 @@ import type {} from '@deepseek-ai/dsh-commands'
12
12
  import z from '@deepseek-ai/schemastery'
13
13
  import type {} from '@deepseek-ai/dsh-system-prompt'
14
14
  import type {} from '@deepseek-ai/dsh-api-gateway'
15
- import type {} from '@deepseek-ai/dsh-client-connection'
16
15
  import type {} from '@deepseek-ai/dsh-workspace'
17
16
  import type {} from '@deepseek-ai/dsh-host-webserver'
18
17
  import type {} from '@deepseek-ai/dsh-tools'
19
18
  import type { ToolDefinition } from '@deepseek-ai/dsh-tools'
20
19
  import type { LlmRuntime } from '@deepseek-ai/dsh-llm'
21
- import { TaskBoardHostService, type HostTimerFace, type TaskBoardTeamDispatcher } from './host-service.ts'
20
+ import { TaskBoardHostService, type HostTimerFace } from './host-service.ts'
21
+ import { createOwnerPeer } from './host-runner.ts'
22
22
  import { parseTaskDraft, TaskParseError } from './host-ai.ts'
23
23
  import { TASK_PERMISSIONS, isTaskPermission, type TaskPermission } from './core/tasks.ts'
24
- import { DEFAULT_SUBTASK_DEPTH, SUBTASK_DEPTH_MAX, SUBTASK_DEPTH_MIN } from './core/subtask.ts'
24
+ import { LEGACY_AGENT_TEAMS_TOOL, DEFAULT_SUBTASK_DEPTH, SUBTASK_DEPTH_MAX, SUBTASK_DEPTH_MIN } from './core/subtask.ts'
25
25
  import { DEFAULT_SESSION_POLL_SECONDS, SESSION_POLL_MAX_SECONDS, SESSION_POLL_MIN_SECONDS } from './core/poll-cadence.ts'
26
+ import { DEFAULT_RUN_LAUNCH_WIDTH, RUN_LAUNCH_WIDTH_MAX, RUN_LAUNCH_WIDTH_MIN } from './core/launch-width.ts'
27
+ import { DEFAULT_SPEND_BUDGET_TOKENS } from './core/spend-budget.ts'
26
28
  import {
27
29
  DEFAULT_VERIFICATION_BUDGET_SECONDS,
28
30
  DEFAULT_VERIFICATION_CALL_TIMEOUT_SECONDS,
@@ -34,10 +36,13 @@ import {
34
36
  verificationCallTimeoutMs,
35
37
  } from './core/verification-budget.ts'
36
38
  import { DEFAULT_SESSION_PERMISSION } from './core/handover.ts'
39
+ import type { CardDefaults } from './core/card-defaults.ts'
37
40
  import { buildTaskBoardTools, TASK_BOARD_TOOL_NAMES } from './host/agent-tools.ts'
38
41
  import { PLUGIN_TOOL_SECTION_ORDERS, visibleToolText } from './tool-surface.ts'
39
- import { makeTaskBoardRoutes } from './host-routes.ts'
42
+ import { makeTaskBoardRoutes, type TaskBoardConnectionTrust } from './host-routes.ts'
43
+ import type { ModelInfoResolver, TaskBoardAttachmentStore } from './host/attachments.ts'
40
44
  import { TASK_BOARD_SERVICE_NAME, type TaskBoardExtension } from './core/extension.ts'
45
+ import type { TaskBoardAction } from './protocol.ts'
41
46
  import { mountOnce } from './mount-once.ts'
42
47
  import { createGoalVerificationGate, type GoalFace } from './host/verification-gate.ts'
43
48
  import { normalizeCatalog, type ModelCatalogView, type VerificationSettings } from './core/verification.ts'
@@ -49,7 +54,7 @@ const SECTION_ORDER = PLUGIN_TOOL_SECTION_ORDERS['task-board']
49
54
  /** Default environment variable holding the authenticated proxy token. */
50
55
  export const DEFAULT_PROXY_TOKEN_ENV = 'DSH_TASK_BOARD_PROXY_TOKEN'
51
56
 
52
- export const inject = ['systemPrompt', 'typertGateway', 'connection', 'workspaceRegistry', 'webServer', 'agents', 'commands']
57
+ export const inject = ['systemPrompt', 'typertGateway', 'workspaceRegistry', 'webServer', 'agents', 'commands']
53
58
 
54
59
  /** Model-facing announcement: plugin presence, capabilities, and limits. */
55
60
  export const TASK_BOARD_GUIDANCE = '本机已安装 dsh-task-board 插件(DSH Web GUI 的任务看板):侧边栏「任务看板」入口;在 dsh-web 插件全家桶仓库(packages/dsh-task-board)统一维护,经聚合包 web-ui-all 一键安装。能力:多列看板管理任务;Host 权威账本;关闭浏览器后仍由 Host 执行和结算;任务可钉住工作区、agent 预设和权限;任务可建子任务(深度上限可配 1..3,默认 1 层,子任务不能再带子任务),执行父任务会并发执行其子任务树,子任务可单独覆盖权限与模型;另注册 task_board_* agent 工具(list/get/create/update/set_parent/run/manage/schedule),任何会话都可直接读写看板、子任务与定时计划,但运行任务会真实执行并消耗额度,高于会话默认权限的绑定仍必须由用户在 GUI 人工确认(工具刻意不提供确认能力);支持 Host 本地时区的 5 段 cron,错过的触发点不补跑;可选且默认关闭的空闲系统睡眠保护允许屏幕熄灭,但不承诺拦截合盖、手动睡眠、休眠、关机或唤醒已睡眠机器。执行消耗 API 额度。用户提到「任务看板 / 看板 / 定时任务」时即指本插件,请据此协作。若你同时用 todo_write 维护会话顶部的可见计划列表,最终回复前必须再次调用 todo_write 收尾:没有剩余工作时不要保留 in_progress,已完成的最后一步要标为 completed。'
@@ -84,6 +89,19 @@ export interface Config {
84
89
  trustedProxyHosts?: string[]
85
90
  /** Environment variable whose value the authenticated proxy injects upstream. */
86
91
  proxyTokenEnv?: string
92
+ /**
93
+ * Whether the operator's OWN reverse proxy or tunnel may speak for the
94
+ * browser (default OFF). Off keeps the pre-existing fence exactly: a request
95
+ * that carries a forwarding header is never local, so only a direct loopback
96
+ * client or an allowlisted token-injecting proxy reaches the board (issue
97
+ * #1906). On admits one narrower case — a forwarded request whose socket and
98
+ * Host are both this machine's loopback upstream, i.e. the proxy dials the
99
+ * board itself (issue #1918) — and still requires the browser same-origin
100
+ * marker, so a third party's tunnel is only trusted while the operator says
101
+ * it is. Volatile: the fence reads it at each request, so an edit binds the
102
+ * next request without re-registering the routes.
103
+ */
104
+ trustForwardedProxy?: Volatile<boolean>
87
105
  /**
88
106
  * An explicit baseline for the permission confirmation gate. Left unset, the
89
107
  * board follows the Host's own default permission preset — the value new DSH
@@ -96,8 +114,8 @@ export interface Config {
96
114
  /**
97
115
  * Subtask depth limit, 1..3 (default 1). At 1 a task may carry one level of
98
116
  * subtasks and a subtask cannot be given subtasks of its own; raising it
99
- * allows deeper trees. Every extra level multiplies the sessions one run
100
- * of the root task opens, so the ceiling is deliberately small.
117
+ * allows deeper trees. Every extra level is another tree the card's own
118
+ * session may have to dispatch, so the ceiling is deliberately small.
101
119
  */
102
120
  maxSubtaskDepth?: Volatile<number>
103
121
  /**
@@ -108,11 +126,25 @@ export interface Config {
108
126
  */
109
127
  sessionPollSeconds?: Volatile<number>
110
128
  /**
111
- * Continuable-subagent provider the Agent Teams service uses to compose a
112
- * teammate. Matches the Agent Teams tool plugin's `freshProvider` default;
113
- * only team-mode runs use it.
129
+ * How many run launches this board may have in flight at once (1..16,
130
+ * default 3). A run opens one session, so a burst is several cards run at
131
+ * once (several tabs, or a due schedule firing while a manual run starts);
132
+ * without a bound the Host would ask DSH for all of them in the same tick.
133
+ * This is the mechanism that enforces the repository's measured guidance for
134
+ * heavy implementation subagents. Runs wait their turn instead of being
135
+ * dropped, and every one of them still starts. Read at each admission, so an
136
+ * edit bounds the next launch of a run that is still queueing.
137
+ */
138
+ runLaunchWidth?: Volatile<number>
139
+ /**
140
+ * Daily token ceiling for the work this board dispatches (default 0 = no
141
+ * gate). Tokens, not money: the ledger the board measures against prices
142
+ * DeepSeek's own routes only, so a cost cap would read 0 elsewhere. Read at
143
+ * each gate, so an edit binds the next run without a remount; a manual
144
+ * run/rerun whose day already spent the cap is refused, and a due occurrence
145
+ * is skipped onto the scheduler with its run budget untouched.
114
146
  */
115
- teamProvider?: string
147
+ spendBudgetTokens?: Volatile<number>
116
148
  /**
117
149
  * GLOBAL native /goal switch (default OFF), the master control over whether
118
150
  * this board starts a run with dsh's built-in /goal at all. A run uses native
@@ -129,6 +161,33 @@ export interface Config {
129
161
  * becomes a goal run.
130
162
  */
131
163
  goalRunEnabled?: Volatile<boolean>
164
+ /**
165
+ * Agent preset a NEW card starts from (volatile, default blank = not set).
166
+ * A prefill, never a pin: the create dialog opens with it selected, the
167
+ * caller may override it, and the card stores what it was created with. It
168
+ * reaches the create path only when that caller opts in with
169
+ * `applyCardDefaults`, so the extension provider's own create and the legacy
170
+ * import are untouched.
171
+ */
172
+ cardDefaultMode?: Volatile<string>
173
+ /**
174
+ * Permission a NEW card starts from (volatile, default blank = not set), one
175
+ * of the three presets. A prefill like the rest: a value above
176
+ * `sessionDefaultPermission` still has to be confirmed by a human before the
177
+ * card may run, because the pre-execution gate is what decides that.
178
+ */
179
+ cardDefaultPermission?: Volatile<TaskPermission | ''>
180
+ /**
181
+ * Model a NEW card starts from (volatile, default blank = not set).
182
+ */
183
+ cardDefaultModel?: Volatile<string>
184
+ /**
185
+ * Reasoning level a NEW card starts from (volatile, default blank = not set).
186
+ * Bound to `cardDefaultModel` exactly as a card's own level is bound to its
187
+ * own model: it applies only while the card's final model IS that default
188
+ * model, and a blank `cardDefaultModel` makes it inert.
189
+ */
190
+ cardDefaultReasoningEffort?: Volatile<string>
132
191
  /**
133
192
  * Goal acceptance for executions this board starts (default ON). When on,
134
193
  * update_goal(action: complete) inside a task execution is refused until an
@@ -173,18 +232,12 @@ export interface Config {
173
232
  goalVerificationBudgetSeconds?: Volatile<number>
174
233
  }
175
234
 
176
- /**
177
- * Continuable-subagent provider for fresh teammates, matching the Agent Teams
178
- * tool plugin's own `freshProvider` default.
179
- */
180
- export const DEFAULT_TEAM_PROVIDER = 'spawn'
181
-
182
235
  /**
183
236
  * Profile-patch shape of {@link Config}: what the Host validates the row's
184
237
  * config against, before the schema turns volatile fields into live references
185
238
  * and applies defaults. Declared separately because the two sides no longer
186
239
  * share one shape, so the schema is annotated `z<ConfigInput, Config>` — the
187
- * same split `dsh-git-graph` uses. The annotation is also what keeps the
240
+ * same split the git-family packages use. The annotation is also what keeps the
188
241
  * emitted declaration portable: an unannotated schema holding a nested object
189
242
  * array infers a type that cannot be named without reaching into a transitive
190
243
  * dependency's own types.
@@ -200,16 +253,28 @@ export interface ConfigInput {
200
253
  trustedProxyHosts?: string[]
201
254
  /** Environment variable whose value the authenticated proxy injects. */
202
255
  proxyTokenEnv?: string
256
+ /** Trust a forwarded request that landed on this machine's loopback upstream; default off. */
257
+ trustForwardedProxy?: boolean
203
258
  /** Explicit baseline for the permission confirmation gate; unset follows the Host default. */
204
259
  sessionDefaultPermission?: TaskPermission
205
260
  /** Subtask depth limit, 1..3. */
206
261
  maxSubtaskDepth?: number
207
262
  /** Roster-poll cadence in seconds while the board has work to reconcile. */
208
263
  sessionPollSeconds?: number
209
- /** Continuable-subagent provider the Agent Teams service composes a teammate from. */
210
- teamProvider?: string
264
+ /** Concurrent run launches allowed at once, 1..16. */
265
+ runLaunchWidth?: number
266
+ /** Daily token ceiling for board runs; 0 disables the gate. */
267
+ spendBudgetTokens?: number
211
268
  /** Global native /goal switch; default off, frozen per execution. */
212
269
  goalRunEnabled?: boolean
270
+ /** Agent preset a new card starts from; blank = not set. */
271
+ cardDefaultMode?: string
272
+ /** Permission a new card starts from; blank = not set. */
273
+ cardDefaultPermission?: TaskPermission | ''
274
+ /** Model a new card starts from; blank = not set. */
275
+ cardDefaultModel?: string
276
+ /** Reasoning level a new card starts from; blank = not set. */
277
+ cardDefaultReasoningEffort?: string
213
278
  /** Goal acceptance switch. */
214
279
  goalVerification?: boolean
215
280
  /** Judge model route for goal acceptance; blank inherits the host default. */
@@ -228,11 +293,17 @@ export const Config: z<ConfigInput, Config> = z.object({
228
293
  preventIdleSleep: z.boolean().default(false).volatile(),
229
294
  trustedProxyHosts: z.array(z.string()).default([]),
230
295
  proxyTokenEnv: z.string().min(1).default(DEFAULT_PROXY_TOKEN_ENV),
296
+ trustForwardedProxy: z.boolean().default(false).volatile(),
231
297
  sessionDefaultPermission: z.union(TASK_PERMISSIONS),
232
298
  maxSubtaskDepth: z.number().min(SUBTASK_DEPTH_MIN).max(SUBTASK_DEPTH_MAX).default(DEFAULT_SUBTASK_DEPTH).volatile(),
233
299
  sessionPollSeconds: z.number().min(SESSION_POLL_MIN_SECONDS).max(SESSION_POLL_MAX_SECONDS).default(DEFAULT_SESSION_POLL_SECONDS).volatile(),
234
- teamProvider: z.string().min(1).default(DEFAULT_TEAM_PROVIDER),
300
+ runLaunchWidth: z.number().min(RUN_LAUNCH_WIDTH_MIN).max(RUN_LAUNCH_WIDTH_MAX).default(DEFAULT_RUN_LAUNCH_WIDTH).volatile(),
301
+ spendBudgetTokens: z.number().min(DEFAULT_SPEND_BUDGET_TOKENS).default(DEFAULT_SPEND_BUDGET_TOKENS).volatile(),
235
302
  goalRunEnabled: z.boolean().default(false).volatile(),
303
+ cardDefaultMode: z.string().default('').volatile(),
304
+ cardDefaultPermission: z.union([...TASK_PERMISSIONS, '']).default('').volatile(),
305
+ cardDefaultModel: z.string().default('').volatile(),
306
+ cardDefaultReasoningEffort: z.string().default('').volatile(),
236
307
  goalVerification: z.boolean().default(true).volatile(),
237
308
  goalVerificationModel: z.string().default('').volatile(),
238
309
  goalVerificationReasoningEffort: z.string().default('').volatile(),
@@ -283,17 +354,66 @@ export function readConfigField<T>(field: Volatile<T> | T | undefined, fallback:
283
354
  return field as T
284
355
  }
285
356
 
286
- /** Resolve proxy access without ever placing the token value in plugin config. */
287
- export function resolveProxyAccess(config: Config | undefined, env: NodeJS.ProcessEnv = process.env): { trustedProxyHosts: string[]; proxyToken?: string } {
357
+ /**
358
+ * Resolve proxy access without ever placing the token value in plugin config.
359
+ *
360
+ * The forwarded-proxy switch travels as a reader rather than a value: it is
361
+ * schema-volatile, so the fence must read it when a request arrives instead of
362
+ * when the routes are registered.
363
+ * @param config - the resolved plugin config.
364
+ * @param env - environment holding the proxy token value.
365
+ * @returns the route access handed to {@link makeTaskBoardRoutes}.
366
+ */
367
+ export function resolveProxyAccess(config: Config | undefined, env: NodeJS.ProcessEnv = process.env): {
368
+ trustedProxyHosts: string[]
369
+ proxyToken?: string
370
+ trustForwardedProxy: () => boolean
371
+ } {
372
+ const trustForwardedProxy = (): boolean => readConfigField(config?.trustForwardedProxy, DEFAULT_TRUST_FORWARDED_PROXY)
288
373
  const trustedProxyHosts = config?.trustedProxyHosts ?? []
289
- if (trustedProxyHosts.length === 0) return { trustedProxyHosts }
374
+ if (trustedProxyHosts.length === 0) return { trustedProxyHosts, trustForwardedProxy }
290
375
  const proxyTokenEnv = config?.proxyTokenEnv ?? DEFAULT_PROXY_TOKEN_ENV
291
376
  if (proxyTokenEnv.trim() === '') throw new Error('task-board: proxyTokenEnv must not be empty')
292
377
  const proxyToken = env[proxyTokenEnv]
293
378
  if (proxyToken === undefined || proxyToken === '') {
294
379
  throw new Error(`task-board: trustedProxyHosts requires a non-empty ${proxyTokenEnv} environment variable`)
295
380
  }
296
- return { trustedProxyHosts, proxyToken }
381
+ return { trustedProxyHosts, proxyToken, trustForwardedProxy }
382
+ }
383
+
384
+ /**
385
+ /**
386
+ * Schema default for the forwarded-proxy switch, re-read for hand-built
387
+ * contexts. Deliberately false: a deployment that never configured it keeps
388
+ * refusing every forwarded request, which is the #1906 fence.
389
+ */
390
+ export const DEFAULT_TRUST_FORWARDED_PROXY = false
391
+
392
+ /**
393
+ * Resolve the composition's optional `connection` service.
394
+ *
395
+ * The service is the Host's own browser-session authority: it fronts every
396
+ * `/api` request with the Host/Origin fence and the signed `dsh-auth-*` cookie,
397
+ * which is what a deployment behind a reverse proxy or ingress validates on the
398
+ * same authority the GUI is served from. The board bridges it instead of
399
+ * repeating that check, so a proxy request the Host already authenticated is
400
+ * admitted without a board-specific host allowlist (issue #1930). It is
401
+ * deliberately resolved like the agent-tool registry rather than injected:
402
+ * a composition that serves no connection keeps mounting the board on the
403
+ * pre-existing loopback fence, and one that mounts the service later is picked
404
+ * up on the next request because the fence asks this resolver each time.
405
+ * @param ctx - the plugin context.
406
+ * @returns the trust face, or undefined when this deployment serves none.
407
+ */
408
+ export function resolveConnectionTrust(ctx: Context): TaskBoardConnectionTrust | undefined {
409
+ try {
410
+ const connection = ctx.get('connection') as Partial<TaskBoardConnectionTrust> | undefined
411
+ return connection !== undefined && typeof connection.requestRejection === 'function'
412
+ ? connection as TaskBoardConnectionTrust
413
+ : undefined
414
+ } catch {
415
+ return undefined
416
+ }
297
417
  }
298
418
 
299
419
  /** The registry face the agent tools register into. */
@@ -377,95 +497,128 @@ export function resolveHostDefaultPermission(ctx: Context): TaskPermission | und
377
497
  }
378
498
 
379
499
  /**
380
- * How long one teammate may take to reach its durable active or failed edge.
381
- * Agent Teams provisioning normally resolves in seconds; the bound exists so a
382
- * hung spawn settles the subtask instead of holding the cascade open forever.
500
+ * Read the optional `llm` service. The board deliberately does not inject it:
501
+ * a deployment without a model must still mount the board, and the parse route
502
+ * answers a typed failure instead of the plugin failing to load (issue #1540).
503
+ * @param ctx - the plugin context.
504
+ * @returns the llm service, or undefined when this deployment serves none.
383
505
  */
384
- const TEAMMATE_PROVISION_TIMEOUT_MS = 600_000
385
-
386
- /** The subset of the Agent Teams service this plugin drives. */
387
- interface AgentTeamsFace {
388
- spawnTeammate(caller: unknown, request: {
389
- name: string
390
- description: string
391
- prompt: Array<{ type: 'text'; text: string }>
392
- context: 'fresh' | 'fork'
393
- provider: string
394
- signal: AbortSignal
395
- }): Promise<{ member?: { id?: string; phase?: string; error?: string } }>
506
+ export function resolveLlmRuntime(ctx: Context): LlmRuntime | undefined {
507
+ try {
508
+ const llm = ctx.get('llm') as LlmRuntime | undefined
509
+ return llm !== undefined && typeof (llm as { stream?: unknown }).stream === 'function' ? llm : undefined
510
+ } catch {
511
+ return undefined
512
+ }
396
513
  }
397
514
 
398
515
  /**
399
- * Resolve the optional Agent Teams service. Like the tool registry and the llm
400
- * runtime, it is deliberately not injected: a deployment without Agent Teams
401
- * must still mount the whole board and only lose team-mode runs.
516
+ * Resolve the optional attachment storage.
517
+ *
518
+ * The board does not inject the service: a deployment without one must still
519
+ * mount the board, and every attachment surface then answers with a typed
520
+ * "storage unavailable" failure instead of the plugin failing to load.
402
521
  * @param ctx - the plugin context.
403
- * @returns the service, or undefined when this deployment serves none.
522
+ * @returns the attachment storage, or undefined when this deployment serves none.
404
523
  */
405
- export function resolveAgentTeams(ctx: Context): AgentTeamsFace | undefined {
524
+ export function resolveAttachmentStore(ctx: Context): TaskBoardAttachmentStore | undefined {
406
525
  try {
407
- const teams = ctx.get('agentTeams') as AgentTeamsFace | undefined
408
- return teams !== undefined && typeof teams.spawnTeammate === 'function' ? teams : undefined
526
+ const store = ctx.get('attachments') as TaskBoardAttachmentStore | undefined
527
+ return store !== undefined && typeof store.saveImage === 'function' ? store : undefined
409
528
  } catch {
410
529
  return undefined
411
530
  }
412
531
  }
413
532
 
414
533
  /**
415
- * Build the team dispatcher: the run's Lead session spawns one teammate per
416
- * subtask through the Agent Teams service, and the teammate's session id is
417
- * attached to that subtask's execution so the ordinary session monitor settles
418
- * it. Returns undefined when the deployment serves no Agent Teams service or
419
- * no live-agent registry, which makes a team run fail closed.
534
+ * The model-info reader the image preflight uses.
535
+ *
536
+ * It asks the OFFICIAL model service about one exact route. The model catalog
537
+ * the board already publishes carries no modality information and must not be
538
+ * used to answer that question: only the model's own declared input
539
+ * modalities can refuse an image route, and a route whose modalities cannot be
540
+ * read is UNKNOWN and therefore allowed.
420
541
  * @param ctx - the plugin context.
421
- * @param provider - the continuable-subagent provider for fresh teammates.
422
- * @returns the dispatcher, or undefined when team runs cannot be served.
542
+ * @returns the reader, or undefined when the deployment serves no model service.
423
543
  */
424
- export function buildTeamDispatcher(ctx: Context, provider: string): TaskBoardTeamDispatcher | undefined {
425
- const teams = resolveAgentTeams(ctx)
426
- if (teams === undefined) return undefined
427
- if (typeof (ctx.agents as { get?: unknown } | undefined)?.get !== 'function') return undefined
428
- return {
429
- async spawn(input) {
430
- const lead = ctx.agents.get(input.leadSessionId as Parameters<typeof ctx.agents.get>[0])
431
- if (lead === undefined) return { error: `lead session ${input.leadSessionId} is not live` }
432
- try {
433
- const result = await teams.spawnTeammate(lead, {
434
- name: input.name,
435
- description: input.description,
436
- prompt: [{ type: 'text', text: input.prompt }],
437
- context: 'fresh',
438
- provider,
439
- signal: AbortSignal.timeout(TEAMMATE_PROVISION_TIMEOUT_MS),
440
- })
441
- const member = result?.member
442
- if (member === undefined) return { error: 'Agent Teams returned no teammate' }
443
- if (member.phase === 'failed') return { error: member.error ?? 'teammate provisioning failed' }
444
- if (typeof member.id !== 'string' || member.id === '') return { error: 'Agent Teams returned no teammate session' }
445
- return { sessionId: member.id }
446
- } catch (error) {
447
- return { error: `teammate provisioning failed: ${error instanceof Error ? error.message : String(error)}` }
448
- }
449
- },
544
+ export function resolveModelInfoReader(ctx: Context): ModelInfoResolver | undefined {
545
+ return async (provider: string, model: string): Promise<{ inputModalities?: readonly string[] } | undefined> => {
546
+ const llm = resolveLlmRuntime(ctx)
547
+ if (llm === undefined) return undefined
548
+ try {
549
+ const info = await llm.resolveModelInfo(provider, model)
550
+ return { ...(info.inputModalities === undefined ? {} : { inputModalities: info.inputModalities }) }
551
+ } catch (error) {
552
+ console.warn('[dsh-task-board] could not resolve the model info of ' + provider + '/' + model + '; the image preflight allows the route', error)
553
+ return undefined
554
+ }
450
555
  }
451
556
  }
452
557
 
453
558
  /**
454
- * Read the optional `llm` service. The board deliberately does not inject it:
455
- * a deployment without a model must still mount the board, and the parse route
456
- * answers a typed failure instead of the plugin failing to load (issue #1540).
559
+ * The subset of `sessionController` the board uses to wake a cold persisted
560
+ * session before running a slash command on it (issue #1861).
561
+ */
562
+ interface SessionControllerFace {
563
+ resolveAgent(
564
+ sessionId: Parameters<Context['agents']['get']>[0],
565
+ ): Promise<
566
+ | { readonly agent: Parameters<Context['commands']['execute']>[0] }
567
+ | { readonly error: { readonly message?: string } }
568
+ >
569
+ }
570
+
571
+ /**
572
+ * Resolve the optional `sessionController` service. Like the tool registry and
573
+ * the llm runtime, it is read dynamically so capture-only test contexts that do
574
+ * not mount the full session controller still activate the board.
457
575
  * @param ctx - the plugin context.
458
- * @returns the llm service, or undefined when this deployment serves none.
576
+ * @returns the session controller face, or undefined when unavailable.
459
577
  */
460
- export function resolveLlmRuntime(ctx: Context): LlmRuntime | undefined {
578
+ export function resolveSessionController(ctx: Context): SessionControllerFace | undefined {
461
579
  try {
462
- const llm = ctx.get('llm') as LlmRuntime | undefined
463
- return llm !== undefined && typeof (llm as { stream?: unknown }).stream === 'function' ? llm : undefined
580
+ const controller = (ctx as { get?: (name: string) => unknown }).get?.('sessionController') as SessionControllerFace | undefined
581
+ return controller !== undefined && typeof controller.resolveAgent === 'function' ? controller : undefined
464
582
  } catch {
465
583
  return undefined
466
584
  }
467
585
  }
468
586
 
587
+ /**
588
+ * Resolve the live Agent for an execution session, resuming a cold persisted
589
+ * session through `sessionController.resolveAgent` when it is not yet in
590
+ * `ctx.agents` (issue #1861).
591
+ *
592
+ * A fresh run (`session/create`) or a session the browser is currently
593
+ * following is already in `ctx.agents`, so the fast path returns immediately.
594
+ * A scheduled or manual reuse of a cold session — one that `session/list`
595
+ * reports as idle from disk without activating its Agent — is not in
596
+ * `ctx.agents` when `pinAndPrompt` runs `/permission` ahead of
597
+ * `session/selectModel` and `session/prompt`; delegating to
598
+ * `sessionController.resolveAgent` resumes it with its recorded preset and
599
+ * model-selection state, matching what those gateway endpoints do next.
600
+ * @param ctx - the plugin context.
601
+ * @param sessionId - the target execution session id.
602
+ * @returns the live Agent for `sessionId`.
603
+ */
604
+ export async function resolveExecutionAgent(
605
+ ctx: Context,
606
+ sessionId: Parameters<Context['agents']['get']>[0],
607
+ ): Promise<Parameters<Context['commands']['execute']>[0]> {
608
+ const live = ctx.agents.get(sessionId)
609
+ if (live !== undefined) return live
610
+ const controller = resolveSessionController(ctx)
611
+ if (controller !== undefined) {
612
+ const resolved = await controller.resolveAgent(sessionId)
613
+ if ('agent' in resolved && resolved.agent !== undefined) return resolved.agent
614
+ const detail = 'error' in resolved && typeof resolved.error?.message === 'string' && resolved.error.message !== ''
615
+ ? `: ${resolved.error.message}`
616
+ : ''
617
+ throw new Error(`execution session ${sessionId} is not available${detail}`)
618
+ }
619
+ throw new Error(`execution session ${sessionId} is not available`)
620
+ }
621
+
469
622
  /**
470
623
  * Activate the board's host half: ledger, routes, cron scheduler, power
471
624
  * inhibitor, and the model-facing announcement.
@@ -492,6 +645,18 @@ function applyImpl(ctx: Context, config?: Config): void {
492
645
  const maxSubtaskDepth = (): number => readConfigField(config?.maxSubtaskDepth, DEFAULT_SUBTASK_DEPTH)
493
646
  /** Current roster-poll cadence in seconds (read live: the settings card edits it in place). */
494
647
  const sessionPollSeconds = (): number => readConfigField(config?.sessionPollSeconds, DEFAULT_SESSION_POLL_SECONDS)
648
+ /**
649
+ * Current run-launch admission width. Read live on every admission, so the
650
+ * settings card bounds the next launch of a run that is still queueing without
651
+ * remounting the row; the Host clamps a hand-edited value into the schema range.
652
+ */
653
+ const runLaunchWidth = (): number => readConfigField(config?.runLaunchWidth, DEFAULT_RUN_LAUNCH_WIDTH)
654
+ /**
655
+ * Current daily token cap, read at each gate like the width above. The value
656
+ * decides first: 0 — the default — ends the gate before a file is opened, so
657
+ * a board that never set a cap pays nothing for it.
658
+ */
659
+ const spendBudgetTokens = (): number => readConfigField(config?.spendBudgetTokens, DEFAULT_SPEND_BUDGET_TOKENS)
495
660
  /**
496
661
  * The baseline the permission confirmation gate judges against: the row's own
497
662
  * `sessionDefaultPermission` when the deployment pins one, otherwise the Host's
@@ -530,20 +695,59 @@ function applyImpl(ctx: Context, config?: Config): void {
530
695
  * executions that start afterwards.
531
696
  */
532
697
  const goalRunEnabled = (): boolean => readConfigField(config?.goalRunEnabled, DEFAULT_GOAL_RUN)
698
+ /**
699
+ * Live reader of the new-card defaults, read at every use like the switch
700
+ * above: the create dialog prefills from the published snapshot, and each
701
+ * creating session re-reads them when it submits the create. A blank value
702
+ * means "not set" and reaches the resolver as an absent target.
703
+ */
704
+ const cardDefaults = (): CardDefaults => {
705
+ const permission = readConfigField<TaskPermission | ''>(config?.cardDefaultPermission, '')
706
+ return {
707
+ mode: readConfigField(config?.cardDefaultMode, '').trim() || undefined,
708
+ permission: isTaskPermission(permission) ? permission : undefined,
709
+ model: readConfigField(config?.cardDefaultModel, '').trim() || undefined,
710
+ reasoningEffort: readConfigField(config?.cardDefaultReasoningEffort, '').trim() || undefined,
711
+ }
712
+ }
713
+ // The 0.2.1 gateway requires every request to name the peer it speaks for:
714
+ // the board calls as the host-local owner, so its peer is minted on this
715
+ // fiber and aborts with it (see createOwnerPeer).
716
+ const ownerPeer = createOwnerPeer(ctx)
717
+ // A deployment that registers the legacy Agent Teams fingerprint cannot
718
+ // orchestrate under the dispatcher preset: the preset's own compatibility
719
+ // gate stops and waits for a human reply, which a scheduled or unattended run
720
+ // never brings (issue #2031). Read at launch, so a runtime mounted after this
721
+ // row is still judged, and read tolerantly: no registry, no lookup half, or a
722
+ // throw all answer false, which keeps today's behaviour rather than refusing
723
+ // cards on a guess.
724
+ const legacyAgentTeams = (): boolean => {
725
+ const lookup = lookupOf(resolveToolRegistry(ctx))
726
+ if (lookup === undefined) return false
727
+ try {
728
+ return lookup.get(LEGACY_AGENT_TEAMS_TOOL) !== undefined
729
+ } catch {
730
+ return false
731
+ }
732
+ }
533
733
  const host = new TaskBoardHostService(ctx.typertGateway, {
534
734
  workspaceRegistry: ctx.workspaceRegistry,
535
- operatorPeer: () => ctx.connection.operator,
735
+ ownerPeer,
536
736
  sessionDefaultPermission,
537
737
  maxSubtaskDepth: maxSubtaskDepth(),
538
738
  goalRunEnabled,
739
+ runLaunchWidth,
740
+ spendBudgetTokens,
741
+ cardDefaults,
539
742
  verificationSettings,
540
743
  verificationCatalog,
744
+ attachments: () => resolveAttachmentStore(ctx),
745
+ modelInfo: () => resolveModelInfoReader(ctx),
746
+ legacyAgentTeams,
541
747
  timers: resolveHostTimers(ctx),
542
- team: buildTeamDispatcher(ctx, config?.teamProvider ?? DEFAULT_TEAM_PROVIDER),
543
748
  commandDispatcher: {
544
749
  async execute(sessionId, line, signal) {
545
- const agent = ctx.agents.get(sessionId)
546
- if (agent === undefined) throw new Error(`execution session ${sessionId} is not available`)
750
+ const agent = await resolveExecutionAgent(ctx, sessionId)
547
751
  return (await ctx.commands.execute(agent, line, [], signal))?.result
548
752
  },
549
753
  },
@@ -558,10 +762,22 @@ function applyImpl(ctx: Context, config?: Config): void {
558
762
  // provider package can resolve it and admit itself; the board itself knows
559
763
  // no provider vocabulary. A capture-only test context implements no service
560
764
  // registry and the board still serves its own surfaces.
765
+ //
766
+ // The same service carries the read/write face an in-process consumer drives
767
+ // the board through — the remote bridge's board plugin reads and applies over
768
+ // it instead of opening an HTTP surface of its own, which the board's routes
769
+ // would refuse anyway (their guard admits a browser-shaped request, not a
770
+ // process). Every member is a forward of the Host service method of the same
771
+ // name: no gate, no normalization and no state lives here, so a consumer
772
+ // reaching the board this way is refused by exactly what refuses a browser.
561
773
  if (typeof (ctx as { provide?: unknown }).provide === 'function') {
562
774
  ctx.provide(TASK_BOARD_SERVICE_NAME, {
563
775
  registerExtension: (extension: TaskBoardExtension) => host.registerExtension(extension),
564
776
  isExtensionEnabled: (extensionId: string) => host.extensions.isActive(extensionId),
777
+ snapshot: () => host.snapshot(),
778
+ apply: (requestId: string, action: TaskBoardAction, initiator?: string) => host.apply(requestId, action, initiator),
779
+ subscribe: (listener: () => void) => host.subscribe(listener),
780
+ verificationOptions: () => host.verificationOptions(),
565
781
  })
566
782
  }
567
783
 
@@ -654,7 +870,11 @@ function applyImpl(ctx: Context, config?: Config): void {
654
870
  const handle = offGate as { dispose(): void }
655
871
  disposers.push(() => { handle.dispose() })
656
872
  }
657
- const routes = makeTaskBoardRoutes(host, resolveProxyAccess(config), {
873
+ const routes = makeTaskBoardRoutes(host, {
874
+ ...resolveProxyAccess(config),
875
+ connection: () => resolveConnectionTrust(ctx),
876
+ }, {
877
+ attachments: () => resolveAttachmentStore(ctx),
658
878
  parseTask: async (request, signal) => {
659
879
  const llm = resolveLlmRuntime(ctx)
660
880
  if (llm === undefined) throw new TaskParseError('no-model', 'this deployment serves no llm service')