mirror of
https://github.com/open-webui/open-terminal.git
synced 2026-11-22 21:50:43 -05:00
49 lines
1.3 KiB
Python
49 lines
1.3 KiB
Python
"""Claude Code launch and model discovery."""
|
|
|
|
NAME = "Claude Code"
|
|
BINARY = "claude"
|
|
|
|
|
|
def arguments(options):
|
|
args = [
|
|
"--input-format",
|
|
"stream-json",
|
|
"--output-format",
|
|
"stream-json",
|
|
"--verbose",
|
|
"--include-partial-messages",
|
|
"--permission-prompt-tool",
|
|
"stdio",
|
|
]
|
|
if options.model:
|
|
args += ["--model", options.model]
|
|
if options.resume:
|
|
args += ["--resume", options.resume]
|
|
if options.instructions:
|
|
args += ["--append-system-prompt", options.instructions]
|
|
return args
|
|
|
|
|
|
async def discover(send, response, cwd=None):
|
|
await send(
|
|
{
|
|
"type": "control_request",
|
|
"request_id": "discovery",
|
|
"request": {"subtype": "initialize"},
|
|
}
|
|
)
|
|
result = (await response("type", "control_response")).get("response", {})
|
|
if result.get("subtype") == "error":
|
|
raise RuntimeError("Claude initialization failed")
|
|
return [
|
|
{
|
|
"id": m.get("resolvedModel") or m["value"],
|
|
"name": m.get("displayName") or m["value"],
|
|
"supportedReasoningEfforts": [
|
|
{"reasoningEffort": level}
|
|
for level in (m.get("supportedEffortLevels") or [])
|
|
],
|
|
}
|
|
for m in result.get("response", {}).get("models", [])
|
|
]
|