Skip to content

Embedding

sarr-io edited this page Sep 13, 2026 · 18 revisions

Embedding

Zig

var image = try pa.Image.init(allocator, io, "./example");
defer image.deinit();
var agent = pa.Agent.init(allocator, io, .{ .agent_id = agent_id });
defer agent.deinit();

const output = try agent.call(allocator, &image, "entries.readonly", input, &.{.{
    .name = "peer",
    .agent = &peer,
    .image = &peer_image,
    .entry = "entries.default",
}});
defer allocator.free(output);

Agent.init requires a thread-safe allocator for std.http.Client; the call allocator must support concurrent batch Eval. Agent stores IO explicitly rather than recovering it from the HTTP client.

Images and Imports are borrowed until the call's Futures settle. Agents may be called concurrently; Agent.deinit requires all calls to have finished. An omitted AgentId is generated. Image watching, publication, and retirement remain embedder policy.

Effect 4 SDK

const output = yield * agent.call("entries.readonly", input, [{
  name: "peer",
  agent: peer,
  entry: "entries.default",
}]);

make uses Effect Crypto when no agentId is supplied. Calls require ChildProcessSpawner; the SDK imports no runtime-specific or FFI API.

Each call starts one scoped agent call process. The SDK writes one JSON request, closes stdin, and reads one JSON result. Interruption terminates the process. Bytes and Agent IDs use padded base64; records have no arbitrary size limit.

The root Agent's binary executes the call. The request contains each distinct Agent once; flat Imports reference those Agents by index. Omitted limits use the binary's defaults.

Distribution

The default build links vendored Lua statically. -Dsystem-lua=true links an ABI-compatible dynamic Lua 5.5 installation.

Clone this wiki locally