dispatchbox 0.1.1__tar.gz → 0.1.2__tar.gz
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.
- {dispatchbox-0.1.1/dispatchbox.egg-info → dispatchbox-0.1.2}/PKG-INFO +1 -1
- {dispatchbox-0.1.1 → dispatchbox-0.1.2}/dispatchbox/__init__.py +1 -1
- {dispatchbox-0.1.1 → dispatchbox-0.1.2}/dispatchbox/server.py +8 -1
- {dispatchbox-0.1.1 → dispatchbox-0.1.2/dispatchbox.egg-info}/PKG-INFO +1 -1
- {dispatchbox-0.1.1 → dispatchbox-0.1.2}/pyproject.toml +1 -1
- {dispatchbox-0.1.1 → dispatchbox-0.1.2}/tests/test_e2e.py +13 -0
- {dispatchbox-0.1.1 → dispatchbox-0.1.2}/LICENSE +0 -0
- {dispatchbox-0.1.1 → dispatchbox-0.1.2}/MANIFEST.in +0 -0
- {dispatchbox-0.1.1 → dispatchbox-0.1.2}/README.md +0 -0
- {dispatchbox-0.1.1 → dispatchbox-0.1.2}/dispatchbox/__main__.py +0 -0
- {dispatchbox-0.1.1 → dispatchbox-0.1.2}/dispatchbox/chat.py +0 -0
- {dispatchbox-0.1.1 → dispatchbox-0.1.2}/dispatchbox/cron.py +0 -0
- {dispatchbox-0.1.1 → dispatchbox-0.1.2}/dispatchbox/feishu.py +0 -0
- {dispatchbox-0.1.1 → dispatchbox-0.1.2}/dispatchbox/hub.py +0 -0
- {dispatchbox-0.1.1 → dispatchbox-0.1.2}/dispatchbox/net.py +0 -0
- {dispatchbox-0.1.1 → dispatchbox-0.1.2}/dispatchbox/rules.py +0 -0
- {dispatchbox-0.1.1 → dispatchbox-0.1.2}/dispatchbox/slack.py +0 -0
- {dispatchbox-0.1.1 → dispatchbox-0.1.2}/dispatchbox/store.py +0 -0
- {dispatchbox-0.1.1 → dispatchbox-0.1.2}/dispatchbox/worker.py +0 -0
- {dispatchbox-0.1.1 → dispatchbox-0.1.2}/dispatchbox.egg-info/SOURCES.txt +0 -0
- {dispatchbox-0.1.1 → dispatchbox-0.1.2}/dispatchbox.egg-info/dependency_links.txt +0 -0
- {dispatchbox-0.1.1 → dispatchbox-0.1.2}/dispatchbox.egg-info/entry_points.txt +0 -0
- {dispatchbox-0.1.1 → dispatchbox-0.1.2}/dispatchbox.egg-info/requires.txt +0 -0
- {dispatchbox-0.1.1 → dispatchbox-0.1.2}/dispatchbox.egg-info/top_level.txt +0 -0
- {dispatchbox-0.1.1 → dispatchbox-0.1.2}/examples/hello-codex.json +0 -0
- {dispatchbox-0.1.1 → dispatchbox-0.1.2}/examples/hello.json +0 -0
- {dispatchbox-0.1.1 → dispatchbox-0.1.2}/rules.example.json +0 -0
- {dispatchbox-0.1.1 → dispatchbox-0.1.2}/setup.cfg +0 -0
- {dispatchbox-0.1.1 → dispatchbox-0.1.2}/tests/__init__.py +0 -0
- {dispatchbox-0.1.1 → dispatchbox-0.1.2}/tests/helpers.py +0 -0
- {dispatchbox-0.1.1 → dispatchbox-0.1.2}/tests/test_chat.py +0 -0
- {dispatchbox-0.1.1 → dispatchbox-0.1.2}/tests/test_cron_rules.py +0 -0
- {dispatchbox-0.1.1 → dispatchbox-0.1.2}/tests/test_hub.py +0 -0
- {dispatchbox-0.1.1 → dispatchbox-0.1.2}/tests/test_net.py +0 -0
- {dispatchbox-0.1.1 → dispatchbox-0.1.2}/tests/test_step0.py +0 -0
|
@@ -151,7 +151,7 @@ class Handler(BaseHTTPRequestHandler):
|
|
|
151
151
|
try:
|
|
152
152
|
self._route(method, parts, query)
|
|
153
153
|
except HubError as e:
|
|
154
|
-
if
|
|
154
|
+
if self._wants_json(parts):
|
|
155
155
|
self._json(e.status, {"error": str(e)})
|
|
156
156
|
else:
|
|
157
157
|
self._html(e.status, page("Error", f"<p>{html.escape(str(e))}</p><p><a href='/'>Back</a></p>"))
|
|
@@ -161,6 +161,13 @@ class Handler(BaseHTTPRequestHandler):
|
|
|
161
161
|
log.exception("request failed")
|
|
162
162
|
self._json(500, {"error": f"internal error: {e.__class__.__name__}"})
|
|
163
163
|
|
|
164
|
+
def _wants_json(self, parts: list[str]) -> bool:
|
|
165
|
+
"""API clients get JSON errors; only a browser using the dashboard gets an HTML page."""
|
|
166
|
+
return (parts[:1] in (["api"], ["events"], ["claim"], ["hooks"])
|
|
167
|
+
or self.headers.get("Accept", "").startswith("application/json")
|
|
168
|
+
or self.headers.get("Content-Type", "").startswith("application/json")
|
|
169
|
+
or self.headers.get("Authorization", "").startswith("Bearer "))
|
|
170
|
+
|
|
164
171
|
def _route(self, method: str, parts: list[str], q: dict[str, str]) -> None:
|
|
165
172
|
if parts == ["healthz"]:
|
|
166
173
|
return self._json(200, {"ok": True})
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "dispatchbox"
|
|
7
|
-
version = "0.1.
|
|
7
|
+
version = "0.1.2"
|
|
8
8
|
description = "Route events to Claude Code and Codex running on your own machines, and ask you only when it matters."
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
requires-python = ">=3.10"
|
|
@@ -130,6 +130,19 @@ class E2ETest(unittest.TestCase):
|
|
|
130
130
|
self.assertEqual(http("GET", self.base + "/healthz", token=None)[0], 200)
|
|
131
131
|
self.assertEqual(http("POST", self.base + "/events", {"source": "a"})[0], 400)
|
|
132
132
|
|
|
133
|
+
def test_api_errors_are_json_without_an_accept_header(self):
|
|
134
|
+
no_accept = {"Accept": ""}
|
|
135
|
+
s, body = http("POST", self.base + "/runs/999/decision", {"choice": "x"}, headers=no_accept)
|
|
136
|
+
self.assertEqual(s, 404)
|
|
137
|
+
self.assertEqual(json.loads(body), {"error": "run 999 not found"})
|
|
138
|
+
s, body = http("POST", self.base + "/runs/999/decision", {"choice": "x"}, token=None, headers=no_accept)
|
|
139
|
+
self.assertEqual(s, 401)
|
|
140
|
+
self.assertIn("error", json.loads(body))
|
|
141
|
+
# A browser posting the dashboard form still gets a page.
|
|
142
|
+
s, body = http("POST", self.base + "/runs/999/decision", token=None, form="choice=x",
|
|
143
|
+
headers={"Accept": "text/html"})
|
|
144
|
+
self.assertTrue(body.lstrip().startswith("<!doctype html>"), body[:80])
|
|
145
|
+
|
|
133
146
|
def test_full_loop_with_decision_and_resume(self):
|
|
134
147
|
self.start_worker()
|
|
135
148
|
s, body = http("POST", self.base + "/events", {"source": "github", "type": "pr.opened", "subject": "r#1"})
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|