@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,453 @@
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
+ /** Cordis service name the board's host and browser halves each publish. */
34
+ export declare const TASK_BOARD_SERVICE_NAME = "taskBoard";
35
+ /** Board contract version this extension was built against. */
36
+ export declare const TASK_BOARD_API_VERSION = 1;
37
+ /** Child seat a provider registers its task-detail section into. */
38
+ export declare const TASK_BOARD_DETAIL_SECTION = "task-board.detail.section";
39
+ /** Child seat a provider registers its settings section into. */
40
+ export declare const TASK_BOARD_SETTINGS_SECTION = "task-board.settings.section";
41
+ /** Child seat a provider registers its card decoration into. */
42
+ export declare const TASK_BOARD_CARD_DECORATION = "task-board.card.decoration";
43
+ /**
44
+ * Child seat a provider registers its new-card section into: its own
45
+ * create-time configuration, rendered inside the create dialog's execution
46
+ * settings, whose draft the board stores on the card it creates.
47
+ */
48
+ export declare const TASK_BOARD_COMPOSE_SECTION = "task-board.compose.section";
49
+ /** Largest accepted extension payload, in bytes of its JSON serialization. */
50
+ export declare const TASK_BOARD_PAYLOAD_LIMIT_BYTES: number;
51
+ /** Largest accepted free text a provider pushes into an execution, in characters. */
52
+ export declare const TASK_BOARD_MESSAGE_MAX_LENGTH = 4000;
53
+ /** One opaque provider payload the board stores without interpreting. */
54
+ export type TaskBoardExtensionPayload = Record<string, unknown>;
55
+ /** One action the browser half dispatches over the board's same-origin channel. */
56
+ export interface TaskBoardExtensionActionRequest {
57
+ /** Id of the extension the action belongs to. */
58
+ extensionId: string;
59
+ /** Provider-owned action name, routed back to this extension's handleAction. */
60
+ action: string;
61
+ /** Task the action targets, when it targets one. */
62
+ taskId?: string;
63
+ /** Opaque provider payload, bounded like every other extension payload. */
64
+ payload?: TaskBoardExtensionPayload;
65
+ }
66
+ /** Deliver one extension action through the board's same-origin action channel. */
67
+ export type TaskBoardExtensionDispatch = (request: TaskBoardExtensionActionRequest) => Promise<boolean>;
68
+ /** Draft one provider creates a task from. */
69
+ export interface TaskBoardTaskDraft {
70
+ /** Card title. */
71
+ title: string;
72
+ /** Card description. */
73
+ description: string;
74
+ /** Prompt an execution sends to the agent. */
75
+ prompt: string;
76
+ /** Column the created card opens in; absent means the board default. */
77
+ status?: TaskStatus;
78
+ /** Parent card id, when the provider materializes a subtask. */
79
+ parentId?: string;
80
+ /** Workspace the execution must run in; absent leaves the board's rules in charge. */
81
+ workspaceId?: string;
82
+ /** Agent preset the card pins as its execution composition. */
83
+ mode?: string;
84
+ /** Model the card pins, in `provider/model` form. */
85
+ model?: string;
86
+ /** Reasoning level for the pinned model. */
87
+ reasoningEffort?: string;
88
+ }
89
+ /** Options of {@link TaskBoardTasksFace.create}. */
90
+ export interface TaskBoardCreateOptions {
91
+ /** Opaque payload stored under the creating extension's id. */
92
+ payload?: TaskBoardExtensionPayload;
93
+ /** Create the card off-board: it exists in the ledger but is never shown. */
94
+ hidden?: boolean;
95
+ }
96
+ /** One task linked to an extension, with that extension's own payload. */
97
+ export interface TaskBoardLinkedTask {
98
+ /** The card as the board stores it. */
99
+ task: TaskRecord;
100
+ /** This extension's payload on that card. */
101
+ payload: TaskBoardExtensionPayload;
102
+ }
103
+ /** Task reads and writes the board grants an extension. */
104
+ export interface TaskBoardTasksFace {
105
+ /** Every task in the ledger. */
106
+ list(): readonly TaskRecord[];
107
+ /** One task by id, or undefined. */
108
+ get(taskId: string): TaskRecord | undefined;
109
+ /** Create a task through the board's own creation gate. Throws on refusal. */
110
+ create(draft: TaskBoardTaskDraft, options?: TaskBoardCreateOptions): TaskRecord;
111
+ /** Patch a task's content through the board's content gate. Throws when frozen. */
112
+ patchContent(taskId: string, patch: {
113
+ title?: string;
114
+ description?: string;
115
+ prompt?: string;
116
+ }): void;
117
+ /** Move a task through the board's status gates. Throws on refusal. */
118
+ setStatus(taskId: string, status: TaskStatus, initiator?: string): void;
119
+ /** Every task carrying this extension's payload. */
120
+ linked(): readonly TaskBoardLinkedTask[];
121
+ /** Run an already executed card again in its original session. */
122
+ rework?(taskId: string, instructions: string, initiator?: string): void;
123
+ }
124
+ /** Execution-session face: what a provider delivers INTO a board run. */
125
+ export interface TaskBoardSessionsFace {
126
+ /** Queue one follow-up user message into the session of the card's latest execution. */
127
+ followUp(taskId: string, text: string): Promise<void>;
128
+ }
129
+ /** Storage face for one extension's own payload on a task. */
130
+ export interface TaskBoardIntegrationFace {
131
+ /** Read this extension's payload, or undefined when the task carries none. */
132
+ read(taskId: string): TaskBoardExtensionPayload | undefined;
133
+ /** Shallow-merge this extension's payload into the task. */
134
+ write(taskId: string, payload: TaskBoardExtensionPayload): void;
135
+ }
136
+ /** Status-change notification. */
137
+ export interface TaskBoardStatusChangedEvent {
138
+ /** Card whose column changed. */
139
+ taskId: string;
140
+ /** Column the card moved to. */
141
+ status: TaskStatus;
142
+ /** Column the card came from. */
143
+ previous: TaskStatus;
144
+ /** Party that initiated the move, when one was recorded. */
145
+ initiator?: string;
146
+ }
147
+ /** Execution-settlement notification. */
148
+ export interface TaskBoardExecutionSettledEvent {
149
+ /** Card whose execution settled. */
150
+ taskId: string;
151
+ /** Execution that settled. */
152
+ executionId: string;
153
+ /** How it settled. */
154
+ outcome: ExecutionOutcome;
155
+ /** Failure text, when the board recorded one. */
156
+ error?: string;
157
+ }
158
+ /** Task-deletion notification. */
159
+ export interface TaskBoardTaskDeletedEvent {
160
+ /** Card that was deleted. */
161
+ taskId: string;
162
+ }
163
+ /** Event subscriptions an extension registers for; every callback runs isolated. */
164
+ export interface TaskBoardEventFace {
165
+ /** Subscribe to column changes. */
166
+ onStatusChanged(callback: (event: TaskBoardStatusChangedEvent) => void): () => void;
167
+ /** Subscribe to local execution settlement. */
168
+ onExecutionSettled(callback: (event: TaskBoardExecutionSettledEvent) => void): () => void;
169
+ /** Subscribe to card deletion. */
170
+ onTaskDeleted(callback: (event: TaskBoardTaskDeletedEvent) => void): () => void;
171
+ }
172
+ /**
173
+ * What asked for a card to run. The runner consults the launch handlers once,
174
+ * at the single launch entry, before any session exists.
175
+ */
176
+ export type TaskBoardLaunchTrigger = 'manual' | 'rerun' | 'schedule' | 'tool';
177
+ /** Context a launch handler receives alongside the card. */
178
+ export interface TaskBoardLaunchContext {
179
+ /** Which path started this launch. */
180
+ trigger: TaskBoardLaunchTrigger;
181
+ }
182
+ /**
183
+ * What a launch handler decides for one card.
184
+ *
185
+ * `local` keeps the board's own execution and injects `promptPreamble` ahead of
186
+ * the prompt (proxy mode); `external` creates no session and no execution
187
+ * record, moves the card to the running column, and leaves the outcome to the
188
+ * provider through the existing external-outcome action.
189
+ */
190
+ export type TaskBoardLaunchDecision = {
191
+ kind: 'local';
192
+ promptPreamble?: string;
193
+ } | {
194
+ kind: 'external';
195
+ } | {
196
+ kind: 'refuse';
197
+ code: string;
198
+ reason: string;
199
+ };
200
+ /**
201
+ * One launch interception. Synchronous by contract: the runner may not await a
202
+ * network round trip between "the user pressed run" and "a session exists", and
203
+ * a throwing handler is isolated and treated as `undefined`.
204
+ */
205
+ export type TaskBoardLaunchHandler = (task: TaskRecord, context: TaskBoardLaunchContext) => TaskBoardLaunchDecision | undefined;
206
+ /** Launch interception surface added to the host face under API version 1. */
207
+ export interface TaskBoardLaunchFace {
208
+ /** Register one handler; the returned disposer removes it. */
209
+ intercept(handler: TaskBoardLaunchHandler): () => void;
210
+ }
211
+ /** Host capability face handed to one extension while it is started. */
212
+ export interface TaskBoardExtensionHost {
213
+ /** Task reads and writes. */
214
+ tasks: TaskBoardTasksFace;
215
+ /** Delivery into a card's execution session, when the board serves it. */
216
+ sessions?: TaskBoardSessionsFace;
217
+ /** Opaque payload storage for this extension. */
218
+ integration: TaskBoardIntegrationFace;
219
+ /** Board notifications. */
220
+ events: TaskBoardEventFace;
221
+ /** Launch interception, when the board serves it. */
222
+ launch?: TaskBoardLaunchFace;
223
+ /** Publish this extension's read-only summary into the board snapshot. */
224
+ publish(summary: TaskBoardExtensionPayload): void;
225
+ /** Register one model-visible tool; the returned disposer unregisters it. */
226
+ registerTool(definition: ToolDefinition): () => void;
227
+ }
228
+ /** One external provider contributed to the task board. */
229
+ export interface TaskBoardExtension {
230
+ /** Stable extension id; also the key of this extension's integration payload. */
231
+ readonly id: string;
232
+ /** Contract version this extension was built against. */
233
+ readonly apiVersion: number;
234
+ /** Volatile per-extension switch; absent means enabled. Read at use time. */
235
+ enabled?(): boolean;
236
+ /** Acquire the capability face and start any provider-side work. */
237
+ start?(host: TaskBoardExtensionHost): void;
238
+ /** Release provider-side work. Never clears stored data. */
239
+ stop?(): void;
240
+ /** Route one dispatched action; the returned value goes back to the dispatcher. */
241
+ handleAction?(request: TaskBoardExtensionActionRequest): unknown | Promise<unknown>;
242
+ /** Model-facing summary of one owned card, merged into `task_board_get` / `task_board_list`. */
243
+ describeTask?(task: TaskRecord): Record<string, unknown> | undefined;
244
+ /** Handle of the run taken over for `taskId`, merged into `task_board_run`'s answer. */
245
+ describeRun?(taskId: string): Record<string, unknown> | undefined;
246
+ }
247
+ /** Board mirror an extension's browser half observes. */
248
+ export interface TaskBoardClientMirror {
249
+ /** Whether the board's master switch currently runs the extension faces. */
250
+ enabled: boolean;
251
+ /** Tasks the board currently holds. */
252
+ tasks: readonly TaskRecord[];
253
+ /** Published extension summaries, keyed by extension id. */
254
+ extensions: Readonly<Record<string, unknown>>;
255
+ /** Whether at least one authoritative Host snapshot has arrived. */
256
+ hydrated?: boolean;
257
+ /** Registered local workspaces, for workspace pickers. */
258
+ workspaces?: readonly {
259
+ workspaceId: string;
260
+ title: string;
261
+ }[];
262
+ /** Last Host refusal message (e.g. a refused extension action), when any. */
263
+ lastError?: string;
264
+ }
265
+ /** Whether a task should be shown on the board; false hides it. */
266
+ export type TaskBoardVisibilityPredicate = (task: TaskRecord) => boolean;
267
+ /** Generic source bucket a provider assigns to one card. */
268
+ export interface TaskBoardSourceGroup {
269
+ /** Stable, provider-namespaced identity used for ordering and fold persistence. */
270
+ id: string;
271
+ /** Full human-readable source label. */
272
+ label: string;
273
+ }
274
+ /** Client capability face the board's browser half provides. */
275
+ export interface TaskBoardClientFace {
276
+ /** Deliver one action through the board's same-origin action channel. */
277
+ dispatch(request: TaskBoardExtensionActionRequest): Promise<boolean>;
278
+ /** Register one card visibility predicate; the returned disposer removes it. */
279
+ registerVisibility(predicate: TaskBoardVisibilityPredicate): () => void;
280
+ /** Register one source-group selector, when the board serves one. */
281
+ registerGrouping?(selector: (task: TaskRecord) => TaskBoardSourceGroup | undefined): () => void;
282
+ /** Subscribe to the board mirror. */
283
+ subscribe(callback: (mirror: TaskBoardClientMirror) => void): () => void;
284
+ /** Read the current board mirror. */
285
+ snapshot(): TaskBoardClientMirror;
286
+ }
287
+ /**
288
+ * Host-half service face published under {@link TASK_BOARD_SERVICE_NAME}. This
289
+ * extension's host half resolves it from the shared cordis service and
290
+ * registers its extension; the board's ledger never crosses this boundary.
291
+ */
292
+ export interface TaskBoardHostFace {
293
+ /** Admit one provider extension; the returned disposer releases it. */
294
+ registerExtension(extension: TaskBoardExtension): () => void;
295
+ /** Whether the board currently runs a given extension (board x extension). */
296
+ isExtensionEnabled(extensionId: string): boolean;
297
+ /** The whole ledger as the board builds it, tasks included. */
298
+ snapshot(): unknown;
299
+ }
300
+ /** Cordis service name the `dsh-ssh` host half publishes the face under. */
301
+ export declare const DSH_SSH_SERVICE = "dshSsh";
302
+ /** Version of the `dsh-ssh` contract; this package restates the number it was built against. */
303
+ export declare const DSH_SSH_API_VERSION = 1;
304
+ /** Authentication flavors a `dsh-ssh` host entry may carry. */
305
+ export type DshSshAuthKind = 'key' | 'password' | 'agent';
306
+ /**
307
+ * One host as `dsh-ssh` reports it. The fields are the ones its own host
308
+ * summary already publishes, minus the `proxyCommand` text: a ProxyCommand is a
309
+ * shell line the host process executes with its own privileges, so no consumer
310
+ * receives it. Passwords, key passphrases and private-key paths are absent as
311
+ * well, which is what makes this face safe to read from a card, a log line or a
312
+ * model payload.
313
+ */
314
+ export interface DshSshHost {
315
+ /** Stable, user-chosen identifier every operation addresses. */
316
+ alias: string;
317
+ /** Hostname or IP of the target. */
318
+ host: string;
319
+ /** SSH port. */
320
+ port: number;
321
+ /** Login user. */
322
+ user: string;
323
+ /** Authentication flavor the stored entry uses. */
324
+ auth: DshSshAuthKind;
325
+ /** Whether the configured private-key file exists on this machine (key auth only). */
326
+ keyReady: boolean;
327
+ /** Jump chain: local aliases connected through in order. */
328
+ proxyJump: string[];
329
+ /** Free-form note. */
330
+ description?: string;
331
+ /** Deployment environment label. */
332
+ environment?: string;
333
+ /** Free-form tags. */
334
+ tags: string[];
335
+ /** Physical location note. */
336
+ location?: string;
337
+ /** Whether this host's sessions forward the local ssh-agent. */
338
+ forwardAgent: boolean;
339
+ /** Creation timestamp (ms). */
340
+ createdAt: number;
341
+ /** Last-change timestamp (ms). */
342
+ updatedAt: number;
343
+ }
344
+ /** Ceiling and cancellation for one remote command. */
345
+ export interface DshSshExecOptions {
346
+ /** Wall-clock ceiling for the remote command; the engine default applies when absent. */
347
+ timeoutMs?: number;
348
+ /** Aborting closes the remote channel and settles the call as a cancelled command. */
349
+ signal?: AbortSignal;
350
+ }
351
+ /** One finished remote command. */
352
+ export interface DshSshExecResult {
353
+ /** Whether the command exited zero. */
354
+ success: boolean;
355
+ /** Remote exit code, or null when the channel died without one. */
356
+ exitCode: number | null;
357
+ /** Whether the ceiling stopped the run. */
358
+ timedOut: boolean;
359
+ /** Captured standard output, verbatim. */
360
+ stdout: string;
361
+ /** Captured standard error, verbatim. */
362
+ stderr: string;
363
+ /** Round trip in milliseconds. */
364
+ durationMs: number;
365
+ /** Connection error message when the command never ran. */
366
+ error?: string;
367
+ }
368
+ /** Outcome of one upload. */
369
+ export interface DshSshUploadResult {
370
+ /** Bytes written. */
371
+ bytes: number;
372
+ /** Files written (one for a single-file upload). */
373
+ files: number;
374
+ }
375
+ /** Outcome of one download. */
376
+ export interface DshSshDownloadResult {
377
+ /** Bytes written locally. */
378
+ bytes: number;
379
+ }
380
+ /**
381
+ * The face a sibling plugin receives under the `dshSsh` service name: a thin
382
+ * forwarder over one `SshEngine`, so a consumer shares the host store and the
383
+ * connection pool the user already operates. No streaming member exists on
384
+ * purpose: a log that must replay after the local host was offline is a remote
385
+ * file read by byte offset, so polling `exec` with `tail` is the whole
386
+ * transport.
387
+ */
388
+ export interface DshSshService {
389
+ /** Contract version this face implements. */
390
+ readonly apiVersion: typeof DSH_SSH_API_VERSION;
391
+ /** The host inventory the plugin's own surfaces read. */
392
+ readonly hosts: {
393
+ /** Every configured host, secret-free, in store order. */
394
+ list(): DshSshHost[];
395
+ /** One host by alias, or undefined when the alias is not configured. */
396
+ find(alias: string): DshSshHost | undefined;
397
+ };
398
+ /**
399
+ * Run one command on a host through the shared pool.
400
+ * @param alias - configured host alias.
401
+ * @param command - command line handed to the remote shell.
402
+ * @param options - ceiling and cancellation.
403
+ * @returns the finished command.
404
+ */
405
+ exec(alias: string, command: string, options?: DshSshExecOptions): Promise<DshSshExecResult>;
406
+ /**
407
+ * Upload one local file to an absolute remote path.
408
+ * @param alias - configured host alias.
409
+ * @param localPath - file on this machine (a directory is not part of this face).
410
+ * @param remotePath - absolute destination path on the host.
411
+ * @returns bytes and files written.
412
+ */
413
+ upload(alias: string, localPath: string, remotePath: string): Promise<DshSshUploadResult>;
414
+ /**
415
+ * Download one remote file to a local path.
416
+ * @param alias - configured host alias.
417
+ * @param remotePath - file on the host.
418
+ * @param localPath - destination path on this machine.
419
+ * @returns bytes written.
420
+ */
421
+ download(alias: string, remotePath: string, localPath: string): Promise<DshSshDownloadResult>;
422
+ }
423
+ /** The narrow context seat every resolver needs: one service read by name. */
424
+ export interface ServiceLookupSeat {
425
+ /** Read one service by name. */
426
+ get(name: string): unknown;
427
+ }
428
+ /**
429
+ * Resolve the browser half's client capability face by service name. Returns
430
+ * undefined when the board is not loaded, so a provider's browser half can
431
+ * degrade instead of throwing.
432
+ * @param ctx - client context.
433
+ * @returns the client face, or undefined.
434
+ */
435
+ export declare function resolveTaskBoardClientFace(ctx: ServiceLookupSeat): TaskBoardClientFace | undefined;
436
+ /**
437
+ * Resolve the board's host face by service name.
438
+ *
439
+ * Registration-side consumers call this instead of reading the property a
440
+ * cordis augmentation would declare: the check is the member they actually
441
+ * need, so a board revision without it answers undefined and the caller
442
+ * degrades visibly rather than throwing.
443
+ * @param ctx - host context.
444
+ * @returns the host face, or undefined when the board is not loaded.
445
+ */
446
+ export declare function resolveTaskBoardHostFace(ctx: ServiceLookupSeat): TaskBoardHostFace | undefined;
447
+ /**
448
+ * Resolve `dsh-ssh`'s forwarder, refusing a version this extension was not
449
+ * built against instead of guessing at a stale shape.
450
+ * @param ctx - host context.
451
+ * @returns the service, or undefined when absent or at another version.
452
+ */
453
+ export declare function resolveDshSshService(ctx: ServiceLookupSeat): DshSshService | undefined;
@@ -0,0 +1,13 @@
1
+ /**
2
+ * The remote launcher, as text.
3
+ *
4
+ * One POSIX `sh` script, installed once per dsh-ssh host and re-entered for
5
+ * every verb; the state directory it works in is derived at run time, so this
6
+ * text carries no per-host value. It is a line array rather than a template
7
+ * literal so the shell quoting below stays literal: nothing in this file is
8
+ * interpolated by the bundler.
9
+ *
10
+ * @module dsh-task-board-ssh/core/launcher-script
11
+ */
12
+ /** Remote launcher source; the POSIX `sh` program the provider installs. */
13
+ export declare const LAUNCHER_SCRIPT: string;
@@ -0,0 +1,153 @@
1
+ /**
2
+ * The launcher's command construction and its output grammar.
3
+ *
4
+ * The remote side is one POSIX `sh` script ({@link LAUNCHER_SCRIPT}) installed
5
+ * once per host. This module builds every command the provider sends it, writes
6
+ * a run's files, and reads the one status line each verb answers, so nothing on
7
+ * this side concatenates a path or a run id into a command by hand.
8
+ *
9
+ * @module dsh-task-board-ssh/core/launcher
10
+ */
11
+ import type { SshAgentCommand } from './adapters/types.ts';
12
+ /** Verbs the installed script accepts. */
13
+ export declare const LAUNCHER_VERBS: readonly ["start", "status", "tail", "stderr", "cancel"];
14
+ /** One launcher verb. */
15
+ export type LauncherVerb = (typeof LAUNCHER_VERBS)[number];
16
+ /**
17
+ * State directory the provider owns on a host, relative to the remote `$HOME`.
18
+ * The provider resolves the absolute path once per host and passes it in, so no
19
+ * command depends on the remote shell expanding a tilde.
20
+ */
21
+ export declare const REMOTE_STATE_SUFFIX = ".dsh/task-board-ssh";
22
+ /** Every file a run directory holds, in the order the provider writes them. */
23
+ export declare const RUN_FILE_NAMES: readonly ["spec.json", "prompt.txt", "cmd.sh", "cwd", "stdout.log", "stderr.log", "pid", "exit", "session", "cancelled"];
24
+ /** One file inside a run directory. */
25
+ export type RunFileName = (typeof RUN_FILE_NAMES)[number];
26
+ /**
27
+ * Resolve the absolute state directory for a host's home directory.
28
+ * @param home - absolute remote home directory.
29
+ * @returns the state directory the provider installs the launcher under.
30
+ */
31
+ export declare function stateDirForHome(home: string): string;
32
+ /**
33
+ * Short content digest of a launcher script, used in its file name.
34
+ *
35
+ * A digest rather than a version number: an installed script is replaced
36
+ * exactly when its text changes, so a host that already runs the current one is
37
+ * left alone. FNV-1a over UTF-16 code units is enough for a file name and keeps
38
+ * this module free of a platform crypto dependency.
39
+ * @param script - launcher source; defaults to the shipped script.
40
+ * @returns eight lower-case hex digits.
41
+ */
42
+ export declare function launcherScriptHash(script?: string): string;
43
+ /**
44
+ * Absolute remote path of the installed launcher.
45
+ * @param stateDir - absolute state directory.
46
+ * @param hash - script digest; defaults to the shipped script's.
47
+ * @returns `<stateDir>/runner-<hash>.sh`.
48
+ */
49
+ export declare function launcherScriptPath(stateDir: string, hash?: string): string;
50
+ /**
51
+ * Refuse a run id the remote script would refuse.
52
+ * @param runId - candidate id.
53
+ * @returns whether it matches the script's grammar.
54
+ */
55
+ export declare function isRunId(runId: string): boolean;
56
+ /**
57
+ * Absolute remote directory of one run.
58
+ * @param stateDir - absolute state directory.
59
+ * @param runId - run identifier.
60
+ * @returns `<stateDir>/runs/<runId>`.
61
+ */
62
+ export declare function runDirectory(stateDir: string, runId: string): string;
63
+ /**
64
+ * Absolute remote path of one run file.
65
+ * @param stateDir - absolute state directory.
66
+ * @param runId - run identifier.
67
+ * @param name - which file.
68
+ * @returns its absolute path.
69
+ */
70
+ export declare function runFilePath(stateDir: string, runId: string, name: RunFileName): string;
71
+ /**
72
+ * Build the command that installs (or refreshes) the launcher on a host.
73
+ *
74
+ * The write lands on a staging file that is then renamed over the launcher, so
75
+ * the command is safe to replay while the host is using the script: `mv` within
76
+ * one directory is a rename(2), so a wrapper already executing the previous
77
+ * file keeps reading the bytes it opened. Writing the launcher path directly
78
+ * would truncate the script a live `__exec` wrapper is still reading, and a
79
+ * POSIX sh that reaches that truncation ends the run without writing its exit
80
+ * code.
81
+ * @param stateDir - absolute state directory.
82
+ * @param script - launcher source; defaults to the shipped script.
83
+ * @returns one shell command that is safe to replay.
84
+ */
85
+ export declare function buildLauncherInstallCommand(stateDir: string, script?: string): string;
86
+ /**
87
+ * Build the command that invokes one verb.
88
+ * @param input - state directory, verb, run id and optional byte bounds.
89
+ * @returns one shell command.
90
+ */
91
+ export declare function buildLauncherCommand(input: {
92
+ /** Absolute state directory. */
93
+ stateDir: string;
94
+ /** Verb to invoke. */
95
+ verb: LauncherVerb;
96
+ /** Run the verb addresses. */
97
+ runId: string;
98
+ /** Byte offset for `tail`; ignored by every other verb. */
99
+ offset?: number;
100
+ /** Maximum byte count for `tail` or `stderr`; omitted reads to EOF / default. */
101
+ limit?: number;
102
+ }): string;
103
+ /** The command body a run executes, as `cmd.sh` holds it. */
104
+ export declare function agentScript(command: SshAgentCommand): string;
105
+ /**
106
+ * Build the commands that write one run's files before `start`.
107
+ *
108
+ * The provider writes the run directory, the prompt, the agent command, the
109
+ * working directory and the spec; the launcher writes only the files it owns
110
+ * (logs, pid, exit, cancelled), so neither side overwrites the other's state.
111
+ * @param input - state directory, run id and the run's content.
112
+ * @returns one shell command per write, in order.
113
+ */
114
+ export declare function buildRunFileCommands(input: {
115
+ /** Absolute state directory. */
116
+ stateDir: string;
117
+ /** Run identifier. */
118
+ runId: string;
119
+ /** Prompt text the agent reads. */
120
+ prompt: string;
121
+ /** Command line the run executes. */
122
+ command: SshAgentCommand;
123
+ /** Absolute remote directory the run works in. */
124
+ cwd: string;
125
+ /** Opaque spec the provider keeps for its own reconciliation. */
126
+ spec: unknown;
127
+ }): string[];
128
+ /** State one verb reported. */
129
+ export type LauncherRunState = 'running' | 'exited' | 'cancelled' | 'lost' | 'missing' | 'not-running' | 'unknown';
130
+ /** One parsed status line. */
131
+ export interface LauncherStatus {
132
+ /** State the launcher reported. */
133
+ state: LauncherRunState;
134
+ /** Process group id the run owns, while it is running. */
135
+ pid?: number;
136
+ /** Exit code the run recorded, once it settled. */
137
+ exitCode?: number;
138
+ /** Bytes of `stdout.log` the launcher has seen. */
139
+ bytes?: number;
140
+ /** Whether `start` spawned the agent on this call. */
141
+ started?: boolean;
142
+ }
143
+ /**
144
+ * Read a verb's status line.
145
+ *
146
+ * The grammar is `key=value` pairs separated by spaces, one line. Anything
147
+ * else parses as `unknown` with the raw text preserved, because a shell that
148
+ * printed something unexpected is a fact the caller should record, not an
149
+ * exception.
150
+ * @param output - captured stdout of a `status` or `start` invocation.
151
+ * @returns the parsed state.
152
+ */
153
+ export declare function parseLauncherStatus(output: string): LauncherStatus;