@deepseek-ai/dsh-tool-bash-persistent 0.1.0-rc.7 → 0.1.0-rc.8

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 (2) hide show
  1. package/lib/index.js +15 -5
  2. package/package.json +19 -19
package/lib/index.js CHANGED
@@ -161,6 +161,18 @@ function appendStatusMarker(content, marker) {
161
161
  function renderShellExitStatus(content, exitCode, signal) {
162
162
  return appendStatusMarker(content, signal !== null ? `[shell killed by signal: ${signal}]` : exitCode !== null ? `[shell exited: code ${exitCode}]` : "[shell exited]");
163
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
+ }
164
176
  function persistentShells(ctx, config) {
165
177
  const pending = /* @__PURE__ */ new WeakMap();
166
178
  const live = /* @__PURE__ */ new Map();
@@ -243,6 +255,8 @@ async function executeCommand(ctx, shells, owner, command, config, upstream) {
243
255
  let fallback = "";
244
256
  let fallbackTruncated = false;
245
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);
246
260
  let operation;
247
261
  let result;
248
262
  try {
@@ -282,11 +296,7 @@ async function executeCommand(ctx, shells, owner, command, config, upstream) {
282
296
  const complete = commandOutput(retainedScrollback(ctx, owner, id, latest), marker);
283
297
  if (complete !== void 0) return renderCaptured(complete, config.maxOutputChars);
284
298
  }
285
- if (result.sessionStatus.kind === "exited") {
286
- const snapshot = retainedScrollback(ctx, owner, id, latest);
287
- await shells.reset(owner, "persistent bash shell exited");
288
- return [renderShellExitStatus(renderCaptured(partialOutput(snapshot, marker, fallback, fallbackTruncated), config.maxOutputChars), result.sessionStatus.exitCode, result.sessionStatus.signal), SHELL_RESET_MESSAGE].filter((part) => part.length > 0).join("\n");
289
- }
299
+ if (result.sessionStatus.kind === "exited") return await respondToSessionExit(ctx, shells, owner, id, result.sessionStatus, marker, fallback, fallbackTruncated, config);
290
300
  if (result.waitReason === "stdin_read") return renderCaptured(partialOutput(retainedScrollback(ctx, owner, id, latest), marker, fallback, fallbackTruncated), config.maxOutputChars);
291
301
  await pause();
292
302
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@deepseek-ai/dsh-tool-bash-persistent",
3
3
  "description": "Model-facing owner-scoped persistent Bash tool backed by the Harness PTY service",
4
- "version": "0.1.0-rc.7",
4
+ "version": "0.1.0-rc.8",
5
5
  "publishConfig": {
6
6
  "access": "public"
7
7
  },
@@ -31,11 +31,11 @@
31
31
  ],
32
32
  "license": "MIT",
33
33
  "peerDependencies": {
34
- "@deepseek-ai/dsh-agent": "^0.1.0-rc.7",
35
- "@deepseek-ai/dsh-invariants": "^0.1.0-rc.7",
36
- "@deepseek-ai/dsh-terminal": "^0.1.0-rc.7",
37
- "@deepseek-ai/dsh-timeout": "^0.1.0-rc.7",
38
- "@deepseek-ai/dsh-tools": "^0.1.0-rc.7",
34
+ "@deepseek-ai/dsh-agent": "^0.1.0-rc.8",
35
+ "@deepseek-ai/dsh-invariants": "^0.1.0-rc.8",
36
+ "@deepseek-ai/dsh-terminal": "^0.1.0-rc.8",
37
+ "@deepseek-ai/dsh-timeout": "^0.1.0-rc.8",
38
+ "@deepseek-ai/dsh-tools": "^0.1.0-rc.8",
39
39
  "@deepseek-ai/cordis": "^4.0.1"
40
40
  },
41
41
  "dependencies": {
@@ -44,18 +44,18 @@
44
44
  "devDependencies": {
45
45
  "@deepseek-ai/cordis-plugin-include": "^1.0.6",
46
46
  "@deepseek-ai/cordis-plugin-loader": "^1.0.2",
47
- "@deepseek-ai/dsh-agent": "^0.1.0-rc.7",
48
- "@deepseek-ai/dsh-invariants": "^0.1.0-rc.7",
49
- "@deepseek-ai/dsh-llm": "^0.1.0-rc.7",
50
- "@deepseek-ai/dsh-terminal": "^0.1.0-rc.7",
51
- "@deepseek-ai/dsh-terminal-bash": "^0.1.0-rc.7",
52
- "@deepseek-ai/dsh-sandbox-policy": "^0.1.0-rc.7",
53
- "@deepseek-ai/dsh-session": "^0.1.0-rc.7",
54
- "@deepseek-ai/dsh-subprocess-local": "^0.1.0-rc.7",
55
- "@deepseek-ai/dsh-system-prompt": "^0.1.0-rc.7",
56
- "@deepseek-ai/dsh-tools": "^0.1.0-rc.7",
57
- "@deepseek-ai/dsh-timeout": "^0.1.0-rc.7",
58
- "@deepseek-ai/cordis": "^4.0.1",
59
- "@deepseek-ai/dsh-sandbox": "^0.1.0-rc.7"
47
+ "@deepseek-ai/dsh-agent": "^0.1.0-rc.8",
48
+ "@deepseek-ai/dsh-invariants": "^0.1.0-rc.8",
49
+ "@deepseek-ai/dsh-llm": "^0.1.0-rc.8",
50
+ "@deepseek-ai/dsh-terminal-bash": "^0.1.0-rc.8",
51
+ "@deepseek-ai/dsh-terminal": "^0.1.0-rc.8",
52
+ "@deepseek-ai/dsh-sandbox": "^0.1.0-rc.8",
53
+ "@deepseek-ai/dsh-sandbox-policy": "^0.1.0-rc.8",
54
+ "@deepseek-ai/dsh-session": "^0.1.0-rc.8",
55
+ "@deepseek-ai/dsh-subprocess-local": "^0.1.0-rc.8",
56
+ "@deepseek-ai/dsh-system-prompt": "^0.1.0-rc.8",
57
+ "@deepseek-ai/dsh-timeout": "^0.1.0-rc.8",
58
+ "@deepseek-ai/dsh-tools": "^0.1.0-rc.8",
59
+ "@deepseek-ai/cordis": "^4.0.1"
60
60
  }
61
61
  }