@linxin666/dsh-client-ui-task-board 0.4.19 → 0.4.21
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 +1 -1
- package/README.zh.md +1 -1
- package/lib/client.js +190 -63
- package/lib/client.js.map +1 -1
- package/lib/index.js +599 -95
- package/lib/types/client/board/TaskForm.d.ts +3 -1
- package/lib/types/client/index.d.ts +7 -1
- package/lib/types/client/native-panel.d.ts +1 -1
- package/lib/types/client/seats.d.ts +36 -2
- package/lib/types/client/settings-form.d.ts +2 -0
- package/lib/types/core/controller.d.ts +1 -1
- package/lib/types/core/extension.d.ts +160 -1
- package/lib/types/core/session-reuse.d.ts +46 -13
- package/lib/types/core/tasks.d.ts +16 -5
- package/lib/types/host/agent-tools.d.ts +12 -2
- package/lib/types/host/extension-registry.d.ts +38 -1
- package/lib/types/host-ledger.d.ts +86 -1
- package/lib/types/host-runner.d.ts +20 -1
- package/lib/types/host-service.d.ts +64 -15
- package/lib/types/protocol.d.ts +18 -1
- package/package.json +1 -1
- package/src/client/board/ExecutionLog.tsx +15 -2
- package/src/client/board/NewTaskModal.tsx +88 -3
- package/src/client/board/TaskDetail.tsx +18 -11
- package/src/client/board/TaskForm.tsx +13 -2
- package/src/client/board.module.css +67 -1
- package/src/client/index.ts +3 -0
- package/src/client/locales.ts +7 -6
- package/src/client/native-panel.tsx +2 -1
- package/src/client/seats.tsx +32 -4
- package/src/client/service.ts +3 -0
- package/src/client/settings-form.ts +21 -2
- package/src/core/controller.ts +9 -3
- package/src/core/execution-summary.ts +3 -2
- package/src/core/extension.ts +159 -1
- package/src/core/session-reuse.ts +58 -21
- package/src/core/store.ts +2 -0
- package/src/core/tasks.ts +16 -5
- package/src/host/agent-tools.ts +70 -17
- package/src/host/extension-registry.ts +157 -2
- package/src/host-ledger.ts +274 -23
- package/src/host-runner.ts +44 -5
- package/src/host-service.ts +190 -37
- package/src/protocol.ts +37 -3
|
@@ -2,6 +2,7 @@ import { type ExecutionOutcome, type ExecutionRecord, type ExecutionSummary, typ
|
|
|
2
2
|
import type { CardDefaults } from './core/card-defaults.ts';
|
|
3
3
|
import { type TaskBoardAction, type TaskBoardSchedulerSnapshot } from './protocol.ts';
|
|
4
4
|
import { type TaskPermission } from './core/handover.ts';
|
|
5
|
+
import type { TaskBoardLaunchHandler, TaskBoardLaunchTrigger } from './core/extension.ts';
|
|
5
6
|
export interface LedgerState {
|
|
6
7
|
revision: number;
|
|
7
8
|
tasks: TaskRecord[];
|
|
@@ -10,6 +11,11 @@ export interface LedgerState {
|
|
|
10
11
|
export interface OpenedRun {
|
|
11
12
|
task: TaskRecord;
|
|
12
13
|
execution: ExecutionRecord;
|
|
14
|
+
/**
|
|
15
|
+
* The prompt preamble the launch gate asked for, injected ahead of the card's
|
|
16
|
+
* own prompt text. Present only when a provider answered `local` with one.
|
|
17
|
+
*/
|
|
18
|
+
promptPreamble?: string;
|
|
13
19
|
}
|
|
14
20
|
/**
|
|
15
21
|
* Prefix of the `initiatedBy` an inherited descendant verdict carries. The Host
|
|
@@ -89,6 +95,15 @@ export type PowerShellProbe = (script: string, timeoutMs: number) => string | un
|
|
|
89
95
|
* probe is injectable so the fallback chain is testable off Windows.
|
|
90
96
|
*/
|
|
91
97
|
export declare function win32StartTimeMs(pid: number, probe?: PowerShellProbe): number | undefined;
|
|
98
|
+
/**
|
|
99
|
+
* The process identity reads the lock decision depends on. Injectable so the
|
|
100
|
+
* unprobeable-identity branch is testable on every platform without a real
|
|
101
|
+
* PowerShell/CIM round trip.
|
|
102
|
+
*/
|
|
103
|
+
export interface LockProcessProbe {
|
|
104
|
+
isAlive(pid: number): boolean;
|
|
105
|
+
startTimeMs(pid: number): number | undefined;
|
|
106
|
+
}
|
|
92
107
|
/**
|
|
93
108
|
* Repair parent links after a load or an import: a link whose parent row is
|
|
94
109
|
* missing, cyclic, or names an archived parent while the child is on board is
|
|
@@ -106,6 +121,10 @@ export declare class HostTaskLedger {
|
|
|
106
121
|
private readonly requestCache;
|
|
107
122
|
private readonly lockToken;
|
|
108
123
|
private lockFd;
|
|
124
|
+
private lockHeartbeat;
|
|
125
|
+
private readonly processProbe;
|
|
126
|
+
/** Warning sink; defaults to console.warn, tests inject a collector. */
|
|
127
|
+
private readonly warn;
|
|
109
128
|
readonly file: string;
|
|
110
129
|
readonly lockFile: string;
|
|
111
130
|
/** Small sidecar for the 30 s scheduler heartbeat (lastTickAt only). */
|
|
@@ -134,12 +153,25 @@ export declare class HostTaskLedger {
|
|
|
134
153
|
private readonly spendBudget;
|
|
135
154
|
/** Today's measured spend in tokens, or undefined when nothing can be measured. */
|
|
136
155
|
private readonly spendUsed;
|
|
156
|
+
/**
|
|
157
|
+
* The board's launch gate, or undefined when no consumer is attached.
|
|
158
|
+
*
|
|
159
|
+
* The ledger is where every run is opened — the run actions, a due schedule,
|
|
160
|
+
* the run tool, a rework all arrive here — so this is the one point a run can
|
|
161
|
+
* be handed to someone else before an execution record exists. Installed by
|
|
162
|
+
* the Host service after construction, because the gate belongs to the
|
|
163
|
+
* extension registry that is built around this ledger.
|
|
164
|
+
*/
|
|
165
|
+
private launchGate;
|
|
137
166
|
constructor(dir?: string, now?: () => number, options?: {
|
|
138
167
|
sessionDefaultPermission?: TaskPermission | (() => TaskPermission);
|
|
139
168
|
maxSubtaskDepth?: number;
|
|
140
169
|
cardDefaults?: () => CardDefaults;
|
|
141
170
|
spendBudgetTokens?: () => number;
|
|
142
171
|
spendUsedToday?: (now: number) => number | undefined;
|
|
172
|
+
processProbe?: LockProcessProbe;
|
|
173
|
+
warn?: (message: string) => void;
|
|
174
|
+
launchGate?: TaskBoardLaunchHandler;
|
|
143
175
|
});
|
|
144
176
|
/** Current subtask depth limit (1..3). */
|
|
145
177
|
get maxSubtaskDepth(): number;
|
|
@@ -149,6 +181,16 @@ export declare class HostTaskLedger {
|
|
|
149
181
|
* changed nothing emits nothing.
|
|
150
182
|
*/
|
|
151
183
|
setMaxSubtaskDepth(depth: number): void;
|
|
184
|
+
/**
|
|
185
|
+
* Install the launch gate, or remove it with undefined.
|
|
186
|
+
*
|
|
187
|
+
* The Host service owns it: the board's extension registry is built around
|
|
188
|
+
* this ledger, so the gate is attached once that registry exists. A ledger
|
|
189
|
+
* with no gate — every ledger a test drives on its own — opens every run
|
|
190
|
+
* itself, exactly as it did before the seam existed.
|
|
191
|
+
* @param gate - the gate to consult before a run opens, or undefined.
|
|
192
|
+
*/
|
|
193
|
+
setLaunchGate(gate: TaskBoardLaunchHandler | undefined): void;
|
|
152
194
|
/** Remove leftover *.tmp-* files from previous crashes or interrupted writes. */
|
|
153
195
|
private cleanStaleTemporaryFiles;
|
|
154
196
|
/** Revision + scheduler without any task cloning; feeds the SSE event frame. */
|
|
@@ -177,11 +219,36 @@ export declare class HostTaskLedger {
|
|
|
177
219
|
/** Return value-only references for schedules due at the supplied Host time. */
|
|
178
220
|
dueSchedules(now: number): DueScheduleReference[];
|
|
179
221
|
subscribe(listener: () => void): () => void;
|
|
222
|
+
/**
|
|
223
|
+
* Refresh the lock's mtime so a later start can distinguish a live owner from
|
|
224
|
+
* a hard-kill leftover without reading the process identity (issue #2061).
|
|
225
|
+
* Best-effort: a failed beat only ages the lock, and a record that no longer
|
|
226
|
+
* carries this owner's token stops the heartbeat instead of beating for
|
|
227
|
+
* whoever holds the lock now.
|
|
228
|
+
*/
|
|
229
|
+
renewLock(): void;
|
|
230
|
+
private startLockHeartbeat;
|
|
231
|
+
private stopLockHeartbeat;
|
|
180
232
|
dispose(): void;
|
|
181
|
-
applyRequest(requestId: string, action: TaskBoardAction, initiator?: string): {
|
|
233
|
+
applyRequest(requestId: string, action: TaskBoardAction, initiator?: string, trigger?: TaskBoardLaunchTrigger): {
|
|
182
234
|
state: LedgerState;
|
|
183
235
|
runs?: OpenedRun[];
|
|
184
236
|
};
|
|
237
|
+
/**
|
|
238
|
+
* Open the run one due occurrence produced, with the occurrence's own progress
|
|
239
|
+
* written in the same commit.
|
|
240
|
+
*
|
|
241
|
+
* The occurrence is spent either way: a launch gate that hands the run to a
|
|
242
|
+
* provider still consumed this trigger, so the rule's budget advances here
|
|
243
|
+
* exactly as it does for a run the Host opens itself. A call that opened
|
|
244
|
+
* nothing commits the progress it recorded on its own, because the fire path
|
|
245
|
+
* has no other commit behind it.
|
|
246
|
+
* @param task - the card whose rule fired.
|
|
247
|
+
* @param triggeredAt - the instant the occurrence came due.
|
|
248
|
+
* @param progress - the rule's advance, recorded atomically with the launch.
|
|
249
|
+
* @returns the executions the occurrence opened.
|
|
250
|
+
*/
|
|
251
|
+
private scheduledRun;
|
|
185
252
|
/**
|
|
186
253
|
* Open the one run a due schedule triggers: an empty array means nothing ran
|
|
187
254
|
* (already running, a card whose elevated permission is still unconfirmed, a
|
|
@@ -325,6 +392,15 @@ export declare class HostTaskLedger {
|
|
|
325
392
|
* subagents inside this session), and the group id is what later lets the
|
|
326
393
|
* settlement fold a HISTORICAL multi-member group it opened before this
|
|
327
394
|
* behavior changed.
|
|
395
|
+
*
|
|
396
|
+
* This is also the launch gate: every entry that opens a run — the run and
|
|
397
|
+
* rerun actions, a due schedule, the run tool, a rework — arrives here, which
|
|
398
|
+
* makes it the only point where a provider can take a run over before an
|
|
399
|
+
* execution record exists and before any session can be created. A gate that
|
|
400
|
+
* answers `external` writes the running column instead of an execution and
|
|
401
|
+
* nothing else: no session, no run record, no settlement. A gate that answers
|
|
402
|
+
* `local` runs the card exactly as it would have, carrying the preamble the
|
|
403
|
+
* provider asked for to the prompt.
|
|
328
404
|
* @param root - the task the user ran.
|
|
329
405
|
* @param now - clock instant (ms epoch).
|
|
330
406
|
* @param initiator - the DSH session that asked for the run (audit only).
|
|
@@ -334,6 +410,7 @@ export declare class HostTaskLedger {
|
|
|
334
410
|
* atomic commit that opened the execution.
|
|
335
411
|
* @param rework - the reviewer's instructions, when this run redoes previous
|
|
336
412
|
* work; recorded on the execution it opens.
|
|
413
|
+
* @param trigger - which entry asked for this run, handed to the gate.
|
|
337
414
|
*/
|
|
338
415
|
private startRun;
|
|
339
416
|
/**
|
|
@@ -420,5 +497,13 @@ export declare class HostTaskLedger {
|
|
|
420
497
|
private writeSchedulerSidecar;
|
|
421
498
|
private commit;
|
|
422
499
|
private notify;
|
|
500
|
+
/**
|
|
501
|
+
* Move an unidentifiable, heartbeat-aged lock aside instead of deleting it:
|
|
502
|
+
* the record is the only evidence of which process held the ledger, and the
|
|
503
|
+
* takeover is a judgment call an operator may need to audit (issue #2061).
|
|
504
|
+
* A refused rename falls back to removal, because the takeover itself must
|
|
505
|
+
* not depend on the filesystem allowing the rename.
|
|
506
|
+
*/
|
|
507
|
+
private quarantineOrphanLock;
|
|
423
508
|
private acquireLock;
|
|
424
509
|
}
|
|
@@ -8,10 +8,21 @@ import type { ExecutionSummary, TaskRecord } from './core/tasks.ts';
|
|
|
8
8
|
import { type ExecutionFilePart, type ModelInfoResolver, type TaskBoardAttachmentStore } from './host/attachments.ts';
|
|
9
9
|
/**
|
|
10
10
|
* Host services needed to validate a task's workspace before creating a
|
|
11
|
-
* session,
|
|
11
|
+
* session, resolve the workspace an unpinned card runs in, and tell a reusable
|
|
12
|
+
* conversation apart from an archived one.
|
|
12
13
|
*/
|
|
13
14
|
export interface TaskBoardWorkspaceRegistry {
|
|
14
15
|
list(): readonly Workspace[];
|
|
16
|
+
/**
|
|
17
|
+
* The registry-global archive set, in archive order (issue #2068). A Session
|
|
18
|
+
* in it cannot run a turn, so the reuse rule refuses it and the launch starts
|
|
19
|
+
* a fresh conversation instead of settling as `blocked`.
|
|
20
|
+
*
|
|
21
|
+
* Optional: a deployment whose registry face does not report an archive set
|
|
22
|
+
* offers no archive action to defend against, and reuse keeps its
|
|
23
|
+
* pre-archive-set behavior.
|
|
24
|
+
*/
|
|
25
|
+
archivedSessionIds?: readonly string[];
|
|
15
26
|
}
|
|
16
27
|
/**
|
|
17
28
|
* The peer every gateway request names: derived from the public
|
|
@@ -114,6 +125,14 @@ export interface PromptDescendant {
|
|
|
114
125
|
}
|
|
115
126
|
/** Execution-shape context appended to the launched task's prompt. */
|
|
116
127
|
export interface PromptContext {
|
|
128
|
+
/**
|
|
129
|
+
* The launch gate's section: what a provider that kept this run local needs
|
|
130
|
+
* the session to know before it reads the card. Injected on the same path as
|
|
131
|
+
* the tag prefixes and ahead of them, so it opens the prompt. Absent on every
|
|
132
|
+
* run nobody intercepted, which is what keeps the prompt byte-for-byte what
|
|
133
|
+
* it was before the seam existed.
|
|
134
|
+
*/
|
|
135
|
+
launchPreamble?: string;
|
|
117
136
|
/**
|
|
118
137
|
* The card's outstanding descendants. Present exactly when this run is an
|
|
119
138
|
* autonomous dispatch: the Host opens no session for them, so this session
|
|
@@ -4,9 +4,9 @@ import { HostExecutionRunner, type GatewayPeer, type SessionCommandDispatcher, t
|
|
|
4
4
|
import { PowerInhibitor } from './power-inhibitor.ts';
|
|
5
5
|
import { type TaskBoardAction, type TaskBoardEventPayload, type TaskBoardSnapshot } from './protocol.ts';
|
|
6
6
|
import type { CardDefaults } from './core/card-defaults.ts';
|
|
7
|
-
import { TaskBoardExtensionRegistry } from './host/extension-registry.ts';
|
|
8
|
-
import type { TaskBoardExtension } from './core/extension.ts';
|
|
9
|
-
import { type ScheduleMode } from './core/tasks.ts';
|
|
7
|
+
import { TaskBoardExtensionRegistry, type TaskBoardExtensionLogger } from './host/extension-registry.ts';
|
|
8
|
+
import type { TaskBoardExtension, TaskBoardLaunchTrigger } from './core/extension.ts';
|
|
9
|
+
import { type ScheduleMode, type TaskRecord } from './core/tasks.ts';
|
|
10
10
|
import type { ModelCatalogView } from './core/model-catalog.ts';
|
|
11
11
|
import type { TaskPermission } from './core/handover.ts';
|
|
12
12
|
import { type ModelInfoResolver, type TaskBoardAttachmentStore } from './host/attachments.ts';
|
|
@@ -170,6 +170,13 @@ export declare class TaskBoardHostService {
|
|
|
170
170
|
* Absent means "not proven legacy", which keeps the force exactly as it is.
|
|
171
171
|
*/
|
|
172
172
|
legacyAgentTeams?: () => boolean;
|
|
173
|
+
/**
|
|
174
|
+
* Logging seat the extension registry writes to. Absent keeps the process
|
|
175
|
+
* console, which is what a deployment without an opinion wants; a
|
|
176
|
+
* deployment (or a test) that collects the board's own warnings and errors
|
|
177
|
+
* injects its own.
|
|
178
|
+
*/
|
|
179
|
+
extensionLogger?: TaskBoardExtensionLogger;
|
|
173
180
|
});
|
|
174
181
|
start(): void;
|
|
175
182
|
/**
|
|
@@ -197,6 +204,10 @@ export declare class TaskBoardHostService {
|
|
|
197
204
|
* disposer releases it (its stored data stays).
|
|
198
205
|
*/
|
|
199
206
|
registerExtension(extension: TaskBoardExtension): () => void;
|
|
207
|
+
/** What running providers say about one card, for the model-facing tools. */
|
|
208
|
+
describeTask(task: TaskRecord): Record<string, Record<string, unknown>> | undefined;
|
|
209
|
+
/** The run handle a running provider holds for one card, for `task_board_run`. */
|
|
210
|
+
describeRun(taskId: string): Record<string, Record<string, unknown>> | undefined;
|
|
200
211
|
/**
|
|
201
212
|
* The host model catalog the settings card's model and reasoning-level
|
|
202
213
|
* choices come from.
|
|
@@ -247,11 +258,11 @@ export declare class TaskBoardHostService {
|
|
|
247
258
|
private verifyActionAttachments;
|
|
248
259
|
apply(requestId: string, action: Extract<TaskBoardAction, {
|
|
249
260
|
kind: 'extension-action';
|
|
250
|
-
}>, initiator?: string): Promise<TaskBoardSnapshot>;
|
|
261
|
+
}>, initiator?: string, trigger?: TaskBoardLaunchTrigger): Promise<TaskBoardSnapshot>;
|
|
251
262
|
apply(requestId: string, action: Exclude<TaskBoardAction, {
|
|
252
263
|
kind: 'extension-action';
|
|
253
|
-
}>, initiator?: string): TaskBoardSnapshot;
|
|
254
|
-
apply(requestId: string, action: TaskBoardAction, initiator?: string): TaskBoardSnapshot | Promise<TaskBoardSnapshot>;
|
|
264
|
+
}>, initiator?: string, trigger?: TaskBoardLaunchTrigger): TaskBoardSnapshot;
|
|
265
|
+
apply(requestId: string, action: TaskBoardAction, initiator?: string, trigger?: TaskBoardLaunchTrigger): TaskBoardSnapshot | Promise<TaskBoardSnapshot>;
|
|
255
266
|
/**
|
|
256
267
|
* Apply one board-owned action with every gate intact. Provider capability
|
|
257
268
|
* calls and the same-origin wire both land here, so the two surfaces can
|
|
@@ -312,19 +323,57 @@ export declare class TaskBoardHostService {
|
|
|
312
323
|
/**
|
|
313
324
|
* The session a run may continue in, for a card that opted into reuse
|
|
314
325
|
* (issue #1419). Reuse requires positive evidence that the previous session
|
|
315
|
-
* is present and
|
|
316
|
-
* idle board no longer polls, so a roster cached from an earlier
|
|
317
|
-
* be hours old — either refusing a session that has been idle all
|
|
318
|
-
* prompting into one that started running since. A card that did not
|
|
319
|
-
* reads no roster at all, and a read that fails mints a fresh
|
|
320
|
-
* exactly as an unknown roster always did.
|
|
326
|
+
* is present, idle, and not archived, and that evidence must be read for THIS
|
|
327
|
+
* launch: an idle board no longer polls, so a roster cached from an earlier
|
|
328
|
+
* pass could be hours old — either refusing a session that has been idle all
|
|
329
|
+
* along, or prompting into one that started running since. A card that did not
|
|
330
|
+
* opt in reads no roster at all, and a read that fails mints a fresh
|
|
331
|
+
* conversation exactly as an unknown roster always did.
|
|
321
332
|
* @param task - the task about to run.
|
|
322
|
-
* @param force - continue the settled session regardless of the card's own
|
|
323
|
-
* opt-in (a rework), which the reuse rule accepts without waiving any of its
|
|
324
|
-
* evidence conditions.
|
|
325
333
|
* @returns the session id to continue in, or undefined for a fresh session.
|
|
326
334
|
*/
|
|
327
335
|
private reuseSessionFor;
|
|
336
|
+
/**
|
|
337
|
+
* One reuse decision for this launch: the session to continue in, or nothing
|
|
338
|
+
* plus the reason nothing was chosen, so each caller can report it.
|
|
339
|
+
*
|
|
340
|
+
* Reuse never targets a session in the Workspace registry's archive set
|
|
341
|
+
* (issue #2068). The Host's archived-session gate rejects the first step of a
|
|
342
|
+
* turn in an archived session before any model request is issued, so the
|
|
343
|
+
* run would settle as the opaque failure `agent turn ended without
|
|
344
|
+
* completing: blocked` — the fate of every scheduled run of a card whose
|
|
345
|
+
* conversation the user archived while cleaning the sidebar. Starting a fresh
|
|
346
|
+
* conversation is the only safe answer: archiving is a live user decision,
|
|
347
|
+
* and the board must not unarchive a conversation behind the user's back to
|
|
348
|
+
* keep reusing it.
|
|
349
|
+
* @param task - the task about to run.
|
|
350
|
+
* @param force - reuse without the card's own opt-in (a rework).
|
|
351
|
+
* @returns the reuse decision for this launch.
|
|
352
|
+
*/
|
|
353
|
+
private reuseDecision;
|
|
354
|
+
/**
|
|
355
|
+
* The archived conversation the reuse rule refused, when it refused one.
|
|
356
|
+
*
|
|
357
|
+
* Reuse skipping an archived conversation is otherwise invisible: the board
|
|
358
|
+
* simply opens a new one, and only the caller knows which outcome it produced.
|
|
359
|
+
* @param task - the task about to run.
|
|
360
|
+
* @param archived - the archive set read for this launch, when reported.
|
|
361
|
+
* @returns the newest settled session id when it is archived, else undefined.
|
|
362
|
+
*/
|
|
363
|
+
private archivedReuseTarget;
|
|
364
|
+
/**
|
|
365
|
+
* The Workspace registry's archive set, or undefined when this deployment's
|
|
366
|
+
* registry face cannot report one. An unreportable set is unknown evidence,
|
|
367
|
+
* never proof that nothing is archived: the rule then keeps its pre-archive
|
|
368
|
+
* behavior instead of inventing a refusal, because a registry face without
|
|
369
|
+
* the getter serves no archive action for the board to defend against.
|
|
370
|
+
*
|
|
371
|
+
* Read per launch rather than cached: archiving is a live user action, and an
|
|
372
|
+
* idle board no longer polls, so a set kept from an earlier pass could already
|
|
373
|
+
* claim a session that the user archived a moment ago.
|
|
374
|
+
* @returns the archived session ids, or undefined when unreportable.
|
|
375
|
+
*/
|
|
376
|
+
private archivedSessionIds;
|
|
328
377
|
/**
|
|
329
378
|
* The session a rework continues, or the refusal that says why it cannot.
|
|
330
379
|
*
|
package/lib/types/protocol.d.ts
CHANGED
|
@@ -82,6 +82,13 @@ export interface TaskBoardSnapshot {
|
|
|
82
82
|
* The board forwards them verbatim; it never interprets their shape.
|
|
83
83
|
*/
|
|
84
84
|
extensions?: Record<string, unknown>;
|
|
85
|
+
/**
|
|
86
|
+
* Monotonic counter bumped whenever any extension publishes, updates, or
|
|
87
|
+
* withdraws its summary. Carried on both full snapshots and SSE frames so
|
|
88
|
+
* browsers refetch `/state` when a provider publishes without touching the
|
|
89
|
+
* task ledger revision.
|
|
90
|
+
*/
|
|
91
|
+
extensionsRevision?: number;
|
|
85
92
|
/**
|
|
86
93
|
* The attachment limits this deployment enforces, so the browser can refuse
|
|
87
94
|
* an oversized selection before it uploads anything. The board's own caps
|
|
@@ -112,9 +119,10 @@ export interface TaskBoardSnapshot {
|
|
|
112
119
|
export interface TaskBoardModelCatalog {
|
|
113
120
|
catalog: ModelCatalogView;
|
|
114
121
|
}
|
|
115
|
-
/** SSE event frame: revision/scheduler/power
|
|
122
|
+
/** SSE event frame: revision/scheduler/power (plus extension summary revision), never the task list. */
|
|
116
123
|
export interface TaskBoardEventPayload {
|
|
117
124
|
revision: number;
|
|
125
|
+
extensionsRevision?: number;
|
|
118
126
|
scheduler: TaskBoardSchedulerSnapshot;
|
|
119
127
|
power: TaskBoardPowerSnapshot;
|
|
120
128
|
}
|
|
@@ -179,7 +187,16 @@ export type TaskBoardAction = {
|
|
|
179
187
|
taskId: string;
|
|
180
188
|
result: 'succeeded' | 'failed';
|
|
181
189
|
initiatedBy: string;
|
|
190
|
+
/** Success: stored as the execution summary. Failure: stored as the error text. */
|
|
182
191
|
summary?: string;
|
|
192
|
+
/** Id the execution record takes, so a handle returned at launch stays valid. */
|
|
193
|
+
executionId?: string;
|
|
194
|
+
/** Instant the outside run started (ms epoch); the record starts there instead of at settlement. */
|
|
195
|
+
startedAt?: number;
|
|
196
|
+
/** Failure only: stable machine-readable code. */
|
|
197
|
+
errorCode?: string;
|
|
198
|
+
/** Failure only: one line on whether and how to retry. */
|
|
199
|
+
retryHint?: string;
|
|
183
200
|
} | {
|
|
184
201
|
kind: 'set-schedule';
|
|
185
202
|
taskId: string;
|
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.21",
|
|
5
5
|
"icon": "icon.svg",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"main": "lib/index.js",
|
|
@@ -56,6 +56,16 @@ function ExecutionRow({ execution, timeZone, onOpen }: {
|
|
|
56
56
|
// spinner, and a named outside agent instead of the initiating session. The
|
|
57
57
|
// data attribute keeps the distinction machine-readable too.
|
|
58
58
|
const external = execution.external === true
|
|
59
|
+
// An external run is closed by the outside agent itself through
|
|
60
|
+
// record-external-outcome, which stores that agent's text on the record's
|
|
61
|
+
// error field. A SUCCEEDED one therefore carries a conclusion, not a failure:
|
|
62
|
+
// it prints verbatim, in the neutral secondary style the row's other metadata
|
|
63
|
+
// uses. A failed or cancelled one still reads as the error it is, and so does
|
|
64
|
+
// every text a Host-run execution recorded.
|
|
65
|
+
// New records keep that conclusion on `summary`; the error-field reading stays
|
|
66
|
+
// for the succeeded external records written before the two were separated.
|
|
67
|
+
const recordedConclusion = external && result === 'succeeded'
|
|
68
|
+
const conclusion = execution.summary?.text
|
|
59
69
|
return (
|
|
60
70
|
<li
|
|
61
71
|
className={css.executionRow}
|
|
@@ -94,9 +104,12 @@ function ExecutionRow({ execution, timeZone, onOpen }: {
|
|
|
94
104
|
{t('detail.execution.initiator', { session: execution.initiatedBy })}
|
|
95
105
|
</span>
|
|
96
106
|
)}
|
|
107
|
+
{conclusion !== undefined && (
|
|
108
|
+
<span className={css.executionTimes}>{conclusion}</span>
|
|
109
|
+
)}
|
|
97
110
|
{execution.error !== undefined && execution.error !== '' && (
|
|
98
|
-
<span className={css.executionError}>
|
|
99
|
-
{failureText(execution.error)}
|
|
111
|
+
<span className={recordedConclusion ? css.executionTimes : css.executionError}>
|
|
112
|
+
{recordedConclusion ? execution.error : failureText(execution.error)}
|
|
100
113
|
</span>
|
|
101
114
|
)}
|
|
102
115
|
</div>
|
|
@@ -2,8 +2,9 @@
|
|
|
2
2
|
* New-task modal: title + description + the prompt that execution will send.
|
|
3
3
|
* Creates through the Host and closes only after the Host confirms it.
|
|
4
4
|
*/
|
|
5
|
-
import { useEffect, useRef, useState } from 'react'
|
|
5
|
+
import { useCallback, useEffect, useRef, useState } from 'react'
|
|
6
6
|
import type { BoardController } from '../../core/controller.ts'
|
|
7
|
+
import { isTaskBoardExtensionPayload, type TaskBoardComposeDraftOptions, type TaskBoardExtensionPayload } from '../../core/extension.ts'
|
|
7
8
|
import { resolveCardTargets, type CardTargetSource } from '../../core/card-defaults.ts'
|
|
8
9
|
import { isValidCron, nextRunAtMs } from '../../core/schedule.ts'
|
|
9
10
|
import { parseFreezeRequest } from '../../core/freeze-snapshot.ts'
|
|
@@ -21,6 +22,7 @@ import { readParseModelPreference, writeParseModelPreference } from './parse-mod
|
|
|
21
22
|
import { inheritPresetLabel, presetChoiceRows, presetLabel } from './preset-label.ts'
|
|
22
23
|
import { ReasoningEffortField } from './ReasoningEffortField.tsx'
|
|
23
24
|
import { modelDisplayLabel, reconcileReasoningEffort } from './model-options.ts'
|
|
25
|
+
import { TaskBoardSeatBoundary, useTaskBoardSeats } from '../seats.tsx'
|
|
24
26
|
import css from '../board.module.css'
|
|
25
27
|
|
|
26
28
|
export interface NewTaskModalProps {
|
|
@@ -93,6 +95,40 @@ export function NewTaskModal({ controller, onClose, initialTask, defaultWorkspac
|
|
|
93
95
|
const [reasoningEffort, setReasoningEffort] = useState(seed.reasoningEffort)
|
|
94
96
|
const inheritedPermission = parentTask === undefined ? undefined : effectiveTaskPermission(parentTask)
|
|
95
97
|
const [reuseSession, setReuseSession] = useState(initialTask?.reuseSession ?? false)
|
|
98
|
+
// The providers' own create-time configuration. What each of them wants
|
|
99
|
+
// written into the new card's `integrations` is held in a ref, not in state:
|
|
100
|
+
// it is read once, when the card is created, so reporting a draft never
|
|
101
|
+
// re-renders this dialog and the provider's own state stays the one place
|
|
102
|
+
// that says what it currently shows.
|
|
103
|
+
const seats = useTaskBoardSeats()
|
|
104
|
+
const composeDrafts = useRef(new Map<string, TaskBoardExtensionPayload | undefined>())
|
|
105
|
+
const composeErrors = useRef(new Map<string, string>())
|
|
106
|
+
const [composeSummaries, setComposeSummaries] = useState<Record<string, string>>({})
|
|
107
|
+
const [composeError, setComposeError] = useState<string | undefined>(undefined)
|
|
108
|
+
const [submitAttempt, setSubmitAttempt] = useState(0)
|
|
109
|
+
// Stable for the life of the dialog: a provider keys its reporting effect on
|
|
110
|
+
// it, so it must not change identity on every render.
|
|
111
|
+
const contribute = useCallback((extensionId: string, payload: TaskBoardExtensionPayload | undefined, options?: TaskBoardComposeDraftOptions): void => {
|
|
112
|
+
composeDrafts.current.set(extensionId, payload)
|
|
113
|
+
const nextError = options?.error?.trim()
|
|
114
|
+
if (nextError !== undefined && nextError !== '') composeErrors.current.set(extensionId, nextError)
|
|
115
|
+
else composeErrors.current.delete(extensionId)
|
|
116
|
+
if (composeErrors.current.size === 0) {
|
|
117
|
+
setComposeError(prev => {
|
|
118
|
+
if (prev !== undefined) setError(current => (current === prev ? undefined : current))
|
|
119
|
+
return undefined
|
|
120
|
+
})
|
|
121
|
+
}
|
|
122
|
+
const nextSummary = options?.summary?.trim() ?? ''
|
|
123
|
+
setComposeSummaries(current => {
|
|
124
|
+
const prev = current[extensionId] ?? ''
|
|
125
|
+
if (prev === nextSummary) return current
|
|
126
|
+
const next = { ...current }
|
|
127
|
+
if (nextSummary === '') delete next[extensionId]
|
|
128
|
+
else next[extensionId] = nextSummary
|
|
129
|
+
return next
|
|
130
|
+
})
|
|
131
|
+
}, [])
|
|
96
132
|
const [scheduleEnabled, setScheduleEnabled] = useState(initialTask?.schedule?.enabled ?? false)
|
|
97
133
|
const [scheduleMode, setScheduleMode] = useState<ScheduleMode>(initialTask?.schedule?.mode ?? 'cron')
|
|
98
134
|
const [scheduleCron, setScheduleCron] = useState(initialTask?.schedule?.cron ?? '')
|
|
@@ -241,6 +277,27 @@ export function NewTaskModal({ controller, onClose, initialTask, defaultWorkspac
|
|
|
241
277
|
// Blank rows never reach the wire: the protocol rejects a tag with an
|
|
242
278
|
// empty name, and an empty list is expressed by omitting the field.
|
|
243
279
|
const tagList = cleanTags(tags)
|
|
280
|
+
setSubmitAttempt(count => count + 1)
|
|
281
|
+
const blockingError = [...composeErrors.current.values()][0]
|
|
282
|
+
if (blockingError !== undefined) {
|
|
283
|
+
setComposeError(blockingError)
|
|
284
|
+
setError(blockingError)
|
|
285
|
+
return
|
|
286
|
+
}
|
|
287
|
+
setComposeError(undefined)
|
|
288
|
+
// What the providers reported for THIS card, through the board's own payload
|
|
289
|
+
// gate: one unusable entry is dropped and named, never allowed to stop the
|
|
290
|
+
// create, and a dialog no provider feeds sends no `integrations` key at all
|
|
291
|
+
// so its create input is the one it always sent.
|
|
292
|
+
const integrations: Record<string, TaskBoardExtensionPayload> = {}
|
|
293
|
+
for (const [extensionId, draft] of composeDrafts.current) {
|
|
294
|
+
if (draft === undefined) continue
|
|
295
|
+
if (!isTaskBoardExtensionPayload(draft)) {
|
|
296
|
+
console.warn(`[dsh-task-board] dropped the ${extensionId} new-card draft: not an extension payload, or over the size limit`)
|
|
297
|
+
continue
|
|
298
|
+
}
|
|
299
|
+
integrations[extensionId] = draft
|
|
300
|
+
}
|
|
244
301
|
setPending(true)
|
|
245
302
|
// The staged files are uploaded NOW, because the card is being saved: the
|
|
246
303
|
// upload is what turns a local file into a stored object the card can
|
|
@@ -277,6 +334,7 @@ export function NewTaskModal({ controller, onClose, initialTask, defaultWorkspac
|
|
|
277
334
|
...(model === '' ? {} : { model }),
|
|
278
335
|
...(reasoningEffort === '' ? {} : { reasoningEffort }),
|
|
279
336
|
...(reuseSession ? { reuseSession: true } : {}),
|
|
337
|
+
...(Object.keys(integrations).length === 0 ? {} : { integrations }),
|
|
280
338
|
...(tagList.length > 0 ? { tags: tagList } : {}),
|
|
281
339
|
...(attachments.persisted.length + uploaded.length > 0
|
|
282
340
|
// The storage is content-addressed: the same content uploaded twice
|
|
@@ -387,7 +445,19 @@ export function NewTaskModal({ controller, onClose, initialTask, defaultWorkspac
|
|
|
387
445
|
: t('new.summary.attachmentCount', { count: String(attachmentCount) })
|
|
388
446
|
const tagCount = cleanTags(tags).length
|
|
389
447
|
const labelsSummary = tagCount === 0 ? t('new.summary.none') : t('new.summary.labelCount', { count: String(tagCount) })
|
|
390
|
-
const
|
|
448
|
+
const runSummaryParts = [
|
|
449
|
+
...(reuseSession ? [t('exec.reuseSession')] : []),
|
|
450
|
+
...Object.values(composeSummaries),
|
|
451
|
+
]
|
|
452
|
+
const runSummary = runSummaryParts.length > 0 ? runSummaryParts.join(' · ') : t('new.summary.none')
|
|
453
|
+
// What the registered providers contribute to this dialog, read once so the
|
|
454
|
+
// run region can tell a deployment without a provider (nothing to wrap) from
|
|
455
|
+
// one that registered rows here.
|
|
456
|
+
const composeSeat = seats.composeSection({
|
|
457
|
+
contribute,
|
|
458
|
+
...(initialTask?.integrations === undefined ? {} : { initialIntegrations: initialTask.integrations }),
|
|
459
|
+
submitAttempt,
|
|
460
|
+
})
|
|
391
461
|
const handoverSummary = freezeText.trim() !== '' || handoverText.trim() !== ''
|
|
392
462
|
? t('new.summary.filled')
|
|
393
463
|
: t('new.summary.none')
|
|
@@ -609,7 +679,13 @@ export function NewTaskModal({ controller, onClose, initialTask, defaultWorkspac
|
|
|
609
679
|
/>
|
|
610
680
|
</CollapsibleSection>
|
|
611
681
|
|
|
612
|
-
<CollapsibleSection
|
|
682
|
+
<CollapsibleSection
|
|
683
|
+
title={t('new.section.run')}
|
|
684
|
+
summary={runSummary}
|
|
685
|
+
defaultOpen={initialTask?.integrations !== undefined && Object.keys(initialTask.integrations).length > 0 && composeSeat !== null && composeSeat !== undefined}
|
|
686
|
+
forceOpen={composeError !== undefined}
|
|
687
|
+
keepMounted={composeSeat !== null && composeSeat !== undefined}
|
|
688
|
+
>
|
|
613
689
|
<label className={css.scheduleToggle}>
|
|
614
690
|
<input
|
|
615
691
|
type="checkbox"
|
|
@@ -619,6 +695,15 @@ export function NewTaskModal({ controller, onClose, initialTask, defaultWorkspac
|
|
|
619
695
|
<span>{t('exec.reuseSession')}</span>
|
|
620
696
|
</label>
|
|
621
697
|
<p className={css.detailText}>{t('exec.reuseSessionHint')}</p>
|
|
698
|
+
{/* A provider's own create-time configuration belongs in the region
|
|
699
|
+
that decides how this card runs, so its rows read after the run
|
|
700
|
+
switches instead of opening a region of the board's own. A page
|
|
701
|
+
whose providers register nothing renders nothing extra, and one
|
|
702
|
+
provider that throws while rendering is isolated here rather than
|
|
703
|
+
taking the dialog's other fields with it. */}
|
|
704
|
+
{composeSeat !== null && composeSeat !== undefined && (
|
|
705
|
+
<TaskBoardSeatBoundary>{composeSeat}</TaskBoardSeatBoundary>
|
|
706
|
+
)}
|
|
622
707
|
</CollapsibleSection>
|
|
623
708
|
|
|
624
709
|
<CollapsibleSection
|
|
@@ -988,8 +988,6 @@ export function TaskDetail({ controller, task, phase = 'open' }: { controller: B
|
|
|
988
988
|
<p className={css.detailMeta}>{t('detail.handover.bundledAt', { time: formatHostTimestamp(current.handover.bundledAt, timeZone) })}</p>
|
|
989
989
|
</section>
|
|
990
990
|
)}
|
|
991
|
-
|
|
992
|
-
{seats.detailSection({ task: current, dispatch })}
|
|
993
991
|
</div>
|
|
994
992
|
|
|
995
993
|
<div className={css.detailColumn} data-detail-column="execution">
|
|
@@ -1011,17 +1009,26 @@ export function TaskDetail({ controller, task, phase = 'open' }: { controller: B
|
|
|
1011
1009
|
blocks around the group keep the panel's 16px rhythm. */}
|
|
1012
1010
|
<div className={css.detailFolds}>
|
|
1013
1011
|
{!archived && (
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
/>
|
|
1021
|
-
<ScheduleSection controller={controller} task={current} pending={pending} />
|
|
1022
|
-
</>
|
|
1012
|
+
<ExecutionSettingsSection
|
|
1013
|
+
controller={controller}
|
|
1014
|
+
task={current}
|
|
1015
|
+
pending={pending}
|
|
1016
|
+
executionOptions={snapshot.executionOptions}
|
|
1017
|
+
/>
|
|
1023
1018
|
)}
|
|
1024
1019
|
|
|
1020
|
+
{/* The providers' own task-detail sections are the same decision
|
|
1021
|
+
the pickers above them make — where and how this card runs —
|
|
1022
|
+
so they close the settings block instead of trailing the
|
|
1023
|
+
card's content. The wrapper is the rhythm: a seat is a
|
|
1024
|
+
section, not a fold row, so it keeps the panel's 16px
|
|
1025
|
+
section pitch inside the run stack. */}
|
|
1026
|
+
<div className={css.detailSeat}>
|
|
1027
|
+
{seats.detailSection({ task: current, dispatch })}
|
|
1028
|
+
</div>
|
|
1029
|
+
|
|
1030
|
+
{!archived && <ScheduleSection controller={controller} task={current} pending={pending} />}
|
|
1031
|
+
|
|
1025
1032
|
<FoldSection title={t('detail.execution')} summary={historySummary}>
|
|
1026
1033
|
{current.executions.length === 0 ? (
|
|
1027
1034
|
<p className={css.detailText}>{t('detail.noExecution')}</p>
|
|
@@ -98,6 +98,7 @@ export function CollapsibleSection({
|
|
|
98
98
|
summary,
|
|
99
99
|
defaultOpen = false,
|
|
100
100
|
forceOpen = false,
|
|
101
|
+
keepMounted = false,
|
|
101
102
|
children,
|
|
102
103
|
}: {
|
|
103
104
|
title: string
|
|
@@ -107,12 +108,17 @@ export function CollapsibleSection({
|
|
|
107
108
|
defaultOpen?: boolean
|
|
108
109
|
/** Open regardless of the stored state: an error inside must stay visible. */
|
|
109
110
|
forceOpen?: boolean
|
|
111
|
+
/** Keep children mounted while collapsed so provider seats keep their local state. */
|
|
112
|
+
keepMounted?: boolean
|
|
110
113
|
children: ReactNode
|
|
111
114
|
}) {
|
|
112
115
|
const [open, setOpen] = useState(defaultOpen)
|
|
116
|
+
const [openedOnce, setOpenedOnce] = useState(defaultOpen || forceOpen)
|
|
113
117
|
const panelId = useId()
|
|
114
118
|
const expanded = forceOpen || open
|
|
119
|
+
if (expanded && !openedOnce) setOpenedOnce(true)
|
|
115
120
|
const presence = usePresence(expanded)
|
|
121
|
+
const rendered = presence.mounted || (keepMounted && openedOnce)
|
|
116
122
|
// The one-line preview is also the row's title, so the line that ellipsizes
|
|
117
123
|
// in the header stays readable in full (same rule as the panel's folds).
|
|
118
124
|
const fullLine = summary ?? ''
|
|
@@ -132,8 +138,13 @@ export function CollapsibleSection({
|
|
|
132
138
|
<span className={css.formSectionSummary}>{summary}</span>
|
|
133
139
|
)}
|
|
134
140
|
</button>
|
|
135
|
-
{
|
|
136
|
-
<div
|
|
141
|
+
{rendered && (
|
|
142
|
+
<div
|
|
143
|
+
className={css.formSectionBody}
|
|
144
|
+
id={panelId}
|
|
145
|
+
data-state={presence.mounted ? presence.phase : 'closed'}
|
|
146
|
+
hidden={!presence.mounted}
|
|
147
|
+
>
|
|
137
148
|
{children}
|
|
138
149
|
</div>
|
|
139
150
|
)}
|