Documentation
¶
Overview ¶
Package extproc runs external helper processes (exec backends) over the suga exec protocol v1 and provides the credential-stripped environment shared with MCP subprocesses.
Protocol v1: one process per call. The caller writes ONE line of JSON to the child's stdin:
{"v":1,"capability":"memory","op":"search","args":{...}}
and the child answers with ONE line of JSON on stdout:
{"ok":true,"result":{...}} or {"ok":false,"error":"..."}
A non-zero exit, a timeout or output that is not valid JSON is a failure; the error carries the tail of the child's stderr. Request and Response are the envelope types; Call itself is envelope-agnostic and decodes the stdout line into whatever resp it is given (normally *Response).
Index ¶
Constants ¶
const ( // ProtocolVersion is the value of Request.V. ProtocolVersion = 1 // DefaultTimeout bounds a call when Spec.Timeout is zero. DefaultTimeout = 10 * time.Second )
Variables ¶
This section is empty.
Functions ¶
func Call ¶
Call runs spec.Command, writes req as one JSON line to its stdin, and decodes the first non-empty stdout line into resp.
func StripCredentials ¶
StripCredentials returns a child-process environment: the parent environment minus credential variables, then the configured entries. Configured entries are passed as-is, so a child may still be given a credential explicitly. Everything else is inherited.
Types ¶
type Request ¶
type Request struct {
V int `json:"v"`
Capability string `json:"capability"`
Op string `json:"op"`
Args any `json:"args,omitempty"`
}
Request is the protocol v1 request envelope.
type Response ¶
type Response struct {
OK bool `json:"ok"`
Result json.RawMessage `json:"result,omitempty"`
Error string `json:"error,omitempty"`
}
Response is the protocol v1 response envelope.
type Spec ¶
type Spec struct {
Command string
Args []string
// Env holds extra entries appended to the credential-stripped parent
// environment (StripCredentials(os.Environ(), Env)); empty means just the
// stripped parent environment.
Env []string
// Timeout bounds the whole call; zero means DefaultTimeout.
Timeout time.Duration
}
Spec describes the child process of one call.