@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.
- package/NOTICE +1 -1
- package/README.en.md +6 -4
- package/README.md +6 -4
- package/README.zh.md +6 -4
- package/icon.png +0 -0
- package/lib/client.js +4428 -1508
- package/lib/client.js.map +1 -1
- package/lib/index.js +2670 -496
- package/lib/types/client/CardDefaultPresetField.d.ts +35 -0
- package/lib/types/client/PluginSettingsCard.d.ts +130 -19
- package/lib/types/client/RangeBubble.d.ts +46 -0
- package/lib/types/client/SegmentGroup.d.ts +28 -0
- package/lib/types/client/TaskBoardSettingsCard.d.ts +63 -0
- package/lib/types/client/board/AttachmentField.d.ts +70 -0
- package/lib/types/client/board/ExecutionLog.d.ts +24 -0
- package/lib/types/client/board/ReasoningEffortField.d.ts +25 -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/board/model-options.d.ts +87 -0
- package/lib/types/client/board/preset-label.d.ts +21 -0
- package/lib/types/client/board/preset-roster.d.ts +45 -0
- package/lib/types/client/board/source-group.d.ts +27 -0
- package/lib/types/client/body-mutations.d.ts +45 -0
- package/lib/types/client/host-api.d.ts +25 -0
- package/lib/types/client/locales.d.ts +87 -9
- package/lib/types/client/pending-verify.d.ts +47 -0
- package/lib/types/client/plugin-card-seat.d.ts +3 -1
- package/lib/types/client/service.d.ts +4 -1
- package/lib/types/client/settings-form.d.ts +73 -51
- package/lib/types/core/attachment.d.ts +132 -0
- package/lib/types/core/card-defaults.d.ts +78 -0
- package/lib/types/core/controller.d.ts +57 -8
- package/lib/types/core/execution-summary.d.ts +52 -0
- package/lib/types/core/extension.d.ts +116 -0
- package/lib/types/core/launch-width.d.ts +31 -0
- package/lib/types/core/reasoning-effort.d.ts +57 -0
- package/lib/types/core/session-reuse.d.ts +7 -1
- package/lib/types/core/spend-budget.d.ts +28 -0
- package/lib/types/core/subtask.d.ts +100 -37
- package/lib/types/core/tasks.d.ts +94 -10
- package/lib/types/core/use-cases/task-create.d.ts +10 -5
- package/lib/types/core/use-cases/task-tag.d.ts +36 -0
- package/lib/types/core/use-cases/task-update.d.ts +22 -1
- package/lib/types/core/wire-projection.d.ts +35 -0
- package/lib/types/core/workspace-target.d.ts +23 -3
- package/lib/types/host/attachments.d.ts +250 -0
- package/lib/types/host/extension-registry.d.ts +40 -0
- package/lib/types/host/launch-admission.d.ts +71 -0
- package/lib/types/host-ledger.d.ts +114 -47
- package/lib/types/host-routes.d.ts +63 -0
- package/lib/types/host-runner.d.ts +164 -18
- package/lib/types/host-service.d.ts +182 -46
- package/lib/types/host-spend.d.ts +52 -0
- package/lib/types/index.d.ts +173 -54
- package/lib/types/loopback.d.ts +41 -1
- package/lib/types/protocol.d.ts +52 -11
- package/lib/types/tool-surface.d.ts +1 -0
- package/locale/en.json +6 -0
- package/locale/zh.json +6 -0
- package/package.json +36 -29
- package/src/client/CardDefaultPresetField.tsx +101 -0
- package/src/client/PluginSettingsCard.tsx +385 -111
- package/src/client/RangeBubble.tsx +164 -0
- package/src/client/SegmentGroup.tsx +93 -0
- package/src/client/TaskBoardSettingsCard.tsx +332 -37
- package/src/client/board/AttachmentField.tsx +383 -0
- package/src/client/board/EditTaskModal.tsx +63 -0
- package/src/client/board/ExecutionLog.tsx +154 -0
- package/src/client/board/LinkSubtaskModal.tsx +1 -1
- package/src/client/board/NewTaskModal.tsx +154 -45
- package/src/client/board/ReasoningEffortField.tsx +50 -0
- package/src/client/board/TagManagerModal.tsx +151 -2
- package/src/client/board/TaskBoard.tsx +47 -10
- package/src/client/board/TaskCard.tsx +45 -23
- package/src/client/board/TaskDetail.tsx +468 -258
- package/src/client/board/TaskForm.tsx +19 -4
- package/src/client/board/VerificationReport.tsx +143 -104
- package/src/client/board/model-options.ts +208 -0
- package/src/client/board/preset-label.ts +32 -0
- package/src/client/board/preset-roster.ts +58 -0
- package/src/client/board/source-group.ts +94 -0
- 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 +1044 -105
- package/src/client/body-mutations.ts +133 -0
- package/src/client/host-api.ts +70 -0
- package/src/client/index.ts +109 -95
- package/src/client/locales.ts +205 -48
- package/src/client/pending-verify.ts +90 -0
- package/src/client/plugin-card-seat.ts +8 -2
- package/src/client/service.ts +24 -0
- package/src/client/settings-card.module.css +466 -89
- package/src/client/settings-entry-form.ts +0 -1
- package/src/client/settings-form.ts +102 -60
- package/src/core/attachment.ts +287 -0
- package/src/core/card-defaults.ts +132 -0
- package/src/core/controller.ts +90 -11
- package/src/core/execution-summary.ts +96 -0
- package/src/core/extension.ts +120 -0
- package/src/core/launch-width.ts +38 -0
- package/src/core/reasoning-effort.ts +92 -0
- package/src/core/session-reuse.ts +7 -1
- package/src/core/spend-budget.ts +35 -0
- package/src/core/store.ts +19 -1
- package/src/core/subtask.ts +144 -68
- package/src/core/tasks.ts +117 -10
- package/src/core/use-cases/task-create.ts +27 -16
- package/src/core/use-cases/task-tag.ts +56 -0
- package/src/core/use-cases/task-update.ts +33 -5
- package/src/core/wire-projection.ts +81 -0
- package/src/core/workspace-target.ts +27 -3
- package/src/host/agent-tools.ts +33 -21
- package/src/host/attachments.ts +650 -0
- package/src/host/extension-registry.ts +150 -5
- package/src/host/launch-admission.ts +139 -0
- package/src/host-ledger.ts +248 -117
- package/src/host-routes.ts +233 -15
- package/src/host-runner.ts +395 -61
- package/src/host-service.ts +512 -139
- package/src/host-spend.ts +105 -0
- package/src/index.ts +312 -92
- package/src/loopback.ts +57 -1
- package/src/protocol.ts +83 -18
- package/src/tool-surface.ts +1 -0
- package/icon.svg +0 -3
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { type ExecutionOutcome, type ExecutionRecord, type ScheduleMode, type TaskRecord } from './core/tasks.ts';
|
|
1
|
+
import { type ExecutionOutcome, type ExecutionRecord, type ExecutionSummary, type ScheduleMode, type TaskRecord } from './core/tasks.ts';
|
|
2
|
+
import type { CardDefaults } from './core/card-defaults.ts';
|
|
2
3
|
import { type TaskBoardAction, type TaskBoardSchedulerSnapshot } from './protocol.ts';
|
|
3
4
|
import { type ExecutionVerification } from './core/verification.ts';
|
|
4
5
|
import { type TaskPermission } from './core/handover.ts';
|
|
@@ -10,14 +11,13 @@ export interface LedgerState {
|
|
|
10
11
|
export interface OpenedRun {
|
|
11
12
|
task: TaskRecord;
|
|
12
13
|
execution: ExecutionRecord;
|
|
13
|
-
/**
|
|
14
|
-
* How the Host obtains this run's session. Absent or `session` launches a
|
|
15
|
-
* fresh (or reused) execution session; `teammate` means the run belongs to a
|
|
16
|
-
* team-mode cascade, where the Host asks the root's Lead session to spawn a
|
|
17
|
-
* teammate instead of launching a session of its own.
|
|
18
|
-
*/
|
|
19
|
-
dispatch?: 'session' | 'teammate';
|
|
20
14
|
}
|
|
15
|
+
/**
|
|
16
|
+
* Prefix of the `initiatedBy` an inherited descendant verdict carries. The Host
|
|
17
|
+
* recorded it on the run card's behalf (see `inheritVerdictForDescendants`), not
|
|
18
|
+
* an outside agent that reported its own work.
|
|
19
|
+
*/
|
|
20
|
+
export declare const PARENT_RUN_INITIATOR_PREFIX = "parent-run:";
|
|
21
21
|
/** Minimal value copy used by the Host session monitor. */
|
|
22
22
|
export interface OpenExecutionReference {
|
|
23
23
|
readonly taskId: string;
|
|
@@ -51,7 +51,7 @@ export interface LedgerRuntimeView {
|
|
|
51
51
|
* Session ids of every open execution, including the ones
|
|
52
52
|
* {@link openExecutions} skips because their own outcome is already
|
|
53
53
|
* recorded. A caller that asks whether the board still observes any session
|
|
54
|
-
* must use this list: a
|
|
54
|
+
* must use this list: a stored run-group parent is settled by its members,
|
|
55
55
|
* but it is still an open execution.
|
|
56
56
|
*/
|
|
57
57
|
readonly openSessionIds: readonly string[];
|
|
@@ -95,7 +95,7 @@ export declare function win32StartTimeMs(pid: number, probe?: PowerShellProbe):
|
|
|
95
95
|
* missing, cyclic, or names an archived parent while the child is on board is
|
|
96
96
|
* dropped (the task becomes a root) instead of dropping the task. A chain
|
|
97
97
|
* deeper than the current `maxSubtaskDepth` is deliberately KEPT: the limit
|
|
98
|
-
* gates new links, it never deletes a stored one, and every
|
|
98
|
+
* gates new links, it never deletes a stored one, and every lineage walk is
|
|
99
99
|
* bounded by the limit anyway. The Host is the only writer of these links, so
|
|
100
100
|
* this is a last-resort guard against a hand-edited or imported document.
|
|
101
101
|
*/
|
|
@@ -125,9 +125,22 @@ export declare class HostTaskLedger {
|
|
|
125
125
|
* instead of remounting the row.
|
|
126
126
|
*/
|
|
127
127
|
private depthLimit;
|
|
128
|
+
/** Live reader of the deployment's new-card defaults (a volatile config read). */
|
|
129
|
+
private readonly cardDefaults;
|
|
130
|
+
/**
|
|
131
|
+
* Live reader of the daily token cap (0 = no gate). The scheduled path asks it
|
|
132
|
+
* per due occurrence, so a cap raised after a skipped occurrence admits the
|
|
133
|
+
* next one without a restart.
|
|
134
|
+
*/
|
|
135
|
+
private readonly spendBudget;
|
|
136
|
+
/** Today's measured spend in tokens, or undefined when nothing can be measured. */
|
|
137
|
+
private readonly spendUsed;
|
|
128
138
|
constructor(dir?: string, now?: () => number, options?: {
|
|
129
139
|
sessionDefaultPermission?: TaskPermission | (() => TaskPermission);
|
|
130
140
|
maxSubtaskDepth?: number;
|
|
141
|
+
cardDefaults?: () => CardDefaults;
|
|
142
|
+
spendBudgetTokens?: () => number;
|
|
143
|
+
spendUsedToday?: (now: number) => number | undefined;
|
|
131
144
|
});
|
|
132
145
|
/** Current subtask depth limit (1..3). */
|
|
133
146
|
get maxSubtaskDepth(): number;
|
|
@@ -171,10 +184,10 @@ export declare class HostTaskLedger {
|
|
|
171
184
|
runs?: OpenedRun[];
|
|
172
185
|
};
|
|
173
186
|
/**
|
|
174
|
-
* Open the
|
|
175
|
-
*
|
|
176
|
-
*
|
|
177
|
-
*
|
|
187
|
+
* Open the one run a due schedule triggers: an empty array means nothing ran
|
|
188
|
+
* (already running, a card whose elevated permission is still unconfirmed, a
|
|
189
|
+
* one-shot whose instant was missed, or an exhausted budget), and the rule's
|
|
190
|
+
* own state says which.
|
|
178
191
|
*
|
|
179
192
|
* The run budget is enforced HERE, inside the single ledger writer: a rule
|
|
180
193
|
* whose counter already reached its cap is stopped instead of opened, so no
|
|
@@ -184,6 +197,14 @@ export declare class HostTaskLedger {
|
|
|
184
197
|
* @returns the executions this occurrence opened.
|
|
185
198
|
*/
|
|
186
199
|
openScheduled(taskId: string, triggeredAt: number): OpenedRun[];
|
|
200
|
+
/**
|
|
201
|
+
* Why a due occurrence may not open a run because the day already spent the
|
|
202
|
+
* cap, or undefined when it may. A cap of 0 — the default — answers before the
|
|
203
|
+
* measurement is read, so a board with no gate reads no ledger file.
|
|
204
|
+
* @param now - clock instant (ms epoch).
|
|
205
|
+
* @returns the refusal message, when the cap is reached.
|
|
206
|
+
*/
|
|
207
|
+
private spendRefusal;
|
|
187
208
|
/**
|
|
188
209
|
* Record a due occurrence that opened no execution: roll a recurring rule to
|
|
189
210
|
* its next occurrence (budget untouched), or stop it when there is none. A
|
|
@@ -197,8 +218,8 @@ export declare class HostTaskLedger {
|
|
|
197
218
|
* failed without creating a session (see
|
|
198
219
|
* {@link applyScheduleRefund}). Called by the service on the failed-launch
|
|
199
220
|
* path only; a manual run and a launch that did reach a session are never
|
|
200
|
-
* refunded. A no-op for a task with no rule, so a failed
|
|
201
|
-
*
|
|
221
|
+
* refunded. A no-op for a task with no rule, so a failed run does not touch
|
|
222
|
+
* anything.
|
|
202
223
|
* @param taskId - the task whose occurrence is being refunded.
|
|
203
224
|
* @param now - clock instant (ms epoch).
|
|
204
225
|
*/
|
|
@@ -215,12 +236,46 @@ export declare class HostTaskLedger {
|
|
|
215
236
|
skipMissed(now: number): void;
|
|
216
237
|
setScheduler(patch: Partial<TaskBoardSchedulerSnapshot>): void;
|
|
217
238
|
/**
|
|
218
|
-
* Settle one execution. A
|
|
219
|
-
*
|
|
220
|
-
*
|
|
221
|
-
*
|
|
239
|
+
* Settle one execution. A NEW run is a single-member group, so it settles on
|
|
240
|
+
* its own turn. A run group the Host opened before it stopped spreading one
|
|
241
|
+
* run across a subtree is folded here instead: a stored participant records
|
|
242
|
+
* its OWN outcome and only finalizes once every child execution in its group
|
|
243
|
+
* has settled, so a parent card leaves 'running' with the whole group's
|
|
244
|
+
* verdict rather than its own turn alone.
|
|
245
|
+
*
|
|
246
|
+
* `summary` is what the run left behind (see `ExecutionSummary`), passed in
|
|
247
|
+
* by whichever reader observed the session. It is informational: a caller
|
|
248
|
+
* without one settles exactly as before, and a settlement never waits on it.
|
|
249
|
+
*/
|
|
250
|
+
settle(taskId: string, executionId: string, outcome: ExecutionOutcome, error?: string, summary?: ExecutionSummary): void;
|
|
251
|
+
/**
|
|
252
|
+
* Record the run's verdict on the outstanding descendants its root was asked
|
|
253
|
+
* to dispatch.
|
|
254
|
+
*
|
|
255
|
+
* A card with unfinished subtasks runs as an autonomous dispatcher: its
|
|
256
|
+
* session reads the subtasks, dispatches them with subagents, and is asked to
|
|
257
|
+
* write their conclusions back with
|
|
258
|
+
* `task_board_manage({action:'record-external-outcome'})` before it finishes.
|
|
259
|
+
* A run that never wrote one back would leave those cards parked with no
|
|
260
|
+
* record of what the parent decided about them, so once the RUN CARD's
|
|
261
|
+
* execution reached a decisive terminal record, every outstanding descendant
|
|
262
|
+
* this run opened no execution for inherits that verdict as an external
|
|
263
|
+
* record.
|
|
264
|
+
*
|
|
265
|
+
* Idempotent by construction: a card that already carries an execution in
|
|
266
|
+
* this run group (the fold owns it), an open execution (it is running on its
|
|
267
|
+
* own), or a terminal record stamped after this run started (the dispatching
|
|
268
|
+
* agent's own backfill, or an earlier pass of this one) is left alone. Only a
|
|
269
|
+
* decisive verdict is inherited: a cancelled run judged nothing about the
|
|
270
|
+
* subtasks, and a subtask already in the done column has nothing left to
|
|
271
|
+
* inherit.
|
|
272
|
+
* @param taskId - the card whose execution just settled.
|
|
273
|
+
* @param executionId - that execution.
|
|
274
|
+
* @param groupId - its run group.
|
|
275
|
+
* @param now - clock instant (ms epoch).
|
|
276
|
+
* @returns whether the document changed.
|
|
222
277
|
*/
|
|
223
|
-
|
|
278
|
+
private inheritVerdictForDescendants;
|
|
224
279
|
attachSession(taskId: string, executionId: string, sessionId: string): void;
|
|
225
280
|
allTasks(): readonly TaskRecord[];
|
|
226
281
|
getTask(id: string): TaskRecord | undefined;
|
|
@@ -237,46 +292,57 @@ export declare class HostTaskLedger {
|
|
|
237
292
|
/**
|
|
238
293
|
* The binding that makes a run illegal, if any.
|
|
239
294
|
*
|
|
240
|
-
*
|
|
241
|
-
*
|
|
242
|
-
*
|
|
243
|
-
* teammate inherits that session's permission, so a subtask's OWN pin is
|
|
244
|
-
* refused exactly when the Lead session does not already carry it — the
|
|
245
|
-
* teammate could never be given that authority, and dropping the pin
|
|
246
|
-
* silently would misreport the work (an inherited binding is the Lead's own
|
|
247
|
-
* and stays allowed once the Lead is confirmed).
|
|
295
|
+
* Only the card being run gets a session, so only ITS resolved binding gates
|
|
296
|
+
* the run: a subtask's own elevated permission is that subtask's gate when the
|
|
297
|
+
* subtask is run, and no longer blocks its parent from running.
|
|
248
298
|
* @param root - the task being run.
|
|
249
299
|
* @returns the first refusal, or undefined when the run may start.
|
|
250
300
|
*/
|
|
251
301
|
private bindingRefusal;
|
|
252
302
|
/**
|
|
253
|
-
* The
|
|
254
|
-
*
|
|
255
|
-
*
|
|
256
|
-
*
|
|
303
|
+
* The rework block a rework request opens its execution with, or the refusal
|
|
304
|
+
* that names why there is nothing to rework.
|
|
305
|
+
*
|
|
306
|
+
* Read from the ledger alone: a card that never ran, and a card whose runs
|
|
307
|
+
* recorded no session, have no conversation to send the reviewer's
|
|
308
|
+
* instructions into. Minting one would hand those instructions to an agent
|
|
309
|
+
* that never saw the work being sent back, which is the opposite of what a
|
|
310
|
+
* rework asks for.
|
|
311
|
+
* @param task - the card being reworked.
|
|
312
|
+
* @param instructions - the reviewer's instructions, already validated.
|
|
313
|
+
* @returns the block recorded on the opened execution.
|
|
257
314
|
*/
|
|
258
|
-
private
|
|
315
|
+
private reworkInput;
|
|
259
316
|
/** Whether a task or any of its subtasks still has an open execution. */
|
|
260
317
|
private subtreeHasOpenExecution;
|
|
318
|
+
/** The descendants of a card that still hold work, as the launch prompt names them. */
|
|
319
|
+
outstandingDescendants(taskId: string): TaskRecord[];
|
|
320
|
+
/** Whether a card still has a subtask outside the done column. */
|
|
321
|
+
hasOutstandingDescendants(taskId: string): boolean;
|
|
261
322
|
/**
|
|
262
|
-
* Open
|
|
263
|
-
*
|
|
264
|
-
*
|
|
265
|
-
*
|
|
323
|
+
* Open ONE execution for the requested card, under a fresh run group, and
|
|
324
|
+
* commit the ledger once. The group stays single-member on purpose: a run
|
|
325
|
+
* never opens a session for a subtask (that card's own agent dispatches
|
|
326
|
+
* subagents inside this session), and the group id is what later lets the
|
|
327
|
+
* settlement fold a HISTORICAL multi-member group it opened before this
|
|
328
|
+
* behavior changed.
|
|
266
329
|
* @param root - the task the user ran.
|
|
267
330
|
* @param now - clock instant (ms epoch).
|
|
268
331
|
* @param initiator - the DSH session that asked for the run (audit only).
|
|
269
332
|
* @param rerun - true to reset the root to 'todo' before starting it.
|
|
270
333
|
* @param progress - when set, this run was a due occurrence and the root's
|
|
271
334
|
* rule is advanced (counter, next target, stop/skip record) in the same
|
|
272
|
-
* atomic commit that opened the
|
|
335
|
+
* atomic commit that opened the execution.
|
|
336
|
+
* @param rework - the reviewer's instructions, when this run redoes previous
|
|
337
|
+
* work; recorded on the execution it opens.
|
|
273
338
|
*/
|
|
274
|
-
private
|
|
339
|
+
private startRun;
|
|
275
340
|
/**
|
|
276
|
-
* Finalize every
|
|
277
|
-
* lineage: a member settles once its own outcome is recorded and none
|
|
278
|
-
* group children is still open, and its verdict folds those children in
|
|
279
|
-
* (failure dominates, then cancellation).
|
|
341
|
+
* Finalize every stored run-group parent that is ready, walking from `taskId`
|
|
342
|
+
* up the lineage: a member settles once its own outcome is recorded and none
|
|
343
|
+
* of its group children is still open, and its verdict folds those children in
|
|
344
|
+
* (failure dominates, then cancellation). A single-member group — every run
|
|
345
|
+
* this Host opens now — settles on its own turn exactly as any plain run does.
|
|
280
346
|
*/
|
|
281
347
|
private settleCascade;
|
|
282
348
|
/**
|
|
@@ -284,11 +350,12 @@ export declare class HostTaskLedger {
|
|
|
284
350
|
* members are all settled. The Host poll calls this on every tick, so a run
|
|
285
351
|
* can no longer be left in the running column by a settle nobody observed:
|
|
286
352
|
*
|
|
287
|
-
* - A team run is governed by its Lead. Once the Lead's own outcome is
|
|
353
|
+
* - A stored team run is governed by its Lead. Once the Lead's own outcome is
|
|
288
354
|
* recorded, its still-open members are settled with that verdict. A
|
|
289
355
|
* teammate is a durable member of the Team and may never report a turn of
|
|
290
|
-
* its own, and without this the whole lineage waits on it forever.
|
|
291
|
-
*
|
|
356
|
+
* its own, and without this the whole lineage waits on it forever. New runs
|
|
357
|
+
* never start a team, so this only closes a group the ledger already holds.
|
|
358
|
+
* - A stored group parent whose members are all settled is finalized here even
|
|
292
359
|
* when the settle that completed the tree happened in another process, or
|
|
293
360
|
* was interrupted between its child write and its parent write.
|
|
294
361
|
*
|
|
@@ -2,12 +2,50 @@ import type { IncomingMessage } from 'node:http';
|
|
|
2
2
|
import type { WebRoute } from '@deepseek-ai/dsh-host-webserver';
|
|
3
3
|
import type { TaskBoardHostService } from './host-service.ts';
|
|
4
4
|
import { type TaskBoardParseDraft, type TaskBoardParseRequest } from './protocol.ts';
|
|
5
|
+
import { type TaskBoardAttachmentStore } from './host/attachments.ts';
|
|
6
|
+
/**
|
|
7
|
+
* Comment-frame cadence on the event stream. It keeps the connection alive
|
|
8
|
+
* through intermediaries that would close an idle one; it is not a frame the
|
|
9
|
+
* browser reports to the panel (an SSE comment is invisible to EventSource).
|
|
10
|
+
*/
|
|
11
|
+
export declare const HEARTBEAT_MS = 15000;
|
|
5
12
|
/** Header replaced by an authenticated same-host reverse proxy. */
|
|
6
13
|
export declare const TASK_BOARD_PROXY_TOKEN_HEADER = "x-dsh-task-board-proxy-token";
|
|
14
|
+
/**
|
|
15
|
+
* The composition's Host connection service, narrowed to the one check the
|
|
16
|
+
* board bridges: `requestRejection` runs the Host/Origin fence and verifies
|
|
17
|
+
* the authority-bound `dsh-auth-*` browser session minted by the Host. It
|
|
18
|
+
* answers `undefined` only for a request it admits and 401/403 otherwise.
|
|
19
|
+
* Declared structurally, like the official open-in-app routes do, because the
|
|
20
|
+
* service's package is a browser-side dependency this Host half does not
|
|
21
|
+
* import.
|
|
22
|
+
*/
|
|
23
|
+
export interface TaskBoardConnectionTrust {
|
|
24
|
+
requestRejection(request: {
|
|
25
|
+
readonly headers: IncomingMessage['headers'];
|
|
26
|
+
}): 401 | 403 | undefined;
|
|
27
|
+
}
|
|
7
28
|
/** Optional authenticated reverse-proxy access layered over the loopback default. */
|
|
8
29
|
export interface TaskBoardRouteAccess {
|
|
9
30
|
trustedProxyHosts?: readonly string[];
|
|
10
31
|
proxyToken?: string;
|
|
32
|
+
/**
|
|
33
|
+
/**
|
|
34
|
+
* Whether the operator's own reverse proxy or tunnel may speak for the
|
|
35
|
+
* browser: a forwarded request that landed on this machine's loopback
|
|
36
|
+
* upstream then counts as trustable, still behind the browser same-origin
|
|
37
|
+
* marker. Read at each request (hence the function), so the settings switch
|
|
38
|
+
* binds the next request without re-registering the routes. Absent or false
|
|
39
|
+
* keeps the pre-existing fence exactly as it was (issue #1906).
|
|
40
|
+
*/
|
|
41
|
+
trustForwardedProxy?: () => boolean;
|
|
42
|
+
/**
|
|
43
|
+
* Resolves the Host's `connection` service when a request arrives, so a
|
|
44
|
+
* deployment that mounts it after these routes still gains the bridge and a
|
|
45
|
+
* composition that never mounts it keeps the pre-existing fence. Absent means
|
|
46
|
+
* no bridge (issue #1930).
|
|
47
|
+
*/
|
|
48
|
+
connection?: () => TaskBoardConnectionTrust | undefined;
|
|
11
49
|
}
|
|
12
50
|
/**
|
|
13
51
|
* Host faces the routes need beyond the ledger service. The parse face is
|
|
@@ -17,10 +55,19 @@ export interface TaskBoardRouteAccess {
|
|
|
17
55
|
*/
|
|
18
56
|
export interface TaskBoardRouteOptions {
|
|
19
57
|
parseTask?: (request: TaskBoardParseRequest, signal: AbortSignal) => Promise<TaskBoardParseDraft>;
|
|
58
|
+
/**
|
|
59
|
+
* The official attachment storage, read at request time so a deployment that
|
|
60
|
+
* mounts it after these routes still gains the attachment surface. Absent
|
|
61
|
+
* means this deployment stores no attachments, and every attachment route
|
|
62
|
+
* answers with a typed "storage unavailable" failure.
|
|
63
|
+
*/
|
|
64
|
+
attachments?: () => TaskBoardAttachmentStore | undefined;
|
|
20
65
|
}
|
|
21
66
|
interface ResolvedRouteAccess {
|
|
22
67
|
trustedProxyHosts: ReadonlySet<string>;
|
|
23
68
|
proxyToken?: string;
|
|
69
|
+
trustForwardedProxy: () => boolean;
|
|
70
|
+
connection?: () => TaskBoardConnectionTrust | undefined;
|
|
24
71
|
}
|
|
25
72
|
/**
|
|
26
73
|
* Task-board route fence. Direct desktop access uses the repository-wide
|
|
@@ -30,6 +77,22 @@ interface ResolvedRouteAccess {
|
|
|
30
77
|
* tripwire, the socket/Host/origin-equality checks carry the authority).
|
|
31
78
|
* Authenticated proxies must be explicitly allowlisted and replace the
|
|
32
79
|
* internal token header after their own authentication step.
|
|
80
|
+
*
|
|
81
|
+
* A third party's proxy cannot inject that token, so a deployment whose own
|
|
82
|
+
* tunnel dials the loopback upstream (issue #1918) can instead turn on
|
|
83
|
+
* trustForwardedProxy: a forwarded request that landed on this machine
|
|
84
|
+
* (loopback socket AND loopback Host) is then admitted on the same browser
|
|
85
|
+
* marker alone. The switch defaults off, so an unconfigured board keeps
|
|
86
|
+
* refusing every forwarded request (issue #1906).
|
|
87
|
+
*
|
|
88
|
+
* A deployment behind a reverse proxy or ingress that DSH itself serves
|
|
89
|
+
* (`--trusted-host`, TLS terminated at the edge) is admitted by the Host's
|
|
90
|
+
* `connection` service instead: a request whose Host/Origin fence and signed
|
|
91
|
+
* browser session it accepts needs no board-specific allowlist, which is why
|
|
92
|
+
* the check runs first when the service is mounted (issue #1930). The fence
|
|
93
|
+
* below stays untouched as the fallback, so a deployment without the service,
|
|
94
|
+
* and every direct client the service does not admit, keeps exactly the
|
|
95
|
+
* pre-existing decision.
|
|
33
96
|
*/
|
|
34
97
|
export declare function isTrustedTaskBoardRequest(req: IncomingMessage, access: ResolvedRouteAccess): boolean;
|
|
35
98
|
export declare function makeTaskBoardRoutes(service: TaskBoardHostService, access?: TaskBoardRouteAccess, options?: TaskBoardRouteOptions): WebRoute[];
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
import
|
|
2
|
-
import type {
|
|
1
|
+
import { Context } from '@deepseek-ai/cordis';
|
|
2
|
+
import type { InvokeRemoteRequest, TypertGateway } from '@deepseek-ai/dsh-api-gateway';
|
|
3
3
|
import type { 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 type {
|
|
6
|
+
import type { ModelCatalogView } from './core/verification.ts';
|
|
7
|
+
import type { ExecutionSummary, TaskRecord } from './core/tasks.ts';
|
|
8
|
+
import { type ExecutionFilePart, type ModelInfoResolver, type TaskBoardAttachmentStore } from './host/attachments.ts';
|
|
7
9
|
/**
|
|
8
10
|
* Host services needed to validate a task's workspace before creating a
|
|
9
11
|
* session, and to resolve the workspace an unpinned card runs in.
|
|
@@ -11,13 +13,47 @@ import type { TaskRecord } from './core/tasks.ts';
|
|
|
11
13
|
export interface TaskBoardWorkspaceRegistry {
|
|
12
14
|
list(): readonly Workspace[];
|
|
13
15
|
}
|
|
16
|
+
/**
|
|
17
|
+
* The peer every gateway request names: derived from the public
|
|
18
|
+
* `InvokeRemoteRequest` type so this package needs no direct dependency on
|
|
19
|
+
* `@deepseek-ai/dsh-typert-protocol` for the shape.
|
|
20
|
+
*/
|
|
21
|
+
export type GatewayPeer = InvokeRemoteRequest['peer'];
|
|
14
22
|
interface GatewayRequest {
|
|
15
23
|
namespace: string;
|
|
16
24
|
method: string;
|
|
17
25
|
args: Record<string, unknown>;
|
|
18
|
-
peer
|
|
26
|
+
peer: GatewayPeer;
|
|
19
27
|
signal?: AbortSignal;
|
|
20
28
|
}
|
|
29
|
+
/**
|
|
30
|
+
* Mint the in-process owner peer this plugin's Host calls speak for.
|
|
31
|
+
*
|
|
32
|
+
* The 0.2.1 gateway made `peer` mandatory on every request, and the
|
|
33
|
+
* authorization layer reads only `peer.principal`: a principal of
|
|
34
|
+
* `{ kind: 'owner' }` is how host-local code states that the call IS the local
|
|
35
|
+
* user driving their own Host, so the gateway answers it directly instead of
|
|
36
|
+
* running a remote-access decision (only non-owner principals are judged).
|
|
37
|
+
* That is exactly the task board's position — it creates, renames, prompts,
|
|
38
|
+
* and reads sessions as the Host itself, which before 0.2.1 was the implicit
|
|
39
|
+
* privilege of every in-process caller. The board claims owner explicitly, and
|
|
40
|
+
* only ever inside its own Host process: no wire field can set a principal,
|
|
41
|
+
* and this plugin never forwards a browser-supplied one.
|
|
42
|
+
*
|
|
43
|
+
* `interactions` stays `'none'`: the board only invokes methods and opens the
|
|
44
|
+
* short `session/follow` stream. The gateway's interactions check gates
|
|
45
|
+
* exactly the forwarded-event endpoints (opening an event stream, answering a
|
|
46
|
+
* waterfall), which this caller never touches; an `'answer'` peer would
|
|
47
|
+
* additionally receive forwarded Host events, a capability the board neither
|
|
48
|
+
* needs nor wants.
|
|
49
|
+
*
|
|
50
|
+
* The peer's signal aborts once `ctx` disposes, so streams opened for it end
|
|
51
|
+
* with the plugin fiber, and `dispose()` is idempotent with racing calls
|
|
52
|
+
* sharing one completion. The id carries no credential — the protocol fixes
|
|
53
|
+
* `principal` as the only identity persisted in a session log — so a fresh
|
|
54
|
+
* unique id per mount is sufficient.
|
|
55
|
+
*/
|
|
56
|
+
export declare function createOwnerPeer(ctx: Context): GatewayPeer;
|
|
21
57
|
interface SessionGateway {
|
|
22
58
|
invoke(request: GatewayRequest): Promise<unknown>;
|
|
23
59
|
stream?(request: GatewayRequest): Promise<AsyncIterable<unknown>>;
|
|
@@ -42,12 +78,15 @@ export type ExecutionInspection =
|
|
|
42
78
|
reason?: string;
|
|
43
79
|
} | {
|
|
44
80
|
outcome: 'succeeded';
|
|
81
|
+
summary?: ExecutionSummary;
|
|
45
82
|
} | {
|
|
46
83
|
outcome: 'failed';
|
|
47
84
|
error: string;
|
|
85
|
+
summary?: ExecutionSummary;
|
|
48
86
|
} | {
|
|
49
87
|
outcome: 'cancelled';
|
|
50
88
|
error: string;
|
|
89
|
+
summary?: ExecutionSummary;
|
|
51
90
|
};
|
|
52
91
|
/** A post-create launch failure that still identifies the session to the ledger. */
|
|
53
92
|
export declare class SessionLaunchError extends Error {
|
|
@@ -64,21 +103,23 @@ export declare class SessionLaunchError extends Error {
|
|
|
64
103
|
* first, the provenance wrap then encloses the instruction. Plain tasks (no
|
|
65
104
|
* freeze) keep the bare handover preamble + prompt.
|
|
66
105
|
*/
|
|
67
|
-
/** One
|
|
68
|
-
export interface
|
|
69
|
-
/** Task id of the
|
|
106
|
+
/** One unfinished subtask the launched card's own agent has to dispatch. */
|
|
107
|
+
export interface PromptDescendant {
|
|
108
|
+
/** Task id of the subtask card. */
|
|
70
109
|
id: string;
|
|
71
|
-
/**
|
|
110
|
+
/** Subtask title. */
|
|
72
111
|
title: string;
|
|
73
|
-
/**
|
|
74
|
-
|
|
112
|
+
/** Its column, so the run can tell a fresh card from one already failed before. */
|
|
113
|
+
status: string;
|
|
75
114
|
}
|
|
76
115
|
/** Execution-shape context appended to the launched task's prompt. */
|
|
77
116
|
export interface PromptContext {
|
|
78
|
-
/**
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
117
|
+
/**
|
|
118
|
+
* The card's outstanding descendants. Present exactly when this run is an
|
|
119
|
+
* autonomous dispatch: the Host opens no session for them, so this session
|
|
120
|
+
* reads them and dispatches subagents itself.
|
|
121
|
+
*/
|
|
122
|
+
descendants?: readonly PromptDescendant[];
|
|
82
123
|
/**
|
|
83
124
|
* Scheduled-run provenance: the instant the rule actually fired, its kind,
|
|
84
125
|
* and the IANA zone its wall clock was read in. Present only for a
|
|
@@ -91,6 +132,22 @@ export interface PromptContext {
|
|
|
91
132
|
mode: 'cron' | 'once';
|
|
92
133
|
cron?: string;
|
|
93
134
|
};
|
|
135
|
+
/**
|
|
136
|
+
* Rework provenance: the instructions a reviewer sent the previous run back
|
|
137
|
+
* with. Present exactly when this execution continues the card's own session
|
|
138
|
+
* to redo work, so the agent reads why it is being asked again instead of
|
|
139
|
+
* seeing the card body a second time with no explanation.
|
|
140
|
+
*/
|
|
141
|
+
rework?: {
|
|
142
|
+
instructions: string;
|
|
143
|
+
};
|
|
144
|
+
/**
|
|
145
|
+
* The card's attached files, resolved to readable host paths for THIS
|
|
146
|
+
* execution. Present exactly when the card carries files: the section is a
|
|
147
|
+
* preamble of its own, separate from the handover references, so the two
|
|
148
|
+
* kinds of reference stay distinguishable to the reading agent.
|
|
149
|
+
*/
|
|
150
|
+
files?: readonly ExecutionFilePart[];
|
|
94
151
|
}
|
|
95
152
|
/**
|
|
96
153
|
* Build the execution prompt for one task.
|
|
@@ -109,20 +166,51 @@ export declare function promptText(task: TaskRecord, context?: PromptContext): s
|
|
|
109
166
|
* @returns the objective text for `/goal <objective>`.
|
|
110
167
|
*/
|
|
111
168
|
export declare function goalObjective(prompt: string): string;
|
|
169
|
+
/**
|
|
170
|
+
* The optional runtime faces an execution needs beyond the session gateway:
|
|
171
|
+
* the official attachment storage and the model-info reader the image
|
|
172
|
+
* preflight uses. Both are read live, so a deployment that mounts them after
|
|
173
|
+
* the board still gains the capability.
|
|
174
|
+
*/
|
|
175
|
+
export interface TaskBoardRuntimeFaces {
|
|
176
|
+
/** The official attachment storage, or undefined when the deployment has none. */
|
|
177
|
+
attachments?: () => TaskBoardAttachmentStore | undefined;
|
|
178
|
+
/** The model-info reader, or undefined when the deployment serves no model information. */
|
|
179
|
+
llm?: () => ModelInfoResolver | undefined;
|
|
180
|
+
/**
|
|
181
|
+
* Whether this deployment runs the legacy Agent Teams runtime, read live
|
|
182
|
+
* from the agent tool registry. Absent, or answering false, means the
|
|
183
|
+
* deployment is not PROVEN legacy: the dispatcher preset is then forced as
|
|
184
|
+
* before. Only a positive answer refuses the run, so a deployment whose
|
|
185
|
+
* registry cannot be read keeps its current behaviour instead of losing the
|
|
186
|
+
* ability to dispatch a subtask tree.
|
|
187
|
+
*/
|
|
188
|
+
legacyAgentTeams?: () => boolean;
|
|
189
|
+
}
|
|
112
190
|
export declare class HostExecutionRunner {
|
|
113
191
|
private readonly gateway;
|
|
114
192
|
private readonly commands?;
|
|
115
193
|
private readonly workspaceRegistry?;
|
|
116
|
-
private readonly
|
|
117
|
-
/**
|
|
194
|
+
private readonly faces;
|
|
195
|
+
/**
|
|
196
|
+
* Newest event sequence per session whose COMPLETE history walk (reaching
|
|
197
|
+
* the execution boundary) found no matching execution end. A later walk may
|
|
198
|
+
* trust everything at or below it and examine only newer records.
|
|
199
|
+
*/
|
|
118
200
|
private readonly scanMemos;
|
|
119
201
|
private readonly unavailableAttempts;
|
|
120
202
|
private readonly unavailableBackoffMs;
|
|
203
|
+
/**
|
|
204
|
+
* The peer every request speaks for. Production passes the peer bound to the
|
|
205
|
+
* plugin fiber; a bare runner (unit tests around fake gateways) gets one
|
|
206
|
+
* bound to a fresh root context instead.
|
|
207
|
+
*/
|
|
208
|
+
private readonly ownerPeer;
|
|
121
209
|
private unsupportedSessionListWarned;
|
|
122
210
|
constructor(gateway: SessionGateway | TypertGateway, commands?: SessionCommandDispatcher | undefined, workspaceRegistry?: TaskBoardWorkspaceRegistry | undefined, unavailableRetry?: {
|
|
123
211
|
attempts?: number;
|
|
124
212
|
backoffMs?: number;
|
|
125
|
-
},
|
|
213
|
+
}, ownerPeer?: GatewayPeer, faces?: TaskBoardRuntimeFaces);
|
|
126
214
|
private invoke;
|
|
127
215
|
private stream;
|
|
128
216
|
/**
|
|
@@ -146,6 +234,14 @@ export declare class HostExecutionRunner {
|
|
|
146
234
|
launch(task: TaskRecord, options?: {
|
|
147
235
|
reuseSessionId?: string;
|
|
148
236
|
promptContext?: PromptContext;
|
|
237
|
+
/**
|
|
238
|
+
* Agent preset this execution is FORCED under, overriding the card's own
|
|
239
|
+
* `mode` pin (and a handover bundle's): the caller decides it from the run's
|
|
240
|
+
* shape (a card with unfinished subtasks runs as the autonomous dispatcher),
|
|
241
|
+
* and the override is never written into the card. A preset the deployment
|
|
242
|
+
* does not register fails the launch before any session exists.
|
|
243
|
+
*/
|
|
244
|
+
agentPreset?: string;
|
|
149
245
|
onSession?: (sessionId: string) => void;
|
|
150
246
|
onGoalArmed?: (armed: boolean) => void;
|
|
151
247
|
/**
|
|
@@ -160,7 +256,27 @@ export declare class HostExecutionRunner {
|
|
|
160
256
|
* `goalRun` still applies on top of it (both must ASK for a goal).
|
|
161
257
|
*/
|
|
162
258
|
goalEnabled?: boolean;
|
|
259
|
+
/**
|
|
260
|
+
* The host model catalog, read ONCE per execution by the caller. The card's
|
|
261
|
+
* pinned reasoning effort is sent only when this catalog declares it for the
|
|
262
|
+
* route the execution runs at, so one snapshot decides both the acceptance
|
|
263
|
+
* contract and the effort this run freezes. Absent means "no capability
|
|
264
|
+
* evidence": an effort is then not sent at all.
|
|
265
|
+
*/
|
|
266
|
+
catalog?: ModelCatalogView;
|
|
163
267
|
}): Promise<string>;
|
|
268
|
+
/**
|
|
269
|
+
* Queue one follow-up user message into an existing execution session.
|
|
270
|
+
*
|
|
271
|
+
* This is the same `session/prompt` call a launch makes, with none of the
|
|
272
|
+
* launch pins: a follow-up continues a conversation the board already
|
|
273
|
+
* composed, so it must not re-assert the permission, rename the session, or
|
|
274
|
+
* switch the model. The message is queued behind whatever that session is
|
|
275
|
+
* doing, which is what lets a caller reach a run that is still working.
|
|
276
|
+
* @param sessionId - the session the card's execution recorded.
|
|
277
|
+
* @param text - the message to deliver, already validated by the caller.
|
|
278
|
+
*/
|
|
279
|
+
followUp(sessionId: string, text: string): Promise<void>;
|
|
164
280
|
/**
|
|
165
281
|
* Fail closed when a reused session records a different Agent preset than
|
|
166
282
|
* the one this task pins.
|
|
@@ -176,12 +292,42 @@ export declare class HostExecutionRunner {
|
|
|
176
292
|
* @param pinned - the preset id the task pins, when it pins one.
|
|
177
293
|
*/
|
|
178
294
|
private assertReusedPreset;
|
|
295
|
+
/**
|
|
296
|
+
* Split a `provider/model` pin. A pin without a provider keeps only the model
|
|
297
|
+
* id: the provider is the one the host catalog declares for it, resolved at
|
|
298
|
+
* launch because the session wire contract requires a provider.
|
|
299
|
+
*/
|
|
300
|
+
private static pinnedRoute;
|
|
301
|
+
/**
|
|
302
|
+
* The route a card that pins no model actually runs at: the session's own
|
|
303
|
+
* recorded selection (the durable fold the GUI reads; `next` is the pending
|
|
304
|
+
* user choice, `lastUsed` what the last request consumed), or — for a session
|
|
305
|
+
* that has selected none yet, which is exactly a session that would start at
|
|
306
|
+
* the deployment default — the host default from the catalog.
|
|
307
|
+
*
|
|
308
|
+
* A route that cannot be READ is undefined and the effort is not sent:
|
|
309
|
+
* falling back to the host default there would silently switch the model of a
|
|
310
|
+
* session this run only meant to continue.
|
|
311
|
+
*/
|
|
312
|
+
private sessionRoute;
|
|
179
313
|
/**
|
|
180
314
|
* Re-assert the pinned execution contract on a session and queue the task
|
|
181
315
|
* prompt. Shared by the fresh-session and reuse paths so both apply exactly
|
|
182
|
-
* the same permission/model pins before the prompt.
|
|
316
|
+
* the same permission/model/effort pins before the prompt. A session that
|
|
317
|
+
* refuses a selection carrying a catalog-confirmed effort throws here, so the
|
|
318
|
+
* prompt is never queued behind a run at the wrong level.
|
|
183
319
|
*/
|
|
184
320
|
private pinAndPrompt;
|
|
321
|
+
/**
|
|
322
|
+
* Resolve a card's attachments for one execution.
|
|
323
|
+
*
|
|
324
|
+
* A card without attachments resolves to nothing, even in a deployment that
|
|
325
|
+
* serves no attachment storage at all. A card WITH attachments cannot run
|
|
326
|
+
* without the storage: the run fails with a readable reason instead of
|
|
327
|
+
* silently dropping the attachment and running the card as if it carried
|
|
328
|
+
* none.
|
|
329
|
+
*/
|
|
330
|
+
private resolveAttachments;
|
|
185
331
|
/**
|
|
186
332
|
* Read the host's model catalog: the default route an unconfigured session
|
|
187
333
|
* starts at, and each provider's models with the reasoning metadata its
|