@fish-under-sea/dsh-client-ui-task-board-fish 0.0.0-stage → 0.5.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 (165) hide show
  1. package/LICENSE +202 -0
  2. package/README.i18n.yaml +6 -0
  3. package/README.md +202 -2
  4. package/README.zh.md +203 -0
  5. package/cordis.patch.yml +12 -0
  6. package/icon.svg +3 -0
  7. package/lib/client.js +12941 -0
  8. package/lib/client.js.map +1 -0
  9. package/lib/index.js +10471 -0
  10. package/lib/types/client/PluginSettingsCard.d.ts +144 -0
  11. package/lib/types/client/TaskBoardSettingsCard.d.ts +92 -0
  12. package/lib/types/client/apply-guard.d.ts +25 -0
  13. package/lib/types/client/board/ClampedMarkdown.d.ts +3 -0
  14. package/lib/types/client/board/ConfirmDialog.d.ts +15 -0
  15. package/lib/types/client/board/EditTaskModal.d.ts +17 -0
  16. package/lib/types/client/board/LinkSubtaskModal.d.ts +14 -0
  17. package/lib/types/client/board/NewTaskModal.d.ts +26 -0
  18. package/lib/types/client/board/TagManagerModal.d.ts +26 -0
  19. package/lib/types/client/board/TaskBoard.d.ts +26 -0
  20. package/lib/types/client/board/TaskCard.d.ts +36 -0
  21. package/lib/types/client/board/TaskDetail.d.ts +9 -0
  22. package/lib/types/client/board/TaskForm.d.ts +72 -0
  23. package/lib/types/client/board/VerificationReport.d.ts +23 -0
  24. package/lib/types/client/board/card-view.d.ts +113 -0
  25. package/lib/types/client/board/icons.d.ts +32 -0
  26. package/lib/types/client/board/overlay.d.ts +69 -0
  27. package/lib/types/client/board/parse-model-pref.d.ts +4 -0
  28. package/lib/types/client/board/preset-label.d.ts +22 -0
  29. package/lib/types/client/board/status-key.d.ts +19 -0
  30. package/lib/types/client/board/task-markdown.d.ts +19 -0
  31. package/lib/types/client/host-api.d.ts +63 -0
  32. package/lib/types/client/index.d.ts +128 -0
  33. package/lib/types/client/locales.d.ts +443 -0
  34. package/lib/types/client/main-session.d.ts +32 -0
  35. package/lib/types/client/native-panel.d.ts +48 -0
  36. package/lib/types/client/plugin-card-seat.d.ts +108 -0
  37. package/lib/types/client/schedule-presets.d.ts +10 -0
  38. package/lib/types/client/schedule-zone.d.ts +97 -0
  39. package/lib/types/client/seats.d.ts +18 -0
  40. package/lib/types/client/service.d.ts +32 -0
  41. package/lib/types/client/settings-entry-form.d.ts +49 -0
  42. package/lib/types/client/settings-form.d.ts +213 -0
  43. package/lib/types/core/controller.d.ts +373 -0
  44. package/lib/types/core/degraded-reason.d.ts +46 -0
  45. package/lib/types/core/extension.d.ts +283 -0
  46. package/lib/types/core/freeze-snapshot.d.ts +71 -0
  47. package/lib/types/core/handover.d.ts +70 -0
  48. package/lib/types/core/issue-form.d.ts +16 -0
  49. package/lib/types/core/package-name.d.ts +9 -0
  50. package/lib/types/core/poll-cadence.d.ts +31 -0
  51. package/lib/types/core/schedule.d.ts +124 -0
  52. package/lib/types/core/session-reuse.d.ts +24 -0
  53. package/lib/types/core/store.d.ts +64 -0
  54. package/lib/types/core/subtask.d.ts +141 -0
  55. package/lib/types/core/tasks.d.ts +601 -0
  56. package/lib/types/core/use-cases/task-archive.d.ts +20 -0
  57. package/lib/types/core/use-cases/task-create.d.ts +27 -0
  58. package/lib/types/core/use-cases/task-delete.d.ts +27 -0
  59. package/lib/types/core/use-cases/task-parent.d.ts +21 -0
  60. package/lib/types/core/use-cases/task-schedule.d.ts +96 -0
  61. package/lib/types/core/use-cases/task-tag.d.ts +48 -0
  62. package/lib/types/core/use-cases/task-update.d.ts +56 -0
  63. package/lib/types/core/verification-budget.d.ts +52 -0
  64. package/lib/types/core/verification.d.ts +753 -0
  65. package/lib/types/core/workspace-target.d.ts +41 -0
  66. package/lib/types/dsh-home.d.ts +16 -0
  67. package/lib/types/host/agent-tools.d.ts +27 -0
  68. package/lib/types/host/extension-registry.d.ts +111 -0
  69. package/lib/types/host/llm-dispatch.d.ts +63 -0
  70. package/lib/types/host/verification-gate.d.ts +95 -0
  71. package/lib/types/host/verification-runner.d.ts +139 -0
  72. package/lib/types/host/workspace-evidence.d.ts +53 -0
  73. package/lib/types/host-ai.d.ts +51 -0
  74. package/lib/types/host-ledger.d.ts +385 -0
  75. package/lib/types/host-routes.d.ts +36 -0
  76. package/lib/types/host-runner.d.ts +252 -0
  77. package/lib/types/host-service.d.ts +379 -0
  78. package/lib/types/http.d.ts +59 -0
  79. package/lib/types/index.d.ts +322 -0
  80. package/lib/types/loopback.d.ts +24 -0
  81. package/lib/types/mount-once.d.ts +55 -0
  82. package/lib/types/power-inhibitor.d.ts +73 -0
  83. package/lib/types/protocol.d.ts +212 -0
  84. package/lib/types/tool-surface.d.ts +71 -0
  85. package/package.json +107 -4
  86. package/src/client/PluginSettingsCard.tsx +564 -0
  87. package/src/client/TaskBoardSettingsCard.tsx +539 -0
  88. package/src/client/apply-guard.ts +35 -0
  89. package/src/client/board/ClampedMarkdown.tsx +69 -0
  90. package/src/client/board/ConfirmDialog.tsx +44 -0
  91. package/src/client/board/EditTaskModal.tsx +110 -0
  92. package/src/client/board/LinkSubtaskModal.tsx +97 -0
  93. package/src/client/board/NewTaskModal.tsx +718 -0
  94. package/src/client/board/TagManagerModal.tsx +235 -0
  95. package/src/client/board/TaskBoard.tsx +558 -0
  96. package/src/client/board/TaskCard.tsx +315 -0
  97. package/src/client/board/TaskDetail.tsx +985 -0
  98. package/src/client/board/TaskForm.tsx +264 -0
  99. package/src/client/board/VerificationReport.tsx +322 -0
  100. package/src/client/board/card-view.ts +220 -0
  101. package/src/client/board/icons.tsx +89 -0
  102. package/src/client/board/overlay.tsx +189 -0
  103. package/src/client/board/parse-model-pref.ts +35 -0
  104. package/src/client/board/preset-label.ts +44 -0
  105. package/src/client/board/status-key.ts +41 -0
  106. package/src/client/board/task-markdown.module.css +137 -0
  107. package/src/client/board/task-markdown.tsx +106 -0
  108. package/src/client/board-settings.module.css +66 -0
  109. package/src/client/board.module.css +1837 -0
  110. package/src/client/css-modules.d.ts +5 -0
  111. package/src/client/host-api.ts +336 -0
  112. package/src/client/index.ts +501 -0
  113. package/src/client/locales.ts +905 -0
  114. package/src/client/main-session.ts +43 -0
  115. package/src/client/native-panel.tsx +140 -0
  116. package/src/client/plugin-card-seat.ts +199 -0
  117. package/src/client/schedule-presets.ts +13 -0
  118. package/src/client/schedule-zone.ts +233 -0
  119. package/src/client/seats.tsx +58 -0
  120. package/src/client/service.ts +94 -0
  121. package/src/client/settings-card.module.css +444 -0
  122. package/src/client/settings-entry-form.ts +142 -0
  123. package/src/client/settings-form.ts +468 -0
  124. package/src/core/controller.ts +871 -0
  125. package/src/core/degraded-reason.ts +81 -0
  126. package/src/core/extension.ts +376 -0
  127. package/src/core/freeze-snapshot.ts +213 -0
  128. package/src/core/handover.ts +132 -0
  129. package/src/core/issue-form.ts +19 -0
  130. package/src/core/package-name.ts +9 -0
  131. package/src/core/poll-cadence.ts +41 -0
  132. package/src/core/schedule.ts +363 -0
  133. package/src/core/session-reuse.ts +40 -0
  134. package/src/core/store.ts +371 -0
  135. package/src/core/subtask.ts +341 -0
  136. package/src/core/tasks.ts +843 -0
  137. package/src/core/use-cases/task-archive.ts +91 -0
  138. package/src/core/use-cases/task-create.ts +110 -0
  139. package/src/core/use-cases/task-delete.ts +43 -0
  140. package/src/core/use-cases/task-parent.ts +65 -0
  141. package/src/core/use-cases/task-schedule.ts +251 -0
  142. package/src/core/use-cases/task-tag.ts +110 -0
  143. package/src/core/use-cases/task-update.ts +126 -0
  144. package/src/core/verification-budget.ts +115 -0
  145. package/src/core/verification.ts +1594 -0
  146. package/src/core/workspace-target.ts +59 -0
  147. package/src/dsh-home.ts +42 -0
  148. package/src/host/agent-tools.ts +762 -0
  149. package/src/host/extension-registry.ts +509 -0
  150. package/src/host/llm-dispatch.ts +87 -0
  151. package/src/host/verification-gate.ts +487 -0
  152. package/src/host/verification-runner.ts +702 -0
  153. package/src/host/workspace-evidence.ts +176 -0
  154. package/src/host-ai.ts +158 -0
  155. package/src/host-ledger.ts +1826 -0
  156. package/src/host-routes.ts +306 -0
  157. package/src/host-runner.ts +755 -0
  158. package/src/host-service.ts +1112 -0
  159. package/src/http.ts +127 -0
  160. package/src/index.ts +722 -0
  161. package/src/loopback.ts +63 -0
  162. package/src/mount-once.ts +142 -0
  163. package/src/power-inhibitor.ts +321 -0
  164. package/src/protocol.ts +591 -0
  165. package/src/tool-surface.ts +95 -0
@@ -0,0 +1,126 @@
1
+ /**
2
+ * Update-task use case: apply an editable-field patch (title/description/
3
+ * prompt plus the execution targets workspaceId/mode/permission) with a
4
+ * fresh updatedAt. Pure ledger transition (no persistence or notify — the
5
+ * controller orchestrates those).
6
+ *
7
+ * An explicit `undefined` in the patch clears the field (the task falls
8
+ * back to the runtime default); an unknown permission string is ignored so
9
+ * stale UI can never persist a value the execution service rejects.
10
+ */
11
+ import { freezeOf, isTaskPermission, normalizeTags, normalizeTargetId, type TaskRecord, type TaskPermission, type TaskTag } from '../tasks.ts'
12
+ import type { FreezeSnapshot } from '../freeze-snapshot.ts'
13
+ import type { TaskHandoverInput } from '../handover.ts'
14
+
15
+ /**
16
+ * Editable fields on a task (the update patch surface). `freeze` replaces the
17
+ * continuation-card snapshot (restamping frozenAt); an explicit null clears it.
18
+ */
19
+ export type TaskUpdatePatch = Partial<Pick<TaskRecord, 'title' | 'description' | 'prompt' | 'workspaceId' | 'mode' | 'permission' | 'model' | 'reuseSession' | 'teamRun' | 'goalRun' | 'skipVerification'>> & {
20
+ freeze?: FreezeSnapshot & { redacted?: boolean } | null
21
+ /** Replaces the handover bundle (restamping bundledAt); an explicit null clears it. */
22
+ handover?: TaskHandoverInput | null
23
+ /**
24
+ * Replaces the task's labels (issue #1521). Unlike the content fields, tags
25
+ * stay editable after the first run: they classify the task and shape the
26
+ * NEXT execution prompt, they are not the record of what already ran. An
27
+ * explicit null (or a list that normalizes to nothing) clears them.
28
+ */
29
+ tags?: TaskTag[] | null
30
+ }
31
+
32
+ /** The fields that edit the task's content (what the user reads and what the
33
+ * next execution sends). Unlike the execution targets they stay editable only
34
+ * while the task has never started executing — after the first run the
35
+ * recorded prompt is the record of what actually ran, so it becomes read-only.
36
+ */
37
+ export const TASK_CONTENT_FIELDS = ['title', 'description', 'prompt'] as const
38
+
39
+ /** Whether an update patch touches any task-content field. */
40
+ export function hasContentPatch(patch: TaskUpdatePatch): boolean {
41
+ return (TASK_CONTENT_FIELDS as readonly string[]).some(field => field in patch)
42
+ }
43
+
44
+ /**
45
+ * Whether a task's content may still be edited: the task must be on-board
46
+ * (not archived) and must never have started executing. Fail-closed: a task
47
+ * with any execution record — running, settled, or cancelled before launch —
48
+ * keeps its content fixed. The run, not the column, is the trigger: a card
49
+ * parked in 'running' by hand has nothing recorded yet and stays editable.
50
+ */
51
+ export function canEditTaskContent(task: TaskRecord): boolean {
52
+ return task.archivedAt === undefined && task.executions.length === 0
53
+ }
54
+
55
+ /** Keep an unknown permission string from entering the ledger. */
56
+ function normalizePermission(
57
+ current: TaskPermission | undefined,
58
+ value: TaskPermission | undefined,
59
+ ): TaskPermission | undefined {
60
+ if (value === undefined) return undefined
61
+ return isTaskPermission(value) ? value : current
62
+ }
63
+
64
+ /**
65
+ * Apply an update across the ledger. Tasks that do not match the id are left
66
+ * untouched; the matched task receives the patch plus a fresh updatedAt.
67
+ * @param tasks - current ledger.
68
+ * @param id - the task to update.
69
+ * @param patch - editable-field changes.
70
+ * @param now - clock instant (ms epoch).
71
+ */
72
+ export function applyUpdateTask(
73
+ tasks: readonly TaskRecord[],
74
+ id: string,
75
+ patch: TaskUpdatePatch,
76
+ now: number,
77
+ ): readonly TaskRecord[] {
78
+ return tasks.map(task => {
79
+ if (task.id !== id) return task
80
+ const { freeze: freezePatch, handover: handoverPatch, tags: tagsPatch, ...rest } = patch
81
+ const workspaceId = 'workspaceId' in patch ? normalizeTargetId(patch.workspaceId) : undefined
82
+ const mode = 'mode' in patch ? normalizeTargetId(patch.mode) : undefined
83
+ const permission = 'permission' in patch ? normalizePermission(task.permission, patch.permission) : undefined
84
+ const model = 'model' in patch ? normalizeTargetId(patch.model) : undefined
85
+ const next: TaskRecord = { ...task, ...rest, updatedAt: now }
86
+ // Content fields normalize like creation does (trimmed); an explicit
87
+ // undefined keeps the current value — content cannot be cleared.
88
+ for (const field of TASK_CONTENT_FIELDS) {
89
+ if (!(field in patch)) continue
90
+ const value = patch[field]
91
+ next[field] = value === undefined ? task[field] : value.trim()
92
+ }
93
+ // null (or a vanished key value) clears the snapshot; a present object
94
+ // replaces it with a fresh frozenAt stamp.
95
+ next.freeze = freezePatch == null ? undefined : freezeOf(freezePatch, now)
96
+ // Handover follows the same null-clears convention, restamping bundledAt.
97
+ next.handover = handoverPatch == null ? undefined : { ...handoverPatch, bundledAt: now }
98
+ // Tags use the same convention: a present array replaces the set (after
99
+ // repair), an explicit null or a fully-invalid list clears it.
100
+ if ('tags' in patch) next.tags = tagsPatch == null ? undefined : normalizeTags(tagsPatch)
101
+ // The permission confirmation binds the exact permission value: a change
102
+ // of the pinned permission or of the handover bundle re-arms the gate
103
+ // (blocking confirm-then-swap escalation). handover was destructured out
104
+ // of rest above, so the stamp survives only when explicitly kept.
105
+ if (('permission' in patch && patch.permission !== undefined && patch.permission !== task.permission) || 'handover' in patch) {
106
+ next.permissionConfirmedAt = undefined
107
+ }
108
+ // Session reuse is a boolean opt-in; false (or an explicit null from a
109
+ // caller that needs to clear it) returns the task to one session per run.
110
+ if ('reuseSession' in patch) next.reuseSession = patch.reuseSession === true ? true : undefined
111
+ // Team execution is a boolean opt-in with the same clear-by-false rule.
112
+ if ('teamRun' in patch) next.teamRun = patch.teamRun === true ? true : undefined
113
+ // The /goal opt-in is default-OFF: true joins the goal run, while false
114
+ // (or an explicit null) returns the card to the default and stores nothing.
115
+ if ('goalRun' in patch) next.goalRun = patch.goalRun === true ? true : undefined
116
+ // The acceptance opt-out is the mirror image: default OFF, so only true
117
+ // pins a card out of the gate; false (or an explicit null) returns it to
118
+ // inheriting the board-wide switch and stores nothing.
119
+ if ('skipVerification' in patch) next.skipVerification = patch.skipVerification === true ? true : undefined
120
+ if (workspaceId !== undefined || 'workspaceId' in patch) next.workspaceId = workspaceId
121
+ if (mode !== undefined || 'mode' in patch) next.mode = mode
122
+ if (permission !== undefined || 'permission' in patch) next.permission = permission
123
+ if (model !== undefined || 'model' in patch) next.model = model
124
+ return next
125
+ })
126
+ }
@@ -0,0 +1,115 @@
1
+ /**
2
+ * Goal acceptance time budgets: the one place the judge's per-call ceiling and
3
+ * the acceptance's total ceiling live.
4
+ *
5
+ * Both are user settings (seconds), so the bounds and the seconds to
6
+ * milliseconds conversion live here rather than in either half: the Host
7
+ * clamps a hand-edited profile value to the same range the schema declares, and
8
+ * the gate reads the effective values live, so raising a ceiling takes effect
9
+ * without a reload.
10
+ *
11
+ * The two numbers are one budget, not two independent knobs: one acceptance is
12
+ * {@link ACCEPTANCE_JUDGE_CALLS} serial judge calls (three criteria times two
13
+ * rounds), so a total budget that cannot fit the calls can only end the
14
+ * acceptance early. {@link DEFAULT_VERIFICATION_BUDGET_SECONDS} is therefore
15
+ * derived from the per-call default times the call count plus two retries.
16
+ *
17
+ * @module dsh-task-board/core/verification-budget
18
+ */
19
+ import { CODING_CRITERIA, VERIFICATION_ROUNDS } from './verification.ts'
20
+
21
+ /** Judge calls one acceptance issues: every criterion, every round. */
22
+ export const ACCEPTANCE_JUDGE_CALLS: number = CODING_CRITERIA.length * VERIFICATION_ROUNDS
23
+
24
+ /**
25
+ * Per-judge-call ceiling used when the row names none: two and a half minutes
26
+ * for a reasoning model reading an 80,000 character trace with a 16,384 token
27
+ * output cap. The former 120s constant was tight enough that a slow but healthy
28
+ * route produced a wall of per-call timeouts, and every one of them was charged
29
+ * as an acceptance anomaly against a budget that then failed the card.
30
+ */
31
+ export const DEFAULT_VERIFICATION_CALL_TIMEOUT_SECONDS = 150
32
+
33
+ /** Shortest accepted per-call ceiling: below this no useful judge answers. */
34
+ export const VERIFICATION_CALL_TIMEOUT_MIN_SECONDS = 30
35
+
36
+ /** Longest accepted per-call ceiling, ten minutes. */
37
+ export const VERIFICATION_CALL_TIMEOUT_MAX_SECONDS = 600
38
+
39
+ /** Headroom the default total budget leaves beyond the mandatory calls. */
40
+ const DEFAULT_BUDGET_EXTRA_CALLS = 2
41
+
42
+ /**
43
+ * Total ceiling of one acceptance attempt, covering evidence rendering and
44
+ * every judge call including retries. Derived from the per-call default rather
45
+ * than pinned, because a total budget smaller than
46
+ * {@link ACCEPTANCE_JUDGE_CALLS} times the per-call ceiling guarantees that no
47
+ * acceptance can ever finish.
48
+ */
49
+ export const DEFAULT_VERIFICATION_BUDGET_SECONDS: number =
50
+ DEFAULT_VERIFICATION_CALL_TIMEOUT_SECONDS * (ACCEPTANCE_JUDGE_CALLS + DEFAULT_BUDGET_EXTRA_CALLS)
51
+
52
+ /** Shortest accepted total budget: long enough for at least one judge call. */
53
+ export const VERIFICATION_BUDGET_MIN_SECONDS = 120
54
+
55
+ /** Longest accepted total budget, thirty minutes. */
56
+ export const VERIFICATION_BUDGET_MAX_SECONDS = 1800
57
+
58
+ /** The default total budget in milliseconds, the face the abort timer takes. */
59
+ export const DEFAULT_VERIFICATION_BUDGET_MS = DEFAULT_VERIFICATION_BUDGET_SECONDS * 1_000
60
+
61
+ /**
62
+ * Clamp a configured ceiling into the supported range. A value the schema
63
+ * would refuse (non-finite, below the floor, above the ceiling) still leaves
64
+ * the board judging: an out-of-range setting never disables acceptance.
65
+ * @param value - configured seconds, or undefined for the default.
66
+ * @param fallback - the default to use when nothing usable was configured.
67
+ * @param min - shortest accepted value.
68
+ * @param max - longest accepted value.
69
+ * @returns the effective value in seconds.
70
+ */
71
+ function clampSeconds(value: number | undefined, fallback: number, min: number, max: number): number {
72
+ if (value === undefined || !Number.isFinite(value)) return fallback
73
+ return Math.min(Math.max(Math.trunc(value), min), max)
74
+ }
75
+
76
+ /**
77
+ * The effective per-judge-call ceiling.
78
+ * @param seconds - configured seconds, or undefined for the default.
79
+ * @returns the effective ceiling in seconds.
80
+ */
81
+ export function normalizeVerificationCallTimeoutSeconds(seconds: number | undefined): number {
82
+ return clampSeconds(
83
+ seconds,
84
+ DEFAULT_VERIFICATION_CALL_TIMEOUT_SECONDS,
85
+ VERIFICATION_CALL_TIMEOUT_MIN_SECONDS,
86
+ VERIFICATION_CALL_TIMEOUT_MAX_SECONDS,
87
+ )
88
+ }
89
+
90
+ /**
91
+ * The effective per-judge-call ceiling the timer face takes.
92
+ * @param seconds - configured seconds, or undefined for the default.
93
+ * @returns the effective ceiling in milliseconds.
94
+ */
95
+ export function verificationCallTimeoutMs(seconds: number | undefined): number {
96
+ return normalizeVerificationCallTimeoutSeconds(seconds) * 1_000
97
+ }
98
+
99
+ /**
100
+ * The effective total budget of one acceptance attempt.
101
+ * @param seconds - configured seconds, or undefined for the default.
102
+ * @returns the effective budget in seconds.
103
+ */
104
+ export function normalizeVerificationBudgetSeconds(seconds: number | undefined): number {
105
+ return clampSeconds(seconds, DEFAULT_VERIFICATION_BUDGET_SECONDS, VERIFICATION_BUDGET_MIN_SECONDS, VERIFICATION_BUDGET_MAX_SECONDS)
106
+ }
107
+
108
+ /**
109
+ * The effective total budget the abort face takes.
110
+ * @param seconds - configured seconds, or undefined for the default.
111
+ * @returns the effective budget in milliseconds.
112
+ */
113
+ export function verificationBudgetMs(seconds: number | undefined): number {
114
+ return normalizeVerificationBudgetSeconds(seconds) * 1_000
115
+ }