termux-dev 1.8.1 → 1.8.2

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.
@@ -63,6 +63,8 @@ export function runShell(command, options = {}) {
63
63
  const stderrDecoder = new StringDecoder('utf8');
64
64
  let stopReason = '';
65
65
  let killTimer;
66
+ let killRepeat;
67
+ let settled = false;
66
68
  const killProcessTree = (force) => {
67
69
  if (!proc.pid)
68
70
  return;
@@ -90,6 +92,10 @@ export function runShell(command, options = {}) {
90
92
  killProcessTree(false);
91
93
  // Commands can ignore SIGTERM. Do not leave them running after cancellation.
92
94
  killTimer = setTimeout(() => killProcessTree(true), 1000);
95
+ // On Windows a command such as `npm test` starts its child a moment later, after the first
96
+ // kill has looked at the tree: kill again until the process is gone.
97
+ if (isWin)
98
+ killRepeat = setInterval(() => killProcessTree(true), 700);
93
99
  };
94
100
  const onAbort = () => stop('[Operation cancelled by user]');
95
101
  const timeout = setTimeout(() => stop(`[Process killed due to timeout after ${timeoutSeconds}s. ` +
@@ -108,14 +114,30 @@ export function runShell(command, options = {}) {
108
114
  const cleanup = () => {
109
115
  clearTimeout(timeout);
110
116
  clearTimeout(killTimer);
117
+ clearInterval(killRepeat);
111
118
  signal?.removeEventListener('abort', onAbort);
112
119
  };
113
- proc.on('close', (code) => {
120
+ const finish = (code) => {
121
+ if (settled)
122
+ return;
123
+ settled = true;
114
124
  if (stopReason)
115
125
  killProcessTree(true);
116
126
  output.push(stdoutDecoder.end() + stderrDecoder.end());
117
127
  cleanup();
118
128
  resolve({ output: output.toString(), code, stopReason });
129
+ };
130
+ proc.on('close', finish);
131
+ // After a cancel or a timeout the shell is gone, but a child that got away can keep the pipes
132
+ // open for good: do not wait for them for more than a moment.
133
+ proc.on('exit', (code) => {
134
+ if (!stopReason)
135
+ return;
136
+ setTimeout(() => {
137
+ proc.stdout?.destroy();
138
+ proc.stderr?.destroy();
139
+ finish(code);
140
+ }, 300);
119
141
  });
120
142
  proc.on('error', (err) => {
121
143
  cleanup();
@@ -1,5 +1,6 @@
1
1
  import { readFileTool, writeFileTool, editFileTool, listDirTool, mkdirTool } from './fs.js';
2
2
  import { bashTool } from './bash.js';
3
+ import { backgroundTool } from './background.js';
3
4
  import { searchTool } from './search.js';
4
5
  import { askQuestionsTool } from './questions.js';
5
6
  import { webSearchTool, fetchUrlTool } from './web.js';
@@ -17,6 +18,6 @@ export function getTools(planMode) {
17
18
  if (planMode) {
18
19
  return [...baseTools, ...mcpTools];
19
20
  }
20
- return [...baseTools, writeFileTool, editFileTool, mkdirTool, bashTool, diagnoseCodeTool, installPackageTool, servePreviewTool, mcpManageTool, ...mcpTools];
21
+ return [...baseTools, writeFileTool, editFileTool, mkdirTool, bashTool, backgroundTool, diagnoseCodeTool, installPackageTool, servePreviewTool, mcpManageTool, ...mcpTools];
21
22
  }
22
23
  export { webSearchTool, fetchUrlTool, diagnoseCodeTool, installPackageTool, saveMemoryTool, planReadyTool, lastPlanReady, resetPlanReady, todoListTool, currentTodoList, resetTodoList, servePreviewTool };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "termux-dev",
3
- "version": "1.8.1",
3
+ "version": "1.8.2",
4
4
  "description": "Ultra-fast, terminal-native AI coding assistant and agent built for Android Termux, Windows, macOS, and Linux.",
5
5
  "main": "dist/cli/index.js",
6
6
  "type": "module",