Core는 도구 핸들러를 직접 쓰지 않아도 되는 완전한 “핸드”입니다: 프로세스 그룹 단위 취소가 되는 bash, 세션 워크스페이스로 제한된 파일 도구, stdio MCP 감독자, 세션별 정리, 등록 가능한 기능을 갖춥니다. 코어 하나로 BMA 클라우드와 로컬 브레인를 동시에 처리할 수 있습니다. Go 전용이며 bash는 샌드박스가 아닙니다: 모든 브레인이 executor의 OS 사용자로 실행됩니다.
bma-executor-sdk 1.12.2과 그 계약(
contracts/bma/executor, 프로토콜 bma.executor.v1.1)에서 생성했습니다. 설치, 자격 증명, 빠른 시작은 bma-executor-sdk 개요를, 프로토콜 자체는 Executor Protocol을 참고하세요.NewCore
옵션을 검증하고 작업 루트를 만듭니다.// TypeScript SDK 1.12.2에는 없습니다.
# Python SDK 1.12.2에는 없습니다.
func NewCore(opts CoreOptions) (*Core, error)
type CoreOptions struct {
// WorkRoot holds every session workspace: WorkRoot/<brain>/<session>.
WorkRoot string
// Workspace overrides the per-session directory (for example a machine
// executor whose sessions all share one directory, or a desktop app
// mapping a brain to a project folder). Tools are confined to it.
Workspace func(brain, sessionID string) string
// MaxSessions bounds active sessions across all attached brains;
// MaxSessionsPerBrain bounds one brain (defaults to MaxSessions). A full
// core answers session.assign with executor_busy (-32009, retryable).
MaxSessions int
MaxSessionsPerBrain int
// MaxMCPServersPerSession bounds session.assign.mcp_servers (default 4).
MaxMCPServersPerSession int
// BashTimeout applies when neither tool.call deadline_ms nor the bash
// timeout_ms is set (default 10 minutes).
BashTimeout time.Duration
// MaxOutputBytes caps each captured bash stream (default 1 MiB).
MaxOutputBytes int
// InlineResultBytes is the largest bash output returned inline (default
// 48 KiB, under the 64 KiB control frame). Larger output is truncated.
InlineResultBytes int
// ComputerUse serves computer_observe and computer_action and advertises
// capabilities.computer_use (for example NewCuaDriver). Nil leaves
// computer use off: the harness then sends no computer_* tool.
ComputerUse ComputerUseBackend
// ComputerVision tells whether the model that reads a session's
// computer use results takes images. When it answers
// ComputerVisionTextOnly, an observation's screenshot is still taken
// (actions use its pixels) but not sent: the result carries its text and
// a note that the model cannot read images. Nil, or
// ComputerVisionUnknown, sends the screenshot.
ComputerVision func(ctx context.Context, q ComputerVisionQuery) ComputerVisionAnswer
// Env is set on every bash tool and process and cannot be overridden by
// a request (for example BMA_HOME).
Env map[string]string
// DenyEnv reports executor-private variables (credentials, state paths)
// that no bash tool, process or stdio MCP server may see: they are
// dropped from the inherited environment and a request setting one is
// rejected. NewCore rejects an Env entry it denies.
DenyEnv func(name string) bool
// RunAs, when set, is the OS identity every bash tool, process and stdio
// MCP server runs as, so a privileged executor (for example root) keeps
// its own credentials and state out of the workload's reach. HOME and
// USER in bash and process environments are the workload's. On Linux,
// the file tools (read, write, edit, glob, grep) use the workload's file
// identity. Unix only.
RunAs *RunAs
// Launch runs before each bash tool command starts (tool.call and
// LocalToolRoute, so also ACPAgent's own tools), with the semantics of
// ProcessOptions.Launch: it may change the directory, argv and
// environment, or refuse the start; see LaunchFunc. File tools run inside
// the executor and do not call it (they stay within the session
// workspace). Nil starts commands as before.
Launch LaunchFunc
// FileAccess runs before every file tool (read, write, edit, glob, grep)
// of this machine: a tool.call and the tools of a LocalToolRoute (so also
// ACPAgent's). It gets the session, the tool, the operation (read or
// write) and the workspace-relative path, and refuses by returning an
// error: an *RPCError (NewReasonError) gives its data.reason as the
// refusal code, any other error permission_denied. A LocalToolRoute call
// is then not_forwarded with the code as Code, recorded like a result (the
// same call id is answered with it again); a tool.call fails with
// "<code>: <message>". Nothing is read or written when it refuses. A host
// uses it for read-only sessions, protected paths, revoked grants and
// stopped turns. The tools stay within the workspace with or without it,
// unless OutsideFiles is set.
// Nil allows every file tool call as before. See FileAccessRequest.
FileAccess FileAccessFunc
// OutsideFiles lets a file tool use an absolute path outside the session
// workspace and mounts (as the user this executor runs as) when
// FileAccess allows that call: the request then has Outside set and the
// absolute path. FileAccess is required with it. Off, such a path fails
// without asking FileAccess, as before. A host sets it for a session
// that has full access to the computer; relative paths stay in the
// workspace either way.
OutsideFiles bool
// ToolOutputDir, when set, holds the output files of the bash commands
// of a LocalToolRoute (so also ACPAgent's own tools):
// ToolOutputDir/<short hash of the session>/, created 0700 (owned by
// RunAs when set). Empty keeps them in .bma-bash/ under the turn's
// working directory. A host whose Launch sandboxes commands sets it to a
// directory outside every folder a session may write, so the executor
// writes nothing into the user's folders. The read tool of the session
// may read its own output files there. tool.call bash keeps its output
// in memory and does not use it.
ToolOutputDir string
// EndAfterToolCall marks sessions that carry exactly one tool call: the
// core ends them (session.ended "completed") after the result is
// delivered. BMA's durable selfhost queue assigns such sessions.
EndAfterToolCall func(SessionAssignParams) bool
// OnAssign runs on every accepted session.assign of the core, the first
// one of a session (the session exists, workspace and MCP servers not yet
// prepared) and each replay (sent again before tool calls, on reconnect,
// to renew a grant). A host keeps per-session state from params.Metadata
// here: a replay carries the whole metadata again, a key it no longer
// holds is gone, and the session's Assignment shows the newest assign's
// once OnAssign returns. A returned error refuses the assign (invalid
// params naming it): a first assign creates no session, a replay leaves
// the previous metadata. End of the session is the session's Context.
// Nil does nothing.
OnAssign func(session *CoreSession, params SessionAssignParams) error
OnLog func(LogEvent)
}
Register
기능(기능 비트 뒤의 메서드 집합)을 추가합니다.Attach 전에 호출하세요.
// TypeScript SDK 1.12.2에는 없습니다.
# Python SDK 1.12.2에는 없습니다.
func (c *Core) Register(capability Capability) error
type Capability struct {
// Advertise sets the capability bits on the register capabilities.
Advertise func(*Capabilities)
Methods map[string]Handler
SessionScoped bool
OnSessionEnd func(*CoreSession)
}
Capabilities
연결된 클라이언트가 선언해야 할 기능.// TypeScript SDK 1.12.2에는 없습니다.
# Python SDK 1.12.2에는 없습니다.
func (c *Core) Capabilities() Capabilities
Attach
클라이언트 하나에서 브레인 하나를 위해session.assign, session.stop, tool.call과 등록된 모든 기능을 처리합니다. 클라이언트가 start하기 전에 호출하세요. 브레인 이름은 코어마다 고유해야 합니다.
// TypeScript SDK 1.12.2에는 없습니다.
# Python SDK 1.12.2에는 없습니다.
func (c *Core) Attach(brain string, client *Client) error
Close
모든 브레인의 모든 세션을session.ended를 보고하지 않고 멈춥니다.
// TypeScript SDK 1.12.2에는 없습니다.
# Python SDK 1.12.2에는 없습니다.
func (c *Core) Close()
Env
executor의 기본 환경, 요청 env(제한 있음, 로더 변수와 금지된 변수는 거부),CoreOptions.Env로 bash나 프로세스 환경을 만듭니다.
// TypeScript SDK 1.12.2에는 없습니다.
# Python SDK 1.12.2에는 없습니다.
func (c *Core) Env(explicit map[string]string) ([]string, error)
NewProcessCapability
코어 세션에서process.start/read/write/interrupt/terminate/list와 process.status를 처리합니다: 파이프 또는 PTY, 커서 기반 출력, 멱등한 시작과 쓰기, 시간 제한, 프로세스 그룹 신호. nil 훅은 해당 기능 비트를 설정하지 않습니다.
// TypeScript SDK 1.12.2에는 없습니다.
# Python SDK 1.12.2에는 없습니다.
func NewProcessCapability(core *Core, opts ProcessOptions) Capability
type ProcessOptions struct {
// Env is set on every process (not on bash tools) over the request env,
// for example a canonical skill root such as BMA_HOME.
Env map[string]string
FileTransfer FileTransferer
GitCredentials GitCredentialGranter
// PackageInstaller serves process.start package_install.
PackageInstaller PackageInstaller
// Launch runs before each new command process starts; see LaunchFunc.
Launch LaunchFunc
// SessionFiles syncs each agent session's files below its root, which
// is advertised as capabilities.session_files.root; see SessionFiles.
SessionFiles *SessionFiles
}
NewSkillInstallCapability
여러분의 설치기로skill.install을 처리합니다. 설치는 한 번에 하나씩 실행됩니다.
// TypeScript SDK 1.12.2에는 없습니다.
# Python SDK 1.12.2에는 없습니다.
func NewSkillInstallCapability(install SkillInstaller) (Capability, error)
CoreSession
기능이 보는, 브레인 하나에 할당된 세션 하나.// TypeScript SDK 1.12.2에는 없습니다.
# Python SDK 1.12.2에는 없습니다.
func (s *CoreSession) ID() string
func (s *CoreSession) Brain() string
func (s *CoreSession) Workspace() string
func (s *CoreSession) Client() *Client
func (s *CoreSession) Context() context.Context
func (s *CoreSession) Assignment() SessionAssignParams
func (s *CoreSession) Value(key any, create func() any) any
func (s *CoreSession) ResolveCwd(cwd string) (string, error)