@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,123 @@
1
+ import { type SshRunRecord, type SshTarget, type SshValidationResult } from './target.ts';
2
+ /** Key this provider's payload occupies inside `TaskRecord.integrations`. */
3
+ export declare const SSH_INTEGRATION_KEY = "ssh";
4
+ /** Schema version of {@link SshLedgerPayload}; a payload at another version is refused. */
5
+ export declare const SSH_LEDGER_VERSION = 1;
6
+ /**
7
+ * Budget for one stored payload, in bytes of its JSON serialization. It equals
8
+ * the board's own ceiling and is kept below it: the board refuses a payload
9
+ * that is not strictly under its limit, so trimming targets the same number.
10
+ */
11
+ export declare const SSH_LEDGER_LIMIT_BYTES: number;
12
+ /** How many run records one payload keeps by default. */
13
+ export declare const SSH_HISTORY_LIMIT = 50;
14
+ /** Longest stored agent summary, in characters. */
15
+ export declare const SSH_SUMMARY_MAX_LENGTH = 512;
16
+ /** Longest stored failure text, in characters. */
17
+ export declare const SSH_ERROR_MAX_LENGTH = 512;
18
+ /** Longest stored branch name, in characters. */
19
+ export declare const SSH_BRANCH_MAX_LENGTH = 200;
20
+ /** Longest stored session id, in characters. */
21
+ export declare const SSH_SESSION_ID_MAX_LENGTH = 200;
22
+ /** Longest stored instruction text, in characters; the board's own message ceiling. */
23
+ export declare const SSH_PENDING_TEXT_MAX_LENGTH = 4000;
24
+ /** Which entry queued an instruction for the card's next run. */
25
+ export type SshPendingKind = 'follow-up' | 'rework';
26
+ /**
27
+ * One instruction the card owes a run: the follow-up or rework message that
28
+ * arrived while a run was already in flight.
29
+ *
30
+ * It is stored beside the frozen run account rather than in it, because it is
31
+ * not a record of what happened — it is work still to do. A card carries at most
32
+ * one, and {@link trimSshLedgerPayload} treats it as the last thing it may drop:
33
+ * the account of finished runs can shrink, but a message a person sent is
34
+ * carried until nothing else is left.
35
+ */
36
+ export interface SshPendingInstruction {
37
+ /** Which entry asked for it. */
38
+ kind: SshPendingKind;
39
+ /** Text the next run's prompt carries, bounded like every board message. */
40
+ text: string;
41
+ /** Instant it was queued (ms epoch). */
42
+ queuedAt: number;
43
+ /** Session known when it was queued, when the card had one. */
44
+ resumeSessionId?: string;
45
+ }
46
+ /**
47
+ * What one card remembers about its remote runs.
48
+ *
49
+ * `activeRun` is the run the card is waiting on; `history` keeps the bounded
50
+ * past, oldest first; `pending` is the one instruction still owed to a future
51
+ * run. None of them carries log bytes.
52
+ */
53
+ export interface SshLedgerPayload {
54
+ /** Schema version; a reader that does not know it refuses the payload. */
55
+ version: typeof SSH_LEDGER_VERSION;
56
+ /** Instant this payload was last written (ms epoch). */
57
+ updatedAt: number;
58
+ /** The target the card pins, absent while the card pins none. */
59
+ target?: SshTarget;
60
+ /** The run in flight, absent between runs. */
61
+ activeRun?: SshRunRecord;
62
+ /** Bounded run history, oldest first. */
63
+ history: SshRunRecord[];
64
+ /** The one instruction a future run still owes, absent when none is queued. */
65
+ pending?: SshPendingInstruction;
66
+ }
67
+ /** What one trimming pass may change. */
68
+ export interface SshLedgerTrimOptions {
69
+ /** Byte budget for the serialized result; defaults to {@link SSH_LEDGER_LIMIT_BYTES}. */
70
+ maxBytes?: number;
71
+ /** How many history records to keep at most; defaults to {@link SSH_HISTORY_LIMIT}. */
72
+ maxHistory?: number;
73
+ }
74
+ /**
75
+ * Byte length of a payload as the board measures it.
76
+ * @param payload - payload to measure.
77
+ * @returns UTF-8 byte length of its JSON serialization.
78
+ */
79
+ export declare function sshLedgerPayloadBytes(payload: SshLedgerPayload): number;
80
+ /**
81
+ * Cut a payload down to the stored budget.
82
+ *
83
+ * The order is fixed and lossy on purpose. Free text is bounded first, and the
84
+ * queued instruction's own bytes are reserved before anything else is measured,
85
+ * so a pass that trims history can never be the reason a person's message is
86
+ * lost. What then goes, in this order: the oldest run records, the active run's
87
+ * optional text, the active run itself, the pinned target — and only with
88
+ * nothing else left, the queued instruction. A payload therefore always comes
89
+ * back strictly under `maxBytes`, and the newest history is the last account of
90
+ * the run to be dropped.
91
+ * @param payload - payload to trim; not mutated.
92
+ * @param options - byte budget and history cap.
93
+ * @returns a payload whose serialization is under the budget.
94
+ */
95
+ export declare function trimSshLedgerPayload(payload: SshLedgerPayload, options?: SshLedgerTrimOptions): SshLedgerPayload;
96
+ /**
97
+ * Parse one stored payload.
98
+ *
99
+ * The container is read strictly (version, timestamp, history array) while a
100
+ * single malformed history entry — or an unusable queued instruction — is
101
+ * dropped alone, the same rule the board applies to integrations: one bad member
102
+ * never takes the card's account with it. Nothing here throws, so a corrupted
103
+ * payload degrades to a readable one.
104
+ * @param value - candidate payload from the ledger or an action.
105
+ * @returns the payload, or every reason it was refused.
106
+ */
107
+ export declare function parseSshLedgerPayload(value: unknown): SshValidationResult<SshLedgerPayload>;
108
+ /**
109
+ * The payload a create dialog reports for a card that does not exist yet: the
110
+ * target the new card pins, and no run account beside it.
111
+ *
112
+ * A card being created has never run, so the document carries an empty history
113
+ * and no active run or queued instruction — exactly what the host half stores
114
+ * when it pins a target on an existing card, minus the runs. The result is read
115
+ * back through {@link parseSshLedgerPayload} before it is returned: a draft this
116
+ * build could store but not read back is never reported at all, so a card
117
+ * created through a create dialog always opens on a payload its own detail seat
118
+ * can account for.
119
+ * @param target - the target the reader picked, already parsed.
120
+ * @param updatedAt - instant the draft is reported (ms epoch).
121
+ * @returns the payload, or undefined when the document does not parse.
122
+ */
123
+ export declare function composeDraftPayload(target: SshTarget, updatedAt: number): SshLedgerPayload | undefined;
@@ -0,0 +1,61 @@
1
+ /**
2
+ * POSIX shell quoting for every value this provider sends to a remote host.
3
+ *
4
+ * The remote side is an arbitrary `sh` on a machine the provider does not own,
5
+ * so nothing is interpolated: each value becomes one single-quoted word, and a
6
+ * value that cannot survive an `execve` argument list is refused instead of
7
+ * silently truncated. Callers compose command lines out of these functions and
8
+ * never concatenate raw text into one.
9
+ *
10
+ * @module dsh-task-board-ssh/core/shell
11
+ */
12
+ /**
13
+ * Quote one value as a single POSIX shell word.
14
+ *
15
+ * The result is a single-quoted string, so the remote shell expands nothing
16
+ * inside it: `$(...)`, backticks, newlines, semicolons and globs stay literal.
17
+ * An embedded quote is closed, emitted as an escaped quote, and reopened, which
18
+ * is the only form that survives quoting inside a quoted string.
19
+ * @param value - text to quote.
20
+ * @returns one shell word that evaluates back to `value`.
21
+ * @throws RangeError when the value contains a NUL byte, which no shell word can carry.
22
+ */
23
+ export declare function shellQuote(value: string): string;
24
+ /**
25
+ * Quote and join several words into one command line.
26
+ * @param words - command and arguments, unquoted.
27
+ * @returns the command line with every word quoted separately.
28
+ */
29
+ export declare function shellJoin(words: readonly string[]): string;
30
+ /**
31
+ * Build the command that ensures one remote directory exists.
32
+ * @param path - absolute remote directory.
33
+ * @returns one shell command.
34
+ */
35
+ export declare function shellEnsureDir(path: string): string;
36
+ /**
37
+ * Build the command that writes one file's exact bytes on the remote host.
38
+ *
39
+ * `printf '%s'` copies its argument verbatim, so the content travels as one
40
+ * quoted word: no heredoc delimiter has to be invented and no line is
41
+ * reinterpreted. The command line's own length is the only limit.
42
+ * @param path - absolute remote path.
43
+ * @param content - UTF-8 text without NUL bytes.
44
+ * @returns one shell command.
45
+ */
46
+ export declare function shellWriteFile(path: string, content: string): string;
47
+ /**
48
+ * Build one command that writes several files, in order.
49
+ * @param entries - remote path and content pairs.
50
+ * @returns one shell command, or an empty string for an empty list.
51
+ */
52
+ export declare function shellWriteFiles(entries: readonly {
53
+ path: string;
54
+ content: string;
55
+ }[]): string;
56
+ /**
57
+ * Build the command that removes one remote directory, tolerating its absence.
58
+ * @param path - absolute remote directory.
59
+ * @returns one shell command.
60
+ */
61
+ export declare function shellRemoveDir(path: string): string;
@@ -0,0 +1,149 @@
1
+ /**
2
+ * The execution target a card pins, and the run record the ledger carries.
3
+ *
4
+ * Both shapes are the wire form: they are what the browser half sends, what the
5
+ * host half stores under `integrations.ssh`, and what an agent tool returns, so
6
+ * both are parsed from `unknown` and never trusted. Parsing reports the exact
7
+ * path of every problem instead of throwing, because a malformed payload
8
+ * arrives from outside the process and must not become an exception in the
9
+ * board's action channel.
10
+ *
11
+ * @module dsh-task-board-ssh/core/target
12
+ */
13
+ /** How a pinned card reaches the remote host. */
14
+ export type SshExecutionMode = 'direct' | 'proxy';
15
+ /** Which agent CLI the remote run starts. */
16
+ export declare const SSH_AGENT_KINDS: readonly ["dsh", "claude", "codex", "custom"];
17
+ /** Agent CLI the remote run starts. */
18
+ export type SshAgentKind = (typeof SSH_AGENT_KINDS)[number];
19
+ /** Which filesystem mechanism a run works in. */
20
+ export type SshWorkspaceKind = 'in-place' | 'git';
21
+ /** Where the git workspace strategy takes its repository from. */
22
+ export type SshGitSource = {
23
+ /** A repository the remote host can reach on its own. */
24
+ kind: 'url';
25
+ /**
26
+ * Clone URL: https, ssh or `user@host:path` form. It reaches `git fetch`
27
+ * and `git push` as a bare word, so a leading dash — which git reads as
28
+ * an option, including the `--upload-pack` that runs a command — is
29
+ * refused by the parser rather than escaped.
30
+ */
31
+ url: string;
32
+ /**
33
+ * Branch the per-run worktree starts from; absent uses the remote HEAD.
34
+ * A leading dash is refused for the same reason: the value is composed
35
+ * into ref names and refspecs, and one future caller will pass it bare.
36
+ */
37
+ base?: string;
38
+ } | {
39
+ /** The workspace's local repository, sent to the host as a git bundle. */
40
+ kind: 'workspace';
41
+ /** Workspace id the local repository comes from. */
42
+ workspaceId: string;
43
+ };
44
+ /** Run in an existing remote directory. */
45
+ export interface SshInPlaceWorkspace {
46
+ /** Discriminator. */
47
+ kind: 'in-place';
48
+ /** Absolute remote directory the agent works in. */
49
+ path: string;
50
+ }
51
+ /** Run in a per-run worktree of a git repository. */
52
+ export interface SshGitWorkspace {
53
+ /** Discriminator. */
54
+ kind: 'git';
55
+ /** Repository the worktree branches from. */
56
+ source: SshGitSource;
57
+ }
58
+ /** Filesystem mechanism one run uses. */
59
+ export type SshWorkspaceTarget = SshInPlaceWorkspace | SshGitWorkspace;
60
+ /** Which agent CLI a target pins, and the command template when it is custom. */
61
+ export interface SshAgentTarget {
62
+ /** Agent CLI kind. */
63
+ kind: SshAgentKind;
64
+ /** Start template of a custom agent; required for, and only read with, `custom`. */
65
+ command?: string;
66
+ /** Resume template of a custom agent; absent degrades a follow-up to a fresh run. */
67
+ resumeCommand?: string;
68
+ }
69
+ /** Everything one card pins about where and how it runs. */
70
+ export interface SshTarget {
71
+ /** Whether the card runs remotely at all, or through a local session driving the host. */
72
+ mode: SshExecutionMode;
73
+ /** `dshSsh` host alias the run addresses. */
74
+ host: string;
75
+ /** Agent CLI the remote run starts. */
76
+ agent: SshAgentTarget;
77
+ /** Filesystem mechanism the run works in. */
78
+ workspace: SshWorkspaceTarget;
79
+ }
80
+ /** Phase of one remote run, as the ledger records it. */
81
+ export type SshRunPhase = 'queued' | 'running' | 'succeeded' | 'failed' | 'cancelled' | 'lost';
82
+ /** One terminal phase; nothing schedules more work for a run in one of these. */
83
+ export declare const SSH_TERMINAL_RUN_PHASES: readonly SshRunPhase[];
84
+ /** What a launch record cost and produced: one run of one card on one host. */
85
+ export interface SshRunRecord {
86
+ /** Identifier the remote launcher is idempotent on. */
87
+ runId: string;
88
+ /** Phase this record was last seen in. */
89
+ phase: SshRunPhase;
90
+ /** Instant the run was requested (ms epoch). */
91
+ startedAt: number;
92
+ /** Instant the run reached a terminal phase (ms epoch), when it did. */
93
+ finishedAt?: number;
94
+ /** Remote exit code, once the run settled. */
95
+ exitCode?: number;
96
+ /** Session id the remote agent reported, used to resume it. */
97
+ sessionId?: string;
98
+ /** Bytes of the remote stdout log the provider has read. */
99
+ bytes?: number;
100
+ /** Branch the git workspace collected, when it produced one. */
101
+ branch?: string;
102
+ /** Final summary the remote agent reported, bounded before it lands here. */
103
+ summary?: string;
104
+ /** Failure text, bounded before it lands here. */
105
+ error?: string;
106
+ /** Follow-up messages delivered into this run's session. */
107
+ followUps?: number;
108
+ /** Execution id handed out at launch; the settled board execution record takes it. */
109
+ executionId?: string;
110
+ /** Last instant the remote log grew (ms epoch). */
111
+ lastActivityAt?: number;
112
+ /** Stable failure code of a failed run. */
113
+ errorCode?: string;
114
+ }
115
+ /** One diagnostic about a malformed value, addressed by its path inside it. */
116
+ export interface SshValidationIssue {
117
+ /** Dotted path of the offending field, empty for the value itself. */
118
+ path: string;
119
+ /** What is wrong with it, in one sentence. */
120
+ message: string;
121
+ }
122
+ /** A parse result: the value, or every reason it was refused. */
123
+ export type SshValidationResult<T> = {
124
+ ok: true;
125
+ value: T;
126
+ } | {
127
+ ok: false;
128
+ errors: readonly SshValidationIssue[];
129
+ };
130
+ /** Host aliases `dshSsh` accepts: letters, digits, dots, hyphens, underscores. */
131
+ export declare const HOST_ALIAS_RE: RegExp;
132
+ /**
133
+ * Parse one pinned execution target.
134
+ * @param value - candidate target from the wire, the ledger or a settings form.
135
+ * @returns the target, or every reason it was refused.
136
+ */
137
+ export declare function parseSshTarget(value: unknown): SshValidationResult<SshTarget>;
138
+ /**
139
+ * Parse one run record.
140
+ * @param value - candidate record from the ledger or an action payload.
141
+ * @returns the record, or every reason it was refused.
142
+ */
143
+ export declare function parseSshRunRecord(value: unknown): SshValidationResult<SshRunRecord>;
144
+ /**
145
+ * Whether a run phase is terminal.
146
+ * @param phase - phase to test.
147
+ * @returns true for succeeded, failed, cancelled and lost.
148
+ */
149
+ export declare function isTerminalRunPhase(phase: SshRunPhase): boolean;
@@ -0,0 +1,74 @@
1
+ /**
2
+ * Structural view of the task-board vocabulary this extension reads.
3
+ *
4
+ * The extension is a separate bundle and may not import the board's internals,
5
+ * so it restates the record shape the provider contract hands it. These are
6
+ * read-only structural declarations: the board's own values satisfy them and
7
+ * nothing here is constructed by the board. The single source of truth for the
8
+ * contract remains the board's `src/core/extension.ts`.
9
+ *
10
+ * @module dsh-task-board-ssh/core/task-record
11
+ */
12
+ /** Column a card occupies. */
13
+ export type TaskStatus = 'backlog' | 'todo' | 'running' | 'done' | 'failed';
14
+ /** Settlement of one local execution. */
15
+ export type ExecutionOutcome = 'succeeded' | 'failed' | 'cancelled';
16
+ /** One execution of a card, as a provider reads it. */
17
+ export interface ExecutionRecord {
18
+ /** Stable execution id. */
19
+ id: string;
20
+ /** Session the execution runs in, once one was opened. */
21
+ sessionId?: string;
22
+ /** Instant the execution started (ms epoch). */
23
+ startedAt: number;
24
+ /** Instant the execution settled (ms epoch). */
25
+ settledAt?: number;
26
+ /** Settlement, absent while the execution is still running. */
27
+ result?: ExecutionOutcome;
28
+ /** Conclusion of a succeeded run. */
29
+ summary?: {
30
+ text: string;
31
+ seq?: number;
32
+ };
33
+ /** Failure text of a failed run. */
34
+ error?: string;
35
+ /** Stable failure code a provider reported. */
36
+ errorCode?: string;
37
+ /** Who recorded the execution (`ssh:<runId>` for this provider). */
38
+ initiatedBy?: string;
39
+ }
40
+ /** One card, as a provider reads it through the capability face. */
41
+ export interface TaskRecord {
42
+ /** Stable card id. */
43
+ id: string;
44
+ /** Card title. */
45
+ title: string;
46
+ /** Card description. */
47
+ description: string;
48
+ /** Prompt one execution sends to the agent. */
49
+ prompt: string;
50
+ /** Column the card occupies. */
51
+ status: TaskStatus;
52
+ /** Instant the card was created (ms epoch). */
53
+ createdAt: number;
54
+ /** Instant the card was last written (ms epoch). */
55
+ updatedAt: number;
56
+ /** Parent card id, when this card is a subtask. */
57
+ parentId?: string;
58
+ /** Workspace the execution must run in, when the card pins one. */
59
+ workspaceId?: string;
60
+ /** Qualified provider/model the card pins for its execution, when it pins one. */
61
+ model?: string;
62
+ /** True for a card the board keeps off the board view. */
63
+ hidden?: boolean;
64
+ /** Instant the card was archived (ms epoch), absent while it is live. */
65
+ archivedAt?: number;
66
+ /** Every execution this card has had, oldest first. */
67
+ executions: ExecutionRecord[];
68
+ /** The board's native tags. */
69
+ tags?: ReadonlyArray<{
70
+ name: string;
71
+ }>;
72
+ /** Opaque provider payloads, keyed by extension id. */
73
+ integrations?: Record<string, unknown>;
74
+ }
@@ -0,0 +1,74 @@
1
+ /**
2
+ * The frozen workspace-strategy interface.
3
+ *
4
+ * One interface covers the three user-visible placement modes the proposal
5
+ * settled: an existing remote directory (`in-place`) and a per-run git
6
+ * worktree whose repository is either a URL the host can reach or the local
7
+ * workspace repository sent as a bundle (`git`). The host engine drives it;
8
+ * this module is the seam only, so the two strategies and the engine can be
9
+ * written against one shape.
10
+ *
11
+ * A strategy never decides policy: it receives the run, prepares a directory,
12
+ * and collects the result. Failures are thrown and recorded by the caller,
13
+ * because a workspace that cannot be prepared must fail the run before any
14
+ * agent starts.
15
+ *
16
+ * @module dsh-task-board-ssh/core/workspace
17
+ */
18
+ import type { DshSshService } from './contract.ts';
19
+ import type { SshGitSource, SshWorkspaceKind } from './target.ts';
20
+ /** Everything a strategy needs about one run. */
21
+ export interface SshWorkspaceRun {
22
+ /** Run identifier; also the branch suffix of a git worktree. */
23
+ runId: string;
24
+ /** `dshSsh` host alias the run addresses. */
25
+ host: string;
26
+ /** Absolute remote state directory the provider owns on that host. */
27
+ stateDir: string;
28
+ /** The host face every remote operation goes through. */
29
+ ssh: DshSshService;
30
+ /** Repository source, present for the git mode. */
31
+ source?: SshGitSource;
32
+ /** Local repository root, present when `source` is the workspace repository. */
33
+ localRepository?: string;
34
+ /**
35
+ * Earlier run id whose git worktree/branch this follow-up/rework run reuses
36
+ * so prior commits stay in place and cwd-scoped sessions (e.g. Claude Code)
37
+ * can resume cleanly.
38
+ */
39
+ reuseWorktreeRunId?: string;
40
+ /** Aborts a transfer or a remote command. */
41
+ signal?: AbortSignal;
42
+ }
43
+ /** What preparing a run produced. */
44
+ export interface SshWorkspacePreparation {
45
+ /** Absolute remote directory the agent CLI runs in. */
46
+ cwd: string;
47
+ }
48
+ /** What collecting a run produced. */
49
+ export interface SshWorkspaceCollection {
50
+ /** Branch carrying the run's commits, when the strategy brings work back as one. */
51
+ branch?: string;
52
+ }
53
+ /** One placement mechanism. */
54
+ export interface SshWorkspaceStrategy {
55
+ /** Which mechanism this is; matches `SshWorkspaceTarget.kind`. */
56
+ readonly kind: SshWorkspaceKind;
57
+ /**
58
+ * Make the run's working directory exist and return it.
59
+ * @param run - the run being prepared.
60
+ * @returns the absolute remote directory the agent runs in.
61
+ */
62
+ prepare(run: SshWorkspaceRun): Promise<SshWorkspacePreparation>;
63
+ /**
64
+ * Bring back whatever the run produced.
65
+ * @param run - the settled run.
66
+ * @returns the branch that carries the result, when there is one.
67
+ */
68
+ collect(run: SshWorkspaceRun): Promise<SshWorkspaceCollection>;
69
+ /**
70
+ * Optional cleanup invoked when a card is deleted (removes worktrees/refs).
71
+ * @param run - run whose workspace resources should be reclaimed.
72
+ */
73
+ cleanup?(run: SshWorkspaceRun): Promise<void>;
74
+ }
@@ -0,0 +1,75 @@
1
+ /**
2
+ * The board's in-process action seat, and the execution facts this package
3
+ * reads off a card.
4
+ *
5
+ * A provider's own writes reach the ledger through exactly what the browser
6
+ * uses: the board service's `apply`, which every gate (running lock, content
7
+ * freeze, permission confirmation, spend cap) still judges. The registration
8
+ * contract this package restates in `src/core/contract.ts` carries the read
9
+ * face only, so the seat is read structurally off the same injected service and
10
+ * refused when the board revision does not serve it — a provider without it
11
+ * still mounts, it just cannot open or close a run.
12
+ *
13
+ * @module dsh-task-board-ssh/host/board
14
+ */
15
+ import { type ServiceLookupSeat } from '../core/contract.ts';
16
+ import type { TaskRecord } from '../core/task-record.ts';
17
+ /** One action this package submits to the board. Field names are the board's own. */
18
+ export type BoardAction = {
19
+ kind: 'run';
20
+ taskId: string;
21
+ } | {
22
+ kind: 'rerun';
23
+ taskId: string;
24
+ } | {
25
+ kind: 'record-external-outcome';
26
+ taskId: string;
27
+ result: 'succeeded' | 'failed';
28
+ initiatedBy: string;
29
+ summary?: string;
30
+ executionId?: string;
31
+ startedAt?: number;
32
+ errorCode?: string;
33
+ retryHint?: string;
34
+ };
35
+ /**
36
+ * The board service's `apply`, as this package drives it.
37
+ *
38
+ * Structurally the board's own: the returned value is the board snapshot, which
39
+ * no caller here reads beyond "the write was accepted", so it stays `unknown`.
40
+ */
41
+ export interface BoardActionSeat {
42
+ /** Submit one action; a refusal throws the board's own message. */
43
+ apply(requestId: string, action: BoardAction, initiator?: string): unknown;
44
+ }
45
+ /** Prefix every external execution record this package writes carries. */
46
+ export declare const SSH_INITIATOR_PREFIX = "ssh:";
47
+ /**
48
+ * Read the action seat off the board service face.
49
+ * @param face - the resolved `taskBoard` host service.
50
+ * @returns the seat, or undefined when this board revision serves no applier.
51
+ */
52
+ export declare function readBoardActionSeat(face: unknown): BoardActionSeat | undefined;
53
+ /**
54
+ * Resolve the board's action seat off the injected service.
55
+ *
56
+ * The registration contract this package restates carries the read face only, so
57
+ * the applier is read off the same service structurally: the board publishes one
58
+ * object with both, and a revision that serves no applier answers undefined here
59
+ * instead of failing the provider.
60
+ * @param ctx - the injected scope the board service was resolved from.
61
+ * @returns the seat, or undefined when this board revision serves no applier.
62
+ */
63
+ export declare function resolveBoardActionSeat(ctx: ServiceLookupSeat): BoardActionSeat | undefined;
64
+ /**
65
+ * Whether the card's execution history already holds the outcome of one run.
66
+ *
67
+ * Reconciliation must close a run that finished while the local host was down
68
+ * exactly once, and a crash between the board write and the payload write would
69
+ * otherwise record it twice: the board appends a fresh external execution for
70
+ * every call, so this package's own marker is the only idempotency key there is.
71
+ * @param task - the card to read.
72
+ * @param runId - the run whose outcome may already be recorded.
73
+ * @returns true when a record this package wrote for `runId` is present.
74
+ */
75
+ export declare function alreadyRecorded(task: TaskRecord, runId: string): boolean;