@vincemakes/kiso-tools-node 0.45.3 → 0.46.0
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/README.md +7 -0
- package/dist/index.d.ts +99 -2
- package/dist/index.js +360 -206
- package/dist/process-backend.d.ts +26 -0
- package/dist/process-backend.js +70 -0
- package/dist/process.d.ts +81 -0
- package/dist/process.js +375 -0
- package/dist/task-runner.d.ts +32 -0
- package/dist/task-runner.js +189 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -5,4 +5,11 @@ read_file, list_dir, search_text (idempotent reads), write_file,
|
|
|
5
5
|
edit_file (safe replacement — external hard links are never
|
|
6
6
|
overwritten), and shell (process-tree kill on timeout/abort).
|
|
7
7
|
|
|
8
|
+
Background tasks (ADR-0058): pass `tasks: (sessionId) => …` — the
|
|
9
|
+
runtime's per-session `TaskManager`, with `processTaskBackend()` — and the
|
|
10
|
+
shell promotes a command that outlives `foregroundMs` to a task instead of
|
|
11
|
+
killing it, starts one at once with `background: true`, ends its wait on
|
|
12
|
+
`readyWhen`; `task_stop` joins the tools and `read_file` serves the
|
|
13
|
+
session's task outputs. Without `tasks`, the shell is unchanged.
|
|
14
|
+
|
|
8
15
|
See the repository README for the framework overview.
|
package/dist/index.d.ts
CHANGED
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
* states what was dropped (deterministic per file state), so the model
|
|
18
18
|
* always has a path to the full content.
|
|
19
19
|
*/
|
|
20
|
-
import { type Tool, type ToolResult } from "@vincemakes/kiso-core";
|
|
20
|
+
import { type AbortSignalLike, type Tool, type ToolResult } from "@vincemakes/kiso-core";
|
|
21
21
|
/**
|
|
22
22
|
* TUI2-R1 (C) — THE SHELL PROGRESS SIDECAR.
|
|
23
23
|
*
|
|
@@ -106,6 +106,17 @@ export interface WorkspaceToolsOptions {
|
|
|
106
106
|
* secrets — so it says so. Ignored when `shellEnv` is "inherit", which is
|
|
107
107
|
* an explicit opt-in to the whole environment. */
|
|
108
108
|
readonly secretEnvNames?: readonly string[];
|
|
109
|
+
/** ADR-0058 §4: read-only roots `read_file` may also serve, by ABSOLUTE
|
|
110
|
+
* path and only inside them — a session's task outputs. Nothing else
|
|
111
|
+
* widens: every other tool, and every relative path, stays inside the
|
|
112
|
+
* workspace. */
|
|
113
|
+
readonly extraReadRoots?: readonly string[];
|
|
114
|
+
/** ADR-0058 (3b): the session's tasks. With them the shell promotes a
|
|
115
|
+
* command that outlives its wait instead of killing it, can start one
|
|
116
|
+
* in the background, `task_stop` joins the tools, and `read_file`
|
|
117
|
+
* serves the session's task outputs. Absent: today's shell, its schema
|
|
118
|
+
* byte for byte. */
|
|
119
|
+
readonly tasks?: (sessionId: string | undefined) => ShellTasks | undefined;
|
|
109
120
|
/**
|
|
110
121
|
* DC-54 — the bounds that keep a tool call finite. Every field is
|
|
111
122
|
* optional and defaults to the constant beside it; a host embedding
|
|
@@ -188,9 +199,95 @@ export { PROTECTED_REFUSAL, diskPath, isProtectedPath, protectedIdentity, protec
|
|
|
188
199
|
* read-only shell allow holds a shell read to the same definition rather
|
|
189
200
|
* than a copy of it. */
|
|
190
201
|
export { isCredentialName, isCredentialPath } from "./corpus.js";
|
|
191
|
-
export
|
|
202
|
+
export { processTaskBackend, type ProcessTaskBackend, type ProcessTaskBackendOptions } from "./process-backend.js";
|
|
203
|
+
/**
|
|
204
|
+
* ADR-0058 (3b): a session's tasks, as the shell and `task_stop` reach them.
|
|
205
|
+
* The runtime's TaskManager satisfies it structurally; the host hands one
|
|
206
|
+
* per session (tools-node takes no dependency on the runtime).
|
|
207
|
+
*/
|
|
208
|
+
export interface ShellTasks {
|
|
209
|
+
/** `<store root>/<session>.tasks` — read_file serves it. */
|
|
210
|
+
readonly root: string;
|
|
211
|
+
/** `background: true` — a runner owns the command (it survives kiso). */
|
|
212
|
+
start(spec: {
|
|
213
|
+
readonly command: string;
|
|
214
|
+
readonly cwd: string;
|
|
215
|
+
readonly env?: Readonly<Record<string, string | undefined>>;
|
|
216
|
+
readonly executionId?: string;
|
|
217
|
+
readonly readyWhen?: string;
|
|
218
|
+
readonly profile?: "oneshot" | "service";
|
|
219
|
+
}): Promise<{
|
|
220
|
+
readonly id: string;
|
|
221
|
+
readonly outputPath: string;
|
|
222
|
+
}>;
|
|
223
|
+
/** A promotion: the running child becomes a task this process owns. */
|
|
224
|
+
adopt(spec: {
|
|
225
|
+
readonly command: string;
|
|
226
|
+
readonly cwd: string;
|
|
227
|
+
readonly executionId?: string;
|
|
228
|
+
readonly readyWhen?: string;
|
|
229
|
+
readonly runner: {
|
|
230
|
+
readonly pid: number;
|
|
231
|
+
readonly startedAt: string;
|
|
232
|
+
};
|
|
233
|
+
readonly ready?: boolean;
|
|
234
|
+
readonly stop: () => void;
|
|
235
|
+
}): {
|
|
236
|
+
readonly id: string;
|
|
237
|
+
readonly outputPath: string;
|
|
238
|
+
ready(match: string): void;
|
|
239
|
+
ended(exitCode: number | null, signal: string | null): void;
|
|
240
|
+
unconfirmed(pids: readonly number[]): void;
|
|
241
|
+
};
|
|
242
|
+
stop(id: string, by: "model"): boolean;
|
|
243
|
+
get(id: string): {
|
|
244
|
+
readonly state: {
|
|
245
|
+
readonly kind: string;
|
|
246
|
+
};
|
|
247
|
+
} | undefined;
|
|
248
|
+
/** ADR-0058 Amendment 7: wait for a task's end (or ready line) that this
|
|
249
|
+
* call's result will report; what it sees is claimed for `executionId`,
|
|
250
|
+
* so it is never noticed. Without it the calls return at once (today's
|
|
251
|
+
* results, a notice to follow). */
|
|
252
|
+
awaitSettled?(id: string, until: "end" | "ready", ms: number, opts: {
|
|
253
|
+
readonly executionId?: string;
|
|
254
|
+
readonly signal?: AbortSignalLike;
|
|
255
|
+
}): Promise<{
|
|
256
|
+
readonly info: SettledTask;
|
|
257
|
+
readonly settled: boolean;
|
|
258
|
+
readonly claimed: boolean;
|
|
259
|
+
}>;
|
|
260
|
+
/** 3e: a running foreground command that can be moved to the background
|
|
261
|
+
* now (the person's key, a steer) — registered while it runs. */
|
|
262
|
+
registerDetachable?(executionId: string, detachable: {
|
|
263
|
+
readonly startedAt: number;
|
|
264
|
+
detach(by: "person" | "steer"): void;
|
|
265
|
+
}): () => void;
|
|
266
|
+
}
|
|
267
|
+
/** What a settled wait reports about its task. */
|
|
268
|
+
interface SettledTask {
|
|
269
|
+
readonly state: {
|
|
270
|
+
readonly kind: string;
|
|
271
|
+
readonly ready?: boolean;
|
|
272
|
+
readonly exitCode?: number | null;
|
|
273
|
+
readonly signal?: string | null;
|
|
274
|
+
readonly error?: string;
|
|
275
|
+
};
|
|
276
|
+
readonly outputPath: string;
|
|
277
|
+
readonly startedAt: number;
|
|
278
|
+
readonly endedAt?: number;
|
|
279
|
+
}
|
|
280
|
+
type ShellInput = {
|
|
192
281
|
command: string;
|
|
193
282
|
timeoutMs?: number;
|
|
283
|
+
foregroundMs?: number;
|
|
284
|
+
background?: boolean;
|
|
285
|
+
readyWhen?: string;
|
|
286
|
+
};
|
|
287
|
+
export declare function shellTool(opts: WorkspaceToolsOptions): Tool<ShellInput>;
|
|
288
|
+
/** ADR-0058 §4: stop a task this session started — its whole process group. */
|
|
289
|
+
export declare function taskStopTool(opts: WorkspaceToolsOptions): Tool<{
|
|
290
|
+
id: string;
|
|
194
291
|
}>;
|
|
195
292
|
/** The full coding toolset, bound to one workspace root (Area 5). */
|
|
196
293
|
export declare function createCodingTools(opts: WorkspaceToolsOptions): readonly Tool<any>[];
|