@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,75 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The host half's reading of the payload it stores on a card.
|
|
3
|
+
*
|
|
4
|
+
* The schema itself belongs to `src/core/ledger.ts` — the target pin, the active
|
|
5
|
+
* run, the bounded history and the one instruction a future run still owes — and
|
|
6
|
+
* the host half adds no member of its own to it. What this module owns is the
|
|
7
|
+
* write: it stamps the document, keeps it under the board's 64 KiB ceiling and
|
|
8
|
+
* makes every member it clears explicit, because the board merges a written
|
|
9
|
+
* payload into the stored one key by key.
|
|
10
|
+
*
|
|
11
|
+
* @module dsh-task-board-ssh/host/payload
|
|
12
|
+
*/
|
|
13
|
+
import { SSH_INTEGRATION_KEY, type SshLedgerPayload } from '../core/ledger.ts';
|
|
14
|
+
import { type SshRunRecord } from '../core/target.ts';
|
|
15
|
+
export { SSH_INTEGRATION_KEY };
|
|
16
|
+
export type { SshPendingInstruction } from '../core/ledger.ts';
|
|
17
|
+
/** How many settled runs one card keeps here, oldest dropped first. */
|
|
18
|
+
export declare const HOST_HISTORY_LIMIT = 20;
|
|
19
|
+
/** One card's payload: exactly the frozen document, with nothing added beside it. */
|
|
20
|
+
export type HostSshPayload = Omit<SshLedgerPayload, 'version'>;
|
|
21
|
+
/**
|
|
22
|
+
* Parse one stored payload into what the host half works with.
|
|
23
|
+
* @param raw - the card's `integrations.ssh` value, or undefined when it carries none.
|
|
24
|
+
* @returns the payload, or undefined when the card carries none this build understands.
|
|
25
|
+
*/
|
|
26
|
+
export declare function readHostPayload(raw: unknown): HostSshPayload | undefined;
|
|
27
|
+
/**
|
|
28
|
+
* Serialize one payload for storage, keeping it strictly under the board's ceiling.
|
|
29
|
+
*
|
|
30
|
+
* The frozen trimmer does the budgeting, including the room it reserves for a
|
|
31
|
+
* queued instruction, so the store may drop the oldest history and never the
|
|
32
|
+
* message a person is waiting on.
|
|
33
|
+
* @param next - the payload to store.
|
|
34
|
+
* @param now - clock instant written into the document (ms epoch).
|
|
35
|
+
* @returns the board-ready extension payload.
|
|
36
|
+
*/
|
|
37
|
+
export declare function writeHostPayload(next: HostSshPayload, now: number): Record<string, unknown>;
|
|
38
|
+
/**
|
|
39
|
+
* The same payload carrying one run as the run in flight.
|
|
40
|
+
* @param payload - the current payload.
|
|
41
|
+
* @param run - the run to carry.
|
|
42
|
+
* @returns the next payload.
|
|
43
|
+
*/
|
|
44
|
+
export declare function withActiveRun(payload: HostSshPayload, run: SshRunRecord): HostSshPayload;
|
|
45
|
+
/**
|
|
46
|
+
* The same payload with one run settled into the bounded history.
|
|
47
|
+
* @param payload - the current payload.
|
|
48
|
+
* @param run - the settled run.
|
|
49
|
+
* @returns the next payload, the active run cleared.
|
|
50
|
+
*/
|
|
51
|
+
export declare function withSettledRun(payload: HostSshPayload, run: SshRunRecord): HostSshPayload;
|
|
52
|
+
/**
|
|
53
|
+
* One run of a card's payload by id.
|
|
54
|
+
*
|
|
55
|
+
* A run stays addressable after it settles — the detail view names a historical
|
|
56
|
+
* run to replay its log — so the search covers the run in flight and the whole
|
|
57
|
+
* bounded history.
|
|
58
|
+
* @param payload - the payload to read.
|
|
59
|
+
* @param runId - run to find.
|
|
60
|
+
* @returns the run, or undefined when this card never had it.
|
|
61
|
+
*/
|
|
62
|
+
export declare function findRun(payload: HostSshPayload | undefined, runId: string): SshRunRecord | undefined;
|
|
63
|
+
/**
|
|
64
|
+
* The most recent session this card's runs recorded, which is the one a
|
|
65
|
+
* follow-up would continue.
|
|
66
|
+
* @param payload - the payload to read.
|
|
67
|
+
* @returns the session id, or undefined when no run of this card reported one.
|
|
68
|
+
*/
|
|
69
|
+
export declare function latestSessionId(payload: HostSshPayload): string | undefined;
|
|
70
|
+
/**
|
|
71
|
+
* The run a card is waiting on, when it is still in a phase that schedules work.
|
|
72
|
+
* @param payload - the payload to read.
|
|
73
|
+
* @returns the live run, or undefined when the card waits on nothing.
|
|
74
|
+
*/
|
|
75
|
+
export declare function liveRunOf(payload: HostSshPayload): SshRunRecord | undefined;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The text one run's prompt carries: the proxy preamble a local session starts
|
|
3
|
+
* with, and the instruction a resumed (or degraded) run reads.
|
|
4
|
+
*
|
|
5
|
+
* These are model-facing strings, so they live here rather than in a locale
|
|
6
|
+
* dictionary, exactly as the board's own tool descriptions do. Nothing in them
|
|
7
|
+
* is rendered to a person.
|
|
8
|
+
*
|
|
9
|
+
* @module dsh-task-board-ssh/host/prompt
|
|
10
|
+
*/
|
|
11
|
+
import type { TaskRecord } from '../core/task-record.ts';
|
|
12
|
+
import type { SshTarget } from '../core/target.ts';
|
|
13
|
+
import type { SshPendingInstruction } from './payload.ts';
|
|
14
|
+
/** The tool family a proxy run has to drive the host with. */
|
|
15
|
+
export declare const SSH_TOOL_FAMILY = "ssh_list, ssh_exec, ssh_upload and ssh_download";
|
|
16
|
+
/** Prefix a recorded summary carries when the instruction started a fresh run. */
|
|
17
|
+
export declare const SSH_DEGRADED_SUMMARY_MARKER = "[fresh run: this agent cannot resume, so the previous summary was carried in the prompt]";
|
|
18
|
+
/**
|
|
19
|
+
* Build the preamble a proxy card's local session opens with.
|
|
20
|
+
*
|
|
21
|
+
* The board injects it ahead of the card body on the same path it injects tag
|
|
22
|
+
* prefixes, so the session reads what this run IS before it reads the task: the
|
|
23
|
+
* work happens on a pinned host through the `ssh_*` tools, and nothing about the
|
|
24
|
+
* card is local.
|
|
25
|
+
* @param task - the card about to run.
|
|
26
|
+
* @param target - the target the card pins.
|
|
27
|
+
* @returns the preamble text.
|
|
28
|
+
*/
|
|
29
|
+
export declare function proxyPreamble(task: TaskRecord, target: SshTarget): string;
|
|
30
|
+
/**
|
|
31
|
+
* Build the prompt one run reads.
|
|
32
|
+
*
|
|
33
|
+
* A start reads the card's own prompt. A follow-up or a rework that continues the
|
|
34
|
+
* agent's session reads the instruction alone, because the session already holds
|
|
35
|
+
* the work. A degraded follow-up — the agent cannot be resumed — reads what the
|
|
36
|
+
* previous run reported before it reads the instruction, which is the whole
|
|
37
|
+
* reason that path exists.
|
|
38
|
+
* @param task - the card being run.
|
|
39
|
+
* @param pending - the instruction this run carries, when it carries one.
|
|
40
|
+
* @param previousSummary - what the previous run reported, when it is known.
|
|
41
|
+
* @param resumed - whether the run continues the agent's session.
|
|
42
|
+
* @returns the text written to the run's prompt file.
|
|
43
|
+
*/
|
|
44
|
+
export declare function runPrompt(task: TaskRecord, pending: SshPendingInstruction | undefined, previousSummary: string | undefined, resumed: boolean): string;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Per-host admission: the concurrency ceiling and the first-in-first-out queue.
|
|
3
|
+
*
|
|
4
|
+
* The queue is not stored anywhere of its own — it is the ordered set of cards
|
|
5
|
+
* whose payload carries a queued run, which is what makes it survive a restart
|
|
6
|
+
* for free: the same cards, read in the same order, produce the same queue.
|
|
7
|
+
* Order is the instant each run was requested, with the run id as the tie-break
|
|
8
|
+
* so two runs requested in the same millisecond still have one order.
|
|
9
|
+
*
|
|
10
|
+
* @module dsh-task-board-ssh/host/queue
|
|
11
|
+
*/
|
|
12
|
+
/** One run waiting for a slot on its host. */
|
|
13
|
+
export interface SshQueueEntry {
|
|
14
|
+
/** Card waiting for the slot. */
|
|
15
|
+
taskId: string;
|
|
16
|
+
/** Run the card waits on. */
|
|
17
|
+
runId: string;
|
|
18
|
+
/** Instant the run was requested (ms epoch). */
|
|
19
|
+
startedAt: number;
|
|
20
|
+
}
|
|
21
|
+
/** What one admission pass decided. */
|
|
22
|
+
export interface SshAdmission {
|
|
23
|
+
/** Runs that may start now, in queue order. */
|
|
24
|
+
start: SshQueueEntry[];
|
|
25
|
+
/** Runs left waiting, in the order they will be reached. */
|
|
26
|
+
waiting: SshQueueEntry[];
|
|
27
|
+
}
|
|
28
|
+
/** Default ceiling of concurrent runs on one host. */
|
|
29
|
+
export declare const DEFAULT_PER_HOST_CAP = 2;
|
|
30
|
+
/** Lowest accepted ceiling; one run at a time is the smallest queue worth naming. */
|
|
31
|
+
export declare const PER_HOST_CAP_MIN = 1;
|
|
32
|
+
/** Highest accepted ceiling per host. */
|
|
33
|
+
export declare const PER_HOST_CAP_MAX = 16;
|
|
34
|
+
/**
|
|
35
|
+
* Clamp a configured ceiling into the accepted range.
|
|
36
|
+
* @param value - configured value; anything unusable falls back to the default.
|
|
37
|
+
* @returns an integer between {@link PER_HOST_CAP_MIN} and {@link PER_HOST_CAP_MAX}.
|
|
38
|
+
*/
|
|
39
|
+
export declare function normalizePerHostCap(value: unknown): number;
|
|
40
|
+
/**
|
|
41
|
+
* Order a host's queue the way it will be served.
|
|
42
|
+
* @param entries - every queued run of one host.
|
|
43
|
+
* @returns the same entries, oldest first.
|
|
44
|
+
*/
|
|
45
|
+
export declare function orderQueue(entries: readonly SshQueueEntry[]): SshQueueEntry[];
|
|
46
|
+
/**
|
|
47
|
+
* Decide which queued runs may start now.
|
|
48
|
+
* @param entries - every queued run of one host, in any order.
|
|
49
|
+
* @param running - how many runs of that host already hold a slot.
|
|
50
|
+
* @param cap - the host's ceiling.
|
|
51
|
+
* @returns the runs to start now and the ones still waiting.
|
|
52
|
+
*/
|
|
53
|
+
export declare function admitRuns(entries: readonly SshQueueEntry[], running: number, cap: number): SshAdmission;
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import type { DshSshService } from '../core/contract.ts';
|
|
2
|
+
import type { SshAgentCommand } from '../core/adapters/types.ts';
|
|
3
|
+
import { type LauncherStatus } from '../core/launcher.ts';
|
|
4
|
+
/** Ceiling for one remote command, in milliseconds. */
|
|
5
|
+
export declare const DEFAULT_COMMAND_TIMEOUT_MS = 30000;
|
|
6
|
+
/** What one remote call addresses. */
|
|
7
|
+
export interface SshRemoteRef {
|
|
8
|
+
/** `dshSsh` host alias. */
|
|
9
|
+
alias: string;
|
|
10
|
+
/** Absolute remote state directory the provider owns on that host. */
|
|
11
|
+
stateDir: string;
|
|
12
|
+
/** Run the call addresses. */
|
|
13
|
+
runId: string;
|
|
14
|
+
}
|
|
15
|
+
/** The files one run's start writes before the launcher runs it. */
|
|
16
|
+
export interface SshRemoteRunFiles {
|
|
17
|
+
/** Prompt text the agent reads. */
|
|
18
|
+
prompt: string;
|
|
19
|
+
/** Quoted command line the launcher executes. */
|
|
20
|
+
command: SshAgentCommand;
|
|
21
|
+
/** Absolute remote directory the run works in. */
|
|
22
|
+
cwd: string;
|
|
23
|
+
/** Opaque spec the provider keeps for its own reconciliation. */
|
|
24
|
+
spec: unknown;
|
|
25
|
+
}
|
|
26
|
+
/** A remote command that could not be completed, in the host's own words. */
|
|
27
|
+
export declare class SshRemoteError extends Error {
|
|
28
|
+
/** Host the command addressed. */
|
|
29
|
+
readonly alias: string;
|
|
30
|
+
/** What the command was for. */
|
|
31
|
+
readonly what: string;
|
|
32
|
+
constructor(alias: string, what: string, message: string);
|
|
33
|
+
}
|
|
34
|
+
/** One page of a run's log, as the read verb returned it. */
|
|
35
|
+
export interface SshTailPage {
|
|
36
|
+
/** Bytes the remote log held from the requested offset to its end, as text. */
|
|
37
|
+
text: string;
|
|
38
|
+
/** Byte offset the next read starts at. */
|
|
39
|
+
bytes: number;
|
|
40
|
+
}
|
|
41
|
+
/** Options of {@link SshRemote}. */
|
|
42
|
+
export interface SshRemoteOptions {
|
|
43
|
+
/** Ceiling for one remote command, in milliseconds. */
|
|
44
|
+
timeoutMs?: number;
|
|
45
|
+
}
|
|
46
|
+
export declare class SshRemote {
|
|
47
|
+
private readonly ssh;
|
|
48
|
+
private readonly timeoutMs;
|
|
49
|
+
private readonly stateDirs;
|
|
50
|
+
private readonly starting;
|
|
51
|
+
private readonly installing;
|
|
52
|
+
constructor(ssh: DshSshService, options?: SshRemoteOptions);
|
|
53
|
+
/** Forget every cached path of one host, or of all hosts when none is named. */
|
|
54
|
+
forget(alias?: string): void;
|
|
55
|
+
/**
|
|
56
|
+
* Resolve (and cache) the absolute state directory of one host.
|
|
57
|
+
* @param alias - host alias.
|
|
58
|
+
* @returns the directory the provider installs the launcher and its runs under.
|
|
59
|
+
*/
|
|
60
|
+
stateDir(alias: string): Promise<string>;
|
|
61
|
+
/**
|
|
62
|
+
* Install (or refresh) the launcher script on one host, deduplicating
|
|
63
|
+
* concurrent installs on the same host and state directory.
|
|
64
|
+
* @param ref - host and state directory.
|
|
65
|
+
*/
|
|
66
|
+
installLauncher(ref: {
|
|
67
|
+
alias: string;
|
|
68
|
+
stateDir: string;
|
|
69
|
+
}): Promise<void>;
|
|
70
|
+
/**
|
|
71
|
+
* Write every file one run needs before `start`.
|
|
72
|
+
*
|
|
73
|
+
* Large prompts are uploaded through SFTP instead of inlined into a single
|
|
74
|
+
* shell command line so multi-megabyte prompts never trip Linux `E2BIG`.
|
|
75
|
+
* @param ref - host, state directory and run.
|
|
76
|
+
* @param files - prompt, command line, working directory and spec.
|
|
77
|
+
*/
|
|
78
|
+
writeRunFiles(ref: SshRemoteRef, files: SshRemoteRunFiles): Promise<void>;
|
|
79
|
+
/**
|
|
80
|
+
* Ask the launcher to start one run, joining a start already in flight.
|
|
81
|
+
* @param ref - host, state directory and run.
|
|
82
|
+
* @returns the state line the launcher printed.
|
|
83
|
+
*/
|
|
84
|
+
start(ref: SshRemoteRef): Promise<LauncherStatus>;
|
|
85
|
+
/**
|
|
86
|
+
* Read one run's state.
|
|
87
|
+
* @param ref - host, state directory and run.
|
|
88
|
+
* @returns the state line the launcher printed.
|
|
89
|
+
*/
|
|
90
|
+
status(ref: SshRemoteRef): Promise<LauncherStatus>;
|
|
91
|
+
/**
|
|
92
|
+
* Read a run's log from a byte offset, optionally capped to `limit` bytes.
|
|
93
|
+
* @param ref - host, state directory and run.
|
|
94
|
+
* @param offset - first byte to return.
|
|
95
|
+
* @param limit - optional maximum byte count to return (prevents hitting dsh-ssh's 2 MiB output cap).
|
|
96
|
+
* @returns the text and the offset the next read starts at.
|
|
97
|
+
*/
|
|
98
|
+
tail(ref: SshRemoteRef, offset: number, limit?: number): Promise<SshTailPage>;
|
|
99
|
+
/**
|
|
100
|
+
* Read the bounded tail of a run's `stderr.log`, for diagnosing failures when
|
|
101
|
+
* `stdout.log` carries no structured agent event.
|
|
102
|
+
* @param ref - host, state directory and run.
|
|
103
|
+
* @param limit - maximum bytes from the end of `stderr.log`.
|
|
104
|
+
* @returns trimmed stderr text, or empty string when unavailable.
|
|
105
|
+
*/
|
|
106
|
+
stderr(ref: SshRemoteRef, limit?: number): Promise<string>;
|
|
107
|
+
/**
|
|
108
|
+
* Ask the launcher to cancel one run.
|
|
109
|
+
* @param ref - host, state directory and run.
|
|
110
|
+
* @returns the state line the launcher printed.
|
|
111
|
+
*/
|
|
112
|
+
cancel(ref: SshRemoteRef): Promise<LauncherStatus>;
|
|
113
|
+
/**
|
|
114
|
+
* Remove one run directory from the host, tolerating its absence.
|
|
115
|
+
* @param ref - host, state directory and run.
|
|
116
|
+
*/
|
|
117
|
+
removeRun(ref: SshRemoteRef): Promise<void>;
|
|
118
|
+
/** Run one command and refuse a failed one in the host's own words. */
|
|
119
|
+
private run;
|
|
120
|
+
}
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This extension's own configuration: reading it live, and the single path that
|
|
3
|
+
* writes it back.
|
|
4
|
+
*
|
|
5
|
+
* The fields are `volatile()` in the Config schema, so the Host's settings
|
|
6
|
+
* surface commits a write into the running fiber without a remount and every
|
|
7
|
+
* consumer here reads them at use time. That is why this module has no cache and
|
|
8
|
+
* no second store: a settings write reaches the next admission, the next run and
|
|
9
|
+
* the next tool call through {@link SshProviderSettings} alone.
|
|
10
|
+
*
|
|
11
|
+
* @module dsh-task-board-ssh/host/settings
|
|
12
|
+
*/
|
|
13
|
+
import { type SshCustomTemplates } from '../core/adapters/index.ts';
|
|
14
|
+
import { type SshAgentKind, type SshExecutionMode } from '../core/target.ts';
|
|
15
|
+
/** Default agent CLI a card starts when neither the card nor the deployment pins one. */
|
|
16
|
+
export declare const DEFAULT_AGENT_KIND: SshAgentKind;
|
|
17
|
+
/** Default execution mode of a card that pins no target yet. */
|
|
18
|
+
export declare const DEFAULT_EXECUTION_MODE: SshExecutionMode;
|
|
19
|
+
/** Profile entry ids this package's rows carry, most specific first. */
|
|
20
|
+
export declare const SSH_ENTRY_IDS: readonly string[];
|
|
21
|
+
/** The effective configuration of one mount. */
|
|
22
|
+
export interface SshProviderSettings {
|
|
23
|
+
/** Master switch of the extension. */
|
|
24
|
+
enabled: boolean;
|
|
25
|
+
/** Host a card opens with when neither the card nor the browser pins one. */
|
|
26
|
+
defaultHost: string;
|
|
27
|
+
/** Agent CLI a card opens with. */
|
|
28
|
+
defaultAgent: SshAgentKind;
|
|
29
|
+
/** Execution mode a card opens with. */
|
|
30
|
+
defaultMode: SshExecutionMode;
|
|
31
|
+
/** How many runs one host executes at once; the rest wait in the queue. */
|
|
32
|
+
perHostCap: number;
|
|
33
|
+
/** Per-agent command templates that replace the built-in command line. */
|
|
34
|
+
agentCommands: Partial<Record<SshAgentKind, SshCustomTemplates>>;
|
|
35
|
+
}
|
|
36
|
+
/** What a deployment that configured nothing gets. */
|
|
37
|
+
export declare const DEFAULT_SSH_SETTINGS: SshProviderSettings;
|
|
38
|
+
/**
|
|
39
|
+
* Read one config field's live value.
|
|
40
|
+
*
|
|
41
|
+
* A `volatile()` field arrives as a live reference the Loader updates in place,
|
|
42
|
+
* so it is unwrapped on every read instead of being captured once.
|
|
43
|
+
* @param field - the field as the Loader handed it.
|
|
44
|
+
* @param fallback - value when the field is absent.
|
|
45
|
+
* @returns the effective value.
|
|
46
|
+
*/
|
|
47
|
+
export declare function readConfigField<T>(field: unknown, fallback: T): T;
|
|
48
|
+
/**
|
|
49
|
+
* Normalize the row's own configuration.
|
|
50
|
+
* @param config - the config the Loader activated this row with.
|
|
51
|
+
* @returns the settings every consumer reads.
|
|
52
|
+
*/
|
|
53
|
+
export declare function parseSshSettings(config: unknown): SshProviderSettings;
|
|
54
|
+
/** One path-addressed edit the settings surface accepts. */
|
|
55
|
+
export type SettingsPathOp = {
|
|
56
|
+
op: 'set';
|
|
57
|
+
path: readonly string[];
|
|
58
|
+
value: unknown;
|
|
59
|
+
} | {
|
|
60
|
+
op: 'unset';
|
|
61
|
+
path: readonly string[];
|
|
62
|
+
};
|
|
63
|
+
/** One entry the settings surface reports. */
|
|
64
|
+
export interface SettingsDescriptor {
|
|
65
|
+
/** Profile entry id the form belongs to. */
|
|
66
|
+
ns?: unknown;
|
|
67
|
+
/** Revision the form was built from. */
|
|
68
|
+
revision?: unknown;
|
|
69
|
+
}
|
|
70
|
+
/** The slice of the Host settings surface this extension uses. */
|
|
71
|
+
export interface SettingsFace {
|
|
72
|
+
/** Whether the active profile accepts form edits. */
|
|
73
|
+
readonly writable: boolean;
|
|
74
|
+
/** Read the live forms. */
|
|
75
|
+
describe(options?: {
|
|
76
|
+
redactSecrets?: boolean;
|
|
77
|
+
}): SettingsDescriptor[];
|
|
78
|
+
/** Apply field edits to one entry against the revision it was read at. */
|
|
79
|
+
mutate(ns: string, ops: readonly SettingsPathOp[], expectedRevision?: number): Promise<void>;
|
|
80
|
+
}
|
|
81
|
+
/** A configuration write this deployment refused, in the term the caller acts on. */
|
|
82
|
+
export declare class SshSettingsError extends Error {
|
|
83
|
+
/** Stable machine code the action reply and the tool carry. */
|
|
84
|
+
readonly code: string;
|
|
85
|
+
constructor(code: string, message: string);
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Read the settings surface off the injected `settings` service.
|
|
89
|
+
* @param value - the service as the injected scope carries it.
|
|
90
|
+
* @returns the face, or undefined when this deployment serves none.
|
|
91
|
+
*/
|
|
92
|
+
export declare function readSettingsFace(value: unknown): SettingsFace | undefined;
|
|
93
|
+
/**
|
|
94
|
+
* Find this extension's own entry among the settings surface's forms.
|
|
95
|
+
* @param face - the settings surface.
|
|
96
|
+
* @returns the entry id and its current revision, or undefined when this
|
|
97
|
+
* deployment exposes no form for this extension.
|
|
98
|
+
*/
|
|
99
|
+
export declare function findSshSettingsEntry(face: SettingsFace): {
|
|
100
|
+
ns: string;
|
|
101
|
+
revision: number;
|
|
102
|
+
} | undefined;
|
|
103
|
+
/** One configuration change a caller may ask for. */
|
|
104
|
+
export interface SshSettingsPatch {
|
|
105
|
+
/** Master switch. */
|
|
106
|
+
enabled?: boolean;
|
|
107
|
+
/** Host a card opens with. */
|
|
108
|
+
defaultHost?: string;
|
|
109
|
+
/** Agent CLI a card opens with. */
|
|
110
|
+
defaultAgent?: SshAgentKind;
|
|
111
|
+
/** Execution mode a card opens with. */
|
|
112
|
+
defaultMode?: SshExecutionMode;
|
|
113
|
+
/** Concurrent runs per host. */
|
|
114
|
+
perHostCap?: number;
|
|
115
|
+
/** Full replacement of the per-agent command overrides. */
|
|
116
|
+
agentCommands?: ReadonlyArray<{
|
|
117
|
+
kind: SshAgentKind;
|
|
118
|
+
command: string;
|
|
119
|
+
resumeCommand?: string;
|
|
120
|
+
}>;
|
|
121
|
+
}
|
|
122
|
+
/** What one accepted write stored. */
|
|
123
|
+
export interface SshSettingsWriteResult {
|
|
124
|
+
/** Profile entry the write landed in. */
|
|
125
|
+
entry: string;
|
|
126
|
+
/** Fields the write addressed, in the order they were applied. */
|
|
127
|
+
fields: string[];
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* The one write path of this extension's configuration.
|
|
131
|
+
*
|
|
132
|
+
* Every caller — a settings card, an action, a future host route — composes a
|
|
133
|
+
* patch and hands it here; nothing else calls `settings.mutate` for this
|
|
134
|
+
* extension, so there is exactly one place where a value is validated, one
|
|
135
|
+
* revision it is written against, and one set of volatile fields it may name.
|
|
136
|
+
*/
|
|
137
|
+
export declare class SshSettingsWriter {
|
|
138
|
+
private readonly face;
|
|
139
|
+
constructor(face: () => SettingsFace | undefined);
|
|
140
|
+
/** Whether a write can be attempted at all right now. */
|
|
141
|
+
available(): boolean;
|
|
142
|
+
/**
|
|
143
|
+
* Validate one patch and write it in a single batch.
|
|
144
|
+
* @param patch - the change to store.
|
|
145
|
+
* @returns which entry and fields the write addressed.
|
|
146
|
+
* @throws SshSettingsError when the patch is unusable or the deployment refuses.
|
|
147
|
+
*/
|
|
148
|
+
save(patch: SshSettingsPatch): Promise<SshSettingsWriteResult>;
|
|
149
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The timer seat the run engine schedules through.
|
|
3
|
+
*
|
|
4
|
+
* The engine never reaches for a global timer directly: the host entry injects
|
|
5
|
+
* this face, so the poll cadence is observable, cancellable and — in tests —
|
|
6
|
+
* advanced by hand instead of waited on. A deployment with no opinion gets
|
|
7
|
+
* {@link processTimers}, which unrefs both handles so a board that is polling
|
|
8
|
+
* nothing keeps the process free to exit.
|
|
9
|
+
*
|
|
10
|
+
* @module dsh-task-board-ssh/host/timers
|
|
11
|
+
*/
|
|
12
|
+
/** The timer operations the engine needs, each returning its own canceller. */
|
|
13
|
+
export interface HostTimerFace {
|
|
14
|
+
/** Run `callback` once after `delay` ms. */
|
|
15
|
+
timeout(callback: () => void, delay: number): () => void;
|
|
16
|
+
/** Run `callback` every `delay` ms. */
|
|
17
|
+
interval(callback: () => void, delay: number): () => void;
|
|
18
|
+
}
|
|
19
|
+
/** The process timer face: what a real Host mount uses. */
|
|
20
|
+
export declare const processTimers: HostTimerFace;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { type ToolDefinition } from '@deepseek-ai/dsh-tools';
|
|
2
|
+
import { type SshExecutionMode } from '../core/target.ts';
|
|
3
|
+
import type { SshRunEngine } from './engine.ts';
|
|
4
|
+
/** Tool names, in registration order. */
|
|
5
|
+
export declare const SSH_TOOL_NAMES: readonly ["task_board_ssh_target", "task_board_ssh_status", "task_board_ssh_follow_up"];
|
|
6
|
+
/** One tool name. */
|
|
7
|
+
export type SshToolName = (typeof SSH_TOOL_NAMES)[number];
|
|
8
|
+
/**
|
|
9
|
+
* Build every tool this extension registers.
|
|
10
|
+
* @param engine - the live run engine behind them.
|
|
11
|
+
* @returns the tool definitions, in registration order.
|
|
12
|
+
*/
|
|
13
|
+
export declare function buildSshTools(engine: SshRunEngine): ToolDefinition[];
|
|
14
|
+
/** Re-exported for the specs: the modes a target may pin. */
|
|
15
|
+
export type { SshExecutionMode };
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The one failure type the workspace strategies raise.
|
|
3
|
+
*
|
|
4
|
+
* Every failure a strategy throws is this class, so the run engine can record a
|
|
5
|
+
* workspace that could not be prepared as a run failure without matching on
|
|
6
|
+
* message text. Each message names what was attempted and the host, path or
|
|
7
|
+
* command it failed on, because it lands in a card where the user has no shell
|
|
8
|
+
* to look behind it.
|
|
9
|
+
*
|
|
10
|
+
* @module dsh-task-board-ssh/host/workspace/errors
|
|
11
|
+
*/
|
|
12
|
+
/** A workspace that cannot be prepared or collected. */
|
|
13
|
+
export declare class SshWorkspaceError extends Error {
|
|
14
|
+
/**
|
|
15
|
+
* @param message - what failed, in one sentence a person can act on.
|
|
16
|
+
* @param options - standard error options, used to keep the underlying failure.
|
|
17
|
+
*/
|
|
18
|
+
constructor(message: string, options?: ErrorOptions);
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* The one line worth quoting out of a command's failure text.
|
|
22
|
+
*
|
|
23
|
+
* A tool prints progress first and the diagnosis last, so the last non-empty
|
|
24
|
+
* line is the part a person needs; the whole output is bounded away because it
|
|
25
|
+
* would bury the sentence it is quoted in.
|
|
26
|
+
* @param text - captured stderr, stdout or an error message.
|
|
27
|
+
* @returns that line, or undefined when there is nothing to quote.
|
|
28
|
+
*/
|
|
29
|
+
export declare function boundedLine(text: string | undefined): string | undefined;
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import type { SshGitSource } from '../../core/target.ts';
|
|
2
|
+
import type { SshWorkspaceCollection, SshWorkspaceRun } from '../../core/workspace.ts';
|
|
3
|
+
import { type GitWorkspaceLayout } from './layout.ts';
|
|
4
|
+
import type { SshWorkspacePreparationNote, SshWorkspaceStrategyWithNote } from './types.ts';
|
|
5
|
+
/** A repository the host reaches by URL. */
|
|
6
|
+
type UrlSource = Extract<SshGitSource, {
|
|
7
|
+
kind: 'url';
|
|
8
|
+
}>;
|
|
9
|
+
/** The local workspace repository, sent as a bundle. */
|
|
10
|
+
type WorkspaceSource = Extract<SshGitSource, {
|
|
11
|
+
kind: 'workspace';
|
|
12
|
+
}>;
|
|
13
|
+
/**
|
|
14
|
+
* The git mechanism's shared state machine.
|
|
15
|
+
*
|
|
16
|
+
* A subclass only answers where the cache's start commit comes from and where
|
|
17
|
+
* `collect` publishes the branch; the cache, the worktree, the base ref and the
|
|
18
|
+
* "did the run commit anything" question are the same for both sources.
|
|
19
|
+
*/
|
|
20
|
+
declare abstract class GitWorkspaceStrategyBase implements SshWorkspaceStrategyWithNote {
|
|
21
|
+
readonly kind: "git";
|
|
22
|
+
/** What makes this repository source unique on one host. */
|
|
23
|
+
private readonly sourceIdentity;
|
|
24
|
+
/**
|
|
25
|
+
* @param sourceIdentity - cache key identity of the pinned source.
|
|
26
|
+
*/
|
|
27
|
+
protected constructor(sourceIdentity: string);
|
|
28
|
+
/** Effective run whose worktree/branch this operation owns (reused on follow-up/rework). */
|
|
29
|
+
private layoutFor;
|
|
30
|
+
/**
|
|
31
|
+
* Make the run's worktree exist on its branch, or confirm it already does.
|
|
32
|
+
* @param run - the run being prepared.
|
|
33
|
+
* @returns the worktree path, plus the source's note when it has one.
|
|
34
|
+
* @throws SshWorkspaceError when the host, the source or git refused.
|
|
35
|
+
*/
|
|
36
|
+
prepare(run: SshWorkspaceRun): Promise<SshWorkspacePreparationNote>;
|
|
37
|
+
/**
|
|
38
|
+
* Bring the run's branch back, when the run committed anything.
|
|
39
|
+
* @param run - the settled run.
|
|
40
|
+
* @returns the branch that carries the result, or nothing when there is none.
|
|
41
|
+
* @throws SshWorkspaceError when no workspace was prepared or publishing failed.
|
|
42
|
+
*/
|
|
43
|
+
collect(run: SshWorkspaceRun): Promise<SshWorkspaceCollection>;
|
|
44
|
+
/** Best-effort reclamation of a run's remote worktree, branch and base ref. */
|
|
45
|
+
cleanup(run: SshWorkspaceRun): Promise<void>;
|
|
46
|
+
/**
|
|
47
|
+
* Put the repository in the cache and pin the commit the branch starts from.
|
|
48
|
+
* @param run - the run being prepared.
|
|
49
|
+
* @param layout - the run's paths.
|
|
50
|
+
* @returns the ref or commit `git worktree add` branches from.
|
|
51
|
+
*/
|
|
52
|
+
protected abstract seed(run: SshWorkspaceRun, layout: GitWorkspaceLayout): Promise<string>;
|
|
53
|
+
/**
|
|
54
|
+
* Publish the run branch where this source keeps its results.
|
|
55
|
+
* @param run - the settled run.
|
|
56
|
+
* @param layout - the run's paths.
|
|
57
|
+
*/
|
|
58
|
+
protected abstract publish(run: SshWorkspaceRun, layout: GitWorkspaceLayout): Promise<void>;
|
|
59
|
+
/**
|
|
60
|
+
* Describe what the source did not send, for the card to explain.
|
|
61
|
+
* @param run - the run being prepared.
|
|
62
|
+
* @returns the note to merge into the preparation; nothing by default.
|
|
63
|
+
*/
|
|
64
|
+
protected sourceNote(_run: SshWorkspaceRun): Promise<{
|
|
65
|
+
untrackedFiles?: number;
|
|
66
|
+
}>;
|
|
67
|
+
/**
|
|
68
|
+
* Read how many commits the run branch carries past the commit it started from.
|
|
69
|
+
* @param run - the run being collected.
|
|
70
|
+
* @param layout - the run's paths.
|
|
71
|
+
* @returns the commit count.
|
|
72
|
+
* @throws SshWorkspaceError when the count could not be read as one.
|
|
73
|
+
*/
|
|
74
|
+
private countRunCommits;
|
|
75
|
+
}
|
|
76
|
+
/** A repository the host clones for itself; the run's branch is pushed back. */
|
|
77
|
+
export declare class GitUrlWorkspaceStrategy extends GitWorkspaceStrategyBase {
|
|
78
|
+
/** The pinned url source. */
|
|
79
|
+
private readonly source;
|
|
80
|
+
/**
|
|
81
|
+
* @param source - repository URL the host can reach, and its optional base.
|
|
82
|
+
*/
|
|
83
|
+
constructor(source: UrlSource);
|
|
84
|
+
protected seed(run: SshWorkspaceRun, layout: GitWorkspaceLayout): Promise<string>;
|
|
85
|
+
protected publish(run: SshWorkspaceRun, layout: GitWorkspaceLayout): Promise<void>;
|
|
86
|
+
}
|
|
87
|
+
/** The local workspace repository, sent as a bundle and fetched back as one. */
|
|
88
|
+
export declare class GitWorkspaceSourceStrategy extends GitWorkspaceStrategyBase {
|
|
89
|
+
/** The pinned workspace source. */
|
|
90
|
+
private readonly source;
|
|
91
|
+
/**
|
|
92
|
+
* @param source - workspace whose local repository the run starts from.
|
|
93
|
+
*/
|
|
94
|
+
constructor(source: WorkspaceSource);
|
|
95
|
+
protected sourceNote(run: SshWorkspaceRun): Promise<{
|
|
96
|
+
untrackedFiles: number;
|
|
97
|
+
}>;
|
|
98
|
+
protected seed(run: SshWorkspaceRun, layout: GitWorkspaceLayout): Promise<string>;
|
|
99
|
+
protected publish(run: SshWorkspaceRun, layout: GitWorkspaceLayout): Promise<void>;
|
|
100
|
+
/**
|
|
101
|
+
* Read the local repository the run starts from.
|
|
102
|
+
* @param run - the run being served.
|
|
103
|
+
* @returns the absolute local repository root.
|
|
104
|
+
* @throws SshWorkspaceError when the run carries no resolved repository.
|
|
105
|
+
*/
|
|
106
|
+
private requireRepository;
|
|
107
|
+
}
|
|
108
|
+
export {};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Runs in a remote directory the user already has.
|
|
3
|
+
*
|
|
4
|
+
* The pinned directory is the whole strategy: nothing is created, copied or
|
|
5
|
+
* versioned, so the agent's changes land where the user pointed and `collect`
|
|
6
|
+
* has nothing to bring back. An absent directory fails the run instead of being
|
|
7
|
+
* created, because a typo in a path must not turn into a silently new, empty
|
|
8
|
+
* place to work in.
|
|
9
|
+
*
|
|
10
|
+
* @module dsh-task-board-ssh/host/workspace/in-place
|
|
11
|
+
*/
|
|
12
|
+
import type { SshWorkspaceCollection, SshWorkspaceRun } from '../../core/workspace.ts';
|
|
13
|
+
import type { SshWorkspacePreparationNote, SshWorkspaceStrategyWithNote } from './types.ts';
|
|
14
|
+
/** The pinned remote directory, checked but never created. */
|
|
15
|
+
export declare class InPlaceWorkspaceStrategy implements SshWorkspaceStrategyWithNote {
|
|
16
|
+
readonly kind: "in-place";
|
|
17
|
+
/** The directory the card pinned. */
|
|
18
|
+
private readonly path;
|
|
19
|
+
/**
|
|
20
|
+
* @param path - absolute remote directory the run works in.
|
|
21
|
+
* @throws SshWorkspaceError when the path is not absolute.
|
|
22
|
+
*/
|
|
23
|
+
constructor(path: string);
|
|
24
|
+
/**
|
|
25
|
+
* Check that the pinned directory exists and hand it back.
|
|
26
|
+
* @param run - the run being prepared.
|
|
27
|
+
* @returns the pinned directory as the working directory.
|
|
28
|
+
* @throws SshWorkspaceError when it is missing or the host is unreachable.
|
|
29
|
+
*/
|
|
30
|
+
prepare(run: SshWorkspaceRun): Promise<SshWorkspacePreparationNote>;
|
|
31
|
+
/**
|
|
32
|
+
* Collect nothing: in-place work stays where it was made.
|
|
33
|
+
* @returns an empty collection, because files in place are already the result.
|
|
34
|
+
*/
|
|
35
|
+
collect(): Promise<SshWorkspaceCollection>;
|
|
36
|
+
}
|