Secrets & Environments›Process Execution (exec)
OpenClaw Exec Provider Protocol (agentsecrets exec)
If you are looking to run terminal commands, servers, or Docker containers with injected environment variables, seeagentsecrets env. The
agentsecrets execcommand is a dedicated machine-to-machine JSON protocol provider designed for automated agent orchestrators like OpenClaw.
Protocol Overview
The agentsecrets exec command implements a machine-facing JSON interface over standard I/O:
- It reads an
ExecRequestJSON payload fromstdin(bounded to a maximum of 10MB). - It authenticates against the local
keychain-authdaemon. - It resolves the requested secret IDs from the OS Keychain for the active project and environment.
- It writes an
ExecResponseJSON payload tostdout.
Because it is designed for automated tooling:
- All interactive terminal spinners, update banners, and human-facing logs are suppressed.
- Human-readable error messages are emitted exclusively to
stderrin structured formats. - The process exits with code
0on success or code1on protocol failure.
Wire Specification (Protocol Version 1)
1Request Payload ()
The caller pipes a single JSON object to the command:
{ "protocolVersion": 1, "provider": "agentsecrets", "ids": [ "STRIPE_SECRET_KEY", "OPENAI_API_KEY", "DATABASE_URL" ] }
Fields:
protocolVersion(integer, required): Must be set to1.provider(string, required): The identifier of the secret provider ("agentsecrets").ids(array of strings, required): The list of secret key names to resolve from the active project.
2Response Payload ()
The command outputs a single JSON response object:
{ "protocolVersion": 1, "values": { "STRIPE_SECRET_KEY": "sk_live_51ABC...", "OPENAI_API_KEY": "sk-proj-xyz..." }, "errors": { "DATABASE_URL": { "message": "secret not found in keychain" } } }
Fields:
protocolVersion(integer): Matches the negotiated protocol version (1).values(map of string to string): Successfully resolved secret keys and their decrypted plaintext values.errors(map of string to object, optional): If any requested key could not be resolved (e.g. key missing in active environment), it is returned in theerrorsmap with a descriptivemessage.
Command Invocation Examples
Testing via Command Line
You can test the protocol directly using shell piping:
echo '{"protocolVersion": 1, "provider": "agentsecrets", "ids": ["STRIPE_KEY"]}' | agentsecrets exec
Programmatic Invocation (Node.js Child Process)
import { spawn } from "child_process"; async function resolveSecrets(keys: string[]): Promise<Record<string, string>> { return new Promise((resolve, reject) => { const child = spawn("agentsecrets", ["exec"]); let stdout = ""; let stderr = ""; child.stdout.on("data", (chunk) => { stdout += chunk; }); child.stderr.on("data", (chunk) => { stderr += chunk; }); child.on("close", (code) => { if (code !== 0) { return reject(new Error(`Exec provider failed (${code}): ${stderr}`)); } try { const response = JSON.parse(stdout); resolve(response.values); } catch (err) { reject(new Error(`Invalid JSON response: ${stdout}`)); } }); const payload = JSON.stringify({ protocolVersion: 1, provider: "agentsecrets", ids: keys, }); child.stdin.write(payload); child.stdin.end(); }); }
Security Guarantees
- Binary Attestation:
keychain-authvalidates that the binary calling the OS Keychain is the genuineagentsecretsexecutable before returning values. - Bounded Stdin Reader: To prevent memory exhaustion attacks,
agentsecrets execlimits stdin reading to 10MB (MaxExecInputSize). - Connection Lifecycle: The
keychain-authsocket connection is strictly closed on exit via deferred cleanup.
Was this helpful?
Thanks for your feedback!
Your feedback helps us improve the platform.