benethos-mailbox-agents 0.1.0__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 (219) hide show
  1. benethos_mailbox_agents-0.1.0/.dockerignore +8 -0
  2. benethos_mailbox_agents-0.1.0/.gitattributes +7 -0
  3. benethos_mailbox_agents-0.1.0/.githooks/pre-commit +85 -0
  4. benethos_mailbox_agents-0.1.0/.github/dependabot.yml +70 -0
  5. benethos_mailbox_agents-0.1.0/.github/workflows/ci.yml +250 -0
  6. benethos_mailbox_agents-0.1.0/.github/workflows/codeql.yml +25 -0
  7. benethos_mailbox_agents-0.1.0/.github/workflows/freshness.yml +75 -0
  8. benethos_mailbox_agents-0.1.0/.github/workflows/publish.yml +130 -0
  9. benethos_mailbox_agents-0.1.0/.gitignore +66 -0
  10. benethos_mailbox_agents-0.1.0/CHANGELOG.md +173 -0
  11. benethos_mailbox_agents-0.1.0/CLAUDE.md +194 -0
  12. benethos_mailbox_agents-0.1.0/LICENSE +21 -0
  13. benethos_mailbox_agents-0.1.0/PKG-INFO +108 -0
  14. benethos_mailbox_agents-0.1.0/README.md +80 -0
  15. benethos_mailbox_agents-0.1.0/assets/brand/icon.png +0 -0
  16. benethos_mailbox_agents-0.1.0/assets/brand/icon.svg +34 -0
  17. benethos_mailbox_agents-0.1.0/assets/brand/social-preview.png +0 -0
  18. benethos_mailbox_agents-0.1.0/assets/build.py +312 -0
  19. benethos_mailbox_agents-0.1.0/config/benethos-mailbox-agents/.env.example +93 -0
  20. benethos_mailbox_agents-0.1.0/config/benethos-mailbox-agents/inquiries.example.json +8 -0
  21. benethos_mailbox_agents-0.1.0/config/benethos-mailbox-agents/sorting.example.json +28 -0
  22. benethos_mailbox_agents-0.1.0/containers/README.md +64 -0
  23. benethos_mailbox_agents-0.1.0/containers/development/compose.yaml +114 -0
  24. benethos_mailbox_agents-0.1.0/containers/images/mailbox-agents/Dockerfile +74 -0
  25. benethos_mailbox_agents-0.1.0/containers/live/README.md +270 -0
  26. benethos_mailbox_agents-0.1.0/containers/live/compose.yaml +167 -0
  27. benethos_mailbox_agents-0.1.0/containers/live/fetch-models.sh +99 -0
  28. benethos_mailbox_agents-0.1.0/containers/live/litellm.yaml +121 -0
  29. benethos_mailbox_agents-0.1.0/containers/live/llama/presets-cpu.ini +36 -0
  30. benethos_mailbox_agents-0.1.0/containers/live/llama/presets-gpu.ini +39 -0
  31. benethos_mailbox_agents-0.1.0/containers/live/mail.py +335 -0
  32. benethos_mailbox_agents-0.1.0/containers/live/nvidia-toolkit.sh +53 -0
  33. benethos_mailbox_agents-0.1.0/containers/live/provision.py +414 -0
  34. benethos_mailbox_agents-0.1.0/containers/live/setup.sh +132 -0
  35. benethos_mailbox_agents-0.1.0/containers/live/sorting.json +33 -0
  36. benethos_mailbox_agents-0.1.0/containers/production/.env.example +15 -0
  37. benethos_mailbox_agents-0.1.0/containers/production/README.md +68 -0
  38. benethos_mailbox_agents-0.1.0/containers/production/agents/awaiting_reply/.env.example +33 -0
  39. benethos_mailbox_agents-0.1.0/containers/production/agents/counting/.env.example +23 -0
  40. benethos_mailbox_agents-0.1.0/containers/production/agents/inquiries/.env.example +31 -0
  41. benethos_mailbox_agents-0.1.0/containers/production/agents/inquiries/inquiries.example.json +8 -0
  42. benethos_mailbox_agents-0.1.0/containers/production/agents/invoices/.env.example +37 -0
  43. benethos_mailbox_agents-0.1.0/containers/production/agents/sorting/.env.example +25 -0
  44. benethos_mailbox_agents-0.1.0/containers/production/agents/sorting/sorting.example.json +28 -0
  45. benethos_mailbox_agents-0.1.0/containers/production/compose.yaml +155 -0
  46. benethos_mailbox_agents-0.1.0/data/.gitkeep +0 -0
  47. benethos_mailbox_agents-0.1.0/docs/ARCHITECTURE.md +139 -0
  48. benethos_mailbox_agents-0.1.0/docs/COMPATIBILITY.md +20 -0
  49. benethos_mailbox_agents-0.1.0/docs/CONCEPT.md +136 -0
  50. benethos_mailbox_agents-0.1.0/docs/LOGGING.md +162 -0
  51. benethos_mailbox_agents-0.1.0/docs/RELEASING.md +70 -0
  52. benethos_mailbox_agents-0.1.0/docs/ROADMAP.md +46 -0
  53. benethos_mailbox_agents-0.1.0/docs/concept/agent-awaiting-reply.md +57 -0
  54. benethos_mailbox_agents-0.1.0/docs/concept/agent-contract.md +160 -0
  55. benethos_mailbox_agents-0.1.0/docs/concept/agent-counting.md +9 -0
  56. benethos_mailbox_agents-0.1.0/docs/concept/agent-inquiries.md +41 -0
  57. benethos_mailbox_agents-0.1.0/docs/concept/agent-invoices.md +301 -0
  58. benethos_mailbox_agents-0.1.0/docs/concept/agent-sorting.md +320 -0
  59. benethos_mailbox_agents-0.1.0/docs/concept/configuration.md +38 -0
  60. benethos_mailbox_agents-0.1.0/docs/concept/evaluation.md +51 -0
  61. benethos_mailbox_agents-0.1.0/docs/concept/mailbox-service.md +206 -0
  62. benethos_mailbox_agents-0.1.0/docs/concept/model-gateway.md +41 -0
  63. benethos_mailbox_agents-0.1.0/docs/concept/operation.md +45 -0
  64. benethos_mailbox_agents-0.1.0/docs/concept/runtime.md +118 -0
  65. benethos_mailbox_agents-0.1.0/docs/concept/safety.md +57 -0
  66. benethos_mailbox_agents-0.1.0/docs/concept/state.md +43 -0
  67. benethos_mailbox_agents-0.1.0/docs/concept/testing.md +50 -0
  68. benethos_mailbox_agents-0.1.0/live/common.py +262 -0
  69. benethos_mailbox_agents-0.1.0/live/gold.py +68 -0
  70. benethos_mailbox_agents-0.1.0/live/invoices.py +363 -0
  71. benethos_mailbox_agents-0.1.0/live/smoke.py +170 -0
  72. benethos_mailbox_agents-0.1.0/live/sorting.py +169 -0
  73. benethos_mailbox_agents-0.1.0/pyproject.toml +122 -0
  74. benethos_mailbox_agents-0.1.0/reports/.gitkeep +0 -0
  75. benethos_mailbox_agents-0.1.0/reports/invoices/2026-11-18-v4-v4-mail-classifier-gpu.json +81 -0
  76. benethos_mailbox_agents-0.1.0/reports/invoices/2026-11-18-v4-v4-mail-classifier.json +81 -0
  77. benethos_mailbox_agents-0.1.0/src/benethos_mailbox_agents/__init__.py +15 -0
  78. benethos_mailbox_agents-0.1.0/src/benethos_mailbox_agents/__main__.py +8 -0
  79. benethos_mailbox_agents-0.1.0/src/benethos_mailbox_agents/agents/__init__.py +3 -0
  80. benethos_mailbox_agents-0.1.0/src/benethos_mailbox_agents/agents/awaiting_reply/__init__.py +2 -0
  81. benethos_mailbox_agents-0.1.0/src/benethos_mailbox_agents/agents/awaiting_reply/agent.py +234 -0
  82. benethos_mailbox_agents-0.1.0/src/benethos_mailbox_agents/agents/awaiting_reply/prompts/system.v1.md +20 -0
  83. benethos_mailbox_agents-0.1.0/src/benethos_mailbox_agents/agents/awaiting_reply/schema.py +59 -0
  84. benethos_mailbox_agents-0.1.0/src/benethos_mailbox_agents/agents/awaiting_reply/text.py +142 -0
  85. benethos_mailbox_agents-0.1.0/src/benethos_mailbox_agents/agents/counting/__init__.py +2 -0
  86. benethos_mailbox_agents-0.1.0/src/benethos_mailbox_agents/agents/counting/agent.py +52 -0
  87. benethos_mailbox_agents-0.1.0/src/benethos_mailbox_agents/agents/inquiries/__init__.py +2 -0
  88. benethos_mailbox_agents-0.1.0/src/benethos_mailbox_agents/agents/inquiries/agent.py +101 -0
  89. benethos_mailbox_agents-0.1.0/src/benethos_mailbox_agents/agents/inquiries/baseline.py +25 -0
  90. benethos_mailbox_agents-0.1.0/src/benethos_mailbox_agents/agents/inquiries/patterns.py +102 -0
  91. benethos_mailbox_agents-0.1.0/src/benethos_mailbox_agents/agents/inquiries/prompts/system.v1.md +19 -0
  92. benethos_mailbox_agents-0.1.0/src/benethos_mailbox_agents/agents/inquiries/prompts/system.v2.md +29 -0
  93. benethos_mailbox_agents-0.1.0/src/benethos_mailbox_agents/agents/inquiries/prompts/system.v3.md +30 -0
  94. benethos_mailbox_agents-0.1.0/src/benethos_mailbox_agents/agents/inquiries/schema.py +128 -0
  95. benethos_mailbox_agents-0.1.0/src/benethos_mailbox_agents/agents/invoices/__init__.py +2 -0
  96. benethos_mailbox_agents-0.1.0/src/benethos_mailbox_agents/agents/invoices/agent.py +237 -0
  97. benethos_mailbox_agents-0.1.0/src/benethos_mailbox_agents/agents/invoices/baseline.py +105 -0
  98. benethos_mailbox_agents-0.1.0/src/benethos_mailbox_agents/agents/invoices/folders.py +253 -0
  99. benethos_mailbox_agents-0.1.0/src/benethos_mailbox_agents/agents/invoices/prompts/system.v1.md +34 -0
  100. benethos_mailbox_agents-0.1.0/src/benethos_mailbox_agents/agents/invoices/prompts/system.v2.md +39 -0
  101. benethos_mailbox_agents-0.1.0/src/benethos_mailbox_agents/agents/invoices/prompts/system.v3.md +42 -0
  102. benethos_mailbox_agents-0.1.0/src/benethos_mailbox_agents/agents/invoices/prompts/system.v4.md +38 -0
  103. benethos_mailbox_agents-0.1.0/src/benethos_mailbox_agents/agents/invoices/schema.py +113 -0
  104. benethos_mailbox_agents-0.1.0/src/benethos_mailbox_agents/agents/sorting/__init__.py +1 -0
  105. benethos_mailbox_agents-0.1.0/src/benethos_mailbox_agents/agents/sorting/agent.py +236 -0
  106. benethos_mailbox_agents-0.1.0/src/benethos_mailbox_agents/agents/sorting/groups.py +278 -0
  107. benethos_mailbox_agents-0.1.0/src/benethos_mailbox_agents/cli/__init__.py +132 -0
  108. benethos_mailbox_agents-0.1.0/src/benethos_mailbox_agents/cli/commands.py +282 -0
  109. benethos_mailbox_agents-0.1.0/src/benethos_mailbox_agents/cli/report.py +158 -0
  110. benethos_mailbox_agents-0.1.0/src/benethos_mailbox_agents/cli/session.py +107 -0
  111. benethos_mailbox_agents-0.1.0/src/benethos_mailbox_agents/contract/__init__.py +36 -0
  112. benethos_mailbox_agents-0.1.0/src/benethos_mailbox_agents/contract/agent.py +297 -0
  113. benethos_mailbox_agents-0.1.0/src/benethos_mailbox_agents/contract/context.py +89 -0
  114. benethos_mailbox_agents-0.1.0/src/benethos_mailbox_agents/contract/prompts.py +23 -0
  115. benethos_mailbox_agents-0.1.0/src/benethos_mailbox_agents/contract/registry.py +63 -0
  116. benethos_mailbox_agents-0.1.0/src/benethos_mailbox_agents/errors/__init__.py +49 -0
  117. benethos_mailbox_agents-0.1.0/src/benethos_mailbox_agents/errors/action_refused.py +16 -0
  118. benethos_mailbox_agents-0.1.0/src/benethos_mailbox_agents/errors/answer_refused.py +18 -0
  119. benethos_mailbox_agents-0.1.0/src/benethos_mailbox_agents/errors/base.py +24 -0
  120. benethos_mailbox_agents-0.1.0/src/benethos_mailbox_agents/errors/changes_expired.py +13 -0
  121. benethos_mailbox_agents-0.1.0/src/benethos_mailbox_agents/errors/config.py +13 -0
  122. benethos_mailbox_agents-0.1.0/src/benethos_mailbox_agents/errors/contract.py +14 -0
  123. benethos_mailbox_agents-0.1.0/src/benethos_mailbox_agents/errors/gateway_unavailable.py +14 -0
  124. benethos_mailbox_agents-0.1.0/src/benethos_mailbox_agents/errors/invalid.py +22 -0
  125. benethos_mailbox_agents-0.1.0/src/benethos_mailbox_agents/errors/limit_reached.py +19 -0
  126. benethos_mailbox_agents-0.1.0/src/benethos_mailbox_agents/errors/mailbox_refused.py +19 -0
  127. benethos_mailbox_agents-0.1.0/src/benethos_mailbox_agents/errors/mailbox_unavailable.py +13 -0
  128. benethos_mailbox_agents-0.1.0/src/benethos_mailbox_agents/errors/message_gone.py +12 -0
  129. benethos_mailbox_agents-0.1.0/src/benethos_mailbox_agents/errors/redaction.py +34 -0
  130. benethos_mailbox_agents-0.1.0/src/benethos_mailbox_agents/errors/service_version.py +15 -0
  131. benethos_mailbox_agents-0.1.0/src/benethos_mailbox_agents/errors/state_file.py +14 -0
  132. benethos_mailbox_agents-0.1.0/src/benethos_mailbox_agents/errors/unavailable.py +14 -0
  133. benethos_mailbox_agents-0.1.0/src/benethos_mailbox_agents/evaluation/__init__.py +2 -0
  134. benethos_mailbox_agents-0.1.0/src/benethos_mailbox_agents/evaluation/gold.py +70 -0
  135. benethos_mailbox_agents-0.1.0/src/benethos_mailbox_agents/evaluation/report.py +167 -0
  136. benethos_mailbox_agents-0.1.0/src/benethos_mailbox_agents/evaluation/run.py +73 -0
  137. benethos_mailbox_agents-0.1.0/src/benethos_mailbox_agents/evaluation/scoring.py +142 -0
  138. benethos_mailbox_agents-0.1.0/src/benethos_mailbox_agents/llm/__init__.py +2 -0
  139. benethos_mailbox_agents-0.1.0/src/benethos_mailbox_agents/llm/evidence.py +87 -0
  140. benethos_mailbox_agents-0.1.0/src/benethos_mailbox_agents/llm/gateway.py +232 -0
  141. benethos_mailbox_agents-0.1.0/src/benethos_mailbox_agents/logbook/__init__.py +31 -0
  142. benethos_mailbox_agents-0.1.0/src/benethos_mailbox_agents/logbook/activity.py +120 -0
  143. benethos_mailbox_agents-0.1.0/src/benethos_mailbox_agents/logbook/catalogue/__init__.py +15 -0
  144. benethos_mailbox_agents-0.1.0/src/benethos_mailbox_agents/logbook/catalogue/actions.py +73 -0
  145. benethos_mailbox_agents-0.1.0/src/benethos_mailbox_agents/logbook/catalogue/feed.py +49 -0
  146. benethos_mailbox_agents-0.1.0/src/benethos_mailbox_agents/logbook/catalogue/messages.py +76 -0
  147. benethos_mailbox_agents-0.1.0/src/benethos_mailbox_agents/logbook/catalogue/process.py +63 -0
  148. benethos_mailbox_agents-0.1.0/src/benethos_mailbox_agents/logbook/catalogue/worker.py +56 -0
  149. benethos_mailbox_agents-0.1.0/src/benethos_mailbox_agents/logbook/output.py +129 -0
  150. benethos_mailbox_agents-0.1.0/src/benethos_mailbox_agents/py.typed +0 -0
  151. benethos_mailbox_agents-0.1.0/src/benethos_mailbox_agents/records/__init__.py +38 -0
  152. benethos_mailbox_agents-0.1.0/src/benethos_mailbox_agents/records/decisions.py +73 -0
  153. benethos_mailbox_agents-0.1.0/src/benethos_mailbox_agents/records/items.py +41 -0
  154. benethos_mailbox_agents-0.1.0/src/benethos_mailbox_agents/records/mail.py +121 -0
  155. benethos_mailbox_agents-0.1.0/src/benethos_mailbox_agents/runtime/__init__.py +2 -0
  156. benethos_mailbox_agents-0.1.0/src/benethos_mailbox_agents/runtime/actions.py +481 -0
  157. benethos_mailbox_agents-0.1.0/src/benethos_mailbox_agents/runtime/health.py +42 -0
  158. benethos_mailbox_agents-0.1.0/src/benethos_mailbox_agents/runtime/items.py +43 -0
  159. benethos_mailbox_agents-0.1.0/src/benethos_mailbox_agents/runtime/loop.py +410 -0
  160. benethos_mailbox_agents-0.1.0/src/benethos_mailbox_agents/runtime/metrics.py +132 -0
  161. benethos_mailbox_agents-0.1.0/src/benethos_mailbox_agents/runtime/model.py +155 -0
  162. benethos_mailbox_agents-0.1.0/src/benethos_mailbox_agents/runtime/reader.py +27 -0
  163. benethos_mailbox_agents-0.1.0/src/benethos_mailbox_agents/runtime/readiness.py +154 -0
  164. benethos_mailbox_agents-0.1.0/src/benethos_mailbox_agents/runtime/steps.py +383 -0
  165. benethos_mailbox_agents-0.1.0/src/benethos_mailbox_agents/settings/__init__.py +215 -0
  166. benethos_mailbox_agents-0.1.0/src/benethos_mailbox_agents/sources/__init__.py +1 -0
  167. benethos_mailbox_agents-0.1.0/src/benethos_mailbox_agents/sources/mailbox.py +444 -0
  168. benethos_mailbox_agents-0.1.0/src/benethos_mailbox_agents/store/__init__.py +18 -0
  169. benethos_mailbox_agents-0.1.0/src/benethos_mailbox_agents/store/migrations/__init__.py +24 -0
  170. benethos_mailbox_agents-0.1.0/src/benethos_mailbox_agents/store/migrations/migration.py +43 -0
  171. benethos_mailbox_agents-0.1.0/src/benethos_mailbox_agents/store/migrations/registry.py +37 -0
  172. benethos_mailbox_agents-0.1.0/src/benethos_mailbox_agents/store/migrations/versions/__init__.py +1 -0
  173. benethos_mailbox_agents-0.1.0/src/benethos_mailbox_agents/store/migrations/versions/v0001_state_file.py +123 -0
  174. benethos_mailbox_agents-0.1.0/src/benethos_mailbox_agents/store/migrations/versions/v0002_keyword_recorded_stage.py +19 -0
  175. benethos_mailbox_agents-0.1.0/src/benethos_mailbox_agents/store/store.py +688 -0
  176. benethos_mailbox_agents-0.1.0/tests/conftest.py +38 -0
  177. benethos_mailbox_agents-0.1.0/tests/data/gold-inquiries.jsonl +8 -0
  178. benethos_mailbox_agents-0.1.0/tests/data/gold-invoices.jsonl +11 -0
  179. benethos_mailbox_agents-0.1.0/tests/data/invented-inquiries.json +44 -0
  180. benethos_mailbox_agents-0.1.0/tests/data/invented.json +86 -0
  181. benethos_mailbox_agents-0.1.0/tests/data/test-ca.pem +15 -0
  182. benethos_mailbox_agents-0.1.0/tests/fakes.py +414 -0
  183. benethos_mailbox_agents-0.1.0/tests/helpers.py +240 -0
  184. benethos_mailbox_agents-0.1.0/tests/test_agent_awaiting_reply.py +670 -0
  185. benethos_mailbox_agents-0.1.0/tests/test_agent_counting.py +45 -0
  186. benethos_mailbox_agents-0.1.0/tests/test_agent_inquiries.py +328 -0
  187. benethos_mailbox_agents-0.1.0/tests/test_agent_invoices.py +927 -0
  188. benethos_mailbox_agents-0.1.0/tests/test_agent_invoices_folders.py +271 -0
  189. benethos_mailbox_agents-0.1.0/tests/test_agent_schemas.py +104 -0
  190. benethos_mailbox_agents-0.1.0/tests/test_agent_sorting.py +423 -0
  191. benethos_mailbox_agents-0.1.0/tests/test_agent_sorting_groups.py +294 -0
  192. benethos_mailbox_agents-0.1.0/tests/test_agents_together.py +166 -0
  193. benethos_mailbox_agents-0.1.0/tests/test_assets_build.py +82 -0
  194. benethos_mailbox_agents-0.1.0/tests/test_cli.py +471 -0
  195. benethos_mailbox_agents-0.1.0/tests/test_cli_report.py +199 -0
  196. benethos_mailbox_agents-0.1.0/tests/test_contract.py +345 -0
  197. benethos_mailbox_agents-0.1.0/tests/test_errors.py +69 -0
  198. benethos_mailbox_agents-0.1.0/tests/test_evaluation_gold.py +67 -0
  199. benethos_mailbox_agents-0.1.0/tests/test_evaluation_run.py +207 -0
  200. benethos_mailbox_agents-0.1.0/tests/test_evaluation_scoring.py +105 -0
  201. benethos_mailbox_agents-0.1.0/tests/test_examples.py +56 -0
  202. benethos_mailbox_agents-0.1.0/tests/test_layers.py +449 -0
  203. benethos_mailbox_agents-0.1.0/tests/test_live_common.py +120 -0
  204. benethos_mailbox_agents-0.1.0/tests/test_llm_evidence.py +211 -0
  205. benethos_mailbox_agents-0.1.0/tests/test_llm_gateway.py +255 -0
  206. benethos_mailbox_agents-0.1.0/tests/test_logbook.py +419 -0
  207. benethos_mailbox_agents-0.1.0/tests/test_pre_commit.py +167 -0
  208. benethos_mailbox_agents-0.1.0/tests/test_records.py +77 -0
  209. benethos_mailbox_agents-0.1.0/tests/test_repo_content.py +260 -0
  210. benethos_mailbox_agents-0.1.0/tests/test_runtime_actions.py +611 -0
  211. benethos_mailbox_agents-0.1.0/tests/test_runtime_health_metrics.py +168 -0
  212. benethos_mailbox_agents-0.1.0/tests/test_runtime_loop.py +371 -0
  213. benethos_mailbox_agents-0.1.0/tests/test_runtime_readiness.py +81 -0
  214. benethos_mailbox_agents-0.1.0/tests/test_runtime_steps.py +304 -0
  215. benethos_mailbox_agents-0.1.0/tests/test_service_version.py +319 -0
  216. benethos_mailbox_agents-0.1.0/tests/test_settings.py +204 -0
  217. benethos_mailbox_agents-0.1.0/tests/test_sources_mailbox.py +306 -0
  218. benethos_mailbox_agents-0.1.0/tests/test_store.py +423 -0
  219. benethos_mailbox_agents-0.1.0/uv.lock +840 -0
@@ -0,0 +1,8 @@
1
+ # The build needs pyproject.toml, uv.lock, README.md and src/. Everything
2
+ # else stays out of the context, above all what holds secrets or mail ids.
3
+ *
4
+ !pyproject.toml
5
+ !uv.lock
6
+ !README.md
7
+ !src/
8
+ **/__pycache__
@@ -0,0 +1,7 @@
1
+ # Normalize line endings: store as LF in the repo, check out native on Windows.
2
+ * text=auto eol=lf
3
+
4
+ # Treat these as binary (never normalize / never diff as text).
5
+ *.png binary
6
+ *.jpg binary
7
+ *.ico binary
@@ -0,0 +1,85 @@
1
+ #!/bin/sh
2
+ # Refuse commits that would put credentials, state files or the gold set
3
+ # into the history.
4
+ #
5
+ # Enable once per clone: git config core.hooksPath .githooks
6
+ # Deliberate bypass: git commit --no-verify
7
+ # Example in a doc/test: end the line with "pragma: allowlist secret"
8
+ #
9
+ # Checks the staged content, not the working tree.
10
+
11
+ set -eu
12
+
13
+ fail=0
14
+ note() {
15
+ printf 'pre-commit: %s\n' "$1" >&2
16
+ fail=1
17
+ }
18
+
19
+ staged=$(git diff --cached --name-only --diff-filter=ACMR)
20
+ [ -n "$staged" ] || exit 0
21
+
22
+ # 1. Files that never belong in the repository: anything in a folder
23
+ # secrets/, a .env other than the example, anything under data/ but
24
+ # .gitkeep, and SQLite files anywhere.
25
+ forbidden=$(
26
+ printf '%s\n' "$staged" | while IFS= read -r file; do
27
+ case "$file" in
28
+ secrets/* | */secrets/*) printf '%s\n' "$file" ;;
29
+ *.env.example) ;;
30
+ .env | */.env | .env.* | */.env.*) printf '%s\n' "$file" ;;
31
+ data/*/.gitkeep | data/.gitkeep) ;;
32
+ data/*) printf '%s\n' "$file" ;;
33
+ *.db | *.db-journal | *.db-wal | *.db-shm | *.sqlite | *.sqlite3)
34
+ printf '%s\n' "$file" ;;
35
+ esac
36
+ done
37
+ )
38
+ if [ -n "$forbidden" ]; then
39
+ note "these files hold configuration, state or real mail ids:"
40
+ printf '%s\n' "$forbidden" | sed 's/^/ /' >&2
41
+ fi
42
+
43
+ # 2. Credentials inside the staged lines, whatever the file is called.
44
+ # tests/test_repo_content.py holds the same patterns for every tracked
45
+ # file. A change to one changes the other.
46
+ patterns='sk-ant-[A-Za-z0-9_-]{16,}'
47
+ patterns="$patterns|sk-[A-Za-z0-9_-]{20,}"
48
+ patterns="$patterns|mbx_[A-Za-z0-9_-]{16,}"
49
+ patterns="$patterns|Bearer [A-Za-z0-9._-]{16,}"
50
+ patterns="$patterns|gh[pousr]_[A-Za-z0-9]{16,}"
51
+ patterns="$patterns|glpat-[A-Za-z0-9_-]{16,}"
52
+ patterns="$patterns|AKIA[0-9A-Z]{16}"
53
+ patterns="$patterns|BEGIN (RSA |OPENSSH |EC |DSA |PGP )?PRIVATE KEY"
54
+ # A name that ends in TOKEN, SECRET, PASSWORD or _KEY, maybe with more
55
+ # parts such as _FILE, then = or :, maybe a quote, then the value.
56
+ # _KEYWORD is no such name. A value that starts with / is a path, as a
57
+ # *_FILE setting names one.
58
+ patterns="$patterns|(TOKEN|SECRET|PASSWORD|_KEY)(_[A-Z]+)*[[:space:]]*[:=][[:space:]]*[\"']?[A-Za-z0-9+_-][A-Za-z0-9+/_.-]{11,}"
59
+ # The same in any case, as JSON and YAML write it: a name that ends in
60
+ # token, secret, password or _key, then = or :, then a quoted value, or a
61
+ # bare one that ends the line or a word. A bare value with a dot or a
62
+ # bracket is code, such as token = base64.b64encode(raw).
63
+ named="(^|[^a-z0-9])[\"']?[a-z0-9_]*(token|secret|password|passwd|_key)[\"']?"
64
+ named="$named[[:space:]]*[:=][[:space:]]*"
65
+ named="$named([\"'][A-Za-z0-9+_-][A-Za-z0-9+/_.-]{11,}|[A-Za-z0-9+_-][A-Za-z0-9+/_-]{11,}([[:space:]]|\$))"
66
+
67
+ added=$(git diff --cached -U0 | grep '^+' || true)
68
+ hits=$(
69
+ {
70
+ printf '%s\n' "$added" | grep -E "$patterns" || true
71
+ printf '%s\n' "$added" | grep -iE "$named" || true
72
+ } \
73
+ | awk '!seen[$0]++' \
74
+ | grep -v 'pragma: allowlist secret' \
75
+ || true
76
+ )
77
+ if [ -n "$hits" ]; then
78
+ note "staged lines look like a credential:"
79
+ printf '%s\n' "$hits" | cut -c 1-120 | sed 's/^/ /' >&2
80
+ fi
81
+
82
+ if [ "$fail" -ne 0 ]; then
83
+ printf 'pre-commit: nothing was committed (override with --no-verify).\n' >&2
84
+ exit 1
85
+ fi
@@ -0,0 +1,70 @@
1
+ version: 2
2
+ # Minor and patch updates arrive as one pull request per ecosystem and week
3
+ # instead of one each. A single run of the gates covers them together. A
4
+ # major update comes on its own, since that is where behaviour changes.
5
+ updates:
6
+ # Python dependencies. The ecosystem is "uv", not "pip", because the
7
+ # versions that get installed are the ones pinned in uv.lock, which the pip
8
+ # ecosystem does not read. Every requirement in pyproject.toml stays inside
9
+ # a patch window (`~=X.Y.Z`). A release past one needs the window moved,
10
+ # and that pull request is the place to check it.
11
+ - package-ecosystem: "uv"
12
+ directory: "/"
13
+ schedule:
14
+ interval: "weekly"
15
+ open-pull-requests-limit: 5
16
+ # A release the window allows changes uv.lock only, and one past it
17
+ # moves the window, as `~=` again, instead of widening it to a range.
18
+ versioning-strategy: increase-if-necessary
19
+ groups:
20
+ minor-and-patch:
21
+ patterns: ["*"]
22
+ update-types: ["minor", "patch"]
23
+ # Always alone: the suite mocks the mailbox service, so a change of
24
+ # its client is not seen by the tests. It wants a live check against
25
+ # the test account of containers/live (CLAUDE.md, Verifying). A
26
+ # release within the tested line changes uv.lock only. One of a new
27
+ # line fails tests/test_service_version.py until the line is added
28
+ # by the steps of docs/concept/mailbox-service.md.
29
+ exclude-patterns: ["benethos-mailbox-client"]
30
+
31
+ # The actions of the workflows, each pinned to a full commit SHA with its
32
+ # version in a trailing comment. Dependabot reads the comment and raises
33
+ # SHA and comment together.
34
+ - package-ecosystem: "github-actions"
35
+ directory: "/"
36
+ schedule:
37
+ interval: "weekly"
38
+ open-pull-requests-limit: 5
39
+ groups:
40
+ minor-and-patch:
41
+ patterns: ["*"]
42
+ update-types: ["minor", "patch"]
43
+
44
+ # The images of the Dockerfile, python and uv, pinned by digest beside
45
+ # their tag. A stale base is no build failure, it is unpatched packages in
46
+ # something people pull.
47
+ - package-ecosystem: "docker"
48
+ directory: "/containers/images/mailbox-agents"
49
+ schedule:
50
+ interval: "weekly"
51
+ open-pull-requests-limit: 5
52
+ groups:
53
+ minor-and-patch:
54
+ patterns: ["*"]
55
+ update-types: ["minor", "patch"]
56
+
57
+ # The images of the live setup's compose file: Stalwart, the mailbox
58
+ # service, LiteLLM, Postgres and llama.cpp, each pinned by digest. A bump
59
+ # of the mailbox service wants a live check as well, and one to a new
60
+ # line the steps of docs/concept/mailbox-service.md.
61
+ - package-ecosystem: "docker-compose"
62
+ directory: "/containers/live"
63
+ schedule:
64
+ interval: "weekly"
65
+ open-pull-requests-limit: 5
66
+ groups:
67
+ minor-and-patch:
68
+ patterns: ["*"]
69
+ update-types: ["minor", "patch"]
70
+ exclude-patterns: ["*benethos-mailbox-service*"]
@@ -0,0 +1,250 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+ pull_request:
7
+ branches: [main]
8
+
9
+ # Nothing here writes anything back but the coverage badge, which asks for
10
+ # its own permission. Without this the token gets whatever the repository
11
+ # default happens to be.
12
+ permissions:
13
+ contents: read
14
+
15
+ jobs:
16
+ # brand, lint, test, lowest-versions, audit, coverage-badge, codeql and
17
+ # dockerfile-lint are the organisation's reusable workflows in
18
+ # benethos-hub/.github, the same for every Python project there. They are
19
+ # followed at main on purpose, so a rule changed there applies here on the
20
+ # next run. What stays here is what only this project has: fresh-install
21
+ # and docker.
22
+
23
+ # assets/brand/icon.svg, and a 512x512 icon.png and a 1280x640
24
+ # social-preview.png rendered from it by assets/build.py, neither older
25
+ # than the SVG.
26
+ brand:
27
+ uses: benethos-hub/.github/.github/workflows/brand.yml@main
28
+
29
+ # uv.lock in step with pyproject.toml, ruff, the formatting and mypy. The
30
+ # dev tools are a dependency group, which uv sync takes by default.
31
+ lint:
32
+ uses: benethos-hub/.github/.github/workflows/python-lint.yml@main
33
+
34
+ # pytest on every supported Python against uv.lock, and on the newest the
35
+ # coverage with its floor of 80 %, which pyproject.toml sets as well. The
36
+ # suite is offline: the mailbox service and the gateway are mocked. live/
37
+ # is not collected, it is the only part that reaches a mail server.
38
+ #
39
+ # The versions are named here although the workflow has the same
40
+ # defaults: which Pythons this project supports is its own decision, in
41
+ # step with requires-python and the classifiers.
42
+ test:
43
+ uses: benethos-hub/.github/.github/workflows/python-tests.yml@main
44
+ with:
45
+ python-versions: '["3.11", "3.12", "3.13", "3.14", "3.15"]'
46
+ coverage-python: "3.15"
47
+ cov: benethos_mailbox_agents
48
+ badge: true
49
+ timeout-minutes: 10
50
+
51
+ # The coverage badge in the README, as coverage.json on the badges branch.
52
+ # On a push to main only, so it shows main's coverage and is no required
53
+ # check.
54
+ coverage-badge:
55
+ if: github.event_name == 'push'
56
+ needs: test
57
+ uses: benethos-hub/.github/.github/workflows/coverage-badge.yml@main
58
+ permissions:
59
+ contents: write # push coverage.json to the badges branch
60
+
61
+ # Every other job installs from uv.lock. This one resolves the dependencies
62
+ # the way a user does, from the wheel and without a lockfile, so a range in
63
+ # pyproject.toml that lets a breaking release in shows here and not after
64
+ # a release.
65
+ fresh-install:
66
+ runs-on: ubuntu-latest
67
+ timeout-minutes: 10
68
+ steps:
69
+ - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
70
+ with:
71
+ persist-credentials: false
72
+
73
+ - name: Install uv
74
+ uses: astral-sh/setup-uv@68559e99cc807c1eb7e9238fd43a15bba460eec2 # v10.3.3
75
+
76
+ - name: Build the wheel
77
+ run: uv build --wheel
78
+
79
+ - name: Install it into a clean environment and start it
80
+ run: |
81
+ set -euo pipefail
82
+ uv venv /tmp/fresh
83
+ uv pip install --python /tmp/fresh/bin/python dist/*.whl
84
+ echo "--- resolved dependency versions ---"
85
+ uv pip list --python /tmp/fresh/bin/python
86
+ echo "--- import, agents and entry point ---"
87
+ # An assertion, not a report: every agent the package ships is
88
+ # found, so a wheel that leaves an agent's prompts or modules out
89
+ # fails here.
90
+ /tmp/fresh/bin/python - <<'PY'
91
+ import benethos_mailbox_agents as package
92
+ from benethos_mailbox_agents.contract import discover
93
+
94
+ names = sorted(discover())
95
+ expected = ["awaiting_reply", "counting", "inquiries", "invoices", "sorting"]
96
+ assert names == expected, f"agents found: {names}"
97
+ print("version", package.__version__, "agents", ", ".join(names))
98
+ PY
99
+ /tmp/fresh/bin/benethos-mailbox-agents --help > /dev/null
100
+ echo "OK: a fresh install imports, finds its agents and starts"
101
+
102
+ # The other half of what fresh-install checks: every direct dependency at
103
+ # its declared lower bound, on the oldest supported Python, without the
104
+ # lockfile, and the tests against them. The test tools at the floors the
105
+ # dev group declares. The audit checks those versions as well. A red run
106
+ # means a lower bound in pyproject.toml needs raising.
107
+ lowest-versions:
108
+ uses: benethos-hub/.github/.github/workflows/python-lowest-versions.yml@main
109
+ with:
110
+ python-version: "3.11"
111
+ requirements: |
112
+ pytest>=9.1.1
113
+ pytest-cov>=7.1.0
114
+ pytest-asyncio>=1.5.0
115
+ audit: true
116
+ timeout-minutes: 10
117
+
118
+ # Every version pinned in uv.lock, for every platform and Python, against
119
+ # PyPI and OSV. GitHub's dependency graph does not read uv.lock, so nothing
120
+ # else covers the packages that land in the image.
121
+ audit:
122
+ uses: benethos-hub/.github/.github/workflows/python-dependency-audit.yml@main
123
+
124
+ # CodeQL on the Python code and on the workflows, with the security and the
125
+ # quality queries. Findings go to Security, Code scanning, and never fail
126
+ # this job, so it is no required check. codeql.yml runs the same analysis
127
+ # once a week.
128
+ codeql:
129
+ uses: benethos-hub/.github/.github/workflows/codeql.yml@main
130
+ permissions:
131
+ contents: read
132
+ security-events: write
133
+ with:
134
+ languages: python,actions
135
+
136
+ # hadolint over the Dockerfile. Findings go to Security, Code scanning, and
137
+ # the job stays green on them. The docker job below builds the image, this
138
+ # one reads the file.
139
+ dockerfile-lint:
140
+ uses: benethos-hub/.github/.github/workflows/dockerfile-lint.yml@main
141
+ permissions:
142
+ contents: read
143
+ security-events: write
144
+ with:
145
+ files: containers/**/Dockerfile
146
+ trusted-registries: docker.io ghcr.io
147
+
148
+ docker:
149
+ runs-on: ubuntu-latest
150
+ timeout-minutes: 20
151
+ steps:
152
+ - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
153
+ with:
154
+ persist-credentials: false
155
+
156
+ - name: Build image
157
+ run: docker build -f containers/images/mailbox-agents/Dockerfile -t benethos-mailbox-agents:ci .
158
+
159
+ # The image runs as uid 10001, starts, and every agent is in it. The
160
+ # agents need a mailbox service to do more, which the live checks of
161
+ # live/ bring, by hand.
162
+ - name: The image starts and holds every agent
163
+ run: |
164
+ set -euo pipefail
165
+ user=$(docker inspect -f '{{.Config.User}}' benethos-mailbox-agents:ci)
166
+ if [ "$user" != "10001" ]; then
167
+ echo "::error::the image runs as '$user', not as 10001"
168
+ exit 1
169
+ fi
170
+ docker run --rm --network none benethos-mailbox-agents:ci --help > /dev/null
171
+ docker run --rm --network none --entrypoint python benethos-mailbox-agents:ci -c "
172
+ from benethos_mailbox_agents.contract import discover
173
+ names = sorted(discover())
174
+ assert names == ['awaiting_reply', 'counting', 'inquiries', 'invoices', 'sorting'], names
175
+ print('OK: the image runs as 10001 and holds', ', '.join(names))
176
+ "
177
+
178
+ # No test reaches the Compose files. Both are read as compose resolves
179
+ # them, with every profile, and three things are asserted: that they
180
+ # are valid, that every published port stays on the loopback address,
181
+ # as the metrics have no authentication, and that each folder is what
182
+ # its name says: development builds from the checkout, production pulls
183
+ # the published image, and both keep the root file system read-only
184
+ # and drop every capability. The settings files compose reads are not
185
+ # versioned, so empty ones stand in for them.
186
+ - name: Compose files are valid, loopback only, and what their folder says
187
+ run: |
188
+ set -euo pipefail
189
+ mkdir -p containers/live/secrets
190
+ touch containers/live/secrets/agent.env
191
+ for agent in counting invoices awaiting_reply inquiries sorting; do
192
+ touch "containers/production/agents/$agent/.env"
193
+ done
194
+ docker compose -f containers/development/compose.yaml \
195
+ --profile invoices --profile sorting config --format json > /tmp/development.json
196
+ docker compose -f containers/production/compose.yaml \
197
+ --env-file containers/production/.env.example \
198
+ --profile counting --profile invoices --profile awaiting_reply \
199
+ --profile inquiries --profile sorting \
200
+ config --format json > /tmp/production.json
201
+ python3 - <<'PY'
202
+ import json
203
+
204
+ AGENTS = {"counting", "invoices", "awaiting_reply", "inquiries", "sorting"}
205
+ for folder in ("development", "production"):
206
+ services = json.load(open(f"/tmp/{folder}.json"))["services"]
207
+ assert services, f"the {folder} Compose file defines no services"
208
+ if folder == "production":
209
+ assert set(services) == AGENTS, f"production runs {sorted(services)}"
210
+ for name, service in services.items():
211
+ where = f"{folder}: {name}"
212
+ for port in service.get("ports") or []:
213
+ host_ip = port.get("host_ip")
214
+ assert host_ip in ("127.0.0.1", "::1"), (
215
+ f"{where} publishes port {port.get('published')} on "
216
+ f"{host_ip or 'every interface'}, not on the loopback address"
217
+ )
218
+ assert service.get("read_only") is True, f"{where} is not read-only"
219
+ assert service.get("cap_drop") == ["ALL"], f"{where} keeps capabilities"
220
+ if folder == "development":
221
+ assert "build" in service, f"{where} does not build from the checkout"
222
+ else:
223
+ assert "build" not in service, f"{where} builds instead of pulling"
224
+ assert service["image"].startswith(
225
+ "ghcr.io/benethos-hub/benethos-mailbox-agents:"
226
+ ), f"{where} runs {service['image']}, not the published image"
227
+ print(f"OK: {where} is loopback only, read-only and "
228
+ f"{'builds' if folder == 'development' else 'pulls'}")
229
+ PY
230
+
231
+ # publish.yml publishes linux/amd64 and linux/arm64, but only amd64 is
232
+ # built above, so an arm64 break would first show at a release. Build
233
+ # it here as well, into the cache scope buildkit a manual run of
234
+ # publish.yml reads. A release reads no cache.
235
+ # Nothing is loaded or pushed: that the build completes is the check.
236
+ - name: Set up QEMU
237
+ uses: docker/setup-qemu-action@99012661954931238ded8c8b007157a8430204e1 # v4.4.0
238
+
239
+ - name: Set up Buildx
240
+ uses: docker/setup-buildx-action@f87e5991a6d7451dcb8d9637bfbc97413f497069 # v4.4.1
241
+
242
+ - name: Build for arm64 as well
243
+ uses: docker/build-push-action@c3c9e263c25d99ce0380d002d59b67737d91b0dc # v7.4.0
244
+ with:
245
+ context: .
246
+ file: containers/images/mailbox-agents/Dockerfile
247
+ platforms: linux/arm64
248
+ push: false
249
+ cache-from: type=gha
250
+ cache-to: type=gha,mode=max
@@ -0,0 +1,25 @@
1
+ name: CodeQL
2
+
3
+ # The weekly half of the CodeQL analysis. The codeql job of ci.yml reads
4
+ # every change on the day it is made, with the queries of that day. GitHub
5
+ # adds and sharpens queries over time, and only a run on a schedule reads
6
+ # code nobody changed with them. Both file under the same category, so each
7
+ # run refreshes the analysis the last one left. Findings go to Security, Code
8
+ # scanning, and never fail the job.
9
+
10
+ on:
11
+ schedule:
12
+ - cron: "0 5 * * 1"
13
+ workflow_dispatch:
14
+
15
+ permissions:
16
+ contents: read
17
+
18
+ jobs:
19
+ codeql:
20
+ uses: benethos-hub/.github/.github/workflows/codeql.yml@main
21
+ permissions:
22
+ contents: read
23
+ security-events: write
24
+ with:
25
+ languages: python,actions
@@ -0,0 +1,75 @@
1
+ name: Freshness
2
+
3
+ # Two questions about the versions, answered once a day in one run and two
4
+ # issues, through the organisation's freshness workflow:
5
+ #
6
+ # * "Pinned versions have newer releases": every package uv.lock pins that
7
+ # has a newer release, within the patch windows and beyond them, the
8
+ # build backend, known vulnerabilities, the images of the Dockerfile and
9
+ # the compose files, and the actions pinned by commit.
10
+ # * "Newest dependency versions break the agents": the job newest installs
11
+ # the newest versions pyproject.toml allows, as a fresh install of the
12
+ # package does, and runs the tests on them.
13
+ #
14
+ # The run after each completed Publish is for the index job, once it is on:
15
+ # it installs the release just published from PyPI, so a release that does
16
+ # not install shows within minutes.
17
+ #
18
+ # Nothing here commits anything: the upgraded lockfile stays in the runner.
19
+
20
+ on:
21
+ schedule:
22
+ - cron: "30 4 * * *"
23
+ workflow_run:
24
+ workflows: [Publish]
25
+ types: [completed]
26
+ workflow_dispatch:
27
+
28
+ permissions:
29
+ contents: read
30
+
31
+ concurrency:
32
+ group: freshness
33
+
34
+ jobs:
35
+ newest:
36
+ name: Newest versions allowed
37
+ runs-on: ubuntu-latest
38
+ timeout-minutes: 20
39
+ steps:
40
+ - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
41
+ with:
42
+ persist-credentials: false
43
+
44
+ - name: Test the newest versions allowed
45
+ uses: benethos-hub/.github/actions/python/freshness-newest@main
46
+ with:
47
+ findings: ${{ runner.temp }}/freshness/newest
48
+ groups: dev
49
+
50
+ - name: Leave the result for the report
51
+ uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
52
+ with:
53
+ name: freshness-newest
54
+ path: ${{ runner.temp }}/freshness/newest
55
+ retention-days: 7
56
+
57
+ # Runs whatever happened before: a job that died before its upload is a
58
+ # line in the report, not a silent gap, since extra-jobs names it.
59
+ freshness:
60
+ name: Freshness report
61
+ needs: newest
62
+ if: ${{ !cancelled() }}
63
+ uses: benethos-hub/.github/.github/workflows/freshness.yml@main
64
+ permissions:
65
+ contents: read
66
+ issues: write
67
+ with:
68
+ issue-title: Pinned versions have newer releases
69
+ extra-jobs: newest
70
+ alarm-title: Newest dependency versions break the agents
71
+ alarm-resolved: The newest dependency versions work.
72
+ # Off until the first release is on PyPI: the index job installs the
73
+ # published package, and there is none yet. Then index: true, and
74
+ # index-check: $FRESHNESS_PYTHON -m benethos_mailbox_agents --help.
75
+ index: false
@@ -0,0 +1,130 @@
1
+ name: Publish
2
+
3
+ # Publishes a release when a GitHub release is published:
4
+ # * sdist and wheel to PyPI, through Trusted Publishing (OIDC, no stored
5
+ # token)
6
+ # * the container image to ghcr.io, through the GITHUB_TOKEN, as
7
+ # benethos-mailbox-agents, the name of the distribution, for linux/amd64
8
+ # and linux/arm64
9
+ #
10
+ # Each upload is done by an action of the organisation in
11
+ # benethos-hub/.github (actions/publish), followed at main like the CI
12
+ # workflows. The jobs stay here because PyPI trusts the workflow of the job
13
+ # that uploads. Every action first checks that the release tag is the
14
+ # version of pyproject.toml, as PEP 440 writes it: v0.1.0, v0.2.0a1.
15
+ #
16
+ # Nothing is built before ci-passed has found a green CI run of the push to
17
+ # main for this very commit. A version on PyPI cannot be replaced, and that
18
+ # run is the full CI with every required check. With audit, the gate checks
19
+ # uv.lock against PyPI and OSV once more. Waive a vulnerability in
20
+ # ignore-vulns there and in ci.yml alike.
21
+ #
22
+ # A manual run (workflow_dispatch) is the trial. pypi-trial builds and checks
23
+ # the package and asks PyPI whether it would take it, without uploading.
24
+ # ghcr-publish pushes the image as `edge`, from main only.
25
+ #
26
+ # One-time setup on PyPI: a pending publisher for the project
27
+ # benethos-mailbox-agents with
28
+ # Owner: benethos-hub
29
+ # Repository: mailbox-agents
30
+ # Workflow filename: publish.yml
31
+ # Environment: pypi-benethos-mailbox-agents
32
+ # and that environment on GitHub, open to tags v* only.
33
+ #
34
+ # One-time setup for ghcr, after the first push: a new package is private
35
+ # even when its repository is public. Switch it to public under the
36
+ # organisation's packages.
37
+ on:
38
+ release:
39
+ types: [published]
40
+ workflow_dispatch:
41
+
42
+ permissions:
43
+ contents: read
44
+
45
+ jobs:
46
+ # Waits up to 30 minutes for a CI run of ci.yml on main still in progress.
47
+ # On a manual run outside main it is skipped, together with everything
48
+ # that needs it.
49
+ ci-passed:
50
+ if: github.event_name == 'release' || github.ref == 'refs/heads/main'
51
+ uses: benethos-hub/.github/.github/workflows/python-release-ci-passed.yml@main
52
+ permissions:
53
+ actions: read # list the CI runs of this commit
54
+ contents: read
55
+ with:
56
+ audit: true
57
+
58
+ pypi-publish:
59
+ name: Build and publish to PyPI
60
+ # A version may be uploaded once only, so never by hand. The trial is
61
+ # pypi-trial.
62
+ if: github.event_name == 'release'
63
+ needs: ci-passed
64
+ runs-on: ubuntu-latest
65
+ timeout-minutes: 10
66
+ environment:
67
+ name: pypi-benethos-mailbox-agents
68
+ url: https://pypi.org/p/benethos-mailbox-agents
69
+ permissions:
70
+ contents: read
71
+ id-token: write # Trusted Publishing (OIDC)
72
+ steps:
73
+ - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
74
+ with:
75
+ persist-credentials: false
76
+ # The PEP 561 marker, and a prompt of an agent: a wheel without its
77
+ # prompts would import and fail only when the agent starts.
78
+ - uses: benethos-hub/.github/actions/publish/pypi@main
79
+ with:
80
+ wheel-contains: |
81
+ benethos_mailbox_agents/py.typed
82
+ benethos_mailbox_agents/agents/invoices/prompts/system.v4.md
83
+
84
+ # The PyPI half of a manual run, without the environment and without an
85
+ # OIDC token, since nothing is uploaded.
86
+ pypi-trial:
87
+ name: Build and check for PyPI (trial)
88
+ if: github.event_name == 'workflow_dispatch'
89
+ needs: ci-passed
90
+ runs-on: ubuntu-latest
91
+ timeout-minutes: 10
92
+ permissions:
93
+ contents: read
94
+ steps:
95
+ - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
96
+ with:
97
+ persist-credentials: false
98
+ - uses: benethos-hub/.github/actions/publish/pypi@main
99
+ with:
100
+ dry-run: true
101
+ wheel-contains: |
102
+ benethos_mailbox_agents/py.typed
103
+ benethos_mailbox_agents/agents/invoices/prompts/system.v4.md
104
+
105
+ ghcr-publish:
106
+ name: Build and publish the image
107
+ # A release, or a manual run on main.
108
+ if: github.event_name == 'release' || github.ref == 'refs/heads/main'
109
+ needs: ci-passed
110
+ runs-on: ubuntu-latest
111
+ timeout-minutes: 45
112
+ permissions:
113
+ contents: read
114
+ packages: write # push to ghcr.io as the GITHUB_TOKEN identity
115
+ steps:
116
+ - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
117
+ with:
118
+ persist-credentials: false
119
+ # arm64 is emulated on the amd64 runner. A manual run reads the layers
120
+ # the arm64 build of the docker job in ci.yml writes to the cache scope
121
+ # buildkit. A release reads none: every job on main can write that
122
+ # scope, also one that installs the newest dependencies before an
123
+ # audit saw them, so a release builds in a scope of its own run, which
124
+ # nothing wrote before (decided 2026-11-19). The action always uses a
125
+ # cache, an empty scope falls back to the image name.
126
+ - uses: benethos-hub/.github/actions/publish/ghcr@main
127
+ with:
128
+ image: benethos-mailbox-agents
129
+ dockerfile: containers/images/mailbox-agents/Dockerfile
130
+ cache-scope: ${{ github.event_name == 'release' && format('release-{0}', github.run_id) || 'buildkit' }}