@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.
- package/README.i18n.yaml +2 -2
- package/README.md +29 -22
- package/README.zh.md +29 -22
- package/lib/client.js +1553 -670
- package/lib/client.js.map +1 -1
- package/lib/index.js +757 -419
- package/lib/types/client/PluginSettingsCard.d.ts +60 -0
- package/lib/types/client/TaskBoardSettingsCard.d.ts +14 -0
- package/lib/types/client/board/ExecutionLog.d.ts +16 -0
- package/lib/types/client/board/TaskForm.d.ts +4 -0
- package/lib/types/client/board/VerificationReport.d.ts +2 -15
- package/lib/types/client/body-mutations.d.ts +45 -0
- package/lib/types/client/locales.d.ts +44 -6
- package/lib/types/client/suppress-schedule-row.d.ts +86 -0
- package/lib/types/client/telemetry.d.ts +14 -2
- package/lib/types/core/controller.d.ts +1 -1
- package/lib/types/core/execution-summary.d.ts +52 -0
- package/lib/types/core/extension.d.ts +34 -0
- package/lib/types/core/spend-budget.d.ts +28 -0
- package/lib/types/core/subtask.d.ts +59 -49
- package/lib/types/core/tasks.d.ts +37 -9
- package/lib/types/core/use-cases/task-update.d.ts +1 -1
- package/lib/types/core/workspace-target.d.ts +23 -3
- package/lib/types/host/launch-admission.d.ts +8 -9
- package/lib/types/host-ledger.d.ts +96 -50
- package/lib/types/host-routes.d.ts +49 -0
- package/lib/types/host-runner.d.ts +24 -11
- package/lib/types/host-service.d.ts +38 -50
- package/lib/types/host-spend.d.ts +52 -0
- package/lib/types/index.d.ts +70 -61
- package/lib/types/loopback.d.ts +41 -1
- package/lib/types/protocol.d.ts +0 -5
- package/lib/types/tool-surface.d.ts +1 -0
- package/package.json +25 -25
- package/src/client/CardDefaultPresetField.tsx +1 -1
- package/src/client/PluginSettingsCard.tsx +140 -20
- package/src/client/TaskBoardSettingsCard.tsx +104 -24
- package/src/client/board/ExecutionLog.tsx +140 -0
- package/src/client/board/LinkSubtaskModal.tsx +1 -9
- package/src/client/board/NewTaskModal.tsx +2 -11
- package/src/client/board/TaskCard.tsx +45 -23
- package/src/client/board/TaskDetail.tsx +407 -261
- package/src/client/board/TaskForm.tsx +19 -4
- package/src/client/board/VerificationReport.tsx +143 -104
- package/src/client/board/task-markdown.module.css +11 -8
- package/src/client/board-settings.module.css +35 -7
- package/src/client/board.module.css +855 -115
- package/src/client/body-mutations.ts +133 -0
- package/src/client/index.ts +10 -0
- package/src/client/locales.ts +101 -24
- package/src/client/settings-card.module.css +141 -11
- package/src/client/suppress-schedule-row.ts +198 -0
- package/src/client/telemetry.ts +47 -2
- package/src/core/controller.ts +1 -3
- package/src/core/execution-summary.ts +96 -0
- package/src/core/extension.ts +34 -0
- package/src/core/spend-budget.ts +35 -0
- package/src/core/store.ts +4 -0
- package/src/core/subtask.ts +81 -76
- package/src/core/tasks.ts +48 -10
- package/src/core/use-cases/task-update.ts +1 -3
- package/src/core/workspace-target.ts +27 -3
- package/src/host/agent-tools.ts +14 -15
- package/src/host/launch-admission.ts +8 -9
- package/src/host-ledger.ts +218 -127
- package/src/host-routes.ts +65 -2
- package/src/host-runner.ts +68 -35
- package/src/host-service.ts +136 -132
- package/src/host-spend.ts +105 -0
- package/src/index.ts +115 -104
- package/src/loopback.ts +57 -1
- package/src/protocol.ts +2 -9
- package/src/tool-surface.ts +1 -0
- package/lib/types/client/board/team-run-promotion.d.ts +0 -26
- package/src/client/board/team-run-promotion.ts +0 -39
package/src/index.ts
CHANGED
|
@@ -17,13 +17,14 @@ import type {} from '@deepseek-ai/dsh-host-webserver'
|
|
|
17
17
|
import type {} from '@deepseek-ai/dsh-tools'
|
|
18
18
|
import type { ToolDefinition } from '@deepseek-ai/dsh-tools'
|
|
19
19
|
import type { LlmRuntime } from '@deepseek-ai/dsh-llm'
|
|
20
|
-
import { TaskBoardHostService, type HostTimerFace
|
|
20
|
+
import { TaskBoardHostService, type HostTimerFace } from './host-service.ts'
|
|
21
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
24
|
import { 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
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'
|
|
27
28
|
import {
|
|
28
29
|
DEFAULT_VERIFICATION_BUDGET_SECONDS,
|
|
29
30
|
DEFAULT_VERIFICATION_CALL_TIMEOUT_SECONDS,
|
|
@@ -38,8 +39,9 @@ import { DEFAULT_SESSION_PERMISSION } from './core/handover.ts'
|
|
|
38
39
|
import type { CardDefaults } from './core/card-defaults.ts'
|
|
39
40
|
import { buildTaskBoardTools, TASK_BOARD_TOOL_NAMES } from './host/agent-tools.ts'
|
|
40
41
|
import { PLUGIN_TOOL_SECTION_ORDERS, visibleToolText } from './tool-surface.ts'
|
|
41
|
-
import { makeTaskBoardRoutes } from './host-routes.ts'
|
|
42
|
+
import { makeTaskBoardRoutes, type TaskBoardConnectionTrust } from './host-routes.ts'
|
|
42
43
|
import { TASK_BOARD_SERVICE_NAME, type TaskBoardExtension } from './core/extension.ts'
|
|
44
|
+
import type { TaskBoardAction } from './protocol.ts'
|
|
43
45
|
import { mountOnce } from './mount-once.ts'
|
|
44
46
|
import { createGoalVerificationGate, type GoalFace } from './host/verification-gate.ts'
|
|
45
47
|
import { normalizeCatalog, type ModelCatalogView, type VerificationSettings } from './core/verification.ts'
|
|
@@ -86,6 +88,19 @@ export interface Config {
|
|
|
86
88
|
trustedProxyHosts?: string[]
|
|
87
89
|
/** Environment variable whose value the authenticated proxy injects upstream. */
|
|
88
90
|
proxyTokenEnv?: string
|
|
91
|
+
/**
|
|
92
|
+
* Whether the operator's OWN reverse proxy or tunnel may speak for the
|
|
93
|
+
* browser (default OFF). Off keeps the pre-existing fence exactly: a request
|
|
94
|
+
* that carries a forwarding header is never local, so only a direct loopback
|
|
95
|
+
* client or an allowlisted token-injecting proxy reaches the board (issue
|
|
96
|
+
* #1906). On admits one narrower case — a forwarded request whose socket and
|
|
97
|
+
* Host are both this machine's loopback upstream, i.e. the proxy dials the
|
|
98
|
+
* board itself (issue #1918) — and still requires the browser same-origin
|
|
99
|
+
* marker, so a third party's tunnel is only trusted while the operator says
|
|
100
|
+
* it is. Volatile: the fence reads it at each request, so an edit binds the
|
|
101
|
+
* next request without re-registering the routes.
|
|
102
|
+
*/
|
|
103
|
+
trustForwardedProxy?: Volatile<boolean>
|
|
89
104
|
/**
|
|
90
105
|
* An explicit baseline for the permission confirmation gate. Left unset, the
|
|
91
106
|
* board follows the Host's own default permission preset — the value new DSH
|
|
@@ -98,8 +113,8 @@ export interface Config {
|
|
|
98
113
|
/**
|
|
99
114
|
* Subtask depth limit, 1..3 (default 1). At 1 a task may carry one level of
|
|
100
115
|
* subtasks and a subtask cannot be given subtasks of its own; raising it
|
|
101
|
-
* allows deeper trees. Every extra level
|
|
102
|
-
*
|
|
116
|
+
* allows deeper trees. Every extra level is another tree the card's own
|
|
117
|
+
* session may have to dispatch, so the ceiling is deliberately small.
|
|
103
118
|
*/
|
|
104
119
|
maxSubtaskDepth?: Volatile<number>
|
|
105
120
|
/**
|
|
@@ -111,21 +126,24 @@ export interface Config {
|
|
|
111
126
|
sessionPollSeconds?: Volatile<number>
|
|
112
127
|
/**
|
|
113
128
|
* How many run launches this board may have in flight at once (1..16,
|
|
114
|
-
* default 3).
|
|
115
|
-
*
|
|
116
|
-
*
|
|
117
|
-
*
|
|
118
|
-
*
|
|
119
|
-
*
|
|
120
|
-
* queueing.
|
|
129
|
+
* default 3). A run opens one session, so a burst is several cards run at
|
|
130
|
+
* once (several tabs, or a due schedule firing while a manual run starts);
|
|
131
|
+
* without a bound the Host would ask DSH for all of them in the same tick.
|
|
132
|
+
* This is the mechanism that enforces the repository's measured guidance for
|
|
133
|
+
* heavy implementation subagents. Runs wait their turn instead of being
|
|
134
|
+
* dropped, and every one of them still starts. Read at each admission, so an
|
|
135
|
+
* edit bounds the next launch of a run that is still queueing.
|
|
121
136
|
*/
|
|
122
137
|
runLaunchWidth?: Volatile<number>
|
|
123
138
|
/**
|
|
124
|
-
*
|
|
125
|
-
*
|
|
126
|
-
* only
|
|
139
|
+
* Daily token ceiling for the work this board dispatches (default 0 = no
|
|
140
|
+
* gate). Tokens, not money: the ledger the board measures against prices
|
|
141
|
+
* DeepSeek's own routes only, so a cost cap would read 0 elsewhere. Read at
|
|
142
|
+
* each gate, so an edit binds the next run without a remount; a manual
|
|
143
|
+
* run/rerun whose day already spent the cap is refused, and a due occurrence
|
|
144
|
+
* is skipped onto the scheduler with its run budget untouched.
|
|
127
145
|
*/
|
|
128
|
-
|
|
146
|
+
spendBudgetTokens?: Volatile<number>
|
|
129
147
|
/**
|
|
130
148
|
* GLOBAL native /goal switch (default OFF), the master control over whether
|
|
131
149
|
* this board starts a run with dsh's built-in /goal at all. A run uses native
|
|
@@ -213,12 +231,6 @@ export interface Config {
|
|
|
213
231
|
goalVerificationBudgetSeconds?: Volatile<number>
|
|
214
232
|
}
|
|
215
233
|
|
|
216
|
-
/**
|
|
217
|
-
* Continuable-subagent provider for fresh teammates, matching the Agent Teams
|
|
218
|
-
* tool plugin's own `freshProvider` default.
|
|
219
|
-
*/
|
|
220
|
-
export const DEFAULT_TEAM_PROVIDER = 'spawn'
|
|
221
|
-
|
|
222
234
|
/**
|
|
223
235
|
* Profile-patch shape of {@link Config}: what the Host validates the row's
|
|
224
236
|
* config against, before the schema turns volatile fields into live references
|
|
@@ -240,6 +252,8 @@ export interface ConfigInput {
|
|
|
240
252
|
trustedProxyHosts?: string[]
|
|
241
253
|
/** Environment variable whose value the authenticated proxy injects. */
|
|
242
254
|
proxyTokenEnv?: string
|
|
255
|
+
/** Trust a forwarded request that landed on this machine's loopback upstream; default off. */
|
|
256
|
+
trustForwardedProxy?: boolean
|
|
243
257
|
/** Explicit baseline for the permission confirmation gate; unset follows the Host default. */
|
|
244
258
|
sessionDefaultPermission?: TaskPermission
|
|
245
259
|
/** Subtask depth limit, 1..3. */
|
|
@@ -248,8 +262,8 @@ export interface ConfigInput {
|
|
|
248
262
|
sessionPollSeconds?: number
|
|
249
263
|
/** Concurrent run launches allowed at once, 1..16. */
|
|
250
264
|
runLaunchWidth?: number
|
|
251
|
-
/**
|
|
252
|
-
|
|
265
|
+
/** Daily token ceiling for board runs; 0 disables the gate. */
|
|
266
|
+
spendBudgetTokens?: number
|
|
253
267
|
/** Global native /goal switch; default off, frozen per execution. */
|
|
254
268
|
goalRunEnabled?: boolean
|
|
255
269
|
/** Agent preset a new card starts from; blank = not set. */
|
|
@@ -278,11 +292,12 @@ export const Config: z<ConfigInput, Config> = z.object({
|
|
|
278
292
|
preventIdleSleep: z.boolean().default(false).volatile(),
|
|
279
293
|
trustedProxyHosts: z.array(z.string()).default([]),
|
|
280
294
|
proxyTokenEnv: z.string().min(1).default(DEFAULT_PROXY_TOKEN_ENV),
|
|
295
|
+
trustForwardedProxy: z.boolean().default(false).volatile(),
|
|
281
296
|
sessionDefaultPermission: z.union(TASK_PERMISSIONS),
|
|
282
297
|
maxSubtaskDepth: z.number().min(SUBTASK_DEPTH_MIN).max(SUBTASK_DEPTH_MAX).default(DEFAULT_SUBTASK_DEPTH).volatile(),
|
|
283
298
|
sessionPollSeconds: z.number().min(SESSION_POLL_MIN_SECONDS).max(SESSION_POLL_MAX_SECONDS).default(DEFAULT_SESSION_POLL_SECONDS).volatile(),
|
|
284
299
|
runLaunchWidth: z.number().min(RUN_LAUNCH_WIDTH_MIN).max(RUN_LAUNCH_WIDTH_MAX).default(DEFAULT_RUN_LAUNCH_WIDTH).volatile(),
|
|
285
|
-
|
|
300
|
+
spendBudgetTokens: z.number().min(DEFAULT_SPEND_BUDGET_TOKENS).default(DEFAULT_SPEND_BUDGET_TOKENS).volatile(),
|
|
286
301
|
goalRunEnabled: z.boolean().default(false).volatile(),
|
|
287
302
|
cardDefaultMode: z.string().default('').volatile(),
|
|
288
303
|
cardDefaultPermission: z.union([...TASK_PERMISSIONS, '']).default('').volatile(),
|
|
@@ -338,17 +353,66 @@ export function readConfigField<T>(field: Volatile<T> | T | undefined, fallback:
|
|
|
338
353
|
return field as T
|
|
339
354
|
}
|
|
340
355
|
|
|
341
|
-
/**
|
|
342
|
-
|
|
356
|
+
/**
|
|
357
|
+
* Resolve proxy access without ever placing the token value in plugin config.
|
|
358
|
+
*
|
|
359
|
+
* The forwarded-proxy switch travels as a reader rather than a value: it is
|
|
360
|
+
* schema-volatile, so the fence must read it when a request arrives instead of
|
|
361
|
+
* when the routes are registered.
|
|
362
|
+
* @param config - the resolved plugin config.
|
|
363
|
+
* @param env - environment holding the proxy token value.
|
|
364
|
+
* @returns the route access handed to {@link makeTaskBoardRoutes}.
|
|
365
|
+
*/
|
|
366
|
+
export function resolveProxyAccess(config: Config | undefined, env: NodeJS.ProcessEnv = process.env): {
|
|
367
|
+
trustedProxyHosts: string[]
|
|
368
|
+
proxyToken?: string
|
|
369
|
+
trustForwardedProxy: () => boolean
|
|
370
|
+
} {
|
|
371
|
+
const trustForwardedProxy = (): boolean => readConfigField(config?.trustForwardedProxy, DEFAULT_TRUST_FORWARDED_PROXY)
|
|
343
372
|
const trustedProxyHosts = config?.trustedProxyHosts ?? []
|
|
344
|
-
if (trustedProxyHosts.length === 0) return { trustedProxyHosts }
|
|
373
|
+
if (trustedProxyHosts.length === 0) return { trustedProxyHosts, trustForwardedProxy }
|
|
345
374
|
const proxyTokenEnv = config?.proxyTokenEnv ?? DEFAULT_PROXY_TOKEN_ENV
|
|
346
375
|
if (proxyTokenEnv.trim() === '') throw new Error('task-board: proxyTokenEnv must not be empty')
|
|
347
376
|
const proxyToken = env[proxyTokenEnv]
|
|
348
377
|
if (proxyToken === undefined || proxyToken === '') {
|
|
349
378
|
throw new Error(`task-board: trustedProxyHosts requires a non-empty ${proxyTokenEnv} environment variable`)
|
|
350
379
|
}
|
|
351
|
-
return { trustedProxyHosts, proxyToken }
|
|
380
|
+
return { trustedProxyHosts, proxyToken, trustForwardedProxy }
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
/**
|
|
384
|
+
/**
|
|
385
|
+
* Schema default for the forwarded-proxy switch, re-read for hand-built
|
|
386
|
+
* contexts. Deliberately false: a deployment that never configured it keeps
|
|
387
|
+
* refusing every forwarded request, which is the #1906 fence.
|
|
388
|
+
*/
|
|
389
|
+
export const DEFAULT_TRUST_FORWARDED_PROXY = false
|
|
390
|
+
|
|
391
|
+
/**
|
|
392
|
+
* Resolve the composition's optional `connection` service.
|
|
393
|
+
*
|
|
394
|
+
* The service is the Host's own browser-session authority: it fronts every
|
|
395
|
+
* `/api` request with the Host/Origin fence and the signed `dsh-auth-*` cookie,
|
|
396
|
+
* which is what a deployment behind a reverse proxy or ingress validates on the
|
|
397
|
+
* same authority the GUI is served from. The board bridges it instead of
|
|
398
|
+
* repeating that check, so a proxy request the Host already authenticated is
|
|
399
|
+
* admitted without a board-specific host allowlist (issue #1930). It is
|
|
400
|
+
* deliberately resolved like the agent-tool registry rather than injected:
|
|
401
|
+
* a composition that serves no connection keeps mounting the board on the
|
|
402
|
+
* pre-existing loopback fence, and one that mounts the service later is picked
|
|
403
|
+
* up on the next request because the fence asks this resolver each time.
|
|
404
|
+
* @param ctx - the plugin context.
|
|
405
|
+
* @returns the trust face, or undefined when this deployment serves none.
|
|
406
|
+
*/
|
|
407
|
+
export function resolveConnectionTrust(ctx: Context): TaskBoardConnectionTrust | undefined {
|
|
408
|
+
try {
|
|
409
|
+
const connection = ctx.get('connection') as Partial<TaskBoardConnectionTrust> | undefined
|
|
410
|
+
return connection !== undefined && typeof connection.requestRejection === 'function'
|
|
411
|
+
? connection as TaskBoardConnectionTrust
|
|
412
|
+
: undefined
|
|
413
|
+
} catch {
|
|
414
|
+
return undefined
|
|
415
|
+
}
|
|
352
416
|
}
|
|
353
417
|
|
|
354
418
|
/** The registry face the agent tools register into. */
|
|
@@ -431,80 +495,6 @@ export function resolveHostDefaultPermission(ctx: Context): TaskPermission | und
|
|
|
431
495
|
}
|
|
432
496
|
}
|
|
433
497
|
|
|
434
|
-
/**
|
|
435
|
-
* How long one teammate may take to reach its durable active or failed edge.
|
|
436
|
-
* Agent Teams provisioning normally resolves in seconds; the bound exists so a
|
|
437
|
-
* hung spawn settles the subtask instead of holding the cascade open forever.
|
|
438
|
-
*/
|
|
439
|
-
const TEAMMATE_PROVISION_TIMEOUT_MS = 600_000
|
|
440
|
-
|
|
441
|
-
/** The subset of the Agent Teams service this plugin drives. */
|
|
442
|
-
interface AgentTeamsFace {
|
|
443
|
-
spawnTeammate(caller: unknown, request: {
|
|
444
|
-
name: string
|
|
445
|
-
description: string
|
|
446
|
-
prompt: Array<{ type: 'text'; text: string }>
|
|
447
|
-
context: 'fresh' | 'fork'
|
|
448
|
-
provider: string
|
|
449
|
-
signal: AbortSignal
|
|
450
|
-
}): Promise<{ member?: { id?: string; phase?: string; error?: string } }>
|
|
451
|
-
}
|
|
452
|
-
|
|
453
|
-
/**
|
|
454
|
-
* Resolve the optional Agent Teams service. Like the tool registry and the llm
|
|
455
|
-
* runtime, it is deliberately not injected: a deployment without Agent Teams
|
|
456
|
-
* must still mount the whole board and only lose team-mode runs.
|
|
457
|
-
* @param ctx - the plugin context.
|
|
458
|
-
* @returns the service, or undefined when this deployment serves none.
|
|
459
|
-
*/
|
|
460
|
-
export function resolveAgentTeams(ctx: Context): AgentTeamsFace | undefined {
|
|
461
|
-
try {
|
|
462
|
-
const teams = ctx.get('agentTeams') as AgentTeamsFace | undefined
|
|
463
|
-
return teams !== undefined && typeof teams.spawnTeammate === 'function' ? teams : undefined
|
|
464
|
-
} catch {
|
|
465
|
-
return undefined
|
|
466
|
-
}
|
|
467
|
-
}
|
|
468
|
-
|
|
469
|
-
/**
|
|
470
|
-
* Build the team dispatcher: the run's Lead session spawns one teammate per
|
|
471
|
-
* subtask through the Agent Teams service, and the teammate's session id is
|
|
472
|
-
* attached to that subtask's execution so the ordinary session monitor settles
|
|
473
|
-
* it. Returns undefined when the deployment serves no Agent Teams service or
|
|
474
|
-
* no live-agent registry, which makes a team run fail closed.
|
|
475
|
-
* @param ctx - the plugin context.
|
|
476
|
-
* @param provider - the continuable-subagent provider for fresh teammates.
|
|
477
|
-
* @returns the dispatcher, or undefined when team runs cannot be served.
|
|
478
|
-
*/
|
|
479
|
-
export function buildTeamDispatcher(ctx: Context, provider: string): TaskBoardTeamDispatcher | undefined {
|
|
480
|
-
const teams = resolveAgentTeams(ctx)
|
|
481
|
-
if (teams === undefined) return undefined
|
|
482
|
-
if (typeof (ctx.agents as { get?: unknown } | undefined)?.get !== 'function') return undefined
|
|
483
|
-
return {
|
|
484
|
-
async spawn(input) {
|
|
485
|
-
const lead = ctx.agents.get(input.leadSessionId as Parameters<typeof ctx.agents.get>[0])
|
|
486
|
-
if (lead === undefined) return { error: `lead session ${input.leadSessionId} is not live` }
|
|
487
|
-
try {
|
|
488
|
-
const result = await teams.spawnTeammate(lead, {
|
|
489
|
-
name: input.name,
|
|
490
|
-
description: input.description,
|
|
491
|
-
prompt: [{ type: 'text', text: input.prompt }],
|
|
492
|
-
context: 'fresh',
|
|
493
|
-
provider,
|
|
494
|
-
signal: AbortSignal.timeout(TEAMMATE_PROVISION_TIMEOUT_MS),
|
|
495
|
-
})
|
|
496
|
-
const member = result?.member
|
|
497
|
-
if (member === undefined) return { error: 'Agent Teams returned no teammate' }
|
|
498
|
-
if (member.phase === 'failed') return { error: member.error ?? 'teammate provisioning failed' }
|
|
499
|
-
if (typeof member.id !== 'string' || member.id === '') return { error: 'Agent Teams returned no teammate session' }
|
|
500
|
-
return { sessionId: member.id }
|
|
501
|
-
} catch (error) {
|
|
502
|
-
return { error: `teammate provisioning failed: ${error instanceof Error ? error.message : String(error)}` }
|
|
503
|
-
}
|
|
504
|
-
},
|
|
505
|
-
}
|
|
506
|
-
}
|
|
507
|
-
|
|
508
498
|
/**
|
|
509
499
|
* Read the optional `llm` service. The board deliberately does not inject it:
|
|
510
500
|
* a deployment without a model must still mount the board, and the parse route
|
|
@@ -617,6 +607,12 @@ function applyImpl(ctx: Context, config?: Config): void {
|
|
|
617
607
|
* remounting the row; the Host clamps a hand-edited value into the schema range.
|
|
618
608
|
*/
|
|
619
609
|
const runLaunchWidth = (): number => readConfigField(config?.runLaunchWidth, DEFAULT_RUN_LAUNCH_WIDTH)
|
|
610
|
+
/**
|
|
611
|
+
* Current daily token cap, read at each gate like the width above. The value
|
|
612
|
+
* decides first: 0 — the default — ends the gate before a file is opened, so
|
|
613
|
+
* a board that never set a cap pays nothing for it.
|
|
614
|
+
*/
|
|
615
|
+
const spendBudgetTokens = (): number => readConfigField(config?.spendBudgetTokens, DEFAULT_SPEND_BUDGET_TOKENS)
|
|
620
616
|
/**
|
|
621
617
|
* The baseline the permission confirmation gate judges against: the row's own
|
|
622
618
|
* `sessionDefaultPermission` when the deployment pins one, otherwise the Host's
|
|
@@ -681,11 +677,11 @@ function applyImpl(ctx: Context, config?: Config): void {
|
|
|
681
677
|
maxSubtaskDepth: maxSubtaskDepth(),
|
|
682
678
|
goalRunEnabled,
|
|
683
679
|
runLaunchWidth,
|
|
680
|
+
spendBudgetTokens,
|
|
684
681
|
cardDefaults,
|
|
685
682
|
verificationSettings,
|
|
686
683
|
verificationCatalog,
|
|
687
684
|
timers: resolveHostTimers(ctx),
|
|
688
|
-
team: buildTeamDispatcher(ctx, config?.teamProvider ?? DEFAULT_TEAM_PROVIDER),
|
|
689
685
|
commandDispatcher: {
|
|
690
686
|
async execute(sessionId, line, signal) {
|
|
691
687
|
const agent = await resolveExecutionAgent(ctx, sessionId)
|
|
@@ -703,10 +699,22 @@ function applyImpl(ctx: Context, config?: Config): void {
|
|
|
703
699
|
// provider package can resolve it and admit itself; the board itself knows
|
|
704
700
|
// no provider vocabulary. A capture-only test context implements no service
|
|
705
701
|
// registry and the board still serves its own surfaces.
|
|
702
|
+
//
|
|
703
|
+
// The same service carries the read/write face an in-process consumer drives
|
|
704
|
+
// the board through — the remote bridge's board plugin reads and applies over
|
|
705
|
+
// it instead of opening an HTTP surface of its own, which the board's routes
|
|
706
|
+
// would refuse anyway (their guard admits a browser-shaped request, not a
|
|
707
|
+
// process). Every member is a forward of the Host service method of the same
|
|
708
|
+
// name: no gate, no normalization and no state lives here, so a consumer
|
|
709
|
+
// reaching the board this way is refused by exactly what refuses a browser.
|
|
706
710
|
if (typeof (ctx as { provide?: unknown }).provide === 'function') {
|
|
707
711
|
ctx.provide(TASK_BOARD_SERVICE_NAME, {
|
|
708
712
|
registerExtension: (extension: TaskBoardExtension) => host.registerExtension(extension),
|
|
709
713
|
isExtensionEnabled: (extensionId: string) => host.extensions.isActive(extensionId),
|
|
714
|
+
snapshot: () => host.snapshot(),
|
|
715
|
+
apply: (requestId: string, action: TaskBoardAction, initiator?: string) => host.apply(requestId, action, initiator),
|
|
716
|
+
subscribe: (listener: () => void) => host.subscribe(listener),
|
|
717
|
+
verificationOptions: () => host.verificationOptions(),
|
|
710
718
|
})
|
|
711
719
|
}
|
|
712
720
|
|
|
@@ -799,7 +807,10 @@ function applyImpl(ctx: Context, config?: Config): void {
|
|
|
799
807
|
const handle = offGate as { dispose(): void }
|
|
800
808
|
disposers.push(() => { handle.dispose() })
|
|
801
809
|
}
|
|
802
|
-
const routes = makeTaskBoardRoutes(host,
|
|
810
|
+
const routes = makeTaskBoardRoutes(host, {
|
|
811
|
+
...resolveProxyAccess(config),
|
|
812
|
+
connection: () => resolveConnectionTrust(ctx),
|
|
813
|
+
}, {
|
|
803
814
|
parseTask: async (request, signal) => {
|
|
804
815
|
const llm = resolveLlmRuntime(ctx)
|
|
805
816
|
if (llm === undefined) throw new TaskParseError('no-model', 'this deployment serves no llm service')
|
package/src/loopback.ts
CHANGED
|
@@ -8,6 +8,19 @@
|
|
|
8
8
|
* Semantics: RFC 5735 IPv4 127/8, ::1, IPv4-mapped ::ffff:127/8 (matching the
|
|
9
9
|
* remote-web-ui gate), localhost hostnames, plus the browser same-origin
|
|
10
10
|
* markers (sec-fetch-site and Origin) for the request-level fence.
|
|
11
|
+
*
|
|
12
|
+
* A reverse proxy in front of the host rewrites the Host header to its own
|
|
13
|
+
* upstream literal (a Cloudflare tunnel, frp and an nginx reverse proxy all
|
|
14
|
+
* dial 127.0.0.1:<port>), and the socket the origin sees is the proxy's, which
|
|
15
|
+
* is loopback by construction. Both halves of the fence then hold for a public
|
|
16
|
+
* request. Forwarding headers are the signal that a hop stands in between: a
|
|
17
|
+
* request that carries CF-Connecting-IP or X-Forwarded-For is answered through
|
|
18
|
+
* a proxy and is never treated as a local one (issue #1906).
|
|
19
|
+
*
|
|
20
|
+
* An operator who runs that proxy or tunnel themselves can opt into the
|
|
21
|
+
* narrower case: isForwardedLoopbackRequest describes a forwarded request that
|
|
22
|
+
* still landed on this machine's loopback upstream, and a route family admits
|
|
23
|
+
* it only behind its own default-off switch (issue #1918).
|
|
11
24
|
* @module dsh-web-shared/host/loopback
|
|
12
25
|
*/
|
|
13
26
|
|
|
@@ -36,13 +49,29 @@ export function isLoopbackHostname(hostname: string): boolean {
|
|
|
36
49
|
return isIPv4Loopback(hostname)
|
|
37
50
|
}
|
|
38
51
|
|
|
52
|
+
/**
|
|
53
|
+
* Whether a reverse proxy stood between the client and this host: the request
|
|
54
|
+
* carries CF-Connecting-IP or X-Forwarded-For. Either header is stamped by a
|
|
55
|
+
* hop that forwards traffic, so the request did not originate on this machine.
|
|
56
|
+
* @param request - node HTTP request.
|
|
57
|
+
* @returns true when a forwarding header is present.
|
|
58
|
+
*/
|
|
59
|
+
export function isProxiedRequest(request: IncomingMessage): boolean {
|
|
60
|
+
return request.headers['cf-connecting-ip'] !== undefined
|
|
61
|
+
|| request.headers['x-forwarded-for'] !== undefined
|
|
62
|
+
}
|
|
63
|
+
|
|
39
64
|
/**
|
|
40
65
|
* Request-level trust fence: a loopback socket address AND a loopback Host
|
|
41
66
|
* header, plus browser same-origin markers. The socket address is
|
|
42
|
-
* authoritative;
|
|
67
|
+
* authoritative for a direct connection; a request that carries a forwarding
|
|
68
|
+
* header is refused outright, because a proxy in front of the host makes both
|
|
69
|
+
* the socket address and the Host header describe the proxy rather than the
|
|
70
|
+
* client. X-Forwarded-For is therefore never evidence *for* loopback.
|
|
43
71
|
*/
|
|
44
72
|
export function isLoopbackRequest(request: IncomingMessage): boolean {
|
|
45
73
|
if (!isLoopbackAddress(request.socket.remoteAddress)) return false
|
|
74
|
+
if (isProxiedRequest(request)) return false
|
|
46
75
|
const host = request.headers.host
|
|
47
76
|
if (typeof host !== 'string') return false
|
|
48
77
|
let hostUrl: URL
|
|
@@ -61,3 +90,30 @@ export function isLoopbackRequest(request: IncomingMessage): boolean {
|
|
|
61
90
|
return false
|
|
62
91
|
}
|
|
63
92
|
}
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Whether a forwarded request landed on this machine's loopback upstream: a
|
|
96
|
+
* forwarding header (the proxy's own stamp), a loopback socket address (the
|
|
97
|
+
* proxy dials 127.0.0.1:<port>), and a loopback Host header (the proxy rewrote
|
|
98
|
+
* the authority to its upstream literal).
|
|
99
|
+
*
|
|
100
|
+
* This is a fact about the route, not a trust decision. A public request to a
|
|
101
|
+
* tunnel satisfies all three by construction, because the proxy is the client
|
|
102
|
+
* of this process: only a caller that operates the proxy can decide it stands
|
|
103
|
+
* for the browser, which is why every consumer keeps this behind an explicit
|
|
104
|
+
* default-off switch and its own browser markers. isLoopbackRequest is
|
|
105
|
+
* unchanged and still refuses a forwarded request (issue #1906).
|
|
106
|
+
* @param request - node HTTP request.
|
|
107
|
+
* @returns true when a forwarding header, a loopback socket, and a loopback Host all hold.
|
|
108
|
+
*/
|
|
109
|
+
export function isForwardedLoopbackRequest(request: IncomingMessage): boolean {
|
|
110
|
+
if (!isProxiedRequest(request)) return false
|
|
111
|
+
if (!isLoopbackAddress(request.socket.remoteAddress)) return false
|
|
112
|
+
const host = request.headers.host
|
|
113
|
+
if (typeof host !== 'string') return false
|
|
114
|
+
try {
|
|
115
|
+
return isLoopbackHostname(new URL('http://' + host).hostname)
|
|
116
|
+
} catch {
|
|
117
|
+
return false
|
|
118
|
+
}
|
|
119
|
+
}
|
package/src/protocol.ts
CHANGED
|
@@ -80,11 +80,6 @@ export interface TaskBoardSnapshot {
|
|
|
80
80
|
* disable the subtask controls; the Host ledger is the authority.
|
|
81
81
|
*/
|
|
82
82
|
maxSubtaskDepth?: number
|
|
83
|
-
/**
|
|
84
|
-
* Whether this deployment serves the Agent Teams service, so a task may opt
|
|
85
|
-
* into team execution (Team Lead session plus one teammate per subtask).
|
|
86
|
-
*/
|
|
87
|
-
teamRunAvailable?: boolean
|
|
88
83
|
/**
|
|
89
84
|
* Live GLOBAL native-/goal switch. The browser uses it to disable the
|
|
90
85
|
* task-level option (and explain that the global switch must be turned on
|
|
@@ -391,7 +386,7 @@ function handoverPayload(value: unknown): TaskHandoverInput | undefined {
|
|
|
391
386
|
|
|
392
387
|
function createInput(value: unknown): value is NewTaskInput {
|
|
393
388
|
const input = record(value)
|
|
394
|
-
if (input === undefined || !exactKeys(input, ['title', 'description', 'prompt', 'parentId', 'workspaceId', 'mode', 'permission', 'schedule', 'freeze', 'handover', 'model', 'reasoningEffort', 'applyCardDefaults', 'reuseSession', '
|
|
389
|
+
if (input === undefined || !exactKeys(input, ['title', 'description', 'prompt', 'parentId', 'workspaceId', 'mode', 'permission', 'schedule', 'freeze', 'handover', 'model', 'reasoningEffort', 'applyCardDefaults', 'reuseSession', 'goalRun', 'skipVerification', 'tags', 'integrations'])) return false
|
|
395
390
|
if (input.parentId !== undefined && (typeof input.parentId !== 'string' || input.parentId.trim() === '')) return false
|
|
396
391
|
if (typeof input.title !== 'string' || typeof input.description !== 'string' || typeof input.prompt !== 'string') return false
|
|
397
392
|
// The reasoning effort is an adapter-owned id the Host resolves against the
|
|
@@ -401,7 +396,6 @@ function createInput(value: unknown): value is NewTaskInput {
|
|
|
401
396
|
if (!optionalString(input.workspaceId) || !optionalString(input.mode) || !optionalString(input.model) || !optionalString(input.reasoningEffort)) return false
|
|
402
397
|
if (input.applyCardDefaults !== undefined && typeof input.applyCardDefaults !== 'boolean') return false
|
|
403
398
|
if (input.reuseSession !== undefined && typeof input.reuseSession !== 'boolean') return false
|
|
404
|
-
if (input.teamRun !== undefined && typeof input.teamRun !== 'boolean') return false
|
|
405
399
|
if (input.goalRun !== undefined && typeof input.goalRun !== 'boolean') return false
|
|
406
400
|
if (input.skipVerification !== undefined && typeof input.skipVerification !== 'boolean') return false
|
|
407
401
|
if (input.permission !== undefined && !isTaskPermission(input.permission)) return false
|
|
@@ -426,10 +420,9 @@ function createInput(value: unknown): value is NewTaskInput {
|
|
|
426
420
|
|
|
427
421
|
function updatePatch(value: unknown): boolean {
|
|
428
422
|
const patch = record(value)
|
|
429
|
-
if (patch === undefined || !exactKeys(patch, ['title', 'description', 'prompt', 'workspaceId', 'mode', 'permission', 'freeze', 'handover', 'model', 'reasoningEffort', 'reuseSession', '
|
|
423
|
+
if (patch === undefined || !exactKeys(patch, ['title', 'description', 'prompt', 'workspaceId', 'mode', 'permission', 'freeze', 'handover', 'model', 'reasoningEffort', 'reuseSession', 'goalRun', 'skipVerification', 'tags'])) return false
|
|
430
424
|
// null (or false) clears the reuse opt-in; only a real boolean is accepted.
|
|
431
425
|
if (patch.reuseSession !== undefined && patch.reuseSession !== null && typeof patch.reuseSession !== 'boolean') return false
|
|
432
|
-
if (patch.teamRun !== undefined && patch.teamRun !== null && typeof patch.teamRun !== 'boolean') return false
|
|
433
426
|
// The goal opt-in is tri-state: null/true return the card to its default
|
|
434
427
|
// (goal run), false pins a single plain turn.
|
|
435
428
|
if (patch.goalRun !== undefined && patch.goalRun !== null && typeof patch.goalRun !== 'boolean') return false
|
package/src/tool-surface.ts
CHANGED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Team-run promotion for a parent card that just gained a subtask. A card with
|
|
3
|
-
* subtasks is exactly what the Agent Team mode is for, so the two join actions
|
|
4
|
-
* (create a subtask, link an existing task) opt the parent in — but only after
|
|
5
|
-
* the Host confirmed the join, and only where the deployment serves Agent
|
|
6
|
-
* Teams. A refused join changes nothing, and a parent that already opted in is
|
|
7
|
-
* left alone rather than rewritten.
|
|
8
|
-
*
|
|
9
|
-
* Nothing here runs on mount or from a render effect: an existing card is only
|
|
10
|
-
* ever touched by the user's own join action, so switching the option off by
|
|
11
|
-
* hand stays off.
|
|
12
|
-
*/
|
|
13
|
-
import type { BoardController } from '../../core/controller.ts';
|
|
14
|
-
import type { TaskRecord } from '../../core/tasks.ts';
|
|
15
|
-
/**
|
|
16
|
-
* Whether a join would promote this parent: the deployment serves Agent Teams
|
|
17
|
-
* and the parent has not opted in yet.
|
|
18
|
-
* @param controller - the board controller (the snapshot carries both facts).
|
|
19
|
-
* @param parent - the task that gained a subtask, if there is one.
|
|
20
|
-
*/
|
|
21
|
-
export declare function parentAwaitsTeamRunPromotion(controller: BoardController, parent: TaskRecord | undefined): boolean;
|
|
22
|
-
/**
|
|
23
|
-
* Opt the parent in after the Host confirmed the join.
|
|
24
|
-
* @returns true when the opt-in was written; false when it did not apply.
|
|
25
|
-
*/
|
|
26
|
-
export declare function promoteParentForTeamRun(controller: BoardController, parent: TaskRecord | undefined): Promise<boolean>;
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Team-run promotion for a parent card that just gained a subtask. A card with
|
|
3
|
-
* subtasks is exactly what the Agent Team mode is for, so the two join actions
|
|
4
|
-
* (create a subtask, link an existing task) opt the parent in — but only after
|
|
5
|
-
* the Host confirmed the join, and only where the deployment serves Agent
|
|
6
|
-
* Teams. A refused join changes nothing, and a parent that already opted in is
|
|
7
|
-
* left alone rather than rewritten.
|
|
8
|
-
*
|
|
9
|
-
* Nothing here runs on mount or from a render effect: an existing card is only
|
|
10
|
-
* ever touched by the user's own join action, so switching the option off by
|
|
11
|
-
* hand stays off.
|
|
12
|
-
*/
|
|
13
|
-
import type { BoardController } from '../../core/controller.ts'
|
|
14
|
-
import type { TaskRecord } from '../../core/tasks.ts'
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* Whether a join would promote this parent: the deployment serves Agent Teams
|
|
18
|
-
* and the parent has not opted in yet.
|
|
19
|
-
* @param controller - the board controller (the snapshot carries both facts).
|
|
20
|
-
* @param parent - the task that gained a subtask, if there is one.
|
|
21
|
-
*/
|
|
22
|
-
export function parentAwaitsTeamRunPromotion(controller: BoardController, parent: TaskRecord | undefined): boolean {
|
|
23
|
-
if (parent === undefined) return false
|
|
24
|
-
const snapshot = controller.getSnapshot()
|
|
25
|
-
if (snapshot.host?.teamRunAvailable !== true) return false
|
|
26
|
-
// The freshest record wins: the card may have been edited since this modal
|
|
27
|
-
// opened with its own copy.
|
|
28
|
-
return (snapshot.tasks.find(task => task.id === parent.id) ?? parent).teamRun !== true
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* Opt the parent in after the Host confirmed the join.
|
|
33
|
-
* @returns true when the opt-in was written; false when it did not apply.
|
|
34
|
-
*/
|
|
35
|
-
export async function promoteParentForTeamRun(controller: BoardController, parent: TaskRecord | undefined): Promise<boolean> {
|
|
36
|
-
if (parent === undefined) return false
|
|
37
|
-
if (!parentAwaitsTeamRunPromotion(controller, parent)) return false
|
|
38
|
-
return await controller.updateTask(parent.id, { teamRun: true })
|
|
39
|
-
}
|