dsh-bash-terminal-ts 0.4.0 → 0.4.1
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/dist/client.core.js +132 -132
- package/dist/client.js +141 -141
- package/dsh.plugin.json +2 -2
- package/lib/dsh-types.d.ts +260 -260
- package/lib/dsh.d.ts +33 -33
- package/lib/index.d.ts +201 -201
- package/lib/index.js +759 -759
- package/lib/terminal.d.ts +87 -87
- package/lib/terminal.js +273 -273
- package/package.json +13 -13
package/lib/dsh-types.d.ts
CHANGED
|
@@ -1,260 +1,260 @@
|
|
|
1
|
-
/** The terminal backends this plugin exposes. */
|
|
2
|
-
export type ShellId = "powershell" | "gitbash" | "msys2" | "wsl";
|
|
3
|
-
/** Permissive node of the DSH JSON-schema dialect used in tool output declarations. */
|
|
4
|
-
export interface JsonSchemaNode {
|
|
5
|
-
type?: string;
|
|
6
|
-
required?: boolean;
|
|
7
|
-
const?: string;
|
|
8
|
-
enum?: readonly string[];
|
|
9
|
-
properties?: Record<string, JsonSchemaNode>;
|
|
10
|
-
items?: JsonSchemaNode;
|
|
11
|
-
oneOf?: JsonSchemaNode[];
|
|
12
|
-
additionalProperties?: boolean;
|
|
13
|
-
}
|
|
14
|
-
/** Model-facing content block (subset). */
|
|
15
|
-
export interface ContentBlock {
|
|
16
|
-
type: string;
|
|
17
|
-
text?: string;
|
|
18
|
-
}
|
|
19
|
-
/** One entry of a tool's `parameters` declaration. */
|
|
20
|
-
export interface ToolParameterProperty {
|
|
21
|
-
type: string;
|
|
22
|
-
required?: boolean;
|
|
23
|
-
description?: string;
|
|
24
|
-
enum?: readonly string[];
|
|
25
|
-
}
|
|
26
|
-
export interface ToolParameters {
|
|
27
|
-
type: "object";
|
|
28
|
-
properties: Record<string, ToolParameterProperty>;
|
|
29
|
-
}
|
|
30
|
-
/** Flat parameter map as accepted by defineTool (wrapped into `ToolParameters` by the runtime). */
|
|
31
|
-
export type ToolParameterMap = Record<string, ToolParameterProperty>;
|
|
32
|
-
/** The exec object every tool body receives. */
|
|
33
|
-
export interface ToolRunContext {
|
|
34
|
-
/** Caller cancellation; observe or forward it in async work. */
|
|
35
|
-
signal: AbortSignal;
|
|
36
|
-
callId?: string;
|
|
37
|
-
agent?: ExecAgent;
|
|
38
|
-
}
|
|
39
|
-
/** The agent slice of exec this plugin reads (session cwd) or passes on (owner). */
|
|
40
|
-
export interface ExecAgent {
|
|
41
|
-
session: {
|
|
42
|
-
header: {
|
|
43
|
-
cwd?: string;
|
|
44
|
-
};
|
|
45
|
-
};
|
|
46
|
-
}
|
|
47
|
-
export interface ToolResult {
|
|
48
|
-
content: ContentBlock[];
|
|
49
|
-
isError?: boolean;
|
|
50
|
-
}
|
|
51
|
-
/** Tool output view handed to presentResult. */
|
|
52
|
-
export interface CallView {
|
|
53
|
-
card: string;
|
|
54
|
-
[key: string]: unknown;
|
|
55
|
-
}
|
|
56
|
-
/** A fully specified tool: schema, canonical output, body, presentations. */
|
|
57
|
-
export interface ToolSpec<TValue> {
|
|
58
|
-
name: string;
|
|
59
|
-
description: string;
|
|
60
|
-
parameters: ToolParameterMap;
|
|
61
|
-
output: {
|
|
62
|
-
schema: JsonSchemaNode;
|
|
63
|
-
render: (args: unknown, value: TValue) => ContentBlock[];
|
|
64
|
-
};
|
|
65
|
-
execute: (args: Record<string, unknown>, exec: ToolRunContext) => Promise<TValue>;
|
|
66
|
-
presentCall?: (args: Record<string, unknown>) => CallView;
|
|
67
|
-
presentResult?: (args: Record<string, unknown>, result: ToolResult) => CallView | undefined;
|
|
68
|
-
}
|
|
69
|
-
/** Canonical output declaration, erased of the tool's value type (registry face). */
|
|
70
|
-
export interface ToolOutputDefinition {
|
|
71
|
-
schema: JsonSchemaNode;
|
|
72
|
-
render: (args: unknown, value: unknown) => ContentBlock[];
|
|
73
|
-
}
|
|
74
|
-
/** What defineTool hands back (opaque to the plugin; registered as-is). */
|
|
75
|
-
export interface ToolDefinition {
|
|
76
|
-
name: string;
|
|
77
|
-
description: string;
|
|
78
|
-
parameters: ToolParameters;
|
|
79
|
-
output: ToolOutputDefinition;
|
|
80
|
-
execute: (args: Record<string, unknown>, exec: ToolRunContext) => Promise<unknown>;
|
|
81
|
-
}
|
|
82
|
-
export interface LoggerSeam {
|
|
83
|
-
info?: (message: string) => void;
|
|
84
|
-
warn?: (message: string) => void;
|
|
85
|
-
error?: (message: string) => void;
|
|
86
|
-
}
|
|
87
|
-
export interface SystemPromptSection {
|
|
88
|
-
name: string;
|
|
89
|
-
order: number;
|
|
90
|
-
text: string;
|
|
91
|
-
}
|
|
92
|
-
export interface SystemPromptSeam {
|
|
93
|
-
section(spec: SystemPromptSection): unknown;
|
|
94
|
-
}
|
|
95
|
-
export interface ToolsSeam {
|
|
96
|
-
register(tool: ToolDefinition): unknown;
|
|
97
|
-
}
|
|
98
|
-
/** A tool entry seen during system-prompt assembly (description re-render). */
|
|
99
|
-
export interface AssembledToolRef {
|
|
100
|
-
name: string;
|
|
101
|
-
description?: string;
|
|
102
|
-
}
|
|
103
|
-
export interface PromptAssembly {
|
|
104
|
-
tools: AssembledToolRef[];
|
|
105
|
-
[key: string]: unknown;
|
|
106
|
-
}
|
|
107
|
-
/** Type of the system-prompt/assemble waterfall listener. */
|
|
108
|
-
export type AssembleHandler = (assembly: PromptAssembly, context: unknown, next: () => Promise<PromptAssembly>) => Promise<PromptAssembly>;
|
|
109
|
-
export interface ShellEnvSeam {
|
|
110
|
-
collect(exec: ToolRunContext): Record<string, string> | undefined;
|
|
111
|
-
}
|
|
112
|
-
export interface SettingsScope<T> {
|
|
113
|
-
get(): T;
|
|
114
|
-
}
|
|
115
|
-
export interface SettingsSeam {
|
|
116
|
-
register<T>(namespace: string, schema: unknown, options: {
|
|
117
|
-
base: T;
|
|
118
|
-
}): SettingsScope<T>;
|
|
119
|
-
}
|
|
120
|
-
export interface SandboxPolicy {
|
|
121
|
-
mode: string;
|
|
122
|
-
workspaceRoot?: string;
|
|
123
|
-
sessionId?: string;
|
|
124
|
-
}
|
|
125
|
-
export interface SandboxPolicySeam {
|
|
126
|
-
resolve(scope: {
|
|
127
|
-
session?: unknown;
|
|
128
|
-
}): SandboxPolicy;
|
|
129
|
-
}
|
|
130
|
-
export interface SandboxConfineResult {
|
|
131
|
-
argv: string[];
|
|
132
|
-
enforcement: string;
|
|
133
|
-
denialSignatures?: string[];
|
|
134
|
-
}
|
|
135
|
-
export interface SandboxSeam {
|
|
136
|
-
confine(argv: string[], policy: SandboxPolicy): SandboxConfineResult;
|
|
137
|
-
}
|
|
138
|
-
/** Sandbox facts embedded in a canonical result. */
|
|
139
|
-
export interface SandboxFacts {
|
|
140
|
-
mode: string;
|
|
141
|
-
enforcement: string;
|
|
142
|
-
denialSignatures?: string[];
|
|
143
|
-
denied?: boolean;
|
|
144
|
-
}
|
|
145
|
-
export interface EscalationRequest {
|
|
146
|
-
requestedMode: string;
|
|
147
|
-
justification: string;
|
|
148
|
-
effectiveMode: string;
|
|
149
|
-
subject: string;
|
|
150
|
-
}
|
|
151
|
-
export interface EscalationContext {
|
|
152
|
-
approver?: unknown;
|
|
153
|
-
agent?: unknown;
|
|
154
|
-
callId?: string;
|
|
155
|
-
toolName: string;
|
|
156
|
-
signal: AbortSignal;
|
|
157
|
-
}
|
|
158
|
-
export interface JobHooks {
|
|
159
|
-
cancel: () => void;
|
|
160
|
-
done: Promise<unknown>;
|
|
161
|
-
readOutput: () => string;
|
|
162
|
-
}
|
|
163
|
-
export interface JobSpec {
|
|
164
|
-
kind: string;
|
|
165
|
-
label: string;
|
|
166
|
-
owner?: unknown;
|
|
167
|
-
run: () => JobHooks;
|
|
168
|
-
}
|
|
169
|
-
export interface JobsRegistry {
|
|
170
|
-
start(spec: JobSpec): string;
|
|
171
|
-
}
|
|
172
|
-
/** Executable paths per backend; undefined when a backend is not installed. */
|
|
173
|
-
export interface ResolvedPaths {
|
|
174
|
-
pwsh?: string;
|
|
175
|
-
gitbash?: string;
|
|
176
|
-
msys2?: string;
|
|
177
|
-
wsl?: string;
|
|
178
|
-
}
|
|
179
|
-
export interface CollectSpec {
|
|
180
|
-
maxBytes: number;
|
|
181
|
-
spill: {
|
|
182
|
-
maxBytes: number;
|
|
183
|
-
};
|
|
184
|
-
}
|
|
185
|
-
export interface StdioSpec {
|
|
186
|
-
stdin: {
|
|
187
|
-
data: string;
|
|
188
|
-
} | "ignore";
|
|
189
|
-
stdout: CollectSpec;
|
|
190
|
-
stderr: CollectSpec;
|
|
191
|
-
}
|
|
192
|
-
export interface SubprocessSpawnSpec {
|
|
193
|
-
argv: string[];
|
|
194
|
-
cwd?: string;
|
|
195
|
-
stdio: StdioSpec;
|
|
196
|
-
graceMs: number;
|
|
197
|
-
signal?: AbortSignal;
|
|
198
|
-
env?: Record<string, string | undefined>;
|
|
199
|
-
}
|
|
200
|
-
export interface CollectedStream {
|
|
201
|
-
readFrom(offset: number): {
|
|
202
|
-
text: string;
|
|
203
|
-
lossy: boolean;
|
|
204
|
-
nextOffset: number;
|
|
205
|
-
spillPath?: string;
|
|
206
|
-
};
|
|
207
|
-
}
|
|
208
|
-
export interface SubprocessOutcome {
|
|
209
|
-
exitCode: number | null;
|
|
210
|
-
signal: string | null;
|
|
211
|
-
}
|
|
212
|
-
export interface SubprocessHandle {
|
|
213
|
-
collected: {
|
|
214
|
-
stdout: CollectedStream;
|
|
215
|
-
stderr: CollectedStream;
|
|
216
|
-
};
|
|
217
|
-
done: Promise<SubprocessOutcome>;
|
|
218
|
-
terminate: () => void | Promise<void>;
|
|
219
|
-
}
|
|
220
|
-
export interface TerminalSpawnSpec {
|
|
221
|
-
argv: string[];
|
|
222
|
-
cwd: string;
|
|
223
|
-
env: Record<string, string | undefined>;
|
|
224
|
-
rows: number;
|
|
225
|
-
cols: number;
|
|
226
|
-
graceMs?: number;
|
|
227
|
-
}
|
|
228
|
-
export interface TerminalHandle {
|
|
229
|
-
pid: number;
|
|
230
|
-
output: NodeJS.ReadableStream;
|
|
231
|
-
done: Promise<SubprocessOutcome>;
|
|
232
|
-
write(data: string): void | Promise<void>;
|
|
233
|
-
signalForeground(sig: string): void | Promise<unknown>;
|
|
234
|
-
terminate(): Promise<void>;
|
|
235
|
-
}
|
|
236
|
-
export interface SubprocessSeam {
|
|
237
|
-
spawn(spec: SubprocessSpawnSpec): SubprocessHandle;
|
|
238
|
-
spawnTerminal?(spec: TerminalSpawnSpec): Promise<TerminalHandle>;
|
|
239
|
-
}
|
|
240
|
-
export interface ApprovalSeam {
|
|
241
|
-
request(input: unknown): Promise<unknown>;
|
|
242
|
-
}
|
|
243
|
-
/**
|
|
244
|
-
* The structural context face dsh-bash-terminal-ts programs against: the union
|
|
245
|
-
* of every `ctx.*` member touched by src/index.ts and src/terminal.ts.
|
|
246
|
-
*/
|
|
247
|
-
export interface BashTerminalContext {
|
|
248
|
-
logger?: LoggerSeam;
|
|
249
|
-
systemPrompt: SystemPromptSeam;
|
|
250
|
-
tools: ToolsSeam;
|
|
251
|
-
on(event: "system-prompt/assemble", handler: AssembleHandler): void;
|
|
252
|
-
shellEnv: ShellEnvSeam;
|
|
253
|
-
settings: SettingsSeam;
|
|
254
|
-
sandboxPolicy: SandboxPolicySeam;
|
|
255
|
-
sandbox: SandboxSeam;
|
|
256
|
-
get(key: string): unknown;
|
|
257
|
-
effect(fn: () => void | (() => void), name?: string): unknown;
|
|
258
|
-
/** Injected via `inject: ["subprocess"]`; tests may defer assignment. */
|
|
259
|
-
subprocess: SubprocessSeam | null;
|
|
260
|
-
}
|
|
1
|
+
/** The terminal backends this plugin exposes. */
|
|
2
|
+
export type ShellId = "powershell" | "gitbash" | "msys2" | "wsl";
|
|
3
|
+
/** Permissive node of the DSH JSON-schema dialect used in tool output declarations. */
|
|
4
|
+
export interface JsonSchemaNode {
|
|
5
|
+
type?: string;
|
|
6
|
+
required?: boolean;
|
|
7
|
+
const?: string;
|
|
8
|
+
enum?: readonly string[];
|
|
9
|
+
properties?: Record<string, JsonSchemaNode>;
|
|
10
|
+
items?: JsonSchemaNode;
|
|
11
|
+
oneOf?: JsonSchemaNode[];
|
|
12
|
+
additionalProperties?: boolean;
|
|
13
|
+
}
|
|
14
|
+
/** Model-facing content block (subset). */
|
|
15
|
+
export interface ContentBlock {
|
|
16
|
+
type: string;
|
|
17
|
+
text?: string;
|
|
18
|
+
}
|
|
19
|
+
/** One entry of a tool's `parameters` declaration. */
|
|
20
|
+
export interface ToolParameterProperty {
|
|
21
|
+
type: string;
|
|
22
|
+
required?: boolean;
|
|
23
|
+
description?: string;
|
|
24
|
+
enum?: readonly string[];
|
|
25
|
+
}
|
|
26
|
+
export interface ToolParameters {
|
|
27
|
+
type: "object";
|
|
28
|
+
properties: Record<string, ToolParameterProperty>;
|
|
29
|
+
}
|
|
30
|
+
/** Flat parameter map as accepted by defineTool (wrapped into `ToolParameters` by the runtime). */
|
|
31
|
+
export type ToolParameterMap = Record<string, ToolParameterProperty>;
|
|
32
|
+
/** The exec object every tool body receives. */
|
|
33
|
+
export interface ToolRunContext {
|
|
34
|
+
/** Caller cancellation; observe or forward it in async work. */
|
|
35
|
+
signal: AbortSignal;
|
|
36
|
+
callId?: string;
|
|
37
|
+
agent?: ExecAgent;
|
|
38
|
+
}
|
|
39
|
+
/** The agent slice of exec this plugin reads (session cwd) or passes on (owner). */
|
|
40
|
+
export interface ExecAgent {
|
|
41
|
+
session: {
|
|
42
|
+
header: {
|
|
43
|
+
cwd?: string;
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
export interface ToolResult {
|
|
48
|
+
content: ContentBlock[];
|
|
49
|
+
isError?: boolean;
|
|
50
|
+
}
|
|
51
|
+
/** Tool output view handed to presentResult. */
|
|
52
|
+
export interface CallView {
|
|
53
|
+
card: string;
|
|
54
|
+
[key: string]: unknown;
|
|
55
|
+
}
|
|
56
|
+
/** A fully specified tool: schema, canonical output, body, presentations. */
|
|
57
|
+
export interface ToolSpec<TValue> {
|
|
58
|
+
name: string;
|
|
59
|
+
description: string;
|
|
60
|
+
parameters: ToolParameterMap;
|
|
61
|
+
output: {
|
|
62
|
+
schema: JsonSchemaNode;
|
|
63
|
+
render: (args: unknown, value: TValue) => ContentBlock[];
|
|
64
|
+
};
|
|
65
|
+
execute: (args: Record<string, unknown>, exec: ToolRunContext) => Promise<TValue>;
|
|
66
|
+
presentCall?: (args: Record<string, unknown>) => CallView;
|
|
67
|
+
presentResult?: (args: Record<string, unknown>, result: ToolResult) => CallView | undefined;
|
|
68
|
+
}
|
|
69
|
+
/** Canonical output declaration, erased of the tool's value type (registry face). */
|
|
70
|
+
export interface ToolOutputDefinition {
|
|
71
|
+
schema: JsonSchemaNode;
|
|
72
|
+
render: (args: unknown, value: unknown) => ContentBlock[];
|
|
73
|
+
}
|
|
74
|
+
/** What defineTool hands back (opaque to the plugin; registered as-is). */
|
|
75
|
+
export interface ToolDefinition {
|
|
76
|
+
name: string;
|
|
77
|
+
description: string;
|
|
78
|
+
parameters: ToolParameters;
|
|
79
|
+
output: ToolOutputDefinition;
|
|
80
|
+
execute: (args: Record<string, unknown>, exec: ToolRunContext) => Promise<unknown>;
|
|
81
|
+
}
|
|
82
|
+
export interface LoggerSeam {
|
|
83
|
+
info?: (message: string) => void;
|
|
84
|
+
warn?: (message: string) => void;
|
|
85
|
+
error?: (message: string) => void;
|
|
86
|
+
}
|
|
87
|
+
export interface SystemPromptSection {
|
|
88
|
+
name: string;
|
|
89
|
+
order: number;
|
|
90
|
+
text: string;
|
|
91
|
+
}
|
|
92
|
+
export interface SystemPromptSeam {
|
|
93
|
+
section(spec: SystemPromptSection): unknown;
|
|
94
|
+
}
|
|
95
|
+
export interface ToolsSeam {
|
|
96
|
+
register(tool: ToolDefinition): unknown;
|
|
97
|
+
}
|
|
98
|
+
/** A tool entry seen during system-prompt assembly (description re-render). */
|
|
99
|
+
export interface AssembledToolRef {
|
|
100
|
+
name: string;
|
|
101
|
+
description?: string;
|
|
102
|
+
}
|
|
103
|
+
export interface PromptAssembly {
|
|
104
|
+
tools: AssembledToolRef[];
|
|
105
|
+
[key: string]: unknown;
|
|
106
|
+
}
|
|
107
|
+
/** Type of the system-prompt/assemble waterfall listener. */
|
|
108
|
+
export type AssembleHandler = (assembly: PromptAssembly, context: unknown, next: () => Promise<PromptAssembly>) => Promise<PromptAssembly>;
|
|
109
|
+
export interface ShellEnvSeam {
|
|
110
|
+
collect(exec: ToolRunContext): Record<string, string> | undefined;
|
|
111
|
+
}
|
|
112
|
+
export interface SettingsScope<T> {
|
|
113
|
+
get(): T;
|
|
114
|
+
}
|
|
115
|
+
export interface SettingsSeam {
|
|
116
|
+
register<T>(namespace: string, schema: unknown, options: {
|
|
117
|
+
base: T;
|
|
118
|
+
}): SettingsScope<T>;
|
|
119
|
+
}
|
|
120
|
+
export interface SandboxPolicy {
|
|
121
|
+
mode: string;
|
|
122
|
+
workspaceRoot?: string;
|
|
123
|
+
sessionId?: string;
|
|
124
|
+
}
|
|
125
|
+
export interface SandboxPolicySeam {
|
|
126
|
+
resolve(scope: {
|
|
127
|
+
session?: unknown;
|
|
128
|
+
}): SandboxPolicy;
|
|
129
|
+
}
|
|
130
|
+
export interface SandboxConfineResult {
|
|
131
|
+
argv: string[];
|
|
132
|
+
enforcement: string;
|
|
133
|
+
denialSignatures?: string[];
|
|
134
|
+
}
|
|
135
|
+
export interface SandboxSeam {
|
|
136
|
+
confine(argv: string[], policy: SandboxPolicy): SandboxConfineResult;
|
|
137
|
+
}
|
|
138
|
+
/** Sandbox facts embedded in a canonical result. */
|
|
139
|
+
export interface SandboxFacts {
|
|
140
|
+
mode: string;
|
|
141
|
+
enforcement: string;
|
|
142
|
+
denialSignatures?: string[];
|
|
143
|
+
denied?: boolean;
|
|
144
|
+
}
|
|
145
|
+
export interface EscalationRequest {
|
|
146
|
+
requestedMode: string;
|
|
147
|
+
justification: string;
|
|
148
|
+
effectiveMode: string;
|
|
149
|
+
subject: string;
|
|
150
|
+
}
|
|
151
|
+
export interface EscalationContext {
|
|
152
|
+
approver?: unknown;
|
|
153
|
+
agent?: unknown;
|
|
154
|
+
callId?: string;
|
|
155
|
+
toolName: string;
|
|
156
|
+
signal: AbortSignal;
|
|
157
|
+
}
|
|
158
|
+
export interface JobHooks {
|
|
159
|
+
cancel: () => void;
|
|
160
|
+
done: Promise<unknown>;
|
|
161
|
+
readOutput: () => string;
|
|
162
|
+
}
|
|
163
|
+
export interface JobSpec {
|
|
164
|
+
kind: string;
|
|
165
|
+
label: string;
|
|
166
|
+
owner?: unknown;
|
|
167
|
+
run: () => JobHooks;
|
|
168
|
+
}
|
|
169
|
+
export interface JobsRegistry {
|
|
170
|
+
start(spec: JobSpec): string;
|
|
171
|
+
}
|
|
172
|
+
/** Executable paths per backend; undefined when a backend is not installed. */
|
|
173
|
+
export interface ResolvedPaths {
|
|
174
|
+
pwsh?: string;
|
|
175
|
+
gitbash?: string;
|
|
176
|
+
msys2?: string;
|
|
177
|
+
wsl?: string;
|
|
178
|
+
}
|
|
179
|
+
export interface CollectSpec {
|
|
180
|
+
maxBytes: number;
|
|
181
|
+
spill: {
|
|
182
|
+
maxBytes: number;
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
export interface StdioSpec {
|
|
186
|
+
stdin: {
|
|
187
|
+
data: string;
|
|
188
|
+
} | "ignore";
|
|
189
|
+
stdout: CollectSpec;
|
|
190
|
+
stderr: CollectSpec;
|
|
191
|
+
}
|
|
192
|
+
export interface SubprocessSpawnSpec {
|
|
193
|
+
argv: string[];
|
|
194
|
+
cwd?: string;
|
|
195
|
+
stdio: StdioSpec;
|
|
196
|
+
graceMs: number;
|
|
197
|
+
signal?: AbortSignal;
|
|
198
|
+
env?: Record<string, string | undefined>;
|
|
199
|
+
}
|
|
200
|
+
export interface CollectedStream {
|
|
201
|
+
readFrom(offset: number): {
|
|
202
|
+
text: string;
|
|
203
|
+
lossy: boolean;
|
|
204
|
+
nextOffset: number;
|
|
205
|
+
spillPath?: string;
|
|
206
|
+
};
|
|
207
|
+
}
|
|
208
|
+
export interface SubprocessOutcome {
|
|
209
|
+
exitCode: number | null;
|
|
210
|
+
signal: string | null;
|
|
211
|
+
}
|
|
212
|
+
export interface SubprocessHandle {
|
|
213
|
+
collected: {
|
|
214
|
+
stdout: CollectedStream;
|
|
215
|
+
stderr: CollectedStream;
|
|
216
|
+
};
|
|
217
|
+
done: Promise<SubprocessOutcome>;
|
|
218
|
+
terminate: () => void | Promise<void>;
|
|
219
|
+
}
|
|
220
|
+
export interface TerminalSpawnSpec {
|
|
221
|
+
argv: string[];
|
|
222
|
+
cwd: string;
|
|
223
|
+
env: Record<string, string | undefined>;
|
|
224
|
+
rows: number;
|
|
225
|
+
cols: number;
|
|
226
|
+
graceMs?: number;
|
|
227
|
+
}
|
|
228
|
+
export interface TerminalHandle {
|
|
229
|
+
pid: number;
|
|
230
|
+
output: NodeJS.ReadableStream;
|
|
231
|
+
done: Promise<SubprocessOutcome>;
|
|
232
|
+
write(data: string): void | Promise<void>;
|
|
233
|
+
signalForeground(sig: string): void | Promise<unknown>;
|
|
234
|
+
terminate(): Promise<void>;
|
|
235
|
+
}
|
|
236
|
+
export interface SubprocessSeam {
|
|
237
|
+
spawn(spec: SubprocessSpawnSpec): SubprocessHandle;
|
|
238
|
+
spawnTerminal?(spec: TerminalSpawnSpec): Promise<TerminalHandle>;
|
|
239
|
+
}
|
|
240
|
+
export interface ApprovalSeam {
|
|
241
|
+
request(input: unknown): Promise<unknown>;
|
|
242
|
+
}
|
|
243
|
+
/**
|
|
244
|
+
* The structural context face dsh-bash-terminal-ts programs against: the union
|
|
245
|
+
* of every `ctx.*` member touched by src/index.ts and src/terminal.ts.
|
|
246
|
+
*/
|
|
247
|
+
export interface BashTerminalContext {
|
|
248
|
+
logger?: LoggerSeam;
|
|
249
|
+
systemPrompt: SystemPromptSeam;
|
|
250
|
+
tools: ToolsSeam;
|
|
251
|
+
on(event: "system-prompt/assemble", handler: AssembleHandler): void;
|
|
252
|
+
shellEnv: ShellEnvSeam;
|
|
253
|
+
settings: SettingsSeam;
|
|
254
|
+
sandboxPolicy: SandboxPolicySeam;
|
|
255
|
+
sandbox: SandboxSeam;
|
|
256
|
+
get(key: string): unknown;
|
|
257
|
+
effect(fn: () => void | (() => void), name?: string): unknown;
|
|
258
|
+
/** Injected via `inject: ["subprocess"]`; tests may defer assignment. */
|
|
259
|
+
subprocess: SubprocessSeam | null;
|
|
260
|
+
}
|
package/lib/dsh.d.ts
CHANGED
|
@@ -1,33 +1,33 @@
|
|
|
1
|
-
import { HarnessError } from "@deepseek-ai/dsh-llm";
|
|
2
|
-
import { parseExitStatus } from "@deepseek-ai/dsh-shell";
|
|
3
|
-
import { clampTimeout, deadline, timeoutOf } from "@deepseek-ai/dsh-timeout";
|
|
4
|
-
import type { EscalationContext, EscalationRequest, JsonSchemaNode, ToolDefinition, ToolSpec } from "./dsh-types.js";
|
|
5
|
-
export { HarnessError, parseExitStatus, clampTimeout, deadline, timeoutOf };
|
|
6
|
-
/** Wrap a fully specified tool spec into a registrable tool definition. */
|
|
7
|
-
export declare const defineTool: <TValue>(spec: ToolSpec<TValue>) => ToolDefinition;
|
|
8
|
-
/** Sentinel code stamped on aborted tool calls. */
|
|
9
|
-
export declare const TOOL_ABORTED: string;
|
|
10
|
-
/** Escalation modes advertised by the official sandbox seam. */
|
|
11
|
-
export declare const ESCALATION_TARGETS: readonly string[];
|
|
12
|
-
/** Official sandbox escalation (mirrors dsh-tool-bash / dsh-tool-pwsh). */
|
|
13
|
-
export declare const approveEscalation: (request: EscalationRequest, context: EscalationContext) => Promise<string>;
|
|
14
|
-
/** Fail-closed validation of the sandbox_permissions / justification pair. */
|
|
15
|
-
export declare const validateEscalationArgs: (permissions: unknown, justification: unknown) => void;
|
|
16
|
-
/** Marker appended to denied results so the UI can offer escalation. */
|
|
17
|
-
export declare const sandboxDenialMarker: (mode: string) => string;
|
|
18
|
-
/** Marker appended to denied results pointing at the escalation affordance. */
|
|
19
|
-
export declare const escalationHintMarker: (subject: string) => string;
|
|
20
|
-
/** Runtime config schema factory (schemastery fork). */
|
|
21
|
-
export interface SchemasterySchema {
|
|
22
|
-
default(value: unknown): SchemasterySchema;
|
|
23
|
-
}
|
|
24
|
-
export interface Schemastery {
|
|
25
|
-
object(fields: Record<string, SchemasterySchema>): SchemasterySchema;
|
|
26
|
-
string(): SchemasterySchema;
|
|
27
|
-
number(): SchemasterySchema;
|
|
28
|
-
const(value: string): SchemasterySchema;
|
|
29
|
-
union(schemas: SchemasterySchema[]): SchemasterySchema;
|
|
30
|
-
}
|
|
31
|
-
export declare const z: Schemastery;
|
|
32
|
-
/** Re-exported for consumers that want to validate output schemas. */
|
|
33
|
-
export type { JsonSchemaNode };
|
|
1
|
+
import { HarnessError } from "@deepseek-ai/dsh-llm";
|
|
2
|
+
import { parseExitStatus } from "@deepseek-ai/dsh-shell";
|
|
3
|
+
import { clampTimeout, deadline, timeoutOf } from "@deepseek-ai/dsh-timeout";
|
|
4
|
+
import type { EscalationContext, EscalationRequest, JsonSchemaNode, ToolDefinition, ToolSpec } from "./dsh-types.js";
|
|
5
|
+
export { HarnessError, parseExitStatus, clampTimeout, deadline, timeoutOf };
|
|
6
|
+
/** Wrap a fully specified tool spec into a registrable tool definition. */
|
|
7
|
+
export declare const defineTool: <TValue>(spec: ToolSpec<TValue>) => ToolDefinition;
|
|
8
|
+
/** Sentinel code stamped on aborted tool calls. */
|
|
9
|
+
export declare const TOOL_ABORTED: string;
|
|
10
|
+
/** Escalation modes advertised by the official sandbox seam. */
|
|
11
|
+
export declare const ESCALATION_TARGETS: readonly string[];
|
|
12
|
+
/** Official sandbox escalation (mirrors dsh-tool-bash / dsh-tool-pwsh). */
|
|
13
|
+
export declare const approveEscalation: (request: EscalationRequest, context: EscalationContext) => Promise<string>;
|
|
14
|
+
/** Fail-closed validation of the sandbox_permissions / justification pair. */
|
|
15
|
+
export declare const validateEscalationArgs: (permissions: unknown, justification: unknown) => void;
|
|
16
|
+
/** Marker appended to denied results so the UI can offer escalation. */
|
|
17
|
+
export declare const sandboxDenialMarker: (mode: string) => string;
|
|
18
|
+
/** Marker appended to denied results pointing at the escalation affordance. */
|
|
19
|
+
export declare const escalationHintMarker: (subject: string) => string;
|
|
20
|
+
/** Runtime config schema factory (schemastery fork). */
|
|
21
|
+
export interface SchemasterySchema {
|
|
22
|
+
default(value: unknown): SchemasterySchema;
|
|
23
|
+
}
|
|
24
|
+
export interface Schemastery {
|
|
25
|
+
object(fields: Record<string, SchemasterySchema>): SchemasterySchema;
|
|
26
|
+
string(): SchemasterySchema;
|
|
27
|
+
number(): SchemasterySchema;
|
|
28
|
+
const(value: string): SchemasterySchema;
|
|
29
|
+
union(schemas: SchemasterySchema[]): SchemasterySchema;
|
|
30
|
+
}
|
|
31
|
+
export declare const z: Schemastery;
|
|
32
|
+
/** Re-exported for consumers that want to validate output schemas. */
|
|
33
|
+
export type { JsonSchemaNode };
|