@fish-under-sea/dsh-client-ui-task-board-fish 1.0.2 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/NOTICE +1 -1
- package/README.en.md +6 -4
- package/README.md +6 -4
- package/README.zh.md +6 -4
- package/icon.png +0 -0
- package/lib/client.js +4428 -1508
- package/lib/client.js.map +1 -1
- package/lib/index.js +2670 -496
- package/lib/types/client/CardDefaultPresetField.d.ts +35 -0
- package/lib/types/client/PluginSettingsCard.d.ts +130 -19
- package/lib/types/client/RangeBubble.d.ts +46 -0
- package/lib/types/client/SegmentGroup.d.ts +28 -0
- package/lib/types/client/TaskBoardSettingsCard.d.ts +63 -0
- package/lib/types/client/board/AttachmentField.d.ts +70 -0
- package/lib/types/client/board/ExecutionLog.d.ts +24 -0
- package/lib/types/client/board/ReasoningEffortField.d.ts +25 -0
- package/lib/types/client/board/TaskForm.d.ts +4 -0
- package/lib/types/client/board/VerificationReport.d.ts +2 -15
- package/lib/types/client/board/model-options.d.ts +87 -0
- package/lib/types/client/board/preset-label.d.ts +21 -0
- package/lib/types/client/board/preset-roster.d.ts +45 -0
- package/lib/types/client/board/source-group.d.ts +27 -0
- package/lib/types/client/body-mutations.d.ts +45 -0
- package/lib/types/client/host-api.d.ts +25 -0
- package/lib/types/client/locales.d.ts +87 -9
- package/lib/types/client/pending-verify.d.ts +47 -0
- package/lib/types/client/plugin-card-seat.d.ts +3 -1
- package/lib/types/client/service.d.ts +4 -1
- package/lib/types/client/settings-form.d.ts +73 -51
- package/lib/types/core/attachment.d.ts +132 -0
- package/lib/types/core/card-defaults.d.ts +78 -0
- package/lib/types/core/controller.d.ts +57 -8
- package/lib/types/core/execution-summary.d.ts +52 -0
- package/lib/types/core/extension.d.ts +116 -0
- package/lib/types/core/launch-width.d.ts +31 -0
- package/lib/types/core/reasoning-effort.d.ts +57 -0
- package/lib/types/core/session-reuse.d.ts +7 -1
- package/lib/types/core/spend-budget.d.ts +28 -0
- package/lib/types/core/subtask.d.ts +100 -37
- package/lib/types/core/tasks.d.ts +94 -10
- package/lib/types/core/use-cases/task-create.d.ts +10 -5
- package/lib/types/core/use-cases/task-tag.d.ts +36 -0
- package/lib/types/core/use-cases/task-update.d.ts +22 -1
- package/lib/types/core/wire-projection.d.ts +35 -0
- package/lib/types/core/workspace-target.d.ts +23 -3
- package/lib/types/host/attachments.d.ts +250 -0
- package/lib/types/host/extension-registry.d.ts +40 -0
- package/lib/types/host/launch-admission.d.ts +71 -0
- package/lib/types/host-ledger.d.ts +114 -47
- package/lib/types/host-routes.d.ts +63 -0
- package/lib/types/host-runner.d.ts +164 -18
- package/lib/types/host-service.d.ts +182 -46
- package/lib/types/host-spend.d.ts +52 -0
- package/lib/types/index.d.ts +173 -54
- package/lib/types/loopback.d.ts +41 -1
- package/lib/types/protocol.d.ts +52 -11
- package/lib/types/tool-surface.d.ts +1 -0
- package/locale/en.json +6 -0
- package/locale/zh.json +6 -0
- package/package.json +36 -29
- package/src/client/CardDefaultPresetField.tsx +101 -0
- package/src/client/PluginSettingsCard.tsx +385 -111
- package/src/client/RangeBubble.tsx +164 -0
- package/src/client/SegmentGroup.tsx +93 -0
- package/src/client/TaskBoardSettingsCard.tsx +332 -37
- package/src/client/board/AttachmentField.tsx +383 -0
- package/src/client/board/EditTaskModal.tsx +63 -0
- package/src/client/board/ExecutionLog.tsx +154 -0
- package/src/client/board/LinkSubtaskModal.tsx +1 -1
- package/src/client/board/NewTaskModal.tsx +154 -45
- package/src/client/board/ReasoningEffortField.tsx +50 -0
- package/src/client/board/TagManagerModal.tsx +151 -2
- package/src/client/board/TaskBoard.tsx +47 -10
- package/src/client/board/TaskCard.tsx +45 -23
- package/src/client/board/TaskDetail.tsx +468 -258
- package/src/client/board/TaskForm.tsx +19 -4
- package/src/client/board/VerificationReport.tsx +143 -104
- package/src/client/board/model-options.ts +208 -0
- package/src/client/board/preset-label.ts +32 -0
- package/src/client/board/preset-roster.ts +58 -0
- package/src/client/board/source-group.ts +94 -0
- package/src/client/board/task-markdown.module.css +11 -8
- package/src/client/board-settings.module.css +35 -7
- package/src/client/board.module.css +1044 -105
- package/src/client/body-mutations.ts +133 -0
- package/src/client/host-api.ts +70 -0
- package/src/client/index.ts +109 -95
- package/src/client/locales.ts +205 -48
- package/src/client/pending-verify.ts +90 -0
- package/src/client/plugin-card-seat.ts +8 -2
- package/src/client/service.ts +24 -0
- package/src/client/settings-card.module.css +466 -89
- package/src/client/settings-entry-form.ts +0 -1
- package/src/client/settings-form.ts +102 -60
- package/src/core/attachment.ts +287 -0
- package/src/core/card-defaults.ts +132 -0
- package/src/core/controller.ts +90 -11
- package/src/core/execution-summary.ts +96 -0
- package/src/core/extension.ts +120 -0
- package/src/core/launch-width.ts +38 -0
- package/src/core/reasoning-effort.ts +92 -0
- package/src/core/session-reuse.ts +7 -1
- package/src/core/spend-budget.ts +35 -0
- package/src/core/store.ts +19 -1
- package/src/core/subtask.ts +144 -68
- package/src/core/tasks.ts +117 -10
- package/src/core/use-cases/task-create.ts +27 -16
- package/src/core/use-cases/task-tag.ts +56 -0
- package/src/core/use-cases/task-update.ts +33 -5
- package/src/core/wire-projection.ts +81 -0
- package/src/core/workspace-target.ts +27 -3
- package/src/host/agent-tools.ts +33 -21
- package/src/host/attachments.ts +650 -0
- package/src/host/extension-registry.ts +150 -5
- package/src/host/launch-admission.ts +139 -0
- package/src/host-ledger.ts +248 -117
- package/src/host-routes.ts +233 -15
- package/src/host-runner.ts +395 -61
- package/src/host-service.ts +512 -139
- package/src/host-spend.ts +105 -0
- package/src/index.ts +312 -92
- package/src/loopback.ts +57 -1
- package/src/protocol.ts +83 -18
- package/src/tool-surface.ts +1 -0
- package/icon.svg +0 -3
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
// Generated by scripts/sync-shared.mjs from shared/client/body-mutations.ts. Do not edit this copy; edit the shared source and run "node scripts/sync-shared.mjs".
|
|
2
|
+
/**
|
|
3
|
+
* One `document.body` MutationObserver per page, shared by every family
|
|
4
|
+
* plugin bundle.
|
|
5
|
+
*
|
|
6
|
+
* Family plugins that inject at the DOM level must notice when the shell
|
|
7
|
+
* re-renders around their injected node: the aggregate shell's column shims
|
|
8
|
+
* and any plugin surface still extending the shell from outside the official
|
|
9
|
+
* slot seats. Each consumer used to install its OWN `MutationObserver` on
|
|
10
|
+
* `document.body` with
|
|
11
|
+
* `{ childList: true, subtree: true }`, so a page carrying N family plugins
|
|
12
|
+
* paid N native observers and N callback invocations for EVERY mutation batch
|
|
13
|
+
* the app produced — chat token streaming alone produces many per second, and
|
|
14
|
+
* the count grows with the number of installed plugins.
|
|
15
|
+
*
|
|
16
|
+
* This module keeps exactly ONE body observer per page. The registry lives on
|
|
17
|
+
* `globalThis` under a `Symbol.for` key, so the per-package generated copies
|
|
18
|
+
* of this file (scripts/sync-shared.mjs) and separately bundled plugins all
|
|
19
|
+
* reach the same hub at runtime instead of one hub per module instance.
|
|
20
|
+
* Record subscribers receive the mutations accumulated since the last flush.
|
|
21
|
+
* Consumers that only re-check their DOM use subscribeBodyInvalidations:
|
|
22
|
+
* when all subscribers use that path, the hub retains no mutation records
|
|
23
|
+
* (or detached subtrees) while a background page's animation frames pause.
|
|
24
|
+
* Both paths run at most once per frame. The last subscriber disconnects the
|
|
25
|
+
* observer, cancels the pending frame and releases its records.
|
|
26
|
+
*
|
|
27
|
+
* Failure policy: without a DOM or `MutationObserver` the subscription is a
|
|
28
|
+
* no-op disposer (the same silence the per-consumer observers had), and when
|
|
29
|
+
* `requestAnimationFrame` is unavailable the flush runs synchronously so a
|
|
30
|
+
* subscriber is never silently dropped. A throwing subscriber cannot stop the
|
|
31
|
+
* others.
|
|
32
|
+
*/
|
|
33
|
+
|
|
34
|
+
/** The page-wide hub: one observer plus its subscribers and pending records. */
|
|
35
|
+
interface BodyMutationHub {
|
|
36
|
+
observer: MutationObserver
|
|
37
|
+
subscribers: Set<(records: MutationRecord[]) => void>
|
|
38
|
+
pending: MutationRecord[]
|
|
39
|
+
scheduled: boolean
|
|
40
|
+
frame?: number
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/** Cross-bundle registry key; `Symbol.for` so every module copy agrees. */
|
|
44
|
+
const HUB_KEY = Symbol.for('dsh-web.body-mutation-hub')
|
|
45
|
+
const INVALIDATION_ONLY = Symbol.for('dsh-web.body-mutation-invalidation')
|
|
46
|
+
type Subscriber = ((records: MutationRecord[]) => void) & { [INVALIDATION_ONLY]?: true }
|
|
47
|
+
|
|
48
|
+
function needsRecords(subscribers: Set<(records: MutationRecord[]) => void>): boolean {
|
|
49
|
+
for (const listener of subscribers) {
|
|
50
|
+
if (!(listener as Subscriber)[INVALIDATION_ONLY]) return true
|
|
51
|
+
}
|
|
52
|
+
return false
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Subscribe to a coalesced DOM re-check without retaining mutation records.
|
|
57
|
+
* The marked wrapper also works with an older hub, which delivers records
|
|
58
|
+
* that it simply ignores until a page reload picks up the updated hub.
|
|
59
|
+
*/
|
|
60
|
+
export function subscribeBodyInvalidations(subscriber: () => void): () => void {
|
|
61
|
+
const listener: Subscriber = () => { subscriber() }
|
|
62
|
+
listener[INVALIDATION_ONLY] = true
|
|
63
|
+
return subscribeBodyMutations(listener)
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Subscribe to body-level childList mutations.
|
|
68
|
+
* @param subscriber - called at most once per animation frame with the records
|
|
69
|
+
* collected since the previous flush; must be safe to run repeatedly.
|
|
70
|
+
* @returns the disposer removing this subscriber (and the observer when it was
|
|
71
|
+
* the last one).
|
|
72
|
+
*/
|
|
73
|
+
export function subscribeBodyMutations(subscriber: (records: MutationRecord[]) => void): () => void {
|
|
74
|
+
if (typeof globalThis === 'undefined' || typeof document === 'undefined') return () => {}
|
|
75
|
+
if (typeof MutationObserver !== 'function') return () => {}
|
|
76
|
+
const registry = globalThis as unknown as Record<symbol, unknown>
|
|
77
|
+
let hub = registry[HUB_KEY] as BodyMutationHub | undefined
|
|
78
|
+
if (hub === undefined) {
|
|
79
|
+
const subscribers = new Set<(records: MutationRecord[]) => void>()
|
|
80
|
+
const created: BodyMutationHub = {
|
|
81
|
+
observer: undefined as unknown as MutationObserver,
|
|
82
|
+
subscribers,
|
|
83
|
+
pending: [],
|
|
84
|
+
scheduled: false,
|
|
85
|
+
}
|
|
86
|
+
const flush = (): void => {
|
|
87
|
+
created.frame = undefined
|
|
88
|
+
created.scheduled = false
|
|
89
|
+
const batch = created.pending
|
|
90
|
+
created.pending = []
|
|
91
|
+
for (const listener of [...subscribers]) {
|
|
92
|
+
if (!subscribers.has(listener)) continue
|
|
93
|
+
try {
|
|
94
|
+
listener(batch)
|
|
95
|
+
} catch {
|
|
96
|
+
// One subscriber must never break the others; the next flush retries it.
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
const schedule = (): void => {
|
|
101
|
+
if (created.scheduled) return
|
|
102
|
+
created.scheduled = true
|
|
103
|
+
if (typeof requestAnimationFrame === 'function') created.frame = requestAnimationFrame(flush)
|
|
104
|
+
else flush()
|
|
105
|
+
}
|
|
106
|
+
created.observer = new MutationObserver((records) => {
|
|
107
|
+
if (needsRecords(subscribers)) {
|
|
108
|
+
for (const record of records) created.pending.push(record)
|
|
109
|
+
}
|
|
110
|
+
schedule()
|
|
111
|
+
})
|
|
112
|
+
created.observer.observe(document.body ?? document.documentElement, { childList: true, subtree: true })
|
|
113
|
+
registry[HUB_KEY] = created
|
|
114
|
+
hub = created
|
|
115
|
+
}
|
|
116
|
+
const active = hub
|
|
117
|
+
active.subscribers.add(subscriber)
|
|
118
|
+
let subscribed = true
|
|
119
|
+
return () => {
|
|
120
|
+
if (!subscribed) return
|
|
121
|
+
subscribed = false
|
|
122
|
+
active.subscribers.delete(subscriber)
|
|
123
|
+
if (!needsRecords(active.subscribers)) active.pending = []
|
|
124
|
+
if (active.subscribers.size === 0 && registry[HUB_KEY] === active) {
|
|
125
|
+
active.observer.disconnect()
|
|
126
|
+
if (active.frame !== undefined && typeof cancelAnimationFrame === 'function') cancelAnimationFrame(active.frame)
|
|
127
|
+
active.frame = undefined
|
|
128
|
+
active.pending = []
|
|
129
|
+
active.scheduled = false
|
|
130
|
+
delete registry[HUB_KEY]
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}
|
package/src/client/host-api.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { degradedRowOf, ledgerOwnerPid } from '../core/degraded-reason.ts'
|
|
2
|
+
import { isTaskAttachment, type TaskAttachment, type TaskAttachmentKind } from '../core/attachment.ts'
|
|
2
3
|
import { TASK_BOARD_PACKAGE } from '../core/package-name.ts'
|
|
3
4
|
import type { TaskRecord } from '../core/tasks.ts'
|
|
4
5
|
import { t } from './locales.ts'
|
|
@@ -27,6 +28,8 @@ const IMPORT_MARKER = 'dsh.taskBoard.v2.hostImported'
|
|
|
27
28
|
const SOURCE_KEY = 'dsh.taskBoard.v2.sourceId'
|
|
28
29
|
const IMPORT_REQUEST_KEY = 'dsh.taskBoard.v2.importRequestId'
|
|
29
30
|
const REQUEST_TIMEOUT_MS = 15_000
|
|
31
|
+
/** An upload moves real bytes, so it gets a wider budget than a JSON call. */
|
|
32
|
+
const UPLOAD_TIMEOUT_MS = 120_000
|
|
30
33
|
/** Re-notify the panel at most this often while the event stream stays broken. */
|
|
31
34
|
const STREAM_ERROR_NOTIFY_MS = 15_000
|
|
32
35
|
/** Mirrors the Host's own parse budget; only used to phrase the timeout. */
|
|
@@ -196,6 +199,22 @@ export interface TaskBoardHostTransport {
|
|
|
196
199
|
subscribe(listener: (event?: TaskBoardEventPayload) => void): () => void
|
|
197
200
|
/** One-shot model parse of pasted text (issue #1540). */
|
|
198
201
|
parseDraft(request: TaskBoardParseRequest, signal?: AbortSignal): Promise<TaskBoardParseDraft>
|
|
202
|
+
/**
|
|
203
|
+
* Upload one file or image into the Host's attachment storage. Optional: a
|
|
204
|
+
* deployment that serves no attachment storage omits it, and the form then
|
|
205
|
+
* refuses to stage an attachment at all.
|
|
206
|
+
*/
|
|
207
|
+
uploadAttachment?(file: File, kind: TaskAttachmentKind): Promise<TaskAttachment>
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
/**
|
|
211
|
+
* The URL of one stored image. The board serves it only for an id a card of
|
|
212
|
+
* this board references, so the URL is useless on its own.
|
|
213
|
+
* @param attachmentId - the stored object's identifier.
|
|
214
|
+
* @returns the document-relative URL of the image.
|
|
215
|
+
*/
|
|
216
|
+
export function attachmentImageUrl(attachmentId: string): string {
|
|
217
|
+
return `${CLIENT_API_PREFIX}/attachments/image?id=${encodeURIComponent(attachmentId)}`
|
|
199
218
|
}
|
|
200
219
|
|
|
201
220
|
export class HttpTaskBoardHostTransport implements TaskBoardHostTransport {
|
|
@@ -305,6 +324,50 @@ export class HttpTaskBoardHostTransport implements TaskBoardHostTransport {
|
|
|
305
324
|
throw new HostApiError('rejected', t('new.aiParseFailed', { error: detail }), response.status)
|
|
306
325
|
}
|
|
307
326
|
|
|
327
|
+
/**
|
|
328
|
+
* Upload one attachment into the Host's attachment storage.
|
|
329
|
+
*
|
|
330
|
+
* The bytes travel as the raw request body: the Host measures the ACTUAL
|
|
331
|
+
* stream, publishes the object and answers with the host-computed metadata
|
|
332
|
+
* (size, type and digest) that the card will record.
|
|
333
|
+
* @param file - the picked file.
|
|
334
|
+
* @param kind - whether the file is stored as an image or verbatim.
|
|
335
|
+
* @returns the metadata the Host computed for the stored object.
|
|
336
|
+
*/
|
|
337
|
+
async uploadAttachment(file: File, kind: TaskAttachmentKind): Promise<TaskAttachment> {
|
|
338
|
+
const controller = new AbortController()
|
|
339
|
+
const timer = globalThis.setTimeout(() => { controller.abort() }, UPLOAD_TIMEOUT_MS)
|
|
340
|
+
try {
|
|
341
|
+
const query = new URLSearchParams({ kind, name: file.name, mediaType: file.type })
|
|
342
|
+
const response = await fetch(`${CLIENT_API_PREFIX}/attachments/upload?${query.toString()}`, {
|
|
343
|
+
method: 'POST',
|
|
344
|
+
headers: { 'content-type': 'application/octet-stream' },
|
|
345
|
+
body: file,
|
|
346
|
+
signal: controller.signal,
|
|
347
|
+
})
|
|
348
|
+
const text = await response.text()
|
|
349
|
+
let parsed: unknown
|
|
350
|
+
try {
|
|
351
|
+
parsed = JSON.parse(text)
|
|
352
|
+
} catch {
|
|
353
|
+
parsed = undefined
|
|
354
|
+
}
|
|
355
|
+
const record = parsed as { ok?: unknown; attachment?: unknown; error?: unknown } | undefined
|
|
356
|
+
if (response.ok) {
|
|
357
|
+
if (record !== undefined && isTaskAttachment(record.attachment)) return record.attachment
|
|
358
|
+
throw new HostApiError('unexpected', t('board.hostError.unexpected', { status: String(response.status) }), response.status)
|
|
359
|
+
}
|
|
360
|
+
const detail = typeof record?.error === 'string' && record.error !== '' ? record.error : String(response.status)
|
|
361
|
+
throw new HostApiError('rejected', detail, response.status)
|
|
362
|
+
} catch (error) {
|
|
363
|
+
if (error instanceof HostApiError) throw error
|
|
364
|
+
if (controller.signal.aborted) throw new HostApiError('timeout', t('board.hostError.timeout', { seconds: String(UPLOAD_TIMEOUT_MS / 1000) }))
|
|
365
|
+
throw new HostApiError('unreachable', t('board.hostError.unreachable'))
|
|
366
|
+
} finally {
|
|
367
|
+
globalThis.clearTimeout(timer)
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
|
|
308
371
|
subscribe(listener: (event?: TaskBoardEventPayload) => void): () => void {
|
|
309
372
|
const events = new EventSource(`${CLIENT_API_PREFIX}/events`)
|
|
310
373
|
let lastStreamErrorNotify = 0
|
|
@@ -317,6 +380,13 @@ export class HttpTaskBoardHostTransport implements TaskBoardHostTransport {
|
|
|
317
380
|
listener()
|
|
318
381
|
}
|
|
319
382
|
}
|
|
383
|
+
// Every connect and every reconnect is a resynchronization point: the route
|
|
384
|
+
// pushes one frame when it accepts a stream, but a frame whose revision
|
|
385
|
+
// already matches the mirrored one is what the panel applies without a
|
|
386
|
+
// read, so the connection itself asks for the snapshot. Without this, a
|
|
387
|
+
// stream that came back after an outage would only catch up if some later
|
|
388
|
+
// Host write happened to move the revision past the mirror.
|
|
389
|
+
events.onopen = (): void => { listener() }
|
|
320
390
|
// A stream that cannot connect at all (unmounted route, refused socket) is
|
|
321
391
|
// how a Host half that never mounted looks from the browser; nudge the
|
|
322
392
|
// panel into one state read so the failure becomes visible (#1528).
|
package/src/client/index.ts
CHANGED
|
@@ -24,14 +24,18 @@ import type {} from '@deepseek-ai/dsh-client-ui-settings/client'
|
|
|
24
24
|
// Type-only: pulls the workspace plugin's Context merge (ctx.uiWorkspace), the
|
|
25
25
|
// multi-instance navigation face that replaced ISessions.open().
|
|
26
26
|
import type {} from '@deepseek-ai/dsh-client-ui-workspace/client'
|
|
27
|
-
import { BoardController, TASK_BOARD_PANEL_ID } from '../core/controller.ts'
|
|
27
|
+
import { BoardController, TASK_BOARD_PANEL_ID, type ExecutionModelOption, type ExecutionPresetOption } from '../core/controller.ts'
|
|
28
|
+
import { modelOptionsFromCatalog, modelOptionsFromDiscoveredModels } from './board/model-options.ts'
|
|
29
|
+
import { presetOptionsFromRoster, readPresetRoster, type PresetRemote } from './board/preset-roster.ts'
|
|
28
30
|
import { mainViewSessionId } from './main-session.ts'
|
|
29
31
|
import { LocalStorageTaskStore } from '../core/store.ts'
|
|
32
|
+
import { hasOpenExecution } from '../core/tasks.ts'
|
|
30
33
|
import { claimTaskboardApply, releaseTaskboardApply } from './apply-guard.ts'
|
|
31
34
|
import { registerTaskBoardPanel } from './native-panel.tsx'
|
|
32
35
|
import { TaskBoardSettingsCard, TaskBoardSettingsCardController, type TaskBoardSettings } from './TaskBoardSettingsCard.tsx'
|
|
33
36
|
import { en, zh, setRuntimeTranslate, type TaskBoardKey } from './locales.ts'
|
|
34
37
|
import { HttpTaskBoardHostTransport } from './host-api.ts'
|
|
38
|
+
import { startPendingVerification } from './pending-verify.ts'
|
|
35
39
|
import { installPluginCard } from './plugin-card-seat.ts'
|
|
36
40
|
import { createServedEntryForm } from './settings-entry-form.ts'
|
|
37
41
|
import { TaskBoardClientService } from './service.ts'
|
|
@@ -139,39 +143,11 @@ declare module '@deepseek-ai/cordis' {
|
|
|
139
143
|
*/
|
|
140
144
|
export const inject = ['slots', 'sessions', 'workspaces', 'connection', 'configForms', 'locale', 'remote', 'remote.session', 'uiWorkspace', 'layout']
|
|
141
145
|
|
|
142
|
-
/** The generated Remote namespace the mode picker reads its roster from. */
|
|
143
|
-
type PresetRemote = ClientRemote['agentPresets']
|
|
144
|
-
|
|
145
|
-
/** One agent-preset row the mode picker consumes. */
|
|
146
|
-
interface PresetRosterRow {
|
|
147
|
-
id: string
|
|
148
|
-
name?: string
|
|
149
|
-
description?: string
|
|
150
|
-
/** Why this preset cannot compose a session; absent when it can. */
|
|
151
|
-
broken?: string
|
|
152
|
-
isDefault: boolean
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
/**
|
|
156
|
-
* Read the agent-preset roster through the generated api-remotes face. The
|
|
157
|
-
* caller passes the namespace resolved inside its scoped inject, so a host
|
|
158
|
-
* that serves no such namespace never reaches here; a host that serves it
|
|
159
|
-
* answers `ok: false` instead, which leaves the picker options untouched.
|
|
160
|
-
* @param remote - the `remote.agentPresets` namespace.
|
|
161
|
-
* @returns the roster, or a failed read the caller ignores.
|
|
162
|
-
*/
|
|
163
|
-
async function readPresetRoster(remote: PresetRemote): Promise<{ ok: boolean; presets: readonly PresetRosterRow[] }> {
|
|
164
|
-
const response = await remote.list()
|
|
165
|
-
if (!response.ok) return { ok: false, presets: [] }
|
|
166
|
-
return { ok: true, presets: response.value.presets }
|
|
167
|
-
}
|
|
168
|
-
|
|
169
146
|
/**
|
|
170
147
|
* Mount the task board.
|
|
171
148
|
* @param ctx - client root context (services: sessions, workspaces).
|
|
172
149
|
*/
|
|
173
150
|
export function apply(ctx: ClientContext): void {
|
|
174
|
-
|
|
175
151
|
// A duplicated client injection (module factory executed twice in one page
|
|
176
152
|
// lifetime) would otherwise mount a second sidebar entry and board view.
|
|
177
153
|
// First application wins; later calls become no-ops (see apply-guard.ts).
|
|
@@ -225,6 +201,48 @@ export function apply(ctx: ClientContext): void {
|
|
|
225
201
|
})
|
|
226
202
|
ctx.effect(() => () => { settingsCard.dispose() }, 'task-board: settings card')
|
|
227
203
|
|
|
204
|
+
// The agent-preset roster is a runtime fact of the deployment, not ledger
|
|
205
|
+
// state, and TWO surfaces read it: the board's mode pickers and the settings
|
|
206
|
+
// card's new-card-defaults topic. It is wired here, outside the board view,
|
|
207
|
+
// because the settings card stays reachable while the board itself is
|
|
208
|
+
// disabled — that is where it is switched back on — and its default-preset
|
|
209
|
+
// field must not lose the roster with the view. The namespace mounts with the
|
|
210
|
+
// official api-remotes assembly, which the page applies beside this entry: at
|
|
211
|
+
// mount time it is usually still absent, and reading it through
|
|
212
|
+
// `remote.agentPresets` before it lands throws ("cannot get property ...
|
|
213
|
+
// without inject"), so a one-shot probe would leave both pickers with nothing
|
|
214
|
+
// but "inherit" for the page lifetime. A hard inject is no better — it would
|
|
215
|
+
// pend the whole plugin on a deployment that never mounts the namespace. The
|
|
216
|
+
// scoped inject runs the feed exactly when the namespace exists and re-runs it
|
|
217
|
+
// if the namespace is replaced; the reconnect read inside covers a deployment
|
|
218
|
+
// change behind the same namespace.
|
|
219
|
+
let presetRoster: readonly ExecutionPresetOption[] | undefined
|
|
220
|
+
let liveController: BoardController | undefined
|
|
221
|
+
const pushPresetOptions = async (presetRemote: PresetRemote): Promise<void> => {
|
|
222
|
+
try {
|
|
223
|
+
const roster = await readPresetRoster(presetRemote)
|
|
224
|
+
if (!roster.ok) return
|
|
225
|
+
const presets = presetOptionsFromRoster(roster.presets)
|
|
226
|
+
presetRoster = presets
|
|
227
|
+
settingsCard.setPresetRoster(presets)
|
|
228
|
+
liveController?.setExecutionOptions({ presets })
|
|
229
|
+
} catch (error) {
|
|
230
|
+
// A failed roster read leaves the previous options in place: the pickers
|
|
231
|
+
// stay usable, the default-preset field keeps the inherit choice alone,
|
|
232
|
+
// and the next reconnect retries the read.
|
|
233
|
+
console.error('[dsh-task-board] agent preset roster read failed', error)
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
const presetRosterFeed = ctx.inject(['remote.agentPresets'], (inner) => {
|
|
237
|
+
const presetRemote = inner.get('remote.agentPresets') as PresetRemote | undefined
|
|
238
|
+
if (presetRemote === undefined) return
|
|
239
|
+
void pushPresetOptions(presetRemote)
|
|
240
|
+
// Subscribed inside the injected scope, so a namespace that goes away takes
|
|
241
|
+
// its listener with it instead of leaving one per remount.
|
|
242
|
+
return inner.on('connection/reset', () => { void pushPresetOptions(presetRemote) })
|
|
243
|
+
})
|
|
244
|
+
ctx.effect(() => () => { void presetRosterFeed.dispose() }, 'task-board: agent preset roster')
|
|
245
|
+
|
|
228
246
|
// The sidebar entry and board view mount once the settings form settles;
|
|
229
247
|
// while the form is still loading, the composition default is unknown, so
|
|
230
248
|
// nothing mounts yet. Only an unavailable form (no settings surface served)
|
|
@@ -271,12 +289,44 @@ export function apply(ctx: ClientContext): void {
|
|
|
271
289
|
clientService.attach(controller)
|
|
272
290
|
|
|
273
291
|
const disposers: Array<() => void> = []
|
|
292
|
+
// The board follows the live controller for the roster feed wired above,
|
|
293
|
+
// which serves the settings card whether or not the view is mounted.
|
|
294
|
+
liveController = controller
|
|
295
|
+
if (presetRoster !== undefined) controller.setExecutionOptions({ presets: presetRoster })
|
|
296
|
+
// While the mirror shows work in flight it verifies that state itself: the
|
|
297
|
+
// pushed frame is unverifiable from the browser (a stream can stay open and
|
|
298
|
+
// silent), and a settled card would otherwise keep rendering as running for
|
|
299
|
+
// as long as the tab stays open. Nothing is read once nothing is in flight.
|
|
300
|
+
disposers.push(startPendingVerification({
|
|
301
|
+
pending: () => controller.getSnapshot().tasks.some(hasOpenExecution),
|
|
302
|
+
refresh: () => { controller.refreshHostState() },
|
|
303
|
+
subscribe: listener => controller.subscribe(listener),
|
|
304
|
+
}))
|
|
305
|
+
|
|
306
|
+
// The new-card defaults are written through the very settings form this
|
|
307
|
+
// plugin binds (that is the card's save), and the Host republishes its
|
|
308
|
+
// snapshot on that write. Its SSE frame carries the value as of BEFORE the
|
|
309
|
+
// write, though, so a mirror that only followed frames would hand the create
|
|
310
|
+
// dialog the previous defaults for the rest of the page session — the
|
|
311
|
+
// "configure a default, create a card, get nothing" report. Follow the form
|
|
312
|
+
// instead: when the four defaults it holds change, re-read the authoritative
|
|
313
|
+
// snapshot. The signature keeps one write to one GET (the form announces a
|
|
314
|
+
// settled document more than once) and keeps an unrelated settings write, or
|
|
315
|
+
// any board action, from pulling the ledger again.
|
|
316
|
+
let followedDefaults = cardDefaultSignature(settingsForm.getSnapshot().value)
|
|
317
|
+
disposers.push(settingsForm.subscribe(() => {
|
|
318
|
+
const next = cardDefaultSignature(settingsForm.getSnapshot().value)
|
|
319
|
+
if (next === followedDefaults) return
|
|
320
|
+
followedDefaults = next
|
|
321
|
+
controller.refreshHostState()
|
|
322
|
+
}))
|
|
274
323
|
|
|
275
324
|
// Execution-target option feeds: the workspace list drives the workspace
|
|
276
325
|
// picker, and the agent-preset roster drives the mode picker. Both are
|
|
277
326
|
// runtime facts (not ledger state), so the wiring pushes them into the
|
|
278
|
-
// controller on change; the preset roster
|
|
279
|
-
//
|
|
327
|
+
// controller on change; the preset roster feed itself lives beside the
|
|
328
|
+
// settings card (see apply) because that card's new-card-defaults topic
|
|
329
|
+
// reads the same roster while this view may not be mounted at all.
|
|
280
330
|
const pushWorkspaceOptions = (): void => {
|
|
281
331
|
const snapshot = workspaces.list.getSnapshot()
|
|
282
332
|
controller.setExecutionOptions({
|
|
@@ -295,47 +345,9 @@ export function apply(ctx: ClientContext): void {
|
|
|
295
345
|
const created = await workspaces.create({ path })
|
|
296
346
|
return { workspaceId: created.workspaceId }
|
|
297
347
|
})
|
|
298
|
-
const pushPresetOptions = async (presetRemote: PresetRemote): Promise<void> => {
|
|
299
|
-
try {
|
|
300
|
-
const roster = await readPresetRoster(presetRemote)
|
|
301
|
-
if (!roster.ok) return
|
|
302
|
-
controller.setExecutionOptions({
|
|
303
|
-
presets: roster.presets.map(preset => ({
|
|
304
|
-
id: preset.id,
|
|
305
|
-
name: preset.name,
|
|
306
|
-
description: preset.description,
|
|
307
|
-
broken: preset.broken,
|
|
308
|
-
isDefault: preset.isDefault,
|
|
309
|
-
})),
|
|
310
|
-
})
|
|
311
|
-
} catch (error) {
|
|
312
|
-
// A failed roster read leaves the previous options in place; the
|
|
313
|
-
// picker stays usable and the next reconnect retries the read.
|
|
314
|
-
console.error('[dsh-task-board] agent preset roster read failed', error)
|
|
315
|
-
}
|
|
316
|
-
}
|
|
317
|
-
// The roster namespace mounts with the official api-remotes assembly,
|
|
318
|
-
// which the page applies beside this entry: at mount time the namespace is
|
|
319
|
-
// usually still absent, and reading it through `remote.agentPresets`
|
|
320
|
-
// before it lands throws ("cannot get property ... without inject"), so a
|
|
321
|
-
// one-shot probe leaves the mode picker with nothing but "inherit" for the
|
|
322
|
-
// page lifetime. A hard inject is no better — it would pend the whole
|
|
323
|
-
// board on a deployment that never mounts the namespace. The scoped inject
|
|
324
|
-
// runs the feed exactly when the namespace exists and re-runs it if the
|
|
325
|
-
// namespace is replaced; the reconnect read inside covers a deployment
|
|
326
|
-
// change behind the same namespace.
|
|
327
|
-
const presetRosterFeed = ctx.inject(['remote.agentPresets'], (inner) => {
|
|
328
|
-
const presetRemote = inner.get('remote.agentPresets') as PresetRemote | undefined
|
|
329
|
-
if (presetRemote === undefined) return
|
|
330
|
-
void pushPresetOptions(presetRemote)
|
|
331
|
-
// Subscribed inside the injected scope, so a namespace that goes away
|
|
332
|
-
// takes its listener with it instead of leaving one per remount.
|
|
333
|
-
return inner.on('connection/reset', () => { void pushPresetOptions(presetRemote) })
|
|
334
|
-
})
|
|
335
|
-
disposers.push(() => { void presetRosterFeed.dispose() })
|
|
336
348
|
const pushModelOptions = async (): Promise<void> => {
|
|
337
349
|
try {
|
|
338
|
-
let models:
|
|
350
|
+
let models: ExecutionModelOption[] = []
|
|
339
351
|
let sessionRemote: ClientRemote['session'] | undefined
|
|
340
352
|
try {
|
|
341
353
|
sessionRemote = (remote as Partial<ClientRemote>).session
|
|
@@ -344,15 +356,7 @@ export function apply(ctx: ClientContext): void {
|
|
|
344
356
|
}
|
|
345
357
|
if (typeof sessionRemote?.modelCatalog === 'function') {
|
|
346
358
|
const res = await sessionRemote.modelCatalog()
|
|
347
|
-
if (res.ok
|
|
348
|
-
for (const g of res.value.groups) {
|
|
349
|
-
const provider = (g as { id?: string; provider?: string }).id ?? (g as { id?: string; provider?: string }).provider
|
|
350
|
-
for (const m of g.models ?? []) {
|
|
351
|
-
const qualifiedId = provider ? `${provider}/${m.id}` : m.id
|
|
352
|
-
models.push({ id: qualifiedId, name: m.name ?? m.id, provider })
|
|
353
|
-
}
|
|
354
|
-
}
|
|
355
|
-
}
|
|
359
|
+
if (res.ok) models = modelOptionsFromCatalog(res.value)
|
|
356
360
|
}
|
|
357
361
|
if (models.length === 0) {
|
|
358
362
|
const conn = ctx.get('connection') as {
|
|
@@ -364,11 +368,8 @@ export function apply(ctx: ClientContext): void {
|
|
|
364
368
|
} | undefined
|
|
365
369
|
if (conn?.api) {
|
|
366
370
|
if (typeof conn.api.llm?.discoverModels === 'function') {
|
|
367
|
-
const res = await conn.api.llm.discoverModels() as { result?: { value?: { models?:
|
|
368
|
-
|
|
369
|
-
if (Array.isArray(list)) {
|
|
370
|
-
models = list.map(m => ({ id: m.id, name: m.name }))
|
|
371
|
-
}
|
|
371
|
+
const res = await conn.api.llm.discoverModels() as { result?: { value?: { models?: unknown } } }
|
|
372
|
+
models = modelOptionsFromDiscoveredModels(res?.result?.value?.models)
|
|
372
373
|
}
|
|
373
374
|
const catalogFn = typeof conn.api.session?.modelCatalog === 'function'
|
|
374
375
|
? conn.api.session.modelCatalog
|
|
@@ -376,17 +377,8 @@ export function apply(ctx: ClientContext): void {
|
|
|
376
377
|
? conn.api.sessions.modelCatalog
|
|
377
378
|
: undefined
|
|
378
379
|
if (models.length === 0 && catalogFn !== undefined) {
|
|
379
|
-
const res = await catalogFn() as { result?: { value?:
|
|
380
|
-
|
|
381
|
-
if (Array.isArray(groups)) {
|
|
382
|
-
for (const g of groups) {
|
|
383
|
-
const provider = g.id ?? g.provider
|
|
384
|
-
for (const m of g.models ?? []) {
|
|
385
|
-
const qualifiedId = provider ? `${provider}/${m.id}` : m.id
|
|
386
|
-
models.push({ id: qualifiedId, name: m.name ?? m.id, provider })
|
|
387
|
-
}
|
|
388
|
-
}
|
|
389
|
-
}
|
|
380
|
+
const res = await catalogFn() as { result?: { value?: unknown } }
|
|
381
|
+
models = modelOptionsFromCatalog(res?.result?.value)
|
|
390
382
|
}
|
|
391
383
|
}
|
|
392
384
|
}
|
|
@@ -423,6 +415,7 @@ export function apply(ctx: ClientContext): void {
|
|
|
423
415
|
for (const dispose of disposers.splice(0)) dispose()
|
|
424
416
|
clientService.detach()
|
|
425
417
|
controller.dispose()
|
|
418
|
+
liveController = undefined
|
|
426
419
|
uiDisposer = undefined
|
|
427
420
|
}
|
|
428
421
|
}
|
|
@@ -476,6 +469,27 @@ export function bindSettingsForm(ctx: ClientContext): ConfigForm<TaskBoardSettin
|
|
|
476
469
|
})
|
|
477
470
|
}
|
|
478
471
|
|
|
472
|
+
/**
|
|
473
|
+
* The four new-card defaults one settings document holds, as a change
|
|
474
|
+
* signature.
|
|
475
|
+
*
|
|
476
|
+
* Deliberately nothing but those four keys: the settings form also carries the
|
|
477
|
+
* board's own switches and the acceptance configuration, and an edit to one of
|
|
478
|
+
* those says nothing about the defaults the create dialog prefills from. Not a
|
|
479
|
+
* second normalization of Host state — the value never leaves this comparison.
|
|
480
|
+
* @param value - the settings form's effective section, if it has one.
|
|
481
|
+
* @returns a stable string that changes exactly when the defaults do.
|
|
482
|
+
*/
|
|
483
|
+
function cardDefaultSignature(value: unknown): string {
|
|
484
|
+
const section = (value ?? {}) as Record<string, unknown>
|
|
485
|
+
return JSON.stringify([
|
|
486
|
+
section.cardDefaultMode,
|
|
487
|
+
section.cardDefaultPermission,
|
|
488
|
+
section.cardDefaultModel,
|
|
489
|
+
section.cardDefaultReasoningEffort,
|
|
490
|
+
])
|
|
491
|
+
}
|
|
492
|
+
|
|
479
493
|
/**
|
|
480
494
|
* The profile entry id this package's own row carries, for a page that serves
|
|
481
495
|
* no family binder.
|