@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
|
@@ -1221,6 +1221,10 @@
|
|
|
1221
1221
|
border-top: 1px solid var(--dsw-alias-separator-primary);
|
|
1222
1222
|
}
|
|
1223
1223
|
|
|
1224
|
+
.formSectionBody[hidden] {
|
|
1225
|
+
display: none;
|
|
1226
|
+
}
|
|
1227
|
+
|
|
1224
1228
|
.field {
|
|
1225
1229
|
display: flex;
|
|
1226
1230
|
flex-direction: column;
|
|
@@ -1288,6 +1292,13 @@
|
|
|
1288
1292
|
* The view's whole type scale is three steps: 15 title, 13 body, 12 meta.
|
|
1289
1293
|
* Hierarchy inside that scale comes from weight and the label colour role,
|
|
1290
1294
|
* never from a fourth size.
|
|
1295
|
+
*
|
|
1296
|
+
* Scrolling contract: the body is the one scrollport and the action bar is its
|
|
1297
|
+
* following sibling in the same column, so the scroll ends at the bar's top
|
|
1298
|
+
* edge and no content can ever sit behind it — the bar is neither sticky nor
|
|
1299
|
+
* absolute. The drawer itself scrolls only when its own chrome no longer fits
|
|
1300
|
+
* (a viewport shorter than header + bar): clipping there would take the action
|
|
1301
|
+
* bar out of reach, which is the one thing a short viewport must not lose.
|
|
1291
1302
|
* --------------------------------------------------------------------------- */
|
|
1292
1303
|
|
|
1293
1304
|
.detail {
|
|
@@ -1300,7 +1311,9 @@
|
|
|
1300
1311
|
border-radius: 14px;
|
|
1301
1312
|
box-shadow: var(--dsw-shadow-lv3);
|
|
1302
1313
|
color: var(--dsw-alias-label-primary);
|
|
1303
|
-
overflow: hidden;
|
|
1314
|
+
overflow-x: hidden;
|
|
1315
|
+
overflow-y: auto;
|
|
1316
|
+
overscroll-behavior: contain;
|
|
1304
1317
|
}
|
|
1305
1318
|
|
|
1306
1319
|
.detailHeader {
|
|
@@ -1383,6 +1396,22 @@
|
|
|
1383
1396
|
min-width: 0;
|
|
1384
1397
|
}
|
|
1385
1398
|
|
|
1399
|
+
/* A provider seat is a section, not a fold row: it carries the panel's own
|
|
1400
|
+
heading level and its 8px inner rhythm. It therefore keeps the 16px section
|
|
1401
|
+
pitch (the group's 8px gap plus its own 8px) instead of the 8px that belongs
|
|
1402
|
+
between two fold rows. */
|
|
1403
|
+
.detailSeat {
|
|
1404
|
+
display: block;
|
|
1405
|
+
min-width: 0;
|
|
1406
|
+
margin-block: 8px;
|
|
1407
|
+
}
|
|
1408
|
+
|
|
1409
|
+
/* A page whose providers contribute nothing keeps the fold pitch untouched: an
|
|
1410
|
+
empty wrapper is no box, so it neither spaces nor separates the rows. */
|
|
1411
|
+
.detailSeat:empty {
|
|
1412
|
+
display: none;
|
|
1413
|
+
}
|
|
1414
|
+
|
|
1386
1415
|
/* The two tracks only exist while the panel can carry them; below this the
|
|
1387
1416
|
reading order is the single column above. */
|
|
1388
1417
|
@media (min-width: 1024px) {
|
|
@@ -2170,6 +2199,43 @@
|
|
|
2170
2199
|
}
|
|
2171
2200
|
}
|
|
2172
2201
|
|
|
2202
|
+
/* Short viewports: at the panel's normal padding the header and the action bar
|
|
2203
|
+
* together take more than half of a 320px-tall surface, leaving the body a strip
|
|
2204
|
+
* a single row fits in — and under 240px they push the bar past the drawer's own
|
|
2205
|
+
* edge, where the drawer used to clip it. The chrome keeps its one 8px rhythm at
|
|
2206
|
+
* half the block padding, so a short viewport keeps a scrollport a block of
|
|
2207
|
+
* content fits in; below that the drawer's own scroll (.detail) takes over and
|
|
2208
|
+
* the bar still travels into reach. The safe-area insets survive because the
|
|
2209
|
+
* compact values are max()ed with them, exactly like the narrow-screen block
|
|
2210
|
+
* above.
|
|
2211
|
+
* --------------------------------------------------------------------------- */
|
|
2212
|
+
|
|
2213
|
+
@media (max-height: 320px) {
|
|
2214
|
+
.detailHeader {
|
|
2215
|
+
padding-block: max(8px, env(safe-area-inset-top)) 8px;
|
|
2216
|
+
}
|
|
2217
|
+
|
|
2218
|
+
.detailBody {
|
|
2219
|
+
padding-block: 8px 12px;
|
|
2220
|
+
}
|
|
2221
|
+
|
|
2222
|
+
.detailFooter {
|
|
2223
|
+
padding-block: 8px max(8px, env(safe-area-inset-bottom));
|
|
2224
|
+
}
|
|
2225
|
+
}
|
|
2226
|
+
|
|
2227
|
+
/* On the same short surface the drawer keeps a mask margin instead of the 80px
|
|
2228
|
+
* one it reserves for a roomy window: at 320px that reservation alone spent a
|
|
2229
|
+
* quarter of the height the content needs, and below 212px it left less room
|
|
2230
|
+
* than the header and the bar take together. The narrow-screen block above
|
|
2231
|
+
* already gives the drawer the full height, so this ceiling is for the desktop
|
|
2232
|
+
* layout only. */
|
|
2233
|
+
@media (min-width: 769px) and (max-height: 320px) {
|
|
2234
|
+
.detail {
|
|
2235
|
+
max-height: calc(100vh - 16px);
|
|
2236
|
+
}
|
|
2237
|
+
}
|
|
2238
|
+
|
|
2173
2239
|
/* -----------------------------------------------------------------------------
|
|
2174
2240
|
* Polish pass: complete interaction states (hover / active / focus-visible /
|
|
2175
2241
|
* disabled), unified 120ms motion, and reduced-motion fallback.
|
package/src/client/index.ts
CHANGED
|
@@ -43,6 +43,7 @@ import { TaskBoardClientService } from './service.ts'
|
|
|
43
43
|
import {
|
|
44
44
|
TASK_BOARD_SERVICE_NAME,
|
|
45
45
|
type TaskBoardCardDecorationProps,
|
|
46
|
+
type TaskBoardComposeSectionProps,
|
|
46
47
|
type TaskBoardDetailSectionProps,
|
|
47
48
|
type TaskBoardHostFace,
|
|
48
49
|
type TaskBoardSettingsSectionProps,
|
|
@@ -114,6 +115,8 @@ declare module '@deepseek-ai/dsh-client-ui-slots' {
|
|
|
114
115
|
'task-board.settings.section': { kind: 'list'; scope: 'root'; owner: TaskBoardSettingsSectionProps }
|
|
115
116
|
/** Provider card decoration; the board declares and renders it. */
|
|
116
117
|
'task-board.card.decoration': { kind: 'list'; scope: 'root'; owner: TaskBoardCardDecorationProps }
|
|
118
|
+
/** Provider new-card section; the board declares and renders it in the create dialog. */
|
|
119
|
+
'task-board.compose.section': { kind: 'list'; scope: 'root'; owner: TaskBoardComposeSectionProps }
|
|
117
120
|
}
|
|
118
121
|
}
|
|
119
122
|
|
package/src/client/locales.ts
CHANGED
|
@@ -289,8 +289,8 @@ export const zh = {
|
|
|
289
289
|
'exec.reasoning.hint.noEfforts': '该模型没有可选的思考档位,始终沿用模型/宿主的默认值。',
|
|
290
290
|
'exec.reasoning.hint.inherit': '留空即沿用该模型/宿主的默认档位。',
|
|
291
291
|
'exec.reuseSession': '在同一对话继续',
|
|
292
|
-
'exec.reuseSessionHint': '
|
|
293
|
-
'exec.reuseSessionHint.short': '
|
|
292
|
+
'exec.reuseSessionHint': '开启后,本任务的后续执行在上一次会话里继续(该会话空闲、仍存在且未被归档时),不再每次新建对话;该会话被归档时本次改开新对话。每次复用时都会重新应用上面钉住的权限与模型。',
|
|
293
|
+
'exec.reuseSessionHint.short': '后续执行复用上一次的空闲会话(归档则新开)',
|
|
294
294
|
'detail.executionSettings': '执行设置',
|
|
295
295
|
'detail.settings.run': '运行方式',
|
|
296
296
|
'detail.settings.summary.none': '未开启',
|
|
@@ -688,8 +688,8 @@ export const en: Record<keyof typeof zh, string> = {
|
|
|
688
688
|
'exec.reasoning.hint.noEfforts': 'This model offers no selectable reasoning effort, so the model or Host default always applies.',
|
|
689
689
|
'exec.reasoning.hint.inherit': 'Leave it empty to follow the model or Host default.',
|
|
690
690
|
'exec.reuseSession': 'Continue in the same conversation',
|
|
691
|
-
'exec.reuseSessionHint': 'When on, later runs continue in the previous session (when that session is idle and
|
|
692
|
-
'exec.reuseSessionHint.short': 'Later runs reuse the previous idle session',
|
|
691
|
+
'exec.reuseSessionHint': 'When on, later runs continue in the previous session (when that session is idle, still exists and is not archived) instead of starting a new conversation each time; an archived session makes that run start a fresh conversation. The pinned permission and model above are re-applied on every reuse.',
|
|
692
|
+
'exec.reuseSessionHint.short': 'Later runs reuse the previous idle session (a fresh one if archived)',
|
|
693
693
|
'detail.executionSettings': 'Execution Settings',
|
|
694
694
|
'detail.settings.run': 'Run Mode',
|
|
695
695
|
'detail.settings.summary.none': 'Not enabled',
|
|
@@ -813,8 +813,9 @@ export type SettingsCardKey = TaskBoardKey
|
|
|
813
813
|
|
|
814
814
|
/** Active dictionary, picked by the document language at call time. */
|
|
815
815
|
export function dictionary(): Record<TaskBoardKey, string> {
|
|
816
|
-
|
|
817
|
-
|
|
816
|
+
// Chinese keeps the Chinese table; every other UI language falls back to English.
|
|
817
|
+
const lang = (typeof document !== 'undefined' && document.documentElement.lang !== '' ? document.documentElement.lang : 'zh').toLowerCase()
|
|
818
|
+
return lang.startsWith('zh') ? zh : en
|
|
818
819
|
}
|
|
819
820
|
|
|
820
821
|
/**
|
|
@@ -77,7 +77,7 @@ export function TaskBoardPanelIcon({ size }: { size: number; active: boolean }):
|
|
|
77
77
|
*/
|
|
78
78
|
export function TaskBoardPanel({ controller, renderSlot }: {
|
|
79
79
|
controller: BoardController
|
|
80
|
-
/** Child-slot renderer the registration declares (detail
|
|
80
|
+
/** Child-slot renderer the registration declares (detail, card decoration, new-card section). */
|
|
81
81
|
renderSlot?: SlotRenderBinding
|
|
82
82
|
}): ReactNode {
|
|
83
83
|
const seats = useMemo(() => seatsFromRenderSlot(renderSlot), [renderSlot])
|
|
@@ -130,6 +130,7 @@ export function registerTaskBoardPanel(ctx: ClientContext, controller: BoardCont
|
|
|
130
130
|
children: {
|
|
131
131
|
'task-board.detail.section': { kind: 'list', scope: 'root' },
|
|
132
132
|
'task-board.card.decoration': { kind: 'list', scope: 'root' },
|
|
133
|
+
'task-board.compose.section': { kind: 'list', scope: 'root' },
|
|
133
134
|
},
|
|
134
135
|
inject: (): PanelFace => ({ controller }),
|
|
135
136
|
}, TaskBoardPanel as never)))
|
package/src/client/seats.tsx
CHANGED
|
@@ -4,27 +4,30 @@
|
|
|
4
4
|
*
|
|
5
5
|
* The framework hands the declaring component a `renderSlot` binding; the board
|
|
6
6
|
* wraps that binding in a React context so a provider's contribution can render
|
|
7
|
-
* deep inside TaskDetail, the card,
|
|
8
|
-
* components knowing which providers exist.
|
|
7
|
+
* deep inside TaskDetail, the card, the settings card, or the create dialog
|
|
8
|
+
* without those components knowing which providers exist.
|
|
9
9
|
*
|
|
10
10
|
* @module dsh-task-board/client/seats
|
|
11
11
|
*/
|
|
12
|
-
import { createContext, useContext } from 'react'
|
|
12
|
+
import { Component, createContext, useContext } from 'react'
|
|
13
13
|
import type { ReactNode } from 'react'
|
|
14
14
|
import {
|
|
15
15
|
TASK_BOARD_CARD_DECORATION,
|
|
16
|
+
TASK_BOARD_COMPOSE_SECTION,
|
|
16
17
|
TASK_BOARD_DETAIL_SECTION,
|
|
17
18
|
TASK_BOARD_SETTINGS_SECTION,
|
|
18
19
|
type TaskBoardCardDecorationProps,
|
|
20
|
+
type TaskBoardComposeSectionProps,
|
|
19
21
|
type TaskBoardDetailSectionProps,
|
|
20
22
|
type TaskBoardSettingsSectionProps,
|
|
21
23
|
} from '../core/extension.ts'
|
|
22
24
|
|
|
23
|
-
/** The
|
|
25
|
+
/** The four provider seats, adapted to plain render functions. */
|
|
24
26
|
export interface TaskBoardSeats {
|
|
25
27
|
detailSection: (props: TaskBoardDetailSectionProps) => ReactNode
|
|
26
28
|
settingsSection: (props: TaskBoardSettingsSectionProps) => ReactNode
|
|
27
29
|
cardDecoration: (props: TaskBoardCardDecorationProps) => ReactNode
|
|
30
|
+
composeSection: (props: TaskBoardComposeSectionProps) => ReactNode
|
|
28
31
|
}
|
|
29
32
|
|
|
30
33
|
/** Nothing registered: every seat renders empty. */
|
|
@@ -32,6 +35,7 @@ export const EMPTY_TASK_BOARD_SEATS: TaskBoardSeats = {
|
|
|
32
35
|
detailSection: () => null,
|
|
33
36
|
settingsSection: () => null,
|
|
34
37
|
cardDecoration: () => null,
|
|
38
|
+
composeSection: () => null,
|
|
35
39
|
}
|
|
36
40
|
|
|
37
41
|
/** The framework `renderSlot` binding shape (key + owner props share). */
|
|
@@ -44,6 +48,30 @@ export function seatsFromRenderSlot(renderSlot: SlotRenderBinding | undefined):
|
|
|
44
48
|
detailSection: props => renderSlot(TASK_BOARD_DETAIL_SECTION, props as unknown as Record<string, unknown>),
|
|
45
49
|
settingsSection: props => renderSlot(TASK_BOARD_SETTINGS_SECTION, props as unknown as Record<string, unknown>),
|
|
46
50
|
cardDecoration: props => renderSlot(TASK_BOARD_CARD_DECORATION, props as unknown as Record<string, unknown>),
|
|
51
|
+
composeSection: props => renderSlot(TASK_BOARD_COMPOSE_SECTION, props as unknown as Record<string, unknown>),
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Isolation for one seat whose providers render outside the framework's own
|
|
57
|
+
* per-entry boundary: a provider that throws while rendering contributes
|
|
58
|
+
* nothing here instead of taking the surface around the seat down with it.
|
|
59
|
+
* Nothing is rendered in that case — the seat is optional, so its absence is
|
|
60
|
+
* the honest state — and the failure is logged once for the provider's author.
|
|
61
|
+
*/
|
|
62
|
+
export class TaskBoardSeatBoundary extends Component<{ children: ReactNode }, { failed: boolean }> {
|
|
63
|
+
state = { failed: false }
|
|
64
|
+
|
|
65
|
+
static getDerivedStateFromError(): { failed: boolean } {
|
|
66
|
+
return { failed: true }
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
componentDidCatch(error: unknown): void {
|
|
70
|
+
console.error('[dsh-task-board] a provider seat failed to render', error)
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
render(): ReactNode {
|
|
74
|
+
return this.state.failed ? null : this.props.children
|
|
47
75
|
}
|
|
48
76
|
}
|
|
49
77
|
|
package/src/client/service.ts
CHANGED
|
@@ -101,6 +101,9 @@ export class TaskBoardClientService implements TaskBoardClientFace {
|
|
|
101
101
|
enabled: this.enabled,
|
|
102
102
|
tasks: (state?.tasks ?? []) as readonly TaskRecord[],
|
|
103
103
|
extensions: state?.extensions ?? {},
|
|
104
|
+
hydrated: state?.host !== undefined,
|
|
105
|
+
...(state?.executionOptions.workspaces === undefined ? {} : { workspaces: state.executionOptions.workspaces }),
|
|
106
|
+
...(state?.transportError === undefined ? {} : { lastError: state.transportError }),
|
|
104
107
|
}
|
|
105
108
|
}
|
|
106
109
|
|
|
@@ -141,11 +141,13 @@ export interface NumberConstraints {
|
|
|
141
141
|
integer?: boolean
|
|
142
142
|
/** The accepted value must be at least this. */
|
|
143
143
|
min?: number
|
|
144
|
+
/** The accepted value must be at most this. */
|
|
145
|
+
max?: number
|
|
144
146
|
}
|
|
145
147
|
|
|
146
148
|
/** 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. */
|
|
147
149
|
export function numberField(field: string, constraints: NumberConstraints = {}): FieldSpec {
|
|
148
|
-
const { integer = false, min } = constraints
|
|
150
|
+
const { integer = false, min, max } = constraints
|
|
149
151
|
return {
|
|
150
152
|
field,
|
|
151
153
|
entry: 'type',
|
|
@@ -157,6 +159,7 @@ export function numberField(field: string, constraints: NumberConstraints = {}):
|
|
|
157
159
|
if (!Number.isFinite(parsed)) return undefined
|
|
158
160
|
if (integer && !Number.isInteger(parsed)) return undefined
|
|
159
161
|
if (min !== undefined && parsed < min) return undefined
|
|
162
|
+
if (max !== undefined && parsed > max) return undefined
|
|
160
163
|
return { kind: 'set', value: parsed }
|
|
161
164
|
},
|
|
162
165
|
}
|
|
@@ -439,7 +442,7 @@ export class CardForm<T> {
|
|
|
439
442
|
// against. Settling is the only signal the form has; the rest of the
|
|
440
443
|
// batch, when one exists, still carries the atomic verdict by read-back.
|
|
441
444
|
if (this.specOf(field).secret) return true
|
|
442
|
-
return this.userLayer()?.[field]
|
|
445
|
+
return jsonValuesEqual(this.userLayer()?.[field], value)
|
|
443
446
|
}
|
|
444
447
|
|
|
445
448
|
/**
|
|
@@ -508,3 +511,19 @@ export class CardForm<T> {
|
|
|
508
511
|
for (const listener of this.listeners) listener()
|
|
509
512
|
}
|
|
510
513
|
}
|
|
514
|
+
|
|
515
|
+
/** Structural equality for JSON settings values (primitives, arrays, plain objects). */
|
|
516
|
+
function jsonValuesEqual(left: unknown, right: unknown): boolean {
|
|
517
|
+
if (Object.is(left, right)) return true
|
|
518
|
+
if (typeof left !== 'object' || left === null || typeof right !== 'object' || right === null) return false
|
|
519
|
+
if (Array.isArray(left) || Array.isArray(right)) {
|
|
520
|
+
if (!Array.isArray(left) || !Array.isArray(right) || left.length !== right.length) return false
|
|
521
|
+
return left.every((item, index) => jsonValuesEqual(item, right[index]))
|
|
522
|
+
}
|
|
523
|
+
const a = left as Record<string, unknown>
|
|
524
|
+
const b = right as Record<string, unknown>
|
|
525
|
+
const keysA = Object.keys(a).filter(key => a[key] !== undefined)
|
|
526
|
+
const keysB = Object.keys(b).filter(key => b[key] !== undefined)
|
|
527
|
+
if (keysA.length !== keysB.length) return false
|
|
528
|
+
return keysA.every(key => Object.hasOwn(b, key) && jsonValuesEqual(a[key], b[key]))
|
|
529
|
+
}
|
package/src/core/controller.ts
CHANGED
|
@@ -160,7 +160,7 @@ export interface ExecutionOptionsSnapshot {
|
|
|
160
160
|
* (revision/scheduler/power); a full snapshot also carries the deployment
|
|
161
161
|
* constants the UI reads (session default permission, subtask depth).
|
|
162
162
|
*/
|
|
163
|
-
export type HostMirror = Pick<TaskBoardSnapshot, 'revision' | 'scheduler' | 'power' | 'sessionDefaultPermission' | 'maxSubtaskDepth' | 'cardDefaults' | 'extensions' | 'attachmentLimits'>
|
|
163
|
+
export type HostMirror = Pick<TaskBoardSnapshot, 'revision' | 'extensionsRevision' | 'scheduler' | 'power' | 'sessionDefaultPermission' | 'maxSubtaskDepth' | 'cardDefaults' | 'extensions' | 'attachmentLimits'>
|
|
164
164
|
|
|
165
165
|
/** Immutable controller snapshot for UI subscriptions. */
|
|
166
166
|
export interface ControllerSnapshot {
|
|
@@ -853,7 +853,8 @@ export class BoardController {
|
|
|
853
853
|
* re-serialize the whole ledger per tab even while nothing changes.
|
|
854
854
|
*/
|
|
855
855
|
private onRemoteEvent(event: TaskBoardEventPayload | undefined): void {
|
|
856
|
-
|
|
856
|
+
const sameExtensions = event?.extensionsRevision === this.hostState?.extensionsRevision
|
|
857
|
+
if (event !== undefined && this.hostState !== undefined && event.revision === this.hostState.revision && sameExtensions
|
|
857
858
|
&& typeof event.scheduler === 'object' && event.scheduler !== null
|
|
858
859
|
&& typeof event.power === 'object' && event.power !== null) {
|
|
859
860
|
this.hostState = { ...this.hostState, revision: event.revision, scheduler: event.scheduler, power: event.power }
|
|
@@ -890,7 +891,11 @@ export class BoardController {
|
|
|
890
891
|
// value over would keep a CLEARED default alive in the create dialog, which
|
|
891
892
|
// is the mirror image of the staleness this key is re-read for.
|
|
892
893
|
const cardDefaults = snapshot.cardDefaults
|
|
893
|
-
|
|
894
|
+
// Published extension summaries are NOT carried over across snapshots: the
|
|
895
|
+
// Host omits `extensions` when the last running extension unmounts, so
|
|
896
|
+
// carrying over an earlier value would keep a stale summary alive forever.
|
|
897
|
+
const extensions = snapshot.extensions
|
|
898
|
+
const extensionsRevision = snapshot.extensionsRevision
|
|
894
899
|
// The attachment limits are carried over: a deployment that lowers them
|
|
895
900
|
// must keep the browser's refusal in step until the next snapshot.
|
|
896
901
|
const attachmentLimits = snapshot.attachmentLimits ?? this.hostState?.attachmentLimits
|
|
@@ -898,6 +903,7 @@ export class BoardController {
|
|
|
898
903
|
revision: snapshot.revision,
|
|
899
904
|
scheduler: snapshot.scheduler,
|
|
900
905
|
power: snapshot.power,
|
|
906
|
+
...(extensionsRevision === undefined ? {} : { extensionsRevision }),
|
|
901
907
|
...(sessionDefaultPermission === undefined ? {} : { sessionDefaultPermission }),
|
|
902
908
|
...(maxSubtaskDepth === undefined ? {} : { maxSubtaskDepth }),
|
|
903
909
|
...(cardDefaults === undefined ? {} : { cardDefaults }),
|
|
@@ -89,8 +89,9 @@ export function executionSummaryOf(events: readonly SummaryEvent[], startedAt: n
|
|
|
89
89
|
export function normalizeExecutionSummary(value: unknown): ExecutionSummary | undefined {
|
|
90
90
|
if (typeof value !== 'object' || value === null) return undefined
|
|
91
91
|
const row = value as Record<string, unknown>
|
|
92
|
-
if (typeof row.text !== 'string'
|
|
92
|
+
if (typeof row.text !== 'string') return undefined
|
|
93
|
+
if (row.seq !== undefined && (typeof row.seq !== 'number' || !Number.isFinite(row.seq))) return undefined
|
|
93
94
|
const text = row.text.trim()
|
|
94
95
|
if (text === '') return undefined
|
|
95
|
-
return { text: truncateExecutionSummary(text), seq: row.seq }
|
|
96
|
+
return { text: truncateExecutionSummary(text), ...(row.seq === undefined ? {} : { seq: row.seq }) }
|
|
96
97
|
}
|
package/src/core/extension.ts
CHANGED
|
@@ -31,12 +31,19 @@ export const TASK_BOARD_DETAIL_SECTION = 'task-board.detail.section'
|
|
|
31
31
|
export const TASK_BOARD_SETTINGS_SECTION = 'task-board.settings.section'
|
|
32
32
|
/** Child seat a provider registers its card decoration into. */
|
|
33
33
|
export const TASK_BOARD_CARD_DECORATION = 'task-board.card.decoration'
|
|
34
|
+
/**
|
|
35
|
+
* Child seat a provider registers its new-card section into: its own
|
|
36
|
+
* create-time configuration, rendered inside the create dialog's execution
|
|
37
|
+
* settings, whose draft the board stores on the card it creates.
|
|
38
|
+
*/
|
|
39
|
+
export const TASK_BOARD_COMPOSE_SECTION = 'task-board.compose.section'
|
|
34
40
|
|
|
35
41
|
/** Every child seat the board declares for extensions, in render order. */
|
|
36
42
|
export const TASK_BOARD_EXTENSION_SEATS: readonly string[] = [
|
|
37
43
|
TASK_BOARD_DETAIL_SECTION,
|
|
38
44
|
TASK_BOARD_SETTINGS_SECTION,
|
|
39
45
|
TASK_BOARD_CARD_DECORATION,
|
|
46
|
+
TASK_BOARD_COMPOSE_SECTION,
|
|
40
47
|
]
|
|
41
48
|
|
|
42
49
|
/**
|
|
@@ -267,6 +274,86 @@ export interface TaskBoardSessionsFace {
|
|
|
267
274
|
followUp(taskId: string, text: string): Promise<void>
|
|
268
275
|
}
|
|
269
276
|
|
|
277
|
+
/**
|
|
278
|
+
* Why the board is opening a run. The four entries reach the launch path from
|
|
279
|
+
* different places and a provider may want to answer only some of them: the
|
|
280
|
+
* board's own run action ({@link 'manual'}), a settled card sent back to run
|
|
281
|
+
* again ({@link 'rerun'}), an armed schedule ({@link 'schedule'}), and the
|
|
282
|
+
* `task_board_run` model-visible tool ({@link 'tool'}).
|
|
283
|
+
*
|
|
284
|
+
* A rework arrives as `manual`: it is the same human entry point, opening a
|
|
285
|
+
* run in the card's own conversation rather than a fresh one.
|
|
286
|
+
*/
|
|
287
|
+
export type TaskBoardLaunchTrigger = 'manual' | 'rerun' | 'schedule' | 'tool'
|
|
288
|
+
|
|
289
|
+
/** Context of one launch the board is about to open. */
|
|
290
|
+
export interface TaskBoardLaunchContext {
|
|
291
|
+
/** Which entry asked for this run. */
|
|
292
|
+
trigger: TaskBoardLaunchTrigger
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
/**
|
|
296
|
+
* What a launch handler decided for one run.
|
|
297
|
+
*
|
|
298
|
+
* `local` keeps the board's own execution and only adds context, so a provider
|
|
299
|
+
* that runs a card through an ordinary session (a session told to drive
|
|
300
|
+
* something else, for instance) reads exactly the launch the board would have
|
|
301
|
+
* made. `external` hands the whole run to the provider: the board opens no
|
|
302
|
+
* session and writes no execution record.
|
|
303
|
+
*/
|
|
304
|
+
export type TaskBoardLaunchDecision =
|
|
305
|
+
/**
|
|
306
|
+
* Run the card locally through the board's own session, with `promptPreamble`
|
|
307
|
+
* injected ahead of the card's prompt on the same path the board's tag
|
|
308
|
+
* prompts take. A blank preamble injects nothing.
|
|
309
|
+
*/
|
|
310
|
+
| { kind: 'local'; promptPreamble?: string }
|
|
311
|
+
/**
|
|
312
|
+
* The provider takes this run over. The board creates no session and records
|
|
313
|
+
* no execution; it only moves the card into the running column, which is
|
|
314
|
+
* already the board's own way of saying work is under way outside a Host-run
|
|
315
|
+
* session. The provider closes the card through the existing
|
|
316
|
+
* `record-external-outcome` action once its own run settles.
|
|
317
|
+
*/
|
|
318
|
+
| { kind: 'external' }
|
|
319
|
+
/**
|
|
320
|
+
* The provider refuses this run. The board opens nothing, writes nothing and
|
|
321
|
+
* answers the caller with `code: reason`, so a second run request against a
|
|
322
|
+
* card the provider already holds is an explicit refusal rather than a
|
|
323
|
+
* silent overwrite. A scheduled occurrence is skipped instead of thrown.
|
|
324
|
+
*/
|
|
325
|
+
| { kind: 'refuse'; code: string; reason: string }
|
|
326
|
+
|
|
327
|
+
/**
|
|
328
|
+
* Decide whether one launch belongs to the provider, and how it runs.
|
|
329
|
+
* @param task - the card about to run.
|
|
330
|
+
* @param context - which entry asked for this run.
|
|
331
|
+
* @returns a decision, or undefined to leave the run to the board unchanged.
|
|
332
|
+
*/
|
|
333
|
+
export type TaskBoardLaunchHandler = (
|
|
334
|
+
task: TaskRecord,
|
|
335
|
+
context: TaskBoardLaunchContext,
|
|
336
|
+
) => TaskBoardLaunchDecision | undefined
|
|
337
|
+
|
|
338
|
+
/**
|
|
339
|
+
* Launch interception: the seam through which a provider takes a run over.
|
|
340
|
+
*
|
|
341
|
+
* The board consults the registered handlers at its single launch gate — before
|
|
342
|
+
* any session exists and before any execution record is written — for every
|
|
343
|
+
* trigger. Handlers run in registration order and the first one that answers
|
|
344
|
+
* anything other than undefined decides that launch. A handler that throws is
|
|
345
|
+
* isolated and treated as undefined, so a broken provider costs one run's
|
|
346
|
+
* interception and never the launch itself.
|
|
347
|
+
*/
|
|
348
|
+
export interface TaskBoardLaunchFace {
|
|
349
|
+
/**
|
|
350
|
+
* Register one launch handler. The returned disposer unregisters it, and the
|
|
351
|
+
* handler is released with the extension's own stop, so a switched-off
|
|
352
|
+
* provider is never consulted.
|
|
353
|
+
*/
|
|
354
|
+
intercept(handler: TaskBoardLaunchHandler): () => void
|
|
355
|
+
}
|
|
356
|
+
|
|
270
357
|
/** Storage face for one extension's own payload on a task. */
|
|
271
358
|
export interface TaskBoardIntegrationFace {
|
|
272
359
|
/** Read this extension's payload, or undefined when the task carries none. */
|
|
@@ -324,6 +411,14 @@ export interface TaskBoardExtensionHost {
|
|
|
324
411
|
* probes the face and keeps working against a board that serves none.
|
|
325
412
|
*/
|
|
326
413
|
sessions?: TaskBoardSessionsFace
|
|
414
|
+
/**
|
|
415
|
+
* Launch interception: the provider decides, per run, whether the board's own
|
|
416
|
+
* session launches it or whether this provider takes the run over. Optional
|
|
417
|
+
* on the same terms as {@link TaskBoardExtensionHost.sessions} — the API
|
|
418
|
+
* version stays 1, so a provider probes the face before using it, and a board
|
|
419
|
+
* that serves no launch gate keeps launching every card itself.
|
|
420
|
+
*/
|
|
421
|
+
launch?: TaskBoardLaunchFace
|
|
327
422
|
integration: TaskBoardIntegrationFace
|
|
328
423
|
events: TaskBoardEventFace
|
|
329
424
|
/**
|
|
@@ -349,6 +444,20 @@ export interface TaskBoardExtension {
|
|
|
349
444
|
stop?(): void
|
|
350
445
|
/** Route one dispatched action; the returned value goes back to the dispatcher. */
|
|
351
446
|
handleAction?(request: TaskBoardExtensionActionRequest): unknown | Promise<unknown>
|
|
447
|
+
/**
|
|
448
|
+
* Model-facing summary of one card this provider owns, merged into the card
|
|
449
|
+
* the `task_board_get` / `task_board_list` tools return under `remote`. An
|
|
450
|
+
* object may carry `localPermission: false` to say the board's local session
|
|
451
|
+
* permission gate does not apply to the card, which drops `permissionPending`
|
|
452
|
+
* from the tool output. Optional: the API version stays 1.
|
|
453
|
+
*/
|
|
454
|
+
describeTask?(task: TaskRecord): Record<string, unknown> | undefined
|
|
455
|
+
/**
|
|
456
|
+
* The handle of the run the provider took over for `taskId`, read right after
|
|
457
|
+
* `task_board_run` so the caller gets identifiers instead of an empty list.
|
|
458
|
+
* Optional on the same terms as {@link TaskBoardExtension.describeTask}.
|
|
459
|
+
*/
|
|
460
|
+
describeRun?(taskId: string): Record<string, unknown> | undefined
|
|
352
461
|
}
|
|
353
462
|
|
|
354
463
|
/** Board mirror an extension's browser half observes. */
|
|
@@ -359,6 +468,16 @@ export interface TaskBoardClientMirror {
|
|
|
359
468
|
tasks: readonly TaskRecord[]
|
|
360
469
|
/** Published extension summaries, keyed by extension id (opaque to the board). */
|
|
361
470
|
extensions: Readonly<Record<string, unknown>>
|
|
471
|
+
/**
|
|
472
|
+
* Whether at least one authoritative Host snapshot has arrived in this page.
|
|
473
|
+
* Absent on older boards or test mirrors; false while `/bootstrap` is still
|
|
474
|
+
* in flight, so providers do not misread an initial empty `{}` as unmounted.
|
|
475
|
+
*/
|
|
476
|
+
hydrated?: boolean
|
|
477
|
+
/** Local workspaces registered in the runtime, for provider workspace pickers. */
|
|
478
|
+
workspaces?: readonly { workspaceId: string; title: string }[]
|
|
479
|
+
/** Last Host transport refusal message (e.g. a refused extension action), when any. */
|
|
480
|
+
lastError?: string
|
|
362
481
|
}
|
|
363
482
|
|
|
364
483
|
/** Whether a task should be shown on the board; false hides it. */
|
|
@@ -412,6 +531,40 @@ export interface TaskBoardCardDecorationProps {
|
|
|
412
531
|
task: TaskRecord
|
|
413
532
|
}
|
|
414
533
|
|
|
534
|
+
/** Optional metadata a provider reports alongside its new-card draft. */
|
|
535
|
+
export interface TaskBoardComposeDraftOptions {
|
|
536
|
+
/** One-line label included in the collapsed Run Mode summary. */
|
|
537
|
+
summary?: string
|
|
538
|
+
/**
|
|
539
|
+
* Validation blocker message: while non-empty, the create dialog refuses to
|
|
540
|
+
* submit or run locally and forces the Run Mode section open.
|
|
541
|
+
*/
|
|
542
|
+
error?: string
|
|
543
|
+
}
|
|
544
|
+
|
|
545
|
+
/** Owner props of the new-card compose seat. */
|
|
546
|
+
export interface TaskBoardComposeSectionProps {
|
|
547
|
+
/**
|
|
548
|
+
* Report the draft this provider wants written into the new card's
|
|
549
|
+
* `integrations` under `extensionId` — that is, what the board stores when
|
|
550
|
+
* the create dialog is submitted. The id is the provider's own extension id,
|
|
551
|
+
* the same key its payload lives under on every other card; a later call for
|
|
552
|
+
* the same id replaces the earlier draft instead of merging with it, and
|
|
553
|
+
* `undefined` withdraws it, so a provider that clears its picker leaves no
|
|
554
|
+
* entry behind. The draft stands until the dialog submits or its provider
|
|
555
|
+
* replaces or withdraws it, because collapsing the region that holds the seat
|
|
556
|
+
* must never discard a choice already made. The board never interprets the
|
|
557
|
+
* payload: a draft that is not a plain JSON object or that exceeds
|
|
558
|
+
* {@link TASK_BOARD_PAYLOAD_LIMIT_BYTES} is dropped from the card being
|
|
559
|
+
* created and named in one warning, and the create itself still happens.
|
|
560
|
+
*/
|
|
561
|
+
contribute(extensionId: string, payload: TaskBoardExtensionPayload | undefined, options?: TaskBoardComposeDraftOptions): void
|
|
562
|
+
/** Initial integrations of the source card when duplicating an existing card. */
|
|
563
|
+
initialIntegrations?: Readonly<Record<string, unknown>>
|
|
564
|
+
/** Incremented each time the user submits the dialog, so providers can reveal untouched field errors. */
|
|
565
|
+
submitAttempt?: number
|
|
566
|
+
}
|
|
567
|
+
|
|
415
568
|
/**
|
|
416
569
|
* Host-half service face published under {@link TASK_BOARD_SERVICE_NAME}. A
|
|
417
570
|
* provider package's host half resolves this from the shared cordis service
|
|
@@ -444,8 +597,13 @@ export interface TaskBoardHostFace {
|
|
|
444
597
|
* retries one envelope does not apply it twice. Refusals are the ledger's:
|
|
445
598
|
* they throw with the Host's own text, which is why this face adds no code
|
|
446
599
|
* table of its own.
|
|
600
|
+
*
|
|
601
|
+
* `trigger` says which entry asked for a run, when the caller knows better
|
|
602
|
+
* than the board's default: the `task_board_run` tool passes `tool` so a
|
|
603
|
+
* launch handler can tell an agent's run from a person's. Only a `run` action
|
|
604
|
+
* reads it — `rerun`, `rework` and the human run path are their own triggers.
|
|
447
605
|
*/
|
|
448
|
-
apply(requestId: string, action: TaskBoardAction, initiator?: string): TaskBoardSnapshot | Promise<TaskBoardSnapshot>
|
|
606
|
+
apply(requestId: string, action: TaskBoardAction, initiator?: string, trigger?: TaskBoardLaunchTrigger): TaskBoardSnapshot | Promise<TaskBoardSnapshot>
|
|
449
607
|
/**
|
|
450
608
|
* Follow the board's change notifications. The listener receives no payload —
|
|
451
609
|
* a consumer that needs the state reads {@link snapshot} — and the returned
|