@linxin666/dsh-client-ui-task-board 0.4.6 → 0.4.8
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 +15 -6
- package/README.zh.md +15 -6
- package/lib/client.js +1634 -822
- package/lib/client.js.map +1 -1
- package/lib/index.js +1072 -125
- package/lib/types/client/CardDefaultPresetField.d.ts +35 -0
- package/lib/types/client/PluginSettingsCard.d.ts +39 -0
- package/lib/types/client/TaskBoardSettingsCard.d.ts +56 -0
- package/lib/types/client/board/ReasoningEffortField.d.ts +25 -0
- package/lib/types/client/board/model-options.d.ts +67 -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/team-run-promotion.d.ts +26 -0
- package/lib/types/client/locales.d.ts +18 -0
- package/lib/types/client/telemetry.d.ts +14 -2
- package/lib/types/core/card-defaults.d.ts +78 -0
- package/lib/types/core/controller.d.ts +32 -7
- package/lib/types/core/execution-summary.d.ts +52 -0
- package/lib/types/core/extension.d.ts +34 -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/spend-budget.d.ts +28 -0
- package/lib/types/core/subtask.d.ts +30 -8
- package/lib/types/core/tasks.d.ts +51 -1
- package/lib/types/core/use-cases/task-create.d.ts +10 -5
- package/lib/types/core/use-cases/task-update.d.ts +1 -1
- package/lib/types/host/launch-admission.d.ts +72 -0
- package/lib/types/host-ledger.d.ts +33 -6
- package/lib/types/host-runner.d.ts +83 -5
- package/lib/types/host-service.d.ts +116 -2
- package/lib/types/host-spend.d.ts +52 -0
- package/lib/types/index.d.ts +98 -0
- package/lib/types/loopback.d.ts +20 -1
- package/lib/types/protocol.d.ts +13 -0
- package/package.json +28 -28
- package/src/client/CardDefaultPresetField.tsx +101 -0
- package/src/client/PluginSettingsCard.tsx +63 -3
- package/src/client/TaskBoardSettingsCard.tsx +251 -16
- package/src/client/board/LinkSubtaskModal.tsx +8 -0
- package/src/client/board/NewTaskModal.tsx +86 -40
- package/src/client/board/ReasoningEffortField.tsx +50 -0
- package/src/client/board/TaskDetail.tsx +42 -6
- package/src/client/board/model-options.ts +178 -0
- package/src/client/board/preset-label.ts +32 -0
- package/src/client/board/preset-roster.ts +58 -0
- package/src/client/board/team-run-promotion.ts +39 -0
- package/src/client/index.ts +98 -94
- package/src/client/locales.ts +38 -2
- package/src/client/settings-card.module.css +70 -1
- package/src/client/settings-entry-form.ts +0 -1
- package/src/client/telemetry.ts +47 -2
- package/src/core/card-defaults.ts +132 -0
- package/src/core/controller.ts +44 -9
- package/src/core/execution-summary.ts +96 -0
- package/src/core/extension.ts +34 -0
- package/src/core/launch-width.ts +38 -0
- package/src/core/reasoning-effort.ts +92 -0
- package/src/core/spend-budget.ts +35 -0
- package/src/core/store.ts +9 -0
- package/src/core/subtask.ts +48 -13
- package/src/core/tasks.ts +63 -1
- package/src/core/use-cases/task-create.ts +27 -16
- package/src/core/use-cases/task-update.ts +6 -1
- package/src/host/agent-tools.ts +21 -8
- package/src/host/launch-admission.ts +140 -0
- package/src/host-ledger.ts +80 -10
- package/src/host-runner.ts +199 -25
- package/src/host-service.ts +340 -27
- package/src/host-spend.ts +105 -0
- package/src/index.ts +182 -2
- package/src/loopback.ts +25 -1
- package/src/protocol.ts +28 -4
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { Context } from '@deepseek-ai/cordis';
|
|
2
|
+
import type { InvokeRemoteRequest, TypertGateway } from '@deepseek-ai/dsh-api-gateway';
|
|
2
3
|
import type { SessionSummary } from '@deepseek-ai/dsh-api-session-controller/types';
|
|
3
4
|
import type { CommandResult } from '@deepseek-ai/dsh-commands/types';
|
|
4
5
|
import type { Workspace } from '@deepseek-ai/dsh-workspace/types';
|
|
5
|
-
import type {
|
|
6
|
+
import type { ModelCatalogView } from './core/verification.ts';
|
|
7
|
+
import type { ExecutionSummary, TaskRecord } from './core/tasks.ts';
|
|
6
8
|
/**
|
|
7
9
|
* Host services needed to validate a task's workspace before creating a
|
|
8
10
|
* session, and to resolve the workspace an unpinned card runs in.
|
|
@@ -10,12 +12,47 @@ import type { TaskRecord } from './core/tasks.ts';
|
|
|
10
12
|
export interface TaskBoardWorkspaceRegistry {
|
|
11
13
|
list(): readonly Workspace[];
|
|
12
14
|
}
|
|
15
|
+
/**
|
|
16
|
+
* The peer every gateway request names: derived from the public
|
|
17
|
+
* `InvokeRemoteRequest` type so this package needs no direct dependency on
|
|
18
|
+
* `@deepseek-ai/dsh-typert-protocol` for the shape.
|
|
19
|
+
*/
|
|
20
|
+
export type GatewayPeer = InvokeRemoteRequest['peer'];
|
|
13
21
|
interface GatewayRequest {
|
|
14
22
|
namespace: string;
|
|
15
23
|
method: string;
|
|
16
24
|
args: Record<string, unknown>;
|
|
25
|
+
peer: GatewayPeer;
|
|
17
26
|
signal?: AbortSignal;
|
|
18
27
|
}
|
|
28
|
+
/**
|
|
29
|
+
* Mint the in-process owner peer this plugin's Host calls speak for.
|
|
30
|
+
*
|
|
31
|
+
* The 0.2.1 gateway made `peer` mandatory on every request, and the
|
|
32
|
+
* authorization layer reads only `peer.principal`: a principal of
|
|
33
|
+
* `{ kind: 'owner' }` is how host-local code states that the call IS the local
|
|
34
|
+
* user driving their own Host, so the gateway answers it directly instead of
|
|
35
|
+
* running a remote-access decision (only non-owner principals are judged).
|
|
36
|
+
* That is exactly the task board's position — it creates, renames, prompts,
|
|
37
|
+
* and reads sessions as the Host itself, which before 0.2.1 was the implicit
|
|
38
|
+
* privilege of every in-process caller. The board claims owner explicitly, and
|
|
39
|
+
* only ever inside its own Host process: no wire field can set a principal,
|
|
40
|
+
* and this plugin never forwards a browser-supplied one.
|
|
41
|
+
*
|
|
42
|
+
* `interactions` stays `'none'`: the board only invokes methods and opens the
|
|
43
|
+
* short `session/follow` stream. The gateway's interactions check gates
|
|
44
|
+
* exactly the forwarded-event endpoints (opening an event stream, answering a
|
|
45
|
+
* waterfall), which this caller never touches; an `'answer'` peer would
|
|
46
|
+
* additionally receive forwarded Host events, a capability the board neither
|
|
47
|
+
* needs nor wants.
|
|
48
|
+
*
|
|
49
|
+
* The peer's signal aborts once `ctx` disposes, so streams opened for it end
|
|
50
|
+
* with the plugin fiber, and `dispose()` is idempotent with racing calls
|
|
51
|
+
* sharing one completion. The id carries no credential — the protocol fixes
|
|
52
|
+
* `principal` as the only identity persisted in a session log — so a fresh
|
|
53
|
+
* unique id per mount is sufficient.
|
|
54
|
+
*/
|
|
55
|
+
export declare function createOwnerPeer(ctx: Context): GatewayPeer;
|
|
19
56
|
interface SessionGateway {
|
|
20
57
|
invoke(request: GatewayRequest): Promise<unknown>;
|
|
21
58
|
stream?(request: GatewayRequest): Promise<AsyncIterable<unknown>>;
|
|
@@ -40,12 +77,15 @@ export type ExecutionInspection =
|
|
|
40
77
|
reason?: string;
|
|
41
78
|
} | {
|
|
42
79
|
outcome: 'succeeded';
|
|
80
|
+
summary?: ExecutionSummary;
|
|
43
81
|
} | {
|
|
44
82
|
outcome: 'failed';
|
|
45
83
|
error: string;
|
|
84
|
+
summary?: ExecutionSummary;
|
|
46
85
|
} | {
|
|
47
86
|
outcome: 'cancelled';
|
|
48
87
|
error: string;
|
|
88
|
+
summary?: ExecutionSummary;
|
|
49
89
|
};
|
|
50
90
|
/** A post-create launch failure that still identifies the session to the ledger. */
|
|
51
91
|
export declare class SessionLaunchError extends Error {
|
|
@@ -111,15 +151,25 @@ export declare class HostExecutionRunner {
|
|
|
111
151
|
private readonly gateway;
|
|
112
152
|
private readonly commands?;
|
|
113
153
|
private readonly workspaceRegistry?;
|
|
114
|
-
/**
|
|
154
|
+
/**
|
|
155
|
+
* Newest event sequence per session whose COMPLETE history walk (reaching
|
|
156
|
+
* the execution boundary) found no matching execution end. A later walk may
|
|
157
|
+
* trust everything at or below it and examine only newer records.
|
|
158
|
+
*/
|
|
115
159
|
private readonly scanMemos;
|
|
116
160
|
private readonly unavailableAttempts;
|
|
117
161
|
private readonly unavailableBackoffMs;
|
|
162
|
+
/**
|
|
163
|
+
* The peer every request speaks for. Production passes the peer bound to the
|
|
164
|
+
* plugin fiber; a bare runner (unit tests around fake gateways) gets one
|
|
165
|
+
* bound to a fresh root context instead.
|
|
166
|
+
*/
|
|
167
|
+
private readonly ownerPeer;
|
|
118
168
|
private unsupportedSessionListWarned;
|
|
119
169
|
constructor(gateway: SessionGateway | TypertGateway, commands?: SessionCommandDispatcher | undefined, workspaceRegistry?: TaskBoardWorkspaceRegistry | undefined, unavailableRetry?: {
|
|
120
170
|
attempts?: number;
|
|
121
171
|
backoffMs?: number;
|
|
122
|
-
});
|
|
172
|
+
}, ownerPeer?: GatewayPeer);
|
|
123
173
|
private invoke;
|
|
124
174
|
private stream;
|
|
125
175
|
/**
|
|
@@ -157,6 +207,14 @@ export declare class HostExecutionRunner {
|
|
|
157
207
|
* `goalRun` still applies on top of it (both must ASK for a goal).
|
|
158
208
|
*/
|
|
159
209
|
goalEnabled?: boolean;
|
|
210
|
+
/**
|
|
211
|
+
* The host model catalog, read ONCE per execution by the caller. The card's
|
|
212
|
+
* pinned reasoning effort is sent only when this catalog declares it for the
|
|
213
|
+
* route the execution runs at, so one snapshot decides both the acceptance
|
|
214
|
+
* contract and the effort this run freezes. Absent means "no capability
|
|
215
|
+
* evidence": an effort is then not sent at all.
|
|
216
|
+
*/
|
|
217
|
+
catalog?: ModelCatalogView;
|
|
160
218
|
}): Promise<string>;
|
|
161
219
|
/**
|
|
162
220
|
* Fail closed when a reused session records a different Agent preset than
|
|
@@ -173,10 +231,30 @@ export declare class HostExecutionRunner {
|
|
|
173
231
|
* @param pinned - the preset id the task pins, when it pins one.
|
|
174
232
|
*/
|
|
175
233
|
private assertReusedPreset;
|
|
234
|
+
/**
|
|
235
|
+
* Split a `provider/model` pin. A pin without a provider keeps only the model
|
|
236
|
+
* id: the provider is the one the host catalog declares for it, resolved at
|
|
237
|
+
* launch because the session wire contract requires a provider.
|
|
238
|
+
*/
|
|
239
|
+
private static pinnedRoute;
|
|
240
|
+
/**
|
|
241
|
+
* The route a card that pins no model actually runs at: the session's own
|
|
242
|
+
* recorded selection (the durable fold the GUI reads; `next` is the pending
|
|
243
|
+
* user choice, `lastUsed` what the last request consumed), or — for a session
|
|
244
|
+
* that has selected none yet, which is exactly a session that would start at
|
|
245
|
+
* the deployment default — the host default from the catalog.
|
|
246
|
+
*
|
|
247
|
+
* A route that cannot be READ is undefined and the effort is not sent:
|
|
248
|
+
* falling back to the host default there would silently switch the model of a
|
|
249
|
+
* session this run only meant to continue.
|
|
250
|
+
*/
|
|
251
|
+
private sessionRoute;
|
|
176
252
|
/**
|
|
177
253
|
* Re-assert the pinned execution contract on a session and queue the task
|
|
178
254
|
* prompt. Shared by the fresh-session and reuse paths so both apply exactly
|
|
179
|
-
* the same permission/model pins before the prompt.
|
|
255
|
+
* the same permission/model/effort pins before the prompt. A session that
|
|
256
|
+
* refuses a selection carrying a catalog-confirmed effort throws here, so the
|
|
257
|
+
* prompt is never queued behind a run at the wrong level.
|
|
180
258
|
*/
|
|
181
259
|
private pinAndPrompt;
|
|
182
260
|
/**
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import type { TypertGateway } from '@deepseek-ai/dsh-api-gateway';
|
|
2
2
|
import { HostTaskLedger } from './host-ledger.ts';
|
|
3
|
-
import { HostExecutionRunner, type SessionCommandDispatcher, type TaskBoardWorkspaceRegistry } from './host-runner.ts';
|
|
3
|
+
import { HostExecutionRunner, type GatewayPeer, type SessionCommandDispatcher, type TaskBoardWorkspaceRegistry } from './host-runner.ts';
|
|
4
4
|
import { PowerInhibitor } from './power-inhibitor.ts';
|
|
5
5
|
import { type TaskBoardAction, type TaskBoardEventPayload, type TaskBoardSnapshot } from './protocol.ts';
|
|
6
|
+
import type { CardDefaults } from './core/card-defaults.ts';
|
|
6
7
|
import { TaskBoardExtensionRegistry } from './host/extension-registry.ts';
|
|
7
8
|
import type { TaskBoardExtension } from './core/extension.ts';
|
|
8
|
-
import type
|
|
9
|
+
import { type ScheduleMode } from './core/tasks.ts';
|
|
9
10
|
import { type ModelCatalogView, type VerificationContract, type VerificationSettings } from './core/verification.ts';
|
|
10
11
|
import type { TaskPermission } from './core/handover.ts';
|
|
11
12
|
/** One teammate the Host asks the Agent Teams service to spawn for a team run. */
|
|
@@ -103,6 +104,12 @@ export declare class TaskBoardHostService {
|
|
|
103
104
|
private disposed;
|
|
104
105
|
private pollInFlight;
|
|
105
106
|
private active;
|
|
107
|
+
/**
|
|
108
|
+
* Admission control for the session-creating half of a run: one board action
|
|
109
|
+
* opens a whole subtree, and this is what keeps the Host from asking DSH for
|
|
110
|
+
* every member's session at once (see {@link LaunchAdmissionQueue}).
|
|
111
|
+
*/
|
|
112
|
+
private readonly launches;
|
|
106
113
|
/**
|
|
107
114
|
* Consecutive unreadable-history polls per open execution (see
|
|
108
115
|
* {@link noteUnreadableInspection}). Cleared as soon as an inspection
|
|
@@ -116,6 +123,21 @@ export declare class TaskBoardHostService {
|
|
|
116
123
|
private readonly timers;
|
|
117
124
|
/** Live reader of the global native-/goal switch; frozen per execution. */
|
|
118
125
|
private readonly goalRunEnabled;
|
|
126
|
+
/** Live reader of the deployment's new-card defaults (published and applied per create). */
|
|
127
|
+
private readonly cardDefaults;
|
|
128
|
+
/**
|
|
129
|
+
* Live reader of the run-launch admission width: how many launches may be in
|
|
130
|
+
* flight at once. Read at every admission, so a settings edit bounds the next
|
|
131
|
+
* launch without remounting the row. Absent means the default.
|
|
132
|
+
*/
|
|
133
|
+
private readonly runLaunchWidth;
|
|
134
|
+
/**
|
|
135
|
+
* Live reader of the daily token cap; 0 means no gate. Read at each run
|
|
136
|
+
* action, so closing or raising the cap binds the next action.
|
|
137
|
+
*/
|
|
138
|
+
private readonly spendBudgetTokens;
|
|
139
|
+
/** Today's measured spend: absent measurement reads as "cannot see", never as zero. */
|
|
140
|
+
private readonly spendUsedToday;
|
|
119
141
|
private lastPowerJson;
|
|
120
142
|
private readonly now;
|
|
121
143
|
/** The deployment's workspaces, consulted to resolve a card that pins none. */
|
|
@@ -132,12 +154,26 @@ export declare class TaskBoardHostService {
|
|
|
132
154
|
now?: () => number;
|
|
133
155
|
commandDispatcher?: SessionCommandDispatcher;
|
|
134
156
|
workspaceRegistry?: TaskBoardWorkspaceRegistry;
|
|
157
|
+
/**
|
|
158
|
+
* The owner peer every gateway request the runner makes speaks for.
|
|
159
|
+
* Production passes the peer bound to the plugin fiber (see
|
|
160
|
+
* {@link createOwnerPeer}); absent is fine for tests and bare mounts,
|
|
161
|
+
* where the runner binds one to a fresh root context.
|
|
162
|
+
*/
|
|
163
|
+
ownerPeer?: GatewayPeer;
|
|
135
164
|
/**
|
|
136
165
|
* Permission baseline of the confirmation gate: a fixed value, or a live
|
|
137
166
|
* resolver the board re-reads so a Host Settings change needs no remount.
|
|
138
167
|
*/
|
|
139
168
|
sessionDefaultPermission?: TaskPermission | (() => TaskPermission);
|
|
140
169
|
maxSubtaskDepth?: number;
|
|
170
|
+
/**
|
|
171
|
+
* Live reader of the deployment's new-card defaults (volatile config reads).
|
|
172
|
+
* The board publishes them for the create dialog and re-reads them for every
|
|
173
|
+
* create that opts in, so a settings edit reaches the next created card
|
|
174
|
+
* without remounting the row. Absent means the deployment configures none.
|
|
175
|
+
*/
|
|
176
|
+
cardDefaults?: () => CardDefaults;
|
|
141
177
|
team?: TaskBoardTeamDispatcher;
|
|
142
178
|
timers?: HostTimerFace;
|
|
143
179
|
/**
|
|
@@ -156,6 +192,25 @@ export declare class TaskBoardHostService {
|
|
|
156
192
|
verificationSettings?: () => VerificationSettings;
|
|
157
193
|
/** The host model catalog the acceptance contract resolves its route from. */
|
|
158
194
|
verificationCatalog?: () => Promise<ModelCatalogView | undefined>;
|
|
195
|
+
/**
|
|
196
|
+
* Live admission width for run launches: the number of launches (one
|
|
197
|
+
* session creation and its prompt each) that may be in flight at once. Read
|
|
198
|
+
* per admission, so editing the setting bounds the next launch of a run that
|
|
199
|
+
* is still queueing. Absent means the default width.
|
|
200
|
+
*/
|
|
201
|
+
runLaunchWidth?: () => number;
|
|
202
|
+
/**
|
|
203
|
+
* Live daily token cap (a volatile config read). 0 — the default, and what
|
|
204
|
+
* every deployment that never configured one keeps — ends the gate before
|
|
205
|
+
* anything is measured. A positive cap refuses a run whose day already spent
|
|
206
|
+
* it, on both the action path and the cron path.
|
|
207
|
+
*/
|
|
208
|
+
spendBudgetTokens?: () => number;
|
|
209
|
+
/**
|
|
210
|
+
* Today's measured spend in tokens, or undefined when this deployment keeps
|
|
211
|
+
* no readable usage ledger. Defaults to the family usage ledger reader.
|
|
212
|
+
*/
|
|
213
|
+
spendUsedToday?: (now: number) => number | undefined;
|
|
159
214
|
});
|
|
160
215
|
start(): void;
|
|
161
216
|
/**
|
|
@@ -222,6 +277,18 @@ export declare class TaskBoardHostService {
|
|
|
222
277
|
* never disagree about a card.
|
|
223
278
|
*/
|
|
224
279
|
private applyBoardAction;
|
|
280
|
+
/**
|
|
281
|
+
* Refuse a run whose day already spent the cap.
|
|
282
|
+
*
|
|
283
|
+
* A cap of 0 — the shipped default — answers before the measurement is read:
|
|
284
|
+
* no ledger file is opened and nothing is summed, which is what keeps a board
|
|
285
|
+
* that never configured a cap identical to the one before it existed.
|
|
286
|
+
*
|
|
287
|
+
* The refusal is a thrown message rather than a code: the wire hands its text
|
|
288
|
+
* to the caller as board-refused, exactly like every other refusal this board
|
|
289
|
+
* makes.
|
|
290
|
+
*/
|
|
291
|
+
private assertSpendCap;
|
|
225
292
|
/** Route one provider action and answer the resulting board snapshot. */
|
|
226
293
|
private handleExtensionAction;
|
|
227
294
|
/** Current task id -> status map, for change detection around a mutation. */
|
|
@@ -230,6 +297,26 @@ export declare class TaskBoardHostService {
|
|
|
230
297
|
private emitStatusChanges;
|
|
231
298
|
dispose(): void;
|
|
232
299
|
private launch;
|
|
300
|
+
/**
|
|
301
|
+
* Read the acceptance contract one run group freezes, in the order the board
|
|
302
|
+
* has always read it: the acceptance settings, then the global native-/goal
|
|
303
|
+
* switch, then the model catalog that both resolves the contract's route and
|
|
304
|
+
* decides the reasoning effort the session may be given.
|
|
305
|
+
*/
|
|
306
|
+
private freezeRunContract;
|
|
307
|
+
/**
|
|
308
|
+
* A {@link RunContractFreezer} that reads once and hands the SAME value to
|
|
309
|
+
* every later caller of one run group. A read that fails is not cached: the
|
|
310
|
+
* next member reads again, exactly as a per-execution read would have.
|
|
311
|
+
*/
|
|
312
|
+
private contractFreezerForRunGroup;
|
|
313
|
+
/**
|
|
314
|
+
* Give back the occurrence a launch consumed, for a launch that never reached
|
|
315
|
+
* a session: a failed launch, or one the Host abandoned while it was still
|
|
316
|
+
* waiting for an admission slot. A manual run, and a launch that DID reach a
|
|
317
|
+
* session, are never refunded.
|
|
318
|
+
*/
|
|
319
|
+
private refundUnstartedSchedule;
|
|
233
320
|
private scheduleTeammate;
|
|
234
321
|
/**
|
|
235
322
|
* Spawn one teammate inside the Lead session and attach the teammate's
|
|
@@ -335,6 +422,13 @@ export declare class TaskBoardHostService {
|
|
|
335
422
|
* member then launches on its own so one refused participant cannot hold the
|
|
336
423
|
* others back. A team run's members are spawned inside the root's Lead
|
|
337
424
|
* session instead, once that session exists.
|
|
425
|
+
*
|
|
426
|
+
* Every launch of one run set goes through the admission queue, which admits
|
|
427
|
+
* at most `runLaunchWidth` of them at a time — the whole subtree still opens,
|
|
428
|
+
* members just enter the running column in batches. Order inside the group is
|
|
429
|
+
* the order they are enqueued here, so the root's session always exists before
|
|
430
|
+
* any member's, and one member's launch settling (or failing) is what admits
|
|
431
|
+
* the next. All members share the one contract this group freezes.
|
|
338
432
|
*/
|
|
339
433
|
private dispatchRuns;
|
|
340
434
|
/**
|
|
@@ -343,6 +437,26 @@ export declare class TaskBoardHostService {
|
|
|
343
437
|
*/
|
|
344
438
|
private setApplicability;
|
|
345
439
|
private scheduleLaunch;
|
|
440
|
+
/**
|
|
441
|
+
* Hand one launch to the admission queue, or abandon it on the spot when the
|
|
442
|
+
* Host is already stopping: a queue entry created after {@link dispose} would
|
|
443
|
+
* otherwise never be drained, and its card would sit in the running column
|
|
444
|
+
* until the next Host start recovered it.
|
|
445
|
+
*/
|
|
446
|
+
private enqueueLaunch;
|
|
447
|
+
/** Whether one opened execution is still open in the ledger. */
|
|
448
|
+
private isExecutionOpen;
|
|
449
|
+
/**
|
|
450
|
+
* Take one launch that never started out of the running column.
|
|
451
|
+
*
|
|
452
|
+
* Settled as CANCELLED, not failed: nothing about the run's work went wrong —
|
|
453
|
+
* the Host stopped before the launch got a slot, which is exactly what the
|
|
454
|
+
* next start's interrupted-start recovery records for an execution that never
|
|
455
|
+
* reached a session. A scheduled occurrence that never reached a session is
|
|
456
|
+
* refunded on the same terms as any other pre-session failure, so a run the
|
|
457
|
+
* Host never started cannot silently spend the user's run budget.
|
|
458
|
+
*/
|
|
459
|
+
private abandonQueuedRun;
|
|
346
460
|
private schedulePoll;
|
|
347
461
|
/**
|
|
348
462
|
* Count one failed pass and arm the retry that follows it.
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Today's measured spend, read from the usage ledger this deployment keeps at
|
|
3
|
+
* `$DSH_HOME/dsh-usage/usage-ledger.json`.
|
|
4
|
+
*
|
|
5
|
+
* The measure is the family usage ledger rather than a counter this plugin
|
|
6
|
+
* accumulates from `session/event`, for two reasons. The ledger is durable, so
|
|
7
|
+
* a cap cannot be reset by restarting the Host (the Loader remounts a row on
|
|
8
|
+
* any config change, and a spend counter that lived only in memory would forget
|
|
9
|
+
* the day). And a second fold of the same events inside the board would have to
|
|
10
|
+
* persist its own totals to be worth anything, which means a second writer of
|
|
11
|
+
* spend state in one process.
|
|
12
|
+
*
|
|
13
|
+
* What that costs: the file belongs to the dsh-usage plugin, so a deployment
|
|
14
|
+
* that does not mount it keeps no ledger and the cap cannot measure anything.
|
|
15
|
+
* That case is reported once per process and the gate then refuses nothing —
|
|
16
|
+
* wedging the board because a sibling plugin is absent would be worse than a
|
|
17
|
+
* cap that says it cannot see. The 3 s flush debounce of that plugin is the
|
|
18
|
+
* other cost: the reading trails the busiest moments by at most one debounce.
|
|
19
|
+
* @module @linxin666/dsh-task-board/host-spend
|
|
20
|
+
*/
|
|
21
|
+
/**
|
|
22
|
+
* Local-date key (`YYYY-MM-DD`) of an instant, the bucketing the usage ledger
|
|
23
|
+
* itself uses: the cap and the usage panel therefore roll over at the same
|
|
24
|
+
* local midnight.
|
|
25
|
+
* @param ms - clock instant (ms epoch).
|
|
26
|
+
* @returns the day key.
|
|
27
|
+
*/
|
|
28
|
+
export declare function spendDateKey(ms: number): string;
|
|
29
|
+
/**
|
|
30
|
+
* Total tokens one ledger day recorded, across every provider and model of that
|
|
31
|
+
* day. Anything that is not a finite token count contributes 0, so a ledger
|
|
32
|
+
* written by another version degrades to a smaller reading instead of NaN.
|
|
33
|
+
* @param day - one day bucket as the ledger stores it, when it is one.
|
|
34
|
+
* @returns the day's token total.
|
|
35
|
+
*/
|
|
36
|
+
export declare function ledgerDayTokens(day: unknown): number;
|
|
37
|
+
/**
|
|
38
|
+
* Path of the usage ledger for this DSH home.
|
|
39
|
+
* @returns the absolute ledger path.
|
|
40
|
+
*/
|
|
41
|
+
export declare function spendLedgerPath(): string;
|
|
42
|
+
/**
|
|
43
|
+
* Tokens already spent today, or undefined when no measurement is available.
|
|
44
|
+
*
|
|
45
|
+
* Undefined is "cannot see", not "spent nothing": the caller fails open and
|
|
46
|
+
* reports it, because a spend cap that cannot read its own source must never
|
|
47
|
+
* decide that no work may run.
|
|
48
|
+
* @param now - clock instant (ms epoch).
|
|
49
|
+
* @param path - ledger path (test seam).
|
|
50
|
+
* @returns today's token total, or undefined when the ledger is unreadable.
|
|
51
|
+
*/
|
|
52
|
+
export declare function usedTokensToday(now?: number, path?: string): number | undefined;
|
package/lib/types/index.d.ts
CHANGED
|
@@ -69,6 +69,26 @@ export interface Config {
|
|
|
69
69
|
* at all, so this cadence only bounds how quickly a running card settles.
|
|
70
70
|
*/
|
|
71
71
|
sessionPollSeconds?: Volatile<number>;
|
|
72
|
+
/**
|
|
73
|
+
* How many run launches this board may have in flight at once (1..16,
|
|
74
|
+
* default 3). One run opens its whole subtree, so without a bound the Host
|
|
75
|
+
* asks DSH for every member's session in the same tick; this is the mechanism
|
|
76
|
+
* that enforces the repository's measured guidance for heavy implementation
|
|
77
|
+
* subagents. Members wait their turn instead of being dropped: the subtree
|
|
78
|
+
* still opens completely, they only enter the running column in batches. Read
|
|
79
|
+
* at each admission, so an edit bounds the next launch of a run that is still
|
|
80
|
+
* queueing.
|
|
81
|
+
*/
|
|
82
|
+
runLaunchWidth?: Volatile<number>;
|
|
83
|
+
/**
|
|
84
|
+
* Daily token ceiling for the work this board dispatches (default 0 = no
|
|
85
|
+
* gate). Tokens, not money: the ledger the board measures against prices
|
|
86
|
+
* DeepSeek's own routes only, so a cost cap would read 0 elsewhere. Read at
|
|
87
|
+
* each gate, so an edit binds the next run without a remount; a manual
|
|
88
|
+
* run/rerun whose day already spent the cap is refused, and a due occurrence
|
|
89
|
+
* is skipped onto the scheduler with its run budget untouched.
|
|
90
|
+
*/
|
|
91
|
+
spendBudgetTokens?: Volatile<number>;
|
|
72
92
|
/**
|
|
73
93
|
* Continuable-subagent provider the Agent Teams service uses to compose a
|
|
74
94
|
* teammate. Matches the Agent Teams tool plugin's `freshProvider` default;
|
|
@@ -91,6 +111,33 @@ export interface Config {
|
|
|
91
111
|
* becomes a goal run.
|
|
92
112
|
*/
|
|
93
113
|
goalRunEnabled?: Volatile<boolean>;
|
|
114
|
+
/**
|
|
115
|
+
* Agent preset a NEW card starts from (volatile, default blank = not set).
|
|
116
|
+
* A prefill, never a pin: the create dialog opens with it selected, the
|
|
117
|
+
* caller may override it, and the card stores what it was created with. It
|
|
118
|
+
* reaches the create path only when that caller opts in with
|
|
119
|
+
* `applyCardDefaults`, so the extension provider's own create and the legacy
|
|
120
|
+
* import are untouched.
|
|
121
|
+
*/
|
|
122
|
+
cardDefaultMode?: Volatile<string>;
|
|
123
|
+
/**
|
|
124
|
+
* Permission a NEW card starts from (volatile, default blank = not set), one
|
|
125
|
+
* of the three presets. A prefill like the rest: a value above
|
|
126
|
+
* `sessionDefaultPermission` still has to be confirmed by a human before the
|
|
127
|
+
* card may run, because the pre-execution gate is what decides that.
|
|
128
|
+
*/
|
|
129
|
+
cardDefaultPermission?: Volatile<TaskPermission | ''>;
|
|
130
|
+
/**
|
|
131
|
+
* Model a NEW card starts from (volatile, default blank = not set).
|
|
132
|
+
*/
|
|
133
|
+
cardDefaultModel?: Volatile<string>;
|
|
134
|
+
/**
|
|
135
|
+
* Reasoning level a NEW card starts from (volatile, default blank = not set).
|
|
136
|
+
* Bound to `cardDefaultModel` exactly as a card's own level is bound to its
|
|
137
|
+
* own model: it applies only while the card's final model IS that default
|
|
138
|
+
* model, and a blank `cardDefaultModel` makes it inert.
|
|
139
|
+
*/
|
|
140
|
+
cardDefaultReasoningEffort?: Volatile<string>;
|
|
94
141
|
/**
|
|
95
142
|
* Goal acceptance for executions this board starts (default ON). When on,
|
|
96
143
|
* update_goal(action: complete) inside a task execution is refused until an
|
|
@@ -166,10 +213,22 @@ export interface ConfigInput {
|
|
|
166
213
|
maxSubtaskDepth?: number;
|
|
167
214
|
/** Roster-poll cadence in seconds while the board has work to reconcile. */
|
|
168
215
|
sessionPollSeconds?: number;
|
|
216
|
+
/** Concurrent run launches allowed at once, 1..16. */
|
|
217
|
+
runLaunchWidth?: number;
|
|
218
|
+
/** Daily token ceiling for board runs; 0 disables the gate. */
|
|
219
|
+
spendBudgetTokens?: number;
|
|
169
220
|
/** Continuable-subagent provider the Agent Teams service composes a teammate from. */
|
|
170
221
|
teamProvider?: string;
|
|
171
222
|
/** Global native /goal switch; default off, frozen per execution. */
|
|
172
223
|
goalRunEnabled?: boolean;
|
|
224
|
+
/** Agent preset a new card starts from; blank = not set. */
|
|
225
|
+
cardDefaultMode?: string;
|
|
226
|
+
/** Permission a new card starts from; blank = not set. */
|
|
227
|
+
cardDefaultPermission?: TaskPermission | '';
|
|
228
|
+
/** Model a new card starts from; blank = not set. */
|
|
229
|
+
cardDefaultModel?: string;
|
|
230
|
+
/** Reasoning level a new card starts from; blank = not set. */
|
|
231
|
+
cardDefaultReasoningEffort?: string;
|
|
173
232
|
/** Goal acceptance switch. */
|
|
174
233
|
goalVerification?: boolean;
|
|
175
234
|
/** Judge model route for goal acceptance; blank inherits the host default. */
|
|
@@ -304,6 +363,45 @@ export declare function buildTeamDispatcher(ctx: Context, provider: string): Tas
|
|
|
304
363
|
* @returns the llm service, or undefined when this deployment serves none.
|
|
305
364
|
*/
|
|
306
365
|
export declare function resolveLlmRuntime(ctx: Context): LlmRuntime | undefined;
|
|
366
|
+
/**
|
|
367
|
+
* The subset of `sessionController` the board uses to wake a cold persisted
|
|
368
|
+
* session before running a slash command on it (issue #1861).
|
|
369
|
+
*/
|
|
370
|
+
interface SessionControllerFace {
|
|
371
|
+
resolveAgent(sessionId: Parameters<Context['agents']['get']>[0]): Promise<{
|
|
372
|
+
readonly agent: Parameters<Context['commands']['execute']>[0];
|
|
373
|
+
} | {
|
|
374
|
+
readonly error: {
|
|
375
|
+
readonly message?: string;
|
|
376
|
+
};
|
|
377
|
+
}>;
|
|
378
|
+
}
|
|
379
|
+
/**
|
|
380
|
+
* Resolve the optional `sessionController` service. Like the tool registry and
|
|
381
|
+
* the llm runtime, it is read dynamically so capture-only test contexts that do
|
|
382
|
+
* not mount the full session controller still activate the board.
|
|
383
|
+
* @param ctx - the plugin context.
|
|
384
|
+
* @returns the session controller face, or undefined when unavailable.
|
|
385
|
+
*/
|
|
386
|
+
export declare function resolveSessionController(ctx: Context): SessionControllerFace | undefined;
|
|
387
|
+
/**
|
|
388
|
+
* Resolve the live Agent for an execution session, resuming a cold persisted
|
|
389
|
+
* session through `sessionController.resolveAgent` when it is not yet in
|
|
390
|
+
* `ctx.agents` (issue #1861).
|
|
391
|
+
*
|
|
392
|
+
* A fresh run (`session/create`) or a session the browser is currently
|
|
393
|
+
* following is already in `ctx.agents`, so the fast path returns immediately.
|
|
394
|
+
* A scheduled or manual reuse of a cold session — one that `session/list`
|
|
395
|
+
* reports as idle from disk without activating its Agent — is not in
|
|
396
|
+
* `ctx.agents` when `pinAndPrompt` runs `/permission` ahead of
|
|
397
|
+
* `session/selectModel` and `session/prompt`; delegating to
|
|
398
|
+
* `sessionController.resolveAgent` resumes it with its recorded preset and
|
|
399
|
+
* model-selection state, matching what those gateway endpoints do next.
|
|
400
|
+
* @param ctx - the plugin context.
|
|
401
|
+
* @param sessionId - the target execution session id.
|
|
402
|
+
* @returns the live Agent for `sessionId`.
|
|
403
|
+
*/
|
|
404
|
+
export declare function resolveExecutionAgent(ctx: Context, sessionId: Parameters<Context['agents']['get']>[0]): Promise<Parameters<Context['commands']['execute']>[0]>;
|
|
307
405
|
/**
|
|
308
406
|
* Activate the board's host half: ledger, routes, cron scheduler, power
|
|
309
407
|
* inhibitor, and the model-facing announcement.
|
package/lib/types/loopback.d.ts
CHANGED
|
@@ -7,6 +7,14 @@
|
|
|
7
7
|
* Semantics: RFC 5735 IPv4 127/8, ::1, IPv4-mapped ::ffff:127/8 (matching the
|
|
8
8
|
* remote-web-ui gate), localhost hostnames, plus the browser same-origin
|
|
9
9
|
* markers (sec-fetch-site and Origin) for the request-level fence.
|
|
10
|
+
*
|
|
11
|
+
* A reverse proxy in front of the host rewrites the Host header to its own
|
|
12
|
+
* upstream literal (a Cloudflare tunnel, frp and an nginx reverse proxy all
|
|
13
|
+
* dial 127.0.0.1:<port>), and the socket the origin sees is the proxy's, which
|
|
14
|
+
* is loopback by construction. Both halves of the fence then hold for a public
|
|
15
|
+
* request. Forwarding headers are the signal that a hop stands in between: a
|
|
16
|
+
* request that carries CF-Connecting-IP or X-Forwarded-For is answered through
|
|
17
|
+
* a proxy and is never treated as a local one (issue #1906).
|
|
10
18
|
* @module dsh-web-shared/host/loopback
|
|
11
19
|
*/
|
|
12
20
|
import type { IncomingMessage } from 'node:http';
|
|
@@ -16,9 +24,20 @@ export declare function isIPv4Loopback(v4: string): boolean;
|
|
|
16
24
|
export declare function isLoopbackAddress(address: string | undefined): boolean;
|
|
17
25
|
/** Whether a normalized URL hostname names the loopback authority (localhost, [::1], 127/8). */
|
|
18
26
|
export declare function isLoopbackHostname(hostname: string): boolean;
|
|
27
|
+
/**
|
|
28
|
+
* Whether a reverse proxy stood between the client and this host: the request
|
|
29
|
+
* carries CF-Connecting-IP or X-Forwarded-For. Either header is stamped by a
|
|
30
|
+
* hop that forwards traffic, so the request did not originate on this machine.
|
|
31
|
+
* @param request - node HTTP request.
|
|
32
|
+
* @returns true when a forwarding header is present.
|
|
33
|
+
*/
|
|
34
|
+
export declare function isProxiedRequest(request: IncomingMessage): boolean;
|
|
19
35
|
/**
|
|
20
36
|
* Request-level trust fence: a loopback socket address AND a loopback Host
|
|
21
37
|
* header, plus browser same-origin markers. The socket address is
|
|
22
|
-
* authoritative;
|
|
38
|
+
* authoritative for a direct connection; a request that carries a forwarding
|
|
39
|
+
* header is refused outright, because a proxy in front of the host makes both
|
|
40
|
+
* the socket address and the Host header describe the proxy rather than the
|
|
41
|
+
* client. X-Forwarded-For is therefore never evidence *for* loopback.
|
|
23
42
|
*/
|
|
24
43
|
export declare function isLoopbackRequest(request: IncomingMessage): boolean;
|
package/lib/types/protocol.d.ts
CHANGED
|
@@ -74,6 +74,19 @@ export interface TaskBoardSnapshot {
|
|
|
74
74
|
* flight.
|
|
75
75
|
*/
|
|
76
76
|
goalRunEnabled?: boolean;
|
|
77
|
+
/**
|
|
78
|
+
* New-card defaults this deployment configures: what the create dialog opens
|
|
79
|
+
* with, and what the create path fills an omitted target from when the caller
|
|
80
|
+
* opts in (`applyCardDefaults`). A target the board configures nothing for is
|
|
81
|
+
* omitted rather than published blank, so the browser can tell "no default
|
|
82
|
+
* model" from "a blank one".
|
|
83
|
+
*/
|
|
84
|
+
cardDefaults?: {
|
|
85
|
+
mode?: string;
|
|
86
|
+
permission?: TaskPermission;
|
|
87
|
+
model?: string;
|
|
88
|
+
reasoningEffort?: string;
|
|
89
|
+
};
|
|
77
90
|
/**
|
|
78
91
|
* Read-only summaries published by running extensions, keyed by extension id.
|
|
79
92
|
* The board forwards them verbatim; it never interprets their shape.
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@linxin666/dsh-client-ui-task-board",
|
|
3
3
|
"description": "Host-authoritative task board for the DSH Web GUI with real session execution, Host cron scheduling, and optional cross-platform idle-sleep protection; mounted without DSH source changes.",
|
|
4
|
-
"version": "0.4.
|
|
4
|
+
"version": "0.4.8",
|
|
5
5
|
"icon": "icon.svg",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"main": "lib/index.js",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
},
|
|
21
21
|
"dsh": {
|
|
22
22
|
"engines": {
|
|
23
|
-
"dsh": ">=0.2.
|
|
23
|
+
"dsh": ">=0.2.1-rc.2"
|
|
24
24
|
},
|
|
25
25
|
"bundle": {
|
|
26
26
|
"patch": "./cordis.patch.yml"
|
|
@@ -40,37 +40,37 @@
|
|
|
40
40
|
}
|
|
41
41
|
},
|
|
42
42
|
"peerDependencies": {
|
|
43
|
-
"@deepseek-ai/dsh": ">=0.2.
|
|
43
|
+
"@deepseek-ai/dsh": ">=0.2.1-rc.2",
|
|
44
44
|
"react": "^18.2.0"
|
|
45
45
|
},
|
|
46
46
|
"dependencies": {
|
|
47
|
-
"@deepseek-ai/schemastery": "^3.18.
|
|
47
|
+
"@deepseek-ai/schemastery": "^3.18.5",
|
|
48
48
|
"marked": "^18.0.14"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
|
-
"@deepseek-ai/cordis": "^4.0.
|
|
52
|
-
"@deepseek-ai/dsh-agent": "^0.2.
|
|
53
|
-
"@deepseek-ai/dsh-agent-preset-registry": "^0.2.
|
|
54
|
-
"@deepseek-ai/dsh-api-gateway": "^0.2.
|
|
55
|
-
"@deepseek-ai/dsh-api-remotes": "^0.2.
|
|
56
|
-
"@deepseek-ai/dsh-api-session-controller": "^0.2.
|
|
57
|
-
"@deepseek-ai/dsh-api-workspace-controller": "^0.2.
|
|
58
|
-
"@deepseek-ai/dsh-client-connection": "^0.2.
|
|
59
|
-
"@deepseek-ai/dsh-client-locale": "^0.2.
|
|
60
|
-
"@deepseek-ai/dsh-client-store": "^0.2.
|
|
61
|
-
"@deepseek-ai/dsh-client-ui-layout": "^0.2.
|
|
62
|
-
"@deepseek-ai/dsh-client-ui-renderer": "^0.2.
|
|
63
|
-
"@deepseek-ai/dsh-client-ui-settings": "^0.2.
|
|
64
|
-
"@deepseek-ai/dsh-client-ui-sidebar": "^0.2.
|
|
65
|
-
"@deepseek-ai/dsh-client-ui-slots": "^0.2.
|
|
66
|
-
"@deepseek-ai/dsh-client-ui-workspace": "^0.2.
|
|
67
|
-
"@deepseek-ai/dsh-commands": "^0.2.
|
|
68
|
-
"@deepseek-ai/dsh-host-webserver": "^0.2.
|
|
69
|
-
"@deepseek-ai/dsh-llm": "^0.2.
|
|
70
|
-
"@deepseek-ai/dsh-settings": "^0.2.
|
|
71
|
-
"@deepseek-ai/dsh-system-prompt": "^0.2.
|
|
72
|
-
"@deepseek-ai/dsh-tools": "^0.2.
|
|
73
|
-
"@deepseek-ai/dsh-workspace": "^0.2.
|
|
51
|
+
"@deepseek-ai/cordis": "^4.0.5",
|
|
52
|
+
"@deepseek-ai/dsh-agent": "^0.2.1-rc.2",
|
|
53
|
+
"@deepseek-ai/dsh-agent-preset-registry": "^0.2.1-rc.2",
|
|
54
|
+
"@deepseek-ai/dsh-api-gateway": "^0.2.1-rc.2",
|
|
55
|
+
"@deepseek-ai/dsh-api-remotes": "^0.2.1-rc.2",
|
|
56
|
+
"@deepseek-ai/dsh-api-session-controller": "^0.2.1-rc.2",
|
|
57
|
+
"@deepseek-ai/dsh-api-workspace-controller": "^0.2.1-rc.2",
|
|
58
|
+
"@deepseek-ai/dsh-client-connection": "^0.2.1-rc.2",
|
|
59
|
+
"@deepseek-ai/dsh-client-locale": "^0.2.1-rc.2",
|
|
60
|
+
"@deepseek-ai/dsh-client-store": "^0.2.1-rc.2",
|
|
61
|
+
"@deepseek-ai/dsh-client-ui-layout": "^0.2.1-rc.2",
|
|
62
|
+
"@deepseek-ai/dsh-client-ui-renderer": "^0.2.1-rc.2",
|
|
63
|
+
"@deepseek-ai/dsh-client-ui-settings": "^0.2.1-rc.2",
|
|
64
|
+
"@deepseek-ai/dsh-client-ui-sidebar": "^0.2.1-rc.2",
|
|
65
|
+
"@deepseek-ai/dsh-client-ui-slots": "^0.2.1-rc.2",
|
|
66
|
+
"@deepseek-ai/dsh-client-ui-workspace": "^0.2.1-rc.2",
|
|
67
|
+
"@deepseek-ai/dsh-commands": "^0.2.1-rc.2",
|
|
68
|
+
"@deepseek-ai/dsh-host-webserver": "^0.2.1-rc.2",
|
|
69
|
+
"@deepseek-ai/dsh-llm": "^0.2.1-rc.2",
|
|
70
|
+
"@deepseek-ai/dsh-settings": "^0.2.1-rc.2",
|
|
71
|
+
"@deepseek-ai/dsh-system-prompt": "^0.2.1-rc.2",
|
|
72
|
+
"@deepseek-ai/dsh-tools": "^0.2.1-rc.2",
|
|
73
|
+
"@deepseek-ai/dsh-workspace": "^0.2.1-rc.2",
|
|
74
74
|
"@types/node": "^22.20.0",
|
|
75
75
|
"@types/react": "~18.3.1",
|
|
76
76
|
"@types/react-dom": "^18.3.5",
|
|
@@ -100,7 +100,7 @@
|
|
|
100
100
|
"build": "tsc -b tsconfig.build.json && tsdown",
|
|
101
101
|
"bundle": "tsdown",
|
|
102
102
|
"watch": "tsdown --watch",
|
|
103
|
-
"typecheck": "
|
|
103
|
+
"typecheck": "tsgo --noEmit",
|
|
104
104
|
"test": "vitest run",
|
|
105
105
|
"test:watch": "vitest"
|
|
106
106
|
}
|