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.
- package/README.md +3 -0
- package/assets/banner.svg +1 -1
- package/assets/preview.svg +1 -1
- package/dist/cli/background-ui.js +116 -0
- package/dist/cli/headless.js +3 -1
- package/dist/cli/index.js +135 -19
- package/dist/cli/prompt.js +39 -1
- package/dist/cli/ui.js +162 -25
- package/dist/cli/updater.js +10 -8
- package/dist/core/background.js +376 -0
- package/dist/core/config-merge.js +67 -0
- package/dist/core/loop.js +18 -1
- package/dist/core/types.js +1 -1
- package/dist/permissions/guard.js +3 -1
- package/dist/prompts/builder.js +2 -1
- package/dist/tools/background.js +118 -0
- package/dist/tools/bash.js +23 -1
- package/dist/tools/index.js +2 -1
- package/package.json +1 -1
package/dist/tools/bash.js
CHANGED
|
@@ -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
|
-
|
|
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();
|
package/dist/tools/index.js
CHANGED
|
@@ -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