@oh-my-ai-sdk/environment
v0.0.1
Published
Turn-scoped execution Environment for AI SDK agents: (host, fs, user, cwd) behind one ctx feeding a whole tool suite — bash and fs tools share the same environment by construction.
Readme
@oh-my-ai-sdk/environment
Turn-scoped execution Environment for AI SDK agents: (host, fs, user, cwd)
behind one ctx feeding a whole tool suite. bash and every fs tool resolve
through the SAME registry, so "read locally, execute remotely" is
structurally inexpressible.
import { EnvRegistry, LocalEnv, SSHEnv } from "@oh-my-ai-sdk/environment";
import { makeEnvironmentTools } from "@oh-my-ai-sdk/environment/tools";
const reg = new EnvRegistry();
reg.register(await LocalEnv.open("local"));
reg.register(await SSHEnv.open("build-box", "google-charles"));
const tools = makeEnvironmentTools(reg); // { bash, read, write, edit, grep, glob }
// generateText({ model, tools, ... })Design (proven in ria lab/env-lab, four generations of live-model probes):
- One persistent shell per environment — local bash child or
ssh host bashover ControlMaster — sentinel-framed, so cwd/env/background jobs persist across calls. The tool is stateless; the state lives in the Environment, which is turn-scoped by construction. - Uniform one-off
targeton the whole suite. A call names its environment or inherits the registrybinding; no tool call mutates the binding (chosen over sticky switching — the binding a model believes it has is the binding it has, regardless of context length). - binding_note on any result produced under an explicit target: the accident-asymmetry mitigation from the ria consult.
- Visibility invariant: every exec result carries a
[user@host:cwd] $ cmdheader. - Unknown target = loud error. Never a silent fallback to local.
Tests: bun run test (local-only, real bash). SSH transport:
ENV_SSH_HOST=<alias> bun smoke/ssh-smoke.ts.
