@linxin666/dsh-client-ui-task-board-ssh 0.0.0-stage → 0.4.21

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 (128) hide show
  1. package/LICENSE +202 -0
  2. package/README.i18n.yaml +6 -0
  3. package/README.md +96 -2
  4. package/README.zh.md +97 -0
  5. package/cordis.patch.yml +15 -0
  6. package/icon.svg +5 -0
  7. package/lib/client.js +4435 -0
  8. package/lib/index.js +7082 -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 +100 -0
  13. package/lib/types/client/locales.d.ts +125 -0
  14. package/lib/types/client/seat-props.d.ts +53 -0
  15. package/lib/types/client/settings-entry-form.d.ts +49 -0
  16. package/lib/types/client/settings-form.d.ts +237 -0
  17. package/lib/types/client/ssh/card-decoration.d.ts +23 -0
  18. package/lib/types/client/ssh/compose-section.d.ts +7 -0
  19. package/lib/types/client/ssh/detail-section.d.ts +7 -0
  20. package/lib/types/client/ssh/extension.d.ts +54 -0
  21. package/lib/types/client/ssh/log-buffer.d.ts +128 -0
  22. package/lib/types/client/ssh/log-view.d.ts +37 -0
  23. package/lib/types/client/ssh/model.d.ts +130 -0
  24. package/lib/types/client/ssh/settings-section.d.ts +134 -0
  25. package/lib/types/client/ssh/summary.d.ts +160 -0
  26. package/lib/types/client/ssh/target-form.d.ts +60 -0
  27. package/lib/types/core/action.d.ts +89 -0
  28. package/lib/types/core/adapters/claude.d.ts +15 -0
  29. package/lib/types/core/adapters/codex.d.ts +15 -0
  30. package/lib/types/core/adapters/custom.d.ts +29 -0
  31. package/lib/types/core/adapters/dsh.d.ts +21 -0
  32. package/lib/types/core/adapters/index.d.ts +25 -0
  33. package/lib/types/core/adapters/types.d.ts +76 -0
  34. package/lib/types/core/contract.d.ts +453 -0
  35. package/lib/types/core/launcher-script.d.ts +13 -0
  36. package/lib/types/core/launcher.d.ts +153 -0
  37. package/lib/types/core/ledger.d.ts +123 -0
  38. package/lib/types/core/shell.d.ts +61 -0
  39. package/lib/types/core/target.d.ts +149 -0
  40. package/lib/types/core/task-record.d.ts +74 -0
  41. package/lib/types/core/workspace.d.ts +74 -0
  42. package/lib/types/host/board.d.ts +75 -0
  43. package/lib/types/host/engine.d.ts +563 -0
  44. package/lib/types/host/extension.d.ts +61 -0
  45. package/lib/types/host/inspect.d.ts +99 -0
  46. package/lib/types/host/logs.d.ts +135 -0
  47. package/lib/types/host/payload.d.ts +75 -0
  48. package/lib/types/host/prompt.d.ts +44 -0
  49. package/lib/types/host/queue.d.ts +53 -0
  50. package/lib/types/host/remote.d.ts +137 -0
  51. package/lib/types/host/settings.d.ts +149 -0
  52. package/lib/types/host/timers.d.ts +20 -0
  53. package/lib/types/host/tools.d.ts +17 -0
  54. package/lib/types/host/workspace/errors.d.ts +29 -0
  55. package/lib/types/host/workspace/git.d.ts +108 -0
  56. package/lib/types/host/workspace/in-place.d.ts +36 -0
  57. package/lib/types/host/workspace/index.d.ts +28 -0
  58. package/lib/types/host/workspace/layout.d.ts +62 -0
  59. package/lib/types/host/workspace/local-git.d.ts +72 -0
  60. package/lib/types/host/workspace/remote-git.d.ts +111 -0
  61. package/lib/types/host/workspace/remote.d.ts +85 -0
  62. package/lib/types/host/workspace/types.d.ts +28 -0
  63. package/lib/types/host/workspace-seam.d.ts +100 -0
  64. package/lib/types/index.d.ts +97 -0
  65. package/lib/types/mount-once.d.ts +55 -0
  66. package/locale/en.json +6 -0
  67. package/locale/zh.json +6 -0
  68. package/package.json +89 -3
  69. package/src/client/PluginSettingsCard.tsx +838 -0
  70. package/src/client/RangeBubble.tsx +164 -0
  71. package/src/client/SegmentGroup.tsx +93 -0
  72. package/src/client/css-modules.d.ts +5 -0
  73. package/src/client/index.ts +195 -0
  74. package/src/client/locales.ts +257 -0
  75. package/src/client/seat-props.ts +58 -0
  76. package/src/client/settings-card.module.css +821 -0
  77. package/src/client/settings-entry-form.ts +141 -0
  78. package/src/client/settings-form.ts +529 -0
  79. package/src/client/ssh/card-decoration.tsx +55 -0
  80. package/src/client/ssh/compose-section.tsx +147 -0
  81. package/src/client/ssh/detail-section.tsx +345 -0
  82. package/src/client/ssh/extension.ts +271 -0
  83. package/src/client/ssh/log-buffer.ts +224 -0
  84. package/src/client/ssh/log-view.tsx +149 -0
  85. package/src/client/ssh/model.ts +299 -0
  86. package/src/client/ssh/settings-section.tsx +401 -0
  87. package/src/client/ssh/summary.ts +388 -0
  88. package/src/client/ssh/target-form.tsx +380 -0
  89. package/src/client/ssh.module.css +617 -0
  90. package/src/core/action.ts +270 -0
  91. package/src/core/adapters/claude.ts +64 -0
  92. package/src/core/adapters/codex.ts +83 -0
  93. package/src/core/adapters/custom.ts +88 -0
  94. package/src/core/adapters/dsh.ts +87 -0
  95. package/src/core/adapters/index.ts +74 -0
  96. package/src/core/adapters/types.ts +95 -0
  97. package/src/core/contract.ts +515 -0
  98. package/src/core/launcher-script.ts +313 -0
  99. package/src/core/launcher.ts +283 -0
  100. package/src/core/ledger.ts +377 -0
  101. package/src/core/shell.ts +77 -0
  102. package/src/core/target.ts +420 -0
  103. package/src/core/task-record.ts +73 -0
  104. package/src/core/workspace.ts +78 -0
  105. package/src/host/board.ts +107 -0
  106. package/src/host/engine.ts +2026 -0
  107. package/src/host/extension.ts +310 -0
  108. package/src/host/inspect.ts +264 -0
  109. package/src/host/logs.ts +297 -0
  110. package/src/host/payload.ts +134 -0
  111. package/src/host/prompt.ts +89 -0
  112. package/src/host/queue.ts +73 -0
  113. package/src/host/remote.ts +356 -0
  114. package/src/host/settings.ts +294 -0
  115. package/src/host/timers.ts +33 -0
  116. package/src/host/tools.ts +449 -0
  117. package/src/host/workspace/errors.ts +43 -0
  118. package/src/host/workspace/git.ts +305 -0
  119. package/src/host/workspace/in-place.ts +58 -0
  120. package/src/host/workspace/index.ts +37 -0
  121. package/src/host/workspace/layout.ts +122 -0
  122. package/src/host/workspace/local-git.ts +164 -0
  123. package/src/host/workspace/remote-git.ts +244 -0
  124. package/src/host/workspace/remote.ts +181 -0
  125. package/src/host/workspace/types.ts +34 -0
  126. package/src/host/workspace-seam.ts +132 -0
  127. package/src/index.ts +243 -0
  128. package/src/mount-once.ts +142 -0
@@ -0,0 +1,95 @@
1
+ /**
2
+ * What every agent adapter consumes and produces.
3
+ *
4
+ * An adapter is a pure function pair: one maps a run's facts onto the command
5
+ * line the remote launcher runs, the other reads the agent's output stream for
6
+ * the session id and the final summary. Neither touches the network, the
7
+ * filesystem or the clock, so both are snapshot-testable and a new agent CLI is
8
+ * one module plus one row in the dispatch table.
9
+ *
10
+ * @module dsh-task-board-ssh/core/adapters/types
11
+ */
12
+ import type { SshAgentKind } from '../target.ts'
13
+
14
+ /** Everything one adapter needs about the run it is building a command for. */
15
+ export interface SshAgentRunInput {
16
+ /** Agent CLI kind; selects the adapter. */
17
+ agent: SshAgentKind
18
+ /** Absolute remote path of the prompt file the caller wrote. */
19
+ promptFile: string
20
+ /** Absolute remote directory the launcher changes into first. */
21
+ cwd: string
22
+ /** Session to continue; absent builds the start command, present the resume command. */
23
+ resumeSessionId?: string
24
+ }
25
+
26
+ /** One command line, fully quoted, plus the file it reads its prompt from. */
27
+ export interface SshAgentCommand {
28
+ /** Single-line POSIX command, every word already quoted. */
29
+ command: string
30
+ /** Absolute remote file redirected into the command's stdin, when it reads one. */
31
+ stdinFile?: string
32
+ }
33
+
34
+ /**
35
+ * What one run is worth, as the agent reported it.
36
+ *
37
+ * `ok: false` carries the agent's own failure text verbatim, because the card
38
+ * shows it; the caller bounds it before storing.
39
+ */
40
+ export type SshAgentOutcome = { ok: true; text: string } | { ok: false; error: string }
41
+
42
+ /** What a reader found in one output stream; both members are absent when it found neither. */
43
+ export interface SshAgentOutput {
44
+ /** Session id the agent reported, usable as `resumeSessionId` later. */
45
+ sessionId?: string
46
+ /** Final summary, or the agent's own failure. */
47
+ outcome?: SshAgentOutcome
48
+ }
49
+
50
+ /** User-supplied command templates of a custom agent. */
51
+ export interface SshCustomTemplates {
52
+ /** Start template; must reference `{prompt_file}`. */
53
+ command: string
54
+ /** Resume template; absent degrades a follow-up to a fresh run. */
55
+ resumeCommand?: string
56
+ }
57
+
58
+ /** One line of newline-delimited JSON, as an object. */
59
+ export type JsonLine = Record<string, unknown>
60
+
61
+ /**
62
+ * Read newline-delimited JSON without throwing.
63
+ *
64
+ * Agents interleave progress notes and warnings with their event stream, and a
65
+ * truncated final line is normal when a run is killed mid-write, so a line that
66
+ * is not a JSON object is skipped instead of failing the read.
67
+ * @param output - the whole captured stream.
68
+ * @returns every line that parsed to an object, in order.
69
+ */
70
+ export function readJsonLines(output: string): JsonLine[] {
71
+ const events: JsonLine[] = []
72
+ for (const line of output.split('\n')) {
73
+ const text = line.trim()
74
+ if (text.length === 0 || !text.startsWith('{')) continue
75
+ try {
76
+ const parsed: unknown = JSON.parse(text)
77
+ if (typeof parsed === 'object' && parsed !== null && !Array.isArray(parsed)) events.push(parsed as JsonLine)
78
+ } catch {
79
+ // A partial or non-JSON line is not an event; the caller sees the others.
80
+ }
81
+ }
82
+ return events
83
+ }
84
+
85
+ /**
86
+ * Read one string field off an arbitrary JSON value without a cast.
87
+ * @param value - container to read.
88
+ * @param key - field name.
89
+ * @returns the string, or undefined when the field is absent or not a string.
90
+ */
91
+ export function readString(value: unknown, key: string): string | undefined {
92
+ if (typeof value !== 'object' || value === null) return undefined
93
+ const field = (value as Record<string, unknown>)[key]
94
+ return typeof field === 'string' ? field : undefined
95
+ }
@@ -0,0 +1,515 @@
1
+ /**
2
+ * Same-shape restatement of the two contracts this extension sits between.
3
+ *
4
+ * The board owns the provider contract (`packages/dsh-task-board/src/core/extension.ts`)
5
+ * and `dsh-ssh` owns its host service; this package may not import either
6
+ * package's internals, so every type and constant it consumes is restated here
7
+ * with an identical shape and resolved at runtime through the shared cordis
8
+ * service name. Nothing in this module is a value import of a board or ssh
9
+ * package: the declarations are erased and each service lookup is a plain
10
+ * property read.
11
+ *
12
+ * Both seams are incremental members under an unchanged API version, following
13
+ * the precedent the board set with `tasks.rework` and `sessions.followUp`:
14
+ * `launch?.intercept(handler)` on the host face and `dshSsh`'s `exec`/`upload`/
15
+ * `download` forwards. A deployment that serves neither keeps working, because
16
+ * every new member is optional and probed before use.
17
+ *
18
+ * This module augments no cordis `Context`. Each service already owns its own
19
+ * `Context` member in the package that publishes it, and a provider that
20
+ * restated one would collide the moment a type program held both restatements
21
+ * and the published contract (TypeScript refuses two declarations of one
22
+ * property that are not identical, and a restatement is never identical: it is
23
+ * deliberately narrower). Every face is therefore read structurally through
24
+ * {@link resolveTaskBoardHostFace}, {@link resolveTaskBoardClientFace} and
25
+ * {@link resolveDshSshService}, which is how the board's own team provider does
26
+ * it, and which also means an older or newer deployment degrades instead of
27
+ * failing to compile.
28
+ *
29
+ * @module dsh-task-board-ssh/core/contract
30
+ */
31
+ import type { ToolDefinition } from '@deepseek-ai/dsh-tools'
32
+ import type { ExecutionOutcome, TaskRecord, TaskStatus } from './task-record.ts'
33
+
34
+ /** Cordis service name the board's host and browser halves each publish. */
35
+ export const TASK_BOARD_SERVICE_NAME = 'taskBoard'
36
+
37
+ /** Board contract version this extension was built against. */
38
+ export const TASK_BOARD_API_VERSION = 1
39
+
40
+ /** Child seat a provider registers its task-detail section into. */
41
+ export const TASK_BOARD_DETAIL_SECTION = 'task-board.detail.section'
42
+ /** Child seat a provider registers its settings section into. */
43
+ export const TASK_BOARD_SETTINGS_SECTION = 'task-board.settings.section'
44
+ /** Child seat a provider registers its card decoration into. */
45
+ export const TASK_BOARD_CARD_DECORATION = 'task-board.card.decoration'
46
+ /**
47
+ * Child seat a provider registers its new-card section into: its own
48
+ * create-time configuration, rendered inside the create dialog's execution
49
+ * settings, whose draft the board stores on the card it creates.
50
+ */
51
+ export const TASK_BOARD_COMPOSE_SECTION = 'task-board.compose.section'
52
+
53
+ /** Largest accepted extension payload, in bytes of its JSON serialization. */
54
+ export const TASK_BOARD_PAYLOAD_LIMIT_BYTES = 64 * 1024
55
+
56
+ /** Largest accepted free text a provider pushes into an execution, in characters. */
57
+ export const TASK_BOARD_MESSAGE_MAX_LENGTH = 4_000
58
+
59
+ /** One opaque provider payload the board stores without interpreting. */
60
+ export type TaskBoardExtensionPayload = Record<string, unknown>
61
+
62
+ /** One action the browser half dispatches over the board's same-origin channel. */
63
+ export interface TaskBoardExtensionActionRequest {
64
+ /** Id of the extension the action belongs to. */
65
+ extensionId: string
66
+ /** Provider-owned action name, routed back to this extension's handleAction. */
67
+ action: string
68
+ /** Task the action targets, when it targets one. */
69
+ taskId?: string
70
+ /** Opaque provider payload, bounded like every other extension payload. */
71
+ payload?: TaskBoardExtensionPayload
72
+ }
73
+
74
+ /** Deliver one extension action through the board's same-origin action channel. */
75
+ export type TaskBoardExtensionDispatch = (request: TaskBoardExtensionActionRequest) => Promise<boolean>
76
+
77
+ /** Draft one provider creates a task from. */
78
+ export interface TaskBoardTaskDraft {
79
+ /** Card title. */
80
+ title: string
81
+ /** Card description. */
82
+ description: string
83
+ /** Prompt an execution sends to the agent. */
84
+ prompt: string
85
+ /** Column the created card opens in; absent means the board default. */
86
+ status?: TaskStatus
87
+ /** Parent card id, when the provider materializes a subtask. */
88
+ parentId?: string
89
+ /** Workspace the execution must run in; absent leaves the board's rules in charge. */
90
+ workspaceId?: string
91
+ /** Agent preset the card pins as its execution composition. */
92
+ mode?: string
93
+ /** Model the card pins, in `provider/model` form. */
94
+ model?: string
95
+ /** Reasoning level for the pinned model. */
96
+ reasoningEffort?: string
97
+ }
98
+
99
+ /** Options of {@link TaskBoardTasksFace.create}. */
100
+ export interface TaskBoardCreateOptions {
101
+ /** Opaque payload stored under the creating extension's id. */
102
+ payload?: TaskBoardExtensionPayload
103
+ /** Create the card off-board: it exists in the ledger but is never shown. */
104
+ hidden?: boolean
105
+ }
106
+
107
+ /** One task linked to an extension, with that extension's own payload. */
108
+ export interface TaskBoardLinkedTask {
109
+ /** The card as the board stores it. */
110
+ task: TaskRecord
111
+ /** This extension's payload on that card. */
112
+ payload: TaskBoardExtensionPayload
113
+ }
114
+
115
+ /** Task reads and writes the board grants an extension. */
116
+ export interface TaskBoardTasksFace {
117
+ /** Every task in the ledger. */
118
+ list(): readonly TaskRecord[]
119
+ /** One task by id, or undefined. */
120
+ get(taskId: string): TaskRecord | undefined
121
+ /** Create a task through the board's own creation gate. Throws on refusal. */
122
+ create(draft: TaskBoardTaskDraft, options?: TaskBoardCreateOptions): TaskRecord
123
+ /** Patch a task's content through the board's content gate. Throws when frozen. */
124
+ patchContent(taskId: string, patch: { title?: string; description?: string; prompt?: string }): void
125
+ /** Move a task through the board's status gates. Throws on refusal. */
126
+ setStatus(taskId: string, status: TaskStatus, initiator?: string): void
127
+ /** Every task carrying this extension's payload. */
128
+ linked(): readonly TaskBoardLinkedTask[]
129
+ /** Run an already executed card again in its original session. */
130
+ rework?(taskId: string, instructions: string, initiator?: string): void
131
+ }
132
+
133
+ /** Execution-session face: what a provider delivers INTO a board run. */
134
+ export interface TaskBoardSessionsFace {
135
+ /** Queue one follow-up user message into the session of the card's latest execution. */
136
+ followUp(taskId: string, text: string): Promise<void>
137
+ }
138
+
139
+ /** Storage face for one extension's own payload on a task. */
140
+ export interface TaskBoardIntegrationFace {
141
+ /** Read this extension's payload, or undefined when the task carries none. */
142
+ read(taskId: string): TaskBoardExtensionPayload | undefined
143
+ /** Shallow-merge this extension's payload into the task. */
144
+ write(taskId: string, payload: TaskBoardExtensionPayload): void
145
+ }
146
+
147
+ /** Status-change notification. */
148
+ export interface TaskBoardStatusChangedEvent {
149
+ /** Card whose column changed. */
150
+ taskId: string
151
+ /** Column the card moved to. */
152
+ status: TaskStatus
153
+ /** Column the card came from. */
154
+ previous: TaskStatus
155
+ /** Party that initiated the move, when one was recorded. */
156
+ initiator?: string
157
+ }
158
+
159
+ /** Execution-settlement notification. */
160
+ export interface TaskBoardExecutionSettledEvent {
161
+ /** Card whose execution settled. */
162
+ taskId: string
163
+ /** Execution that settled. */
164
+ executionId: string
165
+ /** How it settled. */
166
+ outcome: ExecutionOutcome
167
+ /** Failure text, when the board recorded one. */
168
+ error?: string
169
+ }
170
+
171
+ /** Task-deletion notification. */
172
+ export interface TaskBoardTaskDeletedEvent {
173
+ /** Card that was deleted. */
174
+ taskId: string
175
+ }
176
+
177
+ /** Event subscriptions an extension registers for; every callback runs isolated. */
178
+ export interface TaskBoardEventFace {
179
+ /** Subscribe to column changes. */
180
+ onStatusChanged(callback: (event: TaskBoardStatusChangedEvent) => void): () => void
181
+ /** Subscribe to local execution settlement. */
182
+ onExecutionSettled(callback: (event: TaskBoardExecutionSettledEvent) => void): () => void
183
+ /** Subscribe to card deletion. */
184
+ onTaskDeleted(callback: (event: TaskBoardTaskDeletedEvent) => void): () => void
185
+ }
186
+
187
+ /**
188
+ * What asked for a card to run. The runner consults the launch handlers once,
189
+ * at the single launch entry, before any session exists.
190
+ */
191
+ export type TaskBoardLaunchTrigger = 'manual' | 'rerun' | 'schedule' | 'tool'
192
+
193
+ /** Context a launch handler receives alongside the card. */
194
+ export interface TaskBoardLaunchContext {
195
+ /** Which path started this launch. */
196
+ trigger: TaskBoardLaunchTrigger
197
+ }
198
+
199
+ /**
200
+ * What a launch handler decides for one card.
201
+ *
202
+ * `local` keeps the board's own execution and injects `promptPreamble` ahead of
203
+ * the prompt (proxy mode); `external` creates no session and no execution
204
+ * record, moves the card to the running column, and leaves the outcome to the
205
+ * provider through the existing external-outcome action.
206
+ */
207
+ export type TaskBoardLaunchDecision =
208
+ | { kind: 'local'; promptPreamble?: string }
209
+ | { kind: 'external' }
210
+ | { kind: 'refuse'; code: string; reason: string }
211
+
212
+ /**
213
+ * One launch interception. Synchronous by contract: the runner may not await a
214
+ * network round trip between "the user pressed run" and "a session exists", and
215
+ * a throwing handler is isolated and treated as `undefined`.
216
+ */
217
+ export type TaskBoardLaunchHandler = (
218
+ task: TaskRecord,
219
+ context: TaskBoardLaunchContext,
220
+ ) => TaskBoardLaunchDecision | undefined
221
+
222
+ /** Launch interception surface added to the host face under API version 1. */
223
+ export interface TaskBoardLaunchFace {
224
+ /** Register one handler; the returned disposer removes it. */
225
+ intercept(handler: TaskBoardLaunchHandler): () => void
226
+ }
227
+
228
+ /** Host capability face handed to one extension while it is started. */
229
+ export interface TaskBoardExtensionHost {
230
+ /** Task reads and writes. */
231
+ tasks: TaskBoardTasksFace
232
+ /** Delivery into a card's execution session, when the board serves it. */
233
+ sessions?: TaskBoardSessionsFace
234
+ /** Opaque payload storage for this extension. */
235
+ integration: TaskBoardIntegrationFace
236
+ /** Board notifications. */
237
+ events: TaskBoardEventFace
238
+ /** Launch interception, when the board serves it. */
239
+ launch?: TaskBoardLaunchFace
240
+ /** Publish this extension's read-only summary into the board snapshot. */
241
+ publish(summary: TaskBoardExtensionPayload): void
242
+ /** Register one model-visible tool; the returned disposer unregisters it. */
243
+ registerTool(definition: ToolDefinition): () => void
244
+ }
245
+
246
+ /** One external provider contributed to the task board. */
247
+ export interface TaskBoardExtension {
248
+ /** Stable extension id; also the key of this extension's integration payload. */
249
+ readonly id: string
250
+ /** Contract version this extension was built against. */
251
+ readonly apiVersion: number
252
+ /** Volatile per-extension switch; absent means enabled. Read at use time. */
253
+ enabled?(): boolean
254
+ /** Acquire the capability face and start any provider-side work. */
255
+ start?(host: TaskBoardExtensionHost): void
256
+ /** Release provider-side work. Never clears stored data. */
257
+ stop?(): void
258
+ /** Route one dispatched action; the returned value goes back to the dispatcher. */
259
+ handleAction?(request: TaskBoardExtensionActionRequest): unknown | Promise<unknown>
260
+ /** Model-facing summary of one owned card, merged into `task_board_get` / `task_board_list`. */
261
+ describeTask?(task: TaskRecord): Record<string, unknown> | undefined
262
+ /** Handle of the run taken over for `taskId`, merged into `task_board_run`'s answer. */
263
+ describeRun?(taskId: string): Record<string, unknown> | undefined
264
+ }
265
+
266
+ /** Board mirror an extension's browser half observes. */
267
+ export interface TaskBoardClientMirror {
268
+ /** Whether the board's master switch currently runs the extension faces. */
269
+ enabled: boolean
270
+ /** Tasks the board currently holds. */
271
+ tasks: readonly TaskRecord[]
272
+ /** Published extension summaries, keyed by extension id. */
273
+ extensions: Readonly<Record<string, unknown>>
274
+ /** Whether at least one authoritative Host snapshot has arrived. */
275
+ hydrated?: boolean
276
+ /** Registered local workspaces, for workspace pickers. */
277
+ workspaces?: readonly { workspaceId: string; title: string }[]
278
+ /** Last Host refusal message (e.g. a refused extension action), when any. */
279
+ lastError?: string
280
+ }
281
+
282
+ /** Whether a task should be shown on the board; false hides it. */
283
+ export type TaskBoardVisibilityPredicate = (task: TaskRecord) => boolean
284
+
285
+ /** Generic source bucket a provider assigns to one card. */
286
+ export interface TaskBoardSourceGroup {
287
+ /** Stable, provider-namespaced identity used for ordering and fold persistence. */
288
+ id: string
289
+ /** Full human-readable source label. */
290
+ label: string
291
+ }
292
+
293
+ /** Client capability face the board's browser half provides. */
294
+ export interface TaskBoardClientFace {
295
+ /** Deliver one action through the board's same-origin action channel. */
296
+ dispatch(request: TaskBoardExtensionActionRequest): Promise<boolean>
297
+ /** Register one card visibility predicate; the returned disposer removes it. */
298
+ registerVisibility(predicate: TaskBoardVisibilityPredicate): () => void
299
+ /** Register one source-group selector, when the board serves one. */
300
+ registerGrouping?(selector: (task: TaskRecord) => TaskBoardSourceGroup | undefined): () => void
301
+ /** Subscribe to the board mirror. */
302
+ subscribe(callback: (mirror: TaskBoardClientMirror) => void): () => void
303
+ /** Read the current board mirror. */
304
+ snapshot(): TaskBoardClientMirror
305
+ }
306
+
307
+ /**
308
+ * Host-half service face published under {@link TASK_BOARD_SERVICE_NAME}. This
309
+ * extension's host half resolves it from the shared cordis service and
310
+ * registers its extension; the board's ledger never crosses this boundary.
311
+ */
312
+ export interface TaskBoardHostFace {
313
+ /** Admit one provider extension; the returned disposer releases it. */
314
+ registerExtension(extension: TaskBoardExtension): () => void
315
+ /** Whether the board currently runs a given extension (board x extension). */
316
+ isExtensionEnabled(extensionId: string): boolean
317
+ /** The whole ledger as the board builds it, tasks included. */
318
+ snapshot(): unknown
319
+ }
320
+
321
+ /** Cordis service name the `dsh-ssh` host half publishes the face under. */
322
+ export const DSH_SSH_SERVICE = 'dshSsh'
323
+
324
+ /** Version of the `dsh-ssh` contract; this package restates the number it was built against. */
325
+ export const DSH_SSH_API_VERSION = 1
326
+
327
+ /** Authentication flavors a `dsh-ssh` host entry may carry. */
328
+ export type DshSshAuthKind = 'key' | 'password' | 'agent'
329
+
330
+ /**
331
+ * One host as `dsh-ssh` reports it. The fields are the ones its own host
332
+ * summary already publishes, minus the `proxyCommand` text: a ProxyCommand is a
333
+ * shell line the host process executes with its own privileges, so no consumer
334
+ * receives it. Passwords, key passphrases and private-key paths are absent as
335
+ * well, which is what makes this face safe to read from a card, a log line or a
336
+ * model payload.
337
+ */
338
+ export interface DshSshHost {
339
+ /** Stable, user-chosen identifier every operation addresses. */
340
+ alias: string
341
+ /** Hostname or IP of the target. */
342
+ host: string
343
+ /** SSH port. */
344
+ port: number
345
+ /** Login user. */
346
+ user: string
347
+ /** Authentication flavor the stored entry uses. */
348
+ auth: DshSshAuthKind
349
+ /** Whether the configured private-key file exists on this machine (key auth only). */
350
+ keyReady: boolean
351
+ /** Jump chain: local aliases connected through in order. */
352
+ proxyJump: string[]
353
+ /** Free-form note. */
354
+ description?: string
355
+ /** Deployment environment label. */
356
+ environment?: string
357
+ /** Free-form tags. */
358
+ tags: string[]
359
+ /** Physical location note. */
360
+ location?: string
361
+ /** Whether this host's sessions forward the local ssh-agent. */
362
+ forwardAgent: boolean
363
+ /** Creation timestamp (ms). */
364
+ createdAt: number
365
+ /** Last-change timestamp (ms). */
366
+ updatedAt: number
367
+ }
368
+
369
+ /** Ceiling and cancellation for one remote command. */
370
+ export interface DshSshExecOptions {
371
+ /** Wall-clock ceiling for the remote command; the engine default applies when absent. */
372
+ timeoutMs?: number
373
+ /** Aborting closes the remote channel and settles the call as a cancelled command. */
374
+ signal?: AbortSignal
375
+ }
376
+
377
+ /** One finished remote command. */
378
+ export interface DshSshExecResult {
379
+ /** Whether the command exited zero. */
380
+ success: boolean
381
+ /** Remote exit code, or null when the channel died without one. */
382
+ exitCode: number | null
383
+ /** Whether the ceiling stopped the run. */
384
+ timedOut: boolean
385
+ /** Captured standard output, verbatim. */
386
+ stdout: string
387
+ /** Captured standard error, verbatim. */
388
+ stderr: string
389
+ /** Round trip in milliseconds. */
390
+ durationMs: number
391
+ /** Connection error message when the command never ran. */
392
+ error?: string
393
+ }
394
+
395
+ /** Outcome of one upload. */
396
+ export interface DshSshUploadResult {
397
+ /** Bytes written. */
398
+ bytes: number
399
+ /** Files written (one for a single-file upload). */
400
+ files: number
401
+ }
402
+
403
+ /** Outcome of one download. */
404
+ export interface DshSshDownloadResult {
405
+ /** Bytes written locally. */
406
+ bytes: number
407
+ }
408
+
409
+ /**
410
+ * The face a sibling plugin receives under the `dshSsh` service name: a thin
411
+ * forwarder over one `SshEngine`, so a consumer shares the host store and the
412
+ * connection pool the user already operates. No streaming member exists on
413
+ * purpose: a log that must replay after the local host was offline is a remote
414
+ * file read by byte offset, so polling `exec` with `tail` is the whole
415
+ * transport.
416
+ */
417
+ export interface DshSshService {
418
+ /** Contract version this face implements. */
419
+ readonly apiVersion: typeof DSH_SSH_API_VERSION
420
+ /** The host inventory the plugin's own surfaces read. */
421
+ readonly hosts: {
422
+ /** Every configured host, secret-free, in store order. */
423
+ list(): DshSshHost[]
424
+ /** One host by alias, or undefined when the alias is not configured. */
425
+ find(alias: string): DshSshHost | undefined
426
+ }
427
+ /**
428
+ * Run one command on a host through the shared pool.
429
+ * @param alias - configured host alias.
430
+ * @param command - command line handed to the remote shell.
431
+ * @param options - ceiling and cancellation.
432
+ * @returns the finished command.
433
+ */
434
+ exec(alias: string, command: string, options?: DshSshExecOptions): Promise<DshSshExecResult>
435
+ /**
436
+ * Upload one local file to an absolute remote path.
437
+ * @param alias - configured host alias.
438
+ * @param localPath - file on this machine (a directory is not part of this face).
439
+ * @param remotePath - absolute destination path on the host.
440
+ * @returns bytes and files written.
441
+ */
442
+ upload(alias: string, localPath: string, remotePath: string): Promise<DshSshUploadResult>
443
+ /**
444
+ * Download one remote file to a local path.
445
+ * @param alias - configured host alias.
446
+ * @param remotePath - file on the host.
447
+ * @param localPath - destination path on this machine.
448
+ * @returns bytes written.
449
+ */
450
+ download(alias: string, remotePath: string, localPath: string): Promise<DshSshDownloadResult>
451
+ }
452
+
453
+ /** The narrow context seat every resolver needs: one service read by name. */
454
+ export interface ServiceLookupSeat {
455
+ /** Read one service by name. */
456
+ get(name: string): unknown
457
+ }
458
+
459
+ /**
460
+ * Resolve the browser half's client capability face by service name. Returns
461
+ * undefined when the board is not loaded, so a provider's browser half can
462
+ * degrade instead of throwing.
463
+ * @param ctx - client context.
464
+ * @returns the client face, or undefined.
465
+ */
466
+ export function resolveTaskBoardClientFace(ctx: ServiceLookupSeat): TaskBoardClientFace | undefined {
467
+ try {
468
+ const face = ctx.get(TASK_BOARD_SERVICE_NAME) as TaskBoardClientFace | undefined
469
+ return face !== undefined && typeof (face as { dispatch?: unknown }).dispatch === 'function' ? face : undefined
470
+ } catch {
471
+ return undefined
472
+ }
473
+ }
474
+
475
+ /**
476
+ * Resolve the board's host face by service name.
477
+ *
478
+ * Registration-side consumers call this instead of reading the property a
479
+ * cordis augmentation would declare: the check is the member they actually
480
+ * need, so a board revision without it answers undefined and the caller
481
+ * degrades visibly rather than throwing.
482
+ * @param ctx - host context.
483
+ * @returns the host face, or undefined when the board is not loaded.
484
+ */
485
+ export function resolveTaskBoardHostFace(ctx: ServiceLookupSeat): TaskBoardHostFace | undefined {
486
+ try {
487
+ const face = ctx.get(TASK_BOARD_SERVICE_NAME) as TaskBoardHostFace | undefined
488
+ if (face === undefined) return undefined
489
+ return typeof (face as { registerExtension?: unknown }).registerExtension === 'function' ? face : undefined
490
+ } catch {
491
+ return undefined
492
+ }
493
+ }
494
+
495
+ /**
496
+ * Resolve `dsh-ssh`'s forwarder, refusing a version this extension was not
497
+ * built against instead of guessing at a stale shape.
498
+ * @param ctx - host context.
499
+ * @returns the service, or undefined when absent or at another version.
500
+ */
501
+ export function resolveDshSshService(ctx: ServiceLookupSeat): DshSshService | undefined {
502
+ try {
503
+ const face = ctx.get(DSH_SSH_SERVICE) as DshSshService | undefined
504
+ if (face === undefined) return undefined
505
+ const version = (face as { apiVersion?: unknown }).apiVersion
506
+ if (version !== undefined && version !== DSH_SSH_API_VERSION) return undefined
507
+ return face
508
+ } catch {
509
+ return undefined
510
+ }
511
+ }
512
+
513
+ // No `declare module '@deepseek-ai/cordis'` here: see the module comment. The
514
+ // board owns `Context.taskBoard` and dsh-ssh owns `Context.dshSsh`, and a
515
+ // restatement of either one would be a second, non-identical declaration.