@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.
Files changed (125) hide show
  1. package/NOTICE +1 -1
  2. package/README.en.md +6 -4
  3. package/README.md +6 -4
  4. package/README.zh.md +6 -4
  5. package/icon.png +0 -0
  6. package/lib/client.js +4428 -1508
  7. package/lib/client.js.map +1 -1
  8. package/lib/index.js +2670 -496
  9. package/lib/types/client/CardDefaultPresetField.d.ts +35 -0
  10. package/lib/types/client/PluginSettingsCard.d.ts +130 -19
  11. package/lib/types/client/RangeBubble.d.ts +46 -0
  12. package/lib/types/client/SegmentGroup.d.ts +28 -0
  13. package/lib/types/client/TaskBoardSettingsCard.d.ts +63 -0
  14. package/lib/types/client/board/AttachmentField.d.ts +70 -0
  15. package/lib/types/client/board/ExecutionLog.d.ts +24 -0
  16. package/lib/types/client/board/ReasoningEffortField.d.ts +25 -0
  17. package/lib/types/client/board/TaskForm.d.ts +4 -0
  18. package/lib/types/client/board/VerificationReport.d.ts +2 -15
  19. package/lib/types/client/board/model-options.d.ts +87 -0
  20. package/lib/types/client/board/preset-label.d.ts +21 -0
  21. package/lib/types/client/board/preset-roster.d.ts +45 -0
  22. package/lib/types/client/board/source-group.d.ts +27 -0
  23. package/lib/types/client/body-mutations.d.ts +45 -0
  24. package/lib/types/client/host-api.d.ts +25 -0
  25. package/lib/types/client/locales.d.ts +87 -9
  26. package/lib/types/client/pending-verify.d.ts +47 -0
  27. package/lib/types/client/plugin-card-seat.d.ts +3 -1
  28. package/lib/types/client/service.d.ts +4 -1
  29. package/lib/types/client/settings-form.d.ts +73 -51
  30. package/lib/types/core/attachment.d.ts +132 -0
  31. package/lib/types/core/card-defaults.d.ts +78 -0
  32. package/lib/types/core/controller.d.ts +57 -8
  33. package/lib/types/core/execution-summary.d.ts +52 -0
  34. package/lib/types/core/extension.d.ts +116 -0
  35. package/lib/types/core/launch-width.d.ts +31 -0
  36. package/lib/types/core/reasoning-effort.d.ts +57 -0
  37. package/lib/types/core/session-reuse.d.ts +7 -1
  38. package/lib/types/core/spend-budget.d.ts +28 -0
  39. package/lib/types/core/subtask.d.ts +100 -37
  40. package/lib/types/core/tasks.d.ts +94 -10
  41. package/lib/types/core/use-cases/task-create.d.ts +10 -5
  42. package/lib/types/core/use-cases/task-tag.d.ts +36 -0
  43. package/lib/types/core/use-cases/task-update.d.ts +22 -1
  44. package/lib/types/core/wire-projection.d.ts +35 -0
  45. package/lib/types/core/workspace-target.d.ts +23 -3
  46. package/lib/types/host/attachments.d.ts +250 -0
  47. package/lib/types/host/extension-registry.d.ts +40 -0
  48. package/lib/types/host/launch-admission.d.ts +71 -0
  49. package/lib/types/host-ledger.d.ts +114 -47
  50. package/lib/types/host-routes.d.ts +63 -0
  51. package/lib/types/host-runner.d.ts +164 -18
  52. package/lib/types/host-service.d.ts +182 -46
  53. package/lib/types/host-spend.d.ts +52 -0
  54. package/lib/types/index.d.ts +173 -54
  55. package/lib/types/loopback.d.ts +41 -1
  56. package/lib/types/protocol.d.ts +52 -11
  57. package/lib/types/tool-surface.d.ts +1 -0
  58. package/locale/en.json +6 -0
  59. package/locale/zh.json +6 -0
  60. package/package.json +36 -29
  61. package/src/client/CardDefaultPresetField.tsx +101 -0
  62. package/src/client/PluginSettingsCard.tsx +385 -111
  63. package/src/client/RangeBubble.tsx +164 -0
  64. package/src/client/SegmentGroup.tsx +93 -0
  65. package/src/client/TaskBoardSettingsCard.tsx +332 -37
  66. package/src/client/board/AttachmentField.tsx +383 -0
  67. package/src/client/board/EditTaskModal.tsx +63 -0
  68. package/src/client/board/ExecutionLog.tsx +154 -0
  69. package/src/client/board/LinkSubtaskModal.tsx +1 -1
  70. package/src/client/board/NewTaskModal.tsx +154 -45
  71. package/src/client/board/ReasoningEffortField.tsx +50 -0
  72. package/src/client/board/TagManagerModal.tsx +151 -2
  73. package/src/client/board/TaskBoard.tsx +47 -10
  74. package/src/client/board/TaskCard.tsx +45 -23
  75. package/src/client/board/TaskDetail.tsx +468 -258
  76. package/src/client/board/TaskForm.tsx +19 -4
  77. package/src/client/board/VerificationReport.tsx +143 -104
  78. package/src/client/board/model-options.ts +208 -0
  79. package/src/client/board/preset-label.ts +32 -0
  80. package/src/client/board/preset-roster.ts +58 -0
  81. package/src/client/board/source-group.ts +94 -0
  82. package/src/client/board/task-markdown.module.css +11 -8
  83. package/src/client/board-settings.module.css +35 -7
  84. package/src/client/board.module.css +1044 -105
  85. package/src/client/body-mutations.ts +133 -0
  86. package/src/client/host-api.ts +70 -0
  87. package/src/client/index.ts +109 -95
  88. package/src/client/locales.ts +205 -48
  89. package/src/client/pending-verify.ts +90 -0
  90. package/src/client/plugin-card-seat.ts +8 -2
  91. package/src/client/service.ts +24 -0
  92. package/src/client/settings-card.module.css +466 -89
  93. package/src/client/settings-entry-form.ts +0 -1
  94. package/src/client/settings-form.ts +102 -60
  95. package/src/core/attachment.ts +287 -0
  96. package/src/core/card-defaults.ts +132 -0
  97. package/src/core/controller.ts +90 -11
  98. package/src/core/execution-summary.ts +96 -0
  99. package/src/core/extension.ts +120 -0
  100. package/src/core/launch-width.ts +38 -0
  101. package/src/core/reasoning-effort.ts +92 -0
  102. package/src/core/session-reuse.ts +7 -1
  103. package/src/core/spend-budget.ts +35 -0
  104. package/src/core/store.ts +19 -1
  105. package/src/core/subtask.ts +144 -68
  106. package/src/core/tasks.ts +117 -10
  107. package/src/core/use-cases/task-create.ts +27 -16
  108. package/src/core/use-cases/task-tag.ts +56 -0
  109. package/src/core/use-cases/task-update.ts +33 -5
  110. package/src/core/wire-projection.ts +81 -0
  111. package/src/core/workspace-target.ts +27 -3
  112. package/src/host/agent-tools.ts +33 -21
  113. package/src/host/attachments.ts +650 -0
  114. package/src/host/extension-registry.ts +150 -5
  115. package/src/host/launch-admission.ts +139 -0
  116. package/src/host-ledger.ts +248 -117
  117. package/src/host-routes.ts +233 -15
  118. package/src/host-runner.ts +395 -61
  119. package/src/host-service.ts +512 -139
  120. package/src/host-spend.ts +105 -0
  121. package/src/index.ts +312 -92
  122. package/src/loopback.ts +57 -1
  123. package/src/protocol.ts +83 -18
  124. package/src/tool-surface.ts +1 -0
  125. package/icon.svg +0 -3
@@ -1,41 +1,15 @@
1
1
  import type { TypertGateway } from '@deepseek-ai/dsh-api-gateway';
2
- import type { PeerScope } from '@deepseek-ai/dsh-client-connection';
3
2
  import { HostTaskLedger } from './host-ledger.ts';
4
- import { HostExecutionRunner, type SessionCommandDispatcher, type TaskBoardWorkspaceRegistry } from './host-runner.ts';
3
+ import { HostExecutionRunner, type GatewayPeer, type SessionCommandDispatcher, type TaskBoardWorkspaceRegistry } from './host-runner.ts';
5
4
  import { PowerInhibitor } from './power-inhibitor.ts';
6
5
  import { type TaskBoardAction, type TaskBoardEventPayload, type TaskBoardSnapshot } from './protocol.ts';
6
+ import type { CardDefaults } from './core/card-defaults.ts';
7
7
  import { TaskBoardExtensionRegistry } from './host/extension-registry.ts';
8
8
  import type { TaskBoardExtension } from './core/extension.ts';
9
- import type { ScheduleMode } from './core/tasks.ts';
9
+ import { type ScheduleMode } from './core/tasks.ts';
10
10
  import { type ModelCatalogView, type VerificationContract, type VerificationSettings } from './core/verification.ts';
11
11
  import type { TaskPermission } from './core/handover.ts';
12
- /** One teammate the Host asks the Agent Teams service to spawn for a team run. */
13
- export interface TeamSpawnInput {
14
- /** Session id of the run's Team Lead (the root task's execution session). */
15
- leadSessionId: string;
16
- /** Immutable lower-kebab-case teammate name, unique inside the Team. */
17
- name: string;
18
- /** Short description of the delegated responsibility. */
19
- description: string;
20
- /** The subtask's execution prompt. */
21
- prompt: string;
22
- }
23
- /** Result of one teammate spawn attempt. */
24
- export interface TeamSpawnResult {
25
- /** The teammate's session id when it reached the active edge. */
26
- sessionId?: string;
27
- /** Why the spawn failed: a thrown call, or a member that settled as failed. */
28
- error?: string;
29
- }
30
- /**
31
- * The Agent Teams capability the Host needs for team-mode runs. The plugin
32
- * builds it from the optional `agentTeams` service; it is absent when this
33
- * deployment does not serve that service, in which case a team run is refused
34
- * instead of silently degrading into a plain cascade.
35
- */
36
- export interface TaskBoardTeamDispatcher {
37
- spawn(input: TeamSpawnInput): Promise<TeamSpawnResult>;
38
- }
12
+ import { type ModelInfoResolver, type TaskBoardAttachmentStore } from './host/attachments.ts';
39
13
  /**
40
14
  * Why an enforced goal execution settled failed while its acceptance DID run:
41
15
  * attempts were recorded and none of them passed. The judge answered about the
@@ -61,7 +35,7 @@ export declare const NEVER_INVOKED_VERIFICATION_REASON = "goal \u9A8C\u6536\u672
61
35
  */
62
36
  export declare const INVALID_ONLY_VERIFICATION_REASON = "goal \u9A8C\u6536\u65E0\u6548\uFF1A\u672C\u6B21\u6267\u884C\u53EA\u8BB0\u5F55\u4E86\u65E0\u6548\u9A8C\u6536\uFF08\u88C1\u5224\u672A\u80FD\u7ED9\u51FA\u4E0E\u4EFB\u52A1\u8981\u6C42\u5BF9\u5E94\u3001\u4E14\u53EF\u5B9A\u4F4D\u5230\u672C\u6B21\u8BC1\u636E\u7684\u5426\u51B3\u4F9D\u636E\uFF09\uFF0C\u770B\u677F\u5DF2\u505C\u6B62\u8C03\u7528\u88C1\u5224\u3002\u8FD9**\u4E0D\u662F**\u6709\u8BC1\u636E\u7684\u8D28\u91CF\u5224\u8D1F\uFF1A\u9A8C\u6536\u672C\u8EAB\u4E0D\u53EF\u7528\uFF0C\u672C\u6B21\u8FD0\u884C\u56E0\u6CA1\u6709\u5339\u914D\u7684\u901A\u8FC7\u8BB0\u5F55\u800C\u7ED3\u675F\u3002\u8BF7\u68C0\u67E5\u9A8C\u6536\u73AF\u5883\u4E0E\u8BC1\u636E\u53EF\u89C1\u6027\uFF0C\u6216\u7528 task_board_manage(action=reset-verification) \u6E05\u9664\u8BB0\u5F55\u7684\u65E0\u6548\u9A8C\u6536\u540E\u91CD\u65B0\u5B8C\u6210\u76EE\u6807\u3002";
63
37
  /**
64
- * Provenance of one cron-triggered cascade: when the rule fired and the zone
38
+ * Provenance of one cron-triggered run: when the rule fired and the zone
65
39
  * its wall clock was read in. Passed into every launched prompt of that run so
66
40
  * a scheduled job knows its own clock rather than inferring one.
67
41
  */
@@ -88,6 +62,8 @@ export declare class TaskBoardHostService {
88
62
  readonly ledger: HostTaskLedger;
89
63
  readonly runner: HostExecutionRunner;
90
64
  readonly power: PowerInhibitor;
65
+ /** The official attachment storage, read live so a late mount is honoured. */
66
+ private readonly attachmentStore;
91
67
  private readonly listeners;
92
68
  /** The one recurring timer: the session-roster poll. */
93
69
  private pollTimer;
@@ -104,6 +80,12 @@ export declare class TaskBoardHostService {
104
80
  private disposed;
105
81
  private pollInFlight;
106
82
  private active;
83
+ /**
84
+ * Admission control for the session-creating half of a run: one board action
85
+ * opens a whole subtree, and this is what keeps the Host from asking DSH for
86
+ * every member's session at once (see {@link LaunchAdmissionQueue}).
87
+ */
88
+ private readonly launches;
107
89
  /**
108
90
  * Consecutive unreadable-history polls per open execution (see
109
91
  * {@link noteUnreadableInspection}). Cleared as soon as an inspection
@@ -113,10 +95,24 @@ export declare class TaskBoardHostService {
113
95
  private preventIdleSleep;
114
96
  private readonly verificationSettings;
115
97
  private readonly verificationCatalog;
116
- private readonly team;
117
98
  private readonly timers;
118
99
  /** Live reader of the global native-/goal switch; frozen per execution. */
119
100
  private readonly goalRunEnabled;
101
+ /** Live reader of the deployment's new-card defaults (published and applied per create). */
102
+ private readonly cardDefaults;
103
+ /**
104
+ * Live reader of the run-launch admission width: how many launches may be in
105
+ * flight at once. Read at every admission, so a settings edit bounds the next
106
+ * launch without remounting the row. Absent means the default.
107
+ */
108
+ private readonly runLaunchWidth;
109
+ /**
110
+ * Live reader of the daily token cap; 0 means no gate. Read at each run
111
+ * action, so closing or raising the cap binds the next action.
112
+ */
113
+ private readonly spendBudgetTokens;
114
+ /** Today's measured spend: absent measurement reads as "cannot see", never as zero. */
115
+ private readonly spendUsedToday;
120
116
  private lastPowerJson;
121
117
  private readonly now;
122
118
  /** The deployment's workspaces, consulted to resolve a card that pins none. */
@@ -133,13 +129,26 @@ export declare class TaskBoardHostService {
133
129
  now?: () => number;
134
130
  commandDispatcher?: SessionCommandDispatcher;
135
131
  workspaceRegistry?: TaskBoardWorkspaceRegistry;
132
+ /**
133
+ * The owner peer every gateway request the runner makes speaks for.
134
+ * Production passes the peer bound to the plugin fiber (see
135
+ * {@link createOwnerPeer}); absent is fine for tests and bare mounts,
136
+ * where the runner binds one to a fresh root context.
137
+ */
138
+ ownerPeer?: GatewayPeer;
136
139
  /**
137
140
  * Permission baseline of the confirmation gate: a fixed value, or a live
138
141
  * resolver the board re-reads so a Host Settings change needs no remount.
139
142
  */
140
143
  sessionDefaultPermission?: TaskPermission | (() => TaskPermission);
141
144
  maxSubtaskDepth?: number;
142
- team?: TaskBoardTeamDispatcher;
145
+ /**
146
+ * Live reader of the deployment's new-card defaults (volatile config reads).
147
+ * The board publishes them for the create dialog and re-reads them for every
148
+ * create that opts in, so a settings edit reaches the next created card
149
+ * without remounting the row. Absent means the deployment configures none.
150
+ */
151
+ cardDefaults?: () => CardDefaults;
143
152
  timers?: HostTimerFace;
144
153
  /**
145
154
  * Live GLOBAL native /goal switch (a volatile config read). Read ONCE per
@@ -157,7 +166,45 @@ export declare class TaskBoardHostService {
157
166
  verificationSettings?: () => VerificationSettings;
158
167
  /** The host model catalog the acceptance contract resolves its route from. */
159
168
  verificationCatalog?: () => Promise<ModelCatalogView | undefined>;
160
- operatorPeer?: () => PeerScope | undefined;
169
+ /**
170
+ * Live admission width for run launches: the number of launches (one
171
+ * session creation and its prompt each) that may be in flight at once. Read
172
+ * per admission, so editing the setting bounds the next launch of a run that
173
+ * is still queueing. Absent means the default width.
174
+ */
175
+ runLaunchWidth?: () => number;
176
+ /**
177
+ * Live daily token cap (a volatile config read). 0 — the default, and what
178
+ * every deployment that never configured one keeps — ends the gate before
179
+ * anything is measured. A positive cap refuses a run whose day already spent
180
+ * it, on both the action path and the cron path.
181
+ */
182
+ spendBudgetTokens?: () => number;
183
+ /**
184
+ * Today's measured spend in tokens, or undefined when this deployment keeps
185
+ * no readable usage ledger. Defaults to the family usage ledger reader.
186
+ */
187
+ spendUsedToday?: (now: number) => number | undefined;
188
+ /**
189
+ * The official attachment storage, read at request time. Absent means the
190
+ * deployment stores no attachments: every attachment action is then
191
+ * refused and the board publishes no attachment limits.
192
+ */
193
+ attachments?: () => TaskBoardAttachmentStore | undefined;
194
+ /**
195
+ * The model-info reader the image preflight uses. Absent means the
196
+ * deployment serves no model information, and a route whose modalities are
197
+ * unknown is allowed.
198
+ */
199
+ modelInfo?: () => ModelInfoResolver | undefined;
200
+ /**
201
+ * Whether this deployment runs the legacy Agent Teams runtime. Read at
202
+ * launch, only for a run the board is about to force under the dispatcher
203
+ * preset: such a deployment cannot orchestrate, so the run fails closed on
204
+ * the card instead of deadlocking in a session nobody answers (issue #2031).
205
+ * Absent means "not proven legacy", which keeps the force exactly as it is.
206
+ */
207
+ legacyAgentTeams?: () => boolean;
161
208
  });
162
209
  start(): void;
163
210
  /**
@@ -170,6 +217,15 @@ export declare class TaskBoardHostService {
170
217
  * @param sessionPollSeconds - roster-poll cadence in seconds (clamped).
171
218
  */
172
219
  setConfiguration(active: boolean, preventIdleSleep: boolean, sessionPollSeconds?: number): void;
220
+ /**
221
+ * The board's published snapshot.
222
+ *
223
+ * Every read path serializes this object — the HTTP `state` answer, the
224
+ * `action` answer through {@link apply}, and the remote bridge's
225
+ * `board.snapshot` — so a provider's integration credentials are stripped
226
+ * once, here, instead of at each exit. The ledger keeps them verbatim for the
227
+ * provider's own in-process read.
228
+ */
173
229
  snapshot(): TaskBoardSnapshot;
174
230
  /**
175
231
  * Admit one external provider. Idempotent by extension id; the returned
@@ -211,6 +267,25 @@ export declare class TaskBoardHostService {
211
267
  * @returns the action, with an inherited workspace on a root creation.
212
268
  */
213
269
  private withInheritedWorkspace;
270
+ /**
271
+ * Apply an action whose attachments the Host proved against the official
272
+ * storage first.
273
+ *
274
+ * This is the board's trust boundary for attachment metadata: the browser
275
+ * asserts the size, the type and the digest of every object it uploaded, and
276
+ * the Host reads the stored objects back (an image is compared, a file is
277
+ * streamed and its digest recomputed) before the ledger commits the claim.
278
+ * An attachment the storage cannot prove is refused, so a spoofed client
279
+ * claim never becomes a stored fact.
280
+ */
281
+ applyVerified(requestId: string, action: TaskBoardAction, initiator?: string): Promise<TaskBoardSnapshot>;
282
+ /**
283
+ * Prove every attachment of an action against the official storage.
284
+ *
285
+ * An action without attachments is untouched: the board keeps working in a
286
+ * deployment that serves no attachment storage at all.
287
+ */
288
+ private verifyActionAttachments;
214
289
  apply(requestId: string, action: Extract<TaskBoardAction, {
215
290
  kind: 'extension-action';
216
291
  }>, initiator?: string): Promise<TaskBoardSnapshot>;
@@ -224,6 +299,18 @@ export declare class TaskBoardHostService {
224
299
  * never disagree about a card.
225
300
  */
226
301
  private applyBoardAction;
302
+ /**
303
+ * Refuse a run whose day already spent the cap.
304
+ *
305
+ * A cap of 0 — the shipped default — answers before the measurement is read:
306
+ * no ledger file is opened and nothing is summed, which is what keeps a board
307
+ * that never configured a cap identical to the one before it existed.
308
+ *
309
+ * The refusal is a thrown message rather than a code: the wire hands its text
310
+ * to the caller as board-refused, exactly like every other refusal this board
311
+ * makes.
312
+ */
313
+ private assertSpendCap;
227
314
  /** Route one provider action and answer the resulting board snapshot. */
228
315
  private handleExtensionAction;
229
316
  /** Current task id -> status map, for change detection around a mutation. */
@@ -232,15 +319,26 @@ export declare class TaskBoardHostService {
232
319
  private emitStatusChanges;
233
320
  dispose(): void;
234
321
  private launch;
235
- private scheduleTeammate;
236
322
  /**
237
- * Spawn one teammate inside the Lead session and attach the teammate's
238
- * session to the subtask execution, so the existing session monitor settles
239
- * it from the teammate's own turn like any other execution. A spawn that
240
- * fails settles the subtask as failed immediately, which then folds into the
241
- * Lead's cascade verdict.
323
+ * Read the acceptance contract one run group freezes, in the order the board
324
+ * has always read it: the acceptance settings, then the global native-/goal
325
+ * switch, then the model catalog that both resolves the contract's route and
326
+ * decides the reasoning effort the session may be given.
242
327
  */
243
- private spawnTeammate;
328
+ private freezeRunContract;
329
+ /**
330
+ * A {@link RunContractFreezer} that reads once and hands the SAME value to
331
+ * every later caller of one run group. A read that fails is not cached: the
332
+ * next member reads again, exactly as a per-execution read would have.
333
+ */
334
+ private contractFreezerForRunGroup;
335
+ /**
336
+ * Give back the occurrence a launch consumed, for a launch that never reached
337
+ * a session: a failed launch, or one the Host abandoned while it was still
338
+ * waiting for an admission slot. A manual run, and a launch that DID reach a
339
+ * session, are never refunded.
340
+ */
341
+ private refundUnstartedSchedule;
244
342
  /**
245
343
  * One roster pass, and whether it could read the session tree.
246
344
  *
@@ -264,9 +362,25 @@ export declare class TaskBoardHostService {
264
362
  * reads no roster at all, and a read that fails mints a fresh conversation
265
363
  * exactly as an unknown roster always did.
266
364
  * @param task - the task about to run.
365
+ * @param force - continue the settled session regardless of the card's own
366
+ * opt-in (a rework), which the reuse rule accepts without waiving any of its
367
+ * evidence conditions.
267
368
  * @returns the session id to continue in, or undefined for a fresh session.
268
369
  */
269
370
  private reuseSessionFor;
371
+ /**
372
+ * The session a rework continues, or the refusal that says why it cannot.
373
+ *
374
+ * A rework exists for one conversation — the one the reviewer read before
375
+ * sending the work back — so the evidence that this Host still reaches it is
376
+ * required, exactly as it is for a card that opted into reuse. What a rework
377
+ * does NOT get is the fresh-conversation fallback: launching there would hand
378
+ * the reviewer's instructions to an agent that never saw the work, so the run
379
+ * fails with a readable reason instead.
380
+ * @param task - the card being reworked.
381
+ * @returns the session id this rework continues in.
382
+ */
383
+ private reworkSessionFor;
270
384
  /** Reuse the session list this poll already fetched: one list RPC per tick, not 1 + E. */
271
385
  private reconcileExecutions;
272
386
  /**
@@ -332,11 +446,13 @@ export declare class TaskBoardHostService {
332
446
  private onScheduleFire;
333
447
  private armedSchedules;
334
448
  /**
335
- * Launch one run set. The root goes first and receives the run shape in its
336
- * prompt (which members this run opens, and how they run); every plain-cascade
337
- * member then launches on its own so one refused participant cannot hold the
338
- * others back. A team run's members are spawned inside the root's Lead
339
- * session instead, once that session exists.
449
+ * Launch the one run a run request opened. A run request names one card and
450
+ * opens one execution for it; the card's own session dispatches its subtasks
451
+ * as subagents, so nothing else is enqueued here.
452
+ *
453
+ * The launch still goes through the admission queue, which admits at most
454
+ * `runLaunchWidth` launches at a time — that bound now applies across
455
+ * concurrent runs rather than across the members of one run.
340
456
  */
341
457
  private dispatchRuns;
342
458
  /**
@@ -345,6 +461,26 @@ export declare class TaskBoardHostService {
345
461
  */
346
462
  private setApplicability;
347
463
  private scheduleLaunch;
464
+ /**
465
+ * Hand one launch to the admission queue, or abandon it on the spot when the
466
+ * Host is already stopping: a queue entry created after {@link dispose} would
467
+ * otherwise never be drained, and its card would sit in the running column
468
+ * until the next Host start recovered it.
469
+ */
470
+ private enqueueLaunch;
471
+ /** Whether one opened execution is still open in the ledger. */
472
+ private isExecutionOpen;
473
+ /**
474
+ * Take one launch that never started out of the running column.
475
+ *
476
+ * Settled as CANCELLED, not failed: nothing about the run's work went wrong —
477
+ * the Host stopped before the launch got a slot, which is exactly what the
478
+ * next start's interrupted-start recovery records for an execution that never
479
+ * reached a session. A scheduled occurrence that never reached a session is
480
+ * refunded on the same terms as any other pre-session failure, so a run the
481
+ * Host never started cannot silently spend the user's run budget.
482
+ */
483
+ private abandonQueuedRun;
348
484
  private schedulePoll;
349
485
  /**
350
486
  * Count one failed pass and arm the retry that follows it.
@@ -0,0 +1,52 @@
1
+ /**
2
+ * Today's measured spend, read from the usage ledger this deployment keeps at
3
+ * `$DSH_HOME/dsh-usage/usage-ledger.json`.
4
+ *
5
+ * The measure is the family usage ledger rather than a counter this plugin
6
+ * accumulates from `session/event`, for two reasons. The ledger is durable, so
7
+ * a cap cannot be reset by restarting the Host (the Loader remounts a row on
8
+ * any config change, and a spend counter that lived only in memory would forget
9
+ * the day). And a second fold of the same events inside the board would have to
10
+ * persist its own totals to be worth anything, which means a second writer of
11
+ * spend state in one process.
12
+ *
13
+ * What that costs: the file belongs to the dsh-usage plugin, so a deployment
14
+ * that does not mount it keeps no ledger and the cap cannot measure anything.
15
+ * That case is reported once per process and the gate then refuses nothing —
16
+ * wedging the board because a sibling plugin is absent would be worse than a
17
+ * cap that says it cannot see. The 3 s flush debounce of that plugin is the
18
+ * other cost: the reading trails the busiest moments by at most one debounce.
19
+ * @module @fish-under-sea/dsh-client-ui-task-board-fish/host-spend
20
+ */
21
+ /**
22
+ * Local-date key (`YYYY-MM-DD`) of an instant, the bucketing the usage ledger
23
+ * itself uses: the cap and the usage panel therefore roll over at the same
24
+ * local midnight.
25
+ * @param ms - clock instant (ms epoch).
26
+ * @returns the day key.
27
+ */
28
+ export declare function spendDateKey(ms: number): string;
29
+ /**
30
+ * Total tokens one ledger day recorded, across every provider and model of that
31
+ * day. Anything that is not a finite token count contributes 0, so a ledger
32
+ * written by another version degrades to a smaller reading instead of NaN.
33
+ * @param day - one day bucket as the ledger stores it, when it is one.
34
+ * @returns the day's token total.
35
+ */
36
+ export declare function ledgerDayTokens(day: unknown): number;
37
+ /**
38
+ * Path of the usage ledger for this DSH home.
39
+ * @returns the absolute ledger path.
40
+ */
41
+ export declare function spendLedgerPath(): string;
42
+ /**
43
+ * Tokens already spent today, or undefined when no measurement is available.
44
+ *
45
+ * Undefined is "cannot see", not "spent nothing": the caller fails open and
46
+ * reports it, because a spend cap that cannot read its own source must never
47
+ * decide that no work may run.
48
+ * @param now - clock instant (ms epoch).
49
+ * @param path - ledger path (test seam).
50
+ * @returns today's token total, or undefined when the ledger is unreadable.
51
+ */
52
+ export declare function usedTokensToday(now?: number, path?: string): number | undefined;