MCPcopy Index your code
hub / github.com/Acode-Foundation/Acode / start

Method start

src/plugins/terminal/www/Executor.js:60–88  ·  view source on GitHub ↗

* Starts a shell process and enables real-time streaming of stdout, stderr, and exit status. * * @param {string} command - The shell command to run (e.g., `"sh"`, `"ls -al"`). * @param {(type: 'stdout' | 'stderr' | 'exit', data: string) => void} onData - Callback that receives real-time out

(command, onData, alpine = false)

Source from the content-addressed store, hash-verified

58 * });
59 */
60 start(command, onData, alpine = false) {
61 return new Promise((resolve, reject) => {
62 let first = true;
63 exec(
64 async (message) => {
65 //console.log(message);
66 if (first) {
67 first = false;
68 await new Promise(resolve => setTimeout(resolve, 100));
69 // First message is always the process UUID
70 resolve(message);
71 } else {
72 const match = message.match(/^([^:]+):(.*)$/);
73 if (match) {
74 const prefix = match[1]; // e.g. "stdout"
75 const content = match[2]; // output
76 onData(prefix, content);
77 } else {
78 onData("unknown", message);
79 }
80 }
81 },
82 reject,
83 this.ExecutorType,
84 "start",
85 [command, String(alpine)]
86 );
87 });
88 }
89
90 /**
91 * Sends input to a running process's stdin.

Callers 7

startAxsFunction · 0.45
startAndAwaitMethod · 0.45
onOpenMethod · 0.45
onCloseMethod · 0.45
startProcessMethod · 0.45
executeCommandMethod · 0.45
startProcessMethod · 0.45

Calls 3

resolveFunction · 0.85
StringInterface · 0.85
execFunction · 0.50

Tested by

no test coverage detected