@fish-under-sea/dsh-client-ui-task-board-fish 2.2.2 → 2.3.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 (104) hide show
  1. package/README.en.md +4 -4
  2. package/package.json +5 -4
  3. package/README.i18n.yaml +0 -6
  4. package/README.md +0 -31
  5. package/README.zh.md +0 -31
  6. package/lib/client.js +0 -15861
  7. package/lib/client.js.map +0 -1
  8. package/lib/index.js +0 -12653
  9. package/lib/types/client/CardDefaultPresetField.d.ts +0 -35
  10. package/lib/types/client/PluginSettingsCard.d.ts +0 -255
  11. package/lib/types/client/RangeBubble.d.ts +0 -46
  12. package/lib/types/client/SegmentGroup.d.ts +0 -28
  13. package/lib/types/client/TaskBoardSettingsCard.d.ts +0 -155
  14. package/lib/types/client/apply-guard.d.ts +0 -25
  15. package/lib/types/client/board/AttachmentField.d.ts +0 -70
  16. package/lib/types/client/board/ClampedMarkdown.d.ts +0 -3
  17. package/lib/types/client/board/ConfirmDialog.d.ts +0 -15
  18. package/lib/types/client/board/EditTaskModal.d.ts +0 -17
  19. package/lib/types/client/board/ExecutionLog.d.ts +0 -24
  20. package/lib/types/client/board/LinkSubtaskModal.d.ts +0 -14
  21. package/lib/types/client/board/NewTaskModal.d.ts +0 -26
  22. package/lib/types/client/board/ReasoningEffortField.d.ts +0 -25
  23. package/lib/types/client/board/TagManagerModal.d.ts +0 -26
  24. package/lib/types/client/board/TaskBoard.d.ts +0 -26
  25. package/lib/types/client/board/TaskCard.d.ts +0 -36
  26. package/lib/types/client/board/TaskDetail.d.ts +0 -9
  27. package/lib/types/client/board/TaskForm.d.ts +0 -76
  28. package/lib/types/client/board/VerificationReport.d.ts +0 -10
  29. package/lib/types/client/board/card-view.d.ts +0 -113
  30. package/lib/types/client/board/icons.d.ts +0 -32
  31. package/lib/types/client/board/model-options.d.ts +0 -87
  32. package/lib/types/client/board/overlay.d.ts +0 -69
  33. package/lib/types/client/board/parse-model-pref.d.ts +0 -4
  34. package/lib/types/client/board/preset-label.d.ts +0 -43
  35. package/lib/types/client/board/preset-roster.d.ts +0 -45
  36. package/lib/types/client/board/source-group.d.ts +0 -27
  37. package/lib/types/client/board/status-key.d.ts +0 -19
  38. package/lib/types/client/board/task-markdown.d.ts +0 -19
  39. package/lib/types/client/body-mutations.d.ts +0 -45
  40. package/lib/types/client/host-api.d.ts +0 -88
  41. package/lib/types/client/index.d.ts +0 -128
  42. package/lib/types/client/locales.d.ts +0 -521
  43. package/lib/types/client/main-session.d.ts +0 -32
  44. package/lib/types/client/native-panel.d.ts +0 -48
  45. package/lib/types/client/pending-verify.d.ts +0 -47
  46. package/lib/types/client/plugin-card-seat.d.ts +0 -110
  47. package/lib/types/client/schedule-presets.d.ts +0 -10
  48. package/lib/types/client/schedule-zone.d.ts +0 -97
  49. package/lib/types/client/seats.d.ts +0 -18
  50. package/lib/types/client/service.d.ts +0 -35
  51. package/lib/types/client/settings-entry-form.d.ts +0 -49
  52. package/lib/types/client/settings-form.d.ts +0 -235
  53. package/lib/types/core/attachment.d.ts +0 -132
  54. package/lib/types/core/card-defaults.d.ts +0 -78
  55. package/lib/types/core/controller.d.ts +0 -422
  56. package/lib/types/core/degraded-reason.d.ts +0 -46
  57. package/lib/types/core/execution-summary.d.ts +0 -52
  58. package/lib/types/core/extension.d.ts +0 -399
  59. package/lib/types/core/freeze-snapshot.d.ts +0 -71
  60. package/lib/types/core/handover.d.ts +0 -70
  61. package/lib/types/core/issue-form.d.ts +0 -16
  62. package/lib/types/core/launch-width.d.ts +0 -31
  63. package/lib/types/core/package-name.d.ts +0 -9
  64. package/lib/types/core/poll-cadence.d.ts +0 -31
  65. package/lib/types/core/reasoning-effort.d.ts +0 -57
  66. package/lib/types/core/schedule.d.ts +0 -124
  67. package/lib/types/core/session-reuse.d.ts +0 -30
  68. package/lib/types/core/spend-budget.d.ts +0 -28
  69. package/lib/types/core/store.d.ts +0 -64
  70. package/lib/types/core/subtask.d.ts +0 -204
  71. package/lib/types/core/tasks.d.ts +0 -685
  72. package/lib/types/core/use-cases/task-archive.d.ts +0 -20
  73. package/lib/types/core/use-cases/task-create.d.ts +0 -32
  74. package/lib/types/core/use-cases/task-delete.d.ts +0 -27
  75. package/lib/types/core/use-cases/task-parent.d.ts +0 -21
  76. package/lib/types/core/use-cases/task-schedule.d.ts +0 -96
  77. package/lib/types/core/use-cases/task-tag.d.ts +0 -84
  78. package/lib/types/core/use-cases/task-update.d.ts +0 -77
  79. package/lib/types/core/verification-budget.d.ts +0 -52
  80. package/lib/types/core/verification.d.ts +0 -753
  81. package/lib/types/core/wire-projection.d.ts +0 -35
  82. package/lib/types/core/workspace-target.d.ts +0 -61
  83. package/lib/types/dsh-home.d.ts +0 -16
  84. package/lib/types/host/agent-tools.d.ts +0 -27
  85. package/lib/types/host/attachments.d.ts +0 -250
  86. package/lib/types/host/extension-registry.d.ts +0 -151
  87. package/lib/types/host/launch-admission.d.ts +0 -71
  88. package/lib/types/host/llm-dispatch.d.ts +0 -63
  89. package/lib/types/host/verification-gate.d.ts +0 -95
  90. package/lib/types/host/verification-runner.d.ts +0 -139
  91. package/lib/types/host/workspace-evidence.d.ts +0 -53
  92. package/lib/types/host-ai.d.ts +0 -51
  93. package/lib/types/host-ledger.d.ts +0 -452
  94. package/lib/types/host-routes.d.ts +0 -99
  95. package/lib/types/host-runner.d.ts +0 -401
  96. package/lib/types/host-service.d.ts +0 -517
  97. package/lib/types/host-spend.d.ts +0 -52
  98. package/lib/types/http.d.ts +0 -59
  99. package/lib/types/index.d.ts +0 -441
  100. package/lib/types/loopback.d.ts +0 -64
  101. package/lib/types/mount-once.d.ts +0 -55
  102. package/lib/types/power-inhibitor.d.ts +0 -73
  103. package/lib/types/protocol.d.ts +0 -253
  104. package/lib/types/tool-surface.d.ts +0 -72
@@ -1,517 +0,0 @@
1
- import type { TypertGateway } from '@deepseek-ai/dsh-api-gateway';
2
- import { HostTaskLedger } from './host-ledger.ts';
3
- import { HostExecutionRunner, type GatewayPeer, type SessionCommandDispatcher, type TaskBoardWorkspaceRegistry } from './host-runner.ts';
4
- import { PowerInhibitor } from './power-inhibitor.ts';
5
- import { type TaskBoardAction, type TaskBoardEventPayload, type TaskBoardSnapshot } from './protocol.ts';
6
- import type { CardDefaults } from './core/card-defaults.ts';
7
- import { TaskBoardExtensionRegistry } from './host/extension-registry.ts';
8
- import type { TaskBoardExtension } from './core/extension.ts';
9
- import { type ScheduleMode } from './core/tasks.ts';
10
- import { type ModelCatalogView, type VerificationContract, type VerificationSettings } from './core/verification.ts';
11
- import type { TaskPermission } from './core/handover.ts';
12
- import { type ModelInfoResolver, type TaskBoardAttachmentStore } from './host/attachments.ts';
13
- /**
14
- * Why an enforced goal execution settled failed while its acceptance DID run:
15
- * attempts were recorded and none of them passed. The judge answered about the
16
- * work and the work did not pass.
17
- */
18
- export declare const NO_MATCHING_PASS_VERIFICATION_REASON = "goal \u9A8C\u6536\uFF1A\u672C\u6B21\u6267\u884C\u6CA1\u6709\u5339\u914D\u7684\u9A8C\u6536\u901A\u8FC7\u8BB0\u5F55\uFF08\u9A8C\u6536\u672A\u8FD0\u884C\u3001\u672A\u901A\u8FC7\u6216\u62A5\u544A\u6765\u81EA\u5176\u4ED6\u6267\u884C\uFF09\uFF0C\u6309\u672A\u9A8C\u6536\u5224\u5931\u8D25\u3002";
19
- /**
20
- * Why an enforced goal execution settled failed with ZERO acceptance records:
21
- * the gate was never opened, so the judge never ran and nothing was ever judged
22
- * (issue #1837). The root cause is a session that declared completion in prose
23
- * instead of calling `update_goal(action: complete)` — a tool-adherence problem,
24
- * NOT a quality verdict on the delivery — so this reason says so and keeps the
25
- * two investigation directions apart.
26
- */
27
- export declare const NEVER_INVOKED_VERIFICATION_REASON = "goal \u9A8C\u6536\u672A\u89E6\u53D1\uFF1A\u672C\u6B21\u6267\u884C\u6CA1\u6709\u4EFB\u4F55\u9A8C\u6536\u8BB0\u5F55\uFF0C\u9A8C\u6536\u95E8\u4ECE\u672A\u6253\u5F00\u2014\u2014\u6267\u884C\u4F1A\u8BDD\u6CA1\u6709\u8C03\u7528 update_goal(action: complete) \u6765\u5B8C\u6210\u76EE\u6807\uFF08\u5E38\u89C1\u4E8E\u53EA\u5728\u56DE\u590D\u91CC\u5BA3\u544A\u5B8C\u6210\uFF09\u3002\u8FD9\u4E0D\u662F\u8D28\u91CF\u5224\u8D1F\uFF1A\u4EA4\u4ED8\u4ECE\u672A\u88AB\u88C1\u5224\u8BC4\u4F30\u3002";
28
- /**
29
- * Why an enforced goal execution settled failed while its ONLY acceptance
30
- * records are INVALID: the judge answered but could not locate its own
31
- * rejection, so the board stopped calling it. This is NOT an evidence-backed
32
- * quality veto — the requirement is explicit that such a run must not be
33
- * described as one — but the execution still has no matching pass, so it ends
34
- * for lack of one, and the reason names that precisely.
35
- */
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";
37
- /**
38
- * Provenance of one cron-triggered run: when the rule fired and the zone
39
- * its wall clock was read in. Passed into every launched prompt of that run so
40
- * a scheduled job knows its own clock rather than inferring one.
41
- */
42
- export interface ScheduledRunContext {
43
- triggeredAt: number;
44
- timeZone: string;
45
- /** Whether this fire came from a recurring rule or a single planned instant. */
46
- mode: ScheduleMode;
47
- /** Cron expression of a recurring rule; absent on a one-shot. */
48
- cron?: string;
49
- }
50
- /**
51
- * The native timer face the Host arms through. The cordis `timer` service
52
- * (dsh-base's own `cordis-plugin-timer` row) provides it: its handles are
53
- * registered on the owning fiber, so unloading the board clears every armed
54
- * timer without this service tracking handles by hand. A composition that
55
- * serves no timer service falls back to the process globals.
56
- */
57
- export interface HostTimerFace {
58
- timeout(callback: () => void, delay: number): () => void;
59
- interval(callback: () => void, delay: number): () => void;
60
- }
61
- export declare class TaskBoardHostService {
62
- readonly ledger: HostTaskLedger;
63
- readonly runner: HostExecutionRunner;
64
- readonly power: PowerInhibitor;
65
- /** The official attachment storage, read live so a late mount is honoured. */
66
- private readonly attachmentStore;
67
- private readonly listeners;
68
- /** The one recurring timer: the session-roster poll. */
69
- private pollTimer;
70
- /** Cadence of the roster poll, in seconds (a settings field; see the config schema). */
71
- private sessionPollSeconds;
72
- /** Pending delay that follows a failed poll pass, if one is armed. */
73
- private pollBackoffTimer;
74
- /** Consecutive failed poll passes; doubles the next retry delay. */
75
- private consecutivePollFailures;
76
- /** The armed schedule timer, if a trigger is pending. */
77
- private scheduleTimer;
78
- /** The instant the armed schedule timer targets (ms epoch), for resume detection. */
79
- private scheduleTarget;
80
- private disposed;
81
- private pollInFlight;
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;
89
- /**
90
- * Consecutive unreadable-history polls per open execution (see
91
- * {@link noteUnreadableInspection}). Cleared as soon as an inspection
92
- * resolves, so a transient reader failure never fails a card.
93
- */
94
- private readonly unreadablePolls;
95
- private preventIdleSleep;
96
- private readonly verificationSettings;
97
- private readonly verificationCatalog;
98
- private readonly timers;
99
- /** Live reader of the global native-/goal switch; frozen per execution. */
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;
116
- private lastPowerJson;
117
- private readonly now;
118
- /** The deployment's workspaces, consulted to resolve a card that pins none. */
119
- private readonly workspaceRegistry;
120
- /**
121
- * External provider extensions. The board owns task lifecycle and execution;
122
- * a provider observes them through the registry's capability face and never
123
- * reaches into the ledger itself.
124
- */
125
- readonly extensions: TaskBoardExtensionRegistry;
126
- constructor(gateway: TypertGateway, options?: {
127
- ledger?: HostTaskLedger;
128
- power?: PowerInhibitor;
129
- now?: () => number;
130
- commandDispatcher?: SessionCommandDispatcher;
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;
139
- /**
140
- * Permission baseline of the confirmation gate: a fixed value, or a live
141
- * resolver the board re-reads so a Host Settings change needs no remount.
142
- */
143
- sessionDefaultPermission?: TaskPermission | (() => TaskPermission);
144
- maxSubtaskDepth?: number;
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;
152
- timers?: HostTimerFace;
153
- /**
154
- * Live GLOBAL native /goal switch (a volatile config read). Read ONCE per
155
- * execution, at launch, and carried by value from then on: a settings edit
156
- * made while a run is in flight must not arm, disarm or otherwise change the
157
- * goal/acceptance contract of that run. Absent means OFF, which is the
158
- * default for every deployment that never configured it.
159
- */
160
- goalRunEnabled?: () => boolean;
161
- /**
162
- * Live acceptance settings (volatile config reads). Absent keeps goal
163
- * acceptance OFF for every execution this service opens, which is what a
164
- * programmatic mount without the settings domain gets.
165
- */
166
- verificationSettings?: () => VerificationSettings;
167
- /** The host model catalog the acceptance contract resolves its route from. */
168
- verificationCatalog?: () => Promise<ModelCatalogView | 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;
208
- });
209
- start(): void;
210
- /**
211
- * Apply the live configuration. The roster cadence is re-read on every
212
- * commit, so a settings edit takes effect without a restart; the poll is
213
- * scheduled at the new cadence immediately rather than waiting out the old
214
- * interval.
215
- * @param active - the board's master switch.
216
- * @param preventIdleSleep - whether the board holds an idle-sleep assertion.
217
- * @param sessionPollSeconds - roster-poll cadence in seconds (clamped).
218
- */
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
- */
229
- snapshot(): TaskBoardSnapshot;
230
- /**
231
- * Admit one external provider. Idempotent by extension id; the returned
232
- * disposer releases it (its stored data stays).
233
- */
234
- registerExtension(extension: TaskBoardExtension): () => void;
235
- /**
236
- * The acceptance configuration the settings card displays: the live settings,
237
- * the contract they resolve to, and the host catalog the choices come from.
238
- *
239
- * The card shows the RESOLVED route, not the raw configuration, so "inherit
240
- * host" reads as the concrete model and reasoning level the next execution
241
- * will actually freeze, including any recorded effort fallback.
242
- * @returns the resolved acceptance options.
243
- */
244
- verificationOptions(): Promise<{
245
- settings: VerificationSettings;
246
- contract: VerificationContract;
247
- catalog: ModelCatalogView;
248
- }>;
249
- /** SSE frame payload; deliberately skips the tasks deep-clone of {@link snapshot}. */
250
- eventPayload(): TaskBoardEventPayload;
251
- subscribe(listener: () => void): () => void;
252
- /**
253
- * Give a root card created without a workspace pin the workspace its creator
254
- * is in.
255
- *
256
- * An agent's `task_board_create` arrives with the calling session, and the
257
- * GUI submits the session the main view shows, so the card lands where the
258
- * work was asked for instead of where the Host process happens to run. A card
259
- * that names a workspace keeps it, and a subtask keeps inheriting its lineage
260
- * (the runner walks the ancestor chain for that).
261
- *
262
- * The initiator is client-asserted, so it only chooses among workspaces the
263
- * deployment already knows: it can neither register one nor reach outside the
264
- * list the user sees.
265
- * @param action - the action about to be applied.
266
- * @param initiator - the session that issued the action, when one was asserted.
267
- * @returns the action, with an inherited workspace on a root creation.
268
- */
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;
289
- apply(requestId: string, action: Extract<TaskBoardAction, {
290
- kind: 'extension-action';
291
- }>, initiator?: string): Promise<TaskBoardSnapshot>;
292
- apply(requestId: string, action: Exclude<TaskBoardAction, {
293
- kind: 'extension-action';
294
- }>, initiator?: string): TaskBoardSnapshot;
295
- apply(requestId: string, action: TaskBoardAction, initiator?: string): TaskBoardSnapshot | Promise<TaskBoardSnapshot>;
296
- /**
297
- * Apply one board-owned action with every gate intact. Provider capability
298
- * calls and the same-origin wire both land here, so the two surfaces can
299
- * never disagree about a card.
300
- */
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;
314
- /** Route one provider action and answer the resulting board snapshot. */
315
- private handleExtensionAction;
316
- /** Current task id -> status map, for change detection around a mutation. */
317
- private statusMap;
318
- /** Emit a status change for every task whose column moved, isolated per callback. */
319
- private emitStatusChanges;
320
- dispose(): void;
321
- private launch;
322
- /**
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.
327
- */
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;
342
- /**
343
- * One roster pass, and whether it could read the session tree.
344
- *
345
- * The board reads the DSH session roster only while it has something the
346
- * roster can decide: an execution to inspect, or a card parked in the running
347
- * column whose verdict may arrive from a settle this process never saw. That
348
- * gate is what removes the cost the reporter measured — `session/list`
349
- * rebuilds every persisted session row (string conversion, object allocation,
350
- * a stat per record), and an idle board with no tasks was paying it every few
351
- * seconds forever.
352
- * @returns whether the roster was readable (an idle pass counts as readable).
353
- */
354
- private pollSessions;
355
- /**
356
- * The session a run may continue in, for a card that opted into reuse
357
- * (issue #1419). Reuse requires positive evidence that the previous session
358
- * is present and idle, and that evidence must be read for THIS launch: an
359
- * idle board no longer polls, so a roster cached from an earlier pass could
360
- * be hours old — either refusing a session that has been idle all along, or
361
- * prompting into one that started running since. A card that did not opt in
362
- * reads no roster at all, and a read that fails mints a fresh conversation
363
- * exactly as an unknown roster always did.
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.
368
- * @returns the session id to continue in, or undefined for a fresh session.
369
- */
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;
384
- /** Reuse the session list this poll already fetched: one list RPC per tick, not 1 + E. */
385
- private reconcileExecutions;
386
- /**
387
- * Count one poll whose session history could not be read. A reader failure is
388
- * not progress: the session is not running (the runner only reads history for
389
- * one that is idle), so nothing will ever change that verdict. After
390
- * {@link UNREADABLE_SETTLE_POLLS} consecutive polls the execution is reported
391
- * failed with the recorded reason, instead of holding its card — and every
392
- * ancestor of it — in the running column with no way out. The first poll of
393
- * each streak is logged, so the Host log names the session.
394
- */
395
- private settleAndNotify;
396
- /**
397
- * Remove one execution's acceptance-only detail after it PASSED and settled.
398
- *
399
- * Deliberately narrow: only the acceptance mechanism's own per-attempt
400
- * material (findings, invalid diagnostics, the bulky judge side) is removed,
401
- * and only for THIS execution, keyed by its own id in the ledger it belongs
402
- * to. No user file, task artifact, raw session history or other execution's
403
- * record is read or written. Idempotent by the record's own state, and it
404
- * clearly never touches a run that did not pass (the caller's guard) — a
405
- * failed or invalid execution keeps everything a repair or a review needs.
406
- * @param taskId - the task whose execution settled.
407
- * @param executionId - the settled execution.
408
- */
409
- private cleanupAcceptanceDetail;
410
- /**
411
- * Catch-up pass: clean the acceptance detail of every execution that PASSED
412
- * and settled but whose cleanup did not finish (a crash, a failed write, a
413
- * Host killed mid-cleanup).
414
- *
415
- * The same bounds as any other cleanup apply — only a real pass record on a
416
- * settled execution is touched — so this can never delete material belonging
417
- * to an execution that did not pass, and never a user file.
418
- */
419
- private cleanupPendingAcceptanceDetail;
420
- private noteUnreadableInspection;
421
- /** Drop the armed schedule timer and forget its target. */
422
- private clearScheduleTimer;
423
- /**
424
- * Boot / resume recovery: skip every occurrence that came due while the
425
- * board was not running and roll each schedule to its next future target,
426
- * then arm the timer for the nearest one. Rendering the occurrence is
427
- * deliberately not attempted: the ACL of a card that fired hours ago is
428
- * stale, and the board's own recovery contract is "missed triggers are
429
- * skipped, never replayed".
430
- */
431
- private recoverSchedule;
432
- /**
433
- * Arm the native timer at the nearest armed future trigger. One timer serves
434
- * every schedule: the ledger's next target is the only instant the Host has
435
- * to wake for. A target beyond the platform's timer ceiling re-arms in
436
- * segments, and a target already past (the wall clock jumped, or the process
437
- * was suspended) is handled immediately as a recovery.
438
- */
439
- private armSchedule;
440
- /**
441
- * One armed target became due. A fire landing well past its target is a
442
- * resume (suspend, throttle, forward clock jump) rather than a normal
443
- * occurrence, so it takes the recovery path instead of launching a run for a
444
- * long-stale instant.
445
- */
446
- private onScheduleFire;
447
- private armedSchedules;
448
- /**
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.
456
- */
457
- private dispatchRuns;
458
- /**
459
- * Move one execution's applicability without touching its frozen contract or
460
- * its recorded attempts (used when the run's goal form becomes known).
461
- */
462
- private setApplicability;
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;
484
- private schedulePoll;
485
- /**
486
- * Count one failed pass and arm the retry that follows it.
487
- *
488
- * A session tree that is down is retried on a doubling delay instead of
489
- * hammering it on the fixed cadence: the heartbeat would otherwise repeat
490
- * every failure — and every retry inside {@link HostExecutionRunner.listRunning}
491
- * — at exactly the interval the reporter measured.
492
- */
493
- private notePollFailure;
494
- /** Arm the retry that follows a failed pass, doubling up to the ceiling. */
495
- private armPollBackoff;
496
- /** Drop a pending retry; the next regular tick takes over. */
497
- private clearPollBackoff;
498
- /**
499
- * Re-arm from the ledger's current targets. Callers that just changed a
500
- * schedule (the host routes, the agent tools) invoke this after the write
501
- * commits, so a new or edited trigger arms without waiting for the next fire.
502
- */
503
- refreshSchedule(): void;
504
- private syncPowerReasons;
505
- private emit;
506
- }
507
- /**
508
- * Install stream error listeners on process.stderr and process.stdout so that
509
- * transient write failures (e.g. ENOSPC when the disk is full, or EPIPE on a
510
- * closed pipe) never emit unhandled 'error' events that kill the Node.js host process.
511
- */
512
- export declare function installStreamErrorGuards(): void;
513
- /**
514
- * Defensively log to console.error without letting stderr write failures
515
- * (e.g. ENOSPC from SyncWriteStream on redirected logs) crash the host process.
516
- */
517
- export declare function safeConsoleError(message: string, ...args: unknown[]): void;
@@ -1,52 +0,0 @@
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;
@@ -1,59 +0,0 @@
1
- /**
2
- * Shared JSON body/response helpers for the host route families: one strict
3
- * bounded body reader, one lenient bounded body reader, one JSON object
4
- * narrow, one JSON writer, and the outbound request-init helper that keeps a
5
- * host fetch body decodable (withIdentityEncoding). Previously the readers
6
- * were copy-pasted across the
7
- * package route files (routes.ts, update-routes.ts, mobile-api.ts, and each
8
- * family's route module) with drifting contracts: body caps ranging 4 KiB to
9
- * 1 MiB and four distinct overflow behaviors (reject, undefined, null, throw).
10
- *
11
- * Packages receive this file as a generated copy via scripts/sync-shared.mjs;
12
- * edit this shared source and re-run the sync instead of editing a copy.
13
- * Consumer code is migrated onto it in follow-up waves; no call site changes
14
- * belong in the same change as its introduction.
15
- * @module dsh-web-shared/host/http
16
- */
17
- import type { IncomingMessage, OutgoingHttpHeaders, ServerResponse } from 'node:http';
18
- /**
19
- * Strict bounded body reader: parse a request body of at most maxBytes as
20
- * JSON.
21
- * @throws 'body too large' past the cap, or the JSON.parse error for an
22
- * invalid or empty payload.
23
- */
24
- export declare function readBoundedJson(req: IncomingMessage, maxBytes: number): Promise<unknown>;
25
- /**
26
- * Lenient bounded body reader: parse a request body as JSON, or null on an
27
- * empty body, invalid JSON, or a body past maxBytes (default 64 KiB).
28
- * Overflow destroys the request instead of draining the remainder (no drain
29
- * call, matching the current repo-wide behavior); callers must not keep
30
- * reading the request afterwards. With objectOnly, non-JSON-object payloads
31
- * also yield null.
32
- */
33
- export declare function readJsonBody(req: IncomingMessage, opts?: {
34
- maxBytes?: number;
35
- objectOnly?: boolean;
36
- }): Promise<unknown | null>;
37
- /** Narrow a value to a JSON object, or undefined when it is not one. */
38
- export declare function asJsonObject(value: unknown): Record<string, unknown> | undefined;
39
- /**
40
- * Request init that asks a remote origin for an uncompressed body.
41
- *
42
- * The DSH host boots `@deepseek-ai/dsh-http-proxy`, whose top-level import of
43
- * the npm `undici` copy replaces the legacy `undici.globalDispatcher.1` slot
44
- * Node's built-in `fetch()` reads. That cross-major wrapper drops the
45
- * `content-encoding` header and automatic decompression, so a plain fetch
46
- * resolves to raw gzip/brotli/zstd bytes — compressed noise no JSON or text
47
- * consumer can read. Every host fetch that parses a remote body must request
48
- * identity encoding. Caller headers survive; `accept-encoding` is forced to
49
- * `identity` because a caller value has no decoder behind it in this host.
50
- * @param init - the caller's request init (signal, headers, method, ...).
51
- * @returns a copy with `accept-encoding: identity` merged in.
52
- */
53
- export declare function withIdentityEncoding(init?: RequestInit): RequestInit;
54
- /**
55
- * Write one JSON response. Default headers are the family defaults
56
- * (content-type and referrer-policy); caller headers are appended or
57
- * override them.
58
- */
59
- export declare function writeJson(res: ServerResponse, status: number, body: unknown, headers?: OutgoingHttpHeaders): void;