@linxin666/dsh-client-ui-task-board-team 0.0.0-stage → 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 (74) hide show
  1. package/LICENSE +202 -0
  2. package/README.i18n.yaml +6 -0
  3. package/README.md +66 -2
  4. package/README.zh.md +67 -0
  5. package/cordis.patch.yml +14 -0
  6. package/icon.svg +3 -0
  7. package/lib/client.js +1490 -0
  8. package/lib/index.js +2968 -0
  9. package/lib/types/client/PluginSettingsCard.d.ts +255 -0
  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/index.d.ts +58 -0
  13. package/lib/types/client/locales.d.ts +90 -0
  14. package/lib/types/client/optional-service.d.ts +22 -0
  15. package/lib/types/client/settings-form.d.ts +235 -0
  16. package/lib/types/client/team/extension.d.ts +29 -0
  17. package/lib/types/client/team/sections.d.ts +38 -0
  18. package/lib/types/client/team/settings.d.ts +67 -0
  19. package/lib/types/client/team/summary.d.ts +34 -0
  20. package/lib/types/core/contract.d.ts +269 -0
  21. package/lib/types/core/hub-protocol.d.ts +175 -0
  22. package/lib/types/core/identity.d.ts +96 -0
  23. package/lib/types/core/mirror.d.ts +51 -0
  24. package/lib/types/core/question-report.d.ts +84 -0
  25. package/lib/types/core/settlement.d.ts +49 -0
  26. package/lib/types/core/task-record.d.ts +59 -0
  27. package/lib/types/core/timers.d.ts +20 -0
  28. package/lib/types/host/bindings.d.ts +92 -0
  29. package/lib/types/host/channel.d.ts +44 -0
  30. package/lib/types/host/credentials.d.ts +63 -0
  31. package/lib/types/host/extension.d.ts +57 -0
  32. package/lib/types/host/hub-client.d.ts +157 -0
  33. package/lib/types/host/questions.d.ts +105 -0
  34. package/lib/types/host/service.d.ts +209 -0
  35. package/lib/types/host/setup.d.ts +152 -0
  36. package/lib/types/host/tools.d.ts +19 -0
  37. package/lib/types/host/waterfall.d.ts +39 -0
  38. package/lib/types/index.d.ts +152 -0
  39. package/locale/en.json +6 -0
  40. package/locale/zh.json +6 -0
  41. package/package.json +84 -3
  42. package/src/client/PluginSettingsCard.tsx +838 -0
  43. package/src/client/RangeBubble.tsx +164 -0
  44. package/src/client/SegmentGroup.tsx +93 -0
  45. package/src/client/css-modules.d.ts +5 -0
  46. package/src/client/index.ts +139 -0
  47. package/src/client/locales.ts +168 -0
  48. package/src/client/optional-service.ts +30 -0
  49. package/src/client/settings-card.module.css +821 -0
  50. package/src/client/settings-form.ts +510 -0
  51. package/src/client/team/extension.ts +185 -0
  52. package/src/client/team/sections.tsx +159 -0
  53. package/src/client/team/settings.tsx +348 -0
  54. package/src/client/team/summary.ts +156 -0
  55. package/src/client/team/team.module.css +193 -0
  56. package/src/core/contract.ts +326 -0
  57. package/src/core/hub-protocol.ts +217 -0
  58. package/src/core/identity.ts +193 -0
  59. package/src/core/mirror.ts +88 -0
  60. package/src/core/question-report.ts +144 -0
  61. package/src/core/settlement.ts +84 -0
  62. package/src/core/task-record.ts +65 -0
  63. package/src/core/timers.ts +34 -0
  64. package/src/host/bindings.ts +211 -0
  65. package/src/host/channel.ts +97 -0
  66. package/src/host/credentials.ts +147 -0
  67. package/src/host/extension.ts +197 -0
  68. package/src/host/hub-client.ts +287 -0
  69. package/src/host/questions.ts +275 -0
  70. package/src/host/service.ts +1421 -0
  71. package/src/host/setup.ts +259 -0
  72. package/src/host/tools.ts +70 -0
  73. package/src/host/waterfall.ts +51 -0
  74. package/src/index.ts +452 -0
@@ -0,0 +1,175 @@
1
+ /**
2
+ * Wire vocabulary of the team-hub protocol v1, as the Host half reads it.
3
+ *
4
+ * The protocol specification (`team-hub/PROTOCOL.md`) is the single source of
5
+ * truth; this module restates only what a Host uses and the operational
6
+ * constants section 13 fixes, so a drift in either direction is visible in one
7
+ * place. Nothing here interprets collaboration semantics: the hub is
8
+ * authoritative over issues, comments, questions and activity, and the Host is
9
+ * authoritative over execution.
10
+ *
11
+ * @module dsh-task-board-team/core/hub-protocol
12
+ */
13
+ /** Protocol version sent on every REST call and on the WebSocket handshake. */
14
+ export declare const HUB_PROTOCOL_VERSION = "1.0.0";
15
+ /** Header carrying {@link HUB_PROTOCOL_VERSION}. */
16
+ export declare const HUB_PROTOCOL_HEADER = "X-Team-Hub-Protocol-Version";
17
+ /** Prefix of every REST path this Host speaks. */
18
+ export declare const HUB_API_PREFIX = "/api/v1";
19
+ /** Heartbeat cadence the hub expects from an online Host (section 13). */
20
+ export declare const HEARTBEAT_INTERVAL_MS = 15000;
21
+ /** Lease lifetime the hub grants on a claim (section 13). */
22
+ export declare const LEASE_DURATION_MS = 60000;
23
+ /** Lease renewal cadence while an execution is active (section 13). */
24
+ export declare const LEASE_RENEW_INTERVAL_MS = 20000;
25
+ /** Question lifetime before the hub expires it (section 13). */
26
+ export declare const QUESTION_TTL_MS = 86400000;
27
+ /** Execution summary character cap, aligned with the board's own limit. */
28
+ export declare const EXECUTION_SUMMARY_LIMIT = 4000;
29
+ /** Comment text byte cap (section 11). */
30
+ export declare const COMMENT_LIMIT_BYTES = 32768;
31
+ /** Cadence the claim sweep is coalesced to (protocol amendment A4 point 6). */
32
+ export declare const SWEEP_INTERVAL_MS = 5000;
33
+ /** Backoff the reconnect loop starts at after a dropped WebSocket. */
34
+ export declare const RECONNECT_BASE_MS = 1000;
35
+ /** Upper bound of the reconnect backoff; a longer outage never waits longer. */
36
+ export declare const RECONNECT_MAX_MS = 30000;
37
+ /** Client version this Host reports at registration. */
38
+ export declare const HOST_CLIENT_VERSION = "0.4.12";
39
+ /** Collaboration status of one issue, owned by the hub. */
40
+ export type HubIssueStatus = 'todo' | 'assigned' | 'waiting_host' | 'running' | 'in_review' | 'done' | 'canceled' | 'failed';
41
+ /**
42
+ * One Agent definition this Host registers with the hub.
43
+ *
44
+ * Protocol amendment A4 fixes the registration body as snake_case and requires a
45
+ * non-empty `preset_id`: a member whose definition pins no preset is not
46
+ * reported at all, because the hub would otherwise store an agent this Host can
47
+ * only run under the deployment's default preset.
48
+ */
49
+ export interface HubAgentDefinition {
50
+ /** Name the hub resolves `@` mentions by. */
51
+ name: string;
52
+ /** Agent preset id the member definition pins; never empty. */
53
+ preset_id: string;
54
+ /** Pinned model of that member, when it pins one. */
55
+ model?: string;
56
+ /** Reasoning effort bound to that model, when the member pins one. */
57
+ reasoning_effort?: string;
58
+ }
59
+ /** One Agent record the hub answered registration with. */
60
+ export interface HubAgentRecord {
61
+ id: string;
62
+ name: string;
63
+ }
64
+ /** One issue, as the hub serves it. */
65
+ export interface HubIssue {
66
+ id: string;
67
+ issue_number: number;
68
+ title: string;
69
+ description: string;
70
+ status: HubIssueStatus;
71
+ assignee_type?: 'member' | 'agent';
72
+ assignee_member_id?: string;
73
+ assignee_agent_id?: string;
74
+ reviewer_member_id?: string;
75
+ executing_host_id?: string;
76
+ lease_expires_at?: number;
77
+ /** Attempt the hub currently holds for this issue; null when it holds none. */
78
+ execution_attempt_id?: string | null;
79
+ execution_summary?: string;
80
+ /**
81
+ * Rework instructions waiting to be applied (protocol amendment A4 point 5).
82
+ *
83
+ * Non-empty instructions on the issue mean "a review sent this back": whichever
84
+ * path claims the card next must apply them to the existing mirror card.
85
+ */
86
+ rework_instructions?: string | null;
87
+ failure_error?: string | null;
88
+ updated_at?: number;
89
+ }
90
+ /** What a successful claim hands back. */
91
+ export interface HubClaim {
92
+ lease_token: string;
93
+ lease_expires_at: number;
94
+ execution_attempt_id: string;
95
+ }
96
+ /** One selectable answer, as the hub exposes it on the wire. */
97
+ export interface HubQuestionOption {
98
+ label: string;
99
+ description?: string;
100
+ }
101
+ /**
102
+ * One decision question, in the wire shape (protocol amendment A2).
103
+ *
104
+ * The D1 columns `options_json` and `answer_json` are storage forms only: over
105
+ * the wire both are parsed values, so this client never sees a serialized string
106
+ * and never produces one.
107
+ */
108
+ export interface HubQuestion {
109
+ id: string;
110
+ issue_id: string;
111
+ /** Question prompt text. */
112
+ text: string;
113
+ options: readonly HubQuestionOption[] | null;
114
+ multi_select: boolean;
115
+ status: 'pending' | 'answered' | 'dismissed' | 'expired';
116
+ answer: HubQuestionAnswer | null;
117
+ answered_at: number | null;
118
+ }
119
+ /** One comment on an issue. */
120
+ export interface HubComment {
121
+ id: string;
122
+ issue_id: string;
123
+ author_type: 'human' | 'agent';
124
+ author_member_id?: string;
125
+ author_agent_id?: string;
126
+ content: string;
127
+ created_at: number;
128
+ }
129
+ /**
130
+ * One entry of the hub's append-only activity stream, in the wire shape: the
131
+ * payload is a JSON object here, and `payload_json` exists only inside D1.
132
+ */
133
+ export interface HubActivity {
134
+ id: string;
135
+ issue_id: string;
136
+ actor_type: 'member' | 'agent' | 'host' | 'system';
137
+ actor_id: string | null;
138
+ activity_type: string;
139
+ payload: Record<string, unknown>;
140
+ created_at: number;
141
+ }
142
+ /** The answer one human gives to one question (protocol amendment A2). */
143
+ export interface HubQuestionAnswer {
144
+ selected: readonly string[];
145
+ custom?: string;
146
+ }
147
+ /** One client frame the Host sends on the team channel. */
148
+ export type HubClientFrame = {
149
+ t: 'ping';
150
+ ts: number;
151
+ } | {
152
+ t: 'resume';
153
+ since_seq: number;
154
+ };
155
+ /** One server frame the Host reads from the team channel. */
156
+ export type HubServerFrame = {
157
+ t: 'pong';
158
+ ts: number;
159
+ } | {
160
+ t: 'event';
161
+ seq: number;
162
+ event: string;
163
+ payload: Record<string, unknown>;
164
+ ts: number;
165
+ } | {
166
+ t: 'resync_required';
167
+ reason: string;
168
+ latest_seq: number;
169
+ };
170
+ /**
171
+ * Read one server frame, tolerating anything the hub may add.
172
+ * @param raw - one decoded frame.
173
+ * @returns the frame, or undefined when it carries no recognizable shape.
174
+ */
175
+ export declare function readServerFrame(raw: unknown): HubServerFrame | undefined;
@@ -0,0 +1,96 @@
1
+ /**
2
+ * This extension's own payload on a mirror card.
3
+ *
4
+ * The board stores the payload opaquely and never interprets it, so the shape is
5
+ * this provider's private contract with itself: it is what makes claiming,
6
+ * lease renewal, settlement and rework idempotent across a reconnect, because
7
+ * the attempt credentials the hub wants back are exactly what the card already
8
+ * carries. Everything is optional on read: a payload written by an older
9
+ * revision of this extension must degrade instead of throwing.
10
+ *
11
+ * @module dsh-task-board-team/core/identity
12
+ */
13
+ import type { HubIssueStatus } from './hub-protocol.ts';
14
+ import type { TaskBoardExtensionPayload } from './contract.ts';
15
+ import type { SettleRequestBody } from './settlement.ts';
16
+ import type { TaskRecord } from './task-record.ts';
17
+ /** Extension id: also the key of this provider's integration payload. */
18
+ export declare const TEAM_EXTENSION_ID = "task-board-team";
19
+ /** One mirror card's linkage back to its hub issue. */
20
+ export interface TeamIssueLink {
21
+ /** Hub issue id the card mirrors. */
22
+ issueId: string;
23
+ /** Human-facing issue number, when the hub reported one. */
24
+ issueNumber?: number;
25
+ /** Execution attempt the hub granted on the last successful claim. */
26
+ attemptId?: string;
27
+ /** Lease token that attempt holds; the credential a renew or a re-claim needs. */
28
+ leaseToken?: string;
29
+ /** Lease expiry the hub last reported (ms epoch). */
30
+ leaseExpiresAt?: number;
31
+ /** Hub agent record this member is bound as. */
32
+ agentId?: string;
33
+ /** dsh-agents member id the binding came from. */
34
+ agentMemberId?: string;
35
+ /** Agent preset the member definition pins, recorded for the operator. */
36
+ preset?: string;
37
+ /** Last collaboration status the hub reported for this issue. */
38
+ hubStatus?: HubIssueStatus;
39
+ /** Human assignee display name, when the hub named one. */
40
+ assignee?: string;
41
+ /** Human reviewer display name, when the hub named one. */
42
+ reviewer?: string;
43
+ /** Last provider-side failure worth keeping on the card. */
44
+ lastError?: string;
45
+ /**
46
+ * A settlement the hub has not accepted yet.
47
+ *
48
+ * Recorded before the write-back is sent: a hub that refuses it (a lapsed
49
+ * attempt answers 412) must not lose what the run produced, so the next sweep
50
+ * or reconnect retries this same body and the hub's own gates still decide.
51
+ */
52
+ pendingSettle?: SettleRequestBody;
53
+ }
54
+ /**
55
+ * Read one linkage out of an opaque payload.
56
+ * @param payload - the stored payload, or undefined.
57
+ * @returns the linkage, or undefined when the payload carries no issue id.
58
+ */
59
+ export declare function readTeamIssueLink(payload: TaskBoardExtensionPayload | undefined): TeamIssueLink | undefined;
60
+ /**
61
+ * Read the linkage off one card.
62
+ * @param task - the card to read.
63
+ * @returns its linkage, or undefined when it does not mirror an issue.
64
+ */
65
+ export declare function readTaskIssueLink(task: TaskRecord): TeamIssueLink | undefined;
66
+ /**
67
+ * Project a linkage back onto a payload, dropping undefined members so a merge
68
+ * never stores a key whose value is absent.
69
+ * @param link - the linkage to store.
70
+ * @returns the payload the board keeps under this extension's id.
71
+ */
72
+ export declare function toPayload(link: TeamIssueLink): TaskBoardExtensionPayload;
73
+ /**
74
+ * Find the card that already mirrors one issue.
75
+ * @param linked - every card this extension linked.
76
+ * @param issueId - the issue to look for.
77
+ * @returns the linked task, or undefined when the issue has no card yet.
78
+ */
79
+ export declare function findLinkedTask(linked: readonly {
80
+ task: TaskRecord;
81
+ payload: TaskBoardExtensionPayload;
82
+ }[], issueId: string): TaskRecord | undefined;
83
+ /**
84
+ * Find the card whose execution owns one session.
85
+ *
86
+ * Questions and mentions arrive addressed by SESSION, and the only session a
87
+ * team question may be routed for is one a mirror card opened — that is what
88
+ * keeps this provider out of every other conversation on the machine.
89
+ * @param linked - every card this extension linked.
90
+ * @param sessionId - the session that asked, or that will receive the message.
91
+ * @returns the linked task, or undefined when this session is not a team card's.
92
+ */
93
+ export declare function findTaskBySession(linked: readonly {
94
+ task: TaskRecord;
95
+ payload: TaskBoardExtensionPayload;
96
+ }[], sessionId: string): TaskRecord | undefined;
@@ -0,0 +1,51 @@
1
+ /**
2
+ * The card one hub issue becomes on this Host.
3
+ *
4
+ * Mirroring is deliberately one-way in shape: the card carries the issue's
5
+ * title and body so an operator can read and run it locally, while every
6
+ * collaboration field (assignee, reviewer, status, comments, activity) stays on
7
+ * the hub and reaches the browser through the published summary. Nothing the
8
+ * hub serves is ever interpreted as an execution target — remote text never
9
+ * becomes a permission, a workspace or a preset.
10
+ *
11
+ * @module dsh-task-board-team/core/mirror
12
+ */
13
+ import type { HubIssue } from './hub-protocol.ts';
14
+ /** Longest title a mirrored card carries, matching the hub's own issue cap. */
15
+ export declare const MIRROR_TITLE_LIMIT = 256;
16
+ /** Longest issue body carried into a card description. */
17
+ export declare const MIRROR_DESCRIPTION_LIMIT = 32000;
18
+ /** The member one issue was claimed for, as the mirror needs it. */
19
+ export interface MirrorAgent {
20
+ /** Hub agent record id. */
21
+ agentId: string;
22
+ /** dsh-agents member id. */
23
+ memberId: string;
24
+ /** Member name the hub resolves mentions by. */
25
+ name: string;
26
+ /** Agent preset the member definition pins. */
27
+ preset?: string;
28
+ /** Model the member definition pins, when it pins one. */
29
+ model?: string;
30
+ /** Reasoning effort the member definition pins for that model. */
31
+ reasoningEffort?: string;
32
+ /** Workspace the card runs in, as the caller resolved it for this member. */
33
+ workspaceId?: string;
34
+ }
35
+ /** The draft a mirror card is created from. */
36
+ export interface MirrorDraft {
37
+ title: string;
38
+ description: string;
39
+ prompt: string;
40
+ workspaceId?: string;
41
+ mode?: string;
42
+ model?: string;
43
+ reasoningEffort?: string;
44
+ }
45
+ /**
46
+ * Build the card a claimed issue becomes.
47
+ * @param issue - the claimed issue.
48
+ * @param agent - the member it was claimed for.
49
+ * @returns the draft the board creates the card from.
50
+ */
51
+ export declare function buildMirrorDraft(issue: HubIssue, agent: MirrorAgent): MirrorDraft;
@@ -0,0 +1,84 @@
1
+ /** One selectable answer offered by the asker. */
2
+ export interface QuestionOption {
3
+ readonly label: string;
4
+ readonly description?: string;
5
+ }
6
+ /** One question, in the shape the Host's question event publishes. */
7
+ export interface QuestionItem {
8
+ readonly id: string;
9
+ readonly question: string;
10
+ readonly header?: string;
11
+ readonly detail?: string;
12
+ readonly options?: readonly QuestionOption[];
13
+ readonly multiSelect?: boolean;
14
+ }
15
+ /** The fields of a Host question request this provider reads. */
16
+ export interface QuestionRequestShape {
17
+ readonly questions: readonly QuestionItem[];
18
+ /** The agent asking; its id IS the session id (the event carries no session field). */
19
+ readonly agent?: {
20
+ readonly id: string;
21
+ };
22
+ readonly signal?: AbortSignal;
23
+ }
24
+ /** One item of the answer batch the Host settles its ask with. */
25
+ export interface QuestionAnswerItem {
26
+ readonly id: string;
27
+ readonly selected: readonly string[];
28
+ readonly custom?: string;
29
+ }
30
+ /** The whole answer batch the Host's ask is settled with. */
31
+ export interface QuestionAnswer {
32
+ readonly answers: readonly QuestionAnswerItem[];
33
+ }
34
+ /** The body one question report sends to the hub. */
35
+ export interface QuestionReportBody {
36
+ question_text: string;
37
+ /** Selectable answers, in the wire shape the hub stores and serves. */
38
+ options?: readonly QuestionOption[];
39
+ multi_select?: boolean;
40
+ }
41
+ /**
42
+ * Build the hub question one Host question request reports.
43
+ * @param item - the first question of the batch.
44
+ * @returns the report body.
45
+ */
46
+ export declare function buildQuestionReport(item: QuestionItem): QuestionReportBody;
47
+ /**
48
+ * Map one team answer back onto the question the Host asked.
49
+ * @param item - the reported question item (whose id the answer addresses).
50
+ * @param answer - the hub's answer payload: the selected labels and optional custom text.
51
+ * @returns the answer batch the Host settles its ask with.
52
+ */
53
+ export declare function answerToHost(item: QuestionItem, answer: {
54
+ selected: readonly string[];
55
+ custom?: string;
56
+ }): QuestionAnswer;
57
+ /**
58
+ * The answer batch that ends a question nobody answered.
59
+ *
60
+ * The protocol resolves an expired question as unanswered so the agent can
61
+ * proceed on its own assumptions or pause; the Host's answer vocabulary has no
62
+ * "expired" outcome, so the ask settles with an empty batch — a defined answer
63
+ * that selected nothing — instead of a fabricated choice a human never made.
64
+ * @returns the empty answer batch.
65
+ */
66
+ export declare function unansweredAnswer(): QuestionAnswer;
67
+ /** Longest question text one report may carry, derived from the hub's own TTL budget. */
68
+ export declare const QUESTION_REPORT_MAX_LENGTH = 4000;
69
+ /** Whether a question request still fits the hub's question schema. */
70
+ export declare function isReportable(item: QuestionItem): boolean;
71
+ /** Deadline one pending question expires at, measured from the moment it was asked. */
72
+ export declare function questionExpiry(askedAt: number): number;
73
+ declare module '@deepseek-ai/cordis' {
74
+ interface Events {
75
+ /**
76
+ * Ask composed answerers one decision question. Returning an answer claims the
77
+ * request; calling \`next()\` delegates to the rest of the chain.
78
+ * @param request - the pending question batch.
79
+ * @param next - the rest of the answerer chain.
80
+ * @mode waterfall
81
+ */
82
+ 'user-questions/request'(this: unknown, request: QuestionRequestShape, next: () => Promise<QuestionAnswer>): Promise<QuestionAnswer>;
83
+ }
84
+ }
@@ -0,0 +1,49 @@
1
+ import type { ExecutionOutcome, TaskRecord } from './task-record.ts';
2
+ /** The body one settlement write-back sends. */
3
+ export interface SettleRequestBody {
4
+ outcome: 'succeeded' | 'failed';
5
+ summary: string;
6
+ error?: string;
7
+ /**
8
+ * The attempt this settlement belongs to.
9
+ *
10
+ * The hub keeps it optional, but a lease that expired while the run was still
11
+ * going is only accepted when the attempt matches: presenting it is what lets a
12
+ * long execution report its own result instead of having it refused as stale.
13
+ */
14
+ execution_attempt_id?: string;
15
+ /**
16
+ * What the Host itself verified, in the shape the frozen settlement sample
17
+ * shows. It is the local evidence a reviewer reads next to the outcome.
18
+ */
19
+ verification_evidence?: Record<string, unknown>;
20
+ }
21
+ /**
22
+ * Map one execution outcome onto the hub's settlement vocabulary.
23
+ * @param outcome - the board's own verdict.
24
+ * @returns `succeeded` only for a passed run.
25
+ */
26
+ export declare function settleOutcome(outcome: ExecutionOutcome): 'succeeded' | 'failed';
27
+ /**
28
+ * Clip one summary to the protocol's character cap.
29
+ * @param text - the text to clip.
30
+ * @returns text of at most {@link EXECUTION_SUMMARY_LIMIT} characters.
31
+ */
32
+ export declare function clipSummary(text: string): string;
33
+ /**
34
+ * Build the settlement body for one settled execution.
35
+ *
36
+ * The summary names the run and what it produced, so a reviewer reading the hub
37
+ * sees which attempt this was without opening the Host: the card title, the
38
+ * attempt id and, on a failure, the recorded reason.
39
+ * @param input - the settlement event and the card it belongs to.
40
+ * @returns the body to post.
41
+ */
42
+ export declare function buildSettleRequest(input: {
43
+ task: TaskRecord;
44
+ executionId: string;
45
+ outcome: ExecutionOutcome;
46
+ error?: string;
47
+ /** Attempt the card was claimed under, when the payload still records one. */
48
+ attemptId?: string;
49
+ }): SettleRequestBody;
@@ -0,0 +1,59 @@
1
+ /**
2
+ * Structural view of the task-board vocabulary this extension reads.
3
+ *
4
+ * The extension is a separate bundle and may not import the board's internals,
5
+ * so it restates the record shape the provider contract hands it. These are
6
+ * read-only structural declarations: the board's own values satisfy them and
7
+ * nothing here is constructed by the board.
8
+ *
9
+ * @module dsh-task-board-team/core/task-record
10
+ */
11
+ /** Column a card occupies. */
12
+ export type TaskStatus = 'backlog' | 'todo' | 'running' | 'done' | 'failed';
13
+ /** Settlement of one execution. */
14
+ export type ExecutionOutcome = 'succeeded' | 'failed' | 'cancelled';
15
+ /** One execution of a card, as a provider reads it. */
16
+ export interface ExecutionRecord {
17
+ /** Stable execution id. */
18
+ id: string;
19
+ /** Session the execution runs in, once one was opened. */
20
+ sessionId?: string | undefined;
21
+ /** Instant the execution started (ms epoch). */
22
+ startedAt: number;
23
+ /** Instant the execution settled (ms epoch), absent while it runs. */
24
+ endedAt?: number | undefined;
25
+ /** Settlement, absent while the execution is still running. */
26
+ result?: ExecutionOutcome | undefined;
27
+ /** Human failure text when the run failed. */
28
+ error?: string | undefined;
29
+ /** Rework instructions this execution carries, when a run was sent back. */
30
+ rework?: {
31
+ instructions?: string;
32
+ } | undefined;
33
+ }
34
+ /** One card, as a provider reads it through the capability face. */
35
+ export interface TaskRecord {
36
+ id: string;
37
+ title: string;
38
+ description: string;
39
+ prompt: string;
40
+ status: TaskStatus;
41
+ createdAt: number;
42
+ updatedAt: number;
43
+ parentId?: string;
44
+ workspaceId?: string;
45
+ /** Agent preset the card's execution must be composed from. */
46
+ mode?: string;
47
+ hidden?: boolean;
48
+ archivedAt?: number;
49
+ executions: ExecutionRecord[];
50
+ tags?: ReadonlyArray<{
51
+ name: string;
52
+ }>;
53
+ /** Opaque provider payloads, keyed by extension id. */
54
+ integrations?: Record<string, unknown>;
55
+ }
56
+ /** Whether one card still occupies a column the board calls unfinished. */
57
+ export declare function isOpenTask(task: TaskRecord): boolean;
58
+ /** Whether one card currently has an execution the board has not settled. */
59
+ export declare function hasOpenExecution(task: TaskRecord): boolean;
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Timer seat the team sync service schedules through.
3
+ *
4
+ * The extension never reaches for a global timer directly: the Host entry
5
+ * injects the timer face, so heartbeats, lease renewals and reconnect backoff
6
+ * are observable and cancellable under fake timers without patching globals.
7
+ *
8
+ * @module dsh-task-board-team/core/timers
9
+ */
10
+ /** The timer operations this provider needs, each returning its own canceller. */
11
+ export interface HostTimerFace {
12
+ /** Run `callback` once after `delay` ms. */
13
+ timeout(callback: () => void, delay: number): () => void;
14
+ /** Run `callback` every `delay` ms. */
15
+ interval(callback: () => void, delay: number): () => void;
16
+ }
17
+ /** The process timer face: what a real Host mount uses. */
18
+ export declare const processTimers: HostTimerFace;
19
+ /** One clock the service reads; injectable so tests can pin time. */
20
+ export type Clock = () => number;
@@ -0,0 +1,92 @@
1
+ /** The plugin directory dsh-agents keeps under the DSH home. */
2
+ export declare const AGENTS_HOME_DIRECTORY = "dsh-agents";
3
+ /** The ledger file dsh-agents writes its teams and members into. */
4
+ export declare const AGENTS_LEDGER_FILE = "ledger.json";
5
+ /** One member definition, as the agents ledger stores it. */
6
+ export interface AgentsMemberDefinition {
7
+ id: string;
8
+ teamId: string;
9
+ name: string;
10
+ preset?: string;
11
+ permission?: 'read-only' | 'workspace-write' | 'danger-full-access';
12
+ model?: string;
13
+ reasoningEffort?: string;
14
+ brief?: string;
15
+ }
16
+ /** One team in the agents ledger. */
17
+ export interface AgentsTeamDefinition {
18
+ id: string;
19
+ name: string;
20
+ workspaceId?: string;
21
+ members: AgentsMemberDefinition[];
22
+ }
23
+ /** What this module reads out of the agents ledger. */
24
+ export interface AgentsLedgerView {
25
+ teams: AgentsTeamDefinition[];
26
+ /** Why the ledger could not be read, when it could not. */
27
+ problem?: string;
28
+ }
29
+ /** One member this Host binds as a team Agent. */
30
+ export interface BoundAgent {
31
+ /** dsh-agents member id. */
32
+ memberId: string;
33
+ /** Team the member belongs to. */
34
+ teamId: string;
35
+ /** Team name, for the operator. */
36
+ teamName: string;
37
+ /** Name the hub resolves mentions by. */
38
+ name: string;
39
+ /** Agent preset the member definition pins. */
40
+ preset?: string;
41
+ /** Model the member definition pins. */
42
+ model?: string;
43
+ /** Reasoning effort the member definition pins for that model. */
44
+ reasoningEffort?: string;
45
+ /** Workspace the member's team pins, so the mirror card runs where the member does. */
46
+ workspaceId?: string;
47
+ }
48
+ /** One configured binding, as the settings entry stores it. */
49
+ export interface TeamAgentBinding {
50
+ /** dsh-agents member id to bind. */
51
+ memberId: string;
52
+ /** Name the hub resolves mentions by; empty falls back to the member's own name. */
53
+ name?: string;
54
+ }
55
+ /**
56
+ * Resolve the DSH home directory the way every other plugin does.
57
+ * @param env - process environment.
58
+ * @param home - platform home fallback (test seam).
59
+ * @returns the absolute DSH home path.
60
+ */
61
+ export declare function resolveDshHome(env?: NodeJS.ProcessEnv, home?: string): string;
62
+ /**
63
+ * Resolve the path of the agents ledger file.
64
+ * @param env - process environment.
65
+ * @param home - platform home fallback (test seam).
66
+ * @returns the absolute ledger path.
67
+ */
68
+ export declare function agentsLedgerPath(env?: NodeJS.ProcessEnv, home?: string): string;
69
+ /**
70
+ * Read the agents ledger as a member-definition view.
71
+ *
72
+ * Anything unexpected reads as an empty binding list with a reason instead of an
73
+ * exception: this Host has to keep working when dsh-agents is not installed, and
74
+ * a half-written ledger must never turn into a claim of somebody else's work.
75
+ * @param read - file reader seam, defaulting to the filesystem.
76
+ * @returns the teams it found, plus why it found none when that is the case.
77
+ */
78
+ export declare function readAgentsLedger(file: string, read?: (path: string) => Promise<string>): Promise<AgentsLedgerView>;
79
+ /**
80
+ * Project configured bindings onto the member definitions they name.
81
+ *
82
+ * A binding whose member no longer exists is reported and skipped: the hub keeps
83
+ * the agent record it already has, and this Host simply stops claiming for it,
84
+ * which is what an operator unpublishing a member means.
85
+ * @param bindings - the configured member ids.
86
+ * @param view - the members read out of the agents ledger.
87
+ * @returns the resolved agents and one problem line per unusable binding.
88
+ */
89
+ export declare function resolveBindings(bindings: readonly TeamAgentBinding[], view: AgentsLedgerView): {
90
+ agents: BoundAgent[];
91
+ problems: string[];
92
+ };
@@ -0,0 +1,44 @@
1
+ /**
2
+ * The team channel: the WebSocket the hub pushes events over.
3
+ *
4
+ * Both halves of the transport live here rather than in the sync service: the
5
+ * URL is derived from the configured hub (http becomes ws), and one socket is
6
+ * a thin wrapper over whatever the deployment's WebSocket constructor is. The
7
+ * reconnect policy stays with the service, because only it knows whether a
8
+ * dropped connection is a lease-ending outage or a quiet restart.
9
+ *
10
+ * @module dsh-task-board-team/host/channel
11
+ */
12
+ /** One open socket, as the service drives it. */
13
+ export interface SocketLike {
14
+ /** Send one text frame. */
15
+ send(data: string): void;
16
+ /** Close the connection; a later close event is not reported again. */
17
+ close(): void;
18
+ }
19
+ /** What one socket reports back. */
20
+ export interface SocketHandlers {
21
+ /** One decoded text frame. */
22
+ message(data: string): void;
23
+ /** The connection ended; the service decides whether to reconnect. */
24
+ closed(reason?: string): void;
25
+ }
26
+ /** Open one socket at `url`, presenting `headers` on the upgrade, and wire its handlers. */
27
+ export type ConnectSocket = (url: string, handlers: SocketHandlers, headers: Record<string, string>) => SocketLike;
28
+ /**
29
+ * Derive the team channel URL for one hub. The Host Token never travels in the
30
+ * URL; it rides the upgrade's Authorization header (see {@link teamSocketHeaders}).
31
+ * @param hubUrl - configured hub base URL (http/https or ws/wss).
32
+ * @param teamId - team the channel belongs to.
33
+ * @param sinceSeq - last event sequence this Host saw; 0 asks for a full replay.
34
+ * @returns the absolute WebSocket URL.
35
+ */
36
+ export declare function teamSocketUrl(hubUrl: string, teamId: string, sinceSeq: number): string;
37
+ /**
38
+ * The upgrade headers the hub authenticates a Host channel with.
39
+ * @param token - Host Token the handshake presents.
40
+ * @returns the Authorization and protocol version headers.
41
+ */
42
+ export declare function teamSocketHeaders(token: string): Record<string, string>;
43
+ /** The default socket factory: the platform WebSocket, with the headers on the upgrade. */
44
+ export declare const platformSocket: ConnectSocket;