()
| 17 | |
| 18 | |
| 19 | def _build_parser() -> argparse.ArgumentParser: |
| 20 | parser = argparse.ArgumentParser( |
| 21 | prog="opencode-agent", |
| 22 | description="Run a question through OpenCode CLI with AssetOpsBench MCP servers.", |
| 23 | formatter_class=argparse.RawDescriptionHelpFormatter, |
| 24 | epilog=""" |
| 25 | model-id examples: |
| 26 | opencode/gpt-5.1-codex OpenCode Zen model |
| 27 | openai/gpt-5.1 Direct OpenAI provider in OpenCode |
| 28 | anthropic/claude-sonnet-4-5 Direct Anthropic provider in OpenCode |
| 29 | litellm_proxy/<model> Use LITELLM_BASE_URL / LITELLM_API_KEY |
| 30 | tokenrouter/<model> Use TOKENROUTER_BASE_URL / TOKENROUTER_API_KEY |
| 31 | |
| 32 | environment variables: |
| 33 | OPENAI_API_KEY Direct OpenAI key, or set through `opencode /connect` |
| 34 | ANTHROPIC_API_KEY Direct Anthropic key, or set through `opencode /connect` |
| 35 | LITELLM_API_KEY LiteLLM router key for litellm_proxy/* models |
| 36 | LITELLM_BASE_URL LiteLLM OpenAI-compatible base URL |
| 37 | TOKENROUTER_API_KEY TokenRouter key for tokenrouter/* models |
| 38 | TOKENROUTER_BASE_URL TokenRouter OpenAI-compatible base URL |
| 39 | |
| 40 | examples: |
| 41 | opencode-agent "What assets are at site MAIN?" |
| 42 | opencode-agent --model-id tokenrouter/MiniMax-M3 "List sensors on Chiller 6" |
| 43 | opencode-agent --attach http://localhost:4096 "What is the current time?" |
| 44 | opencode-agent --show-trajectory "What sensors are on Chiller 6?" |
| 45 | """, |
| 46 | ) |
| 47 | add_common_args(parser, default_model=_DEFAULT_MODEL) |
| 48 | parser.add_argument( |
| 49 | "--max-steps", |
| 50 | type=int, |
| 51 | default=30, |
| 52 | metavar="N", |
| 53 | help="Maximum OpenCode agentic iterations (default: 30).", |
| 54 | ) |
| 55 | parser.add_argument( |
| 56 | "--agent-name", |
| 57 | default="assetops", |
| 58 | help="OpenCode agent name to create/select from inline config.", |
| 59 | ) |
| 60 | parser.add_argument( |
| 61 | "--opencode-bin", |
| 62 | default="opencode", |
| 63 | help="OpenCode executable path (default: opencode).", |
| 64 | ) |
| 65 | parser.add_argument( |
| 66 | "--attach", |
| 67 | default=None, |
| 68 | metavar="URL", |
| 69 | help="Attach to a running `opencode serve` instance, e.g. http://localhost:4096.", |
| 70 | ) |
| 71 | parser.add_argument( |
| 72 | "--timeout-s", |
| 73 | type=float, |
| 74 | default=900, |
| 75 | help="Wall-clock timeout for `opencode run` in seconds (default: 900).", |
| 76 | ) |
nothing calls this directly
no test coverage detected