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.
Files changed (35) hide show
  1. {dispatchbox-0.1.1/dispatchbox.egg-info → dispatchbox-0.1.2}/PKG-INFO +1 -1
  2. {dispatchbox-0.1.1 → dispatchbox-0.1.2}/dispatchbox/__init__.py +1 -1
  3. {dispatchbox-0.1.1 → dispatchbox-0.1.2}/dispatchbox/server.py +8 -1
  4. {dispatchbox-0.1.1 → dispatchbox-0.1.2/dispatchbox.egg-info}/PKG-INFO +1 -1
  5. {dispatchbox-0.1.1 → dispatchbox-0.1.2}/pyproject.toml +1 -1
  6. {dispatchbox-0.1.1 → dispatchbox-0.1.2}/tests/test_e2e.py +13 -0
  7. {dispatchbox-0.1.1 → dispatchbox-0.1.2}/LICENSE +0 -0
  8. {dispatchbox-0.1.1 → dispatchbox-0.1.2}/MANIFEST.in +0 -0
  9. {dispatchbox-0.1.1 → dispatchbox-0.1.2}/README.md +0 -0
  10. {dispatchbox-0.1.1 → dispatchbox-0.1.2}/dispatchbox/__main__.py +0 -0
  11. {dispatchbox-0.1.1 → dispatchbox-0.1.2}/dispatchbox/chat.py +0 -0
  12. {dispatchbox-0.1.1 → dispatchbox-0.1.2}/dispatchbox/cron.py +0 -0
  13. {dispatchbox-0.1.1 → dispatchbox-0.1.2}/dispatchbox/feishu.py +0 -0
  14. {dispatchbox-0.1.1 → dispatchbox-0.1.2}/dispatchbox/hub.py +0 -0
  15. {dispatchbox-0.1.1 → dispatchbox-0.1.2}/dispatchbox/net.py +0 -0
  16. {dispatchbox-0.1.1 → dispatchbox-0.1.2}/dispatchbox/rules.py +0 -0
  17. {dispatchbox-0.1.1 → dispatchbox-0.1.2}/dispatchbox/slack.py +0 -0
  18. {dispatchbox-0.1.1 → dispatchbox-0.1.2}/dispatchbox/store.py +0 -0
  19. {dispatchbox-0.1.1 → dispatchbox-0.1.2}/dispatchbox/worker.py +0 -0
  20. {dispatchbox-0.1.1 → dispatchbox-0.1.2}/dispatchbox.egg-info/SOURCES.txt +0 -0
  21. {dispatchbox-0.1.1 → dispatchbox-0.1.2}/dispatchbox.egg-info/dependency_links.txt +0 -0
  22. {dispatchbox-0.1.1 → dispatchbox-0.1.2}/dispatchbox.egg-info/entry_points.txt +0 -0
  23. {dispatchbox-0.1.1 → dispatchbox-0.1.2}/dispatchbox.egg-info/requires.txt +0 -0
  24. {dispatchbox-0.1.1 → dispatchbox-0.1.2}/dispatchbox.egg-info/top_level.txt +0 -0
  25. {dispatchbox-0.1.1 → dispatchbox-0.1.2}/examples/hello-codex.json +0 -0
  26. {dispatchbox-0.1.1 → dispatchbox-0.1.2}/examples/hello.json +0 -0
  27. {dispatchbox-0.1.1 → dispatchbox-0.1.2}/rules.example.json +0 -0
  28. {dispatchbox-0.1.1 → dispatchbox-0.1.2}/setup.cfg +0 -0
  29. {dispatchbox-0.1.1 → dispatchbox-0.1.2}/tests/__init__.py +0 -0
  30. {dispatchbox-0.1.1 → dispatchbox-0.1.2}/tests/helpers.py +0 -0
  31. {dispatchbox-0.1.1 → dispatchbox-0.1.2}/tests/test_chat.py +0 -0
  32. {dispatchbox-0.1.1 → dispatchbox-0.1.2}/tests/test_cron_rules.py +0 -0
  33. {dispatchbox-0.1.1 → dispatchbox-0.1.2}/tests/test_hub.py +0 -0
  34. {dispatchbox-0.1.1 → dispatchbox-0.1.2}/tests/test_net.py +0 -0
  35. {dispatchbox-0.1.1 → dispatchbox-0.1.2}/tests/test_step0.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: dispatchbox
3
- Version: 0.1.1
3
+ Version: 0.1.2
4
4
  Summary: Route events to Claude Code and Codex running on your own machines, and ask you only when it matters.
5
5
  Author: Xixian Yang
6
6
  License-Expression: MIT
@@ -1,3 +1,3 @@
1
1
  """dispatchbox: a thin event router that hands work to coding agents on your own machines."""
2
2
 
3
- __version__ = "0.1.1"
3
+ __version__ = "0.1.2"
@@ -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 parts[:1] in (["api"], ["events"], ["claim"], ["hooks"]) or self.headers.get("Accept", "").startswith("application/json"):
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})
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: dispatchbox
3
- Version: 0.1.1
3
+ Version: 0.1.2
4
4
  Summary: Route events to Claude Code and Codex running on your own machines, and ask you only when it matters.
5
5
  Author: Xixian Yang
6
6
  License-Expression: MIT
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "dispatchbox"
7
- version = "0.1.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