Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,16 @@ def main():
profile_checkpoint("cli_main_entry")

import os

# OpenClaude default: experimental API betas off unless the user opts in
# (mirrors typescript/src/entrypoints/cli.tsx:44 — tool search
# defer_loading / global cache scope / context management need internal
# API support external accounts lack → 500). Per-process entry:
# everything cli.main() spawns inherits this via the environment
# (tui_launcher passes env=dict(os.environ)); the standalone
# agent-server entry sets its own (agent_server_cli).
os.environ.setdefault("CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS", "true")

if os.environ.get("CLAWCODEX_DEBUG", "").lower() in ("1", "true", "yes"):
import logging
logging.basicConfig(
Expand Down
9 changes: 9 additions & 0 deletions src/entrypoints/agent_server_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,17 @@
import asyncio
import json
import logging
import os
import sys
import threading

# OpenClaude default: experimental API betas off unless the user opts in
# (mirrors typescript/src/entrypoints/cli.tsx:44's MODULE-scope placement —
# beats any import-time env capture in the heavy imports below). Per-process
# entry: this is the standalone backend where API calls happen; a direct
# ``clawcodex agent-server`` / ``python -m`` run inherits nothing from
# cli.main(), and Ink-spawned children get it by env inheritance too.
os.environ.setdefault("CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS", "true")
from pathlib import Path

# ch02 round-4 WI-4 — bracket the child's import cost. This module is the
Expand Down
17 changes: 17 additions & 0 deletions src/entrypoints/mcp.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,22 @@ def run_mcp_subcommand(rest: list[str]) -> int:
verb = rest[0]
if verb == "list":
return _list_servers()
if verb == "serve":
# Engine imported only inside this branch — the ``list`` fast path
# keeps its lean-import contract; ``serve`` inherently loads the
# tool registry. Mirrors typescript/src/entrypoints/mcp.ts
# (startMCPServer); the TS verb router lives in cli/handlers/mcp.tsx.
import os

# OpenClaude default: experimental API betas off unless the user
# opts in (mcp.ts:6 sets this in TS's separate mcp bundle; here the
# value normally arrives inherited from cli.main(), and this covers
# any direct invocation of the handler).
os.environ.setdefault("CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS", "true")
from src.entrypoints.mcp_serve import run_serve

args = rest[1:]
return run_serve(debug="--debug" in args, verbose="--verbose" in args)
print(f"clawcodex mcp: unknown verb {verb!r}", file=sys.stderr)
_print_usage()
return 2
Expand All @@ -40,6 +56,7 @@ def _print_usage() -> None:
print("")
print("Verbs:")
print(" list List configured MCP servers")
print(" serve Re-expose clawcodex's tools as an MCP stdio server")


def _list_servers() -> int:
Expand Down
Loading