Skip to content

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

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

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
Copy Markdown

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.
@frankekn
Copy link
Copy Markdown
Contributor

Thanks for the original direction here.

The --claude-agent part of this proposal has effectively been superseded by #94, which landed the current-architecture Claude session-option passthrough work on top of cli-core.

That leaves generic --session-meta passthrough as the only remaining unsatisfied part of this PR. We are not carrying that forward from this stale branch as-is. If we decide later that raw _meta passthrough is a worthwhile control surface for acpx, it should come back as a fresh maintainer-owned PR on top of current main, not as a rescue of the old src/cli.ts implementation.

Closing this PR as superseded/de-scoped.

@frankekn frankekn closed this Mar 10, 2026
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.

3 participants