@fish-under-sea/dsh-client-ui-task-board-fish 1.0.2 → 1.1.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 (123) hide show
  1. package/NOTICE +1 -1
  2. package/README.en.md +4 -4
  3. package/README.md +4 -4
  4. package/README.zh.md +4 -4
  5. package/lib/client.js +4428 -1508
  6. package/lib/client.js.map +1 -1
  7. package/lib/index.js +2670 -496
  8. package/lib/types/client/CardDefaultPresetField.d.ts +35 -0
  9. package/lib/types/client/PluginSettingsCard.d.ts +130 -19
  10. package/lib/types/client/RangeBubble.d.ts +46 -0
  11. package/lib/types/client/SegmentGroup.d.ts +28 -0
  12. package/lib/types/client/TaskBoardSettingsCard.d.ts +63 -0
  13. package/lib/types/client/board/AttachmentField.d.ts +70 -0
  14. package/lib/types/client/board/ExecutionLog.d.ts +24 -0
  15. package/lib/types/client/board/ReasoningEffortField.d.ts +25 -0
  16. package/lib/types/client/board/TaskForm.d.ts +4 -0
  17. package/lib/types/client/board/VerificationReport.d.ts +2 -15
  18. package/lib/types/client/board/model-options.d.ts +87 -0
  19. package/lib/types/client/board/preset-label.d.ts +21 -0
  20. package/lib/types/client/board/preset-roster.d.ts +45 -0
  21. package/lib/types/client/board/source-group.d.ts +27 -0
  22. package/lib/types/client/body-mutations.d.ts +45 -0
  23. package/lib/types/client/host-api.d.ts +25 -0
  24. package/lib/types/client/locales.d.ts +87 -9
  25. package/lib/types/client/pending-verify.d.ts +47 -0
  26. package/lib/types/client/plugin-card-seat.d.ts +3 -1
  27. package/lib/types/client/service.d.ts +4 -1
  28. package/lib/types/client/settings-form.d.ts +73 -51
  29. package/lib/types/core/attachment.d.ts +132 -0
  30. package/lib/types/core/card-defaults.d.ts +78 -0
  31. package/lib/types/core/controller.d.ts +57 -8
  32. package/lib/types/core/execution-summary.d.ts +52 -0
  33. package/lib/types/core/extension.d.ts +116 -0
  34. package/lib/types/core/launch-width.d.ts +31 -0
  35. package/lib/types/core/reasoning-effort.d.ts +57 -0
  36. package/lib/types/core/session-reuse.d.ts +7 -1
  37. package/lib/types/core/spend-budget.d.ts +28 -0
  38. package/lib/types/core/subtask.d.ts +100 -37
  39. package/lib/types/core/tasks.d.ts +94 -10
  40. package/lib/types/core/use-cases/task-create.d.ts +10 -5
  41. package/lib/types/core/use-cases/task-tag.d.ts +36 -0
  42. package/lib/types/core/use-cases/task-update.d.ts +22 -1
  43. package/lib/types/core/wire-projection.d.ts +35 -0
  44. package/lib/types/core/workspace-target.d.ts +23 -3
  45. package/lib/types/host/attachments.d.ts +250 -0
  46. package/lib/types/host/extension-registry.d.ts +40 -0
  47. package/lib/types/host/launch-admission.d.ts +71 -0
  48. package/lib/types/host-ledger.d.ts +114 -47
  49. package/lib/types/host-routes.d.ts +63 -0
  50. package/lib/types/host-runner.d.ts +164 -18
  51. package/lib/types/host-service.d.ts +182 -46
  52. package/lib/types/host-spend.d.ts +52 -0
  53. package/lib/types/index.d.ts +173 -54
  54. package/lib/types/loopback.d.ts +41 -1
  55. package/lib/types/protocol.d.ts +52 -11
  56. package/lib/types/tool-surface.d.ts +1 -0
  57. package/locale/en.json +6 -0
  58. package/locale/zh.json +6 -0
  59. package/package.json +35 -28
  60. package/src/client/CardDefaultPresetField.tsx +101 -0
  61. package/src/client/PluginSettingsCard.tsx +385 -111
  62. package/src/client/RangeBubble.tsx +164 -0
  63. package/src/client/SegmentGroup.tsx +93 -0
  64. package/src/client/TaskBoardSettingsCard.tsx +332 -37
  65. package/src/client/board/AttachmentField.tsx +383 -0
  66. package/src/client/board/EditTaskModal.tsx +63 -0
  67. package/src/client/board/ExecutionLog.tsx +154 -0
  68. package/src/client/board/LinkSubtaskModal.tsx +1 -1
  69. package/src/client/board/NewTaskModal.tsx +154 -45
  70. package/src/client/board/ReasoningEffortField.tsx +50 -0
  71. package/src/client/board/TagManagerModal.tsx +151 -2
  72. package/src/client/board/TaskBoard.tsx +47 -10
  73. package/src/client/board/TaskCard.tsx +45 -23
  74. package/src/client/board/TaskDetail.tsx +468 -258
  75. package/src/client/board/TaskForm.tsx +19 -4
  76. package/src/client/board/VerificationReport.tsx +143 -104
  77. package/src/client/board/model-options.ts +208 -0
  78. package/src/client/board/preset-label.ts +32 -0
  79. package/src/client/board/preset-roster.ts +58 -0
  80. package/src/client/board/source-group.ts +94 -0
  81. package/src/client/board/task-markdown.module.css +11 -8
  82. package/src/client/board-settings.module.css +35 -7
  83. package/src/client/board.module.css +1044 -105
  84. package/src/client/body-mutations.ts +133 -0
  85. package/src/client/host-api.ts +70 -0
  86. package/src/client/index.ts +109 -95
  87. package/src/client/locales.ts +205 -48
  88. package/src/client/pending-verify.ts +90 -0
  89. package/src/client/plugin-card-seat.ts +8 -2
  90. package/src/client/service.ts +24 -0
  91. package/src/client/settings-card.module.css +466 -89
  92. package/src/client/settings-entry-form.ts +0 -1
  93. package/src/client/settings-form.ts +102 -60
  94. package/src/core/attachment.ts +287 -0
  95. package/src/core/card-defaults.ts +132 -0
  96. package/src/core/controller.ts +90 -11
  97. package/src/core/execution-summary.ts +96 -0
  98. package/src/core/extension.ts +120 -0
  99. package/src/core/launch-width.ts +38 -0
  100. package/src/core/reasoning-effort.ts +92 -0
  101. package/src/core/session-reuse.ts +7 -1
  102. package/src/core/spend-budget.ts +35 -0
  103. package/src/core/store.ts +19 -1
  104. package/src/core/subtask.ts +144 -68
  105. package/src/core/tasks.ts +117 -10
  106. package/src/core/use-cases/task-create.ts +27 -16
  107. package/src/core/use-cases/task-tag.ts +56 -0
  108. package/src/core/use-cases/task-update.ts +33 -5
  109. package/src/core/wire-projection.ts +81 -0
  110. package/src/core/workspace-target.ts +27 -3
  111. package/src/host/agent-tools.ts +33 -21
  112. package/src/host/attachments.ts +650 -0
  113. package/src/host/extension-registry.ts +150 -5
  114. package/src/host/launch-admission.ts +139 -0
  115. package/src/host-ledger.ts +248 -117
  116. package/src/host-routes.ts +233 -15
  117. package/src/host-runner.ts +395 -61
  118. package/src/host-service.ts +512 -139
  119. package/src/host-spend.ts +105 -0
  120. package/src/index.ts +312 -92
  121. package/src/loopback.ts +57 -1
  122. package/src/protocol.ts +83 -18
  123. package/src/tool-surface.ts +1 -0
@@ -1,3 +1,4 @@
1
+ import { type CardDefaults } from '../card-defaults.ts';
1
2
  import { type NewTaskInput, type TaskRecord } from '../tasks.ts';
2
3
  /** Result of a create transition: the new task (when accepted) + the next ledger. */
3
4
  export interface CreateTaskResult {
@@ -13,15 +14,19 @@ export interface CreateTaskResult {
13
14
  * appended ledger, or the unchanged ledger when the title is blank or the
14
15
  * requested parent link is refused.
15
16
  *
16
- * A subtask inherits the execution targets its parent already pins (workspace,
17
- * agent preset, permission, model) unless the form supplied its own; the
18
- * parent human permission confirmation travels with an inherited permission,
19
- * so a subtask of an already-confirmed elevated card is runnable at once.
17
+ * The execution targets resolve through {@link resolveCardTargets}: what the
18
+ * caller sent wins, then the parent's own pins, then - only when the caller
19
+ * opted in with `applyCardDefaults` - the deployment's configured new-card
20
+ * defaults. Without the flag the resolution sees no defaults at all, which is
21
+ * exactly the inline parent inheritance this path has always applied. The
22
+ * workspace is not part of that resolution: a subtask still takes the parent's
23
+ * workspace, and the defaults never name one.
20
24
  * @param tasks - current ledger.
21
25
  * @param input - raw user input (title/description/prompt + optional schedule/parent).
22
26
  * @param now - clock instant (ms epoch).
23
27
  * @param id - minted task id.
24
28
  * @param maxSubtaskDepth - deployment subtask depth limit.
25
29
  * @param hostTimeZone - zone a rule that stores no zone of its own follows.
30
+ * @param cardDefaults - the deployment's new-card defaults, read live at creation.
26
31
  */
27
- export declare function applyCreateTask(tasks: readonly TaskRecord[], input: NewTaskInput, now: number, id: string, maxSubtaskDepth?: number, hostTimeZone?: string): CreateTaskResult;
32
+ export declare function applyCreateTask(tasks: readonly TaskRecord[], input: NewTaskInput, now: number, id: string, maxSubtaskDepth?: number, hostTimeZone?: string, cardDefaults?: CardDefaults): CreateTaskResult;
@@ -15,6 +15,13 @@
15
15
  * Renaming onto a name that is already in use MERGES the two: a task carrying
16
16
  * both keeps the row it already had (with its execution hint) and loses the
17
17
  * duplicate, which is the only reading that cannot lose a hint the user typed.
18
+ *
19
+ * Clearing up is the third ledger-wide transition, and it is a SELECTION rather
20
+ * than a fourth rewrite: {@link cleanupCandidates} names the labels that are
21
+ * both rarely used and attached only to finished tasks, and each of them then
22
+ * leaves through {@link applyDeleteTag} like any other delete. One delete path,
23
+ * one meaning — a label never disappears by a second rule written beside the
24
+ * first.
18
25
  */
19
26
  import { type TaskRecord } from '../tasks.ts';
20
27
  /** Outcome of one ledger-wide label edit. */
@@ -46,3 +53,32 @@ export declare function applyRenameTag(tasks: readonly TaskRecord[], from: strin
46
53
  * @returns the rewritten ledger.
47
54
  */
48
55
  export declare function applyDeleteTag(tasks: readonly TaskRecord[], name: string, now: number): TagEditResult;
56
+ /** One label the manager offers to clear, with the tasks it would be taken from. */
57
+ export interface TagCleanupCandidate {
58
+ /** The label name. */
59
+ name: string;
60
+ /** Tasks carrying the label right now, board and archive alike. */
61
+ count: number;
62
+ }
63
+ /**
64
+ * Labels that are both rarely used and finished with: fewer tasks carry them
65
+ * than `threshold`, and every one of those tasks is done or failed.
66
+ *
67
+ * The judgement reads the whole ledger it is given — the board's label row and
68
+ * the archive draw from the same set, so an archived card counts towards a
69
+ * label's usage and can keep it alive on its own. Archiving alone decides
70
+ * nothing: an archived card in a finished column lets its label through, while
71
+ * an archived card still in backlog, todo or running holds it back, because a
72
+ * label that live work still points at is not junk.
73
+ *
74
+ * A non-finite threshold selects nothing (a missing number has no reading that
75
+ * is safe to act on); a threshold at or below one selects nothing either, since
76
+ * a label by definition sits on at least one task and none can carry fewer.
77
+ *
78
+ * Order follows {@link collectKnownTags}, which is the order the manager lists
79
+ * labels in, and the count is the same number the manager shows per label.
80
+ * @param tasks - the whole ledger (board and archive).
81
+ * @param threshold - exclusive upper bound on the usage count.
82
+ * @returns the labels a cleanup may remove, in listing order.
83
+ */
84
+ export declare function cleanupCandidates(tasks: readonly TaskRecord[], threshold: number): TagCleanupCandidate[];
@@ -9,13 +9,14 @@
9
9
  * stale UI can never persist a value the execution service rejects.
10
10
  */
11
11
  import { type TaskRecord, type TaskTag } from '../tasks.ts';
12
+ import { type TaskAttachment } from '../attachment.ts';
12
13
  import type { FreezeSnapshot } from '../freeze-snapshot.ts';
13
14
  import type { TaskHandoverInput } from '../handover.ts';
14
15
  /**
15
16
  * Editable fields on a task (the update patch surface). `freeze` replaces the
16
17
  * continuation-card snapshot (restamping frozenAt); an explicit null clears it.
17
18
  */
18
- export type TaskUpdatePatch = Partial<Pick<TaskRecord, 'title' | 'description' | 'prompt' | 'workspaceId' | 'mode' | 'permission' | 'model' | 'reuseSession' | 'teamRun' | 'goalRun' | 'skipVerification'>> & {
19
+ export type TaskUpdatePatch = Partial<Pick<TaskRecord, 'title' | 'description' | 'prompt' | 'workspaceId' | 'mode' | 'permission' | 'model' | 'reasoningEffort' | 'reuseSession' | 'goalRun' | 'skipVerification'>> & {
19
20
  freeze?: FreezeSnapshot & {
20
21
  redacted?: boolean;
21
22
  } | null;
@@ -28,6 +29,15 @@ export type TaskUpdatePatch = Partial<Pick<TaskRecord, 'title' | 'description' |
28
29
  * explicit null (or a list that normalizes to nothing) clears them.
29
30
  */
30
31
  tags?: TaskTag[] | null;
32
+ /**
33
+ * Replaces the card's attachments (issue #1979).
34
+ *
35
+ * The attachments freeze WITH the card content: they are part of what the
36
+ * card hands to its execution, so an executed or archived card keeps the
37
+ * ones it ran with, exactly as it keeps the prompt it ran with. An explicit
38
+ * null clears them; a present array replaces the whole set.
39
+ */
40
+ attachments?: TaskAttachment[] | null;
31
41
  };
32
42
  /** The fields that edit the task's content (what the user reads and what the
33
43
  * next execution sends). Unlike the execution targets they stay editable only
@@ -35,6 +45,17 @@ export type TaskUpdatePatch = Partial<Pick<TaskRecord, 'title' | 'description' |
35
45
  * recorded prompt is the record of what actually ran, so it becomes read-only.
36
46
  */
37
47
  export declare const TASK_CONTENT_FIELDS: readonly ["title", "description", "prompt"];
48
+ /**
49
+ * The fields that freeze with the card content: the text the card says AND
50
+ * the attachments it carries.
51
+ *
52
+ * The attachments freeze with the content because they ARE part of what the
53
+ * card hands to its execution: a card whose first run already consumed an
54
+ * image keeps that image, and the record of what ran stays what it was. An
55
+ * executed or archived card therefore refuses an attachment change exactly
56
+ * as it refuses a prompt change.
57
+ */
58
+ export declare const TASK_FROZEN_FIELDS: readonly ["title", "description", "prompt", "attachments"];
38
59
  /** Whether an update patch touches any task-content field. */
39
60
  export declare function hasContentPatch(patch: TaskUpdatePatch): boolean;
40
61
  /**
@@ -0,0 +1,35 @@
1
+ /**
2
+ * What an extension's `integrations` container looks like once it leaves the
3
+ * Host.
4
+ *
5
+ * The container is provider-owned and crosses the board unread, and it also
6
+ * crosses the wire: the HTTP snapshot, every action answer, and the remote
7
+ * bridge's `board.snapshot` all carry it. A credential a provider stored there
8
+ * would therefore reach every browser and phone paired to this Host. This
9
+ * module is the one place that decides otherwise: the ledger keeps the payload
10
+ * verbatim (the provider reads it back through its in-process capability face,
11
+ * and a Host-side consumer reads the ledger itself), while the copy that leaves
12
+ * carries no credential.
13
+ *
14
+ * @module dsh-task-board/core/wire-projection
15
+ */
16
+ import type { TaskBoardSnapshot } from '../protocol.ts';
17
+ import type { TaskRecord } from './tasks.ts';
18
+ /**
19
+ * The card as the wire may show it: the ledger record with its integration
20
+ * entries copied and stripped.
21
+ *
22
+ * A card that carries no integrations is returned untouched, so a provider that
23
+ * stores nothing sees exactly the record the board has always published.
24
+ * @param task - the ledger record about to be serialized.
25
+ * @returns the projected record; the ledger object is never mutated.
26
+ */
27
+ export declare function projectTaskForWire(task: TaskRecord): TaskRecord;
28
+ /**
29
+ * The snapshot as every read path serializes it: the HTTP `state` answer, the
30
+ * HTTP `action` answer, and the remote bridge's `board.snapshot` all start from
31
+ * the object this returns.
32
+ * @param snapshot - the snapshot the Host service built from its live state.
33
+ * @returns the same snapshot with each card projected through {@link projectTaskForWire}.
34
+ */
35
+ export declare function projectSnapshotForWire(snapshot: TaskBoardSnapshot): TaskBoardSnapshot;
@@ -1,11 +1,12 @@
1
1
  /**
2
2
  * Workspace targeting for cards that pin none.
3
3
  *
4
- * The Host answers two questions here instead of leaving them to
4
+ * The Host answers three questions here instead of leaving them to
5
5
  * `session.create`, whose own fallback is the Host process working directory
6
6
  * (the desktop app's profile directory): which workspace a root card inherits
7
- * from the session that created it, and which workspace an unpinned run lands
8
- * in when nothing could be inherited.
7
+ * from the session that created it, which workspace an unpinned run lands in
8
+ * when nothing could be inherited, and — when neither names one — the refusal
9
+ * that stops the run instead of landing it there.
9
10
  *
10
11
  * Structural types only — the Host's `Workspace` entity satisfies them — so the
11
12
  * browser program compiles this module without importing an SDK value.
@@ -39,3 +40,22 @@ export declare function workspaceOwningSession(items: readonly WorkspaceCandidat
39
40
  * @returns the most recently used workspace id, or undefined when there is none.
40
41
  */
41
42
  export declare function mostRecentWorkspaceId(items: readonly WorkspaceCandidate[]): string | undefined;
43
+ /**
44
+ * The failure text the Host records when a card names no workspace and the
45
+ * deployment has none to resolve it to: the run is refused before any session
46
+ * exists instead of letting `session.create` fall back to the Host process
47
+ * working directory (the desktop app's profile directory), which is never the
48
+ * project the user meant.
49
+ *
50
+ * A finished sentence rather than a code: the ledger stores it as the
51
+ * execution's failure text, which the agent tools serve to a model and which
52
+ * any client prints verbatim. It names the fix, not the mechanism.
53
+ */
54
+ export declare const MISSING_WORKSPACE_REASON = "this card pins no workspace; choose a workspace on the card before running";
55
+ /**
56
+ * Whether a recorded failure text is the missing-workspace refusal, which the
57
+ * browser half renders in the reader's own language.
58
+ * @param reason - the execution's recorded failure text.
59
+ * @returns true when that run was refused for naming no workspace.
60
+ */
61
+ export declare function isMissingWorkspaceReason(reason: string): boolean;
@@ -0,0 +1,250 @@
1
+ import type { IncomingMessage } from 'node:http';
2
+ import type { FileAttachmentRef, ImageAttachmentRef, ImageMediaType, StoredImageAttachment } from '@deepseek-ai/dsh-attachment/types';
3
+ import { type TaskAttachment, type TaskAttachmentKind } from '../core/attachment.ts';
4
+ /**
5
+ * The official attachment storage, narrowed to the members the board uses.
6
+ *
7
+ * The board declares the face structurally (like the other optional services
8
+ * it resolves) so the Host half needs no value import of the SDK package: the
9
+ * deployment's own attachment service provides it, and a deployment without
10
+ * one simply refuses attachment work.
11
+ */
12
+ export interface TaskBoardAttachmentStore {
13
+ /** Deployment-resolved image policy. */
14
+ readonly imageLimits: {
15
+ maxImageBytes: number;
16
+ maxImagesPerMessage: number;
17
+ maxMessageImageBytes: number;
18
+ maxImagePixels: number;
19
+ maxImageDimension: number;
20
+ mediaTypes: readonly string[];
21
+ };
22
+ /** Validate one image without persisting it. */
23
+ validateImage(input: {
24
+ data: Uint8Array;
25
+ mediaType: string;
26
+ name?: string;
27
+ }): Promise<void>;
28
+ /** Validate and durably commit one image. */
29
+ saveImage(input: {
30
+ data: Uint8Array;
31
+ mediaType: string;
32
+ name?: string;
33
+ }): Promise<ImageAttachmentRef>;
34
+ /** Read one image and verify that the bytes still match the reference. */
35
+ readImage(ref: ImageAttachmentRef, signal?: AbortSignal): Promise<StoredImageAttachment>;
36
+ /** Durably commit one file byte-for-byte from bounded chunks. */
37
+ saveFileStream(input: {
38
+ data: AsyncIterable<Uint8Array>;
39
+ signal?: AbortSignal;
40
+ name?: string;
41
+ }): Promise<FileAttachmentRef>;
42
+ /** Read and verify one verbatim stored file as bounded chunks. */
43
+ readFileStream(ref: FileAttachmentRef, signal?: AbortSignal): AsyncIterable<Uint8Array>;
44
+ /** Locate the verbatim stored file object in the Host filesystem. */
45
+ fileHostPath(ref: FileAttachmentRef): string | undefined;
46
+ }
47
+ /** The stable failure classes the attachment routes answer with. */
48
+ export type TaskBoardAttachmentErrorCode = 'invalid-request' | 'unsupported-type' | 'too-large' | 'invalid-image' | 'storage-unavailable' | 'not-found' | 'unreadable';
49
+ /**
50
+ * One attachment failure, carrying the class the route maps to a status and a
51
+ * message that never contains raw bytes or a host path.
52
+ */
53
+ export declare class TaskBoardAttachmentError extends Error {
54
+ readonly code: TaskBoardAttachmentErrorCode;
55
+ constructor(code: TaskBoardAttachmentErrorCode, message: string, options?: ErrorOptions);
56
+ }
57
+ /** The HTTP status one attachment failure class answers with. */
58
+ export declare function attachmentErrorStatus(code: TaskBoardAttachmentErrorCode): number;
59
+ /** Lowercase hex sha256 digest of the exact bytes. */
60
+ export declare function sha256Hex(bytes: Uint8Array): string;
61
+ /** Whether a value names one of the raster media types the image path accepts. */
62
+ export declare function isImageMediaType(value: unknown): value is ImageMediaType;
63
+ /**
64
+ * Normalize a client-declared file media type: a well-formed type is kept
65
+ * (lowercased), anything else falls back to the opaque binary type. The type
66
+ * of a verbatim file is a declaration, not something the storage can prove.
67
+ */
68
+ export declare function normalizeFileMediaType(value: unknown): string;
69
+ /**
70
+ * The canonical display name of an upload.
71
+ *
72
+ * The Host publishes the canonical name, and the ledger stores the same
73
+ * string: the wire gate accepts only a name that already IS canonical, so a
74
+ * client cannot rename an object into something the storage never saw. The
75
+ * canonical form is single-line and free of any path part, which is what
76
+ * makes it safe to place in an execution prompt.
77
+ */
78
+ export declare function sanitizeAttachmentName(value: unknown): string;
79
+ /**
80
+ * The per-image byte cap this deployment enforces: the board's own ceiling
81
+ * lowered by the storage's own policy when that policy is stricter.
82
+ */
83
+ export declare function effectiveImageByteLimit(store: TaskBoardAttachmentStore | undefined): number;
84
+ /**
85
+ * Read a whole request body, refusing it the moment it grows past the cap.
86
+ * The count is the ACTUAL byte length of the stream, not a declared length.
87
+ */
88
+ export declare function readRequestBytes(req: IncomingMessage, limit: number): Promise<Uint8Array>;
89
+ /**
90
+ * A byte stream that measures and digests what it yields.
91
+ *
92
+ * The file path streams the request straight into the official storage: the
93
+ * bytes are never collected in memory, and the count and digest the board
94
+ * records are the ones computed from the bytes that actually went in.
95
+ */
96
+ export declare class MeasuredStream {
97
+ private readonly limit;
98
+ private readonly hash;
99
+ private size;
100
+ private finished;
101
+ constructor(limit: number);
102
+ /** The byte length seen so far. */
103
+ get bytes(): number;
104
+ /** The digest of the bytes seen so far; final once the stream ended. */
105
+ digest(): string;
106
+ /** Whether the whole stream was consumed. */
107
+ get complete(): boolean;
108
+ /** The chunks, refusing the stream the moment it grows past the cap. */
109
+ chunks(source: AsyncIterable<Uint8Array>): AsyncGenerator<Uint8Array>;
110
+ }
111
+ /**
112
+ * The request body as a byte stream: the file path hands it straight to the
113
+ * official storage, so the bytes are never collected in memory.
114
+ */
115
+ export declare function requestChunks(req: IncomingMessage): AsyncIterable<Uint8Array>;
116
+ /**
117
+ * The image reference a recorded attachment stands for. The stored object is
118
+ * addressed by its opaque identifier; the rest of the fields are the board's
119
+ * own record of what the storage holds.
120
+ */
121
+ export declare function imageRefOf(attachment: TaskAttachment): ImageAttachmentRef;
122
+ /** The file reference a recorded attachment stands for. */
123
+ export declare function fileRefOf(attachment: TaskAttachment): FileAttachmentRef;
124
+ /**
125
+ * Publish one image into the official storage and describe it with
126
+ * host-computed metadata.
127
+ *
128
+ * The image is validated before it is stored (the storage checks the decoded
129
+ * bytes against the declared type), and the recorded digest is computed over
130
+ * the NORMALIZED bytes the storage actually kept — not over what the client
131
+ * sent — so the metadata and the object can never disagree.
132
+ */
133
+ export declare function storeImage(store: TaskBoardAttachmentStore, data: Uint8Array, name: string, mediaType: string): Promise<TaskAttachment>;
134
+ /**
135
+ * Publish one file into the official storage and describe it with
136
+ * host-computed metadata. The digest is computed from the streamed bytes, so
137
+ * the record and the stored object agree by construction.
138
+ */
139
+ export declare function storeFile(store: TaskBoardAttachmentStore, chunks: AsyncIterable<Uint8Array>, name: string, mediaType: string, signal?: AbortSignal): Promise<{
140
+ attachment: TaskAttachment;
141
+ bytes: number;
142
+ sha256: string;
143
+ }>;
144
+ /**
145
+ * Map an official attachment failure onto the board's own classes, so a
146
+ * storage fault reads as "the storage is unavailable" and a rejected image
147
+ * reads as "the image is not acceptable" — never as an internal error.
148
+ */
149
+ export declare function asAttachmentError(error: unknown): TaskBoardAttachmentError;
150
+ /**
151
+ * Prove every recorded attachment against the official storage: an image is
152
+ * read back and compared, a file is streamed and its digest recomputed.
153
+ *
154
+ * A reference the storage does not know, and a record whose metadata does not
155
+ * match the stored bytes, are both a refusal: the action never reaches the
156
+ * ledger, so a spoofed client claim can never become a stored fact.
157
+ */
158
+ export declare function verifyAttachments(store: TaskBoardAttachmentStore, attachments: readonly TaskAttachment[]): Promise<void>;
159
+ /**
160
+ * The official image batch limits of a deployment: how many images one
161
+ * message may carry and how many bytes they may add up to.
162
+ *
163
+ * The board's own caps (eight attachments, 10 MiB each, 32 MiB per card) stay
164
+ * in force; the deployment's policy can only lower them, and it governs the
165
+ * IMAGES of one card because that is what one prompt carries.
166
+ */
167
+ export declare function officialImageBatchLimits(store: TaskBoardAttachmentStore | undefined): {
168
+ maxImages: number;
169
+ maxImageBytes: number;
170
+ maxMessageImageBytes: number;
171
+ };
172
+ /**
173
+ * Refuse a card whose images exceed the deployment's per-message budget.
174
+ *
175
+ * The check counts only the images: plain files travel as paths and never
176
+ * enter the prompt admission, so they are not part of that budget.
177
+ * @param store - the official attachment storage.
178
+ * @param attachments - the card's attachments.
179
+ */
180
+ export declare function assertImageBatchWithinLimits(store: TaskBoardAttachmentStore | undefined, attachments: readonly TaskAttachment[]): void;
181
+ /** Read one image back and compare it with the recorded metadata. */
182
+ export declare function verifyImage(store: TaskBoardAttachmentStore, attachment: TaskAttachment): Promise<void>;
183
+ /** Stream one file back and recompute its digest. */
184
+ export declare function verifyFile(store: TaskBoardAttachmentStore, attachment: TaskAttachment): Promise<void>;
185
+ /**
186
+ * The limits the board publishes for its attachments: the board's own caps,
187
+ * lowered by the deployment's image policy where that policy is stricter.
188
+ */
189
+ export declare function publishedAttachmentLimits(store: TaskBoardAttachmentStore | undefined): {
190
+ maxAttachments: number;
191
+ maxBytes: number;
192
+ maxTotalBytes: number;
193
+ maxImages: number;
194
+ maxImageBytes: number;
195
+ maxMessageImageBytes: number;
196
+ };
197
+ /** One image resolved for an execution prompt. */
198
+ export interface ExecutionImagePart {
199
+ type: 'image';
200
+ mediaType: string;
201
+ data: string;
202
+ name?: string;
203
+ }
204
+ /** One file resolved for an execution prompt: its readable host path. */
205
+ export interface ExecutionFilePart {
206
+ name: string;
207
+ path: string;
208
+ bytes: number;
209
+ mediaType: string;
210
+ }
211
+ /** The attachments of a card, resolved for one execution. */
212
+ export interface ResolvedAttachments {
213
+ /** The images, in the order the card lists them. */
214
+ images: ExecutionImagePart[];
215
+ /** The files, in the order the card lists them. */
216
+ files: ExecutionFilePart[];
217
+ }
218
+ /**
219
+ * Resolve a card's attachments for one execution: images become prompt image
220
+ * parts, files become readable host paths.
221
+ *
222
+ * Every execution resolves the attachments afresh — the recorded metadata is
223
+ * never trusted on its own, and a file whose host path is missing or
224
+ * unreadable fails the run instead of being silently dropped.
225
+ */
226
+ export declare function resolveExecutionAttachments(store: TaskBoardAttachmentStore, attachments: readonly TaskAttachment[]): Promise<ResolvedAttachments>;
227
+ /**
228
+ * The attachment section of an execution prompt: the readable paths of the
229
+ * card's files, marked read-only.
230
+ *
231
+ * It is a section of its own — never folded into the handover preamble — so
232
+ * the two kinds of reference stay distinguishable to the reading agent.
233
+ */
234
+ export declare function attachmentPromptPreamble(files: readonly ExecutionFilePart[]): string | undefined;
235
+ /** The model-info reader the image preflight uses. */
236
+ export type ModelInfoResolver = (provider: string, model: string, signal?: AbortSignal) => Promise<{
237
+ inputModalities?: readonly string[];
238
+ } | undefined>;
239
+ /**
240
+ * Refuse an execution whose route cannot read images.
241
+ *
242
+ * The check uses the ACTUAL route of the session the run is about to use and
243
+ * the model's own declared input modalities. A route that declares no
244
+ * modalities is UNKNOWN, and an unknown route is allowed: the official model
245
+ * catalog publishes no modality information, so it cannot answer this
246
+ * question, and refusing on its silence would block every image run.
247
+ */
248
+ export declare function assertRouteAcceptsImages(resolveModelInfo: ModelInfoResolver | undefined, provider: string, model: string): Promise<void>;
249
+ /** The attachment kinds a card may carry, for the wire gates. */
250
+ export declare const ATTACHMENT_KINDS: readonly TaskAttachmentKind[];
@@ -31,11 +31,25 @@ export interface TaskBoardExtensionToolRegistry {
31
31
  export type TaskBoardActionApplier = (action: Exclude<TaskBoardAction, {
32
32
  kind: 'extension-action';
33
33
  }>, initiator?: string) => TaskBoardSnapshot;
34
+ /** Delivers one follow-up message into an existing execution session. */
35
+ export type TaskBoardFollowUpDelivery = (sessionId: string, text: string) => Promise<void>;
36
+ /** Applies one rework request through the board's own run path. */
37
+ export type TaskBoardReworkApplier = (taskId: string, instructions: string, initiator?: string) => void;
34
38
  /** Registry dependencies. */
35
39
  export interface TaskBoardExtensionRegistryOptions {
36
40
  ledger: HostTaskLedger;
37
41
  /** Apply an action through the board service (gates, run dispatch, schedule). */
38
42
  apply?: TaskBoardActionApplier;
43
+ /**
44
+ * Queue one follow-up message into a session. Absent means this deployment
45
+ * serves no session delivery, which the capability face refuses visibly.
46
+ */
47
+ followUp?: TaskBoardFollowUpDelivery;
48
+ /**
49
+ * Apply one rework run request (through the same gates a run takes). Absent
50
+ * means this deployment serves no rework, which the face refuses visibly.
51
+ */
52
+ rework?: TaskBoardReworkApplier;
39
53
  /** Resolve the deployment's tool registry; absent loses the tool surface only. */
40
54
  toolRegistry?: () => TaskBoardExtensionToolRegistry | undefined;
41
55
  now?: () => number;
@@ -46,6 +60,8 @@ export declare class TaskBoardExtensionRegistry {
46
60
  private readonly entries;
47
61
  private readonly ledger;
48
62
  private readonly applyAction;
63
+ private readonly followUpDelivery;
64
+ private readonly reworkApply;
49
65
  private readonly now;
50
66
  private readonly uuid;
51
67
  private readonly logger;
@@ -104,6 +120,30 @@ export declare class TaskBoardExtensionRegistry {
104
120
  private createTask;
105
121
  private patchContent;
106
122
  private setStatus;
123
+ /**
124
+ * Queue one follow-up message into the session of a card's current or most
125
+ * recent execution.
126
+ *
127
+ * A running card is the point of the capability, so an open execution is not
128
+ * a refusal: the message is queued behind the turn that is already going. What
129
+ * IS refused is a card with no conversation to deliver into, and a session
130
+ * this Host no longer reaches — the delivery refuses, and that refusal must
131
+ * reach the provider as such instead of looking like a silent success.
132
+ */
133
+ private followUp;
134
+ /**
135
+ * Re-run an executed card in its own session with rework instructions.
136
+ *
137
+ * The registry decides only what it can read from the ledger — the card
138
+ * exists, is not archived, is not running, and has a conversation to continue
139
+ * — and then hands the request to the board's own run path, so the running
140
+ * lock, the permission confirmation, the acceptance contract and the spend cap
141
+ * keep judging it. A board refusal surfaces unchanged, exactly as it does for
142
+ * {@link setStatus}, because those are the board's own words.
143
+ */
144
+ private rework;
145
+ /** One task by id, or the refusal that names the unknown id. */
146
+ private requireTask;
107
147
  private linkedTasks;
108
148
  private writeIntegration;
109
149
  private publish;
@@ -0,0 +1,71 @@
1
+ /**
2
+ * Admission control for the session-creating half of a run.
3
+ *
4
+ * A run opens one session, so the burst this bounds is several runs starting at
5
+ * once — several cards run from different tabs, or a due schedule firing while
6
+ * a manual run is still launching. Unbounded, the Host asks DSH for N sessions
7
+ * in the same tick: the burst the repository's measured guidance caps at three
8
+ * heavy implementation subagents (docs/multi-agent-resources.md), with no
9
+ * mechanism enforcing it.
10
+ *
11
+ * The queue is SERVICE-wide, not per run group: the pressure it bounds is the
12
+ * machine's (the Host process's memory and the swap it drives), and two run
13
+ * groups opened from two tabs share one Host. Admission is round-robin across
14
+ * run groups — FIFO inside a group — so one run cannot starve another opened
15
+ * after it, and no entry can be starved.
16
+ *
17
+ * The width is read through a live callback, so a settings edit takes effect on
18
+ * the next admission without remounting anything.
19
+ *
20
+ * @module dsh-task-board/host/launch-admission
21
+ */
22
+ /** One launch the queue has not started yet. */
23
+ export interface QueuedLaunch {
24
+ /** Run group this launch belongs to; the unit of round-robin fairness. */
25
+ readonly groupId: string;
26
+ /**
27
+ * Perform the launch. The slot is held until this promise settles, which
28
+ * makes "in flight" mean "still creating and prompting its session".
29
+ * A rejection is swallowed here so one broken launch can never wedge the
30
+ * slot; the caller owns reporting.
31
+ */
32
+ start(): Promise<void>;
33
+ /**
34
+ * Called by {@link LaunchAdmissionQueue.drain} for a launch that never
35
+ * started, so the caller can take its execution out of the running column.
36
+ */
37
+ abandon(): void;
38
+ }
39
+ export declare class LaunchAdmissionQueue {
40
+ private readonly width;
41
+ /** Waiting launches per run group, in arrival order. */
42
+ private readonly waiting;
43
+ /** Run groups in round-robin order. */
44
+ private rotation;
45
+ /** Slot holders of the launches in flight, one per admitted launch. */
46
+ private readonly inFlight;
47
+ /** Highest number of launches in flight at once; observability and tests. */
48
+ peakInFlight: number;
49
+ /**
50
+ * @param width - live admission width (already normalized by the caller).
51
+ */
52
+ constructor(width: () => number);
53
+ /** Launches the queue has not admitted yet. */
54
+ get pendingCount(): number;
55
+ /** Launches currently holding a slot. */
56
+ get inFlightCount(): number;
57
+ /** Admit one launch, immediately if a slot is free. */
58
+ enqueue(launch: QueuedLaunch): void;
59
+ /**
60
+ * Abandon every waiting launch: the queue is being torn down, so an entry
61
+ * that never started can never start. Launches already in flight are left
62
+ * alone — their session may already exist, and the callers that own them
63
+ * settle them through the normal path.
64
+ * @returns the abandoned launches, in abandonment order.
65
+ */
66
+ drain(): QueuedLaunch[];
67
+ private pump;
68
+ /** The next launch by round-robin across groups and FIFO inside one. */
69
+ private takeNext;
70
+ private admit;
71
+ }