@hydraharness/harness-tool-bash-persistent 0.1.1-rc.6

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 ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 DeepSeek
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,49 @@
1
+ # @hydraharness/harness-tool-bash-persistent
2
+
3
+ Model-facing `bash(command)` backed by one owner-scoped `ctx.terminals` shell. The package owns the tool contract and shell reuse; deployments select the PTY backend and sandbox policy.
4
+
5
+ ## Config
6
+
7
+ | Key | Default | Meaning |
8
+ |---|---:|---|
9
+ | `backendType` | `shell` | Registered PTY backend used for each Agent shell. |
10
+ | `timeoutMs` | `300000` | Wall-clock limit for one command; timeout closes the shell. |
11
+ | `maxOutputChars` | `16000` | Maximum retained command-output characters; fixed diagnostics are added afterward. |
12
+ | `description` | Persistent-shell description | Model-facing environment contract. |
13
+
14
+ ## Model Experience
15
+
16
+ ### Tool schema
17
+
18
+ #### What the model sees
19
+
20
+ The generated [`bash` schema](../../../docs/tool-catalog.md#hydraharness-tool-bash-persistent), including the configured `description`. The plugin contributes no standalone system-prompt section; the deployment owns persona and environment guidance.
21
+
22
+ #### Token effect
23
+
24
+ Fixed schema cost while `bash` is visible.
25
+
26
+ #### KV Cache effect
27
+
28
+ Prefix-stable while the configured description and schema remain unchanged.
29
+
30
+ ### Tool results
31
+
32
+ #### What the model sees
33
+
34
+ Commands share one shell per Agent, so cwd, exported variables, activated environments, functions, and background jobs persist across calls. Results exclude private completion markers. When the shell reads stdin again without having printed the completion marker — after `exec`, an interrupt, or an interactive foreground child whose stdin wait the provider proves — the call returns the captured partial output, which can end with the backend's own prompt text. A nonzero wrapped command appends `[exit code: N]`; a shell that exits before reporting that status instead appends `[shell exited: code N]`, `[shell killed by signal: SIG]`, or `[shell exited]` when the backend supplies neither, then resets and tells the model that the next call starts fresh. Long output keeps the earliest retained prefix plus a clipping notice. If the PTY has already dropped that prefix, the result says so explicitly instead of presenting a tail as complete output. Timeout returns bounded partial output, closes the uncertain shell, and reports the reset.
35
+
36
+ #### Token effect
37
+
38
+ Data-dependent. `maxOutputChars` bounds retained command output; fixed clipping, lost-prefix, status, timeout, and reset diagnostics can extend the result.
39
+
40
+ #### KV Cache effect
41
+
42
+ Append-only tool results follow the reusable request prefix.
43
+
44
+ ## Known Limitations and Deferred Work
45
+
46
+ - The tool requires an owning Agent and a real PTY backend.
47
+ - An interactive foreground child (for example a REPL) returns early with partial output only where the subprocess provider proves its stdin wait; elsewhere the call runs to `timeoutMs`.
48
+ - Explicit `exit` and timeout discard shell state. Cancellation also resets and discards the result, even when a complete status marker is already observable; the next call starts a fresh shell.
49
+ - Environment facts such as network access and package mirrors belong in the configured `description`, not this package's default.
package/lib/index.js ADDED
@@ -0,0 +1,382 @@
1
+ import { randomUUID } from "node:crypto";
2
+ import z from "@hydraharness/schemastery";
3
+ import { deadline, timeoutOf } from "@hydraharness/harness-timeout";
4
+ import { defineTool } from "@hydraharness/harness-tools";
5
+ //#region lib/types/index.js
6
+ /**
7
+ * Model-facing persistent `bash` tool over the owner-scoped PTY seam.
8
+ * @module @hydraharness/harness-tool-bash-persistent
9
+ */
10
+ var __addDisposableResource = function(env, value, async) {
11
+ if (value !== null && value !== void 0) {
12
+ if (typeof value !== "object" && typeof value !== "function") throw new TypeError("Object expected.");
13
+ var dispose, inner;
14
+ if (async) {
15
+ if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined.");
16
+ dispose = value[Symbol.asyncDispose];
17
+ }
18
+ if (dispose === void 0) {
19
+ if (!Symbol.dispose) throw new TypeError("Symbol.dispose is not defined.");
20
+ dispose = value[Symbol.dispose];
21
+ if (async) inner = dispose;
22
+ }
23
+ if (typeof dispose !== "function") throw new TypeError("Object not disposable.");
24
+ if (inner) dispose = function() {
25
+ try {
26
+ inner.call(this);
27
+ } catch (e) {
28
+ return Promise.reject(e);
29
+ }
30
+ };
31
+ env.stack.push({
32
+ value,
33
+ dispose,
34
+ async
35
+ });
36
+ } else if (async) env.stack.push({ async: true });
37
+ return value;
38
+ };
39
+ var __disposeResources = (function(SuppressedError) {
40
+ return function(env) {
41
+ function fail(e) {
42
+ env.error = env.hasError ? new SuppressedError(e, env.error, "An error was suppressed during disposal.") : e;
43
+ env.hasError = true;
44
+ }
45
+ var r, s = 0;
46
+ function next() {
47
+ while (r = env.stack.pop()) try {
48
+ if (!r.async && s === 1) return s = 0, env.stack.push(r), Promise.resolve().then(next);
49
+ if (r.dispose) {
50
+ var result = r.dispose.call(r.value);
51
+ if (r.async) return s |= 2, Promise.resolve(result).then(next, function(e) {
52
+ fail(e);
53
+ return next();
54
+ });
55
+ } else s |= 1;
56
+ } catch (e) {
57
+ fail(e);
58
+ }
59
+ if (s === 1) return env.hasError ? Promise.reject(env.error) : Promise.resolve();
60
+ if (env.hasError) throw env.error;
61
+ }
62
+ return next();
63
+ };
64
+ })(typeof SuppressedError === "function" ? SuppressedError : function(error, suppressed, message) {
65
+ var e = new Error(message);
66
+ return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
67
+ });
68
+ const TRUNCATED_MESSAGE = "<response clipped><NOTE>To save on context only part of this file has been shown to you. You should retry this tool after you have searched inside the file with `grep -n` in order to find the line numbers of what you are looking for.</NOTE>";
69
+ const LOST_PREFIX_MESSAGE = "<response clipped><NOTE>The beginning of this command output was dropped by the terminal scrollback limit. The following text is the earliest retained output.</NOTE>\n";
70
+ const SHELL_RESET_MESSAGE = "The persistent bash shell was reset; the next bash call starts from the workspace with a fresh current directory and environment.";
71
+ const TIMEOUT_CODE = "PERSISTENT_BASH_TIMEOUT";
72
+ const SCROLLBACK_PAGE_LINES = 1e3;
73
+ const POLL_INTERVAL_MS = 25;
74
+ const DEFAULT_DESCRIPTION = "Run commands in a persistent bash shell. State, including the current directory and exported environment variables, persists across calls for this agent.";
75
+ function maybeTruncate(content, maxOutputChars, incomplete = false) {
76
+ if (content.length <= maxOutputChars && !incomplete) return content;
77
+ return content.length <= maxOutputChars ? content + TRUNCATED_MESSAGE : content.slice(0, maxOutputChars) + TRUNCATED_MESSAGE;
78
+ }
79
+ function markers() {
80
+ const nonce = randomUUID();
81
+ return {
82
+ start: `__HYDRA_PERSISTENT_BASH_START_${nonce}__`,
83
+ end: `__HYDRA_PERSISTENT_BASH_END_${nonce}:`
84
+ };
85
+ }
86
+ function quoteForBash(value) {
87
+ return `$'${value.replaceAll("\\", "\\\\").replaceAll("'", "\\'").replaceAll("\r", "\\r").replaceAll("\n", "\\n")}'`;
88
+ }
89
+ function wrapCommand(command, marker) {
90
+ return `printf '%s\\n' ${quoteForBash(marker.start)}; eval -- ${quoteForBash(command)}; __hydra_persistent_bash_status=$?; printf '%s%s\\n' ${quoteForBash(marker.end)} "$__hydra_persistent_bash_status"`;
91
+ }
92
+ function trimTrailingNewline(text) {
93
+ return text.replace(/\r?\n$/, "");
94
+ }
95
+ function commandOutput(snapshot, marker) {
96
+ const text = snapshot.text;
97
+ const end = text.lastIndexOf(marker.end);
98
+ const status = /^(\d+)\r?\n/.exec(text.slice(end + marker.end.length))?.[1];
99
+ if (status === void 0) return void 0;
100
+ const startMarker = text.lastIndexOf(marker.start, end);
101
+ const start = startMarker < 0 ? 0 : startMarker + marker.start.length;
102
+ return {
103
+ text: trimTrailingNewline(text.slice(start, end).replace(/^\r?\n/, "")),
104
+ incomplete: startMarker < 0,
105
+ exitCode: Number(status)
106
+ };
107
+ }
108
+ function partialOutput(snapshot, marker, fallback, fallbackTruncated = false) {
109
+ const startMarker = snapshot.text.lastIndexOf(marker.start);
110
+ if (startMarker >= 0) return {
111
+ text: trimTrailingNewline(snapshot.text.slice(startMarker + marker.start.length).replace(/^\r?\n/, "")),
112
+ incomplete: false
113
+ };
114
+ const fallbackStart = fallback.lastIndexOf(marker.start);
115
+ const afterStart = fallbackStart < 0 ? fallback : fallback.slice(fallbackStart + marker.start.length).replace(/^\r?\n/, "");
116
+ const fallbackEnd = afterStart.lastIndexOf(marker.end);
117
+ return {
118
+ text: trimTrailingNewline(fallbackEnd < 0 ? afterStart : afterStart.slice(0, fallbackEnd)),
119
+ incomplete: fallbackTruncated || fallbackStart < 0
120
+ };
121
+ }
122
+ async function pause() {
123
+ await new Promise((resolve) => setTimeout(resolve, POLL_INTERVAL_MS));
124
+ }
125
+ function nextScrollbackOffset(page, offset) {
126
+ if (page.text.length === 0 || page.lineEnd <= offset) return void 0;
127
+ return page.lineEnd;
128
+ }
129
+ function retainedScrollback(ctx, owner, id, latest = ctx.terminals.read(owner, id, {
130
+ offset: 0,
131
+ count: SCROLLBACK_PAGE_LINES
132
+ })) {
133
+ const pages = latest.text.length === 0 ? [] : [latest.text];
134
+ let offset = latest.lineEnd;
135
+ let truncated = latest.truncated;
136
+ while (true) {
137
+ if (offset >= latest.totalLines) break;
138
+ const page = ctx.terminals.read(owner, id, {
139
+ offset,
140
+ count: SCROLLBACK_PAGE_LINES
141
+ });
142
+ truncated ||= page.truncated;
143
+ if (page.text.length > 0) pages.unshift(page.text);
144
+ const next = nextScrollbackOffset(page, offset);
145
+ if (next === void 0 || next >= page.totalLines) break;
146
+ offset = next;
147
+ }
148
+ return {
149
+ text: pages.join("\n"),
150
+ truncated
151
+ };
152
+ }
153
+ function renderCaptured(output, maxOutputChars) {
154
+ const rendered = maybeTruncate(output.text, maxOutputChars, output.incomplete);
155
+ return appendStatusMarker(output.incomplete && output.text.length > 0 ? LOST_PREFIX_MESSAGE + rendered : rendered, output.exitCode !== void 0 && output.exitCode !== 0 ? `[exit code: ${output.exitCode}]` : void 0);
156
+ }
157
+ function appendStatusMarker(content, marker) {
158
+ if (marker === void 0) return content;
159
+ return content.length === 0 ? marker : `${content}\n${marker}`;
160
+ }
161
+ function renderShellExitStatus(content, exitCode, signal) {
162
+ return appendStatusMarker(content, signal !== null ? `[shell killed by signal: ${signal}]` : exitCode !== null ? `[shell exited: code ${exitCode}]` : "[shell exited]");
163
+ }
164
+ /**
165
+ * Render the exited-session result, reset the owner's shell, and reset the
166
+ * message that tells the model the next call starts fresh.
167
+ * @param shells - the owner-scoped registry to reset.
168
+ * @param status - the exited session status (exit code and signal).
169
+ * @returns the complete model-facing result.
170
+ */
171
+ async function respondToSessionExit(ctx, shells, owner, id, status, marker, fallback, fallbackTruncated, config) {
172
+ const snapshot = retainedScrollback(ctx, owner, id);
173
+ await shells.reset(owner, "persistent bash shell exited");
174
+ return [renderShellExitStatus(renderCaptured(partialOutput(snapshot, marker, fallback, fallbackTruncated), config.maxOutputChars), status.exitCode, status.signal), SHELL_RESET_MESSAGE].filter((part) => part.length > 0).join("\n");
175
+ }
176
+ function persistentShells(ctx, config) {
177
+ const pending = /* @__PURE__ */ new WeakMap();
178
+ const live = /* @__PURE__ */ new Map();
179
+ const creating = /* @__PURE__ */ new Set();
180
+ const ownerCleanupInstalled = /* @__PURE__ */ new WeakSet();
181
+ const lifecycle = new AbortController();
182
+ const close = async (owner, id, reason) => {
183
+ if (!ctx.terminals.list(owner).some((snapshot) => snapshot.sessionId === id)) return;
184
+ await ctx.terminals.kill(owner, id, reason);
185
+ };
186
+ ctx.effect(() => async () => {
187
+ lifecycle.abort(/* @__PURE__ */ new Error("tool-bash-persistent disposed during shell creation"));
188
+ await Promise.allSettled([...creating]);
189
+ const closing = [...live].map(async ([owner, id]) => {
190
+ await close(owner, id, "tool-bash-persistent disposed");
191
+ });
192
+ await Promise.all(closing);
193
+ live.clear();
194
+ }, "tool-bash-persistent shell cleanup");
195
+ const reset = async (owner, reason) => {
196
+ pending.delete(owner);
197
+ const id = live.get(owner);
198
+ live.delete(owner);
199
+ if (id !== void 0) await close(owner, id, reason);
200
+ };
201
+ const get = (owner, signal) => {
202
+ const existing = pending.get(owner);
203
+ if (existing !== void 0) return existing;
204
+ const combinedSignal = AbortSignal.any([signal, lifecycle.signal]);
205
+ const tracked = (async () => {
206
+ try {
207
+ const cwd = owner.session.header.cwd;
208
+ const spawned = await ctx.terminals.spawn(owner, {
209
+ type: config.backendType,
210
+ ...cwd === void 0 ? {} : { cwd }
211
+ }, combinedSignal);
212
+ live.set(owner, spawned.sessionId);
213
+ if (!ownerCleanupInstalled.has(owner)) {
214
+ ownerCleanupInstalled.add(owner);
215
+ owner.ctx.effect(() => () => {
216
+ pending.delete(owner);
217
+ live.delete(owner);
218
+ }, "tool-bash-persistent owner cache cleanup");
219
+ }
220
+ const result = await ctx.terminals.startSend(owner, spawned.sessionId, {
221
+ text: "stty -echo",
222
+ submit: true,
223
+ signal: combinedSignal
224
+ }).done;
225
+ if (result.sessionStatus.kind === "exited" || result.waitReason === "timeout") throw new Error("persistent bash shell did not accept initialization");
226
+ return spawned.sessionId;
227
+ } catch (error) {
228
+ await reset(owner, "persistent bash initialization failed");
229
+ throw error;
230
+ }
231
+ })().finally(() => {
232
+ creating.delete(tracked);
233
+ });
234
+ creating.add(tracked);
235
+ pending.set(owner, tracked);
236
+ return tracked;
237
+ };
238
+ return {
239
+ get,
240
+ reset
241
+ };
242
+ }
243
+ async function executeCommand(ctx, shells, owner, command, config, upstream) {
244
+ const env_1 = {
245
+ stack: [],
246
+ error: void 0,
247
+ hasError: false
248
+ };
249
+ try {
250
+ const commandDeadline = __addDisposableResource(env_1, deadline(upstream, config.timeoutMs, TIMEOUT_CODE), false);
251
+ const id = await shells.get(owner, commandDeadline.signal);
252
+ const marker = markers();
253
+ const wrapped = wrapCommand(command, marker);
254
+ let first = true;
255
+ let fallback = "";
256
+ let fallbackTruncated = false;
257
+ while (true) {
258
+ const status = ctx.terminals.list(owner).find((session) => session.sessionId === id)?.status;
259
+ if (status?.kind === "exited") return await respondToSessionExit(ctx, shells, owner, id, status, marker, fallback, fallbackTruncated, config);
260
+ let operation;
261
+ let result;
262
+ try {
263
+ operation = ctx.terminals.startSend(owner, id, {
264
+ text: first ? wrapped : "",
265
+ submit: first,
266
+ signal: commandDeadline.signal
267
+ });
268
+ first = false;
269
+ result = await operation.done;
270
+ } catch (error) {
271
+ await shells.reset(owner, "persistent bash send failed");
272
+ throw error;
273
+ }
274
+ const incremental = operation.readOutput();
275
+ fallback = incremental.delta.length > 0 ? fallback + incremental.delta : result.viewport;
276
+ fallbackTruncated ||= incremental.truncated || result.truncated;
277
+ const latest = ctx.terminals.read(owner, id, {
278
+ offset: 0,
279
+ count: SCROLLBACK_PAGE_LINES
280
+ });
281
+ const timedOut = timeoutOf(commandDeadline.signal, TIMEOUT_CODE);
282
+ if (timedOut !== void 0) {
283
+ const partial = renderCaptured(partialOutput(retainedScrollback(ctx, owner, id, latest), marker, fallback, fallbackTruncated), config.maxOutputChars);
284
+ await shells.reset(owner, "persistent bash command timed out");
285
+ return [
286
+ `Your command timed out after ${Math.round(timedOut.timeoutMs / 1e3)} seconds or experienced an OOM error. Below is partial output:`,
287
+ partial,
288
+ SHELL_RESET_MESSAGE
289
+ ].join("\n");
290
+ }
291
+ if (commandDeadline.signal.aborted) {
292
+ await shells.reset(owner, "persistent bash command aborted");
293
+ commandDeadline.signal.throwIfAborted();
294
+ }
295
+ if (latest.text.includes(marker.end)) {
296
+ const complete = commandOutput(retainedScrollback(ctx, owner, id, latest), marker);
297
+ if (complete !== void 0) return renderCaptured(complete, config.maxOutputChars);
298
+ }
299
+ if (result.sessionStatus.kind === "exited") return await respondToSessionExit(ctx, shells, owner, id, result.sessionStatus, marker, fallback, fallbackTruncated, config);
300
+ if (result.waitReason === "stdin_read") return renderCaptured(partialOutput(retainedScrollback(ctx, owner, id, latest), marker, fallback, fallbackTruncated), config.maxOutputChars);
301
+ await pause();
302
+ }
303
+ } catch (e_1) {
304
+ env_1.error = e_1;
305
+ env_1.hasError = true;
306
+ } finally {
307
+ __disposeResources(env_1);
308
+ }
309
+ }
310
+ /**
311
+ * Register the model-facing persistent `bash` tool.
312
+ * @param ctx - plugin context carrying tools and the owner-scoped PTY service.
313
+ * @param config - selected PTY backend and command deadline.
314
+ */
315
+ function registerPersistentBash(ctx, config) {
316
+ const shells = persistentShells(ctx, config);
317
+ const queues = /* @__PURE__ */ new WeakMap();
318
+ const serialized = async (owner, operation) => {
319
+ const run = (queues.get(owner) ?? Promise.resolve()).then(operation, operation);
320
+ const tail = run.then(() => void 0, () => void 0);
321
+ queues.set(owner, tail);
322
+ try {
323
+ return await run;
324
+ } finally {
325
+ if (queues.get(owner) === tail) queues.delete(owner);
326
+ }
327
+ };
328
+ ctx.tools.register(defineTool({
329
+ name: "bash",
330
+ description: config.description,
331
+ parameters: { command: {
332
+ type: "string",
333
+ required: true,
334
+ description: "The bash command to run. Relative path is preferred in the command."
335
+ } },
336
+ output: {
337
+ schema: { type: "string" },
338
+ render: (_args, value) => [{
339
+ type: "text",
340
+ text: value
341
+ }]
342
+ },
343
+ async execute(args, exec) {
344
+ if (args.command.trim().length === 0) throw new Error("command must be a non-empty string");
345
+ const owner = exec.agent;
346
+ if (owner === void 0) throw new Error("bash requires an owning agent session");
347
+ return serialized(owner, async () => {
348
+ exec.signal.throwIfAborted();
349
+ return executeCommand(ctx, shells, owner, args.command, config, exec.signal);
350
+ });
351
+ },
352
+ presentCall: (args) => ({
353
+ card: "terminal",
354
+ title: args.command
355
+ })
356
+ }));
357
+ }
358
+ const name = "tool-bash-persistent";
359
+ const inject = ["tools", "terminals"];
360
+ /** Runtime configuration schema for the persistent Bash tool. */
361
+ const Config = z.object({
362
+ backendType: z.string().default("shell"),
363
+ timeoutMs: z.number().default(3e5),
364
+ maxOutputChars: z.number().default(16e3),
365
+ description: z.string().default(DEFAULT_DESCRIPTION)
366
+ });
367
+ /** Register one owner-scoped persistent `bash` tool. */
368
+ function apply(ctx, config) {
369
+ const resolved = {
370
+ backendType: config.backendType ?? "shell",
371
+ timeoutMs: config.timeoutMs ?? 3e5,
372
+ maxOutputChars: config.maxOutputChars ?? 16e3,
373
+ description: config.description ?? DEFAULT_DESCRIPTION
374
+ };
375
+ if (resolved.backendType.trim().length === 0) throw new Error("tool-bash-persistent: backendType must be non-empty");
376
+ if (!Number.isSafeInteger(resolved.timeoutMs) || resolved.timeoutMs <= 0) throw new Error("tool-bash-persistent: timeoutMs must be a positive safe integer");
377
+ if (!Number.isSafeInteger(resolved.maxOutputChars) || resolved.maxOutputChars <= 0) throw new Error("tool-bash-persistent: maxOutputChars must be a positive safe integer");
378
+ if (resolved.description.trim().length === 0) throw new Error("tool-bash-persistent: description must be non-empty");
379
+ registerPersistentBash(ctx, resolved);
380
+ }
381
+ //#endregion
382
+ export { Config, apply, inject, name };
@@ -0,0 +1,24 @@
1
+ //#region lib/types/invariant.js
2
+ /**
3
+ * Package-owned invariant companion for `@hydraharness/harness-tool-bash-persistent`.
4
+ * @module @hydraharness/harness-tool-bash-persistent/invariant
5
+ */
6
+ const PACKAGE_NAME = "@hydraharness/harness-tool-bash-persistent";
7
+ /** Cordis companion plugin name. */
8
+ const name = "tool-bash-persistent-invariant";
9
+ /** Service required before the companion can reserve package ownership. */
10
+ const inject = ["invariants"];
11
+ /**
12
+ * No runtime invariant: the adapter's private owner-to-shell cache has no
13
+ * observable event or data relation. Lifecycle tests prove its cleanup without
14
+ * adding a public API solely for an invariant.
15
+ */
16
+ const install = () => {};
17
+ /**
18
+ * Register this package's invariant companion.
19
+ * @param ctx - Cordis context carrying the invariant service.
20
+ * @returns the installed registration's disposer after setup succeeds.
21
+ */
22
+ const apply = (ctx) => Promise.resolve(ctx.invariants.register(PACKAGE_NAME, install));
23
+ //#endregion
24
+ export { apply, inject, name };
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Model-facing persistent `bash` tool over the owner-scoped PTY seam.
3
+ * @module @hydraharness/harness-tool-bash-persistent
4
+ */
5
+ import type { Context } from '@hydraharness/cordis';
6
+ import z from '@hydraharness/schemastery';
7
+ export declare const name = "tool-bash-persistent";
8
+ export declare const inject: string[];
9
+ /** Configuration for the persistent Bash tool. */
10
+ export interface Config {
11
+ /** PTY backend used for each owner-isolated persistent shell (default `shell`). */
12
+ backendType?: string;
13
+ /** Wall-clock limit for one command (default 300000). */
14
+ timeoutMs?: number;
15
+ /** Maximum returned command-output characters before clipping (default 16000). */
16
+ maxOutputChars?: number;
17
+ /** Model-facing tool description; deployments may describe their environment. */
18
+ description?: string;
19
+ }
20
+ /** Runtime configuration schema for the persistent Bash tool. */
21
+ export declare const Config: z<Config>;
22
+ /** Register one owner-scoped persistent `bash` tool. */
23
+ export declare function apply(ctx: Context, config: Config): void;
24
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Package-owned invariant companion for `@hydraharness/harness-tool-bash-persistent`.
3
+ * @module @hydraharness/harness-tool-bash-persistent/invariant
4
+ */
5
+ import type { Context } from '@hydraharness/cordis';
6
+ /** Cordis companion plugin name. */
7
+ export declare const name = "tool-bash-persistent-invariant";
8
+ /** Service required before the companion can reserve package ownership. */
9
+ export declare const inject: string[];
10
+ /**
11
+ * Register this package's invariant companion.
12
+ * @param ctx - Cordis context carrying the invariant service.
13
+ * @returns the installed registration's disposer after setup succeeds.
14
+ */
15
+ export declare const apply: (ctx: Context) => Promise<() => void>;
16
+ //# sourceMappingURL=invariant.d.ts.map
package/package.json ADDED
@@ -0,0 +1,66 @@
1
+ {
2
+ "name": "@hydraharness/harness-tool-bash-persistent",
3
+ "description": "Model-facing owner-scoped persistent Bash tool backed by the Harness PTY service",
4
+ "hydra": {
5
+ "plugin": {
6
+ "application": "Let the agent reuse a persistent Bash terminal across commands."
7
+ }
8
+ },
9
+ "version": "0.1.1-rc.6",
10
+ "publishConfig": {
11
+ "access": "public"
12
+ },
13
+ "repository": {
14
+ "type": "git",
15
+ "url": "git+https://github.com/MaiHongPhong1902/Hydra-Harness.git",
16
+ "directory": "packages/shell/tool-bash-persistent"
17
+ },
18
+ "type": "module",
19
+ "main": "lib/index.js",
20
+ "types": "lib/types/index.d.ts",
21
+ "exports": {
22
+ ".": {
23
+ "types": "./lib/types/index.d.ts",
24
+ "default": "./lib/index.js"
25
+ },
26
+ "./invariant": {
27
+ "types": "./lib/types/invariant.d.ts",
28
+ "default": "./lib/invariant.js"
29
+ },
30
+ "./package.json": "./package.json"
31
+ },
32
+ "files": [
33
+ "lib/index.js",
34
+ "lib/invariant.js",
35
+ "lib/types/**/*.d.ts"
36
+ ],
37
+ "license": "MIT",
38
+ "peerDependencies": {
39
+ "@hydraharness/harness-agent": "^0.1.1-rc.6",
40
+ "@hydraharness/harness-terminal": "^0.1.1-rc.6",
41
+ "@hydraharness/harness-tools": "^0.1.1-rc.6",
42
+ "@hydraharness/harness-invariants": "^0.1.1-rc.6",
43
+ "@hydraharness/cordis": "^4.0.2",
44
+ "@hydraharness/harness-timeout": "^0.1.1-rc.6"
45
+ },
46
+ "dependencies": {
47
+ "@hydraharness/schemastery": "^3.18.2"
48
+ },
49
+ "devDependencies": {
50
+ "@hydraharness/cordis-plugin-loader": "^1.0.3",
51
+ "@hydraharness/cordis-plugin-include": "^1.0.7",
52
+ "@hydraharness/harness-agent": "^0.1.1-rc.6",
53
+ "@hydraharness/harness-llm": "^0.1.1-rc.6",
54
+ "@hydraharness/harness-invariants": "^0.1.1-rc.6",
55
+ "@hydraharness/harness-terminal": "^0.1.1-rc.6",
56
+ "@hydraharness/harness-terminal-bash": "^0.1.1-rc.6",
57
+ "@hydraharness/harness-subprocess-local": "^0.1.1-rc.6",
58
+ "@hydraharness/harness-system-prompt": "^0.1.1-rc.6",
59
+ "@hydraharness/harness-sandbox-policy": "^0.1.1-rc.6",
60
+ "@hydraharness/harness-timeout": "^0.1.1-rc.6",
61
+ "@hydraharness/harness-sandbox": "^0.1.1-rc.6",
62
+ "@hydraharness/harness-tools": "^0.1.1-rc.6",
63
+ "@hydraharness/harness-session": "^0.1.1-rc.6",
64
+ "@hydraharness/cordis": "^4.0.2"
65
+ }
66
+ }