Skip to content

Commit a5fafee

Browse files
committed
implement restart shell and send stdin apis
1 parent a5bcf9d commit a5fafee

File tree

2 files changed

+37
-5
lines changed

2 files changed

+37
-5
lines changed

src/PintClient/index.ts

Lines changed: 37 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ import {
2727
readFile,
2828
deleteFile,
2929
deleteExec,
30+
updateExec,
31+
execExecStdin,
3032
performFileAction,
3133
listDirectory,
3234
createDirectory,
@@ -348,11 +350,42 @@ export class PintShellsClient implements IAgentClientShells {
348350
async rename(shellId: ShellId, name: string): Promise<null> {
349351
return null;
350352
}
351-
restart(shellId: ShellId): Promise<null> {
352-
throw new Error("Not implemented");
353+
async restart(shellId: ShellId): Promise<null> {
354+
try {
355+
await updateExec({
356+
client: this.apiClient,
357+
path: {
358+
id: shellId,
359+
},
360+
body: {
361+
status: 'running',
362+
},
363+
});
364+
365+
return null;
366+
} catch (error) {
367+
console.error("Failed to restart shell:", error);
368+
return null;
369+
}
353370
}
354-
send(shellId: ShellId, input: string, size: ShellSize): Promise<null> {
355-
throw new Error("Not implemented");
371+
async send(shellId: ShellId, input: string, size: ShellSize): Promise<null> {
372+
try {
373+
await execExecStdin({
374+
client: this.apiClient,
375+
path: {
376+
id: shellId,
377+
},
378+
body: {
379+
type: 'stdin',
380+
input: input,
381+
},
382+
});
383+
384+
return null;
385+
} catch (error) {
386+
console.error("Failed to send input to shell:", error);
387+
return null;
388+
}
356389
}
357390
}
358391

test.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ const client = await sandbox.connect();
2020
//console.log("Running command...");
2121
//console.log(await client.commands.run("echo 'Hello World'"));
2222

23-
2423
console.log("creating directory...");
2524
console.log(await client.fs.mkdir("/workspace/newdir"));
2625
console.log("creating file in new dir...");

0 commit comments

Comments
 (0)