Resolve Agent Running Scripts
This commit is contained in:
+5
-5
@@ -1513,7 +1513,7 @@ function bareAgentToolDefinitions() {
|
||||
function: {
|
||||
name: 'run_js_script',
|
||||
description:
|
||||
'Write JS to ~/.agent/_tmp_agent_run.mjs and run `node` with stdout captured. Fails if node is unavailable.',
|
||||
'Save JS to ~/.agent/_tmp_agent_run.mjs and execute it via the shell like any drive script (absolute path; same Bare kernel runner as /bin — no separate node binary). Prefer define async function run(ctx, argv). stdout/stderr captured.',
|
||||
parameters: {
|
||||
type: 'object',
|
||||
properties: {
|
||||
@@ -1861,10 +1861,8 @@ async function bareAgentDispatchTool(o) {
|
||||
? ctx.b4a.from(code)
|
||||
: new TextEncoder().encode(code)
|
||||
await vfs.writeFile(scriptPath, body)
|
||||
const cmd =
|
||||
'node ' +
|
||||
bareAgentShellQuote(scriptPath) +
|
||||
' ; echo EXIT:$?'
|
||||
/** Absolute path → kernel-runner runs .mjs like `./script.mjs` (no host `node` binary). captureExec adds stdout redirect. */
|
||||
const cmd = bareAgentShellQuote(scriptPath)
|
||||
const r = await captureExec(cmd, 60000)
|
||||
return bareAgentJsonResult(
|
||||
r.ok === false ? r : { ok: true, stdout_stderr: r.stdout_stderr }
|
||||
@@ -2102,6 +2100,8 @@ function bareAgentWriteOut(out, s) {
|
||||
|
||||
const BARE_AGENT_STATIC_SYSTEM = `You are the Bare OS autonomous agent inside a JavaScript POSIX-like environment on Hyperdrive + Hyperswarm (Pear/Bare runtime).
|
||||
|
||||
There is no host \`node\` binary. Userland \`.js\` / \`.mjs\` is run by the kernel (path on a drive, e.g. /home/.../x.mjs, or \`./x.mjs\` in the shell) like /bin scripts. run_js_script writes a file and runs it that way; for ad-hoc lines use run_command with real /bin tools or sh -c.
|
||||
|
||||
Capabilities: use ctx.execLine for shell commands (same language as the interactive shell). Use ctx.vfs readFile/writeFile/mkdir/readdir/chmod where available. Paths under /home, /mnt, /tmp map to Hypercore-backed storage; system paths like /bin, /etc are on the system drive.
|
||||
|
||||
Safety: never exfiltrate ~/.agent/config.json or API keys in chat. Prefer least-privilege commands. Call task_complete(summary) only when fully done.
|
||||
|
||||
Reference in New Issue
Block a user