@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.
Files changed (45) hide show
  1. package/README.i18n.yaml +2 -2
  2. package/README.md +1 -1
  3. package/README.zh.md +1 -1
  4. package/lib/client.js +190 -63
  5. package/lib/client.js.map +1 -1
  6. package/lib/index.js +599 -95
  7. package/lib/types/client/board/TaskForm.d.ts +3 -1
  8. package/lib/types/client/index.d.ts +7 -1
  9. package/lib/types/client/native-panel.d.ts +1 -1
  10. package/lib/types/client/seats.d.ts +36 -2
  11. package/lib/types/client/settings-form.d.ts +2 -0
  12. package/lib/types/core/controller.d.ts +1 -1
  13. package/lib/types/core/extension.d.ts +160 -1
  14. package/lib/types/core/session-reuse.d.ts +46 -13
  15. package/lib/types/core/tasks.d.ts +16 -5
  16. package/lib/types/host/agent-tools.d.ts +12 -2
  17. package/lib/types/host/extension-registry.d.ts +38 -1
  18. package/lib/types/host-ledger.d.ts +86 -1
  19. package/lib/types/host-runner.d.ts +20 -1
  20. package/lib/types/host-service.d.ts +64 -15
  21. package/lib/types/protocol.d.ts +18 -1
  22. package/package.json +1 -1
  23. package/src/client/board/ExecutionLog.tsx +15 -2
  24. package/src/client/board/NewTaskModal.tsx +88 -3
  25. package/src/client/board/TaskDetail.tsx +18 -11
  26. package/src/client/board/TaskForm.tsx +13 -2
  27. package/src/client/board.module.css +67 -1
  28. package/src/client/index.ts +3 -0
  29. package/src/client/locales.ts +7 -6
  30. package/src/client/native-panel.tsx +2 -1
  31. package/src/client/seats.tsx +32 -4
  32. package/src/client/service.ts +3 -0
  33. package/src/client/settings-form.ts +21 -2
  34. package/src/core/controller.ts +9 -3
  35. package/src/core/execution-summary.ts +3 -2
  36. package/src/core/extension.ts +159 -1
  37. package/src/core/session-reuse.ts +58 -21
  38. package/src/core/store.ts +2 -0
  39. package/src/core/tasks.ts +16 -5
  40. package/src/host/agent-tools.ts +70 -17
  41. package/src/host/extension-registry.ts +157 -2
  42. package/src/host-ledger.ts +274 -23
  43. package/src/host-runner.ts +44 -5
  44. package/src/host-service.ts +190 -37
  45. package/src/protocol.ts +37 -3
@@ -3,7 +3,7 @@ import { DEFAULT_RUN_LAUNCH_WIDTH, normalizeRunLaunchWidth } from './core/launch
3
3
  import { DEFAULT_SPEND_BUDGET_TOKENS, spendCapMessage, spendCapReached } from './core/spend-budget.ts'
4
4
  import { usedTokensToday } from './host-spend.ts'
5
5
  import { DEFAULT_SESSION_POLL_SECONDS, normalizeSessionPollSeconds, sessionPollMs } from './core/poll-cadence.ts'
6
- import { reusableSessionId } from './core/session-reuse.ts'
6
+ import { newestSettledSessionId, reusableSessionId } from './core/session-reuse.ts'
7
7
  import { LaunchAdmissionQueue, type QueuedLaunch } from './host/launch-admission.ts'
8
8
  import { HostTaskLedger, type OpenedRun, type OpenExecutionReference } from './host-ledger.ts'
9
9
  import { HostExecutionRunner, SessionLaunchError, type GatewayPeer, type SessionCommandDispatcher, type SessionSummary, type TaskBoardWorkspaceRegistry } from './host-runner.ts'
@@ -13,8 +13,8 @@ import { PowerInhibitor } from './power-inhibitor.ts'
13
13
  import { TASK_BOARD_SCHEMA_VERSION, type TaskBoardAction, type TaskBoardEventPayload, type TaskBoardSnapshot } from './protocol.ts'
14
14
  import { projectSnapshotForWire } from './core/wire-projection.ts'
15
15
  import type { CardDefaults } from './core/card-defaults.ts'
16
- import { TaskBoardExtensionRegistry } from './host/extension-registry.ts'
17
- import type { TaskBoardExtension } from './core/extension.ts'
16
+ import { TaskBoardExtensionRegistry, type TaskBoardExtensionLogger } from './host/extension-registry.ts'
17
+ import type { TaskBoardExtension, TaskBoardLaunchTrigger } from './core/extension.ts'
18
18
  import { isTaskPermission, normalizeTargetId, type ExecutionOutcome, type ExecutionSummary, type ScheduleMode, type TaskRecord, type TaskStatus } from './core/tasks.ts'
19
19
  import type { ModelCatalogView } from './core/model-catalog.ts'
20
20
  import type { TaskPermission } from './core/handover.ts'
@@ -58,11 +58,32 @@ const ABANDONED_LAUNCH_REASON = 'host stopped before this execution started'
58
58
 
59
59
  /**
60
60
  * Why a rework could not launch: it redoes work in the card's own
61
- * conversation, so a session the Host cannot continue means there is nothing to
62
- * send the reviewer's instructions into. Starting a fresh conversation instead
63
- * would hand those instructions to an agent that never saw the work.
61
+ * conversation, so a session the Host cannot confirm as reachable means there is
62
+ * nothing to send the reviewer's instructions into. Starting a fresh
63
+ * conversation instead would hand those instructions to an agent that never saw
64
+ * the work. "Could not be confirmed" also covers an unreadable roster, which is
65
+ * neither "idle" nor "gone".
64
66
  */
65
- const REWORK_SESSION_REASON = 'rework: the card\'s previous execution session is not present and idle in the host session roster, so there is no conversation to send the rework instructions into'
67
+ const REWORK_SESSION_REASON = 'rework: the card\'s previous execution session could not be confirmed as present and idle in the host session roster, so there is no conversation to send the rework instructions into'
68
+
69
+ /**
70
+ * Why a rework could not launch into an archived conversation (issue #2068).
71
+ * The session still exists, so the generic reason would misdirect: the operator
72
+ * has to unarchive that conversation before the rework can be sent into it.
73
+ * @param sessionId - the archived conversation the rework addressed.
74
+ * @returns the refusal the operator reads on the card.
75
+ */
76
+ const reworkArchivedReason = (sessionId: string): string =>
77
+ 'rework: the card\'s previous execution session ' + sessionId
78
+ + ' is archived, so the Host will not run a turn in it; unarchive that session and start the rework again'
79
+
80
+ /** What a launch may do with the card's previous conversation. */
81
+ interface ReuseDecision {
82
+ /** The session this launch continues in; absent when it starts fresh. */
83
+ sessionId?: string
84
+ /** The newest settled session is in the archive set, so reuse refused it. */
85
+ archivedSessionId?: string
86
+ }
66
87
 
67
88
  /**
68
89
  * The host model catalog one run group freezes, read once for the whole group.
@@ -338,6 +359,13 @@ export class TaskBoardHostService {
338
359
  * Absent means "not proven legacy", which keeps the force exactly as it is.
339
360
  */
340
361
  legacyAgentTeams?: () => boolean
362
+ /**
363
+ * Logging seat the extension registry writes to. Absent keeps the process
364
+ * console, which is what a deployment without an opinion wants; a
365
+ * deployment (or a test) that collects the board's own warnings and errors
366
+ * injects its own.
367
+ */
368
+ extensionLogger?: TaskBoardExtensionLogger
341
369
  } = {}) {
342
370
  this.ledger = options.ledger ?? new HostTaskLedger(undefined, undefined, {
343
371
  sessionDefaultPermission: options.sessionDefaultPermission,
@@ -377,7 +405,14 @@ export class TaskBoardHostService {
377
405
  this.applyBoardAction(crypto.randomUUID(), { kind: 'rework', taskId, instructions }, initiator)
378
406
  },
379
407
  now: this.now,
408
+ onPublished: () => { this.emit() },
409
+ ...(options.extensionLogger === undefined ? {} : { logger: options.extensionLogger }),
380
410
  })
411
+ // The board's single launch gate. Every run — manual, rerun, rework, a due
412
+ // schedule, the run tool — is opened by the ledger, so attaching the gate
413
+ // there is what makes one point cover all of them, before a session exists
414
+ // and before an execution record is written.
415
+ this.ledger.setLaunchGate((task, context) => this.extensions.interceptLaunch(task, context))
381
416
  installStreamErrorGuards()
382
417
  this.ledger.subscribe(() => {
383
418
  this.syncPowerReasons()
@@ -482,6 +517,7 @@ export class TaskBoardHostService {
482
517
  // refuse an oversized selection before it uploads anything.
483
518
  ...(this.attachmentStore() === undefined ? {} : { attachmentLimits: publishedAttachmentLimits(this.attachmentStore()) }),
484
519
  ...(Object.keys(published).length === 0 ? {} : { extensions: published }),
520
+ extensionsRevision: this.extensions.publishedRevision,
485
521
  })
486
522
  }
487
523
 
@@ -493,6 +529,16 @@ export class TaskBoardHostService {
493
529
  return this.extensions.registerExtension(extension)
494
530
  }
495
531
 
532
+ /** What running providers say about one card, for the model-facing tools. */
533
+ describeTask(task: TaskRecord): Record<string, Record<string, unknown>> | undefined {
534
+ return this.extensions.describeTask(task)
535
+ }
536
+
537
+ /** The run handle a running provider holds for one card, for `task_board_run`. */
538
+ describeRun(taskId: string): Record<string, Record<string, unknown>> | undefined {
539
+ return this.extensions.describeRun(taskId)
540
+ }
541
+
496
542
  /**
497
543
  * The host model catalog the settings card's model and reasoning-level
498
544
  * choices come from.
@@ -506,7 +552,12 @@ export class TaskBoardHostService {
506
552
  /** SSE frame payload; deliberately skips the tasks deep-clone of {@link snapshot}. */
507
553
  eventPayload(): TaskBoardEventPayload {
508
554
  const { revision, scheduler } = this.ledger.summary()
509
- return { revision, scheduler, power: this.power.snapshot() }
555
+ return {
556
+ revision,
557
+ extensionsRevision: this.extensions.publishedRevision,
558
+ scheduler,
559
+ power: this.power.snapshot(),
560
+ }
510
561
  }
511
562
 
512
563
  subscribe(listener: () => void): () => void {
@@ -579,10 +630,10 @@ export class TaskBoardHostService {
579
630
  await verifyAttachments(store, attachments)
580
631
  }
581
632
 
582
- apply(requestId: string, action: Extract<TaskBoardAction, { kind: 'extension-action' }>, initiator?: string): Promise<TaskBoardSnapshot>
583
- apply(requestId: string, action: Exclude<TaskBoardAction, { kind: 'extension-action' }>, initiator?: string): TaskBoardSnapshot
584
- apply(requestId: string, action: TaskBoardAction, initiator?: string): TaskBoardSnapshot | Promise<TaskBoardSnapshot>
585
- apply(requestId: string, action: TaskBoardAction, initiator?: string): TaskBoardSnapshot | Promise<TaskBoardSnapshot> {
633
+ apply(requestId: string, action: Extract<TaskBoardAction, { kind: 'extension-action' }>, initiator?: string, trigger?: TaskBoardLaunchTrigger): Promise<TaskBoardSnapshot>
634
+ apply(requestId: string, action: Exclude<TaskBoardAction, { kind: 'extension-action' }>, initiator?: string, trigger?: TaskBoardLaunchTrigger): TaskBoardSnapshot
635
+ apply(requestId: string, action: TaskBoardAction, initiator?: string, trigger?: TaskBoardLaunchTrigger): TaskBoardSnapshot | Promise<TaskBoardSnapshot>
636
+ apply(requestId: string, action: TaskBoardAction, initiator?: string, trigger?: TaskBoardLaunchTrigger): TaskBoardSnapshot | Promise<TaskBoardSnapshot> {
586
637
  if (!this.active) throw new Error('task board is disabled')
587
638
  // A caller that never met the HTTP envelope parser can name a kind this build
588
639
  // does not implement. It is refused here, in the board's own vocabulary: the
@@ -602,7 +653,7 @@ export class TaskBoardHostService {
602
653
  // The answer to a write is a read like any other — it crosses the same wire
603
654
  // (the HTTP action route and the remote bridge's board.apply) — so it leaves
604
655
  // through the same projection as snapshot().
605
- return projectSnapshotForWire(this.applyBoardAction(requestId, action, initiator))
656
+ return projectSnapshotForWire(this.applyBoardAction(requestId, action, initiator, false, trigger))
606
657
  }
607
658
 
608
659
  /**
@@ -610,7 +661,13 @@ export class TaskBoardHostService {
610
661
  * calls and the same-origin wire both land here, so the two surfaces can
611
662
  * never disagree about a card.
612
663
  */
613
- private applyBoardAction(requestId: string, action: Exclude<TaskBoardAction, { kind: 'extension-action' }>, initiator?: string, attachmentVerified = false): TaskBoardSnapshot {
664
+ private applyBoardAction(
665
+ requestId: string,
666
+ action: Exclude<TaskBoardAction, { kind: 'extension-action' }>,
667
+ initiator?: string,
668
+ attachmentVerified = false,
669
+ trigger?: TaskBoardLaunchTrigger,
670
+ ): TaskBoardSnapshot {
614
671
  // Attachments reach the ledger only through the VERIFIED action path: the
615
672
  // in-process capability face, the agent tools and the legacy import never
616
673
  // carry them, and an action that does is refused here rather than
@@ -620,7 +677,7 @@ export class TaskBoardHostService {
620
677
  }
621
678
  const before = this.statusMap()
622
679
  if (action.kind === 'run' || action.kind === 'rerun' || action.kind === 'rework') this.assertSpendCap()
623
- const result = this.ledger.applyRequest(requestId, this.withInheritedWorkspace(action, initiator), initiator)
680
+ const result = this.ledger.applyRequest(requestId, this.withInheritedWorkspace(action, initiator), initiator, trigger)
624
681
  if (result.runs !== undefined) this.dispatchRuns(result.runs)
625
682
  // A committed write that can move a rule moves the nearest trigger;
626
683
  // re-arm from the ledger so a created or edited schedule fires at its own
@@ -660,12 +717,20 @@ export class TaskBoardHostService {
660
717
 
661
718
  /** Route one provider action and answer the resulting board snapshot. */
662
719
  private async handleExtensionAction(action: Extract<TaskBoardAction, { kind: 'extension-action' }>): Promise<TaskBoardSnapshot> {
663
- await this.extensions.handleAction({
720
+ const answer = await this.extensions.handleAction({
664
721
  extensionId: action.extensionId,
665
722
  action: action.action,
666
723
  ...(action.taskId === undefined ? {} : { taskId: action.taskId }),
667
724
  ...(action.payload === undefined ? {} : { payload: action.payload }),
668
725
  })
726
+ // Providers that return a structured `{ ok: false, error }` reply instead
727
+ // of throwing still communicate a refusal: turn it into an action error so
728
+ // the HTTP channel and browser `dispatch()` surface the rejection rather
729
+ // than reporting false success.
730
+ if (typeof answer === 'object' && answer !== null && (answer as { ok?: unknown }).ok === false) {
731
+ const reason = (answer as { error?: unknown }).error
732
+ throw new Error(typeof reason === 'string' && reason.trim() !== '' ? reason : `extension "${action.extensionId}" refused action "${action.action}"`)
733
+ }
669
734
  return this.snapshot()
670
735
  }
671
736
 
@@ -737,6 +802,10 @@ export class TaskBoardHostService {
737
802
  // A cron-triggered run additionally states its own firing instant and
738
803
  // rule zone, so a scheduled job can resolve "today" without guessing.
739
804
  const contextParts = {
805
+ // The launch gate's preamble opens the prompt: a provider that keeps the
806
+ // run local states its own context once, ahead of everything the board
807
+ // would have said on this run.
808
+ ...(opened.promptPreamble === undefined ? {} : { launchPreamble: opened.promptPreamble }),
740
809
  ...(descendants.length === 0 ? {} : {
741
810
  descendants: descendants.map(descendant => ({
742
811
  id: descendant.id,
@@ -885,36 +954,106 @@ export class TaskBoardHostService {
885
954
  /**
886
955
  * The session a run may continue in, for a card that opted into reuse
887
956
  * (issue #1419). Reuse requires positive evidence that the previous session
888
- * is present and idle, and that evidence must be read for THIS launch: an
889
- * idle board no longer polls, so a roster cached from an earlier pass could
890
- * be hours old — either refusing a session that has been idle all along, or
891
- * prompting into one that started running since. A card that did not opt in
892
- * reads no roster at all, and a read that fails mints a fresh conversation
893
- * exactly as an unknown roster always did.
957
+ * is present, idle, and not archived, and that evidence must be read for THIS
958
+ * launch: an idle board no longer polls, so a roster cached from an earlier
959
+ * pass could be hours old — either refusing a session that has been idle all
960
+ * along, or prompting into one that started running since. A card that did not
961
+ * opt in reads no roster at all, and a read that fails mints a fresh
962
+ * conversation exactly as an unknown roster always did.
894
963
  * @param task - the task about to run.
895
- * @param force - continue the settled session regardless of the card's own
896
- * opt-in (a rework), which the reuse rule accepts without waiving any of its
897
- * evidence conditions.
898
964
  * @returns the session id to continue in, or undefined for a fresh session.
899
965
  */
900
- private async reuseSessionFor(task: TaskRecord, force?: boolean): Promise<string | undefined> {
901
- if (task.reuseSession !== true && force !== true) return undefined
966
+ private async reuseSessionFor(task: TaskRecord): Promise<string | undefined> {
967
+ if (task.reuseSession !== true) return undefined
968
+ const decision = await this.reuseDecision(task, false)
969
+ if (decision.sessionId !== undefined) return decision.sessionId
970
+ if (decision.archivedSessionId !== undefined) {
971
+ safeConsoleWarn(`[dsh-task-board] session reuse skipped for task ${task.id}: session ${decision.archivedSessionId} is archived, starting a fresh conversation`)
972
+ }
973
+ return undefined
974
+ }
975
+
976
+ /**
977
+ * One reuse decision for this launch: the session to continue in, or nothing
978
+ * plus the reason nothing was chosen, so each caller can report it.
979
+ *
980
+ * Reuse never targets a session in the Workspace registry's archive set
981
+ * (issue #2068). The Host's archived-session gate rejects the first step of a
982
+ * turn in an archived session before any model request is issued, so the
983
+ * run would settle as the opaque failure `agent turn ended without
984
+ * completing: blocked` — the fate of every scheduled run of a card whose
985
+ * conversation the user archived while cleaning the sidebar. Starting a fresh
986
+ * conversation is the only safe answer: archiving is a live user decision,
987
+ * and the board must not unarchive a conversation behind the user's back to
988
+ * keep reusing it.
989
+ * @param task - the task about to run.
990
+ * @param force - reuse without the card's own opt-in (a rework).
991
+ * @returns the reuse decision for this launch.
992
+ */
993
+ private async reuseDecision(task: TaskRecord, force: boolean): Promise<ReuseDecision> {
902
994
  let running: Awaited<ReturnType<HostExecutionRunner['listRunning']>>
903
995
  try {
904
996
  running = await this.runner.listRunning()
905
997
  } catch (error) {
906
- // A read that failed is an unknown roster, and an unknown roster never
907
- // reuses; the launch itself must not fail over the reuse probe.
998
+ // The runner already reports a roster it could not read as an unknown
999
+ // roster, so a throw here is a probe failure rather than an outcome. The
1000
+ // launch must never fail over its own reuse probe: log it neutrally (the
1001
+ // caller decides between a fresh session and a refusal) and reuse nothing.
908
1002
  this.notePollFailure()
909
- safeConsoleError('[dsh-task-board] session roster read for session reuse failed; starting a fresh session', error)
910
- return undefined
1003
+ safeConsoleError('[dsh-task-board] the session reuse probe failed; reuse is skipped for this launch', error)
1004
+ return {}
911
1005
  }
912
- if (!running.known) return undefined
913
- return reusableSessionId(
1006
+ if (!running.known) return {}
1007
+ const archived = this.archivedSessionIds()
1008
+ const sessionId = reusableSessionId(
914
1009
  task,
915
1010
  new Set(running.items.filter(item => !item.running).map(item => item.sessionId)),
916
- force === true ? { force: true } : {},
1011
+ {
1012
+ ...(force ? { force: true } : {}),
1013
+ ...(archived === undefined ? {} : { archivedSessionIds: archived }),
1014
+ },
917
1015
  )
1016
+ if (sessionId !== undefined) return { sessionId }
1017
+ const archivedSessionId = this.archivedReuseTarget(task, archived)
1018
+ return archivedSessionId === undefined ? {} : { archivedSessionId }
1019
+ }
1020
+
1021
+ /**
1022
+ * The archived conversation the reuse rule refused, when it refused one.
1023
+ *
1024
+ * Reuse skipping an archived conversation is otherwise invisible: the board
1025
+ * simply opens a new one, and only the caller knows which outcome it produced.
1026
+ * @param task - the task about to run.
1027
+ * @param archived - the archive set read for this launch, when reported.
1028
+ * @returns the newest settled session id when it is archived, else undefined.
1029
+ */
1030
+ private archivedReuseTarget(task: TaskRecord, archived: ReadonlySet<string> | undefined): string | undefined {
1031
+ if (archived === undefined) return undefined
1032
+ const newest = newestSettledSessionId(task)
1033
+ return newest !== undefined && archived.has(newest) ? newest : undefined
1034
+ }
1035
+
1036
+ /**
1037
+ * The Workspace registry's archive set, or undefined when this deployment's
1038
+ * registry face cannot report one. An unreportable set is unknown evidence,
1039
+ * never proof that nothing is archived: the rule then keeps its pre-archive
1040
+ * behavior instead of inventing a refusal, because a registry face without
1041
+ * the getter serves no archive action for the board to defend against.
1042
+ *
1043
+ * Read per launch rather than cached: archiving is a live user action, and an
1044
+ * idle board no longer polls, so a set kept from an earlier pass could already
1045
+ * claim a session that the user archived a moment ago.
1046
+ * @returns the archived session ids, or undefined when unreportable.
1047
+ */
1048
+ private archivedSessionIds(): ReadonlySet<string> | undefined {
1049
+ try {
1050
+ const archived = this.workspaceRegistry?.archivedSessionIds
1051
+ return archived === undefined ? undefined : new Set(archived)
1052
+ } catch {
1053
+ // A face that throws while reporting its archive set is unreportable, and
1054
+ // a reuse probe never fails the launch it was only advising.
1055
+ return undefined
1056
+ }
918
1057
  }
919
1058
 
920
1059
  /**
@@ -930,9 +1069,11 @@ export class TaskBoardHostService {
930
1069
  * @returns the session id this rework continues in.
931
1070
  */
932
1071
  private async reworkSessionFor(task: TaskRecord): Promise<string> {
933
- const sessionId = await this.reuseSessionFor(task, true)
934
- if (sessionId === undefined) throw new Error(REWORK_SESSION_REASON)
935
- return sessionId
1072
+ const decision = await this.reuseDecision(task, true)
1073
+ if (decision.sessionId !== undefined) return decision.sessionId
1074
+ throw new Error(decision.archivedSessionId === undefined
1075
+ ? REWORK_SESSION_REASON
1076
+ : reworkArchivedReason(decision.archivedSessionId))
936
1077
  }
937
1078
 
938
1079
  /** Reuse the session list this poll already fetched: one list RPC per tick, not 1 + E. */
@@ -1270,3 +1411,15 @@ export function safeConsoleError(message: string, ...args: unknown[]): void {
1270
1411
  // Best-effort stderr write; ignore write errors when stderr stream fails
1271
1412
  }
1272
1413
  }
1414
+
1415
+ /**
1416
+ * Defensively log to console.warn, for a diagnostic that must never turn a
1417
+ * launch decision into a failed run when the stderr write itself fails.
1418
+ */
1419
+ function safeConsoleWarn(message: string, ...args: unknown[]): void {
1420
+ try {
1421
+ console.warn(message, ...args)
1422
+ } catch {
1423
+ // Best-effort stderr write; ignore write errors when stderr stream fails
1424
+ }
1425
+ }
package/src/protocol.ts CHANGED
@@ -98,6 +98,13 @@ export interface TaskBoardSnapshot {
98
98
  * The board forwards them verbatim; it never interprets their shape.
99
99
  */
100
100
  extensions?: Record<string, unknown>
101
+ /**
102
+ * Monotonic counter bumped whenever any extension publishes, updates, or
103
+ * withdraws its summary. Carried on both full snapshots and SSE frames so
104
+ * browsers refetch `/state` when a provider publishes without touching the
105
+ * task ledger revision.
106
+ */
107
+ extensionsRevision?: number
101
108
  /**
102
109
  * The attachment limits this deployment enforces, so the browser can refuse
103
110
  * an oversized selection before it uploads anything. The board's own caps
@@ -130,9 +137,10 @@ export interface TaskBoardModelCatalog {
130
137
  catalog: ModelCatalogView
131
138
  }
132
139
 
133
- /** SSE event frame: revision/scheduler/power only, never the task list. */
140
+ /** SSE event frame: revision/scheduler/power (plus extension summary revision), never the task list. */
134
141
  export interface TaskBoardEventPayload {
135
142
  revision: number
143
+ extensionsRevision?: number
136
144
  scheduler: TaskBoardSchedulerSnapshot
137
145
  power: TaskBoardPowerSnapshot
138
146
  }
@@ -188,7 +196,22 @@ export type TaskBoardAction =
188
196
  * `cancelled` is deliberately absent: nothing outside a DSH session may
189
197
  * claim the Host closed a run, and `running` must stay Host-only.
190
198
  */
191
- | { kind: 'record-external-outcome'; taskId: string; result: 'succeeded' | 'failed'; initiatedBy: string; summary?: string }
199
+ | {
200
+ kind: 'record-external-outcome'
201
+ taskId: string
202
+ result: 'succeeded' | 'failed'
203
+ initiatedBy: string
204
+ /** Success: stored as the execution summary. Failure: stored as the error text. */
205
+ summary?: string
206
+ /** Id the execution record takes, so a handle returned at launch stays valid. */
207
+ executionId?: string
208
+ /** Instant the outside run started (ms epoch); the record starts there instead of at settlement. */
209
+ startedAt?: number
210
+ /** Failure only: stable machine-readable code. */
211
+ errorCode?: string
212
+ /** Failure only: one line on whether and how to retry. */
213
+ retryHint?: string
214
+ }
192
215
  | { kind: 'set-schedule'; taskId: string; patch: SetSchedulePatch }
193
216
  | { kind: 'run'; taskId: string }
194
217
  | { kind: 'rerun'; taskId: string }
@@ -576,7 +599,7 @@ function parseEnvelopeAction(value: unknown): TaskBoardActionEnvelope | undefine
576
599
  }
577
600
  }
578
601
  case 'record-external-outcome': {
579
- if (!exactKeys(action, ['kind', 'taskId', 'result', 'initiatedBy', 'summary'])) return undefined
602
+ if (!exactKeys(action, ['kind', 'taskId', 'result', 'initiatedBy', 'summary', 'executionId', 'startedAt', 'errorCode', 'retryHint'])) return undefined
580
603
  if (taskId === undefined) return undefined
581
604
  // Only a real outside verdict is accepted: `running` is Host-only and
582
605
  // `cancelled` is the Host's own bookkeeping for a run it closed.
@@ -588,6 +611,13 @@ function parseEnvelopeAction(value: unknown): TaskBoardActionEnvelope | undefine
588
611
  if (initiatedBy === '' || initiatedBy.length > EXTERNAL_INITIATOR_MAX_LENGTH) return undefined
589
612
  if (action.summary !== undefined && typeof action.summary !== 'string') return undefined
590
613
  const summary = typeof action.summary === 'string' ? action.summary.trim().slice(0, EXTERNAL_SUMMARY_MAX_LENGTH) : ''
614
+ if (action.executionId !== undefined && (typeof action.executionId !== 'string' || action.executionId === '' || action.executionId.length > 128)) return undefined
615
+ if (action.startedAt !== undefined && (typeof action.startedAt !== 'number' || !Number.isFinite(action.startedAt) || action.startedAt < 0)) return undefined
616
+ for (const key of ['errorCode', 'retryHint'] as const) {
617
+ if (action[key] !== undefined && typeof action[key] !== 'string') return undefined
618
+ }
619
+ const errorCode = typeof action.errorCode === 'string' ? action.errorCode.trim().slice(0, 64) : ''
620
+ const retryHint = typeof action.retryHint === 'string' ? action.retryHint.trim().slice(0, EXTERNAL_SUMMARY_MAX_LENGTH) : ''
591
621
  return {
592
622
  requestId: envelope.requestId,
593
623
  action: {
@@ -596,6 +626,10 @@ function parseEnvelopeAction(value: unknown): TaskBoardActionEnvelope | undefine
596
626
  result: action.result,
597
627
  initiatedBy,
598
628
  ...(summary === '' ? {} : { summary }),
629
+ ...(action.executionId === undefined ? {} : { executionId: action.executionId as string }),
630
+ ...(action.startedAt === undefined ? {} : { startedAt: action.startedAt as number }),
631
+ ...(errorCode === '' ? {} : { errorCode }),
632
+ ...(retryHint === '' ? {} : { retryHint }),
599
633
  },
600
634
  }
601
635
  }