@fish-under-sea/dsh-client-ui-task-board-fish 1.0.2 → 2.0.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.
- package/NOTICE +1 -1
- package/README.en.md +6 -4
- package/README.md +6 -4
- package/README.zh.md +6 -4
- package/icon.png +0 -0
- package/lib/client.js +4428 -1508
- package/lib/client.js.map +1 -1
- package/lib/index.js +2670 -496
- package/lib/types/client/CardDefaultPresetField.d.ts +35 -0
- package/lib/types/client/PluginSettingsCard.d.ts +130 -19
- package/lib/types/client/RangeBubble.d.ts +46 -0
- package/lib/types/client/SegmentGroup.d.ts +28 -0
- package/lib/types/client/TaskBoardSettingsCard.d.ts +63 -0
- package/lib/types/client/board/AttachmentField.d.ts +70 -0
- package/lib/types/client/board/ExecutionLog.d.ts +24 -0
- package/lib/types/client/board/ReasoningEffortField.d.ts +25 -0
- package/lib/types/client/board/TaskForm.d.ts +4 -0
- package/lib/types/client/board/VerificationReport.d.ts +2 -15
- package/lib/types/client/board/model-options.d.ts +87 -0
- package/lib/types/client/board/preset-label.d.ts +21 -0
- package/lib/types/client/board/preset-roster.d.ts +45 -0
- package/lib/types/client/board/source-group.d.ts +27 -0
- package/lib/types/client/body-mutations.d.ts +45 -0
- package/lib/types/client/host-api.d.ts +25 -0
- package/lib/types/client/locales.d.ts +87 -9
- package/lib/types/client/pending-verify.d.ts +47 -0
- package/lib/types/client/plugin-card-seat.d.ts +3 -1
- package/lib/types/client/service.d.ts +4 -1
- package/lib/types/client/settings-form.d.ts +73 -51
- package/lib/types/core/attachment.d.ts +132 -0
- package/lib/types/core/card-defaults.d.ts +78 -0
- package/lib/types/core/controller.d.ts +57 -8
- package/lib/types/core/execution-summary.d.ts +52 -0
- package/lib/types/core/extension.d.ts +116 -0
- package/lib/types/core/launch-width.d.ts +31 -0
- package/lib/types/core/reasoning-effort.d.ts +57 -0
- package/lib/types/core/session-reuse.d.ts +7 -1
- package/lib/types/core/spend-budget.d.ts +28 -0
- package/lib/types/core/subtask.d.ts +100 -37
- package/lib/types/core/tasks.d.ts +94 -10
- package/lib/types/core/use-cases/task-create.d.ts +10 -5
- package/lib/types/core/use-cases/task-tag.d.ts +36 -0
- package/lib/types/core/use-cases/task-update.d.ts +22 -1
- package/lib/types/core/wire-projection.d.ts +35 -0
- package/lib/types/core/workspace-target.d.ts +23 -3
- package/lib/types/host/attachments.d.ts +250 -0
- package/lib/types/host/extension-registry.d.ts +40 -0
- package/lib/types/host/launch-admission.d.ts +71 -0
- package/lib/types/host-ledger.d.ts +114 -47
- package/lib/types/host-routes.d.ts +63 -0
- package/lib/types/host-runner.d.ts +164 -18
- package/lib/types/host-service.d.ts +182 -46
- package/lib/types/host-spend.d.ts +52 -0
- package/lib/types/index.d.ts +173 -54
- package/lib/types/loopback.d.ts +41 -1
- package/lib/types/protocol.d.ts +52 -11
- package/lib/types/tool-surface.d.ts +1 -0
- package/locale/en.json +6 -0
- package/locale/zh.json +6 -0
- package/package.json +36 -29
- package/src/client/CardDefaultPresetField.tsx +101 -0
- package/src/client/PluginSettingsCard.tsx +385 -111
- package/src/client/RangeBubble.tsx +164 -0
- package/src/client/SegmentGroup.tsx +93 -0
- package/src/client/TaskBoardSettingsCard.tsx +332 -37
- package/src/client/board/AttachmentField.tsx +383 -0
- package/src/client/board/EditTaskModal.tsx +63 -0
- package/src/client/board/ExecutionLog.tsx +154 -0
- package/src/client/board/LinkSubtaskModal.tsx +1 -1
- package/src/client/board/NewTaskModal.tsx +154 -45
- package/src/client/board/ReasoningEffortField.tsx +50 -0
- package/src/client/board/TagManagerModal.tsx +151 -2
- package/src/client/board/TaskBoard.tsx +47 -10
- package/src/client/board/TaskCard.tsx +45 -23
- package/src/client/board/TaskDetail.tsx +468 -258
- package/src/client/board/TaskForm.tsx +19 -4
- package/src/client/board/VerificationReport.tsx +143 -104
- package/src/client/board/model-options.ts +208 -0
- package/src/client/board/preset-label.ts +32 -0
- package/src/client/board/preset-roster.ts +58 -0
- package/src/client/board/source-group.ts +94 -0
- package/src/client/board/task-markdown.module.css +11 -8
- package/src/client/board-settings.module.css +35 -7
- package/src/client/board.module.css +1044 -105
- package/src/client/body-mutations.ts +133 -0
- package/src/client/host-api.ts +70 -0
- package/src/client/index.ts +109 -95
- package/src/client/locales.ts +205 -48
- package/src/client/pending-verify.ts +90 -0
- package/src/client/plugin-card-seat.ts +8 -2
- package/src/client/service.ts +24 -0
- package/src/client/settings-card.module.css +466 -89
- package/src/client/settings-entry-form.ts +0 -1
- package/src/client/settings-form.ts +102 -60
- package/src/core/attachment.ts +287 -0
- package/src/core/card-defaults.ts +132 -0
- package/src/core/controller.ts +90 -11
- package/src/core/execution-summary.ts +96 -0
- package/src/core/extension.ts +120 -0
- package/src/core/launch-width.ts +38 -0
- package/src/core/reasoning-effort.ts +92 -0
- package/src/core/session-reuse.ts +7 -1
- package/src/core/spend-budget.ts +35 -0
- package/src/core/store.ts +19 -1
- package/src/core/subtask.ts +144 -68
- package/src/core/tasks.ts +117 -10
- package/src/core/use-cases/task-create.ts +27 -16
- package/src/core/use-cases/task-tag.ts +56 -0
- package/src/core/use-cases/task-update.ts +33 -5
- package/src/core/wire-projection.ts +81 -0
- package/src/core/workspace-target.ts +27 -3
- package/src/host/agent-tools.ts +33 -21
- package/src/host/attachments.ts +650 -0
- package/src/host/extension-registry.ts +150 -5
- package/src/host/launch-admission.ts +139 -0
- package/src/host-ledger.ts +248 -117
- package/src/host-routes.ts +233 -15
- package/src/host-runner.ts +395 -61
- package/src/host-service.ts +512 -139
- package/src/host-spend.ts +105 -0
- package/src/index.ts +312 -92
- package/src/loopback.ts +57 -1
- package/src/protocol.ts +83 -18
- package/src/tool-surface.ts +1 -0
- package/icon.svg +0 -3
package/src/core/tasks.ts
CHANGED
|
@@ -8,6 +8,7 @@ import type { FreezeSnapshot } from './freeze-snapshot.ts'
|
|
|
8
8
|
import type { ExecutionVerification } from './verification.ts'
|
|
9
9
|
import type { TaskHandover, TaskHandoverInput } from './handover.ts'
|
|
10
10
|
import { normalizeTaskIntegrations, type TaskBoardExtensionPayload } from './extension.ts'
|
|
11
|
+
import { normalizeAttachments, type TaskAttachment } from './attachment.ts'
|
|
11
12
|
|
|
12
13
|
/** Task lifecycle status, one per kanban column. */
|
|
13
14
|
export type TaskStatus = 'backlog' | 'todo' | 'running' | 'done' | 'failed'
|
|
@@ -15,6 +16,50 @@ export type TaskStatus = 'backlog' | 'todo' | 'running' | 'done' | 'failed'
|
|
|
15
16
|
/** Settled outcome of one execution attempt. */
|
|
16
17
|
export type ExecutionOutcome = 'succeeded' | 'failed' | 'cancelled'
|
|
17
18
|
|
|
19
|
+
/**
|
|
20
|
+
* What one execution left behind: the text of the run's last assistant message
|
|
21
|
+
* and the session event it was read from.
|
|
22
|
+
*
|
|
23
|
+
* The board records a verdict per execution but no output, so a parent card
|
|
24
|
+
* could see that a subtask succeeded without seeing what it produced. Card
|
|
25
|
+
* content cannot answer that (it is the plan and freezes at the first
|
|
26
|
+
* execution), so the closing text rides the execution record instead.
|
|
27
|
+
*/
|
|
28
|
+
export interface ExecutionSummary {
|
|
29
|
+
/** Last assistant message text of the run, bounded by {@link EXECUTION_SUMMARY_LIMIT}. */
|
|
30
|
+
text: string
|
|
31
|
+
/** Seq of the session event that text came from; absent text has no seq either. */
|
|
32
|
+
seq: number
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Upper bound of one recorded summary, in characters. The ledger stores a
|
|
37
|
+
* conclusion, not a transcript: a reader that needs the whole message follows
|
|
38
|
+
* {@link ExecutionSummary.seq} into the session history.
|
|
39
|
+
*/
|
|
40
|
+
export const EXECUTION_SUMMARY_LIMIT = 4000
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Rework input recorded on the execution it opened: the reviewer's instructions
|
|
44
|
+
* for redoing work in the card's own session.
|
|
45
|
+
*/
|
|
46
|
+
export interface ExecutionRework {
|
|
47
|
+
/** The rework instructions this run was given, as the reviewer wrote them. */
|
|
48
|
+
instructions: string
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Repair a persisted rework block: only a non-blank instruction string
|
|
53
|
+
* survives, so a hand-edited ledger loses the block instead of the execution.
|
|
54
|
+
*/
|
|
55
|
+
export function normalizeExecutionRework(value: unknown): ExecutionRework | undefined {
|
|
56
|
+
if (typeof value !== 'object' || value === null) return undefined
|
|
57
|
+
const instructions = (value as { instructions?: unknown }).instructions
|
|
58
|
+
if (typeof instructions !== 'string') return undefined
|
|
59
|
+
const trimmed = instructions.trim()
|
|
60
|
+
return trimmed === '' ? undefined : { instructions: trimmed }
|
|
61
|
+
}
|
|
62
|
+
|
|
18
63
|
/**
|
|
19
64
|
* One real execution attempt: the run's own id, the dsh session that ran it
|
|
20
65
|
* (filled once the session is created), and the settled outcome once the
|
|
@@ -54,6 +99,13 @@ export interface ExecutionRecord {
|
|
|
54
99
|
* `sessionId` and never claims a verdict the Host observed.
|
|
55
100
|
*/
|
|
56
101
|
external?: boolean
|
|
102
|
+
/**
|
|
103
|
+
* Rework instructions this execution carries as extra input: a reviewer sent
|
|
104
|
+
* the previous run back, so the card re-ran in the same session with these
|
|
105
|
+
* instructions instead of having its frozen content rewritten. Absent on
|
|
106
|
+
* every ordinary run.
|
|
107
|
+
*/
|
|
108
|
+
rework?: ExecutionRework
|
|
57
109
|
/** Freeze instant captured from the card snapshot when the run opened. */
|
|
58
110
|
frozenAt?: number
|
|
59
111
|
/** Freeze source session captured from the card snapshot when the run opened. */
|
|
@@ -72,6 +124,16 @@ export interface ExecutionRecord {
|
|
|
72
124
|
ownResult?: ExecutionOutcome
|
|
73
125
|
/** Human failure text that arrived with {@link ownResult}. */
|
|
74
126
|
ownError?: string
|
|
127
|
+
/**
|
|
128
|
+
* What this run left behind: the text of its last assistant message, taken
|
|
129
|
+
* when the settlement read the session and recorded with the verdict.
|
|
130
|
+
*
|
|
131
|
+
* Absent — never an empty string — when the session could not be read or
|
|
132
|
+
* carried no assistant prose, so "recorded nothing" stays distinguishable
|
|
133
|
+
* from "produced nothing". Settling never fails over it: a summary is
|
|
134
|
+
* informational, and every field above is what the board decides with.
|
|
135
|
+
*/
|
|
136
|
+
summary?: ExecutionSummary
|
|
75
137
|
/**
|
|
76
138
|
* Goal acceptance state of this execution (task-board goal verification).
|
|
77
139
|
* Fixed when the execution starts and never rewritten from later settings:
|
|
@@ -406,6 +468,15 @@ export interface TaskRecord {
|
|
|
406
468
|
* absent falls back to the host default (agent-default-model).
|
|
407
469
|
*/
|
|
408
470
|
model?: string
|
|
471
|
+
/**
|
|
472
|
+
* Reasoning effort pinned for that execution route (an adapter-owned id such
|
|
473
|
+
* as "high"). Absent (or blank) means INHERIT: the session runs at the
|
|
474
|
+
* model's own default level, exactly as a card written before the field
|
|
475
|
+
* existed does. The launch sends the value only when the target model's
|
|
476
|
+
* adapter declares that exact id, so switching a card to a model without
|
|
477
|
+
* that level never pushes an invalid selection (see core/reasoning-effort.ts).
|
|
478
|
+
*/
|
|
479
|
+
reasoningEffort?: string
|
|
409
480
|
/**
|
|
410
481
|
* Whether later executions continue in the previous execution's session
|
|
411
482
|
* (issue #1419) instead of minting a fresh conversation per run. Absent or
|
|
@@ -415,12 +486,11 @@ export interface TaskRecord {
|
|
|
415
486
|
*/
|
|
416
487
|
reuseSession?: boolean
|
|
417
488
|
/**
|
|
418
|
-
*
|
|
419
|
-
*
|
|
420
|
-
*
|
|
421
|
-
*
|
|
422
|
-
*
|
|
423
|
-
* and a subtask's own permission pin cannot be honored in this mode.
|
|
489
|
+
* Historical Agent Team opt-in. New runs never write it and the Host never
|
|
490
|
+
* reads it to decide how to run: a run with unfinished subtasks opens one
|
|
491
|
+
* session whose own agent dispatches subagents. The field is kept so cards
|
|
492
|
+
* already on disk keep their record, and so the ledger can still fold a team
|
|
493
|
+
* run group it opened before this behavior changed.
|
|
424
494
|
*/
|
|
425
495
|
teamRun?: boolean
|
|
426
496
|
/**
|
|
@@ -494,6 +564,14 @@ export interface TaskRecord {
|
|
|
494
564
|
* absent means on-board.
|
|
495
565
|
*/
|
|
496
566
|
hidden?: boolean
|
|
567
|
+
/**
|
|
568
|
+
* Files and images the card carries (issue #1979). Metadata only: the bytes
|
|
569
|
+
* live in the official attachment storage, and this record names the stored
|
|
570
|
+
* object, its size and the digest of the exact bytes the Host verified
|
|
571
|
+
* there. Additive and absent on every card written before the field
|
|
572
|
+
* existed, so an old card keeps running exactly as it did.
|
|
573
|
+
*/
|
|
574
|
+
attachments?: TaskAttachment[]
|
|
497
575
|
}
|
|
498
576
|
|
|
499
577
|
/**
|
|
@@ -535,10 +613,18 @@ export interface NewTaskInput {
|
|
|
535
613
|
permission?: TaskPermission
|
|
536
614
|
/** Optional pinned model for the execution session; absent = host default. */
|
|
537
615
|
model?: string
|
|
616
|
+
/** Optional reasoning effort for that model route; empty/absent = the model's own default. */
|
|
617
|
+
reasoningEffort?: string
|
|
618
|
+
/**
|
|
619
|
+
* Opt in to the deployment's new-card defaults: a target this input leaves
|
|
620
|
+
* out is filled from the configured default (agent preset, permission, model
|
|
621
|
+
* and the level bound to that model). Absent means the create stores exactly
|
|
622
|
+
* what it was given, which is what the extension provider's own create path
|
|
623
|
+
* and the legacy import rely on.
|
|
624
|
+
*/
|
|
625
|
+
applyCardDefaults?: boolean
|
|
538
626
|
/** Reuse the previous execution's session for later runs (issue #1419). */
|
|
539
627
|
reuseSession?: boolean
|
|
540
|
-
/** Run the subtree as an Agent Team (Team Lead session plus one teammate per direct subtask). */
|
|
541
|
-
teamRun?: boolean
|
|
542
628
|
/**
|
|
543
629
|
* Start the execution with dsh's built-in `/goal`. Absent means the default
|
|
544
630
|
* (one plain turn); only an explicit true joins the goal run.
|
|
@@ -587,6 +673,12 @@ export interface NewTaskInput {
|
|
|
587
673
|
status?: TaskStatus
|
|
588
674
|
/** Create the card off-board (held in the ledger, never rendered). */
|
|
589
675
|
hidden?: boolean
|
|
676
|
+
/**
|
|
677
|
+
* Files and images the new card carries (issue #1979). The metadata is
|
|
678
|
+
* host-verified against the official attachment storage before it reaches
|
|
679
|
+
* the ledger, so a create never records a claim the storage cannot prove.
|
|
680
|
+
*/
|
|
681
|
+
attachments?: TaskAttachment[]
|
|
590
682
|
}
|
|
591
683
|
|
|
592
684
|
/** The five kanban columns, in display order. */
|
|
@@ -685,6 +777,7 @@ export function freezeOf(
|
|
|
685
777
|
export function createTask(input: NewTaskInput, now: number, id: string): TaskRecord {
|
|
686
778
|
const tags = normalizeTags(input.tags)
|
|
687
779
|
const integrations = normalizeTaskIntegrations(input.integrations)
|
|
780
|
+
const attachments = normalizeAttachments(input.attachments)
|
|
688
781
|
return {
|
|
689
782
|
id,
|
|
690
783
|
title: input.title.trim(),
|
|
@@ -699,8 +792,8 @@ export function createTask(input: NewTaskInput, now: number, id: string): TaskRe
|
|
|
699
792
|
mode: normalizeTargetId(input.mode),
|
|
700
793
|
permission: isTaskPermission(input.permission) ? input.permission : undefined,
|
|
701
794
|
model: normalizeTargetId(input.model),
|
|
795
|
+
reasoningEffort: normalizeTargetId(input.reasoningEffort),
|
|
702
796
|
reuseSession: input.reuseSession === true ? true : undefined,
|
|
703
|
-
teamRun: input.teamRun === true ? true : undefined,
|
|
704
797
|
// Default OFF: only an explicit true is stored, so a card that never
|
|
705
798
|
// touched the option (and every card written before the field existed)
|
|
706
799
|
// keeps running one plain turn.
|
|
@@ -713,6 +806,7 @@ export function createTask(input: NewTaskInput, now: number, id: string): TaskRe
|
|
|
713
806
|
...(input.handover === undefined ? {} : { handover: { ...input.handover, bundledAt: now } }),
|
|
714
807
|
...(tags === undefined ? {} : { tags }),
|
|
715
808
|
...(integrations === undefined ? {} : { integrations }),
|
|
809
|
+
...(attachments === undefined ? {} : { attachments }),
|
|
716
810
|
...(input.hidden === true ? { hidden: true } : {}),
|
|
717
811
|
}
|
|
718
812
|
}
|
|
@@ -762,6 +856,8 @@ export function withSchedule(
|
|
|
762
856
|
* running execution record. Returns the new task and the new execution.
|
|
763
857
|
* @param runGroupId - cascade run group, when this run also opened executions
|
|
764
858
|
* for the task's subtasks (see `core/subtask.ts`).
|
|
859
|
+
* @param rework - the reviewer's instructions, when this run is a rework of the
|
|
860
|
+
* card's previous work; recorded on the execution it opens.
|
|
765
861
|
*/
|
|
766
862
|
export function startExecution(
|
|
767
863
|
task: TaskRecord,
|
|
@@ -769,6 +865,7 @@ export function startExecution(
|
|
|
769
865
|
executionId: string,
|
|
770
866
|
initiatedBy?: string,
|
|
771
867
|
runGroupId?: string,
|
|
868
|
+
rework?: ExecutionRework,
|
|
772
869
|
): { task: TaskRecord; execution: ExecutionRecord } {
|
|
773
870
|
const execution: ExecutionRecord = {
|
|
774
871
|
id: executionId,
|
|
@@ -777,6 +874,7 @@ export function startExecution(
|
|
|
777
874
|
endedAt: undefined,
|
|
778
875
|
result: undefined,
|
|
779
876
|
error: undefined,
|
|
877
|
+
...(rework === undefined ? {} : { rework }),
|
|
780
878
|
...(runGroupId === undefined || runGroupId === '' ? {} : { runGroupId }),
|
|
781
879
|
...(initiatedBy === undefined || initiatedBy === '' ? {} : { initiatedBy }),
|
|
782
880
|
// Capture the card's freeze provenance on the execution record so the
|
|
@@ -823,12 +921,21 @@ export function settleExecution(
|
|
|
823
921
|
outcome: ExecutionOutcome,
|
|
824
922
|
now: number,
|
|
825
923
|
error: string | undefined,
|
|
924
|
+
summary?: ExecutionSummary,
|
|
826
925
|
): TaskRecord {
|
|
827
926
|
const index = task.executions.findIndex(execution => execution.id === executionId)
|
|
828
927
|
if (index === -1) return task
|
|
829
928
|
const execution = task.executions[index]
|
|
830
929
|
if (execution.endedAt !== undefined) return task
|
|
831
|
-
|
|
930
|
+
// A settle without one keeps whatever an earlier settle already recorded: a
|
|
931
|
+
// cascade parent's final fold has no session of its own to read.
|
|
932
|
+
const settled: ExecutionRecord = {
|
|
933
|
+
...execution,
|
|
934
|
+
endedAt: now,
|
|
935
|
+
result: outcome,
|
|
936
|
+
error,
|
|
937
|
+
...(summary === undefined ? {} : { summary }),
|
|
938
|
+
}
|
|
832
939
|
const executions = [...task.executions]
|
|
833
940
|
executions[index] = settled
|
|
834
941
|
return { ...task, status: settledStatus(task, outcome), updatedAt: now, executions }
|
|
@@ -6,7 +6,8 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import { isValidCron, isValidTimeZone, nextRunAtMs, resolveHostTimeZone } from '../schedule.ts'
|
|
8
8
|
import { DEFAULT_SUBTASK_DEPTH, normalizeSubtaskDepth, taskDepth } from '../subtask.ts'
|
|
9
|
-
import {
|
|
9
|
+
import { resolveCardTargets, type CardDefaults } from '../card-defaults.ts'
|
|
10
|
+
import { createTask, isTaskPermission, withSchedule, type NewTaskInput, type TaskRecord } from '../tasks.ts'
|
|
10
11
|
|
|
11
12
|
/** Result of a create transition: the new task (when accepted) + the next ledger. */
|
|
12
13
|
export interface CreateTaskResult {
|
|
@@ -23,16 +24,20 @@ export interface CreateTaskResult {
|
|
|
23
24
|
* appended ledger, or the unchanged ledger when the title is blank or the
|
|
24
25
|
* requested parent link is refused.
|
|
25
26
|
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
27
|
+
* The execution targets resolve through {@link resolveCardTargets}: what the
|
|
28
|
+
* caller sent wins, then the parent's own pins, then - only when the caller
|
|
29
|
+
* opted in with `applyCardDefaults` - the deployment's configured new-card
|
|
30
|
+
* defaults. Without the flag the resolution sees no defaults at all, which is
|
|
31
|
+
* exactly the inline parent inheritance this path has always applied. The
|
|
32
|
+
* workspace is not part of that resolution: a subtask still takes the parent's
|
|
33
|
+
* workspace, and the defaults never name one.
|
|
30
34
|
* @param tasks - current ledger.
|
|
31
35
|
* @param input - raw user input (title/description/prompt + optional schedule/parent).
|
|
32
36
|
* @param now - clock instant (ms epoch).
|
|
33
37
|
* @param id - minted task id.
|
|
34
38
|
* @param maxSubtaskDepth - deployment subtask depth limit.
|
|
35
39
|
* @param hostTimeZone - zone a rule that stores no zone of its own follows.
|
|
40
|
+
* @param cardDefaults - the deployment's new-card defaults, read live at creation.
|
|
36
41
|
*/
|
|
37
42
|
export function applyCreateTask(
|
|
38
43
|
tasks: readonly TaskRecord[],
|
|
@@ -41,6 +46,7 @@ export function applyCreateTask(
|
|
|
41
46
|
id: string,
|
|
42
47
|
maxSubtaskDepth: number = DEFAULT_SUBTASK_DEPTH,
|
|
43
48
|
hostTimeZone: string = resolveHostTimeZone(),
|
|
49
|
+
cardDefaults?: CardDefaults,
|
|
44
50
|
): CreateTaskResult {
|
|
45
51
|
if (input.title.trim() === '') return { task: undefined, tasks, error: 'title is required' }
|
|
46
52
|
const limit = normalizeSubtaskDepth(maxSubtaskDepth)
|
|
@@ -53,18 +59,23 @@ export function applyCreateTask(
|
|
|
53
59
|
return { task: undefined, tasks, error: `subtask depth limit (${limit}) exceeded` }
|
|
54
60
|
}
|
|
55
61
|
}
|
|
56
|
-
//
|
|
57
|
-
//
|
|
58
|
-
//
|
|
59
|
-
//
|
|
60
|
-
//
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
62
|
+
// The execution targets resolve through the one shared rule: the caller's own
|
|
63
|
+
// choice, then the parent's own pins (never its permission, see
|
|
64
|
+
// core/card-defaults.ts), then the deployment's new-card defaults — and only
|
|
65
|
+
// when the caller asked for them, so a create that never opts in stores
|
|
66
|
+
// exactly what it sent, as it always has.
|
|
67
|
+
const seed = resolveCardTargets(
|
|
68
|
+
input.applyCardDefaults === true ? cardDefaults : undefined,
|
|
69
|
+
parent === undefined ? undefined : { kind: 'parent', task: parent },
|
|
70
|
+
{ mode: input.mode, permission: input.permission, model: input.model, reasoningEffort: input.reasoningEffort },
|
|
71
|
+
)
|
|
72
|
+
const effective: NewTaskInput = {
|
|
64
73
|
...input,
|
|
65
|
-
workspaceId: input.workspaceId ?? parent
|
|
66
|
-
mode:
|
|
67
|
-
|
|
74
|
+
workspaceId: input.workspaceId ?? parent?.workspaceId,
|
|
75
|
+
mode: seed.mode,
|
|
76
|
+
permission: isTaskPermission(seed.permission) ? seed.permission : undefined,
|
|
77
|
+
model: seed.model,
|
|
78
|
+
reasoningEffort: seed.reasoningEffort,
|
|
68
79
|
}
|
|
69
80
|
let task = createTask(effective, now, id)
|
|
70
81
|
// Arm the requested schedule (new-task dialog). The Host wire gate already
|
|
@@ -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
|
|
|
20
27
|
import { TAG_NAME_MAX_LENGTH, collectKnownTags, normalizeTags, type TaskRecord, type TaskTag } from '../tasks.ts'
|
|
@@ -108,3 +115,52 @@ export function applyDeleteTag(
|
|
|
108
115
|
})
|
|
109
116
|
return { tasks: changed ? next : tasks, changed }
|
|
110
117
|
}
|
|
118
|
+
|
|
119
|
+
/** One label the manager offers to clear, with the tasks it would be taken from. */
|
|
120
|
+
export interface TagCleanupCandidate {
|
|
121
|
+
/** The label name. */
|
|
122
|
+
name: string
|
|
123
|
+
/** Tasks carrying the label right now, board and archive alike. */
|
|
124
|
+
count: number
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* Labels that are both rarely used and finished with: fewer tasks carry them
|
|
129
|
+
* than `threshold`, and every one of those tasks is done or failed.
|
|
130
|
+
*
|
|
131
|
+
* The judgement reads the whole ledger it is given — the board's label row and
|
|
132
|
+
* the archive draw from the same set, so an archived card counts towards a
|
|
133
|
+
* label's usage and can keep it alive on its own. Archiving alone decides
|
|
134
|
+
* nothing: an archived card in a finished column lets its label through, while
|
|
135
|
+
* an archived card still in backlog, todo or running holds it back, because a
|
|
136
|
+
* label that live work still points at is not junk.
|
|
137
|
+
*
|
|
138
|
+
* A non-finite threshold selects nothing (a missing number has no reading that
|
|
139
|
+
* is safe to act on); a threshold at or below one selects nothing either, since
|
|
140
|
+
* a label by definition sits on at least one task and none can carry fewer.
|
|
141
|
+
*
|
|
142
|
+
* Order follows {@link collectKnownTags}, which is the order the manager lists
|
|
143
|
+
* labels in, and the count is the same number the manager shows per label.
|
|
144
|
+
* @param tasks - the whole ledger (board and archive).
|
|
145
|
+
* @param threshold - exclusive upper bound on the usage count.
|
|
146
|
+
* @returns the labels a cleanup may remove, in listing order.
|
|
147
|
+
*/
|
|
148
|
+
export function cleanupCandidates(tasks: readonly TaskRecord[], threshold: number): TagCleanupCandidate[] {
|
|
149
|
+
if (!Number.isFinite(threshold)) return []
|
|
150
|
+
const counts = new Map<string, number>()
|
|
151
|
+
const unfinished = new Set<string>()
|
|
152
|
+
for (const task of tasks) {
|
|
153
|
+
const settled = task.status === 'done' || task.status === 'failed'
|
|
154
|
+
for (const tag of task.tags ?? []) {
|
|
155
|
+
counts.set(tag.name, (counts.get(tag.name) ?? 0) + 1)
|
|
156
|
+
if (!settled) unfinished.add(tag.name)
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
const candidates: TagCleanupCandidate[] = []
|
|
160
|
+
for (const tag of collectKnownTags(tasks)) {
|
|
161
|
+
const count = counts.get(tag.name) ?? 0
|
|
162
|
+
if (count >= threshold || unfinished.has(tag.name)) continue
|
|
163
|
+
candidates.push({ name: tag.name, count })
|
|
164
|
+
}
|
|
165
|
+
return candidates
|
|
166
|
+
}
|
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
* stale UI can never persist a value the execution service rejects.
|
|
10
10
|
*/
|
|
11
11
|
import { freezeOf, isTaskPermission, normalizeTags, normalizeTargetId, type TaskRecord, type TaskPermission, type TaskTag } from '../tasks.ts'
|
|
12
|
+
import { normalizeAttachments, type TaskAttachment } from '../attachment.ts'
|
|
12
13
|
import type { FreezeSnapshot } from '../freeze-snapshot.ts'
|
|
13
14
|
import type { TaskHandoverInput } from '../handover.ts'
|
|
14
15
|
|
|
@@ -16,7 +17,7 @@ import type { TaskHandoverInput } from '../handover.ts'
|
|
|
16
17
|
* Editable fields on a task (the update patch surface). `freeze` replaces the
|
|
17
18
|
* continuation-card snapshot (restamping frozenAt); an explicit null clears it.
|
|
18
19
|
*/
|
|
19
|
-
export type TaskUpdatePatch = Partial<Pick<TaskRecord, 'title' | 'description' | 'prompt' | 'workspaceId' | 'mode' | 'permission' | 'model' | '
|
|
20
|
+
export type TaskUpdatePatch = Partial<Pick<TaskRecord, 'title' | 'description' | 'prompt' | 'workspaceId' | 'mode' | 'permission' | 'model' | 'reasoningEffort' | 'reuseSession' | 'goalRun' | 'skipVerification'>> & {
|
|
20
21
|
freeze?: FreezeSnapshot & { redacted?: boolean } | null
|
|
21
22
|
/** Replaces the handover bundle (restamping bundledAt); an explicit null clears it. */
|
|
22
23
|
handover?: TaskHandoverInput | null
|
|
@@ -27,6 +28,15 @@ export type TaskUpdatePatch = Partial<Pick<TaskRecord, 'title' | 'description' |
|
|
|
27
28
|
* explicit null (or a list that normalizes to nothing) clears them.
|
|
28
29
|
*/
|
|
29
30
|
tags?: TaskTag[] | null
|
|
31
|
+
/**
|
|
32
|
+
* Replaces the card's attachments (issue #1979).
|
|
33
|
+
*
|
|
34
|
+
* The attachments freeze WITH the card content: they are part of what the
|
|
35
|
+
* card hands to its execution, so an executed or archived card keeps the
|
|
36
|
+
* ones it ran with, exactly as it keeps the prompt it ran with. An explicit
|
|
37
|
+
* null clears them; a present array replaces the whole set.
|
|
38
|
+
*/
|
|
39
|
+
attachments?: TaskAttachment[] | null
|
|
30
40
|
}
|
|
31
41
|
|
|
32
42
|
/** The fields that edit the task's content (what the user reads and what the
|
|
@@ -36,9 +46,21 @@ export type TaskUpdatePatch = Partial<Pick<TaskRecord, 'title' | 'description' |
|
|
|
36
46
|
*/
|
|
37
47
|
export const TASK_CONTENT_FIELDS = ['title', 'description', 'prompt'] as const
|
|
38
48
|
|
|
49
|
+
/**
|
|
50
|
+
* The fields that freeze with the card content: the text the card says AND
|
|
51
|
+
* the attachments it carries.
|
|
52
|
+
*
|
|
53
|
+
* The attachments freeze with the content because they ARE part of what the
|
|
54
|
+
* card hands to its execution: a card whose first run already consumed an
|
|
55
|
+
* image keeps that image, and the record of what ran stays what it was. An
|
|
56
|
+
* executed or archived card therefore refuses an attachment change exactly
|
|
57
|
+
* as it refuses a prompt change.
|
|
58
|
+
*/
|
|
59
|
+
export const TASK_FROZEN_FIELDS = [...TASK_CONTENT_FIELDS, 'attachments'] as const
|
|
60
|
+
|
|
39
61
|
/** Whether an update patch touches any task-content field. */
|
|
40
62
|
export function hasContentPatch(patch: TaskUpdatePatch): boolean {
|
|
41
|
-
return (
|
|
63
|
+
return (TASK_FROZEN_FIELDS as readonly string[]).some(field => field in patch)
|
|
42
64
|
}
|
|
43
65
|
|
|
44
66
|
/**
|
|
@@ -77,11 +99,12 @@ export function applyUpdateTask(
|
|
|
77
99
|
): readonly TaskRecord[] {
|
|
78
100
|
return tasks.map(task => {
|
|
79
101
|
if (task.id !== id) return task
|
|
80
|
-
const { freeze: freezePatch, handover: handoverPatch, tags: tagsPatch, ...rest } = patch
|
|
102
|
+
const { freeze: freezePatch, handover: handoverPatch, tags: tagsPatch, attachments: attachmentsPatch, ...rest } = patch
|
|
81
103
|
const workspaceId = 'workspaceId' in patch ? normalizeTargetId(patch.workspaceId) : undefined
|
|
82
104
|
const mode = 'mode' in patch ? normalizeTargetId(patch.mode) : undefined
|
|
83
105
|
const permission = 'permission' in patch ? normalizePermission(task.permission, patch.permission) : undefined
|
|
84
106
|
const model = 'model' in patch ? normalizeTargetId(patch.model) : undefined
|
|
107
|
+
const reasoningEffort = 'reasoningEffort' in patch ? normalizeTargetId(patch.reasoningEffort) : undefined
|
|
85
108
|
const next: TaskRecord = { ...task, ...rest, updatedAt: now }
|
|
86
109
|
// Content fields normalize like creation does (trimmed); an explicit
|
|
87
110
|
// undefined keeps the current value — content cannot be cleared.
|
|
@@ -98,6 +121,9 @@ export function applyUpdateTask(
|
|
|
98
121
|
// Tags use the same convention: a present array replaces the set (after
|
|
99
122
|
// repair), an explicit null or a fully-invalid list clears it.
|
|
100
123
|
if ('tags' in patch) next.tags = tagsPatch == null ? undefined : normalizeTags(tagsPatch)
|
|
124
|
+
// Attachments follow the same convention: a present array replaces the
|
|
125
|
+
// whole set (after repair), an explicit null clears it.
|
|
126
|
+
if ('attachments' in patch) next.attachments = attachmentsPatch == null ? undefined : normalizeAttachments(attachmentsPatch)
|
|
101
127
|
// The permission confirmation binds the exact permission value: a change
|
|
102
128
|
// of the pinned permission or of the handover bundle re-arms the gate
|
|
103
129
|
// (blocking confirm-then-swap escalation). handover was destructured out
|
|
@@ -108,8 +134,6 @@ export function applyUpdateTask(
|
|
|
108
134
|
// Session reuse is a boolean opt-in; false (or an explicit null from a
|
|
109
135
|
// caller that needs to clear it) returns the task to one session per run.
|
|
110
136
|
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
137
|
// The /goal opt-in is default-OFF: true joins the goal run, while false
|
|
114
138
|
// (or an explicit null) returns the card to the default and stores nothing.
|
|
115
139
|
if ('goalRun' in patch) next.goalRun = patch.goalRun === true ? true : undefined
|
|
@@ -121,6 +145,10 @@ export function applyUpdateTask(
|
|
|
121
145
|
if (mode !== undefined || 'mode' in patch) next.mode = mode
|
|
122
146
|
if (permission !== undefined || 'permission' in patch) next.permission = permission
|
|
123
147
|
if (model !== undefined || 'model' in patch) next.model = model
|
|
148
|
+
// The effort is bound to the model route above it: blank text (or an
|
|
149
|
+
// explicit undefined) returns the card to the model's own default level,
|
|
150
|
+
// and only the launch decides whether the value can be sent at all.
|
|
151
|
+
if (reasoningEffort !== undefined || 'reasoningEffort' in patch) next.reasoningEffort = reasoningEffort
|
|
124
152
|
return next
|
|
125
153
|
})
|
|
126
154
|
}
|
|
@@ -0,0 +1,81 @@
|
|
|
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 { TaskBoardExtensionPayload } from './extension.ts'
|
|
18
|
+
import type { TaskRecord } from './tasks.ts'
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Keys stripped from an integration payload at every depth, as whole keys and
|
|
22
|
+
* compared case-insensitively.
|
|
23
|
+
*
|
|
24
|
+
* `leaseToken` is the name `dsh-task-board-team` writes for its mirror-card
|
|
25
|
+
* lease and `lease_token` the snake spelling, while the rest are the generic
|
|
26
|
+
* names a bearer credential hides under. The match is the whole key rather than
|
|
27
|
+
* a substring: a payload field that merely mentions one of these words while
|
|
28
|
+
* holding something the provider's own UI renders is not a credential and must
|
|
29
|
+
* keep travelling.
|
|
30
|
+
*/
|
|
31
|
+
const CREDENTIAL_KEYS: ReadonlySet<string> = new Set([
|
|
32
|
+
'leasetoken',
|
|
33
|
+
'lease_token',
|
|
34
|
+
'token',
|
|
35
|
+
'secret',
|
|
36
|
+
'password',
|
|
37
|
+
'apikey',
|
|
38
|
+
'credential',
|
|
39
|
+
])
|
|
40
|
+
|
|
41
|
+
/** Copy one JSON value with every credential-keyed entry removed, at any depth. */
|
|
42
|
+
function withoutCredentials(value: unknown): unknown {
|
|
43
|
+
if (Array.isArray(value)) return value.map(withoutCredentials)
|
|
44
|
+
if (value === null || typeof value !== 'object') return value
|
|
45
|
+
const copy: Record<string, unknown> = {}
|
|
46
|
+
for (const [key, entry] of Object.entries(value as Record<string, unknown>)) {
|
|
47
|
+
if (CREDENTIAL_KEYS.has(key.toLowerCase())) continue
|
|
48
|
+
copy[key] = withoutCredentials(entry)
|
|
49
|
+
}
|
|
50
|
+
return copy
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* The card as the wire may show it: the ledger record with its integration
|
|
55
|
+
* entries copied and stripped.
|
|
56
|
+
*
|
|
57
|
+
* A card that carries no integrations is returned untouched, so a provider that
|
|
58
|
+
* stores nothing sees exactly the record the board has always published.
|
|
59
|
+
* @param task - the ledger record about to be serialized.
|
|
60
|
+
* @returns the projected record; the ledger object is never mutated.
|
|
61
|
+
*/
|
|
62
|
+
export function projectTaskForWire(task: TaskRecord): TaskRecord {
|
|
63
|
+
const stored = task.integrations
|
|
64
|
+
if (stored === undefined) return task
|
|
65
|
+
const integrations: Record<string, TaskBoardExtensionPayload> = {}
|
|
66
|
+
for (const [id, payload] of Object.entries(stored)) {
|
|
67
|
+
integrations[id] = withoutCredentials(payload) as TaskBoardExtensionPayload
|
|
68
|
+
}
|
|
69
|
+
return { ...task, integrations }
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* The snapshot as every read path serializes it: the HTTP `state` answer, the
|
|
74
|
+
* HTTP `action` answer, and the remote bridge's `board.snapshot` all start from
|
|
75
|
+
* the object this returns.
|
|
76
|
+
* @param snapshot - the snapshot the Host service built from its live state.
|
|
77
|
+
* @returns the same snapshot with each card projected through {@link projectTaskForWire}.
|
|
78
|
+
*/
|
|
79
|
+
export function projectSnapshotForWire(snapshot: TaskBoardSnapshot): TaskBoardSnapshot {
|
|
80
|
+
return { ...snapshot, tasks: snapshot.tasks.map(projectTaskForWire) }
|
|
81
|
+
}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Workspace targeting for cards that pin none.
|
|
3
3
|
*
|
|
4
|
-
* The Host answers
|
|
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,
|
|
8
|
-
*
|
|
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.
|
|
@@ -57,3 +58,26 @@ export function mostRecentWorkspaceId(items: readonly WorkspaceCandidate[]): str
|
|
|
57
58
|
}
|
|
58
59
|
return best?.id ?? items[0]?.id
|
|
59
60
|
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* The failure text the Host records when a card names no workspace and the
|
|
64
|
+
* deployment has none to resolve it to: the run is refused before any session
|
|
65
|
+
* exists instead of letting `session.create` fall back to the Host process
|
|
66
|
+
* working directory (the desktop app's profile directory), which is never the
|
|
67
|
+
* project the user meant.
|
|
68
|
+
*
|
|
69
|
+
* A finished sentence rather than a code: the ledger stores it as the
|
|
70
|
+
* execution's failure text, which the agent tools serve to a model and which
|
|
71
|
+
* any client prints verbatim. It names the fix, not the mechanism.
|
|
72
|
+
*/
|
|
73
|
+
export const MISSING_WORKSPACE_REASON = 'this card pins no workspace; choose a workspace on the card before running'
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Whether a recorded failure text is the missing-workspace refusal, which the
|
|
77
|
+
* browser half renders in the reader's own language.
|
|
78
|
+
* @param reason - the execution's recorded failure text.
|
|
79
|
+
* @returns true when that run was refused for naming no workspace.
|
|
80
|
+
*/
|
|
81
|
+
export function isMissingWorkspaceReason(reason: string): boolean {
|
|
82
|
+
return reason === MISSING_WORKSPACE_REASON
|
|
83
|
+
}
|