@linxin666/dsh-client-ui-task-board-ssh 0.0.0-stage → 0.4.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +202 -0
- package/README.i18n.yaml +6 -0
- package/README.md +85 -2
- package/README.zh.md +86 -0
- package/cordis.patch.yml +15 -0
- package/icon.svg +5 -0
- package/lib/client.js +4429 -0
- package/lib/index.js +6100 -0
- package/lib/types/client/PluginSettingsCard.d.ts +255 -0
- package/lib/types/client/RangeBubble.d.ts +46 -0
- package/lib/types/client/SegmentGroup.d.ts +28 -0
- package/lib/types/client/index.d.ts +100 -0
- package/lib/types/client/locales.d.ts +125 -0
- package/lib/types/client/seat-props.d.ts +53 -0
- package/lib/types/client/settings-entry-form.d.ts +49 -0
- package/lib/types/client/settings-form.d.ts +237 -0
- package/lib/types/client/ssh/card-decoration.d.ts +23 -0
- package/lib/types/client/ssh/compose-section.d.ts +7 -0
- package/lib/types/client/ssh/detail-section.d.ts +7 -0
- package/lib/types/client/ssh/extension.d.ts +54 -0
- package/lib/types/client/ssh/log-buffer.d.ts +128 -0
- package/lib/types/client/ssh/log-view.d.ts +37 -0
- package/lib/types/client/ssh/model.d.ts +130 -0
- package/lib/types/client/ssh/settings-section.d.ts +134 -0
- package/lib/types/client/ssh/summary.d.ts +160 -0
- package/lib/types/client/ssh/target-form.d.ts +60 -0
- package/lib/types/core/action.d.ts +89 -0
- package/lib/types/core/adapters/claude.d.ts +15 -0
- package/lib/types/core/adapters/codex.d.ts +15 -0
- package/lib/types/core/adapters/custom.d.ts +29 -0
- package/lib/types/core/adapters/dsh.d.ts +21 -0
- package/lib/types/core/adapters/index.d.ts +25 -0
- package/lib/types/core/adapters/types.d.ts +76 -0
- package/lib/types/core/contract.d.ts +445 -0
- package/lib/types/core/launcher-script.d.ts +13 -0
- package/lib/types/core/launcher.d.ts +153 -0
- package/lib/types/core/ledger.d.ts +123 -0
- package/lib/types/core/shell.d.ts +61 -0
- package/lib/types/core/target.d.ts +143 -0
- package/lib/types/core/task-record.d.ts +63 -0
- package/lib/types/core/workspace.d.ts +74 -0
- package/lib/types/host/board.d.ts +71 -0
- package/lib/types/host/engine.d.ts +418 -0
- package/lib/types/host/extension.d.ts +59 -0
- package/lib/types/host/logs.d.ts +135 -0
- package/lib/types/host/payload.d.ts +75 -0
- package/lib/types/host/prompt.d.ts +44 -0
- package/lib/types/host/queue.d.ts +53 -0
- package/lib/types/host/remote.d.ts +120 -0
- package/lib/types/host/settings.d.ts +149 -0
- package/lib/types/host/timers.d.ts +20 -0
- package/lib/types/host/tools.d.ts +15 -0
- package/lib/types/host/workspace/errors.d.ts +29 -0
- package/lib/types/host/workspace/git.d.ts +108 -0
- package/lib/types/host/workspace/in-place.d.ts +36 -0
- package/lib/types/host/workspace/index.d.ts +28 -0
- package/lib/types/host/workspace/layout.d.ts +62 -0
- package/lib/types/host/workspace/local-git.d.ts +72 -0
- package/lib/types/host/workspace/remote-git.d.ts +111 -0
- package/lib/types/host/workspace/remote.d.ts +85 -0
- package/lib/types/host/workspace/types.d.ts +28 -0
- package/lib/types/host/workspace-seam.d.ts +100 -0
- package/lib/types/index.d.ts +97 -0
- package/lib/types/mount-once.d.ts +55 -0
- package/locale/en.json +6 -0
- package/locale/zh.json +6 -0
- package/package.json +89 -3
- package/src/client/PluginSettingsCard.tsx +838 -0
- package/src/client/RangeBubble.tsx +164 -0
- package/src/client/SegmentGroup.tsx +93 -0
- package/src/client/css-modules.d.ts +5 -0
- package/src/client/index.ts +195 -0
- package/src/client/locales.ts +257 -0
- package/src/client/seat-props.ts +58 -0
- package/src/client/settings-card.module.css +821 -0
- package/src/client/settings-entry-form.ts +141 -0
- package/src/client/settings-form.ts +529 -0
- package/src/client/ssh/card-decoration.tsx +55 -0
- package/src/client/ssh/compose-section.tsx +147 -0
- package/src/client/ssh/detail-section.tsx +345 -0
- package/src/client/ssh/extension.ts +271 -0
- package/src/client/ssh/log-buffer.ts +224 -0
- package/src/client/ssh/log-view.tsx +149 -0
- package/src/client/ssh/model.ts +299 -0
- package/src/client/ssh/settings-section.tsx +401 -0
- package/src/client/ssh/summary.ts +388 -0
- package/src/client/ssh/target-form.tsx +380 -0
- package/src/client/ssh.module.css +617 -0
- package/src/core/action.ts +270 -0
- package/src/core/adapters/claude.ts +64 -0
- package/src/core/adapters/codex.ts +83 -0
- package/src/core/adapters/custom.ts +88 -0
- package/src/core/adapters/dsh.ts +87 -0
- package/src/core/adapters/index.ts +74 -0
- package/src/core/adapters/types.ts +95 -0
- package/src/core/contract.ts +510 -0
- package/src/core/launcher-script.ts +313 -0
- package/src/core/launcher.ts +283 -0
- package/src/core/ledger.ts +372 -0
- package/src/core/shell.ts +77 -0
- package/src/core/target.ts +413 -0
- package/src/core/task-record.ts +65 -0
- package/src/core/workspace.ts +78 -0
- package/src/host/board.ts +103 -0
- package/src/host/engine.ts +1602 -0
- package/src/host/extension.ts +304 -0
- package/src/host/logs.ts +297 -0
- package/src/host/payload.ts +134 -0
- package/src/host/prompt.ts +89 -0
- package/src/host/queue.ts +73 -0
- package/src/host/remote.ts +328 -0
- package/src/host/settings.ts +294 -0
- package/src/host/timers.ts +33 -0
- package/src/host/tools.ts +259 -0
- package/src/host/workspace/errors.ts +43 -0
- package/src/host/workspace/git.ts +305 -0
- package/src/host/workspace/in-place.ts +58 -0
- package/src/host/workspace/index.ts +37 -0
- package/src/host/workspace/layout.ts +122 -0
- package/src/host/workspace/local-git.ts +164 -0
- package/src/host/workspace/remote-git.ts +244 -0
- package/src/host/workspace/remote.ts +181 -0
- package/src/host/workspace/types.ts +34 -0
- package/src/host/workspace-seam.ts +132 -0
- package/src/index.ts +243 -0
- 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,510 @@
|
|
|
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
|
+
|
|
211
|
+
/**
|
|
212
|
+
* One launch interception. Synchronous by contract: the runner may not await a
|
|
213
|
+
* network round trip between "the user pressed run" and "a session exists", and
|
|
214
|
+
* a throwing handler is isolated and treated as `undefined`.
|
|
215
|
+
*/
|
|
216
|
+
export type TaskBoardLaunchHandler = (
|
|
217
|
+
task: TaskRecord,
|
|
218
|
+
context: TaskBoardLaunchContext,
|
|
219
|
+
) => TaskBoardLaunchDecision | undefined
|
|
220
|
+
|
|
221
|
+
/** Launch interception surface added to the host face under API version 1. */
|
|
222
|
+
export interface TaskBoardLaunchFace {
|
|
223
|
+
/** Register one handler; the returned disposer removes it. */
|
|
224
|
+
intercept(handler: TaskBoardLaunchHandler): () => void
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
/** Host capability face handed to one extension while it is started. */
|
|
228
|
+
export interface TaskBoardExtensionHost {
|
|
229
|
+
/** Task reads and writes. */
|
|
230
|
+
tasks: TaskBoardTasksFace
|
|
231
|
+
/** Delivery into a card's execution session, when the board serves it. */
|
|
232
|
+
sessions?: TaskBoardSessionsFace
|
|
233
|
+
/** Opaque payload storage for this extension. */
|
|
234
|
+
integration: TaskBoardIntegrationFace
|
|
235
|
+
/** Board notifications. */
|
|
236
|
+
events: TaskBoardEventFace
|
|
237
|
+
/** Launch interception, when the board serves it. */
|
|
238
|
+
launch?: TaskBoardLaunchFace
|
|
239
|
+
/** Publish this extension's read-only summary into the board snapshot. */
|
|
240
|
+
publish(summary: TaskBoardExtensionPayload): void
|
|
241
|
+
/** Register one model-visible tool; the returned disposer unregisters it. */
|
|
242
|
+
registerTool(definition: ToolDefinition): () => void
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
/** One external provider contributed to the task board. */
|
|
246
|
+
export interface TaskBoardExtension {
|
|
247
|
+
/** Stable extension id; also the key of this extension's integration payload. */
|
|
248
|
+
readonly id: string
|
|
249
|
+
/** Contract version this extension was built against. */
|
|
250
|
+
readonly apiVersion: number
|
|
251
|
+
/** Volatile per-extension switch; absent means enabled. Read at use time. */
|
|
252
|
+
enabled?(): boolean
|
|
253
|
+
/** Acquire the capability face and start any provider-side work. */
|
|
254
|
+
start?(host: TaskBoardExtensionHost): void
|
|
255
|
+
/** Release provider-side work. Never clears stored data. */
|
|
256
|
+
stop?(): void
|
|
257
|
+
/** Route one dispatched action; the returned value goes back to the dispatcher. */
|
|
258
|
+
handleAction?(request: TaskBoardExtensionActionRequest): unknown | Promise<unknown>
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
/** Board mirror an extension's browser half observes. */
|
|
262
|
+
export interface TaskBoardClientMirror {
|
|
263
|
+
/** Whether the board's master switch currently runs the extension faces. */
|
|
264
|
+
enabled: boolean
|
|
265
|
+
/** Tasks the board currently holds. */
|
|
266
|
+
tasks: readonly TaskRecord[]
|
|
267
|
+
/** Published extension summaries, keyed by extension id. */
|
|
268
|
+
extensions: Readonly<Record<string, unknown>>
|
|
269
|
+
/** Whether at least one authoritative Host snapshot has arrived. */
|
|
270
|
+
hydrated?: boolean
|
|
271
|
+
/** Registered local workspaces, for workspace pickers. */
|
|
272
|
+
workspaces?: readonly { workspaceId: string; title: string }[]
|
|
273
|
+
/** Last Host refusal message (e.g. a refused extension action), when any. */
|
|
274
|
+
lastError?: string
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
/** Whether a task should be shown on the board; false hides it. */
|
|
278
|
+
export type TaskBoardVisibilityPredicate = (task: TaskRecord) => boolean
|
|
279
|
+
|
|
280
|
+
/** Generic source bucket a provider assigns to one card. */
|
|
281
|
+
export interface TaskBoardSourceGroup {
|
|
282
|
+
/** Stable, provider-namespaced identity used for ordering and fold persistence. */
|
|
283
|
+
id: string
|
|
284
|
+
/** Full human-readable source label. */
|
|
285
|
+
label: string
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
/** Client capability face the board's browser half provides. */
|
|
289
|
+
export interface TaskBoardClientFace {
|
|
290
|
+
/** Deliver one action through the board's same-origin action channel. */
|
|
291
|
+
dispatch(request: TaskBoardExtensionActionRequest): Promise<boolean>
|
|
292
|
+
/** Register one card visibility predicate; the returned disposer removes it. */
|
|
293
|
+
registerVisibility(predicate: TaskBoardVisibilityPredicate): () => void
|
|
294
|
+
/** Register one source-group selector, when the board serves one. */
|
|
295
|
+
registerGrouping?(selector: (task: TaskRecord) => TaskBoardSourceGroup | undefined): () => void
|
|
296
|
+
/** Subscribe to the board mirror. */
|
|
297
|
+
subscribe(callback: (mirror: TaskBoardClientMirror) => void): () => void
|
|
298
|
+
/** Read the current board mirror. */
|
|
299
|
+
snapshot(): TaskBoardClientMirror
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
/**
|
|
303
|
+
* Host-half service face published under {@link TASK_BOARD_SERVICE_NAME}. This
|
|
304
|
+
* extension's host half resolves it from the shared cordis service and
|
|
305
|
+
* registers its extension; the board's ledger never crosses this boundary.
|
|
306
|
+
*/
|
|
307
|
+
export interface TaskBoardHostFace {
|
|
308
|
+
/** Admit one provider extension; the returned disposer releases it. */
|
|
309
|
+
registerExtension(extension: TaskBoardExtension): () => void
|
|
310
|
+
/** Whether the board currently runs a given extension (board x extension). */
|
|
311
|
+
isExtensionEnabled(extensionId: string): boolean
|
|
312
|
+
/** The whole ledger as the board builds it, tasks included. */
|
|
313
|
+
snapshot(): unknown
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
/** Cordis service name the `dsh-ssh` host half publishes the face under. */
|
|
317
|
+
export const DSH_SSH_SERVICE = 'dshSsh'
|
|
318
|
+
|
|
319
|
+
/** Version of the `dsh-ssh` contract; this package restates the number it was built against. */
|
|
320
|
+
export const DSH_SSH_API_VERSION = 1
|
|
321
|
+
|
|
322
|
+
/** Authentication flavors a `dsh-ssh` host entry may carry. */
|
|
323
|
+
export type DshSshAuthKind = 'key' | 'password' | 'agent'
|
|
324
|
+
|
|
325
|
+
/**
|
|
326
|
+
* One host as `dsh-ssh` reports it. The fields are the ones its own host
|
|
327
|
+
* summary already publishes, minus the `proxyCommand` text: a ProxyCommand is a
|
|
328
|
+
* shell line the host process executes with its own privileges, so no consumer
|
|
329
|
+
* receives it. Passwords, key passphrases and private-key paths are absent as
|
|
330
|
+
* well, which is what makes this face safe to read from a card, a log line or a
|
|
331
|
+
* model payload.
|
|
332
|
+
*/
|
|
333
|
+
export interface DshSshHost {
|
|
334
|
+
/** Stable, user-chosen identifier every operation addresses. */
|
|
335
|
+
alias: string
|
|
336
|
+
/** Hostname or IP of the target. */
|
|
337
|
+
host: string
|
|
338
|
+
/** SSH port. */
|
|
339
|
+
port: number
|
|
340
|
+
/** Login user. */
|
|
341
|
+
user: string
|
|
342
|
+
/** Authentication flavor the stored entry uses. */
|
|
343
|
+
auth: DshSshAuthKind
|
|
344
|
+
/** Whether the configured private-key file exists on this machine (key auth only). */
|
|
345
|
+
keyReady: boolean
|
|
346
|
+
/** Jump chain: local aliases connected through in order. */
|
|
347
|
+
proxyJump: string[]
|
|
348
|
+
/** Free-form note. */
|
|
349
|
+
description?: string
|
|
350
|
+
/** Deployment environment label. */
|
|
351
|
+
environment?: string
|
|
352
|
+
/** Free-form tags. */
|
|
353
|
+
tags: string[]
|
|
354
|
+
/** Physical location note. */
|
|
355
|
+
location?: string
|
|
356
|
+
/** Whether this host's sessions forward the local ssh-agent. */
|
|
357
|
+
forwardAgent: boolean
|
|
358
|
+
/** Creation timestamp (ms). */
|
|
359
|
+
createdAt: number
|
|
360
|
+
/** Last-change timestamp (ms). */
|
|
361
|
+
updatedAt: number
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
/** Ceiling and cancellation for one remote command. */
|
|
365
|
+
export interface DshSshExecOptions {
|
|
366
|
+
/** Wall-clock ceiling for the remote command; the engine default applies when absent. */
|
|
367
|
+
timeoutMs?: number
|
|
368
|
+
/** Aborting closes the remote channel and settles the call as a cancelled command. */
|
|
369
|
+
signal?: AbortSignal
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
/** One finished remote command. */
|
|
373
|
+
export interface DshSshExecResult {
|
|
374
|
+
/** Whether the command exited zero. */
|
|
375
|
+
success: boolean
|
|
376
|
+
/** Remote exit code, or null when the channel died without one. */
|
|
377
|
+
exitCode: number | null
|
|
378
|
+
/** Whether the ceiling stopped the run. */
|
|
379
|
+
timedOut: boolean
|
|
380
|
+
/** Captured standard output, verbatim. */
|
|
381
|
+
stdout: string
|
|
382
|
+
/** Captured standard error, verbatim. */
|
|
383
|
+
stderr: string
|
|
384
|
+
/** Round trip in milliseconds. */
|
|
385
|
+
durationMs: number
|
|
386
|
+
/** Connection error message when the command never ran. */
|
|
387
|
+
error?: string
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
/** Outcome of one upload. */
|
|
391
|
+
export interface DshSshUploadResult {
|
|
392
|
+
/** Bytes written. */
|
|
393
|
+
bytes: number
|
|
394
|
+
/** Files written (one for a single-file upload). */
|
|
395
|
+
files: number
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
/** Outcome of one download. */
|
|
399
|
+
export interface DshSshDownloadResult {
|
|
400
|
+
/** Bytes written locally. */
|
|
401
|
+
bytes: number
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
/**
|
|
405
|
+
* The face a sibling plugin receives under the `dshSsh` service name: a thin
|
|
406
|
+
* forwarder over one `SshEngine`, so a consumer shares the host store and the
|
|
407
|
+
* connection pool the user already operates. No streaming member exists on
|
|
408
|
+
* purpose: a log that must replay after the local host was offline is a remote
|
|
409
|
+
* file read by byte offset, so polling `exec` with `tail` is the whole
|
|
410
|
+
* transport.
|
|
411
|
+
*/
|
|
412
|
+
export interface DshSshService {
|
|
413
|
+
/** Contract version this face implements. */
|
|
414
|
+
readonly apiVersion: typeof DSH_SSH_API_VERSION
|
|
415
|
+
/** The host inventory the plugin's own surfaces read. */
|
|
416
|
+
readonly hosts: {
|
|
417
|
+
/** Every configured host, secret-free, in store order. */
|
|
418
|
+
list(): DshSshHost[]
|
|
419
|
+
/** One host by alias, or undefined when the alias is not configured. */
|
|
420
|
+
find(alias: string): DshSshHost | undefined
|
|
421
|
+
}
|
|
422
|
+
/**
|
|
423
|
+
* Run one command on a host through the shared pool.
|
|
424
|
+
* @param alias - configured host alias.
|
|
425
|
+
* @param command - command line handed to the remote shell.
|
|
426
|
+
* @param options - ceiling and cancellation.
|
|
427
|
+
* @returns the finished command.
|
|
428
|
+
*/
|
|
429
|
+
exec(alias: string, command: string, options?: DshSshExecOptions): Promise<DshSshExecResult>
|
|
430
|
+
/**
|
|
431
|
+
* Upload one local file to an absolute remote path.
|
|
432
|
+
* @param alias - configured host alias.
|
|
433
|
+
* @param localPath - file on this machine (a directory is not part of this face).
|
|
434
|
+
* @param remotePath - absolute destination path on the host.
|
|
435
|
+
* @returns bytes and files written.
|
|
436
|
+
*/
|
|
437
|
+
upload(alias: string, localPath: string, remotePath: string): Promise<DshSshUploadResult>
|
|
438
|
+
/**
|
|
439
|
+
* Download one remote file to a local path.
|
|
440
|
+
* @param alias - configured host alias.
|
|
441
|
+
* @param remotePath - file on the host.
|
|
442
|
+
* @param localPath - destination path on this machine.
|
|
443
|
+
* @returns bytes written.
|
|
444
|
+
*/
|
|
445
|
+
download(alias: string, remotePath: string, localPath: string): Promise<DshSshDownloadResult>
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
/** The narrow context seat every resolver needs: one service read by name. */
|
|
449
|
+
export interface ServiceLookupSeat {
|
|
450
|
+
/** Read one service by name. */
|
|
451
|
+
get(name: string): unknown
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
/**
|
|
455
|
+
* Resolve the browser half's client capability face by service name. Returns
|
|
456
|
+
* undefined when the board is not loaded, so a provider's browser half can
|
|
457
|
+
* degrade instead of throwing.
|
|
458
|
+
* @param ctx - client context.
|
|
459
|
+
* @returns the client face, or undefined.
|
|
460
|
+
*/
|
|
461
|
+
export function resolveTaskBoardClientFace(ctx: ServiceLookupSeat): TaskBoardClientFace | undefined {
|
|
462
|
+
try {
|
|
463
|
+
const face = ctx.get(TASK_BOARD_SERVICE_NAME) as TaskBoardClientFace | undefined
|
|
464
|
+
return face !== undefined && typeof (face as { dispatch?: unknown }).dispatch === 'function' ? face : undefined
|
|
465
|
+
} catch {
|
|
466
|
+
return undefined
|
|
467
|
+
}
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
/**
|
|
471
|
+
* Resolve the board's host face by service name.
|
|
472
|
+
*
|
|
473
|
+
* Registration-side consumers call this instead of reading the property a
|
|
474
|
+
* cordis augmentation would declare: the check is the member they actually
|
|
475
|
+
* need, so a board revision without it answers undefined and the caller
|
|
476
|
+
* degrades visibly rather than throwing.
|
|
477
|
+
* @param ctx - host context.
|
|
478
|
+
* @returns the host face, or undefined when the board is not loaded.
|
|
479
|
+
*/
|
|
480
|
+
export function resolveTaskBoardHostFace(ctx: ServiceLookupSeat): TaskBoardHostFace | undefined {
|
|
481
|
+
try {
|
|
482
|
+
const face = ctx.get(TASK_BOARD_SERVICE_NAME) as TaskBoardHostFace | undefined
|
|
483
|
+
if (face === undefined) return undefined
|
|
484
|
+
return typeof (face as { registerExtension?: unknown }).registerExtension === 'function' ? face : undefined
|
|
485
|
+
} catch {
|
|
486
|
+
return undefined
|
|
487
|
+
}
|
|
488
|
+
}
|
|
489
|
+
|
|
490
|
+
/**
|
|
491
|
+
* Resolve `dsh-ssh`'s forwarder, refusing a version this extension was not
|
|
492
|
+
* built against instead of guessing at a stale shape.
|
|
493
|
+
* @param ctx - host context.
|
|
494
|
+
* @returns the service, or undefined when absent or at another version.
|
|
495
|
+
*/
|
|
496
|
+
export function resolveDshSshService(ctx: ServiceLookupSeat): DshSshService | undefined {
|
|
497
|
+
try {
|
|
498
|
+
const face = ctx.get(DSH_SSH_SERVICE) as DshSshService | undefined
|
|
499
|
+
if (face === undefined) return undefined
|
|
500
|
+
const version = (face as { apiVersion?: unknown }).apiVersion
|
|
501
|
+
if (version !== undefined && version !== DSH_SSH_API_VERSION) return undefined
|
|
502
|
+
return face
|
|
503
|
+
} catch {
|
|
504
|
+
return undefined
|
|
505
|
+
}
|
|
506
|
+
}
|
|
507
|
+
|
|
508
|
+
// No `declare module '@deepseek-ai/cordis'` here: see the module comment. The
|
|
509
|
+
// board owns `Context.taskBoard` and dsh-ssh owns `Context.dshSsh`, and a
|
|
510
|
+
// restatement of either one would be a second, non-identical declaration.
|