@linxin666/dsh-client-ui-task-board 0.4.12 → 0.4.14

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 (61) hide show
  1. package/README.i18n.yaml +2 -2
  2. package/README.md +9 -3
  3. package/README.zh.md +9 -3
  4. package/lib/client.js +1476 -478
  5. package/lib/client.js.map +1 -1
  6. package/lib/index.js +1280 -65
  7. package/lib/types/client/board/AttachmentField.d.ts +70 -0
  8. package/lib/types/client/board/model-options.d.ts +21 -1
  9. package/lib/types/client/board/source-group.d.ts +27 -0
  10. package/lib/types/client/host-api.d.ts +25 -0
  11. package/lib/types/client/locales.d.ts +17 -0
  12. package/lib/types/client/pending-verify.d.ts +47 -0
  13. package/lib/types/client/service.d.ts +4 -1
  14. package/lib/types/core/attachment.d.ts +132 -0
  15. package/lib/types/core/controller.d.ts +26 -2
  16. package/lib/types/core/extension.d.ts +82 -0
  17. package/lib/types/core/session-reuse.d.ts +7 -1
  18. package/lib/types/core/tasks.d.ts +38 -1
  19. package/lib/types/core/use-cases/task-update.d.ts +21 -0
  20. package/lib/types/core/wire-projection.d.ts +35 -0
  21. package/lib/types/host/attachments.d.ts +250 -0
  22. package/lib/types/host/extension-registry.d.ts +40 -0
  23. package/lib/types/host-ledger.d.ts +16 -0
  24. package/lib/types/host-routes.d.ts +14 -0
  25. package/lib/types/host-runner.d.ts +53 -1
  26. package/lib/types/host-service.d.ts +59 -0
  27. package/lib/types/index.d.ts +23 -0
  28. package/lib/types/protocol.d.ts +39 -6
  29. package/locale/en.json +6 -0
  30. package/locale/zh.json +6 -0
  31. package/package.json +6 -2
  32. package/src/client/TaskBoardSettingsCard.tsx +11 -1
  33. package/src/client/board/AttachmentField.tsx +383 -0
  34. package/src/client/board/EditTaskModal.tsx +63 -0
  35. package/src/client/board/NewTaskModal.tsx +76 -4
  36. package/src/client/board/TaskBoard.tsx +47 -10
  37. package/src/client/board/TaskDetail.tsx +30 -2
  38. package/src/client/board/model-options.ts +32 -2
  39. package/src/client/board/source-group.ts +94 -0
  40. package/src/client/board.module.css +83 -0
  41. package/src/client/host-api.ts +70 -0
  42. package/src/client/index.ts +11 -0
  43. package/src/client/locales.ts +34 -0
  44. package/src/client/pending-verify.ts +90 -0
  45. package/src/client/service.ts +24 -0
  46. package/src/core/attachment.ts +287 -0
  47. package/src/core/controller.ts +47 -1
  48. package/src/core/extension.ts +86 -0
  49. package/src/core/session-reuse.ts +7 -1
  50. package/src/core/store.ts +10 -1
  51. package/src/core/tasks.ts +49 -0
  52. package/src/core/use-cases/task-update.ts +27 -2
  53. package/src/core/wire-projection.ts +81 -0
  54. package/src/host/attachments.ts +650 -0
  55. package/src/host/extension-registry.ts +150 -5
  56. package/src/host-ledger.ts +32 -4
  57. package/src/host-routes.ts +168 -13
  58. package/src/host-runner.ts +124 -4
  59. package/src/host-service.ts +165 -12
  60. package/src/index.ts +47 -0
  61. package/src/protocol.ts +57 -9
package/src/protocol.ts CHANGED
@@ -5,15 +5,18 @@ import { parseLedger } from './core/store.ts'
5
5
  import { isValidTimeZone } from './core/schedule.ts'
6
6
  import { sanitizeFreezeSnapshot, type FreezeSnapshot } from './core/freeze-snapshot.ts'
7
7
  import { sanitizeHandover, type TaskHandoverInput } from './core/handover.ts'
8
- import { isTaskBoardExtensionPayload, normalizeTaskIntegrations, type TaskBoardExtensionPayload } from './core/extension.ts'
8
+ import { TASK_BOARD_MESSAGE_MAX_LENGTH, isTaskBoardExtensionPayload, normalizeTaskIntegrations, type TaskBoardExtensionPayload } from './core/extension.ts'
9
9
  import { normalizeVerification, type ModelCatalogView, type VerificationContract, type VerificationSettings } from './core/verification.ts'
10
+ import { isTaskAttachmentList, TASK_ATTACHMENT_LIMIT, TASK_ATTACHMENT_MAX_BYTES, TASK_ATTACHMENT_TOTAL_MAX_BYTES } from './core/attachment.ts'
10
11
 
11
12
  /** Freeze payload carried by create/update actions after the gate (redacted in place). */
12
13
  type FreezePayload = FreezeSnapshot & { redacted?: boolean; frozenBy?: string }
13
14
 
14
- export const TASK_BOARD_SCHEMA_VERSION = 6 as const
15
- /** Ledger documents written before v6; loaded once and migrated on startup. */
16
- export const TASK_BOARD_LEGACY_SCHEMA_VERSION = 5 as const
15
+ export const TASK_BOARD_SCHEMA_VERSION = 7 as const
16
+ /** Ledger documents written before v7; loaded once and migrated on startup. */
17
+ export const TASK_BOARD_LEGACY_SCHEMA_VERSION = 6 as const
18
+ /** Ledger documents written before v6 (the scheduling mode and run budget). */
19
+ export const TASK_BOARD_PRE_RUN_BUDGET_SCHEMA_VERSION = 5 as const
17
20
  /** Ledger documents written before v5; migrated through the v5 normalization too. */
18
21
  export const TASK_BOARD_PRE_ACCEPTANCE_SCHEMA_VERSION = 4 as const
19
22
  /** Ledger documents written before v4; migrated through the v4 normalization too. */
@@ -29,12 +32,14 @@ export const TASK_BOARD_OLDEST_SCHEMA_VERSION = 2 as const
29
32
  export const TASK_BOARD_ZONE_STAMP_SCHEMA_VERSION = 4 as const
30
33
  /**
31
34
  * Every older generation the loader migrates in place. v5 only added the
32
- * per-execution acceptance block and v6 only added the scheduling mode and run
33
- * budget, so the migration is the normalization pass that re-validates each
34
- * row; a document from any listed generation upgrades losslessly.
35
+ * per-execution acceptance block, v6 only added the scheduling mode and run
36
+ * budget, and v7 only added the card attachment metadata, so the migration is
37
+ * the normalization pass that re-validates each row; a document from any
38
+ * listed generation upgrades losslessly.
35
39
  */
36
40
  export const TASK_BOARD_MIGRATABLE_SCHEMA_VERSIONS: readonly number[] = [
37
41
  TASK_BOARD_LEGACY_SCHEMA_VERSION,
42
+ TASK_BOARD_PRE_RUN_BUDGET_SCHEMA_VERSION,
38
43
  TASK_BOARD_PRE_ACCEPTANCE_SCHEMA_VERSION,
39
44
  TASK_BOARD_OLDER_SCHEMA_VERSION,
40
45
  TASK_BOARD_OLDEST_SCHEMA_VERSION,
@@ -101,6 +106,26 @@ export interface TaskBoardSnapshot {
101
106
  * The board forwards them verbatim; it never interprets their shape.
102
107
  */
103
108
  extensions?: Record<string, unknown>
109
+ /**
110
+ * The attachment limits this deployment enforces, so the browser can refuse
111
+ * an oversized selection before it uploads anything. The board's own caps
112
+ * are the ceiling; a deployment whose attachment storage publishes stricter
113
+ * image limits lowers the bounds it publishes here.
114
+ */
115
+ attachmentLimits?: {
116
+ /** Maximum number of attachments one card may carry. */
117
+ maxAttachments: number
118
+ /** Maximum byte length of one attachment. */
119
+ maxBytes: number
120
+ /** Maximum byte length of all attachments of one card together. */
121
+ maxTotalBytes: number
122
+ /** Maximum number of IMAGES one card may carry (the official per-message budget). */
123
+ maxImages: number
124
+ /** Maximum byte length of one image. */
125
+ maxImageBytes: number
126
+ /** Maximum byte length of all images of one card together (the official per-message budget). */
127
+ maxMessageImageBytes: number
128
+ }
104
129
  }
105
130
 
106
131
  /**
@@ -181,6 +206,12 @@ export type TaskBoardAction =
181
206
  | { kind: 'set-schedule'; taskId: string; patch: SetSchedulePatch }
182
207
  | { kind: 'run'; taskId: string }
183
208
  | { kind: 'rerun'; taskId: string }
209
+ /**
210
+ * Re-run an executed card in its own session, carrying rework instructions as
211
+ * this run's additional input. Every run gate applies exactly as it does to
212
+ * `rerun`, and the card's frozen content is never rewritten.
213
+ */
214
+ | { kind: 'rework'; taskId: string; instructions: string }
184
215
  | { kind: 'confirm-permission'; taskId: string }
185
216
  | { kind: 'set-parent'; taskId: string; parentId: string | null }
186
217
  /** Ledger-wide label management; see core/use-cases/task-tag.ts. */
@@ -270,6 +301,9 @@ function validImportedKnownFields(value: Record<string, unknown>): boolean {
270
301
  // non-string value is refused here like the other carried known fields.
271
302
  if (value.model !== undefined && typeof value.model !== 'string') return false
272
303
  if (value.integrations !== undefined && normalizeTaskIntegrations(value.integrations) === undefined) return false
304
+ // 安全门(对抗场景 e):import 不接受附件——旧版浏览器导出从不携带附件,
305
+ // 一条声称携带附件的导入必须被拒绝,而不是让未经校验的引用进入账本。
306
+ if (value.attachments !== undefined) return false
273
307
  if (value.schedule !== undefined && !validImportedSchedule(value.schedule)) return false
274
308
  if (value.executions !== undefined) {
275
309
  if (!Array.isArray(value.executions)) return false
@@ -386,7 +420,7 @@ function handoverPayload(value: unknown): TaskHandoverInput | undefined {
386
420
 
387
421
  function createInput(value: unknown): value is NewTaskInput {
388
422
  const input = record(value)
389
- if (input === undefined || !exactKeys(input, ['title', 'description', 'prompt', 'parentId', 'workspaceId', 'mode', 'permission', 'schedule', 'freeze', 'handover', 'model', 'reasoningEffort', 'applyCardDefaults', 'reuseSession', 'goalRun', 'skipVerification', 'tags', 'integrations'])) return false
423
+ if (input === undefined || !exactKeys(input, ['title', 'description', 'prompt', 'parentId', 'workspaceId', 'mode', 'permission', 'schedule', 'freeze', 'handover', 'model', 'reasoningEffort', 'applyCardDefaults', 'reuseSession', 'goalRun', 'skipVerification', 'tags', 'integrations', 'attachments'])) return false
390
424
  if (input.parentId !== undefined && (typeof input.parentId !== 'string' || input.parentId.trim() === '')) return false
391
425
  if (typeof input.title !== 'string' || typeof input.description !== 'string' || typeof input.prompt !== 'string') return false
392
426
  // The reasoning effort is an adapter-owned id the Host resolves against the
@@ -401,6 +435,10 @@ function createInput(value: unknown): value is NewTaskInput {
401
435
  if (input.permission !== undefined && !isTaskPermission(input.permission)) return false
402
436
  if (input.tags !== undefined && !isTaskTagList(input.tags)) return false
403
437
  if (input.integrations !== undefined && normalizeTaskIntegrations(input.integrations) === undefined) return false
438
+ // Attachments are host-verified against the official storage before the
439
+ // ledger sees them; the wire gate only keeps a malformed, duplicated or
440
+ // oversized list off the action.
441
+ if (input.attachments !== undefined && !isTaskAttachmentList(input.attachments)) return false
404
442
  if (input.freeze !== undefined && freezePayload(input.freeze) === undefined) return false
405
443
  if (input.handover !== undefined && handoverPayload(input.handover) === undefined) return false
406
444
  if (input.schedule !== undefined) {
@@ -420,7 +458,7 @@ function createInput(value: unknown): value is NewTaskInput {
420
458
 
421
459
  function updatePatch(value: unknown): boolean {
422
460
  const patch = record(value)
423
- if (patch === undefined || !exactKeys(patch, ['title', 'description', 'prompt', 'workspaceId', 'mode', 'permission', 'freeze', 'handover', 'model', 'reasoningEffort', 'reuseSession', 'goalRun', 'skipVerification', 'tags'])) return false
461
+ if (patch === undefined || !exactKeys(patch, ['title', 'description', 'prompt', 'workspaceId', 'mode', 'permission', 'freeze', 'handover', 'model', 'reasoningEffort', 'reuseSession', 'goalRun', 'skipVerification', 'tags', 'attachments'])) return false
424
462
  // null (or false) clears the reuse opt-in; only a real boolean is accepted.
425
463
  if (patch.reuseSession !== undefined && patch.reuseSession !== null && typeof patch.reuseSession !== 'boolean') return false
426
464
  // The goal opt-in is tri-state: null/true return the card to its default
@@ -435,6 +473,9 @@ function updatePatch(value: unknown): boolean {
435
473
  if (patch.permission !== undefined && !isTaskPermission(patch.permission)) return false
436
474
  // null clears the label set; a present array must be a well-formed list.
437
475
  if (patch.tags !== undefined && patch.tags !== null && !isTaskTagList(patch.tags)) return false
476
+ // null clears the attachment set; a present array replaces it wholesale and
477
+ // must be a well-formed list within the card-wide limits.
478
+ if (patch.attachments !== undefined && patch.attachments !== null && !isTaskAttachmentList(patch.attachments)) return false
438
479
  // null clears the snapshot; an object must pass the freeze gate.
439
480
  if (patch.freeze !== undefined && patch.freeze !== null && freezePayload(patch.freeze) === undefined) return false
440
481
  // Same convention for the handover bundle.
@@ -592,6 +633,13 @@ function parseEnvelopeAction(value: unknown): TaskBoardActionEnvelope | undefine
592
633
  },
593
634
  }
594
635
  }
636
+ case 'rework': {
637
+ if (!exactKeys(action, ['kind', 'taskId', 'instructions'])) return undefined
638
+ if (taskId === undefined || typeof action.instructions !== 'string') return undefined
639
+ const instructions = action.instructions.trim()
640
+ if (instructions === '' || instructions.length > TASK_BOARD_MESSAGE_MAX_LENGTH) return undefined
641
+ return { requestId: envelope.requestId, action: { kind: 'rework', taskId, instructions } }
642
+ }
595
643
  case 'confirm-permission':
596
644
  case 'delete':
597
645
  case 'archive':