Host-function command output doesn't reach a shell pipe, redirection or command substitution

Aperta
#2,082 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
55/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
javascript, rust, wasm
Ambito
backend, cli

Direzione di ricerca

The issue identifies shell pipelines, redirection, and command substitution as failing, with #1967 and #1983 as related context; it names no source files or tests. Start by tracing how host-function commands are dispatched through the VM shell and compare that path with ordinary shell command output. Done when the listed shell forms receive the host function's output and a regression test covers them.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Written by an AI agent (Claude) on behalf of @jasonkuhrt.

A host-function command's output reaches the caller when the command runs on its own, but not through a pipe, a redirection or a command substitution in the VM's shell. Those all see empty output, and the command still exits 0.

Reproduction on @rivet-dev/agentos-core 0.4.4: one collection, probe, with a ping function returning { pong: 'hello' }, and vm.process.exec(command, { output: { capture: 'all' } }) for each command.

Command stdout
agentos-probe ping --json '{}' {"ok":true,"result":{"pong":"hello"}}
agentos-probe ping --json '{}' | cat empty
agentos-probe ping --json '{}' | wc -c 0
agentos-probe ping --json '{}' > /tmp/out.json; wc -c < /tmp/out.json 0: the file is empty
x="$(agentos-probe ping --json '{}')"; echo "[$x]" []
echo '{"pong":"hello"}' | cat (control) {"pong":"hello"}
const vm = await AgentOs.create({
  permissions: { fs: 'allow', childProcess: 'allow', process: 'allow', hostFunction: 'allow', network: 'deny', env: 'deny' },
  hostFunctions: {
    probe: {
      ping: { inputSchema: z.object({}), execute: () => ({ pong: 'hello' }) },
    },
  },
});
await vm.process.exec(`agentos-probe ping --json '{}' | cat`, {
  cwd: '/', timeoutMs: 30_000, output: { capture: 'all' },
});

So a guest can't compose host functions with ordinary shell tools, such as agentos-x list | jq …, > file, or $(…). The silent empty output is worse than an error: a script carries on with nothing.

We work around it by running a host-function command only on its own, through execFile, and refusing pipelines, lists and redirections that contain one.

Possibly related: #1967 delivers JS processes' stdout and stderr to a redirected fd, and #1983 fixed dispatching shell-spawned binding stubs. We haven't checked whether #1967 covers host-function commands.

Lingua principale
Rust
Stelle
4.8k
Fork
270
Merge medio
14h 28m
PR unite (30g)
55

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di rivet-dev/agentos

Tutte le issue di rivet-dev/agentos

Issue simili

Altre issue su Rust

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.