Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
nadeesha committed Dec 9, 2024
1 parent 72f9059 commit 996462b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
14 changes: 6 additions & 8 deletions bootstrap-node/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Inferable } from "inferable";
import { z } from "zod";
import { execFile } from "child_process";
import { promisify } from "util";
import assert from "assert";

const execFilePromise = promisify(execFile);

Expand All @@ -12,9 +13,9 @@ const client = new Inferable({

client.default.register({
name: "exec",
func: async ({ command, arg }: { command: string; arg?: string }) => {
const args = arg ? [arg] : [];
const { stdout, stderr } = await execFilePromise(command, args);
func: async ({ command, arg }: { command: string; arg: string }) => {
assert(arg.startsWith("./"), "can only access paths starting with ./");
const { stdout, stderr } = await execFilePromise(command, [arg]);
return {
stdout: stdout.trim(),
stderr: stderr.trim(),
Expand All @@ -24,12 +25,9 @@ client.default.register({
schema: {
input: z.object({
command: z
.enum(["pwd", "ls", "cat", "echo"]) // This prevents arbitrary commands
.enum(["ls", "cat"]) // This prevents arbitrary commands
.describe("The command to execute"),
arg: z
.string()
.describe("The argument to pass to the command")
.optional(),
arg: z.string().describe("The argument to pass to the command"),
}),
},
});
Expand Down
4 changes: 2 additions & 2 deletions bootstrap-node/src/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ const reportSchema = z.object({
client
.run({
initialPrompt: `
Iteratively inspect the files at the current directory, and produce a report.
You may selectively inspect the contents of files.
Iteratively inspect the source code at the current directory, and produce a report.
You may selectively inspect the contents of files. You can only access files starting with ./
`.trim(),
resultSchema: reportSchema,
})
Expand Down

0 comments on commit 996462b

Please sign in to comment.