@linxin666/dsh-client-ui-task-board 0.4.18 → 0.4.20
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 +2 -2
- package/README.zh.md +2 -2
- package/lib/client.js +179 -60
- package/lib/client.js.map +1 -1
- package/lib/index.js +492 -74
- 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 +135 -1
- package/lib/types/core/session-reuse.d.ts +46 -13
- package/lib/types/core/tasks.d.ts +2 -2
- package/lib/types/host/agent-tools.d.ts +7 -2
- package/lib/types/host/extension-registry.d.ts +30 -1
- package/lib/types/host-ledger.d.ts +86 -1
- package/lib/types/host-routes.d.ts +7 -1
- package/lib/types/host-runner.d.ts +20 -1
- package/lib/types/host-service.d.ts +59 -14
- package/lib/types/protocol.d.ts +9 -1
- package/package.json +26 -26
- package/src/client/board/ExecutionLog.tsx +9 -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/extension.ts +138 -1
- package/src/core/session-reuse.ts +58 -21
- package/src/core/tasks.ts +2 -2
- package/src/host/agent-tools.ts +8 -2
- package/src/host/extension-registry.ts +121 -2
- package/src/host-ledger.ts +252 -18
- package/src/host-routes.ts +30 -3
- package/src/host-runner.ts +44 -5
- package/src/host-service.ts +180 -37
- package/src/index.ts +28 -2
- package/src/protocol.ts +9 -1
|
@@ -37,7 +37,7 @@ export declare function ModalShell({ ariaLabel, title, error, pending, submitLab
|
|
|
37
37
|
* the same animation pair, and `usePresence` keeps it mounted through the exit
|
|
38
38
|
* leg so collapsing never snaps.
|
|
39
39
|
*/
|
|
40
|
-
export declare function CollapsibleSection({ title, summary, defaultOpen, forceOpen, children, }: {
|
|
40
|
+
export declare function CollapsibleSection({ title, summary, defaultOpen, forceOpen, keepMounted, children, }: {
|
|
41
41
|
title: string;
|
|
42
42
|
/** One-line value preview rendered only while the region is collapsed. */
|
|
43
43
|
summary?: string | undefined;
|
|
@@ -45,6 +45,8 @@ export declare function CollapsibleSection({ title, summary, defaultOpen, forceO
|
|
|
45
45
|
defaultOpen?: boolean;
|
|
46
46
|
/** Open regardless of the stored state: an error inside must stay visible. */
|
|
47
47
|
forceOpen?: boolean;
|
|
48
|
+
/** Keep children mounted while collapsed so provider seats keep their local state. */
|
|
49
|
+
keepMounted?: boolean;
|
|
48
50
|
children: ReactNode;
|
|
49
51
|
}): import("react").JSX.Element;
|
|
50
52
|
/** Title + description + prompt fields shared by the new and edit task forms. */
|
|
@@ -12,7 +12,7 @@ import type { Context as ClientContext } from '@deepseek-ai/cordis';
|
|
|
12
12
|
import type { ConfigForm, ConfigForms } from '@deepseek-ai/dsh-client-ui-settings/client';
|
|
13
13
|
import { type TaskBoardSettings } from './TaskBoardSettingsCard.tsx';
|
|
14
14
|
import { type TaskBoardKey } from './locales.ts';
|
|
15
|
-
import { type TaskBoardCardDecorationProps, type TaskBoardDetailSectionProps, type TaskBoardSettingsSectionProps } from '../core/extension.ts';
|
|
15
|
+
import { type TaskBoardCardDecorationProps, type TaskBoardComposeSectionProps, type TaskBoardDetailSectionProps, type TaskBoardSettingsSectionProps } from '../core/extension.ts';
|
|
16
16
|
/** Domain-owned description of one settings namespace a family card binds. */
|
|
17
17
|
export interface SettingsFormSpec<T> {
|
|
18
18
|
/** Settings namespace the card edits. */
|
|
@@ -69,6 +69,12 @@ declare module '@deepseek-ai/dsh-client-ui-slots' {
|
|
|
69
69
|
scope: 'root';
|
|
70
70
|
owner: TaskBoardCardDecorationProps;
|
|
71
71
|
};
|
|
72
|
+
/** Provider new-card section; the board declares and renders it in the create dialog. */
|
|
73
|
+
'task-board.compose.section': {
|
|
74
|
+
kind: 'list';
|
|
75
|
+
scope: 'root';
|
|
76
|
+
owner: TaskBoardComposeSectionProps;
|
|
77
|
+
};
|
|
72
78
|
}
|
|
73
79
|
}
|
|
74
80
|
/** Owner share of a plugin card (the section supplies nothing). */
|
|
@@ -31,7 +31,7 @@ export declare function TaskBoardPanelIcon({ size }: {
|
|
|
31
31
|
*/
|
|
32
32
|
export declare function TaskBoardPanel({ controller, renderSlot }: {
|
|
33
33
|
controller: BoardController;
|
|
34
|
-
/** Child-slot renderer the registration declares (detail
|
|
34
|
+
/** Child-slot renderer the registration declares (detail, card decoration, new-card section). */
|
|
35
35
|
renderSlot?: SlotRenderBinding;
|
|
36
36
|
}): ReactNode;
|
|
37
37
|
/**
|
|
@@ -1,10 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The board's child seats, threaded from the slot registration that declares
|
|
3
|
+
* them down to the components that consume them.
|
|
4
|
+
*
|
|
5
|
+
* The framework hands the declaring component a `renderSlot` binding; the board
|
|
6
|
+
* wraps that binding in a React context so a provider's contribution can render
|
|
7
|
+
* deep inside TaskDetail, the card, the settings card, or the create dialog
|
|
8
|
+
* without those components knowing which providers exist.
|
|
9
|
+
*
|
|
10
|
+
* @module dsh-task-board/client/seats
|
|
11
|
+
*/
|
|
12
|
+
import { Component } from 'react';
|
|
1
13
|
import type { ReactNode } from 'react';
|
|
2
|
-
import { type TaskBoardCardDecorationProps, type TaskBoardDetailSectionProps, type TaskBoardSettingsSectionProps } from '../core/extension.ts';
|
|
3
|
-
/** The
|
|
14
|
+
import { type TaskBoardCardDecorationProps, type TaskBoardComposeSectionProps, type TaskBoardDetailSectionProps, type TaskBoardSettingsSectionProps } from '../core/extension.ts';
|
|
15
|
+
/** The four provider seats, adapted to plain render functions. */
|
|
4
16
|
export interface TaskBoardSeats {
|
|
5
17
|
detailSection: (props: TaskBoardDetailSectionProps) => ReactNode;
|
|
6
18
|
settingsSection: (props: TaskBoardSettingsSectionProps) => ReactNode;
|
|
7
19
|
cardDecoration: (props: TaskBoardCardDecorationProps) => ReactNode;
|
|
20
|
+
composeSection: (props: TaskBoardComposeSectionProps) => ReactNode;
|
|
8
21
|
}
|
|
9
22
|
/** Nothing registered: every seat renders empty. */
|
|
10
23
|
export declare const EMPTY_TASK_BOARD_SEATS: TaskBoardSeats;
|
|
@@ -12,6 +25,27 @@ export declare const EMPTY_TASK_BOARD_SEATS: TaskBoardSeats;
|
|
|
12
25
|
export type SlotRenderBinding = (key: string, owner: Record<string, unknown>) => ReactNode;
|
|
13
26
|
/** Adapt one framework renderSlot binding to the board's seat interface. */
|
|
14
27
|
export declare function seatsFromRenderSlot(renderSlot: SlotRenderBinding | undefined): TaskBoardSeats;
|
|
28
|
+
/**
|
|
29
|
+
* Isolation for one seat whose providers render outside the framework's own
|
|
30
|
+
* per-entry boundary: a provider that throws while rendering contributes
|
|
31
|
+
* nothing here instead of taking the surface around the seat down with it.
|
|
32
|
+
* Nothing is rendered in that case — the seat is optional, so its absence is
|
|
33
|
+
* the honest state — and the failure is logged once for the provider's author.
|
|
34
|
+
*/
|
|
35
|
+
export declare class TaskBoardSeatBoundary extends Component<{
|
|
36
|
+
children: ReactNode;
|
|
37
|
+
}, {
|
|
38
|
+
failed: boolean;
|
|
39
|
+
}> {
|
|
40
|
+
state: {
|
|
41
|
+
failed: boolean;
|
|
42
|
+
};
|
|
43
|
+
static getDerivedStateFromError(): {
|
|
44
|
+
failed: boolean;
|
|
45
|
+
};
|
|
46
|
+
componentDidCatch(error: unknown): void;
|
|
47
|
+
render(): ReactNode;
|
|
48
|
+
}
|
|
15
49
|
/** Provider the board's registered components wrap their subtree in. */
|
|
16
50
|
export declare const TaskBoardSeatsProvider: import("react").Provider<TaskBoardSeats>;
|
|
17
51
|
/** Read the current seat set (empty when no board registration is above). */
|
|
@@ -111,6 +111,8 @@ export interface NumberConstraints {
|
|
|
111
111
|
integer?: boolean;
|
|
112
112
|
/** The accepted value must be at least this. */
|
|
113
113
|
min?: number;
|
|
114
|
+
/** The accepted value must be at most this. */
|
|
115
|
+
max?: number;
|
|
114
116
|
}
|
|
115
117
|
/** A whole- or decimal-number field. An empty draft clears the field; any other draft that is not a finite number within the constraints stays unwritten. */
|
|
116
118
|
export declare function numberField(field: string, constraints?: NumberConstraints): FieldSpec;
|
|
@@ -130,7 +130,7 @@ export interface ExecutionOptionsSnapshot {
|
|
|
130
130
|
* (revision/scheduler/power); a full snapshot also carries the deployment
|
|
131
131
|
* constants the UI reads (session default permission, subtask depth).
|
|
132
132
|
*/
|
|
133
|
-
export type HostMirror = Pick<TaskBoardSnapshot, 'revision' | 'scheduler' | 'power' | 'sessionDefaultPermission' | 'maxSubtaskDepth' | 'cardDefaults' | 'extensions' | 'attachmentLimits'>;
|
|
133
|
+
export type HostMirror = Pick<TaskBoardSnapshot, 'revision' | 'extensionsRevision' | 'scheduler' | 'power' | 'sessionDefaultPermission' | 'maxSubtaskDepth' | 'cardDefaults' | 'extensions' | 'attachmentLimits'>;
|
|
134
134
|
/** Immutable controller snapshot for UI subscriptions. */
|
|
135
135
|
export interface ControllerSnapshot {
|
|
136
136
|
tasks: readonly TaskRecord[];
|
|
@@ -28,6 +28,12 @@ export declare const TASK_BOARD_DETAIL_SECTION = "task-board.detail.section";
|
|
|
28
28
|
export declare const TASK_BOARD_SETTINGS_SECTION = "task-board.settings.section";
|
|
29
29
|
/** Child seat a provider registers its card decoration into. */
|
|
30
30
|
export declare const TASK_BOARD_CARD_DECORATION = "task-board.card.decoration";
|
|
31
|
+
/**
|
|
32
|
+
* Child seat a provider registers its new-card section into: its own
|
|
33
|
+
* create-time configuration, rendered inside the create dialog's execution
|
|
34
|
+
* settings, whose draft the board stores on the card it creates.
|
|
35
|
+
*/
|
|
36
|
+
export declare const TASK_BOARD_COMPOSE_SECTION = "task-board.compose.section";
|
|
31
37
|
/** Every child seat the board declares for extensions, in render order. */
|
|
32
38
|
export declare const TASK_BOARD_EXTENSION_SEATS: readonly string[];
|
|
33
39
|
/**
|
|
@@ -195,6 +201,76 @@ export interface TaskBoardSessionsFace {
|
|
|
195
201
|
*/
|
|
196
202
|
followUp(taskId: string, text: string): Promise<void>;
|
|
197
203
|
}
|
|
204
|
+
/**
|
|
205
|
+
* Why the board is opening a run. The four entries reach the launch path from
|
|
206
|
+
* different places and a provider may want to answer only some of them: the
|
|
207
|
+
* board's own run action ({@link 'manual'}), a settled card sent back to run
|
|
208
|
+
* again ({@link 'rerun'}), an armed schedule ({@link 'schedule'}), and the
|
|
209
|
+
* `task_board_run` model-visible tool ({@link 'tool'}).
|
|
210
|
+
*
|
|
211
|
+
* A rework arrives as `manual`: it is the same human entry point, opening a
|
|
212
|
+
* run in the card's own conversation rather than a fresh one.
|
|
213
|
+
*/
|
|
214
|
+
export type TaskBoardLaunchTrigger = 'manual' | 'rerun' | 'schedule' | 'tool';
|
|
215
|
+
/** Context of one launch the board is about to open. */
|
|
216
|
+
export interface TaskBoardLaunchContext {
|
|
217
|
+
/** Which entry asked for this run. */
|
|
218
|
+
trigger: TaskBoardLaunchTrigger;
|
|
219
|
+
}
|
|
220
|
+
/**
|
|
221
|
+
* What a launch handler decided for one run.
|
|
222
|
+
*
|
|
223
|
+
* `local` keeps the board's own execution and only adds context, so a provider
|
|
224
|
+
* that runs a card through an ordinary session (a session told to drive
|
|
225
|
+
* something else, for instance) reads exactly the launch the board would have
|
|
226
|
+
* made. `external` hands the whole run to the provider: the board opens no
|
|
227
|
+
* session and writes no execution record.
|
|
228
|
+
*/
|
|
229
|
+
export type TaskBoardLaunchDecision =
|
|
230
|
+
/**
|
|
231
|
+
* Run the card locally through the board's own session, with `promptPreamble`
|
|
232
|
+
* injected ahead of the card's prompt on the same path the board's tag
|
|
233
|
+
* prompts take. A blank preamble injects nothing.
|
|
234
|
+
*/
|
|
235
|
+
{
|
|
236
|
+
kind: 'local';
|
|
237
|
+
promptPreamble?: string;
|
|
238
|
+
}
|
|
239
|
+
/**
|
|
240
|
+
* The provider takes this run over. The board creates no session and records
|
|
241
|
+
* no execution; it only moves the card into the running column, which is
|
|
242
|
+
* already the board's own way of saying work is under way outside a Host-run
|
|
243
|
+
* session. The provider closes the card through the existing
|
|
244
|
+
* `record-external-outcome` action once its own run settles.
|
|
245
|
+
*/
|
|
246
|
+
| {
|
|
247
|
+
kind: 'external';
|
|
248
|
+
};
|
|
249
|
+
/**
|
|
250
|
+
* Decide whether one launch belongs to the provider, and how it runs.
|
|
251
|
+
* @param task - the card about to run.
|
|
252
|
+
* @param context - which entry asked for this run.
|
|
253
|
+
* @returns a decision, or undefined to leave the run to the board unchanged.
|
|
254
|
+
*/
|
|
255
|
+
export type TaskBoardLaunchHandler = (task: TaskRecord, context: TaskBoardLaunchContext) => TaskBoardLaunchDecision | undefined;
|
|
256
|
+
/**
|
|
257
|
+
* Launch interception: the seam through which a provider takes a run over.
|
|
258
|
+
*
|
|
259
|
+
* The board consults the registered handlers at its single launch gate — before
|
|
260
|
+
* any session exists and before any execution record is written — for every
|
|
261
|
+
* trigger. Handlers run in registration order and the first one that answers
|
|
262
|
+
* anything other than undefined decides that launch. A handler that throws is
|
|
263
|
+
* isolated and treated as undefined, so a broken provider costs one run's
|
|
264
|
+
* interception and never the launch itself.
|
|
265
|
+
*/
|
|
266
|
+
export interface TaskBoardLaunchFace {
|
|
267
|
+
/**
|
|
268
|
+
* Register one launch handler. The returned disposer unregisters it, and the
|
|
269
|
+
* handler is released with the extension's own stop, so a switched-off
|
|
270
|
+
* provider is never consulted.
|
|
271
|
+
*/
|
|
272
|
+
intercept(handler: TaskBoardLaunchHandler): () => void;
|
|
273
|
+
}
|
|
198
274
|
/** Storage face for one extension's own payload on a task. */
|
|
199
275
|
export interface TaskBoardIntegrationFace {
|
|
200
276
|
/** Read this extension's payload, or undefined when the task carries none. */
|
|
@@ -247,6 +323,14 @@ export interface TaskBoardExtensionHost {
|
|
|
247
323
|
* probes the face and keeps working against a board that serves none.
|
|
248
324
|
*/
|
|
249
325
|
sessions?: TaskBoardSessionsFace;
|
|
326
|
+
/**
|
|
327
|
+
* Launch interception: the provider decides, per run, whether the board's own
|
|
328
|
+
* session launches it or whether this provider takes the run over. Optional
|
|
329
|
+
* on the same terms as {@link TaskBoardExtensionHost.sessions} — the API
|
|
330
|
+
* version stays 1, so a provider probes the face before using it, and a board
|
|
331
|
+
* that serves no launch gate keeps launching every card itself.
|
|
332
|
+
*/
|
|
333
|
+
launch?: TaskBoardLaunchFace;
|
|
250
334
|
integration: TaskBoardIntegrationFace;
|
|
251
335
|
events: TaskBoardEventFace;
|
|
252
336
|
/**
|
|
@@ -280,6 +364,19 @@ export interface TaskBoardClientMirror {
|
|
|
280
364
|
tasks: readonly TaskRecord[];
|
|
281
365
|
/** Published extension summaries, keyed by extension id (opaque to the board). */
|
|
282
366
|
extensions: Readonly<Record<string, unknown>>;
|
|
367
|
+
/**
|
|
368
|
+
* Whether at least one authoritative Host snapshot has arrived in this page.
|
|
369
|
+
* Absent on older boards or test mirrors; false while `/bootstrap` is still
|
|
370
|
+
* in flight, so providers do not misread an initial empty `{}` as unmounted.
|
|
371
|
+
*/
|
|
372
|
+
hydrated?: boolean;
|
|
373
|
+
/** Local workspaces registered in the runtime, for provider workspace pickers. */
|
|
374
|
+
workspaces?: readonly {
|
|
375
|
+
workspaceId: string;
|
|
376
|
+
title: string;
|
|
377
|
+
}[];
|
|
378
|
+
/** Last Host transport refusal message (e.g. a refused extension action), when any. */
|
|
379
|
+
lastError?: string;
|
|
283
380
|
}
|
|
284
381
|
/** Whether a task should be shown on the board; false hides it. */
|
|
285
382
|
export type TaskBoardVisibilityPredicate = (task: TaskRecord) => boolean;
|
|
@@ -325,6 +422,38 @@ export interface TaskBoardSettingsSectionProps {
|
|
|
325
422
|
export interface TaskBoardCardDecorationProps {
|
|
326
423
|
task: TaskRecord;
|
|
327
424
|
}
|
|
425
|
+
/** Optional metadata a provider reports alongside its new-card draft. */
|
|
426
|
+
export interface TaskBoardComposeDraftOptions {
|
|
427
|
+
/** One-line label included in the collapsed Run Mode summary. */
|
|
428
|
+
summary?: string;
|
|
429
|
+
/**
|
|
430
|
+
* Validation blocker message: while non-empty, the create dialog refuses to
|
|
431
|
+
* submit or run locally and forces the Run Mode section open.
|
|
432
|
+
*/
|
|
433
|
+
error?: string;
|
|
434
|
+
}
|
|
435
|
+
/** Owner props of the new-card compose seat. */
|
|
436
|
+
export interface TaskBoardComposeSectionProps {
|
|
437
|
+
/**
|
|
438
|
+
* Report the draft this provider wants written into the new card's
|
|
439
|
+
* `integrations` under `extensionId` — that is, what the board stores when
|
|
440
|
+
* the create dialog is submitted. The id is the provider's own extension id,
|
|
441
|
+
* the same key its payload lives under on every other card; a later call for
|
|
442
|
+
* the same id replaces the earlier draft instead of merging with it, and
|
|
443
|
+
* `undefined` withdraws it, so a provider that clears its picker leaves no
|
|
444
|
+
* entry behind. The draft stands until the dialog submits or its provider
|
|
445
|
+
* replaces or withdraws it, because collapsing the region that holds the seat
|
|
446
|
+
* must never discard a choice already made. The board never interprets the
|
|
447
|
+
* payload: a draft that is not a plain JSON object or that exceeds
|
|
448
|
+
* {@link TASK_BOARD_PAYLOAD_LIMIT_BYTES} is dropped from the card being
|
|
449
|
+
* created and named in one warning, and the create itself still happens.
|
|
450
|
+
*/
|
|
451
|
+
contribute(extensionId: string, payload: TaskBoardExtensionPayload | undefined, options?: TaskBoardComposeDraftOptions): void;
|
|
452
|
+
/** Initial integrations of the source card when duplicating an existing card. */
|
|
453
|
+
initialIntegrations?: Readonly<Record<string, unknown>>;
|
|
454
|
+
/** Incremented each time the user submits the dialog, so providers can reveal untouched field errors. */
|
|
455
|
+
submitAttempt?: number;
|
|
456
|
+
}
|
|
328
457
|
/**
|
|
329
458
|
* Host-half service face published under {@link TASK_BOARD_SERVICE_NAME}. A
|
|
330
459
|
* provider package's host half resolves this from the shared cordis service
|
|
@@ -357,8 +486,13 @@ export interface TaskBoardHostFace {
|
|
|
357
486
|
* retries one envelope does not apply it twice. Refusals are the ledger's:
|
|
358
487
|
* they throw with the Host's own text, which is why this face adds no code
|
|
359
488
|
* table of its own.
|
|
489
|
+
*
|
|
490
|
+
* `trigger` says which entry asked for a run, when the caller knows better
|
|
491
|
+
* than the board's default: the `task_board_run` tool passes `tool` so a
|
|
492
|
+
* launch handler can tell an agent's run from a person's. Only a `run` action
|
|
493
|
+
* reads it — `rerun`, `rework` and the human run path are their own triggers.
|
|
360
494
|
*/
|
|
361
|
-
apply(requestId: string, action: TaskBoardAction, initiator?: string): TaskBoardSnapshot | Promise<TaskBoardSnapshot>;
|
|
495
|
+
apply(requestId: string, action: TaskBoardAction, initiator?: string, trigger?: TaskBoardLaunchTrigger): TaskBoardSnapshot | Promise<TaskBoardSnapshot>;
|
|
362
496
|
/**
|
|
363
497
|
* Follow the board's change notifications. The listener receives no payload —
|
|
364
498
|
* a consumer that needs the state reads {@link snapshot} — and the returned
|
|
@@ -4,27 +4,60 @@
|
|
|
4
4
|
* unit-testable without a gateway.
|
|
5
5
|
*/
|
|
6
6
|
import type { TaskRecord } from './tasks.ts';
|
|
7
|
+
/** Everything the reuse rule reads beyond the card's own execution history. */
|
|
8
|
+
export interface ReuseOptions {
|
|
9
|
+
/**
|
|
10
|
+
* Continue the settled session regardless of the card's own `reuseSession`
|
|
11
|
+
* opt-in. A rework is exactly that case: the reviewer read the previous run's
|
|
12
|
+
* session and sent it back. The force waives the opt-in, never the evidence.
|
|
13
|
+
*/
|
|
14
|
+
force?: boolean;
|
|
15
|
+
/**
|
|
16
|
+
* The Workspace registry's global archive set (issue #2068).
|
|
17
|
+
*
|
|
18
|
+
* A Session in that set can never run a turn: the Host's archived-session
|
|
19
|
+
* gate rejects its first step before any model request is issued, so a
|
|
20
|
+
* launch that prompts into one settles as the opaque failure `agent turn
|
|
21
|
+
* ended without completing: blocked`. A card that keeps one conversation may
|
|
22
|
+
* still lose it to a bulk archive of the sidebar, and every later scheduled
|
|
23
|
+
* run would fail there, so reuse has to step aside instead of dying.
|
|
24
|
+
*
|
|
25
|
+
* Absent means this deployment's registry face cannot report an archive set.
|
|
26
|
+
* That is unknown evidence, never proof that nothing is archived: the rule
|
|
27
|
+
* then keeps its pre-archive-set behavior instead of inventing a refusal,
|
|
28
|
+
* because a registry face without the getter serves no archive action for the
|
|
29
|
+
* board to defend against.
|
|
30
|
+
*/
|
|
31
|
+
archivedSessionIds?: ReadonlySet<string>;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* The session the newest settled execution ran in, or undefined when no
|
|
35
|
+
* execution carries one.
|
|
36
|
+
*
|
|
37
|
+
* The launch path calls the reuse rule after `startExecution` appended this
|
|
38
|
+
* run's own open record, so the array tail is always an unsettled row at that
|
|
39
|
+
* point and the scan has to skip it (issue #1587).
|
|
40
|
+
* @param task - the task whose history is read.
|
|
41
|
+
* @returns the newest settled session id, if any.
|
|
42
|
+
*/
|
|
43
|
+
export declare function newestSettledSessionId(task: TaskRecord): string | undefined;
|
|
7
44
|
/**
|
|
8
45
|
* Pick the session a new execution of this task may continue in, or undefined
|
|
9
46
|
* to mint a fresh conversation. Reuse requires ALL of:
|
|
10
|
-
* - the task opted in (`reuseSession === true`);
|
|
11
|
-
* - the task's newest
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
* - the roster is known and that session is present and idle.
|
|
47
|
+
* - the task opted in (`reuseSession === true`) unless the caller forces it;
|
|
48
|
+
* - the task's newest settled execution carries a session id (issue #1587);
|
|
49
|
+
* - the roster is known and that session is present and idle;
|
|
50
|
+
* - that session is not archived, when the deployment reports an archive set
|
|
51
|
+
* (issue #2068).
|
|
16
52
|
*
|
|
17
53
|
* An unknown roster (session/list unavailable) never reuses: minting a fresh
|
|
18
54
|
* conversation is always safe, prompting into a session we cannot see is not.
|
|
55
|
+
* An archived session is refused for the same reason — the Host will not run a
|
|
56
|
+
* turn in it, so continuing there can only fail the run that tried.
|
|
19
57
|
* @param task - the task about to run.
|
|
20
58
|
* @param idleSessionIds - ids the last roster saw as present and not running;
|
|
21
59
|
* undefined when that roster is unknown.
|
|
22
|
-
* @param options
|
|
23
|
-
* own `reuseSession` opt-in. A rework is exactly that case: the reviewer read
|
|
24
|
-
* the previous run's session and sent it back. Every condition above still
|
|
25
|
-
* applies — the force waives the opt-in, never the evidence.
|
|
60
|
+
* @param options - force and the archive set; see {@link ReuseOptions}.
|
|
26
61
|
* @returns the session id to continue in, or undefined for a fresh session.
|
|
27
62
|
*/
|
|
28
|
-
export declare function reusableSessionId(task: TaskRecord, idleSessionIds: ReadonlySet<string> | undefined, options?:
|
|
29
|
-
force?: boolean;
|
|
30
|
-
}): string | undefined;
|
|
63
|
+
export declare function reusableSessionId(task: TaskRecord, idleSessionIds: ReadonlySet<string> | undefined, options?: ReuseOptions): string | undefined;
|
|
@@ -381,8 +381,8 @@ export interface TaskRecord {
|
|
|
381
381
|
* Whether later executions continue in the previous execution's session
|
|
382
382
|
* (issue #1419) instead of minting a fresh conversation per run. Absent or
|
|
383
383
|
* false keeps the historical one-session-per-execution behavior; the reuse
|
|
384
|
-
* itself only happens when that session is idle
|
|
385
|
-
* {@link reusableSessionId}).
|
|
384
|
+
* itself only happens when that session is idle, still present, and not
|
|
385
|
+
* archived (issue #2068; see {@link reusableSessionId}).
|
|
386
386
|
*/
|
|
387
387
|
reuseSession?: boolean;
|
|
388
388
|
/**
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { type ToolDefinition } from '@deepseek-ai/dsh-tools';
|
|
2
2
|
import type { TaskBoardAction, TaskBoardSnapshot } from '../protocol.ts';
|
|
3
|
+
import type { TaskBoardLaunchTrigger } from '../core/extension.ts';
|
|
3
4
|
/**
|
|
4
5
|
* The narrow Host face the tools need. TaskBoardHostService satisfies it
|
|
5
6
|
* structurally, so tests and a future host can drive the same surface.
|
|
@@ -7,8 +8,12 @@ import type { TaskBoardAction, TaskBoardSnapshot } from '../protocol.ts';
|
|
|
7
8
|
export interface TaskBoardToolHost {
|
|
8
9
|
/** Current board snapshot (tasks + scheduler + power + deployment constants). */
|
|
9
10
|
snapshot(): TaskBoardSnapshot;
|
|
10
|
-
/**
|
|
11
|
-
|
|
11
|
+
/**
|
|
12
|
+
* Submit one confirmed Host action; returns the resulting snapshot. `trigger`
|
|
13
|
+
* names the entry that asked for a run when the tool knows it is the tool, so
|
|
14
|
+
* a provider's launch handler can tell an agent's run from a person's.
|
|
15
|
+
*/
|
|
16
|
+
apply(requestId: string, action: TaskBoardAction, initiator?: string, trigger?: TaskBoardLaunchTrigger): TaskBoardSnapshot | Promise<TaskBoardSnapshot>;
|
|
12
17
|
}
|
|
13
18
|
/** Registered tool names, in registration order. */
|
|
14
19
|
export declare const TASK_BOARD_TOOL_NAMES: readonly ["task_board_list", "task_board_get", "task_board_create", "task_board_update", "task_board_set_parent", "task_board_run", "task_board_manage", "task_board_schedule"];
|
|
@@ -12,7 +12,8 @@
|
|
|
12
12
|
import type { ToolDefinition } from '@deepseek-ai/dsh-tools';
|
|
13
13
|
import type { HostTaskLedger } from '../host-ledger.ts';
|
|
14
14
|
import type { TaskBoardAction, TaskBoardSnapshot } from '../protocol.ts';
|
|
15
|
-
import { type TaskBoardExecutionSettledEvent, type TaskBoardExtension, type TaskBoardExtensionActionRequest, type TaskBoardExtensionPayload, type TaskBoardStatusChangedEvent, type TaskBoardTaskDeletedEvent } from '../core/extension.ts';
|
|
15
|
+
import { type TaskBoardExecutionSettledEvent, type TaskBoardExtension, type TaskBoardExtensionActionRequest, type TaskBoardExtensionPayload, type TaskBoardLaunchContext, type TaskBoardLaunchDecision, type TaskBoardStatusChangedEvent, type TaskBoardTaskDeletedEvent } from '../core/extension.ts';
|
|
16
|
+
import { type TaskRecord } from '../core/tasks.ts';
|
|
16
17
|
/** Diagnosable refusal raised by the registry and the capability face. */
|
|
17
18
|
export declare class TaskBoardExtensionError extends Error {
|
|
18
19
|
readonly code: string;
|
|
@@ -52,6 +53,8 @@ export interface TaskBoardExtensionRegistryOptions {
|
|
|
52
53
|
rework?: TaskBoardReworkApplier;
|
|
53
54
|
/** Resolve the deployment's tool registry; absent loses the tool surface only. */
|
|
54
55
|
toolRegistry?: () => TaskBoardExtensionToolRegistry | undefined;
|
|
56
|
+
/** Notified whenever a provider publishes, changes, or withdraws its summary. */
|
|
57
|
+
onPublished?: () => void;
|
|
55
58
|
now?: () => number;
|
|
56
59
|
uuid?: () => string;
|
|
57
60
|
logger?: TaskBoardExtensionLogger;
|
|
@@ -66,10 +69,14 @@ export declare class TaskBoardExtensionRegistry {
|
|
|
66
69
|
private readonly uuid;
|
|
67
70
|
private readonly logger;
|
|
68
71
|
private toolResolver;
|
|
72
|
+
private readonly onPublished;
|
|
73
|
+
private publishedVersionCounter;
|
|
69
74
|
/** Board master switch (enabled config); providers start only while it is on. */
|
|
70
75
|
private boardEnabled;
|
|
71
76
|
private disposed;
|
|
72
77
|
constructor(options: TaskBoardExtensionRegistryOptions);
|
|
78
|
+
/** Monotonic revision of the published extension summaries map. */
|
|
79
|
+
get publishedRevision(): number;
|
|
73
80
|
/**
|
|
74
81
|
* Pin (or replace) the deployment's tool registry. A registry that appears
|
|
75
82
|
* after a provider started is picked up here, which is what keeps the tool
|
|
@@ -96,6 +103,22 @@ export declare class TaskBoardExtensionRegistry {
|
|
|
96
103
|
* unknown, currently gated off, or does not implement the action.
|
|
97
104
|
*/
|
|
98
105
|
handleAction(request: TaskBoardExtensionActionRequest): Promise<unknown>;
|
|
106
|
+
/**
|
|
107
|
+
* The board's single launch gate: ask every running provider whether this run
|
|
108
|
+
* is theirs.
|
|
109
|
+
*
|
|
110
|
+
* Consulted by the ledger at the one point every trigger passes — before a
|
|
111
|
+
* session exists and before an execution record is written — so the order
|
|
112
|
+
* here is the only ordering a provider can observe: registration order, first
|
|
113
|
+
* decision wins. A handler that throws is isolated and treated as "not mine",
|
|
114
|
+
* exactly as if it had answered undefined, because a provider's bug must cost
|
|
115
|
+
* its own interception and never the launch. Without a registered handler
|
|
116
|
+
* this answers nothing at all and the launch path is untouched.
|
|
117
|
+
* @param task - the card about to run.
|
|
118
|
+
* @param context - which entry asked for this run.
|
|
119
|
+
* @returns the first decision a running provider made, or undefined.
|
|
120
|
+
*/
|
|
121
|
+
interceptLaunch(task: TaskRecord, context: TaskBoardLaunchContext): TaskBoardLaunchDecision | undefined;
|
|
99
122
|
/** Published summaries of currently running providers, keyed by extension id. */
|
|
100
123
|
published(): Record<string, TaskBoardExtensionPayload>;
|
|
101
124
|
/** Fan a status change out to every running provider, isolated per callback. */
|
|
@@ -147,5 +170,11 @@ export declare class TaskBoardExtensionRegistry {
|
|
|
147
170
|
private linkedTasks;
|
|
148
171
|
private writeIntegration;
|
|
149
172
|
private publish;
|
|
173
|
+
/**
|
|
174
|
+
* Hold one launch handler for a running provider. The handler is dropped when
|
|
175
|
+
* the provider stops or is unregistered, so the disposer only has to cover the
|
|
176
|
+
* provider's own early withdrawal.
|
|
177
|
+
*/
|
|
178
|
+
private addLaunchHandler;
|
|
150
179
|
private registerTool;
|
|
151
180
|
}
|
|
@@ -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
|
}
|