mirror of
https://github.com/harivansh-afk/sandbox-agent.git
synced 2026-04-16 22:03:52 +00:00
Configure lefthook formatter checks (#231)
* Add lefthook formatter checks * Fix SDK mode hydration * Stabilize SDK mode integration test
This commit is contained in:
parent
0471214d65
commit
d2346bafb3
282 changed files with 5840 additions and 8399 deletions
|
|
@ -1,18 +1,12 @@
|
|||
import { createInterface } from "node:readline/promises";
|
||||
import { stdin as input, stdout as output } from "node:process";
|
||||
import { Command } from "commander";
|
||||
import {
|
||||
SandboxAgent,
|
||||
type PermissionReply,
|
||||
type SessionPermissionRequest,
|
||||
} from "sandbox-agent";
|
||||
import { SandboxAgent, type PermissionReply, type SessionPermissionRequest } from "sandbox-agent";
|
||||
|
||||
const options = parseOptions();
|
||||
const agent = options.agent.trim().toLowerCase();
|
||||
const autoReply = parsePermissionReply(options.reply);
|
||||
const promptText =
|
||||
options.prompt?.trim() ||
|
||||
`Create ./permission-example.txt with the text 'hello from the ${agent} permissions example'.`;
|
||||
const promptText = options.prompt?.trim() || `Create ./permission-example.txt with the text 'hello from the ${agent} permissions example'.`;
|
||||
|
||||
const sdk = await SandboxAgent.start({
|
||||
spawn: {
|
||||
|
|
@ -31,11 +25,7 @@ try {
|
|||
: [];
|
||||
const modeOption = configOptions.find((option) => option.category === "mode");
|
||||
const availableModes = extractOptionValues(modeOption);
|
||||
const mode =
|
||||
options.mode?.trim() ||
|
||||
(typeof modeOption?.currentValue === "string" ? modeOption.currentValue : "") ||
|
||||
availableModes[0] ||
|
||||
"";
|
||||
const mode = options.mode?.trim() || (typeof modeOption?.currentValue === "string" ? modeOption.currentValue : "") || availableModes[0] || "";
|
||||
|
||||
console.log(`Agent: ${agent}`);
|
||||
console.log(`Mode: ${mode || "(default)"}`);
|
||||
|
|
@ -91,10 +81,7 @@ async function handlePermissionRequest(
|
|||
await session.respondPermission(request.id, reply);
|
||||
}
|
||||
|
||||
async function promptForReply(
|
||||
request: SessionPermissionRequest,
|
||||
rl: ReturnType<typeof createInterface> | null,
|
||||
): Promise<PermissionReply> {
|
||||
async function promptForReply(request: SessionPermissionRequest, rl: ReturnType<typeof createInterface> | null): Promise<PermissionReply> {
|
||||
if (!rl) {
|
||||
return "reject";
|
||||
}
|
||||
|
|
@ -136,8 +123,7 @@ function extractOptionValues(option: { options?: unknown[] } | undefined): strin
|
|||
if (!nested || typeof nested !== "object") {
|
||||
continue;
|
||||
}
|
||||
const nestedValue =
|
||||
"value" in nested && typeof nested.value === "string" ? nested.value : null;
|
||||
const nestedValue = "value" in nested && typeof nested.value === "string" ? nested.value : null;
|
||||
if (nestedValue) {
|
||||
values.push(nestedValue);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue