clearbox 0.1.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
clearbox/__init__.py ADDED
@@ -0,0 +1 @@
1
+ """Clearbox: DAG plans executed by agents, visualised live."""
clearbox/__main__.py ADDED
@@ -0,0 +1,84 @@
1
+ """Command line entry point: ``clearbox`` / ``python -m clearbox``."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import argparse
6
+ import logging
7
+ import os
8
+ import sys
9
+
10
+ import uvicorn
11
+
12
+ from .app import Settings, create_app
13
+ from .bootstrap import StartupError
14
+
15
+
16
+ def main() -> None:
17
+ env = os.environ.get
18
+ ap = argparse.ArgumentParser(prog="clearbox", description=__doc__)
19
+ ap.add_argument("--host", default=env("CLEARBOX_HOST", "127.0.0.1"))
20
+ ap.add_argument("--port", type=int, default=int(env("CLEARBOX_PORT", "8765")))
21
+ ap.add_argument("--db", default=env("CLEARBOX_DB", "clearbox.db"), help="SQLite file")
22
+ ap.add_argument("--workdir", default=env("CLEARBOX_WORKDIR", "workspace"),
23
+ help="base directory; each plan's agents work in <workdir>/plan-<id>")
24
+ ap.add_argument("--mock", action="store_true", default=env("CLEARBOX_AGENT") == "mock",
25
+ help="use fake agents (no Claude sessions, no cost) to try out the UI")
26
+ ap.add_argument("--mock-speed", type=float, default=1.0)
27
+ ap.add_argument("--max-concurrency", type=int, default=int(env("CLEARBOX_MAX_CONCURRENCY", "3")))
28
+ ap.add_argument("--permission-mode", default=env("CLEARBOX_PERMISSION_MODE", "acceptEdits"),
29
+ choices=["default", "acceptEdits", "plan", "bypassPermissions", "dontAsk", "auto"],
30
+ help="permission mode for built-in agents")
31
+ ap.add_argument("--model", default=env("CLEARBOX_MODEL"))
32
+ ap.add_argument("--max-turns", type=int, default=None)
33
+ ap.add_argument("--no-agent-mcp", action="store_true",
34
+ help="do not give built-in agents access to the clearbox MCP tools")
35
+ ap.add_argument("--agent-profile", default=env("CLEARBOX_AGENT_PROFILE"), metavar="NAME",
36
+ help="server-wide default agent profile (default: 'mock' with --mock, else 'claude')")
37
+ ap.add_argument("--openai-base-url", default=env("OPENAI_BASE_URL"), metavar="URL",
38
+ help="bootstrap the 'openai' profile for this OpenAI-compatible endpoint, "
39
+ "e.g. http://localhost:11434/v1")
40
+ ap.add_argument("--openai-model", default=env("CLEARBOX_OPENAI_MODEL"), metavar="NAME",
41
+ help="model of the bootstrapped 'openai' profile")
42
+ ap.add_argument("--openai-api-key-env", default="OPENAI_API_KEY", metavar="NAME",
43
+ help="NAME of the environment variable holding the 'openai' profile's api key")
44
+ args = ap.parse_args()
45
+
46
+ logging.basicConfig(level=logging.INFO, format="%(asctime)s %(levelname)s %(name)s: %(message)s")
47
+ settings = Settings(
48
+ host=args.host,
49
+ port=args.port,
50
+ db=args.db,
51
+ workdir=args.workdir,
52
+ agent="mock" if args.mock else "claude",
53
+ mock_speed=args.mock_speed,
54
+ max_concurrency=args.max_concurrency,
55
+ permission_mode=args.permission_mode,
56
+ model=args.model,
57
+ max_turns=args.max_turns,
58
+ expose_mcp_to_agents=not args.no_agent_mcp,
59
+ default_agent=args.agent_profile,
60
+ openai_base_url=args.openai_base_url,
61
+ openai_model=args.openai_model,
62
+ openai_api_key_env=args.openai_api_key_env,
63
+ )
64
+ try:
65
+ app = create_app(settings)
66
+ except StartupError as e:
67
+ print(f"clearbox: error: {e}", file=sys.stderr)
68
+ sys.exit(2)
69
+ print(f"Clearbox UI: http://{settings.host}:{settings.port}/")
70
+ print(f"MCP endpoint: {settings.mcp_url} (agents: {settings.agent})")
71
+ print(f"Agents: {app.state.agents_line}")
72
+ # Ctrl+C must always get the port back. uvicorn waits for open connections *before* running
73
+ # the lifespan shutdown, and /api/stream is endless, so the app has to notice the stop itself:
74
+ # it watches server.should_exit, which is set the moment the signal arrives. The timeout is
75
+ # the backstop for anything else still holding a connection.
76
+ config = uvicorn.Config(app, host=settings.host, port=settings.port, log_level="warning",
77
+ timeout_graceful_shutdown=5)
78
+ server = uvicorn.Server(config)
79
+ app.state.server = server
80
+ server.run()
81
+
82
+
83
+ if __name__ == "__main__":
84
+ main()
clearbox/agents.py ADDED
@@ -0,0 +1,12 @@
1
+ """Backwards-compatible aliases for code that still imports from ``clearbox.agents``."""
2
+
3
+ from __future__ import annotations
4
+
5
+ # The implementations moved to the clearbox.harness package.
6
+ from .harness import AgentJob, ClaudeSdkHarness, MockHarness
7
+ from .harness.base import MAX_TOOL_RESULT_CHARS, _tool_result_text, _truncate
8
+
9
+ ClaudeBackend = ClaudeSdkHarness
10
+ MockBackend = MockHarness
11
+
12
+ __all__ = ["AgentJob", "ClaudeBackend", "MockBackend", "MAX_TOOL_RESULT_CHARS", "_tool_result_text", "_truncate"]