Skip to content

feat: add --session-meta and --claude-agent CLI options#32

Open
taosu0216 wants to merge 1 commit intoopenclaw:mainfrom
taosu0216:feat/session-meta-and-claude-agent
Open

feat: add --session-meta and --claude-agent CLI options#32
taosu0216 wants to merge 1 commit intoopenclaw:mainfrom
taosu0216:feat/session-meta-and-claude-agent

Conversation

@taosu0216
Copy link

Summary

  • Add --session-meta <json> global option to pass arbitrary _meta to ACP newSession requests, enabling adapter-specific configuration from the CLI
  • Add --claude-agent <name> global option as syntactic sugar for claude-agent-acp, automatically building { claudeCode: { options: { agent: "<name>" } } }
  • Both options can be combined; --claude-agent deep-merges into --session-meta

Motivation

claude-agent-acp supports the agent parameter via _meta.claudeCode.options (which maps to Claude Code's --agent flag for loading .claude/agents/<name>.md), but there was no way to set _meta from the acpx CLI. This feature enables role-based agent dispatch (e.g., research, implement, check) through acpx.

Usage

# One-shot with a specific agent role
acpx --claude-agent research exec "Find where mobile top bar is rendered"

# Generic _meta passthrough
acpx --session-meta '{"claudeCode":{"options":{"agent":"research"}}}' exec "..."

# Create a session with agent config, then reuse with prompt
acpx --claude-agent implement sessions new -s my-task
acpx prompt -s my-task "Add logout button to sidebar"

Changes

File Change
src/types.ts Add sessionMeta to AcpClientOptions
src/client.ts Pass sessionMeta as _meta in newSession()
src/session-runtime.ts Thread sessionMeta through RunOnceOptions, SessionCreateOptions, SessionEnsureOptions
src/cli.ts Add --session-meta and --claude-agent global options with JSON parsing, validation, and deep merge

Scope

Supported on exec, sessions new, and sessions ensure commands. The prompt command uses detached queue owners which would require additional plumbing — left as a potential follow-up.

Test plan

  • acpx --claude-agent research exec "hello" creates session with correct _meta
  • acpx --session-meta '{"foo":"bar"}' exec "hello" passes raw JSON as _meta
  • --session-meta with invalid JSON throws InvalidArgumentError
  • --claude-agent and --session-meta can be combined (deep merge)
  • acpx --claude-agent research sessions new creates a session with agent config
  • All checks pass: typecheck, lint, format:check, build

Allow passing _meta to ACP newSession requests, enabling adapter-specific
configuration from the CLI.

--session-meta <json>: generic JSON passthrough set as _meta on newSession
--claude-agent <name>: sugar for claude-agent-acp, builds
  { claudeCode: { options: { agent: "<name>" } } }

Both options can be combined; --claude-agent deep-merges into --session-meta.

Supported on exec, sessions new, and sessions ensure commands.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant