@linxin666/dsh-client-ui-task-board 0.4.16 → 0.4.18

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 (65) hide show
  1. package/README.i18n.yaml +2 -2
  2. package/README.md +16 -36
  3. package/README.zh.md +16 -36
  4. package/lib/client.js +107 -1354
  5. package/lib/client.js.map +1 -1
  6. package/lib/index.js +138 -2537
  7. package/lib/types/client/TaskBoardSettingsCard.d.ts +0 -20
  8. package/lib/types/client/board/status-key.d.ts +0 -15
  9. package/lib/types/client/locales.d.ts +1 -110
  10. package/lib/types/client/settings-entry-form.d.ts +1 -1
  11. package/lib/types/core/controller.d.ts +1 -1
  12. package/lib/types/core/extension.d.ts +4 -5
  13. package/lib/types/core/model-catalog.d.ts +58 -0
  14. package/lib/types/core/reasoning-effort.d.ts +1 -1
  15. package/lib/types/core/tasks.d.ts +0 -45
  16. package/lib/types/core/use-cases/task-update.d.ts +1 -1
  17. package/lib/types/host/llm-dispatch.d.ts +8 -10
  18. package/lib/types/host-ledger.d.ts +0 -28
  19. package/lib/types/host-runner.d.ts +6 -71
  20. package/lib/types/host-service.d.ts +17 -89
  21. package/lib/types/index.d.ts +0 -78
  22. package/lib/types/protocol.d.ts +6 -23
  23. package/package.json +26 -26
  24. package/src/client/TaskBoardSettingsCard.tsx +13 -201
  25. package/src/client/board/ExecutionLog.tsx +2 -5
  26. package/src/client/board/NewTaskModal.tsx +1 -42
  27. package/src/client/board/TaskBoard.tsx +2 -2
  28. package/src/client/board/TaskCard.tsx +2 -7
  29. package/src/client/board/TaskDetail.tsx +2 -37
  30. package/src/client/board/status-key.ts +0 -30
  31. package/src/client/board-settings.module.css +3 -22
  32. package/src/client/board.module.css +1 -104
  33. package/src/client/index.ts +2 -2
  34. package/src/client/locales.ts +6 -224
  35. package/src/client/settings-entry-form.ts +1 -1
  36. package/src/core/attachment.ts +1 -0
  37. package/src/core/controller.ts +1 -3
  38. package/src/core/extension.ts +4 -5
  39. package/src/core/freeze-snapshot.ts +3 -3
  40. package/src/core/model-catalog.ts +114 -0
  41. package/src/core/reasoning-effort.ts +1 -1
  42. package/src/core/store.ts +22 -17
  43. package/src/core/tasks.ts +0 -53
  44. package/src/core/use-cases/task-update.ts +1 -8
  45. package/src/host/agent-tools.ts +1 -15
  46. package/src/host/extension-registry.ts +2 -2
  47. package/src/host/llm-dispatch.ts +8 -10
  48. package/src/host-ledger.ts +3 -89
  49. package/src/host-routes.ts +4 -4
  50. package/src/host-runner.ts +13 -139
  51. package/src/host-service.ts +51 -266
  52. package/src/index.ts +9 -163
  53. package/src/protocol.ts +9 -44
  54. package/lib/types/client/board/VerificationReport.d.ts +0 -10
  55. package/lib/types/core/verification-budget.d.ts +0 -52
  56. package/lib/types/core/verification.d.ts +0 -753
  57. package/lib/types/host/verification-gate.d.ts +0 -95
  58. package/lib/types/host/verification-runner.d.ts +0 -139
  59. package/lib/types/host/workspace-evidence.d.ts +0 -53
  60. package/src/client/board/VerificationReport.tsx +0 -361
  61. package/src/core/verification-budget.ts +0 -115
  62. package/src/core/verification.ts +0 -1594
  63. package/src/host/verification-gate.ts +0 -487
  64. package/src/host/verification-runner.ts +0 -702
  65. package/src/host/workspace-evidence.ts +0 -176
@@ -1,176 +0,0 @@
1
- /**
2
- * Host-observed workspace changes, as acceptance evidence.
3
- *
4
- * The judge must not take the agent's word for what changed on disk: a patch
5
- * that was never applied, or a file edited again afterwards, looks identical to
6
- * a real edit when only the tool-call arguments are read. The DSH host records
7
- * what a turn actually changed and serves it through the optional
8
- * @@workspaceChanges@@ service, so that observation is offered next to the
9
- * trajectory instead of being trusted from the transcript.
10
- *
11
- * The service is described STRUCTURALLY and resolved optionally: a deployment
12
- * that serves none (or a cohort whose shape differs) degrades to "no extra
13
- * evidence" and never breaks an acceptance that has already spent judge budget.
14
- */
15
- import { createHash } from 'node:crypto'
16
-
17
- /** The subset of the host change service this module drives. */
18
- export interface WorkspaceChangeSource {
19
- summary(sessionId: string, seq: number): unknown
20
- diff(sessionId: string, seq: number, index: number, signal: AbortSignal): Promise<unknown>
21
- }
22
-
23
- /** One session event, as the host log carries it. */
24
- interface RawEvent {
25
- type?: unknown
26
- seq?: unknown
27
- }
28
-
29
- /** How many changed files one evidence block renders. */
30
- export const MAX_WORKSPACE_FILES = 8
31
- /** Character ceiling for the whole rendered block. */
32
- export const WORKSPACE_EVIDENCE_MAX_CHARS = 24_000
33
- /** Character ceiling for one file's rendered comparison. */
34
- export const WORKSPACE_EVIDENCE_MAX_FILE_CHARS = 6_000
35
-
36
- /**
37
- * Resolve the optional host change service from a context-like object.
38
- * @param ctx - anything exposing @@get(name)@@.
39
- * @returns the service, or undefined when this deployment serves none.
40
- */
41
- export function probeWorkspaceChanges(ctx: { get(name: string): unknown }): WorkspaceChangeSource | undefined {
42
- let service: unknown
43
- try {
44
- service = ctx.get('workspaceChanges')
45
- } catch {
46
- return undefined
47
- }
48
- if (typeof service !== 'object' || service === null) return undefined
49
- const candidate = service as { summary?: unknown; diff?: unknown }
50
- if (typeof candidate.summary !== 'function' || typeof candidate.diff !== 'function') return undefined
51
- return service as WorkspaceChangeSource
52
- }
53
-
54
- /** Read a finite number, else 0. */
55
- function count(value: unknown): number {
56
- return typeof value === 'number' && Number.isFinite(value) ? value : 0
57
- }
58
-
59
- /** Read a string, else ''. */
60
- function text(value: unknown): string {
61
- return typeof value === 'string' ? value : ''
62
- }
63
-
64
- /** Bound one text to a character budget, keeping the head. */
65
- function bound(value: string, maxChars: number): string {
66
- if (value.length <= maxChars) return value
67
- const notice = '\n[Truncated ' + (value.length - maxChars) + ' characters]'
68
- if (notice.length >= maxChars) return value.slice(0, maxChars)
69
- return value.slice(0, maxChars - notice.length) + notice
70
- }
71
-
72
- /** The sequence of the newest change event inside the reviewed window. */
73
- export function latestChangeEvent(events: readonly RawEvent[]): { seq: number; turn?: number } | undefined {
74
- let latest: { seq: number; turn?: number } | undefined
75
- for (const event of events) {
76
- if (event.type !== 'workspace/changes') continue
77
- if (typeof event.seq !== 'number') continue
78
- if (latest === undefined || event.seq >= latest.seq) latest = { seq: event.seq }
79
- }
80
- return latest
81
- }
82
-
83
- /** Render one file's comparison from whatever shape the service answered. */
84
- function renderDiff(value: unknown, maxChars: number): string {
85
- if (typeof value !== 'object' || value === null) return '[no comparison available]'
86
- const diff = value as Record<string, unknown>
87
- if (diff.binary === true || text(diff.kind) === 'binary') return '[binary file]'
88
- if (diff.oversized === true) return '[file too large to compare]'
89
- const patch = text(diff.patch)
90
- if (patch !== '') return bound(patch, maxChars)
91
- const hunks = Array.isArray(diff.hunks) ? diff.hunks : []
92
- const lines: string[] = []
93
- for (const entry of hunks) {
94
- if (typeof entry !== 'object' || entry === null) continue
95
- const hunk = entry as Record<string, unknown>
96
- lines.push('@@ -' + count(hunk.oldStart) + ',' + count(hunk.oldLines) + ' +' + count(hunk.newStart) + ',' + count(hunk.newLines) + ' @@')
97
- const body = Array.isArray(hunk.lines) ? hunk.lines : []
98
- for (const line of body) {
99
- if (typeof line === 'string') lines.push(line)
100
- else if (typeof line === 'object' && line !== null) {
101
- const row = line as Record<string, unknown>
102
- const marker = text(row.kind) === 'add' ? '+' : text(row.kind) === 'delete' ? '-' : ' '
103
- lines.push(marker + text(row.text))
104
- }
105
- }
106
- }
107
- return lines.length === 0 ? '' : bound(lines.join('\n'), maxChars)
108
- }
109
-
110
- /**
111
- * Render the host's own record of what the reviewed window changed.
112
- *
113
- * Bounded twice — at most {@link MAX_WORKSPACE_FILES} files, and a shared
114
- * character budget split across them — so one enormous generated file cannot
115
- * crowd out every other change. Every failure degrades to less evidence (or an
116
- * empty block) instead of an error, because the acceptance being prepared must
117
- * still reach a verdict.
118
- * @param events - session events already bounded to the execution's window.
119
- * @param sessionId - the session whose changes these are.
120
- * @param source - the probed host service.
121
- * @param options - budget, cancellation and the diagnostic sink.
122
- * @returns the rendered block plus how many files it shows.
123
- */
124
- export async function renderWorkspaceEvidence(
125
- events: readonly RawEvent[],
126
- sessionId: string,
127
- source: WorkspaceChangeSource,
128
- options: { signal: AbortSignal; warn?: (message: string) => void; maxChars?: number },
129
- ): Promise<{ text: string; files: number; hash: string }> {
130
- const warn = options.warn ?? ((): void => {})
131
- const maxChars = options.maxChars ?? WORKSPACE_EVIDENCE_MAX_CHARS
132
- try {
133
- const event = latestChangeEvent(events)
134
- if (event === undefined) return { text: '', files: 0, hash: '' }
135
- const summary = source.summary(sessionId, event.seq)
136
- if (typeof summary !== 'object' || summary === null) return { text: '', files: 0, hash: '' }
137
- const view = summary as Record<string, unknown>
138
- const listed = (Array.isArray(view.files) ? view.files : [])
139
- .map((file, index) => ({ file, index }))
140
- .filter((entry): entry is { file: Record<string, unknown>, index: number } => typeof entry.file === 'object' && entry.file !== null)
141
- if (listed.length === 0) return { text: '', files: 0, hash: '' }
142
- const shown = listed.slice(0, MAX_WORKSPACE_FILES)
143
- const added = count(view.added)
144
- const deleted = count(view.deleted)
145
- const header = 'Host-recorded workspace changes'
146
- + (typeof view.turn === 'number' ? ' for turn ' + view.turn : '')
147
- + ': ' + listed.length + ' changed file(s)'
148
- + (added > 0 || deleted > 0 ? ' (+' + added + '/-' + deleted + ' lines)' : '')
149
- + (listed.length > shown.length ? '; showing the first ' + shown.length : '')
150
- + '.\nObserved by the DSH host from the workspace itself, not reported by the agent.'
151
- const perFile = Math.max(1, Math.min(WORKSPACE_EVIDENCE_MAX_FILE_CHARS, Math.floor((maxChars - header.length) / shown.length) - 40))
152
- const sections: string[] = []
153
- for (const entry of shown) {
154
- const path = text(entry.file.path) !== '' ? text(entry.file.path) : text(entry.file.display) !== '' ? text(entry.file.display) : 'file'
155
- const fileAdded = count(entry.file.added)
156
- const fileDeleted = count(entry.file.deleted)
157
- let comparison = ''
158
- try {
159
- comparison = renderDiff(await source.diff(sessionId, event.seq, entry.index, options.signal), perFile)
160
- } catch (error) {
161
- comparison = '[comparison unavailable]'
162
- warn('task-board workspace evidence unavailable for one file: ' + (error instanceof Error ? error.message : String(error)))
163
- }
164
- sections.push('- ' + path + (fileAdded > 0 || fileDeleted > 0 ? ' (+' + fileAdded + '/-' + fileDeleted + ')' : '') + '\n' + comparison)
165
- }
166
- const rendered = bound([header, ...sections].join('\n'), maxChars)
167
- return {
168
- text: rendered,
169
- files: shown.length,
170
- hash: createHash('sha256').update(rendered).digest('hex'),
171
- }
172
- } catch (error) {
173
- warn('task-board workspace evidence unavailable: ' + (error instanceof Error ? error.message : String(error)))
174
- return { text: '', files: 0, hash: '' }
175
- }
176
- }