API Reference

Agent Class

The core public API of the local Agent SDK

Agent Class

The local Agent exposes the following main public API:

  • new Agent(options)
  • agent.ready()
  • agent.dispose()
    • agent.session_collection()
  • agent.getConfig()
  • agent.getLogger()
  • agent.plugins

agent.session_collection().create_session() and agent.session_collection().get_session() return AgentSession.

If the host needs lower-level runtime assembly, it can also use agent.getRuntime(), agent.getContext(), and agent.session_collection().

Session collection

agent.session_collection() returns an AgentSessionCollection with the following methods:

  • session_collection.create_session(input?)
  • session_collection.get_session(sessionId)
  • session_collection.list_sessions(input?)
  • session_collection.archive_session({ id })
  • session_collection.archive_sessions(input?)
  • session_collection.clean_archive()

archive_session({ id }) moves an existing non-executing session from the active sessions directory to the archived sessions directory. archive_sessions(input?) returns a paginated list of archived sessions. clean_archive() permanently deletes all archived sessions and returns the removed session ids.

Constructor options

  • id
  • path
  • model
  • env
  • tools
  • instruction
  • plugins
  • Session

There is currently no mode constructor option.

ready() and dispose()

After new Agent(...), plugin lifecycle and ActionSchedule start automatically.

  • await agent.ready() waits until background services are up. Session entry points already wait internally; call ready() only when you need an explicit checkpoint.
  • await agent.dispose() stops plugin lifecycle, ActionSchedule, and shell.

RPC and HTTP exposure

The Agent itself no longer starts any transport. Use @downcity/server when you need RPC or HTTP:

import { AgentRPC, AgentHTTP } from "@downcity/server";

const rpc = new AgentRPC(agent);
await rpc.listen({ host: "127.0.0.1", port: 15314 });

const http = new AgentHTTP(agent);
await http.server().listen({ host: "127.0.0.1", port: 5314 });